]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Porting of the new operations on SALOME
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 28 Nov 2014 09:21:24 +0000 (12:21 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 28 Nov 2014 09:21:24 +0000 (12:21 +0300)
src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp
src/NewGeom/NewGeom_SalomeViewer.cpp
src/NewGeom/NewGeom_SalomeViewer.h
src/PartSet/PartSet_WidgetPoint2d.cpp
src/XGUI/XGUI_ViewerProxy.cpp

index 211363d1661920c52520516f3498ec36407b4075..0f1f100642c2c51852f2c9da0ed3b7da283cdb6d 100644 (file)
@@ -46,6 +46,7 @@
 #include <QString>
 #include <QEvent>
 #include <QDockWidget>
+#include <QApplication>
 
 #include <TopExp_Explorer.hxx>
 #include <TopoDS_Shape.hxx>
@@ -258,7 +259,6 @@ void ModuleBase_WidgetShapeSelector::onSelectionChanged()
         return;
     }
     setObject(aObject, aShape);
-    //activateSelection(false);
     emit focusOutWidget(this);
   }
 }
@@ -272,7 +272,6 @@ void ModuleBase_WidgetShapeSelector::setObject(ObjectPtr theObj, std::shared_ptr
     raisePanel();
   } 
   updateSelectionName();
-  //activateSelection(false);
   emit valuesChanged();
 }
 
index ed2764138491bdf65be5d0c1aea6684fa8d65b57..ef6d6c539b87bca1b16f6a6850c9a54f12a3bc41 100644 (file)
 #include <QMouseEvent>
 #include <QContextMenuEvent>
 
+
+Handle(V3d_View) NewGeom_SalomeView::v3dView() const
+{
+  SUIT_ViewManager* aMgr = myViewer->getViewManager();
+  OCCViewer_ViewWindow* aWnd = static_cast<OCCViewer_ViewWindow*>(aMgr->getActiveView());
+  Handle(V3d_View) aView = aWnd->getViewPort()->getView();
+  return aView;
+}
+
+//**********************************************
+//**********************************************
+//**********************************************
+
+
+
 NewGeom_SalomeViewer::NewGeom_SalomeViewer(QObject* theParent)
     : ModuleBase_IViewer(theParent),
-      mySelector(0)
+      mySelector(0), myView(0), myIsSelectionChanged(false)
+{
+}
+
+NewGeom_SalomeViewer::~NewGeom_SalomeViewer()
 {
+  if (myView)
+    delete myView;
 }
 
