Salome HOME
Rewrite local function ModifySurface of BlockFix_SphereSpaceModifier
[modules/geom.git] / src / MeasureGUI / MeasureGUI_ManageDimensionsDlg.cxx
index 9ab9a745009d6ce3ac9715a8e2955efb887dd117..0843b57f5436d81444b69cdeaef192c66df0eb44 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -61,6 +61,8 @@
 #include <QHBoxLayout>
 #include <QPixmap>
 
+#include <Basics_OCCTVersion.hxx>
+
 //=================================================================================
 // function : Constructor
 // purpose  :
@@ -127,7 +129,7 @@ MeasureGUI_ManageDimensionsDlg::MeasureGUI_ManageDimensionsDlg( GeometryGUI* the
   connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( OnDeactivateThisDialog() ) );
   connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ),        this, SLOT( ClickOnCancel() ) );
 
-  myDimensionInteractor = new MeasureGUI_DimensionInteractor( theGUI, theParent ),
+  myDimensionInteractor = new MeasureGUI_DimensionInteractor( theGUI, this ),
 
   SelectionIntoArgument( Selection_Object );
 
@@ -194,10 +196,8 @@ void MeasureGUI_ManageDimensionsDlg::StartSelection( const Selection theSelectio
 
     Handle(AIS_InteractiveContext) anAISContext = myOperatedViewer->getAISContext();
 
-    anAISContext->ClearCurrents( Standard_False );
+    anAISContext->ClearCurrents( Standard_False );  // todo: deprecated OCCT API
     anAISContext->ClearSelected( Standard_False );
-    anAISContext->OpenLocalContext( Standard_True, Standard_False );
-
     Handle(MeasureGUI_DimensionFilter) aFilter = new MeasureGUI_DimensionFilter( myEditObject->GetStudyEntry() );
 
     anAISContext->AddFilter( aFilter );
@@ -242,6 +242,9 @@ void MeasureGUI_ManageDimensionsDlg::StartSelection( const Selection theSelectio
 //=================================================================================
 void MeasureGUI_ManageDimensionsDlg::StopSelection()
 {
+  if( !myGeomGUI || !myGeomGUI->getApp() || !myGeomGUI->getApp()->selectionMgr() )
+    return;
+
   if ( myCurrentSelection == Selection_Object )
   {
     /* -----------------------------------------------  *
@@ -261,8 +264,8 @@ void MeasureGUI_ManageDimensionsDlg::StopSelection()
      * ------------------------------------------------ */
 
     Handle(AIS_InteractiveContext) anAISContext = myOperatedViewer->getAISContext();
-
-    anAISContext->CloseLocalContext();
+    anAISContext->Deactivate();
+    anAISContext->Activate(0);
 
     LightApp_SelectionMgr* aSelectionMgr = myGeomGUI->getApp()->selectionMgr();
 
@@ -355,16 +358,7 @@ void MeasureGUI_ManageDimensionsDlg::SelectionIntoArgument( const Selection theS
     anAISContext->InitSelected();
 
     Handle(AIS_InteractiveObject) anAIS;
-
-    if ( anAISContext->HasOpenedContext() )
-    {
-      Handle(SelectMgr_EntityOwner) anAISOwner = anAISContext->SelectedOwner();
-      anAIS = Handle(AIS_InteractiveObject)::DownCast( anAISOwner->Selectable() );
-    }
-    else
-    {
-      anAIS = anAISContext->Current();
-    }
+    anAIS = anAISContext->Current(); // todo: deprecated OCCT API
 
     int aDimensionId = IdFromPrs( anAIS );
 
@@ -532,7 +526,7 @@ void MeasureGUI_ManageDimensionsDlg::OnSelectItem()
 //=================================================================================
 void MeasureGUI_ManageDimensionsDlg::OnShowAll()
 {
-  // read propety data
+  // read property data
   SalomeApp_Application* anApp = myGeomGUI->getApp();
   if ( !anApp )
   {
@@ -581,7 +575,7 @@ void MeasureGUI_ManageDimensionsDlg::OnShowAll()
 //=================================================================================
 void MeasureGUI_ManageDimensionsDlg::OnHideAll()
 {
-  // read propety data
+  // read property data
   SalomeApp_Application* anApp = myGeomGUI->getApp();
   if ( !anApp )
   {
@@ -1239,17 +1233,7 @@ void MeasureGUI_ManageDimensionsDlg::SelectInViewer( SOCC_Viewer* theViewer, con
   {
     return;
   }
-
-  Standard_Boolean isLocal = anAISContext->HasOpenedContext();
-  if ( isLocal )
-  {
-    anAISContext->ClearSelected( Standard_False );
-  }
-  else
-  {
-    anAISContext->ClearCurrents( Standard_False );
-  }
-
+  anAISContext->ClearCurrents( Standard_False ); // todo: deprecated OCCT API
   SOCC_Prs* aPrs = dynamic_cast<SOCC_Prs*>( theViewer->CreatePrs( myEditObject->GetStudyEntry() ) );
 
   AIS_ListOfInteractive aListOfIO;
@@ -1261,25 +1245,26 @@ void MeasureGUI_ManageDimensionsDlg::SelectInViewer( SOCC_Viewer* theViewer, con
     const Handle(AIS_InteractiveObject)& anIO = anIt.Value();
     if ( IdFromPrs( anIO ) != theId )
     {
-      if ( isLocal )
-      {
-        anAISContext->Deactivate( anIO, AIS_DSM_Line );
-        anAISContext->Deactivate( anIO, AIS_DSM_Text );
-      }
+#if OCC_VERSION_LARGE >= 0x070400ff
+      anAISContext->Deactivate( anIO, PrsDim_DimensionSelectionMode_Line );
+      anAISContext->Deactivate( anIO, PrsDim_DimensionSelectionMode_Text );
+#else
+      anAISContext->Deactivate( anIO, AIS_DSM_Line );
+      anAISContext->Deactivate( anIO, AIS_DSM_Text );
+#endif
       continue;
     }
+    anAISContext->AddOrRemoveSelected( anIO, Standard_False );
 
-    if ( isLocal )
-    {
-      anAISContext->AddOrRemoveSelected( anIO, Standard_False );
-      anAISContext->Activate( anIO, AIS_DSM_Line );
-      anAISContext->Activate( anIO, AIS_DSM_Text );
-    }
-    else
-    {
-      anAISContext->AddOrRemoveCurrentObject( anIO, Standard_False );
-    }
+#if OCC_VERSION_LARGE >= 0x070400ff
+    anAISContext->Activate( anIO, PrsDim_DimensionSelectionMode_Line );
+    anAISContext->Activate( anIO, PrsDim_DimensionSelectionMode_Text );
+#else
+    anAISContext->Activate( anIO, AIS_DSM_Line );
+    anAISContext->Activate( anIO, AIS_DSM_Text );
+#endif
 
+    anAISContext->AddOrRemoveCurrentObject( anIO, Standard_False ); // todo: deprecated OCCT API
     anAISContext->UpdateCurrentViewer();
   }
 }