+ move creation of SoFCSelection node to ViewProviderBuilder to avoid code duplication
This commit is contained in:
@@ -28,6 +28,8 @@
|
||||
#endif
|
||||
|
||||
#include "ViewProviderBuilder.h"
|
||||
#include "SoFCSelection.h"
|
||||
#include "Window.h"
|
||||
#include <App/PropertyStandard.h>
|
||||
|
||||
using namespace Gui;
|
||||
@@ -55,6 +57,40 @@ ViewProvider* ViewProviderBuilder::create(const Base::Type& type)
|
||||
return 0;
|
||||
}
|
||||
|
||||
Gui::SoFCSelection* ViewProviderBuilder::createSelection()
|
||||
{
|
||||
Gui::SoFCSelection* sel = new Gui::SoFCSelection();
|
||||
|
||||
float transparency;
|
||||
ParameterGrp::handle hGrp = Gui::WindowParameter::getDefaultParameter()->GetGroup("View");
|
||||
bool enablePre = hGrp->GetBool("EnablePreselection", true);
|
||||
bool enableSel = hGrp->GetBool("EnableSelection", true);
|
||||
if (!enablePre) {
|
||||
sel->highlightMode = Gui::SoFCSelection::OFF;
|
||||
}
|
||||
else {
|
||||
// Search for a user defined value with the current color as default
|
||||
SbColor highlightColor = sel->colorHighlight.getValue();
|
||||
unsigned long highlight = (unsigned long)(highlightColor.getPackedValue());
|
||||
highlight = hGrp->GetUnsigned("HighlightColor", highlight);
|
||||
highlightColor.setPackedValue((uint32_t)highlight, transparency);
|
||||
sel->colorHighlight.setValue(highlightColor);
|
||||
}
|
||||
if (!enableSel) {
|
||||
sel->selectionMode = Gui::SoFCSelection::SEL_OFF;
|
||||
}
|
||||
else {
|
||||
// Do the same with the selection color
|
||||
SbColor selectionColor = sel->colorSelection.getValue();
|
||||
unsigned long selection = (unsigned long)(selectionColor.getPackedValue());
|
||||
selection = hGrp->GetUnsigned("SelectionColor", selection);
|
||||
selectionColor.setPackedValue((uint32_t)selection, transparency);
|
||||
sel->colorSelection.setValue(selectionColor);
|
||||
}
|
||||
|
||||
return sel;
|
||||
}
|
||||
|
||||
// --------------------------------------
|
||||
|
||||
ViewProviderColorBuilder::ViewProviderColorBuilder()
|
||||
|
||||
Reference in New Issue
Block a user