Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYCalculWidget.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) 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.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
14  */
15 
21 #include <qtablewidget.h>
22 #include <qtabwidget.h>
23 #include <qradiobutton.h>
24 #include <qbuttongroup.h>
25 #include <qmenu.h>
26 #include <qstringlist.h>
27 #include <qcombobox.h>
28 // Added by qt3to4:
29 #include <QLabel>
30 #include <QGridLayout>
31 #include <QFrame>
32 #include <QDateEdit>
33 #include <QTextEdit>
34 #include <QTreeWidgetItem>
35 #include <QString>
36 #include <QtWidgets>
37 
38 #include "Tympan/core/config.h"
49 #include "TYCalculWidget.h"
50 #include "TYElementWidget.h"
51 
52 #define TR(id) OLocalizator::getString("TYCalculWidget", (id))
53 
54 TYCalculWidget::TYCalculWidget(TYCalcul* pElement, QWidget* _pParent /*=NULL*/) : TYWidget(pElement, _pParent)
55 {
56  QString num;
57  short iln = 0; // Line number for setting elements up (ease the process when adding a new element)
58 
59  resize(300, 690);
60  setWindowTitle(TR("id_caption"));
61 
62  _calculLayout = new QGridLayout();
63  setLayout(_calculLayout);
64 
65  // Computation current elements
66  _elmW = new TYElementWidget(pElement, this);
67  _calculLayout->addWidget(_elmW, iln++, 0);
68 
69  // LOCK COMPUTATION
70  _buttonGroupState = new QButtonGroup(this);
71  _buttonGroupState->setExclusive(true);
72  _pRadioButtonActif = new QRadioButton(TR("id_actif"));
74  _pRadioButtonLocked = new QRadioButton(TR("id_locked"));
76 
77  QGridLayout* groupBoxStateLayout = new QGridLayout();
78  groupBoxStateLayout->addWidget(_pRadioButtonActif, 0, 0);
79  groupBoxStateLayout->addWidget(_pRadioButtonLocked, 0, 1);
80 
81  QGroupBox* groupBoxState = new QGroupBox();
82  groupBoxState->setTitle(TR("id_etat_calcul"));
83  groupBoxState->setLayout(groupBoxStateLayout);
84 
85  _calculLayout->addWidget(groupBoxState, iln++, 0);
86 
87  // CHOOSE SOLVER METHOD
88  QGroupBox* groupBoxCalcMethod = new QGroupBox(this);
89  groupBoxCalcMethod->setTitle(TR(""));
90  QGridLayout* groupBoxCalcMethodLayout = new QGridLayout();
91  groupBoxCalcMethod->setLayout(groupBoxCalcMethodLayout);
92 
93  QLabel* labelCalcMethod = new QLabel(groupBoxCalcMethod);
94  labelCalcMethod->setText(TR("id_calc_method_label"));
95  groupBoxCalcMethodLayout->addWidget(labelCalcMethod, 0, 0);
96 
97  // 20070913 - suite au plassage aux plugins, changement du combo en une ligne de texte
98  _comboSolver = new QComboBox(groupBoxCalcMethod);
99  _comboSolver->setEditable(false);
100 
101  groupBoxCalcMethodLayout->addWidget(_comboSolver, 0, 1);
102 
103  _calculLayout->addWidget(groupBoxCalcMethod, iln++, 0);
104 
105  // COMPUTATION PARAMETERS
106  _tabWidget = new QTabWidget(this);
107 
108  // Read data model of solver parameters
109  QString dataModelPath(QCoreApplication::applicationDirPath() + "/" + SOLVER_PARAMS_JSON);
110  try
111  {
113 
114  // Parameters tab
116 
117  // Meteo tab
119  }
120  catch (const tympan::invalid_data& exc)
121  {
122  OMessageManager::get()->error(exc.what());
123  }
124 
125  // Ponctual receptors tab
126  _tableauPointControle = new QTableWidget();
127  _tableauPointControle->setColumnCount(5);
128  _tableauPointControle->setHorizontalHeaderItem(0, new QTableWidgetItem(TR("id_nom_pc")));
129  _tableauPointControle->setHorizontalHeaderItem(1, new QTableWidgetItem(TR("id_pos_x")));
130  _tableauPointControle->setHorizontalHeaderItem(2, new QTableWidgetItem(TR("id_pos_y")));
131  _tableauPointControle->setHorizontalHeaderItem(3, new QTableWidgetItem(TR("id_pos_h")));
132  _tableauPointControle->setHorizontalHeaderItem(4, new QTableWidgetItem(TR("id_actif")));
133 
134  _tabWidget->insertTab(_tabWidget->count() + 1, _tableauPointControle, TR("id_opt_pc"));
135 
136  // Surfacic receptors tab
137  _tableauMaillages = new QTableWidget();
138  _tableauMaillages->setColumnCount(2);
139  _tableauMaillages->setHorizontalHeaderItem(0, new QTableWidgetItem(TR("id_nom_pc")));
140  _tableauMaillages->setHorizontalHeaderItem(1, new QTableWidgetItem(TR("id_actif")));
141 
142  _tabWidget->insertTab(_tabWidget->count() + 1, _tableauMaillages, TR("id_opt_maillage"));
143 
144  _calculLayout->addWidget(_tabWidget, iln++, 0);
145 
146  // General informations tab
147 
148  _groupBox = new QGroupBox(_tabWidget);
149 
150  _groupBox->setTitle(TR(""));
151  QGridLayout* groupBoxLayout = new QGridLayout();
152  _groupBox->setLayout(groupBoxLayout);
153 
154  _lineEditAuteur = new QLineEdit(_groupBox);
155  groupBoxLayout->addWidget(_lineEditAuteur, 1, 1);
156 
157  _labelAuteur = new QLabel(_groupBox);
158  _labelAuteur->setText(TR("id_auteur_label"));
159  groupBoxLayout->addWidget(_labelAuteur, 1, 0);
160 
161  QDate date;
162 
163  _editDateCreation = new QDateEdit(_groupBox);
164  if (getElement()->getDateCreation() == "2001-10-01")
165  {
166  getElement()->setDateCreation(date.currentDate().toString(Qt::ISODate));
167  }
168  _editDateCreation->setDate(date.fromString(getElement()->getDateCreation(), Qt::ISODate));
169  groupBoxLayout->addWidget(_editDateCreation, 2, 1);
170 
171  _labelDateCreation = new QLabel(_groupBox);
172  _labelDateCreation->setText(TR("id_datecreation_label"));
173  groupBoxLayout->addWidget(_labelDateCreation, 2, 0);
174 
175  _labelDateModif = new QLabel(_groupBox);
176  _labelDateModif->setText(TR("id_datemodif_label"));
177  groupBoxLayout->addWidget(_labelDateModif, 3, 0);
178 
179  _editDateModif = new QDateEdit(_groupBox);
180  if (getElement()->getDateModif() == "2001-10-01")
181  {
182  getElement()->setDateModif(date.currentDate().toString(Qt::ISODate));
183  }
184  _editDateModif->setDate(date.fromString(getElement()->getDateModif(), Qt::ISODate));
185  groupBoxLayout->addWidget(_editDateModif, 3, 1);
186 
187  _lineEditComment = new QTextEdit(_groupBox);
188  groupBoxLayout->addWidget(_lineEditComment, 5, 0, 1, 2);
189 
190  _labelComment = new QLabel(_groupBox);
191  _labelComment->setText(TR("id_comment_label"));
192  groupBoxLayout->addWidget(_labelComment, 4, 0);
193 
194  _calculLayout->addWidget(_groupBox, iln++, 0);
195 
196  _tabWidget->insertTab(_tabWidget->count() + 1, _groupBox, TR("id_info_calc"));
197 
198  // Button allowing the access to states
199  QGroupBox* pGroupBoxTableEtats = new QGroupBox(this);
200  pGroupBoxTableEtats->setTitle(TR("id_map_box"));
201  QGridLayout* groupBoxTableEtatsLayout = new QGridLayout();
202  pGroupBoxTableEtats->setLayout(groupBoxTableEtatsLayout);
203 
204  QLineEdit* pLineEditNomTableEtats = new QLineEdit(pGroupBoxTableEtats);
205  pLineEditNomTableEtats->setEnabled(false);
206  groupBoxTableEtatsLayout->addWidget(pLineEditNomTableEtats, 0, 0);
207 
208  QPushButton* pPushButtonTableEtats = new QPushButton(pGroupBoxTableEtats);
209  pPushButtonTableEtats->setText(TR("id_proprietes"));
210  groupBoxTableEtatsLayout->addWidget(pPushButtonTableEtats, 0, 1);
211 
212  _calculLayout->addWidget(pGroupBoxTableEtats, iln++, 0);
213 
214  _etatsWidget = new TYEtatsWidget(getElement(), this);
215 
216  // Results
217  _groupBoxResultat = new QGroupBox(this);
218  _groupBoxResultat->setTitle(TR("id_resultat"));
219  QGridLayout* groupBoxResultatLayout = new QGridLayout();
220  _groupBoxResultat->setLayout(groupBoxResultatLayout);
221 
222  // Workaround issue #138
223  // _labelStoreGlobalMatrix = new QLabel(_groupBoxResultat);
224  // _labelStoreGlobalMatrix->setText(TR("id_storeglobalmatrix_label"));
225  // groupBoxResultatLayout->addWidget(_labelStoreGlobalMatrix, 0, 0);
226  //
227  // _checkBoxStoreGlobalMatrix = new QCheckBox(_groupBoxResultat);
228  // _checkBoxStoreGlobalMatrix->setText(TR(""));
229  // groupBoxResultatLayout->addWidget(_checkBoxStoreGlobalMatrix, 0, 1);
230 
231  _pushButtonResultat = new QPushButton(_groupBoxResultat);
232  _pushButtonResultat->setText(TR("id_proprietes"));
233  groupBoxResultatLayout->addWidget(_pushButtonResultat, 0, 2);
234 
235  _calculLayout->addWidget(_groupBoxResultat, iln++, 0);
236 
237  updateContent();
238 
239  connect(pPushButtonTableEtats, &QPushButton::clicked, _etatsWidget, &TYEtatsWidget::show);
240  connect(_pushButtonResultat, &QPushButton::clicked, this, &TYCalculWidget::editResultat);
241 
242  connect(_comboSolver, &QComboBox::currentTextChanged, this, &TYCalculWidget::changeSolverMethod);
243  connect(_pRadioButtonActif, &QRadioButton::clicked, this, &TYCalculWidget::changeCalculState);
244  connect(_pRadioButtonLocked, &QRadioButton::clicked, this, &TYCalculWidget::changeCalculState);
245 }
246 
248 {
249  delete _etatsWidget;
250 }
251 
253 {
254  QString num;
255  QDate date;
256 
257  _elmW->setEnabled(true);
258  _groupBox->setEnabled(true);
259 
260  _elmW->updateContent(); // Affichage du nom du calcul
261 
262  // General infos
263  _editDateModif->setDate(date.currentDate());
264  _editDateCreation->setDate(date.fromString(getElement()->getDateCreation(), Qt::ISODate));
265  _lineEditAuteur->setText(getElement()->getAuteur());
266  _lineEditComment->setPlainText(getElement()->getComment());
267 
268  // Mise a jour de l'etat du calcul
270 
271  // Choix du type de calcul
273 
274  // Workaround issue #138
275  // Keep partial results (or not)
276  // _checkBoxStoreGlobalMatrix->setChecked(getElement()->getStatusPartialResult());
277 
278  // Remplissage du tableau des points de controleet maillages
279  _tableauPointControle->setEnabled(true);
280  _tableauMaillages->setEnabled(true);
281 
282  TYProjet* pProjet = getElement()->getProjet();
283  if (pProjet != NULL)
284  {
285  updateControlPointsTab(pProjet);
286  updateNoiseMapsTab(pProjet);
287  }
288 
289  // initialisation des valeurs des paramètres
290  solverParamsWidgetManager->updateWidgets(getElement()->solverParams);
291 
292  // on force la synchronisation des paramètres et des widgets
293  // pour finaliser l'initialisation de l'IHM
296 }
297 
299 {
300  TYTabLPPointControl& tabPoints = pProjet->getPointsControl();
301  unsigned int nbPoints = static_cast<uint32>(tabPoints.size());
302  _tableauPointControle->setRowCount(nbPoints);
303 
304  QString msg;
305  unsigned int row = 0;
306  for (row = 0; row < nbPoints; row++)
307  {
308  _tableauPointControle->setItem(row, 0, new QTableWidgetItem(tabPoints[row]->getName()));
309 
310  msg = QString(TR("id_cell_posx")).arg(tabPoints[row]->_x, 7, 'f', 1);
311  _tableauPointControle->setItem(row, 1, new QTableWidgetItem(msg));
312 
313  msg = QString(TR("id_cell_posy")).arg(tabPoints[row]->_y, 7, 'f', 1);
314  _tableauPointControle->setItem(row, 2, new QTableWidgetItem(msg));
315 
316  msg = QString(TR("id_cell_posh")).arg(tabPoints[row]->getHauteur(), 7, 'f', 1);
317  _tableauPointControle->setItem(row, 3, new QTableWidgetItem(msg));
318 
319  QTableWidgetItem* pCheckItemActif = new QTableWidgetItem("");
320 
321  if (getElement()->getPtCtrlStatus(tabPoints[row]->getID()))
322  {
323  pCheckItemActif->setCheckState(Qt::Checked);
324  }
325  else
326  {
327  pCheckItemActif->setCheckState(Qt::Unchecked);
328  }
329 
330  _tableauPointControle->setItem(row, 4, pCheckItemActif);
331 
332  _tableauPointControle->setRowHeight(row, 30);
333  }
334 }
335 
337 {
338  int nbPoints = static_cast<uint32>(pProjet->getMaillages().size());
339  _tableauMaillages->setRowCount(nbPoints);
340 
341  LPTYMaillage pMaillage = NULL;
342 
343  for (int row = 0; row < nbPoints; row++)
344  {
345  pMaillage = pProjet->getMaillage(row);
346  _tableauMaillages->setItem(row, 0, new QTableWidgetItem(pMaillage->getName()));
347 
348  QTableWidgetItem* pCheckItemActif = new QTableWidgetItem("");
349  if (pMaillage->etat(getElement()) == true)
350  {
351  pCheckItemActif->setCheckState(Qt::Checked);
352  }
353  else
354  {
355  pCheckItemActif->setCheckState(Qt::Unchecked);
356  }
357  _tableauMaillages->setItem(row, 1, pCheckItemActif);
358 
359  _tableauMaillages->setRowHeight(row, 30);
360  }
361 }
362 
364 {
365  OGenID currentId = getElement()->getSolverId(); // Id du solveur courant
366 
368  TYPluginManager::TYPluginList& plugList = pPlug->getPluginList();
369  TYPluginManager::TYPluginList::iterator iter;
370 
371  QString solverName;
372  unsigned short i = 0, currentSolverIndex = 0;
373  OGenID id;
374  for (iter = plugList.begin(), i = 0; iter != plugList.end(); iter++, i++)
375  {
376  solverName = (*iter)->getPlugin()->getName();
377  _comboSolver->insertItem(i, solverName);
378 
379  if ((*iter)->getPlugin()->getUUID() == currentId)
380  {
381  currentSolverIndex = i;
382  }
383  }
384 
385  // On affiche le regime courant
386  _comboSolver->setCurrentIndex(currentSolverIndex);
387 }
388 
390 {
391  if (getElement()->getState() == TYCalcul::Actif)
392  {
393  _pRadioButtonActif->setChecked(true);
394  _pRadioButtonLocked->setChecked(false);
395  }
396  else
397  {
398  _pRadioButtonActif->setChecked(false);
399  _pRadioButtonLocked->setChecked(true);
400  }
401 }
402 
404 {
405  solverParamsWidgetManager->getWidget("UseRealGround")->setEnabled(pEnable);
406  solverParamsWidgetManager->getWidget("UseScreen")->setEnabled(pEnable);
407  solverParamsWidgetManager->getWidget("UseReflection")->setEnabled(pEnable);
408  solverParamsWidgetManager->getWidget("PropaConditions")->setEnabled(pEnable);
409  solverParamsWidgetManager->getWidget("ModSummation")->setEnabled(pEnable);
410  solverParamsWidgetManager->getWidget("UseLateralDiffraction")->setEnabled(pEnable);
411  solverParamsWidgetManager->getWidget("AngleFavorable")->setEnabled(pEnable);
412  solverParamsWidgetManager->getWidget("DSWindDirection")->setEnabled(pEnable);
413  solverParamsWidgetManager->getWidget("MinSRDistance")->setEnabled(pEnable);
414  solverParamsWidgetManager->getWidget("KeepRays")->setEnabled(pEnable);
415 }
416 
417 void TYCalculWidget::_enableDisableDefaultSolverWidgets(bool pIsDefaultSolverSelected)
418 {
419  solverParamsWidgetManager->getWidget("UseRealGround")->setEnabled(pIsDefaultSolverSelected);
420  solverParamsWidgetManager->getWidget("UseScreen")->setEnabled(pIsDefaultSolverSelected);
421  solverParamsWidgetManager->getWidget("UseReflection")->setEnabled(pIsDefaultSolverSelected);
422  solverParamsWidgetManager->getWidget("PropaConditions")->setEnabled(pIsDefaultSolverSelected);
423  solverParamsWidgetManager->getWidget("ModSummation")->setEnabled(pIsDefaultSolverSelected);
424  solverParamsWidgetManager->getWidget("UseLateralDiffraction")->setEnabled(pIsDefaultSolverSelected);
425  solverParamsWidgetManager->getWidget("AngleFavorable")->setEnabled(pIsDefaultSolverSelected);
426  solverParamsWidgetManager->getWidget("DSWindDirection")->setEnabled(pIsDefaultSolverSelected);
427 }
428 
430 {
431 
432  _paramsTabWidget = new QWidget();
433  QGridLayout* tabLayout = new QGridLayout();
434  _paramsTabWidget->setLayout(tabLayout);
435  try
436  {
437  // agencement des widgets
438  // 1ere colonne
439  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("UseRealGround"), 1, 0, 1, 2);
440  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("UseScreen"), 2, 0, 1, 1);
441  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("UseReflection"), 3, 0, 1, 1);
442  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("PropaConditions"), 4, 0, 1, 2);
443  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("ModSummation"), 5, 0, 1, 2);
444  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("MinSRDistance"), 6, 0, 1, 2);
445 
446  // 2eme colonne
447  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("UseLateralDiffraction"), 2, 2, 1, 1);
448  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("H1parameter"), 4, 2, 1, 1);
449  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("KeepRays"), 5, 2, 1, 1);
450 
451  // on recupere les widgets qui necessitent une interactivite particuliere
452  QCheckBox* useReflectionCheckBox =
453  ((TYSolverParamsCheckBoxWidget*)solverParamsWidgetManager->getWidget("UseReflection"))->checkBox;
454  QCheckBox* useLateralDiffCheckBox =
456  ->checkBox;
457  QCheckBox* useScreenCheckBox =
459 
460  // activation/desactivation des reflexions et des diffractions lateral lorsque la prise en compte des
461  // ecrans change
462  connect(useScreenCheckBox, &QCheckBox::toggled, useReflectionCheckBox, &QCheckBox::setEnabled);
463  connect(useScreenCheckBox, &QCheckBox::toggled, useLateralDiffCheckBox, &QCheckBox::setEnabled);
464 
465  // desactivation des reflexions a la desactivation des ecrans
466  auto uncheck_reflection_if_not_use_screen = [useScreenCheckBox, useReflectionCheckBox](bool clicked)
467  {
468  if (!useScreenCheckBox->isChecked())
469  useReflectionCheckBox->setChecked(false);
470  };
471  connect(useScreenCheckBox, &QCheckBox::toggled, useReflectionCheckBox,
472  uncheck_reflection_if_not_use_screen);
473 
474  // activation des diffractions laterales lors a l'activation des reflexions
475  auto check_lateral_diffractions = [useLateralDiffCheckBox](bool clicked)
476  { useLateralDiffCheckBox->setChecked(true); };
477  connect(useReflectionCheckBox, &QCheckBox::clicked, useLateralDiffCheckBox,
478  check_lateral_diffractions);
479 
480  solverParamsWidgetManager->getWidget("H1parameter")->setDisabled(true);
481  }
482  catch (const tympan::invalid_data& exc)
483  {
484  std::ostringstream msg;
485  msg << TR("id_solver_param_tab_err").toStdString() << " " << TR("id_opt_calc").toStdString() << ": "
486  << exc.what();
487  OMessageManager::get()->error(msg.str().c_str());
488  }
489 
490  _paramsTabWidget->layout()->setAlignment(Qt::AlignTop);
491  _tabWidget->insertTab(0, _paramsTabWidget, TR("id_opt_calc"));
492 }
493 
495 {
496  _meteoTabWidget = new QWidget();
497  QGridLayout* tabLayout = new QGridLayout();
498  _meteoTabWidget->setLayout(tabLayout);
499 
500  QGroupBox* atmosGroupBox = new QGroupBox(TR("id_atmos_box"), _meteoTabWidget);
501  QGridLayout* atmosGroupBoxLayout = new QGridLayout(atmosGroupBox);
502  atmosGroupBox->setLayout(atmosGroupBoxLayout);
503  atmosGroupBoxLayout->setColumnStretch(2, 1);
504 
505  QGroupBox* windGroupBox = new QGroupBox(TR("id_wind_box"), _meteoTabWidget);
506  QGridLayout* windGroupBoxLayout = new QGridLayout(windGroupBox);
507  windGroupBox->setLayout(windGroupBoxLayout);
508  windGroupBoxLayout->setColumnStretch(2, 1);
509 
510  try
511  {
512  atmosGroupBoxLayout->addWidget(solverParamsWidgetManager->makeWidget("AtmosPressure"), 0, 0);
513  atmosGroupBoxLayout->addWidget(new QLabel(TR("id_unite_pression")), 0, 1, Qt::AlignLeft);
514 
515  atmosGroupBoxLayout->addWidget(solverParamsWidgetManager->makeWidget("AtmosTemperature"), 1, 0);
516  atmosGroupBoxLayout->addWidget(new QLabel(TR("id_unite_temp")), 1, 1, Qt::AlignLeft);
517 
518  atmosGroupBoxLayout->addWidget(solverParamsWidgetManager->makeWidget("AtmosHygrometry"), 2, 0);
519  atmosGroupBoxLayout->addWidget(new QLabel(TR("id_unite_hygro")), 2, 1, Qt::AlignLeft);
520 
521  windGroupBoxLayout->addWidget(solverParamsWidgetManager->makeWidget("AngleFavorable"), 0, 0);
522 
523  windGroupBoxLayout->addWidget(solverParamsWidgetManager->makeWidget("DSWindDirection"), 1, 0);
524 
525  tabLayout->addWidget(atmosGroupBox, 0, 0);
526  tabLayout->addWidget(windGroupBox, 1, 0);
527  }
528  catch (const tympan::invalid_data& exc)
529  {
530  std::ostringstream msg;
531  msg << TR("id_solver_param_tab_err").toStdString() << " " << TR("id_opt_meteo").toStdString() << ": "
532  << exc.what();
533  OMessageManager::get()->error(msg.str().c_str());
534  }
535 
536  // activation des paramètres de vent uniquement si propaConditions == 2 (mixed)
537  auto enable_wind_params = [windGroupBox](QString value) { windGroupBox->setEnabled(value == "2"); };
539  windGroupBox, enable_wind_params);
540 
541  _meteoTabWidget->layout()->setAlignment(Qt::AlignTop);
542  _tabWidget->insertTab(1, _meteoTabWidget, TR("id_opt_meteo"));
543 }
544 
546 {
547  _elmW->apply();
548 
549  getElement()->setComment(_lineEditComment->toPlainText());
550  getElement()->setAuteur(_lineEditAuteur->text());
551 
552  // CHOIX DU SOLVEUR
554  TYPluginManager::TYPluginList& plugList = pPlug->getPluginList();
555  TYPluginManager::TYPluginList::iterator iter;
556 
557  unsigned short i = 0;
558  unsigned short currentIndex = _comboSolver->currentIndex();
559  OGenID id;
560  for (i = 0, iter = plugList.begin(); i <= currentIndex; i++, iter++)
561  {
562  id = (*iter)->getPlugin()->getUUID();
563  }
564 
565  getElement()->setSolverId(id);
566 
567  // ==================
568 
569  if (_pRadioButtonActif->isChecked())
570  {
571  getElement()->setState(TYCalcul::Actif);
572  }
573  else
574  {
575  if (getElement()->getState() == TYCalcul::Actif && getElement()->getResultat())
576  {
577  getElement()->getResultat()->purge();
578  }
579  getElement()->setState(TYCalcul::Locked);
580  }
581 
582  getElement()->setDateModif(_editDateModif->date().currentDate().toString(Qt::ISODate));
583  getElement()->setDateCreation(_editDateCreation->date().toString(Qt::ISODate));
584 
585  // Mise a jour des points de controles
586  TYTabLPPointControl& tabPoints = getElement()->getProjet()->getPointsControl();
587  int row = 0;
588  bool need_to_rebuild_result(false);
589  for (row = 0; row < _tableauPointControle->rowCount(); row++)
590  {
591  QTableWidgetItem* pCheck = (QTableWidgetItem*)_tableauPointControle->item(row, 4);
592  if (pCheck->checkState() == Qt::Checked)
593  {
594  tabPoints[row]->setEtat(getElement()->getID(), true);
595  need_to_rebuild_result |= getElement()->addPtCtrlToResult(tabPoints[row]);
596  }
597  else
598  {
599  tabPoints[row]->setEtat(getElement()->getID(), false);
600  need_to_rebuild_result |= getElement()->remPtCtrlFromResult(tabPoints[row]);
601  }
602  }
603 
604  if (need_to_rebuild_result)
605  {
606  getElement()->getResultat()->buildMatrix();
607  }
608 
609  // Mise a jour des maillages
610  for (row = 0; row < _tableauMaillages->rowCount(); row++)
611  {
612  QTableWidgetItem* pCheck = (QTableWidgetItem*)_tableauMaillages->item(row, 1);
613  if (pCheck->checkState() == Qt::Checked)
614  {
615  getElement()->addMaillage(getElement()->getProjet()->getMaillage(row));
616  }
617  else
618  {
619  getElement()->remMaillage(getElement()->getProjet()->getMaillage(row));
620  }
621  }
622 
623  getElement()->solverParams = solverParamsWidgetManager->getSolverParams();
624 
625  // Mise a jour du statut de sauvegarde des resultats partiels
626  // Workaround issue #138
627  // bool bEtat1 = _checkBoxStoreGlobalMatrix->isChecked();
628  // getElement()->setStatusPartialResult(bEtat1) ; //(_checkBoxStoreGlobalMatrix->isChecked());
629 
630  emit modified();
631 }
632 
633 void TYCalculWidget::changeSolverMethod(const QString& pSolverName)
634 {
635  bool bIsDefaultSolverSelected{false};
636  if (pSolverName == "9613Solver" || pSolverName == "9613Solver_2024" || _pRadioButtonLocked->isChecked())
637  {
638  bIsDefaultSolverSelected = false;
639  }
640  else
641  {
642  bIsDefaultSolverSelected = true;
643  }
644  _enableDisableDefaultSolverWidgets(bIsDefaultSolverSelected);
645 }
646 
648 {
649  if (_pRadioButtonActif->isChecked())
650  {
652  QString solverName = _comboSolver->currentText();
653  changeSolverMethod(solverName);
654  _comboSolver->setEnabled(true);
655  }
656  else
657  {
659  _comboSolver->setEnabled(false);
660  }
661 }
662 
664 {
665  getElement()->getResultat()->edit(this);
666 }
667 
668 void TYCalculWidget::contextMenuEvent(QContextMenuEvent* e)
669 {
670  QWidget* currentTab = _tabWidget->currentWidget();
671  unsigned short checkCol = 4; // Numero de la colonne a checker
672  if (currentTab == _tableauPointControle)
673  {
674  checkCol = 4;
675  QPoint point = _tableauPointControle->mapFrom(this, e->pos());
676  if ((point.x() >= 0) && (point.y() >= 0) && (point.x() <= _tableauPointControle->width()) &&
677  (point.y() <= _tableauPointControle->height()))
678  {
679  bool bActif = true;
680  QMenu* pMenu = new QMenu(this);
681 
682  QAction* selectAll = pMenu->addAction(TR("id_popup_select_all"));
683  QAction* unSelectAll = pMenu->addAction(TR("id_popup_unselect_all"));
684 
685  QAction* ret = pMenu->exec(_tableauPointControle->mapToGlobal(point));
686  if (ret != NULL)
687  {
688  if (ret == selectAll)
689  {
690  bActif = true;
691  }
692  else if (ret == unSelectAll)
693  {
694  bActif = false;
695  }
696  // Update de la table active
697  for (int row = 0; row < _tableauPointControle->rowCount(); row++)
698  {
699  QTableWidgetItem* pCheck = (QTableWidgetItem*)_tableauPointControle->item(row, checkCol);
700  if (bActif)
701  {
702  pCheck->setCheckState(Qt::Checked);
703  }
704  else
705  {
706  pCheck->setCheckState(Qt::Unchecked);
707  }
708  }
709  }
710  }
711  }
712  else if (currentTab == _tableauMaillages)
713  {
714  checkCol = 1;
715  QPoint point = _tableauMaillages->mapFrom(this, e->pos());
716  if ((point.x() >= 0) && (point.y() >= 0) && (point.x() <= _tableauMaillages->width()) &&
717  (point.y() <= _tableauMaillages->height()))
718  {
719  bool bActif = true;
720  QMenu* pMenu = new QMenu(this);
721 
722  QAction* selectAll = pMenu->addAction(TR("id_popup_select_all"));
723  QAction* unSelectAll = pMenu->addAction(TR("id_popup_unselect_all"));
724 
725  QAction* ret = pMenu->exec(_tableauMaillages->mapToGlobal(point));
726  if (ret != NULL)
727  {
728  if (ret == selectAll)
729  {
730  bActif = true;
731  }
732  else if (ret == unSelectAll)
733  {
734  bActif = false;
735  }
736  // Update de la table active
737  for (int row = 0; row < _tableauMaillages->rowCount(); row++)
738  {
739  QTableWidgetItem* pCheck = (QTableWidgetItem*)_tableauMaillages->item(row, checkCol);
740  if (bActif)
741  {
742  pCheck->setCheckState(Qt::Checked);
743  }
744  else
745  {
746  pCheck->setCheckState(Qt::Unchecked);
747  }
748  }
749  }
750  }
751  }
752 }
#define TR(id)
outil IHM pour un calcul (fichier header)
outil IHM pour un element (fichier header)
objet IHM pour les etats (fichier header)
utilitaire pour la gestion des messages dans Tympan (fichier header)
std::vector< LPTYPointControl > TYTabLPPointControl
Collection de Smart Pointer sur TYPointControl.
int id
Objet permettant de gerer les differents widgets servant a parametriser le solveur.
Definition: idgen.h:28
virtual void error(const char *message,...)
Definition: logging.cpp:127
static OMessageManager * get()
Definition: logging.cpp:108
QRadioButton * _pRadioButtonActif
TYCalculWidget(TYCalcul *pElement, QWidget *_pParent=NULL)
QTableWidget * _tableauPointControle
Onglet des points de controle.
QComboBox * _comboSolver
QDateEdit * _editDateModif
QWidget * _meteoTabWidget
QTableWidget * _tableauMaillages
Onglet des points de controle.
TYSolverParamsWidgetManager * solverParamsWidgetManager
QButtonGroup * _buttonGroupState
virtual void contextMenuEvent(QContextMenuEvent *e)
void _enableDisableDefaultSolverWidgets(bool pIsDefaultSolverSelected)
QGroupBox * _groupBoxResultat
QLabel * _labelDateCreation
QWidget * _paramsTabWidget
QGridLayout * _calculLayout
virtual void updateContent()
QLabel * _labelComment
void updateNoiseMapsTab(TYProjet *pProjet)
QPushButton * _pushButtonResultat
QLabel * _labelAuteur
QLineEdit * _lineEditAuteur
QDateEdit * _editDateCreation
TYElementWidget * _elmW
void _initMeteoParamsTabs()
QLabel * _labelDateModif
void _enableSolverParameterWidgets(bool bEnable)
virtual ~TYCalculWidget()
void updateControlPointsTab(TYProjet *pProjet)
void _initSolverParamsTabs()
TYEtatsWidget * _etatsWidget
virtual void apply()
QTabWidget * _tabWidget
Gestion des differentes options sous forme d'onglet.
QGroupBox * _groupBox
void changeSolverMethod(const QString &pSolverName)
QRadioButton * _pRadioButtonLocked
QTextEdit * _lineEditComment
Calculation program.
Definition: TYCalcul.h:50
@ Locked
Definition: TYCalcul.h:62
@ Actif
Definition: TYCalcul.h:63
classe de l'objet IHM pour un element
virtual void apply()
virtual void updateContent()
classe de l'outil IHM pour les Etats
Definition: TYEtatsWidget.h:50
std::list< TYPluginData * > TYPluginList
static LPTYPluginManager get()
classe de definition d'un projet.
Definition: TYProjet.h:45
TYTabMaillageGeoNode & getMaillages()
Get de la collection de maillages.
Definition: TYProjet.h:261
LPTYMaillage getMaillage(int index)
Retourne un maillage a partir de son index.
Definition: TYProjet.h:318
TYTabLPPointControl & getPointsControl()
Definition: TYProjet.h:193
void updateWidgets(QString newParamValues)
TYSolverParamsWidget * makeWidget(QString paramName)
TYSolverParamsWidget * getWidget(QString paramName)
void valueChanged(QString)
classe de l'objet IHM pour un objet metier de type TYElement
Definition: TYWidget.h:43
void modified()
unsigned int uint32
Definition: defines.h:75
The base exception class for errors due to invalid data.
Definition: exceptions.h:75
Utilities to interact with Python subprocesses from the Tympan application.