diff --git a/.github/workflows/ci_build.yml b/.github/workflows/ci_build.yml index ca515fa61ad..1d75b6b86ff 100644 --- a/.github/workflows/ci_build.yml +++ b/.github/workflows/ci_build.yml @@ -78,7 +78,7 @@ jobs: compiler: g++ version: "10" - - os: ubuntu-20.04 + - os: ubuntu-22.04 compiler: g++ version: "11" diff --git a/Verovio.xcodeproj/project.pbxproj b/Verovio.xcodeproj/project.pbxproj index 06ae5b7bc23..9c99a0a38a6 100644 --- a/Verovio.xcodeproj/project.pbxproj +++ b/Verovio.xcodeproj/project.pbxproj @@ -5172,7 +5172,7 @@ "$(inherited)", NO_HUMDRUM_SUPPORT, ); - MACOSX_DEPLOYMENT_TARGET = ""; + MACOSX_DEPLOYMENT_TARGET = 10.15; PRODUCT_NAME = "$(TARGET_NAME)"; USER_HEADER_SEARCH_PATHS = ""; }; @@ -5184,7 +5184,7 @@ CODE_SIGN_IDENTITY = "-"; DEAD_CODE_STRIPPING = YES; GCC_PREPROCESSOR_DEFINITIONS = NO_HUMDRUM_SUPPORT; - MACOSX_DEPLOYMENT_TARGET = ""; + MACOSX_DEPLOYMENT_TARGET = 10.15; PRODUCT_NAME = "$(TARGET_NAME)"; USER_HEADER_SEARCH_PATHS = ""; }; diff --git a/include/vrv/adjustyrelfortranscriptionfunctor.h b/include/vrv/adjustyrelfortranscriptionfunctor.h deleted file mode 100644 index af26cbda9e2..00000000000 --- a/include/vrv/adjustyrelfortranscriptionfunctor.h +++ /dev/null @@ -1,56 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: adjustyrelfortranscriptionfunctor.h -// Author: Yinan Zhou -// Created: 2024 -// Copyright (c) Authors and others. All rights reserved. -///////////////////////////////////////////////////////////////////////////// - -#ifndef __VRV_ADJUSTYRELFORTRANSCRIPTIONFUNCTOR_H__ -#define __VRV_ADJUSTYRELFORTRANSCRIPTIONFUNCTOR_H__ - -#include "functor.h" - -namespace vrv { - -//---------------------------------------------------------------------------- -// AdjustYRelForTranscriptionFunctor -//---------------------------------------------------------------------------- - -/** - * This class adjusts the YRel positions taking into account the bounding boxes. - */ -class AdjustYRelForTranscriptionFunctor : public Functor { -public: - /** - * @name Constructors, destructors - */ - ///@{ - AdjustYRelForTranscriptionFunctor(); - virtual ~AdjustYRelForTranscriptionFunctor() = default; - ///@} - - /* - * Abstract base implementation - */ - bool ImplementsEndInterface() const override { return false; } - - /* - * Functor interface - */ - ///@{ - FunctorCode VisitLayerElement(LayerElement *layerElement) override; - ///@} - -protected: - // -private: - // -public: - // -private: - // -}; - -} // namespace vrv - -#endif // __VRV_ADJUSTYRELFORTRANSCRIPTIONFUNCTOR_H__ diff --git a/include/vrv/devicecontext.h b/include/vrv/devicecontext.h index 95c62a81208..b319c835a1a 100644 --- a/include/vrv/devicecontext.h +++ b/include/vrv/devicecontext.h @@ -74,7 +74,6 @@ class DeviceContext { m_baseWidth = 0; m_baseHeight = 0; m_pushBack = false; - m_viewBoxFactor = (double)DEFINITION_FACTOR; } DeviceContext(ClassId classId) { @@ -90,7 +89,6 @@ class DeviceContext { m_baseWidth = 0; m_baseHeight = 0; m_pushBack = false; - m_viewBoxFactor = (double)DEFINITION_FACTOR; } virtual ~DeviceContext(){}; ClassId GetClassId() const { return m_classId; } @@ -126,14 +124,12 @@ class DeviceContext { m_baseWidth = width; m_baseHeight = height; } - void SetViewBoxFactor(double ppuFactor); int GetWidth() const { return m_width; } int GetHeight() const { return m_height; } int GetContentHeight() const { return m_contentHeight; } double GetUserScaleX() { return m_userScaleX; } double GetUserScaleY() { return m_userScaleY; } std::pair GetBaseSize() const { return std::make_pair(m_baseWidth, m_baseHeight); } - double GetViewBoxFactor() const { return m_viewBoxFactor; } ///@} /** @@ -369,9 +365,6 @@ class DeviceContext { /** stores the scale as requested by the used */ double m_userScaleX; double m_userScaleY; - - /** stores the viewbox factor taking into account the DEFINTION_FACTOR and the PPU */ - double m_viewBoxFactor; }; } // namespace vrv diff --git a/include/vrv/doc.h b/include/vrv/doc.h index 48876eec45e..687f6f068e2 100644 --- a/include/vrv/doc.h +++ b/include/vrv/doc.h @@ -451,14 +451,6 @@ class Doc : public Object { bool IsMensuralMusicOnly() const { return m_isMensuralMusicOnly; } ///@} - /** - * @name Setter for and getter for neume-line flag - */ - ///@{ - void SetNeumeLines(bool isNeumeLines) { m_isNeumeLines = isNeumeLines; } - bool IsNeumeLines() const { return m_isNeumeLines; } - ///@} - /** * @name Setter and getter for facsimile */ @@ -668,12 +660,6 @@ class Doc : public Object { */ bool m_isMensuralMusicOnly; - /** - * A flag to indicate that the document contains neume lines. - * This is a special document type where neume lines are encoded with
- */ - bool m_isNeumeLines; - /** Page width (MEI scoredef@page.width) - currently not saved */ int m_pageWidth; /** Page height (MEI scoredef@page.height) - currently not saved */ diff --git a/include/vrv/editortoolkit_neume.h b/include/vrv/editortoolkit_neume.h index 90dd931c667..fc148e51488 100644 --- a/include/vrv/editortoolkit_neume.h +++ b/include/vrv/editortoolkit_neume.h @@ -16,7 +16,6 @@ #include "doc.h" #include "editortoolkit.h" -#include "measure.h" #include "view.h" #include "vrv.h" #include "zone.h" @@ -51,8 +50,6 @@ class EditorToolkitNeume : public EditorToolkit { bool Set(std::string elementId, std::string attrType, std::string attrValue); bool SetText(std::string elementId, const std::string &text); bool SetClef(std::string elementId, std::string shape); - bool SetLiquescent(std::string elementId, std::string shape); - bool SortStaves(); bool Split(std::string elementId, int x); bool SplitNeume(std::string elementId, std::string ncId); bool Remove(std::string elementId); @@ -83,7 +80,6 @@ class EditorToolkitNeume : public EditorToolkit { bool ParseSetAction(jsonxx::Object param, std::string *elementId, std::string *attrType, std::string *attrValue); bool ParseSetTextAction(jsonxx::Object param, std::string *elementId, std::string *text); bool ParseSetClefAction(jsonxx::Object param, std::string *elementId, std::string *shape); - bool ParseSetLiquescentAction(jsonxx::Object param, std::string *elementId, std::string *shape); bool ParseSplitAction(jsonxx::Object param, std::string *elementId, int *x); bool ParseSplitNeumeAction(jsonxx::Object param, std::string *elementId, std::string *ncId); bool ParseRemoveAction(jsonxx::Object param, std::string *elementId); @@ -182,26 +178,11 @@ struct ClosestNeume { struct StaffSort { // Sort staves left-to-right and top-to-bottom // Sort by y if there is no intersection, by x if there is x intersection is smaller than half length of staff line - - // Update 2024-04: - // Used only in neume lines, - // System->(Measure->Staff) - // Need to sort Measure to sort staff bool operator()(Object *a, Object *b) { - if (!a->Is(SYSTEM) || !b->Is(SYSTEM)) return false; - if (!a->FindDescendantByType(MEASURE) || !b->FindDescendantByType(MEASURE)) return false; - Measure *measureA = dynamic_cast(a->FindDescendantByType(MEASURE)); - Measure *measureB = dynamic_cast(b->FindDescendantByType(MEASURE)); - if (!measureA->IsNeumeLine() || !measureB->IsNeumeLine()) return true; - Object *staffA = a->FindDescendantByType(STAFF); - Object *staffB = b->FindDescendantByType(STAFF); - assert(staffA); - assert(staffB); - Zone *zoneA = staffA->GetFacsimileInterface()->GetZone(); - Zone *zoneB = staffB->GetFacsimileInterface()->GetZone(); - assert(zoneA); - assert(zoneB); + if (!a->GetFacsimileInterface() || !b->GetFacsimileInterface()) return true; + Zone *zoneA = a->GetFacsimileInterface()->GetZone(); + Zone *zoneB = b->GetFacsimileInterface()->GetZone(); int aLowest, bLowest, aHighest, bHighest; diff --git a/include/vrv/facsimilefunctor.h b/include/vrv/facsimilefunctor.h index 7ccf8f3e772..1273343626c 100644 --- a/include/vrv/facsimilefunctor.h +++ b/include/vrv/facsimilefunctor.h @@ -42,7 +42,7 @@ class SyncFromFacsimileFunctor : public Functor { /* * Abstract base implementation */ - bool ImplementsEndInterface() const override { return true; } + bool ImplementsEndInterface() const override { return false; } /* * Functor interface @@ -51,7 +51,6 @@ class SyncFromFacsimileFunctor : public Functor { FunctorCode VisitLayerElement(LayerElement *layerElement) override; FunctorCode VisitMeasure(Measure *measure) override; FunctorCode VisitPage(Page *page) override; - FunctorCode VisitPageEnd(Page *page) override; FunctorCode VisitPb(Pb *pb) override; FunctorCode VisitSb(Sb *sb) override; FunctorCode VisitStaff(Staff *staff) override; @@ -72,9 +71,6 @@ class SyncFromFacsimileFunctor : public Functor { // Page *m_currentPage; System *m_currentSystem; - Measure *m_currentNeumeLine; - /** map to store the zone corresponding to a staff */ - std::map m_staffZones; }; //---------------------------------------------------------------------------- diff --git a/include/vrv/facsimileinterface.h b/include/vrv/facsimileinterface.h index 84f46ddb9b8..7afafef144b 100644 --- a/include/vrv/facsimileinterface.h +++ b/include/vrv/facsimileinterface.h @@ -58,13 +58,6 @@ class FacsimileInterface : public Interface, public AttFacsimile { Zone *GetZone() { return m_zone; } const Zone *GetZone() const { return m_zone; } ///@} - /// - - /** Get the surface */ - ///@{ - Surface *GetSurface() { return m_surface; } - const Surface *GetSurface() const { return m_surface; } - ///@} //-----------------// // Pseudo functors // diff --git a/include/vrv/layerelement.h b/include/vrv/layerelement.h index ea8307a9da1..cf8a7af9e32 100644 --- a/include/vrv/layerelement.h +++ b/include/vrv/layerelement.h @@ -387,7 +387,6 @@ class LayerElement : public Object, public: /** Absolute position X. This is used for facsimile (transcription) encoding */ int m_drawingFacsX; - int m_drawingFacsY; // This is used only for accid, syl /** * 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 dcf96d15243..49ab432a0d7 100644 --- a/include/vrv/measure.h +++ b/include/vrv/measure.h @@ -53,7 +53,7 @@ class Measure : public Object, * Reset method resets all attribute classes */ ///@{ - Measure(MeasureType measuredMusic = MEASURED, int logMeasureNb = -1); + Measure(bool measuredMusic = true, int logMeasureNb = -1); virtual ~Measure(); Object *Clone() const override { return new Measure(*this); }; void Reset() override; @@ -79,12 +79,7 @@ class Measure : public Object, /** * Return true if measured music (otherwise we have fake measures) */ - bool IsMeasuredMusic() const { return (m_measureType == MEASURED); } - - /** - * Return true if the measure represents a neume (section) line - */ - bool IsNeumeLine() const { return (m_measureType == NEUMELINE); } + bool IsMeasuredMusic() const { return m_measuredMusic; } /** * Get and set the measure index @@ -409,10 +404,9 @@ class Measure : public Object, private: /** - * Indicate measured music (CMN), unmeasured (fake measures for mensural or neumes) or neume lines - * Neume line measure are created from
+ * Indicates measured music (otherwise we have fake measures) */ - MeasureType m_measureType; + bool m_measuredMusic; /** * The unique measure index diff --git a/include/vrv/staff.h b/include/vrv/staff.h index 92a699a43bf..cd68fe3eaa4 100644 --- a/include/vrv/staff.h +++ b/include/vrv/staff.h @@ -112,17 +112,6 @@ class Staff : public Object, } ///@} - /** - * @name Getters and setters for the rotation. - * Used only with facsimile rendering. - */ - ///@{ - void SetDrawingRotation(double drawingRotation) { m_drawingRotation = drawingRotation; } - double GetDrawingRotation() const { return m_drawingRotation; } - bool HasDrawingRotation() const { return (m_drawingRotation != 0.0); } - int GetDrawingRotationOffsetFor(int x); - ///@} - /** * Delete all the legder line arrays. */ @@ -301,12 +290,6 @@ class Staff : public Object, ArrayOfLedgerLines m_ledgerLinesAboveCue; ArrayOfLedgerLines m_ledgerLinesBelowCue; ///@} - - /** - * The drawing rotation. - * Used only with facsimile rendering - */ - double m_drawingRotation; }; } // namespace vrv diff --git a/include/vrv/view.h b/include/vrv/view.h index 485d1d9b1a9..2f59e4c6657 100644 --- a/include/vrv/view.h +++ b/include/vrv/view.h @@ -416,7 +416,6 @@ class View { ///@{ void DrawDivLine(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure); void DrawSyllable(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure); - void DrawLiquescent(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure); void DrawNc(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure); void DrawNeume(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure); ///@} diff --git a/include/vrv/vrvdef.h b/include/vrv/vrvdef.h index bda87157121..526d3af9fac 100644 --- a/include/vrv/vrvdef.h +++ b/include/vrv/vrvdef.h @@ -661,14 +661,6 @@ enum SmuflTextFont { SMUFL_NONE = 0, SMUFL_FONT_SELECTED, SMUFL_FONT_FALLBACK }; enum GraphicID { PRIMARY = 0, SPANNING, SYMBOLREF }; -//---------------------------------------------------------------------------- -// Measure type -//---------------------------------------------------------------------------- - -enum MeasureType { MEASURED = 0, UNMEASURED, NEUMELINE }; - -#define NEUME_LINE_TYPE "neon-neume-line" - //---------------------------------------------------------------------------- // Legacy Wolfgang defines //---------------------------------------------------------------------------- diff --git a/src/adjustyrelfortranscriptionfunctor.cpp b/src/adjustyrelfortranscriptionfunctor.cpp deleted file mode 100644 index 8bcc92402d1..00000000000 --- a/src/adjustyrelfortranscriptionfunctor.cpp +++ /dev/null @@ -1,35 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: adjustyrelfortranscriptionfunctor.cpp -// Author: Yinan Zhou -// Created: 2024 -// Copyright (c) Authors and others. All rights reserved. -///////////////////////////////////////////////////////////////////////////// - -#include "adjustyrelfortranscriptionfunctor.h" - -//---------------------------------------------------------------------------- - -//---------------------------------------------------------------------------- - -namespace vrv { - -//---------------------------------------------------------------------------- -// AdjustYRelForTranscriptionFunctor -//---------------------------------------------------------------------------- - -AdjustYRelForTranscriptionFunctor::AdjustYRelForTranscriptionFunctor() : Functor() {} - -FunctorCode AdjustYRelForTranscriptionFunctor::VisitLayerElement(LayerElement *layerElement) -{ - if (layerElement->m_drawingFacsY == VRV_UNSET) return FUNCTOR_CONTINUE; - - if (layerElement->IsScoreDefElement()) return FUNCTOR_SIBLINGS; - - if (!layerElement->HasSelfBB()) return FUNCTOR_CONTINUE; - - layerElement->SetDrawingYRel(-layerElement->GetSelfY1()); - - return FUNCTOR_CONTINUE; -} - -} // namespace vrv diff --git a/src/calcdotsfunctor.cpp b/src/calcdotsfunctor.cpp index b979a50aa66..2be321aa7a9 100644 --- a/src/calcdotsfunctor.cpp +++ b/src/calcdotsfunctor.cpp @@ -60,10 +60,6 @@ FunctorCode CalcDotsFunctor::VisitChord(Chord *chord) FunctorCode CalcDotsFunctor::VisitNote(Note *note) { - // We currently have no dots object with mensural notes - if (note->IsMensuralDur()) { - return FUNCTOR_SIBLINGS; - } if (!note->IsVisible()) { return FUNCTOR_SIBLINGS; } diff --git a/src/convertfunctor.cpp b/src/convertfunctor.cpp index d80c5db720f..61838252781 100644 --- a/src/convertfunctor.cpp +++ b/src/convertfunctor.cpp @@ -187,12 +187,9 @@ FunctorCode ConvertToCastOffMensuralFunctor::VisitBarLine(BarLine *barLine) bool nextIsBarline = (next && next->Is(BARLINE)); // See if we create proper measures and what to do with the barLine - MeasureType convertToMeasured = UNMEASURED; - if (m_doc->GetOptions()->m_mensuralToMeasure.GetValue()) { - convertToMeasured = MEASURED; - } + bool convertToMeasured = m_doc->GetOptions()->m_mensuralToMeasure.GetValue(); - if (convertToMeasured == MEASURED) { + if (convertToMeasured) { // barLine object will be deleted m_targetMeasure->SetRight(barLine->GetForm()); } @@ -215,7 +212,7 @@ FunctorCode ConvertToCastOffMensuralFunctor::VisitBarLine(BarLine *barLine) // First case: add a new measure segment (e.g., first pass) if (m_targetSubSystem->GetChildCount() <= m_segmentIdx) { m_targetMeasure = new Measure(convertToMeasured); - if (convertToMeasured == MEASURED) { + if (convertToMeasured) { m_targetMeasure->SetN(StringFormat("%d", m_segmentTotal + 1 + m_segmentIdx)); } m_targetSubSystem->AddChild(m_targetMeasure); @@ -280,10 +277,7 @@ FunctorCode ConvertToCastOffMensuralFunctor::VisitMeasure(Measure *measure) return FUNCTOR_CONTINUE; } - MeasureType convertToMeasured = UNMEASURED; - if (m_doc->GetOptions()->m_mensuralToMeasure.GetValue()) { - convertToMeasured = MEASURED; - } + bool convertToMeasured = m_doc->GetOptions()->m_mensuralToMeasure.GetValue(); assert(m_targetSystem); assert(m_layerTree); @@ -295,7 +289,7 @@ FunctorCode ConvertToCastOffMensuralFunctor::VisitMeasure(Measure *measure) // Create the first measure segment - problem: we are dropping the section element - we should create a score-based // MEI file instead Measure *targetMeasure = new Measure(convertToMeasured); - if (convertToMeasured == MEASURED) { + if (convertToMeasured) { targetMeasure->SetN(StringFormat("%d", m_segmentTotal + 1)); } m_targetSubSystem->AddChild(targetMeasure); @@ -381,7 +375,7 @@ FunctorCode ConvertToCastOffMensuralFunctor::VisitSyllable(Syllable *syllable) // Make a segment break // First case: add a new measure segment (e.g., first pass) if (m_targetSubSystem->GetChildCount() <= m_segmentIdx) { - m_targetMeasure = new Measure(UNMEASURED); + m_targetMeasure = new Measure(false); m_targetSubSystem->AddChild(m_targetMeasure); // Add a staff with same attributes as in the previous segment m_targetStaff = new Staff(*m_targetStaff); diff --git a/src/devicecontext.cpp b/src/devicecontext.cpp index e734a35919d..09a868e56ab 100644 --- a/src/devicecontext.cpp +++ b/src/devicecontext.cpp @@ -129,11 +129,6 @@ const Resources *DeviceContext::GetResources(bool showWarning) const return m_resources; } -void DeviceContext::SetViewBoxFactor(double ppuFactor) -{ - m_viewBoxFactor = double(DEFINITION_FACTOR) / ppuFactor; -} - void DeviceContext::SetPen(int color, int width, int style, int dashLength, int gapLength, int lineCap, int lineJoin) { float opacityValue; diff --git a/src/doc.cpp b/src/doc.cpp index 4300e41b8d8..5b13dd476d7 100644 --- a/src/doc.cpp +++ b/src/doc.cpp @@ -132,7 +132,6 @@ void Doc::Reset() m_timemapTempo = 0.0; m_markup = MARKUP_DEFAULT; m_isMensuralMusicOnly = false; - m_isNeumeLines = false; m_isCastOff = false; m_visibleScores.clear(); @@ -1408,8 +1407,6 @@ void Doc::SyncToFacsimileDoc() if (!m_facsimile->FindDescendantByType(SURFACE)) { m_facsimile->AddChild(new Surface()); } - this->ScoreDefSetCurrentDoc(); - m_facsimile->SetType("transcription"); m_facsimile->ClearChildren(); @@ -2131,10 +2128,8 @@ int Doc::GetAdjustedDrawingPageHeight() const { assert(m_drawingPage); - // Take into account the PPU when getting the page height in facsimile if (this->IsTranscription() || this->IsFacs()) { - const int factor = DEFINITION_FACTOR / m_drawingPage->GetPPUFactor(); - return m_drawingPage->m_pageHeight / factor; + return m_drawingPage->m_pageHeight / DEFINITION_FACTOR; } int contentHeight = m_drawingPage->GetContentHeight(); @@ -2145,10 +2140,8 @@ int Doc::GetAdjustedDrawingPageWidth() const { assert(m_drawingPage); - // Take into account the PPU when getting the page width in facsimile if (this->IsTranscription() || this->IsFacs()) { - const int factor = DEFINITION_FACTOR / m_drawingPage->GetPPUFactor(); - return m_drawingPage->m_pageWidth / factor; + return m_drawingPage->m_pageWidth / DEFINITION_FACTOR; } int contentWidth = m_drawingPage->GetContentWidth(); diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 1882808daaf..02820ce1754 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -25,21 +25,19 @@ #include "divline.h" #include "layer.h" #include "liquescent.h" -#include "measure.h" #include "nc.h" #include "neume.h" #include "page.h" #include "rend.h" -#include "sb.h" #include "score.h" #include "staff.h" #include "staffdef.h" #include "surface.h" #include "syl.h" #include "syllable.h" -#include "system.h" #include "text.h" #include "vrv.h" + //-------------------------------------------------------------------------------- namespace vrv { @@ -138,13 +136,6 @@ bool EditorToolkitNeume::ParseEditorAction(const std::string &json_editorAction) } LogWarning("Could not parse the set clef action"); } - else if (action == "setLiquescent") { - std::string elementId, curve; - if (this->ParseSetLiquescentAction(json.get("param"), &elementId, &curve)) { - return this->SetLiquescent(elementId, curve); - } - LogWarning("Could not parse the set liquescent action"); - } else if (action == "remove") { std::string elementId; if (this->ParseRemoveAction(json.get("param"), &elementId)) { @@ -675,12 +666,11 @@ bool EditorToolkitNeume::Drag(std::string elementId, int x, int y) if (fi->GetZone() != NULL) zones.insert(fi->GetZone()); } for (auto it = zones.begin(); it != zones.end(); ++it) { + // Transform y to device context (*it)->ShiftByXY(x, -y); } - SortStaves(); - - if (m_doc->IsTranscription() && m_doc->HasFacsimile()) m_doc->SyncFromFacsimileDoc(); + staff->GetParent()->StableSort(StaffSort()); return true; // Can't reorder by layer since staves contain layers } @@ -739,7 +729,6 @@ bool EditorToolkitNeume::Drag(std::string elementId, int x, int y) } Layer *layer = vrv_cast(element->GetFirstAncestor(LAYER)); layer->ReorderByXPos(); // Reflect position order of elements internally (and in the resulting output file) - if (m_doc->IsTranscription() && m_doc->HasFacsimile()) m_doc->SyncFromFacsimileDoc(); m_editInfo.import("status", status); m_editInfo.import("message", message); return true; @@ -754,7 +743,7 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in m_editInfo.import("message", "Could not get drawing page."); return false; } - if (!m_doc->HasFacsimile()) { + if (m_doc->GetType() != Facs) { LogError("Drawing page without facsimile"); m_editInfo.import("status", "FAILURE"); m_editInfo.import("message", "Drawing page without facsimile is unsupported."); @@ -790,27 +779,26 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in Zone *zone = new Zone(); if (elementType == "staff") { - Object *page = m_doc->GetDrawingPage(); - System *newSystem = new System(); - Sb *newSb = new Sb(); - Measure *newMeasure = new Measure(NEUMELINE); + Object *parent; Staff *newStaff; - Layer *newLayer = new Layer(); std::string columnValue; - // Use closest existing staff (if there is one) if (staff) { + parent = staff->GetParent(); + assert(parent); columnValue = staff->GetType(); - int n = page->GetChildCount(SYSTEM) + 1; + int n = parent->GetChildCount() + 1; newStaff = new Staff(n); newStaff->m_drawingStaffDef = staff->m_drawingStaffDef; newStaff->m_drawingNotationType = staff->m_drawingNotationType; newStaff->m_drawingLines = staff->m_drawingLines; } else { + parent = m_doc->GetDrawingPage()->FindDescendantByType(MEASURE); + assert(parent); newStaff = new Staff(1); newStaff->m_drawingStaffDef = vrv_cast( - m_doc->GetCorrespondingScore(page)->GetScoreDef()->FindDescendantByType(STAFFDEF)); + m_doc->GetCorrespondingScore(parent)->GetScoreDef()->FindDescendantByType(STAFFDEF)); newStaff->m_drawingNotationType = NOTATIONTYPE_neume; newStaff->m_drawingLines = 4; } @@ -824,18 +812,30 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in surface->AddChild(zone); newStaff->AttachZone(zone); if (columnValue.length()) newStaff->SetType(columnValue); - + Layer *newLayer = new Layer(); newStaff->AddChild(newLayer); - newMeasure->AddChild(newStaff); - newSystem->AddChild(newSb); - newSystem->AddChild(newMeasure); - newSystem->SetDrawingScoreDef(vrv_cast(m_doc->GetCorrespondingScore(page)->GetScoreDef())); - - page->InsertAfter(page->GetFirst(SCORE), newSystem); - SortStaves(); - - if (m_doc->IsTranscription() && m_doc->HasFacsimile()) m_doc->SyncFromFacsimileDoc(); + if (staff) { + // Find index to insert new staff + ListOfObjects staves = parent->FindAllDescendantsByType(STAFF, false); + std::vector stavesVector(staves.begin(), staves.end()); + stavesVector.push_back(newStaff); + StaffSort staffSort; + std::stable_sort(stavesVector.begin(), stavesVector.end(), staffSort); + for (int i = 0; i < (int)staves.size(); ++i) { + if (stavesVector.at(i) == newStaff) { + parent->InsertChild(newStaff, i); + parent->Modify(); + + m_editInfo.import("uuid", newStaff->GetID()); + m_editInfo.import("status", status); + m_editInfo.import("message", message); + + return true; + } + } + } + parent->AddChild(newStaff); m_editInfo.import("uuid", newStaff->GetID()); m_editInfo.import("status", status); @@ -879,21 +879,20 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in = (int)(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) / NOTE_HEIGHT_TO_STAFF_SIZE_RATIO); const int noteWidth = (int)(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) / NOTE_WIDTH_TO_STAFF_SIZE_RATIO); - const int offsetX = (int)(noteWidth / 2); // Set up facsimile - zone->SetUlx(ulx - offsetX); + zone->SetUlx(ulx); zone->SetUly(uly); - zone->SetLrx(ulx + offsetX); + zone->SetLrx(ulx + noteWidth); zone->SetLry(uly + noteHeight); // add syl bounding box if Facs - if (m_doc->HasFacsimile()) { + if (m_doc->GetType() == Facs) { FacsimileInterface *fi = vrv_cast(syl->GetFacsimileInterface()); assert(fi); sylZone = new Zone(); - int staffLry = staff->GetZone()->GetLry(); + int staffLry = staff->GetFacsimileInterface()->GetZone()->GetLry(); // width height and offset can be adjusted int bboxHeight = 175; @@ -904,7 +903,8 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in int offsetY = 0; if (theta) { double factor = 1.3; - offsetY = (int)((ulx - staff->GetZone()->GetUlx()) * tan(theta * M_PI / 180.0) / factor); + offsetY = (int)((ulx - staff->GetFacsimileInterface()->GetZone()->GetUlx()) * tan(theta * M_PI / 180.0) + / factor); } sylZone->SetUlx(ulx); @@ -945,6 +945,7 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in contour = it->second; } else if (it->first == "curve") { + Liquescent *liquescent = new Liquescent(); curvatureDirection_CURVE curve = curvatureDirection_CURVE_NONE; if (it->second == "a") { curve = curvatureDirection_CURVE_a; @@ -954,7 +955,6 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in curve = curvatureDirection_CURVE_c; nc->SetCurve(curve); } - Liquescent *liquescent = new Liquescent(); nc->AddChild(liquescent); } } @@ -993,9 +993,9 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in // Apply offset due to rotate newUly += (newUlx - ulx) * tan(-staff->GetDrawingRotate() * M_PI / 180.0); - newZone->SetUlx(newUlx - offsetX); + newZone->SetUlx(newUlx); newZone->SetUly(newUly); - newZone->SetLrx(newUlx + offsetX); + newZone->SetLrx(newUlx + noteWidth); newZone->SetLry(newUly + noteHeight); newNc->AttachZone(newZone); @@ -1025,21 +1025,14 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in Clef *clef = new Clef(); data_CLEFSHAPE clefShape = CLEFSHAPE_NONE; - const int staffSize = m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize); - int offsetR, offsetL; - for (auto it = attributes.begin(); it != attributes.end(); ++it) { if (it->first == "shape") { if (it->second == "C") { clefShape = CLEFSHAPE_C; - offsetR = (int)(staffSize / NOTE_WIDTH_TO_STAFF_SIZE_RATIO / 2); - offsetL = offsetR; break; } else if (it->second == "F") { clefShape = CLEFSHAPE_F; - offsetR = 0; - offsetL = (int)(staffSize / NOTE_WIDTH_TO_STAFF_SIZE_RATIO / 2); break; } } @@ -1053,16 +1046,17 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in return false; } clef->SetShape(clefShape); - int yDiff = -staff->GetZone()->GetUly() + uly; + const int staffSize = m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize); + int yDiff = -staff->GetDrawingY() + uly; yDiff += ((ulx - staff->GetZone()->GetUlx())) * tan(-staff->GetDrawingRotate() * M_PI / 180.0); // Subtract distance due to rotate. int clefLine = staff->m_drawingLines - round((double)yDiff / (double)staffSize); clef->SetLine(clefLine); Zone *zone = new Zone(); - zone->SetUlx(ulx - offsetR); + zone->SetUlx(ulx); zone->SetUly(uly); - zone->SetLrx(ulx + offsetL); + zone->SetLrx(ulx + staffSize / NOTE_WIDTH_TO_STAFF_SIZE_RATIO); zone->SetLry(uly + staffSize / NOTE_HEIGHT_TO_STAFF_SIZE_RATIO); clef->AttachZone(zone); Surface *surface = dynamic_cast(facsimile->FindDescendantByType(SURFACE)); @@ -1108,14 +1102,13 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in = (int)(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) / NOTE_HEIGHT_TO_STAFF_SIZE_RATIO); const int noteWidth = (int)(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) / NOTE_WIDTH_TO_STAFF_SIZE_RATIO); - const int offsetX = (int)(noteWidth / 4); ulx -= noteWidth / 2; uly -= noteHeight / 2; - zone->SetUlx(ulx + offsetX); + zone->SetUlx(ulx); zone->SetUly(uly); - zone->SetLrx(ulx + noteWidth + offsetX); + zone->SetLrx(ulx + noteWidth); zone->SetLry(uly + noteHeight); layer->ReorderByXPos(); if (!AdjustPitchFromPosition(custos)) { @@ -1162,14 +1155,13 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in = (int)(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) / NOTE_HEIGHT_TO_STAFF_SIZE_RATIO); const int noteWidth = (int)(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) / NOTE_WIDTH_TO_STAFF_SIZE_RATIO); - const int offsetX = (int)(noteWidth / 2); ulx -= noteWidth / 2; uly -= noteHeight / 2; - zone->SetUlx(ulx + offsetX); + zone->SetUlx(ulx); zone->SetUly(uly); - zone->SetLrx(ulx + noteWidth + offsetX); + zone->SetLrx(ulx + noteWidth); zone->SetLry(uly + noteHeight); layer->ReorderByXPos(); @@ -1227,14 +1219,13 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in = (int)(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) / NOTE_HEIGHT_TO_STAFF_SIZE_RATIO); const int noteWidth = (int)(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) / NOTE_WIDTH_TO_STAFF_SIZE_RATIO); - const int offsetX = (int)(noteWidth / 2); ulx -= noteWidth / 2; uly -= noteHeight / 2; - zone->SetUlx(ulx + offsetX); + zone->SetUlx(ulx); zone->SetUly(uly); - zone->SetLrx(ulx + noteWidth + offsetX); + zone->SetLrx(ulx + noteWidth); zone->SetLry(uly + noteHeight); layer->ReorderByXPos(); @@ -1248,9 +1239,6 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in return false; } layer->ReorderByXPos(); - - if (m_doc->IsTranscription() && m_doc->HasFacsimile()) m_doc->SyncFromFacsimileDoc(); - m_editInfo.import("status", status); m_editInfo.import("message", message); return true; @@ -1264,7 +1252,7 @@ bool EditorToolkitNeume::InsertToSyllable(std::string elementId) m_editInfo.import("message", "Could not get drawing page."); return false; } - if (!m_doc->HasFacsimile()) { + if (m_doc->GetType() != Facs) { LogError("Drawing page without facsimile"); m_editInfo.import("status", "FAILURE"); m_editInfo.import("message", "Drawing page without facsimile is unsupported."); @@ -1414,7 +1402,7 @@ bool EditorToolkitNeume::MoveOutsideSyllable(std::string elementId) m_editInfo.import("message", "Could not get drawing page."); return false; } - if (!m_doc->HasFacsimile()) { + if (m_doc->GetType() != Facs) { LogError("Drawing page without facsimile"); m_editInfo.import("status", "FAILURE"); m_editInfo.import("message", "Drawing page without facsimile is unsupported."); @@ -1614,7 +1602,7 @@ bool EditorToolkitNeume::MatchHeight(std::string elementId) m_editInfo.import("message", "Could not get drawing page."); return false; } - if (!m_doc->HasFacsimile()) { + if (m_doc->GetType() != Facs) { LogError("Drawing page without facsimile"); m_editInfo.import("status", "FAILURE"); m_editInfo.import("message", "Drawing page without facsimile is unsupported."); @@ -1692,8 +1680,6 @@ bool EditorToolkitNeume::MatchHeight(std::string elementId) zone->SetLry(uly + offsetY + height); } - if (m_doc->IsTranscription() && m_doc->HasFacsimile()) m_doc->SyncFromFacsimileDoc(); - m_editInfo.import("status", "OK"); m_editInfo.import("message", ""); return true; @@ -1785,8 +1771,6 @@ bool EditorToolkitNeume::Merge(std::vector elementIds) m_editInfo.import("status", "OK"); m_editInfo.import("message", ""); - if (m_doc->IsTranscription() && m_doc->HasFacsimile()) m_doc->SyncFromFacsimileDoc(); - // TODO change zones for staff children return true; @@ -1823,7 +1807,10 @@ bool EditorToolkitNeume::Set(std::string elementId, std::string attrType, std::s success = true; else if (AttModule::SetVisual(element, attrType, attrValue)) success = true; - + if (success && m_doc->GetType() != Facs) { + m_doc->PrepareData(); + m_doc->GetDrawingPage()->LayOut(true); + } m_editInfo.import("status", success ? "OK" : "FAILURE"); m_editInfo.import("message", success ? "" : "Could not set attribute '" + attrType + "' to '" + attrValue + "'."); return success; @@ -1889,8 +1876,12 @@ bool EditorToolkitNeume::SetText(std::string elementId, const std::string &text) std::u32string str = U""; text->SetText(str); syl->AddChild(text); + syllable->AddChild(syl); - if (m_doc->HasFacsimile()) { + Text *textChild = new Text(); + textChild->SetText(wtext); + syl->AddChild(textChild); + if (m_doc->GetType() == Facs) { // Create a default bounding box Zone *zone = new Zone(); int ulx, uly, lrx, lry; @@ -1927,9 +1918,6 @@ bool EditorToolkitNeume::SetText(std::string elementId, const std::string &text) m_editInfo.import("message", "Element type '" + element->GetClassName() + "' is unsupported for SetText."); return false; } - - if (m_doc->IsTranscription() && m_doc->HasFacsimile()) m_doc->SyncFromFacsimileDoc(); - m_editInfo.import("status", success ? status : "FAILURE"); m_editInfo.import("message", success ? message : "SetText method failed."); return success; @@ -1987,50 +1975,10 @@ bool EditorToolkitNeume::SetClef(std::string elementId, std::string shape) pi->AdjustPitchByOffset(shift); } } - m_editInfo.import("status", "OK"); - m_editInfo.import("message", ""); - return true; -} - -bool EditorToolkitNeume::SetLiquescent(std::string elementId, std::string curve) -{ - if (!m_doc->GetDrawingPage()) { - LogError("Could not get the drawing page."); - m_editInfo.import("status", "FAILURE"); - m_editInfo.import("message", "Could not get the drawing page."); - return false; - } - - Nc *nc = vrv_cast(m_doc->GetDrawingPage()->FindDescendantByID(elementId)); - assert(nc); - bool hasLiquscent = nc->GetChildCount(); - - if (curve == "a") { - curvatureDirection_CURVE curve = curvatureDirection_CURVE_a; - nc->SetCurve(curve); - if (!hasLiquscent) { - Liquescent *liquescent = new Liquescent(); - nc->AddChild(liquescent); - } - } - else if (curve == "c") { - curvatureDirection_CURVE curve = curvatureDirection_CURVE_c; - nc->SetCurve(curve); - if (!hasLiquscent) { - Liquescent *liquescent = new Liquescent(); - nc->AddChild(liquescent); - } - } - else { - // For unset curve - curvatureDirection_CURVE curve = curvatureDirection_CURVE_NONE; - nc->SetCurve(curve); - if (hasLiquscent) { - Liquescent *liquescent = vrv_cast(nc->FindDescendantByType(LIQUESCENT)); - nc->DeleteChild(liquescent); - } + if (success && m_doc->GetType() != Facs) { + m_doc->PrepareData(); + m_doc->GetDrawingPage()->LayOut(true); } - m_editInfo.import("status", "OK"); m_editInfo.import("message", ""); return true; @@ -2168,9 +2116,6 @@ bool EditorToolkitNeume::Split(std::string elementId, int x) } } layer->ClearRelinquishedChildren(); - - if (m_doc->IsTranscription() && m_doc->HasFacsimile()) m_doc->SyncFromFacsimileDoc(); - m_editInfo.import("status", "OK"); m_editInfo.import("message", ""); m_editInfo.import("uuid", splitStaff->GetID()); @@ -2205,7 +2150,7 @@ void EditorToolkitNeume::UnlinkSyllable(Syllable *syllable) linkedSyllable->AddChild(syl); // Create default bounding box if facs - if (m_doc->HasFacsimile()) { + if (m_doc->GetType() == Facs) { Zone *zone = new Zone(); zone->SetUlx( @@ -2224,8 +2169,6 @@ void EditorToolkitNeume::UnlinkSyllable(Syllable *syllable) FacsimileInterface *fi = syl->GetFacsimileInterface(); assert(fi); fi->AttachZone(zone); - - if (m_doc->IsTranscription() && m_doc->HasFacsimile()) m_doc->SyncFromFacsimileDoc(); } } } @@ -2437,7 +2380,7 @@ bool EditorToolkitNeume::Resize(std::string elementId, int ulx, int uly, int lrx m_editInfo.import("message", "Could not get the drawing page."); return false; } - if (!m_doc->HasFacsimile()) { + if (m_doc->GetType() != Facs) { LogWarning("Resizing is only available in facsimile mode."); m_editInfo.import("status", "FAILURE"); m_editInfo.import("message", "Resizing is only available in facsimile mode."); @@ -2466,28 +2409,11 @@ bool EditorToolkitNeume::Resize(std::string elementId, int ulx, int uly, int lrx zone->SetUly(uly); zone->SetLrx(lrx); zone->SetLry(lry); - double orgRotate = staff->GetDrawingRotation(); if (!isnan(rotate)) { zone->SetRotate(rotate); } zone->Modify(); - SortStaves(); - - if (staff->HasDrawingRotation()) { - ListOfObjects accids = staff->FindAllDescendantsByType(ACCID); - for (auto it = accids.begin(); it != accids.end(); ++it) { - Accid *accid = dynamic_cast(*it); - FacsimileInterface *fi = accid->GetFacsimileInterface(); - Zone *accidZone = fi->GetZone(); - double rotationOffset = (accid->GetDrawingX() - staff->GetDrawingX()) * tan(rotate * M_PI / 180.0); - if (orgRotate) { - double orgOffset = (accid->GetDrawingX() - staff->GetDrawingX()) * tan(orgRotate * M_PI / 180.0); - rotationOffset -= orgOffset; - } - accidZone->SetUly(accidZone->GetUly() + int(rotationOffset)); - accidZone->SetLry(accidZone->GetLry() + int(rotationOffset)); - } - } + staff->GetParent()->StableSort(StaffSort()); } else if (obj->Is(SYL)) { Syl *syl = vrv_cast(obj); @@ -2529,9 +2455,6 @@ bool EditorToolkitNeume::Resize(std::string elementId, int ulx, int uly, int lrx m_editInfo.import("message", "Element of type '" + obj->GetClassName() + "' is unsupported."); return false; } - - if (m_doc->IsTranscription() && m_doc->HasFacsimile()) m_doc->SyncFromFacsimileDoc(); - m_editInfo.import("status", "OK"); m_editInfo.import("message", ""); return true; @@ -2766,7 +2689,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e parent->AddChild(syl); // add a default bounding box if you need to - if (m_doc->HasFacsimile()) { + if (m_doc->GetType() == Facs) { Zone *zone = new Zone(); zone->SetUlx(parent->GetFirst(NEUME)->GetFirst(NC)->GetFacsimileInterface()->GetZone()->GetUlx()); @@ -2824,7 +2747,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e std::u32string fullString = U""; for (auto it = fullParents.begin(); it != fullParents.end(); ++it) { Syl *syl = dynamic_cast((*it)->FindDescendantByType(SYL)); - if (syl != NULL && m_doc->HasFacsimile()) { + if (syl != NULL && m_doc->GetType() == Facs) { Zone *zone = dynamic_cast(syl->GetFacsimileInterface()->GetZone()); if (fullSyl == NULL) { @@ -2858,7 +2781,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e fullText->SetText(fullString); parent->AddChild(fullSyl); - if (m_doc->HasFacsimile()) { + if (m_doc->GetType() == Facs) { Zone *zone = dynamic_cast(fullSyl->GetFacsimileInterface()->GetZone()); zone->SetUlx(ulx); zone->SetUly(uly); @@ -2897,10 +2820,6 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e + obj->GetChildCount(CLEF))) { Object *leftover; while ((leftover = obj->FindDescendantByType(SYL)) != NULL) { - Zone *zone = dynamic_cast(leftover->GetFacsimileInterface()->GetZone()); - if (zone != NULL) { - m_doc->GetFacsimile()->FindDescendantByType(SURFACE)->DeleteChild(zone); - } obj->DeleteChild(leftover); } while ((leftover = obj->FindDescendantByType(DIVLINE)) != NULL) { @@ -2921,8 +2840,6 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e secondParent->ReorderByXPos(); - if (m_doc->IsTranscription() && m_doc->HasFacsimile()) m_doc->SyncFromFacsimileDoc(); - m_editInfo.import("uuid", parent->GetID()); m_editInfo.import("status", status); m_editInfo.import("message", message); @@ -2956,7 +2873,6 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector ListOfObjects syllables; // List of syllables used. groupType=neume only. jsonxx::Array uuidArray; - bool breakOnEnd = false; // Check if you can get drawing page if (!m_doc->GetDrawingPage()) { @@ -3031,7 +2947,7 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector } } } - while (el->Is(ACCID) || el->Is(DIVLINE) || el->Is(CLEF)) { + if (el->Is(ACCID) || el->Is(DIVLINE) || el->Is(CLEF)) { fparent = el->GetFirstAncestor(SYLLABLE); sparent = el->GetFirstAncestor(LAYER); if (fparent && sparent) { @@ -3041,15 +2957,10 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector fparent->ReorderByXPos(); uuidArray << (*it); it = elementIds.erase(it); - if (it == elementIds.end()) { - breakOnEnd = true; - break; - } + if (it == elementIds.end()) break; el = m_doc->GetDrawingPage()->FindDescendantByID(*it); } } - if (breakOnEnd) break; - if (elementIds.begin() == it || firstIsSyl) { // if the element is a syl we want it to stay attached to the first element // we'll still need to initialize all the parents, thus the bool @@ -3151,7 +3062,7 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector newParent->AddChild(syl); // Create default bounding box if facs - if (m_doc->HasFacsimile()) { + if (m_doc->GetType() == Facs) { Zone *zone = new Zone(); zone->SetUlx(el->GetFirst(NC)->GetFacsimileInterface()->GetZone()->GetUlx()); @@ -3205,8 +3116,6 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector } } - if (m_doc->IsTranscription() && m_doc->HasFacsimile()) m_doc->SyncFromFacsimileDoc(); - m_editInfo.import("status", "OK"); m_editInfo.import("message", ""); m_editInfo.import("uuid", uuidArray); @@ -3374,6 +3283,7 @@ bool EditorToolkitNeume::ChangeGroup(std::string elementId, std::string contour) } zone->SetUlx(newUlx); zone->SetUly(newUly); + ; zone->SetLrx(newLrx); zone->SetLry(newLry); @@ -3391,9 +3301,6 @@ bool EditorToolkitNeume::ChangeGroup(std::string elementId, std::string contour) initialLry = newLry; prevNc = newNc; } - - if (m_doc->IsTranscription() && m_doc->HasFacsimile()) m_doc->SyncFromFacsimileDoc(); - m_editInfo.import("uuid", el->GetID()); m_editInfo.import("status", "OK"); m_editInfo.import("message", ""); @@ -3405,6 +3312,12 @@ bool EditorToolkitNeume::ToggleLigature(std::vector elementIds) assert(elementIds.size() == 2); bool success1 = false; bool success2 = false; + + Facsimile *facsimile = m_doc->GetFacsimile(); + assert(facsimile); + Surface *surface = vrv_cast(facsimile->FindDescendantByType(SURFACE)); + assert(surface); + std::string firstNcId = elementIds[0]; std::string secondNcId = elementIds[1]; // Check if you can get drawing page @@ -3430,66 +3343,77 @@ bool EditorToolkitNeume::ToggleLigature(std::vector elementIds) return false; } - bool isLigature = false; + bool isLigature; if (firstNc->HasAttribute("ligated", "true") && secondNc->HasAttribute("ligated", "true")) { isLigature = true; } else { - Set(firstNcId, "tilt", ""); - Set(secondNcId, "tilt", ""); - Set(firstNcId, "curve", ""); - Set(secondNcId, "curve", ""); + isLigature = false; + Set(firstNc->GetID(), "tilt", ""); + Set(secondNc->GetID(), "tilt", ""); + Set(firstNc->GetID(), "curve", ""); + Set(secondNc->GetID(), "curve", ""); } - Zone *firstNcZone = firstNc->GetZone(); - Zone *secondNcZone = secondNc->GetZone(); + Zone *zone = new Zone(); + // set ligature to false and update zone of second Nc + if (isLigature) { + if (AttModule::SetNeumes(firstNc, "ligated", "false")) success1 = true; - int ligUlx = firstNcZone->GetUlx(); - int ligUly = firstNcZone->GetUly(); - int ligLrx = firstNcZone->GetLrx(); - int ligLry = firstNcZone->GetLry(); + int ligUlx = firstNc->GetZone()->GetUlx(); + int ligUly = firstNc->GetZone()->GetUly(); + int ligLrx = firstNc->GetZone()->GetLrx(); + int ligLry = firstNc->GetZone()->GetLry(); - Staff *staff = dynamic_cast(firstNc->GetFirstAncestor(STAFF)); - assert(staff); - const int noteHeight - = (int)(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) / NOTE_HEIGHT_TO_STAFF_SIZE_RATIO); - const int noteWidth - = (int)(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) / NOTE_WIDTH_TO_STAFF_SIZE_RATIO); + Staff *staff = dynamic_cast(firstNc->GetFirstAncestor(STAFF)); + assert(staff); - // set ligature to false and update zone of second Nc - if (isLigature) { - if (Set(firstNcId, "ligated", "false")) success1 = true; + const int noteHeight + = (int)(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) / NOTE_HEIGHT_TO_STAFF_SIZE_RATIO); + const int noteWidth + = (int)(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) / NOTE_WIDTH_TO_STAFF_SIZE_RATIO); + + zone->SetUlx(ligUlx + noteWidth); + zone->SetUly(ligUly + noteHeight); + zone->SetLrx(ligLrx + noteWidth); + zone->SetLry(ligLry + noteHeight); - secondNcZone->SetUlx(ligUlx + noteWidth); - secondNcZone->SetUly(ligUly + noteHeight); - secondNcZone->SetLrx(ligLrx + noteWidth); - secondNcZone->SetLry(ligLry + noteHeight); + secondNc->AttachZone(zone); - if (Set(secondNcId, "ligated", "false")) success2 = true; + if (AttModule::SetNeumes(secondNc, "ligated", "false")) success2 = true; } // set ligature to true and update zones to be the same - else { - if (Set(firstNcId, "ligated", "true")) success1 = true; + else if (!isLigature) { + if (AttModule::SetNeumes(firstNc, "ligated", "true")) success1 = true; - secondNcZone->SetUlx(ligUlx); - secondNcZone->SetUly(ligUly + noteHeight); - secondNcZone->SetLrx(ligLrx); - secondNcZone->SetLry(ligLry + noteHeight); + zone->SetUlx(firstNc->GetZone()->GetUlx()); + zone->SetUly(firstNc->GetZone()->GetUly()); + zone->SetLrx(firstNc->GetZone()->GetLrx()); + zone->SetLry(firstNc->GetZone()->GetLry()); - if (Set(secondNcId, "ligated", "true")) success2 = true; - } + secondNc->AttachZone(zone); + if (AttModule::SetNeumes(secondNc, "ligated", "true")) success2 = true; + } + // else { + // LogError("isLigature is invalid!"); + // m_editInfo.import("status", "FAILURE"); + // m_editInfo.import("message", "isLigature value '" + isLigature + "' is invalid."); + // return false; + // } + if (success1 && success2 && m_doc->GetType() != Facs) { + m_doc->PrepareData(); + m_doc->GetDrawingPage()->LayOut(true); + } + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); if (!(success1 && success2)) { LogWarning("Unable to update ligature attribute"); m_editInfo.import("message", "Unable to update ligature attribute."); m_editInfo.import("status", "WARNING"); - return false; } - if (m_doc->IsTranscription() && m_doc->HasFacsimile()) m_doc->SyncFromFacsimileDoc(); - - m_editInfo.import("status", "OK"); - m_editInfo.import("message", ""); + surface->AddChild(zone); return success1 && success2; } @@ -3502,7 +3426,7 @@ bool EditorToolkitNeume::ChangeStaff(std::string elementId) return false; } - if (!m_doc->HasFacsimile()) { + if (m_doc->GetType() != Facs) { LogWarning("Staff re-association is only available in facsimile mode."); m_editInfo.import("status", "FAILURE"); m_editInfo.import("message", "Staff re-association is only available in facsimile mode."); @@ -3707,7 +3631,7 @@ bool EditorToolkitNeume::ChangeStaffTo(std::string elementId, std::string staffI return false; } - if (!m_doc->HasFacsimile()) { + if (m_doc->GetType() != Facs) { LogWarning("Staff re-association is only available in facsimile mode."); m_editInfo.import("status", "FAILURE"); m_editInfo.import("message", "Staff re-association is only available in facsimile mode."); @@ -4025,21 +3949,6 @@ bool EditorToolkitNeume::ParseSetClefAction(jsonxx::Object param, std::string *e return true; } -bool EditorToolkitNeume::ParseSetLiquescentAction(jsonxx::Object param, std::string *elementId, std::string *curve) -{ - if (!param.has("elementId")) { - LogWarning("Could not parse 'elementId'"); - return false; - } - *elementId = param.get("elementId"); - if (!param.has("curve")) { - LogWarning("Could not parse 'curve'"); - return false; - } - *curve = param.get("curve"); - return true; -} - bool EditorToolkitNeume::ParseRemoveAction(jsonxx::Object param, std::string *elementId) { if (!param.has("elementId")) return false; @@ -4219,12 +4128,15 @@ bool EditorToolkitNeume::AdjustPitchFromPosition(Object *obj, Clef *clef) const int staffSize = m_doc->GetDrawingUnit(staff->m_drawingStaffSize); - const int pitchDifference = round( - (staff->GetDrawingY() - staff->GetDrawingRotationOffsetFor(m_view->ToLogicalX(fi->GetZone()->GetUlx())) - - m_view->ToLogicalY(fi->GetZone()->GetUly())) - / staffSize - - (((staff->m_drawingLines - 1) * 2) - clef->GetClefLocOffset())); - pi->AdjustPitchByOffset(-pitchDifference); + // Use the same pitchDifference equation for both syllables and custos + const int pitchDifference + = round((double)(staff->GetDrawingY() + (2 * staffSize * (staff->m_drawingLines - clef->GetLine())) + - fi->GetZone()->GetUly() + - ((fi->GetZone()->GetUlx() - staff->GetZone()->GetUlx()) + * tan(-staff->GetDrawingRotate() * M_PI / 180.0))) + / (double)(staffSize)); + + pi->AdjustPitchByOffset(pitchDifference); return true; } @@ -4266,8 +4178,6 @@ bool EditorToolkitNeume::AdjustPitchFromPosition(Object *obj, Clef *clef) const int staffSize = m_doc->GetDrawingUnit(staff->m_drawingStaffSize); for (auto it = pitchedChildren.begin(); it != pitchedChildren.end(); ++it) { - if ((*it)->Is(LIQUESCENT)) continue; - FacsimileInterface *fi = (*it)->GetFacsimileInterface(); if (fi == NULL || !fi->HasFacs()) { LogError("Could not adjust pitch: child %s does not have facsimile data", (*it)->GetID().c_str()); @@ -4286,12 +4196,15 @@ bool EditorToolkitNeume::AdjustPitchFromPosition(Object *obj, Clef *clef) } pi->SetOct(octave); - const int pitchDifference = round( - (staff->GetDrawingY() - staff->GetDrawingRotationOffsetFor(m_view->ToLogicalX(fi->GetZone()->GetUlx())) - - m_view->ToLogicalY(fi->GetZone()->GetUly())) - / staffSize - - (((staff->m_drawingLines - 1) * 2) - clef->GetClefLocOffset())); - pi->AdjustPitchByOffset(-pitchDifference); + // Use the same pitchDifference equation for both syllables and custos + const int pitchDifference + = round((double)(staff->GetDrawingY() + (2 * staffSize * (staff->m_drawingLines - clef->GetLine())) + - fi->GetZone()->GetUly() + - ((fi->GetZone()->GetUlx() - staff->GetZone()->GetUlx()) + * tan(-staff->GetDrawingRotate() * M_PI / 180.0))) + / (double)(staffSize)); + + pi->AdjustPitchByOffset(pitchDifference); } return true; diff --git a/src/facsimilefunctor.cpp b/src/facsimilefunctor.cpp index f70d6804d9c..73ec1ef23ca 100644 --- a/src/facsimilefunctor.cpp +++ b/src/facsimilefunctor.cpp @@ -12,7 +12,6 @@ #include "doc.h" #include "layerelement.h" #include "measure.h" -#include "miscfunctor.h" #include "page.h" #include "pb.h" #include "sb.h" @@ -40,80 +39,42 @@ SyncFromFacsimileFunctor::SyncFromFacsimileFunctor(Doc *doc) : Functor() FunctorCode SyncFromFacsimileFunctor::VisitLayerElement(LayerElement *layerElement) { - if (!layerElement->Is({ ACCID, CLEF, CUSTOS, DIVLINE, LIQUESCENT, NC, NOTE, REST, SYL })) return FUNCTOR_CONTINUE; + if (!layerElement->Is({ NOTE, REST })) return FUNCTOR_CONTINUE; Zone *zone = layerElement->GetZone(); assert(zone); layerElement->m_drawingFacsX = m_view.ToLogicalX(zone->GetUlx() * DEFINITION_FACTOR); - if (layerElement->Is({ ACCID, SYL })) { - layerElement->m_drawingFacsY = m_view.ToLogicalY(zone->GetUly() * DEFINITION_FACTOR); - } return FUNCTOR_CONTINUE; } FunctorCode SyncFromFacsimileFunctor::VisitMeasure(Measure *measure) { - // neon specific code - measure have no zone, we will use the staff one in VisitStaff - if (measure->IsNeumeLine()) { - m_currentNeumeLine = measure; - } - else { - Zone *zone = measure->GetZone(); - assert(zone); - measure->m_drawingFacsX1 = m_view.ToLogicalX(zone->GetUlx() * DEFINITION_FACTOR); - measure->m_drawingFacsX2 = m_view.ToLogicalX(zone->GetLrx() * DEFINITION_FACTOR); - } + Zone *zone = measure->GetZone(); + assert(zone); + measure->m_drawingFacsX1 = m_view.ToLogicalX(zone->GetUlx() * DEFINITION_FACTOR); + measure->m_drawingFacsX2 = m_view.ToLogicalX(zone->GetLrx() * DEFINITION_FACTOR); return FUNCTOR_CONTINUE; } FunctorCode SyncFromFacsimileFunctor::VisitPage(Page *page) { - m_staffZones.clear(); m_currentPage = page; m_doc->SetDrawingPage(m_currentPage->GetIdx()); return FUNCTOR_CONTINUE; } -FunctorCode SyncFromFacsimileFunctor::VisitPageEnd(Page *page) -{ - // Used for adjusting staff size in neon - filled in VisitStaff - if (m_staffZones.empty()) return FUNCTOR_CONTINUE; - - // The staff size is calculated based on the zone height and takes into acocunt the rotation - for (auto &[staff, zone] : m_staffZones) { - double rotate = (zone->HasRotate()) ? zone->GetRotate() : 0.0; - int yDiff - = zone->GetLry() - zone->GetUly() - (zone->GetLrx() - zone->GetUlx()) * tan(abs(rotate) * M_PI / 180.0); - staff->m_drawingStaffSize - = 100 * yDiff / (m_doc->GetOptions()->m_unit.GetValue() * 2 * (staff->m_drawingLines - 1)); - staff->SetDrawingRotation(rotate); - } - - // Since we multiply all values by the DEFINITION_FACTOR, set it as PPU - m_currentPage->SetPPUFactor(DEFINITION_FACTOR); - if (m_currentPage->GetPPUFactor() != 1.0) { - ApplyPPUFactorFunctor applyPPUFactor; - m_currentPage->Process(applyPPUFactor); - m_doc->UpdatePageDrawingSizes(); - } - - 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(); - Surface *surface = pb->GetSurface(); - if (!surface && zone && zone->GetParent()) - surface = (zone->GetParent()->Is(SURFACE)) ? vrv_cast(zone->GetParent()) : NULL; - assert(zone || surface); - // Use the (parent) surface attributes if given + 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; @@ -148,27 +109,12 @@ FunctorCode SyncFromFacsimileFunctor::VisitStaff(Staff *staff) assert(zone); staff->m_drawingFacsY = m_view.ToLogicalY(zone->GetUly() * DEFINITION_FACTOR); - // neon specific code - set the position of the pseudo measure (neume line) - if (m_currentNeumeLine) { - m_currentNeumeLine->m_drawingFacsX1 = m_view.ToLogicalX(zone->GetUlx() * DEFINITION_FACTOR); - m_currentNeumeLine->m_drawingFacsX2 = m_view.ToLogicalX(zone->GetLrx() * DEFINITION_FACTOR); - m_staffZones[staff] = zone; - - // The staff slope is going up. The y left position needs to be adjusted accordingly - if (zone->GetRotate() < 0) { - staff->m_drawingFacsY = staff->m_drawingFacsY - + (m_currentNeumeLine->m_drawingFacsX2 - m_currentNeumeLine->m_drawingFacsX1) - * tan(zone->GetRotate() * M_PI / 180.0); - } - } - return FUNCTOR_CONTINUE; } FunctorCode SyncFromFacsimileFunctor::VisitSystem(System *system) { m_currentSystem = system; - m_currentNeumeLine = NULL; return FUNCTOR_CONTINUE; } @@ -190,13 +136,10 @@ SyncToFacsimileFunctor::SyncToFacsimileFunctor(Doc *doc) : Functor() FunctorCode SyncToFacsimileFunctor::VisitLayerElement(LayerElement *layerElement) { - if (!layerElement->Is({ ACCID, CLEF, CUSTOS, DIVLINE, LIQUESCENT, NC, NOTE, REST, SYL })) return FUNCTOR_CONTINUE; + if (!layerElement->Is({ NOTE, REST })) return FUNCTOR_CONTINUE; Zone *zone = this->GetZone(layerElement, layerElement->GetClassName()); zone->SetUlx(m_view.ToDeviceContextX(layerElement->GetDrawingX()) / DEFINITION_FACTOR + m_pageMarginLeft); - if (layerElement->Is({ ACCID, SYL })) { - zone->SetUly(m_view.ToDeviceContextY(layerElement->GetDrawingY()) / DEFINITION_FACTOR + m_pageMarginTop); - } return FUNCTOR_CONTINUE; } diff --git a/src/iodarms.cpp b/src/iodarms.cpp index 0f31bb84223..debf3f3181a 100644 --- a/src/iodarms.cpp +++ b/src/iodarms.cpp @@ -473,7 +473,7 @@ bool DarmsInput::Import(const std::string &data_str) score->AddChild(section); m_staff = new Staff(1); - m_measure = new Measure(MEASURED, 1); + m_measure = new Measure(true, 1); m_layer = new Layer(); m_layer->SetN(1); diff --git a/src/iohumdrum.cpp b/src/iohumdrum.cpp index 5e7423a1e7b..4353e83816a 100644 --- a/src/iohumdrum.cpp +++ b/src/iohumdrum.cpp @@ -29294,7 +29294,7 @@ void HumdrumInput::setupSystemMeasure(int startline, int endline) } if (hasMensuralStaff(&infile[startline])) { - m_measure = new Measure(UNMEASURED); + m_measure = new Measure(false); } else { m_measure = new Measure(); diff --git a/src/iomei.cpp b/src/iomei.cpp index 5d1e8ae1200..aa139f99077 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -445,14 +445,7 @@ bool MEIOutput::WriteObjectInternal(Object *object, bool useCustomScoreDef) this->WriteSymbolTable(m_currentNode, vrv_cast(object)); } else if (object->Is(MEASURE)) { - Measure *measure = vrv_cast(object); - assert(measure); - std::string name = "measure"; - if (measure->IsNeumeLine()) { - name = "section"; - measure->SetType(NEUME_LINE_TYPE); - } - m_currentNode = m_currentNode.append_child(name.c_str()); + m_currentNode = m_currentNode.append_child("measure"); this->WriteMeasure(m_currentNode, vrv_cast(object)); } else if (object->Is(STAFF)) { @@ -1901,7 +1894,7 @@ 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_drawingFacsX1 != VRV_UNSET) && (measure->m_drawingFacsX2 != VRV_UNSET) && !m_doc->IsNeumeLines()) { + 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); @@ -2233,7 +2226,7 @@ void MEIOutput::WriteStaff(pugi::xml_node currentNode, Staff *staff) staff->WriteVisibility(currentNode); // y position - if (staff->m_drawingFacsY != VRV_UNSET && !(m_doc->IsNeumeLines())) { + if (staff->m_drawingFacsY != VRV_UNSET) { staff->SetCoordY1(staff->m_drawingFacsY / DEFINITION_FACTOR); staff->WriteCoordY1(currentNode); } @@ -2313,7 +2306,7 @@ void MEIOutput::WriteLayerElement(pugi::xml_node currentNode, LayerElement *elem this->WriteLinkingInterface(currentNode, element); element->WriteLabelled(currentNode); element->WriteTyped(currentNode); - if (element->m_drawingFacsX != VRV_UNSET && !(m_doc->IsNeumeLines())) { + if (element->m_drawingFacsX != VRV_UNSET) { element->SetCoordX1(element->m_drawingFacsX / DEFINITION_FACTOR); element->WriteCoordX1(currentNode); } @@ -2710,7 +2703,6 @@ void MEIOutput::WriteNc(pugi::xml_node currentNode, Nc *nc) this->WritePitchInterface(currentNode, nc); this->WritePositionInterface(currentNode, nc); nc->WriteColor(currentNode); - nc->WriteCurvatureDirection(currentNode); nc->WriteIntervalMelodic(currentNode); nc->WriteNcForm(currentNode); } @@ -4402,13 +4394,7 @@ bool MEIInput::ReadScore(Object *parent, pugi::xml_node score) bool MEIInput::ReadSection(Object *parent, pugi::xml_node section) { Section *vrvSection = new Section(); - this->ReadSystemElement(section, vrvSection); - - if (vrvSection->GetType() == NEUME_LINE_TYPE) { - delete vrvSection; - m_doc->SetNeumeLines(true); - return ReadSectionChildren(parent, section); - } + this->SetMeiID(section, vrvSection); vrvSection->ReadNNumberLike(section); vrvSection->ReadSectionVis(section); @@ -4468,13 +4454,8 @@ bool MEIInput::ReadSectionChildren(Object *parent, pugi::xml_node parentNode) else if (std::string(current.name()) == "staff") { if (!unmeasured) { if (parent->Is(SECTION)) { - if (m_doc->IsNeumeLines()) { - unmeasured = new Measure(NEUMELINE); - } - else { - unmeasured = new Measure(UNMEASURED); - m_doc->SetMensuralMusicOnly(true); - } + unmeasured = new Measure(false); + m_doc->SetMensuralMusicOnly(true); parent->AddChild(unmeasured); } else { @@ -4502,15 +4483,9 @@ bool MEIInput::ReadSectionChildren(Object *parent, pugi::xml_node parentNode) } // New for blank files in neume notation - if (!unmeasured && parent->Is(SECTION) && (m_doc->m_notationType == NOTATIONTYPE_neume) - && !parent->FindDescendantByType(MEASURE)) { - if (m_doc->IsNeumeLines()) { - unmeasured = new Measure(NEUMELINE); - } - else { - unmeasured = new Measure(UNMEASURED); - m_doc->SetMensuralMusicOnly(true); - } + if (!unmeasured && parent->Is(SECTION) && (m_doc->m_notationType == NOTATIONTYPE_neume)) { + unmeasured = new Measure(false); + m_doc->SetMensuralMusicOnly(true); parent->AddChild(unmeasured); } return success; @@ -4653,7 +4628,7 @@ bool MEIInput::ReadSystemChildren(Object *parent, pugi::xml_node parentNode) if (parent->Is(SYSTEM)) { System *system = vrv_cast(parent); assert(system); - unmeasured = new Measure(UNMEASURED); + unmeasured = new Measure(false); m_doc->SetMensuralMusicOnly(true); if (m_doc->IsTranscription() && (m_meiversion == meiVersion_MEIVERSION_2013)) { UpgradeMeasureTo_3_0_0(unmeasured, system); @@ -6834,7 +6809,6 @@ bool MEIInput::ReadNc(Object *parent, pugi::xml_node nc) this->ReadPitchInterface(nc, vrvNc); this->ReadPositionInterface(nc, vrvNc); vrvNc->ReadColor(nc); - vrvNc->ReadCurvatureDirection(nc); vrvNc->ReadIntervalMelodic(nc); vrvNc->ReadNcForm(nc); @@ -8209,14 +8183,12 @@ void MEIInput::UpgradePageTo_5_0(Page *page) PageMilestoneEnd *scoreEnd = new PageMilestoneEnd(score); page->AddChild(scoreEnd); - score->SetEnd(scoreEnd); Mdiv *mdiv = new Mdiv(); page->InsertChild(mdiv, 0); PageMilestoneEnd *mdivEnd = new PageMilestoneEnd(mdiv); page->AddChild(mdivEnd); - mdiv->SetEnd(mdivEnd); } void MEIInput::UpgradePgHeadFootTo_5_0(pugi::xml_node element) diff --git a/src/iomusxml.cpp b/src/iomusxml.cpp index a7bb45ee05c..001017a6f9d 100644 --- a/src/iomusxml.cpp +++ b/src/iomusxml.cpp @@ -1835,6 +1835,9 @@ void MusicXmlInput::ReadMusicXmlAttributes( section->AddChild(scoreDef); } + else if (time && node.select_node("ancestor::part[(preceding-sibling::part)]")) { + m_meterUnit = time.child("beat-type").text().as_int(); + } pugi::xpath_node measureRepeat = node.select_node("measure-style/measure-repeat"); pugi::xpath_node measureSlash = node.select_node("measure-style/slash"); diff --git a/src/iopae.cpp b/src/iopae.cpp index 005f1ce0d3d..1e844d31a06 100644 --- a/src/iopae.cpp +++ b/src/iopae.cpp @@ -2884,7 +2884,7 @@ bool PAEInput::Import(const std::string &input) } // Add a measure at the beginning of the data because there is always at least one measure - Measure *measure = new Measure(MEASURED, 1); + Measure *measure = new Measure(true, 1); // By default there is no end barline on an incipit measure->SetRight(BARRENDITION_invis); m_pae.push_back(pae::Token(0, pae::UNKOWN_POS, measure)); @@ -3403,7 +3403,7 @@ bool PAEInput::ConvertMeasure() // We can now create a new measure but not if we have reached the end of the data if (!token.IsEnd()) { measureCount++; - currentMeasure = new Measure(MEASURED, measureCount); + currentMeasure = new Measure(true, measureCount); currentMeasure->SetRight(BARRENDITION_invis); measureToken->m_object = currentMeasure; } diff --git a/src/layerelement.cpp b/src/layerelement.cpp index 25dd5d9ad77..459d4c505df 100644 --- a/src/layerelement.cpp +++ b/src/layerelement.cpp @@ -129,7 +129,6 @@ void LayerElement::Reset() m_drawingFacsX = VRV_UNSET; m_drawingYRel = 0; - m_drawingFacsY = VRV_UNSET; m_drawingXRel = 0; m_drawingCueSize = false; @@ -397,6 +396,14 @@ void LayerElement::SetGraceAlignment(Alignment *graceAlignment) int LayerElement::GetDrawingX() const { + // If this element has a facsimile and we are in facsimile mode, use Facsimile::GetDrawingX + if (this->HasFacs()) { + const Doc *doc = vrv_cast(this->GetFirstAncestor(DOC)); + assert(doc); + if (doc->IsFacs()) { + return FacsimileInterface::GetDrawingX(); + } + } // Since m_drawingFacsX is the left position, we adjust the XRel accordingly in AdjustXRelForTranscription if (m_drawingFacsX != VRV_UNSET) return m_drawingFacsX + this->GetDrawingXRel(); @@ -437,8 +444,14 @@ int LayerElement::GetDrawingX() const int LayerElement::GetDrawingY() const { - - if (m_drawingFacsY != VRV_UNSET) return m_drawingFacsY + this->GetDrawingYRel(); + // If this element has a facsimile and we are in facsimile mode, use Facsimile::GetDrawingY + if (this->HasFacs()) { + const Doc *doc = vrv_cast(this->GetFirstAncestor(DOC)); + assert(doc); + if (doc->IsFacs()) { + return FacsimileInterface::GetDrawingY(); + } + } if (m_cachedDrawingY != VRV_UNSET) return m_cachedDrawingY; diff --git a/src/measure.cpp b/src/measure.cpp index d5e48b679f7..322b01ea635 100644 --- a/src/measure.cpp +++ b/src/measure.cpp @@ -54,7 +54,7 @@ namespace vrv { static const ClassRegistrar s_factory("measure", MEASURE); -Measure::Measure(MeasureType measureMusic, int logMeasureNb) +Measure::Measure(bool measureMusic, int logMeasureNb) : Object(MEASURE, "measure-") , FacsimileInterface() , AttBarring() @@ -76,7 +76,7 @@ Measure::Measure(MeasureType measureMusic, int logMeasureNb) this->RegisterAttClass(ATT_TYPED); this->RegisterInterface(FacsimileInterface::GetAttClasses(), FacsimileInterface::IsInterface()); - m_measureType = measureMusic; + m_measuredMusic = measureMusic; // We set parent to it because we want to access the parent doc from the aligners m_measureAligner.SetParent(this); @@ -95,7 +95,7 @@ Measure::Measure(MeasureType measureMusic, int logMeasureNb) this->Reset(); - if (!measureMusic) this->SetRight(BARRENDITION_invis); + if (!this->IsMeasuredMusic()) this->SetRight(BARRENDITION_invis); } Measure::~Measure() @@ -149,10 +149,8 @@ void Measure::Reset() m_rightBarLine.SetForm(this->GetRight()); m_leftBarLine.SetForm(this->GetLeft()); - if (!m_measureType) { - m_drawingFacsX1 = VRV_UNSET; - m_drawingFacsX2 = VRV_UNSET; - } + m_drawingFacsX1 = VRV_UNSET; + m_drawingFacsX2 = VRV_UNSET; m_drawingEnding = NULL; m_hasAlignmentRefWithMultipleLayers = false; @@ -213,6 +211,14 @@ void Measure::AddChildBack(Object *child) int Measure::GetDrawingX() const { + if (!this->IsMeasuredMusic()) { + const System *system = vrv_cast(this->GetFirstAncestor(SYSTEM)); + assert(system); + if (system->m_drawingFacsY != VRV_UNSET) { + return (system->m_systemLeftMar); + } + } + if (m_drawingFacsX1 != VRV_UNSET) return m_drawingFacsX1; if (m_cachedDrawingX != VRV_UNSET) return m_cachedDrawingX; @@ -345,6 +351,17 @@ int Measure::GetRightBarLineRight() const int Measure::GetWidth() const { + if (!this->IsMeasuredMusic()) { + const System *system = vrv_cast(this->GetFirstAncestor(SYSTEM)); + assert(system); + if (system->m_drawingFacsY != VRV_UNSET) { + const Page *page = vrv_cast(system->GetFirstAncestor(PAGE)); + assert(page); + // xAbs2 = page->m_pageWidth - system->m_systemRightMar; + return page->m_pageWidth - system->m_systemLeftMar - system->m_systemRightMar; + } + } + if (m_drawingFacsX2 != VRV_UNSET) return (m_drawingFacsX2 - m_drawingFacsX1); assert(m_measureAligner.GetRightAlignment()); diff --git a/src/miscfunctor.cpp b/src/miscfunctor.cpp index f10936c906e..9c3677a2823 100644 --- a/src/miscfunctor.cpp +++ b/src/miscfunctor.cpp @@ -33,7 +33,6 @@ FunctorCode ApplyPPUFactorFunctor::VisitLayerElement(LayerElement *layerElement) if (layerElement->IsScoreDefElement()) return FUNCTOR_SIBLINGS; if (layerElement->m_drawingFacsX != VRV_UNSET) layerElement->m_drawingFacsX /= m_page->GetPPUFactor(); - if (layerElement->m_drawingFacsY != VRV_UNSET) layerElement->m_drawingFacsY /= m_page->GetPPUFactor(); return FUNCTOR_CONTINUE; } diff --git a/src/page.cpp b/src/page.cpp index 614b64180bc..11264de6c5a 100644 --- a/src/page.cpp +++ b/src/page.cpp @@ -33,7 +33,6 @@ #include "adjustxposfunctor.h" #include "adjustxrelfortranscriptionfunctor.h" #include "adjustyposfunctor.h" -#include "adjustyrelfortranscriptionfunctor.h" #include "alignfunctor.h" #include "bboxdevicecontext.h" #include "cachehorizontallayoutfunctor.h" @@ -271,8 +270,6 @@ void Page::LayOutTranscription(bool force) AdjustXRelForTranscriptionFunctor adjustXRelForTranscription; this->Process(adjustXRelForTranscription); - AdjustYRelForTranscriptionFunctor adjustYRelForTranscription; - this->Process(adjustYRelForTranscription); CalcLedgerLinesFunctor calcLedgerLines(doc); this->Process(calcLedgerLines); @@ -336,10 +333,8 @@ void Page::ResetAligners() CalcAlignmentPitchPosFunctor calcAlignmentPitchPos(doc); this->Process(calcAlignmentPitchPos); - if (IsMensuralType(doc->m_notationType)) { - CalcLigatureNotePosFunctor calcLigatureNotePos(doc); - this->Process(calcLigatureNotePos); - } + CalcLigatureNotePosFunctor calcLigatureNotePos(doc); + this->Process(calcLigatureNotePos); CalcStemFunctor calcStem(doc); this->Process(calcStem); diff --git a/src/preparedatafunctor.cpp b/src/preparedatafunctor.cpp index 2d9226da362..fd69f35d01c 100644 --- a/src/preparedatafunctor.cpp +++ b/src/preparedatafunctor.cpp @@ -1161,17 +1161,6 @@ FunctorCode PrepareLayerElementPartsFunctor::VisitNote(Note *note) } } - // We don't care about flags or dots in mensural notes - if (note->IsMensuralDur()) return FUNCTOR_CONTINUE; - - if (currentStem) { - const bool shouldHaveFlag = ((note->GetActualDur() > DUR_4) && !note->IsInBeam() && !note->GetAncestorFTrem() - && !note->IsChordTone() && !note->IsTabGrpNote()); - currentFlag = this->ProcessFlag(currentFlag, currentStem, shouldHaveFlag); - - if (!chord) note->SetDrawingStem(currentStem); - } - /************ dots ***********/ Dots *currentDots = vrv_cast(note->FindDescendantByType(DOTS, 1)); @@ -1182,6 +1171,17 @@ FunctorCode PrepareLayerElementPartsFunctor::VisitNote(Note *note) } currentDots = this->ProcessDots(currentDots, note, shouldHaveDots); + // We don't care about flags in mensural notes + if (note->IsMensuralDur()) return FUNCTOR_CONTINUE; + + if (currentStem) { + const bool shouldHaveFlag = ((note->GetActualDur() > DUR_4) && !note->IsInBeam() && !note->GetAncestorFTrem() + && !note->IsChordTone() && !note->IsTabGrpNote()); + currentFlag = this->ProcessFlag(currentFlag, currentStem, shouldHaveFlag); + + if (!chord) note->SetDrawingStem(currentStem); + } + /************ Prepare the drawing cue size ************/ PrepareCueSizeFunctor prepareCueSize; diff --git a/src/savefunctor.cpp b/src/savefunctor.cpp index 082b9d9259a..74172c5112e 100644 --- a/src/savefunctor.cpp +++ b/src/savefunctor.cpp @@ -96,12 +96,12 @@ FunctorCode SaveFunctor::VisitMdivEnd(Mdiv *mdiv) FunctorCode SaveFunctor::VisitMeasure(Measure *measure) { - return (measure->IsMeasuredMusic() || measure->IsNeumeLine()) ? this->VisitObject(measure) : FUNCTOR_CONTINUE; + return (measure->IsMeasuredMusic()) ? this->VisitObject(measure) : FUNCTOR_CONTINUE; } FunctorCode SaveFunctor::VisitMeasureEnd(Measure *measure) { - return (measure->IsMeasuredMusic() || measure->IsNeumeLine()) ? this->VisitObjectEnd(measure) : FUNCTOR_CONTINUE; + return (measure->IsMeasuredMusic()) ? this->VisitObjectEnd(measure) : FUNCTOR_CONTINUE; } FunctorCode SaveFunctor::VisitMNum(MNum *mNum) diff --git a/src/staff.cpp b/src/staff.cpp index 9360300b579..12299d1ae39 100644 --- a/src/staff.cpp +++ b/src/staff.cpp @@ -75,7 +75,6 @@ void Staff::Reset() m_timeSpanningElements.clear(); m_drawingStaffDef = NULL; m_drawingTuning = NULL; - m_drawingRotation = 0.0; ClearLedgerLines(); } @@ -91,13 +90,6 @@ void Staff::CloneReset() m_timeSpanningElements.clear(); m_drawingStaffDef = NULL; m_drawingTuning = NULL; - m_drawingRotation = 0.0; -} - -int Staff::GetDrawingRotationOffsetFor(int x) -{ - int xDiff = x - this->GetDrawingX(); - return int(xDiff * tan(this->GetDrawingRotation() * M_PI / 180.0)); } void Staff::ClearLedgerLines() @@ -142,6 +134,13 @@ int Staff::GetDrawingX() const int Staff::GetDrawingY() const { + if (this->HasFacs()) { + const Doc *doc = vrv_cast(this->GetFirstAncestor(DOC)); + assert(DOC); + if (doc->IsFacs()) { + return FacsimileInterface::GetDrawingY(); + } + } if (m_drawingFacsY != VRV_UNSET) return m_drawingFacsY; @@ -173,7 +172,7 @@ void Staff::AdjustDrawingStaffSize() if (this->HasFacs()) { Doc *doc = vrv_cast(this->GetFirstAncestor(DOC)); assert(doc); - if (doc->IsFacs() || doc->IsNeumeLines()) { + if (doc->IsFacs()) { double rotate = this->GetDrawingRotate(); Zone *zone = this->GetZone(); assert(zone); diff --git a/src/svgdevicecontext.cpp b/src/svgdevicecontext.cpp index 1cec345599f..1769f1f138d 100644 --- a/src/svgdevicecontext.cpp +++ b/src/svgdevicecontext.cpp @@ -496,8 +496,8 @@ void SvgDeviceContext::StartPage() = StringFormat("0 0 %d %d", this->GetWidth(), this->GetHeight()).c_str(); } else { - m_currentNode.append_attribute("viewBox") = StringFormat("0 0 %d %d", - int(this->GetWidth() * this->GetViewBoxFactor()), int(this->GetContentHeight() * this->GetViewBoxFactor())) + m_currentNode.append_attribute("viewBox") = StringFormat( + "0 0 %d %d", this->GetWidth() * DEFINITION_FACTOR, this->GetContentHeight() * DEFINITION_FACTOR) .c_str(); } diff --git a/src/toolkit.cpp b/src/toolkit.cpp index d79ed929038..2ae7b97c19b 100644 --- a/src/toolkit.cpp +++ b/src/toolkit.cpp @@ -1525,7 +1525,7 @@ bool Toolkit::RenderToDeviceContext(int pageNo, DeviceContext *deviceContext) std::swap(height, width); } - double userScale = m_options->m_scale.GetValue() / 100.0; + double userScale = m_view.GetPPUFactor() * m_options->m_scale.GetValue() / 100; assert(userScale != 0.0); if (m_options->m_scaleToPageSize.GetValue()) { @@ -1537,7 +1537,6 @@ bool Toolkit::RenderToDeviceContext(int pageNo, DeviceContext *deviceContext) deviceContext->SetUserScale(userScale, userScale); deviceContext->SetWidth(width); deviceContext->SetHeight(height); - deviceContext->SetViewBoxFactor(m_view.GetPPUFactor()); if (m_doc.IsFacs()) { deviceContext->SetWidth(m_doc.GetFacsimile()->GetMaxX()); diff --git a/src/view_element.cpp b/src/view_element.cpp index a2bba2eefea..0525ffcdff4 100644 --- a/src/view_element.cpp +++ b/src/view_element.cpp @@ -113,7 +113,7 @@ void View::DrawLayerElement(DeviceContext *dc, LayerElement *element, Layer *lay this->DrawCustos(dc, element, layer, staff, measure); } else if (element->Is(DIVLINE)) { - this->DrawDivLine(dc, element, layer, staff, measure); + DrawDivLine(dc, element, layer, staff, measure); } else if (element->Is(DOT)) { this->DrawDot(dc, element, layer, staff, measure); @@ -139,9 +139,6 @@ void View::DrawLayerElement(DeviceContext *dc, LayerElement *element, Layer *lay else if (element->Is(LIGATURE)) { this->DrawLigature(dc, element, layer, staff, measure); } - else if (element->Is(LIQUESCENT)) { - this->DrawLiquescent(dc, element, layer, staff, measure); - } else if (element->Is(MENSUR)) { this->DrawMensur(dc, element, layer, staff, measure); } @@ -302,6 +299,19 @@ void View::DrawAccid(DeviceContext *dc, LayerElement *element, Layer *layer, Sta y = (accid->GetPlace() == STAFFREL_below) ? y - extend.m_ascent - unit : y + extend.m_descent + unit; } + if (notationType == NOTATIONTYPE_neume) { + int rotateOffset = 0; + if (m_doc->IsFacs() && (staff->GetDrawingRotate() != 0)) { + double deg = staff->GetDrawingRotate(); + int xDiff = x - staff->GetDrawingX(); + rotateOffset = int(xDiff * tan(deg * M_PI / 180.0)); + } + if (accid->HasFacs() && m_doc->IsFacs()) { + y = ToLogicalY(y); + } + y -= rotateOffset; + } + this->DrawSmuflString( dc, x, y, accidStr, HORIZONTALALIGNMENT_center, staff->m_drawingStaffSize, accid->GetDrawingCueSize(), true); @@ -643,8 +653,14 @@ void View::DrawClef(DeviceContext *dc, LayerElement *element, Layer *layer, Staf } int x, y; - y = staff->GetDrawingY(); - x = element->GetDrawingX(); + if (m_doc->IsFacs() && clef->HasFacs()) { + y = ToLogicalY(staff->GetDrawingY()); + x = clef->GetDrawingX(); + } + else { + y = staff->GetDrawingY(); + x = element->GetDrawingX(); + } char32_t sym = clef->GetClefGlyph(staff->m_drawingNotationType); @@ -655,8 +671,10 @@ void View::DrawClef(DeviceContext *dc, LayerElement *element, Layer *layer, Staf if (clef->HasLine()) { y -= m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) * (staff->m_drawingLines - clef->GetLine()); - if (staff->HasDrawingRotation()) { - y -= staff->GetDrawingRotationOffsetFor(x); + if (m_doc->IsFacs() && (staff->GetDrawingRotate() != 0)) { + double deg = staff->GetDrawingRotate(); + int xDiff = x - staff->GetDrawingX(); + y -= int(xDiff * tan(deg * M_PI / 180.0)); } } else if (clef->GetShape() == CLEFSHAPE_perc) { @@ -678,6 +696,19 @@ void View::DrawClef(DeviceContext *dc, LayerElement *element, Layer *layer, Staf this->DrawSmuflCode(dc, x, y, sym, staff->m_drawingStaffSize, false); + if (m_doc->IsFacs() && element->HasFacs()) { + const int noteHeight + = (int)(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) / NOTE_HEIGHT_TO_STAFF_SIZE_RATIO); + const int noteWidth + = (int)(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) / NOTE_WIDTH_TO_STAFF_SIZE_RATIO); + + FacsimileInterface *fi = element->GetFacsimileInterface(); + fi->GetZone()->SetUlx(x); + fi->GetZone()->SetUly(ToDeviceContextY(y)); + fi->GetZone()->SetLrx(x + noteWidth); + fi->GetZone()->SetLry(ToDeviceContextY(y - noteHeight)); + } + // Possibly draw enclosing brackets this->DrawClefEnclosing(dc, clef, staff, sym, x, y); @@ -729,18 +760,17 @@ void View::DrawCustos(DeviceContext *dc, LayerElement *element, Layer *layer, St const int sym = custos->GetCustosGlyph(staff->m_drawingNotationType); int x, y; - // For neume notation we ignore the value set in CalcAlignmentPitchPosFunctor - if (staff->m_drawingNotationType == NOTATIONTYPE_neume) { + if (custos->HasFacs() && m_doc->IsFacs()) { x = custos->GetDrawingX(); // Recalculate y from pitch to prevent visual/meaning mismatch Clef *clef = layer->GetClef(element); - y = staff->GetDrawingY(); + y = ToLogicalY(staff->GetDrawingY()); PitchInterface pi; // Neume notation uses C3 for C clef rather than C4. // Take this into account when determining location. // However this doesn't affect the value for F clef. pi.SetPname(PITCHNAME_c); - if (clef->GetShape() == CLEFSHAPE_C) { + if ((staff->m_drawingNotationType == NOTATIONTYPE_neume) && (clef->GetShape() == CLEFSHAPE_C)) { pi.SetOct(3); } else { @@ -759,15 +789,25 @@ void View::DrawCustos(DeviceContext *dc, LayerElement *element, Layer *layer, St y -= m_doc->GetDrawingUnit(staff->m_drawingStaffSize); } - if (staff->HasDrawingRotation()) { - y -= staff->GetDrawingRotationOffsetFor(x); - } - else if (staff->HasDrawingRotation()) { - y -= staff->GetDrawingRotationOffsetFor(x); + if (m_doc->IsFacs() && (staff->GetDrawingRotate() != 0)) { + double deg = staff->GetDrawingRotate(); + int xDiff = x - staff->GetDrawingX(); + y -= int(xDiff * tan(deg * M_PI / 180.0)); } this->DrawSmuflCode(dc, x, y, sym, staff->m_drawingStaffSize, false, true); + if (m_doc->IsFacs() && element->HasFacs()) { + const int noteHeight = (int)(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) / 2); + const int noteWidth = (int)(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) / 1.4); + + FacsimileInterface *fi = element->GetFacsimileInterface(); + fi->GetZone()->SetUlx(x); + fi->GetZone()->SetUly(ToDeviceContextY(y)); + fi->GetZone()->SetLrx(x + noteWidth); + fi->GetZone()->SetLry(ToDeviceContextY(y - noteHeight)); + } + /************ Draw children (accidentals, etc) ************/ // Drawing the children should be done before ending the graphic. Otherwise the SVG tree will not match the MEI one this->DrawLayerChildren(dc, custos, layer, staff, measure); @@ -1420,6 +1460,9 @@ void View::DrawNote(DeviceContext *dc, LayerElement *element, Layer *layer, Staf if (note->IsMensuralDur()) { this->DrawMensuralNote(dc, element, layer, staff, measure); + if (note->FindDescendantByType(DOTS)) { + this->DrawLayerChildren(dc, note, layer, staff, measure); + } return; } if (note->IsTabGrpNote()) { @@ -1728,12 +1771,14 @@ void View::DrawSyl(DeviceContext *dc, LayerElement *element, Layer *layer, Staff Syl *syl = vrv_cast(element); assert(syl); - if (!syl->GetStart() && !(staff->m_drawingNotationType == NOTATIONTYPE_neume)) { + bool isNeume = (staff->m_drawingNotationType == NOTATIONTYPE_neume); + + if (!syl->GetStart() && !isNeume) { LogWarning("Parent note for was not found"); return; } - if (m_doc->IsFacs()) { + if (!m_doc->IsFacs()) { syl->SetDrawingYRel(this->GetSylYRel(syl->m_drawingVerse, staff)); } @@ -1760,7 +1805,7 @@ void View::DrawSyl(DeviceContext *dc, LayerElement *element, Layer *layer, Staff TextDrawingParams params; params.m_x = syl->GetDrawingX(); params.m_y = syl->GetDrawingY(); - if (m_doc->IsFacs() || m_doc->IsNeumeLines()) { + if (m_doc->IsFacs()) { params.m_width = syl->GetDrawingWidth(); params.m_height = syl->GetDrawingHeight(); } diff --git a/src/view_neume.cpp b/src/view_neume.cpp index b332c29a859..de32dbed592 100644 --- a/src/view_neume.cpp +++ b/src/view_neume.cpp @@ -169,8 +169,10 @@ void View::DrawNc(DeviceContext *dc, LayerElement *element, Layer *layer, Staff struct drawingParams { wchar_t fontNo = SMUFL_E990_chantPunctum; wchar_t fontNoLiq[5] = {}; - float xOffset = 0; - float yOffset = 0; + double xOffset = 0; + double yOffset = 0; + double xOffsetLiq[5] = { 0, 0, 0, 0, 0 }; + double yOffsetLiq[5] = { 0, 0, 0, 0, 0 }; }; std::vector params; params.push_back(drawingParams()); @@ -196,6 +198,23 @@ void View::DrawNc(DeviceContext *dc, LayerElement *element, Layer *layer, Staff else if (nc->GetLigated() == BOOLEAN_true) { int pitchDifference = 0; bool isFirst; + // Check if this is the first or second part of a ligature + // Object *nextSibling = neume->GetChild(position + 1); + // if (nextSibling != NULL) { + // Nc *nextNc = dynamic_cast(nextSibling); + // assert(nextNc); + // if (nextNc->GetLigated() == BOOLEAN_true) { // first part of the ligature + // isFirst = true; + // pitchDifference = nextNc->PitchDifferenceTo(nc); + // params.at(0).yOffset = pitchDifference; + // } + // else { + // isFirst = false; + // } + // } + // else { + // isFirst = false; + // } int ligCount = neume->GetLigatureCount(position); if (ligCount % 2 == 0) { @@ -217,6 +236,14 @@ void View::DrawNc(DeviceContext *dc, LayerElement *element, Layer *layer, Staff } } + // if (!isFirst) { // still need to get pitchDifference + // Nc *lastnc = dynamic_cast(neume->GetChild(position > 0 ? position - 1 : 0)); + // assert(lastnc); + // pitchDifference = nc->PitchDifferenceTo(lastnc); + // params.at(0).xOffset = -1; + // params.at(0).yOffset = -pitchDifference; + // } + // set the glyph switch (pitchDifference) { case -1: @@ -245,19 +272,40 @@ void View::DrawNc(DeviceContext *dc, LayerElement *element, Layer *layer, Staff params.at(0).fontNo = SMUFL_E997_chantPunctumVirgaReversed; } + else if (nc->GetCurve() == curvatureDirection_CURVE_c) { + params.at(0).fontNoLiq[0] = SMUFL_E9BE_chantConnectingLineAsc3rd; + params.at(0).fontNoLiq[1] = SMUFL_EB92_staffPosRaise3; + params.at(0).fontNoLiq[2] = SMUFL_E995_chantAuctumDesc; + params.at(0).fontNoLiq[3] = SMUFL_EB91_staffPosRaise2; + params.at(0).fontNoLiq[4] = SMUFL_E9BE_chantConnectingLineAsc3rd; + params.at(0).xOffsetLiq[4] = 0.8; + params.at(0).yOffsetLiq[0] = -1.5; + params.at(0).yOffsetLiq[4] = -1.75; + } + else if (nc->GetCurve() == curvatureDirection_CURVE_a) { + params.at(0).fontNoLiq[0] = SMUFL_E9BE_chantConnectingLineAsc3rd; + params.at(0).fontNoLiq[1] = SMUFL_EB98_staffPosLower1; + params.at(0).fontNoLiq[2] = SMUFL_E994_chantAuctumAsc; + params.at(0).fontNoLiq[3] = SMUFL_EB99_staffPosLower2; + params.at(0).fontNoLiq[4] = SMUFL_E9BE_chantConnectingLineAsc3rd; + params.at(0).xOffsetLiq[4] = 0.8; + params.at(0).yOffsetLiq[0] = 0.5; + params.at(0).yOffsetLiq[4] = 0.75; + } + const int noteHeight = (int)(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) / NOTE_HEIGHT_TO_STAFF_SIZE_RATIO); const int noteWidth = (int)(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) / NOTE_WIDTH_TO_STAFF_SIZE_RATIO); int noteY, noteX; int yValue; - if (nc->HasFacs() && m_doc->IsNeumeLines()) { - noteY = staff->GetDrawingY(); + if (nc->HasFacs() && m_doc->IsFacs()) { + noteY = ToLogicalY(staff->GetDrawingY()); noteX = nc->GetDrawingX(); params.at(0).xOffset = 0; } - else if (neume->HasFacs() && m_doc->IsNeumeLines()) { - noteY = staff->GetDrawingY(); + else if (neume->HasFacs() && m_doc->IsFacs()) { + noteY = ToLogicalY(staff->GetDrawingY()); noteX = neume->GetDrawingX() + position * noteWidth; } else { @@ -275,9 +323,14 @@ void View::DrawNc(DeviceContext *dc, LayerElement *element, Layer *layer, Staff clefOctave += (clef->GetDisPlace() == STAFFREL_basic_above ? 1 : -1) * (clef->GetDis() / 7); } int octaveOffset = (nc->GetOct() - clefOctave) * ((staffSize / 2) * 7); - int rotationOffset = 0; - if (staff->HasDrawingRotation()) { - rotationOffset = staff->GetDrawingRotationOffsetFor(noteX); + int rotateOffset; + if (m_doc->IsFacs() && (staff->GetDrawingRotate() != 0)) { + double deg = staff->GetDrawingRotate(); + int xDiff = noteX - staff->GetDrawingX(); + rotateOffset = int(xDiff * tan(deg * M_PI / 180.0)); + } + else { + rotateOffset = 0; } if (nc->HasLoc()) { @@ -290,16 +343,31 @@ void View::DrawNc(DeviceContext *dc, LayerElement *element, Layer *layer, Staff else if (clef->GetShape() == CLEFSHAPE_F) { pitchOffset = (nc->GetPname() - 4) * (staffSize / 2); } - yValue = clefYPosition + pitchOffset + octaveOffset - rotationOffset; + yValue = clefYPosition + pitchOffset + octaveOffset - rotateOffset; } - if (!nc->HasCurve()) { - for (auto it = params.begin(); it != params.end(); it++) { + for (auto it = params.begin(); it != params.end(); it++) { + if (nc->GetCurve() == curvatureDirection_CURVE_a || nc->GetCurve() == curvatureDirection_CURVE_c) { + for (int i = 0; i < static_cast(sizeof(params.at(0).fontNoLiq)); i++) { + DrawSmuflCode(dc, noteX + it->xOffsetLiq[i] * noteWidth, yValue + it->yOffsetLiq[i] * noteHeight, + it->fontNoLiq[i], staff->m_drawingStaffSize, false, true); + } + } + else { DrawSmuflCode(dc, noteX + it->xOffset * noteWidth, yValue + it->yOffset * noteHeight, it->fontNo, staff->m_drawingStaffSize, false, true); } } + // adjust facsimile values of element based on where it is rendered if necessary + if (m_doc->IsFacs() && element->HasFacs()) { + FacsimileInterface *fi = element->GetFacsimileInterface(); + fi->GetZone()->SetUlx(noteX); + fi->GetZone()->SetUly(ToDeviceContextY(yValue)); + fi->GetZone()->SetLrx(noteX + noteWidth); + fi->GetZone()->SetLry(ToDeviceContextY(yValue - noteHeight)); + } + // Draw the children this->DrawLayerChildren(dc, nc, layer, staff, measure); @@ -389,6 +457,9 @@ void View::DrawDivLine(DeviceContext *dc, LayerElement *element, Layer *layer, S DivLine *divLine = dynamic_cast(element); assert(divLine); + // int x = divLine->GetDrawingX(); + // int y = divLine->GetDrawingY(); + dc->StartGraphic(element, "", element->GetID()); int sym = 0; @@ -404,14 +475,29 @@ void View::DrawDivLine(DeviceContext *dc, LayerElement *element, Layer *layer, S } int x, y; - x = divLine->GetDrawingX(); - y = staff->GetDrawingY(); + if (m_doc->IsFacs() && (divLine->HasFacs())) { + x = divLine->GetDrawingX(); + y = ToLogicalY(staff->GetDrawingY()); + } + else { + x = element->GetDrawingX(); + y = element->GetDrawingY(); + y -= m_doc->GetDrawingUnit(staff->m_drawingStaffSize); + } y -= (m_doc->GetDrawingUnit(staff->m_drawingStaffSize)) * 3; - if (staff->HasDrawingRotation()) { - y -= staff->GetDrawingRotationOffsetFor(x); + int rotateOffset; + if (m_doc->IsFacs() && (staff->GetDrawingRotate() != 0)) { + double deg = staff->GetDrawingRotate(); + int xDiff = x - staff->GetDrawingX(); + rotateOffset = int(xDiff * tan(deg * M_PI / 180.0)); } + else { + rotateOffset = 0; + } + + y -= rotateOffset; DrawSmuflCode(dc, x, y, sym, staff->m_drawingStaffSize, false, true); diff --git a/src/view_page.cpp b/src/view_page.cpp index d150f693ed4..51d8b78be5c 100644 --- a/src/view_page.cpp +++ b/src/view_page.cpp @@ -1283,14 +1283,19 @@ void View::DrawStaffLines(DeviceContext *dc, Staff *staff, Measure *measure, Sys int j, x1, x2, y1, y2; - x1 = measure->GetDrawingX(); - x2 = x1 + measure->GetWidth(); - y1 = staff->GetDrawingY(); - if (!staff->HasDrawingRotation()) { - y2 = y1; + if (staff->HasFacs() && m_doc->IsFacs()) { + double d = staff->GetDrawingRotate(); + x1 = staff->GetDrawingX(); + x2 = x1 + staff->GetWidth(); + y1 = ToLogicalY(staff->GetDrawingY()); + staff->AdjustDrawingStaffSize(); + y2 = y1 - staff->GetWidth() * tan(d * M_PI / 180.0); } else { - y2 = y1 - measure->GetWidth() * tan(staff->GetDrawingRotation() * M_PI / 180.0); + x1 = measure->GetDrawingX(); + x2 = x1 + measure->GetWidth(); + y1 = staff->GetDrawingY(); + y2 = y1; } const int lineWidth = m_doc->GetDrawingStaffLineWidth(staff->m_drawingStaffSize); diff --git a/src/view_text.cpp b/src/view_text.cpp index f1f30653f9c..ff281247add 100644 --- a/src/view_text.cpp +++ b/src/view_text.cpp @@ -271,21 +271,21 @@ void View::DrawLyricString( std::u32string syl = U""; std::u32string lyricStr = str; - const int dcX = (params) ? ToDeviceContextX(params->m_x) : VRV_UNSET; - const int dcY = (params) ? ToDeviceContextY(params->m_y) : VRV_UNSET; + const int x = (params) ? params->m_x : VRV_UNSET; + const int y = (params) ? params->m_y : VRV_UNSET; const int width = (params) ? params->m_width : VRV_UNSET; const int height = (params) ? params->m_height : VRV_UNSET; if (m_doc->GetOptions()->m_lyricElision.GetValue() == ELISION_unicode) { std::replace(lyricStr.begin(), lyricStr.end(), U'_', UNICODE_UNDERTIE); - dc->DrawText(UTF32to8(lyricStr), lyricStr, dcX, dcY, width, height); + dc->DrawText(UTF32to8(lyricStr), lyricStr, x, y, width, height); } else { while (lyricStr.compare(syl) != 0) { wroteText = true; auto index = lyricStr.find_first_of(U"_"); syl = lyricStr.substr(0, index); - dc->DrawText(UTF32to8(syl), syl, dcX, dcY, width, height); + dc->DrawText(UTF32to8(syl), syl, x, y, width, height); // no _ if (index == std::string::npos) break; @@ -298,7 +298,7 @@ void View::DrawLyricString( bool isFallbackNeeded = (m_doc->GetResources()).IsSmuflFallbackNeeded(elision); vrvTxt.SetSmuflWithFallback(isFallbackNeeded); dc->SetFont(&vrvTxt); - dc->DrawText(UTF32to8(elision), elision, dcX, dcY, width, height); + dc->DrawText(UTF32to8(elision), elision, x, y, width, height); dc->ResetFont(); // next syllable @@ -310,8 +310,7 @@ void View::DrawLyricString( // This should only be called in facsimile mode where a zone is specified but there is // no text. This draws the bounds of the zone but leaves the space blank. if (!wroteText && params) { - dc->DrawText( - "", U"", ToDeviceContextX(params->m_x), ToDeviceContextY(params->m_y), params->m_width, params->m_height); + dc->DrawText("", U"", params->m_x, params->m_y, params->m_width, params->m_height); } }