Salome HOME
Updated copyright comment
[modules/hexablock.git] / src / HEXABLOCKGUI / HEXABLOCKGUI_SalomeTools.cxx
index e28580f3d31a73e2a560c3b4d5c1226b164fde31..cde214ad1d9c4ebcb6937b325b99911eaf66e359 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2009-2013  CEA/DEN, EDF R&D
+// Copyright (C) 2009-2024  CEA, EDF
 //
 // 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.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 #include <vtkActorCollection.h>
 #include <vtkUnstructuredGrid.h>
 
-
-
 #include <SUIT_Session.h>
 
-#include <SalomeApp_Study.h>
 #include <SalomeApp_Application.h>
 
 #include <OCCViewer_ViewWindow.h>
@@ -89,45 +86,15 @@ namespace GUI
        }
 
 
-       _PTR(Study) GetActiveStudyDocument()
-       {
-               SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(GetActiveStudy());
-               if (aStudy)
-                       return aStudy->studyDS();
-               else
-                       return _PTR(Study)();
-       }
-
-
-       CORBA::Object_var corbaObj( _PTR(SObject) theSO )
-       {
-               CORBA::Object_var aCorbaObj = CORBA::Object::_nil();
-               if ( theSO ) {
-                       std::string aValue = theSO->GetIOR();
-                       if (strcmp(aValue.c_str(), "") != 0) {
-                               CORBA::ORB_ptr anORB = SalomeApp_Application::orb();
-                               aCorbaObj = anORB->string_to_object(aValue.c_str());
-                       }
-               }
-               return aCorbaObj._retn();
-       }
-
-
-       CORBA::Object_var corbaObj( const Handle(SALOME_InteractiveObject)& theIO )
+       _PTR(Study) getStudy()
        {
-               CORBA::Object_var aCorbaObj = CORBA::Object::_nil();
-
-               if ( !theIO.IsNull() && theIO->hasEntry() ){
-                       _PTR(Study)   aStudy = GetActiveStudyDocument();
-                       _PTR(SObject) aSObj  = aStudy->FindObjectID(theIO->getEntry());
-                       aCorbaObj = corbaObj(aSObj);
-               }
-               return aCorbaObj._retn();
+      static _PTR(Study) _study;
+        if(!_study)
+          _study = SalomeApp_Application::getStudy();
+      return _study;
        }
 
 
-
-
        SALOME_Actor* findActorByEntry( SVTK_ViewWindow *theVtkViewWindow, const char* theEntry)
        {
                SALOME_Actor *foundActor = NULL;
@@ -159,17 +126,17 @@ namespace GUI
 
                theName = "";
 
-               TColStd_IndexedMapOfInteger aMapIndex;
+               SVTK_TIndexedMapOfVtkId aMapIndex;
                theSelector->GetIndex(theIO,aMapIndex);
 
                typedef std::set<int> TIdContainer;
 
-               std::set<int> anIdContainer;
+               std::set<vtkIdType> anIdContainer;
 
-               for( int i = 1; i <= aMapIndex.Extent(); i++)
+               for( vtkIdType i = 1; i <= aMapIndex.Extent(); i++)
                        anIdContainer.insert(aMapIndex(i));
 
-               std::set<int>::const_iterator anIter = anIdContainer.begin();
+               std::set<vtkIdType>::const_iterator anIter = anIdContainer.begin();
 
                for( ; anIter != anIdContainer.end(); anIter++)
                        theName += QString(" %1").arg(*anIter);
@@ -202,9 +169,13 @@ namespace GUI
                                continue;
 
                        Handle(SelectMgr_Selection) sel = theObj->Selection( m );
-
-                       for ( sel->Init(); sel->More(); sel->Next() ) {
-                               Handle(SelectBasics_SensitiveEntity) entity = sel->Sensitive();
+                        const NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>& selected = sel->Entities();
+                        for ( NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator selIter( selected );
+                              selIter.More(); selIter.Next() ) {
+                                const Handle(SelectMgr_SensitiveEntity) aHSenEntity = selIter.Value();
+                                if ( aHSenEntity.IsNull() )
+                                        continue;
+                                Handle(SelectBasics_SensitiveEntity) entity = aHSenEntity->BaseSensitive();
                                if ( entity.IsNull() )
                                        continue;