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