Salome HOME
management of closing windows
[modules/filter.git] / src / FILTERGUI / SelectParams.cxx
index f959ef4f43a2efd36b9c5ffb07c0bc3e1ae6bf23..60ddc5468aef8c62725e406c4ed1535ff07a4b8f 100644 (file)
 #include <qpushbutton.h>
 #include <qfiledialog.h>
 
-SelectParams::SelectParams(SelectField *sel)
-  : _size(1024),
-  _myExpr( 0 ),
-  _myFunc( 0 ),
-  _myFieldB( 0 ),
-  _myLinear( 0 ),
-  _myHisto( 0 ),
-  _myNbThresh( 0 ),
-  _myCutNeg( 0 ),
-  _myOneThresh( 0 ),
-  _myTwoThresh( 0 ),
-  _myArea( 0 ),
-  _myVThresh( 0 ),
-  _myOutFile( 0 ),
-  _myOFB( 0 ),
-  _myProc( 0 ),
-  _myFScale( 0 ),
-  _myGroupLayout( 0 ),
-  _myGroupLayout2( 0 ),
-  _myPlot( 0 ),
-  _GroupC1( 0 ),
-  _GroupC2( 0 ),
-  _lay( 0 ),
-  _fr( 0 )
+SelectParams::SelectParams(FilterGUI* theModule,SelectField *sel,
+                          const char* name,
+                          bool modal, WFlags fl)
+  : QDialog(FILTER::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),  _size(1024),_sel(sel)
 {
-  _x = new double[_size];
-  _y = new double[_size];
   if(sel){
+
+    // read reference field values
+    ::MEDMEM::MED *med = sel->getMED();
+
+    // Get reference field and time step
     _inputFile = sel->getFile();
     _inputMesh = sel->getMesh();
     _inputField = sel->getField();
     _inputTS = sel->getTimeStep();
+
+    // if no reference field selection: throw exception
     if( _inputMesh.isNull() || _inputField.isNull() ){
       MESSAGE("Select an input Field in MED file before filtering!!");
+      delete sel;
       throw SALOME_Exception("Salome Exception");
     }
+
+    deque<DT_IT_> myIteration = med->getFieldIteration (_inputField);
+    MEDMEM::FIELD_* field = med->getField(_inputField,myIteration[_inputTS].dt,myIteration[_inputTS].it);
+    if (dynamic_cast<MEDMEM::FIELD<double>*>(field)){
+      _myDField = new MEDMEM::FIELD<double>(MEDMEM::MED_DRIVER,_inputFile,_inputField,myIteration[_inputTS].dt,myIteration[_inputTS].it);
+      _myIField = NULL;
+    }
+    else{
+      _myIField = new MEDMEM::FIELD<int>(MEDMEM::MED_DRIVER,_inputFile,_inputField,myIteration[_inputTS].dt,myIteration[_inputTS].it);
+      _myDField = NULL;
+    }
+    buildFrame();
   }
+  // if no reference field selection: throw exception
   else{
     MESSAGE("Select an input Field in MED file before filtering!!");
     throw SALOME_Exception("Salome Exception");
   }
 
+  // Allocate histogram arrays
+  _x = new double[_size];
+  _y = new double[_size];
+
 }
 
 SelectParams::~SelectParams()
 {
-  cout << "destructor called" << endl;
-//   delete _x;
-//   delete _y;
-//   delete _myExpr;
-//   delete _myFunc;
-//   delete _myFieldB;
-//   delete _myLinear;
-//   delete _myHisto;
-//   delete _myNbThresh;
-//   delete _myCutNeg;
-//   delete _myOneThresh;
-//   delete _myTwoThresh;
-//   delete _myArea;
-//   delete _myVThresh;
-//   delete _myOutFile;
-//   delete _myOFB;
-//   delete _myProc;
-//   delete _myFScale;
-//   delete _myGroupLayout;
-//   delete _myGroupLayout2;
-//   delete _myPlot;
-//   delete _GroupC1;
-//   delete _GroupC2;
-//   delete _lay;
-//   delete _fr;
+  cout << "SelectParams: destructor called" << endl;
+  delete _x;
+  delete _y;
+  if(_myIField){
+    delete _myIField->getSupport();
+    delete _myIField;
+  }
+  if(_myDField){
+    delete _myDField->getSupport();
+    delete _myDField;
+  }
+  delete _sel;
 }
 
