1 // Copyright (C) 2011-2013 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.
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
22 #include "MonEditCase.h"
24 #include "SalomeApp_Tools.h"
25 #include "HOMARDGUI_Utils.h"
26 #include "HomardQtCommun.h"
27 #include <utilities.h>
30 // -------------------------------------------------------------
31 /* Constructs a MonEditCase
32 herite de MonCreateCase
34 // -------------------------------------------------------------
35 MonEditCase::MonEditCase ( QWidget* parent, bool modal,
36 HOMARD::HOMARD_Gen_var myHomardGen,
38 MonCreateCase(parent, modal, myHomardGen)
40 MESSAGE("Debut de MonEditCase" << CaseName.toStdString().c_str());
41 setWindowTitle(QObject::tr("HOM_CASE_EDIT_WINDOW_TITLE"));
42 _aCaseName = CaseName;
43 aCase = _myHomardGen->GetCase(_aCaseName.toStdString().c_str());
46 // ------------------------------
47 MonEditCase::~MonEditCase()
48 // ------------------------------
51 // ------------------------------
52 void MonEditCase::InitValEdit()
53 // ------------------------------
55 MESSAGE("InitValEdit");
56 LECaseName->setText(_aCaseName);
57 LECaseName->setReadOnly(true);
59 QString aDirName = aCase->GetDirName();
60 LEDirName->setText(aDirName);
61 LEDirName->setReadOnly(true);
62 PushDir->setVisible(0);
64 QString _aitername=aCase->GetIter0Name();
65 HOMARD::HOMARD_Iteration_var aIter = _myHomardGen->GetIteration(_aitername.toStdString().c_str());
66 QString aFileName = aIter->GetMeshFile();
67 LEFileName->setText(aFileName);
68 LEFileName->setReadOnly(true);
69 PushFichier->setVisible(0);
71 int ConfType=aCase->GetConfType();
74 GBTypeNoConf->setVisible(0);
75 RBConforme->setChecked(true);
79 RBNonConforme->setChecked(true);
80 GBTypeNoConf->setVisible(1);
81 RB1NpM->setEnabled(false);
82 RB1NpA->setEnabled(false);
83 RBQuelconque->setEnabled(false);
86 if (_ConfType==2) { RB1NpM->setChecked(true);};
87 if (_ConfType==3) { RB1NpA->setChecked(true);};
88 if (_ConfType==4) { RBQuelconque->setChecked(true);};
90 RBNonConforme->setEnabled(false);
91 RBConforme->setEnabled(false);
93 // Non affichage du mode de suivi de frontiere
94 CBBoundaryA->setVisible(0);
95 GBBoundaryA->setVisible(0);
96 CBBoundaryD->setVisible(0);
97 GBBoundaryD->setVisible(0);
99 // On passe en revue tous les couples (frontiere,groupe) du cas
100 HOMARD::ListBoundaryGroupType_var mesBoundarys = aCase->GetBoundaryGroup();
101 if (mesBoundarys->length()>0)
103 QStringList ListeFron ;
105 bool BounDi = false ;
106 bool BounAn = false ;
107 for (int i=0; i<mesBoundarys->length(); i++)
109 // Nom de la frontiere
110 NomFron = mesBoundarys[i++];
111 MESSAGE("NomFron "<<NomFron.toStdString().c_str());
112 // L'objet associe pour en deduire le type
113 HOMARD::HOMARD_Boundary_var myBoundary = _myHomardGen->GetBoundary(NomFron.toStdString().c_str());
114 int type_obj = myBoundary->GetType() ;
115 // C'est une frontiere discrete
116 // Rermarque : on ne gere pas les groupes
120 CBBoundaryDi->addItem(NomFron);
122 // C'est une frontiere analytique
126 int nbcol = TWBoundary->columnCount();
127 // On ajoute une ligne pour le groupe
128 TWBoundary->insertRow(0);
129 // La colonne 0 comporte le nom du groupe
130 TWBoundary->setItem( 0, 0, new QTableWidgetItem(QString(mesBoundarys[i]).trimmed()));
131 // TWBoundary->item( 0, 0 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable );
132 // Chacune des colonnes suivantes est associé a une frontiere deja presente : on y met une
134 for ( int j = 1; j < nbcol; j++ )
136 TWBoundary->setItem( 0, j, new QTableWidgetItem( QString ("") ) );
137 TWBoundary->item( 0, j )->setFlags( 0 );
138 TWBoundary->item( 0, j )->setFlags( Qt::ItemIsUserCheckable );
139 TWBoundary->item( 0, j )->setCheckState( Qt::Unchecked );
141 // On cherche si la frontiere en cours d'examen a deja ete rencontree :
142 // si oui, on stocke son numero de colonne
144 for ( int nufr = 0 ; nufr<ListeFron.size(); nufr++)
145 { if ( ListeFron[nufr] == NomFron ) ok = nufr+1 ; }
146 // si non, on ajoute une colonne
149 ListeFron.append(NomFron);
150 ok = ListeFron.size() ;
151 AddBoundaryAn(NomFron);
153 // on coche la case correspondant au couple (frontiere,groupe) en cours d'examen
154 TWBoundary->item( 0, ok )->setCheckState( Qt::Checked );
157 MESSAGE("BounDi "<<BounDi<<", BounAn "<<BounAn);
159 { GBBoundaryA->setVisible(1);
160 // On rend les cases non modifiables.
161 // On ne peut pas le faire pour tout le tableau sinon on perd l'ascenseur !
162 int nbcol = TWBoundary->columnCount();
163 int nbrow = TWBoundary->rowCount();
164 for ( int i = 0; i < nbrow; i++ )
165 { for ( int j = 0; j < nbcol; j++ ) TWBoundary->item( i, j )->setFlags( Qt::ItemIsSelectable ); }
166 // on met un nom blanc au coin
167 QTableWidgetItem *__colItem = new QTableWidgetItem();
168 __colItem->setText(QApplication::translate("CreateCase", "", 0, QApplication::UnicodeUTF8));
169 TWBoundary->setHorizontalHeaderItem(0, __colItem);
170 // on cache les boutons inutiles
171 PBBoundaryAnNew->setVisible(0);
172 PBBoundaryAnHelp->setVisible(0);
175 { GBBoundaryD->setVisible(1);
176 CBBoundaryDi->setDisabled(true);
177 PBBoundaryDiNew->setVisible(0);
178 PBBoundaryDiHelp->setVisible(0); }
181 // Les options avancees (non modifiables)
182 CBAdvanced->setVisible(0) ;
183 CBAdvanced->setEnabled(false) ;
184 int Pyram = aCase->GetPyram();
185 MESSAGE("Pyram "<<Pyram);
187 { GBAdvancedOptions->setVisible(1);
188 CBPyramid->setChecked(true);
189 CBPyramid->setEnabled(false);
192 { GBAdvancedOptions->setVisible(0);
193 CBPyramid->setChecked(false);
197 int etat = aCase->GetState();
198 MESSAGE("etat "<<etat);
199 if ( etat == 0 ) { Comment->setText(QApplication::translate("CreateCase", "HOM_CASE_EDIT_STATE_0", 0, QApplication::UnicodeUTF8)); }
200 else { Comment->setText(QApplication::translate("CreateCase", "HOM_CASE_EDIT_STATE", 0, QApplication::UnicodeUTF8)); }
202 Comment->setVisible(1);
207 // -------------------------------------
208 bool MonEditCase::PushOnApply()
209 // -------------------------------------