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 "drawinginterface.h"
15 #include "object.h"
16 #include "scoredefinterface.h"
17 
18 namespace vrv {
19 
20 class Clef;
21 class KeySig;
22 class Mensur;
23 class MeterSig;
24 class MeterSigGrp;
25 class PgFoot;
26 class PgHead;
27 class StaffGrp;
28 class StaffDef;
29 
30 //----------------------------------------------------------------------------
31 // ScoreDefElement
32 //----------------------------------------------------------------------------
33 
42 class ScoreDefElement : public Object, public ScoreDefInterface, public AttTyped {
43 public:
49  ScoreDefElement(ClassId classId);
50  virtual ~ScoreDefElement();
51  void Reset() override;
53 
58  ScoreDefInterface *GetScoreDefInterface() override { return vrv_cast<ScoreDefInterface *>(this); }
59  const ScoreDefInterface *GetScoreDefInterface() const override { return vrv_cast<const ScoreDefInterface *>(this); }
61 
66  bool HasClefInfo(int depth = 1) const;
67  bool HasKeySigInfo(int depth = 1) const;
68  bool HasMensurInfo(int depth = 1) const;
69  bool HasMeterSigInfo(int depth = 1) const;
70  bool HasMeterSigGrpInfo(int depth = 1) const;
72 
82  Clef *GetClef();
83  const Clef *GetClef() const;
84  Clef *GetClefCopy() const;
85  KeySig *GetKeySig();
86  const KeySig *GetKeySig() const;
87  KeySig *GetKeySigCopy() const;
88  Mensur *GetMensur();
89  const Mensur *GetMensur() const;
90  Mensur *GetMensurCopy() const;
91  MeterSig *GetMeterSig();
92  const MeterSig *GetMeterSig() const;
93  MeterSig *GetMeterSigCopy() const;
94  MeterSigGrp *GetMeterSigGrp();
95  const MeterSigGrp *GetMeterSigGrp() const;
96  MeterSigGrp *GetMeterSigGrpCopy() const;
98 
99  //----------//
100  // Functors //
101  //----------//
102 
107  FunctorCode Accept(Functor &functor) override;
108  FunctorCode Accept(ConstFunctor &functor) const override;
109  FunctorCode AcceptEnd(Functor &functor) override;
110  FunctorCode AcceptEnd(ConstFunctor &functor) const override;
112 
113 private:
114  //
115 public:
116  //
117 private:
118  //
119 };
120 
121 //----------------------------------------------------------------------------
122 // ScoreDef
123 //----------------------------------------------------------------------------
124 
129 class ScoreDef : public ScoreDefElement,
130  public ObjectListInterface,
131  public AttDistances,
132  public AttEndings,
133  public AttOptimization,
134  public AttTimeBase,
135  public AttTuning {
136 public:
142  ScoreDef();
143  virtual ~ScoreDef();
144  Object *Clone() const override { return new ScoreDef(*this); }
145  void Reset() override;
146  std::string GetClassName() const override { return "scoreDef"; }
148 
152  bool IsSupportedChild(ClassId classId) override;
153 
157  bool AddChildAdditionalCheck(Object *child) override;
158 
162  int GetInsertOrderFor(ClassId classId) const override;
163 
167  void ReplaceDrawingValues(const ScoreDef *newScoreDef);
168 
174  void ReplaceDrawingValues(const StaffDef *newStaffDef);
175 
180  void ReplaceDrawingLabels(const StaffGrp *newStaffGrp);
181 
187 
193  const StaffDef *GetStaffDef(int n) const;
195 
200  StaffGrp *GetStaffGrp(const std::string &n);
201  const StaffGrp *GetStaffGrp(const std::string &n) const;
203 
207  std::vector<int> GetStaffNs() const;
208 
213  void SetRedrawFlags(int redrawFlags);
214 
219  bool DrawLabels() const { return m_drawLabels; }
220  void SetDrawLabels(bool drawLabels) { m_drawLabels = drawLabels; }
222 
227  int GetDrawingWidth() const { return m_drawingWidth; }
228  void SetDrawingWidth(int drawingWidth);
230 
235  int GetDrawingLabelsWidth() const { return m_drawingLabelsWidth; }
236  void SetDrawingLabelsWidth(int width);
237  void ResetDrawingLabelsWidth() { m_drawingLabelsWidth = 0; }
239 
244  PgFoot *GetPgFoot(data_PGFUNC func);
245  const PgFoot *GetPgFoot(data_PGFUNC func) const;
246  PgHead *GetPgHead(data_PGFUNC func);
247  const PgHead *GetPgHead(data_PGFUNC func) const;
249 
253  int GetMaxStaffSize() const;
254 
255  bool IsSectionRestart() const;
256 
260  bool HasSystemStartLine() const;
261 
262  //----------//
263  // Functors //
264  //----------//
265 
270  FunctorCode Accept(Functor &functor) override;
271  FunctorCode Accept(ConstFunctor &functor) const override;
272  FunctorCode AcceptEnd(Functor &functor) override;
273  FunctorCode AcceptEnd(ConstFunctor &functor) const override;
275 
276 protected:
280  void FilterList(ListOfConstObjects &childList) const override;
281 
282 private:
283  //
284 public:
285  bool m_setAsDrawing;
286  bool m_insertScoreDef;
287 
288 private:
290  bool m_drawLabels;
292  int m_drawingWidth;
294  int m_drawingLabelsWidth;
295 };
296 
297 } // namespace vrv
298 
299 #endif
This abstract class is the base class for all const functors.
Definition: functor.h:126
This abstract class is the base class for all mutable functors.
Definition: functor.h:101
This class represents a basic object.
Definition: object.h:61
This class is an pseudo interface for elements maintaining a flat list of children LayerElement for p...
Definition: object.h:893
This class is a base class for MEI scoreDef or staffDef elements.
Definition: scoredef.h:42
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:135
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.
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 ReplaceDrawingValues(const StaffDef *newStaffDef)
Replace the corresponding staffDef with the content of the newStaffDef.
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).
Object * Clone() const override
Method call for copying child classes.
Definition: scoredef.h:144
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:42
This class represents a MEI staffDef.
Definition: staffdef.h:37
This class represents a MEI staffGrp.
Definition: staffgrp.h:39