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  int num = 1;
25  int numbase = 1;
26  // Not const since we are cumulating proportion
27  Proport *proport = NULL;
28  data_DURATION equivalence = DURATION_brevis;
29  bool metcon = true;
30 };
31 
32 //----------------------------------------------------------------------------
33 // AlignHorizontallyFunctor
34 //----------------------------------------------------------------------------
35 
43 public:
49  virtual ~AlignHorizontallyFunctor() = default;
51 
52  /*
53  * Abstract base implementation
54  */
55  bool ImplementsEndInterface() const override { return true; }
56 
57  /*
58  * Functor interface
59  */
61  FunctorCode VisitLayer(Layer *layer) override;
62  FunctorCode VisitLayerEnd(Layer *layer) override;
63  FunctorCode VisitLayerElement(LayerElement *layerElement) override;
64  FunctorCode VisitMeasure(Measure *measure) override;
65  FunctorCode VisitMeasureEnd(Measure *measure) override;
66  FunctorCode VisitMeterSigGrp(MeterSigGrp *meterSigGrp) override;
67  FunctorCode VisitOssia(Ossia *ossia) override;
68  FunctorCode VisitSection(Section *section) override;
69  FunctorCode VisitStaff(Staff *staff) override;
70  FunctorCode VisitSystem(System *system) override;
72 
73 protected:
74  //
75 private:
76  //
77 public:
78  //
79 private:
80  // The measureAligner
81  MeasureAligner *m_measureAligner;
82  // The time
83  Fraction m_time;
84  // The current MeterSig, Mensur and Proport
85  AlignMeterParams m_currentParams;
86  // The current notation type
87  data_NOTATIONTYPE m_notationType;
88  // Indicates the state in processing the caution scoreDef
89  ElementScoreDefRole m_scoreDefRole;
90  // Indicates if we are in the first measure (for the scoreDef role)
91  bool m_isFirstMeasure;
92  // Indicates if we have multiple layer alignment references in the measure
93  bool m_hasMultipleLayer;
94  // Indicates if we are starting a new section with restart
95  bool m_sectionRestart;
96 };
97 
98 //----------------------------------------------------------------------------
99 // AlignMeasuresFunctor
100 //----------------------------------------------------------------------------
101 
107 public:
113  virtual ~AlignMeasuresFunctor() = default;
115 
116  /*
117  * Abstract base implementation
118  */
119  bool ImplementsEndInterface() const override { return true; }
120 
121  /*
122  * Set if castoff system widths should be stored
123  */
124  void StoreCastOffSystemWidths(bool storeWidths) { m_storeCastOffSystemWidths = storeWidths; }
125 
126  /*
127  * Functor interface
128  */
130  FunctorCode VisitDiv(Div *div) override;
131  FunctorCode VisitMeasure(Measure *measure) override;
132  FunctorCode VisitScoreDef(ScoreDef *scoreDef) override;
133  FunctorCode VisitSection(Section *section) override;
134  FunctorCode VisitSystem(System *system) override;
135  FunctorCode VisitSystemEnd(System *system) override;
137 
138 protected:
139  //
140 private:
141  //
142 public:
143  //
144 private:
145  // The cumulated shift
146  int m_shift;
147  // The cumulated justifiable width
148  int m_justifiableWidth;
149  // Shift next measure due to section restart?
150  bool m_applySectionRestartShift;
151  // Store castoff system widths if true
152  bool m_storeCastOffSystemWidths;
153 };
154 
155 //----------------------------------------------------------------------------
156 // AlignVerticallyFunctor
157 //----------------------------------------------------------------------------
158 
164 public:
170  virtual ~AlignVerticallyFunctor() = default;
172 
173  /*
174  * Abstract base implementation
175  */
176  bool ImplementsEndInterface() const override { return true; }
177 
178  /*
179  * Functor interface
180  */
182  FunctorCode VisitDiv(Div *div) override;
183  FunctorCode VisitFig(Fig *fig) override;
184  FunctorCode VisitMeasure(Measure *measure) override;
185  FunctorCode VisitPageEnd(Page *page) override;
186  FunctorCode VisitRend(Rend *rend) override;
187  FunctorCode VisitRunningElement(RunningElement *runningElement) override;
188  FunctorCode VisitStaff(Staff *staff) override;
189  FunctorCode VisitStaffAlignmentEnd(StaffAlignment *staffAlignment) override;
190  FunctorCode VisitSyllable(Syllable *syllable) override;
191  FunctorCode VisitSystem(System *system) override;
192  FunctorCode VisitSystemEnd(System *system) override;
193  FunctorCode VisitRefrain(Refrain *refrain) override;
194  FunctorCode VisitVerse(Verse *verse) override;
196 
197 protected:
198  //
199 private:
200  //
201 public:
202  //
203 private:
204  // The systemAligner
205  SystemAligner *m_systemAligner;
206  // The staff index
207  int m_staffIdx;
208  // The staffN
209  int m_staffN;
210  // The cumulated shift for the default alignment
211  int m_cumulatedShift;
212  // The sum of justification factors per page
213  int m_justificationSum;
214  // The page width - used for setting the horizontal position of <rend> withing text layout elements
215  int m_pageWidth;
216 };
217 
218 //----------------------------------------------------------------------------
219 // AlignSystemsFunctor
220 //----------------------------------------------------------------------------
221 
226 public:
231  AlignSystemsFunctor(Doc *doc);
232  virtual ~AlignSystemsFunctor() = default;
234 
235  /*
236  * Abstract base implementation
237  */
238  bool ImplementsEndInterface() const override { return true; }
239 
240  /*
241  * Setter for shift and spacing
242  */
244  void SetShift(int shift) { m_shift = shift; }
245  void SetSystemSpacing(int spacing) { m_systemSpacing = spacing; }
247 
248  /*
249  * Functor interface
250  */
252  FunctorCode VisitPage(Page *page) override;
253  FunctorCode VisitPageEnd(Page *page) override;
254  FunctorCode VisitSystem(System *system) override;
256 
257 protected:
258  //
259 private:
260  //
261 public:
262  //
263 private:
264  // The cumulated shift
265  int m_shift;
266  // The system margin
267  int m_systemSpacing;
268  // The (clef) overflow below of the previous system
269  int m_prevBottomOverflow;
270  int m_prevBottomClefOverflow;
271  // The sum of justification factors per page
272  double m_justificationSum;
273 };
274 
275 } // namespace vrv
276 
277 #endif // __VRV_ALIGNFUNCTOR_H__
This class aligns horizontally the content of a page.
Definition: alignfunctor.h:42
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: alignfunctor.h:55
This class aligns the measures by adjusting the m_drawingXRel position looking at the MeasureAligner.
Definition: alignfunctor.h:106
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: alignfunctor.h:119
This class aligns the system by adjusting the m_drawingYRel position looking at the SystemAligner.
Definition: alignfunctor.h:225
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: alignfunctor.h:238
This class vertically aligns the content of a page.
Definition: alignfunctor.h:163
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: alignfunctor.h:176
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:40
This class aligns the content of a measure It contains a vector of Alignment.
Definition: horizontalaligner.h:433
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 an ossia.
Definition: ossia.h:28
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
Recurring note-attached lyrics, such as a chorus.
Definition: refrain.h:19
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:180
This class represents a staff in a laid-out score (Doc).
Definition: staff.h:110
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:33
This class represents a system in a laid-out score (Doc).
Definition: system.h:36
Definition: verse.h:21
Regroup pointers to meterSig, mensur and proport objects.
Definition: alignfunctor.h:21