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