Verovio
Source code documentation
setscoredeffunctor.h
1 // Name: setscoredeffunctor.h
3 // Author: David Bauer
4 // Created: 2022
5 // Copyright (c) Authors and others. All rights reserved.
7 
8 #ifndef __VRV_SETSCOREDEFFUNCTOR_H__
9 #define __VRV_SETSCOREDEFFUNCTOR_H__
10 
11 #include "functor.h"
12 
13 namespace vrv {
14 
15 //----------------------------------------------------------------------------
16 // ReplaceDrawingValuesInStaffDefFunctor
17 //----------------------------------------------------------------------------
18 
23 public:
28  ReplaceDrawingValuesInStaffDefFunctor(const Clef *clef, const KeySig *keySig, const Mensur *mensur,
29  const MeterSig *meterSig, const MeterSigGrp *meterSigGrp);
30  virtual ~ReplaceDrawingValuesInStaffDefFunctor() = default;
32 
33  /*
34  * Abstract base implementation
35  */
36  bool ImplementsEndInterface() const override { return false; }
37 
38  /*
39  * Functor interface
40  */
42  FunctorCode VisitStaffDef(StaffDef *staffDef) override;
44 
45 protected:
46  //
47 private:
48  //
49 public:
50  //
51 private:
52  // The clef (NULL if none)
53  const Clef *m_clef;
54  // The key signature (NULL if none)
55  const KeySig *m_keySig;
56  // The mensur (NULL if none)
57  const Mensur *m_mensur;
58  // The meter signature (NULL if none)
59  const MeterSig *m_meterSig;
60  // The meter signature group (NULL if none)
61  const MeterSigGrp *m_meterSigGrp;
62 };
63 
64 //----------------------------------------------------------------------------
65 // ScoreDefSetCurrentPageFunctor
66 //----------------------------------------------------------------------------
67 
72 public:
78  virtual ~ScoreDefSetCurrentPageFunctor() = default;
80 
81  /*
82  * Abstract base implementation
83  */
84  bool ImplementsEndInterface() const override { return true; }
85 
86  /*
87  * Functor interface
88  */
90  FunctorCode VisitPageEnd(Page *page) override;
91  FunctorCode VisitScore(Score *score) override;
93 
94 protected:
95  //
96 private:
97  //
98 public:
99  //
100 private:
101  // The list of all scores
102  std::list<Score *> m_scores;
103 };
104 
105 //----------------------------------------------------------------------------
106 // ScoreDefSetCurrentFunctor
107 //----------------------------------------------------------------------------
108 
115 public:
121  virtual ~ScoreDefSetCurrentFunctor() = default;
123 
124  /*
125  * Abstract base implementation
126  */
127  bool ImplementsEndInterface() const override { return false; }
128 
129  /*
130  * Functor interface
131  */
133  FunctorCode VisitClef(Clef *clef) override;
134  FunctorCode VisitKeySig(KeySig *keySig) override;
135  FunctorCode VisitLayer(Layer *layer) override;
136  FunctorCode VisitMeasure(Measure *measure) override;
137  FunctorCode VisitMensur(Mensur *mensur) override;
138  FunctorCode VisitPage(Page *page) override;
139  FunctorCode VisitProport(Proport *proport) override;
140  FunctorCode VisitScore(Score *score) override;
141  FunctorCode VisitScoreDef(ScoreDef *scoreDef) override;
142  FunctorCode VisitStaff(Staff *staff) override;
143  FunctorCode VisitStaffDef(StaffDef *staffDef) override;
144  FunctorCode VisitStaffGrp(StaffGrp *staffGrp) override;
145  FunctorCode VisitSystem(System *system) override;
147 
148 protected:
149  //
150 private:
151  //
152 public:
153  //
154 private:
155  // The current score
156  Score *m_currentScore;
157  // The current scoreDef
158  ScoreDef *m_currentScoreDef;
159  // The current staffDef
160  StaffDef *m_currentStaffDef;
161  // The upcoming scoreDef
162  ScoreDef m_upcomingScoreDef;
163  // The previous measure (for setting cautionary scoreDef)
164  Measure *m_previousMeasure;
165  // The current system (for setting the system scoreDef)
166  System *m_currentSystem;
167  // Flag indicating whether full labels have to be drawn
168  bool m_drawLabels;
169  // Flag indicating that the scoreDef restarts (draw brace and label)
170  bool m_restart;
171  // Flag indicating if we already have a measure in the system
172  bool m_hasMeasure;
173 };
174 
175 //----------------------------------------------------------------------------
176 // ScoreDefOptimizeFunctor
177 //----------------------------------------------------------------------------
178 
184 public:
190  virtual ~ScoreDefOptimizeFunctor() = default;
192 
193  /*
194  * Abstract base implementation
195  */
196  bool ImplementsEndInterface() const override { return true; }
197 
198  /*
199  * Functor interface
200  */
202  FunctorCode VisitMeasure(Measure *measure) override;
203  FunctorCode VisitScore(Score *score) override;
204  FunctorCode VisitStaff(Staff *staff) override;
205  FunctorCode VisitStaffGrpEnd(StaffGrp *staffGrp) override;
206  FunctorCode VisitSystem(System *system) override;
207  FunctorCode VisitSystemEnd(System *system) override;
209 
210 protected:
211  //
212 private:
213  //
214 public:
215  //
216 private:
217  // The current scoreDef
218  ScoreDef *m_currentScoreDef;
219  // Flag indicating if we are optimizing encoded layout
220  bool m_encoded;
221  // Flag indicating if we consider the first scoreDef
222  bool m_firstScoreDef;
223  // Flag indicating if a Fermata element is present
224  bool m_hasFermata;
225  // Flag indicating if a Tempo element is present
226  bool m_hasTempo;
227 };
228 
229 //----------------------------------------------------------------------------
230 // SetCautionaryScoreDefFunctor
231 //----------------------------------------------------------------------------
232 
237 public:
242  SetCautionaryScoreDefFunctor(ScoreDef *currentScoreDef);
243  virtual ~SetCautionaryScoreDefFunctor() = default;
245 
246  /*
247  * Abstract base implementation
248  */
249  bool ImplementsEndInterface() const override { return false; }
250 
251  /*
252  * Functor interface
253  */
255  FunctorCode VisitLayer(Layer *layer) override;
256  FunctorCode VisitStaff(Staff *staff) override;
258 
259 protected:
260  //
261 private:
262  //
263 public:
264  //
265 private:
266  // The current scoreDef
267  ScoreDef *m_currentScoreDef;
268  // The current staffDef
269  StaffDef *m_currentStaffDef;
270 };
271 
272 //----------------------------------------------------------------------------
273 // ScoreDefSetGrpSymFunctor
274 //----------------------------------------------------------------------------
275 
280 public:
286  virtual ~ScoreDefSetGrpSymFunctor() = default;
288 
289  /*
290  * Abstract base implementation
291  */
292  bool ImplementsEndInterface() const override { return false; }
293 
294  /*
295  * Functor interface
296  */
298  FunctorCode VisitGrpSym(GrpSym *grpSym) override;
299  FunctorCode VisitSystem(System *system) override;
301 
302 protected:
303  //
304 private:
305  //
306 public:
307  //
308 private:
309  //
310 };
311 
312 //----------------------------------------------------------------------------
313 // ScoreDefUnsetCurrentFunctor
314 //----------------------------------------------------------------------------
315 
320 public:
326  virtual ~ScoreDefUnsetCurrentFunctor() = default;
328 
329  /*
330  * Abstract base implementation
331  */
332  bool ImplementsEndInterface() const override { return false; }
333 
334  /*
335  * Functor interface
336  */
338  FunctorCode VisitAlignmentReference(AlignmentReference *alignmentReference) override;
339  FunctorCode VisitKeySig(KeySig *keySig) override;
340  FunctorCode VisitLayer(Layer *layer) override;
341  FunctorCode VisitMeasure(Measure *measure) override;
342  FunctorCode VisitPage(Page *page) override;
343  FunctorCode VisitStaff(Staff *staff) override;
344  FunctorCode VisitSystem(System *system) override;
346 
347 protected:
348  //
349 private:
350  //
351 public:
352  //
353 private:
354  //
355 };
356 
357 //----------------------------------------------------------------------------
358 // SetStaffDefRedrawFlagsFunctor
359 //----------------------------------------------------------------------------
360 
361 enum StaffDefRedrawFlags {
362  REDRAW_CLEF = 0x1,
363  REDRAW_KEYSIG = 0x2,
364  REDRAW_MENSUR = 0x4,
365  REDRAW_METERSIG = 0x8,
366  REDRAW_METERSIGGRP = 0x10,
367  // all flags
368  REDRAW_ALL = REDRAW_CLEF | REDRAW_KEYSIG | REDRAW_MENSUR | REDRAW_METERSIG | REDRAW_METERSIGGRP,
369  //
370  FORCE_REDRAW = 0x100
371 };
372 
378 public:
383  SetStaffDefRedrawFlagsFunctor(int redrawFlags);
384  virtual ~SetStaffDefRedrawFlagsFunctor() = default;
386 
387  /*
388  * Abstract base implementation
389  */
390  bool ImplementsEndInterface() const override { return false; }
391 
392  /*
393  * Functor interface
394  */
396  FunctorCode VisitStaffDef(StaffDef *staffDef) override;
398 
399 protected:
400  //
401 private:
402  //
403 public:
404  //
405 private:
406  // The staffDef redraw flags
407  int m_redrawFlags;
408 };
409 
410 } // namespace vrv
411 
412 #endif // __VRV_SETSCOREDEFFUNCTOR_H__
This class stores a references of LayerElements for a staff.
Definition: horizontalaligner.h:290
This class models the MEI <clef> element.
Definition: clef.h:39
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 abstract class is the base class for all mutable functors.
Definition: functor.h:101
This class represents a MEI grpSym.
Definition: grpsym.h:30
This class models the MEI <keySig> element.
Definition: keysig.h:52
This class represents a layer in a laid-out score (Doc).
Definition: layer.h:39
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:28
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 sets the current drawing clef, key signature, etc.
Definition: setscoredeffunctor.h:22
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:36
This class represents a MEI scoreDef.
Definition: scoredef.h:135
This class optimizes the scoreDef for each system.
Definition: setscoredeffunctor.h:183
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:196
This class sets the current scoreDef wherever needed.
Definition: setscoredeffunctor.h:114
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:127
This class sets the Page::m_score and Page::m_scoreEnd pointers.
Definition: setscoredeffunctor.h:71
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:84
This class prepares the group symbol starting and ending staffDefs for drawing.
Definition: setscoredeffunctor.h:279
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:292
This class unsets the initial scoreDef for each system and measure.
Definition: setscoredeffunctor.h:319
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:332
This class represent a <score> in MEI.
Definition: score.h:30
This class sets the cautionary scoreDef wherever needed.
Definition: setscoredeffunctor.h:236
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:249
This class sets drawing flags for the StaffDef for indicating whether clefs, keysigs,...
Definition: setscoredeffunctor.h:377
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:390
This class represents a MEI staffDef.
Definition: staffdef.h:37
This class represents a MEI staffGrp.
Definition: staffgrp.h:39
This class represents a staff in a laid-out score (Doc).
Definition: staff.h:107
This class represents a system in a laid-out score (Doc).
Definition: system.h:36