1 // Copyright (C) 2011-2016 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();
71 if ( ( ConfType == 0 ) || ( ConfType == -1 ) ) { RBConforme->setChecked(true); }
72 else { RBNonConforme->setChecked(true); };
73 RBConforme->setEnabled(false);
74 RBNonConforme->setEnabled(false);
75 int ExtType=aCase->GetExtType();
77 // Non affichage du mode de suivi de frontiere
78 CBBoundaryA->setVisible(0);
79 GBBoundaryA->setVisible(0);
80 CBBoundaryD->setVisible(0);
81 GBBoundaryD->setVisible(0);
83 // On passe en revue tous les couples (frontiere,groupe) du cas
84 HOMARD::ListBoundaryGroupType_var mesBoundarys = aCase->GetBoundaryGroup();
85 if (mesBoundarys->length()>0)
87 QStringList ListeFron ;
91 for (int i=0; i<mesBoundarys->length(); i++)
93 // Nom de la frontiere
94 NomFron = mesBoundarys[i++];
95 MESSAGE("NomFron "<<NomFron.toStdString().c_str());
96 // L'objet associe pour en deduire le type
97 HOMARD::HOMARD_Boundary_var myBoundary = myHomardGen->GetBoundary(NomFron.toStdString().c_str());
98 int type_obj = myBoundary->GetType() ;
99 // C'est une frontiere discrete
100 // Rermarque : on ne gere pas les groupes
104 CBBoundaryDi->addItem(NomFron);
106 // C'est une frontiere analytique
110 int nbcol = TWBoundary->columnCount();
111 // On ajoute une ligne pour le groupe
112 TWBoundary->insertRow(0);
113 // La colonne 0 comporte le nom du groupe
114 TWBoundary->setItem( 0, 0, new QTableWidgetItem(QString(mesBoundarys[i]).trimmed()));
115 // TWBoundary->item( 0, 0 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable );
116 // Chacune des colonnes suivantes est associé a une frontiere deja presente : on y met une
118 for ( int j = 1; j < nbcol; j++ )
120 TWBoundary->setItem( 0, j, new QTableWidgetItem( QString ("") ) );
121 TWBoundary->item( 0, j )->setFlags( 0 );
122 TWBoundary->item( 0, j )->setFlags( Qt::ItemIsUserCheckable );
123 TWBoundary->item( 0, j )->setCheckState( Qt::Unchecked );
125 // On cherche si la frontiere en cours d'examen a deja ete rencontree :
126 // si oui, on stocke son numero de colonne
128 for ( int nufr = 0 ; nufr<ListeFron.size(); nufr++)
129 { if ( ListeFron[nufr] == NomFron ) ok = nufr+1 ; }
130 // si non, on ajoute une colonne
133 ListeFron.append(NomFron);
134 ok = ListeFron.size() ;
135 AddBoundaryAn(NomFron);
137 // on coche la case correspondant au couple (frontiere,groupe) en cours d'examen
138 TWBoundary->item( 0, ok )->setCheckState( Qt::Checked );
141 MESSAGE("BounDi "<<BounDi<<", BounAn "<<BounAn);
143 { GBBoundaryA->setVisible(1);
144 // On rend les cases non modifiables.
145 // On ne peut pas le faire pour tout le tableau sinon on perd l'ascenseur !
146 int nbcol = TWBoundary->columnCount();
147 int nbrow = TWBoundary->rowCount();
148 for ( int i = 0; i < nbrow; i++ )
149 { for ( int j = 0; j < nbcol; j++ ) TWBoundary->item( i, j )->setFlags( Qt::ItemIsSelectable ); }
150 // on met un nom blanc au coin
151 QTableWidgetItem *__colItem = new QTableWidgetItem();
152 __colItem->setText(QApplication::translate("CreateCase", "", 0));
153 TWBoundary->setHorizontalHeaderItem(0, __colItem);
154 // on cache les boutons inutiles
155 PBBoundaryAnNew->setVisible(0);
156 PBBoundaryAnHelp->setVisible(0);
159 { GBBoundaryD->setVisible(1);
160 CBBoundaryDi->setDisabled(true);
161 PBBoundaryDiNew->setVisible(0);
162 PBBoundaryDiHelp->setVisible(0); }
165 // Les options avancees (non modifiables)
166 CBAdvanced->setVisible(0) ;
167 CBAdvanced->setEnabled(false) ;
168 int Pyram = aCase->GetPyram();
169 MESSAGE("Pyram "<<Pyram);
170 if ( ( Pyram > 0 ) || ( ConfType < 0 ) || ( ConfType > 1 ) || ( ExtType > 0 ) )
171 { GBAdvancedOptions->setVisible(1);
174 { CBPyramid->setChecked(true);
175 CBPyramid->setVisible(1);
178 { CBPyramid->setChecked(false);
179 CBPyramid->setVisible(0);
181 CBPyramid->setEnabled(false);
183 if ( ( ConfType == 0 ) || ( ConfType == -1 ) )
184 { if ( ConfType == 0 ) { RBStandard->setChecked(true); }
185 else { RBBox->setChecked(true); }
186 RBStandard->setVisible(1);
187 RBBox->setVisible(1);
188 RBNC1NpA->setVisible(0);
189 RBNCQuelconque->setVisible(0);
192 { if (ConfType==-2) { RBBox->setChecked(true);};
193 if (ConfType==1) { RBStandard->setChecked(true);};
194 if (ConfType==2) { RBNC1NpA->setChecked(true);};
195 if (ConfType==3) { RBNCQuelconque->setChecked(true);};
196 RBStandard->setVisible(1);
197 RBBox->setVisible(1);
198 RBNC1NpA->setVisible(1);
199 RBNCQuelconque->setVisible(1);
201 RBStandard->setEnabled(false);
202 RBBox->setEnabled(false);
203 RBNC1NpA->setEnabled(false);
204 RBNCQuelconque->setEnabled(false);
207 { GBFormat->setVisible(0);
208 RBMED->setChecked(true);
211 { GBFormat->setVisible(1);
212 RBMED->setVisible(1);
213 RBSaturne->setVisible(1);
214 RBSaturne2D->setVisible(1);
215 if ( ExtType == 1 ) { RBSaturne->setChecked(true); }
216 else { RBSaturne2D->setChecked(true); }
218 RBMED->setEnabled(false);
219 RBSaturne->setEnabled(false);
220 RBSaturne2D->setEnabled(false);
223 { GBAdvancedOptions->setVisible(0);
224 CBPyramid->setChecked(false);
225 RBStandard->setChecked(true);
226 RBMED->setChecked(true);
230 int etat = aCase->GetState();
231 MESSAGE("etat "<<etat);
232 if ( etat == 0 ) { Comment->setText(QApplication::translate("CreateCase", "HOM_CASE_EDIT_STATE_0", 0)); }
233 else { Comment->setText(QApplication::translate("CreateCase", "HOM_CASE_EDIT_STATE", 0)); }
235 Comment->setVisible(1);
240 // -------------------------------------
241 bool MonEditCase::PushOnApply()
242 // -------------------------------------