From 9efcee0709acb68405ba8e9daeb6132c369a71b5 Mon Sep 17 00:00:00 2001 From: secher Date: Wed, 31 Jan 2007 10:29:53 +0000 Subject: [PATCH] add possibility to change the size of histogram --- src/FILTERGUI/FILTER_msg_en.po | 4 ++++ src/FILTERGUI/SelectParams.cxx | 31 ++++++++++++++++++++++++++++--- src/FILTERGUI/SelectParams.h | 7 ++++--- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/FILTERGUI/FILTER_msg_en.po b/src/FILTERGUI/FILTER_msg_en.po index acd9df9..424387d 100644 --- a/src/FILTERGUI/FILTER_msg_en.po +++ b/src/FILTERGUI/FILTER_msg_en.po @@ -80,6 +80,10 @@ msgstr "Field" msgid "FILTER_GRADIENT" msgstr "Gradient" +#: SelectParams.cxx:162 +msgid "FILTER_SIZE_HISTO" +msgstr "Histogram size " + #: SelectParams.cxx:174 msgid "FILTER_DISPLAY_HISTO" msgstr "Display Histogram" diff --git a/src/FILTERGUI/SelectParams.cxx b/src/FILTERGUI/SelectParams.cxx index 181a4f7..10da73f 100644 --- a/src/FILTERGUI/SelectParams.cxx +++ b/src/FILTERGUI/SelectParams.cxx @@ -41,7 +41,7 @@ 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(128) + : QDialog(FILTER::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), _size(1024) { // Allocate histogram arrays _x = new double[_size]; @@ -154,6 +154,16 @@ void SelectParams::buildFrame() _myGroupLayout->addWidget( _myFunc, row, 0 ); row++; + // 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")); @@ -294,6 +304,7 @@ void SelectParams::buildFrame() _myHistoSThresh = _myPlot->insertCurve( QString() ); _myPlot->setCurvePen( _myHistoSThresh, QPen( Qt::black, 1 ) ); + 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())); @@ -316,6 +327,20 @@ void SelectParams::buildFrame() this->show(); /* displays Dialog */ } +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]; +} + void SelectParams::scaleSelected() { // draw linear or log Y scale depend on user @@ -426,11 +451,11 @@ void SelectParams::calcHisto() void SelectParams::displayHisto() { + // 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 ); - // associate values to curve - _myPlot->setCurveData( _myHistoCurve, _x, _y, _size ); if( _myLinear->isChecked() ) _myPlot->setAxisOptions(_myPlot->curveYAxis( _myHistoCurve ), QwtAutoScale::None ); else diff --git a/src/FILTERGUI/SelectParams.h b/src/FILTERGUI/SelectParams.h index 549f0c4..f86bf88 100644 --- a/src/FILTERGUI/SelectParams.h +++ b/src/FILTERGUI/SelectParams.h @@ -65,6 +65,7 @@ protected: virtual void enableWidgets(); protected slots: + virtual void enterSHisto(); virtual void updateHisto(); virtual void scaleSelected(); virtual void nbThreshSelected(); @@ -87,14 +88,14 @@ private: double *_x, *_y; double _xft[100], _yft[100], _xst[100], _yst[100]; - QLineEdit *_myFThresh, *_myExpr, *_myLEST, *_myLEFT, *_myOFN; - QButtonGroup *_myFunc, *_myFScale, *_myNbThresh, *_myArea, *_myVThresh, *_myOutFile; + QLineEdit *_myLESH, *_myFThresh, *_myExpr, *_myLEST, *_myLEFT, *_myOFN; + QButtonGroup *_myHSize, *_myFunc, *_myFScale, *_myNbThresh, *_myArea, *_myVThresh, *_myOutFile; QGridLayout *_myGroupLayout, *_myGroupLayout2, *_lay, *_GroupButtonsLayout; QRadioButton *_myCutNeg, *_myInt, *_myExt, *_myOneThresh, *_myTwoThresh, *_myFieldB, *_myLinear, *_myLog; QPushButton *_myHisto, *_myOFB, *_myProc, * _buttonClose, * _buttonHelp; QGroupBox* _GroupC1, *_GroupC2, *_GroupButtons; QwtPlot *_myPlot; - QLabel *_myLFT, *_myLST, *_myLRR; + QLabel *_myLSH, *_myLFT, *_myLST, *_myLRR; QwtDiMap _qmap; QFrame *_fr; QString _inputFile, _inputMesh, _inputField; -- 2.39.2