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