Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYMainWindow.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 // Added by qt3to4:
22 #include <QPixmap>
23 #include <QCloseEvent>
24 #include <qaction.h>
25 #include <qdir.h>
26 #include <qslider.h>
27 #include <qstatusbar.h>
28 #include <qmenubar.h>
29 #include <qtoolbar.h>
30 #include <qdialog.h>
31 #include <qlabel.h>
32 #include <qfile.h>
33 #include <qfiledialog.h>
34 #include <qfileinfo.h>
35 #include <qtoolbutton.h>
36 #include <qbuttongroup.h>
37 #include <qmessagebox.h>
38 #include <qcursor.h>
39 #include <qmainwindow.h>
40 #include <qprocess.h>
41 #include <qtextbrowser.h>
42 #include <qtextstream.h>
43 #include <QDockWidget>
44 #include <QMdiArea>
45 #include <QMdiSubWindow>
46 #include <QShortcut>
47 #include <qeventloop.h>
48 #include <QDateTime>
49 
50 #include "Tympan/core/config.h"
51 #include <Tympan/core/logging.h>
69 
82 #include "TYMainWindow.h"
83 
84 #define TR(id) OLocalizator::getString("TYMainWindow", (id))
85 #define IMG(id) OLocalizator::getPicture("TYMainWindow", (id))
86 
87 // using namespace Qt;
88 
89 // to avoid X11 macro conflit
90 #ifdef Always
91  #undef Always
92 #endif
93 
94 TYMainWindow::TYMainWindow() : QMainWindow(0)
95 {
96  // QApplication::setStyle(new QGtkStyle());
97  _pDummyQOpenGLWidget = new QOpenGLWidget(this);
98  _pDummyQOpenGLWidget->setVisible(false);
99 
100  TYPickingTable _pPickingTable;
101 
102  setWindowTitle(TR("id_caption") + "-" + TY_CURRENT_RELEASE_ + " (" + TY_PRODUCT_PLATFORM_ + ")");
103 
104  _closeAndQuit = true;
105 
106  // Gestion du workspace
107  _pWorkspace = new QMdiArea();
108  _pWorkspace->setActivationOrder(QMdiArea::ActivationHistoryOrder);
109  setCentralWidget(_pWorkspace);
110 
111  // CLM-NT35 : Empecher de deplacer/tourner en vue perspective/mobile
112  _pCurrentModeler = NULL;
113 
114  // Settings du docking
115  // setDockWindowsMovable(true);
116 
117  // Navigateur d'aide
118  _pHelpBrowser = new QTextBrowser(NULL);
119  _pHelpBrowser->resize(800, 600);
120  QString help_index_file = TYApplication::tympanAppDir() + "/" + TR("id_help_index_path");
121  if (QFile::exists(help_index_file))
122  {
123  _pHelpBrowser->setSource(help_index_file);
124  }
125  _pHelpBrowser->hide();
126 
127  // Modes des Modelers
132 
133  // Disambiguate the overloaded TYMainWindow signals
134  void (TYMainWindow::*tyMainWindow_open)() = &TYMainWindow::open;
135  bool (TYMainWindow::*tyMainWindow_save)() = &TYMainWindow::save;
136  bool (TYMainWindow::*tyMainWindow_saveAs)() = &TYMainWindow::saveAs;
137 
138  // Actions
139  _pCreateNewAction = new QAction(QPixmap(IMG("id_icon_createnew")), TR("id_menuitem_createnew"), this);
140  _pCreateNewAction->setShortcut(Qt::CTRL + Qt::Key_N);
141  _pCreateNewAction->setStatusTip(TR("id_status_createnew"));
142  QObject::connect(_pCreateNewAction, &QAction::triggered, this, &TYMainWindow::createNew);
143 
144  _pOpenAction = new QAction(QPixmap(IMG("id_icon_open")), TR("id_menuitem_open"), this);
145  _pOpenAction->setShortcut(Qt::CTRL + Qt::Key_O);
146  _pOpenAction->setStatusTip(TR("id_status_open"));
147  QObject::connect(_pOpenAction, &QAction::triggered, this, tyMainWindow_open);
148 
149  _pCloseAction = new QAction(QPixmap(IMG("id_icon_close")), TR("id_menuitem_close"), this);
150  _pCloseAction->setStatusTip(TR("id_status_close"));
151  QObject::connect(_pCloseAction, &QAction::triggered, this, &TYMainWindow::close);
152  _pCloseAction->setEnabled(false);
153 
154  _pSaveAction = new QAction(QPixmap(IMG("id_icon_save")), TR("id_menuitem_save"), this);
155  _pSaveAction->setShortcut(Qt::CTRL + Qt::Key_S);
156  _pSaveAction->setStatusTip(TR("id_status_save"));
157  QObject::connect(_pSaveAction, &QAction::triggered, this, tyMainWindow_save);
158 
159  _pSaveAsAction = new QAction(QPixmap(IMG("id_icon_save")), TR("id_menuitem_saveas"), this);
160  _pSaveAsAction->setStatusTip(TR("id_status_saveas"));
161  QObject::connect(_pSaveAsAction, &QAction::triggered, this, tyMainWindow_saveAs);
162 
164  new QAction(QPixmap(IMG("id_icon_save")), TR("id_menuitem_saveas_noresult"), this);
165  _pSaveAsNoResultAction->setStatusTip(TR("id_status_saveas_noresult"));
166  QObject::connect(_pSaveAsNoResultAction, &QAction::triggered, this, &TYMainWindow::saveAsNoResult);
167 
168  _pShowPluginManagerAction = new QAction(QPixmap(IMG("id_icon_plugin")), TR("id_menuitem_plugin"), this);
169  _pShowPluginManagerAction->setStatusTip(TR("id_status_plugin"));
170  QObject::connect(_pShowPluginManagerAction, &QAction::triggered, this, &TYMainWindow::showPluginManager);
171 
172  // az++:
173  _pPrintAction = new QAction(QPixmap(IMG("id_icon_print")), TR("id_menuitem_print"), this);
174  _pPrintAction->setShortcut(Qt::CTRL + Qt::Key_P);
175  _pPrintAction->setStatusTip(TR("id_status_print"));
176  QObject::connect(_pPrintAction, &QAction::triggered, this, &TYMainWindow::print);
177  _pPrintAction->setEnabled(false);
178 
179  _pUndoAction = new QAction(QPixmap(IMG("id_icon_undo")), TR("id_menuitem_undo_na"), this);
180  _pUndoAction->setShortcut(Qt::CTRL + Qt::Key_Z);
181  _pUndoAction->setStatusTip(TR("id_status_undo"));
182  QObject::connect(_pUndoAction, &QAction::triggered, this, &TYMainWindow::undo);
183  _pUndoAction->setEnabled(false);
184 
185  _pRedoAction = new QAction(QPixmap(IMG("id_icon_redo")), TR("id_menuitem_redo_na"), this);
186  _pRedoAction->setShortcut(Qt::CTRL + Qt::Key_Y);
187  _pRedoAction->setStatusTip(TR("id_status_redo"));
188  QObject::connect(_pRedoAction, &QAction::triggered, this, &TYMainWindow::redo);
189  _pRedoAction->setEnabled(false);
190 
191  _pCutAction = new QAction(QPixmap(IMG("id_icon_cut")), TR("id_menuitem_cut"), this);
192  _pCutAction->setShortcut(Qt::CTRL + Qt::Key_X);
193  _pCutAction->setStatusTip(TR("id_status_cut"));
194  QObject::connect(_pCutAction, &QAction::triggered, this, &TYMainWindow::cut);
195  _pCutAction->setEnabled(false);
196 
197  _pCopyAction = new QAction(QPixmap(IMG("id_icon_copy")), TR("id_menuitem_copy"), this);
198  _pCopyAction->setShortcut(Qt::CTRL + Qt::Key_C);
199  _pCopyAction->setStatusTip(TR("id_status_cut"));
200  QObject::connect(_pCopyAction, &QAction::triggered, this, &TYMainWindow::copy);
201  _pCopyAction->setEnabled(false);
202 
203  _pPasteAction = new QAction(QPixmap(IMG("id_icon_paste")), TR("id_menuitem_paste"), this);
204  _pPasteAction->setShortcut(Qt::CTRL + Qt::Key_V);
205  _pPasteAction->setStatusTip(TR("id_status_paste"));
206  QObject::connect(_pPasteAction, &QAction::triggered, this, &TYMainWindow::paste);
207  _pPasteAction->setEnabled(false);
208 
210  new QAction(QPixmap(IMG("id_icon_show_spectremngr")), TR("id_menuitem_show_spectremngr"), this);
211  _pHideOrShowSpectreMngrAction->setCheckable(false); // DT 18-05-04 (true change en false)
212  _pHideOrShowSpectreMngrAction->setStatusTip(TR("id_status_show_spectremngr"));
213  _pHideOrShowSpectreMngrAction->setEnabled(false); // Inactive au depart
214  QObject::connect(_pHideOrShowSpectreMngrAction, &QAction::toggled, this,
216 
218  new QAction(QPixmap(IMG("id_icon_show_maillagemngr")), TR("id_menuitem_show_maillagemngr"), this);
219  _pHideOrShowMaillageMngrAction->setCheckable(false); // DT 18-05-04 (true change en false)
220  _pHideOrShowMaillageMngrAction->setStatusTip(TR("id_status_show_maillagemngr"));
221  _pHideOrShowMaillageMngrAction->setEnabled(false); // Inactive au depart
222  QObject::connect(_pHideOrShowMaillageMngrAction, &QAction::toggled, this,
224 
226  new QAction(QPixmap(IMG("id_icon_show_biblio")), TR("id_menuitem_show_biblio"), this);
227  _pHideOrShowBiblioAction->setCheckable(true);
228  _pHideOrShowBiblioAction->setStatusTip(TR("id_status_show_biblio"));
229  QObject::connect(_pHideOrShowBiblioAction, &QAction::toggled, this, &TYMainWindow::showBiblio);
230  _pHideOrShowBiblioAction->setEnabled(false);
231 
233  new QAction(QPixmap(IMG("id_icon_show_output")), TR("id_menuitem_show_output"), this);
234  _pHideOrShowOutputAction->setCheckable(true);
235  _pHideOrShowOutputAction->setStatusTip(TR("id_status_show_output"));
236  QObject::connect(_pHideOrShowOutputAction, &QAction::toggled, this, &TYMainWindow::showOutput);
237 
239  new QAction(QPixmap(IMG("id_icon_edit_curcalcul")), TR("id_menuitem_edit_curcalcul"), this);
240  _pEditCurCalculAction->setStatusTip(TR("id_status_edit_curcalcul"));
241  QObject::connect(_pEditCurCalculAction, &QAction::triggered, this, &TYMainWindow::editCurCalcul);
242  _pEditCurCalculAction->setEnabled(false);
243 
244  _pGoAltiAction = new QAction(QPixmap(IMG("id_icon_alti")), TR("id_menuitem_lancer_calcul_alti"), this);
245  _pGoAltiAction->setStatusTip(TR("id_status_lancer_alticalcul"));
246  QObject::connect(_pGoAltiAction, &QAction::triggered, this, &TYMainWindow::goAltiCalcul);
247  _pGoAltiAction->setEnabled(false);
248 
250  new QAction(QPixmap(IMG("id_icon_go_curcalcul")), TR("id_menuitem_lancer_calcul_courant"), this);
251  _pGoCurCalculAction->setStatusTip(TR("id_status_go_curcalcul"));
252  QObject::connect(_pGoCurCalculAction, &QAction::triggered, this, &TYMainWindow::goCurCalcul);
253  _pGoCurCalculAction->setEnabled(false);
254 
255  QAction* pPrefDialogAction =
256  new QAction(QPixmap(IMG("id_icon_prefdlg")), TR("id_menuitem_prefdlg"), this);
257  QObject::connect(pPrefDialogAction, &QAction::triggered, this, &TYMainWindow::showPreferenceDialog);
258 
259  // Barre de menu
260  QMenu* pFileMenu = new QMenu(TR("id_menu_file"), this);
261  menuBar()->addMenu(pFileMenu);
262 
263  QMenu* pNewMenu = new QMenu(TR("id_menuitem_new"), this);
264  pNewMenu->setTearOffEnabled(true);
265  pNewMenu->addAction(TR("id_menuitem_newprojet"), this, &TYMainWindow::createNewProjet);
266  pNewMenu->addAction(TR("id_menuitem_newgeoprojet"), this, &TYMainWindow::showZoneSelectPage);
267  pNewMenu->addAction(TR("id_menuitem_newsite"), this, &TYMainWindow::createNewSite);
268  pNewMenu->addAction(TR("id_menuitem_newbatiment"), this, &TYMainWindow::createNewBatiment);
269  pNewMenu->addAction(TR("id_menuitem_newmachine"), this, &TYMainWindow::createNewMachine);
270  pNewMenu->addAction(_pCreateNewAction);
271 
272  pFileMenu->addMenu(pNewMenu);
273  pFileMenu->addAction(_pOpenAction);
274  pFileMenu->addAction(_pCloseAction);
275  pFileMenu->addSeparator();
276  pFileMenu->addAction(_pSaveAction);
277  pFileMenu->addAction(_pSaveAsAction);
278  pFileMenu->addAction(_pSaveAsNoResultAction);
279  pFileMenu->addSeparator();
280  pFileMenu->addAction(_pShowPluginManagerAction);
281  pFileMenu->addSeparator();
282  pFileMenu->addAction(_pPrintAction);
283  pFileMenu->addSeparator();
284  pFileMenu->addAction(TR("id_menuitem_quit"), this, &TYMainWindow::quitte, QKeySequence("Ctrl+Q"));
285 
286  QMenu* pEditMenu = new QMenu(TR("id_menu_edit"), this);
287  menuBar()->addMenu(pEditMenu);
288  pEditMenu->addAction(_pUndoAction);
289  pEditMenu->addAction(_pRedoAction);
290  pEditMenu->addSeparator();
291  pEditMenu->addAction(_pCutAction);
292  pEditMenu->addAction(_pCopyAction);
293  pEditMenu->addAction(_pPasteAction);
294  pEditMenu->addSeparator();
295  pEditMenu->addAction(QPixmap(IMG("id_icon_prefdlg")), TR("id_menuitem_prefdlg"), this,
297 
298  _pWindowsMenu = new QMenu(TR("id_menu_windows"), this);
299  connect(_pWindowsMenu, &QMenu::aboutToShow, this, &TYMainWindow::windowsMenuAboutToShow);
300  menuBar()->addMenu(_pWindowsMenu);
301 
302  menuBar()->addSeparator();
303 
304  QMenu* pHelpMenu = new QMenu(TR("id_menu_help"), this);
305  menuBar()->addMenu(pHelpMenu);
306  pHelpMenu->addAction(TR("id_menuitem_help"), this, &TYMainWindow::showHelp, QKeySequence("F1"));
307  pHelpMenu->addSeparator();
308  pHelpMenu->addAction(TR("id_menuitem_about"), this, &TYMainWindow::about);
309 
310  // Barre d'outils fichier
311  _pMainToolbar = new QToolBar(TR("id_toolbar_file"), this);
312  addToolBar(_pMainToolbar);
313  QToolButton* pToolNewFile = new QToolButton(this);
314  pToolNewFile->setIcon(QPixmap(IMG("id_icon_new")));
315  pToolNewFile->setToolTip(TR("id_menuitem_new"));
316  pToolNewFile->setMenu(pNewMenu);
317  pToolNewFile->setPopupMode(QToolButton::InstantPopup);
318  _pMainToolbar->addWidget(pToolNewFile);
319  _pMainToolbar->addSeparator();
320  _pMainToolbar->addAction(_pOpenAction);
321  _pMainToolbar->addAction(_pSaveAction);
322  _pMainToolbar->addSeparator();
323  _pMainToolbar->addAction(_pPrintAction);
324  _pMainToolbar->addSeparator();
325  _pMainToolbar->addAction(_pCutAction);
326  _pMainToolbar->addAction(_pCopyAction);
327  _pMainToolbar->addAction(_pPasteAction);
328  _pMainToolbar->addSeparator();
329  _pMainToolbar->addAction(_pUndoAction);
330  _pMainToolbar->addAction(_pRedoAction);
331  _pMainToolbar->setObjectName("MainToolbar");
332 
333  // Barre d'outils des fenetres
334  _pWindowToolbar = new QToolBar(TR("id_toolbar_window"), this);
335  addToolBar(_pWindowToolbar);
339  _pWindowToolbar->addSeparator();
341  _pWindowToolbar->addSeparator();
342  _pWindowToolbar->addAction(pPrefDialogAction);
343  _pWindowToolbar->setObjectName("WindowToolbar");
344 
345  // Barre d'outils de calcul acoustique
346  _pCalculAcousticToolbar = new QToolBar(TR("id_toolbar_calculacoustic"), this);
347  addToolBar(_pCalculAcousticToolbar);
351  _pCalculAcousticToolbar->setObjectName("CalculAcousticToolbar");
352 
353  // Barre d'outils pour les modelers
354  _pToolbarModeler = new TYModelerToolbar(0, this, TR("id_toolbar_modeler"));
355  addToolBar(_pToolbarModeler);
356  _pToolbarModeler->setObjectName("ToolbarModeler");
357 
358  // Btn group pour Site
359  _pSiteBtnGroup = new QButtonGroup(this);
360  // _pSiteBtnGroup->hide();
361  _pSiteBtnGroup->setExclusive(true);
362 
363  // Barre d'outils Topographie
364  _pToolbarTopo = new TYTopoToolbar(_pSiteBtnGroup, this, TR("id_toolbar_topo"));
365  addToolBar(_pToolbarTopo);
366  _pToolbarTopo->setObjectName("ToolbarTopo");
367 
368  // Barre d'outils Calcul
369  _pToolbarCalcul = new TYCalculToolbar(_pSiteBtnGroup, this, TR("id_toolbar_calcul"));
370  addToolBar(_pToolbarCalcul);
371  _pToolbarCalcul->setObjectName("ToolbarCalcul");
372 
373  // Barre d'outils Infrastructure
374  _pToolbarInfra = new TYInfraToolbar(_pSiteBtnGroup, this, TR("id_toolbar_infra"));
375  addToolBar(_pToolbarInfra);
376  _pToolbarInfra->setObjectName("ToolbarInfra");
377 
378  // Btn group pour Machine
379  _pMachineBtnGroup = new QButtonGroup(this);
380  // _pMachineBtnGroup->hide();
381  _pMachineBtnGroup->setExclusive(true);
382 
383  // Barre d'outils Machine
384  _pToolbarMachine = new TYMachineToolbar(_pMachineBtnGroup, this, TR("id_toolbar_machine"));
385  addToolBar(_pToolbarMachine);
386  _pToolbarMachine->setObjectName("ToolbarMachine");
387 
388  // Btn group pour Face
389  _pFaceBtnGroup = new QButtonGroup(this);
390  // _pFaceBtnGroup->hide();
391  _pFaceBtnGroup->setExclusive(true);
392 
393  // Barre d'outils Face
394  _pToolbarFace = new TYFaceToolbar(_pFaceBtnGroup, this, TR("id_toolbar_Face"));
395  addToolBar(_pToolbarFace);
396  _pToolbarFace->setObjectName("ToolbarFace");
397 
398  // Btn group pour Batiment
399  _pBatimentBtnGroup = new QButtonGroup(this);
400  // _pBatimentBtnGroup->hide();
401  _pBatimentBtnGroup->setExclusive(true);
402 
403  // Barre d'outils Batiment
404  _pToolbarBatiment = new TYBatimentToolbar(_pBatimentBtnGroup, this, TR("id_toolbar_batiment"));
405  addToolBar(_pToolbarBatiment);
406  _pToolbarBatiment->setObjectName("ToolbarBatiment");
407 
408  // Fenetre Projet
409  _pProjetDockWnd = new QDockWidget(TR("id_toolbar_projet"), this);
410  _pProjetDockWnd->setFloating(false);
412  _pProjetDockWnd->setWidget(_pProjetFrame);
413  _pProjetDockWnd->setObjectName("ProjetDockWnd");
414  _pProjetDockWnd->setContentsMargins(0, 0, 0, 0);
415  addDockWidget(Qt::LeftDockWidgetArea, _pProjetDockWnd);
416 
417  // Fenetre Site
418  _pSiteDockWnd = new QDockWidget(TR("id_toolbar_site"), this);
419  _pSiteDockWnd->setFloating(false);
421  _pSiteDockWnd->setWidget(_pSiteFrame);
422  _pSiteDockWnd->setObjectName("SiteDockWnd");
423  addDockWidget(Qt::LeftDockWidgetArea, _pSiteDockWnd);
424 
425  // Fenetre Output
426  _pOutputDockWnd = new QDockWidget(TR("id_toolbar_output"), this);
427  _pOutputDockWnd->setFloating(false);
429  _pOutputDockWnd->setWidget(_pOutputFrame);
430  _pOutputDockWnd->setObjectName("OutputDockWnd");
431  addDockWidget(Qt::LeftDockWidgetArea, _pOutputDockWnd);
432 
433  // Connexion des signaux
434  QObject::connect(_pOutputDockWnd, &QDockWidget::visibilityChanged, this,
441  QObject::connect(_pProjetFrame, &TYProjetFrame::changeCurrentCalcul, this,
443  QObject::connect(_pWorkspace, &QMdiArea::subWindowActivated, this, &TYMainWindow::subWindowActivated);
444 
445  QShortcut* shortcut = new QShortcut(QKeySequence(Qt::Key_Escape), this);
446  connect(shortcut, &QShortcut::activated, this, &TYMainWindow::setDefaultCameraMode);
447 
448  // Connecte l'Action Manager de l'Application
450 
451  // Connecte le gestionnaire geographique IGN
453  QObject::connect(geoProvider, &TYIGNGeoProvider::geoProjectCreationRequested, this,
455 
456  // Desactive tous les boutons
458 
459  // On active la sauvegarde des instances de type TYElement et derivees
461 
462  // Ready to work !!
463  statusBar()->showMessage(TR("id_status_ready"));
464 
465  // Indique que les TYElement sont ok (rien a sauvegarder)
467 }
468 
470 {
471  delete _pHelpBrowser;
472  _pHelpBrowser = NULL;
473 }
474 
476 {
477  QMenu* returnedMenu = QMainWindow::createPopupMenu();
478  TYCustomPopupMenu* myMenu = new TYCustomPopupMenu();
479  myMenu->addActions(returnedMenu->actions());
480  delete returnedMenu;
481  return myMenu;
482 }
483 
485 {
486  // Main window
487  TYPreferenceManager::saveGeometryToPreferences(metaObject()->className(), this);
488 
489  // Dock windows
490  QObjectList objectsList = children(); // dockWindows();
491  QWidget* pDockWnd = NULL;
492  QObject* pObject = NULL;
493 
494  for (int _i = 0; _i < objectsList.size(); _i++)
495  {
496  pObject = objectsList[_i];
497  if ((pObject->objectName() == "ProjetDockWnd") || (pObject->objectName() == "SiteDockWnd") ||
498  (pObject->objectName() == "OutputDockWnd") ||
499  (strcmp(pObject->metaObject()->className(), "QToolBar") == 0) ||
500  (dynamic_cast<QToolBar*>(pObject) != nullptr))
501  {
502 
503  pDockWnd = (QWidget*)pObject;
504  QString key = pDockWnd->objectName();
505 
506  // Geometry
507  TYPreferenceManager::saveGeometryToPreferences(key, pDockWnd);
508  }
509  }
510 }
511 
513 
514 bool TYMainWindow::loadSettings(const QString& fileName)
515 {
516  // Only for loading settings
517  bool res = true;
518 
519  statusBar()->showMessage(TR("id_status_load_settings"), 3000);
520 
521  // Save user dir before loading settings from file for the case Settings.xml is copied from
522  // DefaultSettings.xml
523  QString userDir = QDir::toNativeSeparators(getTYApp()->tympanUserDir());
524  // Try to load MainWindowIHM.bin in order to restore Main Window state
525  auto inFile = searchSettingsFile(userDir, fileName, QString("MainWindowIHM.bin"),
526  QString("Settings4.[0-9]MainWindowIHM.bin"));
527  // If a file SettingsMainWindowIHM.bin has been found
528  if (inFile != nullptr && inFile->open(QIODevice::ReadOnly))
529  {
530  QByteArray byteArray = inFile->readAll();
531  if (!byteArray.isEmpty())
532  {
533  restoreState(byteArray);
534  }
535  inFile->close();
536  }
537 
538  // Init Settings.xml file
539  bool isCopiedFromDefaultSettings = false;
540  auto settingsFile =
541  searchSettingsFile(userDir, fileName, QString(".xml"), QString("Settings4.[0-9].xml"));
542 
543  // If initialization succeeds
544  res = res &&
545  TYPreferenceManager::init(fileName + ".xml", isCopiedFromDefaultSettings, std::move(settingsFile));
546  if (res)
547  {
548  // Load settings from file Settings.xml
549  res = res && TYPreferenceManager::read();
550  // If reading succeeded
551  if (res)
552  {
553  // If file is newly created, then we have to init path preferences with specific user path
554  if (isCopiedFromDefaultSettings)
555  {
556  TYPreferenceManager::setString(TYDIRPREFERENCEMANAGER, "WorkDirPath", userDir);
557  QString libraryDir = QDir::toNativeSeparators(userDir + "/library/");
558  TYPreferenceManager::setString(TYDIRPREFERENCEMANAGER, "BiblioPath", libraryDir);
559  }
560 
561  // Apply settings
562  TYPreferenceManager::loadGeometryFromPreferences(metaObject()->className(), this);
563 
564  // Dock windows
565  QObjectList objectsList = children(); // dockWindows();
566  QWidget* pDockWnd = NULL;
567  QObject* pObject = NULL;
568 
569  for (int _i = 0; _i < objectsList.size(); _i++)
570  {
571  pObject = objectsList[_i];
572  if ((pObject->objectName() == "ProjetDockWnd") || (pObject->objectName() == "SiteDockWnd") ||
573  (pObject->objectName() == "OutputDockWnd") ||
574  (strcmp(pObject->metaObject()->className(), "QToolBar") == 0) ||
575  (dynamic_cast<QToolBar*>(pObject) != nullptr))
576  {
577  pDockWnd = (QWidget*)pObject;
578  QString key = pDockWnd->objectName();
579  // Geometry
580  TYPreferenceManager::loadGeometryFromPreferences(key, pDockWnd);
581  }
582  }
583  }
584  }
585 
586  return res;
587 }
588 
589 std::unique_ptr<QFile> TYMainWindow::searchSettingsFile(const QString& TympanUserDir,
590  const QString& fileNameBegin,
591  const QString& fileNameEnd,
592  const QString& fileNamePattern)
593 {
594  // First try to load regular SettingsMainWindowIHM.bin
595  auto regularFile = std::make_unique<QFile>(QString(fileNameBegin) + QString(fileNameEnd));
596  if (regularFile->exists())
597  {
598  qDebug() << "Regular file" << QString(fileNameBegin + fileNameEnd) << "found.";
599  return regularFile;
600  }
601  else
602  // Else try to load the most recent file matching the pattern
603  {
604  qDebug() << "Regular file" << QString(fileNameBegin + fileNameEnd)
605  << "NOT found, searching for oldest files";
606 
607  // Create a QDir object for the specified folder
608  QDir folder(TympanUserDir);
609 
610  // Get a list of files matching the pattern
611  QStringList matchingFiles = folder.entryList(QStringList(fileNamePattern), QDir::Files);
612 
613  // Check if any matching files were found
614  if (!matchingFiles.isEmpty())
615  {
616  qDebug() << "File(s) macthing" << fileNamePattern << "pattern found in the folder.";
617 
618  QString selectedFile; // Variable to store the selected file
619  int maxDigit = -1; // Variable to store the maximum digit value
620 
621  // Iterate through the matching files
622  for (const QString& matchingFile : matchingFiles)
623  {
624  // Extract the digit 'x' from the file name
625  int digit = matchingFile.mid(10, 1).toInt();
626 
627  // Check if the current digit is greater than the maximum digit found so far
628  if (digit > maxDigit)
629  {
630  maxDigit = digit;
631  selectedFile = matchingFile;
632  }
633  }
634 
635  // Print and return the selected file
636  qDebug() << "Selected file: " << selectedFile;
637  return std::make_unique<QFile>(QDir::toNativeSeparators(TympanUserDir + "/" + selectedFile));
638  }
639  else
640  {
641  // Return nullptr if no file is found
642  qDebug() << "No matching files found in the folder.";
643  return nullptr;
644  }
645  }
646 }
647 
648 bool TYMainWindow::saveSettings(const QString& fileName)
649 {
650  bool res = false;
651 
652  QByteArray byteArray = saveState();
653  QFile* outFile = new QFile(QString(fileName) + QString("MainWindowIHM.bin"));
654  if (outFile->open(QIODevice::WriteOnly))
655  {
656  outFile->write(byteArray);
657  outFile->close();
658  }
659 
660  delete outFile;
661 
662  // Sauvegarde des settings
663  QString finalFileName = QString(fileName) + QString(".xml");
664  TYPreferenceManager::setFileName(finalFileName);
665  res = TYPreferenceManager::write();
666 
667  return res;
668 }
669 
671 {
672  _pHelpBrowser->show();
673 }
674 
676 {
677  // Dlg "A propos de Tympan"
678  QMessageBox* pAboutTympan = new QMessageBox(NULL);
679  pAboutTympan->setWindowTitle(windowTitle());
680  QString msg = TR("id_about_msg");
681  msg = msg.arg(TY_PRODUCT_NAME_);
682  msg = msg.arg(TY_CURRENT_RELEASE_);
683  msg = msg.arg(TY_PRODUCT_PLATFORM_);
684  msg = msg.arg(TY_PRODUCT_COPYRIGHT_);
685  msg = msg.arg(TY_BUILD_DATE_);
686  msg = msg.arg(TY_BUILD_TIME_);
687  msg = msg.arg(TY_CUSTOMER_);
688  msg = msg.arg(TY_LICENCE_NUMBER_);
689  msg = msg.arg(TY_TIME_LIMIT_);
690  pAboutTympan->setText(msg);
691  pAboutTympan->setIconPixmap(IMG("id_logo_about"));
692 
693  // Affichage
694  pAboutTympan->exec();
695 
696  // Nettoyage
697  delete pAboutTympan;
698  pAboutTympan = NULL;
699 }
700 
702 {
703  if (!pElt)
704  {
705  return true;
706  }
707 
708  TYProjet* pProj = dynamic_cast<TYProjet*>(pElt);
709  if (pProj != nullptr)
710  {
711  makeProjetModeler(pProj);
712  return true;
713  }
714  else if (pElt->isA("TYSiteNode"))
715  {
716  makeSiteModeler(static_cast<TYSiteNode*>(pElt));
717  return true;
718  }
719  else if (pElt->isA("TYBatiment"))
720  {
721  return (makeBatimentModeler(static_cast<TYBatiment*>(pElt)));
722  }
723  else if (pElt->isA("TYMachine"))
724  {
725  return (makeMachineModeler(static_cast<TYMachine*>(pElt)));
726  }
727  else
728  {
729  return true;
730  }
731 }
732 
734 {
735  bool ret = false;
736  TYBatimentModelerFrame* pBatimentModeler =
737  new TYBatimentModelerFrame(NULL, _pWorkspace, "TYBatimentModelerFrame");
738  pBatimentModeler->setAttribute(Qt::WA_DeleteOnClose);
739  _pWorkspace->addSubWindow(pBatimentModeler)->setObjectName("TYBatimentModelerFrame");
740 
741  QObject::connect(pBatimentModeler, &TYBatimentModelerFrame::editorModeChanged, this,
743  QObject::connect(pBatimentModeler, &TYBatimentModelerFrame::frameResized, this,
745  QObject::connect(pBatimentModeler, &QObject::destroyed, this, &TYMainWindow::onDestroyed);
746 
747  if (!pBatiment)
748  {
749  pBatiment = new TYBatiment();
750  }
751  pBatimentModeler->setBatiment(pBatiment);
752 
753  pBatimentModeler->showMaximized();
754  pBatimentModeler->fit();
755 
756  // Waiting for the "aboutToClose" signal to be emited before moving to the next step
757  QEventLoop loop;
758  connect(pBatimentModeler, &TYBatimentModelerFrame::aboutToClose, &loop, &QEventLoop::quit);
759  loop.exec();
760  // If there is no volume, the modeler maker returns false
761  if (pBatiment->getNbChild() == 0)
762  {
763  ret = false;
764  }
765  else
766  {
767  ret = true;
768  }
769  return ret;
770 }
771 
773 {
774  bool ret = false;
775  TYMachineModelerFrame* pMachineModeler =
776  new TYMachineModelerFrame(NULL, _pWorkspace, "TYMachineModelerFrame");
777  pMachineModeler->setAttribute(Qt::WA_DeleteOnClose);
778 
779  _pWorkspace->addSubWindow(pMachineModeler)->setObjectName("TYMachineModelerFrame");
780 
781  QObject::connect(pMachineModeler, &TYMachineModelerFrame::editorModeChanged, this,
783  QObject::connect(pMachineModeler, &TYMachineModelerFrame::frameResized, this,
785  QObject::connect(pMachineModeler, &QObject::destroyed, this, &TYMainWindow::onDestroyed);
786 
787  if (!pMachine)
788  {
789  pMachine = new TYMachine();
790  }
791  pMachineModeler->setMachine(pMachine);
792 
793  pMachineModeler->showMaximized();
794  pMachineModeler->fit();
795 
796  // Waiting for the "aboutTpClose" signal to be emited before moving to the next step
797  QEventLoop loop;
798  connect(pMachineModeler, &TYMachineModelerFrame::aboutToClose, &loop, &QEventLoop::quit);
799  loop.exec();
800  // If there is no volume, the modeler maker returns false
801  if (pMachine->getNbChild() == 0)
802  {
803  ret = false;
804  }
805  else
806  {
807  ret = true;
808  }
809  return ret;
810 }
811 
813 {
814  TYSiteModelerFrame* pSiteModeler = new TYSiteModelerFrame(pSite, _pWorkspace, "TYSiteModelerFrame");
815  pSiteModeler->setAttribute(Qt::WA_DeleteOnClose);
816 
817  _pWorkspace->addSubWindow(pSiteModeler)->setObjectName("TYSiteModelerFrame");
818 
819  QObject::connect(pSiteModeler, &TYSiteModelerFrame::editorModeChanged, this,
821  QObject::connect(pSiteModeler, &TYSiteModelerFrame::frameResized, this,
823  QObject::connect(pSiteModeler, &QObject::destroyed, this, &TYMainWindow::onDestroyed);
824 
825  pSiteModeler->showMaximized();
826  pSiteModeler->fit();
827 }
828 
830 {
831  TYSiteModelerFrame* pSiteModeler = new TYSiteModelerFrame(pProjet, _pWorkspace, "TYSiteModelerFrame");
832  pSiteModeler->setAttribute(Qt::WA_DeleteOnClose);
833 
834  _pWorkspace->addSubWindow(pSiteModeler)->setObjectName("TYSiteModelerFrame");
835 
836  QObject::connect(pSiteModeler, &TYSiteModelerFrame::editorModeChanged, this,
838  QObject::connect(pSiteModeler, &TYSiteModelerFrame::frameResized, this,
840  QObject::connect(pSiteModeler, &QObject::destroyed, this, &TYMainWindow::onDestroyed);
841 
842  pSiteModeler->showMaximized();
843  pSiteModeler->fit();
844 }
845 
847 {
848  QObject::disconnect(this, &TYMainWindow::onUndo, 0, 0);
849  QObject::disconnect(this, &TYMainWindow::onRedo, 0, 0);
850 
851  if (pActionManager)
852  {
853  QObject::connect(this, &TYMainWindow::onUndo, pActionManager, &TYActionManager::undo);
854  QObject::connect(this, &TYMainWindow::onRedo, pActionManager, &TYActionManager::redo);
855 
856  QObject::connect(pActionManager, &TYActionManager::undoRedoChanged, this,
858  pActionManager->emitUndoRedo();
859  }
860  else
861  {
863  }
864 }
865 
867 {
868  connectActionManager(getTYApp()->getActionManager());
869 }
870 
871 void TYMainWindow::updateModelers(bool clipping /*=true*/, bool axesAndGrid /*=true*/,
872  bool displayList /*=true*/)
873 {
874  QList<QMdiSubWindow*> windows = _pWorkspace->subWindowList();
875 
876  for (int i = 0; i < int(windows.count()); ++i)
877  {
878  QWidget* internal_window = windows.at(i)->widget();
879 
880  TYModelerFrame* pInW = dynamic_cast<TYModelerFrame*>(internal_window);
881  if (pInW != nullptr)
882  {
883  pInW->updateView(clipping, axesAndGrid);
884  if (displayList)
885  {
886  TYRenderWindowInteractor* pView = ((TYModelerFrame*)internal_window)->getView();
887  TYOpenGLRenderer* pOpenGLRenderer = pView->getRenderer();
888 
889  TYModelerFrame* pModelerFrame = dynamic_cast<TYModelerFrame*>(internal_window);
890  if (pModelerFrame != nullptr)
891  {
892  // Update state of keep rays button
893  bool keepRays = false;
895  {
897  }
898  pModelerFrame->setKeepRays(keepRays);
899  }
900  TYSiteModelerFrame* pSiteModelerFrame = dynamic_cast<TYSiteModelerFrame*>(internal_window);
901  if (pSiteModelerFrame != nullptr)
902  {
903  // Enable or disable altimetry button
904  bool enableAltimetrieButton = false;
906  {
907  enableAltimetrieButton = _pSiteFrame->getSiteNodeRoot()->getAltimetry()->isUpToDate();
908  }
909  pSiteModelerFrame->enableAltimetrieButton(enableAltimetrieButton);
910  // If altimetry is not consistent with data then hide it
911  if (!enableAltimetrieButton)
912  {
913  pSiteModelerFrame->showAltimetrie(false);
914  }
915  }
916 
917  pOpenGLRenderer->invalidateScene();
918  ((TYModelerFrame*)internal_window)->updateView(clipping, axesAndGrid);
919  pView->update();
920  }
921  }
922  }
923  if (_pCurrentModeler != nullptr)
924  {
925  _pCurrentModeler->setFocus();
926  }
927 }
928 
929 void TYMainWindow::updateModelersElementGraphic(bool force /* = false */)
930 {
931  QList<QMdiSubWindow*> windows = _pWorkspace->subWindowList();
932 
933  for (int i = 0; i < int(windows.count()); ++i)
934  {
935  QWidget* internal_window = windows.at(i)->widget();
936 
937  TYModelerFrame* pInW = dynamic_cast<TYModelerFrame*>(internal_window);
938  if (pInW != nullptr)
939  {
940  pInW->updateElementGraphic(force);
941  }
942  }
943 }
944 
946 {
947  QList<QMdiSubWindow*> windows = _pWorkspace->subWindowList();
948 
949  for (int i = 0; i < int(windows.count()); ++i)
950  {
951  QWidget* internal_window = windows.at(i)->widget();
952 
953  TYModelerFrame* pInW = dynamic_cast<TYModelerFrame*>(internal_window);
954 
955 #ifdef _DEBUG
956  // For Debug purpose
957  QString windowTitle = internal_window->windowTitle();
958 #endif
959 
960  if (pInW != nullptr)
961  {
962  if (pInW->isActiveWindow())
963  {
964  _pCurrentModeler = pInW;
965  }
966  TYSiteModelerFrame* psiteframe = dynamic_cast<TYSiteModelerFrame*>(internal_window);
967  if (psiteframe != nullptr)
968  {
969  psiteframe->getView()->getRenderer()->clearTabSelectedElement();
970  psiteframe->setProjet(result);
971  psiteframe->getView()->getRenderer()->invalidateScene();
972  psiteframe->updateView();
973  psiteframe->setMaillageRenderModeSlot();
974  }
975  else
976  {
977  TYBatimentModelerFrame* pbatimentframe =
978  dynamic_cast<TYBatimentModelerFrame*>(internal_window);
979  if (pbatimentframe != nullptr)
980  {
981  TYUUID uuid = pbatimentframe->getBatiment()->getID();
982  TYElement* newElement = TYElement::getInstance(uuid);
983  // When batiment modeler is empty, newElement is null
984  if (newElement != nullptr)
985  {
986  pbatimentframe->setBatiment((TYBatiment*)newElement);
987  }
988  }
989  TYMachineModelerFrame* pmachineframe = dynamic_cast<TYMachineModelerFrame*>(internal_window);
990  if (pmachineframe != nullptr)
991  {
992  TYUUID uuid = pmachineframe->getMachine()->getID();
993  TYElement* newElement = TYElement::getInstance(uuid);
994  // When machine modeler is empty, newElement is null
995  if (newElement != nullptr)
996  {
997  pmachineframe->setMachine((TYMachine*)newElement);
998  }
999  }
1000  }
1001  }
1002  }
1003  if (_pCurrentModeler != nullptr)
1004  {
1005  _pCurrentModeler->setFocus();
1006  }
1007 }
1008 
1010 {
1011  QList<QMdiSubWindow*> windows = _pWorkspace->subWindowList();
1012 
1013  for (int i = 0; i < int(windows.count()); ++i)
1014  {
1015  QWidget* internal_window = windows.at(i)->widget();
1016  QWidget* container_window = windows.at(i);
1017 
1018  if (dynamic_cast<TYModelerFrame*>(internal_window) != nullptr)
1019  {
1020  if (static_cast<TYModelerFrame*>(internal_window)->getElement() == pElement)
1021  {
1022  // internal_window->close();
1023  container_window->close();
1024  }
1025  }
1026  }
1027 }
1028 
1030 {
1031  QList<QMdiSubWindow*> windows = _pWorkspace->subWindowList();
1032 
1033  for (int i = 0; i < int(windows.count()); ++i)
1034  {
1035  QWidget* container_window = windows.at(i);
1036  container_window->close();
1037  }
1038 }
1039 
1041 {
1043  {
1044  _pProjetFrame->getProjet()->getCurrentCalcul()->edit(this);
1045  }
1046 }
1047 
1049 {
1051  logger.debug("goAltiCalcul");
1052  if (!_pSiteFrame)
1053  {
1054  return;
1055  }
1056 
1057  LPTYSiteNode pRootSite = _pSiteFrame->getSiteNodeRoot();
1058  if (!pRootSite)
1059  {
1060  return;
1061  }
1062 
1064 }
1065 
1067 {
1069 }
1070 
1072 {
1073  _pWindowsMenu->clear();
1074 
1075  QAction* cascadeId =
1076  _pWindowsMenu->addAction(TR("id_menuitem_cascade"), _pWorkspace, &QMdiArea::cascadeSubWindows);
1077  QAction* tileId =
1078  _pWindowsMenu->addAction(TR("id_menuitem_tile"), _pWorkspace, &QMdiArea::tileSubWindows);
1079 
1080  QList<QMdiSubWindow*> windows = _pWorkspace->subWindowList();
1081 
1082  if (windows.isEmpty())
1083  {
1084  cascadeId->setEnabled(false);
1085  tileId->setEnabled(false);
1086  }
1087 
1088  _pWindowsMenu->addSeparator();
1089 
1090  QMenu* viewMenu = createPopupMenu();
1091  viewMenu->setTitle(TR("id_menuitem_views"));
1092  _pWindowsMenu->addMenu(viewMenu);
1093 
1094  _pWindowsMenu->addSeparator();
1095 
1096  for (int i = 0; i < int(windows.count()); ++i)
1097  {
1098  QWidget* internal_window = windows.at(i)->widget();
1099 
1100  if (!internal_window)
1101  {
1102  break;
1103  } // Securite
1104 
1105  QAction* id = _pWindowsMenu->addAction(internal_window->windowTitle(), this,
1107  id->setData(i);
1108  id->setChecked(_pWorkspace->activeSubWindow() == windows.at(i));
1109  }
1110 }
1111 
1113 {
1114  QAction* action = (QAction*)sender();
1115  int id = action->data().toInt();
1116 
1117  QWidget* pWidget = _pWorkspace->subWindowList().at(id)->widget();
1118 
1119  if (pWidget)
1120  {
1121  pWidget->showNormal();
1122  pWidget->setFocus();
1123 
1124  if (QString(pWidget->metaObject()->className()).compare("TYSpectreManager") == 0)
1125  {
1126  _pHideOrShowSpectreMngrAction->setChecked(true);
1127  }
1128  else if (QString(pWidget->metaObject()->className()).compare("TYDataBaseFrame") == 0)
1129  {
1130  _pHideOrShowBiblioAction->setChecked(true);
1131  }
1132  else if (QString(pWidget->metaObject()->className()).compare("TYMaillageManager") == 0)
1133  {
1134  _pHideOrShowMaillageMngrAction->setChecked(true);
1135  }
1136  }
1137 }
1138 
1140 {
1141  if (_pCurrentModeler != NULL)
1142  {
1144  }
1145 }
1146 
1148 {
1149  _pCurrentModeler = nullptr;
1150  QWidget* pW = NULL;
1151  QMdiSubWindow* subWindow = _pWorkspace->activeSubWindow();
1152  if (_pWorkspace->subWindowList().count() > 0 && subWindow)
1153  {
1154  pW = subWindow->widget();
1155  }
1156 
1157  _pPrintAction->setEnabled(false);
1158 
1159  // Toolbars modeler
1161  _pToolbarInfra->activeButtons(false);
1162  _pToolbarTopo->activeButtons(false);
1163  _pSiteBtnGroup->disconnect();
1164 
1166  _pMachineBtnGroup->disconnect();
1167 
1168  _pToolbarFace->activeButtons(false);
1169  _pFaceBtnGroup->disconnect();
1170 
1172  _pBatimentBtnGroup->disconnect();
1173 
1175  _pBatimentBtnGroup->disconnect();
1176 
1177  // TODO Check this work around : it seems we were emptying the BtnGroups here,
1178  // which is a priori doubtful
1179  /*
1180  _pToolbarModeler->removeFromButtonGroup(_pSiteBtnGroup);
1181  _pToolbarModeler->removeFromButtonGroup(_pMachineBtnGroup);
1182  _pToolbarModeler->removeFromButtonGroup(_pFaceBtnGroup);
1183  _pToolbarModeler->removeFromButtonGroup(_pBatimentBtnGroup);
1184  */
1185 
1186  // Disambiguate the overloaded signals
1187  void (QButtonGroup::*qButtonGroup_clicked)(int) = &QButtonGroup::idClicked;
1188  void (TYFaceModelerFrame::*tyFaceModelerFrame_editorModeChanged)(int) =
1190 
1191  connectDefaultActionManager(); // On commence par desactiver tous les boutons
1192 
1193  if (pW == NULL)
1194  {
1196  return;
1197  }
1198 
1199  if (dynamic_cast<TYModelerFrame*>(pW) != nullptr)
1200  {
1201  TYModelerFrame* pModeler = (TYModelerFrame*)pW;
1202  _pCurrentModeler = pModeler;
1203 
1205 
1206  _pPrintAction->setEnabled(true);
1207 
1208  QObject::connect(pModeler, &TYModelerFrame::viewTypeChanged, _pToolbarModeler,
1210 
1211  // On desactive toutes les toolbars...
1213  _pToolbarInfra->activeButtons(false);
1214  _pToolbarTopo->activeButtons(false);
1217  _pToolbarFace->activeButtons(false);
1218  // ...Puis on active celles qui nous sont utiles
1219 
1220  if (QString(pW->metaObject()->className()).compare("TYSiteModelerFrame") == 0)
1221  {
1223 
1224  QObject::connect(_pSiteBtnGroup, qButtonGroup_clicked, this, &TYMainWindow::saveCurSiteMode);
1225  QObject::connect(_pSiteBtnGroup, qButtonGroup_clicked, pS, &TYSiteModelerFrame::setEditorMode);
1226 
1227  // On fait en sorte de n'activer la toolbar de calcul que pour le modeler pointant
1228  // sur le site racine ou le projet
1229  bool bActiveCalculToolBar = false;
1230 
1231  // On recupere le site node represente
1232  if (pS->getElement()->isA("TYProjet"))
1233  {
1234  bActiveCalculToolBar = true;
1235  }
1236  else
1237  {
1238  if (TYSiteNode::safeDownCast(pS->getElement())->getRoot())
1239  {
1240  bActiveCalculToolBar = true;
1241  }
1242  }
1243 
1244  // Si le calcul est bloque, on ne peut modifier le projet // DTn 20110915 : Meme comportement
1245  // dans tous les cas
1248  {
1249  _pToolbarCalcul->activeButtons(bActiveCalculToolBar);
1253  }
1254  else
1255  {
1256  _pToolbarCalcul->activeButtons(bActiveCalculToolBar);
1260  }
1261 
1263 
1265  }
1266  else if (QString(pW->metaObject()->className()).compare("TYMachineModelerFrame") == 0)
1267  {
1269 
1270  QObject::connect(_pMachineBtnGroup, qButtonGroup_clicked, this,
1272  QObject::connect(_pMachineBtnGroup, qButtonGroup_clicked, pM,
1274 
1275  // Si le calcul est bloque, on ne peut modifier le projet
1277  TYCalcul::Locked)) // DTn : Neutralisation : 20110915
1278  {
1281  }
1282  else
1283  {
1286  }
1287 
1289 
1291  }
1292  else if (QString(pW->metaObject()->className()).compare("TYBatimentModelerFrame") == 0)
1293  {
1295 
1296  QObject::connect(_pBatimentBtnGroup, qButtonGroup_clicked, this,
1298  QObject::connect(_pBatimentBtnGroup, qButtonGroup_clicked, pB,
1300 
1302  TYCalcul::Locked)) // DTn : Neutralisation : 20110915
1303  {
1304  _pToolbarModeler->activeModif(false);
1306  }
1307  else
1308  {
1311  }
1312 
1314 
1316  }
1317  else if (QString(pW->metaObject()->className()).compare("TYFaceModelerFrame") == 0)
1318  {
1320 
1321  QObject::disconnect(pF, tyFaceModelerFrame_editorModeChanged, this,
1323  QObject::connect(pF, tyFaceModelerFrame_editorModeChanged, this, &TYMainWindow::saveCurFaceMode);
1324 
1325  QObject::connect(_pFaceBtnGroup, qButtonGroup_clicked, this, &TYMainWindow::saveCurFaceMode);
1326  QObject::connect(_pFaceBtnGroup, qButtonGroup_clicked, pF, &TYFaceModelerFrame::setEditorMode);
1327 
1329  TYCalcul::Locked)) // DTn : Neutralisation : 20110915
1330  {
1331  _pToolbarModeler->activeModif(false);
1332  _pToolbarFace->activeButtons(false);
1333  }
1334  else
1335  {
1338  }
1339 
1341 
1343  }
1344 
1346 
1347  pModeler->getView()->getRenderer()->invalidateScene();
1348  }
1349  else
1350  {
1352  _pCurrentModeler = NULL;
1353  }
1354 }
1355 
1357 {
1358  _curSiteMode = mode;
1359  assert(_pSiteBtnGroup->button(mode)); // XXX This is a bug point : mode does not match a button.
1360  _pSiteBtnGroup->button(mode)->setChecked(true);
1361 }
1362 
1364 {
1365  _curMachineMode = mode;
1366  assert(_pMachineBtnGroup->button(mode));
1367  _pMachineBtnGroup->button(mode)->setChecked(true);
1368 }
1369 
1371 {
1372  _curBatimentMode = mode;
1373  assert(_pBatimentBtnGroup->button(mode)); // XXX This is a bug point : mode does not match a button.
1374  _pBatimentBtnGroup->button(mode)->setChecked(true);
1375 }
1376 
1378 {
1379  _curFaceMode = mode;
1380  assert(_pFaceBtnGroup->button(mode));
1381  _pFaceBtnGroup->button(mode)->setChecked(true);
1382 }
1383 
1384 void TYMainWindow::updateUndoRedo(bool undoAvailable, bool redoAvailable, const QString& undoCmd,
1385  const QString& redoCmd)
1386 {
1387  _pUndoAction->setEnabled(undoAvailable);
1388  _pRedoAction->setEnabled(redoAvailable);
1389 
1390  if (!undoCmd.isEmpty())
1391  {
1392  _pUndoAction->setText(TR("id_menuitem_undo_name").arg(undoCmd));
1393  }
1394  else
1395  {
1396  _pUndoAction->setText(TR("id_menuitem_undo_na"));
1397  }
1398 
1399  if (!redoCmd.isEmpty())
1400  {
1401  _pRedoAction->setText(TR("id_menuitem_redo_name").arg(redoCmd));
1402  }
1403  else
1404  {
1405  _pRedoAction->setText(TR("id_menuitem_redo_na"));
1406  }
1407 
1408  _pUndoAction->setToolTip(_pUndoAction->text());
1409  _pRedoAction->setToolTip(_pRedoAction->text());
1410 }
1411 
1413 {
1414  LPTYSiteNode mainSite = this->getProjetFrame()->getProjet()->getSite();
1415  mainSite->getTopographie()->addCrbNiv(courbeNiveau);
1416  TYProjet* pProjet = getTYApp()->getCurProjet();
1417  if (pProjet)
1418  {
1420  if (pCalcul)
1421  {
1422  pCalcul->addToSelection(courbeNiveau);
1423  }
1424  }
1425 }
1426 
1428 {
1429  _pProjetFrame->setProjet(pProjet);
1430 
1431  // if (pProjet) {
1432  // getTYApp()->setCurSiteNode(pProjet->getSite());
1433  //} else {
1434  // getTYApp()->setCurSiteNode(NULL);
1435  //}
1436 
1437  _pCloseAction->setEnabled(pProjet ? true : false);
1438  // updateCurCalcul();
1439 }
1440 
1442 {
1443  _pSiteFrame->setSiteNodeRoot(pSiteNode);
1444  _pCloseAction->setEnabled(pSiteNode ? true : false);
1445 }
1446 
1448 {
1450  {
1451  if (!_pProjetFrame->getProjet()->getStatusSolver()) // Le solveur du calcul n'est pas disponible
1452  {
1453  if (QMessageBox::warning(this, "Tympan", TR("id_msg_solver_out"), QMessageBox::Yes,
1454  QMessageBox::No) == QMessageBox::Yes)
1455  {
1456  // L'utilisateur accepte d'utiliser le solveur par defaut
1458  OGenID(QString(DEFAULT_SOLVER_UUID)));
1460  _pProjetFrame->getProjet()->setStatusSolver(true); // On est ok sur le solveur
1461  }
1462  else
1463  {
1464  // Le calcul est bloque. Si l'utilisateur le debloque, lancer le calcul appelera le solveur
1465  // courant
1467  }
1468  }
1469  }
1470 
1471  _pGoCurCalculAction->setEnabled(true);
1472  _pGoAltiAction->setEnabled(true);
1473  _pEditCurCalculAction->setEnabled(true);
1474 }
1475 
1477 {
1478  close(); // Fermeture de l'lement precedemment actif
1479  TYCreateElementDialog* pDlg = new TYCreateElementDialog(this);
1480  pDlg->exec();
1482 }
1483 
1485 {
1486  close(); // Fermeture de l'élément précédemment actif
1487  TYCreateElementDialog* pDlg = new TYCreateElementDialog(this);
1488  pDlg->createElement("TYProjet");
1490 
1491  // Save project
1492  bool ret = saveAs();
1493  if (!ret)
1494  {
1495  qInfo() << "Impossible to save project file to " << getTYApp()->getCurrentFileName();
1496  TYElement::setIsSavedOk(false);
1497  close();
1498  return;
1499  }
1500 
1501  // CLM-NT33 - Ouverture automatique du modeler projet
1502  // DTn 20111003 Plus la peine : ouverture assuree par le openElementDialog appele par le
1503  // createElementDialog
1504  // makeProjetModeler(_pProjetFrame->getProjet());
1505 }
1506 
1508 {
1509  close(); // Fermeture de l'lement precedemment actif
1510 
1511  // Initialize geo provider engine if necessary
1512  if (!TYIGNGeoProvider::getInstance()->isInitialised())
1513  {
1515  }
1516 
1517  // If TYMPAN_MOCK_IGN option is activated
1518 #if MOCK_IGN
1519  bool hasMockSucceeded;
1520  hasMockSucceeded = TYIGNGeoProvider::getInstance()->mockGeoPf();
1521  if (!hasMockSucceeded)
1522  {
1523  qCritical()
1524  << "Mocking IGN Geoplatform resources has failed. Please check mock resources availability.";
1525  }
1526 
1527 #else
1528  // Call the function to open the modal window
1530 #endif
1531 }
1532 
1534 {
1535  OMessageManager::get()->debug(QString("TYMainWindow::createNewGeoProjet"));
1536  TYCreateElementDialog* pDlg = new TYCreateElementDialog(this);
1537  pDlg->createElement("TYProjet");
1538  LPTYSiteNode mainSite = this->getProjetFrame()->getProjet()->getSite();
1539 
1540  // Save project
1541  bool ret = saveAs();
1542  if (!ret)
1543  {
1544  qInfo() << "Impossible to save project file to " << getTYApp()->getCurrentFileName();
1545  TYElement::setIsSavedOk(false);
1546  close();
1547  return;
1548  }
1549 
1550  QFileInfo fileInfo(getTYApp()->getCurrentFileName());
1551  QString imageFilePath =
1552  fileInfo.path().replace("\\", "/") + "/" + fileInfo.completeBaseName() + "." + "png";
1553  bool retImageSave = TYIGNGeoProvider::getInstance()->saveImageToFile(imageFilePath);
1554  if (!retImageSave)
1555  {
1556  qInfo() << "Impossible to save image file to " << imageFilePath;
1557  TYElement::setIsSavedOk(false);
1558  close();
1559  return;
1560  }
1561 
1562  mainSite->setUseTopoFile(true);
1563 #if MOCK_IGN
1564  imageFilePath = "C:/projects/tympan/issues/530 - Mock IGN/image.png";
1565  mainSite->setTopoFileName(imageFilePath);
1567 #else
1568  mainSite->setTopoFileName(imageFilePath);
1569 #endif
1570 
1571  // Set current working directory of the application to folder containing background image to ensure
1572  // correct loading of topographic file.
1573  QString dirName = QFileInfo(imageFilePath).absolutePath();
1574  QDir::setCurrent(dirName);
1575 
1576  // Build level curves from geo provider
1577  std::shared_ptr<TYIGNLevelCurvesParser> parser = TYIGNGeoProvider::getInstance()->_parser;
1578  // Build coordinate system to build level curves
1579 
1580  QString coord = TYIGNGeoProvider::getInstance()->getLandtakeCoord().trimmed();
1581  if (coord.isEmpty())
1582  {
1583  qDebug() << "Error getting selected zone coords, aborting project creation";
1584  TYElement::setIsSavedOk(false);
1585  close();
1586  return;
1587  }
1588  QStringList listCoords = coord.split(",");
1589  const int len = listCoords.size();
1590  if (len != 4)
1591  {
1592  qDebug() << "The zone must be a box, aborting project creation";
1593  TYElement::setIsSavedOk(false);
1594  close();
1595  return;
1596  }
1597 
1598  std::vector<double> coordsDouble = TYIGNGeoProvider::getInstance()->coordinatesToDouble(coord);
1599  OBox selectedZone{coordsDouble[0], coordsDouble[1], 0.0, coordsDouble[2], coordsDouble[3], 0.0};
1600  OCoord3D SIGCoords{(selectedZone._min._x + selectedZone._max._x) * 0.5,
1601  (selectedZone._min._y + selectedZone._max._y) * 0.5, 0.0};
1602  // Temporary scale set
1603  QString imageWidthString = TYIGNGeoProvider::getInstance()->getImageWidth();
1604  double imageWidth = imageWidthString.toDouble();
1605  QString scaleFactorString = TYIGNGeoProvider::getInstance()->getScaleFactor();
1606  qInfo() << "scaleFactorString : " << scaleFactorString;
1607  double scaleFactor = scaleFactorString.toDouble();
1608  qInfo() << "scaleFactor : " << scaleFactor;
1609  mainSite->setEchelle(abs(coordsDouble[2] - coordsDouble[0]) * scaleFactor / imageWidth);
1610  connect(parser.get(), &TYIGNLevelCurvesParser::courbeNiveauCreated, this,
1612  TYIGNGeoProvider::getInstance()->buildLevelCurves(SIGCoords, selectedZone, scaleFactor);
1613 
1614  // Landtake creation
1615  std::vector<TYPoint> coords(4);
1616  double demiX = abs(coordsDouble[2] - coordsDouble[0]) * scaleFactor / 2;
1617  double demiY = abs(coordsDouble[3] - coordsDouble[1]) * scaleFactor / 2;
1618  coords[0] = TYPoint(demiX, demiY, 0, false);
1619  coords[1] = TYPoint(demiX, -demiY, 0, false);
1620  coords[2] = TYPoint(-demiX, -demiY, 0, false);
1621  coords[3] = TYPoint(-demiX, demiY, 0, false);
1622  mainSite->setEmprise(coords);
1623  mainSite->setUseEmpriseAsCrbNiv(false);
1624 
1625  mainSite->loadTopoFile();
1626 
1628 
1629  ret = save();
1630  if (!ret)
1631  {
1632  qInfo() << "Impossible to save project file to " << getTYApp()->getCurrentFileName();
1633  TYElement::setIsSavedOk(false);
1634  close();
1635  return;
1636  }
1637 
1638  // Update
1639  getSiteFrame()->updateList();
1640  updateModelers(false, false);
1641 }
1642 
1644 {
1645  close(); // Fermeture de l'lement precedemment actif
1646  TYCreateElementDialog* pDlg = new TYCreateElementDialog(this);
1647  pDlg->createElement("TYSiteNode");
1649 }
1650 
1652 {
1653  close(); // Fermeture de l'lement precedemment actif
1654  TYCreateElementDialog* pDlg = new TYCreateElementDialog(this);
1655  pDlg->createElement("TYBatiment");
1657 }
1658 
1660 {
1661  close(); // Fermeture de l'lement precedemment actif
1662  TYCreateElementDialog* pDlg = new TYCreateElementDialog(this);
1663  pDlg->createElement("TYMachine");
1665 }
1666 
1668 {
1669  close(); // Ferme l'element en cours en demandant la sauvegarde si necessaire
1670  if (!_closeAndQuit) // L'utilisateur ne souhaite pas fermer son projet
1671  {
1672  _closeAndQuit = true;
1673  return;
1674  }
1675 
1676  TYOpenElementDialog* pDlg = new TYOpenElementDialog(this);
1677  pDlg->setMultiSelect(false); // Un seul element peut etre selectionne
1678  pDlg->setDirName(getTYApp()->getCurrentDirName());
1679  pDlg->open();
1680 
1681  if (pDlg->result() == QDialog::Accepted) // si le choix du fichier XML est OK
1682  {
1683  // CLM-NT33 - Choix automatique
1684  if (pDlg->getAvailableElements().size() == 1)
1685  {
1686  pDlg->openElement(pDlg->getAvailableElements()[0]);
1687  }
1688  else
1689  {
1690  pDlg->exec();
1691  }
1692 
1693  TYApplication::setOverrideCursor(Qt::WaitCursor);
1694 
1695  QString strExtend = "";
1696  if (pDlg->isFileReadOnly())
1697  {
1698  strExtend = TR("id_status_file_ro");
1699  _pSaveAction->setEnabled(false); // Desactivation de la fnction de sauvegarde
1700  }
1701 
1702  QString fileName = pDlg->getFileName(); // Nom du fichier lu
1703  setWindowTitle(TR("id_caption") + "-" + TY_CURRENT_RELEASE_ + " (" + TY_PRODUCT_PLATFORM_ +
1704  ") : " + fileName + ' ' + strExtend);
1705 
1708 
1709  TYElement::setIsSavedOk(false); // Tous les elements sont up to date apres le chargement
1710 
1711  TYApplication::restoreOverrideCursor();
1712  }
1713 }
1714 
1715 void TYMainWindow::open(std::vector<LPTYElement>& tabElem, const bool& bRegenerate /*=false*/)
1716 {
1717  TYElement::setRegenerateID(bRegenerate);
1718 
1719  TYOpenElementDialog* pDlg = new TYOpenElementDialog(this);
1720  pDlg->setMultiSelect(true); // Plusieurs elements peuvent etre selectionnes
1721  pDlg->setDirName(getTYApp()->getCurrentDirName());
1722  pDlg->open();
1723 
1724  if (pDlg->result() == QDialog::Accepted)
1725  {
1726  if (pDlg->getAvailableElements().size() == 1)
1727  {
1728  tabElem.push_back(pDlg->getAvailableElements()[0]);
1729  }
1730  else
1731  {
1732  pDlg->exec();
1733  tabElem = pDlg->getTabElem();
1734  }
1735  }
1736 
1738 }
1739 
1741 {
1742  if (TYElement::getIsSavedOk() == true) // Si un element a ete modifie, il faut sauvegarder
1743  {
1744  auto ret = QMessageBox::warning(this, "Attention", TR("id_file_not_saved"),
1745  QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
1746  QMessageBox::Cancel);
1747  switch (ret)
1748  {
1749  case QMessageBox::Yes:
1750  if (_pSaveAction->isEnabled())
1751  {
1752  _closeAndQuit = save();
1753  }
1754  else
1755  {
1756  _closeAndQuit = saveAs();
1757  }
1758 
1759  break;
1760 
1761  case QMessageBox::No:
1762  _closeAndQuit = true;
1763  break;
1764 
1765  case QMessageBox::Cancel:
1766  _closeAndQuit = false;
1767  break;
1768  }
1769  }
1770 
1771  if (_closeAndQuit)
1772  {
1773  // Fermeture de toutes les fenetres
1774  QList<QMdiSubWindow*> windows = _pWorkspace->subWindowList();
1775 
1776  for (int i = 0; i < int(windows.count()); ++i)
1777  {
1778  windows.at(i)->close();
1779  }
1780 
1781  // On reinitialise le projet et le site courant
1782  getTYApp()->setCurProjet(NULL);
1783  getTYApp()->setCurSiteNode(NULL);
1784  // Par securite, on inhibe le calcul courant connu du calculManager (pourrait expliquer des plantages
1785  // ...)
1786  getTYApp()->getCalculManager()->setCurrent(NULL);
1787 
1788  // On efface le nom de fichier en cours
1789  QString fileName = "";
1790  updateCurrentFileName(fileName);
1791 
1792  _pSaveAction->setEnabled(true); // Plus de fichier ouvert, remise en etat de save
1793 
1794  // plus rien en memoire (theoriquement) donc rien a sauvegarder
1795  TYElement::setIsSavedOk(false);
1796  }
1797 }
1798 
1800 {
1801  _closeAndQuit = true; // A priori
1802 
1803  // Ferme le projet courant et demande si necessaire la sauvegarde du fichier.
1804  close();
1805 
1806  // Ferme l'application
1807  if (_closeAndQuit)
1808  {
1809  // Sauvegarde la geometrie des fenetres dans les preferences
1811  // Sauvegarde des settings
1812  saveSettings(QDir::toNativeSeparators(getTYApp()->getSettingsDir() + "/Settings"));
1813  // Fermeture de toutes les fenetres
1814  closeModelers();
1815  // Quitte l'application
1816  getTYApp()->quit();
1817  }
1818 }
1819 
1821 {
1822  TYElement* pElement = NULL;
1823 
1824  if (_pProjetFrame->getProjet()) // Si on est dans un projet, on le sauve (avec son site)
1825  {
1826  pElement = (TYElement*)_pProjetFrame->getProjet();
1827  }
1828  else if (_pSiteFrame->getSiteNodeRoot()) // On sauve que le site si pas de projet mais un site
1829  {
1830  pElement = (TYElement*)_pSiteFrame->getSiteNodeRoot();
1831  }
1832  else // Sinon on sauve ce qu'on peut, l'element actif
1833  {
1834  QWidget* pW = this->focusWidget();
1835  if (pW && (dynamic_cast<TYModelerFrame*>(pW) != nullptr))
1836  {
1837  pElement = ((TYModelerFrame*)pW)->getElement();
1838 
1839  if (pElement && (dynamic_cast<TYAcousticVolume*>(pElement) != nullptr))
1840  {
1841  return pElement;
1842  }
1843 
1844  // Recherche d'un parent de type "acousticVolume"
1845  TYElement* pParent = pElement->getParent();
1846  while (pParent && (dynamic_cast<TYAcousticVolumeNode*>(pParent) == nullptr))
1847  {
1848  pParent = pParent->getParent();
1849  };
1850 
1851  if (pParent && (dynamic_cast<TYAcousticVolumeNode*>(pParent) != nullptr))
1852  {
1853  return pParent;
1854  }
1855  }
1856  }
1857 
1858  return pElement;
1859 }
1860 
1862 {
1863  bool bRet = false;
1864 
1865  TYElement* pElement = elementToSave();
1866 
1867  if (!pElement)
1868  {
1869  QMessageBox::warning(this, "Tympan", TR("id_nothingtoexport"));
1870  return false;
1871  }
1872 
1873  QString dirName;
1874  QString fileName = getFileName("XML (*.xml)", dirName); // Recuperation du nom du fichier courant
1875 
1876  bRet = save(dirName, fileName, pElement, true);
1877 
1878  if (bRet)
1879  {
1880  QMessageBox::information(this, "Tympan", TR("id_export_ok").arg(fileName));
1881  updateCurrentAppFile(dirName, fileName);
1882 
1883  // Indique que les TYElement sont ok (rien a sauvegarder)
1884  TYElement::setIsSavedOk(false);
1885  }
1886  else
1887  {
1888  QMessageBox::critical(this, "Tympan", TR("id_export_failed").arg(fileName));
1889  }
1890 
1891  return bRet;
1892 }
1893 
1894 bool TYMainWindow::save(QString dirName, QString& fileName, TYElement* pElement,
1895  const bool& saveBackup /*= false*/)
1896 {
1897  // Controle des parametres
1898  if (!pElement || fileName.isEmpty())
1899  {
1900  return false;
1901  }
1902  if (dirName.isEmpty())
1903  {
1904  dirName = getTYApp()->getCurrentDirName();
1905  }
1906 
1907  formatFileName(fileName); // Ajoute l'extension si necessaire
1908 
1909  // Creation du fichier XML
1910  TYXMLManager xmlManager;
1911 
1912  QString version(TY_CURRENT_RELEASE_);
1913  QString tiret(" - ");
1914  QString licencie(TY_CUSTOMER_);
1915  QString licenceNumber(TY_LICENCE_NUMBER_);
1916 
1917  QString messageVersion = version + tiret + licencie + tiret + licenceNumber;
1919 
1920  xmlManager.createDoc(TY_PRODUCT_XMLTAG_, messageVersion); // TY_PRODUCT_VERSION_);
1921  xmlManager.addElement(pElement);
1922 
1923  bool saveSucceeded = xmlManager.save(fileName) == 0;
1924 
1925  if (!saveSucceeded)
1926  {
1927  return false;
1928  }
1929 
1930  if (saveBackup)
1931  {
1932  bool saveBakSucceeded = backupFile(fileName);
1933  if (!saveBakSucceeded)
1934  {
1935  return false;
1936  }
1937  }
1938 
1939  return true;
1940 }
1941 
1943 {
1944  bool bRet = false;
1945 
1946  TYElement* pElement = elementToSave();
1947 
1948  if (!pElement)
1949  {
1950  QMessageBox::warning(this, "Tympan", TR("id_nothingtoexport"));
1951  return false;
1952  }
1953 
1954  QString dirName;
1955  QString fileName = getFileName("XML (*.xml)", dirName, true);
1956 
1957  if (testFile(fileName))
1958  {
1959  bRet = save(dirName, fileName, pElement, true);
1960 
1961  if (bRet)
1962  {
1963  QMessageBox::information(this, "Tympan", TR("id_export_ok").arg(fileName));
1964  updateCurrentAppFile(dirName, fileName);
1965 
1966  // Indique que les TYElement sont ok (rien a sauvegarder)
1967  TYElement::setIsSavedOk(false);
1968  }
1969  else
1970  {
1971  QMessageBox::critical(this, "Tympan", TR("id_export_failed").arg(fileName));
1972  }
1973  }
1974 
1975  return bRet;
1976 }
1977 
1979 {
1980  bool bRet = false;
1981 
1982  TYProjet* pProjet = getTYApp()->getCurProjet();
1983 
1984  if (!pProjet)
1985  {
1986  QMessageBox::warning(this, "Tympan", TR("id_nothingtoexport"));
1987  return false;
1988  }
1989 
1990  QString dirName;
1991  QString fileName = getFileName("XML (*.xml)", dirName, true);
1992 
1993  TYProjet::gSaveValues = false;
1994  if (testFile(fileName))
1995  {
1996  bRet = save(dirName, fileName, pProjet, true);
1997 
1998  if (bRet)
1999  {
2000  QMessageBox::information(this, "Tympan", TR("id_export_ok").arg(fileName));
2001  }
2002  else
2003  {
2004  QMessageBox::critical(this, "Tympan", TR("id_export_failed").arg(fileName));
2005  }
2006  }
2007 
2008  TYProjet::gSaveValues = true;
2009 
2010  return bRet;
2011 }
2012 
2014 {
2015  bool bRet = false;
2016 
2017  if (pElement == NULL)
2018  {
2019  return bRet;
2020  }
2021 
2022  QString dirName;
2023  QString fileName = getFileName("XML (*.xml)", dirName, true);
2024 
2025  if (testFile(fileName))
2026  {
2027  bRet = save(dirName, fileName, pElement);
2028 
2029  if (bRet)
2030  {
2031  QMessageBox::information(this, "Tympan", TR("id_export_ok").arg(fileName));
2032  }
2033  else
2034  {
2035  QMessageBox::critical(this, "Tympan", TR("id_export_failed").arg(fileName));
2036  }
2037  }
2038 
2039  return bRet;
2040 }
2041 
2042 void TYMainWindow::updateCurrentAppFile(const QString& dirName, const QString& fileName)
2043 {
2044  getTYApp()->setCurrentDirName(dirName);
2045  getTYApp()->setCurrentFileName(fileName);
2046 
2047  setWindowTitle(TR("id_caption") + "-" + TY_CURRENT_RELEASE_ + " (" + TY_PRODUCT_PLATFORM_ +
2048  ") : " + fileName);
2049 }
2050 
2051 bool TYMainWindow::backupFile(const QString& fileName)
2052 {
2053  // Creation du nom du fichier
2054  QFileInfo fi(fileName);
2055 
2056  QString bakBasename = fi.absolutePath() + '/' + fi.completeBaseName() + ".bak";
2057  QDateTime now = QDateTime::currentDateTime();
2058  QString nowAsStr = now.toString("yyyy-MM-dd_hh-mm-ss");
2059  QString nomFichier = bakBasename + "_" + nowAsStr;
2060 
2061  // Ouverture du fichier d'origine
2062  QFile fileToSave(fileName);
2063  bool bOpen = fileToSave.open(QIODevice::ReadOnly);
2064 
2065  if (!bOpen)
2066  {
2067  return false;
2068  }
2069 
2070  // Ouverture du fichier backup
2071  QFile backupFile(nomFichier);
2072  bOpen = backupFile.open(QIODevice::WriteOnly);
2073 
2074  if (!bOpen)
2075  {
2076  fileToSave.close();
2077  return false;
2078  }
2079 
2080  // Copie en bloc de l'un dans l'autre
2081  backupFile.write(fileToSave.readAll());
2082 
2083  // Fermeture des fichier
2084  fileToSave.close();
2085  backupFile.close();
2086 
2087  const int nbBackupsToKeep = 3;
2088  bool cleanUpOk = keepOnlyMostRecentBackups(bakBasename, nbBackupsToKeep);
2089  if (!cleanUpOk)
2090  {
2091  return false;
2092  }
2093 
2094  return true;
2095 }
2096 
2098 {
2099  TYPluginDialog* pDlg = new TYPluginDialog(this);
2100  pDlg->exec();
2101 
2102  // Mise a jour du solveur pour le calcul courant si calcul pas bloque
2103  if (_pProjetFrame->getProjet())
2106  {
2108  }
2109 }
2110 
2111 bool TYMainWindow::testFile(const QString& fileName)
2112 {
2113  // Verification de l'etat du fichier
2114  QFileInfo fi(fileName);
2115  // Si le fichier existe , on demande confirmation a l'utilisateur
2116  if (fi.exists())
2117  {
2118  // On ecrase le fichier, puis on sauve
2119  QFile* file = new QFile(fileName);
2120  switch (
2121  QMessageBox::warning(this, "Attention", TR("id_file_exist"), QMessageBox::Yes, QMessageBox::No))
2122  {
2123  case QMessageBox::Yes:
2124  if (!file->remove())
2125  {
2126  QMessageBox::warning(this, "Attention", TR("id_file_cannot_be_clear"));
2127  return false;
2128  }
2129 
2130  break;
2131  case QMessageBox::No:
2132  return false; // On sort sans sauvegarder
2133  break;
2134  }
2135 
2136  delete file;
2137  file = NULL;
2138  }
2139 
2140  return true;
2141 }
2142 
2143 QString TYMainWindow::getFileName(const QString& filter, QString& dirName,
2144  const bool& forceNewName /*=false*/)
2145 {
2146  QString fileName = getTYApp()->getCurrentFileName(); // Recuperation du nom du fichier courant
2147  // NOUVELLE VERSION POUR RECUPERER LE REPERTOIRE
2148  dirName = getTYApp()->getCurrentDirName();
2149 
2150  if (!forceNewName && !fileName.isEmpty())
2151  {
2152  return fileName;
2153  }
2154 
2155  // Recuperation de la terminaison de fichier a creer
2156  short index = filter.indexOf(".");
2157  QString end = filter.mid(index, 4);
2158 
2159  QFileDialog* pDialog = new QFileDialog(parentWidget(), "Choose a file", dirName, filter);
2160  pDialog->setFileMode(QFileDialog::AnyFile);
2161  pDialog->setAcceptMode(QFileDialog::AcceptSave);
2162  pDialog->setWindowModality(Qt::WindowModal); // Set window modality
2163  pDialog->exec();
2164 
2165  QStringList list = pDialog->selectedFiles();
2166  if ((pDialog->result() == QDialog::Accepted) && (!list.isEmpty()))
2167  {
2168  fileName = list.first();
2169 
2170  QDir dir = pDialog->directory();
2171  dirName = dir.absolutePath();
2172 
2173  pDialog = NULL;
2174 
2175  if (!fileName.endsWith(end))
2176  {
2177  fileName += end;
2178  }
2179  }
2180  else
2181  {
2182  fileName = "";
2183  }
2184 
2185  return fileName;
2186 }
2187 
2188 bool TYMainWindow::keepOnlyMostRecentBackups(const QString& bakBasename, const int& nbToKeep) const
2189 {
2190  const QFileInfo fiBakBasename(bakBasename);
2191 
2192  QDir workingDir(fiBakBasename.absolutePath());
2193 
2194  workingDir.setNameFilters(QStringList(fiBakBasename.fileName() + "*"));
2195  workingDir.setFilter(QDir::Files);
2196  workingDir.setSorting(QDir::Name);
2197  const QFileInfoList fiBakList = workingDir.entryInfoList();
2198 
2199  const int nbBakFiles = fiBakList.size();
2200  if (nbBakFiles > nbToKeep)
2201  {
2202  const int nbBakToRemove = nbBakFiles - nbToKeep;
2203  const QFileInfoList fiBakToRemoveList = fiBakList.sliced(0, nbBakToRemove);
2204  for (const QFileInfo& fiBakToRemove : fiBakToRemoveList)
2205  {
2206  const bool removeSucceeded = workingDir.remove(fiBakToRemove.fileName());
2207  if (!removeSucceeded)
2208  {
2209  return false;
2210  }
2211  }
2212  }
2213 
2214  return true;
2215 }
2216 
2218 {
2219  QWidget* pW = this->focusWidget();
2220 
2221  if (pW && (dynamic_cast<TYModelerFrame*>(pW) != nullptr))
2222  {
2223  ((TYModelerFrame*)pW)->print();
2224  }
2225 }
2226 
2228 {
2229  emit onUndo();
2230 }
2231 
2233 {
2234  emit onRedo();
2235 }
2236 
2238 {
2239  about();
2240 }
2241 
2243 {
2244  about();
2245 }
2246 
2248 {
2249  about();
2250 }
2251 
2253 
2255 
2256 void TYMainWindow::showBiblio(bool show) {}
2257 
2259 {
2260  TYPreferenceDialog* pDlg = new TYPreferenceDialog(this);
2261  pDlg->exec();
2262 }
2263 
2265 {
2266  _pOutputDockWnd->setVisible(show);
2267 }
2268 
2270 {
2271  _pHideOrShowOutputAction->setChecked(_pOutputDockWnd->isVisible());
2272 }
2273 
2275 {
2276  QProcess* pImporterLauncher = new QProcess(this);
2277 
2278  // On travail dans le repertoire utilisateur
2279  pImporterLauncher->setWorkingDirectory(TYApplication::tympanUserDir());
2280 
2281  // Le nom de l'executable
2282  // pImporterLauncher->addArgument("Importer");
2283 
2284  // Lancement
2285  pImporterLauncher->start("Importer", QStringList(""));
2286 
2287  if (pImporterLauncher->state() == QProcess::Running)
2288  {
2289  writeOutputMsg(TR("id_msg_importer_ok"));
2290  }
2291  else
2292  {
2293  writeOutputMsg(TR("id_msg_importer_fail"));
2294  }
2295 }
2296 
2297 void TYMainWindow::closeEvent(QCloseEvent* pEvent)
2298 {
2299  // Evite les boucles de fermeture si quit() redéclenche des closeEvent
2300  if (_handlingCloseEvent)
2301  {
2302  pEvent->accept();
2303  return;
2304  }
2305  _handlingCloseEvent = true;
2306 
2307  // Même intention que menu Quitter : on décide nous-même si on quitte ou non
2308  _closeAndQuit = true;
2309 
2310  // Ferme le projet courant (avec demande de sauvegarde si nécessaire)
2311  close();
2312 
2313  if (_closeAndQuit)
2314  {
2315  // Comportement identique à la méthode quitte()
2317  saveSettings(QDir::toNativeSeparators(getTYApp()->getSettingsDir() + "/Settings"));
2318  closeModelers();
2319 
2320  pEvent->accept();
2321  getTYApp()->quit();
2322  }
2323  else
2324  {
2325  pEvent->ignore();
2326  }
2327 
2328  _handlingCloseEvent = false;
2329 }
2330 
2331 void TYMainWindow::updateCurrentFileName(const QString& fileName)
2332 {
2333  // Informe l'application du nom du fichier courant
2335 
2336  // Change le titre de la fenetre pour afficher le nom du fichier
2337  setWindowTitle(TR("id_caption") + "-" + TY_CURRENT_RELEASE_ + " (" + TY_PRODUCT_PLATFORM_ +
2338  ") : " + fileName);
2339 }
2340 
2341 // CLM-NT33 : Raffraichissement du nom de fichier en vue modeleur
2343 {
2344  // Change le titre de la fenetre pour afficher le nom du fichier
2345  setWindowTitle(TR("id_caption") + "-" + TY_CURRENT_RELEASE_ + " (" + TY_PRODUCT_PLATFORM_ +
2347 }
2348 
2349 // CLM-NT33 : Fin
void writeOutputMsg(QString msg)
Affiche un message dans la fenetre de sortie.
TYApplication * getTYApp()
Retourne le pointeur sur l'application.
pour l'application Tympan (fichier header)
Modeler specialisee pour l'edition des batiments (fichier header)
Barre d'outils Batiment (fichier header)
Barre d'outil calcul (fichier header)
Boite de dialogue pour la creation d'un nouvel element metier. L'element cree peut etre sauvegarde en...
Definit un popup menu, necessaire pour maitriser l'ouverture automtique apres un createPopupMenu (fic...
class OGenID TYUUID
Definition: TYDefines.h:59
#define TYDIRPREFERENCEMANAGER
Definition: TYElement.h:51
Classe Modeler specialisee pour l'edition des faces (fichier header)
Barre d'outils Face (fichier header)
Barre d'outil infastructure (fichier header)
Modeler specialisee pour l'edition des machines (fichier header)
Barre d'outils Machine (fichier header)
#define IMG(id)
#define TR(id)
Fenetre principale de l'application Tympan (fichier header)
Classe generique pour une fenetre de modeleur (fichier header)
Barre d'outils generale pour les modelers (fichier header)
Boite de dialogue pour le chargement d'un element metier (fichier header)
Frame pour les messages de retour (fichier header)
Gestion de la table de correspondance indice/element pour le picking (fichier header)
Boite de dialogue pour la selection du plugin de calcul (fichier header)
#define DEFAULT_SOLVER_UUID
Tables pour le dialogue de la gestion des preferences (fichier header)
Frame pour la gestion de projet (fichier header)
Frame pour la gestion de site (fichier header)
Classe Modeler specialisee pour l'edition des sites (fichier header)
outil IHM pour un spectre (fichier header)
Barre d'outils topographie (fichier header)
The box class.
Definition: 3d.h:1346
The 3D coordinate class.
Definition: 3d.h:226
Definition: idgen.h:28
virtual void debug(const char *message,...)
Definition: logging.cpp:151
static OMessageManager * get()
Definition: logging.cpp:108
static OPrototype * safeDownCast(OPrototype *pObject)
Definition: TYElement.cpp:71
bool isA(const char *className) const
Definition: TYElement.cpp:65
Gere les undos.
void redo()
Effectue a nouveau la derniere action annulee.
void undo()
Annule la derniere action.
void emitUndoRedo()
Envoie un signal informant sur l'etat de ce ActionManager.
void undoRedoChanged(bool undoAvailable, bool redoAvailable, const QString &undoCmd, const QString &redoCmd)
Indique l'etat de ce ActionManager.
bool isUpToDate() const
Definition: TYAltimetrie.h:176
void setCurSiteNode(LPTYSiteNode pSiteNode)
Set/Get du site node courant.
static const QString & getCurrentDirName()
LPTYProjet getCurProjet()
Set/Get du projet courant.
static QString tympanAppDir()
Retourne le chemin du dossier de l'application.
TYCalculManager * getCalculManager()
Get du gestionnaire de calculs.
Definition: TYApplication.h:99
static const QString & getCurrentFileName()
Retourne le nom du fichier en cours d'utilisation.
void curSiteNodeChanged(LPTYSiteNode pCurSiteNode)
Signal que le site node courant a change.
void curProjetChanged(LPTYProjet pCurProjet)
Signal que le projet courant a change.
static void setCurrentFileName(const QString &fileName)
Enregistre le nom du fichier de travail courant.
static QString tympanUserDir()
Retourne le chemin du dossier de sauvegarde de l'utilisateur courant. Celui-ci est donne par la varia...
void setCurProjet(LPTYProjet pProjet)
Set/Get du projet courant.
static void setCurrentDirName(const QString &dirName)
Get/Set du repertoire de travail courant.
Classe Modeler specialisee pour l'edition des batiments.
void setBatiment(LPTYBatiment pBatiment)
Set/Get du bâtiment a editer.
virtual void setEditorMode(int mode)
Barre d'outils Batiment.
void activeButtons(bool active)
Active/Desactive chaque boutons.
bool launchCurrent()
Execute le calcul courant.
void setCurrent(LPTYCalcul pCalcul)
Set du Calcul et Projet courant.
void launchAltiComputation(LPTYSiteNode pRootSite)
Execute altimetry computation.
Barre d'outil calcul.
void activeButtons(bool active)
Active/Desactive chaque boutons.
int getState()
Get calculation state.
Definition: TYCalcul.h:416
@ Locked
Definition: TYCalcul.h:62
@ Actif
Definition: TYCalcul.h:63
void setSolverId(const OGenID &iD)
Set solver ID.
Definition: TYCalcul.h:455
void setState(int state)
Set editable attribute.
Definition: TYCalcul.h:406
bool getKeepRays() const
Returns if computation contains rays or not \ returns true if computation contains rays else returns ...
Definition: TYCalcul.cpp:1301
bool addToSelection(TYUUID id)
Adds the item to the selection of this Calculation.
Definition: TYCalcul.cpp:873
Boite de dialogue pour la creation d'un nouvel element metier. L'element cree peut etre sauvegarde en...
void createElement(QString eltType)
Gere la creation d'un nouvel element au sein de l'application.
Definit un popup menu, necessaire pour maitriser l'ouverture automtique apres un createPopupMenu.
TYElement * getParent() const
Definition: TYElement.h:706
static void setLogInstances(bool log)
Definition: TYElement.h:831
static void setIsSavedOk(const bool &toSave)
Definition: TYElement.h:914
const TYUUID & getID() const
Definition: TYElement.cpp:176
static void setRegenerateID(const bool &bRegenerate)
Definition: TYElement.h:922
static bool getIsSavedOk()
Definition: TYElement.h:906
static TYElement * getInstance(TYUUID uuid)
Definition: TYElement.cpp:158
Classe Modeler specialisee pour l'edition des faces.
virtual void setEditorMode(int mode)
Barre d'outils Face.
Definition: TYFaceToolbar.h:41
void activeButtons(bool active)
Active/Desactive chaque boutons.
This class holds a singleton instance which is an entry point for accessing IGN Geoplatform in order ...
std::shared_ptr< TYIGNLevelCurvesParser > _parser
const QString getLandtakeCoord()
const QString getImageWidth()
static TYIGNGeoProvider * getInstance()
void geoProjectCreationRequested()
std::vector< double > coordinatesToDouble(const QString &coord)
void buildLevelCurves(const OCoord3D &SIGCoords, const OBox &selectedZone, double scaleFactor)
void openModalWindow(QWidget *mainWindow)
bool mockGeoPf()
Mocks IGN Geoplatform web services when they are down.
bool saveImageToFile(const QString &filePath)
const QString getScaleFactor()
void courbeNiveauCreated(LPTYCourbeNiveau courbeNiveau)
Barre d'outil infastructure.
void activeButtons(bool active)
Classe Modeler specialisee pour l'edition des machines.
void setMachine(LPTYMachine pMachine)
virtual void setEditorMode(int mode)
Barre d'outils Machine.
void activeButtons(bool active)
Main window of the Tympan application.
Definition: TYMainWindow.h:50
void onDestroyed()
Definition: TYMainWindow.h:472
void updateModelersAfterComputation(LPTYProjet &result)
void updateHideOrShowOutputAction(bool visibilityChanged)
QDockWidget * _pOutputDockWnd
Dockable window for feedback messages.
Definition: TYMainWindow.h:633
TYProjetFrame * _pProjetFrame
Frame for project management.
Definition: TYMainWindow.h:621
virtual ~TYMainWindow()
void editCurCalcul()
TYInfraToolbar * _pToolbarInfra
Infrastructure toolbar.
Definition: TYMainWindow.h:595
TYElement * elementToSave()
void updateCurrentAppFile(const QString &dirName, const QString &fileName)
TYFaceToolbar * _pToolbarFace
Face toolbar.
Definition: TYMainWindow.h:611
QString getFileName(const QString &filter, QString &dirName, const bool &forceNewName=false)
Produces a valid file name (or nothing!)
QButtonGroup * _pBatimentBtnGroup
Button group for building toolbar.
Definition: TYMainWindow.h:614
void createNewBatiment()
QAction * _pOpenAction
Action to open the library manager.
Definition: TYMainWindow.h:521
QDockWidget * _pSiteDockWnd
Dockable window for site management.
Definition: TYMainWindow.h:628
void updateCurrentFileName(const QString &fileName)
void createNewSite()
void saveCurBatimentMode(int mode)
bool keepOnlyMostRecentBackups(const QString &xmlFilename, const int &nbToKeep) const
TYSiteFrame * _pSiteFrame
Frame for site management.
Definition: TYMainWindow.h:626
void saveCurFaceMode(int mode)
TYTopoToolbar * _pToolbarTopo
Topography toolbar.
Definition: TYMainWindow.h:593
void setCurSiteNode(LPTYSiteNode pSiteNode)
QAction * _pCreateNewAction
Action to create a new element.
Definition: TYMainWindow.h:519
void onCourbeNiveauCreated(LPTYCourbeNiveau courbeNiveau)
bool loadSettings(const QString &fileName)
void makeSiteModeler(LPTYSiteNode pSite=NULL)
bool _closeAndQuit
Indicator for canceling the exit command.
Definition: TYMainWindow.h:650
TYCalculToolbar * _pToolbarCalcul
Calculation toolbar.
Definition: TYMainWindow.h:597
void formatFileName(QString &fileName)
Definition: TYMainWindow.h:209
bool backupFile(const QString &fileName)
QAction * _pSaveAsAction
Action to save an element with a specific name.
Definition: TYMainWindow.h:529
void updateUndoRedo(bool undoAvailable, bool redoAvailable, const QString &undoCmd, const QString &redoCmd)
void createNewProjet()
bool makeBatimentModeler(LPTYBatiment pBatiment=NULL)
QAction * _pUndoAction
Action to perform an undo.
Definition: TYMainWindow.h:549
int _curSiteMode
Preserves the current mode of SiteModeler windows.
Definition: TYMainWindow.h:591
QAction * _pPrintAction
Action to print.
Definition: TYMainWindow.h:546
QAction * _pRedoAction
Action to perform a redo.
Definition: TYMainWindow.h:551
void windowsMenuActivated()
QButtonGroup * _pFaceBtnGroup
Button group for face toolbar.
Definition: TYMainWindow.h:607
void showPluginManager()
QAction * _pSaveAction
Action to save an element.
Definition: TYMainWindow.h:526
QAction * _pHideOrShowOutputAction
Shows or hides the output messages window.
Definition: TYMainWindow.h:567
QMdiArea * _pWorkspace
Workspace for MDI management.
Definition: TYMainWindow.h:511
TYProjetFrame * getProjetFrame()
Definition: TYMainWindow.h:73
QAction * _pPasteAction
Action to perform a paste.
Definition: TYMainWindow.h:558
bool makeModeler(TYElement *pElt)
void reloadSlots()
void saveCurMachineMode(int mode)
QAction * _pCloseAction
Action to close the current project or site.
Definition: TYMainWindow.h:523
void createNewGeoProjet()
QButtonGroup * _pMachineBtnGroup
Button group for machine toolbar.
Definition: TYMainWindow.h:600
void closeModelers()
void updateModelers(bool clipping=true, bool axesAndGrid=true, bool displayList=true)
void connectActionManager(TYActionManager *pActionManager)
TYSiteFrame * getSiteFrame()
Definition: TYMainWindow.h:77
TYModelerToolbar * _pToolbarModeler
General toolbar for modelers.
Definition: TYMainWindow.h:586
void showBiblio(bool show)
QAction * _pHideOrShowSpectreMngrAction
Shows or hides the Spectrum Manager.
Definition: TYMainWindow.h:561
int _curFaceMode
Preserves the current mode of FaceModeler windows.
Definition: TYMainWindow.h:609
TYMachineToolbar * _pToolbarMachine
Machine toolbar.
Definition: TYMainWindow.h:604
void createNewMachine()
QMenu * _pWindowsMenu
Spectra manager.
Definition: TYMainWindow.h:644
QAction * _pGoAltiAction
Action to start the altimetry calculation.
Definition: TYMainWindow.h:572
void refreshWindowTitle()
void showPreferenceDialog()
QAction * _pHideOrShowMaillageMngrAction
Shows or hides the Mesh Manager.
Definition: TYMainWindow.h:563
void showZoneSelectPage()
void makeProjetModeler(LPTYProjet pProjet=NULL)
virtual void closeEvent(QCloseEvent *pEvent)
void launchImporter()
void showMaillageManager(bool show)
bool saveSettings(const QString &fileName)
TYModelerFrame * _pCurrentModeler
Currently displayed modeler.
Definition: TYMainWindow.h:516
void connectDefaultActionManager()
QOpenGLWidget * _pDummyQOpenGLWidget
Definition: TYMainWindow.h:654
QAction * _pGoCurCalculAction
Action to start the current calculation.
Definition: TYMainWindow.h:574
void updateModelersElementGraphic(bool force=false)
QToolBar * _pCalculAcousticToolbar
Toolbar for acoustic calculations.
Definition: TYMainWindow.h:583
QAction * _pCutAction
Action to perform a cut.
Definition: TYMainWindow.h:554
bool makeMachineModeler(LPTYMachine pMachine=NULL)
QAction * _pEditCurCalculAction
Action to edit the preferences of the current calculation.
Definition: TYMainWindow.h:570
void setCurProjet(LPTYProjet pProjet)
QAction * _pSaveAsNoResultAction
Action to save an element with a specific name without calculation results.
Definition: TYMainWindow.h:532
void showOutput(bool show)
virtual QMenu * createPopupMenu()
bool testFile(const QString &fileName)
Tests the existence and the possibility of writing the file.
QTextBrowser * _pHelpBrowser
Help browser.
Definition: TYMainWindow.h:647
void saveGeometryToPreferences()
save geometry of windows to preferences
int _curMachineMode
Preserves the current mode of MachineModeler windows.
Definition: TYMainWindow.h:602
std::unique_ptr< QFile > searchSettingsFile(const QString &TympanUserDir, const QString &fileNameBegin, const QString &fileNameEnd, const QString &fileNamePattern)
Returns a regular file name or the most recent file matching the file name pattern in the Tympan user...
void windowsMenuAboutToShow()
QToolBar * _pWindowToolbar
Toolbar for window management.
Definition: TYMainWindow.h:580
TYOutputFrame * _pOutputFrame
Frame for feedback messages.
Definition: TYMainWindow.h:631
void saveCurSiteMode(int mode)
bool saveAsNoResult()
void closeModeler(const TYElement *pElement)
QButtonGroup * _pSiteBtnGroup
Button group for site toolbars.
Definition: TYMainWindow.h:589
QAction * _pCopyAction
Action to perform a copy.
Definition: TYMainWindow.h:556
QToolBar * _pMainToolbar
Main toolbar.
Definition: TYMainWindow.h:577
QAction * _pShowPluginManagerAction
Action to display the plug-in manager.
Definition: TYMainWindow.h:535
TYBatimentToolbar * _pToolbarBatiment
Building toolbar.
Definition: TYMainWindow.h:618
void subWindowActivated()
bool _handlingCloseEvent
Definition: TYMainWindow.h:430
int _curBatimentMode
Preserves the current mode of BatimentModeler windows.
Definition: TYMainWindow.h:616
QDockWidget * _pProjetDockWnd
Dockable window for project management.
Definition: TYMainWindow.h:623
void showSpectreManager(bool show)
QAction * _pHideOrShowBiblioAction
Shows or hides the Library of elements.
Definition: TYMainWindow.h:565
void setDefaultCameraMode()
void updateCurCalcul()
Generic class for a modeler window.
void updateElementGraphic(bool force=false)
LPTYElement getElement()
TYRenderWindowInteractor * getView()
void setEditorModeToCamera()
void setKeepRays(bool keepRays)
void editorModeChanged(int mode)
void viewTypeChanged(int)
void aboutToClose()
TYActionManager * getActionManager()
void frameResized()
virtual void updateView(bool clipping=true, bool axesAndGrid=true)
Barre d'outils generale pour les modelers.
void viewTypeChanged(int view)
void activeCameraButtons(int view)
void addToButtonGroup(QButtonGroup *pBtnGroup)
void activeButtons(bool active)
void activeModif(bool active)
Boite de dialogue pour le chargement d'un element metier. L'element peut etre ouvert dans un modeleur...
void openElement(LPTYElement pElt)
void setDirName(const QString &value)
Set du nom du repertoire de travail.
void setMultiSelect(const bool &b)
QString getDirName()
Get du nom du repertoire de travail.
std::vector< LPTYElement > getTabElem()
LPTYElementArray getAvailableElements()
Realise le rendu VTK et le rendu OpenGL.
void invalidateScene(void)
Frame pour les messages de retour.
Definition: TYOutputFrame.h:40
classe graphique pour la gestion de la table de correspondanceindice/element pour le picking
Boite de dialogue pour la selection du plugin de calcul.
OGenID current_solver
Boite de dialogue pour la gestion des preferences.
Frame pour la gestion de projet.
Definition: TYProjetFrame.h:41
LPTYProjet getProjet()
Definition: TYProjetFrame.h:57
void changeSite(LPTYSiteNode pSite)
void setProjet(LPTYProjet pProjet)
void changeCurrentCalcul(LPTYCalcul pCalcul)
classe de definition d'un projet.
Definition: TYProjet.h:45
void setStatusSolver(const bool &bStatus)
Definition: TYProjet.h:574
bool getStatusSolver()
Get/Set du statut de disponibilite du solveur du calcul courant.
Definition: TYProjet.h:566
LPTYSiteNode getSite()
Get du site.
Definition: TYProjet.h:169
LPTYCalcul getCurrentCalcul()
Set/Get du pointeur du Calcul courant.
Definition: TYProjet.h:426
static bool gSaveValues
Definition: TYProjet.h:624
Le role de cette classe est limite a emettre des signaux pouvant etre utilise pour interagir sur le r...
TYOpenGLRenderer * getRenderer()
Frame pour la gestion de site.
Definition: TYSiteFrame.h:40
void updateList()
TYSiteNode * getSiteNodeRoot()
Definition: TYSiteFrame.h:56
void setSiteNodeRoot(LPTYSiteNode pSiteNode)
Definition: TYSiteFrame.cpp:91
void setCurrentCalcul(LPTYCalcul pCalcul)
Definition: TYSiteFrame.h:148
Classe Modeler specialisee pour l'edition des sites.
virtual void setEditorMode(int mode)
void setProjet(LPTYProjet pProjet)
virtual void setMaillageRenderModeSlot()
void showAltimetrie(bool show)
void enableAltimetrieButton(bool enable)
virtual void updateView(bool clipping=true, bool axesAndGrid=true)
LPTYAltimetrie getAltimetry() const
LPTYTopographie getTopographie()
Definition: TYSiteNode.h:149
void setEmprise(TYTabPoint points)
Definition: TYSiteNode.h:362
void setEchelle(float e)
Definition: TYSiteNode.h:288
void setTopoFileName(const QString &name)
Definition: TYSiteNode.h:248
void setUseEmpriseAsCrbNiv(bool b)
Definition: TYSiteNode.h:130
void loadTopoFile(const QString &fileName)
Definition: TYSiteNode.cpp:580
void setUseTopoFile(bool flag)
Definition: TYSiteNode.h:205
Barre d'outils topographie.
Definition: TYTopoToolbar.h:35
void activeButtons(bool active)
bool addCrbNiv(LPTYCourbeNiveauGeoNode pCrbNivGeoNode)
int save(QString fileName)
void createDoc(QString docName, QString version)
int addElement(TYElement *pElt)
static void setSavedFileName(QString savedFileName)
Definition: TYXMLManager.h:131
#define TY_PRODUCT_PLATFORM_
Definition: defines.h:67