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 
62  DurationInterface *GetDurationInterface() override { return vrv_cast<DurationInterface *>(this); }
63  const DurationInterface *GetDurationInterface() const override { return vrv_cast<const DurationInterface *>(this); }
64  StemmedDrawingInterface *GetStemmedDrawingInterface() override { return vrv_cast<StemmedDrawingInterface *>(this); }
65  const StemmedDrawingInterface *GetStemmedDrawingInterface() const override
66  {
67  return vrv_cast<const StemmedDrawingInterface *>(this);
68  }
70 
72  bool HasToBeAligned() const override { return true; }
73 
77  bool IsSupportedChild(ClassId classId) override;
78 
82  void AddChild(Object *object) override;
83 
87  void GetYExtremes(int &yMax, int &yMin) const;
88 
94  const Note *GetTopNote() const;
95  Note *GetBottomNote();
96  const Note *GetBottomNote() const;
97  int GetYTop() const;
98  int GetYBottom() const;
100 
105  int GetXMin() const;
106  int GetXMax() const;
108 
114  Staff *&staffAbove, Staff *&staffBelow, Layer **layerAbove = NULL, Layer **layerBelow = NULL);
115  void GetCrossStaffExtremes(const Staff *&staffAbove, const Staff *&staffBelow, const Layer **layerAbove = NULL,
116  const Layer **layerBelow = NULL) const;
118 
122  bool HasCrossStaff() const override;
123 
128 
133 
134  int PositionInChord(const Note *note) const;
136 
142  Point GetStemUpSE(const Doc *doc, int staffSize, bool isCueSize) const override;
143  Point GetStemDownNW(const Doc *doc, int staffSize, bool isCueSize) const override;
144  int CalcStemLenInThirdUnits(const Staff *staff, data_STEMDIRECTION stemDir) const override;
146 
150  bool IsVisible() const;
151 
155  bool HasAdjacentNotesInStaff(const Staff *staff) const;
156 
160  bool HasNoteWithDots() const;
161 
166  int AdjustOverlappingLayers(const Doc *doc, const std::vector<LayerElement *> &otherElements, bool areDotsAdjusted,
167  bool &isUnison, bool &stemSameas) override;
168 
174  std::list<const Note *> GetAdjacentNotesList(const Staff *staff, int loc) const;
175 
180 
181  //----------//
182  // Functors //
183  //----------//
184 
189  FunctorCode Accept(Functor &functor) override;
190  FunctorCode Accept(ConstFunctor &functor) const override;
191  FunctorCode AcceptEnd(Functor &functor) override;
192  FunctorCode AcceptEnd(ConstFunctor &functor) const override;
194 
195 protected:
199  MapOfNoteLocs CalcNoteLocations(NotePredicate predicate = NULL) const override;
200 
206  MapOfDotLocs CalcDotLocations(int layerCount, bool primary) const override;
207 
211  void ClearNoteGroups() const;
212 
216  void FilterList(ListOfConstObjects &childList) const override;
217 
218 public:
219  //
220 private:
224  mutable std::list<ChordNoteGroup *> m_noteGroups;
225 };
226 
227 } // namespace vrv
228 
229 #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.
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 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:72
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
void AddChild(Object *object) override
Overwritten method for chord.
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:33
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:39
This class models the MEI <note> element.
Definition: note.h:67
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
Simple class for representing points.
Definition: devicecontextbase.h:203
This class represents a staff in a laid-out score (Doc).
Definition: staff.h:107
This class is an interface for MEI stemmed element.
Definition: drawinginterface.h:353