Datums not selectable during edit

This commit is contained in:
Stefan Tröger 2016-01-16 20:44:25 +01:00
parent 5002e8e430
commit 7dea66872e
3 changed files with 35 additions and 4 deletions

View File

@ -228,6 +228,8 @@ TaskDatumParameters::TaskDatumParameters(ViewProviderDatum *DatumView,QWidget *p
autoNext = true;
else
autoNext = false;
DatumView->setPickable(false);
}
QString getShTypeText(eRefType type)
@ -782,6 +784,8 @@ TaskDatumParameters::~TaskDatumParameters()
}
}
DatumView->setPickable(true);
delete ui;
}

View File

@ -85,7 +85,9 @@ ViewProviderDatum::ViewProviderDatum()
{
pShapeSep = new SoSeparator();
pShapeSep->ref();
pPickStyle = new SoPickStyle();
pPickStyle->ref();
// set default color for datums (golden yellow with 60% transparency)
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath (
"User parameter:BaseApp/Preferences/Mod/PartDesign");
@ -103,6 +105,7 @@ ViewProviderDatum::ViewProviderDatum()
ViewProviderDatum::~ViewProviderDatum()
{
pShapeSep->unref();
pPickStyle->unref();
}
void ViewProviderDatum::attach(App::DocumentObject *obj)
@ -125,15 +128,16 @@ void ViewProviderDatum::attach(App::DocumentObject *obj)
hints->vertexOrdering.setValue(SoShapeHints::COUNTERCLOCKWISE);
SoDrawStyle* fstyle = new SoDrawStyle();
fstyle->style = SoDrawStyle::FILLED;
SoPickStyle* pickStyle = new SoPickStyle();
pickStyle->style = SoPickStyle::SHAPE;
fstyle->lineWidth = 3;
fstyle->pointSize = 5;
pPickStyle->style = SoPickStyle::SHAPE;
SoMaterialBinding* matBinding = new SoMaterialBinding;
matBinding->value = SoMaterialBinding::OVERALL;
SoSeparator* sep = new SoSeparator();
sep->addChild(hints);
sep->addChild(fstyle);
sep->addChild(pickStyle);
sep->addChild(pPickStyle);
sep->addChild(matBinding);
sep->addChild(pcShapeMaterial);
sep->addChild(pShapeSep);
@ -388,3 +392,16 @@ SbBox3f ViewProviderDatum::defaultBoundBox () {
return SbBox3f ( -defaultSize, -defaultSize, -defaultSize,
defaultSize, defaultSize, defaultSize );
}
bool ViewProviderDatum::isPickable() {
return bool(pPickStyle->style.getValue() == SoPickStyle::SHAPE);
}
void ViewProviderDatum::setPickable(bool val) {
if(val)
pPickStyle->style = SoPickStyle::SHAPE;
else
pPickStyle->style = SoPickStyle::UNPICKABLE;
}

View File

@ -27,6 +27,7 @@
#include "Gui/ViewProviderGeometryObject.h"
#include <Base/BoundBox.h>
class SoPickStyle;
class SbBox3f;
class SoGetBoundingBoxAction;
@ -59,6 +60,14 @@ public:
virtual std::string getElement(const SoDetail *) const;
virtual SoDetail* getDetail(const char*) const;
/**
* Enable/Disable the selectability of the datum
* This differs from the normal ViewProvider selectability in that, that with this enabled one
* can pick through the datum and select stuff behind it.
*/
bool isPickable();
void setPickable(bool val);
/**
* Update the visual size to match the given extents
* @note should be reimplemented in the offspings
@ -116,6 +125,7 @@ protected:
private:
SoSeparator* pShapeSep;
SoPickStyle* pPickStyle;
std::string oldWb;
App::DocumentObject* oldTip;