From 04421039a897775c6a518915776bd6cfa4ceca61 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Sun, 11 Mar 2018 11:24:17 -0400 Subject: [PATCH] Correct delayed scaling of center/section lines --- src/Mod/TechDraw/Gui/QGIViewPart.cpp | 112 ++++++++++-------- src/Mod/TechDraw/Gui/QGIViewPart.h | 1 + src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp | 6 + 3 files changed, 69 insertions(+), 50 deletions(-) diff --git a/src/Mod/TechDraw/Gui/QGIViewPart.cpp b/src/Mod/TechDraw/Gui/QGIViewPart.cpp index b628c7bbff..40019cc938 100644 --- a/src/Mod/TechDraw/Gui/QGIViewPart.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewPart.cpp @@ -159,22 +159,22 @@ QPainterPath QGIViewPart::geomToPainterPath(TechDrawGeometry::BaseGeom *baseGeom double y = geom->center.y - geom->radius; path.addEllipse(Rez::guiX(x), - Rez::guiX(y), - Rez::guiX(geom->radius * 2), + Rez::guiX(y), + Rez::guiX(geom->radius * 2), Rez::guiX(geom->radius * 2)); //topleft@(x,y) radx,rady } break; case TechDrawGeometry::ARCOFCIRCLE: { TechDrawGeometry::AOC *geom = static_cast(baseGeom); - pathArc(path, - Rez::guiX(geom->radius), - Rez::guiX(geom->radius), - 0., - geom->largeArc, + pathArc(path, + Rez::guiX(geom->radius), + Rez::guiX(geom->radius), + 0., + geom->largeArc, geom->cw, - Rez::guiX(geom->endPnt.x), + Rez::guiX(geom->endPnt.x), Rez::guiX(geom->endPnt.y), - Rez::guiX(geom->startPnt.x), + Rez::guiX(geom->startPnt.x), Rez::guiX(geom->startPnt.y)); } break; case TechDrawGeometry::ELLIPSE: { @@ -186,41 +186,41 @@ QPainterPath QGIViewPart::geomToPainterPath(TechDrawGeometry::BaseGeom *baseGeom endX = geom->center.x - geom->major * cos(geom->angle), endY = geom->center.y - geom->major * sin(geom->angle); - pathArc(path, - Rez::guiX(geom->major), - Rez::guiX(geom->minor), - geom->angle, - false, + pathArc(path, + Rez::guiX(geom->major), + Rez::guiX(geom->minor), + geom->angle, false, - Rez::guiX(endX), - Rez::guiX(endY), - Rez::guiX(startX), + false, + Rez::guiX(endX), + Rez::guiX(endY), + Rez::guiX(startX), Rez::guiX(startY)); - pathArc(path, - Rez::guiX(geom->major), - Rez::guiX(geom->minor), - geom->angle, - false, + pathArc(path, + Rez::guiX(geom->major), + Rez::guiX(geom->minor), + geom->angle, false, - Rez::guiX(startX), - Rez::guiX(startY), - Rez::guiX(endX), + false, + Rez::guiX(startX), + Rez::guiX(startY), + Rez::guiX(endX), Rez::guiX(endY)); } break; case TechDrawGeometry::ARCOFELLIPSE: { TechDrawGeometry::AOE *geom = static_cast(baseGeom); - pathArc(path, - Rez::guiX(geom->major), - Rez::guiX(geom->minor), - geom->angle, - geom->largeArc, + pathArc(path, + Rez::guiX(geom->major), + Rez::guiX(geom->minor), + geom->angle, + geom->largeArc, geom->cw, - Rez::guiX(geom->endPnt.x), + Rez::guiX(geom->endPnt.x), Rez::guiX(geom->endPnt.y), - Rez::guiX(geom->startPnt.x), + Rez::guiX(geom->startPnt.x), Rez::guiX(geom->startPnt.y)); } break; @@ -353,6 +353,9 @@ void QGIViewPart::draw() { drawViewPart(); drawMatting(); QGIView::draw(); + drawCenterLines(true); //have to draw centerlines after border to get size correct. + drawAllSectionLines(); //same for section lines + } void QGIViewPart::drawViewPart() @@ -364,7 +367,7 @@ void QGIViewPart::drawViewPart() if (!viewPart->hasGeometry()) { return; } - + auto vp = static_cast(getViewProvider(getViewObject())); if ( vp == nullptr ) { return; @@ -427,7 +430,7 @@ void QGIViewPart::drawViewPart() newFace->setHatchColor(hatchVp->HatchColor.getValue()); } } - } + } bool drawEdges = getFaceEdgesPref(); newFace->setDrawEdges(drawEdges); //pref. for debugging only newFace->setZValue(ZVALUE::FACE); @@ -512,22 +515,12 @@ void QGIViewPart::drawViewPart() item->setZValue(ZVALUE::VERTEX); } } - //draw section line - if (vp->ShowSectionLine.getValue()) { - auto refs = viewPart->getSectionRefs(); - for (auto& r:refs) { - drawSectionLine(r, true); - } - } //draw detail highlights auto drefs = viewPart->getDetailRefs(); for (auto& r:drefs) { drawHighlight(r, true); } - - //draw center lines - drawCenterLines(true); } QGIFace* QGIViewPart::drawFace(TechDrawGeometry::Face* f, int idx) @@ -597,14 +590,32 @@ void QGIViewPart::removeDecorations() } } +void QGIViewPart::drawAllSectionLines(void) +{ + TechDraw::DrawViewPart *viewPart = static_cast(getViewObject()); + if (!viewPart) { + return; + } + + auto vp = static_cast(getViewProvider(getViewObject())); + if ( vp == nullptr ) { + return; + } + if (vp->ShowSectionLine.getValue()) { + auto refs = viewPart->getSectionRefs(); + for (auto& r:refs) { + drawSectionLine(r, true); + } + } +} + void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b) { TechDraw::DrawViewPart *viewPart = static_cast(getViewObject()); - if (!viewPart || - !viewSection) { + if (!viewPart) { return; } - + if (!viewSection->hasGeometry()) { return; } @@ -614,6 +625,7 @@ void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b return; } + if (b) { QGISectionLine* sectionLine = new QGISectionLine(); addToGroup(sectionLine); @@ -679,7 +691,7 @@ void QGIViewPart::drawCenterLines(bool b) if (!viewPart) { return; } - + auto vp = static_cast(getViewProvider(getViewObject())); if ( vp == nullptr ) { return; @@ -731,7 +743,7 @@ void QGIViewPart::drawHighlight(TechDraw::DrawViewDetail* viewDetail, bool b) !viewDetail) { return; } - + if (!viewDetail->hasGeometry()) { return; } @@ -785,7 +797,7 @@ void QGIViewPart::drawMatting() void QGIViewPart::pathArc(QPainterPath &path, double rx, double ry, double x_axis_rotation, bool large_arc_flag, bool sweep_flag, double x, double y, - double curx, double cury) + double curx, double cury) { double sin_th, cos_th; double a00, a01, a10, a11; diff --git a/src/Mod/TechDraw/Gui/QGIViewPart.h b/src/Mod/TechDraw/Gui/QGIViewPart.h index dfba1ee6b4..5a56dcb023 100644 --- a/src/Mod/TechDraw/Gui/QGIViewPart.h +++ b/src/Mod/TechDraw/Gui/QGIViewPart.h @@ -60,6 +60,7 @@ public: virtual void updateView(bool update = false) override; void tidy(); virtual QRectF boundingRect() const override; + virtual void drawAllSectionLines(void); virtual void drawSectionLine(TechDraw::DrawViewSection* s, bool b); virtual void drawCenterLines(bool b); virtual void drawHighlight(TechDraw::DrawViewDetail* viewDetail, bool b); diff --git a/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp b/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp index f282ab3f91..3d573145b8 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp @@ -94,6 +94,12 @@ ViewProviderViewPart::~ViewProviderViewPart() void ViewProviderViewPart::updateData(const App::Property* prop) { + if (prop == &(getViewObject()->Scale) ) { //shouldn't Scale cause DVP::execute & request paint?? + QGIView* qgiv = getQView(); + if (qgiv) { + qgiv->updateView(true); + } + } ViewProviderDrawingView::updateData(prop); }