GUIDOLib  1.6.8
A Music Score Rendering Engine
Public Types | Public Member Functions | Friends | List of all members
VGDevice Class Referenceabstract

Generic platform independant drawing device. More...

Public Types

enum  VRasterOpMode {
  kUnknown = 0, kOpCopy = 1, kOpAnd = 2, kOpXOr = 4,
  kOpInvert = 8, kOpOr = 16
}
 Raster operation modes (color fill, bit copy, etc.) More...
 
enum  VTextAlignMode {
  kAlignBase = 1, kAlignBottom = 2, kAlignTop = 4, kAlignCenter = 8,
  kAlignLeft = 16, kAlignRight = 32, kAlignBaseLeft = kAlignLeft | kAlignBase
}
 Text alignment modes. More...
 

Public Member Functions

virtual ~VGDevice ()
 
virtual bool IsValid () const =0
 Returns the ability of the current VGdevice to be drawn into. More...
 
virtual bool BeginDraw ()=0
 
virtual void EndDraw ()=0
 
virtual void InvalidateRect (float left, float top, float right, float bottom)=0
 
virtual void MoveTo (float x, float y)=0
 Moves the current position to the point specified by (x,y). More...
 
virtual void LineTo (float x, float y)=0
 
virtual void Line (float x1, float y1, float x2, float y2)=0
 
virtual void Frame (float left, float top, float right, float bottom)=0
 
virtual void Arc (float left, float top, float right, float bottom, float startX, float startY, float endX, float endY)=0
 
virtual void Triangle (float x1, float y1, float x2, float y2, float x3, float y3)=0
 
virtual void Polygon (const float *xCoords, const float *yCoords, int count)=0
 
virtual void Rectangle (float left, float top, float right, float bottom)=0
 
virtual void SetMusicFont (const VGFont *font)=0
 
virtual const VGFontGetMusicFont () const =0
 Returns the currently selected music VGFont. More...
 
virtual void SetTextFont (const VGFont *font)=0
 
virtual const VGFontGetTextFont () const =0
 Returns the currently selected text VGFont. More...
 
virtual void selectfont (int)
 Selects a font (only for SVG device). More...
 
virtual void SelectPen (const VGColor &inColor, float witdh)=0
 
virtual void SelectFillColor (const VGColor &c)=0
 
virtual void PushPen (const VGColor &inColor, float inWidth)=0
 
virtual void PopPen ()=0
 
virtual void PushFillColor (const VGColor &inColor)=0
 
virtual void PopFillColor ()=0
 
virtual void SetRasterOpMode (VRasterOpMode ROpMode)=0
 
virtual VRasterOpMode GetRasterOpMode () const =0
 
virtual bool CopyPixels (VGDevice *pSrcDC, float alpha=-1.0)=0
 
virtual bool CopyPixels (int xDest, int yDest, VGDevice *pSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, float alpha=-1.0)=0
 
virtual bool CopyPixels (int xDest, int yDest, int dstWidth, int dstHeight, VGDevice *pSrcDC, float alpha=-1.0)=0
 
virtual bool CopyPixels (int xDest, int yDest, int dstWidth, int dstHeight, VGDevice *pSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, float alpha=-1.0)=0
 
virtual void SetScale (float x, float y)=0
 Sets the scale factors of the current VGDevice to the input values. More...
 
virtual void SetOrigin (float x, float y)=0
 Specifies which VGDevice point (x,y) maps to the window origin (0,0). More...
 
virtual void OffsetOrigin (float x, float y)=0
 Offsets the current VGDevice's origin (see above). More...
 
virtual void LogicalToDevice (float *x, float *y) const =0
 
virtual void DeviceToLogical (float *x, float *y) const =0
 
virtual float GetXScale () const =0
 
virtual float GetYScale () const =0
 
virtual float GetXOrigin () const =0
 
virtual float GetYOrigin () const =0
 
virtual void NotifySize (int inWidth, int inHeight)=0
 
virtual int GetWidth () const =0
 Returns the width (set via NotifySize) of the current VGDevice. More...
 
virtual int GetHeight () const =0
 Returns the height (set via NotifySize) of the current VGDevice. More...
 
virtual void DrawMusicSymbol (float x, float y, unsigned int inSymbolID)=0
 
virtual void DrawString (float x, float y, const char *s, int inCharCount)=0
 
virtual void SetFontColor (const VGColor &inColor)=0
 Sets the text/music color for the current VGDevice. More...
 
