Salome HOME
*** empty log message ***
authorasl <asl@opencascade.com>
Thu, 14 Jul 2005 08:43:43 +0000 (08:43 +0000)
committerasl <asl@opencascade.com>
Thu, 14 Jul 2005 08:43:43 +0000 (08:43 +0000)
19 files changed:
src/SMESHGUI/Makefile.in
src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx
src/SMESHGUI/SMESHGUI_AddMeshElementOp.cxx
src/SMESHGUI/SMESHGUI_AddMeshElementOp.h
src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx
src/SMESHGUI/SMESHGUI_Dialog.cxx
src/SMESHGUI/SMESHGUI_Dialog.h
src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx
src/SMESHGUI/SMESHGUI_NodesOp.cxx
src/SMESHGUI/SMESHGUI_NodesOp.h
src/SMESHGUI/SMESHGUI_Operation.cxx
src/SMESHGUI/SMESHGUI_Operation.h
src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx
src/SMESHGUI/SMESHGUI_RemoveNodesOp.cxx
src/SMESHGUI/SMESHGUI_RemoveNodesOp.h
src/SMESHGUI/SMESHGUI_SelectionIdsOp.cxx [deleted file]
src/SMESHGUI/SMESHGUI_SelectionIdsOp.h [deleted file]
src/SMESHGUI/SMESHGUI_SelectionOp.cxx
src/SMESHGUI/SMESHGUI_SelectionOp.h

index ff2d7642ebb138696a3b4b00de92da0a0da9934c..448420647823c1bdce19240f2af3ef1da1ca9fa7 100644 (file)
@@ -116,8 +116,7 @@ LIB_SRC =   SMESHGUI.cxx \
                SMESHGUI_CreatePolyhedralVolumeDlg.cxx \
                SMESHGUI_Dialog.cxx \
                SMESHGUI_Operation.cxx \
-               SMESHGUI_SelectionOp.cxx \
-               SMESHGUI_SelectionIdsOp.cxx
+               SMESHGUI_SelectionOp.cxx
 
 LIB_MOC = \
                SMESHGUI.h \
@@ -170,8 +169,7 @@ LIB_MOC = \
                SMESHGUI_Dialog.h \
                SMESHGUI_CreatePolyhedralVolumeDlg.h \
                SMESHGUI_Operation.h \
-               SMESHGUI_SelectionOp.h \
-               SMESHGUI_SelectionIdsOp.h
+               SMESHGUI_SelectionOp.h
     
 LIB_CLIENT_IDL = SALOME_Exception.idl \
                 GEOM_Gen.idl \
index 707d1d4fb9298b56b241619895836e579b402259..fd0ff2270ca827b15b1205fc26ea765bfe19cb0a 100644 (file)
@@ -27,7 +27,6 @@
 //  $Header$
 
 #include "SMESHGUI_AddMeshElementDlg.h"
-#include <SMESHGUI_Operation.h>
 
 #include <SUIT_ResourceMgr.h>
 
@@ -96,7 +95,7 @@ SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( const QString& elemName,
   createObject( tr( "SMESH_ID_NODES" ), GroupC1, 0 );
   setNameIndication( 0, ListOfNames );
   setReadOnly( 0, false );
-  setObjectType( 0, SMESHGUI_Operation::prefix( "SMESH element" ) + SMDSAbs_Node, -1 );
+  setObjectType( 0, prefix( "SMESH element" ) + SMDSAbs_Node, -1 );
 
   myReverse = 0;
   if ( reverse ) {
index 13836e7922dbebb9ace11adbec12cb6b6ddab97e..5942cd6b65bb2ce6e7282bea4f8cbd1cf4a88d31 100644 (file)
@@ -161,7 +161,7 @@ namespace SMESH {
 // purpose  : constructor
 //=================================================================================
 SMESHGUI_AddMeshElementOp::SMESHGUI_AddMeshElementOp( const SMDSAbs_ElementType t, const int nbNodes )
-: SMESHGUI_SelectionIdsOp( NodeSelection ),
+: SMESHGUI_SelectionOp( NodeSelection ),
   myElementType( t ),
   myNbNodes( nbNodes ),
   myIsPoly( myElementType==SMDSAbs_Face && myNbNodes==5 ),
@@ -212,10 +212,11 @@ void SMESHGUI_AddMeshElementOp::startOperation()
     }
     
     myDlg = new SMESHGUI_AddMeshElementDlg( elemName, myElementType == SMDSAbs_Face );
+    connect( myDlg, SIGNAL( objectChanged( int, const QStringList& ) ), this, SLOT( onTextChanged( int, const QStringList& ) ) );
     connect( myDlg, SIGNAL( reverse( int ) ), this, SLOT( onReverse( int ) ) );
   }
 
-  SMESHGUI_SelectionIdsOp::startOperation();
+  SMESHGUI_SelectionOp::startOperation();
 
   mySimulation = new SMESH::TElementSimulation( viewWindow() );
   updateDialog();
@@ -233,7 +234,7 @@ void SMESHGUI_AddMeshElementOp::onSelectionChanged( int id )
     
   mySimulation->SetVisibility(false);
 
-  SMESHGUI_SelectionIdsOp::onSelectionChanged( id );
+  SMESHGUI_SelectionOp::onSelectionChanged( id );
 
   updateDialog();
   displaySimulation();
@@ -248,7 +249,7 @@ void SMESHGUI_AddMeshElementOp::commitOperation()
   if( mySimulation )
     delete mySimulation;
   mySimulation = 0;
-  SMESHGUI_SelectionIdsOp::commitOperation();
+  SMESHGUI_SelectionOp::commitOperation();
 }
 
 //=================================================================================
@@ -260,7 +261,7 @@ void SMESHGUI_AddMeshElementOp::abortOperation()
   if( mySimulation )
     delete mySimulation;
   mySimulation = 0;
-  SMESHGUI_SelectionIdsOp::abortOperation();
+  SMESHGUI_SelectionOp::abortOperation();
 }
 
 //=================================================================================
index 1a11a4ba9039248b843f34a7f41252382e8f8ee0..555c21ee4e8448d5e1099e8c68a0946e537f7d9d 100644 (file)
@@ -33,7 +33,7 @@ namespace SMESH{
   struct TElementSimulation;
 }
 
-#include <SMESHGUI_SelectionIdsOp.h>
+#include <SMESHGUI_SelectionOp.h>
 #include <SMDSAbs_ElementType.hxx>
 
 class SMESHGUI_AddMeshElementDlg;
@@ -42,7 +42,7 @@ class SMESHGUI_AddMeshElementDlg;
 // class    : SMESHGUI_AddMeshElementOp
 // purpose  :
 //=================================================================================
