16 #include "devicecontextbase.h"
17 #include "resources.h"
22 #include "pugixml.hpp"
32 static inline double DegToRad(
double deg)
34 return (deg * M_PI) / 180.0;
36 static inline double RadToDeg(
double deg)
38 return (deg * 180.0) / M_PI;
65 m_classId = DEVICE_CONTEXT;
68 m_isDeactivatedY =
false;
77 m_viewBoxFactor = (double)DEFINITION_FACTOR;
79 this->SetPen(1, PEN_SOLID);
86 m_isDeactivatedY =
false;
95 m_viewBoxFactor = (double)DEFINITION_FACTOR;
97 this->SetPen(1, PEN_SOLID);
100 ClassId GetClassId()
const {
return m_classId; }
101 bool Is(ClassId classId)
const {
return (m_classId == classId); }
109 const Resources *GetResources(
bool showWarning =
false)
const;
110 bool HasResources()
const {
return (m_resources != NULL); }
111 void SetResources(
const Resources *resources) { m_resources = resources; }
112 void ResetResources() { m_resources = NULL; }
125 void SetWidth(
int width) { m_width = width; }
126 void SetHeight(
int height) { m_height = height; }
127 void SetContentHeight(
int height) { m_contentHeight = height; }
128 void SetUserScale(
double scaleX,
double scaleY)
130 m_userScaleX = scaleX;
131 m_userScaleY = scaleY;
133 void SetBaseSize(
int width,
int height)
136 m_baseHeight = height;
138 void SetViewBoxFactor(
double ppuFactor);
139 int GetWidth()
const {
return m_width; }
140 int GetHeight()
const {
return m_height; }
141 int GetContentHeight()
const {
return m_contentHeight; }
142 double GetUserScaleX() {
return m_userScaleX; }
143 double GetUserScaleY() {
return m_userScaleY; }
144 std::pair<int, int> GetBaseSize()
const {
return std::make_pair(m_baseWidth, m_baseHeight); }
145 double GetViewBoxFactor()
const {
return m_viewBoxFactor; }
153 void SetBrush(
float opacity,
int color = COLOR_NONE);
154 void SetPen(
int width, PenStyle style,
int dashLength = 0,
int gapLength = 0,
155 LineCapStyle lineCap = LINECAP_DEFAULT, LineJoinStyle lineJoin = LINEJOIN_DEFAULT,
float opacity = -1.0,
156 int color = COLOR_NONE);
157 void SetFont(FontInfo *font);
163 virtual void SetBackground(
int color,
int style = PEN_SOLID) = 0;
164 virtual void SetBackgroundImage(
void *image,
double opacity = 1.0) = 0;
165 virtual void SetBackgroundMode(
int mode) = 0;
166 virtual void SetTextForeground(
int color) = 0;
167 virtual void SetTextBackground(
int color) = 0;
168 virtual void SetLogicalOrigin(
int x,
int y) = 0;
176 bool HasFont()
const {
return !m_fontStack.empty(); }
183 virtual void GetTextExtent(
const std::string &
string, TextExtend *extend,
bool typeSize);
184 virtual void GetTextExtent(
const std::u32string &
string, TextExtend *extend,
bool typeSize);
185 virtual void GetSmuflTextExtent(
const std::u32string &
string, TextExtend *extend);
191 virtual Point GetLogicalOrigin() = 0;
198 virtual void DrawQuadBezierPath(Point bezier[3]) = 0;
199 virtual void DrawCubicBezierPath(Point bezier[4]) = 0;
200 virtual void DrawCubicBezierPathFilled(Point bezier1[4], Point bezier2[4]) = 0;
201 virtual void DrawBentParallelogramFilled(Point side[4],
int height) = 0;
202 virtual void DrawCircle(
int x,
int y,
int radius) = 0;
203 virtual void DrawEllipse(
int x,
int y,
int width,
int height) = 0;
204 virtual void DrawEllipticArc(
int x,
int y,
int width,
int height,
double start,
double end) = 0;
205 virtual void DrawLine(
int x1,
int y1,
int x2,
int y2) = 0;
206 virtual void DrawPolyline(
int n, Point points[],
bool close =
false) = 0;
207 virtual void DrawPolygon(
int n, Point points[]) = 0;
208 virtual void DrawRectangle(
int x,
int y,
int width,
int height) = 0;
209 virtual void DrawRotatedText(
const std::string &text,
int x,
int y,
double angle) = 0;
210 virtual void DrawRoundedRectangle(
int x,
int y,
int width,
int height,
int radius) = 0;
211 virtual void DrawText(
const std::string &text,
const std::u32string &wtext = U
"",
int x = VRV_UNSET,
212 int y = VRV_UNSET,
int width = VRV_UNSET,
int height = VRV_UNSET) = 0;
213 virtual void DrawMusicText(
const std::u32string &text,
int x,
int y,
bool setSmuflGlyph =
false) = 0;
214 virtual void DrawSpline(
int n, Point points[]) = 0;
215 virtual void DrawGraphicUri(
int x,
int y,
int width,
int height,
const std::string &uri) = 0;
216 virtual void DrawSvgShape(
int x,
int y,
int width,
int height,
double scale, pugi::xml_node svg) = 0;
217 virtual void DrawBackgroundImage(
int x = 0,
int y = 0) = 0;
232 virtual void StartText(
int x,
int y, data_HORIZONTALALIGNMENT alignment = HORIZONTALALIGNMENT_left) = 0;
233 virtual void EndText() = 0;
240 virtual void MoveTextTo(
int x,
int y, data_HORIZONTALALIGNMENT alignment) = 0;
241 virtual void MoveTextVerticallyTo(
int y) = 0;
253 void DeactivateGraphic();
254 void DeactivateGraphicX();
255 void DeactivateGraphicY();
256 void ReactivateGraphic();
269 virtual void StartGraphic(
Object *
object,
const std::string &gClass,
const std::string &gId,
270 GraphicID graphicID = PRIMARY,
bool preprend =
false) = 0;
271 virtual void EndGraphic(
Object *
object,
View *view) = 0;
272 virtual void AddGraphicClass(
const std::string &className) {};
280 virtual void StartCustomGraphic(
const std::string &name, std::string gClass =
"", std::string gId =
"") {}
281 virtual void EndCustomGraphic() {}
299 virtual void ResumeGraphic(
Object *
object, std::string gId) = 0;
300 virtual void EndResumedGraphic(
Object *
object,
View *view) = 0;
308 virtual void StartTextGraphic(
Object *
object,
const std::string &gClass,
const std::string &gId)
310 StartGraphic(
object, gClass, gId);
312 virtual void EndTextGraphic(Object *
object, View *view) { EndGraphic(
object, view); }
320 virtual void RotateGraphic(Point
const &orig,
double angle) = 0;
327 virtual void StartPage() = 0;
328 virtual void EndPage() = 0;
335 virtual void AddDescription(
const std::string &text) {}
356 static int RGB2Int(
char red,
char green,
char blue) {
return (red << 16 | green << 8 | blue); }
365 std::stack<Pen> m_penStack;
366 std::stack<Brush> m_brushStack;
367 std::stack<FontInfo *> m_fontStack;
371 bool m_isDeactivatedY;
376 Zone *m_facsimile = NULL;
401 double m_viewBoxFactor;
This class is an abstract device context.
Definition: devicecontext.h:57
bool m_isDeactivatedX
flag for indicating if the graphic is deactivated
Definition: devicecontext.h:370
virtual void SetCustomGraphicColor(const std::string &color)
Method for changing the color of a custom graphic.
Definition: devicecontext.h:287
virtual void SetCustomGraphicAttributes(const std::string &data, const std::string &value)
Method for adding custom graphic data-* attributes.
Definition: devicecontext.h:292
virtual bool ApplyOffset()
Indicate if offset should be applied.
Definition: devicecontext.h:262
const Glyph * GetMusicGlyph(char32_t code) const
Return the glyph in the music font of the current font (or in the current music font if none)
static int RGB2Int(char red, char green, char blue)
Color conversion method.
Definition: devicecontext.h:356
virtual void DrawPlaceholder(int x, int y)
Special method for forcing bounding boxes to be updated Used for invisible elements (e....
Definition: devicecontext.h:224
virtual bool UseGlobalTextStyling()
Method indicating if text styles (e.g., bold tempo) are left to the global styling.
Definition: devicecontext.h:349
bool m_pushBack
push back mode
Definition: devicecontext.h:374
virtual bool UseGlobalStyling()
Method indicating if default global styling is used.
Definition: devicecontext.h:343
This class is used for storing a music font glyph.
Definition: glyph.h:32
This class represents a basic object.
Definition: object.h:66
This class provides resource values.
Definition: resources.h:33
Simple class for representing text extends.
Definition: devicecontextbase.h:345
This class is a drawing context and corresponds to the view of a MVC design pattern.
Definition: view.h:109
Implements the zone element in MEI.
Definition: zone.h:30
A shaped text run.
Definition: fontstore.h:73