Salome HOME
add Close and Help buttons in dialog windows
[modules/filter.git] / src / FILTERGUI / SelectParams.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 //
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
8 //
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20
21 #include <stdlib.h>
22 #include <math.h>
23 #include "SelectParams.h"
24 #include "utilities.h"
25
26 #include <SUIT_FileDlg.h>
27
28 #include "Utils_SALOME_Exception.hxx"
29 #include <SalomeApp_Tools.h>
30
31 #include <qlabel.h>
32 #include <qgroupbox.h>
33 #include <qframe.h>
34 #include <qlayout.h>
35 #include <qlineedit.h>
36 #include <qbuttongroup.h>
37 #include <qradiobutton.h>
38 #include <qpushbutton.h>
39 #include <qfiledialog.h>
40
41 SelectParams::SelectParams(FilterGUI* theModule,SelectField *sel,
42                            const char* name,
43                            bool modal, WFlags fl)
44   : QDialog(FILTER::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),  _size(128)
45 {
46   // Allocate histogram arrays
47   _x = new double[_size];
48   _y = new double[_size];
49
50   if(sel){
51     // read reference field values
52     ::MEDMEM::MED *med = sel->getMED();
53
54     // Get reference field and time step
55     _inputFile = sel->getFile();
56     _inputMesh = sel->getMesh();
57     _inputField = sel->getField();
58     _inputTS = sel->getTimeStep();
59     // if no reference field selection: throw exception
60     if( _inputMesh.isNull() || _inputField.isNull() ){
61       MESSAGE("Select an input Field in MED file before filtering!!");
62       throw SALOME_Exception("Salome Exception");
63     }
64
65     deque<DT_IT_> myIteration = med->getFieldIteration (_inputField);
66     MEDMEM::FIELD_* field = med->getField(_inputField,myIteration[_inputTS].dt,myIteration[_inputTS].it);
67     if (dynamic_cast<MEDMEM::FIELD<double>*>(field)){
68       _myDField = new MEDMEM::FIELD<double>(MEDMEM::MED_DRIVER,_inputFile,_inputField,myIteration[_inputTS].dt,myIteration[_inputTS].it);
69       _myIField = NULL;
70     }
71     else{
72       _myIField = new MEDMEM::FIELD<int>(MEDMEM::MED_DRIVER,_inputFile,_inputField,myIteration[_inputTS].dt,myIteration[_inputTS].it);
73       _myDField = NULL;
74     }
75     buildFrame();
76   }
77   // if no reference field selection: throw exception
78   else{
79     MESSAGE("Select an input Field in MED file before filtering!!");
80     throw SALOME_Exception("Salome Exception");
81   }
82
83 }
84
85 SelectParams::~SelectParams()
86 {
87   cout << "SelectParams: destructor called" << endl;
88   delete _x;
89   delete _y;
90   if(_myIField){
91     delete _myIField->getSupport();
92     delete _myIField;
93   }
94   if(_myDField){
95     delete _myDField->getSupport();
96     delete _myDField;
97   }
98 }
99
100 void SelectParams::buildFrame()
101 {
102   // build widgets for select filtering parameters
103   QGridLayout* _lay = new QGridLayout( this, 1, 2 );
104
105   QGroupBox* _GroupC1 = new QGroupBox( this, "GroupC1" );
106   _lay->addWidget( _GroupC1,0,0 );
107
108   _GroupC1->setTitle( tr( "FILTER_PARAMS"  ) );
109   _GroupC1->setColumnLayout(0, Qt::Vertical );
110   _GroupC1->layout()->setSpacing( 0 );
111   _GroupC1->layout()->setMargin( 0 );
112   _myGroupLayout = new QGridLayout( _GroupC1->layout() );
113   _myGroupLayout->setAlignment( Qt::AlignTop );
114   _myGroupLayout->setSpacing( 6 );
115   _myGroupLayout->setMargin( 11 );
116   _myGroupLayout->setColStretch( 0, 0 );
117   _myGroupLayout->setColStretch( 1, 1 );
118
119   int row = 0;
120
121   QString qs1(tr("FILTER_INPUT_FILE"));
122   qs1.append(basename(_inputFile));
123   _myGroupLayout->addWidget( new QLabel( qs1, _GroupC1 ), row, 0 );
124   row++;
125
126   QString qs2(tr("FILTER_INPUT_MESH"));
127   qs2.append(_inputMesh);
128   _myGroupLayout->addWidget( new QLabel( qs2, _GroupC1 ), row, 0 );
129   row++;
130
131   QString qs3(tr("FILTER_INPUT_FIELD"));
132   qs3.append(_inputField);
133   _myGroupLayout->addWidget( new QLabel( qs3, _GroupC1 ), row, 0 );
134   row++;
135
136   QString qs4(tr("FILTER_INPUT_TS"));
137   char strTS[128];
138   sprintf(strTS,"%d\0",_inputTS);
139   qs4.append(strTS);
140   _myGroupLayout->addWidget( new QLabel( qs4, _GroupC1 ), row, 0 );
141   row++;
142
143   // 0)  field function to calculate histogram (radiogroup)
144   _myFunc = new QButtonGroup( tr("FILTER_SELECT_FUNC"), _GroupC1 );
145   _myFunc->setExclusive( true );
146   _myFunc->setColumnLayout( 0, Qt::Horizontal );
147
148   _myFieldB = new QRadioButton( tr("FILTER_FIELD"), _myFunc );
149   _myFieldB->setChecked(true);
150
151   QGridLayout* convLay = new QGridLayout( _myFunc->layout() );
152   convLay->addWidget( _myFieldB, 0, 0 );
153   convLay->addWidget( _myCutNeg = new QRadioButton( tr("FILTER_GRADIENT"), _myFunc ), 0, 1 );
154   _myGroupLayout->addWidget( _myFunc, row, 0 );
155   row++;
156
157   // 1)  display histogram button (pushbutton)
158   _myHisto = new QPushButton( "", _GroupC1 );
159   _myHisto->setText(tr("FILTER_DISPLAY_HISTO"));
160   _myHisto->setAutoDefault(TRUE);
161   _myHisto->setDefault(TRUE);
162   _myGroupLayout->addWidget( _myHisto, row, 0 );
163   row++;
164
165   // 2)  scale of histogram (radiogroup)
166   _myFScale = new QButtonGroup( tr("FILTER_TYPE_DISPLAY"), _GroupC1 );
167   _myFScale->setExclusive( true );
168   _myFScale->setColumnLayout( 0, Qt::Horizontal );
169
170   _myLinear = new QRadioButton( tr("FILTER_LINEAR"), _myFScale );
171   _myLinear->setChecked(true);
172   _myLog = new QRadioButton( tr("FILTER_LOG"), _myFScale );
173   _myFScale->setDisabled(true);
174
175   QGridLayout* scaleLay = new QGridLayout( _myFScale->layout() );
176   scaleLay->addWidget( _myLinear, 0, 0 );
177   scaleLay->addWidget( _myLog, 0, 1 );
178   _myGroupLayout->addWidget( _myFScale, row, 0 );
179   row++;
180
181   // 3)  number of thresholds (radiogroup)
182   _myNbThresh = new QButtonGroup( tr("FILTER_SEL_THRESH"), _GroupC1 );
183   _myNbThresh->setExclusive( true );
184   _myNbThresh->setColumnLayout( 0, Qt::Horizontal );
185   QGridLayout* nbtLay = new QGridLayout( _myNbThresh->layout() );
186   nbtLay->addWidget( _myOneThresh = new QRadioButton( tr("FILTER_ONE_THRESH"), _myNbThresh ), 0, 0 );
187   nbtLay->addWidget( _myTwoThresh = new QRadioButton( tr("FILTER_TWO_THRESH"), _myNbThresh ), 0, 1 );
188   _myGroupLayout->addWidget( _myNbThresh, row, 0 );
189
190   _myOneThresh->setChecked(true);
191   _myNbThresh->setDisabled(true);
192   row++;
193
194   // 4)  reference area on thresholds (radiogroup)
195   _myArea = new QButtonGroup( tr("FILTER_REF_AREA"), _GroupC1 );
196   _myArea->setExclusive( true );
197   _myArea->setColumnLayout( 0, Qt::Horizontal );
198   QGridLayout* areaLay = new QGridLayout( _myArea->layout() );
199   areaLay->addWidget( _myInt = new QRadioButton( tr("FILTER_BOTTOM"), _myArea ), 0, 0 );
200   areaLay->addWidget( _myExt = new QRadioButton( tr("FILTER_UP"), _myArea ), 0, 1 );
201   _myGroupLayout->addWidget( _myArea, row, 0 );
202
203   _myExt->setChecked(true);
204   _myArea->setDisabled(true);
205   row++;
206
207   // 5)  threshold values (line edit)
208   _myVThresh = new QButtonGroup( tr("FILTER_TRESH_VAL"), _GroupC1 );
209   _myVThresh->setExclusive( true );
210   _myVThresh->setColumnLayout( 0, Qt::Horizontal );
211   QGridLayout* ftLay = new QGridLayout( _myVThresh->layout() );
212   ftLay->addWidget( _myLFT = new QLabel( tr("FILTER_VAL_TRESH") , _myVThresh ), 0, 0 );
213   ftLay->addWidget( _myLEFT = new QLineEdit( "", _myVThresh ), 0, 1 );
214   ftLay->addWidget( _myLST = new QLabel( tr("FILTER_VAL_2_TRESH") , _myVThresh ), 1, 0 );
215   ftLay->addWidget( _myLEST = new QLineEdit( "", _myVThresh ), 1, 1 );
216   _myGroupLayout->addWidget( _myVThresh, row, 0 );
217
218   _myVThresh->setDisabled(true);
219   _myLST->hide();
220   _myLEST->hide();
221   row++;
222
223   // 6)  output file name (line edit)
224   _myOutFile = new QButtonGroup( tr("FILTER_OUT_FILE"), _GroupC1 );
225   _myOutFile->setExclusive( true );
226   _myOutFile->setColumnLayout( 0, Qt::Horizontal );
227
228   _myOFB = new QPushButton( "", _myOutFile );
229   _myOFB->setText(tr("FILTER_BROWSE"));
230   _myOFB->setAutoDefault(TRUE);
231
232   QGridLayout* outLay = new QGridLayout( _myOutFile->layout() );
233   outLay->addWidget( _myOFB, 0, 0 );
234   outLay->addWidget( _myOFN = new QLineEdit( "", _myOutFile ), 0, 1 );
235   _myGroupLayout->addWidget( _myOutFile, row, 0 );
236
237   _myOutFile->setDisabled(true);
238   row++;
239
240   // 8)  buttons Process, Close and Help 
241   _GroupButtons = new QGroupBox(_GroupC1, "GroupButtons");
242   _GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, _GroupButtons->sizePolicy().hasHeightForWidth()));
243   _GroupButtons->setTitle(tr("" ));
244   _GroupButtons->setColumnLayout(0, Qt::Vertical);
245   _GroupButtons->layout()->setSpacing(0);
246   _GroupButtons->layout()->setMargin(0);
247   _GroupButtonsLayout = new QGridLayout(_GroupButtons->layout());
248   _GroupButtonsLayout->setAlignment(Qt::AlignTop);
249   _GroupButtonsLayout->setSpacing(6);
250   _GroupButtonsLayout->setMargin(11);
251   _myProc = new QPushButton(_GroupButtons, "buttonProcess");
252   _myProc->setText(tr("FILTER_PROCESS"));
253   _myProc->setAutoDefault(TRUE);
254   _GroupButtonsLayout->addWidget(_myProc, 0, 0);
255   _buttonHelp = new QPushButton(_GroupButtons, "buttonHelp");
256   _buttonHelp->setText(tr("FILTER_BUT_HELP" ));
257   _buttonHelp->setAutoDefault(TRUE);
258   _GroupButtonsLayout->addWidget(_buttonHelp, 0, 2);
259   _buttonClose = new QPushButton(_GroupButtons, "buttonClose");
260   _buttonClose->setText(tr("FILTER_BUT_CLOSE" ));
261   _buttonClose->setAutoDefault(TRUE);
262   _GroupButtonsLayout->addWidget(_buttonClose, 0, 1);
263   _myGroupLayout->addWidget( _GroupButtons, row, 0 );
264   _GroupButtons->setDisabled(true);
265   row++;
266
267   _GroupC2 = new QGroupBox( this, "GroupC2" );
268   _lay->addWidget( _GroupC2,0,1 );
269
270   _GroupC2->setTitle( tr( "FILTER_HISTO" ) );
271   _GroupC2->setColumnLayout(0, Qt::Vertical );
272   _GroupC2->layout()->setSpacing( 0 );
273   _GroupC2->layout()->setMargin( 0 );
274   _myGroupLayout2 = new QGridLayout( _GroupC2->layout() );
275
276   // 9)  histogram curve
277   _myPlot = new QwtPlot(_GroupC2);
278   _myHistoCurve = _myPlot->insertCurve( QString() );
279   _myPlot->setCurvePen( _myHistoCurve, QPen( Qt::red, 1 ) );
280   _myPlot->setCurveTitle( _myHistoCurve, "Histogram" );
281
282   _myGroupLayout2->addWidget( _myPlot, 0, 0 );
283
284   // 10)  reduction rate (label)
285   QString qs5(tr("FILTER_RED_RATE"));
286   qs5.append(" = 0.5");
287   _myLRR = new QLabel( qs5, _GroupC2 );
288   _myGroupLayout2->addWidget( _myLRR, 1, 0 );
289
290   _GroupC2->hide();
291
292   _myHistoFThresh = _myPlot->insertCurve( QString() );
293   _myPlot->setCurvePen( _myHistoFThresh, QPen( Qt::black, 1 ) );
294   _myHistoSThresh = _myPlot->insertCurve( QString() );
295   _myPlot->setCurvePen( _myHistoSThresh, QPen( Qt::black, 1 ) );
296
297   connect( _myHisto, SIGNAL(clicked()), this, SLOT(updateHisto()));
298   connect( _myLinear, SIGNAL(clicked()), this, SLOT(scaleSelected()));
299   connect( _myLog, SIGNAL(clicked()), this, SLOT(scaleSelected()));
300   connect( _myOneThresh, SIGNAL(clicked()), this, SLOT(nbThreshSelected()));
301   connect( _myTwoThresh, SIGNAL(clicked()), this, SLOT(nbThreshSelected()));
302   connect( _myInt, SIGNAL(clicked()), this, SLOT(areaSelected()));
303   connect( _myExt, SIGNAL(clicked()), this, SLOT(areaSelected()));
304   connect( _myLEFT, SIGNAL(returnPressed()), this, SLOT(enterFThresh()));
305   connect( _myLEST, SIGNAL(returnPressed()), this, SLOT(enterSThresh()));
306   connect( _myPlot, SIGNAL(plotMouseMoved(const QMouseEvent &)), this, SLOT(moveThresh(const QMouseEvent &)));
307   connect( _myOFB, SIGNAL(clicked()), this, SLOT(getOutFileName()));
308   connect( _myProc, SIGNAL(clicked()), this, SLOT(process()));
309   connect(_buttonClose, SIGNAL(clicked()), this, SLOT(ClickOnClose()));
310   connect(_buttonHelp, SIGNAL(clicked()),   this, SLOT(ClickOnHelp()));
311
312   _GroupC2->setMinimumSize( 500, 500 );
313   _GroupC2->setMaximumSize( 500, 500 );
314   setMinimumSize( 750, 500 );
315   setMaximumSize( 750, 500 );
316   this->show();  /* displays Dialog */
317 }
318
319 void SelectParams::scaleSelected()
320 {
321   // draw linear or log Y scale depend on user
322   if( _myLinear->isChecked() ){
323     _ymin = 0.0;
324     _myPlot->setAxisOptions(_myPlot->curveYAxis( _myHistoCurve ), QwtAutoScale::None );
325   }
326   else{
327     // set min to 0.1 for log scale
328     _ymin = 0.1;
329     _myPlot->setAxisOptions(_myPlot->curveYAxis( _myHistoCurve ), QwtAutoScale::Logarithmic );
330   }
331   _myPlot->setAxisScale( _myPlot->curveYAxis( _myHistoCurve ), _ymin, _ymax );
332   _myPlot->replot();
333 }
334
335 void SelectParams::nbThreshSelected()
336 {
337   if( _myOneThresh->isChecked() ){
338     // if one threshold choice between bottom and up for reference area
339     _myInt->setText(tr("FILTER_BOTTOM"));
340     _myExt->setText(tr("FILTER_UP"));
341     _myLFT->setText(tr("FILTER_VAL_TRESH"));
342     _myLST->hide();
343     _myLEST->hide();
344     // draw first threshold
345     displayFThresh();
346     // erase second threshold
347     clearSThresh();
348   }
349   else{
350     // if two thresholds choice between interior and exterior fir reference area
351     _myInt->setText(tr("FILTER_INT"));
352     _myExt->setText(tr("FILTER_EXT"));
353     _myLFT->setText(tr("FILTER_VAL_1_TRESH"));
354     if(_myLST->isHidden())
355       _myLST->show();
356     if(_myLEST->isHidden())
357       _myLEST->show();
358     // draw two thresholds
359     displayFThresh();
360     displaySThresh();
361   }
362   calcRateRed();
363 }
364
365 void SelectParams::areaSelected()
366 {
367   // calculate reduction rate after thresholds selection
368   calcRateRed();
369 }
370
371 void SelectParams::enterFThresh()
372 {
373   displayFThresh();
374   calcRateRed();
375 }
376
377 void SelectParams::enterSThresh()
378 {
379   displaySThresh();
380   calcRateRed();
381 }
382
383 void SelectParams::calcHisto()
384 {
385   char strth[128];
386   vector<int> myh;
387
388   // calculate histogram values
389   if (_myDField){
390     _myDField->getMinMax(_xmin,_xmax);
391     myh = _myDField->getHistogram(_size);
392   }
393   else{
394     int xmin, xmax;
395     _myIField->getMinMax(xmin,xmax);
396     _xmin = (double)xmin;
397     _xmax = (double)xmax;
398     myh = _myIField->getHistogram(_size);
399   }                     
400   if( _myLinear->isChecked() )
401     _ymin = 0.0;
402   else
403     _ymin = 0.1;
404   _ymax = 0.0;
405
406   for(int i=0;i<_size;i++){
407     // calculate absisses for histogram values
408     _x[i]=_xmin+(i*(_xmax-_xmin))/_size;
409     // set zero to 0.01 because pb of zeros in log display with qwt
410     if(myh[i])
411       _y[i]=(double)myh[i];
412     else
413       _y[i]=0.01;
414     if( _y[i] > _ymax )
415       _ymax = _y[i];
416   }
417
418   // init thresholds values
419   _fthresh = (_xmin + _xmax)/2.0;
420   _sthresh = (_xmin + 3.*_xmax)/4.0;
421   sprintf(strth,"%g",_fthresh);
422   _myLEFT->setText(QString(strth));
423   sprintf(strth,"%g",_sthresh);
424   _myLEST->setText(QString(strth));
425 }
426
427 void SelectParams::displayHisto()
428 {
429   // give extrema values for each axis
430   _myPlot->setAxisScale( _myPlot->curveXAxis( _myHistoCurve ), _xmin, _xmax );
431   _myPlot->setAxisScale( _myPlot->curveYAxis( _myHistoCurve ), _ymin, _ymax );
432   // associate values to curve
433   _myPlot->setCurveData( _myHistoCurve, _x, _y, _size );
434   if( _myLinear->isChecked() )
435     _myPlot->setAxisOptions(_myPlot->curveYAxis( _myHistoCurve ), QwtAutoScale::None );
436   else
437     _myPlot->setAxisOptions(_myPlot->curveYAxis( _myHistoCurve ), QwtAutoScale::Logarithmic );
438   // associate mapping to plot to move thresholds on display
439   _qmap = _myPlot->canvasMap(_myPlot->curveXAxis( _myHistoCurve ));
440   _qmap.setDblRange(_xmin,_xmax);
441   _myPlot->replot();
442 }
443
444 void SelectParams::enableWidgets()
445 {
446   if(_GroupC2->isHidden()){
447     _myFScale->setEnabled(true);
448     _myNbThresh->setEnabled(true);
449     _myArea->setEnabled(true);
450     _myVThresh->setEnabled(true);
451     _myOutFile->setEnabled(true);
452     _GroupButtons->setEnabled(true);
453     _GroupC2->show();
454   }
455 }
456
457 void SelectParams::updateHisto()
458 {
459   calcHisto();
460   displayHisto();
461   displayFThresh();
462   if( _myTwoThresh->isChecked() )
463     displaySThresh();
464   calcRateRed();
465   enableWidgets();
466 }
467
468 void SelectParams::displayFThresh()
469 {
470   _fthresh = atof(_myLEFT->text());
471
472   // draw first threshold curve
473   for(int i=0;i<100;i++){
474     _xft[i]=_fthresh;
475     _yft[i]=((i-1)*_ymax)/100.0;
476   }
477   _myPlot->setCurveData( _myHistoFThresh, _xft, _yft, 100 );
478   _myPlot->replot();
479 }
480
481 void SelectParams::displaySThresh()
482 {
483   _sthresh = atof(_myLEST->text());
484
485   // draw second threshold curve
486   for(int i=0;i<100;i++){
487     _xst[i]=_sthresh;
488     _yst[i]=((i-1)*_ymax)/100.0;
489   }
490   _myPlot->setCurveData( _myHistoSThresh, _xst, _yst, 100 );
491   _myPlot->replot();
492 }
493
494 void SelectParams::clearSThresh()
495 {
496   _sthresh = atof(_myLEST->text());
497
498   // erase second threshold curve
499   for(int i=0;i<100;i++){
500     _xst[i]=_sthresh;
501     _yst[i]=0.0;
502   }
503   _myPlot->setCurveData( _myHistoSThresh, _xst, _yst, 100 );
504   _myPlot->replot();
505 }
506
507 void SelectParams::moveThresh(const QMouseEvent &e)
508 {
509   char strth[128];
510
511   // move threshold curve with mouse
512   int delta = abs(e.x()-_qmap.transform(_fthresh));
513   if( delta < 5 ){
514     // moving first threshold curve
515     sprintf(strth,"%g",_qmap.invTransform(e.x()));
516     _myLEFT->setText(QString(strth));
517     displayFThresh();
518   }
519   else if( _myTwoThresh->isChecked() ){
520     delta = abs(e.x()-_qmap.transform(_sthresh));
521     if( delta < 5 ){
522       // moving second threshold curve
523       sprintf(strth,"%g",_qmap.invTransform(e.x()));
524       _myLEST->setText(QString(strth));
525       displaySThresh();
526     }
527   }
528   calcRateRed();
529 }
530
531 void SelectParams::getOutFileName()
532 {
533   // get output MED file name
534   QString file = QFileDialog::getSaveFileName("",
535                                               "*.med",
536                                               _myOFB,
537                                               "save file dialog",
538                                               "Choose a file to save" );
539   if(!file.isEmpty())
540     _myOFN->setText(file);
541
542   // Selection du Fichier
543 //   file = SUIT_FileDlg::getFileName(application()->desktop(),
544 //                                 "",
545 //                                 filtersList,
546 //                                 "Output MED file name",
547 //                                 true);
548 }
549
550 void SelectParams::process()
551 {
552   string command;
553
554   // have to call ensight driver MED to generate input for filtoo
555
556   MESSAGE("Input MED File : "<<_inputFile);
557   MESSAGE("Input Mesh : "<<_inputMesh);
558   MESSAGE("Input Field : "<<_inputField);
559   MESSAGE("Input Time Step : "<<_inputTS);
560   MESSAGE("Output file name: " << _myOFN->text() );
561
562   // send filtoo command
563   command = "cd /export/home/secher/filtoo/example;filtoo -f s -o sf > /tmp/filter.log";
564   MESSAGE(command);
565   system(command.c_str());
566
567   // have to call ensight driver MED to generate output MED file from filtoo output
568
569 }
570
571 void SelectParams::calcRateRed()
572 {
573   int i1, i2, i;
574   int atot=0, asel=0, atot1;
575   double rateRed=0.0;
576   char strth[128];
577
578   // calculate reduction rate depend on reference area defined by threshold values
579   i1 = (int)((double)_size * ( _fthresh - _xmin ) / ( _xmax - _xmin ));
580   if( _myOneThresh->isChecked() ){
581     for(i=0;i<i1;i++)
582       atot += (int)_y[i];
583     asel = atot;
584     for(i=i1;i<_size;i++)
585       atot += (int)_y[i];
586     if( _myExt->isChecked() )
587       asel = atot - asel;
588   }
589   else{
590     i2 = (int)((double)_size * ( _sthresh - _xmin ) / ( _xmax - _xmin ));
591     if( i2 < i1 ){
592       i=i1;
593       i1=i2;
594       i2=i;
595     }
596     for(i=0;i<i1;i++)
597       atot += (int)_y[i];
598     atot1=atot;
599     for(i=i1;i<i2;i++)
600       atot += (int)_y[i];
601     asel = atot - atot1;
602     for(i=i2;i<_size;i++)
603       atot += (int)_y[i];
604     if( _myExt->isChecked() )
605       asel = atot - asel;
606   }
607   rateRed = (double)asel / (double) atot;
608
609   // display reduction rate value
610   QString qs(tr("FILTER_RED_RATE"));
611   char str[128];
612   sprintf(str," = %4.2g",rateRed);
613   qs.append(str);
614   _myLRR->setText( qs );
615
616 }
617
618 void SelectParams::ClickOnClose()
619 {
620   MESSAGE("click on Cancel");
621   reject();
622 }
623
624 void SelectParams::ClickOnHelp()
625 {
626   MESSAGE("click on Help");
627 }