Antares Simulator
Power System Simulator
main.h
1 /*
2  * Copyright 2007-2025, RTE (https://www.rte-france.com)
3  * See AUTHORS.txt
4  * SPDX-License-Identifier: MPL-2.0
5  * This file is part of Antares-Simulator,
6  * Adequacy and Performance assessment for interconnected energy networks.
7  *
8  * Antares_Simulator is free software: you can redistribute it and/or modify
9  * it under the terms of the Mozilla Public Licence 2.0 as published by
10  * the Mozilla Foundation, either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * Antares_Simulator is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * Mozilla Public Licence 2.0 for more details.
17  *
18  * You should have received a copy of the Mozilla Public Licence 2.0
19  * along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
20  */
21 #ifndef __ANTARES_APPLICATION_MAIN_MAIN_H__
22 #define __ANTARES_APPLICATION_MAIN_MAIN_H__
23 
24 #include <list>
25 #include <ui/common/component/frame/local-frame.h>
26 #include <ui/common/wx-wrapper.h>
27 #include <wx/aui/aui.h>
28 
29 #include <yuni/yuni.h>
30 
31 #include <antares/study/output.h>
32 #include <antares/study/study.h>
33 #include "antares/config/config.h"
34 
35 #include "../../toolbox/components/datagrid/selectionoperation.h"
36 #include "../../toolbox/components/map/settings.h"
37 #include "../../toolbox/components/notebook/notebook.h"
38 #include "fwd.h"
39 
40 namespace Antares::Forms
41 {
42 // Internal data of the main form, to reduce dependencies and (re)compile time
43 // Forward declaration
44 class MainFormData;
45 
49 class ApplWnd final: public Component::Frame::WxLocalFrame, public Yuni::IEventObserver<ApplWnd>
50 {
51 public:
55  static ApplWnd* Instance();
56 
57 public:
59 
60  ApplWnd();
63  virtual ~ApplWnd();
65 
67 
68 
76  wxString openStudyFolder(bool autoLoad = true);
78 
82  void startAntares();
83 
87  wxMenuItem* menuRecentFiles() const;
88 
95  void requestUpdateGUIAfterStudyIO(const bool studyOpened);
96 
101 
102  void hideAllComponentsRelatedToTheStudy();
103 
107  Map::Component* map() const;
108 
124 
129 
136  void gridOperatorSelectedCellsUpdateResult(wxGrid* grid);
137 
141  void disableGridOperatorIfGrid(wxGrid* grid);
143 
145 
146  void title();
147  void title(const wxString& s);
149 
155 
156  void loadUserNotes();
157  void saveUserNotes();
158 
159  void loadSets();
160  void saveSets();
161 
163  void saveStudy();
165  void saveStudyAs(const Yuni::String& path, bool copyoutput, bool copyuserdata, bool copylogs);
167  void exportMap(const Yuni::String& path,
168  bool transparentBackground,
169  const wxColour& backgroundColor,
170  const std::list<uint16_t>& layers,
171  int nbSplitParts,
172  Antares::Map::mapImageFormat format);
173 
177  void selectSystem();
178 
183 
187  void showStudyLogs();
188  void refreshStudyLogs();
189 
190  void evtOnViewOutput(wxCommandEvent& evt);
191  void evtOnOpenOutputInExplorer(wxCommandEvent& evt);
192 
194 
195  void beginUpdateLogs() const;
198  void endUpdateLogs() const;
200  void connectLogCallback();
202 
209  void selectAllDefaultPages();
210 
211  void refreshMenuInput();
215  void refreshMenuOutput();
216 
220  void refreshMenuOptions(Data::Study::Ptr study);
221 
225  void forceFocus();
227  void delayForceFocus();
228 
232  void resetDragAndDrop();
233 
237  void forceRefresh();
238 
242  wxAuiManager& AUIManager()
243  {
244  return pAUIManager;
245  }
246 
247  const wxAuiManager& AUIManager() const
248  {
249  return pAUIManager;
250  }
251 
256 
263  void launchConstraintsBuilder(const Yuni::String& filename);
264 
266 
267 
270  bool isScenarioBuilderOpened() const;
272 
276  void backgroundTimerStop() const;
277 
279 
281 
285 
289  void backToInputData();
290 
292 
293 
296  void copyToClipboard();
297 
303  void pasteFromClipboard(bool showDialog = false);
304 
311  void pasteFromClipboard(const Yuni::String& text, bool showDialog);
313 
315 
316 
322  void showWIP();
329  void hideWIP();
331  bool isInWIPMode() const;
333 
335 
336  MainFormData* data();
339  const MainFormData* data() const;
341  void viewLatestOutput();
342 
343 public:
345  Yuni::Event<void()> onApplicationQuit;
346 
347 private:
349 
350  void internalInitialize();
352 
353  void installUserLicense(bool online = false);
354 
356  void prepareStudyIconFile();
357 
359  wxMenuBar* createMenu();
361  wxMenu* createPopupMenuOperatorsOnGrid();
362 
364  wxMenu* createMenuFiles();
366  wxMenu* createMenuEdit();
368  wxMenu* createMenuView();
370  wxMenu* createMenuInput();
372  wxMenu* createMenuOutput();
374  wxMenu* createMenuSimulation();
376  wxMenu* createMenuOptions();
378  wxMenu* createMenuTools();
380  wxMenu* createMenuWindow();
382  wxMenu* createMenuHelp();
383 
385  void evtOnExecuteQueueEvent(wxCommandEvent&);
386 
388  void createNBSimulation();
390  void createNBNotes();
392  void createNBLoad();
394  void createNBSolar();
396  void createNBHydro();
398  void createNBWind();
400  void createNBThermal();
402  void createNBRenewable();
404  void createNBDSM();
406  void createNBMisc();
408  void createNBInterconnections();
410  void createNBBindingConstraints();
412  void createNBNodalOptimization();
414  void createNBScenarioBuilder();
416  void createNBOutputViewer();
418  void createNBSets();
420 
422 
423  void createLogs();
426  void destroyLogsViewer();
428  void destroyLogs();
430 
432 
433  void evtOnContextMenuStatusBar(wxContextMenuEvent& evt);
435  void evtOnContextMenuChangeOperator(wxCommandEvent& evt);
436  void evtOnContextMenuMap(int x, int y);
438 
440 
441  void evtOnWizard(wxCommandEvent& evt);
444  void evtOnQuit(wxCommandEvent& evt);
446  void evtOnNewStudy(wxCommandEvent& evt);
448  void evtOnOpenStudy(wxCommandEvent& evt);
450  void evtOnOpenRecentsToggleShowPaths(wxCommandEvent& evt);
452  void evtOnOpenRecentsClearHistory(wxCommandEvent& evt);
454  void evtOnDropDownRecents(wxAuiToolBarEvent& evt);
456  void evtOnCloseStudy(wxCommandEvent& evt);
458  void evtOnQuickOpenStudy(wxCommandEvent& evt);
460  void evtOnSave(wxCommandEvent& evt);
462  void evtOnSaveAs(wxCommandEvent& evt);
464  void evtOnExportMap(wxCommandEvent& evt);
466  void evtOnFullscreen(wxCommandEvent& evt);
468  void evtOnInspector(wxCommandEvent& evt);
470  void evtOnOpenStudyFolderInExplorer(wxCommandEvent& evt);
472 
474 
475  void evtOnViewSystem(wxCommandEvent& evt);
476  void evtOnViewAllSystem(wxCommandEvent& evt);
477  void evtOnViewSimulation(wxCommandEvent& evt);
478  void evtOnViewNotes(wxCommandEvent& evt);
479  void evtOnViewLoad(wxCommandEvent& evt);
480  void evtOnViewSolar(wxCommandEvent& evt);
481  void evtOnViewWind(wxCommandEvent& evt);
482  void evtOnViewRenewable(wxCommandEvent& evt);
483  void evtOnViewHydro(wxCommandEvent& evt);
484  void evtOnViewThermal(wxCommandEvent& evt);
485  void evtOnViewReservesDSM(wxCommandEvent& evt);
486  void evtOnViewMiscGen(wxCommandEvent& evt);
487  void evtOnViewInterconnections(wxCommandEvent& evt);
488  void evtOnViewBindingConstraints(wxCommandEvent& evt);
489  void evtOnViewNodalOptimization(wxCommandEvent& evt);
491 
493 
494  void evtOnSetStudyInfos(wxCommandEvent& evt);
496  void evtOnStudySessions(wxCommandEvent& evt);
498  void evtOnEditMapSelectAll(wxCommandEvent& evt);
500  void evtOnEditMapUnselectAll(wxCommandEvent& evt);
502  void evtOnEditMapReverseSelection(wxCommandEvent& evt);
504  void evtOnEditCopy(wxCommandEvent& evt);
506  void evtOnEditPaste(wxCommandEvent& evt);
508  void evtOnEditPasteSpecial(wxCommandEvent& evt);
510  void onMapDblClick(Map::Component& sender);
512 
514 
515  void evtOnRunSimulation(wxCommandEvent& evt);
517  void evtOnRunTSGenerators(wxCommandEvent& evt);
518  void evtOnRunTSGeneratorsDelayed();
519 
520  void evtOnRunConstraintsBuilder(wxCommandEvent& evt);
521  void evtOnRunConstraintsBuilderDelayed();
523 
525 
526  void evtOnMemoryUsedByTheStudy(wxCommandEvent& evt);
529 
531 
532  void evtOnOptionsTempFolder(wxCommandEvent& evt);
535  void evtOnOptionsSelectOutput(wxCommandEvent& evt);
537  void evtOnOptionsSelectAreasTrimming(wxCommandEvent& evt);
539  void evtOnOptionsSelectLinksTrimming(wxCommandEvent& evt);
541  void evtOnOptionsDistricts(wxCommandEvent& evt);
543  void evtOnOptionsMCPlaylist(wxCommandEvent& evt);
545  void evtOnOptionsMCScenarioBuilder(wxCommandEvent& evt);
547  void evtOnOptionsOptimizationPrefs(wxCommandEvent& evt);
549  void evtOnOptionsAdvanced(wxCommandEvent& evt);
551  void evtOnOptionsAdequacyPatchOptions(wxCommandEvent& evt);
553  void evtOnOptionsAdequacyPatchAreas(wxCommandEvent& evt);
555 
557 
558  void evtOnStudyLogs(wxCommandEvent& evt);
561  void evtOnRaiseWindow(wxCommandEvent& evt);
563 
565 
566  // void evtOnHelpVisitRTEWebsite(wxCommandEvent& evt);
569  void evtOnHelpAbout(wxCommandEvent& evt);
571  void evtOnHelpPDFSystemMapEditorReferenceGuide(wxCommandEvent& evt);
573  void evtOnHelpPDFExamplesLibrary(wxCommandEvent& evt);
575  void evtOnHelpOnlineDocumentation(wxCommandEvent& evt);
576 
578 
580 
581  void evtOnMenuOpen(wxMenuEvent& evt);
582  void evtOnMenuClose(wxMenuEvent& evt);
584 
586  void evtOnUpdateGUIAfterStudyIO(bool opened);
587 
589  void onMainNotebookPageChanging(Component::Notebook::Page& page);
591  void onSectionNotebookPageChanging(Component::Notebook::Page& page);
593  void onScenarioBuilderNotebookPageChanging(Component::Notebook::Page& page);
595  void onOutputNotebookPageChanging(Component::Notebook::Page& page);
596 
598  void onSystemParametersChanged();
599 
600  // Renewable generation modelling changed, some pages have to be hidden or disabled
601  void onRenewableGenerationModellingChanged(bool init);
602  void refreshHomePageOnRenewableModellingChanged(bool aggregated, bool init);
603  void refreshScenarioBuilderPagOnRenewableModellingChanged(bool aggregated);
604  void refreshInputMenuOnRenewableModellingChanged(bool aggregated);
605 
607  void evtOnUpdateInterfaceAfterLoadedStudy(wxCommandEvent& evt);
608 
609  void evtOnFrameClose(wxCloseEvent& evt);
610 
611  void internalFrameClose();
612 
613  void evtLaunchConstraintsBuilder(wxCommandEvent& evt);
614 
615  void onMouseMoved(wxMouseEvent& evt);
616 
617  void onLogMessageDeferred(int level, const std::string& message);
618  void onLogMessage(wxCommandEvent& evt);
619 
620  void onStudyLoaded();
621 
622  void purgeAllTemporaryObjects();
623 
624  virtual void updateOpenWindowsMenu();
625  virtual bool excludeFromMenu();
626 
627 private:
629  using StudyPtr = Data::Study*;
630 
631 private:
633  wxPanel* pBigDaddy;
635  wxAuiManager pAUIManager;
637  wxSizer* pMainSizer;
639  wxMenuBar* pMenu;
641  wxMenu* pMenuFile;
642  wxMenuItem* pMenuFileRecents;
644  wxMenu* pMenuEdit;
646  wxMenu* pMenuView;
648  wxMenu* pMenuInput;
649  wxMenuItem* pMenuInputCreation;
650  wxMenuItem* pMenuInputLastSaved;
652  wxMenu* pMenuOutput;
654  wxMenu* pMenuSimulation;
656  wxMenu* pMenuOptions;
658  wxMenuItem* pMenuGeographicTrimming;
660  wxMenuItem* pMenuAdequacyPatch;
662  wxMenu* pMenuWindow;
664  wxMenu* pMenuTools;
666  wxMenu* pMenuHelp;
667 
669  wxMenu* pPopupMenuOperatorsGrid;
670 
672  Map::Component* pMainMap;
673  Component::Notebook* pNotebook;
674  Component::Notebook* pScenarioBuilderNotebook;
675  Component::Notebook* pOutputViewerNotebook;
676  Component::Notebook* pSectionNotebook;
677 
679  Component::MainPanel* pMainPanel;
680 
681  Component::Notebook::Page* pageLoadTimeSeries;
682  Component::Notebook::Page* pageLoadPrepro;
683  Component::Notebook::Page* pageLoadCorrelation;
684 
685  Component::Notebook::Page* pageSolarTimeSeries;
686  Component::Notebook::Page* pageSolarPrepro;
687  Component::Notebook::Page* pageSolarCorrelation;
688 
689  Component::Notebook::Page* pageHydroTimeSeries;
690  Component::Notebook::Page* pageHydroPrepro;
691  Component::Notebook::Page* pageHydroCorrelation;
692  Component::Notebook::Page* pageHydroAllocation;
693 
694  Component::Notebook::Page* pageWindTimeSeries;
695  Component::Notebook::Page* pageWindPrepro;
696  Component::Notebook::Page* pageWindPreproDailyProfile;
697  Component::Notebook::Page* pageWindCorrelation;
698 
699  Component::Notebook::Page* pageThermalClusterList;
700  Component::Notebook::Page* pageThermalTimeSeries;
701  Component::Notebook::Page* pageThermalTimeSeriesFuelCost;
702  Component::Notebook::Page* pageThermalTimeSeriesCO2Cost;
703  Component::Notebook::Page* pageThermalPrepro;
704  Component::Notebook::Page* pageThermalCommon;
705 
706  Component::Notebook::Page* pageRenewableClusterList;
707  Component::Notebook::Page* pageRenewableCommon;
708 
709  Component::Notebook::Page* pageLinksSummary = nullptr;
710  Component::Notebook::Page* pageLinksParameters = nullptr;
711  Component::Notebook::Page* pageLinksNTC = nullptr;
712 
713  Component::Notebook::Page* pageNodalOptim;
714 
715  Window::BindingConstraint* pWndBindingConstraints;
716 
717  // Secnario buider pages
718  Component::Notebook::Page* pScenarioBuilderMainPage;
719  Component::Notebook::Page* pageScBuilderLoad;
720  Component::Notebook::Page* pageScBuilderThermal;
721  Component::Notebook::Page* pageScBuilderHydro;
722  Component::Notebook::Page* pageScBuilderWind;
723  Component::Notebook::Page* pageScBuilderSolar;
724  Component::Notebook::Page* pageScBuilderNTC;
725  Component::Notebook::Page* pageScBuilderRenewable;
726  Component::Notebook::Page* pageScBuilderHydroInitialLevels;
727  Component::Notebook::Page* pageScBuilderHydroFinalLevels;
728 
730  Component::Datagrid::Selection::IOperator* pGridSelectionOperator;
731  wxGrid* pGridSelectionAttachedGrid;
732 
734  wxMenu* pMapContextMenu;
735 
737  Window::Notes* pUserNotes;
738 
740  Window::Sets* pSets;
741 
743  bool pMainNotebookAlreadyHasItsComponents;
744 
746  wxTimer* pLogFlusherTimer;
747 
749  Window::StudyLogs* pWndLogs;
750 
752  bool pGuiReady;
753 
754  uint pUpdateCountLocker;
755 
757  MainFormData* pData;
758 
760  uint pCurrentEquipmentPage;
761 
762  // Pointer to latest output
763  Data::Output::Ptr latestOutput = nullptr;
764 
765  // friends
766  template<class WindowT>
767  friend class Disabler;
768  friend class MainFormData;
769  friend class Window::StudyLogs;
770 
771  // Event table
772  DECLARE_EVENT_TABLE()
773 
774 }; // class ApplWnd
775 
777 extern Yuni::String StudyToLoadAtStartup;
778 
779 } // namespace Antares::Forms
780 
781 #include "disabler.h"
782 #include "main.hxx"
783 
784 #endif // __ANTARES_APPLICATION_MAIN_MAIN_H__
Definition: selectionoperation.h:31
Definition: local-frame.h:32
Definition: mainpanel.h:30
Definition: notebook.h:61
Notebook.
Definition: notebook.h:36
std::shared_ptr< Output > Ptr
Smartptr.
Definition: output.h:41
Definition: study.h:57
Main Frame of the Antares UI application.
Definition: main.h:50
void pasteFromClipboard(const Yuni::String &text, bool showDialog)
Perform the 'paste' operation from a given text.
void selectSystem()
Select the first page of the main notebook.
Definition: main.cpp:355
void copyToClipboard()
Copy to the clipboard items present in the inspector.
Definition: events.edit.cpp:42
void pasteFromClipboard(bool showDialog=false)
Try to paste data from the clipboard.
Definition: paste-from-clipboard.cpp:160
Map::Component * map() const
Get the component used for the map.
Definition: main.hxx:31
void connectLogCallback()
Reconnect the logs to the main callback.
Definition: logs.cpp:229
Component::Datagrid::Selection::IOperator * gridOperatorSelectedCells() const
Get the current grid operator for selected cells.
Definition: main.cpp:880
wxAuiManager & AUIManager()
Get the AUI manager.
Definition: main.h:242
void hideWIP()
Hide the WIP status.
Definition: wip.cpp:56
static ApplWnd * Instance()
Get the instance of the main window.
bool isInWIPMode() const
Get if the WIP mode is enabled.
Definition: main.cpp:1146
void requestUpdateGUIAfterStudyIO(const bool studyOpened)
Emit an event to update the GUI after a study has been loaded or closed.
Definition: main.cpp:584
Component::MainPanel * mainPanel() const
Get the component used for the main panel.
Definition: main.hxx:36
void forceFocus()
Assign the focus to this form and refresh it.
Definition: refresh.cpp:407
bool wouldYouLikeToSaveTheStudy()
Ask the user if the study must be saved.
Definition: main.cpp:931
void showStudyLogs()
Display the logs window.
Definition: logs.cpp:202
void exportMap(const Yuni::String &path, bool transparentBackground, const wxColour &backgroundColor, const std::list< uint16_t > &layers, int nbSplitParts, Antares::Map::mapImageFormat format)
Export the map.
Definition: main.cpp:626
ApplWnd()
Default constructor.
Definition: main.cpp:199
void delayForceFocus()
Force the focus (delayed)
Definition: refresh.cpp:421
void endUpdateLogs() const
end update
Definition: logs.cpp:291
void forceRefresh()
Force the refresh of the window and all its children.
Definition: refresh.cpp:393
void createAllComponentsNeededByTheMainNotebook()
Create all components for displaying a study.
Definition: create.cpp:476
wxMenuItem * menuRecentFiles() const
Get the wxMenuItem associated to the recent files.
Definition: main.hxx:26
void backgroundTimerStop() const
Stop all timers.
Definition: main.cpp:1089
void startAntares()
Starting sequence, delayed after the creation of the main form.
Definition: create.cpp:439
bool isScenarioBuilderOpened() const
Get if the scenario builder page is opened.
Definition: main.cpp:1127
virtual ~ApplWnd()
Destructor.
Definition: main.cpp:279
Yuni::Event< void()> onApplicationQuit
Event: The application is about to quit.
Definition: main.h:345
MainFormData * data()
retrieve the internal data
Definition: main.hxx:41
void backToInputData()
Select the input data notebook page.
Definition: main.cpp:1133
void beginUpdateLogs() const
Avoid display logs.
Definition: logs.cpp:296
void selectAllDefaultPages()
Select all default pages for all notebooks.
Definition: main.cpp:1016
void refreshMenuOutput()
Refresh the simulation results list.
Definition: refresh.cpp:113
wxString openStudyFolder(bool autoLoad=true)
Ask to the user a study folder from a standard dialog box.
Definition: events.file.cpp:264
void launchConstraintsBuilder(const Yuni::String &filename)
Launch the processor.
Definition: constraintsbuilder.cpp:229
void resetDragAndDrop()
Reset the drag and drop target.
Definition: create.cpp:243
void saveStudy()
Save the study.
Definition: main.cpp:610
void resetDefaultStatusBarText()
Reset the default text for the status bar.
Definition: statusbar.cpp:35
void showWIP()
Show the WIP status.
Definition: wip.cpp:41
void disableGridOperatorIfGrid(wxGrid *grid)
Disable the grid operator.
Definition: main.cpp:885
void refreshMenuOptions(Data::Study::Ptr study)
Refresh the simulation options.
Definition: refresh.cpp:369
void gridOperatorSelectedCellsUpdateResult(wxGrid *grid)
Update the GUI to display the result of the grid operator.
Definition: statusbar.cpp:181
uint mainNotebookCurrentEquipmentPage() const
Get the current equipment page.
Definition: main.cpp:644
void saveStudyAs(const Yuni::String &path, bool copyoutput, bool copyuserdata, bool copylogs)
Save the study as...
Definition: main.cpp:618
Definition: disabler.h:28
Definition: internal-data.h:42
Standard study MAP.
Definition: component.h:40
Settings for a single Binding constraint.
Definition: bindingconstraint.h:38
Save As Dialog
Definition: notes.h:34
Save As Dialog
Definition: sets.h:34
Definition: studylogs.h:81