Verovio
Source code documentation
vrv::SvgDeviceContext Class Reference

This class implements a drawing context for generating SVG files. More...

#include <svgdevicecontext.h>

Inheritance diagram for vrv::SvgDeviceContext:
vrv::DeviceContext

Public Member Functions

void SetCustomGraphicColor (const std::string &color) override
 Method for changing the color of a custom graphic.
 
void SetCustomGraphicAttributes (const std::string &data, const std::string &value) override
 Method for adding custom graphic data-* attributes.
 
void AppendIdAndClass (const std::string &gId, const std::string &baseClass, const std::string &addedClasses, GraphicID graphicID=PRIMARY)
 Add id, data-id and class attributes.
 
void AppendAdditionalAttributes (Object *object)
 Append additional attributes, as given in m_svgAdditionalAttributes.
 
bool UseGlobalStyling () override
 In SVG use global styling but not with mm output (for pdf generation)
 
void SetMMOutput (bool mmOutput)
 Setting mm output flag (false by default)
 
void SetFacsimile (bool facsimile)
 
bool GetFacsimile ()
 
void SetSvgBoundingBoxes (bool svgBoundingBoxes)
 Setting m_svgBoudingBoxes flag (false by default)
 
void SetSvgViewBox (bool svgViewBox)
 Setting m_svgViewBox flag (false by default)
 
void SetHtml5 (bool html5)
 Setting m_html5 flag (false by default)
 
void SetIndent (int indent)
 Setter for indent of the SVG (default is 3, -1 for tabs)
 
void SetFormatRaw (bool rawFormat)
 Set the SVG to have 'raw' formatting, with no extraneous whitespace or newlines.
 
void SetRemoveXlink (bool removeXlink)
 Removes the xlink: prefex on href attributes, necessary for some newer browsers.
 
void SetCss (const std::string &css)
 Setter for an additional CSS.
 
void SetAdditionalAttributes (const std::vector< std::string > &additionalAttributes)
 Copies additional attributes of defined elements to the SVG, each string in the form "elementName@attribute" (e.g., "note@pname")
 
void SetSmuflTextFont (option_SMUFLTEXTFONT smuflTextFont)
 Setter for a the smufl text font option.
 
Constructors, destructors, and other standard methods
 SvgDeviceContext (const std::string &docId)
 
virtual ~SvgDeviceContext ()
 
Setters
void SetBackground (int color, int style=PEN_SOLID) override
 
void SetBackgroundImage (void *image, double opacity=1.0) override
 
void SetBackgroundMode (int mode) override
 
void SetTextForeground (int color) override
 
void SetTextBackground (int color) override
 
void SetLogicalOrigin (int x, int y) override
 
Getters
Point GetLogicalOrigin () override
 
std::string GetStringSVG (bool xml_declaration=false)
 } More...
 
Drawing methods
void DrawQuadBezierPath (Point bezier[3]) override
 
void DrawCubicBezierPath (Point bezier[4]) override
 
void DrawCubicBezierPathFilled (Point bezier1[4], Point bezier2[4]) override
 
void DrawBentParallelogramFilled (Point side[4], int height) override
 
void DrawCircle (int x, int y, int radius) override
 
void DrawEllipse (int x, int y, int width, int height) override
 
void DrawEllipticArc (int x, int y, int width, int height, double start, double end) override
 
void DrawLine (int x1, int y1, int x2, int y2) override
 
void DrawPolyline (int n, Point points[], bool close) override
 
void DrawPolygon (int n, Point points[]) override
 
void DrawRectangle (int x, int y, int width, int height) override
 
void DrawRotatedText (const std::string &text, int x, int y, double angle) override
 
void DrawRoundedRectangle (int x, int y, int width, int height, int radius) override
 
void DrawText (const std::string &text, const std::u32string &wtext=U"", int x=VRV_UNSET, int y=VRV_UNSET, int width=VRV_UNSET, int height=VRV_UNSET) override
 
void DrawMusicText (const std::u32string &text, int x, int y, bool setSmuflGlyph=false) override
 
void DrawSpline (int n, Point points[]) override
 
void DrawGraphicUri (int x, int y, int width, int height, const std::string &uri) override
 
void DrawSvgShape (int x, int y, int width, int height, double scale, pugi::xml_node svg) override
 
void DrawBackgroundImage (int x=0, int y=0) override
 
Method for starting and ending a text
void StartText (int x, int y, data_HORIZONTALALIGNMENT alignment=HORIZONTALALIGNMENT_left) override
 
