Salome HOME
Merge remote-tracking branch 'origin/pre/V8_3_BR' into hydro/imps_2017_salome_83
[modules/gui.git] / src / OCCViewer / OCCViewer_ViewWindow.cxx
index 5f7c09b9c84e04147a3fa60fbeea4a8e08a41375..cfeb79fb49f605a791e11bdaf7784d9edb151968 100644 (file)
@@ -115,7 +115,11 @@ static QEvent* l_mbPressEvent = 0;
 //# include <QWindowsStyle>
 //#endif
 
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
 #include <GL/gl.h>
+#endif
 
 // To avoid conflict between KeyPress from the X.h (define KeyPress 2)
 // and QEvent::KeyPress (qevent.h)
@@ -272,6 +276,7 @@ OCCViewer_ViewWindow::OCCViewer_ViewWindow( SUIT_Desktop*     theDesktop,
   mySelectionEnabled = true;
 
   myCursorIsHand = false;
+  myPanningByBtn = false;
 
   clearViewAspects();
 }
@@ -406,7 +411,9 @@ bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e )
           int x1 = (int)( aEvent->x() + width()*delta/100 );
           int y1 = (int)( aEvent->y() + height()*delta/100 );
           myViewPort->zoom( x, y, x1, y1 );
+#if OCC_VERSION_LARGE <= 0x07000000
           myViewPort->getView()->ZFitAll();
+#endif
           emit vpTransformationFinished ( ZOOMVIEW );
         }
       }
@@ -536,7 +543,7 @@ void OCCViewer_ViewWindow::vpMousePressEvent( QMouseEvent* theEvent )
         if ( theEvent->button() == Qt::LeftButton )
         {
           Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
-          ic->Select();
+          ic->Select( Standard_True );
           for ( ic->InitSelected(); ic->MoreSelected(); ic->NextSelected() )
           {
             TopoDS_Shape aShape = ic->SelectedShape();
@@ -575,7 +582,7 @@ void OCCViewer_ViewWindow::vpMousePressEvent( QMouseEvent* theEvent )
           }
           if ( ic->NbSelected() == 0 ) myCurrPointType = myPrevPointType;
           if ( mySetRotationPointDlg ) mySetRotationPointDlg->toggleChange();
-          ic->CloseAllContexts();
+          ic->CloseAllContexts( Standard_True );
           myOperation = NOTHING;
           myViewPort->setCursor( myCursor );
           myCursorIsHand = false;
@@ -619,6 +626,12 @@ void OCCViewer_ViewWindow::activateZoom()
 }
 
 
