PAL13473 (Build repetitive mesh):

1) now dlg of MESHGUI_GenericHypothesisCreator is non modal
	2) make MESHGUI_GenericHypothesisCreator::dlg() work
This commit is contained in:
eap 2006-12-06 15:18:17 +00:00
parent b6766b8ebd
commit 8860097b4b
2 changed files with 46 additions and 19 deletions

View File

@ -43,9 +43,10 @@
#include <qpixmap.h> #include <qpixmap.h>
#include <qgroupbox.h> #include <qgroupbox.h>
#include <qapplication.h>
SMESHGUI_GenericHypothesisCreator::SMESHGUI_GenericHypothesisCreator( const QString& aHypType ) SMESHGUI_GenericHypothesisCreator::SMESHGUI_GenericHypothesisCreator( const QString& aHypType )
: myHypType( aHypType ), : myHypType( aHypType ), myIsCreate( false ), myDlg( 0 )
myIsCreate( false )
{ {
} }
@ -131,17 +132,22 @@ bool SMESHGUI_GenericHypothesisCreator::editHypothesis( SMESH::SMESH_Hypothesis_
bool res = true; bool res = true;
myHypo = SMESH::SMESH_Hypothesis::_duplicate( h ); myHypo = SMESH::SMESH_Hypothesis::_duplicate( h );
SMESHGUI_HypothesisDlg* Dlg =
new SMESHGUI_HypothesisDlg( const_cast<SMESHGUI_GenericHypothesisCreator*>( this ), parent );
myDlg = Dlg;
QFrame* fr = buildFrame(); QFrame* fr = buildFrame();
if( fr ) if( fr )
{ {
SMESHGUI_HypothesisDlg* dlg = Dlg->setCustomFrame( fr );
new SMESHGUI_HypothesisDlg( const_cast<SMESHGUI_GenericHypothesisCreator*>( this ), parent ); Dlg->setCaption( caption() );
dlg->setCustomFrame( fr ); Dlg->setHIcon( icon() );
dlg->setCaption( caption() ); Dlg->setType( type() );
dlg->setHIcon( icon() );
dlg->setType( type() );
retrieveParams(); retrieveParams();
res = dlg->exec()==QDialog::Accepted; Dlg->show();
//connect(myDlg, SIGNAL( closed() ), this, SLOT( onDlgClosed() ));
qApp->enter_loop(); // make myDlg not modal
// res = myDlg->exec()==QDialog::Accepted;
res = myDlg->result();
if( res ) { if( res ) {
QString paramValues = storeParams(); QString paramValues = storeParams();
if ( !paramValues.isEmpty() ) { if ( !paramValues.isEmpty() ) {
@ -149,14 +155,14 @@ bool SMESHGUI_GenericHypothesisCreator::editHypothesis( SMESH::SMESH_Hypothesis_
SMESH::SetValue( SHyp, paramValues ); SMESH::SetValue( SHyp, paramValues );
} }
} }
delete dlg;
} }
delete Dlg; myDlg = 0;
changeWidgets().clear(); changeWidgets().clear();
myHypo = SMESH::SMESH_Hypothesis::_nil(); myHypo = SMESH::SMESH_Hypothesis::_nil();
myInitParamsHypo = SMESH::SMESH_Hypothesis::_nil(); myInitParamsHypo = SMESH::SMESH_Hypothesis::_nil();
return res; return res;
} }
QFrame* SMESHGUI_GenericHypothesisCreator::buildStdFrame() QFrame* SMESHGUI_GenericHypothesisCreator::buildStdFrame()
{ {
if( CORBA::is_nil( hypothesis() ) ) if( CORBA::is_nil( hypothesis() ) )
@ -187,7 +193,7 @@ QFrame* SMESHGUI_GenericHypothesisCreator::buildStdFrame()
QLabel* lab = new QLabel( (*anIt).myName, GroupC1 ); QLabel* lab = new QLabel( (*anIt).myName, GroupC1 );
GroupC1Layout->addWidget( lab, i, 0 ); GroupC1Layout->addWidget( lab, i, 0 );
QWidget* w = getCustomWidget( *anIt, GroupC1 ); QWidget* w = getCustomWidget( *anIt, GroupC1, i );
if ( !w ) if ( !w )
switch( (*anIt).myValue.type() ) switch( (*anIt).myValue.type() )
{ {
@ -283,10 +289,13 @@ QString SMESHGUI_GenericHypothesisCreator::stdParamValues( const ListOfStdParams
{ {
QString valueStr = ""; QString valueStr = "";
ListOfStdParams::const_iterator param = params.begin(), aLast = params.end(); ListOfStdParams::const_iterator param = params.begin(), aLast = params.end();
uint len0 = 0;
for( int i=0; param!=aLast; param++, i++ ) for( int i=0; param!=aLast; param++, i++ )
{ {
if ( i > 0 ) if ( valueStr.length() > len0 ) {
valueStr += "; "; valueStr += "; ";
len0 = valueStr.length();
}
switch( (*param).myValue.type() ) switch( (*param).myValue.type() )
{ {
case QVariant::Int: case QVariant::Int:
@ -357,7 +366,8 @@ QString SMESHGUI_GenericHypothesisCreator::type() const
return QString(); return QString();
} }
QWidget* SMESHGUI_GenericHypothesisCreator::getCustomWidget( const StdParam & /*param*/, QWidget* SMESHGUI_GenericHypothesisCreator::getCustomWidget( const StdParam & /*param*/,
QWidget* /*parent*/) const QWidget* /*parent*/,
const int /*index*/) const
{ {
return 0; return 0;
} }
@ -366,11 +376,15 @@ bool SMESHGUI_GenericHypothesisCreator::getParamFromCustomWidget( StdParam& , QW
return false; return false;
} }
void SMESHGUI_GenericHypothesisCreator::onReject()
{
}
SMESHGUI_HypothesisDlg::SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator* creator, QWidget* parent ) SMESHGUI_HypothesisDlg::SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator* creator, QWidget* parent )
: QtxDialog( parent, "", true, true ), : QtxDialog( parent, "", false, true ),
myCreator( creator ) myCreator( creator )
{ {
setMinimumSize( 300, height() ); setMinimumSize( 300, height() );
@ -414,7 +428,6 @@ SMESHGUI_HypothesisDlg::SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreato
myHelpFileName = ""; myHelpFileName = "";
connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) ); connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
} }
SMESHGUI_HypothesisDlg::~SMESHGUI_HypothesisDlg() SMESHGUI_HypothesisDlg::~SMESHGUI_HypothesisDlg()
@ -432,8 +445,17 @@ void SMESHGUI_HypothesisDlg::setCustomFrame( QFrame* f )
void SMESHGUI_HypothesisDlg::accept() void SMESHGUI_HypothesisDlg::accept()
{ {
if( !myCreator || myCreator->checkParams() ) if ( myCreator && !myCreator->checkParams() )
QtxDialog::accept(); return;
QtxDialog::accept();
qApp->exit_loop();
}
void SMESHGUI_HypothesisDlg::reject()
{
if ( myCreator ) myCreator->onReject();
QtxDialog::reject();
qApp->exit_loop();
} }
void SMESHGUI_HypothesisDlg::onHelp() void SMESHGUI_HypothesisDlg::onHelp()

View File

@ -51,7 +51,9 @@ public:
void create( const bool isAlgo, QWidget* ); void create( const bool isAlgo, QWidget* );
void edit( SMESH::SMESH_Hypothesis_ptr, QWidget* ); void edit( SMESH::SMESH_Hypothesis_ptr, QWidget* );
void create( SMESH::SMESH_Hypothesis_ptr, QWidget* ); void create( SMESH::SMESH_Hypothesis_ptr, QWidget* );
virtual bool checkParams() const = 0; virtual bool checkParams() const = 0;
virtual void onReject();
QString hypType() const; QString hypType() const;
bool isCreation() const; bool isCreation() const;
@ -71,6 +73,7 @@ protected:
SMESH::SMESH_Hypothesis_var initParamsHypothesis() const; SMESH::SMESH_Hypothesis_var initParamsHypothesis() const;
const ListOfWidgets& widgets() const; const ListOfWidgets& widgets() const;
ListOfWidgets& changeWidgets(); ListOfWidgets& changeWidgets();
QtxDialog* dlg() const { return myDlg; }
virtual QFrame* buildFrame () = 0; virtual QFrame* buildFrame () = 0;
QFrame* buildStdFrame (); QFrame* buildStdFrame ();
@ -80,7 +83,7 @@ protected:
bool getStdParamFromDlg( ListOfStdParams& ) const; bool getStdParamFromDlg( ListOfStdParams& ) const;
static QString stdParamValues( const ListOfStdParams& ); static QString stdParamValues( const ListOfStdParams& );
virtual void attuneStdWidget( QWidget*, const int ) const; virtual void attuneStdWidget( QWidget*, const int ) const;
virtual QWidget* getCustomWidget( const StdParam &, QWidget* ) const; virtual QWidget* getCustomWidget( const StdParam &, QWidget*, const int ) const;
virtual bool getParamFromCustomWidget( StdParam& , QWidget* ) const; virtual bool getParamFromCustomWidget( StdParam& , QWidget* ) const;
virtual QString caption() const; virtual QString caption() const;
virtual QPixmap icon() const; virtual QPixmap icon() const;
@ -97,6 +100,7 @@ private:
QString myHypType; QString myHypType;
ListOfWidgets myParamWidgets; ListOfWidgets myParamWidgets;
bool myIsCreate; bool myIsCreate;
QtxDialog* myDlg;
}; };
class SMESHGUI_HypothesisDlg : public QtxDialog class SMESHGUI_HypothesisDlg : public QtxDialog
@ -113,6 +117,7 @@ public:
protected slots: protected slots:
virtual void accept(); virtual void accept();
virtual void reject();
void onHelp(); void onHelp();
private: private: