From 49bc86ba27fe72fcd8cb8d003340db37497c8b00 Mon Sep 17 00:00:00 2001 From: sbh Date: Mon, 15 Sep 2014 12:58:18 +0400 Subject: [PATCH] Issue #79 Move Events messages to boost pointers: XGUI, PartSet --- src/PartSet/PartSet_Listener.cpp | 10 ++++---- src/PartSet/PartSet_Listener.h | 2 +- src/PartSet/PartSet_Module.cpp | 5 ++-- src/XGUI/XGUI_DocumentDataModel.cpp | 12 ++++----- src/XGUI/XGUI_DocumentDataModel.h | 2 +- src/XGUI/XGUI_ObjectsBrowser.cpp | 2 +- src/XGUI/XGUI_ObjectsBrowser.h | 2 +- src/XGUI/XGUI_Workshop.cpp | 38 ++++++++++++++--------------- src/XGUI/XGUI_Workshop.h | 12 ++++----- 9 files changed, 43 insertions(+), 42 deletions(-) diff --git a/src/PartSet/PartSet_Listener.cpp b/src/PartSet/PartSet_Listener.cpp index d6a1edca8..be392c009 100644 --- a/src/PartSet/PartSet_Listener.cpp +++ b/src/PartSet/PartSet_Listener.cpp @@ -38,7 +38,7 @@ PartSet_Listener::~PartSet_Listener() } //****************************************************** -void PartSet_Listener::processEvent(const Events_Message* theMessage) +void PartSet_Listener::processEvent(const boost::shared_ptr& theMessage) { ModuleBase_Operation* anOperation = myModule->workshop()->operationMgr()->currentOperation(); PartSet_OperationSketchBase* aSketchOp = dynamic_cast(anOperation); @@ -48,8 +48,8 @@ void PartSet_Listener::processEvent(const Events_Message* theMessage) XGUI_Displayer* aDisplayer = myModule->workshop()->displayer(); QString aType = QString(theMessage->eventID().eventText()); if (aType == EVENT_OBJECT_CREATED) { - const ModelAPI_ObjectUpdatedMessage* aUpdMsg = - dynamic_cast(theMessage); + boost::shared_ptr aUpdMsg = + boost::dynamic_pointer_cast(theMessage); std::set aFeatures = aUpdMsg->objects(); std::set::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end(); for (; anIt != aLast; anIt++) { @@ -60,8 +60,8 @@ void PartSet_Listener::processEvent(const Events_Message* theMessage) } } else if (aType == EVENT_OBJECT_DELETED) { - const ModelAPI_ObjectDeletedMessage* aDelMsg = - dynamic_cast(theMessage); + boost::shared_ptr aDelMsg = + boost::dynamic_pointer_cast(theMessage); boost::shared_ptr aDoc = aDelMsg->document(); std::set aGroups = aDelMsg->groups(); diff --git a/src/PartSet/PartSet_Listener.h b/src/PartSet/PartSet_Listener.h index a0ae4d742..272a40063 100644 --- a/src/PartSet/PartSet_Listener.h +++ b/src/PartSet/PartSet_Listener.h @@ -26,7 +26,7 @@ class PARTSET_EXPORT PartSet_Listener : public Events_Listener virtual ~PartSet_Listener(); /// This method is called by loop when the event is started to process. - virtual void processEvent(const Events_Message* theMessage); + virtual void processEvent(const boost::shared_ptr& theMessage); private: PartSet_Module* myModule; ///< the current module diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index bb42c3373..211bc89cc 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -480,8 +480,9 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI void PartSet_Module::sendOperation(ModuleBase_Operation* theOperation) { static Events_ID aModuleEvent = Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED); - Config_PointerMessage aMessage(aModuleEvent, this); - aMessage.setPointer(theOperation); + boost::shared_ptr aMessage = + boost::shared_ptr(new Config_PointerMessage(aModuleEvent, this)); + aMessage->setPointer(theOperation); Events_Loop::loop()->send(aMessage); } diff --git a/src/XGUI/XGUI_DocumentDataModel.cpp b/src/XGUI/XGUI_DocumentDataModel.cpp index d74163c71..2744d196d 100644 --- a/src/XGUI/XGUI_DocumentDataModel.cpp +++ b/src/XGUI/XGUI_DocumentDataModel.cpp @@ -44,14 +44,14 @@ XGUI_DocumentDataModel::~XGUI_DocumentDataModel() clearModelIndexes(); } -void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) +void XGUI_DocumentDataModel::processEvent(const boost::shared_ptr& theMessage) { DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); // Created object event ******************* if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) { - const ModelAPI_ObjectUpdatedMessage* aUpdMsg = - dynamic_cast(theMessage); + boost::shared_ptr aUpdMsg = + boost::dynamic_pointer_cast(theMessage); std::set aObjects = aUpdMsg->objects(); std::set::const_iterator aIt; @@ -97,8 +97,8 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) } // Deleted object event *********************** } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) { - const ModelAPI_ObjectDeletedMessage* aUpdMsg = - dynamic_cast(theMessage); + boost::shared_ptr aUpdMsg = + boost::dynamic_pointer_cast(theMessage); DocumentPtr aDoc = aUpdMsg->document(); std::set aGroups = aUpdMsg->groups(); @@ -140,7 +140,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) } // Deleted object event *********************** } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) { - //const ModelAPI_ObjectUpdatedMessage* aUpdMsg = dynamic_cast(theMessage); + //boost::shared_ptr aUpdMsg = boost::dynamic_pointer_cast(theMessage); //ObjectPtr aFeature = aUpdMsg->feature(); //DocumentPtr aDoc = aFeature->document(); diff --git a/src/XGUI/XGUI_DocumentDataModel.h b/src/XGUI/XGUI_DocumentDataModel.h index 393ce6bbe..c24360827 100644 --- a/src/XGUI/XGUI_DocumentDataModel.h +++ b/src/XGUI/XGUI_DocumentDataModel.h @@ -28,7 +28,7 @@ Q_OBJECT virtual ~XGUI_DocumentDataModel(); // Event Listener method - virtual void processEvent(const Events_Message* theMessage); + virtual void processEvent(const boost::shared_ptr& theMessage); virtual QVariant data(const QModelIndex& theIndex, int theRole) const; virtual QVariant headerData(int theSection, Qt::Orientation theOrient, int theRole = diff --git a/src/XGUI/XGUI_ObjectsBrowser.cpp b/src/XGUI/XGUI_ObjectsBrowser.cpp index 9325c8afb..4242f4dbe 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.cpp +++ b/src/XGUI/XGUI_ObjectsBrowser.cpp @@ -344,7 +344,7 @@ void XGUI_ObjectsBrowser::setObjectsSelected(const QList& theObjects) } //*************************************************** -void XGUI_ObjectsBrowser::processEvent(const Events_Message* theMessage) +void XGUI_ObjectsBrowser::processEvent(const boost::shared_ptr& theMessage) { myDocModel->processEvent(theMessage); } diff --git a/src/XGUI/XGUI_ObjectsBrowser.h b/src/XGUI/XGUI_ObjectsBrowser.h index 0760242bd..ebcaffe08 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.h +++ b/src/XGUI/XGUI_ObjectsBrowser.h @@ -94,7 +94,7 @@ Q_OBJECT void rebuildDataTree(); - void processEvent(const Events_Message* theMessage); + void processEvent(const boost::shared_ptr& theMessage); signals: //! Emited when selection is changed diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index bc7625b9a..a3fac8efc 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -233,7 +233,7 @@ XGUI_Workbench* XGUI_Workshop::addWorkbench(const QString& theName) } //****************************************************** -void XGUI_Workshop::processEvent(const Events_Message* theMessage) +void XGUI_Workshop::processEvent(const boost::shared_ptr& theMessage) { if (QApplication::instance()->thread() != QThread::currentThread()) { #ifdef _DEBUG @@ -247,8 +247,8 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage) //A message to start feature creation received. if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_LOADED)) { - const Config_FeatureMessage* aFeatureMsg = - dynamic_cast(theMessage); + boost::shared_ptr aFeatureMsg = + boost::dynamic_pointer_cast(theMessage); if (!aFeatureMsg->isInternal()) { addFeature(aFeatureMsg); } @@ -256,8 +256,8 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage) // Process creation of Part else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) { - const ModelAPI_ObjectUpdatedMessage* aUpdMsg = - dynamic_cast(theMessage); + boost::shared_ptr aUpdMsg = + boost::dynamic_pointer_cast(theMessage); onFeatureCreatedMsg(aUpdMsg); if (myUpdatePrefs) { if (mySalomeConnector) @@ -271,22 +271,22 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage) // Redisplay feature else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) { - const ModelAPI_ObjectUpdatedMessage* aUpdMsg = - dynamic_cast(theMessage); + boost::shared_ptr aUpdMsg = + boost::dynamic_pointer_cast(theMessage); onFeatureRedisplayMsg(aUpdMsg); } //Update property panel on corresponding message. If there is no current operation (no //property panel), or received message has different feature to the current - do nothing. else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) { - const ModelAPI_ObjectUpdatedMessage* anUpdateMsg = - dynamic_cast(theMessage); + boost::shared_ptr anUpdateMsg = + boost::dynamic_pointer_cast(theMessage); onFeatureUpdatedMsg(anUpdateMsg); } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) { - const ModelAPI_ObjectDeletedMessage* aDelMsg = - dynamic_cast(theMessage); + boost::shared_ptr aDelMsg = + boost::dynamic_pointer_cast(theMessage); onObjectDeletedMsg(aDelMsg); } @@ -299,8 +299,8 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage) //An operation passed by message. Start it, process and commit. else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OPERATION_LAUNCHED)) { - const Config_PointerMessage* aPartSetMsg = - dynamic_cast(theMessage); + boost::shared_ptr aPartSetMsg = + boost::dynamic_pointer_cast(theMessage); //myPropertyPanel->cleanContent(); ModuleBase_Operation* anOperation = (ModuleBase_Operation*) aPartSetMsg->pointer(); @@ -336,7 +336,7 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage) } else { //Show error dialog if error message received. - const Events_Error* anAppError = dynamic_cast(theMessage); + boost::shared_ptr anAppError = boost::dynamic_pointer_cast(theMessage); if (anAppError) { emit errorOccurred(QString::fromLatin1(anAppError->description())); } @@ -358,7 +358,7 @@ void XGUI_Workshop::onStartWaiting() } //****************************************************** -void XGUI_Workshop::onFeatureUpdatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg) +void XGUI_Workshop::onFeatureUpdatedMsg(const boost::shared_ptr& theMsg) { std::set aFeatures = theMsg->objects(); if (myOperationMgr->hasOperation()) { @@ -378,7 +378,7 @@ void XGUI_Workshop::onFeatureUpdatedMsg(const ModelAPI_ObjectUpdatedMessage* the } //****************************************************** -void XGUI_Workshop::onFeatureRedisplayMsg(const ModelAPI_ObjectUpdatedMessage* theMsg) +void XGUI_Workshop::onFeatureRedisplayMsg(const boost::shared_ptr& theMsg) { std::set aObjects = theMsg->objects(); std::set::const_iterator aIt; @@ -403,7 +403,7 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const ModelAPI_ObjectUpdatedMessage* t } //****************************************************** -void XGUI_Workshop::onFeatureCreatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg) +void XGUI_Workshop::onFeatureCreatedMsg(const boost::shared_ptr& theMsg) { std::set aObjects = theMsg->objects(); @@ -434,7 +434,7 @@ void XGUI_Workshop::onFeatureCreatedMsg(const ModelAPI_ObjectUpdatedMessage* the } //****************************************************** -void XGUI_Workshop::onObjectDeletedMsg(const ModelAPI_ObjectDeletedMessage* theMsg) +void XGUI_Workshop::onObjectDeletedMsg(const boost::shared_ptr& theMsg) { if (myObjectBrowser) myObjectBrowser->processEvent(theMsg); @@ -517,7 +517,7 @@ bool XGUI_Workshop::event(QEvent * theEvent) /* * */ -void XGUI_Workshop::addFeature(const Config_FeatureMessage* theMessage) +void XGUI_Workshop::addFeature(const boost::shared_ptr& theMessage) { if (!theMessage) { #ifdef _DEBUG diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index b4073224a..c2ca4a75c 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -104,7 +104,7 @@ Q_OBJECT XGUI_Workbench* addWorkbench(const QString& theName); //! Redefinition of Events_Listener method - virtual void processEvent(const Events_Message* theMessage); + virtual void processEvent(const boost::shared_ptr& theMessage); //! Returns an object which provides interface to Salome Module (LightApp_Module) XGUI_SalomeConnector* salomeConnector() const @@ -213,13 +213,13 @@ signals: protected: bool event(QEvent * theEvent); //Event-loop processing methods: - void addFeature(const Config_FeatureMessage*); + void addFeature(const boost::shared_ptr&); void connectWithOperation(ModuleBase_Operation* theOperation); - void onFeatureUpdatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg); - void onFeatureCreatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg); - void onFeatureRedisplayMsg(const ModelAPI_ObjectUpdatedMessage* theMsg); - void onObjectDeletedMsg(const ModelAPI_ObjectDeletedMessage* theMsg); + void onFeatureUpdatedMsg(const boost::shared_ptr& theMsg); + void onFeatureCreatedMsg(const boost::shared_ptr& theMsg); + void onFeatureRedisplayMsg(const boost::shared_ptr& theMsg); + void onObjectDeletedMsg(const boost::shared_ptr& theMsg); void validateOperation(const QString& theOperationId); -- 2.30.2