1 // Copyright (C) 2011-2014 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 "MonEditCase.h"
22 #include "SalomeApp_Tools.h"
23 #include "HOMARDGUI_Utils.h"
24 #include "HomardQtCommun.h"
25 #include <utilities.h>
29 // -------------------------------------------------------------
30 /* Constructs a MonEditCase
31 herite de MonCreateCase
33 // -------------------------------------------------------------
34 MonEditCase::MonEditCase ( bool modal,
35 HOMARD::HOMARD_Gen_var myHomardGen,
37 MonCreateCase(modal, myHomardGen)
39 MESSAGE("Debut de MonEditCase" << CaseName.toStdString().c_str());
40 setWindowTitle(QObject::tr("HOM_CASE_EDIT_WINDOW_TITLE"));
41 _aCaseName = CaseName;
42 aCase = myHomardGen->GetCase(_aCaseName.toStdString().c_str());
45 // ------------------------------
46 MonEditCase::~MonEditCase()
47 // ------------------------------
50 // ------------------------------
51 void MonEditCase::InitValEdit()
52 // ------------------------------
54 MESSAGE("InitValEdit");
55 LEName->setText(_aCaseName);
56 LEName->setReadOnly(true);
58 QString aDirName = aCase->GetDirName();
59 LEDirName->setText(aDirName);
60 LEDirName->setReadOnly(true);
61 PushDir->setVisible(0);
63 QString _aitername=aCase->GetIter0Name();
64 HOMARD::HOMARD_Iteration_var aIter = myHomardGen->GetIteration(_aitername.toStdString().c_str());
65 QString aFileName = aIter->GetMeshFile();
66 LEFileName->setText(aFileName);
67 LEFileName->setReadOnly(true);
68 PushFichier->setVisible(0);
70 int ConfType=aCase->GetConfType();
73 RBConforme->setChecked(true);
74 GBTypeNoConf->setVisible(0);
78 RBNonConforme->setChecked(true);
79 GBTypeNoConf->setVisible(1);
80 if (ConfType==2) { RB1NpM->setChecked(true);};
81 if (ConfType==3) { RB1NpA->setChecked(true);};
82 if (ConfType==4) { RBQuelconque->setChecked(true);};
83 RB1NpM->setEnabled(false);
84 RB1NpA->setEnabled(false);
85 RBQuelconque->setEnabled(false);
88 RBConforme->setEnabled(false);
89 RBNonConforme->setEnabled(false);
91 // Non affichage du mode de suivi de frontiere
92 CBBoundaryA->setVisible(0);
93 GBBoundaryA->setVisible(0);
94 CBBoundaryD->setVisible(0);
95 GBBoundaryD->setVisible(0);
97 // On passe en revue tous les couples (frontiere,groupe) du cas
98 HOMARD::ListBoundaryGroupType_var mesBoundarys = aCase->GetBoundaryGroup();
99 if (mesBoundarys->length()>0)
101 QStringList ListeFron ;
103 bool BounDi = false ;
104 bool BounAn = false ;
105 for (int i=0; i<mesBoundarys->length(); i++)
107 // Nom de la frontiere
108 NomFron = mesBoundarys[i++];
109 MESSAGE("NomFron "<<NomFron.toStdString().c_str());
110 // L'objet associe pour en deduire le type
111 HOMARD::HOMARD_Boundary_var myBoundary = myHomardGen->GetBoundary(NomFron.toStdString().c_str());
112 int type_obj = myBoundary->GetType() ;
113 // C'est une frontiere discrete
114 // Rermarque : on ne gere pas les groupes
118 CBBoundaryDi->addItem(NomFron);
120 // C'est une frontiere analytique
124 int nbcol = TWBoundary->columnCount();
125 // On ajoute une ligne pour le groupe
126 TWBoundary->insertRow(0);
127 // La colonne 0 comporte le nom du groupe
128 TWBoundary->setItem( 0, 0, new QTableWidgetItem(QString(mesBoundarys[i]).trimmed()));
129 // TWBoundary->item( 0, 0 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable );
130 // Chacune des colonnes suivantes est associé a une frontiere deja presente : on y met une
132 for ( int j = 1; j < nbcol; j++ )
134 TWBoundary->setItem( 0, j, new QTableWidgetItem( QString ("") ) );
135 TWBoundary->item( 0, j )->setFlags( 0 );
136 TWBoundary->item( 0, j )->setFlags( Qt::ItemIsUserCheckable );
137 TWBoundary->item( 0, j )->setCheckState( Qt::Unchecked );
139 // On cherche si la frontiere en cours d'examen a deja ete rencontree :
140 // si oui, on stocke son numero de colonne
142 for ( int nufr = 0 ; nufr<ListeFron.size(); nufr++)
143 { if ( ListeFron[nufr] == NomFron ) ok = nufr+1 ; }
144 // si non, on ajoute une colonne
147 ListeFron.append(NomFron);
148 ok = ListeFron.size() ;
149 AddBoundaryAn(NomFron);
151 // on coche la case correspondant au couple (frontiere,groupe) en cours d'examen
152 TWBoundary->item( 0, ok )->setCheckState( Qt::Checked );
155 MESSAGE("BounDi "<<BounDi<<", BounAn "<<BounAn);
157 { GBBoundaryA->setVisible(1);
158 // On rend les cases non modifiables.
159 // On ne peut pas le faire pour tout le tableau sinon on perd l'ascenseur !
160 int nbcol = TWBoundary->columnCount();
161 int nbrow = TWBoundary->rowCount();
162 for ( int i = 0; i < nbrow; i++ )
163 { for ( int j = 0; j < nbcol; j++ ) TWBoundary->item( i, j )->setFlags( Qt::ItemIsSelectable ); }
164 // on met un nom blanc au coin
165 QTableWidgetItem *__colItem = new QTableWidgetItem();
166 __colItem->setText(QApplication::translate("CreateCase", "", 0, QApplication::UnicodeUTF8));
167 TWBoundary->setHorizontalHeaderItem(0, __colItem);
168 // on cache les boutons inutiles
169 PBBoundaryAnNew->setVisible(0);
170 PBBoundaryAnHelp->setVisible(0);
173 { GBBoundaryD->setVisible(1);
174 CBBoundaryDi->setDisabled(true);
175 PBBoundaryDiNew->setVisible(0);
176 PBBoundaryDiHelp->setVisible(0); }
179 // Les options avancees (non modifiables)
180 CBAdvanced->setVisible(0) ;
181 CBAdvanced->setEnabled(false) ;
182 int Pyram = aCase->GetPyram();
183 MESSAGE("Pyram "<<Pyram);
185 { GBAdvancedOptions->setVisible(1);
186 CBPyramid->setChecked(true);
187 CBPyramid->setEnabled(false);
190 { GBAdvancedOptions->setVisible(0);
191 CBPyramid->setChecked(false);
195 int etat = aCase->GetState();
196 MESSAGE("etat "<<etat);
197 if ( etat == 0 ) { Comment->setText(QApplication::translate("CreateCase", "HOM_CASE_EDIT_STATE_0", 0, QApplication::UnicodeUTF8)); }
198 else { Comment->setText(QApplication::translate("CreateCase", "HOM_CASE_EDIT_STATE", 0, QApplication::UnicodeUTF8)); }
200 Comment->setVisible(1);
205 // -------------------------------------
206 bool MonEditCase::PushOnApply()
207 // -------------------------------------