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 StaffDef;
24 class Stem;
25 
26 //----------------------------------------------------------------------------
27 // DrawingListInterface
28 //----------------------------------------------------------------------------
29 
35 public:
42  virtual ~DrawingListInterface();
43  virtual void Reset();
45 
52  void AddToDrawingList(Object *element);
53 
58  ArrayOfObjects *GetDrawingList();
59 
65 
66  //-----------------//
67  // Pseudo functors //
68  //-----------------//
69 
74  FunctorCode InterfaceResetData(ResetDataFunctor &functor);
76 
77 private:
78  //
79 public:
80  //
81 protected:
83  ArrayOfObjects m_drawingList;
84 
85 private:
86  //
87 };
88 
89 //----------------------------------------------------------------------------
90 // BeamDrawingInterface
91 //----------------------------------------------------------------------------
92 
99 public:
105  virtual ~BeamDrawingInterface();
106  virtual void Reset();
108 
113  bool IsFirstIn(const LayerElement *element) const;
114  bool IsLastIn(const LayerElement *element) const;
116 
121  bool HasCoords() const { return !m_beamElementCoords.empty(); }
122  void InitCoords(const ArrayOfObjects &childList, Staff *staff, data_BEAMPLACE place);
123  void InitCoords(const ListOfObjects &childList, Staff *staff, data_BEAMPLACE place);
125 
130  void InitCue(bool beamCue);
131 
136  void InitGraceStemDir(bool graceGrp);
137 
138  bool IsHorizontal() const;
139 
140  bool IsRepeatedPattern() const;
141 
145  bool HasOneStepHeight() const;
146 
151  int GetTotalBeamWidth() const;
152 
156  void ClearCoords();
157 
161  virtual std::pair<int, int> GetAdditionalBeamCount() const { return { 0, 0 }; }
162 
166  virtual std::pair<int, int> GetFloatingBeamCount() const { return { 0, 0 }; }
167 
171  void GetBeamOverflow(StaffAlignment *&above, StaffAlignment *&below) const;
172 
176  void GetBeamChildOverflow(StaffAlignment *&above, StaffAlignment *&below) const;
177 
178  //-----------------//
179  // Pseudo functors //
180  //-----------------//
181 
186  FunctorCode InterfaceResetData(ResetDataFunctor &functor);
188 
189 protected:
194  int GetPosition(const LayerElement *element) const;
195 
196  //
197 private:
202  bool IsHorizontalMixedBeam(const std::vector<int> &items, const std::vector<data_BEAMPLACE> &directions) const;
203 
204 public:
205  // values to be set before calling CalcBeam
206  bool m_changingDur;
207  bool m_beamHasChord;
208  bool m_hasMultipleStemDir;
209  bool m_cueSize;
210  Staff *m_crossStaffContent;
211  data_STAFFREL_basic m_crossStaffRel;
212  bool m_isSpanningElement;
213  data_DURATION m_shortestDur;
214  data_STEMDIRECTION m_notesStemDir;
215  data_BEAMPLACE m_drawingPlace;
216  Staff *m_beamStaff;
217 
218  // values set by CalcBeam
219  int m_beamWidth;
220  int m_beamWidthBlack;
221  int m_beamWidthWhite;
222  int m_fractionSize;
223 
227  ArrayOfBeamElementCoords m_beamElementCoords;
228 
229 private:
230  //
231 };
232 
233 //----------------------------------------------------------------------------
234 // StaffDefDrawingInterface
235 //----------------------------------------------------------------------------
236 
246 public:
252  virtual ~StaffDefDrawingInterface();
253  virtual void Reset();
255 
260 
267  bool DrawClef() const { return (m_drawClef && m_currentClef.HasShape()); }
268  void SetDrawClef(bool drawClef) { m_drawClef = drawClef; }
269  bool DrawKeySig() const { return (m_drawKeySig); }
270  void SetDrawKeySig(bool drawKeySig) { m_drawKeySig = drawKeySig; }
271  bool DrawMensur() const { return (m_drawMensur && (m_currentMensur.HasSign() || m_currentMensur.HasNum())); }
272  void SetDrawMensur(bool drawMensur) { m_drawMensur = drawMensur; }
273  bool DrawMeterSig() const
274  {
275  return (m_drawMeterSig && (m_currentMeterSig.HasUnit() || m_currentMeterSig.HasSym()));
276  }
277  void SetDrawMeterSig(bool drawMeterSig) { m_drawMeterSig = drawMeterSig; }
278  bool DrawMeterSigGrp() const;
279  void SetDrawMeterSigGrp(bool drawMeterSigGrp) { m_drawMeterSigGrp = drawMeterSigGrp; }
281 
286  void SetCurrentClef(const Clef *clef);
287  void SetCurrentKeySig(const KeySig *keySig);
288  void SetCurrentMensur(const Mensur *mensur);
289  void SetCurrentMeterSig(const MeterSig *meterSig);
290  void SetCurrentMeterSigGrp(const MeterSigGrp *meterSigGrp);
291  void AlternateCurrentMeterSig(const Measure *measure);
292  void SetCurrentProport(const Proport *proport);
294 
300  Clef *GetCurrentClef() { return &m_currentClef; }
301  const Clef *GetCurrentClef() const { return &m_currentClef; }
302  KeySig *GetCurrentKeySig() { return &m_currentKeySig; }
303  const KeySig *GetCurrentKeySig() const { return &m_currentKeySig; }
304  Mensur *GetCurrentMensur() { return &m_currentMensur; }
305  const Mensur *GetCurrentMensur() const { return &m_currentMensur; }
306  MeterSig *GetCurrentMeterSig() { return &m_currentMeterSig; }
307  const MeterSig *GetCurrentMeterSig() const { return &m_currentMeterSig; }
308  MeterSigGrp *GetCurrentMeterSigGrp() { return &m_currentMeterSigGrp; }
309  const MeterSigGrp *GetCurrentMeterSigGrp() const { return &m_currentMeterSigGrp; }
310  Proport *GetCurrentProport() { return &m_currentProport; }
311  const Proport *GetCurrentProport() const { return &m_currentProport; }
313 
318  void AddOssiaAbove(StaffDef *ossiaStaffDef) { m_ossiasAbove.push_back(ossiaStaffDef); }
319  void AddOssiaBelow(StaffDef *ossiaStaffDef) { m_ossiasBelow.push_back(ossiaStaffDef); }
320  void GetOssiaAboveNs(std::vector<int> &staffNs) const;
321  void GetOssiaBelowNs(std::vector<int> &staffNs) const;
322  StaffDef *GetOssiaStaffDef(int staffN);
323  const StaffDef *GetOssiaStaffDef(int staffN) const;
325 
326  //-----------------//
327  // Pseudo functors //
328  //-----------------//
329 
334  FunctorCode InterfaceResetData(ResetDataFunctor &functor);
336 
337 private:
339  Clef m_currentClef;
341  KeySig m_currentKeySig;
343  Mensur m_currentMensur;
345  MeterSig m_currentMeterSig;
347  MeterSigGrp m_currentMeterSigGrp;
349  Proport m_currentProport;
350 
355  bool m_drawClef;
356  bool m_drawKeySig;
357  bool m_drawMensur;
358  bool m_drawMeterSig;
359  bool m_drawMeterSigGrp;
361 
366  std::list<StaffDef *> m_ossiasAbove;
367  std::list<StaffDef *> m_ossiasBelow;
369 };
370 
371 //----------------------------------------------------------------------------
372 // StemmedDrawingInterface
373 //----------------------------------------------------------------------------
374 
380 public:
386  virtual ~StemmedDrawingInterface();
387  virtual void Reset();
389 
394  void SetDrawingStem(Stem *stem);
395  Stem *GetDrawingStem() { return m_drawingStem; }
396  const Stem *GetDrawingStem() const { return m_drawingStem; }
398 
404  void SetDrawingStemDir(data_STEMDIRECTION stemDir);
405  data_STEMDIRECTION GetDrawingStemDir() const;
406  void SetDrawingStemLen(int drawingStemLen);
407  int GetDrawingStemLen() const;
408  int GetDrawingStemModRelY() const;
410 
411  Point GetDrawingStemStart(const Object *object = NULL) const;
412  Point GetDrawingStemEnd(const Object *object = NULL) const;
413 
418  virtual Point GetStemUpSE(const Doc *doc, int staffSize, bool graceSize) const = 0;
419  virtual Point GetStemDownNW(const Doc *doc, int staffSize, bool graceSize) const = 0;
420  virtual int CalcStemLenInThirdUnits(const Staff *staff, data_STEMDIRECTION stemDir) const = 0;
422 
423  //-----------------//
424  // Pseudo functors //
425  //-----------------//
426 
431  FunctorCode InterfaceResetData(ResetDataFunctor &functor);
433 
434 protected:
439 };
440 
441 //----------------------------------------------------------------------------
442 // VisibilityDrawingInterface
443 //----------------------------------------------------------------------------
444 
449 public:
455  virtual ~VisibilityDrawingInterface();
456  virtual void Reset();
458 
463  void SetVisibility(VisibilityType visibility) { m_visibility = visibility; }
464  bool IsHidden() const { return (m_visibility == Hidden); }
466 
467  //-----------------//
468  // Pseudo functors //
469  //-----------------//
470 
471 private:
477  VisibilityType m_visibility;
478 };
479 
480 } // namespace vrv
481 
482 #endif
This class is an interface for MEI beam elements (beam, beamSpan).
Definition: drawinginterface.h:98
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:227
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:161
virtual std::pair< int, int > GetFloatingBeamCount() const
Helper to get number of beams represented by attributes @beam and @beam.float.
Definition: drawinginterface.h:166
bool HasCoords() const
Initializes the m_beamElementCoords vector objects.
Definition: drawinginterface.h:121
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:41
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:34
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:83
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 models the MEI <mensur> element.
Definition: mensur.h:34
This class represents a MEI meterSigGrp.
Definition: metersiggrp.h:32
This class models the MEI <meterSig> element.
Definition: metersig.h:34
This class represents a basic object.
Definition: object.h:64
This class is an pseudo interface for elements maintaining a flat list of children LayerElement for p...
Definition: object.h:916
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:245
FunctorCode InterfaceResetData(ResetDataFunctor &functor)
Called explicitly from ResetDataFunctor.
void ResetOssiaStaffDefs()
Clear the ossia staffDef lists.
This class represents a staff in a laid-out score (Doc).
Definition: staff.h:110
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:379
Stem * m_drawingStem
A pointer to the child Stem set by PrepareLayerElementParts.
Definition: drawinginterface.h:438
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:448