]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #30 - Sketch base GUI: create, draw lines
authornds <natalia.donis@opencascade.com>
Tue, 29 Apr 2014 12:58:01 +0000 (16:58 +0400)
committernds <natalia.donis@opencascade.com>
Tue, 29 Apr 2014 12:58:01 +0000 (16:58 +0400)
The code is corrected by the 3D Viewer modification,
Call enable nested actions

src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketch.h
src/PartSet/PartSet_OperationSketchBase.h
src/PartSet/PartSet_OperationSketchLine.cpp
src/PartSet/PartSet_OperationSketchLine.h
src/XGUI/XGUI_ActionsMgr.h
src/XGUI/XGUI_Viewer.h
src/XGUI/XGUI_Workshop.h

index 5fb8796e0eedafb0be7ea2bf9e607af989b1f7a8..54472ed0a6ecda456a16ad56b7defaaefc68f48a 100644 (file)
@@ -14,6 +14,7 @@
 #include <XGUI_ViewWindow.h>
 #include <XGUI_SelectionMgr.h>
 #include <XGUI_ViewPort.h>
+#include <XGUI_ActionsMgr.h>
 
 #include <Config_PointerMessage.h>
 #include <Config_ModuleReader.h>
@@ -27,6 +28,7 @@
 #include <AIS_ListOfInteractive.hxx>
 
 #include <QObject>
+#include <QMouseEvent>
 #include <QString>
 
 #ifdef _DEBUG
@@ -51,10 +53,12 @@ PartSet_Module::PartSet_Module(XGUI_Workshop* theWshop)
   connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
           this, SLOT(onOperationStopped(ModuleBase_Operation*)));
   if (!myWorkshop->isSalomeMode()) {
-    connect(myWorkshop->mainWindow()->viewer(), SIGNAL(mouseReleased(QPoint)),
-            this, SLOT(onMouseReleased(QPoint)));
-    connect(myWorkshop->mainWindow()->viewer(), SIGNAL(mouseMoved(QPoint)),
-            this, SLOT(onMouseMoved(QPoint)));
+    XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
+    connect(aViewer, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
+    connect(aViewer, SIGNAL(mouseRelease(XGUI_ViewWindow*, QMouseEvent*)),
+            this, SLOT(onMouseReleased(XGUI_ViewWindow*, QMouseEvent*)));
+    connect(aViewer, SIGNAL(mouseMove(XGUI_ViewWindow*, QMouseEvent*)),
+            this, SLOT(onMouseMoved(XGUI_ViewWindow*, QMouseEvent*)));
   }
 }
 
@@ -135,8 +139,12 @@ void PartSet_Module::onOperationStarted()
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
   if (aPreviewOp) {
     visualizePreview(true);
-    connect(aPreviewOp, SIGNAL(viewerProjectionChange(double, double, double)),
-            this, SLOT(onViewerProjectionChange(double, double, double)));
+
+    PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
+    if (aSketchOp) {
+      connect(aSketchOp, SIGNAL(planeSelected(double, double, double)),
+              this, SLOT(onPlaneSelected(double, double, double)));
+    }
   }
 }
 
@@ -150,7 +158,7 @@ void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
     visualizePreview(false);
 }
 
-void PartSet_Module::onMouseReleased(QPoint thePoint)
+void PartSet_Module::onSelectionChanged()
 {
   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
@@ -159,20 +167,34 @@ void PartSet_Module::onMouseReleased(QPoint thePoint)
     if (aSelector) {
       NCollection_List<TopoDS_Shape> aList;
       aSelector->selectedShapes(aList);
+      aPreviewOp->setSelectedShapes(aList);
+    }
+  }
+}
+
+void PartSet_Module::onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent)
+{
+  QPoint aPoint = theEvent->pos();
+  ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
+  PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
+  if (aPreviewOp) {
+    XGUI_SelectionMgr* aSelector = myWorkshop->selector();
+    if (aSelector) {
       XGUI_ViewWindow* aWindow = myWorkshop->mainWindow()->viewer()->activeViewWindow();
       if (aWindow) {
         Handle(V3d_View) aView3d = aWindow->viewPort()->getView();
         if ( !aView3d.IsNull() ) {
-          gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(thePoint, aView3d);
-          aPreviewOp->setSelectedShapes(aList, aPoint);
+          gp_Pnt aPnt = PartSet_Tools::ConvertClickToPoint(aPoint, aView3d);
+          aPreviewOp->mouseReleased(aPnt);
         }
       }
     }
   }
 }
 
