diff --git a/Verovio.xcodeproj/project.pbxproj b/Verovio.xcodeproj/project.pbxproj index b129cb6e9af..6a55d542017 100644 --- a/Verovio.xcodeproj/project.pbxproj +++ b/Verovio.xcodeproj/project.pbxproj @@ -800,6 +800,12 @@ 4DE96E3B21C4373200CB85BE /* bracketspan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DE96E3A21C4373200CB85BE /* bracketspan.cpp */; }; 4DE96E3C21C4373200CB85BE /* bracketspan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DE96E3A21C4373200CB85BE /* bracketspan.cpp */; }; 4DE96E3D21C4373200CB85BE /* bracketspan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DE96E3A21C4373200CB85BE /* bracketspan.cpp */; }; + 4DEBE6E12B36E78900B67DFB /* facsimilefunctor.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DEBE6E02B36E78900B67DFB /* facsimilefunctor.h */; }; + 4DEBE6E22B36E78900B67DFB /* facsimilefunctor.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DEBE6E02B36E78900B67DFB /* facsimilefunctor.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 4DEBE6E42B36E79600B67DFB /* facsimilefunctor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEBE6E32B36E79600B67DFB /* facsimilefunctor.cpp */; }; + 4DEBE6E52B36E79600B67DFB /* facsimilefunctor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEBE6E32B36E79600B67DFB /* facsimilefunctor.cpp */; }; + 4DEBE6E62B36E9B300B67DFB /* facsimilefunctor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEBE6E32B36E79600B67DFB /* facsimilefunctor.cpp */; }; + 4DEBE6E72B36E9B400B67DFB /* facsimilefunctor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEBE6E32B36E79600B67DFB /* facsimilefunctor.cpp */; }; 4DEC4D5A21C800A000D1D273 /* abbr.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DEC4D5921C8009600D1D273 /* abbr.h */; }; 4DEC4D7A21C8048700D1D273 /* abbr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEC4D7921C8048700D1D273 /* abbr.cpp */; }; 4DEC4D7B21C8048700D1D273 /* abbr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEC4D7921C8048700D1D273 /* abbr.cpp */; }; @@ -2014,6 +2020,8 @@ 4DE644F41EDBEA01002FBE6C /* breath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = breath.cpp; path = src/breath.cpp; sourceTree = ""; }; 4DE96E3821C4370E00CB85BE /* bracketspan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = bracketspan.h; path = include/vrv/bracketspan.h; sourceTree = ""; }; 4DE96E3A21C4373200CB85BE /* bracketspan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = bracketspan.cpp; path = src/bracketspan.cpp; sourceTree = ""; }; + 4DEBE6E02B36E78900B67DFB /* facsimilefunctor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = facsimilefunctor.h; path = include/vrv/facsimilefunctor.h; sourceTree = ""; }; + 4DEBE6E32B36E79600B67DFB /* facsimilefunctor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = facsimilefunctor.cpp; path = src/facsimilefunctor.cpp; sourceTree = ""; }; 4DEC4D5921C8009600D1D273 /* abbr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = abbr.h; path = include/vrv/abbr.h; sourceTree = ""; }; 4DEC4D7921C8048700D1D273 /* abbr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = abbr.cpp; path = src/abbr.cpp; sourceTree = ""; }; 4DEC4D7D21C804C500D1D273 /* add.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = add.cpp; path = src/add.cpp; sourceTree = ""; }; @@ -3012,6 +3020,8 @@ E7265E6D29DC6FD200D11F41 /* castofffunctor.h */, E763EF4129E939FB0029E56D /* convertfunctor.cpp */, E763EF3E29E939C00029E56D /* convertfunctor.h */, + 4DEBE6E32B36E79600B67DFB /* facsimilefunctor.cpp */, + 4DEBE6E02B36E78900B67DFB /* facsimilefunctor.h */, E74A806028BC9111005274E7 /* findfunctor.cpp */, E74A806528BC97D5005274E7 /* findfunctor.h */, E722106528F856C4002CD6E9 /* findlayerelementsfunctor.cpp */, @@ -3384,6 +3394,7 @@ 40DA9C3720905CEB006BED92 /* ioabc.h in Headers */, 4DB3D8CD1F83D11100B5FC2B /* harm.h in Headers */, 40D45EC2204EEAFB009C1EC9 /* instrdef.h in Headers */, + 4DEBE6E12B36E78900B67DFB /* facsimilefunctor.h in Headers */, 4D94E0E22995411100F49F89 /* meibasic.h in Headers */, BD2E4D9B2875882200B04350 /* stem.h in Headers */, 4DACC9EA2990F29A00B55913 /* attmodule.h in Headers */, @@ -3441,6 +3452,7 @@ E7908EA0298582090004C1F9 /* alignfunctor.h in Headers */, BB4C4B9822A932E5001F6AF0 /* durationinterface.h in Headers */, BB4C4BB722A932F6001F6AF0 /* jsonxx.h in Headers */, + 4DEBE6E22B36E78900B67DFB /* facsimilefunctor.h in Headers */, BB4C4B1622A932C8001F6AF0 /* systemelement.h in Headers */, BB4C4AC622A932B6001F6AF0 /* measure.h in Headers */, E741AD00299A3D3500854426 /* calcslurdirectionfunctor.h in Headers */, @@ -3926,6 +3938,7 @@ E7F39C6229A62B430055DBE0 /* adjustclefchangesfunctor.cpp in Sources */, E79320682991454000D80975 /* calcstemfunctor.cpp in Sources */, 4DED4F18294733140073E504 /* altsyminterface.cpp in Sources */, + 4DEBE6E72B36E9B400B67DFB /* facsimilefunctor.cpp in Sources */, 4DEF8A6521B7AAF90093A76B /* f.cpp in Sources */, 4D2073F922A3BCE000E0765F /* tabdursym.cpp in Sources */, 4D16940B1E3A44F300569BF4 /* keysig.cpp in Sources */, @@ -4206,6 +4219,7 @@ 8F086EF1188539540037FD8E /* keysig.cpp in Sources */, E74A806C28BC98B2005274E7 /* functorinterface.cpp in Sources */, E7870357299CF06D00156DC4 /* adjustarpegfunctor.cpp in Sources */, + 4DEBE6E62B36E9B300B67DFB /* facsimilefunctor.cpp in Sources */, 4DEC4D9E21C81E9400D1D273 /* orig.cpp in Sources */, 4DDBBB5D1C7AE45900054AFF /* hairpin.cpp in Sources */, 4D43C30C1A9BB22A00EA28F3 /* view_mensural.cpp in Sources */, @@ -4489,6 +4503,7 @@ 4DB3D8D51F83D12B00B5FC2B /* tempo.cpp in Sources */, 4DEC4DA021C81E9400D1D273 /* orig.cpp in Sources */, E7F39C6329A62B440055DBE0 /* adjustclefchangesfunctor.cpp in Sources */, + 4DEBE6E42B36E79600B67DFB /* facsimilefunctor.cpp in Sources */, E79320692991454000D80975 /* calcstemfunctor.cpp in Sources */, 8F3DD33E18854B2E0051330C /* beam.cpp in Sources */, 4DED4F19294733140073E504 /* altsyminterface.cpp in Sources */, @@ -4771,6 +4786,7 @@ E793206A2991454100D80975 /* calcstemfunctor.cpp in Sources */, BB4C4AD722A932B6001F6AF0 /* staff.cpp in Sources */, 4DED4F1A294733140073E504 /* altsyminterface.cpp in Sources */, + 4DEBE6E52B36E79600B67DFB /* facsimilefunctor.cpp in Sources */, BB4C4B9F22A932E5001F6AF0 /* positioninterface.cpp in Sources */, BB4C4B5322A932D7001F6AF0 /* halfmrpt.cpp in Sources */, BB4C4B8722A932DF001F6AF0 /* num.cpp in Sources */, diff --git a/include/vrv/doc.h b/include/vrv/doc.h index 3952633bb49..8b387ef995a 100644 --- a/include/vrv/doc.h +++ b/include/vrv/doc.h @@ -109,7 +109,6 @@ class Doc : public Object { /** * Getter and setter for the DocType. - * The setter resets the document. */ ///@{ DocType GetType() const { return m_type; } @@ -370,6 +369,18 @@ class Doc : public Object { */ void ConvertMarkupDoc(bool permanent = true); + /** + * Sync the coordinate provided trought to m_drawingFacsX/Y. + * Call the SyncToFacsimile functor. + */ + void SyncFromFacsimileDoc(); + + /** + * Sync the coordinate provided in rendering to a . + * The document must have encoded layout and the option --break encoded must have enabled. + */ + void SyncToFacsimileDoc(); + /** * Transpose the content of the doc. */ @@ -387,6 +398,11 @@ class Doc : public Object { */ Page *SetDrawingPage(int pageIdx); + /** + * Update the drawing page sizes when a page is set as drawing page. + */ + void UpdatePageDrawingSizes(); + /** * Reset drawing page to NULL. * This might be necessary if we have replaced a page in the document. diff --git a/include/vrv/durationinterface.h b/include/vrv/durationinterface.h index 67bf2caab43..17d0ec0cc22 100644 --- a/include/vrv/durationinterface.h +++ b/include/vrv/durationinterface.h @@ -16,7 +16,6 @@ namespace vrv { -class FunctorParams; class Mensur; class Object; diff --git a/include/vrv/facsimilefunctor.h b/include/vrv/facsimilefunctor.h new file mode 100644 index 00000000000..1273343626c --- /dev/null +++ b/include/vrv/facsimilefunctor.h @@ -0,0 +1,136 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: facsimilefunctor.h +// Author: Laurent Pugin +// Created: 2023 +// Copyright (c) Authors and others. All rights reserved. +///////////////////////////////////////////////////////////////////////////// + +#ifndef __VRV_FACSIMILEFUNCTOR_H__ +#define __VRV_FACSIMILEFUNCTOR_H__ + +#include "functor.h" +#include "view.h" + +namespace vrv { + +class LayerElement; +class Measure; +class Page; +class Pb; +class Sb; +class Staff; +class Surface; +class System; + +//---------------------------------------------------------------------------- +// SyncFromFacsimileFunctor +//---------------------------------------------------------------------------- + +/** + * This class sync the layout encoded in the facsimile to m_Abs members + */ +class SyncFromFacsimileFunctor : public Functor { +public: + /** + * @name Constructors, destructors + */ + ///@{ + SyncFromFacsimileFunctor(Doc *doc); + virtual ~SyncFromFacsimileFunctor() = default; + ///@} + + /* + * Abstract base implementation + */ + bool ImplementsEndInterface() const override { return false; } + + /* + * Functor interface + */ + ///@{ + FunctorCode VisitLayerElement(LayerElement *layerElement) override; + FunctorCode VisitMeasure(Measure *measure) override; + FunctorCode VisitPage(Page *page) override; + FunctorCode VisitPb(Pb *pb) override; + FunctorCode VisitSb(Sb *sb) override; + FunctorCode VisitStaff(Staff *staff) override; + FunctorCode VisitSystem(System *system) override; + ///@} + +protected: + // +private: + // +public: + // +private: + /** The doc */ + Doc *m_doc; + // + View m_view; + // + Page *m_currentPage; + System *m_currentSystem; +}; + +//---------------------------------------------------------------------------- +// SyncToFacsimileFunctor +//---------------------------------------------------------------------------- + +/** + * This class sync the layout calculated to the facsimile + */ +class SyncToFacsimileFunctor : public Functor { +public: + /** + * @name Constructors, destructors + */ + ///@{ + SyncToFacsimileFunctor(Doc *doc); + virtual ~SyncToFacsimileFunctor() = default; + ///@} + + /* + * Abstract base implementation + */ + bool ImplementsEndInterface() const override { return false; } + + /* + * Functor interface + */ + ///@{ + FunctorCode VisitLayerElement(LayerElement *layerElement) override; + FunctorCode VisitMeasure(Measure *measure) override; + FunctorCode VisitPage(Page *page) override; + FunctorCode VisitPb(Pb *pb) override; + FunctorCode VisitSb(Sb *sb) override; + FunctorCode VisitStaff(Staff *staff) override; + FunctorCode VisitSystem(System *system) override; + ///@} + +protected: + // +private: + /** Create zone if not exist */ + Zone *GetZone(FacsimileInterface *interface, std::string type); + +public: + // +private: + /** The doc */ + Doc *m_doc; + // + View m_view; + /** The surface we are going to add / update zone */ + Surface *m_surface; + // + Page *m_currentPage; + System *m_currentSystem; + // + int m_pageMarginTop; + int m_pageMarginLeft; +}; + +} // namespace vrv + +#endif // __VRV_FACSIMILEFUNCTOR_H__ diff --git a/include/vrv/facsimileinterface.h b/include/vrv/facsimileinterface.h index cbc46f7ddb3..7afafef144b 100644 --- a/include/vrv/facsimileinterface.h +++ b/include/vrv/facsimileinterface.h @@ -13,8 +13,11 @@ #include "interface.h" namespace vrv { -class FunctorParams; -class View; + +class Facsimile; +class PrepareFacsimileFunctor; +class ResetDataFunctor; +class Surface; class Zone; //---------------------------------------------------------------------------- @@ -56,8 +59,23 @@ class FacsimileInterface : public Interface, public AttFacsimile { const Zone *GetZone() const { return m_zone; } ///@} + //-----------------// + // Pseudo functors // + //-----------------// + + /** + * We have functor code in the interface for avoiding code duplication in each implementation class. + * Since we are in an interface, we need to pass the object (implementation) to + * the pseudo functor method. + */ + ///@{ + FunctorCode InterfacePrepareFacsimile(PrepareFacsimileFunctor &functor, Object *object); + FunctorCode InterfaceResetData(ResetDataFunctor &functor, Object *object); + ///@} + private: - Zone *m_zone = NULL; + Zone *m_zone; + Surface *m_surface; }; } // namespace vrv #endif diff --git a/include/vrv/layerelement.h b/include/vrv/layerelement.h index af0917a61d7..085fa811845 100644 --- a/include/vrv/layerelement.h +++ b/include/vrv/layerelement.h @@ -386,7 +386,7 @@ class LayerElement : public Object, public: /** Absolute position X. This is used for facsimile (transcription) encoding */ - int m_xAbs; + int m_drawingFacsX; /** * This stores a pointer to the cross-staff (if any) and the appropriate layer * See PrepareCrossStaffFunctor diff --git a/include/vrv/measure.h b/include/vrv/measure.h index e9fe0cef9ca..49ab432a0d7 100644 --- a/include/vrv/measure.h +++ b/include/vrv/measure.h @@ -11,6 +11,7 @@ #include "atts_cmn.h" #include "atts_shared.h" #include "barline.h" +#include "facsimileinterface.h" #include "horizontalaligner.h" #include "object.h" @@ -34,6 +35,7 @@ class TimestampAttr; * For internally simplication of processing, unmeasured music is contained in one single measure object */ class Measure : public Object, + public FacsimileInterface, public AttBarring, public AttCoordX1, public AttCoordX2, @@ -63,6 +65,17 @@ class Measure : public Object, */ void CloneReset() override; + /** + * @name Getter to interfaces + */ + ///@{ + FacsimileInterface *GetFacsimileInterface() override { return vrv_cast(this); } + const FacsimileInterface *GetFacsimileInterface() const override + { + return vrv_cast(this); + } + ///@} + /** * Return true if measured music (otherwise we have fake measures) */ @@ -358,8 +371,8 @@ class Measure : public Object, * This is the left and right position of the measure. */ ///@{ - int m_xAbs; - int m_xAbs2; + int m_drawingFacsX1; + int m_drawingFacsX2; ///@} /** diff --git a/include/vrv/object.h b/include/vrv/object.h index 1cb3f41ff41..31bbf863f95 100644 --- a/include/vrv/object.h +++ b/include/vrv/object.h @@ -31,7 +31,6 @@ class EditorialElement; class Output; class Filters; class Functor; -class FunctorParams; class Functor; class ConstFunctor; class LinkingInterface; diff --git a/include/vrv/pb.h b/include/vrv/pb.h index 92cecf39fd6..11f66ab2b0a 100644 --- a/include/vrv/pb.h +++ b/include/vrv/pb.h @@ -9,6 +9,7 @@ #define __VRV_PB_H__ #include "atts_shared.h" +#include "facsimileinterface.h" #include "systemelement.h" namespace vrv { @@ -21,7 +22,7 @@ namespace vrv { * This class represents a MEI pb in score-based MEI. * In page-based MEI, it remains as is as. Actual pages are represented by Page objects. */ -class Pb : public SystemElement, public AttNNumberLike { +class Pb : public SystemElement, public FacsimileInterface, public AttNNumberLike { public: /** * @name Constructors, destructors, and other standard methods @@ -35,6 +36,16 @@ class Pb : public SystemElement, public AttNNumberLike { std::string GetClassName() const override { return "Pb"; } ///@} + /** + * @name Getter to interfaces + */ + ///@{ + FacsimileInterface *GetFacsimileInterface() override { return vrv_cast(this); } + const FacsimileInterface *GetFacsimileInterface() const override + { + return vrv_cast(this); + } + //----------// // Functors // //----------// diff --git a/include/vrv/preparedatafunctor.h b/include/vrv/preparedatafunctor.h index 412ef9f3918..793d1e66c0e 100644 --- a/include/vrv/preparedatafunctor.h +++ b/include/vrv/preparedatafunctor.h @@ -218,6 +218,11 @@ class PrepareFacsimileFunctor : public Functor { */ const ListOfObjects &GetZonelessSyls() const { return m_zonelessSyls; } + /* + * Getter for the facsimile + */ + Facsimile *GetFacsimile() const { return m_facsimile; } + /* * Functor interface */ diff --git a/include/vrv/resetfunctor.h b/include/vrv/resetfunctor.h index 2e681f1d877..f8f4d5c1032 100644 --- a/include/vrv/resetfunctor.h +++ b/include/vrv/resetfunctor.h @@ -62,6 +62,7 @@ class ResetDataFunctor : public Functor { FunctorCode VisitMeasure(Measure *measure) override; FunctorCode VisitMRest(MRest *mRest) override; FunctorCode VisitNote(Note *note) override; + FunctorCode VisitObject(Object *object) override; FunctorCode VisitRepeatMark(RepeatMark *repeatMark) override; FunctorCode VisitRest(Rest *rest) override; FunctorCode VisitSection(Section *section) override; diff --git a/include/vrv/sb.h b/include/vrv/sb.h index 83d4812dd7a..f1d43319e0e 100644 --- a/include/vrv/sb.h +++ b/include/vrv/sb.h @@ -9,6 +9,7 @@ #define __VRV_SB_H__ #include "atts_shared.h" +#include "facsimileinterface.h" #include "systemelement.h" namespace vrv { @@ -21,7 +22,7 @@ namespace vrv { * This class represents a MEI sb in score-based MEI. * In page-based MEI, it remains as it is. Actual systems are represented by System objects. */ -class Sb : public SystemElement, public AttNNumberLike { +class Sb : public SystemElement, public FacsimileInterface, public AttNNumberLike { public: /** * @name Constructors, destructors, and other standard methods @@ -35,6 +36,16 @@ class Sb : public SystemElement, public AttNNumberLike { std::string GetClassName() const override { return "Sb"; } ///@} + /** + * @name Getter to interfaces + */ + ///@{ + FacsimileInterface *GetFacsimileInterface() override { return vrv_cast(this); } + const FacsimileInterface *GetFacsimileInterface() const override + { + return vrv_cast(this); + } + //----------// // Functors // //----------// diff --git a/include/vrv/staff.h b/include/vrv/staff.h index db2edc25618..51cbdbd9346 100644 --- a/include/vrv/staff.h +++ b/include/vrv/staff.h @@ -226,7 +226,7 @@ class Staff : public Object, * The Y absolute position of the staff for facsimile (transcription) encodings. * This is the top left corner of the staff (the X position is the position of the system). */ - int m_yAbs; + int m_drawingFacsY; StaffDef *m_drawingStaffDef; diff --git a/include/vrv/system.h b/include/vrv/system.h index a8900f2a9c5..7485e2abfbe 100644 --- a/include/vrv/system.h +++ b/include/vrv/system.h @@ -191,12 +191,12 @@ class System : public Object, public DrawingListInterface, public AttTyped { * The Y absolute position of the staff for facsimile (transcription) encodings. * This is the top left corner of the system. */ - int m_yAbs; + int m_drawingFacsY; /** * The x absolute position of the system for facsimile layouts. * This is the top left corner of the system. */ - int m_xAbs; + int m_drawingFacsX; /** * The width used by the abbreviated labels at the left of the system. * It is used internally when calculating the layout and it is not stored in the file. diff --git a/include/vrv/vrvdef.h b/include/vrv/vrvdef.h index 86ead543896..eb3644af011 100644 --- a/include/vrv/vrvdef.h +++ b/include/vrv/vrvdef.h @@ -61,11 +61,8 @@ namespace vrv { #ifdef VRV_DYNAMIC_CAST // To be used for all cases where type is cheched through Object::m_type #define vrv_cast dynamic_cast -// To be used for all FunctorParams casts within Functors -#define vrv_params_cast dynamic_cast #else #define vrv_cast static_cast -#define vrv_params_cast static_cast #endif //---------------------------------------------------------------------------- diff --git a/src/adjustxrelfortranscriptionfunctor.cpp b/src/adjustxrelfortranscriptionfunctor.cpp index c4e4c1f20d4..be005259ec4 100644 --- a/src/adjustxrelfortranscriptionfunctor.cpp +++ b/src/adjustxrelfortranscriptionfunctor.cpp @@ -21,7 +21,7 @@ AdjustXRelForTranscriptionFunctor::AdjustXRelForTranscriptionFunctor() : Functor FunctorCode AdjustXRelForTranscriptionFunctor::VisitLayerElement(LayerElement *layerElement) { - if (layerElement->m_xAbs == VRV_UNSET) return FUNCTOR_CONTINUE; + if (layerElement->m_drawingFacsX == VRV_UNSET) return FUNCTOR_CONTINUE; if (layerElement->IsScoreDefElement()) return FUNCTOR_SIBLINGS; diff --git a/src/doc.cpp b/src/doc.cpp index 8d1710d09e3..d138ced9ba9 100644 --- a/src/doc.cpp +++ b/src/doc.cpp @@ -23,6 +23,7 @@ #include "convertfunctor.h" #include "docselection.h" #include "expansion.h" +#include "facsimilefunctor.h" #include "featureextractor.h" #include "functor.h" #include "glyph.h" @@ -58,6 +59,7 @@ #include "staff.h" #include "staffdef.h" #include "staffgrp.h" +#include "surface.h" #include "syl.h" #include "syllable.h" #include "system.h" @@ -1391,6 +1393,32 @@ void Doc::ConvertMarkupDoc(bool permanent) } } +void Doc::SyncFromFacsimileDoc() +{ + PrepareFacsimileFunctor prepareFacsimile(this->GetFacsimile()); + this->Process(prepareFacsimile); + + SyncFromFacsimileFunctor syncFromFacsimileFunctor(this); + this->Process(syncFromFacsimileFunctor); +} + +void Doc::SyncToFacsimileDoc() +{ + // Create a new facsimile object if we do not have one already + if (!this->HasFacsimile()) { + Facsimile *facsimile = new Facsimile(); + this->SetFacsimile(facsimile); + } + if (!m_facsimile->FindDescendantByType(SURFACE)) { + m_facsimile->AddChild(new Surface()); + } + m_facsimile->SetType("transcription"); + m_facsimile->ClearChildren(); + + SyncToFacsimileFunctor syncToFacimileFunctor(this); + this->Process(syncToFacimileFunctor); +} + void Doc::TransposeDoc() { Transposer transposer; @@ -2010,6 +2038,15 @@ Page *Doc::SetDrawingPage(int pageIdx) m_drawingPage = vrv_cast(pages->GetChild(pageIdx)); assert(m_drawingPage); + UpdatePageDrawingSizes(); + + return m_drawingPage; +} + +void Doc::UpdatePageDrawingSizes() +{ + assert(m_drawingPage); + int glyph_size; // we use the page members only if set (!= -1) @@ -2075,8 +2112,6 @@ Page *Doc::SetDrawingPage(int pageIdx) glyph_size = this->GetGlyphWidth(SMUFL_E0A2_noteheadWhole, 100, 0); m_drawingBrevisWidth = (int)((glyph_size * 0.8) / 2); - - return m_drawingPage; } int Doc::CalcMusicFontSize() diff --git a/src/facsimilefunctor.cpp b/src/facsimilefunctor.cpp new file mode 100644 index 00000000000..73ec1ef23ca --- /dev/null +++ b/src/facsimilefunctor.cpp @@ -0,0 +1,229 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: facsimilefunctor.cpp +// Author: Laurent Pugin +// Created: 2023 +// Copyright (c) Authors and others. All rights reserved. +///////////////////////////////////////////////////////////////////////////// + +#include "facsimilefunctor.h" + +//---------------------------------------------------------------------------- + +#include "doc.h" +#include "layerelement.h" +#include "measure.h" +#include "page.h" +#include "pb.h" +#include "sb.h" +#include "staff.h" +#include "surface.h" +#include "system.h" +#include "vrv.h" +#include "zone.h" + +//---------------------------------------------------------------------------- + +namespace vrv { + +//---------------------------------------------------------------------------- +// SyncFromFacsimileFunctor +//---------------------------------------------------------------------------- + +SyncFromFacsimileFunctor::SyncFromFacsimileFunctor(Doc *doc) : Functor() +{ + m_doc = doc; + m_view.SetDoc(doc); + m_currentPage = NULL; + m_currentSystem = NULL; +} + +FunctorCode SyncFromFacsimileFunctor::VisitLayerElement(LayerElement *layerElement) +{ + if (!layerElement->Is({ NOTE, REST })) return FUNCTOR_CONTINUE; + + Zone *zone = layerElement->GetZone(); + assert(zone); + layerElement->m_drawingFacsX = m_view.ToLogicalX(zone->GetUlx() * DEFINITION_FACTOR); + + return FUNCTOR_CONTINUE; +} + +FunctorCode SyncFromFacsimileFunctor::VisitMeasure(Measure *measure) +{ + Zone *zone = measure->GetZone(); + assert(zone); + measure->m_drawingFacsX1 = m_view.ToLogicalX(zone->GetUlx() * DEFINITION_FACTOR); + measure->m_drawingFacsX2 = m_view.ToLogicalX(zone->GetLrx() * DEFINITION_FACTOR); + + return FUNCTOR_CONTINUE; +} + +FunctorCode SyncFromFacsimileFunctor::VisitPage(Page *page) +{ + m_currentPage = page; + m_doc->SetDrawingPage(m_currentPage->GetIdx()); + + return FUNCTOR_CONTINUE; +} + +FunctorCode SyncFromFacsimileFunctor::VisitPb(Pb *pb) +{ + // This would happen if we run the functor on data not converted to page-based + assert(m_currentPage); + + Zone *zone = pb->GetZone(); + assert(zone && zone->GetParent()); + Surface *surface = (zone->GetParent()->Is(SURFACE)) ? vrv_cast(zone->GetParent()) : NULL; + // Use the parent surface attributes if given + if (surface && surface->HasLrx() && surface->HasLry()) { + m_currentPage->m_pageHeight = surface->GetLry() * DEFINITION_FACTOR; + m_currentPage->m_pageWidth = surface->GetLrx() * DEFINITION_FACTOR; + } + // Fallback on zone + else { + m_currentPage->m_pageHeight = zone->GetLry() * DEFINITION_FACTOR; + m_currentPage->m_pageWidth = zone->GetLrx() * DEFINITION_FACTOR; + } + // Update the page size to have to View::ToLogicalX/Y valid + m_doc->UpdatePageDrawingSizes(); + + return FUNCTOR_CONTINUE; +} + +FunctorCode SyncFromFacsimileFunctor::VisitSb(Sb *sb) +{ + // This would happen if we run the functor on data not converted to page-based + assert(m_currentSystem); + + Zone *zone = sb->GetZone(); + assert(zone); + m_currentSystem->m_drawingFacsX = m_view.ToLogicalX(zone->GetUlx() * DEFINITION_FACTOR); + m_currentSystem->m_drawingFacsY = m_view.ToLogicalY(zone->GetUly() * DEFINITION_FACTOR); + + return FUNCTOR_CONTINUE; +} + +FunctorCode SyncFromFacsimileFunctor::VisitStaff(Staff *staff) +{ + Zone *zone = staff->GetZone(); + assert(zone); + staff->m_drawingFacsY = m_view.ToLogicalY(zone->GetUly() * DEFINITION_FACTOR); + + return FUNCTOR_CONTINUE; +} + +FunctorCode SyncFromFacsimileFunctor::VisitSystem(System *system) +{ + m_currentSystem = system; + + return FUNCTOR_CONTINUE; +} + +//---------------------------------------------------------------------------- +// SyncToFacsimileFunctor +//---------------------------------------------------------------------------- + +SyncToFacsimileFunctor::SyncToFacsimileFunctor(Doc *doc) : Functor() +{ + m_doc = doc; + m_view.SetDoc(doc); + m_surface = NULL; + m_currentPage = NULL; + m_currentSystem = NULL; + m_pageMarginTop = 0; + m_pageMarginLeft = 0; +} + +FunctorCode SyncToFacsimileFunctor::VisitLayerElement(LayerElement *layerElement) +{ + if (!layerElement->Is({ NOTE, REST })) return FUNCTOR_CONTINUE; + + Zone *zone = this->GetZone(layerElement, layerElement->GetClassName()); + zone->SetUlx(m_view.ToDeviceContextX(layerElement->GetDrawingX()) / DEFINITION_FACTOR + m_pageMarginLeft); + + return FUNCTOR_CONTINUE; +} + +FunctorCode SyncToFacsimileFunctor::VisitMeasure(Measure *measure) +{ + Zone *zone = this->GetZone(measure, measure->GetClassName()); + zone->SetUlx(m_view.ToDeviceContextX(measure->GetDrawingX()) / DEFINITION_FACTOR + m_pageMarginLeft); + zone->SetLrx( + m_view.ToDeviceContextX(measure->GetDrawingX() + measure->GetWidth()) / DEFINITION_FACTOR + m_pageMarginLeft); + + return FUNCTOR_CONTINUE; +} + +FunctorCode SyncToFacsimileFunctor::VisitPage(Page *page) +{ + m_currentPage = page; + m_doc->SetDrawingPage(page->GetIdx()); + page->LayOut(); + // + m_surface = new Surface(); + assert(m_doc->GetFacsimile()); + m_doc->GetFacsimile()->AddChild(m_surface); + m_surface->SetLrx(m_doc->m_drawingPageWidth / DEFINITION_FACTOR); + m_surface->SetLry(m_doc->m_drawingPageHeight / DEFINITION_FACTOR); + // Because the facsimile output zone positions include the margins, we will add them to each zone + m_pageMarginTop = m_doc->m_drawingPageMarginTop / DEFINITION_FACTOR; + m_pageMarginLeft = m_doc->m_drawingPageMarginLeft / DEFINITION_FACTOR; + + return FUNCTOR_CONTINUE; +} + +FunctorCode SyncToFacsimileFunctor::VisitPb(Pb *pb) +{ + Zone *zone = this->GetZone(pb, pb->GetClassName()); + // The Pb zone values are currently not used in SyncFromFacsimileFunctor because the + // page sizes are synced from the parent Surface and zone positions include margins + zone->SetUlx(m_pageMarginLeft); + zone->SetUly(m_pageMarginTop); + zone->SetLrx(m_doc->m_drawingPageContentWidth / DEFINITION_FACTOR + m_pageMarginLeft); + zone->SetLry(m_doc->m_drawingPageContentHeight / DEFINITION_FACTOR + m_pageMarginTop); + + return FUNCTOR_CONTINUE; +} + +FunctorCode SyncToFacsimileFunctor::VisitSb(Sb *sb) +{ + Zone *zone = this->GetZone(sb, sb->GetClassName()); + zone->SetUlx(m_view.ToDeviceContextX(m_currentSystem->GetDrawingX()) / DEFINITION_FACTOR + m_pageMarginLeft); + zone->SetUly(m_view.ToDeviceContextY(m_currentSystem->GetDrawingY()) / DEFINITION_FACTOR + m_pageMarginTop); + + return FUNCTOR_CONTINUE; +} + +FunctorCode SyncToFacsimileFunctor::VisitStaff(Staff *staff) +{ + Zone *zone = this->GetZone(staff, staff->GetClassName()); + zone->SetUly(m_view.ToDeviceContextY(staff->GetDrawingY()) / DEFINITION_FACTOR + m_pageMarginTop); + + return FUNCTOR_CONTINUE; +} + +FunctorCode SyncToFacsimileFunctor::VisitSystem(System *system) +{ + m_currentSystem = system; + + return FUNCTOR_CONTINUE; +} + +Zone *SyncToFacsimileFunctor::GetZone(FacsimileInterface *interface, std::string type) +{ + if (interface->GetZone()) { + // Here we should probably check if the zone is a child of m_surface + return interface->GetZone(); + } + else { + Zone *zone = new Zone(); + std::transform(type.begin(), type.end(), type.begin(), ::tolower); + zone->SetType(type); + m_surface->AddChild(zone); + interface->SetFacs(StringFormat("#%s", zone->GetID().c_str())); + interface->AttachZone(zone); + return interface->GetZone(); + } +} + +} // namespace vrv diff --git a/src/facsimileinterface.cpp b/src/facsimileinterface.cpp index 6ef3a50b88a..93dd965da22 100644 --- a/src/facsimileinterface.cpp +++ b/src/facsimileinterface.cpp @@ -15,6 +15,7 @@ #include "doc.h" #include "facsimile.h" +#include "preparedatafunctor.h" #include "surface.h" #include "syllable.h" #include "view.h" @@ -34,7 +35,9 @@ FacsimileInterface::~FacsimileInterface() {} void FacsimileInterface::Reset() { this->ResetFacsimile(); - this->AttachZone(NULL); + + m_zone = NULL; + m_surface = NULL; } int FacsimileInterface::GetDrawingX() const @@ -79,12 +82,7 @@ int FacsimileInterface::GetSurfaceY() const assert(m_zone); Surface *surface = vrv_cast(m_zone->GetFirstAncestor(SURFACE)); assert(surface); - if (surface->HasLry()) { - return surface->GetLry(); - } - else { - return surface->GetMaxY(); - } + return surface->GetMaxY(); } void FacsimileInterface::AttachZone(Zone *zone) @@ -104,4 +102,39 @@ void FacsimileInterface::AttachZone(Zone *zone) } } +//---------------------------------------------------------------------------- +// Interface pseudo functor (redirected) +//---------------------------------------------------------------------------- + +FunctorCode FacsimileInterface::InterfacePrepareFacsimile(PrepareFacsimileFunctor &functor, Object *object) +{ + assert(functor.GetFacsimile()); + Facsimile *facsimile = functor.GetFacsimile(); + std::string facsID = ExtractIDFragment(this->GetFacs()); + Object *facsDescendant = facsimile->FindDescendantByID(facsID); + if (!facsDescendant) { + LogWarning("Could not find @facs '%s' in facsimile element", facsID.c_str()); + return FUNCTOR_CONTINUE; + } + + if (facsDescendant->Is(ZONE)) { + m_zone = vrv_cast(facsDescendant); + assert(m_zone); + } + else if (facsDescendant->Is(SURFACE)) { + m_surface = vrv_cast(facsDescendant); + assert(m_surface); + } + + return FUNCTOR_CONTINUE; +} + +FunctorCode FacsimileInterface::InterfaceResetData(ResetDataFunctor &functor, Object *object) +{ + m_zone = NULL; + m_surface = NULL; + + return FUNCTOR_CONTINUE; +} + } // namespace vrv diff --git a/src/iomei.cpp b/src/iomei.cpp index 6ff5920f6c4..d9487f9020d 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -1640,8 +1640,8 @@ void MEIOutput::WriteSystem(pugi::xml_node currentNode, System *system) currentNode.append_attribute("system.rightmar") = StringFormat("%d", system->m_systemRightMar / DEFINITION_FACTOR).c_str(); // y positions - if (system->m_yAbs != VRV_UNSET) { - currentNode.append_attribute("uly") = StringFormat("%d", system->m_yAbs / DEFINITION_FACTOR).c_str(); + if (system->m_drawingFacsY != VRV_UNSET) { + currentNode.append_attribute("uly") = StringFormat("%d", system->m_drawingFacsY / DEFINITION_FACTOR).c_str(); } system->WriteTyped(currentNode); } @@ -1698,6 +1698,7 @@ void MEIOutput::WritePb(pugi::xml_node currentNode, Pb *pb) assert(pb); this->WriteSystemElement(currentNode, pb); + this->WriteFacsimileInterface(currentNode, pb); pb->WriteNNumberLike(currentNode); } @@ -1706,6 +1707,7 @@ void MEIOutput::WriteSb(pugi::xml_node currentNode, Sb *sb) assert(sb); this->WriteSystemElement(currentNode, sb); + this->WriteFacsimileInterface(currentNode, sb); sb->WriteNNumberLike(currentNode); } @@ -1883,6 +1885,8 @@ void MEIOutput::WriteMeasure(pugi::xml_node currentNode, Measure *measure) assert(measure); this->WriteXmlId(currentNode, measure); + this->WriteFacsimileInterface(currentNode, measure); + measure->WriteBarring(currentNode); measure->WriteMeasureLog(currentNode); measure->WriteMeterConformanceBar(currentNode); @@ -1890,9 +1894,9 @@ void MEIOutput::WriteMeasure(pugi::xml_node currentNode, Measure *measure) measure->WritePointing(currentNode); measure->WriteTyped(currentNode); // For now we copy the adjusted value of coord.x1 and coord.x2 to xAbs and xAbs2 respectively - if ((measure->m_xAbs != VRV_UNSET) && (measure->m_xAbs2 != VRV_UNSET)) { - measure->SetCoordX1(measure->m_xAbs / DEFINITION_FACTOR); - measure->SetCoordX2(measure->m_xAbs2 / DEFINITION_FACTOR); + if ((measure->m_drawingFacsX1 != VRV_UNSET) && (measure->m_drawingFacsX2 != VRV_UNSET)) { + measure->SetCoordX1(measure->m_drawingFacsX1 / DEFINITION_FACTOR); + measure->SetCoordX2(measure->m_drawingFacsX2 / DEFINITION_FACTOR); measure->WriteCoordX1(currentNode); measure->WriteCoordX2(currentNode); } @@ -2216,14 +2220,14 @@ void MEIOutput::WriteStaff(pugi::xml_node currentNode, Staff *staff) assert(staff); this->WriteXmlId(currentNode, staff); - staff->WriteFacsimile(currentNode); + this->WriteFacsimileInterface(currentNode, staff); staff->WriteNInteger(currentNode); staff->WriteTyped(currentNode); staff->WriteVisibility(currentNode); // y position - if (staff->m_yAbs != VRV_UNSET) { - staff->SetCoordY1(staff->m_yAbs / DEFINITION_FACTOR); + if (staff->m_drawingFacsY != VRV_UNSET) { + staff->SetCoordY1(staff->m_drawingFacsY / DEFINITION_FACTOR); staff->WriteCoordY1(currentNode); } } @@ -2298,11 +2302,12 @@ void MEIOutput::WriteLayerElement(pugi::xml_node currentNode, LayerElement *elem assert(element); this->WriteXmlId(currentNode, element); + this->WriteFacsimileInterface(currentNode, element); this->WriteLinkingInterface(currentNode, element); element->WriteLabelled(currentNode); element->WriteTyped(currentNode); - if (element->m_xAbs != VRV_UNSET) { - element->SetCoordX1(element->m_xAbs / DEFINITION_FACTOR); + if (element->m_drawingFacsX != VRV_UNSET) { + element->SetCoordX1(element->m_drawingFacsX / DEFINITION_FACTOR); element->WriteCoordX1(currentNode); } } @@ -2320,7 +2325,6 @@ void MEIOutput::WriteAccid(pugi::xml_node currentNode, Accid *accid) } WriteLayerElement(currentNode, accid); - WriteFacsimileInterface(currentNode, accid); WritePositionInterface(currentNode, accid); accid->WriteAccidental(currentNode); accid->WriteAccidentalGes(currentNode); @@ -2433,7 +2437,6 @@ void MEIOutput::WriteClef(pugi::xml_node currentNode, Clef *clef) } this->WriteLayerElement(currentNode, clef); - this->WriteFacsimileInterface(currentNode, clef); clef->WriteClefLog(currentNode); clef->WriteClefShape(currentNode); clef->WriteColor(currentNode); @@ -2451,7 +2454,6 @@ void MEIOutput::WriteCustos(pugi::xml_node currentNode, Custos *custos) { assert(custos); - this->WriteFacsimileInterface(currentNode, custos); this->WritePitchInterface(currentNode, custos); this->WritePositionInterface(currentNode, custos); this->WriteLayerElement(currentNode, custos); @@ -2465,7 +2467,6 @@ void MEIOutput::WriteDivLine(pugi::xml_node currentNode, DivLine *divLine) assert(divLine); this->WriteLayerElement(currentNode, divLine); - this->WriteFacsimileInterface(currentNode, divLine); divLine->WriteDivLineLog(currentNode); divLine->WriteColor(currentNode); divLine->WriteVisibility(currentNode); @@ -2698,7 +2699,6 @@ void MEIOutput::WriteNc(pugi::xml_node currentNode, Nc *nc) this->WriteLayerElement(currentNode, nc); this->WriteDurationInterface(currentNode, nc); - this->WriteFacsimileInterface(currentNode, nc); this->WritePitchInterface(currentNode, nc); this->WritePositionInterface(currentNode, nc); nc->WriteColor(currentNode); @@ -2711,7 +2711,6 @@ void MEIOutput::WriteNeume(pugi::xml_node currentNode, Neume *neume) assert(neume); this->WriteLayerElement(currentNode, neume); - this->WriteFacsimileInterface(currentNode, neume); neume->WriteColor(currentNode); } @@ -2830,7 +2829,6 @@ void MEIOutput::WriteSyl(pugi::xml_node currentNode, Syl *syl) assert(syl); this->WriteLayerElement(currentNode, syl); - this->WriteFacsimileInterface(currentNode, syl); syl->WriteLang(currentNode); syl->WriteTypography(currentNode); syl->WriteSylLog(currentNode); @@ -2878,6 +2876,7 @@ void MEIOutput::WriteSurface(pugi::xml_node currentNode, Surface *surface) assert(surface); this->WriteXmlId(currentNode, surface); surface->WriteCoordinated(currentNode); + surface->WriteCoordinatedUl(currentNode); surface->WriteTyped(currentNode); for (Object *child = surface->GetFirst(); child != NULL; child = surface->GetNext()) { @@ -3906,6 +3905,11 @@ bool MEIInput::ReadDoc(pugi::xml_node root) m_doc->m_drawingPageHeight = m_doc->GetFacsimile()->GetMaxY(); m_doc->m_drawingPageWidth = m_doc->GetFacsimile()->GetMaxX(); } + // Temporary solution to set the document type to Transcription when using + else if (m_doc->HasFacsimile() && !m_doc->GetFacsimile()->GetType().empty()) { + m_doc->SetType(StrToDocType(m_doc->GetFacsimile()->GetType())); + // Facsimile data eventually sync with Doc::SyncFromFacsimileDoc below + } if (facsimile.next_sibling("facsimile")) { LogWarning("Only first is processed"); } @@ -4529,6 +4533,7 @@ bool MEIInput::ReadPb(Object *parent, pugi::xml_node pb) Pb *vrvPb = new Pb(); this->ReadSystemElement(pb, vrvPb); + this->ReadFacsimileInterface(pb, vrvPb); vrvPb->ReadNNumberLike(pb); @@ -4545,6 +4550,7 @@ bool MEIInput::ReadSb(Object *parent, pugi::xml_node sb) Sb *vrvSb = new Sb(); this->ReadSystemElement(sb, vrvSb); + this->ReadFacsimileInterface(sb, vrvSb); vrvSb->ReadNNumberLike(sb); @@ -4572,7 +4578,7 @@ bool MEIInput::ReadSystem(Object *parent, pugi::xml_node system) system.remove_attribute("system.rightmar"); } if (system.attribute("uly") && m_doc->IsTranscription()) { - vrvSystem->m_yAbs = system.attribute("uly").as_int() * DEFINITION_FACTOR; + vrvSystem->m_drawingFacsY = system.attribute("uly").as_int() * DEFINITION_FACTOR; system.remove_attribute("uly"); } @@ -5348,6 +5354,7 @@ bool MEIInput::ReadMeasure(Object *parent, pugi::xml_node measure) m_doc->SetMensuralMusicOnly(false); } this->SetMeiID(measure, vrvMeasure); + this->ReadFacsimileInterface(measure, vrvMeasure); vrvMeasure->ReadBarring(measure); vrvMeasure->ReadMeasureLog(measure); @@ -5363,8 +5370,8 @@ bool MEIInput::ReadMeasure(Object *parent, pugi::xml_node measure) if (measure.attribute("coord.x1") && measure.attribute("coord.x2") && m_doc->IsTranscription()) { vrvMeasure->ReadCoordX1(measure); vrvMeasure->ReadCoordX2(measure); - vrvMeasure->m_xAbs = vrvMeasure->GetCoordX1() * DEFINITION_FACTOR; - vrvMeasure->m_xAbs2 = vrvMeasure->GetCoordX2() * DEFINITION_FACTOR; + vrvMeasure->m_drawingFacsX1 = vrvMeasure->GetCoordX1() * DEFINITION_FACTOR; + vrvMeasure->m_drawingFacsX2 = vrvMeasure->GetCoordX2() * DEFINITION_FACTOR; } parent->AddChild(vrvMeasure); @@ -6044,8 +6051,8 @@ bool MEIInput::ReadStaff(Object *parent, pugi::xml_node staff) { Staff *vrvStaff = new Staff(); this->SetMeiID(staff, vrvStaff); + this->ReadFacsimileInterface(staff, vrvStaff); - vrvStaff->ReadFacsimile(staff); vrvStaff->ReadNInteger(staff); vrvStaff->ReadTyped(staff); vrvStaff->ReadVisibility(staff); @@ -6056,7 +6063,7 @@ bool MEIInput::ReadStaff(Object *parent, pugi::xml_node staff) if (staff.attribute("coord.y1") && m_doc->IsTranscription()) { vrvStaff->ReadCoordY1(staff); - vrvStaff->m_yAbs = vrvStaff->GetCoordY1() * DEFINITION_FACTOR; + vrvStaff->m_drawingFacsY = vrvStaff->GetCoordY1() * DEFINITION_FACTOR; } if (!vrvStaff->HasN() || (vrvStaff->GetN() == 0)) { @@ -6285,6 +6292,7 @@ bool MEIInput::ReadLayerChildren(Object *parent, pugi::xml_node parentNode, Obje bool MEIInput::ReadLayerElement(pugi::xml_node element, LayerElement *object) { this->SetMeiID(element, object); + this->ReadFacsimileInterface(element, object); this->ReadLinkingInterface(element, object); object->ReadLabelled(element); object->ReadTyped(element); @@ -6295,7 +6303,7 @@ bool MEIInput::ReadLayerElement(pugi::xml_node element, LayerElement *object) if (element.attribute("coord.x1") && m_doc->IsTranscription()) { object->ReadCoordX1(element); - object->m_xAbs = object->GetCoordX1() * DEFINITION_FACTOR; + object->m_drawingFacsX = object->GetCoordX1() * DEFINITION_FACTOR; } return true; @@ -6307,7 +6315,6 @@ bool MEIInput::ReadAccid(Object *parent, pugi::xml_node accid) this->ReadLayerElement(accid, vrvAccid); ReadPositionInterface(accid, vrvAccid); - ReadFacsimileInterface(accid, vrvAccid); vrvAccid->ReadAccidental(accid); vrvAccid->ReadAccidentalGes(accid); vrvAccid->ReadAccidLog(accid); @@ -6452,7 +6459,6 @@ bool MEIInput::ReadClef(Object *parent, pugi::xml_node clef) { Clef *vrvClef = new Clef(); this->ReadLayerElement(clef, vrvClef); - this->ReadFacsimileInterface(clef, vrvClef); vrvClef->ReadClefLog(clef); vrvClef->ReadClefShape(clef); @@ -6510,7 +6516,6 @@ bool MEIInput::ReadDivLine(Object *parent, pugi::xml_node divLine) DivLine *vrvDivLine = new DivLine(); this->ReadLayerElement(divLine, vrvDivLine); - this->ReadFacsimileInterface(divLine, vrvDivLine); vrvDivLine->ReadDivLineLog(divLine); vrvDivLine->ReadColor(divLine); vrvDivLine->ReadVisibility(divLine); @@ -6793,7 +6798,6 @@ bool MEIInput::ReadNc(Object *parent, pugi::xml_node nc) this->ReadLayerElement(nc, vrvNc); this->ReadDurationInterface(nc, vrvNc); - this->ReadFacsimileInterface(nc, vrvNc); this->ReadPitchInterface(nc, vrvNc); this->ReadPositionInterface(nc, vrvNc); vrvNc->ReadColor(nc); @@ -6808,7 +6812,6 @@ bool MEIInput::ReadNeume(Object *parent, pugi::xml_node neume) { Neume *vrvNeume = new Neume(); this->ReadLayerElement(neume, vrvNeume); - this->ReadFacsimileInterface(neume, vrvNeume); vrvNeume->ReadColor(neume); @@ -8468,14 +8471,14 @@ void MEIInput::UpgradeMeasureTo_3_0_0(Measure *measure, System *system) assert(system); assert(!measure->IsMeasuredMusic()); - if (system->m_yAbs == VRV_UNSET) return; + if (system->m_drawingFacsY == VRV_UNSET) return; if (system->m_systemRightMar == VRV_UNSET) return; if (system->m_systemRightMar == VRV_UNSET) return; Page *page = vrv_cast(system->GetFirstAncestor(PAGE)); assert(page); - measure->m_xAbs = system->m_systemLeftMar; - measure->m_xAbs2 = page->m_pageWidth - system->m_systemRightMar; + measure->m_drawingFacsX1 = system->m_systemLeftMar; + measure->m_drawingFacsX2 = page->m_pageWidth - system->m_systemRightMar; } void MEIInput::UpgradePageTo_3_0_0(Page *page, Doc *doc) @@ -8509,6 +8512,7 @@ bool MEIInput::ReadSurface(Facsimile *parent, pugi::xml_node surface) Surface *vrvSurface = new Surface(); this->SetMeiID(surface, vrvSurface); vrvSurface->ReadCoordinated(surface); + vrvSurface->ReadCoordinatedUl(surface); vrvSurface->ReadTyped(surface); for (pugi::xml_node child = surface.first_child(); child; child = child.next_sibling()) { diff --git a/src/layerelement.cpp b/src/layerelement.cpp index 90d453f4569..459d4c505df 100644 --- a/src/layerelement.cpp +++ b/src/layerelement.cpp @@ -127,7 +127,7 @@ void LayerElement::Reset() this->ResetLabelled(); this->ResetTyped(); - m_xAbs = VRV_UNSET; + m_drawingFacsX = VRV_UNSET; m_drawingYRel = 0; m_drawingXRel = 0; m_drawingCueSize = false; @@ -405,8 +405,8 @@ int LayerElement::GetDrawingX() const } } - // Since m_xAbs is the left position, we adjust the XRel accordingly in AdjustXRelForTranscription - if (m_xAbs != VRV_UNSET) return m_xAbs + this->GetDrawingXRel(); + // Since m_drawingFacsX is the left position, we adjust the XRel accordingly in AdjustXRelForTranscription + if (m_drawingFacsX != VRV_UNSET) return m_drawingFacsX + this->GetDrawingXRel(); if (m_cachedDrawingX != VRV_UNSET) return m_cachedDrawingX; @@ -532,7 +532,7 @@ void LayerElement::CacheYRel(bool restore) void LayerElement::CenterDrawingX() { - if (m_xAbs != VRV_UNSET) return; + if (m_drawingFacsX != VRV_UNSET) return; this->SetDrawingXRel(0); diff --git a/src/measure.cpp b/src/measure.cpp index b6cff691a5a..4439fe36ce8 100644 --- a/src/measure.cpp +++ b/src/measure.cpp @@ -56,6 +56,7 @@ static const ClassRegistrar s_factory("measure", MEASURE); Measure::Measure(bool measureMusic, int logMeasureNb) : Object(MEASURE, "measure-") + , FacsimileInterface() , AttBarring() , AttCoordX1() , AttCoordX2() @@ -73,6 +74,7 @@ Measure::Measure(bool measureMusic, int logMeasureNb) this->RegisterAttClass(ATT_NNUMBERLIKE); this->RegisterAttClass(ATT_POINTING); this->RegisterAttClass(ATT_TYPED); + this->RegisterInterface(FacsimileInterface::GetAttClasses(), FacsimileInterface::IsInterface()); m_measuredMusic = measureMusic; @@ -121,6 +123,7 @@ void Measure::CloneReset() void Measure::Reset() { Object::Reset(); + FacsimileInterface::Reset(); this->ResetCoordX1(); this->ResetCoordX2(); this->ResetMeasureLog(); @@ -134,8 +137,8 @@ void Measure::Reset() this->ResetDrawingScoreDef(); m_timestampAligner.Reset(); - m_xAbs = VRV_UNSET; - m_xAbs2 = VRV_UNSET; + m_drawingFacsX1 = VRV_UNSET; + m_drawingFacsX2 = VRV_UNSET; m_drawingXRel = 0; m_cachedXRel = VRV_UNSET; @@ -147,8 +150,8 @@ void Measure::Reset() m_leftBarLine.SetForm(this->GetLeft()); if (!m_measuredMusic) { - m_xAbs = VRV_UNSET; - m_xAbs2 = VRV_UNSET; + m_drawingFacsX1 = VRV_UNSET; + m_drawingFacsX2 = VRV_UNSET; } m_drawingEnding = NULL; @@ -213,12 +216,12 @@ int Measure::GetDrawingX() const if (!this->IsMeasuredMusic()) { const System *system = vrv_cast(this->GetFirstAncestor(SYSTEM)); assert(system); - if (system->m_yAbs != VRV_UNSET) { + if (system->m_drawingFacsY != VRV_UNSET) { return (system->m_systemLeftMar); } } - if (m_xAbs != VRV_UNSET) return m_xAbs; + if (m_drawingFacsX1 != VRV_UNSET) return m_drawingFacsX1; if (m_cachedDrawingX != VRV_UNSET) return m_cachedDrawingX; @@ -353,7 +356,7 @@ int Measure::GetWidth() const if (!this->IsMeasuredMusic()) { const System *system = vrv_cast(this->GetFirstAncestor(SYSTEM)); assert(system); - if (system->m_yAbs != VRV_UNSET) { + if (system->m_drawingFacsY != VRV_UNSET) { const Page *page = vrv_cast(system->GetFirstAncestor(PAGE)); assert(page); // xAbs2 = page->m_pageWidth - system->m_systemRightMar; @@ -361,7 +364,7 @@ int Measure::GetWidth() const } } - if (m_xAbs2 != VRV_UNSET) return (m_xAbs2 - m_xAbs); + if (m_drawingFacsX2 != VRV_UNSET) return (m_drawingFacsX2 - m_drawingFacsX1); assert(m_measureAligner.GetRightAlignment()); return m_measureAligner.GetRightAlignment()->GetXRel(); diff --git a/src/miscfunctor.cpp b/src/miscfunctor.cpp index c592281c499..9c3677a2823 100644 --- a/src/miscfunctor.cpp +++ b/src/miscfunctor.cpp @@ -32,15 +32,15 @@ FunctorCode ApplyPPUFactorFunctor::VisitLayerElement(LayerElement *layerElement) { if (layerElement->IsScoreDefElement()) return FUNCTOR_SIBLINGS; - if (layerElement->m_xAbs != VRV_UNSET) layerElement->m_xAbs /= m_page->GetPPUFactor(); + if (layerElement->m_drawingFacsX != VRV_UNSET) layerElement->m_drawingFacsX /= m_page->GetPPUFactor(); return FUNCTOR_CONTINUE; } FunctorCode ApplyPPUFactorFunctor::VisitMeasure(Measure *measure) { - if (measure->m_xAbs != VRV_UNSET) measure->m_xAbs /= m_page->GetPPUFactor(); - if (measure->m_xAbs2 != VRV_UNSET) measure->m_xAbs2 /= m_page->GetPPUFactor(); + if (measure->m_drawingFacsX1 != VRV_UNSET) measure->m_drawingFacsX1 /= m_page->GetPPUFactor(); + if (measure->m_drawingFacsX2 != VRV_UNSET) measure->m_drawingFacsX2 /= m_page->GetPPUFactor(); return FUNCTOR_CONTINUE; } @@ -60,15 +60,15 @@ FunctorCode ApplyPPUFactorFunctor::VisitPage(Page *page) FunctorCode ApplyPPUFactorFunctor::VisitStaff(Staff *staff) { - if (staff->m_yAbs != VRV_UNSET) staff->m_yAbs /= m_page->GetPPUFactor(); + if (staff->m_drawingFacsY != VRV_UNSET) staff->m_drawingFacsY /= m_page->GetPPUFactor(); return FUNCTOR_CONTINUE; } FunctorCode ApplyPPUFactorFunctor::VisitSystem(System *system) { - if (system->m_xAbs != VRV_UNSET) system->m_xAbs /= m_page->GetPPUFactor(); - if (system->m_yAbs != VRV_UNSET) system->m_yAbs /= m_page->GetPPUFactor(); + if (system->m_drawingFacsX != VRV_UNSET) system->m_drawingFacsX /= m_page->GetPPUFactor(); + if (system->m_drawingFacsY != VRV_UNSET) system->m_drawingFacsY /= m_page->GetPPUFactor(); system->m_systemLeftMar *= m_page->GetPPUFactor(); system->m_systemRightMar *= m_page->GetPPUFactor(); diff --git a/src/options.cpp b/src/options.cpp index 08aa84dad59..294837d2679 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -954,7 +954,7 @@ Options::Options() m_baseOptions.AddOption(&m_scale); m_outputTo.SetInfo("Output to", - "Select output format to: \"mei\", \"mei-pb\", \"mei-basic\", \"svg\", \"midi\", \"timemap\", " + "Select output format to: \"mei\", \"mei-pb\", \"mei-facs\", \"mei-basic\", \"svg\", \"midi\", \"timemap\", " "\"expansionmap\", \"humdrum\" or " "\"pae\""); m_outputTo.Init("svg"); diff --git a/src/pb.cpp b/src/pb.cpp index 9b7386736a8..10f68009081 100644 --- a/src/pb.cpp +++ b/src/pb.cpp @@ -29,9 +29,10 @@ namespace vrv { static const ClassRegistrar s_factory("pb", PB); -Pb::Pb() : SystemElement(PB, "pb-"), AttNNumberLike() +Pb::Pb() : SystemElement(PB, "pb-"), FacsimileInterface(), AttNNumberLike() { this->RegisterAttClass(ATT_NNUMBERLIKE); + this->RegisterInterface(FacsimileInterface::GetAttClasses(), FacsimileInterface::IsInterface()); this->Reset(); } @@ -41,6 +42,7 @@ Pb::~Pb() {} void Pb::Reset() { SystemElement::Reset(); + FacsimileInterface::Reset(); this->ResetNNumberLike(); } diff --git a/src/preparedatafunctor.cpp b/src/preparedatafunctor.cpp index bf6a106a6e3..98b7b07152e 100644 --- a/src/preparedatafunctor.cpp +++ b/src/preparedatafunctor.cpp @@ -380,11 +380,7 @@ FunctorCode PrepareFacsimileFunctor::VisitObject(Object *object) FacsimileInterface *interface = object->GetFacsimileInterface(); assert(interface); if (interface->HasFacs()) { - std::string facsID = ExtractIDFragment(interface->GetFacs()); - Zone *zone = m_facsimile->FindZoneByID(facsID); - if (zone != NULL) { - interface->AttachZone(zone); - } + interface->InterfacePrepareFacsimile(*this, object); } // Zoneless syl else if (object->Is(SYL)) { diff --git a/src/resetfunctor.cpp b/src/resetfunctor.cpp index 8a09f26fe80..6c53b73e881 100644 --- a/src/resetfunctor.cpp +++ b/src/resetfunctor.cpp @@ -63,10 +63,7 @@ FunctorCode ResetDataFunctor::VisitArpeg(Arpeg *arpeg) { // Call parent one too this->VisitControlElement(arpeg); - - PlistInterface *interface = arpeg->GetPlistInterface(); - assert(interface); - interface->InterfaceResetData(*this, arpeg); + arpeg->PlistInterface::InterfaceResetData(*this, arpeg); return FUNCTOR_CONTINUE; } @@ -184,6 +181,9 @@ FunctorCode ResetDataFunctor::VisitDots(Dots *dots) FunctorCode ResetDataFunctor::VisitEditorialElement(EditorialElement *editorialElement) { + // Call parent one too + this->VisitObject(editorialElement); + if (editorialElement->IsSystemMilestone()) { editorialElement->SystemMilestoneInterface::InterfaceResetData(*this); } @@ -194,7 +194,6 @@ FunctorCode ResetDataFunctor::VisitEditorialElement(EditorialElement *editorialE FunctorCode ResetDataFunctor::VisitEnding(Ending *ending) { this->VisitFloatingObject(ending); - ending->SystemMilestoneInterface::InterfaceResetData(*this); return FUNCTOR_CONTINUE; @@ -203,10 +202,7 @@ FunctorCode ResetDataFunctor::VisitEnding(Ending *ending) FunctorCode ResetDataFunctor::VisitF(F *f) { this->VisitTextElement(f); - - TimeSpanningInterface *interface = f->GetTimeSpanningInterface(); - assert(interface); - interface->InterfaceResetData(*this, f); + f->TimeSpanningInterface::InterfaceResetData(*this, f); return FUNCTOR_CONTINUE; } @@ -222,10 +218,19 @@ FunctorCode ResetDataFunctor::VisitFlag(Flag *flag) FunctorCode ResetDataFunctor::VisitFloatingObject(FloatingObject *floatingObject) { + // Call parent one too + this->VisitObject(floatingObject); + floatingObject->ResetDrawing(); floatingObject->SetDrawingGrpId(0); // Pass it to the pseudo functor of the interface + if (floatingObject->HasInterface(INTERFACE_FACSIMILE)) { + FacsimileInterface *interface = floatingObject->GetFacsimileInterface(); + assert(interface); + interface->InterfaceResetData(*this, floatingObject); + } + // else / else if because TimpeSpanningInterface::InterfaceResetData resets TimePointingInterface if (floatingObject->HasInterface(INTERFACE_TIME_SPANNING)) { TimeSpanningInterface *interface = floatingObject->GetTimeSpanningInterface(); assert(interface); @@ -265,6 +270,9 @@ FunctorCode ResetDataFunctor::VisitHairpin(Hairpin *hairpin) FunctorCode ResetDataFunctor::VisitLayer(Layer *layer) { + // Call parent one too + this->VisitObject(layer); + layer->SetCrossStaffFromAbove(false); layer->SetCrossStaffFromBelow(false); return FUNCTOR_CONTINUE; @@ -272,6 +280,10 @@ FunctorCode ResetDataFunctor::VisitLayer(Layer *layer) FunctorCode ResetDataFunctor::VisitLayerElement(LayerElement *layerElement) { + // Call parent one too + this->VisitObject(layerElement); + layerElement->FacsimileInterface::InterfaceResetData(*this, layerElement); + layerElement->SetIsInBeamSpan(false); layerElement->SetDrawingCueSize(false); layerElement->m_crossStaff = NULL; @@ -299,6 +311,10 @@ FunctorCode ResetDataFunctor::VisitLigature(Ligature *ligature) FunctorCode ResetDataFunctor::VisitMeasure(Measure *measure) { + // Call parent one too + this->VisitObject(measure); + measure->FacsimileInterface::InterfaceResetData(*this, measure); + measure->m_timestampAligner.Reset(); measure->SetDrawingEnding(NULL); return FUNCTOR_CONTINUE; @@ -327,6 +343,11 @@ FunctorCode ResetDataFunctor::VisitNote(Note *note) return FUNCTOR_CONTINUE; } +FunctorCode ResetDataFunctor::VisitObject(Object *object) +{ + return FUNCTOR_CONTINUE; +} + FunctorCode ResetDataFunctor::VisitRepeatMark(RepeatMark *repeatMark) { // Call parent one too @@ -348,6 +369,7 @@ FunctorCode ResetDataFunctor::VisitRest(Rest *rest) FunctorCode ResetDataFunctor::VisitSection(Section *section) { + // Call parent one too this->VisitFloatingObject(section); if (section->IsSystemMilestone()) { @@ -369,6 +391,10 @@ FunctorCode ResetDataFunctor::VisitSlur(Slur *slur) FunctorCode ResetDataFunctor::VisitStaff(Staff *staff) { + // Call parent one too + this->VisitObject(staff); + staff->FacsimileInterface::InterfaceResetData(*this, staff); + staff->m_timeSpanningElements.clear(); staff->ClearLedgerLines(); return FUNCTOR_CONTINUE; diff --git a/src/sb.cpp b/src/sb.cpp index 33a33c0bdf6..883f46a7e1c 100644 --- a/src/sb.cpp +++ b/src/sb.cpp @@ -29,9 +29,10 @@ namespace vrv { static const ClassRegistrar s_factory("sb", SB); -Sb::Sb() : SystemElement(SB, "sb-"), AttNNumberLike() +Sb::Sb() : SystemElement(SB, "sb-"), FacsimileInterface(), AttNNumberLike() { this->RegisterAttClass(ATT_NNUMBERLIKE); + this->RegisterInterface(FacsimileInterface::GetAttClasses(), FacsimileInterface::IsInterface()); this->Reset(); } @@ -41,6 +42,7 @@ Sb::~Sb() {} void Sb::Reset() { SystemElement::Reset(); + FacsimileInterface::Reset(); this->ResetNNumberLike(); } diff --git a/src/staff.cpp b/src/staff.cpp index 9a01f64d063..28b69219213 100644 --- a/src/staff.cpp +++ b/src/staff.cpp @@ -66,7 +66,7 @@ void Staff::Reset() this->ResetTyped(); this->ResetVisibility(); - m_yAbs = VRV_UNSET; + m_drawingFacsY = VRV_UNSET; m_drawingStaffSize = 100; m_drawingLines = 5; @@ -142,7 +142,7 @@ int Staff::GetDrawingY() const } } - if (m_yAbs != VRV_UNSET) return m_yAbs; + if (m_drawingFacsY != VRV_UNSET) return m_drawingFacsY; if (!m_staffAlignment) return 0; diff --git a/src/system.cpp b/src/system.cpp index f7deae78600..2a070dba54f 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -74,9 +74,9 @@ void System::Reset() m_systemLeftMar = 0; m_systemRightMar = 0; - m_xAbs = VRV_UNSET; + m_drawingFacsX = VRV_UNSET; m_drawingXRel = 0; - m_yAbs = VRV_UNSET; + m_drawingFacsY = VRV_UNSET; m_drawingYRel = 0; m_drawingTotalWidth = 0; m_drawingJustifiableWidth = 0; @@ -111,7 +111,7 @@ bool System::IsSupportedChild(Object *child) int System::GetDrawingX() const { - if (m_xAbs != VRV_UNSET) return m_xAbs; + if (m_drawingFacsX != VRV_UNSET) return m_drawingFacsX; m_cachedDrawingX = 0; return m_drawingXRel; @@ -119,7 +119,7 @@ int System::GetDrawingX() const int System::GetDrawingY() const { - if (m_yAbs != VRV_UNSET) return m_yAbs; + if (m_drawingFacsY != VRV_UNSET) return m_drawingFacsY; m_cachedDrawingY = 0; return m_drawingYRel; diff --git a/src/toolkit.cpp b/src/toolkit.cpp index cb8fe6e8ada..4821605cf8b 100644 --- a/src/toolkit.cpp +++ b/src/toolkit.cpp @@ -152,6 +152,9 @@ bool Toolkit::SetOutputTo(std::string const &outputTo) else if (outputTo == "mei-pb") { m_outputTo = MEI; } + else if (outputTo == "mei-facs") { + m_outputTo = MEI; + } else if (outputTo == "midi") { m_outputTo = MIDI; } @@ -749,9 +752,14 @@ bool Toolkit::LoadData(const std::string &data) breaks = BREAKS_none; } - // Always set breaks to 'none' with Transcription or Facs rendering - rendering them differenty requires the MEI - // to be converted - if (m_doc.GetType() == Transcription || m_doc.GetType() == Facs) breaks = BREAKS_none; + // Always set breaks to 'none' with Facs rendering + if (m_doc.IsFacs()) breaks = BREAKS_none; + + // Always set breaks to 'none' or 'encoded' with Transcription rendering + // rendering them differenty requires the MEI + if (m_doc.IsTranscription()) { + breaks = (m_doc.HasFacsimile()) ? BREAKS_encoded : BREAKS_none; + } if (breaks != BREAKS_none) { if (input->GetLayoutInformation() == LAYOUT_ENCODED @@ -784,6 +792,10 @@ bool Toolkit::LoadData(const std::string &data) } } + if (m_doc.IsTranscription() && m_doc.HasFacsimile()) { + m_doc.SyncFromFacsimileDoc(); + } + delete input; m_view.SetDoc(&m_doc); @@ -816,6 +828,7 @@ std::string Toolkit::GetMEI(const std::string &jsonOptions) std::string firstMeasure; std::string lastMeasure; std::string mdiv; + bool generateFacs = false; jsonxx::Object json; @@ -838,6 +851,7 @@ std::string Toolkit::GetMEI(const std::string &jsonOptions) if (json.has("firstMeasure")) firstMeasure = json.get("firstMeasure"); if (json.has("lastMeasure")) lastMeasure = json.get("lastMeasure"); if (json.has("mdiv")) mdiv = json.get("mdiv"); + if (json.has("generateFacs")) generateFacs = json.get("generateFacs"); } } @@ -873,6 +887,16 @@ std::string Toolkit::GetMEI(const std::string &jsonOptions) if (!lastMeasure.empty()) meioutput.SetLastMeasure(lastMeasure); if (!mdiv.empty()) meioutput.SetMdiv(mdiv); + if (generateFacs) { + if (meioutput.HasFilter() || !scoreBased || (m_options->m_breaks.GetValue() != BREAKS_encoded) + || m_doc.HasSelection()) { + LogError("Generating facsimile is only possible with all pages, encoded breaks, score-based output and " + "without selection."); + return ""; + } + m_doc.SyncToFacsimileDoc(); + } + std::string output = meioutput.GetOutput(); if (hadSelection) m_doc.ReactivateSelection(false); @@ -1402,7 +1426,7 @@ void Toolkit::RedoLayout(const std::string &jsonOptions) this->ResetLogBuffer(); - if ((this->GetPageCount() == 0) || (m_doc.GetType() == Transcription) || (m_doc.GetType() == Facs)) { + if ((this->GetPageCount() == 0) || m_doc.IsTranscription() || m_doc.IsFacs()) { LogWarning("No data to re-layout"); return; } @@ -1465,7 +1489,7 @@ bool Toolkit::RenderToDeviceContext(int pageNo, DeviceContext *deviceContext) if (adjustWidth || (breaks == BREAKS_none)) width = m_doc.GetAdjustedDrawingPageWidth(); if (adjustHeight || (breaks == BREAKS_none)) height = m_doc.GetAdjustedDrawingPageHeight(); - if (m_doc.GetType() == Transcription) { + if (m_doc.IsTranscription()) { width = m_doc.GetAdjustedDrawingPageWidth(); height = m_doc.GetAdjustedDrawingPageHeight(); } @@ -1488,7 +1512,7 @@ bool Toolkit::RenderToDeviceContext(int pageNo, DeviceContext *deviceContext) deviceContext->SetWidth(width); deviceContext->SetHeight(height); - if (m_doc.GetType() == Facs) { + if (m_doc.IsFacs()) { deviceContext->SetWidth(m_doc.GetFacsimile()->GetMaxX()); deviceContext->SetHeight(m_doc.GetFacsimile()->GetMaxY()); } @@ -1524,7 +1548,7 @@ std::string Toolkit::RenderToSVG(int pageNo, bool xmlDeclaration) svg.SetMMOutput(true); } - if (m_doc.GetType() == Facs) { + if (m_doc.IsFacs()) { svg.SetFacsimile(true); } diff --git a/src/view.cpp b/src/view.cpp index f474d7c3b8a..666db7ba544 100644 --- a/src/view.cpp +++ b/src/view.cpp @@ -74,7 +74,7 @@ void View::SetPage(int pageIdx, bool doLayout) m_doc->ScoreDefSetCurrentDoc(); // if we once deal with multiple views, it would be better // to redo the layout only when necessary? - if (m_doc->GetType() == Transcription || m_doc->IsFacs()) { + if (m_doc->IsTranscription() || m_doc->IsFacs()) { m_currentPage->LayOutTranscription(); } else { diff --git a/src/view_element.cpp b/src/view_element.cpp index eab43c14a38..82ba0443207 100644 --- a/src/view_element.cpp +++ b/src/view_element.cpp @@ -653,7 +653,7 @@ void View::DrawClef(DeviceContext *dc, LayerElement *element, Layer *layer, Staf } int x, y; - if (m_doc->GetType() == Facs && clef->HasFacs()) { + if (m_doc->IsFacs() && clef->HasFacs()) { y = ToLogicalY(staff->GetDrawingY()); x = clef->GetDrawingX(); } diff --git a/tools/main.cpp b/tools/main.cpp index 6f5aba3d793..c3eca7deec5 100644 --- a/tools/main.cpp +++ b/tools/main.cpp @@ -278,12 +278,12 @@ int main(int argc, char **argv) exit(1); } - if ((outformat != "svg") && (outformat != "mei") && (outformat != "mei-basic") && (outformat != "mei-pb") - && (outformat != "midi") && (outformat != "timemap") && (outformat != "expansionmap") - && (outformat != "humdrum") && (outformat != "hum") && (outformat != "pae")) { + const std::vector outformats = { "mei", "mei-basic", "mei-pb", "mei-facs", "svg", "midi", "timemap", + "expansionmap", "humdrum", "hum", "pae" }; + if (std::find(outformats.begin(), outformats.end(), outformat) == outformats.end()) { std::cerr << "Output format (" << outformat - << ") can only be 'mei', 'mei-basic', 'mei-pb', 'svg', 'midi', 'timemap', 'expansionmap', 'humdrum' " - "or 'pae'." + << ") can only be 'mei', 'mei-basic', 'mei-pb', mei-facs', 'svg', 'midi', 'timemap', 'expansionmap', " + "'humdrum', 'hum', or 'pae'." << std::endl; exit(1); } @@ -553,10 +553,12 @@ int main(int argc, char **argv) const char *scoreBased = (outformat == "mei-pb") ? "false" : "true"; const char *basic = (outformat == "mei-basic") ? "true" : "false"; const char *removeIds = (options->m_removeIds.GetValue()) ? "true" : "false"; + const char *generateFacs = (outformat == "mei-facs") ? "true" : "false"; outfile += ".mei"; if (all_pages) { std::string params - = vrv::StringFormat("{'scoreBased': %s, 'basic': %s, 'removeIds': %s}", scoreBased, basic, removeIds); + = vrv::StringFormat("{'scoreBased': %s, 'basic': %s, 'removeIds': %s, 'generateFacs': %s}", scoreBased, + basic, removeIds, generateFacs); if (std_output) { std::string output; std::cout << toolkit.GetMEI(params); @@ -570,7 +572,8 @@ int main(int argc, char **argv) } else { std::string params = vrv::StringFormat( - "{'scoreBased': %s, 'basic': %s, 'pageNo': %d, 'removeIds': %s}", scoreBased, basic, page, removeIds); + "{'scoreBased': %s, 'basic': %s, 'pageNo': %d, 'removeIds': %s, 'generateFacs': %s}", scoreBased, basic, + page, removeIds, generateFacs); if (std_output) { std::cout << toolkit.GetMEI(params); }