From a55f81f09a49596908c0ab746d3e8d912b103413 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Tue, 20 Jun 2017 12:34:09 +0300 Subject: [PATCH] Fixing grace slash missing --- include/vrv/elementpart.h | 2 +- include/vrv/view.h | 2 +- src/chord.cpp | 1 + src/elementpart.cpp | 4 +++- src/note.cpp | 1 + src/view_element.cpp | 38 +++++++++++++++----------------------- 6 files changed, 22 insertions(+), 26 deletions(-) diff --git a/include/vrv/elementpart.h b/include/vrv/elementpart.h index 3536ddbd885..357c46e02e3 100644 --- a/include/vrv/elementpart.h +++ b/include/vrv/elementpart.h @@ -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 diff --git a/include/vrv/view.h b/include/vrv/view.h index 9b08bf4cb79..31919c4753e 100644 --- a/include/vrv/view.h +++ b/include/vrv/view.h @@ -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); diff --git a/src/chord.cpp b/src/chord.cpp index 872d81ebfe6..d5ddbe7e467 100644 --- a/src/chord.cpp +++ b/src/chord.cpp @@ -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); } diff --git a/src/elementpart.cpp b/src/elementpart.cpp index 24d24c0af35..e489abd74de 100644 --- a/src/elementpart.cpp +++ b/src/elementpart.cpp @@ -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); @@ -139,6 +140,7 @@ Stem::~Stem() void Stem::Reset() { LayerElement::Reset(); + ResetGraced(); ResetStems(); ResetStemsCmn(); diff --git a/src/note.cpp b/src/note.cpp index f9943dbb460..c908061ff81 100644 --- a/src/note.cpp +++ b/src/note.cpp @@ -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); } diff --git a/src/view_element.cpp b/src/view_element.cpp index 7ffb7c1445c..7f23078a9ae 100644 --- a/src/view_element.cpp +++ b/src/view_element.cpp @@ -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); } @@ -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(element); - assert(durInterface); - - StemmedDrawingInterface *stemInterface = dynamic_cast(element); - assert(stemInterface); - - Staff *staff = dynamic_cast(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(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();