Prevent origin and base entities from transforming
This commit is contained in:
parent
3f5caa2181
commit
fcdb80eab3
|
@ -226,6 +226,17 @@ bool ViewProviderLine::isSelectable(void) const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ViewProviderLine::setEdit(int ModNum)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProviderLine::unsetEdit(int ModNum)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,9 @@ public:
|
||||||
virtual std::string getElement(const SoDetail *) const;
|
virtual std::string getElement(const SoDetail *) const;
|
||||||
virtual SoDetail* getDetail(const char*) const;
|
virtual SoDetail* getDetail(const char*) const;
|
||||||
|
|
||||||
|
virtual bool setEdit(int ModNum);
|
||||||
|
virtual void unsetEdit(int ModNum);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onChanged(const App::Property* prop);
|
void onChanged(const App::Property* prop);
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,17 @@ ViewProviderOrigin::~ViewProviderOrigin()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ViewProviderOrigin::setEdit(int ModNum)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProviderOrigin::unsetEdit(int ModNum)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Python feature -----------------------------------------------------------------------
|
// Python feature -----------------------------------------------------------------------
|
||||||
|
|
||||||
namespace Gui {
|
namespace Gui {
|
||||||
|
|
|
@ -43,6 +43,9 @@ public:
|
||||||
ViewProviderOrigin();
|
ViewProviderOrigin();
|
||||||
/// destructor.
|
/// destructor.
|
||||||
virtual ~ViewProviderOrigin();
|
virtual ~ViewProviderOrigin();
|
||||||
|
|
||||||
|
virtual bool setEdit(int ModNum);
|
||||||
|
virtual void unsetEdit(int ModNum);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef ViewProviderPythonFeatureT<ViewProviderOrigin> ViewProviderOriginPython;
|
typedef ViewProviderPythonFeatureT<ViewProviderOrigin> ViewProviderOriginPython;
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <App/Part.h>
|
#include <App/Part.h>
|
||||||
|
#include <App/Origin.h>
|
||||||
#include <App/Plane.h>
|
#include <App/Plane.h>
|
||||||
#include <App/Line.h>
|
#include <App/Line.h>
|
||||||
#include <App/Document.h>
|
#include <App/Document.h>
|
||||||
|
@ -92,6 +93,7 @@ void ViewProviderPart::onObjectChanged(const App::DocumentObject& obj, const App
|
||||||
{
|
{
|
||||||
App::Part* part = static_cast<App::Part*>(pcObject);
|
App::Part* part = static_cast<App::Part*>(pcObject);
|
||||||
if(static_cast<App::Part*>(pcObject)->hasObject(&obj) &&
|
if(static_cast<App::Part*>(pcObject)->hasObject(&obj) &&
|
||||||
|
obj.getTypeId() != App::Origin::getClassTypeId() &&
|
||||||
obj.getTypeId() != App::Plane::getClassTypeId() &&
|
obj.getTypeId() != App::Plane::getClassTypeId() &&
|
||||||
obj.getTypeId() != App::Line::getClassTypeId()) {
|
obj.getTypeId() != App::Line::getClassTypeId()) {
|
||||||
|
|
||||||
|
@ -101,7 +103,8 @@ void ViewProviderPart::onObjectChanged(const App::DocumentObject& obj, const App
|
||||||
//calculate for everything but planes
|
//calculate for everything but planes
|
||||||
SbBox3f bbox(0.0001f,0.0001f,0.0001f,0.0001f,0.0001f,0.0001f);
|
SbBox3f bbox(0.0001f,0.0001f,0.0001f,0.0001f,0.0001f,0.0001f);
|
||||||
for(App::DocumentObject* obj : part->getObjects()) {
|
for(App::DocumentObject* obj : part->getObjects()) {
|
||||||
if(obj->getTypeId() != App::Plane::getClassTypeId() &&
|
if(obj->getTypeId() != App::Origin::getClassTypeId() &&
|
||||||
|
obj->getTypeId() != App::Plane::getClassTypeId() &&
|
||||||
obj->getTypeId() != App::Line::getClassTypeId() ) {
|
obj->getTypeId() != App::Line::getClassTypeId() ) {
|
||||||
bboxAction.apply(Gui::Application::Instance->getViewProvider(obj)->getRoot());
|
bboxAction.apply(Gui::Application::Instance->getViewProvider(obj)->getRoot());
|
||||||
bbox.extendBy(bboxAction.getBoundingBox());
|
bbox.extendBy(bboxAction.getBoundingBox());
|
||||||
|
@ -113,8 +116,12 @@ void ViewProviderPart::onObjectChanged(const App::DocumentObject& obj, const App
|
||||||
SbVec3f max = bbox.getMax()*1.3;
|
SbVec3f max = bbox.getMax()*1.3;
|
||||||
SbVec3f min = bbox.getMin()*1.3;
|
SbVec3f min = bbox.getMin()*1.3;
|
||||||
|
|
||||||
|
App::Origin* origin = static_cast<App::Origin*>(part->getObjectsOfType(App::Origin::getClassTypeId()).front());
|
||||||
|
if(!origin)
|
||||||
|
return;
|
||||||
|
|
||||||
//get the planes and set their values
|
//get the planes and set their values
|
||||||
std::vector<App::DocumentObject*> planes = part->getObjectsOfType(App::Plane::getClassTypeId());
|
std::vector<App::DocumentObject*> planes = origin->getObjectsOfType(App::Plane::getClassTypeId());
|
||||||
for (std::vector<App::DocumentObject*>::const_iterator p = planes.begin(); p != planes.end(); p++) {
|
for (std::vector<App::DocumentObject*>::const_iterator p = planes.begin(); p != planes.end(); p++) {
|
||||||
|
|
||||||
Gui::ViewProviderPlane* vp = dynamic_cast<Gui::ViewProviderPlane*>(Gui::Application::Instance->getViewProvider(*p));
|
Gui::ViewProviderPlane* vp = dynamic_cast<Gui::ViewProviderPlane*>(Gui::Application::Instance->getViewProvider(*p));
|
||||||
|
@ -145,7 +152,7 @@ void ViewProviderPart::onObjectChanged(const App::DocumentObject& obj, const App
|
||||||
}
|
}
|
||||||
|
|
||||||
//get the lines and set their values
|
//get the lines and set their values
|
||||||
std::vector<App::DocumentObject*> lines = part->getObjectsOfType(App::Line::getClassTypeId());
|
std::vector<App::DocumentObject*> lines = origin->getObjectsOfType(App::Line::getClassTypeId());
|
||||||
for (std::vector<App::DocumentObject*>::const_iterator p = lines.begin(); p != lines.end(); p++) {
|
for (std::vector<App::DocumentObject*>::const_iterator p = lines.begin(); p != lines.end(); p++) {
|
||||||
|
|
||||||
Gui::ViewProviderLine* vp = dynamic_cast<Gui::ViewProviderLine*>(Gui::Application::Instance->getViewProvider(*p));
|
Gui::ViewProviderLine* vp = dynamic_cast<Gui::ViewProviderLine*>(Gui::Application::Instance->getViewProvider(*p));
|
||||||
|
|
|
@ -229,6 +229,17 @@ bool ViewProviderPlane::isSelectable(void) const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ViewProviderPlane::setEdit(int ModNum)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProviderPlane::unsetEdit(int ModNum)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,9 @@ public:
|
||||||
virtual std::string getElement(const SoDetail *) const;
|
virtual std::string getElement(const SoDetail *) const;
|
||||||
virtual SoDetail* getDetail(const char*) const;
|
virtual SoDetail* getDetail(const char*) const;
|
||||||
|
|
||||||
|
virtual bool setEdit(int ModNum);
|
||||||
|
virtual void unsetEdit(int ModNum);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onChanged(const App::Property* prop);
|
void onChanged(const App::Property* prop);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user