- //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* theView, QMouseEvent* theEvent)
+{
+ myView->setCurrentView(theView);
+ emit mousePress(myView, theEvent);
+}
+
+//**********************************************
+void NewGeom_SalomeViewer::onMouseRelease(SUIT_ViewWindow* theView, QMouseEvent* theEvent)
+{
+ myView->setCurrentView(theView);
+ emit mouseRelease(myView, theEvent);
+ if (myIsSelectionChanged) {
+ emit selectionChanged();
+ myIsSelectionChanged = false;
+ }
+}
+
+//**********************************************
+void NewGeom_SalomeViewer::onMouseDoubleClick(SUIT_ViewWindow* theView, QMouseEvent* theEvent)
+{
+ myView->setCurrentView(theView);
+ emit mouseDoubleClick(myView, theEvent);
+}
+
+//**********************************************
+void NewGeom_SalomeViewer::onMouseMove(SUIT_ViewWindow* theView, QMouseEvent* theEvent)
+{
+ myView->setCurrentView(theView);
+ OCCViewer_ViewWindow* aViewWnd = dynamic_cast<OCCViewer_ViewWindow*>(theView);
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext->HasDetected()) // Set focus to provide key events in the view
+ aViewWnd->getViewPort()->setFocus(Qt::MouseFocusReason);
+ emit mouseMove(myView, theEvent);
+}
+
+//**********************************************
+bool NewGeom_SalomeViewer::canDragByMouse() const
+{
+ OCCViewer_Viewer* aViewer = mySelector->viewer();
+ SUIT_ViewWindow* aWnd = aViewer->getViewManager()->getActiveView();
+ OCCViewer_ViewWindow* aViewWnd = dynamic_cast<OCCViewer_ViewWindow*>(aWnd);
+ if (aViewWnd) {
+ return (aViewWnd->interactionStyle() == 0);
+ }
+ return true;
+}
+
+
+//**********************************************
+void NewGeom_SalomeViewer::onKeyPress(SUIT_ViewWindow* theView, QKeyEvent* theEvent)
+{
+ OCCViewer_ViewWindow* aViewWnd = dynamic_cast<OCCViewer_ViewWindow*>(theView);
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ Handle(V3d_View) aView = aViewWnd->getViewPort()->getView();
+
+ bool noModifiers = (theEvent->modifiers() == Qt::NoModifier);
+ if ((theEvent->key() == Qt::Key_N) && noModifiers) {
+ aContext->HilightNextDetected(aView);
+ } else if ((theEvent->key() == Qt::Key_P) && noModifiers) {
+ aContext->HilightPreviousDetected(aView);
+ }
+ emit keyPress(myView, theEvent);
+}
+
+//**********************************************
+void NewGeom_SalomeViewer::onKeyRelease(SUIT_ViewWindow* theView, 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* theView)
+{
+ myView->setCurrentView(theView);
+ emit viewCreated(myView);
+}
+
+//**********************************************
+void NewGeom_SalomeViewer::onActivated(SUIT_ViewWindow*)
+{
+ emit activated(myView);
+}