]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
OPERATION_LAUNCHED event created.
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 3 Jul 2014 11:56:55 +0000 (15:56 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 3 Jul 2014 11:56:55 +0000 (15:56 +0400)
src/ModelAPI/ModelAPI_Events.h
src/ModuleBase/ModuleBase_WidgetPoint2dDistance.cpp
src/PartSet/PartSet_Module.cpp
src/XGUI/XGUI_Workshop.cpp

index c65d717e85a228dd77809b896d139679bf3205d4..215c34c7148ea83f36a3fcb32c596746819b1e66 100644 (file)
@@ -25,6 +25,8 @@ static const char * EVENT_FEATURE_DELETED = "FeatureDeleted";
 static const char * EVENT_FEATURE_MOVED = "FeaturesMoved";
 /// Event ID that visualization must be redisplayed (comes with ModelAPI_FeatureUpdatedMessage)
 static const char * EVENT_FEATURE_TO_REDISPLAY = "FeaturesToRedisplay";
+/// Event ID that visualization must be redisplayed (comes with ModelAPI_FeatureUpdatedMessage)
+static const char * EVENT_OPERATION_LAUNCHED = "OperationLaunched";
 
 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
 class ModelAPI_FeatureUpdatedMessage : public Events_MessageGroup {
index 92a616504c22183c9ab457d84f1f1bdfad7eefdd..303d4508e07d04c6cf45b8cf8872ac837204c9ad 100644 (file)
@@ -48,6 +48,8 @@ void ModuleBase_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature, const boo
   boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
                                                               (aData->attribute(myFirstPntName));
+  if (!aPoint) return;
+
   double aRadius = thePnt->distance(aPoint->pnt());
   AttributeDoublePtr aReal = aData->real(attributeID());
   if (aReal && (aReal->value() != aRadius)) {
index dd788f540c534fa49f221028d8ba6b2bf3382ff1..b12db997bcf4473aa1b46a556b8cfb48fe66d3fe 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <ModuleBase_Operation.h>
 #include <ModelAPI_Object.h>
+#include <ModelAPI_Events.h>
 
 #include <ModelAPI_Data.h>
 #include <GeomDataAPI_Point2D.h>
@@ -411,8 +412,7 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI
 
 void PartSet_Module::sendOperation(ModuleBase_Operation* theOperation)
 {
-  //TODO(sbh): Implement static method to extract event id [SEID]
-  static Events_ID aModuleEvent = Events_Loop::eventByName("PartSetModuleEvent");
+  static Events_ID aModuleEvent = Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED);
   Config_PointerMessage aMessage(aModuleEvent, this);
   aMessage.setPointer(theOperation);
   Events_Loop::loop()->send(aMessage);
index 81bb1d0a3ce5f2c2ad88c266b6f26d49cbf74d7d..ed05647f4bed4f0ac2d8a88abfcc195a9adb3d57 100644 (file)
@@ -120,10 +120,10 @@ void XGUI_Workshop::startApplication()
   Events_Loop* aLoop = Events_Loop::loop();
   aLoop->registerListener(this, Events_Error::errorID()); //!< Listening application errors.
   //TODO(sbh): Implement static method to extract event id [SEID]
-  aLoop->registerListener(this, aLoop->eventByName(EVENT_FEATURE_LOADED));
+  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_LOADED));
   // TODO Is it good to use non standard event within workshop?
-  aLoop->registerListener(this, aLoop->eventByName("PartSetModuleEvent"));
-  aLoop->registerListener(this, aLoop->eventByName(EVENT_FEATURE_UPDATED));
+  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED));
+  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_CREATED));
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_TO_REDISPLAY));
 
@@ -236,16 +236,15 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage)
 
   //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.
-  static Events_ID aFeatureUpdatedId = Events_Loop::loop()->eventByName(EVENT_FEATURE_UPDATED);
-  if (theMessage->eventID() == aFeatureUpdatedId) {
+  if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_UPDATED)) {
     const Model_FeatureUpdatedMessage* anUpdateMsg =
         dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
     onFeatureUpdatedMsg(anUpdateMsg);
   }
 
   //An operation passed by message. Start it, process and commit.
-  const Config_PointerMessage* aPartSetMsg = dynamic_cast<const Config_PointerMessage*>(theMessage);
-  if (aPartSetMsg) {
+  if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OPERATION_LAUNCHED)) {
+    const Config_PointerMessage* aPartSetMsg = dynamic_cast<const Config_PointerMessage*>(theMessage);
     myPropertyPanel->cleanContent();
     ModuleBase_Operation* anOperation = (ModuleBase_Operation*)aPartSetMsg->pointer();