]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
0023083: [CEA 1400] Be able to active stereo in OCC view and to choose which kind...
authorimn <imn@opencascade.com>
Thu, 16 Jul 2015 13:45:14 +0000 (16:45 +0300)
committerimn <imn@opencascade.com>
Fri, 31 Jul 2015 11:15:34 +0000 (14:15 +0300)
29 files changed:
src/LightApp/LightApp_Application.cxx
src/LightApp/LightApp_Application.h
src/LightApp/LightApp_FullScreenHelper.cxx
src/LightApp/LightApp_FullScreenHelper.h
src/LightApp/resources/LightApp.xml
src/LightApp/resources/LightApp_msg_en.ts
src/LightApp/resources/LightApp_msg_fr.ts
src/LightApp/resources/LightApp_msg_ja.ts
src/OCCViewer/CMakeLists.txt
src/OCCViewer/OCCViewer_ViewFrame.cxx
src/OCCViewer/OCCViewer_ViewFrame.h
src/OCCViewer/OCCViewer_ViewModel.cxx
src/OCCViewer/OCCViewer_ViewModel.h
src/OCCViewer/OCCViewer_ViewPort3d.cxx
src/OCCViewer/OCCViewer_ViewPort3d.h
src/OCCViewer/OCCViewer_ViewWindow.cxx
src/OCCViewer/OCCViewer_ViewWindow.h
src/OCCViewer/resources/OCCViewer_images.ts
src/OCCViewer/resources/OCCViewer_msg_en.ts
src/OCCViewer/resources/OCCViewer_msg_fr.ts
src/OCCViewer/resources/OCCViewer_msg_ja.ts
src/OCCViewer/resources/occ_view_stereo.png [new file with mode: 0644]
src/Qtx/Qtx.cxx
src/Qtx/QtxWorkstack.cxx
src/Qtx/QtxWorkstack.h
src/SUIT/SUIT_Application.cxx
src/SUIT/SUIT_Application.h
src/SUIT/SUIT_Desktop.cxx
src/SUIT/SUIT_Desktop.h

index 1ee467adfa8d07e7f27ffdb8f54efad8e229815a..0eb31709f6981ae725eb7959f6f5a4c717525167 100644 (file)
 #ifndef DISABLE_OCCVIEWER
   #include <OCCViewer_ViewManager.h>
   #include <OCCViewer_ViewFrame.h>
+  #include <OCCViewer_ViewPort3d.h>
 #ifndef DISABLE_SALOMEOBJECT
   #include <SOCC_ViewModel.h>
 #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 );
 
@@ -1532,6 +1535,18 @@ 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() ) );
+  #if OCC_VERSION_LARGE > 0x06090000
+    vm->setStereoType( resMgr->integerValue( "OCCViewer", "stereo_type", 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() ) );
+  #endif
     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() ) );
@@ -1836,6 +1851,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<OCCViewer_ViewManager*>( getViewManager( OCCViewer_Viewer::Type(), false ) );
+  if (viewMgr) {
+    OCCViewer_ViewWindow* view = 0;
+    view = dynamic_cast<OCCViewer_ViewWindow*>( viewMgr->getActiveView() );
+    if (view) {
+      view->getViewPort()->repaintViewAfterMove();
+    }
+  }
+}
+*/
 /*!Private SLOT. Support drag-and-drop operation.*/
 void LightApp_Application::onDropped( const QList<SUIT_DataObject*>& objects, SUIT_DataObject* parent, int row, Qt::DropAction action )
 {
@@ -2257,13 +2288,15 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref )
   pref->setItemProperty( "strings", aValuesList,   mruLinkType );
   pref->setItemProperty( "indexes", anIndicesList, mruLinkType );
   // ... "MRU" preferences group <<end>>
+
   // ... "Full-screen" group <<start>>
   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" );
+                      LightApp_Preferences::Bool, "OCCViewer", "automatic_hiding" );
   // ... "Full-screen" group <<end>>
+
   // .. "General" preferences tab <<end>>
 
   // .. "3D viewer" group <<start>>
@@ -2307,7 +2340,7 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref )
   // .. "OCC viewer" group <<start>>
   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();
@@ -2316,12 +2349,85 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref )
   anIndicesList << 0                       << 1;
   pref->setItemProperty( "strings", aValuesList,   occProjMode );
   pref->setItemProperty( "indexes", anIndicesList, occProjMode );
+#if OCC_VERSION_LARGE > 0x06090000
+  // .... -> 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();
+  idList.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" );
+#endif
   // ... "Background" group <<start>>
   int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup );
   //  pref->setItemProperty( "columns", 2, bgGroup );
   aValuesList.clear();
   anIndicesList.clear();
   txtList.clear();
+  idList.clear();
   formats = OCCViewer_Viewer::backgroundData( aValuesList, idList, txtList );
   foreach( int gid, idList ) anIndicesList << gid;
   // .... -> 3D viewer background
@@ -2413,6 +2519,7 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref )
   pref->setItemProperty( "margin",  0, occGen );
   pref->setItemProperty( "columns", 2, occGen );
   // ... -> empty frame (for layout) <<end>>
+
   // .. "OCC viewer" group <<end>>
 #endif
 
@@ -3018,7 +3125,144 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString
     }
   }
 #endif
+#if OCC_VERSION_LARGE > 0x06090000
+#ifndef DISABLE_OCCVIEWER
+  if ( sec == QString( "OCCViewer" ) && param == QString( "stereo_type" ) )
+  {
+    int mode = resMgr->integerValue( "OCCViewer", "stereo_type", 0 );
+    QList<SUIT_ViewManager*> lst;
+    viewManagers( OCCViewer_Viewer::Type(), lst );
+    QListIterator<SUIT_ViewManager*> 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<SUIT_ViewManager*> lst;
+    viewManagers( OCCViewer_Viewer::Type(), lst );
+    QListIterator<SUIT_ViewManager*> 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<SUIT_ViewManager*> lst;
+    viewManagers( OCCViewer_Viewer::Type(), lst );
+    QListIterator<SUIT_ViewManager*> 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<SUIT_ViewManager*> lst;
+    viewManagers( OCCViewer_Viewer::Type(), lst );
+    QListIterator<SUIT_ViewManager*> 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<SUIT_ViewManager*> lst;
+    viewManagers( OCCViewer_Viewer::Type(), lst );
+    QListIterator<SUIT_ViewManager*> 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<SUIT_ViewManager*> lst;
+    viewManagers( OCCViewer_Viewer::Type(), lst );
+    QListIterator<SUIT_ViewManager*> 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<SUIT_ViewManager*> lst;
+    viewManagers( OCCViewer_Viewer::Type(), lst );
+    QListIterator<SUIT_ViewManager*> 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
+#endif
   if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) )
   {
     int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 );
@@ -3926,6 +4170,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 ); */
   }
 }
 
index 24d59fbcbfcb4aa3f0b61b1080163c35c8ee063d..3d7080d6bc5363bd32257c1f2c17a288d1c82766 100644 (file)
@@ -276,6 +276,7 @@ private slots:
   void                                onCloseAllWindow();
   void                                onGroupAllWindow();
   void                                onRenamed();
