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; }
120 void SetWidth(
int width) { m_width = width; }
121 void SetHeight(
int height) { m_height = height; }
122 void SetContentHeight(
int height) { m_contentHeight = height; }
123 void SetUserScale(
double scaleX,
double scaleY)
125 m_userScaleX = scaleX;
126 m_userScaleY = scaleY;
128 void SetBaseSize(
int width,
int height)
131 m_baseHeight = height;
133 void SetViewBoxFactor(
double ppuFactor);
134 int GetWidth()
const {
return m_width; }
135 int GetHeight()
const {
return m_height; }
136 int GetContentHeight()
const {
return m_contentHeight; }
137 double GetUserScaleX() {
return m_userScaleX; }
138 double GetUserScaleY() {
return m_userScaleY; }
139 std::pair<int, int> GetBaseSize()
const {
return std::make_pair(m_baseWidth, m_baseHeight); }
140 double GetViewBoxFactor()
const {
return m_viewBoxFactor; }
148 void SetBrush(
float opacity,
int color = COLOR_NONE);
149 void SetPen(
int width, PenStyle style,
int dashLength = 0,
int gapLength = 0,
150 LineCapStyle lineCap = LINECAP_DEFAULT, LineJoinStyle lineJoin = LINEJOIN_DEFAULT,
float opacity = 1.0,
151 int color = COLOR_NONE);
158 virtual void SetBackground(
int color,
int style = PEN_SOLID) = 0;
159 virtual void SetBackgroundImage(
void *image,
double opacity = 1.0) = 0;
160 virtual void SetBackgroundMode(
int mode) = 0;
161 virtual void SetTextForeground(
int color) = 0;
162 virtual void SetTextBackground(
int color) = 0;
163 virtual void SetLogicalOrigin(
int x,
int y) = 0;
171 bool HasFont()
const {
return !m_fontStack.empty(); }
178 virtual void GetTextExtent(
const std::string &
string,
TextExtend *extend,
bool typeSize);
179 virtual void GetTextExtent(
const std::u32string &
string,
TextExtend *extend,
bool typeSize);
180 virtual void GetSmuflTextExtent(
const std::u32string &
string,
TextExtend *extend);
186 virtual Point GetLogicalOrigin() = 0;
193 virtual void DrawQuadBezierPath(
Point bezier[3]) = 0;
194 virtual void DrawCubicBezierPath(
Point bezier[4]) = 0;
195 virtual void DrawCubicBezierPathFilled(
Point bezier1[4],
Point bezier2[4]) = 0;
196 virtual void DrawBentParallelogramFilled(
Point side[4],
int height) = 0;
197 virtual void DrawCircle(
int x,
int y,
int radius) = 0;
198 virtual void DrawEllipse(
int x,
int y,
int width,
int height) = 0;
199 virtual void DrawEllipticArc(
int x,
int y,
int width,
int height,
double start,
double end) = 0;
200 virtual void DrawLine(
int x1,
int y1,
int x2,
int y2) = 0;
201 virtual void DrawPolyline(
int n,
Point points[],
bool close =
false) = 0;
202 virtual void DrawPolygon(
int n,
Point points[]) = 0;
203 virtual void DrawRectangle(
int x,
int y,
int width,
int height) = 0;
204 virtual void DrawRotatedText(
const std::string &text,
int x,
int y,
double angle) = 0;
205 virtual void DrawRoundedRectangle(
int x,
int y,
int width,
int height,
int radius) = 0;
206 virtual void DrawText(
const std::string &text,
const std::u32string &wtext = U
"",
int x = VRV_UNSET,
207 int y = VRV_UNSET,
int width = VRV_UNSET,
int height = VRV_UNSET)
209 virtual void DrawMusicText(
const std::u32string &text,
int x,
int y,
bool setSmuflGlyph =
false) = 0;
210 virtual void DrawSpline(
int n,
Point points[]) = 0;
211 virtual void DrawGraphicUri(
int x,
int y,
int width,
int height,
const std::string &uri) = 0;
212 virtual void DrawSvgShape(
int x,
int y,
int width,
int height,
double scale, pugi::xml_node svg) = 0;
213 virtual void DrawBackgroundImage(
int x = 0,
int y = 0) = 0;
228 virtual void StartText(
int x,
int y, data_HORIZONTALALIGNMENT alignment = HORIZONTALALIGNMENT_left) = 0;
229 virtual void EndText() = 0;
236 virtual void MoveTextTo(
int x,
int y, data_HORIZONTALALIGNMENT alignment) = 0;
237 virtual void MoveTextVerticallyTo(
int y) = 0;
249 void DeactivateGraphic();
250 void DeactivateGraphicX();
251 void DeactivateGraphicY();
252 void ReactivateGraphic();
260 virtual void StartGraphic(
Object *
object,
const std::string &gClass,
const std::string &gId,
261 GraphicID graphicID = PRIMARY,
bool preprend =
false)
263 virtual void EndGraphic(
Object *
object,
View *view) = 0;
271 virtual void StartCustomGraphic(
const std::string &name, std::string gClass =
"", std::string gId =
"") {}
272 virtual void EndCustomGraphic() {}
290 virtual void ResumeGraphic(
Object *
object, std::string gId) = 0;
291 virtual void EndResumedGraphic(
Object *
object,
View *view) = 0;
299 virtual void StartTextGraphic(
Object *
object,
const std::string &gClass,
const std::string &gId)
301 StartGraphic(
object, gClass, gId);
303 virtual void EndTextGraphic(Object *
object, View *view) { EndGraphic(
object, view); }
311 virtual void RotateGraphic(Point
const &orig,
double angle) = 0;
318 virtual void StartPage() = 0;
319 virtual void EndPage() = 0;
326 virtual void AddDescription(
const std::string &text) {}
341 static int RGB2Int(
char red,
char green,
char blue) {
return (red << 16 | green << 8 | blue); }
349 std::stack<Pen> m_penStack;
350 std::stack<Brush> m_brushStack;
351 std::stack<FontInfo *> m_fontStack;
355 bool m_isDeactivatedY;
360 Zone *m_facsimile = NULL;
385 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:354
virtual void SetCustomGraphicColor(const std::string &color)
Method for changing the color of a custom graphic.
Definition: devicecontext.h:278
virtual void SetCustomGraphicAttributes(const std::string &data, const std::string &value)
Method for adding custom graphic data-* attributes.
Definition: devicecontext.h:283
static int RGB2Int(char red, char green, char blue)
Color conversion method.
Definition: devicecontext.h:341
virtual void DrawPlaceholder(int x, int y)
Special method for forcing bounding boxes to be updated Used for invisible elements (e....
Definition: devicecontext.h:220
bool m_pushBack
push back mode
Definition: devicecontext.h:358
virtual bool UseGlobalStyling()
Method indicating if default global styling is used.
Definition: devicecontext.h:334
This class is store font properties.
Definition: devicecontextbase.h:137
This class is used for storing a music font glyph.
Definition: glyph.h:31
This class represents a basic object.
Definition: object.h:61
Simple class for representing points.
Definition: devicecontextbase.h:203
This class provides resource values.
Definition: resources.h:30
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:106
Implements the zone element in MEI.
Definition: zone.h:30