Skip to content

Commit

Permalink
Fixing grace slash missing
Browse files Browse the repository at this point in the history
  • Loading branch information
lpugin committed Jun 20, 2017
1 parent 9bb13b4 commit a55f81f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 26 deletions.
2 changes: 1 addition & 1 deletion include/vrv/elementpart.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class Flag : public LayerElement {
/**
* This class models a stem as a layer element part and has not direct MEI equivlatent.
*/
class Stem : public LayerElement, public AttStems, public AttStemsCmn {
class Stem : public LayerElement, public AttGraced, public AttStems, public AttStemsCmn {
public:
/**
* @name Constructors, destructors, reset and class name methods
Expand Down
2 changes: 1 addition & 1 deletion include/vrv/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class View {
* Defined in view_element.cpp
*/
///@{
void DrawAcciaccaturaSlash(DeviceContext *dc, LayerElement *element);
void DrawAcciaccaturaSlash(DeviceContext *dc, Stem *stem, Staff *staff);
void DrawDotsPart(DeviceContext *dc, int x, int y, unsigned char dots, Staff *staff);
void DrawFermataAttr(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff);
void DrawLigatureNote(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff);
Expand Down
1 change: 1 addition & 0 deletions src/chord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ int Chord::PrepareLayerElementParts(FunctorParams *functorParams)
currentStem = new Stem();
this->AddChild(currentStem);
}
currentStem->AttGraced::operator=(*this);
currentStem->AttStems::operator=(*this);
currentStem->AttStemsCmn::operator=(*this);
}
Expand Down
4 changes: 3 additions & 1 deletion src/elementpart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ Point Flag::GetStemDownNW(Doc *doc, int staffSize, bool graceSize, wchar_t &code
// Stem
//----------------------------------------------------------------------------

Stem::Stem() : LayerElement("stem-"), AttStems(), AttStemsCmn()
Stem::Stem() : LayerElement("stem-"), AttGraced(), AttStems(), AttStemsCmn()
{
RegisterAttClass(ATT_GRACED);
RegisterAttClass(ATT_STEMS);
RegisterAttClass(ATT_STEMSCMN);

Expand All @@ -139,6 +140,7 @@ Stem::~Stem()
void Stem::Reset()
{
LayerElement::Reset();
ResetGraced();
ResetStems();
ResetStemsCmn();

Expand Down
1 change: 1 addition & 0 deletions src/note.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ int Note::PrepareLayerElementParts(FunctorParams *functorParams)
currentStem = new Stem();
this->AddChild(currentStem);
}
currentStem->AttGraced::operator=(*this);
currentStem->AttStems::operator=(*this);
currentStem->AttStemsCmn::operator=(*this);
}
Expand Down
38 changes: 15 additions & 23 deletions src/view_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,12 @@ void View::DrawStem(DeviceContext *dc, LayerElement *element, Layer *layer, Staf
stem->GetDrawingY() - stem->GetDrawingStemLen());

DrawLayerChildren(dc, stem, layer, staff, measure);

/************ Draw slash ************/

if (stem->GetGrace() == GRACE_unacc) {
DrawAcciaccaturaSlash(dc, stem, staff);
}

dc->EndGraphic(element, this);
}
Expand Down Expand Up @@ -1335,46 +1341,32 @@ void View::DrawVerse(DeviceContext *dc, LayerElement *element, Layer *layer, Sta
// Partial drawing methods
//----------------------------------------------------------------------------

void View::DrawAcciaccaturaSlash(DeviceContext *dc, LayerElement *element)
void View::DrawAcciaccaturaSlash(DeviceContext *dc, Stem *stem, Staff *staff)
{
DurationInterface *durInterface = dynamic_cast<DurationInterface *>(element);
assert(durInterface);

StemmedDrawingInterface *stemInterface = dynamic_cast<StemmedDrawingInterface *>(element);
assert(stemInterface);

Staff *staff = dynamic_cast<Staff *>(element->GetFirstParent(STAFF));
assert(dc);
assert(stem);
assert(staff);

if (durInterface->GetActualDur() < DUR_8) return;

dc->SetPen(AxBLACK, m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize), AxSOLID);
dc->SetBrush(AxBLACK, AxSOLID);

int positionShift = m_doc->GetCueSize(m_doc->GetDrawingUnit(staff->m_drawingStaffSize));
int positionShiftX1 = positionShift * 3 / 2;
int positionShiftY1 = positionShift * 2;
int positionShiftY1 = positionShift * -5;
int positionShiftX2 = positionShift * 3;
int positionShiftY2 = positionShift * 6;
Point startPoint = stemInterface->GetDrawingStemStart(element);
int positionShiftY2 = positionShift * -1;
Point startPoint(stem->GetDrawingX(), stem->GetDrawingY() - stem->GetDrawingStemLen());

int startPointY = startPoint.y;
if (element->Is(CHORD)) {
Chord *chord = dynamic_cast<Chord *>(element);
assert(chord);
int yMin, yMax;
chord->GetYExtremes(yMin, yMax);
startPointY = (stemInterface->GetDrawingStemDir() == STEMDIRECTION_up) ? yMin : yMax;
}

// HARDCODED
if (stemInterface->GetDrawingStemDir() == STEMDIRECTION_up) {
if (stem->GetDrawingStemDir() == STEMDIRECTION_up) {
dc->DrawLine(ToDeviceContextX(startPoint.x - positionShiftX1), ToDeviceContextY(startPointY + positionShiftY1),
ToDeviceContextX(startPoint.x + positionShiftX2), ToDeviceContextY(startPointY + positionShiftY2));
}
else {
dc->DrawLine(ToDeviceContextX(startPoint.x - positionShiftX1), ToDeviceContextY(startPointY - positionShiftY1),
ToDeviceContextX(startPoint.x + positionShiftX2), ToDeviceContextY(startPointY - positionShiftY2));
dc->DrawLine(ToDeviceContextX(startPoint.x - positionShiftX1), ToDeviceContextY(startPointY - positionShiftY2),
ToDeviceContextX(startPoint.x + positionShiftX2), ToDeviceContextY(startPointY - positionShiftY1));
}

dc->ResetPen();
Expand Down

0 comments on commit a55f81f

Please sign in to comment.