From: nds Date: Fri, 16 May 2014 05:26:54 +0000 (+0400) Subject: refs #30 - Sketch base GUI: create, draw lines X-Git-Tag: V_0.2~58 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=687ea8b22e81218c017cfbe3322b832654a9e7eb;p=modules%2Fshaper.git refs #30 - Sketch base GUI: create, draw lines Displayer method to remove deleted features from the displayer map. onUndo() - perform abortOperation if the document method isOperation() returns true. --- diff --git a/src/PartSet/PartSet_Listener.cpp b/src/PartSet/PartSet_Listener.cpp index 9615dac4c..0deb7fb74 100644 --- a/src/PartSet/PartSet_Listener.cpp +++ b/src/PartSet/PartSet_Listener.cpp @@ -50,6 +50,7 @@ void PartSet_Listener::processEvent(const Events_Message* theMessage) std::string aGroup = aDelMsg->group(); if (aDelMsg->group().compare("Sketch") == 0) { // Update only Sketch group + //myModule->workshop()->displayer()->EraseDeletedFeatures(); myModule->updateCurrentPreview(aGroup); } } diff --git a/src/SketchPlugin/SketchPlugin_Line.cpp b/src/SketchPlugin/SketchPlugin_Line.cpp index ee3f8c861..734666d89 100644 --- a/src/SketchPlugin/SketchPlugin_Line.cpp +++ b/src/SketchPlugin/SketchPlugin_Line.cpp @@ -17,7 +17,6 @@ const double PLANE_SIZE = 200; SketchPlugin_Line::SketchPlugin_Line() : SketchPlugin_Feature() { - setSketch(0); } void SketchPlugin_Line::initAttributes() diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 2613adae6..a01a31129 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -161,6 +161,34 @@ void XGUI_Displayer::EraseAll(const bool isUpdateViewer) ic->UpdateCurrentViewer(); } +void XGUI_Displayer::EraseDeletedFeatures(const bool isUpdateViewer) +{ + Handle(AIS_InteractiveContext) aContext = AISContext(); + + FeatureToAISMap::const_iterator aFIt = myFeature2AISObjectMap.begin(), + aFLast = myFeature2AISObjectMap.end(); + std::list> aRemoved; + for (; aFIt != aFLast; aFIt++) + { + boost::shared_ptr aFeature = (*aFIt).first; + if (!aFeature) { + Handle(AIS_InteractiveObject) anAIS = (*aFIt).second; + if (!anAIS.IsNull()) { + aContext->Erase(anAIS, false); + aRemoved.push_back(aFeature); + } + } + } + std::list>::const_iterator anIt = aRemoved.begin(), + aLast = aRemoved.end(); + for (; anIt != aLast; anIt++) { + myFeature2AISObjectMap.erase(myFeature2AISObjectMap.find(*anIt)); + } + + if (isUpdateViewer) + aContext->UpdateCurrentViewer(); +} + void XGUI_Displayer::CloseLocalContexts(const bool isUpdateViewer) { closeAllContexts(true); diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index a8bfbe2f3..c03157885 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -85,6 +85,10 @@ public: /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly void EraseAll(const bool isUpdateViewer = true); + /// Erase AIS interactive objects, which has an empty feature in the internal map + /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly + void EraseDeletedFeatures(const bool isUpdateViewer = true); + /// Deactivates selection of sub-shapes /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly void CloseLocalContexts(const bool isUpdateViewer = true); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 20f4e47c7..9b391a44e 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -473,9 +473,8 @@ void XGUI_Workshop::onUndo() objectBrowser()->setCurrentIndex(QModelIndex()); boost::shared_ptr aMgr = ModelAPI_PluginManager::get(); boost::shared_ptr aDoc = aMgr->rootDocument(); - //if (!operationMgr()->abortOperation()) - // return; - operationMgr()->abortOperation(); + if (aDoc->isOperation()) + operationMgr()->abortOperation(); aDoc->undo(); updateCommandStatus(); }