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  bool bDefaultSolverSelected{false};
115 
116  // 9613
117  if (getElement()->getSolverId() == OGenID("{B45873B6-550C-11ED-BDC3-0242AC120002}"))
118  {
119  bDefaultSolverSelected = false;
120  }
121  // DefaultSolver
122  else
123  {
124  bDefaultSolverSelected = true;
125  }
126  // Parameters tab
128 
129  // Meteo tab
131 
132  _enableDisableDefaultSolverWidgets(bDefaultSolverSelected);
133  }
134  catch (const tympan::invalid_data& exc)
135  {
136  OMessageManager::get()->error(exc.what());
137  }
138 
139  // Ponctual receptors tab
140  _tableauPointControle = new QTableWidget();
141  _tableauPointControle->setColumnCount(5);
142  _tableauPointControle->setHorizontalHeaderItem(0, new QTableWidgetItem(TR("id_nom_pc")));
143  _tableauPointControle->setHorizontalHeaderItem(1, new QTableWidgetItem(TR("id_pos_x")));
144  _tableauPointControle->setHorizontalHeaderItem(2, new QTableWidgetItem(TR("id_pos_y")));
145  _tableauPointControle->setHorizontalHeaderItem(3, new QTableWidgetItem(TR("id_pos_h")));
146  _tableauPointControle->setHorizontalHeaderItem(4, new QTableWidgetItem(TR("id_actif")));
147 
148  _tabWidget->insertTab(_tabWidget->count() + 1, _tableauPointControle, TR("id_opt_pc"));
149 
150  // Surfacic receptors tab
151  _tableauMaillages = new QTableWidget();
152  _tableauMaillages->setColumnCount(2);
153  _tableauMaillages->setHorizontalHeaderItem(0, new QTableWidgetItem(TR("id_nom_pc")));
154  _tableauMaillages->setHorizontalHeaderItem(1, new QTableWidgetItem(TR("id_actif")));
155 
156  _tabWidget->insertTab(_tabWidget->count() + 1, _tableauMaillages, TR("id_opt_maillage"));
157 
158  _calculLayout->addWidget(_tabWidget, iln++, 0);
159 
160  // General informations tab
161 
162  _groupBox = new QGroupBox(_tabWidget);
163 
164  _groupBox->setTitle(TR(""));
165  QGridLayout* groupBoxLayout = new QGridLayout();
166  _groupBox->setLayout(groupBoxLayout);
167 
168  _lineEditAuteur = new QLineEdit(_groupBox);
169  groupBoxLayout->addWidget(_lineEditAuteur, 1, 1);
170 
171  _labelAuteur = new QLabel(_groupBox);
172  _labelAuteur->setText(TR("id_auteur_label"));
173  groupBoxLayout->addWidget(_labelAuteur, 1, 0);
174 
175  QDate date;
176 
177  _editDateCreation = new QDateEdit(_groupBox);
178  if (getElement()->getDateCreation() == "2001-10-01")
179  {
180  getElement()->setDateCreation(date.currentDate().toString(Qt::ISODate));
181  }
182  _editDateCreation->setDate(date.fromString(getElement()->getDateCreation(), Qt::ISODate));
183  groupBoxLayout->addWidget(_editDateCreation, 2, 1);
184 
185  _labelDateCreation = new QLabel(_groupBox);
186  _labelDateCreation->setText(TR("id_datecreation_label"));
187  groupBoxLayout->addWidget(_labelDateCreation, 2, 0);
188 
189  _labelDateModif = new QLabel(_groupBox);
190  _labelDateModif->setText(TR("id_datemodif_label"));
191  groupBoxLayout->addWidget(_labelDateModif, 3, 0);
192 
193  _editDateModif = new QDateEdit(_groupBox);
194  if (getElement()->getDateModif() == "2001-10-01")
195  {
196  getElement()->setDateModif(date.currentDate().toString(Qt::ISODate));
197  }
198  _editDateModif->setDate(date.fromString(getElement()->getDateModif(), Qt::ISODate));
199  groupBoxLayout->addWidget(_editDateModif, 3, 1);
200 
201  _lineEditComment = new QTextEdit(_groupBox);
202  groupBoxLayout->addWidget(_lineEditComment, 5, 0, 1, 2);
203 
204  _labelComment = new QLabel(_groupBox);
205  _labelComment->setText(TR("id_comment_label"));
206  groupBoxLayout->addWidget(_labelComment, 4, 0);
207 
208  _calculLayout->addWidget(_groupBox, iln++, 0);
209 
210  _tabWidget->insertTab(_tabWidget->count() + 1, _groupBox, TR("id_info_calc"));
211 
212  // Button allowing the access to states
213  QGroupBox* pGroupBoxTableEtats = new QGroupBox(this);
214  pGroupBoxTableEtats->setTitle(TR("id_map_box"));
215  QGridLayout* groupBoxTableEtatsLayout = new QGridLayout();
216  pGroupBoxTableEtats->setLayout(groupBoxTableEtatsLayout);
217 
218  QLineEdit* pLineEditNomTableEtats = new QLineEdit(pGroupBoxTableEtats);
219  pLineEditNomTableEtats->setEnabled(false);
220  groupBoxTableEtatsLayout->addWidget(pLineEditNomTableEtats, 0, 0);
221 
222  QPushButton* pPushButtonTableEtats = new QPushButton(pGroupBoxTableEtats);
223  pPushButtonTableEtats->setText(TR("id_proprietes"));
224  groupBoxTableEtatsLayout->addWidget(pPushButtonTableEtats, 0, 1);
225 
226  _calculLayout->addWidget(pGroupBoxTableEtats, iln++, 0);
227 
228  _etatsWidget = new TYEtatsWidget(getElement(), this);
229 
230  // Results
231  _groupBoxResultat = new QGroupBox(this);
232  _groupBoxResultat->setTitle(TR("id_resultat"));
233  QGridLayout* groupBoxResultatLayout = new QGridLayout();
234  _groupBoxResultat->setLayout(groupBoxResultatLayout);
235 
236  // Workaround issue #138
237  // _labelStoreGlobalMatrix = new QLabel(_groupBoxResultat);
238  // _labelStoreGlobalMatrix->setText(TR("id_storeglobalmatrix_label"));
239  // groupBoxResultatLayout->addWidget(_labelStoreGlobalMatrix, 0, 0);
240  //
241  // _checkBoxStoreGlobalMatrix = new QCheckBox(_groupBoxResultat);
242  // _checkBoxStoreGlobalMatrix->setText(TR(""));
243  // groupBoxResultatLayout->addWidget(_checkBoxStoreGlobalMatrix, 0, 1);
244 
245  _pushButtonResultat = new QPushButton(_groupBoxResultat);
246  _pushButtonResultat->setText(TR("id_proprietes"));
247  groupBoxResultatLayout->addWidget(_pushButtonResultat, 0, 2);
248 
249  _calculLayout->addWidget(_groupBoxResultat, iln++, 0);
250 
251  updateContent();
252 
253  connect(pPushButtonTableEtats, &QPushButton::clicked, _etatsWidget, &TYEtatsWidget::show);
254  connect(_pushButtonResultat, &QPushButton::clicked, this, &TYCalculWidget::editResultat);
255 
256  connect(_comboSolver, &QComboBox::currentTextChanged, this, &TYCalculWidget::changeSolverMethod);
257  connect(_pRadioButtonActif, &QRadioButton::clicked, this, &TYCalculWidget::changeCalculState);
258  connect(_pRadioButtonLocked, &QRadioButton::clicked, this, &TYCalculWidget::changeCalculState);
259 }
260 
262 {
263  delete _etatsWidget;
264 }
265 
267 {
268  QString num;
269  QDate date;
270 
271  _elmW->setEnabled(true);
272  _groupBox->setEnabled(true);
273 
274  _elmW->updateContent(); // Affichage du nom du calcul
275 
276  // General infos
277  _editDateModif->setDate(date.currentDate());
278  _editDateCreation->setDate(date.fromString(getElement()->getDateCreation(), Qt::ISODate));
279  _lineEditAuteur->setText(getElement()->getAuteur());
280  _lineEditComment->setPlainText(getElement()->getComment());
281 
282  // Mise a jour de l'etat du calcul
284 
285  // Choix du type de calcul
287 
288  // Workaround issue #138
289  // Keep partial results (or not)
290  // _checkBoxStoreGlobalMatrix->setChecked(getElement()->getStatusPartialResult());
291 
292  // Remplissage du tableau des points de controleet maillages
293  _tableauPointControle->setEnabled(true);
294  _tableauMaillages->setEnabled(true);
295 
296  TYProjet* pProjet = getElement()->getProjet();
297  if (pProjet != NULL)
298  {
299  updateControlPointsTab(pProjet);
300  updateNoiseMapsTab(pProjet);
301  }
302 
303  // initialisation des valeurs des paramètres
304  solverParamsWidgetManager->updateWidgets(getElement()->solverParams);
305 
306  // on force la synchronisation des paramètres et des widgets
307  // pour finaliser l'initialisation de l'IHM
310 }
311 
313 {
314  TYTabLPPointControl& tabPoints = pProjet->getPointsControl();
315  unsigned int nbPoints = static_cast<uint32>(tabPoints.size());
316  _tableauPointControle->setRowCount(nbPoints);
317 
318  QString msg;
319  unsigned int row = 0;
320  for (row = 0; row < nbPoints; row++)
321  {
322  _tableauPointControle->setItem(row, 0, new QTableWidgetItem(tabPoints[row]->getName()));
323 
324  msg = QString(TR("id_cell_posx")).arg(tabPoints[row]->_x, 7, 'f', 1);
325  _tableauPointControle->setItem(row, 1, new QTableWidgetItem(msg));
326 
327  msg = QString(TR("id_cell_posy")).arg(tabPoints[row]->_y, 7, 'f', 1);
328  _tableauPointControle->setItem(row, 2, new QTableWidgetItem(msg));
329 
330  msg = QString(TR("id_cell_posh")).arg(tabPoints[row]->getHauteur(), 7, 'f', 1);
331  _tableauPointControle->setItem(row, 3, new QTableWidgetItem(msg));
332 
333  QTableWidgetItem* pCheckItemActif = new QTableWidgetItem("");
334 
335  if (getElement()->getPtCtrlStatus(tabPoints[row]->getID()))
336  {
337  pCheckItemActif->setCheckState(Qt::Checked);
338  }
339  else
340  {
341  pCheckItemActif->setCheckState(Qt::Unchecked);
342  }
343 
344  _tableauPointControle->setItem(row, 4, pCheckItemActif);
345 
346  _tableauPointControle->setRowHeight(row, 30);
347  }
348 }
349 
351 {
352  int nbPoints = static_cast<uint32>(pProjet->getMaillages().size());
353  _tableauMaillages->setRowCount(nbPoints);
354 
355  LPTYMaillage pMaillage = NULL;
356 
357  for (int row = 0; row < nbPoints; row++)
358  {
359  pMaillage = pProjet->getMaillage(row);
360  _tableauMaillages->setItem(row, 0, new QTableWidgetItem(pMaillage->getName()));
361 
362  QTableWidgetItem* pCheckItemActif = new QTableWidgetItem("");
363  if (pMaillage->etat(getElement()) == true)
364  {
365  pCheckItemActif->setCheckState(Qt::Checked);
366  }
367  else
368  {
369  pCheckItemActif->setCheckState(Qt::Unchecked);
370  }
371  _tableauMaillages->setItem(row, 1, pCheckItemActif);
372 
373  _tableauMaillages->setRowHeight(row, 30);
374  }
375 }
376 
378 {
379  OGenID currentId = getElement()->getSolverId(); // Id du solveur courant
380 
382  TYPluginManager::TYPluginList& plugList = pPlug->getPluginList();
383  TYPluginManager::TYPluginList::iterator iter;
384 
385  QString solverName;
386  unsigned short i = 0, currentSolverIndex = 0;
387  OGenID id;
388  for (iter = plugList.begin(), i = 0; iter != plugList.end(); iter++, i++)
389  {
390  solverName = (*iter)->getPlugin()->getName();
391  _comboSolver->insertItem(i, solverName);
392 
393  if ((*iter)->getPlugin()->getUUID() == currentId)
394  {
395  currentSolverIndex = i;
396  }
397  }
398 
399  // On affiche le regime courant
400  _comboSolver->setCurrentIndex(currentSolverIndex);
401 }
402 
404 {
405  if (getElement()->getState() == TYCalcul::Actif)
406  {
407  _pRadioButtonActif->setChecked(true);
408  _pRadioButtonLocked->setChecked(false);
409  }
410  else
411  {
412  _pRadioButtonActif->setChecked(false);
413  _pRadioButtonLocked->setChecked(true);
414  }
415 }
416 
418 {
419  solverParamsWidgetManager->getWidget("UseRealGround")->setEnabled(pEnable);
420  solverParamsWidgetManager->getWidget("UseScreen")->setEnabled(pEnable);
421  solverParamsWidgetManager->getWidget("UseReflection")->setEnabled(pEnable);
422  solverParamsWidgetManager->getWidget("PropaConditions")->setEnabled(pEnable);
423  solverParamsWidgetManager->getWidget("ModSummation")->setEnabled(pEnable);
424  solverParamsWidgetManager->getWidget("UseLateralDiffraction")->setEnabled(pEnable);
425  solverParamsWidgetManager->getWidget("AngleFavorable")->setEnabled(pEnable);
426  solverParamsWidgetManager->getWidget("DSWindDirection")->setEnabled(pEnable);
427  solverParamsWidgetManager->getWidget("MinSRDistance")->setEnabled(pEnable);
428  solverParamsWidgetManager->getWidget("KeepRays")->setEnabled(pEnable);
429 }
430 
431 void TYCalculWidget::_enableDisableDefaultSolverWidgets(bool pIsDefaultSolverSelected)
432 {
433  solverParamsWidgetManager->getWidget("UseRealGround")->setEnabled(pIsDefaultSolverSelected);
434  solverParamsWidgetManager->getWidget("UseScreen")->setEnabled(pIsDefaultSolverSelected);
435  solverParamsWidgetManager->getWidget("UseReflection")->setEnabled(pIsDefaultSolverSelected);
436  solverParamsWidgetManager->getWidget("PropaConditions")->setEnabled(pIsDefaultSolverSelected);
437  solverParamsWidgetManager->getWidget("ModSummation")->setEnabled(pIsDefaultSolverSelected);
438  solverParamsWidgetManager->getWidget("UseLateralDiffraction")->setEnabled(pIsDefaultSolverSelected);
439  solverParamsWidgetManager->getWidget("AngleFavorable")->setEnabled(pIsDefaultSolverSelected);
440  solverParamsWidgetManager->getWidget("DSWindDirection")->setEnabled(pIsDefaultSolverSelected);
441 }
442 
444 {
445 
446  _paramsTabWidget = new QWidget();
447  QGridLayout* tabLayout = new QGridLayout();
448  _paramsTabWidget->setLayout(tabLayout);
449  try
450  {
451  // agencement des widgets
452  // 1ere colonne
453  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("UseRealGround"), 1, 0, 1, 2);
454  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("UseScreen"), 2, 0, 1, 1);
455  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("UseReflection"), 3, 0, 1, 1);
456  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("PropaConditions"), 4, 0, 1, 2);
457  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("ModSummation"), 5, 0, 1, 2);
458  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("MinSRDistance"), 6, 0, 1, 2);
459 
460  // 2eme colonne
461  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("UseLateralDiffraction"), 2, 2, 1, 1);
462  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("H1parameter"), 4, 2, 1, 1);
463  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("KeepRays"), 5, 2, 1, 1);
464 
465  // on recupere les widgets qui necessitent une interactivite particuliere
466  QCheckBox* useReflectionCheckBox =
467  ((TYSolverParamsCheckBoxWidget*)solverParamsWidgetManager->getWidget("UseReflection"))->checkBox;
468  QCheckBox* useLateralDiffCheckBox =
470  ->checkBox;
471  QCheckBox* useScreenCheckBox =
473 
474  // activation/desactivation des reflexions et des diffractions lateral lorsque la prise en compte des
475  // ecrans change
476  connect(useScreenCheckBox, &QCheckBox::toggled, useReflectionCheckBox, &QCheckBox::setEnabled);
477  connect(useScreenCheckBox, &QCheckBox::toggled, useLateralDiffCheckBox, &QCheckBox::setEnabled);
478 
479  // desactivation des reflexions a la desactivation des ecrans
480  auto uncheck_reflection_if_not_use_screen = [useScreenCheckBox, useReflectionCheckBox](bool clicked)
481  {
482  if (!useScreenCheckBox->isChecked())
483  useReflectionCheckBox->setChecked(false);
484  };
485  connect(useScreenCheckBox, &QCheckBox::toggled, useReflectionCheckBox,
486  uncheck_reflection_if_not_use_screen);
487 
488  // activation des diffractions laterales lors a l'activation des reflexions
489  auto check_lateral_diffractions = [useLateralDiffCheckBox](bool clicked)
490  { useLateralDiffCheckBox->setChecked(true); };
491  connect(useReflectionCheckBox, &QCheckBox::clicked, useLateralDiffCheckBox,
492  check_lateral_diffractions);
493 
494  solverParamsWidgetManager->getWidget("H1parameter")->setDisabled(true);
495  }
496  catch (const tympan::invalid_data& exc)
497  {
498  std::ostringstream msg;
499  msg << TR("id_solver_param_tab_err").toStdString() << " " << TR("id_opt_calc").toStdString() << ": "
500  << exc.what();
501  OMessageManager::get()->error(msg.str().c_str());
502  }
503 
504  _paramsTabWidget->layout()->setAlignment(Qt::AlignTop);
505  _tabWidget->insertTab(0, _paramsTabWidget, TR("id_opt_calc"));
506 }
507 
509 {
510  _meteoTabWidget = new QWidget();
511  QGridLayout* tabLayout = new QGridLayout();
512  _meteoTabWidget->setLayout(tabLayout);
513 
514  QGroupBox* atmosGroupBox = new QGroupBox(TR("id_atmos_box"), _meteoTabWidget);
515  QGridLayout* atmosGroupBoxLayout = new QGridLayout(atmosGroupBox);
516  atmosGroupBox->setLayout(atmosGroupBoxLayout);
517  atmosGroupBoxLayout->setColumnStretch(2, 1);
518 
519  QGroupBox* windGroupBox = new QGroupBox(TR("id_wind_box"), _meteoTabWidget);
520  QGridLayout* windGroupBoxLayout = new QGridLayout(windGroupBox);
521  windGroupBox->setLayout(windGroupBoxLayout);
522  windGroupBoxLayout->setColumnStretch(2, 1);
523 
524  try
525  {
526  atmosGroupBoxLayout->addWidget(solverParamsWidgetManager->makeWidget("AtmosPressure"), 0, 0);
527  atmosGroupBoxLayout->addWidget(new QLabel(TR("id_unite_pression")), 0, 1, Qt::AlignLeft);
528 
529  atmosGroupBoxLayout->addWidget(solverParamsWidgetManager->makeWidget("AtmosTemperature"), 1, 0);
530  atmosGroupBoxLayout->addWidget(new QLabel(TR("id_unite_temp")), 1, 1, Qt::AlignLeft);
531 
532  atmosGroupBoxLayout->addWidget(solverParamsWidgetManager->makeWidget("AtmosHygrometry"), 2, 0);
533  atmosGroupBoxLayout->addWidget(new QLabel(TR("id_unite_hygro")), 2, 1, Qt::AlignLeft);
534 
535  windGroupBoxLayout->addWidget(solverParamsWidgetManager->makeWidget("AngleFavorable"), 0, 0);
536 
537  windGroupBoxLayout->addWidget(solverParamsWidgetManager->makeWidget("DSWindDirection"), 1, 0);
538 
539  tabLayout->addWidget(atmosGroupBox, 0, 0);
540  tabLayout->addWidget(windGroupBox, 1, 0);
541  }
542  catch (const tympan::invalid_data& exc)
543  {
544  std::ostringstream msg;
545  msg << TR("id_solver_param_tab_err").toStdString() << " " << TR("id_opt_meteo").toStdString() << ": "
546  << exc.what();
547  OMessageManager::get()->error(msg.str().c_str());
548  }
549 
550  // activation des paramètres de vent uniquement si propaConditions == 2 (mixed)
551  auto enable_wind_params = [windGroupBox](QString value) { windGroupBox->setEnabled(value == "2"); };
553  windGroupBox, enable_wind_params);
554 
555  _meteoTabWidget->layout()->setAlignment(Qt::AlignTop);
556  _tabWidget->insertTab(1, _meteoTabWidget, TR("id_opt_meteo"));
557 }
558 
560 {
561  _elmW->apply();
562 
563  getElement()->setComment(_lineEditComment->toPlainText());
564  getElement()->setAuteur(_lineEditAuteur->text());
565 
566  // CHOIX DU SOLVEUR
568  TYPluginManager::TYPluginList& plugList = pPlug->getPluginList();
569  TYPluginManager::TYPluginList::iterator iter;
570 
571  unsigned short i = 0;
572  unsigned short currentIndex = _comboSolver->currentIndex();
573  OGenID id;
574  for (i = 0, iter = plugList.begin(); i <= currentIndex; i++, iter++)
575  {
576  id = (*iter)->getPlugin()->getUUID();
577  }
578 
579  getElement()->setSolverId(id);
580 
581  // ==================
582 
583  if (_pRadioButtonActif->isChecked())
584  {
585  getElement()->setState(TYCalcul::Actif);
586  }
587  else
588  {
589  if (getElement()->getState() == TYCalcul::Actif && getElement()->getResultat())
590  {
591  getElement()->getResultat()->purge();
592  }
593  getElement()->setState(TYCalcul::Locked);
594  }
595 
596  getElement()->setDateModif(_editDateModif->date().currentDate().toString(Qt::ISODate));
597  getElement()->setDateCreation(_editDateCreation->date().toString(Qt::ISODate));
598 
599  // Mise a jour des points de controles
600  TYTabLPPointControl& tabPoints = getElement()->getProjet()->getPointsControl();
601  int row = 0;
602  bool need_to_rebuild_result(false);
603  for (row = 0; row < _tableauPointControle->rowCount(); row++)
604  {
605  QTableWidgetItem* pCheck = (QTableWidgetItem*)_tableauPointControle->item(row, 4);
606  if (pCheck->checkState() == Qt::Checked)
607  {
608  tabPoints[row]->setEtat(getElement()->getID(), true);
609  need_to_rebuild_result |= getElement()->addPtCtrlToResult(tabPoints[row]);
610  }
611  else
612  {
613  tabPoints[row]->setEtat(getElement()->getID(), false);
614  need_to_rebuild_result |= getElement()->remPtCtrlFromResult(tabPoints[row]);
615  }
616  }
617 
618  if (need_to_rebuild_result)
619  {
620  getElement()->getResultat()->buildMatrix();
621  }
622 
623  // Mise a jour des maillages
624  for (row = 0; row < _tableauMaillages->rowCount(); row++)
625  {
626  QTableWidgetItem* pCheck = (QTableWidgetItem*)_tableauMaillages->item(row, 1);
627  if (pCheck->checkState() == Qt::Checked)
628  {
629  getElement()->addMaillage(getElement()->getProjet()->getMaillage(row));
630  }
631  else
632  {
633  getElement()->remMaillage(getElement()->getProjet()->getMaillage(row));
634  }
635  }
636 
637  getElement()->solverParams = solverParamsWidgetManager->getSolverParams();
638 
639  // Mise a jour du statut de sauvegarde des resultats partiels
640  // Workaround issue #138
641  // bool bEtat1 = _checkBoxStoreGlobalMatrix->isChecked();
642  // getElement()->setStatusPartialResult(bEtat1) ; //(_checkBoxStoreGlobalMatrix->isChecked());
643 
644  emit modified();
645 }
646 
647 void TYCalculWidget::changeSolverMethod(const QString& pSolverName)
648 {
649  bool bIsDefaultSolverSelected{false};
650  if (pSolverName == "9613Solver" || _pRadioButtonLocked->isChecked())
651  {
652  bIsDefaultSolverSelected = false;
653  }
654  else
655  {
656  bIsDefaultSolverSelected = true;
657  }
658  _enableDisableDefaultSolverWidgets(bIsDefaultSolverSelected);
659 }
660 
662 {
663  if (_pRadioButtonActif->isChecked())
664  {
666  QString solverName = _comboSolver->currentText();
667  changeSolverMethod(solverName);
668  _comboSolver->setEnabled(true);
669  }
670  else
671  {
673  _comboSolver->setEnabled(false);
674  }
675 }
676 
678 {
679  getElement()->getResultat()->edit(this);
680 }
681 
682 void TYCalculWidget::contextMenuEvent(QContextMenuEvent* e)
683 {
684  QWidget* currentTab = _tabWidget->currentWidget();
685  unsigned short checkCol = 4; // Numero de la colonne a checker
686  if (currentTab == _tableauPointControle)
687  {
688  checkCol = 4;
689  QPoint point = _tableauPointControle->mapFrom(this, e->pos());
690  if ((point.x() >= 0) && (point.y() >= 0) && (point.x() <= _tableauPointControle->width()) &&
691  (point.y() <= _tableauPointControle->height()))
692  {
693  bool bActif = true;
694  QMenu* pMenu = new QMenu(this);
695 
696  QAction* selectAll = pMenu->addAction(TR("id_popup_select_all"));
697  QAction* unSelectAll = pMenu->addAction(TR("id_popup_unselect_all"));
698 
699  QAction* ret = pMenu->exec(_tableauPointControle->mapToGlobal(point));
700  if (ret != NULL)
701  {
702  if (ret == selectAll)
703  {
704  bActif = true;
705  }
706  else if (ret == unSelectAll)
707  {
708  bActif = false;
709  }
710  // Update de la table active
711  for (int row = 0; row < _tableauPointControle->rowCount(); row++)
712  {
713  QTableWidgetItem* pCheck = (QTableWidgetItem*)_tableauPointControle->item(row, checkCol);
714  if (bActif)
715  {
716  pCheck->setCheckState(Qt::Checked);
717  }
718  else
719  {
720  pCheck->setCheckState(Qt::Unchecked);
721  }
722  }
723  }
724  }
725  }
726  else if (currentTab == _tableauMaillages)
727  {
728  checkCol = 1;
729  QPoint point = _tableauMaillages->mapFrom(this, e->pos());
730  if ((point.x() >= 0) && (point.y() >= 0) && (point.x() <= _tableauMaillages->width()) &&
731  (point.y() <= _tableauMaillages->height()))
732  {
733  bool bActif = true;
734  QMenu* pMenu = new QMenu(this);
735 
736  QAction* selectAll = pMenu->addAction(TR("id_popup_select_all"));
737  QAction* unSelectAll = pMenu->addAction(TR("id_popup_unselect_all"));
738 
739  QAction* ret = pMenu->exec(_tableauMaillages->mapToGlobal(point));
740  if (ret != NULL)
741  {
742  if (ret == selectAll)
743  {
744  bActif = true;
745  }
746  else if (ret == unSelectAll)
747  {
748  bActif = false;
749  }
750  // Update de la table active
751  for (int row = 0; row < _tableauMaillages->rowCount(); row++)
752  {
753  QTableWidgetItem* pCheck = (QTableWidgetItem*)_tableauMaillages->item(row, checkCol);
754  if (bActif)
755  {
756  pCheck->setCheckState(Qt::Checked);
757  }
758  else
759  {
760  pCheck->setCheckState(Qt::Unchecked);
761  }
762  }
763  }
764  }
765  }
766 }
#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.