Version: 6.3.1

src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx

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