]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #30 - Sketch base GUI: create, draw lines
authornds <natalia.donis@opencascade.com>
Tue, 20 May 2014 11:20:31 +0000 (15:20 +0400)
committernds <natalia.donis@opencascade.com>
Tue, 20 May 2014 11:20:31 +0000 (15:20 +0400)
One signal about the features has been moved.

src/Model/Model_Events.cpp
src/Model/Model_Events.h
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_OperationEditLine.cpp
src/PartSet/PartSet_OperationEditLine.h

index f4bede4e44ebc09faf54dfac9af7b84e0f09f1c7..cbf4859979003d74a98e762ac767ca08f87ef000 100644 (file)
@@ -17,3 +17,26 @@ const Events_ID Model_FeatureDeletedMessage::messageId()
   static Events_ID MY_ID = Events_Loop::eventByName(EVENT_FEATURE_DELETED);
   return MY_ID;
 }
+
+Model_FeaturesMovedMessage::Model_FeaturesMovedMessage()
+: Events_Message(messageId(), 0)
+{
+}
+
+const Events_ID Model_FeaturesMovedMessage::messageId()
+{
+  static Events_ID MY_ID = Events_Loop::eventByName(EVENT_FEATURES_MOVED);
+  return MY_ID;
+}
+
+void Model_FeaturesMovedMessage::setFeatures(
+                                const std::list<boost::shared_ptr<ModelAPI_Feature> >& theFeatures)
+{
+  myFeatures = theFeatures;  
+}
+
+const std::list<boost::shared_ptr<ModelAPI_Feature> >& Model_FeaturesMovedMessage::features() const
+{
+  return myFeatures;
+}
+
index ba0b7ea3438c66a73be4c744e5f719aab1739375..c9c60b65ffd77a2be6b9fb3a2e4dc1c5a832da55 100644 (file)
@@ -7,8 +7,10 @@
 
 #include <Model.h>
 #include <Events_Message.h>
+#include <Events_Loop.h>
 #include <boost/shared_ptr.hpp>
 #include <string>
+#include <list>
 
 class ModelAPI_Feature;
 class ModelAPI_Document;
@@ -19,6 +21,8 @@ static const char * EVENT_FEATURE_CREATED = "FeatureCreated";
 static const char * EVENT_FEATURE_UPDATED = "FeatureUpdated";
 /// Event ID that data of feature is deleted (comes with Model_FeatureDeletedMessage)
 static const char * EVENT_FEATURE_DELETED = "FeatureDeleted";
+/// Event ID that data of feature is updated (comes with Model_FeaturesMovedMessage)
+static const char * EVENT_FEATURES_MOVED = "FeaturesMoved";
 
 /// Message that feature was changed (used for Object Browser update)
 class Model_FeatureUpdatedMessage : public Events_Message {
@@ -53,4 +57,21 @@ public:
   const std::string& group() const {return myGroup;}
 };
 
+/// Message that features were moved (used for the feature preview update)
+class Model_FeaturesMovedMessage : public Events_Message {
+  std::list<boost::shared_ptr<ModelAPI_Feature> > myFeatures; ///< which features are moved
+public:
+  /// creates a message by initialization of fields
+  MODEL_EXPORT Model_FeaturesMovedMessage();
+
+  /// Returns the ID of this message (EVENT_FEATURES_MOVED)
+  static const Events_ID messageId();
+
+  /// Sets a list of features
+  MODEL_EXPORT void setFeatures(const std::list<boost::shared_ptr<ModelAPI_Feature> >& theFeatures);
+
+  /// Returns a list of features
+  MODEL_EXPORT const std::list<boost::shared_ptr<ModelAPI_Feature> >& features() const;
+};
+
 #endif
index 7461196d2aabfa03c6ce7dec0bc9dce119c631a9..7e4e35034339559c403e7ef4276fbc66e64cf2e0 100644 (file)
@@ -80,7 +80,7 @@ ADD_LIBRARY(PartSet SHARED
 )
 
 # The Qt5Widgets_LIBRARIES variable also includes QtGui and QtCore
-TARGET_LINK_LIBRARIES(PartSet ${PROJECT_LIBRARIES} XGUI ModelAPI GeomAlgoAPI)
+TARGET_LINK_LIBRARIES(PartSet ${PROJECT_LIBRARIES} XGUI ModelAPI Model GeomAlgoAPI)
 
 ADD_DEPENDENCIES(PartSet ModuleBase)
 
index 5383e0d493393863abec6cb728bed0cf49a156d6..7b37976e8a0f041f2f19f85a18b9aa9ec11437dd 100644 (file)
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Document.h>
 
+#include <Model_Events.h>
+
+#include <Events_Loop.h>
+
 #include <SketchPlugin_Line.h>
 
 #include <V3d_View.hxx>
@@ -97,6 +101,8 @@ void PartSet_OperationEditLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_Vie
       moveLinePoint(aFeature, aDeltaX, aDeltaY, LINE_ATTR_END);
     }
   }
+  sendFeatures();
+
   myCurPoint.setPoint(aPoint);
 }
 
@@ -149,7 +155,7 @@ boost::shared_ptr<ModelAPI_Feature> PartSet_OperationEditLine::createFeature()
   return boost::shared_ptr<ModelAPI_Feature>();
 }
 
-void  PartSet_OperationEditLine::moveLinePoint(boost::shared_ptr<ModelAPI_Feature> theFeature,
+void PartSet_OperationEditLine::moveLinePoint(boost::shared_ptr<ModelAPI_Feature> theFeature,
                                                double theDeltaX, double theDeltaY,
                                                const std::string& theAttribute)
 {
@@ -162,3 +168,20 @@ void  PartSet_OperationEditLine::moveLinePoint(boost::shared_ptr<ModelAPI_Featur
 
   aPoint->setValue(aPoint->x() + theDeltaX, aPoint->y() + theDeltaY);
 }
+
+void PartSet_OperationEditLine::sendFeatures()
+{
+  std::list<boost::shared_ptr<ModelAPI_Feature> > aFeatures;
+  std::list<XGUI_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
+  for (; anIt != aLast; anIt++) {
+    boost::shared_ptr<ModelAPI_Feature> aFeature = (*anIt).feature();
+    if (!aFeature || aFeature == feature())
+      continue;
+  }
+
+  static Events_ID aModuleEvent = Events_Loop::eventByName("PartSetEditEvent");
+  Model_FeaturesMovedMessage aMessage;
+  aMessage.setFeatures(aFeatures);
+  Events_Loop::loop()->send(aMessage);
+}
+
index 5f447c7305bcd7425703b13458c92b7c85453fdf..14fd56959cfebedd8688389b7c6140c40ca797b9 100644 (file)
@@ -16,7 +16,7 @@ class QMouseEvent;
  \class PartSet_OperationEditLine
  * \brief The operation for the sketch feature creation
 */
-class PARTSET_EXPORT PartSet_OperationEditLine : public PartSet_OperationSketchBase
+class PARTSET_EXPORT PartSet_OperationEditLine : public PartSet_OperationSketchBase                                                 
 {
   Q_OBJECT
   /// Struct to define gp point, with the state is the point is initialized
@@ -118,6 +118,8 @@ protected:
   void  moveLinePoint(boost::shared_ptr<ModelAPI_Feature> theFeature,
                       double theDeltaX, double theDeltaY,
                       const std::string& theAttribute);
+  /// Sends the features
+  void sendFeatures();
 
 private:
   boost::shared_ptr<ModelAPI_Feature> mySketch; ///< the sketch feature