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