1 // Copyright (C) 2015-2019 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>
23 #include <SALOMEDS_SObject.hxx>
24 #include <SALOMEDS_Study.hxx>
25 #include CORBA_CLIENT_HEADER(SALOMEDS)
26 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
29 #include <QMessageBox>
30 #include <QDoubleValidator>
32 DlgInterpolateField::DlgInterpolateField(SALOME_AppStudyEditor * studyEditor,
34 : GenericDialog(parent)
36 ui.setupUi(this->getPanel());
38 _studyEditor = studyEditor;
40 QDoubleValidator* precisionValidator = new QDoubleValidator(1e-15, 1e-1, 1, this);
41 precisionValidator->setNotation(QDoubleValidator::ScientificNotation);
42 this->ui.lineEditPrecision->setValidator(precisionValidator);
43 this->ui.lineEditPrecision->setText("1e-12");
45 QDoubleValidator* defaultValueValidator = new QDoubleValidator(this);
46 this->ui.lineEditDefaultValue->setValidator(defaultValueValidator);
47 this->ui.lineEditDefaultValue->setText("0");
49 QStringList intersectionTypes;
50 intersectionTypes << "Triangulation" << "Convex" << "Geometric2D" << "PointLocator" << "Barycentric" << "BarycentricGeo2D";
51 this->ui.comboBoxIntersType->addItems(intersectionTypes);
54 methods << "P0P0" << "P0P1" << "P1P0" << "P1P1" << "P2P0";
55 this->ui.comboBoxMethod->addItems(methods);
58 natures << "NoNature" << "IntensiveMaximum" << "ExtensiveMaximum" << "ExtensiveConservation" << "IntensiveConservation";
59 this->ui.comboBoxNature->addItems(natures);
61 connect(this->ui.btnSelectMesh, SIGNAL(clicked()), this, SLOT(OnSelectMesh()));
62 this->setWindowTitle("Field interpolation");
63 this->getPanel()->adjustSize();
67 /** This reset the dialog for a new selection */
68 void DlgInterpolateField::setFieldId(int fieldId) {
71 this->ui.txtMesh->setText(QString(""));
73 int DlgInterpolateField::getFieldId() {
77 int DlgInterpolateField::getMeshId() {
81 double DlgInterpolateField::getPrecision() {
82 return this->ui.lineEditPrecision->text().toDouble();
85 double DlgInterpolateField::getDefaultValue() {
86 return this->ui.lineEditDefaultValue->text().toDouble();
89 bool DlgInterpolateField::getReverse() {
90 return this->ui.checkBoxReverse->isChecked();
93 std::string DlgInterpolateField::getIntersectionType() {
94 return this->ui.comboBoxIntersType->currentText().toStdString();
97 std::string DlgInterpolateField::getMethod() {
98 return this->ui.comboBoxMethod->currentText().toStdString();
101 std::string DlgInterpolateField::getFieldNature() {
102 return this->ui.comboBoxNature->currentText().toStdString();
105 void DlgInterpolateField::accept() {
106 if ( _meshId == -1 ) {
107 QMessageBox::warning(this,
108 tr("Data verification"),
109 tr("You must select a mesh in the explorer and clic the button Mesh"));
112 GenericDialog::accept();
113 emit inputValidated();
117 void DlgInterpolateField::OnSelectMesh() {
118 SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects();
119 if ( listOfSObject->size() > 0 ) {
120 SALOMEDS::SObject_var soMesh = listOfSObject->at(0);
121 std::string name(_studyEditor->getName(soMesh));
122 if (soMesh->_is_nil() || name == "MEDCalc")
124 SALOMEDS::GenericAttribute_var anAttr;
125 SALOMEDS::AttributeParameter_var aParam;
126 if ( soMesh->FindAttribute(anAttr,"AttributeParameter") ) {
127 aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
128 if (! aParam->IsSet(MESH_ID, PT_INTEGER))
131 _meshId = aParam->GetInt(MESH_ID);
132 const char * meshname = _studyEditor->getName(soMesh);
133 this->ui.txtMesh->setText(QString(meshname));