Salome HOME
Fix for the '22047: Automatic Tetrahedralization - field Length is shown not from...
[modules/smesh.git] / src / StdMeshersGUI / StdMeshersGUI_StdHypothesisCreator.cxx
1 // Copyright (C) 2007-2015  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, or (at your option) any later version.
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 //  File   : StdMeshersGUI_StdHypothesisCreator.cxx
23 //  Author : Alexander SOLOVYOV, Open CASCADE S.A.S.
24 //  SMESH includes
25
26 #include "StdMeshersGUI_StdHypothesisCreator.h"
27
28 #include <SMESHGUI.h>
29 #include <SMESHGUI_SpinBox.h>
30 #include <SMESHGUI_HypothesesUtils.h>
31 #include <SMESHGUI_Utils.h>
32 #include <SMESHGUI_GEOMGenUtils.h>
33
34 #include <SMESH_TypeFilter.hxx>
35 #include <SMESH_NumberFilter.hxx>
36
37 #include "StdMeshersGUI_FixedPointsParamWdg.h"
38 #include "StdMeshersGUI_LayerDistributionParamWdg.h"
39 #include "StdMeshersGUI_ObjectReferenceParamWdg.h"
40 #include "StdMeshersGUI_PropagationHelperWdg.h"
41 #include "StdMeshersGUI_QuadrangleParamWdg.h"
42 #include "StdMeshersGUI_RadioButtonsGrpWdg.h"
43 #include "StdMeshersGUI_SubShapeSelectorWdg.h"
44
45 #include <SALOMEDSClient_Study.hxx>
46
47 #include <GEOM_wrap.hxx>
48
49 // SALOME GUI includes
50 #include <SUIT_ResourceMgr.h>
51 #include <SUIT_MessageBox.h>
52
53 // IDL includes
54 #include <SALOMEconfig.h>
55 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
56 #include CORBA_SERVER_HEADER(SMESH_Mesh)
57 #include CORBA_SERVER_HEADER(SMESH_Group)
58
59 // Qt includes
60 #include <QHBoxLayout>
61 #include <QSlider>
62 #include <QLabel>
63 #include <QCheckBox>
64 #include <QButtonGroup>
65
66 const double VALUE_MAX = 1.0e+15, // COORD_MAX
67              VALUE_MAX_2  = VALUE_MAX * VALUE_MAX,
68              VALUE_MAX_3  = VALUE_MAX_2 * VALUE_MAX,
69              VALUE_SMALL = 1.0e-15,
70              VALUE_SMALL_2 = VALUE_SMALL * VALUE_SMALL,
71              VALUE_SMALL_3 = VALUE_SMALL_2 * VALUE_SMALL;
72
73 //================================================================================
74 /*!
75  * \brief Constructor
76   * \param type - hypothesis type
77  */
78 //================================================================================
79
80 StdMeshersGUI_StdHypothesisCreator::StdMeshersGUI_StdHypothesisCreator( const QString& type )
81   : SMESHGUI_GenericHypothesisCreator( type ), myHelperWidget( 0 )
82 {
83 }
84
85 //================================================================================
86 /*!
87  * \brief Destructor
88  */
89 //================================================================================
90
91 StdMeshersGUI_StdHypothesisCreator::~StdMeshersGUI_StdHypothesisCreator()
92 {
93 }
94
95 //================================================================================
96 /*!
97  * \brief Return widget for i-th hypothesis parameter (got from myParamWidgets)
98   * \param i - index of hypothesis parameter
99   * \retval QWidget* - found widget
100  */
101 //================================================================================
102
103 QWidget* StdMeshersGUI_StdHypothesisCreator::getWidgetForParam( int i ) const
104 {
105   QWidget* w = 0;
106   if ( isCreation() ) ++i; // skip widget of 'name' parameter
107
108   if ( i < myCustomWidgets.count() ) {
109     QList<QWidget*>::const_iterator anIt  = myCustomWidgets.begin();
110     QList<QWidget*>::const_iterator aLast = myCustomWidgets.end();
111     for ( int j = 0 ; !w && anIt != aLast; ++anIt, ++j )
112       if ( i == j )
113         w = *anIt;
114   }
115   if ( !w ) {
116     // list has no at() const, so we iterate
117     QList<QWidget*>::const_iterator anIt  = widgets().begin();
118     QList<QWidget*>::const_iterator aLast = widgets().end();
119     for( int j = 0; !w && anIt!=aLast; anIt++, ++j ) {
120       if ( i == j )
121         w = *anIt;
122     }
123   }
124   return w;
125 }
126
127 //================================================================================
128 /*!
129  * \brief Allow modifing myCustomWidgets in const methods
130   * \retval ListOfWidgets* - non-const pointer to myCustomWidgets
131  */
132 //================================================================================
133
134 StdMeshersGUI_StdHypothesisCreator::ListOfWidgets*
135 StdMeshersGUI_StdHypothesisCreator::customWidgets() const
136 {
137   return const_cast< ListOfWidgets* >( & myCustomWidgets );
138 }
139
140 //================================================================================
141 /*!
142  * \brief Builds dlg layout
143   * \retval QFrame* - the built widget
144  */
145 //================================================================================
146
147 QFrame* StdMeshersGUI_StdHypothesisCreator::buildFrame()
148 {
149   return buildStdFrame();
150 }
151
152 //================================================================================
153 /*!
154  * \brief Initialise parameter values in controls
155  */
156 //================================================================================
157
158 void StdMeshersGUI_StdHypothesisCreator::retrieveParams() const
159 {
160   // buildStdFrame() sets values itself calling stdParams()
161
162   if ( hypType().startsWith("ProjectionSource" ))
163   {
164     // we use this method to connect depending custom widgets
165     StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0;
166     ListOfWidgets::const_iterator anIt = myCustomWidgets.begin();
167     for ( ; anIt != myCustomWidgets.end(); anIt++)
168     {
169       if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
170       {
171         StdMeshersGUI_ObjectReferenceParamWdg * w1 =
172           ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
173         ListOfWidgets::const_iterator anIt2 = anIt;
174         for ( ++anIt2; anIt2 != myCustomWidgets.end(); anIt2++)
175           if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
176           {
177             StdMeshersGUI_ObjectReferenceParamWdg * w2 =
178               ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 );
179             w1->AvoidSimultaneousSelection( w2 );
180           }
181         if ( !widgetToActivate )
182           widgetToActivate = w1;
183       }
184     }
185     if ( widgetToActivate )
186       widgetToActivate->activateSelection();
187   }
188
189   if ( dlg() )
190     dlg()->setMinimumSize( dlg()->minimumSizeHint().width(), dlg()->minimumSizeHint().height() );
191 }
192
193 namespace {
194
195   //================================================================================
196   /*!
197    * \brief Widget: slider with left and right labels
198    */
199   //================================================================================
200
201   class TDoubleSliderWith2Labels: public QWidget
202   {
203   public:
204     TDoubleSliderWith2Labels( const QString& leftLabel, const QString& rightLabel,
205                               const double   initValue, const double   bottom,
206                               const double   top      , const double   precision,
207                               QWidget *      parent=0 , const char *   name=0 )
208       :QWidget(parent), _bottom(bottom), _precision(precision)
209     {
210       setObjectName(name);
211
212       QHBoxLayout* aHBoxL = new QHBoxLayout(this);
213
214       if ( !leftLabel.isEmpty() ) {
215         QLabel* aLeftLabel = new QLabel( this );
216         aLeftLabel->setText( leftLabel );
217         aHBoxL->addWidget( aLeftLabel );
218       }
219
220       _slider = new QSlider( Qt::Horizontal, this );
221       _slider->setRange( 0, toInt( top ));
222       _slider->setValue( toInt( initValue ));
223       aHBoxL->addWidget( _slider );
224
225       if ( !rightLabel.isEmpty() ) {
226         QLabel* aRightLabel = new QLabel( this );
227         aRightLabel->setText( rightLabel );
228         aHBoxL->addWidget( aRightLabel );
229       }
230
231       setLayout( aHBoxL );
232     }
233     double value() const { return _bottom + _slider->value() * _precision; }
234     QSlider * getSlider() const { return _slider; }
235     int toInt( double val ) const { return (int) ceil(( val - _bottom ) / _precision ); }
236   private:
237     double _bottom, _precision;
238     QSlider * _slider;
239   };
240
241   //================================================================================
242   /*!
243    * \brief Retrieve GEOM_Object held by widget
244    */
245   //================================================================================
246
247   inline GEOM::GEOM_Object_var geomFromWdg(const QWidget* wdg)
248   {
249     const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
250       dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
251     if ( objRefWdg )
252       return objRefWdg->GetObject< GEOM::GEOM_Object >();
253
254     return GEOM::GEOM_Object::_nil();
255   }
256   //================================================================================
257   /*!
258    * \brief Retrieve SMESH_Mesh held by widget
259    */
260   //================================================================================
261
262   inline SMESH::SMESH_Mesh_var meshFromWdg(const QWidget* wdg)
263   {
264     const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
265       dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
266     if ( objRefWdg )
267       return objRefWdg->GetObject< SMESH::SMESH_Mesh >();
268
269     return SMESH::SMESH_Mesh::_nil();
270   }
271   //================================================================================
272   /*!
273    * \brief Retrieve SMESH_Mesh held by widget
274    */
275   //================================================================================
276
277   inline SMESH::ListOfGroups_var groupsFromWdg(const QWidget* wdg)
278   {
279     SMESH::ListOfGroups_var groups = new SMESH::ListOfGroups;
280     const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
281       dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
282     if ( objRefWdg )
283     {
284       groups->length( objRefWdg->NbObjects() );
285       for ( unsigned i = 0; i < groups->length(); ++i )
286         groups[i] = objRefWdg->GetObject< SMESH::SMESH_GroupBase >(i);
287     }
288     return groups;
289   }
290   //================================================================================
291   /*!
292    * \brief creates a filter for selection of shapes of given dimension
293     * \param dim - dimension
294     * \param subShapeType - required type of sub-shapes, number of which must be \a nbSubShapes
295     * \param nbSubShapes - number of sub-shapes of given type
296     * \param closed - required closeness flag of a shape
297     * \retval SUIT_SelectionFilter* - created filter
298    */
299   //================================================================================
300
301   SUIT_SelectionFilter* filterForShapeOfDim(const int        dim,
302                                             TopAbs_ShapeEnum subShapeType = TopAbs_SHAPE,
303                                             const int        nbSubShapes = 0,
304                                             bool             closed = false)
305   {
306     TColStd_MapOfInteger shapeTypes;
307     switch ( dim ) {
308     case 0: shapeTypes.Add( TopAbs_VERTEX ); break;
309     case 1:
310       if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_EDGE;
311       shapeTypes.Add( TopAbs_EDGE );
312       shapeTypes.Add( TopAbs_COMPOUND ); // for a group
313       break;
314     case 2:
315       if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_FACE;
316       shapeTypes.Add( TopAbs_FACE );
317       shapeTypes.Add( TopAbs_COMPOUND ); // for a group
318       break;
319     case 3:
320       shapeTypes.Add( TopAbs_SHELL );
321       shapeTypes.Add( TopAbs_SOLID );
322       shapeTypes.Add( TopAbs_COMPSOLID );
323       shapeTypes.Add( TopAbs_COMPOUND );
324       break;
325     }
326     return new SMESH_NumberFilter("GEOM", subShapeType, nbSubShapes,
327                                   shapeTypes, GEOM::GEOM_Object::_nil(), closed);
328   }
329
330   //================================================================================
331   /*!
332    * \brief Create a widget for object selection
333     * \param object - initial object
334     * \param filter - selection filter
335     * \retval QWidget* - created widget
336    */
337   //================================================================================
338
339   QWidget* newObjRefParamWdg( SUIT_SelectionFilter* filter,
340                               CORBA::Object_var     object)
341   {
342     StdMeshersGUI_ObjectReferenceParamWdg* w =
343       new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0);
344     w->SetObject( object.in() );
345     return w;
346   }
347   QWidget* newObjRefParamWdg( SUIT_SelectionFilter*    filter,
348                               SMESH::string_array_var& objEntries)
349   {
350     StdMeshersGUI_ObjectReferenceParamWdg* w =
351       new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0, /*multiSel=*/true);
352     //RNV: Firstly, activate selection, then set objects
353     w->activateSelection();
354     w->SetObjects( objEntries );
355     return w;
356   }
357
358   //================================================================================
359   /*!
360    * \brief calls deactivateSelection() for StdMeshersGUI_ObjectReferenceParamWdg
361     * \param widgetList - list of widgets
362    */
363   //================================================================================
364
365   void deactivateObjRefParamWdg( QList<QWidget*>* widgetList )
366   {
367     StdMeshersGUI_ObjectReferenceParamWdg* w = 0;
368     QList<QWidget*>::iterator anIt  = widgetList->begin();
369     QList<QWidget*>::iterator aLast = widgetList->end();
370     for ( ; anIt != aLast; anIt++ ) {
371       if ( (*anIt) && (*anIt)->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
372       {
373         w = (StdMeshersGUI_ObjectReferenceParamWdg* )( *anIt );
374         w->deactivateSelection();
375       }
376     }
377   }
378 }
379
380 //================================================================================
381 /*!
382  * \brief Check parameter values before accept()
383   * \retval bool - true if OK
384  */
385 //================================================================================
386
387 bool StdMeshersGUI_StdHypothesisCreator::checkParams( QString& msg ) const
388 {
389   if( !SMESHGUI_GenericHypothesisCreator::checkParams( msg ) )
390     return false;
391
392   // check if object reference parameter is set, as it has no default value
393   bool ok = true;
394   if ( hypType().startsWith("ProjectionSource" ))
395   {
396     StdMeshersGUI_ObjectReferenceParamWdg* w =
397       widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
398     ok = ( w->IsObjectSelected() );
399     if ( !ok ) w->SetObject( CORBA::Object::_nil() );
400     int nbAssocVert = ( hypType() == "ProjectionSource1D" ? 1 : 2 );
401     int nbNonEmptyAssoc = 0;
402     for ( int i = 0; ok && i < nbAssocVert*2; i += 2)
403     {
404       QString srcV, tgtV;
405       StdMeshersGUI_ObjectReferenceParamWdg* w1 =
406         widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+2 );
407       StdMeshersGUI_ObjectReferenceParamWdg* w2 =
408         widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+3 );
409       srcV = w1->GetValue();
410       tgtV = w2->GetValue();
411       ok = (( srcV.isEmpty()  && tgtV.isEmpty() ) ||
412             ( !srcV.isEmpty() && !tgtV.isEmpty() /*&& srcV != tgtV*/ ));
413       if ( !ok ) {
414         w1->SetObject( CORBA::Object::_nil() );
415         w2->SetObject( CORBA::Object::_nil() );
416       }
417       nbNonEmptyAssoc += !srcV.isEmpty();
418     }
419     if ( ok && nbNonEmptyAssoc == 1 && nbAssocVert == 2 )
420     {
421       // only one pair of VERTEXes is given for a FACE,
422       // then the FACE must have only one VERTEX
423       GEOM::GEOM_Object_var face = w->GetObject< GEOM::GEOM_Object >();
424
425       GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
426       _PTR(Study)         aStudy = SMESH::GetActiveStudyDocument();
427       GEOM::GEOM_IShapesOperations_wrap shapeOp;
428       if ( !geomGen->_is_nil() && aStudy )
429         shapeOp = geomGen->GetIShapesOperations( aStudy->StudyId() );
430       if ( !shapeOp->_is_nil() )
431       {
432         GEOM::ListOfLong_var vertices =
433           shapeOp->GetAllSubShapesIDs (face, GEOM::VERTEX, /*isSorted=*/false);
434         ok = ( vertices->length() == 1 );
435       }
436     }
437     // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
438     if ( ok )
439       deactivateObjRefParamWdg( customWidgets() );
440   }
441   else if ( hypType().startsWith("ImportSource" ))
442   {
443     StdMeshersGUI_ObjectReferenceParamWdg* w =
444       widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
445     ok = ( w->IsObjectSelected() );
446   }
447   else if ( hypType() == "LayerDistribution" || hypType() == "LayerDistribution2D" )
448   {
449     StdMeshersGUI_LayerDistributionParamWdg* w = 
450       widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
451     ok = ( w && w->IsOk() );
452   }
453
454   return ok;
455 }
456
457 //================================================================================
458 /*!
459  * \brief Store params from GUI controls to a hypothesis
460   * \retval QString - text representation of parameters
461  */
462 //================================================================================
463
464 QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
465 {
466   ListOfStdParams params;
467   bool res = getStdParamFromDlg( params );
468   if( isCreation() )
469   {
470     SMESH::SetName( SMESH::FindSObject( hypothesis() ), params[0].myValue.toString().toLatin1().data() );
471     params.erase( params.begin() );
472   }
473
474   QString valueStr = stdParamValues( params );
475   //QStringList aVariablesList = getVariablesFromDlg();
476
477   if( res && !params.isEmpty() )
478   {
479     if( hypType()=="LocalLength" )
480     {
481       StdMeshers::StdMeshers_LocalLength_var h =
482         StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
483
484       h->SetVarParameter( params[0].text(), "SetLength" );
485       h->SetLength( params[0].myValue.toDouble() );
486       h->SetVarParameter( params[1].text(), "SetPrecision" );
487       h->SetPrecision( params[1].myValue.toDouble() );
488     }
489     else if( hypType()=="MaxLength" )
490     {
491       StdMeshers::StdMeshers_MaxLength_var h =
492         StdMeshers::StdMeshers_MaxLength::_narrow( hypothesis() );
493
494       h->SetVarParameter( params[0].text(), "SetLength" );
495       h->SetLength( params[0].myValue.toDouble() );
496       h->SetUsePreestimatedLength( widget< QCheckBox >( 1 )->isChecked() );
497       if ( !h->HavePreestimatedLength() && !h->_is_equivalent( initParamsHypothesis() )) {
498         StdMeshers::StdMeshers_MaxLength_var hInit =
499           StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
500         h->SetPreestimatedLength( hInit->GetPreestimatedLength() );
501       }
502     }
503     else if( hypType()=="SegmentLengthAroundVertex" )
504     {
505       StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
506         StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hypothesis() );
507
508       h->SetVarParameter( params[0].text(), "SetLength" );
509       h->SetLength( params[0].myValue.toDouble() );
510     }
511     else if( hypType()=="Arithmetic1D" )
512     {
513       StdMeshers::StdMeshers_Arithmetic1D_var h =
514         StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
515
516       StdMeshersGUI_SubShapeSelectorWdg* w = 
517         widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
518
519       h->SetVarParameter( params[0].text(), "SetStartLength" );
520       h->SetStartLength( params[0].myValue.toDouble() );
521       h->SetVarParameter( params[1].text(), "SetEndLength" );
522       h->SetEndLength( params[1].myValue.toDouble() );
523       if (w) {
524         h->SetReversedEdges( w->GetListOfIDs() );
525         h->SetObjectEntry( w->GetMainShapeEntry() );
526       }
527     }
528     else if( hypType()=="GeometricProgression" )
529     {
530       StdMeshers::StdMeshers_Geometric1D_var h =
531         StdMeshers::StdMeshers_Geometric1D::_narrow( hypothesis() );
532
533       StdMeshersGUI_SubShapeSelectorWdg* w = 
534         widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
535
536       h->SetVarParameter( params[0].text(), "SetStartLength" );
537       h->SetStartLength( params[0].myValue.toDouble() );
538       h->SetVarParameter( params[1].text(), "SetCommonRatio" );
539       h->SetCommonRatio( params[1].myValue.toDouble() );
540       if (w) {
541         h->SetReversedEdges( w->GetListOfIDs() );
542         h->SetObjectEntry( w->GetMainShapeEntry() );
543       }
544     }
545     else if( hypType()=="FixedPoints1D" )
546     {
547       StdMeshers::StdMeshers_FixedPoints1D_var h =
548         StdMeshers::StdMeshers_FixedPoints1D::_narrow( hypothesis() );
549
550       StdMeshersGUI_FixedPointsParamWdg* w1 = 
551         widget< StdMeshersGUI_FixedPointsParamWdg >( 0 );
552
553       StdMeshersGUI_SubShapeSelectorWdg* w2 = 
554         widget< StdMeshersGUI_SubShapeSelectorWdg >( 1 );
555
556       if (w1) {
557         h->SetPoints( w1->GetListOfPoints() );
558         h->SetNbSegments( w1->GetListOfSegments() );
559       }
560       if (w2) {
561         h->SetReversedEdges( w2->GetListOfIDs() );
562         h->SetObjectEntry( w2->GetMainShapeEntry() );
563       }
564     }
565     else if( hypType()=="MaxElementArea" )
566     {
567       StdMeshers::StdMeshers_MaxElementArea_var h =
568         StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() );
569       h->SetVarParameter( params[0].text(), "SetMaxElementArea" );
570       h->SetMaxElementArea( params[0].myValue.toDouble() );
571     }
572     else if( hypType()=="MaxElementVolume" )
573     {
574       StdMeshers::StdMeshers_MaxElementVolume_var h =
575         StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() );
576
577       h->SetVarParameter( params[0].text(), "SetMaxElementVolume" );
578       h->SetMaxElementVolume( params[0].myValue.toDouble() );
579     }
580     else if( hypType()=="StartEndLength" )
581     {
582       StdMeshers::StdMeshers_StartEndLength_var h =
583         StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
584
585       StdMeshersGUI_SubShapeSelectorWdg* w = 
586         widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
587
588       h->SetVarParameter( params[0].text(), "SetStartLength" );
589       h->SetStartLength( params[0].myValue.toDouble() );
590       h->SetVarParameter( params[1].text(), "SetEndLength" );
591       h->SetEndLength( params[1].myValue.toDouble() );
592       if (w) {
593         h->SetReversedEdges( w->GetListOfIDs() );
594         h->SetObjectEntry( w->GetMainShapeEntry() );
595       }
596     }
597     else if( hypType()=="Deflection1D" )
598     {
599       StdMeshers::StdMeshers_Deflection1D_var h =
600         StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
601       h->SetVarParameter( params[0].text(), "SetDeflection" );
602       h->SetDeflection( params[0].myValue.toDouble() );
603     }
604     else if( hypType()=="Adaptive1D" )
605     {
606       StdMeshers::StdMeshers_Adaptive1D_var h =
607         StdMeshers::StdMeshers_Adaptive1D::_narrow( hypothesis() );
608       h->SetVarParameter( params[0].text(), "SetMinSize" );
609       h->SetMinSize( params[0].myValue.toDouble() );
610       h->SetVarParameter( params[0].text(), "SetMaxSize" );
611       h->SetMaxSize( params[1].myValue.toDouble() );
612       h->SetVarParameter( params[0].text(), "SetDeflection" );
613       h->SetDeflection( params[2].myValue.toDouble() );
614     }
615     else if( hypType()=="AutomaticLength" )
616     {
617       StdMeshers::StdMeshers_AutomaticLength_var h =
618         StdMeshers::StdMeshers_AutomaticLength::_narrow( hypothesis() );
619
620       h->SetVarParameter( params[0].text(), "SetFineness" );
621       h->SetFineness( params[0].myValue.toDouble() );
622     }
623     else if( hypType()=="NumberOfLayers" )
624     {
625       StdMeshers::StdMeshers_NumberOfLayers_var h =
626         StdMeshers::StdMeshers_NumberOfLayers::_narrow( hypothesis() );
627
628       h->SetVarParameter( params[0].text(), "SetNumberOfLayers" );
629       h->SetNumberOfLayers( params[0].myValue.toInt() );
630     }
631     else if( hypType()=="LayerDistribution" )
632     {
633       StdMeshers::StdMeshers_LayerDistribution_var h =
634         StdMeshers::StdMeshers_LayerDistribution::_narrow( hypothesis() );
635       StdMeshersGUI_LayerDistributionParamWdg* w = 
636         widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
637       
638       h->SetLayerDistribution( w->GetHypothesis() );
639     }
640     else if( hypType()=="NumberOfLayers2D" )
641     {
642       StdMeshers::StdMeshers_NumberOfLayers2D_var h =
643         StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hypothesis() );
644
645       h->SetVarParameter( params[0].text(), "SetNumberOfLayers" );
646       h->SetNumberOfLayers( params[0].myValue.toInt() );
647     }
648     else if( hypType()=="LayerDistribution2D" )
649     {
650       StdMeshers::StdMeshers_LayerDistribution2D_var h =
651         StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hypothesis() );
652       StdMeshersGUI_LayerDistributionParamWdg* w = 
653         widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
654       
655       h->SetLayerDistribution( w->GetHypothesis() );
656     }
657     else if( hypType()=="ProjectionSource1D" )
658     {
659       StdMeshers::StdMeshers_ProjectionSource1D_var h =
660         StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hypothesis() );
661
662       h->SetSourceEdge       ( geomFromWdg ( getWidgetForParam( 0 )));
663       h->SetSourceMesh       ( meshFromWdg ( getWidgetForParam( 1 )));
664       h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )),
665                                geomFromWdg ( getWidgetForParam( 3 )));
666     }
667     else if( hypType()=="ProjectionSource2D" )
668     {
669       StdMeshers::StdMeshers_ProjectionSource2D_var h =
670         StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hypothesis() );
671
672       h->SetSourceFace       ( geomFromWdg ( getWidgetForParam( 0 )));
673       h->SetSourceMesh       ( meshFromWdg ( getWidgetForParam( 1 )));
674       h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
675                                geomFromWdg ( getWidgetForParam( 4 )), // src2
676                                geomFromWdg ( getWidgetForParam( 3 )), // tgt1
677                                geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
678     }
679     else if( hypType()=="ProjectionSource3D" )
680     {
681       StdMeshers::StdMeshers_ProjectionSource3D_var h =
682         StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hypothesis() );
683
684       h->SetSource3DShape    ( geomFromWdg ( getWidgetForParam( 0 )));
685       h->SetSourceMesh       ( meshFromWdg ( getWidgetForParam( 1 )));
686       h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
687                                geomFromWdg ( getWidgetForParam( 4 )), // src2
688                                geomFromWdg ( getWidgetForParam( 3 )), // tgt1
689                                geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
690     }
691     else if( hypType()=="ImportSource1D" )
692     {
693       StdMeshers::StdMeshers_ImportSource1D_var h =
694         StdMeshers::StdMeshers_ImportSource1D::_narrow( hypothesis() );
695
696       SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
697       h->SetSourceEdges( groups.in() );
698       QCheckBox* toCopyMesh   = widget< QCheckBox >( 1 );
699       QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
700       h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
701     }
702     else if( hypType()=="ImportSource2D" )
703     {
704       StdMeshers::StdMeshers_ImportSource2D_var h =
705         StdMeshers::StdMeshers_ImportSource2D::_narrow( hypothesis() );
706
707       SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
708       h->SetSourceFaces( groups.in() );
709       QCheckBox* toCopyMesh   = widget< QCheckBox >( 1 );
710       QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
711       h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
712     }
713     else if( hypType()=="ViscousLayers" )
714     {
715       StdMeshers::StdMeshers_ViscousLayers_var h =
716         StdMeshers::StdMeshers_ViscousLayers::_narrow( hypothesis() );
717
718       h->SetVarParameter  ( params[0].text(), "SetTotalThickness" );
719       h->SetTotalThickness( params[0].myValue.toDouble() );
720       h->SetVarParameter  ( params[1].text(), "SetNumberLayers" );
721       h->SetNumberLayers  ( params[1].myValue.toInt() );
722       h->SetVarParameter  ( params[2].text(), "SetStretchFactor" );
723       h->SetStretchFactor ( params[2].myValue.toDouble() );
724       h->SetMethod (( StdMeshers::VLExtrusionMethod ) params[3].myValue.toInt() );
725
726       if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg =
727            widget< StdMeshersGUI_SubShapeSelectorWdg >( 5 ))
728       {
729         h->SetFaces( idsWg->GetListOfIDs(), params[4].myValue.toInt() );
730       }
731     }
732     else if( hypType()=="ViscousLayers2D" )
733     {
734       StdMeshers::StdMeshers_ViscousLayers2D_var h =
735         StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hypothesis() );
736
737       h->SetVarParameter  ( params[0].text(), "SetTotalThickness" );
738       h->SetTotalThickness( params[0].myValue.toDouble() );
739       h->SetVarParameter  ( params[1].text(), "SetNumberLayers" );
740       h->SetNumberLayers  ( params[1].myValue.toInt() );
741       h->SetVarParameter  ( params[2].text(), "SetStretchFactor" );
742       h->SetStretchFactor ( params[2].myValue.toDouble() );
743
744       if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg =
745            widget< StdMeshersGUI_SubShapeSelectorWdg >( 4 ))
746       {
747         h->SetEdges( idsWg->GetListOfIDs(), params[3].myValue.toInt() );
748       }
749     }
750     // else if( hypType()=="QuadrangleParams" )
751     // {
752     //   StdMeshers::StdMeshers_QuadrangleParams_var h =
753     //     StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() );
754     //   StdMeshersGUI_SubShapeSelectorWdg* w1 =
755     //     widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
756     //   StdMeshersGUI_QuadrangleParamWdg* w2 =
757     //     widget< StdMeshersGUI_QuadrangleParamWdg >( 1 );
758     //   if (w1 && w2) {
759     //     if (w1->GetListSize() > 0) {
760     //       h->SetTriaVertex(w1->GetListOfIDs()[0]); // getlist must be called once
761     //       const char * entry = w1->GetMainShapeEntry();
762     //       h->SetObjectEntry(entry);
763     //     }
764     //     h->SetQuadType(StdMeshers::QuadType(w2->GetType()));
765     //   }
766     // }
767   }
768   return valueStr;
769 }
770
771 //================================================================================
772 /*!
773  * \brief Return parameter values as SMESHGUI_GenericHypothesisCreator::StdParam
774  * \param p - list of parameters
775  * \retval bool - success flag
776  *
777  * Is called from SMESHGUI_GenericHypothesisCreator::buildStdFrame().
778  * Parameters will be shown using "standard" controls:
779  *   Int by QtxIntSpinBox
780  *   Double by SMESHGUI_SpinBox
781  *   String by QLineEdit
782  * getCustomWidget() allows to redefine control for a parameter
783  */
784 //================================================================================
785
786 bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
787 {
788   bool res = true;
789   SMESHGUI_GenericHypothesisCreator::StdParam item;
790
791   p.clear();
792   customWidgets()->clear();
793   if( isCreation() )
794   {
795     HypothesisData* data = SMESH::GetHypothesisData( hypType() );
796     item.myName = tr( "SMESH_NAME" );
797     item.myValue = data ? hypName() : QString();
798     p.append( item );
799     customWidgets()->append(0);
800   }
801
802   SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
803   //SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
804
805   if( hypType()=="LocalLength" )
806   {
807     StdMeshers::StdMeshers_LocalLength_var h =
808       StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
809
810     item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
811     if(!initVariableName( hyp, item, "SetLength"))
812       item.myValue = h->GetLength();
813     p.append( item );     
814
815     item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
816     if(!initVariableName( hyp, item, "SetPrecision"))
817       item.myValue = h->GetPrecision(); 
818     p.append( item );
819   }
820   else if( hypType()=="MaxLength" )
821   {
822     StdMeshers::StdMeshers_MaxLength_var h =
823       StdMeshers::StdMeshers_MaxLength::_narrow( hyp );
824     // try to set a right preestimated length to edited hypothesis
825     bool noPreestimatedAtEdition = false;
826     if ( !isCreation() ) {
827       StdMeshers::StdMeshers_MaxLength_var initHyp =
828         StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis(true) );
829       noPreestimatedAtEdition =
830         ( initHyp->_is_nil() || !initHyp->HavePreestimatedLength() );
831       if ( !noPreestimatedAtEdition )
832         h->SetPreestimatedLength( initHyp->GetPreestimatedLength() );
833     }
834
835     item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
836     if(!initVariableName( hyp, item, "SetLength"))
837       item.myValue = h->GetLength();
838     p.append( item );
839     customWidgets()->append(0);
840
841     item.myName = tr("SMESH_USE_PREESTIMATED_LENGTH");
842     p.append( item );
843     QCheckBox* aQCheckBox = new QCheckBox(dlg());
844     if ( !noPreestimatedAtEdition && h->HavePreestimatedLength() ) {
845       aQCheckBox->setChecked( h->GetUsePreestimatedLength() );
846       connect( aQCheckBox, SIGNAL(  stateChanged(int) ), this, SLOT( onValueChanged() ) );
847     }
848     else {
849       aQCheckBox->setChecked( false );
850       aQCheckBox->setEnabled( false );
851     }
852     customWidgets()->append( aQCheckBox );
853   }
854   else if( hypType()=="SegmentLengthAroundVertex" )
855   {
856     StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
857       StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp );
858
859     item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
860     if(!initVariableName( hyp, item, "SetLength"))
861       item.myValue = h->GetLength();
862     
863     p.append( item );
864   }
865   else if( hypType()=="Arithmetic1D" )
866   {
867     StdMeshers::StdMeshers_Arithmetic1D_var h =
868       StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
869
870     item.myName = tr( "SMESH_START_LENGTH_PARAM" );
871     if(!initVariableName( hyp, item, "SetStartLength" ))
872       item.myValue = h->GetLength( true );
873     p.append( item );
874
875     customWidgets()->append (0);
876
877     item.myName = tr( "SMESH_END_LENGTH_PARAM" );
878     if(!initVariableName( hyp, item, "SetEndLength" ))
879       item.myValue = h->GetLength( false );
880     p.append( item );
881
882     customWidgets()->append (0);
883
884     item.myName = tr( "SMESH_REVERSED_EDGES" );
885     p.append( item );
886
887     customWidgets()->append ( makeReverseEdgesWdg( h->GetReversedEdges(), h->GetObjectEntry() ));
888   }
889
890   else if( hypType()=="GeometricProgression" )
891   {
892     StdMeshers::StdMeshers_Geometric1D_var h =
893       StdMeshers::StdMeshers_Geometric1D::_narrow( hyp );
894
895     item.myName = tr( "SMESH_START_LENGTH_PARAM" );
896     if(!initVariableName( hyp, item, "SetStartLength" ))
897       item.myValue = h->GetStartLength();
898     p.append( item );
899
900     customWidgets()->append (0);
901
902     item.myName = tr( "SMESH_COMMON_RATIO" );
903     if(!initVariableName( hyp, item, "SetCommonRatio" ))
904       item.myValue = h->GetCommonRatio();
905     p.append( item );
906
907     customWidgets()->append (0);
908
909     item.myName = tr( "SMESH_REVERSED_EDGES" );
910     p.append( item );
911
912     customWidgets()->append ( makeReverseEdgesWdg( h->GetReversedEdges(), h->GetObjectEntry() ));
913   }
914
915   else if( hypType()=="FixedPoints1D" )
916   {
917     StdMeshers::StdMeshers_FixedPoints1D_var h =
918       StdMeshers::StdMeshers_FixedPoints1D::_narrow( hyp );
919
920     item.myName = tr( "SMESH_FIXED_POINTS" );
921     p.append( item );
922
923     StdMeshersGUI_FixedPointsParamWdg* aFixedPointsWidget =
924       new StdMeshersGUI_FixedPointsParamWdg();
925
926     if ( !isCreation() ) {
927       aFixedPointsWidget->SetListOfPoints( h->GetPoints() );
928       aFixedPointsWidget->SetListOfSegments( h->GetNbSegments() );
929     }
930     customWidgets()->append( aFixedPointsWidget );
931
932     item.myName = tr( "SMESH_REVERSED_EDGES" );
933     p.append( item );
934
935     customWidgets()->append ( makeReverseEdgesWdg( h->GetReversedEdges(), h->GetObjectEntry() ));
936   }
937
938
939   else if( hypType()=="MaxElementArea" )
940   {
941     StdMeshers::StdMeshers_MaxElementArea_var h =
942       StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp );
943
944     item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
945     if(!initVariableName( hyp, item, "SetMaxElementArea" ))
946       item.myValue = h->GetMaxElementArea();
947     p.append( item );
948
949   }
950   else if( hypType()=="MaxElementVolume" )
951   {
952     StdMeshers::StdMeshers_MaxElementVolume_var h =
953       StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp );
954
955     item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
956     if(!initVariableName( hyp, item, "SetMaxElementVolume" ))
957       item.myValue = h->GetMaxElementVolume();
958     p.append( item );
959   }
960   else if( hypType()=="StartEndLength" )
961   {
962     StdMeshers::StdMeshers_StartEndLength_var h =
963       StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
964
965     item.myName = tr( "SMESH_START_LENGTH_PARAM" );
966
967     if(!initVariableName( hyp, item, "SetStartLength" ))
968       item.myValue = h->GetLength( true );
969     p.append( item );
970     customWidgets()->append(0);
971
972     item.myName = tr( "SMESH_END_LENGTH_PARAM" );
973     if(!initVariableName( hyp, item, "SetEndLength" ))
974       item.myValue = h->GetLength( false );
975     p.append( item );
976     customWidgets()->append(0);
977
978     item.myName = tr( "SMESH_REVERSED_EDGES" );
979     p.append( item );
980
981     customWidgets()->append ( makeReverseEdgesWdg( h->GetReversedEdges(), h->GetObjectEntry() ));
982   }
983   else if( hypType()=="Deflection1D" )
984   {
985     StdMeshers::StdMeshers_Deflection1D_var h =
986       StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
987
988     item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
989     if(!initVariableName( hyp, item, "SetDeflection" ))
990       item.myValue = h->GetDeflection();
991     p.append( item );
992   }
993   else if( hypType()=="Adaptive1D" )
994   {
995     StdMeshers::StdMeshers_Adaptive1D_var h =
996       StdMeshers::StdMeshers_Adaptive1D::_narrow( hyp );
997
998     item.myName = tr( "SMESH_MIN_SIZE" );
999     if(!initVariableName( hyp, item, "SetMinSize" ))
1000       item.myValue = h->GetMinSize();
1001     p.append( item );
1002
1003     item.myName = tr( "SMESH_MAX_SIZE" );
1004     if(!initVariableName( hyp, item, "SetMaxSize" ))
1005       item.myValue = h->GetMaxSize();
1006     p.append( item );
1007
1008     item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
1009     if(!initVariableName( hyp, item, "SetDeflection" ))
1010       item.myValue = h->GetDeflection();
1011     p.append( item );
1012   }
1013   else if( hypType()=="AutomaticLength" )
1014   {
1015     StdMeshers::StdMeshers_AutomaticLength_var h =
1016       StdMeshers::StdMeshers_AutomaticLength::_narrow( hyp );
1017
1018     item.myName = tr( "SMESH_FINENESS_PARAM" );
1019     //item.myValue = h->GetFineness();
1020     p.append( item );
1021     SMESHGUI_SpinBox* _autoLengthSpinBox = new SMESHGUI_SpinBox(dlg());
1022     _autoLengthSpinBox->RangeStepAndValidator(0, 1, 0.01, "length_precision");
1023     _autoLengthSpinBox->SetValue(h->GetFineness());
1024     customWidgets()->append( _autoLengthSpinBox);
1025   }
1026   else if( hypType()=="NumberOfLayers" )
1027   {
1028     StdMeshers::StdMeshers_NumberOfLayers_var h =
1029       StdMeshers::StdMeshers_NumberOfLayers::_narrow( hyp );
1030
1031     item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1032     if(!initVariableName( hyp, item, "SetNumberOfLayers" ))     
1033       item.myValue = (int) h->GetNumberOfLayers();
1034     p.append( item );
1035   }
1036   else if( hypType()=="LayerDistribution" )
1037   {
1038     StdMeshers::StdMeshers_LayerDistribution_var h =
1039       StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp );
1040     
1041     item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
1042     initVariableName( hyp, item, "SetLayerDistribution" );
1043     customWidgets()->append ( new StdMeshersGUI_LayerDistributionParamWdg
1044                               ( h, h->GetLayerDistribution(), hypName(), dlg() ));
1045   }
1046   else if( hypType()=="NumberOfLayers2D" )
1047   {
1048     StdMeshers::StdMeshers_NumberOfLayers2D_var h =
1049       StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hyp );
1050     
1051     item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1052     if(!initVariableName( hyp, item, "SetNumberOfLayers" ))     
1053       item.myValue = (int) h->GetNumberOfLayers();
1054     p.append( item );
1055   }
1056   else if( hypType()=="LayerDistribution2D" )
1057   {
1058     StdMeshers::StdMeshers_LayerDistribution2D_var h =
1059       StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hyp );
1060
1061     item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
1062     initVariableName( hyp, item, "SetLayerDistribution" );
1063     customWidgets()->append ( new StdMeshersGUI_LayerDistributionParamWdg
1064                               ( h, h->GetLayerDistribution(), hypName(), dlg() ));
1065   }
1066   else if( hypType()=="ProjectionSource1D" )
1067   {
1068     StdMeshers::StdMeshers_ProjectionSource1D_var h =
1069       StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hyp );
1070
1071     item.myName = tr( "SMESH_SOURCE_EDGE" ); p.append( item );
1072     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 1 ),
1073                                                h->GetSourceEdge()));
1074     item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1075     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1076                                                h->GetSourceMesh()));
1077     item.myName = tr( "SMESH_SOURCE_VERTEX" ); p.append( item );
1078     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1079                                                h->GetSourceVertex()));
1080     item.myName = tr( "SMESH_TARGET_VERTEX" ); p.append( item );
1081     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1082                                                h->GetTargetVertex()));
1083   }
1084   else if( hypType()=="ProjectionSource2D" )
1085   {
1086     StdMeshers::StdMeshers_ProjectionSource2D_var h =
1087       StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hyp );
1088
1089     item.myName = tr( "SMESH_SOURCE_FACE" ); p.append( item );
1090     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 2 ),
1091                                                h->GetSourceFace()));
1092     item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1093     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1094                                                h->GetSourceMesh()));
1095     item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1096     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1097                                                h->GetSourceVertex( 1 )));
1098     item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1099     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1100                                                h->GetTargetVertex( 1 )));
1101     item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1102     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1103                                                h->GetSourceVertex( 2 )));
1104     item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1105     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1106                                                h->GetTargetVertex( 2 )));
1107   }
1108   else if( hypType()=="ProjectionSource3D" )
1109   {
1110     StdMeshers::StdMeshers_ProjectionSource3D_var h =
1111       StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hyp );
1112
1113     item.myName = tr( "SMESH_SOURCE_3DSHAPE" ); p.append( item );
1114     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 3, TopAbs_FACE, 6, true ),
1115                                                h->GetSource3DShape()));
1116     item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
1117     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::MESH ),
1118                                                h->GetSourceMesh()));
1119     item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
1120     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1121                                                h->GetSourceVertex( 1 )));
1122     item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
1123     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1124                                                h->GetTargetVertex( 1 )));
1125     item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
1126     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1127                                                h->GetSourceVertex( 2 )));
1128     item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
1129     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
1130                                                h->GetTargetVertex( 2 )));
1131   }
1132   else if( hypType()=="ImportSource1D" )
1133   {
1134     StdMeshers::StdMeshers_ImportSource1D_var h =
1135       StdMeshers::StdMeshers_ImportSource1D::_narrow( hyp );
1136
1137     SMESH::string_array_var groupEntries = h->GetSourceEdges();
1138     CORBA::Boolean toCopyMesh, toCopyGroups;
1139     h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1140
1141     item.myName = tr( "SMESH_SOURCE_EDGES" ); p.append( item );
1142     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::GROUP_EDGE ), 
1143                                                 groupEntries));
1144
1145     item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1146     QCheckBox* aQCheckBox = new QCheckBox(dlg());
1147     aQCheckBox->setChecked( toCopyMesh );
1148     connect( aQCheckBox, SIGNAL(  stateChanged(int) ), this, SLOT( onValueChanged() ));
1149     customWidgets()->append( aQCheckBox );
1150
1151     item.myName = tr( "SMESH_TO_COPY_GROUPS" ); p.append( item );
1152     aQCheckBox = new QCheckBox(dlg());
1153     aQCheckBox->setChecked( toCopyGroups );
1154     aQCheckBox->setEnabled( toCopyMesh );
1155     customWidgets()->append( aQCheckBox );
1156   }
1157   else if( hypType()=="ImportSource2D" )
1158   {
1159     StdMeshers::StdMeshers_ImportSource2D_var h =
1160       StdMeshers::StdMeshers_ImportSource2D::_narrow( hyp );
1161
1162     SMESH::string_array_var groupEntries = h->GetSourceFaces();
1163     CORBA::Boolean toCopyMesh, toCopyGroups;
1164     h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
1165
1166     item.myName = tr( "SMESH_SOURCE_FACES" ); p.append( item );
1167     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( SMESH::GROUP_FACE ), 
1168                                                 groupEntries));
1169
1170     item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
1171     QCheckBox* aQCheckBox = new QCheckBox(dlg());
1172     aQCheckBox->setChecked( toCopyMesh );
1173     connect( aQCheckBox, SIGNAL(  stateChanged(int) ), this, SLOT( onValueChanged() ));
1174     customWidgets()->append( aQCheckBox );
1175
1176     item.myName = tr( "SMESH_COPY_GROUPS" ); p.append( item );
1177     aQCheckBox = new QCheckBox(dlg());
1178     aQCheckBox->setChecked( toCopyGroups );
1179     aQCheckBox->setEnabled( toCopyMesh );
1180     customWidgets()->append( aQCheckBox );
1181   }
1182   else if( hypType()=="ViscousLayers" )
1183   {
1184     StdMeshers::StdMeshers_ViscousLayers_var h =
1185       StdMeshers::StdMeshers_ViscousLayers::_narrow( hyp );
1186
1187     item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1188     if(!initVariableName( hyp, item, "SetTotalThickness" ))
1189       item.myValue = h->GetTotalThickness();
1190     p.append( item );
1191     customWidgets()->append (0);
1192
1193     item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1194     if(!initVariableName( hyp, item, "SetNumberLayers" ))
1195       item.myValue = h->GetNumberLayers();
1196     p.append( item );
1197     customWidgets()->append (0);
1198
1199     item.myName = tr( "SMESH_STRETCH_FACTOR" );
1200     if(!initVariableName( hyp, item, "SetStretchFactor" ))
1201       item.myValue = h->GetStretchFactor();
1202     p.append( item );
1203     customWidgets()->append (0);
1204
1205     item.myName = tr( "EXTRUSION_METHOD" );
1206     p.append( item );
1207     StdMeshersGUI_RadioButtonsGrpWdg* methodWdg = new StdMeshersGUI_RadioButtonsGrpWdg("");
1208     methodWdg->setButtonLabels ( QStringList()
1209                                  << tr("EXTMETH_SURF_OFFSET_SMOOTH")
1210                                  << tr("EXTMETH_FACE_OFFSET")
1211                                  << tr("EXTMETH_NODE_OFFSET"),
1212                                  QStringList()
1213                                  << tr("ICON_EXTMETH_SURF_OFFSET_SMOOTH")
1214                                  << tr("ICON_EXTMETH_FACE_OFFSET")
1215                                  << tr("ICON_EXTMETH_NODE_OFFSET"));
1216     methodWdg->setChecked( (int) h->GetMethod() );
1217     customWidgets()->append( methodWdg );
1218
1219     QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1220     QString aSubEntry  = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1221     if ( !aMainEntry.isEmpty() )
1222     {
1223       item.myName = tr( "TO_IGNORE_FACES_OR_NOT" );
1224       p.append( item );
1225
1226       StdMeshersGUI_RadioButtonsGrpWdg* ignoreWdg = new StdMeshersGUI_RadioButtonsGrpWdg("");
1227       ignoreWdg->setButtonLabels ( QStringList()
1228                                    << tr("NOT_TO_IGNORE_FACES")
1229                                    << tr("TO_IGNORE_FACES") );
1230       ignoreWdg->setChecked( h->GetIsToIgnoreFaces() );
1231       connect(ignoreWdg->getButtonGroup(),SIGNAL(buttonClicked(int)),this,SLOT(onValueChanged()));
1232       customWidgets()->append( ignoreWdg );
1233
1234       item.myName =
1235         tr( h->GetIsToIgnoreFaces() ? "SMESH_FACES_WO_LAYERS" : "SMESH_FACES_WITH_LAYERS" );
1236       p.append( item );
1237
1238       StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1239         new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_FACE);
1240
1241       idsWg->SetGeomShapeEntry( aSubEntry, aMainEntry );
1242       if ( idsWg->SetListOfIDs( h->GetFaces() ))
1243       {
1244         idsWg->ShowPreview( true );
1245       }
1246       else
1247       {
1248         SUIT_MessageBox::warning( dlg(),tr( "SMESH_WRN_WARNING" ),tr( "BAD_FACES_WARNING" ));
1249         idsWg->setEnabled( false );
1250       }
1251       customWidgets()->append ( idsWg );
1252     }
1253   }
1254   else if( hypType()=="ViscousLayers2D" )
1255   {
1256     StdMeshers::StdMeshers_ViscousLayers2D_var h =
1257       StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hyp );
1258
1259     item.myName = tr( "SMESH_TOTAL_THICKNESS" );
1260     if(!initVariableName( hyp, item, "SetTotalThickness" ))
1261       item.myValue = h->GetTotalThickness();
1262     p.append( item );
1263     customWidgets()->append (0);
1264
1265     item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
1266     if(!initVariableName( hyp, item, "SetNumberLayers" ))
1267       item.myValue = h->GetNumberLayers();
1268     p.append( item );
1269     customWidgets()->append (0);
1270
1271     item.myName = tr( "SMESH_STRETCH_FACTOR" );
1272     if(!initVariableName( hyp, item, "SetStretchFactor" ))
1273       item.myValue = h->GetStretchFactor();
1274     p.append( item );
1275     customWidgets()->append (0);
1276
1277     QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1278     QString aSubEntry  = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1279     if ( !aMainEntry.isEmpty() )
1280     {
1281       item.myName = tr("TO_IGNORE_EDGES_OR_NOT");
1282       p.append( item );
1283
1284       StdMeshersGUI_RadioButtonsGrpWdg* ignoreWdg = new StdMeshersGUI_RadioButtonsGrpWdg("");
1285       ignoreWdg->setButtonLabels ( QStringList()
1286                                    << tr("NOT_TO_IGNORE_EDGES")
1287                                    << tr("TO_IGNORE_EDGES") );
1288       ignoreWdg->setChecked( h->GetIsToIgnoreEdges() );
1289       connect(ignoreWdg->getButtonGroup(),SIGNAL(buttonClicked(int)),this,SLOT(onValueChanged()));
1290       customWidgets()->append( ignoreWdg );
1291
1292       item.myName =
1293         tr( h->GetIsToIgnoreEdges() ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" );
1294       p.append( item );
1295
1296       StdMeshersGUI_SubShapeSelectorWdg* idsWg =
1297         new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_EDGE);
1298
1299       idsWg->SetGeomShapeEntry( aSubEntry, aMainEntry );
1300       if ( idsWg->SetListOfIDs( h->GetEdges() ))
1301       {
1302         idsWg->ShowPreview( true );
1303       }
1304       else
1305       {
1306         SUIT_MessageBox::warning( dlg(),tr( "SMESH_WRN_WARNING" ),tr( "BAD_EDGES_WARNING" ));
1307         idsWg->setEnabled( false );
1308       }
1309       customWidgets()->append ( idsWg );
1310     }
1311   }
1312   else
1313     res = false;
1314   return res;
1315 }
1316
1317 //================================================================================
1318 /*!
1319  * \brief tune "standard" control
1320  *  \param w - control widget
1321  *  \param int - parameter index
1322  */
1323 //================================================================================
1324
1325 void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) const
1326 {
1327   SMESHGUI_SpinBox* sb = w->inherits( "SMESHGUI_SpinBox" ) ? ( SMESHGUI_SpinBox* )w : 0;
1328   if ( sb )
1329   {
1330     if( hypType()=="LocalLength" )
1331     {
1332       if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PARAM"))
1333         sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1334       else if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PRECISION"))
1335         sb->RangeStepAndValidator( 0.0, 1.0, 0.05, "len_tol_precision" );
1336     }
1337     else if( hypType()=="Arithmetic1D" )
1338     {
1339       sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1340     }
1341     else if( hypType()=="GeometricProgression" )
1342     {
1343       if (sb->objectName() == tr("SMESH_START_LENGTH_PARAM"))
1344         sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1345       else if (sb->objectName() == tr("SMESH_COMMON_RATIO"))
1346         sb->RangeStepAndValidator( -VALUE_MAX, VALUE_MAX, 0.5, "len_tol_precision" );
1347     }
1348     else if( hypType()=="MaxLength" )
1349     {
1350       sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1351       sb->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1352       sb->setMinimumWidth( 150 );
1353     }
1354     else if( hypType()=="MaxElementArea" )
1355     {
1356       sb->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 1.0, "area_precision" );
1357     }
1358     else if( hypType()=="MaxElementVolume" )
1359     {
1360       sb->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 1.0, "vol_precision" );
1361     }
1362     else if( hypType()=="StartEndLength" )
1363     {
1364       sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1365     }
1366     else if( hypType()=="Deflection1D" )
1367     {
1368       sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
1369     }
1370     else if( hypType()=="Adaptive1D" )
1371     {
1372       sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1373     }
1374     else if( hypType().startsWith( "ViscousLayers" ))
1375     {
1376       if (sb->objectName() == tr("SMESH_STRETCH_FACTOR"))
1377         sb->RangeStepAndValidator( 1.0, VALUE_MAX, 0.1, "parametric_precision" );
1378       else
1379         sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1380     }
1381     else // default validator for possible ancestors
1382     {
1383       sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
1384     }
1385   }
1386 }
1387
1388 //================================================================================
1389 /*!
1390  * \brief Return dlg title
1391   * \retval QString - title string
1392  */
1393 //================================================================================
1394
1395 QString StdMeshersGUI_StdHypothesisCreator::caption() const
1396 {
1397   return tr( QString( "SMESH_%1_TITLE" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1398 }
1399
1400 //================================================================================
1401 /*!
1402  * \brief return pixmap for dlg icon
1403   * \retval QPixmap - 
1404  */
1405 //================================================================================
1406
1407 QPixmap StdMeshersGUI_StdHypothesisCreator::icon() const
1408 {
1409   QString hypIconName = tr( QString( "ICON_DLG_%1" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1410   return SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName );
1411 }
1412
1413 //================================================================================
1414 /*!
1415  * \brief Return hypothesis type name to show in dlg
1416   * \retval QString - 
1417  */
1418 //================================================================================
1419
1420 QString StdMeshersGUI_StdHypothesisCreator::type() const
1421 {
1422   return tr( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
1423 }
1424
1425 //================================================================================
1426 /*!
1427  * \brief String to insert in "SMESH_%1_HYPOTHESIS" to get hypothesis type name
1428  * from message resouce file
1429   * \param t - hypothesis type
1430   * \retval QString - result string
1431  */
1432 //================================================================================
1433
1434 QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) const
1435 {
1436   static QMap<QString,QString>  types;
1437   if( types.isEmpty() )
1438   {
1439     types.insert( "LocalLength", "LOCAL_LENGTH" );
1440     types.insert( "NumberOfSegments", "NB_SEGMENTS" );
1441     types.insert( "MaxElementArea", "MAX_ELEMENT_AREA" );
1442     types.insert( "MaxElementVolume", "MAX_ELEMENT_VOLUME" );
1443     types.insert( "StartEndLength", "START_END_LENGTH" );
1444     types.insert( "Deflection1D", "DEFLECTION1D" );
1445     types.insert( "Adaptive1D", "ADAPTIVE1D" );
1446     types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
1447     types.insert( "GeometricProgression", "GEOMETRIC_1D" );
1448     types.insert( "FixedPoints1D", "FIXED_POINTS_1D" );
1449     types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" );
1450     types.insert( "ProjectionSource1D", "PROJECTION_SOURCE_1D" );
1451     types.insert( "ProjectionSource2D", "PROJECTION_SOURCE_2D" );
1452     types.insert( "ProjectionSource3D", "PROJECTION_SOURCE_3D" );
1453     types.insert( "ImportSource1D", "IMPORT_SOURCE_1D" );
1454     types.insert( "ImportSource2D", "IMPORT_SOURCE_2D" );
1455     types.insert( "NumberOfLayers", "NUMBER_OF_LAYERS" );
1456     types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" );
1457     types.insert( "NumberOfLayers2D", "NUMBER_OF_LAYERS_2D" );
1458     types.insert( "LayerDistribution2D", "LAYER_DISTRIBUTION" );
1459     types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" );
1460     types.insert( "MaxLength", "MAX_LENGTH" );
1461     types.insert( "ViscousLayers", "VISCOUS_LAYERS" );
1462     types.insert( "ViscousLayers2D", "VISCOUS_LAYERS" );
1463     types.insert( "QuadrangleParams", "QUADRANGLE_PARAMS" );
1464     types.insert( "CartesianParameters3D", "CARTESIAN_PARAMS" );
1465   }
1466
1467   QString res;
1468   if( types.contains( t ) )
1469     res = types[ t ];
1470
1471   return res;
1472 }
1473
1474
1475 //=======================================================================
1476 //function : getCustomWidget
1477 //purpose  : is called from buildStdFrame()
1478 //=======================================================================
1479
1480 QWidget* StdMeshersGUI_StdHypothesisCreator::getCustomWidget( const StdParam & param,
1481                                                               QWidget*         parent,
1482                                                               const int        index) const
1483 {
1484   QWidget* w = 0;
1485   if ( index < customWidgets()->count() ) {
1486     w = customWidgets()->at( index );
1487     if ( w ) {
1488       w->setParent( parent );
1489       w->move( QPoint( 0, 0 ) );
1490     }
1491   }
1492   return w;
1493 }
1494
1495 //================================================================================
1496 /*!
1497  * \brief Set param value taken from a custom widget
1498   * \param param - SMESHGUI_GenericHypothesisCreator::StdParam structure
1499   * \param widget - widget presenting param
1500   * \retval bool - success flag
1501  * 
1502  * this method is called from getStdParamFromDlg()
1503  */
1504 //================================================================================
1505
1506 bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & param,
1507                                                                    QWidget*   widget) const
1508 {
1509   if ( hypType()=="AutomaticLength" ) {
1510     SMESHGUI_SpinBox* w = dynamic_cast<SMESHGUI_SpinBox*>( widget );
1511     if ( w ) {
1512       param.myValue = w->GetValue();
1513       return true;
1514     }
1515   }
1516   if ( hypType() == "MaxLength" ) {
1517     param.myValue = "";
1518     return true;
1519   }
1520   if ( widget->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
1521   {
1522     // show only 1st reference value
1523     if ( true /*widget == getWidgetForParam( 0 )*/) {
1524       const StdMeshersGUI_ObjectReferenceParamWdg * w =
1525         static_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( widget );
1526       param.myValue = w->GetValue();
1527     }
1528     return true;
1529   }
1530   if ( widget->inherits( "StdMeshersGUI_LayerDistributionParamWdg" ))
1531   {
1532     const StdMeshersGUI_LayerDistributionParamWdg * w =
1533       static_cast<const StdMeshersGUI_LayerDistributionParamWdg*>( widget );
1534     param.myValue = w->GetValue();
1535     return true;
1536   }
1537   if ( widget->inherits( "StdMeshersGUI_SubShapeSelectorWdg" ))
1538   {
1539     const StdMeshersGUI_SubShapeSelectorWdg * w =
1540       static_cast<const StdMeshersGUI_SubShapeSelectorWdg*>( widget );
1541     param.myValue = w->GetValue();
1542     return true;
1543   }
1544   // if ( widget->inherits( "StdMeshersGUI_QuadrangleParamWdg" ))
1545   // {
1546   //   param.myValue = "QuadType";
1547   //   return true;
1548   // }
1549   if ( widget->inherits( "StdMeshersGUI_FixedPointsParamWdg" ))
1550   {
1551     const StdMeshersGUI_FixedPointsParamWdg * w =
1552       static_cast<const StdMeshersGUI_FixedPointsParamWdg*>( widget );
1553     param.myValue = w->GetValue();
1554     return true;
1555   }
1556   if ( widget->inherits( "QCheckBox" ))
1557   {
1558     //const QCheckBox * w = static_cast<const QCheckBox*>( widget );
1559     //param.myValue = w->isChecked();
1560     return true;
1561   }
1562   if ( widget->inherits( "StdMeshersGUI_RadioButtonsGrpWdg" ))
1563   {
1564     const StdMeshersGUI_RadioButtonsGrpWdg * w =
1565       static_cast<const StdMeshersGUI_RadioButtonsGrpWdg*>( widget );
1566     param.myValue = w->checkedId();
1567     return true;
1568   }
1569   return false;
1570 }
1571
1572 //================================================================================
1573 /*!
1574  * \brief called when operation cancelled
1575  */
1576 //================================================================================
1577
1578 void StdMeshersGUI_StdHypothesisCreator::onReject()
1579 {
1580   if ( hypType().startsWith("ProjectionSource" ) ||
1581        hypType().startsWith("ImportSource" ))
1582   {
1583     // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
1584     deactivateObjRefParamWdg( customWidgets() );
1585   }
1586 }
1587
1588 //================================================================================
1589 /*!
1590  * \brief Update widgets dependent on paramWidget
1591  */
1592 //================================================================================
1593
1594 void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget)
1595 {
1596   if ( hypType() == "MaxLength" && paramWidget == getWidgetForParam(1) )
1597   {
1598     getWidgetForParam(0)->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
1599     if ( !getWidgetForParam(0)->isEnabled() ) {
1600       StdMeshers::StdMeshers_MaxLength_var h =
1601         StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
1602       widget< QtxDoubleSpinBox >( 0 )->setValue( h->GetPreestimatedLength() );
1603     }
1604   }
1605   else if ( hypType().startsWith("ImportSource") && paramWidget == getWidgetForParam(1) )
1606   {
1607     QCheckBox* toCopyMesh   = (QCheckBox*) paramWidget;
1608     QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
1609     if ( !toCopyMesh->isChecked() )
1610     {
1611       toCopyGroups->setChecked( false );
1612       toCopyGroups->setEnabled( false );
1613     }
1614     else
1615     {
1616       toCopyGroups->setEnabled( true );
1617     }
1618   }
1619   else if ( hypType().startsWith( "ViscousLayers" ) && paramWidget->inherits("QButtonGroup"))
1620   {
1621     int widgetNumber = hypType() == "ViscousLayers2D" ? 3 : 4;
1622     if ( QLabel* label = getLabel( widgetNumber + 1 ) )
1623     {
1624       bool toIgnore = widget< StdMeshersGUI_RadioButtonsGrpWdg >( widgetNumber )->checkedId();
1625       if ( hypType() == "ViscousLayers2D" )
1626         label->setText( tr( toIgnore ? "SMESH_EDGES_WO_LAYERS" : "SMESH_EDGES_WITH_LAYERS" ));
1627       else
1628         label->setText( tr( toIgnore ? "SMESH_FACES_WO_LAYERS" : "SMESH_FACES_WITH_LAYERS" ));
1629     }
1630   }
1631 }
1632
1633 //================================================================================
1634 /*!
1635  *
1636  */
1637 //================================================================================
1638
1639 bool StdMeshersGUI_StdHypothesisCreator::initVariableName(SMESH::SMESH_Hypothesis_var theHyp, 
1640                                                           StdParam &                  theParams, 
1641                                                           const char*                 theMethod) const
1642 {
1643   QString aVaribaleName = getVariableName( theMethod );
1644   theParams.isVariable = !aVaribaleName.isEmpty();
1645   if (theParams.isVariable)
1646     theParams.myValue = aVaribaleName;
1647
1648   return theParams.isVariable;
1649 }
1650
1651 //================================================================================
1652 /*!
1653  * \brief Creates two widgets used to define reversed edges for some 1D hypotheses
1654  *  \param [in] edgeIDs - ids of reversed edges to set to the widgets
1655  *  \param [in] shapeEntry - entry of a sub-shape of a sub-mesh if any
1656  *  \return QWidget* - new StdMeshersGUI_SubShapeSelectorWdg; 
1657  *          new StdMeshersGUI_PropagationHelperWdg is stored in \a myHelperWidget field.
1658  */
1659 //================================================================================
1660
1661 QWidget*
1662 StdMeshersGUI_StdHypothesisCreator::makeReverseEdgesWdg( SMESH::long_array_var edgeIDs,
1663                                                          CORBA::String_var     shapeEntry) const
1664 {
1665   QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
1666   QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
1667   if ( aGeomEntry.isEmpty() && shapeEntry.in() )
1668     aGeomEntry = shapeEntry.in();
1669
1670   StdMeshersGUI_SubShapeSelectorWdg* wdg = new StdMeshersGUI_SubShapeSelectorWdg();
1671   wdg->SetGeomShapeEntry( aGeomEntry, aMainEntry );
1672   wdg->SetListOfIDs( edgeIDs );
1673   wdg->ShowPreview( true );
1674
1675   if ( !aGeomEntry.isEmpty() || !aMainEntry.isEmpty() )
1676     const_cast<StdMeshersGUI_StdHypothesisCreator*>( this )->
1677       myHelperWidget = new StdMeshersGUI_PropagationHelperWdg( wdg );
1678
1679   return wdg;
1680 }