Salome HOME
untabify
[modules/geom.git] / src / GEOMGUI / GEOMGUI_OCCSelector.cxx
index 0cd04c86fea0af0cec87e27e5838f835d8ca786b..e99774513812eee665ea92c56e94b2a3237c691c 100644 (file)
@@ -1,22 +1,26 @@
-// Copyright (C) 2005  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.
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-// 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
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//  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.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)
 
 #include "GEOMGUI_OCCSelector.h"
 
@@ -46,7 +50,7 @@
 
 //================================================================
 // Function : GEOMGUI_OCCSelector
-// Purpose  : 
+// Purpose  :
 //================================================================
 GEOMGUI_OCCSelector::GEOMGUI_OCCSelector( OCCViewer_Viewer* viewer, SUIT_SelectionMgr* mgr )
 : LightApp_OCCSelector( viewer, mgr )
@@ -55,7 +59,7 @@ GEOMGUI_OCCSelector::GEOMGUI_OCCSelector( OCCViewer_Viewer* viewer, SUIT_Selecti
 
 //================================================================
 // Function : ~GEOMGUI_OCCSelector
-// Purpose  : 
+// Purpose  :
 //================================================================
 GEOMGUI_OCCSelector::~GEOMGUI_OCCSelector()
 {
@@ -63,7 +67,7 @@ GEOMGUI_OCCSelector::~GEOMGUI_OCCSelector()
 
 //================================================================
 // Function : getSelection
-// Purpose  : 
+// Purpose  :
 //================================================================
 void GEOMGUI_OCCSelector::getSelection( SUIT_DataOwnerPtrList& aList ) const
 {
@@ -100,6 +104,7 @@ void GEOMGUI_OCCSelector::getSelection( SUIT_DataOwnerPtrList& aList ) const
           if (!bigShape.IsEqual(curBigShape))
           {
             curBigShape = bigShape;
+            subShapes.Clear();
             TopExp::MapShapes(bigShape, subShapes);
           }
           index = subShapes.FindIndex(subShape);
@@ -144,11 +149,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;
@@ -167,19 +172,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 )
 {
@@ -211,20 +216,20 @@ void GEOMGUI_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList )
     {
       QString entry = subOwner->entry();
 #ifndef WNT
-      if ( indexesMap.IsBound( TCollection_AsciiString((char*)entry.latin1())))
+      if ( indexesMap.IsBound( TCollection_AsciiString(entry.toLatin1().data())))
 #else
-         if ( indexesMap.IsBound( (char*)entry.latin1()))
+      if ( indexesMap.IsBound( entry.toLatin1().data() ) )
 #endif
       {
-       TColStd_IndexedMapOfInteger& subIndexes = indexesMap.ChangeFind((char*)entry.latin1());
-       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((char*)entry.latin1(), 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
@@ -232,11 +237,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;
       }
     }
   }
@@ -268,10 +273,11 @@ void GEOMGUI_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList )
           {
             // has a local selection
             Handle(AIS_Shape) aisShape = Handle(AIS_Shape)::DownCast( io );
-            if (!aisShape.IsNull() && indexesMap.IsBound((char*)entryStr.latin1()))
+            if (!aisShape.IsNull() && indexesMap.IsBound(entryStr.toLatin1().data()))
             {
               isLocal = true;
               TopoDS_Shape shape = aisShape->Shape();
+              aMapOfShapes.Clear();
               TopExp::MapShapes(shape, aMapOfShapes);
             }
           }
@@ -298,7 +304,7 @@ void GEOMGUI_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList )
           if (isLocal)
           {
             const TColStd_IndexedMapOfInteger& subIndexes =
-              indexesMap.ChangeFind((char*)entryStr.latin1());
+              indexesMap.ChangeFind(entryStr.toLatin1().data());
 
             const TopoDS_Shape& aSubShape = anOwner->Shape();
             int aSubShapeId = aMapOfShapes.FindIndex( aSubShape );
@@ -349,10 +355,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);
       }
     }
   }