Salome HOME
793cc17518e2b183a1fc31e78f1db8cadc332d14
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_Hypotheses.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // SMESH SMESHGUI : GUI for SMESH component
23 // File   : SMESHGUI_Hypotheses.cxx
24 // Author : Julia DOROVSKIKH, Open CASCADE S.A.S.
25 // SMESH includes
26 //
27 #include "SMESHGUI_Hypotheses.h"
28
29 #include "SMESHGUI.h"
30 #include "SMESHGUI_HypothesesUtils.h"
31 #include "SMESHGUI_Utils.h"
32 #include "SMESHGUI_SpinBox.h"
33
34 // SALOME KERNEL includes
35 #include <SALOMEDSClient_Study.hxx>
36 #include <utilities.h>
37
38 // SALOME GUI includes
39 #include <SUIT_Session.h>
40 #include <SUIT_MessageBox.h>
41 #include <SUIT_ResourceMgr.h>
42 #include <LightApp_Application.h>
43 #include <SalomeApp_Application.h>
44 #include <SalomeApp_IntSpinBox.h>
45
46 // Qt includes
47 #include <QFrame>
48 #include <QLineEdit>
49 #include <QLabel>
50 #include <QGroupBox>
51 #include <QVBoxLayout>
52
53 #define SPACING 6
54 #define MARGIN  11
55
56 SMESHGUI_GenericHypothesisCreator::SMESHGUI_GenericHypothesisCreator( const QString& theHypType )
57   : myHypType( theHypType ), myIsCreate( false ), myDlg( 0 )
58 {
59 }
60
61 SMESHGUI_GenericHypothesisCreator::~SMESHGUI_GenericHypothesisCreator()
62 {
63 }
64
65 void SMESHGUI_GenericHypothesisCreator::setInitParamsHypothesis(SMESH::SMESH_Hypothesis_ptr hyp)
66 {
67   if ( !CORBA::is_nil( hyp ) && hypType() == hyp->GetName() )
68     myInitParamsHypo = SMESH::SMESH_Hypothesis::_duplicate( hyp );
69 }
70
71 void SMESHGUI_GenericHypothesisCreator::create( SMESH::SMESH_Hypothesis_ptr initParamsHyp,
72                                                 const QString& theHypName,
73                                                 QWidget* parent, QObject* obj, const QString& slot )
74 {
75   MESSAGE( "Creation of hypothesis with initial params" );
76   setInitParamsHypothesis( initParamsHyp );
77   create( false, theHypName, parent, obj, slot );
78 }
79
80 void SMESHGUI_GenericHypothesisCreator::create( bool isAlgo,
81                                                 const QString& theHypName,
82                                                 QWidget* theParent, QObject* obj, const QString& slot )
83 {
84   MESSAGE( "Creation of hypothesis" );
85
86   myIsCreate = true;
87
88   // Create hypothesis/algorithm
89   if (isAlgo)
90     SMESH::CreateHypothesis( hypType(), theHypName, isAlgo );
91
92   else
93   {
94     SMESH::SMESH_Hypothesis_var aHypothesis = 
95       SMESH::CreateHypothesis( hypType(), theHypName, false );
96     editHypothesis( aHypothesis.in(), theHypName, theParent, obj, slot );
97   }
98 }
99
100 void SMESHGUI_GenericHypothesisCreator::edit( SMESH::SMESH_Hypothesis_ptr theHypothesis,
101                                               const QString& theHypName,
102                                               QWidget* theParent, QObject* obj, const QString& slot )
103 {
104   if( CORBA::is_nil( theHypothesis ) )
105     return;
106
107   MESSAGE("Edition of hypothesis");
108
109   myIsCreate = false;
110
111   editHypothesis( theHypothesis, theHypName, theParent, obj, slot );
112 }
113
114 void SMESHGUI_GenericHypothesisCreator::editHypothesis( SMESH::SMESH_Hypothesis_ptr h, 
115                                                         const QString& theHypName,
116                                                         QWidget* theParent,
117                                                         QObject* obj, const QString& slot )
118 {
119   myHypName = theHypName;
120   myHypo = SMESH::SMESH_Hypothesis::_duplicate( h );
121
122   SMESHGUI_HypothesisDlg* Dlg = new SMESHGUI_HypothesisDlg( this, theParent );
123   connect( Dlg, SIGNAL( finished( int ) ), this, SLOT( onDialogFinished( int ) ) );
124   connect( this, SIGNAL( finished( int ) ), obj, slot.toLatin1().constData() );
125
126   myDlg = Dlg;
127   QFrame* fr = buildFrame();
128   if( fr )
129   {
130     Dlg->setCustomFrame( fr );
131     Dlg->setWindowTitle( caption() );
132     Dlg->setObjectName( theHypName );
133     Dlg->setHIcon( icon() );
134     Dlg->setType( type() );
135     retrieveParams();
136     Dlg->show();
137     Dlg->resize( Dlg->minimumSizeHint() );
138   }
139   else
140     emit finished( QDialog::Accepted );
141 }
142   
143 QFrame* SMESHGUI_GenericHypothesisCreator::buildStdFrame()
144 {
145   if( CORBA::is_nil( hypothesis() ) )
146     return 0;
147
148   ListOfStdParams params;
149   if( !stdParams( params ) || params.isEmpty() )
150     return 0;
151
152   QFrame* fr = new QFrame( 0 );
153   QVBoxLayout* lay = new QVBoxLayout( fr );
154   lay->setMargin( 5 );
155   lay->setSpacing( 0 );
156
157   QGroupBox* GroupC1 = new QGroupBox( tr( "SMESH_ARGUMENTS" ), fr );
158   lay->addWidget( GroupC1 );
159
160   QGridLayout* GroupC1Layout = new QGridLayout( GroupC1 );
161   GroupC1Layout->setSpacing( SPACING );
162   GroupC1Layout->setMargin( MARGIN );
163
164   ListOfStdParams::const_iterator anIt = params.begin(), aLast = params.end();
165   for( int i=0; anIt!=aLast; anIt++, i++ )
166   {
167     QLabel* lab = new QLabel( (*anIt).myName, GroupC1 );
168     GroupC1Layout->addWidget( lab, i, 0 );
169
170     QWidget* w = getCustomWidget( *anIt, GroupC1, i );
171     if ( !w ) 
172       switch( (*anIt).myValue.type() )
173       {
174       case QVariant::Int:
175         {
176           SalomeApp_IntSpinBox* sb = new SalomeApp_IntSpinBox( GroupC1 );
177           sb->setObjectName( (*anIt).myName );
178           attuneStdWidget( sb, i );
179           sb->setValue( (*anIt).myValue.toInt() );
180           connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
181           w = sb;
182         }
183         break;
184       case QVariant::Double:
185         {
186           SalomeApp_DoubleSpinBox* sb = new SMESHGUI_SpinBox( GroupC1 );
187           sb->setObjectName( (*anIt).myName );
188           attuneStdWidget( sb, i );
189           sb->setValue( (*anIt).myValue.toDouble() );
190           connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
191           w = sb;
192         }
193         break;
194       case QVariant::String:
195         {
196           /* ouv: temporarily disabled
197           if((*anIt).isVariable) {
198             _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
199             QString aVar = (*anIt).myValue.toString();
200             if(aStudy->IsInteger(aVar.toLatin1().constData())){
201               SalomeApp_IntSpinBox* sb = new SalomeApp_IntSpinBox( GroupC1 );
202               sb->setObjectName( (*anIt).myName );
203               attuneStdWidget( sb, i );
204               sb->setText( aVar );
205               connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
206               w = sb;
207             }
208             else if(aStudy->IsReal(aVar.toLatin1().constData())){
209               SalomeApp_DoubleSpinBox* sb = new SMESHGUI_SpinBox( GroupC1 );
210               sb->setObjectName( (*anIt).myName );
211               attuneStdWidget( sb, i );
212               sb->setText( aVar );
213               connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
214               w = sb;
215             }
216           }
217           else {
218           */
219             QLineEdit* le = new QLineEdit( GroupC1 );
220             le->setObjectName( (*anIt).myName );
221             attuneStdWidget( le, i );
222             le->setText( (*anIt).myValue.toString() );
223             connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
224             w = le;
225           //}
226         }
227         break;
228       }
229
230     if( w )
231     {
232       GroupC1Layout->addWidget( w, i, 1 );
233       changeWidgets().append( w );
234     }
235   }
236
237   return fr;
238 }
239
240 void SMESHGUI_GenericHypothesisCreator::onValueChanged()
241 {
242   valueChanged( (QWidget*) sender() );
243 }
244
245 void SMESHGUI_GenericHypothesisCreator::valueChanged( QWidget* )
246 {
247 }
248
249 void SMESHGUI_GenericHypothesisCreator::onDialogFinished( int result )
250 {
251   bool res = result==QDialog::Accepted;
252   if( res )
253   {
254       /*QString paramValues = */storeParams();
255       // No longer needed since NoteBook appears and "Value" OB field shows names of variable
256 //       if ( !paramValues.isEmpty() ) {
257 //         if ( _PTR(SObject) SHyp = SMESH::FindSObject( myHypo ))
258 //           SMESH::SetValue( SHyp, paramValues );
259 //       }
260   }
261
262   changeWidgets().clear();
263
264   if( myIsCreate && !res )
265   {
266     //remove just created hypothesis
267     _PTR(SObject) aHypSObject = SMESH::FindSObject( myHypo );
268     _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
269     if( aStudy && !aStudy->GetProperties()->IsLocked() )
270     {
271       _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
272       aBuilder->RemoveObjectWithChildren( aHypSObject );
273     }
274   }
275   else if( !myIsCreate && res )
276   {
277     SMESH::SObjectList listSOmesh = SMESH::GetMeshesUsingAlgoOrHypothesis( myHypo );
278     if( listSOmesh.size() > 0 )
279       for( int i = 0; i < listSOmesh.size(); i++ )
280       {
281         _PTR(SObject) submSO = listSOmesh[i];
282         SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( submSO );
283         SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( submSO );
284         if( !aSubMesh->_is_nil() )
285           aMesh = aSubMesh->GetFather();
286         _PTR(SObject) meshSO = SMESH::FindSObject( aMesh );
287         SMESH::ModifiedMesh( meshSO, false, aMesh->NbNodes()==0);
288       }
289   }
290   SMESHGUI::GetSMESHGUI()->updateObjBrowser( true, 0 );
291   myHypo = SMESH::SMESH_Hypothesis::_nil();
292   myInitParamsHypo = SMESH::SMESH_Hypothesis::_nil();
293
294   disconnect( myDlg, SIGNAL( finished( int ) ), this, SLOT( onDialogFinished( int ) ) );
295   myDlg->close();
296   //delete myDlg;
297   myDlg = 0;
298   emit finished( result );
299 }
300
301 bool SMESHGUI_GenericHypothesisCreator::stdParams( ListOfStdParams& ) const
302 {
303   return false;
304 }
305
306 bool SMESHGUI_GenericHypothesisCreator::getStdParamFromDlg( ListOfStdParams& params ) const
307 {
308   bool res = true;
309   StdParam item;
310   ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
311   for( ; anIt!=aLast; anIt++ )
312   {
313     item.myName = (*anIt)->objectName();
314     if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) )
315     {
316       SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
317       item.myValue = sb->value();
318       params.append( item );
319     }
320     
321     else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) )
322     {
323       SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt );
324       item.myValue = sb->value();
325       params.append( item );
326     }
327
328     else if( (*anIt)->inherits( "QLineEdit" ) )
329     {
330       QLineEdit* line = ( QLineEdit* )( *anIt );
331       item.myValue = line->text();
332       params.append( item );
333     }
334
335     else if ( getParamFromCustomWidget( item, *anIt ))
336     {
337       params.append( item );
338     }
339
340     else
341       res = false;
342   }
343   return res;
344 }
345
346
347 QStringList SMESHGUI_GenericHypothesisCreator::getVariablesFromDlg() const
348 {
349   QStringList aResult;
350   ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
351   for( ; anIt!=aLast; anIt++ ) {
352     if( (*anIt)->inherits( "QAbstractSpinBox" ) ) {
353       QAbstractSpinBox* sb = ( QAbstractSpinBox* )( *anIt );
354       aResult.append(sb->text());
355     } 
356   }
357   return aResult;
358 }
359
360 QString SMESHGUI_GenericHypothesisCreator::stdParamValues( const ListOfStdParams& params)
361 {
362   QString valueStr = "";
363   ListOfStdParams::const_iterator param = params.begin(), aLast = params.end();
364   uint len0 = 0;
365   for( int i=0; param!=aLast; param++, i++ )
366   {
367     if ( valueStr.length() > len0 ) {
368       valueStr += "; ";
369       len0 = valueStr.length();
370     }
371     switch( (*param).myValue.type() )
372     {
373     case QVariant::Int:
374       valueStr += valueStr.number( (*param).myValue.toInt() );
375       break;
376     case QVariant::Double:
377       valueStr += valueStr.number( (*param).myValue.toDouble() );
378       break;
379     case QVariant::String:
380       valueStr += (*param).myValue.toString();
381       break;
382     default:
383       QVariant valCopy = (*param).myValue;
384       valueStr += valCopy.toString();
385     }
386   }
387   return valueStr;
388 }
389
390 SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::hypothesis() const
391 {
392   return myHypo;
393 }
394
395 void SMESHGUI_GenericHypothesisCreator::setShapeEntry( const QString& theEntry )
396 {
397   myShapeEntry = theEntry;
398 }
399
400 //================================================================================
401 /*!
402  * \brief Return hypothesis containing initial parameters
403  *  \param strictly - if true, always return myInitParamsHypo,
404  *                    else, return myInitParamsHypo only in creation mode and if it
405  *                    is non-nil
406  */
407 //================================================================================
408
409 SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::initParamsHypothesis(const bool strictly) const
410 {
411   if ( strictly )
412     return myInitParamsHypo;
413   if ( !isCreation() || CORBA::is_nil( myInitParamsHypo ))
414     return myHypo;
415   return myInitParamsHypo;
416 }
417
418 bool SMESHGUI_GenericHypothesisCreator::hasInitParamsHypothesis() const
419 {
420   return !CORBA::is_nil( myInitParamsHypo );
421 }
422
423 QString SMESHGUI_GenericHypothesisCreator::hypType() const
424 {
425   return myHypType;
426 }
427
428 QString SMESHGUI_GenericHypothesisCreator::hypName() const
429 {
430   return myHypName;
431 }
432
433 const SMESHGUI_GenericHypothesisCreator::ListOfWidgets& SMESHGUI_GenericHypothesisCreator::widgets() const
434 {
435   return myParamWidgets;
436 }
437
438 SMESHGUI_GenericHypothesisCreator::ListOfWidgets& SMESHGUI_GenericHypothesisCreator::changeWidgets()
439 {
440   return myParamWidgets;
441 }
442
443 QtxDialog* SMESHGUI_GenericHypothesisCreator:: dlg() const
444
445   return myDlg;
446 }
447
448 bool SMESHGUI_GenericHypothesisCreator::isCreation() const
449 {
450   return myIsCreate;
451 }
452
453 void SMESHGUI_GenericHypothesisCreator::attuneStdWidget( QWidget*, const int ) const
454 {
455 }
456
457 QString SMESHGUI_GenericHypothesisCreator::caption() const
458 {
459   return QString();
460 }
461
462 QPixmap SMESHGUI_GenericHypothesisCreator::icon() const
463 {
464   return QPixmap();
465 }
466
467 QString SMESHGUI_GenericHypothesisCreator::type() const
468 {
469   return QString();
470 }
471 QWidget* SMESHGUI_GenericHypothesisCreator::getCustomWidget( const StdParam & /*param*/,
472                                                              QWidget*   /*parent*/,
473                                                              const int  /*index*/) const
474 {
475   return 0;
476 }
477 bool SMESHGUI_GenericHypothesisCreator::getParamFromCustomWidget( StdParam&, QWidget* ) const
478 {
479   return false;
480 }
481
482 bool SMESHGUI_GenericHypothesisCreator::checkParams( QString& msg, QStringList& absentParams ) const
483 {
484   bool ok = true;
485   ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
486   for( ; anIt!=aLast; anIt++ )
487   {
488     if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) )
489     {
490       SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
491       ok = sb->isValid( msg, absentParams, true ) && ok;
492     }
493     else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) )
494     {
495       SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt );
496       ok = sb->isValid( msg, absentParams, true ) && ok;
497     }
498   }
499   return ok;
500 }
501
502 void SMESHGUI_GenericHypothesisCreator::onReject()
503 {
504 }
505
506 QString SMESHGUI_GenericHypothesisCreator::helpPage() const
507 {
508   QString aHypType = hypType();
509   QString aHelpFileName = "";
510   if ( aHypType == "LocalLength" )
511     aHelpFileName = "a1d_meshing_hypo_page.html#average_length_anchor";
512   else if ( aHypType == "MaxLength" )
513     aHelpFileName = "a1d_meshing_hypo_page.html#max_length_anchor";
514   else if ( aHypType == "Arithmetic1D")
515     aHelpFileName = "a1d_meshing_hypo_page.html#arithmetic_1d_anchor";
516   else if ( aHypType == "FixedPoints1D")
517     aHelpFileName = "a1d_meshing_hypo_page.html#fixed_points_1d_anchor";
518   else if ( aHypType == "MaxElementArea")
519     aHelpFileName = "a2d_meshing_hypo_page.html#max_element_area_anchor";
520   else if ( aHypType == "MaxElementVolume")
521     aHelpFileName = "max_element_volume_hypo_page.html";
522   else if ( aHypType == "StartEndLength")
523     aHelpFileName = "a1d_meshing_hypo_page.html#start_and_end_length_anchor";
524   else if ( aHypType == "Deflection1D")
525     aHelpFileName = "a1d_meshing_hypo_page.html#deflection_1d_anchor";
526   else if ( aHypType == "AutomaticLength")
527     aHelpFileName = "a1d_meshing_hypo_page.html#automatic_length_anchor";
528   else if ( aHypType == "NumberOfSegments")
529     aHelpFileName = "a1d_meshing_hypo_page.html#number_of_segments_anchor";
530   else if ( aHypType == "ProjectionSource1D")
531     aHelpFileName = "projection_algos_page.html";
532   else if ( aHypType == "ProjectionSource2D")
533     aHelpFileName = "projection_algos_page.html";
534   else if ( aHypType == "ProjectionSource3D")
535     aHelpFileName = "projection_algos_page.html";
536   else if ( aHypType == "NumberOfLayers")
537     aHelpFileName = "radial_prism_algo_page.html";
538   else if ( aHypType == "NumberOfLayers2D")
539     aHelpFileName = "radial_quadrangle_1D2D_algo_page.html";
540   else if ( aHypType == "LayerDistribution")
541     aHelpFileName = "radial_prism_algo_page.html";
542   else if ( aHypType == "LayerDistribution2D")
543     aHelpFileName = "radial_quadrangle_1D2D_algo_page.html";
544   else if ( aHypType == "SegmentLengthAroundVertex")
545     aHelpFileName = "segments_around_vertex_algo_page.html";
546   else if ( aHypType == "QuadrangleParams")
547     aHelpFileName = "a2d_meshing_hypo_page.html#hypo_quad_params_anchor";
548   return aHelpFileName;
549 }
550
551
552
553
554 SMESHGUI_HypothesisDlg::SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator* creator, QWidget* parent )
555 : QtxDialog( parent, false, true ),
556   myCreator( creator )
557 {
558   setAttribute(Qt::WA_DeleteOnClose, true);
559   setMinimumSize( 300, height() );
560 //  setFixedSize( 300, height() );
561   QVBoxLayout* topLayout = new QVBoxLayout( mainFrame() );
562   topLayout->setMargin( 0 );
563   topLayout->setSpacing( 0 );
564
565   QFrame* titFrame = new QFrame( mainFrame() );
566   QHBoxLayout* titLay = new QHBoxLayout( titFrame );
567   titLay->setMargin( 0 );
568   titLay->setSpacing( SPACING );
569   
570   myIconLabel = new QLabel( titFrame );
571   myIconLabel->setScaledContents( false );
572   myIconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
573   myTypeLabel = new QLabel( titFrame );
574   if( creator )
575     myTypeLabel->setText( creator->hypType() );
576
577   titLay->addWidget( myIconLabel, 0 );
578   titLay->addWidget( myTypeLabel, 0 );
579   titLay->addStretch( 1 );
580
581   topLayout->addWidget( titFrame, 0 );
582
583   myHelpFileName = creator->helpPage();
584
585   connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
586 }
587
588 SMESHGUI_HypothesisDlg::~SMESHGUI_HypothesisDlg()
589 {
590   delete myCreator;
591 }
592
593 void SMESHGUI_HypothesisDlg::setCustomFrame( QFrame* f )
594 {
595   if( f )
596   {
597     f->setParent( mainFrame() );
598     qobject_cast<QVBoxLayout*>( mainFrame()->layout() )->insertWidget( 1, f, 1 );
599   }
600 }
601
602 void SMESHGUI_HypothesisDlg::accept()
603 {
604   QString msg;
605   QStringList absentParams;
606   if ( myCreator && !myCreator->checkParams( msg, absentParams ) )
607   {
608     if( !absentParams.isEmpty() )
609     {
610       SalomeApp_Application* app =
611         dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
612       if( app )
613         app->defineAbsentParameters( absentParams );
614       return;
615     }
616     QString str( tr( "SMESH_INCORRECT_INPUT" ) );
617     if ( !msg.isEmpty() )
618       str += "\n" + msg;
619     SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
620     return;
621   }
622   QtxDialog::accept();
623 }
624
625 void SMESHGUI_HypothesisDlg::reject()
626 {
627   if ( myCreator ) myCreator->onReject();
628   QtxDialog::reject();
629 }
630
631 void SMESHGUI_HypothesisDlg::onHelp()
632 {
633   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
634   if (app) {
635     SMESHGUI* aSMESHGUI = dynamic_cast<SMESHGUI*>( app->activeModule() );
636     app->onHelpContextModule(aSMESHGUI ? app->moduleName(aSMESHGUI->moduleName()) : QString(""), myHelpFileName);
637   }
638   else {
639     QString platform;
640 #ifdef WIN32
641     platform = "winapplication";
642 #else
643     platform = "application";
644 #endif
645     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
646                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
647                              arg(app->resourceMgr()->stringValue("ExternalBrowser", 
648                                                                  platform)).
649                              arg(myHelpFileName));
650   }
651 }
652
653 void SMESHGUI_HypothesisDlg::setHIcon( const QPixmap& p )
654 {
655   myIconLabel->setPixmap( p );  
656 }
657
658 void SMESHGUI_HypothesisDlg::setType( const QString& t )
659 {
660   myTypeLabel->setText( t );
661 }
662
663 HypothesisData::HypothesisData( const QString& theTypeName,
664                                 const QString& thePluginName,
665                                 const QString& theServerLibName,
666                                 const QString& theClientLibName,
667                                 const QString& theLabel,
668                                 const QString& theIconId,
669                                 const QList<int>& theDim,
670                                 const bool theIsAux,
671                                 const QStringList& theNeededHypos,
672                                 const QStringList& theOptionalHypos,
673                                 const QStringList& theInputTypes,
674                                 const QStringList& theOutputTypes,
675                                 const bool theIsNeedGeometry,
676                                 const bool supportSub)
677   : TypeName( theTypeName ),
678     PluginName( thePluginName ),
679     ServerLibName( theServerLibName ),
680     ClientLibName( theClientLibName ),
681     Label( theLabel ),
682     IconId( theIconId ),
683     Dim( theDim ),
684     IsAux( theIsAux ),
685     NeededHypos( theNeededHypos ), 
686     OptionalHypos( theOptionalHypos ),
687     InputTypes( theInputTypes ),
688     OutputTypes( theOutputTypes ),
689     IsNeedGeometry( theIsNeedGeometry ),
690     IsSupportSubmeshes( supportSub )
691 {
692 }
693
694 HypothesesSet::HypothesesSet( const QString& theSetName ) 
695   : myHypoSetName( theSetName ),
696     myIsAlgo( false )
697 {
698 }
699
700 HypothesesSet::HypothesesSet( const QString&     theSetName,
701                               const QStringList& theHypoList,
702                               const QStringList& theAlgoList )
703   : myHypoSetName( theSetName ), 
704     myHypoList( theHypoList ), 
705     myAlgoList( theAlgoList ),
706     myIsAlgo( false )
707 {
708 }
709
710 QStringList* HypothesesSet::list(bool is_algo) const
711 {
712   return const_cast<QStringList*>( &( is_algo ? myAlgoList : myHypoList ) );
713 }
714
715 QStringList* HypothesesSet::list() const
716 {
717   return list( myIsAlgo );
718 }
719
720 QString HypothesesSet::name() const
721 {
722   return myHypoSetName;
723 }
724
725 void HypothesesSet::set( bool isAlgo, const QStringList& lst )
726 {
727   *list(isAlgo) = lst;
728 }
729
730 int HypothesesSet::count( bool isAlgo ) const
731 {
732   return list(isAlgo)->count();
733 }
734
735 bool HypothesesSet::isAlgo() const
736 {
737   return myIsAlgo;
738 }
739
740 void HypothesesSet::init( bool isAlgo )
741 {
742   myIsAlgo = isAlgo;
743   myIndex = -1;
744 }
745
746 bool HypothesesSet::more() const
747 {
748   return myIndex < list()->count();
749 }
750
751 void HypothesesSet::next()
752 {
753   myIndex++;
754 }
755
756 QString HypothesesSet::current() const
757 {
758   return list()->at(myIndex);
759 }
760