Salome HOME
Adapt Fitter to SALOME
[modules/shaper.git] / src / SHAPERGUI / SHAPERGUI_SalomeViewer.cpp
1 // Copyright (C) 2014-2019  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "SHAPERGUI_SalomeViewer.h"
21 #include "SHAPERGUI_OCCSelector.h"
22
23 #include <OCCViewer_ViewPort3d.h>
24 #include <OCCViewer_ViewFrame.h>
25 #include <SOCC_ViewModel.h>
26 #include <SUIT_ViewManager.h>
27
28 #include <QtxActionToolMgr.h>
29 #include <SALOME_AISShape.hxx>
30
31 #include <SelectMgr_ListIteratorOfListOfFilter.hxx>
32
33 #include <QMouseEvent>
34 #include <QContextMenuEvent>
35
36 #define SALOME_PATCH_FOR_CTRL_WHEEL
37
38 SHAPERGUI_SalomeView::SHAPERGUI_SalomeView(OCCViewer_Viewer* theViewer)
39 : ModuleBase_IViewWindow(), myCurrentView(0)
40 {
41   myViewer = theViewer;
42 }
43
44
45 Handle(V3d_View) SHAPERGUI_SalomeView::v3dView() const
46 {
47   Handle(V3d_View) aView;
48   if (myCurrentView) {
49     OCCViewer_ViewWindow* aWnd = static_cast<OCCViewer_ViewWindow*>(myCurrentView);
50     aView = aWnd->getViewPort()->getView();
51   }
52   return aView;
53 }
54
55 QWidget* SHAPERGUI_SalomeView::viewPort() const
56 {
57   QWidget* aViewPort = 0;
58   if (myCurrentView) {
59     OCCViewer_ViewWindow* aWnd = static_cast<OCCViewer_ViewWindow*>(myCurrentView);
60     aViewPort = aWnd->getViewPort();
61   }
62   return aViewPort;
63 }
64
65 //**********************************************
66 //**********************************************
67 //**********************************************
68
69
70
71 SHAPERGUI_SalomeViewer::SHAPERGUI_SalomeViewer(QObject* theParent)
72     : ModuleBase_IViewer(theParent),
73       mySelector(0), myView(0), myIsSelectionChanged(false)
74 {
75 }
76
77 SHAPERGUI_SalomeViewer::~SHAPERGUI_SalomeViewer()
78 {
79   if (myView)
80     delete myView;
81 }
82
83
84 //**********************************************
85 Handle(AIS_InteractiveContext) SHAPERGUI_SalomeViewer::AISContext() const
86 {
87   if (mySelector && mySelector->viewer())
88     return mySelector->viewer()->getAISContext();
89   Handle(AIS_InteractiveContext) aNull;
90   return aNull;
91 }
92
93 //**********************************************
94 Handle(V3d_Viewer) SHAPERGUI_SalomeViewer::v3dViewer() const
95 {
96   if (mySelector)
97     return mySelector->viewer()->getViewer3d();
98   return Handle(V3d_Viewer)();
99 }
100
101 //**********************************************
102 Handle(AIS_Trihedron) SHAPERGUI_SalomeViewer::trihedron() const
103 {
104   return mySelector->viewer()->getTrihedron();
105 }
106
107 //**********************************************
108 Handle(V3d_View) SHAPERGUI_SalomeViewer::activeView() const
109 {
110   if (mySelector) {
111     OCCViewer_Viewer* aViewer = mySelector->viewer();
112     SUIT_ViewManager* aMgr = aViewer->getViewManager();
113     OCCViewer_ViewWindow* aWnd = static_cast<OCCViewer_ViewWindow*>(aMgr->getActiveView());
114     return aWnd->getViewPort()->getView();
115   }
116   return Handle(V3d_View)();
117 }
118
119 //**********************************************
120 QWidget* SHAPERGUI_SalomeViewer::activeViewPort() const
121 {
122   QWidget* aViewPort = 0;
123   if (mySelector) {
124     OCCViewer_Viewer* aViewer = mySelector->viewer();
125     SUIT_ViewManager* aMgr = aViewer->getViewManager();
126     OCCViewer_ViewWindow* aWnd = static_cast<OCCViewer_ViewWindow*>(aMgr->getActiveView());
127     aViewPort = aWnd->getViewPort();
128   }
129   return aViewPort;
130 }
131
132 //**********************************************
133 void SHAPERGUI_SalomeViewer::setSelector(SHAPERGUI_OCCSelector* theSel)
134 {
135   if (mySelector) {
136     if (mySelector == theSel)
137       return;
138     else {
139       mySelector->viewer()->getViewManager()->disconnect(this);
140       OCCViewer_Viewer* aViewer = mySelector->viewer();
141       if (aViewer)
142         aViewer->disconnect(this);
143     }
144   }
145   mySelector = theSel;
146   if (!mySelector)
147     return;
148   OCCViewer_Viewer* aViewer = mySelector->viewer();
149   SUIT_ViewManager* aMgr = aViewer->getViewManager();
150
151   myView = new SHAPERGUI_SalomeView(mySelector->viewer());
152
153   // TODO: Provide ModuleBase_IViewWindow interface
154   connect(aMgr, SIGNAL(lastViewClosed(SUIT_ViewManager*)), this, SIGNAL(lastViewClosed()));
155
156   connect(aMgr, SIGNAL(tryCloseView(SUIT_ViewWindow*)),
157           this, SLOT(onTryCloseView(SUIT_ViewWindow*)));
158   connect(aMgr, SIGNAL(deleteView(SUIT_ViewWindow*)),
159           this, SLOT(onDeleteView(SUIT_ViewWindow*)));
160   connect(aMgr, SIGNAL(viewCreated(SUIT_ViewWindow*)),
161           this, SLOT(onViewCreated(SUIT_ViewWindow*)));
162   connect(aMgr, SIGNAL(activated(SUIT_ViewManager*)),
163           this, SLOT(onActivated(SUIT_ViewManager*)));
164
165   connect(aMgr, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), this,
166           SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*)));
167   connect(aMgr, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), this,
168           SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*)));
169   connect(aMgr, SIGNAL(mouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*)), this,
170           SLOT(onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*)));
171   connect(aMgr, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)), this,
172           SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*)));
173
174   connect(aMgr, SIGNAL(keyPress(SUIT_ViewWindow*, QKeyEvent*)), this,
175           SLOT(onKeyPress(SUIT_ViewWindow*, QKeyEvent*)));
176   connect(aMgr, SIGNAL(keyRelease(SUIT_ViewWindow*, QKeyEvent*)), this,
177           SLOT(onKeyRelease(SUIT_ViewWindow*, QKeyEvent*)));
178
179   connect(aViewer, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
180 }
181
182 //**********************************************
183 void SHAPERGUI_SalomeViewer::onSelectionChanged()
184 {
185   // Selection event must be sent only after mouse release
186   myIsSelectionChanged = true;
187 }
188
189 //**********************************************
190 void SHAPERGUI_SalomeViewer::onMousePress(SUIT_ViewWindow* theView, QMouseEvent* theEvent)
191 {
192   myView->setCurrentView(theView);
193   emit mousePress(myView, theEvent);
194 }
195
196 //**********************************************
197 void SHAPERGUI_SalomeViewer::onMouseRelease(SUIT_ViewWindow* theView, QMouseEvent* theEvent)
198 {
199   myView->setCurrentView(theView);
200   emit mouseRelease(myView, theEvent);
201   if (myIsSelectionChanged) {
202     emit selectionChanged();
203     myIsSelectionChanged = false;
204   }
205 }
206
207 //**********************************************
208 void SHAPERGUI_SalomeViewer::onMouseDoubleClick(SUIT_ViewWindow* theView, QMouseEvent* theEvent)
209 {
210   myView->setCurrentView(theView);
211   emit mouseDoubleClick(myView, theEvent);
212 }
213
214 //**********************************************
215 void SHAPERGUI_SalomeViewer::onMouseMove(SUIT_ViewWindow* theView, QMouseEvent* theEvent)
216 {
217   myView->setCurrentView(theView);
218   emit mouseMove(myView, theEvent);
219 }
220
221 //**********************************************
222 bool SHAPERGUI_SalomeViewer::canDragByMouse() const
223 {
224   OCCViewer_Viewer* aViewer = mySelector->viewer();
225   SUIT_ViewWindow* aWnd = aViewer->getViewManager()->getActiveView();
226   OCCViewer_ViewWindow* aViewWnd = dynamic_cast<OCCViewer_ViewWindow*>(aWnd);
227   if (aViewWnd) {
228     return (aViewWnd->interactionStyle() == 0);
229   }
230   return true;
231 }
232
233
234 //**********************************************
235 void SHAPERGUI_SalomeViewer::onKeyPress(SUIT_ViewWindow* theView, QKeyEvent* theEvent)
236 {
237   emit keyPress(myView, theEvent);
238 }
239
240 //**********************************************
241 void SHAPERGUI_SalomeViewer::onKeyRelease(SUIT_ViewWindow* theView, QKeyEvent* theEvent)
242 {
243   emit keyRelease(myView, theEvent);
244 }
245
246 //**********************************************
247 void SHAPERGUI_SalomeViewer::onTryCloseView(SUIT_ViewWindow*)
248 {
249   emit tryCloseView(myView);
250 }
251
252 //**********************************************
253 void SHAPERGUI_SalomeViewer::onDeleteView(SUIT_ViewWindow*)
254 {
255   if(myWindowScale.contains(myView->v3dView()))
256     myWindowScale.remove(myView->v3dView());
257   emit deleteView(myView);
258 }
259
260 //**********************************************
261 void SHAPERGUI_SalomeViewer::onViewCreated(SUIT_ViewWindow* theView)
262 {
263   myView->setCurrentView(theView);
264
265   OCCViewer_ViewFrame* aView = dynamic_cast<OCCViewer_ViewFrame*>(theView);
266
267   OCCViewer_ViewWindow* aWnd = aView->getView(OCCViewer_ViewFrame::MAIN_VIEW);
268   if (aWnd) {
269     connect(aWnd, SIGNAL(vpTransformationFinished(OCCViewer_ViewWindow::OperationType)),
270       this, SLOT(onViewTransformed(OCCViewer_ViewWindow::OperationType)));
271     OCCViewer_ViewPort3d* aViewPort = aWnd->getViewPort();
272     if (aViewPort)
273       connect(aViewPort, SIGNAL(vpMapped(OCCViewer_ViewPort3d*)), this, SLOT(onViewPortMapped()));
274   }
275   reconnectActions(aWnd, true);
276
277   myWindowScale.insert(aView->getViewPort()->getView(),
278                        aView->getViewPort()->getView()->Camera()->Scale());
279
280   emit viewCreated(myView);
281
282
283 }
284
285 //**********************************************
286 void SHAPERGUI_SalomeViewer::onActivated(SUIT_ViewManager* theMgr)
287 {
288   myView->setCurrentView(theMgr->getActiveView());
289   emit activated(myView);
290 }
291
292 //**********************************************
293 void SHAPERGUI_SalomeViewer::enableSelection(bool isEnabled)
294 {
295   if (mySelector)
296     if (mySelector->viewer()->isSelectionEnabled() != isEnabled)
297       mySelector->viewer()->enableSelection(isEnabled);
298   // The enableSelection() in SALOME 7.5 cause of forced Viewer update(we have blinking)
299   // After this is corrected, the first row should be recommented, the last - removed
300     //mySelector->viewer()->setInteractionStyle(isEnabled ? SUIT_ViewModel::STANDARD
301     //                                                    : SUIT_ViewModel::KEY_FREE);
302 }
303
304 //**********************************************
305 bool SHAPERGUI_SalomeViewer::isSelectionEnabled() const
306 {
307   if (mySelector)
308     return mySelector->viewer()->isSelectionEnabled();
309   return false;
310 }
311
312 //**********************************************
313 void SHAPERGUI_SalomeViewer::enableMultiselection(bool isEnable)
314 {
315   if (mySelector)
316     mySelector->viewer()->enableMultiselection(isEnable);
317 }
318
319 //**********************************************
320 bool SHAPERGUI_SalomeViewer::isMultiSelectionEnabled() const
321 {
322   if (mySelector)
323     return mySelector->viewer()->isMultiSelectionEnabled();
324   return false;
325 }
326
327 //**********************************************
328 bool SHAPERGUI_SalomeViewer::enableDrawMode(bool isEnabled)
329 {
330   // TODO: Has to be replaced when SALOME patch become available
331   if (mySelector)
332     return mySelector->viewer()->enableDrawMode(isEnabled);
333   return false;
334 }
335
336 //**********************************************
337 void SHAPERGUI_SalomeViewer::reconnectActions(SUIT_ViewWindow* theWindow,
338                                             const bool theUseSHAPERSlot)
339 {
340   OCCViewer_ViewWindow* aWindow = dynamic_cast<OCCViewer_ViewWindow*>(theWindow);
341   if (!aWindow)
342     return;
343
344   QAction* anAction = theWindow->toolMgr()->action(OCCViewer_ViewWindow::TrihedronShowId);
345   if (!anAction)
346     return;
347
348   if (theUseSHAPERSlot) {
349     anAction->disconnect(anAction, SIGNAL(toggled(bool)),
350                          theWindow, SLOT(onTrihedronShow(bool)));
351     anAction->connect(anAction, SIGNAL(toggled(bool)),
352                       this, SIGNAL(trihedronVisibilityChanged(bool)));
353   }
354   else {
355     anAction->connect(anAction, SIGNAL(toggled(bool)),
356                       theWindow, SLOT(onTrihedronShow(bool)));
357     anAction->disconnect(anAction, SIGNAL(toggled(bool)),
358                          this, SIGNAL(trihedronVisibilityChanged(bool)));
359   }
360 }
361
362 //**********************************************
363 void SHAPERGUI_SalomeViewer::fitAll()
364 {
365   if (mySelector) {
366     SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager();
367     OCCViewer_ViewFrame* aVFrame = dynamic_cast<OCCViewer_ViewFrame*>(aMgr->getActiveView());
368     if (aVFrame) {
369       aVFrame->onFitAll();
370     }
371   }
372 }
373
374 //**********************************************
375 void SHAPERGUI_SalomeViewer::eraseAll()
376 {
377   Handle(AIS_InteractiveContext) aContext = AISContext();
378   if (aContext.IsNull())
379     return;
380   AIS_ListOfInteractive aList;
381   aContext->DisplayedObjects(aList);
382   AIS_ListIteratorOfListOfInteractive aLIt;
383   Handle(AIS_InteractiveObject) anAISIO;
384   for (aLIt.Initialize(aList); aLIt.More(); aLIt.Next()) {
385     anAISIO = aLIt.Value();
386     Handle(Standard_Type) aType = anAISIO->DynamicType();
387     if (anAISIO->IsKind(STANDARD_TYPE(SALOME_AISShape))) {
388       aContext->Erase(anAISIO, false);
389     }
390   }
391 }
392
393 //**********************************************
394 void SHAPERGUI_SalomeViewer::setViewProjection(double theX, double theY,
395                                                double theZ, double theTwist)
396 {
397   if (!mySelector)
398     return;
399
400   SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager();
401   OCCViewer_ViewFrame* aVFrame = dynamic_cast<OCCViewer_ViewFrame*>(aMgr->getActiveView());
402   if (aVFrame) {
403     Handle(V3d_View) aView3d = aVFrame->getViewPort()->getView();
404     if (!aView3d.IsNull()) {
405       aView3d->SetProj(theX, theY, theZ);
406       aView3d->SetTwist( theTwist );
407       aView3d->FitAll(0.01, false);
408       aView3d->SetZSize(0.);
409       if (aView3d->Depth() < 0.1)
410         aView3d->DepthFitAll();
411     }
412   }
413 }
414
415 //***************************************
416 void SHAPERGUI_SalomeViewer::addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
417 {
418   Handle(AIS_InteractiveContext) aContext = AISContext();
419   if (!aContext.IsNull()) {
420     aContext->AddFilter(theFilter);
421   }
422 }
423
424 //***************************************
425 void SHAPERGUI_SalomeViewer::removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
426 {
427   Handle(AIS_InteractiveContext) aContext = AISContext();
428   if (!aContext.IsNull()) {
429     aContext->RemoveFilter(theFilter);
430   }
431 }
432
433 //***************************************
434 bool SHAPERGUI_SalomeViewer::hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
435 {
436   bool aFoundFilter = false;
437   Handle(AIS_InteractiveContext) aContext = AISContext();
438   if (!aContext.IsNull()) {
439     const SelectMgr_ListOfFilter& aFilters = aContext->Filters();
440     SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
441     for (; aIt.More() && !aFoundFilter; aIt.Next()) {
442       aFoundFilter = theFilter.get() == aIt.Value().get();
443     }
444   }
445   return aFoundFilter;
446 }
447
448 //***************************************
449 void SHAPERGUI_SalomeViewer::clearSelectionFilters()
450 {
451   Handle(AIS_InteractiveContext) aContext = AISContext();
452   if (!aContext.IsNull()) {
453     aContext->RemoveFilters();
454   }
455 }
456
457 //***************************************
458 void SHAPERGUI_SalomeViewer::update()
459 {
460   Handle(AIS_InteractiveContext) aContext = AISContext();
461   if (!aContext.IsNull()) {
462     aContext->UpdateCurrentViewer();
463   }
464 }
465
466 //***************************************
467 void SHAPERGUI_SalomeViewer::onViewTransformed(OCCViewer_ViewWindow::OperationType theType)
468 {
469   emit viewTransformed((int) theType);
470 }
471
472 //***************************************
473 void SHAPERGUI_SalomeViewer::onViewPortMapped()
474 {
475   emit trihedronVisibilityChanged(true);
476 }
477
478 //***************************************
479 void SHAPERGUI_SalomeViewer::activateViewer(bool toActivate)
480 {
481   if (!mySelector || !mySelector->viewer())
482     return;
483   SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager();
484 #ifdef SALOME_PATCH_FOR_CTRL_WHEEL
485   OCCViewer_Viewer* aViewer = dynamic_cast<OCCViewer_Viewer*>(aMgr->getViewModel());
486   if (aViewer)
487     aViewer->setUseLocalSelection(toActivate);
488 #endif
489   QVector<SUIT_ViewWindow*> aViews = aMgr->getViews();
490   if (toActivate) {
491     foreach (SUIT_ViewWindow* aView, aViews) {
492       OCCViewer_ViewFrame* aOCCView = dynamic_cast<OCCViewer_ViewFrame*>(aView);
493       OCCViewer_ViewWindow* aWnd = aOCCView->getView(OCCViewer_ViewFrame::MAIN_VIEW);
494       connect(aWnd, SIGNAL(vpTransformationFinished(OCCViewer_ViewWindow::OperationType)),
495         this, SLOT(onViewTransformed(OCCViewer_ViewWindow::OperationType)));
496       reconnectActions(aWnd, true);
497     }
498   } else {
499     foreach (SUIT_ViewWindow* aView, aViews) {
500       OCCViewer_ViewFrame* aOCCView = dynamic_cast<OCCViewer_ViewFrame*>(aView);
501       OCCViewer_ViewWindow* aWnd = aOCCView->getView(OCCViewer_ViewFrame::MAIN_VIEW);
502       disconnect((OCCViewer_ViewWindow*)aWnd,
503                  SIGNAL(vpTransformationFinished(OCCViewer_ViewWindow::OperationType)),
504         this, SLOT(onViewTransformed(OCCViewer_ViewWindow::OperationType)));
505       reconnectActions(aWnd, false);
506     }
507   }
508 }
509
510 bool SHAPERGUI_SalomeViewer::isColorScaleVisible() const
511 {
512   if (mySelector) {
513     return mySelector->viewer()->isColorScaleVisible();
514   }
515   return false;
516 }
517
518 void SHAPERGUI_SalomeViewer::setColorScaleShown(bool on)
519 {
520   if (mySelector) {
521     mySelector->viewer()->setColorScaleShown(on);
522   }
523 }
524
525 void SHAPERGUI_SalomeViewer::setColorScalePosition(double theX, double theY)
526 {
527   if (mySelector) {
528     QWidget* aWindow = activeViewPort();
529     mySelector->viewer()->getColorScale()->SetPosition(aWindow->width() * theX,
530       aWindow->height() * theY);
531   }
532 }
533
534 void SHAPERGUI_SalomeViewer::setColorScaleSize(double theW, double theH)
535 {
536   if (mySelector) {
537     QWidget* aWindow = activeViewPort();
538     mySelector->viewer()->getColorScale()->SetSize(aWindow->width() * theW,
539       aWindow->height() * theH);
540   }
541 }
542
543 void SHAPERGUI_SalomeViewer::setColorScaleRange(double theMin, double theMax)
544 {
545   if (mySelector) {
546     mySelector->viewer()->getColorScale()->SetRange(theMin, theMax);
547   }
548 }
549
550 void SHAPERGUI_SalomeViewer::setColorScaleIntervals(int theNb)
551 {
552   if (mySelector) {
553     mySelector->viewer()->getColorScale()->SetNumberOfIntervals(theNb);
554   }
555 }
556
557 void SHAPERGUI_SalomeViewer::setColorScaleTextHeigth(int theH)
558 {
559   if (mySelector) {
560     mySelector->viewer()->getColorScale()->SetTextHeight(theH);
561   }
562 }
563
564 void SHAPERGUI_SalomeViewer::setColorScaleTextColor(const QColor& theColor)
565 {
566   if (mySelector) {
567     Quantity_Color aColor(theColor.redF(), theColor.greenF(), theColor.blueF(), Quantity_TOC_RGB);
568     mySelector->viewer()->getColorScale()->SetColor(aColor);
569   }
570 }
571
572 void SHAPERGUI_SalomeViewer::setColorScaleTitle(const QString& theText)
573 {
574   if (mySelector) {
575     mySelector->viewer()->getColorScale()->SetTitle(theText.toStdString().c_str());
576   }
577 }
578
579 void SHAPERGUI_SalomeViewer::setFitter(OCCViewer_Fitter* theFitter)
580 {
581   if (mySelector)
582     mySelector->viewer()->setFitter(theFitter);
583 }
584
585 OCCViewer_Fitter* SHAPERGUI_SalomeViewer::currentFitter() const
586 {
587   if (mySelector)
588     return mySelector->viewer()->currentFitter();
589   return 0;
590 }
591
592 void SHAPERGUI_SalomeViewer::unsetFitter()
593 {
594   if (mySelector)
595     mySelector->viewer()->unsetFitter();
596 }
597
598
599 //void SHAPERGUI_SalomeViewer::Zfitall()
600 //{
601 //  if (!mySelector || !mySelector->viewer())
602 //    return;
603 //  SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager();
604 //  /// WORKAROUND for issue #1798. SUIT_ViewManager::closeAllViews() should nullify myActiveView
605 //  /// As a result, we need to check views count in manager
606 //  if (aMgr->getViews().size() > 0) {
607 //    OCCViewer_ViewFrame* aView = dynamic_cast<OCCViewer_ViewFrame*>(aMgr->getActiveView());
608 //    if (aView) {
609 //      OCCViewer_ViewWindow* aWnd = aView->getView(OCCViewer_ViewFrame::MAIN_VIEW);
610 //      Handle(V3d_View) aView3d = aWnd->getViewPort()->getView();
611 //      aView3d->ZFitAll();
612 //      if (aView3d->Depth() < 0.1)
613 //        aView3d->DepthFitAll();
614 //    }
615 //  }
616 //}