Antares Simulator
Power System Simulator
panel.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_PANEL_PANEL_H__
22 #define __ANTARES_WINDOWS_OUTPUT_PANEL_PANEL_H__
23 
24 #include <ui/common/component/panel.h>
25 #include "../fwd.h"
26 #include <vector>
27 #include <wx/sizer.h>
28 #include <wx/statbmp.h>
29 #include <antares/array/matrix.h>
30 #include <yuni/core/event.h>
31 
32 #include <mutex>
33 #include <memory>
34 #include <atomic>
35 
36 namespace Antares::Private::OutputViewerData
37 {
38 class Panel final: public Antares::Component::Panel
39 {
40 public:
42  using Vector = std::vector<Panel*>;
47 
50 
51  class IData
52  {
53  public:
54  IData()
55  {
56  }
57 
58  virtual ~IData()
59  {
60  }
61  };
62 
63 public:
65 
66 
69  Panel(OutputViewerComponent* component, wxWindow* parent);
71  virtual ~Panel();
73 
75 
76  void index(uint i);
79  uint index() const;
81 
83 
84  void layer(Layer* newLayer, bool forceUpdate = false);
87  const Layer* layer() const;
89  Layer* layer();
91 
93 
94  const Yuni::String& filename() const;
97 
99 
100 
103  void forceRefresh();
105 
107 
108 
111  void message(const wxString& msg, const char* image = NULL);
112 
113  void messageMergeYbY();
115 
116  void loadVirtualLayer();
117  void loadDataFromFile();
118  void loadDataFromMatrix(MatrixType* matrix);
119  void clearAllComponents();
120 
121 private:
122  void onProceed(void*);
123  void runMerge();
124  void executeAggregator();
125  void noData();
126 
127 private:
129  OutputViewerComponent* pComponent;
131  Layer* pLayer;
133  uint pIndex;
134 
136  wxSizer* pSizer;
138  wxWindow* pLabelMessage;
139  wxStaticBitmap* pIconMessage;
140  wxWindow* pButton;
141  bool pShouldRebuildMessage;
142 
143  std::mutex pMutex;
145  IData* pData;
147  Yuni::String pFilename;
148 
150  // This method is often an async call
151  static std::atomic<int> pPanelsInCallingLoadDataFromFile;
152 
153 }; // class Panel
154 
163 std::shared_ptr<std::mutex> ProvideLockingForFileLocking(const YString& filename);
164 
168 void ClearAllMutexForFileLocking();
169 
170 } // namespace Antares::Private::OutputViewerData
171 
172 #include "panel.hxx"
173 
174 #endif // __ANTARES_WINDOWS_OUTPUT_PANEL_PANEL_H__
Panel implementation.
Definition: panel.h:34
A n-by-n matrix.
Definition: matrix.h:44
const Yuni::String & filename() const
Get the filename currently used (empty if the layer is virtual)
Definition: panel.hxx:41
void message(const wxString &msg, const char *image=NULL)
Replace the whole panel by a message with an icon.
Definition: panel.cpp:304
std::vector< Panel * > Vector
Vector.
Definition: panel.h:42
void forceRefresh()
Force the GUI refresh.
Definition: panel.cpp:150
const Layer * layer() const
Get the attached layer (const)
Definition: panel.hxx:26
virtual ~Panel()
Destructor.
Definition: panel.cpp:107
uint index() const
Get the index.
Definition: panel.hxx:36
Panel(OutputViewerComponent *component, wxWindow *parent)
Constructor.
Definition: panel.cpp:74
Component: Viewer for simulation results.
Definition: output.h:45