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