+void OCCViewer_ViewWindow::onPanning()
+{
+  myPanningByBtn = true;
+  activatePanning();
+}
+
 /*!
   \brief Start panning operation.
 
@@ -770,7 +783,7 @@ void OCCViewer_ViewWindow::activateSetRotationGravity()
   if ( myRotationPointSelection )
   {
     Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
-    ic->CloseAllContexts();
+    ic->CloseAllContexts( Standard_True );
     myOperation = NOTHING;
     myViewPort->setCursor( myCursor );
     myCursorIsHand = false;
@@ -810,7 +823,7 @@ void OCCViewer_ViewWindow::activateSetRotationSelected( double theX, double theY
   if ( myRotationPointSelection )
   {
     Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
-    ic->CloseAllContexts();
+    ic->CloseAllContexts( Standard_True );
     myOperation = NOTHING;
     myViewPort->setCursor( myCursor );
     myCursorIsHand = false;
@@ -1060,9 +1073,17 @@ void OCCViewer_ViewWindow::vpMouseReleaseEvent(QMouseEvent* theEvent)
 
   case PANVIEW:
   case ZOOMVIEW:
+#if OCC_VERSION_LARGE <= 0x07000000
     myViewPort->getView()->ZFitAll();
-    resetState();
-    break;
+#endif
+    {
+      OCCViewer_ViewManager* aMgr = dynamic_cast<OCCViewer_ViewManager*>( getViewManager() );
+      bool isChained = aMgr->isChainedOperations();
+      bool isReset = !( myOperation==PANVIEW && myPanningByBtn && isChained ) || theEvent->button() == Qt::RightButton;
+      if( isReset )
+        resetState();
+      break;
+    }
 
   case PANGLOBAL:
     if ( theEvent->button() == Qt::LeftButton ) {
@@ -1228,7 +1249,7 @@ void OCCViewer_ViewWindow::createActions()
   aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_PAN" ) ),
                            tr( "MNU_PAN_VIEW" ), 0, this);
   aAction->setStatusTip(tr("DSC_PAN_VIEW"));
-  connect(aAction, SIGNAL(triggered()), this, SLOT(activatePanning()));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onPanning()));
   toolMgr()->registerAction( aAction, PanId );
 
   // Global Panning
@@ -2329,10 +2350,15 @@ void OCCViewer_ViewWindow::setCuttingPlane( bool on, const double x,  const doub
     gp_Pln pln (gp_Pnt(x, y, z), gp_Dir(dx, dy, dz));
     double a, b, c, d;
     pln.Coefficients(a, b, c, d);
-
+#if OCC_VERSION_LARGE > 0x07000000 
+    Handle(Graphic3d_SequenceOfHClipPlane) aPlanes = view->ClipPlanes();
+    Graphic3d_SequenceOfHClipPlane::Iterator anIter (*aPlanes);
+    if(aPlanes->Size() > 0 ) {
+#else
     Graphic3d_SequenceOfHClipPlane aPlanes = view->GetClipPlanes();
+    Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes);
     if(aPlanes.Size() > 0 ) {
-      Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes);
+#endif
       Handle(Graphic3d_ClipPlane) aClipPlane = anIter.Value();
       aClipPlane->SetEquation(pln);
       aClipPlane->SetOn(Standard_True);
@@ -2341,8 +2367,13 @@ void OCCViewer_ViewWindow::setCuttingPlane( bool on, const double x,  const doub
     }
   }
   else {
+#if OCC_VERSION_LARGE > 0x07000000 
+    Handle(Graphic3d_SequenceOfHClipPlane) aPlanes = view->ClipPlanes();
+    Graphic3d_SequenceOfHClipPlane::Iterator anIter (*aPlanes);
+#else
     Graphic3d_SequenceOfHClipPlane aPlanes = view->GetClipPlanes();
     Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes);
+#endif
     for( ;anIter.More();anIter.Next() ){
       Handle(Graphic3d_ClipPlane) aClipPlane = anIter.Value();
       aClipPlane->SetOn(Standard_False);
@@ -2369,8 +2400,13 @@ bool OCCViewer_ViewWindow::isCuttingPlane()
 {
   Handle(V3d_View) view = myViewPort->getView();
   bool res = false;
-  Graphic3d_SequenceOfHClipPlane aPlanes = view->GetClipPlanes();
-  Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes);
+#if OCC_VERSION_LARGE > 0x07000000 
+  Handle(Graphic3d_SequenceOfHClipPlane) aPlanes = view->ClipPlanes();
+  Graphic3d_SequenceOfHClipPlane::Iterator anIter (*aPlanes);
+#else
+    Graphic3d_SequenceOfHClipPlane aPlanes = view->GetClipPlanes();
+    Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes);
+#endif
   for( ;anIter.More();anIter.Next() ) {
     Handle(Graphic3d_ClipPlane) aClipPlane = anIter.Value();
     if(aClipPlane->IsOn()) {
@@ -3652,8 +3688,9 @@ void OCCViewer_ViewWindow::synchronize( SUIT_ViewWindow* theView )
 #endif
 
   getViewPort()->setAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );
-
+#if OCC_VERSION_LARGE <= 0x07000000
   aDestView->ZFitAll();
+#endif
   aDestView->SetImmediateUpdate( Standard_True );
   aDestView->Redraw();