+ remove SoFCSelection from ViewProviderGeometryObject

This commit is contained in:
wmayer
2015-05-20 21:44:27 +02:00
parent 27863408c9
commit ef610c8c96
9 changed files with 111 additions and 58 deletions

View File

@@ -50,6 +50,7 @@
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/SoFCSelection.h>
#include <Gui/Window.h>
#include <Gui/View3DInventorViewer.h>
#include <Mod/Points/App/PointsFeature.h>
@@ -72,6 +73,12 @@ ViewProviderPoints::ViewProviderPoints()
ADD_PROPERTY(PointSize,(2.0f));
PointSize.setConstraints(&floatRange);
// Create the selection node
pcHighlight = createFromSettings();
pcHighlight->ref();
if (pcHighlight->selectionMode.getValue() == Gui::SoFCSelection::SEL_OFF)
Selectable.setValue(false);
pcPointsCoord = new SoCoordinate3();
pcPointsCoord->ref();
pcPoints = new SoPointSet();
@@ -89,6 +96,7 @@ ViewProviderPoints::ViewProviderPoints()
ViewProviderPoints::~ViewProviderPoints()
{
pcHighlight->unref();
pcPointsCoord->unref();
pcPoints->unref();
pcPointsNormal->unref();
@@ -96,6 +104,40 @@ 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 ) {
@@ -162,6 +204,10 @@ void ViewProviderPoints::attach(App::DocumentObject* pcObj)
// call parent's attach to define display modes
ViewProviderGeometryObject::attach(pcObj);
pcHighlight->objectName = pcObj->getNameInDocument();
pcHighlight->documentName = pcObj->getDocument()->getName();
pcHighlight->subElementName = "Main";
SoGroup* pcPointRoot = new SoGroup();
SoGroup* pcPointShadedRoot = new SoGroup();
SoGroup* pcColorShadedRoot = new SoGroup();