-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathGRNotationElement.h
More file actions
199 lines (154 loc) · 7.52 KB
/
GRNotationElement.h
File metadata and controls
199 lines (154 loc) · 7.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#ifndef GRNotationElement_H
#define GRNotationElement_H
/*
GUIDO Library
Copyright (C) 2002 Holger Hoos, Juergen Kilian, Kai Renz
Copyright (C) 2003, 2004 Grame
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
Grame Research Laboratory, 11, cours de Verdun Gensoul 69002 Lyon - France
research@grame.fr
*/
#include <cassert>
#include <iostream>
#include "GObject.h"
#include "defines.h" // for TYPE_DURATION
#include "GRVisitable.h"
#include "GRVisitor.h"
class ARMusicalObject;
class GRAccidental;
class GRBar;
class GREvent;
class GRFingering;
class GRGlue;
class GRHarmony;
class GRNote;
class GRRest;
class GRSingleNote;
class GRStaff;
class GRSystemSlice;
class GRTempo;
class GRText;
class GRTrill;
class NEPointerList;
#ifdef SMUFL
#define DEFAULTNUMERICSPACE 6
#else
#define DEFAULTNUMERICSPACE 0
#endif
const float kMinNoteSize = 0.001f; // minimum size of an element, the element is not drawn when the size is smaller
/** \brief parent class for all notation elements.
*/
class GRNotationElement : public GObject, public GRVisitable
{
public:
GRNotationElement();
virtual ~GRNotationElement();
static int ComparePos( const GRNotationElement * g1, const GRNotationElement * g2 );
GRStaff * getGRStaff() const { return mGrStaff; }
virtual void setGRStaff( GRStaff * in ) { mGrStaff = in; }
GRSystemSlice * getGRSystemSlice() const;
virtual int getStaffNumber() const;
virtual void tellPosition( GObject * caller, const NVPoint & point);
virtual float getLeftSpace() const { return mLeftSpace; }
virtual float getRightSpace() const { return mRightSpace; }
virtual void setLeftSpace( float lspace ) { mLeftSpace = lspace; }
virtual void setRightSpace( float rspace ) { mRightSpace = rspace; }
virtual void setHPosition( float nx );
virtual void setPosition( const NVPoint & newPosition);
virtual void setNeedsSpring( int inFlag ) { mNeedsSpring = inFlag; }
virtual int getNeedsSpring() const { return mNeedsSpring; }
virtual int getSpringID() const { return mSpringID; }
virtual void tellSpringID( int inSpringID ) { mSpringID = inSpringID; }
NEPointerList * getAssociations() { return mAssociated; }
const NEPointerList * getAssociations() const { return mAssociated; }
virtual void removeAssociation( const NEPointerList & nl );
virtual void removeAssociation( GRNotationElement * el );
void FreeAssociatedList();
virtual NVPoint getTieEnd() const { return mPosition; } // do not rely on that
virtual NVPoint getTieStart() const { return mPosition; }
virtual NVRect getAssociatedBoundingBox() const;
void addToBoundingBox( GRNotationElement * in );
// - Drawing
virtual void OnDraw( VGDevice & hdc ) const;
void OnDrawSymbol(VGDevice & hdc, unsigned int inSymbol, float inOffsetX = 0,
float inOffsetY = 0, float inFontSize = 0) const; // , float inScaleX = 0) const;
void OnDrawText( VGDevice & hdc, NVPoint pos, const char * cp, int inCharCount = -1 ) const;
void OnDrawText( VGDevice & hdc, const char * cp, int inCharCount = -1 ) const;
void DrawSymbol( VGDevice & hdc, unsigned int inSymbol, float x = 0, float y = 0, float size = 0) const;
void DrawNumericSymbols( VGDevice & hdc, const char* symbols, float x, float y, float size, float spacing=DEFAULTNUMERICSPACE) const;
void Show( bool status ) { mShow = status; }
bool GetShow() const { return mShow; }
virtual void SendMap (const NVRect& r, MapCollector& f, TYPE_TIMEPOSITION date, TYPE_DURATION dur, GuidoElementType type, MapInfos& infos) const;
virtual void SendMap (MapCollector& f, TYPE_TIMEPOSITION date, TYPE_DURATION dur, GuidoElementType type, MapInfos& infos) const;
virtual unsigned int getTextAlign() const;
//
virtual const ARMusicalObject * getAbstractRepresentation() const { return 0; }
virtual const TYPE_DURATION & getDuration() const { return mDurationOfGR; }
virtual void setDuration(const TYPE_TIMEPOSITION & dur ) { mDurationOfGR = dur; }
virtual void setRelativeTimePosition(const TYPE_TIMEPOSITION & tp ) { mRelativeTimePositionOfGR = tp; }
virtual void setRelativeEndTimePosition(const TYPE_TIMEPOSITION & tp ) { mDurationOfGR = tp - mRelativeTimePositionOfGR; }
virtual const TYPE_TIMEPOSITION & getRelativeTimePosition() const { return mRelativeTimePositionOfGR; }
virtual void setDrawOnOff(bool onoff) { mDraw = onoff;}
virtual bool getDrawOnOff() { return mDraw;}
virtual TYPE_TIMEPOSITION getRelativeEndTimePosition() const;
virtual void recalcVerticalPosition();
virtual void addAssociation( GRNotationElement * grnot );
virtual void accept (GRVisitor& visitor);
// - Text, streams
virtual void print(std::ostream& os) const;
inline const NEPointerList* associated() const { return mAssociated; }
/**** Functions to avoid dynamic_cast ****/
/*****************************************/
virtual void setIsInHeader(bool state) { mIsInHeader = state; }
virtual bool isInHeader() const { return false; }
virtual bool isEmpty() const { return false; }
virtual bool isLyrics() const { return false; }
virtual bool isChordComma() const { return false; }
virtual bool checkCollisionWith() const { return false; }
virtual const GRText* isText() const { return 0; }
virtual const GRSingleNote* isSingleNote() const { return 0; }
virtual GRSingleNote* isSingleNote() { return 0; }
virtual const GRNote * isGRNote() const { return 0; }
virtual const GRRest * isRest() const { return 0; }
virtual const GREvent * isGREvent() const { return 0; }
virtual GREvent * isGREvent() { return 0; }
virtual const GRGlue * isGRGlue() const { return 0; }
virtual const GRTempo * isGRTempo() const { return 0; }
virtual const GRTrill * isGRTrill() const { return 0; }
virtual const GRBar * isGRBar() const { return 0; }
virtual const GRDynamics * isGRDynamic() const { return 0; }
virtual GRFingering * isGRFingering() { return 0; }
virtual GRSlur * isGRSlur() { return 0; }
virtual const GRHarmony * isGRHarmony() const { return 0; }
protected:
void DrawExtents( VGDevice & hdc, const VGColor & inColor ) const; // Debug
unsigned int mSymbol;
GRStaff * mGrStaff;
int mNeedsSpring; // Can be -1, 0 or 1
int mSpringID;
float mLeftSpace; // Can't we deal only with bounding boxes ?
float mRightSpace;
bool mDraw; // a flag to show or hide an element (default is true) connected to staff on/off
bool mShow; // a flag to show or hide an element (default is true) used by GuidoShowElement
bool mIsInHeader; // For proportional rendering
TYPE_DURATION mDurationOfGR;
NEPointerList * mAssociated;
private:
TYPE_TIMEPOSITION mRelativeTimePositionOfGR;
};
std::ostream& operator<< (std::ostream& os, const GRNotationElement& e);
std::ostream& operator<< (std::ostream& os, const GRNotationElement* e);
/** \brief This comparison routine compares to notationelements
by y-position. This way the association-list of chords is sorted.
*/
/*
previous implementation made use of template declared as below
template <class T> int compnotposy( const T * el1, const T * el2 );
since gcc 4.0, template has been removed and replaced by the 2 specialized
functions declared below and implemented in cpp file.
*/
int compnotposy( const GRNotationElement * el1, const GRNotationElement * el2 );
int compaccposy( const GRAccidental * el1, const GRAccidental * el2 );
#endif