From 7d6bc8d92c07cace388291a24c7718b8b11f408f Mon Sep 17 00:00:00 2001 From: wandererfan Date: Mon, 3 Jun 2019 20:05:42 -0400 Subject: [PATCH] Clean up Scale retrieval --- src/Mod/TechDraw/App/DrawLeaderLine.cpp | 16 +++++++++----- src/Mod/TechDraw/Gui/QGILeaderLine.cpp | 29 +++++-------------------- src/Mod/TechDraw/Gui/QGILeaderLine.h | 1 - 3 files changed, 16 insertions(+), 30 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawLeaderLine.cpp b/src/Mod/TechDraw/App/DrawLeaderLine.cpp index 3b59ca08cc41..81f4b3628fd5 100644 --- a/src/Mod/TechDraw/App/DrawLeaderLine.cpp +++ b/src/Mod/TechDraw/App/DrawLeaderLine.cpp @@ -146,14 +146,18 @@ bool DrawLeaderLine::keepUpdated(void) double DrawLeaderLine::getScale(void) const { +// Base::Console().Message("DLL::getScale()\n"); double result = 1.0; - DrawView* parent = getBaseView(); - if (parent != nullptr) { - result = parent->getScale(); - } else { - //TARFU - Base::Console().Log("DrawLeaderLine - %s - scale not found. Using 1.0. \n", getNameInDocument()); + if (Scalable.getValue()) { + DrawView* parent = getBaseView(); + if (parent != nullptr) { + result = parent->getScale(); + } else { + //TARFU + Base::Console().Log("DrawLeaderLine - %s - scale not found. Using 1.0. \n", getNameInDocument()); + } } +// Base::Console().Message("DLL::getScale - returns: %.3f\n", result); return result; } diff --git a/src/Mod/TechDraw/Gui/QGILeaderLine.cpp b/src/Mod/TechDraw/Gui/QGILeaderLine.cpp index df32a373756b..2829661b6397 100644 --- a/src/Mod/TechDraw/Gui/QGILeaderLine.cpp +++ b/src/Mod/TechDraw/Gui/QGILeaderLine.cpp @@ -168,11 +168,7 @@ void QGILeaderLine::onSourceChange(TechDraw::DrawView* newParent) void QGILeaderLine::onAttachMoved(QPointF attach) { auto leadFeat( dynamic_cast(getViewObject()) ); - TechDraw::DrawView* parent = leadFeat->getBaseView(); - double pScale = 1.0; - if (parent != nullptr) { - pScale = parent->getScale(); - } + double pScale = leadFeat->getScale(); QPointF mapped = m_parentItem->mapFromItem(this,attach); //map point to baseView Base::Vector3d attachPoint = Base::Vector3d(mapped.x(),mapped.y(),0.0); getFeature()->setPosition(Rez::appX(attachPoint.x / pScale), //attach point must scale with parent. @@ -208,12 +204,8 @@ void QGILeaderLine::onLineEditFinished(QPointF attach, std::vector delt // TechDraw::DrawUtil::formatVector(attach).c_str(), // deltas.size()); m_blockDraw = true; - double pScale = 1.0; auto leadFeat( dynamic_cast(getViewObject()) ); - TechDraw::DrawView* parent = leadFeat->getBaseView(); - if (parent != nullptr) { - pScale = parent->getScale(); - } + double pScale = leadFeat->getScale(); QPointF p0 = deltas.front(); if ( !(TechDraw::DrawUtil::fpCompare(attach.x(),0.0) && @@ -256,8 +248,9 @@ void QGILeaderLine::onLineEditFinished(QPointF attach, std::vector delt void QGILeaderLine::startPathEdit(void) { saveState(); + auto leadFeat( dynamic_cast(getViewObject()) ); - double scale = getScale(); + double scale = leadFeat->getScale(); m_line->setScale(scale); m_line->inEdit(true); m_line->startPathEdit(); @@ -373,7 +366,7 @@ void QGILeaderLine::draw() m_line->setWidth(scaler * m_lineWidth); m_line->setNormalColor(m_lineColor); - scale = getScale(); + scale = leadFeat->getScale(); m_line->setScale(scale); if (leadFeat->StartSymbol.getValue() > -1) { m_line->setStartAdjust(QGIArrow::getOverlapAdjust(leadFeat->StartSymbol.getValue(), @@ -448,7 +441,7 @@ void QGILeaderLine::setArrows(std::vector pathPoints) Base::Vector3d stdX(1.0,0.0,0.0); TechDraw::DrawLeaderLine* line = getFeature(); - double scale = getScale(); + double scale = line->getScale(); QPointF lastOffset = (pathPoints.back() - pathPoints.front()) * scale; if (line->StartSymbol.getValue() > -1) { @@ -505,16 +498,6 @@ void QGILeaderLine::abandonEdit(void) restoreState(); } -double QGILeaderLine::getScale(void) -{ - bool isScalable = getFeature()->Scalable.getValue(); - double scale = getFeature()->getScale(); - if (!isScalable) { - scale = 1.0; - } - return scale; -} - TechDraw::DrawLeaderLine* QGILeaderLine::getFeature(void) { TechDraw::DrawLeaderLine* result = diff --git a/src/Mod/TechDraw/Gui/QGILeaderLine.h b/src/Mod/TechDraw/Gui/QGILeaderLine.h index fbd7bdf2b8c4..2be3c2a96e9f 100644 --- a/src/Mod/TechDraw/Gui/QGILeaderLine.h +++ b/src/Mod/TechDraw/Gui/QGILeaderLine.h @@ -82,7 +82,6 @@ class TechDrawGuiExport QGILeaderLine : public QGIView void abandonEdit(void); void closeEdit(void); - double getScale(void); public Q_SLOTS: void onLineEditFinished(QPointF attach, std::vector deltas); //QGEPath is finished editing points