SMESHGUI_CreatePolyhedralVolumeDlg.cxx \
SMESHGUI_Dialog.cxx \
SMESHGUI_Operation.cxx \
- SMESHGUI_SelectionOp.cxx \
- SMESHGUI_SelectionIdsOp.cxx
+ SMESHGUI_SelectionOp.cxx
LIB_MOC = \
SMESHGUI.h \
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 \
// $Header$
#include "SMESHGUI_AddMeshElementDlg.h"
-#include <SMESHGUI_Operation.h>
#include <SUIT_ResourceMgr.h>
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 ) {
// 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 ),
}
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();
mySimulation->SetVisibility(false);
- SMESHGUI_SelectionIdsOp::onSelectionChanged( id );
+ SMESHGUI_SelectionOp::onSelectionChanged( id );
updateDialog();
displaySimulation();
if( mySimulation )
delete mySimulation;
mySimulation = 0;
- SMESHGUI_SelectionIdsOp::commitOperation();
+ SMESHGUI_SelectionOp::commitOperation();
}
//=================================================================================
if( mySimulation )
delete mySimulation;
mySimulation = 0;
- SMESHGUI_SelectionIdsOp::abortOperation();
+ SMESHGUI_SelectionOp::abortOperation();
}
//=================================================================================
struct TElementSimulation;
}
-#include <SMESHGUI_SelectionIdsOp.h>
+#include <SMESHGUI_SelectionOp.h>
#include <SMDSAbs_ElementType.hxx>
class SMESHGUI_AddMeshElementDlg;
// class : SMESHGUI_AddMeshElementOp
// purpose :
//=================================================================================
-class SMESHGUI_AddMeshElementOp : public SMESHGUI_SelectionIdsOp
+class SMESHGUI_AddMeshElementOp : public SMESHGUI_SelectionOp
{
Q_OBJECT
// $Header$
#include "SMESHGUI_AddSubMeshDlg.h"
-#include <SMESHGUI_Operation.h>
#include <SMESH_Type.h>
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 );
// $Header$
#include <SMESHGUI_Dialog.h>
-#include <SMESHGUI_Operation.h>
#include <SMESH_Type.h>
#include <SUIT_Session.h>
#include <SalomeApp_Application.h>
SMESHGUI_Dialog::SMESHGUI_Dialog( const bool modal, const bool allowResize, const int flags )
: SalomeApp_Dialog( desktop(), "", modal, allowResize, flags )
{
- int prefix = SMESHGUI_Operation::prefix( "SMESH" );
- typeName( prefix + MESH ) = tr( "DLG_MESH" );
- typeName( prefix + HYPOTHESIS ) = tr( "DLG_HYPO" );
- typeName( prefix + ALGORITHM ) = tr( "DLG_ALGO" );
+ int pr = prefix( "SMESH" );
+ typeName( pr + MESH ) = tr( "DLG_MESH" );
+ typeName( pr + HYPOTHESIS ) = tr( "DLG_HYPO" );
+ typeName( pr + ALGORITHM ) = tr( "DLG_ALGO" );
}
//=================================================================================
}
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;
+}
//! 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;
#include "SMESHGUI_InitMeshDlg.h"
#include <SMESHGUI.h>
-#include <SMESHGUI_Operation.h>
#include <SMESH_Type.h>
setNameIndication( GeomObj, OneName );
- int _smesh = SMESHGUI_Operation::prefix( "SMESH" );
+ int _smesh = prefix( "SMESH" );
setObjectType( Hypo, _smesh + HYPOTHESIS, -1 );
setObjectType( Algo, _smesh + ALGORITHM, -1 );
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 );
}
//=================================================================================
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;
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
if (SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)) {
if (anActor->hasIO()) {
if (SMESH_MeshObj *aMeshObj = dynamic_cast<SMESH_MeshObj*>(anActor->GetObject().get())) {
- if (myMesh->_is_equivalent(aMeshObj->GetMeshServer())) {
+ if ( mesh()->_is_equivalent(aMeshObj->GetMeshServer())) {
aList.Clear();
aList.Append(anActor->getIO());
selectionMgr()->setSelectedObjects(aList, false);
#include <SMESHGUI_SelectionOp.h>
-// IDL Headers
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER(SMESH_Mesh)
-
class SMESHGUI_NodesDlg;
-
//=================================================================================
// class : SMESHGUI_NodesOp
// purpose :
void onValueChanged( double );
private:
- SMESH::SMESH_Mesh_var myMesh;
SMESH::TNodeSimulation* mySimulation;
SMESHGUI_NodesDlg* myDlg;
};
// Module : SALOME
#include "SMESHGUI_Operation.h"
-#include "SMESHGUI.h"
-#include "SMESHGUI_VTKUtils.h"
-#include "SMESHGUI_Selection.h"
-
-#include <SVTK_ViewWindow.h>
-#include <SVTK_Selector.h>
-#include <SUIT_MessageBox.h>
-#include <SUIT_Desktop.h>
+#include <SMESHGUI.h>
+#include <SMESHGUI_Dialog.h>
#include <SalomeApp_Study.h>
-#include <SalomeApp_VTKSelector.h>
-#include <SalomeApp_SelectionMgr.h>
-#include <SALOMEDS_SObject.hxx>
-
-#include <SMESHDS_Mesh.hxx>
+#include <SUIT_MessageBox.h>
+#include <SUIT_Desktop.h>
/*
Class : SMESHGUI_Operation
{
}
-//=======================================================================
-// 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
return dynamic_cast<SMESHGUI*>( module() );
}
-//=======================================================================
-// name : viewWindow
-// Purpose : Get active view window
-//=======================================================================
-SVTK_ViewWindow* SMESHGUI_Operation::viewWindow() const
-{
- return SMESH::GetViewWindow( getSMESHGUI() );
-}
-
-//=======================================================================
-// name : selector
-// Purpose : Get selector
-//=======================================================================
-SVTK_Selector* SMESHGUI_Operation::selector() const
-{
- SVTK_ViewWindow* wnd = viewWindow();
- return wnd ? wnd->GetSelector() : 0;
-}
-
//=======================================================================
// name : startOperation
// Purpose : Start opeartion
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;
}
return true;
}
-//=======================================================================
-// name : typeById
-// Purpose : Find type by id
-//=======================================================================
-int SMESHGUI_Operation::typeById( const QString& str, const SelectedObjectType objtype ) const
-{
- SalomeApp_Study* _study = dynamic_cast<SalomeApp_Study*>( study() );
- if( !_study )
- return -1;
-
- _PTR( Study ) st = _study->studyDS();
-
- int res = -1;
- if( objtype == Object )
- {
- SalomeApp_Study* _study = dynamic_cast<SalomeApp_Study*>( study() );
- if( _study )
- {
- int t = SMESHGUI_Selection::type( str, _study->studyDS() );
- if( t<0 )
- {
- //try to get GEOM type
- _PTR( SObject ) sobj = st->FindObjectID( str.latin1() );
- if( sobj )
- {
- GEOM::GEOM_Object_var obj = GEOM::GEOM_Object::_narrow( dynamic_cast<SALOMEDS_SObject*>( sobj.get() )->GetObject() );
- if( !CORBA::is_nil( obj ) )
- res = prefix( "GEOM" ) + obj->GetType();
- }
- }
- else
- res = prefix( "SMESH" ) + t;
- }
- }
- else
- {
- int pos = str.find( idChar() );
- QString entry = str.left( pos ),
- _id = str.mid( pos+1 );
- bool ok;
- int id = _id.toInt( &ok );
- if( ok )
- {
- _PTR( SObject ) sobj = st->FindObjectID( entry.latin1() );
- SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( dynamic_cast<SALOMEDS_SObject*>( sobj.get() )->GetObject() );
- SMESH::SMESH_subMesh_var submesh = SMESH::SMESH_subMesh::_narrow( dynamic_cast<SALOMEDS_SObject*>( sobj.get() )->GetObject() );
- if( !CORBA::is_nil( mesh ) )
- res = prefix( "SMESH element" ) + mesh->GetElementType( id, objtype==MeshElement );
-
- else if( !CORBA::is_nil( submesh ) )
- res = prefix( "SMESH element" ) + submesh->GetElementType( id, objtype==MeshElement );
- }
- }
-
- return res;
-}
-
-//=======================================================================
-// name : prefix
-// Purpose : Get prefix for module types
-//=======================================================================
-int SMESHGUI_Operation::prefix( const QString& name )
-{
- if( name == "GEOM" )
- return 100;
- else if( name == "SMESH" )
- return 200;
- else if( name == "SMESH element" )
- return 300;
- else
- return 0;
-}
-
-//=======================================================================
-// name : selected
-// Purpose : Get names, types and ids of selected objects
-//=======================================================================
-void SMESHGUI_Operation::selected( QStringList& names, SalomeApp_Dialog::TypesList& types, QStringList& ids ) const
-{
- SUIT_DataOwnerPtrList list; selectionMgr()->selected( list );
- SUIT_DataOwnerPtrList::const_iterator anIt = list.begin(),
- aLast = list.end();
- for( ; anIt!=aLast; anIt++ )
- {
- SalomeApp_DataOwner* owner = dynamic_cast<SalomeApp_DataOwner*>( (*anIt).operator->() );
- SalomeApp_SVTKDataOwner* vtkowner = dynamic_cast<SalomeApp_SVTKDataOwner*>( (*anIt).operator->() );
-
- if( vtkowner )
- {
- QString id_str = QString( "%1%2%3" ).arg( vtkowner->entry() ).arg( idChar() ), current_id_str;
- Selection_Mode mode = vtkowner->GetMode();
- SelectedObjectType objtype = mode == NodeSelection ? MeshNode : MeshElement;
- const TColStd_IndexedMapOfInteger& ownerids = vtkowner->GetIds();
-
- for( int i=1, n=ownerids.Extent(); i<=n; i++ )
- {
- int curid = ownerids( i );
- current_id_str = id_str.arg( curid );
- ids.append( current_id_str );
- types.append( typeById( current_id_str, objtype ) );
- names.append( QString( "%1" ).arg( curid ) );
- }
- }
-
- else if( owner )
- {
- QString id = owner->entry();
- ids.append( id );
- types.append( typeById( id, Object ) );
- names.append( owner->IO()->getName() );
- }
- }
-}
-
-//=======================================================================
-// name : idChar
-// Purpose : Char using to divide <entry> and <id> in string id representation. By default, '#'
-//=======================================================================
-QChar SMESHGUI_Operation::idChar() const
-{
- return '#';
-}
-
//=======================================================================
// name : setDialogActive
// Purpose :
#define SMESHGUI_Operation_H
#include <SalomeApp_Operation.h>
-#include <SMESHGUI_Dialog.h>
-#include <SALOME_InteractiveObject.hxx>
-#include <SVTK_Selection.h>
-
#include <SALOMEDSClient.hxx>
class SMESHGUI;
-class SVTK_ViewWindow;
-class SVTK_Selector;
-class TColStd_MapOfInteger;
-
/*
Class : SMESHGUI_Operation
SMESHGUI_Operation();
virtual ~SMESHGUI_Operation();
- static int prefix( const QString& );
- // Return hard-coded prefix using to differ intersecting types
-
-protected:
- typedef enum
- {
- Object,
- MeshNode,
- MeshElement
-
- } SelectedObjectType;
-
protected:
- Selection_Mode selectionMode() const;
- void setSelectionMode( const Selection_Mode );
- void highlight( const Handle( SALOME_InteractiveObject )&,
- const bool, const bool = true );
- void addOrRemoveIndex( const Handle( SALOME_InteractiveObject )&,
- const TColStd_MapOfInteger&, const bool );
-
//! sets the dialog widgets to state just after operation start
virtual void initDialog();
virtual void startOperation();
virtual bool isReadyToStart();
+
+ //! Set according dialog active or inactive
+ virtual void setDialogActive( const bool );
SMESHGUI* getSMESHGUI() const;
- SVTK_ViewWindow* viewWindow() const;
- SVTK_Selector* selector() const;
_PTR(Study) studyDS() const;
-
- //! Get names, types and ids of selected objects
- virtual void selected( QStringList&, SMESHGUI_Dialog::TypesList&, QStringList& ) const;
-
- //! Find type by id
- virtual int typeById( const QString&, const SelectedObjectType ) const;
-
- //! Char using to divide <entry> and <id> in string id representation. By default, '#'
- virtual QChar idChar() const;
-
- //! Set accroding dialog active or inactive
- virtual void setDialogActive( const bool );
-
protected slots:
virtual void onOk();
virtual bool onApply();
// $Header$
#include "SMESHGUI_RemoveNodesDlg.h"
-#include <SMESHGUI_Operation.h>
#include <SUIT_ResourceMgr.h>
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);
}
// purpose :
//=================================================================================
SMESHGUI_RemoveNodesOp::SMESHGUI_RemoveNodesOp()
-: SMESHGUI_SelectionIdsOp( NodeSelection ),
+: SMESHGUI_SelectionOp( NodeSelection ),
myDlg( 0 )
{
}
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();
}
//=================================================================================
void SMESHGUI_RemoveNodesOp::selectionDone()
{
- SMESHGUI_SelectionIdsOp::selectionDone();
+ SMESHGUI_SelectionOp::selectionDone();
updateDialog();
}
#ifndef OPERATION_REMOVE_NODES_H
#define OPERATION_REMOVE_NODES_H
-#include <SMESHGUI_SelectionIdsOp.h>
+#include <SMESHGUI_SelectionOp.h>
class SMESHGUI_RemoveNodesDlg;
// class : SMESHGUI_RemoveNodesOp
// purpose :
//=================================================================================
-class SMESHGUI_RemoveNodesOp : public SMESHGUI_SelectionIdsOp
+class SMESHGUI_RemoveNodesOp : public SMESHGUI_SelectionOp
{
Q_OBJECT
+++ /dev/null
-// 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() );
-}
+++ /dev/null
-// 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
// Module : SMESH
#include <SMESHGUI_SelectionOp.h>
+#include <SMESHGUI_VTKUtils.h>
+#include <SMESHGUI_MeshUtils.h>
+#include <SMESHGUI_Selection.h>
+#include <SMESHGUI.h>
#include <SUIT_SelectionFilter.h>
#include <SalomeApp_SelectionMgr.h>
+#include <SalomeApp_Study.h>
+#include <SalomeApp_VTKSelector.h>
+#include <SVTK_ViewWindow.h>
+#include <SVTK_ViewModel.h>
+#include <SVTK_Selector.h>
+#include <SMESH_Actor.h>
+
+#include <SMDS_Mesh.hxx>
+#include <SMDS_MeshNode.hxx>
+
+#include CORBA_SERVER_HEADER(GEOM_Gen)
+#include <SALOMEDS_SObject.hxx>
/*
Class : SMESHGUI_SelectionOp
{
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;
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() );
+}
#define SMESHGUI_SelectionOp_H
#include <SMESHGUI_Operation.h>
+#include <SMESHGUI_Dialog.h>
+#include <SVTK_Selection.h>
+#include <SALOME_InteractiveObject.hxx>
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Gen)
+
+
+class SUIT_SelectionFilter;
+class TColStd_MapOfInteger;
+class SVTK_ViewWindow;
+class SVTK_Selector;
+class SMESH_Actor;
/*
Class : SMESHGUI_SelectionOp
Description : Base operation for all operations using object selection in viewer or objectbrowser
through common widgets created by SalomeApp_Dialog::createObject
*/
-
-class SUIT_SelectionFilter;
-
class SMESHGUI_SelectionOp : public SMESHGUI_Operation
{
Q_OBJECT
+public:
+ typedef QValueList<int> IdList; //! List of node or element ids
+
public:
SMESHGUI_SelectionOp( const Selection_Mode = ActorSelection );
virtual ~SMESHGUI_SelectionOp();
+
+ static void extractIds( const QStringList&, IdList&, const QChar );
+
+protected:
+ typedef enum
+ {
+ Object,
+ MeshNode,
+ MeshElement
+
+ } EntityType;
+ /*!
+ This enumeration is used in typeById method to distinguish objects, mesh nodes and mesh elements,
+ because node end element ids may overlap
+ */
protected:
virtual void startOperation();
virtual void commitOperation();
- virtual void abortOperation();
-
+ virtual void abortOperation();
virtual void selectionDone();
//! sets the dialog widgets to state just after operation start
virtual void initDialog();
- /*! Creates filter being used when certain object selection widget is active
+ /*!
+ * Creates filter being used when certain object selection widget is active
* If no filter must be used, then function must return 0
* if id is negative, then function must return filter for common using independently of active widget
*/
//! Remove only filters set by this operation (they are in map myFilters )
void removeCustomFilters() const;
+ //! Return what selection mode is set in VTK viewer
+ Selection_Mode selectionMode() const;
+
+ //! Set selection mode in VTK viewer
+ void setSelectionMode( const Selection_Mode );
+
+ //! Hilight object in VTK viewer
+ void highlight( const Handle( SALOME_InteractiveObject )&,
+ const bool, const bool = true );
+
+ //! Select some nodes or elements in VTK
+ void addOrRemoveIndex( const Handle( SALOME_InteractiveObject )&,
+ const TColStd_MapOfInteger&, const bool );
+
+ SVTK_ViewWindow* viewWindow() const;
+ SVTK_Selector* selector() const;
+
+ //! Get names, types and ids of selected objects
+ virtual void selected( QStringList&, SMESHGUI_Dialog::TypesList&, QStringList& ) const;
+
+ //! Find type by id
+ virtual int typeById( const QString&, const EntityType ) const;
+
+ //! Char using to divide <entry> and <id> in string id representation. By default, '#'
+ virtual QChar idChar() const;
+
+ //! Try to find in certain object selection widget selected node or element ids and return it
+ void selectedIds( const int, IdList& ) const;
+
+ //! Find in QStringList correct node or element ids representation and append integer(id) to IdList
+ void extractIds( const QStringList&, IdList& ) const;
+
+ //! Return selected mesh if selection mode isn't ActorSelection and only one object is selected
+ SMESH::SMESH_Mesh_var mesh() const;
+
+ //! Return actor according to selected mesh if selection mode isn't ActorSelection
+ SMESH_Actor* actor() const;
+
protected slots:
//! Installs filter corresponding to certain object selection widget
virtual void onActivateObject( int );
*/
virtual void onSelectionChanged( int );
+ /*! Default implementation allowing user to edit selected ids "by hands".
+ In order to run default mechanism, you must set for some
+ object selection widget the "name indication" to "ListOfNames",
+ "read only" state to false and connect the dialog's signal "objectChanged"
+ to this slot
+ Warning: this mechanism can process only integer ids, NOT MESH OR GROUP NAMES!!!
+ */
+ virtual void onTextChanged( int, const QStringList& );
+
private:
typedef QMap<int, SUIT_SelectionFilter*> Filters;