*** empty log message ***

This commit is contained in:
asl 2005-07-14 08:43:43 +00:00
parent 241395cd3a
commit 44ff3c5c26
19 changed files with 462 additions and 607 deletions

View File

@ -116,8 +116,7 @@ LIB_SRC = SMESHGUI.cxx \
SMESHGUI_CreatePolyhedralVolumeDlg.cxx \ SMESHGUI_CreatePolyhedralVolumeDlg.cxx \
SMESHGUI_Dialog.cxx \ SMESHGUI_Dialog.cxx \
SMESHGUI_Operation.cxx \ SMESHGUI_Operation.cxx \
SMESHGUI_SelectionOp.cxx \ SMESHGUI_SelectionOp.cxx
SMESHGUI_SelectionIdsOp.cxx
LIB_MOC = \ LIB_MOC = \
SMESHGUI.h \ SMESHGUI.h \
@ -170,8 +169,7 @@ LIB_MOC = \
SMESHGUI_Dialog.h \ SMESHGUI_Dialog.h \
SMESHGUI_CreatePolyhedralVolumeDlg.h \ SMESHGUI_CreatePolyhedralVolumeDlg.h \
SMESHGUI_Operation.h \ SMESHGUI_Operation.h \
SMESHGUI_SelectionOp.h \ SMESHGUI_SelectionOp.h
SMESHGUI_SelectionIdsOp.h
LIB_CLIENT_IDL = SALOME_Exception.idl \ LIB_CLIENT_IDL = SALOME_Exception.idl \
GEOM_Gen.idl \ GEOM_Gen.idl \

View File

@ -27,7 +27,6 @@
// $Header$ // $Header$
#include "SMESHGUI_AddMeshElementDlg.h" #include "SMESHGUI_AddMeshElementDlg.h"
#include <SMESHGUI_Operation.h>
#include <SUIT_ResourceMgr.h> #include <SUIT_ResourceMgr.h>
@ -96,7 +95,7 @@ SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( const QString& elemName,
createObject( tr( "SMESH_ID_NODES" ), GroupC1, 0 ); createObject( tr( "SMESH_ID_NODES" ), GroupC1, 0 );
setNameIndication( 0, ListOfNames ); setNameIndication( 0, ListOfNames );
setReadOnly( 0, false ); setReadOnly( 0, false );
setObjectType( 0, SMESHGUI_Operation::prefix( "SMESH element" ) + SMDSAbs_Node, -1 ); setObjectType( 0, prefix( "SMESH element" ) + SMDSAbs_Node, -1 );
myReverse = 0; myReverse = 0;
if ( reverse ) { if ( reverse ) {

View File

@ -161,7 +161,7 @@ namespace SMESH {
// purpose : constructor // purpose : constructor
//================================================================================= //=================================================================================
SMESHGUI_AddMeshElementOp::SMESHGUI_AddMeshElementOp( const SMDSAbs_ElementType t, const int nbNodes ) SMESHGUI_AddMeshElementOp::SMESHGUI_AddMeshElementOp( const SMDSAbs_ElementType t, const int nbNodes )
: SMESHGUI_SelectionIdsOp( NodeSelection ), : SMESHGUI_SelectionOp( NodeSelection ),
myElementType( t ), myElementType( t ),
myNbNodes( nbNodes ), myNbNodes( nbNodes ),
myIsPoly( myElementType==SMDSAbs_Face && myNbNodes==5 ), myIsPoly( myElementType==SMDSAbs_Face && myNbNodes==5 ),
@ -212,10 +212,11 @@ void SMESHGUI_AddMeshElementOp::startOperation()
} }
myDlg = new SMESHGUI_AddMeshElementDlg( elemName, myElementType == SMDSAbs_Face ); 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 ) ) ); connect( myDlg, SIGNAL( reverse( int ) ), this, SLOT( onReverse( int ) ) );
} }
SMESHGUI_SelectionIdsOp::startOperation(); SMESHGUI_SelectionOp::startOperation();
mySimulation = new SMESH::TElementSimulation( viewWindow() ); mySimulation = new SMESH::TElementSimulation( viewWindow() );
updateDialog(); updateDialog();
@ -233,7 +234,7 @@ void SMESHGUI_AddMeshElementOp::onSelectionChanged( int id )
mySimulation->SetVisibility(false); mySimulation->SetVisibility(false);
SMESHGUI_SelectionIdsOp::onSelectionChanged( id ); SMESHGUI_SelectionOp::onSelectionChanged( id );
updateDialog(); updateDialog();
displaySimulation(); displaySimulation();
@ -248,7 +249,7 @@ void SMESHGUI_AddMeshElementOp::commitOperation()
if( mySimulation ) if( mySimulation )
delete mySimulation; delete mySimulation;
mySimulation = 0; mySimulation = 0;
SMESHGUI_SelectionIdsOp::commitOperation(); SMESHGUI_SelectionOp::commitOperation();
} }
//================================================================================= //=================================================================================
@ -260,7 +261,7 @@ void SMESHGUI_AddMeshElementOp::abortOperation()
if( mySimulation ) if( mySimulation )
delete mySimulation; delete mySimulation;
mySimulation = 0; mySimulation = 0;
SMESHGUI_SelectionIdsOp::abortOperation(); SMESHGUI_SelectionOp::abortOperation();
} }
//================================================================================= //=================================================================================