virtual VGColor GetFontColor () const =0
 Returns the text/music color of the current VGDevice. More...
 
virtual void SetFontBackgroundColor (const VGColor &inColor)=0
 Sets the text/music background color for the current VGDevice. More...
 
virtual VGColor GetFontBackgroundColor () const =0
 Returns the text/music background color of the current VGDevice. More...
 
virtual void SetFontAlign (unsigned int inAlign)=0
 
virtual unsigned int GetFontAlign () const =0
 
virtual void SetDPITag (float inDPI)=0
 Sets the printing resolution of the current VGDevice. More...
 
virtual float GetDPITag () const =0
 Returns the printing resolution of the current VGDevice. More...
 
virtual void * GetBitMapPixels ()=0
 Allows pixels operations and returns a pointer to the bitmap pixels. More...
 
virtual void ReleaseBitMapPixels ()=0
 Update bitmap pixels and ends pixels operations. More...
 
virtual const char * GetImageData (const char *&outDataPtr, int &outLength)=0
 Gives the current device data and returns the data associated mime type. More...
 
virtual void ReleaseImageData (const char *) const =0
 Release the pointer returned by GetImageData. More...
 
virtual VGSystemgetVGSystem () const =0
 temporary hack - must be removed asap More...
 
virtual void * GetNativeContext () const =0
 Exports all graphical data to an image file. More...
 
virtual void SelectPenColor (const VGColor &inColor)=0
 Creates a new VGPen object with the specified VGColor. More...
 
virtual void SelectPenWidth (float witdh)=0
 Creates a new VGPen object with the specified VGColor. More...
 
virtual void PushPenColor (const VGColor &inColor)=0
 
virtual void PopPenColor ()=0
 
virtual void PushPenWidth (float width)=0
 
virtual void PopPenWidth ()=0
 

Friends

class VGFont
 
class DecoratorDevice
 

Detailed Description

Generic platform independant drawing device.

VGDevice is a pure virtual class that declares the minimal set of methods required by the GGR (Guido Graphic Representation) objects to communicate their graphical operations. Implementations of VGDevice derived classes must then be provided by client applications.

VGDevice thus provides standard graphic functions (Lines, Arc, Rectangles, Polygons, Text), coordinate transformation (zoom / scaling), and symbolic music symbols handlers.

A VGDevice can be seen as the association of:

- a drawing context, describing how these operations are
performed, including pen and color state;

- a graphic 'device' ('port' or 'output'), describing
'where' the graphical operations are to be performed
(these various outputs can be a screen, an offscreen
pixmap, a printer, a file, a network stream, etc.);

- a 'link-to-guido' class allowing the client app to
collect informations about the score and give them to
the guido engine (see Set/GetSymbolMap).

To allow using a VGDevice for double buffering mechanism, it also provides bit-block copy operations from one VGDevice to another.

Each VGDevice needs to be dynamicaly associated with external music and text VGFont objects, using the appropriate SetFont() method. Here we have to repeat that Guido, for higher abstraction, makes a clear distinction between text characters and music symbols, although music symbols are generally glyphs in a music font.

Member Enumeration Documentation

◆ VRasterOpMode

Raster operation modes (color fill, bit copy, etc.)

Enumerator
kUnknown 
kOpCopy 
kOpAnd 
kOpXOr 
kOpInvert 
kOpOr 

◆ VTextAlignMode

Text alignment modes.

Enumerator
kAlignBase 
kAlignBottom 
kAlignTop 
kAlignCenter 
kAlignLeft 
kAlignRight 
kAlignBaseLeft 

Constructor & Destructor Documentation

◆ ~VGDevice()

virtual VGDevice::~VGDevice ( )
inlinevirtual

Member Function Documentation

◆ Arc()

virtual void VGDevice::Arc ( float  left,
float  top,
float  right,
float  bottom,
float  startX,
float  startY,
float  endX,
float  endY 
)
pure virtual

Draws a counter-clockwise elliptical arc between the startX, startY, endX & endY coordinates and inside the [left, top, right, bottom] elliptical bounding box. The distance from these points to the middle of the ellipse is not important, only the angle is taken in account.

◆ BeginDraw()

virtual bool VGDevice::BeginDraw ( )
pure virtual

Prepares the device's context before a set of drawing operations and saves the current one (like the previous SaveDC() method). This method should be used before every set of drawing operation.

◆ CopyPixels() [1/4]

