Salome HOME
PAL12789. Add and use COORD_MIN and COORD_MAX macros
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_SelectionOp.cxx
index ec170a047a62f69df7d969b28b4ecc00a1cafe90..2e620f71cb574453cdb7e2b6813ba2ad06a7f6b7 100644 (file)
@@ -15,7 +15,7 @@
 //  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
@@ -29,9 +29,9 @@
 #include <SMESHGUI_Selection.h>
 #include <SMESHGUI.h>
 #include <SUIT_SelectionFilter.h>
-#include <SalomeApp_SelectionMgr.h>
+#include <LightApp_SelectionMgr.h>
 #include <SalomeApp_Study.h>
-#include <SalomeApp_VTKSelector.h>
+#include <LightApp_VTKSelector.h>
 #include <SVTK_ViewWindow.h>
 #include <SVTK_ViewModel.h>
 #include <SVTK_Selector.h>
@@ -48,7 +48,7 @@
 /*
   Class       : SMESHGUI_SelectionOp
   Description : Base operation for all operations using object selection in viewer or objectbrowser
-                through common widgets created by SalomeApp_Dialog::createObject
+                through common widgets created by LightApp_Dialog::createObject
 */
 
 //=================================================================================
@@ -67,11 +67,7 @@ SMESHGUI_SelectionOp::SMESHGUI_SelectionOp( const Selection_Mode mode )
 //=================================================================================
 SMESHGUI_SelectionOp::~SMESHGUI_SelectionOp()
 {
-  Filters::const_iterator anIt = myFilters.begin(),
-                          aLast = myFilters.end();
-  for( ; anIt!=aLast; anIt++ )
-    if( anIt.data() )
-      delete anIt.data();
+  removeCustomFilters();
 }
 
 //=================================================================================
@@ -80,6 +76,9 @@ SMESHGUI_SelectionOp::~SMESHGUI_SelectionOp()
 //=================================================================================
 void SMESHGUI_SelectionOp::startOperation()
 {
+  myOldSelectionMode = selectionMode();
+  setSelectionMode( myDefSelectionMode );
+
   SMESHGUI_Operation::startOperation();
   if( dlg() )
   {
@@ -90,26 +89,27 @@ void SMESHGUI_SelectionOp::startOperation()
     connect( dlg(), SIGNAL( objectDeactivated( int ) ), this, SLOT( onDeactivateObject( int ) ) );
     connect( dlg(), SIGNAL( selectionChanged( int ) ), this, SLOT( onSelectionChanged( int ) ) );
   }
-
-  myOldSelectionMode = selectionMode();
-  setSelectionMode( myDefSelectionMode );
 }
 
 //=================================================================================
 // name     : removeCustomFilters
 // purpose  :
 //=================================================================================
-void SMESHGUI_SelectionOp::removeCustomFilters() const
+void SMESHGUI_SelectionOp::removeCustomFilters()
 {
-  SalomeApp_SelectionMgr* mgr = selectionMgr();
-  if( !mgr )
-    return;
-    
-  Filters::const_iterator anIt = myFilters.begin(),
-                          aLast = myFilters.end();
-  for( ; anIt!=aLast; anIt++ )
-    if( anIt.data() )
-      mgr->removeFilter( anIt.data() );
+  if (myFilters.count() > 0) {
+    LightApp_SelectionMgr* mgr = selectionMgr();
+    Filters::const_iterator anIt = myFilters.begin(),
+                            aLast = myFilters.end();
+    for (; anIt != aLast; anIt++) {
+      if (anIt.data()) {
+        if (mgr) mgr->removeFilter(anIt.data());
+        delete anIt.data();
+      }
+    }
+
+    myFilters.clear();
+  }
 }
 
 //=================================================================================
@@ -118,9 +118,9 @@ void SMESHGUI_SelectionOp::removeCustomFilters() const
 //=================================================================================
 void SMESHGUI_SelectionOp::commitOperation()
 {
+  SMESHGUI_Operation::commitOperation();  
   removeCustomFilters();
   setSelectionMode( myOldSelectionMode );
-  SMESHGUI_Operation::commitOperation();  
 }
 
 //=================================================================================
