Salome HOME
updated copyright message
[modules/gui.git] / src / LightApp / LightApp_FullScreenHelper.cxx
index 8d5e738750492827d66c3cd7bdcba3beaca306c8..46cd3705ac433e752f48894bff44e0da9723c947 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 #include <QAction>
 #include <QMenuBar>
 #include <QStatusBar>
+#include <QToolBar>
 
-#include <PyConsole_Console.h>
+#include <QtxWorkstack.h>
 
 #include <STD_Application.h>
+#include <STD_TabDesktop.h>
 
 #include <SUIT_Session.h>
 #include <SUIT_Desktop.h>
 #include <SUIT_DataBrowser.h>
+#include <SUIT_ViewWindow.h>
+#include <SUIT_ResourceMgr.h>
+
+#ifndef DISABLE_OCCVIEWER
+  #include <OCCViewer_ViewFrame.h>
+#endif
 
 #include "LightApp_FullScreenHelper.h"
 #include "LightApp_Application.h"
@@ -76,6 +84,47 @@ void LightApp_FullScreenHelper::switchToFullScreen() {
   if(!desktop)
     return;
   
+  STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop );
+
+  myWindowsList.clear();
+  myFrameHideMap.clear();
+  //Hide all toolbars and inactive window
+  QList<SUIT_ViewWindow*> aWindowList = desk->windows();
+  SUIT_ViewWindow* anActiveWindow = desk->activeWindow();
+  QList<SUIT_ViewWindow*>::const_iterator it = aWindowList.begin();
+  int aKey = 0;
+  for ( ; it != aWindowList.end(); it++ ) {
+    myWindowsList.push_back(*it);
+  #ifndef DISABLE_OCCVIEWER
+    OCCViewer_ViewFrame* anActiveOCCFrame = dynamic_cast<OCCViewer_ViewFrame*>( *it );
+    if ( anActiveOCCFrame ) {
+      QList<int> aList;
+      if ( (*it) == anActiveWindow ) {
+        OCCViewer_ViewWindow* anActiveOCCWindow = anActiveOCCFrame->getActiveView();
+        for (int i = OCCViewer_ViewFrame::BOTTOM_RIGHT; i <= OCCViewer_ViewFrame::TOP_RIGHT; i++ ) {
+          OCCViewer_ViewWindow* aCurrentOCCWindow = anActiveOCCFrame->getView(i);
+          if ( aCurrentOCCWindow && aCurrentOCCWindow->isVisible() ) {
+            if ( aCurrentOCCWindow != anActiveOCCWindow ) {
+              aCurrentOCCWindow->hide();
+              toolbarVisible(aCurrentOCCWindow, false);
+            }
+            if ( anActiveOCCWindow )
+              aList.append(i);
+          }
+        }
+      }
+      if ( aList.count() > 0 ) {
+        myFrameHideMap.insert(aKey, aList);
+        aKey++;
+      }
+    }
+  #endif
+    toolbarVisible(*it, false);
+  }
+
+  QtxWorkstack* wgStack = desk->workstack();
+  wgStack->splittersVisible(anActiveWindow, false);
+
   desktop->setWindowState(desktop->windowState() ^ Qt::WindowFullScreen);
 
   if(desktop->menuBar())
@@ -93,8 +142,13 @@ void LightApp_FullScreenHelper::switchToFullScreen() {
   QList<QDockWidget*> aDocWidgets = desktop->findChildren<QDockWidget*>();
   myDocWidgetMap.clear();
 
+  bool isHidding = false;
+  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+    if ( resMgr )
+      isHidding = resMgr->booleanValue( "OCCViewer", "automatic_hiding", true );
+
   QWidget* ob = app->objectBrowser();
-  QObject* obParent = ob ? ob->parent() : 0;
+  QObject* obParent = (ob && !isHidding)? ob->parent() : 0;
 
   foreach(QDockWidget* aWidget, aDocWidgets) {
     if(aWidget && aWidget->parent() == desktop) {
@@ -113,7 +167,7 @@ void LightApp_FullScreenHelper::switchToFullScreen() {
       }
     }    
   }
-  
+
   QList<QToolBar*> aToolBars = desktop->findChildren<QToolBar*>();
   myToolBarMap.clear();
   foreach(QToolBar* aWidget, aToolBars )  {
@@ -131,7 +185,7 @@ void LightApp_FullScreenHelper::switchToFullScreen() {
        myToolBarMap.insert(aWidget, isActionEnabled);
       }
     }    
-  }  
+  }
 }
 
 /*!
@@ -155,6 +209,32 @@ void LightApp_FullScreenHelper::switchToNormalScreen() {
   
   desktop->setWindowState(desktop->windowState() ^ Qt::WindowFullScreen);
 
+  STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop );
+  SUIT_ViewWindow* anActiveWindow = desk->activeWindow();
+
+  //Show all toolbars and windows
+  QList<SUIT_ViewWindow*>::const_iterator itr = myWindowsList.begin();
+  int aKey = 0;
+  for ( ; itr != myWindowsList.end(); itr++ ) {
+  #ifndef DISABLE_OCCVIEWER
+    OCCViewer_ViewFrame* anActiveOCCFrame = dynamic_cast<OCCViewer_ViewFrame*>( *itr );
+    if ( anActiveOCCFrame ) {
+      if ( (*itr) == anActiveWindow ) {
+        QList<int>::const_iterator it = myFrameHideMap[aKey].begin();
+        for (; it != myFrameHideMap[aKey].end(); it++) {
+          OCCViewer_ViewWindow* aCurrentOCCWindow = anActiveOCCFrame->getView(*it);
+          aCurrentOCCWindow->show();
+          toolbarVisible( aCurrentOCCWindow, true);
+        }
+        aKey++;
+      }
+    }
+  #endif
+    toolbarVisible( *itr, true );
+  }
+
+  QtxWorkstack* wgStack = desk->workstack();
+  wgStack->splittersVisible(anActiveWindow, true);
 
   DocWidgetMap::iterator it = myDocWidgetMap.begin();
   for( ;it != myDocWidgetMap.end() ; it++ ) {
@@ -185,5 +265,24 @@ void LightApp_FullScreenHelper::switchToNormalScreen() {
     if(act)
       act->setEnabled(true);
   }
-  
+}
+
+/*!
+ * Show/Hide toolbars on current view.
+ */
+void LightApp_FullScreenHelper::toolbarVisible(SUIT_ViewWindow* view, bool toolbar_visible)
+{
+  bool isHidding = false;
+  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+  if ( resMgr )
+    isHidding = resMgr->booleanValue( "OCCViewer", "automatic_hiding", true );
+  QList<QToolBar*> lst = view->findChildren<QToolBar*>();
+  if ( isHidding ) {
+    QList<QToolBar*>::const_iterator iter = lst.begin();
+    for ( ; iter!=lst.end(); iter++ ) {
+      if ( *iter ) {
+        (*iter)->setVisible(toolbar_visible);
+      }
+    }
+  }
 }