Back to index

salome-smesh  6.5.0
StdMeshersGUI_StdHypothesisCreator.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 //  File   : StdMeshersGUI_StdHypothesisCreator.cxx
00023 //  Author : Alexander SOLOVYOV, Open CASCADE S.A.S.
00024 //  SMESH includes
00025 
00026 #include "StdMeshersGUI_StdHypothesisCreator.h"
00027 
00028 #include <SMESHGUI.h>
00029 #include <SMESHGUI_SpinBox.h>
00030 #include <SMESHGUI_HypothesesUtils.h>
00031 #include <SMESHGUI_Utils.h>
00032 #include <SMESHGUI_GEOMGenUtils.h>
00033 
00034 #include <SMESH_TypeFilter.hxx>
00035 #include <SMESH_NumberFilter.hxx>
00036 
00037 #include "StdMeshersGUI_FixedPointsParamWdg.h"
00038 #include "StdMeshersGUI_LayerDistributionParamWdg.h"
00039 #include "StdMeshersGUI_ObjectReferenceParamWdg.h"
00040 #include "StdMeshersGUI_QuadrangleParamWdg.h"
00041 #include "StdMeshersGUI_SubShapeSelectorWdg.h"
00042 
00043 #include <SALOMEDSClient_Study.hxx>
00044 
00045 // SALOME GUI includes
00046 #include <SUIT_ResourceMgr.h>
00047 
00048 // IDL includes
00049 #include <SALOMEconfig.h>
00050 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
00051 #include CORBA_SERVER_HEADER(SMESH_Mesh)
00052 #include CORBA_SERVER_HEADER(SMESH_Group)
00053 
00054 // Qt includes
00055 #include <QHBoxLayout>
00056 #include <QSlider>
00057 #include <QLabel>
00058 #include <QCheckBox>
00059 
00060 const double VALUE_MAX = 1.0e+15, // COORD_MAX
00061              VALUE_MAX_2  = VALUE_MAX * VALUE_MAX,
00062              VALUE_MAX_3  = VALUE_MAX_2 * VALUE_MAX,
00063              VALUE_SMALL = 1.0e-15,
00064              VALUE_SMALL_2 = VALUE_SMALL * VALUE_SMALL,
00065              VALUE_SMALL_3 = VALUE_SMALL_2 * VALUE_SMALL;
00066 
00067 //================================================================================
00072 //================================================================================
00073 
00074 StdMeshersGUI_StdHypothesisCreator::StdMeshersGUI_StdHypothesisCreator( const QString& type )
00075 : SMESHGUI_GenericHypothesisCreator( type )
00076 {
00077 }
00078 
00079 //================================================================================
00083 //================================================================================
00084 
00085 StdMeshersGUI_StdHypothesisCreator::~StdMeshersGUI_StdHypothesisCreator()
00086 {
00087 }
00088 
00089 //================================================================================
00095 //================================================================================
00096 
00097 QWidget* StdMeshersGUI_StdHypothesisCreator::getWidgetForParam( int i ) const
00098 {
00099   QWidget* w = 0;
00100   if ( isCreation() ) ++i; // skip widget of 'name' parameter
00101 
00102   if ( i < myCustomWidgets.count() ) {
00103     QList<QWidget*>::const_iterator anIt  = myCustomWidgets.begin();
00104     QList<QWidget*>::const_iterator aLast = myCustomWidgets.end();
00105     for ( int j = 0 ; !w && anIt != aLast; ++anIt, ++j )
00106       if ( i == j )
00107         w = *anIt;
00108   }
00109   if ( !w ) {
00110     // list has no at() const, so we iterate
00111     QList<QWidget*>::const_iterator anIt  = widgets().begin();
00112     QList<QWidget*>::const_iterator aLast = widgets().end();
00113     for( int j = 0; !w && anIt!=aLast; anIt++, ++j ) {
00114       if ( i == j )
00115         w = *anIt;
00116     }
00117   }
00118   return w;
00119 }
00120 
00121 //================================================================================
00126 //================================================================================
00127 
00128 StdMeshersGUI_StdHypothesisCreator::ListOfWidgets*
00129 StdMeshersGUI_StdHypothesisCreator::customWidgets() const
00130 {
00131   return const_cast< ListOfWidgets* >( & myCustomWidgets );
00132 }
00133 
00134 //================================================================================
00139 //================================================================================
00140 
00141 QFrame* StdMeshersGUI_StdHypothesisCreator::buildFrame()
00142 {
00143   return buildStdFrame();
00144 }
00145 
00146 //================================================================================
00150 //================================================================================
00151 
00152 void StdMeshersGUI_StdHypothesisCreator::retrieveParams() const
00153 {
00154   // buildStdFrame() sets values itself calling stdParams()
00155 
00156   if ( hypType().startsWith("ProjectionSource" ))
00157   {
00158     // we use this method to connect depending custom widgets
00159     StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0;
00160     ListOfWidgets::const_iterator anIt = myCustomWidgets.begin();
00161     for ( ; anIt != myCustomWidgets.end(); anIt++)
00162     {
00163       if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
00164       {
00165         StdMeshersGUI_ObjectReferenceParamWdg * w1 =
00166           ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
00167         ListOfWidgets::const_iterator anIt2 = anIt;
00168         for ( ++anIt2; anIt2 != myCustomWidgets.end(); anIt2++)
00169           if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
00170           {
00171             StdMeshersGUI_ObjectReferenceParamWdg * w2 =
00172               ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 );
00173             w1->AvoidSimultaneousSelection( w2 );
00174           }
00175         if ( !widgetToActivate )
00176           widgetToActivate = w1;
00177       }
00178     }
00179     if ( widgetToActivate )
00180       widgetToActivate->activateSelection();
00181   }
00182 
00183   if ( dlg() )
00184     dlg()->setMinimumSize( dlg()->minimumSizeHint().width(), dlg()->minimumSizeHint().height() );
00185 }
00186 
00187 namespace {
00188 
00189   //================================================================================
00193   //================================================================================
00194 
00195   class TDoubleSliderWith2Labels: public QWidget
00196   {
00197   public:
00198     TDoubleSliderWith2Labels( const QString& leftLabel, const QString& rightLabel,
00199                               const double   initValue, const double   bottom,
00200                               const double   top      , const double   precision,
00201                               QWidget *      parent=0 , const char *   name=0 )
00202       :QWidget(parent), _bottom(bottom), _precision(precision)
00203     {
00204       setObjectName(name);
00205 
00206       QHBoxLayout* aHBoxL = new QHBoxLayout(this);
00207 
00208       if ( !leftLabel.isEmpty() ) {
00209         QLabel* aLeftLabel = new QLabel( this );
00210         aLeftLabel->setText( leftLabel );
00211         aHBoxL->addWidget( aLeftLabel );
00212       }
00213 
00214       _slider = new QSlider( Qt::Horizontal, this );
00215       _slider->setRange( 0, toInt( top ));
00216       _slider->setValue( toInt( initValue ));
00217       aHBoxL->addWidget( _slider );
00218 
00219       if ( !rightLabel.isEmpty() ) {
00220         QLabel* aRightLabel = new QLabel( this );
00221         aRightLabel->setText( rightLabel );
00222         aHBoxL->addWidget( aRightLabel );
00223       }
00224 
00225       setLayout( aHBoxL );
00226     }
00227     double value() const { return _bottom + _slider->value() * _precision; }
00228     QSlider * getSlider() const { return _slider; }
00229     int toInt( double val ) const { return (int) ceil(( val - _bottom ) / _precision ); }
00230   private:
00231     double _bottom, _precision;
00232     QSlider * _slider;
00233   };
00234 
00235   //================================================================================
00239   //================================================================================
00240 
00241   inline GEOM::GEOM_Object_var geomFromWdg(const QWidget* wdg)
00242   {
00243     const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
00244       dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
00245     if ( objRefWdg )
00246       return objRefWdg->GetObject< GEOM::GEOM_Object >();
00247 
00248     return GEOM::GEOM_Object::_nil();
00249   }
00250   //================================================================================
00254   //================================================================================
00255 
00256   inline SMESH::SMESH_Mesh_var meshFromWdg(const QWidget* wdg)
00257   {
00258     const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
00259       dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
00260     if ( objRefWdg )
00261       return objRefWdg->GetObject< SMESH::SMESH_Mesh >();
00262 
00263     return SMESH::SMESH_Mesh::_nil();
00264   }
00265   //================================================================================
00269   //================================================================================
00270 
00271   inline SMESH::ListOfGroups_var groupsFromWdg(const QWidget* wdg)
00272   {
00273     SMESH::ListOfGroups_var groups = new SMESH::ListOfGroups;
00274     const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg =
00275       dynamic_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( wdg );
00276     if ( objRefWdg )
00277     {
00278       groups->length( objRefWdg->NbObjects() );
00279       for ( unsigned i = 0; i < groups->length(); ++i )
00280         groups[i] = objRefWdg->GetObject< SMESH::SMESH_GroupBase >(i);
00281     }
00282     return groups;
00283   }
00284   //================================================================================
00293   //================================================================================
00294 
00295   SUIT_SelectionFilter* filterForShapeOfDim(const int        dim,
00296                                             TopAbs_ShapeEnum subShapeType = TopAbs_SHAPE,
00297                                             const int        nbSubShapes = 0,
00298                                             bool             closed = false)
00299   {
00300     TColStd_MapOfInteger shapeTypes;
00301     switch ( dim ) {
00302     case 0: shapeTypes.Add( TopAbs_VERTEX ); break;
00303     case 1:
00304       if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_EDGE;
00305       shapeTypes.Add( TopAbs_EDGE );
00306       shapeTypes.Add( TopAbs_COMPOUND ); // for a group
00307       break;
00308     case 2:
00309       if ( subShapeType == TopAbs_SHAPE ) subShapeType = TopAbs_FACE;
00310       shapeTypes.Add( TopAbs_FACE );
00311       shapeTypes.Add( TopAbs_COMPOUND ); // for a group
00312       break;
00313     case 3:
00314       shapeTypes.Add( TopAbs_SHELL );
00315       shapeTypes.Add( TopAbs_SOLID );
00316       shapeTypes.Add( TopAbs_COMPSOLID );
00317       shapeTypes.Add( TopAbs_COMPOUND );
00318       break;
00319     }
00320     return new SMESH_NumberFilter("GEOM", subShapeType, nbSubShapes,
00321                                   shapeTypes, GEOM::GEOM_Object::_nil(), closed);
00322   }
00323 
00324   //================================================================================
00331   //================================================================================
00332 
00333   QWidget* newObjRefParamWdg( SUIT_SelectionFilter* filter,
00334                               CORBA::Object_var     object)
00335   {
00336     StdMeshersGUI_ObjectReferenceParamWdg* w =
00337       new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0);
00338     w->SetObject( object.in() );
00339     return w;
00340   }
00341   QWidget* newObjRefParamWdg( SUIT_SelectionFilter*    filter,
00342                               SMESH::string_array_var& objEntries)
00343   {
00344     StdMeshersGUI_ObjectReferenceParamWdg* w =
00345       new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0, /*multiSel=*/true);
00346     //RNV: Firstly, activate selection, then set objects
00347     w->activateSelection();
00348     w->SetObjects( objEntries );
00349     return w;
00350   }
00351 
00352   //================================================================================
00357   //================================================================================
00358 
00359   void deactivateObjRefParamWdg( QList<QWidget*>* widgetList )
00360   {
00361     StdMeshersGUI_ObjectReferenceParamWdg* w = 0;
00362     QList<QWidget*>::iterator anIt  = widgetList->begin();
00363     QList<QWidget*>::iterator aLast = widgetList->end();
00364     for ( ; anIt != aLast; anIt++ ) {
00365       if ( (*anIt) && (*anIt)->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
00366       {
00367         w = (StdMeshersGUI_ObjectReferenceParamWdg* )( *anIt );
00368         w->deactivateSelection();
00369       }
00370     }
00371   }
00372 }
00373 
00374 //================================================================================
00379 //================================================================================
00380 
00381 bool StdMeshersGUI_StdHypothesisCreator::checkParams( QString& msg ) const
00382 {
00383   if( !SMESHGUI_GenericHypothesisCreator::checkParams( msg ) )
00384     return false;
00385 
00386   // check if object reference parameter is set, as it has no default value
00387   bool ok = true;
00388   if ( hypType().startsWith("ProjectionSource" ))
00389   {
00390     StdMeshersGUI_ObjectReferenceParamWdg* w =
00391       widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
00392     ok = ( w->IsObjectSelected() );
00393     if ( !ok ) w->SetObject( CORBA::Object::_nil() );
00394     int nbAssocVert = ( hypType() == "ProjectionSource1D" ? 1 : 2 );
00395     int nbNonEmptyAssoc = 0;
00396     for ( int i = 0; ok && i < nbAssocVert*2; i += 2)
00397     {
00398       QString srcV, tgtV;
00399       StdMeshersGUI_ObjectReferenceParamWdg* w1 =
00400         widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+2 );
00401       StdMeshersGUI_ObjectReferenceParamWdg* w2 =
00402         widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+3 );
00403       srcV = w1->GetValue();
00404       tgtV = w2->GetValue();
00405       ok = (( srcV.isEmpty()  && tgtV.isEmpty() ) ||
00406             ( !srcV.isEmpty() && !tgtV.isEmpty() && srcV != tgtV ));
00407       if ( !ok ) {
00408         w1->SetObject( CORBA::Object::_nil() );
00409         w2->SetObject( CORBA::Object::_nil() );
00410       }
00411       nbNonEmptyAssoc += !srcV.isEmpty();
00412     }
00413     if ( ok && nbNonEmptyAssoc == 1 && nbAssocVert == 2 )
00414     {
00415       // only one pair of VERTEXes is given for a FACE,
00416       // then the FACE must have only one VERTEX
00417       GEOM::GEOM_Object_var face = w->GetObject< GEOM::GEOM_Object >();
00418 
00419       GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
00420       _PTR(Study)         aStudy = SMESH::GetActiveStudyDocument();
00421       GEOM::GEOM_IShapesOperations_var shapeOp;
00422       if ( !geomGen->_is_nil() && aStudy )
00423         shapeOp = geomGen->GetIShapesOperations( aStudy->StudyId() );
00424       if ( !shapeOp->_is_nil() )
00425       {
00426         GEOM::ListOfLong_var vertices =
00427           shapeOp->GetAllSubShapesIDs (face, GEOM::VERTEX, /*isSorted=*/false);
00428         ok = ( vertices->length() == 1 );
00429       }
00430     }
00431     // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
00432     if ( ok )
00433       deactivateObjRefParamWdg( customWidgets() );
00434   }
00435   else if ( hypType().startsWith("ImportSource" ))
00436   {
00437     StdMeshersGUI_ObjectReferenceParamWdg* w =
00438       widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 );
00439     ok = ( w->IsObjectSelected() );
00440   }
00441   else if ( hypType() == "LayerDistribution" || hypType() == "LayerDistribution2D" )
00442   {
00443     StdMeshersGUI_LayerDistributionParamWdg* w = 
00444       widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
00445     ok = ( w && w->IsOk() );
00446   }
00447 
00448   return ok;
00449 }
00450 
00451 //================================================================================
00456 //================================================================================
00457 
00458 QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
00459 {
00460   ListOfStdParams params;
00461   bool res = getStdParamFromDlg( params );
00462   if( isCreation() )
00463   {
00464     SMESH::SetName( SMESH::FindSObject( hypothesis() ), params[0].myValue.toString().toLatin1().data() );
00465     params.erase( params.begin() );
00466   }
00467 
00468   QString valueStr = stdParamValues( params );
00469   //QStringList aVariablesList = getVariablesFromDlg();
00470 
00471   if( res && !params.isEmpty() )
00472   {
00473     if( hypType()=="LocalLength" )
00474     {
00475       StdMeshers::StdMeshers_LocalLength_var h =
00476         StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
00477 
00478       h->SetVarParameter( params[0].text(), "SetLength" );
00479       h->SetLength( params[0].myValue.toDouble() );
00480       h->SetVarParameter( params[1].text(), "SetPrecision" );
00481       h->SetPrecision( params[1].myValue.toDouble() );
00482     }
00483     else if( hypType()=="MaxLength" )
00484     {
00485       StdMeshers::StdMeshers_MaxLength_var h =
00486         StdMeshers::StdMeshers_MaxLength::_narrow( hypothesis() );
00487 
00488       h->SetVarParameter( params[0].text(), "SetLength" );
00489       h->SetLength( params[0].myValue.toDouble() );
00490       h->SetUsePreestimatedLength( widget< QCheckBox >( 1 )->isChecked() );
00491       if ( !h->HavePreestimatedLength() && !h->_is_equivalent( initParamsHypothesis() )) {
00492         StdMeshers::StdMeshers_MaxLength_var hInit =
00493           StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
00494         h->SetPreestimatedLength( hInit->GetPreestimatedLength() );
00495       }
00496     }
00497     else if( hypType()=="SegmentLengthAroundVertex" )
00498     {
00499       StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
00500         StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hypothesis() );
00501 
00502       h->SetVarParameter( params[0].text(), "SetLength" );
00503       h->SetLength( params[0].myValue.toDouble() );
00504     }
00505     else if( hypType()=="Arithmetic1D" )
00506     {
00507       StdMeshers::StdMeshers_Arithmetic1D_var h =
00508         StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
00509 
00510       StdMeshersGUI_SubShapeSelectorWdg* w = 
00511         widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
00512 
00513       h->SetVarParameter( params[0].text(), "SetStartLength" );
00514       h->SetStartLength( params[0].myValue.toDouble() );
00515       h->SetVarParameter( params[1].text(), "SetEndLength" );
00516       h->SetEndLength( params[1].myValue.toDouble() );
00517       if (w) {
00518         h->SetReversedEdges( w->GetListOfIDs() );
00519         h->SetObjectEntry( w->GetMainShapeEntry() );
00520       }
00521     }
00522     else if( hypType()=="FixedPoints1D" )
00523     {
00524       StdMeshers::StdMeshers_FixedPoints1D_var h =
00525         StdMeshers::StdMeshers_FixedPoints1D::_narrow( hypothesis() );
00526 
00527       StdMeshersGUI_FixedPointsParamWdg* w1 = 
00528         widget< StdMeshersGUI_FixedPointsParamWdg >( 0 );
00529 
00530       StdMeshersGUI_SubShapeSelectorWdg* w2 = 
00531         widget< StdMeshersGUI_SubShapeSelectorWdg >( 1 );
00532 
00533       if (w1) {
00534         h->SetPoints( w1->GetListOfPoints() );
00535         h->SetNbSegments( w1->GetListOfSegments() );
00536       }
00537       if (w2) {
00538         h->SetReversedEdges( w2->GetListOfIDs() );
00539         h->SetObjectEntry( w2->GetMainShapeEntry() );
00540       }
00541     }
00542     else if( hypType()=="MaxElementArea" )
00543     {
00544       StdMeshers::StdMeshers_MaxElementArea_var h =
00545         StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() );
00546       h->SetVarParameter( params[0].text(), "SetMaxElementArea" );
00547       h->SetMaxElementArea( params[0].myValue.toDouble() );
00548     }
00549     else if( hypType()=="MaxElementVolume" )
00550     {
00551       StdMeshers::StdMeshers_MaxElementVolume_var h =
00552         StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() );
00553 
00554       h->SetVarParameter( params[0].text(), "SetMaxElementVolume" );
00555       h->SetMaxElementVolume( params[0].myValue.toDouble() );
00556     }
00557     else if( hypType()=="StartEndLength" )
00558     {
00559       StdMeshers::StdMeshers_StartEndLength_var h =
00560         StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
00561 
00562       StdMeshersGUI_SubShapeSelectorWdg* w = 
00563         widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
00564 
00565       h->SetVarParameter( params[0].text(), "SetStartLength" );
00566       h->SetStartLength( params[0].myValue.toDouble() );
00567       h->SetVarParameter( params[1].text(), "SetEndLength" );
00568       h->SetEndLength( params[1].myValue.toDouble() );
00569       if (w) {
00570         h->SetReversedEdges( w->GetListOfIDs() );
00571         h->SetObjectEntry( w->GetMainShapeEntry() );
00572       }
00573     }
00574     else if( hypType()=="Deflection1D" )
00575     {
00576       StdMeshers::StdMeshers_Deflection1D_var h =
00577         StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
00578       h->SetVarParameter( params[0].text(), "SetDeflection" );
00579       h->SetDeflection( params[0].myValue.toDouble() );
00580     }
00581     else if( hypType()=="AutomaticLength" )
00582     {
00583       StdMeshers::StdMeshers_AutomaticLength_var h =
00584         StdMeshers::StdMeshers_AutomaticLength::_narrow( hypothesis() );
00585 
00586       h->SetVarParameter( params[0].text(), "SetFineness" );
00587       h->SetFineness( params[0].myValue.toDouble() );
00588     }
00589     else if( hypType()=="NumberOfLayers" )
00590     {
00591       StdMeshers::StdMeshers_NumberOfLayers_var h =
00592         StdMeshers::StdMeshers_NumberOfLayers::_narrow( hypothesis() );
00593 
00594       h->SetVarParameter( params[0].text(), "SetNumberOfLayers" );
00595       h->SetNumberOfLayers( params[0].myValue.toInt() );
00596     }
00597     else if( hypType()=="LayerDistribution" )
00598     {
00599       StdMeshers::StdMeshers_LayerDistribution_var h =
00600         StdMeshers::StdMeshers_LayerDistribution::_narrow( hypothesis() );
00601       StdMeshersGUI_LayerDistributionParamWdg* w = 
00602         widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
00603       
00604       h->SetLayerDistribution( w->GetHypothesis() );
00605     }
00606     else if( hypType()=="NumberOfLayers2D" )
00607     {
00608       StdMeshers::StdMeshers_NumberOfLayers2D_var h =
00609         StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hypothesis() );
00610 
00611       h->SetVarParameter( params[0].text(), "SetNumberOfLayers" );
00612       h->SetNumberOfLayers( params[0].myValue.toInt() );
00613     }
00614     else if( hypType()=="LayerDistribution2D" )
00615     {
00616       StdMeshers::StdMeshers_LayerDistribution2D_var h =
00617         StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hypothesis() );
00618       StdMeshersGUI_LayerDistributionParamWdg* w = 
00619         widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
00620       
00621       h->SetLayerDistribution( w->GetHypothesis() );
00622     }
00623     else if( hypType()=="ProjectionSource1D" )
00624     {
00625       StdMeshers::StdMeshers_ProjectionSource1D_var h =
00626         StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hypothesis() );
00627 
00628       h->SetSourceEdge       ( geomFromWdg ( getWidgetForParam( 0 )));
00629       h->SetSourceMesh       ( meshFromWdg ( getWidgetForParam( 1 )));
00630       h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )),
00631                                geomFromWdg ( getWidgetForParam( 3 )));
00632     }
00633     else if( hypType()=="ProjectionSource2D" )
00634     {
00635       StdMeshers::StdMeshers_ProjectionSource2D_var h =
00636         StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hypothesis() );
00637 
00638       h->SetSourceFace       ( geomFromWdg ( getWidgetForParam( 0 )));
00639       h->SetSourceMesh       ( meshFromWdg ( getWidgetForParam( 1 )));
00640       h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
00641                                geomFromWdg ( getWidgetForParam( 4 )), // src2
00642                                geomFromWdg ( getWidgetForParam( 3 )), // tgt1
00643                                geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
00644     }
00645     else if( hypType()=="ProjectionSource3D" )
00646     {
00647       StdMeshers::StdMeshers_ProjectionSource3D_var h =
00648         StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hypothesis() );
00649 
00650       h->SetSource3DShape    ( geomFromWdg ( getWidgetForParam( 0 )));
00651       h->SetSourceMesh       ( meshFromWdg ( getWidgetForParam( 1 )));
00652       h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1
00653                                geomFromWdg ( getWidgetForParam( 4 )), // src2
00654                                geomFromWdg ( getWidgetForParam( 3 )), // tgt1
00655                                geomFromWdg ( getWidgetForParam( 5 ))); // tgt2
00656     }
00657     else if( hypType()=="ImportSource1D" )
00658     {
00659       StdMeshers::StdMeshers_ImportSource1D_var h =
00660         StdMeshers::StdMeshers_ImportSource1D::_narrow( hypothesis() );
00661 
00662       SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
00663       h->SetSourceEdges( groups.in() );
00664       QCheckBox* toCopyMesh   = widget< QCheckBox >( 1 );
00665       QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
00666       h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
00667     }
00668     else if( hypType()=="ImportSource2D" )
00669     {
00670       StdMeshers::StdMeshers_ImportSource2D_var h =
00671         StdMeshers::StdMeshers_ImportSource2D::_narrow( hypothesis() );
00672 
00673       SMESH::ListOfGroups_var groups = groupsFromWdg( getWidgetForParam( 0 ));
00674       h->SetSourceFaces( groups.in() );
00675       QCheckBox* toCopyMesh   = widget< QCheckBox >( 1 );
00676       QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
00677       h->SetCopySourceMesh( toCopyMesh->isChecked(), toCopyGroups->isChecked());
00678     }
00679     else if( hypType()=="ViscousLayers" )
00680     {
00681       StdMeshers::StdMeshers_ViscousLayers_var h =
00682         StdMeshers::StdMeshers_ViscousLayers::_narrow( hypothesis() );
00683 
00684       h->SetVarParameter( params[0].text(), "SetTotalThickness" );
00685       h->SetTotalThickness( params[0].myValue.toDouble() );
00686       h->SetVarParameter( params[1].text(), "SetNumberLayers" );
00687       h->SetNumberLayers  ( params[1].myValue.toInt() );
00688       h->SetVarParameter( params[2].text(), "SetStretchFactor" );
00689       h->SetStretchFactor ( params[2].myValue.toDouble() );
00690 
00691       if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg = 
00692            widget< StdMeshersGUI_SubShapeSelectorWdg >( 3 ))
00693       {
00694         h->SetIgnoreFaces( idsWg->GetListOfIDs() );
00695       }
00696     }
00697     else if( hypType()=="QuadrangleParams" )
00698     {
00699       StdMeshers::StdMeshers_QuadrangleParams_var h =
00700         StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() );
00701       StdMeshersGUI_SubShapeSelectorWdg* w1 =
00702         widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
00703       StdMeshersGUI_QuadrangleParamWdg* w2 =
00704         widget< StdMeshersGUI_QuadrangleParamWdg >( 1 );
00705       if (w1 && w2) {
00706         if (w1->GetListSize() > 0) {
00707           h->SetTriaVertex(w1->GetListOfIDs()[0]); // getlist must be called once
00708           const char * entry = w1->GetMainShapeEntry();
00709           h->SetObjectEntry(entry);
00710         }
00711         h->SetQuadType(StdMeshers::QuadType(w2->GetType()));
00712       }
00713     }
00714   }
00715   return valueStr;
00716 }
00717 
00718 //================================================================================
00731 //================================================================================
00732 
00733 bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
00734 {
00735   bool res = true;
00736   SMESHGUI_GenericHypothesisCreator::StdParam item;
00737 
00738   p.clear();
00739   customWidgets()->clear();
00740   if( isCreation() )
00741   {
00742     HypothesisData* data = SMESH::GetHypothesisData( hypType() );
00743     item.myName = tr( "SMESH_NAME" );
00744     item.myValue = data ? hypName() : QString();
00745     p.append( item );
00746     customWidgets()->append(0);
00747   }
00748 
00749   SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
00750   SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
00751 
00752   if( hypType()=="LocalLength" )
00753   {
00754     StdMeshers::StdMeshers_LocalLength_var h =
00755       StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
00756 
00757     item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
00758     if(!initVariableName( hyp, item, "SetLength"))
00759       item.myValue = h->GetLength();
00760     p.append( item );     
00761 
00762     item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
00763     if(!initVariableName( hyp, item, "SetPrecision"))
00764       item.myValue = h->GetPrecision(); 
00765     p.append( item );
00766   }
00767   else if( hypType()=="MaxLength" )
00768   {
00769     StdMeshers::StdMeshers_MaxLength_var h =
00770       StdMeshers::StdMeshers_MaxLength::_narrow( hyp );
00771     // try to set a right preestimated length to edited hypothesis
00772     bool noPreestimatedAtEdition = false;
00773     if ( !isCreation() ) {
00774       StdMeshers::StdMeshers_MaxLength_var initHyp =
00775         StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis(true) );
00776       noPreestimatedAtEdition =
00777         ( initHyp->_is_nil() || !initHyp->HavePreestimatedLength() );
00778       if ( !noPreestimatedAtEdition )
00779         h->SetPreestimatedLength( initHyp->GetPreestimatedLength() );
00780     }
00781 
00782     item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
00783     if(!initVariableName( hyp, item, "SetLength"))
00784       item.myValue = h->GetLength();
00785     p.append( item );
00786     customWidgets()->append(0);
00787 
00788     item.myName = tr("SMESH_USE_PREESTIMATED_LENGTH");
00789     p.append( item );
00790     QCheckBox* aQCheckBox = new QCheckBox(dlg());
00791     if ( !noPreestimatedAtEdition && h->HavePreestimatedLength() ) {
00792       aQCheckBox->setChecked( h->GetUsePreestimatedLength() );
00793       connect( aQCheckBox, SIGNAL(  stateChanged(int) ), this, SLOT( onValueChanged() ) );
00794     }
00795     else {
00796       aQCheckBox->setChecked( false );
00797       aQCheckBox->setEnabled( false );
00798     }
00799     customWidgets()->append( aQCheckBox );
00800   }
00801   else if( hypType()=="SegmentLengthAroundVertex" )
00802   {
00803     StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
00804       StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp );
00805 
00806     item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
00807     if(!initVariableName( hyp, item, "SetLength"))
00808       item.myValue = h->GetLength();
00809     
00810     p.append( item );
00811   }
00812   else if( hypType()=="Arithmetic1D" )
00813   {
00814     StdMeshers::StdMeshers_Arithmetic1D_var h =
00815       StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
00816 
00817     item.myName = tr( "SMESH_START_LENGTH_PARAM" );
00818     if(!initVariableName( hyp, item, "SetStartLength" ))
00819       item.myValue = h->GetLength( true );
00820     p.append( item );
00821 
00822     customWidgets()->append (0);
00823 
00824     item.myName = tr( "SMESH_END_LENGTH_PARAM" );
00825     if(!initVariableName( hyp, item, "SetEndLength" ))
00826       item.myValue = h->GetLength( false );
00827     p.append( item );
00828 
00829     customWidgets()->append (0);
00830 
00831     item.myName = tr( "SMESH_REVERSED_EDGES" );
00832     p.append( item );
00833 
00834     StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
00835       new StdMeshersGUI_SubShapeSelectorWdg();
00836     QString aGeomEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
00837     QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
00838     if ( aGeomEntry == "" )
00839       aGeomEntry = h->GetObjectEntry();
00840 
00841     aDirectionWidget->SetGeomShapeEntry( aGeomEntry );
00842     aDirectionWidget->SetMainShapeEntry( aMainEntry );
00843     aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
00844     aDirectionWidget->showPreview( true );
00845     customWidgets()->append ( aDirectionWidget );
00846   }
00847 
00848 
00849   else if( hypType()=="FixedPoints1D" )
00850   {
00851     StdMeshers::StdMeshers_FixedPoints1D_var h =
00852       StdMeshers::StdMeshers_FixedPoints1D::_narrow( hyp );
00853 
00854     item.myName = tr( "SMESH_FIXED_POINTS" );
00855     p.append( item );
00856 
00857     StdMeshersGUI_FixedPointsParamWdg* aFixedPointsWidget =
00858       new StdMeshersGUI_FixedPointsParamWdg();
00859 
00860     if ( !isCreation() ) {
00861       aFixedPointsWidget->SetListOfPoints( h->GetPoints() );
00862       aFixedPointsWidget->SetListOfSegments( h->GetNbSegments() );
00863     }
00864     customWidgets()->append( aFixedPointsWidget );
00865 
00866     item.myName = tr( "SMESH_REVERSED_EDGES" );
00867     p.append( item );
00868 
00869     StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
00870       new StdMeshersGUI_SubShapeSelectorWdg();
00871     QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
00872     QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
00873     if ( anEntry == "" )
00874       anEntry = h->GetObjectEntry();
00875     aDirectionWidget->SetGeomShapeEntry( anEntry );
00876     aDirectionWidget->SetMainShapeEntry( aMainEntry );
00877     aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
00878     aDirectionWidget->showPreview( true );
00879     customWidgets()->append ( aDirectionWidget );
00880   }
00881 
00882 
00883   else if( hypType()=="MaxElementArea" )
00884   {
00885     StdMeshers::StdMeshers_MaxElementArea_var h =
00886       StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp );
00887 
00888     item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
00889     if(!initVariableName( hyp, item, "SetMaxElementArea" ))
00890       item.myValue = h->GetMaxElementArea();
00891     p.append( item );
00892     
00893   }
00894   else if( hypType()=="MaxElementVolume" )
00895   {
00896     StdMeshers::StdMeshers_MaxElementVolume_var h =
00897       StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp );
00898 
00899     item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
00900     if(!initVariableName( hyp, item, "SetMaxElementVolume" ))
00901       item.myValue = h->GetMaxElementVolume();
00902     p.append( item );
00903   }
00904   else if( hypType()=="StartEndLength" )
00905   {
00906     StdMeshers::StdMeshers_StartEndLength_var h =
00907       StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
00908 
00909     item.myName = tr( "SMESH_START_LENGTH_PARAM" );
00910 
00911     if(!initVariableName( hyp, item, "SetStartLength" )) 
00912       item.myValue = h->GetLength( true );
00913     p.append( item );
00914     customWidgets()->append(0);
00915 
00916     item.myName = tr( "SMESH_END_LENGTH_PARAM" );
00917     if(!initVariableName( hyp, item, "SetEndLength" )) 
00918       item.myValue = h->GetLength( false );
00919     p.append( item );
00920     customWidgets()->append(0);
00921 
00922     item.myName = tr( "SMESH_REVERSED_EDGES" );
00923     p.append( item );
00924 
00925     StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
00926       new StdMeshersGUI_SubShapeSelectorWdg();
00927     QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
00928     QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
00929     if ( anEntry == "" )
00930       anEntry = h->GetObjectEntry();
00931     aDirectionWidget->SetGeomShapeEntry( anEntry );
00932     aDirectionWidget->SetMainShapeEntry( aMainEntry );
00933     aDirectionWidget->SetListOfIDs( h->GetReversedEdges() );
00934     aDirectionWidget->showPreview( true );
00935     customWidgets()->append ( aDirectionWidget );
00936   }
00937   else if( hypType()=="Deflection1D" )
00938   {
00939     StdMeshers::StdMeshers_Deflection1D_var h =
00940       StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
00941     
00942     item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
00943     if(!initVariableName( hyp, item, "SetDeflection" )) 
00944       item.myValue = h->GetDeflection();
00945     p.append( item );
00946   }
00947   else if( hypType()=="AutomaticLength" )
00948   {
00949     StdMeshers::StdMeshers_AutomaticLength_var h =
00950       StdMeshers::StdMeshers_AutomaticLength::_narrow( hyp );
00951 
00952     item.myName = tr( "SMESH_FINENESS_PARAM" );
00953     //item.myValue = h->GetFineness();
00954     p.append( item );
00955     SMESHGUI_SpinBox* _autoLengthSpinBox = new SMESHGUI_SpinBox(dlg());
00956     _autoLengthSpinBox->RangeStepAndValidator(0, 1, 0.01, "length_precision");
00957     _autoLengthSpinBox->SetValue(h->GetFineness());
00958     customWidgets()->append( _autoLengthSpinBox);
00959   }
00960   else if( hypType()=="NumberOfLayers" )
00961   {
00962     StdMeshers::StdMeshers_NumberOfLayers_var h =
00963       StdMeshers::StdMeshers_NumberOfLayers::_narrow( hyp );
00964 
00965     item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
00966     if(!initVariableName( hyp, item, "SetNumberOfLayers" ))     
00967       item.myValue = (int) h->GetNumberOfLayers();
00968     p.append( item );
00969   }
00970   else if( hypType()=="LayerDistribution" )
00971   {
00972     StdMeshers::StdMeshers_LayerDistribution_var h =
00973       StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp );
00974     
00975     item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
00976     initVariableName( hyp, item, "SetLayerDistribution" );
00977     customWidgets()->append
00978       ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg()));
00979   }
00980   else if( hypType()=="NumberOfLayers2D" )
00981   {
00982     StdMeshers::StdMeshers_NumberOfLayers2D_var h =
00983       StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hyp );
00984     
00985     item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
00986     if(!initVariableName( hyp, item, "SetNumberOfLayers" ))     
00987       item.myValue = (int) h->GetNumberOfLayers();
00988     p.append( item );
00989   }
00990   else if( hypType()=="LayerDistribution2D" )
00991   {
00992     StdMeshers::StdMeshers_LayerDistribution2D_var h =
00993       StdMeshers::StdMeshers_LayerDistribution2D::_narrow( hyp );
00994 
00995     item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
00996     initVariableName( hyp, item, "SetLayerDistribution" );
00997     customWidgets()->append
00998       ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg()));
00999   }
01000   else if( hypType()=="ProjectionSource1D" )
01001   {
01002     StdMeshers::StdMeshers_ProjectionSource1D_var h =
01003       StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hyp );
01004 
01005     item.myName = tr( "SMESH_SOURCE_EDGE" ); p.append( item );
01006     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 1 ),
01007                                                h->GetSourceEdge()));
01008     item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
01009     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
01010                                                h->GetSourceMesh()));
01011     item.myName = tr( "SMESH_SOURCE_VERTEX" ); p.append( item );
01012     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
01013                                                h->GetSourceVertex()));
01014     item.myName = tr( "SMESH_TARGET_VERTEX" ); p.append( item );
01015     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
01016                                                h->GetTargetVertex()));
01017   }
01018   else if( hypType()=="ProjectionSource2D" )
01019   {
01020     StdMeshers::StdMeshers_ProjectionSource2D_var h =
01021       StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hyp );
01022 
01023     item.myName = tr( "SMESH_SOURCE_FACE" ); p.append( item );
01024     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 2 ),
01025                                                h->GetSourceFace()));
01026     item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
01027     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
01028                                                h->GetSourceMesh()));
01029     item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
01030     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
01031                                                h->GetSourceVertex( 1 )));
01032     item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
01033     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
01034                                                h->GetTargetVertex( 1 )));
01035     item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
01036     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
01037                                                h->GetSourceVertex( 2 )));
01038     item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
01039     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
01040                                                h->GetTargetVertex( 2 )));
01041   }
01042   else if( hypType()=="ProjectionSource3D" )
01043   {
01044     StdMeshers::StdMeshers_ProjectionSource3D_var h =
01045       StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hyp );
01046 
01047     item.myName = tr( "SMESH_SOURCE_3DSHAPE" ); p.append( item );
01048     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 3, TopAbs_FACE, 6, true ),
01049                                                h->GetSource3DShape()));
01050     item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item );
01051     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ),
01052                                                h->GetSourceMesh()));
01053     item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item );
01054     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
01055                                                h->GetSourceVertex( 1 )));
01056     item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item );
01057     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
01058                                                h->GetTargetVertex( 1 )));
01059     item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item );
01060     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
01061                                                h->GetSourceVertex( 2 )));
01062     item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item );
01063     customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ),
01064                                                h->GetTargetVertex( 2 )));
01065   }
01066   else if( hypType()=="ImportSource1D" )
01067   {
01068     StdMeshers::StdMeshers_ImportSource1D_var h =
01069       StdMeshers::StdMeshers_ImportSource1D::_narrow( hyp );
01070 
01071     SMESH::string_array_var groupEntries = h->GetSourceEdges();
01072     CORBA::Boolean toCopyMesh, toCopyGroups;
01073     h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
01074 
01075     item.myName = tr( "SMESH_SOURCE_EDGES" ); p.append( item );
01076     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( GROUP_EDGE ), 
01077                                                 groupEntries));
01078 
01079     item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
01080     QCheckBox* aQCheckBox = new QCheckBox(dlg());
01081     aQCheckBox->setChecked( toCopyMesh );
01082     connect( aQCheckBox, SIGNAL(  stateChanged(int) ), this, SLOT( onValueChanged() ));
01083     customWidgets()->append( aQCheckBox );
01084 
01085     item.myName = tr( "SMESH_TO_COPY_GROUPS" ); p.append( item );
01086     aQCheckBox = new QCheckBox(dlg());
01087     aQCheckBox->setChecked( toCopyGroups );
01088     aQCheckBox->setEnabled( toCopyMesh );
01089     customWidgets()->append( aQCheckBox );
01090   }
01091   else if( hypType()=="ImportSource2D" )
01092   {
01093     StdMeshers::StdMeshers_ImportSource2D_var h =
01094       StdMeshers::StdMeshers_ImportSource2D::_narrow( hyp );
01095 
01096     SMESH::string_array_var groupEntries = h->GetSourceFaces();
01097     CORBA::Boolean toCopyMesh, toCopyGroups;
01098     h->GetCopySourceMesh(toCopyMesh, toCopyGroups);
01099 
01100     item.myName = tr( "SMESH_SOURCE_FACES" ); p.append( item );
01101     customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( GROUP_FACE ), 
01102                                                 groupEntries));
01103 
01104     item.myName = tr( "SMESH_COPY_MESH" ); p.append( item );
01105     QCheckBox* aQCheckBox = new QCheckBox(dlg());
01106     aQCheckBox->setChecked( toCopyMesh );
01107     connect( aQCheckBox, SIGNAL(  stateChanged(int) ), this, SLOT( onValueChanged() ));
01108     customWidgets()->append( aQCheckBox );
01109 
01110     item.myName = tr( "SMESH_COPY_GROUPS" ); p.append( item );
01111     aQCheckBox = new QCheckBox(dlg());
01112     aQCheckBox->setChecked( toCopyGroups );
01113     aQCheckBox->setEnabled( toCopyMesh );
01114     customWidgets()->append( aQCheckBox );
01115   }
01116   else if( hypType()=="ViscousLayers" )
01117   {
01118     StdMeshers::StdMeshers_ViscousLayers_var h =
01119       StdMeshers::StdMeshers_ViscousLayers::_narrow( hyp );
01120 
01121     item.myName = tr( "SMESH_TOTAL_THICKNESS" );
01122     if(!initVariableName( hyp, item, "SetTotalThickness" ))
01123       item.myValue = h->GetTotalThickness();
01124     p.append( item );
01125     customWidgets()->append (0);
01126 
01127     item.myName = tr( "SMESH_NUMBER_OF_LAYERS" );
01128     if(!initVariableName( hyp, item, "SetNumberLayers" ))
01129       item.myValue = h->GetNumberLayers();
01130     p.append( item );
01131     customWidgets()->append (0);
01132 
01133     item.myName = tr( "SMESH_STRETCH_FACTOR" );
01134     if(!initVariableName( hyp, item, "SetStretchFactor" ))
01135       item.myValue = h->GetStretchFactor();
01136     p.append( item );
01137     customWidgets()->append (0);
01138 
01139     QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
01140     if ( !aMainEntry.isEmpty() )
01141     {
01142       item.myName = tr( "SMESH_FACES_WO_LAYERS" );
01143       p.append( item );
01144 
01145       StdMeshersGUI_SubShapeSelectorWdg* idsWg =
01146         new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_FACE);
01147 
01148       idsWg->SetGeomShapeEntry( aMainEntry );
01149       idsWg->SetMainShapeEntry( aMainEntry );
01150       idsWg->SetListOfIDs( h->GetIgnoreFaces() );
01151       idsWg->showPreview( true );
01152       customWidgets()->append ( idsWg );
01153     }
01154   }
01155   else if (hypType() == "QuadrangleParams")
01156   {
01157     StdMeshers::StdMeshers_QuadrangleParams_var h =
01158       StdMeshers::StdMeshers_QuadrangleParams::_narrow(hyp);
01159 
01160     item.myName = tr("SMESH_BASE_VERTEX");
01161     p.append(item);
01162 
01163     StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
01164       new StdMeshersGUI_SubShapeSelectorWdg(0, TopAbs_VERTEX);
01165     aDirectionWidget->SetMaxSize(1);
01166     QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
01167     QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
01168     if (anEntry == "")
01169       anEntry = h->GetObjectEntry();
01170     aDirectionWidget->SetGeomShapeEntry(anEntry);
01171     aDirectionWidget->SetMainShapeEntry(aMainEntry);
01172     if (!isCreation()) {
01173       SMESH::long_array_var aVec = new SMESH::long_array;
01174       int vertID = h->GetTriaVertex();
01175       if (vertID > 0) {
01176         aVec->length(1);
01177         aVec[0] = vertID;
01178         aDirectionWidget->SetListOfIDs(aVec);
01179       }
01180     }
01181     aDirectionWidget->showPreview(true);
01182 
01183     item.myName = tr("SMESH_QUAD_TYPE");
01184     p.append(item);
01185 
01186     StdMeshersGUI_QuadrangleParamWdg* aTypeWidget =
01187       new StdMeshersGUI_QuadrangleParamWdg();
01188     if (!isCreation()) {
01189       aTypeWidget->SetType(int(h->GetQuadType()));
01190     }
01191 
01192     customWidgets()->append(aDirectionWidget);
01193     customWidgets()->append(aTypeWidget);
01194   }
01195   else
01196     res = false;
01197   return res;
01198 }
01199 
01200 //================================================================================
01206 //================================================================================
01207 
01208 void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) const
01209 {
01210   SMESHGUI_SpinBox* sb = w->inherits( "SMESHGUI_SpinBox" ) ? ( SMESHGUI_SpinBox* )w : 0;
01211   if ( sb )
01212   {
01213     if( hypType()=="LocalLength" )
01214     {
01215       if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PARAM"))
01216         sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
01217       else if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PRECISION"))
01218         sb->RangeStepAndValidator( 0.0, 1.0, 0.05, "len_tol_precision" );
01219     }
01220     else if( hypType()=="Arithmetic1D" )
01221     {
01222       sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
01223     }
01224     else if( hypType()=="MaxLength" )
01225     {
01226       sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
01227       sb->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
01228     }
01229     else if( hypType()=="MaxElementArea" )
01230     {
01231       sb->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 1.0, "area_precision" );
01232     }
01233     else if( hypType()=="MaxElementVolume" )
01234     {
01235       sb->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 1.0, "vol_precision" );
01236     }
01237     else if( hypType()=="StartEndLength" )
01238     {
01239       sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
01240     }
01241     else if( hypType()=="Deflection1D" )
01242     {
01243       sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" );
01244     }
01245     else if( hypType()=="ViscousLayers" )
01246     {
01247       if (sb->objectName() == tr("SMESH_STRETCH_FACTOR"))
01248         sb->RangeStepAndValidator( 1.0, VALUE_MAX, 0.1, "parametric_precision" );
01249       else
01250         sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
01251     }
01252     else // default validator for possible ancestors
01253     {
01254       sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" );
01255     }
01256   }
01257 //   else if ( QtxIntSpinBox* ib = w->inherits( "QtxIntSpinBox" ) ? ( QtxIntSpinBox* )w : 0)
01258 //   {
01259 //     if( hypType()=="ViscousLayers" )
01260 //     {
01261 //     }
01262 //   }
01263 }
01264 
01265 //================================================================================
01270 //================================================================================
01271 
01272 QString StdMeshersGUI_StdHypothesisCreator::caption() const
01273 {
01274   return tr( QString( "SMESH_%1_TITLE" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
01275 }
01276 
01277 //================================================================================
01282 //================================================================================
01283 
01284 QPixmap StdMeshersGUI_StdHypothesisCreator::icon() const
01285 {
01286   QString hypIconName = tr( QString( "ICON_DLG_%1" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
01287   return SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName );
01288 }
01289 
01290 //================================================================================
01295 //================================================================================
01296 
01297 QString StdMeshersGUI_StdHypothesisCreator::type() const
01298 {
01299   return tr( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeName( hypType() ) ).toLatin1().data() );
01300 }
01301 
01302 //================================================================================
01309 //================================================================================
01310 
01311 QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) const
01312 {
01313   static QMap<QString,QString>  types;
01314   if( types.isEmpty() )
01315   {
01316     types.insert( "LocalLength", "LOCAL_LENGTH" );
01317     types.insert( "NumberOfSegments", "NB_SEGMENTS" );
01318     types.insert( "MaxElementArea", "MAX_ELEMENT_AREA" );
01319     types.insert( "MaxElementVolume", "MAX_ELEMENT_VOLUME" );
01320     types.insert( "StartEndLength", "START_END_LENGTH" );
01321     types.insert( "Deflection1D", "DEFLECTION1D" );
01322     types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
01323     types.insert( "FixedPoints1D", "FIXED_POINTS_1D" );
01324     types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" );
01325     types.insert( "ProjectionSource1D", "PROJECTION_SOURCE_1D" );
01326     types.insert( "ProjectionSource2D", "PROJECTION_SOURCE_2D" );
01327     types.insert( "ProjectionSource3D", "PROJECTION_SOURCE_3D" );
01328     types.insert( "ImportSource1D", "IMPORT_SOURCE_1D" );
01329     types.insert( "ImportSource2D", "IMPORT_SOURCE_2D" );
01330     types.insert( "NumberOfLayers", "NUMBER_OF_LAYERS" );
01331     types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" );
01332     types.insert( "NumberOfLayers2D", "NUMBER_OF_LAYERS_2D" );
01333     types.insert( "LayerDistribution2D", "LAYER_DISTRIBUTION" );
01334     types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" );
01335     types.insert( "MaxLength", "MAX_LENGTH" );
01336     types.insert( "ViscousLayers", "VISCOUS_LAYERS" );
01337     types.insert( "QuadrangleParams", "QUADRANGLE_PARAMS" );
01338     types.insert( "CartesianParameters3D", "CARTESIAN_PARAMS" );
01339   }
01340 
01341   QString res;
01342   if( types.contains( t ) )
01343     res = types[ t ];
01344 
01345   return res;
01346 }
01347 
01348 
01349 //=======================================================================
01350 //function : getCustomWidget
01351 //purpose  : is called from buildStdFrame()
01352 //=======================================================================
01353 
01354 QWidget* StdMeshersGUI_StdHypothesisCreator::getCustomWidget( const StdParam & param,
01355                                                               QWidget*         parent,
01356                                                               const int        index) const
01357 {
01358   QWidget* w = 0;
01359   if ( index < customWidgets()->count() ) {
01360     w = customWidgets()->at( index );
01361     if ( w ) {
01362       w->setParent( parent );
01363       w->move( QPoint( 0, 0 ) );
01364     }
01365   }
01366   return w;
01367 }
01368 
01369 //================================================================================
01378 //================================================================================
01379 
01380 bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & param,
01381                                                                    QWidget*   widget) const
01382 {
01383   if ( hypType()=="AutomaticLength" ) {
01384     SMESHGUI_SpinBox* w = dynamic_cast<SMESHGUI_SpinBox*>( widget );
01385     if ( w ) {
01386       param.myValue = w->GetValue();
01387       return true;
01388     }
01389   }
01390   if ( hypType() == "MaxLength" ) {
01391     param.myValue = "";
01392     return true;
01393   }
01394   if ( widget->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
01395   {
01396     // show only 1st reference value
01397     if ( true /*widget == getWidgetForParam( 0 )*/) {
01398       const StdMeshersGUI_ObjectReferenceParamWdg * w =
01399         static_cast<const StdMeshersGUI_ObjectReferenceParamWdg*>( widget );
01400       param.myValue = w->GetValue();
01401     }
01402     return true;
01403   }
01404   if ( widget->inherits( "StdMeshersGUI_LayerDistributionParamWdg" ))
01405   {
01406     const StdMeshersGUI_LayerDistributionParamWdg * w =
01407       static_cast<const StdMeshersGUI_LayerDistributionParamWdg*>( widget );
01408     param.myValue = w->GetValue();
01409     return true;
01410   }
01411   if ( widget->inherits( "StdMeshersGUI_SubShapeSelectorWdg" ))
01412   {
01413     const StdMeshersGUI_SubShapeSelectorWdg * w =
01414       static_cast<const StdMeshersGUI_SubShapeSelectorWdg*>( widget );
01415     param.myValue = w->GetValue();
01416     return true;
01417   }
01418   if ( widget->inherits( "StdMeshersGUI_QuadrangleParamWdg" ))
01419   {
01420     //const StdMeshersGUI_QuadrangleParamWdg * w =
01421     //  static_cast<const StdMeshersGUI_QuadrangleParamWdg*>( widget );
01422     param.myValue = "QuadType";
01423     return true;
01424   }
01425   if ( widget->inherits( "StdMeshersGUI_FixedPointsParamWdg" ))
01426   {
01427     const StdMeshersGUI_FixedPointsParamWdg * w =
01428       static_cast<const StdMeshersGUI_FixedPointsParamWdg*>( widget );
01429     param.myValue = w->GetValue();
01430     return true;
01431   }
01432   if ( widget->inherits( "QCheckBox" ))
01433   {
01434     //const QCheckBox * w = static_cast<const QCheckBox*>( widget );
01435     //param.myValue = w->isChecked();
01436     return true;
01437   }
01438   return false;
01439 }
01440 
01441 //================================================================================
01445 //================================================================================
01446 
01447 void StdMeshersGUI_StdHypothesisCreator::onReject()
01448 {
01449   if ( hypType().startsWith("ProjectionSource" ) ||
01450        hypType().startsWith("ImportSource" ))
01451   {
01452     // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg
01453     deactivateObjRefParamWdg( customWidgets() );
01454   }
01455 }
01456 
01457 //================================================================================
01461 //================================================================================
01462 
01463 void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget)
01464 {
01465   if ( hypType() == "MaxLength" && paramWidget == getWidgetForParam(1) )
01466   {
01467     getWidgetForParam(0)->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
01468     if ( !getWidgetForParam(0)->isEnabled() ) {
01469       StdMeshers::StdMeshers_MaxLength_var h =
01470         StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
01471       widget< QtxDoubleSpinBox >( 0 )->setValue( h->GetPreestimatedLength() );
01472     }
01473   }
01474   else if ( hypType().startsWith("ImportSource") && paramWidget == getWidgetForParam(1) )
01475   {
01476     QCheckBox* toCopyMesh   = (QCheckBox*) paramWidget;
01477     QCheckBox* toCopyGroups = widget< QCheckBox >( 2 );
01478     if ( !toCopyMesh->isChecked() )
01479     {
01480       toCopyGroups->setChecked( false );
01481       toCopyGroups->setEnabled( false );
01482     }
01483     else
01484     {
01485       toCopyGroups->setEnabled( true );
01486     }
01487   }
01488 }
01489 
01490 //================================================================================
01494 //================================================================================
01495 
01496 bool StdMeshersGUI_StdHypothesisCreator::initVariableName(SMESH::SMESH_Hypothesis_var theHyp, 
01497                                                           StdParam &                  theParams, 
01498                                                           const char*                 theMethod) const
01499 {
01500   QString aVaribaleName = getVariableName( theMethod );
01501   theParams.isVariable = !aVaribaleName.isEmpty();
01502   if (theParams.isVariable)
01503     theParams.myValue = aVaribaleName;
01504 
01505   return theParams.isVariable;
01506 }