8 #ifndef __VRV_HORIZONTAL_ALIGNER_H__
9 #define __VRV_HORIZONTAL_ALIGNER_H__
11 #include "atts_shared.h"
19 class AlignmentReference;
32 ALIGNMENT_MEASURE_START = 0,
34 ALIGNMENT_SCOREDEF_CLEF,
35 ALIGNMENT_SCOREDEF_KEYSIG,
36 ALIGNMENT_SCOREDEF_MENSUR,
37 ALIGNMENT_SCOREDEF_METERSIG,
38 ALIGNMENT_MEASURE_LEFT_BARLINE,
40 ALIGNMENT_FULLMEASURE,
41 ALIGNMENT_FULLMEASURE2,
55 ALIGNMENT_MEASURE_RIGHT_BARLINE,
56 ALIGNMENT_SCOREDEF_CAUTION_CLEF,
57 ALIGNMENT_SCOREDEF_CAUTION_KEYSIG,
58 ALIGNMENT_SCOREDEF_CAUTION_MENSUR,
59 ALIGNMENT_SCOREDEF_CAUTION_METERSIG,
63 #define BARLINE_REFERENCES -1
64 #define TSTAMP_REFERENCES -2
100 void SetXRel(
int xRel);
101 int GetXRel()
const {
return m_xRel; }
108 void SetTime(
const Fraction &time) { m_time = time; }
109 Fraction GetTime()
const {
return m_time; }
116 bool operator==(
const Alignment &other)
const;
117 std::weak_ordering operator<=>(
const Alignment &other)
const;
131 void SetType(AlignmentType type) { m_type = type; }
132 AlignmentType GetType()
const {
return m_type; }
138 bool IsOfType(
const std::vector<AlignmentType> &types)
const;
146 const std::vector<int> &staffNs,
int &minLeft,
int &maxRight,
const std::vector<ClassId> &excludes = {})
const;
147 void GetLeftRight(
int staffN,
int &minLeft,
int &maxRight,
const std::vector<ClassId> &excludes = {})
const;
204 return StringFormat(
"%d %f", this->GetXRel(), this->GetTime().ToDouble());
227 const Fraction &intervalTime, data_DURATION maxActualDur,
double spacingLinear,
double spacingNonLinear);
239 FunctorCode AcceptEnd(
Functor &functor)
override;
240 FunctorCode AcceptEnd(
ConstFunctor &functor)
const override;
272 AlignmentType m_type;
277 MapOfIntGraceAligners m_graceAligners;
338 FunctorCode AcceptEnd(
Functor &functor)
override;
339 FunctorCode AcceptEnd(
ConstFunctor &functor)
const override;
379 int GetAlignmentCount()
const {
return this->GetChildCount(); }
391 FunctorCode AcceptEnd(
Functor &functor)
override;
392 FunctorCode AcceptEnd(
ConstFunctor &functor)
const override;
465 int GetNonJustifiableMargin()
const {
return m_nonJustifiableLeftMargin; }
473 void SetInitialTstamp(data_DURATION meterUnit);
474 Fraction GetInitialTstampDur()
const {
return m_initialTstampDur; }
485 Alignment *GetLeftBarLineAlignment() {
return m_leftBarLineAlignment; }
486 const Alignment *GetLeftBarLineAlignment()
const {
return m_leftBarLineAlignment; }
497 Alignment *GetRightBarLineAlignment() {
return m_rightBarLineAlignment; }
498 const Alignment *GetRightBarLineAlignment()
const {
return m_rightBarLineAlignment; }
529 FunctorCode AcceptEnd(
Functor &functor)
override;
530 FunctorCode AcceptEnd(
ConstFunctor &functor)
const override;
553 int m_nonJustifiableLeftMargin;
605 void SetWidth(
int totalWidth) { m_totalWidth = totalWidth; }
606 int GetWidth()
const {
return m_totalWidth; }
614 int GetGraceGroupLeft(
int staffN)
const;
615 int GetGraceGroupRight(
int staffN)
const;
634 FunctorCode AcceptEnd(
Functor &functor)
override;
635 FunctorCode AcceptEnd(
ConstFunctor &functor)
const override;
646 ArrayOfObjects m_graceStack;
696 FunctorCode AcceptEnd(
Functor &functor)
override;
697 FunctorCode AcceptEnd(
ConstFunctor &functor)
const override;
This class stores an alignment position elements will point to.
Definition: horizontalaligner.h:73
std::pair< int, int > GetAlignmentTopBottom() const
Return pair of max and min Y value within alignment.
AlignmentReference * GetReferenceWithElement(const LayerElement *element, int staffN=VRV_UNSET)
Return the AlignmentReference holding the element.
bool HasAccidVerticalOverlap(const Alignment *otherAlignment, int staffN) const
Return true if there is vertical overlap with accidentals from another alignment for specific staffN.
static int HorizontalSpaceForDuration(const Fraction &intervalTime, data_DURATION maxActualDur, double spacingLinear, double spacingNonLinear)
Compute "ideal" horizontal space to allow for a given time interval, ignoring the need to keep consec...
void GetLeftRight(const std::vector< int > &staffNs, int &minLeft, int &maxRight, const std::vector< ClassId > &excludes={}) const
Retrieve the minimum left and maximum right position for the objects in an alignment.
std::string LogDebugTreeMsg() override
Debug message.
Definition: horizontalaligner.h:202
void ClearGraceAligners()
Delete the grace aligners in the map.
bool HasTimestampOnly() const
Return true if the alignment contains only references to timestamp attributes.
bool AddLayerElementRef(LayerElement *element)
Add the LayerElement to the appropriate AlignmentReference child.
bool IsOfType(const std::vector< AlignmentType > &types) const
Check if the element is of on of the types.
bool HasAlignmentReference(int staffN) const
Return true if the alignment contains at least one reference with staffN.
void Reset() override
Reset the object, that is 1) removing all children and 2) resetting all attributes.
bool HasGraceAligner(int id) const
Returns true if the aligner has a GraceAligner.
GraceAligner * GetGraceAligner(int id)
Returns the GraceAligner for the Alignment.
const MapOfIntGraceAligners & GetGraceAligners()
Return all GraceAligners for the Alignment.
Definition: horizontalaligner.h:152
bool IsSupportedChild(ClassId classId) override
Override the method of adding AlignmentReference children.
bool PerformBoundingBoxAlignment() const
Returns true for Alignment for which we want to do bounding box alignment.
FunctorCode Accept(Functor &functor) override
Interface for class functor visitation.
This class stores a references of LayerElements for a staff.
Definition: horizontalaligner.h:290
void Reset() override
Reset the object, that is 1) removing all children and 2) resetting all attributes.
bool HasAccidVerticalOverlap(const ArrayOfConstObjects &objects) const
Return true if one of objects overlaps with accidentals from current reference (i....
bool IsSupportedChild(ClassId classId) override
Override the method of adding Alignment children.
void AddChild(Object *object) override
Overwritten method for AlignmentReference children.
bool HasMultipleLayer() const
Return true if the reference has elements from multiple layers.
Definition: horizontalaligner.h:321
FunctorCode Accept(Functor &functor) override
Interface for class functor visitation.
bool HasCrossStaffElements() const
Return true if the reference has elements from cross-staff.
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
Definition: fraction.h:19
This abstract class is the base class for all mutable functors.
Definition: functor.h:101
This class aligns the content of a grace note group It contains a vector of Alignment.
Definition: horizontalaligner.h:570
void AlignStack()
Align the notes in the reverse order.
FunctorCode Accept(Functor &functor) override
Interface for class functor visitation.
void Reset() override
Reset the object, that is 1) removing all children and 2) resetting all attributes.
void SetGraceAlignmentXPos(const Doc *doc)
Set an linear defaut position for each grace note This is called from the CalcAlignmentXPosFunctor.
void StackGraceElement(LayerElement *object)
Because the grace notes appear from left to right but need to be aligned from right to left,...
Alignment * GetAlignmentAtTime(const Fraction &time, AlignmentType type)
Retrieve the alignmnet of the type at that time.
This class aligns the content horizontally It contains a vector of Alignment.
Definition: horizontalaligner.h:362
FunctorCode Accept(Functor &functor) override
Interface for class functor visitation.
Alignment * SearchAlignmentAtTime(const Fraction &time, AlignmentType type, int &idx)
Search if an alignment of the type is already there at the time.
HorizontalAligner(ClassId classId)
@(
void Reset() override
Reset the object, that is 1) removing all children and 2) resetting all attributes.
bool CopyChildren() const override
Do not copy children for HorizontalAligner.
Definition: horizontalaligner.h:377
void AddAlignment(Alignment *alignment, int idx=-1)
Add an alignment at the appropriate position (at the end if -1)
This class is a base class for the Layer (<layer>) content.
Definition: layerelement.h:51
This class aligns the content of a measure It contains a vector of Alignment.
Definition: horizontalaligner.h:425
void PushAlignmentsRight()
Push all the ALIGNMENT_GRACENOTE and ALIGNMENT_CONTAINER to the right.
Fraction GetMaxTime() const
Return the max time of the measure (i.e., the right measure alignment time)
FunctorCode Accept(Functor &functor) override
Interface for class functor visitation.
void SetMaxTime(const Fraction &time)
Keep the maximum time of the measure.
Alignment * GetAlignmentAtTime(const Fraction &time, AlignmentType type)
Retrieve the alignmnet of the type at that time.
void AdjustGraceNoteSpacing(const Doc *doc, Alignment *alignment, int staffN)
Adjust the spacing for the grace note group(s) of the alignment on staffN The alignment need to be of...
Alignment * GetLeftAlignment()
Get left Alignment for the measure and for the left BarLine.
Definition: horizontalaligner.h:483
Alignment * GetRightAlignment()
Get right Alignment for the measure.
Definition: horizontalaligner.h:495
void Reset() override
Reset the object, that is 1) removing all children and 2) resetting all attributes.
void AdjustProportionally(const ArrayOfAdjustmentTuples &adjustments)
Adjust the spacing of the measure looking at each tuple of start / end alignment and a distance.
bool IsSupportedChild(ClassId classId) override
Override the method of adding AlignmentReference children.
This class represents a basic object.
Definition: object.h:61
This class stores the timestamps (TimestampsAttr) in a measure.
Definition: horizontalaligner.h:664
bool IsSupportedChild(ClassId classId) override
Override the method of adding TimestampAttr children.
void Reset() override
Reset the aligner (clear the content)
FunctorCode Accept(Functor &functor) override
Interface for class functor visitation.
TimestampAttr * GetTimestampAtTime(double time)
Look for an existing TimestampAttr at a certain time.
Definition: timestamp.h:19