Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYProjetFrame.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 <qcursor.h>
22 #include <qtreewidget.h>
23 #include <qmenubar.h>
24 #include <qmenu.h>
25 #include <qtoolbutton.h>
26 #include <qlayout.h>
27 #include <qdialog.h>
28 #include <qfiledialog.h>
29 #include <qmessagebox.h>
30 #include <QTextStream>
31 // Added by qt3to4:
32 #include <QKeyEvent>
33 #include <QPixmap>
34 #include <QVBoxLayout>
35 #include <QBoxLayout>
36 #include <QHeaderView>
37 #include <QMdiArea>
38 #include <QMdiSubWindow>
39 #include <qvector3d.h>
40 
54 #include "TYProjetFrame.h"
57 
58 #define TR(id) OLocalizator::getString("TYProjetFrame", (id))
59 #define IMG(id) OLocalizator::getPicture("TYProjetFrame", (id))
60 
61 // using namespace Qt;
62 
63 TYProjetFrame::TYProjetFrame(QWidget* parent, const char* name, Qt::WindowFlags f) : QWidget(parent, f)
64 {
65  setObjectName(name);
66  QBoxLayout* pLayout = new QVBoxLayout(this);
67  pLayout->setContentsMargins(0, 0, 0, 0);
68  setLayout(pLayout);
69 
70  // List view
71  _pListView = new QTreeWidget(this);
72  QStringList stringList;
73  stringList.append(TR("id_column_projet"));
74  stringList.append(TR("id_column_solver"));
75  _pListView->setColumnCount(2);
76  _pListView->setHeaderLabels(stringList);
77  _pListView->resizeColumnToContents(0);
78 
79  pLayout->addWidget(_pListView);
80 
81  _pProjet = NULL;
82  _pCurrentCalcul = NULL;
83  _pCurrentCalculItem = NULL;
84 
85  // Signaux
86  QObject::connect(_pListView, &QTreeWidget::itemDoubleClicked, this, &TYProjetFrame::doubleClic);
87  QObject::connect(_pListView, &QTreeWidget::itemClicked, this, &TYProjetFrame::apply);
88 }
89 
91 {
92  _pListView->disconnect();
93 }
94 
96 {
97  if (_pProjet && _pProjet->getGraphicObject())
98  {
99  _pProjet->getGraphicObject()->disconnectUpdateSignal(this, SLOT(updateList()));
100  }
101 
102  _pProjet = pProjet;
103 
104  if (_pProjet)
105  {
106  // On signale que le site courant a change
107  emit changeSite(_pProjet->getSite());
108 
109  if (_pProjet->getGraphicObject())
110  {
111  _pProjet->getGraphicObject()->connectUpdateSignal(this, SLOT(updateList()));
112  }
113  }
114  else
115  {
116  // Plus de calcul courant
117  _pCurrentCalcul = NULL;
118 
119  // On signale le changement de calcul courant
121  }
122 
123  updateList();
124 }
125 
127 {
128  TYTreeViewState state;
130 
131  clear();
132 
133  if (!_pProjet)
134  {
135  return;
136  }
137 
138  TYElementListItem* pRootItem = addToList(_pProjet);
139  pRootItem->setExpanded(true);
140  _pListView->resizeColumnToContents(0);
141 
143 }
144 
146 {
147  unsigned int i = 0;
148  TYElementListItem* pRootItem = addEltToList(pElement, parent);
149 
150  // Ajout des points de controle
151  TYElementListItem* pListPointsControlItem =
152  new TYElementListItem(pRootItem, QStringList(TR("id_list_pointscontrol_item")));
153  for (i = 0; i < pElement->getPointsControl().size(); i++)
154  {
155  new TYElementListItem(pListPointsControlItem, pElement->getPointControl(i),
156  pElement->getCurrentCalcul(), QStringList(), true);
157  }
158  pListPointsControlItem->sortChildren(0, Qt::AscendingOrder);
159 
160  // Ajout des maillages
161  TYElementListItem* pLisMaillagesItem =
162  new TYElementListItem(pRootItem, QStringList(TR("id_list_maillages_item")));
163  for (i = 0; i < pElement->getMaillages().size(); i++)
164  {
165  new TYElementListItem(pLisMaillagesItem, pElement->getMaillage(i), pElement->getCurrentCalcul(),
166  QStringList(), true);
167  }
168  pLisMaillagesItem->sortChildren(0, Qt::AscendingOrder);
169 
170  // Ajout des calculs
171  for (i = 0; i < pElement->getListCalcul().size(); i++)
172  {
173  addToList(pElement->getListCalcul()[i], pRootItem);
174  }
175 
176  return pRootItem;
177 }
178 
180 {
181  TYElementListItem* pRootItem = addEltToList(pElement, parent);
182 
183  // Icone indiquant si ce calcul est le calcul courant du projet
184  if (_pProjet->getCurrentCalcul() == pElement)
185  {
186  _pCurrentCalcul = pElement;
187  pRootItem->setIcon(0, QPixmap(IMG("id_icon_check")));
189 
190  _pCurrentCalculItem = pRootItem;
191  }
192  else
193  {
194  pRootItem->setIcon(0, QPixmap(IMG("id_icon_no_check")));
195  }
196 
197  setCalculItemState(pRootItem, pElement->getIsUpTodate());
198 
199  new TYElementListItem(pRootItem, NULL, NULL, QStringList(TR("id_Etats_item")));
200 
201  new TYElementListItem(pRootItem, pElement->getResultat());
202 
203  pRootItem->setExpanded(true);
204 
205  return pRootItem;
206 }
207 
209 {
210  if (state == true)
211  {
213  if (_pCurrentCalculItem != NULL)
214  {
216  }
217  }
218  else
219  {
220  // Rem: Les autres calculs seront systematiquement recalcule lors qu'ils deviendront actifs
221  QTreeWidgetItem* pProjetItem = _pListView->topLevelItem(0);
222  for (int i = 0; i < pProjetItem->childCount(); i++)
223  {
224  TYElementListItem* pCalcItem = static_cast<TYElementListItem*>(pProjetItem->child(i));
225  TYCalcul* pCalcul = static_cast<TYCalcul*>((TYElement*)pCalcItem->getElement());
226  if (pCalcul != NULL && pCalcul->getIsAcousticModified())
227  {
228  pCalcul->setIsUpTodate(state);
229  setCalculItemState(pCalcItem, false);
230  }
231  }
232  }
233 }
234 
236 {
237  if (pCalcItem != NULL)
238  {
239  QFont f = pCalcItem->font(0);
240  f.setItalic(!state);
241  if (state == true)
242  {
243  pCalcItem->setForeground(0, QBrush(QColor::fromRgb(0, 0, 0)));
244  pCalcItem->setText(0, pCalcItem->text(0).replace(" *", ""));
245  }
246  else
247  {
248  pCalcItem->setForeground(0, QBrush(QColor::fromRgb(128, 128, 128)));
249  pCalcItem->setText(0, pCalcItem->text(0).replace(" *", ""));
250  pCalcItem->setText(0, pCalcItem->text(0) + " *");
251  }
252  pCalcItem->setFont(0, f);
253  }
254 }
255 
256 void TYProjetFrame::contextMenuEvent(QContextMenuEvent* e)
257 {
258  if (_pProjet == nullptr)
259  return;
260  // assert(_pProjet != nullptr);
261 
262  // si on trouve un item associe
263  QPoint point = _pListView->mapFrom(this, e->pos());
264  QTreeWidgetItem* item = _pListView->itemAt(point.x(), point.y() - _pListView->header()->height());
265 
266  if (item != NULL)
267  {
268  TYElementListItem* eltItem = (TYElementListItem*)item;
270  TYAction* pAction(NULL);
271 
272  if (eltItem->isElementItem())
273  {
274  QMenu* pMenu = new QMenu(this);
275 
276  QAction* curCalcul = NULL;
277  QAction* remCalculRes = NULL;
278  QAction* goCalcul = NULL;
279  QAction* duplicateCalcul = NULL;
280  QAction* showModeler = NULL;
281  QAction* delCalcul = NULL;
282  QAction* addCalcul = NULL;
283  QAction* remPtControl = NULL;
284  QAction* highlight = NULL; // DTn 20110215
285  QAction* remMaillage = NULL;
286  QAction* changeSiteRoot = NULL;
287  QAction* exportCsv = NULL;
288  QAction *calc_actif = NULL, *calc_locked = NULL;
289 
290  LPTYElementGraphic pGraphicObject = nullptr;
291 
292  // En tete de menu l'acces aux proprietes de l'element
293  QAction* prop =
294  pMenu->addAction(QIcon(QPixmap(IMG("id_icon_editeelt"))), TR("id_contextmenu_properties"));
295  pMenu->addSeparator();
296 
297  // Calcul
298  if (eltItem->getElement()->isA("TYCalcul"))
299  {
300  TYCalcul* pCalcul = dynamic_cast<TYCalcul*>(eltItem->getElement().getRealPointer());
301  if (pCalcul == nullptr)
302  {
303  return;
304  }
305 
306  // Suppression des resultats
307  remCalculRes = pMenu->addAction(QIcon(QPixmap(IMG("id_icon_bin"))),
308  TR("id_contextmenu_remcalculresult"));
309  pMenu->addSeparator();
310 
311  // Calcul courant
312  if (_pProjet->getCurrentCalcul() != nullptr &&
313  _pProjet->getCurrentCalcul()->getID() != eltItem->getElement()->getID())
314  {
315  curCalcul = pMenu->addAction(TR("id_contextmenu_setascurcalcul"));
316  pMenu->addSeparator();
317  }
318 
319  calc_actif = pMenu->addAction(TR("id_contextmenu_ptactif"));
320  if (pCalcul->getState() == TYCalcul::Actif)
321  {
322  calc_actif->setCheckable(true);
323  calc_actif->setChecked(true);
324  }
325 
326  calc_locked = pMenu->addAction(TR("id_contextmenu_ptlocked"));
327  if (pCalcul->getState() == TYCalcul::Locked)
328  {
329  calc_locked->setCheckable(true);
330  calc_locked->setChecked(true);
331  }
332 
333  pMenu->addSeparator();
334 
335  // Lancer calcul (si le calcul est actif et que c est le calcul courant
336  if (pCalcul->getState() == TYCalcul::Actif && pCalcul == _pProjet->getCurrentCalcul())
337  {
338  goCalcul = pMenu->addAction(QIcon(QPixmap(IMG("id_icon_calcul"))),
339  TR("id_contextmenu_gocalcul"));
340  pMenu->addSeparator();
341  }
342 
343  // Duplication
344  duplicateCalcul = pMenu->addAction(QIcon(QPixmap(IMG("id_icon_duplicate"))),
345  TR("id_contextmenu_duplicatecalcul"));
346 
347  pMenu->addSeparator();
348  delCalcul = pMenu->addAction(QIcon(QPixmap(IMG("id_icon_del"))), TR("id_contextmenu_delete"));
349  pMenu->addSeparator();
351  }
352  // Projet
353  else if (dynamic_cast<TYProjet*>(eltItem->getElement()._pObj) != nullptr)
354  {
355  // Ajout calcul
356  addCalcul = pMenu->addAction(TR("id_contextmenu_addcalcul"));
357  pMenu->addSeparator();
358 
359  // Suppression des resultats
360  remCalculRes = pMenu->addAction(QIcon(QPixmap(IMG("id_icon_bin"))),
361  TR("id_contextmenu_remcalculresults"));
362  pMenu->addSeparator();
363 
364  // Modeler
365  showModeler =
366  pMenu->addAction(QIcon(QPixmap(IMG("id_icon_modeler"))), TR("id_contextmenu_modeler"));
367  pMenu->addSeparator();
368 
369  // Changer le site racine
370  changeSiteRoot = pMenu->addAction(TR("id_contextmenu_changesiteroot"));
371  }
372  else if (eltItem->getElement()->isA("TYPointControl"))
373  {
374  // On recupere l'objet graphique de l'element
375  pGraphicObject = eltItem->getElement()->getGraphicObject();
376  if (pGraphicObject)
377  {
378  highlight = pMenu->addAction(TR("id_contextmenu_highlight"));
379  highlight->setCheckable(true);
380  highlight->setChecked(pGraphicObject->isBoundingBoxVisible());
381  pMenu->addSeparator();
382  }
383 
384  remPtControl =
385  pMenu->addAction(QIcon(QPixmap(IMG("id_icon_del"))), TR("id_contextmenu_remptcontrol"));
386  pMenu->addSeparator();
387  }
388  else if (dynamic_cast<TYMaillage*>(eltItem->getElement()._pObj) != nullptr) // Maillage
389  {
390  // On recupere l'objet graphique de l'element
391  pGraphicObject = eltItem->getElement()->getGraphicObject();
392  if (pGraphicObject)
393  {
394  highlight = pMenu->addAction(TR("id_contextmenu_highlight"));
395  highlight->setCheckable(true);
396  highlight->setChecked(pGraphicObject->isBoundingBoxVisible());
397  pMenu->addSeparator();
398  }
399 
400  pMenu->addSeparator();
401  exportCsv = pMenu->addAction(TR("id_contextmenu_exportcsv"));
402  pMenu->addSeparator();
403  remMaillage =
404  pMenu->addAction(QIcon(QPixmap(IMG("id_icon_del"))), TR("id_contextmenu_remmaillage"));
405  pMenu->addSeparator();
406  }
407 
408  // AFFICHAGE DU MENU
409  QAction* ret = pMenu->exec(_pListView->mapToGlobal(point));
410 
411  // ANALYSE DU CHOIX DE L'UTILISATEUR
412  if (ret)
413  {
414  if (ret == prop)
415  {
416  LPTYElement pElt = eltItem->getElement();
417 
418  if (pElt->edit(this) == QDialog::Accepted)
419  {
420  eltItem->updateContent();
421  updateList();
422  }
423  }
424  else if (ret == showModeler)
425  {
427  return;
428  }
429  else if (ret == remPtControl)
430  {
431  TYPointControl* pPoint =
432  dynamic_cast<TYPointControl*>(eltItem->getElement().getRealPointer());
433  if (QMessageBox::warning(this, "Tympan",
434  TR("id_warning_suppr").arg(eltItem->getElement()->getName()),
435  QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
436  {
437  if (_pProjet->remPointControl(pPoint))
438  {
439  // Action
440  pAction = new TYRemPointControlAction(_pProjet, pPoint, pModeler,
441  TR("id_contextmenu_remptcontrol"));
443  updateList();
445  }
446  }
447  }
448  else if (ret == highlight)
449  {
450  highlight_element(pGraphicObject.getRealPointer(),
451  eltItem->getElement().getRealPointer());
452  }
453  else if (ret == remMaillage)
454  {
455  TYMaillage* pMail = dynamic_cast<TYMaillage*>(eltItem->getElement()._pObj);
456  if (pMail != nullptr)
457  {
458  if (_pProjet->remMaillage(pMail))
459  {
460  updateList();
462  }
463  }
464  }
465  else if (ret == exportCsv)
466  {
467  LPTYMaillage pMaillage = TYMaillage::safeDownCast(eltItem->getElement());
468  exportMaillageCSV(pMaillage);
469  return;
470  }
471  else if (ret == changeSiteRoot)
472  {
473  vector<LPTYElement> tabElem;
474  getTYMainWnd()->open(tabElem);
475 
476  if (tabElem.size() > 0)
477  {
478  LPTYElement pElt = tabElem[0];
479  if ((pElt != NULL) && (pElt->isA("TYSiteNode")))
480  {
482  pSite->setRoot(true); // Le nouveau site est racine
483  _pProjet->setSite(pSite);
484 
485  // On met a jour l'arborescence du site frame
487  }
488 
489  pElt = NULL;
490  }
491 
492  tabElem.clear();
493  }
494  else if (ret == delCalcul)
495  {
496  TYElement* pElem = eltItem->getElement();
497  if (pElem == _pProjet->getCurrentCalcul())
498  {
499  QMessageBox::warning(this, "Tympan", TR("id_warning_def_calc_suppr"));
500  }
501  else if (QMessageBox::warning(
502  this, "Tympan", TR("id_warning_suppr").arg(eltItem->getElement()->getName()),
503  QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
504  {
505  if (remFromList(eltItem))
506  {
507  eltItem->remove();
508  delete eltItem;
509  eltItem = NULL;
511  }
512  else
513  {
514  QMessageBox::warning(
515  this, "Tympan",
516  TR("id_warning_notsuppr").arg(eltItem->getElement()->getName()));
517  }
518  }
519  }
520  else if (ret == remCalculRes)
521  {
522  LPTYProjet pProjet = dynamic_cast<TYProjet*>(eltItem->getElement()._pObj);
523  if (pProjet._pObj != nullptr)
524  {
525  for (unsigned int i = 0; i < pProjet->getListCalcul().size(); i++)
526  {
527  LPTYCalcul pCalcul = pProjet->getListCalcul().at(i);
528  pCalcul->clearResult();
529  pCalcul->updateGraphic();
530  }
531  }
532  else
533  {
534  LPTYCalcul pCalcul = dynamic_cast<TYCalcul*>(eltItem->getElement()._pObj);
535  if (pCalcul._pObj != nullptr)
536  {
537  pCalcul->clearResult();
538  pCalcul->updateGraphic();
539  }
540  }
541 
542  updateList();
543  }
544  else if (ret == curCalcul)
545  {
546  TYCalcul* pCalcul = (TYCalcul*)eltItem->getElement().getRealPointer();
547 
548  // Si le calcul courant (avant changement), conserve les contributions partielles, on les
549  // efface
550  if (_pCurrentCalcul && (pCalcul != _pCurrentCalcul))
551  {
553  }
554 
555  _pProjet->setCurrentCalcul(pCalcul);
556  _pCurrentCalcul = pCalcul;
557 
558  LPTYSiteNode pSite = _pProjet->getSite();
559  if (pSite && pCalcul)
560  {
561  pSite->getInfrastructure()->updateAcoustic(pCalcul);
562  }
563 
564  updateList();
565 
566  setCalculDone(true);
567  emit changeCurrentCalcul(pCalcul);
568  }
569  else if (ret == goCalcul)
570  {
571  if ((LPTYElement&)_pCurrentCalcul == eltItem->getElement())
572  {
574  (TYCalcul*)eltItem->getElement().getRealPointer());
575  return;
576  }
577  }
578  else if (ret == duplicateCalcul)
579  {
580  LPTYCalcul pCalcul = (TYCalcul*)eltItem->getElement().getRealPointer();
581 
582  // Duplication et ajout
583  _pProjet->duplicateCalcul(pCalcul);
584 
585  updateList();
587  return;
588  }
589  else if (ret == calc_actif) // DT 16/08/2005 un calcul peut etre actif ou bloque
590  {
591  ((TYCalcul*)eltItem->getElement().getRealPointer())->setState(TYCalcul::Actif);
593  }
594  else if (ret == calc_locked) // DT 16/08/2005 un calcul peut etre actif ou bloque
595  {
596  ((TYCalcul*)eltItem->getElement().getRealPointer())->setState(TYCalcul::Locked);
598  }
599  else if (ret == addCalcul)
600  {
601  LPTYCalcul calcul = new TYCalcul();
602  _pProjet->addCalcul(calcul);
603 
604  calcul->edit(this);
605  updateList();
607  }
608 
609  delete pMenu;
610  }
611  }
612  else if (eltItem->text(0) == TR("id_list_pointscontrol_item"))
613  {
614  QMenu* pMenu = new QMenu(this);
615  QAction* addPtControl = pMenu->addAction(TR("id_contextmenu_addptcontrol"));
616  QAction* selectAllPts = pMenu->addAction(TR("id_contextmenu_selectAllPts"));
617  QAction* unselectAllPts = pMenu->addAction(TR("id_contextmenu_unselectAllPts"));
618 
619  // Affiche popup
620  QAction* ret = pMenu->exec(_pListView->mapToGlobal(point));
621 
622  if (ret)
623  {
624  if (ret == addPtControl)
625  {
626  LPTYPointControl pPtControl = new TYPointControl();
627  pPtControl->setParent(_pProjet);
628 
629  if (pPtControl->edit(this) == QDialog::Accepted)
630  {
631  if (_pProjet->addPointControl(pPtControl))
632  {
633  // Action
634  pAction = new TYAddPointControlAction(_pProjet, pPtControl, pModeler,
635  TR("id_contextmenu_addptcontrol"));
636 
638  updateList();
640  }
641  }
642  }
643  else if (ret == selectAllPts)
644  {
645  selectOrUnselectAll(static_cast<TYElementListItem*>(item), true);
646  }
647  else if (ret == unselectAllPts)
648  {
649  selectOrUnselectAll(static_cast<TYElementListItem*>(item), false);
650  }
651  }
652  }
653  else if (eltItem->text(0) == "id_list_maillages_item")
654  {
655  QMenu* pMenu = new QMenu(this);
656  QAction* selectAllMaps = pMenu->addAction(TR("id_contextmenu_selectAllMaps"));
657  QAction* unselectAllMaps = pMenu->addAction(TR("id_contextmenu_unselectAllMaps"));
658 
659  // Affiche popup
660  QAction* ret = pMenu->exec(_pListView->mapToGlobal(point));
661 
662  if (ret)
663  {
664  if (ret == selectAllMaps)
665  {
666  selectOrUnselectAll(static_cast<TYElementListItem*>(item), true);
667  }
668  else if (ret == unselectAllMaps)
669  {
670  selectOrUnselectAll(static_cast<TYElementListItem*>(item), false);
671  }
672  }
673  }
674  else if (eltItem->text(0) == "Etats")
675  {
676  QMenu* pMenu = new QMenu(this);
677  QAction* prop = NULL;
678 
679  prop = pMenu->addAction(TR("id_contextmenu_properties"));
680 
681  // Affiche popup
682  QAction* ret = pMenu->exec(_pListView->mapToGlobal(point));
683  if (ret)
684  {
685  if (ret == prop)
686  {
687  LPTYCalcul pCalcul =
688  (TYCalcul*)((TYElementListItem*)eltItem->parent())->getElement().getRealPointer();
689  TYEtatsWidget* pEtatWidget = new TYEtatsWidget(pCalcul, this);
690  pEtatWidget->exec();
691  pEtatWidget = NULL;
692  }
693  }
694  }
695  if (pAction && pModeler)
696  {
697  pModeler->getActionManager()->addAction(pAction);
698  }
699  }
700 
701  updateGraphics();
702 }
703 
705 {
706  TYElementListItem* pItem = NULL;
707 
708  if (!parent)
709  {
710  pItem = new TYElementListItem(_pListView, pElement);
711  }
712  else
713  {
714  pItem = new TYElementListItem(parent, pElement);
715  }
716 
717  return pItem;
718 }
719 
721 {
722  bool res = false;
723 
724  if (item && item->getElement())
725  {
726  if (item->getElement()->isA("TYCalcul"))
727  {
728  res = _pProjet->remCalcul(item->getElement()->getID().toString());
729  return res;
730  }
731  }
732 
733  return res;
734 }
735 
737 {
738  TYElementListItem* pItem = (TYElementListItem*)_pListView->currentItem();
739 
740  if (pItem != 0)
741  {
742  switch (e->key())
743  {
744  case Qt::Key_Delete:
745  remFromList(pItem);
746  break;
747  }
748  e->accept();
749  }
750 }
751 
752 void TYProjetFrame::doubleClic(QTreeWidgetItem* item, int column)
753 {
754  TYElementListItem* eltItem = (TYElementListItem*)item;
755 
756  if (eltItem->isElementItem())
757  {
758  if (dynamic_cast<TYProjet*>(eltItem->getElement()._pObj) != nullptr)
759  {
761  }
762  else // Pour tous les autres, affichage des proprietes
763  {
764  LPTYElement pElt = eltItem->getElement();
765  if (pElt->edit(this) == QDialog::Accepted)
766  {
767  eltItem->updateContent();
768  pElt->updateGraphic();
769  }
770  }
771  }
772  else if (eltItem->text(0) == "Etats")
773  {
774  LPTYCalcul pCalcul =
775  (TYCalcul*)((TYElementListItem*)eltItem->parent())->getElement().getRealPointer();
776  TYEtatsWidget* pEtatWidget = new TYEtatsWidget(pCalcul, this);
777  pEtatWidget->exec();
778  pEtatWidget = NULL;
779  }
780 
781  updateGraphics();
782 }
783 
784 void TYProjetFrame::apply(QTreeWidgetItem* item, int col)
785 {
786  if (item)
787  {
788  TYElementListItem* pCheckItem = (TYElementListItem*)item;
789  pCheckItem->setCheckState(0, pCheckItem->checkState(0));
790  }
791 }
792 
794 {
795  assert(pMaillage);
796 
797  QString fileName = QFileDialog::getSaveFileName(this, "", "", "CSV (*.csv)");
798 
799  if (!fileName.isEmpty())
800  {
801  if (!fileName.endsWith(".csv"))
802  {
803  fileName += ".csv";
804  }
805  }
806 
807  QFile f(fileName);
808 
809  if (f.open(QIODevice::WriteOnly))
810  {
811  QTextStream s(&f);
812 
813  s << "X"
814  << ";"
815  << "Y"
816  << ";"
817  << "Lp"
818  << "\n";
819 
820  TYTabLPPointCalcul tabPoints = pMaillage->getPtsCalcul();
821  double value = 0.0;
822  LPTYPointCalcul pPtCalcul = NULL;
823  TYSpectre spectre;
824 
825  for (int i = 0; i < tabPoints.size(); i++)
826  {
827  pPtCalcul = tabPoints[i];
828 
829  // Valeur du scalaire pour la color map
830  switch (pMaillage->getDataType())
831  {
833  default:
834  value = pPtCalcul->getValA();
835  break;
837  value = pPtCalcul->getValLin();
838  break;
840  spectre = *pPtCalcul->getSpectre();
841  value = spectre.getValueReal(pMaillage->getDataFreq());
842  break;
843  }
844 
845  s << pPtCalcul->getCoordSIG()._x << ";" << pPtCalcul->getCoordSIG()._y << ";" << value << "\n";
846  }
847 
848  f.close();
849  }
850 }
851 
853 {
854  if (getTYApp()->getCalculManager()->askForResetResultat())
855  {
856  bool on = bSelect;
857 
858  for (int i = 0; (i < item->childCount()) && _pCurrentCalcul; i++)
859  {
860  static_cast<TYElementListItem*>(item->child(i))->setOn(on, false);
861  }
862 
863  updateGraphics();
864  }
865 }
866 
868 {
869  _pProjet->updateGraphicTree();
871  TYSiteModelerFrame* psiteframe = dynamic_cast<TYSiteModelerFrame*>(getTYMainWnd()->getCurrentModeler());
872 
873  if (psiteframe != nullptr)
874  {
875  psiteframe->setSite(_pProjet->getSite());
876  psiteframe->getView()->getRenderer()->invalidateScene();
877  psiteframe->updateView();
878  }
879 
880  getTYMainWnd()->updateModelers(false, false);
881 }
882 
884 {
885  if (pGraphicObject)
886  {
887  bool bCenterOnLocate = false;
888  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "CenterOnLocate"))
889  {
890  bCenterOnLocate = TYPreferenceManager::getBool(TYDIRPREFERENCEMANAGER, "CenterOnLocate");
891  }
892  // Toggle le highlight
893  pGraphicObject->setBoundingBoxVisible(!pGraphicObject->isBoundingBoxVisible());
894 
895  if (pGraphicObject->isBoundingBoxVisible())
896  {
897  QList<QMdiSubWindow*> windows = getTYMainWnd()->getWorkspace()->subWindowList();
898 
899  for (int i = 0; i < int(windows.count()); ++i)
900  {
901  QWidget* internal_window = windows.at(i)->widget();
902 
903  QString qClassName = internal_window->metaObject()->className();
904  if (qClassName == QString("TYSiteModelerFrame"))
905  {
906  TYRenderWindowInteractor* pView = ((TYModelerFrame*)internal_window)->getView();
907  pView->getRenderer()->addSelectedElement(pElement);
908  }
909  }
910  }
911 
912  if (bCenterOnLocate && pGraphicObject->isBoundingBoxVisible())
913  {
914  TYGeometryNode* pGeoNode = TYGeometryNode::GetGeoNode(pElement);
915  if (pGeoNode)
916  {
917  ORepere3D repere = pGeoNode->getORepere3D();
918  QVector3D repereCenter(repere._origin._x, repere._origin._z, -repere._origin._y);
919  OBox oBox = pGraphicObject->boundingBox();
920  QVector3D oBoxMin(oBox._min._x, oBox._min._z, -oBox._min._y);
921  QVector3D oBoxMax(oBox._max._x, oBox._max._z, -oBox._max._y);
922  QVector3D oBoxCenter = oBoxMin + ((oBoxMax - oBoxMin) / 2);
923  QVector3D center = repereCenter + oBoxCenter;
924 
925  QList<QMdiSubWindow*> windows = getTYMainWnd()->getWorkspace()->subWindowList();
926 
927  for (int i = 0; i < int(windows.count()); ++i)
928  {
929  QWidget* internal_window = windows.at(i)->widget();
930 
931  if (dynamic_cast<TYModelerFrame*>(internal_window) != nullptr)
932  {
933  TYRenderWindowInteractor* pView = ((TYModelerFrame*)internal_window)->getView();
934  pView->getActiveCamera()->setTo(center);
935  }
936  }
937  }
938  }
939 
940  getTYMainWnd()->updateModelers(); // az++ pour la fonction localiser
941 
942  // il faut un update avant d'enlever l'etat de "locate" sur l'objet
943  if (!pGraphicObject->isBoundingBoxVisible())
944  {
945  QList<QMdiSubWindow*> windows = getTYMainWnd()->getWorkspace()->subWindowList();
946 
947  for (int i = 0; i < int(windows.count()); ++i)
948  {
949  QWidget* internal_window = windows.at(i)->widget();
950 
951  QString qClassName = internal_window->metaObject()->className();
952  if (qClassName == QString("TYSiteModelerFrame"))
953  {
954  getTYMainWnd()->updateModelers(); // az++ pour localiser
955  TYRenderWindowInteractor* pView = ((TYModelerFrame*)internal_window)->getView();
956  pView->getRenderer()->removeSelectedElement(pElement);
957  }
958  }
959  }
960  }
961 }
NxReal s
Definition: NxVec3.cpp:317
fichier contenant differents types d'actions (fichier header)
TYApplication * getTYApp()
Retourne le pointeur sur l'application.
TYMainWindow * getTYMainWnd()
Retourne le pointeur sur la fenetre principale.
pour l'application Tympan (fichier header)
std::vector< LPTYPointCalcul > TYTabLPPointCalcul
Collection de pointeurs de TYPointCalcul.
Definition: TYDefines.h:358
Frame pour les messages de retour (fichier header)
#define TYDIRPREFERENCEMANAGER
Definition: TYElement.h:51
objet IHM pour les etats (fichier header)
Fenetre principale de l'application Tympan (fichier header)
Classe generique pour une fenetre de modeleur (fichier header)
#define IMG(id)
#define TR(id)
Frame pour la gestion de projet (fichier header)
Le role de cette classe est limite a emettre des signaux pouvant etre utilise pour interagir sur le r...
const char * name
Frame pour la gestion de site (fichier header)
Classe Modeler specialisee pour l'edition des sites (fichier header)
Helper pour la gestion des arbres Site et Projet (fichier header)
The box class.
Definition: 3d.h:1346
OPoint3D _min
Minimal coordinates of the OBox.
Definition: 3d.h:1423
OPoint3D _max
Maximal coordinates of the OBox.
Definition: 3d.h:1424
double _y
y coordinate of OCoord3D
Definition: 3d.h:283
double _z
z coordinate of OCoord3D
Definition: 3d.h:284
double _x
x coordinate of OCoord3D
Definition: 3d.h:282
void setTo(const QVector3D &_to)
Definition: OGLCamera.cpp:281
static OPrototype * safeDownCast(OPrototype *pObject)
Definition: TYElement.cpp:71
bool isA(const char *className) const
Definition: TYElement.cpp:65
3D frame with a point and 3 vectors.
Definition: 3d.h:1263
OPoint3D _origin
The origin point.
Definition: 3d.h:1331
double getValueReal(double freq)
Definition: spectre.cpp:974
T * getRealPointer()
Definition: smartptr.h:291
T * _pObj
The real pointer, must derived IRefCount.
Definition: smartptr.h:307
void addAction(TYAction *pAction)
Ajoute une nouvelle action a l'historique.
Definit une action, necessaire pour la gestion de l'undo.
Definition: TYAction.h:37
Action d'ajout d'un point de controle.
Definition: TYActions.h:876
TYMainWindow * getMainWnd()
Get de la fenetre principale.
Definition: TYApplication.h:81
TYCalculManager * getCalculManager()
Get du gestionnaire de calculs.
Definition: TYApplication.h:99
bool askForResetResultat()
Previent l'utilisateur que le resultat va etre efface, si celui-ci est valide.
bool launch(LPTYCalcul pCalcul)
Execute un calcul.
Calculation program.
Definition: TYCalcul.h:50
void clearResult()
Definition: TYCalcul.cpp:845
int getState()
Get calculation state.
Definition: TYCalcul.h:416
@ Locked
Definition: TYCalcul.h:62
@ Actif
Definition: TYCalcul.h:63
void setStatusPartialResult(const bool &status)
Partial result retention set.
Definition: TYCalcul.h:445
void setIsUpTodate(bool upTodate)
Set the calculated state up to date or not link to the infrastructure.
Definition: TYCalcul.h:246
const LPTYResultat getResultat() const
Get result.
Definition: TYCalcul.h:367
bool getIsUpTodate() const
Get the calculated state up to date or not link to the infrastructure.
Definition: TYCalcul.h:237
classe graphique pour un element de base
OBox boundingBox() const
void setBoundingBoxVisible(bool state=true)
bool isBoundingBoxVisible() const
Frame pour les messages de retour.
bool isElementItem()
Indique si un element est associe a cet item.
void updateContent()
Mets a jour le contenu des colonnes.
LPTYElement getElement()
Retourne l'element associe a cet item.
void remove()
Supprime l'item de la liste.
void setCheckState(int column, Qt::CheckState state)
Reimplementation.
static void setIsSavedOk(const bool &toSave)
Definition: TYElement.h:914
const TYUUID & getID() const
Definition: TYElement.cpp:176
virtual QString getName() const
Definition: TYElement.h:691
bool getIsAcousticModified()
Definition: TYElement.h:725
void setParent(TYElement *pParent)
Definition: TYElement.h:699
classe de l'outil IHM pour les Etats
Definition: TYEtatsWidget.h:50
const ORepere3D & getORepere3D() const
static TYGeometryNode * GetGeoNode(TYElement *pElement)
bool updateAcoustic(const TYCalcul *pCalcul, const bool &force=false)
Classe de definition d'un maillage.
Definition: TYMaillage.h:51
@ ValGlobalDBLin
Definition: TYMaillage.h:299
void updateModelers(bool clipping=true, bool axesAndGrid=true, bool displayList=true)
TYSiteFrame * getSiteFrame()
Definition: TYMainWindow.h:77
void makeProjetModeler(LPTYProjet pProjet=NULL)
QMdiArea * getWorkspace()
Definition: TYMainWindow.h:63
TYModelerFrame * getCurrentModeler()
Definition: TYMainWindow.h:68
Generic class for a modeler window.
TYRenderWindowInteractor * getView()
TYActionManager * getActionManager()
void removeSelectedElement(TYElement *pElement)
void invalidateScene(void)
void addSelectedElement(TYElement *pElement)
double getValLin()
Get de la valeur globale Lin au point.
virtual LPTYSpectre getSpectre()
Get du spectre resultat d'un calcul donne.
TYPoint getCoordSIG()
Passage en coordonnees SIG.
double getValA()
Get de la valeur globale A au point.
Classe de definition d'un point de controle.Le point de controle est un point de calcul avec une haut...
void apply(QTreeWidgetItem *item, int col)
bool remFromList(TYElementListItem *item)
void setCalculDone(bool state)
void changeSite(LPTYSiteNode pSite)
TYElementListItem * addEltToList(LPTYElement pElement, TYElementListItem *parent=NULL)
void setCalculItemState(TYElementListItem *pCalcItem, bool state)
LPTYProjet _pProjet
Le projet.
virtual void contextMenuEvent(QContextMenuEvent *e)
void keyPressEvent(QKeyEvent *e)
void selectOrUnselectAll(TYElementListItem *item, const bool &bSelect)
TYElementListItem * addToList(LPTYProjet pElement, TYElementListItem *parent=NULL)
TYProjetFrame(QWidget *parent=0, const char *name=0, Qt::WindowFlags f=QFlag(0))
TYElementListItem * _pCurrentCalculItem
L'item du treeview du projet.
QTreeWidget * _pListView
void setProjet(LPTYProjet pProjet)
void updateGraphics()
void updateGraphics()
void exportMaillageCSV(const LPTYMaillage pMaillage)
void changeCurrentCalcul(LPTYCalcul pCalcul)
virtual ~TYProjetFrame()
void highlight_element(TYElementGraphic *pGraphicObject, TYElement *pElement)
highlight object
LPTYCalcul _pCurrentCalcul
Le calcul courant.
void doubleClic(QTreeWidgetItem *, int)
classe de definition d'un projet.
Definition: TYProjet.h:45
TYTabLPCalcul & getListCalcul()
Set/Get de la liste des Calcul.
Definition: TYProjet.h:366
TYTabMaillageGeoNode & getMaillages()
Get de la collection de maillages.
Definition: TYProjet.h:261
bool addPointControl(LPTYPointControl pPointControl)
Definition: TYProjet.cpp:438
void setCurrentCalcul(LPTYCalcul pCurCalcul)
Set/Get du pointeur du Calcul courant.
Definition: TYProjet.cpp:571
bool remPointControl(LPTYPointControl pPointControl)
Definition: TYProjet.cpp:456
bool remMaillage(const LPTYMaillageGeoNode pMaillageGeoNode)
Suppression d'un maillage.
Definition: TYProjet.cpp:862
LPTYSiteNode getSite()
Get du site.
Definition: TYProjet.h:169
LPTYPointControl getPointControl(int index)
Definition: TYProjet.h:232
void setSite(const LPTYSiteNode pSite)
Set du site.
Definition: TYProjet.cpp:808
LPTYMaillage getMaillage(int index)
Retourne un maillage a partir de son index.
Definition: TYProjet.h:318
bool addCalcul(LPTYCalcul pCalcul)
Ajout d'un Calcul a la liste des Calcul.
Definition: TYProjet.cpp:505
LPTYCalcul duplicateCalcul(const LPTYCalcul pCalcul)
Duplique pCalcul.
Definition: TYProjet.cpp:685
virtual void updateGraphic()
Definition: TYProjet.cpp:1162
TYTabLPPointControl & getPointsControl()
Definition: TYProjet.h:193
LPTYCalcul getCurrentCalcul()
Set/Get du pointeur du Calcul courant.
Definition: TYProjet.h:426
bool remCalcul(const LPTYCalcul pCalcul)
Suppression d'un Calcul a la liste des Calcul.
Definition: TYProjet.cpp:515
Action de suppression d'un point de controle.
Definition: TYActions.h:902
Le role de cette classe est limite a emettre des signaux pouvant etre utilise pour interagir sur le r...
TYOpenGLRenderer * getRenderer()
OGLCamera * getActiveCamera()
void setSiteNodeRoot(LPTYSiteNode pSiteNode)
Definition: TYSiteFrame.cpp:91
Classe Modeler specialisee pour l'edition des sites.
void setSite(LPTYSiteNode pSite)
virtual void updateView(bool clipping=true, bool axesAndGrid=true)
LPTYInfrastructure getInfrastructure()
Definition: TYSiteNode.h:174
void setRoot(bool b)
Definition: TYSiteNode.h:329
static void capture(QTreeWidget *tree, TYTreeViewState &outState)
Capture l'état complet (expansions + scroll) du QTreeWidget.
static void apply(QTreeWidget *tree, const TYTreeViewState &state)
Applique l'état complet (expansions + scroll) au QTreeWidget.