From 399c568ef2d599a58485c1c363215f4491e085f0 Mon Sep 17 00:00:00 2001 From: imn Date: Wed, 29 Jul 2015 20:27:55 +0300 Subject: [PATCH] Fixed full screen mode and add support full screen mode for splitted occt viewers --- src/LightApp/LightApp_FullScreenHelper.cxx | 116 ++++++++++++++------- src/LightApp/LightApp_FullScreenHelper.h | 5 + src/OCCViewer/OCCViewer_ViewFrame.cxx | 21 +++- src/OCCViewer/OCCViewer_ViewFrame.h | 4 + src/Qtx/QtxWorkstack.cxx | 77 ++++++++++++-- src/Qtx/QtxWorkstack.h | 7 +- src/SVTK/SVTK_InteractorStyle.cxx | 5 + 7 files changed, 185 insertions(+), 50 deletions(-) diff --git a/src/LightApp/LightApp_FullScreenHelper.cxx b/src/LightApp/LightApp_FullScreenHelper.cxx index 7ddce9822..56610b6a3 100644 --- a/src/LightApp/LightApp_FullScreenHelper.cxx +++ b/src/LightApp/LightApp_FullScreenHelper.cxx @@ -40,6 +40,10 @@ #include #include +#ifndef DISABLE_OCCVIEWER + #include +#endif + #include "LightApp_FullScreenHelper.h" #include "LightApp_Application.h" @@ -82,32 +86,44 @@ void LightApp_FullScreenHelper::switchToFullScreen() { STD_TabDesktop* desk = dynamic_cast( desktop ); - QtxWorkstack* wgStack = desk->workstack(); - wgStack->showActiveTabBar(false); myWindowsList.clear(); - bool isHidding = false; - SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); - if ( resMgr ) - isHidding = resMgr->booleanValue( "OCCViewer", "automatic_hiding", true ); + myFrameHideMap.clear(); //Hide all toolbars and inactive window QList aWindowList = desk->windows(); SUIT_ViewWindow* anActiveWindow = desk->activeWindow(); QList::const_iterator it = aWindowList.begin(); - for ( ; it!=aWindowList.end(); it++ ) { - QList lst = (*it)->findChildren(); - if ( *it ) { - myWindowsList.push_back(*it); - ( *it )->hide(); - } - if ( isHidding ) { - QList::const_iterator iter = lst.begin(); - for ( ; iter!=lst.end(); iter++ ) { - (*iter)->hide(); + int aKey = 0; + for ( ; it != aWindowList.end(); it++ ) { + myWindowsList.push_back(*it); + #ifndef DISABLE_OCCVIEWER + OCCViewer_ViewFrame* anActiveOCCFrame = dynamic_cast( *it ); + if ( anActiveOCCFrame ) { + QList 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); } - if (anActiveWindow) - anActiveWindow->show(); + + QtxWorkstack* wgStack = desk->workstack(); + wgStack->splittersVisible(anActiveWindow, false); desktop->setWindowState(desktop->windowState() ^ Qt::WindowFullScreen); @@ -126,6 +142,11 @@ void LightApp_FullScreenHelper::switchToFullScreen() { QList aDocWidgets = desktop->findChildren(); 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 && !isHidding)? ob->parent() : 0; @@ -146,7 +167,7 @@ void LightApp_FullScreenHelper::switchToFullScreen() { } } } - + QList aToolBars = desktop->findChildren(); myToolBarMap.clear(); foreach(QToolBar* aWidget, aToolBars ) { @@ -164,7 +185,7 @@ void LightApp_FullScreenHelper::switchToFullScreen() { myToolBarMap.insert(aWidget, isActionEnabled); } } - } + } } /*! @@ -189,28 +210,32 @@ void LightApp_FullScreenHelper::switchToNormalScreen() { desktop->setWindowState(desktop->windowState() ^ Qt::WindowFullScreen); STD_TabDesktop* desk = dynamic_cast( desktop ); + SUIT_ViewWindow* anActiveWindow = desk->activeWindow(); - QtxWorkstack* wgStack = desk->workstack(); - wgStack->showActiveTabBar(true); - - bool isHidding = false; - SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); - if ( resMgr ) - isHidding = resMgr->booleanValue( "OCCViewer", "automatic_hiding", true ); //Show all toolbars and windows QList::const_iterator itr = myWindowsList.begin(); - for ( ; itr!=myWindowsList.end(); itr++ ) { - QList lst = (*itr)->findChildren(); - if (*itr && !(*itr)->isVisible()) - (*itr)->show(); - if ( isHidding ) { - QList::const_iterator iter = lst.begin(); - for ( ; iter!=lst.end(); iter++ ) { - (*iter)->show(); + int aKey = 0; + for ( ; itr != myWindowsList.end(); itr++ ) { + #ifndef DISABLE_OCCVIEWER + OCCViewer_ViewFrame* anActiveOCCFrame = dynamic_cast( *itr ); + if ( anActiveOCCFrame ) { + if ( (*itr) == anActiveWindow ) { + QList::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++ ) { QDockWidget* aWidget = it.key(); @@ -240,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 lst = view->findChildren(); + if ( isHidding ) { + QList::const_iterator iter = lst.begin(); + for ( ; iter!=lst.end(); iter++ ) { + if ( *iter ) { + (*iter)->setVisible(toolbar_visible); + } + } + } } diff --git a/src/LightApp/LightApp_FullScreenHelper.h b/src/LightApp/LightApp_FullScreenHelper.h index e5f4dedf4..0b96d663e 100644 --- a/src/LightApp/LightApp_FullScreenHelper.h +++ b/src/LightApp/LightApp_FullScreenHelper.h @@ -43,12 +43,17 @@ class LIGHTAPP_EXPORT LightApp_FullScreenHelper { void switchToFullScreen(); void switchToNormalScreen(); + private: + void toolbarVisible(SUIT_ViewWindow*, bool=false); + private: typedef QMap DocWidgetMap; DocWidgetMap myDocWidgetMap; typedef QMap ToolBarMap; ToolBarMap myToolBarMap; QList myWindowsList; + typedef QMap > FrameHideMap; + FrameHideMap myFrameHideMap; bool myStatusBarVisibility; diff --git a/src/OCCViewer/OCCViewer_ViewFrame.cxx b/src/OCCViewer/OCCViewer_ViewFrame.cxx index 5907af309..70e253b63 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.cxx +++ b/src/OCCViewer/OCCViewer_ViewFrame.cxx @@ -52,6 +52,7 @@ OCCViewer_ViewFrame::OCCViewer_ViewFrame(SUIT_Desktop* theDesktop, OCCViewer_Vie myLayout->addWidget( view0, 0, 0 ); myMaximizedView = view0; + myActiveView = view0; connectViewSignals(view0); } @@ -76,6 +77,12 @@ OCCViewer_ViewWindow* OCCViewer_ViewFrame::getView( const int i ) const return ( i >= 0 && i < myViews.count() ) ? myViews.at( i ) : 0 ; } +//************************************************************************************** +OCCViewer_ViewWindow* OCCViewer_ViewFrame::getActiveView( ) const +{ + return myActiveView; +} + //************************************************************************************** void OCCViewer_ViewFrame::setViewManager( SUIT_ViewManager* theMgr ) { @@ -93,7 +100,10 @@ void OCCViewer_ViewFrame::returnTo3dView() view = myViews.at(i); view->setVisible( view->get2dMode() == No2dMode ); view->setMaximized( true, false ); - if (view->get2dMode() == No2dMode) myMaximizedView = view; + if (view->get2dMode() == No2dMode) { + myMaximizedView = view; + myActiveView = view; + } } myLayout->setColumnStretch(0, 0); myLayout->setColumnStretch(1, 0); @@ -107,6 +117,7 @@ void OCCViewer_ViewFrame::returnTo3dView() void OCCViewer_ViewFrame::onMaximizedView( OCCViewer_ViewWindow* theView, bool isMaximized) { myMaximizedView = theView; + myActiveView = theView; if (isMaximized) { if (myViews.count() <= 1) return; @@ -466,6 +477,9 @@ void OCCViewer_ViewFrame::connectViewSignals(OCCViewer_ViewWindow* theView) this, SIGNAL( mouseDoubleClicked(SUIT_ViewWindow*, QMouseEvent*) ) ); connect( theView, SIGNAL( mousePressed(SUIT_ViewWindow*, QMouseEvent*) ), this, SIGNAL( mousePressed(SUIT_ViewWindow*, QMouseEvent*) ) ); + // The signal is used to mouse pressed for choose the current window + connect( theView, SIGNAL( mousePressed(SUIT_ViewWindow*, QMouseEvent*) ), + this, SLOT( onMousePressed(SUIT_ViewWindow*, QMouseEvent*) ) ); connect( theView, SIGNAL( mouseReleased(SUIT_ViewWindow*, QMouseEvent*) ), this, SIGNAL( mouseReleased(SUIT_ViewWindow*, QMouseEvent*) ) ); connect( theView, SIGNAL( mouseMoving(SUIT_ViewWindow*, QMouseEvent*) ), @@ -579,6 +593,11 @@ void OCCViewer_ViewFrame::onContextMenuRequested(QContextMenuEvent*) myPopupRequestedView = dynamic_cast(sender()); } +void OCCViewer_ViewFrame::onMousePressed(SUIT_ViewWindow* view, QMouseEvent*) +{ + myActiveView = dynamic_cast(view); +} + void OCCViewer_ViewFrame::onDumpView() { if (myPopupRequestedView) { diff --git a/src/OCCViewer/OCCViewer_ViewFrame.h b/src/OCCViewer/OCCViewer_ViewFrame.h index 1e56502da..8c0481398 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.h +++ b/src/OCCViewer/OCCViewer_ViewFrame.h @@ -46,6 +46,8 @@ public: OCCViewer_ViewWindow* getView( const int ) const; + OCCViewer_ViewWindow* getActiveView() const; + virtual OCCViewer_ViewPort3d* getViewPort() { return getView(MAIN_VIEW)->getViewPort(); } OCCViewer_ViewPort3d* getViewPort(int theView); @@ -161,6 +163,7 @@ protected: private slots: void onContextMenuRequested(QContextMenuEvent*); + void onMousePressed(SUIT_ViewWindow*, QMouseEvent*); private: void connectViewSignals( OCCViewer_ViewWindow* theView ); @@ -171,6 +174,7 @@ private: QList myViews; QGridLayout* myLayout; OCCViewer_ViewWindow* myMaximizedView; + OCCViewer_ViewWindow* myActiveView; int mySplitMode; QList myViewsMode; diff --git a/src/Qtx/QtxWorkstack.cxx b/src/Qtx/QtxWorkstack.cxx index cd8944258..fcc14df28 100644 --- a/src/Qtx/QtxWorkstack.cxx +++ b/src/Qtx/QtxWorkstack.cxx @@ -3190,21 +3190,76 @@ bool QtxWorkstack::opaqueResize() const } /*! - \brief Show/Hide active tab bar. + \brief Show/hide splitter state and area. + \param widget and parent area will be shown/hidden + \param split splitter will be shown/hidden + \param visible splitter */ -void QtxWorkstack::showActiveTabBar( bool visible ) +void QtxWorkstack::splitterVisible(QWidget* widget, QList& parentList, QSplitter* split, bool visible) { + QList recList; + splitters( split, recList, false ); + for ( QList::iterator itr = recList.begin(); itr != recList.end(); ++itr ) { + parentList.prepend( *itr ); + splitterVisible( widget, parentList, *itr, visible ); + } + QList areaList; - areas( mySplit, areaList, true ); - QList::ConstIterator it; - for ( it = areaList.begin(); it != areaList.end(); ++it ) - { - (*it)->showTabBar( visible ); + areas( split, areaList, false ); + for ( QList::const_iterator it = areaList.begin(); it != areaList.end(); ++it ) { + QtxWorkstackArea* area = *it; + bool isCurrentWidget = false; + area->showTabBar(visible); + + QList childList = area->childList(); + for ( QList::iterator itr = childList.begin(); itr != childList.end(); ++itr ) { + QWidget* aCurWid = (*itr)->widget(); + if ( aCurWid == widget ) { + isCurrentWidget = true; + aCurWid->setVisible( true ); + } + else + aCurWid->setVisible( visible ); + } + + if ( !isCurrentWidget || visible ) + area->setVisible( visible ); + + if ( isCurrentWidget || visible ) { + QSplitter* pSplit = splitter( area ); + int count = pSplit->count(); + for ( int i = 0; i < count; i++ ) { + if ( pSplit->indexOf( area ) == i && !visible ) + continue; + pSplit->widget(i)->setVisible( visible ); + } + for ( QList::iterator itr = parentList.begin(); itr != parentList.end() && pSplit != mySplit; ++itr ) { + if ( pSplit == *itr ) + continue; + QList splitlist; + splitters( *itr, splitlist, false ); + for ( QList::iterator iter = splitlist.begin(); iter != splitlist.end(); ++iter ) { + if ( pSplit == (*iter) ) { + pSplit = *itr; + continue; + } + (*iter)->setVisible(visible); + } + } + } } - QList recList; - splitters( mySplit, recList, true ); - for ( QList::iterator itr = recList.begin(); itr != recList.end(); ++itr ) - (*itr)->setVisible(visible); +} + +/*! + \brief Show/hide splitters state and area. + \param widget and parent area will be shown/hidden + \param visible splitters +*/ +void QtxWorkstack::splittersVisible(QWidget* widget, bool visible ) +{ + QList parentList; + parentList.append(mySplit); + splitterVisible(widget, parentList, mySplit, visible ); } /*! diff --git a/src/Qtx/QtxWorkstack.h b/src/Qtx/QtxWorkstack.h index 6d8e89bd2..25be96a43 100644 --- a/src/Qtx/QtxWorkstack.h +++ b/src/Qtx/QtxWorkstack.h @@ -116,13 +116,15 @@ public: void setOpaqueResize( bool = true ); bool opaqueResize() const; - void showActiveTabBar( bool = true ); + void splittersVisible( QWidget*, bool = true ); void Split( QWidget* wid, const Qt::Orientation o, const SplitType type ); void Attract( QWidget* wid1, QWidget* wid2, const bool all ); void SetRelativePosition( QWidget* wid, const Qt::Orientation o, const double pos ); void SetRelativePositionInSplitter( QWidget* wid, const double pos ); + void updateState(); + signals: void windowActivated( QWidget* ); @@ -166,9 +168,10 @@ private: QtxWorkstackArea* createArea( QWidget* ) const; - void updateState(); void updateState( QSplitter* ); + void splitterVisible(QWidget*, QList&, QSplitter*, bool ); + void distributeSpace( QSplitter* ) const; int setPosition( QWidget* wid, QSplitter* split, const Qt::Orientation o, diff --git a/src/SVTK/SVTK_InteractorStyle.cxx b/src/SVTK/SVTK_InteractorStyle.cxx index 5ab2ac63a..c824589da 100644 --- a/src/SVTK/SVTK_InteractorStyle.cxx +++ b/src/SVTK/SVTK_InteractorStyle.cxx @@ -1200,6 +1200,11 @@ void SVTK_InteractorStyle::onFinishOperation() if( anActorCollection ) { + if( !myShiftState && + anActorCollection->GetNumberOfItems () > 1 && + myLastHighlitedActor.GetPointer() ) { + anActorCollection->RemoveItem ( myLastHighlitedActor.GetPointer() ); + } anActorCollection->InitTraversal(); while( vtkActor* aVTKActor = anActorCollection->GetNextActor() ) { -- 2.39.2