Salome HOME
Merge with PAL/SALOME 2.1.0d
[modules/kernel.git] / src / TOOLSGUI / ToolsGUI.cxx
index 7e98ad7b18f263ca97ddd501adfec5a1e483795e..eb0b26b8577521f57a2e069f7f18653f175d1084 100644 (file)
 #include "utilities.h"
 
 #include <stdlib.h>
+
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
 using namespace std;
 
+//============================================================================
+// function : runCommand
+// purpose  : Run command
+//============================================================================
 int ToolsGUI::runCommand(string & arg)
 { 
   int res;
-  res = system(arg.c_str());
+  res = system( arg.c_str() );
  
-  if (res == -1)
-    MESSAGE("fork failed (system command result = 0x" << hex << res << ")" << dec
+  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)
-       
+    if ( res == 217 )
+      MESSAGE( "shell exec failed (system command result = 0x" << hex << res << ")" << dec )
   return res;
 }
 
-bool ToolsGUI::OnGUIEvent(int theCommandID,  QAD_Desktop* parent)
+//============================================================================
+// function : OnGUIEvent
+// purpose  : Process events
+//============================================================================
+bool ToolsGUI::OnGUIEvent( int theCommandID,  QAD_Desktop* parent )
 {
-  QAD_Study* myActiveStudy = parent->getActiveStudy();
-  switch (theCommandID)
+  switch ( theCommandID )
+  {
+  case 5102 :
     {
-    case 5102 :
-      {
-       ToolsGUI_CatalogGeneratorDlg* aDlg = new ToolsGUI_CatalogGeneratorDlg(parent);
-       aDlg->exec();
-       delete aDlg;
-       break;
-      }
-
-    default:
-      MESSAGE (" No command associated with this id = " << theCommandID )
+      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)
+  bool OnGUIEvent( int theCommandID, QAD_Desktop* parent )
   {
-    //MESSAGE("ToolsGUI::OnGUIEvent "<< theCommandID);
     return ToolsGUI::OnGUIEvent(theCommandID, parent);
   }
+}
+
+//=======================================================================
+// name    : GetVisibility
+// Purpose : Verify whether object is visible or not
+//=======================================================================
+bool ToolsGUI::GetVisibility( SALOMEDS::Study_var   theStudy,
+                              SALOMEDS::SObject_var theObj,
+                              void*                 theId )
+{
+  SALOMEDS::GenericAttribute_var anAttr;
+  if ( !theObj->_is_nil() && theObj->FindAttribute( anAttr, "AttributeGraphic" ) )
+  {
+    SALOMEDS::AttributeGraphic_var aGraphic =
+      SALOMEDS::AttributeGraphic::_narrow( anAttr );
+    return aGraphic->GetVisibility( (unsigned long)theId );
+  }
 
+  return false;
 }
+
+//=======================================================================
+// name    : SetVisibility
+// Purpose : Set flag visibility of object
+//=======================================================================
+bool ToolsGUI::SetVisibility( SALOMEDS::Study_var theStudy,
+                              const char*         theEntry,
+                              const bool          theValue,
+                              void*               theId )
+{
+  SALOMEDS::SObject_var anObj = theStudy->FindObjectID( theEntry );
+
+  if ( !anObj->_is_nil() )
+  {
+    SALOMEDS::GenericAttribute_var aGAttr;
+    if ( anObj->FindAttribute( aGAttr, "AttributeGraphic" ) )
+    {
+      SALOMEDS::AttributeGraphic_var anAttr = SALOMEDS::AttributeGraphic::_narrow( aGAttr );
+      anAttr->SetVisibility( (unsigned long)theId, theValue );
+    }
+    else if ( theValue )
+    {
+      SALOMEDS::StudyBuilder_var aBuilder = theStudy->NewBuilder();
+      SALOMEDS::AttributeGraphic_var anAttr = SALOMEDS::AttributeGraphic::_narrow(
+        aBuilder->FindOrCreateAttribute( anObj, "AttributeGraphic" ) );
+      anAttr->SetVisibility( (unsigned long)theId, theValue );
+    }
+    return true;
+  }
+
+  return false;
+}
+
+
+
+
+
+