From 8832356802011bf5d70e9d6f0efa89c47bc70a91 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 22 Feb 2020 12:09:26 +0100 Subject: [PATCH] Part: [skip ci] add option to set two-side rendering of Part shapes --- src/Mod/Part/Gui/DlgSettingsObjectColor.cpp | 2 + src/Mod/Part/Gui/DlgSettingsObjectColor.ui | 253 +++++++++++--------- src/Mod/Part/Gui/ViewProviderExt.cpp | 8 +- 3 files changed, 141 insertions(+), 122 deletions(-) diff --git a/src/Mod/Part/Gui/DlgSettingsObjectColor.cpp b/src/Mod/Part/Gui/DlgSettingsObjectColor.cpp index fb86da0bbf..c4d79d1824 100644 --- a/src/Mod/Part/Gui/DlgSettingsObjectColor.cpp +++ b/src/Mod/Part/Gui/DlgSettingsObjectColor.cpp @@ -64,6 +64,7 @@ void DlgSettingsObjectColor::saveSettings() ui->DefaultShapeVertexColor->onSave(); ui->DefaultShapeVertexSize->onSave(); ui->BoundingBoxColor->onSave(); + ui->twosideRendering->onSave(); // Annotations ui->AnnotationTextColor->onSave(); } @@ -78,6 +79,7 @@ void DlgSettingsObjectColor::loadSettings() ui->DefaultShapeVertexColor->onRestore(); ui->DefaultShapeVertexSize->onRestore(); ui->BoundingBoxColor->onRestore(); + ui->twosideRendering->onRestore(); // Annotations ui->AnnotationTextColor->onRestore(); } diff --git a/src/Mod/Part/Gui/DlgSettingsObjectColor.ui b/src/Mod/Part/Gui/DlgSettingsObjectColor.ui index 01a8a1cb7b..d7406b8b4b 100644 --- a/src/Mod/Part/Gui/DlgSettingsObjectColor.ui +++ b/src/Mod/Part/Gui/DlgSettingsObjectColor.ui @@ -22,32 +22,6 @@ - - - - - 182 - 0 - - - - Default vertex color - - - - - - - - 182 - 0 - - - - Bounding box color - - - @@ -61,6 +35,52 @@ + + + + The default color for new shapes + + + + 204 + 204 + 204 + + + + DefaultShapeColor + + + View + + + + + + + Random shape color + + + RandomColor + + + View + + + + + + + + 182 + 0 + + + + Default line color + + + @@ -81,23 +101,16 @@ - - - - The default color for new shapes + + + + + 182 + 0 + - - - 204 - 204 - 204 - - - - DefaultShapeColor - - - View + + Default line width @@ -123,50 +136,8 @@ - - - - The default size for new vertices - - - px - - - 9 - - - 2 - - - DefaultShapePointSize - - - View - - - - - - - The color of bounding boxes in the 3D view - - - - 255 - 255 - 255 - - - - BoundingBoxColor - - - View - - - - - + + 182 @@ -174,33 +145,7 @@ - Default vertex size - - - - - - - - 182 - 0 - - - - Default line width - - - - - - - - 182 - 0 - - - - Default line color + Default vertex color @@ -224,19 +169,93 @@ - - + + + + + 182 + 0 + + - Random shape color + Default vertex size + + + + + + + The default size for new vertices + + + px + + + 9 + + + 2 - RandomColor + DefaultShapePointSize View + + + + + 182 + 0 + + + + Bounding box color + + + + + + + The color of bounding boxes in the 3D view + + + + 255 + 255 + 255 + + + + BoundingBoxColor + + + View + + + + + + + + 182 + 0 + + + + Two-side rendering + + + TwoSideRendering + + + Mod/Part + + + diff --git a/src/Mod/Part/Gui/ViewProviderExt.cpp b/src/Mod/Part/Gui/ViewProviderExt.cpp index edd28bae5a..70230e0af6 100644 --- a/src/Mod/Part/Gui/ViewProviderExt.cpp +++ b/src/Mod/Part/Gui/ViewProviderExt.cpp @@ -246,6 +246,8 @@ ViewProviderPartExt::ViewProviderPartExt() ("User parameter:BaseApp/Preferences/Mod/Part"); NormalsFromUV = hPart->GetBool("NormalsFromUVNodes", NormalsFromUV); + long twoside = hPart->GetBool("TwoSideRendering", false) ? 1 : 0; + // Let the user define a custom lower limit but a value less than // OCCT's epsilon is not allowed double lowerLimit = hPart->GetFloat("MinimumDeviation", tessRange.LowerBound); @@ -274,7 +276,7 @@ ViewProviderPartExt::ViewProviderPartExt() Deviation.setConstraints(&tessRange); ADD_PROPERTY(AngularDeflection,(28.65)); AngularDeflection.setConstraints(&angDeflectionRange); - ADD_PROPERTY(Lighting,(1)); + ADD_PROPERTY(Lighting,(twoside)); Lighting.setEnums(LightingEnums); ADD_PROPERTY(DrawStyle,((long int)0)); DrawStyle.setEnums(DrawStyleEnums); @@ -502,10 +504,6 @@ void ViewProviderPartExt::attach(App::DocumentObject *pcFeat) pcPointsRoot->boundingBoxCaching = wireframe->boundingBoxCaching = SoSeparator::OFF; - // enable two-side rendering - pShapeHints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE; - pShapeHints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE; - // Avoid any Z-buffer artifacts, so that the lines always appear on top of the faces // The correct order is Edges, Polygon offset, Faces. SoPolygonOffset* offset = new SoPolygonOffset();