Canorus
0.7
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
drawable
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
14
class
QPainter;
15
16
struct
CADrawSettings
{
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
27
class
CADrawable
{
28
public
:
29
enum
CADrawableType
{
30
DrawableMusElement
,
31
DrawableContext
32
};
33
34
enum
CADirection
{
35
Undefined
,
36
Top
,
37
Bottom
,
38
Left
,
39
Right
,
40
TopLeft
,
41
TopRight
,
42
BottomLeft
,
43
BottomRight
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
54
inline
CADrawableType
drawableType
() {
return
_drawableType
; }
55
inline
double
xPos
() {
return
_xPos
; }
56
inline
double
yPos
() {
return
_yPos
; }
57
inline
double
width
() {
return
_width
; }
58
inline
double
height
() {
return
_height
; }
59
inline
double
neededSpaceWidth
() {
return
_neededSpaceWidth
; }
60
inline
double
neededSpaceHeight
() {
return
_neededSpaceHeight
; }
61
inline
double
neededWidth
() {
return
_width
+
_neededSpaceWidth
; }
62
inline
double
neededHeight
() {
return
_height
+
_neededSpaceHeight
; }
63
inline
double
xCenter
() {
return
_xPos
+ (
_width
)/2; }
64
inline
double
yCenter
() {
return
_yPos
+ (
_height
)/2; }
65
inline
const
QRect
bBox
() {
return
QRect(
_xPos
,
_yPos
,
_width
,
_height
); }
66
inline
bool
isVisible
() {
return
_visible
; }
67
inline
bool
isSelectable
() {
return
_selectable
; }
68
inline
bool
isHScalable
() {
return
_hScalable
; }
69
inline
bool
isVScalable
() {
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
; }
76
inline
void
setNeededSpaceHeight
(
double
height
) {
_neededSpaceHeight
=
height
; }
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
82
protected
:
83
void
setDrawableType
(
CADrawableType
t ) {
_drawableType
= t; };
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
92
bool
_visible
;
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_ */
Generated on Fri Jan 11 2013 14:40:12 for Canorus by
1.8.3