Fix DrawViewDetail behaviour near object edge
This commit is contained in:
parent
0ad0b58ab3
commit
b845bc7e41
|
@ -103,7 +103,6 @@ DrawViewDetail::DrawViewDetail()
|
|||
ADD_PROPERTY_TYPE(Reference ,("1"),dgroup,App::Prop_None,"An identifier for this detail");
|
||||
|
||||
getParameters();
|
||||
|
||||
}
|
||||
|
||||
DrawViewDetail::~DrawViewDetail()
|
||||
|
@ -235,7 +234,7 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
|
|||
|
||||
gp_Pnt inputCenter;
|
||||
try {
|
||||
inputCenter = TechDrawGeometry::findCentroid(detail,
|
||||
inputCenter = TechDrawGeometry::findCentroid(tool,
|
||||
Direction.getValue());
|
||||
TopoDS_Shape mirroredShape = TechDrawGeometry::mirrorShape(detail,
|
||||
inputCenter,
|
||||
|
|
|
@ -23,9 +23,6 @@
|
|||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <assert.h>
|
||||
//#include <QGraphicsScene>
|
||||
//#include <QGraphicsSceneHoverEvent>
|
||||
//#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
#endif
|
||||
|
@ -55,16 +52,18 @@ QGIMatting::QGIMatting() :
|
|||
setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||
setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||
|
||||
m_mat = new QGraphicsPathItem(); //QGIPrimPath??
|
||||
m_mat = new QGraphicsPathItem();
|
||||
addToGroup(m_mat);
|
||||
m_border = new QGraphicsPathItem();
|
||||
addToGroup(m_border);
|
||||
|
||||
m_pen.setColor(Qt::white);
|
||||
m_brush.setColor(Qt::white);
|
||||
m_brush.setStyle(Qt::SolidPattern);
|
||||
// m_pen.setColor(Qt::black);
|
||||
// m_pen.setStyle(Qt::DashLine);
|
||||
m_brush.setColor(Qt::white);
|
||||
// m_brush.setColor(Qt::black);
|
||||
m_brush.setStyle(Qt::SolidPattern);
|
||||
// m_brush.setStyle(Qt::CrossPattern);
|
||||
// m_brush.setStyle(Qt::NoBrush);
|
||||
m_penB.setColor(Qt::black);
|
||||
m_brushB.setStyle(Qt::NoBrush);
|
||||
|
@ -77,29 +76,14 @@ QGIMatting::QGIMatting() :
|
|||
setZValue(ZVALUE::MATTING);
|
||||
}
|
||||
|
||||
void QGIMatting::centerAt(QPointF centerPos)
|
||||
{
|
||||
QRectF box = boundingRect();
|
||||
double width = box.width();
|
||||
double height = box.height();
|
||||
double newX = centerPos.x() - width/2.;
|
||||
double newY = centerPos.y() - height/2.;
|
||||
setPos(newX,newY);
|
||||
}
|
||||
|
||||
void QGIMatting::centerAt(double cX, double cY)
|
||||
{
|
||||
QRectF box = boundingRect();
|
||||
double width = box.width();
|
||||
double height = box.height();
|
||||
double newX = cX - width/2.;
|
||||
double newY = cY - height/2.;
|
||||
setPos(newX,newY);
|
||||
}
|
||||
|
||||
void QGIMatting::draw()
|
||||
{
|
||||
QRectF outline(-m_width/2.0,-m_height/2.0,m_width,m_height);
|
||||
prepareGeometryChange();
|
||||
double radiusFudge = 1.15; //keep slightly larger than fudge in App/DVDetail to prevent bleed through
|
||||
double outerRadius = m_radius * radiusFudge;
|
||||
m_width = outerRadius;
|
||||
m_height = outerRadius;
|
||||
QRectF outline(-m_width,-m_height,2.0 * m_width,2.0 * m_height);
|
||||
QPainterPath ppOut;
|
||||
ppOut.addRect(outline);
|
||||
QPainterPath ppCut;
|
||||
|
@ -107,13 +91,15 @@ void QGIMatting::draw()
|
|||
QRectF roundCutout (-m_radius,-m_radius,2.0 * m_radius,2.0 * m_radius);
|
||||
ppCut.addEllipse(roundCutout);
|
||||
} else {
|
||||
double squareSize = m_radius / 1.4142; //fit within radius
|
||||
double squareSize = m_radius/ 1.4142; //fit just within radius
|
||||
QRectF squareCutout (-squareSize,-squareSize,2.0 * squareSize,2.0 * squareSize);
|
||||
ppCut.addRect(squareCutout);
|
||||
}
|
||||
ppOut.addPath(ppCut);
|
||||
m_mat->setPath(ppOut);
|
||||
m_border->setPath(ppCut);
|
||||
m_mat->setZValue(ZVALUE::MATTING);
|
||||
m_border->setZValue(ZVALUE::MATTING);
|
||||
}
|
||||
|
||||
int QGIMatting::getHoleStyle()
|
||||
|
@ -124,9 +110,19 @@ int QGIMatting::getHoleStyle()
|
|||
return style;
|
||||
}
|
||||
|
||||
//need this because QQGIG only updates BR when items added/deleted.
|
||||
QRectF QGIMatting::boundingRect() const
|
||||
{
|
||||
QRectF result ;
|
||||
result = childrenBoundingRect().adjusted(-1,-1,1,1);
|
||||
return result;
|
||||
}
|
||||
|
||||
void QGIMatting::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
|
||||
QStyleOptionGraphicsItem myOption(*option);
|
||||
myOption.state &= ~QStyle::State_Selected;
|
||||
|
||||
//painter->drawRect(boundingRect().adjusted(-2.0,-2.0,2.0,2.0));
|
||||
|
||||
QGraphicsItemGroup::paint (painter, &myOption, widget);
|
||||
}
|
||||
|
|
|
@ -49,8 +49,7 @@ public:
|
|||
int type() const { return Type;}
|
||||
|
||||
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
|
||||
virtual void centerAt(QPointF centerPos);
|
||||
virtual void centerAt(double cX, double cY);
|
||||
virtual QRectF boundingRect() const;
|
||||
|
||||
virtual void setSize(double w, double h) {m_height = h; m_width = w;}
|
||||
//virtual void setHoleStyle(int hs) {m_holeStyle = hs;}
|
||||
|
|
|
@ -310,8 +310,8 @@ void QGIViewPart::updateView(bool update)
|
|||
|
||||
void QGIViewPart::draw() {
|
||||
drawViewPart();
|
||||
drawBorder();
|
||||
drawMatting();
|
||||
drawBorder();
|
||||
}
|
||||
|
||||
void QGIViewPart::drawViewPart()
|
||||
|
@ -625,11 +625,8 @@ void QGIViewPart::drawMatting()
|
|||
double radius = dvd->Radius.getValue() * scale;
|
||||
QGIMatting* mat = new QGIMatting();
|
||||
addToGroup(mat);
|
||||
mat->setPos(0.0,0.0);
|
||||
mat->setRadius(radius);
|
||||
QRectF displayArea = customChildrenBoundingRect();
|
||||
mat->setSize(displayArea.width(),displayArea.height());
|
||||
//mat->setHoleStyle(dvd->getMattingStyle());
|
||||
mat->setPos(0.0,0.0);
|
||||
mat->draw();
|
||||
mat->show();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user