From: imn Date: Mon, 13 Jul 2015 13:04:14 +0000 (+0300) Subject: 0023083: [CEA 1400] Be able to active stereo in OCC view and to choose which kind... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=96d497b9a670f9a0be04ec24a887810eb5ce79b8;p=modules%2Fgui.git 0023083: [CEA 1400] Be able to active stereo in OCC view and to choose which kind of stereo mode --- diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index ab27384ed..4dfb2b7b0 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -116,6 +116,7 @@ #ifndef DISABLE_OCCVIEWER #include #include + #include #ifndef DISABLE_SALOMEOBJECT #include #else @@ -317,6 +318,8 @@ LightApp_Application::LightApp_Application() myAutoSaveTimer->setSingleShot( true ); connect( myAutoSaveTimer, SIGNAL( timeout() ), this, SLOT( onSaveDoc() ) ); + //connect( this, SIGNAL( moving() ), this, SLOT( onMoved() ) ); + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false ); @@ -1535,6 +1538,16 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() )); vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) ); vm->setProjectionType( resMgr->integerValue( "OCCViewer", "projection_mode", vm->projectionType() ) ); + vm->setStereoType( resMgr->integerValue( "OCCViewer", "stereo_mode", vm->stereoType() ) ); + vm->setAnaglyphFilter( resMgr->integerValue( "OCCViewer", "anaglyph_filter", vm->anaglyphFilter() ) ); + vm->setStereographicFocus( resMgr->integerValue( "OCCViewer", "focus_type", vm->stereographicFocusType() ), + resMgr->doubleValue( "OCCViewer", "focus_value", vm->stereographicFocusValue() )); + vm->setInterocularDistance( resMgr->integerValue( "OCCViewer", "iod_type", vm->interocularDistanceType() ), + resMgr->doubleValue( "OCCViewer", "iod_value", vm->interocularDistanceValue() )); + + vm->setReverseStereo( resMgr->booleanValue( "OCCViewer", "reverse_stereo", vm->isReverseStereo() ) ); + vm->setVSync( resMgr->booleanValue( "OCCViewer", "enable_vsync", vm->isVSync() ) ); + vm->setQuadBufferSupport( resMgr->booleanValue( "OCCViewer", "enable_quad_buffer_support", vm->isQuadBufferSupport() ) ); vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) ); vm->enablePreselection( resMgr->booleanValue( "OCCViewer", "enable_preselection", vm->isPreselectionEnabled() ) ); vm->enableSelection( resMgr->booleanValue( "OCCViewer", "enable_selection", vm->isSelectionEnabled() ) ); @@ -1837,6 +1850,22 @@ void LightApp_Application::onRenamed() updateActions(); } +// IMN 08.07.2015 : issue 002556: Some stereo outputs are affected by window position. +// To prevent reversion the window should be either aligned during movement and resize. +/*!Private SLOT. Update actions after rename object.*/ +/*void LightApp_Application::onMoved() +{ + OCCViewer_ViewManager* viewMgr = 0; + viewMgr = dynamic_cast( getViewManager( OCCViewer_Viewer::Type(), false ) ); + if (viewMgr) { + OCCViewer_ViewWindow* view = 0; + view = dynamic_cast( viewMgr->getActiveView() ); + if (view) { + view->getViewPort()->repaintViewAfterMove(); + } + } +} +*/ /*!Private SLOT. Support drag-and-drop operation.*/ void LightApp_Application::onDropped( const QList& objects, SUIT_DataObject* parent, int row, Qt::DropAction action ) { @@ -2258,6 +2287,15 @@ 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 <> @@ -2301,7 +2339,7 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) // .. "OCC viewer" group <> int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), salomeCat ); - // .... -> projection mode + // .... -> Projection mode int occProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), occGroup, LightApp_Preferences::Selector, "OCCViewer", "projection_mode" ); aValuesList.clear(); @@ -2310,6 +2348,77 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) anIndicesList << 0 << 1; pref->setItemProperty( "strings", aValuesList, occProjMode ); pref->setItemProperty( "indexes", anIndicesList, occProjMode ); + + // .... -> Stereo group + int stereoGroup = pref->addPreference( tr( "PREF_GROUP_STEREO" ), occGroup); + pref->setItemProperty( "columns", 2, stereoGroup ); + // .... -> Stereo type + int stereoType = pref->addPreference( tr( "PREF_STEREO_TYPE" ), stereoGroup, + LightApp_Preferences::Selector, "OCCViewer", "stereo_type" ); + aValuesList.clear(); + anIndicesList.clear(); + OCCViewer_Viewer::stereoData( aValuesList, idList); + foreach( int gid, idList ) anIndicesList << gid; + pref->setItemProperty( "strings", aValuesList, stereoType ); + pref->setItemProperty( "indexes", anIndicesList, stereoType ); + + // .... -> Anaglyph filter + int anaglyphFilter = pref->addPreference( tr( "PREF_ANAGLYPH_FILTER" ), stereoGroup, + LightApp_Preferences::Selector, "OCCViewer", "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, anaglyphFilter ); + pref->setItemProperty( "indexes", anIndicesList, anaglyphFilter ); + + // .... -> Convergence distance type + int occFocusType = pref->addPreference( tr( "PREF_FOCUS_TYPE" ), stereoGroup, + LightApp_Preferences::Selector, "OCCViewer", "focus_type" ); + aValuesList.clear(); + anIndicesList.clear(); + aValuesList << tr("PREF_ABSOLUTE") << tr("PREF_RELATIVE"); + anIndicesList << 0 << 1; + pref->setItemProperty( "strings", aValuesList, occFocusType ); + pref->setItemProperty( "indexes", anIndicesList, occFocusType ); + + // .... -> Stereographic focus value + int focusValue = pref->addPreference( tr( "PREF_FOCUS_VALUE" ), stereoGroup, + LightApp_Preferences::DblSpin, "OCCViewer", "focus_value" ); + pref->setItemProperty( "precision", 3, focusValue ); + pref->setItemProperty( "min", 1.0E-03, focusValue ); + pref->setItemProperty( "max", 1.0E03, focusValue ); + pref->setItemProperty( "step", 0.05, focusValue ); + + // .... -> IOD type + int occIODType = pref->addPreference( tr( "PREF_IOD_TYPE" ), stereoGroup, + LightApp_Preferences::Selector, "OCCViewer", "iod_type" ); + aValuesList.clear(); + anIndicesList.clear(); + aValuesList << tr("PREF_ABSOLUTE") << tr("PREF_RELATIVE"); + anIndicesList << 0 << 1; + pref->setItemProperty( "strings", aValuesList, occIODType ); + pref->setItemProperty( "indexes", anIndicesList, occIODType ); + + // .... -> Interocular distance (IOD) value + int IODValue = pref->addPreference( tr( "PREF_IOD_VALUE" ), stereoGroup, + LightApp_Preferences::DblSpin, "OCCViewer", "iod_value" ); + pref->setItemProperty( "precision", 3, IODValue ); + pref->setItemProperty( "min", 1.0E-03, IODValue ); + pref->setItemProperty( "max", 1.0E03, IODValue ); + pref->setItemProperty( "step", 0.05, IODValue ); + + // .... -> Reverse stereo + pref->addPreference( tr( "PREF_REVERSE_STEREO" ), stereoGroup, + LightApp_Preferences::Bool, "OCCViewer", "reverse_stereo" ); + // .... -> Enable V-Sync + pref->addPreference( tr( "PREF_ENABLE_VSYNC" ), stereoGroup, + LightApp_Preferences::Bool, "OCCViewer", "enable_vsync" ); + // .... -> Enable quad-buffer support + pref->addPreference( tr( "PREF_ENABLE_QUAD_BUFFER_SUPPORT" ), stereoGroup, + LightApp_Preferences::Bool, "OCCViewer", "enable_quad_buffer_support" ); + // ... "Background" group <> int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup ); // pref->setItemProperty( "columns", 2, bgGroup ); @@ -2407,6 +2516,7 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) pref->setItemProperty( "margin", 0, occGen ); pref->setItemProperty( "columns", 2, occGen ); // ... -> empty frame (for layout) <> + // .. "OCC viewer" group <> #endif @@ -2983,6 +3093,143 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString } #endif +#ifndef DISABLE_OCCVIEWER + if ( sec == QString( "OCCViewer" ) && param == QString( "stereo_type" ) ) + { + int mode = resMgr->integerValue( "OCCViewer", "stereo_type", 0 ); + QList lst; + viewManagers( OCCViewer_Viewer::Type(), lst ); + QListIterator it( lst ); + while ( it.hasNext() ) + { + SUIT_ViewModel* vm = it.next()->getViewModel(); + if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) ) + continue; + + OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm; + occVM->setStereoType( mode ); + } + } +#endif + +#ifndef DISABLE_OCCVIEWER + if ( sec == QString( "OCCViewer" ) && param == QString( "anaglyph_filter" ) ) + { + int mode = resMgr->integerValue( "OCCViewer", "anaglyph_filter", 0 ); + QList lst; + viewManagers( OCCViewer_Viewer::Type(), lst ); + QListIterator it( lst ); + while ( it.hasNext() ) + { + SUIT_ViewModel* vm = it.next()->getViewModel(); + if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) ) + continue; + + OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm; + occVM->setAnaglyphFilter( mode ); + } + } +#endif + +#ifndef DISABLE_OCCVIEWER + if ( sec == QString( "OCCViewer" ) && ( param == QString( "focus_type" ) || + param == QString( "focus_value" ) ) ) + { + int aType = resMgr->integerValue( "OCCViewer", "focus_type" ); + double aValue = resMgr->doubleValue( "OCCViewer", "focus_value" ); + QList lst; + viewManagers( OCCViewer_Viewer::Type(), lst ); + QListIterator it( lst ); + while ( it.hasNext() ) + { + SUIT_ViewModel* vm = it.next()->getViewModel(); + if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) ) + continue; + + OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm; + occVM->setStereographicFocus( aType, aValue ); + } + } +#endif + +#ifndef DISABLE_OCCVIEWER + if ( sec == QString( "OCCViewer" ) && ( param == QString( "iod_type" ) || + param == QString( "iod_value" ) ) ) + { + int aType = resMgr->integerValue( "OCCViewer", "iod_type" ); + double aValue = resMgr->doubleValue( "OCCViewer", "iod_value" ); + QList lst; + viewManagers( OCCViewer_Viewer::Type(), lst ); + QListIterator it( lst ); + while ( it.hasNext() ) + { + SUIT_ViewModel* vm = it.next()->getViewModel(); + if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) ) + continue; + + OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm; + occVM->setInterocularDistance( aType, aValue ); + } + } +#endif + +#ifndef DISABLE_OCCVIEWER + if ( sec == QString( "OCCViewer" ) && param == QString( "reverse_stereo" ) ) + { + bool reverse = resMgr->booleanValue( "OCCViewer", "reverse_stereo", false ); + QList lst; + viewManagers( OCCViewer_Viewer::Type(), lst ); + QListIterator it( lst ); + while ( it.hasNext() ) + { + SUIT_ViewModel* vm = it.next()->getViewModel(); + if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) ) + continue; + + OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm; + occVM->setReverseStereo( reverse ); + } + } +#endif + +#ifndef DISABLE_OCCVIEWER + if ( sec == QString( "OCCViewer" ) && param == QString( "enable_vsync" ) ) + { + bool enable = resMgr->booleanValue( "OCCViewer", "enable_vsync", true ); + QList lst; + viewManagers( OCCViewer_Viewer::Type(), lst ); + QListIterator it( lst ); + while ( it.hasNext() ) + { + SUIT_ViewModel* vm = it.next()->getViewModel(); + if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) ) + continue; + + OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm; + occVM->setVSync( enable ); + } + } +#endif + +#ifndef DISABLE_OCCVIEWER + if ( sec == QString( "OCCViewer" ) && param == QString( "enable_quad_buffer_support" ) ) + { + bool enable = resMgr->booleanValue( "OCCViewer", "enable_quad_buffer_support", false ); + QList lst; + viewManagers( OCCViewer_Viewer::Type(), lst ); + QListIterator it( lst ); + while ( it.hasNext() ) + { + SUIT_ViewModel* vm = it.next()->getViewModel(); + if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) ) + continue; + + OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm; + occVM->setQuadBufferSupport( enable ); + } + } +#endif + if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) ) { int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 ); @@ -3848,6 +4095,8 @@ void LightApp_Application::setDesktop( SUIT_Desktop* desk ) this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection ); connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ), this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection ); + /* connect( desk, SIGNAL( windowMoved( SUIT_ViewWindow* ) ), + this, SLOT( onWindowMoved( SUIT_ViewWindow* ) ), Qt::UniqueConnection ); */ } } diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index 24d59fbcb..3d7080d6b 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -276,6 +276,7 @@ private slots: void onCloseAllWindow(); void onGroupAllWindow(); void onRenamed(); + //void onMoved(); protected: void updateWindows(); 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..694487ec3 100644 --- a/src/LightApp/resources/LightApp.xml +++ b/src/LightApp/resources/LightApp.xml @@ -144,6 +144,16 @@
+ + + + + + + + + + @@ -159,6 +169,10 @@ + + + + diff --git a/src/LightApp/resources/LightApp_msg_en.ts b/src/LightApp/resources/LightApp_msg_en.ts index e146f8654..987657246 100644 --- a/src/LightApp/resources/LightApp_msg_en.ts +++ b/src/LightApp/resources/LightApp_msg_en.ts @@ -627,6 +627,66 @@ 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_FOCUS_TYPE + Convergence distance type + + + PREF_FOCUS_VALUE + Stereographic focus value + + + PREF_IOD_TYPE + IOD type + + + PREF_IOD_VALUE + Interocular distance (IOD) value + + + PREF_ABSOLUTE + Absolute + + + PREF_RELATIVE + Relative + + + PREF_REVERSE_STEREO + Reverse stereo + + + PREF_ENABLE_VSYNC + Enable V-Sync + + + PREF_ENABLE_QUAD_BUFFER_SUPPORT + Enable quad-buffer support + PREF_LOGARITHMIC Logarithmic @@ -888,6 +948,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..9d293f254 100755 --- a/src/LightApp/resources/LightApp_msg_fr.ts +++ b/src/LightApp/resources/LightApp_msg_fr.ts @@ -627,6 +627,66 @@ 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_FOCUS_TYPE + type="unfinished"Convergence distance type + + + PREF_FOCUS_VALUE + Stereographic focus value + + + PREF_IOD_TYPE + IOD type + + + PREF_IOD_VALUE + Interocular distance (IOD) value + + + PREF_ABSOLUTE + Absolute + + + PREF_RELATIVE + Relative + + + PREF_REVERSE_STEREO + Reverse stereo + + + PREF_ENABLE_VSYNC + Enable V-Sync + + + PREF_ENABLE_QUAD_BUFFER_SUPPORT + Enable quad-buffer support + PREF_LOGARITHMIC Logarithmique @@ -888,6 +948,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..954a371ce 100644 --- a/src/LightApp/resources/LightApp_msg_ja.ts +++ b/src/LightApp/resources/LightApp_msg_ja.ts @@ -627,6 +627,66 @@ 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_FOCUS_TYPE + type="unfinished"Convergence distance type + + + PREF_FOCUS_VALUE + Stereographic focus value + + + PREF_IOD_TYPE + IOD type + + + PREF_IOD_VALUE + Interocular distance (IOD) value + + + PREF_ABSOLUTE + Absolute + + + PREF_RELATIVE + Relative + + + PREF_REVERSE_STEREO + Reverse stereo + + + PREF_ENABLE_VSYNC + Enable V-Sync + + + PREF_ENABLE_QUAD_BUFFER_SUPPORT + Enable quad-buffer support + PREF_LOGARITHMIC 対数 @@ -887,6 +947,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/OCCViewer/CMakeLists.txt b/src/OCCViewer/CMakeLists.txt index a69ace133..01e7473bb 100755 --- a/src/OCCViewer/CMakeLists.txt +++ b/src/OCCViewer/CMakeLists.txt @@ -135,6 +135,7 @@ SET(_other_RESOURCES resources/occ_view_scaling.png resources/occ_view_selection.png resources/occ_view_shoot.png + resources/occ_view_stereo.png resources/occ_view_style_switch.png resources/occ_view_top.png resources/occ_view_triedre.png diff --git a/src/OCCViewer/OCCViewer_ViewFrame.cxx b/src/OCCViewer/OCCViewer_ViewFrame.cxx index 9ebb0cdf2..5907af309 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.cxx +++ b/src/OCCViewer/OCCViewer_ViewFrame.cxx @@ -328,6 +328,116 @@ void OCCViewer_ViewFrame::setProjectionType( int t) } } +//************************************************************************************** +int OCCViewer_ViewFrame::stereoType() const +{ + return getView(MAIN_VIEW)->stereoType(); +} + +//************************************************************************************** +void OCCViewer_ViewFrame::setStereoType( int t) +{ + foreach (OCCViewer_ViewWindow* aView, myViews) { + aView->setStereoType(t); + } +} + +//************************************************************************************** +int OCCViewer_ViewFrame::anaglyphFilter() const +{ + return getView(MAIN_VIEW)->anaglyphFilter(); +} + +//************************************************************************************** +void OCCViewer_ViewFrame::setAnaglyphFilter( int t) +{ + foreach (OCCViewer_ViewWindow* aView, myViews) { + aView->setAnaglyphFilter(t); + } +} + +//************************************************************************************** +int OCCViewer_ViewFrame::stereographicFocusType() const +{ + return getView(MAIN_VIEW)->stereographicFocusType(); +} + +//************************************************************************************** +double OCCViewer_ViewFrame::stereographicFocusValue() const +{ + return getView(MAIN_VIEW)->stereographicFocusValue(); +} + +//************************************************************************************** +void OCCViewer_ViewFrame::setStereographicFocus( int t, double v) +{ + foreach (OCCViewer_ViewWindow* aView, myViews) { + aView->setStereographicFocus(t, v); + } +} + +//************************************************************************************** +int OCCViewer_ViewFrame::interocularDistanceType() const +{ + return getView(MAIN_VIEW)->interocularDistanceType(); +} + +//************************************************************************************** +double OCCViewer_ViewFrame::interocularDistanceValue() const +{ + return getView(MAIN_VIEW)->interocularDistanceValue(); +} + +//************************************************************************************** +void OCCViewer_ViewFrame::setInterocularDistance( int t, double v) +{ + foreach (OCCViewer_ViewWindow* aView, myViews) { + aView->setInterocularDistance(t, v); + } +} + +//************************************************************************************** +bool OCCViewer_ViewFrame::isReverseStereo() const +{ + return getView(MAIN_VIEW)->isReverseStereo(); +} + +//************************************************************************************** +void OCCViewer_ViewFrame::setReverseStereo( bool t) +{ + foreach (OCCViewer_ViewWindow* aView, myViews) { + aView->setReverseStereo(t); + } +} + +//************************************************************************************** +bool OCCViewer_ViewFrame::isVSync() const +{ + return getView(MAIN_VIEW)->isVSync(); +} + +//************************************************************************************** +void OCCViewer_ViewFrame::setVSync( bool t) +{ + foreach (OCCViewer_ViewWindow* aView, myViews) { + aView->setVSync(t); + } +} + +//************************************************************************************** +bool OCCViewer_ViewFrame::isQuadBufferSupport() const +{ + return getView(MAIN_VIEW)->isQuadBufferSupport(); +} + +//************************************************************************************** +void OCCViewer_ViewFrame::setQuadBufferSupport( bool t) +{ + foreach (OCCViewer_ViewWindow* aView, myViews) { + aView->setQuadBufferSupport(t); + } +} + //************************************************************************************** void OCCViewer_ViewFrame::setZoomingStyle( const int i ) { diff --git a/src/OCCViewer/OCCViewer_ViewFrame.h b/src/OCCViewer/OCCViewer_ViewFrame.h index a8ef4b2ac..1e56502da 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.h +++ b/src/OCCViewer/OCCViewer_ViewFrame.h @@ -73,6 +73,29 @@ public: virtual int projectionType() const; virtual void setProjectionType( int ); + virtual int stereoType() const; + virtual void setStereoType( const int ); + + virtual int anaglyphFilter() const; + virtual void setAnaglyphFilter( const int ); + + virtual void setStereographicFocus( const int, const double ); + virtual int stereographicFocusType() const; + virtual double stereographicFocusValue() const; + + virtual void setInterocularDistance( const int, const double ); + virtual int interocularDistanceType() const; + virtual double interocularDistanceValue() const; + + virtual bool isReverseStereo() const; + virtual void setReverseStereo( const bool ); + + virtual bool isVSync() const; + virtual void setVSync( const bool ); + + virtual bool isQuadBufferSupport() const; + virtual void setQuadBufferSupport( const bool ); + virtual int zoomingStyle() const { return getView(MAIN_VIEW)->zoomingStyle(); } virtual void setZoomingStyle( const int ); diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index d8feb5d21..10cd6c850 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -90,6 +90,21 @@ QString OCCViewer_Viewer::backgroundData( QStringList& gradList, QIntList& idLis return tr("BG_IMAGE_FILES"); } +/*! + Get data for supported stereo pair modes: stereo types and identifiers +*/ +void OCCViewer_Viewer::stereoData( QStringList& typeList, QIntList& idList) +{ + typeList << tr("ST_QUADBUFFER") << tr("ST_ANAGLYPH") << + tr("ST_ROWINTERLACED") << tr("ST_COLUMNINTERLACED") << + tr("ST_CHESSBOARD") << tr("ST_SIDEBYSIDE") << + tr("ST_OVERUNDER"); + idList << QuadBufferType << AnaglyphType << + RowInterlacedType << ColumnInterlacedType << + ChessBoardType << SideBySideType << + OverUnderType; +} + /*! Constructor \param DisplayTrihedron - is trihedron displayed @@ -155,6 +170,17 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron) // set projection type to orthographic myProjectionType = 0; + // set stereo parameters + myStereoType = 0; + myAnaglyphFilter = 0; + myToReverseStereo = 0; + myVSyncMode = 1; + myQuadBufferSupport = 0; + myStereographicFocusType = 1; + myInterocularDistanceType = 1; + myStereographicFocusValue = 1.0; + myInterocularDistanceValue = 0.05; + //set clipping color and texture to standard myClippingColor = QColor( 50, 50, 50 ); myDefaultTextureUsed = true; @@ -219,10 +245,17 @@ void OCCViewer_Viewer::initView( OCCViewer_ViewWindow* view ) view->initSketchers(); view->setInteractionStyle( interactionStyle() ); view->setProjectionType( projectionType() ); + view->setStereoType( stereoType() ); + view->setAnaglyphFilter( anaglyphFilter() ); + view->setStereographicFocus( stereographicFocusType(), stereographicFocusValue() ); + view->setInterocularDistance( interocularDistanceType(), interocularDistanceValue() ); + view->setReverseStereo( isReverseStereo() ); + view->setVSync( isVSync() ); + view->setQuadBufferSupport( isQuadBufferSupport() ); view->setZoomingStyle( zoomingStyle() ); view->enablePreselection( isPreselectionEnabled() ); view->enableSelection( isSelectionEnabled() ); - + OCCViewer_ViewPort3d* vp3d = view->getViewPort(); if ( vp3d ) { @@ -507,6 +540,222 @@ void OCCViewer_Viewer::setProjectionType( const int theType ) } } +/*! + \return stereo type +*/ +int OCCViewer_Viewer::stereoType() const +{ + return myStereoType; +} + +/*! + Sets stereo type + \param theType - new stereo type +*/ +void OCCViewer_Viewer::setStereoType( const int theType ) +{ + myStereoType = theType; + + if ( !myViewManager ) + return; + + QVector wins = myViewManager->getViews(); + for ( int i = 0; i < (int)wins.count(); i++ ) + { + OCCViewer_ViewWindow* win = ::qobject_cast( wins.at( i ) ); + if ( win ) + win->setStereoType( (OCCViewer_ViewWindow::StereoType)theType ); + } +} + +/*! + \return stereographic focus type +*/ +int OCCViewer_Viewer::stereographicFocusType() const +{ + return myStereographicFocusType; +} + +/*! + \return stereographic focus value +*/ +double OCCViewer_Viewer::stereographicFocusValue() const +{ + return myStereographicFocusValue; +} + +/*! + Sets stereographic focus parameters + \param theType - new stereographic focus type + \param theValue - new stereographic focus value +*/ +void OCCViewer_Viewer::setStereographicFocus( const int theType, const double theValue ) +{ + myStereographicFocusType = theType; + myStereographicFocusValue = theValue; + + if ( !myViewManager ) + return; + + QVector wins = myViewManager->getViews(); + for ( int i = 0; i < (int)wins.count(); i++ ) + { + OCCViewer_ViewWindow* win = ::qobject_cast( wins.at( i ) ); + if ( win ) + win->setStereographicFocus( (OCCViewer_ViewWindow::FocusIODType)theType, theValue ); + } +} + +/*! + \return stereographic focus type +*/ +int OCCViewer_Viewer::interocularDistanceType() const +{ + return myInterocularDistanceType; +} + +/*! + \return stereographic focus value +*/ +double OCCViewer_Viewer::interocularDistanceValue() const +{ + return myInterocularDistanceValue; +} + +/*! + Sets interocular distance parameters + \param theType - new IOD type + \param theValue - new IOD value +*/ +void OCCViewer_Viewer::setInterocularDistance( const int theType, const double theValue ) +{ + myInterocularDistanceType = theType; + myInterocularDistanceValue = theValue; + + if ( !myViewManager ) + return; + + QVector wins = myViewManager->getViews(); + for ( int i = 0; i < (int)wins.count(); i++ ) + { + OCCViewer_ViewWindow* win = ::qobject_cast( wins.at( i ) ); + if ( win ) + win->setInterocularDistance( (OCCViewer_ViewWindow::FocusIODType)theType, theValue ); + } +} + +/*! + \return anaglyph filter +*/ +int OCCViewer_Viewer::anaglyphFilter() const +{ + return myAnaglyphFilter; +} + +/*! + Sets anaglyph filter + \param theType - new anaglyph filter +*/ +void OCCViewer_Viewer::setAnaglyphFilter( const int theType ) +{ + myAnaglyphFilter = theType; + + if ( !myViewManager ) + return; + + QVector wins = myViewManager->getViews(); + for ( int i = 0; i < (int)wins.count(); i++ ) + { + OCCViewer_ViewWindow* win = ::qobject_cast( wins.at( i ) ); + if ( win ) + win->setAnaglyphFilter( (OCCViewer_ViewWindow::AnaglyphFilter)theType ); + } +} + +/*! + \return reverse stereo +*/ +bool OCCViewer_Viewer::isReverseStereo() const +{ + return myToReverseStereo; +} + +/*! + Sets reverse stereo + \param theReverse - enable/disable reverse mode +*/ +void OCCViewer_Viewer::setReverseStereo( const bool theReverse ) +{ + myToReverseStereo = theReverse; + + if ( !myViewManager ) + return; + + QVector wins = myViewManager->getViews(); + for ( int i = 0; i < (int)wins.count(); i++ ) + { + OCCViewer_ViewWindow* win = ::qobject_cast( wins.at( i ) ); + if ( win ) + win->setReverseStereo( theReverse ); + } +} + +/*! + \return V-Sync mode +*/ +bool OCCViewer_Viewer::isVSync() const +{ + return myVSyncMode; +} + +/*! + Set V-Sync mode + \param theEnable - enable/disable V-Sync mode +*/ +void OCCViewer_Viewer::setVSync( const bool theEnable ) +{ + myVSyncMode = theEnable; + + if ( !myViewManager ) + return; + + QVector wins = myViewManager->getViews(); + for ( int i = 0; i < (int)wins.count(); i++ ) + { + OCCViewer_ViewWindow* win = ::qobject_cast( wins.at( i ) ); + if ( win ) + win->setVSync( theEnable ); + } +} + +/*! + \return support quad-buffered stereo +*/ +bool OCCViewer_Viewer::isQuadBufferSupport() const +{ + return myQuadBufferSupport; +} + +/*! + Set support quad-buffered stereo + \param theEnable - enable/disable support quad-buffered stereo +*/ +void OCCViewer_Viewer::setQuadBufferSupport( const bool theEnable ) +{ + myQuadBufferSupport = theEnable; + + if ( !myViewManager ) + return; + + QVector wins = myViewManager->getViews(); + for ( int i = 0; i < (int)wins.count(); i++ ) + { + OCCViewer_ViewWindow* win = ::qobject_cast( wins.at( i ) ); + if ( win ) + win->setQuadBufferSupport( theEnable ); + } +} + /*! \return zooming style */ diff --git a/src/OCCViewer/OCCViewer_ViewModel.h b/src/OCCViewer/OCCViewer_ViewModel.h index 6bd1e1271..04fd3d53e 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.h +++ b/src/OCCViewer/OCCViewer_ViewModel.h @@ -69,9 +69,17 @@ public: Corner3Gradient, Corner4Gradient, LastGradient = Corner4Gradient }; + /*! supported stereo types */ + enum { + QuadBufferType, AnaglyphType, + RowInterlacedType, ColumnInterlacedType, + ChessBoardType, SideBySideType, + OverUnderType + }; static QString Type() { return "OCCViewer"; } static QString backgroundData( QStringList&, QIntList&, QIntList& ); + static void stereoData( QStringList&, QIntList&); OCCViewer_Viewer( bool DisplayTrihedron = true); virtual ~OCCViewer_Viewer(); @@ -136,6 +144,29 @@ public: int projectionType() const; void setProjectionType( const int ); + int stereoType() const; + void setStereoType( const int ); + + int anaglyphFilter() const; + void setAnaglyphFilter( const int ); + + void setStereographicFocus( const int, const double ); + int stereographicFocusType() const; + double stereographicFocusValue() const; + + void setInterocularDistance( const int, const double ); + int interocularDistanceType() const; + double interocularDistanceValue() const; + + bool isReverseStereo() const; + void setReverseStereo( const bool ); + + bool isVSync() const; + void setVSync( const bool ); + + bool isQuadBufferSupport() const; + void setQuadBufferSupport( const bool ); + int zoomingStyle() const; void setZoomingStyle( const int ); @@ -212,11 +243,21 @@ protected: int myInteractionStyle; int myZoomingStyle; int myProjectionType; + int myStereoType; + int myAnaglyphFilter; + int myStereographicFocusType; + int myInterocularDistanceType; + + double myStereographicFocusValue; + double myInterocularDistanceValue; bool myPreselectionEnabled; bool mySelectionEnabled; bool myMultiSelectionEnabled; bool myIsRelative; + bool myToReverseStereo; + bool myVSyncMode; + bool myQuadBufferSupport; int myTopLayerId; diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.cxx b/src/OCCViewer/OCCViewer_ViewPort3d.cxx index 7fa8797e2..cc6d7bf5a 100755 --- a/src/OCCViewer/OCCViewer_ViewPort3d.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort3d.cxx @@ -614,6 +614,17 @@ void OCCViewer_ViewPort3d::resizeEvent( QResizeEvent* e ) activeView()->MustBeResized(); } +/*! + Moved the viewport +*/ +/* +void OCCViewer_ViewPort3d::repaintViewAfterMove( ) +{ + if ( !activeView().IsNull() ){ + activeView()->MustBeResized(); + } +} +*/ /*! Fits all objects in view. [ virtual protected ] */ diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.h b/src/OCCViewer/OCCViewer_ViewPort3d.h index 5ac793fb3..7f8841a25 100755 --- a/src/OCCViewer/OCCViewer_ViewPort3d.h +++ b/src/OCCViewer/OCCViewer_ViewPort3d.h @@ -94,6 +94,8 @@ public: void showStaticTrihedron( bool ); + //void repaintViewAfterMove( ); + void setDefaultCursor( Qt::CursorShape theCursorShape ); QCursor* getDefaultCursor() const; diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 0599c7534..d4ff42f37 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -35,8 +35,6 @@ #include "OCCViewer_CubeAxesDlg.h" #include "OCCViewer_ClippingDlg.h" -#include - #include #include #include @@ -49,7 +47,7 @@ #include #include -#include +#include #include #include @@ -70,10 +68,18 @@ #include #include +#include +#include +#include +#include + #include #include #include #include +#include +#include + #include #include @@ -84,9 +90,6 @@ #include #include -#include -#include - #include #include @@ -105,6 +108,12 @@ static QEvent* l_mbPressEvent = 0; #include +// To avoid conflict between KeyPress from the X.h (define KeyPress 2) +// and QEvent::KeyPress (qevent.h) +#ifdef KeyPress +#undef KeyPress +#endif + const char* imageZoomCursor[] = { "32 32 3 1", ". c None", @@ -252,7 +261,6 @@ OCCViewer_ViewWindow::OCCViewer_ViewWindow( SUIT_Desktop* theDesktop, myCursorIsHand = false; clearViewAspects(); - } /*! @@ -1293,10 +1301,19 @@ void OCCViewer_ViewWindow::createActions() //connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onProjectionType())); toolMgr()->registerAction( aAction, PerspectiveId ); + // - stereo projection + aAction = new QtxAction(tr("MNU_STEREO_MODE"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_STEREO" ) ), + tr( "MNU_STEREO_MODE" ), 0, this); + aAction->setStatusTip(tr("DSC_STEREO_MODE")); + aAction->setCheckable(true); + toolMgr()->registerAction( aAction, StereoId ); + //connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onProjectionType())); + // - add exclusive action group QActionGroup* aProjectionGroup = new QActionGroup( this ); aProjectionGroup->addAction( toolMgr()->action( OrthographicId ) ); aProjectionGroup->addAction( toolMgr()->action( PerspectiveId ) ); + aProjectionGroup->addAction( toolMgr()->action( StereoId ) ); connect(aProjectionGroup, SIGNAL(triggered(QAction*)), this, SLOT(onProjectionType())); // Reset @@ -1481,6 +1498,7 @@ void OCCViewer_ViewWindow::createToolBar() toolMgr()->append( OrthographicId, tid ); toolMgr()->append( PerspectiveId, tid ); + toolMgr()->append( StereoId, tid ); toolMgr()->append( ResetId, tid ); } @@ -1628,7 +1646,13 @@ void OCCViewer_ViewWindow::onResetView() void OCCViewer_ViewWindow::onProjectionType() { emit vpTransformationStarted( PROJECTION ); - setProjectionType( toolMgr()->action( OrthographicId )->isChecked() ? Orthographic : Perspective ); + if (toolMgr()->action( OrthographicId )->isChecked()) + setProjectionType( Orthographic); + if (toolMgr()->action( PerspectiveId )->isChecked()) + setProjectionType( Perspective); + if (toolMgr()->action( StereoId )->isChecked()) { + setProjectionType( Stereo); + } emit vpTransformationFinished( PROJECTION ); } @@ -2793,13 +2817,57 @@ void OCCViewer_ViewWindow::setProjectionType( int mode ) Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) { Handle(Graphic3d_Camera) aCamera = aView3d->Camera(); - aCamera->SetProjectionType( mode == Perspective ? Graphic3d_Camera::Projection_Perspective : Graphic3d_Camera::Projection_Orthographic ); + if (mode == Perspective) + aCamera->SetProjectionType ( Graphic3d_Camera::Projection_Perspective ); + if (mode == Orthographic) + aCamera->SetProjectionType ( Graphic3d_Camera::Projection_Orthographic ); + if (mode == Stereo) { + aCamera->SetProjectionType ( Graphic3d_Camera::Projection_Stereo ); + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + setStereoType( aResMgr->integerValue( "OCCViewer", "stereo_type", 0 ) ); + setAnaglyphFilter( aResMgr->integerValue( "OCCViewer", "anaglyph_filter", 0 ) ); + setReverseStereo( aResMgr->booleanValue( "OCCViewer", "reverse_stereo", false ) ); + setVSync( aResMgr->booleanValue( "OCCViewer", "enable_vsync", true ) ); + setQuadBufferSupport( aResMgr->booleanValue( "OCCViewer", "enable_quad_buffer_support", true ) ); + } + aView3d->Redraw(); onViewFitAll(); } // update action state if method is called outside - QtxAction* a = dynamic_cast( toolMgr()->action( mode == Orthographic ? OrthographicId : PerspectiveId ) ); - if ( ! a->isChecked() ) - a->setChecked( true ); + QtxAction* anOrthographicAction = dynamic_cast( toolMgr()->action( OrthographicId ) ); + QtxAction* aPerspectiveAction = dynamic_cast( toolMgr()->action( PerspectiveId ) ); + QtxAction* aStereoAction = dynamic_cast( toolMgr()->action( StereoId ) ); + if ( mode == Orthographic && !anOrthographicAction->isChecked() ) { + anOrthographicAction->setChecked( true ); + } + if ( mode == Perspective && !aPerspectiveAction->isChecked() ) { + aPerspectiveAction->setChecked( true ); + } + if ( mode == Stereo ) { + if ( anOrthographicAction->isEnabled() ) + anOrthographicAction->setDisabled( true ); + else + anOrthographicAction->setEnabled( true ); + if ( aPerspectiveAction->isEnabled() ) { + aPerspectiveAction->setChecked( true ); + aPerspectiveAction->setDisabled( true ); + if ( isQuadBufferSupport() ) { + if ( !isOpenGlStereoSupport() && stereoType() == QuadBuffer ) + SUIT_MessageBox::warning( 0, tr( "WRN_WARNING" ), tr( "WRN_SUPPORT_QUAD_BUFFER" ) ); + } + } + else { + aPerspectiveAction->setChecked( true ); + aPerspectiveAction->setEnabled( true ); + onProjectionType(); + } + } + else { + if ( !anOrthographicAction->isEnabled() ) + anOrthographicAction->setEnabled( true ); + if ( !aPerspectiveAction->isEnabled() ) + aPerspectiveAction->setEnabled( true ); + } } int OCCViewer_ViewWindow::projectionType() const @@ -2808,11 +2876,201 @@ int OCCViewer_ViewWindow::projectionType() const Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) { Handle(Graphic3d_Camera) aCamera = aView3d->Camera(); - mode = aCamera->ProjectionType() == Graphic3d_Camera::Projection_Perspective ? Perspective : Orthographic; + if (aCamera->ProjectionType() == Graphic3d_Camera::Projection_Perspective) + mode = Perspective; + if (aCamera->ProjectionType() == Graphic3d_Camera::Projection_Orthographic) + mode = Orthographic; + if (aCamera->ProjectionType() == Graphic3d_Camera::Projection_Stereo) + mode = Stereo; } return mode; } +void OCCViewer_ViewWindow::setStereoType( int type ) +{ + Handle(V3d_View) aView3d = myViewPort->getView(); + if ( !aView3d.IsNull() ) { + Graphic3d_RenderingParams* aParams = &aView3d->ChangeRenderingParams(); + aParams->StereoMode = (Graphic3d_StereoMode)type; + } +} + +int OCCViewer_ViewWindow::stereoType() const +{ + int type = QuadBuffer; + Handle(V3d_View) aView3d = myViewPort->getView(); + if ( !aView3d.IsNull() ) { + Graphic3d_RenderingParams* aParams = &aView3d->ChangeRenderingParams(); + type = (OCCViewer_ViewWindow::StereoType)aParams->StereoMode; + } + return type; +} + +void OCCViewer_ViewWindow::setAnaglyphFilter( int type ) +{ + Handle(V3d_View) aView3d = myViewPort->getView(); + if ( !aView3d.IsNull() ) { + Graphic3d_RenderingParams* aParams = &aView3d->ChangeRenderingParams(); + if (type == RedCyan) + aParams->AnaglyphFilter = Graphic3d_RenderingParams::Anaglyph_RedCyan_Optimized; + if (type == YellowBlue) + aParams->AnaglyphFilter = Graphic3d_RenderingParams::Anaglyph_YellowBlue_Optimized; + if (type == GreenMagenta) + aParams->AnaglyphFilter = Graphic3d_RenderingParams::Anaglyph_GreenMagenta_Simple; + } +} + +int OCCViewer_ViewWindow::anaglyphFilter() const +{ + int type = RedCyan; + Handle(V3d_View) aView3d = myViewPort->getView(); + if ( !aView3d.IsNull() ) { + Graphic3d_RenderingParams* aParams = &aView3d->ChangeRenderingParams(); + if (aParams->AnaglyphFilter == Graphic3d_RenderingParams::Anaglyph_RedCyan_Optimized) + type = RedCyan; + if (aParams->AnaglyphFilter == Graphic3d_RenderingParams::Anaglyph_YellowBlue_Optimized) + type = YellowBlue; + if (aParams->AnaglyphFilter == Graphic3d_RenderingParams::Anaglyph_GreenMagenta_Simple) + type = GreenMagenta; + } + return type; +} + +void OCCViewer_ViewWindow::setStereographicFocus( int type, double value ) +{ + Handle(V3d_View) aView3d = myViewPort->getView(); + if ( !aView3d.IsNull() ) { + Handle(Graphic3d_Camera) aCamera = aView3d->Camera(); + aCamera->SetZFocus( (Graphic3d_Camera::FocusType) type, value ); + } +} + +int OCCViewer_ViewWindow::stereographicFocusType() const +{ + int type = Relative; + Handle(V3d_View) aView3d = myViewPort->getView(); + if ( !aView3d.IsNull() ) { + Handle(Graphic3d_Camera) aCamera = aView3d->Camera(); + type = (OCCViewer_ViewWindow::FocusIODType)aCamera->ZFocusType(); + } + return type; +} + +double OCCViewer_ViewWindow::stereographicFocusValue() const +{ + double value = 1.0; + Handle(V3d_View) aView3d = myViewPort->getView(); + if ( !aView3d.IsNull() ) { + Handle(Graphic3d_Camera) aCamera = aView3d->Camera(); + value = aCamera->ZFocus(); + } + return value; +} + +void OCCViewer_ViewWindow::setInterocularDistance( int type, double value ) +{ + Handle(V3d_View) aView3d = myViewPort->getView(); + if ( !aView3d.IsNull() ) { + Handle(Graphic3d_Camera) aCamera = aView3d->Camera(); + aCamera->SetIOD( (Graphic3d_Camera::IODType) type, value ); + } +} + +int OCCViewer_ViewWindow::interocularDistanceType() const +{ + int type = Relative; + Handle(V3d_View) aView3d = myViewPort->getView(); + if ( !aView3d.IsNull() ) { + Handle(Graphic3d_Camera) aCamera = aView3d->Camera(); + type = (OCCViewer_ViewWindow::FocusIODType)aCamera->GetIODType(); + } + return type; +} + +double OCCViewer_ViewWindow::interocularDistanceValue() const +{ + double value = 0.05; + Handle(V3d_View) aView3d = myViewPort->getView(); + if ( !aView3d.IsNull() ) { + Handle(Graphic3d_Camera) aCamera = aView3d->Camera(); + value = aCamera->IOD(); + } + return value; +} + +void OCCViewer_ViewWindow::setReverseStereo( bool reverse ) +{ + Handle(V3d_View) aView3d = myViewPort->getView(); + if ( !aView3d.IsNull() ) { + Graphic3d_RenderingParams* aParams = &aView3d->ChangeRenderingParams(); + aParams->ToReverseStereo = reverse; + } +} + +bool OCCViewer_ViewWindow::isReverseStereo() const +{ + int reverse = false; + Handle(V3d_View) aView3d = myViewPort->getView(); + if ( !aView3d.IsNull() ) { + Graphic3d_RenderingParams* aParams = &aView3d->ChangeRenderingParams(); + reverse = aParams->ToReverseStereo; + } + return reverse; +} + +void OCCViewer_ViewWindow::setVSync( bool enable ) +{ + Handle(AIS_InteractiveContext) anIntCont = myModel->getAISContext(); + if ( !anIntCont.IsNull() ) { + Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast(anIntCont->CurrentViewer()->Driver()); + OpenGl_Caps* aCaps = &aDriver->ChangeOptions(); + aCaps->swapInterval = enable; + } +} + +bool OCCViewer_ViewWindow::isVSync() const +{ + int enable = true; + Handle(AIS_InteractiveContext) anIntCont = myModel->getAISContext(); + if ( !anIntCont.IsNull() ) { + Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast(anIntCont->CurrentViewer()->Driver()); + OpenGl_Caps* aCaps = &aDriver->ChangeOptions(); + enable = aCaps->swapInterval; + } + return enable; +} + +void OCCViewer_ViewWindow::setQuadBufferSupport( bool enable ) +{ + Handle(AIS_InteractiveContext) anIntCont = myModel->getAISContext(); + if ( !anIntCont.IsNull() ) { + Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast(anIntCont->CurrentViewer()->Driver()); + OpenGl_Caps* aCaps = &aDriver->ChangeOptions(); + aCaps->contextStereo = enable; + } +} + +bool OCCViewer_ViewWindow::isQuadBufferSupport() const +{ + int enable = true; + Handle(AIS_InteractiveContext) anIntCont = myModel->getAISContext(); + if ( !anIntCont.IsNull() ) { + Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast(anIntCont->CurrentViewer()->Driver()); + OpenGl_Caps* aCaps = &aDriver->ChangeOptions(); + enable = aCaps->contextStereo; + } + return enable; +} + +bool OCCViewer_ViewWindow::isOpenGlStereoSupport() const +{ + GLboolean support[1]; + glGetBooleanv (GL_STEREO, support); + if ( support[0] ) + return true; + return false; +} + // obsolete QColor OCCViewer_ViewWindow::backgroundColor() const { diff --git a/src/OCCViewer/OCCViewer_ViewWindow.h b/src/OCCViewer/OCCViewer_ViewWindow.h index c0a023771..08f4202e3 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.h +++ b/src/OCCViewer/OCCViewer_ViewWindow.h @@ -151,7 +151,7 @@ public: SwitchInteractionStyleId, SwitchZoomingStyleId, SwitchPreselectionId, SwitchSelectionId, MaximizedId, SynchronizeId, ReturnTo3dViewId, - OrthographicId, PerspectiveId, + OrthographicId, PerspectiveId, StereoId, UserId }; enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE, @@ -165,8 +165,14 @@ public: enum Mode2dType { No2dMode, XYPlane, XZPlane, YZPlane }; - enum ProjectionType { Orthographic, Perspective }; + enum ProjectionType { Orthographic, Perspective, Stereo }; + enum StereoType { QuadBuffer, Anaglyph, RowInterlaced, ColumnInterlaced, ChessBoard, SideBySide, OverUnder, SoftPageFlip, NumberOfModes }; + + enum AnaglyphFilter { RedCyan, YellowBlue, GreenMagenta }; + + enum FocusIODType { Absolute, Relative }; + OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel); virtual ~OCCViewer_ViewWindow(); @@ -211,6 +217,29 @@ public: virtual int projectionType() const; virtual void setProjectionType( int ); + virtual int stereoType() const; + virtual void setStereoType( const int ); + + virtual int anaglyphFilter() const; + virtual void setAnaglyphFilter( const int ); + + virtual void setStereographicFocus( const int, const double ); + virtual int stereographicFocusType() const; + virtual double stereographicFocusValue() const; + + virtual void setInterocularDistance( const int, const double ); + virtual int interocularDistanceType() const; + virtual double interocularDistanceValue() const; + + virtual bool isReverseStereo() const; + virtual void setReverseStereo( const bool ); + + virtual bool isVSync() const; + virtual void setVSync( const bool ); + + virtual bool isQuadBufferSupport() const; + virtual void setQuadBufferSupport( const bool ); + void setTransformEnabled( const OperationType, const bool ); bool transformEnabled( const OperationType ) const; @@ -304,6 +333,8 @@ public: protected: virtual QString filter() const; + bool isOpenGlStereoSupport() const; + /* Transformation selected but not started yet */ bool transformRequested() const; bool setTransformRequested ( OperationType ); @@ -322,7 +353,7 @@ protected: void createActions(); void createToolBar(); - + virtual OperationType getButtonState(QMouseEvent* theEvent, int theInteractionStyle); viewAspect getViewParams() const; diff --git a/src/OCCViewer/resources/OCCViewer_images.ts b/src/OCCViewer/resources/OCCViewer_images.ts index 74b1e9f56..ee8fbb6a0 100644 --- a/src/OCCViewer/resources/OCCViewer_images.ts +++ b/src/OCCViewer/resources/OCCViewer_images.ts @@ -147,5 +147,9 @@ ICON_OCCVIEWER_PERSPECTIVE occ_view_perspective.png + + ICON_OCCVIEWER_STEREO + occ_view_stereo.png + diff --git a/src/OCCViewer/resources/OCCViewer_msg_en.ts b/src/OCCViewer/resources/OCCViewer_msg_en.ts index a533aa166..5c993519b 100644 --- a/src/OCCViewer/resources/OCCViewer_msg_en.ts +++ b/src/OCCViewer/resources/OCCViewer_msg_en.ts @@ -312,6 +312,18 @@ DSC_PERSPECTIVE_MODE Set the perspective projection type + + MNU_STEREO_MODE + Stereo projection + + + DSC_STEREO_MODE + Set the stereo projection type + + + WRN_SUPPORT_QUAD_BUFFER + Graphic driver not support quad-buffer + OCCViewer_CreateRestoreViewDlg @@ -444,6 +456,34 @@ BG_IMAGE_FILES Image files (*.bmp *.gif *.pix *.xwd *.rgb *.rs) + + ST_QUADBUFFER + Shutter glasses (OpenGL quad-buffer) + + + ST_ANAGLYPH + Anaglyph + + + ST_ROWINTERLACED + Row-interlaced + + + ST_COLUMNINTERLACED + Column-interlaced + + + ST_CHESSBOARD + Chess-board stereo for DLP TVs + + + ST_SIDEBYSIDE + Horizontal-anamorphic (side-by-side) + + + ST_OVERUNDER + Vertical-anamorphic (Half OverUnder) + OCCViewer_AxialScaleDlg diff --git a/src/OCCViewer/resources/OCCViewer_msg_fr.ts b/src/OCCViewer/resources/OCCViewer_msg_fr.ts index 87e685c02..df2e06769 100755 --- a/src/OCCViewer/resources/OCCViewer_msg_fr.ts +++ b/src/OCCViewer/resources/OCCViewer_msg_fr.ts @@ -312,6 +312,18 @@ DSC_PERSPECTIVE_MODE Choisir la projection en perspective + + MNU_STEREO_MODE + Stereo projection + + + DSC_STEREO_MODE + Set the stereo projection type + + + WRN_SUPPORT_QUAD_BUFFER + Graphic driver not support quad-buffer + OCCViewer_CreateRestoreViewDlg @@ -444,6 +456,34 @@ BG_IMAGE_FILES Fichiers images (*.bmp *.gif *.pix *.xwd *.rgb *.rs) + + ST_QUADBUFFER + Shutter glasses (OpenGL quad-buffer) + + + ST_ANAGLYPH + Anaglyph + + + ST_ROWINTERLACED + Row-interlaced + + + ST_COLUMNINTERLACED + Column-interlaced + + + ST_CHESSBOARD + Chess-board stereo for DLP TVs + + + ST_SIDEBYSIDE + Horizontal-anamorphic (side-by-side) + + + ST_OVERUNDER + Vertical-anamorphic (Half OverUnder) + OCCViewer_AxialScaleDlg diff --git a/src/OCCViewer/resources/OCCViewer_msg_ja.ts b/src/OCCViewer/resources/OCCViewer_msg_ja.ts index f88b6b5da..c05ea384d 100644 --- a/src/OCCViewer/resources/OCCViewer_msg_ja.ts +++ b/src/OCCViewer/resources/OCCViewer_msg_ja.ts @@ -312,6 +312,18 @@ DSC_PERSPECTIVE_MODE 透視投影を選択します。 + + MNU_STEREO_MODE + Stereo projection + + + DSC_STEREO_MODE + Set the stereo projection type + + + WRN_SUPPORT_QUAD_BUFFER + Graphic driver not support quad-buffer + OCCViewer_CreateRestoreViewDlg @@ -444,6 +456,34 @@ BG_IMAGE_FILES イメージ ファイル (*.bmp *.gif *.pix *.xwd *.rgb * .rs) + + ST_QUADBUFFER + Shutter glasses (OpenGL quad-buffer) + + + ST_ANAGLYPH + Anaglyph + + + ST_ROWINTERLACED + Row-interlaced + + + ST_COLUMNINTERLACED + Column-interlaced + + + ST_CHESSBOARD + Chess-board stereo for DLP TVs + + + ST_SIDEBYSIDE + Horizontal-anamorphic (side-by-side) + + + ST_OVERUNDER + Vertical-anamorphic (Half OverUnder) + OCCViewer_AxialScaleDlg diff --git a/src/OCCViewer/resources/occ_view_stereo.png b/src/OCCViewer/resources/occ_view_stereo.png new file mode 100644 index 000000000..218a2a64d Binary files /dev/null and b/src/OCCViewer/resources/occ_view_stereo.png differ diff --git a/src/Qtx/Qtx.cxx b/src/Qtx/Qtx.cxx index 3b147fc67..a4df0a7c3 100755 --- a/src/Qtx/Qtx.cxx +++ b/src/Qtx/Qtx.cxx @@ -2117,6 +2117,7 @@ Qt::HANDLE Qtx::getVisual() GLX_RGBA, // Needs to support OpenGL GLX_DEPTH_SIZE, 16, // Needs to support a 16 bit depth buffer GLX_DOUBLEBUFFER, // Needs to support double-buffering + GLX_STEREO, // Needs to support stereo rendering GLX_STENCIL_SIZE, 1, None // end of list }; 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/SUIT/SUIT_Application.cxx b/src/SUIT/SUIT_Application.cxx index 00f89a799..811be3e9a 100755 --- a/src/SUIT/SUIT_Application.cxx +++ b/src/SUIT/SUIT_Application.cxx @@ -278,6 +278,7 @@ void SUIT_Application::setDesktop( SUIT_Desktop* desk ) myDesktop = desk; if ( myDesktop ) { connect( myDesktop, SIGNAL( activated() ), this, SLOT( onDesktopActivated() ) ); +// connect( myDesktop, SIGNAL( moved() ), this, SLOT( onDesktopMoved() ) ); // Force desktop activation (NPAL16628) QApplication::postEvent(myDesktop, new QEvent(QEvent::WindowActivate)); } @@ -689,6 +690,13 @@ void SUIT_Application::onDesktopActivated() emit activated( this ); } +/*! + SLOT: it is called when desktop is moved +*/ +/*void SUIT_Application::onDesktopMoved() +{ + emit moving(); +}*/ /*! SLOT: is used for Help browsing */ diff --git a/src/SUIT/SUIT_Application.h b/src/SUIT/SUIT_Application.h index 917c3872b..542b160bb 100755 --- a/src/SUIT/SUIT_Application.h +++ b/src/SUIT/SUIT_Application.h @@ -118,6 +118,7 @@ public: signals: void applicationClosed( SUIT_Application* ); void activated( SUIT_Application* ); +// void moving(); void infoChanged( QString ); public slots: @@ -176,6 +177,7 @@ protected: protected slots: virtual void onDesktopActivated(); +// void onDesktopMoved(); private: SUIT_Study* myStudy; diff --git a/src/SUIT/SUIT_Desktop.cxx b/src/SUIT/SUIT_Desktop.cxx index e0cbd04a0..96bc10f3d 100755 --- a/src/SUIT/SUIT_Desktop.cxx +++ b/src/SUIT/SUIT_Desktop.cxx @@ -84,6 +84,9 @@ bool SUIT_Desktop::event( QEvent* e ) case QEvent::WindowDeactivate: emit deactivated(); break; + /*case QEvent::Move: + emit moved(); + break;*/ default: break; } diff --git a/src/SUIT/SUIT_Desktop.h b/src/SUIT/SUIT_Desktop.h index c1f62e4d7..8a0a17e53 100755 --- a/src/SUIT/SUIT_Desktop.h +++ b/src/SUIT/SUIT_Desktop.h @@ -76,6 +76,7 @@ public: signals: void activated(); void deactivated(); +// void moved(); void windowActivated( SUIT_ViewWindow* ); void closing( SUIT_Desktop*, QCloseEvent* ); void message( const QString& );