Menu

[5dc849]: / src / utilities / DebugDevice.h  Maximize  Restore  History

Download this file

404 lines (369 with data), 16.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
#ifndef __DebugDevice__
#define __DebugDevice__
/*
GUIDO Library
Copyright (C) 2003, 2004 Grame
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
Grame Research Laboratory, 11, cours de Verdun Gensoul 69002 Lyon - France
research@grame.fr
*/
#include "DecoratorDevice.h"
#include "VGFont.h"
#include <iostream>
#include <fstream>
using namespace std;
// --------------------------------------------------------------
class DebugDevice : public DecoratorDevice
{
public:
DebugDevice(VGDevice& dev, const char* outfile=0) : DecoratorDevice(&dev, false), filestream(0)
{ if (outfile) filestream = new ofstream(outfile); }
DebugDevice(VGDevice * dev, const char* outfile=0) : DecoratorDevice(dev), filestream(0)
{ if (outfile) filestream = new ofstream(outfile); }
virtual ~DebugDevice()
{ if (filestream) { filestream->close(); delete filestream; } }
// Returns the ability of the current VGdevice to be drawn into.
virtual bool IsValid() const;
// - Drawing services
virtual bool BeginDraw();
virtual void EndDraw();
virtual void MoveTo(float x, float y);
virtual void LineTo(float x, float y);
virtual void Line(float x1, float y1, float x2, float y2);
virtual void Frame(float left, float top, float right, float bottom);
virtual void Arc(float left, float top, float right, float bottom, float startX, float startY, float endX, float endY);
virtual void Triangle(float x1, float y1, float x2, float y2, float x3, float y3);
virtual void Polygon(const float* xCoords, const float* yCoords, int count);
virtual void Rectangle(float left, float top, float right, float bottom);
// - Musical symbol services
virtual void SetMusicFont(const VGFont* font);
virtual const VGFont* GetMusicFont() const;
virtual void SetTextFont(const VGFont* font);
virtual const VGFont* GetTextFont() const;
// - Pen & brush services
virtual void SelectPen(const VGColor & inColor, float witdh);
virtual void SelectFillColor(const VGColor& c);
virtual void PushPen(const VGColor & inColor, float inWidth);
virtual void PopPen();
virtual void PushFillColor(const VGColor& inColor);
virtual void PopFillColor();
virtual void SetRasterOpMode(VRasterOpMode ROpMode);
virtual VRasterOpMode GetRasterOpMode() const;
// - Bitmap services (bit-block copy methods)
virtual bool CopyPixels(VGDevice* pSrcDC, float alpha = -1.0);
virtual bool CopyPixels(int xDest, int yDest,
VGDevice* pSrcDC,
int xSrc, int ySrc,
int nSrcWidth, int nSrcHeight, float alpha = -1.0);
virtual bool CopyPixels(int xDest, int yDest,
int dstWidth, int dstHeight,
VGDevice* pSrcDC, float alpha = -1.0);
// - Coordinate services
virtual void SetScale(float x, float y);
virtual void SetOrigin(float x, float y);
virtual void OffsetOrigin(float x, float y);
virtual void LogicalToDevice(float * x, float * y) const;
virtual void DeviceToLogical(float * x, float * y) const;
virtual float GetXScale() const;
virtual float GetYScale() const;
virtual float GetXOrigin() const;
virtual float GetYOrigin() const;
virtual void NotifySize(int inWidth, int inHeight);
virtual int GetWidth() const;
virtual int GetHeight() const;
// - Text and music symbols services
virtual void DrawMusicSymbol(float x, float y, unsigned int inSymbolID);
virtual void DrawString(float x, float y, const char * s, int inCharCount);
virtual void SetFontColor(const VGColor & inColor);
virtual VGColor GetFontColor() const;
virtual void SetFontBackgroundColor(const VGColor & inColor);
virtual VGColor GetFontBackgroundColor() const;
virtual void SetFontAlign(unsigned int inAlign);
virtual unsigned int GetFontAlign() const;
// - Printer informations services
virtual void SetDPITag(float inDPI);
virtual float GetDPITag() const;
virtual void* GetBitMapPixels();
virtual void ReleaseBitMapPixels();
virtual const char* GetImageData(const char* & outDataPtr, int& outLength);
virtual void ReleaseImageData(const char *) const;
virtual VGSystem * getVGSystem() const;
ofstream * filestream;
// - VGDevice extension
virtual void SelectPenColor(const VGColor & inColor);
virtual void SelectPenWidth(float witdh);
virtual void PushPenColor( const VGColor & inColor);
virtual void PopPenColor();
virtual void PushPenWidth( float width);
virtual void PopPenWidth();
};
#ifdef WIN32
# define dbgStream cout
#else
# define dbgStream (filestream ? (*filestream) : cout)
#endif
// --------------------------------------------------------------
inline bool DebugDevice::IsValid() const {
dbgStream << "Device::IsValid " << endl;
return fDevice ? fDevice->IsValid () : false;
}
// --------------------------------------------------------------
inline bool DebugDevice::BeginDraw() {
dbgStream << "Device::BeginDraw " << endl;
return (fDevice) ? fDevice->BeginDraw() : false;
return true;
}
inline void DebugDevice::EndDraw() {
dbgStream << "Device::EndDraw " << endl;
if (fDevice) fDevice->EndDraw();
}
// --------------------------------------------------------------
inline void DebugDevice::MoveTo( float x, float y ) {
dbgStream << "Device::MoveTo (" << x << ", " << y << ")" << endl;
if (fDevice) fDevice->MoveTo (x, y);
}
inline void DebugDevice::LineTo( float x, float y ) {
dbgStream << "Device::LineTo (" << x << ", " << y << ")" << endl;
if (fDevice) fDevice->LineTo (x, y);
}
inline void DebugDevice::Line( float x1, float y1, float x2, float y2 ) {
dbgStream << "Device::Line (" << x1 << ", " << y1 << ", " << x2 << ", " << y2 << ")" << endl;
if (fDevice) fDevice->Line (x1, y1, x2, y2);
}
inline void DebugDevice::Frame( float left, float top, float right, float bottom ) {
dbgStream << "Device::Frame (" << left << ", " << top << ", " << right << ", " << bottom << ")" << endl;
if (fDevice) fDevice->Frame (left, top, right, bottom);
}
inline void DebugDevice::Arc( float left, float top, float right, float bottom, float startX, float startY, float endX, float endY ) {
dbgStream << "Device::Arc (" << left << ", " << top << ", " << right << ", " << bottom << "," << startX << ", " << startY << ", " << endX << ", " << endY << ")" << endl;
if (fDevice) fDevice->Arc (left, top, right, bottom, startX, startY, endX, endY);
}
inline void DebugDevice::Triangle( float x1, float y1, float x2, float y2, float x3, float y3 ) {
dbgStream << "Device::Triangle (" << x1 << ", " << y1 << ", " << x2 << ", " << y2 << ", " << x3 << ", " << y3 << ")" << endl;
if (fDevice) fDevice->Triangle (x1, y1, x2, y2, x3, y3);
}
inline void DebugDevice::Polygon( const float * x, const float * y, int count ) {
dbgStream << "Device::Polygon count: " << count << endl;
if (fDevice) fDevice->Polygon (x, y, count);
}
inline void DebugDevice::Rectangle( float left, float top, float right, float bottom ) {
dbgStream << "Device::Rectangle (" << left << ", " << top << ", " << right << ", " << bottom << ")" << endl;
if (fDevice) fDevice->Rectangle (left, top, right, bottom);
}
// --------------------------------------------------------------
inline void DebugDevice::SetMusicFont(const VGFont * font) {
dbgStream << "Device::SetMusicFont " << (void*)font;
if (font) cout << " " << font->GetName() << " " << font->GetSize ();
cout << endl;
if (fDevice) fDevice->SetMusicFont(font);
}
inline const VGFont* DebugDevice::GetMusicFont() const {
dbgStream << "Device::GetMusicFont" << endl;
return (fDevice) ? fDevice->GetMusicFont(): NULL;
}
inline void DebugDevice::SetTextFont(const VGFont * font) {
dbgStream << "Device::SetTextFont " << (void*)font;
if (font) cout << " " << font->GetName() << " " << font->GetSize ();
cout << endl;
if (fDevice) fDevice->SetTextFont(font);
}
inline const VGFont* DebugDevice::GetTextFont() const {
dbgStream << "Device::GetTextFont" << endl;
return (fDevice) ? fDevice->GetTextFont(): NULL;
}
// --------------------------------------------------------------
inline void DebugDevice::SelectPen(const VGColor & inColor, float witdh) {
dbgStream << "Device::SelectPen (" << witdh << ")" << endl;
if (fDevice) fDevice->SelectPen(inColor, witdh);
}
inline void DebugDevice::SelectPenColor(const VGColor & inColor) {
dbgStream << "Device::SelectPenColor" << endl;
if (fDevice) fDevice->SelectPenColor(inColor);
}
inline void DebugDevice::SelectPenWidth(float witdh) {
dbgStream << "Device::SelectPenWidth (" << witdh << ")" << endl;
if (fDevice) fDevice->SelectPenWidth(witdh);
}
inline void DebugDevice::PushPenColor(const VGColor & inColor) {
dbgStream << "Device::PushPenColor " << inColor << endl;
if (fDevice) fDevice->PushPenColor(inColor);
}
inline void DebugDevice::PushPenWidth(float witdh) {
dbgStream << "Device::PushPenWidth (" << witdh << ")" << endl;
if (fDevice) fDevice->PushPenWidth(witdh);
}
inline void DebugDevice::PopPenColor() {
dbgStream << "Device::PopPenColor" << endl;
if (fDevice) fDevice->PopPenColor();
}
inline void DebugDevice::PopPenWidth() {
dbgStream << "Device::PopPenWidth" << endl;
if (fDevice) fDevice->PopPenWidth();
}
inline void DebugDevice::SelectFillColor(const VGColor & inColor) {
dbgStream << "Device::SelectFillColor " << inColor << endl;
if (fDevice) fDevice->SelectFillColor(inColor);
}
inline void DebugDevice::PushPen(const VGColor & inColor, float witdh) {
dbgStream << "Device::PushPen (" << witdh << ")" << endl;
if (fDevice) fDevice->PushPen(inColor, witdh);
}
inline void DebugDevice::PopPen() {
dbgStream << "Device::PopPen" << endl;
if (fDevice) fDevice->PopPen();
}
inline void DebugDevice::PushFillColor(const VGColor & inColor) {
dbgStream << "Device::PushFillColor " << inColor << endl;
if (fDevice) fDevice->PushFillColor(inColor);
}
inline void DebugDevice::PopFillColor() {
dbgStream << "Device::PopFillColor" << endl;
if (fDevice) fDevice->PopFillColor();
}
inline void DebugDevice::SetRasterOpMode(VGDevice::VRasterOpMode ROpMode) {
dbgStream << "Device::SetRasterOpMode (" << ROpMode << ")"<< endl;
if (fDevice) fDevice->SetRasterOpMode(ROpMode);
}
inline VGDevice::VRasterOpMode DebugDevice::GetRasterOpMode() const{
dbgStream << "Device::GetRasterOpMode" << endl;
return (fDevice) ? fDevice->GetRasterOpMode() : VGDevice::kUnknown;
}
// --------------------------------------------------------------
inline bool DebugDevice::CopyPixels(VGDevice* pSrcDC, float alpha) {
dbgStream << "Device::CopyPixels (" << alpha << ")" << endl;
return (fDevice) ? fDevice->CopyPixels(pSrcDC, alpha) : false;
}
inline bool DebugDevice::CopyPixels(int xDest, int yDest,
VGDevice* pSrcDC,
int xSrc, int ySrc,
int nSrcWidth, int nSrcHeight, float alpha) {
dbgStream << "Device::CopyPixels (" << xDest << ", " << yDest << ", " << xSrc << ", " << ySrc << ", " << nSrcWidth << ", " << nSrcHeight << ", " << alpha << ")" << endl;
return (fDevice) ? fDevice->CopyPixels(xDest, yDest, pSrcDC, xSrc, ySrc, nSrcWidth, nSrcHeight, alpha) : false;
}
inline bool DebugDevice::CopyPixels(int xDest, int yDest,
int dstWidth, int dstHeight,
VGDevice* pSrcDC, float alpha) {
dbgStream << "Device::CopyPixels (" << xDest << ", " << yDest << ", " << dstWidth << ", " << dstHeight << ", " << alpha << ")" << endl;
return (fDevice) ? fDevice->CopyPixels(xDest, yDest, dstWidth, dstHeight, pSrcDC, alpha) : false;
}
// --------------------------------------------------------------
inline void DebugDevice::SetScale(float x, float y) {
dbgStream << "Device::SetScale (" << x << ", " << y << ")" << endl;
if (fDevice) fDevice->SetScale(x, y);
}
inline void DebugDevice::SetOrigin(float x, float y) {
dbgStream << "Device::SetOrigin (" << x << ", " << y << ")" << endl;
if (fDevice) fDevice->SetOrigin(x, y);
}
inline void DebugDevice::OffsetOrigin(float x, float y) {
dbgStream << "Device::OffsetOrigin (" << x << ", " << y << ")" << endl;
if (fDevice) fDevice->OffsetOrigin(x, y);
}
inline void DebugDevice::LogicalToDevice(float * x, float * y) const {
if (fDevice) fDevice->LogicalToDevice(x, y);
dbgStream << "Device::LogicalToDevice (" << *x << ", " << *y << ")" << endl;
}
inline void DebugDevice::DeviceToLogical(float * x, float * y) const {
if (fDevice) fDevice->DeviceToLogical(x, y);
dbgStream << "Device::DeviceToLogical (" << *x << ", " << *y << ")" << endl;
}
inline float DebugDevice::GetXScale() const {
float xs = fDevice->GetXScale();
dbgStream << "Device::GetXScale -> " << xs << endl;
return xs;
}
inline float DebugDevice::GetYScale() const {
float ys = fDevice->GetYScale();
dbgStream << "Device::GetYScale -> " << ys << endl;
return ys;
}
inline float DebugDevice::GetXOrigin() const {
float x = fDevice->GetXOrigin();
dbgStream << "Device::GetXOrigin -> " << x << endl;
return x;
}
inline float DebugDevice::GetYOrigin() const {
float y = fDevice->GetYOrigin();
dbgStream << "Device::GetYOrigin -> " << y << endl;
return y;
}
inline void DebugDevice::NotifySize( int inWidth, int inHeight ) {
dbgStream << "Device::NotifySize (" << inWidth << ", " << inHeight << ")" << endl;
if (fDevice) fDevice->NotifySize (inWidth, inHeight);
}
inline int DebugDevice::GetWidth() const {
int width = fDevice->GetWidth();
dbgStream << "Device::GetWidth -> " << width << endl;
return width;
}
inline int DebugDevice::GetHeight() const {
int height = fDevice->GetHeight();
dbgStream << "Device::GetWidth -> " << height << endl;
return height;
}
// --------------------------------------------------------------
inline void DebugDevice::DrawMusicSymbol(float x, float y, unsigned int inSymbolID) {
dbgStream << "Device::DrawMusicSymbol (" << x << ", " << y << ", " << inSymbolID << ")" << endl;
if (fDevice) fDevice->DrawMusicSymbol(x, y, inSymbolID);
}
inline void DebugDevice::DrawString(float x, float y, const char * s, int inCharCount) {
dbgStream << "Device::DrawString (" << x << ", " << y << ", " << s << ", " << inCharCount << ")" << endl;
if (fDevice) fDevice->DrawString(x, y, s, inCharCount);
}
inline void DebugDevice::SetFontColor(const VGColor & inColor) {
dbgStream << "Device::SetFontColor " << inColor << endl;
if (fDevice) fDevice->SetFontColor(inColor);
}
inline VGColor DebugDevice::GetFontColor() const {
dbgStream << "Device::GetFontColor" << endl;
return (fDevice) ? fDevice->GetFontColor() : VGColor();
}
inline void DebugDevice::SetFontBackgroundColor(const VGColor & inColor) {
dbgStream << "Device::SetFontBackgroundColor" << inColor << endl;
if (fDevice) fDevice->SetFontBackgroundColor(inColor);
}
inline VGColor DebugDevice::GetFontBackgroundColor() const {
dbgStream << "Device::GetFontBackgroundColor" << endl;
return (fDevice) ? fDevice->GetFontBackgroundColor() : VGColor();
}
inline void DebugDevice::SetFontAlign(unsigned int inAlign) {
dbgStream << "Device::SetFontAlign " << inAlign << endl;
if (fDevice) fDevice->SetFontAlign(inAlign);
}
inline unsigned int DebugDevice::GetFontAlign() const {
dbgStream << "Device::GetFontAlign" << endl;
return (fDevice) ? fDevice->GetFontAlign() : 0;
}
// --------------------------------------------------------------
inline void DebugDevice::SetDPITag(float inDPI) {
dbgStream << "Device::SetDPITag" << endl;
if (fDevice) fDevice->SetDPITag(inDPI);
}
inline float DebugDevice::GetDPITag() const {
dbgStream << "Device::GetDPITag" << endl;
return (fDevice) ? fDevice->GetDPITag() : 0.f;
}
inline void* DebugDevice::GetBitMapPixels() {
dbgStream << "Device::GetBitMapPixels" << endl;
return (fDevice) ? fDevice->GetBitMapPixels() : NULL;
}
inline void DebugDevice::ReleaseBitMapPixels() {
dbgStream << "Device::ReleaseBitMapPixels" << endl;
if (fDevice) fDevice->ReleaseBitMapPixels();
}
inline const char* DebugDevice::GetImageData(const char* & outDataPtr, int& outLength) {
dbgStream << "Device::GetImageData" << endl;
if (fDevice) return fDevice->GetImageData(outDataPtr, outLength);
return 0;
}
inline void DebugDevice::ReleaseImageData(const char * ptr) const {
dbgStream << "Device::ReleaseImageData" << endl;
if (fDevice) fDevice->ReleaseImageData (ptr);
}
inline VGSystem * DebugDevice::getVGSystem() const {
dbgStream << "Device::getVGSystem" << endl;
return (fDevice) ? fDevice->getVGSystem() : NULL;
}
#endif
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.