// Module : SMESH
// $Header$
-using namespace std;
#include "SMESHGUI_RemoveNodesDlg.h"
#include "SMESHGUI.h"
+#include "SMESHGUI_Utils.h"
+#include "SMESHGUI_VTKUtils.h"
+#include "SMESHGUI_MeshUtils.h"
+#include "SMESHGUI_IdValidator.h"
+#include "SMESH_Actor.h"
+#include "SMDS_Mesh.hxx"
+
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_MessageBox.h"
#include <qimage.h>
#include <qpixmap.h>
+using namespace std;
//=================================================================================
// class : SMESHGUI_RemoveNodesDlg()
//=================================================================================
SMESHGUI_RemoveNodesDlg::SMESHGUI_RemoveNodesDlg( QWidget* parent, const char* name, SALOME_Selection* Sel,
bool modal, WFlags fl )
- : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+ : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu |
+ Qt::WDestructiveClose),
+ myBusy( false )
{
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_REM_NODE")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT")));
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 );
//=================================================================================
void SMESHGUI_RemoveNodesDlg::Init( SALOME_Selection* Sel )
{
+ myBusy = false;
GroupC1->show();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
- this->myOkNodes = false ;
- mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
+ myNbOkNodes = 0 ;
+ myActor = 0;
+ mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
/* signals and slots connections */
connect( mySelection, 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 ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
+ SMESH::SetPointRepresentation(true);
+ QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
+
SelectionIntoArgument();
return ;
}
//=================================================================================
void SMESHGUI_RemoveNodesDlg::ClickOnApply()
{
- switch(myConstructorId)
- {
- case 0 :
- {
- if(myOkNodes) {
- mySMESHGUI->EraseSimulationActors();
- mySMESHGUI->RemoveNodes( myMesh, myMapIndex ) ;
- mySMESHGUI->ViewNodes();
- mySelection->ClearIObjects();
- }
- break ;
- }
+ if (mySMESHGUI->ActiveStudyLocked())
+ 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()) ;
}
- return ;
+ catch( ... )
+ {
+ }
+
+ if ( aResult )
+ {
+ Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
+ mySelection->ClearIObjects();
+ SMESH::UpdateView();
+ mySelection->AddIObject( anIO, false );
+ }
+
+ SMESH::SetPointRepresentation(true);
+ }
}
//=================================================================================
//=================================================================================
void SMESHGUI_RemoveNodesDlg::ClickOnCancel()
{
- QAD_Application::getDesktop()->SetSelectionMode( 4 );
+ mySelection->ClearIObjects();
+ SMESH::SetPointRepresentation(false);
+ QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
disconnect( mySelection, 0, this, 0 );
mySMESHGUI->ResetState() ;
- mySMESHGUI->EraseSimulationActors();
reject() ;
return ;
}
+//=======================================================================
+//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
+ SMDS_Mesh* aMesh = 0;
+ if ( myActor )
+ aMesh = myActor->GetObject()->GetMesh();
+ if ( aMesh ) {
+
+ mySelection->ClearIObjects();
+ mySelection->AddIObject( myActor->getIO() );
+
+ QStringList aListId = QStringList::split( " ", theNewText, false);
+ for ( int i = 0; i < aListId.count(); i++ ) {
+ const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() );
+ if ( n ) {
+ if ( !mySelection->IsIndexSelected( myActor->getIO(), n->GetID() ))
+ mySelection->AddOrRemoveIndex (myActor->getIO(), n->GetID(), true);
+ myNbOkNodes++;
+ }
+ }
+
+ if ( myNbOkNodes ) {
+ buttonOk->setEnabled( true );
+ buttonApply->setEnabled( true );
+ }
+ }
+
+ myBusy = false;
+}
//=================================================================================
// function : SelectionIntoArgument()
//=================================================================================
void SMESHGUI_RemoveNodesDlg::SelectionIntoArgument()
{
- myEditCurrentArgument->setText("") ;
- myOkNodes = false;
- QString aString = "";
+ 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
int nbSel = mySelection->IObjectCount();
if(nbSel != 1)
- return ;
+ return;
- int nbNodes = mySMESHGUI->GetNameOfSelectedNodes(mySelection, aString) ;
- if(nbNodes < 1)
- return ;
-
- if ( mySelection->SelectionMode() != 1 ){
- QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"),
- tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_YES") );
+ myMesh = SMESH::GetMeshByIO( mySelection->firstIObject() );
+ if ( myMesh->_is_nil() )
return;
- }
- myEditCurrentArgument->setText(aString) ;
- Standard_Boolean res;
- myMesh = mySMESHGUI->ConvertIOinMesh( mySelection->firstIObject(), res );
- if (!res)
+ myActor = SMESH::FindActorByEntry( mySelection->firstIObject()->getEntry() );
+ if ( !myActor )
+ return;
+
+ // get selected nodes
+
+ QString aString = "";
+ int nbNodes = SMESH::GetNameOfSelectedNodes(mySelection, aString) ;
+ if(nbNodes < 1)
return ;
+ myBusy = true;
+ myEditCurrentArgument->setText( aString );
+ myBusy = false;
- mySelection->GetIndex( mySelection->firstIObject(), myMapIndex);
+ // OK
- myOkNodes = true ;
- return ;
+ myNbOkNodes = true;
+
+ buttonOk->setEnabled( true );
+ buttonApply->setEnabled( true );
}
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
- mySMESHGUI->EraseSimulationActors() ;
mySMESHGUI->ResetState() ;
mySMESHGUI->SetActiveDialogBox(0) ;
}
GroupButtons->setEnabled(true) ;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
- return ;
+
+ SMESH::SetPointRepresentation(true);
+ QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
+
+ SelectionIntoArgument();
}
}
+//=======================================================================
+//function : hideEvent
+//purpose : caused by ESC key
+//=======================================================================
+
+void SMESHGUI_RemoveNodesDlg::hideEvent ( QHideEvent * e )
+{
+ if ( !isMinimized() )
+ ClickOnCancel();
+}