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 "timeinterface.h"
13 
14 namespace vrv {
15 
16 class Chord;
17 class Layer;
18 class Note;
19 
20 //----------------------------------------------------------------------------
21 // Tie
22 //----------------------------------------------------------------------------
23 
27 class Tie : public ControlElement, public TimeSpanningInterface, public AttCurvature, public AttLineRendBase {
28 public:
34  Tie();
35  Tie(ClassId classId);
36  virtual ~Tie();
37  Object *Clone() const override { return new Tie(*this); }
38  void Reset() override;
39  std::string GetClassName() const override { return "tie"; }
41 
46  TimePointInterface *GetTimePointInterface() override { return vrv_cast<TimePointInterface *>(this); }
47  const TimePointInterface *GetTimePointInterface() const override
48  {
49  return vrv_cast<const TimePointInterface *>(this);
50  }
51  TimeSpanningInterface *GetTimeSpanningInterface() override { return vrv_cast<TimeSpanningInterface *>(this); }
52  const TimeSpanningInterface *GetTimeSpanningInterface() const override
53  {
54  return vrv_cast<const TimeSpanningInterface *>(this);
55  }
57 
58  virtual bool CalculatePosition(
59  const Doc *doc, const Staff *staff, int x1, int x2, int spanningType, Point bezier[4]);
60 
64  int CalculateAdjacentChordXOffset(const Doc *doc, const Staff *staff, const Chord *parentChord, const Note *note,
65  curvature_CURVEDIR drawingCurveDir, int initialX, bool isStartPoint) const;
66 
67  //----------//
68  // Functors //
69  //----------//
70 
75  FunctorCode Accept(Functor &functor) override;
76  FunctorCode Accept(ConstFunctor &functor) const override;
77  FunctorCode AcceptEnd(Functor &functor) override;
78  FunctorCode AcceptEnd(ConstFunctor &functor) const override;
80 
81 private:
82  // Update tie positioning based overlaps with accidentals in cases with enharmonic ties
83  bool AdjustEnharmonicTies(const Doc *doc, const FloatingCurvePositioner *curve, Point bezier[4],
84  const Note *startNote, const Note *endNote, curvature_CURVEDIR drawingCurveDir) const;
85 
86  // Calculate the initial X position and return true if the tie endpoints should be adjusted vertically
87  bool CalculateXPosition(const Doc *doc, const Staff *staff, const Chord *startParentChord,
88  const Chord *endParentChord, int spanningType, bool isOuterChordNote, Point &startPoint, Point &endPoint,
89  curvature_CURVEDIR drawingCurveDir) const;
90 
91  // Helper function to get preferred curve direction based on the number of conditions (like note direction, position
92  // on the staff, etc.)
93  curvature_CURVEDIR GetPreferredCurveDirection(const Layer *layer, const Note *note, const Chord *startParentChord,
94  data_STEMDIRECTION noteStemDir, bool isAboveStaffCenter) const;
95 
96  // Update tie positioning based on the overlaps with possible layerElements such as dots/flags
97  void UpdateTiePositioning(const FloatingCurvePositioner *curve, Point bezier[4], const LayerElement *durElement,
98  const Note *startNote, int height, curvature_CURVEDIR drawingCurveDir) const;
99 
100 public:
101  //
102 private:
103 };
104 
105 } // namespace vrv
106 
107 #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:33
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:67
This class represents a basic object.
Definition: object.h:61
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:27
Object * Clone() const override
Method call for copying child classes.
Definition: tie.h:37
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 elements having a single time point, such as tempo,...
Definition: timeinterface.h:39
This class is an interface for spanning elements, such as slur, hairpin, etc.
Definition: timeinterface.h:145