[TD]Clean up Welding Symbol creation

This commit is contained in:
wandererfan
2019-08-01 19:29:34 -04:00
committed by WandererFan
parent 7cb2713e8c
commit 70a64afa53
12 changed files with 156 additions and 80 deletions

View File

@@ -152,7 +152,7 @@ void QGCustomText::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
void QGCustomText::setPrettyNormal() {
m_colCurrent = m_colNormal;
setDefaultTextColor(m_colNormal);
setDefaultTextColor(m_colCurrent);
update();
}

View File

@@ -45,20 +45,24 @@ QGIArrow::QGIArrow() :
m_fill(Qt::SolidPattern),
m_size(5.0),
m_style(0),
m_flipped(false),
m_dirMode(false),
m_dir(Base::Vector3d(1.0,0.0,0.0))
{
isFlipped = false;
setFill(Qt::SolidPattern);
m_brush.setStyle(m_fill);
setCacheMode(QGraphicsItem::NoCache);
setAcceptHoverEvents(false);
setFlag(QGraphicsItem::ItemIsSelectable, false);
setFlag(QGraphicsItem::ItemIsMovable, false);
}
void QGIArrow::flip(bool state) {
isFlipped = state;
}
void QGIArrow::draw() {
QPainterPath path;
if (m_style == 0) {
@@ -69,22 +73,26 @@ void QGIArrow::draw() {
path = makeFilledTriangle(m_size,m_size/6.0,isFlipped()); //"arrow l/w sb 3/1" ??
}
} else if (m_style == 1) {
setFill(Qt::NoBrush);
if (m_dirMode) {
path = makeOpenArrow(getDirection(), m_size,m_size/3.0); //broad arrow?
} else {
path = makeOpenArrow(m_size,m_size/3.0,isFlipped());
}
} else if (m_style == 2) {
setFill(Qt::NoBrush);
if (m_dirMode) {
path = makeHashMark(getDirection(), m_size/2.0,m_size/2.0); //big enough?
} else {
path = makeHashMark(m_size/2.0,m_size/2.0,isFlipped()); //big enough?
}
} else if (m_style == 3) {
setFill(Qt::SolidPattern);
path = makeDot(m_size/2.0,m_size/2.0,isFlipped());
} else if (m_style == 4) {
path = makeOpenDot(m_size/2.0,m_size/2.0,isFlipped());
} else if (m_style == 5) {
setFill(Qt::NoBrush);
if (m_dirMode) {
path = makeForkArrow(getDirection(), m_size/2.0,m_size/2.0); //big enough?
} else {

View File

@@ -62,16 +62,14 @@
#include "QGCustomSvg.h"
#include "QGCustomRect.h"
#include "QGIViewPart.h"
#include "QGIPrimPath.h"
#include "QGIFace.h"
using namespace TechDrawGui;
using namespace TechDraw;
QGIFace::QGIFace(int index) :
projIndex(index),
m_colDefFill(Qt::white),
m_styleDef(Qt::SolidPattern),
m_styleSelect(Qt::SolidPattern)
projIndex(index)
{
m_segCount = 0;
setFillMode(NoFill);
@@ -80,10 +78,6 @@ QGIFace::QGIFace(int index) :
//setStyle(Qt::NoPen); //don't draw face lines, just fill for debugging
setStyle(Qt::DashLine);
m_styleNormal = m_styleDef;
m_fillStyle = m_styleDef;
m_colNormalFill = m_colDefFill;
m_geomColor = QColor(Qt::black);
setLineWeight(0.5); //0 = cosmetic
@@ -99,6 +93,15 @@ QGIFace::QGIFace(int index) :
m_fillScale = 1.0;
getParameters();
m_styleNormal = m_styleDef;
m_fillStyle = m_styleDef;
m_fill = m_styleDef;
m_colDefFill = Qt::white;
m_colNormalFill = m_colDefFill;
m_styleDef = Qt::SolidPattern;
m_styleSelect = Qt::SolidPattern;
}
QGIFace::~QGIFace()
@@ -115,6 +118,7 @@ void QGIFace::draw()
if (!m_lineSets.empty()) {
m_brush.setTexture(QPixmap());
m_fillStyle = m_styleDef;
m_fill = m_styleDef;
m_styleNormal = m_fillStyle;
for (auto& ls: m_lineSets) {
lineSetToFillItems(ls);
@@ -130,6 +134,7 @@ void QGIFace::draw()
setFillMode(SvgFill);
m_brush.setTexture(QPixmap());
m_fillStyle = m_styleDef;
m_fill = m_styleDef;
m_styleNormal = m_fillStyle;
loadSvgHatch(m_fileSpec);
buildSvgHatch();
@@ -141,6 +146,7 @@ void QGIFace::draw()
setFillMode(BitmapFill);
toggleSvg(false);
m_fillStyle = Qt::TexturePattern;
m_fill = Qt::TexturePattern;
m_texture = textureFromBitmap(m_fileSpec);
m_brush.setTexture(m_texture);
}
@@ -154,11 +160,14 @@ void QGIFace::setPrettyNormal() {
if (isHatched() &&
(m_mode == BitmapFill) ) { //hatch with bitmap fill
m_fillStyle = Qt::TexturePattern;
m_fill = Qt::TexturePattern;
m_brush.setTexture(m_texture);
} else {
m_fillStyle = m_styleNormal;
m_fill = m_styleNormal;
m_brush.setTexture(QPixmap());
m_brush.setStyle(m_fillStyle);
// m_brush.setStyle(m_fillStyle);
m_brush.setStyle(m_fill); //???
m_fillColor = m_colNormalFill;
}
QGIPrimPath::setPrettyNormal();
@@ -167,6 +176,7 @@ void QGIFace::setPrettyNormal() {
void QGIFace::setPrettyPre() {
m_brush.setTexture(QPixmap());
m_fillStyle = m_styleSelect;
m_fill = m_styleSelect;
m_fillColor = getPreColor();
QGIPrimPath::setPrettyPre();
}
@@ -174,6 +184,7 @@ void QGIFace::setPrettyPre() {
void QGIFace::setPrettySel() {
m_brush.setTexture(QPixmap());
m_fillStyle = m_styleSelect;
m_fill = m_styleSelect;
m_fillColor = getSelectColor();
QGIPrimPath::setPrettySel();
}
@@ -595,21 +606,6 @@ QPixmap QGIFace::textureFromBitmap(std::string fileSpec)
return pix;
}
void QGIFace::setFill(QColor c, Qt::BrushStyle s) {
m_colNormalFill = c;
m_styleNormal = s;
}
void QGIFace::setFill(QBrush b) {
m_colNormalFill = b.color();
m_styleNormal = b.style();
}
void QGIFace::resetFill() {
m_colNormalFill = m_colDefFill;
m_styleNormal = m_styleDef;
}
void QGIFace::setLineWeight(double w) {
m_geomWeight = w;
}
@@ -642,9 +638,9 @@ void QGIFace::paint ( QPainter * painter, const QStyleOptionGraphicsItem * optio
myOption.state &= ~QStyle::State_Selected;
// painter->drawRect(boundingRect()); //good for debugging
m_brush.setStyle(m_fillStyle);
m_brush.setColor(m_fillColor);
setBrush(m_brush);
// m_brush.setStyle(m_fillStyle);
// m_brush.setColor(m_fillColor);
// setBrush(m_brush);
QGIPrimPath::paint (painter, &myOption, widget);
}

View File

@@ -74,9 +74,9 @@ public:
int getProjIndex() const { return projIndex; }
void draw();
void setPrettyNormal();
void setPrettyPre();
void setPrettySel();
virtual void setPrettyNormal() override;
virtual void setPrettyPre() override;
void setPrettySel() override;
void setDrawEdges(bool b);
virtual void setOutline(const QPainterPath& path);
@@ -85,10 +85,10 @@ public:
bool isHatched(void) {return m_isHatched;}
void setFillMode(fillMode m);
//plain color fill parms
void setFill(QColor c, Qt::BrushStyle s);
void setFill(QBrush b);
void resetFill();
/* //plain color fill parms*/
/* void setFill(QColor c, Qt::BrushStyle s);*/
/* void setFill(QBrush b);*/
/* void resetFill();*/
//general hatch parms & methods
void setHatchColor(App::Color c);
@@ -151,15 +151,15 @@ protected:
private:
QBrush m_brush;
Qt::BrushStyle m_fillStyle; //current fill style
QColor m_fillColor; //current fill color
/* QBrush m_brush;*/
/* Qt::BrushStyle m_fillStyle; //current fill style*/
/* QColor m_fillColor; //current fill color*/
QColor m_colDefFill; //"no color" default normal fill color
QColor m_colNormalFill; //current Normal fill color
Qt::BrushStyle m_styleDef; //default Normal fill style
Qt::BrushStyle m_styleNormal; //current Normal fill style
Qt::BrushStyle m_styleSelect; //Select/preSelect fill style
/* QColor m_colDefFill; //"no color" default normal fill color*/
/* QColor m_colNormalFill; //current Normal fill color*/
/* Qt::BrushStyle m_styleDef; //default Normal fill style*/
/* Qt::BrushStyle m_styleNormal; //current Normal fill style*/
/* Qt::BrushStyle m_styleSelect; //Select/preSelect fill style*/
QPixmap m_texture; //

View File

@@ -55,16 +55,27 @@ QGIPrimPath::QGIPrimPath():
isHighlighted = false;
m_colNormal = Qt::white;
m_colOverride = false;
m_colCurrent = getNormalColor();
m_colNormal = getNormalColor();
m_colCurrent = m_colNormal;
m_styleCurrent = Qt::SolidLine;
m_pen.setStyle(m_styleCurrent);
m_capStyle = prefCapStyle();
m_pen.setCapStyle(m_capStyle);
// m_pen.setCapStyle(Qt::FlatCap);
m_pen.setWidthF(m_width);
m_styleDef = Qt::NoBrush;
m_styleSelect = Qt::SolidPattern;
m_styleNormal = m_styleDef;
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);
setPrettyNormal();
}
@@ -109,36 +120,24 @@ void QGIPrimPath::setHighlighted(bool b)
}
void QGIPrimPath::setPrettyNormal() {
m_colCurrent = getNormalColor();
m_colCurrent = m_colNormal;
m_fillColor = m_colNormalFill;
// m_colCurrent = getNormalColor();
update();
}
void QGIPrimPath::setPrettyPre() {
m_colCurrent = getPreColor();
m_fillColor = getPreColor();
update();
}
void QGIPrimPath::setPrettySel() {
m_colCurrent = getSelectColor();
m_fillColor = getSelectColor();
update();
}
void QGIPrimPath::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;
m_pen.setWidthF(m_width);
m_pen.setColor(m_colCurrent);
m_pen.setStyle(m_styleCurrent);
setPen(m_pen);
m_brush.setColor(m_colCurrent);
m_brush.setStyle(m_fill);
setBrush(m_brush);
QGraphicsPathItem::paint (painter, &myOption, widget);
}
QColor QGIPrimPath::getNormalColor()
{
@@ -281,3 +280,38 @@ void QGIPrimPath::mousePressEvent(QGraphicsSceneMouseEvent * event)
QGraphicsPathItem::mousePressEvent(event);
}
}
void QGIPrimPath::setFill(QColor c, Qt::BrushStyle s) {
m_colNormalFill = c;
m_styleNormal = s;
m_fill = s;
}
void QGIPrimPath::setFill(QBrush b) {
m_colNormalFill = b.color();
m_styleNormal = b.style();
m_fill = b.style();
}
void QGIPrimPath::resetFill() {
m_colNormalFill = m_colDefFill;
m_styleNormal = m_styleDef;
m_fill = m_styleDef;
}
void QGIPrimPath::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;
m_pen.setWidthF(m_width);
m_pen.setColor(m_colCurrent);
m_pen.setStyle(m_styleCurrent);
setPen(m_pen);
m_brush.setColor(m_fillColor); //pencolr
m_brush.setStyle(m_fill);
setBrush(m_brush);
QGraphicsPathItem::paint (painter, &myOption, widget);
}

