From dd459f0d88381be61b5ebf9018943137e3203cb3 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Thu, 29 Aug 2019 20:57:46 -0400 Subject: [PATCH] [TD]Allow transparent Faces as default --- src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui | 1028 +++++++++--------- src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp | 4 + src/Mod/TechDraw/Gui/QGIFace.cpp | 40 +- src/Mod/TechDraw/Gui/QGIFace.h | 17 +- src/Mod/TechDraw/Gui/QGIPrimPath.cpp | 17 +- src/Mod/TechDraw/Gui/QGIPrimPath.h | 9 +- src/Mod/TechDraw/Gui/QGIViewPart.cpp | 3 +- 7 files changed, 598 insertions(+), 520 deletions(-) diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui b/src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui index 7cdec64c12..47a2a58e14 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui @@ -7,7 +7,7 @@ 0 0 558 - 1095 + 1110 @@ -17,489 +17,6 @@ Default value for new Page - - - - General - - - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Projection Angle - - - - - - - ProjectionAngle - - - /Mod/TechDraw/General - - - - First - - - - - Third - - - - - - - - Hidden Line - - - - - - - Style for hidden lines - - - 1 - - - HiddenLine - - - Mod/TechDraw/General - - - - NeverShow - - - - - Solid - - - - - Dash - - - - - Dot - - - - - DashDot - - - - - DashDotDot - - - - - - - - Perform/skip face processing - - - Detect Faces - - - true - - - HandleFaces - - - /Mod/TechDraw/General - - - - - - - Debugging option - - - Show Section Edges - - - ShowSectionEdges - - - /Mod/TechDraw/General - - - - - - - Automatically distribute secondary views. - - - AutoDistribute Secondary Views - - - true - - - AutoDist - - - /Mod/TechDraw/General - - - - - - - - 75 - true - - - - Drawing Updates - - - - - - - Update drawings with changes in 3D model - - - Update with 3D (Global Policy) - - - true - - - GlobalUpdateDrawings - - - Mod/TechDraw/General - - - - - - - Allow Page to override Global update setting - - - Allow Page Override - - - true - - - AllowPageOverride - - - Mod/TechDraw/General - - - - - - - <html><head/><body><p>Update Pages as scheduled or skip updates. This is the default setting for new Pages.</p></body></html> - - - Keep Page Up to Date (default) - - - true - - - KeepPagesUpToDate - - - Mod/TechDraw/General - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Colors - - - - - - - - Section Hatch - - - - - - - Section Face - - - - - - - - 80 - 80 - 80 - - - - Background - - - /Mod/TechDraw/Colors - - - - - - - - 255 - 255 - 20 - - - - PreSelectColor - - - Mod/TechDraw/Colors - - - - - - - Normal - - - - - - - HiddenColor - - - Mod/TechDraw/Colors - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 28 - 173 - 28 - - - - SelectColor - - - Mod/TechDraw/Colors - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - 0 - - - - NormalColor - - - Mod/TechDraw/Colors - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - PreSelected - - - - - - - Hidden Line - - - - - - - - 225 - 225 - 225 - - - - CutSurfaceColor - - - Mod/TechDraw/Colors - - - - - - - Selected - - - - - - - - 0 - 0 - 0 - - - - Hatch - - - /Mod/TechDraw/Colors - - - - - - - Background - - - - - - - Geom Hatch - - - - - - - - 0 - 0 - 0 - - - - GeomHatch - - - /Mod/TechDraw/Colors - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - @@ -841,6 +358,549 @@ + + + + Colors + + + + + + + + Section Hatch + + + + + + + Section Face + + + + + + + Window background color + + + + 80 + 80 + 80 + + + + Background + + + /Mod/TechDraw/Colors + + + + + + + Preselection color + + + + 255 + 255 + 20 + + + + PreSelectColor + + + Mod/TechDraw/Colors + + + + + + + Normal + + + + + + + Hidden line color + + + HiddenColor + + + Mod/TechDraw/Colors + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Selected item color + + + + 28 + 173 + 28 + + + + SelectColor + + + Mod/TechDraw/Colors + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Normal lne color + + + + 0 + 0 + 0 + + + + NormalColor + + + Mod/TechDraw/Colors + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + PreSelected + + + + + + + Hidden Line + + + + + + + Section Face color + + + + 225 + 225 + 225 + + + + CutSurfaceColor + + + Mod/TechDraw/Colors + + + + + + + Selected + + + + + + + Section Face Hatch color + + + + 0 + 0 + 0 + + + + Hatch + + + /Mod/TechDraw/Colors + + + + + + + Background + + + + + + + Geom Hatch + + + + + + + Default geometric hatch color + + + + 0 + 0 + 0 + + + + GeomHatch + + + /Mod/TechDraw/Colors + + + + + + + Default Face Color + + + + 255 + 255 + 255 + + + + FaceColor + + + /Mod/TechDraw/Colors + + + + + + + Transparent faces if checked + + + Transparent Faces + + + ClearFace + + + /Mod/TechDraw/Colors + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + General + + + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + Projection Angle + + + + + + + ProjectionAngle + + + /Mod/TechDraw/General + + + + First + + + + + Third + + + + + + + + Hidden Line + + + + + + + Style for hidden lines + + + 1 + + + HiddenLine + + + Mod/TechDraw/General + + + + NeverShow + + + + + Solid + + + + + Dash + + + + + Dot + + + + + DashDot + + + + + DashDotDot + + + + + + + + Perform/skip face processing + + + Detect Faces + + + true + + + HandleFaces + + + /Mod/TechDraw/General + + + + + + + Debugging option + + + Show Section Edges + + + ShowSectionEdges + + + /Mod/TechDraw/General + + + + + + + Automatically distribute secondary views. + + + AutoDistribute Secondary Views + + + true + + + AutoDist + + + /Mod/TechDraw/General + + + + + + + + 75 + true + + + + Drawing Updates + + + + + + + Update drawings with changes in 3D model + + + Update with 3D (Global Policy) + + + true + + + GlobalUpdateDrawings + + + Mod/TechDraw/General + + + + + + + Allow Page to override Global update setting + + + Allow Page Override + + + true + + + AllowPageOverride + + + Mod/TechDraw/General + + + + + + + <html><head/><body><p>Update Pages as scheduled or skip updates. This is the default setting for new Pages.</p></body></html> + + + Keep Page Up to Date (default) + + + true + + + KeepPagesUpToDate + + + Mod/TechDraw/General + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp index 53be57bdc3..c614e1024c 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp @@ -61,6 +61,8 @@ void DlgPrefsTechDrawImp::saveSettings() pcb_Surface->onSave(); pcb_Background->onSave(); pcb_Hatch->onSave(); + pcb_Face->onSave(); + pcb_PaintFaces->onSave(); //check box! pfb_LabelFont->onSave(); plsb_LabelSize->onSave(); @@ -94,6 +96,8 @@ void DlgPrefsTechDrawImp::loadSettings() pcb_Surface->onRestore(); pcb_Background->onRestore(); pcb_Hatch->onRestore(); + pcb_Face->onRestore(); + pcb_PaintFaces->onRestore(); //check box! pfb_LabelFont->onRestore(); plsb_LabelSize->onRestore(); diff --git a/src/Mod/TechDraw/Gui/QGIFace.cpp b/src/Mod/TechDraw/Gui/QGIFace.cpp index 42fcb63a14..92943b3973 100644 --- a/src/Mod/TechDraw/Gui/QGIFace.cpp +++ b/src/Mod/TechDraw/Gui/QGIFace.cpp @@ -72,7 +72,7 @@ QGIFace::QGIFace(int index) : projIndex(index) { m_segCount = 0; - setFillMode(NoFill); +// setFillMode(NoFill); isHatched(false); setFlag(QGraphicsItem::ItemClipsChildrenToShape,true); @@ -91,17 +91,23 @@ QGIFace::QGIFace(int index) : m_svgCol = SVGCOLDEFAULT; m_fillScale = 1.0; - + + m_colDefFill = Qt::white; + m_styleDef = Qt::SolidPattern; + m_styleSelect = Qt::SolidPattern; + 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; - + if (m_defClearFace) { + setFillMode(NoFill); + setFill(Qt::transparent, m_styleDef); + } else { + setFillMode(PlainFill); + setFill(m_colNormalFill, m_styleDef); + } } QGIFace::~QGIFace() @@ -151,6 +157,10 @@ void QGIFace::draw() m_brush.setTexture(m_texture); } } + } else if (m_mode == PlainFill) { + if (!m_lineSets.empty()) { + setFill(m_colNormalFill, m_styleNormal); + } } } show(); @@ -166,8 +176,7 @@ void QGIFace::setPrettyNormal() { m_fillStyle = m_styleNormal; m_fill = m_styleNormal; m_brush.setTexture(QPixmap()); -// m_brush.setStyle(m_fillStyle); - m_brush.setStyle(m_fill); //??? + m_brush.setStyle(m_fill); m_fillColor = m_colNormalFill; } QGIPrimPath::setPrettyNormal(); @@ -620,8 +629,16 @@ void QGIFace::getParameters(void) hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations"); m_maxTile = hGrp->GetInt("MaxSVGTile",10000l); -} + hGrp = App::GetApplication().GetUserParameter() + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors"); + App::Color temp = hGrp->GetUnsigned("FaceColor",0xffffffff); + setFillColor(temp.asValue()); + + hGrp = App::GetApplication().GetUserParameter() + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors"); + m_defClearFace = hGrp->GetBool("ClearFace",false); +} QRectF QGIFace::boundingRect() const { @@ -638,9 +655,6 @@ 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); QGIPrimPath::paint (painter, &myOption, widget); } diff --git a/src/Mod/TechDraw/Gui/QGIFace.h b/src/Mod/TechDraw/Gui/QGIFace.h index 5e3635a892..97b81cf7de 100644 --- a/src/Mod/TechDraw/Gui/QGIFace.h +++ b/src/Mod/TechDraw/Gui/QGIFace.h @@ -85,11 +85,6 @@ 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();*/ - //general hatch parms & methods void setHatchColor(App::Color c); void setHatchScale(double s); @@ -151,16 +146,6 @@ protected: private: -/* 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*/ - QPixmap m_texture; // QPainterPath m_outline; // @@ -169,6 +154,8 @@ private: QColor m_geomColor; //color for crosshatch lines double m_geomWeight; //lineweight for crosshatch lines + bool m_defClearFace; + QColor m_defFaceColor; }; } diff --git a/src/Mod/TechDraw/Gui/QGIPrimPath.cpp b/src/Mod/TechDraw/Gui/QGIPrimPath.cpp index 0fb4ab283b..30a94c1f6c 100644 --- a/src/Mod/TechDraw/Gui/QGIPrimPath.cpp +++ b/src/Mod/TechDraw/Gui/QGIPrimPath.cpp @@ -138,9 +138,10 @@ void QGIPrimPath::setPrettySel() { update(); } +//wf: why would a face use it's parent's normal colour? +//this always goes to parameter QColor QGIPrimPath::getNormalColor() { - QColor result; QGIView *parent; @@ -164,6 +165,7 @@ QColor QGIPrimPath::getNormalColor() fcColor.setPackedValue(hGrp->GetUnsigned("NormalColor", 0x00000000)); result = fcColor.asValue(); } + return result; } @@ -282,13 +284,13 @@ void QGIPrimPath::mousePressEvent(QGraphicsSceneMouseEvent * event) } void QGIPrimPath::setFill(QColor c, Qt::BrushStyle s) { - m_colNormalFill = c; + setFillColor(c); m_styleNormal = s; m_fill = s; } void QGIPrimPath::setFill(QBrush b) { - m_colNormalFill = b.color(); + setFillColor(b.color()); m_styleNormal = b.style(); m_fill = b.style(); } @@ -299,6 +301,13 @@ void QGIPrimPath::resetFill() { m_fill = m_styleDef; } +void QGIPrimPath::setFillColor(QColor c) +{ + m_colNormalFill = c; + m_colDefFill = c; +} + + void QGIPrimPath::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) { QStyleOptionGraphicsItem myOption(*option); myOption.state &= ~QStyle::State_Selected; @@ -308,7 +317,7 @@ void QGIPrimPath::paint ( QPainter * painter, const QStyleOptionGraphicsItem * o m_pen.setStyle(m_styleCurrent); setPen(m_pen); - m_brush.setColor(m_fillColor); //pencolr + m_brush.setColor(m_colNormalFill); m_brush.setStyle(m_fill); setBrush(m_brush); diff --git a/src/Mod/TechDraw/Gui/QGIPrimPath.h b/src/Mod/TechDraw/Gui/QGIPrimPath.h index 0625bf5574..d23fe6fbbf 100644 --- a/src/Mod/TechDraw/Gui/QGIPrimPath.h +++ b/src/Mod/TechDraw/Gui/QGIPrimPath.h @@ -58,15 +58,18 @@ public: void setStyle(int s); 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; } + Qt::BrushStyle getFill() { return m_fill; } + 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) { m_colNormalFill = c;*/ +/* m_colDefFill = c; }*/ + void setFillColor(QColor c); + QColor getFillColor(void) { return m_colDefFill; } protected: virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override; diff --git a/src/Mod/TechDraw/Gui/QGIViewPart.cpp b/src/Mod/TechDraw/Gui/QGIViewPart.cpp index 02c1067352..23c5b6b39a 100644 --- a/src/Mod/TechDraw/Gui/QGIViewPart.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewPart.cpp @@ -372,6 +372,7 @@ void QGIViewPart::drawViewPart() QGIFace* newFace = drawFace(*fit,i); newFace->isHatched(false); newFace->setFillMode(QGIFace::PlainFill); +// newFace->setFill(QColor(Qt::red), Qt::SolidPattern); //this overrides the QGIF defaults TechDraw::DrawHatch* fHatch = faceIsHatched(i,hatchObjs); TechDraw::DrawGeomHatch* fGeom = faceIsGeomHatched(i,geomObjs); if (fGeom) { @@ -418,8 +419,8 @@ void QGIViewPart::drawViewPart() bool drawEdges = prefFaceEdges(); newFace->setDrawEdges(drawEdges); //pref. for debugging only newFace->setZValue(ZVALUE::FACE); - newFace->draw(); newFace->setPrettyNormal(); + newFace->draw(); } } #endif //#if MOD_TECHDRAW_HANDLE_FACES