View File

@ -33,7 +33,7 @@ namespace SMESH{
struct TElementSimulation; struct TElementSimulation;
} }
#include <SMESHGUI_SelectionIdsOp.h> #include <SMESHGUI_SelectionOp.h>
#include <SMDSAbs_ElementType.hxx> #include <SMDSAbs_ElementType.hxx>
class SMESHGUI_AddMeshElementDlg; class SMESHGUI_AddMeshElementDlg;
@ -42,7 +42,7 @@ class SMESHGUI_AddMeshElementDlg;
// class : SMESHGUI_AddMeshElementOp // class : SMESHGUI_AddMeshElementOp
// purpose : // purpose :
//================================================================================= //=================================================================================
class SMESHGUI_AddMeshElementOp : public SMESHGUI_SelectionIdsOp class SMESHGUI_AddMeshElementOp : public SMESHGUI_SelectionOp
{ {
Q_OBJECT Q_OBJECT

View File

@ -27,7 +27,6 @@
// $Header$ // $Header$
#include "SMESHGUI_AddSubMeshDlg.h" #include "SMESHGUI_AddSubMeshDlg.h"
#include <SMESHGUI_Operation.h>
#include <SMESH_Type.h> #include <SMESH_Type.h>
@ -69,7 +68,7 @@ SMESHGUI_AddSubMeshDlg::SMESHGUI_AddSubMeshDlg()
setNameIndication( MeshObj, OneName ); setNameIndication( MeshObj, OneName );
setNameIndication( GeomObj, OneName ); setNameIndication( GeomObj, OneName );
int _smesh = SMESHGUI_Operation::prefix( "SMESH" ); int _smesh = prefix( "SMESH" );
setObjectType( Hypo, _smesh + HYPOTHESIS, -1 ); setObjectType( Hypo, _smesh + HYPOTHESIS, -1 );
setObjectType( Algo, _smesh + ALGORITHM, -1 ); setObjectType( Algo, _smesh + ALGORITHM, -1 );

View File

@ -27,7 +27,6 @@
// $Header$ // $Header$
#include <SMESHGUI_Dialog.h> #include <SMESHGUI_Dialog.h>
#include <SMESHGUI_Operation.h>
#include <SMESH_Type.h> #include <SMESH_Type.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
@ -39,10 +38,10 @@
SMESHGUI_Dialog::SMESHGUI_Dialog( const bool modal, const bool allowResize, const int flags ) SMESHGUI_Dialog::SMESHGUI_Dialog( const bool modal, const bool allowResize, const int flags )
: SalomeApp_Dialog( desktop(), "", modal, allowResize, flags ) : SalomeApp_Dialog( desktop(), "", modal, allowResize, flags )
{ {
int prefix = SMESHGUI_Operation::prefix( "SMESH" ); int pr = prefix( "SMESH" );
typeName( prefix + MESH ) = tr( "DLG_MESH" ); typeName( pr + MESH ) = tr( "DLG_MESH" );
typeName( prefix + HYPOTHESIS ) = tr( "DLG_HYPO" ); typeName( pr + HYPOTHESIS ) = tr( "DLG_HYPO" );
typeName( prefix + ALGORITHM ) = tr( "DLG_ALGO" ); typeName( pr + ALGORITHM ) = tr( "DLG_ALGO" );
} }
//================================================================================= //=================================================================================
@ -92,3 +91,19 @@ SUIT_Desktop* SMESHGUI_Dialog::desktop() const
} }
return d; 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;
}

