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, bool restart = false);
260  virtual ~SetCautionaryScoreDefFunctor() = default;
262 
267  void SetRestartStaffNs(const std::vector<int> &staffNs) { m_staffNs = staffNs; }
268 
269  /*
270  * Abstract base implementation
271  */
272  bool ImplementsEndInterface() const override { return false; }
273 
274  /*
275  * Functor interface
276  */
278  FunctorCode VisitLayer(Layer *layer) override;
279  FunctorCode VisitStaff(Staff *staff) override;
281 
282 protected:
283  //
284 private:
285  //
286 public:
287  //
288 private:
289  // The current scoreDef
290  ScoreDef *m_currentScoreDef;
291  // The current staffDef
292  StaffDef *m_currentStaffDef;
293  // Flag indicating we are processing a restart
294  bool m_restart;
295  // The list of staff n after the restart
296  std::vector<int> m_staffNs;
297 };
298 
299 //----------------------------------------------------------------------------
300 // ScoreDefSetGrpSymFunctor
301 //----------------------------------------------------------------------------
302 
307 public:
313  virtual ~ScoreDefSetGrpSymFunctor() = default;
315 
316  /*
317  * Abstract base implementation
318  */
319  bool ImplementsEndInterface() const override { return false; }
320 
321  /*
322  * Functor interface
323  */
325  FunctorCode VisitGrpSym(GrpSym *grpSym) override;
326  FunctorCode VisitSystem(System *system) override;
328 
329 protected:
330  //
331 private:
332  //
333 public:
334  //
335 private:
336  //
337 };
338 
339 //----------------------------------------------------------------------------
340 // ScoreDefSetOssiaFunctor
341 //----------------------------------------------------------------------------
342 
347 public:
353  virtual ~ScoreDefSetOssiaFunctor() = default;
355 
356  /*
357  * Abstract base implementation
358  */
359  bool ImplementsEndInterface() const override { return true; }
360 
361  /*
362  * Functor interface
363  */
365  FunctorCode VisitClef(Clef *clef) override;
366  FunctorCode VisitLayer(Layer *layer) override;
367  FunctorCode VisitMeasure(Measure *measure) override;
368  FunctorCode VisitMeasureEnd(Measure *measure) override;
369  FunctorCode VisitOssia(Ossia *ossia) override;
370  FunctorCode VisitStaff(Staff *staff) override;
371  FunctorCode VisitStaffEnd(Staff *staff) override;
372  FunctorCode VisitSystem(System *system) override;
374 
375 protected:
376  //
377 private:
381  const StaffDef *GetPreviousStaffDef(Ossia *ossia, int staffN);
382 
387  class CurrentOssia {
388  public:
389  Ossia *m_ossia = NULL;
390  std::map<int, StaffDef> m_staffDefs;
391  };
392 
393 public:
394  //
395 private:
396  // The current ossias (i.e., in the current measure)
397  std::list<CurrentOssia> m_currentOssias;
398  // The ossias in the previous measure
399  std::list<CurrentOssia> m_previousOssias;
400  // The upcoming staffDef
401  StaffDef m_upcomingStaffDef;
402  // The current scoreDef
403  ScoreDef *m_currentScoreDef;
404  // The current staffDef
405  StaffDef *m_currentStaffDef;
406  // A flag indicating the layer ossia staffDef will have to be drawn
407  bool m_layerOssiaStaffDef;
408  // Flag for first measure in the system
409  bool m_isFirstMeasure;
410 };
411 
412 //----------------------------------------------------------------------------
413 // ScoreDefUnsetCurrentFunctor
414 //----------------------------------------------------------------------------
415 
420 public:
426  virtual ~ScoreDefUnsetCurrentFunctor() = default;
428 
429  /*
430  * Abstract base implementation
431  */
432  bool ImplementsEndInterface() const override { return false; }
433 
434  /*
435  * Functor interface
436  */
438  FunctorCode VisitAlignmentReference(AlignmentReference *alignmentReference) override;
439  FunctorCode VisitKeySig(KeySig *keySig) override;
440  FunctorCode VisitLayer(Layer *layer) override;
441  FunctorCode VisitMeasure(Measure *measure) override;
442  FunctorCode VisitOssia(Ossia *ossia) override;
443  FunctorCode VisitPage(Page *page) override;
444  FunctorCode VisitStaff(Staff *staff) override;
445  FunctorCode VisitSystem(System *system) override;
447 
448 protected:
449  //
450 private:
451  //
452 public:
453  //
454 private:
455  //
456 };
457 
458 //----------------------------------------------------------------------------
459 // SetStaffDefRedrawFlagsFunctor
460 //----------------------------------------------------------------------------
461 
462 enum StaffDefRedrawFlags {
463  REDRAW_CLEF = 0x1,
464  REDRAW_KEYSIG = 0x2,
465  REDRAW_MENSUR = 0x4,
466  REDRAW_METERSIG = 0x8,
467  REDRAW_METERSIGGRP = 0x10,
468  // all flags
469  REDRAW_ALL = REDRAW_CLEF | REDRAW_KEYSIG | REDRAW_MENSUR | REDRAW_METERSIG | REDRAW_METERSIGGRP,
470  //
471  FORCE_REDRAW = 0x100
472 };
473 
479 public:
484  SetStaffDefRedrawFlagsFunctor(int redrawFlags);
485  virtual ~SetStaffDefRedrawFlagsFunctor() = default;
487 
488  /*
489  * Abstract base implementation
490  */
491  bool ImplementsEndInterface() const override { return false; }
492 
493  /*
494  * Functor interface
495  */
497  FunctorCode VisitStaffDef(StaffDef *staffDef) override;
499 
500 protected:
501  //
502 private:
503  //
504 public:
505  //
506 private:
507  // The staffDef redraw flags
508  int m_redrawFlags;
509 };
510 
511 } // namespace vrv
512 
513 #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:306
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:319
This class prepares the ossia staffDefs for drawing.
Definition: setscoredeffunctor.h:346
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:359
This class unsets the initial scoreDef for each system and measure.
Definition: setscoredeffunctor.h:419
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:432
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:272
void SetRestartStaffNs(const std::vector< int > &staffNs)
Set the list of staffNs in the scoreDef after the restart.
Definition: setscoredeffunctor.h:267
This class sets drawing flags for the StaffDef for indicating whether clefs, keysigs,...
Definition: setscoredeffunctor.h:478
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:491
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