View File

@@ -59,7 +59,14 @@ public:
virtual void setNormalColor(QColor c);
virtual void setCapStyle(Qt::PenCapStyle c);
Qt::BrushStyle getFill() { return m_fill; }
//plain color fill parms
void setFill(Qt::BrushStyle f) { m_fill = f; }
void setFill(QColor c, Qt::BrushStyle s);
void setFill(QBrush b);
void resetFill();
void setFillColor(QColor c) { m_colNormalFill = c;
m_colDefFill = c; }
protected:
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
@@ -74,6 +81,7 @@ protected:
virtual Qt::PenCapStyle prefCapStyle(void);
bool isHighlighted;
QPen m_pen;
QColor m_colCurrent;
QColor m_colNormal;
@@ -81,8 +89,17 @@ protected:
Qt::PenStyle m_styleCurrent;
double m_width;
Qt::PenCapStyle m_capStyle;
QBrush m_brush;
Qt::BrushStyle m_fill;
Qt::BrushStyle m_fill; //current fille style
Qt::BrushStyle m_fillStyle; //current fill style*/
QColor m_fillColor; //current fill color
QColor m_colDefFill; //"no color" default normal fill color
QColor m_colNormalFill; //current Normal fill color
Qt::BrushStyle m_styleDef; //default Normal fill style
Qt::BrushStyle m_styleNormal; //current Normal fill style
Qt::BrushStyle m_styleSelect; //Select/preSelect fill style
private:

