Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace handling of current scoreDef in Doc #3518

Merged
merged 8 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 36 additions & 26 deletions include/vrv/doc.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ class Doc : public Object {
/**
* Generate a document pgFoot if none is provided
*/
bool GenerateFooter();
void GenerateFooter();

/**
* Generate a document pgHead from the MEI header if none is provided
*/
bool GenerateHeader();
void GenerateHeader();

/**
* Generate measure numbers from measure attributes
Expand All @@ -121,11 +121,6 @@ class Doc : public Object {
*/
bool HasPage(int pageIdx) const;

/**
* Get all the Score in the visible Mdiv.
*/
std::list<Score *> GetScores();

/**
* Get the Pages in the visible Mdiv.
* Will find it only when having read a pages-based MEI file,
Expand All @@ -141,6 +136,31 @@ class Doc : public Object {
*/
int GetPageCount() const;

/**
* Get the first scoreDef
*/
///@{
ScoreDef *GetFirstScoreDef();
const ScoreDef *GetFirstScoreDef() const;
///@}

/**
* Get all visible scores / the first visible score
* Lazily updates the visible scores, hence not const
*/
///@{
std::list<Score *> GetVisibleScores();
Score *GetFirstVisibleScore();
///@}

/**
* Get the corresponding score for a node
*/
///@{
Score *GetCorrespondingScore(const Object *object);
const Score *GetCorrespondingScore(const Object *object) const;
///@}

/**
* Return true if the MIDI generation is already done
*/
Expand Down Expand Up @@ -225,7 +245,7 @@ class Doc : public Object {
* Get the default distance from the staff for the object
* The distance is given in x * MEI UNIT
*/
data_MEASUREMENTSIGNED GetStaffDistance(const ClassId classId, int staffIndex, data_STAFFREL staffPosition);
data_MEASUREMENTSIGNED GetStaffDistance(const Object *object, int staffIndex, data_STAFFREL staffPosition) const;

/**
* Prepare the timemap for MIDI and timemap file export.
Expand Down Expand Up @@ -418,19 +438,6 @@ class Doc : public Object {
bool HasFacsimile() const { return m_facsimile != NULL; }
///@}

/**
* @name Setter and getter for the current Score/ScoreDef.
* If not set, then looks for the first Score in the Document and use that.
* The currentScoreDef is also changed by the Object::Process whenever as Score is reached.
* When processing backward, the ScoreDef is changed when reaching the corresponding PageMilestoneEnd
*/
///@{
Score *GetCurrentScore();
ScoreDef *GetCurrentScoreDef();
void SetCurrentScore(Score *score);
bool HasCurrentScore() const { return m_currentScore != NULL; }
///@}

/**
* Return true if the document has been cast off already.
*/
Expand Down Expand Up @@ -477,6 +484,11 @@ class Doc : public Object {
*/
void PrepareMeasureIndices();

/**
* Determine all visible scores
*/
void CollectVisibleScores();

public:
Page *m_selectionPreceding;
Page *m_selectionFollowing;
Expand Down Expand Up @@ -546,12 +558,10 @@ class Doc : public Object {
Resources m_resources;

/**
* @name Holds a pointer to the current score/scoreDef.
* Set by Doc::GetCurrentScoreDef or explicitly through Doc::SetCurrentScoreDef
* The list of all visible scores
* Used in Doc::GetCorrespondingScore to quickly determine the score for an object
*/
///@{
Score *m_currentScore;
///@}
std::list<Score *> m_visibleScores;

/**
* A flag indicating if the document has been cast off or not.
Expand Down
2 changes: 1 addition & 1 deletion include/vrv/floatingobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class FloatingPositioner : public BoundingBox {
/**
* Update the Y drawing relative position based on collision detection with the overlapping bounding box
*/
void CalcDrawingYRel(Doc *doc, const StaffAlignment *staffAlignment, const BoundingBox *horizOverlappingBBox);
void CalcDrawingYRel(const Doc *doc, const StaffAlignment *staffAlignment, const BoundingBox *horizOverlappingBBox);

/**
* Align extender elements across systems
Expand Down
2 changes: 1 addition & 1 deletion include/vrv/iomei.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ class MEIOutput : public Output {
* Scoredef manipulation
*/
///@{
void WriteCustomScoreDef();
void WriteCustomScoreDef(ScoreDef *scoreDef);
void AdjustStaffDef(StaffDef *staffDef, Measure *measure);
bool AdjustLabel(Label *label);
///@}
Expand Down
1 change: 0 additions & 1 deletion include/vrv/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,6 @@ class Object : public BoundingBox {
* Helper methods for functor processing
*/
///@{
void UpdateDocumentScore(bool direction);
bool SkipChildren(bool visibleOnly) const;
bool FiltersApply(const Filters *filters, Object *object) const;
///@}
Expand Down
5 changes: 0 additions & 5 deletions include/vrv/page.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ class Page : public Object {
bool IsSupportedChild(Object *object) override;
///@}

/**
* Return the number of system (children are System object only)
*/
int GetSystemCount() const { return (int)GetChildren().size(); }

/**
* @name Get and set the pixel per unit factor.
*/
Expand Down
6 changes: 0 additions & 6 deletions include/vrv/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ class Score : public PageElement, public PageMilestoneInterface, public AttLabel
const ScoreDef *GetScoreDef() const { return &m_scoreDef; }
///@}

/**
* Helper looking at the parent Doc and set its scoreDef as current one.
* Called from Object::Process
*/
void SetAsCurrent();

/**
* Calculate the height of the pgHead/pgHead2 and pgFoot/pgFoot2 (if any)
* Requires the Doc to have an empty Pages object because it adds temporary pages
Expand Down
4 changes: 3 additions & 1 deletion src/adjustaccidxfunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
//----------------------------------------------------------------------------

#include "doc.h"
#include "score.h"

//----------------------------------------------------------------------------

Expand Down Expand Up @@ -41,7 +42,8 @@ FunctorCode AdjustAccidXFunctor::VisitAlignmentReference(AlignmentReference *ali
if (accids.empty()) return FUNCTOR_SIBLINGS;

assert(m_doc);
StaffDef *staffDef = m_doc->GetCurrentScoreDef()->GetStaffDef(alignmentReference->GetN());
ScoreDef *scoreDef = m_doc->GetCorrespondingScore(alignmentReference)->GetScoreDef();
StaffDef *staffDef = scoreDef->GetStaffDef(alignmentReference->GetN());
int staffSize = (staffDef && staffDef->HasScale()) ? staffDef->GetScale() : 100;

std::sort(accids.begin(), accids.end(), AccidSpaceSort());
Expand Down
3 changes: 2 additions & 1 deletion src/adjustdotsfunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "doc.h"
#include "elementpart.h"
#include "score.h"
#include "staff.h"

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -125,7 +126,7 @@ FunctorCode AdjustDotsFunctor::VisitMeasure(Measure *measure)

FunctorCode AdjustDotsFunctor::VisitScore(Score *score)
{
m_staffNs = m_doc->GetCurrentScoreDef()->GetStaffNs();
m_staffNs = score->GetScoreDef()->GetStaffNs();

return FUNCTOR_CONTINUE;
}
Expand Down
3 changes: 2 additions & 1 deletion src/adjustgracexposfunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
//----------------------------------------------------------------------------

#include "doc.h"
#include "score.h"

//----------------------------------------------------------------------------

Expand Down Expand Up @@ -230,7 +231,7 @@ FunctorCode AdjustGraceXPosFunctor::VisitMeasure(Measure *measure)

FunctorCode AdjustGraceXPosFunctor::VisitScore(Score *score)
{
m_staffNs = m_doc->GetCurrentScoreDef()->GetStaffNs();
m_staffNs = score->GetScoreDef()->GetStaffNs();

return FUNCTOR_CONTINUE;
}
Expand Down
3 changes: 2 additions & 1 deletion src/adjustlayersfunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
//----------------------------------------------------------------------------

#include "doc.h"
#include "score.h"
#include "staff.h"

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -148,7 +149,7 @@ FunctorCode AdjustLayersFunctor::VisitMeasure(Measure *measure)

FunctorCode AdjustLayersFunctor::VisitScore(Score *score)
{
m_staffNs = m_doc->GetCurrentScoreDef()->GetStaffNs();
m_staffNs = score->GetScoreDef()->GetStaffNs();

return FUNCTOR_CONTINUE;
}
Expand Down
3 changes: 2 additions & 1 deletion src/adjustxposfunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "doc.h"
#include "multirest.h"
#include "rest.h"
#include "score.h"
#include "staff.h"
#include "system.h"

Expand Down Expand Up @@ -298,7 +299,7 @@ FunctorCode AdjustXPosFunctor::VisitMeasure(Measure *measure)

FunctorCode AdjustXPosFunctor::VisitScore(Score *score)
{
m_staffNs = m_doc->GetCurrentScoreDef()->GetStaffNs();
m_staffNs = score->GetScoreDef()->GetStaffNs();

return FUNCTOR_CONTINUE;
}
Expand Down
Loading