View File

@ -51,6 +51,9 @@ public:
//! set all content to enable (parameter is true) or disable state //! set all content to enable (parameter is true) or disable state
void setContentActive( const bool ) const; void setContentActive( const bool ) const;
//! Return hard-coded prefix using to differ overlapping types
static int prefix( const QString& );
protected: protected:
//! find desktop of active application //! find desktop of active application
SUIT_Desktop* desktop() const; SUIT_Desktop* desktop() const;

View File

@ -28,7 +28,6 @@
#include "SMESHGUI_InitMeshDlg.h" #include "SMESHGUI_InitMeshDlg.h"
#include <SMESHGUI.h> #include <SMESHGUI.h>
#include <SMESHGUI_Operation.h>
#include <SMESH_Type.h> #include <SMESH_Type.h>
@ -68,7 +67,7 @@ SMESHGUI_InitMeshDlg::SMESHGUI_InitMeshDlg()
setNameIndication( GeomObj, OneName ); setNameIndication( GeomObj, OneName );
int _smesh = SMESHGUI_Operation::prefix( "SMESH" ); int _smesh = prefix( "SMESH" );
setObjectType( Hypo, _smesh + HYPOTHESIS, -1 ); setObjectType( Hypo, _smesh + HYPOTHESIS, -1 );
setObjectType( Algo, _smesh + ALGORITHM, -1 ); setObjectType( Algo, _smesh + ALGORITHM, -1 );

View File

