+ 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

@@ -242,6 +242,12 @@ ViewProviderMesh::ViewProviderMesh() : pcOpenEdge(0)
Lighting.setEnums(LightingEnums);
ADD_PROPERTY(LineColor,(0,0,0));
// Create the selection node
pcHighlight = createFromSettings();
pcHighlight->ref();
if (pcHighlight->selectionMode.getValue() == Gui::SoFCSelection::SEL_OFF)
Selectable.setValue(false);
pOpenColor = new SoBaseColor();
setOpenEdgeColorFrom(ShapeColor.getValue());
pOpenColor->ref();
@@ -307,6 +313,7 @@ ViewProviderMesh::ViewProviderMesh() : pcOpenEdge(0)
ViewProviderMesh::~ViewProviderMesh()
{
pcHighlight->unref();
pOpenColor->unref();
pcLineStyle->unref();
pcPointStyle->unref();
@@ -315,6 +322,40 @@ ViewProviderMesh::~ViewProviderMesh()
pLineColor->unref();
}
Gui::SoFCSelection* ViewProviderMesh::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 ViewProviderMesh::onChanged(const App::Property* prop)
{
// we gonna change the number of colors to one
@@ -389,6 +430,10 @@ void ViewProviderMesh::attach(App::DocumentObject *pcFeat)
{
ViewProviderGeometryObject::attach(pcFeat);
pcHighlight->objectName = pcFeat->getNameInDocument();
pcHighlight->documentName = pcFeat->getDocument()->getName();
pcHighlight->subElementName = "Main";
// Note: Since for mesh data the SoFCSelection node has no SoSeparator but
// an SoGroup as parent the EMISSIVE style if set has fundamentally no effect.
// This behaviour is given due to the fact that SoFCSelection inherits from