1 // Copyright (C) 2015-2021 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 "DlgChangeUnderlyingMesh.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>
31 DlgChangeUnderlyingMesh::DlgChangeUnderlyingMesh(SALOME_AppStudyEditor * studyEditor,
33 : GenericDialog(parent)
35 ui.setupUi(this->getPanel());
37 _studyEditor = studyEditor;
38 connect(this->ui.btnSelectMesh, SIGNAL(clicked()), this, SLOT(OnSelectMesh()));
39 this->setWindowTitle("Remplacement du maillage support");
42 /** This reset the dialog for a new selection */
43 void DlgChangeUnderlyingMesh::setFieldId(int fieldId) {
46 this->ui.txtMesh->setText(QString(""));
48 int DlgChangeUnderlyingMesh::getFieldId() {
52 int DlgChangeUnderlyingMesh::getMeshId() {
56 void DlgChangeUnderlyingMesh::accept() {
57 if ( _meshId == -1 ) {
58 QMessageBox::warning(this,
59 tr("Data verification"),
60 tr("You must select a mesh in the explorer and clic the button Mesh"));
63 GenericDialog::accept();
64 emit inputValidated();
68 void DlgChangeUnderlyingMesh::OnSelectMesh() {
69 SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects();
70 if ( listOfSObject->size() > 0 ) {
71 SALOMEDS::SObject_var soMesh = listOfSObject->at(0);
72 std::string name(_studyEditor->getName(soMesh));
73 if (soMesh->_is_nil() || name == "MEDCalc")
75 SALOMEDS::GenericAttribute_var anAttr;
76 SALOMEDS::AttributeParameter_var aParam;
77 if ( soMesh->FindAttribute(anAttr,"AttributeParameter") ) {
78 aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
79 if (! aParam->IsSet(MESH_ID, PT_INTEGER))
82 _meshId = aParam->GetInt(MESH_ID);
83 const char * meshname = _studyEditor->getName(soMesh);
84 this->ui.txtMesh->setText(QString(meshname));