00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "SMESHGUI_Hypotheses.h"
00027
00028 #include "SMESHGUI.h"
00029 #include "SMESHGUI_HypothesesUtils.h"
00030 #include "SMESHGUI_Utils.h"
00031 #include "SMESHGUI_SpinBox.h"
00032
00033
00034 #include <SALOMEDSClient_Study.hxx>
00035 #include <utilities.h>
00036
00037
00038 #include <SUIT_Session.h>
00039 #include <SUIT_MessageBox.h>
00040 #include <SUIT_ResourceMgr.h>
00041 #include <LightApp_Application.h>
00042 #include <SalomeApp_IntSpinBox.h>
00043
00044
00045 #include <QFrame>
00046 #include <QLineEdit>
00047 #include <QLabel>
00048 #include <QGroupBox>
00049 #include <QVBoxLayout>
00050
00051 #define SPACING 6
00052 #define MARGIN 11
00053
00054
00055
00056 #define WITHGENERICOBJ
00057
00058 SMESHGUI_GenericHypothesisCreator::SMESHGUI_GenericHypothesisCreator( const QString& theHypType )
00059 : myHypType( theHypType ), myIsCreate( false ), myDlg( 0 )
00060 {
00061 }
00062
00063 SMESHGUI_GenericHypothesisCreator::~SMESHGUI_GenericHypothesisCreator()
00064 {
00065 }
00066
00067 void SMESHGUI_GenericHypothesisCreator::setInitParamsHypothesis(SMESH::SMESH_Hypothesis_ptr hyp)
00068 {
00069 if ( !CORBA::is_nil( hyp ) && hypType() == hyp->GetName() )
00070 myInitParamsHypo = SMESH::SMESH_Hypothesis::_duplicate( hyp );
00071 }
00072
00073 void SMESHGUI_GenericHypothesisCreator::create( SMESH::SMESH_Hypothesis_ptr initParamsHyp,
00074 const QString& theHypName,
00075 QWidget* parent, QObject* obj, const QString& slot )
00076 {
00077 MESSAGE( "Creation of hypothesis with initial params" );
00078 setInitParamsHypothesis( initParamsHyp );
00079 create( false, theHypName, parent, obj, slot );
00080 }
00081
00082 void SMESHGUI_GenericHypothesisCreator::create( bool isAlgo,
00083 const QString& theHypName,
00084 QWidget* theParent, QObject* obj, const QString& slot )
00085 {
00086 MESSAGE( "Creation of hypothesis" );
00087
00088 myIsCreate = true;
00089
00090
00091 if (isAlgo) {
00092 SMESH::SMESH_Hypothesis_var anAlgo =
00093 SMESH::CreateHypothesis( hypType(), theHypName, isAlgo );
00094 #ifdef WITHGENERICOBJ
00095 if (!CORBA::is_nil(anAlgo))
00096 anAlgo->UnRegister();
00097 #endif
00098 }
00099 else {
00100 SMESH::SMESH_Hypothesis_var aHypothesis =
00101 SMESH::CreateHypothesis( hypType(), theHypName, false );
00102 editHypothesis( aHypothesis.in(), theHypName, theParent, obj, slot );
00103 #ifdef WITHGENERICOBJ
00104 if (!CORBA::is_nil(aHypothesis))
00105 aHypothesis->UnRegister();
00106 #endif
00107 }
00108 }
00109
00110 void SMESHGUI_GenericHypothesisCreator::edit( SMESH::SMESH_Hypothesis_ptr theHypothesis,
00111 const QString& theHypName,
00112 QWidget* theParent, QObject* obj, const QString& slot )
00113 {
00114 if( CORBA::is_nil( theHypothesis ) )
00115 return;
00116
00117 MESSAGE("Edition of hypothesis");
00118
00119 myIsCreate = false;
00120
00121 editHypothesis( theHypothesis, theHypName, theParent, obj, slot );
00122 }
00123
00124 void SMESHGUI_GenericHypothesisCreator::editHypothesis( SMESH::SMESH_Hypothesis_ptr h,
00125 const QString& theHypName,
00126 QWidget* theParent,
00127 QObject* obj, const QString& slot )
00128 {
00129 myHypName = theHypName;
00130 myHypo = SMESH::SMESH_Hypothesis::_duplicate( h );
00131 #ifdef WITHGENERICOBJ
00132 myHypo->Register();
00133 #endif
00134
00135 SMESHGUI_HypothesisDlg* Dlg = new SMESHGUI_HypothesisDlg( this, theParent );
00136 connect( Dlg, SIGNAL( finished( int ) ), this, SLOT( onDialogFinished( int ) ) );
00137 connect( this, SIGNAL( finished( int ) ), obj, slot.toLatin1().constData() );
00138 connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalCloseAllDialogs() ), Dlg, SLOT( reject() ));
00139
00140 myDlg = Dlg;
00141 QFrame* fr = buildFrame();
00142 if( fr )
00143 {
00144 Dlg->setCustomFrame( fr );
00145 Dlg->setWindowTitle( caption() );
00146 Dlg->setObjectName( theHypName );
00147 Dlg->setHIcon( icon() );
00148 Dlg->setType( type() );
00149 retrieveParams();
00150 Dlg->show();
00151 Dlg->resize( Dlg->minimumSizeHint() );
00152 }
00153 else
00154 emit finished( QDialog::Accepted );
00155 }
00156
00157 QFrame* SMESHGUI_GenericHypothesisCreator::buildStdFrame()
00158 {
00159 if( CORBA::is_nil( hypothesis() ) )
00160 return 0;
00161
00162 ListOfStdParams params;
00163 if( !stdParams( params ) || params.isEmpty() )
00164 return 0;
00165
00166 QFrame* fr = new QFrame( 0 );
00167 QVBoxLayout* lay = new QVBoxLayout( fr );
00168 lay->setMargin( 5 );
00169 lay->setSpacing( 0 );
00170
00171 QGroupBox* GroupC1 = new QGroupBox( tr( "SMESH_ARGUMENTS" ), fr );
00172 lay->addWidget( GroupC1 );
00173
00174 QGridLayout* GroupC1Layout = new QGridLayout( GroupC1 );
00175 GroupC1Layout->setSpacing( SPACING );
00176 GroupC1Layout->setMargin( MARGIN );
00177
00178 ListOfStdParams::const_iterator anIt = params.begin(), aLast = params.end();
00179 for( int i=0; anIt!=aLast; anIt++, i++ )
00180 {
00181 QLabel* lab = new QLabel( (*anIt).myName, GroupC1 );
00182 GroupC1Layout->addWidget( lab, i, 0 );
00183
00184 QWidget* w = getCustomWidget( *anIt, GroupC1, i );
00185 if ( !w )
00186 switch( (*anIt).myValue.type() )
00187 {
00188 case QVariant::Int:
00189 {
00190 SalomeApp_IntSpinBox* sb = new SalomeApp_IntSpinBox( GroupC1 );
00191 sb->setObjectName( (*anIt).myName );
00192 attuneStdWidget( sb, i );
00193 sb->setValue( (*anIt).myValue.toInt() );
00194 connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
00195 w = sb;
00196 }
00197 break;
00198 case QVariant::Double:
00199 {
00200 SalomeApp_DoubleSpinBox* sb = new SMESHGUI_SpinBox( GroupC1 );
00201 sb->setObjectName( (*anIt).myName );
00202 attuneStdWidget( sb, i );
00203 sb->setValue( (*anIt).myValue.toDouble() );
00204 connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
00205 w = sb;
00206 }
00207 break;
00208 case QVariant::String:
00209 {
00210 if((*anIt).isVariable) {
00211 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
00212 QString aVar = (*anIt).myValue.toString();
00213 if(aStudy->IsInteger(aVar.toLatin1().constData())){
00214 SalomeApp_IntSpinBox* sb = new SalomeApp_IntSpinBox( GroupC1 );
00215 sb->setObjectName( (*anIt).myName );
00216 attuneStdWidget( sb, i );
00217 sb->setText( aVar );
00218 connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
00219 w = sb;
00220 }
00221 else if(aStudy->IsReal(aVar.toLatin1().constData())){
00222 SalomeApp_DoubleSpinBox* sb = new SMESHGUI_SpinBox( GroupC1 );
00223 sb->setObjectName( (*anIt).myName );
00224 attuneStdWidget( sb, i );
00225 sb->setText( aVar );
00226 connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
00227 w = sb;
00228 }
00229 }
00230 else {
00231 QLineEdit* le = new QLineEdit( GroupC1 );
00232 le->setObjectName( (*anIt).myName );
00233 attuneStdWidget( le, i );
00234 le->setText( (*anIt).myValue.toString() );
00235 connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
00236 w = le;
00237 }
00238 }
00239 break;
00240 }
00241
00242 if( w )
00243 {
00244 GroupC1Layout->addWidget( w, i, 1 );
00245 changeWidgets().append( w );
00246 }
00247 }
00248
00249 return fr;
00250 }
00251
00252 void SMESHGUI_GenericHypothesisCreator::onValueChanged()
00253 {
00254 valueChanged( (QWidget*) sender() );
00255 }
00256
00257 void SMESHGUI_GenericHypothesisCreator::valueChanged( QWidget* )
00258 {
00259 }
00260
00261 void SMESHGUI_GenericHypothesisCreator::onDialogFinished( int result )
00262 {
00263 bool res = result==QDialog::Accepted;
00264 if( res )
00265 {
00266 storeParams();
00267
00268
00269
00270
00271
00272 }
00273
00274 changeWidgets().clear();
00275
00276 if( myIsCreate && !res )
00277 {
00278
00279 _PTR(SObject) aHypSObject = SMESH::FindSObject( myHypo );
00280 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
00281 if( aStudy && !aStudy->GetProperties()->IsLocked() )
00282 {
00283 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
00284 aBuilder->RemoveObjectWithChildren( aHypSObject );
00285 }
00286 }
00287 else if( !myIsCreate && res )
00288 {
00289 SMESH::SObjectList listSOmesh = SMESH::GetMeshesUsingAlgoOrHypothesis( myHypo );
00290 if( listSOmesh.size() > 0 )
00291 for( int i = 0; i < listSOmesh.size(); i++ )
00292 {
00293 _PTR(SObject) submSO = listSOmesh[i];
00294 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( submSO );
00295 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( submSO );
00296 if( !aSubMesh->_is_nil() )
00297 aMesh = aSubMesh->GetFather();
00298 _PTR(SObject) meshSO = SMESH::FindSObject( aMesh );
00299 SMESH::ModifiedMesh( meshSO, false, aMesh->NbNodes()==0);
00300 }
00301 }
00302 SMESHGUI::GetSMESHGUI()->updateObjBrowser( true, 0 );
00303 #ifdef WITHGENERICOBJ
00304 myHypo->UnRegister();
00305 #endif
00306 myHypo = SMESH::SMESH_Hypothesis::_nil();
00307 myInitParamsHypo = SMESH::SMESH_Hypothesis::_nil();
00308
00309 disconnect( myDlg, SIGNAL( finished( int ) ), this, SLOT( onDialogFinished( int ) ) );
00310 myDlg->close();
00311
00312 myDlg = 0;
00313 emit finished( result );
00314 }
00315
00316 bool SMESHGUI_GenericHypothesisCreator::stdParams( ListOfStdParams& ) const
00317 {
00318 return false;
00319 }
00320
00321 bool SMESHGUI_GenericHypothesisCreator::getStdParamFromDlg( ListOfStdParams& params ) const
00322 {
00323 bool res = true;
00324 StdParam item;
00325 ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
00326 for( ; anIt!=aLast; anIt++ )
00327 {
00328 item.myName = (*anIt)->objectName();
00329 if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) )
00330 {
00331 SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
00332 item.myValue = sb->value();
00333 params.append( item );
00334 }
00335 else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) )
00336 {
00337 SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt );
00338 item.myValue = sb->value();
00339 params.append( item );
00340 }
00341 else if( (*anIt)->inherits( "QLineEdit" ) )
00342 {
00343 QLineEdit* line = ( QLineEdit* )( *anIt );
00344 item.myValue = line->text();
00345 params.append( item );
00346 }
00347 else if ( getParamFromCustomWidget( item, *anIt ))
00348 {
00349 params.append( item );
00350 }
00351 else
00352 res = false;
00353 }
00354 return res;
00355 }
00356
00357
00358 QStringList SMESHGUI_GenericHypothesisCreator::getVariablesFromDlg() const
00359 {
00360 QStringList aResult;
00361 ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
00362 for( ; anIt!=aLast; anIt++ ) {
00363 if( (*anIt)->inherits( "QAbstractSpinBox" ) ) {
00364 QAbstractSpinBox* sb = ( QAbstractSpinBox* )( *anIt );
00365 aResult.append(sb->text());
00366 }
00367 }
00368 return aResult;
00369 }
00370
00371 QString SMESHGUI_GenericHypothesisCreator::stdParamValues( const ListOfStdParams& params)
00372 {
00373 QString valueStr = "";
00374 ListOfStdParams::const_iterator param = params.begin(), aLast = params.end();
00375 uint len0 = 0;
00376 for( int i=0; param!=aLast; param++, i++ )
00377 {
00378 if ( valueStr.length() > len0 ) {
00379 valueStr += "; ";
00380 len0 = valueStr.length();
00381 }
00382 switch( (*param).myValue.type() )
00383 {
00384 case QVariant::Int:
00385 valueStr += valueStr.number( (*param).myValue.toInt() );
00386 break;
00387 case QVariant::Double:
00388 valueStr += valueStr.number( (*param).myValue.toDouble() );
00389 break;
00390 case QVariant::String:
00391 valueStr += (*param).myValue.toString();
00392 break;
00393 default:
00394 QVariant valCopy = (*param).myValue;
00395 valueStr += valCopy.toString();
00396 }
00397 }
00398 return valueStr;
00399 }
00400
00401 SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::hypothesis() const
00402 {
00403 return myHypo;
00404 }
00405
00406 void SMESHGUI_GenericHypothesisCreator::setShapeEntry( const QString& theEntry )
00407 {
00408 myShapeEntry = theEntry;
00409 }
00410
00411
00418
00419
00420 SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::initParamsHypothesis(const bool strictly) const
00421 {
00422 if ( strictly )
00423 return myInitParamsHypo;
00424 if ( !isCreation() || CORBA::is_nil( myInitParamsHypo ))
00425 return myHypo;
00426 return myInitParamsHypo;
00427 }
00428
00429 bool SMESHGUI_GenericHypothesisCreator::hasInitParamsHypothesis() const
00430 {
00431 return !CORBA::is_nil( myInitParamsHypo );
00432 }
00433
00434 QString SMESHGUI_GenericHypothesisCreator::hypType() const
00435 {
00436 return myHypType;
00437 }
00438
00439 QString SMESHGUI_GenericHypothesisCreator::hypName() const
00440 {
00441 return myHypName;
00442 }
00443
00444 const SMESHGUI_GenericHypothesisCreator::ListOfWidgets& SMESHGUI_GenericHypothesisCreator::widgets() const
00445 {
00446 return myParamWidgets;
00447 }
00448
00449 SMESHGUI_GenericHypothesisCreator::ListOfWidgets& SMESHGUI_GenericHypothesisCreator::changeWidgets()
00450 {
00451 return myParamWidgets;
00452 }
00453
00454 QtxDialog* SMESHGUI_GenericHypothesisCreator:: dlg() const
00455 {
00456 return myDlg;
00457 }
00458
00459 bool SMESHGUI_GenericHypothesisCreator::isCreation() const
00460 {
00461 return myIsCreate;
00462 }
00463
00464 void SMESHGUI_GenericHypothesisCreator::attuneStdWidget( QWidget*, const int ) const
00465 {
00466 }
00467
00468 QString SMESHGUI_GenericHypothesisCreator::caption() const
00469 {
00470 return QString();
00471 }
00472
00473 QPixmap SMESHGUI_GenericHypothesisCreator::icon() const
00474 {
00475 return QPixmap();
00476 }
00477
00478 QString SMESHGUI_GenericHypothesisCreator::type() const
00479 {
00480 return QString();
00481 }
00482 QWidget* SMESHGUI_GenericHypothesisCreator::getCustomWidget( const StdParam & ,
00483 QWidget* ,
00484 const int ) const
00485 {
00486 return 0;
00487 }
00488 bool SMESHGUI_GenericHypothesisCreator::getParamFromCustomWidget( StdParam&, QWidget* ) const
00489 {
00490 return false;
00491 }
00492
00493 bool SMESHGUI_GenericHypothesisCreator::checkParams( QString& msg ) const
00494 {
00495 bool ok = true;
00496 ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
00497 for( ; anIt!=aLast; anIt++ )
00498 {
00499 if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) )
00500 {
00501 SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
00502 ok = sb->isValid( msg, true ) && ok;
00503 }
00504 else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) )
00505 {
00506 SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt );
00507 ok = sb->isValid( msg, true ) && ok;
00508 }
00509 }
00510 return ok;
00511 }
00512
00513 void SMESHGUI_GenericHypothesisCreator::onReject()
00514 {
00515 }
00516
00517 QString SMESHGUI_GenericHypothesisCreator::helpPage() const
00518 {
00519 QString aHypType = hypType();
00520 QString aHelpFileName = "";
00521 if ( aHypType == "LocalLength" )
00522 aHelpFileName = "a1d_meshing_hypo_page.html#average_length_anchor";
00523 else if ( aHypType == "MaxLength" )
00524 aHelpFileName = "a1d_meshing_hypo_page.html#max_length_anchor";
00525 else if ( aHypType == "Arithmetic1D")
00526 aHelpFileName = "a1d_meshing_hypo_page.html#arithmetic_1d_anchor";
00527 else if ( aHypType == "FixedPoints1D")
00528 aHelpFileName = "a1d_meshing_hypo_page.html#fixed_points_1d_anchor";
00529 else if ( aHypType == "MaxElementArea")
00530 aHelpFileName = "a2d_meshing_hypo_page.html#max_element_area_anchor";
00531 else if ( aHypType == "MaxElementVolume")
00532 aHelpFileName = "max_element_volume_hypo_page.html";
00533 else if ( aHypType == "StartEndLength")
00534 aHelpFileName = "a1d_meshing_hypo_page.html#start_and_end_length_anchor";
00535 else if ( aHypType == "Deflection1D")
00536 aHelpFileName = "a1d_meshing_hypo_page.html#deflection_1d_anchor";
00537 else if ( aHypType == "AutomaticLength")
00538 aHelpFileName = "a1d_meshing_hypo_page.html#automatic_length_anchor";
00539 else if ( aHypType == "NumberOfSegments")
00540 aHelpFileName = "a1d_meshing_hypo_page.html#number_of_segments_anchor";
00541 else if ( aHypType == "ProjectionSource1D")
00542 aHelpFileName = "projection_algos_page.html";
00543 else if ( aHypType == "ProjectionSource2D")
00544 aHelpFileName = "projection_algos_page.html";
00545 else if ( aHypType == "ProjectionSource3D")
00546 aHelpFileName = "projection_algos_page.html";
00547 else if ( aHypType == "NumberOfLayers")
00548 aHelpFileName = "radial_prism_algo_page.html";
00549 else if ( aHypType == "NumberOfLayers2D")
00550 aHelpFileName = "radial_quadrangle_1D2D_algo_page.html";
00551 else if ( aHypType == "LayerDistribution")
00552 aHelpFileName = "radial_prism_algo_page.html";
00553 else if ( aHypType == "LayerDistribution2D")
00554 aHelpFileName = "radial_quadrangle_1D2D_algo_page.html";
00555 else if ( aHypType == "SegmentLengthAroundVertex")
00556 aHelpFileName = "segments_around_vertex_algo_page.html";
00557 else if ( aHypType == "QuadrangleParams")
00558 aHelpFileName = "a2d_meshing_hypo_page.html#hypo_quad_params_anchor";
00559 else if ( aHypType == "ViscousLayers")
00560 aHelpFileName = "additional_hypo_page.html#viscous_layers_anchor";
00561 else if ( aHypType == "ImportSource1D" || aHypType == "ImportSource2D")
00562 aHelpFileName = "import_algos_page.html";
00563 return aHelpFileName;
00564 }
00565
00566 SMESHGUI_HypothesisDlg::SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator* creator, QWidget* parent )
00567 : QtxDialog( parent, false, true ),
00568 myCreator( creator )
00569 {
00570 setAttribute(Qt::WA_DeleteOnClose, true);
00571
00572
00573 QVBoxLayout* topLayout = new QVBoxLayout( mainFrame() );
00574 topLayout->setMargin( 0 );
00575 topLayout->setSpacing( 0 );
00576
00577 QFrame* titFrame = new QFrame( mainFrame() );
00578 QHBoxLayout* titLay = new QHBoxLayout( titFrame );
00579 titLay->setMargin( 0 );
00580 titLay->setSpacing( SPACING );
00581
00582 myIconLabel = new QLabel( titFrame );
00583 myIconLabel->setScaledContents( false );
00584 myIconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
00585 myTypeLabel = new QLabel( titFrame );
00586 if( creator )
00587 myTypeLabel->setText( creator->hypType() );
00588
00589 titLay->addWidget( myIconLabel, 0 );
00590 titLay->addWidget( myTypeLabel, 0 );
00591 titLay->addStretch( 1 );
00592
00593 topLayout->addWidget( titFrame, 0 );
00594
00595 myHelpFileName = creator->helpPage();
00596
00597 connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
00598 }
00599
00600 SMESHGUI_HypothesisDlg::~SMESHGUI_HypothesisDlg()
00601 {
00602 delete myCreator;
00603 }
00604
00605 void SMESHGUI_HypothesisDlg::setCustomFrame( QFrame* f )
00606 {
00607 if( f )
00608 {
00609 f->setParent( mainFrame() );
00610 qobject_cast<QVBoxLayout*>( mainFrame()->layout() )->insertWidget( 1, f, 1 );
00611 }
00612 }
00613
00614 void SMESHGUI_HypothesisDlg::accept()
00615 {
00616 QString msg;
00617 if ( myCreator && !myCreator->checkParams( msg ) )
00618 {
00619 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
00620 if ( !msg.isEmpty() )
00621 str += "\n" + msg;
00622 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
00623 return;
00624 }
00625 QtxDialog::accept();
00626 }
00627
00628 void SMESHGUI_HypothesisDlg::reject()
00629 {
00630 if ( myCreator ) myCreator->onReject();
00631 QtxDialog::reject();
00632 }
00633
00634 void SMESHGUI_HypothesisDlg::onHelp()
00635 {
00636 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
00637 if (app) {
00638 SMESHGUI* aSMESHGUI = dynamic_cast<SMESHGUI*>( app->activeModule() );
00639 app->onHelpContextModule(aSMESHGUI ? app->moduleName(aSMESHGUI->moduleName()) : QString(""), myHelpFileName);
00640 }
00641 else {
00642 QString platform;
00643 #ifdef WIN32
00644 platform = "winapplication";
00645 #else
00646 platform = "application";
00647 #endif
00648 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
00649 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
00650 arg(app->resourceMgr()->stringValue("ExternalBrowser",
00651 platform)).
00652 arg(myHelpFileName));
00653 }
00654 }
00655
00656 void SMESHGUI_HypothesisDlg::setHIcon( const QPixmap& p )
00657 {
00658 myIconLabel->setPixmap( p );
00659 }
00660
00661 void SMESHGUI_HypothesisDlg::setType( const QString& t )
00662 {
00663 myTypeLabel->setText( t );
00664 }
00665
00666 HypothesisData::HypothesisData( const QString& theTypeName,
00667 const QString& thePluginName,
00668 const QString& theServerLibName,
00669 const QString& theClientLibName,
00670 const QString& theLabel,
00671 const QString& theIconId,
00672 const QList<int>& theDim,
00673 const bool theIsAux,
00674 const QStringList& theNeededHypos,
00675 const QStringList& theOptionalHypos,
00676 const QStringList& theInputTypes,
00677 const QStringList& theOutputTypes,
00678 const bool theIsNeedGeometry,
00679 const bool supportSub)
00680 : TypeName( theTypeName ),
00681 PluginName( thePluginName ),
00682 ServerLibName( theServerLibName ),
00683 ClientLibName( theClientLibName ),
00684 Label( theLabel ),
00685 IconId( theIconId ),
00686 Dim( theDim ),
00687 IsAux( theIsAux ),
00688 NeededHypos( theNeededHypos ),
00689 OptionalHypos( theOptionalHypos ),
00690 InputTypes( theInputTypes ),
00691 OutputTypes( theOutputTypes ),
00692 IsNeedGeometry( theIsNeedGeometry ),
00693 IsSupportSubmeshes( supportSub )
00694 {
00695 }
00696
00697 HypothesesSet::HypothesesSet( const QString& theSetName )
00698 : myHypoSetName( theSetName ),
00699 myIsAlgo( false ),
00700 myIsCustom( false )
00701 {
00702 }
00703
00704 HypothesesSet::HypothesesSet( const QString& theSetName,
00705 const QStringList& theHypoList,
00706 const QStringList& theAlgoList )
00707 : myHypoSetName( theSetName ),
00708 myHypoList( theHypoList ),
00709 myAlgoList( theAlgoList ),
00710 myIsAlgo( false ),
00711 myIsCustom( false )
00712 {
00713 }
00714
00715 QStringList* HypothesesSet::list(bool is_algo) const
00716 {
00717 return const_cast<QStringList*>( &( is_algo ? myAlgoList : myHypoList ) );
00718 }
00719
00720 QStringList* HypothesesSet::list() const
00721 {
00722 return list( myIsAlgo );
00723 }
00724
00725 QString HypothesesSet::name() const
00726 {
00727 return myHypoSetName;
00728 }
00729
00730 void HypothesesSet::set( bool isAlgo, const QStringList& lst )
00731 {
00732 *list(isAlgo) = lst;
00733 }
00734
00735 int HypothesesSet::count( bool isAlgo ) const
00736 {
00737 return list(isAlgo)->count();
00738 }
00739
00740 bool HypothesesSet::isAlgo() const
00741 {
00742 return myIsAlgo;
00743 }
00744
00745 void HypothesesSet::init( bool isAlgo )
00746 {
00747 myIsAlgo = isAlgo;
00748 myIndex = -1;
00749 }
00750
00751 bool HypothesesSet::more() const
00752 {
00753 return myIndex < list()->count();
00754 }
00755
00756 void HypothesesSet::next()
00757 {
00758 myIndex++;
00759 }
00760
00761 QString HypothesesSet::current() const
00762 {
00763 return list()->at(myIndex);
00764 }
00765
00766 void HypothesesSet::setIsCustom( bool isCustom )
00767 {
00768 myIsCustom = isCustom;
00769 }
00770
00771 bool HypothesesSet::getIsCustom() const
00772 {
00773 return myIsCustom;
00774 }
00775
00776 int HypothesesSet::maxDim() const
00777 {
00778 HypothesesSet * thisSet = (HypothesesSet*) this;
00779 int dim = -1;
00780 for ( int isAlgo = 0; isAlgo < 2; ++isAlgo )
00781 {
00782 thisSet->init( isAlgo );
00783 while ( thisSet->next(), thisSet->more() )
00784 if ( HypothesisData* hypData = SMESH::GetHypothesisData( thisSet->current() ))
00785 for ( int i = 0; i < hypData->Dim.count(); ++i )
00786 dim = qMax( dim, hypData->Dim[i] );
00787 }
00788 return dim;
00789 }