+
 //**********************************************
 Handle(AIS_InteractiveContext) NewGeom_SalomeViewer::AISContext() const
 {
@@ -59,64 +81,107 @@ void NewGeom_SalomeViewer::setSelector(NewGeom_OCCSelector* theSel)
   OCCViewer_Viewer* aViewer = mySelector->viewer();
   SUIT_ViewManager* aMgr = aViewer->getViewManager();
 
+  myView = new NewGeom_SalomeView(mySelector->viewer());
+
   // TODO: Provide ModuleBase_IViewWindow interface
-  //connect(aMgr, SIGNAL(lastViewClosed(SUIT_ViewManager*)), this, SIGNAL(lastViewClosed()));
-  //connect(aMgr, SIGNAL(tryCloseView(SUIT_ViewManager*)), this, SIGNAL(tryCloseView()));
-  //connect(aMgr, SIGNAL(deleteView(SUIT_ViewManager*)), this, SIGNAL(deleteView()));
-  //connect(aMgr, SIGNAL(viewCreated(SUIT_ViewManager*)), this, SIGNAL(viewCreated()));
-  //connect(aMgr, SIGNAL(activated(SUIT_ViewManager*)), this, SIGNAL(activated()));
-
-  //connect(aMgr, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), this,
-  //        SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*)));
-  //connect(aMgr, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), this,
-  //        SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*)));
-  //connect(aMgr, SIGNAL(mouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*)), this,
-  //        SLOT(onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*)));
-  //connect(aMgr, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)), this,
-  //        SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*)));
-  //connect(aMgr, SIGNAL(keyPress(SUIT_ViewWindow*, QKeyEvent*)), this,
-  //        SLOT(onKeyPress(SUIT_ViewWindow*, QKeyEvent*)));
-  //connect(aMgr, SIGNAL(keyRelease(SUIT_ViewWindow*, QKeyEvent*)), this,
-  //        SLOT(onKeyRelease(SUIT_ViewWindow*, QKeyEvent*)));
-
-  //connect(aViewer, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
-}
-
-//**********************************************
-//void NewGeom_SalomeViewer::onMousePress(SUIT_ViewWindow*, QMouseEvent* theEvent)
-//{
-//  emit mousePress(theEvent);
-//}
-//
-////**********************************************
-//void NewGeom_SalomeViewer::onMouseRelease(SUIT_ViewWindow*, QMouseEvent* theEvent)
-//{
-//  emit mouseRelease(theEvent);
-//}
-//
-////**********************************************
-//void NewGeom_SalomeViewer::onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent* theEvent)
-//{
-//  emit mouseDoubleClick(theEvent);
-//}
-//
-////**********************************************
-//void NewGeom_SalomeViewer::onMouseMove(SUIT_ViewWindow*, QMouseEvent* theEvent)
-//{
-//  emit mouseMove(theEvent);
-//}
-//
-////**********************************************
-//void NewGeom_SalomeViewer::onKeyPress(SUIT_ViewWindow*, QKeyEvent* theEvent)
-//{
-//  emit keyPress(theEvent);
-//}
-//
-////**********************************************
-//void NewGeom_SalomeViewer::onKeyRelease(SUIT_ViewWindow*, QKeyEvent* theEvent)
-//{
-//  emit keyRelease(theEvent);
-//}
+  connect(aMgr, SIGNAL(lastViewClosed(SUIT_ViewManager*)), this, SIGNAL(lastViewClosed()));
+
+  connect(aMgr, SIGNAL(tryCloseView(SUIT_ViewWindow*)), 
+          this, SLOT(onTryCloseView(SUIT_ViewWindow*)));
+  connect(aMgr, SIGNAL(deleteView(SUIT_ViewWindow*)), 
+          this, SLOT(onDeleteView(SUIT_ViewWindow*)));
+  connect(aMgr, SIGNAL(viewCreated(SUIT_ViewWindow*)), 
+          this, SLOT(onViewCreated(SUIT_ViewWindow*)));
+  connect(aMgr, SIGNAL(activated(SUIT_ViewWindow*)), 
+          this, SLOT(onActivated(SUIT_ViewWindow*)));
+
+  connect(aMgr, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), this,
+          SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*)));
+  connect(aMgr, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), this,
+          SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*)));
+  connect(aMgr, SIGNAL(mouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*)), this,
+          SLOT(onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*)));
+  connect(aMgr, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)), this,
+          SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*)));
+
+  connect(aMgr, SIGNAL(keyPress(SUIT_ViewWindow*, QKeyEvent*)), this,
+          SLOT(onKeyPress(SUIT_ViewWindow*, QKeyEvent*)));
+  connect(aMgr, SIGNAL(keyRelease(SUIT_ViewWindow*, QKeyEvent*)), this,
+          SLOT(onKeyRelease(SUIT_ViewWindow*, QKeyEvent*)));
+
+  connect(aViewer, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
+}
+
+//**********************************************
+void NewGeom_SalomeViewer::onSelectionChanged()
+{
+  // Selection event must be sent only after mouse release
+  myIsSelectionChanged = true;
+}
+
+//**********************************************
+void NewGeom_SalomeViewer::onMousePress(SUIT_ViewWindow*, QMouseEvent* theEvent)
+{
+  emit mousePress(myView, theEvent);
+}
+
+//**********************************************
+void NewGeom_SalomeViewer::onMouseRelease(SUIT_ViewWindow*, QMouseEvent* theEvent)
+{
+  emit mouseRelease(myView, theEvent);
+  if (myIsSelectionChanged) {
+    emit selectionChanged();
+    myIsSelectionChanged = false;
+  }
+}
+
+//**********************************************
+void NewGeom_SalomeViewer::onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent* theEvent)
+{
+  emit mouseDoubleClick(myView, theEvent);
+}
+
+//**********************************************
+void NewGeom_SalomeViewer::onMouseMove(SUIT_ViewWindow*, QMouseEvent* theEvent)
+{
+  emit mouseMove(myView, theEvent);
+}
+
+//**********************************************
+void NewGeom_SalomeViewer::onKeyPress(SUIT_ViewWindow*, QKeyEvent* theEvent)
+{
+  emit keyPress(myView, theEvent);
+}
+
+//**********************************************
+void NewGeom_SalomeViewer::onKeyRelease(SUIT_ViewWindow*, QKeyEvent* theEvent)
+{
+  emit keyRelease(myView, theEvent);
+}
+
+//**********************************************
+void NewGeom_SalomeViewer::onTryCloseView(SUIT_ViewWindow*)
+{
+  emit tryCloseView(myView);
+}
+
+//**********************************************
+void NewGeom_SalomeViewer::onDeleteView(SUIT_ViewWindow*)
+{
+  emit deleteView(myView);
+}
+
+//**********************************************
+void NewGeom_SalomeViewer::onViewCreated(SUIT_ViewWindow*)
+{
+  emit viewCreated(myView);
+}
+
+//**********************************************
+void NewGeom_SalomeViewer::onActivated(SUIT_ViewWindow*)
+{
+  emit activated(myView);
+}
 
 //**********************************************
 void NewGeom_SalomeViewer::enableSelection(bool isEnabled)
