]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Connect from SALOME to Sketcher (ref #31)
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 30 Apr 2014 12:38:56 +0000 (16:38 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 30 Apr 2014 12:38:56 +0000 (16:38 +0400)
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/XGUI/XGUI_Viewer.cpp
src/XGUI/XGUI_Viewer.h
src/XGUI/XGUI_ViewerProxy.cpp
src/XGUI/XGUI_ViewerProxy.h

index 5826a3493c5711295fe0e4bcdd8ac69dcc1b8aff..13f3c8635e6a5aa7dc108f089b71cc3c6fbd7473 100644 (file)
 #include <XGUI_Viewer.h>
 #include <XGUI_Workshop.h>
 #include <XGUI_OperationMgr.h>
-#include <XGUI_ViewWindow.h>
 #include <XGUI_SelectionMgr.h>
 #include <XGUI_ViewPort.h>
 #include <XGUI_ActionsMgr.h>
+#include <XGUI_ViewerProxy.h>
 
 #include <Config_PointerMessage.h>
 #include <Config_ModuleReader.h>
@@ -52,16 +52,15 @@ PartSet_Module::PartSet_Module(XGUI_Workshop* theWshop)
   connect(anOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted()));
   connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
           this, SLOT(onOperationStopped(ModuleBase_Operation*)));
-  if (!myWorkshop->isSalomeMode()) {
-    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*)));
-    connect(aViewer, SIGNAL(keyRelease(XGUI_ViewWindow*, QKeyEvent*)),
-            this, SLOT(onKeyRelease(XGUI_ViewWindow*, QKeyEvent*)));
-  }
+
+  connect(myWorkshop->selector(), SIGNAL(selectionChanged()), 
+          this, SLOT(onSelectionChanged()));
+  connect(myWorkshop->viewer(), SIGNAL(mouseRelease(QMouseEvent*)),
+          this, SLOT(onMouseReleased(QMouseEvent*)));
+  connect(myWorkshop->viewer(), SIGNAL(mouseMove(QMouseEvent*)),
+          this, SLOT(onMouseMoved(QMouseEvent*)));
+  connect(myWorkshop->viewer(), SIGNAL(keyRelease(QKeyEvent*)),
+          this, SLOT(onKeyRelease(QKeyEvent*)));
 }
 
 PartSet_Module::~PartSet_Module()
@@ -177,7 +176,7 @@ void PartSet_Module::onSelectionChanged()
   }
 }
 
-void PartSet_Module::onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent)
+void PartSet_Module::onMouseReleased(QMouseEvent* theEvent)
 {
   QPoint aPoint = theEvent->pos();
   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
@@ -185,39 +184,30 @@ void PartSet_Module::onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* th
   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 aPnt = PartSet_Tools::ConvertClickToPoint(aPoint, aView3d);
-          aPreviewOp->mouseReleased(aPnt);
-        }
+      Handle(V3d_View) aView3d = myWorkshop->viewer()->activeView();
+      if ( !aView3d.IsNull() ) {
+        gp_Pnt aPnt = PartSet_Tools::ConvertClickToPoint(aPoint, aView3d);
+        aPreviewOp->mouseReleased(aPnt);
       }
     }
   }
 }
 
