Salome HOME
Copyright update 2022
[modules/geom.git] / src / GEOMToolsGUI / GEOMToolsGUI_1.cxx
index 723dd270d9d154824c3fb9d8ed4fc79acc174572..95086a66061934e0aaaea24cd3d06b28b0c00e09 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2022  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
@@ -160,13 +160,13 @@ void GEOMToolsGUI::OnAutoColor()
   _PTR(Study) aStudy = appStudy->studyDS();
   _PTR(SObject) aMainSObject(aStudy->FindObjectID(anIObject->getEntry()));
   GEOM::GEOM_Object_var aMainObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject));
-  if (CORBA::is_nil(aMainObject)) return;
+  if (CORBA::is_nil(aMainObject) || !GeometryGUI::IsInGeomComponent( aMainSObject )) return;
 
   aMainObject->SetAutoColor( true );
 
   QList<SALOMEDS::Color> aReservedColors;
 
-  GEOM_Displayer displayer ( appStudy );
+  GEOM_Displayer displayer;
 
   SALOME_View* window = displayer.GetActiveView();
   if ( !window ) return;
@@ -229,7 +229,7 @@ void GEOMToolsGUI::OnDisableAutoColor()
   _PTR(Study) aStudy = appStudy->studyDS();
   _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
   GEOM::GEOM_Object_var aMainObject =  GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject));
-  if( CORBA::is_nil( aMainObject ) )
+  if( CORBA::is_nil( aMainObject ) || !GeometryGUI::IsInGeomComponent( aMainSObject ))
     return;
 
   aMainObject->SetAutoColor( false );
@@ -254,7 +254,7 @@ void GEOMToolsGUI::OnColor()
   aSelMgr->selectedObjects( selected );
   if ( selected.IsEmpty() ) return;
 
-  GEOM_Displayer displayer( appStudy );
+  GEOM_Displayer displayer;
 
   // get active view
   SALOME_View* window = displayer.GetActiveView();
@@ -306,7 +306,7 @@ void GEOMToolsGUI::OnTexture()
   aSelMgr->selectedObjects( selected );
   if ( selected.IsEmpty() ) return;
 
-  GEOM_Displayer displayer( appStudy );
+  GEOM_Displayer displayer;
   SALOME_View* window = displayer.GetActiveView();
   if ( !window ) return;
 
@@ -349,7 +349,7 @@ void GEOMToolsGUI::OnChangeTransparency( bool increase )
   aSelMgr->selectedObjects( selected );
   if ( selected.IsEmpty() ) return;
 
-  GEOM_Displayer displayer( appStudy );
+  GEOM_Displayer displayer;
   SALOME_View* window = displayer.GetActiveView();
   if ( !window ) return;
 
@@ -394,7 +394,7 @@ void GEOMToolsGUI::OnNbIsos( ActionType actionType )
   aSelMgr->selectedObjects( selected );
   if ( selected.IsEmpty() ) return;
 
-  GEOM_Displayer displayer( appStudy );
+  GEOM_Displayer displayer;
   SALOME_View* window = displayer.GetActiveView();
   if ( !window ) return;
  
@@ -464,14 +464,14 @@ void GEOMToolsGUI::OnDeflection()
   aSelMgr->selectedObjects( selected );
   if ( selected.IsEmpty() ) return;
 
-  GEOM_Displayer displayer( appStudy );
+  GEOM_Displayer displayer;
   SALOME_View* window = displayer.GetActiveView();
   if ( !window ) return;
 
   int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId();
 
   QVariant v = appStudy->getObjectProperty( aMgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::Deflection ), QVariant() );
-  double aDC =  v.isValid() ? v.toDouble() : SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "deflection_coef", 0.001 );
+  double aDC =  v.isValid() ? v.toDouble() : SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "deflection_coeff", 0.001 );
 
   GEOMToolsGUI_DeflectionDlg * DeflectionDlg = new GEOMToolsGUI_DeflectionDlg
     ( SUIT_Session::session()->activeApplication()->desktop() );
@@ -494,8 +494,7 @@ void GEOMToolsGUI::OnSelectOnly(int mode)
 {
   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
   if ( app ) {
-    SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
-    GEOM_Displayer aDisp (appStudy);
+    GEOM_Displayer aDisp;
     aDisp.GlobalSelection(mode);
     getGeometryGUI()->setLocalSelectionMode(mode);
   }
@@ -608,7 +607,7 @@ void GEOMToolsGUI::OnUnpublishObject() {
             disp->EraseWithChildren(IObject);
             // hide references if any
             std::vector< _PTR(SObject) > vso = aStudy->FindDependances(obj);
-            for ( int i = 0; i < vso.size(); i++ ) {
+            for ( int i = 0; i < (int)vso.size(); i++ ) {
               _PTR(SObject) refObj = vso[i];
               aDrw = B->FindOrCreateAttribute( refObj, "AttributeDrawable" );
               aDrw->SetDrawable( false );
@@ -668,7 +667,7 @@ void GEOMToolsGUI::OnEdgeWidth()
   aSelMgr->selectedObjects( selected );
   if ( selected.IsEmpty() ) return;
 
-  GEOM_Displayer displayer( appStudy );
+  GEOM_Displayer displayer;
 
   SALOME_View* window = displayer.GetActiveView();
   if ( !window ) return;
@@ -711,7 +710,7 @@ void GEOMToolsGUI::OnIsosWidth() {
   aSelMgr->selectedObjects( selected );
   if ( selected.IsEmpty() ) return;
 
-  GEOM_Displayer displayer( appStudy );
+  GEOM_Displayer displayer;
 
   SALOME_View* window = displayer.GetActiveView();
   if ( !window ) return;
@@ -753,7 +752,7 @@ void GEOMToolsGUI::OnBringToFront() {
   aSelMgr->selectedObjects( selected );
   if ( selected.IsEmpty() ) return;
 
-  GEOM_Displayer displayer( appStudy );
+  GEOM_Displayer displayer;
 
   SALOME_View* window = displayer.GetActiveView();
   if ( !window ) return;
@@ -779,7 +778,7 @@ void GEOMToolsGUI::OnClsBringToFront() {
   SalomeApp_Study* appStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
   if ( !appStudy ) return;
 
-  GEOM_Displayer displayer( appStudy );
+  GEOM_Displayer displayer;
 
   SALOME_View* window = displayer.GetActiveView();
   if ( !window ) return;
@@ -818,7 +817,7 @@ void GEOMToolsGUI::OnSetMaterial( const QVariant& theParam )
 
   if ( selected.IsEmpty() ) return;
   
-  GEOM_Displayer displayer( study );
+  GEOM_Displayer displayer;
 
   SALOME_View* window = displayer.GetActiveView();
   if ( !window ) return;
@@ -859,7 +858,7 @@ void GEOMToolsGUI::OnCreateFolder()
   _PTR(SObject) aFatherSO(aStudy->FindObjectID(anIObject->getEntry()));
   if ( !aFatherSO ) return;
 
-  GeometryGUI::GetGeomGen()->CreateFolder( tr("NEW_FOLDER_NAME").toLatin1().constData(), 
+  GeometryGUI::GetGeomGen()->CreateFolder( tr("NEW_FOLDER_NAME").toUtf8().constData(), 
                                            _CAST(SObject, aFatherSO)->GetSObject() );
   app->updateObjectBrowser( false );
 }