 |
Verovio
Source code documentation
|
8 #ifndef __VRV_SVG_DC_H__
9 #define __VRV_SVG_DC_H__
19 #include "devicecontext.h"
52 void SetBackground(
int color,
int style = PEN_SOLID)
override;
54 void SetBackgroundImage(
void *image,
double opacity = 1.0)
override;
55 void SetBackgroundMode(
int mode)
override;
56 void SetTextForeground(
int color)
override;
57 void SetTextBackground(
int color)
override;
58 void SetLogicalOrigin(
int x,
int y)
override;
64 Point GetLogicalOrigin()
override;
77 void DrawQuadBezierPath(
Point bezier[3])
override;
79 void DrawCubicBezierPath(
Point bezier[4])
override;
80 void DrawCubicBezierPathFilled(
Point bezier1[4],
Point bezier2[4])
override;
81 void DrawBentParallelogramFilled(
Point side[4],
int height)
override;
82 void DrawCircle(
int x,
int y,
int radius)
override;
83 void DrawEllipse(
int x,
int y,
int width,
int height)
override;
84 void DrawEllipticArc(
int x,
int y,
int width,
int height,
double start,
double end)
override;
85 void DrawLine(
int x1,
int y1,
int x2,
int y2)
override;
86 void DrawPolyline(
int n,
Point points[],
bool close)
override;
87 void DrawPolygon(
int n,
Point points[])
override;
88 void DrawRectangle(
int x,
int y,
int width,
int height)
override;
89 void DrawRotatedText(
const std::string &text,
int x,
int y,
double angle)
override;
90 void DrawRoundedRectangle(
int x,
int y,
int width,
int height,
int radius)
override;
91 void DrawText(
const std::string &text,
const std::u32string &wtext = U
"",
int x = VRV_UNSET,
int y = VRV_UNSET,
92 int width = VRV_UNSET,
int height = VRV_UNSET)
override;
93 void DrawMusicText(
const std::u32string &text,
int x,
int y,
bool setSmuflGlyph =
false)
override;
94 void DrawSpline(
int n,
Point points[])
override;
95 void DrawGraphicUri(
int x,
int y,
int width,
int height,
const std::string &uri)
override;
96 void DrawSvgShape(
int x,
int y,
int width,
int height,
double scale, pugi::xml_node svg)
override;
97 void DrawBackgroundImage(
int x = 0,
int y = 0)
override;
103 void StartText(
int x,
int y, data_HORIZONTALALIGNMENT alignment = HORIZONTALALIGNMENT_left)
override;
105 void EndText()
override;
110 void MoveTextTo(
int x,
int y, data_HORIZONTALALIGNMENT alignment)
override;
112 void MoveTextVerticallyTo(
int y)
override;
118 void StartGraphic(
Object *
object,
const std::string &gClass,
const std::string &gId, GraphicID graphicID = PRIMARY,
120 bool prepend =
false)
override;
121 void EndGraphic(
Object *
object,
View *view)
override;
127 void StartCustomGraphic(
const std::string &name, std::string gClass =
"", std::string gId =
"")
override;
129 void EndCustomGraphic()
override;
145 void ResumeGraphic(
Object *
object, std::string gId)
override;
147 void EndResumedGraphic(
Object *
object,
View *view)
override;
153 void StartTextGraphic(
Object *
object,
const std::string &gClass,
const std::string &gId)
override;
155 void EndTextGraphic(
Object *
object,
View *view)
override;
161 void RotateGraphic(
Point const &orig,
double angle)
override;
168 void StartPage()
override;
170 void EndPage()
override;
176 void AddDescription(
const std::string &text)
override;
183 void AppendIdAndClass(
const std::string &gId,
const std::string &baseClass,
const std::string &addedClasses,
184 GraphicID graphicID = PRIMARY);
201 void SetFacsimile(
bool facsimile) { m_facsimile = facsimile; }
202 bool GetFacsimile() {
return m_facsimile; }
240 this->PrefixCssRules(m_css);
249 for (std::string s : additionalAttributes) {
250 std::string className = s.substr(0, s.find(
"@"));
251 std::string attributeName = s.substr(s.find(
"@") + 1);
253 m_svgAdditionalAttributes.insert({ classId, attributeName });
260 void SetSmuflTextFont(option_SMUFLTEXTFONT smuflTextFont) { m_smuflTextFont = smuflTextFont; }
267 bool CopyFileToStream(
const std::string &filename, std::ostream &dest);
272 void DrawSvgBoundingBox(
Object *
object,
View *view);
277 void DrawSvgBoundingBoxRectangle(
int x,
int y,
int width,
int height);
282 void VrvTextFont() { m_vrvTextFont =
true; }
287 void VrvTextFontFallback() { m_vrvTextFontFallback =
true; }
292 void IncludeTextFont(
const std::string &fontname,
const Resources *resources);
298 void Commit(
bool xml_declaration);
300 void WriteLine(std::string);
302 std::string GetColor(
int color)
const;
304 pugi::xml_node AddChild(std::string name);
309 void AppendStrokeLineCap(pugi::xml_node node,
const Pen &pen);
311 void AppendStrokeLineJoin(pugi::xml_node node,
const Pen &pen);
312 void AppendStrokeDashArray(pugi::xml_node node,
const Pen &pen);
318 void PrefixCssRules(std::string &rules);
333 bool m_vrvTextFontFallback;
339 std::ostringstream m_outdata;
342 int m_originX, m_originY;
355 GlyphRef(
const Glyph *glyph,
int count,
const std::string &postfix);
356 const Glyph *GetGlyph()
const {
return m_glyph; };
357 const std::string &GetRefId()
const {
return m_refId; };
360 const Glyph *m_glyph;
363 const std::string InsertGlyphRef(
const Glyph *glyph);
364 std::map<const Glyph *, GlyphRef> m_smuflGlyphs;
365 std::map<std::string, int> m_glyphCodeFontCounter;
368 pugi::xml_document m_svgDoc;
369 pugi::xml_node m_svgNode;
370 pugi::xml_node m_pageNode;
371 pugi::xml_node m_currentNode;
372 std::list<pugi::xml_node> m_svgNodeStack;
378 bool m_svgBoundingBoxes;
386 std::multimap<ClassId, std::string> m_svgAdditionalAttributes;
394 std::string m_glyphPostfixId;
396 option_SMUFLTEXTFONT m_smuflTextFont;
403 #endif // __VRV_SVG_DC_H__
ClassId GetClassId(std::string name)
Get the ClassId from the MEI element string name by making a lookup in the register.
void SetAdditionalAttributes(const std::vector< std::string > &additionalAttributes)
Copies additional attributes of defined elements to the SVG, each string in the form "elementName@att...
Definition: svgdevicecontext.h:247
void SetIndent(int indent)
Setter for indent of the SVG (default is 3, -1 for tabs)
Definition: svgdevicecontext.h:222
void SetHtml5(bool html5)
Setting m_html5 flag (false by default)
Definition: svgdevicecontext.h:217
This class represents a basic object.
Definition: object.h:59
void SetMMOutput(bool mmOutput)
Setting mm output flag (false by default)
Definition: svgdevicecontext.h:199
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 SetSvgViewBox(bool svgViewBox)
Setting m_svgViewBox flag (false by default)
Definition: svgdevicecontext.h:212
This class is an abstract device context.
Definition: devicecontext.h:57
bool UseGlobalStyling() override
In SVG use global styling but not with mm output (for pdf generation)
Definition: svgdevicecontext.h:194
void SetCustomGraphicAttributes(const std::string &data, const std::string &value) override
Method for adding custom graphic data-* attributes.
void SetRemoveXlink(bool removeXlink)
Removes the xlink: prefex on href attributes, necessary for some newer browsers.
Definition: svgdevicecontext.h:232
std::string GetStringSVG(bool xml_declaration=false)
}
static ObjectFactory * GetInstance()
A static method returning a static object in order to guarantee initialisation.
void AppendAdditionalAttributes(Object *object)
Append additional attributes, as given in m_svgAdditionalAttributes.
void SetCss(const std::string &css)
Setter for an additional CSS.
Definition: svgdevicecontext.h:237
This class is a drawing context and corresponds to the view of a MVC design pattern.
Definition: view.h:105
void SetFormatRaw(bool rawFormat)
Set the SVG to have 'raw' formatting, with no extraneous whitespace or newlines.
Definition: svgdevicecontext.h:227
void SetSmuflTextFont(option_SMUFLTEXTFONT smuflTextFont)
Setter for a the smufl text font option.
Definition: svgdevicecontext.h:260
Simple class for representing points.
Definition: devicecontextbase.h:203
void SetSvgBoundingBoxes(bool svgBoundingBoxes)
Setting m_svgBoudingBoxes flag (false by default)
Definition: svgdevicecontext.h:207
This class implements a drawing context for generating SVG files.
Definition: svgdevicecontext.h:39
void SetCustomGraphicColor(const std::string &color) override
Method for changing the color of a custom graphic.