index c0d1ec6ce7008a2a24c40396520ad68ede17f7d3..8362a7d1ec72ce8d2e62c0bbc54739a45e25451e 100644 (file)
@@ -5,12 +5,33 @@
 #include "NewGeom.h"
 
 #include <ModuleBase_IViewer.h>
+#include <ModuleBase_IViewWindow.h>
+
+#include <V3d_View.hxx>
 
 class SUIT_ViewWindow;
 class QMouseEvent;
 class QKeyEvent;
 
 class NewGeom_OCCSelector;
+class OCCViewer_Viewer;
+class SUIT_ViewManager;
+
+
+class NewGeom_SalomeView: public ModuleBase_IViewWindow
+{
+public:
+  NewGeom_SalomeView(OCCViewer_Viewer* theViewer) { myViewer = theViewer; }
+
+  virtual Handle(V3d_View) v3dView() const;
+
+  void setViewer(OCCViewer_Viewer* theViewer) { myViewer = theViewer; }
+  OCCViewer_Viewer* viewer() const { return myViewer; }
+
+private:
+  OCCViewer_Viewer* myViewer;
+};
+
 
 class NewGeom_SalomeViewer : public ModuleBase_IViewer
 {
@@ -18,6 +39,8 @@ Q_OBJECT
  public:
   NewGeom_SalomeViewer(QObject* theParent);
 
+  ~NewGeom_SalomeViewer();
+
   //! Returns AIS_InteractiveContext from current OCCViewer
   virtual Handle(AIS_InteractiveContext) AISContext() const;
 
@@ -65,17 +88,25 @@ Q_OBJECT
   }
 
  private slots:
-  // TODO: Provide ModuleBase_IViewWindow interface
-  //void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
-  //void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
-  //void onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*);
-  //void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
-  //void onKeyPress(SUIT_ViewWindow*, QKeyEvent*);
-  //void onKeyRelease(SUIT_ViewWindow*, QKeyEvent*);
+  void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
+  void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
+  void onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*);
+  void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
+  void onKeyPress(SUIT_ViewWindow*, QKeyEvent*);
+  void onKeyRelease(SUIT_ViewWindow*, QKeyEvent*);
+
+  void onTryCloseView(SUIT_ViewWindow*);
+  void onDeleteView(SUIT_ViewWindow*);
+  void onViewCreated(SUIT_ViewWindow*);
+  void onActivated(SUIT_ViewWindow*);
+
+  void onSelectionChanged();
 
  private:
   NewGeom_OCCSelector* mySelector;
-
+  NewGeom_SalomeView* myView;
+  bool myIsSelectionChanged;
 };
 
