Salome HOME
[MEDCalc] Presentation removal
[modules/med.git] / src / MEDCalc / gui / dialogs / DlgChangeUnderlyingMesh.cxx
1 // Copyright (C) 2015-2016  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "DlgChangeUnderlyingMesh.hxx"
21 #include <MEDCalcConstants.hxx>
22
23 #include <QString>
24 #include <QMessageBox>
25
26 DlgChangeUnderlyingMesh::DlgChangeUnderlyingMesh(SALOME_AppStudyEditor * studyEditor,
27              QDialog * parent)
28   : GenericDialog(parent)
29 {
30   ui.setupUi(this->getPanel());
31   _meshId=-1;
32   _studyEditor = studyEditor;
33   connect(this->ui.btnSelectMesh, SIGNAL(clicked()), this, SLOT(OnSelectMesh()));
34   this->setWindowTitle("Remplacement du maillage support");
35 }
36
37 /** This reset the dialog for a new selection */
38 void DlgChangeUnderlyingMesh::setFieldId(int fieldId) {
39   _fieldId = fieldId;
40   _meshId=-1;
41   this->ui.txtMesh->setText(QString(""));
42 }
43 int DlgChangeUnderlyingMesh::getFieldId() {
44   return _fieldId;
45 }
46
47 int DlgChangeUnderlyingMesh::getMeshId() {
48   return _meshId;
49 }
50
51 void DlgChangeUnderlyingMesh::accept() {
52   if ( _meshId == -1 ) {
53     QMessageBox::warning(this,
54        tr("Data verification"),
55        tr("You must select a mesh in the explorer and clic the button Mesh"));
56   }
57   else {
58     GenericDialog::accept();
59     emit inputValidated();
60   }
61 }
62
63 void DlgChangeUnderlyingMesh::OnSelectMesh() {
64   SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects();
65   if ( listOfSObject->size() > 0 ) {
66     SALOMEDS::SObject_var soMesh = listOfSObject->at(0);
67     // _GBO_ TODO: we should test here if it is a mesh (attribute in
68     // the sobject)
69     _meshId = _studyEditor->getParameterInt(soMesh,MESH_ID);
70     const char * meshname = _studyEditor->getName(soMesh);
71     this->ui.txtMesh->setText(QString(meshname));
72   }
73
74 }