@@ -129,9 +129,9 @@ void SMESHGUI_SelectionOp::commitOperation()
 //=================================================================================
 void SMESHGUI_SelectionOp::abortOperation()
 {
+  SMESHGUI_Operation::abortOperation();
   removeCustomFilters();
   setSelectionMode( myOldSelectionMode );  
-  SMESHGUI_Operation::abortOperation();
 }
 
 //=================================================================================
@@ -156,7 +156,7 @@ void SMESHGUI_SelectionOp::selectionDone()
   }
     
   QStringList names, ids;
-  SalomeApp_Dialog::TypesList types;
+  LightApp_Dialog::TypesList types;
   selected( names, types, ids );
   dlg()->selectObject( names, types, ids );
 }
@@ -176,7 +176,7 @@ SUIT_SelectionFilter* SMESHGUI_SelectionOp::createFilter( const int ) const
 //=================================================================================
 void SMESHGUI_SelectionOp::onActivateObject( int id )
 {
-  SalomeApp_SelectionMgr* mgr = selectionMgr();
+  LightApp_SelectionMgr* mgr = selectionMgr();
   if( !mgr )
     return;
     
@@ -195,9 +195,7 @@ void SMESHGUI_SelectionOp::onActivateObject( int id )
 //=================================================================================
 void SMESHGUI_SelectionOp::onDeactivateObject( int id )
 {
-  SalomeApp_SelectionMgr* mgr = selectionMgr();
-  if( mgr && myFilters.contains( id ) && myFilters[ id ] )
-    mgr->removeFilter( myFilters[ id ] );
+  removeCustomFilters();
 }
 
 //=================================================================================
@@ -356,7 +354,7 @@ int SMESHGUI_SelectionOp::typeById( const QString& str, const EntityType objtype
 // Purpose : Get names, types and ids of selected objects
 //=======================================================================
 void SMESHGUI_SelectionOp::selected( QStringList& names,
-                                     SalomeApp_Dialog::TypesList& types,
+                                     LightApp_Dialog::TypesList& types,
                                      QStringList& ids ) const
 {
 /*  SUIT_DataOwnerPtrList list; selectionMgr()->selected( list );
@@ -364,8 +362,8 @@ void SMESHGUI_SelectionOp::selected( QStringList& names,
                                         aLast = list.end();
   for( ; anIt!=aLast; anIt++ )
   {
-    SalomeApp_DataOwner* owner = dynamic_cast<SalomeApp_DataOwner*>( (*anIt).operator->() );
-    SalomeApp_SVTKDataOwner* vtkowner = dynamic_cast<SalomeApp_SVTKDataOwner*>( (*anIt).operator->() );
+    LightApp_DataOwner* owner = dynamic_cast<LightApp_DataOwner*>( (*anIt).operator->() );
+    LightApp_SVTKDataOwner* vtkowner = dynamic_cast<LightApp_SVTKDataOwner*>( (*anIt).operator->() );
 
     if( vtkowner )
     {
@@ -420,7 +418,13 @@ void SMESHGUI_SelectionOp::selected( QStringList& names,
       QString id = anIt.Value()->getEntry();
       ids.append( id );
       types.append( typeById( id, Object ) );
-      names.append( anIt.Value()->getName() );
+      SalomeApp_Study* _study = dynamic_cast<SalomeApp_Study*>( study() );
+      if( _study )
+      {
+       _PTR(SObject) obj = _study->studyDS()->FindObjectID( anIt.Value()->getEntry() );
+       if( obj )
+         names.append( obj->GetName().c_str() );
+      }
     }
   }
 }
@@ -491,7 +495,7 @@ void SMESHGUI_SelectionOp::onTextChanged( int, const QStringList& list )
     selector()->AddOrRemoveIndex( sel.First(), newIndices, false );
     highlight( sel.First(), true, true );
 
-    QStringList names, _ids; SalomeApp_Dialog::TypesList types;
+    QStringList names, _ids; LightApp_Dialog::TypesList types;
     selected( names, types, _ids );
     dlg()->selectObject( names, types, _ids, false );
 }