TechDraw: remove unneeded state from QGIDecoration

This commit is contained in:
Benjamin Bræstrup Sayoc
2025-02-23 00:07:20 +01:00
parent 37cd2bd03a
commit 6cb6757908
4 changed files with 23 additions and 45 deletions

View File

@@ -38,9 +38,7 @@ using namespace TechDrawGui;
using namespace TechDraw;
QGIDecoration::QGIDecoration() :
m_colCurrent(Qt::black),
m_styleCurrent(Qt::SolidLine),
m_brushCurrent(Qt::SolidPattern),
m_pen(Qt::SolidLine),
m_dragState(DragState::NoDrag)
{
setCacheMode(QGraphicsItem::NoCache);
@@ -68,22 +66,18 @@ void QGIDecoration::paint ( QPainter * painter, const QStyleOptionGraphicsItem *
void QGIDecoration::setWidth(double w)
{
m_width = w;
m_pen.setWidthF(m_width);
m_pen.setWidthF(w);
}
void QGIDecoration::setStyle(Qt::PenStyle s)
{
m_styleCurrent = s;
m_pen.setStyle(m_styleCurrent);
m_pen.setStyle(s);
}
void QGIDecoration::setColor(QColor c)
{
m_colNormal = c;
m_colCurrent = c;
m_pen.setColor(m_colCurrent);
m_brush.setColor(m_colCurrent);
m_pen.setColor(c);
m_brush.setColor(c);
}
QColor QGIDecoration::prefNormalColor()

View File

@@ -67,11 +67,10 @@ public:
virtual void onDragFinished();
void setWidth(double w);
double getWidth() { return m_width; }
double getWidth() { return m_pen.widthF(); }
void setStyle(Qt::PenStyle s);
void setColor(QColor c);
QColor getColor() { return m_colNormal; }
void setFill(Qt::BrushStyle bs) { m_brushCurrent = bs; }
void makeMark(double x, double y);
void makeMark(Base::Vector3d v);
@@ -84,11 +83,7 @@ protected:
virtual QColor prefSelectColor();
QPen m_pen;
QBrush m_brush;
QColor m_colCurrent;
QColor m_colNormal;
double m_width;
Qt::PenStyle m_styleCurrent;
Qt::BrushStyle m_brushCurrent;
DragState m_dragState;

View File

@@ -483,22 +483,18 @@ void QGISectionLine::paint ( QPainter * painter, const QStyleOptionGraphicsItem
void QGISectionLine::setTools()
{
m_pen.setWidthF(m_width);
m_pen.setColor(m_colCurrent);
m_brush.setStyle(m_brushCurrent);
m_brush.setColor(m_colCurrent);
m_line->setPen(m_pen);
QColor currentColor = m_pen.color();
m_arrow1->setNormalColor(m_colCurrent);
m_arrow1->setFillColor(m_colCurrent);
m_arrow1->setNormalColor(currentColor);
m_arrow1->setFillColor(currentColor);
m_arrow1->setPrettyNormal();
m_arrow2->setNormalColor(m_colCurrent);
m_arrow2->setFillColor(m_colCurrent);
m_arrow2->setNormalColor(currentColor);
m_arrow2->setFillColor(currentColor);
m_arrow2->setPrettyNormal();
m_symbol1->setDefaultTextColor(m_colCurrent);
m_symbol2->setDefaultTextColor(m_colCurrent);
m_symbol1->setDefaultTextColor(currentColor);
m_symbol2->setDefaultTextColor(currentColor);
}

View File

@@ -84,7 +84,6 @@ QGITile::QGITile(TechDraw::DrawTileWeld* dtw) :
setFlag(QGraphicsItem::ItemStacksBehindParent, true);
m_colNormal = prefNormalColor();
m_colCurrent = m_colNormal;
}
@@ -100,7 +99,6 @@ void QGITile::draw()
void QGITile::makeSymbol()
{
// m_effect->setColor(m_colCurrent);
// m_qgSvg->setGraphicsEffect(m_effect);
std::string symbolString = getStringFromFile(m_tileFeat->SymbolFile.getValue());
@@ -123,7 +121,6 @@ void QGITile::makeText()
m_qgTextL->setFont(m_font);
m_qgTextL->setPlainText(m_textL);
m_qgTextL->setColor(m_colCurrent);
double textWidth = m_qgTextL->boundingRect().width();
double charWidth = textWidth / m_textL.size(); //not good for non-ASCII chars
double hMargin = 1;
@@ -148,7 +145,6 @@ void QGITile::makeText()
m_qgTextR->setFont(m_font);
m_qgTextR->setPlainText(m_textR);
m_qgTextR->setColor(m_colCurrent);
textWidth = m_qgTextR->boundingRect().width();
charWidth = textWidth / m_textR.size();
hMargin = 1;
@@ -165,7 +161,6 @@ void QGITile::makeText()
m_qgTextC->setFont(m_font);
m_qgTextC->setPlainText(m_textC);
m_qgTextC->setColor(m_colCurrent);
double textHeightC = m_qgTextC->boundingRect().height();
if (m_row < 0) { // below line
vOffset = m_high * (1 + verticalFudge);
@@ -235,8 +230,6 @@ void QGITile::setSymbolFile(const std::string &fileSpec)
}
void QGITile::setPrettyNormal() {
m_colCurrent = m_colNormal;
// m_effect->setColor(m_colNormal);
m_qgTextL->setColor(m_colNormal);
m_qgTextR->setColor(m_colNormal);
@@ -246,23 +239,23 @@ void QGITile::setPrettyNormal() {
}
void QGITile::setPrettyPre() {
m_colCurrent = prefPreColor();
QColor color = prefPreColor();
// m_effect->setColor(m_colCurrent);
m_qgTextL->setColor(m_colCurrent);
m_qgTextR->setColor(m_colCurrent);
m_qgTextC->setColor(m_colCurrent);
// m_effect->setColor(color);
m_qgTextL->setColor(color);
m_qgTextR->setColor(color);
m_qgTextC->setColor(color);
draw();
}
void QGITile::setPrettySel() {
m_colCurrent = prefSelectColor();
QColor color = prefSelectColor();
// m_effect->setColor(m_colCurrent);
m_qgTextL->setColor(m_colCurrent);
m_qgTextR->setColor(m_colCurrent);
m_qgTextC->setColor(m_colCurrent);
// m_effect->setColor(color);
m_qgTextL->setColor(color);
m_qgTextR->setColor(color);
m_qgTextC->setColor(color);
draw();
}