View File

@@ -44,6 +44,8 @@ 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);

View File

@@ -560,6 +560,7 @@ void QGIViewPart::drawViewPart()
item->setRadius(cv->size);
} else {
item->setNormalColor(vertexColor);
item->setFillColor(vertexColor);
item->setRadius(lineWidth * vertexScaleFactor);
}
addToGroup(item);

View File

@@ -80,8 +80,12 @@ QGIWeldSymbol::QGIWeldSymbol(QGILeaderLine* myParent,
m_qgLead(myParent),
m_blockDraw(false)
{
// setHandlesChildEvents(true); //qt4 deprecated in qt5
#if PY_MAJOR_VERSION < 3
setHandlesChildEvents(true); //qt4 deprecated in qt5
#else
setFiltersChildEvents(true); //qt5
#endif
setFlag(QGraphicsItem::ItemIsMovable, false);
setCacheMode(QGraphicsItem::NoCache);
@@ -106,7 +110,6 @@ QVariant QGIWeldSymbol::itemChange(GraphicsItemChange change, const QVariant &va
} else {
setPrettyNormal();
}
draw();
} else if(change == ItemSceneChange && scene()) {
// nothing special!
}
@@ -152,7 +155,7 @@ void QGIWeldSymbol::draw()
}
if (strlen(m_weldFeat->TailText.getValue()) != 0) {
drawProcessText();
drawTailText();
}
}
@@ -186,9 +189,12 @@ void QGIWeldSymbol::drawAllAround(void)
m_allAround = new QGIVertex(-1);
m_allAround->setParentItem(this);
m_allAround->setAcceptHoverEvents(false);
m_allAround->setFlag(QGraphicsItem::ItemIsSelectable, false);
m_allAround->setFlag(QGraphicsItem::ItemIsMovable, false);
m_allAround->setAcceptHoverEvents(false);
m_allAround->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false);
m_allAround->setFlag(QGraphicsItem::ItemSendsGeometryChanges,true);
m_allAround->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
m_allAround->setNormalColor(getCurrentColor());
@@ -202,9 +208,9 @@ void QGIWeldSymbol::drawAllAround(void)
m_allAround->setPos(allAroundPos);
}
void QGIWeldSymbol::drawProcessText(void)
void QGIWeldSymbol::drawTailText(void)
{
// Base::Console().Message("QGIWS::drawProcessText()\n");
// Base::Console().Message("QGIWS::drawTailText()\n");
m_tailText = new QGCustomText();
m_tailText->setParentItem(this);
@@ -251,17 +257,24 @@ void QGIWeldSymbol::drawFieldFlag()
m_fieldFlag = new QGIPrimPath();
m_fieldFlag->setParentItem(this);
m_fieldFlag->setAcceptHoverEvents(false);
m_fieldFlag->setFlag(QGraphicsItem::ItemIsSelectable, false);
m_fieldFlag->setFlag(QGraphicsItem::ItemIsMovable, false);
m_fieldFlag->setAcceptHoverEvents(false);
m_fieldFlag->setPath(path);
m_fieldFlag->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false);
m_fieldFlag->setFlag(QGraphicsItem::ItemSendsGeometryChanges,true);
m_fieldFlag->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
m_fieldFlag->setNormalColor(getCurrentColor());
m_fieldFlag->setFill(Qt::SolidPattern);
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);
m_fieldFlag->setPath(path);
QPointF fieldFlagPos = getKinkPoint();
m_fieldFlag->setPos(fieldFlagPos);
}
@@ -296,8 +309,8 @@ void QGIWeldSymbol::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
if (isSelected()) {
setPrettySel();
m_colCurrent = getSelectColor();
setPrettySel();
} else {
m_colCurrent = getPreColor();
setPrettyPre();
@@ -330,8 +343,13 @@ void QGIWeldSymbol::setPrettyNormal()
t->setColor(m_colNormal);
t->draw();
}
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();
m_tailText->setColor(m_colCurrent);
m_tailText->setPrettyNormal();
}

View File

@@ -93,7 +93,7 @@ protected:
void drawTile(TechDraw::DrawTileWeld* dtw,
QGITile* tile);
void drawAllAround(void);
void drawProcessText(void);
void drawTailText(void);
void drawFieldFlag();
void removeDecorations();

View File

@@ -371,7 +371,7 @@ App::DocumentObject* TaskWeldingSymbol::createWeldingSymbol(void)
Command::doCommand(Command::Doc,"App.activeDocument().%s.FieldWeld = %s",
symbolName.c_str(), fieldWeldText.c_str());
std::string tailText = Base::Tools::toStdString(ui->leProcessText->text());
std::string tailText = Base::Tools::toStdString(ui->leTailText->text());
Command::doCommand(Command::Doc,"App.activeDocument().%s.TailText = '%s'",
symbolName.c_str(), tailText.c_str());

View File

@@ -345,7 +345,7 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="leProcessText">
<widget class="QLineEdit" name="leTailText">
<property name="toolTip">
<string>Text at end of symbol</string>
</property>