From 151d8a7b08730cf0115033c8256039852f6deb51 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Sat, 1 Apr 2017 02:49:24 +0800 Subject: [PATCH] Gui: allow bounding box style to be customized --- src/Gui/ViewProviderGeometryObject.cpp | 15 +++++++++------ src/Gui/ViewProviderGeometryObject.h | 4 +++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Gui/ViewProviderGeometryObject.cpp b/src/Gui/ViewProviderGeometryObject.cpp index a556076939..0e282d90a9 100644 --- a/src/Gui/ViewProviderGeometryObject.cpp +++ b/src/Gui/ViewProviderGeometryObject.cpp @@ -415,15 +415,18 @@ SoPickedPoint* ViewProviderGeometryObject::getPickedPoint(const SbVec2s& pos, co return (pick ? new SoPickedPoint(*pick) : 0); } +unsigned long ViewProviderGeometryObject::getBoundColor() const { + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View"); + if(SelectionStyle.getValue() == 0 || !Selectable.getValue() || !hGrp->GetBool("EnableSelection", true)) + return hGrp->GetUnsigned("BoundingBoxColor",4294967295UL); // white (255,255,255) + else + return hGrp->GetUnsigned("SelectionColor",0x00CD00UL); // rgb(0,205,0) +} + void ViewProviderGeometryObject::applyBoundColor() { if(!pcBoundColor) return; - ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View"); - unsigned long bbcol; - if(SelectionStyle.getValue() == 0 || !Selectable.getValue() || !hGrp->GetBool("EnableSelection", true)) - bbcol = hGrp->GetUnsigned("BoundingBoxColor",4294967295UL); // white (255,255,255) - else - bbcol = hGrp->GetUnsigned("SelectionColor",0x00CD00UL); // rgb(0,205,0) + unsigned long bbcol = getBoundColor(); float r,g,b; r = ((bbcol >> 24) & 0xff) / 255.0; g = ((bbcol >> 16) & 0xff) / 255.0; b = ((bbcol >> 8) & 0xff) / 255.0; pcBoundColor->rgb.setValue(r, g, b); diff --git a/src/Gui/ViewProviderGeometryObject.h b/src/Gui/ViewProviderGeometryObject.h index 99c1937f7b..8f513a9fda 100644 --- a/src/Gui/ViewProviderGeometryObject.h +++ b/src/Gui/ViewProviderGeometryObject.h @@ -96,7 +96,7 @@ public: /*! synchronize From FC placement to Coin placement*/ static void updateTransform(const Base::Placement &from, SoTransform *to); - void showBoundingBox(bool); + virtual void showBoundingBox(bool); protected: bool setEdit(int ModNum); @@ -110,6 +110,8 @@ protected: /// get called by the container whenever a property has been changed void onChanged(const App::Property* prop); void setSelectable(bool Selectable=true); + + virtual unsigned long getBoundColor() const; void applyBoundColor(); private: