From: vsv Date: Fri, 26 Jun 2015 13:58:30 +0000 (+0300) Subject: Issue #676: ZFitall for display new object X-Git-Tag: V_1.3.0~177 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a63f4aea8cf064bae8339c926584316f218d98d5;p=modules%2Fshaper.git Issue #676: ZFitall for display new object --- diff --git a/src/ModuleBase/ModuleBase_IViewer.h b/src/ModuleBase/ModuleBase_IViewer.h index b08d49e72..5c62cb5fa 100644 --- a/src/ModuleBase/ModuleBase_IViewer.h +++ b/src/ModuleBase/ModuleBase_IViewer.h @@ -89,6 +89,9 @@ Q_OBJECT /// by mouse drugging. If this is impossible thet it has to return False. virtual bool canDragByMouse() const { return true; } + // Fit all along Z (perpendicular to display) + virtual void Zfitall() = 0; + signals: /// Signal emited when last view window is closed void lastViewClosed(); diff --git a/src/NewGeom/NewGeom_SalomeViewer.cpp b/src/NewGeom/NewGeom_SalomeViewer.cpp index deb172331..a9b806519 100644 --- a/src/NewGeom/NewGeom_SalomeViewer.cpp +++ b/src/NewGeom/NewGeom_SalomeViewer.cpp @@ -379,4 +379,16 @@ void NewGeom_SalomeViewer::activateViewer(bool toActivate) this, SLOT(onViewTransformed(OCCViewer_ViewWindow::OperationType))); } } +} + +void NewGeom_SalomeViewer::Zfitall() +{ + if (!mySelector || !mySelector->viewer()) + return; + SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager(); + OCCViewer_ViewFrame* aView = dynamic_cast(aMgr->getActiveView()); + if (aView) { + OCCViewer_ViewWindow* aWnd = aView->getView(OCCViewer_ViewFrame::MAIN_VIEW); + aWnd->getViewPort()->getView()->ZFitAll(); + } } \ No newline at end of file diff --git a/src/NewGeom/NewGeom_SalomeViewer.h b/src/NewGeom/NewGeom_SalomeViewer.h index 56a456bb4..8012c4a01 100644 --- a/src/NewGeom/NewGeom_SalomeViewer.h +++ b/src/NewGeom/NewGeom_SalomeViewer.h @@ -130,6 +130,9 @@ Q_OBJECT /// \param toActivate - activation flag void activateViewer(bool toActivate); + // Fit all along Z (perpendicular to display) + virtual void Zfitall(); + private slots: void onMousePress(SUIT_ViewWindow*, QMouseEvent*); void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*); diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index fae50aa55..5e76cf201 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -596,8 +596,10 @@ bool XGUI_Displayer::enableUpdateViewer(const bool isEnabled) void XGUI_Displayer::updateViewer() const { Handle(AIS_InteractiveContext) aContext = AISContext(); - if (!aContext.IsNull() && myEnableUpdateViewer) + if (!aContext.IsNull() && myEnableUpdateViewer) { + myWorkshop->viewer()->Zfitall(); aContext->UpdateCurrentViewer(); + } } void XGUI_Displayer::activateAIS(const Handle(AIS_InteractiveObject)& theIO, diff --git a/src/XGUI/XGUI_ViewerProxy.cpp b/src/XGUI/XGUI_ViewerProxy.cpp index 2011cf6b7..2f5ba0004 100644 --- a/src/XGUI/XGUI_ViewerProxy.cpp +++ b/src/XGUI/XGUI_ViewerProxy.cpp @@ -313,3 +313,16 @@ void XGUI_ViewerProxy::onViewTransformed(AppElements_ViewWindow::OperationType t emit viewTransformed((int) theType); } + +//*************************************** +void XGUI_ViewerProxy::Zfitall() +{ + if (myWorkshop->isSalomeMode()) { + myWorkshop->salomeConnector()->viewer()->Zfitall(); + } else { + AppElements_Viewer* aViewer = myWorkshop->mainWindow()->viewer(); + AppElements_ViewWindow* aView = aViewer->activeViewWindow(); + if (aView) + aView->v3dView()->ZFitAll(); + } +} \ No newline at end of file diff --git a/src/XGUI/XGUI_ViewerProxy.h b/src/XGUI/XGUI_ViewerProxy.h index 233bc5a9c..f7c40d4c1 100644 --- a/src/XGUI/XGUI_ViewerProxy.h +++ b/src/XGUI/XGUI_ViewerProxy.h @@ -72,6 +72,9 @@ Q_OBJECT /// by mouse drugging. If this is impossible thet it has to return False. virtual bool canDragByMouse() const; + // Fit all along Z (perpendicular to display) + virtual void Zfitall(); + signals: /// Emits by mouse entering the view port void enterViewPort();