-QFrame* SelectParams::buildFrame()
+void SelectParams::buildFrame()
 {
-  QFrame* _fr = new QFrame( 0, "myframe" );
-  QGridLayout* _lay = new QGridLayout( _fr, 1, 2 );
+  // build widgets for select filtering parameters
+  QGridLayout* _lay = new QGridLayout( this, 1, 2 );
 
-  QGroupBox* _GroupC1 = new QGroupBox( _fr, "GroupC1" );
+  QGroupBox* _GroupC1 = new QGroupBox( this, "GroupC1" );
   _lay->addWidget( _GroupC1,0,0 );
 
-  _GroupC1->setTitle( tr( "Filtering parameters"  ) );
+  _GroupC1->setTitle( tr( "FILTER_PARAMS"  ) );
   _GroupC1->setColumnLayout(0, Qt::Vertical );
   _GroupC1->layout()->setSpacing( 0 );
   _GroupC1->layout()->setMargin( 0 );
@@ -132,112 +122,125 @@ QFrame* SelectParams::buildFrame()
 
   int row = 0;
 
-  QString qs1("Input File : ");
+  QString qs1(tr("FILTER_INPUT_FILE"));
   qs1.append(basename(_inputFile));
   _myGroupLayout->addWidget( new QLabel( qs1, _GroupC1 ), row, 0 );
   row++;
 
-  QString qs2("Input Mesh : ");
+  QString qs2(tr("FILTER_INPUT_MESH"));
   qs2.append(_inputMesh);
   _myGroupLayout->addWidget( new QLabel( qs2, _GroupC1 ), row, 0 );
   row++;
 
-  QString qs3("Input Field : ");
+  QString qs3(tr("FILTER_INPUT_FIELD"));
   qs3.append(_inputField);
   _myGroupLayout->addWidget( new QLabel( qs3, _GroupC1 ), row, 0 );
   row++;
 
+  QString qs4(tr("FILTER_INPUT_TS"));
   char strTS[128];
-  sprintf(strTS,"Input Time Step : %d\0",_inputTS);
-  QString qs4(strTS);
+  sprintf(strTS,"%d\0",_inputTS);
+  qs4.append(strTS);
   _myGroupLayout->addWidget( new QLabel( qs4, _GroupC1 ), row, 0 );
   row++;
 
   // 0)  field function to calculate histogram (radiogroup)
-  _myFunc = new QButtonGroup( "Select function on field", _GroupC1 );
+  _myFunc = new QButtonGroup( tr("FILTER_SELECT_FUNC"), _GroupC1 );
   _myFunc->setExclusive( true );
   _myFunc->setColumnLayout( 0, Qt::Horizontal );
 
-  _myFieldB = new QRadioButton( "Field", _myFunc );
+  _myFieldB = new QRadioButton( tr("FILTER_FIELD"), _myFunc );
   _myFieldB->setChecked(true);
 
   QGridLayout* convLay = new QGridLayout( _myFunc->layout() );
   convLay->addWidget( _myFieldB, 0, 0 );
-  convLay->addWidget( _myCutNeg = new QRadioButton( "Gradient", _myFunc ), 0, 1 );
+  convLay->addWidget( _myCutNeg = new QRadioButton( tr("FILTER_GRADIENT"), _myFunc ), 0, 1 );
   _myGroupLayout->addWidget( _myFunc, row, 0 );
   row++;
 
-  // 1)  scale of histogram (radiogroup)
-  _myFScale = new QButtonGroup( "Type of display", _GroupC1 );
+  // 01)  histogram size (line edit)
+  _myHSize = new QButtonGroup( tr(""), _GroupC1 );
+  _myHSize->setExclusive( true );
+  _myHSize->setColumnLayout( 0, Qt::Horizontal );
+  QGridLayout* shLay = new QGridLayout( _myHSize->layout() );
+  shLay->addWidget( _myLSH = new QLabel( tr("FILTER_SIZE_HISTO") , _myHSize ), 0, 0 );
+  shLay->addWidget( _myLESH = new QLineEdit( "1024", _myHSize ), 0, 1 );
+  _myGroupLayout->addWidget( _myHSize, row, 0 );
+  row++;
+
+  // 1)  display histogram button (pushbutton)
+  _myHisto = new QPushButton( "", _GroupC1 );
+  _myHisto->setText(tr("FILTER_DISPLAY_HISTO"));
+  _myHisto->setAutoDefault(TRUE);
+  _myHisto->setDefault(TRUE);
+  _myGroupLayout->addWidget( _myHisto, row, 0 );
+  row++;
+
+  // 2)  scale of histogram (radiogroup)
+  _myFScale = new QButtonGroup( tr("FILTER_TYPE_DISPLAY"), _GroupC1 );
   _myFScale->setExclusive( true );
   _myFScale->setColumnLayout( 0, Qt::Horizontal );
 
-  _myLinear = new QRadioButton( "Linear", _myFScale );
+  _myLinear = new QRadioButton( tr("FILTER_LINEAR"), _myFScale );
   _myLinear->setChecked(true);
+  _myLog = new QRadioButton( tr("FILTER_LOG"), _myFScale );
+  _myFScale->setDisabled(true);
 
   QGridLayout* scaleLay = new QGridLayout( _myFScale->layout() );
   scaleLay->addWidget( _myLinear, 0, 0 );
-  scaleLay->addWidget( new QRadioButton( "Logarithm", _myFScale ), 0, 1 );
+  scaleLay->addWidget( _myLog, 0, 1 );
   _myGroupLayout->addWidget( _myFScale, row, 0 );
   row++;
 
-  // 2)  display histogram button (pushbutton)
-  _myHisto = new QPushButton( "Display Histogram", _GroupC1 );
-  _myHisto->setText("Display Histogram");
-  _myHisto->setAutoDefault(TRUE);
-  _myHisto->setDefault(TRUE);
-  _myGroupLayout->addWidget( _myHisto, row, 0 );
-  row++;
-
   // 3)  number of thresholds (radiogroup)
-  _myNbThresh = new QButtonGroup( "Select number of thresholds", _GroupC1 );
+  _myNbThresh = new QButtonGroup( tr("FILTER_SEL_THRESH"), _GroupC1 );
   _myNbThresh->setExclusive( true );
   _myNbThresh->setColumnLayout( 0, Qt::Horizontal );
   QGridLayout* nbtLay = new QGridLayout( _myNbThresh->layout() );
-  nbtLay->addWidget( _myOneThresh = new QRadioButton( "One threshold", _myNbThresh ), 0, 0 );
-  nbtLay->addWidget( _myTwoThresh = new QRadioButton( "Two thresholds", _myNbThresh ), 0, 1 );
+  nbtLay->addWidget( _myOneThresh = new QRadioButton( tr("FILTER_ONE_THRESH"), _myNbThresh ), 0, 0 );
+  nbtLay->addWidget( _myTwoThresh = new QRadioButton( tr("FILTER_TWO_THRESH"), _myNbThresh ), 0, 1 );
   _myGroupLayout->addWidget( _myNbThresh, row, 0 );
 
-//   _myOneThresh->setChecked(true);
-  _myNbThresh->hide();
+  _myOneThresh->setChecked(true);
+  _myNbThresh->setDisabled(true);
   row++;
 
   // 4)  reference area on thresholds (radiogroup)
-  _myArea = new QButtonGroup( "Select reference area", _GroupC1 );
+  _myArea = new QButtonGroup( tr("FILTER_REF_AREA"), _GroupC1 );
   _myArea->setExclusive( true );
   _myArea->setColumnLayout( 0, Qt::Horizontal );
   QGridLayout* areaLay = new QGridLayout( _myArea->layout() );
-  areaLay->addWidget( _myInt = new QRadioButton( "Interior", _myArea ), 0, 0 );
-  areaLay->addWidget( _myExt = new QRadioButton( "Exterior", _myArea ), 0, 1 );
+  areaLay->addWidget( _myInt = new QRadioButton( tr("FILTER_BOTTOM"), _myArea ), 0, 0 );
+  areaLay->addWidget( _myExt = new QRadioButton( tr("FILTER_UP"), _myArea ), 0, 1 );
   _myGroupLayout->addWidget( _myArea, row, 0 );
 
   _myExt->setChecked(true);
-  _myArea->hide();
+  _myArea->setDisabled(true);
   row++;
 
   // 5)  threshold values (line edit)
-  _myVThresh = new QButtonGroup( "Threshold values", _GroupC1 );
+  _myVThresh = new QButtonGroup( tr("FILTER_TRESH_VAL"), _GroupC1 );
   _myVThresh->setExclusive( true );
   _myVThresh->setColumnLayout( 0, Qt::Horizontal );
   QGridLayout* ftLay = new QGridLayout( _myVThresh->layout() );
-  ftLay->addWidget( _myLFT = new QLabel( "threshold value   " , _myVThresh ), 0, 0 );
+  ftLay->addWidget( _myLFT = new QLabel( tr("FILTER_VAL_TRESH") , _myVThresh ), 0, 0 );
   ftLay->addWidget( _myLEFT = new QLineEdit( "", _myVThresh ), 0, 1 );
-  ftLay->addWidget( _myLST = new QLabel( "2d threshold value" , _myVThresh ), 1, 0 );
+  ftLay->addWidget( _myLST = new QLabel( tr("FILTER_VAL_2_TRESH") , _myVThresh ), 1, 0 );
   ftLay->addWidget( _myLEST = new QLineEdit( "", _myVThresh ), 1, 1 );
   _myGroupLayout->addWidget( _myVThresh, row, 0 );
 
-  _myVThresh->hide();
+  _myVThresh->setDisabled(true);
   _myLST->hide();
   _myLEST->hide();
   row++;
 
   // 6)  output file name (line edit)
-  _myOutFile = new QButtonGroup( "Output file name", _GroupC1 );
+  _myOutFile = new QButtonGroup( tr("FILTER_OUT_FILE"), _GroupC1 );
   _myOutFile->setExclusive( true );
   _myOutFile->setColumnLayout( 0, Qt::Horizontal );
 
-  _myOFB = new QPushButton( "Browse", _myOutFile );
-  _myOFB->setText("Browse");
+  _myOFB = new QPushButton( "", _myOutFile );
+  _myOFB->setText(tr("FILTER_BROWSE"));
   _myOFB->setAutoDefault(TRUE);
 
   QGridLayout* outLay = new QGridLayout( _myOutFile->layout() );
@@ -245,26 +248,46 @@ QFrame* SelectParams::buildFrame()
   outLay->addWidget( _myOFN = new QLineEdit( "", _myOutFile ), 0, 1 );
   _myGroupLayout->addWidget( _myOutFile, row, 0 );
 
-  _myOutFile->hide();
+  _myOutFile->setDisabled(true);
   row++;
 
-  // 8)  process button (pushbutton)
-  _myProc = new QPushButton( "Process", _GroupC1 );
-  _myProc->setText("Process");
+  // 8)  buttons Process, Close and Help 
+  _GroupButtons = new QGroupBox(_GroupC1, "GroupButtons");
+  _GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, _GroupButtons->sizePolicy().hasHeightForWidth()));
+  _GroupButtons->setTitle(tr("" ));
+  _GroupButtons->setColumnLayout(0, Qt::Vertical);
+  _GroupButtons->layout()->setSpacing(0);
+  _GroupButtons->layout()->setMargin(0);
+  _GroupButtonsLayout = new QGridLayout(_GroupButtons->layout());
+  _GroupButtonsLayout->setAlignment(Qt::AlignTop);
+  _GroupButtonsLayout->setSpacing(6);
+  _GroupButtonsLayout->setMargin(11);
+  _myProc = new QPushButton(_GroupButtons, "buttonProcess");
+  _myProc->setText(tr("FILTER_PROCESS"));
   _myProc->setAutoDefault(TRUE);
