+ remove SoFCSelection from ViewProviderGeometryObject
This commit is contained in:
@@ -254,8 +254,6 @@ void ViewProviderFemMesh::attach(App::DocumentObject *pcObj)
|
||||
SoPointSet * pointset = new SoPointSet;
|
||||
pcAnotRoot->addChild(pointset);
|
||||
|
||||
//pcHighlight->addChild(pcFaces);
|
||||
|
||||
// flat
|
||||
SoGroup* pcFlatRoot = new SoGroup();
|
||||
// face nodes
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -123,6 +123,7 @@ public:
|
||||
|
||||
virtual void attach(App::DocumentObject *);
|
||||
virtual bool useNewSelectionModel(void) const {return false;}
|
||||
Gui::SoFCSelection* getHighlightNode() const { return pcHighlight; }
|
||||
virtual QIcon getIcon() const;
|
||||
/// Sets the correct display mode
|
||||
virtual void setDisplayMode(const char* ModeName);
|
||||
@@ -175,6 +176,7 @@ protected:
|
||||
|
||||
virtual SoShape* getShapeNode() const;
|
||||
virtual SoNode* getCoordNode() const;
|
||||
Gui::SoFCSelection* createFromSettings() const;
|
||||
|
||||
public:
|
||||
static void faceInfoCallback(void * ud, SoEventCallback * n);
|
||||
@@ -195,6 +197,7 @@ private:
|
||||
static void panCamera(SoCamera*, float, const SbPlane&, const SbVec2f&, const SbVec2f&);
|
||||
|
||||
protected:
|
||||
Gui::SoFCSelection * pcHighlight;
|
||||
SoDrawStyle * pcLineStyle;
|
||||
SoDrawStyle * pcPointStyle;
|
||||
SoSeparator * pcOpenEdge;
|
||||
|
||||
@@ -315,7 +315,7 @@ void ViewProviderMeshCurvature::updateData(const App::Property* prop)
|
||||
// get the view provider of the associated mesh feature
|
||||
App::Document* rDoc = pcObject->getDocument();
|
||||
Gui::Document* pDoc = Gui::Application::Instance->getDocument(rDoc);
|
||||
Gui::ViewProviderGeometryObject* view = static_cast<Gui::ViewProviderGeometryObject*>(pDoc->getViewProvider(object));
|
||||
ViewProviderMesh* view = static_cast<ViewProviderMesh*>(pDoc->getViewProvider(object));
|
||||
this->pcLinkRoot->addChild(view->getHighlightNode());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
#include <Base/Sequencer.h>
|
||||
#include <App/Application.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/SoFCSelection.h>
|
||||
|
||||
#include <Mod/Mesh/App/Core/Degeneration.h>
|
||||
#include <Mod/Mesh/App/Core/Evaluation.h>
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -41,6 +41,10 @@ namespace App {
|
||||
class PropertyColorList;
|
||||
}
|
||||
|
||||
namespace Gui {
|
||||
class SoFCSelection;
|
||||
}
|
||||
|
||||
namespace Points {
|
||||
class PropertyGreyValueList;
|
||||
class PropertyNormalList;
|
||||
@@ -96,6 +100,7 @@ public:
|
||||
static void clipPointsCallback(void * ud, SoEventCallback * n);
|
||||
|
||||
protected:
|
||||
Gui::SoFCSelection* createFromSettings() const;
|
||||
void onChanged(const App::Property* prop);
|
||||
void setVertexColorMode(App::PropertyColorList*);
|
||||
void setVertexGreyvalueMode(Points::PropertyGreyValueList*);
|
||||
@@ -103,11 +108,12 @@ protected:
|
||||
virtual void cut( const std::vector<SbVec2f>& picked, Gui::View3DInventorViewer &Viewer);
|
||||
|
||||
protected:
|
||||
SoCoordinate3 *pcPointsCoord;
|
||||
SoPointSet *pcPoints;
|
||||
SoMaterial *pcColorMat;
|
||||
SoNormal *pcPointsNormal;
|
||||
SoDrawStyle *pcPointStyle;
|
||||
Gui::SoFCSelection * pcHighlight;
|
||||
SoCoordinate3 * pcPointsCoord;
|
||||
SoPointSet * pcPoints;
|
||||
SoMaterial * pcColorMat;
|
||||
SoNormal * pcPointsNormal;
|
||||
SoDrawStyle * pcPointStyle;
|
||||
|
||||
private:
|
||||
static App::PropertyFloatConstraint::Constraints floatRange;
|
||||
|
||||
Reference in New Issue
Block a user