Verovio
Source code documentation
elementpart.h
1 // Name: elementpart.h
3 // Author: Laurent Pugin
4 // Created: 2017
5 // Copyright (c) Authors and others. All rights reserved.
7 
8 #ifndef __VRV_ELEMENT_PART_H__
9 #define __VRV_ELEMENT_PART_H__
10 
11 #include "atts_cmn.h"
12 #include "atts_shared.h"
13 #include "atts_visual.h"
14 #include "layerelement.h"
15 
16 namespace vrv {
17 
18 class TupletNum;
19 
20 //----------------------------------------------------------------------------
21 // Dots
22 //----------------------------------------------------------------------------
23 
27 class Dots : public LayerElement, public AttAugmentDots {
28 public:
34  Dots();
35  virtual ~Dots();
36  void Reset() override;
37  std::string GetClassName() const override { return "dots"; }
38  Object *Clone() const override { return new Dots(*this); }
40 
42  bool HasToBeAligned() const override { return true; }
43 
44  std::set<int> GetDotLocsForStaff(const Staff *staff) const;
45  std::set<int> &ModifyDotLocsForStaff(const Staff *staff);
46 
47  const MapOfDotLocs &GetMapOfDotLocs() const { return m_dotLocsByStaff; }
48  void SetMapOfDotLocs(const MapOfDotLocs &dotLocs) { m_dotLocsByStaff = dotLocs; };
49  void ResetMapOfDotLocs() { m_dotLocsByStaff.clear(); }
50 
51  void IsAdjusted(bool isAdjusted) { m_isAdjusted = isAdjusted; }
52  bool IsAdjusted() const { return m_isAdjusted; }
53 
54  //----------//
55  // Functors //
56  //----------//
57 
62  FunctorCode Accept(Functor &functor) override;
63  FunctorCode Accept(ConstFunctor &functor) const override;
64  FunctorCode AcceptEnd(Functor &functor) override;
65  FunctorCode AcceptEnd(ConstFunctor &functor) const override;
67 
72  int GetFlagShift() const { return m_flagShift; }
73  void SetFlagShift(int shiftVal) { m_flagShift = shiftVal; }
75 
76 private:
77  //
78 public:
79  //
80 private:
84  MapOfDotLocs m_dotLocsByStaff;
85 
86  bool m_isAdjusted;
87  int m_flagShift;
88 };
89 
90 //----------------------------------------------------------------------------
91 // Flag
92 //----------------------------------------------------------------------------
93 
97 class Flag : public LayerElement {
98 public:
104  Flag();
105  virtual ~Flag();
106  void Reset() override;
107  std::string GetClassName() const override { return "flag"; }
108  Object *Clone() const override { return new Flag(*this); }
110 
112  bool HasToBeAligned() const override { return true; }
113 
114  char32_t GetFlagGlyph(data_STEMDIRECTION stemDir) const;
115 
116  Point GetStemUpSE(const Doc *doc, int staffSize, bool graceSize) const;
117  Point GetStemDownNW(const Doc *doc, int staffSize, bool graceSize) const;
118 
119  //----------//
120  // Functors //
121  //----------//
122 
127  FunctorCode Accept(Functor &functor) override;
128  FunctorCode Accept(ConstFunctor &functor) const override;
129  FunctorCode AcceptEnd(Functor &functor) override;
130  FunctorCode AcceptEnd(ConstFunctor &functor) const override;
132 
133 private:
134  //
135 public:
138 
139 private:
140 };
141 
142 //----------------------------------------------------------------------------
143 // TupletBracket
144 //----------------------------------------------------------------------------
145 
150 class TupletBracket : public LayerElement, public AttTupletVis {
151 public:
157  TupletBracket();
158  virtual ~TupletBracket();
159  void Reset() override;
160  std::string GetClassName() const override { return "tupletBracket"; }
161  Object *Clone() const override { return new TupletBracket(*this); }
163 
168  int GetDrawingXRelLeft() const { return m_drawingXRelLeft; }
169  void SetDrawingXRelLeft(int drawingXRelLeft) { m_drawingXRelLeft = drawingXRelLeft; }
170  int GetDrawingXRelRight() const { return m_drawingXRelRight; }
171  void SetDrawingXRelRight(int drawingXRelRight) { m_drawingXRelRight = drawingXRelRight; }
172  // Vertical positions
173  int GetDrawingYRelLeft() const { return m_drawingYRelLeft; }
174  void SetDrawingYRelLeft(int drawingYRelLeft) { m_drawingYRelLeft = drawingYRelLeft; }
175  int GetDrawingYRelRight() const { return m_drawingYRelRight; }
176  void SetDrawingYRelRight(int drawingYRelRight) { m_drawingYRelRight = drawingYRelRight; }
178 
186  int GetDrawingXLeft() const;
187  int GetDrawingXRight() const;
188  int GetDrawingYLeft() const;
189  int GetDrawingYRight() const;
191 
196  TupletNum *GetAlignedNum() { return m_alignedNum; }
197  const TupletNum *GetAlignedNum() const { return m_alignedNum; }
198  void SetAlignedNum(TupletNum *alignedNum) { m_alignedNum = alignedNum; }
200 
201  //----------//
202  // Functors //
203  //----------//
204 
209  FunctorCode Accept(Functor &functor) override;
210  FunctorCode Accept(ConstFunctor &functor) const override;
211  FunctorCode AcceptEnd(Functor &functor) override;
212  FunctorCode AcceptEnd(ConstFunctor &functor) const override;
214 
215 private:
216  //
217 public:
218  //
219 private:
224  int m_drawingXRelLeft;
229  int m_drawingXRelRight;
233  int m_drawingYRelLeft = 0;
237  int m_drawingYRelRight = 0;
239  TupletNum *m_alignedNum;
240 };
241 
242 //----------------------------------------------------------------------------
243 // TupletNum
244 //----------------------------------------------------------------------------
245 
250 class TupletNum : public LayerElement, public AttNumberPlacement, public AttTupletVis {
251 public:
257  TupletNum();
258  virtual ~TupletNum();
259  void Reset() override;
260  std::string GetClassName() const override { return "tupletNum"; }
261  Object *Clone() const override { return new TupletNum(*this); }
263 
272  int GetDrawingYMid() const;
273  int GetDrawingXMid(const Doc *doc = NULL) const;
275 
280  TupletBracket *GetAlignedBracket() { return m_alignedBracket; }
281  const TupletBracket *GetAlignedBracket() const { return m_alignedBracket; }
282  void SetAlignedBracket(TupletBracket *alignedBracket);
284 
285  //----------//
286  // Functors //
287  //----------//
288 
293  FunctorCode Accept(Functor &functor) override;
294  FunctorCode Accept(ConstFunctor &functor) const override;
295  FunctorCode AcceptEnd(Functor &functor) override;
296  FunctorCode AcceptEnd(ConstFunctor &functor) const override;
298 
299 private:
300  //
301 public:
302  //
303 private:
305  TupletBracket *m_alignedBracket;
306 };
307 
308 } // namespace vrv
309 
310 #endif
This abstract class is the base class for all const functors.
Definition: functor.h:126
This class is a hold the data and corresponds to the model of a MVC design pattern.
Definition: doc.h:41
This class models a group of dots as a layer element part and has no direct MEI equivalent.
Definition: elementpart.h:27
Object * Clone() const override
Method call for copying child classes.
Definition: elementpart.h:38
int GetFlagShift() const
Set/get methods for the flagShift.
Definition: elementpart.h:72
FunctorCode Accept(Functor &functor) override
Interface for class functor visitation.
bool HasToBeAligned() const override
Override the method since alignment is required.
Definition: elementpart.h:42
void Reset() override
Reset the object, that is 1) removing all children and 2) resetting all attributes.
This class models a stem as a layer element part and has no direct MEI equivalent.
Definition: elementpart.h:97
Object * Clone() const override
Method call for copying child classes.
Definition: elementpart.h:108
FunctorCode Accept(Functor &functor) override
Interface for class functor visitation.
int m_drawingNbFlags
The number of flags to be drawn.
Definition: elementpart.h:137
bool HasToBeAligned() const override
Override the method since alignment is required.
Definition: elementpart.h:112
void Reset() override
Reset the object, that is 1) removing all children and 2) resetting all attributes.
This abstract class is the base class for all mutable functors.
Definition: functor.h:101
This class is a base class for the Layer (<layer>) content.
Definition: layerelement.h:51
This class represents a basic object.
Definition: object.h:66
Simple class for representing points.
Definition: devicecontextbase.h:203
This class represents a staff in a laid-out score (Doc).
Definition: staff.h:110
This class models a bracket as a layer element part and has no direct MEI equivalent.
Definition: elementpart.h:150
Object * Clone() const override
Method call for copying child classes.
Definition: elementpart.h:161
void Reset() override
Reset the object, that is 1) removing all children and 2) resetting all attributes.
FunctorCode Accept(Functor &functor) override
Interface for class functor visitation.
This class models a tuplet num as a layer element part and has no direct MEI equivalent.
Definition: elementpart.h:250
void Reset() override
Reset the object, that is 1) removing all children and 2) resetting all attributes.
Object * Clone() const override
Method call for copying child classes.
Definition: elementpart.h:261
FunctorCode Accept(Functor &functor) override
Interface for class functor visitation.