From: mpv Date: Fri, 19 Sep 2014 13:28:38 +0000 (+0400) Subject: Single delete is active now X-Git-Tag: V_0.4.4~41^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f54f110afd9cf0f574384bedaeae8b51654b18a9;p=modules%2Fshaper.git Single delete is active now --- diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index fdf230c58..256ba9d5e 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -167,3 +167,17 @@ AISObjectPtr SketchPlugin_Sketch::getAISObject(AISObjectPtr thePrevious) } return AISObjectPtr(); } + +void SketchPlugin_Sketch::erase() +{ + boost::shared_ptr aRefList = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefList>(data()->attribute(SketchPlugin_Sketch::FEATURES_ID())); + std::list aFeatures = aRefList->list(); + std::list::const_iterator anIt = aFeatures.begin(); + for (; anIt != aFeatures.end(); anIt++) { + FeaturePtr aFeature = boost::dynamic_pointer_cast(*anIt); + if (aFeature) + document()->removeFeature(aFeature); + } + SketchPlugin_Feature::erase(); +} diff --git a/src/SketchPlugin/SketchPlugin_Sketch.h b/src/SketchPlugin/SketchPlugin_Sketch.h index 806025dd7..07f8ae269 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.h +++ b/src/SketchPlugin/SketchPlugin_Sketch.h @@ -115,6 +115,9 @@ class SketchPlugin_Sketch : public SketchPlugin_Feature, public GeomAPI_IPresent virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious); + /// removes also all sub-sketch elements + SKETCHPLUGIN_EXPORT virtual void erase(); + protected: /// Creates a plane and append it to the list /// \param theX the X normal value diff --git a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp index 81a812ca5..bd70204c7 100644 --- a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp @@ -817,7 +817,7 @@ bool SketchSolver_ConstraintGroup::updateGroup() std::set >::iterator aCIter = anExtraCopy.begin(); for (; aCIter != anExtraCopy.end(); aCIter++) - if ((*aCIter)->data()->isValid()) + if ((*aCIter)->data() && (*aCIter)->data()->isValid()) changeConstraint(*aCIter); } diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index ec698bc52..5f69add11 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -108,18 +108,30 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const if (aSelected > 0) { SessionPtr aMgr = ModelAPI_Session::get(); XGUI_Displayer* aDisplayer = myWorkshop->displayer(); + bool hasResult = false; + bool hasFeature = false; + foreach(ObjectPtr aObj, aObjects) + { + FeaturePtr aFeature = boost::dynamic_pointer_cast(aObj); + ResultPtr aResult = boost::dynamic_pointer_cast(aObj); + if (aResult) + hasResult = true; + if (aFeature) + hasFeature = true; + if (hasFeature && hasResult) + break; + } //Process Feature if (aSelected == 1) { ObjectPtr aObject = aObjects.first(); if (aObject) { ResultPartPtr aPart = boost::dynamic_pointer_cast(aObject); - FeaturePtr aFeature = boost::dynamic_pointer_cast(aObject); if (aPart) { if (aMgr->activeDocument() == aPart->partDoc()) aMenu->addAction(action("DEACTIVATE_PART_CMD")); else aMenu->addAction(action("ACTIVATE_PART_CMD")); - } else if (aFeature) { + } else if (hasFeature) { aMenu->addAction(action("EDIT_CMD")); } else { if (aDisplayer->isVisible(aObject)) @@ -133,28 +145,15 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const if (aMgr->activeDocument() != aMgr->moduleDocument()) aMenu->addAction(action("ACTIVATE_PART_CMD")); } - } else if (aSelected >= 1) { - bool hasResult = false; - bool hasFeature = false; - foreach(ObjectPtr aObj, aObjects) - { - FeaturePtr aFeature = boost::dynamic_pointer_cast(aObj); - ResultPtr aResult = boost::dynamic_pointer_cast(aObj); - if (aResult) - hasResult = true; - if (aFeature) - hasFeature = true; - if (hasFeature && hasResult) - break; - } + } else { if (hasResult) { aMenu->addAction(action("SHOW_CMD")); aMenu->addAction(action("HIDE_CMD")); aMenu->addAction(action("SHOW_ONLY_CMD")); } - if (hasFeature) - aMenu->addAction(action("DELETE_CMD")); } + if (hasFeature) + aMenu->addAction(action("DELETE_CMD")); } aMenu->addActions(myWorkshop->objectBrowser()->actions()); if (aMenu->actions().size() > 0) {