diff --git a/src/Gui/SoFCSelection.cpp b/src/Gui/SoFCSelection.cpp index 27e939790..53b1e1b7b 100644 --- a/src/Gui/SoFCSelection.cpp +++ b/src/Gui/SoFCSelection.cpp @@ -802,10 +802,10 @@ SoFCSelection::redrawHighlighted(SoAction * action , SbBool doHighlight ) //void* window; //void* context; //void *display; - QGLWidget* window; + QGLWidget* window; SoGLRenderAction *glAction; //SoWindowElement::get(state, window, context, display, glAction); - SoGLWidgetElement::get(state, window); + SoGLWidgetElement::get(state, window); SoGLRenderActionElement::get(state, glAction); // If we don't have a current window, then simply return... @@ -917,4 +917,36 @@ SoFCSelection::isHighlighted(SoAction *action) *currenthighlight == *actionPath); } +void SoFCSelection::applySettings () +{ + // TODO Some view providers got copy of this code: make them use this (2015-09-03, Fat-Zer) + // Note: SoFCUnifiedSelection got the same code, keep in sync or think about a way to share it + float transparency; + ParameterGrp::handle hGrp = Gui::WindowParameter::getDefaultParameter()->GetGroup("View"); + bool enablePre = hGrp->GetBool("EnablePreselection", true); + bool enableSel = hGrp->GetBool("EnableSelection", true); + if (!enablePre) { + this->highlightMode = Gui::SoFCSelection::OFF; + } + else { + // Search for a user defined value with the current color as default + SbColor highlightColor = this->colorHighlight.getValue(); + unsigned long highlight = (unsigned long)(highlightColor.getPackedValue()); + highlight = hGrp->GetUnsigned("HighlightColor", highlight); + highlightColor.setPackedValue((uint32_t)highlight, transparency); + this->colorHighlight.setValue(highlightColor); + } + if (!enableSel) { + this->selectionMode = Gui::SoFCSelection::SEL_OFF; + } + else { + // Do the same with the selection color + SbColor selectionColor = this->colorSelection.getValue(); + unsigned long selection = (unsigned long)(selectionColor.getPackedValue()); + selection = hGrp->GetUnsigned("SelectionColor", selection); + selectionColor.setPackedValue((uint32_t)selection, transparency); + this->colorSelection.setValue(selectionColor); + } +} + //#undef THIS diff --git a/src/Gui/SoFCSelection.h b/src/Gui/SoFCSelection.h index 656f3ccdf..e1ae8a98a 100644 --- a/src/Gui/SoFCSelection.h +++ b/src/Gui/SoFCSelection.h @@ -23,15 +23,15 @@ #ifndef GUI_SOFCSELECTION_H #define GUI_SOFCSELECTION_H -# ifdef FC_OS_MACOSX -# include -# else +# ifdef FC_OS_MACOSX +# include +# else # ifdef FC_OS_WIN32 # define NOMINMAX # include -# endif -# include -# endif +# endif +# include +# endif #include #include @@ -61,6 +61,9 @@ public: static void finish(void); SoFCSelection(void); + /// Load highlight settings from the configuration + void applySettings (); + enum HighlightModes { AUTO, ON, OFF };