Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
common.areasummary.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
22#pragma once
23
24#include "../../renderer.h"
25#include "../../../../input/area.h"
26#include "../../../../../application/study.h"
27
28using namespace Yuni;
29
30namespace Antares
31{
32namespace Component
33{
34namespace Datagrid
35{
36namespace Renderer
37{
38// Check on value ...
39
40struct NoCheck
41{
42 template<class T>
43 static bool Validate(const T&)
44 {
45 return true;
46 }
47};
48
50{
51 static bool Validate(uint f)
52 {
53 return (f == 1) || (f == 24) || (f == 168);
54 }
55};
56
58{
59 static bool Validate(uint& f)
60 {
61 if (f > 100)
62 f = 100;
63 return true;
64 }
65};
66
67// Refresh after update ...
69{
70 static void refresh()
71 {
72 OnInspectorRefresh(nullptr);
73 }
74};
75
77{
78 static void refresh()
79 {
80 MarkTheStudyAsModified();
81 OnInspectorRefresh(nullptr);
82 }
83};
84
85// Update value ...
86
87template<class T, class CheckT, class RefreshT>
88bool Update(T& value, const String& str)
89{
90 T v;
91 if (str.to(v))
92 {
93 if (not Math::Equals<T>(value, v) and CheckT::Validate(v))
94 {
95 value = v;
96 RefreshT::refresh();
97 return true;
98 }
99 }
100 return false;
101}
102
103// Single area common cluster summary renderer
104
106{
107public:
109
111
112 virtual int width() const = 0;
113 virtual int height() const = 0;
114
115 virtual wxString columnCaption(int colIndx) const = 0;
116
117 virtual wxString rowCaption(int rowIndx) const = 0;
118
119 virtual wxString cellValue(int x, int y) const = 0;
120
121 virtual double cellNumericValue(int x, int y) const = 0;
122
123 virtual bool cellValue(int x, int y, const Yuni::String& v) = 0;
124
125 virtual void resetColors(int, int, wxColour&, wxColour&) const
126 {
127 // Does nothing
128 }
129
130 virtual IRenderer::CellStyle cellStyle(int col, int row) const;
131
132 virtual uint maxWidthResize() const
133 {
134 return 0;
135 }
136 virtual uint maxHeightResize() const
137 {
138 return 0;
139 }
140
141 virtual bool valid() const
142 {
143 return (pArea != NULL);
144 }
145
146protected:
147 virtual void onAreaChanged(Antares::Data::Area* area);
148 virtual void onStudyClosed() override;
149 void onStudyAreaDelete(Antares::Data::Area* area);
150
151protected:
152 Antares::Data::Area* pArea;
153 wxWindow* pControl;
154 Toolbox::InputSelector::Area* pAreaNotifier;
155
156}; // class CommonClusterSummarySingleArea
157
158} // namespace Renderer
159} // namespace Datagrid
160} // namespace Component
161} // namespace Antares
virtual int width() const =0
The effective width of the grid.
virtual double cellNumericValue(int x, int y) const =0
Get the floating value of a Cell.
virtual uint maxWidthResize() const
The most suitable column count.
Definition common.areasummary.h:132
virtual wxString rowCaption(int rowIndx) const =0
Get the caption of a row.
virtual wxString cellValue(int x, int y) const =0
Get the string representation of a Cell.
virtual wxString columnCaption(int colIndx) const =0
Get the caption of a column.
virtual int height() const =0
The effective height of the grid.
virtual uint maxHeightResize() const
The most suitable column count.
Definition common.areasummary.h:136
virtual bool cellValue(int x, int y, const Yuni::String &v)=0
Try to modify a cell value.
virtual void onStudyClosed() override
Event: the study has been closed.
Definition common.areasummary.cpp:69
Data provider for Datagrids.
Definition renderer.h:53
Definition for a single area.
Definition area.h:52
Visual Component for displaying all available areas (and groups)
Definition area.h:41
Definition common.areasummary.h:41