-void PartSet_Module::onMouseMoved(QPoint thePoint)
+void PartSet_Module::onMouseMoved(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent)
 {
+  QPoint aPoint = theEvent->pos();
   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
   if (aPreviewOp) {
@@ -182,20 +204,21 @@ void PartSet_Module::onMouseMoved(QPoint thePoint)
       if (aWindow) {
         Handle(V3d_View) aView3d = aWindow->viewPort()->getView();
         if ( !aView3d.IsNull() ) {
-          gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(thePoint, aView3d);
-          aPreviewOp->setMouseMovePoint(aPoint);
+          gp_Pnt aPnt = PartSet_Tools::ConvertClickToPoint(aPoint, aView3d);
+          aPreviewOp->mouseMoved(aPnt);
         }
       }
     }
   }
 }
 
-void PartSet_Module::onViewerProjectionChange(double theX, double theY, double theZ)
+void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
 {
   XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
   if (aViewer) {
     aViewer->setViewProjection(theX, theY, theZ);
   }
+  myWorkshop->actionsMgr()->setNestedActionsEnabled(true);
 }
 
 void PartSet_Module::visualizePreview(bool isDisplay)
index b71c7fb2e31140bb4618661809655ad7113744c2..ba120ea0940d858fc4f0210e96c93b685fd21a48 100644 (file)
@@ -11,6 +11,8 @@
 
 #include <string>
 
+class XGUI_ViewWindow;
+class QMouseEvent;
 class PartSet_Listener;
 
 class PARTSET_EXPORT PartSet_Module: public QObject, public XGUI_Module
@@ -40,19 +42,26 @@ public slots:
   /// SLOT, that is called after the operation is stopped. Disconnect the sketch feature
   /// from the viewer selection and show the sketch preview.
   void onOperationStopped(ModuleBase_Operation* theOperation);
+
   /// SLOT, that is called by the selection in the viewer is changed.
-  /// The selection is sent to the current operation if it listen the selection.
-  void onMouseReleased(QPoint thePoint);
+  /// The selection is sent to the current operation if it listens selection.
+  void onSelectionChanged();
+  /// SLOT, that is called by mouse click in the viewer.
+  /// The mouse released point is sent to the current operation to be processed.
+  /// \param theWindow the window where the signal appears
+  /// \param theEvent the mouse event
+  void onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
   /// SLOT, that is called by the selection in the viewer is changed.
-  /// The selection is sent to the current operation if it listen the selection.
-  /// \thePoint the mouse point
-  void onMouseMoved(QPoint thePoint);
+  /// The mouse moved point is sent to the current operation to be processed.
+  /// \param theWindow the window where the signal appears
+  /// \param theEvent the mouse event
+  void onMouseMoved(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
 
   /// SLOT, to apply to the current viewer the operation
   /// \param theX the X projection value
   /// \param theY the Y projection value
   /// \param theZ the Z projection value
-  void onViewerProjectionChange(double theX, double theY, double theZ);
+  void onPlaneSelected(double theX, double theY, double theZ);
 
 private:
   XGUI_Workshop* myWorkshop;
index 48bd5f0e34de92fe5da62a1c6b2285c64155bd27..cc5fad46cb8f74a7493bd2580a35c23135ff36c1 100644 (file)
@@ -35,8 +35,7 @@ int PartSet_OperationSketch::getSelectionMode() const
   return TopAbs_FACE;
 }
 
-void PartSet_OperationSketch::setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList,
-                                                const gp_Pnt& theSelectedPoint)
+void PartSet_OperationSketch::setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList)
 {
   if (theList.IsEmpty())
     return;
@@ -76,7 +75,7 @@ void PartSet_OperationSketch::setSelectedShapes(const NCollection_List<TopoDS_Sh
   aDirY->setValue(aC, anA, aB);
 
   boost::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
-  emit viewerProjectionChange(aDir->x(), aDir->y(), aDir->z());
+  emit planeSelected(aDir->x(), aDir->y(), aDir->z());
 
   //commit();
   //SketchPlugin_Sketch::setActive(myFeature);
index 021a8c8cdebf7981a3e5040880668d9188694126..5eb45b17e7318cb8d67e2934ff44063bc1a44299 100644 (file)
@@ -32,8 +32,14 @@ public:
   /// Gives the current selected objects to be processed by the operation
   /// \param theList a list of interactive selected shapes
   /// \param theSelectedPoint a point clidked in the viewer
-  virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList,
-                                 const gp_Pnt& theSelectedPoint);
+  virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList);
+
+signals:
+  /// signal about the sketch plane is selected
+  /// \param theX the value in the X direction of the plane
+  /// \param theX the value in the Y direction value of the plane
+  /// \param theX the value in the Z direction of the plane
+  void planeSelected(double theX, double theY, double theZ);
 };
 
 #endif
index 0e6c242635f6974a48ecbd587af7d503843a5e99..bcc3f3aa1a5e9f110ef679735ed8348e5a919074 100644 (file)
@@ -41,15 +41,15 @@ public:
 
   /// Gives the current selected objects to be processed by the operation
   /// \param theList a list of interactive selected shapes
