Salome HOME
updated copyright message
[modules/gui.git] / src / TOOLSGUI / ToolsGUI.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 4a49254..bdaff1b
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023  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
@@ -25,6 +25,8 @@
 //  Author : Nicolas REJNERI
 //
 #include "ToolsGUI.h"
+#include <SALOMEDSClient_ClientFactory.hxx>
+#include <SALOME_KernelServices.hxx>
 
 /*!
   \class ToolsGUI
 
 /*!
   \brief Get visibility value of the "AttributeGraphic" attribute.
-  \param theStudy study
   \param theObj object
   \param theId sub-object identifier
   \return \c true if an object (sub-object) is visible
 */
-bool ToolsGUI::GetVisibility( _PTR(Study)   theStudy,
-                              _PTR(SObject) theObj,
+bool ToolsGUI::GetVisibility( _PTR(SObject) theObj,
                               void*         theId )
 {
+  // todo: this function seems to be not used
   _PTR(GenericAttribute) anAttr;
   if ( theObj && theObj->FindAttribute( anAttr, "AttributeGraphic" ) )
   {
     _PTR(AttributeGraphic) aGraphic (anAttr);
-    return aGraphic->GetVisibility( (unsigned long)theId );
+    return aGraphic->GetVisibility( int(reinterpret_cast<long long>(theId)) ); // todo: unsafe - converting pointer to int can give non-unique result
   }
 
   return false;
@@ -54,17 +55,17 @@ bool ToolsGUI::GetVisibility( _PTR(Study)   theStudy,
 
 /*!
   \brief Set visibility value of the "AttributeGraphic" attribute.
-  \param theStudy study
   \param theObj object
   \return theValue new visibility value
   \param theId sub-object identifier
 */
-bool ToolsGUI::SetVisibility( _PTR(Study) theStudy,
-                              const char* theEntry,
+bool ToolsGUI::SetVisibility( const char* theEntry,
                               const bool  theValue,
                               void*       theId )
 {
-  _PTR(SObject) anObj ( theStudy->FindObjectID( theEntry ) );
+  // todo: this function seems to be not used
+  _PTR(Study) aStudy = ClientFactory::Study(KERNEL::getStudyServant());
+  _PTR(SObject) anObj ( aStudy->FindObjectID( theEntry ) );
 
   if ( anObj )
   {
@@ -72,13 +73,13 @@ bool ToolsGUI::SetVisibility( _PTR(Study) theStudy,
     if ( anObj->FindAttribute( aGAttr, "AttributeGraphic" ) )
     {
       _PTR(AttributeGraphic) anAttr ( aGAttr );
-      anAttr->SetVisibility( (unsigned long)theId, theValue );
+      anAttr->SetVisibility( int(reinterpret_cast<long long>(theId)), theValue ); // todo: unsafe - converting pointer to int can give non-unique result
     }
     else if ( theValue )
     {
-      _PTR(StudyBuilder) aBuilder (theStudy->NewBuilder());
+      _PTR(StudyBuilder) aBuilder (aStudy->NewBuilder());
       _PTR(AttributeGraphic) anAttr (aBuilder->FindOrCreateAttribute(anObj, "AttributeGraphic"));
-      anAttr->SetVisibility( (unsigned long)theId, theValue );
+      anAttr->SetVisibility( int(reinterpret_cast<long long>(theId)), theValue ); // todo: unsafe - converting pointer to int can give non-unique result
     }
     return true;
   }