1 // Copyright (C) 2011-2012 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 MonEditCase::MonEditCase ( QWidget* parent, bool modal,
32 HOMARD::HOMARD_Gen_var myHomardGen,
34 // -------------------------------------------------------------
35 /* Constructs a MonEditCase
36 herite de MonCreateCase
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 // ------------------------------
53 // ------------------------------
54 void MonEditCase::InitValEdit()
55 // ------------------------------
57 MESSAGE("InitValEdit");
58 LECaseName->setText(_aCaseName);
59 LECaseName->setReadOnly(true);
61 QString aDirName = aCase->GetDirName();
62 LEDirName->setText(aDirName);
63 LEDirName->setReadOnly(true);
64 PushDir->setVisible(0);
66 QString _aitername=aCase->GetIter0Name();
67 HOMARD::HOMARD_Iteration_var aIter = _myHomardGen->GetIteration(_aitername.toStdString().c_str());
68 QString aFileName = aIter->GetMeshFile();
69 LEFileName->setText(aFileName);
70 LEFileName->setReadOnly(true);
71 PushFichier->setVisible(0);
73 int ConfType=aCase->GetConfType();
76 GBTypeNoConf->setVisible(0);
77 RBConforme->setChecked(true);
81 RBNonConforme->setChecked(true);
82 GBTypeNoConf->setVisible(1);
83 RB1NpM->setEnabled(false);
84 RB1NpA->setEnabled(false);
85 RBQuelconque->setEnabled(false);
88 if (_ConfType==2) { RB1NpM->setChecked(true);};
89 if (_ConfType==3) { RB1NpA->setChecked(true);};
90 if (_ConfType==4) { RBQuelconque->setChecked(true);};
92 RBNonConforme->setEnabled(false);
93 RBConforme->setEnabled(false);
95 // Non affichage du mode de suivi de frontiere
96 CBBoundaryA->setVisible(0);
97 GBBoundaryA->setVisible(0);
98 CBBoundaryD->setVisible(0);
99 GBBoundaryD->setVisible(0);
101 // On passe en revue tous les couples (frontiere,groupe) du cas
102 HOMARD::ListBoundaryGroupType_var mesBoundarys = aCase->GetBoundaryGroup();
103 if (mesBoundarys->length()>0)
105 QStringList ListeFron ;
107 bool BounDi = false ;
108 bool BounAn = false ;
109 for (int i=0; i<mesBoundarys->length(); i++)
111 // Nom de la frontiere
112 NomFron = mesBoundarys[i++];
113 MESSAGE("NomFron "<<NomFron.toStdString().c_str());
114 // L'objet associe pour en deduire le type
115 HOMARD::HOMARD_Boundary_var myBoundary = _myHomardGen->GetBoundary(NomFron.toStdString().c_str());
116 int type_obj = myBoundary->GetType() ;
117 // C'est une frontiere discrete
118 // Rermarque : on ne gere pas les groupes
122 CBBoundaryDi->addItem(NomFron);
124 // C'est une frontiere analytique
128 int nbcol = TWBoundary->columnCount();
129 // On ajoute une ligne pour le groupe
130 TWBoundary->insertRow(0);
131 // La colonne 0 comporte le nom du groupe
132 TWBoundary->setItem( 0, 0, new QTableWidgetItem(QString(mesBoundarys[i]).trimmed()));
133 // TWBoundary->item( 0, 0 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable );
134 // Chacune des colonnes suivantes est associé a une frontiere deja presente : on y met une
136 for ( int j = 1; j < nbcol; j++ )
138 TWBoundary->setItem( 0, j, new QTableWidgetItem( QString ("") ) );
139 TWBoundary->item( 0, j )->setFlags( 0 );
140 TWBoundary->item( 0, j )->setFlags( Qt::ItemIsUserCheckable );
141 TWBoundary->item( 0, j )->setCheckState( Qt::Unchecked );
143 // On cherche si la frontiere en cours d'examen a deja ete rencontree :
144 // si oui, on stocke son numero de colonne
146 for ( int nufr = 0 ; nufr<ListeFron.size(); nufr++)
147 { if ( ListeFron[nufr] == NomFron ) ok = nufr+1 ; }
148 // si non, on ajoute une colonne
151 ListeFron.append(NomFron);
152 ok = ListeFron.size() ;
153 addBoundaryAn(NomFron);
155 // on coche la case correspondant au couple (frontiere,groupe) en cours d'examen
156 TWBoundary->item( 0, ok )->setCheckState( Qt::Checked );
159 MESSAGE("BounDi "<<BounDi<<", BounAn "<<BounAn);
161 { GBBoundaryA->setVisible(1);
162 // On rend les cases non modifiables.
163 // On ne peut pas le faire pour tout le tableau sinon on perd l'ascenseur !
164 int nbcol = TWBoundary->columnCount();
165 int nbrow = TWBoundary->rowCount();
166 for ( int i = 0; i < nbrow; i++ )
167 { for ( int j = 0; j < nbcol; j++ ) TWBoundary->item( i, j )->setFlags( Qt::ItemIsSelectable ); }
168 // on met un nom blanc au coin
169 QTableWidgetItem *__colItem = new QTableWidgetItem();
170 __colItem->setText(QApplication::translate("CreateCase", "", 0, QApplication::UnicodeUTF8));
171 TWBoundary->setHorizontalHeaderItem(0, __colItem);
172 // on cache les boutons inutiles
173 PBBoundaryAnNew->setVisible(0);
174 PBBoundaryAnHelp->setVisible(0);
177 { GBBoundaryD->setVisible(1);
178 CBBoundaryDi->setDisabled(true);
179 PBBoundaryDiNew->setVisible(0);
180 PBBoundaryDiHelp->setVisible(0); }
183 // Les options avancees (non modifiables)
184 CBAdvanced->setVisible(0) ;
185 CBAdvanced->setEnabled(false) ;
186 int Pyram = aCase->GetPyram();
187 MESSAGE("Pyram "<<Pyram);
189 { GBAdvancedOptions->setVisible(1);
190 CBPyramid->setChecked(true);
191 CBPyramid->setEnabled(false);
194 { GBAdvancedOptions->setVisible(0);
195 CBPyramid->setChecked(false);
201 // -------------------------------------
202 bool MonEditCase::PushOnApply()
203 // -------------------------------------