Salome HOME
Additional fix for the issue "20937: EDF 1399 GEOM: extend the properties of GEOM...
[modules/geom.git] / src / GEOMGUI / GEOMGUI_OCCSelector.cxx
index 6fed25fa8ef00cdaf98e2a3e2e4cfba981fffba5..36a455dcf3904ea7d24ff196aa61c9e15454a254 100644 (file)
@@ -1,4 +1,4 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+//  Copyright (C) 2007-2010  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
@@ -19,6 +19,7 @@
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 // File   : GEOMGUI_OCCSelector.cxx
 // Author : Alexander SOLOVYOV, Open CASCADE S.A.S. (alexander.solovyov@opencascade.com)
 //
@@ -50,7 +51,7 @@
 
 //================================================================
 // Function : GEOMGUI_OCCSelector
-// Purpose  : 
+// Purpose  :
 //================================================================
 GEOMGUI_OCCSelector::GEOMGUI_OCCSelector( OCCViewer_Viewer* viewer, SUIT_SelectionMgr* mgr )
 : LightApp_OCCSelector( viewer, mgr )
@@ -59,7 +60,7 @@ GEOMGUI_OCCSelector::GEOMGUI_OCCSelector( OCCViewer_Viewer* viewer, SUIT_Selecti
 
 //================================================================
 // Function : ~GEOMGUI_OCCSelector
-// Purpose  : 
+// Purpose  :
 //================================================================
 GEOMGUI_OCCSelector::~GEOMGUI_OCCSelector()
 {
@@ -67,7 +68,7 @@ GEOMGUI_OCCSelector::~GEOMGUI_OCCSelector()
 
 //================================================================
 // Function : getSelection
-// Purpose  : 
+// Purpose  :
 //================================================================
 void GEOMGUI_OCCSelector::getSelection( SUIT_DataOwnerPtrList& aList ) const
 {
@@ -113,11 +114,12 @@ void GEOMGUI_OCCSelector::getSelection( SUIT_DataOwnerPtrList& aList ) const
 
       if (!entryStr.isEmpty())
       {
+        Handle(SALOME_InteractiveObject) anIO = Handle(SALOME_InteractiveObject)::DownCast(io->GetOwner()); 
         LightApp_DataOwner* owner;
         if (index > -1) // Local Selection
           owner = new LightApp_DataSubOwner (entryStr, index);
-        else // Global Selection
-          owner = new LightApp_DataOwner (entryStr);
+        else if ( !anIO.IsNull() ) // Global Selection
+          owner = new LightApp_DataOwner( anIO );
 
         aList.append(SUIT_DataOwnerPtr(owner));
       }
@@ -133,8 +135,11 @@ void GEOMGUI_OCCSelector::getSelection( SUIT_DataOwnerPtrList& aList ) const
 
       if ( !entryStr.isEmpty() )
       {
-        LightApp_DataOwner* owner = new LightApp_DataOwner( entryStr );
-        aList.append( SUIT_DataOwnerPtr( owner ) );
+        Handle(SALOME_InteractiveObject) anIO = Handle(SALOME_InteractiveObject)::DownCast(io->GetOwner()); 
+        if ( !anIO.IsNull() ) {
+          LightApp_DataOwner* owner = new LightApp_DataOwner( anIO );
+          aList.append( SUIT_DataOwnerPtr( owner ) );
+        }
       }
     }
   }
@@ -149,11 +154,11 @@ void GEOMGUI_OCCSelector::getSelection( SUIT_DataOwnerPtrList& aList ) const
 
 //================================================================
 // Function : getEntityOwners
-// Purpose  : 
+// Purpose  :
 //================================================================
 static void getEntityOwners( const Handle(AIS_InteractiveObject)& theObj,
-                            const Handle(AIS_InteractiveContext)& theIC,
-                            SelectMgr_IndexedMapOfOwner& theMap )
+                             const Handle(AIS_InteractiveContext)& theIC,
+                             SelectMgr_IndexedMapOfOwner& theMap )
 {
   if ( theObj.IsNull() || theIC.IsNull() )
     return;
@@ -172,19 +177,19 @@ static void getEntityOwners( const Handle(AIS_InteractiveObject)& theObj,
     for ( sel->Init(); sel->More(); sel->Next() ) {
       Handle(SelectBasics_SensitiveEntity) entity = sel->Sensitive();
       if ( entity.IsNull() )
-       continue;
+        continue;
 
       Handle(SelectMgr_EntityOwner) owner =
-       Handle(SelectMgr_EntityOwner)::DownCast(entity->OwnerId());
+        Handle(SelectMgr_EntityOwner)::DownCast(entity->OwnerId());
       if ( !owner.IsNull() )
-       theMap.Add( owner );
+        theMap.Add( owner );
     }
   }
 }
 
 //================================================================
 // Function : setSelection
