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..8d1710d09e3 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); @@ -1281,10 +1281,10 @@ 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->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->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->GetType() == Facs)) { + if (this->IsTranscription() || this->IsFacs()) { return m_drawingPage->m_pageWidth / DEFINITION_FACTOR; } diff --git a/src/iomei.cpp b/src/iomei.cpp index 3a5fd146a75..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); } @@ -4141,7 +4142,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 +4181,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); } @@ -4570,7 +4571,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"); } @@ -4619,7 +4620,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); @@ -5355,11 +5356,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; @@ -6049,11 +6050,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; } @@ -6288,11 +6289,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; } @@ -6947,7 +6948,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(); @@ -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; 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/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); 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();