+ move creation of SoFCSelection node to ViewProviderBuilder to avoid code duplication

This commit is contained in:
wmayer
2016-03-31 15:54:33 +02:00
parent f623d870ce
commit 39e41146bb
6 changed files with 41 additions and 73 deletions

View File

@@ -75,7 +75,7 @@ ViewProviderPoints::ViewProviderPoints()
PointSize.setConstraints(&floatRange);
// Create the selection node
pcHighlight = createFromSettings();
pcHighlight = Gui::ViewProviderBuilder::createSelection();
pcHighlight->ref();
if (pcHighlight->selectionMode.getValue() == Gui::SoFCSelection::SEL_OFF)
Selectable.setValue(false);
@@ -102,40 +102,6 @@ ViewProviderPoints::~ViewProviderPoints()
pcPointStyle->unref();
}
Gui::SoFCSelection* ViewProviderPoints::createFromSettings() const
{
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 || !Selectable.getValue()) {
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;
}
void ViewProviderPoints::onChanged(const App::Property* prop)
{
if (prop == &PointSize) {