+  //void                                onMoved();
 
 protected:
   void                                updateWindows();
index 7ddce9822a53dbbeeb38439ef3de07f933c47baa..56610b6a344f78729004a9e05922a1bce82b7b36 100644 (file)
 #include <SUIT_ViewWindow.h>
 #include <SUIT_ResourceMgr.h>
 
+#ifndef DISABLE_OCCVIEWER
+  #include <OCCViewer_ViewFrame.h>
+#endif
+
 #include "LightApp_FullScreenHelper.h"
 #include "LightApp_Application.h"
 
@@ -82,32 +86,44 @@ void LightApp_FullScreenHelper::switchToFullScreen() {
   
   STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop );
 
-  QtxWorkstack* wgStack = desk->workstack();
-  wgStack->showActiveTabBar(false);
   myWindowsList.clear();
-  bool isHidding = false;
-  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
-  if ( resMgr )
-    isHidding = resMgr->booleanValue( "OCCViewer", "automatic_hiding", true );
+  myFrameHideMap.clear();
   //Hide all toolbars and inactive window
   QList<SUIT_ViewWindow*> aWindowList = desk->windows();
   SUIT_ViewWindow* anActiveWindow = desk->activeWindow();
   QList<SUIT_ViewWindow*>::const_iterator it = aWindowList.begin();
-  for ( ; it!=aWindowList.end(); it++ ) {
-    QList<QToolBar*> lst = (*it)->findChildren<QToolBar*>();
-    if ( *it ) {
-      myWindowsList.push_back(*it);
-      ( *it )->hide();
-    }
-    if ( isHidding ) {
-      QList<QToolBar*>::const_iterator iter = lst.begin();
-      for ( ; iter!=lst.end(); iter++ ) {
-        (*iter)->hide();
+  int aKey = 0;
+  for ( ; it != aWindowList.end(); it++ ) {
+    myWindowsList.push_back(*it);
+  #ifndef DISABLE_OCCVIEWER
+    OCCViewer_ViewFrame* anActiveOCCFrame = dynamic_cast<OCCViewer_ViewFrame*>( *it );
+    if ( anActiveOCCFrame ) {
+      QList<int> aList;
+      if ( (*it) == anActiveWindow ) {
+        OCCViewer_ViewWindow* anActiveOCCWindow = anActiveOCCFrame->getActiveView();
+        for (int i = OCCViewer_ViewFrame::BOTTOM_RIGHT; i <= OCCViewer_ViewFrame::TOP_RIGHT; i++ ) {
+          OCCViewer_ViewWindow* aCurrentOCCWindow = anActiveOCCFrame->getView(i);
+          if ( aCurrentOCCWindow && aCurrentOCCWindow->isVisible() ) {
+            if ( aCurrentOCCWindow != anActiveOCCWindow ) {
+              aCurrentOCCWindow->hide();
+              toolbarVisible(aCurrentOCCWindow, false);
+            }
+            if ( anActiveOCCWindow )
+              aList.append(i);
+          }
+        }
+      }
+      if ( aList.count() > 0 ) {
+        myFrameHideMap.insert(aKey, aList);
+        aKey++;
       }
     }
+  #endif
+    toolbarVisible(*it, false);
   }
-  if (anActiveWindow)
-    anActiveWindow->show();
+
+  QtxWorkstack* wgStack = desk->workstack();
+  wgStack->splittersVisible(anActiveWindow, false);
 
   desktop->setWindowState(desktop->windowState() ^ Qt::WindowFullScreen);
 
@@ -126,6 +142,11 @@ void LightApp_FullScreenHelper::switchToFullScreen() {
   QList<QDockWidget*> aDocWidgets = desktop->findChildren<QDockWidget*>();
   myDocWidgetMap.clear();
 
+  bool isHidding = false;
+  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+    if ( resMgr )
+      isHidding = resMgr->booleanValue( "OCCViewer", "automatic_hiding", true );
+
   QWidget* ob = app->objectBrowser();
   QObject* obParent = (ob && !isHidding)? ob->parent() : 0;
 
@@ -146,7 +167,7 @@ void LightApp_FullScreenHelper::switchToFullScreen() {
       }
     }    
   }
-  
+
   QList<QToolBar*> aToolBars = desktop->findChildren<QToolBar*>();
   myToolBarMap.clear();
   foreach(QToolBar* aWidget, aToolBars )  {
@@ -164,7 +185,7 @@ void LightApp_FullScreenHelper::switchToFullScreen() {
        myToolBarMap.insert(aWidget, isActionEnabled);
       }
     }    
-  }  
+  }
 }
 
 /*!
@@ -189,28 +210,32 @@ void LightApp_FullScreenHelper::switchToNormalScreen() {
   desktop->setWindowState(desktop->windowState() ^ Qt::WindowFullScreen);
 
   STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop );
+  SUIT_ViewWindow* anActiveWindow = desk->activeWindow();
 
-  QtxWorkstack* wgStack = desk->workstack();
-  wgStack->showActiveTabBar(true);
-
-  bool isHidding = false;
-  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
-  if ( resMgr )
-    isHidding = resMgr->booleanValue( "OCCViewer", "automatic_hiding", true );
   //Show all toolbars and windows
   QList<SUIT_ViewWindow*>::const_iterator itr = myWindowsList.begin();
-  for ( ; itr!=myWindowsList.end(); itr++ ) {
-    QList<QToolBar*> lst = (*itr)->findChildren<QToolBar*>();
-    if (*itr && !(*itr)->isVisible())
-      (*itr)->show();
-    if ( isHidding ) {
-      QList<QToolBar*>::const_iterator iter = lst.begin();
-      for ( ; iter!=lst.end(); iter++ ) {
-        (*iter)->show();
+  int aKey = 0;
+  for ( ; itr != myWindowsList.end(); itr++ ) {
+  #ifndef DISABLE_OCCVIEWER
+    OCCViewer_ViewFrame* anActiveOCCFrame = dynamic_cast<OCCViewer_ViewFrame*>( *itr );
+    if ( anActiveOCCFrame ) {
+      if ( (*itr) == anActiveWindow ) {
+        QList<int>::const_iterator it = myFrameHideMap[aKey].begin();
+        for (; it != myFrameHideMap[aKey].end(); it++) {
+          OCCViewer_ViewWindow* aCurrentOCCWindow = anActiveOCCFrame->getView(*it);
+          aCurrentOCCWindow->show();
+          toolbarVisible( aCurrentOCCWindow, true);
+        }
+        aKey++;
       }
     }
+  #endif
+    toolbarVisible( *itr, true );
   }
 
+  QtxWorkstack* wgStack = desk->workstack();
+  wgStack->splittersVisible(anActiveWindow, true);
+
   DocWidgetMap::iterator it = myDocWidgetMap.begin();
   for( ;it != myDocWidgetMap.end() ; it++ ) {
     QDockWidget* aWidget = it.key();
@@ -240,5 +265,24 @@ void LightApp_FullScreenHelper::switchToNormalScreen() {
     if(act)
       act->setEnabled(true);
   }
-  
+}
+
+/*!
+ * Show/Hide toolbars on current view.
+ */
+void LightApp_FullScreenHelper::toolbarVisible(SUIT_ViewWindow* view, bool toolbar_visible)
+{
+  bool isHidding = false;
+  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+  if ( resMgr )
+    isHidding = resMgr->booleanValue( "OCCViewer", "automatic_hiding", true );
+  QList<QToolBar*> lst = view->findChildren<QToolBar*>();
+  if ( isHidding ) {
+    QList<QToolBar*>::const_iterator iter = lst.begin();
+    for ( ; iter!=lst.end(); iter++ ) {
+      if ( *iter ) {
+        (*iter)->setVisible(toolbar_visible);
+      }
+    }
+  }
 }
