Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
main.h
1/*
2** Copyright 2007-2024, 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 <yuni/yuni.h>
25#include <ui/common/wx-wrapper.h>
26#include <wx/aui/aui.h>
27
28#include "../../toolbox/components/notebook/notebook.h"
29#include "../../toolbox/components/datagrid/selectionoperation.h"
30#include "../../toolbox/components/map/settings.h"
31#include <list>
32#include "fwd.h"
33#include "antares/config/config.h"
34#include <ui/common/component/frame/local-frame.h>
35#include <antares/study/study.h>
36#include <antares/study/output.h>
37
38namespace Antares
39{
40namespace Forms
41{
42// Internal data of the main form, to reduce dependencies and (re)compile time
43// Forward declaration
44class MainFormData;
45
49class ApplWnd final : public Component::Frame::WxLocalFrame, public Yuni::IEventObserver<ApplWnd>
50{
51public:
55 static ApplWnd* Instance();
56
57public:
59
60
61 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
196 void beginUpdateLogs() const;
198 void endUpdateLogs() const;
200 void connectLogCallback();
202
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 const wxAuiManager& AUIManager() const
247 {
248 return pAUIManager;
249 }
250
255
261 void launchAnalyzer(const Yuni::String& filename);
262
269 void launchConstraintsBuilder(const Yuni::String& filename);
270
272
273
276 bool isScenarioBuilderOpened() const;
278
282 void backgroundTimerStop() const;
283
285
287
288
291
295 void backToInputData();
296
298
299
302 void copyToClipboard();
303
309 void pasteFromClipboard(bool showDialog = false);
310
317 void pasteFromClipboard(const Yuni::String& text, bool showDialog);
319
321
322
328 void showWIP();
335 void hideWIP();
337 bool isInWIPMode() const;
339
341
342
345 const MainFormData* data() const;
347 void viewLatestOutput();
348
349public:
351 Yuni::Event<void()> onApplicationQuit;
352
353private:
355
356
357 void internalInitialize();
358
359 void installUserLicense(bool online = false);
360
362 void prepareStudyIconFile();
363
365 wxMenuBar* createMenu();
367 wxMenu* createPopupMenuOperatorsOnGrid();
368
370 wxMenu* createMenuFiles();
372 wxMenu* createMenuEdit();
374 wxMenu* createMenuView();
376 wxMenu* createMenuInput();
378 wxMenu* createMenuOutput();
380 wxMenu* createMenuSimulation();
382 wxMenu* createMenuOptions();
384 wxMenu* createMenuTools();
386 wxMenu* createMenuWindow();
388 wxMenu* createMenuHelp();
389
391 void evtOnExecuteQueueEvent(wxCommandEvent&);
392
394 void createNBSimulation();
396 void createNBNotes();
398 void createNBLoad();
400 void createNBSolar();
402 void createNBHydro();
404 void createNBWind();
406 void createNBThermal();
408 void createNBRenewable();
410 void createNBDSM();
412 void createNBMisc();
414 void createNBInterconnections();
416 void createNBBindingConstraints();
418 void createNBNodalOptimization();
420 void createNBScenarioBuilder();
422 void createNBOutputViewer();
424 void createNBSets();
426
428
429
430 void createLogs();
432 void destroyLogsViewer();
434 void destroyLogs();
436
438
439
440 void evtOnContextMenuStatusBar(wxContextMenuEvent& evt);
441 void evtOnContextMenuChangeOperator(wxCommandEvent& evt);
442 void evtOnContextMenuMap(int x, int y);
444
446
447
448 void evtOnWizard(wxCommandEvent& evt);
450 void evtOnQuit(wxCommandEvent& evt);
452 void evtOnNewStudy(wxCommandEvent& evt);
454 void evtOnOpenStudy(wxCommandEvent& evt);
456 void evtOnOpenRecentsToggleShowPaths(wxCommandEvent& evt);
458 void evtOnOpenRecentsClearHistory(wxCommandEvent& evt);
460 void evtOnDropDownRecents(wxAuiToolBarEvent& evt);
462 void evtOnCloseStudy(wxCommandEvent& evt);
464 void evtOnQuickOpenStudy(wxCommandEvent& evt);
466 void evtOnSave(wxCommandEvent& evt);
468 void evtOnSaveAs(wxCommandEvent& evt);
470 void evtOnExportMap(wxCommandEvent& evt);
472 void evtOnFullscreen(wxCommandEvent& evt);
474 void evtOnInspector(wxCommandEvent& evt);
476 void evtOnOpenStudyFolderInExplorer(wxCommandEvent& evt);
478
480
481 void evtOnViewSystem(wxCommandEvent& evt);
482 void evtOnViewAllSystem(wxCommandEvent& evt);
483 void evtOnViewSimulation(wxCommandEvent& evt);
484 void evtOnViewNotes(wxCommandEvent& evt);
485 void evtOnViewLoad(wxCommandEvent& evt);
486 void evtOnViewSolar(wxCommandEvent& evt);
487 void evtOnViewWind(wxCommandEvent& evt);
488 void evtOnViewRenewable(wxCommandEvent& evt);
489 void evtOnViewHydro(wxCommandEvent& evt);
490 void evtOnViewThermal(wxCommandEvent& evt);
491 void evtOnViewReservesDSM(wxCommandEvent& evt);
492 void evtOnViewMiscGen(wxCommandEvent& evt);
493 void evtOnViewInterconnections(wxCommandEvent& evt);
494 void evtOnViewBindingConstraints(wxCommandEvent& evt);
495 void evtOnViewNodalOptimization(wxCommandEvent& evt);
497
499
500 void evtOnSetStudyInfos(wxCommandEvent& evt);
502 void evtOnStudySessions(wxCommandEvent& evt);
504 void evtOnEditMapSelectAll(wxCommandEvent& evt);
506 void evtOnEditMapUnselectAll(wxCommandEvent& evt);
508 void evtOnEditMapReverseSelection(wxCommandEvent& evt);
510 void evtOnEditCopy(wxCommandEvent& evt);
512 void evtOnEditPaste(wxCommandEvent& evt);
514 void evtOnEditPasteSpecial(wxCommandEvent& evt);
516 void onMapDblClick(Map::Component& sender);
518
520
521
522 void evtOnRunSimulation(wxCommandEvent& evt);
523 void evtOnRunTSGenerators(wxCommandEvent& evt);
524 void evtOnRunTSGeneratorsDelayed();
525
526 void evtOnRunTSAnalyzer(wxCommandEvent& evt);
527 void evtOnRunTSAnalyzerDelayed();
528
529 void evtOnRunConstraintsBuilder(wxCommandEvent& evt);
530 void evtOnRunConstraintsBuilderDelayed();
532
534
535
536 void evtOnMemoryUsedByTheStudy(wxCommandEvent& evt);
538
540
541
542 void evtOnOptionsTempFolder(wxCommandEvent& evt);
544 void evtOnOptionsSelectOutput(wxCommandEvent& evt);
546 void evtOnOptionsSelectAreasTrimming(wxCommandEvent& evt);
548 void evtOnOptionsSelectLinksTrimming(wxCommandEvent& evt);
550 void evtOnOptionsDistricts(wxCommandEvent& evt);
552 void evtOnOptionsMCPlaylist(wxCommandEvent& evt);
554 void evtOnOptionsMCScenarioBuilder(wxCommandEvent& evt);
556 void evtOnOptionsOptimizationPrefs(wxCommandEvent& evt);
558 void evtOnOptionsAdvanced(wxCommandEvent& evt);
560 void evtOnOptionsAdequacyPatchOptions(wxCommandEvent& evt);
562 void evtOnOptionsAdequacyPatchAreas(wxCommandEvent& evt);
564
566
567
568 void evtOnStudyLogs(wxCommandEvent& evt);
570 void evtOnRaiseWindow(wxCommandEvent& evt);
572
574
575
576 // void evtOnHelpVisitRTEWebsite(wxCommandEvent& evt);
578 void evtOnHelpAbout(wxCommandEvent& evt);
580 void evtOnHelpPDFSystemMapEditorReferenceGuide(wxCommandEvent& evt);
582 void evtOnHelpPDFExamplesLibrary(wxCommandEvent& evt);
584 void evtOnHelpOnlineDocumentation(wxCommandEvent& evt);
585
587
589
590 void evtOnMenuOpen(wxMenuEvent& evt);
591 void evtOnMenuClose(wxMenuEvent& evt);
593
595 void evtOnUpdateGUIAfterStudyIO(bool opened);
596
598 void onMainNotebookPageChanging(Component::Notebook::Page& page);
600 void onSectionNotebookPageChanging(Component::Notebook::Page& page);
602 void onScenarioBuilderNotebookPageChanging(Component::Notebook::Page& page);
604 void onOutputNotebookPageChanging(Component::Notebook::Page& page);
605
607 void onSystemParametersChanged();
608
609 // Renewable generation modelling changed, some pages have to be hidden or disabled
610 void onRenewableGenerationModellingChanged(bool init);
611 void refreshHomePageOnRenewableModellingChanged(bool aggregated, bool init);
612 void refreshScenarioBuilderPagOnRenewableModellingChanged(bool aggregated);
613 void refreshInputMenuOnRenewableModellingChanged(bool aggregated);
614
616 void evtOnUpdateInterfaceAfterLoadedStudy(wxCommandEvent& evt);
617
618 void evtOnFrameClose(wxCloseEvent& evt);
619
620 void internalFrameClose();
621
622 void evtLaunchAnalyzer(wxCommandEvent& evt);
623
624 void evtLaunchConstraintsBuilder(wxCommandEvent& evt);
625
626 void onMouseMoved(wxMouseEvent& evt);
627
628 void onLogMessageDeferred(int level, const std::string& message);
629 void onLogMessage(wxCommandEvent& evt);
630
631 void onStudyLoaded();
632
633 void purgeAllTemporaryObjects();
634
635 virtual void updateOpenWindowsMenu();
636 virtual bool excludeFromMenu();
637
638private:
640 using StudyPtr = Data::Study*;
641
642private:
644 wxPanel* pBigDaddy;
646 wxAuiManager pAUIManager;
648 wxSizer* pMainSizer;
650 wxMenuBar* pMenu;
652 wxMenu* pMenuFile;
653 wxMenuItem* pMenuFileRecents;
655 wxMenu* pMenuEdit;
657 wxMenu* pMenuView;
659 wxMenu* pMenuInput;
660 wxMenuItem* pMenuInputCreation;
661 wxMenuItem* pMenuInputLastSaved;
663 wxMenu* pMenuOutput;
665 wxMenu* pMenuSimulation;
667 wxMenu* pMenuOptions;
669 wxMenuItem* pMenuGeographicTrimming;
671 wxMenuItem* pMenuAdequacyPatch;
673 wxMenu* pMenuWindow;
675 wxMenu* pMenuTools;
677 wxMenu* pMenuHelp;
678
680 wxMenu* pPopupMenuOperatorsGrid;
681
683 Map::Component* pMainMap;
684 Component::Notebook* pNotebook;
685 Component::Notebook* pScenarioBuilderNotebook;
686 Component::Notebook* pOutputViewerNotebook;
687 Component::Notebook* pSectionNotebook;
688
690 Component::MainPanel* pMainPanel;
691
692 Component::Notebook::Page* pageLoadTimeSeries;
693 Component::Notebook::Page* pageLoadPrepro;
694 Component::Notebook::Page* pageLoadCorrelation;
695
696 Component::Notebook::Page* pageSolarTimeSeries;
697 Component::Notebook::Page* pageSolarPrepro;
698 Component::Notebook::Page* pageSolarCorrelation;
699
700 Component::Notebook::Page* pageHydroTimeSeries;
701 Component::Notebook::Page* pageHydroPrepro;
702 Component::Notebook::Page* pageHydroCorrelation;
703 Component::Notebook::Page* pageHydroAllocation;
704
705 Component::Notebook::Page* pageWindTimeSeries;
706 Component::Notebook::Page* pageWindPrepro;
707 Component::Notebook::Page* pageWindPreproDailyProfile;
708 Component::Notebook::Page* pageWindCorrelation;
709
710 Component::Notebook::Page* pageThermalClusterList;
711 Component::Notebook::Page* pageThermalTimeSeries;
712 Component::Notebook::Page* pageThermalTimeSeriesFuelCost;
713 Component::Notebook::Page* pageThermalTimeSeriesCO2Cost;
714 Component::Notebook::Page* pageThermalPrepro;
715 Component::Notebook::Page* pageThermalCommon;
716
717 Component::Notebook::Page* pageRenewableClusterList;
718 Component::Notebook::Page* pageRenewableCommon;
719
720 Component::Notebook::Page* pageLinksSummary = nullptr;
721 Component::Notebook::Page* pageLinksParameters = nullptr;
722 Component::Notebook::Page* pageLinksNTC = nullptr;
723
724 Component::Notebook::Page* pageNodalOptim;
725
726 Window::BindingConstraint* pWndBindingConstraints;
727
728 // Secnario buider pages
729 Component::Notebook::Page* pScenarioBuilderMainPage;
730 Component::Notebook::Page* pageScBuilderLoad;
731 Component::Notebook::Page* pageScBuilderThermal;
732 Component::Notebook::Page* pageScBuilderHydro;
733 Component::Notebook::Page* pageScBuilderWind;
734 Component::Notebook::Page* pageScBuilderSolar;
735 Component::Notebook::Page* pageScBuilderNTC;
736 Component::Notebook::Page* pageScBuilderRenewable;
737 Component::Notebook::Page* pageScBuilderHydroInitialLevels;
738 Component::Notebook::Page* pageScBuilderHydroFinalLevels;
739
741 Component::Datagrid::Selection::IOperator* pGridSelectionOperator;
742 wxGrid* pGridSelectionAttachedGrid;
743
745 wxMenu* pMapContextMenu;
746
748 Window::Notes* pUserNotes;
749
751 Window::Sets* pSets;
752
754 bool pMainNotebookAlreadyHasItsComponents;
755
757 wxTimer* pLogFlusherTimer;
758
760 Window::StudyLogs* pWndLogs;
761
763 bool pGuiReady;
764
765 uint pUpdateCountLocker;
766
768 MainFormData* pData;
769
771 uint pCurrentEquipmentPage;
772
773 // Pointer to latest output
774 Data::Output::Ptr latestOutput = nullptr;
775
776 // friends
777 template<class WindowT>
778 friend class Disabler;
779 friend class MainFormData;
780 friend class Window::StudyLogs;
781
782 // Event table
783 DECLARE_EVENT_TABLE()
784
785}; // class ApplWnd
786
788extern Yuni::String StudyToLoadAtStartup;
789
790} // namespace Forms
791} // namespace Antares
792
793#include "main.hxx"
794#include "disabler.h"
795
796#endif // __ANTARES_APPLICATION_MAIN_MAIN_H__
Definition selectionoperation.h:43
Definition local-frame.h:36
Definition mainpanel.h:32
Definition notebook.h:62
Notebook.
Definition notebook.h:38
std::shared_ptr< Output > Ptr
Smartptr.
Definition output.h:43
Definition study.h:61
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:358
void copyToClipboard()
Copy to the clipboard items present in the inspector.
Definition events.edit.cpp:44
void pasteFromClipboard(bool showDialog=false)
Try to paste data from the clipboard.
Definition paste-from-clipboard.cpp:148
Map::Component * map() const
Get the component used for the map.
Definition main.hxx:33
void connectLogCallback()
Reconnect the logs to the main callback.
Definition logs.cpp:203
Component::Datagrid::Selection::IOperator * gridOperatorSelectedCells() const
Get the current grid operator for selected cells.
Definition main.cpp:835
void hideWIP()
Hide the WIP status.
Definition wip.cpp:56
bool isInWIPMode() const
Get if the WIP mode is enabled.
Definition main.cpp:1056
void requestUpdateGUIAfterStudyIO(const bool studyOpened)
Emit an event to update the GUI after a study has been loaded or closed.
Definition main.cpp:577
Component::MainPanel * mainPanel() const
Get the component used for the main panel.
Definition main.hxx:38
void forceFocus()
Assign the focus to this form and refresh it.
Definition refresh.cpp:358
bool wouldYouLikeToSaveTheStudy()
Ask the user if the study must be saved.
Definition main.cpp:882
void showStudyLogs()
Display the logs window.
Definition logs.cpp:180
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:615
ApplWnd()
Default constructor.
Definition main.cpp:204
void delayForceFocus()
Force the focus (delayed)
Definition refresh.cpp:372
void endUpdateLogs() const
end update
Definition logs.cpp:263
void forceRefresh()
Force the refresh of the window and all its children.
Definition refresh.cpp:344
void createAllComponentsNeededByTheMainNotebook()
Create all components for displaying a study.
Definition create.cpp:469
wxMenuItem * menuRecentFiles() const
Get the wxMenuItem associated to the recent files.
Definition main.hxx:28
void backgroundTimerStop() const
Stop all timers.
Definition main.cpp:1003
void startAntares()
Starting sequence, delayed after the creation of the main form.
Definition create.cpp:435
static ApplWnd * Instance()
Get the instance of the main window.
bool isScenarioBuilderOpened() const
Get if the scenario builder page is opened.
Definition main.cpp:1039
virtual ~ApplWnd()
Destructor.
Definition main.cpp:284
Yuni::Event< void()> onApplicationQuit
Event: The application is about to quit.
Definition main.h:351
MainFormData * data()
retrieve the internal data
Definition main.hxx:43
void backToInputData()
Select the input data notebook page.
Definition main.cpp:1045
wxAuiManager & AUIManager()
Get the AUI manager.
Definition main.h:242
void beginUpdateLogs() const
Avoid display logs.
Definition logs.cpp:268
void selectAllDefaultPages()
Select all default pages for all notebooks.
Definition main.cpp:960
void refreshMenuOutput()
Refresh the simulation results list.
Definition refresh.cpp:105
wxString openStudyFolder(bool autoLoad=true)
Ask to the user a study folder from a standard dialog box.
Definition events.file.cpp:256
void launchConstraintsBuilder(const Yuni::String &filename)
Launch the processor.
Definition constraintsbuilder.cpp:227
void resetDragAndDrop()
Reset the drag and drop target.
Definition create.cpp:243
void saveStudy()
Save the study.
Definition main.cpp:603
void resetDefaultStatusBarText()
Reset the default text for the status bar.
Definition statusbar.cpp:35
void showWIP()
Show the WIP status.
Definition wip.cpp:43
void disableGridOperatorIfGrid(wxGrid *grid)
Disable the grid operator.
Definition main.cpp:840
void refreshMenuOptions(Data::Study::Ptr study)
Refresh the simulation options.
Definition refresh.cpp:326
void gridOperatorSelectedCellsUpdateResult(wxGrid *grid)
Update the GUI to display the result of the grid operator.
Definition statusbar.cpp:180
uint mainNotebookCurrentEquipmentPage() const
Get the current equipment page.
Definition main.cpp:627
void saveStudyAs(const Yuni::String &path, bool copyoutput, bool copyuserdata, bool copylogs)
Save the study as...
Definition main.cpp:609
void launchAnalyzer(const Yuni::String &filename)
Launch the processor.
Definition analyzer.cpp:39
Definition fwd.h:59
Definition internal-data.h:44
Standard study MAP.
Definition component.h:42
Settings for a single Binding constraint.
Definition bindingconstraint.h:40
Save As Dialog
Definition notes.h:36
Save As Dialog
Definition sets.h:36
Definition studylogs.h:82