Verovio
Source code documentation
tuplet.h
1 // Name: tuplet.h
3 // Author: Rodolfo Zitellini
4 // Created: 26/06/2012
5 // Copyright (c) Authors and others. All rights reserved.
7 
8 #ifndef __VRV_TUPLET_H__
9 #define __VRV_TUPLET_H__
10 
11 #include "atts_cmn.h"
12 #include "atts_shared.h"
13 #include "atts_visual.h"
14 #include "layerelement.h"
15 
16 namespace vrv {
17 
18 class Note;
19 class TupletBracket;
20 
21 // Helper enum classes
22 enum class MelodicDirection { None, Up, Down };
23 
24 //----------------------------------------------------------------------------
25 // Tuplet
26 //----------------------------------------------------------------------------
27 
28 class Tuplet : public LayerElement,
29  public ObjectListInterface,
30  public AttColor,
31  public AttDurationRatio,
32  public AttNumberPlacement,
33  public AttTupletVis {
34 public:
39  Tuplet();
41  virtual ~Tuplet();
42  Object *Clone() const override { return new Tuplet(*this); }
43  void Reset() override;
44  std::string GetClassName() const override { return "tuplet"; }
46 
51  bool IsSupportedChild(ClassId classId) override;
52 
56  void AddChild(Object *object) override;
57 
61  LayerElement *GetDrawingLeft() { return m_drawingLeft; }
63  const LayerElement *GetDrawingLeft() const { return m_drawingLeft; }
64  void SetDrawingLeft(LayerElement *drawingLeft) { m_drawingLeft = drawingLeft; }
65  LayerElement *GetDrawingRight() { return m_drawingRight; }
66  const LayerElement *GetDrawingRight() const { return m_drawingRight; }
67  void SetDrawingRight(LayerElement *drawingRight) { m_drawingRight = drawingRight; }
68  data_STAFFREL_basic GetDrawingBracketPos() const { return m_drawingBracketPos; }
69  void SetDrawingBracketPos(data_STAFFREL_basic bracketPos) { m_drawingBracketPos = bracketPos; }
70  data_STAFFREL_basic GetDrawingNumPos() const { return m_drawingNumPos; }
71  void SetDrawingNumPos(data_STAFFREL_basic numPos) { m_drawingNumPos = numPos; }
73 
77  Beam *GetBracketAlignedBeam() { return m_bracketAlignedBeam; }
79  const Beam *GetBracketAlignedBeam() const { return m_bracketAlignedBeam; }
80  void SetBracketAlignedBeam(Beam *alignedBeam) { m_bracketAlignedBeam = alignedBeam; }
81  Beam *GetNumAlignedBeam() { return m_numAlignedBeam; }
82  const Beam *GetNumAlignedBeam() const { return m_numAlignedBeam; }
83  void SetNumAlignedBeam(Beam *alignedBeam) { m_numAlignedBeam = alignedBeam; }
85 
89  const std::set<const FloatingCurvePositioner *> &GetInnerSlurs() const { return m_innerSlurs; }
91  void AddInnerSlur(const FloatingCurvePositioner *slur) { m_innerSlurs.insert(slur); }
92  void ResetInnerSlurs() { m_innerSlurs.clear(); }
94 
98  MelodicDirection GetMelodicDirection() const;
99 
104  void CalcDrawingBracketAndNumPos(bool tupletNumHead);
105 
110  void GetDrawingLeftRightXRel(int &xRelLeft, int &xRelRight, const Doc *doc) const;
111 
116  void CalculateTupletNumCrossStaff(LayerElement *layerElement);
117 
121  bool HasValidTupletNumPosition(const Staff *preferredStaff, const Staff *otherStaff) const;
122 
123  //----------//
124  // Functors //
125  //----------//
126 
130  FunctorCode Accept(Functor &functor) override;
132  FunctorCode Accept(ConstFunctor &functor) const override;
133  FunctorCode AcceptEnd(Functor &functor) override;
134  FunctorCode AcceptEnd(ConstFunctor &functor) const override;
136 
137 protected:
141  void FilterList(ListOfConstObjects &childList) const override;
142 
143 private:
144  //
145 public:
146  //
147 private:
152  LayerElement *m_drawingLeft;
157  LayerElement *m_drawingRight;
159  data_STAFFREL_basic m_drawingBracketPos;
161  data_STAFFREL_basic m_drawingNumPos;
163  Beam *m_bracketAlignedBeam;
165  Beam *m_numAlignedBeam;
167  std::set<const FloatingCurvePositioner *> m_innerSlurs;
168 };
169 
170 } // namespace vrv
171 
172 #endif
vrv::Tuplet::Clone
Object * Clone() const override
Method call for copying child classes.
Definition: tuplet.h:42
vrv::Tuplet::GetMelodicDirection
MelodicDirection GetMelodicDirection() const
Determine the melodic direction.
vrv::Object
This class represents a basic object.
Definition: object.h:59
vrv::Tuplet::AddChild
void AddChild(Object *object) override
Overwritten method for tuplet.
vrv::Tuplet::Accept
FunctorCode Accept(Functor &functor) override
Interface for class functor visitation.
vrv::Tuplet::CalcDrawingBracketAndNumPos
void CalcDrawingBracketAndNumPos(bool tupletNumHead)
Calculate the position of the bracket and the num looking at the stem direction or at the encoded val...
vrv::ObjectListInterface
This class is an pseudo interface for elements maintaining a flat list of children LayerElement for p...
Definition: object.h:873
vrv::Tuplet::FilterList
void FilterList(ListOfConstObjects &childList) const override
Filter the flat list and keep only Note elements.
vrv::Tuplet::HasValidTupletNumPosition
bool HasValidTupletNumPosition(const Staff *preferredStaff, const Staff *otherStaff) const
Check whether tuplet number has valid positioning staffwise.
vrv::Tuplet
Definition: tuplet.h:28
vrv::Tuplet::Reset
void Reset() override
Virtual reset method.
vrv::Tuplet::CalculateTupletNumCrossStaff
void CalculateTupletNumCrossStaff(LayerElement *layerElement)
Calculate corresponding cross-staff for the tuplet number if necessary.
vrv::Tuplet::GetDrawingLeftRightXRel
void GetDrawingLeftRightXRel(int &xRelLeft, int &xRelRight, const Doc *doc) const
Return the maximum and minimum X positions of the notes in the tuplets.
vrv::LayerElement
This class is a base class for the Layer (<layer>) content.
Definition: layerelement.h:46
vrv::Tuplet::IsSupportedChild
bool IsSupportedChild(ClassId classId) override
Add an element (a note or a rest) to a tuplet.