-  _myGroupLayout->addWidget( _myProc, row, 0 );
-  _myProc->hide();
+  _GroupButtonsLayout->addWidget(_myProc, 0, 0);
+  _buttonHelp = new QPushButton(_GroupButtons, "buttonHelp");
+  _buttonHelp->setText(tr("FILTER_BUT_HELP" ));
+  _buttonHelp->setAutoDefault(TRUE);
+  _GroupButtonsLayout->addWidget(_buttonHelp, 0, 2);
+  _buttonCancel = new QPushButton(_GroupButtons, "buttonCancel");
+  _buttonCancel->setText(tr("FILTER_BUT_CANCEL" ));
+  _buttonCancel->setAutoDefault(TRUE);
+  _GroupButtonsLayout->addWidget(_buttonCancel, 0, 1);
+  _myGroupLayout->addWidget( _GroupButtons, row, 0 );
+  _GroupButtons->setDisabled(true);
   row++;
 
-  _GroupC2 = new QGroupBox( _fr, "GroupC2" );
+  _GroupC2 = new QGroupBox( this, "GroupC2" );
   _lay->addWidget( _GroupC2,0,1 );
 
-  _GroupC2->setTitle( tr( "Histogram"  ) );
+  _GroupC2->setTitle( tr( "FILTER_HISTO" ) );
   _GroupC2->setColumnLayout(0, Qt::Vertical );
   _GroupC2->layout()->setSpacing( 0 );
   _GroupC2->layout()->setMargin( 0 );
   _myGroupLayout2 = new QGridLayout( _GroupC2->layout() );
 
