Gui: forbid to delete OriginFeatures

This commit is contained in:
Alexander Golubev 2015-09-09 06:15:43 +03:00 committed by Stefan Tröger
parent bceec93a92
commit 5918f6f264
3 changed files with 20 additions and 4 deletions

View File

@ -45,6 +45,7 @@
#include <App/DocumentObjectGroup.h> #include <App/DocumentObjectGroup.h>
#include <App/DocumentObject.h> #include <App/DocumentObject.h>
#include <App/GeoFeature.h> #include <App/GeoFeature.h>
#include <App/Origin.h>
#include "Action.h" #include "Action.h"
#include "Application.h" #include "Application.h"
@ -1077,9 +1078,11 @@ void StdCmdDelete::activated(int iMsg)
for (std::vector<App::DocumentObject*>::iterator lt = links.begin(); lt != links.end(); ++lt) { for (std::vector<App::DocumentObject*>::iterator lt = links.begin(); lt != links.end(); ++lt) {
if ( if (
(!(*lt)->getTypeId().isDerivedFrom(App::DocumentObjectGroup::getClassTypeId())) && (!(*lt)->getTypeId().isDerivedFrom(App::DocumentObjectGroup::getClassTypeId())) &&
(!(*lt)->getTypeId().isDerivedFrom(App::Origin::getClassTypeId())) &&
(!rSel.isSelected(*lt)) && (!rSel.isSelected(*lt)) &&
(!(*lt)->getTypeId().isDerivedFrom(Base::Type::fromName("Part::BodyBase"))) (!(*lt)->getTypeId().isDerivedFrom(Base::Type::fromName("Part::BodyBase")))
){ ){
// TODO Do something with this hack of Part::BodyBase (2015-09-09, Fat-Zer)
autoDeletion = false; autoDeletion = false;
affectedLabels.insert(QString::fromUtf8((*lt)->Label.getValue())); affectedLabels.insert(QString::fromUtf8((*lt)->Label.getValue()));
} }

View File

@ -38,6 +38,7 @@
#endif #endif
#include <App/Document.h> #include <App/Document.h>
#include <App/OriginFeature.h>
#include "SoFCSelection.h" #include "SoFCSelection.h"
#include "Window.h" #include "Window.h"
@ -176,3 +177,14 @@ void ViewProviderOriginFeature::setDisplayMode (const char* ModeName)
setDisplayMaskMode("Base"); setDisplayMaskMode("Base");
ViewProviderGeometryObject::setDisplayMode(ModeName); ViewProviderGeometryObject::setDisplayMode(ModeName);
} }
bool ViewProviderOriginFeature::onDelete(const std::vector<std::string> &) {
App::OriginFeature *feat = static_cast <App::OriginFeature *> ( getObject() );
// Forbid deletion if there is an origin thes feature belongs to
if ( feat->getOrigin () ) {
return false;
} else {
return true;
}
}

View File

@ -65,6 +65,7 @@ public:
protected: protected:
virtual void onChanged ( const App::Property* prop ); virtual void onChanged ( const App::Property* prop );
virtual bool onDelete ( const std::vector<std::string> & );
protected: protected:
SoSeparator * pOriginFeatureRoot; SoSeparator * pOriginFeatureRoot;
SoScale * pScale; SoScale * pScale;