Skip to content

Commit

Permalink
Merge pull request #3453 from rism-digital/develop-ending
Browse files Browse the repository at this point in the history
Add support for ending@lform and ending@label
  • Loading branch information
lpugin authored Jun 17, 2023
2 parents e2a9ae7 + 2fed0d1 commit cb6e57a
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 17 deletions.
7 changes: 6 additions & 1 deletion include/vrv/ending.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ class Measure;
* It can be both a container (in score-based MEI) and a milestone (in page-based MEI).
* It inherits from FloatingElement for spanning drawing features.
*/
class Ending : public SystemElement, public SystemMilestoneInterface, public AttLineRend, public AttNNumberLike {
class Ending : public SystemElement,
public SystemMilestoneInterface,
public AttLabelled,
public AttLineRend,
public AttLineRendBase,
public AttNNumberLike {
public:
/**
* @name Constructors, destructors, and other standard methods
Expand Down
12 changes: 11 additions & 1 deletion src/ending.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,17 @@ namespace vrv {

static const ClassRegistrar<Ending> s_factory("ending", ENDING);

Ending::Ending() : SystemElement(ENDING, "ending-"), SystemMilestoneInterface(), AttLineRend(), AttNNumberLike()
Ending::Ending()
: SystemElement(ENDING, "ending-")
, SystemMilestoneInterface()
, AttLabelled()
, AttLineRend()
, AttLineRendBase()
, AttNNumberLike()
{
this->RegisterAttClass(ATT_LABELLED);
this->RegisterAttClass(ATT_LINEREND);
this->RegisterAttClass(ATT_LINERENDBASE);
this->RegisterAttClass(ATT_NINTEGER);

this->Reset();
Expand All @@ -43,7 +51,9 @@ void Ending::Reset()
{
SystemElement::Reset();
SystemMilestoneInterface::Reset();
this->ResetLabelled();
this->ResetLineRend();
this->ResetLineRendBase();
this->ResetNNumberLike();
}

Expand Down
4 changes: 4 additions & 0 deletions src/iomei.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1668,7 +1668,9 @@ void MEIOutput::WriteEnding(pugi::xml_node currentNode, Ending *ending)
assert(ending);

this->WriteSystemElement(currentNode, ending);
ending->WriteLabelled(currentNode);
ending->WriteLineRend(currentNode);
ending->WriteLineRendBase(currentNode);
ending->WriteNNumberLike(currentNode);
}

Expand Down Expand Up @@ -4410,7 +4412,9 @@ bool MEIInput::ReadEnding(Object *parent, pugi::xml_node ending)
Ending *vrvEnding = new Ending();
this->ReadSystemElement(ending, vrvEnding);

vrvEnding->ReadLabelled(ending);
vrvEnding->ReadLineRend(ending);
vrvEnding->ReadLineRendBase(ending);
vrvEnding->ReadNNumberLike(ending);

parent->AddChild(vrvEnding);
Expand Down
39 changes: 24 additions & 15 deletions src/view_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2921,11 +2921,12 @@ void View::DrawEnding(DeviceContext *dc, Ending *ending, System *system)
dc->GetTextExtent("M", &extend, false);

const int unit = m_doc->GetDrawingUnit(staffSize);
if (ending->HasN()) {
if (ending->HasN() || ending->HasLabel()) {
const std::string endingText = (ending->HasN()) ? ending->GetN() : ending->GetLabel();
std::stringstream strStream;
// Maybe we want to add ( ) after system breaks? Or . as a styling options?
if ((spanningType == SPANNING_END) || (spanningType == SPANNING_MIDDLE)) strStream << "(";
strStream << ending->GetN(); // << ".";
strStream << endingText; // << ".";
if ((spanningType == SPANNING_END) || (spanningType == SPANNING_MIDDLE)) strStream << ")";

Text text;
Expand Down Expand Up @@ -2967,21 +2968,29 @@ void View::DrawEnding(DeviceContext *dc, Ending *ending, System *system)
endX -= std::max(lineWidth + unit / 2 - rightBarLineWidth, 0);
}

dc->SetPen(m_currentColor, lineWidth, AxSOLID, 0, 0, AxCAP_SQUARE, AxJOIN_MITER);
Point p[4];
p[0] = { ToDeviceContextX(startX), ToDeviceContextY(y1) };
p[1] = { ToDeviceContextX(startX), ToDeviceContextY(y2) };
p[2] = { ToDeviceContextX(endX), ToDeviceContextY(y2) };
p[3] = { ToDeviceContextX(endX), ToDeviceContextY(y1) };
if ((spanningType == SPANNING_END) || (spanningType == SPANNING_MIDDLE)
|| (ending->GetLstartsym() == LINESTARTENDSYMBOL_none)) {
p[0] = p[1];
int penStyle = AxSOLID;
int capStyle = AxCAP_SQUARE;
switch (ending->GetLform()) {
case (LINEFORM_dashed): penStyle = AxLONG_DASH; break;
case (LINEFORM_dotted):
penStyle = AxDOT;
capStyle = AxCAP_ROUND;
break;
default: penStyle = AxSOLID;
}
if ((spanningType == SPANNING_START) || (spanningType == SPANNING_MIDDLE)
|| (ending->GetLendsym() == LINESTARTENDSYMBOL_none)) {
p[3] = p[2];

dc->SetPen(m_currentColor, lineWidth, penStyle, 0, 0, capStyle);
dc->DrawLine(ToDeviceContextX(startX), ToDeviceContextY(y2), ToDeviceContextX(endX), ToDeviceContextY(y2));
if ((spanningType != SPANNING_END) && (spanningType != SPANNING_MIDDLE)
&& (ending->GetLstartsym() != LINESTARTENDSYMBOL_none)) {
dc->DrawLine(
ToDeviceContextX(startX), ToDeviceContextY(y2), ToDeviceContextX(startX), ToDeviceContextY(y1));
}
dc->DrawPolyline(4, p);
if ((spanningType != SPANNING_START) && (spanningType != SPANNING_MIDDLE)
&& (ending->GetLendsym() != LINESTARTENDSYMBOL_none)) {
dc->DrawLine(ToDeviceContextX(endX), ToDeviceContextY(y2), ToDeviceContextX(endX), ToDeviceContextY(y1));
}

dc->ResetPen();

dc->EndCustomGraphic();
Expand Down

0 comments on commit cb6e57a

Please sign in to comment.