#include "NewGeom_SalomeViewer.h"
#include "NewGeom_OCCSelector.h"
-#include <OCCViewer_ViewWindow.h>
#include <OCCViewer_ViewPort3d.h>
#include <OCCViewer_ViewFrame.h>
#include <QMouseEvent>
#include <QContextMenuEvent>
+NewGeom_SalomeView::NewGeom_SalomeView(OCCViewer_Viewer* theViewer)
+: ModuleBase_IViewWindow(), myCurrentView(0)
+{
+ myViewer = theViewer;
+}
+
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();
+ Handle(V3d_View) aView;
+ if (myCurrentView) {
+ OCCViewer_ViewWindow* aWnd = static_cast<OCCViewer_ViewWindow*>(myCurrentView);
+ aView = aWnd->getViewPort()->getView();
+ }
return aView;
}
+QWidget* NewGeom_SalomeView::viewPort() const
+{
+ QWidget* aViewPort = 0;
+ if (myCurrentView) {
+ OCCViewer_ViewWindow* aWnd = static_cast<OCCViewer_ViewWindow*>(myCurrentView);
+ aViewPort = aWnd->getViewPort();
+ }
+ return aViewPort;
+}
+
//**********************************************
//**********************************************
//**********************************************
}
//**********************************************
-void NewGeom_SalomeViewer::onMousePress(SUIT_ViewWindow*, QMouseEvent* theEvent)
+void NewGeom_SalomeViewer::onMousePress(SUIT_ViewWindow* theView, QMouseEvent* theEvent)
{
+ myView->setCurrentView(theView);
emit mousePress(myView, theEvent);
}
//**********************************************
-void NewGeom_SalomeViewer::onMouseRelease(SUIT_ViewWindow*, QMouseEvent* theEvent)
+void NewGeom_SalomeViewer::onMouseRelease(SUIT_ViewWindow* theView, QMouseEvent* theEvent)
{
+ myView->setCurrentView(theView);
emit mouseRelease(myView, theEvent);
if (myIsSelectionChanged) {
emit selectionChanged();
}
//**********************************************
-void NewGeom_SalomeViewer::onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent* theEvent)
+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())
+ 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)
{
}
//**********************************************
-void NewGeom_SalomeViewer::onViewCreated(SUIT_ViewWindow*)
+void NewGeom_SalomeViewer::onViewCreated(SUIT_ViewWindow* theView)
{
+ myView->setCurrentView(theView);
+
+ OCCViewer_ViewFrame* aView = dynamic_cast<OCCViewer_ViewFrame*>(theView);
+
+ OCCViewer_ViewWindow* aWnd = aView->getView(OCCViewer_ViewFrame::MAIN_VIEW);
+ if (aWnd)
+ connect(aWnd, SIGNAL(vpTransformationFinished(OCCViewer_ViewWindow::OperationType)),
+ this, SLOT(onViewTransformed(OCCViewer_ViewWindow::OperationType)));
+
emit viewCreated(myView);
}
//**********************************************
-void NewGeom_SalomeViewer::onActivated(SUIT_ViewWindow*)
+void NewGeom_SalomeViewer::onActivated(SUIT_ViewWindow* theView)
{
+ myView->setCurrentView(theView);
emit activated(myView);
}
//**********************************************
void NewGeom_SalomeViewer::enableSelection(bool isEnabled)
{
- //mySelector->viewer()->enableSelection(isEnabled);
+ if (mySelector)
+ mySelector->viewer()->enableSelection(isEnabled);
// The enableSelection() in SALOME 7.5 cause of forced Viewer update(we have blinking)
// After this is corrected, the first row should be recommented, the last - removed
- if (mySelector)
- mySelector->viewer()->setInteractionStyle(isEnabled ? SUIT_ViewModel::STANDARD
- : SUIT_ViewModel::KEY_FREE);
+ //mySelector->viewer()->setInteractionStyle(isEnabled ? SUIT_ViewModel::STANDARD
+ // : SUIT_ViewModel::KEY_FREE);
}
//**********************************************
aContext->UpdateCurrentViewer();
}
}
+
+//***************************************
+void NewGeom_SalomeViewer::onViewTransformed(OCCViewer_ViewWindow::OperationType theType)
+{
+ emit viewTransformed((int) theType);
+}