Skip to content

Commit

Permalink
Fix overlap of dimension selection area
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Jun 8, 2019
1 parent 3874dda commit 4494d38
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 94 deletions.
29 changes: 25 additions & 4 deletions src/Mod/TechDraw/Gui/QGIDimLines.cpp
Expand Up @@ -32,6 +32,10 @@
#include <QPainter>
#endif

#include <App/Application.h>
#include <Base/Parameter.h>
#include <Base/Console.h>

#include "QGIDimLines.h"

using namespace TechDrawGui;
Expand All @@ -50,19 +54,36 @@ void QGIDimLines::draw()
{
}

QPainterPath QGIDimLines::shape() const
{
QPainterPath outline;
QPainterPathStroker stroker;
stroker.setWidth(getEdgeFuzz());
outline = stroker.createStroke(path());
return outline;
}

double QGIDimLines::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;
}


QRectF QGIDimLines::boundingRect() const
{
return shape().boundingRect().adjusted(-2, -2, 2, 2); //room for 0.5 line widths? needs Rez::guiX??
// return childrenBoundingRect().adjusted(-2,-2,2,2);
return shape().controlPointRect().adjusted(-3, -3, 3, 3);
}

//probably don't need this paint
void QGIDimLines::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
// painter->drawPath(shape()); //good for debugging

QGIPrimPath::paint (painter, &myOption, widget);
}
Expand Down
4 changes: 3 additions & 1 deletion src/Mod/TechDraw/Gui/QGIDimLines.h
Expand Up @@ -41,7 +41,8 @@ class TechDrawGuiExport QGIDimLines : public QGIPrimPath

enum {Type = QGraphicsItem::UserType + 175};
int type() const { return Type;}
QRectF boundingRect() const;
virtual QRectF boundingRect() const override;
virtual QPainterPath shape() const override;

public:
void draw();
Expand All @@ -53,6 +54,7 @@ class TechDrawGuiExport QGIDimLines : public QGIPrimPath

protected:
//QVariant itemChange(GraphicsItemChange change, const QVariant &value);
double getEdgeFuzz(void) const;


private:
Expand Down
2 changes: 0 additions & 2 deletions src/Mod/TechDraw/Gui/QGIView.cpp
Expand Up @@ -52,10 +52,8 @@
#include "ZVALUE.h"
#include "DrawGuiUtil.h"
#include "QGVPage.h"
#include "QGCustomBorder.h"
#include "QGCustomLabel.h"
#include "QGCustomBorder.h"
#include "QGCustomLabel.h"
#include "QGCustomText.h"
#include "QGICaption.h"
#include "QGCustomClip.h"
Expand Down

0 comments on commit 4494d38

Please sign in to comment.