From 54da404dbde4ced2c9948b6824a2695b1b2668d0 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Thu, 23 Feb 2012 13:28:56 -0200 Subject: [PATCH] Extended the DrawStryle property to all Part-based objects ViewProvider of Part objects now have a DrawStyle property that allow them to display with solid, dashed, dotted or dashdotted linestyles. --- src/Mod/Draft/Draft.py | 8 -------- src/Mod/Part/Gui/ViewProviderExt.cpp | 14 ++++++++++++++ src/Mod/Part/Gui/ViewProviderExt.h | 2 ++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py index 9fce6f8c6..1ef9c6aa2 100644 --- a/src/Mod/Draft/Draft.py +++ b/src/Mod/Draft/Draft.py @@ -1510,8 +1510,6 @@ class _ViewProviderDraft: return mode def onChanged(self, vp, prop): - if prop == "DrawStyle": - self.setStyle(vp) return def setStyle(self,vobj): @@ -2116,8 +2114,6 @@ class _ViewProviderRectangle(_ViewProviderDraft): if self.texture: r.removeChild(self.texture) self.texture = None - elif prop == "DrawStyle": - self.setStyle(vp) return class _Circle: @@ -2284,8 +2280,6 @@ class _ViewProviderWire(_ViewProviderDraft): rn.addChild(self.pt) else: rn.removeChild(self.pt) - elif prop == "DrawStyle": - self.setStyle(vp) return def claimChildren(self): @@ -2446,8 +2440,6 @@ class _ViewProviderBSpline(_ViewProviderDraft): rn.addChild(self.pt) else: rn.removeChild(self.pt) - elif prop == "DrawStyle": - self.setStyle(vp) return class _Block: diff --git a/src/Mod/Part/Gui/ViewProviderExt.cpp b/src/Mod/Part/Gui/ViewProviderExt.cpp index 8f929e121..1c2584813 100644 --- a/src/Mod/Part/Gui/ViewProviderExt.cpp +++ b/src/Mod/Part/Gui/ViewProviderExt.cpp @@ -119,6 +119,7 @@ PROPERTY_SOURCE(PartGui::ViewProviderPartExt, Gui::ViewProviderGeometryObject) App::PropertyFloatConstraint::Constraints ViewProviderPartExt::sizeRange = {1.0f,64.0f,1.0f}; App::PropertyFloatConstraint::Constraints ViewProviderPartExt::tessRange = {0.0001f,100.0f,0.01f}; const char* ViewProviderPartExt::LightingEnums[]= {"One side","Two side",NULL}; +const char* ViewProviderPartExt::DrawStyleEnums[]= {"Solid","Dashed","Dotted","Dashdot",NULL}; ViewProviderPartExt::ViewProviderPartExt() { @@ -145,6 +146,8 @@ ViewProviderPartExt::ViewProviderPartExt() ADD_PROPERTY(ControlPoints,(false)); ADD_PROPERTY(Lighting,(1)); Lighting.setEnums(LightingEnums); + ADD_PROPERTY(DrawStyle,((long int)0)); + DrawStyle.setEnums(DrawStyleEnums); coords = new SoCoordinate3(); coords->ref(); @@ -185,6 +188,7 @@ ViewProviderPartExt::ViewProviderPartExt() pShapeHints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE; pShapeHints->ref(); Lighting.touch(); + DrawStyle.touch(); sPixmap = "Tree_Part"; loadParameter(); @@ -278,6 +282,16 @@ void ViewProviderPartExt::onChanged(const App::Property* prop) else pShapeHints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE; } + else if (prop == &DrawStyle) { + if (DrawStyle.getValue() == 0) + pcLineStyle->linePattern = 0xffff; + else if (DrawStyle.getValue() == 1) + pcLineStyle->linePattern = 0xf00f; + else if (DrawStyle.getValue() == 2) + pcLineStyle->linePattern = 0x0f0f; + else + pcLineStyle->linePattern = 0xff88; + } else { // if the object was invisible and has been changed, recreate the visual if (prop == &Visibility && Visibility.getValue() && VisualTouched) diff --git a/src/Mod/Part/Gui/ViewProviderExt.h b/src/Mod/Part/Gui/ViewProviderExt.h index 116997963..4e0839e7c 100644 --- a/src/Mod/Part/Gui/ViewProviderExt.h +++ b/src/Mod/Part/Gui/ViewProviderExt.h @@ -77,6 +77,7 @@ public: App::PropertyMaterial PointMaterial; App::PropertyBool ControlPoints; App::PropertyEnumeration Lighting; + App::PropertyEnumeration DrawStyle; App::PropertyColorList DiffuseColor; @@ -144,6 +145,7 @@ private: static App::PropertyFloatConstraint::Constraints sizeRange; static App::PropertyFloatConstraint::Constraints tessRange; static const char* LightingEnums[]; + static const char* DrawStyleEnums[]; }; }