GUIDOLib  1.7.7
Guido Engine Internal Documentation
BinaryDevice.h
1 #ifndef __BinaryDevice__
2 #define __BinaryDevice__
3 
4 /*
5  GUIDO Library
6  Copyright (C) 2011 Grame
7 
8  This Source Code Form is subject to the terms of the Mozilla Public
9  License, v. 2.0. If a copy of the MPL was not distributed with this
10  file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 
12  Grame Research Laboratory, 11, cours de Verdun Gensoul 69002 Lyon - France
13  research@grame.fr
14 
15 */
16 
17 #include "GUIDOExport.h"
18 
19 #ifdef WIN32
20 # pragma warning (disable : 4275 4251)
21 #endif
22 
23 #include "VGDevice.h"
24 #include <ostream>
25 #include <fstream>
26 #include <string>
27 
34 // --------------------------------------------------------------
35 // BinaryDevice class
36 // --------------------------------------------------------------
40 class_export BinaryDevice : public VGDevice
41 {
42  BinarySystem* fSystem;
43  std::ostream& fStream;
44  int fWidth;
45  int fHeight;
46  const VGFont * fMusicFont;
47  const VGFont * fTextFont;
48  VRasterOpMode fOpMode;
49  float fXScale;
50  float fYScale;
51  float fXOrigin;
52  float fYOrigin;
53  unsigned int fFontAlign;
54  float fDPI;
57 
58  void writeColor (const VGColor& color) const;
59  void writeString (const char *str) const;
60  void writeFormattedImage (VGDevice* pSrcDC) const;
61  void writeRasterOpModeToString(VRasterOpMode mode) const;
62  void writeFont(const VGFont *font) const;
63  public:
64  BinaryDevice(std::ostream& outstream, BinarySystem* system);
65  virtual ~BinaryDevice();
66 
68  virtual bool IsValid() const { return true; }
69 
70 
71  // - Drawing services ------------------------------------------------
72  // 0
73  virtual bool BeginDraw();
74  // 1
75  virtual void EndDraw();
76  // 2
77  virtual void InvalidateRect( float left, float top, float right, float bottom );
78 
79  // - Standard graphic primitives -------------------------
80  // 3
81  virtual void MoveTo( float x, float y );
82  // 4
83  virtual void LineTo( float x, float y );
84  // 5
85  virtual void Line( float x1, float y1, float x2, float y2 );
86  // 6
87  virtual void Frame( float left, float top, float right, float bottom );
88  // 7
89  virtual void Arc( float left, float top, float right, float bottom,
90  float startX, float startY, float endX, float endY );
91 
92  // - Filled surfaces --------------------------------------
93  // 8
94  virtual void Triangle( float x1, float y1, float x2, float y2, float x3, float y3 );
95  // 9
96  virtual void Polygon( const float * xCoords, const float * yCoords, int count );
97  // 10
98  virtual void Rectangle( float left, float top, float right, float bottom );
99 
100  // - Font services ---------------------------------------------------
101  // 11
102  virtual void SetMusicFont( const VGFont * font );
103  // 12
104  virtual const VGFont * GetMusicFont() const;
105  // 13
106  virtual void SetTextFont( const VGFont * font );
107  // 14
108  virtual const VGFont * GetTextFont() const;
109 
110  // - Pen & brush services --------------------------------------------
111  // 15
112  virtual void SelectPen( const VGColor & inColor, float witdh );
113  // 16
114  virtual void SelectFillColor( const VGColor & c );
115  // 17
116  virtual void PushPen( const VGColor & inColor, float inWidth );
117  // 18
118  virtual void PopPen();
119  // 19
120  virtual void PushFillColor( const VGColor & inColor );
121  // 20
122  virtual void PopFillColor();
123  // 21
124  virtual void SetRasterOpMode( VRasterOpMode ROpMode);
125  // 22
126  virtual VRasterOpMode GetRasterOpMode() const;
127 
128 
129  // - Bitmap services (bit-block copy methods) --------------------------
130  // 23
131  virtual bool CopyPixels( VGDevice* pSrcDC, float alpha = -1.0);
132  // 24
133  virtual bool CopyPixels( int xDest, int yDest, VGDevice* pSrcDC, int xSrc, int ySrc,
134  int nSrcWidth, int nSrcHeight, float alpha = -1.0);
135  // 25
136  virtual bool CopyPixels( int xDest, int yDest, int dstWidth, int dstHeight,
137  VGDevice* pSrcDC, float alpha = -1.0);
138  // 26
139  virtual bool CopyPixels( int xDest, int yDest, int dstWidth, int dstHeight,
140  VGDevice* pSrcDC, int xSrc, int ySrc,
141  int nSrcWidth, int nSrcHeight, float alpha = -1.0);
142 
143  // - Coordinate services ------------------------------------------------
144  // 27
145  virtual void SetScale( float x, float y );
146  // 28
147  virtual void SetOrigin( float x, float y );
148  //29
149  virtual void OffsetOrigin( float x, float y );
150  // 30
151  virtual void LogicalToDevice( float * x, float * y ) const;
152  // 31
153  virtual void DeviceToLogical( float * x, float * y ) const;
154 
155  // 32
156  virtual float GetXScale() const;
157  // 33
158  virtual float GetYScale() const;
159  // 34
160  virtual float GetXOrigin() const;
161  // 35
162  virtual float GetYOrigin() const;
163 
164  // 36
165  virtual void NotifySize( int inWidth, int inHeight );
166  // 37
167  virtual int GetWidth() const;
168  // 38
169  virtual int GetHeight() const;
170 
171 
172  // - Text and music symbols services -------------------------------------
173  // 39
174  virtual void DrawMusicSymbol(float x, float y, unsigned int inSymbolID );
175  // 40
176  virtual void DrawString( float x, float y, const char * s, int inCharCount );
177 
178  // 41
179  virtual void SetFontColor( const VGColor & inColor );
180  // 42
181  virtual VGColor GetFontColor() const;
182  // 43
183  virtual void SetFontBackgroundColor( const VGColor & inColor );
184  // 44
185  virtual VGColor GetFontBackgroundColor() const;
186  // 45
187  virtual void SetFontAlign( unsigned int inAlign );
188  // 46
189  virtual unsigned int GetFontAlign() const;
190 
191  // - Printer informations services ----------------------------------------
192  // 47
193  virtual void SetDPITag( float inDPI );
194  // 48
195  virtual float GetDPITag() const;
196 
197  // ----------------------- never needed in abstract device ------------------
198  virtual void* GetBitMapPixels() { return 0; }
199  virtual void ReleaseBitMapPixels() {}
200  virtual const char* GetImageData(const char* & outDataPtr, int& outLength) { return 0; };
201  virtual void ReleaseImageData(const char *) const {}
202 
204  virtual VGSystem * getVGSystem() const { return (VGSystem *)fSystem; }
205 
206  // - Data export services ----------------------------------------
207  virtual void * GetNativeContext() const { return 0; }
208  // ----------------------- end "never needed in abstract device" ------------------
209 
210 
211  // - VGDevice extension --------------------------------------------
212  // 49
213  virtual void SelectPenColor( const VGColor & inColor);
214  // 50
215  virtual void SelectPenWidth( float witdh);
216  // 51
217  virtual void PushPenColor( const VGColor & inColor);
218  // 52
219  virtual void PopPenColor();
220  // 53
221  virtual void PushPenWidth( float width);
222  // 54
223  virtual void PopPenWidth();
224 
225  // - VGDevice extension --------------------------------------------
226  // 55
227  virtual void FrameEllipse( float x, float y, float width, float height);
228  // 56
229  virtual void Ellipse( float x, float y, float width, float height, const VGColor& color);
230 };
231 
234 #endif
PushPenWidth
virtual void PushPenWidth(float width)
fXScale
float fXScale
Definition: BinaryDevice.h:49
GetWidth
virtual int GetWidth() const
Arc
virtual void Arc(float left, float top, float right, float bottom, float startX, float startY, float endX, float endY)
DrawMusicSymbol
virtual void DrawMusicSymbol(float x, float y, unsigned int inSymbolID)
BinarySystem
class_export BinarySystem
Definition: BinarySystem.h:38
GetFontAlign
virtual unsigned int GetFontAlign() const
SelectFillColor
virtual void SelectFillColor(const VGColor &c)
GetNativeContext
virtual void * GetNativeContext() const
Definition: AbstractDevice.h:173
PushFillColor
virtual void PushFillColor(const VGColor &inColor)
ReleaseImageData
virtual void ReleaseImageData(const char *) const
Definition: AbstractDevice.h:167
LineTo
virtual void LineTo(float x, float y)
SetDPITag
virtual void SetDPITag(float inDPI)
GetFontColor
virtual VGColor GetFontColor() const
GetHeight
virtual int GetHeight() const
PushPen
virtual void PushPen(const VGColor &inColor, float inWidth)
InvalidateRect
virtual void InvalidateRect(float left, float top, float right, float bottom)
SelectPen
virtual void SelectPen(const VGColor &inColor, float witdh)
getVGSystem
virtual VGSystem * getVGSystem() const
temporary hack - must be removed asap
Definition: AbstractDevice.h:170
fYScale
float fYScale
Definition: BinaryDevice.h:50
LogicalToDevice
virtual void LogicalToDevice(float *x, float *y) const
FrameEllipse
virtual void FrameEllipse(float x, float y, float width, float height)
Frame
virtual void Frame(float left, float top, float right, float bottom)
GetYOrigin
virtual float GetYOrigin() const
PushPenColor
virtual void PushPenColor(const VGColor &inColor)
writeFont
void writeFont(const VGFont *font) const
GetMusicFont
virtual const VGFont * GetMusicFont() const
fFontAlign
unsigned int fFontAlign
Definition: BinaryDevice.h:53
SetFontColor
virtual void SetFontColor(const VGColor &inColor)
PopFillColor
virtual void PopFillColor()
Polygon
virtual void Polygon(const float *xCoords, const float *yCoords, int count)
SetMusicFont
virtual void SetMusicFont(const VGFont *font)
BinaryDevice
class_export BinaryDevice
An abstract drawing device, for use with higher level devices. outputs commands and their passed para...
Definition: BinaryDevice.h:33
fDPI
float fDPI
Definition: BinaryDevice.h:54
Triangle
virtual void Triangle(float x1, float y1, float x2, float y2, float x3, float y3)
fHeight
int fHeight
Definition: BinaryDevice.h:45
fWidth
int fWidth
Definition: BinaryDevice.h:44
writeRasterOpModeToString
void writeRasterOpModeToString(VRasterOpMode mode) const
GetImageData
virtual const char * GetImageData(const char *&outDataPtr, int &outLength)
Definition: AbstractDevice.h:166
GetBitMapPixels
virtual void * GetBitMapPixels()
Definition: AbstractDevice.h:164
writeFormattedImage
void writeFormattedImage(VGDevice *pSrcDC) const
NotifySize
virtual void NotifySize(int inWidth, int inHeight)
Ellipse
virtual void Ellipse(float x, float y, float width, float height, const VGColor &color)
Rectangle
virtual void Rectangle(float left, float top, float right, float bottom)
VGSystem
Generic pure virtual class for manipulating platform independant drawing devices and fonts.
Definition: VGSystem.h:61
fOpMode
VRasterOpMode fOpMode
Definition: BinaryDevice.h:48
SetScale
virtual void SetScale(float x, float y)
GetFontBackgroundColor
virtual VGColor GetFontBackgroundColor() const
OffsetOrigin
virtual void OffsetOrigin(float x, float y)
GetYScale
virtual float GetYScale() const
BeginDraw
virtual bool BeginDraw()
GetDPITag
virtual float GetDPITag() const
VGDevice
Generic platform independant drawing device.
Definition: VGDevice.h:68
VGColor
Generic class to manipulate device independant colors.
Definition: VGColor.h:34
SetOrigin
virtual void SetOrigin(float x, float y)
SetFontBackgroundColor
virtual void SetFontBackgroundColor(const VGColor &inColor)
IsValid
virtual bool IsValid() const
Returns the ability of the current VGdevice to be drawn into.
Definition: AbstractDevice.h:80
GetTextFont
virtual const VGFont * GetTextFont() const
MoveTo
virtual void MoveTo(float x, float y)
fTextFont
const VGFont * fTextFont
Definition: BinaryDevice.h:47
SetFontAlign
virtual void SetFontAlign(unsigned int inAlign)
writeString
void writeString(const char *str) const
SetTextFont
virtual void SetTextFont(const VGFont *font)
CopyPixels
virtual bool CopyPixels(VGDevice *pSrcDC, float alpha=-1.0)
fStream
std::ostream & fStream
Definition: BinaryDevice.h:43
EndDraw
virtual void EndDraw()
DrawString
virtual void DrawString(float x, float y, const char *s, int inCharCount)
fMusicFont
const VGFont * fMusicFont
Definition: BinaryDevice.h:46
PopPenColor
virtual void PopPenColor()
fXOrigin
float fXOrigin
Definition: BinaryDevice.h:51
SelectPenColor
virtual void SelectPenColor(const VGColor &inColor)
VGFont
Generic pure virtual & device-independant font class.
Definition: VGFont.h:36
PopPenWidth
virtual void PopPenWidth()
~BinaryDevice
virtual ~BinaryDevice()
PopPen
virtual void PopPen()
fYOrigin
float fYOrigin
Definition: BinaryDevice.h:52
GetRasterOpMode
virtual VRasterOpMode GetRasterOpMode() const
fFontBackgroundColor
VGColor fFontBackgroundColor
Definition: BinaryDevice.h:56
fFontColor
VGColor fFontColor
Definition: BinaryDevice.h:55
DeviceToLogical
virtual void DeviceToLogical(float *x, float *y) const
writeColor
void writeColor(const VGColor &color) const
ReleaseBitMapPixels
virtual void ReleaseBitMapPixels()
Definition: AbstractDevice.h:165
SetRasterOpMode
virtual void SetRasterOpMode(VRasterOpMode ROpMode)
SelectPenWidth
virtual void SelectPenWidth(float witdh)
GetXOrigin
virtual float GetXOrigin() const
Line
virtual void Line(float x1, float y1, float x2, float y2)
GetXScale
virtual float GetXScale() const

Guido Project Copyright © 2019 Grame-CNCM