From 98f6f008de828f33e7b0b951e33fe3057ef5d8c1 Mon Sep 17 00:00:00 2001 From: imn Date: Thu, 16 Jul 2015 16:06:25 +0300 Subject: [PATCH] 0023105: [CEA 1535] Be able to active stereo in VTK view and to choose which kind of stereo mode --- src/LightApp/LightApp_Application.cxx | 81 +++++++++ src/LightApp/LightApp_FullScreenHelper.cxx | 59 ++++++- src/LightApp/LightApp_FullScreenHelper.h | 3 +- src/LightApp/resources/LightApp.xml | 3 + src/LightApp/resources/LightApp_msg_en.ts | 36 ++++ src/LightApp/resources/LightApp_msg_fr.ts | 36 ++++ src/LightApp/resources/LightApp_msg_ja.ts | 36 ++++ src/Qtx/QtxWorkstack.cxx | 37 ++++- src/Qtx/QtxWorkstack.h | 5 + src/SVTK/CMakeLists.txt | 1 + src/SVTK/SVTK_InteractorStyle.cxx | 5 - src/SVTK/SVTK_ViewModel.cxx | 79 ++++++++- src/SVTK/SVTK_ViewModel.h | 22 +++ src/SVTK/SVTK_ViewParameterDlg.cxx | 4 +- src/SVTK/SVTK_ViewWindow.cxx | 183 +++++++++++++++++++-- src/SVTK/SVTK_ViewWindow.h | 19 ++- src/SVTK/resources/SVTK_images.ts | 4 + src/SVTK/resources/SVTK_msg_en.ts | 50 +++++- src/SVTK/resources/SVTK_msg_fr.ts | 50 +++++- src/SVTK/resources/SVTK_msg_ja.ts | 48 ++++++ src/SVTK/resources/vtk_view_stereo.png | Bin 0 -> 1070 bytes 21 files changed, 724 insertions(+), 37 deletions(-) create mode 100644 src/SVTK/resources/vtk_view_stereo.png diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index ab27384ed..ed6e0e8e2 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1562,6 +1562,8 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType if( vm ) { vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) ); + vm->setStereoType( resMgr->integerValue( "VTKViewer", "stereo_type", vm->stereoType() ) ); + vm->setAnaglyphFilter( resMgr->integerValue( "VTKViewer", "anaglyph_filter", vm->anaglyphFilter() ) ); vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) ); vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ), resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ) ); @@ -2258,6 +2260,13 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) pref->setItemProperty( "strings", aValuesList, mruLinkType ); pref->setItemProperty( "indexes", anIndicesList, mruLinkType ); // ... "MRU" preferences group <> + // ... "Full-screen" group <> + int fullScreenGroup = pref->addPreference( tr( "PREF_GROUP_FULL_SCREEN" ), genTab ); + pref->setItemProperty( "columns", 2, fullScreenGroup ); + // .... -> automatic hiding toolbars + pref->addPreference( tr( "PREF_FULL_SCREEN_AUTO" ), fullScreenGroup, + LightApp_Preferences::Bool, "OCCViewer", "automatic_hiding" ); + // ... "Full-screen" group <> // .. "General" preferences tab <> // .. "3D viewer" group <> @@ -2426,10 +2435,40 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) anIndicesList << 0 << 1; pref->setItemProperty( "strings", aValuesList, vtkProjMode ); pref->setItemProperty( "indexes", anIndicesList, vtkProjMode ); + + // .... -> Stereo group + int vtkStereoGroup = pref->addPreference( tr( "PREF_GROUP_STEREO" ), vtkGroup); + pref->setItemProperty( "columns", 2, vtkStereoGroup ); + // .... -> Stereo type + int vtkStereoType = pref->addPreference( tr( "PREF_STEREO_TYPE" ), vtkStereoGroup, + LightApp_Preferences::Selector, "VTKViewer", "stereo_type" ); + aValuesList.clear(); + anIndicesList.clear(); + idList.clear(); + SVTK_Viewer::stereoData( aValuesList, idList); + foreach( int gid, idList ) anIndicesList << gid; + pref->setItemProperty( "strings", aValuesList, vtkStereoType ); + pref->setItemProperty( "indexes", anIndicesList, vtkStereoType ); + // .... -> Anaglyph filter + int vtkAnaglyphFilter = pref->addPreference( tr( "PREF_ANAGLYPH_FILTER" ), vtkStereoGroup, + LightApp_Preferences::Selector, "VTKViewer", "anaglyph_filter" ); + aValuesList.clear(); + anIndicesList.clear(); + aValuesList << tr("PREF_ANAGLYPH_RED_CYAN") << tr("PREF_ANAGLYPH_YELLOW_BLUE") << tr("PREF_ANAGLYPH_GREEN_MAGENTA"); + anIndicesList << 0 << 1 << 2; + + pref->setItemProperty( "strings", aValuesList, vtkAnaglyphFilter ); + pref->setItemProperty( "indexes", anIndicesList, vtkAnaglyphFilter ); + + // .... -> Enable quad-buffer support + pref->addPreference( tr( "PREF_ENABLE_QUAD_BUFFER_SUPPORT" ), vtkStereoGroup, + LightApp_Preferences::Bool, "VTKViewer", "enable_quad_buffer_support" ); + // .... -> background aValuesList.clear(); anIndicesList.clear(); txtList.clear(); + idList.clear(); #ifndef DISABLE_SALOMEOBJECT formats = SVTK_Viewer::backgroundData( aValuesList, idList, txtList ); #endif @@ -3060,6 +3099,48 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString } #endif +#ifndef DISABLE_VTKVIEWER + if ( sec == QString( "VTKViewer" ) && param == QString( "stereo_type" ) ) + { + int mode = resMgr->integerValue( "VTKViewer", "stereo_type", 0 ); + QList lst; +#ifndef DISABLE_SALOMEOBJECT + viewManagers( SVTK_Viewer::Type(), lst ); + QListIterator it( lst ); + while ( it.hasNext() ) + { + SUIT_ViewModel* vm = it.next()->getViewModel(); + if ( !vm || !vm->inherits( "SVTK_Viewer" ) ) + continue; + + SVTK_Viewer* vtkVM = dynamic_cast( vm ); + if( vtkVM ) vtkVM->setStereoType( mode ); + } +#endif + } +#endif + +#ifndef DISABLE_VTKVIEWER + if ( sec == QString( "VTKViewer" ) && param == QString( "anaglyph_filter" ) ) + { + int mode = resMgr->integerValue( "VTKViewer", "anaglyph_filter", 0 ); + QList lst; +#ifndef DISABLE_SALOMEOBJECT + viewManagers( SVTK_Viewer::Type(), lst ); + QListIterator it( lst ); + while ( it.hasNext() ) + { + SUIT_ViewModel* vm = it.next()->getViewModel(); + if ( !vm || !vm->inherits( "SVTK_Viewer" ) ) + continue; + + SVTK_Viewer* vtkVM = dynamic_cast( vm ); + if( vtkVM ) vtkVM->setAnaglyphFilter( mode ); + } +#endif + } +#endif + #ifndef DISABLE_VTKVIEWER if ( sec == QString( "VTKViewer" ) && param == QString( "preselection" ) ) { diff --git a/src/LightApp/LightApp_FullScreenHelper.cxx b/src/LightApp/LightApp_FullScreenHelper.cxx index 2960e4edb..7ddce9822 100644 --- a/src/LightApp/LightApp_FullScreenHelper.cxx +++ b/src/LightApp/LightApp_FullScreenHelper.cxx @@ -27,12 +27,18 @@ #include #include #include +#include + +#include #include +#include #include #include #include +#include +#include #include "LightApp_FullScreenHelper.h" #include "LightApp_Application.h" @@ -74,6 +80,35 @@ void LightApp_FullScreenHelper::switchToFullScreen() { if(!desktop) return; + 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 ); + //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(); + } + } + } + if (anActiveWindow) + anActiveWindow->show(); + desktop->setWindowState(desktop->windowState() ^ Qt::WindowFullScreen); if(desktop->menuBar()) @@ -92,7 +127,7 @@ void LightApp_FullScreenHelper::switchToFullScreen() { myDocWidgetMap.clear(); 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) { @@ -153,6 +188,28 @@ void LightApp_FullScreenHelper::switchToNormalScreen() { desktop->setWindowState(desktop->windowState() ^ Qt::WindowFullScreen); + STD_TabDesktop* desk = dynamic_cast( desktop ); + + 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(); + } + } + } DocWidgetMap::iterator it = myDocWidgetMap.begin(); for( ;it != myDocWidgetMap.end() ; it++ ) { diff --git a/src/LightApp/LightApp_FullScreenHelper.h b/src/LightApp/LightApp_FullScreenHelper.h index 7cc443514..e5f4dedf4 100644 --- a/src/LightApp/LightApp_FullScreenHelper.h +++ b/src/LightApp/LightApp_FullScreenHelper.h @@ -46,10 +46,9 @@ class LIGHTAPP_EXPORT LightApp_FullScreenHelper { private: typedef QMap DocWidgetMap; DocWidgetMap myDocWidgetMap; - typedef QMap ToolBarMap; ToolBarMap myToolBarMap; - + QList myWindowsList; bool myStatusBarVisibility; diff --git a/src/LightApp/resources/LightApp.xml b/src/LightApp/resources/LightApp.xml index c8034c4bc..5af653a27 100644 --- a/src/LightApp/resources/LightApp.xml +++ b/src/LightApp/resources/LightApp.xml @@ -159,6 +159,9 @@ + + + diff --git a/src/LightApp/resources/LightApp_msg_en.ts b/src/LightApp/resources/LightApp_msg_en.ts index e146f8654..c35522f02 100644 --- a/src/LightApp/resources/LightApp_msg_en.ts +++ b/src/LightApp/resources/LightApp_msg_en.ts @@ -627,6 +627,34 @@ The changes will be applied on the next application session. PREF_GROUP_OCCVIEWER OCC 3D Viewer + + PREF_GROUP_STEREO + Stereo render + + + PREF_STEREO_TYPE + Stereo type + + + PREF_ANAGLYPH_FILTER + Anaglyph filter + + + PREF_ANAGLYPH_RED_CYAN + Red-Cyan + + + PREF_ANAGLYPH_YELLOW_BLUE + Yellow-Blue + + + PREF_ANAGLYPH_GREEN_MAGENTA + Green-Magenta + + + PREF_ENABLE_QUAD_BUFFER_SUPPORT + Enable quad-buffer support + PREF_LOGARITHMIC Logarithmic @@ -888,6 +916,14 @@ File does not exist PREF_GROUP_SHORTCUTS Shortcuts settings + + PREF_GROUP_FULL_SCREEN + Full-screen + + + PREF_FULL_SCREEN_AUTO + Hide object browser and viewers toolbars + PREF_TAB_PYEDITOR Python Viewer diff --git a/src/LightApp/resources/LightApp_msg_fr.ts b/src/LightApp/resources/LightApp_msg_fr.ts index 81ca07de7..80af332b3 100755 --- a/src/LightApp/resources/LightApp_msg_fr.ts +++ b/src/LightApp/resources/LightApp_msg_fr.ts @@ -627,6 +627,34 @@ Les modifications seront appliquées à la prochaine session. PREF_GROUP_OCCVIEWER Scène OCC 3D + + PREF_GROUP_STEREO + Stereo render + + + PREF_STEREO_TYPE + Stereo type + + + PREF_ANAGLYPH_FILTER + Anaglyph filter + + + PREF_ANAGLYPH_RED_CYAN + Red-Cyan + + + PREF_ANAGLYPH_YELLOW_BLUE + Yellow-Blue + + + PREF_ANAGLYPH_GREEN_MAGENTA + Green-Magenta + + + PREF_ENABLE_QUAD_BUFFER_SUPPORT + Enable quad-buffer support + PREF_LOGARITHMIC Logarithmique @@ -888,6 +916,14 @@ Le fichier n'existe pas PREF_GROUP_SHORTCUTS Réglage des raccourcis clavier + + PREF_GROUP_FULL_SCREEN + Full-screen + + + PREF_FULL_SCREEN_AUTO + Hide object browser and viewers toolbars + PREF_TAB_PYEDITOR Editeur python diff --git a/src/LightApp/resources/LightApp_msg_ja.ts b/src/LightApp/resources/LightApp_msg_ja.ts index 881dd0507..42400f42e 100644 --- a/src/LightApp/resources/LightApp_msg_ja.ts +++ b/src/LightApp/resources/LightApp_msg_ja.ts @@ -627,6 +627,34 @@ CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITASPREF_GROUP_OCCVIEWER OCC 3D Viewer + + PREF_GROUP_STEREO + Stereo render + + + PREF_STEREO_TYPE + Stereo type + + + PREF_ANAGLYPH_FILTER + Anaglyph filter + + + PREF_ANAGLYPH_RED_CYAN + Red-Cyan + + + PREF_ANAGLYPH_YELLOW_BLUE + Yellow-Blue + + + PREF_ANAGLYPH_GREEN_MAGENTA + Green-Magenta + + + PREF_ENABLE_QUAD_BUFFER_SUPPORT + Enable quad-buffer support + PREF_LOGARITHMIC 対数 @@ -887,6 +915,14 @@ CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITASPREF_GROUP_SHORTCUTS ショートカットの設定 + + PREF_GROUP_FULL_SCREEN + Full-screen + + + PREF_FULL_SCREEN_AUTO + Hide object browser and viewers toolbars + PREF_TAB_PYEDITOR Python Viewer diff --git a/src/Qtx/QtxWorkstack.cxx b/src/Qtx/QtxWorkstack.cxx index b4abe7b8f..cd8944258 100644 --- a/src/Qtx/QtxWorkstack.cxx +++ b/src/Qtx/QtxWorkstack.cxx @@ -528,16 +528,16 @@ QtxWorkstackArea::QtxWorkstackArea( QWidget* parent ) base->setMargin( frameWidth() ); base->setSpacing( 0 ); - QWidget* top = new QWidget( this ); - base->addWidget( top ); + myTop = new QWidget( this ); + base->addWidget( myTop ); - QHBoxLayout* tl = new QHBoxLayout( top ); + QHBoxLayout* tl = new QHBoxLayout( myTop ); tl->setMargin( 0 ); - myBar = new QtxWorkstackTabBar( top ); + myBar = new QtxWorkstackTabBar( myTop ); tl->addWidget( myBar, 1 ); - CloseButton* close = new CloseButton( top ); + CloseButton* close = new CloseButton( myTop ); close->setIcon( style()->standardIcon( QStyle::SP_TitleBarCloseButton ) ); myClose = close; tl->addWidget( myClose ); @@ -902,6 +902,16 @@ bool QtxWorkstackArea::restoreState( QDataStream& stream, QMapsetVisible(visible); + myBar->setVisible(visible); +} + + /*! \brief Get rectangle to be drawn when highlighting drop area. \return area drop rectangle @@ -3179,6 +3189,23 @@ bool QtxWorkstack::opaqueResize() const return mySplit->opaqueResize(); } +/*! + \brief Show/Hide active tab bar. +*/ +void QtxWorkstack::showActiveTabBar( bool visible ) +{ + QList areaList; + areas( mySplit, areaList, true ); + QList::ConstIterator it; + for ( it = areaList.begin(); it != areaList.end(); ++it ) + { + (*it)->showTabBar( visible ); + } + QList recList; + splitters( mySplit, recList, true ); + for ( QList::iterator itr = recList.begin(); itr != recList.end(); ++itr ) + (*itr)->setVisible(visible); +} /*! \fn void QtxWorkstack::windowActivated( QWidget* w ) diff --git a/src/Qtx/QtxWorkstack.h b/src/Qtx/QtxWorkstack.h index 8772058a5..6d8e89bd2 100644 --- a/src/Qtx/QtxWorkstack.h +++ b/src/Qtx/QtxWorkstack.h @@ -116,6 +116,8 @@ public: void setOpaqueResize( bool = true ); bool opaqueResize() const; + void showActiveTabBar( 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 ); @@ -244,6 +246,8 @@ public: void saveState( QDataStream& ) const; bool restoreState( QDataStream&, QMap& ); + void showTabBar( bool = true); + signals: void activated( QWidget* ); void contextMenuRequested( QWidget*, QPoint ); @@ -294,6 +298,7 @@ private: typedef QList ChildList; private: + QWidget* myTop; //!< workarea top widget QtxWorkstackTabBar* myBar; //!< workarea tab bar header ChildList myList; //!< child widgets list QAbstractButton* myClose; //!< close button diff --git a/src/SVTK/CMakeLists.txt b/src/SVTK/CMakeLists.txt index 69f99a014..53a802ae3 100755 --- a/src/SVTK/CMakeLists.txt +++ b/src/SVTK/CMakeLists.txt @@ -139,6 +139,7 @@ SET(_other_RESOURCES resources/vtk_view_rotation_point.png resources/vtk_view_scaling.png resources/vtk_view_selection.png + resources/vtk_view_stereo.png resources/vtk_view_style_switch.png resources/vtk_view_update_rate.png resources/vtk_view_zooming_style_switch.png diff --git a/src/SVTK/SVTK_InteractorStyle.cxx b/src/SVTK/SVTK_InteractorStyle.cxx index 6a94115f5..5ab2ac63a 100644 --- a/src/SVTK/SVTK_InteractorStyle.cxx +++ b/src/SVTK/SVTK_InteractorStyle.cxx @@ -1200,11 +1200,6 @@ void SVTK_InteractorStyle::onFinishOperation() if( anActorCollection ) { - if( !myShiftState && - anActorCollection->GetNumberOfItems () > 1 && - myLastHighlitedActor.GetPointer() ) { - anActorCollection->RemoveItem ( myLastHighlitedActor.GetPointer() ); - } anActorCollection->InitTraversal(); while( vtkActor* aVTKActor = anActorCollection->GetNextActor() ) { diff --git a/src/SVTK/SVTK_ViewModel.cxx b/src/SVTK/SVTK_ViewModel.cxx index 977da9440..9109c2f80 100644 --- a/src/SVTK/SVTK_ViewModel.cxx +++ b/src/SVTK/SVTK_ViewModel.cxx @@ -84,6 +84,8 @@ SVTK_Viewer::SVTK_Viewer() myIncrementSpeed = 10; myIncrementMode = 0; myProjMode = 0; + myStereoType = 0; + myAnaglyphFilter = 0; myStyle = 0; myZoomingStyle = 0; mySelectionEnabled = true; @@ -126,6 +128,21 @@ QString SVTK_Viewer::backgroundData( QStringList& gradList, QIntList& idList, QI return tr("BG_IMAGE_FILES"); } +/*! Get data for supported background modes: gradient types, identifiers and supported image formats */ +void SVTK_Viewer::stereoData( QStringList& typeList, QIntList& idList ) +{ + typeList << tr("ST_CRYSTALEYES") << tr("ST_REDBLUE") << + tr("ST_INTERLACED") << tr("ST_LEFT") << + tr("ST_RIGHT") << tr("ST_DRESDEN") << + tr("ST_ANAGLYPH") << tr("ST_CHECKERBOARD") << + tr("ST_SPLITVIEWPORTHORIZONTAL"); + idList << CrystalEyesType << RedBlueType << + InterlacedType << LeftType << + RightType << DresdenType << + AnaglyphType << CheckerboardType << + SplitViewPortHorizontalType; +} + //! Get background color of the viewer [obsolete] QColor SVTK_Viewer::backgroundColor() const { @@ -177,6 +194,8 @@ SUIT_ViewWindow* SVTK_Viewer::createView( SUIT_Desktop* theDesktop ) aViewWindow->SetTrihedronSize( trihedronSize(), trihedronRelative() ); aViewWindow->SetStaticTrihedronVisible( isStaticTrihedronVisible() ); aViewWindow->SetProjectionMode( projectionMode() ); + aViewWindow->SetStereoType( stereoType() ); + aViewWindow->SetAnaglyphFilter( anaglyphFilter() ); aViewWindow->SetInteractionStyle( interactionStyle() ); aViewWindow->SetZoomingStyle( zoomingStyle() ); aViewWindow->SetPreSelectionMode( preSelectionMode() ); @@ -270,8 +289,8 @@ int SVTK_Viewer::projectionMode() const void SVTK_Viewer::setProjectionMode( const int theMode ) { if ( myProjMode != theMode ) { - myProjMode = theMode; - + if ( theMode != SVTK_ViewWindow::Stereo ) + myProjMode = theMode; if (SUIT_ViewManager* aViewManager = getViewManager()) { QVector aViews = aViewManager->getViews(); for ( uint i = 0; i < aViews.count(); i++ ) @@ -283,6 +302,62 @@ void SVTK_Viewer::setProjectionMode( const int theMode ) } } +/*! + \return stereo type +*/ +int SVTK_Viewer::stereoType() const +{ + return myStereoType; +} + +/*! + Sets stereo type + \param theType - new stereo type +*/ +void SVTK_Viewer::setStereoType( const int theType ) +{ + if ( myStereoType != theType ) { + myStereoType = theType; + + if (SUIT_ViewManager* aViewManager = getViewManager()) { + QVector aViews = aViewManager->getViews(); + for ( uint i = 0; i < aViews.count(); i++ ) + { + if ( TViewWindow* aView = dynamic_cast(aViews.at( i )) ) + aView->SetStereoType( theType ); + } + } + } +} + +/*! + \return anaglyph filter +*/ +int SVTK_Viewer::anaglyphFilter() const +{ + return myAnaglyphFilter; +} + +/*! + Sets anaglyph filter + \param theFilter - new anaglyph filter +*/ +void SVTK_Viewer::setAnaglyphFilter( const int theFilter ) +{ + if ( myAnaglyphFilter != theFilter ) { + myAnaglyphFilter = theFilter; + + if (SUIT_ViewManager* aViewManager = getViewManager()) { + QVector aViews = aViewManager->getViews(); + for ( uint i = 0; i < aViews.count(); i++ ) + { + if ( TViewWindow* aView = dynamic_cast(aViews.at( i )) ) + aView->SetAnaglyphFilter( theFilter ); + } + } + } +} + /*! \return interaction style */ diff --git a/src/SVTK/SVTK_ViewModel.h b/src/SVTK/SVTK_ViewModel.h index 5215a2556..b5f04839a 100644 --- a/src/SVTK/SVTK_ViewModel.h +++ b/src/SVTK/SVTK_ViewModel.h @@ -60,11 +60,19 @@ public: LastGradient = FourthCornerGradient, }; + enum { + CrystalEyesType, RedBlueType, + InterlacedType, LeftType, + RightType, DresdenType, + AnaglyphType, CheckerboardType, + SplitViewPortHorizontalType + }; typedef SVTK_ViewWindow TViewWindow; //! Define string representation of the viewer type static QString Type() { return "VTKViewer"; } static QString backgroundData( QStringList&, QIntList&, QIntList& ); + static void stereoData( QStringList&, QIntList&); SVTK_Viewer(); virtual ~SVTK_Viewer(); @@ -114,6 +122,18 @@ public: //! Sets projection mode void setProjectionMode( const int ); + //! Gets stereo type + int stereoType() const; + + //! Sets stereo type + void setStereoType( const int ); + + //! Gets anaglyph filter + int anaglyphFilter() const; + + //! Sets anaglyph filter + void setAnaglyphFilter( const int ); + //! Gets interaction style int interactionStyle() const; @@ -206,6 +226,8 @@ private: int myIncrementSpeed; int myIncrementMode; int myProjMode; + int myStereoType; + int myAnaglyphFilter; int myStyle; int myZoomingStyle; Preselection_Mode myPreSelectionMode; diff --git a/src/SVTK/SVTK_ViewParameterDlg.cxx b/src/SVTK/SVTK_ViewParameterDlg.cxx index f686464c3..6db03e854 100755 --- a/src/SVTK/SVTK_ViewParameterDlg.cxx +++ b/src/SVTK/SVTK_ViewParameterDlg.cxx @@ -500,8 +500,8 @@ void SVTK_ViewParameterDlg::onProjectionModeChanged(int mode) vtkCamera* aCamera = myRWInteractor->getRenderer()->GetActiveCamera(); aCamera->SetParallelProjection(aBtn == 0); - - myMainWindow->activateProjectionMode(aBtn); + if (!myBusy) + myMainWindow->activateProjectionMode(!aBtn); // update view myRWInteractor->GetDevice()->CreateTimer(VTKI_TIMER_FIRST); diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index 88bb74354..88bee3fc5 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -103,6 +103,8 @@ #include +#include + namespace SVTK { int convertAction( const int accelAction ) @@ -183,6 +185,9 @@ void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel) myInteractor->setBackgroundRole( QPalette::NoRole );//NoBackground myInteractor->setFocusPolicy(Qt::StrongFocus); myInteractor->setFocus(); + bool isSupportQuadBuffer = SUIT_Session::session()->resourceMgr()-> + booleanValue( "VTKViewer", "enable_quad_buffer_support", false ); + myInteractor->getRenderWindow()->SetStereoCapableWindow((int)isSupportQuadBuffer); setFocusProxy(myInteractor); myUpdateRateDlg = new SVTK_UpdateRateDlg( getAction( UpdateRate ), this, "SVTK_UpdateRateDlg" ); @@ -850,13 +855,145 @@ double SVTK_ViewWindow::GetTrihedronSize() const /*! Sets projection mode - \param theMode - projection mode ( 0 - orthogonal, 1 - perspective ) + \param theMode - projection mode ( 0 - orthogonal, 1 - perspective, 2 - stereo ) */ void SVTK_ViewWindow::SetProjectionMode(const int theMode) { - activateProjectionMode( theMode ); + SVTK_Viewer* aViewer = dynamic_cast(myModel); + + if ( theMode != Stereo ) { + aViewer->setProjectionMode(theMode); + bool anIsParallelMode = (theMode == Parallel); + vtkCamera* aCamera = getRenderer()->GetActiveCamera(); + aCamera->SetParallelProjection(anIsParallelMode); + GetInteractor()->GetDevice()->CreateTimer(VTKI_TIMER_FIRST); + getRenderWindow()->SetStereoRender(0); + } + else { + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + SetStereoType( aResMgr->integerValue( "VTKViewer", "stereo_type", 0 ) ); + getRenderWindow()->SetStereoRender(1); + } + Repaint(); + + // update action state if method is called outside + QtxAction* aParallelAction = dynamic_cast( toolMgr()->action( ParallelModeId ) ); + QtxAction* aProjectionAction = dynamic_cast( toolMgr()->action( ProjectionModeId ) ); + QtxAction* aStereoAction = dynamic_cast( toolMgr()->action( StereoModeId ) ); + QtxAction* aSwitchZoomingStyle = dynamic_cast( toolMgr()->action( SwitchZoomingStyleId ) ); + if ( theMode == Parallel && !aParallelAction->isChecked() ) { + aParallelAction->setChecked( true ); + aSwitchZoomingStyle->setEnabled(true); + aStereoAction->setChecked( false ); + } + if ( theMode == Projection && !aProjectionAction->isChecked() ) { + aProjectionAction->setChecked( true ); + aSwitchZoomingStyle->setEnabled(false); + } + if ( theMode == Stereo ) { + aStereoAction->setChecked( true ); + if ( aParallelAction->isEnabled() ) { + aParallelAction->setEnabled( false ); + aParallelAction->setChecked( false ); + aStereoAction->setChecked( false ); + } + else { + aParallelAction->setEnabled( true ); + aStereoAction->setChecked( false ); + aParallelAction->setChecked( aViewer->projectionMode() == Parallel ); + } + if ( aProjectionAction->isEnabled() ) { + aProjectionAction->setEnabled( false ); + aProjectionAction->setChecked( true ); + if ( getRenderWindow()->GetStereoCapableWindow() == 1 && !isOpenGlStereoSupport() && + strcmp( "CrystalEyes", getRenderWindow()->GetStereoTypeAsString() ) == 0 ){ + SUIT_MessageBox::warning( 0, tr( "WRN_WARNING" ), tr( "WRN_SUPPORT_QUAD_BUFFER" ) ); + } + } + else { + aProjectionAction->setEnabled( true ); + aStereoAction->setChecked( false ); + aProjectionAction->setChecked( aViewer->projectionMode() == Projection ); + onPerspectiveMode(); + } + } + else { + if ( !aParallelAction->isEnabled() ) + aParallelAction->setEnabled( true ); + if ( !aProjectionAction->isEnabled() ) + aProjectionAction->setEnabled( true ); + } +} + +/*! + Sets stereo type + \param theType - stereo type +*/ +void SVTK_ViewWindow::SetStereoType(const int theType) +{ + vtkRenderWindow* aWindow = getRenderWindow(); + switch (theType ) { + case CrystalEyes: + aWindow->SetStereoTypeToCrystalEyes(); + break; + case RedBlue: + aWindow->SetStereoTypeToRedBlue(); + break; + case Interlaced: + aWindow->SetStereoTypeToInterlaced(); + break; + case Left: + aWindow->SetStereoTypeToLeft(); + break; + case Right: + aWindow->SetStereoTypeToRight(); + break; + case Dresden: + aWindow->SetStereoTypeToDresden(); + break; + case Anaglyph: + aWindow->SetStereoTypeToAnaglyph(); + break; + case Checkerboard: + aWindow->SetStereoTypeToCheckerboard(); + break; + case SplitViewPortHorizontal: + aWindow->SetStereoTypeToSplitViewportHorizontal(); + break; + } +} + +/*! + Sets anaglyph filter + \param theFilter - anaglyph filter +*/ +void SVTK_ViewWindow::SetAnaglyphFilter(const int theFilter) +{ + vtkRenderWindow* aWindow = getRenderWindow(); + switch (theFilter ) { + case RedCyan: + aWindow->SetAnaglyphColorMask(4,3); + break; + case YellowBlue: + aWindow->SetAnaglyphColorMask(6,1); + break; + case GreenMagenta: + aWindow->SetAnaglyphColorMask(2,5); + break; + } } +/*! + \return OpenGl stereo support +*/ +bool SVTK_ViewWindow::isOpenGlStereoSupport() const +{ + GLboolean support[1]; + glGetBooleanv (GL_STEREO, support); + if ( support[0] ) + return true; + return false; +} /*! Set the gravity center as a focal point @@ -884,10 +1021,17 @@ void SVTK_ViewWindow::activateStartFocalPointSelection() void SVTK_ViewWindow::activateProjectionMode(int theMode) { + QtxAction* aParallelAction = dynamic_cast( toolMgr()->action( ParallelModeId ) ); + QtxAction* aProjectionAction = dynamic_cast( toolMgr()->action( ProjectionModeId ) ); if (theMode) - toolMgr()->action( ProjectionModeId )->setChecked( true ); + aParallelAction->setChecked( true ); else - toolMgr()->action( ParallelModeId )->setChecked( true ); + aProjectionAction->setChecked( true ); + + if ( !aParallelAction->isEnabled() ) + aParallelAction->setEnabled( true ); + if ( !aProjectionAction->isEnabled() ) + aProjectionAction->setEnabled( true ); } /*! @@ -1891,16 +2035,12 @@ void SVTK_ViewWindow::activateStartPointSelection( Selection_Mode theSelectionMo */ void SVTK_ViewWindow::onPerspectiveMode() { - bool anIsParallelMode = toolMgr()->action( ParallelModeId )->isChecked(); - - // advanced zooming is not available in perspective mode - if( QtxAction* anAction = getAction( SwitchZoomingStyleId ) ) - anAction->setEnabled( anIsParallelMode ); - - vtkCamera* aCamera = getRenderer()->GetActiveCamera(); - aCamera->SetParallelProjection(anIsParallelMode); - GetInteractor()->GetDevice()->CreateTimer(VTKI_TIMER_FIRST); - + if (toolMgr()->action( ParallelModeId )->isChecked()) + SetProjectionMode( Parallel); + if (toolMgr()->action( ProjectionModeId )->isChecked()) + SetProjectionMode( Projection); + if (toolMgr()->action( StereoModeId )->isChecked()) + SetProjectionMode( Stereo); emit transformed( this ); } @@ -2110,7 +2250,7 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr) tr( "MNU_SVTK_PARALLEL_MODE" ), 0, this); anAction->setStatusTip(tr("DSC_SVTK_PARALLEL_MODE")); anAction->setCheckable(true); - connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onPerspectiveMode())); + //connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onPerspectiveMode())); mgr->registerAction( anAction, ParallelModeId ); anAction = new QtxAction(tr("MNU_SVTK_PERSPECTIVE_MODE"), @@ -2118,12 +2258,22 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr) tr( "MNU_SVTK_PERSPECTIVE_MODE" ), 0, this); anAction->setStatusTip(tr("DSC_SVTK_PERSPECTIVE_MODE")); anAction->setCheckable(true); - connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onPerspectiveMode())); + //connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onPerspectiveMode())); mgr->registerAction( anAction, ProjectionModeId ); + anAction = new QtxAction(tr("MNU_SVTK_STEREO_MODE"), + theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_STEREO" ) ), + tr( "MNU_SVTK_STEREO_MODE" ), 0, this); + anAction->setStatusTip(tr("DSC_SVTK_STEREO_MODE")); + anAction->setCheckable(true); + //connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onPerspectiveMode())); + mgr->registerAction( anAction, StereoModeId ); + QActionGroup* aPerspectiveGroup = new QActionGroup( this ); aPerspectiveGroup->addAction( mgr->action( ParallelModeId ) ); aPerspectiveGroup->addAction( mgr->action( ProjectionModeId ) ); + aPerspectiveGroup->addAction( mgr->action( StereoModeId ) ); + connect(aPerspectiveGroup, SIGNAL(triggered(QAction*)), this, SLOT(onPerspectiveMode())); // View Parameters anAction = new QtxAction(tr("MNU_VIEWPARAMETERS_VIEW"), @@ -2298,6 +2448,7 @@ void SVTK_ViewWindow::createToolBar() mgr->append( ParallelModeId, myToolBar ); mgr->append( ProjectionModeId, myToolBar ); + mgr->append( StereoModeId, myToolBar ); mgr->append( StartRecordingId, myRecordingToolBar ); mgr->append( PlayRecordingId, myRecordingToolBar ); diff --git a/src/SVTK/SVTK_ViewWindow.h b/src/SVTK/SVTK_ViewWindow.h index 9d27ced4f..b0de0c81b 100755 --- a/src/SVTK/SVTK_ViewWindow.h +++ b/src/SVTK/SVTK_ViewWindow.h @@ -230,6 +230,12 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow //! Set current projection mode virtual void SetProjectionMode( const int ); + //! Sets stereo type + virtual void SetStereoType( const int ); + + //! Sets anaglyph filter + virtual void SetAnaglyphFilter( const int ); + //! Set interactive style virtual void SetInteractionStyle( const int ); @@ -393,6 +399,13 @@ protected slots: void onMouseReleased(QMouseEvent* event); void onMouseMoving(QMouseEvent* event); +public: + enum ProjectionType { Parallel, Projection, Stereo }; + + enum StereoType { CrystalEyes, RedBlue, Interlaced, Left, Right, Dresden, Anaglyph, Checkerboard, SplitViewPortHorizontal }; + + enum AnaglyphFilter { RedCyan, YellowBlue, GreenMagenta }; + protected: virtual void Initialize(SVTK_View* theView, SVTK_ViewModelBase* theModel); @@ -403,6 +416,8 @@ protected: void* clientdata, void* calldata); + bool isOpenGlStereoSupport() const; + void doSetVisualParameters( const QString&, bool = false ); void SetEventDispatcher(vtkObject* theDispatcher); @@ -420,8 +435,8 @@ protected: enum { DumpId, FitAllId, FitRectId, FitSelectionId, ZoomId, PanId, GlobalPanId, ChangeRotationPointId, RotationId, FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId, ResetId, - ViewTrihedronId, NonIsometric, GraduatedAxes, UpdateRate, - ParallelModeId, ProjectionModeId, ViewParametersId, SynchronizeId, SwitchInteractionStyleId, + ViewTrihedronId, NonIsometric, GraduatedAxes, UpdateRate, + ParallelModeId, ProjectionModeId, StereoModeId, ViewParametersId, SynchronizeId, SwitchInteractionStyleId, SwitchZoomingStyleId, PreselectionId, StandardPreselectionId, DynamicPreselectionId, DisablePreselectionId, EnableSelectionId, diff --git a/src/SVTK/resources/SVTK_images.ts b/src/SVTK/resources/SVTK_images.ts index f446c7718..5aec9190e 100644 --- a/src/SVTK/resources/SVTK_images.ts +++ b/src/SVTK/resources/SVTK_images.ts @@ -31,6 +31,10 @@ ICON_SVTK_VIEW_PERSPECTIVE vtk_view_perspective.png + + ICON_SVTK_VIEW_STEREO + vtk_view_stereo.png + ICON_SVTK_STYLE_SWITCH vtk_view_style_switch.png diff --git a/src/SVTK/resources/SVTK_msg_en.ts b/src/SVTK/resources/SVTK_msg_en.ts index 614c16560..f922e9b14 100644 --- a/src/SVTK/resources/SVTK_msg_en.ts +++ b/src/SVTK/resources/SVTK_msg_en.ts @@ -199,6 +199,14 @@ DSC_SVTK_PERSPECTIVE_MODE Set the perspective projection type + + MNU_SVTK_STEREO_MODE + Stereo Mode + + + DSC_SVTK_STEREO_MODE + Set the stereo projection type + DSC_SVTK_STYLE_SWITCH Interaction style switch @@ -246,7 +254,11 @@ MNU_SVTK_ENABLE_SELECTION Enable/Disable selection - + + + WRN_SUPPORT_QUAD_BUFFER + Graphic driver not support quad-buffer + SVTK_FontWidget @@ -663,5 +675,41 @@ Please, refer to the documentation. BG_IMAGE_FILES Image files (*.png *.jpg *.jpeg *.bmp *.tif *.tiff *.mhd *.mha) + + ST_CRYSTALEYES + Crystal Eyes + + + ST_REDBLUE + Red-Blue + + + ST_INTERLACED + Interlaced + + + ST_LEFT + Left + + + ST_RIGHT + Right + + + ST_DRESDEN + Dresden + + + ST_ANAGLYPH + Anaglyph + + + ST_CHECKERBOARD + Checkerboard + + + ST_SPLITVIEWPORTHORIZONTAL + Split View Port Horizontal + diff --git a/src/SVTK/resources/SVTK_msg_fr.ts b/src/SVTK/resources/SVTK_msg_fr.ts index 5ea0cdea0..efd27894c 100755 --- a/src/SVTK/resources/SVTK_msg_fr.ts +++ b/src/SVTK/resources/SVTK_msg_fr.ts @@ -199,6 +199,14 @@ DSC_SVTK_PERSPECTIVE_MODE Choisir la projection en perspective + + MNU_SVTK_STEREO_MODE + Stereo Mode + + + DSC_SVTK_STEREO_MODE + Set the stereo projection type + DSC_SVTK_STYLE_SWITCH Changer le style d'intéraction @@ -246,7 +254,11 @@ MNU_SVTK_ENABLE_SELECTION Enable/Disable selection - + + + WRN_SUPPORT_QUAD_BUFFER + Graphic driver not support quad-buffer + SVTK_FontWidget @@ -663,5 +675,41 @@ Veuillez consulter la documentation. BG_IMAGE_FILES Fichiers images (*.png *.jpg *.jpeg *.bmp *.tif *.tiff *.mhd *.mha) + + ST_CRYSTALEYES + Crystal Eyes + + + ST_REDBLUE + Red-Blue + + + ST_INTERLACED + Interlaced + + + ST_LEFT + Left + + + ST_RIGHT + Right + + + ST_DRESDEN + Dresden + + + ST_ANAGLYPH + Anaglyph + + + ST_CHECKERBOARD + Checkerboard + + + ST_SPLITVIEWPORTHORIZONTAL + Split View Port Horizontal + diff --git a/src/SVTK/resources/SVTK_msg_ja.ts b/src/SVTK/resources/SVTK_msg_ja.ts index 7472ff435..a9cc240cb 100644 --- a/src/SVTK/resources/SVTK_msg_ja.ts +++ b/src/SVTK/resources/SVTK_msg_ja.ts @@ -199,6 +199,14 @@ DSC_SVTK_PERSPECTIVE_MODE 透視投影を選択します。 + + MNU_SVTK_STEREO_MODE + Stereo Mode + + + DSC_SVTK_STEREO_MODE + Set the stereo projection type + DSC_SVTK_STYLE_SWITCH 相互作用のスタイルを変更します。 @@ -247,6 +255,10 @@ MNU_SVTK_ENABLE_SELECTION 選択を有効/無効にします。 + + WRN_SUPPORT_QUAD_BUFFER + Graphic driver not support quad-buffer + SVTK_FontWidget @@ -662,5 +674,41 @@ BG_IMAGE_FILES ファイル (*.png *.jpg *.jpeg、*.bmp, *.tif, *.tiff *.mhd *.mha) + + ST_CRYSTALEYES + Crystal Eyes + + + ST_REDBLUE + Red-Blue + + + ST_INTERLACED + Interlaced + + + ST_LEFT + Left + + + ST_RIGHT + Right + + + ST_DRESDEN + Dresden + + + ST_ANAGLYPH + Anaglyph + + + ST_CHECKERBOARD + Checkerboard + + + ST_SPLITVIEWPORTHORIZONTAL + Split View Port Horizontal + diff --git a/src/SVTK/resources/vtk_view_stereo.png b/src/SVTK/resources/vtk_view_stereo.png new file mode 100644 index 0000000000000000000000000000000000000000..218a2a64d59898f01bb03307ecb23b955c17d192 GIT binary patch literal 1070 zcmV+}1kwA6P)U|W`z+{iJ;j8rN$;BvWk-4x6)jF@2^*0KI!jFO=s2e$+=lzPJ9Lr|27jM*Ux&T?0J2Xw}EtN`9##kYd zNc3o$cAha-vTZxRy1M%2%F4=1{|Y;U00P(b#A9cJ)$%K{(;>!E z`1IU+?|0V(G}q+h)Uau@pKaTgP1Do?fHC$*BB6WBD?HLymqt&hfqJ!Cky=6l|B-Ox zZ9Z;KTTB19mqz(`(Se-kR?{YHNyKABkH{ca7+G<&rq^at`18wa` zbH6UPR7tMgYioJ&m*^6|v#F__bU)q2`bNf)dgv(_{u%%bTnp1)tWV2w{ikkMIE35h3+I6;BxTq-USlW>JAs~ID8>?{CR*-01O}m0E4(3 zLEz<+hLX>$dTio-)|P}@Yznt1ffvg_ToRa5#5psL$j;`kX=Gt>u*&OOUo6J~q5w!D zu%!%UD1?@$ytE8TGTd=PzJ2;~(JoHE=M3f?~ZZWjfBz11F&QVFmb zVA<<#GmugdzKU{cT2{(m7oa7P2X#0=L