-  /// \param theSelectedPoint a 3D selected point
-  virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList,
-                                 const gp_Pnt& thePoint) = 0;
-  /// Gives the current mouse point in the viewer
-  /// \param thePoint a point clidked in the viewer
-  virtual void setMouseMovePoint(const gp_Pnt& thePoint) {};
-
-signals:
-  void viewerProjectionChange(double theX, double theY, double theZ);
+  virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList) {};
+
+  /// Processes the mouse release in the point
+  /// \param thePoint a point clicked in the viewer
+  virtual void mouseReleased(const gp_Pnt& thePoint) {};
+
+  /// Processes the mouse move in the point
+  /// \param thePoint a 3D point clicked in the viewer
+  virtual void mouseMoved(const gp_Pnt& thePoint) {};
 };
 
 #endif
index 57d5f764603bcd745e2e55746595ae8f8b37caf7..6da4b71f5d25eb55a06da55d251f2cb08247635b 100644 (file)
@@ -38,12 +38,8 @@ int PartSet_OperationSketchLine::getSelectionMode() const
   return 0;//TopAbs_FACE;
 }
 
-void PartSet_OperationSketchLine::setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList,
-                                                    const gp_Pnt& thePoint)
+void PartSet_OperationSketchLine::mouseReleased(const gp_Pnt& thePoint)
 {
-  if (theList.IsEmpty())
-    return;
-
   switch (myPointSelectionMode)
   {
     case SM_FirstPoint: {
@@ -65,7 +61,7 @@ void PartSet_OperationSketchLine::setSelectedShapes(const NCollection_List<TopoD
   }
 }
 
-void PartSet_OperationSketchLine::setMouseMovePoint(const gp_Pnt& thePoint)
+void PartSet_OperationSketchLine::mouseMoved(const gp_Pnt& thePoint)
 {
   if (myPointSelectionMode == SM_SecondPoint)
     setLinePoint(thePoint, LINE_ATTR_END);
index 27a03a43f8af98192646aed69c014b04fe319ba3..a01220b102a77a2bb4123484da6062c09dc1ea97 100644 (file)
@@ -36,13 +36,11 @@ public:
   virtual int getSelectionMode() const;
 
   /// Gives the current selected objects to be processed by the operation
-  /// \param theList a list of interactive selected shapes
-  /// \param theSelectedPoint a point clidked in the viewer
-  virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList,
-                                 const gp_Pnt& thePoint);
+  /// \param thePoint a point clicked in the viewer
+  virtual void mouseReleased(const gp_Pnt& thePoint);
   /// Gives the current mouse point in the viewer
-  /// \param thePoint a point clidked in the viewer
-  virtual void setMouseMovePoint(const gp_Pnt& thePoint);
+  /// \param thePoint a point clicked in the viewer
+  virtual void mouseMoved(const gp_Pnt& thePoint);
 
 protected:
   /// \brief Virtual method called when operation is started
index d6c55d833ca7b87720107404be8267a1afd434c3..dd5ac36f7d593a6b79c9d2aa949bbd22fb088c60 100644 (file)
@@ -5,6 +5,8 @@
 #ifndef XGUI_ACTIONSMGR_H_
 #define XGUI_ACTIONSMGR_H_
 
+#include "XGUI.h"
+
 #include <QObject>
 #include <QMap>
 #include <QStringList>
@@ -12,7 +14,7 @@
 class XGUI_Command;
 class QAction;
 
-class XGUI_ActionsMgr: public QObject
+class XGUI_EXPORT XGUI_ActionsMgr: public QObject
 {
   Q_OBJECT
 
index b422e4034432576fb6f54861c0f180a1be0c78b9..466951c7ab0342c00e199fb3d1687963ea1eed6e 100644 (file)
@@ -149,8 +149,6 @@ signals:
   void keyRelease(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent);
   void activated(XGUI_ViewWindow* theWindow);
   void selectionChanged();
-  //void mouseReleased(QPoint thePoint);
-  //void mouseMoved(QPoint thePoint);
 
 public slots:
   void onWindowMinimized(QMdiSubWindow*);
index 3f857ff12400d7f12e68d8f34869a788b504ac65..41ac3b14420d9b6dac365184cb1227befd83aefb 100644 (file)
@@ -59,6 +59,9 @@ public:
   //! ! Returns operation manager.
   XGUI_OperationMgr* operationMgr() const { return myOperationMgr; }
 
+  //! ! Returns an actions manager
+  XGUI_ActionsMgr* actionsMgr() const { return myActionsMgr; };
+
   //! Creates and adds a new workbench (menu group) with the given name and returns it
   XGUI_Workbench* addWorkbench(const QString& theName);