From 32f7bf8e33ff86b498bcc351081f35cbda1e0db3 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 2 Jun 2023 17:40:08 +0200 Subject: [PATCH 01/36] Add TextLayoutElement class --- Verovio.xcodeproj/project.pbxproj | 22 ++++++++++-- include/vrv/functorinterface.h | 9 +++-- include/vrv/textlayoutelement.h | 59 ++++++++++++++++++++++++++++++ src/functorinterface.cpp | 21 +++++++++++ src/textlayoutelement.cpp | 60 +++++++++++++++++++++++++++++++ 5 files changed, 166 insertions(+), 5 deletions(-) create mode 100644 include/vrv/textlayoutelement.h create mode 100644 src/textlayoutelement.cpp diff --git a/Verovio.xcodeproj/project.pbxproj b/Verovio.xcodeproj/project.pbxproj index add36f2a53c..b2a7a4c9ac6 100644 --- a/Verovio.xcodeproj/project.pbxproj +++ b/Verovio.xcodeproj/project.pbxproj @@ -209,6 +209,12 @@ 4D1D733E1A1D08CD001E08F6 /* glyph.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D1D733D1A1D08CD001E08F6 /* glyph.h */; }; 4D1D73401A1D08DC001E08F6 /* glyph.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D1D733F1A1D08DC001E08F6 /* glyph.cpp */; }; 4D1D73411A1D08DC001E08F6 /* glyph.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D1D733F1A1D08DC001E08F6 /* glyph.cpp */; }; + 4D1EB6A12A2A40B400AF2F98 /* textlayoutelement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D1EB6A02A2A40B400AF2F98 /* textlayoutelement.cpp */; }; + 4D1EB6A22A2A40B400AF2F98 /* textlayoutelement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D1EB6A02A2A40B400AF2F98 /* textlayoutelement.cpp */; }; + 4D1EB6A32A2A40B400AF2F98 /* textlayoutelement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D1EB6A02A2A40B400AF2F98 /* textlayoutelement.cpp */; }; + 4D1EB6A42A2A40B400AF2F98 /* textlayoutelement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D1EB6A02A2A40B400AF2F98 /* textlayoutelement.cpp */; }; + 4D1EB6A62A2A40CB00AF2F98 /* textlayoutelement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D1EB6A52A2A40CB00AF2F98 /* textlayoutelement.h */; }; + 4D1EB6A72A2A40CB00AF2F98 /* textlayoutelement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D1EB6A52A2A40CB00AF2F98 /* textlayoutelement.h */; }; 4D2073F522A3BCE000E0765F /* tuning.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D2073F222A3BCDF00E0765F /* tuning.cpp */; }; 4D2073F622A3BCE000E0765F /* tuning.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D2073F222A3BCDF00E0765F /* tuning.cpp */; }; 4D2073F722A3BCE000E0765F /* tuning.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D2073F222A3BCDF00E0765F /* tuning.cpp */; }; @@ -1761,6 +1767,8 @@ 4D1D733B1A1D0390001E08F6 /* smufl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = smufl.h; path = include/vrv/smufl.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 4D1D733D1A1D08CD001E08F6 /* glyph.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = glyph.h; path = include/vrv/glyph.h; sourceTree = ""; }; 4D1D733F1A1D08DC001E08F6 /* glyph.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = glyph.cpp; path = src/glyph.cpp; sourceTree = ""; }; + 4D1EB6A02A2A40B400AF2F98 /* textlayoutelement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = textlayoutelement.cpp; path = src/textlayoutelement.cpp; sourceTree = ""; }; + 4D1EB6A52A2A40CB00AF2F98 /* textlayoutelement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = textlayoutelement.h; path = include/vrv/textlayoutelement.h; sourceTree = ""; }; 4D2073EF22A3BCB700E0765F /* tabdursym.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tabdursym.h; path = include/vrv/tabdursym.h; sourceTree = ""; }; 4D2073F022A3BCB700E0765F /* tuning.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tuning.h; path = include/vrv/tuning.h; sourceTree = ""; }; 4D2073F122A3BCB700E0765F /* tabgrp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tabgrp.h; path = include/vrv/tabgrp.h; sourceTree = ""; }; @@ -2568,9 +2576,11 @@ name = symbolelements; sourceTree = ""; }; - 4DC12A761F740089000440E9 /* runningelements */ = { + 4DC12A761F740089000440E9 /* textlayoutelements */ = { isa = PBXGroup; children = ( + 4D1EB6A52A2A40CB00AF2F98 /* textlayoutelement.h */, + 4D1EB6A02A2A40B400AF2F98 /* textlayoutelement.cpp */, 4DC12A771F7400B9000440E9 /* runningelement.cpp */, 4DC12A741F73FF92000440E9 /* runningelement.h */, 4DC12A7F1F741110000440E9 /* pgfoot.cpp */, @@ -2582,7 +2592,7 @@ 4DC12A621F73F898000440E9 /* pghead2.cpp */, 4DC12A5C1F73F888000440E9 /* pghead2.h */, ); - name = runningelements; + name = textlayoutelements; sourceTree = ""; }; 4DC34B9E19BC33A0006175CD /* interfaces */ = { @@ -2725,7 +2735,7 @@ 8F086F38188539F00037FD8E /* containers */, 4D3080F9203DA03600BC44F6 /* editorialelements */, 4DA0EABF22BB775F00A7EBEB /* facselements */, - 4DC12A761F740089000440E9 /* runningelements */, + 4DC12A761F740089000440E9 /* textlayoutelements */, 4D95D4F31D717CD600B2B856 /* systemelements */, 4D79641626C151250026288B /* pageelements */, 4DF28A011A754DAA00BA9F7D /* controlelements */, @@ -3330,6 +3340,7 @@ 4D1BE7791C6942930086DC0E /* pugixml.hpp in Headers */, 400FEDD4206FA74A000D3233 /* gracegrp.h in Headers */, 4DF440751D39567A00152B7E /* ending.h in Headers */, + 4D1EB6A62A2A40CB00AF2F98 /* textlayoutelement.h in Headers */, 4DE96E3921C4370E00CB85BE /* bracketspan.h in Headers */, E7E1698B29A8BA3900FFF482 /* adjustgracexposfunctor.h in Headers */, E7265E6E29DC6FD300D11F41 /* castofffunctor.h in Headers */, @@ -3453,6 +3464,7 @@ BB4C4B5222A932D7001F6AF0 /* ftrem.h in Headers */, E7E9C11329B0A1E200CFCE2F /* adjustaccidxfunctor.h in Headers */, 4D88AD0B289673F50006D7DA /* symbol.h in Headers */, + 4D1EB6A72A2A40CB00AF2F98 /* textlayoutelement.h in Headers */, 4D2E759022BC2B71004C51F0 /* course.h in Headers */, BB4C4AA722A932A0001F6AF0 /* bboxdevicecontext.h in Headers */, BB4C4AF822A932BC001F6AF0 /* reg.h in Headers */, @@ -3879,6 +3891,7 @@ 4DEC4DAF21C81F0600D1D273 /* sic.cpp in Sources */, E75EA9FE29CC3A8B003A97A7 /* calcarticfunctor.cpp in Sources */, 4D81351F2322C41800F59C01 /* keyaccid.cpp in Sources */, + 4D1EB6A22A2A40B400AF2F98 /* textlayoutelement.cpp in Sources */, 4D79642226C167100026288B /* pagemilestone.cpp in Sources */, 4DB3D8E31F83D16300B5FC2B /* elementpart.cpp in Sources */, E741AD03299A3D6300854426 /* calcslurdirectionfunctor.cpp in Sources */, @@ -4341,6 +4354,7 @@ 4D4FCD0C1F5455FF0009C455 /* staffgrp.cpp in Sources */, 4DEC4DBE21C828AC00D1D273 /* corr.cpp in Sources */, 4D1BD1B521908D6B000D35B2 /* halfmrpt.cpp in Sources */, + 4D1EB6A12A2A40B400AF2F98 /* textlayoutelement.cpp in Sources */, 4D09D3ED1EA8AD8500A420E6 /* horizontalaligner.cpp in Sources */, 4DEC4DA221C81EB300D1D273 /* rdg.cpp in Sources */, 4D9A9C19199F561200028D93 /* verse.cpp in Sources */, @@ -4438,6 +4452,7 @@ 4D1BE7861C6A40A80086DC0E /* pugixml.cpp in Sources */, E75EA9FF29CC3A8B003A97A7 /* calcarticfunctor.cpp in Sources */, 400FEDD5206FA74D000D3233 /* gracegrp.cpp in Sources */, + 4D1EB6A32A2A40B400AF2F98 /* textlayoutelement.cpp in Sources */, 4DA0EAC522BB779400A7EBEB /* surface.cpp in Sources */, 4DB726C61B8BB0E80040231B /* text.cpp in Sources */, 4D79642326C167100026288B /* pagemilestone.cpp in Sources */, @@ -4718,6 +4733,7 @@ 4DA0EAC622BB779400A7EBEB /* surface.cpp in Sources */, E75EAA0029CC3A8C003A97A7 /* calcarticfunctor.cpp in Sources */, BB4C4ADB22A932BC001F6AF0 /* abbr.cpp in Sources */, + 4D1EB6A42A2A40B400AF2F98 /* textlayoutelement.cpp in Sources */, 4D79642426C167100026288B /* pagemilestone.cpp in Sources */, E741AD05299A3D6500854426 /* calcslurdirectionfunctor.cpp in Sources */, BB4C4A9322A9328F001F6AF0 /* doc.cpp in Sources */, diff --git a/include/vrv/functorinterface.h b/include/vrv/functorinterface.h index 5d4a1412626..5ecf183e15f 100644 --- a/include/vrv/functorinterface.h +++ b/include/vrv/functorinterface.h @@ -130,6 +130,7 @@ class TabGrp; class Tempo; class Text; class TextElement; +class TextLayoutElement; class Tie; class TimestampAligner; class TimestampAttr; @@ -223,7 +224,7 @@ class FunctorInterface { ///@} /** - * @name Visit running elements + * @name Visit text layout elements */ ///@{ virtual FunctorCode VisitRunningElement(RunningElement *runningElement); @@ -236,6 +237,8 @@ class FunctorInterface { virtual FunctorCode VisitPgHeadEnd(PgHead *pgHead); virtual FunctorCode VisitPgHead2(PgHead2 *pgHead2); virtual FunctorCode VisitPgHead2End(PgHead2 *pgHead2); + virtual FunctorCode VisitTextLayoutElement(TextLayoutElement *textLayoutElement); + virtual FunctorCode VisitTextLayoutElementEnd(TextLayoutElement *textLayoutElement); ///@} /** @@ -578,7 +581,7 @@ class ConstFunctorInterface { ///@} /** - * @name Visit running elements + * @name Visit text layout elements */ ///@{ virtual FunctorCode VisitRunningElement(const RunningElement *runningElement); @@ -591,6 +594,8 @@ class ConstFunctorInterface { virtual FunctorCode VisitPgHeadEnd(const PgHead *pgHead); virtual FunctorCode VisitPgHead2(const PgHead2 *pgHead2); virtual FunctorCode VisitPgHead2End(const PgHead2 *pgHead2); + virtual FunctorCode VisitTextLayoutElement(const TextLayoutElement *textLayoutElement); + virtual FunctorCode VisitTextLayoutElementEnd(const TextLayoutElement *textLayoutElement); ///@} /** diff --git a/include/vrv/textlayoutelement.h b/include/vrv/textlayoutelement.h new file mode 100644 index 00000000000..dd27d5d31f0 --- /dev/null +++ b/include/vrv/textlayoutelement.h @@ -0,0 +1,59 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: textlayoutelement.h +// Author: Laurent Pugin +// Created: 2023 +// Copyright (c) Authors and others. All rights reserved. +///////////////////////////////////////////////////////////////////////////// + +#ifndef __VRV_TEXTLAYOUTELEMENT_H__ +#define __VRV_TEXTLAYOUTELEMENT_H__ + +#include "object.h" + +namespace vrv { + +//---------------------------------------------------------------------------- +// TextLayoutElement +//---------------------------------------------------------------------------- + +/** + * This class represents a text element featuring horizontal and vertical layout. + * It is not an abstract class but should not be instanciated directly. + */ +class TextLayoutElement : public Object { +public: + /** + * @name Constructors, destructors, and other standard methods + * Reset method resets all attribute classes + */ + ///@{ + TextLayoutElement(); + virtual ~TextLayoutElement(); + void Reset() override; + ///@} + + //----------// + // Functors // + //----------// + + /** + * Interface for class functor visitation + */ + ///@{ + FunctorCode Accept(Functor &functor) override; + FunctorCode Accept(ConstFunctor &functor) const override; + FunctorCode AcceptEnd(Functor &functor) override; + FunctorCode AcceptEnd(ConstFunctor &functor) const override; + ///@} + +private: + // +public: + // +private: + // +}; + +} // namespace vrv + +#endif diff --git a/src/functorinterface.cpp b/src/functorinterface.cpp index c81cbf8bb70..50f348c3e17 100644 --- a/src/functorinterface.cpp +++ b/src/functorinterface.cpp @@ -110,6 +110,7 @@ #include "tabgrp.h" #include "tempo.h" #include "text.h" +#include "textlayoutelement.h" #include "tie.h" #include "timestamp.h" #include "trill.h" @@ -384,6 +385,16 @@ FunctorCode FunctorInterface::VisitPgFoot2End(PgFoot2 *pgFoot2) return this->VisitRunningElementEnd(pgFoot2); } +FunctorCode FunctorInterface::VisitTextLayoutElement(TextLayoutElement *textLayoutElement) +{ + return this->VisitObject(textLayoutElement); +} + +FunctorCode FunctorInterface::VisitTextLayoutElementEnd(TextLayoutElement *textLayoutElement) +{ + return this->VisitObjectEnd(textLayoutElement); +} + FunctorCode FunctorInterface::VisitEnding(Ending *ending) { return this->VisitSystemElement(ending); @@ -1658,6 +1669,16 @@ FunctorCode ConstFunctorInterface::VisitPgFoot2End(const PgFoot2 *pgFoot2) return this->VisitRunningElementEnd(pgFoot2); } +FunctorCode ConstFunctorInterface::VisitTextLayoutElement(const TextLayoutElement *textLayoutElement) +{ + return this->VisitObject(textLayoutElement); +} + +FunctorCode ConstFunctorInterface::VisitTextLayoutElementEnd(const TextLayoutElement *textLayoutElement) +{ + return this->VisitObjectEnd(textLayoutElement); +} + FunctorCode ConstFunctorInterface::VisitEnding(const Ending *ending) { return this->VisitSystemElement(ending); diff --git a/src/textlayoutelement.cpp b/src/textlayoutelement.cpp new file mode 100644 index 00000000000..b3aabbf2e56 --- /dev/null +++ b/src/textlayoutelement.cpp @@ -0,0 +1,60 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: textlayoutelement.cpp +// Author: Laurent Pugin +// Created: 2023 +// Copyright (c) Authors and others. All rights reserved. +///////////////////////////////////////////////////////////////////////////// + +#include "textlayoutelement.h" + +//---------------------------------------------------------------------------- + +#include + +//---------------------------------------------------------------------------- + +#include "doc.h" +#include "functor.h" + +namespace vrv { + +//---------------------------------------------------------------------------- +// TextLayoutElement +//---------------------------------------------------------------------------- + +TextLayoutElement::TextLayoutElement() : Object() +{ + this->Reset(); +} + +TextLayoutElement::~TextLayoutElement() {} + +void TextLayoutElement::Reset() +{ +} + +//---------------------------------------------------------------------------- +// Functor methods +//---------------------------------------------------------------------------- + +FunctorCode TextLayoutElement::Accept(Functor &functor) +{ + return functor.VisitTextLayoutElement(this); +} + +FunctorCode TextLayoutElement::Accept(ConstFunctor &functor) const +{ + return functor.VisitTextLayoutElement(this); +} + +FunctorCode TextLayoutElement::AcceptEnd(Functor &functor) +{ + return functor.VisitTextLayoutElementEnd(this); +} + +FunctorCode TextLayoutElement::AcceptEnd(ConstFunctor &functor) const +{ + return functor.VisitTextLayoutElementEnd(this); +} + +} // namespace vrv From e9ffcb3e52b1e49ae9b57db5dae59db8c9fe242d Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 2 Jun 2023 17:45:52 +0200 Subject: [PATCH 02/36] Make TextLayoutElement inherit from ObjectListInterface and AttType --- include/vrv/textlayoutelement.h | 9 +++++---- src/textlayoutelement.cpp | 5 ++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/vrv/textlayoutelement.h b/include/vrv/textlayoutelement.h index dd27d5d31f0..b6a2337f5e3 100644 --- a/include/vrv/textlayoutelement.h +++ b/include/vrv/textlayoutelement.h @@ -5,9 +5,10 @@ // Copyright (c) Authors and others. All rights reserved. ///////////////////////////////////////////////////////////////////////////// -#ifndef __VRV_TEXTLAYOUTELEMENT_H__ -#define __VRV_TEXTLAYOUTELEMENT_H__ +#ifndef __VRV_TEXT_LAYOUT_ELEMENT_H__ +#define __VRV_TEXT_LAYOUT_ELEMENT_H__ +#include "atts_shared.h" #include "object.h" namespace vrv { @@ -20,14 +21,14 @@ namespace vrv { * This class represents a text element featuring horizontal and vertical layout. * It is not an abstract class but should not be instanciated directly. */ -class TextLayoutElement : public Object { +class TextLayoutElement : public Object, public ObjectListInterface, public AttTyped { public: /** * @name Constructors, destructors, and other standard methods * Reset method resets all attribute classes */ ///@{ - TextLayoutElement(); + TextLayoutElement(ClassId classId, const std::string &classIdStr); virtual ~TextLayoutElement(); void Reset() override; ///@} diff --git a/src/textlayoutelement.cpp b/src/textlayoutelement.cpp index b3aabbf2e56..b23e7fa6c07 100644 --- a/src/textlayoutelement.cpp +++ b/src/textlayoutelement.cpp @@ -22,8 +22,10 @@ namespace vrv { // TextLayoutElement //---------------------------------------------------------------------------- -TextLayoutElement::TextLayoutElement() : Object() +TextLayoutElement::TextLayoutElement(ClassId classId, const std::string &classIdStr) : Object(classId, classIdStr), ObjectListInterface(), AttTyped() { + this->RegisterAttClass(ATT_TYPED); + this->Reset(); } @@ -31,6 +33,7 @@ TextLayoutElement::~TextLayoutElement() {} void TextLayoutElement::Reset() { + } //---------------------------------------------------------------------------- From c88241a656eb9674676a0dbbec58a3e400006dde Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 2 Jun 2023 18:21:02 +0200 Subject: [PATCH 03/36] Make RunningElement inherit from TextLayoutElement --- include/vrv/iomei.h | 3 +++ include/vrv/runningelement.h | 4 ++-- src/alignfunctor.cpp | 2 ++ src/functorinterface.cpp | 8 ++++---- src/iomei.cpp | 23 +++++++++++++++++++---- src/preparedatafunctor.cpp | 2 ++ src/runningelement.cpp | 14 ++++---------- src/savefunctor.cpp | 4 ++-- src/textlayoutelement.cpp | 8 +++++--- 9 files changed, 43 insertions(+), 25 deletions(-) diff --git a/include/vrv/iomei.h b/include/vrv/iomei.h index 0bfb7b64c95..d86b4735780 100644 --- a/include/vrv/iomei.h +++ b/include/vrv/iomei.h @@ -157,6 +157,7 @@ class Tempo; class Text; class TextDirInterface; class TextElement; +class TextLayoutElement; class Tie; class TimePointInterface; class TimeSpanningInterface; @@ -515,6 +516,7 @@ class MEIOutput : public Output { void WriteControlElement(pugi::xml_node element, ControlElement *object); void WriteEditorialElement(pugi::xml_node element, EditorialElement *object); void WriteLayerElement(pugi::xml_node element, LayerElement *object); + void WriteTextLayoutElement(pugi::xml_node element, TextLayoutElement *object); void WriteRunningElement(pugi::xml_node element, RunningElement *object); void WriteScoreDefElement(pugi::xml_node element, ScoreDefElement *object); void WriteSystemElement(pugi::xml_node element, SystemElement *object); @@ -812,6 +814,7 @@ class MEIInput : public Input { bool ReadControlElement(pugi::xml_node element, ControlElement *object); bool ReadEditorialElement(pugi::xml_node element, EditorialElement *object); bool ReadLayerElement(pugi::xml_node element, LayerElement *object); + bool ReadTextLayoutElement(pugi::xml_node element, TextLayoutElement *object); bool ReadRunningElement(pugi::xml_node element, RunningElement *object); bool ReadScoreDefElement(pugi::xml_node element, ScoreDefElement *object); bool ReadSystemElement(pugi::xml_node element, SystemElement *object); diff --git a/include/vrv/runningelement.h b/include/vrv/runningelement.h index 20f03a85ae1..d365eda4b32 100644 --- a/include/vrv/runningelement.h +++ b/include/vrv/runningelement.h @@ -9,7 +9,7 @@ #define __VRV_RUNNING_ELEMENT_H__ #include "atts_shared.h" -#include "object.h" +#include "textlayoutelement.h" namespace vrv { @@ -25,7 +25,7 @@ class TextElement; * This class represents running elements (headers and footers). * It is not an abstract class but should not be instanciated directly. */ -class RunningElement : public Object, public ObjectListInterface, public AttHorizontalAlign, public AttTyped { +class RunningElement : public TextLayoutElement, public AttHorizontalAlign { public: /** * @name Constructors, destructors, reset methods diff --git a/src/alignfunctor.cpp b/src/alignfunctor.cpp index 251227ba266..5d3fcc29f36 100644 --- a/src/alignfunctor.cpp +++ b/src/alignfunctor.cpp @@ -549,6 +549,8 @@ FunctorCode AlignVerticallyFunctor::VisitRend(Rend *rend) FunctorCode AlignVerticallyFunctor::VisitRunningElement(RunningElement *runningElement) { + this->VisitTextLayoutElement(runningElement); + m_pageWidth = runningElement->GetWidth(); return FUNCTOR_CONTINUE; diff --git a/src/functorinterface.cpp b/src/functorinterface.cpp index 50f348c3e17..abe526f0d7e 100644 --- a/src/functorinterface.cpp +++ b/src/functorinterface.cpp @@ -337,12 +337,12 @@ FunctorCode FunctorInterface::VisitEditorialElementEnd(EditorialElement *editori FunctorCode FunctorInterface::VisitRunningElement(RunningElement *runningElement) { - return this->VisitObject(runningElement); + return this->VisitTextLayoutElement(runningElement); } FunctorCode FunctorInterface::VisitRunningElementEnd(RunningElement *runningElement) { - return this->VisitObjectEnd(runningElement); + return this->VisitTextLayoutElementEnd(runningElement); } FunctorCode FunctorInterface::VisitPgHead(PgHead *pgHead) @@ -1621,12 +1621,12 @@ FunctorCode ConstFunctorInterface::VisitEditorialElementEnd(const EditorialEleme FunctorCode ConstFunctorInterface::VisitRunningElement(const RunningElement *runningElement) { - return this->VisitObject(runningElement); + return this->VisitTextLayoutElement(runningElement); } FunctorCode ConstFunctorInterface::VisitRunningElementEnd(const RunningElement *runningElement) { - return this->VisitObjectEnd(runningElement); + return this->VisitTextLayoutElementEnd(runningElement); } FunctorCode ConstFunctorInterface::VisitPgHead(const PgHead *pgHead) diff --git a/src/iomei.cpp b/src/iomei.cpp index 974ba3bcd3c..386069b4a18 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -140,6 +140,7 @@ #include "tabgrp.h" #include "tempo.h" #include "text.h" +#include "textlayoutelement.h" #include "tie.h" #include "trill.h" #include "tuning.h" @@ -1715,13 +1716,20 @@ void MEIOutput::WriteScoreDef(pugi::xml_node currentNode, ScoreDef *scoreDef) scoreDef->WriteTuning(currentNode); } +void MEIOutput::WriteTextLayoutElement(pugi::xml_node currentNode, TextLayoutElement *textLayoutElement) +{ + assert(textLayoutElement); + + this->WriteXmlId(currentNode, textLayoutElement); + textLayoutElement->WriteTyped(currentNode); +} + void MEIOutput::WriteRunningElement(pugi::xml_node currentNode, RunningElement *runningElement) { assert(runningElement); - this->WriteXmlId(currentNode, runningElement); + this->WriteTextLayoutElement(currentNode, runningElement); runningElement->WriteHorizontalAlign(currentNode); - runningElement->WriteTyped(currentNode); } void MEIOutput::WriteGrpSym(pugi::xml_node currentNode, GrpSym *grpSym) @@ -4864,15 +4872,22 @@ bool MEIInput::ReadStaffGrpChildren(Object *parent, pugi::xml_node parentNode) return success; } -bool MEIInput::ReadRunningElement(pugi::xml_node element, RunningElement *object) +bool MEIInput::ReadTextLayoutElement(pugi::xml_node element, TextLayoutElement *object) { this->SetMeiID(element, object); - object->ReadHorizontalAlign(element); object->ReadTyped(element); return true; } +bool MEIInput::ReadRunningElement(pugi::xml_node element, RunningElement *object) +{ + this->ReadTextLayoutElement(element, object); + object->ReadHorizontalAlign(element); + + return true; +} + bool MEIInput::ReadGrpSym(Object *parent, pugi::xml_node grpSym) { GrpSym *vrvGrpSym = new GrpSym(); diff --git a/src/preparedatafunctor.cpp b/src/preparedatafunctor.cpp index bc2f920b99e..c45483b0f27 100644 --- a/src/preparedatafunctor.cpp +++ b/src/preparedatafunctor.cpp @@ -83,6 +83,8 @@ FunctorCode PrepareDataInitializationFunctor::VisitKeySig(KeySig *keySig) FunctorCode PrepareDataInitializationFunctor::VisitRunningElement(RunningElement *runningElement) { + this->VisitTextLayoutElement(runningElement); + runningElement->ResetCells(); runningElement->ResetDrawingScaling(); diff --git a/src/runningelement.cpp b/src/runningelement.cpp index d07d397cb79..f3626036dad 100644 --- a/src/runningelement.cpp +++ b/src/runningelement.cpp @@ -31,29 +31,24 @@ namespace vrv { // RunningElement //---------------------------------------------------------------------------- -RunningElement::RunningElement() - : Object(RUNNING_ELEMENT, "re"), ObjectListInterface(), AttHorizontalAlign(), AttTyped() +RunningElement::RunningElement() : TextLayoutElement(RUNNING_ELEMENT, "re"), AttHorizontalAlign() { this->RegisterAttClass(ATT_HORIZONTALALIGN); - this->RegisterAttClass(ATT_TYPED); this->Reset(); } -RunningElement::RunningElement(ClassId classId) - : Object(classId, "re"), ObjectListInterface(), AttHorizontalAlign(), AttTyped() +RunningElement::RunningElement(ClassId classId) : TextLayoutElement(classId, "re"), AttHorizontalAlign() { this->RegisterAttClass(ATT_HORIZONTALALIGN); - this->RegisterAttClass(ATT_TYPED); this->Reset(); } RunningElement::RunningElement(ClassId classId, const std::string &classIdStr) - : Object(classId, classIdStr), AttHorizontalAlign(), AttTyped() + : TextLayoutElement(classId, classIdStr), AttHorizontalAlign() { this->RegisterAttClass(ATT_HORIZONTALALIGN); - this->RegisterAttClass(ATT_TYPED); this->Reset(); } @@ -62,9 +57,8 @@ RunningElement::~RunningElement() {} void RunningElement::Reset() { - Object::Reset(); + TextLayoutElement::Reset(); this->ResetHorizontalAlign(); - this->ResetTyped(); m_isGenerated = false; diff --git a/src/savefunctor.cpp b/src/savefunctor.cpp index 641845a1269..8a1b1e549c6 100644 --- a/src/savefunctor.cpp +++ b/src/savefunctor.cpp @@ -135,7 +135,7 @@ FunctorCode SaveFunctor::VisitRunningElement(RunningElement *runningElement) return FUNCTOR_SIBLINGS; } else { - return this->VisitObject(runningElement); + return this->VisitTextLayoutElement(runningElement); } } @@ -145,7 +145,7 @@ FunctorCode SaveFunctor::VisitRunningElementEnd(RunningElement *runningElement) return FUNCTOR_SIBLINGS; } else { - return this->VisitObjectEnd(runningElement); + return this->VisitTextLayoutElementEnd(runningElement); } } diff --git a/src/textlayoutelement.cpp b/src/textlayoutelement.cpp index b23e7fa6c07..349f824d139 100644 --- a/src/textlayoutelement.cpp +++ b/src/textlayoutelement.cpp @@ -22,10 +22,11 @@ namespace vrv { // TextLayoutElement //---------------------------------------------------------------------------- -TextLayoutElement::TextLayoutElement(ClassId classId, const std::string &classIdStr) : Object(classId, classIdStr), ObjectListInterface(), AttTyped() +TextLayoutElement::TextLayoutElement(ClassId classId, const std::string &classIdStr) + : Object(classId, classIdStr), ObjectListInterface(), AttTyped() { this->RegisterAttClass(ATT_TYPED); - + this->Reset(); } @@ -33,7 +34,8 @@ TextLayoutElement::~TextLayoutElement() {} void TextLayoutElement::Reset() { - + Object::Reset(); + this->ResetTyped(); } //---------------------------------------------------------------------------- From 8a707475deee4409b31b6e1235402837a8de8610 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 2 Jun 2023 18:21:50 +0200 Subject: [PATCH 04/36] Re-order files in xcode --- Verovio.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Verovio.xcodeproj/project.pbxproj b/Verovio.xcodeproj/project.pbxproj index b2a7a4c9ac6..1b6c95b0aa5 100644 --- a/Verovio.xcodeproj/project.pbxproj +++ b/Verovio.xcodeproj/project.pbxproj @@ -2579,8 +2579,6 @@ 4DC12A761F740089000440E9 /* textlayoutelements */ = { isa = PBXGroup; children = ( - 4D1EB6A52A2A40CB00AF2F98 /* textlayoutelement.h */, - 4D1EB6A02A2A40B400AF2F98 /* textlayoutelement.cpp */, 4DC12A771F7400B9000440E9 /* runningelement.cpp */, 4DC12A741F73FF92000440E9 /* runningelement.h */, 4DC12A7F1F741110000440E9 /* pgfoot.cpp */, @@ -2591,6 +2589,8 @@ 4DC12A561F716E1C000440E9 /* pghead.h */, 4DC12A621F73F898000440E9 /* pghead2.cpp */, 4DC12A5C1F73F888000440E9 /* pghead2.h */, + 4D1EB6A02A2A40B400AF2F98 /* textlayoutelement.cpp */, + 4D1EB6A52A2A40CB00AF2F98 /* textlayoutelement.h */, ); name = textlayoutelements; sourceTree = ""; From 744fd78dc9d3d0b5a3e6d82ab516caefbdd3405f Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 2 Jun 2023 18:34:57 +0200 Subject: [PATCH 05/36] Move RunningElement cells to TextLayoutElement --- include/vrv/runningelement.h | 68 ------------ include/vrv/textlayoutelement.h | 68 +++++++++++- src/runningelement.cpp | 177 ------------------------------- src/textlayoutelement.cpp | 180 ++++++++++++++++++++++++++++++++ 4 files changed, 247 insertions(+), 246 deletions(-) diff --git a/include/vrv/runningelement.h b/include/vrv/runningelement.h index d365eda4b32..665a9b68ae5 100644 --- a/include/vrv/runningelement.h +++ b/include/vrv/runningelement.h @@ -45,13 +45,6 @@ class RunningElement : public TextLayoutElement, public AttHorizontalAlign { */ Object *Clone() const override { return NULL; } - /** - * @name Methods for adding allowed content - */ - ///@{ - bool IsSupportedChild(Object *object) override; - ///@} - /** * @name Setter and getter of the generated flag */ @@ -87,49 +80,6 @@ class RunningElement : public TextLayoutElement, public AttHorizontalAlign { virtual void SetDrawingYRel(int drawingYRel); ///@} - /** - * @name Setter and getter for the text element cells - */ - ///@{ - void ResetCells(); - void AppendTextToCell(int index, TextElement *text); - ///@} - - /** - * @name Setter and getter for the drawing scaling - */ - ///@{ - void ResetDrawingScaling(); - ///@} - - /** - * @name Get the size of row, cols or cells - */ - ///@{ - /** Height including margins */ - virtual int GetTotalHeight(const Doc *doc) const = 0; - /** Content height */ - int GetContentHeight() const; - /** Row from 0 to 2 */ - int GetRowHeight(int row) const; - /** Col from 0 to 2 */ - int GetColHeight(int col) const; - /** Row from 0 to 8 */ - int GetCellHeight(int cell) const; - ///@} - - /** - * Scale the content of the running element. - * Currently unused. - */ - bool AdjustDrawingScaling(int width); - - /** - * Adjust the postition of the content of the running element. - * First adjust the content of each cell, and then the cells themselves. - */ - bool AdjustRunningElementYPos(); - /** * Set the current page number by looking for a # element. */ @@ -164,13 +114,6 @@ class RunningElement : public TextLayoutElement, public AttHorizontalAlign { FunctorCode AcceptEnd(ConstFunctor &functor) const override; ///@} -protected: - /** - * Filter the list for a specific class. - * Keep only the top and - */ - void FilterList(ListOfConstObjects &childList) const override; - private: // @@ -187,21 +130,10 @@ class RunningElement : public TextLayoutElement, public AttHorizontalAlign { */ int m_drawingYRel; - /** - * Stored the top or with the 9 possible positioning combinations, from - * top-left to bottom-right (going left to right first) - */ - ArrayOfTextElements m_cells[9]; - /** * Flag indicating whether or not the element was generated */ bool m_isGenerated; - - /** - * - */ - int m_drawingScalingPercent[3]; }; } // namespace vrv diff --git a/include/vrv/textlayoutelement.h b/include/vrv/textlayoutelement.h index b6a2337f5e3..de4d8266748 100644 --- a/include/vrv/textlayoutelement.h +++ b/include/vrv/textlayoutelement.h @@ -33,6 +33,56 @@ class TextLayoutElement : public Object, public ObjectListInterface, public AttT void Reset() override; ///@} + /** + * @name Methods for adding allowed content + */ + ///@{ + bool IsSupportedChild(Object *object) override; + ///@} + + /** + * @name Setter and getter for the text element cells + */ + ///@{ + void ResetCells(); + void AppendTextToCell(int index, TextElement *text); + ///@} + + /** + * @name Setter and getter for the drawing scaling + */ + ///@{ + void ResetDrawingScaling(); + ///@} + + /** + * Scale the content of the running element. + * Currently unused. + */ + bool AdjustDrawingScaling(int width); + + /** + * Adjust the postition of the content of the running element. + * First adjust the content of each cell, and then the cells themselves. + */ + bool AdjustRunningElementYPos(); + + /** + * @name Get the size of row, cols or cells + */ + ///@{ + /** Height including margins */ + virtual int GetTotalHeight(const Doc *doc) const = 0; + /** Content height */ + int GetContentHeight() const; + /** Row from 0 to 2 */ + int GetRowHeight(int row) const; + /** Col from 0 to 2 */ + int GetColHeight(int col) const; + /** Row from 0 to 8 */ + int GetCellHeight(int cell) const; + ///@} + //----------// // Functors // //----------// @@ -47,12 +97,28 @@ class TextLayoutElement : public Object, public ObjectListInterface, public AttT FunctorCode AcceptEnd(ConstFunctor &functor) const override; ///@} +protected: + /** + * Filter the list for a specific class. + * Keep only the top and + */ + void FilterList(ListOfConstObjects &childList) const override; + private: // public: // private: - // + /** + * Stored the top or with the 9 possible positioning combinations, from + * top-left to bottom-right (going left to right first) + */ + ArrayOfTextElements m_cells[9]; + + /** + * + */ + int m_drawingScalingPercent[3]; }; } // namespace vrv diff --git a/src/runningelement.cpp b/src/runningelement.cpp index f3626036dad..02a45537883 100644 --- a/src/runningelement.cpp +++ b/src/runningelement.cpp @@ -68,41 +68,6 @@ void RunningElement::Reset() this->ResetDrawingScaling(); } -bool RunningElement::IsSupportedChild(Object *child) -{ - if (child->IsTextElement()) { - assert(dynamic_cast(child)); - } - else if (child->IsEditorialElement()) { - assert(dynamic_cast(child)); - } - else { - return false; - } - return true; -} - -void RunningElement::FilterList(ListOfConstObjects &childList) const -{ - ListOfConstObjects::iterator iter = childList.begin(); - - while (iter != childList.end()) { - // remove nested rend elements - if ((*iter)->Is(REND)) { - if ((*iter)->GetFirstAncestor(REND)) { - iter = childList.erase(iter); - continue; - } - } - // Also remove anything that is not a fig - else if (!(*iter)->Is(FIG)) { - iter = childList.erase(iter); - continue; - } - ++iter; - } -} - int RunningElement::GetDrawingX() const { if (!m_drawingPage) return 0; @@ -158,148 +123,6 @@ void RunningElement::SetDrawingPage(Page *page) } } -void RunningElement::ResetCells() -{ - for (int i = 0; i < 9; ++i) { - m_cells[i].clear(); - } -} - -void RunningElement::AppendTextToCell(int index, TextElement *text) -{ - assert((index >= 0) && (index < 9)); - m_cells[index].push_back(text); -} - -void RunningElement::ResetDrawingScaling() -{ - for (int i = 0; i < 3; ++i) { - m_drawingScalingPercent[i] = 100; - } -} - -int RunningElement::GetContentHeight() const -{ - int height = 0; - for (int i = 0; i < 3; ++i) { - height += this->GetRowHeight(i); - } - return height; -} - -int RunningElement::GetRowHeight(int row) const -{ - assert((row >= 0) && (row < 3)); - - int height = 0; - for (int i = 0; i < 3; ++i) { - height = std::max(height, this->GetCellHeight(row * 3 + i)); - } - return height; -} - -int RunningElement::GetColHeight(int col) const -{ - assert((col >= 0) && (col < 3)); - - int height = 0; - for (int i = 0; i < 3; ++i) { - height += this->GetCellHeight(i * 3 + col); - } - return height; -} - -int RunningElement::GetCellHeight(int cell) const -{ - assert((cell >= 0) && (cell < 9)); - - int columnHeight = 0; - const ArrayOfTextElements *textElements = &m_cells[cell]; - ArrayOfTextElements::const_iterator iter; - for (iter = textElements->begin(); iter != textElements->end(); ++iter) { - if ((*iter)->HasContentBB()) { - columnHeight += (*iter)->GetContentY2() - (*iter)->GetContentY1(); - } - } - return columnHeight; -} - -bool RunningElement::AdjustDrawingScaling(int width) -{ - bool scale = false; - // For each row - for (int i = 0; i < 3; ++i) { - int rowWidth = 0; - // For each column - for (int j = 0; j < 3; ++j) { - ArrayOfTextElements *textElements = &m_cells[i * 3 + j]; - int columnWidth = 0; - // For each object - for (TextElement *element : *textElements) { - if (element->HasContentBB()) { - int iterWidth = element->GetContentX2() - element->GetContentX1(); - columnWidth = std::max(columnWidth, iterWidth); - } - } - rowWidth += columnWidth; - } - if (rowWidth && (rowWidth > width)) { - m_drawingScalingPercent[i] = width * 100 / rowWidth; - scale = true; - } - } - return scale; -} - -bool RunningElement::AdjustRunningElementYPos() -{ - // First adjust the content of each cell - for (int i = 0; i < 9; ++i) { - int cumulatedYRel = 0; - ArrayOfTextElements *textElements = &m_cells[i]; - // For each object - for (TextElement *element : *textElements) { - if (!element->HasContentBB()) { - continue; - } - int yShift = element->GetContentY2(); - element->SetDrawingYRel(cumulatedYRel - yShift); - cumulatedYRel += (element->GetContentY1() - element->GetContentY2()); - } - } - - int rowYRel = 0; - // For each row - for (int i = 0; i < 3; ++i) { - int currentRowHeigt = this->GetRowHeight(i); - // For each column - for (int j = 0; j < 3; ++j) { - int cell = i * 3 + j; - int colYShift = 0; - // middle row - it needs to be middle-aligned so calculate the colYShift accordingly - if (i == 1) { - colYShift = (currentRowHeigt - this->GetCellHeight(cell)) / 2; - } - // bottom row - it needs to be bottom-aligned so calculate the colYShift accordingly - else if (i == 2) { - colYShift = (currentRowHeigt - this->GetCellHeight(cell)); - } - - ArrayOfTextElements *textElements = &m_cells[cell]; - // For each object - adjust the yRel according to the rowYRel and the colYshift - for (TextElement *element : *textElements) { - if (!element->HasContentBB()) { - continue; - } - element->SetDrawingYRel(element->GetDrawingYRel() + rowYRel - colYShift); - } - } - rowYRel -= currentRowHeigt; - } - - return true; -} - int RunningElement::GetAlignmentPos(data_HORIZONTALALIGNMENT h, data_VERTICALALIGNMENT v) const { int pos = 0; diff --git a/src/textlayoutelement.cpp b/src/textlayoutelement.cpp index 349f824d139..6585e480c69 100644 --- a/src/textlayoutelement.cpp +++ b/src/textlayoutelement.cpp @@ -14,7 +14,10 @@ //---------------------------------------------------------------------------- #include "doc.h" +#include "editorial.h" +#include "fig.h" #include "functor.h" +#include "rend.h" namespace vrv { @@ -38,6 +41,183 @@ void TextLayoutElement::Reset() this->ResetTyped(); } +bool TextLayoutElement::IsSupportedChild(Object *child) +{ + if (child->IsTextElement()) { + assert(dynamic_cast(child)); + } + else if (child->IsEditorialElement()) { + assert(dynamic_cast(child)); + } + else { + return false; + } + return true; +} + +void TextLayoutElement::FilterList(ListOfConstObjects &childList) const +{ + ListOfConstObjects::iterator iter = childList.begin(); + + while (iter != childList.end()) { + // remove nested rend elements + if ((*iter)->Is(REND)) { + if ((*iter)->GetFirstAncestor(REND)) { + iter = childList.erase(iter); + continue; + } + } + // Also remove anything that is not a fig + else if (!(*iter)->Is(FIG)) { + iter = childList.erase(iter); + continue; + } + ++iter; + } +} + +void TextLayoutElement::ResetCells() +{ + for (int i = 0; i < 9; ++i) { + m_cells[i].clear(); + } +} + +void TextLayoutElement::AppendTextToCell(int index, TextElement *text) +{ + assert((index >= 0) && (index < 9)); + m_cells[index].push_back(text); +} + +int TextLayoutElement::GetContentHeight() const +{ + int height = 0; + for (int i = 0; i < 3; ++i) { + height += this->GetRowHeight(i); + } + return height; +} + +int TextLayoutElement::GetRowHeight(int row) const +{ + assert((row >= 0) && (row < 3)); + + int height = 0; + for (int i = 0; i < 3; ++i) { + height = std::max(height, this->GetCellHeight(row * 3 + i)); + } + return height; +} + +int TextLayoutElement::GetColHeight(int col) const +{ + assert((col >= 0) && (col < 3)); + + int height = 0; + for (int i = 0; i < 3; ++i) { + height += this->GetCellHeight(i * 3 + col); + } + return height; +} + +int TextLayoutElement::GetCellHeight(int cell) const +{ + assert((cell >= 0) && (cell < 9)); + + int columnHeight = 0; + const ArrayOfTextElements *textElements = &m_cells[cell]; + ArrayOfTextElements::const_iterator iter; + for (iter = textElements->begin(); iter != textElements->end(); ++iter) { + if ((*iter)->HasContentBB()) { + columnHeight += (*iter)->GetContentY2() - (*iter)->GetContentY1(); + } + } + return columnHeight; +} + +bool TextLayoutElement::AdjustDrawingScaling(int width) +{ + bool scale = false; + // For each row + for (int i = 0; i < 3; ++i) { + int rowWidth = 0; + // For each column + for (int j = 0; j < 3; ++j) { + ArrayOfTextElements *textElements = &m_cells[i * 3 + j]; + int columnWidth = 0; + // For each object + for (TextElement *element : *textElements) { + if (element->HasContentBB()) { + int iterWidth = element->GetContentX2() - element->GetContentX1(); + columnWidth = std::max(columnWidth, iterWidth); + } + } + rowWidth += columnWidth; + } + if (rowWidth && (rowWidth > width)) { + m_drawingScalingPercent[i] = width * 100 / rowWidth; + scale = true; + } + } + return scale; +} + +void TextLayoutElement::ResetDrawingScaling() +{ + for (int i = 0; i < 3; ++i) { + m_drawingScalingPercent[i] = 100; + } +} + +bool TextLayoutElement::AdjustRunningElementYPos() +{ + // First adjust the content of each cell + for (int i = 0; i < 9; ++i) { + int cumulatedYRel = 0; + ArrayOfTextElements *textElements = &m_cells[i]; + // For each object + for (TextElement *element : *textElements) { + if (!element->HasContentBB()) { + continue; + } + int yShift = element->GetContentY2(); + element->SetDrawingYRel(cumulatedYRel - yShift); + cumulatedYRel += (element->GetContentY1() - element->GetContentY2()); + } + } + + int rowYRel = 0; + // For each row + for (int i = 0; i < 3; ++i) { + int currentRowHeigt = this->GetRowHeight(i); + // For each column + for (int j = 0; j < 3; ++j) { + int cell = i * 3 + j; + int colYShift = 0; + // middle row - it needs to be middle-aligned so calculate the colYShift accordingly + if (i == 1) { + colYShift = (currentRowHeigt - this->GetCellHeight(cell)) / 2; + } + // bottom row - it needs to be bottom-aligned so calculate the colYShift accordingly + else if (i == 2) { + colYShift = (currentRowHeigt - this->GetCellHeight(cell)); + } + + ArrayOfTextElements *textElements = &m_cells[cell]; + // For each object - adjust the yRel according to the rowYRel and the colYshift + for (TextElement *element : *textElements) { + if (!element->HasContentBB()) { + continue; + } + element->SetDrawingYRel(element->GetDrawingYRel() + rowYRel - colYShift); + } + } + rowYRel -= currentRowHeigt; + } + + return true; +} + //---------------------------------------------------------------------------- // Functor methods //---------------------------------------------------------------------------- From bb2ea8dd865ee5248f0cee2d57572eebf44c8e08 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 2 Jun 2023 22:01:34 +0200 Subject: [PATCH 06/36] Add Div class --- Verovio.xcodeproj/project.pbxproj | 16 +++++++ include/vrv/div.h | 64 ++++++++++++++++++++++++++ include/vrv/functorinterface.h | 5 ++ include/vrv/runningelement.h | 4 +- include/vrv/vrvdef.h | 1 + src/div.cpp | 76 +++++++++++++++++++++++++++++++ src/functorinterface.cpp | 21 +++++++++ src/runningelement.cpp | 2 + 8 files changed, 187 insertions(+), 2 deletions(-) create mode 100644 include/vrv/div.h create mode 100644 src/div.cpp diff --git a/Verovio.xcodeproj/project.pbxproj b/Verovio.xcodeproj/project.pbxproj index 1b6c95b0aa5..b89430ad3fb 100644 --- a/Verovio.xcodeproj/project.pbxproj +++ b/Verovio.xcodeproj/project.pbxproj @@ -215,6 +215,12 @@ 4D1EB6A42A2A40B400AF2F98 /* textlayoutelement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D1EB6A02A2A40B400AF2F98 /* textlayoutelement.cpp */; }; 4D1EB6A62A2A40CB00AF2F98 /* textlayoutelement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D1EB6A52A2A40CB00AF2F98 /* textlayoutelement.h */; }; 4D1EB6A72A2A40CB00AF2F98 /* textlayoutelement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D1EB6A52A2A40CB00AF2F98 /* textlayoutelement.h */; }; + 4D1EB6A92A2A7C5100AF2F98 /* div.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D1EB6A82A2A7C5100AF2F98 /* div.cpp */; }; + 4D1EB6AA2A2A7C5100AF2F98 /* div.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D1EB6A82A2A7C5100AF2F98 /* div.cpp */; }; + 4D1EB6AB2A2A7C5100AF2F98 /* div.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D1EB6A82A2A7C5100AF2F98 /* div.cpp */; }; + 4D1EB6AC2A2A7C5100AF2F98 /* div.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D1EB6A82A2A7C5100AF2F98 /* div.cpp */; }; + 4D1EB6AE2A2A7C6400AF2F98 /* div.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D1EB6AD2A2A7C6400AF2F98 /* div.h */; }; + 4D1EB6AF2A2A7C6400AF2F98 /* div.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D1EB6AD2A2A7C6400AF2F98 /* div.h */; }; 4D2073F522A3BCE000E0765F /* tuning.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D2073F222A3BCDF00E0765F /* tuning.cpp */; }; 4D2073F622A3BCE000E0765F /* tuning.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D2073F222A3BCDF00E0765F /* tuning.cpp */; }; 4D2073F722A3BCE000E0765F /* tuning.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D2073F222A3BCDF00E0765F /* tuning.cpp */; }; @@ -1769,6 +1775,8 @@ 4D1D733F1A1D08DC001E08F6 /* glyph.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = glyph.cpp; path = src/glyph.cpp; sourceTree = ""; }; 4D1EB6A02A2A40B400AF2F98 /* textlayoutelement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = textlayoutelement.cpp; path = src/textlayoutelement.cpp; sourceTree = ""; }; 4D1EB6A52A2A40CB00AF2F98 /* textlayoutelement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = textlayoutelement.h; path = include/vrv/textlayoutelement.h; sourceTree = ""; }; + 4D1EB6A82A2A7C5100AF2F98 /* div.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = div.cpp; path = src/div.cpp; sourceTree = ""; }; + 4D1EB6AD2A2A7C6400AF2F98 /* div.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = div.h; path = include/vrv/div.h; sourceTree = ""; }; 4D2073EF22A3BCB700E0765F /* tabdursym.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tabdursym.h; path = include/vrv/tabdursym.h; sourceTree = ""; }; 4D2073F022A3BCB700E0765F /* tuning.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tuning.h; path = include/vrv/tuning.h; sourceTree = ""; }; 4D2073F122A3BCB700E0765F /* tabgrp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tabgrp.h; path = include/vrv/tabgrp.h; sourceTree = ""; }; @@ -2579,6 +2587,8 @@ 4DC12A761F740089000440E9 /* textlayoutelements */ = { isa = PBXGroup; children = ( + 4D1EB6A82A2A7C5100AF2F98 /* div.cpp */, + 4D1EB6AD2A2A7C6400AF2F98 /* div.h */, 4DC12A771F7400B9000440E9 /* runningelement.cpp */, 4DC12A741F73FF92000440E9 /* runningelement.h */, 4DC12A7F1F741110000440E9 /* pgfoot.cpp */, @@ -3284,6 +3294,7 @@ 4DC12A891F74111E000440E9 /* pgfoot.h in Headers */, 4DB3D8C91F83D10300B5FC2B /* dir.h in Headers */, BD05622F2518CD12004057EB /* beamspan.h in Headers */, + 4D1EB6AE2A2A7C6400AF2F98 /* div.h in Headers */, 4DEC4DDA21C8295700D1D273 /* damage.h in Headers */, 4DACC9CE2990F29A00B55913 /* atts_mei.h in Headers */, 8F59294E18854BF800FE51AD /* positioninterface.h in Headers */, @@ -3410,6 +3421,7 @@ BB4C4BC422A9330D001F6AF0 /* pugixml.hpp in Headers */, 4DACC9F52990F29A00B55913 /* atts_visual.h in Headers */, BBC19FC322B38C1400100F42 /* VerovioFramework.h in Headers */, + 4D1EB6AF2A2A7C6400AF2F98 /* div.h in Headers */, BB4C4BC222A9330D001F6AF0 /* pugiconfig.hpp in Headers */, 4DACC9F12990F29A00B55913 /* atts_critapp.h in Headers */, 4D81351C2322C2CC00F59C01 /* keyaccid.h in Headers */, @@ -3995,6 +4007,7 @@ 4D16942C1E3A44F300569BF4 /* staff.cpp in Sources */, 4DB3D8E61F83D16A00B5FC2B /* ftrem.cpp in Sources */, 4DACCA072990F29A00B55913 /* atts_harmony.cpp in Sources */, + 4D1EB6AA2A2A7C5100AF2F98 /* div.cpp in Sources */, 4DC12A5A1F716E27000440E9 /* pghead.cpp in Sources */, 4DACC9A72990F29A00B55913 /* atts_externalsymbols.cpp in Sources */, 4DACC9F92990F29A00B55913 /* atts_figtable.cpp in Sources */, @@ -4210,6 +4223,7 @@ 406916DC23833770009E6B04 /* mspace.cpp in Sources */, E7A1640C29AF34750099BD6A /* adjustharmgrpsspacingfunctor.cpp in Sources */, 4D95D4F91D718D4A00B2B856 /* systemelement.cpp in Sources */, + 4D1EB6A92A2A7C5100AF2F98 /* div.cpp in Sources */, 4DDBBB5B1C7AE45900054AFF /* dynam.cpp in Sources */, E7E1698E29A8BA5200FFF482 /* adjustgracexposfunctor.cpp in Sources */, 4D5572441CF57B5C008D06A0 /* pedal.cpp in Sources */, @@ -4556,6 +4570,7 @@ 8F3DD32E18854B250051330C /* layer.cpp in Sources */, 8F3DD33018854B250051330C /* measure.cpp in Sources */, 4DACCA082990F29A00B55913 /* atts_harmony.cpp in Sources */, + 4D1EB6AB2A2A7C5100AF2F98 /* div.cpp in Sources */, 8F3DD33218854B250051330C /* page.cpp in Sources */, 4DACC9A82990F29A00B55913 /* atts_externalsymbols.cpp in Sources */, 4DACC9FA2990F29A00B55913 /* atts_figtable.cpp in Sources */, @@ -4837,6 +4852,7 @@ BB4C4BB122A932EB001F6AF0 /* view_page.cpp in Sources */, 4DACCA092990F29A00B55913 /* atts_harmony.cpp in Sources */, BB4C4A9F22A9328F001F6AF0 /* toolkit.cpp in Sources */, + 4D1EB6AC2A2A7C5100AF2F98 /* div.cpp in Sources */, 4DACC9A92990F29A00B55913 /* atts_externalsymbols.cpp in Sources */, 4DACC9FB2990F29A00B55913 /* atts_figtable.cpp in Sources */, E797C465298EC30800CAD67E /* calcalignmentpitchposfunctor.cpp in Sources */, diff --git a/include/vrv/div.h b/include/vrv/div.h new file mode 100644 index 00000000000..5ee546a2db2 --- /dev/null +++ b/include/vrv/div.h @@ -0,0 +1,64 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: div.h +// Author: Laurent Pugin +// Created: 2023 +// Copyright (c) Authors and others. All rights reserved. +///////////////////////////////////////////////////////////////////////////// + +#ifndef __VRV_DIV_H__ +#define __VRV_DIV_H__ + +#include "textlayoutelement.h" + +namespace vrv { + +//---------------------------------------------------------------------------- +// Div +//---------------------------------------------------------------------------- + +/** + * This class represents an MEI Div. + */ +class Div : public TextLayoutElement { +public: + /** + * @name Constructors, destructors, and other standard methods + * Reset method resets all attribute classes + */ + ///@{ + Div(); + virtual ~Div(); + void Reset() override; + std::string GetClassName() const override { return "Div"; } + ///@} + + /** + * Overriden to get the appropriate margin + */ + int GetTotalHeight(const Doc *doc) const override; + + //----------// + // Functors // + //----------// + + /** + * Interface for class functor visitation + */ + ///@{ + FunctorCode Accept(Functor &functor) override; + FunctorCode Accept(ConstFunctor &functor) const override; + FunctorCode AcceptEnd(Functor &functor) override; + FunctorCode AcceptEnd(ConstFunctor &functor) const override; + ///@} + +private: + // +public: + // +private: + // +}; + +} // namespace vrv + +#endif diff --git a/include/vrv/functorinterface.h b/include/vrv/functorinterface.h index 5ecf183e15f..fb4518aeec3 100644 --- a/include/vrv/functorinterface.h +++ b/include/vrv/functorinterface.h @@ -32,6 +32,7 @@ class ControlElement; class Course; class Custos; class Dir; +class Div; class Dot; class Dots; class Doc; @@ -227,6 +228,8 @@ class FunctorInterface { * @name Visit text layout elements */ ///@{ + virtual FunctorCode VisitDiv(Div *div); + virtual FunctorCode VisitDivEnd(Div *div); virtual FunctorCode VisitRunningElement(RunningElement *runningElement); virtual FunctorCode VisitRunningElementEnd(RunningElement *runningElement); virtual FunctorCode VisitPgFoot(PgFoot *pgFoot); @@ -584,6 +587,8 @@ class ConstFunctorInterface { * @name Visit text layout elements */ ///@{ + virtual FunctorCode VisitDiv(const Div *div); + virtual FunctorCode VisitDivEnd(const Div *div); virtual FunctorCode VisitRunningElement(const RunningElement *runningElement); virtual FunctorCode VisitRunningElementEnd(const RunningElement *runningElement); virtual FunctorCode VisitPgFoot(const PgFoot *pgFoot); diff --git a/include/vrv/runningelement.h b/include/vrv/runningelement.h index 665a9b68ae5..9a2e6216f3a 100644 --- a/include/vrv/runningelement.h +++ b/include/vrv/runningelement.h @@ -32,8 +32,8 @@ class RunningElement : public TextLayoutElement, public AttHorizontalAlign { * Reset method resets all attribute classes */ ///@{ - RunningElement(); - RunningElement(ClassId classId); + // RunningElement(); + // RunningElement(ClassId classId); RunningElement(ClassId classId, const std::string &classIdStr); virtual ~RunningElement(); void Reset() override; diff --git a/include/vrv/vrvdef.h b/include/vrv/vrvdef.h index 8aebcedb1e6..6affe26c487 100644 --- a/include/vrv/vrvdef.h +++ b/include/vrv/vrvdef.h @@ -153,6 +153,7 @@ enum ClassId : uint16_t { UNCLEAR, EDITORIAL_ELEMENT_max, // Ids for RunningElement child classes + DIV, RUNNING_ELEMENT, PGFOOT, PGFOOT2, diff --git a/src/div.cpp b/src/div.cpp new file mode 100644 index 00000000000..15339cd5d3b --- /dev/null +++ b/src/div.cpp @@ -0,0 +1,76 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: div.cpp +// Author: Laurent Pugin +// Created: 2023 +// Copyright (c) Authors and others. All rights reserved. +///////////////////////////////////////////////////////////////////////////// + +#include "div.h" + +//---------------------------------------------------------------------------- + +#include + +//---------------------------------------------------------------------------- + +#include "doc.h" +#include "functor.h" +#include "vrv.h" + +namespace vrv { + +//---------------------------------------------------------------------------- +// Div +//---------------------------------------------------------------------------- + +static const ClassRegistrar
s_factory("div", DIV); + +Div::Div() : TextLayoutElement(DIV, "div-") +{ + this->Reset(); +} + +Div::~Div() {} + +void Div::Reset() +{ + TextLayoutElement::Reset(); +} + +int Div::GetTotalHeight(const Doc *doc) const +{ + assert(doc); + + int height = this->GetContentHeight(); + if (height > 0) { + // const int unit = doc->GetDrawingUnit(100); + // height += doc->GetOptions()->m_bottomMarginPgHead.GetValue() * unit; + } + return height; +} + +//---------------------------------------------------------------------------- +// Functor methods +//---------------------------------------------------------------------------- + +FunctorCode Div::Accept(Functor &functor) +{ + return functor.VisitDiv(this); +} + +FunctorCode Div::Accept(ConstFunctor &functor) const +{ + return functor.VisitDiv(this); +} + +FunctorCode Div::AcceptEnd(Functor &functor) +{ + return functor.VisitDivEnd(this); +} + +FunctorCode Div::AcceptEnd(ConstFunctor &functor) const +{ + return functor.VisitDivEnd(this); +} + +} // namespace vrv diff --git a/src/functorinterface.cpp b/src/functorinterface.cpp index abe526f0d7e..c8426c78214 100644 --- a/src/functorinterface.cpp +++ b/src/functorinterface.cpp @@ -26,6 +26,7 @@ #include "course.h" #include "custos.h" #include "dir.h" +#include "div.h" #include "doc.h" #include "dot.h" #include "dynam.h" @@ -335,6 +336,16 @@ FunctorCode FunctorInterface::VisitEditorialElementEnd(EditorialElement *editori return this->VisitObjectEnd(editorialElement); } +FunctorCode FunctorInterface::VisitDiv(Div *div) +{ + return this->VisitTextLayoutElement(div); +} + +FunctorCode FunctorInterface::VisitDivEnd(Div *div) +{ + return this->VisitTextLayoutElementEnd(div); +} + FunctorCode FunctorInterface::VisitRunningElement(RunningElement *runningElement) { return this->VisitTextLayoutElement(runningElement); @@ -1619,6 +1630,16 @@ FunctorCode ConstFunctorInterface::VisitEditorialElementEnd(const EditorialEleme return this->VisitObjectEnd(editorialElement); } +FunctorCode ConstFunctorInterface::VisitDiv(const Div *div) +{ + return this->VisitTextLayoutElement(div); +} + +FunctorCode ConstFunctorInterface::VisitDivEnd(const Div *div) +{ + return this->VisitTextLayoutElementEnd(div); +} + FunctorCode ConstFunctorInterface::VisitRunningElement(const RunningElement *runningElement) { return this->VisitTextLayoutElement(runningElement); diff --git a/src/runningelement.cpp b/src/runningelement.cpp index 02a45537883..116f3d54d36 100644 --- a/src/runningelement.cpp +++ b/src/runningelement.cpp @@ -31,6 +31,7 @@ namespace vrv { // RunningElement //---------------------------------------------------------------------------- +/* RunningElement::RunningElement() : TextLayoutElement(RUNNING_ELEMENT, "re"), AttHorizontalAlign() { this->RegisterAttClass(ATT_HORIZONTALALIGN); @@ -44,6 +45,7 @@ RunningElement::RunningElement(ClassId classId) : TextLayoutElement(classId, "re this->Reset(); } +*/ RunningElement::RunningElement(ClassId classId, const std::string &classIdStr) : TextLayoutElement(classId, classIdStr), AttHorizontalAlign() From e9f614d4d544d9a7511d72b3952511543abb8186 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 2 Jun 2023 22:07:43 +0200 Subject: [PATCH 07/36] Add Div reading and writing methods (scaffolding) --- include/vrv/iomei.h | 3 +++ src/iomei.cpp | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/vrv/iomei.h b/include/vrv/iomei.h index d86b4735780..550493a42ef 100644 --- a/include/vrv/iomei.h +++ b/include/vrv/iomei.h @@ -51,6 +51,7 @@ class Damage; class Del; class Dot; class Dir; +class Div; class DurationInterface; class Dynam; class Ending; @@ -359,6 +360,7 @@ class MEIOutput : public Output { void WritePgFoot2(pugi::xml_node currentNode, PgFoot2 *pgFoot2); void WritePgHead(pugi::xml_node currentNode, PgHead *pgHead); void WritePgHead2(pugi::xml_node currentNode, PgHead2 *pgHead2); + void WriteDiv(pugi::xml_node currentNode, Div *div); void WriteStaffGrp(pugi::xml_node currentNode, StaffGrp *staffGrp); void WriteStaffDef(pugi::xml_node currentNode, StaffDef *staffDef); void WriteInstrDef(pugi::xml_node currentNode, InstrDef *instrDef); @@ -656,6 +658,7 @@ class MEIInput : public Input { bool ReadPgFoot2(Object *parent, pugi::xml_node pgFoot2); bool ReadPgHead(Object *parent, pugi::xml_node pgHead); bool ReadPgHead2(Object *parent, pugi::xml_node pgHead2); + bool ReadDiv(Object *parent, pugi::xml_node div); bool ReadRunningChildren(Object *parent, pugi::xml_node parentNode, Object *filter = NULL); bool ReadStaffGrp(Object *parent, pugi::xml_node staffGrp); bool ReadStaffGrpChildren(Object *parent, pugi::xml_node parentNode); diff --git a/src/iomei.cpp b/src/iomei.cpp index 386069b4a18..166658b5a27 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -40,6 +40,7 @@ #include "damage.h" #include "del.h" #include "dir.h" +#include "div.h" #include "dot.h" #include "dynam.h" #include "editorial.h" @@ -410,6 +411,10 @@ bool MEIOutput::WriteObjectInternal(Object *object, bool useCustomScoreDef) m_currentNode = m_currentNode.append_child("scoreDef"); this->WriteScoreDef(m_currentNode, vrv_cast(object)); } + else if (object->Is(DIV)) { + m_currentNode = m_currentNode.append_child("div"); + this->WriteDiv(m_currentNode, vrv_cast
(object)); + } else if (object->Is(PGFOOT)) { m_currentNode = m_currentNode.append_child("pgFoot"); this->WritePgFoot(m_currentNode, vrv_cast(object)); @@ -1750,6 +1755,13 @@ void MEIOutput::WriteGrpSym(pugi::xml_node currentNode, GrpSym *grpSym) grpSym->WriteStartEndId(currentNode); } +void MEIOutput::WriteDiv(pugi::xml_node currentNode, Div *div) +{ + assert(div); + + this->WriteTextLayoutElement(currentNode, div); +} + void MEIOutput::WritePgFoot(pugi::xml_node currentNode, PgFoot *pgFoot) { assert(pgFoot); @@ -4952,6 +4964,17 @@ bool MEIInput::ReadPgHead2(Object *parent, pugi::xml_node pgHead2) return this->ReadRunningChildren(vrvPgHead2, pgHead2, vrvPgHead2); } +bool MEIInput::ReadDiv(Object *parent, pugi::xml_node div) +{ + Div *vrvDiv = new Div(); + this->ReadTextLayoutElement(div, vrvDiv); + + parent->AddChild(vrvDiv); + this->ReadUnsupportedAttr(div, vrvDiv); + // return this->ReadRunningChildren(vrvDiv, pgDiv, vrvDiv); + return true; +} + bool MEIInput::ReadRunningChildren(Object *parent, pugi::xml_node parentNode, Object *filter) { bool success = true; From 4e7411b02900705938ef132cecde5f6bc8f968e3 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sat, 3 Jun 2023 09:08:49 +0200 Subject: [PATCH 08/36] Handle Div when converting to PageBased --- include/vrv/convertfunctor.h | 1 + src/convertfunctor.cpp | 9 +++++++++ src/iomei.cpp | 5 ++++- src/section.cpp | 4 ++++ src/system.cpp | 4 ++++ 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/include/vrv/convertfunctor.h b/include/vrv/convertfunctor.h index 74c9e50393d..4cd9c686bad 100644 --- a/include/vrv/convertfunctor.h +++ b/include/vrv/convertfunctor.h @@ -38,6 +38,7 @@ class ConvertToPageBasedFunctor : public Functor { * Functor interface */ ///@{ + FunctorCode VisitDiv(Div *div) override; FunctorCode VisitEditorialElement(EditorialElement *editorialElement) override; FunctorCode VisitEditorialElementEnd(EditorialElement *editorialElement) override; FunctorCode VisitEnding(Ending *ending) override; diff --git a/src/convertfunctor.cpp b/src/convertfunctor.cpp index a5ecb4d3b5c..cc2fd889660 100644 --- a/src/convertfunctor.cpp +++ b/src/convertfunctor.cpp @@ -9,6 +9,7 @@ //---------------------------------------------------------------------------- +#include "div.h" #include "doc.h" #include "ending.h" #include "fermata.h" @@ -38,6 +39,14 @@ ConvertToPageBasedFunctor::ConvertToPageBasedFunctor(Page *page) : Functor() m_page = page; } +FunctorCode ConvertToPageBasedFunctor::VisitDiv(Div *div) +{ + assert(m_currentSystem); + div->MoveItselfTo(m_currentSystem); + + return FUNCTOR_CONTINUE; +} + FunctorCode ConvertToPageBasedFunctor::VisitEditorialElement(EditorialElement *editorialElement) { assert(m_currentSystem); diff --git a/src/iomei.cpp b/src/iomei.cpp index 166658b5a27..6c064afe23a 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -4344,8 +4344,11 @@ bool MEIInput::ReadSectionChildren(Object *parent, pugi::xml_node parentNode) success = this->ReadEditorialElement(parent, current, EDITORIAL_TOPLEVEL); } // content + else if (std::string(current.name()) == "div") { + success = this->ReadDiv(parent, current); + } else if (std::string(current.name()) == "ending") { - // we should not endings with unmeasured music ... (?) + // we should not have endings with unmeasured music ... (?) assert(!unmeasured); success = this->ReadEnding(parent, current); } diff --git a/src/section.cpp b/src/section.cpp index 2751bc9f3d2..c536dafb5ac 100644 --- a/src/section.cpp +++ b/src/section.cpp @@ -13,6 +13,7 @@ //---------------------------------------------------------------------------- +#include "div.h" #include "doc.h" #include "editorial.h" #include "ending.h" @@ -61,6 +62,9 @@ bool Section::IsSupportedChild(Object *child) else if (child->IsSystemElement()) { assert(dynamic_cast(child)); } + else if (child->Is(DIV)) { + assert(dynamic_cast
(child)); + } else if (child->IsEditorialElement()) { assert(dynamic_cast(child)); } diff --git a/src/system.cpp b/src/system.cpp index 395ca9d1e11..270c85b3671 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -17,6 +17,7 @@ #include "comparison.h" #include "convertfunctor.h" #include "dir.h" +#include "div.h" #include "doc.h" #include "dynam.h" #include "ending.h" @@ -96,6 +97,9 @@ bool System::IsSupportedChild(Object *child) else if (child->IsSystemElement()) { assert(dynamic_cast(child)); } + else if (child->Is(DIV)) { + assert(dynamic_cast
(child)); + } else if (child->IsEditorialElement()) { assert(dynamic_cast(child)); } From 885cf9ee6d35afa222cbbbdd200beeb0dc886b95 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sat, 3 Jun 2023 09:09:29 +0200 Subject: [PATCH 09/36] Handle Div when casting off --- include/vrv/castofffunctor.h | 3 +++ src/castofffunctor.cpp | 25 ++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/include/vrv/castofffunctor.h b/include/vrv/castofffunctor.h index 1553a8bab11..fa968871809 100644 --- a/include/vrv/castofffunctor.h +++ b/include/vrv/castofffunctor.h @@ -49,6 +49,7 @@ class CastOffSystemsFunctor : public DocFunctor { * Functor interface */ ///@{ + FunctorCode VisitDiv(Div *div) override; FunctorCode VisitEditorialElement(EditorialElement *editorialElement) override; FunctorCode VisitEnding(Ending *ending) override; FunctorCode VisitMeasure(Measure *measure) override; @@ -183,6 +184,7 @@ class CastOffEncodingFunctor : public DocFunctor { * Functor interface */ ///@{ + FunctorCode VisitDiv(Div *div) override; FunctorCode VisitEditorialElement(EditorialElement *editorialElement) override; FunctorCode VisitEnding(Ending *ending) override; FunctorCode VisitMeasure(Measure *measure) override; @@ -296,6 +298,7 @@ class CastOffToSelectionFunctor : public DocFunctor { * Functor interface */ ///@{ + FunctorCode VisitDiv(Div *div) override; FunctorCode VisitEditorialElement(EditorialElement *editorialElement) override; FunctorCode VisitMeasure(Measure *measure) override; FunctorCode VisitPageElement(PageElement *pageElement) override; diff --git a/src/castofffunctor.cpp b/src/castofffunctor.cpp index 5fd1e7d3c61..88d5765c0c7 100644 --- a/src/castofffunctor.cpp +++ b/src/castofffunctor.cpp @@ -9,6 +9,7 @@ //---------------------------------------------------------------------------- +#include "div.h" #include "doc.h" #include "editorial.h" #include "ending.h" @@ -30,6 +31,14 @@ namespace vrv { // CastOffSystemsFunctor //---------------------------------------------------------------------------- +FunctorCode CastOffSystemsFunctor::VisitDiv(Div *div) +{ + assert(m_currentSystem); + div->MoveItselfTo(m_currentSystem); + + return FUNCTOR_SIBLINGS; +} + CastOffSystemsFunctor::CastOffSystemsFunctor(Page *page, Doc *doc, bool smart) : DocFunctor(doc) { m_page = page; @@ -385,6 +394,13 @@ CastOffEncodingFunctor::CastOffEncodingFunctor(Doc *doc, Page *currentPage, bool m_usePages = usePages; } +FunctorCode CastOffEncodingFunctor::VisitDiv(Div *div) +{ + div->MoveItselfTo(m_currentSystem); + + return FUNCTOR_SIBLINGS; +} + FunctorCode CastOffEncodingFunctor::VisitEditorialElement(EditorialElement *editorialElement) { // Only move editorial elements that are a child of the system @@ -458,7 +474,7 @@ FunctorCode CastOffEncodingFunctor::VisitSb(Sb *sb) // We look if the current system has at least one measure - if yes, we assume that the // is not the one at the beginning of the content (). This is not very robust but at least make it // work when rendering a that does not start with a or a (which we cannot enforce) - if (m_currentSystem->GetChildCount(MEASURE) > 0) { + if (m_currentSystem->GetChildCount(MEASURE) > 0 || m_currentSystem->GetChildCount(DIV) > 0) { m_currentPage->AddChild(m_currentSystem); m_currentSystem = new System(); } @@ -589,6 +605,13 @@ CastOffToSelectionFunctor::CastOffToSelectionFunctor( m_isSelection = false; } +FunctorCode CastOffToSelectionFunctor::VisitDiv(Div *div) +{ + div->MoveItselfTo(m_currentSystem); + + return FUNCTOR_SIBLINGS; +} + FunctorCode CastOffToSelectionFunctor::VisitEditorialElement(EditorialElement *editorialElement) { editorialElement->MoveItselfTo(m_currentSystem); From 0e0a0edd113cfd5ae25cc7ed5767a2263d44053e Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sat, 3 Jun 2023 09:10:29 +0200 Subject: [PATCH 10/36] Align Div vertically --- include/vrv/alignfunctor.h | 1 + src/alignfunctor.cpp | 8 ++++++++ src/div.cpp | 8 ++++---- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/vrv/alignfunctor.h b/include/vrv/alignfunctor.h index 536a66361cc..708a799d984 100644 --- a/include/vrv/alignfunctor.h +++ b/include/vrv/alignfunctor.h @@ -159,6 +159,7 @@ class AlignVerticallyFunctor : public DocFunctor { * Functor interface */ ///@{ + FunctorCode VisitDiv(Div *div) override; FunctorCode VisitFig(Fig *fig) override; FunctorCode VisitMeasure(Measure *measure) override; FunctorCode VisitPageEnd(Page *page) override; diff --git a/src/alignfunctor.cpp b/src/alignfunctor.cpp index 5d3fcc29f36..a4e137fa979 100644 --- a/src/alignfunctor.cpp +++ b/src/alignfunctor.cpp @@ -9,6 +9,7 @@ //---------------------------------------------------------------------------- +#include "div.h" #include "doc.h" #include "dot.h" #include "fig.h" @@ -490,6 +491,13 @@ AlignVerticallyFunctor::AlignVerticallyFunctor(Doc *doc) : DocFunctor(doc) m_pageWidth = 0; } +FunctorCode AlignVerticallyFunctor::VisitDiv(Div *div) +{ + m_systemAligner->GetBottomAlignment()->SetYRel(-div->GetTotalHeight(m_doc)); + + return FUNCTOR_SIBLINGS; +} + FunctorCode AlignVerticallyFunctor::VisitFig(Fig *fig) { Svg *svg = vrv_cast(fig->FindDescendantByType(SVG)); diff --git a/src/div.cpp b/src/div.cpp index 15339cd5d3b..1a5b524a2bc 100644 --- a/src/div.cpp +++ b/src/div.cpp @@ -42,10 +42,10 @@ int Div::GetTotalHeight(const Doc *doc) const assert(doc); int height = this->GetContentHeight(); - if (height > 0) { - // const int unit = doc->GetDrawingUnit(100); - // height += doc->GetOptions()->m_bottomMarginPgHead.GetValue() * unit; - } + // if (height > 0) { + const int unit = doc->GetDrawingUnit(100); + height += 50 * unit; + //} return height; } From 52fa705196e0694b9d50394fe621fbc28246f2ea Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sat, 3 Jun 2023 09:10:51 +0200 Subject: [PATCH 11/36] Return page with for div --- include/vrv/div.h | 2 ++ src/div.cpp | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/include/vrv/div.h b/include/vrv/div.h index 5ee546a2db2..9357043fe32 100644 --- a/include/vrv/div.h +++ b/include/vrv/div.h @@ -37,6 +37,8 @@ class Div : public TextLayoutElement { */ int GetTotalHeight(const Doc *doc) const override; + int GetTotalWidth(const Doc *doc) const; + //----------// // Functors // //----------// diff --git a/src/div.cpp b/src/div.cpp index 1a5b524a2bc..88ddfc0c4d5 100644 --- a/src/div.cpp +++ b/src/div.cpp @@ -49,6 +49,11 @@ int Div::GetTotalHeight(const Doc *doc) const return height; } +int Div::GetTotalWidth(const Doc *doc) const +{ + return (doc->m_drawingPageContentWidth); +} + //---------------------------------------------------------------------------- // Functor methods //---------------------------------------------------------------------------- From 569614ce5521bc10cb0b3d60b3627aa17055c37e Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sat, 3 Jun 2023 09:11:33 +0200 Subject: [PATCH 12/36] Draw Div - at this stage a rectangle with fixed height --- include/vrv/view.h | 2 ++ src/view_page.cpp | 5 +++++ src/view_running.cpp | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/include/vrv/view.h b/include/vrv/view.h index 4e3756a9a9a..ba11a6fcd14 100644 --- a/include/vrv/view.h +++ b/include/vrv/view.h @@ -30,6 +30,7 @@ class Chord; class ControlElement; class DeviceContext; class Dir; +class Div; class Doc; class Dynam; class EditorialElement; @@ -242,6 +243,7 @@ class View { * Defined in view_running.cpp */ ///@{ + void DrawDiv(DeviceContext *dc, Div *div, System *system); void DrawRunningElements(DeviceContext *dc, Page *page); void DrawPgFooter(DeviceContext *dc, RunningElement *pgFooter); void DrawPgHeader(DeviceContext *dc, RunningElement *pgHeader); diff --git a/src/view_page.cpp b/src/view_page.cpp index 5cebfaa9fe5..a56e34501b7 100644 --- a/src/view_page.cpp +++ b/src/view_page.cpp @@ -23,6 +23,7 @@ #include "comparison.h" #include "controlelement.h" #include "devicecontext.h" +#include "div.h" #include "doc.h" #include "editorial.h" #include "ending.h" @@ -1635,6 +1636,10 @@ void View::DrawSystemChildren(DeviceContext *dc, Object *parent, System *system) // cast to SystemElement check in DrawSystemEditorial element this->DrawSystemElement(dc, dynamic_cast(current), system); } + else if (current->Is(DIV)) { + // cast to Div check in DrawDiv element + this->DrawDiv(dc, dynamic_cast
(current), system); + } else if (current->IsEditorialElement()) { // cast to EditorialElement check in DrawSystemEditorial element this->DrawSystemEditorialElement(dc, dynamic_cast(current), system); diff --git a/src/view_running.cpp b/src/view_running.cpp index a355d195a54..50993260528 100644 --- a/src/view_running.cpp +++ b/src/view_running.cpp @@ -15,6 +15,7 @@ #include "bboxdevicecontext.h" #include "devicecontext.h" +#include "div.h" #include "doc.h" #include "page.h" #include "pgfoot.h" @@ -82,4 +83,22 @@ void View::DrawPgHeader(DeviceContext *dc, RunningElement *pgHeader) dc->EndGraphic(pgHeader, this); } +void View::DrawDiv(DeviceContext *dc, Div *div, System *system) +{ + dc->StartGraphic(div, "", div->GetID()); + + dc->SetBrush(m_currentColor, AxSOLID); + + const int x = div->GetDrawingX(); + const int y = div->GetDrawingY(); + const int height = div->GetTotalHeight(m_doc); + const int width = div->GetTotalWidth(m_doc); + + this->DrawFilledRectangle(dc, x, y, x + width, y - height); + + dc->ResetBrush(); + + dc->EndGraphic(div, this); +} + } // namespace vrv From cdc33376c7dd52077f4e63949c238d1c0b9c3300 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sun, 4 Jun 2023 15:47:15 +0200 Subject: [PATCH 13/36] Move methods to TextLayoutElement --- include/vrv/div.h | 2 +- include/vrv/runningelement.h | 7 +------ include/vrv/textlayoutelement.h | 10 ++++++++++ src/div.cpp | 5 +---- src/runningelement.cpp | 26 +------------------------- src/textlayoutelement.cpp | 18 ++++++++++++++++++ 6 files changed, 32 insertions(+), 36 deletions(-) diff --git a/include/vrv/div.h b/include/vrv/div.h index 9357043fe32..23df3beecdc 100644 --- a/include/vrv/div.h +++ b/include/vrv/div.h @@ -37,7 +37,7 @@ class Div : public TextLayoutElement { */ int GetTotalHeight(const Doc *doc) const override; - int GetTotalWidth(const Doc *doc) const; + int GetTotalWidth(const Doc *doc) const override; //----------// // Functors // diff --git a/include/vrv/runningelement.h b/include/vrv/runningelement.h index 9a2e6216f3a..828fcef505c 100644 --- a/include/vrv/runningelement.h +++ b/include/vrv/runningelement.h @@ -61,7 +61,7 @@ class RunningElement : public TextLayoutElement, public AttHorizontalAlign { int GetDrawingY() const override; ///@} - int GetWidth() const; + int GetTotalWidth(const Doc *doc) const override; /* * @name Setter and getter for the current drawing page @@ -90,11 +90,6 @@ class RunningElement : public TextLayoutElement, public AttHorizontalAlign { */ void LoadFooter(const Doc *doc); - /** - * Calculate the cell position - */ - int GetAlignmentPos(data_HORIZONTALALIGNMENT h, data_VERTICALALIGNMENT v) const; - /** * Add page numbering to the running element. */ diff --git a/include/vrv/textlayoutelement.h b/include/vrv/textlayoutelement.h index de4d8266748..636de08e5b8 100644 --- a/include/vrv/textlayoutelement.h +++ b/include/vrv/textlayoutelement.h @@ -83,6 +83,16 @@ class TextLayoutElement : public Object, public ObjectListInterface, public AttT int GetCellHeight(int cell) const; ///@} + /** + * + */ + virtual int GetTotalWidth(const Doc *doc) const = 0; + + /** + * Calculate the cell position + */ + int GetAlignmentPos(data_HORIZONTALALIGNMENT h, data_VERTICALALIGNMENT v) const; + //----------// // Functors // //----------// diff --git a/src/div.cpp b/src/div.cpp index 88ddfc0c4d5..9c82247fd06 100644 --- a/src/div.cpp +++ b/src/div.cpp @@ -42,10 +42,7 @@ int Div::GetTotalHeight(const Doc *doc) const assert(doc); int height = this->GetContentHeight(); - // if (height > 0) { - const int unit = doc->GetDrawingUnit(100); - height += 50 * unit; - //} + return height; } diff --git a/src/runningelement.cpp b/src/runningelement.cpp index 116f3d54d36..5eb7fbb53da 100644 --- a/src/runningelement.cpp +++ b/src/runningelement.cpp @@ -101,15 +101,9 @@ void RunningElement::SetDrawingYRel(int drawingYRel) m_drawingYRel = drawingYRel; } -int RunningElement::GetWidth() const +int RunningElement::GetTotalWidth(const Doc *doc) const { - if (!m_drawingPage) return 0; - - Doc *doc = vrv_cast(m_drawingPage->GetFirstAncestor(DOC)); - if (!doc) return 0; - return (doc->m_drawingPageContentWidth); - // return m_drawingPage->GetContentWidth(); } void RunningElement::SetDrawingPage(Page *page) @@ -125,24 +119,6 @@ void RunningElement::SetDrawingPage(Page *page) } } -int RunningElement::GetAlignmentPos(data_HORIZONTALALIGNMENT h, data_VERTICALALIGNMENT v) const -{ - int pos = 0; - switch (h) { - case (HORIZONTALALIGNMENT_left): break; - case (HORIZONTALALIGNMENT_center): pos += POSITION_CENTER; break; - case (HORIZONTALALIGNMENT_right): pos += POSITION_RIGHT; break; - default: pos += POSITION_LEFT; break; - } - switch (v) { - case (VERTICALALIGNMENT_top): break; - case (VERTICALALIGNMENT_middle): pos += POSITION_MIDDLE; break; - case (VERTICALALIGNMENT_bottom): pos += POSITION_BOTTOM; break; - default: pos += POSITION_MIDDLE; break; - } - return pos; -} - void RunningElement::SetCurrentPageNum(const Page *currentPage) { assert(currentPage); diff --git a/src/textlayoutelement.cpp b/src/textlayoutelement.cpp index 6585e480c69..cbbe6b3a536 100644 --- a/src/textlayoutelement.cpp +++ b/src/textlayoutelement.cpp @@ -218,6 +218,24 @@ bool TextLayoutElement::AdjustRunningElementYPos() return true; } +int TextLayoutElement::GetAlignmentPos(data_HORIZONTALALIGNMENT h, data_VERTICALALIGNMENT v) const +{ + int pos = 0; + switch (h) { + case (HORIZONTALALIGNMENT_left): break; + case (HORIZONTALALIGNMENT_center): pos += POSITION_CENTER; break; + case (HORIZONTALALIGNMENT_right): pos += POSITION_RIGHT; break; + default: pos += POSITION_LEFT; break; + } + switch (v) { + case (VERTICALALIGNMENT_top): break; + case (VERTICALALIGNMENT_middle): pos += POSITION_MIDDLE; break; + case (VERTICALALIGNMENT_bottom): pos += POSITION_BOTTOM; break; + default: pos += POSITION_MIDDLE; break; + } + return pos; +} + //---------------------------------------------------------------------------- // Functor methods //---------------------------------------------------------------------------- From c925617ba3b038b7fcedb24a1e8d70c20a70c320 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sun, 4 Jun 2023 15:48:37 +0200 Subject: [PATCH 14/36] Align rend within Div --- include/vrv/alignfunctor.h | 2 +- src/alignfunctor.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/vrv/alignfunctor.h b/include/vrv/alignfunctor.h index 708a799d984..d36b11fc87f 100644 --- a/include/vrv/alignfunctor.h +++ b/include/vrv/alignfunctor.h @@ -189,7 +189,7 @@ class AlignVerticallyFunctor : public DocFunctor { int m_cumulatedShift; // The sum of justification factors per page int m_justificationSum; - // The page width + // The page width - used for setting the horizontal position of withing text layout elements int m_pageWidth; }; diff --git a/src/alignfunctor.cpp b/src/alignfunctor.cpp index a4e137fa979..8cac950b916 100644 --- a/src/alignfunctor.cpp +++ b/src/alignfunctor.cpp @@ -495,7 +495,9 @@ FunctorCode AlignVerticallyFunctor::VisitDiv(Div *div) { m_systemAligner->GetBottomAlignment()->SetYRel(-div->GetTotalHeight(m_doc)); - return FUNCTOR_SIBLINGS; + m_pageWidth = div->GetTotalWidth(m_doc); + + return FUNCTOR_CONTINUE; } FunctorCode AlignVerticallyFunctor::VisitFig(Fig *fig) @@ -544,6 +546,8 @@ FunctorCode AlignVerticallyFunctor::VisitPageEnd(Page *page) FunctorCode AlignVerticallyFunctor::VisitRend(Rend *rend) { + if (!rend->GetFirstAncestorInRange(TEXT_LAYOUT_ELEMENT, TEXT_LAYOUT_ELEMENT_max)) return FUNCTOR_SIBLINGS; + if (rend->GetHalign()) { switch (rend->GetHalign()) { case HORIZONTALALIGNMENT_right: rend->SetDrawingXRel(m_pageWidth); break; @@ -559,7 +563,7 @@ FunctorCode AlignVerticallyFunctor::VisitRunningElement(RunningElement *runningE { this->VisitTextLayoutElement(runningElement); - m_pageWidth = runningElement->GetWidth(); + m_pageWidth = runningElement->GetTotalWidth(m_doc); return FUNCTOR_CONTINUE; } From 3b904a4d1829b41e2cc9112f57ac84cdd9045f50 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sun, 4 Jun 2023 15:49:32 +0200 Subject: [PATCH 15/36] Prepare and adjust position for Div --- include/vrv/adjustyposfunctor.h | 1 + include/vrv/preparedatafunctor.h | 2 +- src/adjustyposfunctor.cpp | 10 +++++++++- src/preparedatafunctor.cpp | 31 ++++++++++++++++--------------- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/include/vrv/adjustyposfunctor.h b/include/vrv/adjustyposfunctor.h index b2773c9d66c..e817bf5a3f1 100644 --- a/include/vrv/adjustyposfunctor.h +++ b/include/vrv/adjustyposfunctor.h @@ -38,6 +38,7 @@ class AdjustYPosFunctor : public DocFunctor { * Functor interface */ ///@{ + FunctorCode VisitDiv(Div *div) override; FunctorCode VisitStaffAlignment(StaffAlignment *staffAlignment) override; FunctorCode VisitSystem(System *system) override; ///@} diff --git a/include/vrv/preparedatafunctor.h b/include/vrv/preparedatafunctor.h index dfacf5a80a9..e479a786efb 100644 --- a/include/vrv/preparedatafunctor.h +++ b/include/vrv/preparedatafunctor.h @@ -45,8 +45,8 @@ class PrepareDataInitializationFunctor : public DocFunctor { FunctorCode VisitChord(Chord *chord) override; FunctorCode VisitFloatingObject(FloatingObject *floatingObject) override; FunctorCode VisitKeySig(KeySig *keySig) override; - FunctorCode VisitRunningElement(RunningElement *runningElement) override; FunctorCode VisitScore(Score *score) override; + FunctorCode VisitTextLayoutElement(TextLayoutElement *textLayoutElement) override; ///@} protected: diff --git a/src/adjustyposfunctor.cpp b/src/adjustyposfunctor.cpp index 75124f2fe18..27199ce6356 100644 --- a/src/adjustyposfunctor.cpp +++ b/src/adjustyposfunctor.cpp @@ -12,6 +12,7 @@ #include "beamspan.h" #include "calcalignmentpitchposfunctor.h" #include "calcstemfunctor.h" +#include "div.h" #include "system.h" //---------------------------------------------------------------------------- @@ -27,6 +28,13 @@ AdjustYPosFunctor::AdjustYPosFunctor(Doc *doc) : DocFunctor(doc) m_cumulatedShift = 0; } +FunctorCode AdjustYPosFunctor::VisitDiv(Div *div) +{ + div->AdjustRunningElementYPos(); + + return FUNCTOR_SIBLINGS; +} + FunctorCode AdjustYPosFunctor::VisitStaffAlignment(StaffAlignment *staffAlignment) { const int defaultSpacing = staffAlignment->GetMinimumSpacing(m_doc); @@ -52,7 +60,7 @@ FunctorCode AdjustYPosFunctor::VisitSystem(System *system) system->m_systemAligner.Process(*this); - return FUNCTOR_SIBLINGS; + return FUNCTOR_CONTINUE; } //---------------------------------------------------------------------------- diff --git a/src/preparedatafunctor.cpp b/src/preparedatafunctor.cpp index c45483b0f27..20f2505287d 100644 --- a/src/preparedatafunctor.cpp +++ b/src/preparedatafunctor.cpp @@ -13,6 +13,7 @@ #include "areaposinterface.h" #include "beamspan.h" #include "dir.h" +#include "div.h" #include "doc.h" #include "dot.h" #include "dynam.h" @@ -81,35 +82,35 @@ FunctorCode PrepareDataInitializationFunctor::VisitKeySig(KeySig *keySig) return FUNCTOR_CONTINUE; } -FunctorCode PrepareDataInitializationFunctor::VisitRunningElement(RunningElement *runningElement) +FunctorCode PrepareDataInitializationFunctor::VisitScore(Score *score) +{ + // Evaluate functor on scoreDef + score->GetScoreDef()->Process(*this); + + return FUNCTOR_CONTINUE; +} + +FunctorCode PrepareDataInitializationFunctor::VisitTextLayoutElement(TextLayoutElement *textLayoutElement) { - this->VisitTextLayoutElement(runningElement); + this->VisitObject(textLayoutElement); - runningElement->ResetCells(); - runningElement->ResetDrawingScaling(); + textLayoutElement->ResetCells(); + textLayoutElement->ResetDrawingScaling(); - const ListOfObjects &childList = runningElement->GetList(runningElement); + const ListOfObjects &childList = textLayoutElement->GetList(textLayoutElement); for (ListOfObjects::const_iterator iter = childList.begin(); iter != childList.end(); ++iter) { int pos = 0; AreaPosInterface *interface = dynamic_cast(*iter); assert(interface); - pos = runningElement->GetAlignmentPos(interface->GetHalign(), interface->GetValign()); + pos = textLayoutElement->GetAlignmentPos(interface->GetHalign(), interface->GetValign()); TextElement *text = vrv_cast(*iter); assert(text); - runningElement->AppendTextToCell(pos, text); + textLayoutElement->AppendTextToCell(pos, text); } return FUNCTOR_CONTINUE; } -FunctorCode PrepareDataInitializationFunctor::VisitScore(Score *score) -{ - // Evaluate functor on scoreDef - score->GetScoreDef()->Process(*this); - - return FUNCTOR_CONTINUE; -} - //---------------------------------------------------------------------------- // PrepareCueSizeFunctor //---------------------------------------------------------------------------- From 64e7600ff057f813000ad0ffa60f6810c01f04f7 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sun, 4 Jun 2023 15:50:23 +0200 Subject: [PATCH 16/36] Rename DrawPgHeader to DrawTextLayoutElement and call it from DrawDiv --- include/vrv/view.h | 3 ++- include/vrv/vrvdef.h | 5 ++++- src/textelement.cpp | 16 ++++++++-------- src/view_running.cpp | 43 +++++++++++++++---------------------------- 4 files changed, 29 insertions(+), 38 deletions(-) diff --git a/include/vrv/view.h b/include/vrv/view.h index ba11a6fcd14..99be5bb8683 100644 --- a/include/vrv/view.h +++ b/include/vrv/view.h @@ -82,6 +82,7 @@ class Tempo; class Text; class TextDrawingParams; class TextElement; +class TextLayoutElement; class Tie; class Trill; class Turn; @@ -246,7 +247,7 @@ class View { void DrawDiv(DeviceContext *dc, Div *div, System *system); void DrawRunningElements(DeviceContext *dc, Page *page); void DrawPgFooter(DeviceContext *dc, RunningElement *pgFooter); - void DrawPgHeader(DeviceContext *dc, RunningElement *pgHeader); + void DrawTextLayoutElement(DeviceContext *dc, TextLayoutElement *textLayoutElement); ///@} /** diff --git a/include/vrv/vrvdef.h b/include/vrv/vrvdef.h index 6affe26c487..52f94d3b54d 100644 --- a/include/vrv/vrvdef.h +++ b/include/vrv/vrvdef.h @@ -152,14 +152,17 @@ enum ClassId : uint16_t { SUPPLIED, UNCLEAR, EDITORIAL_ELEMENT_max, - // Ids for RunningElement child classes + // Ids for TextLayoutElement child classes + TEXT_LAYOUT_ELEMENT, DIV, + // Ids for RunningElement child classes RUNNING_ELEMENT, PGFOOT, PGFOOT2, PGHEAD, PGHEAD2, RUNNING_ELEMENT_max, + TEXT_LAYOUT_ELEMENT_max, // Ids for PageElement child classes PAGE_ELEMENT, PAGE_MILESTONE_END, diff --git a/src/textelement.cpp b/src/textelement.cpp index aab3720badd..53d5d4e478e 100644 --- a/src/textelement.cpp +++ b/src/textelement.cpp @@ -68,10 +68,10 @@ int TextElement::GetDrawingX() const return (textElement->GetDrawingX() + this->GetDrawingXRel()); } - // Otherwise get the running element parent - no cast to RunningElement is necessary - const Object *runningElement = this->GetFirstAncestorInRange(RUNNING_ELEMENT, RUNNING_ELEMENT_max); - if (runningElement) { - return (runningElement->GetDrawingX() + this->GetDrawingXRel()); + // Otherwise get the text layout element parent - no cast to TextLayoutElement is necessary + const Object *textLayoutElement = this->GetFirstAncestorInRange(TEXT_LAYOUT_ELEMENT, TEXT_LAYOUT_ELEMENT_max); + if (textLayoutElement) { + return (textLayoutElement->GetDrawingX() + this->GetDrawingXRel()); } return Object::GetDrawingX(); @@ -87,10 +87,10 @@ int TextElement::GetDrawingY() const return (textElement->GetDrawingY() + this->GetDrawingYRel()); } - // Otherwise get the running element parent - no cast to RunningElement is necessary - const Object *runningElement = this->GetFirstAncestorInRange(RUNNING_ELEMENT, RUNNING_ELEMENT_max); - if (runningElement) { - return (runningElement->GetDrawingY() + this->GetDrawingYRel()); + // Otherwise get the text layout element parent - no cast to TextLayoutElement is necessary + const Object *textLayoutElement = this->GetFirstAncestorInRange(TEXT_LAYOUT_ELEMENT, TEXT_LAYOUT_ELEMENT_max); + if (textLayoutElement) { + return (textLayoutElement->GetDrawingY() + this->GetDrawingYRel()); } // TextElement not within RunningElement; diff --git a/src/view_running.cpp b/src/view_running.cpp index 50993260528..6f0fd12a2ee 100644 --- a/src/view_running.cpp +++ b/src/view_running.cpp @@ -40,65 +40,52 @@ void View::DrawRunningElements(DeviceContext *dc, Page *page) RunningElement *header = page->GetHeader(); if (header) { - this->DrawPgHeader(dc, header); + this->DrawTextLayoutElement(dc, header); } RunningElement *footer = page->GetFooter(); if (footer) { - this->DrawPgHeader(dc, footer); + this->DrawTextLayoutElement(dc, footer); } } -void View::DrawPgHeader(DeviceContext *dc, RunningElement *pgHeader) +void View::DrawTextLayoutElement(DeviceContext *dc, TextLayoutElement *textLayoutElement) { assert(dc); - assert(pgHeader); + assert(textLayoutElement); - dc->StartGraphic(pgHeader, "", pgHeader->GetID()); + dc->StartGraphic(textLayoutElement, "", textLayoutElement->GetID()); - FontInfo pgHeadTxt; + FontInfo textElementFont; if (!dc->UseGlobalStyling()) { - pgHeadTxt.SetFaceName("Times"); + textElementFont.SetFaceName("Times"); } TextDrawingParams params; // If we have not timestamp - params.m_x = pgHeader->GetDrawingX(); - params.m_y = pgHeader->GetDrawingY(); - params.m_width = pgHeader->GetWidth(); + params.m_x = textLayoutElement->GetDrawingX(); + params.m_y = textLayoutElement->GetDrawingY(); + params.m_width = textLayoutElement->GetTotalWidth(m_doc); params.m_alignment = HORIZONTALALIGNMENT_NONE; params.m_laidOut = true; params.m_pointSize = m_doc->GetDrawingLyricFont(100)->GetPointSize(); - pgHeadTxt.SetPointSize(params.m_pointSize); + textElementFont.SetPointSize(params.m_pointSize); dc->SetBrush(m_currentColor, AxSOLID); - dc->SetFont(&pgHeadTxt); + dc->SetFont(&textElementFont); - this->DrawRunningChildren(dc, pgHeader, params); + this->DrawRunningChildren(dc, textLayoutElement, params); dc->ResetFont(); dc->ResetBrush(); - dc->EndGraphic(pgHeader, this); + dc->EndGraphic(textLayoutElement, this); } void View::DrawDiv(DeviceContext *dc, Div *div, System *system) { - dc->StartGraphic(div, "", div->GetID()); - - dc->SetBrush(m_currentColor, AxSOLID); - - const int x = div->GetDrawingX(); - const int y = div->GetDrawingY(); - const int height = div->GetTotalHeight(m_doc); - const int width = div->GetTotalWidth(m_doc); - - this->DrawFilledRectangle(dc, x, y, x + width, y - height); - - dc->ResetBrush(); - - dc->EndGraphic(div, this); + this->DrawTextLayoutElement(dc, div); } } // namespace vrv From 274e25e7c601f536cce8821a9552c7eeb2fd66ca Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sun, 4 Jun 2023 15:50:48 +0200 Subject: [PATCH 17/36] Load RunningChildren within Div (invalid MEI) --- src/iomei.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/iomei.cpp b/src/iomei.cpp index 6c064afe23a..88511664184 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -4974,8 +4974,7 @@ bool MEIInput::ReadDiv(Object *parent, pugi::xml_node div) parent->AddChild(vrvDiv); this->ReadUnsupportedAttr(div, vrvDiv); - // return this->ReadRunningChildren(vrvDiv, pgDiv, vrvDiv); - return true; + return this->ReadRunningChildren(vrvDiv, div, vrvDiv); } bool MEIInput::ReadRunningChildren(Object *parent, pugi::xml_node parentNode, Object *filter) From 087dde46d0cbd8686b1ded8897a9680291f12209 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sun, 4 Jun 2023 15:54:57 +0200 Subject: [PATCH 18/36] Move view_running.cpp to view_text.cpp --- Verovio.xcodeproj/project.pbxproj | 10 ---- include/vrv/view.h | 5 +- src/view_running.cpp | 91 ------------------------------- src/view_text.cpp | 68 +++++++++++++++++++++++ 4 files changed, 70 insertions(+), 104 deletions(-) delete mode 100644 src/view_running.cpp diff --git a/Verovio.xcodeproj/project.pbxproj b/Verovio.xcodeproj/project.pbxproj index b89430ad3fb..0c5b37ee969 100644 --- a/Verovio.xcodeproj/project.pbxproj +++ b/Verovio.xcodeproj/project.pbxproj @@ -745,9 +745,6 @@ 4DC12A781F7400B9000440E9 /* runningelement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A771F7400B9000440E9 /* runningelement.cpp */; }; 4DC12A791F7400B9000440E9 /* runningelement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A771F7400B9000440E9 /* runningelement.cpp */; }; 4DC12A7A1F7400B9000440E9 /* runningelement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A771F7400B9000440E9 /* runningelement.cpp */; }; - 4DC12A7C1F740FB9000440E9 /* view_running.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A7B1F740FB9000440E9 /* view_running.cpp */; }; - 4DC12A7D1F740FB9000440E9 /* view_running.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A7B1F740FB9000440E9 /* view_running.cpp */; }; - 4DC12A7E1F740FB9000440E9 /* view_running.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A7B1F740FB9000440E9 /* view_running.cpp */; }; 4DC12A811F741110000440E9 /* pgfoot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A7F1F741110000440E9 /* pgfoot.cpp */; }; 4DC12A821F741110000440E9 /* pgfoot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A7F1F741110000440E9 /* pgfoot.cpp */; }; 4DC12A831F741110000440E9 /* pgfoot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A7F1F741110000440E9 /* pgfoot.cpp */; }; @@ -1310,7 +1307,6 @@ BB4C4BAF22A932EB001F6AF0 /* view_mensural.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D43C30B1A9BB22A00EA28F3 /* view_mensural.cpp */; }; BB4C4BB022A932EB001F6AF0 /* view_neume.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D766EF820ACAD62006875D8 /* view_neume.cpp */; }; BB4C4BB122A932EB001F6AF0 /* view_page.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8F086EDE188539540037FD8E /* view_page.cpp */; }; - BB4C4BB222A932EB001F6AF0 /* view_running.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A7B1F740FB9000440E9 /* view_running.cpp */; }; BB4C4BB322A932EB001F6AF0 /* view_slur.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D7927CF20ECCC6D0002A45D /* view_slur.cpp */; }; BB4C4BB422A932EB001F6AF0 /* view_text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DDBBCC41C2EBAE7001AB50A /* view_text.cpp */; }; BB4C4BB522A932EB001F6AF0 /* view_tuplet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8F086EDF188539540037FD8E /* view_tuplet.cpp */; }; @@ -1983,7 +1979,6 @@ 4DC12A621F73F898000440E9 /* pghead2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = pghead2.cpp; path = src/pghead2.cpp; sourceTree = ""; }; 4DC12A741F73FF92000440E9 /* runningelement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = runningelement.h; path = include/vrv/runningelement.h; sourceTree = ""; }; 4DC12A771F7400B9000440E9 /* runningelement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = runningelement.cpp; path = src/runningelement.cpp; sourceTree = ""; }; - 4DC12A7B1F740FB9000440E9 /* view_running.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = view_running.cpp; path = src/view_running.cpp; sourceTree = ""; }; 4DC12A7F1F741110000440E9 /* pgfoot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = pgfoot.cpp; path = src/pgfoot.cpp; sourceTree = ""; }; 4DC12A801F741110000440E9 /* pgfoot2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = pgfoot2.cpp; path = src/pgfoot2.cpp; sourceTree = ""; }; 4DC12A871F74111E000440E9 /* pgfoot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pgfoot.h; path = include/vrv/pgfoot.h; sourceTree = ""; }; @@ -2885,7 +2880,6 @@ 4D43C30B1A9BB22A00EA28F3 /* view_mensural.cpp */, 4D766EF820ACAD62006875D8 /* view_neume.cpp */, 8F086EDE188539540037FD8E /* view_page.cpp */, - 4DC12A7B1F740FB9000440E9 /* view_running.cpp */, 4D7927CF20ECCC6D0002A45D /* view_slur.cpp */, 4DDBBCC41C2EBAE7001AB50A /* view_text.cpp */, 4D20741122A708C600E0765F /* view_tab.cpp */, @@ -3946,7 +3940,6 @@ E78F204B29D98D2B00CD5910 /* adjustxrelfortranscriptionfunctor.cpp in Sources */, BD0562372518CD20004057EB /* beamspan.cpp in Sources */, 4D1694181E3A44F300569BF4 /* text.cpp in Sources */, - 4DC12A7D1F740FB9000440E9 /* view_running.cpp in Sources */, E7265E7329DC701000D11F41 /* castofffunctor.cpp in Sources */, E7D48C7529D21F2B0031D89D /* adjustyposfunctor.cpp in Sources */, E77C198228CD31AC00F5BADA /* calcdotsfunctor.cpp in Sources */, @@ -4139,7 +4132,6 @@ 4DEC4D9621C81E3B00D1D273 /* expan.cpp in Sources */, 4D508C3026D4E64C00020F35 /* crc.cpp in Sources */, 8F086EE4188539540037FD8E /* barline.cpp in Sources */, - 4DC12A7C1F740FB9000440E9 /* view_running.cpp in Sources */, E7E9C11529B0A1FF00CFCE2F /* adjustaccidxfunctor.cpp in Sources */, 4DACC9A62990F29A00B55913 /* atts_externalsymbols.cpp in Sources */, 8F086EE5188539540037FD8E /* bboxdevicecontext.cpp in Sources */, @@ -4624,7 +4616,6 @@ 4DACC9EE2990F29A00B55913 /* atts_shared.cpp in Sources */, 8F3DD32018854AFB0051330C /* devicecontext.cpp in Sources */, 4DACC9AC2990F29A00B55913 /* attmodule.cpp in Sources */, - 4DC12A7E1F740FB9000440E9 /* view_running.cpp in Sources */, 8F3DD32218854AFB0051330C /* svgdevicecontext.cpp in Sources */, 4DCA95D91A515D0E008AD7E9 /* editorial.cpp in Sources */, 4DA80D971A6ACF5D0089802D /* options.cpp in Sources */, @@ -4860,7 +4851,6 @@ 4DACC9E52990F29A00B55913 /* atts_midi.cpp in Sources */, BB4C4AE922A932BC001F6AF0 /* del.cpp in Sources */, BB4C4B7122A932D7001F6AF0 /* rest.cpp in Sources */, - BB4C4BB222A932EB001F6AF0 /* view_running.cpp in Sources */, BB4C4B9D22A932E5001F6AF0 /* plistinterface.cpp in Sources */, BB4C4B8522A932DF001F6AF0 /* lb.cpp in Sources */, BB4C4AA322A9328F001F6AF0 /* vrv.cpp in Sources */, diff --git a/include/vrv/view.h b/include/vrv/view.h index 99be5bb8683..354dd167fc3 100644 --- a/include/vrv/view.h +++ b/include/vrv/view.h @@ -240,13 +240,12 @@ class View { ///@} /** - * @name Methods for drawing RunningElements (PgHead, PgFoot, etc.) - * Defined in view_running.cpp + * @name Methods for drawing TextLayoutElement (Div, PgHead, PgFoot, etc.) + * Defined in view_text.cpp */ ///@{ void DrawDiv(DeviceContext *dc, Div *div, System *system); void DrawRunningElements(DeviceContext *dc, Page *page); - void DrawPgFooter(DeviceContext *dc, RunningElement *pgFooter); void DrawTextLayoutElement(DeviceContext *dc, TextLayoutElement *textLayoutElement); ///@} diff --git a/src/view_running.cpp b/src/view_running.cpp deleted file mode 100644 index 6f0fd12a2ee..00000000000 --- a/src/view_running.cpp +++ /dev/null @@ -1,91 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: view_running.cpp -// Author: Laurent Pugin -// Created: 2017 -// Copyright (c) Authors and others. All rights reserved. -///////////////////////////////////////////////////////////////////////////// - -#include "view.h" - -//---------------------------------------------------------------------------- - -#include - -//---------------------------------------------------------------------------- - -#include "bboxdevicecontext.h" -#include "devicecontext.h" -#include "div.h" -#include "doc.h" -#include "page.h" -#include "pgfoot.h" -#include "pgfoot2.h" -#include "pghead.h" -#include "pghead2.h" -#include "text.h" -#include "vrv.h" - -namespace vrv { - -void View::DrawRunningElements(DeviceContext *dc, Page *page) -{ - assert(dc); - assert(page); - - if (dc->Is(BBOX_DEVICE_CONTEXT)) { - BBoxDeviceContext *bBoxDC = vrv_cast(dc); - assert(bBoxDC); - if (!bBoxDC->UpdateVerticalValues()) return; - } - - RunningElement *header = page->GetHeader(); - if (header) { - this->DrawTextLayoutElement(dc, header); - } - RunningElement *footer = page->GetFooter(); - if (footer) { - this->DrawTextLayoutElement(dc, footer); - } -} - -void View::DrawTextLayoutElement(DeviceContext *dc, TextLayoutElement *textLayoutElement) -{ - assert(dc); - assert(textLayoutElement); - - dc->StartGraphic(textLayoutElement, "", textLayoutElement->GetID()); - - FontInfo textElementFont; - if (!dc->UseGlobalStyling()) { - textElementFont.SetFaceName("Times"); - } - - TextDrawingParams params; - - // If we have not timestamp - params.m_x = textLayoutElement->GetDrawingX(); - params.m_y = textLayoutElement->GetDrawingY(); - params.m_width = textLayoutElement->GetTotalWidth(m_doc); - params.m_alignment = HORIZONTALALIGNMENT_NONE; - params.m_laidOut = true; - params.m_pointSize = m_doc->GetDrawingLyricFont(100)->GetPointSize(); - - textElementFont.SetPointSize(params.m_pointSize); - - dc->SetBrush(m_currentColor, AxSOLID); - dc->SetFont(&textElementFont); - - this->DrawRunningChildren(dc, textLayoutElement, params); - - dc->ResetFont(); - dc->ResetBrush(); - - dc->EndGraphic(textLayoutElement, this); -} - -void View::DrawDiv(DeviceContext *dc, Div *div, System *system) -{ - this->DrawTextLayoutElement(dc, div); -} - -} // namespace vrv diff --git a/src/view_text.cpp b/src/view_text.cpp index 56ab13022d8..9dbd2e7f7ba 100644 --- a/src/view_text.cpp +++ b/src/view_text.cpp @@ -16,7 +16,9 @@ //---------------------------------------------------------------------------- +#include "bboxdevicecontext.h" #include "devicecontext.h" +#include "div.h" #include "doc.h" #include "dynam.h" #include "f.h" @@ -26,6 +28,11 @@ #include "lb.h" #include "num.h" #include "options.h" +#include "page.h" +#include "pgfoot.h" +#include "pgfoot2.h" +#include "pghead.h" +#include "pghead2.h" #include "rend.h" #include "smufl.h" #include "staff.h" @@ -623,4 +630,65 @@ void View::DrawSymbol(DeviceContext *dc, Symbol *symbol, TextDrawingParams ¶ dc->EndTextGraphic(symbol, this); } +void View::DrawRunningElements(DeviceContext *dc, Page *page) +{ + assert(dc); + assert(page); + + if (dc->Is(BBOX_DEVICE_CONTEXT)) { + BBoxDeviceContext *bBoxDC = vrv_cast(dc); + assert(bBoxDC); + if (!bBoxDC->UpdateVerticalValues()) return; + } + + RunningElement *header = page->GetHeader(); + if (header) { + this->DrawTextLayoutElement(dc, header); + } + RunningElement *footer = page->GetFooter(); + if (footer) { + this->DrawTextLayoutElement(dc, footer); + } +} + +void View::DrawTextLayoutElement(DeviceContext *dc, TextLayoutElement *textLayoutElement) +{ + assert(dc); + assert(textLayoutElement); + + dc->StartGraphic(textLayoutElement, "", textLayoutElement->GetID()); + + FontInfo textElementFont; + if (!dc->UseGlobalStyling()) { + textElementFont.SetFaceName("Times"); + } + + TextDrawingParams params; + + // If we have not timestamp + params.m_x = textLayoutElement->GetDrawingX(); + params.m_y = textLayoutElement->GetDrawingY(); + params.m_width = textLayoutElement->GetTotalWidth(m_doc); + params.m_alignment = HORIZONTALALIGNMENT_NONE; + params.m_laidOut = true; + params.m_pointSize = m_doc->GetDrawingLyricFont(100)->GetPointSize(); + + textElementFont.SetPointSize(params.m_pointSize); + + dc->SetBrush(m_currentColor, AxSOLID); + dc->SetFont(&textElementFont); + + this->DrawRunningChildren(dc, textLayoutElement, params); + + dc->ResetFont(); + dc->ResetBrush(); + + dc->EndGraphic(textLayoutElement, this); +} + +void View::DrawDiv(DeviceContext *dc, Div *div, System *system) +{ + this->DrawTextLayoutElement(dc, div); +} + } // namespace vrv From 654a2c8ab5fc57bbd8ae5a5f2f7443b2fc682b08 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Mon, 5 Jun 2023 09:11:25 +0200 Subject: [PATCH 19/36] Add input filter for Div parent --- src/iomei.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/iomei.cpp b/src/iomei.cpp index 88511664184..0780ce3d898 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -3473,7 +3473,7 @@ bool MEIInput::IsAllowed(std::string element, Object *filterParent) } } // filter for any other control element - else if (filterParent->IsRunningElement()) { + else if (filterParent->IsRunningElement() || filterParent->Is(DIV)) { if (element == "fig") { return true; } From b6f8e50a9f66491da362a46aa99ea905c9531028 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Mon, 5 Jun 2023 09:11:50 +0200 Subject: [PATCH 20/36] Basic cast off for automatic layout --- src/castofffunctor.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/castofffunctor.cpp b/src/castofffunctor.cpp index 88d5765c0c7..7a9f887dc75 100644 --- a/src/castofffunctor.cpp +++ b/src/castofffunctor.cpp @@ -33,9 +33,18 @@ namespace vrv { FunctorCode CastOffSystemsFunctor::VisitDiv(Div *div) { - assert(m_currentSystem); + // If we have a previous a Measure or a Div in the System, add a new one + if ((m_currentSystem->GetChildCount(MEASURE) > 0) || (m_currentSystem->GetChildCount(DIV)) > 0) { + m_currentSystem = new System(); + m_page->AddChild(m_currentSystem); + } + div->MoveItselfTo(m_currentSystem); + // Always add a System after an Div + m_currentSystem = new System(); + m_page->AddChild(m_currentSystem); + return FUNCTOR_SIBLINGS; } From cc684720d7a321b3510579b12d59c236b63d099a Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Mon, 5 Jun 2023 11:07:22 +0200 Subject: [PATCH 21/36] Adjust functors for setting and resetting inline div --- include/vrv/alignfunctor.h | 1 + include/vrv/preparedatafunctor.h | 1 + include/vrv/resetfunctor.h | 2 ++ src/alignfunctor.cpp | 9 +++++++++ src/preparedatafunctor.cpp | 11 +++++++++++ src/resetfunctor.cpp | 22 ++++++++++++++++++++++ 6 files changed, 46 insertions(+) diff --git a/include/vrv/alignfunctor.h b/include/vrv/alignfunctor.h index d36b11fc87f..78d4f841e4f 100644 --- a/include/vrv/alignfunctor.h +++ b/include/vrv/alignfunctor.h @@ -108,6 +108,7 @@ class AlignMeasuresFunctor : public DocFunctor { * Functor interface */ ///@{ + FunctorCode VisitDiv(Div *div) override; FunctorCode VisitMeasure(Measure *measure) override; FunctorCode VisitScoreDef(ScoreDef *scoreDef) override; FunctorCode VisitSection(Section *section) override; diff --git a/include/vrv/preparedatafunctor.h b/include/vrv/preparedatafunctor.h index e479a786efb..87bc55e6b03 100644 --- a/include/vrv/preparedatafunctor.h +++ b/include/vrv/preparedatafunctor.h @@ -42,6 +42,7 @@ class PrepareDataInitializationFunctor : public DocFunctor { * Functor interface */ ///@{ + FunctorCode VisitDiv(Div *div) override; FunctorCode VisitChord(Chord *chord) override; FunctorCode VisitFloatingObject(FloatingObject *floatingObject) override; FunctorCode VisitKeySig(KeySig *keySig) override; diff --git a/include/vrv/resetfunctor.h b/include/vrv/resetfunctor.h index 09ad003db65..82133f6ca80 100644 --- a/include/vrv/resetfunctor.h +++ b/include/vrv/resetfunctor.h @@ -46,6 +46,7 @@ class ResetDataFunctor : public Functor { FunctorCode VisitChord(Chord *chord) override; FunctorCode VisitControlElement(ControlElement *controlElement) override; FunctorCode VisitCustos(Custos *custos) override; + FunctorCode VisitDiv(Div *div) override; FunctorCode VisitDot(Dot *dot) override; FunctorCode VisitDots(Dots *dots) override; FunctorCode VisitEditorialElement(EditorialElement *editorialElement) override; @@ -115,6 +116,7 @@ class ResetHorizontalAlignmentFunctor : public Functor { FunctorCode VisitBeam(Beam *beam) override; FunctorCode VisitBeamSpan(BeamSpan *beamSpan) override; FunctorCode VisitCustos(Custos *custos) override; + FunctorCode VisitDiv(Div *div) override; FunctorCode VisitDot(Dot *dot) override; FunctorCode VisitDots(Dots *dots) override; FunctorCode VisitFloatingObject(FloatingObject *floatingObject) override; diff --git a/src/alignfunctor.cpp b/src/alignfunctor.cpp index 8cac950b916..67a1ac84bd7 100644 --- a/src/alignfunctor.cpp +++ b/src/alignfunctor.cpp @@ -416,6 +416,15 @@ AlignMeasuresFunctor::AlignMeasuresFunctor(Doc *doc) : DocFunctor(doc) m_storeCastOffSystemWidths = false; } +FunctorCode AlignMeasuresFunctor::VisitDiv(Div *div) +{ + if (div->GetDrawingInline()) div->SetDrawingXRel(m_shift); + + m_shift += div->GetContentWidth(); + + return FUNCTOR_SIBLINGS; +} + FunctorCode AlignMeasuresFunctor::VisitMeasure(Measure *measure) { if (m_applySectionRestartShift) { diff --git a/src/preparedatafunctor.cpp b/src/preparedatafunctor.cpp index 20f2505287d..b030d44b4be 100644 --- a/src/preparedatafunctor.cpp +++ b/src/preparedatafunctor.cpp @@ -55,6 +55,17 @@ namespace vrv { PrepareDataInitializationFunctor::PrepareDataInitializationFunctor(Doc *doc) : DocFunctor(doc) {} +FunctorCode PrepareDataInitializationFunctor::VisitDiv(Div *div) +{ + this->VisitTextLayoutElement(div); + + if (m_doc->GetOptions()->m_breaks.GetValue() == BREAKS_none) { + div->SetDrawingInline(true); + } + + return FUNCTOR_CONTINUE; +} + FunctorCode PrepareDataInitializationFunctor::VisitChord(Chord *chord) { if (chord->HasEmptyList(chord)) { diff --git a/src/resetfunctor.cpp b/src/resetfunctor.cpp index afbc96b3113..321f163ec14 100644 --- a/src/resetfunctor.cpp +++ b/src/resetfunctor.cpp @@ -12,6 +12,7 @@ #include "arpeg.h" #include "beamspan.h" #include "custos.h" +#include "div.h" #include "dot.h" #include "editorial.h" #include "elementpart.h" @@ -33,6 +34,7 @@ #include "syl.h" #include "system.h" #include "tempo.h" +#include "textlayoutelement.h" #include "tuplet.h" #include "turn.h" #include "verse.h" @@ -144,6 +146,16 @@ FunctorCode ResetDataFunctor::VisitCustos(Custos *custos) return FUNCTOR_CONTINUE; } +FunctorCode ResetDataFunctor::VisitDiv(Div *div) +{ + // Call parent one too + this->VisitObject(div); + + div->SetDrawingInline(false); + + return FUNCTOR_CONTINUE; +} + FunctorCode ResetDataFunctor::VisitDot(Dot *dot) { // Call parent one too @@ -471,6 +483,16 @@ FunctorCode ResetHorizontalAlignmentFunctor::VisitCustos(Custos *custos) return FUNCTOR_CONTINUE; } +FunctorCode ResetHorizontalAlignmentFunctor::VisitDiv(Div *div) +{ + this->VisitTextLayoutElement(div); + + div->SetDrawingXRel(0); + div->SetDrawingYRel(0); + + return FUNCTOR_CONTINUE; +} + FunctorCode ResetHorizontalAlignmentFunctor::VisitDot(Dot *dot) { this->VisitLayerElement(dot); From 6ea1879b1d8042e46be4577f2301b012d897a717 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Mon, 5 Jun 2023 11:07:45 +0200 Subject: [PATCH 22/36] Add member to Div to handle inline div --- include/vrv/div.h | 45 +++++++++++++++++++++++++++- include/vrv/textlayoutelement.h | 14 +++++---- src/div.cpp | 40 ++++++++++++++++++++++++- src/textlayoutelement.cpp | 52 +++++++++++++++++++++++++++++++++ 4 files changed, 144 insertions(+), 7 deletions(-) diff --git a/include/vrv/div.h b/include/vrv/div.h index 23df3beecdc..55e9e754721 100644 --- a/include/vrv/div.h +++ b/include/vrv/div.h @@ -32,6 +32,34 @@ class Div : public TextLayoutElement { std::string GetClassName() const override { return "Div"; } ///@} + /** + * @name Get and set the inline drawing flag + */ + ///@{ + bool GetDrawingInline() const { return m_drawingInline; } + void SetDrawingInline(bool drawingInline) { m_drawingInline = drawingInline; } + ///@} + + /** + * @name Get the X and Y drawing position + */ + ///@{ + int GetDrawingX() const override; + int GetDrawingY() const override; + ///@} + + /** + * @name Get and set the X and Y drawing relative positions + */ + ///@{ + int GetDrawingXRel() const { return m_drawingXRel; } + virtual void SetDrawingXRel(int drawingXRel); + void CacheXRel(bool restore = false); + int GetDrawingYRel() const { return m_drawingYRel; } + virtual void SetDrawingYRel(int drawingYRel); + void CacheYRel(bool restore = false); + ///@} + /** * Overriden to get the appropriate margin */ @@ -58,7 +86,22 @@ class Div : public TextLayoutElement { public: // private: - // + /** + * The Y drawing relative position of the object. + * It is re-computed everytime the object is drawn and it is not stored in the file. + */ + int m_drawingYRel; + + /** + * The X drawing relative position of the object. + * It is re-computed everytime the object is drawn and it is not stored in the file. + */ + int m_drawingXRel; + + /** + * A flag indicating that the div should be displayed inline + */ + bool m_drawingInline; }; } // namespace vrv diff --git a/include/vrv/textlayoutelement.h b/include/vrv/textlayoutelement.h index 636de08e5b8..4dcf20978b8 100644 --- a/include/vrv/textlayoutelement.h +++ b/include/vrv/textlayoutelement.h @@ -81,12 +81,16 @@ class TextLayoutElement : public Object, public ObjectListInterface, public AttT int GetColHeight(int col) const; /** Row from 0 to 8 */ int GetCellHeight(int cell) const; - ///@} - - /** - * - */ + // Width including margins */ virtual int GetTotalWidth(const Doc *doc) const = 0; + /** Content width */ + int GetContentWidth() const; + /** Row from 0 to 2 */ + int GetRowWidth(int col) const; + /** Col from 0 to 2 */ + int GetColWidth(int col) const; + /** Row from 0 to 8 */ + int GetCellWidth(int cell) const; /** * Calculate the cell position diff --git a/src/div.cpp b/src/div.cpp index 9c82247fd06..271f875d1bb 100644 --- a/src/div.cpp +++ b/src/div.cpp @@ -35,6 +35,38 @@ Div::~Div() {} void Div::Reset() { TextLayoutElement::Reset(); + + m_drawingInline = false; +} + +int Div::GetDrawingX() const +{ + const Object *parent = this->GetParent(); + assert(parent); + if (m_drawingInline && parent) { + return parent->GetDrawingX() + this->GetDrawingXRel(); + } + return parent->GetDrawingX(); +} + +int Div::GetDrawingY() const +{ + const Object *parent = this->GetParent(); + assert(parent); + if (m_drawingInline) { + return parent->GetDrawingY() + this->GetDrawingYRel(); + } + return parent->GetDrawingY(); +} + +void Div::SetDrawingXRel(int drawingXRel) +{ + m_drawingXRel = drawingXRel; +} + +void Div::SetDrawingYRel(int drawingYRel) +{ + m_drawingYRel = drawingYRel; } int Div::GetTotalHeight(const Doc *doc) const @@ -48,7 +80,13 @@ int Div::GetTotalHeight(const Doc *doc) const int Div::GetTotalWidth(const Doc *doc) const { - return (doc->m_drawingPageContentWidth); + if (!m_drawingInline) { + return (doc->m_drawingPageContentWidth); + } + else { + int width = this->GetContentWidth(); + return width; + } } //---------------------------------------------------------------------------- diff --git a/src/textlayoutelement.cpp b/src/textlayoutelement.cpp index cbbe6b3a536..d761ad55abc 100644 --- a/src/textlayoutelement.cpp +++ b/src/textlayoutelement.cpp @@ -98,6 +98,15 @@ int TextLayoutElement::GetContentHeight() const return height; } +int TextLayoutElement::GetContentWidth() const +{ + int width = 0; + for (int i = 0; i < 3; ++i) { + width = std::max(width, this->GetRowWidth(i)); + } + return width; +} + int TextLayoutElement::GetRowHeight(int row) const { assert((row >= 0) && (row < 3)); @@ -135,6 +144,49 @@ int TextLayoutElement::GetCellHeight(int cell) const return columnHeight; } +int TextLayoutElement::GetRowWidth(int row) const +{ + assert((row >= 0) && (row < 3)); + + const int col0 = (this->GetCellWidth(row * 3) > 0); + const int col1 = (this->GetCellWidth(row * 3 + 1) > 0); + const int col2 = (this->GetCellWidth(row * 3 + 2) > 0); + + int width = 0; + for (int i = 0; i < 3; ++i) { + width = std::max(width, this->GetCellWidth(row * 3 + i)); + } + // If we have someting in the middle column, ensure 3 times the max col width + // Oterwise the maximum width for the number of columns + return (col1 && (col0 || col2)) ? width * 3 : width * (col0 + col1 + col2); +} + +int TextLayoutElement::GetColWidth(int col) const +{ + assert((col >= 0) && (col < 3)); + + int width = 0; + for (int i = 0; i < 3; ++i) { + width = std::max(width, this->GetCellWidth(i * 3 + col)); + } + return width; +} + +int TextLayoutElement::GetCellWidth(int cell) const +{ + assert((cell >= 0) && (cell < 9)); + + int columWidth = 0; + const ArrayOfTextElements *textElements = &m_cells[cell]; + ArrayOfTextElements::const_iterator iter; + for (iter = textElements->begin(); iter != textElements->end(); ++iter) { + if ((*iter)->HasContentBB()) { + columWidth = std::max(columWidth, (*iter)->GetContentX2() - (*iter)->GetContentX1()); + } + } + return columWidth; +} + bool TextLayoutElement::AdjustDrawingScaling(int width) { bool scale = false; From 6cc2402be51aa077b165af1b9ca86a8d4a03365d Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Mon, 5 Jun 2023 11:10:40 +0200 Subject: [PATCH 23/36] Fix formatting --- src/resetfunctor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resetfunctor.cpp b/src/resetfunctor.cpp index 321f163ec14..2d373a7e062 100644 --- a/src/resetfunctor.cpp +++ b/src/resetfunctor.cpp @@ -489,7 +489,7 @@ FunctorCode ResetHorizontalAlignmentFunctor::VisitDiv(Div *div) div->SetDrawingXRel(0); div->SetDrawingYRel(0); - + return FUNCTOR_CONTINUE; } From 27449ab893b3f0aa7890e91a87ec70a1e67994d4 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 30 Jun 2023 08:17:50 +0200 Subject: [PATCH 24/36] Add comment for invalid MEI current state --- include/vrv/div.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/vrv/div.h b/include/vrv/div.h index 55e9e754721..9ba84946929 100644 --- a/include/vrv/div.h +++ b/include/vrv/div.h @@ -18,6 +18,8 @@ namespace vrv { /** * This class represents an MEI Div. + * The current implementation accepts as child of
, which is not valid + * See https://github.com/music-encoding/music-encoding/issues/1189 */ class Div : public TextLayoutElement { public: From b7c05f4432960cead4b7b8f32cfff456f8a29d27 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 30 Jun 2023 15:01:01 +0200 Subject: [PATCH 25/36] Remove PgHead2 and PgFoot2 (WIP) --- Verovio.xcodeproj/project.pbxproj | 32 ------------- include/vrv/functorinterface.h | 10 ----- include/vrv/pgfoot2.h | 64 -------------------------- include/vrv/view.h | 2 - include/vrv/vrvdef.h | 2 - src/functorinterface.cpp | 42 ----------------- src/pgfoot2.cpp | 75 ------------------------------- src/view_text.cpp | 2 - 8 files changed, 229 deletions(-) delete mode 100644 include/vrv/pgfoot2.h delete mode 100644 src/pgfoot2.cpp diff --git a/Verovio.xcodeproj/project.pbxproj b/Verovio.xcodeproj/project.pbxproj index 438895865a4..897d4be93e6 100644 --- a/Verovio.xcodeproj/project.pbxproj +++ b/Verovio.xcodeproj/project.pbxproj @@ -737,10 +737,6 @@ 4DC12A591F716E27000440E9 /* pghead.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A581F716E27000440E9 /* pghead.cpp */; }; 4DC12A5A1F716E27000440E9 /* pghead.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A581F716E27000440E9 /* pghead.cpp */; }; 4DC12A5B1F716E27000440E9 /* pghead.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A581F716E27000440E9 /* pghead.cpp */; }; - 4DC12A5D1F73F888000440E9 /* pghead2.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DC12A5C1F73F888000440E9 /* pghead2.h */; }; - 4DC12A631F73F898000440E9 /* pghead2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A621F73F898000440E9 /* pghead2.cpp */; }; - 4DC12A641F73F898000440E9 /* pghead2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A621F73F898000440E9 /* pghead2.cpp */; }; - 4DC12A651F73F898000440E9 /* pghead2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A621F73F898000440E9 /* pghead2.cpp */; }; 4DC12A751F73FF92000440E9 /* runningelement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DC12A741F73FF92000440E9 /* runningelement.h */; }; 4DC12A781F7400B9000440E9 /* runningelement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A771F7400B9000440E9 /* runningelement.cpp */; }; 4DC12A791F7400B9000440E9 /* runningelement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A771F7400B9000440E9 /* runningelement.cpp */; }; @@ -748,11 +744,7 @@ 4DC12A811F741110000440E9 /* pgfoot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A7F1F741110000440E9 /* pgfoot.cpp */; }; 4DC12A821F741110000440E9 /* pgfoot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A7F1F741110000440E9 /* pgfoot.cpp */; }; 4DC12A831F741110000440E9 /* pgfoot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A7F1F741110000440E9 /* pgfoot.cpp */; }; - 4DC12A841F741110000440E9 /* pgfoot2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A801F741110000440E9 /* pgfoot2.cpp */; }; - 4DC12A851F741110000440E9 /* pgfoot2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A801F741110000440E9 /* pgfoot2.cpp */; }; - 4DC12A861F741110000440E9 /* pgfoot2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A801F741110000440E9 /* pgfoot2.cpp */; }; 4DC12A891F74111E000440E9 /* pgfoot.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DC12A871F74111E000440E9 /* pgfoot.h */; }; - 4DC12A8A1F74111E000440E9 /* pgfoot2.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DC12A881F74111E000440E9 /* pgfoot2.h */; }; 4DC34BA219BC4A71006175CD /* accid.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DC34B9F19BC4A70006175CD /* accid.h */; }; 4DC34BA319BC4A71006175CD /* custos.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DC34BA019BC4A70006175CD /* custos.h */; }; 4DC34BA419BC4A71006175CD /* dot.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DC34BA119BC4A70006175CD /* dot.h */; }; @@ -1142,12 +1134,8 @@ BB4C4B0422A932C3001F6AF0 /* runningelement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DC12A741F73FF92000440E9 /* runningelement.h */; settings = {ATTRIBUTES = (Public, ); }; }; BB4C4B0522A932C3001F6AF0 /* pgfoot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A7F1F741110000440E9 /* pgfoot.cpp */; }; BB4C4B0622A932C3001F6AF0 /* pgfoot.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DC12A871F74111E000440E9 /* pgfoot.h */; settings = {ATTRIBUTES = (Public, ); }; }; - BB4C4B0722A932C3001F6AF0 /* pgfoot2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A801F741110000440E9 /* pgfoot2.cpp */; }; - BB4C4B0822A932C3001F6AF0 /* pgfoot2.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DC12A881F74111E000440E9 /* pgfoot2.h */; settings = {ATTRIBUTES = (Public, ); }; }; BB4C4B0922A932C3001F6AF0 /* pghead.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A581F716E27000440E9 /* pghead.cpp */; }; BB4C4B0A22A932C3001F6AF0 /* pghead.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DC12A561F716E1C000440E9 /* pghead.h */; settings = {ATTRIBUTES = (Public, ); }; }; - BB4C4B0B22A932C3001F6AF0 /* pghead2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DC12A621F73F898000440E9 /* pghead2.cpp */; }; - BB4C4B0C22A932C3001F6AF0 /* pghead2.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DC12A5C1F73F888000440E9 /* pghead2.h */; settings = {ATTRIBUTES = (Public, ); }; }; BB4C4B0D22A932C8001F6AF0 /* systemmilestone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DF4407C1D511D0200152B7E /* systemmilestone.cpp */; }; BB4C4B0E22A932C8001F6AF0 /* systemmilestone.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DF4407B1D511CEE00152B7E /* systemmilestone.h */; settings = {ATTRIBUTES = (Public, ); }; }; BB4C4B0F22A932C8001F6AF0 /* ending.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DF440761D39575500152B7E /* ending.cpp */; }; @@ -1981,14 +1969,10 @@ 4DBDD6702939E1AE009EC466 /* symboldef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = symboldef.cpp; path = src/symboldef.cpp; sourceTree = ""; }; 4DC12A561F716E1C000440E9 /* pghead.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pghead.h; path = include/vrv/pghead.h; sourceTree = ""; }; 4DC12A581F716E27000440E9 /* pghead.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = pghead.cpp; path = src/pghead.cpp; sourceTree = ""; }; - 4DC12A5C1F73F888000440E9 /* pghead2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pghead2.h; path = include/vrv/pghead2.h; sourceTree = ""; }; - 4DC12A621F73F898000440E9 /* pghead2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = pghead2.cpp; path = src/pghead2.cpp; sourceTree = ""; }; 4DC12A741F73FF92000440E9 /* runningelement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = runningelement.h; path = include/vrv/runningelement.h; sourceTree = ""; }; 4DC12A771F7400B9000440E9 /* runningelement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = runningelement.cpp; path = src/runningelement.cpp; sourceTree = ""; }; 4DC12A7F1F741110000440E9 /* pgfoot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = pgfoot.cpp; path = src/pgfoot.cpp; sourceTree = ""; }; - 4DC12A801F741110000440E9 /* pgfoot2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = pgfoot2.cpp; path = src/pgfoot2.cpp; sourceTree = ""; }; 4DC12A871F74111E000440E9 /* pgfoot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pgfoot.h; path = include/vrv/pgfoot.h; sourceTree = ""; }; - 4DC12A881F74111E000440E9 /* pgfoot2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pgfoot2.h; path = include/vrv/pgfoot2.h; sourceTree = ""; }; 4DC34B9F19BC4A70006175CD /* accid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = accid.h; path = include/vrv/accid.h; sourceTree = ""; }; 4DC34BA019BC4A70006175CD /* custos.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = custos.h; path = include/vrv/custos.h; sourceTree = ""; }; 4DC34BA119BC4A70006175CD /* dot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = dot.h; path = include/vrv/dot.h; sourceTree = ""; }; @@ -2596,12 +2580,8 @@ 4DC12A741F73FF92000440E9 /* runningelement.h */, 4DC12A7F1F741110000440E9 /* pgfoot.cpp */, 4DC12A871F74111E000440E9 /* pgfoot.h */, - 4DC12A801F741110000440E9 /* pgfoot2.cpp */, - 4DC12A881F74111E000440E9 /* pgfoot2.h */, 4DC12A581F716E27000440E9 /* pghead.cpp */, 4DC12A561F716E1C000440E9 /* pghead.h */, - 4DC12A621F73F898000440E9 /* pghead2.cpp */, - 4DC12A5C1F73F888000440E9 /* pghead2.h */, 4D1EB6A02A2A40B400AF2F98 /* textlayoutelement.cpp */, 4D1EB6A52A2A40CB00AF2F98 /* textlayoutelement.h */, ); @@ -3185,7 +3165,6 @@ 403BEFF1206C00D500D022D5 /* mrpt2.h in Headers */, 4DC12A571F716E1C000440E9 /* pghead.h in Headers */, 4DA0EADF22BB77AF00A7EBEB /* facsimileinterface.h in Headers */, - 4DC12A8A1F74111E000440E9 /* pgfoot2.h in Headers */, 8F59294018854BF800FE51AD /* iomei.h in Headers */, 4DACC9A02990F29A00B55913 /* atts_gestural.h in Headers */, 4DACC9CC2990F29A00B55913 /* attclasses.h in Headers */, @@ -3220,7 +3199,6 @@ 4DACCA172990F2E600B55913 /* attdef.h in Headers */, 4DB3D8EC1F83D18300B5FC2B /* proport.h in Headers */, 4DEC4DDE21C8295700D1D273 /* lem.h in Headers */, - 4DC12A5D1F73F888000440E9 /* pghead2.h in Headers */, E778BDAE29D5BD3D00672D51 /* adjuststaffoverlapfunctor.h in Headers */, E7E9C11A29B0EF9600CFCE2F /* adjusttempofunctor.h in Headers */, 8F59294518854BF800FE51AD /* layerelement.h in Headers */, @@ -3551,7 +3529,6 @@ BB4C4AB422A932A6001F6AF0 /* iohumdrum.h in Headers */, 40ACDEA724079F6900F82B8C /* reh.h in Headers */, BB4C4B6822A932D7001F6AF0 /* multirpt.h in Headers */, - BB4C4B0822A932C3001F6AF0 /* pgfoot2.h in Headers */, 4D94E0E32995411100F49F89 /* meibasic.h in Headers */, 4DA0EAD822BB77AF00A7EBEB /* editortoolkit_cmn.h in Headers */, 4DACCA102990F2E600B55913 /* att.h in Headers */, @@ -3559,7 +3536,6 @@ BB4C4AF222A932BC001F6AF0 /* orig.h in Headers */, E7A03CD229D6172D00C02941 /* adjusttupletsyfunctor.h in Headers */, BB4C4AD622A932B6001F6AF0 /* staffgrp.h in Headers */, - BB4C4B0C22A932C3001F6AF0 /* pghead2.h in Headers */, 4DACC9F72990F29A00B55913 /* atts_mensural.h in Headers */, BB4C4ACE22A932B6001F6AF0 /* sb.h in Headers */, 4DA0EADA22BB77AF00A7EBEB /* facsimile.h in Headers */, @@ -3870,7 +3846,6 @@ 4DEC4DB321C826E000D1D273 /* supplied.cpp in Sources */, E7E1698729A898CE00FFF482 /* adjustlayersfunctor.cpp in Sources */, E7ED8A6929C111CA00735875 /* cachehorizontallayoutfunctor.cpp in Sources */, - 4DC12A851F741110000440E9 /* pgfoot2.cpp in Sources */, 40E1CEE0205060FD0007C8AF /* labelabbr.cpp in Sources */, 35F6580F24F92B6100C99A2D /* fing.cpp in Sources */, 4D1693FA1E3A44F300569BF4 /* clef.cpp in Sources */, @@ -3962,7 +3937,6 @@ 4D16946A1E3A455100569BF4 /* humlib.cpp in Sources */, 4D72A5E3208A3822009DEC1E /* beatrpt.cpp in Sources */, 4D16941A1E3A44F300569BF4 /* view_text.cpp in Sources */, - 4DC12A641F73F898000440E9 /* pghead2.cpp in Sources */, 4D94722020CA702C00C780C8 /* linkinginterface.cpp in Sources */, 4DEC4DAB21C81EEC00D1D273 /* restore.cpp in Sources */, 4D766EFE20ACAD6D006875D8 /* nc.cpp in Sources */, @@ -4168,7 +4142,6 @@ E78F204A29D98D2300CD5910 /* adjustxrelfortranscriptionfunctor.cpp in Sources */, 4DFD82FB2A38398200A3E20B /* repeatmark.cpp in Sources */, 4DACC9FC2990F29A00B55913 /* atts_fingering.cpp in Sources */, - 4DC12A631F73F898000440E9 /* pghead2.cpp in Sources */, 4DACC9EC2990F29A00B55913 /* atts_shared.cpp in Sources */, 4DA0EAEA22BB77C300A7EBEB /* editortoolkit_neume.cpp in Sources */, 4D95D4FC1D74551100B2B856 /* score.cpp in Sources */, @@ -4260,7 +4233,6 @@ 8F086EF8188539540037FD8E /* note.cpp in Sources */, 409B3DD91F2D1C2A0098A265 /* ftrem.cpp in Sources */, 4D5FA9111E16A93F00F3B919 /* boundingbox.cpp in Sources */, - 4DC12A841F741110000440E9 /* pgfoot2.cpp in Sources */, 8F086EF9188539540037FD8E /* object.cpp in Sources */, 4DD7C10227A5650600B9C017 /* timemap.cpp in Sources */, E797C460298EC2C600CAD67E /* calcalignmentpitchposfunctor.cpp in Sources */, @@ -4425,7 +4397,6 @@ 8F3DD36718854B410051330C /* verticalaligner.cpp in Sources */, 4D766F0220ACAD6E006875D8 /* nc.cpp in Sources */, 4DEC4D9821C81E3B00D1D273 /* expan.cpp in Sources */, - 4DC12A651F73F898000440E9 /* pghead2.cpp in Sources */, 4D3C3F0E294B89AF009993E6 /* ornam.cpp in Sources */, E7770F8829D0DA2000A9BECF /* adjustslursfunctor.cpp in Sources */, 4DB3D8C81F83D10000B5FC2B /* dir.cpp in Sources */, @@ -4542,7 +4513,6 @@ 403BEFF2206C00D700D022D5 /* mrpt2.cpp in Sources */, 4D508C3226D4E64C00020F35 /* crc.cpp in Sources */, 8F3DD34E18854B2E0051330C /* pitchinterface.cpp in Sources */, - 4DC12A861F741110000440E9 /* pgfoot2.cpp in Sources */, E7D3389D293E05A800C40B81 /* setscoredeffunctor.cpp in Sources */, 4DA1448B1C2AB28700CB7CEE /* textelement.cpp in Sources */, 8F3DD35018854B2E0051330C /* positioninterface.cpp in Sources */, @@ -4728,7 +4698,6 @@ 4DACC98B2990F29A00B55913 /* atts_mei.cpp in Sources */, E787035A299CF07700156DC4 /* adjustarpegfunctor.cpp in Sources */, E76046C128D4829000C36204 /* calcledgerlinesfunctor.cpp in Sources */, - BB4C4B0B22A932C3001F6AF0 /* pghead2.cpp in Sources */, BB4C4BBA22A932FC001F6AF0 /* MidiEvent.cpp in Sources */, BB4C4B8B22A932DF001F6AF0 /* rend.cpp in Sources */, E7876F1B29C07F23002147DC /* adjustsylspacingfunctor.cpp in Sources */, @@ -4836,7 +4805,6 @@ E763EF4329E939FB0029E56D /* convertfunctor.cpp in Sources */, 4DA0EAF522BB77C300A7EBEB /* facsimileinterface.cpp in Sources */, 4DACCA052990F29A00B55913 /* atts_usersymbols.cpp in Sources */, - BB4C4B0722A932C3001F6AF0 /* pgfoot2.cpp in Sources */, BB4C4B6122A932D7001F6AF0 /* mrpt.cpp in Sources */, BB4C4AE722A932BC001F6AF0 /* damage.cpp in Sources */, 4DA0EACA22BB779400A7EBEB /* facsimile.cpp in Sources */, diff --git a/include/vrv/functorinterface.h b/include/vrv/functorinterface.h index 0e09cced309..38424282880 100644 --- a/include/vrv/functorinterface.h +++ b/include/vrv/functorinterface.h @@ -95,9 +95,7 @@ class Pages; class Pb; class Pedal; class PgFoot; -class PgFoot2; class PgHead; -class PgHead2; class Phrase; class PitchInflection; class Plica; @@ -235,12 +233,8 @@ class FunctorInterface { virtual FunctorCode VisitRunningElementEnd(RunningElement *runningElement); virtual FunctorCode VisitPgFoot(PgFoot *pgFoot); virtual FunctorCode VisitPgFootEnd(PgFoot *pgFoot); - virtual FunctorCode VisitPgFoot2(PgFoot2 *pgFoot2); - virtual FunctorCode VisitPgFoot2End(PgFoot2 *pgFoot2); virtual FunctorCode VisitPgHead(PgHead *pgHead); virtual FunctorCode VisitPgHeadEnd(PgHead *pgHead); - virtual FunctorCode VisitPgHead2(PgHead2 *pgHead2); - virtual FunctorCode VisitPgHead2End(PgHead2 *pgHead2); virtual FunctorCode VisitTextLayoutElement(TextLayoutElement *textLayoutElement); virtual FunctorCode VisitTextLayoutElementEnd(TextLayoutElement *textLayoutElement); ///@} @@ -596,12 +590,8 @@ class ConstFunctorInterface { virtual FunctorCode VisitRunningElementEnd(const RunningElement *runningElement); virtual FunctorCode VisitPgFoot(const PgFoot *pgFoot); virtual FunctorCode VisitPgFootEnd(const PgFoot *pgFoot); - virtual FunctorCode VisitPgFoot2(const PgFoot2 *pgFoot2); - virtual FunctorCode VisitPgFoot2End(const PgFoot2 *pgFoot2); virtual FunctorCode VisitPgHead(const PgHead *pgHead); virtual FunctorCode VisitPgHeadEnd(const PgHead *pgHead); - virtual FunctorCode VisitPgHead2(const PgHead2 *pgHead2); - virtual FunctorCode VisitPgHead2End(const PgHead2 *pgHead2); virtual FunctorCode VisitTextLayoutElement(const TextLayoutElement *textLayoutElement); virtual FunctorCode VisitTextLayoutElementEnd(const TextLayoutElement *textLayoutElement); ///@} diff --git a/include/vrv/pgfoot2.h b/include/vrv/pgfoot2.h deleted file mode 100644 index 00e938c02ed..00000000000 --- a/include/vrv/pgfoot2.h +++ /dev/null @@ -1,64 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: pgfoot2.h -// Author: Laurent Pugin -// Created: 2017 -// Copyright (c) Authors and others. All rights reserved. -///////////////////////////////////////////////////////////////////////////// - -#ifndef __VRV_PGFOOT2_H__ -#define __VRV_PGFOOT2_H__ - -#include "runningelement.h" - -namespace vrv { - -//---------------------------------------------------------------------------- -// PgFoot2 -//---------------------------------------------------------------------------- - -/** - * This class represents an MEI pgFoot2. - */ -class PgFoot2 : public RunningElement { -public: - /** - * @name Constructors, destructors, and other standard methods - * Reset method resets all attribute classes - */ - ///@{ - PgFoot2(); - virtual ~PgFoot2(); - void Reset() override; - std::string GetClassName() const override { return "PgFoot2"; } - ///@} - - /** - * Overriden to get the appropriate margin - */ - int GetTotalHeight(const Doc *doc) const override; - - //----------// - // Functors // - //----------// - - /** - * Interface for class functor visitation - */ - ///@{ - FunctorCode Accept(Functor &functor) override; - FunctorCode Accept(ConstFunctor &functor) const override; - FunctorCode AcceptEnd(Functor &functor) override; - FunctorCode AcceptEnd(ConstFunctor &functor) const override; - ///@} - -private: - // -public: - // -private: - // -}; - -} // namespace vrv - -#endif diff --git a/include/vrv/view.h b/include/vrv/view.h index 46d03974464..3168a31c261 100644 --- a/include/vrv/view.h +++ b/include/vrv/view.h @@ -62,9 +62,7 @@ class Page; class PageElement; class Pedal; class PgFoot; -class PgFoot; class PgHead; -class PgHead2; class PitchInflection; class Reh; class Rend; diff --git a/include/vrv/vrvdef.h b/include/vrv/vrvdef.h index 42d3d900052..04c83b2d557 100644 --- a/include/vrv/vrvdef.h +++ b/include/vrv/vrvdef.h @@ -158,9 +158,7 @@ enum ClassId : uint16_t { // Ids for RunningElement child classes RUNNING_ELEMENT, PGFOOT, - PGFOOT2, PGHEAD, - PGHEAD2, RUNNING_ELEMENT_max, TEXT_LAYOUT_ELEMENT_max, // Ids for PageElement child classes diff --git a/src/functorinterface.cpp b/src/functorinterface.cpp index e48129c3119..cbd6c259b0c 100644 --- a/src/functorinterface.cpp +++ b/src/functorinterface.cpp @@ -81,9 +81,7 @@ #include "pb.h" #include "pedal.h" #include "pgfoot.h" -#include "pgfoot2.h" #include "pghead.h" -#include "pghead2.h" #include "phrase.h" #include "pitchinflection.h" #include "plica.h" @@ -367,16 +365,6 @@ FunctorCode FunctorInterface::VisitPgHeadEnd(PgHead *pgHead) return this->VisitRunningElementEnd(pgHead); } -FunctorCode FunctorInterface::VisitPgHead2(PgHead2 *pgHead2) -{ - return this->VisitRunningElement(pgHead2); -} - -FunctorCode FunctorInterface::VisitPgHead2End(PgHead2 *pgHead2) -{ - return this->VisitRunningElementEnd(pgHead2); -} - FunctorCode FunctorInterface::VisitPgFoot(PgFoot *pgFoot) { return this->VisitRunningElement(pgFoot); @@ -387,16 +375,6 @@ FunctorCode FunctorInterface::VisitPgFootEnd(PgFoot *pgFoot) return this->VisitRunningElementEnd(pgFoot); } -FunctorCode FunctorInterface::VisitPgFoot2(PgFoot2 *pgFoot2) -{ - return this->VisitRunningElement(pgFoot2); -} - -FunctorCode FunctorInterface::VisitPgFoot2End(PgFoot2 *pgFoot2) -{ - return this->VisitRunningElementEnd(pgFoot2); -} - FunctorCode FunctorInterface::VisitTextLayoutElement(TextLayoutElement *textLayoutElement) { return this->VisitObject(textLayoutElement); @@ -1671,16 +1649,6 @@ FunctorCode ConstFunctorInterface::VisitPgHeadEnd(const PgHead *pgHead) return this->VisitRunningElementEnd(pgHead); } -FunctorCode ConstFunctorInterface::VisitPgHead2(const PgHead2 *pgHead2) -{ - return this->VisitRunningElement(pgHead2); -} - -FunctorCode ConstFunctorInterface::VisitPgHead2End(const PgHead2 *pgHead2) -{ - return this->VisitRunningElementEnd(pgHead2); -} - FunctorCode ConstFunctorInterface::VisitPgFoot(const PgFoot *pgFoot) { return this->VisitRunningElement(pgFoot); @@ -1691,16 +1659,6 @@ FunctorCode ConstFunctorInterface::VisitPgFootEnd(const PgFoot *pgFoot) return this->VisitRunningElementEnd(pgFoot); } -FunctorCode ConstFunctorInterface::VisitPgFoot2(const PgFoot2 *pgFoot2) -{ - return this->VisitRunningElement(pgFoot2); -} - -FunctorCode ConstFunctorInterface::VisitPgFoot2End(const PgFoot2 *pgFoot2) -{ - return this->VisitRunningElementEnd(pgFoot2); -} - FunctorCode ConstFunctorInterface::VisitTextLayoutElement(const TextLayoutElement *textLayoutElement) { return this->VisitObject(textLayoutElement); diff --git a/src/pgfoot2.cpp b/src/pgfoot2.cpp deleted file mode 100644 index 0f0f021ca63..00000000000 --- a/src/pgfoot2.cpp +++ /dev/null @@ -1,75 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: pgfoot2.cpp -// Author: Laurent Pugin -// Created: 2017 -// Copyright (c) Authors and others. All rights reserved. -///////////////////////////////////////////////////////////////////////////// - -#include "pgfoot2.h" - -//---------------------------------------------------------------------------- - -#include - -//---------------------------------------------------------------------------- - -#include "doc.h" -#include "functor.h" - -namespace vrv { - -//---------------------------------------------------------------------------- -// PgFoot2 -//---------------------------------------------------------------------------- - -static const ClassRegistrar s_factory("pgFoot2", PGFOOT2); - -PgFoot2::PgFoot2() : RunningElement(PGFOOT2, "pgfoot2-") -{ - this->Reset(); -} - -PgFoot2::~PgFoot2() {} - -void PgFoot2::Reset() -{ - RunningElement::Reset(); -} - -int PgFoot2::GetTotalHeight(const Doc *doc) const -{ - assert(doc); - - int height = this->GetContentHeight(); - if (height > 0) { - const int unit = doc->GetDrawingUnit(100); - height += doc->GetOptions()->m_topMarginPgFooter.GetValue() * unit; - } - return height; -} - -//---------------------------------------------------------------------------- -// Functor methods -//---------------------------------------------------------------------------- - -FunctorCode PgFoot2::Accept(Functor &functor) -{ - return functor.VisitPgFoot2(this); -} - -FunctorCode PgFoot2::Accept(ConstFunctor &functor) const -{ - return functor.VisitPgFoot2(this); -} - -FunctorCode PgFoot2::AcceptEnd(Functor &functor) -{ - return functor.VisitPgFoot2End(this); -} - -FunctorCode PgFoot2::AcceptEnd(ConstFunctor &functor) const -{ - return functor.VisitPgFoot2End(this); -} - -} // namespace vrv diff --git a/src/view_text.cpp b/src/view_text.cpp index 2b90fa10add..7466cf5694b 100644 --- a/src/view_text.cpp +++ b/src/view_text.cpp @@ -30,9 +30,7 @@ #include "options.h" #include "page.h" #include "pgfoot.h" -#include "pgfoot2.h" #include "pghead.h" -#include "pghead2.h" #include "rend.h" #include "smufl.h" #include "staff.h" From 4b1fd1ee80b91cf6de3feef19710875664842314 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 30 Jun 2023 15:24:36 +0200 Subject: [PATCH 26/36] Update LibMEI --- libmei/dist/attclasses.h | 1 + libmei/dist/attmodule.cpp | 15 ++++++ libmei/dist/atts_shared.cpp | 40 +++++++++++++++ libmei/dist/atts_shared.h | 49 ++++++++++++++++++ libmei/mei/develop/mei-verovio_compiled.odd | 56 ++++++++++----------- 5 files changed, 133 insertions(+), 28 deletions(-) diff --git a/libmei/dist/attclasses.h b/libmei/dist/attclasses.h index 49004a09362..569964ea2bf 100644 --- a/libmei/dist/attclasses.h +++ b/libmei/dist/attclasses.h @@ -214,6 +214,7 @@ enum AttClassId { ATT_REPEATMARKLOG, ATT_RESPONSIBILITY, ATT_RESTDURATIONLOG, + ATT_RUNNINGTEXT, ATT_SCALABLE, ATT_SEQUENCE, ATT_SLASHCOUNT, diff --git a/libmei/dist/attmodule.cpp b/libmei/dist/attmodule.cpp index 4a81bdd5bf1..ba0be2b5f60 100644 --- a/libmei/dist/attmodule.cpp +++ b/libmei/dist/attmodule.cpp @@ -3435,6 +3435,14 @@ bool AttModule::SetShared(Object *element, const std::string &attrType, const st return true; } } + if (element->HasAttClass(ATT_RUNNINGTEXT)) { + AttRunningtext *att = dynamic_cast(element); + assert(att); + if (attrType == "func") { + att->SetFunc(att->StrToPgfunc(attrValue)); + return true; + } + } if (element->HasAttClass(ATT_SCALABLE)) { AttScalable *att = dynamic_cast(element); assert(att); @@ -4874,6 +4882,13 @@ void AttModule::GetShared(const Object *element, ArrayOfStrAttr *attributes) attributes->push_back({ "dur", att->DurationToStr(att->GetDur()) }); } } + if (element->HasAttClass(ATT_RUNNINGTEXT)) { + const AttRunningtext *att = dynamic_cast(element); + assert(att); + if (att->HasFunc()) { + attributes->push_back({ "func", att->PgfuncToStr(att->GetFunc()) }); + } + } if (element->HasAttClass(ATT_SCALABLE)) { const AttScalable *att = dynamic_cast(element); assert(att); diff --git a/libmei/dist/atts_shared.cpp b/libmei/dist/atts_shared.cpp index cf35eddc799..6ad7d079af7 100644 --- a/libmei/dist/atts_shared.cpp +++ b/libmei/dist/atts_shared.cpp @@ -5157,6 +5157,46 @@ bool AttRestdurationLog::HasDur() const return (m_dur != DURATION_NONE); } +//---------------------------------------------------------------------------- +// AttRunningtext +//---------------------------------------------------------------------------- + +AttRunningtext::AttRunningtext() : Att() +{ + ResetRunningtext(); +} + +void AttRunningtext::ResetRunningtext() +{ + m_func = PGFUNC_NONE; +} + +bool AttRunningtext::ReadRunningtext(pugi::xml_node element, bool removeAttr) +{ + bool hasAttribute = false; + if (element.attribute("func")) { + this->SetFunc(StrToPgfunc(element.attribute("func").value())); + if (removeAttr) element.remove_attribute("func"); + hasAttribute = true; + } + return hasAttribute; +} + +bool AttRunningtext::WriteRunningtext(pugi::xml_node element) +{ + bool wroteAttribute = false; + if (this->HasFunc()) { + element.append_attribute("func") = PgfuncToStr(this->GetFunc()).c_str(); + wroteAttribute = true; + } + return wroteAttribute; +} + +bool AttRunningtext::HasFunc() const +{ + return (m_func != PGFUNC_NONE); +} + //---------------------------------------------------------------------------- // AttScalable //---------------------------------------------------------------------------- diff --git a/libmei/dist/atts_shared.h b/libmei/dist/atts_shared.h index 412610fbf40..05067a7a48e 100644 --- a/libmei/dist/atts_shared.h +++ b/libmei/dist/atts_shared.h @@ -5618,6 +5618,55 @@ class InstRestdurationLog : public AttRestdurationLog { virtual ~InstRestdurationLog() = default; }; +//---------------------------------------------------------------------------- +// AttRunningtext +//---------------------------------------------------------------------------- + +class AttRunningtext : public Att { +protected: + AttRunningtext(); + ~AttRunningtext() = default; + +public: + /** Reset the default values for the attribute class **/ + void ResetRunningtext(); + + /** Read the values for the attribute class **/ + bool ReadRunningtext(pugi::xml_node element, bool removeAttr = true); + + /** Write the values for the attribute class **/ + bool WriteRunningtext(pugi::xml_node element); + + /** + * @name Setters, getters and presence checker for class members. + * The checker returns true if the attribute class is set (e.g., not equal + * to the default value) + **/ + ///@{ + void SetFunc(data_PGFUNC func_) { m_func = func_; } + data_PGFUNC GetFunc() const { return m_func; } + bool HasFunc() const; + ///@} + +private: + /** Describes the function of the bracketed event sequence. **/ + data_PGFUNC m_func; +}; + +//---------------------------------------------------------------------------- +// InstRunningtext +//---------------------------------------------------------------------------- + +/** + * Instantiable version of AttRunningtext + */ + +class InstRunningtext : public AttRunningtext { +public: + InstRunningtext() = default; + virtual ~InstRunningtext() = default; +}; + //---------------------------------------------------------------------------- // AttScalable //---------------------------------------------------------------------------- diff --git a/libmei/mei/develop/mei-verovio_compiled.odd b/libmei/mei/develop/mei-verovio_compiled.odd index 351d5c8c348..7b77a819cba 100644 --- a/libmei/mei/develop/mei-verovio_compiled.odd +++ b/libmei/mei/develop/mei-verovio_compiled.odd @@ -2829,8 +2829,7 @@ - Oct attribute values. The default values conform to Acoustical Society of America - representation. Read, p. 44. + Octave number. The default values conform to the Scientific Pitch Notation (SPN). 9 @@ -5269,7 +5268,7 @@ tstamp.real attribute, while the ending point may be recorded by either a dur, dur.ges, endid, or tstamp2 attribute. It is a semantic error not to specify one starting and one ending type of attribute.

- A container for a sequence of grace notes. + grace groupA container for a sequence of grace notes. @@ -6027,7 +6026,7 @@ - (apparatus) – Contains one or more alternative encodings. + apparatusContains one or more alternative encodings. @@ -6043,7 +6042,7 @@ lectio difficilior, usus auctoris, etc.).

