Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
areas.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_TOOLBOX_COMPONENT_DATAGRID_RENDERER_AREA_CORRELATION_H__
22#define __ANTARES_TOOLBOX_COMPONENT_DATAGRID_RENDERER_AREA_CORRELATION_H__
23
24#include "../../renderer.h"
25#include <antares/study/study.h>
26#include <mutex>
27#include <map>
28#include <yuni/core/bind.h>
29#include <yuni/core/event.h>
30
31namespace Antares
32{
33namespace Component
34{
35namespace Datagrid
36{
37namespace Renderer
38{
39namespace Analyzer
40{
41class Areas final : public virtual Renderer::IRenderer
42{
43public:
45 using Map = std::map<Yuni::String, Yuni::String>;
46 class Record final
47 {
48 public:
49 enum Status
50 {
51 stWaiting,
52 stNotFound,
53 stReady,
54 stError,
55 };
56 class Vector final
57 {
58 public:
59 using iterator = std::vector<Record>::iterator;
60 using const_iterator = std::vector<Record>::const_iterator;
61
62 public:
63 size_t size() const
64 {
65 return array.size();
66 }
67
68 bool empty() const
69 {
70 return array.empty();
71 }
72
73 public:
74 mutable std::mutex mutex;
75 std::vector<Record> array;
76 bool canRunAnalyzer;
77 };
78
79 public:
81 bool enabled;
83 Status status;
87 wxString wxAreaName;
89 Yuni::String fileToSearch;
90
95
97 uint mWidth, mHeight;
98 };
99
100public:
102
103
106 Areas();
108 virtual ~Areas();
110
111 void mapFile(Map* newMap);
112 Map* mapFile();
113
114 void resetStatus(Record::Status status, bool invalidateSize = true);
115 void resetStatusWaiting(bool invalidateSize = true);
116
117 Record::Vector& record()
118 {
119 return pRecord;
120 }
121
122 void onBeforeUpdate(const Yuni::Bind<void(int, int)>& b)
123 {
124 pOnBeforeUpdate = b;
125 }
126 void onAfterUpdate(const Yuni::Bind<void(int, int)>& b)
127 {
128 pOnAfterUpdate = b;
129 }
130
131 virtual int width() const
132 {
133 return 5;
134 }
135
136 virtual int height() const
137 {
138 return (int)pRecord.size();
139 }
140
141 virtual wxString columnCaption(int colIndx) const;
142
143 virtual wxString rowCaption(int rowIndx) const;
144
145 virtual wxString cellValue(int, int) const;
146
147 virtual double cellNumericValue(int, int) const;
148
149 virtual bool cellValue(int x, int y, const Yuni::String& value);
150
151 virtual void resetColors(int, int, wxColour&, wxColour&) const
152 { /*Do nothing*/
153 }
154
155 virtual IRenderer::CellStyle cellStyle(int col, int row) const;
156 virtual wxColour cellBackgroundColor(int, int) const;
157 virtual wxColour cellTextColor(int, int) const;
158
159 virtual bool valid() const;
160
161 void reloadDistributionLawsFromStudy(Data::TimeSeriesType ts);
162
166 void initializeFromStudy();
167
168protected:
169 virtual void onUpdate()
170 {
171 }
172
173private:
174 Map* pMapFile;
175 Record::Vector pRecord;
176 Yuni::Bind<void(int, int)> pOnBeforeUpdate;
177 Yuni::Bind<void(int, int)> pOnAfterUpdate;
178
179}; // class Areas
180
181} // namespace Analyzer
182} // namespace Renderer
183} // namespace Datagrid
184} // namespace Component
185} // namespace Antares
186
187#endif // __ANTARES_TOOLBOX_COMPONENT_DATAGRID_RENDERER_AREA_CORRELATION_H__
Data::XCast::Distribution distribution
Distribution law.
Definition areas.h:92
bool enabled
Get if the item is enabled.
Definition areas.h:81
uint areaIndex
Index of the area in the study.
Definition areas.h:85
Yuni::String fileToSearch
The file to search in the set.
Definition areas.h:89
uint mWidth
Width and height of the matrix.
Definition areas.h:97
wxString wxAreaName
Name of the area (wx)
Definition areas.h:87
void initializeFromStudy()
Reset internal variables according the current study.
Definition areas.cpp:43
virtual wxString rowCaption(int rowIndx) const
Get the caption of a row.
Definition areas.cpp:146
virtual double cellNumericValue(int, int) const
Get the floating value of a Cell.
Definition areas.cpp:225
virtual ~Areas()
Destructor.
Definition areas.cpp:129
virtual wxString cellValue(int, int) const
Get the string representation of a Cell.
Definition areas.cpp:190
Areas()
Constructor.
Definition areas.cpp:39
virtual bool cellValue(int x, int y, const Yuni::String &value)
Try to modify a cell value.
std::map< Yuni::String, Yuni::String > Map
Map of string.
Definition areas.h:45
virtual int height() const
The effective height of the grid.
Definition areas.h:136
virtual int width() const
The effective width of the grid.
Definition areas.h:131
virtual wxString columnCaption(int colIndx) const
Get the caption of a column.
Definition areas.cpp:134
Data provider for Datagrids.
Definition renderer.h:53
Distribution
All available probability distribution.
Definition xcast.h:61