-class SMESHGUI_AddMeshElementOp : public SMESHGUI_SelectionIdsOp
+class SMESHGUI_AddMeshElementOp : public SMESHGUI_SelectionOp
 { 
     Q_OBJECT
 
index da520ad1a085eae933d6e6e53ba12fbb0a5bc781..4a098c8eca755b58730691ef30821ddbfe286377 100644 (file)
@@ -27,7 +27,6 @@
 //  $Header$
 
 #include "SMESHGUI_AddSubMeshDlg.h"
-#include <SMESHGUI_Operation.h>
 
 #include <SMESH_Type.h>
 
@@ -69,7 +68,7 @@ SMESHGUI_AddSubMeshDlg::SMESHGUI_AddSubMeshDlg()
     setNameIndication( MeshObj, OneName );
     setNameIndication( GeomObj, OneName );
 
-    int _smesh = SMESHGUI_Operation::prefix( "SMESH" );
+    int _smesh = prefix( "SMESH" );
     setObjectType( Hypo, _smesh + HYPOTHESIS, -1 );
     setObjectType( Algo, _smesh + ALGORITHM, -1 );
 
index 3666b7c4669d7fb4b03a1f96673590fd0a6d2e8c..eff519e681928685b30dc553dc837d4e17d3903d 100644 (file)
@@ -27,7 +27,6 @@
 //  $Header$
 
 #include <SMESHGUI_Dialog.h>
-#include <SMESHGUI_Operation.h>
 #include <SMESH_Type.h>
 #include <SUIT_Session.h>
 #include <SalomeApp_Application.h>
 SMESHGUI_Dialog::SMESHGUI_Dialog( const bool modal, const bool allowResize, const int flags )
 : SalomeApp_Dialog( desktop(), "", modal, allowResize, flags )
 {
-  int prefix = SMESHGUI_Operation::prefix( "SMESH" );
-  typeName( prefix + MESH ) = tr( "DLG_MESH" );
-  typeName( prefix + HYPOTHESIS ) = tr( "DLG_HYPO" );
-  typeName( prefix + ALGORITHM ) = tr( "DLG_ALGO" );
+  int pr = prefix( "SMESH" );
+  typeName( pr + MESH ) = tr( "DLG_MESH" );
+  typeName( pr + HYPOTHESIS ) = tr( "DLG_HYPO" );
+  typeName( pr + ALGORITHM ) = tr( "DLG_ALGO" );
 }
 
 //=================================================================================
@@ -92,3 +91,19 @@ SUIT_Desktop* SMESHGUI_Dialog::desktop() const
   }
   return d;
 }
+
+//=======================================================================
+// name    : prefix
+// Purpose : Get prefix for module types
+//=======================================================================
+int SMESHGUI_Dialog::prefix( const QString& name )
+{
+  if( name == "GEOM" )
+    return 100;
+  else if( name == "SMESH" )
+    return 200;
+  else if( name == "SMESH element" )
+    return 300;
+  else
+    return 0;
+}
index 268b67ae79e2748f0ce1e80423b6956906fb20fc..927ac7b6caf11ecb4f123dd695faf1513f5805b0 100644 (file)
@@ -51,6 +51,9 @@ public:
   //! set all content to enable (parameter is true) or disable state
   void setContentActive( const bool ) const;
 
+  //! Return hard-coded prefix using to differ overlapping types
+  static int   prefix( const QString& );
+  
 protected:
   //! find desktop of active application
   SUIT_Desktop* desktop() const;
index f687dfef01f08a88922c85c76284d388bc4d35ef..edf7276acd3cd8c6368f1dd976a7372cbb9005af 100644 (file)
@@ -28,7 +28,6 @@
 
 #include "SMESHGUI_InitMeshDlg.h"
 #include <SMESHGUI.h>
-#include <SMESHGUI_Operation.h>
 
 #include <SMESH_Type.h>
 
@@ -68,7 +67,7 @@ SMESHGUI_InitMeshDlg::SMESHGUI_InitMeshDlg()
 
     setNameIndication( GeomObj, OneName );
     
-    int _smesh = SMESHGUI_Operation::prefix( "SMESH" );
+    int _smesh = prefix( "SMESH" );
     setObjectType( Hypo, _smesh + HYPOTHESIS, -1 );
     setObjectType( Algo, _smesh + ALGORITHM, -1 );
     
index 59f5a7fb7ade42b205ae35c34d320de13996a197..4e2f6ae3ceb65ad7d9396803a694882bf1d617cb 100644 (file)
@@ -275,26 +275,23 @@ void SMESHGUI_NodesOp::selectionDone()
   SMESH::SetPointRepresentation(true);
 
   const SALOME_ListIO& aList = selector()->StoredIObjects();
-  if (aList.Extent() == 1) {
+  if (aList.Extent() == 1)
+  {
     Handle(SALOME_InteractiveObject) anIO = aList.First();
-    if (anIO->hasEntry()) {
-      myMesh = SMESH::GetMeshByIO(anIO);
-      if (myMesh->_is_nil()) return;
+    if (anIO->hasEntry())
+    {
       QString aText;
-      if (SMESH::GetNameOfSelectedNodes(selector(),anIO,aText) == 1) {
-       if (SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh.in())) {
-         if (SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh()) {
-           if (const SMDS_MeshNode* aNode = aMesh->FindNode(aText.toInt())) {
-        myDlg->setCoords( aNode->X(), aNode->Y(), aNode->Z() );
-            }
-         }
-       }
-      }
-      double x, y, z;
-      myDlg->coords( x, y, z );
-      mySimulation->SetPosition( x, y, z );
+      if( SMESH::GetNameOfSelectedNodes( selector(), anIO, aText ) == 1 )
+        if( SMESH_Actor* anActor = actor() )
+          if( SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh() )
+            if( const SMDS_MeshNode* aNode = aMesh->FindNode( aText.toInt() ) )
+              myDlg->setCoords( aNode->X(), aNode->Y(), aNode->Z() );
     }
-  } 
+  }
+    
+  double x, y, z;
+  myDlg->coords( x, y, z );
+  mySimulation->SetPosition( x, y, z );
 }
 
 //=================================================================================
@@ -315,7 +312,7 @@ bool SMESHGUI_NodesOp::onApply()
   if( getSMESHGUI()->isActiveStudyLocked() || !mySimulation )
     return false;
 
