Verovio
Source code documentation
timeinterface.h
1 // Name: timeinterface.h
3 // Author: Laurent Pugin
4 // Created: 2015
5 // Copyright (c) Authors and others. All rights reserved.
7 
8 #ifndef __VRV_TIME_INTERFACE_H__
9 #define __VRV_TIME_INTERFACE_H__
10 
11 #include "atts_shared.h"
12 #include "interface.h"
13 #include "vrvdef.h"
14 
15 namespace vrv {
16 
17 class Object;
18 class LayerElement;
19 class Measure;
20 class PrepareStaffCurrentTimeSpanningFunctor;
21 class PrepareTimePointingFunctor;
22 class PrepareTimeSpanningFunctor;
23 class PrepareTimestampsFunctor;
24 class ResetDataFunctor;
25 class StaffAlignment;
26 
27 //----------------------------------------------------------------------------
28 // TimePointInterface
29 //----------------------------------------------------------------------------
30 
36  public AttPartIdent,
37  public AttStaffIdent,
38  public AttStartId,
39  public AttTimestampLog {
40 public:
47  virtual ~TimePointInterface();
48  void Reset() override;
49  InterfaceId IsInterface() const override { return INTERFACE_TIME_POINT; }
51 
57  void SetStart(LayerElement *start);
58  LayerElement *GetStart() { return m_start; }
59  const LayerElement *GetStart() const { return m_start; }
61 
65  bool SetStartOnly(LayerElement *start);
66 
70  void AddStaff(int n);
71 
75  bool HasStart() const { return (m_start); }
76 
82  const Measure *GetStartMeasure() const;
84 
89  bool IsOnStaff(int n) const;
90 
95  std::vector<const Staff *> GetTstampStaves(const Measure *measure, const Object *object) const;
96  std::vector<Staff *> GetTstampStaves(const Measure *measure, const Object *object);
98 
103  bool VerifyMeasure(const Object *owner) const;
104 
105  //-----------------//
106  // Pseudo functors //
107  //-----------------//
108 
116  virtual FunctorCode InterfacePrepareTimestamps(PrepareTimestampsFunctor &functor, Object *object);
117  virtual FunctorCode InterfaceResetData(ResetDataFunctor &functor, Object *object);
119 
120 protected:
124  void SetIDStr();
125 
126 private:
127  //
128 public:
129  //
130 protected:
131  LayerElement *m_start;
132  std::string m_startID;
133 
134 private:
135 };
136 
137 //----------------------------------------------------------------------------
138 // TimeSpanningInterface
139 //----------------------------------------------------------------------------
140 
145 class TimeSpanningInterface : public TimePointInterface, public AttStartEndId, public AttTimestamp2Log {
146 public:
153  virtual ~TimeSpanningInterface();
154  void Reset() override;
155  InterfaceId IsInterface() const override { return INTERFACE_TIME_SPANNING; }
157 
163  void SetEnd(LayerElement *end);
164  LayerElement *GetEnd() { return m_end; }
165  const LayerElement *GetEnd() const { return m_end; }
167 
171  bool SetStartAndEnd(LayerElement *element);
172 
176  bool HasStartAndEnd() const { return (m_start && m_end); }
177 
183  const Measure *GetEndMeasure() const;
185 
189  bool IsSpanningMeasures() const;
190 
194  void SetIDStr();
195 
201  bool IsOrdered() const;
202  bool IsOrdered(const LayerElement *start, const LayerElement *end) const;
204 
211  StaffAlignment *alignment, curvature_CURVEDIR curveDir, bool &skipAbove, bool &skipBelow);
212 
213  //-----------------//
214  // Pseudo functors //
215  //-----------------//
216 
224  FunctorCode InterfacePrepareTimestamps(PrepareTimestampsFunctor &functor, Object *object) override;
225  FunctorCode InterfacePrepareStaffCurrentTimeSpanning(
227  FunctorCode InterfaceResetData(ResetDataFunctor &functor, Object *object) override;
229 
230 private:
231  //
232 public:
233  //
234 private:
235  LayerElement *m_end;
236  std::string m_endID;
237 };
238 
239 } // namespace vrv
240 
241 #endif
This is a base class for regrouping MEI att classes.
Definition: interface.h:32
This class is a base class for the Layer (<layer>) content.
Definition: layerelement.h:51
This class represents a measure in a page-based score (Doc).
Definition: measure.h:46
This class represents a basic object.
Definition: object.h:61
This class goes through all the TimeSpanningInterface elements and sets them for each staff that is c...
Definition: preparedatafunctor.h:978
This class matches the start for TimePointingInterface elements (such as fermata or harm).
Definition: preparedatafunctor.h:414
This class matches start and end for TimeSpanningInterface elements (such as tie or slur).
Definition: preparedatafunctor.h:466
This class matches start and end for TimeSpanningInterface elements with tstamp(2) attributes.
Definition: preparedatafunctor.h:524
This class resets the drawing values before calling PrepareData after changes.
Definition: resetfunctor.h:22
This class stores an alignement position staves will point to.
Definition: verticalaligner.h:172
This class is an interface for elements having a single time point, such as tempo,...
Definition: timeinterface.h:39
FunctorCode InterfacePrepareTimePointing(PrepareTimePointingFunctor &functor, Object *object)
We have functor code in the interface for avoiding code duplication in each implementation class.
bool HasStart() const
Return true if a start is given (@startid or @tstamp)
Definition: timeinterface.h:75
InterfaceId IsInterface() const override
Virtual method returning the InterfaceId of the interface.
Definition: timeinterface.h:49
bool SetStartOnly(LayerElement *start)
Set first LayerElement by verifying it is the correct one.
Measure * GetStartMeasure()
Return the start measure of the TimePointInterface.
void AddStaff(int n)
Add a staff n to the AttStaffident vector (if not already there)
void SetIDStr()
Extract the fragment of the start or end @xml:id if given.
void Reset() override
Virtual reset method.
bool VerifyMeasure(const Object *owner) const
Return true if the interface owner is encoded in the measure of its start element Display a warning i...
std::vector< const Staff * > GetTstampStaves(const Measure *measure, const Object *object) const
Return a vector of staves looking at the @staff attribute or at the parent staff of the @startid.
bool IsOnStaff(int n) const
Return true if the TimePointInterface occurs on the staff Looks that the parent staff if the using @...
This class is an interface for spanning elements, such as slur, hairpin, etc.
Definition: timeinterface.h:145
bool IsOrdered() const
Check if the end points are temporally ordered @Return true if end temporally occurs after start.
FunctorCode InterfacePrepareTimeSpanning(PrepareTimeSpanningFunctor &functor, Object *object)
We have functor code in the interface for avoiding code duplication in each implementation class.
bool IsSpanningMeasures() const
Return true if the element is spanning over two or more measures.
InterfaceId IsInterface() const override
Virtual method returning the InterfaceId of the interface.
Definition: timeinterface.h:155
void GetCrossStaffOverflows(StaffAlignment *alignment, curvature_CURVEDIR curveDir, bool &skipAbove, bool &skipBelow)
Check if the slur or tie needs to be taken into account as overflow above or below in case of cross-s...
void Reset() override
Virtual reset method.
Measure * GetEndMeasure()
Return the end measure of the TimePointInterface.