Salome HOME
PAL10810 - "Display", "Erase", "Display only" on root objects
authorasl <asl@opencascade.com>
Wed, 14 Dec 2005 06:42:14 +0000 (06:42 +0000)
committerasl <asl@opencascade.com>
Wed, 14 Dec 2005 06:42:14 +0000 (06:42 +0000)
src/LightApp/LightApp_Selection.cxx
src/SalomeApp/SalomeApp_Module.cxx
src/SalomeApp/SalomeApp_Module.h

index ff39d132d0917626995261c1e61dca5049f1115c..2416983dd07cc26c58a9e6105b3780ac94fc3b65 100644 (file)
@@ -128,6 +128,11 @@ QtxValue LightApp_Selection::param( const int ind, const QString& p ) const
   {
     return myStudy->componentDataType( myEntries[ ind ] );
   }
+  
+  else if( p=="isComponent" )
+  {
+    return QtxValue( myStudy->isComponent( myEntries[ ind ] ), 0 );
+  }
 
   else if( p=="isReference" )
     return QtxValue( isReference( ind ), false );
index b9ef43f9aa8fd580e03ca0fa5a81a5e649945214..9284a579204aae09eaf81fb49d8effd0acea6b1a 100644 (file)
@@ -4,11 +4,11 @@
 // Copyright (C) CEA 2004
 
 #include "SalomeApp_Module.h"
-
 #include "SalomeApp_DataModel.h"
 #include "SalomeApp_Application.h"
-#include "LightApp_Selection.h"
+#include "SalomeApp_Study.h"
 
+#include "LightApp_Selection.h"
 #include "LightApp_Operation.h"
 #include "LightApp_Preferences.h"
 
 
 #include "OB_Browser.h"
 
+#include <SALOME_ListIO.hxx>
+#include <SALOME_ListIteratorOfListIO.hxx>
+#include <SALOME_InteractiveObject.hxx>
+
+#include <SUIT_Session.h>
+
 #include <qstring.h>
 #include <qmap.h>
 
@@ -47,3 +53,47 @@ LightApp_Selection* SalomeApp_Module::createSelection() const
 {
   return LightApp_Module::createSelection();
 }
+
+void SalomeApp_Module::extractContainers( const SALOME_ListIO& source, SALOME_ListIO& dest ) const
+{
+  SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
+  if( !study )
+  {
+    dest = source;
+    return;
+  }
+
+  SALOME_ListIteratorOfListIO anIt( source );
+  for( ; anIt.More(); anIt.Next() )
+  {
+    Handle( SALOME_InteractiveObject ) obj = anIt.Value();
+    if( obj->hasEntry() )
+    {
+      _PTR(SObject) SO = study->studyDS()->FindObjectID( obj->getEntry() );
+      if( SO && QString( SO->GetID().c_str() ) == SO->GetFatherComponent()->GetID().c_str() )
+      { //component is selected
+       _PTR(SComponent) SC( SO->GetFatherComponent() );
+       _PTR(ChildIterator) anIter ( study->studyDS()->NewChildIterator( SC ) );
+       anIter->InitEx( true );
+       while( anIter->More() )
+       {
+         _PTR(SObject) valSO ( anIter->Value() );
+         _PTR(SObject) refSO;
+         if( !valSO->ReferencedObject( refSO ) )
+         {
+           QString id = valSO->GetID().c_str(),
+                   comp = SC->ComponentDataType().c_str(),
+                   val = valSO->GetName().c_str();
+
+           Handle( SALOME_InteractiveObject ) new_obj =
+             new SALOME_InteractiveObject( id.latin1(), comp.latin1(), val.latin1() );
+           dest.Append( new_obj );
+         }
+         anIter->Next();
+       }
+       continue;
+      }
+    }
+    dest.Append( obj );
+  }
+}
index 21d5064a945b04569478161afae669f27a13b091..433d918fd0b9e9e6d542d3e7ba3a461f85985869 100644 (file)
@@ -16,7 +16,7 @@ class CAM_DataModel;
 class SalomeApp_Application;
 class LightApp_Operation;
 class LightApp_Selection;
-
+class SALOME_ListIO;
 class QString;
 
 /*!
@@ -44,7 +44,7 @@ public:
 protected:
   virtual CAM_DataModel*              createDataModel();
   virtual LightApp_Selection*         createSelection() const;
-
+  virtual void                        extractContainers( const SALOME_ListIO&, SALOME_ListIO& ) const;
 };
 
 #endif