Salome HOME
updated copyright message
[modules/gui.git] / src / TOOLSGUI / ToolsGUI.cxx
old mode 100755 (executable)
new mode 100644 (file)
index f40970d..bdaff1b
-//  SALOME TOOLSGUI : implementation of desktop "Tools" optioins
+// 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
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
 //
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  This library is free software; you can redistribute it and/or 
-//  modify it under the terms of the GNU Lesser General Public 
-//  License as published by the Free Software Foundation; either 
-//  version 2.1 of the License. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
+//  SALOME TOOLSGUI : implementation of desktop "Tools" optioins
 //  File   : ToolsGUI.cxx
 //  Author : Nicolas REJNERI
-//  Module : SALOME
-//  $Header$
-
+//
 #include "ToolsGUI.h"
-#include "ToolsGUI_CatalogGeneratorDlg.h"
-
-#include "utilities.h"
-
-#include <stdlib.h>
-
-using namespace std;
-
-//============================================================================
-// function : runCommand
-// purpose  : Run command
-//============================================================================
-int ToolsGUI::runCommand(string & arg)
-{ 
-  int res;
-  res = system( arg.c_str() );
-  if ( res == -1 )
-    MESSAGE( "fork failed (system command result = 0x" << hex << res << ")" << dec ) 
-  else
-    if ( res == 217 )
-      MESSAGE( "shell exec failed (system command result = 0x" << hex << res << ")" << dec )
-  return res;
-}
-
-/*
-
-//============================================================================
-// function : OnGUIEvent
-// purpose  : Process events
-//============================================================================
-bool ToolsGUI::OnGUIEvent( int theCommandID,  QAD_Desktop* parent )
-{
-  switch ( theCommandID )
-  {
-  case 5102 :
-    {
-      ToolsGUI_CatalogGeneratorDlg* aDlg = new ToolsGUI_CatalogGeneratorDlg( parent );
-      aDlg->exec();
-      delete aDlg;
-      break;
-    }
-
-  default:
-    MESSAGE ( " No command associated with this id = " << theCommandID )
-    break;
-  }
-  return true;
-}
-
-extern "C"
-{
-  bool OnGUIEvent( int theCommandID, QAD_Desktop* parent )
-  {
-    return ToolsGUI::OnGUIEvent(theCommandID, parent);
-  }
-}
+#include <SALOMEDSClient_ClientFactory.hxx>
+#include <SALOME_KernelServices.hxx>
 
+/*!
+  \class ToolsGUI
+  \brief Utility class.
 */
 
-//=======================================================================
-// name    : GetVisibility
-// Purpose : Verify whether object is visible or not
-//=======================================================================
-bool ToolsGUI::GetVisibility( _PTR(Study)   theStudy,
-                              _PTR(SObject) theObj,
+/*!
+  \brief Get visibility value of the "AttributeGraphic" attribute.
+  \param theObj object
+  \param theId sub-object identifier
+  \return \c true if an object (sub-object) is visible
+*/
+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;
 }
 
-//=======================================================================
-// name    : SetVisibility
-// Purpose : Set flag visibility of object
-//=======================================================================
-bool ToolsGUI::SetVisibility( _PTR(Study) theStudy,
-                              const char* theEntry,
+/*!
+  \brief Set visibility value of the "AttributeGraphic" attribute.
+  \param theObj object
+  \return theValue new visibility value
+  \param theId sub-object identifier
+*/
+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 )
   {
@@ -122,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;
   }
@@ -136,8 +87,3 @@ bool ToolsGUI::SetVisibility( _PTR(Study) theStudy,
   return false;
 }
 
-
-
-
-
-