Verovio
Source code documentation
alignfunctor.h
1 // Name: alignfunctor.h
3 // Author: David Bauer
4 // Created: 2023
5 // Copyright (c) Authors and others. All rights reserved.
7 
8 #ifndef __VRV_ALIGNFUNCTOR_H__
9 #define __VRV_ALIGNFUNCTOR_H__
10 
11 #include "functor.h"
12 
13 namespace vrv {
14 
15 //----------------------------------------------------------------------------
16 // AlignMeterParams
17 //----------------------------------------------------------------------------
22  const MeterSig *meterSig = NULL;
23  const Mensur *mensur = NULL;
24  // Not const since we are cumulating proportion
25  Proport *proport = NULL;
26  data_DURATION equivalence = DURATION_brevis;
27  bool metcon = true;
28 };
29 
30 //----------------------------------------------------------------------------
31 // AlignHorizontallyFunctor
32 //----------------------------------------------------------------------------
33 
41 public:
47  virtual ~AlignHorizontallyFunctor() = default;
49 
50  /*
51  * Abstract base implementation
52  */
53  bool ImplementsEndInterface() const override { return true; }
54 
55  /*
56  * Functor interface
57  */
59  FunctorCode VisitLayer(Layer *layer) override;
60  FunctorCode VisitLayerEnd(Layer *layer) override;
61  FunctorCode VisitLayerElement(LayerElement *layerElement) override;
62  FunctorCode VisitMeasure(Measure *measure) override;
63  FunctorCode VisitMeasureEnd(Measure *measure) override;
64  FunctorCode VisitMeterSigGrp(MeterSigGrp *meterSigGrp) override;
65  FunctorCode VisitSection(Section *section) override;
66  FunctorCode VisitStaff(Staff *staff) override;
67  FunctorCode VisitSystem(System *system) override;
69 
70 protected:
71  //
72 private:
73  //
74 public:
75  //
76 private:
77  // The measureAligner
78  MeasureAligner *m_measureAligner;
79  // The time
80  Fraction m_time;
81  // The current MeterSig, Mensur and Proport
82  AlignMeterParams m_currentParams;
83  // The current notation type
84  data_NOTATIONTYPE m_notationType;
85  // Indicates the state in processing the caution scoreDef
86  ElementScoreDefRole m_scoreDefRole;
87  // Indicates if we are in the first measure (for the scoreDef role)
88  bool m_isFirstMeasure;
89  // Indicates if we have multiple layer alignment references in the measure
90  bool m_hasMultipleLayer;
91  // Indicates if we are starting a new section with restart
92  bool m_sectionRestart;
93 };
94 
95 //----------------------------------------------------------------------------
96 // AlignMeasuresFunctor
97 //----------------------------------------------------------------------------
98 
104 public:
110  virtual ~AlignMeasuresFunctor() = default;
112 
113  /*
114  * Abstract base implementation
115  */
116  bool ImplementsEndInterface() const override { return true; }
117 
118  /*
119  * Set if castoff system widths should be stored
120  */
121  void StoreCastOffSystemWidths(bool storeWidths) { m_storeCastOffSystemWidths = storeWidths; }
122 
123  /*
124  * Functor interface
125  */
127  FunctorCode VisitDiv(Div *div) override;
128  FunctorCode VisitMeasure(Measure *measure) override;
129  FunctorCode VisitScoreDef(ScoreDef *scoreDef) override;
130  FunctorCode VisitSection(Section *section) override;
131  FunctorCode VisitSystem(System *system) override;
132  FunctorCode VisitSystemEnd(System *system) override;
134 
135 protected:
136  //
137 private:
138  //
139 public:
140  //
141 private:
142  // The cumulated shift
143  int m_shift;
144  // The cumulated justifiable width
145  int m_justifiableWidth;
146  // Shift next measure due to section restart?
147  bool m_applySectionRestartShift;
148  // Store castoff system widths if true
149  bool m_storeCastOffSystemWidths;
150 };
151 
152 //----------------------------------------------------------------------------
153 // AlignVerticallyFunctor
154 //----------------------------------------------------------------------------
155 
161 public:
167  virtual ~AlignVerticallyFunctor() = default;
169 
170  /*
171  * Abstract base implementation
172  */
173  bool ImplementsEndInterface() const override { return true; }
174 
175  /*
176  * Functor interface
177  */
179  FunctorCode VisitDiv(Div *div) override;
180  FunctorCode VisitFig(Fig *fig) override;
181  FunctorCode VisitMeasure(Measure *measure) override;
182  FunctorCode VisitPageEnd(Page *page) override;
183  FunctorCode VisitRend(Rend *rend) override;
184  FunctorCode VisitRunningElement(RunningElement *runningElement) override;
185  FunctorCode VisitStaff(Staff *staff) override;
186  FunctorCode VisitStaffAlignmentEnd(StaffAlignment *staffAlignment) override;
187  FunctorCode VisitSyllable(Syllable *syllable) override;
188  FunctorCode VisitSystem(System *system) override;
189  FunctorCode VisitSystemEnd(System *system) override;
190  FunctorCode VisitVerse(Verse *verse) override;
192 
193 protected:
194  //
195 private:
196  //
197 public:
198  //
199 private:
200  // The systemAligner
201  SystemAligner *m_systemAligner;
202  // The staff index
203  int m_staffIdx;
204  // The staffN
205  int m_staffN;
206  // The cumulated shift for the default alignment
207  int m_cumulatedShift;
208  // The sum of justification factors per page
209  int m_justificationSum;
210  // The page width - used for setting the horizontal position of <rend> withing text layout elements
211  int m_pageWidth;
212 };
213 
214 //----------------------------------------------------------------------------
215 // AlignSystemsFunctor
216 //----------------------------------------------------------------------------
217 
222 public:
227  AlignSystemsFunctor(Doc *doc);
228  virtual ~AlignSystemsFunctor() = default;
230 
231  /*
232  * Abstract base implementation
233  */
234  bool ImplementsEndInterface() const override { return true; }
235 
236  /*
237  * Setter for shift and spacing
238  */
240  void SetShift(int shift) { m_shift = shift; }
241  void SetSystemSpacing(int spacing) { m_systemSpacing = spacing; }
243 
244  /*
245  * Functor interface
246  */
248  FunctorCode VisitPage(Page *page) override;
249  FunctorCode VisitPageEnd(Page *page) override;
250  FunctorCode VisitSystem(System *system) override;
252 
253 protected:
254  //
255 private:
256  //
257 public:
258  //
259 private:
260  // The cumulated shift
261  int m_shift;
262  // The system margin
263  int m_systemSpacing;
264  // The (clef) overflow below of the previous system
265  int m_prevBottomOverflow;
266  int m_prevBottomClefOverflow;
267  // The sum of justification factors per page
268  double m_justificationSum;
269 };
270 
271 } // namespace vrv
272 
273 #endif // __VRV_ALIGNFUNCTOR_H__
This class aligns horizontally the content of a page.
Definition: alignfunctor.h:40
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: alignfunctor.h:53
This class aligns the measures by adjusting the m_drawingXRel position looking at the MeasureAligner.
Definition: alignfunctor.h:103
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: alignfunctor.h:116
This class aligns the system by adjusting the m_drawingYRel position looking at the SystemAligner.
Definition: alignfunctor.h:221
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: alignfunctor.h:234
This class vertically aligns the content of a page.
Definition: alignfunctor.h:160
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: alignfunctor.h:173
This class represents an MEI Div.
Definition: div.h:24
This abstract class is the base class for all mutable functors that need access to the document.
Definition: functor.h:151
This class is a hold the data and corresponds to the model of a MVC design pattern.
Definition: doc.h:41
This class models the MEI <fig> element.
Definition: fig.h:23
Definition: fraction.h:19
This class is a base class for the Layer (<layer>) content.
Definition: layerelement.h:51
This class represents a layer in a laid-out score (Doc).
Definition: layer.h:39
This class aligns the content of a measure It contains a vector of Alignment.
Definition: horizontalaligner.h:425
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:32
This class models the MEI <meterSig> element.
Definition: metersig.h:34
This class represents a page in a laid-out score (Doc).
Definition: page.h:31
This class models the MEI <proport> element.
Definition: proport.h:23
This class models the MEI <rend> element.
Definition: rend.h:33
This class represents running elements (headers and footers).
Definition: runningelement.h:28
This class represents a MEI section.
Definition: section.h:28
This class stores an alignement position staves will point to.
Definition: verticalaligner.h:172
This class represents a staff in a laid-out score (Doc).
Definition: staff.h:107
This class models the MEI <mensur> element.
Definition: syllable.h:25
This class aligns the content of a system It contains a vector of StaffAlignment.
Definition: verticalaligner.h:31
This class represents a system in a laid-out score (Doc).
Definition: system.h:36
Definition: verse.h:28
Regroup pointers to meterSig, mensur and proport objects.
Definition: alignfunctor.h:21