]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #79 Move Events messages to boost pointers: XGUI, PartSet
authorsbh <sergey.belash@opencascade.com>
Mon, 15 Sep 2014 08:58:18 +0000 (12:58 +0400)
committersbh <sergey.belash@opencascade.com>
Mon, 15 Sep 2014 08:58:18 +0000 (12:58 +0400)
src/PartSet/PartSet_Listener.cpp
src/PartSet/PartSet_Listener.h
src/PartSet/PartSet_Module.cpp
src/XGUI/XGUI_DocumentDataModel.cpp
src/XGUI/XGUI_DocumentDataModel.h
src/XGUI/XGUI_ObjectsBrowser.cpp
src/XGUI/XGUI_ObjectsBrowser.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index d6a1edca830b842bd27d47c46fa6fdb0578294f6..be392c0097207ca07c38d6ac1f2fa3f302bf005e 100644 (file)
@@ -38,7 +38,7 @@ PartSet_Listener::~PartSet_Listener()
 }
 
 //******************************************************
-void PartSet_Listener::processEvent(const Events_Message* theMessage)
+void PartSet_Listener::processEvent(const boost::shared_ptr<Events_Message>& theMessage)
 {
   ModuleBase_Operation* anOperation = myModule->workshop()->operationMgr()->currentOperation();
   PartSet_OperationSketchBase* aSketchOp = dynamic_cast<PartSet_OperationSketchBase*>(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<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
+    boost::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
+        boost::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
     std::set<ObjectPtr> aFeatures = aUpdMsg->objects();
     std::set<ObjectPtr>::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<const ModelAPI_ObjectDeletedMessage*>(theMessage);
+    boost::shared_ptr<ModelAPI_ObjectDeletedMessage> aDelMsg =
+        boost::dynamic_pointer_cast<ModelAPI_ObjectDeletedMessage>(theMessage);
     boost::shared_ptr<ModelAPI_Document> aDoc = aDelMsg->document();
 
     std::set<std::string> aGroups = aDelMsg->groups();
index a0ae4d7420efa1813c2ab1a1cc2754445e6d4991..272a40063a0ce08be3ea474d85783684f14549b3 100644 (file)
@@ -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<Events_Message>& theMessage);
 
  private:
   PartSet_Module* myModule;  ///< the current module
index bb42c3373eb3c905f60c97ad68c66b4d3dd02888..211bc89cc2eb2f3c32eb8095375238d6d1b78a35 100644 (file)
@@ -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<Config_PointerMessage> aMessage =
+      boost::shared_ptr<Config_PointerMessage>(new Config_PointerMessage(aModuleEvent, this));
+  aMessage->setPointer(theOperation);
   Events_Loop::loop()->send(aMessage);
 }
 
index d74163c715332aaa640744424b5ac46d05a98198..2744d196d4114b08b7ae71f7ed55397bb2b75454 100644 (file)
@@ -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<Events_Message>& 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<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
+    boost::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
+        boost::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
     std::set<ObjectPtr> aObjects = aUpdMsg->objects();
 
     std::set<ObjectPtr>::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<const ModelAPI_ObjectDeletedMessage*>(theMessage);
+    boost::shared_ptr<ModelAPI_ObjectDeletedMessage> aUpdMsg =
+        boost::dynamic_pointer_cast<ModelAPI_ObjectDeletedMessage>(theMessage);
     DocumentPtr aDoc = aUpdMsg->document();
     std::set<std::string> 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<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
+    //boost::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg = boost::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
     //ObjectPtr aFeature = aUpdMsg->feature();
     //DocumentPtr aDoc = aFeature->document();
 
index 393ce6bbe3626a9d3c02baaf572b528c35c9a661..c2436082783f1e3851053acd4f01f4c3018a15ac 100644 (file)
@@ -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<Events_Message>& theMessage);
 
   virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
   virtual QVariant headerData(int theSection, Qt::Orientation theOrient, int theRole =
index 9325c8afbc67509ffe08bfeb8502e6b91284a7e5..4242f4dbeb05e095c4ad5f4d53742777e20fb572 100644 (file)
@@ -344,7 +344,7 @@ void XGUI_ObjectsBrowser::setObjectsSelected(const QList<ObjectPtr>& theObjects)
 }
 
 //***************************************************
-void XGUI_ObjectsBrowser::processEvent(const Events_Message* theMessage) 
+void XGUI_ObjectsBrowser::processEvent(const boost::shared_ptr<Events_Message>& theMessage)
 { 
   myDocModel->processEvent(theMessage); 
 }
index 0760242bd99033635f2fef12a25fb6aea9f8ee10..ebcaffe08ef30deee9dfd8b56a8cf1e295f5d7a3 100644 (file)
@@ -94,7 +94,7 @@ Q_OBJECT
 
   void rebuildDataTree();
 
-  void processEvent(const Events_Message* theMessage);
+  void processEvent(const boost::shared_ptr<Events_Message>& theMessage);
 
 signals:
   //! Emited when selection is changed
index bc7625b9af6418a76cb8d9114745d22382cf6c8c..a3fac8efc54a4c71c8aefc520bfe60b3d418b259 100644 (file)
@@ -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<Events_Message>& 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<const Config_FeatureMessage*>(theMessage);
+    boost::shared_ptr<Config_FeatureMessage> aFeatureMsg =
+       boost::dynamic_pointer_cast<Config_FeatureMessage>(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<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
+    boost::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
+        boost::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(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<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
+    boost::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
+        boost::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(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<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
+    boost::shared_ptr<ModelAPI_ObjectUpdatedMessage> anUpdateMsg =
+        boost::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
     onFeatureUpdatedMsg(anUpdateMsg);
   }
 
   else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
-    const ModelAPI_ObjectDeletedMessage* aDelMsg =
-        dynamic_cast<const ModelAPI_ObjectDeletedMessage*>(theMessage);
+    boost::shared_ptr<ModelAPI_ObjectDeletedMessage> aDelMsg =
+        boost::dynamic_pointer_cast<ModelAPI_ObjectDeletedMessage>(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<const Config_PointerMessage*>(theMessage);
+    boost::shared_ptr<Config_PointerMessage> aPartSetMsg =
+        boost::dynamic_pointer_cast<Config_PointerMessage>(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<const Events_Error*>(theMessage);
+    boost::shared_ptr<Events_Error> anAppError = boost::dynamic_pointer_cast<Events_Error>(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<ModelAPI_ObjectUpdatedMessage>& theMsg)
 {
   std::set<ObjectPtr> 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<ModelAPI_ObjectUpdatedMessage>& theMsg)
 {
   std::set<ObjectPtr> aObjects = theMsg->objects();
   std::set<ObjectPtr>::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<ModelAPI_ObjectUpdatedMessage>& theMsg)
 {
   std::set<ObjectPtr> 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<ModelAPI_ObjectDeletedMessage>& 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<Config_FeatureMessage>& theMessage)
 {
   if (!theMessage) {
 #ifdef _DEBUG
index b4073224ab167a7a2065ba679b787fa32319c23c..c2ca4a75c7ec2b240a6c1dfb28bd8cb4109f9a78 100644 (file)
@@ -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<Events_Message>& 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<Config_FeatureMessage>&);
   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<ModelAPI_ObjectUpdatedMessage>& theMsg);
+  void onFeatureCreatedMsg(const boost::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
+  void onFeatureRedisplayMsg(const boost::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
+  void onObjectDeletedMsg(const boost::shared_ptr<ModelAPI_ObjectDeletedMessage>& theMsg);
 
   void validateOperation(const QString& theOperationId);