Fix QGEPath selection area
This commit is contained in:
@@ -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<ParameterGrp> 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);
|
||||
}
|
||||
|
||||
@@ -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<QPointF> m_deltas; //deltas between points 1:1 scale, starts at (0,0)
|
||||
std::vector<QGMarker*> m_markers;
|
||||
QPointF m_attach;
|
||||
|
||||
@@ -433,20 +433,35 @@ void TaskLeaderLine::startTracker(void)
|
||||
|
||||
void TaskLeaderLine::onTrackerFinished(std::vector<QPointF> 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<QGIView*>(qgParent);
|
||||
if (qgiv != nullptr) {
|
||||
m_qgParent = qgiv;
|
||||
|
||||
if (qgParent == nullptr) {
|
||||
//do something;
|
||||
m_qgParent = findParentQGIV();
|
||||
} else {
|
||||
QGIView* qgiv = dynamic_cast<QGIView*>(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<ViewProviderDrawingView*>(gvp);
|
||||
if (vpdv != nullptr) {
|
||||
result = vpdv->getQView();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void TaskLeaderLine::setEditCursor(QCursor c)
|
||||
{
|
||||
if (m_baseFeat != nullptr) {
|
||||
|
||||
@@ -116,7 +116,8 @@ protected:
|
||||
void enableVPUi(bool b);
|
||||
void setEditCursor(QCursor c);
|
||||
|
||||
int getPrefArrowStyle();
|
||||
QGIView* findParentQGIV();
|
||||
int getPrefArrowStyle();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user