Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYMainWindow.h
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 
27 #ifndef __TY_MAIN_WINDOW__
28 #define __TY_MAIN_WINDOW__
29 
30 #include <qmainwindow.h>
31 #include <memory>
34 
35 class QAction;
36 class QToolBar;
37 class QMenu;
38 class QDockWidget;
39 class QButtonGroup;
40 class QTextBrowser;
41 class QCloseEvent;
42 class QMdiArea;
43 class QOpenGLWidget;
44 
49 class TYMainWindow : public QMainWindow
50 {
51  Q_OBJECT
52 
53 public:
57  TYMainWindow();
61  virtual ~TYMainWindow();
62 
63  QMdiArea* getWorkspace()
64  {
65  return _pWorkspace;
66  }
67 
69  {
70  return _pCurrentModeler;
71  }
72 
74  {
75  return _pProjetFrame;
76  }
78  {
79  return _pSiteFrame;
80  }
82  {
83  return _pOutputFrame;
84  }
85 
87  {
88  return _pToolbarFace;
89  }
91  {
92  return _pToolbarModeler;
93  }
94 
95  void updateCurrentFileName(const QString& fileName);
96 
99  {
100  return _closeAndQuit;
101  }
103  {
104  _closeAndQuit = true;
105  }
106 
107  virtual QMenu* createPopupMenu();
108 
113 
114 public slots:
118  void refreshWindowTitle();
122  bool loadSettings(const QString& fileName);
123 
134  std::unique_ptr<QFile> searchSettingsFile(const QString& TympanUserDir, const QString& fileNameBegin,
135  const QString& fileNameEnd, const QString& fileNamePattern);
139  bool saveSettings(const QString& fileName);
140 
144  void setCurProjet(LPTYProjet pProjet);
148  void setCurSiteNode(LPTYSiteNode pSiteNode);
152  void updateCurCalcul();
153 
157  void createNew();
161  void createNewProjet();
162 
166  void showZoneSelectPage();
167 
171  void createNewGeoProjet();
172 
176  void createNewSite();
180  void createNewBatiment();
184  void createNewMachine();
185 
189  void open();
190 
194  void open(std::vector<LPTYElement>& tabElem, const bool& bRegenerate = false);
195 
204  bool save(QString dirName, QString& fileName, TYElement* pElement, const bool& saveBackup = false);
205 
209  void formatFileName(QString& fileName)
210  {
211  if (!fileName.endsWith(".xml"))
212  {
213  fileName += ".xml";
214  }
215  }
216 
220  void updateCurrentAppFile(const QString& dirName, const QString& fileName);
221 
225  bool save();
226 
230  bool saveAs();
231 
235  bool saveAsNoResult();
236 
240  bool saveAs(LPTYElement pElement);
241 
246 
250  bool backupFile(const QString& fileName);
251 
255  void showPluginManager();
256 
260  void close();
261 
265  void quitte();
266 
270  void print();
271 
275  void undo();
279  void redo();
280 
284  void cut();
288  void copy();
292  void paste();
293 
297  void showHelp();
298 
302  void about();
303 
307  void showSpectreManager(bool show);
311  void showMaillageManager(bool show);
315  void showBiblio(bool show);
319  void showPreferenceDialog();
323  void showOutput(bool show);
324 
328  void updateHideOrShowOutputAction(bool visibilityChanged);
329 
334  void launchImporter();
335 
339  bool makeModeler(TYElement* pElt);
340 
344  bool makeBatimentModeler(LPTYBatiment pBatiment = NULL);
348  bool makeMachineModeler(LPTYMachine pMachine = NULL);
352  void makeSiteModeler(LPTYSiteNode pSite = NULL);
356  void makeProjetModeler(LPTYProjet pProjet = NULL);
357 
365  void connectActionManager(TYActionManager* pActionManager);
370 
378  void updateModelers(bool clipping = true, bool axesAndGrid = true, bool displayList = true);
385  void updateModelersElementGraphic(bool force = false);
386 
393 
398  void closeModeler(const TYElement* pElement);
399 
403  void closeModelers();
404 
408  void editCurCalcul();
412  void goAltiCalcul();
416  void goCurCalcul();
417 
418  void reloadSlots();
419 
424  void setDefaultCameraMode();
425 
426 private:
430  bool _handlingCloseEvent = false;
431 
432 private slots:
436  void windowsMenuAboutToShow();
440  void windowsMenuActivated();
444  void subWindowActivated();
445 
449  void saveCurSiteMode(int mode);
453  void saveCurMachineMode(int mode);
457  void saveCurBatimentMode(int mode);
461  void saveCurFaceMode(int mode);
462 
466  void updateUndoRedo(bool undoAvailable, bool redoAvailable, const QString& undoCmd,
467  const QString& redoCmd);
468 
469  /*
470  * When the modeler is deleted, assign nullptr
471  */
472  void onDestroyed()
473  {
474  _pCurrentModeler = nullptr;
475  };
476 
477  /*
478  * Add the level curve to main site topography, when it is created from geo provider
479  */
480  void onCourbeNiveauCreated(LPTYCourbeNiveau courbeNiveau);
481 
482 signals:
486  void onUndo();
490  void onRedo();
491 
492 protected:
493  virtual void closeEvent(QCloseEvent* pEvent);
494 
496  bool testFile(const QString& fileName);
497 
499  QString getFileName(const QString& filter, QString& dirName, const bool& forceNewName = false);
500 
501  /*
502  * @brief Remove old backup files on disk
503  * @param bakBasename Basename of the backup file (ex : "model.bak")
504  * @param nbToKeep Number of most recent backup files to keep on disk
505  * @return true if backup files have been correcly cleaned
506  */
507  bool keepOnlyMostRecentBackups(const QString& xmlFilename, const int& nbToKeep) const;
508 
509 protected:
511  QMdiArea* _pWorkspace;
512 
513  // CLM-NT35 End
514 
517 
521  QAction* _pOpenAction;
523  QAction* _pCloseAction;
524 
526  QAction* _pSaveAction;
527 
529  QAction* _pSaveAsAction;
530 
533 
536 
538  QAction* _pSaveAllAction;
539 
544 
546  QAction* _pPrintAction;
547 
549  QAction* _pUndoAction;
551  QAction* _pRedoAction;
552 
554  QAction* _pCutAction;
556  QAction* _pCopyAction;
558  QAction* _pPasteAction;
559 
568 
572  QAction* _pGoAltiAction;
575 
577  QToolBar* _pMainToolbar;
578 
580  QToolBar* _pWindowToolbar;
581 
584 
587 
589  QButtonGroup* _pSiteBtnGroup;
598 
600  QButtonGroup* _pMachineBtnGroup;
605 
607  QButtonGroup* _pFaceBtnGroup;
612 
614  QButtonGroup* _pBatimentBtnGroup;
619 
623  QDockWidget* _pProjetDockWnd;
624 
628  QDockWidget* _pSiteDockWnd;
629 
633  QDockWidget* _pOutputDockWnd;
634 
636  // TYSpectreManager * _pSpectreManager;
637 
639  // TYMaillageManager * _pMaillageManager;
641  // TYMaillageModelerFrame * _pMaillageModeler;//az--
642 
645 
647  QTextBrowser* _pHelpBrowser;
648 
651 
654  QOpenGLWidget* _pDummyQOpenGLWidget;
655 };
656 
657 #endif //__TY_MAIN_WINDOW__
Gere les undos.
Barre d'outils Batiment.
Barre d'outil calcul.
Barre d'outils Face.
Definition: TYFaceToolbar.h:41
Barre d'outil infastructure.
Barre d'outils Machine.
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
TYOutputFrame * getOutputFrame()
Definition: TYMainWindow.h:81
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)
bool getSaveStatus()
Returns the save request status.
Definition: TYMainWindow.h:98
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
QAction * _pExportXMLAction
Action to export the element from the active modeler to XML.
Definition: TYMainWindow.h:543
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
TYFaceToolbar * getFaceToolbar()
Definition: TYMainWindow.h:86
void updateModelersElementGraphic(bool force=false)
QToolBar * _pCalculAcousticToolbar
Toolbar for acoustic calculations.
Definition: TYMainWindow.h:583
QAction * _pImportXMLAction
Action to import an element from an XML file.
Definition: TYMainWindow.h:541
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)
TYModelerToolbar * getModelerToolbar()
Definition: TYMainWindow.h:90
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
QMdiArea * getWorkspace()
Definition: TYMainWindow.h:63
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
void initSaveStatus()
Definition: TYMainWindow.h:102
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
QAction * _pSaveAllAction
Action to save all elements.
Definition: TYMainWindow.h:538
TYModelerFrame * getCurrentModeler()
Definition: TYMainWindow.h:68
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.
Barre d'outils generale pour les modelers.
Frame pour les messages de retour.
Definition: TYOutputFrame.h:40
Frame pour la gestion de projet.
Definition: TYProjetFrame.h:41
Frame pour la gestion de site.
Definition: TYSiteFrame.h:40
Barre d'outils topographie.
Definition: TYTopoToolbar.h:35