index e5f4dedf45e7faed7fc94753e94811eb2a284960..0b96d663e018b51cce15bc57ad8809e91efba35a 100644 (file)
@@ -43,12 +43,17 @@ class LIGHTAPP_EXPORT LightApp_FullScreenHelper {
   void switchToFullScreen();
   void switchToNormalScreen();
 
+ private:
+  void toolbarVisible(SUIT_ViewWindow*, bool=false);
+
  private:
   typedef QMap<QDockWidget*,bool> DocWidgetMap;
   DocWidgetMap myDocWidgetMap;
   typedef QMap<QToolBar*, bool> ToolBarMap;
   ToolBarMap myToolBarMap;
   QList<SUIT_ViewWindow*> myWindowsList;
+  typedef QMap<int, QList<int> > FrameHideMap;
+  FrameHideMap myFrameHideMap;
 
   bool myStatusBarVisibility;
 
index 5af653a277b49d3e4e6438d41c685754ceb17ff1..e8a0858e162a231fca81dced744f059a9ebdd555 100644 (file)
   </section>
   <section name="OCCViewer" >
     <!-- OCC viewer preferences -->
+    <parameter name="projection_mode"     value="0"/>
+    <parameter name="stereo_type"         value="0"/>
+    <parameter name="anaglyph_filter"     value="0"/>
+    <parameter name="focus_type"          value="1"/>
+    <parameter name="focus_value"         value="1.0"/>
+    <parameter name="iod_type"            value="1"/>
+    <parameter name="iod_value"           value="0.05"/>
+    <parameter name="reverse_stereo"      value="false"/>
+    <parameter name="enable_vsync"        value="true"/>
+    <parameter name="enable_quad_buffer_support" value="false"/>
     <parameter name="enable_preselection" value="true"/>
     <parameter name="enable_selection"    value="true"/>
     <parameter name="clipping_color"      value="50, 50, 50"/>
index c35522f0246d0fb36559ef7c7e086cb04f8013f6..9876572466807af52a3c7475865ce77ffb80aee1 100644 (file)
@@ -651,6 +651,38 @@ The changes will be applied on the next application session.</translation>
         <source>PREF_ANAGLYPH_GREEN_MAGENTA</source>
         <translation>Green-Magenta</translation>
     </message>
+    <message>
+        <source>PREF_FOCUS_TYPE</source>
+        <translation>Convergence distance type</translation>
+    </message>
+    <message>
+        <source>PREF_FOCUS_VALUE</source>
+        <translation>Stereographic focus value</translation>
+    </message>
+    <message>
+        <source>PREF_IOD_TYPE</source>
+        <translation>IOD type</translation>
+    </message>
+    <message>
+        <source>PREF_IOD_VALUE</source>
+        <translation>Interocular distance (IOD) value</translation>
+    </message>
+    <message>
+        <source>PREF_ABSOLUTE</source>
+        <translation>Absolute</translation>
+    </message>
+    <message>
+        <source>PREF_RELATIVE</source>
+        <translation>Relative</translation>
+    </message>
+    <message>
+        <source>PREF_REVERSE_STEREO</source>
+        <translation>Reverse stereo</translation>
+    </message>
+    <message>
+        <source>PREF_ENABLE_VSYNC</source>
+        <translation>Enable V-Sync</translation>
+    </message>
     <message>
         <source>PREF_ENABLE_QUAD_BUFFER_SUPPORT</source>
         <translation>Enable quad-buffer support</translation>
index 80af332b3b7ee3deec355fe6d24554925b992482..9d293f2546190ac4d50416872136aabd3f5296a1 100755 (executable)
@@ -651,6 +651,38 @@ Les modifications seront appliquées à la prochaine session.</translation>
         <source>PREF_ANAGLYPH_GREEN_MAGENTA</source>
         <translation type="unfinished">Green-Magenta</translation>
     </message>
+    <message>
+        <source>PREF_FOCUS_TYPE</source>
+        <translation> type="unfinished"Convergence distance type</translation>
+    </message>
+    <message>
+        <source>PREF_FOCUS_VALUE</source>
+        <translation type="unfinished">Stereographic focus value</translation>
+    </message>
+    <message>
+        <source>PREF_IOD_TYPE</source>
+        <translation type="unfinished">IOD type</translation>
+    </message>
+    <message>
+        <source>PREF_IOD_VALUE</source>
+        <translation type="unfinished">Interocular distance (IOD) value</translation>
+    </message>
+    <message>
+        <source>PREF_ABSOLUTE</source>
+        <translation type="unfinished">Absolute</translation>
+    </message>
+    <message>
+        <source>PREF_RELATIVE</source>
+        <translation type="unfinished">Relative</translation>
+    </message>
+    <message>
+        <source>PREF_REVERSE_STEREO</source>
+        <translation type="unfinished">Reverse stereo</translation>
+    </message>
+    <message>
+        <source>PREF_ENABLE_VSYNC</source>
+        <translation type="unfinished">Enable V-Sync</translation>
+    </message>
     <message>
         <source>PREF_ENABLE_QUAD_BUFFER_SUPPORT</source>
         <translation type="unfinished">Enable quad-buffer support</translation>
index 42400f42ee2939b500e043f7f0dbe66aaffa9c20..954a371ce4faede40105f3310557a5cec08dc850 100644 (file)
@@ -651,6 +651,38 @@ CEA/DEN, CEDRAT, EDF R&amp;D, LEG, PRINCIPIA R&amp;D, BUREAU VERITAS</translatio
       <source>PREF_ANAGLYPH_GREEN_MAGENTA</source>
       <translation type="unfinished">Green-Magenta</translation>
     </message>
+    <message>
+      <source>PREF_FOCUS_TYPE</source>
+      <translation> type="unfinished"Convergence distance type</translation>
+    </message>
+    <message>
+      <source>PREF_FOCUS_VALUE</source>
+      <translation type="unfinished">Stereographic focus value</translation>
+    </message>
+    <message>
+      <source>PREF_IOD_TYPE</source>
+      <translation type="unfinished">IOD type</translation>
+    </message>
+    <message>
+      <source>PREF_IOD_VALUE</source>
+      <translation type="unfinished">Interocular distance (IOD) value</translation>
+    </message>
+    <message>
+      <source>PREF_ABSOLUTE</source>
+      <translation type="unfinished">Absolute</translation>
+    </message>
+    <message>
+      <source>PREF_RELATIVE</source>
+      <translation type="unfinished">Relative</translation>
+    </message>
+    <message>
+      <source>PREF_REVERSE_STEREO</source>
+      <translation type="unfinished">Reverse stereo</translation>
+    </message>
+    <message>
+      <source>PREF_ENABLE_VSYNC</source>
+      <translation type="unfinished">Enable V-Sync</translation>
+    </message>
     <message>
       <source>PREF_ENABLE_QUAD_BUFFER_SUPPORT</source>
       <translation type="unfinished">Enable quad-buffer support</translation>
index a69ace13358b076cf121a8f7ca17a19a01768ef3..01e7473bb8ec32a09450f3fd6294de2792f88500 100755 (executable)
@@ -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
index 9ebb0cdf228f9e3e3eb4aa78ab9fedaf0c30c7dc..70e253b63a624abf80814b44a63079ea943c6da7 100644 (file)
@@ -52,6 +52,7 @@ OCCViewer_ViewFrame::OCCViewer_ViewFrame(SUIT_Desktop* theDesktop, OCCViewer_Vie
 
   myLayout->addWidget( view0, 0, 0 );
   myMaximizedView = view0;
+  myActiveView = view0;
   connectViewSignals(view0);
 }
 
@@ -76,6 +77,12 @@ OCCViewer_ViewWindow* OCCViewer_ViewFrame::getView( const int i ) const
   return ( i >= 0 && i < myViews.count() ) ? myViews.at( i ) : 0 ;
 }
 
