]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #30 - Sketch base GUI: create, draw lines
authornds <natalia.donis@opencascade.com>
Wed, 30 Apr 2014 10:52:25 +0000 (14:52 +0400)
committernds <natalia.donis@opencascade.com>
Wed, 30 Apr 2014 10:52:25 +0000 (14:52 +0400)
Contour of some lines creation.

src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationSketchBase.h
src/PartSet/PartSet_OperationSketchLine.cpp
src/PartSet/PartSet_OperationSketchLine.h
src/XGUI/XGUI_ViewWindow.cpp

index 8bcafffef7f617994bc123ada88dd7912ce5192d..5826a3493c5711295fe0e4bcdd8ac69dcc1b8aff 100644 (file)
@@ -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<PartSet_OperationSketchBase*>(anOperation);
+  if (aPreviewOp) {
+    aPreviewOp->keyReleased(theEvent->key());
+  }
+}
+
 void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
 {
   XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
index ea7d30e4dac0997544fc34b33fece681e758cb6a..7e8190eb16755222d7d0290f4bf5c0d2a6ee8963 100644 (file)
@@ -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
index e5aa868a398f1afb38bf98482998d0ba68d0ca2c..48aa06c840fc0878d6b496543f17a92d0b1af7c1 100644 (file)
@@ -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
index b76a73084afa3fa30c2534209415203dc7f374eb..5bc516c3954a89c2fb15789086d9b229f02a7627 100644 (file)
@@ -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();
index 3e07b82b8a510b0663c6c2f0d5591360e092c8d7..86b1eacebc7cb3b9cb6b2a9a20bb728915543dda 100644 (file)
@@ -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
index 2c4809cb86d9af4f5c7511f479e2114926395a51..12c92e6fa62cfeae5fd87963ae58f66c41519dd0 100644 (file)
@@ -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);
 }