#include <ModelAPI_Events.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_ResultParameter.h>
-#include <ModelAPI_ResultConstruction.h>
#include <QMainWindow>
#include <QAction>
theStdActions["SHOW_CMD"]->setEnabled(false);
theStdActions["HIDE_CMD"]->setEnabled(false);
theStdActions["HIDEALL_CMD"]->setEnabled(false);
-
- ModuleBase_ISelection* aSelection = myModule->workshop()->selection();
- QList<ModuleBase_ViewerPrsPtr> aPrsList = aSelection->getSelected(ModuleBase_ISelection::Viewer);
- ResultConstructionPtr aResult;
- bool canBeDeleted = true;
- foreach(ModuleBase_ViewerPrsPtr aPrs, aPrsList) {
- aResult = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aPrs->object());
- if (aResult.get() != NULL) {
- FeaturePtr aFeature = ModelAPI_Feature::feature(aPrs->object());
- canBeDeleted = !(!(aFeature->isInHistory()) && aResult->isInfinite());
- if (!canBeDeleted)
- break;
- }
- }
- theStdActions["DELETE_CMD"]->setEnabled(canBeDeleted);
}
}
bool hasCompositeOwner = false;
bool hasResultInHistory = false;
bool hasFolder = false;
- bool canBeDeleted = true;
ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter,
hasCompositeOwner, hasResultInHistory, hasFolder);
//Process Feature
if( aMgr->activeDocument() == aObject->document() )
{
action("RENAME_CMD")->setEnabled(true);
- if (aObject->groupName() == ModelAPI_ResultConstruction::group()) {
- ResultConstructionPtr aConstr = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aObject);
- FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
- canBeDeleted = !(!(aFeature->isInHistory()) && aConstr->isInfinite());
- action("DELETE_CMD")->setEnabled(canBeDeleted);
- }
- else
- action("DELETE_CMD")->setEnabled(!hasCompositeOwner);
+ action("DELETE_CMD")->setEnabled(!hasCompositeOwner);
action("CLEAN_HISTORY_CMD")->setEnabled(!hasCompositeOwner &&
(hasFeature || hasParameter));
}
action("SHOW_ONLY_CMD")->setEnabled(true);
action("SHADING_CMD")->setEnabled(true);
action("WIREFRAME_CMD")->setEnabled(true);
-
- foreach(ObjectPtr aObj, aObjects) {
- FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
- if (!aFeature->isInHistory()) {
- canBeDeleted = false;
- break;
- }
- }
- action("DELETE_CMD")->setEnabled(canBeDeleted);
}
if (hasFeature && myWorkshop->canMoveFeature())
action("MOVE_CMD")->setEnabled(true);
break;
}
if (!hasCompositeOwner && allActive ) {
- if (hasResult || hasFeature || hasParameter) // #2924 results can be erased
- action("DELETE_CMD")->setEnabled(canBeDeleted);
+ if (hasResult || hasFeature || hasParameter) // #2924 results can be erased
+ action("DELETE_CMD")->setEnabled(true);
}
if (!hasCompositeOwner && allActive && (hasFeature|| hasParameter))
action("CLEAN_HISTORY_CMD")->setEnabled(true);
}
}
+ ModuleBase_IModule* aModule = myWorkshop->module();
+ if (aModule)
+ aModule->updateViewerMenu(myActions);
+
if (myWorkshop->canChangeProperty("COLOR_CMD"))
action("COLOR_CMD")->setEnabled(true);
if (myWorkshop->canChangeProperty("TRANSPARENCY_CMD"))
action("TRANSPARENCY_CMD")->setEnabled(true);
- ModuleBase_IModule* aModule = myWorkshop->module();
- if (aModule)
- aModule->updateViewerMenu(myActions);
+ action("DELETE_CMD")->setEnabled(true);
}
void XGUI_ContextMenuMgr::connectObjectBrowser()
if (!(hasResult || hasFeature || hasParameter || hasFolder))
return;
+ // Remove from the list non-deletable objects: infinite constuctions which are not in history
+ bool notDelete = true;
+ QObjectPtrList::iterator aIt;
+ for (aIt = anObjects.begin(); aIt != anObjects.end(); aIt++) {
+ ObjectPtr aObj = (*aIt);
+ ResultConstructionPtr aConstr = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aObj);
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
+ notDelete = (!aFeature->isInHistory()) && aConstr->isInfinite();
+ if (notDelete) {
+ anObjects.removeAll(aObj);
+ aIt--;
+ }
+ }
// delete objects
std::map<FeaturePtr, std::set<FeaturePtr> > aReferences;
std::set<FeaturePtr> aFeatures;