Verovio
Source code documentation
scoredef.h
1 // Name: scoredef.h
3 // Author: Laurent Pugin
4 // Created: 2013/11/08
5 // Copyright (c) Authors and others. All rights reserved.
7 
8 #ifndef __VRV_SCOREDEF_H__
9 #define __VRV_SCOREDEF_H__
10 
11 #include "atts_gestural.h"
12 #include "atts_mei.h"
13 #include "atts_shared.h"
14 #include "customtuning.h"
15 #include "drawinginterface.h"
16 #include "object.h"
17 #include "scoredefinterface.h"
18 
19 namespace vrv {
20 
21 class Clef;
22 class KeySig;
23 class Mensur;
24 class MeterSig;
25 class MeterSigGrp;
26 class PgFoot;
27 class PgHead;
28 class StaffGrp;
29 class StaffDef;
30 
31 //----------------------------------------------------------------------------
32 // ScoreDefElement
33 //----------------------------------------------------------------------------
34 
43 class ScoreDefElement : public Object, public ScoreDefInterface, public AttTyped {
44 public:
50  ScoreDefElement(ClassId classId);
51  virtual ~ScoreDefElement();
52  void Reset() override;
54 
59  ScoreDefInterface *GetScoreDefInterface() override { return vrv_cast<ScoreDefInterface *>(this); }
60  const ScoreDefInterface *GetScoreDefInterface() const override { return vrv_cast<const ScoreDefInterface *>(this); }
62 
67  bool HasClefInfo(int depth = 1) const;
68  bool HasKeySigInfo(int depth = 1) const;
69  bool HasMensurInfo(int depth = 1) const;
70  bool HasMeterSigInfo(int depth = 1) const;
71  bool HasMeterSigGrpInfo(int depth = 1) const;
73 
83  Clef *GetClef();
84  const Clef *GetClef() const;
85  Clef *GetClefCopy() const;
86  KeySig *GetKeySig();
87  const KeySig *GetKeySig() const;
88  KeySig *GetKeySigCopy() const;
89  Mensur *GetMensur();
90  const Mensur *GetMensur() const;
91  Mensur *GetMensurCopy() const;
92  MeterSig *GetMeterSig();
93  const MeterSig *GetMeterSig() const;
94  MeterSig *GetMeterSigCopy() const;
95  MeterSigGrp *GetMeterSigGrp();
96  const MeterSigGrp *GetMeterSigGrp() const;
97  MeterSigGrp *GetMeterSigGrpCopy() const;
99 
100  //----------//
101  // Functors //
102  //----------//
103 
108  FunctorCode Accept(Functor &functor) override;
109  FunctorCode Accept(ConstFunctor &functor) const override;
110  FunctorCode AcceptEnd(Functor &functor) override;
111  FunctorCode AcceptEnd(ConstFunctor &functor) const override;
113 
114 private:
115  //
116 public:
117  //
118 private:
119  //
120 };
121 
122 //----------------------------------------------------------------------------
123 // ScoreDef
124 //----------------------------------------------------------------------------
125 
130 class ScoreDef : public ScoreDefElement,
131  public ObjectListInterface,
132  public AttDistances,
133  public AttEndings,
134  public AttOptimization,
135  public AttTimeBase,
136  public AttTuning {
137 public:
143  ScoreDef();
144  virtual ~ScoreDef();
145  Object *Clone() const override { return new ScoreDef(*this); }
146  void Reset() override;
147  std::string GetClassName() const override { return "scoreDef"; }
149 
153  void CloneReset() override;
154 
158  bool IsSupportedChild(ClassId classId) override;
159 
163  bool AddChildAdditionalCheck(Object *child) override;
164 
168  int GetInsertOrderFor(ClassId classId) const override;
169 
173  void ReplaceDrawingValues(const ScoreDef *newScoreDef);
174 
180  void ReplaceDrawingValues(const StaffDef *newStaffDef);
181 
186  void ReplaceDrawingLabels(const StaffGrp *newStaffGrp);
187 
193 
199  const StaffDef *GetStaffDef(int n) const;
201 
206  StaffGrp *GetStaffGrp(const std::string &n);
207  const StaffGrp *GetStaffGrp(const std::string &n) const;
209 
213  std::vector<int> GetStaffNs() const;
214 
219  void SetRedrawFlags(int redrawFlags);
220 
225  bool DrawLabels() const { return m_drawLabels; }
226  void SetDrawLabels(bool drawLabels) { m_drawLabels = drawLabels; }
228 
233  int GetDrawingWidth() const { return m_drawingWidth; }
234  void SetDrawingWidth(int drawingWidth);
236 
241  int GetDrawingLabelsWidth() const { return m_drawingLabelsWidth; }
242  void SetDrawingLabelsWidth(int width);
243  void ResetDrawingLabelsWidth() { m_drawingLabelsWidth = 0; }
245 
250  PgFoot *GetPgFoot(data_PGFUNC func);
251  const PgFoot *GetPgFoot(data_PGFUNC func) const;
252  PgHead *GetPgHead(data_PGFUNC func);
253  const PgHead *GetPgHead(data_PGFUNC func) const;
255 
260  // CustomTuning &GetCustomTuning() { return m_customTuning; }
261  void ResetCustomTuning();
262  CustomTuning *GetCustomTuning() const { return m_customTuning; }
263  bool HasCustomTuning() const { return (m_customTuning != NULL); }
264  void SetCustomTuning(CustomTuning *customTuning);
266 
270  int GetMaxStaffSize() const;
271 
272  bool IsSectionRestart() const;
273 
277  bool HasSystemStartLine() const;
278 
282  void AddOssias(int staffN, const std::list<int>, bool above);
283 
289  void UpdateMeterSig(LayerElement *meterSigOrGrp);
290 
296  void UpdateKeySig(KeySig *keySig);
297 
298  //----------//
299  // Functors //
300  //----------//
301 
306  FunctorCode Accept(Functor &functor) override;
307  FunctorCode Accept(ConstFunctor &functor) const override;
308  FunctorCode AcceptEnd(Functor &functor) override;
309  FunctorCode AcceptEnd(ConstFunctor &functor) const override;
311 
312 protected:
316  void FilterList(ListOfConstObjects &childList) const override;
317 
318 private:
319  //
320 public:
321  bool m_setAsDrawing;
322  bool m_insertScoreDef;
323 
324 private:
326  bool m_drawLabels;
328  int m_drawingWidth;
330  int m_drawingLabelsWidth;
332  CustomTuning *m_customTuning;
333 };
334 
335 } // namespace vrv
336 
337 #endif
This abstract class is the base class for all const functors.
Definition: functor.h:126
Definition: customtuning.h:28
This abstract class is the base class for all mutable functors.
Definition: functor.h:101
This class models the MEI <keySig> element.
Definition: keysig.h:51
This class is a base class for the Layer (<layer>) content.
Definition: layerelement.h:51
This class represents a basic object.
Definition: object.h:66
This class is an pseudo interface for elements maintaining a flat list of children LayerElement for p...
Definition: object.h:937
This class is a base class for MEI scoreDef or staffDef elements.
Definition: scoredef.h:43
FunctorCode Accept(Functor &functor) override
Interface for class functor visitation.
void Reset() override
Reset the object, that is 1) removing all children and 2) resetting all attributes.
This class represents a MEI scoreDef.
Definition: scoredef.h:136
FunctorCode Accept(Functor &functor) override
Interface for class functor visitation.
bool HasSystemStartLine() const
void SetRedrawFlags(int redrawFlags)
Set the redraw flag to all staffDefs.
void ResetFromDrawingValues()
Replace the staffDef score attributes with the ones currently set as drawing values.
void Reset() override
Reset the object, that is 1) removing all children and 2) resetting all attributes.
int GetMaxStaffSize() const
Return the maximum staff size in the scoreDef (100 if empty)
void ReplaceDrawingValues(const ScoreDef *newScoreDef)
Replace the scoreDef with the content of the newScoreDef.
void ReplaceDrawingLabels(const StaffGrp *newStaffGrp)
Replace the corresponding staffGrp with the labels of the newStaffGrp.
void AddOssias(int staffN, const std::list< int >, bool above)
Add ossia staffDefs to the staffN staffDef (above or below)
int GetInsertOrderFor(ClassId classId) const override
Return an order for the given ClassId.
std::vector< int > GetStaffNs() const
Return all the @n values of the staffDef in a scoreDef.
void FilterList(ListOfConstObjects &childList) const override
Filter the flat list and keep only StaffDef elements.
bool IsSupportedChild(ClassId classId) override
Check if a object is allowed as child.
void UpdateKeySig(KeySig *keySig)
Update the keySig of all staffDefs.
void ReplaceDrawingValues(const StaffDef *newStaffDef)
Replace the corresponding staffDef with the content of the newStaffDef.
void CloneReset() override
Overriding CloneReset() method to be called after copy / assignment calls.
bool AddChildAdditionalCheck(Object *child) override
Additional check when adding a child.
StaffGrp * GetStaffGrp(const std::string &n)
Get the staffGrp with number n (NULL if not found).
void UpdateMeterSig(LayerElement *meterSigOrGrp)
Update the meterSig or meterSigGrp of all staffDefs.
Object * Clone() const override
Method call for copying child classes.
Definition: scoredef.h:145
StaffDef * GetStaffDef(int n)
Get the staffDef with number n (NULL if not found).
This class is an interface for elements implementing score attributes, such as <scoreDef>,...
Definition: scoredefinterface.h:43
This class represents a MEI staffDef.
Definition: staffdef.h:37
This class represents a MEI staffGrp.
Definition: staffgrp.h:39