virtual bool VGDevice::CopyPixels ( int  xDest,
int  yDest,
int  dstWidth,
int  dstHeight,
VGDevice pSrcDC,
float  alpha = -1.0 
)
pure virtual

Copies a pixmap from a source rectangle into a destination rectangle, stretching or compressing the pixmap to fit the dimensions of the destination rectangle, if necessary. The method stretches or compresses the pixmap using the raster mode currently set in the destination VGdevice. Default alpha (-1.0) means copying bits using their own transparency values, if any; if no alpha channel value is available, opaque copy (alpha = 1.0) is performed.

◆ CopyPixels() [2/4]

virtual bool VGDevice::CopyPixels ( int  xDest,
int  yDest,
int  dstWidth,
int  dstHeight,
VGDevice pSrcDC,
int  xSrc,
int  ySrc,
int  nSrcWidth,
int  nSrcHeight,
float  alpha = -1.0 
)
pure virtual

Copies a pixmap from a source rectangle into a destination rectangle, stretching or compressing the pixmap to fit the dimensions of the destination rectangle, if necessary. The method stretches or compresses the pixmap using the raster mode currently set in the destination VGdevice. Default alpha (-1.0) means copying bits using their own transparency values, if any; if no alpha channel value is available, opaque copy (alpha = 1.0) is performed.

◆ CopyPixels() [3/4]

virtual bool VGDevice::CopyPixels ( int  xDest,
int  yDest,
VGDevice pSrcDC,
int  xSrc,
int  ySrc,
int  nSrcWidth,
int  nSrcHeight,
float  alpha = -1.0 
)
pure virtual

Makes the exact copy of the content (pixmap) of the specified rectangle from the pSrcDC source VGDevice to the specified destination of the current device. The raster operation mode should be specified using SetRasterOpMode(). Default alpha (-1.0) means copying bits using their own transparency values, if any; if no alpha channel value is available, opaque copy (alpha = 1.0) is performed.

◆ CopyPixels() [4/4]

virtual bool VGDevice::CopyPixels ( VGDevice pSrcDC,
float  alpha = -1.0 
)
pure virtual

Copies the entire content (pixmap) of the pSrcDC source VGDevice to the current device. The raster operation mode should be specified using SetRasterOpMode(). Default alpha (-1.0) means copying bits using their own transparency values, if any; if no alpha channel value is available, opaque copy (alpha = 1.0) is performed.

◆ DeviceToLogical()

virtual void VGDevice::DeviceToLogical ( float *  x,
float *  y 
) const
pure virtual

Computes input VGDevice coordinates to get their values outside its VGDevice coordinate system.

◆ DrawMusicSymbol()

virtual void VGDevice::DrawMusicSymbol ( float  x,
float  y,
unsigned int  inSymbolID 
)
pure virtual

Writes the music symbol specified by the input inSymbolID at the specified location, using the currently selected music font, background color, and text color.

◆ DrawString()

virtual void VGDevice::DrawString ( float  x,
float  y,
const char *  s,
int  inCharCount 
)
pure virtual

Writes the specified inCharCount number of text characters at the specified location, using the currently selected text font, background color, and text color.

◆ EndDraw()

virtual void VGDevice::EndDraw ( )
pure virtual

Restores the device's context after a set of drawing operations. and restore the previous one (like the previous RestoreDC() method). This method should be used after every set of drawing operation.

◆ Frame()

virtual void VGDevice::Frame ( float  left,
float  top,
float  right,
float  bottom 
)
pure virtual

Draws a frame using the specified coordinates. The frame is outlined by using the current pen, but not filled.

◆ GetBitMapPixels()

virtual void* VGDevice::GetBitMapPixels ( )
pure virtual

Allows pixels operations and returns a pointer to the bitmap pixels.

◆ GetDPITag()

virtual float VGDevice::GetDPITag ( ) const
pure virtual

Returns the printing resolution of the current VGDevice.

◆ GetFontAlign()

virtual unsigned int VGDevice::GetFontAlign ( ) const
pure virtual

Returns the text/music alignment mode of the current VGDevice. See enum VTextAlignMode above.

◆ GetFontBackgroundColor()

virtual VGColor VGDevice::GetFontBackgroundColor ( ) const
pure virtual

Returns the text/music background color of the current VGDevice.

◆ GetFontColor()

virtual VGColor VGDevice::GetFontColor ( ) const
pure virtual

Returns the text/music color of the current VGDevice.

