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

Guido Project Copyright © 2019 Grame-CNCM