From d34bc15bf8fafedd9188f47ff5962b5a1661d5b0 Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 15 Jul 2014 17:59:20 +0400 Subject: [PATCH] Adaptation to new data structure --- src/XGUI/XGUI_ContextMenuMgr.cpp | 6 +++++- src/XGUI/XGUI_Workshop.cpp | 30 +++++++++++++++++++++++++----- src/XGUI/XGUI_Workshop.h | 2 ++ 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index d7dcfce78..21fc9672b 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -123,9 +123,13 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const aMenu->addAction(action("HIDE_CMD")); else aMenu->addAction(action("SHOW_CMD")); + } else { + FeaturePtr aResult = boost::dynamic_pointer_cast(aObject); + if (aResult) { + aMenu->addAction(action("DELETE_CMD")); + } } } - aMenu->addAction(action("DELETE_CMD")); aMenu->addSeparator(); // Process Root object (document) diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 436803e09..a94804532 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -133,6 +133,7 @@ void XGUI_Workshop::startApplication() aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED)); activateModule(); if (myMainWindow) { @@ -233,12 +234,14 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage) if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) { const Model_ObjectUpdatedMessage* aUpdMsg = dynamic_cast(theMessage); onFeatureCreatedMsg(aUpdMsg); + return; } // Redisplay feature if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) { const Model_ObjectUpdatedMessage* aUpdMsg = dynamic_cast(theMessage); onFeatureRedisplayMsg(aUpdMsg); + return; } //Update property panel on corresponding message. If there is no current operation (no @@ -247,6 +250,14 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage) const Model_ObjectUpdatedMessage* anUpdateMsg = dynamic_cast(theMessage); onFeatureUpdatedMsg(anUpdateMsg); + return; + } + + if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) { + const Model_ObjectDeletedMessage* aDelMsg = + dynamic_cast(theMessage); + onObjectDeletedMsg(aDelMsg); + return; } //An operation passed by message. Start it, process and commit. @@ -296,7 +307,8 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const Model_ObjectUpdatedMessage* theM std::set::const_iterator aIt; bool isDisplayed = false; for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) { - ResultPtr aRes = boost::dynamic_pointer_cast(*aIt); + ObjectPtr aObj = (*aIt); + ResultPtr aRes = boost::dynamic_pointer_cast(aObj); if (aRes) { isDisplayed = myDisplayer->redisplay(aRes, false); } @@ -332,6 +344,12 @@ void XGUI_Workshop::onFeatureCreatedMsg(const Model_ObjectUpdatedMessage* theMsg QTimer::singleShot(50, this, SLOT(activateLastPart())); } } + +//****************************************************** +void XGUI_Workshop::onObjectDeletedMsg(const Model_ObjectDeletedMessage* theMsg) +{ + //std::set aFeatures = theMsg->objects(); +} //****************************************************** void XGUI_Workshop::onOperationStarted() @@ -917,7 +935,7 @@ void XGUI_Workshop::deleteObjects(const QList& theList) tr("Seleted features will be deleted. Continue?"), QMessageBox::No | QMessageBox::Yes, QMessageBox::No); // ToDo: definbe deleting method - /* if (aRes == QMessageBox::Yes) { + if (aRes == QMessageBox::Yes) { PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); aMgr->rootDocument()->startOperation(); foreach (ObjectPtr aObj, theList) { @@ -927,14 +945,16 @@ void XGUI_Workshop::deleteObjects(const QList& theList) if (aDoc == aMgr->currentDocument()) { aDoc->close(); } - aMgr->rootDocument()->removeFeature(aPart->owner()); + //aMgr->rootDocument()->removeFeature(aPart->owner()); } else { - aObj->document()->removeFeature(aObj); + FeaturePtr aFeature = boost::dynamic_pointer_cast(aObj); + if (aFeature) + aObj->document()->removeFeature(aFeature); } } myDisplayer->updateViewer(); aMgr->rootDocument()->finishOperation(); - }*/ + } } //************************************************************** diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 1b85fbc0c..681afb312 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -39,6 +39,7 @@ class QWidget; class QDockWidget; class Model_ObjectUpdatedMessage; +class Model_ObjectDeletedMessage; class QAction; /**\class XGUI_Workshop @@ -156,6 +157,7 @@ protected: void onFeatureUpdatedMsg(const Model_ObjectUpdatedMessage* theMsg); void onFeatureCreatedMsg(const Model_ObjectUpdatedMessage* theMsg); void onFeatureRedisplayMsg(const Model_ObjectUpdatedMessage* theMsg); + void onObjectDeletedMsg(const Model_ObjectDeletedMessage* theMsg); QList getModuleCommands() const; -- 2.39.2