Skip to content

Commit

Permalink
Merge pull request #3522 from rism-digital/revert-3518-develop-curren…
Browse files Browse the repository at this point in the history
…tScoreDef

Revert "Replace handling of current scoreDef in Doc"
  • Loading branch information
lpugin authored Sep 28, 2023
2 parents ae7c305 + d39a097 commit 994d1f2
Show file tree
Hide file tree
Showing 25 changed files with 262 additions and 267 deletions.
62 changes: 26 additions & 36 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
*/
void GenerateFooter();
bool GenerateFooter();

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

/**
* Generate measure numbers from measure attributes
Expand All @@ -121,6 +121,11 @@ 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 @@ -136,31 +141,6 @@ 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 @@ -245,7 +225,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 Object *object, int staffIndex, data_STAFFREL staffPosition) const;
data_MEASUREMENTSIGNED GetStaffDistance(const ClassId classId, int staffIndex, data_STAFFREL staffPosition);

/**
* Prepare the timemap for MIDI and timemap file export.
Expand Down Expand Up @@ -438,6 +418,19 @@ 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 @@ -484,11 +477,6 @@ class Doc : public Object {
*/
void PrepareMeasureIndices();

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

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

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

/**
* 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(const Doc *doc, const StaffAlignment *staffAlignment, const BoundingBox *horizOverlappingBBox);
void CalcDrawingYRel(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(ScoreDef *scoreDef);
void WriteCustomScoreDef();
void AdjustStaffDef(StaffDef *staffDef, Measure *measure);
bool AdjustLabel(Label *label);
///@}
Expand Down
1 change: 1 addition & 0 deletions include/vrv/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,7 @@ 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: 5 additions & 0 deletions include/vrv/page.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ 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: 6 additions & 0 deletions include/vrv/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ 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: 1 addition & 3 deletions src/adjustaccidxfunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
//----------------------------------------------------------------------------

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

return FUNCTOR_CONTINUE;
}
Expand Down
Loading

0 comments on commit 994d1f2

Please sign in to comment.