Salome HOME
Merge from V5_1_4_BR 07/05/2010
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_Hypotheses.cxx
1 //  Copyright (C) 2007-2010  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
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File   : SMESHGUI_Hypotheses.cxx
25 // Author : Julia DOROVSKIKH, Open CASCADE S.A.S.
26 // SMESH includes
27 //
28 #include "SMESHGUI_Hypotheses.h"
29
30 #include "SMESHGUI.h"
31 #include "SMESHGUI_HypothesesUtils.h"
32 #include "SMESHGUI_Utils.h"
33 #include "SMESHGUI_SpinBox.h"
34
35 // SALOME KERNEL includes
36 #include <SALOMEDSClient_Study.hxx>
37 #include <utilities.h>
38
39 // SALOME GUI includes
40 #include <SUIT_Session.h>
41 #include <SUIT_MessageBox.h>
42 #include <SUIT_ResourceMgr.h>
43 #include <LightApp_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           if((*anIt).isVariable) {
197             _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
198             QString aVar = (*anIt).myValue.toString();
199             if(aStudy->IsInteger(aVar.toLatin1().constData())){
200               SalomeApp_IntSpinBox* sb = new SalomeApp_IntSpinBox( GroupC1 );
201               sb->setObjectName( (*anIt).myName );
202               attuneStdWidget( sb, i );
203               sb->setText( aVar );
204               connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
205               w = sb;
206             }
207             else if(aStudy->IsReal(aVar.toLatin1().constData())){
208               SalomeApp_DoubleSpinBox* sb = new SMESHGUI_SpinBox( GroupC1 );
209               sb->setObjectName( (*anIt).myName );
210               attuneStdWidget( sb, i );
211               sb->setText( aVar );
212               connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
213               w = sb;
214             }
215           }
216           else {
217             QLineEdit* le = new QLineEdit( GroupC1 );
218             le->setObjectName( (*anIt).myName );
219             attuneStdWidget( le, i );
220             le->setText( (*anIt).myValue.toString() );
221             connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
222             w = le;
223           }
224         }
225         break;
226       }
227
228     if( w )
229     {
230       GroupC1Layout->addWidget( w, i, 1 );
231       changeWidgets().append( w );
232     }
233   }
234
235   return fr;
236 }
237
238 void SMESHGUI_GenericHypothesisCreator::onValueChanged()
239 {
240   valueChanged( (QWidget*) sender() );
241 }
242
243 void SMESHGUI_GenericHypothesisCreator::valueChanged( QWidget* )
244 {
245 }
246
247 void SMESHGUI_GenericHypothesisCreator::onDialogFinished( int result )
248 {
249   bool res = result==QDialog::Accepted;
250   if( res )
251   {
252       /*QString paramValues = */storeParams();
253       // No longer needed since NoteBook appears and "Value" OB field shows names of variable
254 //       if ( !paramValues.isEmpty() ) {
255 //         if ( _PTR(SObject) SHyp = SMESH::FindSObject( myHypo ))
256 //           SMESH::SetValue( SHyp, paramValues );
257 //       }
258   }
259
260   changeWidgets().clear();
261
262   if( myIsCreate && !res )
263   {
264     //remove just created hypothesis
265     _PTR(SObject) aHypSObject = SMESH::FindSObject( myHypo );
266     _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
267     if( aStudy && !aStudy->GetProperties()->IsLocked() )
268     {
269       _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
270       aBuilder->RemoveObjectWithChildren( aHypSObject );
271     }
272   }
273   else if( !myIsCreate && res )
274   {
275     SMESH::SObjectList listSOmesh = SMESH::GetMeshesUsingAlgoOrHypothesis( myHypo );
276     if( listSOmesh.size() > 0 )
277       for( int i = 0; i < listSOmesh.size(); i++ )
278       {
279         _PTR(SObject) submSO = listSOmesh[i];
280         SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( submSO );
281         SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( submSO );
282         if( !aSubMesh->_is_nil() )
283           aMesh = aSubMesh->GetFather();
284         _PTR(SObject) meshSO = SMESH::FindSObject( aMesh );
285         SMESH::ModifiedMesh( meshSO, false, aMesh->NbNodes()==0);
286       }
287   }
288   SMESHGUI::GetSMESHGUI()->updateObjBrowser( true, 0 );
289   myHypo = SMESH::SMESH_Hypothesis::_nil();
290   myInitParamsHypo = SMESH::SMESH_Hypothesis::_nil();
291
292   disconnect( myDlg, SIGNAL( finished( int ) ), this, SLOT( onDialogFinished( int ) ) );
293   myDlg->close();
294   //delete myDlg;
295   myDlg = 0;
296   emit finished( result );
297 }
298
299 bool SMESHGUI_GenericHypothesisCreator::stdParams( ListOfStdParams& ) const
300 {
301   return false;
302 }
303
304 bool SMESHGUI_GenericHypothesisCreator::getStdParamFromDlg( ListOfStdParams& params ) const
305 {
306   bool res = true;
307   StdParam item;
308   ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
309   for( ; anIt!=aLast; anIt++ )
310   {
311     item.myName = (*anIt)->objectName();
312     if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) )
313     {
314       SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
315       item.myValue = sb->value();
316       params.append( item );
317     }
318     
319     else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) )
320     {
321       SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt );
322       item.myValue = sb->value();
323       params.append( item );
324     }
325
326     else if( (*anIt)->inherits( "QLineEdit" ) )
327     {
328       QLineEdit* line = ( QLineEdit* )( *anIt );
329       item.myValue = line->text();
330       params.append( item );
331     }
332
333     else if ( getParamFromCustomWidget( item, *anIt ))
334     {
335       params.append( item );
336     }
337
338     else
339       res = false;
340   }
341   return res;
342 }
343
344
345 QStringList SMESHGUI_GenericHypothesisCreator::getVariablesFromDlg() const
346 {
347   QStringList aResult;
348   ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
349   for( ; anIt!=aLast; anIt++ ) {
350     if( (*anIt)->inherits( "QAbstractSpinBox" ) ) {
351       QAbstractSpinBox* sb = ( QAbstractSpinBox* )( *anIt );
352       aResult.append(sb->text());
353     } 
354   }
355   return aResult;
356 }
357
358 QString SMESHGUI_GenericHypothesisCreator::stdParamValues( const ListOfStdParams& params)
359 {
360   QString valueStr = "";
361   ListOfStdParams::const_iterator param = params.begin(), aLast = params.end();
362   uint len0 = 0;
363   for( int i=0; param!=aLast; param++, i++ )
364   {
365     if ( valueStr.length() > len0 ) {
366       valueStr += "; ";
367       len0 = valueStr.length();
368     }
369     switch( (*param).myValue.type() )
370     {
371     case QVariant::Int:
372       valueStr += valueStr.number( (*param).myValue.toInt() );
373       break;
374     case QVariant::Double:
375       valueStr += valueStr.number( (*param).myValue.toDouble() );
376       break;
377     case QVariant::String:
378       valueStr += (*param).myValue.toString();
379       break;
380     default:
381       QVariant valCopy = (*param).myValue;
382       valueStr += valCopy.toString();
383     }
384   }
385   return valueStr;
386 }
387
388 SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::hypothesis() const
389 {
390   return myHypo;
391 }
392
393 void SMESHGUI_GenericHypothesisCreator::setShapeEntry( const QString& theEntry )
394 {
395   myShapeEntry = theEntry;
396 }
397
398 //================================================================================
399 /*!
400  * \brief Return hypothesis containing initial parameters
401  *  \param strictly - if true, always return myInitParamsHypo,
402  *                    else, return myInitParamsHypo only in creation mode and if it
403  *                    is non-nil
404  */
405 //================================================================================
406
407 SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::initParamsHypothesis(const bool strictly) const
408 {
409   if ( strictly )
410     return myInitParamsHypo;
411   if ( !isCreation() || CORBA::is_nil( myInitParamsHypo ))
412     return myHypo;
413   return myInitParamsHypo;
414 }
415
416 bool SMESHGUI_GenericHypothesisCreator::hasInitParamsHypothesis() const
417 {
418   return !CORBA::is_nil( myInitParamsHypo );
419 }
420
421 QString SMESHGUI_GenericHypothesisCreator::hypType() const
422 {
423   return myHypType;
424 }
425
426 QString SMESHGUI_GenericHypothesisCreator::hypName() const
427 {
428   return myHypName;
429 }
430
431 const SMESHGUI_GenericHypothesisCreator::ListOfWidgets& SMESHGUI_GenericHypothesisCreator::widgets() const
432 {
433   return myParamWidgets;
434 }
435
436 SMESHGUI_GenericHypothesisCreator::ListOfWidgets& SMESHGUI_GenericHypothesisCreator::changeWidgets()
437 {
438   return myParamWidgets;
439 }
440
441 QtxDialog* SMESHGUI_GenericHypothesisCreator:: dlg() const
442
443   return myDlg;
444 }
445
446 bool SMESHGUI_GenericHypothesisCreator::isCreation() const
447 {
448   return myIsCreate;
449 }
450
451 void SMESHGUI_GenericHypothesisCreator::attuneStdWidget( QWidget*, const int ) const
452 {
453 }
454
455 QString SMESHGUI_GenericHypothesisCreator::caption() const
456 {
457   return QString();
458 }
459
460 QPixmap SMESHGUI_GenericHypothesisCreator::icon() const
461 {
462   return QPixmap();
463 }
464
465 QString SMESHGUI_GenericHypothesisCreator::type() const
466 {
467   return QString();
468 }
469 QWidget* SMESHGUI_GenericHypothesisCreator::getCustomWidget( const StdParam & /*param*/,
470                                                              QWidget*   /*parent*/,
471                                                              const int  /*index*/) const
472 {
473   return 0;
474 }
475 bool SMESHGUI_GenericHypothesisCreator::getParamFromCustomWidget( StdParam&, QWidget* ) const
476 {
477   return false;
478 }
479
480 bool SMESHGUI_GenericHypothesisCreator::checkParams( QString& msg ) const
481 {
482   bool ok = true;
483   ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
484   for( ; anIt!=aLast; anIt++ )
485   {
486     if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) )
487     {
488       SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
489       ok = sb->isValid( msg, true ) && ok;
490     }
491     else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) )
492     {
493       SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt );
494       ok = sb->isValid( msg, true ) && ok;
495     }
496   }
497   return ok;
498 }
499
500 void SMESHGUI_GenericHypothesisCreator::onReject()
501 {
502 }
503
504 QString SMESHGUI_GenericHypothesisCreator::helpPage() const
505 {
506   QString aHypType = hypType();
507   QString aHelpFileName = "";
508   if ( aHypType == "LocalLength" )
509     aHelpFileName = "a1d_meshing_hypo_page.html#average_length_anchor";
510   else if ( aHypType == "MaxLength" )
511     aHelpFileName = "a1d_meshing_hypo_page.html#max_length_anchor";
512   else if ( aHypType == "Arithmetic1D")
513     aHelpFileName = "a1d_meshing_hypo_page.html#arithmetic_1d_anchor";
514   else if ( aHypType == "FixedPoints1D")
515     aHelpFileName = "a1d_meshing_hypo_page.html#fixed_points_1d_anchor";
516   else if ( aHypType == "MaxElementArea")
517     aHelpFileName = "a2d_meshing_hypo_page.html#max_element_area_anchor";
518   else if ( aHypType == "MaxElementVolume")
519     aHelpFileName = "max_element_volume_hypo_page.html";
520   else if ( aHypType == "StartEndLength")
521     aHelpFileName = "a1d_meshing_hypo_page.html#start_and_end_length_anchor";
522   else if ( aHypType == "Deflection1D")
523     aHelpFileName = "a1d_meshing_hypo_page.html#deflection_1d_anchor";
524   else if ( aHypType == "AutomaticLength")
525     aHelpFileName = "a1d_meshing_hypo_page.html#automatic_length_anchor";
526   else if ( aHypType == "NumberOfSegments")
527     aHelpFileName = "a1d_meshing_hypo_page.html#number_of_segments_anchor";
528   else if ( aHypType == "ProjectionSource1D")
529     aHelpFileName = "projection_algos_page.html";
530   else if ( aHypType == "ProjectionSource2D")
531     aHelpFileName = "projection_algos_page.html";
532   else if ( aHypType == "ProjectionSource3D")
533     aHelpFileName = "projection_algos_page.html";
534   else if ( aHypType == "NumberOfLayers")
535     aHelpFileName = "radial_prism_algo_page.html";
536   else if ( aHypType == "NumberOfLayers2D")
537     aHelpFileName = "radial_quadrangle_1D2D_algo_page.html";
538   else if ( aHypType == "LayerDistribution")
539     aHelpFileName = "radial_prism_algo_page.html";
540   else if ( aHypType == "LayerDistribution2D")
541     aHelpFileName = "radial_quadrangle_1D2D_algo_page.html";
542   else if ( aHypType == "SegmentLengthAroundVertex")
543     aHelpFileName = "segments_around_vertex_algo_page.html";
544   else if ( aHypType == "QuadrangleParams")
545     aHelpFileName = "a2d_meshing_hypo_page.html#hypo_quad_params_anchor";
546   return aHelpFileName;
547 }
548
549
550
551
552 SMESHGUI_HypothesisDlg::SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator* creator, QWidget* parent )
553 : QtxDialog( parent, false, true ),
554   myCreator( creator )
555 {
556   setAttribute(Qt::WA_DeleteOnClose, true);
557   setMinimumSize( 300, height() );
558 //  setFixedSize( 300, height() );
559   QVBoxLayout* topLayout = new QVBoxLayout( mainFrame() );
560   topLayout->setMargin( 0 );
561   topLayout->setSpacing( 0 );
562
563   QFrame* titFrame = new QFrame( mainFrame() );
564   QHBoxLayout* titLay = new QHBoxLayout( titFrame );
565   titLay->setMargin( 0 );
566   titLay->setSpacing( SPACING );
567   
568   myIconLabel = new QLabel( titFrame );
569   myIconLabel->setScaledContents( false );
570   myIconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
571   myTypeLabel = new QLabel( titFrame );
572   if( creator )
573     myTypeLabel->setText( creator->hypType() );
574
575   titLay->addWidget( myIconLabel, 0 );
576   titLay->addWidget( myTypeLabel, 0 );
577   titLay->addStretch( 1 );
578
579   topLayout->addWidget( titFrame, 0 );
580
581   myHelpFileName = creator->helpPage();
582
583   connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
584 }
585
586 SMESHGUI_HypothesisDlg::~SMESHGUI_HypothesisDlg()
587 {
588   delete myCreator;
589 }
590
591 void SMESHGUI_HypothesisDlg::setCustomFrame( QFrame* f )
592 {
593   if( f )
594   {
595     f->setParent( mainFrame() );
596     qobject_cast<QVBoxLayout*>( mainFrame()->layout() )->insertWidget( 1, f, 1 );
597   }
598 }
599
600 void SMESHGUI_HypothesisDlg::accept()
601 {
602   QString msg;
603   if ( myCreator && !myCreator->checkParams( msg ) )
604   {
605     QString str( tr( "SMESH_INCORRECT_INPUT" ) );
606     if ( !msg.isEmpty() )
607       str += "\n" + msg;
608     SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
609     return;
610   }
611   QtxDialog::accept();
612 }
613
614 void SMESHGUI_HypothesisDlg::reject()
615 {
616   if ( myCreator ) myCreator->onReject();
617   QtxDialog::reject();
618 }
619
620 void SMESHGUI_HypothesisDlg::onHelp()
621 {
622   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
623   if (app) {
624     SMESHGUI* aSMESHGUI = dynamic_cast<SMESHGUI*>( app->activeModule() );
625     app->onHelpContextModule(aSMESHGUI ? app->moduleName(aSMESHGUI->moduleName()) : QString(""), myHelpFileName);
626   }
627   else {
628     QString platform;
629 #ifdef WIN32
630     platform = "winapplication";
631 #else
632     platform = "application";
633 #endif
634     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
635                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
636                              arg(app->resourceMgr()->stringValue("ExternalBrowser", 
637                                                                  platform)).
638                              arg(myHelpFileName));
639   }
640 }
641
642 void SMESHGUI_HypothesisDlg::setHIcon( const QPixmap& p )
643 {
644   myIconLabel->setPixmap( p );  
645 }
646
647 void SMESHGUI_HypothesisDlg::setType( const QString& t )
648 {
649   myTypeLabel->setText( t );
650 }
651
652 HypothesisData::HypothesisData( const QString& theTypeName,
653                                 const QString& thePluginName,
654                                 const QString& theServerLibName,
655                                 const QString& theClientLibName,
656                                 const QString& theLabel,
657                                 const QString& theIconId,
658                                 const QList<int>& theDim,
659                                 const bool theIsAux,
660                                 const QStringList& theNeededHypos,
661                                 const QStringList& theOptionalHypos,
662                                 const QStringList& theInputTypes,
663                                 const QStringList& theOutputTypes,
664                                 const bool theIsNeedGeometry,
665                                 const bool supportSub)
666   : TypeName( theTypeName ),
667     PluginName( thePluginName ),
668     ServerLibName( theServerLibName ),
669     ClientLibName( theClientLibName ),
670     Label( theLabel ),
671     IconId( theIconId ),
672     Dim( theDim ),
673     IsAux( theIsAux ),
674     NeededHypos( theNeededHypos ), 
675     OptionalHypos( theOptionalHypos ),
676     InputTypes( theInputTypes ),
677     OutputTypes( theOutputTypes ),
678     IsNeedGeometry( theIsNeedGeometry ),
679     IsSupportSubmeshes( supportSub )
680 {
681 }
682
683 HypothesesSet::HypothesesSet( const QString& theSetName ) 
684   : myHypoSetName( theSetName ),
685     myIsAlgo( false )
686 {
687 }
688
689 HypothesesSet::HypothesesSet( const QString&     theSetName,
690                               const QStringList& theHypoList,
691                               const QStringList& theAlgoList )
692   : myHypoSetName( theSetName ), 
693     myHypoList( theHypoList ), 
694     myAlgoList( theAlgoList ),
695     myIsAlgo( false )
696 {
697 }
698
699 QStringList* HypothesesSet::list(bool is_algo) const
700 {
701   return const_cast<QStringList*>( &( is_algo ? myAlgoList : myHypoList ) );
702 }
703
704 QStringList* HypothesesSet::list() const
705 {
706   return list( myIsAlgo );
707 }
708
709 QString HypothesesSet::name() const
710 {
711   return myHypoSetName;
712 }
713
714 void HypothesesSet::set( bool isAlgo, const QStringList& lst )
715 {
716   *list(isAlgo) = lst;
717 }
718
719 int HypothesesSet::count( bool isAlgo ) const
720 {
721   return list(isAlgo)->count();
722 }
723
724 bool HypothesesSet::isAlgo() const
725 {
726   return myIsAlgo;
727 }
728
729 void HypothesesSet::init( bool isAlgo )
730 {
731   myIsAlgo = isAlgo;
732   myIndex = -1;
733 }
734
735 bool HypothesesSet::more() const
736 {
737   return myIndex < list()->count();
738 }
739
740 void HypothesesSet::next()
741 {
742   myIndex++;
743 }
744
745 QString HypothesesSet::current() const
746 {
747   return list()->at(myIndex);
748 }
749