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, const ScoreDef *newScoreDef, int &redrawFlags);
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  // The newScoreDef for accessing values in each new staffDef
63  const ScoreDef *m_newScoreDef;
64  // The redraw flags
65  int *m_redrawFlags;
66 };
67 
68 //----------------------------------------------------------------------------
69 // ScoreDefSetCurrentPageFunctor
70 //----------------------------------------------------------------------------
71 
76 public:
82  virtual ~ScoreDefSetCurrentPageFunctor() = default;
84 
85  /*
86  * Abstract base implementation
87  */
88  bool ImplementsEndInterface() const override { return true; }
89 
90  /*
91  * Functor interface
92  */
94  FunctorCode VisitPageEnd(Page *page) override;
95  FunctorCode VisitScore(Score *score) override;
97 
98 protected:
99  //
100 private:
101  //
102 public:
103  //
104 private:
105  // The list of all scores
106  std::list<Score *> m_scores;
107 };
108 
109 //----------------------------------------------------------------------------
110 // ScoreDefSetCurrentFunctor
111 //----------------------------------------------------------------------------
112 
119 public:
125  virtual ~ScoreDefSetCurrentFunctor() = default;
127 
128  /*
129  * Abstract base implementation
130  */
131  bool ImplementsEndInterface() const override { return true; }
132 
133  /*
134  * Getter for ossia flag
135  */
136  bool HasOssia() const { return m_hasOssia; }
137 
138  /*
139  * Functor interface
140  */
142  FunctorCode VisitClef(Clef *clef) override;
143  FunctorCode VisitKeySig(KeySig *keySig) override;
144  FunctorCode VisitLayer(Layer *layer) override;
145  FunctorCode VisitMeasure(Measure *measure) override;
146  FunctorCode VisitMensur(Mensur *mensur) override;
147  FunctorCode VisitOssia(Ossia *ossia) override;
148  FunctorCode VisitPage(Page *page) override;
149  FunctorCode VisitProport(Proport *proport) override;
150  FunctorCode VisitScore(Score *score) override;
151  FunctorCode VisitScoreDef(ScoreDef *scoreDef) override;
152  FunctorCode VisitStaff(Staff *staff) override;
153  FunctorCode VisitStaffDef(StaffDef *staffDef) override;
154  FunctorCode VisitStaffGrp(StaffGrp *staffGrp) override;
155  FunctorCode VisitSystem(System *system) override;
156  FunctorCode VisitSystemEnd(System *system) override;
158 
159 protected:
160  //
161 private:
162  //
163 public:
164  //
165 private:
166  // The current score
167  Score *m_currentScore;
168  // The current scoreDef
169  ScoreDef *m_currentScoreDef;
170  // The current staffDef
171  StaffDef *m_currentStaffDef;
172  // The upcoming scoreDef
173  ScoreDef m_upcomingScoreDef;
174  // The previous measure (for setting cautionary scoreDef)
175  Measure *m_previousMeasure;
176  // The current system (for setting the system scoreDef)
177  System *m_currentSystem;
178  // Flag indicating whether full labels have to be drawn
179  bool m_drawLabels;
180  // Flag indicating that the scoreDef restarts (draw brace and label)
181  bool m_restart;
182  // Flag indicating if we already have a measure in the system
183  bool m_hasMeasure;
184  // Map of ossia above a given staffN
185  MapOfOssiaStaffNs m_ossiasAbove;
186  // Map of ossia below a given staffN
187  MapOfOssiaStaffNs m_ossiasBelow;
188  // Flag indicating if we need have ossias to process
189  bool m_hasOssia;
190 };
191 
192 //----------------------------------------------------------------------------
193 // ScoreDefOptimizeFunctor
194 //----------------------------------------------------------------------------
195 
201 public:
207  virtual ~ScoreDefOptimizeFunctor() = default;
209 
210  /*
211  * Abstract base implementation
212  */
213  bool ImplementsEndInterface() const override { return true; }
214 
215  /*
216  * Functor interface
217  */
219  FunctorCode VisitMeasure(Measure *measure) override;
220  FunctorCode VisitScore(Score *score) override;
221  FunctorCode VisitStaff(Staff *staff) override;
222  FunctorCode VisitStaffGrpEnd(StaffGrp *staffGrp) override;
223  FunctorCode VisitSystem(System *system) override;
224  FunctorCode VisitSystemEnd(System *system) override;
226 
227 protected:
228  //
229 private:
230  //
231 public:
232  //
233 private:
234  // The current scoreDef
235  ScoreDef *m_currentScoreDef;
236  // Flag indicating if we are optimizing encoded layout
237  bool m_encoded;
238  // Flag indicating if we consider the first scoreDef
239  bool m_firstScoreDef;
240  // Flag indicating if a Fermata element is present
241  bool m_hasFermata;
242  // Flag indicating if a Tempo element is present
243  bool m_hasTempo;
244 };
245 
246 //----------------------------------------------------------------------------
247 // SetCautionaryScoreDefFunctor
248 //----------------------------------------------------------------------------
249 
254 public:
259  SetCautionaryScoreDefFunctor(ScoreDef *currentScoreDef);
260  virtual ~SetCautionaryScoreDefFunctor() = default;
262 
263  /*
264  * Abstract base implementation
265  */
266  bool ImplementsEndInterface() const override { return false; }
267 
268  /*
269  * Functor interface
270  */
272  FunctorCode VisitLayer(Layer *layer) override;
273  FunctorCode VisitStaff(Staff *staff) override;
275 
276 protected:
277  //
278 private:
279  //
280 public:
281  //
282 private:
283  // The current scoreDef
284  ScoreDef *m_currentScoreDef;
285  // The current staffDef
286  StaffDef *m_currentStaffDef;
287 };
288 
289 //----------------------------------------------------------------------------
290 // ScoreDefSetGrpSymFunctor
291 //----------------------------------------------------------------------------
292 
297 public:
303  virtual ~ScoreDefSetGrpSymFunctor() = default;
305 
306  /*
307  * Abstract base implementation
308  */
309  bool ImplementsEndInterface() const override { return false; }
310 
311  /*
312  * Functor interface
313  */
315  FunctorCode VisitGrpSym(GrpSym *grpSym) override;
316  FunctorCode VisitSystem(System *system) override;
318 
319 protected:
320  //
321 private:
322  //
323 public:
324  //
325 private:
326  //
327 };
328 
329 //----------------------------------------------------------------------------
330 // ScoreDefSetOssiaFunctor
331 //----------------------------------------------------------------------------
332 
337 public:
343  virtual ~ScoreDefSetOssiaFunctor() = default;
345 
346  /*
347  * Abstract base implementation
348  */
349  bool ImplementsEndInterface() const override { return true; }
350 
351  /*
352  * Functor interface
353  */
355  FunctorCode VisitClef(Clef *clef) override;
356  FunctorCode VisitLayer(Layer *layer) override;
357  FunctorCode VisitMeasure(Measure *measure) override;
358  FunctorCode VisitMeasureEnd(Measure *measure) override;
359  FunctorCode VisitOssia(Ossia *ossia) override;
360  FunctorCode VisitStaff(Staff *staff) override;
361  FunctorCode VisitStaffEnd(Staff *staff) override;
362  FunctorCode VisitSystem(System *system) override;
364 
365 protected:
366  //
367 private:
371  const StaffDef *GetPreviousStaffDef(Ossia *ossia, int staffN);
372 
377  class CurrentOssia {
378  public:
379  Ossia *m_ossia = NULL;
380  std::map<int, StaffDef> m_staffDefs;
381  };
382 
383 public:
384  //
385 private:
386  // The current ossias (i.e., in the current measure)
387  std::list<CurrentOssia> m_currentOssias;
388  // The ossias in the previous measure
389  std::list<CurrentOssia> m_previousOssias;
390  // The upcoming staffDef
391  StaffDef m_upcomingStaffDef;
392  // The current scoreDef
393  ScoreDef *m_currentScoreDef;
394  // The current staffDef
395  StaffDef *m_currentStaffDef;
396  // A flag indicating the layer ossia staffDef will have to be drawn
397  bool m_layerOssiaStaffDef;
398  // Flag for first measure in the system
399  bool m_isFirstMeasure;
400 };
401 
402 //----------------------------------------------------------------------------
403 // ScoreDefUnsetCurrentFunctor
404 //----------------------------------------------------------------------------
405 
410 public:
416  virtual ~ScoreDefUnsetCurrentFunctor() = default;
418 
419  /*
420  * Abstract base implementation
421  */
422  bool ImplementsEndInterface() const override { return false; }
423 
424  /*
425  * Functor interface
426  */
428  FunctorCode VisitAlignmentReference(AlignmentReference *alignmentReference) override;
429  FunctorCode VisitKeySig(KeySig *keySig) override;
430  FunctorCode VisitLayer(Layer *layer) override;
431  FunctorCode VisitMeasure(Measure *measure) override;
432  FunctorCode VisitOssia(Ossia *ossia) override;
433  FunctorCode VisitPage(Page *page) override;
434  FunctorCode VisitStaff(Staff *staff) override;
435  FunctorCode VisitSystem(System *system) override;
437 
438 protected:
439  //
440 private:
441  //
442 public:
443  //
444 private:
445  //
446 };
447 
448 //----------------------------------------------------------------------------
449 // SetStaffDefRedrawFlagsFunctor
450 //----------------------------------------------------------------------------
451 
452 enum StaffDefRedrawFlags {
453  REDRAW_CLEF = 0x1,
454  REDRAW_KEYSIG = 0x2,
455  REDRAW_MENSUR = 0x4,
456  REDRAW_METERSIG = 0x8,
457  REDRAW_METERSIGGRP = 0x10,
458  // all flags
459  REDRAW_ALL = REDRAW_CLEF | REDRAW_KEYSIG | REDRAW_MENSUR | REDRAW_METERSIG | REDRAW_METERSIGGRP,
460  //
461  FORCE_REDRAW = 0x100
462 };
463 
469 public:
474  SetStaffDefRedrawFlagsFunctor(int redrawFlags);
475  virtual ~SetStaffDefRedrawFlagsFunctor() = default;
477 
478  /*
479  * Abstract base implementation
480  */
481  bool ImplementsEndInterface() const override { return false; }
482 
483  /*
484  * Functor interface
485  */
487  FunctorCode VisitStaffDef(StaffDef *staffDef) override;
489 
490 protected:
491  //
492 private:
493  //
494 public:
495  //
496 private:
497  // The staffDef redraw flags
498  int m_redrawFlags;
499 };
500 
501 } // namespace vrv
502 
503 #endif // __VRV_SETSCOREDEFFUNCTOR_H__
This class stores a references of LayerElements for a staff.
Definition: horizontalaligner.h:292
This class models the MEI <clef> element.
Definition: clef.h:41
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:51
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: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 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:136
This class optimizes the scoreDef for each system.
Definition: setscoredeffunctor.h:200
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:213
This class sets the current scoreDef wherever needed.
Definition: setscoredeffunctor.h:118
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:131
This class sets the Page::m_score and Page::m_scoreEnd pointers.
Definition: setscoredeffunctor.h:75
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:88
This class prepares the group symbol starting and ending staffDefs for drawing.
Definition: setscoredeffunctor.h:296
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:309
This class prepares the ossia staffDefs for drawing.
Definition: setscoredeffunctor.h:336
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:349
This class unsets the initial scoreDef for each system and measure.
Definition: setscoredeffunctor.h:409
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:422
This class represent a <score> in MEI.
Definition: score.h:30
This class sets the cautionary scoreDef wherever needed.
Definition: setscoredeffunctor.h:253
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:266
This class sets drawing flags for the StaffDef for indicating whether clefs, keysigs,...
Definition: setscoredeffunctor.h:468
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:481
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:110
This class represents a system in a laid-out score (Doc).
Definition: system.h:36