]> SALOME platform Git repositories - modules/filter.git/commitdiff
Salome HOME
second version of select parameters IHM
authorsecher <secher>
Mon, 22 Jan 2007 11:25:25 +0000 (11:25 +0000)
committersecher <secher>
Mon, 22 Jan 2007 11:25:25 +0000 (11:25 +0000)
src/FILTERGUI/SelectParams.cxx
src/FILTERGUI/SelectParams.h

index f959ef4f43a2efd36b9c5ffb07c0bc3e1ae6bf23..d38acc221440d9b9021d4b6ea30715e7ffb59fcb 100644 (file)
@@ -44,6 +44,7 @@ SelectParams::SelectParams(SelectField *sel)
   _myFunc( 0 ),
   _myFieldB( 0 ),
   _myLinear( 0 ),
+  _myLog( 0 ),
   _myHisto( 0 ),
   _myNbThresh( 0 ),
   _myCutNeg( 0 ),
@@ -167,28 +168,30 @@ QFrame* SelectParams::buildFrame()
   _myGroupLayout->addWidget( _myFunc, row, 0 );
   row++;
 
-  // 1)  scale of histogram (radiogroup)
+  // 1)  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++;
+
+  // 2)  scale of histogram (radiogroup)
   _myFScale = new QButtonGroup( "Type of display", _GroupC1 );
   _myFScale->setExclusive( true );
   _myFScale->setColumnLayout( 0, Qt::Horizontal );
 
   _myLinear = new QRadioButton( "Linear", _myFScale );
   _myLinear->setChecked(true);
+  _myLog = new QRadioButton( "Logarithm", _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->setExclusive( true );
@@ -198,8 +201,8 @@ QFrame* SelectParams::buildFrame()
   nbtLay->addWidget( _myTwoThresh = new QRadioButton( "Two thresholds", _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)
@@ -212,7 +215,7 @@ QFrame* SelectParams::buildFrame()
   _myGroupLayout->addWidget( _myArea, row, 0 );
 
   _myExt->setChecked(true);
-  _myArea->hide();
+  _myArea->setDisabled(true);
   row++;
 
   // 5)  threshold values (line edit)
@@ -226,7 +229,7 @@ QFrame* SelectParams::buildFrame()
   ftLay->addWidget( _myLEST = new QLineEdit( "", _myVThresh ), 1, 1 );
   _myGroupLayout->addWidget( _myVThresh, row, 0 );
 
-  _myVThresh->hide();
+  _myVThresh->setDisabled(true);
   _myLST->hide();
   _myLEST->hide();
   row++;
@@ -245,7 +248,7 @@ 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)
@@ -253,7 +256,7 @@ QFrame* SelectParams::buildFrame()
   _myProc->setText("Process");
   _myProc->setAutoDefault(TRUE);
   _myGroupLayout->addWidget( _myProc, row, 0 );
-  _myProc->hide();
+  _myProc->setDisabled(true);
   row++;
 
   _GroupC2 = new QGroupBox( _fr, "GroupC2" );
@@ -273,17 +276,18 @@ QFrame* SelectParams::buildFrame()
   _myGroupLayout2->addWidget( _myPlot, 0, 0 );
 
   // 9)  reduction rate (label)
-  _myGroupLayout2->addWidget( _myLRR = new QLabel( "reduction rate = 0.23", _GroupC2 ), 1, 0 );
+  _myGroupLayout2->addWidget( _myLRR = new QLabel( "reduction rate = 0.5", _GroupC2 ), 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( _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()));
@@ -294,11 +298,18 @@ QFrame* SelectParams::buildFrame()
   connect( _myOFB, SIGNAL(clicked()), this, SLOT(getOutFileName()));
   connect( _myProc, SIGNAL(clicked()), this, SLOT(process()));
 
-  calcHisto();
-
   return _fr;
 }
 
