]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Porting to DEV version of OCCT rnv/occt_8.4.0_dev
authormnt <mnt@opencascade.com>
Tue, 19 Feb 2019 11:43:54 +0000 (14:43 +0300)
committermnt <mnt@opencascade.com>
Tue, 19 Feb 2019 11:43:54 +0000 (14:43 +0300)
src/OCCViewer/OCCViewer_ViewModel.cxx
src/OCCViewer/OCCViewer_ViewModel.h
src/OCCViewer/OCCViewer_ViewWindow.cxx
src/SOCC/SOCC_ViewModel.cxx

index 9de784810e69250fd77e09f0b2327e36216d7cd9..c4906bba93acad2cce756700099801b9d2883aff 100644 (file)
@@ -68,6 +68,8 @@
 #include <V3d_DirectionalLight.hxx>
 #include <V3d_AmbientLight.hxx>
 
+#include <Basics_OCCTVersion.hxx>
+
 /*!
   Get data for supported background modes: gradient types, identifiers and supported image formats
 */
@@ -110,8 +112,10 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron)
   myIsRelative(true),
   myTopLayerId( 0 ),
   myTrihedronSize(100),
-  myClippingDlg (NULL),
-  myIsUseLocalSelection(false)
+#if OCC_VERSION_LARGE <= 0x07030000
+  myIsUseLocalSelection(false),
+#endif
+  myClippingDlg (NULL)
 {
   // init CasCade viewers
   myV3dViewer = OCCViewer_VService::CreateViewer( TCollection_ExtendedString("Viewer3d").ToExtString() );
@@ -353,7 +357,7 @@ void OCCViewer_Viewer::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* t
   bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
   
   if (!aHasShift) {
-    myAISContext->ClearCurrents( false );
+    myAISContext->ClearSelected( false );
     emit deselection();
   }
 
@@ -414,7 +418,7 @@ void OCCViewer_Viewer::onKeyPress(SUIT_ViewWindow* theWindow, QKeyEvent* theEven
   switch ( theEvent->key() ) {
   case  Qt::Key_S:
     if (!aHasShift) {
-      myAISContext->ClearCurrents( false );
+      myAISContext->ClearSelected( false );
       emit deselection();
     }
 
@@ -435,13 +439,17 @@ void OCCViewer_Viewer::onKeyPress(SUIT_ViewWindow* theWindow, QKeyEvent* theEven
     break;
   case  Qt::Key_N:
     if ( isPreselectionEnabled() ) {
+#if OCC_VERSION_LARGE <= 0x07030000
       if ( useLocalSelection() )
+#endif
        getAISContext()->HilightNextDetected( aView->getViewPort()->getView() );
     }
     break;
   case  Qt::Key_P:
     if ( isPreselectionEnabled() ) {
-      if ( getAISContext()->HasOpenedContext() )
+#if OCC_VERSION_LARGE <= 0x07030000
+      if ( useLocalSelection() )
+#endif
        getAISContext()->HilightPreviousDetected( aView->getViewPort()->getView() );
     }
     break;
@@ -882,10 +890,13 @@ void OCCViewer_Viewer::setClippingColor( const QColor& theColor )
   Graphic3d_MaterialAspect aMaterialAspect = Graphic3d_MaterialAspect();
   aMaterialAspect.SetColor( Quantity_Color( theColor.redF(), theColor.greenF(),
                                             theColor.blueF(), Quantity_TOC_RGB ) );
-
+#if OCC_VERSION_LARGE <= 0x07030000
   for( int i = 1; i <= myInternalClipPlanes.Size(); i++ )
     myInternalClipPlanes.Value(i)->SetCappingMaterial( aMaterialAspect );
-
+#else
+  for ( Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt ( myInternalClipPlanes ); aPlaneIt.More(); aPlaneIt.Next() )
+    aPlaneIt.Value()->SetCappingMaterial( aMaterialAspect );
+#endif
   update();
 }
 
@@ -934,9 +945,13 @@ void OCCViewer_Viewer::setClippingTextureParams( const bool isDefault, const QSt
   Handle(Graphic3d_Texture2Dmanual) aTexture =
     initClippingTexture( myDefaultTextureUsed, myClippingTexture,
                          myTextureModulated, myClippingTextureScale );
-
+#if OCC_VERSION_LARGE <= 0x07030000
   for( int i = 1; i <= myInternalClipPlanes.Size(); i++ )
     myInternalClipPlanes.Value(i)->SetCappingTexture( aTexture );
+#else
+  for ( Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt ( myInternalClipPlanes ); aPlaneIt.More(); aPlaneIt.Next() )
+    aPlaneIt.Value()->SetCappingTexture( aTexture );
+#endif
 
   update();
 }
@@ -1115,19 +1130,23 @@ void OCCViewer_Viewer::setDefaultLights()
 bool OCCViewer_Viewer::highlight( const Handle(AIS_InteractiveObject)& obj,
                                   bool hilight, bool update )
 {
-  bool isInLocal = myAISContext->HasOpenedContext();
-  if( !obj.IsNull() )
-    if( !isInLocal )
-    {
-      if ( hilight && !myAISContext->IsSelected( obj ) )
-        myAISContext->AddOrRemoveCurrentObject( obj, false );
-      else if ( !hilight && myAISContext->IsSelected( obj ) )
-        myAISContext->AddOrRemoveCurrentObject( obj, false );
-    }
+  if( !obj.IsNull() ) {
+#if OCC_VERSION_LARGE <= 0x07030000
+    if( !myAISContext->HasOpenedContext() )
+      {
+#endif
+       if ( hilight && !myAISContext->IsSelected( obj ) )
+         myAISContext->AddOrRemoveSelected( obj, false );
+       else if ( !hilight && myAISContext->IsSelected( obj ) )
+         myAISContext->AddOrRemoveSelected( obj, false );
+#if OCC_VERSION_LARGE <= 0x07030000
+      }
+#endif
+  }
 
   if ( update )
     myV3dViewer->Redraw();
-    
+  
   return false;
 }
 
@@ -1137,20 +1156,17 @@ bool OCCViewer_Viewer::highlight( const Handle(AIS_InteractiveObject)& obj,
 */
 bool OCCViewer_Viewer::unHighlightAll( bool updateviewer, bool unselect )
 {
+#if OCC_VERSION_LARGE <= 0x07030000
   if ( myAISContext->HasOpenedContext() ) {
+#endif
     if ( unselect ) {
       myAISContext->ClearSelected( updateviewer );
     } else {
       myAISContext->UnhilightSelected( updateviewer );
     }
-  } else {
-    if ( unselect ) {
-      myAISContext->ClearCurrents( updateviewer );
-    } else {
-      myAISContext->UnhilightCurrents( updateviewer );
-    }
+#if OCC_VERSION_LARGE <= 0x07030000
   }
-
+#endif
   return false;
 }
 
@@ -1358,6 +1374,7 @@ OCCViewer_ViewWindow* OCCViewer_Viewer::createSubWindow()
   return new OCCViewer_ViewWindow(0,  this);
 }
 
+#if OCC_VERSION_LARGE <= 0x07030000
 /*!
   Sets using local selection state
   \param theIsUseLocalSelection - state
@@ -1374,10 +1391,10 @@ bool OCCViewer_Viewer::useLocalSelection() const
 {
   if (myIsUseLocalSelection)
     return true;
-
   Handle(AIS_InteractiveContext) ic = getAISContext();
   return !ic.IsNull() && ic->HasOpenedContext();
 }
+#endif
 
 // obsolete  
 QColor OCCViewer_Viewer::backgroundColor( int theViewId ) const
index 6e80da203a4445d60673929e59faf2369306c6e0..9135fab574de465f165d46b80e4cdb45391dd6e0 100755 (executable)
@@ -40,6 +40,8 @@
 #include <AIS_ListOfInteractive.hxx>
 #include <Graphic3d_SequenceOfHClipPlane.hxx>
 
+#include <Basics_OCCTVersion.hxx>
+
 class QKeyEvent;
 class QMouseEvent;
 
@@ -136,8 +138,10 @@ public:
 
   virtual OCCViewer_ViewWindow*   createSubWindow();
 
+#if OCC_VERSION_LARGE <= 0x07030000
   void                            setUseLocalSelection(bool theIsUseLocalSelection);
   bool                            useLocalSelection() const;
+#endif
 
 public:
   Handle(V3d_Viewer)              getViewer3d()    const { return myV3dViewer;}
@@ -287,7 +291,9 @@ protected:
   QString                         myClippingTexture;
   bool                            myTextureModulated;
   double                          myClippingTextureScale;
+#if OCC_VERSION_LARGE <= 0x07030000
   bool                            myIsUseLocalSelection;
+#endif
 };
 
 #ifdef WIN32
index 7c9cb3e878871201ba6bbf5280d41ae3ca15696e..62ebfdaf9c6169d5f542186890e84080260ed257 100644 (file)
 #include <Graphic3d_ClipPlane.hxx>
 #include <OpenGl_GraphicDriver.hxx>
 #include <OpenGLUtils_FrameBuffer.h>
-
+#include <Basics_OCCTVersion.hxx>
 #include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
 #include <Graphic3d_MapOfStructure.hxx>
 #include <Graphic3d_Structure.hxx>
+#if OCC_VERSION_LARGE <= 0x07030000
 #include <Graphic3d_ExportFormat.hxx>
+#endif
 #include <Graphic3d_StereoMode.hxx>
 #include <Graphic3d_RenderingParams.hxx>
 #include <Graphic3d_BndBox3d.hxx>
@@ -388,7 +390,11 @@ bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e )
 
         if ( aEvent->modifiers().testFlag(Qt::ControlModifier) ) {
           Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
-          if ( isPreselectionEnabled() && myModel->useLocalSelection() ) {
+          if ( isPreselectionEnabled() 
+#if OCC_VERSION_LARGE <= 0x07030000
+              && myModel->useLocalSelection()
+#endif
+            ) {
             if ( aEvent->delta() > 0 ) {
               ic->HilightNextDetected( myViewPort->getView() );
             } else {
@@ -573,7 +579,12 @@ void OCCViewer_ViewWindow::vpMousePressEvent( QMouseEvent* theEvent )
           }
           if ( ic->NbSelected() == 0 ) myCurrPointType = myPrevPointType;
           if ( mySetRotationPointDlg ) mySetRotationPointDlg->toggleChange();
+#if OCC_VERSION_LARGE <= 0x07030000
           ic->CloseAllContexts( Standard_True );
+#else
+         ic->Deactivate();
+         ic->Activate(0);
+#endif
           myOperation = NOTHING;
           myViewPort->setCursor( myCursor );
           myCursorIsHand = false;
@@ -771,7 +782,12 @@ void OCCViewer_ViewWindow::activateSetRotationGravity()
   if ( myRotationPointSelection )
   {
     Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
+#if OCC_VERSION_LARGE <= 0x07030000
     ic->CloseAllContexts( Standard_True );
+#else
+    ic->Deactivate();
+    ic->Activate(0);
+#endif
     myOperation = NOTHING;
     myViewPort->setCursor( myCursor );
     myCursorIsHand = false;
@@ -811,7 +827,12 @@ void OCCViewer_ViewWindow::activateSetRotationSelected( double theX, double theY
   if ( myRotationPointSelection )
   {
     Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
+#if OCC_VERSION_LARGE < 0x07030000
     ic->CloseAllContexts( Standard_True );
+#else
+    ic->Deactivate();
+    ic->Activate(0);
+#endif
     myOperation = NOTHING;
     myViewPort->setCursor( myCursor );
     myCursorIsHand = false;
@@ -833,8 +854,11 @@ void OCCViewer_ViewWindow::activateStartPointSelection( TopAbs_ShapeEnum theShap
 
   // activate selection ------>
   Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
-
+#if OCC_VERSION_LARGE <= 0x07030000
   ic->OpenLocalContext();
+#else
+  ic->Deactivate();
+#endif
 
   AIS_ListOfInteractive aList;
   ic->DisplayedObjects( aList );
@@ -2317,6 +2341,8 @@ bool OCCViewer_ViewWindow::dumpViewToFormat( const QImage& img,
   bool res = false;
   QApplication::setOverrideCursor( Qt::WaitCursor );
 
+  // OCCT version > 7.3.0 is not support export to PS and EPS
+#if OCC_VERSION_LARGE <= 0x07030000
   Handle(Graphic3d_CView) a3dView = myViewPort->getView()->View();
 
   if (format == "PS") {
@@ -2335,9 +2361,12 @@ bool OCCViewer_ViewWindow::dumpViewToFormat( const QImage& img,
     res = a3dView->Export(strdup(qUtf8Printable(fileName)), Graphic3d_EF_EnhPostScript);
     aCaps->ffpEnable = prev;
   }
-  else {
+  else { 
+#endif
     res = myViewPort->getView()->Dump( fileName.toStdString().c_str() );
+#if OCC_VERSION_LARGE <= 0x07030000
   }
+#endif
 
   QApplication::restoreOverrideCursor();
   return res;
@@ -2346,7 +2375,12 @@ bool OCCViewer_ViewWindow::dumpViewToFormat( const QImage& img,
 
 QString OCCViewer_ViewWindow::filter() const
 {
+#if OCC_VERSION_LARGE <= 0x07030000
   return tr( "OCC_IMAGE_FILES" );
+#else
+  QString formats = tr( "OCC_IMAGE_FILES" );
+  return formats.remove(" *.eps *.ps");
+#endif
 }
 
 
index aa9ed64b2ae762a1e6ff5c917690352d20bc55fa..63630df67c01851161897aa34a35019ef0c4f9d0 100755 (executable)
@@ -74,7 +74,9 @@ SOCC_Viewer::~SOCC_Viewer()
 bool SOCC_Viewer::highlight( const Handle(SALOME_InteractiveObject)& obj,
                              bool hilight, bool upd )
 {
+#if OCC_VERSION_LARGE <= 0x07030000
   bool isInLocal = getAISContext()->HasOpenedContext();
+#endif
   //SUIT_Study* ActiveStudy = SUIT_Application::getDesktop()->getActiveStudy();
   //SALOME_Selection* Sel = SALOME_Selection::Selection( ActiveStudy->getSelection() );
 
@@ -89,9 +91,12 @@ bool SOCC_Viewer::highlight( const Handle(SALOME_InteractiveObject)& obj,
 
     if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( obj ) )
     {
+#if OCC_VERSION_LARGE <= 0x07030000
       if ( !isInLocal )
+#endif
           OCCViewer_Viewer::highlight( ite.Value(), hilight, false );
       // highlight sub-shapes only when local selection is active
+#if OCC_VERSION_LARGE <= 0x07030000
       else
       {
         /*if ( ite.Value()->IsKind( STANDARD_TYPE( SALOME_AISShape ) ) )
@@ -102,6 +107,7 @@ bool SOCC_Viewer::highlight( const Handle(SALOME_InteractiveObject)& obj,
           aSh->highlightSubShapes( MapIndex, highlight );
         }*/
       }
+#endif
       break;
     }
   }
@@ -503,10 +509,14 @@ void SOCC_Viewer::LocalSelection( const SALOME_OCCPrs* thePrs, const std::list<i
   
   // Open local context if there is no one
   bool allObjects = thePrs == 0 || thePrs->IsNull();
+#if OCC_VERSION_LARGE <= 0x07030000
   if ( !ic->HasOpenedContext() ) {
     ic->ClearCurrents( false );
     ic->OpenLocalContext( Standard_False, Standard_True, Standard_True );
   }
+#else
+  ic->Deactivate();
+#endif
 
   AIS_ListOfInteractive anObjs;
   // Get objects to be activated
@@ -561,7 +571,12 @@ void SOCC_Viewer::GlobalSelection( const bool update ) const
   Handle(AIS_InteractiveContext) ic = getAISContext();
   if ( !ic.IsNull() )
   {
+#if OCC_VERSION_LARGE <= 0x07030000
     ic->CloseAllContexts( false );
+#else
+    ic->Deactivate();
+    ic->Activate( 0 );
+#endif
     if ( update )
       ic->CurrentViewer()->Redraw();
   }