From a22ba538b7de5d154b463cb78c2ce090d85c06d3 Mon Sep 17 00:00:00 2001 From: secher Date: Wed, 31 Jan 2007 09:46:47 +0000 Subject: [PATCH] add Close and Help buttons in dialog windows --- src/FILTERGUI/FILTER_msg_en.po | 11 ++++ src/FILTERGUI/SelectField.cxx | 46 ++++++++++++--- src/FILTERGUI/SelectField.h | 8 ++- src/FILTERGUI/SelectParams.cxx | 103 +++++++++++++++++++++------------ src/FILTERGUI/SelectParams.h | 8 ++- 5 files changed, 128 insertions(+), 48 deletions(-) diff --git a/src/FILTERGUI/FILTER_msg_en.po b/src/FILTERGUI/FILTER_msg_en.po index 53ebdc0..acd9df9 100644 --- a/src/FILTERGUI/FILTER_msg_en.po +++ b/src/FILTERGUI/FILTER_msg_en.po @@ -192,4 +192,15 @@ msgstr "Select a time step:" msgid "MEN_FILTERING" msgstr "Filtering" +#------------------------------------------------------------------------- +# BUTTON +#------------------------------------------------------------------------- + +#Close +msgid "FILTER_BUT_CLOSE" +msgstr "&Close" + +#Help +msgid "FILTER_BUT_HELP" +msgstr "&Help" diff --git a/src/FILTERGUI/SelectField.cxx b/src/FILTERGUI/SelectField.cxx index b507a61..7dfdb76 100644 --- a/src/FILTERGUI/SelectField.cxx +++ b/src/FILTERGUI/SelectField.cxx @@ -25,6 +25,7 @@ #include #include #include +#include SelectField::SelectField(FilterGUI* theModule,const QString& file, const char* name, @@ -34,15 +35,10 @@ SelectField::SelectField(FilterGUI* theModule,const QString& file, _file(file), _mesh(0), _field(0), - _ts(0), - _myList( 0 ), - _myLab( 0 ), - _mySlider( 0 ), - _fr( 0 ) + _ts(0) { QListViewItem *element; - cout << "File: " << _file << endl; SCRUTE(_file); _med = new ::MED(MED_DRIVER,_file); deque meshesNames = _med->getMeshNames(); @@ -93,8 +89,8 @@ SelectField::SelectField(FilterGUI* theModule,const QString& file, } element->setSelectable(false); - _myGroupLayout->addWidget( _myList, row, 0 ); } + _myGroupLayout->addWidget( _myList, row, 0 ); row++; // 1) label for time steps @@ -112,8 +108,33 @@ SelectField::SelectField(FilterGUI* theModule,const QString& file, _mySlider->hide(); row++; + // 3) buttons Close and Help + _GroupButtons = new QGroupBox(_GroupC1, "GroupButtons"); + _GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, _GroupButtons->sizePolicy().hasHeightForWidth())); +// _GroupButtons->setGeometry(QRect(10, 10, 281, 48)); + _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); + _buttonHelp = new QPushButton(_GroupButtons, "buttonHelp"); + _buttonHelp->setText(tr("FILTER_BUT_HELP" )); + _buttonHelp->setAutoDefault(TRUE); + _GroupButtonsLayout->addWidget(_buttonHelp, 0, 1); + _buttonClose = new QPushButton(_GroupButtons, "buttonClose"); + _buttonClose->setText(tr("FILTER_BUT_CLOSE" )); + _buttonClose->setAutoDefault(TRUE); + _GroupButtonsLayout->addWidget(_buttonClose, 0, 0); + _myGroupLayout->addWidget( _GroupButtons, row, 0 ); + row++; + connect( _myList, SIGNAL(clicked(QListViewItem *)), this, SLOT(fieldSelected(QListViewItem *))); connect( _mySlider, SIGNAL(sliderReleased()), this, SLOT(tsSelected())); + connect(_buttonClose, SIGNAL(clicked()), this, SLOT(ClickOnClose())); + connect(_buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp())); this->show(); /* displays Dialog */ } @@ -156,3 +177,14 @@ void SelectField::tsSelected() MESSAGE("Field " << _field ); MESSAGE("Time step " << _ts ); } + +void SelectField::ClickOnClose() +{ + MESSAGE("click on Cancel"); + reject(); +} + +void SelectField::ClickOnHelp() +{ + MESSAGE("click on Help"); +} diff --git a/src/FILTERGUI/SelectField.h b/src/FILTERGUI/SelectField.h index 236ba87..7987ab5 100644 --- a/src/FILTERGUI/SelectField.h +++ b/src/FILTERGUI/SelectField.h @@ -38,6 +38,7 @@ class QSlider; class QGridLayout; class QGroupBox; class QLabel; +class QPushButton; class SelectField: public QDialog { @@ -63,16 +64,19 @@ protected: protected slots: virtual void fieldSelected(QListViewItem *lvi); virtual void tsSelected(); + virtual void ClickOnClose(); + virtual void ClickOnHelp(); private: int _ts; - QGridLayout *_myGroupLayout, *_lay; - QGroupBox* _GroupC1; + QGridLayout *_myGroupLayout, *_GroupButtonsLayout, *_lay; + QGroupBox* _GroupC1, *_GroupButtons; QFrame *_fr; QString _file, _mesh, _field; QListView *_myList; QLabel *_myLab; QSlider *_mySlider; + QPushButton* _buttonClose, * _buttonHelp; ::MEDMEM::MED *_med; }; diff --git a/src/FILTERGUI/SelectParams.cxx b/src/FILTERGUI/SelectParams.cxx index 0f8a1e0..181a4f7 100644 --- a/src/FILTERGUI/SelectParams.cxx +++ b/src/FILTERGUI/SelectParams.cxx @@ -41,30 +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), - _myExpr( 0 ), - _myFunc( 0 ), - _myFieldB( 0 ), - _myLinear( 0 ), - _myLog( 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 ) + : QDialog(FILTER::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), _size(128) { // Allocate histogram arrays _x = new double[_size]; @@ -110,8 +87,14 @@ SelectParams::~SelectParams() cout << "SelectParams: destructor called" << endl; delete _x; delete _y; - if(_myIField) delete _myIField; - if(_myDField) delete _myDField; + if(_myIField){ + delete _myIField->getSupport(); + delete _myIField; + } + if(_myDField){ + delete _myDField->getSupport(); + delete _myDField; + } } void SelectParams::buildFrame() @@ -254,12 +237,31 @@ void SelectParams::buildFrame() _myOutFile->setDisabled(true); row++; - // 8) process button (pushbutton) - _myProc = new QPushButton( "", _GroupC1 ); + // 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->setDisabled(true); + _GroupButtonsLayout->addWidget(_myProc, 0, 0); + _buttonHelp = new QPushButton(_GroupButtons, "buttonHelp"); + _buttonHelp->setText(tr("FILTER_BUT_HELP" )); + _buttonHelp->setAutoDefault(TRUE); + _GroupButtonsLayout->addWidget(_buttonHelp, 0, 2); + _buttonClose = new QPushButton(_GroupButtons, "buttonClose"); + _buttonClose->setText(tr("FILTER_BUT_CLOSE" )); + _buttonClose->setAutoDefault(TRUE); + _GroupButtonsLayout->addWidget(_buttonClose, 0, 1); + _myGroupLayout->addWidget( _GroupButtons, row, 0 ); + _GroupButtons->setDisabled(true); row++; _GroupC2 = new QGroupBox( this, "GroupC2" ); @@ -304,7 +306,13 @@ void SelectParams::buildFrame() 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(_buttonClose, SIGNAL(clicked()), this, SLOT(ClickOnClose())); + 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 */ } @@ -316,7 +324,8 @@ void SelectParams::scaleSelected() _myPlot->setAxisOptions(_myPlot->curveYAxis( _myHistoCurve ), QwtAutoScale::None ); } else{ - _ymin = 1.0; + // 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 ); @@ -388,13 +397,20 @@ void SelectParams::calcHisto() _xmax = (double)xmax; myh = _myIField->getHistogram(_size); } - _ymin = 0.0; + 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]=(double)myh[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]; } @@ -433,7 +449,7 @@ void SelectParams::enableWidgets() _myArea->setEnabled(true); _myVThresh->setEnabled(true); _myOutFile->setEnabled(true); - _myProc->setEnabled(true); + _GroupButtons->setEnabled(true); _GroupC2->show(); } } @@ -535,16 +551,21 @@ void SelectParams::process() { string command; - // send filtoo 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 + } void SelectParams::calcRateRed() @@ -594,3 +615,13 @@ void SelectParams::calcRateRed() } +void SelectParams::ClickOnClose() +{ + MESSAGE("click on Cancel"); + reject(); +} + +void SelectParams::ClickOnHelp() +{ + MESSAGE("click on Help"); +} diff --git a/src/FILTERGUI/SelectParams.h b/src/FILTERGUI/SelectParams.h index 6ac7ba5..549f0c4 100644 --- a/src/FILTERGUI/SelectParams.h +++ b/src/FILTERGUI/SelectParams.h @@ -74,6 +74,8 @@ protected slots: virtual void moveThresh(const QMouseEvent &e); virtual void getOutFileName(); virtual void process(); + virtual void ClickOnClose(); + virtual void ClickOnHelp(); private: @@ -87,10 +89,10 @@ private: QLineEdit *_myFThresh, *_myExpr, *_myLEST, *_myLEFT, *_myOFN; QButtonGroup *_myFunc, *_myFScale, *_myNbThresh, *_myArea, *_myVThresh, *_myOutFile; - QGridLayout *_myGroupLayout, *_myGroupLayout2, *_lay; + QGridLayout *_myGroupLayout, *_myGroupLayout2, *_lay, *_GroupButtonsLayout; QRadioButton *_myCutNeg, *_myInt, *_myExt, *_myOneThresh, *_myTwoThresh, *_myFieldB, *_myLinear, *_myLog; - QPushButton *_myHisto, *_myOFB, *_myProc; - QGroupBox* _GroupC1, *_GroupC2; + QPushButton *_myHisto, *_myOFB, *_myProc, * _buttonClose, * _buttonHelp; + QGroupBox* _GroupC1, *_GroupC2, *_GroupButtons; QwtPlot *_myPlot; QLabel *_myLFT, *_myLST, *_myLRR; QwtDiMap _qmap; -- 2.39.2