+  // 9)  histogram curve
   _myPlot = new QwtPlot(_GroupC2);
   _myHistoCurve = _myPlot->insertCurve( QString() );
   _myPlot->setCurvePen( _myHistoCurve, QPen( Qt::red, 1 ) );
@@ -272,90 +295,156 @@ QFrame* SelectParams::buildFrame()
 
   _myGroupLayout2->addWidget( _myPlot, 0, 0 );
 
-  // 9)  reduction rate (label)
-  _myGroupLayout2->addWidget( _myLRR = new QLabel( "reduction rate = 0.23", _GroupC2 ), 1, 0 );
+  // 10)  reduction rate (label)
+  QString qs5(tr("FILTER_RED_RATE"));
+  qs5.append(" = 0.5");
+  _myLRR = new QLabel( qs5, _GroupC2 );
+  _myGroupLayout2->addWidget( _myLRR, 1, 0 );
 
   _GroupC2->hide();
-  _myLRR->hide();
 
   _myHistoFThresh = _myPlot->insertCurve( QString() );
   _myPlot->setCurvePen( _myHistoFThresh, QPen( Qt::black, 1 ) );
   _myHistoSThresh = _myPlot->insertCurve( QString() );
   _myPlot->setCurvePen( _myHistoSThresh, QPen( Qt::black, 1 ) );
 
