]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Implementation of mechanism of grouping of messages
authornds <natalia.donis@opencascade.com>
Thu, 22 May 2014 12:42:24 +0000 (16:42 +0400)
committernds <natalia.donis@opencascade.com>
Thu, 22 May 2014 12:42:24 +0000 (16:42 +0400)
Flush call during operation of line creation.

src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_Operation.h
src/PartSet/PartSet_OperationEditLine.cpp
src/PartSet/PartSet_OperationEditLine.h
src/PartSet/PartSet_OperationSketchBase.cpp
src/PartSet/PartSet_OperationSketchBase.h
src/PartSet/PartSet_OperationSketchLine.cpp
src/PartSet/PartSet_OperationSketchLine.h

index b154decb009ed0e9e21ba1c885e7f0bfdeb7f47e..82f7214d88e005c820d1fda431e71c81f9b8eb81 100644 (file)
@@ -41,6 +41,8 @@ SOURCE_GROUP ("Generated Files" FILES ${PROJECT_AUTOMOC} ${PROJECT_COMPILED_RESO
 
 INCLUDE_DIRECTORIES(
     ${PROJECT_SOURCE_DIR}/src/Config
+    ${CMAKE_SOURCE_DIR}/src/Events
+    ${CMAKE_SOURCE_DIR}/src/Model
     ${CMAKE_SOURCE_DIR}/src/ModelAPI
     ${CMAKE_SOURCE_DIR}/src/GeomDataAPI
 )
index e742c055393a02e4d1d582406fbc71b82bc2d27a..642718ece14c854abfa87af3a6718ab709de10c6 100644 (file)
@@ -15,6 +15,9 @@
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Document.h>
+#include <Model_Events.h>
+
+#include <Events_Loop.h>
 
 #ifdef _DEBUG
 #include <QDebug>
@@ -84,13 +87,16 @@ void ModuleBase_Operation::commitOperation()
   if (myFeature) myFeature->execute();
 }
 
-boost::shared_ptr<ModelAPI_Feature> ModuleBase_Operation::createFeature()
+boost::shared_ptr<ModelAPI_Feature> ModuleBase_Operation::createFeature(const bool theFlushMessage)
 {
   boost::shared_ptr<ModelAPI_Document> aDoc = document();
   boost::shared_ptr<ModelAPI_Feature> aFeature = aDoc->addFeature(
                                            getDescription()->operationId().toStdString());
   if (aFeature) // TODO: generate an error if feature was not created
     aFeature->execute();
+
+  if (theFlushMessage)
+    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_CREATED));
   return aFeature;
 }
 
index 43c225dd147802f48e5fc3c3bd22209d596f567a..21bfacc8da4839026b384db9dd485268c0905a5a 100644 (file)
@@ -71,8 +71,9 @@ protected:
   virtual void commitOperation();
 
   /// Creates an operation new feature
+  /// \param theFlushMessage the flag whether the create message should be flushed
   /// \returns the created feature
-  virtual boost::shared_ptr<ModelAPI_Feature> createFeature();
+  virtual boost::shared_ptr<ModelAPI_Feature> createFeature(const bool theFlushMessage = true);
 
   /// Returns the operation feature
   /// \return the feature
index c66f38f35281f25db8804a67c9c0fc19538ad566..c355c82c0b57c1c76bc0d4b24295b1ef15a22f95 100644 (file)
@@ -150,7 +150,7 @@ void PartSet_OperationEditLine::stopOperation()
   myFeatures.clear();
 }
 
