Salome HOME
management of closing windows
authorsecher <secher>
Wed, 31 Jan 2007 15:11:03 +0000 (15:11 +0000)
committersecher <secher>
Wed, 31 Jan 2007 15:11:03 +0000 (15:11 +0000)
src/FILTERGUI/FILTER_msg_en.po
src/FILTERGUI/FilterGUI.cxx
src/FILTERGUI/SelectField.cxx
src/FILTERGUI/SelectField.h
src/FILTERGUI/SelectParams.cxx
src/FILTERGUI/SelectParams.h

index 424387d05e9edf8c2168badba26c4596d7f8d62b..bb1788d56dc19a621de289eae1c9ca0bca14a262 100644 (file)
@@ -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"
index 186b6e5ade96b699c934f409ac834d6b282b5b91..2526e15814d860cd4bc2c2a86f8634a03a721a9b 100644 (file)
@@ -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;
       }
index 7dfdb76377af319ca4c1fc5c7a04417cf805edbd..2e2e5b0769f32cf1652054125086e9b797969a68 100644 (file)
@@ -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();
index 7987ab577c8a7baa326cc41ca29e64eb6da51b50..35eeba8e3ea079ee41f99fdf2a3452f9b50078e9 100644 (file)
@@ -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;
 };
 
index 10da73f8fe9def90a24c942bc4e9bb1811db1286..60ddc5468aef8c62725e406c4ed1535ff07a4b8f 100644 (file)
 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();
index f86bf8829a0d7caa7fd4fc3a2d7bba8e5e4d7530..d1898ebf69b21657fdc8a6b8ac5c3828542599dd 100644 (file)
@@ -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<double> * _myDField;
   FIELD<int> * _myIField;
   int _inputTS;
+  SelectField *_sel;
 
 };