-  connect( _myHisto, SIGNAL(clicked()), this, SLOT(displayHisto()));
+  connect( _myLESH, SIGNAL(returnPressed()), this, SLOT(enterSHisto()));
+  connect( _myHisto, SIGNAL(clicked()), this, SLOT(updateHisto()));
+  connect( _myLinear, SIGNAL(clicked()), this, SLOT(scaleSelected()));
+  connect( _myLog, SIGNAL(clicked()), this, SLOT(scaleSelected()));
   connect( _myOneThresh, SIGNAL(clicked()), this, SLOT(nbThreshSelected()));
   connect( _myTwoThresh, SIGNAL(clicked()), this, SLOT(nbThreshSelected()));
   connect( _myInt, SIGNAL(clicked()), this, SLOT(areaSelected()));
   connect( _myExt, SIGNAL(clicked()), this, SLOT(areaSelected()));
-  connect( _myLEFT, SIGNAL(returnPressed()), this, SLOT(displayFThresh()));
-  connect( _myLEST, SIGNAL(returnPressed()), this, SLOT(displaySThresh()));
+  connect( _myLEFT, SIGNAL(returnPressed()), this, SLOT(enterFThresh()));
+  connect( _myLEST, SIGNAL(returnPressed()), this, SLOT(enterSThresh()));
   connect( _myPlot, SIGNAL(plotMouseMoved(const QMouseEvent &)), this, SLOT(moveThresh(const QMouseEvent &)));
   connect( _myOFB, SIGNAL(clicked()), this, SLOT(getOutFileName()));
   connect( _myProc, SIGNAL(clicked()), this, SLOT(process()));
