Verovio
Source code documentation
drawinginterface.h
1 // Name: drawinginterface.h
3 // Author: Laurent Pugin
4 // Created: 2015
5 // Copyright (c) Authors and others. All rights reserved.
7 
8 #ifndef __VRV_DRAWING_INTERFACE_H__
9 #define __VRV_DRAWING_INTERFACE_H__
10 
11 #include "clef.h"
12 #include "devicecontextbase.h"
13 #include "keysig.h"
14 #include "mensur.h"
15 #include "metersig.h"
16 #include "metersiggrp.h"
17 #include "proport.h"
18 #include "vrvdef.h"
19 
20 namespace vrv {
21 
22 class Object;
23 class Stem;
24 
25 //----------------------------------------------------------------------------
26 // DrawingListInterface
27 //----------------------------------------------------------------------------
28 
34 public:
41  virtual ~DrawingListInterface();
42  virtual void Reset();
44 
51  void AddToDrawingList(Object *element);
52 
57  ArrayOfObjects *GetDrawingList();
58 
64 
65  //-----------------//
66  // Pseudo functors //
67  //-----------------//
68 
73  FunctorCode InterfaceResetData(ResetDataFunctor &functor);
75 
76 private:
77  //
78 public:
79  //
80 protected:
82  ArrayOfObjects m_drawingList;
83 
84 private:
85  //
86 };
87 
88 //----------------------------------------------------------------------------
89 // BeamDrawingInterface
90 //----------------------------------------------------------------------------
91 
98 public:
104  virtual ~BeamDrawingInterface();
105  virtual void Reset();
107 
112  bool IsFirstIn(const LayerElement *element) const;
113  bool IsLastIn(const LayerElement *element) const;
115 
120  bool HasCoords() const { return !m_beamElementCoords.empty(); }
121  void InitCoords(const ArrayOfObjects &childList, Staff *staff, data_BEAMPLACE place);
122  void InitCoords(const ListOfObjects &childList, Staff *staff, data_BEAMPLACE place);
124 
129  void InitCue(bool beamCue);
130 
135  void InitGraceStemDir(bool graceGrp);
136 
137  bool IsHorizontal() const;
138 
139  bool IsRepeatedPattern() const;
140 
144  bool HasOneStepHeight() const;
145 
150  int GetTotalBeamWidth() const;
151 
155  void ClearCoords();
156 
160  virtual std::pair<int, int> GetAdditionalBeamCount() const { return { 0, 0 }; }
161 
165  virtual std::pair<int, int> GetFloatingBeamCount() const { return { 0, 0 }; }
166 
170  void GetBeamOverflow(StaffAlignment *&above, StaffAlignment *&below) const;
171 
175  void GetBeamChildOverflow(StaffAlignment *&above, StaffAlignment *&below) const;
176 
177  //-----------------//
178  // Pseudo functors //
179  //-----------------//
180 
185  FunctorCode InterfaceResetData(ResetDataFunctor &functor);
187 
188 protected:
193  int GetPosition(const LayerElement *element) const;
194 
195  //
196 private:
201  bool IsHorizontalMixedBeam(const std::vector<int> &items, const std::vector<data_BEAMPLACE> &directions) const;
202 
203 public:
204  // values to be set before calling CalcBeam
205  bool m_changingDur;
206  bool m_beamHasChord;
207  bool m_hasMultipleStemDir;
208  bool m_cueSize;
209  Staff *m_crossStaffContent;
210  data_STAFFREL_basic m_crossStaffRel;
211  bool m_isSpanningElement;
212  data_DURATION m_shortestDur;
213  data_STEMDIRECTION m_notesStemDir;
214  data_BEAMPLACE m_drawingPlace;
215  Staff *m_beamStaff;
216 
217  // values set by CalcBeam
218  int m_beamWidth;
219  int m_beamWidthBlack;
220  int m_beamWidthWhite;
221  int m_fractionSize;
222 
226  ArrayOfBeamElementCoords m_beamElementCoords;
227 
228 private:
229  //
230 };
231 
232 //----------------------------------------------------------------------------
233 // StaffDefDrawingInterface
234 //----------------------------------------------------------------------------
235 
245 public:
251  virtual ~StaffDefDrawingInterface();
252  virtual void Reset();
254 
261  bool DrawClef() const { return (m_drawClef && m_currentClef.HasShape()); }
262  void SetDrawClef(bool drawClef) { m_drawClef = drawClef; }
263  bool DrawKeySig() const { return (m_drawKeySig); }
264  void SetDrawKeySig(bool drawKeySig) { m_drawKeySig = drawKeySig; }
265  bool DrawMensur() const { return (m_drawMensur && (m_currentMensur.HasSign() || m_currentMensur.HasNum())); }
266  void SetDrawMensur(bool drawMensur) { m_drawMensur = drawMensur; }
267  bool DrawMeterSig() const
268  {
269  return (m_drawMeterSig && (m_currentMeterSig.HasUnit() || m_currentMeterSig.HasSym()));
270  }
271  void SetDrawMeterSig(bool drawMeterSig) { m_drawMeterSig = drawMeterSig; }
272  bool DrawMeterSigGrp() const;
273  void SetDrawMeterSigGrp(bool drawMeterSigGrp) { m_drawMeterSigGrp = drawMeterSigGrp; }
275 
280  void SetCurrentClef(const Clef *clef);
281  void SetCurrentKeySig(const KeySig *keySig);
282  void SetCurrentMensur(const Mensur *mensur);
283  void SetCurrentMeterSig(const MeterSig *meterSig);
284  void SetCurrentMeterSigGrp(const MeterSigGrp *meterSigGrp);
285  void AlternateCurrentMeterSig(const Measure *measure);
286  void SetCurrentProport(const Proport *proport);
288 
294  Clef *GetCurrentClef() { return &m_currentClef; }
295  const Clef *GetCurrentClef() const { return &m_currentClef; }
296  KeySig *GetCurrentKeySig() { return &m_currentKeySig; }
297  const KeySig *GetCurrentKeySig() const { return &m_currentKeySig; }
298  Mensur *GetCurrentMensur() { return &m_currentMensur; }
299  const Mensur *GetCurrentMensur() const { return &m_currentMensur; }
300  MeterSig *GetCurrentMeterSig() { return &m_currentMeterSig; }
301  const MeterSig *GetCurrentMeterSig() const { return &m_currentMeterSig; }
302  MeterSigGrp *GetCurrentMeterSigGrp() { return &m_currentMeterSigGrp; }
303  const MeterSigGrp *GetCurrentMeterSigGrp() const { return &m_currentMeterSigGrp; }
304  Proport *GetCurrentProport() { return &m_currentProport; }
305  const Proport *GetCurrentProport() const { return &m_currentProport; }
307 
308  //-----------------//
309  // Pseudo functors //
310  //-----------------//
311 
316  FunctorCode InterfaceResetData(ResetDataFunctor &functor);
318 
319 private:
321  Clef m_currentClef;
323  KeySig m_currentKeySig;
325  Mensur m_currentMensur;
327  MeterSig m_currentMeterSig;
329  MeterSigGrp m_currentMeterSigGrp;
331  Proport m_currentProport;
332 
337  bool m_drawClef;
338  bool m_drawKeySig;
339  bool m_drawMensur;
340  bool m_drawMeterSig;
341  bool m_drawMeterSigGrp;
343 };
344 
345 //----------------------------------------------------------------------------
346 // StemmedDrawingInterface
347 //----------------------------------------------------------------------------
348 
354 public:
360  virtual ~StemmedDrawingInterface();
361  virtual void Reset();
363 
368  void SetDrawingStem(Stem *stem);
369  Stem *GetDrawingStem() { return m_drawingStem; }
370  const Stem *GetDrawingStem() const { return m_drawingStem; }
372 
378  void SetDrawingStemDir(data_STEMDIRECTION stemDir);
379  data_STEMDIRECTION GetDrawingStemDir() const;
380  void SetDrawingStemLen(int drawingStemLen);
381  int GetDrawingStemLen() const;
382  int GetDrawingStemModRelY() const;
384 
385  Point GetDrawingStemStart(const Object *object = NULL) const;
386  Point GetDrawingStemEnd(const Object *object = NULL) const;
387 
392  virtual Point GetStemUpSE(const Doc *doc, int staffSize, bool graceSize) const = 0;
393  virtual Point GetStemDownNW(const Doc *doc, int staffSize, bool graceSize) const = 0;
394  virtual int CalcStemLenInThirdUnits(const Staff *staff, data_STEMDIRECTION stemDir) const = 0;
396 
397  //-----------------//
398  // Pseudo functors //
399  //-----------------//
400 
405  FunctorCode InterfaceResetData(ResetDataFunctor &functor);
407 
408 protected:
413 };
414 
415 //----------------------------------------------------------------------------
416 // VisibilityDrawingInterface
417 //----------------------------------------------------------------------------
418 
423 public:
429  virtual ~VisibilityDrawingInterface();
430  virtual void Reset();
432 
437  void SetVisibility(VisibilityType visibility) { m_visibility = visibility; }
438  bool IsHidden() const { return (m_visibility == Hidden); }
440 
441  //-----------------//
442  // Pseudo functors //
443  //-----------------//
444 
445 private:
451  VisibilityType m_visibility;
452 };
453 
454 } // namespace vrv
455 
456 #endif
This class is an interface for MEI beam elements (beam, beamSpan).
Definition: drawinginterface.h:97
void InitGraceStemDir(bool graceGrp)
Initialize m_notesStemDir value based on the @graceGrp attribute and presence of child elements with ...
ArrayOfBeamElementCoords m_beamElementCoords
An array of coordinates for each element.
Definition: drawinginterface.h:226
void GetBeamChildOverflow(StaffAlignment *&above, StaffAlignment *&below) const
Get above/below overflow for the children.
virtual std::pair< int, int > GetAdditionalBeamCount() const
Helper to find number of additional beams.
Definition: drawinginterface.h:160
virtual std::pair< int, int > GetFloatingBeamCount() const
Helper to get number of beams represented by attributes @beam and @beam.float.
Definition: drawinginterface.h:165
bool HasCoords() const
Initializes the m_beamElementCoords vector objects.
Definition: drawinginterface.h:120
int GetPosition(const LayerElement *element) const
Return the position of the element in the beam.
bool IsFirstIn(const LayerElement *element) const
Return information about the position in the beam.
void GetBeamOverflow(StaffAlignment *&above, StaffAlignment *&below) const
Get above/below overflow.
void ClearCoords()
Clear the m_beamElementCoords vector and delete all the objects.
int GetTotalBeamWidth() const
Get total beam width with regards to the shortest duration of the beam (counting both beams and white...
void InitCue(bool beamCue)
Initialize m_cueSize value based on the @cue attribute and presence of child elements with @cue attri...
bool HasOneStepHeight() const
Checks whether difference between highest and lowest notes of the beam is just one step.
FunctorCode InterfaceResetData(ResetDataFunctor &functor)
Called explicitly from ResetDataFunctor.
This class models the MEI <clef> element.
Definition: clef.h:39
This class is a hold the data and corresponds to the model of a MVC design pattern.
Definition: doc.h:41
This class is an interface for elements with duration, such as notes and rests.
Definition: drawinginterface.h:33
void AddToDrawingList(Object *element)
Add an element to the drawing list.
ArrayOfObjects m_drawingList
The list of object for which drawing is postponed.
Definition: drawinginterface.h:82
FunctorCode InterfaceResetData(ResetDataFunctor &functor)
Called explicitly from ResetDataFunctor.
void ResetDrawingList()
Reset the drawing list.
ArrayOfObjects * GetDrawingList()
Return the drawing list.
This class models the MEI <keySig> element.
Definition: keysig.h:52
This class is a base class for the Layer (<layer>) content.
Definition: layerelement.h:51
This class represents a measure in a page-based score (Doc).
Definition: measure.h:46
This class models the MEI <mensur> element.
Definition: mensur.h:34
This class represents a MEI meterSigGrp.
Definition: metersiggrp.h:28
This class models the MEI <meterSig> element.
Definition: metersig.h:34
This class represents a basic object.
Definition: object.h:61
This class is an pseudo interface for elements maintaining a flat list of children LayerElement for p...
Definition: object.h:893
Simple class for representing points.
Definition: devicecontextbase.h:203
This class models the MEI <proport> element.
Definition: proport.h:23
This class resets the drawing values before calling PrepareData after changes.
Definition: resetfunctor.h:22
This class stores an alignement position staves will point to.
Definition: verticalaligner.h:172
This class is an interface for MEI scoreDef or staffDef attributes clef, keysig and mensur.
Definition: drawinginterface.h:244
FunctorCode InterfaceResetData(ResetDataFunctor &functor)
Called explicitly from ResetDataFunctor.
This class represents a staff in a laid-out score (Doc).
Definition: staff.h:107
This class models a stem as a layer element part and as MEI <stem> element.
Definition: stem.h:27
This class is an interface for MEI stemmed element.
Definition: drawinginterface.h:353
Stem * m_drawingStem
A pointer to the child Stem set by PrepareLayerElementParts.
Definition: drawinginterface.h:412
FunctorCode InterfaceResetData(ResetDataFunctor &functor)
Called explicitly from ResetDataFunctor.
This class is an interface for MEI element that can be hidden during drawing.
Definition: drawinginterface.h:422