From 241395cd3a83a3761d1840c16bf7b32da78fc6e5 Mon Sep 17 00:00:00 2001 From: asl Date: Thu, 14 Jul 2005 05:01:00 +0000 Subject: [PATCH] *** empty log message *** --- src/SMESHGUI/Makefile.in | 8 +- src/SMESHGUI/SMESHGUI.cxx | 13 +- src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx | 9 - src/SMESHGUI/SMESHGUI_AddMeshElementDlg.h | 1 - src/SMESHGUI/SMESHGUI_AddMeshElementOp.cxx | 112 +---- src/SMESHGUI/SMESHGUI_AddMeshElementOp.h | 13 +- src/SMESHGUI/SMESHGUI_GroupOp.cxx | 2 +- src/SMESHGUI/SMESHGUI_NodesOp.cxx | 1 - src/SMESHGUI/SMESHGUI_Operation.cxx | 7 +- src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx | 433 ++------------------ src/SMESHGUI/SMESHGUI_RemoveNodesDlg.h | 84 +--- src/SMESHGUI/SMESHGUI_RemoveNodesOp.cxx | 135 ++++++ src/SMESHGUI/SMESHGUI_RemoveNodesOp.h | 63 +++ src/SMESHGUI/SMESHGUI_SelectionIdsOp.cxx | 221 ++++++++++ src/SMESHGUI/SMESHGUI_SelectionIdsOp.h | 78 ++++ src/SMESHGUI/SMESHGUI_VTKUtils.cxx | 2 + 16 files changed, 570 insertions(+), 612 deletions(-) create mode 100644 src/SMESHGUI/SMESHGUI_RemoveNodesOp.cxx create mode 100644 src/SMESHGUI/SMESHGUI_RemoveNodesOp.h create mode 100644 src/SMESHGUI/SMESHGUI_SelectionIdsOp.cxx create mode 100644 src/SMESHGUI/SMESHGUI_SelectionIdsOp.h diff --git a/src/SMESHGUI/Makefile.in b/src/SMESHGUI/Makefile.in index fe959bda1..ff2d7642e 100644 --- a/src/SMESHGUI/Makefile.in +++ b/src/SMESHGUI/Makefile.in @@ -70,6 +70,7 @@ LIB_SRC = SMESHGUI.cxx \ SMESHGUI_ClippingDlg.cxx \ SMESHGUI_GroupDlg.cxx \ SMESHGUI_RemoveNodesDlg.cxx \ + SMESHGUI_RemoveNodesOp.cxx \ SMESHGUI_RemoveElementsDlg.cxx \ SMESHGUI_MeshInfosDlg.cxx \ SMESHGUI_StandardMeshInfosDlg.cxx \ @@ -115,7 +116,8 @@ LIB_SRC = SMESHGUI.cxx \ SMESHGUI_CreatePolyhedralVolumeDlg.cxx \ SMESHGUI_Dialog.cxx \ SMESHGUI_Operation.cxx \ - SMESHGUI_SelectionOp.cxx + SMESHGUI_SelectionOp.cxx \ + SMESHGUI_SelectionIdsOp.cxx LIB_MOC = \ SMESHGUI.h \ @@ -135,6 +137,7 @@ LIB_MOC = \ SMESHGUI_ClippingDlg.h \ SMESHGUI_GroupDlg.h \ SMESHGUI_RemoveNodesDlg.h \ + SMESHGUI_RemoveNodesOp.h \ SMESHGUI_RemoveElementsDlg.h \ SMESHGUI_MeshInfosDlg.h \ SMESHGUI_StandardMeshInfosDlg.h \ @@ -167,7 +170,8 @@ LIB_MOC = \ SMESHGUI_Dialog.h \ SMESHGUI_CreatePolyhedralVolumeDlg.h \ SMESHGUI_Operation.h \ - SMESHGUI_SelectionOp.h + SMESHGUI_SelectionOp.h \ + SMESHGUI_SelectionIdsOp.h LIB_CLIENT_IDL = SALOME_Exception.idl \ GEOM_Gen.idl \ diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 0daf4dd4c..2d215dc02 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -31,7 +31,7 @@ #include "SMESHGUI_TransparencyDlg.h" #include "SMESHGUI_ClippingDlg.h" #include "SMESHGUI_GroupDlg.h" -#include "SMESHGUI_RemoveNodesDlg.h" +#include "SMESHGUI_RemoveNodesOp.h" #include "SMESHGUI_RemoveElementsDlg.h" #include "SMESHGUI_MeshInfosDlg.h" #include "SMESHGUI_StandardMeshInfosDlg.h" @@ -2031,7 +2031,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) case 4041: // REMOVES NODES { if(checkLock(aStudy)) break; - if ( vtkwnd ) { + startOperation( 4041 ); +/* if ( vtkwnd ) { EmitSignalDeactivateDialog(); new SMESHGUI_RemoveNodesDlg(this); } @@ -2039,7 +2040,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) SUIT_MessageBox::warn1(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), tr("SMESH_BUT_OK")); - } + }*/ break; } case 4042: // REMOVES ELEMENTS @@ -3319,7 +3320,11 @@ SalomeApp_Operation* SMESHGUI::createOperation( const int id ) const case 4032: op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Volume, 8 ); break; - + + case 4041: + op = new SMESHGUI_RemoveNodesOp(); + break; + case 702: op = new SMESHGUI_AddSubMeshOp(); break; diff --git a/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx index 55629dfb7..707d1d4fb 100644 --- a/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx @@ -129,12 +129,3 @@ bool SMESHGUI_AddMeshElementDlg::isReverse() const else return false; } - -//================================================================================= -// function : ~SMESHGUI_AddMeshElementDlg() -// purpose : Destroys the object and frees any allocated resources -//================================================================================= -void SMESHGUI_AddMeshElementDlg::setBusy( const bool b ) -{ - myIsBusy = b; -} diff --git a/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.h b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.h index e4aa5b58b..aec5bacc3 100644 --- a/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.h +++ b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.h @@ -46,7 +46,6 @@ public: ~SMESHGUI_AddMeshElementDlg(); bool isReverse() const; - void setBusy( const bool ); signals: void reverse( int ); diff --git a/src/SMESHGUI/SMESHGUI_AddMeshElementOp.cxx b/src/SMESHGUI/SMESHGUI_AddMeshElementOp.cxx index fee223ec9..13836e792 100644 --- a/src/SMESHGUI/SMESHGUI_AddMeshElementOp.cxx +++ b/src/SMESHGUI/SMESHGUI_AddMeshElementOp.cxx @@ -37,22 +37,13 @@ #include #include #include -#include #include -#include - -#include #include #include #include #include -#include - -#include -#include - namespace SMESH { class TElementSimulation { @@ -170,7 +161,7 @@ namespace SMESH { // purpose : constructor //================================================================================= SMESHGUI_AddMeshElementOp::SMESHGUI_AddMeshElementOp( const SMDSAbs_ElementType t, const int nbNodes ) -: SMESHGUI_SelectionOp( NodeSelection ), +: SMESHGUI_SelectionIdsOp( NodeSelection ), myElementType( t ), myNbNodes( nbNodes ), myIsPoly( myElementType==SMDSAbs_Face && myNbNodes==5 ), @@ -221,13 +212,10 @@ void SMESHGUI_AddMeshElementOp::startOperation() } myDlg = new SMESHGUI_AddMeshElementDlg( elemName, myElementType == SMDSAbs_Face ); - connect( myDlg, SIGNAL( objectChanged( int, const QStringList& ) ), - this, SLOT( onTextChanged( int, const QStringList& ) ) ); - connect( myDlg, SIGNAL( dlgClose() ), this, SLOT( onCancel() ) ); connect( myDlg, SIGNAL( reverse( int ) ), this, SLOT( onReverse( int ) ) ); } - SMESHGUI_SelectionOp::startOperation(); + SMESHGUI_SelectionIdsOp::startOperation(); mySimulation = new SMESH::TElementSimulation( viewWindow() ); updateDialog(); @@ -235,29 +223,17 @@ void SMESHGUI_AddMeshElementOp::startOperation() } //================================================================================= -// function : selectionDone() +// function : onSelectionChanged() // purpose : //================================================================================= -void SMESHGUI_AddMeshElementOp::selectionDone() +void SMESHGUI_AddMeshElementOp::onSelectionChanged( int id ) { if( !mySimulation ) return; mySimulation->SetVisibility(false); - // get selected mesh - SALOME_ListIO aList; - selectionMgr()->selectedObjects(aList,SVTK_Viewer::Type()); - - if( aList.Extent() != 1) - return; - - Handle(SALOME_InteractiveObject) anIO = aList.First(); - myMesh = SMESH::GetMeshByIO(anIO); - - QStringList names, ids; SalomeApp_Dialog::TypesList types; - selected( names, types, ids ); - myDlg->selectObject( names, types, ids ); + SMESHGUI_SelectionIdsOp::onSelectionChanged( id ); updateDialog(); displaySimulation(); @@ -272,7 +248,7 @@ void SMESHGUI_AddMeshElementOp::commitOperation() if( mySimulation ) delete mySimulation; mySimulation = 0; - SMESHGUI_SelectionOp::commitOperation(); + SMESHGUI_SelectionIdsOp::commitOperation(); } //================================================================================= @@ -284,7 +260,7 @@ void SMESHGUI_AddMeshElementOp::abortOperation() if( mySimulation ) delete mySimulation; mySimulation = 0; - SMESHGUI_SelectionOp::abortOperation(); + SMESHGUI_SelectionIdsOp::abortOperation(); } //================================================================================= @@ -296,7 +272,7 @@ bool SMESHGUI_AddMeshElementOp::onApply() if( !mySimulation ) return false; - QStringList ids; myDlg->selectedObject( 0, ids ); + IdList ids; selectedIds( 0, ids ); if( ids.count()>=myNbNodes && !getSMESHGUI()->isActiveStudyLocked() ) { //myBusy = true; SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array; @@ -305,25 +281,13 @@ bool SMESHGUI_AddMeshElementOp::onApply() for (int i = 0; i < myNbNodes; i++) { - QString id_str = ids[ i ]; - int pos = id_str.find( idChar() ); - int id = -1; - if( pos>=0 ) - id = id_str.mid( pos+1 ).toInt(); - - if( id==-1 ) - { - printf( "SMESHGUI_AddMeshElementOp::onApply(): Error!!!\n" ); - return false; - } - if (reverse) - anArrayOfIdeces[ myNbNodes - i - 1 ] = id; + anArrayOfIdeces[ myNbNodes - i - 1 ] = ids[i]; else - anArrayOfIdeces[i] = id; + anArrayOfIdeces[i] = ids[i]; } - SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + SMESH::SMESH_MeshEditor_var aMeshEditor = mesh()->GetMeshEditor(); switch (myElementType) { case SMDSAbs_Edge: aMeshEditor->AddEdge(anArrayOfIdeces.inout()); break; @@ -348,65 +312,23 @@ bool SMESHGUI_AddMeshElementOp::onApply() return false; } -//================================================================================= -// function : onTextChanged() -// purpose : -//================================================================================= -void SMESHGUI_AddMeshElementOp::onTextChanged( int, const QStringList& aListId ) -{ - myDlg->setBusy( true ); - TColStd_MapOfInteger newIndices; - SALOME_ListIO list; selectionMgr()->selectedObjects( list ); - if( list.Extent()==0 ) - return; - - SMESH_Actor* anActor = SMESH::FindActorByObject( myMesh.in() ); - if( !anActor ) - return; - - SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); - - for (int i = 0; i < aListId.count(); i++) - if( const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ) ) - newIndices.Add( n->GetID() ); - - selector()->AddOrRemoveIndex( list.First(), newIndices, false ); - highlight( list.First(), true, true ); - - selectionDone(); - myDlg->setBusy( false ); -} - //================================================================================= // function : displaySimulation() // purpose : //================================================================================= void SMESHGUI_AddMeshElementOp::displaySimulation() { - QStringList ids; myDlg->selectedObject( 0, ids ); + IdList ids; selectedIds( 0, ids ); + if( ids.count()>=myNbNodes ) { SMESH::TElementSimulation::TVTKIds anIds; - SMESH_Actor* anActor = SMESH::FindActorByObject( myMesh.in() ); + SMESH_Actor* anActor = actor(); if( !anActor ) return; - for (int i = 0; i < myNbNodes; i++) - { - QString id_str = ids[ i ]; - int pos = id_str.find( idChar() ); - int id = -1; - if( pos>=0 ) - id = id_str.mid( pos+1 ).toInt(); - - if( id==-1 ) - { - printf( "SMESHGUI_AddMeshElementOp::displaySimulation(): Error!!!\n" ); - return; - } - - anIds.push_back( anActor->GetObject()->GetNodeVTKId( id ) ); - } + for (int i = 0; i < myNbNodes; i++) + anIds.push_back( anActor->GetObject()->GetNodeVTKId( ids[i] ) ); if( myDlg->isReverse() ) reverse( anIds.begin(), anIds.end() ); @@ -453,7 +375,7 @@ void SMESHGUI_AddMeshElementOp::updateDialog() { if( myDlg ) { - QStringList ids; myDlg->selectedObject( 0, ids ); + IdList ids; selectedIds( 0, ids ); myDlg->setButtonEnabled( ids.count()>=myNbNodes, QtxDialog::OK | QtxDialog::Apply ); } } diff --git a/src/SMESHGUI/SMESHGUI_AddMeshElementOp.h b/src/SMESHGUI/SMESHGUI_AddMeshElementOp.h index d7429b160..1a11a4ba9 100644 --- a/src/SMESHGUI/SMESHGUI_AddMeshElementOp.h +++ b/src/SMESHGUI/SMESHGUI_AddMeshElementOp.h @@ -33,11 +33,7 @@ namespace SMESH{ struct TElementSimulation; } -// IDL Headers -#include -#include CORBA_SERVER_HEADER(SMESH_Mesh) - -#include +#include #include class SMESHGUI_AddMeshElementDlg; @@ -46,7 +42,7 @@ class SMESHGUI_AddMeshElementDlg; // class : SMESHGUI_AddMeshElementOp // purpose : //================================================================================= -class SMESHGUI_AddMeshElementOp : public SMESHGUI_SelectionOp +class SMESHGUI_AddMeshElementOp : public SMESHGUI_SelectionIdsOp { Q_OBJECT @@ -58,7 +54,6 @@ public: protected: virtual void startOperation(); - virtual void selectionDone(); virtual void commitOperation(); virtual void abortOperation(); @@ -66,7 +61,8 @@ protected: protected slots: virtual bool onApply(); - void onTextChanged( int, const QStringList& ); + virtual void onSelectionChanged( int ); + void onReverse( int ); private: @@ -77,7 +73,6 @@ private: int myNbNodes; bool myIsPoly; - SMESH::SMESH_Mesh_var myMesh; SMESH::TElementSimulation* mySimulation; SMESHGUI_AddMeshElementDlg* myDlg; diff --git a/src/SMESHGUI/SMESHGUI_GroupOp.cxx b/src/SMESHGUI/SMESHGUI_GroupOp.cxx index ea80945af..2b96f1c68 100644 --- a/src/SMESHGUI/SMESHGUI_GroupOp.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupOp.cxx @@ -127,7 +127,7 @@ void SMESHGUI_GroupOp::startOperation() { if( !myDlg ) { - myDlg = new SMESHGUI_GroupOpDlg( getSMESHGUI(), myMode ); + myDlg = new SMESHGUI_GroupOpDlg( myMode ); connect( myDlg, SIGNAL( nameChanged( const QString& ) ), this, SLOT( onNameChanged( const QString& ) ) ); } diff --git a/src/SMESHGUI/SMESHGUI_NodesOp.cxx b/src/SMESHGUI/SMESHGUI_NodesOp.cxx index 2313f1aca..59f5a7fb7 100644 --- a/src/SMESHGUI/SMESHGUI_NodesOp.cxx +++ b/src/SMESHGUI/SMESHGUI_NodesOp.cxx @@ -230,7 +230,6 @@ void SMESHGUI_NodesOp::startOperation() { myDlg = new SMESHGUI_NodesDlg(); connect( myDlg, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged( double ) ) ); - connect( myDlg, SIGNAL( dlgClose() ), this, SLOT( onCancel() ) ); } SMESHGUI_SelectionOp::startOperation(); diff --git a/src/SMESHGUI/SMESHGUI_Operation.cxx b/src/SMESHGUI/SMESHGUI_Operation.cxx index 9a98634f1..0d46d002e 100755 --- a/src/SMESHGUI/SMESHGUI_Operation.cxx +++ b/src/SMESHGUI/SMESHGUI_Operation.cxx @@ -136,6 +136,7 @@ void SMESHGUI_Operation::startOperation() disconnect( dlg(), SIGNAL( dlgOk() ), this, SLOT( onOk() ) ); disconnect( dlg(), SIGNAL( dlgApply() ), this, SLOT( onApply() ) ); disconnect( dlg(), SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) ); + disconnect( dlg(), SIGNAL( dlgClose() ), this, SLOT( onCancel() ) ); if( dlg()->testButtonFlags( QtxDialog::OK ) ) connect( dlg(), SIGNAL( dlgOk() ), this, SLOT( onOk() ) ); @@ -145,6 +146,9 @@ void SMESHGUI_Operation::startOperation() if( dlg()->testButtonFlags( QtxDialog::Cancel ) ) connect( dlg(), SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) ); + + if( dlg()->testButtonFlags( QtxDialog::Close ) ) + connect( dlg(), SIGNAL( dlgClose() ), this, SLOT( onCancel() ) ); initDialog(); } @@ -315,8 +319,7 @@ void SMESHGUI_Operation::setDialogActive( const bool active ) _PTR(Study) SMESHGUI_Operation::studyDS() const { SalomeApp_Study* s = dynamic_cast( study() ); - if( s ) - return s->studyDS(); + return s->studyDS(); } //======================================================================= diff --git a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx index 7e913dbd5..7185dd98c 100644 --- a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx @@ -27,89 +27,46 @@ // $Header$ #include "SMESHGUI_RemoveNodesDlg.h" +#include -#include "SMESHGUI.h" -#include "SMESHGUI_Utils.h" -#include "SMESHGUI_VTKUtils.h" -#include "SMESHGUI_MeshUtils.h" -#include "SMESHGUI_IdValidator.h" +#include -#include "SMESH_Actor.h" -#include "SMDS_Mesh.hxx" +#include -#include "SUIT_ResourceMgr.h" -#include "SUIT_Desktop.h" - -#include "SVTK_Selector.h" -#include "SVTK_ViewModel.h" -#include "SVTK_ViewWindow.h" -#include "SALOME_ListIO.hxx" - -#include "utilities.h" - -// OCCT Includes -#include -#include - -// QT Includes -#include +#include #include -#include -#include -#include +#include #include -#include -#include -#include -#include -#include -#include - -using namespace std; //================================================================================= // class : SMESHGUI_RemoveNodesDlg() // purpose : //================================================================================= -SMESHGUI_RemoveNodesDlg -::SMESHGUI_RemoveNodesDlg(SMESHGUI* theModule, - const char* name, - bool modal, - WFlags fl) - : QDialog(SMESH::GetDesktop(theModule), - name, - modal, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), - mySelector(SMESH::GetViewWindow(theModule)->GetSelector()), - mySelectionMgr(SMESH::GetSelectionMgr(theModule)), - myViewWindow(SMESH::GetViewWindow(theModule)), - mySMESHGUI(theModule), - myBusy(false) +SMESHGUI_RemoveNodesDlg::SMESHGUI_RemoveNodesDlg() +: SMESHGUI_Dialog( false, true, OK | Apply | Close ) { - QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_REM_NODE"))); - QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap image0( resMgr()->loadPixmap("SMESH", tr("ICON_DLG_REM_NODE"))); + QPixmap image1( resMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); - if (!name) - setName("SMESHGUI_RemoveNodesDlg"); + setName("SMESHGUI_RemoveNodesDlg"); resize(303, 185); setCaption(tr("SMESH_REMOVE_NODES_TITLE" )); setSizeGripEnabled(TRUE); - SMESHGUI_RemoveNodesDlgLayout = new QGridLayout(this); - SMESHGUI_RemoveNodesDlgLayout->setSpacing(6); - SMESHGUI_RemoveNodesDlgLayout->setMargin(11); + + QVBoxLayout* main = new QVBoxLayout( mainFrame() ); /***************************************************************/ - GroupConstructors = new QButtonGroup(this, "GroupConstructors"); + QButtonGroup* GroupConstructors = new QButtonGroup( mainFrame(), "GroupConstructors"); GroupConstructors->setTitle(tr("SMESH_NODES" )); GroupConstructors->setExclusive(TRUE); GroupConstructors->setColumnLayout(0, Qt::Vertical); GroupConstructors->layout()->setSpacing(0); GroupConstructors->layout()->setMargin(0); - GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout()); + QGridLayout* GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout()); GroupConstructorsLayout->setAlignment(Qt::AlignTop); GroupConstructorsLayout->setSpacing(6); GroupConstructorsLayout->setMargin(11); - Constructor1 = new QRadioButton(GroupConstructors, "Constructor1"); + QRadioButton* Constructor1 = new QRadioButton(GroupConstructors, "Constructor1"); Constructor1->setText(tr("" )); Constructor1->setPixmap(image0); Constructor1->setChecked(TRUE); @@ -118,66 +75,24 @@ SMESHGUI_RemoveNodesDlg GroupConstructorsLayout->addWidget(Constructor1, 0, 0); QSpacerItem* spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); GroupConstructorsLayout->addItem(spacer, 0, 1); - SMESHGUI_RemoveNodesDlgLayout->addWidget(GroupConstructors, 0, 0); - - /***************************************************************/ - GroupButtons = new QGroupBox(this, "GroupButtons"); - GroupButtons->setGeometry(QRect(10, 10, 281, 48)); - GroupButtons->setTitle(tr("" )); - GroupButtons->setColumnLayout(0, Qt::Vertical); - GroupButtons->layout()->setSpacing(0); - GroupButtons->layout()->setMargin(0); - GroupButtonsLayout = new QGridLayout(GroupButtons->layout()); - GroupButtonsLayout->setAlignment(Qt::AlignTop); - GroupButtonsLayout->setSpacing(6); - GroupButtonsLayout->setMargin(11); - buttonCancel = new QPushButton(GroupButtons, "buttonCancel"); - buttonCancel->setText(tr("SMESH_BUT_CLOSE" )); - buttonCancel->setAutoDefault(TRUE); - GroupButtonsLayout->addWidget(buttonCancel, 0, 3); - buttonApply = new QPushButton(GroupButtons, "buttonApply"); - buttonApply->setText(tr("SMESH_BUT_APPLY" )); - buttonApply->setAutoDefault(TRUE); - GroupButtonsLayout->addWidget(buttonApply, 0, 1); - QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - GroupButtonsLayout->addItem(spacer_9, 0, 2); - buttonOk = new QPushButton(GroupButtons, "buttonOk"); - buttonOk->setText(tr("SMESH_BUT_OK" )); - buttonOk->setAutoDefault(TRUE); - buttonOk->setDefault(TRUE); - GroupButtonsLayout->addWidget(buttonOk, 0, 0); - SMESHGUI_RemoveNodesDlgLayout->addWidget(GroupButtons, 2, 0); + main->addWidget(GroupConstructors); /***************************************************************/ - GroupC1 = new QGroupBox(this, "GroupC1"); + QGroupBox* GroupC1 = new QGroupBox( mainFrame(), "GroupC1"); GroupC1->setTitle(tr("SMESH_REMOVE" )); GroupC1->setMinimumSize(QSize(0, 0)); GroupC1->setFrameShape(QGroupBox::Box); GroupC1->setFrameShadow(QGroupBox::Sunken); - GroupC1->setColumnLayout(0, Qt::Vertical); - GroupC1->layout()->setSpacing(0); - GroupC1->layout()->setMargin(0); - GroupC1Layout = new QGridLayout(GroupC1->layout()); - GroupC1Layout->setAlignment(Qt::AlignTop); - GroupC1Layout->setSpacing(6); - GroupC1Layout->setMargin(11); - TextLabelC1A1 = new QLabel(GroupC1, "TextLabelC1A1"); - TextLabelC1A1->setText(tr("SMESH_ID_NODES" )); - TextLabelC1A1->setMinimumSize(QSize(50, 0)); - TextLabelC1A1->setFrameShape(QLabel::NoFrame); - TextLabelC1A1->setFrameShadow(QLabel::Plain); - GroupC1Layout->addWidget(TextLabelC1A1, 0, 0); - SelectButtonC1A1 = new QPushButton(GroupC1, "SelectButtonC1A1"); - SelectButtonC1A1->setText(tr("" )); - SelectButtonC1A1->setPixmap(image1); - SelectButtonC1A1->setToggleButton(FALSE); - GroupC1Layout->addWidget(SelectButtonC1A1, 0, 1); - LineEditC1A1 = new QLineEdit(GroupC1, "LineEditC1A1"); - LineEditC1A1->setValidator(new SMESHGUI_IdValidator(this, "validator")); - GroupC1Layout->addWidget(LineEditC1A1, 0, 2); - SMESHGUI_RemoveNodesDlgLayout->addWidget(GroupC1, 1, 0); + GroupC1->setColumnLayout( 3, Qt::Horizontal ); +// GroupC1->layout()->setSpacing(0); +// GroupC1->layout()->setMargin(0); - Init(); /* Initialisations */ + createObject( tr("SMESH_ID_NODES" ), GroupC1, 0 ); + setNameIndication( 0, ListOfNames ); + setReadOnly( 0, false ); + setObjectType( 0, SMESHGUI_Operation::prefix( "SMESH element" ) + SMDSAbs_Node, -1 ); + + main->addWidget(GroupC1); } //================================================================================= @@ -186,300 +101,4 @@ SMESHGUI_RemoveNodesDlg //================================================================================= SMESHGUI_RemoveNodesDlg::~SMESHGUI_RemoveNodesDlg() { - // no need to delete child widgets, Qt does it all for us -} - -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void SMESHGUI_RemoveNodesDlg::Init() -{ - GroupC1->show(); - myConstructorId = 0; - Constructor1->setChecked(TRUE); - myEditCurrentArgument = LineEditC1A1; - - myNbOkNodes = 0; - mySMESHGUI->SetActiveDialogBox((QDialog*)this); - myActor = 0; - myBusy = false; - - /* signals and slots connections */ - connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); - connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); - connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int))); - - connect(SelectButtonC1A1, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); - connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); - connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - /* to close dialog if study change */ - connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); - connect(myEditCurrentArgument, SIGNAL(textChanged(const QString&)), - SLOT(onTextChange(const QString&))); - - /* Move widget on the botton right corner of main widget */ - int x, y; - mySMESHGUI->DefineDlgPosition(this, x, y); - this->move(x, y); - this->show(); /* displays Dialog */ - - SMESH::SetPointRepresentation(true); - myViewWindow->SetSelectionMode(NodeSelection); - - SelectionIntoArgument(); -} - -//================================================================================= -// function : ConstructorsClicked() -// purpose : Radio button management -//================================================================================= -void SMESHGUI_RemoveNodesDlg::ConstructorsClicked (int) -{ -} - -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -void SMESHGUI_RemoveNodesDlg::ClickOnApply() -{ - if (mySMESHGUI->isActiveStudyLocked()) - return; - - if (myNbOkNodes) { - QStringList aListId = QStringList::split(" ", myEditCurrentArgument->text(), false); - SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array; - anArrayOfIdeces->length(aListId.count()); - for (int i = 0; i < aListId.count(); i++) - anArrayOfIdeces[i] = aListId[ i ].toInt(); - - bool aResult = false; - try { - SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - aResult = aMeshEditor->RemoveNodes(anArrayOfIdeces.inout()); - } catch(...) { - } - - if (aResult) { - myEditCurrentArgument->clear(); - SMESH::UpdateView(); - } - - SMESH::SetPointRepresentation(true); - } -} - -//================================================================================= -// function : ClickOnOk() -// purpose : -//================================================================================= -void SMESHGUI_RemoveNodesDlg::ClickOnOk() -{ - ClickOnApply(); - ClickOnCancel(); -} - -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void SMESHGUI_RemoveNodesDlg::ClickOnCancel() -{ - mySelectionMgr->clearSelected(); - SMESH::SetPointRepresentation(false); - myViewWindow->SetSelectionMode(ActorSelection); - disconnect(mySelectionMgr, 0, this, 0); - mySMESHGUI->ResetState(); - reject(); -} - -//======================================================================= -//function : onTextChange -//purpose : -//======================================================================= -void SMESHGUI_RemoveNodesDlg::onTextChange (const QString& theNewText) -{ - if (myBusy) return; - myBusy = true; - - myNbOkNodes = 0; - - buttonOk->setEnabled(false); - buttonApply->setEnabled(false); - - // hilight entered nodes - if(myActor){ - if(SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh()){ - Handle(SALOME_InteractiveObject) anIO = myActor->getIO(); - - TColStd_MapOfInteger newIndices; - - QStringList aListId = QStringList::split(" ", theNewText, false); - for (int i = 0; i < aListId.count(); i++) { - if (const SMDS_MeshNode *aNode = aMesh->FindNode(aListId[i].toInt())) { - newIndices.Add(aNode->GetID()); - myNbOkNodes++; - } - } - - mySelector->AddOrRemoveIndex(anIO,newIndices,false); - myViewWindow->highlight(anIO,true,true); - } - } - - if (myNbOkNodes) { - buttonOk->setEnabled(true); - buttonApply->setEnabled(true); - } - - myBusy = false; -} - -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection as changed or other case -//================================================================================= -void SMESHGUI_RemoveNodesDlg::SelectionIntoArgument() -{ - if (myBusy) return; - - // clear - - myNbOkNodes = false; - myActor = 0; - - myBusy = true; - myEditCurrentArgument->setText(""); - myBusy = false; - - if (!GroupButtons->isEnabled()) // inactive - return; - - buttonOk->setEnabled(false); - buttonApply->setEnabled(false); - - // get selected mesh - SALOME_ListIO aList; - mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); - - int nbSel = aList.Extent(); - if (nbSel != 1) - return; - - Handle(SALOME_InteractiveObject) anIO = aList.First(); - myMesh = SMESH::GetMeshByIO(anIO); - if (myMesh->_is_nil()) - return; - - myActor = SMESH::FindActorByEntry(anIO->getEntry()); - if (!myActor) - return; - - // get selected nodes - - QString aString = ""; - int nbNodes = SMESH::GetNameOfSelectedNodes(mySelector,anIO,aString); - if(nbNodes < 1) - return; - myBusy = true; - myEditCurrentArgument->setText(aString); - myBusy = false; - - // OK - - myNbOkNodes = true; - - buttonOk->setEnabled(true); - buttonApply->setEnabled(true); -} - -//================================================================================= -// function : SetEditCurrentArgument() -// purpose : -//================================================================================= -void SMESHGUI_RemoveNodesDlg::SetEditCurrentArgument() -{ - QPushButton* send = (QPushButton*)sender(); - switch (myConstructorId) - { - case 0: /* default constructor */ - { - if(send == SelectButtonC1A1) { - LineEditC1A1->setFocus(); - myEditCurrentArgument = LineEditC1A1; - } - SelectionIntoArgument(); - break; - } - } - return; -} - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void SMESHGUI_RemoveNodesDlg::DeactivateActiveDialog() -{ - if (GroupConstructors->isEnabled()) { - GroupConstructors->setEnabled(false); - GroupC1->setEnabled(false); - GroupButtons->setEnabled(false); - mySMESHGUI->ResetState(); // ?? - mySMESHGUI->SetActiveDialogBox(0); // ?? - } -} - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void SMESHGUI_RemoveNodesDlg::ActivateThisDialog() -{ - /* Emit a signal to deactivate the active dialog */ - mySMESHGUI->EmitSignalDeactivateDialog(); - - GroupConstructors->setEnabled(true); - GroupC1->setEnabled(true); - GroupButtons->setEnabled(true); - - mySMESHGUI->SetActiveDialogBox((QDialog*)this); // ?? - - SMESH::SetPointRepresentation(true); - myViewWindow->SetSelectionMode(NodeSelection); - - SelectionIntoArgument(); // ?? -} - -//================================================================================= -// function : enterEvent() -// purpose : -//================================================================================= -void SMESHGUI_RemoveNodesDlg::enterEvent (QEvent*) -{ - if (!GroupConstructors->isEnabled()) - ActivateThisDialog(); -} - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void SMESHGUI_RemoveNodesDlg::closeEvent (QCloseEvent*) -{ - /* same than click on cancel button */ - this->ClickOnCancel(); - return; -} - -//======================================================================= -//function : hideEvent -//purpose : caused by ESC key -//======================================================================= -void SMESHGUI_RemoveNodesDlg::hideEvent (QHideEvent * e) -{ - if (!isMinimized()) - ClickOnCancel(); } diff --git a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.h b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.h index 6a847e2cf..bf4948c30 100644 --- a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.h +++ b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.h @@ -29,97 +29,19 @@ #ifndef DIALOGBOX_REMOVE_NODES_H #define DIALOGBOX_REMOVE_NODES_H -#include "SalomeApp_SelectionMgr.h" - -// QT Includes -#include -#include - -// Open CASCADE Includes -#include - -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QButtonGroup; -class QGroupBox; -class QLabel; -class QLineEdit; -class QPushButton; -class QRadioButton; - -class SMESHGUI; -class SMESH_Actor; -class SVTK_Selector; -class SVTK_ViewWindow; - -// IDL Headers -#include -#include CORBA_SERVER_HEADER(SMESH_Mesh) +#include //================================================================================= // class : SMESHGUI_RemoveNodesDlg // purpose : //================================================================================= -class SMESHGUI_RemoveNodesDlg : public QDialog +class SMESHGUI_RemoveNodesDlg : public SMESHGUI_Dialog { Q_OBJECT public: - SMESHGUI_RemoveNodesDlg(SMESHGUI* theModule, - const char* name = 0, - bool modal = FALSE, - WFlags fl = 0); + SMESHGUI_RemoveNodesDlg(); ~SMESHGUI_RemoveNodesDlg(); - -private: - - void Init() ; - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ - void hideEvent ( QHideEvent * ); /* ESC key */ - - SalomeApp_SelectionMgr* mySelectionMgr; - SVTK_ViewWindow* myViewWindow; - SVTK_Selector* mySelector; - SMESHGUI* mySMESHGUI; - - int myNbOkNodes; /* to check when arguments is defined */ - int myConstructorId; /* Current constructor id = radio button id */ - QLineEdit* myEditCurrentArgument; /* Current LineEdit */ - - bool myBusy; - SMESH::SMESH_Mesh_var myMesh; - SMESH_Actor* myActor; - - QButtonGroup* GroupConstructors; - QRadioButton* Constructor1; - QGroupBox* GroupButtons; - QPushButton* buttonOk; - QPushButton* buttonCancel; - QPushButton* buttonApply; - QGroupBox* GroupC1; - QLabel* TextLabelC1A1; - QPushButton* SelectButtonC1A1; - QLineEdit* LineEditC1A1; - -private slots: - - void ConstructorsClicked(int constructorId); - void ClickOnOk(); - void ClickOnCancel(); - void ClickOnApply(); - void SetEditCurrentArgument() ; - void SelectionIntoArgument() ; - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; - void onTextChange(const QString&); - -protected: - QGridLayout* SMESHGUI_RemoveNodesDlgLayout; - QGridLayout* GroupConstructorsLayout; - QGridLayout* GroupButtonsLayout; - QGridLayout* GroupC1Layout; }; #endif // DIALOGBOX_REMOVE_NODES_H diff --git a/src/SMESHGUI/SMESHGUI_RemoveNodesOp.cxx b/src/SMESHGUI/SMESHGUI_RemoveNodesOp.cxx new file mode 100644 index 000000000..c8145579e --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_RemoveNodesOp.cxx @@ -0,0 +1,135 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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_RemoveNodesOp.cxx +// Author : Alexander SOLOVYOV +// Module : SMESH +// $Header$ + +#include "SMESHGUI_RemoveNodesOp.h" +#include +#include +#include + +//================================================================================= +// function : +// purpose : +//================================================================================= +SMESHGUI_RemoveNodesOp::SMESHGUI_RemoveNodesOp() +: SMESHGUI_SelectionIdsOp( NodeSelection ), + myDlg( 0 ) +{ +} + +//================================================================================= +// function : +// purpose : +//================================================================================= +SMESHGUI_RemoveNodesOp::~SMESHGUI_RemoveNodesOp() +{ + if( myDlg ) + delete myDlg; +} + +//================================================================================= +// function : +// purpose : +//================================================================================= +SalomeApp_Dialog* SMESHGUI_RemoveNodesOp::dlg() const +{ + return myDlg; +} + +//================================================================================= +// function : +// purpose : +//================================================================================= +void SMESHGUI_RemoveNodesOp::startOperation() +{ + if( !myDlg ) + myDlg = new SMESHGUI_RemoveNodesDlg(); + + SMESHGUI_SelectionIdsOp::startOperation(); + + myDlg->show(); +} + +//================================================================================= +// function : +// purpose : +//================================================================================= +void SMESHGUI_RemoveNodesOp::selectionDone() +{ + SMESHGUI_SelectionIdsOp::selectionDone(); + updateDialog(); +} + +//================================================================================= +// function : +// purpose : +//================================================================================= +void SMESHGUI_RemoveNodesOp::updateDialog() +{ + if( !myDlg ) + return; + + bool en = myDlg->hasSelection( 0 ); + myDlg->setButtonEnabled( en, QtxDialog::OK | QtxDialog::Apply ); +} + +//================================================================================= +// function : +// purpose : +//================================================================================= +bool SMESHGUI_RemoveNodesOp::onApply() +{ + if( getSMESHGUI()->isActiveStudyLocked() ) + return false; + + IdList ids; selectedIds( 0, ids ); + + SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array; + anArrayOfIdeces->length(ids.count()); + for (int i=0, n=ids.count(); iGetMeshEditor(); + aResult = aMeshEditor->RemoveNodes( anArrayOfIdeces.inout() ); + } + catch(...) + { + } + + if (aResult) + { + initDialog(); + SMESH::UpdateView(); + } + + SMESH::SetPointRepresentation(true); + return aResult; +} + diff --git a/src/SMESHGUI/SMESHGUI_RemoveNodesOp.h b/src/SMESHGUI/SMESHGUI_RemoveNodesOp.h new file mode 100644 index 000000000..5bd9ceb44 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_RemoveNodesOp.h @@ -0,0 +1,63 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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_RemoveNodesOp.h +// Author : Nicolas REJNERI +// Module : SMESH +// $Header$ + +#ifndef OPERATION_REMOVE_NODES_H +#define OPERATION_REMOVE_NODES_H + +#include + +class SMESHGUI_RemoveNodesDlg; + +//================================================================================= +// class : SMESHGUI_RemoveNodesOp +// purpose : +//================================================================================= +class SMESHGUI_RemoveNodesOp : public SMESHGUI_SelectionIdsOp +{ + Q_OBJECT + +public: + SMESHGUI_RemoveNodesOp(); + ~SMESHGUI_RemoveNodesOp(); + + virtual SalomeApp_Dialog* dlg() const; + +protected: + virtual void startOperation(); + virtual void selectionDone(); + + void updateDialog(); + +protected slots: + virtual bool onApply(); + +private: + SMESHGUI_RemoveNodesDlg* myDlg; +}; + +#endif // DIALOGBOX_REMOVE_NODES_H diff --git a/src/SMESHGUI/SMESHGUI_SelectionIdsOp.cxx b/src/SMESHGUI/SMESHGUI_SelectionIdsOp.cxx new file mode 100644 index 000000000..2436435d5 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_SelectionIdsOp.cxx @@ -0,0 +1,221 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_SelectionIdsOp.cxx +// Author : Alexander SOLOVYOV +// Module : SMESH + +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include + +#include + +/* + Class : SMESHGUI_SelectionIdsOp + Description : +*/ + +//================================================================================= +// name : SMESHGUI_SelectionIdsOp +// purpose : +//================================================================================= +SMESHGUI_SelectionIdsOp::SMESHGUI_SelectionIdsOp( const Selection_Mode mode ) +: SMESHGUI_SelectionOp( mode ) +{ +} + +//================================================================================= +// name : ~SMESHGUI_SelectionIdsOp +// purpose : +//================================================================================= +SMESHGUI_SelectionIdsOp::~SMESHGUI_SelectionIdsOp() +{ +} + +//================================================================================= +// name : startOperation +// purpose : +//================================================================================= +void SMESHGUI_SelectionIdsOp::startOperation() +{ + SMESHGUI_SelectionOp::startOperation(); + if( dlg() ) + { + disconnect( dlg(), SIGNAL( objectChanged( int, const QStringList& ) ), + this, SLOT( onTextChanged( int, const QStringList& ) ) ); + connect( dlg(), SIGNAL( objectChanged( int, const QStringList& ) ), + this, SLOT( onTextChanged( int, const QStringList& ) ) ); + } +} + +//================================================================================= +// name : commitOperation +// purpose : +//================================================================================= +void SMESHGUI_SelectionIdsOp::commitOperation() +{ + SMESHGUI_SelectionOp::commitOperation(); + myMesh = SMESH::SMESH_Mesh::_nil(); +} + +//================================================================================= +// name : abortOperation +// purpose : +//================================================================================= +void SMESHGUI_SelectionIdsOp::abortOperation() +{ + SMESHGUI_SelectionOp::abortOperation(); + myMesh = SMESH::SMESH_Mesh::_nil(); +} + +//================================================================================= +// name : selectionDone +// purpose : +//================================================================================= +void SMESHGUI_SelectionIdsOp::selectionDone() +{ + if( !dlg() ) + return; + + // get selected mesh + SALOME_ListIO aList; + selectionMgr()->selectedObjects(aList,SVTK_Viewer::Type()); + + if( aList.Extent() != 1) + { + myMesh = SMESH::SMESH_Mesh::_nil(); + dlg()->clearSelection(); + return; + } + + Handle(SALOME_InteractiveObject) anIO = aList.First(); + myMesh = SMESH::GetMeshByIO(anIO); + + QStringList names, ids; SalomeApp_Dialog::TypesList types; + selected( names, types, ids ); + dlg()->selectObject( names, types, ids ); +} + +//================================================================================= +// name : mesh +// purpose : +//================================================================================= +SMESH::SMESH_Mesh_var SMESHGUI_SelectionIdsOp::mesh() const +{ + return myMesh; +} + +//================================================================================= +// name : actor +// purpose : +//================================================================================= +SMESH_Actor* SMESHGUI_SelectionIdsOp::actor() const +{ + return SMESH::FindActorByObject( myMesh.in() ); +} + +//================================================================================= +// name : onTextChanged +// purpose : +//================================================================================= +void SMESHGUI_SelectionIdsOp::onTextChanged( int, const QStringList& list ) +{ + if( !dlg() ) + return; + + TColStd_MapOfInteger newIndices; + + SALOME_ListIO sel; selectionMgr()->selectedObjects( sel ); + SMESH_Actor* anActor = actor(); + if( sel.Extent()==0 || !anActor ) + return; + + SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); + + IdList ids; extractIds( list, ids, '\0' ); + IdList::const_iterator anIt = ids.begin(), + aLast = ids.end(); + for( ; anIt!=aLast; anIt++ ) + if( const SMDS_MeshNode * n = aMesh->FindNode( *anIt ) ) + newIndices.Add( n->GetID() ); + + selector()->AddOrRemoveIndex( sel.First(), newIndices, false ); + highlight( sel.First(), true, true ); + + QStringList names, _ids; SalomeApp_Dialog::TypesList types; + selected( names, types, _ids ); + dlg()->selectObject( names, types, _ids, false ); +} + +//================================================================================= +// name : selectedIds +// purpose : +//================================================================================= +void SMESHGUI_SelectionIdsOp::selectedIds( const int id, IdList& list ) const +{ + if( !dlg() ) + return; + + QStringList ids; dlg()->selectedObject( id, ids ); + extractIds( ids, list ); +} + +//================================================================================= +// name : extractIds +// purpose : +//================================================================================= +void SMESHGUI_SelectionIdsOp::extractIds( const QStringList& ids, IdList& list, const QChar idchar ) +{ + QStringList::const_iterator anIt = ids.begin(), + aLast = ids.end(); + QString id_str; + for( ; anIt!=aLast; anIt++ ) + { + id_str = *anIt; + int pos = idchar=='\0' ? -1 : id_str.find( idchar ); + int id = -1; + if( idchar=='\0' || pos>=0 ) + { + id = id_str.mid( pos+1 ).toInt(); + list.append( id ); + } + } +} + +//================================================================================= +// name : extractIds +// purpose : +//================================================================================= +void SMESHGUI_SelectionIdsOp::extractIds( const QStringList& ids, IdList& list ) const +{ + extractIds( ids, list, idChar() ); +} diff --git a/src/SMESHGUI/SMESHGUI_SelectionIdsOp.h b/src/SMESHGUI/SMESHGUI_SelectionIdsOp.h new file mode 100644 index 000000000..f39e7747a --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_SelectionIdsOp.h @@ -0,0 +1,78 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_SelectionIdsOp.h +// Author : Alexander SOLOVYOV +// Module : SMESH + + +#ifndef SMESHGUI_SelectionIdsOp_H +#define SMESHGUI_SelectionIdsOp_H + +#include + +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +class SMESH_Actor; + +/* + Class : SMESHGUI_SelectionIdsOp + Description : Base operation for all operations using selection mesh elements by id on one mesh + In order to allow user to edit ids "by hands" the dialog must call setReadOnly( .., false ) + with id or object selection widget instead '..' + All other necessary actions are implemented here +*/ + +class SUIT_SelectionFilter; + +class SMESHGUI_SelectionIdsOp : public SMESHGUI_SelectionOp +{ + Q_OBJECT + +public: + typedef QValueList IdList; + +public: + SMESHGUI_SelectionIdsOp( const Selection_Mode = ActorSelection ); + virtual ~SMESHGUI_SelectionIdsOp(); + + static void extractIds( const QStringList&, IdList&, const QChar ); + +protected: + virtual void startOperation(); + virtual void commitOperation(); + virtual void abortOperation(); + virtual void selectionDone(); + + SMESH::SMESH_Mesh_var mesh() const; + SMESH_Actor* actor() const; + void selectedIds( const int, IdList& ) const; + void extractIds( const QStringList&, IdList& ) const; + +protected slots: + virtual void onTextChanged( int, const QStringList& ); + +private: + SMESH::SMESH_Mesh_var myMesh; +}; + +#endif diff --git a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx index d2a5689d3..e8e91a544 100644 --- a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx @@ -147,6 +147,8 @@ namespace SMESH{ { if(SalomeApp_Application* anApp = theModule->getApp()) return dynamic_cast(anApp->desktop()->activeWindow()); + else + return 0; } SVTK_ViewWindow* FindVtkViewWindow( SUIT_ViewManager* theMgr, -- 2.39.2