The model of this element is based on the app element of the Text Encoding Initiative (TEI).

-
(lemma) – Contains the lemma, or base text, of a textual variation. + lemmaContains the lemma, or base text, of a textual variation. @@ -6068,7 +6067,7 @@ should only contain those elements allowed within verse.

The model of this element is based on the lem element of the Text Encoding Initiative (TEI).

-
(reading) – Contains a single reading within a textual variation. + readingContains a single reading within a textual variation. @@ -7095,7 +7094,7 @@ - finger – An individual finger in a fingering indication. + fingerAn individual finger in a fingering indication. @@ -7120,7 +7119,7 @@ descendant of fing. - (finger group)– A group of individual fingers in a fingering indication. + finger groupA group of individual fingers in a fingering indication. @@ -9362,7 +9361,7 @@

The model of this element is based on the normalization element of the Text Encoding Initiative (TEI).

-
(notes statement)– Collects any notes providing information about a text additional to + notes statementCollects any notes providing information about a text additional to that recorded in other parts of the bibliographic description. @@ -9489,7 +9488,7 @@

In the context of a performance resource the attribute adlib marks a resource as optional.

To indicate the tuning of an instrument, the attribute trans.diat can be used.

-
Several instrumental or vocal resources treated as a group. + performance resources listSeveral instrumental or vocal resources treated as a group. @@ -11055,7 +11054,7 @@ persName is taken may be recorded using the auth attribute.

