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