+//**************************************************************************************
+OCCViewer_ViewWindow* OCCViewer_ViewFrame::getActiveView( ) const
+{
+  return myActiveView;
+}
+
 //**************************************************************************************
 void OCCViewer_ViewFrame::setViewManager( SUIT_ViewManager* theMgr )
 {
@@ -93,7 +100,10 @@ void OCCViewer_ViewFrame::returnTo3dView()
     view = myViews.at(i);
     view->setVisible( view->get2dMode() == No2dMode );
     view->setMaximized( true, false );
-    if (view->get2dMode() == No2dMode) myMaximizedView = view;
+    if (view->get2dMode() == No2dMode) {
+      myMaximizedView = view;
+      myActiveView = view;
+    }
   }
   myLayout->setColumnStretch(0, 0);
   myLayout->setColumnStretch(1, 0);
@@ -107,6 +117,7 @@ void OCCViewer_ViewFrame::returnTo3dView()
 void OCCViewer_ViewFrame::onMaximizedView( OCCViewer_ViewWindow* theView, bool isMaximized)
 {
   myMaximizedView = theView;
+  myActiveView = theView;
   if (isMaximized) {
     if (myViews.count() <= 1)
       return;
@@ -328,6 +339,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 ) 
 { 
@@ -356,6 +477,9 @@ void OCCViewer_ViewFrame::connectViewSignals(OCCViewer_ViewWindow* theView)
            this, SIGNAL( mouseDoubleClicked(SUIT_ViewWindow*, QMouseEvent*) ) );
   connect( theView, SIGNAL( mousePressed(SUIT_ViewWindow*, QMouseEvent*) ), 
            this, SIGNAL( mousePressed(SUIT_ViewWindow*, QMouseEvent*) ) );
+  // The signal is used to mouse pressed for choose the current window
+  connect( theView, SIGNAL( mousePressed(SUIT_ViewWindow*, QMouseEvent*) ),
+           this, SLOT( onMousePressed(SUIT_ViewWindow*, QMouseEvent*) ) );
   connect( theView, SIGNAL( mouseReleased(SUIT_ViewWindow*, QMouseEvent*) ), 
            this, SIGNAL( mouseReleased(SUIT_ViewWindow*, QMouseEvent*) ) );
   connect( theView, SIGNAL( mouseMoving(SUIT_ViewWindow*, QMouseEvent*) ), 
@@ -469,6 +593,11 @@ void OCCViewer_ViewFrame::onContextMenuRequested(QContextMenuEvent*)
   myPopupRequestedView = dynamic_cast<OCCViewer_ViewWindow*>(sender());
 }
 
+void OCCViewer_ViewFrame::onMousePressed(SUIT_ViewWindow* view, QMouseEvent*)
+{
+  myActiveView = dynamic_cast<OCCViewer_ViewWindow*>(view);
+}
+
 void OCCViewer_ViewFrame::onDumpView()
 {
   if (myPopupRequestedView) {
index a8ef4b2ac5910ed269b2a8c59eafa54ef3034d13..8c04813980faf52b080c59ac2d4bfa7495dd8984 100644 (file)
@@ -46,6 +46,8 @@ public:
 
   OCCViewer_ViewWindow*   getView( const int ) const;
 
+  OCCViewer_ViewWindow*   getActiveView() const;
+
   virtual OCCViewer_ViewPort3d* getViewPort() { return getView(MAIN_VIEW)->getViewPort(); }
   OCCViewer_ViewPort3d* getViewPort(int theView);
 
@@ -73,6 +75,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 );
 
@@ -138,6 +163,7 @@ protected:
 
 private slots:
   void onContextMenuRequested(QContextMenuEvent*);
+  void onMousePressed(SUIT_ViewWindow*, QMouseEvent*);
 
 private:
   void connectViewSignals( OCCViewer_ViewWindow* theView );
@@ -148,6 +174,7 @@ private:
   QList<OCCViewer_ViewWindow*> myViews;
   QGridLayout* myLayout;
   OCCViewer_ViewWindow* myMaximizedView;
+  OCCViewer_ViewWindow* myActiveView;
   int mySplitMode;
   QList<int> myViewsMode;
 
index d8feb5d21ce801209b9433800713d830b96dbe42..afa24d3751b1bfbb5dca460b583338cc8a200e4e 100755 (executable)
@@ -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
@@ -154,7 +169,16 @@ 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 +243,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 )
     {
@@ -493,7 +524,226 @@ int OCCViewer_Viewer::projectionType() const
 */
 void OCCViewer_Viewer::setProjectionType( const int theType )
 {
-  myProjectionType = theType;
+  if ( myProjectionType != theType ) {
+    if ( theType != OCCViewer_ViewWindow::Stereo )
+      myProjectionType = theType;
+
+    if ( !myViewManager )
+      return;
+
+    QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
+    for ( int i = 0; i < (int)wins.count(); i++ )
+    {
+      OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
+      if ( win )
+        win->setProjectionType( (OCCViewer_ViewWindow::ProjectionType)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<SUIT_ViewWindow*> wins = myViewManager->getViews();
+  for ( int i = 0; i < (int)wins.count(); i++ )
+  {
+    OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( 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<SUIT_ViewWindow*> wins = myViewManager->getViews();
+  for ( int i = 0; i < (int)wins.count(); i++ )
+  {
+    OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( 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<SUIT_ViewWindow*> wins = myViewManager->getViews();
+  for ( int i = 0; i < (int)wins.count(); i++ )
+  {
+    OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( 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<SUIT_ViewWindow*> wins = myViewManager->getViews();
+  for ( int i = 0; i < (int)wins.count(); i++ )
+  {
+    OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( 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<SUIT_ViewWindow*> wins = myViewManager->getViews();
+  for ( int i = 0; i < (int)wins.count(); i++ )
+  {
+    OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( 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<SUIT_ViewWindow*> wins = myViewManager->getViews();
+  for ( int i = 0; i < (int)wins.count(); i++ )
+  {
+    OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( 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;
@@ -503,7 +753,7 @@ void OCCViewer_Viewer::setProjectionType( const int theType )
   {
     OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
     if ( win )
-      win->setProjectionType( (OCCViewer_ViewWindow::ProjectionType)theType );
+      win->setQuadBufferSupport( theEnable );
   }
 }
 
index 6bd1e12710244969e234ca0d420434f9386713b0..0115104bfdb1a2666d6ca7aefe215b418ac82952 100755 (executable)
@@ -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();
@@ -135,7 +143,28 @@ 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 +241,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;
 
index 7fa8797e2038e772e9f2b2e32e3679889da4b9f5..cc6d7bf5a496d68a28ce9401c1e20304d940803b 100755 (executable)
@@ -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 ]
 */
index 5ac793fb399b4d0b65b2bb1a189268f0d0a1a3e3..7f8841a25e2523ca88716d8f86f00d4af86dc1eb 100755 (executable)
@@ -94,6 +94,8 @@ public:
 
   void                  showStaticTrihedron( bool );
 
+  //void                  repaintViewAfterMove( );
+
   void                  setDefaultCursor( Qt::CursorShape theCursorShape );
   QCursor*              getDefaultCursor() const;
 
index 0599c7534b8d2a921b773998d43c0b17388f3c55..6d03da7df0ddb8e68acd2c8b67194df9a5a9e718 100755 (executable)
@@ -35,8 +35,6 @@
 #include "OCCViewer_CubeAxesDlg.h"
 #include "OCCViewer_ClippingDlg.h"
 
-#include <Basics_OCCTVersion.hxx>
-
 #include <SUIT_Desktop.h>
 #include <SUIT_Session.h>
 #include <SUIT_ViewManager.h>
@@ -49,7 +47,7 @@
 #include <QtxMultiAction.h>
 #include <QtxRubberBand.h>
 
-#include <OpenGLUtils_FrameBuffer.h>
+#include <Basics_OCCTVersion.hxx>
 
 #include <QPainter>
 #include <QTime>
 #include <GProp_GProps.hxx>
 #include <TopoDS.hxx>
 
+#include <Graphic3d_SequenceOfHClipPlane.hxx>
+#include <Graphic3d_ClipPlane.hxx>
+#include <OpenGl_GraphicDriver.hxx>
+#include <OpenGLUtils_FrameBuffer.h>
+
 #include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
 #include <Graphic3d_MapOfStructure.hxx>
 #include <Graphic3d_Structure.hxx>
 #include <Graphic3d_ExportFormat.hxx>
+#if OCC_VERSION_LARGE > 0x06090000
+#include <Graphic3d_StereoMode.hxx>
+#include <Graphic3d_RenderingParams.hxx>
+#endif
+
 
 #include <Visual3d_View.hxx>
 #include <V3d_Plane.hxx>
@@ -84,9 +92,6 @@
 #include <gp_GTrsf.hxx>
 #include <TColgp_Array1OfPnt2d.hxx>
 
-#include <Graphic3d_SequenceOfHClipPlane.hxx>
-#include <Graphic3d_ClipPlane.hxx>
-
 #include <Image_PixMap.hxx>
 
 #include <Standard_Version.hxx>
@@ -105,6 +110,12 @@ static QEvent* l_mbPressEvent = 0;
 
 #include <GL/gl.h>
 
+// 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 +263,6 @@ OCCViewer_ViewWindow::OCCViewer_ViewWindow( SUIT_Desktop*     theDesktop,
   myCursorIsHand = false;
 
   clearViewAspects();
-
 }
 
 /*!
@@ -1292,11 +1302,22 @@ void OCCViewer_ViewWindow::createActions()
   aAction->setCheckable(true);
   //connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onProjectionType()));
   toolMgr()->registerAction( aAction, PerspectiveId );
-
+#if OCC_VERSION_LARGE > 0x06090000
+  // - 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()));
+#endif
   // - add exclusive action group
   QActionGroup* aProjectionGroup = new QActionGroup( this );
   aProjectionGroup->addAction( toolMgr()->action( OrthographicId ) );
   aProjectionGroup->addAction( toolMgr()->action( PerspectiveId ) );
+#if OCC_VERSION_LARGE > 0x06090000
+  aProjectionGroup->addAction( toolMgr()->action( StereoId ) );
+#endif
   connect(aProjectionGroup, SIGNAL(triggered(QAction*)), this, SLOT(onProjectionType()));
 
   // Reset
@@ -1481,6 +1502,7 @@ void OCCViewer_ViewWindow::createToolBar()
 
     toolMgr()->append( OrthographicId, tid );
     toolMgr()->append( PerspectiveId, tid );
+    toolMgr()->append( StereoId, tid );
 
     toolMgr()->append( ResetId, tid );
   }
@@ -1628,7 +1650,14 @@ 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 OCC_VERSION_LARGE > 0x06090000
+  if (toolMgr()->action( StereoId )->isChecked())
+    setProjectionType( Stereo);
+#endif
   emit vpTransformationFinished( PROJECTION );
 }
 
@@ -2793,13 +2822,81 @@ 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) {
+      myModel->setProjectionType(Perspective);
+      aCamera->SetProjectionType ( Graphic3d_Camera::Projection_Perspective );
+    }
+    if (mode == Orthographic) {
+      myModel->setProjectionType(Orthographic);
+      aCamera->SetProjectionType ( Graphic3d_Camera::Projection_Orthographic );
+    }
+  #if OCC_VERSION_LARGE > 0x06090000
+    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", false ) );
+    }
+  #endif
+    aView3d->Redraw();
     onViewFitAll();
   }
   // update action state if method is called outside
-  QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( mode == Orthographic ? OrthographicId : PerspectiveId ) );
-  if ( ! a->isChecked() )
-    a->setChecked( true );
+  QtxAction* anOrthographicAction = dynamic_cast<QtxAction*>( toolMgr()->action( OrthographicId ) );
+  QtxAction* aPerspectiveAction = dynamic_cast<QtxAction*>( toolMgr()->action( PerspectiveId ) );
+#if OCC_VERSION_LARGE > 0x06090000
+  QtxAction* aStereoAction = dynamic_cast<QtxAction*>( toolMgr()->action( StereoId ) );
+#endif
+  if ( mode == Orthographic && !anOrthographicAction->isChecked() ) {
+         anOrthographicAction->setChecked( true );
+    #if OCC_VERSION_LARGE > 0x06090000
+         aStereoAction->setChecked( false );
+    #endif
+  }
+  if ( mode == Perspective && !aPerspectiveAction->isChecked() ) {
+         aPerspectiveAction->setChecked( true );
+    #if OCC_VERSION_LARGE > 0x06090000
+         aStereoAction->setChecked( false );
+    #endif
+  }
+#if OCC_VERSION_LARGE > 0x06090000
+  if ( mode == Stereo ) {
+    aStereoAction->setChecked( true );
+    if ( anOrthographicAction->isEnabled() ) {
+      anOrthographicAction->setEnabled( false );
+      anOrthographicAction->setChecked( false );
+      aStereoAction->setChecked( false );
+    }
+    else {
+      anOrthographicAction->setEnabled( true );
+      aStereoAction->setChecked( false );
+      anOrthographicAction->setChecked(myModel->projectionType() == Orthographic);
+    }
+    if ( aPerspectiveAction->isEnabled() ) {
+      aPerspectiveAction->setEnabled( false );
+      aPerspectiveAction->setChecked( true );
+    #if OCC_VERSION_LARGE > 0x06090000
+      if ( isQuadBufferSupport() && !isOpenGlStereoSupport() && stereoType() == QuadBuffer )
+        SUIT_MessageBox::warning( 0, tr( "WRN_WARNING" ),  tr( "WRN_SUPPORT_QUAD_BUFFER" ) );
+    #endif
+    }
+    else {
+      aPerspectiveAction->setEnabled( true );
+      aStereoAction->setChecked( false );
+      aPerspectiveAction->setChecked(myModel->projectionType() == Perspective);
+      onProjectionType();
+    }
+  }
+  else {
+    if ( !anOrthographicAction->isEnabled() )
+      anOrthographicAction->setEnabled( true );
+    if ( !aPerspectiveAction->isEnabled() )
+      aPerspectiveAction->setEnabled( true );
+  }
+#endif
 }
 
 int OCCViewer_ViewWindow::projectionType() const
@@ -2808,11 +2905,236 @@ 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 OCC_VERSION_LARGE > 0x06090000
+    if (aCamera->ProjectionType() == Graphic3d_Camera::Projection_Stereo)
+      mode = Stereo;
+  #endif
   }
   return mode;
 }
 
+void OCCViewer_ViewWindow::setStereoType( int type )
+{
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) {
+  #if OCC_VERSION_LARGE > 0x06090000
+    Graphic3d_RenderingParams* aParams = &aView3d->ChangeRenderingParams();
+    aParams->StereoMode = (Graphic3d_StereoMode)type;
+  #endif
+  }
+}
+
+int OCCViewer_ViewWindow::stereoType() const
+{
+  int type = QuadBuffer;
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) {
+  #if OCC_VERSION_LARGE > 0x06090000
+    Graphic3d_RenderingParams* aParams = &aView3d->ChangeRenderingParams();
+    type = (OCCViewer_ViewWindow::StereoType)aParams->StereoMode;
+  #endif
+  }
+  return type;
+}
+
+void OCCViewer_ViewWindow::setAnaglyphFilter( int type )
+{
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) {
+  #if OCC_VERSION_LARGE > 0x06090000
+    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;
+  #endif
+  }
+}
+
+int OCCViewer_ViewWindow::anaglyphFilter() const
+{
+  int type = RedCyan;
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) {
+  #if OCC_VERSION_LARGE > 0x06090000
+    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;
+  #endif
+  }
+  return type;
+}
+
+void OCCViewer_ViewWindow::setStereographicFocus( int type, double value )
+{
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) {
+  #if OCC_VERSION_LARGE > 0x06090000
+    Handle(Graphic3d_Camera) aCamera = aView3d->Camera();
+    aCamera->SetZFocus( (Graphic3d_Camera::FocusType) type, value );
+  #endif
+  }
+}
+
+int OCCViewer_ViewWindow::stereographicFocusType() const
+{
+  int type = Relative;
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) {
+  #if OCC_VERSION_LARGE > 0x06090000
+    Handle(Graphic3d_Camera) aCamera = aView3d->Camera();
+    type = (OCCViewer_ViewWindow::FocusIODType)aCamera->ZFocusType();
+  #endif
+  }
+  return type;
+}
+
+double OCCViewer_ViewWindow::stereographicFocusValue() const
+{
+  double value = 1.0;
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) {
+  #if OCC_VERSION_LARGE > 0x06090000
+    Handle(Graphic3d_Camera) aCamera = aView3d->Camera();
+    value = aCamera->ZFocus();
+  #endif
+  }
+  return value;
+}
+
+void OCCViewer_ViewWindow::setInterocularDistance( int type, double value )
+{
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) {
+  #if OCC_VERSION_LARGE > 0x06090000
+    Handle(Graphic3d_Camera) aCamera = aView3d->Camera();
+    aCamera->SetIOD( (Graphic3d_Camera::IODType) type, value );
+  #endif
+  }
+}
+
+int OCCViewer_ViewWindow::interocularDistanceType() const
+{
+  int type = Relative;
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) {
+  #if OCC_VERSION_LARGE > 0x06090000
+    Handle(Graphic3d_Camera) aCamera = aView3d->Camera();
+    type = (OCCViewer_ViewWindow::FocusIODType)aCamera->GetIODType();
+  #endif
+  }
+  return type;
+}
+
+double OCCViewer_ViewWindow::interocularDistanceValue() const
+{
+  double value = 0.05;
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) {
+  #if OCC_VERSION_LARGE > 0x06090000
+    Handle(Graphic3d_Camera) aCamera = aView3d->Camera();
+    value = aCamera->IOD();
+  #endif
+  }
+  return value;
+}
+
+void OCCViewer_ViewWindow::setReverseStereo( bool reverse )
+{
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) {
+  #if OCC_VERSION_LARGE > 0x06090000
+    Graphic3d_RenderingParams* aParams = &aView3d->ChangeRenderingParams();
+    aParams->ToReverseStereo = reverse;
+  #endif
+  }
+}
+
+bool OCCViewer_ViewWindow::isReverseStereo() const
+{
+  int reverse = false;
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) {
+  #if OCC_VERSION_LARGE > 0x06090000
+    Graphic3d_RenderingParams* aParams = &aView3d->ChangeRenderingParams();
+    reverse = aParams->ToReverseStereo;
+  #endif
+  }
+  return reverse;
+}
+
+void OCCViewer_ViewWindow::setVSync( bool enable )
+{
+  Handle(AIS_InteractiveContext) anIntCont = myModel->getAISContext();
+  if ( !anIntCont.IsNull() ) {
+  #if OCC_VERSION_LARGE > 0x06090000
+    Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast(anIntCont->CurrentViewer()->Driver());
+    OpenGl_Caps* aCaps = &aDriver->ChangeOptions();
+    aCaps->swapInterval = enable;
+  #endif
+  }
+}
+
+bool OCCViewer_ViewWindow::isVSync() const
+{
+  int enable = true;
+  Handle(AIS_InteractiveContext) anIntCont = myModel->getAISContext();
+  if ( !anIntCont.IsNull() ) {
+  #if OCC_VERSION_LARGE > 0x06090000
+    Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast(anIntCont->CurrentViewer()->Driver());
+    OpenGl_Caps* aCaps = &aDriver->ChangeOptions();
+    enable = aCaps->swapInterval;
+  #endif
+  }
+  return enable;
+}
+
+void OCCViewer_ViewWindow::setQuadBufferSupport( bool enable )
+{
+  Handle(AIS_InteractiveContext) anIntCont = myModel->getAISContext();
+  if ( !anIntCont.IsNull() ) {
+  #if OCC_VERSION_LARGE > 0x06090000
+    Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast(anIntCont->CurrentViewer()->Driver());
+    OpenGl_Caps* aCaps = &aDriver->ChangeOptions();
+    aCaps->contextStereo = enable;
+  #endif
+  }
+}
+
+bool OCCViewer_ViewWindow::isQuadBufferSupport() const
+{
+  int enable = true;
+  Handle(AIS_InteractiveContext) anIntCont = myModel->getAISContext();
+  if ( !anIntCont.IsNull() ) {
+  #if OCC_VERSION_LARGE > 0x06090000
+    Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast(anIntCont->CurrentViewer()->Driver());
+    OpenGl_Caps* aCaps = &aDriver->ChangeOptions();
+    enable = aCaps->contextStereo;
+  #endif
+  }
+  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
 {
index c0a0237715f49cdcf90942aff477cc060bc035ba..08f4202e36ebe299ccb832e69027767a49de7a94 100755 (executable)
@@ -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;
index 74b1e9f567721636aeb62018a9857232a07b8fcd..ee8fbb6a0ba19d7c6f2f55c704950bb59a671167 100644 (file)
         <source>ICON_OCCVIEWER_PERSPECTIVE</source>
         <translation>occ_view_perspective.png</translation>
     </message>
+    <message>
+        <source>ICON_OCCVIEWER_STEREO</source>
+        <translation>occ_view_stereo.png</translation>
+    </message>
 </context>
 </TS>
index a533aa166029cf35c03e76e106e559c03cf414ef..5c993519b32c53b3f1b022e3254f9d779cf588da 100644 (file)
         <source>DSC_PERSPECTIVE_MODE</source>
         <translation>Set the perspective projection type</translation>
     </message>
+    <message>
+        <source>MNU_STEREO_MODE</source>
+        <translation>Stereo projection</translation>
+    </message>
+    <message>
+        <source>DSC_STEREO_MODE</source>
+        <translation>Set the stereo projection type</translation>
+    </message>
+    <message>
+        <source>WRN_SUPPORT_QUAD_BUFFER</source>
+        <translation>Graphic driver not support quad-buffer</translation>
+    </message>
 </context>
 <context>
     <name>OCCViewer_CreateRestoreViewDlg</name>
         <source>BG_IMAGE_FILES</source>
         <translation>Image files (*.bmp *.gif *.pix *.xwd *.rgb *.rs)</translation>
     </message>
+    <message>
+        <source>ST_QUADBUFFER</source>
+        <translation>Shutter glasses (OpenGL quad-buffer)</translation>
+    </message>
+    <message>
+        <source>ST_ANAGLYPH</source>
+        <translation>Anaglyph</translation>
+    </message>
+    <message>
+        <source>ST_ROWINTERLACED</source>
+        <translation>Row-interlaced</translation>
+    </message>
+    <message>
+        <source>ST_COLUMNINTERLACED</source>
+        <translation>Column-interlaced</translation>
+    </message>
+    <message>
+        <source>ST_CHESSBOARD</source>
+        <translation>Chess-board stereo for DLP TVs</translation>
+    </message>
+    <message>
+        <source>ST_SIDEBYSIDE</source>
+        <translation>Horizontal-anamorphic (side-by-side)</translation>
+    </message>
+    <message>
+        <source>ST_OVERUNDER</source>
+        <translation>Vertical-anamorphic (Half OverUnder)</translation>
+    </message>
 </context>
 <context>
     <name>OCCViewer_AxialScaleDlg</name>
index 87e685c0214a1493852da8a1258399f16b7d8f41..df2e06769ed87ff7b6520875ca9a1a792c010dd1 100755 (executable)
         <source>DSC_PERSPECTIVE_MODE</source>
         <translation>Choisir la projection en perspective</translation>
     </message>
+    <message>
+        <source>MNU_STEREO_MODE</source>
+        <translation type="unfinished">Stereo projection</translation>
+    </message>
+    <message>
+        <source>DSC_STEREO_MODE</source>
+        <translation type="unfinished">Set the stereo projection type</translation>
+    </message>
+    <message>
+        <source>WRN_SUPPORT_QUAD_BUFFER</source>
+        <translation type="unfinished">Graphic driver not support quad-buffer</translation>
+    </message>
 </context>
 <context>
     <name>OCCViewer_CreateRestoreViewDlg</name>
         <source>BG_IMAGE_FILES</source>
         <translation>Fichiers images (*.bmp *.gif *.pix *.xwd *.rgb *.rs)</translation>
     </message>
+    <message>
+        <source>ST_QUADBUFFER</source>
+        <translation type="unfinished">Shutter glasses (OpenGL quad-buffer)</translation>
+    </message>
+    <message>
+        <source>ST_ANAGLYPH</source>
+        <translation type="unfinished">Anaglyph</translation>
+    </message>
+    <message>
+        <source>ST_ROWINTERLACED</source>
+        <translation type="unfinished">Row-interlaced</translation>
+    </message>
+    <message>
+        <source>ST_COLUMNINTERLACED</source>
+        <translation type="unfinished">Column-interlaced</translation>
+    </message>
+    <message>
+        <source>ST_CHESSBOARD</source>
+        <translation type="unfinished">Chess-board stereo for DLP TVs</translation>
+    </message>
+    <message>
+        <source>ST_SIDEBYSIDE</source>
+        <translation type="unfinished">Horizontal-anamorphic (side-by-side)</translation>
+    </message>
+    <message>
+        <source>ST_OVERUNDER</source>
+        <translation type="unfinished">Vertical-anamorphic (Half OverUnder)</translation>
+    </message>
 </context>
 <context>
     <name>OCCViewer_AxialScaleDlg</name>
index f88b6b5dabe018025239abd7c8366faca1e72258..c05ea384d9e68e86657b69aec033db441ca83a8a 100644 (file)
       <source>DSC_PERSPECTIVE_MODE</source>
       <translation>透視投影を選択します。</translation>
     </message>
+    <message>
+      <source>MNU_STEREO_MODE</source>
+      <translation type="unfinished">Stereo projection</translation>
+    </message>
+    <message>
+      <source>DSC_STEREO_MODE</source>
+      <translation type="unfinished">Set the stereo projection type</translation>
+    </message>
+    <message>
+      <source>WRN_SUPPORT_QUAD_BUFFER</source>
+      <translation type="unfinished">Graphic driver not support quad-buffer</translation>
+    </message>
   </context>
   <context>
     <name>OCCViewer_CreateRestoreViewDlg</name>
       <source>BG_IMAGE_FILES</source>
       <translation>イメージ ファイル (*.bmp *.gif *.pix *.xwd *.rgb * .rs)</translation>
     </message>
+    <message>
+      <source>ST_QUADBUFFER</source>
+      <translation type="unfinished">Shutter glasses (OpenGL quad-buffer)</translation>
+    </message>
+    <message>
+      <source>ST_ANAGLYPH</source>
+      <translation type="unfinished">Anaglyph</translation>
+    </message>
+    <message>
+      <source>ST_ROWINTERLACED</source>
+      <translation type="unfinished">Row-interlaced</translation>
+    </message>
+    <message>
+      <source>ST_COLUMNINTERLACED</source>
+      <translation type="unfinished">Column-interlaced</translation>
+    </message>
+    <message>
+      <source>ST_CHESSBOARD</source>
+      <translation type="unfinished">Chess-board stereo for DLP TVs</translation>
+    </message>
+    <message>
+      <source>ST_SIDEBYSIDE</source>
+      <translation type="unfinished">Horizontal-anamorphic (side-by-side)</translation>
+    </message>
+    <message>
+      <source>ST_OVERUNDER</source>
+      <translation type="unfinished">Vertical-anamorphic (Half OverUnder)</translation>
+    </message>
   </context>
   <context>
     <name>OCCViewer_AxialScaleDlg</name>
diff --git a/src/OCCViewer/resources/occ_view_stereo.png b/src/OCCViewer/resources/occ_view_stereo.png
new file mode 100644 (file)
index 0000000..218a2a6
Binary files /dev/null and b/src/OCCViewer/resources/occ_view_stereo.png differ
index 3b147fc676d35e2831d82cf11f55d77c00c3dec4..a4df0a7c3ae87ae80f2753a36942249da2965ce1 100755 (executable)
@@ -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
   };
index cd8944258b9ee22fbdf540290929486430533c4a..6721d6d8a65ac8116cecf7dfa9fcbd684e727623 100644 (file)
@@ -3190,21 +3190,89 @@ bool QtxWorkstack::opaqueResize() const
 }
 
 /*!
-  \brief Show/Hide active tab bar.
+  \brief Show/hide splitter state and area.
+  \param wid widget (and parent area) will be shown/hidden
+  \param parent_list parent splitters list
+  \param split splitter will be shown/hidden
+  \param visible splitter
 */
-void QtxWorkstack::showActiveTabBar( bool visible )
+void QtxWorkstack::splitterVisible(QWidget* wid, QList<QSplitter*>& parent_list, QSplitter* split, bool visible)
 {
+  QList<QSplitter*> recList;
+  splitters( split, recList, false );
+  for ( QList<QSplitter*>::iterator itr = recList.begin(); itr != recList.end(); ++itr ) {
+    parent_list.prepend( *itr );
+    splitterVisible( wid, parent_list, *itr, visible );
+  }
+
   QList<QtxWorkstackArea*> areaList;
-  areas( mySplit, areaList, true );
-  QList<QtxWorkstackArea*>::ConstIterator it;
-  for ( it = areaList.begin(); it != areaList.end(); ++it )
-  {
-    (*it)->showTabBar( visible );
+  areas( split, areaList, false );
+  for ( QList<QtxWorkstackArea*>::const_iterator it = areaList.begin(); it != areaList.end(); ++it ) {
+    QtxWorkstackArea* area = *it;
+    bool isCurrentWidget = false;
+
+    area->showTabBar(visible);
+
+    // 1. Looking for the selected widget at the lowest level among all splitted areas.
+    QList<QtxWorkstackChild*> childList = area->childList();
+    for ( QList<QtxWorkstackChild*>::iterator itr = childList.begin(); itr != childList.end(); ++itr ) {
+      QWidget* aCurWid = (*itr)->widget();
+      if ( aCurWid == wid ) {
+        isCurrentWidget = true;
+        aCurWid->setVisible( true );
+      }
+      else
+        aCurWid->setVisible( visible );
+    }
+
+    // 2. Show/Hide other areas and widgets that don't contain the desired widget
+    if ( !isCurrentWidget || visible )
+      area->setVisible( visible );
+
+    if ( !isCurrentWidget && !visible )
+      continue;
+
+    // 3. Show/hide all parent widgets
+    QSplitter* pSplit = splitter( area );
+    int count = pSplit->count();
+    for ( int i = 0; i < count; i++ ) {
+      if ( pSplit->indexOf( area ) == i && !visible )
+        continue;
+      pSplit->widget(i)->setVisible( visible );
+    }
+
+    // 4. Show/hide all parent splitters don't contain the selected widget
+    if ( visible )
+      pSplit->setVisible( true );
+
+    if ( isCurrentWidget && !visible ) {
+      for ( QList<QSplitter*>::iterator itr = parent_list.begin(); itr != parent_list.end() && pSplit != mySplit; ++itr ) {
+        if ( pSplit == *itr )
+          continue;
+        QList<QSplitter*> splitList;
+        splitters( *itr, splitList, false );
+        for ( QList<QSplitter*>::iterator iter = splitList.begin(); iter != splitList.end(); ++iter ) {
+          if ( pSplit == (*iter) ) {
+            pSplit = *itr;
+            continue;
+          }
+          (*iter)->setVisible( false );
+        }
+      }
+    }
   }
-  QList<QSplitter*> recList;
-  splitters( mySplit, recList, true );
-  for ( QList<QSplitter*>::iterator itr = recList.begin(); itr != recList.end(); ++itr )
-    (*itr)->setVisible(visible);
+}
+
+/*!
+  \brief Show/hide splitters state and area.
+  \param wid widget (and parent area) will be shown/hidden
+  \param visible splitters
+*/
+void QtxWorkstack::splittersVisible( QWidget* wid, bool visible )
+{
+  QList<QSplitter*> parent_list;
+  parent_list.append( mySplit );
+  splitterVisible( wid, parent_list, mySplit, visible );
 }
 
 /*!
index 6d8e89bd2d21881c0e3bbf26dba8ebefc275e8c9..25be96a431624458c75c953f1b7e041fe3df275b 100644 (file)
@@ -116,13 +116,15 @@ public:
   void                setOpaqueResize( bool = true );
   bool                opaqueResize() const;
 
-  void                showActiveTabBar( bool = true );
+  void                splittersVisible( QWidget*, bool = true );
 
   void Split( QWidget* wid, const Qt::Orientation o, const SplitType type );
   void Attract( QWidget* wid1, QWidget* wid2, const bool all );
   void SetRelativePosition( QWidget* wid, const Qt::Orientation o, const double pos );
   void SetRelativePositionInSplitter( QWidget* wid, const double pos );
 
+  void                updateState();
+
 signals:
   void                windowActivated( QWidget* );
 
@@ -166,9 +168,10 @@ private:
 
   QtxWorkstackArea*   createArea( QWidget* ) const;
 
-  void                updateState();
   void                updateState( QSplitter* );
 
+  void                splitterVisible(QWidget*, QList<QSplitter*>&, QSplitter*, bool );
+
   void                distributeSpace( QSplitter* ) const;
 
   int                 setPosition( QWidget* wid, QSplitter* split, const Qt::Orientation o,
index 00f89a799be913872a2bc96853a8d2df5c514b47..811be3e9a838949bf08e2b9e97d7e4a1baab0b53 100755 (executable)
@@ -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
 */
index 917c3872b27d916157f2e5f662bf965fb9b1b260..542b160bb3ea05dd37575dd3c43c4fb0f312dc2c 100755 (executable)
@@ -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;
index e0cbd04a03f8daf457007c40c9b420ff71554576..96bc10f3dbd6b3ed71324b679710474d20850fc2 100755 (executable)
@@ -84,6 +84,9 @@ bool SUIT_Desktop::event( QEvent* e )
   case QEvent::WindowDeactivate:
     emit deactivated();
     break;
+ /*case QEvent::Move:
+    emit moved();
+    break;*/
   default:
     break;
   }
index c1f62e4d7087653089ee1b0b2a27783b33f83ae9..8a0a17e53ccb0476f604b92cfeac6cf1764d03e1 100755 (executable)
@@ -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& );