Salome HOME
updated copyright message
[modules/gui.git] / src / LightApp / LightApp_VTKSelector.cxx
index 015530eb920c1eec52375da231bd41fab5fefad5..b8da312f11f8bd615b8fc009e2c654c2928f4279 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 
 #ifndef DISABLE_SALOMEOBJECT
   #include "SALOME_Actor.h"
-  #include "SALOME_ListIteratorOfListIO.hxx"
+  #include "SALOME_ListIO.hxx"
 #endif
 
-
+#include <utilities.h>
 
 #ifndef DISABLE_VTKVIEWER
 #ifndef DISABLE_SALOMEOBJECT
@@ -77,7 +77,7 @@ LightApp_SVTKDataOwner
 /*!
   Gets dataowners ids list.
 */
-const TColStd_IndexedMapOfInteger
+const SVTK_TIndexedMapOfVtkId
 LightApp_SVTKDataOwner
 ::GetIds() const
 {
@@ -103,7 +103,7 @@ LightApp_SVTKDataOwner
     }
   }
   
-  return -1;
+  return ActorSelection; // workaround for embedded VTK viewer in a module : is it safe ?
 }
 
 /*!
@@ -187,7 +187,11 @@ void
 LightApp_VTKSelector
 ::getSelection( SUIT_DataOwnerPtrList& aList ) const
 {
-  if(myViewer){
+  if( myViewer ) {
+    if( SVTK_Viewer* aSViewer = dynamic_cast<SVTK_Viewer*>(myViewer) ) {
+      if( !aSViewer->isSelectionEnabled() )
+        return;
+    }
     if(SUIT_ViewManager* aViewManager = myViewer->getViewManager()){
       if(SVTK_ViewManager* aViewMgr = dynamic_cast<SVTK_ViewManager*>(aViewManager)){
         if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewMgr->getActiveView())){
@@ -209,21 +213,23 @@ LightApp_VTKSelector
 /*!
   Sets selection to selector from data owner list \a theList.
 */
-void 
+void
 LightApp_VTKSelector
 ::setSelection( const SUIT_DataOwnerPtrList& theList )
 {
   SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myViewer);
-  if(myViewer && aViewer && aViewer->isSelectionEnabled()){
+  if ( myViewer && aViewer && ( theList.isEmpty() || aViewer->isSelectionEnabled() )) {
     if(SUIT_ViewManager* aViewMgr = myViewer->getViewManager()){
       if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewMgr->getActiveView())){
         if(SVTK_Selector* aSelector = aView->GetSelector()){
           SALOME_ListIO anAppendList;
           const SALOME_ListIO& aStoredList = aSelector->StoredIObjects();
           SUIT_DataOwnerPtrList::const_iterator anIter = theList.begin();
-          for(; anIter != theList.end(); ++anIter){
+          for(; anIter != theList.end(); ++anIter) {
             const SUIT_DataOwner* aDataOwner = (*anIter).get();
-            if(const LightApp_SVTKDataOwner* anOwner = dynamic_cast<const LightApp_SVTKDataOwner*>(aDataOwner)){
+            if(const LightApp_SVTKDataOwner* anOwner = dynamic_cast<const LightApp_SVTKDataOwner*>(aDataOwner))
+            {
+              MESSAGE("aSelector->SetSelectionMode("<<anOwner->GetMode()<<");");
               aSelector->SetSelectionMode(anOwner->GetMode());
               Handle(SALOME_InteractiveObject) anIO = anOwner->IO();
 
@@ -231,9 +237,11 @@ LightApp_VTKSelector
 
               anAppendList.Append(anIO);
               aSelector->AddOrRemoveIndex(anIO,anOwner->GetIds(),false);
-            }else if(const LightApp_DataOwner* anOwner = dynamic_cast<const LightApp_DataOwner*>(aDataOwner)){
-              Handle(SALOME_InteractiveObject) anIO = 
-                new SALOME_InteractiveObject(anOwner->entry().toLatin1(),"");
+            }
+            else if(const LightApp_DataOwner* anOwner = dynamic_cast<const LightApp_DataOwner*>(aDataOwner))
+            {
+              Handle(SALOME_InteractiveObject) anIO =
+                new SALOME_InteractiveObject(anOwner->entry().toUtf8(),"");
               aSelector->AddIObject(anIO);
               anAppendList.Append(anIO);
             }
@@ -250,10 +258,10 @@ LightApp_VTKSelector
             toRemove.remove( anIt.Value()->getEntry() );
 
           QMap< QString, Handle( SALOME_InteractiveObject )>::const_iterator RIt = toRemove.begin(),
-                                                                             REnd = toRemove.end();
+            REnd = toRemove.end();
           for( ; RIt!=REnd; RIt++ )
             aSelector->RemoveIObject( RIt.value() );
-          
+
           aView->onSelectionChanged();
         }
       }