-boost::shared_ptr<ModelAPI_Feature> PartSet_OperationEditLine::createFeature()
+boost::shared_ptr<ModelAPI_Feature> PartSet_OperationEditLine::createFeature(const bool /*theFlushMessage*/)
 {
   // do nothing in order to do not create a new feature
   return boost::shared_ptr<ModelAPI_Feature>();
index 14fd56959cfebedd8688389b7c6140c40ca797b9..d053067b85517278fe809893065b545dafa7e8d3 100644 (file)
@@ -106,8 +106,9 @@ protected:
 
   /// Creates an operation new feature
   /// Returns NULL feature. This is an operation of edition, not creation.
+  /// \param theFlushMessage the flag whether the create message should be flushed
   /// \returns the created feature
-  virtual boost::shared_ptr<ModelAPI_Feature> createFeature();
+  virtual boost::shared_ptr<ModelAPI_Feature> createFeature(const bool theFlushMessage = true);
 
 protected:
   /// \brief Save the point to the line.
index 45981e24402b8b827621b20efdb7e558e3b916c9..2b83d306f3efbe8ab6305e866c7c4be9a7648195 100644 (file)
@@ -54,9 +54,9 @@ std::list<int> PartSet_OperationSketchBase::getSelectionModes(boost::shared_ptr<
   aModes.push_back(TopAbs_EDGE);
   return aModes;
 }
-boost::shared_ptr<ModelAPI_Feature> PartSet_OperationSketchBase::createFeature()
+boost::shared_ptr<ModelAPI_Feature> PartSet_OperationSketchBase::createFeature(const bool theFlushMessage)
 {
-  boost::shared_ptr<ModelAPI_Feature> aFeature = ModuleBase_Operation::createFeature();
+  boost::shared_ptr<ModelAPI_Feature> aFeature = ModuleBase_Operation::createFeature(theFlushMessage);
   if (aFeature)
     emit featureConstructed(aFeature, FM_Activation);
   return aFeature;
index 0045a8e87b1a6c19b2cf227188974d3ea7099387..6b4eb49f4c96a652d5c2a6eb2d0e5b549fee2944 100644 (file)
@@ -119,8 +119,9 @@ protected:
   /// Creates an operation new feature
   /// In addition to the default realization it appends the created line feature to
   /// the sketch feature
+  /// \param theFlushMessage the flag whether the create message should be flushed
   /// \returns the created feature
-  virtual boost::shared_ptr<ModelAPI_Feature> createFeature();
+  virtual boost::shared_ptr<ModelAPI_Feature> createFeature(const bool theFlushMessage = true);
 };
 
 #endif
index 6b64cd2759cff1930c142411f11a40d44ab5d1bc..84d5fc7620bbbb88a01ffe27cdc78f957a6abb08 100644 (file)
@@ -10,6 +10,9 @@
 #include <SketchPlugin_Feature.h>
 #include <SketchPlugin_Sketch.h>
 
+#include <Events_Loop.h>
+#include <Model_Events.h>
+
 #include <GeomDataAPI_Point2D.h>
 
 #include <ModuleBase_OperationDescription.h>
@@ -142,11 +145,15 @@ void PartSet_OperationSketchLine::mouseReleased(QMouseEvent* theEvent, Handle(V3
     case SM_FirstPoint: {
       setLinePoint(feature(), aX, anY, LINE_ATTR_START);
       setLinePoint(feature(), aX, anY, LINE_ATTR_END);
+      Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
+
       myPointSelectionMode = SM_SecondPoint;
     }
     break;
     case SM_SecondPoint: {
       setLinePoint(feature(), aX, anY, LINE_ATTR_END);
+      Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
+
       myPointSelectionMode = SM_DonePoint;
     }
     break;
@@ -165,12 +172,14 @@ void PartSet_OperationSketchLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_V
       PartSet_Tools::ConvertTo2D(aPoint, sketch(), theView, aX, anY);
       setLinePoint(feature(), aX, anY, LINE_ATTR_START);
       setLinePoint(feature(), aX, anY, LINE_ATTR_END);
+      Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
     }
     break;
     case SM_SecondPoint:
     {
       gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(theEvent->pos(), theView);
       setLinePoint(aPoint, theView, LINE_ATTR_END);
+      Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
     }
     break;
     case SM_DonePoint:
@@ -223,9 +232,9 @@ void PartSet_OperationSketchLine::stopOperation()
   emit multiSelectionEnabled(true);
 }
 
-boost::shared_ptr<ModelAPI_Feature> PartSet_OperationSketchLine::createFeature()
+boost::shared_ptr<ModelAPI_Feature> PartSet_OperationSketchLine::createFeature(const bool theFlushMessage)
 {
-  boost::shared_ptr<ModelAPI_Feature> aNewFeature = ModuleBase_Operation::createFeature();
+  boost::shared_ptr<ModelAPI_Feature> aNewFeature = ModuleBase_Operation::createFeature(false);
   if (sketch()) {
     boost::shared_ptr<SketchPlugin_Feature> aFeature = 
                            boost::dynamic_pointer_cast<SketchPlugin_Feature>(sketch());
@@ -243,6 +252,8 @@ boost::shared_ptr<ModelAPI_Feature> PartSet_OperationSketchLine::createFeature()
   }
 
   emit featureConstructed(aNewFeature, FM_Activation);
+  if (theFlushMessage)
+    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_CREATED));
   return aNewFeature;
 }
 
index 09c33f6f452621540d8d17e9ede546f703c417e7..d4b2fc85cf67a4efb20c9cf9ea39a94c43b9df89 100644 (file)
@@ -86,8 +86,9 @@ protected:
   /// Creates an operation new feature
   /// In addition to the default realization it appends the created line feature to
   /// the sketch feature
+  /// \param theFlushMessage the flag whether the create message should be flushed
   /// \returns the created feature
-  virtual boost::shared_ptr<ModelAPI_Feature> createFeature();
+  virtual boost::shared_ptr<ModelAPI_Feature> createFeature(const bool theFlushMessage = true);
 
   /// Creates a constraint on two points
   /// \param thePoint1 the first point