Salome HOME
Synchronize adm files
[modules/med.git] / src / MEDOP / gui / dialogs / DlgChangeUnderlyingMesh.cxx
1 #include "DlgChangeUnderlyingMesh.hxx"
2 #include "DatasourceConstants.hxx"
3
4 #include <QString>
5 #include <QMessageBox>
6
7 DlgChangeUnderlyingMesh::DlgChangeUnderlyingMesh(SALOME_AppStudyEditor * studyEditor,
8              QDialog * parent)
9   : GenericDialog(parent)
10 {
11   ui.setupUi(this->getPanel());
12   _meshId=-1;
13   _studyEditor = studyEditor;
14   connect(this->ui.btnSelectMesh, SIGNAL(clicked()), this, SLOT(OnSelectMesh()));
15   this->setWindowTitle("Remplacement du maillage support");
16 }
17
18 /** This reset the dialog for a new selection */
19 void DlgChangeUnderlyingMesh::setFieldId(int fieldId) {
20   _fieldId = fieldId;
21   _meshId=-1;
22   this->ui.txtMesh->setText(QString(""));
23 }
24 int DlgChangeUnderlyingMesh::getFieldId() {
25   return _fieldId;
26 }
27
28 int DlgChangeUnderlyingMesh::getMeshId() {
29   return _meshId;
30 }
31
32 void DlgChangeUnderlyingMesh::accept() {
33   if ( _meshId == -1 ) {
34     QMessageBox::warning(this,
35        tr("Data verification"),
36        tr("You must select a mesh in the explorer and clic the button Mesh"));
37   }
38   else {
39     GenericDialog::accept();
40     emit inputValidated();
41   }
42 }
43
44 void DlgChangeUnderlyingMesh::OnSelectMesh() {
45   SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects();
46   if ( listOfSObject->size() > 0 ) {
47     SALOMEDS::SObject_var soMesh = listOfSObject->at(0);
48     // _GBO_ TODO: we should test here if it is a mesh (attribute in
49     // the sobject)
50     _meshId = _studyEditor->getParameterInt(soMesh,OBJECT_ID);
51     const char * meshname = _studyEditor->getName(soMesh);
52     this->ui.txtMesh->setText(QString(meshname));
53   }
54
55 }