#include "SelectParams.h"
#include "MEDMEM_MedMeshDriver.hxx"
#include "MEDMEM_EnsightMeshDriver.hxx"
-#include "MEDMEM_Family.hxx"
-#include "MEDMEM_Group.hxx"
#include <SUIT_FileDlg.h>
SelectParams::SelectParams(FilterGUI* theModule,SelectField *sel,
const char* name,
bool modal, WFlags fl) throw(SALOME_Exception)
- : QDialog(FILTER::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), _size(1024),_sel(sel),_criteria(NULL)
+ : QDialog(FILTER::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),_size(1024),_sel(sel),_criteria(NULL),_myGradient(NULL)
{
if(sel){
delete _x;
delete _y;
- // destruction of support of reference field: reference filed is destroyed
+ // destruction of gradient field
+ if(_myGradient)
+ delete _myGradient;
+
+ // destruction of support of reference field: reference field is destroyed
// by destruction of med object in _sel destruction
if(_myIField)
delete _myIField->getSupport();
if(_myDField)
delete _myDField->getSupport();
- // destruction of criteria: support and field
+ // destruction of criteria: support and field
if(_criteria){
delete _criteria->getSupport();
delete _criteria;
QGridLayout* convLay = new QGridLayout( _myFunc->layout() );
convLay->addWidget( _myFieldB, 0, 0 );
- convLay->addWidget( _myCutNeg = new QRadioButton( tr("FILTER_GRADIENT"), _myFunc ), 0, 1 );
+ convLay->addWidget( _myGradB = new QRadioButton( tr("FILTER_GRADIENT"), _myFunc ), 0, 1 );
_myGroupLayout->addWidget( _myFunc, row, 0 );
row++;
_myHistoSThresh = _myPlot->insertCurve( QString() );
_myPlot->setCurvePen( _myHistoSThresh, QPen( Qt::black, 1 ) );
+ connect( _myGradB, SIGNAL(clicked()), this, SLOT(gradSelected()));
connect( _myLESH, SIGNAL(returnPressed()), this, SLOT(enterSHisto()));
connect( _myHisto, SIGNAL(clicked()), this, SLOT(updateHisto()));
connect( _myLinear, SIGNAL(clicked()), this, SLOT(scaleSelected()));
}
+void SelectParams::gradSelected()
+{
+ if(!_myGradient){
+ FIELD<double> * gradient;
+ try{
+ if(_myDField)
+ gradient = _myDField->buildGradient();
+ else
+ gradient = _myIField->buildGradient();
+ _myGradient = gradient->buildNorm2Field();
+ delete gradient;
+ }
+ catch(MEDEXCEPTION& Mex){
+ _myFieldB->setChecked(true);
+ QMessageBox::information( this,
+ "Filtering",
+ "Unable to calculate gradient on vector field.\n"
+ "You must select a reference scalar field." );
+ }
+ }
+}
+
void SelectParams::enterSHisto()
{
// Deallocate old histogram arrays
char strth[128];
vector<int> myh;
- // calculate histogram values
- if (_myDField){
- _myDField->getMinMax(_xmin,_xmax);
- myh = _myDField->getHistogram(_size);
+ if( _myFieldB->isChecked() ){
+ // calculate histogram values on field
+ if (_myDField){
+ _myDField->getMinMax(_xmin,_xmax);
+ myh = _myDField->getHistogram(_size);
+ }
+ else{
+ int xmin, xmax;
+ _myIField->getMinMax(xmin,xmax);
+ _xmin = (double)xmin;
+ _xmax = (double)xmax;
+ myh = _myIField->getHistogram(_size);
+ }
}
else{
- int xmin, xmax;
- _myIField->getMinMax(xmin,xmax);
- _xmin = (double)xmin;
- _xmax = (double)xmax;
- myh = _myIField->getHistogram(_size);
- }
+ // calculate histogram values on gradient
+ _myGradient->getMinMax(_xmin,_xmax);
+ myh = _myGradient->getHistogram(_size);
+ }
if( _myLinear->isChecked() )
_ymin = 0.0;
else
// have to call ensight driver MED to generate output MED file from filtoo output
+ // create fields on new mesh
+ // if new nodes on new mesh: interpolation
+ // if input fields on cell, transform it on nodes
+
+ // destroy filtoo output files
+
+ // create new MED file with new mesh and fields
+
// close the window
accept();
virtual void generateCriteria() throw(SALOME_Exception);
protected slots:
+ virtual void gradSelected();
virtual void enterSHisto();
virtual void updateHisto();
virtual void scaleSelected();
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;
+ QRadioButton *_myFieldB, *_myGradB, *_myInt, *_myExt, *_myOneThresh, *_myTwoThresh, *_myLinear, *_myLog;
QPushButton *_myHisto, *_myOFB, *_myProc, * _buttonCancel, * _buttonHelp;
QGroupBox* _GroupC1, *_GroupC2, *_GroupButtons;
QwtPlot *_myPlot;
SelectField *_sel;
::MEDMEM::MED *_med;
MESH* _mesh;
+ FIELD<double> * _myGradient;
FIELD<double> * _myDField;
FIELD<int> * _myIField;
FIELD<int> *_criteria;