Canorus 0.0
drawable.h
Go to the documentation of this file.
1
8#ifndef DRAWABLE_H_
9#define DRAWABLE_H_
10
11#include <QRect>
12#include <QColor>
13
14class QPainter;
15
17 float z; // zoom level
18 int x; // painter x pos in pixels
19 int y; // painter y pos in pixels
20 int w; // canvas width in pixels
21 int h; // canvas height in pixels
22 QColor color; // pen color
23 double worldX; // x coordinate of the view
24 double worldY; // y coordinate of the view
25};
26
28public:
32 };
33
44 };
45
46 CADrawable( double x, double y ); // x and y position of an element in absolute world units
47 virtual ~CADrawable() { }
48 virtual void draw(QPainter *p, const CADrawSettings s) = 0;
49 virtual CADrawable *clone();
50
51 void drawHScaleHandles( QPainter *p, const CADrawSettings s );
52 void drawVScaleHandles( QPainter *p, const CADrawSettings s );
53
55 inline double xPos() const { return _xPos; }
56 inline double yPos() const { return _yPos; }
57 inline double width() const { return _width; }
58 inline double height() const { return _height; }
59 inline double neededSpaceWidth() const { return _neededSpaceWidth; }
60 inline double neededSpaceHeight() const { return _neededSpaceHeight; }
61 inline double neededWidth() const { return _width+_neededSpaceWidth; }
62 inline double neededHeight() const { return _height+_neededSpaceHeight; }
63 inline double xCenter() const { return _xPos + (_width)/2; }
64 inline double yCenter() const { return _yPos + (_height)/2; }
65 inline const QRect bBox() const { return QRect(_xPos, _yPos, _width, _height); }
66 inline bool isVisible() const { return _visible; }
67 inline bool isSelectable() const { return _selectable; }
68 inline bool isHScalable() const { return _hScalable; }
69 inline bool isVScalable() const { return _vScalable; }
70
71 inline void setXPos(double xPos) { _xPos = xPos; }
72 inline void setYPos(double yPos) { _yPos = yPos; }
73 inline void setWidth(double width) { _width = width; }
74 inline void setHeight(double height) { _height = height; }
75 inline void setNeededSpaceWidth( double width ) { _neededSpaceWidth = width; }
77 inline void setVisible(bool v) { _visible = v; }
78 inline void setSelectable(bool s) { _selectable = s; }
79 inline void setHScalable(bool s) { _hScalable = s; }
80 inline void setVScalable(bool s) { _vScalable = s; }
81
82protected:
84
85 CADrawableType _drawableType; // DrawableMusElement or DrawableContext.
86 double _xPos;
87 double _yPos;
88 double _width; // Element's width as it appears on the screen
89 double _height; // Element's height as it appears on the screen
90 double _neededSpaceWidth; // Minimum width the next element should be placed next to it by engraver
91 double _neededSpaceHeight; // Minimum height the next element should be placed next to it by engraver
93 bool _selectable; // Can the element be clicked on and is then selected
94 bool _hScalable; // Can the element be streched horizontally
95 bool _vScalable; // Can the element be streched vertically
96
97 static const int SCALE_HANDLES_SIZE; // Width and Height of the scale handles squares in pixels
98};
99
100#endif /* DRAWABLE_H_ */
Definition: drawable.h:27
virtual void draw(QPainter *p, const CADrawSettings s)=0
double yPos() const
Definition: drawable.h:56
bool isHScalable() const
Definition: drawable.h:68
double yCenter() const
Definition: drawable.h:64
void setDrawableType(CADrawableType t)
Definition: drawable.h:83
bool isVisible() const
Definition: drawable.h:66
double _xPos
Definition: drawable.h:86
void setNeededSpaceHeight(double height)
Definition: drawable.h:76
void setXPos(double xPos)
Definition: drawable.h:71
CADrawableType
Definition: drawable.h:29
@ DrawableMusElement
Definition: drawable.h:30
@ DrawableContext
Definition: drawable.h:31
double xCenter() const
Definition: drawable.h:63
void setWidth(double width)
Definition: drawable.h:73
CADrawableType _drawableType
Definition: drawable.h:83
double _width
Definition: drawable.h:88
double neededSpaceWidth() const
Definition: drawable.h:59
void setHScalable(bool s)
Definition: drawable.h:79
void drawHScaleHandles(QPainter *p, const CADrawSettings s)
Definition: drawable.cpp:28
void drawVScaleHandles(QPainter *p, const CADrawSettings s)
Definition: drawable.cpp:36
double neededWidth() const
Definition: drawable.h:61
double _height
Definition: drawable.h:89
bool _vScalable
Definition: drawable.h:95
void setHeight(double height)
Definition: drawable.h:74
bool _hScalable
Definition: drawable.h:94
double _neededSpaceHeight
Definition: drawable.h:91
double _neededSpaceWidth
Definition: drawable.h:90
void setVisible(bool v)
Definition: drawable.h:77
void setYPos(double yPos)
Definition: drawable.h:72
bool isSelectable() const
Definition: drawable.h:67
const QRect bBox() const
Definition: drawable.h:65
CADirection
Definition: drawable.h:34
@ Left
Definition: drawable.h:38
@ BottomLeft
Definition: drawable.h:42
@ BottomRight
Definition: drawable.h:43
@ TopLeft
Definition: drawable.h:40
@ Bottom
Definition: drawable.h:37
@ Undefined
Definition: drawable.h:35
@ Top
Definition: drawable.h:36
@ Right
Definition: drawable.h:39
@ TopRight
Definition: drawable.h:41
static const int SCALE_HANDLES_SIZE
Definition: drawable.h:97
bool _selectable
Definition: drawable.h:93
double neededSpaceHeight() const
Definition: drawable.h:60
void setNeededSpaceWidth(double width)
Definition: drawable.h:75
double width() const
Definition: drawable.h:57
double height() const
Definition: drawable.h:58
double xPos() const
Definition: drawable.h:55
double neededHeight() const
Definition: drawable.h:62
CADrawable(double x, double y)
Definition: drawable.cpp:16
virtual CADrawable * clone()
Definition: drawable.cpp:23
void setSelectable(bool s)
Definition: drawable.h:78
virtual ~CADrawable()
Definition: drawable.h:47
bool isVScalable() const
Definition: drawable.h:69
double _yPos
Definition: drawable.h:87
bool _visible
Definition: drawable.h:92
CADrawableType drawableType()
Definition: drawable.h:54
void setVScalable(bool s)
Definition: drawable.h:80
Definition: drawable.h:16
float z
Definition: drawable.h:17
int h
Definition: drawable.h:21
int w
Definition: drawable.h:20
QColor color
Definition: drawable.h:22
int y
Definition: drawable.h:19
double worldY
Definition: drawable.h:24
int x
Definition: drawable.h:18
double worldX
Definition: drawable.h:23