◆ GetHeight()

virtual int VGDevice::GetHeight ( ) const
pure virtual

Returns the height (set via NotifySize) of the current VGDevice.

◆ GetImageData()

virtual const char* VGDevice::GetImageData ( const char *&  outDataPtr,
int &  outLength 
)
pure virtual

Gives the current device data and returns the data associated mime type.

◆ GetMusicFont()

virtual const VGFont* VGDevice::GetMusicFont ( ) const
pure virtual

Returns the currently selected music VGFont.

◆ GetNativeContext()

virtual void* VGDevice::GetNativeContext ( ) const
pure virtual

Exports all graphical data to an image file.

Returns the platform-specific device context object.

◆ GetRasterOpMode()

virtual VRasterOpMode VGDevice::GetRasterOpMode ( ) const
pure virtual

Retrieves the foreground mix mode of the specified device. The mix mode specifies how the pen or interior color and the color already on the device are combined to yield a new color.

◆ GetTextFont()

virtual const VGFont* VGDevice::GetTextFont ( ) const
pure virtual

Returns the currently selected text VGFont.

◆ getVGSystem()

virtual VGSystem* VGDevice::getVGSystem ( ) const
pure virtual

temporary hack - must be removed asap

◆ GetWidth()

virtual int VGDevice::GetWidth ( ) const
pure virtual

Returns the width (set via NotifySize) of the current VGDevice.

◆ GetXOrigin()

virtual float VGDevice::GetXOrigin ( ) const
pure virtual

◆ GetXScale()

virtual float VGDevice::GetXScale ( ) const
pure virtual

GetXScale, GetYScale, GetXOrigin, GetYOrigin : get VGDevice's scaling/coordinate atributes.

◆ GetYOrigin()

virtual float VGDevice::GetYOrigin ( ) const
pure virtual

◆ GetYScale()

virtual float VGDevice::GetYScale ( ) const
pure virtual

◆ InvalidateRect()

virtual void VGDevice::InvalidateRect ( float  left,
float  top,
float  right,
float  bottom 
)
pure virtual

Invalidate a rectangle i.e. indicates the native graphic device that the corresponding rectangle needs to be refreshed.

◆ IsValid()

virtual bool VGDevice::IsValid ( ) const
pure virtual

Returns the ability of the current VGdevice to be drawn into.

◆ Line()

virtual void VGDevice::Line ( float  x1,
float  y1,
float  x2,
float  y2 
)
pure virtual

Draws a line from the position specified by (x1,y1) up to, but not including, the point specified by (x2,y2).

◆ LineTo()

virtual void VGDevice::LineTo ( float  x,
float  y 
)
pure virtual

Draws a line from the current position up to, but not including, the point specified by (x,y).

◆ LogicalToDevice()

virtual void VGDevice::LogicalToDevice ( float *  x,
float *  y 
) const
pure virtual

Computes input coordinates to get their values in the current VGDevice coordinate system.

◆ MoveTo()

virtual void VGDevice::MoveTo ( float  x,
float  y 
)
pure virtual

Moves the current position to the point specified by (x,y).

◆ NotifySize()

virtual void VGDevice::NotifySize ( int  inWidth,
int  inHeight 
)
pure virtual

Sets the size of the current VGDevice. Use this method to update the derived device's attributes and actual size.

◆ OffsetOrigin()

virtual void VGDevice::OffsetOrigin ( float  x,
float  y 
)
pure virtual

Offsets the current VGDevice's origin (see above).

◆ Polygon()

virtual void VGDevice::Polygon ( const float *  xCoords,
const float *  yCoords,
int  count 
)
pure virtual

Draws a polygon consisting of count vertices connected by straight lines. The polygon is NOT outlined but simply filled using the current fill color.

◆ PopFillColor()

virtual void VGDevice::PopFillColor ( )
pure virtual

Restores the previous color brush from the stack into the current VGDevice. This method was previously called PopBrush().

◆ PopPen()

virtual void VGDevice::PopPen ( )
pure virtual

Restores the previous VGPen object from the stack into the current VGDevice.

◆ PopPenColor()

virtual void VGDevice::PopPenColor ( )
pure virtual

◆ PopPenWidth()

virtual void VGDevice::PopPenWidth ( )
pure virtual

◆ PushFillColor()

virtual void VGDevice::PushFillColor ( const VGColor inColor)
pure virtual

Saves the current color brush and selects the new one using the specified VGColor into the current VGDevice. This method was previously called PushBrush().

