Salome HOME
Merge branch 'master' of https://git.salome-platform.org/git/modules/gui
[modules/gui.git] / src / OCCViewer / OCCViewer_ViewWindow.cxx
index 7ceb65ef17e9c7ba92884ed0f2e834e0d3fae052..a0e96792bba525452df09cffa38363629dd3dc4c 100755 (executable)
@@ -243,6 +243,7 @@ OCCViewer_ViewWindow::OCCViewer_ViewWindow( SUIT_Desktop*     theDesktop,
   myModel = theModel;
   myRestoreFlag = 0;
   myEnableDrawMode = false;
+  myDrawRectEnabled = true;
   myDrawRect=false;
   updateEnabledDrawMode();
   myScalingDlg = 0;
@@ -385,7 +386,9 @@ bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e )
               ic->HilightPreviousDetected( myViewPort->getView() );
             }
           }
-        } else {
+        }
+        else {
+          emit vpTransformationStarted ( ZOOMVIEW );
           myViewPort->startZoomAtPoint( aEvent->x(), aEvent->y() );
           double delta = (double)( aEvent->delta() ) / ( 15 * 8 );
           int x  = aEvent->x();
@@ -394,6 +397,7 @@ bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e )
           int y1 = (int)( aEvent->y() + height()*delta/100 );
           myViewPort->zoom( x, y, x1, y1 );
           myViewPort->getView()->ZFitAll();
+          emit vpTransformationFinished ( ZOOMVIEW );
         }
       }
       return true;
@@ -417,13 +421,25 @@ bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e )
   return SUIT_ViewWindow::eventFilter(watched, e);
 }
 
+/*!
+  \brief Enable / disable draw rect (rubber band) mode
+*/
+bool OCCViewer_ViewWindow::enableDrawMode( bool on )
+{
+  bool prev = myDrawRectEnabled;
+  myDrawRectEnabled = on;
+  updateEnabledDrawMode();
+  return prev;
+}
+
 /*!
   \brief Update state of enable draw mode state.
 */
 void OCCViewer_ViewWindow::updateEnabledDrawMode()
 {
+  myEnableDrawMode = myDrawRectEnabled;
   if ( myModel )
-    myEnableDrawMode = myModel->isSelectionEnabled() && myModel->isMultiSelectionEnabled();
+    myEnableDrawMode = myEnableDrawMode && myModel->isSelectionEnabled() && myModel->isMultiSelectionEnabled();
 }
 
 /*!
@@ -562,7 +578,7 @@ void OCCViewer_ViewWindow::vpMousePressEvent( QMouseEvent* theEvent )
     }
     /* notify that we start a transformation */
     if ( transformRequested() )
-            emit vpTransformationStarted ( myOperation );
+      emit vpTransformationStarted ( myOperation );
   }
   if ( transformRequested() )
     setTransformInProcess( true );
@@ -671,9 +687,8 @@ bool OCCViewer_ViewWindow::computeGravityCenter( double& theX, double& theY, dou
 
   for( ; aStructureIt.More(); aStructureIt.Next() ) {
     const Handle(Graphic3d_Structure)& aStructure = aStructureIt.Key();
-    if ( aStructure->IsEmpty() ) {
+    if ( aStructure->IsEmpty() || !aStructure->IsVisible() || aStructure->CStructure()->IsForHighlight )
       continue;
-    }
 
 #if OCC_VERSION_LARGE > 0x06070100
     Bnd_Box aBox = aStructure->MinMaxValues();
@@ -1497,7 +1512,9 @@ void OCCViewer_ViewWindow::createToolBar()
 
     toolMgr()->append( OrthographicId, tid );
     toolMgr()->append( PerspectiveId, tid );
+#if OCC_VERSION_LARGE > 0x06090000
     toolMgr()->append( StereoId, tid );
+#endif
 
     toolMgr()->append( ResetId, tid );
   }
@@ -1650,13 +1667,19 @@ void OCCViewer_ViewWindow::onProjectionType( QAction* theAction )
     if (theAction == toolMgr()->action( OrthographicId )) {
       myModel->setProjectionType(Orthographic);
       aCamera->SetProjectionType ( Graphic3d_Camera::Projection_Orthographic );
+      aCamera->SetFOVy(45.0);
     }
     else if (theAction == toolMgr()->action( PerspectiveId )) {
       myModel->setProjectionType(Perspective);
       aCamera->SetProjectionType ( Graphic3d_Camera::Projection_Perspective );
+      aCamera->SetFOVy(30.0);
     }
-    if (toolMgr()->action( StereoId )->isChecked())
+#if OCC_VERSION_LARGE > 0x06090000
+    if (toolMgr()->action( StereoId )->isChecked()) {
       aCamera->SetProjectionType ( Graphic3d_Camera::Projection_Stereo );
+      aCamera->SetFOVy(30.0);
+    }
+#endif
     aView3d->Redraw();
     onViewFitAll();
   }
@@ -1701,7 +1724,8 @@ void OCCViewer_ViewWindow::onStereoType( bool activate )
     onViewFitAll();
   }
 
-  if ( isQuadBufferSupport() && !isOpenGlStereoSupport() && stereoType() == QuadBuffer )
+  if ( isQuadBufferSupport() && !isOpenGlStereoSupport() && stereoType() == QuadBuffer &&
+       toolMgr()->action( StereoId )->isChecked() )
     SUIT_MessageBox::warning( 0, tr( "WRN_WARNING" ),  tr( "WRN_SUPPORT_QUAD_BUFFER" ) );
 #endif
 }
@@ -1772,7 +1796,8 @@ void OCCViewer_ViewWindow::setProjectionType( int mode )
     if ( aPerspectiveAction->isEnabled() ) {
       aPerspectiveAction->setEnabled( false );
       aPerspectiveAction->setChecked( true );
-      if ( isQuadBufferSupport() && !isOpenGlStereoSupport() && stereoType() == QuadBuffer )
+      if ( isQuadBufferSupport() && !isOpenGlStereoSupport() && stereoType() == QuadBuffer &&
+           toolMgr()->action( StereoId )->isChecked() )
         SUIT_MessageBox::warning( 0, tr( "WRN_WARNING" ),  tr( "WRN_SUPPORT_QUAD_BUFFER" ) );
     }
     else {