-  if (myMesh->_is_nil()) {
+  if( mesh()->_is_nil()) {
     SUIT_MessageBox::warn1( myDlg, tr("SMESH_WRN_WARNING"),
                             tr("MESH_IS_NOT_SELECTED"), tr("SMESH_BUT_OK"));
     return false;
@@ -323,7 +320,7 @@ bool SMESHGUI_NodesOp::onApply()
 
   double x, y, z; myDlg->coords( x, y, z );
   mySimulation->SetVisibility(false);
-  SMESH::AddNode(myMesh,x,y,z);
+  SMESH::AddNode( mesh(), x, y, z );
   SMESH::SetPointRepresentation(true);
 
   // select myMesh
@@ -337,7 +334,7 @@ bool SMESHGUI_NodesOp::onApply()
         if (SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)) {
           if (anActor->hasIO()) {
             if (SMESH_MeshObj *aMeshObj = dynamic_cast<SMESH_MeshObj*>(anActor->GetObject().get())) {
-              if (myMesh->_is_equivalent(aMeshObj->GetMeshServer())) {
+              if ( mesh()->_is_equivalent(aMeshObj->GetMeshServer())) {
                 aList.Clear();
                 aList.Append(anActor->getIO());
                 selectionMgr()->setSelectedObjects(aList, false);
index 45acb92f497879617852edd359f79fea3761f87f..eb2564c4776c742f5ff2abc77d49d6069235d8c1 100644 (file)
@@ -35,13 +35,8 @@ namespace SMESH{
 
 #include <SMESHGUI_SelectionOp.h>
 
-// IDL Headers
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER(SMESH_Mesh)
-
 class SMESHGUI_NodesDlg;
 
-
 //=================================================================================
 // class    : SMESHGUI_NodesOp
 // purpose  :
@@ -71,7 +66,6 @@ private slots:
     void onValueChanged( double );
 
 private:
-    SMESH::SMESH_Mesh_var   myMesh;
     SMESH::TNodeSimulation* mySimulation;
     SMESHGUI_NodesDlg*      myDlg;
 };
index 0d46d002e6b6e5773149536de8bb5c344b0f2604..14c925ae03c769abb5e09b87319b86eddc8f645d 100755 (executable)
@@ -9,22 +9,13 @@
 //  Module : SALOME
 
 #include "SMESHGUI_Operation.h"
-#include "SMESHGUI.h"
-#include "SMESHGUI_VTKUtils.h"
-#include "SMESHGUI_Selection.h"
-
-#include <SVTK_ViewWindow.h>
-#include <SVTK_Selector.h>
-#include <SUIT_MessageBox.h>
-#include <SUIT_Desktop.h>
+#include <SMESHGUI.h>
+#include <SMESHGUI_Dialog.h>
 
 #include <SalomeApp_Study.h>
-#include <SalomeApp_VTKSelector.h>
-#include <SalomeApp_SelectionMgr.h>
 
-#include <SALOMEDS_SObject.hxx>
-
-#include <SMESHDS_Mesh.hxx>
+#include <SUIT_MessageBox.h>
+#include <SUIT_Desktop.h>
 
 /*
   Class       : SMESHGUI_Operation
@@ -48,55 +39,6 @@ SMESHGUI_Operation::~SMESHGUI_Operation()
 {
 }
 
-//=======================================================================
-// name    : selectionMode
-// Purpose : Returns selection mode
-//=======================================================================
-Selection_Mode SMESHGUI_Operation::selectionMode() const
-{
-  SVTK_ViewWindow* wnd = viewWindow();
-  if( wnd )
-    return wnd->SelectionMode();
-  else
-    return ActorSelection;
-}
-
-//=======================================================================
-// name    : setSelectionMode
-// Purpose : Set selection mode
-//=======================================================================
-void SMESHGUI_Operation::setSelectionMode( const Selection_Mode mode )
-{
-  SVTK_ViewWindow* wnd = viewWindow();
-  if( wnd )
-    wnd->SetSelectionMode( mode );
-}
-
-//=======================================================================
-// name    : highlight
-// Purpose : Highlight object in 3d viewer
-//=======================================================================
-void SMESHGUI_Operation::highlight( const Handle( SALOME_InteractiveObject )& obj,
-                                    const bool hilight, const bool immediately )
-{
-  SVTK_ViewWindow* wnd = viewWindow();
-  if( wnd )
-    wnd->highlight( obj, hilight, immediately );
-}
-
-//=======================================================================
-// name    : addOrRemoveIndex
-// Purpose : Select/deselect cells of mesh
-//=======================================================================
-void SMESHGUI_Operation::addOrRemoveIndex( const Handle( SALOME_InteractiveObject )& obj,
-                                           const TColStd_MapOfInteger& indices,
-                                           const bool isModeShift )
-{
-  SVTK_Selector* sel = selector();
-  if( sel )
-    sel->AddOrRemoveIndex( obj, indices, isModeShift );
-}
-
 //=======================================================================
 // name    : getSMESHGUI
 // Purpose : Get SMESH module
@@ -106,25 +48,6 @@ SMESHGUI* SMESHGUI_Operation::getSMESHGUI() const
   return dynamic_cast<SMESHGUI*>( module() );
 }
 
-//=======================================================================
-// name    : viewWindow
-// Purpose : Get active view window
-//=======================================================================
-SVTK_ViewWindow* SMESHGUI_Operation::viewWindow() const
-{
-  return SMESH::GetViewWindow( getSMESHGUI() );
-}
-
-//=======================================================================
-// name    : selector
-// Purpose : Get selector
-//=======================================================================
-SVTK_Selector* SMESHGUI_Operation::selector() const
-{
-  SVTK_ViewWindow* wnd = viewWindow();
-  return wnd ? wnd->GetSelector() : 0;
-}
-
 //=======================================================================
 // name    : startOperation
 // Purpose : Start opeartion
@@ -167,7 +90,7 @@ bool SMESHGUI_Operation::isReadyToStart()
     
   if ( getSMESHGUI() == 0 )
   {
-    SUIT_MessageBox::warn1( SMESHGUI::desktop(), tr( "SMESH_WRN_WARNING" ),
+    SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
       tr( "NO_MODULE" ), tr( "SMESH_BUT_OK" ) );
     return false;
   }
@@ -175,129 +98,6 @@ bool SMESHGUI_Operation::isReadyToStart()
   return true;
 }
 
-//=======================================================================
-// name    : typeById
-// Purpose : Find type by id
-//=======================================================================
-int SMESHGUI_Operation::typeById( const QString& str, const SelectedObjectType objtype ) const
-{
-  SalomeApp_Study* _study = dynamic_cast<SalomeApp_Study*>( study() );
-  if( !_study )
-    return -1;
-
-  _PTR( Study ) st = _study->studyDS();
-
-  int res = -1;
-  if( objtype == Object )
-  {
-    SalomeApp_Study* _study = dynamic_cast<SalomeApp_Study*>( study() );
-    if( _study )
-    {
-      int t = SMESHGUI_Selection::type( str, _study->studyDS() );
-      if( t<0 )
-      {
-        //try to get GEOM type
-        _PTR( SObject ) sobj = st->FindObjectID( str.latin1() );
-        if( sobj )
-        {
-          GEOM::GEOM_Object_var obj = GEOM::GEOM_Object::_narrow( dynamic_cast<SALOMEDS_SObject*>( sobj.get() )->GetObject() );
-          if( !CORBA::is_nil( obj ) )
-            res = prefix( "GEOM" ) + obj->GetType();
-        }
-      }
-      else
-        res = prefix( "SMESH" ) + t;
-    }
-  }
-  else  
-  {
-    int pos = str.find( idChar() );
-    QString entry = str.left( pos ),
-            _id = str.mid( pos+1 );
-    bool ok;
-    int id = _id.toInt( &ok );
-    if( ok )
-    {
-      _PTR( SObject ) sobj = st->FindObjectID( entry.latin1() );
-      SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( dynamic_cast<SALOMEDS_SObject*>( sobj.get() )->GetObject() );
-      SMESH::SMESH_subMesh_var submesh = SMESH::SMESH_subMesh::_narrow( dynamic_cast<SALOMEDS_SObject*>( sobj.get() )->GetObject() );
-      if( !CORBA::is_nil( mesh ) )
-        res = prefix( "SMESH element" ) + mesh->GetElementType( id, objtype==MeshElement );
-        
-      else if( !CORBA::is_nil( submesh ) )
-        res = prefix( "SMESH element" ) + submesh->GetElementType( id, objtype==MeshElement );
-    }
-  }
-
-  return res;
-}
-
-//=======================================================================
-// name    : prefix
-// Purpose : Get prefix for module types
-//=======================================================================
-int SMESHGUI_Operation::prefix( const QString& name )
-{
-  if( name == "GEOM" )
-    return 100;
-  else if( name == "SMESH" )
-    return 200;
-  else if( name == "SMESH element" )
-    return 300;
-  else
-    return 0;
-}
-
-//=======================================================================
-// name    : selected
-// Purpose : Get names, types and ids of selected objects
-//=======================================================================
-void SMESHGUI_Operation::selected( QStringList& names, SalomeApp_Dialog::TypesList& types, QStringList& ids ) const
-{
-  SUIT_DataOwnerPtrList list; selectionMgr()->selected( list );
-  SUIT_DataOwnerPtrList::const_iterator anIt = list.begin(),
-                                        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->() );
-
-    if( vtkowner )
-    {
-      QString id_str = QString( "%1%2%3" ).arg( vtkowner->entry() ).arg( idChar() ), current_id_str;
-      Selection_Mode mode = vtkowner->GetMode();
-      SelectedObjectType objtype = mode == NodeSelection ? MeshNode : MeshElement;
-      const TColStd_IndexedMapOfInteger& ownerids = vtkowner->GetIds();
-
-      for( int i=1, n=ownerids.Extent(); i<=n; i++ )
-      {
-        int curid = ownerids( i );
-        current_id_str = id_str.arg( curid );
-        ids.append( current_id_str );
-        types.append( typeById( current_id_str, objtype ) );
-        names.append( QString( "%1" ).arg( curid ) );
-      }
-    }
-
-    else if( owner )
-    {
-      QString id = owner->entry();
-      ids.append( id );
-      types.append( typeById( id, Object ) );
-      names.append( owner->IO()->getName() );
-    }
-  }
-}
-
-//=======================================================================
-// name    : idChar
-// Purpose : Char using to divide <entry> and <id> in string id representation. By default, '#'
-//=======================================================================
-QChar SMESHGUI_Operation::idChar() const
-{
-  return '#';
-}
-
 //=======================================================================
 // name    : setDialogActive
 // Purpose : 
index 68542417a3f8a5896946889b7c3288296292d07b..89ec3f6b7580be00b53acb87eb25c7e970e4c7a2 100755 (executable)
 #define SMESHGUI_Operation_H
 
 #include <SalomeApp_Operation.h>
-#include <SMESHGUI_Dialog.h>
-#include <SALOME_InteractiveObject.hxx>
-#include <SVTK_Selection.h>
-
 #include <SALOMEDSClient.hxx>
 
 class SMESHGUI;
-class SVTK_ViewWindow;
-class SVTK_Selector;
-class TColStd_MapOfInteger;
-
 
 /*
   Class       : SMESHGUI_Operation
@@ -38,51 +30,20 @@ public:
   SMESHGUI_Operation();
   virtual ~SMESHGUI_Operation();
 
-  static  int       prefix( const QString& );
-  // Return hard-coded prefix using to differ intersecting types
-  
-protected:
-  typedef enum
-  {
-    Object,
-    MeshNode,
-    MeshElement
-
-  } SelectedObjectType;
-
 protected:
-  Selection_Mode    selectionMode() const;
-  void              setSelectionMode( const Selection_Mode );
-  void              highlight( const Handle( SALOME_InteractiveObject )&,
-                               const bool, const bool = true );
-  void              addOrRemoveIndex( const Handle( SALOME_InteractiveObject )&,
-                                      const TColStd_MapOfInteger&, const bool );
-
   //! sets the dialog widgets to state just after operation start
   virtual void      initDialog();
 
   virtual void      startOperation();
   virtual bool      isReadyToStart();
+  
+  //! Set according dialog active or inactive
+  virtual void      setDialogActive( const bool );
 
   SMESHGUI*         getSMESHGUI() const;
-  SVTK_ViewWindow*  viewWindow() const;
-  SVTK_Selector*    selector() const;
 
   _PTR(Study)       studyDS() const;
 
-
-  //! Get names, types and ids of selected objects
-  virtual void      selected( QStringList&, SMESHGUI_Dialog::TypesList&, QStringList& ) const;
-  
-  //! Find type by id
-  virtual int       typeById( const QString&, const SelectedObjectType ) const;
-  
-  //! Char using to divide <entry> and <id> in string id representation. By default, '#'
-  virtual QChar     idChar() const;
-  
-  //! Set accroding dialog active or inactive
-  virtual void      setDialogActive( const bool );
-
 protected slots:
   virtual void onOk();
   virtual bool onApply();
index 7185dd98c392a9f0c0a5146e2d62c3c9ddb14350..3c00fef84cc437c86de1c12d1d3ec13880f0b6a6 100644 (file)
@@ -27,7 +27,6 @@
 //  $Header$
 
 #include "SMESHGUI_RemoveNodesDlg.h"
-#include <SMESHGUI_Operation.h>
 
 #include <SUIT_ResourceMgr.h>
 
@@ -90,7 +89,7 @@ SMESHGUI_RemoveNodesDlg::SMESHGUI_RemoveNodesDlg()
     createObject( tr("SMESH_ID_NODES" ), GroupC1, 0 );
     setNameIndication( 0, ListOfNames );
     setReadOnly( 0, false );
-    setObjectType( 0, SMESHGUI_Operation::prefix( "SMESH element" ) + SMDSAbs_Node, -1 );
+    setObjectType( 0, prefix( "SMESH element" ) + SMDSAbs_Node, -1 );
 
     main->addWidget(GroupC1);
 }
index c8145579e485b013902b9b1cc9c50894b9a70608..15c443e65df5d2223e8fac5ae2c95a6cd43bd160 100644 (file)
@@ -36,7 +36,7 @@
 // purpose  : 
 //=================================================================================
 SMESHGUI_RemoveNodesOp::SMESHGUI_RemoveNodesOp()
-: SMESHGUI_SelectionIdsOp( NodeSelection ),
+: SMESHGUI_SelectionOp( NodeSelection ),
   myDlg( 0 )
 {
 }
@@ -67,9 +67,12 @@ SalomeApp_Dialog* SMESHGUI_RemoveNodesOp::dlg() const
 void SMESHGUI_RemoveNodesOp::startOperation()
 {
   if( !myDlg )
+  {
     myDlg = new SMESHGUI_RemoveNodesDlg();
+    connect( myDlg, SIGNAL( objectChanged( int, const QStringList& ) ), this, SLOT( onTextChanged( int, const QStringList& ) ) );
+  }
 
-  SMESHGUI_SelectionIdsOp::startOperation();
+  SMESHGUI_SelectionOp::startOperation();
 
   myDlg->show();
 }
@@ -80,7 +83,7 @@ void SMESHGUI_RemoveNodesOp::startOperation()
 //=================================================================================
 void SMESHGUI_RemoveNodesOp::selectionDone()
 {
-  SMESHGUI_SelectionIdsOp::selectionDone();
+  SMESHGUI_SelectionOp::selectionDone();
   updateDialog();
 } 
 
index 5bd9ceb445a333b0b32da89e253a97248183bca1..68af749bc411163ab5811771c1fbcbe340bde6dc 100644 (file)
@@ -29,7 +29,7 @@
 #ifndef OPERATION_REMOVE_NODES_H
 #define OPERATION_REMOVE_NODES_H
 
-#include <SMESHGUI_SelectionIdsOp.h>
+#include <SMESHGUI_SelectionOp.h>
 
 class SMESHGUI_RemoveNodesDlg;
 
@@ -37,7 +37,7 @@ class SMESHGUI_RemoveNodesDlg;
 // class    : SMESHGUI_RemoveNodesOp
 // purpose  :
 //=================================================================================
-class SMESHGUI_RemoveNodesOp : public SMESHGUI_SelectionIdsOp
+class SMESHGUI_RemoveNodesOp : public SMESHGUI_SelectionOp
 {
     Q_OBJECT
 
diff --git a/src/SMESHGUI/SMESHGUI_SelectionIdsOp.cxx b/src/SMESHGUI/SMESHGUI_SelectionIdsOp.cxx
deleted file mode 100644 (file)
index 2436435..0000000
+++ /dev/null
@@ -1,221 +0,0 @@
-//  Copyright (C) 2003  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. 
-// 
-//  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : SMESHGUI_SelectionIdsOp.cxx
-//  Author : Alexander SOLOVYOV
-//  Module : SMESH
-
-#include <SMESHGUI_SelectionIdsOp.h>
-#include <SMESHGUI_Utils.h>
-#include <SMESHGUI_VTKUtils.h>
-#include <SMESHGUI_MeshUtils.h>
-
-#include <SalomeApp_SelectionMgr.h>
-
-#include <SALOME_ListIO.hxx>
-#include <SVTK_ViewModel.h>
-#include <SVTK_Selector.h>
-
-#include <SMDS_Mesh.hxx>
-#include <SMESH_Actor.h>
-
-#include <TColStd_MapOfInteger.hxx>
-
-/*
-  Class       : SMESHGUI_SelectionIdsOp
-  Description : 
-*/
-
-//=================================================================================
-// name     : SMESHGUI_SelectionIdsOp
-// purpose  : 
-//=================================================================================
-SMESHGUI_SelectionIdsOp::SMESHGUI_SelectionIdsOp( const Selection_Mode mode )
-: SMESHGUI_SelectionOp( mode )
-{
-}
-
-//=================================================================================
-// name     : ~SMESHGUI_SelectionIdsOp
-// purpose  :
-//=================================================================================
-SMESHGUI_SelectionIdsOp::~SMESHGUI_SelectionIdsOp()
-{
-}
-
-//=================================================================================
-// name     : startOperation
-// purpose  :
-//=================================================================================
-void SMESHGUI_SelectionIdsOp::startOperation()
-{
-  SMESHGUI_SelectionOp::startOperation();
-  if( dlg() )
-  {
-    disconnect( dlg(), SIGNAL( objectChanged( int, const QStringList& ) ),
-                this,  SLOT( onTextChanged( int, const QStringList& ) ) );
-    connect( dlg(), SIGNAL( objectChanged( int, const QStringList& ) ),
-             this,  SLOT( onTextChanged( int, const QStringList& ) ) );    
-  }
-}
-
-//=================================================================================
-// name     : commitOperation
-// purpose  :
-//=================================================================================
-void SMESHGUI_SelectionIdsOp::commitOperation()
-{
-  SMESHGUI_SelectionOp::commitOperation();
-  myMesh = SMESH::SMESH_Mesh::_nil();
-}
-
-//=================================================================================
-// name     : abortOperation
-// purpose  :
-//=================================================================================
-void SMESHGUI_SelectionIdsOp::abortOperation()
-{
-  SMESHGUI_SelectionOp::abortOperation();
-  myMesh = SMESH::SMESH_Mesh::_nil();
-}
-
-//=================================================================================
-// name     : selectionDone
-// purpose  :
-//=================================================================================
-void SMESHGUI_SelectionIdsOp::selectionDone()
-{
-  if( !dlg() )
-    return;
-    
-  // get selected mesh
-  SALOME_ListIO aList;
-  selectionMgr()->selectedObjects(aList,SVTK_Viewer::Type());
-
-  if( aList.Extent() != 1)
-  {
-    myMesh = SMESH::SMESH_Mesh::_nil();
-    dlg()->clearSelection();
-    return;
-  }
-
-  Handle(SALOME_InteractiveObject) anIO = aList.First();
-  myMesh = SMESH::GetMeshByIO(anIO);
-
-  QStringList names, ids; SalomeApp_Dialog::TypesList types;
-  selected( names, types, ids );  
-  dlg()->selectObject( names, types, ids );
-}
-
-//=================================================================================
-// name     : mesh
-// purpose  :
-//=================================================================================
-SMESH::SMESH_Mesh_var SMESHGUI_SelectionIdsOp::mesh() const
-{
-  return myMesh;
-}
-
-//=================================================================================
-// name     : actor
-// purpose  :
-//=================================================================================
-SMESH_Actor* SMESHGUI_SelectionIdsOp::actor() const
-{
-  return SMESH::FindActorByObject( myMesh.in() );
-}
-
-//=================================================================================
-// name     : onTextChanged
-// purpose  :
-//=================================================================================
-void SMESHGUI_SelectionIdsOp::onTextChanged( int, const QStringList& list )
-{
-    if( !dlg() )
-      return;
-
-    TColStd_MapOfInteger newIndices;
-
-    SALOME_ListIO sel; selectionMgr()->selectedObjects( sel );
-    SMESH_Actor* anActor = actor();
-    if( sel.Extent()==0 || !anActor )
-      return;
-
-    SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
-
-    IdList ids; extractIds( list, ids, '\0' );
-    IdList::const_iterator anIt = ids.begin(),
-                           aLast = ids.end();
-    for( ; anIt!=aLast; anIt++ )
-      if( const SMDS_MeshNode * n = aMesh->FindNode( *anIt ) )
-        newIndices.Add( n->GetID() );
-
-    selector()->AddOrRemoveIndex( sel.First(), newIndices, false );
-    highlight( sel.First(), true, true );
-
-    QStringList names, _ids; SalomeApp_Dialog::TypesList types;
-    selected( names, types, _ids );
-    dlg()->selectObject( names, types, _ids, false );
-}
-
-//=================================================================================
-// name     : selectedIds
-// purpose  :
-//=================================================================================
-void SMESHGUI_SelectionIdsOp::selectedIds( const int id, IdList& list ) const
-{
-  if( !dlg() )
-    return;
-    
-  QStringList ids; dlg()->selectedObject( id, ids );
-  extractIds( ids, list );
-}
-
-//=================================================================================
-// name     : extractIds
-// purpose  :
-//=================================================================================
-void SMESHGUI_SelectionIdsOp::extractIds( const QStringList& ids, IdList& list, const QChar idchar )
-{
-  QStringList::const_iterator anIt = ids.begin(),
-                              aLast = ids.end();
-  QString id_str;
-  for( ; anIt!=aLast; anIt++ )
-  {
-    id_str = *anIt;
-    int pos = idchar=='\0' ? -1 : id_str.find( idchar );
-    int id = -1;
-    if( idchar=='\0' || pos>=0 )
-    {
-      id = id_str.mid( pos+1 ).toInt();
-      list.append( id );
-    }
-  }  
-}
-
-//=================================================================================
-// name     : extractIds
-// purpose  :
-//=================================================================================
-void SMESHGUI_SelectionIdsOp::extractIds( const QStringList& ids, IdList& list ) const
-{
-  extractIds( ids, list, idChar() );
-}
diff --git a/src/SMESHGUI/SMESHGUI_SelectionIdsOp.h b/src/SMESHGUI/SMESHGUI_SelectionIdsOp.h
deleted file mode 100644 (file)
index f39e774..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-//  Copyright (C) 2003  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. 
-// 
-//  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : SMESHGUI_SelectionIdsOp.h
-//  Author : Alexander SOLOVYOV
-//  Module : SMESH
-
-
-#ifndef SMESHGUI_SelectionIdsOp_H
-#define SMESHGUI_SelectionIdsOp_H
-
-#include <SMESHGUI_SelectionOp.h>
-
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER(SMESH_Mesh)
-
-class SMESH_Actor;
-
-/*
-  Class       : SMESHGUI_SelectionIdsOp
-  Description : Base operation for all operations using selection mesh elements by id on one mesh
-                In order to allow user to edit ids "by hands" the dialog must call setReadOnly( .., false )
-                with id or object selection widget instead '..'
-                All other necessary actions are implemented here
-*/
-
-class SUIT_SelectionFilter;
-
-class SMESHGUI_SelectionIdsOp : public SMESHGUI_SelectionOp
-{ 
-  Q_OBJECT
-
-public:
-  typedef QValueList<int> IdList;
-
-public:
-  SMESHGUI_SelectionIdsOp( const Selection_Mode = ActorSelection );
-  virtual ~SMESHGUI_SelectionIdsOp();
-
-  static void   extractIds( const QStringList&, IdList&, const QChar );
-    
-protected:
-  virtual void  startOperation();
-  virtual void  commitOperation();
-  virtual void  abortOperation();
-  virtual void  selectionDone();
-
-  SMESH::SMESH_Mesh_var  mesh() const;
-  SMESH_Actor*           actor() const;
-  void                   selectedIds( const int, IdList& ) const;
-  void                   extractIds( const QStringList&, IdList& ) const;
-
-protected slots:
-  virtual void  onTextChanged( int, const QStringList& );
-
-private:
-  SMESH::SMESH_Mesh_var       myMesh;
-};
-
-#endif
index 4a497c68b22589f2325d4d3c3457c3c44527ba25..752903f0eb8975745bcd8d81eb8e8627f6290d80 100644 (file)
 //  Module : SMESH
 
 #include <SMESHGUI_SelectionOp.h>
+#include <SMESHGUI_VTKUtils.h>
+#include <SMESHGUI_MeshUtils.h>
+#include <SMESHGUI_Selection.h>
+#include <SMESHGUI.h>
 #include <SUIT_SelectionFilter.h>
 #include <SalomeApp_SelectionMgr.h>
+#include <SalomeApp_Study.h>
+#include <SalomeApp_VTKSelector.h>
+#include <SVTK_ViewWindow.h>
+#include <SVTK_ViewModel.h>
+#include <SVTK_Selector.h>
+#include <SMESH_Actor.h>
+
+#include <SMDS_Mesh.hxx>
+#include <SMDS_MeshNode.hxx>
+
+#include CORBA_SERVER_HEADER(GEOM_Gen)
+#include <SALOMEDS_SObject.hxx>
 
 /*
   Class       : SMESHGUI_SelectionOp
@@ -124,6 +140,18 @@ void SMESHGUI_SelectionOp::selectionDone()
 {
   if( !dlg() )
     return;
+
+  if( selectionMode()!=ActorSelection )
+  {
+    SALOME_ListIO aList;
+    selectionMgr()->selectedObjects( aList, SVTK_Viewer::Type() );
+
+    if( aList.Extent() != 1 ) //we can select nodes or elements only within one mesh
+    {
+      dlg()->clearSelection();
+      return;
+    }    
+  }
     
   QStringList names, ids;
   SalomeApp_Dialog::TypesList types;
@@ -190,3 +218,286 @@ void SMESHGUI_SelectionOp::initDialog()
 void SMESHGUI_SelectionOp::onSelectionChanged( int )
 {
 }
+
+//=======================================================================
+// name    : selectionMode
+// Purpose : Returns selection mode
+//=======================================================================
+Selection_Mode SMESHGUI_SelectionOp::selectionMode() const
+{
+  SVTK_ViewWindow* wnd = viewWindow();
+  if( wnd )
+    return wnd->SelectionMode();
+  else
+    return ActorSelection;
+}
+
+//=======================================================================
+// name    : setSelectionMode
+// Purpose : Set selection mode
+//=======================================================================
+void SMESHGUI_SelectionOp::setSelectionMode( const Selection_Mode mode )
+{
+  SVTK_ViewWindow* wnd = viewWindow();
+  if( wnd )
+    wnd->SetSelectionMode( mode );
+}
+
+//=======================================================================
+// name    : highlight
+// Purpose : Highlight object in 3d viewer
+//=======================================================================
+void SMESHGUI_SelectionOp::highlight( const Handle( SALOME_InteractiveObject )& obj,
+                                      const bool hilight, const bool immediately )
+{
+  SVTK_ViewWindow* wnd = viewWindow();
+  if( wnd )
+    wnd->highlight( obj, hilight, immediately );
+}
+
+//=======================================================================
+// name    : addOrRemoveIndex
+// Purpose : Select/deselect cells of mesh
+//=======================================================================
+void SMESHGUI_SelectionOp::addOrRemoveIndex( const Handle( SALOME_InteractiveObject )& obj,
+                                             const TColStd_MapOfInteger& indices,
+                                             const bool isModeShift )
+{
+  SVTK_Selector* sel = selector();
+  if( sel )
+    sel->AddOrRemoveIndex( obj, indices, isModeShift );
+}
+
+//=======================================================================
+// name    : viewWindow
+// Purpose : Get active view window
+//=======================================================================
+SVTK_ViewWindow* SMESHGUI_SelectionOp::viewWindow() const
+{
+  return SMESH::GetViewWindow( getSMESHGUI() );
+}
+
+//=======================================================================
+// name    : selector
+// Purpose : Get selector
+//=======================================================================
+SVTK_Selector* SMESHGUI_SelectionOp::selector() const
+{
+  SVTK_ViewWindow* wnd = viewWindow();
+  return wnd ? wnd->GetSelector() : 0;
+}
+
+//=======================================================================
+// name    : typeById
+// Purpose : Find type by id
+//=======================================================================
+int SMESHGUI_SelectionOp::typeById( const QString& str, const EntityType objtype ) const
+{
+  SalomeApp_Study* _study = dynamic_cast<SalomeApp_Study*>( study() );
+  if( !_study )
+    return -1;
+
+  _PTR( Study ) st = _study->studyDS();
+
+  int res = -1;
+  if( objtype == Object )
+  {
+    SalomeApp_Study* _study = dynamic_cast<SalomeApp_Study*>( study() );
+    if( _study )
+    {
+      int t = SMESHGUI_Selection::type( str, _study->studyDS() );
+      if( t<0 )
+      {
+        //try to get GEOM type
+        _PTR( SObject ) sobj = st->FindObjectID( str.latin1() );
+        if( sobj )
+        {
+          GEOM::GEOM_Object_var obj = GEOM::GEOM_Object::_narrow( dynamic_cast<SALOMEDS_SObject*>( sobj.get() )->GetObject() );
+          if( !CORBA::is_nil( obj ) )
+            res = SMESHGUI_Dialog::prefix( "GEOM" ) + obj->GetType();
+        }
+      }
+      else
+        res = SMESHGUI_Dialog::prefix( "SMESH" ) + t;
+    }
+  }
+  else
+  {
+    int pos = str.find( idChar() );
+    QString entry = str.left( pos ),
+            _id = str.mid( pos+1 );
+    bool ok;
+    int id = _id.toInt( &ok );
+    if( ok )
+    {
+      _PTR( SObject ) sobj = st->FindObjectID( entry.latin1() );
+      SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( dynamic_cast<SALOMEDS_SObject*>( sobj.get() )->GetObject() );
+      SMESH::SMESH_subMesh_var submesh = SMESH::SMESH_subMesh::_narrow( dynamic_cast<SALOMEDS_SObject*>( sobj.get() )->GetObject() );
+      if( !CORBA::is_nil( mesh ) )
+        res = SMESHGUI_Dialog::prefix( "SMESH element" ) + mesh->GetElementType( id, objtype==MeshElement );
+
+      else if( !CORBA::is_nil( submesh ) )
+        res = SMESHGUI_Dialog::prefix( "SMESH element" ) + submesh->GetElementType( id, objtype==MeshElement );
+    }
+  }
+
+  return res;
+}
+
+//=======================================================================
+// name    : selected
+// Purpose : Get names, types and ids of selected objects
+//=======================================================================
+void SMESHGUI_SelectionOp::selected( QStringList& names,
+                                     SalomeApp_Dialog::TypesList& types,
+                                     QStringList& ids ) const
+{
+  SUIT_DataOwnerPtrList list; selectionMgr()->selected( list );
+  SUIT_DataOwnerPtrList::const_iterator anIt = list.begin(),
+                                        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->() );
+
+    if( vtkowner )
+    {
+      QString id_str = QString( "%1%2%3" ).arg( vtkowner->entry() ).arg( idChar() ), current_id_str;
+      Selection_Mode mode = vtkowner->GetMode();
+      EntityType objtype = mode == NodeSelection ? MeshNode : MeshElement;
+      const TColStd_IndexedMapOfInteger& ownerids = vtkowner->GetIds();
+
+      for( int i=1, n=ownerids.Extent(); i<=n; i++ )
+      {
+        int curid = ownerids( i );
+        current_id_str = id_str.arg( curid );
+        ids.append( current_id_str );
+        types.append( typeById( current_id_str, objtype ) );
+        names.append( QString( "%1" ).arg( curid ) );
+      }
+    }
+
+    else if( owner )
+    {
+      QString id = owner->entry();
+      ids.append( id );
+      types.append( typeById( id, Object ) );
+      names.append( owner->IO()->getName() );
+    }
+  }
+}
+
+//=======================================================================
+// name    : idChar
+// Purpose : Char using to divide <entry> and <id> in string id representation. By default, '#'
+//=======================================================================
+QChar SMESHGUI_SelectionOp::idChar() const
+{
+  return '#';
+}
+
+//=================================================================================
+// name     : mesh
+// purpose  :
+//=================================================================================
+SMESH::SMESH_Mesh_var SMESHGUI_SelectionOp::mesh() const
+{
+  if( selectionMode()==ActorSelection )
+    return SMESH::SMESH_Mesh::_nil();
+    
+  SALOME_ListIO sel; selectionMgr()->selectedObjects( sel, SVTK_Viewer::Type() );
+  if( sel.Extent()==1 )
+    return SMESH::GetMeshByIO( sel.First() );
+  else
+    return SMESH::SMESH_Mesh::_nil();
+}
+
+//=================================================================================
+// name     : actor
+// purpose  :
+//=================================================================================
+SMESH_Actor* SMESHGUI_SelectionOp::actor() const
+{
+  SMESH::SMESH_Mesh_var m = mesh();
+  if( !m->_is_nil() )
+    return SMESH::FindActorByObject( m.in() );
+  else
+    return 0;
+}
+
+//=================================================================================
+// name     : onTextChanged
+// purpose  :
+//=================================================================================
+void SMESHGUI_SelectionOp::onTextChanged( int, const QStringList& list )
+{
+    if( !dlg() )
+      return;
+
+    TColStd_MapOfInteger newIndices;
+
+    SALOME_ListIO sel; selectionMgr()->selectedObjects( sel );
+    SMESH_Actor* anActor = actor();
+    if( sel.Extent()==0 || !anActor )
+      return;
+
+    SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
+
+    IdList ids; extractIds( list, ids, '\0' );
+    IdList::const_iterator anIt = ids.begin(),
+                           aLast = ids.end();
+    for( ; anIt!=aLast; anIt++ )
+      if( const SMDS_MeshNode * n = aMesh->FindNode( *anIt ) )
+        newIndices.Add( n->GetID() );
+
+    selector()->AddOrRemoveIndex( sel.First(), newIndices, false );
+    highlight( sel.First(), true, true );
+
+    QStringList names, _ids; SalomeApp_Dialog::TypesList types;
+    selected( names, types, _ids );
+    dlg()->selectObject( names, types, _ids, false );
+}
+
+//=================================================================================
+// name     : selectedIds
+// purpose  :
+//=================================================================================
+void SMESHGUI_SelectionOp::selectedIds( const int id, IdList& list ) const
+{
+  if( !dlg() )
+    return;
+
+  QStringList ids; dlg()->selectedObject( id, ids );
+  extractIds( ids, list );
+}
+
+//=================================================================================
+// name     : extractIds
+// purpose  :
+//=================================================================================
+void SMESHGUI_SelectionOp::extractIds( const QStringList& ids, IdList& list, const QChar idchar )
+{
+  QStringList::const_iterator anIt = ids.begin(),
+                              aLast = ids.end();
+  QString id_str;
+  for( ; anIt!=aLast; anIt++ )
+  {
+    id_str = *anIt;
+    int pos = idchar=='\0' ? -1 : id_str.find( idchar );
+    int id = -1;
+    if( idchar=='\0' || pos>=0 )
+    {
+      id = id_str.mid( pos+1 ).toInt();
+      list.append( id );
+    }
+  }
+}
+
+//=================================================================================
+// name     : extractIds
+// purpose  :
+//=================================================================================
+void SMESHGUI_SelectionOp::extractIds( const QStringList& ids, IdList& list ) const
+{
+  extractIds( ids, list, idChar() );
+}
index 0f9893f374b4c9ab5317a5b44bd34c66b6b3f1f1..5dde0a05933ce789052c709e4ff86c562be83372 100644 (file)
 #define SMESHGUI_SelectionOp_H
 
 #include <SMESHGUI_Operation.h>
+#include <SMESHGUI_Dialog.h>
+#include <SVTK_Selection.h>
+#include <SALOME_InteractiveObject.hxx>
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Gen)
+
+
+class SUIT_SelectionFilter;
+class TColStd_MapOfInteger;
+class SVTK_ViewWindow;
+class SVTK_Selector;
+class SMESH_Actor;
 
 /*
   Class       : SMESHGUI_SelectionOp
   Description : Base operation for all operations using object selection in viewer or objectbrowser
                 through common widgets created by SalomeApp_Dialog::createObject
 */
-
-class SUIT_SelectionFilter;
-
 class SMESHGUI_SelectionOp : public SMESHGUI_Operation
 { 
   Q_OBJECT
 
+public:
+  typedef QValueList<int> IdList; //! List of node or element ids
+  
 public:
   SMESHGUI_SelectionOp( const Selection_Mode = ActorSelection );
   virtual ~SMESHGUI_SelectionOp();
+
+  static void  extractIds( const QStringList&, IdList&, const QChar );  
+
+protected:
+  typedef enum
+  {
+    Object,
+    MeshNode,
+    MeshElement
+
+  } EntityType;
+  /*!
+      This enumeration is used in typeById method to distinguish objects, mesh nodes and mesh elements,
+      because node end element ids may overlap
+  */
   
 protected:
   virtual void                  startOperation();
   virtual void                  commitOperation();
-  virtual void                  abortOperation();  
-  
+  virtual void                  abortOperation();
   virtual void                  selectionDone();
 
   //! sets the dialog widgets to state just after operation start
   virtual void                  initDialog();
 
-  /*! Creates filter being used when certain object selection widget is active
+  /*!
+   *  Creates filter being used when certain object selection widget is active
    *  If no filter must be used, then function must return 0
    *  if id is negative, then function must return filter for common using independently of active widget
    */
@@ -64,6 +92,44 @@ protected:
   //! Remove only filters set by this operation (they are in map myFilters )
   void removeCustomFilters() const;
 
+  //! Return what selection mode is set in VTK viewer
+  Selection_Mode    selectionMode() const;
+
+  //! Set selection mode in VTK viewer
+  void              setSelectionMode( const Selection_Mode );
+
+  //! Hilight object in VTK viewer
+  void              highlight( const Handle( SALOME_InteractiveObject )&,
+                               const bool, const bool = true );
+                               
+  //! Select some nodes or elements in VTK
+  void              addOrRemoveIndex( const Handle( SALOME_InteractiveObject )&,
+                                      const TColStd_MapOfInteger&, const bool );
+
+  SVTK_ViewWindow*  viewWindow() const;
+  SVTK_Selector*    selector() const;
+
+  //! Get names, types and ids of selected objects
+  virtual void      selected( QStringList&, SMESHGUI_Dialog::TypesList&, QStringList& ) const;
+
+  //! Find type by id
+  virtual int       typeById( const QString&, const EntityType ) const;
+
+  //! Char using to divide <entry> and <id> in string id representation. By default, '#'
+  virtual QChar     idChar() const;
+
+  //! Try to find in certain object selection widget selected node or element ids and return it
+  void                   selectedIds( const int, IdList& ) const;
+
+  //! Find in QStringList correct node or element ids representation and append integer(id) to IdList
+  void                   extractIds( const QStringList&, IdList& ) const;
+
+  //! Return selected mesh if selection mode isn't ActorSelection and only one object is selected
+  SMESH::SMESH_Mesh_var  mesh() const;
+
+  //! Return actor according to selected mesh if selection mode isn't ActorSelection
+  SMESH_Actor*           actor() const;
+  
 protected slots:
   //! Installs filter corresponding to certain object selection widget
   virtual void onActivateObject( int );
@@ -77,6 +143,15 @@ protected slots:
   */
   virtual void onSelectionChanged( int );
 
+  /*! Default implementation allowing user to edit selected ids "by hands".
+      In order to run default mechanism, you must set for some
+      object selection widget the "name indication" to "ListOfNames",
+      "read only" state to false and connect the dialog's signal "objectChanged"
+      to this slot
+      Warning: this mechanism can process only integer ids, NOT MESH OR GROUP NAMES!!!
+  */
+  virtual void  onTextChanged( int, const QStringList& );
+  
 private:
   typedef QMap<int, SUIT_SelectionFilter*> Filters;