Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
renderer.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_H__
22#define __ANTARES_TOOLBOX_COMPONENT_DATAGRID_RENDERER_H__
23
24#include <yuni/core/event.h>
25#include <antares/date/date.h>
26#include <wx/colour.h>
27#include "default.h"
28#include <antares/study/study.h>
29
30#ifdef YUNI_OS_MSVC
31// Disable warning C4250, inherits via dominance
32#pragma warning(disable : 4250)
33#endif
34
35namespace Antares
36{
37namespace Component
38{
39namespace Datagrid
40{
41 class VGridHelper;
42namespace Renderer
43{
52class IRenderer : public Yuni::IEventObserver<IRenderer>
53{
54public:
55 enum CellStyle
56 {
57 cellStyleDefault = 0,
58 cellStyleCustom,
59 cellStyleDefaultAlternate,
60 cellStyleDefaultDisabled,
61 cellStyleDefaultAlternateDisabled,
62 cellStyleDefaultCenter,
63 cellStyleDefaultCenterAlternate,
64 cellStyleDefaultCenterDisabled,
65 cellStyleDefaultCenterAlternateDisabled,
66 cellStyleWarning,
67 cellStyleError,
68 cellStyleDisabled,
69 cellStyleAverage,
70 cellStyleSum,
71 cellStyleMinMax,
72 cellStyleConstraintEnabled,
73 cellStyleConstraintDisabled,
74 cellStyleConstraintNoWeight,
75 cellStyleConstraintWeight,
76 cellStyleConstraintWeightCount,
77 cellStyleConstraintOperator,
78 cellStyleConstraintType,
79 cellStyleLayerDisabled,
80 cellStyleFilterYearByYearOn,
81 cellStyleFilterYearByYearOff,
82 cellStyleFilterSynthesisOn,
83 cellStyleFilterSynthesisOff,
84 cellStyleFilterUndefined,
85 cellStyleAdqPatchVirtual,
86 cellStyleAdqPatchOutside,
87 cellStyleAdqPatchInside,
88
89
90 cellStyleMax /* Max items in the list */
91 };
92
93 static const wxChar* CellStyleToCSSClass(CellStyle s);
94 static void CellStyleToCSSClass(CellStyle s, Yuni::String& str);
95
96public:
98
99
102 IRenderer();
104 virtual ~IRenderer();
106
108
109 virtual bool valid() const = 0;
111
113
114
117 virtual int width() const = 0;
118
122 virtual int height() const = 0;
123
129 virtual int internalWidth() const;
135 virtual int internalHeight() const;
137
139
140
143 virtual wxString columnCaption(int colIndx) const = 0;
144
148 virtual wxString rowCaption(int rowIndx) const = 0;
150
152
153
156 virtual wxString asString(int x, int y) const;
160 virtual double asDouble(int x, int y) const;
161
165 virtual wxString cellValue(int x, int y) const = 0;
166
167 void appendCellValue(int x, int y, Yuni::String& s) const;
168
172 virtual double cellNumericValue(int x, int y) const = 0;
173
178 virtual bool cellValue(int x, int y, const Yuni::String& value) = 0;
180
182
183 virtual void resetColors(int x,
184 int y,
185 wxColour& background,
186 wxColour& textForeground) const = 0;
187
189
190 virtual IRenderer::CellStyle cellStyle(int, int y) const;
191 IRenderer::CellStyle cellStyleWithNumericCheck(int x, int y) const;
192
193 virtual wxColour cellBackgroundColor(int, int) const;
194 virtual wxColour cellTextColor(int, int) const;
195
197 virtual wxColour verticalBorderColor(int x, int y) const;
198
200 virtual wxColour horizontalBorderColor(int x, int y) const;
201
203 virtual int cellAlignment(int x, int y) const;
204
206 virtual int columnWidthCustom(int x) const;
208 virtual void hintForColumnWidth(int x, wxString& out) const;
210
214 virtual Date::Precision precision();
215
219 virtual bool ensureDataAreLoaded();
221
223
224
228 virtual uint maxWidthResize() const;
233 virtual uint maxHeightResize() const;
234
238 virtual void resizeMatrixToXColumns(uint /*m*/)
239 {
240 }
241
251 virtual bool onMatrixResize(uint oldX, uint oldY, uint& newX, uint& newY);
252
256 virtual void onMatrixLoad()
257 {
258 }
259
266 virtual bool circularShiftRowsUntilDate(MonthName month, uint daymonth);
268
270
271
272 virtual void onSelectCell(uint, uint)
273 {
274 }
276 virtual void onScroll()
277 {
278 }
280
281 virtual void applyLayerFiltering(size_t layerID, VGridHelper* gridHelper);
282
283public:
285 Yuni::Event<void()> onRefresh;
287 // This property is set by VGridHelper
288 Date::Precision dataGridPrecision;
290 Data::Study::Ptr study;
291
294
295protected:
297 virtual void onStudyClosed();
299 virtual void onStudyLoaded();
300
301}; // class IRenderer
302
303} // namespace Renderer
304} // namespace Datagrid
305} // namespace Component
306} // namespace Antares
307
308#include "renderer.hxx"
309
310#endif // __ANTARES_TOOLBOX_COMPONENT_DATAGRID_RENDERER_H__
Data provider for Datagrids.
Definition renderer.h:53
virtual bool circularShiftRowsUntilDate(MonthName month, uint daymonth)
Rotate all rows until a given date.
Definition renderer.hxx:125
virtual ~IRenderer()
Destructor.
Definition renderer.cpp:173
virtual bool ensureDataAreLoaded()
Make sure all data are effectively loaded.
Definition renderer.hxx:43
Data::Study::Ptr study
Attached study (if any)
Definition renderer.h:290
virtual double asDouble(int x, int y) const
Read a cell as a double.
Definition renderer.hxx:115
virtual int internalHeight() const
The real height of the matrix in memory.
Definition renderer.hxx:38
virtual double cellNumericValue(int x, int y) const =0
Get the floating value of a Cell.
virtual wxColour verticalBorderColor(int x, int y) const
Get the color of the vertical right border.
Definition renderer.hxx:75
virtual bool cellValue(int x, int y, const Yuni::String &value)=0
Try to modify a cell value.
virtual void onMatrixLoad()
Event triggered right after a matrix was loaded by the renderer.
Definition renderer.h:256
virtual wxString cellValue(int x, int y) const =0
Get the string representation of a Cell.
virtual uint maxWidthResize() const
The most suitable column count.
Definition renderer.hxx:85
virtual void resizeMatrixToXColumns(uint)
Resize the internal matrix with a given col count.
Definition renderer.h:238
virtual wxString asString(int x, int y) const
Read a cell as a string.
Definition renderer.hxx:110
virtual void hintForColumnWidth(int x, wxString &out) const
String to use.
Definition renderer.hxx:105
virtual wxString rowCaption(int rowIndx) const =0
Get the caption of a row.
virtual int internalWidth() const
The real width of the matrix in memory.
Definition renderer.hxx:33
Yuni::Event< void()> onRefresh
Event on refresh.
Definition renderer.h:285
virtual bool onMatrixResize(uint oldX, uint oldY, uint &newX, uint &newY)
Event trigerred before resizing a matrix.
Definition renderer.hxx:70
virtual int width() const =0
The effective width of the grid.
virtual void onStudyClosed()
Event: the study has been closed.
Definition renderer.cpp:184
virtual int cellAlignment(int x, int y) const
Get the alignment of a cell (-1: left, 0: center, +1: right)
Definition renderer.hxx:95
virtual void onScroll()
A scroll event has been triggered.
Definition renderer.h:276
virtual Date::Precision precision()
Time Precision.
Definition renderer.hxx:120
virtual int height() const =0
The effective height of the grid.
virtual wxString columnCaption(int colIndx) const =0
Get the caption of a column.
virtual wxColour horizontalBorderColor(int x, int y) const
Get the color of the horizontal bottom border.
Definition renderer.hxx:80
virtual void onStudyLoaded()
Event: the study has been loaded.
Definition renderer.cpp:179
virtual void onSelectCell(uint, uint)
A cell has been selected.
Definition renderer.h:272
bool invalidate
True to invalidate the current data and force a refresh for the next call to DBGrid:onDraw.
Definition renderer.h:293
IRenderer()
Default constructor.
Definition renderer.cpp:166
Date::Precision dataGridPrecision
The real precision asked by the datagrid.
Definition renderer.h:288
virtual uint maxHeightResize() const
The most suitable column count.
Definition renderer.hxx:90
virtual int columnWidthCustom(int x) const
Get how the a column must resize (0: auto, >0: specific width, <0: use custom string)
Definition renderer.hxx:100
Wrapper between a wxGridTableBase and a renderer
Definition gridhelper.h:47