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 
199  bool save(QString dirName, QString& fileName, TYElement* pElement);
200 
204  void formatFileName(QString& fileName)
205  {
206  if (!fileName.endsWith(".xml"))
207  {
208  fileName += ".xml";
209  }
210  }
211 
215  void updateCurrentAppFile(const QString& dirName, const QString& fileName);
216 
220  bool save();
221 
225  bool saveAs();
226 
230  bool saveAsNoResult();
231 
235  bool saveAs(LPTYElement pElement);
236 
241 
245  bool backupFile(const QString& fileName);
246 
250  void showPluginManager();
251 
255  void close();
256 
260  void quitte();
261 
265  void print();
266 
270  void undo();
274  void redo();
275 
279  void cut();
283  void copy();
287  void paste();
288 
292  void showHelp();
293 
297  void about();
298 
302  void showSpectreManager(bool show);
306  void showMaillageManager(bool show);
310  void showBiblio(bool show);
314  void showPreferenceDialog();
318  void showOutput(bool show);
319 
323  void updateHideOrShowOutputAction(bool visibilityChanged);
324 
329  void launchImporter();
330 
334  bool makeModeler(TYElement* pElt);
335 
339  bool makeBatimentModeler(LPTYBatiment pBatiment = NULL);
343  bool makeMachineModeler(LPTYMachine pMachine = NULL);
347  void makeSiteModeler(LPTYSiteNode pSite = NULL);
351  void makeProjetModeler(LPTYProjet pProjet = NULL);
352 
360  void connectActionManager(TYActionManager* pActionManager);
365 
373  void updateModelers(bool clipping = true, bool axesAndGrid = true, bool displayList = true);
380  void updateModelersElementGraphic(bool force = false);
381 
388 
393  void closeModeler(const TYElement* pElement);
394 
398  void closeModelers();
399 
403  void editCurCalcul();
407  void goCurCalcul();
408 
409  void reloadSlots();
410 
415  void setDefaultCameraMode();
416 
417 private:
421  bool _handlingCloseEvent = false;
422 
423 private slots:
427  void windowsMenuAboutToShow();
431  void windowsMenuActivated();
435  void subWindowActivated();
436 
440  void saveCurSiteMode(int mode);
444  void saveCurMachineMode(int mode);
448  void saveCurBatimentMode(int mode);
452  void saveCurFaceMode(int mode);
453 
457  void updateUndoRedo(bool undoAvailable, bool redoAvailable, const QString& undoCmd,
458  const QString& redoCmd);
459 
460  /*
461  * When the modeler is deleted, assign nullptr
462  */
463  void onDestroyed()
464  {
465  _pCurrentModeler = nullptr;
466  };
467 
468  /*
469  * Add the level curve to main site topography, when it is created from geo provider
470  */
471  void onCourbeNiveauCreated(LPTYCourbeNiveau courbeNiveau);
472 
473 signals:
477  void onUndo();
481  void onRedo();
482 
483 protected:
484  virtual void closeEvent(QCloseEvent* pEvent);
485 
487  bool testFile(const QString& fileName);
488 
490  QString getFileName(const QString& filter, QString& dirName, const bool& forceNewName = false);
491 
492 protected:
494  QMdiArea* _pWorkspace;
495 
496  // CLM-NT35 End
497 
500 
504  QAction* _pOpenAction;
506  QAction* _pCloseAction;
507 
509  QAction* _pSaveAction;
510 
512  QAction* _pSaveAsAction;
513 
516 
519 
521  QAction* _pSaveAllAction;
522 
527 
529  QAction* _pPrintAction;
530 
532  QAction* _pUndoAction;
534  QAction* _pRedoAction;
535 
537  QAction* _pCutAction;
539  QAction* _pCopyAction;
541  QAction* _pPasteAction;
542 
551 
556 
558  QToolBar* _pMainToolbar;
559 
561  QToolBar* _pWindowToolbar;
562 
565 
568 
570  QButtonGroup* _pSiteBtnGroup;
579 
581  QButtonGroup* _pMachineBtnGroup;
586 
588  QButtonGroup* _pFaceBtnGroup;
593 
595  QButtonGroup* _pBatimentBtnGroup;
600 
604  QDockWidget* _pProjetDockWnd;
605 
609  QDockWidget* _pSiteDockWnd;
610 
614  QDockWidget* _pOutputDockWnd;
615 
617  // TYSpectreManager * _pSpectreManager;
618 
620  // TYMaillageManager * _pMaillageManager;
622  // TYMaillageModelerFrame * _pMaillageModeler;//az--
623 
626 
628  QTextBrowser* _pHelpBrowser;
629 
632 
635  QOpenGLWidget* _pDummyQOpenGLWidget;
636 };
637 
638 #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:463
void updateModelersAfterComputation(LPTYProjet &result)
void updateHideOrShowOutputAction(bool visibilityChanged)
QDockWidget * _pOutputDockWnd
Dockable window for feedback messages.
Definition: TYMainWindow.h:614
TYProjetFrame * _pProjetFrame
Frame for project management.
Definition: TYMainWindow.h:602
virtual ~TYMainWindow()
void editCurCalcul()
TYInfraToolbar * _pToolbarInfra
Infrastructure toolbar.
Definition: TYMainWindow.h:576
TYOutputFrame * getOutputFrame()
Definition: TYMainWindow.h:81
TYElement * elementToSave()
void updateCurrentAppFile(const QString &dirName, const QString &fileName)
TYFaceToolbar * _pToolbarFace
Face toolbar.
Definition: TYMainWindow.h:592
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:595
void createNewBatiment()
QAction * _pOpenAction
Action to open the library manager.
Definition: TYMainWindow.h:504
QDockWidget * _pSiteDockWnd
Dockable window for site management.
Definition: TYMainWindow.h:609
void updateCurrentFileName(const QString &fileName)
void createNewSite()
void saveCurBatimentMode(int mode)
TYSiteFrame * _pSiteFrame
Frame for site management.
Definition: TYMainWindow.h:607
void saveCurFaceMode(int mode)
TYTopoToolbar * _pToolbarTopo
Topography toolbar.
Definition: TYMainWindow.h:574
void setCurSiteNode(LPTYSiteNode pSiteNode)
QAction * _pCreateNewAction
Action to create a new element.
Definition: TYMainWindow.h:502
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:631
TYCalculToolbar * _pToolbarCalcul
Calculation toolbar.
Definition: TYMainWindow.h:578
void formatFileName(QString &fileName)
Definition: TYMainWindow.h:204
bool backupFile(const QString &fileName)
QAction * _pSaveAsAction
Action to save an element with a specific name.
Definition: TYMainWindow.h:512
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:532
int _curSiteMode
Preserves the current mode of SiteModeler windows.
Definition: TYMainWindow.h:572
QAction * _pPrintAction
Action to print.
Definition: TYMainWindow.h:529
QAction * _pRedoAction
Action to perform a redo.
Definition: TYMainWindow.h:534
void windowsMenuActivated()
QButtonGroup * _pFaceBtnGroup
Button group for face toolbar.
Definition: TYMainWindow.h:588
QAction * _pExportXMLAction
Action to export the element from the active modeler to XML.
Definition: TYMainWindow.h:526
void showPluginManager()
QAction * _pSaveAction
Action to save an element.
Definition: TYMainWindow.h:509
QAction * _pHideOrShowOutputAction
Shows or hides the output messages window.
Definition: TYMainWindow.h:550
QMdiArea * _pWorkspace
Workspace for MDI management.
Definition: TYMainWindow.h:494
TYProjetFrame * getProjetFrame()
Definition: TYMainWindow.h:73
QAction * _pPasteAction
Action to perform a paste.
Definition: TYMainWindow.h:541
bool makeModeler(TYElement *pElt)
void reloadSlots()
void saveCurMachineMode(int mode)
QAction * _pCloseAction
Action to close the current project or site.
Definition: TYMainWindow.h:506
void createNewGeoProjet()
QButtonGroup * _pMachineBtnGroup
Button group for machine toolbar.
Definition: TYMainWindow.h:581
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:567
void showBiblio(bool show)
QAction * _pHideOrShowSpectreMngrAction
Shows or hides the Spectrum Manager.
Definition: TYMainWindow.h:544
int _curFaceMode
Preserves the current mode of FaceModeler windows.
Definition: TYMainWindow.h:590
TYMachineToolbar * _pToolbarMachine
Machine toolbar.
Definition: TYMainWindow.h:585
void createNewMachine()
QMenu * _pWindowsMenu
Spectra manager.
Definition: TYMainWindow.h:625
void refreshWindowTitle()
void showPreferenceDialog()
QAction * _pHideOrShowMaillageMngrAction
Shows or hides the Mesh Manager.
Definition: TYMainWindow.h:546
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:499
void connectDefaultActionManager()
QOpenGLWidget * _pDummyQOpenGLWidget
Definition: TYMainWindow.h:635
QAction * _pGoCurCalculAction
Action to start the current calculation.
Definition: TYMainWindow.h:555
TYFaceToolbar * getFaceToolbar()
Definition: TYMainWindow.h:86
void updateModelersElementGraphic(bool force=false)
QToolBar * _pCalculAcousticToolbar
Toolbar for acoustic calculations.
Definition: TYMainWindow.h:564
QAction * _pImportXMLAction
Action to import an element from an XML file.
Definition: TYMainWindow.h:524
QAction * _pCutAction
Action to perform a cut.
Definition: TYMainWindow.h:537
bool makeMachineModeler(LPTYMachine pMachine=NULL)
QAction * _pEditCurCalculAction
Action to edit the preferences of the current calculation.
Definition: TYMainWindow.h:553
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:515
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:628
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:583
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:561
void initSaveStatus()
Definition: TYMainWindow.h:102
TYOutputFrame * _pOutputFrame
Frame for feedback messages.
Definition: TYMainWindow.h:612
void saveCurSiteMode(int mode)
bool saveAsNoResult()
void closeModeler(const TYElement *pElement)
QButtonGroup * _pSiteBtnGroup
Button group for site toolbars.
Definition: TYMainWindow.h:570
QAction * _pCopyAction
Action to perform a copy.
Definition: TYMainWindow.h:539
QToolBar * _pMainToolbar
Main toolbar.
Definition: TYMainWindow.h:558
QAction * _pShowPluginManagerAction
Action to display the plug-in manager.
Definition: TYMainWindow.h:518
TYBatimentToolbar * _pToolbarBatiment
Building toolbar.
Definition: TYMainWindow.h:599
void subWindowActivated()
bool _handlingCloseEvent
Definition: TYMainWindow.h:421
int _curBatimentMode
Preserves the current mode of BatimentModeler windows.
Definition: TYMainWindow.h:597
QDockWidget * _pProjetDockWnd
Dockable window for project management.
Definition: TYMainWindow.h:604
QAction * _pSaveAllAction
Action to save all elements.
Definition: TYMainWindow.h:521
TYModelerFrame * getCurrentModeler()
Definition: TYMainWindow.h:68
void showSpectreManager(bool show)
QAction * _pHideOrShowBiblioAction
Shows or hides the Library of elements.
Definition: TYMainWindow.h:548
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