Verovio
Source code documentation
chord.h
1 // Name: chord.h
3 // Author: Andrew Horwitz
4 // Created: 2015
5 // Copyright (c) Authors and others. All rights reserved.
7 
8 #ifndef __VRV_CHORD_H__
9 #define __VRV_CHORD_H__
10 
11 #include "atts_shared.h"
12 #include "drawinginterface.h"
13 #include "durationinterface.h"
14 #include "layerelement.h"
15 
16 namespace vrv {
17 
18 class Dots;
19 class StaffAlignment;
20 
21 //----------------------------------------------------------------------------
22 // Chord
23 //----------------------------------------------------------------------------
24 
32 class Chord : public LayerElement,
33  public ObjectListInterface,
34  public DrawingListInterface,
36  public DurationInterface,
37  public AttChordVis,
38  public AttColor,
39  public AttCue,
40  public AttGraced,
41  public AttStems,
42  public AttStemsCmn,
43  public AttTiePresent,
44  public AttVisibility {
45 public:
51  Chord();
52  virtual ~Chord();
53  Object *Clone() const override { return new Chord(*this); }
54  void Reset() override;
55  std::string GetClassName() const override { return "chord"; }
57 
61  void CloneReset() override;
62 
67  DurationInterface *GetDurationInterface() override { return vrv_cast<DurationInterface *>(this); }
68  const DurationInterface *GetDurationInterface() const override { return vrv_cast<const DurationInterface *>(this); }
69  StemmedDrawingInterface *GetStemmedDrawingInterface() override { return vrv_cast<StemmedDrawingInterface *>(this); }
70  const StemmedDrawingInterface *GetStemmedDrawingInterface() const override
71  {
72  return vrv_cast<const StemmedDrawingInterface *>(this);
73  }
75 
77  bool HasToBeAligned() const override { return true; }
78 
82  bool IsSupportedChild(ClassId classId) override;
83 
87  bool AddChild(Object *object) override;
88 
92  void GetYExtremes(int &yMax, int &yMin) const;
93 
99  const Note *GetTopNote() const;
100  Note *GetBottomNote();
101  const Note *GetBottomNote() const;
102  int GetYTop() const;
103  int GetYBottom() const;
105 
110  int GetXMin() const;
111  int GetXMax() const;
113 
119  Staff *&staffAbove, Staff *&staffBelow, Layer **layerAbove = NULL, Layer **layerBelow = NULL);
120  void GetCrossStaffExtremes(const Staff *&staffAbove, const Staff *&staffBelow, const Layer **layerAbove = NULL,
121  const Layer **layerBelow = NULL) const;
123 
127  bool HasCrossStaff() const override;
128 
133 
138 
139  int PositionInChord(const Note *note) const;
141 
147  Point GetStemUpSE(const Doc *doc, int staffSize, bool isCueSize) const override;
148  Point GetStemDownNW(const Doc *doc, int staffSize, bool isCueSize) const override;
149  int CalcStemLenInThirdUnits(const Staff *staff, data_STEMDIRECTION stemDir) const override;
151 
155  bool IsVisible() const;
156 
160  bool HasAdjacentNotesInStaff(const Staff *staff) const;
161 
165  bool HasNoteWithDots() const;
166 
171  int AdjustOverlappingLayers(const Doc *doc, const std::vector<LayerElement *> &otherElements, bool areDotsAdjusted,
172  bool &isUnison, bool &stemSameas) override;
173 
179  std::list<const Note *> GetAdjacentNotesList(const Staff *staff, int loc) const;
180 
185 
186  //----------//
187  // Functors //
188  //----------//
189 
194  FunctorCode Accept(Functor &functor) override;
195  FunctorCode Accept(ConstFunctor &functor) const override;
196  FunctorCode AcceptEnd(Functor &functor) override;
197  FunctorCode AcceptEnd(ConstFunctor &functor) const override;
199 
200 protected:
204  MapOfNoteLocs CalcNoteLocations(NotePredicate predicate = NULL) const override;
205 
211  MapOfDotLocs CalcDotLocations(int layerCount, bool primary) const override;
212 
216  void ClearNoteGroups() const;
217 
221  void FilterList(ListOfConstObjects &childList) const override;
222 
223 public:
224  //
225 private:
229  mutable std::list<ChordNoteGroup *> m_noteGroups;
230 };
231 
232 } // namespace vrv
233 
234 #endif
This class represents a collection of notes in the same layer with the same onset time.
Definition: chord.h:44
int GetXMin() const
Return min or max note X position.
MapOfDotLocs CalcDotLocations(int layerCount, bool primary) const override
The dot locations w.r.t.
bool HasCrossStaff() const override
Return true if the chord has some cross staff notes.
void ResetAccidList()
Returns list of notes that have accidentals.
bool AddChild(Object *object) override
Overwritten method for chord.
void FilterList(ListOfConstObjects &childList) const override
Filter the flat list and keep only Note elements.
bool HasNoteWithDots() const
Return true if the chord has at least one note with a @dots > 0.
void CloneReset() override
Overriding CloneReset() method to be called after copy / assignment calls.
void GetCrossStaffExtremes(Staff *&staffAbove, Staff *&staffBelow, Layer **layerAbove=NULL, Layer **layerBelow=NULL)
Return the cross staff above or below (if any).
bool IsVisible() const
Check if the chord or one of its children is visible.
void CalculateNoteGroups()
Recalculate the m_noteGroups vector.
bool HasToBeAligned() const override
Override the method since alignment is required.
Definition: chord.h:77
Point GetStemUpSE(const Doc *doc, int staffSize, bool isCueSize) const override
Get the stem up / stem down attachment point.
MapOfNoteLocs CalcNoteLocations(NotePredicate predicate=NULL) const override
The note locations w.r.t.
void ClearNoteGroups() const
Clear the m_noteGroups vector and delete all the objects.
int PositionInChord(const Note *note) const
Return information about a note's position in the chord.
bool HasAdjacentNotesInStaff(const Staff *staff) const
Return true if the chord has two notes with 1 diatonic step difference in the specific staff.
int AdjustOverlappingLayers(const Doc *doc, const std::vector< LayerElement * > &otherElements, bool areDotsAdjusted, bool &isUnison, bool &stemSameas) override
Helper to adjust overlapping layers for chords Returns the shift of the adjustment.
std::list< const Note * > GetAdjacentNotesList(const Staff *staff, int loc) const
Helper to get list of notes that are adjacent to the specified location.
void GetYExtremes(int &yMax, int &yMin) const
Return the maximum and minimum Y positions of the notes in the chord.
FunctorCode Accept(Functor &functor) override
Interface for class functor visitation.
Object * Clone() const override
Method call for copying child classes.
Definition: chord.h:53
Note * GetTopNote()
Return the top or bottom note or their Y position.
bool IsSupportedChild(ClassId classId) override
Add an element (only note supported) to a chord.
This abstract class is the base class for all const functors.
Definition: functor.h:126
This class is a hold the data and corresponds to the model of a MVC design pattern.
Definition: doc.h:41
This class is an interface for elements with duration, such as notes and rests.
Definition: drawinginterface.h:34
This class is an interface for elements with duration, such as notes and rests.
Definition: durationinterface.h:39
This abstract class is the base class for all mutable functors.
Definition: functor.h:101
This class is a base class for the Layer (<layer>) content.
Definition: layerelement.h:51
This class represents a layer in a laid-out score (Doc).
Definition: layer.h:40
This class models the MEI <note> element.
Definition: note.h:69
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:925
Simple class for representing points.
Definition: devicecontextbase.h:203
This class represents a staff in a laid-out score (Doc).
Definition: staff.h:110
This class is an interface for MEI stemmed element.
Definition: drawinginterface.h:379