[TD]Fix selection highlight for QGIPrimPath children
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
#ifndef _PreComp_
|
||||
#include <assert.h>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsSceneHoverEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QPainterPathStroker>
|
||||
@@ -68,16 +67,16 @@ void QGIEdge::setHiddenEdge(bool b) {
|
||||
} else {
|
||||
m_styleCurrent = Qt::SolidLine;
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
void QGIEdge::setPrettyNormal() {
|
||||
// Base::Console().Message("QGIE::setPrettyNormal()\n");
|
||||
if (isHiddenEdge) {
|
||||
m_colCurrent = getHiddenColor();
|
||||
} else {
|
||||
m_colCurrent = getNormalColor();
|
||||
}
|
||||
update();
|
||||
//should call QGIPP::setPrettyNormal()?
|
||||
}
|
||||
|
||||
QColor QGIEdge::getHiddenColor()
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <QContextMenuEvent>
|
||||
#include <QGraphicsScene>
|
||||
#include <QMouseEvent>
|
||||
#include <QGraphicsSceneHoverEvent>
|
||||
#include <QPainterPathStroker>
|
||||
#include <QPainter>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
@@ -92,21 +91,19 @@ QGIFace::QGIFace(int index) :
|
||||
m_svgCol = SVGCOLDEFAULT;
|
||||
m_fillScale = 1.0;
|
||||
|
||||
m_colDefFill = Qt::white;
|
||||
getParameters();
|
||||
|
||||
m_styleDef = Qt::SolidPattern;
|
||||
m_styleSelect = Qt::SolidPattern;
|
||||
|
||||
getParameters();
|
||||
|
||||
m_styleNormal = m_styleDef;
|
||||
m_fillStyle = m_styleDef;
|
||||
m_fill = m_styleDef;
|
||||
if (m_defClearFace) {
|
||||
setFillMode(NoFill);
|
||||
m_colDefFill = Qt::transparent;
|
||||
setFill(Qt::transparent, m_styleDef);
|
||||
} else {
|
||||
setFillMode(PlainFill);
|
||||
setFill(m_colNormalFill, m_styleDef);
|
||||
m_colDefFill = Qt::white;
|
||||
setFill(m_colDefFill, m_styleDef);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,9 +120,8 @@ void QGIFace::draw()
|
||||
if (m_mode == GeomHatchFill) {
|
||||
if (!m_lineSets.empty()) {
|
||||
m_brush.setTexture(QPixmap());
|
||||
m_fillStyle = m_styleDef;
|
||||
m_fill = m_styleDef;
|
||||
m_styleNormal = m_fillStyle;
|
||||
m_fillStyleCurrent = m_styleDef;
|
||||
m_styleNormal = m_fillStyleCurrent;
|
||||
for (auto& ls: m_lineSets) {
|
||||
lineSetToFillItems(ls);
|
||||
}
|
||||
@@ -139,9 +135,8 @@ void QGIFace::draw()
|
||||
if (ext.toUpper() == QString::fromUtf8("SVG")) {
|
||||
setFillMode(SvgFill);
|
||||
m_brush.setTexture(QPixmap());
|
||||
m_fillStyle = m_styleDef;
|
||||
m_fill = m_styleDef;
|
||||
m_styleNormal = m_fillStyle;
|
||||
m_styleNormal = m_styleDef;
|
||||
m_fillStyleCurrent = m_styleNormal;
|
||||
loadSvgHatch(m_fileSpec);
|
||||
buildSvgHatch();
|
||||
toggleSvg(true);
|
||||
@@ -151,8 +146,7 @@ void QGIFace::draw()
|
||||
(ext.toUpper() == QString::fromUtf8("BMP")) ) {
|
||||
setFillMode(BitmapFill);
|
||||
toggleSvg(false);
|
||||
m_fillStyle = Qt::TexturePattern;
|
||||
m_fill = Qt::TexturePattern;
|
||||
m_fillStyleCurrent = Qt::TexturePattern;
|
||||
m_texture = textureFromBitmap(m_fileSpec);
|
||||
m_brush.setTexture(m_texture);
|
||||
}
|
||||
@@ -167,34 +161,26 @@ void QGIFace::draw()
|
||||
}
|
||||
|
||||
void QGIFace::setPrettyNormal() {
|
||||
// Base::Console().Message("QGIF::setPrettyNormal() - hatched: %d\n", isHatched());
|
||||
if (isHatched() &&
|
||||
(m_mode == BitmapFill) ) { //hatch with bitmap fill
|
||||
m_fillStyle = Qt::TexturePattern;
|
||||
m_fill = Qt::TexturePattern;
|
||||
m_fillStyleCurrent = Qt::TexturePattern;
|
||||
m_brush.setTexture(m_texture);
|
||||
} else {
|
||||
m_fillStyle = m_styleNormal;
|
||||
m_fill = m_styleNormal;
|
||||
m_brush.setTexture(QPixmap());
|
||||
m_brush.setStyle(m_fill);
|
||||
m_fillColor = m_colNormalFill;
|
||||
}
|
||||
QGIPrimPath::setPrettyNormal();
|
||||
}
|
||||
|
||||
void QGIFace::setPrettyPre() {
|
||||
// Base::Console().Message("QGIF::setPrettyPre()\n");
|
||||
m_brush.setTexture(QPixmap());
|
||||
m_fillStyle = m_styleSelect;
|
||||
m_fill = m_styleSelect;
|
||||
m_fillColor = getPreColor();
|
||||
QGIPrimPath::setPrettyPre();
|
||||
}
|
||||
|
||||
void QGIFace::setPrettySel() {
|
||||
// Base::Console().Message("QGIF::setPrettySel()\n");
|
||||
m_brush.setTexture(QPixmap());
|
||||
m_fillStyle = m_styleSelect;
|
||||
m_fill = m_styleSelect;
|
||||
m_fillColor = getSelectColor();
|
||||
QGIPrimPath::setPrettySel();
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
void draw();
|
||||
virtual void setPrettyNormal() override;
|
||||
virtual void setPrettyPre() override;
|
||||
void setPrettySel() override;
|
||||
virtual void setPrettySel() override;
|
||||
void setDrawEdges(bool b);
|
||||
virtual void setOutline(const QPainterPath& path);
|
||||
|
||||
|
||||
@@ -43,8 +43,8 @@ using namespace TechDrawGui;
|
||||
QGIPrimPath::QGIPrimPath():
|
||||
m_width(0),
|
||||
m_capStyle(Qt::RoundCap),
|
||||
m_fill(Qt::NoBrush)
|
||||
// m_fill(Qt::SolidPattern)
|
||||
m_fillStyleCurrent (Qt::NoBrush)
|
||||
// m_fillStyleCurrent (Qt::SolidPattern)
|
||||
{
|
||||
setCacheMode(QGraphicsItem::NoCache);
|
||||
setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||
@@ -67,14 +67,11 @@ QGIPrimPath::QGIPrimPath():
|
||||
m_styleDef = Qt::NoBrush;
|
||||
m_styleSelect = Qt::SolidPattern;
|
||||
m_styleNormal = m_styleDef;
|
||||
m_fillStyleCurrent = m_styleNormal;
|
||||
|
||||
m_colDefFill = Qt::white;
|
||||
// m_colDefFill = Qt::transparent;
|
||||
m_fillStyle = m_styleDef;
|
||||
m_fill = m_styleDef;
|
||||
m_colNormalFill = m_colDefFill;
|
||||
m_brush.setStyle(m_styleDef);
|
||||
m_brush.setColor(m_colDefFill);
|
||||
setFillColor(m_colDefFill);
|
||||
|
||||
setPrettyNormal();
|
||||
}
|
||||
@@ -94,6 +91,7 @@ QVariant QGIPrimPath::itemChange(GraphicsItemChange change, const QVariant &valu
|
||||
|
||||
void QGIPrimPath::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
// Base::Console().Message("QGIPP::hoverEnter() - selected; %d\n",isSelected());
|
||||
if (!isSelected()) {
|
||||
setPrettyPre();
|
||||
}
|
||||
@@ -102,9 +100,11 @@ void QGIPrimPath::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
|
||||
void QGIPrimPath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
// Base::Console().Message("QGIPP::hoverLeave() - selected; %d\n",isSelected());
|
||||
if(!isSelected()) {
|
||||
setPrettyNormal();
|
||||
}
|
||||
|
||||
QGraphicsPathItem::hoverLeaveEvent(event);
|
||||
}
|
||||
|
||||
@@ -120,22 +120,21 @@ void QGIPrimPath::setHighlighted(bool b)
|
||||
}
|
||||
|
||||
void QGIPrimPath::setPrettyNormal() {
|
||||
// Base::Console().Message("QGIPP::setPrettyNormal()\n");
|
||||
m_colCurrent = m_colNormal;
|
||||
m_fillColor = m_colNormalFill;
|
||||
// m_colCurrent = getNormalColor();
|
||||
update();
|
||||
m_fillColorCurrent = m_colNormalFill;
|
||||
}
|
||||
|
||||
void QGIPrimPath::setPrettyPre() {
|
||||
// Base::Console().Message("QGIPP::setPrettyPre()\n");
|
||||
m_colCurrent = getPreColor();
|
||||
m_fillColor = getPreColor();
|
||||
update();
|
||||
m_fillColorCurrent = getPreColor();
|
||||
}
|
||||
|
||||
void QGIPrimPath::setPrettySel() {
|
||||
// Base::Console().Message("QGIPP::setPrettySel()\n");
|
||||
m_colCurrent = getSelectColor();
|
||||
m_fillColor = getSelectColor();
|
||||
update();
|
||||
m_fillColorCurrent = getSelectColor();
|
||||
}
|
||||
|
||||
//wf: why would a face use it's parent's normal colour?
|
||||
@@ -286,25 +285,26 @@ void QGIPrimPath::mousePressEvent(QGraphicsSceneMouseEvent * event)
|
||||
void QGIPrimPath::setFill(QColor c, Qt::BrushStyle s) {
|
||||
setFillColor(c);
|
||||
m_styleNormal = s;
|
||||
m_fill = s;
|
||||
m_fillStyleCurrent = s;
|
||||
}
|
||||
|
||||
void QGIPrimPath::setFill(QBrush b) {
|
||||
setFillColor(b.color());
|
||||
m_styleNormal = b.style();
|
||||
m_fill = b.style();
|
||||
m_fillStyleCurrent = b.style();
|
||||
}
|
||||
|
||||
void QGIPrimPath::resetFill() {
|
||||
m_colNormalFill = m_colDefFill;
|
||||
m_styleNormal = m_styleDef;
|
||||
m_fill = m_styleDef;
|
||||
m_fillStyleCurrent = m_styleDef;
|
||||
}
|
||||
|
||||
//set PlainFill
|
||||
void QGIPrimPath::setFillColor(QColor c)
|
||||
{
|
||||
m_colNormalFill = c;
|
||||
m_colDefFill = c;
|
||||
// m_colDefFill = c;
|
||||
}
|
||||
|
||||
|
||||
@@ -317,8 +317,8 @@ void QGIPrimPath::paint ( QPainter * painter, const QStyleOptionGraphicsItem * o
|
||||
m_pen.setStyle(m_styleCurrent);
|
||||
setPen(m_pen);
|
||||
|
||||
m_brush.setColor(m_colNormalFill);
|
||||
m_brush.setStyle(m_fill);
|
||||
m_brush.setColor(m_fillColorCurrent);
|
||||
m_brush.setStyle(m_fillStyleCurrent);
|
||||
setBrush(m_brush);
|
||||
|
||||
QGraphicsPathItem::paint (painter, &myOption, widget);
|
||||
|
||||
@@ -60,14 +60,12 @@ public:
|
||||
virtual void setCapStyle(Qt::PenCapStyle c);
|
||||
|
||||
//plain color fill parms
|
||||
void setFill(Qt::BrushStyle f) { m_fill = f; }
|
||||
Qt::BrushStyle getFill() { return m_fill; }
|
||||
void setFillStyle(Qt::BrushStyle f) { m_fillStyleCurrent = f; }
|
||||
Qt::BrushStyle getFillStyle() { return m_fillStyleCurrent; }
|
||||
|
||||
void setFill(QColor c, Qt::BrushStyle s);
|
||||
void setFill(QBrush b);
|
||||
void resetFill();
|
||||
/* void setFillColor(QColor c) { m_colNormalFill = c;*/
|
||||
/* m_colDefFill = c; }*/
|
||||
void setFillColor(QColor c);
|
||||
QColor getFillColor(void) { return m_colDefFill; }
|
||||
|
||||
@@ -94,12 +92,11 @@ protected:
|
||||
Qt::PenCapStyle m_capStyle;
|
||||
|
||||
QBrush m_brush;
|
||||
Qt::BrushStyle m_fill; //current fill style
|
||||
Qt::BrushStyle m_fillStyle; //current fill style
|
||||
QColor m_fillColor; //current fill color
|
||||
Qt::BrushStyle m_fillStyleCurrent; //current fill style
|
||||
QColor m_fillColorCurrent; //current fill color
|
||||
|
||||
QColor m_colDefFill; //"no color" default normal fill color
|
||||
QColor m_colNormalFill; //current Normal fill color
|
||||
QColor m_colNormalFill; //current Normal fill color def or plain fill
|
||||
Qt::BrushStyle m_styleDef; //default Normal fill style
|
||||
Qt::BrushStyle m_styleNormal; //current Normal fill style
|
||||
Qt::BrushStyle m_styleSelect; //Select/preSelect fill style
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
#endif
|
||||
|
||||
//#include <App/Application.h>
|
||||
//#include <App/Material.h>
|
||||
#include <App/Application.h>
|
||||
#include <App/Material.h>
|
||||
#include <Base/Console.h>
|
||||
//#include <Base/Parameter.h>
|
||||
#include <Base/Parameter.h>
|
||||
|
||||
#include "QGIPrimPath.h"
|
||||
#include "QGIVertex.h"
|
||||
@@ -44,10 +44,13 @@ QGIVertex::QGIVertex(int index) :
|
||||
projIndex(index),
|
||||
m_radius(2)
|
||||
{
|
||||
m_colDefFill = getNormalColor();
|
||||
m_colNormalFill = m_colDefFill;
|
||||
m_fill = Qt::SolidPattern;
|
||||
m_brush.setStyle(m_fill);
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
|
||||
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("VertexColor", 0x00000000));
|
||||
QColor vertexColor = fcColor.asValue<QColor>();
|
||||
|
||||
setFill(vertexColor, Qt::SolidPattern);
|
||||
|
||||
setRadius(m_radius);
|
||||
}
|
||||
|
||||
@@ -121,9 +121,12 @@ QGIWeldSymbol::QGIWeldSymbol(QGILeaderLine* myParent) :
|
||||
m_fieldFlag->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false);
|
||||
m_fieldFlag->setFlag(QGraphicsItem::ItemSendsGeometryChanges,true);
|
||||
m_fieldFlag->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
||||
m_fieldFlag->setFill(prefNormalColor(), Qt::SolidPattern);
|
||||
|
||||
m_colCurrent = prefNormalColor();
|
||||
m_colSetting = m_colCurrent;
|
||||
|
||||
setPrettyNormal();
|
||||
}
|
||||
|
||||
QVariant QGIWeldSymbol::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
@@ -297,12 +300,7 @@ void QGIWeldSymbol::drawFieldFlag()
|
||||
path.lineTo(flagPoints.at(i) * scale);
|
||||
}
|
||||
|
||||
m_fieldFlag->setNormalColor(getCurrentColor()); //penColor
|
||||
double width = m_qgLead->getLineWidth();
|
||||
|
||||
m_fieldFlag->setFillColor(getCurrentColor());
|
||||
m_fieldFlag->setFill(Qt::SolidPattern);
|
||||
|
||||
m_fieldFlag->setWidth(width);
|
||||
m_fieldFlag->setZValue(ZVALUE::DIMENSION);
|
||||
|
||||
@@ -406,7 +404,6 @@ void QGIWeldSymbol::setPrettyNormal()
|
||||
}
|
||||
m_colCurrent = m_colNormal;
|
||||
m_fieldFlag->setNormalColor(m_colCurrent);
|
||||
m_fieldFlag->setFillColor(m_colCurrent);
|
||||
m_fieldFlag->setPrettyNormal();
|
||||
m_allAround->setNormalColor(m_colCurrent);
|
||||
m_allAround->setPrettyNormal();
|
||||
@@ -424,7 +421,6 @@ void QGIWeldSymbol::setPrettyPre()
|
||||
|
||||
m_colCurrent = getPreColor();
|
||||
m_fieldFlag->setNormalColor(getPreColor());
|
||||
m_fieldFlag->setFillColor(getPreColor());
|
||||
m_fieldFlag->setPrettyPre();
|
||||
m_allAround->setNormalColor(getPreColor());
|
||||
m_allAround->setPrettyPre();
|
||||
@@ -442,7 +438,6 @@ void QGIWeldSymbol::setPrettySel()
|
||||
|
||||
m_colCurrent = getSelectColor();
|
||||
m_fieldFlag->setNormalColor(getSelectColor());
|
||||
m_fieldFlag->setFillColor(getSelectColor());
|
||||
m_fieldFlag->setPrettySel();
|
||||
m_allAround->setNormalColor(getSelectColor());
|
||||
m_allAround->setPrettySel();
|
||||
|
||||
Reference in New Issue
Block a user