diff --git a/src/Mod/TechDraw/Gui/QGEPath.cpp b/src/Mod/TechDraw/Gui/QGEPath.cpp index d708b1b7cb..a191157c68 100644 --- a/src/Mod/TechDraw/Gui/QGEPath.cpp +++ b/src/Mod/TechDraw/Gui/QGEPath.cpp @@ -391,11 +391,34 @@ void QGEPath::updateFeature(void) } } +QRectF QGEPath::boundingRect() const +{ + return shape().controlPointRect(); +} + +QPainterPath QGEPath::shape() const +{ + QPainterPath outline; + QPainterPathStroker stroker; + stroker.setWidth(getEdgeFuzz() * 2.0); + outline = stroker.createStroke(path()).simplified(); + return outline; +} + + double QGEPath::getEdgeFuzz(void) const +{ + Base::Reference hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")-> + GetGroup("Preferences")->GetGroup("Mod/TechDraw/General"); + double result = hGrp->GetFloat("EdgeFuzz",10.0); + return result; +} + + void QGEPath::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) { QStyleOptionGraphicsItem myOption(*option); myOption.state &= ~QStyle::State_Selected; - // painter->drawRect(boundingRect()); //good for debugging +// painter->drawRect(boundingRect()); //good for debugging QGIPrimPath::paint (painter, &myOption, widget); } diff --git a/src/Mod/TechDraw/Gui/QGEPath.h b/src/Mod/TechDraw/Gui/QGEPath.h index 9805047c97..6c635bd339 100644 --- a/src/Mod/TechDraw/Gui/QGEPath.h +++ b/src/Mod/TechDraw/Gui/QGEPath.h @@ -88,6 +88,8 @@ public: enum {Type = QGraphicsItem::UserType + 301}; int type() const override { return Type;} + virtual QRectF boundingRect() const override; + virtual QPainterPath shape() const override; virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 ) override; void inEdit(bool b) { m_inEdit = b; } @@ -127,6 +129,8 @@ protected: virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) override; virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override; virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override; + double getEdgeFuzz(void) const; + std::vector m_deltas; //deltas between points 1:1 scale, starts at (0,0) std::vector m_markers; QPointF m_attach; diff --git a/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp b/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp index 0d4057d5ac..e019ac74ba 100644 --- a/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp +++ b/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp @@ -433,20 +433,35 @@ void TaskLeaderLine::startTracker(void) void TaskLeaderLine::onTrackerFinished(std::vector pts, QGIView* qgParent) { -// Base::Console().Message("TTL::onTrackerFinished()\n"); +// Base::Console().Message("TTL::onTrackerFinished() - parent: %X\n",qgParent); if (pts.empty()) { Base::Console().Error("TaskLeaderLine - no points available\n"); return; } - QGIView* qgiv = dynamic_cast(qgParent); - if (qgiv != nullptr) { - m_qgParent = qgiv; + + if (qgParent == nullptr) { + //do something; + m_qgParent = findParentQGIV(); + } else { + QGIView* qgiv = dynamic_cast(qgParent); + if (qgiv != nullptr) { + m_qgParent = qgiv; + } else { + Base::Console().Message("TTL::onTrackerFinished - can't find parent graphic!\n"); + //blow up!? + throw Base::RuntimeError("TaskLeaderLine - can not find parent graphic"); + } } + if (m_qgParent != nullptr) { double scale = m_qgParent->getScale(); QPointF mapped = m_qgParent->mapFromScene(pts.front()) / scale; m_attachPoint = Base::Vector3d(mapped.x(), mapped.y(), 0.0); convertTrackerPoints(pts); + } else { + Base::Console().Message("TTL::onTrackerFinished - can't find parent graphic!\n"); + //blow up!? + throw Base::RuntimeError("TaskLeaderLine - can not find parent graphic"); } QString msg = tr("Press OK or Cancel to continue"); @@ -472,6 +487,19 @@ void TaskLeaderLine::removeTracker(void) } } +QGIView* TaskLeaderLine::findParentQGIV() +{ + QGIView* result = nullptr; + if (m_baseFeat != nullptr) { + Gui::ViewProvider* gvp = QGIView::getViewProvider(m_baseFeat); + ViewProviderDrawingView* vpdv = dynamic_cast(gvp); + if (vpdv != nullptr) { + result = vpdv->getQView(); + } + } + return result; +} + void TaskLeaderLine::setEditCursor(QCursor c) { if (m_baseFeat != nullptr) { diff --git a/src/Mod/TechDraw/Gui/TaskLeaderLine.h b/src/Mod/TechDraw/Gui/TaskLeaderLine.h index 461fc36827..7b41df059c 100644 --- a/src/Mod/TechDraw/Gui/TaskLeaderLine.h +++ b/src/Mod/TechDraw/Gui/TaskLeaderLine.h @@ -116,7 +116,8 @@ protected: void enableVPUi(bool b); void setEditCursor(QCursor c); - int getPrefArrowStyle(); + QGIView* findParentQGIV(); + int getPrefArrowStyle(); private: