1 // Copyright (C) 2011-2015 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);
76 // Non affichage du mode de suivi de frontiere
77 CBBoundaryA->setVisible(0);
78 GBBoundaryA->setVisible(0);
79 CBBoundaryD->setVisible(0);
80 GBBoundaryD->setVisible(0);
82 // On passe en revue tous les couples (frontiere,groupe) du cas
83 HOMARD::ListBoundaryGroupType_var mesBoundarys = aCase->GetBoundaryGroup();
84 if (mesBoundarys->length()>0)
86 QStringList ListeFron ;
90 for (int i=0; i<mesBoundarys->length(); i++)
92 // Nom de la frontiere
93 NomFron = mesBoundarys[i++];
94 MESSAGE("NomFron "<<NomFron.toStdString().c_str());
95 // L'objet associe pour en deduire le type
96 HOMARD::HOMARD_Boundary_var myBoundary = myHomardGen->GetBoundary(NomFron.toStdString().c_str());
97 int type_obj = myBoundary->GetType() ;
98 // C'est une frontiere discrete
99 // Rermarque : on ne gere pas les groupes
103 CBBoundaryDi->addItem(NomFron);
105 // C'est une frontiere analytique
109 int nbcol = TWBoundary->columnCount();
110 // On ajoute une ligne pour le groupe
111 TWBoundary->insertRow(0);
112 // La colonne 0 comporte le nom du groupe
113 TWBoundary->setItem( 0, 0, new QTableWidgetItem(QString(mesBoundarys[i]).trimmed()));
114 // TWBoundary->item( 0, 0 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable );
115 // Chacune des colonnes suivantes est associé a une frontiere deja presente : on y met une
117 for ( int j = 1; j < nbcol; j++ )
119 TWBoundary->setItem( 0, j, new QTableWidgetItem( QString ("") ) );
120 TWBoundary->item( 0, j )->setFlags( 0 );
121 TWBoundary->item( 0, j )->setFlags( Qt::ItemIsUserCheckable );
122 TWBoundary->item( 0, j )->setCheckState( Qt::Unchecked );
124 // On cherche si la frontiere en cours d'examen a deja ete rencontree :
125 // si oui, on stocke son numero de colonne
127 for ( int nufr = 0 ; nufr<ListeFron.size(); nufr++)
128 { if ( ListeFron[nufr] == NomFron ) ok = nufr+1 ; }
129 // si non, on ajoute une colonne
132 ListeFron.append(NomFron);
133 ok = ListeFron.size() ;
134 AddBoundaryAn(NomFron);
136 // on coche la case correspondant au couple (frontiere,groupe) en cours d'examen
137 TWBoundary->item( 0, ok )->setCheckState( Qt::Checked );
140 MESSAGE("BounDi "<<BounDi<<", BounAn "<<BounAn);
142 { GBBoundaryA->setVisible(1);
143 // On rend les cases non modifiables.
144 // On ne peut pas le faire pour tout le tableau sinon on perd l'ascenseur !
145 int nbcol = TWBoundary->columnCount();
146 int nbrow = TWBoundary->rowCount();
147 for ( int i = 0; i < nbrow; i++ )
148 { for ( int j = 0; j < nbcol; j++ ) TWBoundary->item( i, j )->setFlags( Qt::ItemIsSelectable ); }
149 // on met un nom blanc au coin
150 QTableWidgetItem *__colItem = new QTableWidgetItem();
151 __colItem->setText(QApplication::translate("CreateCase", "", 0, QApplication::UnicodeUTF8));
152 TWBoundary->setHorizontalHeaderItem(0, __colItem);
153 // on cache les boutons inutiles
154 PBBoundaryAnNew->setVisible(0);
155 PBBoundaryAnHelp->setVisible(0);
158 { GBBoundaryD->setVisible(1);
159 CBBoundaryDi->setDisabled(true);
160 PBBoundaryDiNew->setVisible(0);
161 PBBoundaryDiHelp->setVisible(0); }
164 // Les options avancees (non modifiables)
165 CBAdvanced->setVisible(0) ;
166 CBAdvanced->setEnabled(false) ;
167 int Pyram = aCase->GetPyram();
168 MESSAGE("Pyram "<<Pyram);
169 if ( ( Pyram > 0 ) || ( ConfType < 0 ) || ( ConfType > 1 ) )
170 { GBAdvancedOptions->setVisible(1);
172 { CBPyramid->setChecked(true);
173 CBPyramid->setEnabled(false);
176 { CBPyramid->setChecked(false);
177 CBPyramid->setVisible(0);
179 if ( ( ConfType == 0 ) || ( ConfType == -1 ) )
180 { if ( ConfType == 0 ) { RBStandard->setChecked(true); }
181 else { RBBox->setChecked(true); }
182 RBStandard->setVisible(1);
183 RBBox->setVisible(1);
184 RBNC1NpA->setVisible(0);
185 RBNCQuelconque->setVisible(0);
186 RBStandard->setEnabled(false);
187 RBBox->setEnabled(false);
190 { if (ConfType==-2) { RBBox->setChecked(true);};
191 if (ConfType==1) { RBStandard->setChecked(true);};
192 if (ConfType==2) { RBNC1NpA->setChecked(true);};
193 if (ConfType==3) { RBNCQuelconque->setChecked(true);};
194 RBStandard->setVisible(1);
195 RBBox->setVisible(1);
196 RBNC1NpA->setVisible(1);
197 RBNCQuelconque->setVisible(1);
198 RBStandard->setEnabled(false);
199 RBBox->setEnabled(false);
200 RBNC1NpA->setEnabled(false);
201 RBNCQuelconque->setEnabled(false);
205 { GBAdvancedOptions->setVisible(0);
206 CBPyramid->setChecked(false);
210 int etat = aCase->GetState();
211 MESSAGE("etat "<<etat);
212 if ( etat == 0 ) { Comment->setText(QApplication::translate("CreateCase", "HOM_CASE_EDIT_STATE_0", 0, QApplication::UnicodeUTF8)); }
213 else { Comment->setText(QApplication::translate("CreateCase", "HOM_CASE_EDIT_STATE", 0, QApplication::UnicodeUTF8)); }
215 Comment->setVisible(1);
220 // -------------------------------------
221 bool MonEditCase::PushOnApply()
222 // -------------------------------------