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