From: secher Date: Wed, 31 Jan 2007 15:11:03 +0000 (+0000) Subject: management of closing windows X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5011714b458217e62222889f79969baab6c847dd;p=modules%2Ffilter.git management of closing windows --- diff --git a/src/FILTERGUI/FILTER_msg_en.po b/src/FILTERGUI/FILTER_msg_en.po index 424387d..bb1788d 100644 --- a/src/FILTERGUI/FILTER_msg_en.po +++ b/src/FILTERGUI/FILTER_msg_en.po @@ -201,8 +201,12 @@ msgstr "Filtering" #------------------------------------------------------------------------- #Close -msgid "FILTER_BUT_CLOSE" -msgstr "&Close" +msgid "FILTER_BUT_CANCEL" +msgstr "&Cancel" + +#Help +msgid "FILTER_BUT_OK" +msgstr "&Ok" #Help msgid "FILTER_BUT_HELP" diff --git a/src/FILTERGUI/FilterGUI.cxx b/src/FILTERGUI/FilterGUI.cxx index 186b6e5..2526e15 100644 --- a/src/FILTERGUI/FilterGUI.cxx +++ b/src/FILTERGUI/FilterGUI.cxx @@ -280,11 +280,18 @@ bool FilterGUI::OnGUIEvent (int theCommandID) { MESSAGE("command " << theCommandID << " activated"); - try { - SelectParams *filter = new SelectParams(this,_sel); - } - catch ( SALOME_Exception& S_ex ) { + if(_sel){ + SelectParams *filter; + try { + filter = new SelectParams(this,_sel); + filter->exec(); + _sel = NULL; + } + catch ( SALOME_Exception& S_ex ) { + } } + else + MESSAGE("Select an input Field in MED file before filtering!!"); break; } case 111: @@ -297,8 +304,13 @@ bool FilterGUI::OnGUIEvent (int theCommandID) filtersList, tr("FILTER_MEN_IMPORT"), true); - if (!file.isEmpty() ) + if (!file.isEmpty() ){ _sel = new SelectField(this,file); + if ( _sel->exec() == QDialog::Rejected ){ + delete _sel; + _sel = NULL; + } + } break; } diff --git a/src/FILTERGUI/SelectField.cxx b/src/FILTERGUI/SelectField.cxx index 7dfdb76..2e2e5b0 100644 --- a/src/FILTERGUI/SelectField.cxx +++ b/src/FILTERGUI/SelectField.cxx @@ -30,7 +30,7 @@ SelectField::SelectField(FilterGUI* theModule,const QString& file, const char* name, bool modal, WFlags fl) - : QDialog(FILTER::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), + : QDialog(FILTER::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), myFilterGUI( theModule ), _file(file), _mesh(0), @@ -123,20 +123,24 @@ SelectField::SelectField(FilterGUI* theModule,const QString& file, _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); + _GroupButtonsLayout->addWidget(_buttonHelp, 0, 2); + _buttonCancel = new QPushButton(_GroupButtons, "buttonClose"); + _buttonCancel->setText(tr("FILTER_BUT_CANCEL" )); + _buttonCancel->setAutoDefault(TRUE); + _GroupButtonsLayout->addWidget(_buttonCancel, 0, 1); + _buttonOk = new QPushButton(_GroupButtons, "buttonOk"); + _buttonOk->setText(tr("FILTER_BUT_OK" )); + _buttonOk->setAutoDefault(TRUE); + _GroupButtonsLayout->addWidget(_buttonOk, 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(_buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); + connect(_buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(_buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp())); - this->show(); /* displays Dialog */ } SelectField::~SelectField() @@ -178,7 +182,13 @@ void SelectField::tsSelected() MESSAGE("Time step " << _ts ); } -void SelectField::ClickOnClose() +void SelectField::ClickOnOk() +{ + MESSAGE("click on Ok"); + accept(); +} + +void SelectField::ClickOnCancel() { MESSAGE("click on Cancel"); reject(); diff --git a/src/FILTERGUI/SelectField.h b/src/FILTERGUI/SelectField.h index 7987ab5..35eeba8 100644 --- a/src/FILTERGUI/SelectField.h +++ b/src/FILTERGUI/SelectField.h @@ -64,7 +64,8 @@ protected: protected slots: virtual void fieldSelected(QListViewItem *lvi); virtual void tsSelected(); - virtual void ClickOnClose(); + virtual void ClickOnOk(); + virtual void ClickOnCancel(); virtual void ClickOnHelp(); private: @@ -76,7 +77,7 @@ private: QListView *_myList; QLabel *_myLab; QSlider *_mySlider; - QPushButton* _buttonClose, * _buttonHelp; + QPushButton* _buttonCancel, * _buttonHelp, * _buttonOk; ::MEDMEM::MED *_med; }; diff --git a/src/FILTERGUI/SelectParams.cxx b/src/FILTERGUI/SelectParams.cxx index 10da73f..60ddc54 100644 --- a/src/FILTERGUI/SelectParams.cxx +++ b/src/FILTERGUI/SelectParams.cxx @@ -41,13 +41,10 @@ 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) + : QDialog(FILTER::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), _size(1024),_sel(sel) { - // Allocate histogram arrays - _x = new double[_size]; - _y = new double[_size]; - if(sel){ + // read reference field values ::MEDMEM::MED *med = sel->getMED(); @@ -56,9 +53,11 @@ SelectParams::SelectParams(FilterGUI* theModule,SelectField *sel, _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"); } @@ -80,6 +79,10 @@ SelectParams::SelectParams(FilterGUI* theModule,SelectField *sel, throw SALOME_Exception("Salome Exception"); } + // Allocate histogram arrays + _x = new double[_size]; + _y = new double[_size]; + } SelectParams::~SelectParams() @@ -95,6 +98,7 @@ SelectParams::~SelectParams() delete _myDField->getSupport(); delete _myDField; } + delete _sel; } void SelectParams::buildFrame() @@ -266,10 +270,10 @@ void SelectParams::buildFrame() _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); + _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++; @@ -317,14 +321,14 @@ 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(_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 */ +// this->show(); /* displays Dialog */ } void SelectParams::enterSHisto() @@ -591,6 +595,9 @@ void SelectParams::process() // have to call ensight driver MED to generate output MED file from filtoo output + // close the window + accept(); + } void SelectParams::calcRateRed() @@ -598,7 +605,6 @@ 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 )); @@ -640,7 +646,7 @@ void SelectParams::calcRateRed() } -void SelectParams::ClickOnClose() +void SelectParams::ClickOnCancel() { MESSAGE("click on Cancel"); reject(); diff --git a/src/FILTERGUI/SelectParams.h b/src/FILTERGUI/SelectParams.h index f86bf88..d1898eb 100644 --- a/src/FILTERGUI/SelectParams.h +++ b/src/FILTERGUI/SelectParams.h @@ -75,7 +75,7 @@ protected slots: virtual void moveThresh(const QMouseEvent &e); virtual void getOutFileName(); virtual void process(); - virtual void ClickOnClose(); + virtual void ClickOnCancel(); virtual void ClickOnHelp(); private: @@ -92,7 +92,7 @@ private: 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; + QPushButton *_myHisto, *_myOFB, *_myProc, * _buttonCancel, * _buttonHelp; QGroupBox* _GroupC1, *_GroupC2, *_GroupButtons; QwtPlot *_myPlot; QLabel *_myLSH, *_myLFT, *_myLST, *_myLRR; @@ -102,6 +102,7 @@ private: FIELD * _myDField; FIELD * _myIField; int _inputTS; + SelectField *_sel; };