@ -275,26 +275,23 @@ void SMESHGUI_NodesOp::selectionDone()
SMESH::SetPointRepresentation(true); SMESH::SetPointRepresentation(true);
const SALOME_ListIO& aList = selector()->StoredIObjects(); const SALOME_ListIO& aList = selector()->StoredIObjects();
if (aList.Extent() == 1) { if (aList.Extent() == 1)
{
Handle(SALOME_InteractiveObject) anIO = aList.First(); Handle(SALOME_InteractiveObject) anIO = aList.First();
if (anIO->hasEntry()) { if (anIO->hasEntry())
myMesh = SMESH::GetMeshByIO(anIO); {
if (myMesh->_is_nil()) return;
QString aText; QString aText;
if (SMESH::GetNameOfSelectedNodes(selector(),anIO,aText) == 1) { if( SMESH::GetNameOfSelectedNodes( selector(), anIO, aText ) == 1 )
if (SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh.in())) { if( SMESH_Actor* anActor = actor() )
if (SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh()) { if( SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh() )
if (const SMDS_MeshNode* aNode = aMesh->FindNode(aText.toInt())) { if( const SMDS_MeshNode* aNode = aMesh->FindNode( aText.toInt() ) )
myDlg->setCoords( aNode->X(), aNode->Y(), aNode->Z() ); myDlg->setCoords( aNode->X(), aNode->Y(), aNode->Z() );
}
}
}
}
double x, y, z;
myDlg->coords( x, y, z );
mySimulation->SetPosition( x, y, 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 ) if( getSMESHGUI()->isActiveStudyLocked() || !mySimulation )
return false; return false;
if (myMesh->_is_nil()) { if( mesh()->_is_nil()) {
SUIT_MessageBox::warn1( myDlg, tr("SMESH_WRN_WARNING"), SUIT_MessageBox::warn1( myDlg, tr("SMESH_WRN_WARNING"),
tr("MESH_IS_NOT_SELECTED"), tr("SMESH_BUT_OK")); tr("MESH_IS_NOT_SELECTED"), tr("SMESH_BUT_OK"));
return false; return false;
@ -323,7 +320,7 @@ bool SMESHGUI_NodesOp::onApply()
double x, y, z; myDlg->coords( x, y, z ); double x, y, z; myDlg->coords( x, y, z );
mySimulation->SetVisibility(false); mySimulation->SetVisibility(false);
SMESH::AddNode(myMesh,x,y,z); SMESH::AddNode( mesh(), x, y, z );
SMESH::SetPointRepresentation(true); SMESH::SetPointRepresentation(true);
// select myMesh // select myMesh
@ -337,7 +334,7 @@ bool SMESHGUI_NodesOp::onApply()
if (SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)) { if (SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)) {
if (anActor->hasIO()) { if (anActor->hasIO()) {
if (SMESH_MeshObj *aMeshObj = dynamic_cast<SMESH_MeshObj*>(anActor->GetObject().get())) { 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.Clear();
aList.Append(anActor->getIO()); aList.Append(anActor->getIO());
selectionMgr()->setSelectedObjects(aList, false); selectionMgr()->setSelectedObjects(aList, false);

View File

@ -35,13 +35,8 @@ namespace SMESH{
#include <SMESHGUI_SelectionOp.h> #include <SMESHGUI_SelectionOp.h>
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
class SMESHGUI_NodesDlg; class SMESHGUI_NodesDlg;
//================================================================================= //=================================================================================
// class : SMESHGUI_NodesOp // class : SMESHGUI_NodesOp
// purpose : // purpose :
@ -71,7 +66,6 @@ private slots:
void onValueChanged( double ); void onValueChanged( double );
private: private:
SMESH::SMESH_Mesh_var myMesh;
SMESH::TNodeSimulation* mySimulation; SMESH::TNodeSimulation* mySimulation;
SMESHGUI_NodesDlg* myDlg; SMESHGUI_NodesDlg* myDlg;
}; };

View File

@ -9,22 +9,13 @@
// Module : SALOME // Module : SALOME
#include "SMESHGUI_Operation.h" #include "SMESHGUI_Operation.h"
#include "SMESHGUI.h" #include <SMESHGUI.h>
#include "SMESHGUI_VTKUtils.h" #include <SMESHGUI_Dialog.h>
#include "SMESHGUI_Selection.h"
#include <SVTK_ViewWindow.h>
#include <SVTK_Selector.h>
#include <SUIT_MessageBox.h>
#include <SUIT_Desktop.h>
#include <SalomeApp_Study.h> #include <SalomeApp_Study.h>
#include <SalomeApp_VTKSelector.h>
#include <SalomeApp_SelectionMgr.h>
#include <SALOMEDS_SObject.hxx> #include <SUIT_MessageBox.h>
#include <SUIT_Desktop.h>
#include <SMESHDS_Mesh.hxx>
/* /*
Class : SMESHGUI_Operation 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 // name : getSMESHGUI
// Purpose : Get SMESH module // Purpose : Get SMESH module
@ -106,25 +48,6 @@ SMESHGUI* SMESHGUI_Operation::getSMESHGUI() const
return dynamic_cast<SMESHGUI*>( module() ); 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 // name : startOperation
// Purpose : Start opeartion // Purpose : Start opeartion
@ -167,7 +90,7 @@ bool SMESHGUI_Operation::isReadyToStart()
if ( getSMESHGUI() == 0 ) 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" ) ); tr( "NO_MODULE" ), tr( "SMESH_BUT_OK" ) );
return false; return false;
} }
@ -175,129 +98,6 @@ bool SMESHGUI_Operation::isReadyToStart()
return true; 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 // name : setDialogActive
// Purpose : // Purpose :

View File

@ -13,17 +13,9 @@
#define SMESHGUI_Operation_H #define SMESHGUI_Operation_H
#include <SalomeApp_Operation.h> #include <SalomeApp_Operation.h>
#include <SMESHGUI_Dialog.h>
#include <SALOME_InteractiveObject.hxx>
#include <SVTK_Selection.h>
#include <SALOMEDSClient.hxx> #include <SALOMEDSClient.hxx>
class SMESHGUI; class SMESHGUI;
class SVTK_ViewWindow;
class SVTK_Selector;
class TColStd_MapOfInteger;
/* /*
Class : SMESHGUI_Operation Class : SMESHGUI_Operation
@ -38,51 +30,20 @@ public:
SMESHGUI_Operation(); SMESHGUI_Operation();
virtual ~SMESHGUI_Operation(); virtual ~SMESHGUI_Operation();
static int prefix( const QString& );
// Return hard-coded prefix using to differ intersecting types
protected: 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 //! sets the dialog widgets to state just after operation start
virtual void initDialog(); virtual void initDialog();
virtual void startOperation(); virtual void startOperation();
virtual bool isReadyToStart(); virtual bool isReadyToStart();
//! Set according dialog active or inactive
virtual void setDialogActive( const bool );
SMESHGUI* getSMESHGUI() const; SMESHGUI* getSMESHGUI() const;
SVTK_ViewWindow* viewWindow() const;
SVTK_Selector* selector() const;
_PTR(Study) studyDS() 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: protected slots:
virtual void onOk(); virtual void onOk();
virtual bool onApply(); virtual bool onApply();

View File

@ -27,7 +27,6 @@
// $Header$ // $Header$
#include "SMESHGUI_RemoveNodesDlg.h" #include "SMESHGUI_RemoveNodesDlg.h"
#include <SMESHGUI_Operation.h>
#include <SUIT_ResourceMgr.h> #include <SUIT_ResourceMgr.h>
@ -90,7 +89,7 @@ SMESHGUI_RemoveNodesDlg::SMESHGUI_RemoveNodesDlg()
createObject( tr("SMESH_ID_NODES" ), GroupC1, 0 ); createObject( tr("SMESH_ID_NODES" ), GroupC1, 0 );
setNameIndication( 0, ListOfNames ); setNameIndication( 0, ListOfNames );
setReadOnly( 0, false ); setReadOnly( 0, false );
setObjectType( 0, SMESHGUI_Operation::prefix( "SMESH element" ) + SMDSAbs_Node, -1 ); setObjectType( 0, prefix( "SMESH element" ) + SMDSAbs_Node, -1 );
main->addWidget(GroupC1); main->addWidget(GroupC1);
} }

View File

@ -36,7 +36,7 @@
// purpose : // purpose :
//================================================================================= //=================================================================================
SMESHGUI_RemoveNodesOp::SMESHGUI_RemoveNodesOp() SMESHGUI_RemoveNodesOp::SMESHGUI_RemoveNodesOp()
: SMESHGUI_SelectionIdsOp( NodeSelection ), : SMESHGUI_SelectionOp( NodeSelection ),
myDlg( 0 ) myDlg( 0 )
{ {
} }
@ -67,9 +67,12 @@ SalomeApp_Dialog* SMESHGUI_RemoveNodesOp::dlg() const
void SMESHGUI_RemoveNodesOp::startOperation() void SMESHGUI_RemoveNodesOp::startOperation()
{ {
if( !myDlg ) if( !myDlg )
{
myDlg = new SMESHGUI_RemoveNodesDlg(); 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(); myDlg->show();
} }
@ -80,7 +83,7 @@ void SMESHGUI_RemoveNodesOp::startOperation()
//================================================================================= //=================================================================================
void SMESHGUI_RemoveNodesOp::selectionDone() void SMESHGUI_RemoveNodesOp::selectionDone()
{ {
SMESHGUI_SelectionIdsOp::selectionDone(); SMESHGUI_SelectionOp::selectionDone();
updateDialog(); updateDialog();
} }

View File

@ -29,7 +29,7 @@
#ifndef OPERATION_REMOVE_NODES_H #ifndef OPERATION_REMOVE_NODES_H
#define OPERATION_REMOVE_NODES_H #define OPERATION_REMOVE_NODES_H
#include <SMESHGUI_SelectionIdsOp.h> #include <SMESHGUI_SelectionOp.h>
class SMESHGUI_RemoveNodesDlg; class SMESHGUI_RemoveNodesDlg;
@ -37,7 +37,7 @@ class SMESHGUI_RemoveNodesDlg;
// class : SMESHGUI_RemoveNodesOp // class : SMESHGUI_RemoveNodesOp
// purpose : // purpose :
//================================================================================= //=================================================================================
class SMESHGUI_RemoveNodesOp : public SMESHGUI_SelectionIdsOp class SMESHGUI_RemoveNodesOp : public SMESHGUI_SelectionOp
{ {
Q_OBJECT Q_OBJECT

View File

@ -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() );
}

View File

@ -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

View File

@ -24,8 +24,24 @@
// Module : SMESH // Module : SMESH
#include <SMESHGUI_SelectionOp.h> #include <SMESHGUI_SelectionOp.h>
#include <SMESHGUI_VTKUtils.h>
#include <SMESHGUI_MeshUtils.h>
#include <SMESHGUI_Selection.h>
#include <SMESHGUI.h>
#include <SUIT_SelectionFilter.h> #include <SUIT_SelectionFilter.h>
#include <SalomeApp_SelectionMgr.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 Class : SMESHGUI_SelectionOp
@ -125,6 +141,18 @@ void SMESHGUI_SelectionOp::selectionDone()
if( !dlg() ) if( !dlg() )
return; 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; QStringList names, ids;
SalomeApp_Dialog::TypesList types; SalomeApp_Dialog::TypesList types;
selected( names, types, ids ); selected( names, types, ids );
@ -190,3 +218,286 @@ void SMESHGUI_SelectionOp::initDialog()
void SMESHGUI_SelectionOp::onSelectionChanged( int ) 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() );
}

View File

@ -28,34 +28,62 @@
#define SMESHGUI_SelectionOp_H #define SMESHGUI_SelectionOp_H
#include <SMESHGUI_Operation.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 Class : SMESHGUI_SelectionOp
Description : Base operation for all operations using object selection in viewer or objectbrowser Description : Base operation for all operations using object selection in viewer or objectbrowser
through common widgets created by SalomeApp_Dialog::createObject through common widgets created by SalomeApp_Dialog::createObject
*/ */
class SUIT_SelectionFilter;
class SMESHGUI_SelectionOp : public SMESHGUI_Operation class SMESHGUI_SelectionOp : public SMESHGUI_Operation
{ {
Q_OBJECT Q_OBJECT
public:
typedef QValueList<int> IdList; //! List of node or element ids
public: public:
SMESHGUI_SelectionOp( const Selection_Mode = ActorSelection ); SMESHGUI_SelectionOp( const Selection_Mode = ActorSelection );
virtual ~SMESHGUI_SelectionOp(); 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: protected:
virtual void startOperation(); virtual void startOperation();
virtual void commitOperation(); virtual void commitOperation();
virtual void abortOperation(); virtual void abortOperation();
virtual void selectionDone(); virtual void selectionDone();
//! sets the dialog widgets to state just after operation start //! sets the dialog widgets to state just after operation start
virtual void initDialog(); 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 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 * 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 ) //! Remove only filters set by this operation (they are in map myFilters )
void removeCustomFilters() const; 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: protected slots:
//! Installs filter corresponding to certain object selection widget //! Installs filter corresponding to certain object selection widget
virtual void onActivateObject( int ); virtual void onActivateObject( int );
@ -77,6 +143,15 @@ protected slots:
*/ */
virtual void onSelectionChanged( int ); 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: private:
typedef QMap<int, SUIT_SelectionFilter*> Filters; typedef QMap<int, SUIT_SelectionFilter*> Filters;