+  connect(_buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
+  connect(_buttonHelp, SIGNAL(clicked()),   this, SLOT(ClickOnHelp()));
+
+  _GroupC2->setMinimumSize( 500, 500 );
+  _GroupC2->setMaximumSize( 500, 500 );
+  setMinimumSize( 750, 500 );
+  setMaximumSize( 750, 500 );
+//   this->show();  /* displays Dialog */
+}
 
-  calcHisto();
+void SelectParams::enterSHisto()
+{
+  // Deallocate old histogram arrays
+  delete _x;
+  delete _y;
+
+  // get new histogram size
+  _size = atoi(_myLESH->text());
+
+  // Allocate new histogram arrays
+  _x = new double[_size];
+  _y = new double[_size];
+}
 
-  return _fr;
+void SelectParams::scaleSelected()
+{
+  // draw linear or log Y scale depend on user
+  if( _myLinear->isChecked() ){
+    _ymin = 0.0;
+    _myPlot->setAxisOptions(_myPlot->curveYAxis( _myHistoCurve ), QwtAutoScale::None );
+  }
+  else{
+    // set min to 0.1 for log scale
+    _ymin = 0.1;
+    _myPlot->setAxisOptions(_myPlot->curveYAxis( _myHistoCurve ), QwtAutoScale::Logarithmic );
+  }
+  _myPlot->setAxisScale( _myPlot->curveYAxis( _myHistoCurve ), _ymin, _ymax );
+  _myPlot->replot();
 }
 
 void SelectParams::nbThreshSelected()
 {
   if( _myOneThresh->isChecked() ){
-    _myInt->setText("bottom");
-    _myExt->setText("up");
-    _myLFT->setText("threshold value   ");
+    // if one threshold choice between bottom and up for reference area
+    _myInt->setText(tr("FILTER_BOTTOM"));
+    _myExt->setText(tr("FILTER_UP"));
+    _myLFT->setText(tr("FILTER_VAL_TRESH"));
     _myLST->hide();
     _myLEST->hide();
+    // draw first threshold
     displayFThresh();
+    // erase second threshold
     clearSThresh();
   }
   else{
-    _myInt->setText("interior");
-    _myExt->setText("exterior");
-    _myLFT->setText("1st threshold value");
+    // if two thresholds choice between interior and exterior fir reference area
+    _myInt->setText(tr("FILTER_INT"));
+    _myExt->setText(tr("FILTER_EXT"));
+    _myLFT->setText(tr("FILTER_VAL_1_TRESH"));
     if(_myLST->isHidden())
       _myLST->show();
     if(_myLEST->isHidden())
       _myLEST->show();
+    // draw two thresholds
     displayFThresh();
     displaySThresh();
   }
   calcRateRed();
-  if(_myArea->isHidden())
-    _myArea->show();
-  if(_myVThresh->isHidden())
-    _myVThresh->show();
-  if(_myLRR->isHidden())
-    _myLRR->show();
-  if(_myOutFile->isHidden())
-    _myOutFile->show();
-  if(_myProc->isHidden())
-    _myProc->show();
 }
 
 void SelectParams::areaSelected()
 {
+  // calculate reduction rate after thresholds selection
+  calcRateRed();
+}
+
+void SelectParams::enterFThresh()
+{
+  displayFThresh();
+  calcRateRed();
+}
+
+void SelectParams::enterSThresh()
+{
+  displaySThresh();
   calcRateRed();
 }
 
 void SelectParams::calcHisto()
 {
   char strth[128];
-  _xmin = -50.0;
-  _xmax = 50.0;
-  _ymax = 100.0;
-  _ymin = _ymax;
+  vector<int> myh;
+
+  // calculate histogram values
+  if (_myDField){
+    _myDField->getMinMax(_xmin,_xmax);
+    myh = _myDField->getHistogram(_size);
+  }
+  else{
+    int xmin, xmax;
+    _myIField->getMinMax(xmin,xmax);
+    _xmin = (double)xmin;
+    _xmax = (double)xmax;
+    myh = _myIField->getHistogram(_size);
+  }                    
+  if( _myLinear->isChecked() )
+    _ymin = 0.0;
+  else
+    _ymin = 0.1;
+  _ymax = 0.0;
 
   for(int i=0;i<_size;i++){
+    // calculate absisses for histogram values
     _x[i]=_xmin+(i*(_xmax-_xmin))/_size;
-    _y[i]=80.*exp(-_x[i]*_x[i]/400.);
-    if( (_y[i] < _ymin) && (_y[i] != 0.0) )
-      _ymin = _y[i];
+    // set zero to 0.01 because pb of zeros in log display with qwt
+    if(myh[i])
+      _y[i]=(double)myh[i];
+    else
+      _y[i]=0.01;
+    if( _y[i] > _ymax )
+      _ymax = _y[i];
   }
-  _myPlot->setAxisScale( _myPlot->curveXAxis( _myHistoCurve ), _xmin, _xmax );
-  _myPlot->setAxisScale( _myPlot->curveYAxis( _myHistoCurve ), _ymin, _ymax );
-  _myPlot->setCurveData( _myHistoCurve, _x, _y, _size );
+
+  // init thresholds values
   _fthresh = (_xmin + _xmax)/2.0;
   _sthresh = (_xmin + 3.*_xmax)/4.0;
   sprintf(strth,"%g",_fthresh);
@@ -366,23 +455,50 @@ void SelectParams::calcHisto()
 
 void SelectParams::displayHisto()
 {
-  _qmap = _myPlot->canvasMap(_myPlot->curveXAxis( _myHistoCurve ));
-  _qmap.setDblRange(_xmin,_xmax);
+  // associate values to curve
+  _myPlot->setCurveData( _myHistoCurve, _x, _y, _size );
+  // give extrema values for each axis
+  _myPlot->setAxisScale( _myPlot->curveXAxis( _myHistoCurve ), _xmin, _xmax );
+  _myPlot->setAxisScale( _myPlot->curveYAxis( _myHistoCurve ), _ymin, _ymax );
   if( _myLinear->isChecked() )
     _myPlot->setAxisOptions(_myPlot->curveYAxis( _myHistoCurve ), QwtAutoScale::None );
   else
     _myPlot->setAxisOptions(_myPlot->curveYAxis( _myHistoCurve ), QwtAutoScale::Logarithmic );
+  // associate mapping to plot to move thresholds on display
+  _qmap = _myPlot->canvasMap(_myPlot->curveXAxis( _myHistoCurve ));
+  _qmap.setDblRange(_xmin,_xmax);
   _myPlot->replot();
-  if(_GroupC2->isHidden())
+}
+
+void SelectParams::enableWidgets()
+{
+  if(_GroupC2->isHidden()){
+    _myFScale->setEnabled(true);
+    _myNbThresh->setEnabled(true);
+    _myArea->setEnabled(true);
+    _myVThresh->setEnabled(true);
+    _myOutFile->setEnabled(true);
+    _GroupButtons->setEnabled(true);
     _GroupC2->show();
-  if(_myNbThresh->isHidden())
-    _myNbThresh->show();
+  }
+}
+
+void SelectParams::updateHisto()
+{
+  calcHisto();
+  displayHisto();
+  displayFThresh();
+  if( _myTwoThresh->isChecked() )
+    displaySThresh();
+  calcRateRed();
+  enableWidgets();
 }
 
 void SelectParams::displayFThresh()
 {
   _fthresh = atof(_myLEFT->text());
 
+  // draw first threshold curve
   for(int i=0;i<100;i++){
     _xft[i]=_fthresh;
     _yft[i]=((i-1)*_ymax)/100.0;
@@ -395,6 +511,7 @@ void SelectParams::displaySThresh()
 {
   _sthresh = atof(_myLEST->text());
 
+  // draw second threshold curve
   for(int i=0;i<100;i++){
     _xst[i]=_sthresh;
     _yst[i]=((i-1)*_ymax)/100.0;
@@ -407,6 +524,7 @@ void SelectParams::clearSThresh()
 {
   _sthresh = atof(_myLEST->text());
 
+  // erase second threshold curve
   for(int i=0;i<100;i++){
     _xst[i]=_sthresh;
     _yst[i]=0.0;
@@ -418,8 +536,11 @@ void SelectParams::clearSThresh()
 void SelectParams::moveThresh(const QMouseEvent &e)
 {
   char strth[128];
+
+  // move threshold curve with mouse
   int delta = abs(e.x()-_qmap.transform(_fthresh));
   if( delta < 5 ){
+    // moving first threshold curve
     sprintf(strth,"%g",_qmap.invTransform(e.x()));
     _myLEFT->setText(QString(strth));
     displayFThresh();
@@ -427,6 +548,7 @@ void SelectParams::moveThresh(const QMouseEvent &e)
   else if( _myTwoThresh->isChecked() ){
     delta = abs(e.x()-_qmap.transform(_sthresh));
     if( delta < 5 ){
+      // moving second threshold curve
       sprintf(strth,"%g",_qmap.invTransform(e.x()));
       _myLEST->setText(QString(strth));
       displaySThresh();
@@ -437,7 +559,8 @@ void SelectParams::moveThresh(const QMouseEvent &e)
 
 void SelectParams::getOutFileName()
 {
-  QString file = QFileDialog::getSaveFileName("/home",
+  // get output MED file name
+  QString file = QFileDialog::getSaveFileName("",
                                              "*.med",
                                              _myOFB,
                                              "save file dialog",
@@ -457,15 +580,24 @@ void SelectParams::process()
 {
   string command;
 
+  // have to call ensight driver MED to generate input for filtoo
+
   MESSAGE("Input MED File : "<<_inputFile);
   MESSAGE("Input Mesh : "<<_inputMesh);
   MESSAGE("Input Field : "<<_inputField);
   MESSAGE("Input Time Step : "<<_inputTS);
   MESSAGE("Output file name: " << _myOFN->text() );
+
+  // send filtoo command
   command = "cd /export/home/secher/filtoo/example;filtoo -f s -o sf > /tmp/filter.log";
   MESSAGE(command);
   system(command.c_str());
-//   delete this;
+
+  // have to call ensight driver MED to generate output MED file from filtoo output
+
+  // close the window
+  accept();
+
 }
 
 void SelectParams::calcRateRed()
@@ -473,8 +605,8 @@ void SelectParams::calcRateRed()
   int i1, i2, i;
   int atot=0, asel=0, atot1;
   double rateRed=0.0;
-  char strth[128];
 
+  // calculate reduction rate depend on reference area defined by threshold values
   i1 = (int)((double)_size * ( _fthresh - _xmin ) / ( _xmax - _xmin ));
   if( _myOneThresh->isChecked() ){
     for(i=0;i<i1;i++)
@@ -504,9 +636,23 @@ void SelectParams::calcRateRed()
       asel = atot - asel;
   }
   rateRed = (double)asel / (double) atot;
-  sprintf(strth,"reduction rate = %4.2g",rateRed);
-  _myLRR->setText( strth );
 
+  // display reduction rate value
+  QString qs(tr("FILTER_RED_RATE"));
+  char str[128];
+  sprintf(str," = %4.2g",rateRed);
+  qs.append(str);
+  _myLRR->setText( qs );
 
 }
 
+void SelectParams::ClickOnCancel()
+{
+  MESSAGE("click on Cancel");
+  reject();
+}
+
+void SelectParams::ClickOnHelp()
+{
+  MESSAGE("click on Help");
+}