2003-07-10 19:18:22 +06:00
|
|
|
// 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_InitMeshDlg.cxx
|
|
|
|
// Author : Nicolas REJNERI
|
|
|
|
// Module : SMESH
|
2003-05-19 20:07:00 +06:00
|
|
|
// $Header$
|
|
|
|
|
|
|
|
#include "SMESHGUI_InitMeshDlg.h"
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2003-05-19 20:07:00 +06:00
|
|
|
#include "SMESHGUI.h"
|
2004-12-01 15:48:31 +05:00
|
|
|
#include "SMESHGUI_Utils.h"
|
|
|
|
#include "SMESHGUI_SMESHGenUtils.h"
|
|
|
|
#include "SMESHGUI_HypothesesUtils.h"
|
|
|
|
|
|
|
|
#include "GEOMBase.h"
|
2003-05-19 20:07:00 +06:00
|
|
|
|
|
|
|
#include "QAD_Application.h"
|
|
|
|
#include "QAD_Desktop.h"
|
2004-06-18 14:34:31 +06:00
|
|
|
#include "QAD_MessageBox.h"
|
|
|
|
#include "QAD_WaitCursor.h"
|
|
|
|
#include "QAD_Operation.h"
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
#include "SALOME_ListIteratorOfListIO.hxx"
|
|
|
|
#include "SALOMEGUI_QtCatchCorbaException.hxx"
|
|
|
|
|
2003-05-19 20:07:00 +06:00
|
|
|
#include "utilities.h"
|
|
|
|
|
|
|
|
// QT Includes
|
|
|
|
#include <qgroupbox.h>
|
|
|
|
#include <qlabel.h>
|
|
|
|
#include <qlineedit.h>
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
#include <qlayout.h>
|
|
|
|
#include <qpixmap.h>
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
namespace SMESH{
|
|
|
|
SMESH::SMESH_Mesh_var InitMesh(GEOM::GEOM_Object_ptr theShapeObject,
|
|
|
|
const char* theMeshName)
|
|
|
|
{
|
|
|
|
SMESH::SMESH_Mesh_var aMesh;
|
|
|
|
try {
|
|
|
|
SMESH::SMESH_Gen_var aSMESHGen = SMESH::GetSMESHGen();
|
|
|
|
if ( !aSMESHGen->_is_nil() && !theShapeObject->_is_nil() ) {
|
|
|
|
aMesh = aSMESHGen->CreateMesh( theShapeObject );
|
|
|
|
if ( !aMesh->_is_nil() ) {
|
|
|
|
SALOMEDS::SObject_var aMeshSObject = SMESH::FindSObject( aMesh.in() );
|
|
|
|
SMESH::SetName( aMeshSObject, theMeshName );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( const SALOME::SALOME_Exception& S_ex ) {
|
|
|
|
QtCatchCorbaException( S_ex );
|
|
|
|
}
|
|
|
|
return aMesh._retn();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-19 20:07:00 +06:00
|
|
|
//=================================================================================
|
|
|
|
// class : SMESHGUI_InitMeshDlg()
|
|
|
|
// purpose : Constructs a SMESHGUI_InitMeshDlg which is a child of 'parent', with the
|
|
|
|
// name 'name' and widget flags set to 'f'.
|
|
|
|
// The dialog will by default be modeless, unless you set 'modal' to
|
|
|
|
// TRUE to construct a modal dialog.
|
|
|
|
//=================================================================================
|
|
|
|
SMESHGUI_InitMeshDlg::SMESHGUI_InitMeshDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
|
2004-06-18 14:34:31 +06:00
|
|
|
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2003-05-23 17:40:45 +06:00
|
|
|
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT")));
|
2003-05-19 20:07:00 +06:00
|
|
|
if ( !name )
|
|
|
|
setName( "SMESHGUI_InitMeshDlg" );
|
|
|
|
setCaption( tr( "SMESH_INIT_MESH" ) );
|
|
|
|
setSizeGripEnabled( TRUE );
|
2004-06-18 14:34:31 +06:00
|
|
|
QGridLayout* SMESHGUI_InitMeshDlgLayout = new QGridLayout( this );
|
2003-05-19 20:07:00 +06:00
|
|
|
SMESHGUI_InitMeshDlgLayout->setSpacing( 6 );
|
|
|
|
SMESHGUI_InitMeshDlgLayout->setMargin( 11 );
|
|
|
|
|
|
|
|
/***************************************************************/
|
2004-06-18 14:34:31 +06:00
|
|
|
GroupC1 = new QGroupBox( tr( "SMESH_ARGUMENTS" ), this, "GroupC1" );
|
2003-05-19 20:07:00 +06:00
|
|
|
GroupC1->setColumnLayout(0, Qt::Vertical );
|
|
|
|
GroupC1->layout()->setSpacing( 0 );
|
|
|
|
GroupC1->layout()->setMargin( 0 );
|
2004-06-18 14:34:31 +06:00
|
|
|
QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() );
|
2003-05-19 20:07:00 +06:00
|
|
|
GroupC1Layout->setAlignment( Qt::AlignTop );
|
|
|
|
GroupC1Layout->setSpacing( 6 );
|
|
|
|
GroupC1Layout->setMargin( 11 );
|
|
|
|
|
2004-06-18 14:34:31 +06:00
|
|
|
TextLabel_NameMesh = new QLabel( tr( "SMESH_NAME" ), GroupC1, "TextLabel_NameMesh" );
|
|
|
|
GroupC1Layout->addWidget( TextLabel_NameMesh, 0, 0 );
|
|
|
|
LineEdit_NameMesh = new QLineEdit( GroupC1, "LineEdit_NameMesh" );
|
|
|
|
GroupC1Layout->addWidget( LineEdit_NameMesh, 0, 2 );
|
|
|
|
|
|
|
|
TextLabelC1A1 = new QLabel( tr( "SMESH_OBJECT_GEOM" ), GroupC1, "TextLabelC1A1" );
|
|
|
|
GroupC1Layout->addWidget( TextLabelC1A1, 1, 0 );
|
2003-05-19 20:07:00 +06:00
|
|
|
SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
|
|
|
|
SelectButtonC1A1->setPixmap( image0 );
|
|
|
|
SelectButtonC1A1->setToggleButton( FALSE );
|
2004-06-18 14:34:31 +06:00
|
|
|
GroupC1Layout->addWidget( SelectButtonC1A1, 1, 1 );
|
2003-05-19 20:07:00 +06:00
|
|
|
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
|
2004-12-01 15:48:31 +05:00
|
|
|
LineEditC1A1->setReadOnly( true );
|
2004-06-18 14:34:31 +06:00
|
|
|
GroupC1Layout->addWidget( LineEditC1A1, 1, 2 );
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2004-06-18 14:34:31 +06:00
|
|
|
TextLabelC1A1Hyp = new QLabel( tr( "SMESH_OBJECT_HYPOTHESIS" ), GroupC1, "TextLabelC1A1Hyp" );
|
2003-05-19 20:07:00 +06:00
|
|
|
GroupC1Layout->addWidget( TextLabelC1A1Hyp, 2, 0 );
|
|
|
|
SelectButtonC1A1Hyp = new QPushButton( GroupC1, "SelectButtonC1A1Hyp" );
|
|
|
|
SelectButtonC1A1Hyp->setPixmap( image0 );
|
|
|
|
GroupC1Layout->addWidget( SelectButtonC1A1Hyp, 2, 1 );
|
|
|
|
LineEditC1A1Hyp = new QLineEdit( GroupC1, "LineEditC1A1Hyp" );
|
2004-12-01 15:48:31 +05:00
|
|
|
LineEditC1A1Hyp->setReadOnly( true );
|
2003-05-19 20:07:00 +06:00
|
|
|
GroupC1Layout->addWidget( LineEditC1A1Hyp, 2, 2 );
|
|
|
|
|
2004-06-18 14:34:31 +06:00
|
|
|
TextLabelC1A1Algo = new QLabel( tr( "SMESH_OBJECT_ALGORITHM" ), GroupC1, "TextLabelC1A1Algo" );
|
2003-05-19 20:07:00 +06:00
|
|
|
GroupC1Layout->addWidget( TextLabelC1A1Algo, 3, 0 );
|
|
|
|
SelectButtonC1A1Algo = new QPushButton( GroupC1, "SelectButtonC1A1Algo" );
|
|
|
|
SelectButtonC1A1Algo->setPixmap( image0 );
|
|
|
|
GroupC1Layout->addWidget( SelectButtonC1A1Algo, 3, 1 );
|
|
|
|
LineEditC1A1Algo = new QLineEdit( GroupC1, "LineEditC1A1Algo" );
|
2004-12-01 15:48:31 +05:00
|
|
|
LineEditC1A1Algo->setReadOnly( true );
|
2003-05-19 20:07:00 +06:00
|
|
|
GroupC1Layout->addWidget( LineEditC1A1Algo, 3, 2 );
|
|
|
|
|
|
|
|
SMESHGUI_InitMeshDlgLayout->addWidget( GroupC1, 1, 0 );
|
2004-06-18 14:34:31 +06:00
|
|
|
|
2003-05-19 20:07:00 +06:00
|
|
|
/***************************************************************/
|
2004-06-18 14:34:31 +06:00
|
|
|
GroupButtons = new QGroupBox( this, "GroupButtons" );
|
|
|
|
GroupButtons->setColumnLayout(0, Qt::Vertical );
|
|
|
|
GroupButtons->layout()->setSpacing( 0 );
|
|
|
|
GroupButtons->layout()->setMargin( 0 );
|
|
|
|
QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
|
|
|
|
GroupButtonsLayout->setAlignment( Qt::AlignTop );
|
|
|
|
GroupButtonsLayout->setSpacing( 6 );
|
|
|
|
GroupButtonsLayout->setMargin( 11 );
|
|
|
|
|
|
|
|
buttonOk = new QPushButton( tr( "SMESH_BUT_OK" ), GroupButtons, "buttonOk" );
|
|
|
|
buttonOk->setAutoDefault( TRUE );
|
|
|
|
buttonOk->setDefault( TRUE );
|
|
|
|
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
|
|
|
|
|
|
|
|
buttonApply = new QPushButton( tr( "SMESH_BUT_APPLY" ), GroupButtons, "buttonApply" );
|
|
|
|
buttonApply->setAutoDefault( TRUE );
|
|
|
|
GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
|
|
|
|
|
|
|
|
GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 2 );
|
|
|
|
|
|
|
|
buttonCancel = new QPushButton( tr( "SMESH_BUT_CLOSE" ), GroupButtons, "buttonCancel" );
|
|
|
|
buttonCancel->setAutoDefault( TRUE );
|
|
|
|
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
|
|
|
|
|
|
|
|
SMESHGUI_InitMeshDlgLayout->addWidget( GroupButtons, 2, 0 );
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2004-06-18 14:34:31 +06:00
|
|
|
/***************************************************************/
|
|
|
|
Init( Sel ) ;
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ~SMESHGUI_InitMeshDlg()
|
|
|
|
// purpose : Destroys the object and frees any allocated resources
|
|
|
|
//=================================================================================
|
|
|
|
SMESHGUI_InitMeshDlg::~SMESHGUI_InitMeshDlg()
|
|
|
|
{
|
|
|
|
// no need to delete child widgets, Qt does it all for us
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : Init()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_InitMeshDlg::Init( SALOME_Selection* Sel )
|
|
|
|
{
|
|
|
|
mySelection = Sel;
|
|
|
|
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
|
|
|
|
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
|
|
|
|
|
2004-06-18 14:34:31 +06:00
|
|
|
myGeomFilter = new SALOME_TypeFilter( "GEOM" );
|
|
|
|
myAlgorithmFilter = new SMESH_TypeFilter( ALGORITHM );
|
2003-05-19 20:07:00 +06:00
|
|
|
myHypothesisFilter = new SMESH_TypeFilter( HYPOTHESIS );
|
|
|
|
|
|
|
|
/* signals and slots connections */
|
2004-06-18 14:34:31 +06:00
|
|
|
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
|
|
|
|
connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
|
2003-05-19 20:07:00 +06:00
|
|
|
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
|
|
|
|
|
2004-06-18 14:34:31 +06:00
|
|
|
connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
|
|
|
|
connect( SelectButtonC1A1Hyp, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
|
2003-05-19 20:07:00 +06:00
|
|
|
connect( SelectButtonC1A1Algo, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
|
|
|
|
|
2004-06-18 14:34:31 +06:00
|
|
|
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
|
|
|
|
connect( mySMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
|
|
|
|
connect( mySMESHGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
|
2003-05-19 20:07:00 +06:00
|
|
|
|
|
|
|
int x, y ;
|
|
|
|
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
|
|
|
|
this->move( x, y ) ;
|
|
|
|
this->show() ;
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
LineEdit_NameMesh->setText( GetDefaultMeshName() );
|
2004-06-18 14:34:31 +06:00
|
|
|
LineEdit_NameMesh->setFocus() ;
|
|
|
|
myEditCurrentArgument = LineEditC1A1 ;
|
|
|
|
mySelection->ClearFilters() ;
|
|
|
|
mySelection->AddFilter( myGeomFilter ) ;
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2004-06-18 14:34:31 +06:00
|
|
|
SelectionIntoArgument();
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2004-06-18 14:34:31 +06:00
|
|
|
UpdateControlState();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2004-06-18 14:34:31 +06:00
|
|
|
|
2003-05-19 20:07:00 +06:00
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnOk()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_InitMeshDlg::ClickOnOk()
|
|
|
|
{
|
2004-06-18 14:34:31 +06:00
|
|
|
if ( this->ClickOnApply() )
|
|
|
|
this->ClickOnCancel() ;
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnApply()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2004-06-18 14:34:31 +06:00
|
|
|
bool SMESHGUI_InitMeshDlg::ClickOnApply()
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2004-12-01 15:48:31 +05:00
|
|
|
if (mySMESHGUI->ActiveStudyLocked())
|
|
|
|
return false;
|
|
|
|
|
2004-06-18 14:34:31 +06:00
|
|
|
QString myNameMesh = LineEdit_NameMesh->text().stripWhiteSpace();
|
|
|
|
if ( myNameMesh.isEmpty() ) {
|
|
|
|
QAD_MessageBox::warn1( this, tr( "SMESH_WRN_WARNING" ), tr( "SMESH_WRN_EMPTY_NAME" ), tr( "SMESH_BUT_OK" ) );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( myGeomShape->_is_nil() || !HypoList.count() || !AlgoList.count() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
QAD_WaitCursor wc;
|
|
|
|
|
|
|
|
QAD_Operation* op = new QAD_Operation( mySMESHGUI->GetActiveStudy() );
|
|
|
|
|
|
|
|
// start transaction
|
|
|
|
op->start();
|
|
|
|
|
|
|
|
// create mesh
|
2004-12-01 15:48:31 +05:00
|
|
|
SMESH::SMESH_Mesh_var aMesh = SMESH::InitMesh( myGeomShape, myNameMesh ) ;
|
2004-06-18 14:34:31 +06:00
|
|
|
|
|
|
|
if ( !aMesh->_is_nil() ) {
|
|
|
|
// assign hypotheses
|
|
|
|
for( int i = 0; i < HypoList.count(); i++ ) {
|
2004-12-01 15:48:31 +05:00
|
|
|
SALOMEDS::SObject_var aHypSO = SMESH::GetActiveStudyDocument()->FindObjectID( HypoList[i] );
|
2004-06-18 14:34:31 +06:00
|
|
|
if ( !aHypSO->_is_nil() ) {
|
|
|
|
CORBA::Object_var anObject = aHypSO->GetObject();
|
|
|
|
if ( !CORBA::is_nil( anObject ) ) {
|
|
|
|
SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
|
|
|
|
if ( !aHyp->_is_nil() ) {
|
2004-12-01 15:48:31 +05:00
|
|
|
if ( !SMESH::AddHypothesisOnMesh( aMesh, aHyp ) ) {
|
2004-06-18 14:34:31 +06:00
|
|
|
// abort transaction
|
|
|
|
op->abort();
|
|
|
|
return false;
|
|
|
|
}
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
}
|
2004-06-18 14:34:31 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// assign algorithms
|
|
|
|
for( int i = 0; i < AlgoList.count(); i++ ) {
|
2004-12-01 15:48:31 +05:00
|
|
|
SALOMEDS::SObject_var aHypSO = SMESH::GetActiveStudyDocument()->FindObjectID( AlgoList[i] );
|
2004-06-18 14:34:31 +06:00
|
|
|
if ( !aHypSO->_is_nil() ) {
|
|
|
|
CORBA::Object_var anObject = aHypSO->GetObject();
|
|
|
|
if ( !CORBA::is_nil( anObject ) ) {
|
|
|
|
SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject );
|
|
|
|
if ( !aHyp->_is_nil() ) {
|
2004-12-01 15:48:31 +05:00
|
|
|
if ( !SMESH::AddHypothesisOnMesh( aMesh, aHyp ) ) {
|
2004-06-18 14:34:31 +06:00
|
|
|
// abort transaction
|
|
|
|
op->abort();
|
|
|
|
return false;
|
|
|
|
}
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-06-18 14:34:31 +06:00
|
|
|
}
|
|
|
|
// commit transaction
|
|
|
|
op->finish();
|
2004-12-01 15:48:31 +05:00
|
|
|
LineEdit_NameMesh->setText( GetDefaultMeshName() );
|
2004-06-18 14:34:31 +06:00
|
|
|
return true;
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnCancel()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_InitMeshDlg::ClickOnCancel()
|
|
|
|
{
|
2004-06-18 14:34:31 +06:00
|
|
|
close();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : SelectionIntoArgument()
|
|
|
|
// purpose : Called when selection as changed or other case
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_InitMeshDlg::SelectionIntoArgument()
|
|
|
|
{
|
|
|
|
QString aString = "";
|
2004-06-18 14:34:31 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
int nbSel = SMESH::GetNameOfSelectedIObjects( mySelection, aString );
|
2004-06-18 14:34:31 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
if ( myEditCurrentArgument == LineEditC1A1 )
|
|
|
|
{
|
2004-06-18 14:34:31 +06:00
|
|
|
// geom shape
|
2004-12-01 15:48:31 +05:00
|
|
|
if ( nbSel != 1 )
|
|
|
|
{
|
|
|
|
myGeomShape = GEOM::GEOM_Object::_nil();
|
2004-06-18 14:34:31 +06:00
|
|
|
aString = "";
|
|
|
|
}
|
2004-12-01 15:48:31 +05:00
|
|
|
else
|
|
|
|
{
|
2003-05-19 20:07:00 +06:00
|
|
|
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
|
2004-12-01 15:48:31 +05:00
|
|
|
myGeomShape = SMESH::IObjectToInterface<GEOM::GEOM_Object>( IO ) ;
|
|
|
|
if ( myGeomShape->_is_nil() || !GEOMBase::IsShape( myGeomShape ) )
|
|
|
|
{
|
|
|
|
myGeomShape = GEOM::GEOM_Object::_nil();
|
|
|
|
aString = "";
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( myEditCurrentArgument == LineEditC1A1Hyp ) {
|
2004-06-18 14:34:31 +06:00
|
|
|
// hypotheses
|
|
|
|
HypoList.clear();
|
2003-05-19 20:07:00 +06:00
|
|
|
if ( nbSel >= 1 ) {
|
|
|
|
SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() );
|
2004-06-18 14:34:31 +06:00
|
|
|
for ( ; Itinit.More(); Itinit.Next() ) {
|
|
|
|
HypoList.append( Itinit.Value()->getEntry() );
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
2004-06-18 14:34:31 +06:00
|
|
|
if ( nbSel > 1 )
|
|
|
|
aString = tr( "%1 Hypothesis" ).arg( nbSel ) ;
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
else {
|
2004-06-18 14:34:31 +06:00
|
|
|
aString = "";
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
2004-06-18 14:34:31 +06:00
|
|
|
}
|
|
|
|
else if ( myEditCurrentArgument == LineEditC1A1Algo ) {
|
|
|
|
// algorithms
|
|
|
|
AlgoList.clear();
|
2003-05-19 20:07:00 +06:00
|
|
|
if ( nbSel >= 1 ) {
|
|
|
|
SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() );
|
2004-06-18 14:34:31 +06:00
|
|
|
for ( ; Itinit.More(); Itinit.Next() ) {
|
|
|
|
AlgoList.append( Itinit.Value()->getEntry() );
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
2004-06-18 14:34:31 +06:00
|
|
|
if ( nbSel > 1 )
|
|
|
|
aString = tr( "%1 Algorithms" ).arg( nbSel ) ;
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
else {
|
2004-06-18 14:34:31 +06:00
|
|
|
aString = "";
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
myEditCurrentArgument->setText(aString) ;
|
2004-06-18 14:34:31 +06:00
|
|
|
|
|
|
|
UpdateControlState();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : SetEditCurrentArgument()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_InitMeshDlg::SetEditCurrentArgument()
|
|
|
|
{
|
|
|
|
QPushButton* send = (QPushButton*)sender();
|
2004-06-18 14:34:31 +06:00
|
|
|
if(send == SelectButtonC1A1) {
|
|
|
|
LineEditC1A1->setFocus() ;
|
|
|
|
myEditCurrentArgument = LineEditC1A1;
|
|
|
|
mySelection->ClearFilters() ;
|
|
|
|
mySelection->AddFilter(myGeomFilter) ;
|
|
|
|
} else if( send == SelectButtonC1A1Hyp ) {
|
|
|
|
LineEditC1A1Hyp->setFocus() ;
|
|
|
|
myEditCurrentArgument = LineEditC1A1Hyp ;
|
|
|
|
mySelection->ClearFilters() ;
|
|
|
|
mySelection->AddFilter(myHypothesisFilter) ;
|
|
|
|
} else if( send == SelectButtonC1A1Algo ) {
|
|
|
|
LineEditC1A1Algo->setFocus() ;
|
|
|
|
myEditCurrentArgument = LineEditC1A1Algo ;
|
|
|
|
mySelection->ClearFilters() ;
|
|
|
|
mySelection->AddFilter(myAlgorithmFilter) ;
|
|
|
|
}
|
|
|
|
SelectionIntoArgument() ;
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : DeactivateActiveDialog()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_InitMeshDlg::DeactivateActiveDialog()
|
|
|
|
{
|
2004-06-18 14:34:31 +06:00
|
|
|
if ( GroupC1->isEnabled() ) {
|
2003-05-19 20:07:00 +06:00
|
|
|
disconnect( mySelection, 0, this, 0 );
|
|
|
|
GroupC1->setEnabled(false) ;
|
|
|
|
GroupButtons->setEnabled(false) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ActivateThisDialog()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_InitMeshDlg::ActivateThisDialog()
|
|
|
|
{
|
|
|
|
mySMESHGUI->EmitSignalDeactivateDialog() ;
|
|
|
|
GroupC1->setEnabled(true) ;
|
|
|
|
GroupButtons->setEnabled(true) ;
|
|
|
|
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : enterEvent()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_InitMeshDlg::enterEvent(QEvent* e)
|
|
|
|
{
|
2004-06-18 14:34:31 +06:00
|
|
|
if ( !GroupC1->isEnabled() )
|
|
|
|
ActivateThisDialog() ;
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : closeEvent()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_InitMeshDlg::closeEvent( QCloseEvent* e )
|
|
|
|
{
|
2004-06-18 14:34:31 +06:00
|
|
|
disconnect( mySelection, 0, this, 0 );
|
|
|
|
mySMESHGUI->ResetState() ;
|
|
|
|
mySelection->ClearFilters() ;
|
|
|
|
QDialog::closeEvent( e );
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
2004-06-18 14:34:31 +06:00
|
|
|
// function : UpdateControlState()
|
2003-05-19 20:07:00 +06:00
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2004-06-18 14:34:31 +06:00
|
|
|
void SMESHGUI_InitMeshDlg::UpdateControlState()
|
|
|
|
{
|
|
|
|
bool isEnabled = ( !myGeomShape->_is_nil() && HypoList.count() && AlgoList.count() );
|
|
|
|
|
|
|
|
buttonOk ->setEnabled( isEnabled );
|
|
|
|
buttonApply->setEnabled( isEnabled );
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
2004-06-18 14:34:31 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
//=================================================================================
|
|
|
|
// function : GetDefaultMeshName()
|
|
|
|
// purpose : Generates default mesh name(Mesh_1, Mesh_2, etc.)
|
|
|
|
//=================================================================================
|
|
|
|
QString SMESHGUI_InitMeshDlg::GetDefaultMeshName()
|
|
|
|
{
|
|
|
|
SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
|
|
|
|
int aNumber = 0;
|
|
|
|
QString aMeshName;
|
|
|
|
SALOMEDS::SObject_var obj;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
aMeshName = QString(tr("SMESH_OBJECT_MESH")) +"_"+QString::number(++aNumber);
|
|
|
|
obj = aStudy->FindObject(aMeshName);
|
|
|
|
}
|
|
|
|
while (!obj->_is_nil());
|
2004-06-18 14:34:31 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
return aMeshName;
|
|
|
|
}
|
2004-06-18 14:34:31 +06:00
|
|
|
|
|
|
|
|
|
|
|
|