+void SelectParams::scaleSelected()
+{
+  if( _myLinear->isChecked() )
+    _myPlot->setAxisOptions(_myPlot->curveYAxis( _myHistoCurve ), QwtAutoScale::None );
+  else
+    _myPlot->setAxisOptions(_myPlot->curveYAxis( _myHistoCurve ), QwtAutoScale::Logarithmic );
+  _myPlot->replot();
+}
+
 void SelectParams::nbThreshSelected()
 {
   if( _myOneThresh->isChecked() ){
@@ -322,16 +333,6 @@ void SelectParams::nbThreshSelected()
     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()
@@ -353,9 +354,6 @@ void SelectParams::calcHisto()
     if( (_y[i] < _ymin) && (_y[i] != 0.0) )
       _ymin = _y[i];
   }
-  _myPlot->setAxisScale( _myPlot->curveXAxis( _myHistoCurve ), _xmin, _xmax );
-  _myPlot->setAxisScale( _myPlot->curveYAxis( _myHistoCurve ), _ymin, _ymax );
-  _myPlot->setCurveData( _myHistoCurve, _x, _y, _size );
   _fthresh = (_xmin + _xmax)/2.0;
   _sthresh = (_xmin + 3.*_xmax)/4.0;
   sprintf(strth,"%g",_fthresh);
@@ -366,17 +364,40 @@ void SelectParams::calcHisto()
 
 void SelectParams::displayHisto()
 {
-  _qmap = _myPlot->canvasMap(_myPlot->curveXAxis( _myHistoCurve ));
-  _qmap.setDblRange(_xmin,_xmax);
+  if(!_myFScale->isEnabled())
+    _myFScale->setEnabled(true);
+  if(!_myNbThresh->isEnabled())
+    _myNbThresh->setEnabled(true);
+  if(!_myArea->isEnabled())
+    _myArea->setEnabled(true);
+  if(!_myVThresh->isEnabled())
+    _myVThresh->setEnabled(true);
+  if(!_myOutFile->isEnabled())
+    _myOutFile->setEnabled(true);
+  if(!_myProc->isEnabled())
+    _myProc->setEnabled(true);
+  _myPlot->setAxisScale( _myPlot->curveXAxis( _myHistoCurve ), _xmin, _xmax );
+  _myPlot->setAxisScale( _myPlot->curveYAxis( _myHistoCurve ), _ymin, _ymax );
+  _myPlot->setCurveData( _myHistoCurve, _x, _y, _size );
   if( _myLinear->isChecked() )
     _myPlot->setAxisOptions(_myPlot->curveYAxis( _myHistoCurve ), QwtAutoScale::None );
   else
     _myPlot->setAxisOptions(_myPlot->curveYAxis( _myHistoCurve ), QwtAutoScale::Logarithmic );
+  _qmap = _myPlot->canvasMap(_myPlot->curveXAxis( _myHistoCurve ));
+  _qmap.setDblRange(_xmin,_xmax);
   _myPlot->replot();
   if(_GroupC2->isHidden())
     _GroupC2->show();
-  if(_myNbThresh->isHidden())
-    _myNbThresh->show();
+}
+
+void SelectParams::updateHisto()
+{
+  calcHisto();
+  displayHisto();
+  displayFThresh();
+  if( _myTwoThresh->isChecked() )
+    displaySThresh();
+  calcRateRed();
 }
 
 void SelectParams::displayFThresh()
@@ -437,7 +458,7 @@ void SelectParams::moveThresh(const QMouseEvent &e)
 
 void SelectParams::getOutFileName()
 {
-  QString file = QFileDialog::getSaveFileName("/home",
+  QString file = QFileDialog::getSaveFileName("",
                                              "*.med",
                                              _myOFB,
                                              "save file dialog",
index 54eee208a2a1bc70dc1d87ea22ec3a32d5bf378e..25a75bdee903dfbd083ec8b18a20c8f0e736baea 100644 (file)
@@ -51,11 +51,13 @@ public:
 
 protected:
   virtual void     calcHisto();
+  virtual void     displayHisto();
   virtual void     calcRateRed();
   virtual void     clearSThresh();
 
 protected slots:
-  virtual void     displayHisto();
+  virtual void     updateHisto();
+  virtual void     scaleSelected();
   virtual void     nbThreshSelected();
   virtual void     areaSelected();
   virtual void     displayFThresh();
@@ -77,7 +79,7 @@ private:
   QLineEdit *_myFThresh, *_myExpr, *_myLEST, *_myLEFT, *_myOFN;
   QButtonGroup *_myFunc, *_myFScale, *_myNbThresh, *_myArea, *_myVThresh, *_myOutFile;
   QGridLayout *_myGroupLayout, *_myGroupLayout2, *_lay;
-  QRadioButton *_myCutNeg, *_myInt, *_myExt, *_myOneThresh, *_myTwoThresh, *_myFieldB, *_myLinear;
+  QRadioButton *_myCutNeg, *_myInt, *_myExt, *_myOneThresh, *_myTwoThresh, *_myFieldB, *_myLinear, *_myLog;
   QPushButton *_myHisto, *_myOFB, *_myProc;
   QGroupBox* _GroupC1, *_GroupC2;
   QwtPlot *_myPlot;