Antares Simulator
Power System Simulator
output.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_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 
39 namespace Antares::Window::OutputViewer
40 {
44 class Component: public Antares::Component::Panel, public Yuni::IEventObserver<Component>
45 {
46 public:
49 
50 public:
54  static void ConvertVarNameToID(Yuni::String& id, const Yuni::String& name);
55 
56 public:
58 
59 
62  Component(wxWindow* parent, bool parentIsStandaloneWindow = false);
64  virtual ~Component();
66 
70  void clear();
71 
75  void update(const Data::Output::List& list, const Data::Output::Ptr& selection);
76 
77  void updateLayerList();
78 
82  void copyFrom(const Component& source);
83 
87  void scrollAllPanels(wxScrolledWindow* component);
88 
89  void selectCellAllPanels(uint x, uint y);
90 
92  void refreshAllTabs();
94  void refreshAllPanels();
97 
98  void refreshPanel(uint index);
99 
100 private:
101  class Tab
102  {
103  public:
105  using Ptr = std::shared_ptr<Tab>;
107  using Vector = std::vector<Ptr>;
108 
109  public:
111 
112  explicit Tab(Component& comparent);
115  ~Tab();
117 
118  void updateAreaOrLinkName(SelectionType selection, const Yuni::String& text);
119 
120  public:
122  Component& component;
124  Antares::Component::Panel* support;
126  Antares::Component::Button* btnOutput;
128  Antares::Component::Button* btnCustomSelection;
132  wxSizer* btnSizer;
133  };
134 
135 private:
137  void outputSelectionsClear();
138 
140  void createAllControlsIfNeeded();
142  void onStudyClosed();
144  void internalUpdate();
146  void backToInputData(void*);
148  void allYearsOrYearByYearSelector(Antares::Component::Button&, wxMenu& menu, void*);
150  void dropDownAllVariables(Antares::Component::Button&, wxMenu&, void*);
152  void incrementYearByYear(void*);
154  void decrementYearByYear(void*);
156  void goToASpecificYear(void*);
157 
159  void openNewWindow(void*);
161  void updateFromExternalEvent(const Data::Output::List&, const Data::Output::Ptr selection);
162 
164  void onDropDownOutputs(Antares::Component::Button&, wxMenu& menu, void*);
165  void onDropDownComparison(Antares::Component::Button&, wxMenu& menu, void*);
166  void onDropDownDetachMenu(Antares::Component::Button&, wxMenu& menu, void*);
167 
169  void selectAnotherOutput(const Data::Output::Ptr& selectedOutput);
171  void removeOutput(Layer* layer);
172 
174  void onDetachCurrentLayer(wxCommandEvent& evt);
175 
177  uint outputSelectionsAdd(Data::Output::Ptr output);
179  void createNewVirtualLayer(LayerType type);
180 
182  void onSelectDataLevel(void*);
184  void onSelectTimeLevel(void*);
185 
187  void onToggleSidebar(void*);
188 
190  const char* imageForLayerPlaceOrder(const Layer* so) const;
191  const char* imageForLayerPlaceOrder(const Data::Output::Ptr& so) const;
196  int imageIndexForOutput(const Data::Output::Ptr& output) const;
198  void createSubMenuForSwitchingOrders(wxMenu* menu, const Layer* currentLayer) const;
200  void rebuildIndexes();
201 
203  void refreshCurrentYear();
204 
208  void displayMiniFrame(wxWindow* parent,
209  Antares::Component::Spotlight::IProvider::Ptr provider,
210  int width = 340,
211  bool searchInput = true,
212  bool groups = true);
213 
215  void bugFixResetSashPosition();
216 
218  void mergeOutputs();
220  void stopMerging();
221 
223  void treeDataClear();
225  void treeDataWaiting();
227  void treeDataUpdate();
229  void treeDataUpdateWL(const Content& content);
231  bool checkAreaIsCommonToAllOutputs(const Data::AreaName& name);
233  bool checkLinkIsCommonToAllOutputs(const Data::AreaLinkName& name);
235  void checkYearByYearMode();
237  void noSimulationData();
239  void updateAreaOrLinkName();
240 
242  void updateGlobalSelection();
243 
244  void updateButtonView();
245 
249  void emptyCache();
250 
254  void closeSubFrames();
255 
256 private:
258  using Button = Antares::Component::Button;
260  using WxPanelVector = std::vector<wxPanel*>;
261 
262 private:
264  Data::Output::List pOutputs;
266  Layer::Vector pSelections;
268  Yuni::String pCurrentAreaOrLink;
270  SelectionType pCurrentSelectionType;
272  LevelOfDetails pCurrentLOD;
274  uint pCurrentYear;
276  uint pYearsLimits[2];
278  bool pHasYearByYear;
280  bool pHasConcatenedDataset;
282  Yuni::String pCurrentVariable;
284  Yuni::String pCurrentVariableID;
285 
287  Antares::Private::OutputViewerData::ThermalNameSetPerArea* pCurrentClusters;
288 
290  Tab::Vector pTabs;
292  WxPanelVector pBtnPanelAllOutputs;
294  wxSizer* pSizerForBtnOutputs;
296  wxWindow* pWindowForBtnOutputs;
300  wxSizer* pSizerForPanelOutputs;
302  wxWindow* pWindowForPanelOutputs;
304  Yuni::Event<void(wxScrolledWindow*)> pOnScrollAllPanels;
306  Yuni::Event<void(uint, uint)> pOnSelectCellAllPanels;
307 
309  Button* pBtnAllYears;
310 
312  wxSizer* pSizerYearsToolbar;
314  wxSizer* pSizerYearByYearToolbar;
316  wxSizer* pSizerVariables;
317 
318  wxSizer* pSizerToolbar;
319 
321  Layer* pCurrentLayerForMenu;
323  wxWindow* pLblAreaOrLinkName;
324 
326  Antares::Component::Spotlight* pSpotlight;
327 
329  bool pControlsAlreadyCreated;
330 
332  wxSplitterWindow* pSplitter;
333  wxWindow* pSplitterWindow1;
334  wxWindow* pSplitterWindow2;
336  bool pSidebarCollapsed;
337  int pOldSidebarWidth;
338  Button* pBtnExpandCollapseSidebar;
339 
341  wxWindow* pParentWindow;
342 
344  wxWindow* pLabelItemName;
346  Button* pBtnValues;
348  Button* pBtnDetails;
350  Button* pBtnDetailsRes;
352  Button* pBtnID;
353 
355  Button* pBtnHourly;
357  Button* pBtnDaily;
359  Button* pBtnWeekly;
361  Button* pBtnMonthly;
363  Button* pBtnAnnual;
364 
366  Button* pBtnCurrentYearNumber;
368  Button* pBtnVariables;
369 
371 
372  std::mutex pMutex;
374  Antares::Private::OutputViewerData::JobVector pJobs;
376  // The access to this variable must be protected with pMutex
377  // This variable is used to build the list of areas / links once
378  // prepared.
379  Antares::Private::OutputViewerData::ContentMap pAlreadyPreparedContents;
381  // The access to this variable must be protected with pMutex
382  uint pJobsRemaining;
384 
386  bool pOpenedInANewWindow;
387 
389  bool pASelectionHasAlreadyBeenMade;
390 
391  // friends !
394  friend class Tab;
395  friend class SpotlightProvider;
397  friend class SpotlightProviderMCAll;
398  friend class Provider::Variables;
399  friend class Provider::Outputs;
400  friend class Provider::Comparison;
401 
402 }; // class Component
403 
404 } // namespace Antares::Window::OutputViewer
405 
406 #endif // __ANTARES_WINDOWS_OUTPUT_OUTPUT_H__
Definition: button.h:32
Panel implementation.
Definition: panel.h:34
Definition: spotlight.h:38
std::list< Ptr > List
List.
Definition: output.h:43
std::shared_ptr< Output > Ptr
Smartptr.
Definition: output.h:41
std::vector< Panel * > Vector
Vector.
Definition: panel.h:42
Component: Viewer for simulation results.
Definition: output.h:45
void update(const Data::Output::List &list, const Data::Output::Ptr &selection)
Update the list of all outputs.
Definition: output.cpp:685
void refreshAllPanels()
Refresh all panels (only their content)
Definition: output.cpp:2213
void scrollAllPanels(wxScrolledWindow *component)
Ask to all panels to scroll as the given component.
Definition: output.cpp:2291
virtual ~Component()
Destructor.
Definition: output.cpp:136
void refreshAllPanelsWithVirtualLayer()
Refresh all virtual layers.
Definition: output.cpp:2268
void clear()
Clear all output.
Definition: output.cpp:608
void refreshAllTabs()
Refresh all tabs (but not their content)
Definition: output.cpp:2301
Antares::Private::OutputViewerData::Content Content
Content.
Definition: output.h:48
Component(wxWindow *parent, bool parentIsStandaloneWindow=false)
Constructor.
Definition: output.cpp:82
static void ConvertVarNameToID(Yuni::String &id, const Yuni::String &name)
Convert a name into an ID.
Definition: output.cpp:2486
void copyFrom(const Component &source)
Copy data from another output viewer.
Definition: output.cpp:1436
std::vector< Layer * > Vector
Array.
Definition: layer.h:33
Definition: output-comparison.h:31
Definition: spotlight-provider.h:160
Definition: spotlight-provider.h:32