Skip to content

Commit

Permalink
Merge pull request #122 from rism-digital/develop-ddmal-merge-23-12
Browse files Browse the repository at this point in the history
Resolve Read/Write zone coordinated ul
  • Loading branch information
yinanazhou authored Dec 27, 2023
2 parents bacf879 + d89dc94 commit baa503a
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 43 deletions.
4 changes: 4 additions & 0 deletions include/vrv/doc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
///@}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/doc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
26 changes: 14 additions & 12 deletions src/iomei.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ const Clef *Layer::GetClefFacs(const LayerElement *test) const
{
const Doc *doc = vrv_cast<const Doc *>(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);
Expand Down
4 changes: 2 additions & 2 deletions src/layerelement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ int LayerElement::GetDrawingX() const
if (this->HasFacs()) {
const Doc *doc = vrv_cast<const Doc *>(this->GetFirstAncestor(DOC));
assert(doc);
if (doc->GetType() == Facs) {
if (doc->IsFacs()) {
return FacsimileInterface::GetDrawingX();
}
}
Expand Down Expand Up @@ -448,7 +448,7 @@ int LayerElement::GetDrawingY() const
if (this->HasFacs()) {
const Doc *doc = vrv_cast<const Doc *>(this->GetFirstAncestor(DOC));
assert(doc);
if (doc->GetType() == Facs) {
if (doc->IsFacs()) {
return FacsimileInterface::GetDrawingY();
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/preparedatafunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/staff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ int Staff::GetDrawingX() const
if (this->HasFacs()) {
const Doc *doc = vrv_cast<const Doc *>(this->GetFirstAncestor(DOC));
assert(doc);
if (doc->GetType() == Facs) {
if (doc->IsFacs()) {
return FacsimileInterface::GetDrawingX();
}
}
Expand All @@ -137,7 +137,7 @@ int Staff::GetDrawingY() const
if (this->HasFacs()) {
const Doc *doc = vrv_cast<const Doc *>(this->GetFirstAncestor(DOC));
assert(DOC);
if (doc->GetType() == Facs) {
if (doc->IsFacs()) {
return FacsimileInterface::GetDrawingY();
}
}
Expand All @@ -160,7 +160,7 @@ double Staff::GetDrawingRotate() const
if (this->HasFacs()) {
const Doc *doc = vrv_cast<const Doc *>(this->GetFirstAncestor(DOC));
assert(doc);
if (doc->GetType() == Facs) {
if (doc->IsFacs()) {
return FacsimileInterface::GetDrawingRotate();
}
}
Expand All @@ -172,7 +172,7 @@ void Staff::AdjustDrawingStaffSize()
if (this->HasFacs()) {
Doc *doc = vrv_cast<Doc *>(this->GetFirstAncestor(DOC));
assert(doc);
if (doc->GetType() == Facs) {
if (doc->IsFacs()) {
double rotate = this->GetDrawingRotate();
Zone *zone = this->GetZone();
assert(zone);
Expand Down
2 changes: 1 addition & 1 deletion src/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 8 additions & 8 deletions src/view_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -777,15 +777,15 @@ 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));
}

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);

Expand Down Expand Up @@ -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();
}
Expand Down
12 changes: 6 additions & 6 deletions src/view_neume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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));
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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());
}
Expand All @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions src/view_page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit baa503a

Please sign in to comment.