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 ( bool modal,
36 HOMARD::HOMARD_Gen_var myHomardGen,
38 MonCreateCase(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 LEName->setText(_aCaseName);
57 LEName->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 RBConforme->setChecked(true);
75 GBTypeNoConf->setVisible(0);
79 RBNonConforme->setChecked(true);
80 GBTypeNoConf->setVisible(1);
81 if (ConfType==2) { RB1NpM->setChecked(true);};
82 if (ConfType==3) { RB1NpA->setChecked(true);};
83 if (ConfType==4) { RBQuelconque->setChecked(true);};
84 RB1NpM->setEnabled(false);
85 RB1NpA->setEnabled(false);
86 RBQuelconque->setEnabled(false);
89 RBConforme->setEnabled(false);
90 RBNonConforme->setEnabled(false);
92 // Non affichage du mode de suivi de frontiere
93 CBBoundaryA->setVisible(0);
94 GBBoundaryA->setVisible(0);
95 CBBoundaryD->setVisible(0);
96 GBBoundaryD->setVisible(0);
98 // On passe en revue tous les couples (frontiere,groupe) du cas
99 HOMARD::ListBoundaryGroupType_var mesBoundarys = aCase->GetBoundaryGroup();
100 if (mesBoundarys->length()>0)
102 QStringList ListeFron ;
104 bool BounDi = false ;
105 bool BounAn = false ;
106 for (int i=0; i<mesBoundarys->length(); i++)
108 // Nom de la frontiere
109 NomFron = mesBoundarys[i++];
110 MESSAGE("NomFron "<<NomFron.toStdString().c_str());
111 // L'objet associe pour en deduire le type
112 HOMARD::HOMARD_Boundary_var myBoundary = myHomardGen->GetBoundary(NomFron.toStdString().c_str());
113 int type_obj = myBoundary->GetType() ;
114 // C'est une frontiere discrete
115 // Rermarque : on ne gere pas les groupes
119 CBBoundaryDi->addItem(NomFron);
121 // C'est une frontiere analytique
125 int nbcol = TWBoundary->columnCount();
126 // On ajoute une ligne pour le groupe
127 TWBoundary->insertRow(0);
128 // La colonne 0 comporte le nom du groupe
129 TWBoundary->setItem( 0, 0, new QTableWidgetItem(QString(mesBoundarys[i]).trimmed()));
130 // TWBoundary->item( 0, 0 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable );
131 // Chacune des colonnes suivantes est associƩ a une frontiere deja presente : on y met une
133 for ( int j = 1; j < nbcol; j++ )
135 TWBoundary->setItem( 0, j, new QTableWidgetItem( QString ("") ) );
136 TWBoundary->item( 0, j )->setFlags( 0 );
137 TWBoundary->item( 0, j )->setFlags( Qt::ItemIsUserCheckable );
138 TWBoundary->item( 0, j )->setCheckState( Qt::Unchecked );
140 // On cherche si la frontiere en cours d'examen a deja ete rencontree :
141 // si oui, on stocke son numero de colonne
143 for ( int nufr = 0 ; nufr<ListeFron.size(); nufr++)
144 { if ( ListeFron[nufr] == NomFron ) ok = nufr+1 ; }
145 // si non, on ajoute une colonne
148 ListeFron.append(NomFron);
149 ok = ListeFron.size() ;
150 AddBoundaryAn(NomFron);
152 // on coche la case correspondant au couple (frontiere,groupe) en cours d'examen
153 TWBoundary->item( 0, ok )->setCheckState( Qt::Checked );
156 MESSAGE("BounDi "<<BounDi<<", BounAn "<<BounAn);
158 { GBBoundaryA->setVisible(1);
159 // On rend les cases non modifiables.
160 // On ne peut pas le faire pour tout le tableau sinon on perd l'ascenseur !
161 int nbcol = TWBoundary->columnCount();
162 int nbrow = TWBoundary->rowCount();
163 for ( int i = 0; i < nbrow; i++ )
164 { for ( int j = 0; j < nbcol; j++ ) TWBoundary->item( i, j )->setFlags( Qt::ItemIsSelectable ); }
165 // on met un nom blanc au coin
166 QTableWidgetItem *__colItem = new QTableWidgetItem();
167 __colItem->setText(QApplication::translate("CreateCase", "", 0, QApplication::UnicodeUTF8));
168 TWBoundary->setHorizontalHeaderItem(0, __colItem);
169 // on cache les boutons inutiles
170 PBBoundaryAnNew->setVisible(0);
171 PBBoundaryAnHelp->setVisible(0);
174 { GBBoundaryD->setVisible(1);
175 CBBoundaryDi->setDisabled(true);
176 PBBoundaryDiNew->setVisible(0);
177 PBBoundaryDiHelp->setVisible(0); }
180 // Les options avancees (non modifiables)
181 CBAdvanced->setVisible(0) ;
182 CBAdvanced->setEnabled(false) ;
183 int Pyram = aCase->GetPyram();
184 MESSAGE("Pyram "<<Pyram);
186 { GBAdvancedOptions->setVisible(1);
187 CBPyramid->setChecked(true);
188 CBPyramid->setEnabled(false);
191 { GBAdvancedOptions->setVisible(0);
192 CBPyramid->setChecked(false);
196 int etat = aCase->GetState();
197 MESSAGE("etat "<<etat);
198 if ( etat == 0 ) { Comment->setText(QApplication::translate("CreateCase", "HOM_CASE_EDIT_STATE_0", 0, QApplication::UnicodeUTF8)); }
199 else { Comment->setText(QApplication::translate("CreateCase", "HOM_CASE_EDIT_STATE", 0, QApplication::UnicodeUTF8)); }
201 Comment->setVisible(1);
206 // -------------------------------------
207 bool MonEditCase::PushOnApply()
208 // -------------------------------------