From: asl Date: Thu, 14 Jul 2005 08:43:43 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=44ff3c5c26f6374c986da9f8daf03ac81946a646;p=modules%2Fsmesh.git *** empty log message *** --- diff --git a/src/SMESHGUI/Makefile.in b/src/SMESHGUI/Makefile.in index ff2d7642e..448420647 100644 --- a/src/SMESHGUI/Makefile.in +++ b/src/SMESHGUI/Makefile.in @@ -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 \ diff --git a/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx index 707d1d4fb..fd0ff2270 100644 --- a/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx @@ -27,7 +27,6 @@ // $Header$ #include "SMESHGUI_AddMeshElementDlg.h" -#include #include @@ -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 ) { diff --git a/src/SMESHGUI/SMESHGUI_AddMeshElementOp.cxx b/src/SMESHGUI/SMESHGUI_AddMeshElementOp.cxx index 13836e792..5942cd6b6 100644 --- a/src/SMESHGUI/SMESHGUI_AddMeshElementOp.cxx +++ b/src/SMESHGUI/SMESHGUI_AddMeshElementOp.cxx @@ -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(); } //================================================================================= diff --git a/src/SMESHGUI/SMESHGUI_AddMeshElementOp.h b/src/SMESHGUI/SMESHGUI_AddMeshElementOp.h index 1a11a4ba9..555c21ee4 100644 --- a/src/SMESHGUI/SMESHGUI_AddMeshElementOp.h +++ b/src/SMESHGUI/SMESHGUI_AddMeshElementOp.h @@ -33,7 +33,7 @@ namespace SMESH{ struct TElementSimulation; } -#include +#include #include 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 diff --git a/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx b/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx index da520ad1a..4a098c8ec 100644 --- a/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx @@ -27,7 +27,6 @@ // $Header$ #include "SMESHGUI_AddSubMeshDlg.h" -#include #include @@ -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 ); diff --git a/src/SMESHGUI/SMESHGUI_Dialog.cxx b/src/SMESHGUI/SMESHGUI_Dialog.cxx index 3666b7c46..eff519e68 100644 --- a/src/SMESHGUI/SMESHGUI_Dialog.cxx +++ b/src/SMESHGUI/SMESHGUI_Dialog.cxx @@ -27,7 +27,6 @@ // $Header$ #include -#include #include #include #include @@ -39,10 +38,10 @@ 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; +} diff --git a/src/SMESHGUI/SMESHGUI_Dialog.h b/src/SMESHGUI/SMESHGUI_Dialog.h index 268b67ae7..927ac7b6c 100644 --- a/src/SMESHGUI/SMESHGUI_Dialog.h +++ b/src/SMESHGUI/SMESHGUI_Dialog.h @@ -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; diff --git a/src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx b/src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx index f687dfef0..edf7276ac 100644 --- a/src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx @@ -28,7 +28,6 @@ #include "SMESHGUI_InitMeshDlg.h" #include -#include #include @@ -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 ); diff --git a/src/SMESHGUI/SMESHGUI_NodesOp.cxx b/src/SMESHGUI/SMESHGUI_NodesOp.cxx index 59f5a7fb7..4e2f6ae3c 100644 --- a/src/SMESHGUI/SMESHGUI_NodesOp.cxx +++ b/src/SMESHGUI/SMESHGUI_NodesOp.cxx @@ -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(anAct)) { if (anActor->hasIO()) { if (SMESH_MeshObj *aMeshObj = dynamic_cast(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); diff --git a/src/SMESHGUI/SMESHGUI_NodesOp.h b/src/SMESHGUI/SMESHGUI_NodesOp.h index 45acb92f4..eb2564c47 100644 --- a/src/SMESHGUI/SMESHGUI_NodesOp.h +++ b/src/SMESHGUI/SMESHGUI_NodesOp.h @@ -35,13 +35,8 @@ namespace SMESH{ #include -// IDL Headers -#include -#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; }; diff --git a/src/SMESHGUI/SMESHGUI_Operation.cxx b/src/SMESHGUI/SMESHGUI_Operation.cxx index 0d46d002e..14c925ae0 100755 --- a/src/SMESHGUI/SMESHGUI_Operation.cxx +++ b/src/SMESHGUI/SMESHGUI_Operation.cxx @@ -9,22 +9,13 @@ // Module : SALOME #include "SMESHGUI_Operation.h" -#include "SMESHGUI.h" -#include "SMESHGUI_VTKUtils.h" -#include "SMESHGUI_Selection.h" - -#include -#include -#include -#include +#include +#include #include -#include -#include -#include - -#include +#include +#include /* 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( 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( study() ); - if( !_study ) - return -1; - - _PTR( Study ) st = _study->studyDS(); - - int res = -1; - if( objtype == Object ) - { - SalomeApp_Study* _study = dynamic_cast( 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( 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( sobj.get() )->GetObject() ); - SMESH::SMESH_subMesh_var submesh = SMESH::SMESH_subMesh::_narrow( dynamic_cast( 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( (*anIt).operator->() ); - SalomeApp_SVTKDataOwner* vtkowner = dynamic_cast( (*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 and in string id representation. By default, '#' -//======================================================================= -QChar SMESHGUI_Operation::idChar() const -{ - return '#'; -} - //======================================================================= // name : setDialogActive // Purpose : diff --git a/src/SMESHGUI/SMESHGUI_Operation.h b/src/SMESHGUI/SMESHGUI_Operation.h index 68542417a..89ec3f6b7 100755 --- a/src/SMESHGUI/SMESHGUI_Operation.h +++ b/src/SMESHGUI/SMESHGUI_Operation.h @@ -13,17 +13,9 @@ #define SMESHGUI_Operation_H #include -#include -#include -#include - #include 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 and 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(); diff --git a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx index 7185dd98c..3c00fef84 100644 --- a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx @@ -27,7 +27,6 @@ // $Header$ #include "SMESHGUI_RemoveNodesDlg.h" -#include #include @@ -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); } diff --git a/src/SMESHGUI/SMESHGUI_RemoveNodesOp.cxx b/src/SMESHGUI/SMESHGUI_RemoveNodesOp.cxx index c8145579e..15c443e65 100644 --- a/src/SMESHGUI/SMESHGUI_RemoveNodesOp.cxx +++ b/src/SMESHGUI/SMESHGUI_RemoveNodesOp.cxx @@ -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(); } diff --git a/src/SMESHGUI/SMESHGUI_RemoveNodesOp.h b/src/SMESHGUI/SMESHGUI_RemoveNodesOp.h index 5bd9ceb44..68af749bc 100644 --- a/src/SMESHGUI/SMESHGUI_RemoveNodesOp.h +++ b/src/SMESHGUI/SMESHGUI_RemoveNodesOp.h @@ -29,7 +29,7 @@ #ifndef OPERATION_REMOVE_NODES_H #define OPERATION_REMOVE_NODES_H -#include +#include 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 index 2436435d5..000000000 --- a/src/SMESHGUI/SMESHGUI_SelectionIdsOp.cxx +++ /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 -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include - -#include - -/* - 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 index f39e7747a..000000000 --- a/src/SMESHGUI/SMESHGUI_SelectionIdsOp.h +++ /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 - -#include -#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 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 diff --git a/src/SMESHGUI/SMESHGUI_SelectionOp.cxx b/src/SMESHGUI/SMESHGUI_SelectionOp.cxx index 4a497c68b..752903f0e 100644 --- a/src/SMESHGUI/SMESHGUI_SelectionOp.cxx +++ b/src/SMESHGUI/SMESHGUI_SelectionOp.cxx @@ -24,8 +24,24 @@ // Module : SMESH #include +#include +#include +#include +#include #include #include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include /* 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( study() ); + if( !_study ) + return -1; + + _PTR( Study ) st = _study->studyDS(); + + int res = -1; + if( objtype == Object ) + { + SalomeApp_Study* _study = dynamic_cast( 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( 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( sobj.get() )->GetObject() ); + SMESH::SMESH_subMesh_var submesh = SMESH::SMESH_subMesh::_narrow( dynamic_cast( 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( (*anIt).operator->() ); + SalomeApp_SVTKDataOwner* vtkowner = dynamic_cast( (*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 and 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() ); +} diff --git a/src/SMESHGUI/SMESHGUI_SelectionOp.h b/src/SMESHGUI/SMESHGUI_SelectionOp.h index 0f9893f37..5dde0a059 100644 --- a/src/SMESHGUI/SMESHGUI_SelectionOp.h +++ b/src/SMESHGUI/SMESHGUI_SelectionOp.h @@ -28,34 +28,62 @@ #define SMESHGUI_SelectionOp_H #include +#include +#include +#include + +#include +#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 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 and 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 Filters;