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 VisitScoreOrPartElement(ScoreOrPartElement *scoreOrPart) override;
93 
94 protected:
95  //
96 private:
97  //
98 public:
99  //
100 private:
101  // The list of all scores
102  std::list<ScoreOrPartElement *> 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 VisitScoreOrPartElement(ScoreOrPartElement *scoreOrPart) override;
147  FunctorCode VisitScoreDef(ScoreDef *scoreDef) override;
148  FunctorCode VisitScoreDefEnd(ScoreDef *scoreDef) override;
149  FunctorCode VisitStaff(Staff *staff) override;
150  FunctorCode VisitStaffDef(StaffDef *staffDef) override;
151  FunctorCode VisitStaffGrp(StaffGrp *staffGrp) override;
152  FunctorCode VisitSystem(System *system) override;
153  FunctorCode VisitSystemEnd(System *system) override;
155 
156 protected:
157  //
158 private:
159  //
160 public:
161  //
162 private:
163  // The current score
164  ScoreOrPartElement *m_currentScore;
165  // The current scoreDef
166  ScoreDef *m_currentScoreDef;
167  // The current staffDef
168  StaffDef *m_currentStaffDef;
169  // The upcoming scoreDef
170  ScoreDef m_upcomingScoreDef;
171  // The previous measure (for setting cautionary scoreDef)
172  Measure *m_previousMeasure;
173  // The current system (for setting the system scoreDef)
174  System *m_currentSystem;
175  // Flag indicating whether full labels have to be drawn
176  bool m_drawLabels;
177  // Flag indicating that the scoreDef restarts (draw brace and label)
178  bool m_restart;
179  // Flag indicating if we already have a measure in the system
180  bool m_hasMeasure;
181  // Map of ossia above a given staffN
182  MapOfOssiaStaffNs m_ossiasAbove;
183  // Map of ossia below a given staffN
184  MapOfOssiaStaffNs m_ossiasBelow;
185  // Flag indicating if we need have ossias to process
186  bool m_hasOssia;
187 };
188 
189 //----------------------------------------------------------------------------
190 // ScoreDefOptimizeFunctor
191 //----------------------------------------------------------------------------
192 
198 public:
204  virtual ~ScoreDefOptimizeFunctor() = default;
206 
207  /*
208  * Abstract base implementation
209  */
210  bool ImplementsEndInterface() const override { return true; }
211 
212  /*
213  * Functor interface
214  */
216  FunctorCode VisitMeasure(Measure *measure) override;
217  FunctorCode VisitScoreOrPartElement(ScoreOrPartElement *scoreOrPart) override;
218  FunctorCode VisitStaff(Staff *staff) override;
219  FunctorCode VisitStaffGrpEnd(StaffGrp *staffGrp) override;
220  FunctorCode VisitSystem(System *system) override;
221  FunctorCode VisitSystemEnd(System *system) override;
223 
224 protected:
225  //
226 private:
227  //
228 public:
229  //
230 private:
231  // The current scoreDef
232  ScoreDef *m_currentScoreDef;
233  // Flag indicating if we are optimizing encoded layout
234  bool m_encoded;
235  // Flag indicating if we consider the first scoreDef
236  bool m_firstScoreDef;
237  // Flag indicating if a Fermata element is present
238  bool m_hasFermata;
239  // Flag indicating if a Tempo element is present
240  bool m_hasTempo;
241 };
242 
243 //----------------------------------------------------------------------------
244 // SetCautionaryScoreDefFunctor
245 //----------------------------------------------------------------------------
246 
251 public:
256  SetCautionaryScoreDefFunctor(ScoreDef *currentScoreDef, bool restart = false);
257  virtual ~SetCautionaryScoreDefFunctor() = default;
259 
264  void SetRestartStaffNs(const std::vector<int> &staffNs) { m_staffNs = staffNs; }
265 
266  /*
267  * Abstract base implementation
268  */
269  bool ImplementsEndInterface() const override { return false; }
270 
271  /*
272  * Functor interface
273  */
275  FunctorCode VisitLayer(Layer *layer) override;
276  FunctorCode VisitStaff(Staff *staff) override;
278 
279 protected:
280  //
281 private:
282  //
283 public:
284  //
285 private:
286  // The current scoreDef
287  ScoreDef *m_currentScoreDef;
288  // The current staffDef
289  StaffDef *m_currentStaffDef;
290  // Flag indicating we are processing a restart
291  bool m_restart;
292  // The list of staff n after the restart
293  std::vector<int> m_staffNs;
294 };
295 
296 //----------------------------------------------------------------------------
297 // ScoreDefSetGrpSymFunctor
298 //----------------------------------------------------------------------------
299 
304 public:
310  virtual ~ScoreDefSetGrpSymFunctor() = default;
312 
313  /*
314  * Abstract base implementation
315  */
316  bool ImplementsEndInterface() const override { return false; }
317 
318  /*
319  * Functor interface
320  */
322  FunctorCode VisitGrpSym(GrpSym *grpSym) override;
323  FunctorCode VisitSystem(System *system) override;
325 
326 protected:
327  //
328 private:
329  //
330 public:
331  //
332 private:
333  //
334 };
335 
336 //----------------------------------------------------------------------------
337 // ScoreDefSetOssiaFunctor
338 //----------------------------------------------------------------------------
339 
344 public:
350  virtual ~ScoreDefSetOssiaFunctor() = default;
352 
353  /*
354  * Abstract base implementation
355  */
356  bool ImplementsEndInterface() const override { return true; }
357 
358  /*
359  * Functor interface
360  */
362  FunctorCode VisitClef(Clef *clef) override;
363  FunctorCode VisitLayer(Layer *layer) override;
364  FunctorCode VisitMeasure(Measure *measure) override;
365  FunctorCode VisitMeasureEnd(Measure *measure) override;
366  FunctorCode VisitOssia(Ossia *ossia) override;
367  FunctorCode VisitStaff(Staff *staff) override;
368  FunctorCode VisitStaffEnd(Staff *staff) override;
369  FunctorCode VisitSystem(System *system) override;
371 
372 protected:
373  //
374 private:
378  const StaffDef *GetPreviousStaffDef(Ossia *ossia, int staffN);
379 
384  class CurrentOssia {
385  public:
386  Ossia *m_ossia = NULL;
387  std::map<int, StaffDef> m_staffDefs;
388  };
389 
390 public:
391  //
392 private:
393  // The current ossias (i.e., in the current measure)
394  std::list<CurrentOssia> m_currentOssias;
395  // The ossias in the previous measure
396  std::list<CurrentOssia> m_previousOssias;
397  // The upcoming staffDef
398  StaffDef m_upcomingStaffDef;
399  // The current scoreDef
400  ScoreDef *m_currentScoreDef;
401  // The current staffDef
402  StaffDef *m_currentStaffDef;
403  // A flag indicating the layer ossia staffDef will have to be drawn
404  bool m_layerOssiaStaffDef;
405  // Flag for first measure in the system
406  bool m_isFirstMeasure;
407 };
408 
409 //----------------------------------------------------------------------------
410 // ScoreDefUnsetCurrentFunctor
411 //----------------------------------------------------------------------------
412 
417 public:
423  virtual ~ScoreDefUnsetCurrentFunctor() = default;
425 
426  /*
427  * Abstract base implementation
428  */
429  bool ImplementsEndInterface() const override { return false; }
430 
431  /*
432  * Functor interface
433  */
435  FunctorCode VisitAlignmentReference(AlignmentReference *alignmentReference) override;
436  FunctorCode VisitKeySig(KeySig *keySig) override;
437  FunctorCode VisitLayer(Layer *layer) override;
438  FunctorCode VisitMeasure(Measure *measure) override;
439  FunctorCode VisitOssia(Ossia *ossia) override;
440  FunctorCode VisitPage(Page *page) override;
441  FunctorCode VisitStaff(Staff *staff) override;
442  FunctorCode VisitSystem(System *system) override;
444 
445 protected:
446  //
447 private:
448  //
449 public:
450  //
451 private:
452  //
453 };
454 
455 //----------------------------------------------------------------------------
456 // SetStaffDefRedrawFlagsFunctor
457 //----------------------------------------------------------------------------
458 
459 enum StaffDefRedrawFlags {
460  REDRAW_CLEF = 0x1,
461  REDRAW_KEYSIG = 0x2,
462  REDRAW_MENSUR = 0x4,
463  REDRAW_METERSIG = 0x8,
464  REDRAW_METERSIGGRP = 0x10,
465  // all flags
466  REDRAW_ALL = REDRAW_CLEF | REDRAW_KEYSIG | REDRAW_MENSUR | REDRAW_METERSIG | REDRAW_METERSIGGRP,
467  //
468  FORCE_REDRAW = 0x100
469 };
470 
476 public:
481  SetStaffDefRedrawFlagsFunctor(int redrawFlags);
482  virtual ~SetStaffDefRedrawFlagsFunctor() = default;
484 
485  /*
486  * Abstract base implementation
487  */
488  bool ImplementsEndInterface() const override { return false; }
489 
490  /*
491  * Functor interface
492  */
494  FunctorCode VisitStaffDef(StaffDef *staffDef) override;
496 
497 protected:
498  //
499 private:
500  //
501 public:
502  //
503 private:
504  // The staffDef redraw flags
505  int m_redrawFlags;
506 };
507 
508 } // namespace vrv
509 
510 #endif // __VRV_SETSCOREDEFFUNCTOR_H__
This class stores a references of LayerElements for a staff.
Definition: horizontalaligner.h:298
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:40
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:197
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:210
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:303
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:316
This class prepares the ossia staffDefs for drawing.
Definition: setscoredeffunctor.h:343
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:356
This class unsets the initial scoreDef for each system and measure.
Definition: setscoredeffunctor.h:416
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:429
This class represents a <score> or a <part> in MEI.
Definition: scoreorpartelement.h:33
This class sets the cautionary scoreDef wherever needed.
Definition: setscoredeffunctor.h:250
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:269
void SetRestartStaffNs(const std::vector< int > &staffNs)
Set the list of staffNs in the scoreDef after the restart.
Definition: setscoredeffunctor.h:264
This class sets drawing flags for the StaffDef for indicating whether clefs, keysigs,...
Definition: setscoredeffunctor.h:475
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:488
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