From 8edfa147da732ed6bf0c95db39b8808c20d35a1a Mon Sep 17 00:00:00 2001 From: WandererFan Date: Sat, 9 Jul 2016 11:37:55 -0400 Subject: [PATCH] Implement ShowCutSurface --- src/Mod/TechDraw/App/DrawViewSection.cpp | 16 +- src/Mod/TechDraw/App/DrawViewSection.h | 3 +- src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui | 768 ++++++++++--------- src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp | 2 + src/Mod/TechDraw/Gui/QGIViewSection.cpp | 7 +- 5 files changed, 417 insertions(+), 379 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawViewSection.cpp b/src/Mod/TechDraw/App/DrawViewSection.cpp index e72a8a4cb..7f90ce78c 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.cpp +++ b/src/Mod/TechDraw/App/DrawViewSection.cpp @@ -77,10 +77,13 @@ #include +#include +#include #include #include -#include +//#include #include +#include #include #include @@ -99,11 +102,17 @@ PROPERTY_SOURCE(TechDraw::DrawViewSection, TechDraw::DrawViewPart) DrawViewSection::DrawViewSection() { - static const char *group = "Shape view"; + static const char *group = "Section"; + + Base::Reference hGrp = App::GetApplication().GetUserParameter() + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors"); + App::Color fcColor = App::Color((uint32_t) hGrp->GetUnsigned("CutSurfaceColor", 0xC8C8C800)); + ADD_PROPERTY_TYPE(SectionNormal ,(0,0,1.0) ,group,App::Prop_None,"Section Plane normal direction"); ADD_PROPERTY_TYPE(SectionOrigin ,(0,0,0) ,group,App::Prop_None,"Section Plane Origin"); ADD_PROPERTY_TYPE(ShowCutSurface ,(true),group,App::Prop_None,"Show the cut surface"); + ADD_PROPERTY_TYPE(CutSurfaceColor,(fcColor),group,App::Prop_None,"The color to shade the cut surface"); geometryObject = new TechDrawGeometry::GeometryObject(); } @@ -117,7 +126,8 @@ short DrawViewSection::mustExecute() const // If Tolerance Property is touched if(SectionNormal.isTouched() || SectionOrigin.isTouched() || - ShowCutSurface.isTouched()) + ShowCutSurface.isTouched() || + CutSurfaceColor.isTouched() ) return 1; return TechDraw::DrawViewPart::mustExecute(); diff --git a/src/Mod/TechDraw/App/DrawViewSection.h b/src/Mod/TechDraw/App/DrawViewSection.h index a872db47f..5b4351314 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.h +++ b/src/Mod/TechDraw/App/DrawViewSection.h @@ -53,7 +53,8 @@ public: App::PropertyVector SectionNormal; App::PropertyVector SectionOrigin; - App::PropertyBool ShowCutSurface; + App::PropertyBool ShowCutSurface; + App::PropertyColor CutSurfaceColor; short mustExecute() const; bool isReallyInBox (const Base::Vector3d v, const Base::BoundBox3d bb) const; diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui b/src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui index 877985dda..eabe6bf13 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui @@ -6,396 +6,418 @@ 0 0 - 601 - 600 + 566 + 538 TechDraw - + 20 - 30 - 561 - 551 + 250 + 531 + 108 - + + Templates + + + + + 10 + 30 + 501 + 71 + + + + + + + Template Directory + + + + + + + Default Template + + + + + + + Gui::FileChooser::Directory + + + TemplateDir + + + /Mod/TechDraw + + + + + + + TemplateFile + + + /Mod/TechDraw + + + + + + + + + + 20 + 160 + 541 + 91 + + + + + 0 + 0 + + + + Font + + + + + 10 + 30 + 501 + 41 + + + + + + + Label Font + + + + + + + LabelFont + + + Mod/TechDraw + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + + 20 + 380 + 531 + 141 + + + + Misc + + + + + 10 + 30 + 501 + 95 + + + + + + + Projection Angle + + + + + + + ProjectionAngle + + + Mod/TechDraw + + + + First + + + + + Third + + + + + + + + Hidden Line + + + + + + + HiddenLine + + + Mod/TechDraw + + + + Solid + + + + + Dash + + + + + Dot + + + + + DashDot + + + + + DashDotDot + + + + + + + + Default Pattern File + + + + + + + PatternFile + + + /Mod/TechDraw + + + + + + + + + + 10 + 10 + 531 + 141 + + + + Colors + + - - - Colors - - - - - 20 - 20 - 191 - 128 - - - - - - - - 28 - 173 - 28 - - - - SelectColor - - - Mod/TechDraw/Colors - - - - - - - HiddenColor - - - Mod/TechDraw/Colors - - - - - - - - 0 - 0 - 0 - - - - NormalColor - - - Mod/TechDraw/Colors - - - - - - - PreSelected - - - - - - - Normal - - - - - - - Hidden - - - - - - - Selected - - - - - - - - 255 - 255 - 20 - - - - PreSelectColor - - - Mod/TechDraw/Colors - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - 0 - 160 - 559 - 91 - - - - - 0 - 0 - - - - Font - - - - - 20 - 30 - 451 - 41 - + + + + + Selected - - - - - Label Font - - - - - - - LabelFont - - - Mod/TechDraw - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - - - - - - 0 - 240 - 559 - 121 - - - - Templates - - - - - 20 - 20 - 451 - 71 - + + + + + + 255 + 255 + 20 + - - - - - Template Directory - - - - - - - Default Template - - - - - - - Gui::FileChooser::Directory - - - TemplateDir - - - /Mod/TechDraw - - - - - - - TemplateFile - - - /Mod/TechDraw - - - - - - - - - - 0 - 350 - 551 - 181 - - - - Misc - - - - - 20 - 30 - 531 - 103 - + + PreSelectColor - - - - - Hidden Line - - - - - - - ProjectionAngle - - - Mod/TechDraw - - - - First - - - - - Third - - - - - - - - HiddenLine - - - Mod/TechDraw - - - - Solid - - - - - Dash - - - - - Dot - - - - - DashDot - - - - - DashDotDot - - - - - - - - Projection Angle - - - - - - - - - 20 - 130 - 531 - 54 - + + Mod/TechDraw/Colors - - - - - - - PatternFile - - - /Mod/TechDraw - - - - - - - Default Pattern File - - - - - - - - + + + + + Normal + + + + + + + HiddenColor + + + Mod/TechDraw/Colors + + + + + + + + 28 + 173 + 28 + + + + SelectColor + + + Mod/TechDraw/Colors + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Section Face + + + + + + + + 0 + 0 + 0 + + + + NormalColor + + + Mod/TechDraw/Colors + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + PreSelected + + + + + + + Hidden + + + + + + + + 225 + 225 + 225 + + + + CutSurfaceColor + + + Mod/TechDraw/Colors + + + + diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp index 2ee5d03af..b6b357928 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp @@ -47,6 +47,7 @@ void DlgPrefsTechDrawImp::saveSettings() pcb_Select->onSave(); pcb_PreSelect->onSave(); pcb_Hidden->onSave(); + pcb_Surface->onSave(); le_LabelFont->onSave(); pfc_DefTemp->onSave(); pfc_DefDir->onSave(); @@ -62,6 +63,7 @@ void DlgPrefsTechDrawImp::loadSettings() pcb_Select->onRestore(); pcb_PreSelect->onRestore(); pcb_Hidden->onRestore(); + pcb_Surface->onRestore(); le_LabelFont->onRestore(); pfc_DefTemp->onRestore(); pfc_DefDir->onRestore(); diff --git a/src/Mod/TechDraw/Gui/QGIViewSection.cpp b/src/Mod/TechDraw/Gui/QGIViewSection.cpp index c0857ad69..ae58397bb 100644 --- a/src/Mod/TechDraw/Gui/QGIViewSection.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewSection.cpp @@ -67,6 +67,10 @@ void QGIViewSection::drawSectionFace() return; } + if (!section->ShowCutSurface.getValue()) { + return; + } + std::vector sectionFaces; sectionFaces = section->getFaceGeometry(); if (sectionFaces.empty()) { @@ -74,8 +78,7 @@ void QGIViewSection::drawSectionFace() return; } std::vector::iterator fit = sectionFaces.begin(); - QColor faceColor(0,0,255,40); //temp. sb preference or property. transparency allows bleed through/colour mix. - //QColor faceColor(170,170,255); //temp. sb preference or property. + QColor faceColor = section->CutSurfaceColor.getValue().asValue(); for(; fit != sectionFaces.end(); fit++) { QGIFace* newFace = drawFace(*fit,-1); //TODO: do we need to know which sectionFace this QGIFace came from? newFace->setZValue(ZVALUE::SECTIONFACE);