]> SALOME platform Git repositories - modules/homard.git/blob - src/HOMARDGUI/MonEditCase.cxx
Salome HOME
7fcc792f345cc8afc18b6c04ed3ead4818d97fa3
[modules/homard.git] / src / HOMARDGUI / MonEditCase.cxx
1 // Copyright (C) 2011-2015  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "MonEditCase.h"
21
22 #include "SalomeApp_Tools.h"
23 #include "HOMARDGUI_Utils.h"
24 #include "HomardQtCommun.h"
25 #include <utilities.h>
26
27 using namespace std;
28
29 // -------------------------------------------------------------
30 /* Constructs a MonEditCase
31     herite de MonCreateCase
32 */
33 // -------------------------------------------------------------
34 MonEditCase::MonEditCase ( bool modal,
35                            HOMARD::HOMARD_Gen_var myHomardGen,
36                            QString CaseName ):
37    MonCreateCase(modal, myHomardGen)
38 {
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());
43     InitValEdit();
44 }
45 // ------------------------------
46 MonEditCase::~MonEditCase()
47 // ------------------------------
48 {
49 }
50 // ------------------------------
51 void MonEditCase::InitValEdit()
52 // ------------------------------
53 {
54   MESSAGE("InitValEdit");
55   LEName->setText(_aCaseName);
56   LEName->setReadOnly(true);
57
58   QString aDirName = aCase->GetDirName();
59   LEDirName->setText(aDirName);
60   LEDirName->setReadOnly(true);
61   PushDir->setVisible(0);
62
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);
69
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
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);
81
82 //    On passe en revue tous les couples (frontiere,groupe) du cas
83   HOMARD::ListBoundaryGroupType_var mesBoundarys = aCase->GetBoundaryGroup();
84   if (mesBoundarys->length()>0)
85   {
86     QStringList ListeFron ;
87     QString NomFron ;
88     bool BounDi = false ;
89     bool BounAn = false ;
90     for (int i=0; i<mesBoundarys->length(); i++)
91     {
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
100       if ( type_obj==0 )
101       {
102         BounDi = true ;
103         CBBoundaryDi->addItem(NomFron);
104       }
105 //        C'est une frontiere analytique
106       else
107       {
108         BounAn = true ;
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
116 //          case non cochee
117         for ( int j = 1; j < nbcol; j++ )
118         {
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 );
123         }
124 //          On cherche si la frontiere en cours d'examen a deja ete rencontree :
125 //          si oui, on stocke son numero de colonne
126         int ok = -1 ;
127         for ( int nufr = 0 ; nufr<ListeFron.size(); nufr++)
128         { if ( ListeFron[nufr] == NomFron ) ok = nufr+1 ; }
129 //            si non, on ajoute une colonne
130         if ( ok < 0 )
131         {
132           ListeFron.append(NomFron);
133           ok = ListeFron.size() ;
134           AddBoundaryAn(NomFron);
135         }
136 //          on coche la case correspondant au couple (frontiere,groupe) en cours d'examen
137         TWBoundary->item( 0, ok )->setCheckState( Qt::Checked );
138       }
139     }
140     MESSAGE("BounDi "<<BounDi<<", BounAn "<<BounAn);
141     if ( 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);
156     }
157     if ( BounDi )
158     { GBBoundaryD->setVisible(1);
159       CBBoundaryDi->setDisabled(true);
160       PBBoundaryDiNew->setVisible(0);
161       PBBoundaryDiHelp->setVisible(0); }
162   }
163 //
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);
171     if ( Pyram > 0 )
172     { CBPyramid->setChecked(true);
173       CBPyramid->setEnabled(false);
174     }
175     else
176     { CBPyramid->setChecked(false);
177       CBPyramid->setVisible(0);
178     }
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);
188     }
189     else
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);
202     }
203   }
204   else
205   { GBAdvancedOptions->setVisible(0);
206     CBPyramid->setChecked(false);
207   }
208 //
209 // L'etat
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)); }
214
215   Comment->setVisible(1);
216 //
217   adjustSize();
218 }
219
220 // -------------------------------------
221 bool MonEditCase::PushOnApply()
222 // -------------------------------------
223 {
224   return true ;
225 };