void EndText () override
 
Move a text to the specified position, for example when starting a new line.
void MoveTextTo (int x, int y, data_HORIZONTALALIGNMENT alignment) override
 
void MoveTextVerticallyTo (int y) override
 
Method for starting and ending a graphic
void StartGraphic (Object *object, const std::string &gClass, const std::string &gId, GraphicID graphicID=PRIMARY, bool prepend=false) override
 
void EndGraphic (Object *object, View *view) override
 
Method for starting and ending a graphic custom graphic that do not correspond to an Object
void StartCustomGraphic (const std::string &name, std::string gClass="", std::string gId="") override
 
void EndCustomGraphic () override
 
Methods for re-starting and ending a graphic for objects drawn in separate steps
void ResumeGraphic (Object *object, std::string gId) override
 
void EndResumedGraphic (Object *object, View *view) override
 
Method for starting and ending a text (<tspan>) text graphic
void StartTextGraphic (Object *object, const std::string &gClass, const std::string &gId) override
 
void EndTextGraphic (Object *object, View *view) override
 
Method for rotating a graphic (clockwise).
void RotateGraphic (Point const &orig, double angle) override
 
Method for starting and ending page
void StartPage () override
 
void EndPage () override
 
Method for adding description element
void AddDescription (const std::string &text) override
 
- Public Member Functions inherited from vrv::DeviceContext
virtual void DrawPlaceholder (int x, int y)
 Special method for forcing bounding boxes to be updated Used for invisible elements (e.g., <space>) that needs to be take into account in spacing.
 
 DeviceContext ()
 
 DeviceContext (ClassId classId)
 
virtual ~DeviceContext ()
 
ClassId GetClassId () const
 
bool Is (ClassId classId) const
 
const ResourcesGetResources (bool showWarning=false) const
 
bool HasResources () const
 
void SetResources (const Resources *resources)
 
void ResetResources ()
 
void SetWidth (int width)
 
void SetHeight (int height)
 
void SetContentHeight (int height)
 
void SetUserScale (double scaleX, double scaleY)
 
void SetBaseSize (int width, int height)
 
void SetViewBoxFactor (double ppuFactor)
 
int GetWidth () const
 
int GetHeight () const
 
int GetContentHeight () const
 
double GetUserScaleX ()
 
double GetUserScaleY ()
 
std::pair< int, int > GetBaseSize () const
 
double GetViewBoxFactor () const
 
void SetBrush (float opacity, int color=COLOR_NONE)
 
void SetPen (int width, PenStyle style, int dashLength=0, int gapLength=0, LineCapStyle lineCap=LINECAP_DEFAULT, LineJoinStyle lineJoin=LINEJOIN_DEFAULT, float opacity=1.0, int color=COLOR_NONE)
 
void SetFont (FontInfo *font)
 
void SetPushBack ()
 
void ResetBrush ()
 
void ResetPen ()
 
void ResetFont ()
 
void ResetPushBack ()
 
FontInfoGetFont ()
 
bool HasFont () const
 
virtual void GetTextExtent (const std::string &string, TextExtend *extend, bool typeSize)
 
virtual void GetTextExtent (const std::u32string &string, TextExtend *extend, bool typeSize)
 
virtual void GetSmuflTextExtent (const std::u32string &string, TextExtend *extend)
 
void DeactivateGraphic ()
 
void DeactivateGraphicX ()
 
void DeactivateGraphicY ()
 
void ReactivateGraphic ()
 

Additional Inherited Members

- Static Public Member Functions inherited from vrv::DeviceContext
static int RGB2Int (char red, char green, char blue)
 Color conversion method.
 
- Protected Attributes inherited from vrv::DeviceContext
std::stack< Penm_penStack
 
std::stack< Brushm_brushStack
 
std::stack< FontInfo * > m_fontStack
 
bool m_isDeactivatedX
 flag for indicating if the graphic is deactivated
 
bool m_isDeactivatedY
 
bool m_pushBack
 push back mode
 
Zonem_facsimile = NULL
 

Detailed Description

This class implements a drawing context for generating SVG files.

The music font is embedded by incorporating ./data/[fontname]/[glyph].xml glyphs within the SVG file.

Member Function Documentation

◆ GetStringSVG()

std::string vrv::SvgDeviceContext::GetStringSVG ( bool  xml_declaration = false)

}

Get the SVG into a string. Add the xml tag if necessary.


The documentation for this class was generated from the following file: