1 // Copyright (C) 2015-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "DlgInterpolateField.hxx"
21 #include <MEDCalcConstants.hxx>
24 #include <QMessageBox>
25 #include <QDoubleValidator>
27 DlgInterpolateField::DlgInterpolateField(SALOME_AppStudyEditor * studyEditor,
29 : GenericDialog(parent)
31 ui.setupUi(this->getPanel());
33 _studyEditor = studyEditor;
35 QDoubleValidator* precisionValidator = new QDoubleValidator(1e-15, 1e-1, 1, this);
36 precisionValidator->setNotation(QDoubleValidator::ScientificNotation);
37 this->ui.lineEditPrecision->setValidator(precisionValidator);
38 this->ui.lineEditPrecision->setText("1e-12");
40 QDoubleValidator* defaultValueValidator = new QDoubleValidator(this);
41 this->ui.lineEditDefaultValue->setValidator(defaultValueValidator);
42 this->ui.lineEditDefaultValue->setText("0");
44 QStringList intersectionTypes;
45 intersectionTypes << "Triangulation" << "Convex" << "Geometric2D" << "PointLocator" << "Barycentric" << "BarycentricGeo2D";
46 this->ui.comboBoxIntersType->addItems(intersectionTypes);
49 methods << "P0P0" << "P0P1" << "P1P0" << "P1P1" << "P2P0";
50 this->ui.comboBoxMethod->addItems(methods);
53 natures << "NoNature" << "IntensiveMaximum" << "ExtensiveMaximum" << "ExtensiveConservation" << "IntensiveConservation";
54 this->ui.comboBoxNature->addItems(natures);
56 connect(this->ui.btnSelectMesh, SIGNAL(clicked()), this, SLOT(OnSelectMesh()));
57 this->setWindowTitle("Field interpolation");
58 this->getPanel()->adjustSize();
62 /** This reset the dialog for a new selection */
63 void DlgInterpolateField::setFieldId(int fieldId) {
66 this->ui.txtMesh->setText(QString(""));
68 int DlgInterpolateField::getFieldId() {
72 int DlgInterpolateField::getMeshId() {
76 double DlgInterpolateField::getPrecision() {
77 return this->ui.lineEditPrecision->text().toDouble();
80 double DlgInterpolateField::getDefaultValue() {
81 return this->ui.lineEditDefaultValue->text().toDouble();
84 bool DlgInterpolateField::getReverse() {
85 return this->ui.checkBoxReverse->isChecked();
88 std::string DlgInterpolateField::getIntersectionType() {
89 return this->ui.comboBoxIntersType->currentText().toStdString();
92 std::string DlgInterpolateField::getMethod() {
93 return this->ui.comboBoxMethod->currentText().toStdString();
96 std::string DlgInterpolateField::getFieldNature() {
97 return this->ui.comboBoxNature->currentText().toStdString();
100 void DlgInterpolateField::accept() {
101 if ( _meshId == -1 ) {
102 QMessageBox::warning(this,
103 tr("Data verification"),
104 tr("You must select a mesh in the explorer and clic the button Mesh"));
107 GenericDialog::accept();
108 emit inputValidated();
112 void DlgInterpolateField::OnSelectMesh() {
113 SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects();
114 if ( listOfSObject->size() > 0 ) {
115 SALOMEDS::SObject_var soMesh = listOfSObject->at(0);
116 // _GBO_ TODO: we should test here if it is a mesh (attribute in
118 _meshId = _studyEditor->getParameterInt(soMesh,MESH_ID);
119 const char * meshname = _studyEditor->getName(soMesh);
120 this->ui.txtMesh->setText(QString(meshname));