Verovio
Source code documentation
keysig.h
1 
3 // Name: keysig.h
4 // Author: Rodolfo Zitellini
5 // Created: 10/07/2012
6 // Copyright (c) Authors and others. All rights reserved.
8 
9 #ifndef __VRV_KEYSIG_H__
10 #define __VRV_KEYSIG_H__
11 
12 #include <optional>
13 
14 //----------------------------------------------------------------------------
15 
16 #include "atts_analytical.h"
17 #include "atts_shared.h"
18 #include "atts_visual.h"
19 #include "clef.h"
20 #include "layerelement.h"
21 
22 namespace vrv {
23 
24 class ScoreDefInterface;
25 
26 //----------------------------------------------------------------------------
27 // KeyAccidInfo
28 //----------------------------------------------------------------------------
32 struct KeyAccidInfo {
33  data_ACCIDENTAL_WRITTEN accid;
34  data_PITCHNAME pname;
35 };
36 
37 //----------------------------------------------------------------------------
38 // KeySig
39 //----------------------------------------------------------------------------
40 
44 class KeySig : public LayerElement,
45  public ObjectListInterface,
46  public AttAccidental,
47  public AttColor,
48  public AttKeyMode,
49  public AttKeySigLog,
50  public AttKeySigVis,
51  public AttPitch,
52  public AttVisibility {
53 public:
59  KeySig();
60  virtual ~KeySig();
61  Object *Clone() const override { return new KeySig(*this); }
62  void Reset() override;
63  std::string GetClassName() const override { return "keySig"; }
65 
67  bool HasToBeAligned() const override { return true; }
68 
70  bool IsScoreDefElement() const override { return (this->GetParent() && this->GetFirstAncestor(SCOREDEF)); }
71 
75  bool IsSupportedChild(ClassId classId) override;
76 
80  bool AddChildAdditionalCheck(Object *child) override;
81 
83  int GetAccidCount(bool fromAttribute = false) const;
84 
86  data_ACCIDENTAL_WRITTEN GetAccidType() const;
87 
93  void GenerateKeyAccidAttribChildren();
95 
101  data_KEYSIGNATURE ConvertToSig() const;
102 
106  void FillMap(MapOfOctavedPitchAccid &mapOfPitchAccid) const;
107 
108  int GetFifthsInt() const;
109 
115  void ResetDrawingClef();
116  void SetDrawingClef(Clef *clef);
118 
119  //----------------//
120  // Static methods //
121  //----------------//
122 
126  static data_PITCHNAME GetAccidPnameAt(data_ACCIDENTAL_WRITTEN alterationType, int pos);
127  static int GetOctave(data_ACCIDENTAL_WRITTEN alterationType, data_PITCHNAME pitch, const Clef *clef);
128 
129  //----------//
130  // Functors //
131  //----------//
132 
137  FunctorCode Accept(Functor &functor) override;
138  FunctorCode Accept(ConstFunctor &functor) const override;
139  FunctorCode AcceptEnd(Functor &functor) override;
140  FunctorCode AcceptEnd(ConstFunctor &functor) const override;
142 
143 protected:
147  void FilterList(ListOfConstObjects &childList) const override;
148 
149 private:
153  std::optional<KeyAccidInfo> GetKeyAccidInfoAt(int pos) const;
154 
155 public:
162  data_ACCIDENTAL_WRITTEN m_drawingCancelAccidType;
163  char m_drawingCancelAccidCount;
165 
166  //----------------//
167  // Static members //
168  //----------------//
169 
170  static const data_PITCHNAME s_pnameForFlats[];
171  static const data_PITCHNAME s_pnameForSharps[];
172 
173 private:
178  std::optional<Clef> m_drawingClef;
179 
180  //----------------//
181  // Static members //
182  //----------------//
183 
184  static const int octave_map[2][9][7];
185 };
186 
187 } // namespace vrv
188 
189 #endif
This class models the MEI <clef> element.
Definition: clef.h:39
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 models the MEI <keySig> element.
Definition: keysig.h:52
static data_PITCHNAME GetAccidPnameAt(data_ACCIDENTAL_WRITTEN alterationType, int pos)
Static methods for calculating position;.
void FillMap(MapOfOctavedPitchAccid &mapOfPitchAccid) const
Fill the map of modified pitches.
FunctorCode Accept(Functor &functor) override
Interface for class functor visitation.
bool AddChildAdditionalCheck(Object *child) override
Additional check when adding a child.
void FilterList(ListOfConstObjects &childList) const override
Filter the flat list and keep only StaffDef elements.
data_ACCIDENTAL_WRITTEN GetAccidType() const
Accid type getter.
bool HasNonAttribKeyAccidChildren() const
Generate KeyAccid attribute children.
Clef * GetDrawingClef()
Set/Get the drawing clef.
bool IsSupportedChild(ClassId classId) override
Add an element (a keyAccid) to a keySig.
bool IsScoreDefElement() const override
Override the method since check is required.
Definition: keysig.h:70
Object * Clone() const override
Method call for copying child classes.
Definition: keysig.h:61
data_KEYSIGNATURE ConvertToSig() const
Try to convert a keySig content (keyAccid) to a @sig value This can work only if the content represen...
void Reset() override
Virtual reset method.
bool HasToBeAligned() const override
Override the method since alignment is required.
Definition: keysig.h:67
bool m_skipCancellation
Variables for storing cancellation introduced by the key sig.
Definition: keysig.h:161
int GetAccidCount(bool fromAttribute=false) const
Accid number getter.
This class is a base class for the Layer (<layer>) content.
Definition: layerelement.h:51
This class represents a basic object.
Definition: object.h:61
Object * GetFirstAncestor(const ClassId classId, int maxSteps=-1)
Return the first ancestor of the specified type.
Object * GetParent()
Get the parent of the Object.
Definition: object.h:383
This class is an pseudo interface for elements maintaining a flat list of children LayerElement for p...
Definition: object.h:893
Useful information regarding a KeyAccid child.
Definition: keysig.h:32