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 true; }
128 
129  /*
130  * Getter for ossia flag
131  */
132  bool HasOssia() const { return m_hasOssia; }
133 
134  /*
135  * Functor interface
136  */
138  FunctorCode VisitClef(Clef *clef) override;
139  FunctorCode VisitKeySig(KeySig *keySig) override;
140  FunctorCode VisitLayer(Layer *layer) override;
141  FunctorCode VisitMeasure(Measure *measure) override;
142  FunctorCode VisitMensur(Mensur *mensur) override;
143  FunctorCode VisitOssia(Ossia *ossia) override;
144  FunctorCode VisitPage(Page *page) override;
145  FunctorCode VisitProport(Proport *proport) override;
146  FunctorCode VisitScore(Score *score) override;
147  FunctorCode VisitScoreDef(ScoreDef *scoreDef) override;
148  FunctorCode VisitStaff(Staff *staff) override;
149  FunctorCode VisitStaffDef(StaffDef *staffDef) override;
150  FunctorCode VisitStaffGrp(StaffGrp *staffGrp) override;
151  FunctorCode VisitSystem(System *system) override;
152  FunctorCode VisitSystemEnd(System *system) override;
154 
155 protected:
156  //
157 private:
158  //
159 public:
160  //
161 private:
162  // The current score
163  Score *m_currentScore;
164  // The current scoreDef
165  ScoreDef *m_currentScoreDef;
166  // The current staffDef
167  StaffDef *m_currentStaffDef;
168  // The upcoming scoreDef
169  ScoreDef m_upcomingScoreDef;
170  // The previous measure (for setting cautionary scoreDef)
171  Measure *m_previousMeasure;
172  // The current system (for setting the system scoreDef)
173  System *m_currentSystem;
174  // Flag indicating whether full labels have to be drawn
175  bool m_drawLabels;
176  // Flag indicating that the scoreDef restarts (draw brace and label)
177  bool m_restart;
178  // Flag indicating if we already have a measure in the system
179  bool m_hasMeasure;
180  // Map of ossia above a given staffN
181  MapOfOssiaStaffNs m_ossiasAbove;
182  // Map of ossia below a given staffN
183  MapOfOssiaStaffNs m_ossiasBelow;
184  // Flag indicating if we need have ossias to process
185  bool m_hasOssia;
186 };
187 
188 //----------------------------------------------------------------------------
189 // ScoreDefOptimizeFunctor
190 //----------------------------------------------------------------------------
191 
197 public:
203  virtual ~ScoreDefOptimizeFunctor() = default;
205 
206  /*
207  * Abstract base implementation
208  */
209  bool ImplementsEndInterface() const override { return true; }
210 
211  /*
212  * Functor interface
213  */
215  FunctorCode VisitMeasure(Measure *measure) override;
216  FunctorCode VisitScore(Score *score) override;
217  FunctorCode VisitStaff(Staff *staff) override;
218  FunctorCode VisitStaffGrpEnd(StaffGrp *staffGrp) override;
219  FunctorCode VisitSystem(System *system) override;
220  FunctorCode VisitSystemEnd(System *system) override;
222 
223 protected:
224  //
225 private:
226  //
227 public:
228  //
229 private:
230  // The current scoreDef
231  ScoreDef *m_currentScoreDef;
232  // Flag indicating if we are optimizing encoded layout
233  bool m_encoded;
234  // Flag indicating if we consider the first scoreDef
235  bool m_firstScoreDef;
236  // Flag indicating if a Fermata element is present
237  bool m_hasFermata;
238  // Flag indicating if a Tempo element is present
239  bool m_hasTempo;
240 };
241 
242 //----------------------------------------------------------------------------
243 // SetCautionaryScoreDefFunctor
244 //----------------------------------------------------------------------------
245 
250 public:
255  SetCautionaryScoreDefFunctor(ScoreDef *currentScoreDef);
256  virtual ~SetCautionaryScoreDefFunctor() = default;
258 
259  /*
260  * Abstract base implementation
261  */
262  bool ImplementsEndInterface() const override { return false; }
263 
264  /*
265  * Functor interface
266  */
268  FunctorCode VisitLayer(Layer *layer) override;
269  FunctorCode VisitStaff(Staff *staff) override;
271 
272 protected:
273  //
274 private:
275  //
276 public:
277  //
278 private:
279  // The current scoreDef
280  ScoreDef *m_currentScoreDef;
281  // The current staffDef
282  StaffDef *m_currentStaffDef;
283 };
284 
285 //----------------------------------------------------------------------------
286 // ScoreDefSetGrpSymFunctor
287 //----------------------------------------------------------------------------
288 
293 public:
299  virtual ~ScoreDefSetGrpSymFunctor() = default;
301 
302  /*
303  * Abstract base implementation
304  */
305  bool ImplementsEndInterface() const override { return false; }
306 
307  /*
308  * Functor interface
309  */
311  FunctorCode VisitGrpSym(GrpSym *grpSym) override;
312  FunctorCode VisitSystem(System *system) override;
314 
315 protected:
316  //
317 private:
318  //
319 public:
320  //
321 private:
322  //
323 };
324 
325 //----------------------------------------------------------------------------
326 // ScoreDefSetOssiaFunctor
327 //----------------------------------------------------------------------------
328 
333 public:
339  virtual ~ScoreDefSetOssiaFunctor() = default;
341 
342  /*
343  * Abstract base implementation
344  */
345  bool ImplementsEndInterface() const override { return true; }
346 
347  /*
348  * Functor interface
349  */
351  FunctorCode VisitClef(Clef *clef) override;
352  FunctorCode VisitLayer(Layer *layer) override;
353  FunctorCode VisitMeasure(Measure *measure) override;
354  FunctorCode VisitMeasureEnd(Measure *measure) override;
355  FunctorCode VisitOssia(Ossia *ossia) override;
356  FunctorCode VisitStaff(Staff *staff) override;
357  FunctorCode VisitStaffEnd(Staff *staff) override;
358  FunctorCode VisitSystem(System *system) override;
360 
361 protected:
362  //
363 private:
367  const StaffDef *GetPreviousStaffDef(Ossia *ossia, int staffN);
368 
373  class CurrentOssia {
374  public:
375  Ossia *m_ossia = NULL;
376  std::map<int, StaffDef> m_staffDefs;
377  };
378 
379 public:
380  //
381 private:
382  // The current ossias (i.e., in the current measure)
383  std::list<CurrentOssia> m_currentOssias;
384  // The ossias in the previous measure
385  std::list<CurrentOssia> m_previousOssias;
386  // The upcoming staffDef
387  StaffDef m_upcomingStaffDef;
388  // The current scoreDef
389  ScoreDef *m_currentScoreDef;
390  // The current staffDef
391  StaffDef *m_currentStaffDef;
392  // A flag indicating the layer ossia staffDef will have to be drawn
393  bool m_layerOssiaStaffDef;
394  // Flag for first measure in the system
395  bool m_isFirstMeasure;
396 };
397 
398 //----------------------------------------------------------------------------
399 // ScoreDefUnsetCurrentFunctor
400 //----------------------------------------------------------------------------
401 
406 public:
412  virtual ~ScoreDefUnsetCurrentFunctor() = default;
414 
415  /*
416  * Abstract base implementation
417  */
418  bool ImplementsEndInterface() const override { return false; }
419 
420  /*
421  * Functor interface
422  */
424  FunctorCode VisitAlignmentReference(AlignmentReference *alignmentReference) override;
425  FunctorCode VisitKeySig(KeySig *keySig) override;
426  FunctorCode VisitLayer(Layer *layer) override;
427  FunctorCode VisitMeasure(Measure *measure) override;
428  FunctorCode VisitOssia(Ossia *ossia) override;
429  FunctorCode VisitPage(Page *page) override;
430  FunctorCode VisitStaff(Staff *staff) override;
431  FunctorCode VisitSystem(System *system) override;
433 
434 protected:
435  //
436 private:
437  //
438 public:
439  //
440 private:
441  //
442 };
443 
444 //----------------------------------------------------------------------------
445 // SetStaffDefRedrawFlagsFunctor
446 //----------------------------------------------------------------------------
447 
448 enum StaffDefRedrawFlags {
449  REDRAW_CLEF = 0x1,
450  REDRAW_KEYSIG = 0x2,
451  REDRAW_MENSUR = 0x4,
452  REDRAW_METERSIG = 0x8,
453  REDRAW_METERSIGGRP = 0x10,
454  // all flags
455  REDRAW_ALL = REDRAW_CLEF | REDRAW_KEYSIG | REDRAW_MENSUR | REDRAW_METERSIG | REDRAW_METERSIGGRP,
456  //
457  FORCE_REDRAW = 0x100
458 };
459 
465 public:
470  SetStaffDefRedrawFlagsFunctor(int redrawFlags);
471  virtual ~SetStaffDefRedrawFlagsFunctor() = default;
473 
474  /*
475  * Abstract base implementation
476  */
477  bool ImplementsEndInterface() const override { return false; }
478 
479  /*
480  * Functor interface
481  */
483  FunctorCode VisitStaffDef(StaffDef *staffDef) override;
485 
486 protected:
487  //
488 private:
489  //
490 public:
491  //
492 private:
493  // The staffDef redraw flags
494  int m_redrawFlags;
495 };
496 
497 } // namespace vrv
498 
499 #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: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: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:135
This class optimizes the scoreDef for each system.
Definition: setscoredeffunctor.h:196
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:209
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:292
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:305
This class prepares the ossia staffDefs for drawing.
Definition: setscoredeffunctor.h:332
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:345
This class unsets the initial scoreDef for each system and measure.
Definition: setscoredeffunctor.h:405
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:418
This class represent a <score> in MEI.
Definition: score.h:30
This class sets the cautionary scoreDef wherever needed.
Definition: setscoredeffunctor.h:249
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:262
This class sets drawing flags for the StaffDef for indicating whether clefs, keysigs,...
Definition: setscoredeffunctor.h:464
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:477
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