TechDraw: remove unneeded state from QGIPrimPath
This commit is contained in:
@@ -47,10 +47,7 @@ using namespace TechDraw;
|
||||
using DGU = DrawGuiUtil;
|
||||
|
||||
QGIPrimPath::QGIPrimPath():
|
||||
m_width(0),
|
||||
m_capStyle(Qt::RoundCap),
|
||||
m_fillStyleCurrent (Qt::NoBrush),
|
||||
m_fillOverride(false)
|
||||
m_brush(Qt::NoBrush)
|
||||
{
|
||||
setCacheMode(QGraphicsItem::NoCache);
|
||||
setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||
@@ -61,26 +58,19 @@ QGIPrimPath::QGIPrimPath():
|
||||
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||
setAcceptHoverEvents(true);
|
||||
|
||||
isHighlighted = false;
|
||||
multiselectActivated = false;
|
||||
|
||||
m_colOverride = false;
|
||||
m_colNormal = getNormalColor();
|
||||
m_colCurrent = m_colNormal;
|
||||
m_pen.setColor(m_colNormal);
|
||||
m_styleNormal = Qt::SolidLine;
|
||||
m_styleCurrent = m_styleNormal;
|
||||
m_pen.setStyle(m_styleCurrent);
|
||||
m_capStyle = prefCapStyle();
|
||||
m_pen.setCapStyle(m_capStyle);
|
||||
m_pen.setWidthF(m_width);
|
||||
m_pen.setStyle(m_styleNormal);
|
||||
m_pen.setCapStyle(prefCapStyle());
|
||||
m_pen.setWidthF(0);
|
||||
|
||||
m_fillDef = Qt::NoBrush;
|
||||
m_fillSelect = Qt::SolidPattern;
|
||||
m_fillNormal = m_fillDef;
|
||||
m_fillStyleCurrent = m_fillNormal;
|
||||
m_fillNormal = getDefaultFillStyle();
|
||||
m_brush.setStyle(m_fillNormal);
|
||||
|
||||
m_colDefFill = Qt::white;
|
||||
setFillColor(m_colDefFill);
|
||||
setFillColor(getDefaultFillColor());
|
||||
|
||||
setPrettyNormal();
|
||||
}
|
||||
@@ -119,22 +109,18 @@ void QGIPrimPath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
|
||||
void QGIPrimPath::setPrettyNormal() {
|
||||
|
||||
m_colCurrent = m_colNormal;
|
||||
m_fillColorCurrent = m_colNormalFill;
|
||||
m_pen.setColor(m_colNormal);
|
||||
m_brush.setColor(m_colNormalFill);
|
||||
}
|
||||
|
||||
void QGIPrimPath::setPrettyPre() {
|
||||
m_colCurrent = getPreColor();
|
||||
if (!m_fillOverride) {
|
||||
m_fillColorCurrent = getPreColor();
|
||||
}
|
||||
m_pen.setColor(getPreColor());
|
||||
m_brush.setColor(getPreColor());
|
||||
}
|
||||
|
||||
void QGIPrimPath::setPrettySel() {
|
||||
m_colCurrent = getSelectColor();
|
||||
if (!m_fillOverride) {
|
||||
m_fillColorCurrent = getSelectColor();
|
||||
}
|
||||
m_pen.setColor(getSelectColor());
|
||||
m_brush.setColor(getSelectColor());
|
||||
}
|
||||
|
||||
//wf: why would a face use its parent's normal colour?
|
||||
@@ -142,11 +128,6 @@ void QGIPrimPath::setPrettySel() {
|
||||
QColor QGIPrimPath::getNormalColor()
|
||||
{
|
||||
QGIView *parent;
|
||||
|
||||
if (m_colOverride) {
|
||||
return m_colNormal;
|
||||
}
|
||||
|
||||
QGraphicsItem* qparent = parentItem();
|
||||
if (!qparent) {
|
||||
parent = nullptr;
|
||||
@@ -195,8 +176,7 @@ QColor QGIPrimPath::getSelectColor()
|
||||
void QGIPrimPath::setWidth(double w)
|
||||
{
|
||||
// Base::Console().Message("QGIPP::setWidth(%.3f)\n", w);
|
||||
m_width = w;
|
||||
m_pen.setWidthF(m_width);
|
||||
m_pen.setWidthF(w);
|
||||
}
|
||||
|
||||
void QGIPrimPath::setStyle(Qt::PenStyle s)
|
||||
@@ -204,27 +184,25 @@ void QGIPrimPath::setStyle(Qt::PenStyle s)
|
||||
// TODO: edge lines for faces are drawn with setStyle(Qt::NoPen) and trigger this message.
|
||||
// Base::Console().Warning("QGIPP::setStyle(Qt: %d) is deprecated. Use setLinePen instead\n", s);
|
||||
m_styleNormal = s;
|
||||
m_styleCurrent = s;
|
||||
m_pen.setStyle(s);
|
||||
}
|
||||
|
||||
void QGIPrimPath::setStyle(int s)
|
||||
{
|
||||
// TODO: edge lines for faces are drawn with setStyle(Qt::NoPen) and trigger this message.
|
||||
// Base::Console().Warning("QGIPP::setStyle(int: %d) is deprecated. Use setLinePen instead\n", s);
|
||||
m_styleCurrent = static_cast<Qt::PenStyle>(s);
|
||||
m_styleNormal = static_cast<Qt::PenStyle>(s);
|
||||
m_pen.setStyle(m_styleNormal);
|
||||
}
|
||||
|
||||
void QGIPrimPath::setNormalColor(QColor c)
|
||||
{
|
||||
m_colNormal = c;
|
||||
m_colOverride = true;
|
||||
m_colCurrent = m_colNormal;
|
||||
m_pen.setColor(m_colNormal);
|
||||
}
|
||||
|
||||
void QGIPrimPath::setCapStyle(Qt::PenCapStyle c)
|
||||
{
|
||||
m_capStyle = c;
|
||||
m_pen.setCapStyle(c);
|
||||
}
|
||||
|
||||
@@ -286,44 +264,32 @@ void QGIPrimPath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
void QGIPrimPath::setFill(QColor c, Qt::BrushStyle s) {
|
||||
setFillColor(c);
|
||||
m_fillNormal = s;
|
||||
m_fillStyleCurrent = s;
|
||||
m_brush.setStyle(s);
|
||||
}
|
||||
|
||||
void QGIPrimPath::setFill(QBrush b) {
|
||||
setFillColor(b.color());
|
||||
m_fillNormal = b.style();
|
||||
m_fillStyleCurrent = b.style();
|
||||
setFillColor(b.color());
|
||||
m_brush.setStyle(b.style());
|
||||
}
|
||||
|
||||
void QGIPrimPath::resetFill() {
|
||||
m_colNormalFill = m_colDefFill;
|
||||
m_fillNormal = m_fillDef;
|
||||
m_fillStyleCurrent = m_fillDef;
|
||||
m_colNormalFill = getDefaultFillColor();
|
||||
m_fillNormal = getDefaultFillStyle();
|
||||
m_brush.setStyle(m_fillNormal);
|
||||
}
|
||||
|
||||
//set PlainFill
|
||||
void QGIPrimPath::setFillColor(QColor c)
|
||||
{
|
||||
m_colNormalFill = c;
|
||||
m_fillColorCurrent = m_colNormalFill;
|
||||
}
|
||||
|
||||
void QGIPrimPath::setCurrentPen()
|
||||
{
|
||||
m_pen.setWidthF(m_width);
|
||||
m_pen.setColor(m_colCurrent);
|
||||
m_pen.setStyle(m_styleCurrent);
|
||||
}
|
||||
|
||||
void QGIPrimPath::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
|
||||
QStyleOptionGraphicsItem myOption(*option);
|
||||
myOption.state &= ~QStyle::State_Selected;
|
||||
|
||||
setCurrentPen();
|
||||
setPen(m_pen);
|
||||
|
||||
m_brush.setColor(m_fillColorCurrent);
|
||||
m_brush.setStyle(m_fillStyleCurrent);
|
||||
setBrush(m_brush);
|
||||
|
||||
QGraphicsPathItem::paint (painter, &myOption, widget);
|
||||
|
||||
Reference in New Issue
Block a user