From 28b980855fb3e381f78477b207e2ce2439d6b8f5 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sat, 23 Dec 2023 09:38:25 +0100 Subject: [PATCH 01/30] Use Doc type helpers in Toolkit and in DrawClef --- src/toolkit.cpp | 10 +++++----- src/view_element.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/toolkit.cpp b/src/toolkit.cpp index cb8fe6e8ada..bcfd058ebe3 100644 --- a/src/toolkit.cpp +++ b/src/toolkit.cpp @@ -751,7 +751,7 @@ bool Toolkit::LoadData(const std::string &data) // 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; + if (m_doc.IsTranscription() || m_doc.IsFacs()) breaks = BREAKS_none; if (breaks != BREAKS_none) { if (input->GetLayoutInformation() == LAYOUT_ENCODED @@ -1402,7 +1402,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 +1465,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 +1488,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 +1524,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_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(); } From b071364e2c374b24c99da8cf12f4db1a3bef3f39 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sat, 23 Dec 2023 10:02:30 +0100 Subject: [PATCH 02/30] Remove unnecessary check in FacsimileInterface::GetSurfaceY * Same check is performed in Surface::GetMaxY --- src/facsimileinterface.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/facsimileinterface.cpp b/src/facsimileinterface.cpp index 6ef3a50b88a..420b18be836 100644 --- a/src/facsimileinterface.cpp +++ b/src/facsimileinterface.cpp @@ -79,12 +79,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) From d8600ed22957539dc191f82060141a95af8162e2 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sat, 23 Dec 2023 10:37:59 +0100 Subject: [PATCH 03/30] Read and write `staff@facs` through Read/WriteFacsimileInterface * Also remove call to Read/WriteFacsimileInterface in LayerElement child classes --- src/iomei.cpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/iomei.cpp b/src/iomei.cpp index 07ed3f6ce56..ba53ace1cb0 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -2216,7 +2216,7 @@ 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); @@ -2298,6 +2298,7 @@ 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); @@ -2320,7 +2321,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 +2433,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 +2450,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 +2463,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 +2695,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 +2707,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 +2825,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); @@ -6036,8 +6030,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); @@ -6277,6 +6271,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); @@ -6299,7 +6294,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); @@ -6444,7 +6438,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); @@ -6502,7 +6495,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); @@ -6785,7 +6777,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); @@ -6800,7 +6791,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); From 24bc829ff1e29163177c4a24eecab8586b50e4f5 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sat, 23 Dec 2023 10:40:02 +0100 Subject: [PATCH 04/30] Add FacsimileInterface to Measure --- include/vrv/measure.h | 2 ++ src/iomei.cpp | 3 +++ src/measure.cpp | 3 +++ 3 files changed, 8 insertions(+) diff --git a/include/vrv/measure.h b/include/vrv/measure.h index e9fe0cef9ca..f431913b8a3 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, diff --git a/src/iomei.cpp b/src/iomei.cpp index ba53ace1cb0..e612b02b1c9 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -1883,6 +1883,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); @@ -5334,6 +5336,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); diff --git a/src/measure.cpp b/src/measure.cpp index b6cff691a5a..3e5cf77f2db 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(); From da9470f6e878719ceff966262d6411da54acfaa5 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sat, 23 Dec 2023 11:12:28 +0100 Subject: [PATCH 05/30] Add FacsimileInterface getters to Measure --- Verovio.xcodeproj/project.pbxproj | 16 ++++++++ include/vrv/facsimilefunctor.h | 62 +++++++++++++++++++++++++++++++ include/vrv/measure.h | 11 ++++++ src/facsimilefunctor.cp | 45 ++++++++++++++++++++++ 4 files changed, 134 insertions(+) create mode 100644 include/vrv/facsimilefunctor.h create mode 100644 src/facsimilefunctor.cp diff --git a/Verovio.xcodeproj/project.pbxproj b/Verovio.xcodeproj/project.pbxproj index b129cb6e9af..ff5bdc6da47 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.cp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEBE6E32B36E79600B67DFB /* facsimilefunctor.cp */; }; + 4DEBE6E52B36E79600B67DFB /* facsimilefunctor.cp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEBE6E32B36E79600B67DFB /* facsimilefunctor.cp */; }; + 4DEBE6E62B36E9B300B67DFB /* facsimilefunctor.cp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEBE6E32B36E79600B67DFB /* facsimilefunctor.cp */; }; + 4DEBE6E72B36E9B400B67DFB /* facsimilefunctor.cp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEBE6E32B36E79600B67DFB /* facsimilefunctor.cp */; }; 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.cp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = facsimilefunctor.cp; path = src/facsimilefunctor.cp; 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.cp */, + 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.cp 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.cp 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.cp 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.cp in Sources */, BB4C4B9F22A932E5001F6AF0 /* positioninterface.cpp in Sources */, BB4C4B5322A932D7001F6AF0 /* halfmrpt.cpp in Sources */, BB4C4B8722A932DF001F6AF0 /* num.cpp in Sources */, diff --git a/include/vrv/facsimilefunctor.h b/include/vrv/facsimilefunctor.h new file mode 100644 index 00000000000..f31c3b887cc --- /dev/null +++ b/include/vrv/facsimilefunctor.h @@ -0,0 +1,62 @@ +///////////////////////////////////////////////////////////////////////////// +// 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" + +namespace vrv { + +class LayerElement; +class Measure; +class Staff; + +//---------------------------------------------------------------------------- +// SyncFromFacsimileFunctor +//---------------------------------------------------------------------------- + +/** + * This class sync the layout encoded in the facsimile to m_Abs members + */ +class SyncFromFacsimileFunctor : public Functor { +public: + /** + * @name Constructors, destructors + */ + ///@{ + SyncFromFacsimileFunctor(); + 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 VisitStaff(Staff *staff) override; + ///@} + +protected: + // +private: + // +public: + // +private: + // +}; + +} // namespace vrv + +#endif // __VRV_FACSIMILEFUNCTOR_H__ diff --git a/include/vrv/measure.h b/include/vrv/measure.h index f431913b8a3..e76832df519 100644 --- a/include/vrv/measure.h +++ b/include/vrv/measure.h @@ -65,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) */ diff --git a/src/facsimilefunctor.cp b/src/facsimilefunctor.cp new file mode 100644 index 00000000000..4b3aaa946bd --- /dev/null +++ b/src/facsimilefunctor.cp @@ -0,0 +1,45 @@ +///////////////////////////////////////////////////////////////////////////// +// 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 "staff.h" +#include "vrv.h" + +//---------------------------------------------------------------------------- + +namespace vrv { + +//---------------------------------------------------------------------------- +// SyncFromFacsimileFunctor +//---------------------------------------------------------------------------- + +SyncFromFacsimileFunctor::SyncFromFacsimileFunctor() : Functor() +{ +} + +FunctorCode SyncFromFacsimileFunctor::VisitLayerElement(LayerElement *layerElement) +{ + return FUNCTOR_CONTINUE; +} + +FunctorCode SyncFromFacsimileFunctor::VisitMeasure(Measure *measure) +{ + return FUNCTOR_CONTINUE; +} + +FunctorCode SyncFromFacsimileFunctor::VisitStaff(Staff *staff) +{ + return FUNCTOR_CONTINUE; +} + +} // namespace vrv From dabd14bd4976f95140beeb5b76894c235080abab Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sat, 23 Dec 2023 16:06:08 +0000 Subject: [PATCH 06/30] Add Doc::SyncFromFacsimileDoc and implement functor --- include/vrv/doc.h | 7 ++++++- src/doc.cpp | 10 ++++++++++ src/facsimilefunctor.cp | 17 +++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/include/vrv/doc.h b/include/vrv/doc.h index 3952633bb49..f4113c32aff 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,12 @@ class Doc : public Object { */ void ConvertMarkupDoc(bool permanent = true); + /** + * Sync the coordinate provided trought to m_Abs. + * Call the SyncToFacsimile functor. + */ + void SyncFromFacsimileDoc(); + /** * Transpose the content of the doc. */ diff --git a/src/doc.cpp b/src/doc.cpp index 8d1710d09e3..b48afdd4b5d 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" @@ -1391,6 +1392,15 @@ void Doc::ConvertMarkupDoc(bool permanent) } } +void Doc::SyncFromFacsimileDoc() +{ + PrepareFacsimileFunctor prepareFacsimile(this->GetFacsimile()); + this->Process(prepareFacsimile); + + SyncFromFacsimileFunctor syncFacsimileFunctor; + this->Process(syncFacsimileFunctor); +} + void Doc::TransposeDoc() { Transposer transposer; diff --git a/src/facsimilefunctor.cp b/src/facsimilefunctor.cp index 4b3aaa946bd..2b932db87d6 100644 --- a/src/facsimilefunctor.cp +++ b/src/facsimilefunctor.cp @@ -12,8 +12,10 @@ #include "doc.h" #include "layerelement.h" #include "measure.h" + #include "staff.h" #include "vrv.h" +#include "zone.h" //---------------------------------------------------------------------------- @@ -29,16 +31,31 @@ SyncFromFacsimileFunctor::SyncFromFacsimileFunctor() : Functor() FunctorCode SyncFromFacsimileFunctor::VisitLayerElement(LayerElement *layerElement) { + if (!layerElement->Is({NOTE, REST})) return FUNCTOR_CONTINUE; + + Zone *zone = layerElement->GetZone(); + assert(zone); + layerElement->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; + return FUNCTOR_CONTINUE; } FunctorCode SyncFromFacsimileFunctor::VisitMeasure(Measure *measure) { + Zone *zone = measure->GetZone(); + assert(zone); + measure->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; + measure->m_xAbs2 = zone->GetLrx() * DEFINITION_FACTOR; + return FUNCTOR_CONTINUE; } FunctorCode SyncFromFacsimileFunctor::VisitStaff(Staff *staff) { + Zone *zone = staff->GetZone(); + assert(zone); + staff->m_yAbs = zone->GetUly() * DEFINITION_FACTOR; + return FUNCTOR_CONTINUE; } From 70b1646e0c36636d21aafc5d36087e5f0659db85 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sat, 23 Dec 2023 16:07:15 +0000 Subject: [PATCH 07/30] Fix missing Read/Write zone coordinated ul --- src/iomei.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/iomei.cpp b/src/iomei.cpp index e612b02b1c9..db220383508 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -2896,6 +2896,7 @@ void MEIOutput::WriteZone(pugi::xml_node currentNode, Zone *zone) assert(zone); this->WriteXmlId(currentNode, zone); zone->WriteCoordinated(currentNode); + zone->WriteCoordinatedUl(currentNode); zone->WriteTyped(currentNode); } @@ -8517,6 +8518,7 @@ bool MEIInput::ReadZone(Surface *parent, pugi::xml_node zone) Zone *vrvZone = new Zone(); this->SetMeiID(zone, vrvZone); vrvZone->ReadCoordinated(zone); + vrvZone->ReadCoordinatedUl(zone); vrvZone->ReadTyped(zone); parent->AddChild(vrvZone); return true; From cdc8cab0cbc716219d3c9cc05186e10b02d46ef6 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sat, 23 Dec 2023 16:07:45 +0000 Subject: [PATCH 08/30] Fix overlooked Doc type helper --- src/view.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 { From f3ac85b0ef11de84e14c7e3f2aa52e03b258bdfd Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sat, 23 Dec 2023 16:08:33 +0000 Subject: [PATCH 09/30] Initial implementation of call to SyncFromFacsimileDoc --- src/iomei.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/iomei.cpp b/src/iomei.cpp index db220383508..68a5839469d 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -3902,6 +3902,12 @@ 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())); + m_doc->m_drawingPageHeight = m_doc->GetFacsimile()->GetMaxY(); + m_doc->m_drawingPageWidth = m_doc->GetFacsimile()->GetMaxX(); + } if (facsimile.next_sibling("facsimile")) { LogWarning("Only first is processed"); } @@ -3991,6 +3997,10 @@ bool MEIInput::ReadDoc(pugi::xml_node root) m_doc->ConvertMarkupDoc(!m_doc->GetOptions()->m_preserveAnalyticalMarkup.GetValue()); } + if (success && m_doc->IsTranscription()) { + m_doc->SyncFromFacsimileDoc(); + } + if (success && !m_hasScoreDef) { LogWarning("No scoreDef provided, trying to generate one..."); success = m_doc->GenerateDocumentScoreDef(); From 6742a01751dbdf5644703006781f5e2a0fdff9bd Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sat, 23 Dec 2023 18:03:05 +0000 Subject: [PATCH 10/30] Add FacsimileInterface to Pb and Sb --- include/vrv/pb.h | 13 ++++++++++++- include/vrv/sb.h | 13 ++++++++++++- src/iomei.cpp | 4 ++++ src/pb.cpp | 4 +++- src/sb.cpp | 4 +++- 5 files changed, 34 insertions(+), 4 deletions(-) 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/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/src/iomei.cpp b/src/iomei.cpp index 68a5839469d..c3779dc75fd 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -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); } @@ -4528,6 +4530,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); @@ -4544,6 +4547,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); 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/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(); } From 808aa9d78f2225efff3bc8d58a0c7fdf0db6a083 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sat, 23 Dec 2023 18:21:44 +0000 Subject: [PATCH 11/30] Sync Pb facsimile in SyncFromFacsimile functor * Placeholder for sb but not tested nor enabled --- include/vrv/facsimilefunctor.h | 10 +++++++ src/facsimilefunctor.cp | 51 +++++++++++++++++++++++++++++++++- src/iomei.cpp | 3 +- 3 files changed, 61 insertions(+), 3 deletions(-) diff --git a/include/vrv/facsimilefunctor.h b/include/vrv/facsimilefunctor.h index f31c3b887cc..3df74f90dcd 100644 --- a/include/vrv/facsimilefunctor.h +++ b/include/vrv/facsimilefunctor.h @@ -14,7 +14,11 @@ namespace vrv { class LayerElement; class Measure; +class Page; +class Pb; +class Sb; class Staff; +class System; //---------------------------------------------------------------------------- // SyncFromFacsimileFunctor @@ -44,7 +48,11 @@ class SyncFromFacsimileFunctor : public Functor { ///@{ 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: @@ -55,6 +63,8 @@ class SyncFromFacsimileFunctor : public Functor { // private: // + Page *m_currentPage; + System *m_currentSystem; }; } // namespace vrv diff --git a/src/facsimilefunctor.cp b/src/facsimilefunctor.cp index 2b932db87d6..bfb5495fd44 100644 --- a/src/facsimilefunctor.cp +++ b/src/facsimilefunctor.cp @@ -12,8 +12,11 @@ #include "doc.h" #include "layerelement.h" #include "measure.h" - +#include "page.h" +#include "pb.h" +#include "sb.h" #include "staff.h" +#include "system.h" #include "vrv.h" #include "zone.h" @@ -27,6 +30,8 @@ namespace vrv { SyncFromFacsimileFunctor::SyncFromFacsimileFunctor() : Functor() { + m_currentPage = NULL; + m_currentSystem = NULL; } FunctorCode SyncFromFacsimileFunctor::VisitLayerElement(LayerElement *layerElement) @@ -50,6 +55,42 @@ FunctorCode SyncFromFacsimileFunctor::VisitMeasure(Measure *measure) return FUNCTOR_CONTINUE; } +FunctorCode SyncFromFacsimileFunctor::VisitPage(Page *page) +{ + m_currentPage = page; + + 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); + m_currentPage->m_pageHeight = zone->GetLry() * DEFINITION_FACTOR; + m_currentPage->m_pageWidth = zone->GetLrx() * DEFINITION_FACTOR; + + 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_xAbs = zone->GetUlx() * DEFINITION_FACTOR; + m_currentSystem->m_yAbs = zone->GetUly() * DEFINITION_FACTOR; + */ + + return FUNCTOR_CONTINUE; +} + FunctorCode SyncFromFacsimileFunctor::VisitStaff(Staff *staff) { Zone *zone = staff->GetZone(); @@ -59,4 +100,12 @@ FunctorCode SyncFromFacsimileFunctor::VisitStaff(Staff *staff) return FUNCTOR_CONTINUE; } +FunctorCode SyncFromFacsimileFunctor::VisitSystem(System *system) +{ + m_currentSystem = system; + + return FUNCTOR_CONTINUE; +} + + } // namespace vrv diff --git a/src/iomei.cpp b/src/iomei.cpp index c3779dc75fd..9dd0095f1dd 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -3907,8 +3907,7 @@ bool MEIInput::ReadDoc(pugi::xml_node root) // 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())); - m_doc->m_drawingPageHeight = m_doc->GetFacsimile()->GetMaxY(); - m_doc->m_drawingPageWidth = m_doc->GetFacsimile()->GetMaxX(); + // Facsimile data eventually sync with Doc::SyncFromFacsimileDoc below } if (facsimile.next_sibling("facsimile")) { LogWarning("Only first is processed"); From a1a7a933b7f42fb0d9a1ee94f7d12accd1619501 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sat, 23 Dec 2023 18:41:50 +0000 Subject: [PATCH 12/30] Scaffold SyncFromFacsimileFunctor --- Verovio.xcodeproj/project.pbxproj | 20 +++--- include/vrv/facsimilefunctor.h | 47 +++++++++++++ ...csimilefunctor.cp => facsimilefunctor.cpp} | 66 +++++++++++++++++++ 3 files changed, 123 insertions(+), 10 deletions(-) rename src/{facsimilefunctor.cp => facsimilefunctor.cpp} (63%) diff --git a/Verovio.xcodeproj/project.pbxproj b/Verovio.xcodeproj/project.pbxproj index ff5bdc6da47..6a55d542017 100644 --- a/Verovio.xcodeproj/project.pbxproj +++ b/Verovio.xcodeproj/project.pbxproj @@ -802,10 +802,10 @@ 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.cp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEBE6E32B36E79600B67DFB /* facsimilefunctor.cp */; }; - 4DEBE6E52B36E79600B67DFB /* facsimilefunctor.cp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEBE6E32B36E79600B67DFB /* facsimilefunctor.cp */; }; - 4DEBE6E62B36E9B300B67DFB /* facsimilefunctor.cp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEBE6E32B36E79600B67DFB /* facsimilefunctor.cp */; }; - 4DEBE6E72B36E9B400B67DFB /* facsimilefunctor.cp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEBE6E32B36E79600B67DFB /* facsimilefunctor.cp */; }; + 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 */; }; @@ -2021,7 +2021,7 @@ 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.cp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = facsimilefunctor.cp; path = src/facsimilefunctor.cp; 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 = ""; }; @@ -3020,7 +3020,7 @@ E7265E6D29DC6FD200D11F41 /* castofffunctor.h */, E763EF4129E939FB0029E56D /* convertfunctor.cpp */, E763EF3E29E939C00029E56D /* convertfunctor.h */, - 4DEBE6E32B36E79600B67DFB /* facsimilefunctor.cp */, + 4DEBE6E32B36E79600B67DFB /* facsimilefunctor.cpp */, 4DEBE6E02B36E78900B67DFB /* facsimilefunctor.h */, E74A806028BC9111005274E7 /* findfunctor.cpp */, E74A806528BC97D5005274E7 /* findfunctor.h */, @@ -3938,7 +3938,7 @@ E7F39C6229A62B430055DBE0 /* adjustclefchangesfunctor.cpp in Sources */, E79320682991454000D80975 /* calcstemfunctor.cpp in Sources */, 4DED4F18294733140073E504 /* altsyminterface.cpp in Sources */, - 4DEBE6E72B36E9B400B67DFB /* facsimilefunctor.cp in Sources */, + 4DEBE6E72B36E9B400B67DFB /* facsimilefunctor.cpp in Sources */, 4DEF8A6521B7AAF90093A76B /* f.cpp in Sources */, 4D2073F922A3BCE000E0765F /* tabdursym.cpp in Sources */, 4D16940B1E3A44F300569BF4 /* keysig.cpp in Sources */, @@ -4219,7 +4219,7 @@ 8F086EF1188539540037FD8E /* keysig.cpp in Sources */, E74A806C28BC98B2005274E7 /* functorinterface.cpp in Sources */, E7870357299CF06D00156DC4 /* adjustarpegfunctor.cpp in Sources */, - 4DEBE6E62B36E9B300B67DFB /* facsimilefunctor.cp in Sources */, + 4DEBE6E62B36E9B300B67DFB /* facsimilefunctor.cpp in Sources */, 4DEC4D9E21C81E9400D1D273 /* orig.cpp in Sources */, 4DDBBB5D1C7AE45900054AFF /* hairpin.cpp in Sources */, 4D43C30C1A9BB22A00EA28F3 /* view_mensural.cpp in Sources */, @@ -4503,7 +4503,7 @@ 4DB3D8D51F83D12B00B5FC2B /* tempo.cpp in Sources */, 4DEC4DA021C81E9400D1D273 /* orig.cpp in Sources */, E7F39C6329A62B440055DBE0 /* adjustclefchangesfunctor.cpp in Sources */, - 4DEBE6E42B36E79600B67DFB /* facsimilefunctor.cp in Sources */, + 4DEBE6E42B36E79600B67DFB /* facsimilefunctor.cpp in Sources */, E79320692991454000D80975 /* calcstemfunctor.cpp in Sources */, 8F3DD33E18854B2E0051330C /* beam.cpp in Sources */, 4DED4F19294733140073E504 /* altsyminterface.cpp in Sources */, @@ -4786,7 +4786,7 @@ E793206A2991454100D80975 /* calcstemfunctor.cpp in Sources */, BB4C4AD722A932B6001F6AF0 /* staff.cpp in Sources */, 4DED4F1A294733140073E504 /* altsyminterface.cpp in Sources */, - 4DEBE6E52B36E79600B67DFB /* facsimilefunctor.cp 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/facsimilefunctor.h b/include/vrv/facsimilefunctor.h index 3df74f90dcd..5073049d496 100644 --- a/include/vrv/facsimilefunctor.h +++ b/include/vrv/facsimilefunctor.h @@ -67,6 +67,53 @@ class SyncFromFacsimileFunctor : public Functor { System *m_currentSystem; }; +//---------------------------------------------------------------------------- +// SyncToFacsimileFunctor +//---------------------------------------------------------------------------- + +/** + * This class sync the layout calculated to the facsimile + */ +class SyncToFacsimileFunctor : public Functor { +public: + /** + * @name Constructors, destructors + */ + ///@{ + SyncToFacsimileFunctor(); + 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: + // +public: + // +private: + // + Page *m_currentPage; + System *m_currentSystem; +}; + } // namespace vrv #endif // __VRV_FACSIMILEFUNCTOR_H__ diff --git a/src/facsimilefunctor.cp b/src/facsimilefunctor.cpp similarity index 63% rename from src/facsimilefunctor.cp rename to src/facsimilefunctor.cpp index bfb5495fd44..7923024c713 100644 --- a/src/facsimilefunctor.cp +++ b/src/facsimilefunctor.cpp @@ -107,5 +107,71 @@ FunctorCode SyncFromFacsimileFunctor::VisitSystem(System *system) return FUNCTOR_CONTINUE; } +//---------------------------------------------------------------------------- +// SyncToFacsimileFunctor +//---------------------------------------------------------------------------- + +SyncToFacsimileFunctor::SyncToFacsimileFunctor() : Functor() +{ + m_currentPage = NULL; + m_currentSystem = NULL; +} + +FunctorCode SyncToFacsimileFunctor::VisitLayerElement(LayerElement *layerElement) +{ + if (!layerElement->Is({NOTE, REST})) return FUNCTOR_CONTINUE; + + //layerElement->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; + + return FUNCTOR_CONTINUE; +} + +FunctorCode SyncToFacsimileFunctor::VisitMeasure(Measure *measure) +{ + //measure->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; + //measure->m_xAbs2 = zone->GetLrx() * DEFINITION_FACTOR; + + return FUNCTOR_CONTINUE; +} + +FunctorCode SyncToFacsimileFunctor::VisitPage(Page *page) +{ + m_currentPage = page; + + return FUNCTOR_CONTINUE; +} + + +FunctorCode SyncToFacsimileFunctor::VisitPb(Pb *pb) +{ + //m_currentPage->m_pageHeight = zone->GetLry() * DEFINITION_FACTOR; + //m_currentPage->m_pageWidth = zone->GetLrx() * DEFINITION_FACTOR; + + return FUNCTOR_CONTINUE; +} + +FunctorCode SyncToFacsimileFunctor::VisitSb(Sb *sb) +{ + //m_currentSystem->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; + //m_currentSystem->m_yAbs = zone->GetUly() * DEFINITION_FACTOR; + + return FUNCTOR_CONTINUE; +} + +FunctorCode SyncToFacsimileFunctor::VisitStaff(Staff *staff) +{ + //staff->m_yAbs = zone->GetUly() * DEFINITION_FACTOR; + + return FUNCTOR_CONTINUE; +} + +FunctorCode SyncToFacsimileFunctor::VisitSystem(System *system) +{ + m_currentSystem = system; + + return FUNCTOR_CONTINUE; +} + + } // namespace vrv From 44e83659b6e9c6a46d5f4ce55f1be0346321278e Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sat, 23 Dec 2023 18:44:15 +0000 Subject: [PATCH 13/30] Fix format --- src/facsimilefunctor.cpp | 52 +++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/src/facsimilefunctor.cpp b/src/facsimilefunctor.cpp index 7923024c713..68e54dbbe7a 100644 --- a/src/facsimilefunctor.cpp +++ b/src/facsimilefunctor.cpp @@ -36,12 +36,12 @@ SyncFromFacsimileFunctor::SyncFromFacsimileFunctor() : Functor() FunctorCode SyncFromFacsimileFunctor::VisitLayerElement(LayerElement *layerElement) { - if (!layerElement->Is({NOTE, REST})) return FUNCTOR_CONTINUE; - + if (!layerElement->Is({ NOTE, REST })) return FUNCTOR_CONTINUE; + Zone *zone = layerElement->GetZone(); assert(zone); layerElement->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; - + return FUNCTOR_CONTINUE; } @@ -51,18 +51,17 @@ FunctorCode SyncFromFacsimileFunctor::VisitMeasure(Measure *measure) assert(zone); measure->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; measure->m_xAbs2 = zone->GetLrx() * DEFINITION_FACTOR; - + return FUNCTOR_CONTINUE; } FunctorCode SyncFromFacsimileFunctor::VisitPage(Page *page) { m_currentPage = page; - + return FUNCTOR_CONTINUE; } - FunctorCode SyncFromFacsimileFunctor::VisitPb(Pb *pb) { // This would happen if we run the functor on data not converted to page-based @@ -87,7 +86,7 @@ FunctorCode SyncFromFacsimileFunctor::VisitSb(Sb *sb) m_currentSystem->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; m_currentSystem->m_yAbs = zone->GetUly() * DEFINITION_FACTOR; */ - + return FUNCTOR_CONTINUE; } @@ -96,14 +95,14 @@ FunctorCode SyncFromFacsimileFunctor::VisitStaff(Staff *staff) Zone *zone = staff->GetZone(); assert(zone); staff->m_yAbs = zone->GetUly() * DEFINITION_FACTOR; - + return FUNCTOR_CONTINUE; } FunctorCode SyncFromFacsimileFunctor::VisitSystem(System *system) { m_currentSystem = system; - + return FUNCTOR_CONTINUE; } @@ -119,59 +118,56 @@ SyncToFacsimileFunctor::SyncToFacsimileFunctor() : Functor() FunctorCode SyncToFacsimileFunctor::VisitLayerElement(LayerElement *layerElement) { - if (!layerElement->Is({NOTE, REST})) return FUNCTOR_CONTINUE; - - //layerElement->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; - + if (!layerElement->Is({ NOTE, REST })) return FUNCTOR_CONTINUE; + + // layerElement->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; + return FUNCTOR_CONTINUE; } FunctorCode SyncToFacsimileFunctor::VisitMeasure(Measure *measure) { - //measure->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; - //measure->m_xAbs2 = zone->GetLrx() * DEFINITION_FACTOR; - + // measure->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; + // measure->m_xAbs2 = zone->GetLrx() * DEFINITION_FACTOR; + return FUNCTOR_CONTINUE; } FunctorCode SyncToFacsimileFunctor::VisitPage(Page *page) { m_currentPage = page; - + return FUNCTOR_CONTINUE; } - FunctorCode SyncToFacsimileFunctor::VisitPb(Pb *pb) { - //m_currentPage->m_pageHeight = zone->GetLry() * DEFINITION_FACTOR; - //m_currentPage->m_pageWidth = zone->GetLrx() * DEFINITION_FACTOR; + // m_currentPage->m_pageHeight = zone->GetLry() * DEFINITION_FACTOR; + // m_currentPage->m_pageWidth = zone->GetLrx() * DEFINITION_FACTOR; return FUNCTOR_CONTINUE; } FunctorCode SyncToFacsimileFunctor::VisitSb(Sb *sb) { - //m_currentSystem->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; - //m_currentSystem->m_yAbs = zone->GetUly() * DEFINITION_FACTOR; - + // m_currentSystem->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; + // m_currentSystem->m_yAbs = zone->GetUly() * DEFINITION_FACTOR; + return FUNCTOR_CONTINUE; } FunctorCode SyncToFacsimileFunctor::VisitStaff(Staff *staff) { - //staff->m_yAbs = zone->GetUly() * DEFINITION_FACTOR; - + // staff->m_yAbs = zone->GetUly() * DEFINITION_FACTOR; + return FUNCTOR_CONTINUE; } FunctorCode SyncToFacsimileFunctor::VisitSystem(System *system) { m_currentSystem = system; - + return FUNCTOR_CONTINUE; } - - } // namespace vrv From 85c6b517af3b44a1089c53b0d955d6184bd6e584 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Wed, 27 Dec 2023 09:39:21 +0000 Subject: [PATCH 14/30] Implement SyncToFacsimile --- include/vrv/doc.h | 6 ++++++ include/vrv/facsimilefunctor.h | 13 ++++++++++-- src/doc.cpp | 25 ++++++++++++++++++++-- src/facsimilefunctor.cpp | 39 ++++++++++++++++++++++++++++++++-- 4 files changed, 77 insertions(+), 6 deletions(-) diff --git a/include/vrv/doc.h b/include/vrv/doc.h index f4113c32aff..c6573a53d09 100644 --- a/include/vrv/doc.h +++ b/include/vrv/doc.h @@ -375,6 +375,12 @@ class Doc : public Object { */ 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. */ diff --git a/include/vrv/facsimilefunctor.h b/include/vrv/facsimilefunctor.h index 5073049d496..626b7c71a38 100644 --- a/include/vrv/facsimilefunctor.h +++ b/include/vrv/facsimilefunctor.h @@ -18,6 +18,7 @@ class Page; class Pb; class Sb; class Staff; +class Surface; class System; //---------------------------------------------------------------------------- @@ -80,7 +81,7 @@ class SyncToFacsimileFunctor : public Functor { * @name Constructors, destructors */ ///@{ - SyncToFacsimileFunctor(); + SyncToFacsimileFunctor(Doc *doc, Surface *surface, int height, int width); virtual ~SyncToFacsimileFunctor() = default; ///@} @@ -105,10 +106,18 @@ class SyncToFacsimileFunctor : public Functor { protected: // private: - // + /** Create zone if not exist */ + Zone *GetZone(FacsimileInterface *interface); public: // private: + /** The doc */ + Doc *m_doc; + /** Page height and width */ + int m_height; + int m_width; + /** The surface we are going to add / update zone */ + Surface *m_surface; // Page *m_currentPage; System *m_currentSystem; diff --git a/src/doc.cpp b/src/doc.cpp index b48afdd4b5d..b909bb5f4d0 100644 --- a/src/doc.cpp +++ b/src/doc.cpp @@ -59,6 +59,7 @@ #include "staff.h" #include "staffdef.h" #include "staffgrp.h" +#include "surface.h" #include "syl.h" #include "syllable.h" #include "system.h" @@ -1397,8 +1398,28 @@ void Doc::SyncFromFacsimileDoc() PrepareFacsimileFunctor prepareFacsimile(this->GetFacsimile()); this->Process(prepareFacsimile); - SyncFromFacsimileFunctor syncFacsimileFunctor; - this->Process(syncFacsimileFunctor); + SyncFromFacsimileFunctor syncFromFacsimileFunctor; + 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"); + Surface *surface = vrv_cast(m_facsimile->FindDescendantByType(SURFACE)); + assert(surface); + + const int width = m_options->m_pageWidth.GetUnfactoredValue(); + const int height = m_options->m_pageHeight.GetUnfactoredValue(); + SyncToFacsimileFunctor syncToFacimileFunctor(this, surface, height, width); + this->Process(syncToFacimileFunctor); } void Doc::TransposeDoc() diff --git a/src/facsimilefunctor.cpp b/src/facsimilefunctor.cpp index 68e54dbbe7a..57756c828f3 100644 --- a/src/facsimilefunctor.cpp +++ b/src/facsimilefunctor.cpp @@ -16,6 +16,7 @@ #include "pb.h" #include "sb.h" #include "staff.h" +#include "surface.h" #include "system.h" #include "vrv.h" #include "zone.h" @@ -110,8 +111,12 @@ FunctorCode SyncFromFacsimileFunctor::VisitSystem(System *system) // SyncToFacsimileFunctor //---------------------------------------------------------------------------- -SyncToFacsimileFunctor::SyncToFacsimileFunctor() : Functor() +SyncToFacsimileFunctor::SyncToFacsimileFunctor(Doc *doc, Surface *surface, int height, int width) : Functor() { + m_doc = doc; + m_height = height; + m_width = width; + m_surface = surface; m_currentPage = NULL; m_currentSystem = NULL; } @@ -121,6 +126,8 @@ FunctorCode SyncToFacsimileFunctor::VisitLayerElement(LayerElement *layerElement if (!layerElement->Is({ NOTE, REST })) return FUNCTOR_CONTINUE; // layerElement->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; + Zone *zone = this->GetZone(layerElement); + zone->SetUlx(layerElement->GetDrawingX() / DEFINITION_FACTOR); return FUNCTOR_CONTINUE; } @@ -129,6 +136,9 @@ FunctorCode SyncToFacsimileFunctor::VisitMeasure(Measure *measure) { // measure->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; // measure->m_xAbs2 = zone->GetLrx() * DEFINITION_FACTOR; + Zone *zone = this->GetZone(measure); + zone->SetUlx(measure->GetDrawingX() / DEFINITION_FACTOR); + zone->SetLrx(measure->GetDrawingX() + measure->GetWidth() / DEFINITION_FACTOR); return FUNCTOR_CONTINUE; } @@ -136,6 +146,8 @@ FunctorCode SyncToFacsimileFunctor::VisitMeasure(Measure *measure) FunctorCode SyncToFacsimileFunctor::VisitPage(Page *page) { m_currentPage = page; + m_doc->SetDrawingPage(page->GetIdx()); + page->LayOut(); return FUNCTOR_CONTINUE; } @@ -144,7 +156,10 @@ FunctorCode SyncToFacsimileFunctor::VisitPb(Pb *pb) { // m_currentPage->m_pageHeight = zone->GetLry() * DEFINITION_FACTOR; // m_currentPage->m_pageWidth = zone->GetLrx() * DEFINITION_FACTOR; - + Zone *zone = this->GetZone(pb); + zone->SetLry(m_height); + zone->SetLrx(m_width); + return FUNCTOR_CONTINUE; } @@ -152,6 +167,9 @@ FunctorCode SyncToFacsimileFunctor::VisitSb(Sb *sb) { // m_currentSystem->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; // m_currentSystem->m_yAbs = zone->GetUly() * DEFINITION_FACTOR; + Zone *zone = this->GetZone(sb); + zone->SetUlx(m_currentSystem->GetDrawingX() / DEFINITION_FACTOR); + zone->SetUly(m_currentSystem->GetDrawingY() / DEFINITION_FACTOR); return FUNCTOR_CONTINUE; } @@ -159,6 +177,8 @@ FunctorCode SyncToFacsimileFunctor::VisitSb(Sb *sb) FunctorCode SyncToFacsimileFunctor::VisitStaff(Staff *staff) { // staff->m_yAbs = zone->GetUly() * DEFINITION_FACTOR; + Zone *zone = this->GetZone(staff); + zone->SetUly(staff->GetDrawingY() / DEFINITION_FACTOR); return FUNCTOR_CONTINUE; } @@ -170,4 +190,19 @@ FunctorCode SyncToFacsimileFunctor::VisitSystem(System *system) return FUNCTOR_CONTINUE; } +Zone *SyncToFacsimileFunctor::GetZone(FacsimileInterface *interface) +{ + 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(); + m_surface->AddChild(zone); + interface->SetFacs(StringFormat("#%s", zone->GetID().c_str())); + interface->AttachZone(zone); + return interface->GetZone(); + } +} + } // namespace vrv From aa34af471e5f5e92fb7d99ce594d637558ac3e06 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Wed, 27 Dec 2023 09:39:32 +0000 Subject: [PATCH 15/30] Read sb@facs --- src/facsimilefunctor.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/facsimilefunctor.cpp b/src/facsimilefunctor.cpp index 57756c828f3..4dd47302093 100644 --- a/src/facsimilefunctor.cpp +++ b/src/facsimilefunctor.cpp @@ -82,11 +82,9 @@ FunctorCode SyncFromFacsimileFunctor::VisitSb(Sb *sb) assert(m_currentSystem); Zone *zone = sb->GetZone(); - /* assert(zone); m_currentSystem->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; m_currentSystem->m_yAbs = zone->GetUly() * DEFINITION_FACTOR; - */ return FUNCTOR_CONTINUE; } From 220f0fbdc56a46bae22b4200dba55d9d0ec89790 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Wed, 27 Dec 2023 09:40:03 +0000 Subject: [PATCH 16/30] Call SyncToFacsimileDoc (testing) * To be reverted --- src/toolkit.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/toolkit.cpp b/src/toolkit.cpp index bcfd058ebe3..f178da04c5b 100644 --- a/src/toolkit.cpp +++ b/src/toolkit.cpp @@ -857,6 +857,8 @@ std::string Toolkit::GetMEI(const std::string &jsonOptions) hadSelection = true; m_doc.DeactiveateSelection(); } + + m_doc.SyncToFacsimileDoc(); MEIOutput meioutput(&m_doc); meioutput.SetScoreBasedMEI(scoreBased); From 065805f6286d6f228c0bd34a0be3298e85ea00b8 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Wed, 27 Dec 2023 21:15:04 +0000 Subject: [PATCH 17/30] Remove FunctorParams old mentions * Clang formatting --- include/vrv/doc.h | 2 +- include/vrv/durationinterface.h | 1 - include/vrv/object.h | 1 - include/vrv/vrvdef.h | 2 +- src/toolkit.cpp | 2 +- 5 files changed, 3 insertions(+), 5 deletions(-) diff --git a/include/vrv/doc.h b/include/vrv/doc.h index c6573a53d09..788483f2554 100644 --- a/include/vrv/doc.h +++ b/include/vrv/doc.h @@ -380,7 +380,7 @@ class Doc : public Object { * The document must have encoded layout and the option --break encoded must have enabled. */ void SyncToFacsimileDoc(); - + /** * Transpose the content of the doc. */ 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/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/vrvdef.h b/include/vrv/vrvdef.h index 86ead543896..8178d672501 100644 --- a/include/vrv/vrvdef.h +++ b/include/vrv/vrvdef.h @@ -61,7 +61,7 @@ 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 +// To be used for params casts within Functors #define vrv_params_cast dynamic_cast #else #define vrv_cast static_cast diff --git a/src/toolkit.cpp b/src/toolkit.cpp index f178da04c5b..c946c020aca 100644 --- a/src/toolkit.cpp +++ b/src/toolkit.cpp @@ -857,7 +857,7 @@ std::string Toolkit::GetMEI(const std::string &jsonOptions) hadSelection = true; m_doc.DeactiveateSelection(); } - + m_doc.SyncToFacsimileDoc(); MEIOutput meioutput(&m_doc); From 4cc1e8309111afc5f18d8fa7c3abce0da5b48554 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Wed, 27 Dec 2023 21:19:54 +0000 Subject: [PATCH 18/30] Allow surface within surface * Not MEI valid structure --- include/vrv/iomei.h | 2 +- src/iomei.cpp | 9 ++++++++- src/surface.cpp | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/vrv/iomei.h b/include/vrv/iomei.h index 6b0d7800119..6f0b358c3db 100644 --- a/include/vrv/iomei.h +++ b/include/vrv/iomei.h @@ -846,7 +846,7 @@ class MEIInput : public Input { ///@{ bool ReadFacsimile(Doc *doc, pugi::xml_node facsimile); bool ReadGraphic(Object *parent, pugi::xml_node graphic); - bool ReadSurface(Facsimile *parent, pugi::xml_node surface); + bool ReadSurface(Object *parent, pugi::xml_node surface); bool ReadTupletSpanAsTuplet(Measure *measure, pugi::xml_node tupletSpan); bool ReadZone(Surface *parent, pugi::xml_node zone); ///@} diff --git a/src/iomei.cpp b/src/iomei.cpp index 9dd0095f1dd..f7ac28f32c7 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -2883,6 +2883,10 @@ void MEIOutput::WriteSurface(pugi::xml_node currentNode, Surface *surface) pugi::xml_node childNode = currentNode.append_child("graphic"); this->WriteGraphic(childNode, dynamic_cast(child)); } + else if (child->GetClassId() == SURFACE) { + pugi::xml_node childNode = currentNode.append_child("surface"); + this->WriteSurface(childNode, dynamic_cast(child)); + } else if (child->GetClassId() == ZONE) { pugi::xml_node childNode = currentNode.append_child("zone"); this->WriteZone(childNode, dynamic_cast(child)); @@ -8502,7 +8506,7 @@ bool MEIInput::ReadGraphic(Object *parent, pugi::xml_node graphic) return true; } -bool MEIInput::ReadSurface(Facsimile *parent, pugi::xml_node surface) +bool MEIInput::ReadSurface(Object *parent, pugi::xml_node surface) { assert(parent); Surface *vrvSurface = new Surface(); @@ -8514,6 +8518,9 @@ bool MEIInput::ReadSurface(Facsimile *parent, pugi::xml_node surface) if (strcmp(child.name(), "graphic") == 0) { this->ReadGraphic(vrvSurface, child); } + else if (strcmp(child.name(), "surface") == 0) { + this->ReadSurface(vrvSurface, child); + } else if (strcmp(child.name(), "zone") == 0) { this->ReadZone(vrvSurface, child); } diff --git a/src/surface.cpp b/src/surface.cpp index 3c0b01d1b43..799f8477e26 100644 --- a/src/surface.cpp +++ b/src/surface.cpp @@ -49,6 +49,9 @@ bool Surface::IsSupportedChild(Object *object) if (object->Is(GRAPHIC)) { assert(dynamic_cast(object)); } + else if (object->Is(SURFACE)) { + assert(dynamic_cast(object)); + } else if (object->Is(ZONE)) { assert(dynamic_cast(object)); } From af4fe04ece718cb99b3880f46b308d9213ccfc8e Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Wed, 27 Dec 2023 21:20:51 +0000 Subject: [PATCH 19/30] Read and write att.coordinated.ul in Surface (missing) --- src/iomei.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/iomei.cpp b/src/iomei.cpp index f7ac28f32c7..dbe70a5232d 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -2876,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()) { @@ -8512,6 +8513,7 @@ bool MEIInput::ReadSurface(Object *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()) { From 8a4a76a09ffd015af94b4ab2e29e2cfb3a4d3dee Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Wed, 27 Dec 2023 21:21:50 +0000 Subject: [PATCH 20/30] Output facsimile with nested surface (invalid MEI) --- include/vrv/facsimilefunctor.h | 11 ++++---- include/vrv/facsimileinterface.h | 3 +-- src/doc.cpp | 9 +++---- src/facsimilefunctor.cpp | 45 ++++++++++++++++++++------------ 4 files changed, 38 insertions(+), 30 deletions(-) diff --git a/include/vrv/facsimilefunctor.h b/include/vrv/facsimilefunctor.h index 626b7c71a38..4f3ae259fe5 100644 --- a/include/vrv/facsimilefunctor.h +++ b/include/vrv/facsimilefunctor.h @@ -9,6 +9,7 @@ #define __VRV_FACSIMILEFUNCTOR_H__ #include "functor.h" +#include "view.h" namespace vrv { @@ -81,7 +82,7 @@ class SyncToFacsimileFunctor : public Functor { * @name Constructors, destructors */ ///@{ - SyncToFacsimileFunctor(Doc *doc, Surface *surface, int height, int width); + SyncToFacsimileFunctor(Doc *doc); virtual ~SyncToFacsimileFunctor() = default; ///@} @@ -107,20 +108,20 @@ class SyncToFacsimileFunctor : public Functor { // private: /** Create zone if not exist */ - Zone *GetZone(FacsimileInterface *interface); + Zone *GetZone(FacsimileInterface *interface, std::string type); + public: // private: /** The doc */ Doc *m_doc; - /** Page height and width */ - int m_height; - int m_width; /** The surface we are going to add / update zone */ Surface *m_surface; // Page *m_currentPage; System *m_currentSystem; + // + View m_view; }; } // namespace vrv diff --git a/include/vrv/facsimileinterface.h b/include/vrv/facsimileinterface.h index cbc46f7ddb3..6faa2ab80b9 100644 --- a/include/vrv/facsimileinterface.h +++ b/include/vrv/facsimileinterface.h @@ -13,8 +13,7 @@ #include "interface.h" namespace vrv { -class FunctorParams; -class View; + class Zone; //---------------------------------------------------------------------------- diff --git a/src/doc.cpp b/src/doc.cpp index b909bb5f4d0..1b5d917a0d5 100644 --- a/src/doc.cpp +++ b/src/doc.cpp @@ -1413,12 +1413,9 @@ void Doc::SyncToFacsimileDoc() m_facsimile->AddChild(new Surface()); } m_facsimile->SetType("transcription"); - Surface *surface = vrv_cast(m_facsimile->FindDescendantByType(SURFACE)); - assert(surface); - - const int width = m_options->m_pageWidth.GetUnfactoredValue(); - const int height = m_options->m_pageHeight.GetUnfactoredValue(); - SyncToFacsimileFunctor syncToFacimileFunctor(this, surface, height, width); + m_facsimile->ClearChildren(); + + SyncToFacsimileFunctor syncToFacimileFunctor(this); this->Process(syncToFacimileFunctor); } diff --git a/src/facsimilefunctor.cpp b/src/facsimilefunctor.cpp index 4dd47302093..62a3e61b795 100644 --- a/src/facsimilefunctor.cpp +++ b/src/facsimilefunctor.cpp @@ -109,12 +109,11 @@ FunctorCode SyncFromFacsimileFunctor::VisitSystem(System *system) // SyncToFacsimileFunctor //---------------------------------------------------------------------------- -SyncToFacsimileFunctor::SyncToFacsimileFunctor(Doc *doc, Surface *surface, int height, int width) : Functor() +SyncToFacsimileFunctor::SyncToFacsimileFunctor(Doc *doc) : Functor() { m_doc = doc; - m_height = height; - m_width = width; - m_surface = surface; + m_view.SetDoc(doc); + m_surface = NULL; m_currentPage = NULL; m_currentSystem = NULL; } @@ -124,8 +123,8 @@ FunctorCode SyncToFacsimileFunctor::VisitLayerElement(LayerElement *layerElement if (!layerElement->Is({ NOTE, REST })) return FUNCTOR_CONTINUE; // layerElement->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; - Zone *zone = this->GetZone(layerElement); - zone->SetUlx(layerElement->GetDrawingX() / DEFINITION_FACTOR); + Zone *zone = this->GetZone(layerElement, layerElement->GetClassName()); + zone->SetUlx(m_view.ToLogicalX(layerElement->GetDrawingX()) / DEFINITION_FACTOR); return FUNCTOR_CONTINUE; } @@ -134,7 +133,7 @@ FunctorCode SyncToFacsimileFunctor::VisitMeasure(Measure *measure) { // measure->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; // measure->m_xAbs2 = zone->GetLrx() * DEFINITION_FACTOR; - Zone *zone = this->GetZone(measure); + Zone *zone = this->GetZone(measure, measure->GetClassName()); zone->SetUlx(measure->GetDrawingX() / DEFINITION_FACTOR); zone->SetLrx(measure->GetDrawingX() + measure->GetWidth() / DEFINITION_FACTOR); @@ -146,6 +145,18 @@ FunctorCode SyncToFacsimileFunctor::VisitPage(Page *page) m_currentPage = page; m_doc->SetDrawingPage(page->GetIdx()); page->LayOut(); + // + Surface *surface = new Surface(); + assert(m_doc->GetFacsimile()); + m_doc->GetFacsimile()->AddChild(surface); + surface->SetLrx(m_doc->m_drawingPageWidth / DEFINITION_FACTOR); + surface->SetLry(m_doc->m_drawingPageHeight / DEFINITION_FACTOR); + m_surface = new Surface(); + surface->AddChild(m_surface); + m_surface->SetUlx(m_doc->m_drawingPageMarginLeft / DEFINITION_FACTOR); + m_surface->SetUly(m_doc->m_drawingPageMarginRight / DEFINITION_FACTOR); + m_surface->SetLrx(m_doc->m_drawingPageContentWidth / DEFINITION_FACTOR); + m_surface->SetLry(m_doc->m_drawingPageContentHeight / DEFINITION_FACTOR); return FUNCTOR_CONTINUE; } @@ -154,10 +165,8 @@ FunctorCode SyncToFacsimileFunctor::VisitPb(Pb *pb) { // m_currentPage->m_pageHeight = zone->GetLry() * DEFINITION_FACTOR; // m_currentPage->m_pageWidth = zone->GetLrx() * DEFINITION_FACTOR; - Zone *zone = this->GetZone(pb); - zone->SetLry(m_height); - zone->SetLrx(m_width); - + // Zone *zone = this->GetZone(pb, pb->GetClassName()); + return FUNCTOR_CONTINUE; } @@ -165,9 +174,9 @@ FunctorCode SyncToFacsimileFunctor::VisitSb(Sb *sb) { // m_currentSystem->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; // m_currentSystem->m_yAbs = zone->GetUly() * DEFINITION_FACTOR; - Zone *zone = this->GetZone(sb); - zone->SetUlx(m_currentSystem->GetDrawingX() / DEFINITION_FACTOR); - zone->SetUly(m_currentSystem->GetDrawingY() / DEFINITION_FACTOR); + Zone *zone = this->GetZone(sb, sb->GetClassName()); + zone->SetUlx(m_view.ToLogicalX(m_currentSystem->GetDrawingX()) / DEFINITION_FACTOR); + zone->SetUly(m_view.ToLogicalY(m_currentSystem->GetDrawingY()) / DEFINITION_FACTOR); return FUNCTOR_CONTINUE; } @@ -175,8 +184,8 @@ FunctorCode SyncToFacsimileFunctor::VisitSb(Sb *sb) FunctorCode SyncToFacsimileFunctor::VisitStaff(Staff *staff) { // staff->m_yAbs = zone->GetUly() * DEFINITION_FACTOR; - Zone *zone = this->GetZone(staff); - zone->SetUly(staff->GetDrawingY() / DEFINITION_FACTOR); + Zone *zone = this->GetZone(staff, staff->GetClassName()); + zone->SetUly(m_view.ToLogicalY(staff->GetDrawingY()) / DEFINITION_FACTOR); return FUNCTOR_CONTINUE; } @@ -188,7 +197,7 @@ FunctorCode SyncToFacsimileFunctor::VisitSystem(System *system) return FUNCTOR_CONTINUE; } -Zone *SyncToFacsimileFunctor::GetZone(FacsimileInterface *interface) +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 @@ -196,6 +205,8 @@ Zone *SyncToFacsimileFunctor::GetZone(FacsimileInterface *interface) } 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); From 82845f9bfb57a333a22217525b5a3734380639c3 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Thu, 28 Dec 2023 10:08:51 +0000 Subject: [PATCH 21/30] Add pseudo functors to FacsimileInterface --- include/vrv/facsimileinterface.h | 21 ++++++++++++++++- include/vrv/preparedatafunctor.h | 5 ++++ src/facsimileinterface.cpp | 40 +++++++++++++++++++++++++++++++- 3 files changed, 64 insertions(+), 2 deletions(-) diff --git a/include/vrv/facsimileinterface.h b/include/vrv/facsimileinterface.h index 6faa2ab80b9..7afafef144b 100644 --- a/include/vrv/facsimileinterface.h +++ b/include/vrv/facsimileinterface.h @@ -14,6 +14,10 @@ namespace vrv { +class Facsimile; +class PrepareFacsimileFunctor; +class ResetDataFunctor; +class Surface; class Zone; //---------------------------------------------------------------------------- @@ -55,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/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/src/facsimileinterface.cpp b/src/facsimileinterface.cpp index 420b18be836..d6caee2e131 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 @@ -99,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 From 0eb3ce4806c1de5cd2cc391a7aa271c36f0ff931 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Thu, 28 Dec 2023 10:09:42 +0000 Subject: [PATCH 22/30] Make sure ResetData parent is always called * Also add call to FascimileInterface::ResetDataInterface --- include/vrv/resetfunctor.h | 1 + src/preparedatafunctor.cpp | 6 +----- src/resetfunctor.cpp | 44 ++++++++++++++++++++++++++++++-------- 3 files changed, 37 insertions(+), 14 deletions(-) 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/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; From 238e3bbdbd62483396ca3635ebb7b1089fd0179e Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Thu, 28 Dec 2023 10:13:23 +0000 Subject: [PATCH 23/30] Revert "Allow surface within surface" This reverts commit 4cc1e8309111afc5f18d8fa7c3abce0da5b48554. --- include/vrv/iomei.h | 2 +- src/iomei.cpp | 9 +-------- src/surface.cpp | 3 --- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/include/vrv/iomei.h b/include/vrv/iomei.h index 6f0b358c3db..6b0d7800119 100644 --- a/include/vrv/iomei.h +++ b/include/vrv/iomei.h @@ -846,7 +846,7 @@ class MEIInput : public Input { ///@{ bool ReadFacsimile(Doc *doc, pugi::xml_node facsimile); bool ReadGraphic(Object *parent, pugi::xml_node graphic); - bool ReadSurface(Object *parent, pugi::xml_node surface); + bool ReadSurface(Facsimile *parent, pugi::xml_node surface); bool ReadTupletSpanAsTuplet(Measure *measure, pugi::xml_node tupletSpan); bool ReadZone(Surface *parent, pugi::xml_node zone); ///@} diff --git a/src/iomei.cpp b/src/iomei.cpp index dbe70a5232d..039e39b29e8 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -2884,10 +2884,6 @@ void MEIOutput::WriteSurface(pugi::xml_node currentNode, Surface *surface) pugi::xml_node childNode = currentNode.append_child("graphic"); this->WriteGraphic(childNode, dynamic_cast(child)); } - else if (child->GetClassId() == SURFACE) { - pugi::xml_node childNode = currentNode.append_child("surface"); - this->WriteSurface(childNode, dynamic_cast(child)); - } else if (child->GetClassId() == ZONE) { pugi::xml_node childNode = currentNode.append_child("zone"); this->WriteZone(childNode, dynamic_cast(child)); @@ -8507,7 +8503,7 @@ bool MEIInput::ReadGraphic(Object *parent, pugi::xml_node graphic) return true; } -bool MEIInput::ReadSurface(Object *parent, pugi::xml_node surface) +bool MEIInput::ReadSurface(Facsimile *parent, pugi::xml_node surface) { assert(parent); Surface *vrvSurface = new Surface(); @@ -8520,9 +8516,6 @@ bool MEIInput::ReadSurface(Object *parent, pugi::xml_node surface) if (strcmp(child.name(), "graphic") == 0) { this->ReadGraphic(vrvSurface, child); } - else if (strcmp(child.name(), "surface") == 0) { - this->ReadSurface(vrvSurface, child); - } else if (strcmp(child.name(), "zone") == 0) { this->ReadZone(vrvSurface, child); } diff --git a/src/surface.cpp b/src/surface.cpp index 799f8477e26..3c0b01d1b43 100644 --- a/src/surface.cpp +++ b/src/surface.cpp @@ -49,9 +49,6 @@ bool Surface::IsSupportedChild(Object *object) if (object->Is(GRAPHIC)) { assert(dynamic_cast(object)); } - else if (object->Is(SURFACE)) { - assert(dynamic_cast(object)); - } else if (object->Is(ZONE)) { assert(dynamic_cast(object)); } From 3a5dda70b23cd67fe7d3176f252a462a760b89be Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Thu, 28 Dec 2023 11:49:56 +0000 Subject: [PATCH 24/30] Make a separate Doc::UpdatePageDrawingSizes method --- include/vrv/doc.h | 5 +++++ src/doc.cpp | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/vrv/doc.h b/include/vrv/doc.h index 788483f2554..3a60bfe6c6b 100644 --- a/include/vrv/doc.h +++ b/include/vrv/doc.h @@ -398,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/src/doc.cpp b/src/doc.cpp index 1b5d917a0d5..ce24cb3dbed 100644 --- a/src/doc.cpp +++ b/src/doc.cpp @@ -2038,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) @@ -2103,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() From 64110d14b35c3c7269372deeefecbce9143911cd Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Thu, 28 Dec 2023 12:19:56 +0000 Subject: [PATCH 25/30] Adjust the implementation of SyncFromFacsimile * Read page size from the surface attributes * Convert to logical units --- include/vrv/facsimilefunctor.h | 11 ++++- src/doc.cpp | 2 +- src/facsimilefunctor.cpp | 82 +++++++++++++++++++--------------- src/facsimileinterface.cpp | 4 +- 4 files changed, 59 insertions(+), 40 deletions(-) diff --git a/include/vrv/facsimilefunctor.h b/include/vrv/facsimilefunctor.h index 4f3ae259fe5..1273343626c 100644 --- a/include/vrv/facsimilefunctor.h +++ b/include/vrv/facsimilefunctor.h @@ -35,7 +35,7 @@ class SyncFromFacsimileFunctor : public Functor { * @name Constructors, destructors */ ///@{ - SyncFromFacsimileFunctor(); + SyncFromFacsimileFunctor(Doc *doc); virtual ~SyncFromFacsimileFunctor() = default; ///@} @@ -64,6 +64,10 @@ class SyncFromFacsimileFunctor : public Functor { public: // private: + /** The doc */ + Doc *m_doc; + // + View m_view; // Page *m_currentPage; System *m_currentSystem; @@ -115,13 +119,16 @@ class SyncToFacsimileFunctor : public Functor { 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; // - View m_view; + int m_pageMarginTop; + int m_pageMarginLeft; }; } // namespace vrv diff --git a/src/doc.cpp b/src/doc.cpp index ce24cb3dbed..d138ced9ba9 100644 --- a/src/doc.cpp +++ b/src/doc.cpp @@ -1398,7 +1398,7 @@ void Doc::SyncFromFacsimileDoc() PrepareFacsimileFunctor prepareFacsimile(this->GetFacsimile()); this->Process(prepareFacsimile); - SyncFromFacsimileFunctor syncFromFacsimileFunctor; + SyncFromFacsimileFunctor syncFromFacsimileFunctor(this); this->Process(syncFromFacsimileFunctor); } diff --git a/src/facsimilefunctor.cpp b/src/facsimilefunctor.cpp index 62a3e61b795..eb97b6ed18d 100644 --- a/src/facsimilefunctor.cpp +++ b/src/facsimilefunctor.cpp @@ -29,8 +29,10 @@ namespace vrv { // SyncFromFacsimileFunctor //---------------------------------------------------------------------------- -SyncFromFacsimileFunctor::SyncFromFacsimileFunctor() : Functor() +SyncFromFacsimileFunctor::SyncFromFacsimileFunctor(Doc *doc) : Functor() { + m_doc = doc; + m_view.SetDoc(doc); m_currentPage = NULL; m_currentSystem = NULL; } @@ -41,7 +43,7 @@ FunctorCode SyncFromFacsimileFunctor::VisitLayerElement(LayerElement *layerEleme Zone *zone = layerElement->GetZone(); assert(zone); - layerElement->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; + layerElement->m_xAbs = m_view.ToLogicalX(zone->GetUlx() * DEFINITION_FACTOR); return FUNCTOR_CONTINUE; } @@ -50,8 +52,8 @@ FunctorCode SyncFromFacsimileFunctor::VisitMeasure(Measure *measure) { Zone *zone = measure->GetZone(); assert(zone); - measure->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; - measure->m_xAbs2 = zone->GetLrx() * DEFINITION_FACTOR; + measure->m_xAbs = m_view.ToLogicalX(zone->GetUlx() * DEFINITION_FACTOR); + measure->m_xAbs2 = m_view.ToLogicalX(zone->GetLrx() * DEFINITION_FACTOR); return FUNCTOR_CONTINUE; } @@ -59,6 +61,7 @@ FunctorCode SyncFromFacsimileFunctor::VisitMeasure(Measure *measure) FunctorCode SyncFromFacsimileFunctor::VisitPage(Page *page) { m_currentPage = page; + m_doc->SetDrawingPage(m_currentPage->GetIdx()); return FUNCTOR_CONTINUE; } @@ -69,9 +72,20 @@ FunctorCode SyncFromFacsimileFunctor::VisitPb(Pb *pb) assert(m_currentPage); Zone *zone = pb->GetZone(); - assert(zone); - m_currentPage->m_pageHeight = zone->GetLry() * DEFINITION_FACTOR; - m_currentPage->m_pageWidth = zone->GetLrx() * DEFINITION_FACTOR; + 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; } @@ -83,8 +97,8 @@ FunctorCode SyncFromFacsimileFunctor::VisitSb(Sb *sb) Zone *zone = sb->GetZone(); assert(zone); - m_currentSystem->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; - m_currentSystem->m_yAbs = zone->GetUly() * DEFINITION_FACTOR; + m_currentSystem->m_xAbs = m_view.ToLogicalX(zone->GetUlx() * DEFINITION_FACTOR); + m_currentSystem->m_yAbs = m_view.ToLogicalY(zone->GetUly() * DEFINITION_FACTOR); return FUNCTOR_CONTINUE; } @@ -93,7 +107,7 @@ FunctorCode SyncFromFacsimileFunctor::VisitStaff(Staff *staff) { Zone *zone = staff->GetZone(); assert(zone); - staff->m_yAbs = zone->GetUly() * DEFINITION_FACTOR; + staff->m_yAbs = m_view.ToLogicalY(zone->GetUly() * DEFINITION_FACTOR); return FUNCTOR_CONTINUE; } @@ -116,26 +130,26 @@ SyncToFacsimileFunctor::SyncToFacsimileFunctor(Doc *doc) : Functor() 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; - // layerElement->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; Zone *zone = this->GetZone(layerElement, layerElement->GetClassName()); - zone->SetUlx(m_view.ToLogicalX(layerElement->GetDrawingX()) / DEFINITION_FACTOR); + zone->SetUlx(m_view.ToDeviceContextX(layerElement->GetDrawingX()) / DEFINITION_FACTOR + m_pageMarginLeft); return FUNCTOR_CONTINUE; } FunctorCode SyncToFacsimileFunctor::VisitMeasure(Measure *measure) { - // measure->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; - // measure->m_xAbs2 = zone->GetLrx() * DEFINITION_FACTOR; Zone *zone = this->GetZone(measure, measure->GetClassName()); - zone->SetUlx(measure->GetDrawingX() / DEFINITION_FACTOR); - zone->SetLrx(measure->GetDrawingX() + measure->GetWidth() / DEFINITION_FACTOR); + 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; } @@ -146,46 +160,44 @@ FunctorCode SyncToFacsimileFunctor::VisitPage(Page *page) m_doc->SetDrawingPage(page->GetIdx()); page->LayOut(); // - Surface *surface = new Surface(); - assert(m_doc->GetFacsimile()); - m_doc->GetFacsimile()->AddChild(surface); - surface->SetLrx(m_doc->m_drawingPageWidth / DEFINITION_FACTOR); - surface->SetLry(m_doc->m_drawingPageHeight / DEFINITION_FACTOR); m_surface = new Surface(); - surface->AddChild(m_surface); - m_surface->SetUlx(m_doc->m_drawingPageMarginLeft / DEFINITION_FACTOR); - m_surface->SetUly(m_doc->m_drawingPageMarginRight / DEFINITION_FACTOR); - m_surface->SetLrx(m_doc->m_drawingPageContentWidth / DEFINITION_FACTOR); - m_surface->SetLry(m_doc->m_drawingPageContentHeight / DEFINITION_FACTOR); + 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) { - // m_currentPage->m_pageHeight = zone->GetLry() * DEFINITION_FACTOR; - // m_currentPage->m_pageWidth = zone->GetLrx() * DEFINITION_FACTOR; - // Zone *zone = this->GetZone(pb, pb->GetClassName()); + 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) { - // m_currentSystem->m_xAbs = zone->GetUlx() * DEFINITION_FACTOR; - // m_currentSystem->m_yAbs = zone->GetUly() * DEFINITION_FACTOR; Zone *zone = this->GetZone(sb, sb->GetClassName()); - zone->SetUlx(m_view.ToLogicalX(m_currentSystem->GetDrawingX()) / DEFINITION_FACTOR); - zone->SetUly(m_view.ToLogicalY(m_currentSystem->GetDrawingY()) / DEFINITION_FACTOR); + 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) { - // staff->m_yAbs = zone->GetUly() * DEFINITION_FACTOR; Zone *zone = this->GetZone(staff, staff->GetClassName()); - zone->SetUly(m_view.ToLogicalY(staff->GetDrawingY()) / DEFINITION_FACTOR); + zone->SetUly(m_view.ToDeviceContextY(staff->GetDrawingY()) / DEFINITION_FACTOR + m_pageMarginTop); return FUNCTOR_CONTINUE; } diff --git a/src/facsimileinterface.cpp b/src/facsimileinterface.cpp index d6caee2e131..93dd965da22 100644 --- a/src/facsimileinterface.cpp +++ b/src/facsimileinterface.cpp @@ -35,7 +35,7 @@ FacsimileInterface::~FacsimileInterface() {} void FacsimileInterface::Reset() { this->ResetFacsimile(); - + m_zone = NULL; m_surface = NULL; } @@ -116,7 +116,7 @@ FunctorCode FacsimileInterface::InterfacePrepareFacsimile(PrepareFacsimileFuncto 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); From ca055284bbdac22aa97ad4fed49064e36a0a0d9d Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Thu, 28 Dec 2023 14:15:53 +0000 Subject: [PATCH 26/30] Remove unused vrv_params_cast --- include/vrv/vrvdef.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/vrv/vrvdef.h b/include/vrv/vrvdef.h index 8178d672501..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 params casts within Functors -#define vrv_params_cast dynamic_cast #else #define vrv_cast static_cast -#define vrv_params_cast static_cast #endif //---------------------------------------------------------------------------- From cc9269df0bd0ba3f2d47e6698f92d237f90c57e1 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Thu, 28 Dec 2023 19:17:22 +0000 Subject: [PATCH 27/30] Add mei-facs output option in the command-line tool --- src/options.cpp | 2 +- src/toolkit.cpp | 17 +++++++++++++++-- tools/main.cpp | 14 +++++++++----- 3 files changed, 25 insertions(+), 8 deletions(-) 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/toolkit.cpp b/src/toolkit.cpp index c946c020aca..b7a31251bd2 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; } @@ -816,6 +819,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 +842,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"); } } @@ -858,8 +863,6 @@ std::string Toolkit::GetMEI(const std::string &jsonOptions) m_doc.DeactiveateSelection(); } - m_doc.SyncToFacsimileDoc(); - MEIOutput meioutput(&m_doc); meioutput.SetScoreBasedMEI(scoreBased); meioutput.SetBasic(basic); @@ -875,6 +878,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); diff --git a/tools/main.cpp b/tools/main.cpp index 6f5aba3d793..3c0c8ee647f 100644 --- a/tools/main.cpp +++ b/tools/main.cpp @@ -279,10 +279,11 @@ int main(int argc, char **argv) } if ((outformat != "svg") && (outformat != "mei") && (outformat != "mei-basic") && (outformat != "mei-pb") - && (outformat != "midi") && (outformat != "timemap") && (outformat != "expansionmap") - && (outformat != "humdrum") && (outformat != "hum") && (outformat != "pae")) { + && (outformat != "mei-facs") && (outformat != "midi") && (outformat != "timemap") + && (outformat != "expansionmap") && (outformat != "humdrum") && (outformat != "hum") && (outformat != "pae")) { std::cerr << "Output format (" << outformat - << ") can only be 'mei', 'mei-basic', 'mei-pb', 'svg', 'midi', 'timemap', 'expansionmap', 'humdrum' " + << ") can only be 'mei', 'mei-basic', 'mei-pb', mei-facs', 'svg', 'midi', 'timemap', 'expansionmap', " + "'humdrum' " "or 'pae'." << std::endl; exit(1); @@ -553,10 +554,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 +573,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); } From 972ae2cc11922fa0258a1c0c220253a5777eeee9 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 29 Dec 2023 07:52:05 +0000 Subject: [PATCH 28/30] Move call to Doc::SyncFromFacsimile to Toolkit::LoadData --- src/iomei.cpp | 4 ---- src/toolkit.cpp | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/iomei.cpp b/src/iomei.cpp index 7aa1a46e76d..66c7cf2076c 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -3999,10 +3999,6 @@ bool MEIInput::ReadDoc(pugi::xml_node root) m_doc->ConvertMarkupDoc(!m_doc->GetOptions()->m_preserveAnalyticalMarkup.GetValue()); } - if (success && m_doc->IsTranscription()) { - m_doc->SyncFromFacsimileDoc(); - } - if (success && !m_hasScoreDef) { LogWarning("No scoreDef provided, trying to generate one..."); success = m_doc->GenerateDocumentScoreDef(); diff --git a/src/toolkit.cpp b/src/toolkit.cpp index b7a31251bd2..4821605cf8b 100644 --- a/src/toolkit.cpp +++ b/src/toolkit.cpp @@ -752,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.IsTranscription() || m_doc.IsFacs()) 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 @@ -787,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); From 6d05ef624340fba31c3ce65fe19d221321a8f804 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Fri, 29 Dec 2023 11:58:11 +0100 Subject: [PATCH 29/30] Rename m_*Abs members to m_drawingFacs* --- include/vrv/doc.h | 2 +- include/vrv/layerelement.h | 2 +- include/vrv/measure.h | 4 +-- include/vrv/staff.h | 2 +- include/vrv/system.h | 4 +-- src/adjustxrelfortranscriptionfunctor.cpp | 2 +- src/facsimilefunctor.cpp | 12 ++++---- src/iomei.cpp | 34 +++++++++++------------ src/layerelement.cpp | 8 +++--- src/measure.cpp | 16 +++++------ src/miscfunctor.cpp | 12 ++++---- src/staff.cpp | 4 +-- src/system.cpp | 8 +++--- 13 files changed, 55 insertions(+), 55 deletions(-) diff --git a/include/vrv/doc.h b/include/vrv/doc.h index 3a60bfe6c6b..8b387ef995a 100644 --- a/include/vrv/doc.h +++ b/include/vrv/doc.h @@ -370,7 +370,7 @@ class Doc : public Object { void ConvertMarkupDoc(bool permanent = true); /** - * Sync the coordinate provided trought to m_Abs. + * Sync the coordinate provided trought to m_drawingFacsX/Y. * Call the SyncToFacsimile functor. */ void SyncFromFacsimileDoc(); 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 e76832df519..49ab432a0d7 100644 --- a/include/vrv/measure.h +++ b/include/vrv/measure.h @@ -371,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/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/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/facsimilefunctor.cpp b/src/facsimilefunctor.cpp index eb97b6ed18d..73ec1ef23ca 100644 --- a/src/facsimilefunctor.cpp +++ b/src/facsimilefunctor.cpp @@ -43,7 +43,7 @@ FunctorCode SyncFromFacsimileFunctor::VisitLayerElement(LayerElement *layerEleme Zone *zone = layerElement->GetZone(); assert(zone); - layerElement->m_xAbs = m_view.ToLogicalX(zone->GetUlx() * DEFINITION_FACTOR); + layerElement->m_drawingFacsX = m_view.ToLogicalX(zone->GetUlx() * DEFINITION_FACTOR); return FUNCTOR_CONTINUE; } @@ -52,8 +52,8 @@ FunctorCode SyncFromFacsimileFunctor::VisitMeasure(Measure *measure) { Zone *zone = measure->GetZone(); assert(zone); - measure->m_xAbs = m_view.ToLogicalX(zone->GetUlx() * DEFINITION_FACTOR); - measure->m_xAbs2 = m_view.ToLogicalX(zone->GetLrx() * DEFINITION_FACTOR); + measure->m_drawingFacsX1 = m_view.ToLogicalX(zone->GetUlx() * DEFINITION_FACTOR); + measure->m_drawingFacsX2 = m_view.ToLogicalX(zone->GetLrx() * DEFINITION_FACTOR); return FUNCTOR_CONTINUE; } @@ -97,8 +97,8 @@ FunctorCode SyncFromFacsimileFunctor::VisitSb(Sb *sb) Zone *zone = sb->GetZone(); assert(zone); - m_currentSystem->m_xAbs = m_view.ToLogicalX(zone->GetUlx() * DEFINITION_FACTOR); - m_currentSystem->m_yAbs = m_view.ToLogicalY(zone->GetUly() * DEFINITION_FACTOR); + 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; } @@ -107,7 +107,7 @@ FunctorCode SyncFromFacsimileFunctor::VisitStaff(Staff *staff) { Zone *zone = staff->GetZone(); assert(zone); - staff->m_yAbs = m_view.ToLogicalY(zone->GetUly() * DEFINITION_FACTOR); + staff->m_drawingFacsY = m_view.ToLogicalY(zone->GetUly() * DEFINITION_FACTOR); return FUNCTOR_CONTINUE; } diff --git a/src/iomei.cpp b/src/iomei.cpp index 66c7cf2076c..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); } @@ -1894,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); } @@ -2226,8 +2226,8 @@ void MEIOutput::WriteStaff(pugi::xml_node currentNode, Staff *staff) 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); } } @@ -2306,8 +2306,8 @@ void MEIOutput::WriteLayerElement(pugi::xml_node currentNode, LayerElement *elem 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); } } @@ -4578,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"); } @@ -5370,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); @@ -6063,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)) { @@ -6303,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; @@ -8471,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) 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 3e5cf77f2db..4439fe36ce8 100644 --- a/src/measure.cpp +++ b/src/measure.cpp @@ -137,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; @@ -150,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; @@ -216,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; @@ -356,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; @@ -364,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/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; From 3a03a72143665dd104c6c117ce0034ee5dbbce19 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Tue, 9 Jan 2024 15:13:21 +0100 Subject: [PATCH 30/30] Make a vector of possible output formats --- tools/main.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/main.cpp b/tools/main.cpp index 3c0c8ee647f..c3eca7deec5 100644 --- a/tools/main.cpp +++ b/tools/main.cpp @@ -278,13 +278,12 @@ int main(int argc, char **argv) exit(1); } - if ((outformat != "svg") && (outformat != "mei") && (outformat != "mei-basic") && (outformat != "mei-pb") - && (outformat != "mei-facs") && (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', mei-facs', 'svg', 'midi', 'timemap', 'expansionmap', " - "'humdrum' " - "or 'pae'." + "'humdrum', 'hum', or 'pae'." << std::endl; exit(1); }