Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
output.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_WINDOWS_OUTPUT_OUTPUT_H__
22#define __ANTARES_WINDOWS_OUTPUT_OUTPUT_H__
23
24#include <mutex>
25#include <ui/common/component/panel.h>
26#include "../../application/study.h"
27#include "../../toolbox/components/button.h"
28#include <wx/treectrl.h>
29#include <wx/splitter.h>
30#include <wx/sizer.h>
31#include "layer.h"
32#include "fwd.h"
33#include <antares/study/fwd.h>
34#include <wx/statbmp.h>
35#include <wx/scrolwin.h>
36#include "panel.h"
37#include <ui/common/component/spotlight.h>
38
39namespace Antares
40{
41namespace Window
42{
43namespace OutputViewer
44{
48class Component : public Antares::Component::Panel, public Yuni::IEventObserver<Component>
49{
50public:
53
54public:
58 static void ConvertVarNameToID(Yuni::String& id, const Yuni::String& name);
59
60public:
62
63
66 Component(wxWindow* parent, bool parentIsStandaloneWindow = false);
68 virtual ~Component();
70
74 void clear();
75
79 void update(const Data::Output::List& list, const Data::Output::Ptr& selection);
80
81 void updateLayerList();
82
86 void copyFrom(const Component& source);
87
91 void scrollAllPanels(wxScrolledWindow* component);
92
93 void selectCellAllPanels(uint x, uint y);
94
96 void refreshAllTabs();
98 void refreshAllPanels();
101
102 void refreshPanel(uint index);
103
104private:
105 class Tab
106 {
107 public:
109 using Ptr = std::shared_ptr<Tab>;
111 using Vector = std::vector<Ptr>;
112
113 public:
115
116
117 explicit Tab(Component& comparent);
119 ~Tab();
121
122 void updateAreaOrLinkName(SelectionType selection, const Yuni::String& text);
123
124 public:
126 Component& component;
132 Antares::Component::Button* btnCustomSelection;
136 wxSizer* btnSizer;
137 };
138
139private:
141 void outputSelectionsClear();
142
144 void createAllControlsIfNeeded();
146 void onStudyClosed();
148 void internalUpdate();
150 void backToInputData(void*);
152 void allYearsOrYearByYearSelector(Antares::Component::Button&, wxMenu& menu, void*);
154 void dropDownAllVariables(Antares::Component::Button&, wxMenu&, void*);
156 void incrementYearByYear(void*);
158 void decrementYearByYear(void*);
160 void goToASpecificYear(void*);
161
163 void openNewWindow(void*);
165 void updateFromExternalEvent(const Data::Output::List&, const Data::Output::Ptr selection);
166
168 void onDropDownOutputs(Antares::Component::Button&, wxMenu& menu, void*);
169 void onDropDownComparison(Antares::Component::Button&, wxMenu& menu, void*);
170 void onDropDownDetachMenu(Antares::Component::Button&, wxMenu& menu, void*);
171
173 void selectAnotherOutput(const Data::Output::Ptr& selectedOutput);
175 void removeOutput(Layer* layer);
176
178 void onDetachCurrentLayer(wxCommandEvent& evt);
179
181 uint outputSelectionsAdd(Data::Output::Ptr output);
183 void createNewVirtualLayer(LayerType type);
184
186 void onSelectDataLevel(void*);
188 void onSelectTimeLevel(void*);
189
191 void onToggleSidebar(void*);
192
194 const char* imageForLayerPlaceOrder(const Layer* so) const;
195 const char* imageForLayerPlaceOrder(const Data::Output::Ptr& so) const;
200 int imageIndexForOutput(const Data::Output::Ptr& output) const;
202 void createSubMenuForSwitchingOrders(wxMenu* menu, const Layer* currentLayer) const;
204 void rebuildIndexes();
205
207 void refreshCurrentYear();
208
212 void displayMiniFrame(wxWindow* parent,
214 int width = 340,
215 bool searchInput = true,
216 bool groups = true);
217
219 void bugFixResetSashPosition();
220
222 void mergeOutputs();
224 void stopMerging();
225
227 void treeDataClear();
229 void treeDataWaiting();
231 void treeDataUpdate();
233 void treeDataUpdateWL(const Content& content);
235 bool checkAreaIsCommonToAllOutputs(const Data::AreaName& name);
237 bool checkLinkIsCommonToAllOutputs(const Data::AreaLinkName& name);
239 void checkYearByYearMode();
241 void noSimulationData();
243 void updateAreaOrLinkName();
244
246 void updateGlobalSelection();
247
248 void updateButtonView();
249
253 void emptyCache();
254
258 void closeSubFrames();
259
260private:
262 using Button = Antares::Component::Button;
264 using WxPanelVector = std::vector<wxPanel*>;
265
266private:
268 Data::Output::List pOutputs;
270 Layer::Vector pSelections;
272 Yuni::String pCurrentAreaOrLink;
274 SelectionType pCurrentSelectionType;
276 LevelOfDetails pCurrentLOD;
278 uint pCurrentYear;
280 uint pYearsLimits[2];
282 bool pHasYearByYear;
284 bool pHasConcatenedDataset;
286 Yuni::String pCurrentVariable;
288 Yuni::String pCurrentVariableID;
289
291 Antares::Private::OutputViewerData::ThermalNameSetPerArea* pCurrentClusters;
292
294 Tab::Vector pTabs;
296 WxPanelVector pBtnPanelAllOutputs;
298 wxSizer* pSizerForBtnOutputs;
300 wxWindow* pWindowForBtnOutputs;
304 wxSizer* pSizerForPanelOutputs;
306 wxWindow* pWindowForPanelOutputs;
308 Yuni::Event<void(wxScrolledWindow*)> pOnScrollAllPanels;
310 Yuni::Event<void(uint, uint)> pOnSelectCellAllPanels;
311
313 Button* pBtnAllYears;
314
316 wxSizer* pSizerYearsToolbar;
318 wxSizer* pSizerYearByYearToolbar;
320 wxSizer* pSizerVariables;
321
322 wxSizer* pSizerToolbar;
323
325 Layer* pCurrentLayerForMenu;
327 wxWindow* pLblAreaOrLinkName;
328
331
333 bool pControlsAlreadyCreated;
334
336 wxSplitterWindow* pSplitter;
337 wxWindow* pSplitterWindow1;
338 wxWindow* pSplitterWindow2;
340 bool pSidebarCollapsed;
341 int pOldSidebarWidth;
342 Button* pBtnExpandCollapseSidebar;
343
345 wxWindow* pParentWindow;
346
348 wxWindow* pLabelItemName;
350 Button* pBtnValues;
352 Button* pBtnDetails;
354 Button* pBtnDetailsRes;
356 Button* pBtnID;
357
359 Button* pBtnHourly;
361 Button* pBtnDaily;
363 Button* pBtnWeekly;
365 Button* pBtnMonthly;
367 Button* pBtnAnnual;
368
370 Button* pBtnCurrentYearNumber;
372 Button* pBtnVariables;
373
375
376 std::mutex pMutex;
378 Antares::Private::OutputViewerData::JobVector pJobs;
380 // The access to this variable must be protected with pMutex
381 // This variable is used to build the list of areas / links once
382 // prepared.
383 Antares::Private::OutputViewerData::ContentMap pAlreadyPreparedContents;
385 // The access to this variable must be protected with pMutex
386 uint pJobsRemaining;
388
390 bool pOpenedInANewWindow;
391
393 bool pASelectionHasAlreadyBeenMade;
394
395 // friends !
398 friend class Tab;
399 friend class SpotlightProvider;
401 friend class SpotlightProviderMCAll;
402 friend class Provider::Variables;
403 friend class Provider::Outputs;
404 friend class Provider::Comparison;
405
406}; // class Component
407
408} // namespace OutputViewer
409} // namespace Window
410} // namespace Antares
411
412#endif // __ANTARES_WINDOWS_OUTPUT_OUTPUT_H__
Definition button.h:34
Panel implementation.
Definition panel.h:36
std::shared_ptr< IProvider > Ptr
ptr
Definition spotlight.h:34
Definition spotlight.h:40
std::list< Ptr > List
List.
Definition output.h:45
std::shared_ptr< Output > Ptr
Smartptr.
Definition output.h:43
std::vector< Panel * > Vector
Vector.
Definition panel.h:46
Component: Viewer for simulation results.
Definition output.h:49
void update(const Data::Output::List &list, const Data::Output::Ptr &selection)
Update the list of all outputs.
Definition output.cpp:638
void refreshAllPanels()
Refresh all panels (only their content)
Definition output.cpp:1993
void scrollAllPanels(wxScrolledWindow *component)
Ask to all panels to scroll as the given component.
Definition output.cpp:2065
virtual ~Component()
Destructor.
Definition output.cpp:138
void refreshAllPanelsWithVirtualLayer()
Refresh all virtual layers.
Definition output.cpp:2044
void clear()
Clear all output.
Definition output.cpp:565
void refreshAllTabs()
Refresh all tabs (but not their content)
Definition output.cpp:2075
Antares::Private::OutputViewerData::Content Content
Content.
Definition output.h:52
static void ConvertVarNameToID(Yuni::String &id, const Yuni::String &name)
Convert a name into an ID.
Definition output.cpp:2229
void copyFrom(const Component &source)
Copy data from another output viewer.
Definition output.cpp:1310
std::vector< Layer * > Vector
Array.
Definition layer.h:37
Definition spotlight-provider.h:36