The model of this element is based on the persname element of the Encoded Archival Description (EAD).

-
(postal box or post office box) contains a number or other identifier for some postal + postal box or post office boxContains a number or other identifier for some postal delivery point other than a street address. @@ -11065,7 +11064,7 @@

The model of this element is based on the postBox element of the Text Encoding Initiative (TEI).

-
(postal code) contains a numerical or alphanumeric code used as part of a postal address + postal codeContains a numerical or alphanumeric code used as part of a postal address to simplify sorting or delivery of mail. @@ -11423,7 +11422,7 @@ - Collection of one or more neume components. + neume component groupCollection of one or more neume components. @@ -14283,6 +14282,16 @@ + + Attributes that record the function (i.e., placement) of page running text elements. + + + Records the function (i.e., placement) of a page header or footer. + + + + + Logical domain attributes. @@ -17066,6 +17075,7 @@ + @@ -17073,11 +17083,6 @@ - - Records the function (i.e., placement) of the page footer. - - -

This element is used to capture the textual data that often appears in printed music. It may also be used for similarly formatted material in manuscripts. When @@ -17088,6 +17093,7 @@ + @@ -17095,11 +17101,6 @@ - - Records the function (i.e., placement) of the page header. - - -

This element is used to capture the textual data that often appears in printed music. It may also be used for similarly formatted material in manuscripts. When @@ -18250,8 +18251,7 @@

