Verovio
Source code documentation
miscfunctor.h
1 // Name: miscfunctor.h
3 // Author: David Bauer
4 // Created: 2023
5 // Copyright (c) Authors and others. All rights reserved.
7 
8 #ifndef __VRV_MISCFUNCTOR_H__
9 #define __VRV_MISCFUNCTOR_H__
10 
11 #include "functor.h"
12 
13 namespace vrv {
14 
15 class LyricElement;
16 
17 //----------------------------------------------------------------------------
18 // ApplyPPUFactorFunctor
19 //----------------------------------------------------------------------------
20 
25 public:
30  ApplyPPUFactorFunctor(Page *page = NULL);
31  virtual ~ApplyPPUFactorFunctor() = default;
33 
34  /*
35  * Abstract base implementation
36  */
37  bool ImplementsEndInterface() const override { return false; }
38 
39  /*
40  * Functor interface
41  */
43  FunctorCode VisitLayerElement(LayerElement *layerElement) override;
44  FunctorCode VisitMeasure(Measure *measure) override;
45  FunctorCode VisitPage(Page *page) override;
46  FunctorCode VisitStaff(Staff *staff) override;
47  FunctorCode VisitSurface(Surface *surface) override;
48  FunctorCode VisitSystem(System *system) override;
49  FunctorCode VisitZone(Zone *zone) override;
51 
52 protected:
53  //
54 private:
55  //
56 public:
57  //
58 private:
59  // The current page
60  Page *m_page;
61 };
62 
63 //----------------------------------------------------------------------------
64 // GetAlignmentLeftRightFunctor
65 //----------------------------------------------------------------------------
66 
71 public:
77  virtual ~GetAlignmentLeftRightFunctor() = default;
79 
80  /*
81  * Abstract base implementation
82  */
83  bool ImplementsEndInterface() const override { return false; }
84 
85  /*
86  * Set the classes to exclude
87  */
88  void ExcludeClasses(const std::vector<ClassId> &excludeClasses) { m_excludeClasses = excludeClasses; }
89 
90  /*
91  * Get the minimum left and maximum right
92  */
94  int GetMinLeft() const { return m_minLeft; }
95  int GetMaxRight() const { return m_maxRight; }
97 
98  /*
99  * Functor interface
100  */
102  FunctorCode VisitObject(const Object *object) override;
104 
105 protected:
106  //
107 private:
108  //
109 public:
110  //
111 private:
112  // The min left and right
113  int m_minLeft;
114  int m_maxRight;
115  // The classes which are ignored
116  std::vector<ClassId> m_excludeClasses;
117 };
118 
119 //----------------------------------------------------------------------------
120 // InitProcessingListsFunctor
121 //----------------------------------------------------------------------------
122 
127 public:
133  virtual ~InitProcessingListsFunctor() = default;
135 
136  /*
137  * Abstract base implementation
138  */
139  bool ImplementsEndInterface() const override { return false; }
140 
141  /*
142  * Getter for the int trees
143  */
145  const IntTree &GetLayerTree()
146  {
147  this->PrepareLyricElementTracks();
148  return m_layerTree;
149  }
150  const IntTree &GetVerseTree();
152 
153  /*
154  * Functor interface
155  */
157  FunctorCode VisitLayer(const Layer *layer) override;
158  FunctorCode VisitRefrain(const Refrain *refrain) override;
159  FunctorCode VisitVerse(const Verse *verse) override;
161 
162 protected:
163  //
164 private:
165  //
166 public:
167  //
168 private:
169  void PrepareLyricElementTracks();
170  void CollectLyricElement(const LyricElement *lyricElement);
171 
172  // The IntTree for staff/layer
173  IntTree m_layerTree;
174  // The IntTree for staff/layer/verse/volta-track. Track 0 is direct verse content.
175  IntTree m_verseTree;
176  // Lyric elements collected before stable drawing and processing slots are assigned.
177  std::vector<const LyricElement *> m_lyricElements;
178  bool m_lyricElementTracksPrepared = false;
179  // Stable volta track numbers, allocated in document order for each staff/layer/lyric group.
180  std::map<std::tuple<int, int, int, std::string>, int> m_voltaTracks;
181  std::map<std::tuple<int, int, int>, int> m_nextVoltaTrack;
182  // Lyric elements grouped together so a direct-syllable track is reflected at every note.
183  std::map<std::tuple<int, int, int>, std::vector<const LyricElement *>> m_lyricElementGroups;
184  std::set<std::tuple<int, int, int>> m_directSylTrackGroups;
185 };
186 
187 //----------------------------------------------------------------------------
188 // ReorderByXPosFunctor
189 //----------------------------------------------------------------------------
190 
195 public:
201  virtual ~ReorderByXPosFunctor() = default;
203 
204  /*
205  * Abstract base implementation
206  */
207  bool ImplementsEndInterface() const override { return false; }
208 
209  /*
210  * Functor interface
211  */
213  FunctorCode VisitObject(Object *object) override;
215 
216 protected:
217  //
218 private:
219  //
220 public:
221  //
222 private:
223  //
224 };
225 
226 } // namespace vrv
227 
228 #endif // __VRV_MISCFUNCTOR_H__
This class applies the Pixel Per Unit factor of the page to its elements.
Definition: miscfunctor.h:24
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: miscfunctor.h:37
This abstract class is the base class for all const functors.
Definition: functor.h:126
This abstract class is the base class for all mutable functors.
Definition: functor.h:101
This class retrieves the minimum left and maximum right for an alignment.
Definition: miscfunctor.h:70
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: miscfunctor.h:83
This class builds trees of ints with staff/layer and staff/layer/verse/volta-track numbers.
Definition: miscfunctor.h:126
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: miscfunctor.h:139
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 represents a basic object.
Definition: object.h:66
This class represents a page in a laid-out score (Doc).
Definition: page.h:31
This class reorders elements by x-position.
Definition: miscfunctor.h:194
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: miscfunctor.h:207
This class represents a staff in a laid-out score (Doc).
Definition: staff.h:110
Implements the surface element in MEI.
Definition: surface.h:30
This class represents a system in a laid-out score (Doc).
Definition: system.h:36
Implements the zone element in MEI.
Definition: zone.h:30
Generic int map recursive structure for storing hierachy of values For example, we want to process al...
Definition: vrvdef.h:437