+
 #endif
index 1fc77dc99a0cde51a435936f3526479b6e244bce..70b21db9e94daccf88bb3d40b2bcbb107308b0bd 100644 (file)
@@ -33,6 +33,7 @@
 #include <QLabel>
 #include <QEvent>
 #include <QMouseEvent>
+#include <QApplication>
 
 #include <TopoDS.hxx>
 #include <TopoDS_Vertex.hxx>
@@ -231,6 +232,7 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous
           PartSet_Tools::convertTo2D(aPoint, mySketch, theWnd->v3dView(), aX, aY);
           setPoint(aX, aY);
           emit vertexSelected(aObjects.front(), aShape);
+          QApplication::processEvents();
           emit focusOutWidget(this);
           return;
         }
index 6e619156dbd2ee90e066d1e0f25feab7aeba0489..747dec2455b3797cd49a47be352668525345f90b 100644 (file)
@@ -68,23 +68,35 @@ void XGUI_ViewerProxy::connectToViewer()
     ModuleBase_IViewer* aViewer = myWorkshop->salomeConnector()->viewer();
 
     connect(aViewer, SIGNAL(lastViewClosed()), this, SIGNAL(lastViewClosed()));
-    connect(aViewer, SIGNAL(tryCloseView()), this, SIGNAL(tryCloseView()));
-    connect(aViewer, SIGNAL(deleteView()), this, SIGNAL(deleteView()));
-    connect(aViewer, SIGNAL(viewCreated()), this, SIGNAL(viewCreated()));
-    connect(aViewer, SIGNAL(activated()), this, SIGNAL(activated()));
+    connect(aViewer, SIGNAL(tryCloseView(ModuleBase_IViewWindow*)), 
+      this, SIGNAL(tryCloseView(ModuleBase_IViewWindow*)));
 
-    connect(aViewer, SIGNAL(mousePress(QMouseEvent*)), this, SIGNAL(mousePress(QMouseEvent*)));
+    connect(aViewer, SIGNAL(deleteView(ModuleBase_IViewWindow*)), 
+      this, SIGNAL(deleteView(ModuleBase_IViewWindow*)));
 
-    connect(aViewer, SIGNAL(mouseRelease(QMouseEvent*)), this, SIGNAL(mouseRelease(QMouseEvent*)));
+    connect(aViewer, SIGNAL(viewCreated(ModuleBase_IViewWindow*)), 
+      this, SIGNAL(viewCreated(ModuleBase_IViewWindow*)));
 
-    connect(aViewer, SIGNAL(mouseDoubleClick(QMouseEvent*)), this,
-            SIGNAL(mouseDoubleClick(QMouseEvent*)));
+    connect(aViewer, SIGNAL(activated(ModuleBase_IViewWindow*)), 
+      this, SIGNAL(activated(ModuleBase_IViewWindow*)));
 
-    connect(aViewer, SIGNAL(mouseMove(QMouseEvent*)), this, SIGNAL(mouseMove(QMouseEvent*)));
+    connect(aViewer, SIGNAL(mousePress(ModuleBase_IViewWindow*, QMouseEvent*)), 
+      this, SIGNAL(mousePress(ModuleBase_IViewWindow*, QMouseEvent*)));
 
-    connect(aViewer, SIGNAL(keyPress(QKeyEvent*)), this, SIGNAL(keyPress(QKeyEvent*)));
+    connect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)), 
+      this, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)));
 
-    connect(aViewer, SIGNAL(keyRelease(QKeyEvent*)), this, SIGNAL(keyRelease(QKeyEvent*)));
+    connect(aViewer, SIGNAL(mouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)), this,
+            SIGNAL(mouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)));
+
+    connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)), 
+      this, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
+
+    connect(aViewer, SIGNAL(keyPress(ModuleBase_IViewWindow*, QKeyEvent*)), 
+      this, SIGNAL(keyPress(ModuleBase_IViewWindow*, QKeyEvent*)));
+
+    connect(aViewer, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)), 
+      this, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)));
 
     connect(aViewer, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
     connect(aViewer, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this,