From: nds Date: Thu, 4 Dec 2014 08:42:02 +0000 (+0300) Subject: An improvement to process 'Enter' button click in the PartSet module. X-Git-Tag: V_0.6.0^2~24 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c9a864dfffea8ecbe87341d01439cb7b3344abba;p=modules%2Fshaper.git An improvement to process 'Enter' button click in the PartSet module. Fix a problem concerned to the second click if the property panel lost the focus(moving under a highlighted point). It connects the current viewer to the method of operation manager, which processes the key release. --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 8edff2835..e3c2d76ab 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(LastFeatureUse), myDragDone(false) + myIsDragging(false), myRestartingMode(RM_LastFeatureUse), myDragDone(false) { //myWorkshop = dynamic_cast(theWshop); ModuleBase_IViewer* aViewer = aViewer = theWshop->viewer(); @@ -111,6 +111,9 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop) XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr(); connect(anOpMgr, SIGNAL(keyEnterReleased()), this, SLOT(onEnterReleased())); + + connect(aViewer, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)), + this, SLOT(onKeyRelease(ModuleBase_IViewWindow*, QKeyEvent*))); } PartSet_Module::~PartSet_Module() @@ -142,9 +145,9 @@ void PartSet_Module::onOperationComitted(ModuleBase_Operation* theOperation) FeaturePtr aFeature = theOperation->feature(); std::shared_ptr aSPFeature = std::dynamic_pointer_cast(aFeature); - if (aSPFeature && (myRestartingMode != None)) { + if (aSPFeature && (myRestartingMode != RM_None)) { myLastOperationId = theOperation->id(); - myLastFeature = myRestartingMode == LastFeatureUse ? theOperation->feature() : FeaturePtr(); + myLastFeature = myRestartingMode == RM_LastFeatureUse ? theOperation->feature() : FeaturePtr(); launchOperation(myLastOperationId); } else { breakOperationSequence(); @@ -155,7 +158,7 @@ void PartSet_Module::breakOperationSequence() { myLastOperationId = ""; myLastFeature = FeaturePtr(); - myRestartingMode = None; + myRestartingMode = RM_None; } @@ -166,7 +169,7 @@ void PartSet_Module::onOperationAborted(ModuleBase_Operation* theOperation) void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation) { - myRestartingMode = LastFeatureUse; + myRestartingMode = RM_LastFeatureUse; if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) { // Display all sketcher sub-Objects myCurrentSketch = std::dynamic_pointer_cast(theOperation->feature()); @@ -507,9 +510,16 @@ void PartSet_Module::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* t } } +void PartSet_Module::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent) +{ + XGUI_ModuleConnector* aConnector = dynamic_cast(workshop()); + XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr(); + anOpMgr->onKeyReleased(theEvent); +} + void PartSet_Module::onEnterReleased() { - myRestartingMode = LastFeatureEmpty; + myRestartingMode = RM_LastFeatureEmpty; } QStringList PartSet_Module::sketchOperationIdList() const diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 1dd3b8cc2..36156c8ec 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -30,9 +30,9 @@ Q_OBJECT /// 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 + RM_None, /// the operation should not be restarted + RM_LastFeatureUse, /// the operation is restarted and use the previous feature for own initialization + RM_LastFeatureEmpty /// the operation is restarted and does not use the previous feature }; public: @@ -77,6 +77,11 @@ protected slots: /// \param theEvent the mouse event virtual void onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent); + /// SLOT, that is called by key release in the viewer. + /// The mouse moved point is sent to the current operation to be processed. + /// \param theEvent the key event + void onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent); + /// SLOT, that is called by enter key released /// Set a specific type of restarting the current operation void onEnterReleased();