]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #676: ZFitall for display new object
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 26 Jun 2015 13:58:30 +0000 (16:58 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 26 Jun 2015 13:58:30 +0000 (16:58 +0300)
src/ModuleBase/ModuleBase_IViewer.h
src/NewGeom/NewGeom_SalomeViewer.cpp
src/NewGeom/NewGeom_SalomeViewer.h
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_ViewerProxy.cpp
src/XGUI/XGUI_ViewerProxy.h

index b08d49e7246bfab55804962611292d7ce9f1c548..5c62cb5fa922fa320ed0d4c3bca12e20abc16a61 100644 (file)
@@ -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();
index deb1723311fb636eb94e078b08d21d7d6023d140..a9b8065198911abc86788bec6f9c0842edaade92 100644 (file)
@@ -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<OCCViewer_ViewFrame*>(aMgr->getActiveView());
+  if (aView) {
+    OCCViewer_ViewWindow* aWnd = aView->getView(OCCViewer_ViewFrame::MAIN_VIEW);
+    aWnd->getViewPort()->getView()->ZFitAll();
+  }
 }
\ No newline at end of file
index 56a456bb446c145d581ab1448d18b88c805a00ed..8012c4a015c25ad59a452ee9fe598ba28bc30ca3 100644 (file)
@@ -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*);
index fae50aa553b33aee7636d9f19b329b3ee3eb4cd9..5e76cf2017842781fa04d87a9702ae89fcd9c15a 100644 (file)
@@ -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,
index 2011cf6b7bd10779d505ac0f78b3149ec4edfa83..2f5ba000413b056b8c58deefdd1524dd8803f1f6 100644 (file)
@@ -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
index 233bc5a9c254aba2193de03018f652108580d9f3..f7c40d4c101830d9d7642bc0218655e0af6d2274 100644 (file)
@@ -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();