◆ PushPen()

virtual void VGDevice::PushPen ( const VGColor inColor,
float  inWidth 
)
pure virtual

Saves the current VGPen and selects the new one using the specified VGColor and width into the current VGDevice.

◆ PushPenColor()

virtual void VGDevice::PushPenColor ( const VGColor inColor)
pure virtual

◆ PushPenWidth()

virtual void VGDevice::PushPenWidth ( float  width)
pure virtual

◆ Rectangle()

virtual void VGDevice::Rectangle ( float  left,
float  top,
float  right,
float  bottom 
)
pure virtual

Draws a rectangle. The rectangle is NOT outlined but simply filled using the current fill color.

◆ ReleaseBitMapPixels()

virtual void VGDevice::ReleaseBitMapPixels ( )
pure virtual

Update bitmap pixels and ends pixels operations.

◆ ReleaseImageData()

virtual void VGDevice::ReleaseImageData ( const char *  ) const
pure virtual

Release the pointer returned by GetImageData.

◆ SelectFillColor()

virtual void VGDevice::SelectFillColor ( const VGColor c)
pure virtual

Creates a new solid brush (to paint the interiors of filled shapes) with the specified VGColor and selects it into the current VGDevice. This method was previously called SelectBrush().

◆ selectfont()

virtual void VGDevice::selectfont ( int  )
inlinevirtual

Selects a font (only for SVG device).

◆ SelectPen()

virtual void VGDevice::SelectPen ( const VGColor inColor,
float  witdh 
)
pure virtual

Creates a new VGPen object with the specified VGColor and width and selects it into the current VGDevice.

◆ SelectPenColor()

virtual void VGDevice::SelectPenColor ( const VGColor inColor)
pure virtual

Creates a new VGPen object with the specified VGColor.

◆ SelectPenWidth()

virtual void VGDevice::SelectPenWidth ( float  witdh)
pure virtual

Creates a new VGPen object with the specified VGColor.

◆ SetDPITag()

virtual void VGDevice::SetDPITag ( float  inDPI)
pure virtual

Sets the printing resolution of the current VGDevice.

◆ SetFontAlign()

virtual void VGDevice::SetFontAlign ( unsigned int  inAlign)
pure virtual

Sets the text/music alignment mode of the current VGDevice. See enum VTextAlignMode above.

◆ SetFontBackgroundColor()

virtual void VGDevice::SetFontBackgroundColor ( const VGColor inColor)
pure virtual

Sets the text/music background color for the current VGDevice.

◆ SetFontColor()

virtual void VGDevice::SetFontColor ( const VGColor inColor)
pure virtual

Sets the text/music color for the current VGDevice.

◆ SetMusicFont()

virtual void VGDevice::SetMusicFont ( const VGFont font)
pure virtual

Selects the specified music VGFont into the current VGDevice. Warning ! this method doesn't return the previously selected font anymore. Use GetMusicFont() instead.

◆ SetOrigin()

virtual void VGDevice::SetOrigin ( float  x,
float  y 
)
pure virtual

Specifies which VGDevice point (x,y) maps to the window origin (0,0).

◆ SetRasterOpMode()

virtual void VGDevice::SetRasterOpMode ( VRasterOpMode  ROpMode)
pure virtual

Sets the current foreground mix mode. We use the foreground mix mode to combine pens and interiors of filled objects with the colors already on the device. The foreground mix mode defines how colors from the brush or pen and the colors in the existing image are to be combined. See enum VRasterOpMode above.

◆ SetScale()

virtual void VGDevice::SetScale ( float  x,
float  y 
)
pure virtual

Sets the scale factors of the current VGDevice to the input values.

◆ SetTextFont()

virtual void VGDevice::SetTextFont ( const VGFont font)
pure virtual

Selects the specified text VGFont into the current VGDevice. Warning ! this method doesn't return the previously selected font anymore. Use GetMusicFont() instead.

◆ Triangle()

virtual void VGDevice::Triangle ( float  x1,
float  y1,
float  x2,
float  y2,
float  x3,
float  y3 
)
pure virtual

Draws a triangle consisting of three points connected by straight lines. The triangle is NOT outlined but simply filled using the current fill color.

Friends And Related Function Documentation

◆ DecoratorDevice

friend class DecoratorDevice
friend

◆ VGFont

friend class VGFont
friend

Guido Project Copyright © 2019 Grame-CNCM