From: nds Date: Thu, 22 May 2014 12:42:24 +0000 (+0400) Subject: Implementation of mechanism of grouping of messages X-Git-Tag: V_0.2~26^2~1^2^2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a6cdb246419bf0d2e447106d2492f7bb40c0c531;p=modules%2Fshaper.git Implementation of mechanism of grouping of messages Flush call during operation of line creation. --- diff --git a/src/ModuleBase/CMakeLists.txt b/src/ModuleBase/CMakeLists.txt index b154decb0..82f7214d8 100644 --- a/src/ModuleBase/CMakeLists.txt +++ b/src/ModuleBase/CMakeLists.txt @@ -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 ) diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index e742c0553..642718ece 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -15,6 +15,9 @@ #include #include #include +#include + +#include #ifdef _DEBUG #include @@ -84,13 +87,16 @@ void ModuleBase_Operation::commitOperation() if (myFeature) myFeature->execute(); } -boost::shared_ptr ModuleBase_Operation::createFeature() +boost::shared_ptr ModuleBase_Operation::createFeature(const bool theFlushMessage) { boost::shared_ptr aDoc = document(); boost::shared_ptr 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; } diff --git a/src/ModuleBase/ModuleBase_Operation.h b/src/ModuleBase/ModuleBase_Operation.h index 43c225dd1..21bfacc8d 100644 --- a/src/ModuleBase/ModuleBase_Operation.h +++ b/src/ModuleBase/ModuleBase_Operation.h @@ -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 createFeature(); + virtual boost::shared_ptr createFeature(const bool theFlushMessage = true); /// Returns the operation feature /// \return the feature diff --git a/src/PartSet/PartSet_OperationEditLine.cpp b/src/PartSet/PartSet_OperationEditLine.cpp index c66f38f35..c355c82c0 100644 --- a/src/PartSet/PartSet_OperationEditLine.cpp +++ b/src/PartSet/PartSet_OperationEditLine.cpp @@ -150,7 +150,7 @@ void PartSet_OperationEditLine::stopOperation() myFeatures.clear(); } -boost::shared_ptr PartSet_OperationEditLine::createFeature() +boost::shared_ptr PartSet_OperationEditLine::createFeature(const bool /*theFlushMessage*/) { // do nothing in order to do not create a new feature return boost::shared_ptr(); diff --git a/src/PartSet/PartSet_OperationEditLine.h b/src/PartSet/PartSet_OperationEditLine.h index 14fd56959..d053067b8 100644 --- a/src/PartSet/PartSet_OperationEditLine.h +++ b/src/PartSet/PartSet_OperationEditLine.h @@ -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 createFeature(); + virtual boost::shared_ptr createFeature(const bool theFlushMessage = true); protected: /// \brief Save the point to the line. diff --git a/src/PartSet/PartSet_OperationSketchBase.cpp b/src/PartSet/PartSet_OperationSketchBase.cpp index 45981e244..2b83d306f 100644 --- a/src/PartSet/PartSet_OperationSketchBase.cpp +++ b/src/PartSet/PartSet_OperationSketchBase.cpp @@ -54,9 +54,9 @@ std::list PartSet_OperationSketchBase::getSelectionModes(boost::shared_ptr< aModes.push_back(TopAbs_EDGE); return aModes; } -boost::shared_ptr PartSet_OperationSketchBase::createFeature() +boost::shared_ptr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage) { - boost::shared_ptr aFeature = ModuleBase_Operation::createFeature(); + boost::shared_ptr aFeature = ModuleBase_Operation::createFeature(theFlushMessage); if (aFeature) emit featureConstructed(aFeature, FM_Activation); return aFeature; diff --git a/src/PartSet/PartSet_OperationSketchBase.h b/src/PartSet/PartSet_OperationSketchBase.h index 0045a8e87..6b4eb49f4 100644 --- a/src/PartSet/PartSet_OperationSketchBase.h +++ b/src/PartSet/PartSet_OperationSketchBase.h @@ -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 createFeature(); + virtual boost::shared_ptr createFeature(const bool theFlushMessage = true); }; #endif diff --git a/src/PartSet/PartSet_OperationSketchLine.cpp b/src/PartSet/PartSet_OperationSketchLine.cpp index 6b64cd275..84d5fc762 100644 --- a/src/PartSet/PartSet_OperationSketchLine.cpp +++ b/src/PartSet/PartSet_OperationSketchLine.cpp @@ -10,6 +10,9 @@ #include #include +#include +#include + #include #include @@ -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 PartSet_OperationSketchLine::createFeature() +boost::shared_ptr PartSet_OperationSketchLine::createFeature(const bool theFlushMessage) { - boost::shared_ptr aNewFeature = ModuleBase_Operation::createFeature(); + boost::shared_ptr aNewFeature = ModuleBase_Operation::createFeature(false); if (sketch()) { boost::shared_ptr aFeature = boost::dynamic_pointer_cast(sketch()); @@ -243,6 +252,8 @@ boost::shared_ptr PartSet_OperationSketchLine::createFeature() } emit featureConstructed(aNewFeature, FM_Activation); + if (theFlushMessage) + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_CREATED)); return aNewFeature; } diff --git a/src/PartSet/PartSet_OperationSketchLine.h b/src/PartSet/PartSet_OperationSketchLine.h index 09c33f6f4..d4b2fc85c 100644 --- a/src/PartSet/PartSet_OperationSketchLine.h +++ b/src/PartSet/PartSet_OperationSketchLine.h @@ -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 createFeature(); + virtual boost::shared_ptr createFeature(const bool theFlushMessage = true); /// Creates a constraint on two points /// \param thePoint1 the first point