Salome HOME
Fix bug 12796: Warning missed for the bad file 'test18.med'
[modules/smesh.git] / src / StdMeshersGUI / StdMeshersGUI_NbSegmentsCreator.cxx
index a071169aea30d1d02833fec9ac8f5d6970cb6fcd..02bb83a356cdcb578b31c91ef7f67121d99f86db 100644 (file)
@@ -1,3 +1,22 @@
+// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 #include "StdMeshersGUI_NbSegmentsCreator.h"
 #include "StdMeshersGUI_DistrTable.h"
@@ -12,6 +31,7 @@
 
 #include <QtxIntSpinBox.h>
 #include <QtxComboBox.h>
+#include <QtxDblValidator.h>
 #include <SMESHGUI_SpinBox.h>
 
 #include <qlabel.h>
@@ -142,7 +162,7 @@ QFrame* StdMeshersGUI_NbSegmentsCreator::buildFrame()
   myConv->setColumnLayout( 0, Qt::Vertical );
   QGridLayout* convLay = new QGridLayout( myConv->layout() );
   convLay->addWidget( new QRadioButton( tr( "SMESH_EXP_MODE" ), myConv ), 0, 0 );
-  convLay->addWidget( new QRadioButton( tr( "SMESH_CUT_NEG_MODE" ), myConv ), 1, 0 );
+  convLay->addWidget( myCutNeg = new QRadioButton( tr( "SMESH_CUT_NEG_MODE" ), myConv ), 1, 0 );
   myGroupLayout->addWidget( myConv, row, 1 );
   row++;
 
@@ -172,21 +192,64 @@ void StdMeshersGUI_NbSegmentsCreator::retrieveParams() const
   myDistr->setCurrentItem( data.myDistrType );
   myScale->setValue( data.myScale );
   myConv->setButton( data.myConv );
+  myTable->table()->funcValidator()->setBottom(myConv->id( myConv->selected() )==0 ? -1E20 : 0);
   myTable->table()->setData( data.myTable );
   myExpr->setText( data.myExpr );
 }
 
-void StdMeshersGUI_NbSegmentsCreator::storeParams() const
+QString StdMeshersGUI_NbSegmentsCreator::storeParams() const
 {
   NbSegmentsHypothesisData data;
   readParamsFromWidgets( data );
   storeParamsToHypo( data );
+
+  QString valStr = QString::number( data.myNbSeg ) += "; ";
+
+  enum DistrType
+  {
+    Regular, //!< equidistant distribution
+    Scale,   //!< scale distribution
+    TabFunc, //!< distribution with density function presented by table
+    ExprFunc //!< distribution with density function presented by expression
+  };
+  bool hasConv = false;
+  switch ( data.myDistrType ) {
+  case Regular :
+    valStr += tr("SMESH_DISTR_REGULAR");
+    break;
+  case Scale   :
+    valStr += tr("SMESH_NB_SEGMENTS_SCALE_PARAM") + " = " + QString::number( data.myScale );
+    break;
+  case TabFunc : {
+    //valStr += tr("SMESH_TAB_FUNC");
+    bool param = true;
+    for( int i=0; i < data.myTable.length(); i++, param = !param ) {
+      if ( param )
+        valStr += "[";
+      valStr += QString::number( data.myTable[ i ]);
+      valStr += ( param ? "," : "]" );
+    }
+    hasConv = true;
+    break;
+  }
+  case ExprFunc:
+    valStr += data.myExpr;
+    hasConv = true;
+    break;
+  }
+  if ( hasConv )
+    if ( data.myConv )
+      valStr += "; " + tr("SMESH_CUT_NEG_MODE");
+    else
+      valStr += "; " + tr("SMESH_EXP_MODE");
+
+  return valStr;
 }
 
 bool StdMeshersGUI_NbSegmentsCreator::readParamsFromHypo( NbSegmentsHypothesisData& h_data ) const
 {
   StdMeshers::StdMeshers_NumberOfSegments_var h =
-    StdMeshers::StdMeshers_NumberOfSegments::_narrow( hypothesis() );
+    StdMeshers::StdMeshers_NumberOfSegments::_narrow( initParamsHypothesis() );
 
   HypothesisData* data = SMESH::GetHypothesisData( hypType() );
   h_data.myName = isCreation() && data ? data->Label : "";
@@ -270,6 +333,19 @@ void StdMeshersGUI_NbSegmentsCreator::onValueChanged()
 {
   int distr = myDistr->currentItem();
 
+/*  if( distr==2 ) //table func
+    myCutNeg->setText( tr( "SMESH_NO_CONV" ) );
+  else if( distr==3 )
+    myCutNeg->setText( tr( "SMESH_CUT_NEG_MODE" ) );*/
+
+  if( distr==2 && sender()==myConv ) //table func
+  {
+    myTable->table()->funcValidator()->setBottom( myConv->id( myConv->selected() )==0 ? -1E20 : 0 );
+    SMESH::double_array arr;
+    myTable->table()->data( arr );
+    myTable->table()->setData( arr ); //update data in table
+  }
+
   myScale->setShown( distr==1 );
   myLScale->setShown( distr==1 );