Do not confuse this element, used to capture block-level quotations, and q, intended for inline quotations.

The model of this element is based on the quote element of the Text Encoding Initiative (TEI) and the quote element of the Encoded Archival Description (EAD).

-
(arbitrary segment) represents any segmentation of text below the "text component" - level. + arbitrary segmentrepresents any segmentation of text below the "text component" level. @@ -18611,7 +18611,7 @@ - + @@ -19605,7 +19605,6 @@ - @@ -19644,6 +19643,7 @@ + @@ -20076,7 +20076,7 @@ -

The value is structured; that is, it should contain a single color value or have +

The value is structured; that is, it should contain a single color value or have the same number of space-separated values as the number of lines indicated by the lines attribute. The first value then applies to the lowest line of the staff.

All values from data.COLOR are allowed.

From bae35389f2b688875156ab0b3085126542c36613 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 30 Jun 2023 15:32:08 +0200 Subject: [PATCH 27/36] Add AttRunningText to RunningElement * Also remove AttHorizontalAlign since it has never been used --- include/vrv/iomei.h | 6 ---- include/vrv/runningelement.h | 2 +- src/iomei.cpp | 54 ++---------------------------------- src/runningelement.cpp | 6 ++-- 4 files changed, 6 insertions(+), 62 deletions(-) diff --git a/include/vrv/iomei.h b/include/vrv/iomei.h index adb4a698d70..0d715cebc20 100644 --- a/include/vrv/iomei.h +++ b/include/vrv/iomei.h @@ -111,9 +111,7 @@ class Pages; class Pb; class Pedal; class PgFoot; -class PgFoot2; class PgHead; -class PgHead2; class Phrase; class PitchInflection; class PitchInterface; @@ -358,9 +356,7 @@ class MEIOutput : public Output { void WriteScoreDef(pugi::xml_node currentNode, ScoreDef *scoreDef); void WriteGrpSym(pugi::xml_node currentNode, GrpSym *grmSym); void WritePgFoot(pugi::xml_node currentNode, PgFoot *pgFoot); - void WritePgFoot2(pugi::xml_node currentNode, PgFoot2 *pgFoot2); void WritePgHead(pugi::xml_node currentNode, PgHead *pgHead); - void WritePgHead2(pugi::xml_node currentNode, PgHead2 *pgHead2); void WriteDiv(pugi::xml_node currentNode, Div *div); void WriteStaffGrp(pugi::xml_node currentNode, StaffGrp *staffGrp); void WriteStaffDef(pugi::xml_node currentNode, StaffDef *staffDef); @@ -657,9 +653,7 @@ class MEIInput : public Input { bool ReadScoreDefChildren(Object *parent, pugi::xml_node parentNode); bool ReadGrpSym(Object *parent, pugi::xml_node grpSym); bool ReadPgFoot(Object *parent, pugi::xml_node pgFoot); - bool ReadPgFoot2(Object *parent, pugi::xml_node pgFoot2); bool ReadPgHead(Object *parent, pugi::xml_node pgHead); - bool ReadPgHead2(Object *parent, pugi::xml_node pgHead2); bool ReadDiv(Object *parent, pugi::xml_node div); bool ReadRunningChildren(Object *parent, pugi::xml_node parentNode, Object *filter = NULL); bool ReadStaffGrp(Object *parent, pugi::xml_node staffGrp); diff --git a/include/vrv/runningelement.h b/include/vrv/runningelement.h index 828fcef505c..5f8e2d26ab6 100644 --- a/include/vrv/runningelement.h +++ b/include/vrv/runningelement.h @@ -25,7 +25,7 @@ class TextElement; * This class represents running elements (headers and footers). * It is not an abstract class but should not be instanciated directly. */ -class RunningElement : public TextLayoutElement, public AttHorizontalAlign { +class RunningElement : public TextLayoutElement, public AttRunningtext { public: /** * @name Constructors, destructors, reset methods diff --git a/src/iomei.cpp b/src/iomei.cpp index 15280e8dd38..42e5f6eb5c8 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -102,9 +102,7 @@ #include "pb.h" #include "pedal.h" #include "pgfoot.h" -#include "pgfoot2.h" #include "pghead.h" -#include "pghead2.h" #include "phrase.h" #include "pitchinflection.h" #include "plica.h" @@ -420,18 +418,10 @@ bool MEIOutput::WriteObjectInternal(Object *object, bool useCustomScoreDef) m_currentNode = m_currentNode.append_child("pgFoot"); this->WritePgFoot(m_currentNode, vrv_cast(object)); } - else if (object->Is(PGFOOT2)) { - m_currentNode = m_currentNode.append_child("pgFoot2"); - this->WritePgFoot2(m_currentNode, vrv_cast(object)); - } else if (object->Is(PGHEAD)) { m_currentNode = m_currentNode.append_child("pgHead"); this->WritePgHead(m_currentNode, vrv_cast(object)); } - else if (object->Is(PGHEAD2)) { - m_currentNode = m_currentNode.append_child("pgHead2"); - this->WritePgHead2(m_currentNode, vrv_cast(object)); - } else if (object->Is(STAFFGRP)) { m_currentNode = m_currentNode.append_child("staffGrp"); this->WriteStaffGrp(m_currentNode, vrv_cast(object)); @@ -1741,7 +1731,7 @@ void MEIOutput::WriteRunningElement(pugi::xml_node currentNode, RunningElement * assert(runningElement); this->WriteTextLayoutElement(currentNode, runningElement); - runningElement->WriteHorizontalAlign(currentNode); + runningElement->WriteRunningtext(currentNode); } void MEIOutput::WriteGrpSym(pugi::xml_node currentNode, GrpSym *grpSym) @@ -1776,13 +1766,6 @@ void MEIOutput::WritePgFoot(pugi::xml_node currentNode, PgFoot *pgFoot) this->WriteRunningElement(currentNode, pgFoot); } -void MEIOutput::WritePgFoot2(pugi::xml_node currentNode, PgFoot2 *pgFoot2) -{ - assert(pgFoot2); - - this->WriteRunningElement(currentNode, pgFoot2); -} - void MEIOutput::WritePgHead(pugi::xml_node currentNode, PgHead *pgHead) { assert(pgHead); @@ -1790,13 +1773,6 @@ void MEIOutput::WritePgHead(pugi::xml_node currentNode, PgHead *pgHead) this->WriteRunningElement(currentNode, pgHead); } -void MEIOutput::WritePgHead2(pugi::xml_node currentNode, PgHead2 *pgHead2) -{ - assert(pgHead2); - - this->WriteRunningElement(currentNode, pgHead2); -} - void MEIOutput::WriteStaffGrp(pugi::xml_node currentNode, StaffGrp *staffGrp) { assert(staffGrp); @@ -4798,15 +4774,9 @@ bool MEIInput::ReadScoreDefChildren(Object *parent, pugi::xml_node parentNode) else if (std::string(current.name()) == "pgFoot") { success = this->ReadPgFoot(parent, current); } - else if (std::string(current.name()) == "pgFoot2") { - success = this->ReadPgFoot2(parent, current); - } else if (std::string(current.name()) == "pgHead") { success = this->ReadPgHead(parent, current); } - else if (std::string(current.name()) == "pgHead2") { - success = this->ReadPgHead2(parent, current); - } // symbolTable else if (std::string(current.name()) == "symbolTable") { success = this->ReadSymbolTable(parent, current); @@ -4921,7 +4891,7 @@ bool MEIInput::ReadTextLayoutElement(pugi::xml_node element, TextLayoutElement * bool MEIInput::ReadRunningElement(pugi::xml_node element, RunningElement *object) { this->ReadTextLayoutElement(element, object); - object->ReadHorizontalAlign(element); + object->ReadRunningtext(element); return true; } @@ -4960,16 +4930,6 @@ bool MEIInput::ReadPgFoot(Object *parent, pugi::xml_node pgFoot) return this->ReadRunningChildren(vrvPgFoot, pgFoot, vrvPgFoot); } -bool MEIInput::ReadPgFoot2(Object *parent, pugi::xml_node pgFoot2) -{ - PgFoot2 *vrvPgFoot2 = new PgFoot2(); - this->ReadRunningElement(pgFoot2, vrvPgFoot2); - - parent->AddChild(vrvPgFoot2); - this->ReadUnsupportedAttr(pgFoot2, vrvPgFoot2); - return this->ReadRunningChildren(vrvPgFoot2, pgFoot2, vrvPgFoot2); -} - bool MEIInput::ReadPgHead(Object *parent, pugi::xml_node pgHead) { PgHead *vrvPgHead = new PgHead(); @@ -4980,16 +4940,6 @@ bool MEIInput::ReadPgHead(Object *parent, pugi::xml_node pgHead) return this->ReadRunningChildren(vrvPgHead, pgHead, vrvPgHead); } -bool MEIInput::ReadPgHead2(Object *parent, pugi::xml_node pgHead2) -{ - PgHead2 *vrvPgHead2 = new PgHead2(); - this->ReadRunningElement(pgHead2, vrvPgHead2); - - parent->AddChild(vrvPgHead2); - this->ReadUnsupportedAttr(pgHead2, vrvPgHead2); - return this->ReadRunningChildren(vrvPgHead2, pgHead2, vrvPgHead2); -} - bool MEIInput::ReadDiv(Object *parent, pugi::xml_node div) { Div *vrvDiv = new Div(); diff --git a/src/runningelement.cpp b/src/runningelement.cpp index 5eb7fbb53da..fcb7dfab81a 100644 --- a/src/runningelement.cpp +++ b/src/runningelement.cpp @@ -48,9 +48,9 @@ RunningElement::RunningElement(ClassId classId) : TextLayoutElement(classId, "re */ RunningElement::RunningElement(ClassId classId, const std::string &classIdStr) - : TextLayoutElement(classId, classIdStr), AttHorizontalAlign() + : TextLayoutElement(classId, classIdStr), AttRunningtext() { - this->RegisterAttClass(ATT_HORIZONTALALIGN); + this->RegisterAttClass(ATT_RUNNINGTEXT); this->Reset(); } @@ -60,7 +60,7 @@ RunningElement::~RunningElement() {} void RunningElement::Reset() { TextLayoutElement::Reset(); - this->ResetHorizontalAlign(); + this->ResetRunningtext(); m_isGenerated = false; From 9208c76b91276f3448e93735133e33456db992cb Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 30 Jun 2023 15:32:51 +0200 Subject: [PATCH 28/36] Add a AttRuningtextComparison class --- include/vrv/comparison.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/include/vrv/comparison.h b/include/vrv/comparison.h index b0a54e08dfe..40d5bbaae07 100644 --- a/include/vrv/comparison.h +++ b/include/vrv/comparison.h @@ -380,6 +380,32 @@ class AttVisibilityComparison : public ClassIdComparison { data_BOOLEAN m_isVisible; }; +//---------------------------------------------------------------------------- +// AttRunningtextComparison +//---------------------------------------------------------------------------- + +/** + * This class evaluates if the object is of a certain ClassId and has a @func of value func. + */ +class AttRunningtextComparison : public ClassIdComparison { + +public: + AttRunningtextComparison(ClassId classId, data_PGFUNC func) : ClassIdComparison(classId) { m_func = func; } + + bool operator()(const Object *object) override + { + if (!MatchesType(object)) return false; + // This should not happen, but just in case + if (!object->HasAttClass(ATT_RUNNINGTEXT)) return false; + const AttRunningtext *element = dynamic_cast(object); + assert(element); + return (element->GetFunc() == m_func); + } + +private: + data_PGFUNC m_func; +}; + //---------------------------------------------------------------------------- // CrossAlignmentReferenceComparison //---------------------------------------------------------------------------- From 80f3fb1a2e954b56f47ce91fb07e2a632908de6a Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 30 Jun 2023 15:33:47 +0200 Subject: [PATCH 29/36] Remove pgHead2 and pgFoot2 use when generating headers/footers --- include/vrv/scoredef.h | 14 ++++---------- src/doc.cpp | 10 ++++++---- src/page.cpp | 10 ++++------ src/scoredef.cpp | 44 +++++++++++++----------------------------- 4 files changed, 27 insertions(+), 51 deletions(-) diff --git a/include/vrv/scoredef.h b/include/vrv/scoredef.h index 156be727709..a0ff8e9863c 100644 --- a/include/vrv/scoredef.h +++ b/include/vrv/scoredef.h @@ -23,9 +23,7 @@ class Mensur; class MeterSig; class MeterSigGrp; class PgFoot; -class PgFoot2; class PgHead; -class PgHead2; class StaffGrp; class StaffDef; @@ -239,14 +237,10 @@ class ScoreDef : public ScoreDefElement, * @name Getters for running elements */ ///@{ - PgFoot *GetPgFoot(); - const PgFoot *GetPgFoot() const; - PgFoot2 *GetPgFoot2(); - const PgFoot2 *GetPgFoot2() const; - PgHead *GetPgHead(); - const PgHead *GetPgHead() const; - PgHead2 *GetPgHead2(); - const PgHead2 *GetPgHead2() const; + PgFoot *GetPgFoot(data_PGFUNC func); + const PgFoot *GetPgFoot(data_PGFUNC func) const; + PgHead *GetPgHead(data_PGFUNC func); + const PgHead *GetPgHead(data_PGFUNC func) const; ///@} /** diff --git a/src/doc.cpp b/src/doc.cpp index 77af736ea5b..1da0c6a7411 100644 --- a/src/doc.cpp +++ b/src/doc.cpp @@ -47,9 +47,7 @@ #include "page.h" #include "pages.h" #include "pgfoot.h" -#include "pgfoot2.h" #include "pghead.h" -#include "pghead2.h" #include "preparedatafunctor.h" #include "resetfunctor.h" #include "runningelement.h" @@ -218,13 +216,15 @@ bool Doc::GenerateFooter() } PgFoot *pgFoot = new PgFoot(); + pgFoot->SetFunc(PGFUNC_first); // We mark it as generated for not having it written in the output pgFoot->IsGenerated(true); pgFoot->LoadFooter(this); pgFoot->SetType("autogenerated"); this->GetCurrentScoreDef()->AddChild(pgFoot); - PgFoot2 *pgFoot2 = new PgFoot2(); + PgFoot *pgFoot2 = new PgFoot(); + pgFoot2->SetFunc(PGFUNC_all); pgFoot2->IsGenerated(true); pgFoot2->LoadFooter(this); pgFoot2->SetType("autogenerated"); @@ -238,13 +238,15 @@ bool Doc::GenerateHeader() if (this->GetCurrentScoreDef()->FindDescendantByType(PGHEAD)) return false; PgHead *pgHead = new PgHead(); + pgHead->SetFunc(PGFUNC_first); // We mark it as generated for not having it written in the output pgHead->IsGenerated(true); pgHead->GenerateFromMEIHeader(m_header); pgHead->SetType("autogenerated"); this->GetCurrentScoreDef()->AddChild(pgHead); - PgHead2 *pgHead2 = new PgHead2(); + PgHead *pgHead2 = new PgHead(); + pgHead2->SetFunc(PGFUNC_all); pgHead2->IsGenerated(true); pgHead2->AddPageNum(HORIZONTALALIGNMENT_center, VERTICALALIGNMENT_top); pgHead2->SetType("autogenerated"); diff --git a/src/page.cpp b/src/page.cpp index 067da51cf5e..cc122c44468 100644 --- a/src/page.cpp +++ b/src/page.cpp @@ -56,9 +56,7 @@ #include "pageelement.h" #include "pages.h" #include "pgfoot.h" -#include "pgfoot2.h" #include "pghead.h" -#include "pghead2.h" #include "resetfunctor.h" #include "score.h" #include "staff.h" @@ -155,10 +153,10 @@ const RunningElement *Page::GetHeader() const // first page or use the pgHeader for all pages? if ((pages->GetFirst() == this) || (doc->GetOptions()->m_usePgHeaderForAll.GetValue())) { - return m_score->GetScoreDef()->GetPgHead(); + return m_score->GetScoreDef()->GetPgHead(PGFUNC_first); } else { - return m_score->GetScoreDef()->GetPgHead2(); + return m_score->GetScoreDef()->GetPgHead(PGFUNC_all); } } @@ -181,10 +179,10 @@ const RunningElement *Page::GetFooter() const // first page or use the pgFooter for all pages? if ((pages->GetFirst() == this) || (doc->GetOptions()->m_usePgFooterForAll.GetValue())) { - return m_scoreEnd->GetScoreDef()->GetPgFoot(); + return m_scoreEnd->GetScoreDef()->GetPgFoot(PGFUNC_first); } else { - return m_scoreEnd->GetScoreDef()->GetPgFoot2(); + return m_scoreEnd->GetScoreDef()->GetPgFoot(PGFUNC_all); } } diff --git a/src/scoredef.cpp b/src/scoredef.cpp index 40ff1bfe4b2..c8305fe396f 100644 --- a/src/scoredef.cpp +++ b/src/scoredef.cpp @@ -25,9 +25,7 @@ #include "metersig.h" #include "metersiggrp.h" #include "pgfoot.h" -#include "pgfoot2.h" #include "pghead.h" -#include "pghead2.h" #include "section.h" #include "setscoredeffunctor.h" #include "staffdef.h" @@ -299,7 +297,7 @@ int ScoreDef::GetInsertOrderFor(ClassId classId) const { static const std::vector s_order({ SYMBOLTABLE, CLEF, KEYSIG, METERSIGGRP, METERSIG, MENSUR, PGHEAD, PGFOOT, - PGHEAD2, PGFOOT2, STAFFGRP, GRPSYM }); + STAFFGRP, GRPSYM }); return this->GetInsertOrderForIn(classId, s_order); } @@ -583,44 +581,28 @@ void ScoreDef::SetDrawingLabelsWidth(int width) } } -PgFoot *ScoreDef::GetPgFoot() +PgFoot *ScoreDef::GetPgFoot(data_PGFUNC func) { - return vrv_cast(this->FindDescendantByType(PGFOOT)); + AttRunningtextComparison comparison(PGFOOT, func); + return vrv_cast(this->FindDescendantByComparison(&comparison)); } -const PgFoot *ScoreDef::GetPgFoot() const +const PgFoot *ScoreDef::GetPgFoot(data_PGFUNC func) const { - return vrv_cast(this->FindDescendantByType(PGFOOT)); + AttRunningtextComparison comparison(PGFOOT, func); + return vrv_cast(this->FindDescendantByComparison(&comparison)); } -PgFoot2 *ScoreDef::GetPgFoot2() +PgHead *ScoreDef::GetPgHead(data_PGFUNC func) { - return vrv_cast(this->FindDescendantByType(PGFOOT2)); + AttRunningtextComparison comparison(PGHEAD, func); + return vrv_cast(this->FindDescendantByComparison(&comparison)); } -const PgFoot2 *ScoreDef::GetPgFoot2() const +const PgHead *ScoreDef::GetPgHead(data_PGFUNC func) const { - return vrv_cast(this->FindDescendantByType(PGFOOT2)); -} - -PgHead *ScoreDef::GetPgHead() -{ - return vrv_cast(this->FindDescendantByType(PGHEAD)); -} - -const PgHead *ScoreDef::GetPgHead() const -{ - return vrv_cast(this->FindDescendantByType(PGHEAD)); -} - -PgHead2 *ScoreDef::GetPgHead2() -{ - return vrv_cast(this->FindDescendantByType(PGHEAD2)); -} - -const PgHead2 *ScoreDef::GetPgHead2() const -{ - return vrv_cast(this->FindDescendantByType(PGHEAD2)); + AttRunningtextComparison comparison(PGHEAD, func); + return vrv_cast(this->FindDescendantByComparison(&comparison)); } int ScoreDef::GetMaxStaffSize() const From d7c7e6700b1e217d3eaa1ebbd6d3baf9f211eeca Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 30 Jun 2023 15:34:05 +0200 Subject: [PATCH 30/36] Update iohumrdum --- src/iohumdrum.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/iohumdrum.cpp b/src/iohumdrum.cpp index 24cd50ad51a..63baf0646d8 100644 --- a/src/iohumdrum.cpp +++ b/src/iohumdrum.cpp @@ -56,6 +56,7 @@ using namespace std; #include "btrem.h" #include "choice.h" #include "chord.h" +#include "comparison.h" #include "custos.h" #include "dir.h" #include "dot.h" @@ -4610,13 +4611,13 @@ bool HumdrumInput::prepareFooter( std::string meifile = "\n"; meifile += ""; meifile += "\n"; - meifile += "\n"; + meifile += "\n"; meifile += footer; meifile += "\n"; // Always putting footer on all pages for now: - meifile += "\n"; + meifile += "\n"; meifile += footer; - meifile += "\n"; + meifile += "\n"; meifile += "\n"; Doc tempdoc; @@ -4631,7 +4632,8 @@ bool HumdrumInput::prepareFooter( // std::string meicontent = meioutput.GetOutput(); // std::cout << "MEI CONTENT " << meicontent << std::endl; - Object *pgfoot = tempdoc.GetCurrentScoreDef()->FindDescendantByType(ClassId::PGFOOT); + AttRunningtextComparison comparison(PGFOOT, PGFUNC_first); + Object *pgfoot = tempdoc.GetCurrentScoreDef()->FindDescendantByComparison(&comparison); if (pgfoot == NULL) { return false; } @@ -4651,7 +4653,8 @@ bool HumdrumInput::prepareFooter( m_doc->GetCurrentScoreDef()->AddChild(pgfoot); - Object *pgfoot2 = tempdoc.GetCurrentScoreDef()->FindDescendantByType(ClassId::PGFOOT2); + AttRunningtextComparison comparison2(PGFOOT, PGFUNC_all); + Object *pgfoot2 = tempdoc.GetCurrentScoreDef()->FindDescendantByComparison(&comparison2); if (pgfoot2 == NULL) { return true; } @@ -4662,7 +4665,7 @@ bool HumdrumInput::prepareFooter( } detached = pgfoot2->GetParent()->DetachChild(index); if (detached != pgfoot2) { - std::cerr << "Detached element is not a pgFoot2 element" << std::endl; + std::cerr << "Detached element is not a pgFoot element" << std::endl; if (detached) { delete detached; } From 74b3328722e28790995b58fc382da3b9a2bc43e6 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 30 Jun 2023 15:34:23 +0200 Subject: [PATCH 31/36] Update ios binding header list --- bindings/iOS/all.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bindings/iOS/all.h b/bindings/iOS/all.h index 6a45301f915..c884aa77465 100644 --- a/bindings/iOS/all.h +++ b/bindings/iOS/all.h @@ -74,6 +74,7 @@ #import #import #import +#import #import #import #import @@ -170,7 +171,6 @@ #import #import #import -#import #import #import #import @@ -186,6 +186,7 @@ #import #import #import +#import #import #import #import @@ -226,6 +227,7 @@ #import #import #import +#import #import #import #import From 12c00b437538bbcc62270af67c2ce05257b1a787 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 30 Jun 2023 15:44:41 +0200 Subject: [PATCH 32/36] Add pgHead2 and pgFoot2 upgrade function --- include/vrv/iomei.h | 1 + src/iomei.cpp | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/include/vrv/iomei.h b/include/vrv/iomei.h index 0d715cebc20..1f547d07093 100644 --- a/include/vrv/iomei.h +++ b/include/vrv/iomei.h @@ -885,6 +885,7 @@ class MEIInput : public Input { // to MEI 5.0.0 void UpgradeKeySigTo_5_0_0(pugi::xml_node keySig); void UpgradePageTo_5_0_0(Page *page); + void UpgradePgHeadFootTo_5_0_0(pugi::xml_node element); void UpgradeMeasureTo_5_0_0(pugi::xml_node measure); void UpgradeMeterSigTo_5_0_0(pugi::xml_node meterSig, MeterSig *vrvMeterSig); void UpgradeScoreDefElementTo_5_0_0(pugi::xml_node scoreDefElement); diff --git a/src/iomei.cpp b/src/iomei.cpp index 42e5f6eb5c8..efead7e24ce 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -4772,9 +4772,27 @@ bool MEIInput::ReadScoreDefChildren(Object *parent, pugi::xml_node parentNode) } // headers and footers else if (std::string(current.name()) == "pgFoot") { + if (m_meiversion <= meiVersion_MEIVERSION_5_0_0_dev) { + UpgradePgHeadFootTo_5_0_0(current); + } + success = this->ReadPgFoot(parent, current); + } + else if (std::string(current.name()) == "pgFoot2") { + if (m_meiversion <= meiVersion_MEIVERSION_5_0_0_dev) { + UpgradePgHeadFootTo_5_0_0(current); + } success = this->ReadPgFoot(parent, current); } else if (std::string(current.name()) == "pgHead") { + if (m_meiversion <= meiVersion_MEIVERSION_5_0_0_dev) { + UpgradePgHeadFootTo_5_0_0(current); + } + success = this->ReadPgHead(parent, current); + } + else if (std::string(current.name()) == "pgHead2") { + if (m_meiversion <= meiVersion_MEIVERSION_5_0_0_dev) { + UpgradePgHeadFootTo_5_0_0(current); + } success = this->ReadPgHead(parent, current); } // symbolTable @@ -8039,6 +8057,24 @@ void MEIInput::UpgradePageTo_5_0_0(Page *page) page->AddChild(mdivEnd); } +void MEIInput::UpgradePgHeadFootTo_5_0_0(pugi::xml_node element) +{ + if ((std::string(element.name()) == "pgFoot") && !element.attribute("func")) { + element.append_attribute("func") = "first"; + } + else if (std::string(element.name()) == "pgFoot2") { + element.set_name("pgFoot"); + element.append_attribute("func") = "all"; + } + else if ((std::string(element.name()) == "pgHead") && !element.attribute("func")) { + element.append_attribute("func") = "first"; + } + else if (std::string(element.name()) == "pgHead2") { + element.set_name("pgHead"); + element.append_attribute("func") = "all"; + } +} + void MEIInput::UpgradeMeasureTo_5_0_0(pugi::xml_node measure) { if (measure.attribute("ulx")) { From 336dfa069a97998db02a7eae1232bf34d7a2c231 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 30 Jun 2023 15:45:13 +0200 Subject: [PATCH 33/36] Formatting --- src/scoredef.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scoredef.cpp b/src/scoredef.cpp index c8305fe396f..7cf7715fe4c 100644 --- a/src/scoredef.cpp +++ b/src/scoredef.cpp @@ -296,8 +296,8 @@ bool ScoreDef::IsSupportedChild(Object *child) int ScoreDef::GetInsertOrderFor(ClassId classId) const { - static const std::vector s_order({ SYMBOLTABLE, CLEF, KEYSIG, METERSIGGRP, METERSIG, MENSUR, PGHEAD, PGFOOT, - STAFFGRP, GRPSYM }); + static const std::vector s_order( + { SYMBOLTABLE, CLEF, KEYSIG, METERSIGGRP, METERSIG, MENSUR, PGHEAD, PGFOOT, STAFFGRP, GRPSYM }); return this->GetInsertOrderForIn(classId, s_order); } From dc5f5db65dc6934a0359138fb4eadb1569a4748c Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sat, 1 Jul 2023 08:54:36 +0200 Subject: [PATCH 34/36] Update LibMEI --- libmei/dist/attclasses.h | 2 +- libmei/dist/attmodule.cpp | 30 +++---- libmei/dist/atts_shared.cpp | 80 ++++++++--------- libmei/dist/atts_shared.h | 98 ++++++++++----------- libmei/mei/develop/mei-verovio_compiled.odd | 24 ++--- 5 files changed, 117 insertions(+), 117 deletions(-) diff --git a/libmei/dist/attclasses.h b/libmei/dist/attclasses.h index 569964ea2bf..cd97543bc18 100644 --- a/libmei/dist/attclasses.h +++ b/libmei/dist/attclasses.h @@ -158,6 +158,7 @@ enum AttClassId { ATT_EXTENT, ATT_FERMATAPRESENT, ATT_FILING, + ATT_FORMEWORK, ATT_GRPSYMLOG, ATT_HANDIDENT, ATT_HEIGHT, @@ -214,7 +215,6 @@ enum AttClassId { ATT_REPEATMARKLOG, ATT_RESPONSIBILITY, ATT_RESTDURATIONLOG, - ATT_RUNNINGTEXT, ATT_SCALABLE, ATT_SEQUENCE, ATT_SLASHCOUNT, diff --git a/libmei/dist/attmodule.cpp b/libmei/dist/attmodule.cpp index ba0be2b5f60..cdff9d3b589 100644 --- a/libmei/dist/attmodule.cpp +++ b/libmei/dist/attmodule.cpp @@ -2763,6 +2763,14 @@ bool AttModule::SetShared(Object *element, const std::string &attrType, const st return true; } } + if (element->HasAttClass(ATT_FORMEWORK)) { + AttFormework *att = dynamic_cast(element); + assert(att); + if (attrType == "func") { + att->SetFunc(att->StrToPgfunc(attrValue)); + return true; + } + } if (element->HasAttClass(ATT_GRPSYMLOG)) { AttGrpSymLog *att = dynamic_cast(element); assert(att); @@ -3435,14 +3443,6 @@ bool AttModule::SetShared(Object *element, const std::string &attrType, const st return true; } } - if (element->HasAttClass(ATT_RUNNINGTEXT)) { - AttRunningtext *att = dynamic_cast(element); - assert(att); - if (attrType == "func") { - att->SetFunc(att->StrToPgfunc(attrValue)); - return true; - } - } if (element->HasAttClass(ATT_SCALABLE)) { AttScalable *att = dynamic_cast(element); assert(att); @@ -4322,6 +4322,13 @@ void AttModule::GetShared(const Object *element, ArrayOfStrAttr *attributes) attributes->push_back({ "nonfiling", att->IntToStr(att->GetNonfiling()) }); } } + if (element->HasAttClass(ATT_FORMEWORK)) { + const AttFormework *att = dynamic_cast(element); + assert(att); + if (att->HasFunc()) { + attributes->push_back({ "func", att->PgfuncToStr(att->GetFunc()) }); + } + } if (element->HasAttClass(ATT_GRPSYMLOG)) { const AttGrpSymLog *att = dynamic_cast(element); assert(att); @@ -4882,13 +4889,6 @@ void AttModule::GetShared(const Object *element, ArrayOfStrAttr *attributes) attributes->push_back({ "dur", att->DurationToStr(att->GetDur()) }); } } - if (element->HasAttClass(ATT_RUNNINGTEXT)) { - const AttRunningtext *att = dynamic_cast(element); - assert(att); - if (att->HasFunc()) { - attributes->push_back({ "func", att->PgfuncToStr(att->GetFunc()) }); - } - } if (element->HasAttClass(ATT_SCALABLE)) { const AttScalable *att = dynamic_cast(element); assert(att); diff --git a/libmei/dist/atts_shared.cpp b/libmei/dist/atts_shared.cpp index 6ad7d079af7..355de5cc18e 100644 --- a/libmei/dist/atts_shared.cpp +++ b/libmei/dist/atts_shared.cpp @@ -2077,6 +2077,46 @@ bool AttFiling::HasNonfiling() const return (m_nonfiling != MEI_UNSET); } +//---------------------------------------------------------------------------- +// AttFormework +//---------------------------------------------------------------------------- + +AttFormework::AttFormework() : Att() +{ + ResetFormework(); +} + +void AttFormework::ResetFormework() +{ + m_func = PGFUNC_NONE; +} + +bool AttFormework::ReadFormework(pugi::xml_node element, bool removeAttr) +{ + bool hasAttribute = false; + if (element.attribute("func")) { + this->SetFunc(StrToPgfunc(element.attribute("func").value())); + if (removeAttr) element.remove_attribute("func"); + hasAttribute = true; + } + return hasAttribute; +} + +bool AttFormework::WriteFormework(pugi::xml_node element) +{ + bool wroteAttribute = false; + if (this->HasFunc()) { + element.append_attribute("func") = PgfuncToStr(this->GetFunc()).c_str(); + wroteAttribute = true; + } + return wroteAttribute; +} + +bool AttFormework::HasFunc() const +{ + return (m_func != PGFUNC_NONE); +} + //---------------------------------------------------------------------------- // AttGrpSymLog //---------------------------------------------------------------------------- @@ -5157,46 +5197,6 @@ bool AttRestdurationLog::HasDur() const return (m_dur != DURATION_NONE); } -//---------------------------------------------------------------------------- -// AttRunningtext -//---------------------------------------------------------------------------- - -AttRunningtext::AttRunningtext() : Att() -{ - ResetRunningtext(); -} - -void AttRunningtext::ResetRunningtext() -{ - m_func = PGFUNC_NONE; -} - -bool AttRunningtext::ReadRunningtext(pugi::xml_node element, bool removeAttr) -{ - bool hasAttribute = false; - if (element.attribute("func")) { - this->SetFunc(StrToPgfunc(element.attribute("func").value())); - if (removeAttr) element.remove_attribute("func"); - hasAttribute = true; - } - return hasAttribute; -} - -bool AttRunningtext::WriteRunningtext(pugi::xml_node element) -{ - bool wroteAttribute = false; - if (this->HasFunc()) { - element.append_attribute("func") = PgfuncToStr(this->GetFunc()).c_str(); - wroteAttribute = true; - } - return wroteAttribute; -} - -bool AttRunningtext::HasFunc() const -{ - return (m_func != PGFUNC_NONE); -} - //---------------------------------------------------------------------------- // AttScalable //---------------------------------------------------------------------------- diff --git a/libmei/dist/atts_shared.h b/libmei/dist/atts_shared.h index 05067a7a48e..e6d444e1ac4 100644 --- a/libmei/dist/atts_shared.h +++ b/libmei/dist/atts_shared.h @@ -2344,6 +2344,55 @@ class InstFiling : public AttFiling { virtual ~InstFiling() = default; }; +//---------------------------------------------------------------------------- +// AttFormework +//---------------------------------------------------------------------------- + +class AttFormework : public Att { +protected: + AttFormework(); + ~AttFormework() = default; + +public: + /** Reset the default values for the attribute class **/ + void ResetFormework(); + + /** Read the values for the attribute class **/ + bool ReadFormework(pugi::xml_node element, bool removeAttr = true); + + /** Write the values for the attribute class **/ + bool WriteFormework(pugi::xml_node element); + + /** + * @name Setters, getters and presence checker for class members. + * The checker returns true if the attribute class is set (e.g., not equal + * to the default value) + **/ + ///@{ + void SetFunc(data_PGFUNC func_) { m_func = func_; } + data_PGFUNC GetFunc() const { return m_func; } + bool HasFunc() const; + ///@} + +private: + /** Describes the function of the bracketed event sequence. **/ + data_PGFUNC m_func; +}; + +//---------------------------------------------------------------------------- +// InstFormework +//---------------------------------------------------------------------------- + +/** + * Instantiable version of AttFormework + */ + +class InstFormework : public AttFormework { +public: + InstFormework() = default; + virtual ~InstFormework() = default; +}; + //---------------------------------------------------------------------------- // AttGrpSymLog //---------------------------------------------------------------------------- @@ -5618,55 +5667,6 @@ class InstRestdurationLog : public AttRestdurationLog { virtual ~InstRestdurationLog() = default; }; -//---------------------------------------------------------------------------- -// AttRunningtext -//---------------------------------------------------------------------------- - -class AttRunningtext : public Att { -protected: - AttRunningtext(); - ~AttRunningtext() = default; - -public: - /** Reset the default values for the attribute class **/ - void ResetRunningtext(); - - /** Read the values for the attribute class **/ - bool ReadRunningtext(pugi::xml_node element, bool removeAttr = true); - - /** Write the values for the attribute class **/ - bool WriteRunningtext(pugi::xml_node element); - - /** - * @name Setters, getters and presence checker for class members. - * The checker returns true if the attribute class is set (e.g., not equal - * to the default value) - **/ - ///@{ - void SetFunc(data_PGFUNC func_) { m_func = func_; } - data_PGFUNC GetFunc() const { return m_func; } - bool HasFunc() const; - ///@} - -private: - /** Describes the function of the bracketed event sequence. **/ - data_PGFUNC m_func; -}; - -//---------------------------------------------------------------------------- -// InstRunningtext -//---------------------------------------------------------------------------- - -/** - * Instantiable version of AttRunningtext - */ - -class InstRunningtext : public AttRunningtext { -public: - InstRunningtext() = default; - virtual ~InstRunningtext() = default; -}; - //---------------------------------------------------------------------------- // AttScalable //---------------------------------------------------------------------------- diff --git a/libmei/mei/develop/mei-verovio_compiled.odd b/libmei/mei/develop/mei-verovio_compiled.odd index 7b77a819cba..6f7ff7c7885 100644 --- a/libmei/mei/develop/mei-verovio_compiled.odd +++ b/libmei/mei/develop/mei-verovio_compiled.odd @@ -12777,6 +12777,16 @@
+
+ Attributes that record the function (i.e., placement) of forme work elements. + + + Records the function (i.e., placement) of a page header or footer. + + + + + Logical domain attributes. @@ -14282,16 +14292,6 @@ - - Attributes that record the function (i.e., placement) of page running text elements. - - - Records the function (i.e., placement) of a page header or footer. - - - - - Logical domain attributes. @@ -17074,8 +17074,8 @@
page footerA running footer. + - @@ -17092,8 +17092,8 @@ page headerA running header. + - From c3d59820dd279936deaf9812480dc74d0dee73f4 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sat, 1 Jul 2023 08:57:53 +0200 Subject: [PATCH 35/36] Rename runningtext to formework --- include/vrv/comparison.h | 10 +++++----- include/vrv/runningelement.h | 2 +- src/iohumdrum.cpp | 4 ++-- src/iomei.cpp | 4 ++-- src/runningelement.cpp | 6 +++--- src/scoredef.cpp | 8 ++++---- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/vrv/comparison.h b/include/vrv/comparison.h index 40d5bbaae07..d338ee2a7ce 100644 --- a/include/vrv/comparison.h +++ b/include/vrv/comparison.h @@ -381,23 +381,23 @@ class AttVisibilityComparison : public ClassIdComparison { }; //---------------------------------------------------------------------------- -// AttRunningtextComparison +// AttFormeworkComparison //---------------------------------------------------------------------------- /** * This class evaluates if the object is of a certain ClassId and has a @func of value func. */ -class AttRunningtextComparison : public ClassIdComparison { +class AttFormeworkComparison : public ClassIdComparison { public: - AttRunningtextComparison(ClassId classId, data_PGFUNC func) : ClassIdComparison(classId) { m_func = func; } + AttFormeworkComparison(ClassId classId, data_PGFUNC func) : ClassIdComparison(classId) { m_func = func; } bool operator()(const Object *object) override { if (!MatchesType(object)) return false; // This should not happen, but just in case - if (!object->HasAttClass(ATT_RUNNINGTEXT)) return false; - const AttRunningtext *element = dynamic_cast(object); + if (!object->HasAttClass(ATT_FORMEWORK)) return false; + const AttFormework *element = dynamic_cast(object); assert(element); return (element->GetFunc() == m_func); } diff --git a/include/vrv/runningelement.h b/include/vrv/runningelement.h index 5f8e2d26ab6..a561c64cee0 100644 --- a/include/vrv/runningelement.h +++ b/include/vrv/runningelement.h @@ -25,7 +25,7 @@ class TextElement; * This class represents running elements (headers and footers). * It is not an abstract class but should not be instanciated directly. */ -class RunningElement : public TextLayoutElement, public AttRunningtext { +class RunningElement : public TextLayoutElement, public AttFormework { public: /** * @name Constructors, destructors, reset methods diff --git a/src/iohumdrum.cpp b/src/iohumdrum.cpp index 63baf0646d8..fcc530446b3 100644 --- a/src/iohumdrum.cpp +++ b/src/iohumdrum.cpp @@ -4632,7 +4632,7 @@ bool HumdrumInput::prepareFooter( // std::string meicontent = meioutput.GetOutput(); // std::cout << "MEI CONTENT " << meicontent << std::endl; - AttRunningtextComparison comparison(PGFOOT, PGFUNC_first); + AttFormeworkComparison comparison(PGFOOT, PGFUNC_first); Object *pgfoot = tempdoc.GetCurrentScoreDef()->FindDescendantByComparison(&comparison); if (pgfoot == NULL) { return false; @@ -4653,7 +4653,7 @@ bool HumdrumInput::prepareFooter( m_doc->GetCurrentScoreDef()->AddChild(pgfoot); - AttRunningtextComparison comparison2(PGFOOT, PGFUNC_all); + AttFormeworkComparison comparison2(PGFOOT, PGFUNC_all); Object *pgfoot2 = tempdoc.GetCurrentScoreDef()->FindDescendantByComparison(&comparison2); if (pgfoot2 == NULL) { return true; diff --git a/src/iomei.cpp b/src/iomei.cpp index efead7e24ce..fd24390695a 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -1731,7 +1731,7 @@ void MEIOutput::WriteRunningElement(pugi::xml_node currentNode, RunningElement * assert(runningElement); this->WriteTextLayoutElement(currentNode, runningElement); - runningElement->WriteRunningtext(currentNode); + runningElement->WriteFormework(currentNode); } void MEIOutput::WriteGrpSym(pugi::xml_node currentNode, GrpSym *grpSym) @@ -4909,7 +4909,7 @@ bool MEIInput::ReadTextLayoutElement(pugi::xml_node element, TextLayoutElement * bool MEIInput::ReadRunningElement(pugi::xml_node element, RunningElement *object) { this->ReadTextLayoutElement(element, object); - object->ReadRunningtext(element); + object->ReadFormework(element); return true; } diff --git a/src/runningelement.cpp b/src/runningelement.cpp index fcb7dfab81a..3fcc0a36082 100644 --- a/src/runningelement.cpp +++ b/src/runningelement.cpp @@ -48,9 +48,9 @@ RunningElement::RunningElement(ClassId classId) : TextLayoutElement(classId, "re */ RunningElement::RunningElement(ClassId classId, const std::string &classIdStr) - : TextLayoutElement(classId, classIdStr), AttRunningtext() + : TextLayoutElement(classId, classIdStr), AttFormework() { - this->RegisterAttClass(ATT_RUNNINGTEXT); + this->RegisterAttClass(ATT_FORMEWORK); this->Reset(); } @@ -60,7 +60,7 @@ RunningElement::~RunningElement() {} void RunningElement::Reset() { TextLayoutElement::Reset(); - this->ResetRunningtext(); + this->ResetFormework(); m_isGenerated = false; diff --git a/src/scoredef.cpp b/src/scoredef.cpp index 7cf7715fe4c..2cc929116dc 100644 --- a/src/scoredef.cpp +++ b/src/scoredef.cpp @@ -583,25 +583,25 @@ void ScoreDef::SetDrawingLabelsWidth(int width) PgFoot *ScoreDef::GetPgFoot(data_PGFUNC func) { - AttRunningtextComparison comparison(PGFOOT, func); + AttFormeworkComparison comparison(PGFOOT, func); return vrv_cast(this->FindDescendantByComparison(&comparison)); } const PgFoot *ScoreDef::GetPgFoot(data_PGFUNC func) const { - AttRunningtextComparison comparison(PGFOOT, func); + AttFormeworkComparison comparison(PGFOOT, func); return vrv_cast(this->FindDescendantByComparison(&comparison)); } PgHead *ScoreDef::GetPgHead(data_PGFUNC func) { - AttRunningtextComparison comparison(PGHEAD, func); + AttFormeworkComparison comparison(PGHEAD, func); return vrv_cast(this->FindDescendantByComparison(&comparison)); } const PgHead *ScoreDef::GetPgHead(data_PGFUNC func) const { - AttRunningtextComparison comparison(PGHEAD, func); + AttFormeworkComparison comparison(PGHEAD, func); return vrv_cast(this->FindDescendantByComparison(&comparison)); } From 0ebb4fe8d4b75d6dddad22b17cb2163c39533e85 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sun, 2 Jul 2023 10:49:22 +0200 Subject: [PATCH 36/36] Remove pghead2.h/cpp --- include/vrv/pghead2.h | 64 ------------------------------------ src/pghead2.cpp | 75 ------------------------------------------- 2 files changed, 139 deletions(-) delete mode 100644 include/vrv/pghead2.h delete mode 100644 src/pghead2.cpp diff --git a/include/vrv/pghead2.h b/include/vrv/pghead2.h deleted file mode 100644 index 8f3d0605875..00000000000 --- a/include/vrv/pghead2.h +++ /dev/null @@ -1,64 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: pghead2.h -// Author: Laurent Pugin -// Created: 2017 -// Copyright (c) Authors and others. All rights reserved. -///////////////////////////////////////////////////////////////////////////// - -#ifndef __VRV_PGHEAD2_H__ -#define __VRV_PGHEAD2_H__ - -#include "runningelement.h" - -namespace vrv { - -//---------------------------------------------------------------------------- -// PgHead2 -//---------------------------------------------------------------------------- - -/** - * This class represents an MEI pgHead2. - */ -class PgHead2 : public RunningElement { -public: - /** - * @name Constructors, destructors, and other standard methods - * Reset method resets all attribute classes - */ - ///@{ - PgHead2(); - virtual ~PgHead2(); - void Reset() override; - std::string GetClassName() const override { return "PgHead2"; } - ///@} - - /** - * Overriden to get the appropriate margin - */ - int GetTotalHeight(const Doc *doc) const override; - - //----------// - // Functors // - //----------// - - /** - * Interface for class functor visitation - */ - ///@{ - FunctorCode Accept(Functor &functor) override; - FunctorCode Accept(ConstFunctor &functor) const override; - FunctorCode AcceptEnd(Functor &functor) override; - FunctorCode AcceptEnd(ConstFunctor &functor) const override; - ///@} - -private: - // -public: - // -private: - // -}; - -} // namespace vrv - -#endif diff --git a/src/pghead2.cpp b/src/pghead2.cpp deleted file mode 100644 index 892067cffd3..00000000000 --- a/src/pghead2.cpp +++ /dev/null @@ -1,75 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: pghead2.cpp -// Author: Laurent Pugin -// Created: 2017 -// Copyright (c) Authors and others. All rights reserved. -///////////////////////////////////////////////////////////////////////////// - -#include "pghead2.h" - -//---------------------------------------------------------------------------- - -#include - -//---------------------------------------------------------------------------- - -#include "doc.h" -#include "functor.h" - -namespace vrv { - -//---------------------------------------------------------------------------- -// PgHead2 -//---------------------------------------------------------------------------- - -static const ClassRegistrar s_factory("pgHead2", PGHEAD2); - -PgHead2::PgHead2() : RunningElement(PGHEAD2, "pghead2-") -{ - this->Reset(); -} - -PgHead2::~PgHead2() {} - -void PgHead2::Reset() -{ - RunningElement::Reset(); -} - -int PgHead2::GetTotalHeight(const Doc *doc) const -{ - assert(doc); - - int height = this->GetContentHeight(); - if (height > 0) { - const int unit = doc->GetDrawingUnit(100); - height += doc->GetOptions()->m_bottomMarginPgHead.GetValue() * unit; - } - return height; -} - -//---------------------------------------------------------------------------- -// Functor methods -//---------------------------------------------------------------------------- - -FunctorCode PgHead2::Accept(Functor &functor) -{ - return functor.VisitPgHead2(this); -} - -FunctorCode PgHead2::Accept(ConstFunctor &functor) const -{ - return functor.VisitPgHead2(this); -} - -FunctorCode PgHead2::AcceptEnd(Functor &functor) -{ - return functor.VisitPgHead2End(this); -} - -FunctorCode PgHead2::AcceptEnd(ConstFunctor &functor) const -{ - return functor.VisitPgHead2End(this); -} - -} // namespace vrv