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
309 }
310 
312 {
313  TYTabLPPointControl& tabPoints = pProjet->getPointsControl();
314  unsigned int nbPoints = static_cast<uint32>(tabPoints.size());
315  _tableauPointControle->setRowCount(nbPoints);
316 
317  QString msg;
318  unsigned int row = 0;
319  for (row = 0; row < nbPoints; row++)
320  {
321  _tableauPointControle->setItem(row, 0, new QTableWidgetItem(tabPoints[row]->getName()));
322 
323  msg = QString(TR("id_cell_posx")).arg(tabPoints[row]->_x, 7, 'f', 1);
324  _tableauPointControle->setItem(row, 1, new QTableWidgetItem(msg));
325 
326  msg = QString(TR("id_cell_posy")).arg(tabPoints[row]->_y, 7, 'f', 1);
327  _tableauPointControle->setItem(row, 2, new QTableWidgetItem(msg));
328 
329  msg = QString(TR("id_cell_posh")).arg(tabPoints[row]->getHauteur(), 7, 'f', 1);
330  _tableauPointControle->setItem(row, 3, new QTableWidgetItem(msg));
331 
332  QTableWidgetItem* pCheckItemActif = new QTableWidgetItem("");
333 
334  if (getElement()->getPtCtrlStatus(tabPoints[row]->getID()))
335  {
336  pCheckItemActif->setCheckState(Qt::Checked);
337  }
338  else
339  {
340  pCheckItemActif->setCheckState(Qt::Unchecked);
341  }
342 
343  _tableauPointControle->setItem(row, 4, pCheckItemActif);
344 
345  _tableauPointControle->setRowHeight(row, 30);
346  }
347 }
348 
350 {
351  int nbPoints = static_cast<uint32>(pProjet->getMaillages().size());
352  _tableauMaillages->setRowCount(nbPoints);
353 
354  LPTYMaillage pMaillage = NULL;
355 
356  for (int row = 0; row < nbPoints; row++)
357  {
358  pMaillage = pProjet->getMaillage(row);
359  _tableauMaillages->setItem(row, 0, new QTableWidgetItem(pMaillage->getName()));
360 
361  QTableWidgetItem* pCheckItemActif = new QTableWidgetItem("");
362  if (pMaillage->etat(getElement()) == true)
363  {
364  pCheckItemActif->setCheckState(Qt::Checked);
365  }
366  else
367  {
368  pCheckItemActif->setCheckState(Qt::Unchecked);
369  }
370  _tableauMaillages->setItem(row, 1, pCheckItemActif);
371 
372  _tableauMaillages->setRowHeight(row, 30);
373  }
374 }
375 
377 {
378  OGenID currentId = getElement()->getSolverId(); // Id du solveur courant
379 
381  TYPluginManager::TYPluginList& plugList = pPlug->getPluginList();
382  TYPluginManager::TYPluginList::iterator iter;
383 
384  QString solverName;
385  unsigned short i = 0, currentSolverIndex = 0;
386  OGenID id;
387  for (iter = plugList.begin(), i = 0; iter != plugList.end(); iter++, i++)
388  {
389  solverName = (*iter)->getPlugin()->getName();
390  _comboSolver->insertItem(i, solverName);
391 
392  if ((*iter)->getPlugin()->getUUID() == currentId)
393  {
394  currentSolverIndex = i;
395  }
396  }
397 
398  // On affiche le regime courant
399  _comboSolver->setCurrentIndex(currentSolverIndex);
400 }
401 
403 {
404  if (getElement()->getState() == TYCalcul::Actif)
405  {
406  _pRadioButtonActif->setChecked(true);
407  _pRadioButtonLocked->setChecked(false);
408  }
409  else
410  {
411  _pRadioButtonActif->setChecked(false);
412  _pRadioButtonLocked->setChecked(true);
413  }
414 }
415 
417 {
418  solverParamsWidgetManager->getWidget("UseRealGround")->setEnabled(pEnable);
419  solverParamsWidgetManager->getWidget("UseScreen")->setEnabled(pEnable);
420  solverParamsWidgetManager->getWidget("UseReflection")->setEnabled(pEnable);
421  solverParamsWidgetManager->getWidget("PropaConditions")->setEnabled(pEnable);
422  solverParamsWidgetManager->getWidget("ModSummation")->setEnabled(pEnable);
423  solverParamsWidgetManager->getWidget("UseLateralDiffraction")->setEnabled(pEnable);
424  solverParamsWidgetManager->getWidget("AngleFavorable")->setEnabled(pEnable);
425  solverParamsWidgetManager->getWidget("DSWindDirection")->setEnabled(pEnable);
426  solverParamsWidgetManager->getWidget("MinSRDistance")->setEnabled(pEnable);
427  solverParamsWidgetManager->getWidget("KeepRays")->setEnabled(pEnable);
428 }
429 
430 void TYCalculWidget::_enableDisableDefaultSolverWidgets(bool pIsDefaultSolverSelected)
431 {
432  solverParamsWidgetManager->getWidget("UseRealGround")->setEnabled(pIsDefaultSolverSelected);
433  solverParamsWidgetManager->getWidget("UseScreen")->setEnabled(pIsDefaultSolverSelected);
434  solverParamsWidgetManager->getWidget("UseReflection")->setEnabled(pIsDefaultSolverSelected);
435  solverParamsWidgetManager->getWidget("PropaConditions")->setEnabled(pIsDefaultSolverSelected);
436  solverParamsWidgetManager->getWidget("ModSummation")->setEnabled(pIsDefaultSolverSelected);
437  solverParamsWidgetManager->getWidget("UseLateralDiffraction")->setEnabled(pIsDefaultSolverSelected);
438  solverParamsWidgetManager->getWidget("AngleFavorable")->setEnabled(pIsDefaultSolverSelected);
439  solverParamsWidgetManager->getWidget("DSWindDirection")->setEnabled(pIsDefaultSolverSelected);
440 }
441 
443 {
444 
445  _paramsTabWidget = new QWidget();
446  QGridLayout* tabLayout = new QGridLayout();
447  _paramsTabWidget->setLayout(tabLayout);
448  try
449  {
450  // agencement des widgets
451  // 1ere colonne
452  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("UseRealGround"), 1, 0, 1, 2);
453  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("UseScreen"), 2, 0, 1, 1);
454  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("UseReflection"), 3, 0, 1, 1);
455  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("PropaConditions"), 4, 0, 1, 2);
456  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("ModSummation"), 5, 0, 1, 2);
457  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("MinSRDistance"), 6, 0, 1, 2);
458 
459  // 2eme colonne
460  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("UseLateralDiffraction"), 2, 2, 1, 1);
461  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("H1parameter"), 4, 2, 1, 1);
462  tabLayout->addWidget(solverParamsWidgetManager->makeWidget("KeepRays"), 5, 2, 1, 1);
463 
464  // on recupere les widgets qui necessitent une interactivite particuliere
465  QCheckBox* useReflectionCheckBox =
466  ((TYSolverParamsCheckBoxWidget*)solverParamsWidgetManager->getWidget("UseReflection"))->checkBox;
467  QCheckBox* useLateralDiffCheckBox =
469  ->checkBox;
470  QCheckBox* useScreenCheckBox =
472 
473  // activation/desactivation des reflexions et des diffractions lateral lorsque la prise en compte des
474  // ecrans change
475  connect(useScreenCheckBox, &QCheckBox::toggled, useReflectionCheckBox, &QCheckBox::setEnabled);
476  connect(useScreenCheckBox, &QCheckBox::toggled, useLateralDiffCheckBox, &QCheckBox::setEnabled);
477 
478  // desactivation des reflexions a la desactivation des ecrans
479  auto uncheck_reflection_if_not_use_screen = [useScreenCheckBox, useReflectionCheckBox](bool clicked)
480  {
481  if (!useScreenCheckBox->isChecked())
482  useReflectionCheckBox->setChecked(false);
483  };
484  connect(useScreenCheckBox, &QCheckBox::toggled, useReflectionCheckBox,
485  uncheck_reflection_if_not_use_screen);
486 
487  // activation des diffractions laterales lors a l'activation des reflexions
488  auto check_lateral_diffractions = [useLateralDiffCheckBox](bool clicked)
489  { useLateralDiffCheckBox->setChecked(true); };
490  connect(useReflectionCheckBox, &QCheckBox::clicked, useLateralDiffCheckBox,
491  check_lateral_diffractions);
492 
493  solverParamsWidgetManager->getWidget("H1parameter")->setDisabled(true);
494  }
495  catch (const tympan::invalid_data& exc)
496  {
497  std::ostringstream msg;
498  msg << TR("id_solver_param_tab_err").toStdString() << " " << TR("id_opt_calc").toStdString() << ": "
499  << exc.what();
500  OMessageManager::get()->error(msg.str().c_str());
501  }
502 
503  _paramsTabWidget->layout()->setAlignment(Qt::AlignTop);
504  _tabWidget->insertTab(0, _paramsTabWidget, TR("id_opt_calc"));
505 }
506 
508 {
509  _meteoTabWidget = new QWidget();
510  QGridLayout* tabLayout = new QGridLayout();
511  _meteoTabWidget->setLayout(tabLayout);
512 
513  QGroupBox* atmosGroupBox = new QGroupBox(TR("id_atmos_box"), _meteoTabWidget);
514  QGridLayout* atmosGroupBoxLayout = new QGridLayout(atmosGroupBox);
515  atmosGroupBox->setLayout(atmosGroupBoxLayout);
516  atmosGroupBoxLayout->setColumnStretch(2, 1);
517 
518  QGroupBox* windGroupBox = new QGroupBox(TR("id_wind_box"), _meteoTabWidget);
519  QGridLayout* windGroupBoxLayout = new QGridLayout(windGroupBox);
520  windGroupBox->setLayout(windGroupBoxLayout);
521  windGroupBoxLayout->setColumnStretch(2, 1);
522 
523  try
524  {
525  atmosGroupBoxLayout->addWidget(solverParamsWidgetManager->makeWidget("AtmosPressure"), 0, 0);
526  atmosGroupBoxLayout->addWidget(new QLabel(TR("id_unite_pression")), 0, 1, Qt::AlignLeft);
527 
528  atmosGroupBoxLayout->addWidget(solverParamsWidgetManager->makeWidget("AtmosTemperature"), 1, 0);
529  atmosGroupBoxLayout->addWidget(new QLabel(TR("id_unite_temp")), 1, 1, Qt::AlignLeft);
530 
531  atmosGroupBoxLayout->addWidget(solverParamsWidgetManager->makeWidget("AtmosHygrometry"), 2, 0);
532  atmosGroupBoxLayout->addWidget(new QLabel(TR("id_unite_hygro")), 2, 1, Qt::AlignLeft);
533 
534  windGroupBoxLayout->addWidget(solverParamsWidgetManager->makeWidget("AngleFavorable"), 0, 0);
535 
536  windGroupBoxLayout->addWidget(solverParamsWidgetManager->makeWidget("DSWindDirection"), 1, 0);
537 
538  tabLayout->addWidget(atmosGroupBox, 0, 0);
539  tabLayout->addWidget(windGroupBox, 1, 0);
540  }
541  catch (const tympan::invalid_data& exc)
542  {
543  std::ostringstream msg;
544  msg << TR("id_solver_param_tab_err").toStdString() << " " << TR("id_opt_meteo").toStdString() << ": "
545  << exc.what();
546  OMessageManager::get()->error(msg.str().c_str());
547  }
548 
549  // activation des paramètres de vent uniquement si propaConditions == 2 (mixed)
550  auto enable_wind_params = [windGroupBox](QString value) { windGroupBox->setEnabled(value == "2"); };
552  windGroupBox, enable_wind_params);
553 
554  _meteoTabWidget->layout()->setAlignment(Qt::AlignTop);
555  _tabWidget->insertTab(1, _meteoTabWidget, TR("id_opt_meteo"));
556 }
557 
559 {
560  _elmW->apply();
561 
562  getElement()->setComment(_lineEditComment->toPlainText());
563  getElement()->setAuteur(_lineEditAuteur->text());
564 
565  // CHOIX DU SOLVEUR
567  TYPluginManager::TYPluginList& plugList = pPlug->getPluginList();
568  TYPluginManager::TYPluginList::iterator iter;
569 
570  unsigned short i = 0;
571  unsigned short currentIndex = _comboSolver->currentIndex();
572  OGenID id;
573  for (i = 0, iter = plugList.begin(); i <= currentIndex; i++, iter++)
574  {
575  id = (*iter)->getPlugin()->getUUID();
576  }
577 
578  getElement()->setSolverId(id);
579 
580  // ==================
581 
582  if (_pRadioButtonActif->isChecked())
583  {
584  getElement()->setState(TYCalcul::Actif);
585  }
586  else
587  {
588  getElement()->setState(TYCalcul::Locked);
589  if (getElement()->getResultat())
590  {
591  getElement()->getResultat()->purge();
592  }
593  }
594 
595  getElement()->setDateModif(_editDateModif->date().currentDate().toString(Qt::ISODate));
596  getElement()->setDateCreation(_editDateCreation->date().toString(Qt::ISODate));
597 
598  // Mise a jour des points de controles
599  TYTabLPPointControl& tabPoints = getElement()->getProjet()->getPointsControl();
600  int row = 0;
601  bool need_to_rebuild_result(false);
602  for (row = 0; row < _tableauPointControle->rowCount(); row++)
603  {
604  QTableWidgetItem* pCheck = (QTableWidgetItem*)_tableauPointControle->item(row, 4);
605  if (pCheck->checkState() == Qt::Checked)
606  {
607  tabPoints[row]->setEtat(getElement()->getID(), true);
608  need_to_rebuild_result |= getElement()->addPtCtrlToResult(tabPoints[row]);
609  }
610  else
611  {
612  tabPoints[row]->setEtat(getElement()->getID(), false);
613  need_to_rebuild_result |= getElement()->remPtCtrlFromResult(tabPoints[row]);
614  }
615  }
616 
617  if (need_to_rebuild_result)
618  {
619  getElement()->getResultat()->buildMatrix();
620  }
621 
622  // Mise a jour des maillages
623  for (row = 0; row < _tableauMaillages->rowCount(); row++)
624  {
625  QTableWidgetItem* pCheck = (QTableWidgetItem*)_tableauMaillages->item(row, 1);
626  if (pCheck->checkState() == Qt::Checked)
627  {
628  getElement()->addMaillage(getElement()->getProjet()->getMaillage(row));
629  }
630  else
631  {
632  getElement()->remMaillage(getElement()->getProjet()->getMaillage(row));
633  }
634  }
635 
636  getElement()->solverParams = solverParamsWidgetManager->getSolverParams();
637 
638  // Mise a jour du statut de sauvegarde des resultats partiels
639  // Workaround issue #138
640  // bool bEtat1 = _checkBoxStoreGlobalMatrix->isChecked();
641  // getElement()->setStatusPartialResult(bEtat1) ; //(_checkBoxStoreGlobalMatrix->isChecked());
642 
643  emit modified();
644 }
645 
646 void TYCalculWidget::changeSolverMethod(const QString& pSolverName)
647 {
648  bool bIsDefaultSolverSelected{false};
649  if (pSolverName == "9613Solver" || _pRadioButtonLocked->isChecked())
650  {
651  bIsDefaultSolverSelected = false;
652  }
653  else
654  {
655  bIsDefaultSolverSelected = true;
656  }
657  _enableDisableDefaultSolverWidgets(bIsDefaultSolverSelected);
658 }
659 
661 {
662  if (_pRadioButtonActif->isChecked())
663  {
665  QString solverName = _comboSolver->currentText();
666  changeSolverMethod(solverName);
667  }
668  else
669  {
671  }
672 }
673 
675 {
676  getElement()->getResultat()->edit(this);
677 }
678 
679 void TYCalculWidget::contextMenuEvent(QContextMenuEvent* e)
680 {
681  QWidget* currentTab = _tabWidget->currentWidget();
682  unsigned short checkCol = 4; // Numero de la colonne a checker
683  if (currentTab == _tableauPointControle)
684  {
685  checkCol = 4;
686  QPoint point = _tableauPointControle->mapFrom(this, e->pos());
687  if ((point.x() >= 0) && (point.y() >= 0) && (point.x() <= _tableauPointControle->width()) &&
688  (point.y() <= _tableauPointControle->height()))
689  {
690  bool bActif = true;
691  QMenu* pMenu = new QMenu(this);
692 
693  QAction* selectAll = pMenu->addAction(TR("id_popup_select_all"));
694  QAction* unSelectAll = pMenu->addAction(TR("id_popup_unselect_all"));
695 
696  QAction* ret = pMenu->exec(_tableauPointControle->mapToGlobal(point));
697  if (ret != NULL)
698  {
699  if (ret == selectAll)
700  {
701  bActif = true;
702  }
703  else if (ret == unSelectAll)
704  {
705  bActif = false;
706  }
707  // Update de la table active
708  for (int row = 0; row < _tableauPointControle->rowCount(); row++)
709  {
710  QTableWidgetItem* pCheck = (QTableWidgetItem*)_tableauPointControle->item(row, checkCol);
711  if (bActif)
712  {
713  pCheck->setCheckState(Qt::Checked);
714  }
715  else
716  {
717  pCheck->setCheckState(Qt::Unchecked);
718  }
719  }
720  }
721  }
722  }
723  else if (currentTab == _tableauMaillages)
724  {
725  checkCol = 1;
726  QPoint point = _tableauMaillages->mapFrom(this, e->pos());
727  if ((point.x() >= 0) && (point.y() >= 0) && (point.x() <= _tableauMaillages->width()) &&
728  (point.y() <= _tableauMaillages->height()))
729  {
730  bool bActif = true;
731  QMenu* pMenu = new QMenu(this);
732 
733  QAction* selectAll = pMenu->addAction(TR("id_popup_select_all"));
734  QAction* unSelectAll = pMenu->addAction(TR("id_popup_unselect_all"));
735 
736  QAction* ret = pMenu->exec(_tableauMaillages->mapToGlobal(point));
737  if (ret != NULL)
738  {
739  if (ret == selectAll)
740  {
741  bActif = true;
742  }
743  else if (ret == unSelectAll)
744  {
745  bActif = false;
746  }
747  // Update de la table active
748  for (int row = 0; row < _tableauMaillages->rowCount(); row++)
749  {
750  QTableWidgetItem* pCheck = (QTableWidgetItem*)_tableauMaillages->item(row, checkCol);
751  if (bActif)
752  {
753  pCheck->setCheckState(Qt::Checked);
754  }
755  else
756  {
757  pCheck->setCheckState(Qt::Unchecked);
758  }
759  }
760  }
761  }
762  }
763 }
#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.