-// Purpose  : 
+// Purpose  :
 //================================================================
 void GEOMGUI_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList )
 {
@@ -195,11 +200,7 @@ void GEOMGUI_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList )
   Handle(AIS_InteractiveContext) ic = vw->getAISContext();
 
   // "entry - list_of_int" map for LOCAL selection
-#ifndef WNT
   NCollection_DataMap<TCollection_AsciiString, TColStd_IndexedMapOfInteger> indexesMap;
-#else
-  NCollection_DataMap<Standard_CString, TColStd_IndexedMapOfInteger> indexesMap;
-#endif
 
   QMap<QString,int> globalSelMap; // only Key=entry from this map is used.  value(int) is NOT used at all.
   SelectMgr_IndexedMapOfOwner ownersmap; // map of owners to be selected
@@ -215,21 +216,17 @@ void GEOMGUI_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList )
     if ( subOwner )
     {
       QString entry = subOwner->entry();
-#ifndef WNT
       if ( indexesMap.IsBound( TCollection_AsciiString(entry.toLatin1().data())))
-#else
-      if ( indexesMap.IsBound( entry.toLatin1().data() ) )
-#endif
       {
-       TColStd_IndexedMapOfInteger& subIndexes = indexesMap.ChangeFind(entry.toLatin1().data());
-       subIndexes.Add( subOwner->index() );
-       //indexesMap.replace( entry, subIndexes );
+        TColStd_IndexedMapOfInteger& subIndexes = indexesMap.ChangeFind(entry.toLatin1().data());
+        subIndexes.Add( subOwner->index() );
+        //indexesMap.replace( entry, subIndexes );
       }
       else
       {
-       TColStd_IndexedMapOfInteger subIndexes;
-       subIndexes.Add( subOwner->index() );
-       indexesMap.Bind(entry.toLatin1().data(), subIndexes);
+        TColStd_IndexedMapOfInteger subIndexes;
+        subIndexes.Add( subOwner->index() );
+        indexesMap.Bind(entry.toLatin1().data(), subIndexes);
       }
     }
     else // the owner is NOT a sub owner, maybe it is a DataOwner == GLOBAL selection
@@ -237,11 +234,11 @@ void GEOMGUI_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList )
       const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*itr).operator->() );
       if ( owner )
       {
-       SalomeApp_Study* appStudy =
+        SalomeApp_Study* appStudy =
           dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
-       QString anEntry = appStudy->referencedToEntry( owner->entry() );
+        QString anEntry = appStudy->referencedToEntry( owner->entry() );
 
-       globalSelMap[anEntry] = 1;
+        globalSelMap[anEntry] = 1;
       }
     }
   }
@@ -355,10 +352,10 @@ void GEOMGUI_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList )
       const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*itr2).operator->() );
       if ( owner )
       {
-       SalomeApp_Study* appStudy =
+        SalomeApp_Study* appStudy =
           dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
-       QString anEntry = appStudy->referencedToEntry( owner->entry() );
-       if (globalSelMap[anEntry] == 1) mySelectedExternals.append(*itr2);
+        QString anEntry = appStudy->referencedToEntry( owner->entry() );
+        if (globalSelMap[anEntry] == 1) mySelectedExternals.append(*itr2);
       }
     }
   }