From faad0aa7799788eed6df7305df13c827106b566e Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Tue, 16 May 2023 14:23:47 -0400 Subject: [PATCH 01/91] pass neon path as command line argument --- emscripten/testNeon.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emscripten/testNeon.sh b/emscripten/testNeon.sh index 3bd16175df4..6e543fedf33 100755 --- a/emscripten/testNeon.sh +++ b/emscripten/testNeon.sh @@ -16,9 +16,9 @@ cd build # Moves the needed verovio.js into Neon cp verovio.js verovio_new.js -mv verovio_new.js [location_of_your_Neon]/Neon/verovio-util +mv verovio_new.js $1/verovio-util -cd [location_of_your_Neon]/Neon/verovio-util +cd $1/verovio-util rm verovio.js; mv verovio_new.js verovio.js From 0bbfe648e5488f90edd6f214385f7998e48c0fef Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Tue, 16 May 2023 14:23:47 -0400 Subject: [PATCH 02/91] pass neon path as command line argument --- emscripten/testNeon.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 emscripten/testNeon.sh diff --git a/emscripten/testNeon.sh b/emscripten/testNeon.sh new file mode 100644 index 00000000000..0158466bf4a --- /dev/null +++ b/emscripten/testNeon.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# This is a little script that compiles verovio using buildToolkit +# and moves the output, verovio.js, into Neon/verovio-util. +# It then starts up a local instance of Neon using yarn so the +# developer can see the changes as soon as possible. +# Please change [location_of_your_Neon] with the actual path. +# For example: ~/Desktop/DDMAL + + +# Builds verovio for Neon +./buildToolkit -x "Gootville,Petaluma" -DHPX + +cd build + +# Moves the needed verovio.js into Neon +cp verovio.js verovio_new.js + +mv verovio_new.js /Users/yinanzhou/SIMSSA/Neon/verovio-util + +cd /Users/yinanzhou/SIMSSA/Neon/verovio-util + +rm verovio.js; mv verovio_new.js verovio.js + +# Runs Neon +yarn build && yarn start \ No newline at end of file From 39c0099cec6ee9de627ee8b27aa92cc2422007b2 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Wed, 5 Jul 2023 16:30:52 -0400 Subject: [PATCH 03/91] Remove testNeon.sh from git --- emscripten/testNeon.sh | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 emscripten/testNeon.sh diff --git a/emscripten/testNeon.sh b/emscripten/testNeon.sh deleted file mode 100644 index 0158466bf4a..00000000000 --- a/emscripten/testNeon.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -# This is a little script that compiles verovio using buildToolkit -# and moves the output, verovio.js, into Neon/verovio-util. -# It then starts up a local instance of Neon using yarn so the -# developer can see the changes as soon as possible. -# Please change [location_of_your_Neon] with the actual path. -# For example: ~/Desktop/DDMAL - - -# Builds verovio for Neon -./buildToolkit -x "Gootville,Petaluma" -DHPX - -cd build - -# Moves the needed verovio.js into Neon -cp verovio.js verovio_new.js - -mv verovio_new.js /Users/yinanzhou/SIMSSA/Neon/verovio-util - -cd /Users/yinanzhou/SIMSSA/Neon/verovio-util - -rm verovio.js; mv verovio_new.js verovio.js - -# Runs Neon -yarn build && yarn start \ No newline at end of file From 118eeb652f800536195a23e8c480219c04ed4bda Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 10 Jul 2023 11:49:20 -0400 Subject: [PATCH 04/91] MatchHeight editor action for bbox --- include/vrv/editortoolkit_neume.h | 2 + src/editortoolkit_neume.cpp | 80 +++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/include/vrv/editortoolkit_neume.h b/include/vrv/editortoolkit_neume.h index dfeb65043e5..a31242d2970 100644 --- a/include/vrv/editortoolkit_neume.h +++ b/include/vrv/editortoolkit_neume.h @@ -44,6 +44,7 @@ class EditorToolkitNeume : public EditorToolkit { bool Insert(std::string elementType, std::string staffId, int ulx, int uly, int lrx, int lry, std::vector> attributes); bool InsertToSyllable(std::string elementId); + bool MatchHeight(std::string elementId); bool Merge(std::vector elementIds); bool MoveOutsideSyllable(std::string elementId); bool Set(std::string elementId, std::string attrType, std::string attrValue); @@ -72,6 +73,7 @@ class EditorToolkitNeume : public EditorToolkit { bool ParseInsertAction(jsonxx::Object param, std::string *elementType, std::string *staffId, int *ulx, int *uly, int *lrx, int *lry, std::vector> *attributes); bool ParseInsertToSyllableAction(jsonxx::Object param, std::string *elementId); + bool ParseMatchHeightAction(jsonxx::Object param, std::string *elementId); bool ParseMergeAction(jsonxx::Object param, std::vector *elementIds); bool ParseMoveOutsideSyllableAction(jsonxx::Object param, std::string *elementId); bool ParseSetAction(jsonxx::Object param, std::string *elementId, std::string *attrType, std::string *attrValue); diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index aa60f6b3559..132b579e4d6 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -183,6 +183,13 @@ bool EditorToolkitNeume::ParseEditorAction(const std::string &json_editorAction) return this->SplitNeume(elementId, ncId); } } + else if (action == "matchHeight") { + std::string elementId; + if (this->ParseMatchHeightAction(json.get("param"), &elementId)) { + return this->MatchHeight(elementId); + } + LogWarning("Could not parse the insert action"); + } else if (action == "merge") { std::vector elementIds; if (this->ParseMergeAction(json.get("param"), &elementIds)) { @@ -1596,6 +1603,72 @@ bool EditorToolkitNeume::DisplaceClefOctave(std::string elementId, std::string d return true; } +bool EditorToolkitNeume::MatchHeight(std::string elementId) +{ + if (!m_doc->GetDrawingPage()) { + LogError("Could not get drawing page"); + m_infoObject.import("status", "FAILURE"); + m_infoObject.import("message", "Could not get drawing page."); + return false; + } + if (m_doc->GetType() != Facs) { + LogError("Drawing page without facsimile"); + m_infoObject.import("status", "FAILURE"); + m_infoObject.import("message", "Drawing page without facsimile is unsupported."); + return false; + } + + Object *element = m_doc->GetDrawingPage()->FindDescendantByID(elementId); + assert(element); + Object *staffParent = element->GetFirstAncestor(STAFF); + if (element == NULL) { + LogError("No element exists with ID '%s'.", elementId.c_str()); + m_infoObject.import("status", "FAILURE"); + m_infoObject.import("message", "No element exists with ID" + elementId + "."); + return false; + } + if (!element->Is(SYL)) { + LogError("Element is of type %s, but only element can match height.", element->GetClassName().c_str()); + m_infoObject.import("status", "FAILURE"); + m_infoObject.import( + "message", "Element is of type " + element->GetClassName() + ", but only element can match height."); + return false; + } + + // get the position of the selected bbox + int uly; + int lry; + if (dynamic_cast(element)->HasFacs()) { + uly = element->GetFacsimileInterface()->GetZone()->GetUly(); + lry = element->GetFacsimileInterface()->GetZone()->GetLry(); + } + else { + LogError("Selected '%s' without facsimile", element->GetClassName().c_str()); + m_infoObject.import("status", "FAILURE"); + m_infoObject.import("message", "Selected '" + element->GetClassName() + "' without facsimile is unsupported."); + return false; + } + + // find all syls in staff + ListOfObjects syls; + ClassIdComparison ac(SYL); + staffParent->FindAllDescendantsByComparison(&syls, &ac); + Syl *syl; + Zone *zone; + + for (auto it = syls.begin(); it != syls.end(); ++it) { + syl = dynamic_cast(*it); + zone = syl->GetFacsimileInterface()->GetZone(); + assert(zone); + zone->SetUly(uly); + zone->SetLry(lry); + } + + m_infoObject.import("status", "OK"); + m_infoObject.import("message", ""); + return true; +} + bool EditorToolkitNeume::Merge(std::vector elementIds) { if (!m_doc->GetDrawingPage()) return false; @@ -3777,6 +3850,13 @@ bool EditorToolkitNeume::ParseDisplaceClefAction(jsonxx::Object param, std::stri return true; } +bool EditorToolkitNeume::ParseMatchHeightAction(jsonxx::Object param, std::string *elementId) +{ + if (!param.has("elementId")) return false; + (*elementId) = param.get("elementId"); + return true; +} + bool EditorToolkitNeume::ParseMergeAction(jsonxx::Object param, std::vector *elementIds) { if (!param.has("elementIds")) return false; From 9e30b5428509ac320a70897b8da91b26b5ad73a1 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Wed, 12 Jul 2023 17:25:17 -0400 Subject: [PATCH 05/91] Add overlap correction on x-axis --- src/editortoolkit_neume.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 132b579e4d6..8054cf2780b 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -1655,11 +1655,25 @@ bool EditorToolkitNeume::MatchHeight(std::string elementId) staffParent->FindAllDescendantsByComparison(&syls, &ac); Syl *syl; Zone *zone; + int rightMost = -1; + int itUlx; + int itLrx; for (auto it = syls.begin(); it != syls.end(); ++it) { syl = dynamic_cast(*it); zone = syl->GetFacsimileInterface()->GetZone(); assert(zone); + + // adjust x-axis first + itUlx = zone->GetUlx(); + itLrx = zone->GetLrx(); + if (itLrx > rightMost) { + // correct overlap + if (itUlx < rightMost) zone->SetUlx(rightMost); + // Update right most point if needed + rightMost = itLrx; + } + zone->SetUly(uly); zone->SetLry(lry); } From bd90014631971c2ae441eb960b8a354c2185cb40 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Thu, 13 Jul 2023 15:14:05 -0400 Subject: [PATCH 06/91] Add staff rotation offset --- src/editortoolkit_neume.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 8054cf2780b..9ff8db76b7e 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -1636,11 +1636,15 @@ bool EditorToolkitNeume::MatchHeight(std::string elementId) } // get the position of the selected bbox + int ulx; int uly; - int lry; + int height; + int lrx; if (dynamic_cast(element)->HasFacs()) { + ulx = element->GetFacsimileInterface()->GetZone()->GetUlx(); uly = element->GetFacsimileInterface()->GetZone()->GetUly(); - lry = element->GetFacsimileInterface()->GetZone()->GetLry(); + lrx = element->GetFacsimileInterface()->GetZone()->GetLrx(); + height = element->GetFacsimileInterface()->GetZone()->GetLry() - uly; } else { LogError("Selected '%s' without facsimile", element->GetClassName().c_str()); @@ -1655,9 +1659,11 @@ bool EditorToolkitNeume::MatchHeight(std::string elementId) staffParent->FindAllDescendantsByComparison(&syls, &ac); Syl *syl; Zone *zone; - int rightMost = -1; int itUlx; int itLrx; + int offsetY; + int rightMost = -1; + double theta = staffParent->GetFacsimileInterface()->GetZone()->GetRotate(); for (auto it = syls.begin(); it != syls.end(); ++it) { syl = dynamic_cast(*it); @@ -1674,8 +1680,14 @@ bool EditorToolkitNeume::MatchHeight(std::string elementId) rightMost = itLrx; } - zone->SetUly(uly); - zone->SetLry(lry); + offsetY = 0; + if (theta) { + double factor = 1.3; + offsetY = (int)((itUlx - ulx) * tan(theta * M_PI / 180.0) / factor); + } + + zone->SetUly(uly + offsetY); + zone->SetLry(uly + offsetY + height); } m_infoObject.import("status", "OK"); From 939be300897df2cd8aaebd323e0873c9ae028b93 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Thu, 13 Jul 2023 16:50:21 -0400 Subject: [PATCH 07/91] Adjust original bbox size for ungrouping --- src/editortoolkit_neume.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 9ff8db76b7e..bd17ef5b4f4 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2988,6 +2988,10 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector // if the element is a syl then we want to keep it attached to the first node if (el->Is(SYL)) { + Zone *zone = dynamic_cast(el->GetFacsimileInterface()->GetZone()); + + zone->SetLrx(zone->GetUlx() + 100); + zone->SetLry(zone->GetUly() + 200); continue; } From 467e074b47a94ab53aeca31e038d3dab3ecf8297 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Fri, 14 Jul 2023 15:20:47 -0400 Subject: [PATCH 08/91] Fix ungroup when syllable start with layer element --- src/editortoolkit_neume.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index bd17ef5b4f4..88f2b5922a2 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2932,8 +2932,10 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector sparent->ReorderByXPos(); fparent->ClearRelinquishedChildren(); fparent->ReorderByXPos(); + uuidArray << (*it); + it = elementIds.erase(it); + el = m_doc->GetDrawingPage()->FindDescendantByID(*it); } - continue; } if (elementIds.begin() == it || firstIsSyl) { // if the element is a syl we want it to stay attached to the first element From 28efa4b0d3e247cda1401ae23ebfe8d8ba96ce3b Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Fri, 14 Jul 2023 16:12:22 -0400 Subject: [PATCH 09/91] Clean up comments --- src/editortoolkit_neume.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 88f2b5922a2..26ecf7e5af6 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2997,12 +2997,6 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector continue; } - // if (el->Is(DIVLINE) || el->Is(ACCID)) { - // el->MoveItselfTo(sparent); - // fparent->ClearRelinquishedChildren(); - // continue; - // } - if (groupType == "nc") { Nc *nc = dynamic_cast(el); assert(nc); @@ -3096,15 +3090,11 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector FacsimileInterface *fi = syl->GetFacsimileInterface(); assert(fi); fi->AttachZone(zone); - - // syl->ResetFacsimile(); - // syl->SetFacs(zone->GetID()); } } if (ligNum != 1) { // if not 1st nc in ligature, add child - uuidArray << newParent->GetID(); sparent->AddChild(newParent); From bad01cfb1dcc9885709bb41e7bf7f72f3ba149bd Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 24 Jul 2023 16:22:34 -0400 Subject: [PATCH 10/91] Refactor ungroup bbox --- src/editortoolkit_neume.cpp | 67 +++++++++---------------------------- 1 file changed, 15 insertions(+), 52 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 26ecf7e5af6..ee3d1f303f0 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2845,6 +2845,7 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector int ligNum = 0; // for ligature in ungroupNcs int firstIsLig = false; bool firstIsSyl = false; + Zone *oldSylZone = NULL; Clef *oldClef = NULL; ClassIdComparison ac(CLEF); ListOfObjects syllables; // List of syllables used. groupType=neume only. @@ -2977,6 +2978,9 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector if (oldClef == NULL) { oldClef = dynamic_cast(sparent)->GetCurrentClef(); } + + // Get orginal syl zone + oldSylZone = dynamic_cast(currentParent->GetFirst(SYL)->GetFacsimileInterface()->GetZone()); } else { @@ -2990,10 +2994,9 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector // if the element is a syl then we want to keep it attached to the first node if (el->Is(SYL)) { - Zone *zone = dynamic_cast(el->GetFacsimileInterface()->GetZone()); - - zone->SetLrx(zone->GetUlx() + 100); - zone->SetLry(zone->GetUly() + 200); + if (oldSylZone) { + oldSylZone->SetLrx(oldSylZone->GetUlx() + 100); + } continue; } @@ -3035,55 +3038,15 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector if (m_doc->GetType() == Facs) { Zone *zone = new Zone(); - // Use syllable parent positions if possible - FacsimileInterface *syllableFi = NULL; - if (syl->GetFirstAncestor(SYLLABLE)->GetFacsimileInterface()->HasFacs()) { - syllableFi = syl->GetFirstAncestor(SYLLABLE)->GetFacsimileInterface(); - Zone *tempZone = dynamic_cast(syllableFi->GetZone()); - zone->SetUlx(tempZone->GetUlx()); - zone->SetUly(tempZone->GetUly()); - zone->SetLrx(tempZone->GetLrx()); - zone->SetLry(tempZone->GetLry()); - } - // otherwise get a boundingbox that comprises all the neumes in the syllable - else { - ListOfObjects children; - InterfaceComparison comp(INTERFACE_FACSIMILE); - syl->GetFirstAncestor(SYLLABLE)->FindAllDescendantsByComparison(&children, &comp); - for (auto iter2 = children.begin(); iter2 != children.end(); ++iter2) { - FacsimileInterface *temp = (*iter2)->GetFacsimileInterface(); - assert(temp); - Zone *tempZone = vrv_cast(temp->GetZone()); - assert(tempZone); - if (temp->HasFacs()) { - if (syllableFi == NULL) { - zone->SetUlx(tempZone->GetUlx()); - zone->SetUly(tempZone->GetUly()); - zone->SetLrx(tempZone->GetLrx()); - zone->SetLry(tempZone->GetLry()); - } - else { - if (tempZone->GetUlx() < zone->GetUlx()) { - zone->SetUlx(tempZone->GetUlx()); - } - if (tempZone->GetUly() < zone->GetUly()) { - zone->SetUly(tempZone->GetUly()); - } - if (tempZone->GetLrx() > zone->GetLrx()) { - zone->SetLrx(tempZone->GetLrx()); - } - if (tempZone->GetLry() > zone->GetLry()) { - zone->SetLry(tempZone->GetLry()); - } - } - } - } - } + zone->SetUlx(el->GetFirst(NC)->GetFacsimileInterface()->GetZone()->GetUlx()); + zone->SetUly(oldSylZone->GetUly()); + zone->SetLrx(el->GetLast(NC)->GetFacsimileInterface()->GetZone()->GetLrx()); + zone->SetLry(oldSylZone->GetLry()); - // make the bounding box a little bigger and lower so it's easier to edit - zone->SetUly(zone->GetUly() + 100); - zone->SetLrx(zone->GetLrx() + 100); - zone->SetLry(zone->GetLry() + 200); + // Make bbox larger if it has less than 2 ncs + if (newParent->GetChildCount(NC, 2) <= 2) { + zone->SetLrx(zone->GetLrx() + 50); + } assert(m_doc->GetFacsimile()); m_doc->GetFacsimile()->FindDescendantByType(SURFACE)->AddChild(zone); From 5456a4cb645ff21460d4042f92195932a6df9d86 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 24 Jul 2023 16:23:34 -0400 Subject: [PATCH 11/91] Clean up --- src/editortoolkit_neume.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index ee3d1f303f0..15a2616f740 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2950,7 +2950,6 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector Nc *nc = dynamic_cast(el); assert(nc); if (nc->HasLigated() && nc->GetLigated() == BOOLEAN_true) { - // ligNum++; firstIsLig = true; } @@ -3003,7 +3002,6 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector if (groupType == "nc") { Nc *nc = dynamic_cast(el); assert(nc); - // if (nc->HasLigated()) continue; if (firstIsLig) { // if 1st is ligature, neglect 2nd, go to the next nc From d69ae9e353a3de2bdeeab075fa21ea4e89a3a452 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Tue, 25 Jul 2023 11:30:52 -0400 Subject: [PATCH 12/91] Remove x-axis adjustment --- src/editortoolkit_neume.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 15a2616f740..43f34d7f7fd 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -1660,9 +1660,9 @@ bool EditorToolkitNeume::MatchHeight(std::string elementId) Syl *syl; Zone *zone; int itUlx; - int itLrx; + // int itLrx; int offsetY; - int rightMost = -1; + // int rightMost = -1; double theta = staffParent->GetFacsimileInterface()->GetZone()->GetRotate(); for (auto it = syls.begin(); it != syls.end(); ++it) { @@ -1670,17 +1670,18 @@ bool EditorToolkitNeume::MatchHeight(std::string elementId) zone = syl->GetFacsimileInterface()->GetZone(); assert(zone); - // adjust x-axis first - itUlx = zone->GetUlx(); - itLrx = zone->GetLrx(); - if (itLrx > rightMost) { - // correct overlap - if (itUlx < rightMost) zone->SetUlx(rightMost); - // Update right most point if needed - rightMost = itLrx; - } + // // adjust x-axis first + // itUlx = zone->GetUlx(); + // itLrx = zone->GetLrx(); + // if (itLrx > rightMost) { + // // correct overlap + // if (itUlx < rightMost) zone->SetUlx(rightMost); + // // Update right most point if needed + // rightMost = itLrx; + // } offsetY = 0; + itUlx = zone->GetUlx(); if (theta) { double factor = 1.3; offsetY = (int)((itUlx - ulx) * tan(theta * M_PI / 180.0) / factor); From 7c1dc57786a5ef333fc1d95ad5435ad5ec15a821 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Thu, 27 Jul 2023 16:57:47 -0400 Subject: [PATCH 13/91] Fix ungroup when firstIsSyl --- src/editortoolkit_neume.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 43f34d7f7fd..037591d462e 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2944,6 +2944,10 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector // we'll still need to initialize all the parents, thus the bool if (el->Is(SYL)) { firstIsSyl = true; + oldSylZone = dynamic_cast(el->GetFacsimileInterface()->GetZone()); + if (oldSylZone) { + oldSylZone->SetLrx(oldSylZone->GetUlx() + 100); + } continue; } else if (groupType == "nc") { @@ -2980,7 +2984,9 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector } // Get orginal syl zone - oldSylZone = dynamic_cast(currentParent->GetFirst(SYL)->GetFacsimileInterface()->GetZone()); + if (!oldSylZone) { + oldSylZone = dynamic_cast(currentParent->GetFirst(SYL)->GetFacsimileInterface()->GetZone()); + } } else { From 4d66a78924e87caecb14c670b2a066d0a9646bb1 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Fri, 28 Jul 2023 17:17:43 -0400 Subject: [PATCH 14/91] Remove redundant new syl for insert action --- src/editortoolkit_neume.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 037591d462e..72745a2a16d 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -874,8 +874,6 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in if (m_doc->GetType() == Facs) { FacsimileInterface *fi = vrv_cast(syl->GetFacsimileInterface()); assert(fi); - Text *text = new Text(); - syl->AddChild(text); Zone *sylZone = new Zone(); // calculate bboxUlx and bboxUly wrt rotation using sine rule From 6769c821af488b36f30cbb6d8aca28bdc0bb7496 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Sun, 30 Jul 2023 16:46:13 -0400 Subject: [PATCH 15/91] Remove unnecessary doubleParent check --- src/editortoolkit_neume.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 72745a2a16d..20f2af437d0 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2648,16 +2648,14 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e // also in this case we need to make sure that the facsimile of the resulting syl is correct else { if (elementClass == NC) { - if (doubleParent) { - parent = new Neume(); - for (auto it = elements.begin(); it != elements.end(); ++it) { - if ((*it)->GetParent() != parent && !(*it)->Is(SYL)) { - (*it)->MoveItselfTo(parent); - parent->ReorderByXPos(); - } + parent = new Neume(); + for (auto it = elements.begin(); it != elements.end(); ++it) { + if ((*it)->GetParent() != parent && !(*it)->Is(SYL)) { + (*it)->MoveItselfTo(parent); + parent->ReorderByXPos(); } - doubleParent->AddChild(parent); } + doubleParent->AddChild(parent); Layer *layer = dynamic_cast(parent->GetFirstAncestor(LAYER)); if (!layer) { From 599b28aae381503936d820183dc9039e9c41517d Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Sun, 30 Jul 2023 16:50:29 -0400 Subject: [PATCH 16/91] Rename doubleParent to secondParent --- src/editortoolkit_neume.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 20f2af437d0..9573a407a8c 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2314,7 +2314,7 @@ bool EditorToolkitNeume::Resize(std::string elementId, int ulx, int uly, int lrx bool EditorToolkitNeume::Group(std::string groupType, std::vector elementIds) { - Object *parent = NULL, *doubleParent = NULL; + Object *parent = NULL, *secondParent = NULL; std::map parents; std::set elements; std::vector sortedElements; @@ -2441,9 +2441,9 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } } - if (doubleParent == NULL) { - doubleParent = par->GetParent(); - if (doubleParent == NULL) { + if (secondParent == NULL) { + secondParent = par->GetParent(); + if (secondParent == NULL) { LogError("No second level parent!"); m_infoObject.import("status", "FAILURE"); m_infoObject.import("message", "No second level parent."); @@ -2451,7 +2451,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } } else { - if (par->GetParent() != doubleParent) { + if (par->GetParent() != secondParent) { LogError("No shared second level parent!"); m_infoObject.import("status", "FAILURE"); m_infoObject.import("message", "No shared second level parent."); @@ -2620,10 +2620,10 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } parent->ReorderByXPos(); - if (doubleParent == NULL) { + if (secondParent == NULL) { return false; } - doubleParent->AddChild(parent); + secondParent->AddChild(parent); Layer *layer = vrv_cast(parent->GetFirstAncestor(LAYER)); assert(layer); @@ -2655,7 +2655,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e parent->ReorderByXPos(); } } - doubleParent->AddChild(parent); + secondParent->AddChild(parent); Layer *layer = dynamic_cast(parent->GetFirstAncestor(LAYER)); if (!layer) { @@ -2733,11 +2733,11 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } } - if (doubleParent == NULL) { + if (secondParent == NULL) { LogError("No second level parent!"); return false; } - doubleParent->AddChild(fullSyllable); + secondParent->AddChild(fullSyllable); Layer *layer = vrv_cast(fullSyllable->GetFirstAncestor(LAYER)); assert(layer); if (ulx >= 0 && uly >= 0 && lrx >= 0 && lry >= 0) { @@ -2779,11 +2779,11 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e Object *obj = (*it).first; obj->ClearRelinquishedChildren(); if (obj->GetChildCount() == 0) { - if (doubleParent == NULL) { + if (secondParent == NULL) { LogError("No second level parent!"); return false; } - doubleParent->DeleteChild(obj); + secondParent->DeleteChild(obj); } else if (obj->GetChildCount() == (obj->GetChildCount(SYL) + obj->GetChildCount(DIVLINE) + obj->GetChildCount(ACCID) @@ -2807,11 +2807,11 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e parent->ReorderByXPos(); obj->ClearRelinquishedChildren(); } - if (doubleParent == NULL) { + if (secondParent == NULL) { LogError("No second level parent!"); return false; } - doubleParent->DeleteChild(obj); + secondParent->DeleteChild(obj); } } From cf6e7e8c6d049936c22c0e50e3ebf6d4144e0f99 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Sun, 30 Jul 2023 16:57:04 -0400 Subject: [PATCH 17/91] Optimize parents counting --- src/editortoolkit_neume.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 9573a407a8c..108465c45c5 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2458,13 +2458,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e return false; } } - auto possibleEntry = parents.find(el->GetParent()); - if (possibleEntry == parents.end()) { - parents.emplace(el->GetParent(), 1); - } - else { - possibleEntry->second += 1; - } + parents[par]++; elements.insert(el); } From 1ce2b26d1aea740e6183c2bc2fd871a42c119524 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Sun, 30 Jul 2023 16:59:10 -0400 Subject: [PATCH 18/91] Clean up --- src/editortoolkit_neume.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 108465c45c5..6686c8d4b77 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2475,16 +2475,6 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e return false; } - // auto it = elementIds.begin(); - // Object *el = m_doc->GetDrawingPage()->FindDescendantByID(*it); - // Layer *layer = dynamic_cast(el->GetFirstAncestor(LAYER)); - // if (!layer) { - // LogError("Elements does not have Layer parent. This should not happen."); - // m_infoObject.import("status", "FAILURE"); - // m_infoObject.import("message", "Elements does not have Layer parent."); - // return false; - // } - std::copy(elements.begin(), elements.end(), std::back_inserter(sortedElements)); std::stable_sort(sortedElements.begin(), sortedElements.end(), Object::sortByUlx); From d1070c804b7f90f723a56f37dfec9f0f87e76ce0 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Sun, 30 Jul 2023 17:18:21 -0400 Subject: [PATCH 19/91] Remove unnecessary conversion --- src/editortoolkit_neume.cpp | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 6686c8d4b77..1498e8b6b38 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2316,8 +2316,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e { Object *parent = NULL, *secondParent = NULL; std::map parents; - std::set elements; - std::vector sortedElements; + ListOfObjects elements; std::vector fullParents; std::map clefsBefore; @@ -2459,7 +2458,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } } parents[par]++; - elements.insert(el); + elements.push_back(el); } if (parents.size() == 0) { @@ -2475,34 +2474,29 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e return false; } - std::copy(elements.begin(), elements.end(), std::back_inserter(sortedElements)); - std::stable_sort(sortedElements.begin(), sortedElements.end(), Object::sortByUlx); - ListOfObjects clefs; - std::set syllables; - ListOfObjects sortedSyllables; + ListOfObjects syllables; ClassIdComparison clefComp(CLEF); InterfaceComparison pitchComp(INTERFACE_PITCH); Clef *newClef = NULL; - m_doc->GetDrawingPage()->FindAllDescendantsBetween(&clefs, &clefComp, - sortedElements.front()->GetFirstAncestor(SYLLABLE), sortedElements.back()->GetFirstAncestor(SYLLABLE)); + m_doc->GetDrawingPage()->FindAllDescendantsBetween( + &clefs, &clefComp, elements.front()->GetFirstAncestor(SYLLABLE), elements.back()->GetFirstAncestor(SYLLABLE)); // if there are clefs between the elements getting grouped // some elements will need their pitch adjusted for the new clef // clefsBefore maps the syllable parent to its clef before the group // so we can reassociate any pitched children from their old clef to the new one if (clefs.size() != 0) { - for (auto it = sortedElements.begin(); it != sortedElements.end(); ++it) { + for (auto it = elements.begin(); it != elements.end(); ++it) { if ((*it)->Is(SYLLABLE)) { - syllables.insert(dynamic_cast(*it)); + syllables.push_back(dynamic_cast(*it)); } else { - syllables.insert((*it)->GetFirstAncestor(SYLLABLE)); + syllables.push_back((*it)->GetFirstAncestor(SYLLABLE)); } } - std::copy(syllables.begin(), syllables.end(), std::back_inserter(sortedSyllables)); - for (auto it = sortedSyllables.begin(); it != sortedSyllables.end(); ++it) { + for (auto it = syllables.begin(); it != syllables.end(); ++it) { Clef *tempClef = dynamic_cast(m_doc->GetDrawingPage()->FindPreviousChild(&clefComp, (*it))); if (tempClef == NULL) { Layer *layer = vrv_cast((*it)->GetFirstAncestor(LAYER)); @@ -2510,7 +2504,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } clefsBefore.insert(std::pair(dynamic_cast(*it), tempClef)); } - newClef = clefsBefore[dynamic_cast(sortedSyllables.front())]; + newClef = clefsBefore[dynamic_cast(syllables.front())]; } // find parents where all of their children are being grouped @@ -2746,8 +2740,8 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e // change the pitch of any pitched elements whose clef may have changed assert(newClef); ListOfObjects pitchedChildren; - if (sortedSyllables.size()) { - for (auto it = sortedSyllables.begin(); it != sortedSyllables.end(); ++it) { + if (syllables.size()) { + for (auto it = syllables.begin(); it != syllables.end(); ++it) { Syllable *syllable = dynamic_cast(*it); if (clefsBefore[syllable] != newClef) { syllable->FindAllDescendantsByComparison(&pitchedChildren, &pitchComp); From 0e81f754152aa8ea79718c765a0b16e2fb5b21c1 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 31 Jul 2023 11:28:45 -0400 Subject: [PATCH 20/91] Move second level parent check --- src/editortoolkit_neume.cpp | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 1498e8b6b38..a15438f63e0 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2440,23 +2440,6 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } } - if (secondParent == NULL) { - secondParent = par->GetParent(); - if (secondParent == NULL) { - LogError("No second level parent!"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "No second level parent."); - return false; - } - } - else { - if (par->GetParent() != secondParent) { - LogError("No shared second level parent!"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "No shared second level parent."); - return false; - } - } parents[par]++; elements.push_back(el); } @@ -2507,11 +2490,25 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e newClef = clefsBefore[dynamic_cast(syllables.front())]; } + // check if share second level parent + secondParent = (*parents.begin()).first->GetParent(); + if (secondParent == NULL) { + LogError("No second level parent!"); + m_infoObject.import("status", "FAILURE"); + m_infoObject.import("message", "No second level parent."); + return false; + } // find parents where all of their children are being grouped for (auto it = parents.begin(); it != parents.end(); ++it) { auto parentPair = *it; Object *par = parentPair.first; int expected; + if (par->GetParent() != secondParent) { + LogError("No shared second level parent!"); + m_infoObject.import("status", "FAILURE"); + m_infoObject.import("message", "No shared second level parent."); + return false; + } if (par->GetClassId() == SYLLABLE) { expected = par->GetChildCount(NEUME); } From 3b2c0daf1a6b7b1961e3a1c1e54020c23cbd2e0f Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 31 Jul 2023 11:29:17 -0400 Subject: [PATCH 21/91] Clean up --- src/editortoolkit_neume.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index a15438f63e0..5ccba2b6447 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2588,9 +2588,6 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e FacsimileInterface *fi = vrv_cast((*syl).GetFacsimileInterface()); assert(fi); fi->AttachZone(zone); - - // syl->ResetFacsimile(); - // syl->SetFacs(zone->GetID()); } } From 4a1e0ea71499d6e12c4067f1ce6a17a602684683 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 31 Jul 2023 11:30:22 -0400 Subject: [PATCH 22/91] Remove unnecessary second level parent check --- src/editortoolkit_neume.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 5ccba2b6447..e484b8fbd5b 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2592,9 +2592,6 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } parent->ReorderByXPos(); - if (secondParent == NULL) { - return false; - } secondParent->AddChild(parent); Layer *layer = vrv_cast(parent->GetFirstAncestor(LAYER)); From 5f8dfc243837d2d541afc3c41b2502c5dce0f918 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 31 Jul 2023 13:14:45 -0400 Subject: [PATCH 23/91] Simplify syl zone calculation --- src/editortoolkit_neume.cpp | 57 +++++++++++++------------------------ 1 file changed, 19 insertions(+), 38 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index e484b8fbd5b..595b02139e6 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2519,6 +2519,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e fullParents.push_back(parentPair.first); } } + // if there are no full parents we need to make a new one to attach everything to if (fullParents.empty()) { if (elementClass == NC) { @@ -2526,10 +2527,18 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } else if (elementClass == NEUME) { parent = new Syllable(); + int lry; + int uly; for (auto it = elements.begin(); it != elements.end(); ++it) { - if ((*it)->GetParent() != parent && !(*it)->Is(SYL)) { - (*it)->MoveItselfTo(parent); + if ((*it)->GetParent() != parent) { + if (!(*it)->Is(SYL)) { + (*it)->MoveItselfTo(parent); + } + else { + lry = (*it)->GetFacsimileInterface()->GetZone()->GetLry(); + uly = (*it)->GetFacsimileInterface()->GetZone()->GetUly(); + } } } @@ -2545,43 +2554,15 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e if (m_doc->GetType() == Facs) { Zone *zone = new Zone(); - // if it's syllable parent has position values just use those - FacsimileInterface *syllableFi = NULL; - if (syl->GetFirstAncestor(SYLLABLE)->GetFacsimileInterface()->HasFacs()) { - syllableFi = syl->GetFirstAncestor(SYLLABLE)->GetFacsimileInterface(); - Zone *tempZone = dynamic_cast(syllableFi->GetZone()); - zone->SetUlx(tempZone->GetUlx()); - zone->SetUly(tempZone->GetUly()); - zone->SetLrx(tempZone->GetLrx()); - zone->SetLry(tempZone->GetLry()); - } - // otherwise get a boundingbox that comprises all the neumes in the syllable - else { - ListOfObjects children; - InterfaceComparison comp(INTERFACE_FACSIMILE); - syl->GetFirstAncestor(SYLLABLE)->FindAllDescendantsByComparison(&children, &comp); - for (auto iter2 = children.begin(); iter2 != children.end(); ++iter2) { - FacsimileInterface *temp = (*iter2)->GetFacsimileInterface(); - assert(temp); - Zone *tempZone = vrv_cast(temp->GetZone()); - assert(tempZone); - if (temp->HasFacs()) { - zone->SetUlx(tempZone->GetUlx()); - zone->SetUly(tempZone->GetUly()); - zone->SetLrx(tempZone->GetLrx()); - zone->SetLry(tempZone->GetLry()); - } - } - } - - // make the bounding box a little bigger and lower so it's easier to edit - const int offSetUly = 100; - const int offSetLrx = 100; - const int offSetLry = 200; + zone->SetUlx(parent->GetFirst(NC)->GetFacsimileInterface()->GetZone()->GetUlx()); + zone->SetUly(uly); + zone->SetLrx(parent->GetLast(NC)->GetFacsimileInterface()->GetZone()->GetLrx()); + zone->SetLry(lry); - zone->SetUly(zone->GetUly() + offSetUly); - zone->SetLrx(zone->GetLrx() + offSetLrx); - zone->SetLry(zone->GetLry() + offSetLry); + // Make bbox larger if it has less than 2 ncs + if (parent->GetChildCount(NC, 2) <= 2) { + zone->SetLrx(zone->GetLrx() + 50); + } assert(m_doc->GetFacsimile()); m_doc->GetFacsimile()->FindDescendantByType(SURFACE)->AddChild(zone); From 83a727666a20ae11c2342556de7e5bf356b266ea Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 31 Jul 2023 13:30:20 -0400 Subject: [PATCH 24/91] Optimize reordering --- src/editortoolkit_neume.cpp | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 595b02139e6..cb920b9db20 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2572,12 +2572,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } } - parent->ReorderByXPos(); secondParent->AddChild(parent); - - Layer *layer = vrv_cast(parent->GetFirstAncestor(LAYER)); - assert(layer); - layer->ReorderByXPos(); } // if there's only one full parent we just add the other elements to it @@ -2590,7 +2585,6 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e (*it)->MoveItselfTo(parent); } } - parent->ReorderByXPos(); } // if there is more than 1 full parent we need to concat syl's @@ -2602,20 +2596,9 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e for (auto it = elements.begin(); it != elements.end(); ++it) { if ((*it)->GetParent() != parent && !(*it)->Is(SYL)) { (*it)->MoveItselfTo(parent); - parent->ReorderByXPos(); } } secondParent->AddChild(parent); - - Layer *layer = dynamic_cast(parent->GetFirstAncestor(LAYER)); - if (!layer) { - LogError("Elements does not have Layer parent. This should not happen."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Elements does not have Layer parent."); - return false; - } - - layer->ReorderByXPos(); } else { std::sort(fullParents.begin(), fullParents.end(), Object::sortByUlx); @@ -2688,8 +2671,6 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e return false; } secondParent->AddChild(fullSyllable); - Layer *layer = vrv_cast(fullSyllable->GetFirstAncestor(LAYER)); - assert(layer); if (ulx >= 0 && uly >= 0 && lrx >= 0 && lry >= 0) { FacsimileInterface *facsInter = vrv_cast(fullSyl->GetFacsimileInterface()); assert(facsInter); @@ -2704,7 +2685,6 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e assert(lry >= 0); zone->SetLry(lry); } - layer->ReorderByXPos(); parent = fullSyllable; } } @@ -2765,6 +2745,10 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } } + Layer *layer = dynamic_cast(parent->GetFirstAncestor(LAYER)); + assert(layer); + layer->ReorderByXPos(); + m_infoObject.import("uuid", parent->GetID()); m_infoObject.import("status", status); m_infoObject.import("message", message); From ecc5cbb9e0d5cbc9562f5111aa5133200fc19d2a Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 31 Jul 2023 15:48:36 -0400 Subject: [PATCH 25/91] Rename fullSyllable to parent --- src/editortoolkit_neume.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index cb920b9db20..c82401bc2c0 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2602,7 +2602,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } else { std::sort(fullParents.begin(), fullParents.end(), Object::sortByUlx); - Syllable *fullSyllable = new Syllable(); + Syllable *parent = new Syllable(); Syl *fullSyl = NULL; // construct concatenated string of all the syls @@ -2656,13 +2656,13 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e Text *text = vrv_cast(fullSyl->FindDescendantByType(TEXT)); assert(text); text->SetText(fullString); - assert(fullSyllable); - fullSyllable->AddChild(fullSyl); + assert(parent); + parent->AddChild(fullSyl); // Move elements to the new group syllable for (auto it = elements.begin(); it != elements.end(); ++it) { - if ((*it)->GetParent() != fullSyllable && !(*it)->Is(SYL)) { - (*it)->MoveItselfTo(fullSyllable); + if ((*it)->GetParent() != parent && !(*it)->Is(SYL)) { + (*it)->MoveItselfTo(parent); } } @@ -2670,7 +2670,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e LogError("No second level parent!"); return false; } - secondParent->AddChild(fullSyllable); + secondParent->AddChild(parent); if (ulx >= 0 && uly >= 0 && lrx >= 0 && lry >= 0) { FacsimileInterface *facsInter = vrv_cast(fullSyl->GetFacsimileInterface()); assert(facsInter); @@ -2685,7 +2685,6 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e assert(lry >= 0); zone->SetLry(lry); } - parent = fullSyllable; } } From 8fe8581088aedf6fda37f3cffbd99a5820a297f5 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Tue, 1 Aug 2023 16:15:37 -0400 Subject: [PATCH 26/91] Refactor multiple full parents --- src/editortoolkit_neume.cpp | 79 +++++++++++-------------------------- 1 file changed, 22 insertions(+), 57 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index c82401bc2c0..04d47a875c9 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2601,17 +2601,23 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e secondParent->AddChild(parent); } else { - std::sort(fullParents.begin(), fullParents.end(), Object::sortByUlx); Syllable *parent = new Syllable(); Syl *fullSyl = NULL; + int ulx, uly, lrx, lry; // construct concatenated string of all the syls std::u32string fullString = U""; for (auto it = fullParents.begin(); it != fullParents.end(); ++it) { Syl *syl = dynamic_cast((*it)->FindDescendantByType(SYL)); - if (syl != NULL) { + if (syl != NULL && m_doc->GetType() == Facs) { + Zone *zone = dynamic_cast(syl->GetFacsimileInterface()->GetZone()); + if (fullSyl == NULL) { fullSyl = syl; + ulx = zone->GetUlx(); + uly = zone->GetUly(); + lrx = zone->GetLrx(); + lry = zone->GetLry(); } Text *text = dynamic_cast(syl->FindDescendantByType(TEXT)); @@ -2619,46 +2625,13 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e std::u32string currentString = text->GetText(); fullString = fullString + currentString; } + + ulx = zone->GetUlx() < ulx ? zone->GetUlx() : ulx; + uly = zone->GetUly() < uly ? zone->GetUly() : uly; + lrx = zone->GetLrx() > lrx ? zone->GetLrx() : lrx; + lry = zone->GetLry() > lry ? zone->GetLry() : lry; } } - // find the new boundingbox comprising all of the text - int ulx = -1, uly = -1, lrx = -1, lry = -1; - for (auto it = fullParents.begin(); it != fullParents.end(); ++it) { - Object *par = vrv_cast(*it); - assert(par); - Syl *descSyl = vrv_cast(par->FindDescendantByType(SYL)); - assert(descSyl); - // FacsimileInterface *facsInter = dynamic_cast - // ((*it)->FindDescendantByType(SYL)->GetFacsimileInterface()); - if (descSyl != NULL) { - FacsimileInterface *facsInter - = dynamic_cast(descSyl->GetFacsimileInterface()); - - if (facsInter != NULL) { - if (ulx == -1 || ulx > facsInter->GetDrawingX()) { - ulx = facsInter->GetDrawingX(); - } - - if (lrx < facsInter->GetWidth() + facsInter->GetDrawingX()) { - lrx = facsInter->GetWidth() + facsInter->GetDrawingX(); - } - - if (uly == -1 || uly > facsInter->GetDrawingY()) { - uly = facsInter->GetDrawingY(); - } - if (lry < facsInter->GetHeight() + facsInter->GetDrawingY()) { - lry = facsInter->GetHeight() + facsInter->GetDrawingY(); - } - } - } - } - assert(fullSyl); - Text *text = vrv_cast(fullSyl->FindDescendantByType(TEXT)); - assert(text); - text->SetText(fullString); - assert(parent); - parent->AddChild(fullSyl); - // Move elements to the new group syllable for (auto it = elements.begin(); it != elements.end(); ++it) { if ((*it)->GetParent() != parent && !(*it)->Is(SYL)) { @@ -2666,25 +2639,19 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } } - if (secondParent == NULL) { - LogError("No second level parent!"); - return false; - } - secondParent->AddChild(parent); - if (ulx >= 0 && uly >= 0 && lrx >= 0 && lry >= 0) { - FacsimileInterface *facsInter = vrv_cast(fullSyl->GetFacsimileInterface()); - assert(facsInter); - Zone *zone = vrv_cast(facsInter->GetZone()); - assert(zone); - assert(ulx >= 0); + Text *fullText = dynamic_cast(fullSyl->FindDescendantByType(TEXT)); + fullText->SetText(fullString); + parent->AddChild(fullSyl); + + if (m_doc->GetType() == Facs) { + Zone *zone = dynamic_cast(fullSyl->GetFacsimileInterface()->GetZone()); zone->SetUlx(ulx); - assert(uly >= 0); zone->SetUly(uly); - assert(lrx >= 0); zone->SetLrx(lrx); - assert(lry >= 0); zone->SetLry(lry); } + + secondParent->AddChild(parent); } } @@ -2744,9 +2711,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } } - Layer *layer = dynamic_cast(parent->GetFirstAncestor(LAYER)); - assert(layer); - layer->ReorderByXPos(); + secondParent->ReorderByXPos(); m_infoObject.import("uuid", parent->GetID()); m_infoObject.import("status", status); From c631643c099d739dfa6835d20fc3dfb393cdd687 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Tue, 1 Aug 2023 18:05:45 -0400 Subject: [PATCH 27/91] Fix bbox calculation for empty full parent --- src/editortoolkit_neume.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 04d47a875c9..de6db9e906a 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2527,18 +2527,11 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } else if (elementClass == NEUME) { parent = new Syllable(); - int lry; - int uly; + Object *oldSyl = (*elements.begin())->GetFirstAncestor(SYLLABLE)->GetFirst(SYL); for (auto it = elements.begin(); it != elements.end(); ++it) { - if ((*it)->GetParent() != parent) { - if (!(*it)->Is(SYL)) { - (*it)->MoveItselfTo(parent); - } - else { - lry = (*it)->GetFacsimileInterface()->GetZone()->GetLry(); - uly = (*it)->GetFacsimileInterface()->GetZone()->GetUly(); - } + if (!(*it)->Is(SYL)) { + (*it)->MoveItselfTo(parent); } } @@ -2554,10 +2547,10 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e if (m_doc->GetType() == Facs) { Zone *zone = new Zone(); - zone->SetUlx(parent->GetFirst(NC)->GetFacsimileInterface()->GetZone()->GetUlx()); - zone->SetUly(uly); - zone->SetLrx(parent->GetLast(NC)->GetFacsimileInterface()->GetZone()->GetLrx()); - zone->SetLry(lry); + zone->SetUlx(parent->GetFirst(NEUME)->GetFirst(NC)->GetFacsimileInterface()->GetZone()->GetUlx()); + zone->SetUly(oldSyl->GetFacsimileInterface()->GetZone()->GetUly()); + zone->SetLrx(parent->GetLast(NEUME)->GetLast(NC)->GetFacsimileInterface()->GetZone()->GetLrx()); + zone->SetLry(oldSyl->GetFacsimileInterface()->GetZone()->GetLry()); // Make bbox larger if it has less than 2 ncs if (parent->GetChildCount(NC, 2) <= 2) { @@ -2566,7 +2559,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e assert(m_doc->GetFacsimile()); m_doc->GetFacsimile()->FindDescendantByType(SURFACE)->AddChild(zone); - FacsimileInterface *fi = vrv_cast((*syl).GetFacsimileInterface()); + FacsimileInterface *fi = syl->GetFacsimileInterface(); assert(fi); fi->AttachZone(zone); } From 0b6f65492b7af2135018370d45729e378c6bde19 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Tue, 1 Aug 2023 18:10:30 -0400 Subject: [PATCH 28/91] Remove unnecessary checks & reordering --- src/editortoolkit_neume.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index de6db9e906a..f137fada668 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2668,10 +2668,6 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e Object *obj = (*it).first; obj->ClearRelinquishedChildren(); if (obj->GetChildCount() == 0) { - if (secondParent == NULL) { - LogError("No second level parent!"); - return false; - } secondParent->DeleteChild(obj); } else if (obj->GetChildCount() @@ -2683,23 +2679,16 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } while ((leftover = obj->FindDescendantByType(DIVLINE)) != NULL) { leftover->MoveItselfTo(parent); - parent->ReorderByXPos(); obj->ClearRelinquishedChildren(); } while ((leftover = obj->FindDescendantByType(ACCID)) != NULL) { leftover->MoveItselfTo(parent); - parent->ReorderByXPos(); obj->ClearRelinquishedChildren(); } while ((leftover = obj->FindDescendantByType(CLEF)) != NULL) { leftover->MoveItselfTo(parent); - parent->ReorderByXPos(); obj->ClearRelinquishedChildren(); } - if (secondParent == NULL) { - LogError("No second level parent!"); - return false; - } secondParent->DeleteChild(obj); } } From fabe667bf59430aa2216401b60241ec3c7762d68 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Tue, 1 Aug 2023 18:14:44 -0400 Subject: [PATCH 29/91] Remove unused variable --- src/editortoolkit_neume.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index f137fada668..59fbe82b1f4 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -1637,11 +1637,9 @@ bool EditorToolkitNeume::MatchHeight(std::string elementId) int ulx; int uly; int height; - int lrx; if (dynamic_cast(element)->HasFacs()) { ulx = element->GetFacsimileInterface()->GetZone()->GetUlx(); uly = element->GetFacsimileInterface()->GetZone()->GetUly(); - lrx = element->GetFacsimileInterface()->GetZone()->GetLrx(); height = element->GetFacsimileInterface()->GetZone()->GetLry() - uly; } else { From 926131e8f0365e8eb752f3654da35d26ff41c8ba Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Wed, 2 Aug 2023 16:12:11 -0400 Subject: [PATCH 30/91] Preserve ordering of multiple ligated nc in the same neume --- src/object.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/object.cpp b/src/object.cpp index 17b6f97426c..113358a8d69 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -1298,7 +1298,10 @@ bool Object::sortByUlx(Object *a, Object *b) if (a->Is(NC) && b->Is(NC)) { Nc *nca = dynamic_cast(a); Nc *ncb = dynamic_cast(b); - if (nca->HasLigated() && ncb->HasLigated() && (a->GetParent() == b->GetParent())) { + Zone *zonea = dynamic_cast(nca->GetFacsimileInterface()->GetZone()); + Zone *zoneb = dynamic_cast(ncb->GetFacsimileInterface()->GetZone()); + if (nca->HasLigated() && ncb->HasLigated() && (a->GetParent() == b->GetParent()) + && (zonea->GetUlx() == zoneb->GetUly())) { Object *parent = a->GetParent(); assert(parent); if (abs(parent->GetChildIndex(a) - parent->GetChildIndex(b)) == 1) { From 0fa95a9b6be39ac9512a8b2e9abe5f82a741f0f1 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Thu, 3 Aug 2023 10:41:03 -0400 Subject: [PATCH 31/91] Add validity check && correction --- src/object.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/object.cpp b/src/object.cpp index 113358a8d69..63e8fa0ca2d 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -1299,9 +1299,11 @@ bool Object::sortByUlx(Object *a, Object *b) Nc *nca = dynamic_cast(a); Nc *ncb = dynamic_cast(b); Zone *zonea = dynamic_cast(nca->GetFacsimileInterface()->GetZone()); + assert(zonea); Zone *zoneb = dynamic_cast(ncb->GetFacsimileInterface()->GetZone()); + assert(zoneb); if (nca->HasLigated() && ncb->HasLigated() && (a->GetParent() == b->GetParent()) - && (zonea->GetUlx() == zoneb->GetUly())) { + && (zonea->GetUlx() == zoneb->GetUlx())) { Object *parent = a->GetParent(); assert(parent); if (abs(parent->GetChildIndex(a) - parent->GetChildIndex(b)) == 1) { From 8f93fd319911cafe2301bebc3cdfe980f8f20c75 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 14 Aug 2023 14:37:15 -0400 Subject: [PATCH 32/91] Convert m_infoObject to m_editInfo --- include/vrv/editortoolkit_neume.h | 7 +- src/editortoolkit_neume.cpp | 622 +++++++++++++++--------------- 2 files changed, 315 insertions(+), 314 deletions(-) diff --git a/include/vrv/editortoolkit_neume.h b/include/vrv/editortoolkit_neume.h index a31242d2970..108b50e5266 100644 --- a/include/vrv/editortoolkit_neume.h +++ b/include/vrv/editortoolkit_neume.h @@ -31,8 +31,8 @@ namespace vrv { class EditorToolkitNeume : public EditorToolkit { public: EditorToolkitNeume(Doc *doc, View *view) : EditorToolkit(doc, view) {} - bool ParseEditorAction(const std::string &json_editorAction); - virtual std::string EditInfo() { return m_infoObject.json(); }; + bool ParseEditorAction(const std::string &json_editorAction) override; + std::string EditInfo() override; /** * Experimental editor functions. @@ -100,9 +100,6 @@ class EditorToolkitNeume : public EditorToolkit { bool AdjustPitchFromPosition(Object *obj, Clef *clef = NULL); bool AdjustClefLineFromPosition(Clef *clef, Staff *staff = NULL); ///@} - -private: - jsonxx::Object m_infoObject; }; //-------------------------------------------------------------------------------- diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 59fbe82b1f4..38fde2bee57 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -40,25 +40,29 @@ //-------------------------------------------------------------------------------- namespace vrv { +std::string EditorToolkitNeume::EditInfo() +{ + return m_editInfo.json(); +} bool EditorToolkitNeume::ParseEditorAction(const std::string &json_editorAction) { jsonxx::Object json; - m_infoObject.reset(); + // m_editInfo.reset(); // Read JSON actions if (!json.parse(json_editorAction)) { LogError("Cannot parse JSON std::string."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Cannot parse JSON from std::string " + json_editorAction); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Cannot parse JSON from std::string " + json_editorAction); return false; } if (!json.has("action") || (!json.has("param") && !json.has("param"))) { LogWarning("Incorrectly formatted JSON action"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "JSON action misformatted."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "JSON action misformatted."); return false; } @@ -66,8 +70,8 @@ bool EditorToolkitNeume::ParseEditorAction(const std::string &json_editorAction) if (action != "chain" && json.has("param")) { LogWarning("Only 'chain' uses 'param' as an array."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "'param' can only be an array for a chain action."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "'param' can only be an array for a chain action."); return false; } @@ -238,8 +242,8 @@ bool EditorToolkitNeume::ParseEditorAction(const std::string &json_editorAction) else { LogWarning("Unknown action type '%s'.", action.c_str()); } - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Action " + action + " could not be parsed or is unknown."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Action " + action + " could not be parsed or is unknown."); return false; } @@ -251,15 +255,15 @@ bool EditorToolkitNeume::Chain(jsonxx::Array actions) for (int i = 0; i < (int)actions.size(); i++) { if (!actions.has(0)) { LogError("Action %d was not an object", i); - m_infoObject.reset(); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Action " + std::to_string(i) + " was not an object."); + m_editInfo.reset(); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Action " + std::to_string(i) + " was not an object."); return false; } status |= this->ParseEditorAction(actions.get(i).json()); - results.import(std::to_string(i), m_infoObject); + results.import(std::to_string(i), m_editInfo); } - m_infoObject = results; + m_editInfo = results; return status; } @@ -480,8 +484,8 @@ bool EditorToolkitNeume::Drag(std::string elementId, int x, int y) std::string status = "OK", message = ""; if (!m_doc->GetDrawingPage()) { LogError("Could not get drawing page."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get drawing page."); return false; } @@ -513,8 +517,8 @@ bool EditorToolkitNeume::Drag(std::string elementId, int x, int y) Layer *layer = dynamic_cast(element->GetFirstAncestor(LAYER)); if (!layer) { LogError("Element does not have Layer parent. This should not happen."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Element does not have Layer parent."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Element does not have Layer parent."); return false; } @@ -593,8 +597,8 @@ bool EditorToolkitNeume::Drag(std::string elementId, int x, int y) Clef *clef = dynamic_cast(element); if (!clef->HasFacs()) { LogError("Clef dragging is only supported for clefs with facsimiles!"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Clef dragging is only supported for clefs with facsimiles."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Clef dragging is only supported for clefs with facsimiles."); return false; } FacsimileInterface *fi = (*clef).GetFacsimileInterface(); @@ -645,8 +649,8 @@ bool EditorToolkitNeume::Drag(std::string elementId, int x, int y) Staff *staff = vrv_cast(element); if (!staff->HasFacs()) { LogError("Staff dragging is only supported for staves with facsimiles!"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Staff dragging is only supported for staves with facsimiles."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Staff dragging is only supported for staves with facsimiles."); return false; } @@ -674,8 +678,8 @@ bool EditorToolkitNeume::Drag(std::string elementId, int x, int y) Syl *syl = dynamic_cast(element); if (!syl->HasFacs()) { LogError("Syl (boundingbox) dragging is only supported for syls with facsimiles!"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Syl dragging is only supported for syls with facsimiles."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Syl dragging is only supported for syls with facsimiles."); return false; } FacsimileInterface *fi = (*syl).GetFacsimileInterface(); @@ -688,8 +692,8 @@ bool EditorToolkitNeume::Drag(std::string elementId, int x, int y) Accid *accid = dynamic_cast(element); if (!accid->HasFacs()) { LogError("Accid dragging is only supported for accid with facsimiles!"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Accid dragging is only supported for accid with facsimiles."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Accid dragging is only supported for accid with facsimiles."); return false; } FacsimileInterface *fi = (*accid).GetFacsimileInterface(); @@ -705,8 +709,8 @@ bool EditorToolkitNeume::Drag(std::string elementId, int x, int y) DivLine *divLine = dynamic_cast(element); if (!divLine->HasFacs()) { LogError("DivLine dragging is only supported for divLine with facsimiles!"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "DivLine dragging is only supported for divLine with facsimiles."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "DivLine dragging is only supported for divLine with facsimiles."); return false; } FacsimileInterface *fi = (*divLine).GetFacsimileInterface(); @@ -720,14 +724,14 @@ bool EditorToolkitNeume::Drag(std::string elementId, int x, int y) } else { LogWarning("Unsupported element for dragging."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Unsupported element for dragging."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Unsupported element for dragging."); return false; } Layer *layer = vrv_cast(element->GetFirstAncestor(LAYER)); layer->ReorderByXPos(); // Reflect position order of elements internally (and in the resulting output file) - m_infoObject.import("status", status); - m_infoObject.import("message", message); + m_editInfo.import("status", status); + m_editInfo.import("message", message); return true; } @@ -736,14 +740,14 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in { if (!m_doc->GetDrawingPage()) { LogError("Could not get drawing page"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get drawing page."); return false; } if (m_doc->GetType() != Facs) { LogError("Drawing page without facsimile"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Drawing page without facsimile is unsupported."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Drawing page without facsimile is unsupported."); return false; } @@ -820,9 +824,9 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in parent->InsertChild(newStaff, i); parent->Modify(); - m_infoObject.import("uuid", newStaff->GetID()); - m_infoObject.import("status", status); - m_infoObject.import("message", message); + m_editInfo.import("uuid", newStaff->GetID()); + m_editInfo.import("status", status); + m_editInfo.import("message", message); return true; } @@ -832,17 +836,17 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in parent->AddChild(newStaff); parent->Modify(); - m_infoObject.import("uuid", newStaff->GetID()); - m_infoObject.import("status", status); - m_infoObject.import("message", message); + m_editInfo.import("uuid", newStaff->GetID()); + m_editInfo.import("status", status); + m_editInfo.import("message", message); return true; } if (staff == NULL) { LogError("A staff must exist in the page to add a non-staff element."); delete zone; - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "A staff must exist in the page to add a non-staff element."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "A staff must exist in the page to add a non-staff element."); return false; } Layer *layer = vrv_cast(staff->FindDescendantByType(LAYER)); @@ -929,8 +933,8 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in delete nc; LogError("Failed to set pitch."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Failed to set pitch."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Failed to set pitch."); return false; } @@ -992,8 +996,8 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in LogError("Unsupported character in contour."); delete newNc; delete newZone; - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Unsupported character in contour."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Unsupported character in contour."); return false; } @@ -1018,10 +1022,10 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in } } if (elementType == "nc") { - m_infoObject.import("uuid", nc->GetID()); + m_editInfo.import("uuid", nc->GetID()); } else { - m_infoObject.import("uuid", neume->GetID()); + m_editInfo.import("uuid", neume->GetID()); } } else if (elementType == "clef") { @@ -1046,8 +1050,8 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in LogError("A clef shape must be specified."); delete clef; - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "A clef shape must be specified."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "A clef shape must be specified."); return false; } clef->SetShape(clefShape); @@ -1068,7 +1072,7 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in assert(surface); surface->AddChild(zone); layer->AddChild(clef); - m_infoObject.import("uuid", clef->GetID()); + m_editInfo.import("uuid", clef->GetID()); layer->ReorderByXPos(); // ensure pitched elements associated with this clef keep their x,y positions @@ -1119,11 +1123,11 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in if (!AdjustPitchFromPosition(custos)) { LogError("Failed to set pitch."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Failed to set pitch."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Failed to set pitch."); return false; } - m_infoObject.import("uuid", custos->GetID()); + m_editInfo.import("uuid", custos->GetID()); } else if (elementType == "accid") { Accid *accid = new Accid(); @@ -1144,8 +1148,8 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in LogError("A accid type must be specified."); delete accid; - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "A accid type must be specified."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "A accid type must be specified."); return false; } @@ -1170,7 +1174,7 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in zone->SetLry(uly + noteHeight); layer->ReorderByXPos(); - m_infoObject.import("uuid", accid->GetID()); + m_editInfo.import("uuid", accid->GetID()); } else if (elementType == "divLine") { DivLine *divLine = new DivLine(); @@ -1208,8 +1212,8 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in LogError("A divLine type must be specified."); delete divLine; - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "A divLine type must be specified."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "A divLine type must be specified."); return false; } @@ -1234,18 +1238,18 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in zone->SetLry(uly + noteHeight); layer->ReorderByXPos(); - m_infoObject.import("uuid", divLine->GetID()); + m_editInfo.import("uuid", divLine->GetID()); } else { delete zone; LogError("Unsupported type '%s' for insertion", elementType.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Unsupported type '" + elementType + "' for insertion."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Unsupported type '" + elementType + "' for insertion."); return false; } layer->ReorderByXPos(); - m_infoObject.import("status", status); - m_infoObject.import("message", message); + m_editInfo.import("status", status); + m_editInfo.import("message", message); return true; } @@ -1253,14 +1257,14 @@ bool EditorToolkitNeume::InsertToSyllable(std::string elementId) { if (!m_doc->GetDrawingPage()) { LogError("Could not get drawing page"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get drawing page."); return false; } if (m_doc->GetType() != Facs) { LogError("Drawing page without facsimile"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Drawing page without facsimile is unsupported."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Drawing page without facsimile is unsupported."); return false; } @@ -1271,23 +1275,23 @@ bool EditorToolkitNeume::InsertToSyllable(std::string elementId) if (element == NULL) { LogError("No element exists with ID '%s'.", elementId.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "No element exists with ID" + elementId + "."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "No element exists with ID" + elementId + "."); return false; } if (!(element->Is(DIVLINE) || element->Is(ACCID) || element->Is(CLEF))) { LogError("Element is of type %s, but only Divlines and Accids can be inserted into syllables.", element->GetClassName().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Element is of type " + element->GetClassName() + ", but only DivLines, Accids, and Clefs can be inserted into syllables."); return false; } if (!parent->Is(LAYER)) { LogError("The selected %s is not a child of layer.", element->GetClassName().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "The selected " + element->GetClassName() + "is not a child of layer."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "The selected " + element->GetClassName() + "is not a child of layer."); return false; } @@ -1300,8 +1304,8 @@ bool EditorToolkitNeume::InsertToSyllable(std::string elementId) } else { LogError("Selected '%s' without facsimile", element->GetClassName().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Selected '" + element->GetClassName() + "' without facsimile is unsupported."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Selected '" + element->GetClassName() + "' without facsimile is unsupported."); return false; } @@ -1325,8 +1329,8 @@ bool EditorToolkitNeume::InsertToSyllable(std::string elementId) } else { LogError("A syllable must exist in the staff to insert a '%s' into.", element->GetClassName().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import( + m_editInfo.import("status", "FAILURE"); + m_editInfo.import( "message", "A syllable must exist in the staff to insert a '" + element->GetClassName() + "' into."); return false; } @@ -1396,8 +1400,8 @@ bool EditorToolkitNeume::InsertToSyllable(std::string elementId) } } - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); return true; } @@ -1405,14 +1409,14 @@ bool EditorToolkitNeume::MoveOutsideSyllable(std::string elementId) { if (!m_doc->GetDrawingPage()) { LogError("Could not get drawing page"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get drawing page."); return false; } if (m_doc->GetType() != Facs) { LogError("Drawing page without facsimile"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Drawing page without facsimile is unsupported."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Drawing page without facsimile is unsupported."); return false; } @@ -1423,23 +1427,23 @@ bool EditorToolkitNeume::MoveOutsideSyllable(std::string elementId) if (element == NULL) { LogError("No element exists with ID '%s'.", elementId.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "No element exists with ID" + elementId + "."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "No element exists with ID" + elementId + "."); return false; } if (!(element->Is(DIVLINE) || element->Is(ACCID) || element->Is(CLEF))) { LogError("Element is of type %s, but only Divlines, Accids, and Clefs can be moved out of syllables.", element->GetClassName().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Element is of type " + element->GetClassName() + ", but only DivLines and Accids can be inserted into syllables."); return false; } if (!parent->Is(SYLLABLE)) { LogError("The selected %s is not a child of syllable.", element->GetClassName().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "The selected " + element->GetClassName() + "is not a child of syllable."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "The selected " + element->GetClassName() + "is not a child of syllable."); return false; } @@ -1519,8 +1523,8 @@ bool EditorToolkitNeume::MoveOutsideSyllable(std::string elementId) // INSIDE do nothing } - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); return true; } @@ -1528,15 +1532,15 @@ bool EditorToolkitNeume::DisplaceClefOctave(std::string elementId, std::string d { if (!m_doc->GetDrawingPage()) { LogError("Could not get the drawing page."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the drawing page."); return false; } if (direction != "above" && direction != "below") { LogError("Direction can only be either \"above\" or \"below\"."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Direction can only be either \"above\" or \"below\"."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Direction can only be either \"above\" or \"below\"."); return false; } @@ -1544,8 +1548,8 @@ bool EditorToolkitNeume::DisplaceClefOctave(std::string elementId, std::string d Object *obj = page->FindDescendantByID(elementId); if (obj == NULL || !obj->Is(CLEF)) { LogError("This action can only be done on clefs!"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "This action can only be done on clefs!"); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "This action can only be done on clefs!"); return false; } @@ -1560,8 +1564,8 @@ bool EditorToolkitNeume::DisplaceClefOctave(std::string elementId, std::string d if (octaveDis > 3 || octaveDis < -3) { LogError("Clefs can only be displaced 3 octaves."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Clefs can only be displaced 3 octaves."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Clefs can only be displaced 3 octaves."); return false; } @@ -1596,8 +1600,8 @@ bool EditorToolkitNeume::DisplaceClefOctave(std::string elementId, std::string d nc->SetOct(nc->GetOct() + move); }); - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); return true; } @@ -1605,14 +1609,14 @@ bool EditorToolkitNeume::MatchHeight(std::string elementId) { if (!m_doc->GetDrawingPage()) { LogError("Could not get drawing page"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get drawing page."); return false; } if (m_doc->GetType() != Facs) { LogError("Drawing page without facsimile"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Drawing page without facsimile is unsupported."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Drawing page without facsimile is unsupported."); return false; } @@ -1621,14 +1625,14 @@ bool EditorToolkitNeume::MatchHeight(std::string elementId) Object *staffParent = element->GetFirstAncestor(STAFF); if (element == NULL) { LogError("No element exists with ID '%s'.", elementId.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "No element exists with ID" + elementId + "."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "No element exists with ID" + elementId + "."); return false; } if (!element->Is(SYL)) { LogError("Element is of type %s, but only element can match height.", element->GetClassName().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import( + m_editInfo.import("status", "FAILURE"); + m_editInfo.import( "message", "Element is of type " + element->GetClassName() + ", but only element can match height."); return false; } @@ -1644,8 +1648,8 @@ bool EditorToolkitNeume::MatchHeight(std::string elementId) } else { LogError("Selected '%s' without facsimile", element->GetClassName().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Selected '" + element->GetClassName() + "' without facsimile is unsupported."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Selected '" + element->GetClassName() + "' without facsimile is unsupported."); return false; } @@ -1687,8 +1691,8 @@ bool EditorToolkitNeume::MatchHeight(std::string elementId) zone->SetLry(uly + offsetY + height); } - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); return true; } @@ -1705,15 +1709,15 @@ bool EditorToolkitNeume::Merge(std::vector elementIds) } else { LogError("Staff with ID '%s' does not exist!", it->c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Staff with ID '" + *it + "' does not exist."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Staff with ID '" + *it + "' does not exist."); return false; } } if (staves.size() < 2) { LogError("At least two staves must be provided."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "At least two staves must be provided."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "At least two staves must be provided."); return false; } @@ -1774,9 +1778,9 @@ bool EditorToolkitNeume::Merge(std::vector elementIds) fillLayer->ReorderByXPos(); - m_infoObject.import("uuid", fillStaff->GetID()); - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); + m_editInfo.import("uuid", fillStaff->GetID()); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); // TODO change zones for staff children @@ -1818,8 +1822,8 @@ bool EditorToolkitNeume::Set(std::string elementId, std::string attrType, std::s m_doc->PrepareData(); m_doc->GetDrawingPage()->LayOut(true); } - m_infoObject.import("status", success ? "OK" : "FAILURE"); - m_infoObject.import("message", success ? "" : "Could not set attribute '" + attrType + "' to '" + attrValue + "'."); + m_editInfo.import("status", success ? "OK" : "FAILURE"); + m_editInfo.import("message", success ? "" : "Could not set attribute '" + attrType + "' to '" + attrValue + "'."); return success; } @@ -1829,15 +1833,15 @@ bool EditorToolkitNeume::SetText(std::string elementId, const std::string &text) std::string status = "OK", message = ""; const std::u32string wtext = UTF8to32(text); if (!m_doc->GetDrawingPage()) { - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not find drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not find drawing page."); return false; } Object *element = m_doc->GetDrawingPage()->FindDescendantByID(elementId); if (element == NULL) { LogWarning("No element with ID '%s' exists", elementId.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "No element with ID '" + elementId + "' exists."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "No element with ID '" + elementId + "' exists."); return false; } @@ -1921,12 +1925,12 @@ bool EditorToolkitNeume::SetText(std::string elementId, const std::string &text) } else { LogError("Element type '%s' is unsupported for SetText", element->GetClassName().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Element type '" + element->GetClassName() + "' is unsupported for SetText."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Element type '" + element->GetClassName() + "' is unsupported for SetText."); return false; } - m_infoObject.import("status", success ? status : "FAILURE"); - m_infoObject.import("message", success ? message : "SetText method failed."); + m_editInfo.import("status", success ? status : "FAILURE"); + m_editInfo.import("message", success ? message : "SetText method failed."); return success; } @@ -1934,8 +1938,8 @@ bool EditorToolkitNeume::SetClef(std::string elementId, std::string shape) { if (!m_doc->GetDrawingPage()) { LogError("Could not get the drawing page."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the drawing page."); return false; } ListOfObjects objects; @@ -1958,8 +1962,8 @@ bool EditorToolkitNeume::SetClef(std::string elementId, std::string shape) success = AttModule::SetShared(clef, "shape", shape); if (!success) { LogError("Unable to set clef shape"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Unable to set clef shape."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Unable to set clef shape."); return false; } @@ -1986,8 +1990,8 @@ bool EditorToolkitNeume::SetClef(std::string elementId, std::string shape) m_doc->PrepareData(); m_doc->GetDrawingPage()->LayOut(true); } - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); return true; } @@ -1995,23 +1999,23 @@ bool EditorToolkitNeume::Split(std::string elementId, int x) { if (!m_doc->GetDrawingPage()) { LogError("Could not get the drawing page"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the drawing page."); return false; } Staff *staff = dynamic_cast(m_doc->GetDrawingPage()->FindDescendantByID(elementId)); // Validate parameters if (staff == NULL) { LogError("Either no element exists with ID '%s' or it is not a staff.", elementId.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Either no element exists with ID '" + elementId + "' or it is not a staff."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Either no element exists with ID '" + elementId + "' or it is not a staff."); return false; } if (staff->GetZone()->GetUlx() > x || staff->GetZone()->GetLrx() < x) { LogError("The 'x' parameter is not within the bounds of the original staff."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "The 'x' parameter is not within bounds of the original staff."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "The 'x' parameter is not within bounds of the original staff."); return false; } @@ -2025,19 +2029,19 @@ bool EditorToolkitNeume::Split(std::string elementId, int x) if (!this->Insert("staff", "auto", newUlx, newUly, newLrx, newLry, v)) { LogError("Failed to create a second staff."); - m_infoObject.reset(); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Failed to create a second staff."); + m_editInfo.reset(); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Failed to create a second staff."); return false; } Staff *splitStaff - = dynamic_cast(m_doc->GetDrawingPage()->FindDescendantByID(m_infoObject.get("uuid"))); + = dynamic_cast(m_doc->GetDrawingPage()->FindDescendantByID(m_editInfo.get("uuid"))); assert(splitStaff); if (splitStaff == NULL) { LogError("Split staff is null"); - m_infoObject.reset(); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Split staff is null."); + m_editInfo.reset(); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Split staff is null."); return false; } @@ -2079,9 +2083,9 @@ bool EditorToolkitNeume::Split(std::string elementId, int x) } } layer->ClearRelinquishedChildren(); - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); - m_infoObject.import("uuid", splitStaff->GetID()); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); + m_editInfo.import("uuid", splitStaff->GetID()); return true; } @@ -2089,8 +2093,8 @@ bool EditorToolkitNeume::Remove(std::string elementId) { if (!m_doc->GetDrawingPage()) { LogError("Could not get the drawing page."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the drawing page."); return false; } Object *obj = m_doc->GetDrawingPage()->FindDescendantByID(elementId); @@ -2102,7 +2106,7 @@ bool EditorToolkitNeume::Remove(std::string elementId) isClef = obj->Is(CLEF); Object *parent = obj->GetParent(); assert(parent); - m_infoObject.import("uuid", elementId); + m_editInfo.import("uuid", elementId); // Remove Zone for element (if any) InterfaceComparison ic(INTERFACE_FACSIMILE); ListOfObjects fiChildren; @@ -2143,9 +2147,9 @@ bool EditorToolkitNeume::Remove(std::string elementId) if (!result) { LogError("Failed to delete the desired element (%s)", elementId.c_str()); - m_infoObject.reset(); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Failed to delete the desired element (" + elementId + ")."); + m_editInfo.reset(); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Failed to delete the desired element (" + elementId + ")."); return false; } @@ -2163,9 +2167,9 @@ bool EditorToolkitNeume::Remove(std::string elementId) if (!result) { LogError("Failed to delete the desired element (%s)", elementId.c_str()); - m_infoObject.reset(); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Failed to delete the desired element (" + elementId + ")."); + m_editInfo.reset(); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Failed to delete the desired element (" + elementId + ")."); return false; } // Check if this leaves any containers empty and delete them @@ -2179,9 +2183,9 @@ bool EditorToolkitNeume::Remove(std::string elementId) result &= parent->DeleteChild(obj); if (!result) { LogError("Failed to delete empty neume (%s)", neumeId.c_str()); - m_infoObject.reset(); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Failed to delete empty neume (" + neumeId + ")."); + m_editInfo.reset(); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Failed to delete empty neume (" + neumeId + ")."); return false; } } @@ -2209,16 +2213,16 @@ bool EditorToolkitNeume::Remove(std::string elementId) result &= parent->DeleteChild(obj); if (!result) { LogError("Failed to delete empty syllable (%s)", syllableId.c_str()); - m_infoObject.reset(); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Failed to delete empty syllable (" + syllableId + ")."); + m_editInfo.reset(); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Failed to delete empty syllable (" + syllableId + ")."); return false; } } } - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); return true; } @@ -2226,22 +2230,22 @@ bool EditorToolkitNeume::Resize(std::string elementId, int ulx, int uly, int lrx { if (!m_doc->GetDrawingPage()) { LogError("Could not get the drawing page."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the drawing page."); return false; } if (m_doc->GetType() != Facs) { LogWarning("Resizing is only available in facsimile mode."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Resizing is only available in facsimile mode."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Resizing is only available in facsimile mode."); return false; } Object *obj = m_doc->GetDrawingPage()->FindDescendantByID(elementId); if (obj == NULL) { LogError("Object with ID '%s' not found.", elementId.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Object with ID '" + elementId + "' could not be found."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Object with ID '" + elementId + "' could not be found."); return false; } if (obj->Is(STAFF)) { @@ -2249,8 +2253,8 @@ bool EditorToolkitNeume::Resize(std::string elementId, int ulx, int uly, int lrx assert(staff); if (!staff->HasFacs()) { LogError("This staff does not have a facsimile."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "This staff does not have a facsimile."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "This staff does not have a facsimile."); return false; } Zone *zone = staff->GetZone(); @@ -2270,8 +2274,8 @@ bool EditorToolkitNeume::Resize(std::string elementId, int ulx, int uly, int lrx assert(syl); if (!syl->HasFacs()) { LogError("This syl (bounding box) does not have a facsimile"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "This syl does not have a facsimile."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "This syl does not have a facsimile."); return false; } Zone *zone = syl->GetZone(); @@ -2301,12 +2305,12 @@ bool EditorToolkitNeume::Resize(std::string elementId, int ulx, int uly, int lrx } else { LogError("Element of type '%s' is unsupported.", obj->GetClassName().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Element of type '" + obj->GetClassName() + "' is unsupported."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Element of type '" + obj->GetClassName() + "' is unsupported."); return false; } - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); return true; } @@ -2323,16 +2327,16 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e // Get the current drawing page if (!m_doc->GetDrawingPage()) { LogError("Could not get the drawing page."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the drawing page."); return false; } if (elementIds.size() == 0) { LogWarning("No element IDs to group!"); status = "WARNING"; message = "No element IDs to group!"; - m_infoObject.import("status", status); - m_infoObject.import("message", message); + m_editInfo.import("status", status); + m_editInfo.import("message", message); return true; } ClassId elementClass; @@ -2344,8 +2348,8 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } else { LogError("Invalid groupType: %s", groupType.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Invalid groupType: " + groupType); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Invalid groupType: " + groupType); return false; } @@ -2355,15 +2359,15 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e Object *el = m_doc->GetDrawingPage()->FindDescendantByID(*it); if (el == NULL) { LogError("Could not get element with ID %s", it->c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get element with ID " + *it); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get element with ID " + *it); return false; } if (el->GetClassId() != elementClass) { LogError("Element %s was of class %s. Expected class %s", el->GetID().c_str(), el->GetClassName().c_str(), groupType.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Element " + el->GetID() + " was of class " + el->GetClassName() + " but expected class " + groupType + "."); return false; @@ -2373,8 +2377,8 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e Object *par = el->GetParent(); if (par == NULL) { LogError("Parent of %s is null!", el->GetID().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Parent of " + el->GetID() + " is null."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Parent of " + el->GetID() + " is null."); return false; } @@ -2402,20 +2406,20 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e std::vector elementIds0 = { elementIds.begin(), elementIds.begin() + idx }; Group("neume", elementIds0); - if (m_infoObject.get("status") == "FAILURE") { + if (m_editInfo.get("status") == "FAILURE") { resultId0 = linkedID; } else { - resultId0 = m_infoObject.get("uuid"); + resultId0 = m_editInfo.get("uuid"); } std::vector elementIds1 = { elementIds.begin() + idx, elementIds.end() }; Group("neume", elementIds1); - if (m_infoObject.get("status") == "FAILURE") { + if (m_editInfo.get("status") == "FAILURE") { resultId1 = par->GetID(); } else { - resultId1 = m_infoObject.get("uuid"); + resultId1 = m_editInfo.get("uuid"); par = m_doc->GetDrawingPage()->FindDescendantByID(resultId1); } @@ -2431,9 +2435,9 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e uuidArray << resultId0; uuidArray << resultId1; - m_infoObject.import("uuid", uuidArray); - m_infoObject.import("status", status); - m_infoObject.import("message", message); + m_editInfo.import("uuid", uuidArray); + m_editInfo.import("status", status); + m_editInfo.import("message", message); return true; } } @@ -2444,14 +2448,14 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e if (parents.size() == 0) { LogError("Could not get the parent."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the parent."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the parent."); return false; } else if (parents.size() == 1) { LogError("The selected elements are already grouped."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "The selected elements are already grouped."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "The selected elements are already grouped."); return false; } @@ -2492,8 +2496,8 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e secondParent = (*parents.begin()).first->GetParent(); if (secondParent == NULL) { LogError("No second level parent!"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "No second level parent."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "No second level parent."); return false; } // find parents where all of their children are being grouped @@ -2503,8 +2507,8 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e int expected; if (par->GetParent() != secondParent) { LogError("No shared second level parent!"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "No shared second level parent."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "No shared second level parent."); return false; } if (par->GetClassId() == SYLLABLE) { @@ -2693,9 +2697,9 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e secondParent->ReorderByXPos(); - m_infoObject.import("uuid", parent->GetID()); - m_infoObject.import("status", status); - m_infoObject.import("message", message); + m_editInfo.import("uuid", parent->GetID()); + m_editInfo.import("status", status); + m_editInfo.import("message", message); return true; } @@ -2730,8 +2734,8 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector // Check if you can get drawing page if (!m_doc->GetDrawingPage()) { LogError("Could not get the drawing page."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the drawing page."); return false; } @@ -2793,8 +2797,8 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector } else { LogError("Unable to toggle ligature within ungroup ncs!"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Unable to toggle ligature within ungroup ncs."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Unable to toggle ligature within ungroup ncs."); return false; } } @@ -2865,8 +2869,8 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector else { LogError("Invalid groupType for ungrouping"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Invalid groupType for ungrouping."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Invalid groupType for ungrouping."); return false; } } @@ -2968,9 +2972,9 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector } } - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); - m_infoObject.import("uuid", uuidArray); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); + m_editInfo.import("uuid", uuidArray); return true; } @@ -2979,8 +2983,8 @@ bool EditorToolkitNeume::SplitNeume(std::string neumeId, std::string ncId) // Check if you can get drawing page if (!m_doc->GetDrawingPage()) { LogError("Could not get the drawing page."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the drawing page."); return false; } @@ -3002,8 +3006,8 @@ bool EditorToolkitNeume::SplitNeume(std::string neumeId, std::string ncId) int nLen = fparent->GetChildCount(); if (nLen == 0) { LogError("The selected neume has no children."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "The selected neume has no children."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "The selected neume has no children."); return false; } @@ -3011,8 +3015,8 @@ bool EditorToolkitNeume::SplitNeume(std::string neumeId, std::string ncId) int fIdx = fparent->GetChildIndex(elNc); if (fIdx == -1) { LogError("The selected neume component is not a child of the selected neume."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "The selected neume component is not a child of the selected neume."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "The selected neume component is not a child of the selected neume."); return false; } // if click on a ligature, ncId point to the second nc in the ligature, thus minus 1 @@ -3046,9 +3050,9 @@ bool EditorToolkitNeume::SplitNeume(std::string neumeId, std::string ncId) // insert newParent to sparent sparent->InsertAfter(fparent, newParent); - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); - m_infoObject.import("uuid", uuidArray); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); + m_editInfo.import("uuid", uuidArray); return true; } @@ -3057,15 +3061,15 @@ bool EditorToolkitNeume::ChangeGroup(std::string elementId, std::string contour) // Check if you can get drawing page if (!m_doc->GetDrawingPage()) { LogError("Could not get the drawing page."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the drawing page."); return false; } Neume *el = dynamic_cast(m_doc->GetDrawingPage()->FindDescendantByID(elementId)); if (el == NULL) { LogError("Unable to find neume with id %s", elementId.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Unable to find neume with id " + elementId + "."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Unable to find neume with id " + elementId + "."); return false; } Nc *firstChild = NULL; @@ -3129,8 +3133,8 @@ bool EditorToolkitNeume::ChangeGroup(std::string elementId, std::string contour) LogError("Unsupported character in contour."); delete newNc; delete zone; - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Unsupported character in contour."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Unsupported character in contour."); return false; } zone->SetUlx(newUlx); @@ -3153,9 +3157,9 @@ bool EditorToolkitNeume::ChangeGroup(std::string elementId, std::string contour) initialLry = newLry; prevNc = newNc; } - m_infoObject.import("uuid", el->GetID()); - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); + m_editInfo.import("uuid", el->GetID()); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); return true; } @@ -3173,8 +3177,8 @@ bool EditorToolkitNeume::ToggleLigature(std::vector elementIds) // Check if you can get drawing page if (!m_doc->GetDrawingPage()) { LogError("Could not get the drawing page."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the drawing page."); return false; } @@ -3188,8 +3192,8 @@ bool EditorToolkitNeume::ToggleLigature(std::vector elementIds) int secondIdx = secondNc->GetIdx(); if (std::abs(firstIdx - secondIdx) != 1) { LogError("The selected ncs are not adjacent."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "The selected ncs are not adjacent."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "The selected ncs are not adjacent."); return false; } @@ -3247,20 +3251,20 @@ bool EditorToolkitNeume::ToggleLigature(std::vector elementIds) } // else { // LogError("isLigature is invalid!"); - // m_infoObject.import("status", "FAILURE"); - // m_infoObject.import("message", "isLigature value '" + 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_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); if (!(success1 && success2)) { LogWarning("Unable to update ligature attribute"); - m_infoObject.import("message", "Unable to update ligature attribute."); - m_infoObject.import("status", "WARNING"); + m_editInfo.import("message", "Unable to update ligature attribute."); + m_editInfo.import("status", "WARNING"); } surface->AddChild(zone); @@ -3271,15 +3275,15 @@ bool EditorToolkitNeume::ChangeStaff(std::string elementId) { if (!m_doc->GetDrawingPage()) { LogError("Could not get the drawing page"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the drawing page."); return false; } if (m_doc->GetType() != Facs) { LogWarning("Staff re-association is only available in facsimile mode."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "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."); return false; } @@ -3287,8 +3291,8 @@ bool EditorToolkitNeume::ChangeStaff(std::string elementId) assert(element); if (element == NULL) { LogError("No element exists with ID '%s'.", elementId.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "No element exists with ID" + elementId + "."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "No element exists with ID" + elementId + "."); return false; } @@ -3296,8 +3300,8 @@ bool EditorToolkitNeume::ChangeStaff(std::string elementId) || element->Is(ACCID))) { LogError("Element is of type %s, but only Syllables, Custos, Clefs, Divlines, and Accids can change staves.", element->GetClassName().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Element is of type " + element->GetClassName() + ", but only Syllables, Custos, Clefs, DivLines, and Accids can change staves."); return false; @@ -3318,8 +3322,8 @@ bool EditorToolkitNeume::ChangeStaff(std::string elementId) LayerElement *layerElement = dynamic_cast(element); if (!layerElement->GenerateZoneBounds(&ulx, &uly, &lrx, &lry)) { LogError("Couldn't generate bounding box for syllable."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Couldn't generate bounding box for syllable."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Couldn't generate bounding box for syllable."); return false; } comp.x = (lrx + ulx) / 2; @@ -3327,8 +3331,8 @@ bool EditorToolkitNeume::ChangeStaff(std::string elementId) } else { LogError("This element does not have a facsimile."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "This element does not have a facsimile."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "This element does not have a facsimile."); return false; } @@ -3341,8 +3345,8 @@ bool EditorToolkitNeume::ChangeStaff(std::string elementId) } else { LogError("Could not find any staves. This should not happen"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not find any staves. This should not happen"); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not find any staves. This should not happen"); return false; } @@ -3351,8 +3355,8 @@ bool EditorToolkitNeume::ChangeStaff(std::string elementId) assert(parent); if (parent == NULL || sParent == NULL) { LogError("Couldn't find staff parent of element with id '%s'", elementId.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Couldn't find staff parent of element with id " + elementId); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Couldn't find staff parent of element with id " + elementId); return false; } @@ -3360,16 +3364,16 @@ bool EditorToolkitNeume::ChangeStaff(std::string elementId) assert(LAYER); if (layer == NULL) { LogError("Couldn't find layer child of staff. This should not happen"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Couldn't find layer child of staff. This should not happen"); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Couldn't find layer child of staff. This should not happen"); return false; } if (layer == parent) { - m_infoObject.import("status", "WARNING"); - m_infoObject.import("message", "Moving to the same staff as before."); - m_infoObject.import("elementId", elementId); - m_infoObject.import("newStaffId", staff->GetID()); + m_editInfo.import("status", "WARNING"); + m_editInfo.import("message", "Moving to the same staff as before."); + m_editInfo.import("elementId", elementId); + m_editInfo.import("newStaffId", staff->GetID()); return true; } @@ -3427,8 +3431,8 @@ bool EditorToolkitNeume::ChangeStaff(std::string elementId) // Adjust clefline if (!AdjustClefLineFromPosition(dynamic_cast(element), staff)) { LogError("Could not adjust clef line of %s", element->GetID().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Failed to set clef line from facsimile."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Failed to set clef line from facsimile."); return false; } @@ -3456,19 +3460,19 @@ bool EditorToolkitNeume::ChangeStaff(std::string elementId) if (!(element->Is(ACCID) || element->Is(DIVLINE))) { if (!AdjustPitchFromPosition(element)) { LogError("Could not adjust pitch of %s", element->GetID().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Failed to properly set pitch."); - m_infoObject.import("elementId", element->GetID()); - m_infoObject.import("newStaffId", staff->GetID()); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Failed to properly set pitch."); + m_editInfo.import("elementId", element->GetID()); + m_editInfo.import("newStaffId", staff->GetID()); return false; } } } - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); - m_infoObject.import("elementId", elementId); - m_infoObject.import("newStaffId", staff->GetID()); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); + m_editInfo.import("elementId", elementId); + m_editInfo.import("newStaffId", staff->GetID()); return true; } @@ -3476,15 +3480,15 @@ bool EditorToolkitNeume::ChangeStaffTo(std::string elementId, std::string staffI { if (!m_doc->GetDrawingPage()) { LogError("Could not get the drawing page"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the drawing page."); return false; } if (m_doc->GetType() != Facs) { LogWarning("Staff re-association is only available in facsimile mode."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "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."); return false; } @@ -3492,16 +3496,16 @@ bool EditorToolkitNeume::ChangeStaffTo(std::string elementId, std::string staffI assert(element); if (element == NULL) { LogError("No element exists with ID '%s'.", elementId.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "No element exists with ID" + elementId + "."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "No element exists with ID" + elementId + "."); return false; } if (!(element->Is(CLEF) || element->Is(DIVLINE) || element->Is(ACCID))) { LogError("Element is of type %s, but only Clefs, Divlines, and Accids can change to a specified staff.", element->GetClassName().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Element is of type " + element->GetClassName() + ", but only Clefs, Divlines, and Accids can change to a specified staff."); return false; @@ -3511,8 +3515,8 @@ bool EditorToolkitNeume::ChangeStaffTo(std::string elementId, std::string staffI if (!staff) { LogError("Could not find any staves. This should not happen"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not find any staves. This should not happen"); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not find any staves. This should not happen"); return false; } @@ -3521,8 +3525,8 @@ bool EditorToolkitNeume::ChangeStaffTo(std::string elementId, std::string staffI assert(parent); if (parent == NULL || sParent == NULL) { LogError("Couldn't find staff parent of element with id '%s'", elementId.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Couldn't find staff parent of element with id " + elementId); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Couldn't find staff parent of element with id " + elementId); return false; } @@ -3530,16 +3534,16 @@ bool EditorToolkitNeume::ChangeStaffTo(std::string elementId, std::string staffI assert(LAYER); if (layer == NULL) { LogError("Couldn't find layer child of staff. This should not happen"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Couldn't find layer child of staff. This should not happen"); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Couldn't find layer child of staff. This should not happen"); return false; } if (layer == parent) { - m_infoObject.import("status", "WARNING"); - m_infoObject.import("message", "Moving to the same staff as before."); - m_infoObject.import("elementId", elementId); - m_infoObject.import("newStaffId", staff->GetID()); + m_editInfo.import("status", "WARNING"); + m_editInfo.import("message", "Moving to the same staff as before."); + m_editInfo.import("elementId", elementId); + m_editInfo.import("newStaffId", staff->GetID()); return true; } @@ -3597,8 +3601,8 @@ bool EditorToolkitNeume::ChangeStaffTo(std::string elementId, std::string staffI // Adjust clefline if (!AdjustClefLineFromPosition(dynamic_cast(element), staff)) { LogError("Could not adjust clef line of %s", element->GetID().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Failed to set clef line from facsimile."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Failed to set clef line from facsimile."); return false; } @@ -3625,10 +3629,10 @@ bool EditorToolkitNeume::ChangeStaffTo(std::string elementId, std::string staffI parent->ReorderByXPos(); } - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); - m_infoObject.import("elementId", elementId); - m_infoObject.import("newStaffId", staff->GetID()); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); + m_editInfo.import("elementId", elementId); + m_editInfo.import("newStaffId", staff->GetID()); return true; } From 0a1727fbffb91a6384c4b66a4c9e075827a6c14a Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 14 Aug 2023 14:48:46 -0400 Subject: [PATCH 33/91] Fix outer scope shadowing --- src/editortoolkit_neume.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 38fde2bee57..29a811d4b0a 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2596,7 +2596,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e secondParent->AddChild(parent); } else { - Syllable *parent = new Syllable(); + parent = new Syllable(); Syl *fullSyl = NULL; int ulx, uly, lrx, lry; From ffcf15178a55895d221be5ee2ceece19488b8f38 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 14 Aug 2023 14:49:21 -0400 Subject: [PATCH 34/91] Clean up comments --- src/editortoolkit_neume.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 29a811d4b0a..9e35505ccd3 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2401,9 +2401,6 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e std::string resultId0; std::string resultId1; - // LogMessage("%s", chainArray.get(0).json().c_str()); - // for_each(elementIds.begin(), elementIds.begin()+idx,[](std::string s){LogMessage("%s", s.c_str());}); - std::vector elementIds0 = { elementIds.begin(), elementIds.begin() + idx }; Group("neume", elementIds0); if (m_editInfo.get("status") == "FAILURE") { From 83ac0e7ab2e068e0e0894f6d96a08026fe9df13f Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 14 Aug 2023 16:56:28 -0400 Subject: [PATCH 35/91] Break when last element --- src/editortoolkit_neume.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 9e35505ccd3..270ac94a86a 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2811,6 +2811,7 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector fparent->ReorderByXPos(); uuidArray << (*it); it = elementIds.erase(it); + if (it == elementIds.end()) break; el = m_doc->GetDrawingPage()->FindDescendantByID(*it); } } From 37232c1ce6c92c09870f8ecd7c14713004d6f050 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Tue, 15 Aug 2023 16:50:29 -0400 Subject: [PATCH 36/91] Reset m_editInfo for OOM error --- src/editortoolkit_neume.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 270ac94a86a..cb1432194b4 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -48,7 +48,7 @@ std::string EditorToolkitNeume::EditInfo() bool EditorToolkitNeume::ParseEditorAction(const std::string &json_editorAction) { jsonxx::Object json; - // m_editInfo.reset(); + m_editInfo.reset(); // Read JSON actions if (!json.parse(json_editorAction)) { From 12ea581cbcaa610c1f93c945830275d9490e41d1 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Thu, 17 Aug 2023 18:15:41 -0400 Subject: [PATCH 37/91] Refactor new bbox zone && add staff rotation offset --- src/editortoolkit_neume.cpp | 66 ++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 37 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index cb1432194b4..802668a5da2 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -857,12 +857,12 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in Syl *syl = new Syl(); Neume *neume = new Neume(); Nc *nc = new Nc(); + Zone *sylZone; std::string contour = ""; nc->AttachZone(zone); Surface *surface = vrv_cast(facsimile->FindDescendantByType(SURFACE)); surface->AddChild(zone); - zone->SetUlx(ulx); Text *text = new Text(); std::u32string str = U""; @@ -874,57 +874,48 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in syllable->AddChild(syl); layer->AddChild(syllable); + 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); + ulx -= noteWidth / 2; + + // calculate staff rotation offset + double theta = staff->GetDrawingRotate(); + int offsetY = 0; + if (theta) { + double factor = 1.3; + offsetY = (int)((ulx - staff->GetFacsimileInterface()->GetZone()->GetUlx()) * tan(theta * M_PI / 180.0) + / factor); + } + + // Set up facsimile + zone->SetUlx(ulx); + zone->SetUly(uly + offsetY); + zone->SetLrx(ulx + noteWidth); + zone->SetLry(uly + offsetY + noteHeight); + // add syl bounding box if Facs if (m_doc->GetType() == Facs) { FacsimileInterface *fi = vrv_cast(syl->GetFacsimileInterface()); assert(fi); - Zone *sylZone = new Zone(); + sylZone = new Zone(); - // calculate bboxUlx and bboxUly wrt rotation using sine rule - int draw_w = staff->GetWidth(); int draw_h = staff->GetHeight(); - double theta = staff->GetDrawingRotate(); int staffUly = staff->GetDrawingY(); - int x = ulx - staff->GetDrawingX(); - int bboxUlx = ulx; - int bboxUly; - // if staff rotates downward to the right - if (theta > 0) { - int y = (int)((draw_w - x) * tan(theta * M_PI / 180.0)); - bboxUly = staffUly + draw_h - y; - } - // if staff rotates upwards to the right - else { - int y = (int)(x * tan(-theta * M_PI / 180.0)); - int h = (int)(draw_w * tan(-theta * M_PI / 180.0)); - bboxUly = staffUly + (draw_h - h) - y; - } // width height and offset can be adjusted - int bboxWidth = 225; int bboxHeight = 175; int bboxOffsetX = 50; - sylZone->SetUlx(bboxUlx - bboxOffsetX); - sylZone->SetUly(bboxUly); - sylZone->SetLrx(bboxUlx + bboxWidth - bboxOffsetX); - sylZone->SetLry(bboxUly + bboxHeight); + sylZone->SetUlx(ulx); + sylZone->SetUly(staffUly + draw_h + offsetY); + sylZone->SetLrx(ulx + noteWidth + bboxOffsetX); + sylZone->SetLry(staffUly + draw_h + offsetY + bboxHeight); surface->AddChild(sylZone); fi->AttachZone(sylZone); } - 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); - ulx -= noteWidth / 2; - // uly -= noteHeight / 2; - // Set up facsimile - zone->SetUlx(ulx); - zone->SetUly(uly); - zone->SetLrx(ulx + noteWidth); - zone->SetLry(uly + noteHeight); - layer->ReorderByXPos(); if (!AdjustPitchFromPosition(syllable)) { @@ -1005,12 +996,13 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in newUly += (newUlx - ulx) * tan(-staff->GetDrawingRotate() * M_PI / 180.0); newZone->SetUlx(newUlx); newZone->SetUly(newUly); - ; newZone->SetLrx(newUlx + noteWidth); newZone->SetLry(newUly + noteHeight); newNc->AttachZone(newZone); + if (sylZone) sylZone->SetLrx(newUlx + noteWidth); + assert(surface); surface->AddChild(newZone); From 8330f3b6b51c92aed6642a9733881f5270d409bd Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Fri, 27 Oct 2023 16:32:50 -0400 Subject: [PATCH 38/91] Add empty syl for follows syllable if precedes becomes empty --- src/editortoolkit_neume.cpp | 41 ++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 802668a5da2..67f5dc19638 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2197,7 +2197,46 @@ bool EditorToolkitNeume::Remove(std::string elementId) = dynamic_cast(m_doc->GetDrawingPage()->FindDescendantByID(linkedID)); if (linkedSyllable != NULL) { if (linkedSyllable->HasPrecedes()) linkedSyllable->SetPrecedes(""); - if (linkedSyllable->HasFollows()) linkedSyllable->SetFollows(""); + if (linkedSyllable->HasFollows()) { + linkedSyllable->SetFollows(""); + // Create an empty syl for the second part + Syl *syl = new Syl(); + Text *text = new Text(); + std::u32string str = U""; + text->SetText(str); + syl->AddChild(text); + linkedSyllable->AddChild(syl); + + // Create default bounding box if facs + if (m_doc->GetType() == Facs) { + Zone *zone = new Zone(); + + zone->SetUlx(linkedSyllable->GetFirst(NEUME) + ->GetFirst(NC) + ->GetFacsimileInterface() + ->GetZone() + ->GetUlx()); + zone->SetUly( + linkedSyllable->GetAncestorStaff()->GetFacsimileInterface()->GetZone()->GetLry()); + zone->SetLrx(linkedSyllable->GetLast(NEUME) + ->GetLast(NC) + ->GetFacsimileInterface() + ->GetZone() + ->GetLrx()); + zone->SetLry(zone->GetUly() + 100); + + // Make bbox larger if it has less than 2 ncs + if (linkedSyllable->GetChildCount(NC, 2) <= 2) { + zone->SetLrx(zone->GetLrx() + 50); + } + + assert(m_doc->GetFacsimile()); + m_doc->GetFacsimile()->FindDescendantByType(SURFACE)->AddChild(zone); + FacsimileInterface *fi = syl->GetFacsimileInterface(); + assert(fi); + fi->AttachZone(zone); + } + }; } } // Delete the syllable empty of neumes From a82d7518c910b5a705f25b9a98106acd343bba8d Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Fri, 1 Dec 2023 17:14:09 -0500 Subject: [PATCH 39/91] Set column value for newly inserted staff if has columns --- src/editortoolkit_neume.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 67f5dc19638..048d90eba4c 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -782,10 +782,12 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in if (elementType == "staff") { Object *parent; Staff *newStaff; + std::string columnValue; // Use closest existing staff (if there is one) if (staff) { parent = staff->GetParent(); assert(parent); + columnValue = staff->GetType(); int n = parent->GetChildCount() + 1; newStaff = new Staff(n); newStaff->m_drawingStaffDef = staff->m_drawingStaffDef; @@ -810,6 +812,7 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in assert(surface); surface->AddChild(zone); newStaff->AttachZone(zone); + if (columnValue.length()) newStaff->SetType(columnValue); Layer *newLayer = new Layer(); newStaff->AddChild(newLayer); From 3e5ba64599352a29bee3d05d260b007736469440 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 4 Dec 2023 20:38:54 -0500 Subject: [PATCH 40/91] Unlink syllable when removed --- include/vrv/editortoolkit_neume.h | 1 + src/editortoolkit_neume.cpp | 108 +++++++++++++++++------------- 2 files changed, 62 insertions(+), 47 deletions(-) diff --git a/include/vrv/editortoolkit_neume.h b/include/vrv/editortoolkit_neume.h index 108b50e5266..11828f083cb 100644 --- a/include/vrv/editortoolkit_neume.h +++ b/include/vrv/editortoolkit_neume.h @@ -55,6 +55,7 @@ class EditorToolkitNeume : public EditorToolkit { bool Remove(std::string elementId); bool Resize(std::string elementId, int ulx, int uly, int lrx, int lry, float resize = NAN); bool Group(std::string groupType, std::vector elementIds); + void UnlinkSyllable(Syllable *syllable); bool Ungroup(std::string groupType, std::vector elementIds); bool ChangeGroup(std::string elementId, std::string contour); bool ToggleLigature(std::vector elementIds); diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 048d90eba4c..3eb7ec10a7e 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2084,6 +2084,58 @@ bool EditorToolkitNeume::Split(std::string elementId, int x) return true; } +void EditorToolkitNeume::UnlinkSyllable(Syllable *syllable) +{ + 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; + } + + assert(syllable); + + std::string linkedID = (syllable->HasPrecedes() ? syllable->GetPrecedes() : syllable->GetFollows()); + if (linkedID.compare(0, 1, "#") == 0) linkedID.erase(0, 1); + Syllable *linkedSyllable = dynamic_cast(m_doc->GetDrawingPage()->FindDescendantByID(linkedID)); + if (linkedSyllable != NULL) { + if (linkedSyllable->HasPrecedes()) linkedSyllable->SetPrecedes(""); + if (linkedSyllable->HasFollows()) { + linkedSyllable->SetFollows(""); + + // Create an empty syl for the second part + Syl *syl = new Syl(); + Text *text = new Text(); + std::u32string str = U""; + text->SetText(str); + syl->AddChild(text); + linkedSyllable->AddChild(syl); + + // Create default bounding box if facs + if (m_doc->GetType() == Facs) { + Zone *zone = new Zone(); + + zone->SetUlx( + linkedSyllable->GetFirst(NEUME)->GetFirst(NC)->GetFacsimileInterface()->GetZone()->GetUlx()); + zone->SetUly(linkedSyllable->GetAncestorStaff()->GetFacsimileInterface()->GetZone()->GetLry()); + zone->SetLrx(linkedSyllable->GetLast(NEUME)->GetLast(NC)->GetFacsimileInterface()->GetZone()->GetLrx()); + zone->SetLry(zone->GetUly() + 100); + + // Make bbox larger if it has less than 2 ncs + if (linkedSyllable->GetChildCount(NC, 2) <= 2) { + zone->SetLrx(zone->GetLrx() + 50); + } + + assert(m_doc->GetFacsimile()); + m_doc->GetFacsimile()->FindDescendantByType(SURFACE)->AddChild(zone); + FacsimileInterface *fi = syl->GetFacsimileInterface(); + assert(fi); + fi->AttachZone(zone); + } + } + } +} + bool EditorToolkitNeume::Remove(std::string elementId) { if (!m_doc->GetDrawingPage()) { @@ -2156,6 +2208,14 @@ bool EditorToolkitNeume::Remove(std::string elementId) } } + if (obj->Is(SYLLABLE)) { + Syllable *syllable = dynamic_cast(obj); + assert(syllable); + if (syllable->HasPrecedes() || syllable->HasFollows()) { + UnlinkSyllable(syllable); + } + } + if (!result) { result = parent->DeleteChild(obj); } @@ -2194,53 +2254,7 @@ bool EditorToolkitNeume::Remove(std::string elementId) Syllable *li = dynamic_cast(obj); assert(li); if (li->HasPrecedes() || li->HasFollows()) { - std::string linkedID = (li->HasPrecedes() ? li->GetPrecedes() : li->GetFollows()); - if (linkedID.compare(0, 1, "#") == 0) linkedID.erase(0, 1); - Syllable *linkedSyllable - = dynamic_cast(m_doc->GetDrawingPage()->FindDescendantByID(linkedID)); - if (linkedSyllable != NULL) { - if (linkedSyllable->HasPrecedes()) linkedSyllable->SetPrecedes(""); - if (linkedSyllable->HasFollows()) { - linkedSyllable->SetFollows(""); - // Create an empty syl for the second part - Syl *syl = new Syl(); - Text *text = new Text(); - std::u32string str = U""; - text->SetText(str); - syl->AddChild(text); - linkedSyllable->AddChild(syl); - - // Create default bounding box if facs - if (m_doc->GetType() == Facs) { - Zone *zone = new Zone(); - - zone->SetUlx(linkedSyllable->GetFirst(NEUME) - ->GetFirst(NC) - ->GetFacsimileInterface() - ->GetZone() - ->GetUlx()); - zone->SetUly( - linkedSyllable->GetAncestorStaff()->GetFacsimileInterface()->GetZone()->GetLry()); - zone->SetLrx(linkedSyllable->GetLast(NEUME) - ->GetLast(NC) - ->GetFacsimileInterface() - ->GetZone() - ->GetLrx()); - zone->SetLry(zone->GetUly() + 100); - - // Make bbox larger if it has less than 2 ncs - if (linkedSyllable->GetChildCount(NC, 2) <= 2) { - zone->SetLrx(zone->GetLrx() + 50); - } - - assert(m_doc->GetFacsimile()); - m_doc->GetFacsimile()->FindDescendantByType(SURFACE)->AddChild(zone); - FacsimileInterface *fi = syl->GetFacsimileInterface(); - assert(fi); - fi->AttachZone(zone); - } - }; - } + UnlinkSyllable(li); } // Delete the syllable empty of neumes std::string syllableId = obj->GetID(); From e847556a0aeb060f8c36621a54acafbaa7418d4d Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 11 Dec 2023 17:14:31 -0500 Subject: [PATCH 41/91] Handle empty staff when inserting new staff --- src/editortoolkit_neume.cpp | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 3eb7ec10a7e..bb0756c02cf 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -816,28 +816,27 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in Layer *newLayer = new Layer(); newStaff->AddChild(newLayer); - // 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; + 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; + } } } - LogWarning("Failed to insert newStaff into staff"); - message += "Failed to insert newStaff into staves."; parent->AddChild(newStaff); - parent->Modify(); m_editInfo.import("uuid", newStaff->GetID()); m_editInfo.import("status", status); From fe3a0526d7fc8b84fe15b234edc022a14ee18224 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Tue, 12 Dec 2023 17:06:45 -0500 Subject: [PATCH 42/91] New for blank files in neume notation --- src/iomei.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/iomei.cpp b/src/iomei.cpp index ac3f89bde36..77b60e7a0d8 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -4467,6 +4467,13 @@ bool MEIInput::ReadSectionChildren(Object *parent, pugi::xml_node parentNode) LogWarning("Unsupported '<%s>' within
", current.name()); } } + + // New for blank files in neume notation + if (!unmeasured && parent->Is(SECTION) && (m_doc->m_notationType == NOTATIONTYPE_neume)) { + unmeasured = new Measure(false); + m_doc->SetMensuralMusicOnly(true); + parent->AddChild(unmeasured); + } return success; } From 459b29399672c425e5257bec053e32d4badcf601 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Tue, 19 Dec 2023 16:37:58 -0500 Subject: [PATCH 43/91] Fix removing clef error --- src/editortoolkit_neume.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index bb0756c02cf..e793f336fdf 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2146,10 +2146,11 @@ bool EditorToolkitNeume::Remove(std::string elementId) Object *obj = m_doc->GetDrawingPage()->FindDescendantByID(elementId); assert(obj); bool result = false; - bool isNeumeOrNc, isNc, isClef; + bool isNeumeOrNc, isNc, isClef, isSyllable; isNeumeOrNc = (obj->Is(NC) || obj->Is(NEUME)); isNc = obj->Is(NC); isClef = obj->Is(CLEF); + isSyllable = obj->Is(SYLLABLE); Object *parent = obj->GetParent(); assert(parent); m_editInfo.import("uuid", elementId); @@ -2206,8 +2207,7 @@ bool EditorToolkitNeume::Remove(std::string elementId) pi->AdjustPitchForNewClef(clef, previousClef); } } - - if (obj->Is(SYLLABLE)) { + else if (isSyllable) { Syllable *syllable = dynamic_cast(obj); assert(syllable); if (syllable->HasPrecedes() || syllable->HasFollows()) { From 5a5cc737411a7d36a3544c54bb98442e354b288a Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Thu, 21 Dec 2023 16:07:26 -0500 Subject: [PATCH 44/91] Fix staff rotation offset for inserted syllables --- src/editortoolkit_neume.cpp | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index e793f336fdf..c4d60dd438d 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -880,22 +880,12 @@ 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); - ulx -= noteWidth / 2; - - // calculate staff rotation offset - double theta = staff->GetDrawingRotate(); - int offsetY = 0; - if (theta) { - double factor = 1.3; - offsetY = (int)((ulx - staff->GetFacsimileInterface()->GetZone()->GetUlx()) * tan(theta * M_PI / 180.0) - / factor); - } // Set up facsimile zone->SetUlx(ulx); - zone->SetUly(uly + offsetY); + zone->SetUly(uly); zone->SetLrx(ulx + noteWidth); - zone->SetLry(uly + offsetY + noteHeight); + zone->SetLry(uly + noteHeight); // add syl bounding box if Facs if (m_doc->GetType() == Facs) { @@ -903,17 +893,25 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in assert(fi); sylZone = new Zone(); - int draw_h = staff->GetHeight(); - int staffUly = staff->GetDrawingY(); + int staffLry = staff->GetFacsimileInterface()->GetZone()->GetLry(); // width height and offset can be adjusted int bboxHeight = 175; int bboxOffsetX = 50; + // calculate staff rotation offset + double theta = staff->GetDrawingRotate(); + int offsetY = 0; + if (theta) { + double factor = 1.3; + offsetY = (int)((ulx - staff->GetFacsimileInterface()->GetZone()->GetUlx()) * tan(theta * M_PI / 180.0) + / factor); + } + sylZone->SetUlx(ulx); - sylZone->SetUly(staffUly + draw_h + offsetY); + sylZone->SetUly(staffLry + offsetY); sylZone->SetLrx(ulx + noteWidth + bboxOffsetX); - sylZone->SetLry(staffUly + draw_h + offsetY + bboxHeight); + sylZone->SetLry(staffLry + offsetY + bboxHeight); surface->AddChild(sylZone); fi->AttachZone(sylZone); } From 78afb12997ddeaf8a8c80e2643bee3828b7cc2b9 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sat, 23 Dec 2023 09:00:34 +0100 Subject: [PATCH 45/91] Use ExtractIDFragment function --- src/preparedatafunctor.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/preparedatafunctor.cpp b/src/preparedatafunctor.cpp index e33f0daa2fd..bf6a106a6e3 100644 --- a/src/preparedatafunctor.cpp +++ b/src/preparedatafunctor.cpp @@ -380,8 +380,7 @@ FunctorCode PrepareFacsimileFunctor::VisitObject(Object *object) FacsimileInterface *interface = object->GetFacsimileInterface(); assert(interface); if (interface->HasFacs()) { - std::string facsID = ((interface->GetFacs().compare(0, 1, "#") == 0) ? interface->GetFacs().substr(1) - : interface->GetFacs()); + std::string facsID = ExtractIDFragment(interface->GetFacs()); Zone *zone = m_facsimile->FindZoneByID(facsID); if (zone != NULL) { interface->AttachZone(zone); From d449c0a96c6d0529d73d287a4cae1cb7b52f9431 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Tue, 16 May 2023 14:23:47 -0400 Subject: [PATCH 46/91] pass neon path as command line argument --- emscripten/testNeon.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 emscripten/testNeon.sh diff --git a/emscripten/testNeon.sh b/emscripten/testNeon.sh new file mode 100644 index 00000000000..0158466bf4a --- /dev/null +++ b/emscripten/testNeon.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# This is a little script that compiles verovio using buildToolkit +# and moves the output, verovio.js, into Neon/verovio-util. +# It then starts up a local instance of Neon using yarn so the +# developer can see the changes as soon as possible. +# Please change [location_of_your_Neon] with the actual path. +# For example: ~/Desktop/DDMAL + + +# Builds verovio for Neon +./buildToolkit -x "Gootville,Petaluma" -DHPX + +cd build + +# Moves the needed verovio.js into Neon +cp verovio.js verovio_new.js + +mv verovio_new.js /Users/yinanzhou/SIMSSA/Neon/verovio-util + +cd /Users/yinanzhou/SIMSSA/Neon/verovio-util + +rm verovio.js; mv verovio_new.js verovio.js + +# Runs Neon +yarn build && yarn start \ No newline at end of file From 9f8ef22d9fc68a74a95d6de1ea1973c40be4bbfb Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Wed, 5 Jul 2023 16:30:52 -0400 Subject: [PATCH 47/91] Remove testNeon.sh from git --- emscripten/testNeon.sh | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 emscripten/testNeon.sh diff --git a/emscripten/testNeon.sh b/emscripten/testNeon.sh deleted file mode 100644 index 0158466bf4a..00000000000 --- a/emscripten/testNeon.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -# This is a little script that compiles verovio using buildToolkit -# and moves the output, verovio.js, into Neon/verovio-util. -# It then starts up a local instance of Neon using yarn so the -# developer can see the changes as soon as possible. -# Please change [location_of_your_Neon] with the actual path. -# For example: ~/Desktop/DDMAL - - -# Builds verovio for Neon -./buildToolkit -x "Gootville,Petaluma" -DHPX - -cd build - -# Moves the needed verovio.js into Neon -cp verovio.js verovio_new.js - -mv verovio_new.js /Users/yinanzhou/SIMSSA/Neon/verovio-util - -cd /Users/yinanzhou/SIMSSA/Neon/verovio-util - -rm verovio.js; mv verovio_new.js verovio.js - -# Runs Neon -yarn build && yarn start \ No newline at end of file From e6bc31854e78fff0d8fd126fc97181bb743bab32 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 10 Jul 2023 11:49:20 -0400 Subject: [PATCH 48/91] MatchHeight editor action for bbox --- include/vrv/editortoolkit_neume.h | 2 + src/editortoolkit_neume.cpp | 80 +++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/include/vrv/editortoolkit_neume.h b/include/vrv/editortoolkit_neume.h index dfeb65043e5..a31242d2970 100644 --- a/include/vrv/editortoolkit_neume.h +++ b/include/vrv/editortoolkit_neume.h @@ -44,6 +44,7 @@ class EditorToolkitNeume : public EditorToolkit { bool Insert(std::string elementType, std::string staffId, int ulx, int uly, int lrx, int lry, std::vector> attributes); bool InsertToSyllable(std::string elementId); + bool MatchHeight(std::string elementId); bool Merge(std::vector elementIds); bool MoveOutsideSyllable(std::string elementId); bool Set(std::string elementId, std::string attrType, std::string attrValue); @@ -72,6 +73,7 @@ class EditorToolkitNeume : public EditorToolkit { bool ParseInsertAction(jsonxx::Object param, std::string *elementType, std::string *staffId, int *ulx, int *uly, int *lrx, int *lry, std::vector> *attributes); bool ParseInsertToSyllableAction(jsonxx::Object param, std::string *elementId); + bool ParseMatchHeightAction(jsonxx::Object param, std::string *elementId); bool ParseMergeAction(jsonxx::Object param, std::vector *elementIds); bool ParseMoveOutsideSyllableAction(jsonxx::Object param, std::string *elementId); bool ParseSetAction(jsonxx::Object param, std::string *elementId, std::string *attrType, std::string *attrValue); diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index e355c23fd64..880c7b4454c 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -184,6 +184,13 @@ bool EditorToolkitNeume::ParseEditorAction(const std::string &json_editorAction) return this->SplitNeume(elementId, ncId); } } + else if (action == "matchHeight") { + std::string elementId; + if (this->ParseMatchHeightAction(json.get("param"), &elementId)) { + return this->MatchHeight(elementId); + } + LogWarning("Could not parse the insert action"); + } else if (action == "merge") { std::vector elementIds; if (this->ParseMergeAction(json.get("param"), &elementIds)) { @@ -1595,6 +1602,72 @@ bool EditorToolkitNeume::DisplaceClefOctave(std::string elementId, std::string d return true; } +bool EditorToolkitNeume::MatchHeight(std::string elementId) +{ + if (!m_doc->GetDrawingPage()) { + LogError("Could not get drawing page"); + m_infoObject.import("status", "FAILURE"); + m_infoObject.import("message", "Could not get drawing page."); + return false; + } + if (m_doc->GetType() != Facs) { + LogError("Drawing page without facsimile"); + m_infoObject.import("status", "FAILURE"); + m_infoObject.import("message", "Drawing page without facsimile is unsupported."); + return false; + } + + Object *element = m_doc->GetDrawingPage()->FindDescendantByID(elementId); + assert(element); + Object *staffParent = element->GetFirstAncestor(STAFF); + if (element == NULL) { + LogError("No element exists with ID '%s'.", elementId.c_str()); + m_infoObject.import("status", "FAILURE"); + m_infoObject.import("message", "No element exists with ID" + elementId + "."); + return false; + } + if (!element->Is(SYL)) { + LogError("Element is of type %s, but only element can match height.", element->GetClassName().c_str()); + m_infoObject.import("status", "FAILURE"); + m_infoObject.import( + "message", "Element is of type " + element->GetClassName() + ", but only element can match height."); + return false; + } + + // get the position of the selected bbox + int uly; + int lry; + if (dynamic_cast(element)->HasFacs()) { + uly = element->GetFacsimileInterface()->GetZone()->GetUly(); + lry = element->GetFacsimileInterface()->GetZone()->GetLry(); + } + else { + LogError("Selected '%s' without facsimile", element->GetClassName().c_str()); + m_infoObject.import("status", "FAILURE"); + m_infoObject.import("message", "Selected '" + element->GetClassName() + "' without facsimile is unsupported."); + return false; + } + + // find all syls in staff + ListOfObjects syls; + ClassIdComparison ac(SYL); + staffParent->FindAllDescendantsByComparison(&syls, &ac); + Syl *syl; + Zone *zone; + + for (auto it = syls.begin(); it != syls.end(); ++it) { + syl = dynamic_cast(*it); + zone = syl->GetFacsimileInterface()->GetZone(); + assert(zone); + zone->SetUly(uly); + zone->SetLry(lry); + } + + m_infoObject.import("status", "OK"); + m_infoObject.import("message", ""); + return true; +} + bool EditorToolkitNeume::Merge(std::vector elementIds) { if (!m_doc->GetDrawingPage()) return false; @@ -3776,6 +3849,13 @@ bool EditorToolkitNeume::ParseDisplaceClefAction(jsonxx::Object param, std::stri return true; } +bool EditorToolkitNeume::ParseMatchHeightAction(jsonxx::Object param, std::string *elementId) +{ + if (!param.has("elementId")) return false; + (*elementId) = param.get("elementId"); + return true; +} + bool EditorToolkitNeume::ParseMergeAction(jsonxx::Object param, std::vector *elementIds) { if (!param.has("elementIds")) return false; From f41a0a0f88707da27de4e2e9f5406b97d0af89db Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Wed, 12 Jul 2023 17:25:17 -0400 Subject: [PATCH 49/91] Add overlap correction on x-axis --- src/editortoolkit_neume.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 880c7b4454c..b0692ef2e3a 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -1654,11 +1654,25 @@ bool EditorToolkitNeume::MatchHeight(std::string elementId) staffParent->FindAllDescendantsByComparison(&syls, &ac); Syl *syl; Zone *zone; + int rightMost = -1; + int itUlx; + int itLrx; for (auto it = syls.begin(); it != syls.end(); ++it) { syl = dynamic_cast(*it); zone = syl->GetFacsimileInterface()->GetZone(); assert(zone); + + // adjust x-axis first + itUlx = zone->GetUlx(); + itLrx = zone->GetLrx(); + if (itLrx > rightMost) { + // correct overlap + if (itUlx < rightMost) zone->SetUlx(rightMost); + // Update right most point if needed + rightMost = itLrx; + } + zone->SetUly(uly); zone->SetLry(lry); } From 23057412c0e701b1572f6fa7d5b1851ea823add0 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Thu, 13 Jul 2023 15:14:05 -0400 Subject: [PATCH 50/91] Add staff rotation offset --- src/editortoolkit_neume.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index b0692ef2e3a..7df8954643e 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -1635,11 +1635,15 @@ bool EditorToolkitNeume::MatchHeight(std::string elementId) } // get the position of the selected bbox + int ulx; int uly; - int lry; + int height; + int lrx; if (dynamic_cast(element)->HasFacs()) { + ulx = element->GetFacsimileInterface()->GetZone()->GetUlx(); uly = element->GetFacsimileInterface()->GetZone()->GetUly(); - lry = element->GetFacsimileInterface()->GetZone()->GetLry(); + lrx = element->GetFacsimileInterface()->GetZone()->GetLrx(); + height = element->GetFacsimileInterface()->GetZone()->GetLry() - uly; } else { LogError("Selected '%s' without facsimile", element->GetClassName().c_str()); @@ -1654,9 +1658,11 @@ bool EditorToolkitNeume::MatchHeight(std::string elementId) staffParent->FindAllDescendantsByComparison(&syls, &ac); Syl *syl; Zone *zone; - int rightMost = -1; int itUlx; int itLrx; + int offsetY; + int rightMost = -1; + double theta = staffParent->GetFacsimileInterface()->GetZone()->GetRotate(); for (auto it = syls.begin(); it != syls.end(); ++it) { syl = dynamic_cast(*it); @@ -1673,8 +1679,14 @@ bool EditorToolkitNeume::MatchHeight(std::string elementId) rightMost = itLrx; } - zone->SetUly(uly); - zone->SetLry(lry); + offsetY = 0; + if (theta) { + double factor = 1.3; + offsetY = (int)((itUlx - ulx) * tan(theta * M_PI / 180.0) / factor); + } + + zone->SetUly(uly + offsetY); + zone->SetLry(uly + offsetY + height); } m_infoObject.import("status", "OK"); From 187d98256fa5bfeb532ff5e7701f48a32cd316fb Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Thu, 13 Jul 2023 16:50:21 -0400 Subject: [PATCH 51/91] Adjust original bbox size for ungrouping --- src/editortoolkit_neume.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 7df8954643e..3747bcba517 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2987,6 +2987,10 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector // if the element is a syl then we want to keep it attached to the first node if (el->Is(SYL)) { + Zone *zone = dynamic_cast(el->GetFacsimileInterface()->GetZone()); + + zone->SetLrx(zone->GetUlx() + 100); + zone->SetLry(zone->GetUly() + 200); continue; } From 81fd49f34631a8477e15024527203a7e9997957e Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Fri, 14 Jul 2023 15:20:47 -0400 Subject: [PATCH 52/91] Fix ungroup when syllable start with layer element --- src/editortoolkit_neume.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 3747bcba517..3979269ad3d 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2931,8 +2931,10 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector sparent->ReorderByXPos(); fparent->ClearRelinquishedChildren(); fparent->ReorderByXPos(); + uuidArray << (*it); + it = elementIds.erase(it); + el = m_doc->GetDrawingPage()->FindDescendantByID(*it); } - continue; } if (elementIds.begin() == it || firstIsSyl) { // if the element is a syl we want it to stay attached to the first element From dea073b10e8209e762547bfdafb3c0375198b065 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Fri, 14 Jul 2023 16:12:22 -0400 Subject: [PATCH 53/91] Clean up comments --- src/editortoolkit_neume.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 3979269ad3d..ec0430a7b29 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2996,12 +2996,6 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector continue; } - // if (el->Is(DIVLINE) || el->Is(ACCID)) { - // el->MoveItselfTo(sparent); - // fparent->ClearRelinquishedChildren(); - // continue; - // } - if (groupType == "nc") { Nc *nc = dynamic_cast(el); assert(nc); @@ -3095,15 +3089,11 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector FacsimileInterface *fi = syl->GetFacsimileInterface(); assert(fi); fi->AttachZone(zone); - - // syl->ResetFacsimile(); - // syl->SetFacs(zone->GetID()); } } if (ligNum != 1) { // if not 1st nc in ligature, add child - uuidArray << newParent->GetID(); sparent->AddChild(newParent); From 89321b8033222ddac0e4cf059bf6dfbad50f0499 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 24 Jul 2023 16:22:34 -0400 Subject: [PATCH 54/91] Refactor ungroup bbox --- src/editortoolkit_neume.cpp | 67 +++++++++---------------------------- 1 file changed, 15 insertions(+), 52 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index ec0430a7b29..c0f63cfee33 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2844,6 +2844,7 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector int ligNum = 0; // for ligature in ungroupNcs int firstIsLig = false; bool firstIsSyl = false; + Zone *oldSylZone = NULL; Clef *oldClef = NULL; ClassIdComparison ac(CLEF); ListOfObjects syllables; // List of syllables used. groupType=neume only. @@ -2976,6 +2977,9 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector if (oldClef == NULL) { oldClef = dynamic_cast(sparent)->GetCurrentClef(); } + + // Get orginal syl zone + oldSylZone = dynamic_cast(currentParent->GetFirst(SYL)->GetFacsimileInterface()->GetZone()); } else { @@ -2989,10 +2993,9 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector // if the element is a syl then we want to keep it attached to the first node if (el->Is(SYL)) { - Zone *zone = dynamic_cast(el->GetFacsimileInterface()->GetZone()); - - zone->SetLrx(zone->GetUlx() + 100); - zone->SetLry(zone->GetUly() + 200); + if (oldSylZone) { + oldSylZone->SetLrx(oldSylZone->GetUlx() + 100); + } continue; } @@ -3034,55 +3037,15 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector if (m_doc->GetType() == Facs) { Zone *zone = new Zone(); - // Use syllable parent positions if possible - FacsimileInterface *syllableFi = NULL; - if (syl->GetFirstAncestor(SYLLABLE)->GetFacsimileInterface()->HasFacs()) { - syllableFi = syl->GetFirstAncestor(SYLLABLE)->GetFacsimileInterface(); - Zone *tempZone = dynamic_cast(syllableFi->GetZone()); - zone->SetUlx(tempZone->GetUlx()); - zone->SetUly(tempZone->GetUly()); - zone->SetLrx(tempZone->GetLrx()); - zone->SetLry(tempZone->GetLry()); - } - // otherwise get a boundingbox that comprises all the neumes in the syllable - else { - ListOfObjects children; - InterfaceComparison comp(INTERFACE_FACSIMILE); - syl->GetFirstAncestor(SYLLABLE)->FindAllDescendantsByComparison(&children, &comp); - for (auto iter2 = children.begin(); iter2 != children.end(); ++iter2) { - FacsimileInterface *temp = (*iter2)->GetFacsimileInterface(); - assert(temp); - Zone *tempZone = vrv_cast(temp->GetZone()); - assert(tempZone); - if (temp->HasFacs()) { - if (syllableFi == NULL) { - zone->SetUlx(tempZone->GetUlx()); - zone->SetUly(tempZone->GetUly()); - zone->SetLrx(tempZone->GetLrx()); - zone->SetLry(tempZone->GetLry()); - } - else { - if (tempZone->GetUlx() < zone->GetUlx()) { - zone->SetUlx(tempZone->GetUlx()); - } - if (tempZone->GetUly() < zone->GetUly()) { - zone->SetUly(tempZone->GetUly()); - } - if (tempZone->GetLrx() > zone->GetLrx()) { - zone->SetLrx(tempZone->GetLrx()); - } - if (tempZone->GetLry() > zone->GetLry()) { - zone->SetLry(tempZone->GetLry()); - } - } - } - } - } + zone->SetUlx(el->GetFirst(NC)->GetFacsimileInterface()->GetZone()->GetUlx()); + zone->SetUly(oldSylZone->GetUly()); + zone->SetLrx(el->GetLast(NC)->GetFacsimileInterface()->GetZone()->GetLrx()); + zone->SetLry(oldSylZone->GetLry()); - // make the bounding box a little bigger and lower so it's easier to edit - zone->SetUly(zone->GetUly() + 100); - zone->SetLrx(zone->GetLrx() + 100); - zone->SetLry(zone->GetLry() + 200); + // Make bbox larger if it has less than 2 ncs + if (newParent->GetChildCount(NC, 2) <= 2) { + zone->SetLrx(zone->GetLrx() + 50); + } assert(m_doc->GetFacsimile()); m_doc->GetFacsimile()->FindDescendantByType(SURFACE)->AddChild(zone); From 9cb464b86377993d3c7a4304af6c949d7b1fd63b Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 24 Jul 2023 16:23:34 -0400 Subject: [PATCH 55/91] Clean up --- src/editortoolkit_neume.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index c0f63cfee33..a08fb58f098 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2949,7 +2949,6 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector Nc *nc = dynamic_cast(el); assert(nc); if (nc->HasLigated() && nc->GetLigated() == BOOLEAN_true) { - // ligNum++; firstIsLig = true; } @@ -3002,7 +3001,6 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector if (groupType == "nc") { Nc *nc = dynamic_cast(el); assert(nc); - // if (nc->HasLigated()) continue; if (firstIsLig) { // if 1st is ligature, neglect 2nd, go to the next nc From b302f3e76f9356a9cafe9160b83c0c53c0aa9c3e Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Tue, 25 Jul 2023 11:30:52 -0400 Subject: [PATCH 56/91] Remove x-axis adjustment --- src/editortoolkit_neume.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index a08fb58f098..30e4e7b5794 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -1659,9 +1659,9 @@ bool EditorToolkitNeume::MatchHeight(std::string elementId) Syl *syl; Zone *zone; int itUlx; - int itLrx; + // int itLrx; int offsetY; - int rightMost = -1; + // int rightMost = -1; double theta = staffParent->GetFacsimileInterface()->GetZone()->GetRotate(); for (auto it = syls.begin(); it != syls.end(); ++it) { @@ -1669,17 +1669,18 @@ bool EditorToolkitNeume::MatchHeight(std::string elementId) zone = syl->GetFacsimileInterface()->GetZone(); assert(zone); - // adjust x-axis first - itUlx = zone->GetUlx(); - itLrx = zone->GetLrx(); - if (itLrx > rightMost) { - // correct overlap - if (itUlx < rightMost) zone->SetUlx(rightMost); - // Update right most point if needed - rightMost = itLrx; - } + // // adjust x-axis first + // itUlx = zone->GetUlx(); + // itLrx = zone->GetLrx(); + // if (itLrx > rightMost) { + // // correct overlap + // if (itUlx < rightMost) zone->SetUlx(rightMost); + // // Update right most point if needed + // rightMost = itLrx; + // } offsetY = 0; + itUlx = zone->GetUlx(); if (theta) { double factor = 1.3; offsetY = (int)((itUlx - ulx) * tan(theta * M_PI / 180.0) / factor); From 92fe5f6d70e5e64da3b3997339683dc36636ba06 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Thu, 27 Jul 2023 16:57:47 -0400 Subject: [PATCH 57/91] Fix ungroup when firstIsSyl --- src/editortoolkit_neume.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 30e4e7b5794..9188864f0bb 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2943,6 +2943,10 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector // we'll still need to initialize all the parents, thus the bool if (el->Is(SYL)) { firstIsSyl = true; + oldSylZone = dynamic_cast(el->GetFacsimileInterface()->GetZone()); + if (oldSylZone) { + oldSylZone->SetLrx(oldSylZone->GetUlx() + 100); + } continue; } else if (groupType == "nc") { @@ -2979,7 +2983,9 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector } // Get orginal syl zone - oldSylZone = dynamic_cast(currentParent->GetFirst(SYL)->GetFacsimileInterface()->GetZone()); + if (!oldSylZone) { + oldSylZone = dynamic_cast(currentParent->GetFirst(SYL)->GetFacsimileInterface()->GetZone()); + } } else { From a0e3dcdf9c649c7dcceb8a3f8df224d41603e418 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Fri, 28 Jul 2023 17:17:43 -0400 Subject: [PATCH 58/91] Remove redundant new syl for insert action --- src/editortoolkit_neume.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 9188864f0bb..abef4f7c69f 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -875,8 +875,6 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in if (m_doc->GetType() == Facs) { FacsimileInterface *fi = vrv_cast(syl->GetFacsimileInterface()); assert(fi); - Text *text = new Text(); - syl->AddChild(text); Zone *sylZone = new Zone(); // calculate bboxUlx and bboxUly wrt rotation using sine rule From 0b26cc73174a1204280ff2fc877d8d42646d4dca Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Sun, 30 Jul 2023 16:46:13 -0400 Subject: [PATCH 59/91] Remove unnecessary doubleParent check --- src/editortoolkit_neume.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index abef4f7c69f..9bf1655b406 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2647,16 +2647,14 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e // also in this case we need to make sure that the facsimile of the resulting syl is correct else { if (elementClass == NC) { - if (doubleParent) { - parent = new Neume(); - for (auto it = elements.begin(); it != elements.end(); ++it) { - if ((*it)->GetParent() != parent && !(*it)->Is(SYL)) { - (*it)->MoveItselfTo(parent); - parent->ReorderByXPos(); - } + parent = new Neume(); + for (auto it = elements.begin(); it != elements.end(); ++it) { + if ((*it)->GetParent() != parent && !(*it)->Is(SYL)) { + (*it)->MoveItselfTo(parent); + parent->ReorderByXPos(); } - doubleParent->AddChild(parent); } + doubleParent->AddChild(parent); Layer *layer = dynamic_cast(parent->GetFirstAncestor(LAYER)); if (!layer) { From 682d11d91a259010d35b81ee7e553d40fd80f0a8 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Sun, 30 Jul 2023 16:50:29 -0400 Subject: [PATCH 60/91] Rename doubleParent to secondParent --- src/editortoolkit_neume.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 9bf1655b406..057d536f5ae 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2313,7 +2313,7 @@ bool EditorToolkitNeume::Resize(std::string elementId, int ulx, int uly, int lrx bool EditorToolkitNeume::Group(std::string groupType, std::vector elementIds) { - Object *parent = NULL, *doubleParent = NULL; + Object *parent = NULL, *secondParent = NULL; std::map parents; std::set elements; std::vector sortedElements; @@ -2440,9 +2440,9 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } } - if (doubleParent == NULL) { - doubleParent = par->GetParent(); - if (doubleParent == NULL) { + if (secondParent == NULL) { + secondParent = par->GetParent(); + if (secondParent == NULL) { LogError("No second level parent!"); m_infoObject.import("status", "FAILURE"); m_infoObject.import("message", "No second level parent."); @@ -2450,7 +2450,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } } else { - if (par->GetParent() != doubleParent) { + if (par->GetParent() != secondParent) { LogError("No shared second level parent!"); m_infoObject.import("status", "FAILURE"); m_infoObject.import("message", "No shared second level parent."); @@ -2619,10 +2619,10 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } parent->ReorderByXPos(); - if (doubleParent == NULL) { + if (secondParent == NULL) { return false; } - doubleParent->AddChild(parent); + secondParent->AddChild(parent); Layer *layer = vrv_cast(parent->GetFirstAncestor(LAYER)); assert(layer); @@ -2654,7 +2654,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e parent->ReorderByXPos(); } } - doubleParent->AddChild(parent); + secondParent->AddChild(parent); Layer *layer = dynamic_cast(parent->GetFirstAncestor(LAYER)); if (!layer) { @@ -2732,11 +2732,11 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } } - if (doubleParent == NULL) { + if (secondParent == NULL) { LogError("No second level parent!"); return false; } - doubleParent->AddChild(fullSyllable); + secondParent->AddChild(fullSyllable); Layer *layer = vrv_cast(fullSyllable->GetFirstAncestor(LAYER)); assert(layer); if (ulx >= 0 && uly >= 0 && lrx >= 0 && lry >= 0) { @@ -2778,11 +2778,11 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e Object *obj = (*it).first; obj->ClearRelinquishedChildren(); if (obj->GetChildCount() == 0) { - if (doubleParent == NULL) { + if (secondParent == NULL) { LogError("No second level parent!"); return false; } - doubleParent->DeleteChild(obj); + secondParent->DeleteChild(obj); } else if (obj->GetChildCount() == (obj->GetChildCount(SYL) + obj->GetChildCount(DIVLINE) + obj->GetChildCount(ACCID) @@ -2806,11 +2806,11 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e parent->ReorderByXPos(); obj->ClearRelinquishedChildren(); } - if (doubleParent == NULL) { + if (secondParent == NULL) { LogError("No second level parent!"); return false; } - doubleParent->DeleteChild(obj); + secondParent->DeleteChild(obj); } } From 6d29f65d6f501249002aaea1981e33a08f012d4b Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Sun, 30 Jul 2023 16:57:04 -0400 Subject: [PATCH 61/91] Optimize parents counting --- src/editortoolkit_neume.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 057d536f5ae..db13d027509 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2457,13 +2457,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e return false; } } - auto possibleEntry = parents.find(el->GetParent()); - if (possibleEntry == parents.end()) { - parents.emplace(el->GetParent(), 1); - } - else { - possibleEntry->second += 1; - } + parents[par]++; elements.insert(el); } From ee769848d8bd7adfb7a8312949d2f7d369dbe6ce Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Sun, 30 Jul 2023 16:59:10 -0400 Subject: [PATCH 62/91] Clean up --- src/editortoolkit_neume.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index db13d027509..695156fd75e 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2474,16 +2474,6 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e return false; } - // auto it = elementIds.begin(); - // Object *el = m_doc->GetDrawingPage()->FindDescendantByID(*it); - // Layer *layer = dynamic_cast(el->GetFirstAncestor(LAYER)); - // if (!layer) { - // LogError("Elements does not have Layer parent. This should not happen."); - // m_infoObject.import("status", "FAILURE"); - // m_infoObject.import("message", "Elements does not have Layer parent."); - // return false; - // } - std::copy(elements.begin(), elements.end(), std::back_inserter(sortedElements)); std::stable_sort(sortedElements.begin(), sortedElements.end(), Object::sortByUlx); From affe5b4d1d187a8ccecac8c6959b64eafe258ef1 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Sun, 30 Jul 2023 17:18:21 -0400 Subject: [PATCH 63/91] Remove unnecessary conversion --- src/editortoolkit_neume.cpp | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 695156fd75e..df5d45d534e 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2315,8 +2315,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e { Object *parent = NULL, *secondParent = NULL; std::map parents; - std::set elements; - std::vector sortedElements; + ListOfObjects elements; std::vector fullParents; std::map clefsBefore; @@ -2458,7 +2457,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } } parents[par]++; - elements.insert(el); + elements.push_back(el); } if (parents.size() == 0) { @@ -2474,34 +2473,29 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e return false; } - std::copy(elements.begin(), elements.end(), std::back_inserter(sortedElements)); - std::stable_sort(sortedElements.begin(), sortedElements.end(), Object::sortByUlx); - ListOfObjects clefs; - std::set syllables; - ListOfObjects sortedSyllables; + ListOfObjects syllables; ClassIdComparison clefComp(CLEF); InterfaceComparison pitchComp(INTERFACE_PITCH); Clef *newClef = NULL; - m_doc->GetDrawingPage()->FindAllDescendantsBetween(&clefs, &clefComp, - sortedElements.front()->GetFirstAncestor(SYLLABLE), sortedElements.back()->GetFirstAncestor(SYLLABLE)); + m_doc->GetDrawingPage()->FindAllDescendantsBetween( + &clefs, &clefComp, elements.front()->GetFirstAncestor(SYLLABLE), elements.back()->GetFirstAncestor(SYLLABLE)); // if there are clefs between the elements getting grouped // some elements will need their pitch adjusted for the new clef // clefsBefore maps the syllable parent to its clef before the group // so we can reassociate any pitched children from their old clef to the new one if (clefs.size() != 0) { - for (auto it = sortedElements.begin(); it != sortedElements.end(); ++it) { + for (auto it = elements.begin(); it != elements.end(); ++it) { if ((*it)->Is(SYLLABLE)) { - syllables.insert(dynamic_cast(*it)); + syllables.push_back(dynamic_cast(*it)); } else { - syllables.insert((*it)->GetFirstAncestor(SYLLABLE)); + syllables.push_back((*it)->GetFirstAncestor(SYLLABLE)); } } - std::copy(syllables.begin(), syllables.end(), std::back_inserter(sortedSyllables)); - for (auto it = sortedSyllables.begin(); it != sortedSyllables.end(); ++it) { + for (auto it = syllables.begin(); it != syllables.end(); ++it) { Clef *tempClef = dynamic_cast(m_doc->GetDrawingPage()->FindPreviousChild(&clefComp, (*it))); if (tempClef == NULL) { Layer *layer = vrv_cast((*it)->GetFirstAncestor(LAYER)); @@ -2509,7 +2503,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } clefsBefore.insert(std::pair(dynamic_cast(*it), tempClef)); } - newClef = clefsBefore[dynamic_cast(sortedSyllables.front())]; + newClef = clefsBefore[dynamic_cast(syllables.front())]; } // find parents where all of their children are being grouped @@ -2745,8 +2739,8 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e // change the pitch of any pitched elements whose clef may have changed assert(newClef); ListOfObjects pitchedChildren; - if (sortedSyllables.size()) { - for (auto it = sortedSyllables.begin(); it != sortedSyllables.end(); ++it) { + if (syllables.size()) { + for (auto it = syllables.begin(); it != syllables.end(); ++it) { Syllable *syllable = dynamic_cast(*it); if (clefsBefore[syllable] != newClef) { syllable->FindAllDescendantsByComparison(&pitchedChildren, &pitchComp); From 88a7b37405dd8a5a01acdf84ba73d8c1bdc35683 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 31 Jul 2023 11:28:45 -0400 Subject: [PATCH 64/91] Move second level parent check --- src/editortoolkit_neume.cpp | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index df5d45d534e..6ea4fb0bda8 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2439,23 +2439,6 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } } - if (secondParent == NULL) { - secondParent = par->GetParent(); - if (secondParent == NULL) { - LogError("No second level parent!"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "No second level parent."); - return false; - } - } - else { - if (par->GetParent() != secondParent) { - LogError("No shared second level parent!"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "No shared second level parent."); - return false; - } - } parents[par]++; elements.push_back(el); } @@ -2506,11 +2489,25 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e newClef = clefsBefore[dynamic_cast(syllables.front())]; } + // check if share second level parent + secondParent = (*parents.begin()).first->GetParent(); + if (secondParent == NULL) { + LogError("No second level parent!"); + m_infoObject.import("status", "FAILURE"); + m_infoObject.import("message", "No second level parent."); + return false; + } // find parents where all of their children are being grouped for (auto it = parents.begin(); it != parents.end(); ++it) { auto parentPair = *it; Object *par = parentPair.first; int expected; + if (par->GetParent() != secondParent) { + LogError("No shared second level parent!"); + m_infoObject.import("status", "FAILURE"); + m_infoObject.import("message", "No shared second level parent."); + return false; + } if (par->GetClassId() == SYLLABLE) { expected = par->GetChildCount(NEUME); } From 3c91687ea8a32945e2d59fe240e24686a949c0e5 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 31 Jul 2023 11:29:17 -0400 Subject: [PATCH 65/91] Clean up --- src/editortoolkit_neume.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 6ea4fb0bda8..1bbc257c66c 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2587,9 +2587,6 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e FacsimileInterface *fi = vrv_cast((*syl).GetFacsimileInterface()); assert(fi); fi->AttachZone(zone); - - // syl->ResetFacsimile(); - // syl->SetFacs(zone->GetID()); } } From 8cc6061ae3bbeae18476b70b19567744f430769b Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 31 Jul 2023 11:30:22 -0400 Subject: [PATCH 66/91] Remove unnecessary second level parent check --- src/editortoolkit_neume.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 1bbc257c66c..3ca84d14d52 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2591,9 +2591,6 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } parent->ReorderByXPos(); - if (secondParent == NULL) { - return false; - } secondParent->AddChild(parent); Layer *layer = vrv_cast(parent->GetFirstAncestor(LAYER)); From 08c4dcf939e08bb714bc3a7e7a52008b5d3d001a Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 31 Jul 2023 13:14:45 -0400 Subject: [PATCH 67/91] Simplify syl zone calculation --- src/editortoolkit_neume.cpp | 57 +++++++++++++------------------------ 1 file changed, 19 insertions(+), 38 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 3ca84d14d52..b93f1ba1579 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2518,6 +2518,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e fullParents.push_back(parentPair.first); } } + // if there are no full parents we need to make a new one to attach everything to if (fullParents.empty()) { if (elementClass == NC) { @@ -2525,10 +2526,18 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } else if (elementClass == NEUME) { parent = new Syllable(); + int lry; + int uly; for (auto it = elements.begin(); it != elements.end(); ++it) { - if ((*it)->GetParent() != parent && !(*it)->Is(SYL)) { - (*it)->MoveItselfTo(parent); + if ((*it)->GetParent() != parent) { + if (!(*it)->Is(SYL)) { + (*it)->MoveItselfTo(parent); + } + else { + lry = (*it)->GetFacsimileInterface()->GetZone()->GetLry(); + uly = (*it)->GetFacsimileInterface()->GetZone()->GetUly(); + } } } @@ -2544,43 +2553,15 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e if (m_doc->GetType() == Facs) { Zone *zone = new Zone(); - // if it's syllable parent has position values just use those - FacsimileInterface *syllableFi = NULL; - if (syl->GetFirstAncestor(SYLLABLE)->GetFacsimileInterface()->HasFacs()) { - syllableFi = syl->GetFirstAncestor(SYLLABLE)->GetFacsimileInterface(); - Zone *tempZone = dynamic_cast(syllableFi->GetZone()); - zone->SetUlx(tempZone->GetUlx()); - zone->SetUly(tempZone->GetUly()); - zone->SetLrx(tempZone->GetLrx()); - zone->SetLry(tempZone->GetLry()); - } - // otherwise get a boundingbox that comprises all the neumes in the syllable - else { - ListOfObjects children; - InterfaceComparison comp(INTERFACE_FACSIMILE); - syl->GetFirstAncestor(SYLLABLE)->FindAllDescendantsByComparison(&children, &comp); - for (auto iter2 = children.begin(); iter2 != children.end(); ++iter2) { - FacsimileInterface *temp = (*iter2)->GetFacsimileInterface(); - assert(temp); - Zone *tempZone = vrv_cast(temp->GetZone()); - assert(tempZone); - if (temp->HasFacs()) { - zone->SetUlx(tempZone->GetUlx()); - zone->SetUly(tempZone->GetUly()); - zone->SetLrx(tempZone->GetLrx()); - zone->SetLry(tempZone->GetLry()); - } - } - } - - // make the bounding box a little bigger and lower so it's easier to edit - const int offSetUly = 100; - const int offSetLrx = 100; - const int offSetLry = 200; + zone->SetUlx(parent->GetFirst(NC)->GetFacsimileInterface()->GetZone()->GetUlx()); + zone->SetUly(uly); + zone->SetLrx(parent->GetLast(NC)->GetFacsimileInterface()->GetZone()->GetLrx()); + zone->SetLry(lry); - zone->SetUly(zone->GetUly() + offSetUly); - zone->SetLrx(zone->GetLrx() + offSetLrx); - zone->SetLry(zone->GetLry() + offSetLry); + // Make bbox larger if it has less than 2 ncs + if (parent->GetChildCount(NC, 2) <= 2) { + zone->SetLrx(zone->GetLrx() + 50); + } assert(m_doc->GetFacsimile()); m_doc->GetFacsimile()->FindDescendantByType(SURFACE)->AddChild(zone); From 3c901209f2f4e3a747a0ff5a65ec8e2e50e9b234 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 31 Jul 2023 13:30:20 -0400 Subject: [PATCH 68/91] Optimize reordering --- src/editortoolkit_neume.cpp | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index b93f1ba1579..0f3af38680d 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2571,12 +2571,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } } - parent->ReorderByXPos(); secondParent->AddChild(parent); - - Layer *layer = vrv_cast(parent->GetFirstAncestor(LAYER)); - assert(layer); - layer->ReorderByXPos(); } // if there's only one full parent we just add the other elements to it @@ -2589,7 +2584,6 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e (*it)->MoveItselfTo(parent); } } - parent->ReorderByXPos(); } // if there is more than 1 full parent we need to concat syl's @@ -2601,20 +2595,9 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e for (auto it = elements.begin(); it != elements.end(); ++it) { if ((*it)->GetParent() != parent && !(*it)->Is(SYL)) { (*it)->MoveItselfTo(parent); - parent->ReorderByXPos(); } } secondParent->AddChild(parent); - - Layer *layer = dynamic_cast(parent->GetFirstAncestor(LAYER)); - if (!layer) { - LogError("Elements does not have Layer parent. This should not happen."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Elements does not have Layer parent."); - return false; - } - - layer->ReorderByXPos(); } else { std::sort(fullParents.begin(), fullParents.end(), Object::sortByUlx); @@ -2687,8 +2670,6 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e return false; } secondParent->AddChild(fullSyllable); - Layer *layer = vrv_cast(fullSyllable->GetFirstAncestor(LAYER)); - assert(layer); if (ulx >= 0 && uly >= 0 && lrx >= 0 && lry >= 0) { FacsimileInterface *facsInter = vrv_cast(fullSyl->GetFacsimileInterface()); assert(facsInter); @@ -2703,7 +2684,6 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e assert(lry >= 0); zone->SetLry(lry); } - layer->ReorderByXPos(); parent = fullSyllable; } } @@ -2764,6 +2744,10 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } } + Layer *layer = dynamic_cast(parent->GetFirstAncestor(LAYER)); + assert(layer); + layer->ReorderByXPos(); + m_infoObject.import("uuid", parent->GetID()); m_infoObject.import("status", status); m_infoObject.import("message", message); From 87bc478aa03a96cc3d8b129db18228326cfe44a0 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 31 Jul 2023 15:48:36 -0400 Subject: [PATCH 69/91] Rename fullSyllable to parent --- src/editortoolkit_neume.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 0f3af38680d..9607b387ac1 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2601,7 +2601,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } else { std::sort(fullParents.begin(), fullParents.end(), Object::sortByUlx); - Syllable *fullSyllable = new Syllable(); + Syllable *parent = new Syllable(); Syl *fullSyl = NULL; // construct concatenated string of all the syls @@ -2655,13 +2655,13 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e Text *text = vrv_cast(fullSyl->FindDescendantByType(TEXT)); assert(text); text->SetText(fullString); - assert(fullSyllable); - fullSyllable->AddChild(fullSyl); + assert(parent); + parent->AddChild(fullSyl); // Move elements to the new group syllable for (auto it = elements.begin(); it != elements.end(); ++it) { - if ((*it)->GetParent() != fullSyllable && !(*it)->Is(SYL)) { - (*it)->MoveItselfTo(fullSyllable); + if ((*it)->GetParent() != parent && !(*it)->Is(SYL)) { + (*it)->MoveItselfTo(parent); } } @@ -2669,7 +2669,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e LogError("No second level parent!"); return false; } - secondParent->AddChild(fullSyllable); + secondParent->AddChild(parent); if (ulx >= 0 && uly >= 0 && lrx >= 0 && lry >= 0) { FacsimileInterface *facsInter = vrv_cast(fullSyl->GetFacsimileInterface()); assert(facsInter); @@ -2684,7 +2684,6 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e assert(lry >= 0); zone->SetLry(lry); } - parent = fullSyllable; } } From d5fc196a72333b8cdd15255673b99dcd45cacb90 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Tue, 1 Aug 2023 16:15:37 -0400 Subject: [PATCH 70/91] Refactor multiple full parents --- src/editortoolkit_neume.cpp | 79 +++++++++++-------------------------- 1 file changed, 22 insertions(+), 57 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 9607b387ac1..8bebe73d0dc 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2600,17 +2600,23 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e secondParent->AddChild(parent); } else { - std::sort(fullParents.begin(), fullParents.end(), Object::sortByUlx); Syllable *parent = new Syllable(); Syl *fullSyl = NULL; + int ulx, uly, lrx, lry; // construct concatenated string of all the syls std::u32string fullString = U""; for (auto it = fullParents.begin(); it != fullParents.end(); ++it) { Syl *syl = dynamic_cast((*it)->FindDescendantByType(SYL)); - if (syl != NULL) { + if (syl != NULL && m_doc->GetType() == Facs) { + Zone *zone = dynamic_cast(syl->GetFacsimileInterface()->GetZone()); + if (fullSyl == NULL) { fullSyl = syl; + ulx = zone->GetUlx(); + uly = zone->GetUly(); + lrx = zone->GetLrx(); + lry = zone->GetLry(); } Text *text = dynamic_cast(syl->FindDescendantByType(TEXT)); @@ -2618,46 +2624,13 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e std::u32string currentString = text->GetText(); fullString = fullString + currentString; } + + ulx = zone->GetUlx() < ulx ? zone->GetUlx() : ulx; + uly = zone->GetUly() < uly ? zone->GetUly() : uly; + lrx = zone->GetLrx() > lrx ? zone->GetLrx() : lrx; + lry = zone->GetLry() > lry ? zone->GetLry() : lry; } } - // find the new boundingbox comprising all of the text - int ulx = -1, uly = -1, lrx = -1, lry = -1; - for (auto it = fullParents.begin(); it != fullParents.end(); ++it) { - Object *par = vrv_cast(*it); - assert(par); - Syl *descSyl = vrv_cast(par->FindDescendantByType(SYL)); - assert(descSyl); - // FacsimileInterface *facsInter = dynamic_cast - // ((*it)->FindDescendantByType(SYL)->GetFacsimileInterface()); - if (descSyl != NULL) { - FacsimileInterface *facsInter - = dynamic_cast(descSyl->GetFacsimileInterface()); - - if (facsInter != NULL) { - if (ulx == -1 || ulx > facsInter->GetDrawingX()) { - ulx = facsInter->GetDrawingX(); - } - - if (lrx < facsInter->GetWidth() + facsInter->GetDrawingX()) { - lrx = facsInter->GetWidth() + facsInter->GetDrawingX(); - } - - if (uly == -1 || uly > facsInter->GetDrawingY()) { - uly = facsInter->GetDrawingY(); - } - if (lry < facsInter->GetHeight() + facsInter->GetDrawingY()) { - lry = facsInter->GetHeight() + facsInter->GetDrawingY(); - } - } - } - } - assert(fullSyl); - Text *text = vrv_cast(fullSyl->FindDescendantByType(TEXT)); - assert(text); - text->SetText(fullString); - assert(parent); - parent->AddChild(fullSyl); - // Move elements to the new group syllable for (auto it = elements.begin(); it != elements.end(); ++it) { if ((*it)->GetParent() != parent && !(*it)->Is(SYL)) { @@ -2665,25 +2638,19 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } } - if (secondParent == NULL) { - LogError("No second level parent!"); - return false; - } - secondParent->AddChild(parent); - if (ulx >= 0 && uly >= 0 && lrx >= 0 && lry >= 0) { - FacsimileInterface *facsInter = vrv_cast(fullSyl->GetFacsimileInterface()); - assert(facsInter); - Zone *zone = vrv_cast(facsInter->GetZone()); - assert(zone); - assert(ulx >= 0); + Text *fullText = dynamic_cast(fullSyl->FindDescendantByType(TEXT)); + fullText->SetText(fullString); + parent->AddChild(fullSyl); + + if (m_doc->GetType() == Facs) { + Zone *zone = dynamic_cast(fullSyl->GetFacsimileInterface()->GetZone()); zone->SetUlx(ulx); - assert(uly >= 0); zone->SetUly(uly); - assert(lrx >= 0); zone->SetLrx(lrx); - assert(lry >= 0); zone->SetLry(lry); } + + secondParent->AddChild(parent); } } @@ -2743,9 +2710,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } } - Layer *layer = dynamic_cast(parent->GetFirstAncestor(LAYER)); - assert(layer); - layer->ReorderByXPos(); + secondParent->ReorderByXPos(); m_infoObject.import("uuid", parent->GetID()); m_infoObject.import("status", status); From a52ba37f6d6752b8a4a8dea1a5c7f0efc9a3eba9 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Tue, 1 Aug 2023 18:05:45 -0400 Subject: [PATCH 71/91] Fix bbox calculation for empty full parent --- src/editortoolkit_neume.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 8bebe73d0dc..73538765a79 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2526,18 +2526,11 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } else if (elementClass == NEUME) { parent = new Syllable(); - int lry; - int uly; + Object *oldSyl = (*elements.begin())->GetFirstAncestor(SYLLABLE)->GetFirst(SYL); for (auto it = elements.begin(); it != elements.end(); ++it) { - if ((*it)->GetParent() != parent) { - if (!(*it)->Is(SYL)) { - (*it)->MoveItselfTo(parent); - } - else { - lry = (*it)->GetFacsimileInterface()->GetZone()->GetLry(); - uly = (*it)->GetFacsimileInterface()->GetZone()->GetUly(); - } + if (!(*it)->Is(SYL)) { + (*it)->MoveItselfTo(parent); } } @@ -2553,10 +2546,10 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e if (m_doc->GetType() == Facs) { Zone *zone = new Zone(); - zone->SetUlx(parent->GetFirst(NC)->GetFacsimileInterface()->GetZone()->GetUlx()); - zone->SetUly(uly); - zone->SetLrx(parent->GetLast(NC)->GetFacsimileInterface()->GetZone()->GetLrx()); - zone->SetLry(lry); + zone->SetUlx(parent->GetFirst(NEUME)->GetFirst(NC)->GetFacsimileInterface()->GetZone()->GetUlx()); + zone->SetUly(oldSyl->GetFacsimileInterface()->GetZone()->GetUly()); + zone->SetLrx(parent->GetLast(NEUME)->GetLast(NC)->GetFacsimileInterface()->GetZone()->GetLrx()); + zone->SetLry(oldSyl->GetFacsimileInterface()->GetZone()->GetLry()); // Make bbox larger if it has less than 2 ncs if (parent->GetChildCount(NC, 2) <= 2) { @@ -2565,7 +2558,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e assert(m_doc->GetFacsimile()); m_doc->GetFacsimile()->FindDescendantByType(SURFACE)->AddChild(zone); - FacsimileInterface *fi = vrv_cast((*syl).GetFacsimileInterface()); + FacsimileInterface *fi = syl->GetFacsimileInterface(); assert(fi); fi->AttachZone(zone); } From f35390d1fc3dc1a6a875b4bf4789b0326e224353 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Tue, 1 Aug 2023 18:10:30 -0400 Subject: [PATCH 72/91] Remove unnecessary checks & reordering --- src/editortoolkit_neume.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 73538765a79..3a0ad6178a9 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2667,10 +2667,6 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e Object *obj = (*it).first; obj->ClearRelinquishedChildren(); if (obj->GetChildCount() == 0) { - if (secondParent == NULL) { - LogError("No second level parent!"); - return false; - } secondParent->DeleteChild(obj); } else if (obj->GetChildCount() @@ -2682,23 +2678,16 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } while ((leftover = obj->FindDescendantByType(DIVLINE)) != NULL) { leftover->MoveItselfTo(parent); - parent->ReorderByXPos(); obj->ClearRelinquishedChildren(); } while ((leftover = obj->FindDescendantByType(ACCID)) != NULL) { leftover->MoveItselfTo(parent); - parent->ReorderByXPos(); obj->ClearRelinquishedChildren(); } while ((leftover = obj->FindDescendantByType(CLEF)) != NULL) { leftover->MoveItselfTo(parent); - parent->ReorderByXPos(); obj->ClearRelinquishedChildren(); } - if (secondParent == NULL) { - LogError("No second level parent!"); - return false; - } secondParent->DeleteChild(obj); } } From 11425b4bbc59b82ce5f4eb23f66678def3b22ffb Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Tue, 1 Aug 2023 18:14:44 -0400 Subject: [PATCH 73/91] Remove unused variable --- src/editortoolkit_neume.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 3a0ad6178a9..44f49fba0fc 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -1636,11 +1636,9 @@ bool EditorToolkitNeume::MatchHeight(std::string elementId) int ulx; int uly; int height; - int lrx; if (dynamic_cast(element)->HasFacs()) { ulx = element->GetFacsimileInterface()->GetZone()->GetUlx(); uly = element->GetFacsimileInterface()->GetZone()->GetUly(); - lrx = element->GetFacsimileInterface()->GetZone()->GetLrx(); height = element->GetFacsimileInterface()->GetZone()->GetLry() - uly; } else { From dc01be2ae49b7b66b1753c7a3d7fb792ecbc8e9c Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Wed, 2 Aug 2023 16:12:11 -0400 Subject: [PATCH 74/91] Preserve ordering of multiple ligated nc in the same neume --- src/object.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/object.cpp b/src/object.cpp index bd6a76b6c67..c9c303b72c7 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -1272,7 +1272,10 @@ bool Object::sortByUlx(Object *a, Object *b) if (a->Is(NC) && b->Is(NC)) { Nc *nca = dynamic_cast(a); Nc *ncb = dynamic_cast(b); - if (nca->HasLigated() && ncb->HasLigated() && (a->GetParent() == b->GetParent())) { + Zone *zonea = dynamic_cast(nca->GetFacsimileInterface()->GetZone()); + Zone *zoneb = dynamic_cast(ncb->GetFacsimileInterface()->GetZone()); + if (nca->HasLigated() && ncb->HasLigated() && (a->GetParent() == b->GetParent()) + && (zonea->GetUlx() == zoneb->GetUly())) { Object *parent = a->GetParent(); assert(parent); if (abs(parent->GetChildIndex(a) - parent->GetChildIndex(b)) == 1) { From 9abbe67bb2429852cda906ed1325fb8ae840e12f Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Thu, 3 Aug 2023 10:41:03 -0400 Subject: [PATCH 75/91] Add validity check && correction --- src/object.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/object.cpp b/src/object.cpp index c9c303b72c7..086e4589db2 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -1273,9 +1273,11 @@ bool Object::sortByUlx(Object *a, Object *b) Nc *nca = dynamic_cast(a); Nc *ncb = dynamic_cast(b); Zone *zonea = dynamic_cast(nca->GetFacsimileInterface()->GetZone()); + assert(zonea); Zone *zoneb = dynamic_cast(ncb->GetFacsimileInterface()->GetZone()); + assert(zoneb); if (nca->HasLigated() && ncb->HasLigated() && (a->GetParent() == b->GetParent()) - && (zonea->GetUlx() == zoneb->GetUly())) { + && (zonea->GetUlx() == zoneb->GetUlx())) { Object *parent = a->GetParent(); assert(parent); if (abs(parent->GetChildIndex(a) - parent->GetChildIndex(b)) == 1) { From 51f2b105eb9ee8d47fc4ce02df4e33cf19408971 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 14 Aug 2023 14:37:15 -0400 Subject: [PATCH 76/91] Convert m_infoObject to m_editInfo --- include/vrv/editortoolkit_neume.h | 7 +- src/editortoolkit_neume.cpp | 622 +++++++++++++++--------------- 2 files changed, 315 insertions(+), 314 deletions(-) diff --git a/include/vrv/editortoolkit_neume.h b/include/vrv/editortoolkit_neume.h index a31242d2970..108b50e5266 100644 --- a/include/vrv/editortoolkit_neume.h +++ b/include/vrv/editortoolkit_neume.h @@ -31,8 +31,8 @@ namespace vrv { class EditorToolkitNeume : public EditorToolkit { public: EditorToolkitNeume(Doc *doc, View *view) : EditorToolkit(doc, view) {} - bool ParseEditorAction(const std::string &json_editorAction); - virtual std::string EditInfo() { return m_infoObject.json(); }; + bool ParseEditorAction(const std::string &json_editorAction) override; + std::string EditInfo() override; /** * Experimental editor functions. @@ -100,9 +100,6 @@ class EditorToolkitNeume : public EditorToolkit { bool AdjustPitchFromPosition(Object *obj, Clef *clef = NULL); bool AdjustClefLineFromPosition(Clef *clef, Staff *staff = NULL); ///@} - -private: - jsonxx::Object m_infoObject; }; //-------------------------------------------------------------------------------- diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 44f49fba0fc..7f55e3298ad 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -41,25 +41,29 @@ //-------------------------------------------------------------------------------- namespace vrv { +std::string EditorToolkitNeume::EditInfo() +{ + return m_editInfo.json(); +} bool EditorToolkitNeume::ParseEditorAction(const std::string &json_editorAction) { jsonxx::Object json; - m_infoObject.reset(); + // m_editInfo.reset(); // Read JSON actions if (!json.parse(json_editorAction)) { LogError("Cannot parse JSON std::string."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Cannot parse JSON from std::string " + json_editorAction); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Cannot parse JSON from std::string " + json_editorAction); return false; } if (!json.has("action") || (!json.has("param") && !json.has("param"))) { LogWarning("Incorrectly formatted JSON action"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "JSON action misformatted."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "JSON action misformatted."); return false; } @@ -67,8 +71,8 @@ bool EditorToolkitNeume::ParseEditorAction(const std::string &json_editorAction) if (action != "chain" && json.has("param")) { LogWarning("Only 'chain' uses 'param' as an array."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "'param' can only be an array for a chain action."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "'param' can only be an array for a chain action."); return false; } @@ -239,8 +243,8 @@ bool EditorToolkitNeume::ParseEditorAction(const std::string &json_editorAction) else { LogWarning("Unknown action type '%s'.", action.c_str()); } - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Action " + action + " could not be parsed or is unknown."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Action " + action + " could not be parsed or is unknown."); return false; } @@ -252,15 +256,15 @@ bool EditorToolkitNeume::Chain(jsonxx::Array actions) for (int i = 0; i < (int)actions.size(); i++) { if (!actions.has(0)) { LogError("Action %d was not an object", i); - m_infoObject.reset(); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Action " + std::to_string(i) + " was not an object."); + m_editInfo.reset(); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Action " + std::to_string(i) + " was not an object."); return false; } status |= this->ParseEditorAction(actions.get(i).json()); - results.import(std::to_string(i), m_infoObject); + results.import(std::to_string(i), m_editInfo); } - m_infoObject = results; + m_editInfo = results; return status; } @@ -481,8 +485,8 @@ bool EditorToolkitNeume::Drag(std::string elementId, int x, int y) std::string status = "OK", message = ""; if (!m_doc->GetDrawingPage()) { LogError("Could not get drawing page."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get drawing page."); return false; } @@ -514,8 +518,8 @@ bool EditorToolkitNeume::Drag(std::string elementId, int x, int y) Layer *layer = dynamic_cast(element->GetFirstAncestor(LAYER)); if (!layer) { LogError("Element does not have Layer parent. This should not happen."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Element does not have Layer parent."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Element does not have Layer parent."); return false; } @@ -594,8 +598,8 @@ bool EditorToolkitNeume::Drag(std::string elementId, int x, int y) Clef *clef = dynamic_cast(element); if (!clef->HasFacs()) { LogError("Clef dragging is only supported for clefs with facsimiles!"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Clef dragging is only supported for clefs with facsimiles."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Clef dragging is only supported for clefs with facsimiles."); return false; } FacsimileInterface *fi = (*clef).GetFacsimileInterface(); @@ -646,8 +650,8 @@ bool EditorToolkitNeume::Drag(std::string elementId, int x, int y) Staff *staff = vrv_cast(element); if (!staff->HasFacs()) { LogError("Staff dragging is only supported for staves with facsimiles!"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Staff dragging is only supported for staves with facsimiles."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Staff dragging is only supported for staves with facsimiles."); return false; } @@ -675,8 +679,8 @@ bool EditorToolkitNeume::Drag(std::string elementId, int x, int y) Syl *syl = dynamic_cast(element); if (!syl->HasFacs()) { LogError("Syl (boundingbox) dragging is only supported for syls with facsimiles!"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Syl dragging is only supported for syls with facsimiles."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Syl dragging is only supported for syls with facsimiles."); return false; } FacsimileInterface *fi = (*syl).GetFacsimileInterface(); @@ -689,8 +693,8 @@ bool EditorToolkitNeume::Drag(std::string elementId, int x, int y) Accid *accid = dynamic_cast(element); if (!accid->HasFacs()) { LogError("Accid dragging is only supported for accid with facsimiles!"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Accid dragging is only supported for accid with facsimiles."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Accid dragging is only supported for accid with facsimiles."); return false; } FacsimileInterface *fi = (*accid).GetFacsimileInterface(); @@ -706,8 +710,8 @@ bool EditorToolkitNeume::Drag(std::string elementId, int x, int y) DivLine *divLine = dynamic_cast(element); if (!divLine->HasFacs()) { LogError("DivLine dragging is only supported for divLine with facsimiles!"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "DivLine dragging is only supported for divLine with facsimiles."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "DivLine dragging is only supported for divLine with facsimiles."); return false; } FacsimileInterface *fi = (*divLine).GetFacsimileInterface(); @@ -721,14 +725,14 @@ bool EditorToolkitNeume::Drag(std::string elementId, int x, int y) } else { LogWarning("Unsupported element for dragging."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Unsupported element for dragging."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Unsupported element for dragging."); return false; } Layer *layer = vrv_cast(element->GetFirstAncestor(LAYER)); layer->ReorderByXPos(); // Reflect position order of elements internally (and in the resulting output file) - m_infoObject.import("status", status); - m_infoObject.import("message", message); + m_editInfo.import("status", status); + m_editInfo.import("message", message); return true; } @@ -737,14 +741,14 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in { if (!m_doc->GetDrawingPage()) { LogError("Could not get drawing page"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get drawing page."); return false; } if (m_doc->GetType() != Facs) { LogError("Drawing page without facsimile"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Drawing page without facsimile is unsupported."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Drawing page without facsimile is unsupported."); return false; } @@ -821,9 +825,9 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in parent->InsertChild(newStaff, i); parent->Modify(); - m_infoObject.import("uuid", newStaff->GetID()); - m_infoObject.import("status", status); - m_infoObject.import("message", message); + m_editInfo.import("uuid", newStaff->GetID()); + m_editInfo.import("status", status); + m_editInfo.import("message", message); return true; } @@ -833,17 +837,17 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in parent->AddChild(newStaff); parent->Modify(); - m_infoObject.import("uuid", newStaff->GetID()); - m_infoObject.import("status", status); - m_infoObject.import("message", message); + m_editInfo.import("uuid", newStaff->GetID()); + m_editInfo.import("status", status); + m_editInfo.import("message", message); return true; } if (staff == NULL) { LogError("A staff must exist in the page to add a non-staff element."); delete zone; - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "A staff must exist in the page to add a non-staff element."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "A staff must exist in the page to add a non-staff element."); return false; } Layer *layer = vrv_cast(staff->FindDescendantByType(LAYER)); @@ -930,8 +934,8 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in delete nc; LogError("Failed to set pitch."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Failed to set pitch."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Failed to set pitch."); return false; } @@ -993,8 +997,8 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in LogError("Unsupported character in contour."); delete newNc; delete newZone; - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Unsupported character in contour."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Unsupported character in contour."); return false; } @@ -1019,10 +1023,10 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in } } if (elementType == "nc") { - m_infoObject.import("uuid", nc->GetID()); + m_editInfo.import("uuid", nc->GetID()); } else { - m_infoObject.import("uuid", neume->GetID()); + m_editInfo.import("uuid", neume->GetID()); } } else if (elementType == "clef") { @@ -1047,8 +1051,8 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in LogError("A clef shape must be specified."); delete clef; - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "A clef shape must be specified."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "A clef shape must be specified."); return false; } clef->SetShape(clefShape); @@ -1069,7 +1073,7 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in assert(surface); surface->AddChild(zone); layer->AddChild(clef); - m_infoObject.import("uuid", clef->GetID()); + m_editInfo.import("uuid", clef->GetID()); layer->ReorderByXPos(); // ensure pitched elements associated with this clef keep their x,y positions @@ -1120,11 +1124,11 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in if (!AdjustPitchFromPosition(custos)) { LogError("Failed to set pitch."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Failed to set pitch."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Failed to set pitch."); return false; } - m_infoObject.import("uuid", custos->GetID()); + m_editInfo.import("uuid", custos->GetID()); } else if (elementType == "accid") { Accid *accid = new Accid(); @@ -1145,8 +1149,8 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in LogError("A accid type must be specified."); delete accid; - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "A accid type must be specified."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "A accid type must be specified."); return false; } @@ -1171,7 +1175,7 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in zone->SetLry(uly + noteHeight); layer->ReorderByXPos(); - m_infoObject.import("uuid", accid->GetID()); + m_editInfo.import("uuid", accid->GetID()); } else if (elementType == "divLine") { DivLine *divLine = new DivLine(); @@ -1209,8 +1213,8 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in LogError("A divLine type must be specified."); delete divLine; - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "A divLine type must be specified."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "A divLine type must be specified."); return false; } @@ -1235,18 +1239,18 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in zone->SetLry(uly + noteHeight); layer->ReorderByXPos(); - m_infoObject.import("uuid", divLine->GetID()); + m_editInfo.import("uuid", divLine->GetID()); } else { delete zone; LogError("Unsupported type '%s' for insertion", elementType.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Unsupported type '" + elementType + "' for insertion."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Unsupported type '" + elementType + "' for insertion."); return false; } layer->ReorderByXPos(); - m_infoObject.import("status", status); - m_infoObject.import("message", message); + m_editInfo.import("status", status); + m_editInfo.import("message", message); return true; } @@ -1254,14 +1258,14 @@ bool EditorToolkitNeume::InsertToSyllable(std::string elementId) { if (!m_doc->GetDrawingPage()) { LogError("Could not get drawing page"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get drawing page."); return false; } if (m_doc->GetType() != Facs) { LogError("Drawing page without facsimile"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Drawing page without facsimile is unsupported."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Drawing page without facsimile is unsupported."); return false; } @@ -1272,23 +1276,23 @@ bool EditorToolkitNeume::InsertToSyllable(std::string elementId) if (element == NULL) { LogError("No element exists with ID '%s'.", elementId.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "No element exists with ID" + elementId + "."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "No element exists with ID" + elementId + "."); return false; } if (!(element->Is(DIVLINE) || element->Is(ACCID) || element->Is(CLEF))) { LogError("Element is of type %s, but only Divlines and Accids can be inserted into syllables.", element->GetClassName().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Element is of type " + element->GetClassName() + ", but only DivLines, Accids, and Clefs can be inserted into syllables."); return false; } if (!parent->Is(LAYER)) { LogError("The selected %s is not a child of layer.", element->GetClassName().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "The selected " + element->GetClassName() + "is not a child of layer."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "The selected " + element->GetClassName() + "is not a child of layer."); return false; } @@ -1301,8 +1305,8 @@ bool EditorToolkitNeume::InsertToSyllable(std::string elementId) } else { LogError("Selected '%s' without facsimile", element->GetClassName().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Selected '" + element->GetClassName() + "' without facsimile is unsupported."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Selected '" + element->GetClassName() + "' without facsimile is unsupported."); return false; } @@ -1316,8 +1320,8 @@ bool EditorToolkitNeume::InsertToSyllable(std::string elementId) if (neumes.empty()) { LogError("A syllable must exist in the staff to insert a '%s' into.", element->GetClassName().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import( + m_editInfo.import("status", "FAILURE"); + m_editInfo.import( "message", "A syllable must exist in the staff to insert a '" + element->GetClassName() + "' into."); return false; } @@ -1395,8 +1399,8 @@ bool EditorToolkitNeume::InsertToSyllable(std::string elementId) } } - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); return true; } @@ -1404,14 +1408,14 @@ bool EditorToolkitNeume::MoveOutsideSyllable(std::string elementId) { if (!m_doc->GetDrawingPage()) { LogError("Could not get drawing page"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get drawing page."); return false; } if (m_doc->GetType() != Facs) { LogError("Drawing page without facsimile"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Drawing page without facsimile is unsupported."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Drawing page without facsimile is unsupported."); return false; } @@ -1422,23 +1426,23 @@ bool EditorToolkitNeume::MoveOutsideSyllable(std::string elementId) if (element == NULL) { LogError("No element exists with ID '%s'.", elementId.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "No element exists with ID" + elementId + "."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "No element exists with ID" + elementId + "."); return false; } if (!(element->Is(DIVLINE) || element->Is(ACCID) || element->Is(CLEF))) { LogError("Element is of type %s, but only Divlines, Accids, and Clefs can be moved out of syllables.", element->GetClassName().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Element is of type " + element->GetClassName() + ", but only DivLines and Accids can be inserted into syllables."); return false; } if (!parent->Is(SYLLABLE)) { LogError("The selected %s is not a child of syllable.", element->GetClassName().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "The selected " + element->GetClassName() + "is not a child of syllable."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "The selected " + element->GetClassName() + "is not a child of syllable."); return false; } @@ -1518,8 +1522,8 @@ bool EditorToolkitNeume::MoveOutsideSyllable(std::string elementId) // INSIDE do nothing } - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); return true; } @@ -1527,15 +1531,15 @@ bool EditorToolkitNeume::DisplaceClefOctave(std::string elementId, std::string d { if (!m_doc->GetDrawingPage()) { LogError("Could not get the drawing page."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the drawing page."); return false; } if (direction != "above" && direction != "below") { LogError("Direction can only be either \"above\" or \"below\"."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Direction can only be either \"above\" or \"below\"."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Direction can only be either \"above\" or \"below\"."); return false; } @@ -1543,8 +1547,8 @@ bool EditorToolkitNeume::DisplaceClefOctave(std::string elementId, std::string d Object *obj = page->FindDescendantByID(elementId); if (obj == NULL || !obj->Is(CLEF)) { LogError("This action can only be done on clefs!"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "This action can only be done on clefs!"); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "This action can only be done on clefs!"); return false; } @@ -1559,8 +1563,8 @@ bool EditorToolkitNeume::DisplaceClefOctave(std::string elementId, std::string d if (octaveDis > 3 || octaveDis < -3) { LogError("Clefs can only be displaced 3 octaves."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Clefs can only be displaced 3 octaves."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Clefs can only be displaced 3 octaves."); return false; } @@ -1595,8 +1599,8 @@ bool EditorToolkitNeume::DisplaceClefOctave(std::string elementId, std::string d nc->SetOct(nc->GetOct() + move); }); - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); return true; } @@ -1604,14 +1608,14 @@ bool EditorToolkitNeume::MatchHeight(std::string elementId) { if (!m_doc->GetDrawingPage()) { LogError("Could not get drawing page"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get drawing page."); return false; } if (m_doc->GetType() != Facs) { LogError("Drawing page without facsimile"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Drawing page without facsimile is unsupported."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Drawing page without facsimile is unsupported."); return false; } @@ -1620,14 +1624,14 @@ bool EditorToolkitNeume::MatchHeight(std::string elementId) Object *staffParent = element->GetFirstAncestor(STAFF); if (element == NULL) { LogError("No element exists with ID '%s'.", elementId.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "No element exists with ID" + elementId + "."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "No element exists with ID" + elementId + "."); return false; } if (!element->Is(SYL)) { LogError("Element is of type %s, but only element can match height.", element->GetClassName().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import( + m_editInfo.import("status", "FAILURE"); + m_editInfo.import( "message", "Element is of type " + element->GetClassName() + ", but only element can match height."); return false; } @@ -1643,8 +1647,8 @@ bool EditorToolkitNeume::MatchHeight(std::string elementId) } else { LogError("Selected '%s' without facsimile", element->GetClassName().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Selected '" + element->GetClassName() + "' without facsimile is unsupported."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Selected '" + element->GetClassName() + "' without facsimile is unsupported."); return false; } @@ -1686,8 +1690,8 @@ bool EditorToolkitNeume::MatchHeight(std::string elementId) zone->SetLry(uly + offsetY + height); } - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); return true; } @@ -1704,15 +1708,15 @@ bool EditorToolkitNeume::Merge(std::vector elementIds) } else { LogError("Staff with ID '%s' does not exist!", it->c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Staff with ID '" + *it + "' does not exist."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Staff with ID '" + *it + "' does not exist."); return false; } } if (staves.size() < 2) { LogError("At least two staves must be provided."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "At least two staves must be provided."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "At least two staves must be provided."); return false; } @@ -1773,9 +1777,9 @@ bool EditorToolkitNeume::Merge(std::vector elementIds) fillLayer->ReorderByXPos(); - m_infoObject.import("uuid", fillStaff->GetID()); - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); + m_editInfo.import("uuid", fillStaff->GetID()); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); // TODO change zones for staff children @@ -1817,8 +1821,8 @@ bool EditorToolkitNeume::Set(std::string elementId, std::string attrType, std::s m_doc->PrepareData(); m_doc->GetDrawingPage()->LayOut(true); } - m_infoObject.import("status", success ? "OK" : "FAILURE"); - m_infoObject.import("message", success ? "" : "Could not set attribute '" + attrType + "' to '" + attrValue + "'."); + m_editInfo.import("status", success ? "OK" : "FAILURE"); + m_editInfo.import("message", success ? "" : "Could not set attribute '" + attrType + "' to '" + attrValue + "'."); return success; } @@ -1828,15 +1832,15 @@ bool EditorToolkitNeume::SetText(std::string elementId, const std::string &text) std::string status = "OK", message = ""; const std::u32string wtext = UTF8to32(text); if (!m_doc->GetDrawingPage()) { - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not find drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not find drawing page."); return false; } Object *element = m_doc->GetDrawingPage()->FindDescendantByID(elementId); if (element == NULL) { LogWarning("No element with ID '%s' exists", elementId.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "No element with ID '" + elementId + "' exists."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "No element with ID '" + elementId + "' exists."); return false; } @@ -1920,12 +1924,12 @@ bool EditorToolkitNeume::SetText(std::string elementId, const std::string &text) } else { LogError("Element type '%s' is unsupported for SetText", element->GetClassName().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Element type '" + element->GetClassName() + "' is unsupported for SetText."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Element type '" + element->GetClassName() + "' is unsupported for SetText."); return false; } - m_infoObject.import("status", success ? status : "FAILURE"); - m_infoObject.import("message", success ? message : "SetText method failed."); + m_editInfo.import("status", success ? status : "FAILURE"); + m_editInfo.import("message", success ? message : "SetText method failed."); return success; } @@ -1933,8 +1937,8 @@ bool EditorToolkitNeume::SetClef(std::string elementId, std::string shape) { if (!m_doc->GetDrawingPage()) { LogError("Could not get the drawing page."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the drawing page."); return false; } ListOfObjects objects; @@ -1957,8 +1961,8 @@ bool EditorToolkitNeume::SetClef(std::string elementId, std::string shape) success = AttModule::SetShared(clef, "shape", shape); if (!success) { LogError("Unable to set clef shape"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Unable to set clef shape."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Unable to set clef shape."); return false; } @@ -1985,8 +1989,8 @@ bool EditorToolkitNeume::SetClef(std::string elementId, std::string shape) m_doc->PrepareData(); m_doc->GetDrawingPage()->LayOut(true); } - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); return true; } @@ -1994,23 +1998,23 @@ bool EditorToolkitNeume::Split(std::string elementId, int x) { if (!m_doc->GetDrawingPage()) { LogError("Could not get the drawing page"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the drawing page."); return false; } Staff *staff = dynamic_cast(m_doc->GetDrawingPage()->FindDescendantByID(elementId)); // Validate parameters if (staff == NULL) { LogError("Either no element exists with ID '%s' or it is not a staff.", elementId.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Either no element exists with ID '" + elementId + "' or it is not a staff."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Either no element exists with ID '" + elementId + "' or it is not a staff."); return false; } if (staff->GetZone()->GetUlx() > x || staff->GetZone()->GetLrx() < x) { LogError("The 'x' parameter is not within the bounds of the original staff."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "The 'x' parameter is not within bounds of the original staff."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "The 'x' parameter is not within bounds of the original staff."); return false; } @@ -2024,19 +2028,19 @@ bool EditorToolkitNeume::Split(std::string elementId, int x) if (!this->Insert("staff", "auto", newUlx, newUly, newLrx, newLry, v)) { LogError("Failed to create a second staff."); - m_infoObject.reset(); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Failed to create a second staff."); + m_editInfo.reset(); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Failed to create a second staff."); return false; } Staff *splitStaff - = dynamic_cast(m_doc->GetDrawingPage()->FindDescendantByID(m_infoObject.get("uuid"))); + = dynamic_cast(m_doc->GetDrawingPage()->FindDescendantByID(m_editInfo.get("uuid"))); assert(splitStaff); if (splitStaff == NULL) { LogError("Split staff is null"); - m_infoObject.reset(); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Split staff is null."); + m_editInfo.reset(); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Split staff is null."); return false; } @@ -2078,9 +2082,9 @@ bool EditorToolkitNeume::Split(std::string elementId, int x) } } layer->ClearRelinquishedChildren(); - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); - m_infoObject.import("uuid", splitStaff->GetID()); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); + m_editInfo.import("uuid", splitStaff->GetID()); return true; } @@ -2088,8 +2092,8 @@ bool EditorToolkitNeume::Remove(std::string elementId) { if (!m_doc->GetDrawingPage()) { LogError("Could not get the drawing page."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the drawing page."); return false; } Object *obj = m_doc->GetDrawingPage()->FindDescendantByID(elementId); @@ -2101,7 +2105,7 @@ bool EditorToolkitNeume::Remove(std::string elementId) isClef = obj->Is(CLEF); Object *parent = obj->GetParent(); assert(parent); - m_infoObject.import("uuid", elementId); + m_editInfo.import("uuid", elementId); // Remove Zone for element (if any) InterfaceComparison ic(INTERFACE_FACSIMILE); ListOfObjects fiChildren; @@ -2142,9 +2146,9 @@ bool EditorToolkitNeume::Remove(std::string elementId) if (!result) { LogError("Failed to delete the desired element (%s)", elementId.c_str()); - m_infoObject.reset(); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Failed to delete the desired element (" + elementId + ")."); + m_editInfo.reset(); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Failed to delete the desired element (" + elementId + ")."); return false; } @@ -2162,9 +2166,9 @@ bool EditorToolkitNeume::Remove(std::string elementId) if (!result) { LogError("Failed to delete the desired element (%s)", elementId.c_str()); - m_infoObject.reset(); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Failed to delete the desired element (" + elementId + ")."); + m_editInfo.reset(); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Failed to delete the desired element (" + elementId + ")."); return false; } // Check if this leaves any containers empty and delete them @@ -2178,9 +2182,9 @@ bool EditorToolkitNeume::Remove(std::string elementId) result &= parent->DeleteChild(obj); if (!result) { LogError("Failed to delete empty neume (%s)", neumeId.c_str()); - m_infoObject.reset(); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Failed to delete empty neume (" + neumeId + ")."); + m_editInfo.reset(); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Failed to delete empty neume (" + neumeId + ")."); return false; } } @@ -2208,16 +2212,16 @@ bool EditorToolkitNeume::Remove(std::string elementId) result &= parent->DeleteChild(obj); if (!result) { LogError("Failed to delete empty syllable (%s)", syllableId.c_str()); - m_infoObject.reset(); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Failed to delete empty syllable (" + syllableId + ")."); + m_editInfo.reset(); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Failed to delete empty syllable (" + syllableId + ")."); return false; } } } - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); return true; } @@ -2225,22 +2229,22 @@ bool EditorToolkitNeume::Resize(std::string elementId, int ulx, int uly, int lrx { if (!m_doc->GetDrawingPage()) { LogError("Could not get the drawing page."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the drawing page."); return false; } if (m_doc->GetType() != Facs) { LogWarning("Resizing is only available in facsimile mode."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Resizing is only available in facsimile mode."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Resizing is only available in facsimile mode."); return false; } Object *obj = m_doc->GetDrawingPage()->FindDescendantByID(elementId); if (obj == NULL) { LogError("Object with ID '%s' not found.", elementId.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Object with ID '" + elementId + "' could not be found."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Object with ID '" + elementId + "' could not be found."); return false; } if (obj->Is(STAFF)) { @@ -2248,8 +2252,8 @@ bool EditorToolkitNeume::Resize(std::string elementId, int ulx, int uly, int lrx assert(staff); if (!staff->HasFacs()) { LogError("This staff does not have a facsimile."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "This staff does not have a facsimile."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "This staff does not have a facsimile."); return false; } Zone *zone = staff->GetZone(); @@ -2269,8 +2273,8 @@ bool EditorToolkitNeume::Resize(std::string elementId, int ulx, int uly, int lrx assert(syl); if (!syl->HasFacs()) { LogError("This syl (bounding box) does not have a facsimile"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "This syl does not have a facsimile."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "This syl does not have a facsimile."); return false; } Zone *zone = syl->GetZone(); @@ -2300,12 +2304,12 @@ bool EditorToolkitNeume::Resize(std::string elementId, int ulx, int uly, int lrx } else { LogError("Element of type '%s' is unsupported.", obj->GetClassName().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Element of type '" + obj->GetClassName() + "' is unsupported."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Element of type '" + obj->GetClassName() + "' is unsupported."); return false; } - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); return true; } @@ -2322,16 +2326,16 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e // Get the current drawing page if (!m_doc->GetDrawingPage()) { LogError("Could not get the drawing page."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the drawing page."); return false; } if (elementIds.size() == 0) { LogWarning("No element IDs to group!"); status = "WARNING"; message = "No element IDs to group!"; - m_infoObject.import("status", status); - m_infoObject.import("message", message); + m_editInfo.import("status", status); + m_editInfo.import("message", message); return true; } ClassId elementClass; @@ -2343,8 +2347,8 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e } else { LogError("Invalid groupType: %s", groupType.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Invalid groupType: " + groupType); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Invalid groupType: " + groupType); return false; } @@ -2354,15 +2358,15 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e Object *el = m_doc->GetDrawingPage()->FindDescendantByID(*it); if (el == NULL) { LogError("Could not get element with ID %s", it->c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get element with ID " + *it); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get element with ID " + *it); return false; } if (el->GetClassId() != elementClass) { LogError("Element %s was of class %s. Expected class %s", el->GetID().c_str(), el->GetClassName().c_str(), groupType.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Element " + el->GetID() + " was of class " + el->GetClassName() + " but expected class " + groupType + "."); return false; @@ -2372,8 +2376,8 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e Object *par = el->GetParent(); if (par == NULL) { LogError("Parent of %s is null!", el->GetID().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Parent of " + el->GetID() + " is null."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Parent of " + el->GetID() + " is null."); return false; } @@ -2401,20 +2405,20 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e std::vector elementIds0 = { elementIds.begin(), elementIds.begin() + idx }; Group("neume", elementIds0); - if (m_infoObject.get("status") == "FAILURE") { + if (m_editInfo.get("status") == "FAILURE") { resultId0 = linkedID; } else { - resultId0 = m_infoObject.get("uuid"); + resultId0 = m_editInfo.get("uuid"); } std::vector elementIds1 = { elementIds.begin() + idx, elementIds.end() }; Group("neume", elementIds1); - if (m_infoObject.get("status") == "FAILURE") { + if (m_editInfo.get("status") == "FAILURE") { resultId1 = par->GetID(); } else { - resultId1 = m_infoObject.get("uuid"); + resultId1 = m_editInfo.get("uuid"); par = m_doc->GetDrawingPage()->FindDescendantByID(resultId1); } @@ -2430,9 +2434,9 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e uuidArray << resultId0; uuidArray << resultId1; - m_infoObject.import("uuid", uuidArray); - m_infoObject.import("status", status); - m_infoObject.import("message", message); + m_editInfo.import("uuid", uuidArray); + m_editInfo.import("status", status); + m_editInfo.import("message", message); return true; } } @@ -2443,14 +2447,14 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e if (parents.size() == 0) { LogError("Could not get the parent."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the parent."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the parent."); return false; } else if (parents.size() == 1) { LogError("The selected elements are already grouped."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "The selected elements are already grouped."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "The selected elements are already grouped."); return false; } @@ -2491,8 +2495,8 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e secondParent = (*parents.begin()).first->GetParent(); if (secondParent == NULL) { LogError("No second level parent!"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "No second level parent."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "No second level parent."); return false; } // find parents where all of their children are being grouped @@ -2502,8 +2506,8 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e int expected; if (par->GetParent() != secondParent) { LogError("No shared second level parent!"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "No shared second level parent."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "No shared second level parent."); return false; } if (par->GetClassId() == SYLLABLE) { @@ -2692,9 +2696,9 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e secondParent->ReorderByXPos(); - m_infoObject.import("uuid", parent->GetID()); - m_infoObject.import("status", status); - m_infoObject.import("message", message); + m_editInfo.import("uuid", parent->GetID()); + m_editInfo.import("status", status); + m_editInfo.import("message", message); return true; } @@ -2729,8 +2733,8 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector // Check if you can get drawing page if (!m_doc->GetDrawingPage()) { LogError("Could not get the drawing page."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the drawing page."); return false; } @@ -2792,8 +2796,8 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector } else { LogError("Unable to toggle ligature within ungroup ncs!"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Unable to toggle ligature within ungroup ncs."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Unable to toggle ligature within ungroup ncs."); return false; } } @@ -2864,8 +2868,8 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector else { LogError("Invalid groupType for ungrouping"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Invalid groupType for ungrouping."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Invalid groupType for ungrouping."); return false; } } @@ -2967,9 +2971,9 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector } } - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); - m_infoObject.import("uuid", uuidArray); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); + m_editInfo.import("uuid", uuidArray); return true; } @@ -2978,8 +2982,8 @@ bool EditorToolkitNeume::SplitNeume(std::string neumeId, std::string ncId) // Check if you can get drawing page if (!m_doc->GetDrawingPage()) { LogError("Could not get the drawing page."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the drawing page."); return false; } @@ -3001,8 +3005,8 @@ bool EditorToolkitNeume::SplitNeume(std::string neumeId, std::string ncId) int nLen = fparent->GetChildCount(); if (nLen == 0) { LogError("The selected neume has no children."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "The selected neume has no children."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "The selected neume has no children."); return false; } @@ -3010,8 +3014,8 @@ bool EditorToolkitNeume::SplitNeume(std::string neumeId, std::string ncId) int fIdx = fparent->GetChildIndex(elNc); if (fIdx == -1) { LogError("The selected neume component is not a child of the selected neume."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "The selected neume component is not a child of the selected neume."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "The selected neume component is not a child of the selected neume."); return false; } // if click on a ligature, ncId point to the second nc in the ligature, thus minus 1 @@ -3045,9 +3049,9 @@ bool EditorToolkitNeume::SplitNeume(std::string neumeId, std::string ncId) // insert newParent to sparent sparent->InsertAfter(fparent, newParent); - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); - m_infoObject.import("uuid", uuidArray); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); + m_editInfo.import("uuid", uuidArray); return true; } @@ -3056,15 +3060,15 @@ bool EditorToolkitNeume::ChangeGroup(std::string elementId, std::string contour) // Check if you can get drawing page if (!m_doc->GetDrawingPage()) { LogError("Could not get the drawing page."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the drawing page."); return false; } Neume *el = dynamic_cast(m_doc->GetDrawingPage()->FindDescendantByID(elementId)); if (el == NULL) { LogError("Unable to find neume with id %s", elementId.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Unable to find neume with id " + elementId + "."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Unable to find neume with id " + elementId + "."); return false; } Nc *firstChild = NULL; @@ -3128,8 +3132,8 @@ bool EditorToolkitNeume::ChangeGroup(std::string elementId, std::string contour) LogError("Unsupported character in contour."); delete newNc; delete zone; - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Unsupported character in contour."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Unsupported character in contour."); return false; } zone->SetUlx(newUlx); @@ -3152,9 +3156,9 @@ bool EditorToolkitNeume::ChangeGroup(std::string elementId, std::string contour) initialLry = newLry; prevNc = newNc; } - m_infoObject.import("uuid", el->GetID()); - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); + m_editInfo.import("uuid", el->GetID()); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); return true; } @@ -3172,8 +3176,8 @@ bool EditorToolkitNeume::ToggleLigature(std::vector elementIds) // Check if you can get drawing page if (!m_doc->GetDrawingPage()) { LogError("Could not get the drawing page."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the drawing page."); return false; } @@ -3187,8 +3191,8 @@ bool EditorToolkitNeume::ToggleLigature(std::vector elementIds) int secondIdx = secondNc->GetIdx(); if (std::abs(firstIdx - secondIdx) != 1) { LogError("The selected ncs are not adjacent."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "The selected ncs are not adjacent."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "The selected ncs are not adjacent."); return false; } @@ -3246,20 +3250,20 @@ bool EditorToolkitNeume::ToggleLigature(std::vector elementIds) } // else { // LogError("isLigature is invalid!"); - // m_infoObject.import("status", "FAILURE"); - // m_infoObject.import("message", "isLigature value '" + 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_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); if (!(success1 && success2)) { LogWarning("Unable to update ligature attribute"); - m_infoObject.import("message", "Unable to update ligature attribute."); - m_infoObject.import("status", "WARNING"); + m_editInfo.import("message", "Unable to update ligature attribute."); + m_editInfo.import("status", "WARNING"); } surface->AddChild(zone); @@ -3270,15 +3274,15 @@ bool EditorToolkitNeume::ChangeStaff(std::string elementId) { if (!m_doc->GetDrawingPage()) { LogError("Could not get the drawing page"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the drawing page."); return false; } if (m_doc->GetType() != Facs) { LogWarning("Staff re-association is only available in facsimile mode."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "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."); return false; } @@ -3286,8 +3290,8 @@ bool EditorToolkitNeume::ChangeStaff(std::string elementId) assert(element); if (element == NULL) { LogError("No element exists with ID '%s'.", elementId.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "No element exists with ID" + elementId + "."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "No element exists with ID" + elementId + "."); return false; } @@ -3295,8 +3299,8 @@ bool EditorToolkitNeume::ChangeStaff(std::string elementId) || element->Is(ACCID))) { LogError("Element is of type %s, but only Syllables, Custos, Clefs, Divlines, and Accids can change staves.", element->GetClassName().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Element is of type " + element->GetClassName() + ", but only Syllables, Custos, Clefs, DivLines, and Accids can change staves."); return false; @@ -3317,8 +3321,8 @@ bool EditorToolkitNeume::ChangeStaff(std::string elementId) LayerElement *layerElement = dynamic_cast(element); if (!layerElement->GenerateZoneBounds(&ulx, &uly, &lrx, &lry)) { LogError("Couldn't generate bounding box for syllable."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Couldn't generate bounding box for syllable."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Couldn't generate bounding box for syllable."); return false; } comp.x = (lrx + ulx) / 2; @@ -3326,8 +3330,8 @@ bool EditorToolkitNeume::ChangeStaff(std::string elementId) } else { LogError("This element does not have a facsimile."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "This element does not have a facsimile."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "This element does not have a facsimile."); return false; } @@ -3340,8 +3344,8 @@ bool EditorToolkitNeume::ChangeStaff(std::string elementId) } else { LogError("Could not find any staves. This should not happen"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not find any staves. This should not happen"); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not find any staves. This should not happen"); return false; } @@ -3350,8 +3354,8 @@ bool EditorToolkitNeume::ChangeStaff(std::string elementId) assert(parent); if (parent == NULL || sParent == NULL) { LogError("Couldn't find staff parent of element with id '%s'", elementId.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Couldn't find staff parent of element with id " + elementId); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Couldn't find staff parent of element with id " + elementId); return false; } @@ -3359,16 +3363,16 @@ bool EditorToolkitNeume::ChangeStaff(std::string elementId) assert(LAYER); if (layer == NULL) { LogError("Couldn't find layer child of staff. This should not happen"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Couldn't find layer child of staff. This should not happen"); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Couldn't find layer child of staff. This should not happen"); return false; } if (layer == parent) { - m_infoObject.import("status", "WARNING"); - m_infoObject.import("message", "Moving to the same staff as before."); - m_infoObject.import("elementId", elementId); - m_infoObject.import("newStaffId", staff->GetID()); + m_editInfo.import("status", "WARNING"); + m_editInfo.import("message", "Moving to the same staff as before."); + m_editInfo.import("elementId", elementId); + m_editInfo.import("newStaffId", staff->GetID()); return true; } @@ -3426,8 +3430,8 @@ bool EditorToolkitNeume::ChangeStaff(std::string elementId) // Adjust clefline if (!AdjustClefLineFromPosition(dynamic_cast(element), staff)) { LogError("Could not adjust clef line of %s", element->GetID().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Failed to set clef line from facsimile."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Failed to set clef line from facsimile."); return false; } @@ -3455,19 +3459,19 @@ bool EditorToolkitNeume::ChangeStaff(std::string elementId) if (!(element->Is(ACCID) || element->Is(DIVLINE))) { if (!AdjustPitchFromPosition(element)) { LogError("Could not adjust pitch of %s", element->GetID().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Failed to properly set pitch."); - m_infoObject.import("elementId", element->GetID()); - m_infoObject.import("newStaffId", staff->GetID()); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Failed to properly set pitch."); + m_editInfo.import("elementId", element->GetID()); + m_editInfo.import("newStaffId", staff->GetID()); return false; } } } - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); - m_infoObject.import("elementId", elementId); - m_infoObject.import("newStaffId", staff->GetID()); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); + m_editInfo.import("elementId", elementId); + m_editInfo.import("newStaffId", staff->GetID()); return true; } @@ -3475,15 +3479,15 @@ bool EditorToolkitNeume::ChangeStaffTo(std::string elementId, std::string staffI { if (!m_doc->GetDrawingPage()) { LogError("Could not get the drawing page"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not get the drawing page."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not get the drawing page."); return false; } if (m_doc->GetType() != Facs) { LogWarning("Staff re-association is only available in facsimile mode."); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "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."); return false; } @@ -3491,16 +3495,16 @@ bool EditorToolkitNeume::ChangeStaffTo(std::string elementId, std::string staffI assert(element); if (element == NULL) { LogError("No element exists with ID '%s'.", elementId.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "No element exists with ID" + elementId + "."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "No element exists with ID" + elementId + "."); return false; } if (!(element->Is(CLEF) || element->Is(DIVLINE) || element->Is(ACCID))) { LogError("Element is of type %s, but only Clefs, Divlines, and Accids can change to a specified staff.", element->GetClassName().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Element is of type " + element->GetClassName() + ", but only Clefs, Divlines, and Accids can change to a specified staff."); return false; @@ -3510,8 +3514,8 @@ bool EditorToolkitNeume::ChangeStaffTo(std::string elementId, std::string staffI if (!staff) { LogError("Could not find any staves. This should not happen"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Could not find any staves. This should not happen"); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Could not find any staves. This should not happen"); return false; } @@ -3520,8 +3524,8 @@ bool EditorToolkitNeume::ChangeStaffTo(std::string elementId, std::string staffI assert(parent); if (parent == NULL || sParent == NULL) { LogError("Couldn't find staff parent of element with id '%s'", elementId.c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Couldn't find staff parent of element with id " + elementId); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Couldn't find staff parent of element with id " + elementId); return false; } @@ -3529,16 +3533,16 @@ bool EditorToolkitNeume::ChangeStaffTo(std::string elementId, std::string staffI assert(LAYER); if (layer == NULL) { LogError("Couldn't find layer child of staff. This should not happen"); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Couldn't find layer child of staff. This should not happen"); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Couldn't find layer child of staff. This should not happen"); return false; } if (layer == parent) { - m_infoObject.import("status", "WARNING"); - m_infoObject.import("message", "Moving to the same staff as before."); - m_infoObject.import("elementId", elementId); - m_infoObject.import("newStaffId", staff->GetID()); + m_editInfo.import("status", "WARNING"); + m_editInfo.import("message", "Moving to the same staff as before."); + m_editInfo.import("elementId", elementId); + m_editInfo.import("newStaffId", staff->GetID()); return true; } @@ -3596,8 +3600,8 @@ bool EditorToolkitNeume::ChangeStaffTo(std::string elementId, std::string staffI // Adjust clefline if (!AdjustClefLineFromPosition(dynamic_cast(element), staff)) { LogError("Could not adjust clef line of %s", element->GetID().c_str()); - m_infoObject.import("status", "FAILURE"); - m_infoObject.import("message", "Failed to set clef line from facsimile."); + m_editInfo.import("status", "FAILURE"); + m_editInfo.import("message", "Failed to set clef line from facsimile."); return false; } @@ -3624,10 +3628,10 @@ bool EditorToolkitNeume::ChangeStaffTo(std::string elementId, std::string staffI parent->ReorderByXPos(); } - m_infoObject.import("status", "OK"); - m_infoObject.import("message", ""); - m_infoObject.import("elementId", elementId); - m_infoObject.import("newStaffId", staff->GetID()); + m_editInfo.import("status", "OK"); + m_editInfo.import("message", ""); + m_editInfo.import("elementId", elementId); + m_editInfo.import("newStaffId", staff->GetID()); return true; } From 8e0d846cc3f326f4ef45d3daac2eb2715edeca88 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 14 Aug 2023 14:48:46 -0400 Subject: [PATCH 77/91] Fix outer scope shadowing --- src/editortoolkit_neume.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 7f55e3298ad..cfc0b513083 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2595,7 +2595,7 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e secondParent->AddChild(parent); } else { - Syllable *parent = new Syllable(); + parent = new Syllable(); Syl *fullSyl = NULL; int ulx, uly, lrx, lry; From 31dcb03c1f003b845fbd43f8e512ebd9e2ffdf94 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 14 Aug 2023 14:49:21 -0400 Subject: [PATCH 78/91] Clean up comments --- src/editortoolkit_neume.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index cfc0b513083..b565321602d 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2400,9 +2400,6 @@ bool EditorToolkitNeume::Group(std::string groupType, std::vector e std::string resultId0; std::string resultId1; - // LogMessage("%s", chainArray.get(0).json().c_str()); - // for_each(elementIds.begin(), elementIds.begin()+idx,[](std::string s){LogMessage("%s", s.c_str());}); - std::vector elementIds0 = { elementIds.begin(), elementIds.begin() + idx }; Group("neume", elementIds0); if (m_editInfo.get("status") == "FAILURE") { From f3a565111fde416729014f189a41f471d2d09633 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 14 Aug 2023 16:56:28 -0400 Subject: [PATCH 79/91] Break when last element --- src/editortoolkit_neume.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index b565321602d..decb9bc5ca6 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2810,6 +2810,7 @@ bool EditorToolkitNeume::Ungroup(std::string groupType, std::vector fparent->ReorderByXPos(); uuidArray << (*it); it = elementIds.erase(it); + if (it == elementIds.end()) break; el = m_doc->GetDrawingPage()->FindDescendantByID(*it); } } From 7b96407768f77f6e0ec7122fdb5163509c82ef9e Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Tue, 15 Aug 2023 16:50:29 -0400 Subject: [PATCH 80/91] Reset m_editInfo for OOM error --- src/editortoolkit_neume.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index decb9bc5ca6..5a9dd322d76 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -49,7 +49,7 @@ std::string EditorToolkitNeume::EditInfo() bool EditorToolkitNeume::ParseEditorAction(const std::string &json_editorAction) { jsonxx::Object json; - // m_editInfo.reset(); + m_editInfo.reset(); // Read JSON actions if (!json.parse(json_editorAction)) { From 6238cffd718b9e77007932ab6a230d75709ed1b4 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Thu, 17 Aug 2023 18:15:41 -0400 Subject: [PATCH 81/91] Refactor new bbox zone && add staff rotation offset --- src/editortoolkit_neume.cpp | 66 ++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 37 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 5a9dd322d76..769fc5e0c34 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -858,12 +858,12 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in Syl *syl = new Syl(); Neume *neume = new Neume(); Nc *nc = new Nc(); + Zone *sylZone; std::string contour = ""; nc->AttachZone(zone); Surface *surface = vrv_cast(facsimile->FindDescendantByType(SURFACE)); surface->AddChild(zone); - zone->SetUlx(ulx); Text *text = new Text(); std::u32string str = U""; @@ -875,57 +875,48 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in syllable->AddChild(syl); layer->AddChild(syllable); + 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); + ulx -= noteWidth / 2; + + // calculate staff rotation offset + double theta = staff->GetDrawingRotate(); + int offsetY = 0; + if (theta) { + double factor = 1.3; + offsetY = (int)((ulx - staff->GetFacsimileInterface()->GetZone()->GetUlx()) * tan(theta * M_PI / 180.0) + / factor); + } + + // Set up facsimile + zone->SetUlx(ulx); + zone->SetUly(uly + offsetY); + zone->SetLrx(ulx + noteWidth); + zone->SetLry(uly + offsetY + noteHeight); + // add syl bounding box if Facs if (m_doc->GetType() == Facs) { FacsimileInterface *fi = vrv_cast(syl->GetFacsimileInterface()); assert(fi); - Zone *sylZone = new Zone(); + sylZone = new Zone(); - // calculate bboxUlx and bboxUly wrt rotation using sine rule - int draw_w = staff->GetWidth(); int draw_h = staff->GetHeight(); - double theta = staff->GetDrawingRotate(); int staffUly = staff->GetDrawingY(); - int x = ulx - staff->GetDrawingX(); - int bboxUlx = ulx; - int bboxUly; - // if staff rotates downward to the right - if (theta > 0) { - int y = (int)((draw_w - x) * tan(theta * M_PI / 180.0)); - bboxUly = staffUly + draw_h - y; - } - // if staff rotates upwards to the right - else { - int y = (int)(x * tan(-theta * M_PI / 180.0)); - int h = (int)(draw_w * tan(-theta * M_PI / 180.0)); - bboxUly = staffUly + (draw_h - h) - y; - } // width height and offset can be adjusted - int bboxWidth = 225; int bboxHeight = 175; int bboxOffsetX = 50; - sylZone->SetUlx(bboxUlx - bboxOffsetX); - sylZone->SetUly(bboxUly); - sylZone->SetLrx(bboxUlx + bboxWidth - bboxOffsetX); - sylZone->SetLry(bboxUly + bboxHeight); + sylZone->SetUlx(ulx); + sylZone->SetUly(staffUly + draw_h + offsetY); + sylZone->SetLrx(ulx + noteWidth + bboxOffsetX); + sylZone->SetLry(staffUly + draw_h + offsetY + bboxHeight); surface->AddChild(sylZone); fi->AttachZone(sylZone); } - 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); - ulx -= noteWidth / 2; - // uly -= noteHeight / 2; - // Set up facsimile - zone->SetUlx(ulx); - zone->SetUly(uly); - zone->SetLrx(ulx + noteWidth); - zone->SetLry(uly + noteHeight); - layer->ReorderByXPos(); if (!AdjustPitchFromPosition(syllable)) { @@ -1006,12 +997,13 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in newUly += (newUlx - ulx) * tan(-staff->GetDrawingRotate() * M_PI / 180.0); newZone->SetUlx(newUlx); newZone->SetUly(newUly); - ; newZone->SetLrx(newUlx + noteWidth); newZone->SetLry(newUly + noteHeight); newNc->AttachZone(newZone); + if (sylZone) sylZone->SetLrx(newUlx + noteWidth); + assert(surface); surface->AddChild(newZone); From 7be37548e61310d0b62e265a4e0a93ddeca557db Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Fri, 27 Oct 2023 16:32:50 -0400 Subject: [PATCH 82/91] Add empty syl for follows syllable if precedes becomes empty --- src/editortoolkit_neume.cpp | 41 ++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 769fc5e0c34..7bea9763139 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2196,7 +2196,46 @@ bool EditorToolkitNeume::Remove(std::string elementId) = dynamic_cast(m_doc->GetDrawingPage()->FindDescendantByID(linkedID)); if (linkedSyllable != NULL) { if (linkedSyllable->HasPrecedes()) linkedSyllable->SetPrecedes(""); - if (linkedSyllable->HasFollows()) linkedSyllable->SetFollows(""); + if (linkedSyllable->HasFollows()) { + linkedSyllable->SetFollows(""); + // Create an empty syl for the second part + Syl *syl = new Syl(); + Text *text = new Text(); + std::u32string str = U""; + text->SetText(str); + syl->AddChild(text); + linkedSyllable->AddChild(syl); + + // Create default bounding box if facs + if (m_doc->GetType() == Facs) { + Zone *zone = new Zone(); + + zone->SetUlx(linkedSyllable->GetFirst(NEUME) + ->GetFirst(NC) + ->GetFacsimileInterface() + ->GetZone() + ->GetUlx()); + zone->SetUly( + linkedSyllable->GetAncestorStaff()->GetFacsimileInterface()->GetZone()->GetLry()); + zone->SetLrx(linkedSyllable->GetLast(NEUME) + ->GetLast(NC) + ->GetFacsimileInterface() + ->GetZone() + ->GetLrx()); + zone->SetLry(zone->GetUly() + 100); + + // Make bbox larger if it has less than 2 ncs + if (linkedSyllable->GetChildCount(NC, 2) <= 2) { + zone->SetLrx(zone->GetLrx() + 50); + } + + assert(m_doc->GetFacsimile()); + m_doc->GetFacsimile()->FindDescendantByType(SURFACE)->AddChild(zone); + FacsimileInterface *fi = syl->GetFacsimileInterface(); + assert(fi); + fi->AttachZone(zone); + } + }; } } // Delete the syllable empty of neumes From b0916d7e41de50fd0066625fcbe26aa2aabdc3e5 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Fri, 1 Dec 2023 17:14:09 -0500 Subject: [PATCH 83/91] Set column value for newly inserted staff if has columns --- src/editortoolkit_neume.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 7bea9763139..1fe7b435ff8 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -783,10 +783,12 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in if (elementType == "staff") { Object *parent; Staff *newStaff; + std::string columnValue; // Use closest existing staff (if there is one) if (staff) { parent = staff->GetParent(); assert(parent); + columnValue = staff->GetType(); int n = parent->GetChildCount() + 1; newStaff = new Staff(n); newStaff->m_drawingStaffDef = staff->m_drawingStaffDef; @@ -811,6 +813,7 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in assert(surface); surface->AddChild(zone); newStaff->AttachZone(zone); + if (columnValue.length()) newStaff->SetType(columnValue); Layer *newLayer = new Layer(); newStaff->AddChild(newLayer); From 8e884fa5b0ca4b6a23c82d3b72aa4a171ce8294f Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 4 Dec 2023 20:38:54 -0500 Subject: [PATCH 84/91] Unlink syllable when removed --- include/vrv/editortoolkit_neume.h | 1 + src/editortoolkit_neume.cpp | 108 +++++++++++++++++------------- 2 files changed, 62 insertions(+), 47 deletions(-) diff --git a/include/vrv/editortoolkit_neume.h b/include/vrv/editortoolkit_neume.h index 108b50e5266..11828f083cb 100644 --- a/include/vrv/editortoolkit_neume.h +++ b/include/vrv/editortoolkit_neume.h @@ -55,6 +55,7 @@ class EditorToolkitNeume : public EditorToolkit { bool Remove(std::string elementId); bool Resize(std::string elementId, int ulx, int uly, int lrx, int lry, float resize = NAN); bool Group(std::string groupType, std::vector elementIds); + void UnlinkSyllable(Syllable *syllable); bool Ungroup(std::string groupType, std::vector elementIds); bool ChangeGroup(std::string elementId, std::string contour); bool ToggleLigature(std::vector elementIds); diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 1fe7b435ff8..d1c4b9de3ed 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2083,6 +2083,58 @@ bool EditorToolkitNeume::Split(std::string elementId, int x) return true; } +void EditorToolkitNeume::UnlinkSyllable(Syllable *syllable) +{ + 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; + } + + assert(syllable); + + std::string linkedID = (syllable->HasPrecedes() ? syllable->GetPrecedes() : syllable->GetFollows()); + if (linkedID.compare(0, 1, "#") == 0) linkedID.erase(0, 1); + Syllable *linkedSyllable = dynamic_cast(m_doc->GetDrawingPage()->FindDescendantByID(linkedID)); + if (linkedSyllable != NULL) { + if (linkedSyllable->HasPrecedes()) linkedSyllable->SetPrecedes(""); + if (linkedSyllable->HasFollows()) { + linkedSyllable->SetFollows(""); + + // Create an empty syl for the second part + Syl *syl = new Syl(); + Text *text = new Text(); + std::u32string str = U""; + text->SetText(str); + syl->AddChild(text); + linkedSyllable->AddChild(syl); + + // Create default bounding box if facs + if (m_doc->GetType() == Facs) { + Zone *zone = new Zone(); + + zone->SetUlx( + linkedSyllable->GetFirst(NEUME)->GetFirst(NC)->GetFacsimileInterface()->GetZone()->GetUlx()); + zone->SetUly(linkedSyllable->GetAncestorStaff()->GetFacsimileInterface()->GetZone()->GetLry()); + zone->SetLrx(linkedSyllable->GetLast(NEUME)->GetLast(NC)->GetFacsimileInterface()->GetZone()->GetLrx()); + zone->SetLry(zone->GetUly() + 100); + + // Make bbox larger if it has less than 2 ncs + if (linkedSyllable->GetChildCount(NC, 2) <= 2) { + zone->SetLrx(zone->GetLrx() + 50); + } + + assert(m_doc->GetFacsimile()); + m_doc->GetFacsimile()->FindDescendantByType(SURFACE)->AddChild(zone); + FacsimileInterface *fi = syl->GetFacsimileInterface(); + assert(fi); + fi->AttachZone(zone); + } + } + } +} + bool EditorToolkitNeume::Remove(std::string elementId) { if (!m_doc->GetDrawingPage()) { @@ -2155,6 +2207,14 @@ bool EditorToolkitNeume::Remove(std::string elementId) } } + if (obj->Is(SYLLABLE)) { + Syllable *syllable = dynamic_cast(obj); + assert(syllable); + if (syllable->HasPrecedes() || syllable->HasFollows()) { + UnlinkSyllable(syllable); + } + } + if (!result) { result = parent->DeleteChild(obj); } @@ -2193,53 +2253,7 @@ bool EditorToolkitNeume::Remove(std::string elementId) Syllable *li = dynamic_cast(obj); assert(li); if (li->HasPrecedes() || li->HasFollows()) { - std::string linkedID = (li->HasPrecedes() ? li->GetPrecedes() : li->GetFollows()); - if (linkedID.compare(0, 1, "#") == 0) linkedID.erase(0, 1); - Syllable *linkedSyllable - = dynamic_cast(m_doc->GetDrawingPage()->FindDescendantByID(linkedID)); - if (linkedSyllable != NULL) { - if (linkedSyllable->HasPrecedes()) linkedSyllable->SetPrecedes(""); - if (linkedSyllable->HasFollows()) { - linkedSyllable->SetFollows(""); - // Create an empty syl for the second part - Syl *syl = new Syl(); - Text *text = new Text(); - std::u32string str = U""; - text->SetText(str); - syl->AddChild(text); - linkedSyllable->AddChild(syl); - - // Create default bounding box if facs - if (m_doc->GetType() == Facs) { - Zone *zone = new Zone(); - - zone->SetUlx(linkedSyllable->GetFirst(NEUME) - ->GetFirst(NC) - ->GetFacsimileInterface() - ->GetZone() - ->GetUlx()); - zone->SetUly( - linkedSyllable->GetAncestorStaff()->GetFacsimileInterface()->GetZone()->GetLry()); - zone->SetLrx(linkedSyllable->GetLast(NEUME) - ->GetLast(NC) - ->GetFacsimileInterface() - ->GetZone() - ->GetLrx()); - zone->SetLry(zone->GetUly() + 100); - - // Make bbox larger if it has less than 2 ncs - if (linkedSyllable->GetChildCount(NC, 2) <= 2) { - zone->SetLrx(zone->GetLrx() + 50); - } - - assert(m_doc->GetFacsimile()); - m_doc->GetFacsimile()->FindDescendantByType(SURFACE)->AddChild(zone); - FacsimileInterface *fi = syl->GetFacsimileInterface(); - assert(fi); - fi->AttachZone(zone); - } - }; - } + UnlinkSyllable(li); } // Delete the syllable empty of neumes std::string syllableId = obj->GetID(); From f6a7ecfc391aed4678c8df20a1b82a8101918b23 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 11 Dec 2023 17:14:31 -0500 Subject: [PATCH 85/91] Handle empty staff when inserting new staff --- src/editortoolkit_neume.cpp | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index d1c4b9de3ed..7fe8ec86401 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -817,28 +817,27 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in Layer *newLayer = new Layer(); newStaff->AddChild(newLayer); - // 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; + 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; + } } } - LogWarning("Failed to insert newStaff into staff"); - message += "Failed to insert newStaff into staves."; parent->AddChild(newStaff); - parent->Modify(); m_editInfo.import("uuid", newStaff->GetID()); m_editInfo.import("status", status); From bcbde28d54f075e8b7507b4cc7ec21258e493802 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Tue, 12 Dec 2023 17:06:45 -0500 Subject: [PATCH 86/91] New for blank files in neume notation --- src/iomei.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/iomei.cpp b/src/iomei.cpp index aaa69f00c64..3a5fd146a75 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -4472,6 +4472,13 @@ bool MEIInput::ReadSectionChildren(Object *parent, pugi::xml_node parentNode) LogWarning("Unsupported '<%s>' within
", current.name()); } } + + // New for blank files in neume notation + if (!unmeasured && parent->Is(SECTION) && (m_doc->m_notationType == NOTATIONTYPE_neume)) { + unmeasured = new Measure(false); + m_doc->SetMensuralMusicOnly(true); + parent->AddChild(unmeasured); + } return success; } From 4a1c61fa96f68fdd7b4d23b3c969b3fcc9b8e2b9 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Tue, 19 Dec 2023 16:37:58 -0500 Subject: [PATCH 87/91] Fix removing clef error --- src/editortoolkit_neume.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 7fe8ec86401..b80c98efcac 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -2145,10 +2145,11 @@ bool EditorToolkitNeume::Remove(std::string elementId) Object *obj = m_doc->GetDrawingPage()->FindDescendantByID(elementId); assert(obj); bool result = false; - bool isNeumeOrNc, isNc, isClef; + bool isNeumeOrNc, isNc, isClef, isSyllable; isNeumeOrNc = (obj->Is(NC) || obj->Is(NEUME)); isNc = obj->Is(NC); isClef = obj->Is(CLEF); + isSyllable = obj->Is(SYLLABLE); Object *parent = obj->GetParent(); assert(parent); m_editInfo.import("uuid", elementId); @@ -2205,8 +2206,7 @@ bool EditorToolkitNeume::Remove(std::string elementId) pi->AdjustPitchForNewClef(clef, previousClef); } } - - if (obj->Is(SYLLABLE)) { + else if (isSyllable) { Syllable *syllable = dynamic_cast(obj); assert(syllable); if (syllable->HasPrecedes() || syllable->HasFollows()) { From 6ed5103e3c439bc7b7d55c61ebdb9c588767f4e1 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Thu, 21 Dec 2023 16:07:26 -0500 Subject: [PATCH 88/91] Fix staff rotation offset for inserted syllables --- src/editortoolkit_neume.cpp | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index b80c98efcac..2b1d30f6dc8 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -881,22 +881,12 @@ 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); - ulx -= noteWidth / 2; - - // calculate staff rotation offset - double theta = staff->GetDrawingRotate(); - int offsetY = 0; - if (theta) { - double factor = 1.3; - offsetY = (int)((ulx - staff->GetFacsimileInterface()->GetZone()->GetUlx()) * tan(theta * M_PI / 180.0) - / factor); - } // Set up facsimile zone->SetUlx(ulx); - zone->SetUly(uly + offsetY); + zone->SetUly(uly); zone->SetLrx(ulx + noteWidth); - zone->SetLry(uly + offsetY + noteHeight); + zone->SetLry(uly + noteHeight); // add syl bounding box if Facs if (m_doc->GetType() == Facs) { @@ -904,17 +894,25 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in assert(fi); sylZone = new Zone(); - int draw_h = staff->GetHeight(); - int staffUly = staff->GetDrawingY(); + int staffLry = staff->GetFacsimileInterface()->GetZone()->GetLry(); // width height and offset can be adjusted int bboxHeight = 175; int bboxOffsetX = 50; + // calculate staff rotation offset + double theta = staff->GetDrawingRotate(); + int offsetY = 0; + if (theta) { + double factor = 1.3; + offsetY = (int)((ulx - staff->GetFacsimileInterface()->GetZone()->GetUlx()) * tan(theta * M_PI / 180.0) + / factor); + } + sylZone->SetUlx(ulx); - sylZone->SetUly(staffUly + draw_h + offsetY); + sylZone->SetUly(staffLry + offsetY); sylZone->SetLrx(ulx + noteWidth + bboxOffsetX); - sylZone->SetLry(staffUly + draw_h + offsetY + bboxHeight); + sylZone->SetLry(staffLry + offsetY + bboxHeight); surface->AddChild(sylZone); fi->AttachZone(sylZone); } From 3b005e8391a78478870c0ca1cc912f2bc7e8de27 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sat, 23 Dec 2023 09:23:17 +0100 Subject: [PATCH 89/91] Add Doc::IsFacs helper (and others) and use it --- include/vrv/doc.h | 4 ++++ src/doc.cpp | 8 ++++---- src/iomei.cpp | 2 +- src/layer.cpp | 2 +- src/layerelement.cpp | 4 ++-- src/staff.cpp | 8 ++++---- src/view.cpp | 2 +- src/view_element.cpp | 16 ++++++++-------- src/view_neume.cpp | 12 ++++++------ src/view_page.cpp | 4 ++-- 10 files changed, 33 insertions(+), 29 deletions(-) diff --git a/include/vrv/doc.h b/include/vrv/doc.h index d32fd434a3b..3952633bb49 100644 --- a/include/vrv/doc.h +++ b/include/vrv/doc.h @@ -114,6 +114,10 @@ class Doc : public Object { ///@{ DocType GetType() const { return m_type; } void SetType(DocType type); + bool IsFacs() const { return (m_type == Facs); } + bool IsRaw() const { return (m_type == Raw); } + bool IsRendering() const { return (m_type == Rendering); } + bool IsTranscription() const { return (m_type == Transcription); } ///@} /** diff --git a/src/doc.cpp b/src/doc.cpp index e1dc8fb97de..19a52cf8215 100644 --- a/src/doc.cpp +++ b/src/doc.cpp @@ -869,7 +869,7 @@ void Doc::PrepareData() } /************ Resolve @facs ************/ - if (this->GetType() == Facs) { + if (this->IsFacs()) { // Associate zones with elements PrepareFacsimileFunctor prepareFacsimile(this->GetFacsimile()); this->Process(prepareFacsimile); @@ -1284,7 +1284,7 @@ void Doc::ConvertToCastOffMensuralDoc(bool castOff) if (this->GetType() == Transcription) return; // Do not convert facs files - if (this->GetType() == Facs) return; + if (this->IsFacs()) return; // We are converting to measure music in a definite way if (this->GetOptions()->m_mensuralToMeasure.GetValue()) { @@ -2088,7 +2088,7 @@ int Doc::GetAdjustedDrawingPageHeight() const { assert(m_drawingPage); - if ((this->GetType() == Transcription) || (this->GetType() == Facs)) { + if ((this->GetType() == Transcription) || this->IsFacs()) { return m_drawingPage->m_pageHeight / DEFINITION_FACTOR; } @@ -2100,7 +2100,7 @@ int Doc::GetAdjustedDrawingPageWidth() const { assert(m_drawingPage); - if ((this->GetType() == Transcription) || (this->GetType() == Facs)) { + if ((this->GetType() == Transcription) || this->IsFacs()) { return m_drawingPage->m_pageWidth / DEFINITION_FACTOR; } diff --git a/src/iomei.cpp b/src/iomei.cpp index aaa69f00c64..ed8028cf3f7 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -6940,7 +6940,7 @@ bool MEIInput::ReadStem(Object *parent, pugi::xml_node stem) bool MEIInput::ReadSyl(Object *parent, pugi::xml_node syl) { // Add empty text node for empty syl element for invisible bbox in neume notation - if (!syl.first_child() && (m_doc->GetType() == Facs) && (m_doc->m_notationType == NOTATIONTYPE_neume)) { + if (!syl.first_child() && m_doc->IsFacs() && (m_doc->m_notationType == NOTATIONTYPE_neume)) { syl.text().set(""); } Syl *vrvSyl = new Syl(); diff --git a/src/layer.cpp b/src/layer.cpp index a2ea2da1ba4..a05d48903f1 100644 --- a/src/layer.cpp +++ b/src/layer.cpp @@ -273,7 +273,7 @@ const Clef *Layer::GetClefFacs(const LayerElement *test) const { const Doc *doc = vrv_cast(this->GetFirstAncestor(DOC)); assert(doc); - if (doc->GetType() == Facs) { + if (doc->IsFacs()) { ListOfConstObjects clefs; ClassIdComparison ac(CLEF); doc->FindAllDescendantsBetween(&clefs, &ac, doc->GetFirst(CLEF), test); diff --git a/src/layerelement.cpp b/src/layerelement.cpp index 589bc8e4dd9..90d453f4569 100644 --- a/src/layerelement.cpp +++ b/src/layerelement.cpp @@ -400,7 +400,7 @@ int LayerElement::GetDrawingX() const if (this->HasFacs()) { const Doc *doc = vrv_cast(this->GetFirstAncestor(DOC)); assert(doc); - if (doc->GetType() == Facs) { + if (doc->IsFacs()) { return FacsimileInterface::GetDrawingX(); } } @@ -448,7 +448,7 @@ int LayerElement::GetDrawingY() const if (this->HasFacs()) { const Doc *doc = vrv_cast(this->GetFirstAncestor(DOC)); assert(doc); - if (doc->GetType() == Facs) { + if (doc->IsFacs()) { return FacsimileInterface::GetDrawingY(); } } diff --git a/src/staff.cpp b/src/staff.cpp index 3d91195fea9..9a01f64d063 100644 --- a/src/staff.cpp +++ b/src/staff.cpp @@ -125,7 +125,7 @@ int Staff::GetDrawingX() const if (this->HasFacs()) { const Doc *doc = vrv_cast(this->GetFirstAncestor(DOC)); assert(doc); - if (doc->GetType() == Facs) { + if (doc->IsFacs()) { return FacsimileInterface::GetDrawingX(); } } @@ -137,7 +137,7 @@ int Staff::GetDrawingY() const if (this->HasFacs()) { const Doc *doc = vrv_cast(this->GetFirstAncestor(DOC)); assert(DOC); - if (doc->GetType() == Facs) { + if (doc->IsFacs()) { return FacsimileInterface::GetDrawingY(); } } @@ -160,7 +160,7 @@ double Staff::GetDrawingRotate() const if (this->HasFacs()) { const Doc *doc = vrv_cast(this->GetFirstAncestor(DOC)); assert(doc); - if (doc->GetType() == Facs) { + if (doc->IsFacs()) { return FacsimileInterface::GetDrawingRotate(); } } @@ -172,7 +172,7 @@ void Staff::AdjustDrawingStaffSize() if (this->HasFacs()) { Doc *doc = vrv_cast(this->GetFirstAncestor(DOC)); assert(doc); - if (doc->GetType() == Facs) { + if (doc->IsFacs()) { double rotate = this->GetDrawingRotate(); Zone *zone = this->GetZone(); assert(zone); diff --git a/src/view.cpp b/src/view.cpp index f9ee518f1eb..f474d7c3b8a 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->GetType() == Facs) { + if (m_doc->GetType() == Transcription || m_doc->IsFacs()) { m_currentPage->LayOutTranscription(); } else { diff --git a/src/view_element.cpp b/src/view_element.cpp index c970d76b031..eab43c14a38 100644 --- a/src/view_element.cpp +++ b/src/view_element.cpp @@ -301,12 +301,12 @@ void View::DrawAccid(DeviceContext *dc, LayerElement *element, Layer *layer, Sta if (notationType == NOTATIONTYPE_neume) { int rotateOffset = 0; - if ((m_doc->GetType() == Facs) && (staff->GetDrawingRotate() != 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->GetType() == Facs)) { + if (accid->HasFacs() && m_doc->IsFacs()) { y = ToLogicalY(y); } y -= rotateOffset; @@ -671,7 +671,7 @@ 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 ((m_doc->GetType() == Facs) && (staff->GetDrawingRotate() != 0)) { + 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)); @@ -689,7 +689,7 @@ void View::DrawClef(DeviceContext *dc, LayerElement *element, Layer *layer, Staf this->DrawSmuflCode(dc, x, y, sym, staff->m_drawingStaffSize, false); - if ((m_doc->GetType() == Facs) && element->HasFacs()) { + 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 @@ -748,7 +748,7 @@ void View::DrawCustos(DeviceContext *dc, LayerElement *element, Layer *layer, St const int sym = custos->GetCustosGlyph(staff->m_drawingNotationType); int x, y; - if (custos->HasFacs() && m_doc->GetType() == Facs) { + if (custos->HasFacs() && m_doc->IsFacs()) { x = custos->GetDrawingX(); // Recalculate y from pitch to prevent visual/meaning mismatch Clef *clef = layer->GetClef(element); @@ -777,7 +777,7 @@ void View::DrawCustos(DeviceContext *dc, LayerElement *element, Layer *layer, St y -= m_doc->GetDrawingUnit(staff->m_drawingStaffSize); } - if ((m_doc->GetType() == Facs) && (staff->GetDrawingRotate() != 0)) { + 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)); @@ -785,7 +785,7 @@ void View::DrawCustos(DeviceContext *dc, LayerElement *element, Layer *layer, St this->DrawSmuflCode(dc, x, y, sym, staff->m_drawingStaffSize, false, true); - if ((m_doc->GetType() == Facs) && element->HasFacs()) { + 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); @@ -1770,7 +1770,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->GetType() == Facs) { + 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 cbdf0b8c624..eeeaed614b1 100644 --- a/src/view_neume.cpp +++ b/src/view_neume.cpp @@ -204,12 +204,12 @@ void View::DrawNc(DeviceContext *dc, LayerElement *element, Layer *layer, Staff = (int)(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) / NOTE_WIDTH_TO_STAFF_SIZE_RATIO); int noteY, noteX; int yValue; - if (nc->HasFacs() && (m_doc->GetType() == Facs)) { + if (nc->HasFacs() && m_doc->IsFacs()) { noteY = ToLogicalY(staff->GetDrawingY()); noteX = nc->GetDrawingX(); params.at(0).xOffset = 0; } - else if (neume->HasFacs() && (m_doc->GetType() == Facs)) { + else if (neume->HasFacs() && m_doc->IsFacs()) { noteY = ToLogicalY(staff->GetDrawingY()); noteX = neume->GetDrawingX() + position * noteWidth; } @@ -229,7 +229,7 @@ void View::DrawNc(DeviceContext *dc, LayerElement *element, Layer *layer, Staff } int octaveOffset = (nc->GetOct() - clefOctave) * ((staffSize / 2) * 7); int rotateOffset; - if ((m_doc->GetType() == Facs) && (staff->GetDrawingRotate() != 0)) { + 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)); @@ -265,7 +265,7 @@ void View::DrawNc(DeviceContext *dc, LayerElement *element, Layer *layer, Staff } // adjust facsimile values of element based on where it is rendered if necessary - if ((m_doc->GetType() == Facs) && element->HasFacs()) { + if (m_doc->IsFacs() && element->HasFacs()) { FacsimileInterface *fi = element->GetFacsimileInterface(); fi->GetZone()->SetUlx(noteX); fi->GetZone()->SetUly(ToDeviceContextY(yValue)); @@ -380,7 +380,7 @@ void View::DrawDivLine(DeviceContext *dc, LayerElement *element, Layer *layer, S } int x, y; - if ((m_doc->GetType() == Facs) && (divLine->HasFacs())) { + if (m_doc->IsFacs() && (divLine->HasFacs())) { x = divLine->GetDrawingX(); y = ToLogicalY(staff->GetDrawingY()); } @@ -393,7 +393,7 @@ void View::DrawDivLine(DeviceContext *dc, LayerElement *element, Layer *layer, S y -= (m_doc->GetDrawingUnit(staff->m_drawingStaffSize)) * 3; int rotateOffset; - if ((m_doc->GetType() == Facs) && (staff->GetDrawingRotate() != 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)); diff --git a/src/view_page.cpp b/src/view_page.cpp index 7a49126257c..51d8b78be5c 100644 --- a/src/view_page.cpp +++ b/src/view_page.cpp @@ -1238,7 +1238,7 @@ void View::DrawStaff(DeviceContext *dc, Staff *staff, Measure *measure, System * dc->StartGraphic(staff, "", staff->GetID()); - if (m_doc->GetType() == Facs) { + if (m_doc->IsFacs()) { staff->SetFromFacsimile(m_doc); } @@ -1283,7 +1283,7 @@ void View::DrawStaffLines(DeviceContext *dc, Staff *staff, Measure *measure, Sys int j, x1, x2, y1, y2; - if (staff->HasFacs() && (m_doc->GetType() == Facs)) { + if (staff->HasFacs() && m_doc->IsFacs()) { double d = staff->GetDrawingRotate(); x1 = staff->GetDrawingX(); x2 = x1 + staff->GetWidth(); From a2667ae15381bd5b08123bdd44c4336e54df933e Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sat, 23 Dec 2023 09:31:29 +0100 Subject: [PATCH 90/91] Use Doc::IsTranscription helper --- src/doc.cpp | 6 +++--- src/iomei.cpp | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/doc.cpp b/src/doc.cpp index 19a52cf8215..8d1710d09e3 100644 --- a/src/doc.cpp +++ b/src/doc.cpp @@ -1281,7 +1281,7 @@ void Doc::ConvertToCastOffMensuralDoc(bool castOff) if (!m_isMensuralMusicOnly) return; // Do not convert transcription files - if (this->GetType() == Transcription) return; + if (this->IsTranscription()) return; // Do not convert facs files if (this->IsFacs()) return; @@ -2088,7 +2088,7 @@ int Doc::GetAdjustedDrawingPageHeight() const { assert(m_drawingPage); - if ((this->GetType() == Transcription) || this->IsFacs()) { + if (this->IsTranscription() || this->IsFacs()) { return m_drawingPage->m_pageHeight / DEFINITION_FACTOR; } @@ -2100,7 +2100,7 @@ int Doc::GetAdjustedDrawingPageWidth() const { assert(m_drawingPage); - if ((this->GetType() == Transcription) || this->IsFacs()) { + if (this->IsTranscription() || this->IsFacs()) { return m_drawingPage->m_pageWidth / DEFINITION_FACTOR; } diff --git a/src/iomei.cpp b/src/iomei.cpp index ed8028cf3f7..07ed3f6ce56 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -4141,7 +4141,7 @@ bool MEIInput::ReadPage(Object *parent, pugi::xml_node page) Page *vrvPage = new Page(); this->SetMeiID(page, vrvPage); - if ((m_doc->GetType() == Transcription) && (m_meiversion == meiVersion_MEIVERSION_2013)) { + if (m_doc->IsTranscription() && (m_meiversion == meiVersion_MEIVERSION_2013)) { UpgradePageTo_3_0_0(vrvPage, m_doc); } @@ -4180,12 +4180,12 @@ bool MEIInput::ReadPage(Object *parent, pugi::xml_node page) parent->AddChild(vrvPage); bool success = this->ReadPageChildren(vrvPage, page); - if (success && (m_doc->GetType() == Transcription) && (vrvPage->GetPPUFactor() != 1.0)) { + if (success && m_doc->IsTranscription() && (vrvPage->GetPPUFactor() != 1.0)) { ApplyPPUFactorFunctor applyPPUFactor; vrvPage->Process(applyPPUFactor); } - if ((m_doc->GetType() == Transcription) && (m_meiversion == meiVersion_MEIVERSION_2013)) { + if (m_doc->IsTranscription() && (m_meiversion == meiVersion_MEIVERSION_2013)) { UpgradePageTo_5_0(vrvPage); } @@ -4563,7 +4563,7 @@ bool MEIInput::ReadSystem(Object *parent, pugi::xml_node system) vrvSystem->m_systemRightMar = system.attribute("system.rightmar").as_int(); system.remove_attribute("system.rightmar"); } - if (system.attribute("uly") && (m_doc->GetType() == Transcription)) { + if (system.attribute("uly") && m_doc->IsTranscription()) { vrvSystem->m_yAbs = system.attribute("uly").as_int() * DEFINITION_FACTOR; system.remove_attribute("uly"); } @@ -4612,7 +4612,7 @@ bool MEIInput::ReadSystemChildren(Object *parent, pugi::xml_node parentNode) assert(system); unmeasured = new Measure(false); m_doc->SetMensuralMusicOnly(true); - if ((m_doc->GetType() == Transcription) && (m_meiversion == meiVersion_MEIVERSION_2013)) { + if (m_doc->IsTranscription() && (m_meiversion == meiVersion_MEIVERSION_2013)) { UpgradeMeasureTo_3_0_0(unmeasured, system); } system->AddChild(unmeasured); @@ -5348,11 +5348,11 @@ bool MEIInput::ReadMeasure(Object *parent, pugi::xml_node measure) vrvMeasure->ReadPointing(measure); vrvMeasure->ReadTyped(measure); - if ((m_doc->GetType() == Transcription) && (m_meiversion == meiVersion_MEIVERSION_2013)) { + if (m_doc->IsTranscription() && (m_meiversion == meiVersion_MEIVERSION_2013)) { UpgradeMeasureTo_5_0(measure); } - if (measure.attribute("coord.x1") && measure.attribute("coord.x2") && (m_doc->GetType() == Transcription)) { + 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; @@ -6042,11 +6042,11 @@ bool MEIInput::ReadStaff(Object *parent, pugi::xml_node staff) vrvStaff->ReadTyped(staff); vrvStaff->ReadVisibility(staff); - if ((m_doc->GetType() == Transcription) && (m_meiversion == meiVersion_MEIVERSION_2013)) { + if (m_doc->IsTranscription() && (m_meiversion == meiVersion_MEIVERSION_2013)) { UpgradeStaffTo_5_0(staff); } - if (staff.attribute("coord.y1") && (m_doc->GetType() == Transcription)) { + if (staff.attribute("coord.y1") && m_doc->IsTranscription()) { vrvStaff->ReadCoordY1(staff); vrvStaff->m_yAbs = vrvStaff->GetCoordY1() * DEFINITION_FACTOR; } @@ -6281,11 +6281,11 @@ bool MEIInput::ReadLayerElement(pugi::xml_node element, LayerElement *object) object->ReadLabelled(element); object->ReadTyped(element); - if ((m_doc->GetType() == Transcription) && (m_meiversion == meiVersion_MEIVERSION_2013)) { + if (m_doc->IsTranscription() && (m_meiversion == meiVersion_MEIVERSION_2013)) { UpgradeLayerElementTo_5_0(element); } - if (element.attribute("coord.x1") && (m_doc->GetType() == Transcription)) { + if (element.attribute("coord.x1") && m_doc->IsTranscription()) { object->ReadCoordX1(element); object->m_xAbs = object->GetCoordX1() * DEFINITION_FACTOR; } From d89dc949357cb22a8fd062515af56bf3b533cb70 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Sat, 23 Dec 2023 16:07:15 +0000 Subject: [PATCH 91/91] 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 97556fbbde0..6ff5920f6c4 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -2900,6 +2900,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); } @@ -8531,6 +8532,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;