Skip to content

Commit

Permalink
Clean up Scale retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Jun 4, 2019
1 parent 8e6dd25 commit 7d6bc8d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 30 deletions.
16 changes: 10 additions & 6 deletions src/Mod/TechDraw/App/DrawLeaderLine.cpp
Expand Up @@ -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;
}

Expand Down
29 changes: 6 additions & 23 deletions src/Mod/TechDraw/Gui/QGILeaderLine.cpp
Expand Up @@ -168,11 +168,7 @@ void QGILeaderLine::onSourceChange(TechDraw::DrawView* newParent)
void QGILeaderLine::onAttachMoved(QPointF attach)
{
auto leadFeat( dynamic_cast<TechDraw::DrawLeaderLine*>(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.
Expand Down Expand Up @@ -208,12 +204,8 @@ void QGILeaderLine::onLineEditFinished(QPointF attach, std::vector<QPointF> delt
// TechDraw::DrawUtil::formatVector(attach).c_str(),
// deltas.size());
m_blockDraw = true;
double pScale = 1.0;
auto leadFeat( dynamic_cast<TechDraw::DrawLeaderLine*>(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) &&
Expand Down Expand Up @@ -256,8 +248,9 @@ void QGILeaderLine::onLineEditFinished(QPointF attach, std::vector<QPointF> delt
void QGILeaderLine::startPathEdit(void)
{
saveState();
auto leadFeat( dynamic_cast<TechDraw::DrawLeaderLine*>(getViewObject()) );

double scale = getScale();
double scale = leadFeat->getScale();
m_line->setScale(scale);
m_line->inEdit(true);
m_line->startPathEdit();
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -448,7 +441,7 @@ void QGILeaderLine::setArrows(std::vector<QPointF> 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) {
Expand Down Expand Up @@ -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 =
Expand Down
1 change: 0 additions & 1 deletion src/Mod/TechDraw/Gui/QGILeaderLine.h
Expand Up @@ -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<QPointF> deltas); //QGEPath is finished editing points
Expand Down

0 comments on commit 7d6bc8d

Please sign in to comment.