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 VisitOssia(Ossia *ossia) override;
66  FunctorCode VisitSection(Section *section) override;
67  FunctorCode VisitStaff(Staff *staff) override;
68  FunctorCode VisitSystem(System *system) override;
70 
71 protected:
72  //
73 private:
74  //
75 public:
76  //
77 private:
78  // The measureAligner
79  MeasureAligner *m_measureAligner;
80  // The time
81  Fraction m_time;
82  // The current MeterSig, Mensur and Proport
83  AlignMeterParams m_currentParams;
84  // The current notation type
85  data_NOTATIONTYPE m_notationType;
86  // Indicates the state in processing the caution scoreDef
87  ElementScoreDefRole m_scoreDefRole;
88  // Indicates if we are in the first measure (for the scoreDef role)
89  bool m_isFirstMeasure;
90  // Indicates if we have multiple layer alignment references in the measure
91  bool m_hasMultipleLayer;
92  // Indicates if we are starting a new section with restart
93  bool m_sectionRestart;
94 };
95 
96 //----------------------------------------------------------------------------
97 // AlignMeasuresFunctor
98 //----------------------------------------------------------------------------
99 
105 public:
111  virtual ~AlignMeasuresFunctor() = default;
113 
114  /*
115  * Abstract base implementation
116  */
117  bool ImplementsEndInterface() const override { return true; }
118 
119  /*
120  * Set if castoff system widths should be stored
121  */
122  void StoreCastOffSystemWidths(bool storeWidths) { m_storeCastOffSystemWidths = storeWidths; }
123 
124  /*
125  * Functor interface
126  */
128  FunctorCode VisitDiv(Div *div) override;
129  FunctorCode VisitMeasure(Measure *measure) override;
130  FunctorCode VisitScoreDef(ScoreDef *scoreDef) override;
131  FunctorCode VisitSection(Section *section) override;
132  FunctorCode VisitSystem(System *system) override;
133  FunctorCode VisitSystemEnd(System *system) override;
135 
136 protected:
137  //
138 private:
139  //
140 public:
141  //
142 private:
143  // The cumulated shift
144  int m_shift;
145  // The cumulated justifiable width
146  int m_justifiableWidth;
147  // Shift next measure due to section restart?
148  bool m_applySectionRestartShift;
149  // Store castoff system widths if true
150  bool m_storeCastOffSystemWidths;
151 };
152 
153 //----------------------------------------------------------------------------
154 // AlignVerticallyFunctor
155 //----------------------------------------------------------------------------
156 
162 public:
168  virtual ~AlignVerticallyFunctor() = default;
170 
171  /*
172  * Abstract base implementation
173  */
174  bool ImplementsEndInterface() const override { return true; }
175 
176  /*
177  * Functor interface
178  */
180  FunctorCode VisitDiv(Div *div) override;
181  FunctorCode VisitFig(Fig *fig) override;
182  FunctorCode VisitMeasure(Measure *measure) override;
183  FunctorCode VisitPageEnd(Page *page) override;
184  FunctorCode VisitRend(Rend *rend) override;
185  FunctorCode VisitRunningElement(RunningElement *runningElement) override;
186  FunctorCode VisitStaff(Staff *staff) override;
187  FunctorCode VisitStaffAlignmentEnd(StaffAlignment *staffAlignment) override;
188  FunctorCode VisitSyllable(Syllable *syllable) override;
189  FunctorCode VisitSystem(System *system) override;
190  FunctorCode VisitSystemEnd(System *system) override;
191  FunctorCode VisitVerse(Verse *verse) override;
193 
194 protected:
195  //
196 private:
197  //
198 public:
199  //
200 private:
201  // The systemAligner
202  SystemAligner *m_systemAligner;
203  // The staff index
204  int m_staffIdx;
205  // The staffN
206  int m_staffN;
207  // The cumulated shift for the default alignment
208  int m_cumulatedShift;
209  // The sum of justification factors per page
210  int m_justificationSum;
211  // The page width - used for setting the horizontal position of <rend> withing text layout elements
212  int m_pageWidth;
213 };
214 
215 //----------------------------------------------------------------------------
216 // AlignSystemsFunctor
217 //----------------------------------------------------------------------------
218 
223 public:
228  AlignSystemsFunctor(Doc *doc);
229  virtual ~AlignSystemsFunctor() = default;
231 
232  /*
233  * Abstract base implementation
234  */
235  bool ImplementsEndInterface() const override { return true; }
236 
237  /*
238  * Setter for shift and spacing
239  */
241  void SetShift(int shift) { m_shift = shift; }
242  void SetSystemSpacing(int spacing) { m_systemSpacing = spacing; }
244 
245  /*
246  * Functor interface
247  */
249  FunctorCode VisitPage(Page *page) override;
250  FunctorCode VisitPageEnd(Page *page) override;
251  FunctorCode VisitSystem(System *system) override;
253 
254 protected:
255  //
256 private:
257  //
258 public:
259  //
260 private:
261  // The cumulated shift
262  int m_shift;
263  // The system margin
264  int m_systemSpacing;
265  // The (clef) overflow below of the previous system
266  int m_prevBottomOverflow;
267  int m_prevBottomClefOverflow;
268  // The sum of justification factors per page
269  double m_justificationSum;
270 };
271 
272 } // namespace vrv
273 
274 #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:104
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: alignfunctor.h:117
This class aligns the system by adjusting the m_drawingYRel position looking at the SystemAligner.
Definition: alignfunctor.h:222
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: alignfunctor.h:235
This class vertically aligns the content of a page.
Definition: alignfunctor.h:161
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: alignfunctor.h:174
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:427
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
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: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: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