-void PartSet_Module::onMouseMoved(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent)
+void PartSet_Module::onMouseMoved(QMouseEvent* theEvent)
 {
   QPoint aPoint = theEvent->pos();
   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
   if (aPreviewOp) {
-    XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
-    if (aViewer) {
-      XGUI_ViewWindow* aWindow = aViewer->activeViewWindow();
-      if (aWindow) {
-        Handle(V3d_View) aView3d = aWindow->viewPort()->getView();
-        if ( !aView3d.IsNull() ) {
-          gp_Pnt aPnt = PartSet_Tools::ConvertClickToPoint(aPoint, aView3d);
-          aPreviewOp->mouseMoved(aPnt);
-        }
-      }
+    Handle(V3d_View) aView3d = myWorkshop->viewer()->activeView();
+    if ( !aView3d.IsNull() ) {
+      gp_Pnt aPnt = PartSet_Tools::ConvertClickToPoint(aPoint, aView3d);
+      aPreviewOp->mouseMoved(aPnt);
     }
   }
 }
 
-void PartSet_Module::onKeyRelease(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent)
+void PartSet_Module::onKeyRelease(QKeyEvent* theEvent)
 {
   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
@@ -228,10 +218,7 @@ void PartSet_Module::onKeyRelease(XGUI_ViewWindow* theWindow, QKeyEvent* theEven
 
 void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
 {
-  XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
-  if (aViewer) {
-    aViewer->setViewProjection(theX, theY, theZ);
-  }
+  myWorkshop->viewer()->setViewProjection(theX, theY, theZ);
 
   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
   if (anOperation) {
index 7e8190eb16755222d7d0290f4bf5c0d2a6ee8963..a67b8d038633c2ec2d084c0798a160bf91839590 100644 (file)
@@ -13,7 +13,6 @@
 
 #include <boost/shared_ptr.hpp>
 
-class XGUI_ViewWindow;
 class QMouseEvent;
 class QKeyEvent;
 class PartSet_Listener;
@@ -53,19 +52,16 @@ public slots:
   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);
+  void onMouseReleased(QMouseEvent* theEvent);
   /// SLOT, that is called by the selection in the viewer is changed.
   /// 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);
+  void onMouseMoved(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*);
+  void onKeyRelease(QKeyEvent*);
 
   /// SLOT, to apply to the current viewer the operation
   /// \param theX the X projection value
index 20436bfbd30681390e053b80b3ec287c44d053c1..7e53ec0e7c1ce977601d41855ca103c66ba71353 100644 (file)
@@ -247,17 +247,6 @@ void XGUI_Viewer::getHotButton(XGUI::InteractionStyle theInteractionStyle,
   theButton = myButtonMap[theInteractionStyle][theOper];
 }
 
-void XGUI_Viewer::setViewProjection(double theX, double theY, double theZ)
-{
-  XGUI_ViewWindow* aWindow = dynamic_cast<XGUI_ViewWindow*>(myActiveView->widget());
-  if (aWindow) {
-    Handle(V3d_View) aView3d = aWindow->viewPort()->getView();
-    if ( !aView3d.IsNull() ) 
-      aView3d->SetProj(theX, theY, theZ);
-    aWindow->viewPort()->fitAll();
-  }
-}
-
 /*!
  Changes visibility of trihedron to opposite
  */
index 466951c7ab0342c00e199fb3d1687963ea1eed6e..9222827f36e5374df07e654678215aeb146b4182 100644 (file)
@@ -121,12 +121,6 @@ public:
   static void getHotButton(XGUI::InteractionStyle theInteractionStyle, XGUI::HotOperation theOper,
                            Qt::KeyboardModifiers& theState, Qt::MouseButtons& theButton);
 
-  //! Sets the view projection
-  /// \param theX the X projection value
-  /// \param theY the Y projection value
-  /// \param theZ the Z projection value
-  void setViewProjection(double theX, double theY, double theZ);
-
   typedef QMap<XGUI::HotOperation, Qt::KeyboardModifiers> StatesMap;
   typedef QMap<XGUI::HotOperation, Qt::MouseButtons> ButtonsMap;
 
index ff95ecff63b1e5ade0f9a4b3d83a76d693f01688..b39b1ce97946f3193ded0fde8140549a393ee512 100644 (file)
@@ -41,6 +41,17 @@ Handle(V3d_View) XGUI_ViewerProxy::activeView() const
   }
 }
  
+void XGUI_ViewerProxy::setViewProjection(double theX, double theY, double theZ)
+{
+  Handle(V3d_View) aView3d = activeView();
+  if ( !aView3d.IsNull() ) {
+    aView3d->SetProj(theX, theY, theZ);
+    aView3d->FitAll( 0.01, true, true );
+    aView3d->SetZSize(0.);
+  }
+}
+
+
 void XGUI_ViewerProxy::connectToViewer()
 {
   if (myWorkshop->isSalomeMode()) {
@@ -57,18 +68,23 @@ void XGUI_ViewerProxy::connectToViewer()
     connect(aViewer, SIGNAL(activated()),
             this, SIGNAL(activated()));
 
-    connect(aViewer, SIGNAL(mousePress(QMouseEvent* theEvent)),
-            this, SIGNAL(mousePress(QMouseEvent* theEvent)));
-    connect(aViewer, SIGNAL(mouseRelease(QMouseEvent* theEvent)),
-            this, SIGNAL(mouseRelease(QMouseEvent* theEvent)));
-    connect(aViewer, SIGNAL(mouseDoubleClick(QMouseEvent* theEvent)),
-            this, SIGNAL(mouseDoubleClick(QMouseEvent* theEvent)));
-    connect(aViewer, SIGNAL(mouseMove(QMouseEvent* theEvent)),
-            this, SIGNAL(mouseMove(QMouseEvent* theEvent)));
-    connect(aViewer, SIGNAL(keyPress(QKeyEvent* theEvent)),
-            this, SIGNAL(keyPress(QKeyEvent* theEvent)));
-    connect(aViewer, SIGNAL(keyRelease(QKeyEvent* theEvent)),
-            this, SIGNAL(keyRelease(QKeyEvent* theEvent)));
+    connect(aViewer, SIGNAL(mousePress(QMouseEvent*)),
+            this, SIGNAL(mousePress(QMouseEvent*)));
+
+    connect(aViewer, SIGNAL(mouseRelease(QMouseEvent*)),
+            this, SIGNAL(mouseRelease(QMouseEvent*)));
+    
+    connect(aViewer, SIGNAL(mouseDoubleClick(QMouseEvent*)),
+            this, SIGNAL(mouseDoubleClick(QMouseEvent*)));
+    
+    connect(aViewer, SIGNAL(mouseMove(QMouseEvent*)),
+            this, SIGNAL(mouseMove(QMouseEvent*)));
+    
+    connect(aViewer, SIGNAL(keyPress(QKeyEvent*)),
+            this, SIGNAL(keyPress(QKeyEvent*)));
+    
+    connect(aViewer, SIGNAL(keyRelease(QKeyEvent*)),
+            this, SIGNAL(keyRelease(QKeyEvent*)));
   } else {
     XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
 
index 7d26c492438eda38740cd7fa357cfc6ce5474c8a..17d0bb8c4cd2cd8a85a31982e16dadb870f31880 100644 (file)
@@ -13,7 +13,7 @@ class XGUI_ViewWindow;
 * It is reccomennded to use this class in operation for accessing to viewer 
 * functionality instead of direct access to a viewer
 */
-class XGUI_ViewerProxy: public XGUI_SalomeViewer
+class XGUI_EXPORT XGUI_ViewerProxy: public XGUI_SalomeViewer
 {
   Q_OBJECT
 public:
@@ -28,6 +28,13 @@ public:
   //! Returns Vsd_View object from currently active view window
   virtual Handle(V3d_View) activeView() const;
 
+  //! Sets the view projection
+  /// \param theX the X projection value
+  /// \param theY the Y projection value
+  /// \param theZ the Z projection value
+  void setViewProjection(double theX, double theY, double theZ);
+
+  /// Connects to a viewer according to current environment
   void connectToViewer();
 
 private slots: