Salome HOME
SMESH note book
[modules/smesh.git] / src / StdMeshersGUI / StdMeshersGUI_StdHypothesisCreator.cxx
index 2daf8bd257ac0093cf0e9c596c1dcd22cf7dc693..5fe2b8a552bae0473c9637f790fbdfd536b46f5d 100644 (file)
@@ -32,6 +32,7 @@
 #include <SMESH_NumberFilter.hxx>
 #include <StdMeshersGUI_ObjectReferenceParamWdg.h>
 #include <StdMeshersGUI_LayerDistributionParamWdg.h>
+#include <SALOMEDSClient_Study.hxx>
 
 // SALOME GUI includes
 #include <SUIT_ResourceMgr.h>
@@ -168,6 +169,9 @@ void StdMeshersGUI_StdHypothesisCreator::retrieveParams() const
     if ( widgetToActivate )
       widgetToActivate->activateSelection();
   }
+
+  if ( dlg() )
+    dlg()->setMinimumSize( dlg()->minimumSizeHint().width(), dlg()->minimumSizeHint().height() );
 }
 
 namespace {
@@ -335,8 +339,11 @@ namespace {
  */
 //================================================================================
 
-bool StdMeshersGUI_StdHypothesisCreator::checkParams() const
+bool StdMeshersGUI_StdHypothesisCreator::checkParams( QString& msg ) const
 {
+  if( !SMESHGUI_GenericHypothesisCreator::checkParams( msg ) )
+    return false;
+
   // check if object reference parameter is set, as it has no default value
   bool ok = true;
   if ( hypType().startsWith("ProjectionSource" ))
@@ -394,6 +401,7 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
   }
 
   QString valueStr = stdParamValues( params );
+  QStringList aVariablesList = getVariablesFromDlg();
 
   if( res && !params.isEmpty() )
   {
@@ -403,7 +411,9 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
        StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
 
       h->SetLength( params[0].myValue.toDouble() );
+      h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
       h->SetPrecision( params[1].myValue.toDouble() );
+      h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
     }
     else if( hypType()=="SegmentLengthAroundVertex" )
     {
@@ -411,6 +421,7 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
        StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hypothesis() );
 
       h->SetLength( params[0].myValue.toDouble() );
+      h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
     }
     else if( hypType()=="Arithmetic1D" )
     {
@@ -418,7 +429,9 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
        StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
 
       h->SetLength( params[0].myValue.toDouble(), true );
+      h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
       h->SetLength( params[1].myValue.toDouble(), false );
+      h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
     }
     else if( hypType()=="MaxElementArea" )
     {
@@ -440,13 +453,15 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
        StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
 
       h->SetLength( params[0].myValue.toDouble(), true );
+      h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
       h->SetLength( params[1].myValue.toDouble(), false );
+      h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
     }
     else if( hypType()=="Deflection1D" )
     {
       StdMeshers::StdMeshers_Deflection1D_var h =
        StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
-
+      h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
       h->SetDeflection( params[0].myValue.toDouble() );
     }
     else if( hypType()=="AutomaticLength" )
@@ -469,8 +484,12 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
        StdMeshers::StdMeshers_LayerDistribution::_narrow( hypothesis() );
       StdMeshersGUI_LayerDistributionParamWdg* w = 
         widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
-
+      
       h->SetLayerDistribution( w->GetHypothesis() );
+      /*      h->SetParameters(w->GetHypothesis()->GetParameters());
+      if(QString(w->GetHypothesis()->GetName()) == "LocalLength")
+        h->SetParameters(w->GetHypothesis()->GetParameters());
+      */
     }
     else if( hypType()=="ProjectionSource1D" )
     {
@@ -540,28 +559,49 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
     p.append( item );
     customWidgets()->append(0);
   }
-
+  
   SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
+  SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
+  QString aVaribaleName; 
 
   if( hypType()=="LocalLength" )
   {
     StdMeshers::StdMeshers_LocalLength_var h =
       StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
-
+    
     item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
-    item.myValue = h->GetLength();
+
+    aVaribaleName = (aParameters->length() > 0) ? QString(aParameters[0].in()) : QString("");
+    item.isVariable = !aVaribaleName.isEmpty();
+    if(item.isVariable) 
+      item.myValue = aVaribaleName;
+    else
+      item.myValue = h->GetLength();
     p.append( item );
+     
     item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
-    item.myValue = h->GetPrecision();
+    aVaribaleName = (aParameters->length() > 1) ? QString(aParameters[1].in()) : QString("");
+    item.isVariable = !aVaribaleName.isEmpty();
+    if(item.isVariable)
+      item.myValue = aVaribaleName;
+    else
+      item.myValue = h->GetPrecision();
     p.append( item );
+    
   }
   else if( hypType()=="SegmentLengthAroundVertex" )
   {
     StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
       StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp );
-
     item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
