From: nds Date: Wed, 3 Dec 2014 12:08:09 +0000 (+0300) Subject: An improvement to process 'Enter' button click in the PartSet module. X-Git-Tag: V_0.6.0^2~30^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=67e6cec1ebbf895a735eebdb5b47f3a80d8e6788;p=modules%2Fshaper.git An improvement to process 'Enter' button click in the PartSet module. This is important for the line creation. The current line should be validated. A line creation operation is restarted but a new line does not connected to the previous countour. --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 38e9671dd..8edff2835 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -93,7 +93,7 @@ extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(ModuleBase_IWorkshop* PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop) : ModuleBase_IModule(theWshop), - myIsDragging(false), myRestartingMode(true), myDragDone(false) + myIsDragging(false), myRestartingMode(LastFeatureUse), myDragDone(false) { //myWorkshop = dynamic_cast(theWshop); ModuleBase_IViewer* aViewer = aViewer = theWshop->viewer(); @@ -106,6 +106,11 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop) connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)), this, SLOT(onMouseMoved(ModuleBase_IViewWindow*, QMouseEvent*))); + XGUI_ModuleConnector* aConnector = dynamic_cast(theWshop); + XGUI_Workshop* aWorkshop = aConnector->workshop(); + + XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr(); + connect(anOpMgr, SIGNAL(keyEnterReleased()), this, SLOT(onEnterReleased())); } PartSet_Module::~PartSet_Module() @@ -137,9 +142,9 @@ void PartSet_Module::onOperationComitted(ModuleBase_Operation* theOperation) FeaturePtr aFeature = theOperation->feature(); std::shared_ptr aSPFeature = std::dynamic_pointer_cast(aFeature); - if (aSPFeature && myRestartingMode) { + if (aSPFeature && (myRestartingMode != None)) { myLastOperationId = theOperation->id(); - myLastFeature = theOperation->feature(); + myLastFeature = myRestartingMode == LastFeatureUse ? theOperation->feature() : FeaturePtr(); launchOperation(myLastOperationId); } else { breakOperationSequence(); @@ -150,7 +155,7 @@ void PartSet_Module::breakOperationSequence() { myLastOperationId = ""; myLastFeature = FeaturePtr(); - myRestartingMode = false; + myRestartingMode = None; } @@ -161,7 +166,7 @@ void PartSet_Module::onOperationAborted(ModuleBase_Operation* theOperation) void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation) { - myRestartingMode = true; + myRestartingMode = LastFeatureUse; if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) { // Display all sketcher sub-Objects myCurrentSketch = std::dynamic_pointer_cast(theOperation->feature()); @@ -502,6 +507,10 @@ void PartSet_Module::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* t } } +void PartSet_Module::onEnterReleased() +{ + myRestartingMode = LastFeatureEmpty; +} QStringList PartSet_Module::sketchOperationIdList() const { diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 085876eb2..1dd3b8cc2 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -28,7 +28,14 @@ class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule { Q_OBJECT - public: +/// Enumeration to specify the restart operation properties. +enum RestartingMode { + None, /// the operation should not be restarted + LastFeatureUse, /// the operation is restarted and use the previous feature for own initialization + LastFeatureEmpty /// the operation is restarted and does not use the previous feature +}; + +public: PartSet_Module(ModuleBase_IWorkshop* theWshop); virtual ~PartSet_Module(); @@ -70,6 +77,10 @@ protected slots: /// \param theEvent the mouse event virtual void onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent); + /// SLOT, that is called by enter key released + /// Set a specific type of restarting the current operation + void onEnterReleased(); + /// Launches the operation from current highlighting void launchEditing(); @@ -102,7 +113,7 @@ protected slots: bool myDragDone; // Automatical restarting mode flag - bool myRestartingMode; + RestartingMode myRestartingMode; double myCurX, myCurY; CompositeFeaturePtr myCurrentSketch; diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 6a3cc32be..94e5026e2 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -264,6 +264,7 @@ bool XGUI_OperationMgr::onKeyReleased(QKeyEvent* theEvent) switch (theEvent->key()) { case Qt::Key_Return: case Qt::Key_Enter: { + emit keyEnterReleased(); commitOperation(); } break; diff --git a/src/XGUI/XGUI_OperationMgr.h b/src/XGUI/XGUI_OperationMgr.h index c589e0dc5..29a340b0d 100644 --- a/src/XGUI/XGUI_OperationMgr.h +++ b/src/XGUI/XGUI_OperationMgr.h @@ -108,6 +108,9 @@ signals: /// Signal is emitted after the validate methods calls. void operationValidated(bool); + /// Signal is emitted after the key released click. + void keyEnterReleased(); + protected: /// Commits the current operatin if it is valid