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);
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 the text styles of each new staffDef
63  const ScoreDef *m_newScoreDef;
64 };
65 
66 //----------------------------------------------------------------------------
67 // ScoreDefSetCurrentPageFunctor
68 //----------------------------------------------------------------------------
69 
74 public:
80  virtual ~ScoreDefSetCurrentPageFunctor() = default;
82 
83  /*
84  * Abstract base implementation
85  */
86  bool ImplementsEndInterface() const override { return true; }
87 
88  /*
89  * Functor interface
90  */
92  FunctorCode VisitPageEnd(Page *page) override;
93  FunctorCode VisitScoreOrPartElement(ScoreOrPartElement *scoreOrPart) override;
95 
96 protected:
97  //
98 private:
99  //
100 public:
101  //
102 private:
103  // The list of all scores
104  std::list<ScoreOrPartElement *> m_scores;
105 };
106 
107 //----------------------------------------------------------------------------
108 // ScoreDefSetCurrentFunctor
109 //----------------------------------------------------------------------------
110 
117 public:
123  virtual ~ScoreDefSetCurrentFunctor() = default;
125 
126  /*
127  * Abstract base implementation
128  */
129  bool ImplementsEndInterface() const override { return true; }
130 
131  /*
132  * Getter for ossia flag
133  */
134  bool HasOssia() const { return m_hasOssia; }
135 
136  /*
137  * Functor interface
138  */
140  FunctorCode VisitClef(Clef *clef) override;
141  FunctorCode VisitKeySig(KeySig *keySig) override;
142  FunctorCode VisitLayer(Layer *layer) override;
143  FunctorCode VisitMeasure(Measure *measure) override;
144  FunctorCode VisitMensur(Mensur *mensur) override;
145  FunctorCode VisitOssia(Ossia *ossia) override;
146  FunctorCode VisitPage(Page *page) override;
147  FunctorCode VisitProport(Proport *proport) override;
148  FunctorCode VisitScoreOrPartElement(ScoreOrPartElement *scoreOrPart) override;
149  FunctorCode VisitScoreDef(ScoreDef *scoreDef) override;
150  FunctorCode VisitScoreDefEnd(ScoreDef *scoreDef) override;
151  FunctorCode VisitStaff(Staff *staff) override;
152  FunctorCode VisitStaffDef(StaffDef *staffDef) override;
153  FunctorCode VisitStaffGrp(StaffGrp *staffGrp) override;
154  FunctorCode VisitSystem(System *system) override;
155  FunctorCode VisitSystemEnd(System *system) override;
157 
158 protected:
159  //
160 private:
161  //
162 public:
163  //
164 private:
165  // The current score
166  ScoreOrPartElement *m_currentScore;
167  // The current scoreDef
168  ScoreDef *m_currentScoreDef;
169  // The current staffDef
170  StaffDef *m_currentStaffDef;
171  // The upcoming scoreDef
172  ScoreDef m_upcomingScoreDef;
173  // The previous measure (for setting cautionary scoreDef)
174  Measure *m_previousMeasure;
175  // The current system (for setting the system scoreDef)
176  System *m_currentSystem;
177  // Flag indicating whether full labels have to be drawn
178  bool m_drawLabels;
179  // Flag indicating that the scoreDef restarts (draw brace and label)
180  bool m_restart;
181  // Flag indicating if we already have a measure in the system
182  bool m_hasMeasure;
183  // Map of ossia above a given staffN
184  MapOfOssiaStaffNs m_ossiasAbove;
185  // Map of ossia below a given staffN
186  MapOfOssiaStaffNs m_ossiasBelow;
187  // Flag indicating if we need have ossias to process
188  bool m_hasOssia;
189 };
190 
191 //----------------------------------------------------------------------------
192 // ScoreDefOptimizeFunctor
193 //----------------------------------------------------------------------------
194 
200 public:
206  virtual ~ScoreDefOptimizeFunctor() = default;
208 
209  /*
210  * Abstract base implementation
211  */
212  bool ImplementsEndInterface() const override { return true; }
213 
214  /*
215  * Functor interface
216  */
218  FunctorCode VisitMeasure(Measure *measure) override;
219  FunctorCode VisitScoreOrPartElement(ScoreOrPartElement *scoreOrPart) override;
220  FunctorCode VisitStaff(Staff *staff) override;
221  FunctorCode VisitStaffGrpEnd(StaffGrp *staffGrp) override;
222  FunctorCode VisitSystem(System *system) override;
223  FunctorCode VisitSystemEnd(System *system) override;
225 
226 protected:
227  //
228 private:
229  //
230 public:
231  //
232 private:
233  // The current scoreDef
234  ScoreDef *m_currentScoreDef;
235  // Flag indicating if we are optimizing encoded layout
236  bool m_encoded;
237  // Flag indicating if we consider the first scoreDef
238  bool m_firstScoreDef;
239  // Flag indicating if a Fermata element is present
240  bool m_hasFermata;
241  // Flag indicating if a Tempo element is present
242  bool m_hasTempo;
243 };
244 
245 //----------------------------------------------------------------------------
246 // SetCautionaryScoreDefFunctor
247 //----------------------------------------------------------------------------
248 
253 public:
258  SetCautionaryScoreDefFunctor(ScoreDef *currentScoreDef, bool restart = false);
259  virtual ~SetCautionaryScoreDefFunctor() = default;
261 
266  void SetRestartStaffNs(const std::vector<int> &staffNs) { m_staffNs = staffNs; }
267 
268  /*
269  * Abstract base implementation
270  */
271  bool ImplementsEndInterface() const override { return false; }
272 
273  /*
274  * Functor interface
275  */
277  FunctorCode VisitLayer(Layer *layer) override;
278  FunctorCode VisitStaff(Staff *staff) override;
280 
281 protected:
282  //
283 private:
284  //
285 public:
286  //
287 private:
288  // The current scoreDef
289  ScoreDef *m_currentScoreDef;
290  // The current staffDef
291  StaffDef *m_currentStaffDef;
292  // Flag indicating we are processing a restart
293  bool m_restart;
294  // The list of staff n after the restart
295  std::vector<int> m_staffNs;
296 };
297 
298 //----------------------------------------------------------------------------
299 // ScoreDefSetGrpSymFunctor
300 //----------------------------------------------------------------------------
301 
306 public:
312  virtual ~ScoreDefSetGrpSymFunctor() = default;
314 
315  /*
316  * Abstract base implementation
317  */
318  bool ImplementsEndInterface() const override { return false; }
319 
320  /*
321  * Functor interface
322  */
324  FunctorCode VisitGrpSym(GrpSym *grpSym) override;
325  FunctorCode VisitSystem(System *system) override;
327 
328 protected:
329  //
330 private:
331  //
332 public:
333  //
334 private:
335  //
336 };
337 
338 //----------------------------------------------------------------------------
339 // ScoreDefSetOssiaFunctor
340 //----------------------------------------------------------------------------
341 
346 public:
352  virtual ~ScoreDefSetOssiaFunctor() = default;
354 
355  /*
356  * Abstract base implementation
357  */
358  bool ImplementsEndInterface() const override { return true; }
359 
360  /*
361  * Functor interface
362  */
364  FunctorCode VisitClef(Clef *clef) override;
365  FunctorCode VisitLayer(Layer *layer) override;
366  FunctorCode VisitMeasure(Measure *measure) override;
367  FunctorCode VisitMeasureEnd(Measure *measure) override;
368  FunctorCode VisitOssia(Ossia *ossia) override;
369  FunctorCode VisitStaff(Staff *staff) override;
370  FunctorCode VisitStaffEnd(Staff *staff) override;
371  FunctorCode VisitSystem(System *system) override;
373 
374 protected:
375  //
376 private:
380  const StaffDef *GetPreviousStaffDef(Ossia *ossia, int staffN);
381 
386  class CurrentOssia {
387  public:
388  Ossia *m_ossia = NULL;
389  std::map<int, StaffDef> m_staffDefs;
390  };
391 
392 public:
393  //
394 private:
395  // The current ossias (i.e., in the current measure)
396  std::list<CurrentOssia> m_currentOssias;
397  // The ossias in the previous measure
398  std::list<CurrentOssia> m_previousOssias;
399  // The upcoming staffDef
400  StaffDef m_upcomingStaffDef;
401  // The current scoreDef
402  ScoreDef *m_currentScoreDef;
403  // The current staffDef
404  StaffDef *m_currentStaffDef;
405  // A flag indicating the layer ossia staffDef will have to be drawn
406  bool m_layerOssiaStaffDef;
407  // Flag for first measure in the system
408  bool m_isFirstMeasure;
409 };
410 
411 //----------------------------------------------------------------------------
412 // ScoreDefUnsetCurrentFunctor
413 //----------------------------------------------------------------------------
414 
419 public:
425  virtual ~ScoreDefUnsetCurrentFunctor() = default;
427 
428  /*
429  * Abstract base implementation
430  */
431  bool ImplementsEndInterface() const override { return false; }
432 
433  /*
434  * Functor interface
435  */
437  FunctorCode VisitAlignmentReference(AlignmentReference *alignmentReference) override;
438  FunctorCode VisitKeySig(KeySig *keySig) override;
439  FunctorCode VisitLayer(Layer *layer) override;
440  FunctorCode VisitMeasure(Measure *measure) override;
441  FunctorCode VisitOssia(Ossia *ossia) override;
442  FunctorCode VisitPage(Page *page) override;
443  FunctorCode VisitStaff(Staff *staff) override;
444  FunctorCode VisitSystem(System *system) override;
446 
447 protected:
448  //
449 private:
450  //
451 public:
452  //
453 private:
454  //
455 };
456 
457 //----------------------------------------------------------------------------
458 // SetStaffDefRedrawFlagsFunctor
459 //----------------------------------------------------------------------------
460 
461 enum StaffDefRedrawFlags {
462  REDRAW_CLEF = 0x1,
463  REDRAW_KEYSIG = 0x2,
464  REDRAW_MENSUR = 0x4,
465  REDRAW_METERSIG = 0x8,
466  REDRAW_METERSIGGRP = 0x10,
467  // all flags
468  REDRAW_ALL = REDRAW_CLEF | REDRAW_KEYSIG | REDRAW_MENSUR | REDRAW_METERSIG | REDRAW_METERSIGGRP,
469  //
470  FORCE_REDRAW = 0x100
471 };
472 
478 public:
483  SetStaffDefRedrawFlagsFunctor(int redrawFlags);
484  virtual ~SetStaffDefRedrawFlagsFunctor() = default;
486 
487  /*
488  * Abstract base implementation
489  */
490  bool ImplementsEndInterface() const override { return false; }
491 
492  /*
493  * Functor interface
494  */
496  FunctorCode VisitStaffDef(StaffDef *staffDef) override;
498 
499 protected:
500  //
501 private:
502  //
503 public:
504  //
505 private:
506  // The staffDef redraw flags
507  int m_redrawFlags;
508 };
509 
510 } // namespace vrv
511 
512 #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:199
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:212
This class sets the current scoreDef wherever needed.
Definition: setscoredeffunctor.h:116
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:129
This class sets the Page::m_score and Page::m_scoreEnd pointers.
Definition: setscoredeffunctor.h:73
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:86
This class prepares the group symbol starting and ending staffDefs for drawing.
Definition: setscoredeffunctor.h:305
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:318
This class prepares the ossia staffDefs for drawing.
Definition: setscoredeffunctor.h:345
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:358
This class unsets the initial scoreDef for each system and measure.
Definition: setscoredeffunctor.h:418
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:431
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:252
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:271
void SetRestartStaffNs(const std::vector< int > &staffNs)
Set the list of staffNs in the scoreDef after the restart.
Definition: setscoredeffunctor.h:266
This class sets drawing flags for the StaffDef for indicating whether clefs, keysigs,...
Definition: setscoredeffunctor.h:477
bool ImplementsEndInterface() const override
Return true if the functor implements the end interface.
Definition: setscoredeffunctor.h:490
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