-    item.myValue = h->GetLength();
+
+    aVaribaleName = (aParameters->length() > 0) ? QString(aParameters[0].in()) : QString("");    
+    item.isVariable = !aVaribaleName.isEmpty();
+
+    if(item.isVariable)
+      item.myValue = aVaribaleName;
+    else
+      item.myValue = h->GetLength();
     p.append( item );
   }
   else if( hypType()=="Arithmetic1D" )
@@ -569,11 +609,25 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
     StdMeshers::StdMeshers_Arithmetic1D_var h =
       StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
 
+    aVaribaleName = (aParameters->length() > 0) ? QString(aParameters[0].in()) : QString("");
+    
+    item.isVariable = !aVaribaleName.isEmpty();
+
     item.myName = tr( "SMESH_START_LENGTH_PARAM" );
-    item.myValue = h->GetLength( true );
+    if(item.isVariable)
+      item.myValue = aVaribaleName;
+    else
+      item.myValue = h->GetLength( true );
     p.append( item );
+
+    aVaribaleName = (aParameters->length() > 1) ? QString(aParameters[1].in()) : QString("");
+
     item.myName = tr( "SMESH_END_LENGTH_PARAM" );
-    item.myValue = h->GetLength( false );
+
+    if(item.isVariable)
+      item.myValue = aVaribaleName;
+    else
+      item.myValue = h->GetLength( false );
     p.append( item );
   }
   else if( hypType()=="MaxElementArea" )
@@ -600,19 +654,37 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
       StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
 
     item.myName = tr( "SMESH_START_LENGTH_PARAM" );
-    item.myValue = h->GetLength( true );
+
+    aVaribaleName = (aParameters->length() > 0) ? QString(aParameters[0].in()) : QString("");
+    item.isVariable = !aVaribaleName.isEmpty();
+    if(item.isVariable) 
+      item.myValue = aVaribaleName;
+    else
+      item.myValue = h->GetLength( true );
     p.append( item );
+
     item.myName = tr( "SMESH_END_LENGTH_PARAM" );
+    aVaribaleName = (aParameters->length() > 1) ? QString(aParameters[1].in()) : QString("");
+    item.isVariable = !aVaribaleName.isEmpty();
+    if(item.isVariable) 
+      item.myValue = aVaribaleName;
+    else
     item.myValue = h->GetLength( false );
+    
     p.append( item );
   }
   else if( hypType()=="Deflection1D" )
   {
     StdMeshers::StdMeshers_Deflection1D_var h =
       StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
-
+    
     item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
-    item.myValue = h->GetDeflection();
+    aVaribaleName = (aParameters->length() > 0) ? QString(aParameters[0].in()) : QString("");
+    item.isVariable = !aVaribaleName.isEmpty();
+    if(item.isVariable) 
+      item.myValue = aVaribaleName;
+    else
+      item.myValue = h->GetDeflection();
     p.append( item );
   }
   else if( hypType()=="AutomaticLength" )
@@ -636,11 +708,20 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
     p.append( item );
   }
   else if( hypType()=="LayerDistribution" )
-  {
-    StdMeshers::StdMeshers_LayerDistribution_var h =
+    {
+      StdMeshers::StdMeshers_LayerDistribution_var h =
       StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp );
 
     item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
+    
+    //Set into not published hypo last variables
+    /*    QStringList aLastVarsList;
+    for(int i = 0;i<aParameters->length();i++) 
+      aLastVarsList.append(QString(aParameters[i].in()));
+
+    if(!aLastVarsList.isEmpty())
+      h->GetLayerDistribution()->SetParameters(SMESHGUI::JoinObjectParameters(aLastVarsList));
+    */    
     customWidgets()->append
       ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg()));
   }
@@ -731,7 +812,7 @@ void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int)
     if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PARAM"))
       sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 );
     else if (sb->objectName() == tr("SMESH_LOCAL_LENGTH_PRECISION"))
-      sb->RangeStepAndValidator( 0.0, 1.0, 0.05, 6 );
+      sb->RangeStepAndValidator( 0.0, 1.0, 0.05, 7 );
   }
   else if( hypType()=="Arithmetic1D" && sb )
   {
@@ -909,3 +990,36 @@ void StdMeshersGUI_StdHypothesisCreator::onReject()
     deactivateObjRefParamWdg( customWidgets() );
   }
 }
+
+//================================================================================
+/*!
+ * \brief
+ */
+//================================================================================
+/*QVariant StdMeshersGUI_StdHypothesisCreator::
+parseParameter(const QStringList& theList, int theNbParam) const
+{
+  _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+  QVariant aResult;
+  if(theList.size() > theNbParam) {
+    QString aParameter =  theList[theNbParam];
+    if(QString::compare(QString(""),aParameter) !=0 ) {
+      if(aStudy->IsVariable(aParameter.toLatin1().constData())) {
+        aResult=aParameter;
+      }
+      else {
+        bool aResult = false;
+        int anIResult = aParameter.toInt(&aResult);
+        if(aResult)
+          aResult = anIResult;
+        else {
+          double aDResult = aParameter.toDouble(&aResult);
+          if(aResult)
+            aResult = aDResult;
+        } 
+      }
+    }
+  }
+  return aResult;
+}
+*/