Verovio
Source code documentation
tie.h
1 // Name: tie.h
3 // Author: Rodolfo Zitellini
4 // Created: 26/06/2012
5 // Copyright (c) Authors and others. All rights reserved.
7 
8 #ifndef __VRV_TIE_H__
9 #define __VRV_TIE_H__
10 
11 #include "controlelement.h"
12 #include "offsetinterface.h"
13 #include "timeinterface.h"
14 
15 namespace vrv {
16 
17 class Chord;
18 class Layer;
19 class Note;
20 
21 //----------------------------------------------------------------------------
22 // Tie
23 //----------------------------------------------------------------------------
24 
28 class Tie : public ControlElement,
30  public TimeSpanningInterface,
31  public AttCurvature,
32  public AttLineRendBase {
33 public:
39  Tie();
40  Tie(ClassId classId);
41  virtual ~Tie();
42  Object *Clone() const override { return new Tie(*this); }
43  void Reset() override;
44  std::string GetClassName() const override { return "tie"; }
46 
51  OffsetSpanningInterface *GetOffsetSpanningInterface() override { return vrv_cast<OffsetSpanningInterface *>(this); }
52  const OffsetSpanningInterface *GetOffsetSpanningInterface() const override
53  {
54  return vrv_cast<const OffsetSpanningInterface *>(this);
55  }
56  TimePointInterface *GetTimePointInterface() override { return vrv_cast<TimePointInterface *>(this); }
57  const TimePointInterface *GetTimePointInterface() const override
58  {
59  return vrv_cast<const TimePointInterface *>(this);
60  }
61  TimeSpanningInterface *GetTimeSpanningInterface() override { return vrv_cast<TimeSpanningInterface *>(this); }
62  const TimeSpanningInterface *GetTimeSpanningInterface() const override
63  {
64  return vrv_cast<const TimeSpanningInterface *>(this);
65  }
67 
68  virtual bool CalculatePosition(
69  const Doc *doc, const Staff *staff, int x1, int x2, int spanningType, Point bezier[4]);
70 
74  int CalculateAdjacentChordXOffset(const Doc *doc, const Staff *staff, const Chord *parentChord, const Note *note,
75  curvature_CURVEDIR drawingCurveDir, int initialX, bool isStartPoint) const;
76 
77  //----------//
78  // Functors //
79  //----------//
80 
85  FunctorCode Accept(Functor &functor) override;
86  FunctorCode Accept(ConstFunctor &functor) const override;
87  FunctorCode AcceptEnd(Functor &functor) override;
88  FunctorCode AcceptEnd(ConstFunctor &functor) const override;
90 
91 private:
92  // Update tie positioning based overlaps with accidentals in cases with enharmonic ties
93  bool AdjustEnharmonicTies(const Doc *doc, const FloatingCurvePositioner *curve, Point bezier[4],
94  const Note *startNote, const Note *endNote, curvature_CURVEDIR drawingCurveDir) const;
95 
96  // Calculate the initial X position and return true if the tie endpoints should be adjusted vertically
97  bool CalculateXPosition(const Doc *doc, const Staff *staff, const Chord *startParentChord,
98  const Chord *endParentChord, int spanningType, bool isOuterChordNote, Point &startPoint, Point &endPoint,
99  curvature_CURVEDIR drawingCurveDir) const;
100 
101  // Helper function to get preferred curve direction based on the number of conditions (like note direction, position
102  // on the staff, etc.)
103  curvature_CURVEDIR GetPreferredCurveDirection(const Layer *layer, const Note *note, const Chord *startParentChord,
104  data_STEMDIRECTION noteStemDir, bool isAboveStaffCenter) const;
105 
106  // Update tie positioning based on the overlaps with possible layerElements such as dots/flags
107  void UpdateTiePositioning(const FloatingCurvePositioner *curve, Point bezier[4], const LayerElement *durElement,
108  const Note *startNote, int height, curvature_CURVEDIR drawingCurveDir) const;
109 
110 public:
111  //
112 private:
113 };
114 
115 } // namespace vrv
116 
117 #endif
This class represents a collection of notes in the same layer with the same onset time.
Definition: chord.h:44
This abstract class is the base class for all const functors.
Definition: functor.h:126
This class represents elements appearing within a measure.
Definition: controlelement.h:35
This class is a hold the data and corresponds to the model of a MVC design pattern.
Definition: doc.h:41
This class represents a basic object for a curve (slur, tie) in the layout domain.
Definition: floatingobject.h:329
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:69
This class represents a basic object.
Definition: object.h:64
This class is an interface for elements having spanning visual offsets, such as slur,...
Definition: offsetinterface.h:72
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 models the MEI <tie> element.
Definition: tie.h:32
Object * Clone() const override
Method call for copying child classes.
Definition: tie.h:42
int CalculateAdjacentChordXOffset(const Doc *doc, const Staff *staff, const Chord *parentChord, const Note *note, curvature_CURVEDIR drawingCurveDir, int initialX, bool isStartPoint) const
Calculate starting/ending point for the ties in the chords with adjacent notes.
void Reset() override
Virtual reset method.
FunctorCode Accept(Functor &functor) override
Interface for class functor visitation.
This class is an interface for spanning elements, such as slur, hairpin, etc.
Definition: timeinterface.h:145