Skip to content

Commit

Permalink
Merge pull request rism-digital#3743 from rettinghaus/dev/takt
Browse files Browse the repository at this point in the history
Enable takt barlines and import from Volpiano
  • Loading branch information
ahankinson authored Sep 3, 2024
2 parents 8fa21dd + 44ad2fc commit 6f0b050
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 4 deletions.
2 changes: 2 additions & 0 deletions include/vrv/barline.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define __VRV_BARLINE_H__

#include "atts_shared.h"
#include "atts_visual.h"
#include "layerelement.h"

namespace vrv {
Expand All @@ -27,6 +28,7 @@ enum class BarLinePosition { None, Left, Right };
*/
class BarLine : public LayerElement,
public AttBarLineLog,
public AttBarLineVis,
public AttColor,
public AttNNumberLike,
public AttVisibility {
Expand Down
8 changes: 6 additions & 2 deletions src/barline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,22 @@ namespace vrv {

static const ClassRegistrar<BarLine> s_factory("barLine", BARLINE);

BarLine::BarLine() : LayerElement(BARLINE, "bline-"), AttBarLineLog(), AttColor(), AttNNumberLike(), AttVisibility()
BarLine::BarLine()
: LayerElement(BARLINE, "bline-"), AttBarLineLog(), AttBarLineVis(), AttColor(), AttNNumberLike(), AttVisibility()
{
this->RegisterAttClass(ATT_BARLINELOG);
this->RegisterAttClass(ATT_BARLINEVIS);
this->RegisterAttClass(ATT_COLOR);
this->RegisterAttClass(ATT_VISIBILITY);

this->Reset();
}

BarLine::BarLine(ClassId classId)
: LayerElement(classId, "bline-"), AttBarLineLog(), AttColor(), AttNNumberLike(), AttVisibility()
: LayerElement(classId, "bline-"), AttBarLineLog(), AttBarLineVis(), AttColor(), AttNNumberLike(), AttVisibility()
{
this->RegisterAttClass(ATT_BARLINELOG);
this->RegisterAttClass(ATT_BARLINEVIS);
this->RegisterAttClass(ATT_COLOR);
this->RegisterAttClass(ATT_VISIBILITY);

Expand All @@ -59,6 +62,7 @@ void BarLine::Reset()
LayerElement::Reset();

this->ResetBarLineLog();
this->ResetBarLineVis();
this->ResetColor();
this->ResetVisibility();

Expand Down
2 changes: 2 additions & 0 deletions src/iomei.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2381,6 +2381,7 @@ void MEIOutput::WriteBarLine(pugi::xml_node currentNode, BarLine *barLine)

this->WriteLayerElement(currentNode, barLine);
barLine->WriteBarLineLog(currentNode);
barLine->WriteBarLineVis(currentNode);
barLine->WriteColor(currentNode);
barLine->WriteNNumberLike(currentNode);
barLine->WriteVisibility(currentNode);
Expand Down Expand Up @@ -6428,6 +6429,7 @@ bool MEIInput::ReadBarLine(Object *parent, pugi::xml_node barLine)
this->ReadLayerElement(barLine, vrvBarLine);

vrvBarLine->ReadBarLineLog(barLine);
vrvBarLine->ReadBarLineVis(barLine);
vrvBarLine->ReadColor(barLine);
vrvBarLine->ReadNNumberLike(barLine);
vrvBarLine->ReadVisibility(barLine);
Expand Down
23 changes: 23 additions & 0 deletions src/iovolpiano.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

//----------------------------------------------------------------------------

#include "barline.h"
#include "clef.h"
#include "doc.h"
#include "layer.h"
Expand Down Expand Up @@ -110,6 +111,28 @@ bool VolpianoInput::Import(const std::string &volpiano)
else if (ch == 'I' || ch == 'W' || ch == 'X' || ch == 'Y' || ch == 'Z') {
accidVal = ACCIDENTAL_WRITTEN_n;
}
else if (ch == '3') {
BarLine *single = new BarLine();
layer->AddChild(single);
}
else if (ch == '4') {
BarLine *dbl = new BarLine();
dbl->SetForm(BARRENDITION_dbl);
layer->AddChild(dbl);
}
else if (ch == '5') {
BarLine *end = new BarLine();
end->SetForm(BARRENDITION_end);
layer->AddChild(end);
}
else if (ch == '6') {
LogWarning("Volpiano '6' barline is not supported");
}
else if (ch == '7') {
BarLine *takt = new BarLine();
takt->SetMethod(BARMETHOD_takt);
layer->AddChild(takt);
}
}

// add minimal scoreDef
Expand Down
16 changes: 14 additions & 2 deletions src/view_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,23 @@ void View::DrawBarLine(DeviceContext *dc, LayerElement *element, Layer *layer, S
barLine->SetEmptyBB();
return;
}
StaffDef *drawingStaffDef = staff->m_drawingStaffDef;
// Determine the method
assert(drawingStaffDef);
auto [hasMethod, method] = barLine->GetMethod(drawingStaffDef);
if (barLine->HasMethod()) {
method = barLine->AttBarLineVis::GetMethod();
}

dc->StartGraphic(element, "", element->GetID());

const int yTop = staff->GetDrawingY();
const int yBottom = yTop - (staff->m_drawingLines - 1) * m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize);
int yTop = staff->GetDrawingY();
int yBottom = yTop - (staff->m_drawingLines - 1) * m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize);

if (method == BARMETHOD_takt) {
yTop += m_doc->GetDrawingUnit(staff->m_drawingStaffSize);
yBottom = yTop - m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize);
}

const int offset = (yTop == yBottom) ? m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) : 0;

Expand Down

0 comments on commit 6f0b050

Please sign in to comment.