From 4d174a6caccb8530b4b0724a891ec20621a9da95 Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 25 Jun 2015 10:35:32 +0300 Subject: [PATCH] Issue #632: Activate/Deactivate zoom tracking on activation/deactivation of module --- src/NewGeom/NewGeom_Module.cpp | 3 ++- src/NewGeom/NewGeom_SalomeViewer.cpp | 24 ++++++++++++++++++++++++ src/NewGeom/NewGeom_SalomeViewer.h | 4 ++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/NewGeom/NewGeom_Module.cpp b/src/NewGeom/NewGeom_Module.cpp index 547ed1ab5..16dc0216c 100644 --- a/src/NewGeom/NewGeom_Module.cpp +++ b/src/NewGeom/NewGeom_Module.cpp @@ -215,13 +215,14 @@ bool NewGeom_Module::activateModule(SUIT_Study* theStudy) } Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); } - + myProxyViewer->activateViewer(true); return isDone; } //****************************************************** bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy) { + myProxyViewer->activateViewer(false); setMenuShown(false); setToolShown(false); diff --git a/src/NewGeom/NewGeom_SalomeViewer.cpp b/src/NewGeom/NewGeom_SalomeViewer.cpp index 4539bbdbc..deb172331 100644 --- a/src/NewGeom/NewGeom_SalomeViewer.cpp +++ b/src/NewGeom/NewGeom_SalomeViewer.cpp @@ -356,3 +356,27 @@ void NewGeom_SalomeViewer::onViewTransformed(OCCViewer_ViewWindow::OperationType { emit viewTransformed((int) theType); } + +//*************************************** +void NewGeom_SalomeViewer::activateViewer(bool toActivate) +{ + if (!mySelector || !mySelector->viewer()) + return; + SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager(); + QVector aViews = aMgr->getViews(); + if (toActivate) { + foreach (SUIT_ViewWindow* aView, aViews) { + OCCViewer_ViewFrame* aOCCView = dynamic_cast(aView); + OCCViewer_ViewWindow* aWnd = aOCCView->getView(OCCViewer_ViewFrame::MAIN_VIEW); + connect(aWnd, SIGNAL(vpTransformationFinished(OCCViewer_ViewWindow::OperationType)), + this, SLOT(onViewTransformed(OCCViewer_ViewWindow::OperationType))); + } + } else { + foreach (SUIT_ViewWindow* aView, aViews) { + OCCViewer_ViewFrame* aOCCView = dynamic_cast(aView); + OCCViewer_ViewWindow* aWnd = aOCCView->getView(OCCViewer_ViewFrame::MAIN_VIEW); + disconnect((OCCViewer_ViewWindow*)aWnd, SIGNAL(vpTransformationFinished(OCCViewer_ViewWindow::OperationType)), + this, SLOT(onViewTransformed(OCCViewer_ViewWindow::OperationType))); + } + } +} \ No newline at end of file diff --git a/src/NewGeom/NewGeom_SalomeViewer.h b/src/NewGeom/NewGeom_SalomeViewer.h index b02058daa..56a456bb4 100644 --- a/src/NewGeom/NewGeom_SalomeViewer.h +++ b/src/NewGeom/NewGeom_SalomeViewer.h @@ -126,6 +126,10 @@ Q_OBJECT /// by mouse drugging. If this is impossible thet it has to return False. virtual bool canDragByMouse() const; + /// Activate or deactivate viewer + /// \param toActivate - activation flag + void activateViewer(bool toActivate); + private slots: void onMousePress(SUIT_ViewWindow*, QMouseEvent*); void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*); -- 2.39.2