From: nds Date: Wed, 30 Apr 2014 10:52:25 +0000 (+0400) Subject: refs #30 - Sketch base GUI: create, draw lines X-Git-Tag: V_0.2~99^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fdba6b33575c4ed5ccfff778364e480806be1a53;p=modules%2Fshaper.git refs #30 - Sketch base GUI: create, draw lines Contour of some lines creation. --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 8bcafffef..5826a3493 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -59,6 +59,8 @@ PartSet_Module::PartSet_Module(XGUI_Workshop* theWshop) this, SLOT(onMouseReleased(XGUI_ViewWindow*, QMouseEvent*))); connect(aViewer, SIGNAL(mouseMove(XGUI_ViewWindow*, QMouseEvent*)), this, SLOT(onMouseMoved(XGUI_ViewWindow*, QMouseEvent*))); + connect(aViewer, SIGNAL(keyRelease(XGUI_ViewWindow*, QKeyEvent*)), + this, SLOT(onKeyRelease(XGUI_ViewWindow*, QKeyEvent*))); } } @@ -215,6 +217,15 @@ void PartSet_Module::onMouseMoved(XGUI_ViewWindow* theWindow, QMouseEvent* theEv } } +void PartSet_Module::onKeyRelease(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent) +{ + ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation(); + PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); + if (aPreviewOp) { + aPreviewOp->keyReleased(theEvent->key()); + } +} + void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ) { XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer(); diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index ea7d30e4d..7e8190eb1 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -15,6 +15,7 @@ class XGUI_ViewWindow; class QMouseEvent; +class QKeyEvent; class PartSet_Listener; class ModelAPI_Feature; @@ -61,6 +62,11 @@ public slots: /// \param theEvent the mouse event void onMouseMoved(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent); + /// SLOT, that is called by the key in the viewer is clicked. + /// \param theWindow the window where the signal appears + /// \param theEvent the mouse event + void onKeyRelease(XGUI_ViewWindow*, QKeyEvent*); + /// SLOT, to apply to the current viewer the operation /// \param theX the X projection value /// \param theY the Y projection value diff --git a/src/PartSet/PartSet_OperationSketchBase.h b/src/PartSet/PartSet_OperationSketchBase.h index e5aa868a3..48aa06c84 100644 --- a/src/PartSet/PartSet_OperationSketchBase.h +++ b/src/PartSet/PartSet_OperationSketchBase.h @@ -53,6 +53,10 @@ public: /// \param thePoint a 3D point clicked in the viewer virtual void mouseMoved(const gp_Pnt& thePoint) {}; + /// Processes the key pressed in the view + /// \param theKey a key value + virtual void keyReleased(const int theKey) {}; + signals: /// Signal about the feature construing is finished /// \param theFeature the result feature diff --git a/src/PartSet/PartSet_OperationSketchLine.cpp b/src/PartSet/PartSet_OperationSketchLine.cpp index b76a73084..5bc516c39 100644 --- a/src/PartSet/PartSet_OperationSketchLine.cpp +++ b/src/PartSet/PartSet_OperationSketchLine.cpp @@ -96,6 +96,20 @@ void PartSet_OperationSketchLine::mouseMoved(const gp_Pnt& thePoint) } } +void PartSet_OperationSketchLine::keyReleased(const int theKey) +{ + switch (theKey) { + case Qt::Key_Escape: + abort(); + break; + case Qt::Key_Enter: + //myPointSelectionMode = myPointSelectionMode; + break; + default: + break; + } +} + void PartSet_OperationSketchLine::startOperation() { PartSet_OperationSketchBase::startOperation(); diff --git a/src/PartSet/PartSet_OperationSketchLine.h b/src/PartSet/PartSet_OperationSketchLine.h index 3e07b82b8..86b1eaceb 100644 --- a/src/PartSet/PartSet_OperationSketchLine.h +++ b/src/PartSet/PartSet_OperationSketchLine.h @@ -42,6 +42,9 @@ public: /// Gives the current mouse point in the viewer /// \param thePoint a point clicked in the viewer virtual void mouseMoved(const gp_Pnt& thePoint); + /// Processes the key pressed in the view + /// \param theKey a key value + virtual void keyReleased(const int theKey); signals: /// signal about the sketch plane is selected diff --git a/src/XGUI/XGUI_ViewWindow.cpp b/src/XGUI/XGUI_ViewWindow.cpp index 2c4809cb8..12c92e6fa 100644 --- a/src/XGUI/XGUI_ViewWindow.cpp +++ b/src/XGUI/XGUI_ViewWindow.cpp @@ -530,6 +530,10 @@ bool XGUI_ViewWindow::eventFilter(QObject *theObj, QEvent *theEvent) if (processViewPort(theEvent)) { return true; } + if (theEvent->type() == QEvent::KeyRelease) { + emit keyReleased(this, (QKeyEvent*) theEvent); + return true; + } } return QFrame::eventFilter(theObj, theEvent); }