From: nds Date: Tue, 20 May 2014 11:20:31 +0000 (+0400) Subject: refs #30 - Sketch base GUI: create, draw lines X-Git-Tag: V_0.2~26^2~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f336bd42fdbf099f8fed4dc5288f4a2cef3a3dda;p=modules%2Fshaper.git refs #30 - Sketch base GUI: create, draw lines One signal about the features has been moved. --- diff --git a/src/Model/Model_Events.cpp b/src/Model/Model_Events.cpp index f4bede4e4..cbf485997 100644 --- a/src/Model/Model_Events.cpp +++ b/src/Model/Model_Events.cpp @@ -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 >& theFeatures) +{ + myFeatures = theFeatures; +} + +const std::list >& Model_FeaturesMovedMessage::features() const +{ + return myFeatures; +} + diff --git a/src/Model/Model_Events.h b/src/Model/Model_Events.h index ba0b7ea34..c9c60b65f 100644 --- a/src/Model/Model_Events.h +++ b/src/Model/Model_Events.h @@ -7,8 +7,10 @@ #include #include +#include #include #include +#include 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 > 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 >& theFeatures); + + /// Returns a list of features + MODEL_EXPORT const std::list >& features() const; +}; + #endif diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index 7461196d2..7e4e35034 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -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) diff --git a/src/PartSet/PartSet_OperationEditLine.cpp b/src/PartSet/PartSet_OperationEditLine.cpp index 5383e0d49..7b37976e8 100644 --- a/src/PartSet/PartSet_OperationEditLine.cpp +++ b/src/PartSet/PartSet_OperationEditLine.cpp @@ -15,6 +15,10 @@ #include #include +#include + +#include + #include #include @@ -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 PartSet_OperationEditLine::createFeature() return boost::shared_ptr(); } -void PartSet_OperationEditLine::moveLinePoint(boost::shared_ptr theFeature, +void PartSet_OperationEditLine::moveLinePoint(boost::shared_ptr theFeature, double theDeltaX, double theDeltaY, const std::string& theAttribute) { @@ -162,3 +168,20 @@ void PartSet_OperationEditLine::moveLinePoint(boost::shared_ptrsetValue(aPoint->x() + theDeltaX, aPoint->y() + theDeltaY); } + +void PartSet_OperationEditLine::sendFeatures() +{ + std::list > aFeatures; + std::list::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end(); + for (; anIt != aLast; anIt++) { + boost::shared_ptr 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); +} + diff --git a/src/PartSet/PartSet_OperationEditLine.h b/src/PartSet/PartSet_OperationEditLine.h index 5f447c730..14fd56959 100644 --- a/src/PartSet/PartSet_OperationEditLine.h +++ b/src/PartSet/PartSet_OperationEditLine.h @@ -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 theFeature, double theDeltaX, double theDeltaY, const std::string& theAttribute); + /// Sends the features + void sendFeatures(); private: boost::shared_ptr mySketch; ///< the sketch feature