Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
xcast-conversion.hxx
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_XCAST_CONVERTION_HXX__
22#define __ANTARES_TOOLBOX_COMPONENT_DATAGRID_RENDERER_AREA_XCAST_CONVERTION_HXX__
23
24#include <antares/study/xcast/xcast.h>
25
26namespace Antares
27{
28namespace Component
29{
30namespace Datagrid
31{
32namespace Renderer
33{
34template<enum Data::TimeSeriesType T>
36 MatrixAncestorType(control), Renderer::ARendererArea(control, notifier)
37{
38}
39
40template<enum Data::TimeSeriesType T>
42{
43 destroyBoundEvents();
44}
45
46template<enum Data::TimeSeriesType T>
47inline wxString XCastConversion<T>::columnCaption(int colIndx) const
48{
49 return wxString() << wxT(" point ") << (colIndx + 1) << wxT(' ');
50}
51
52template<enum Data::TimeSeriesType T>
53inline wxString XCastConversion<T>::cellValue(int x, int y) const
54{
55 return MatrixAncestorType::cellValue(x + 1, y);
56}
57
58template<enum Data::TimeSeriesType T>
59double XCastConversion<T>::cellNumericValue(int x, int y) const
60{
61 return MatrixAncestorType::cellNumericValue(x + 1, y);
62}
63
64template<enum Data::TimeSeriesType T>
65inline bool XCastConversion<T>::cellValue(int x, int y, const Yuni::String& value)
66{
67 return MatrixAncestorType::cellValue(x + 1, y, value);
68}
69
70template<enum Data::TimeSeriesType T>
72{
73 if (area)
74 {
75 auto* xcastData = area->xcastData<T>();
76 this->matrix(&(xcastData->conversion));
77 }
78 else
79 this->matrix(NULL);
80 Renderer::ARendererArea::internalAreaChanged(area);
81}
82
83template<enum Data::TimeSeriesType T>
84IRenderer::CellStyle XCastConversion<T>::cellStyle(int col, int row) const
85{
86 double b = MatrixAncestorType::cellNumericValue(col + 1, 0);
87 return (Yuni::Math::Abs(b) >= 1.0e+19)
88 || (col > 0 && b <= MatrixAncestorType::cellNumericValue(col, 0))
89 ? cellStyleError
90 : MatrixAncestorType::cellStyle(col, row);
91}
92
93template<enum Data::TimeSeriesType T>
94wxString XCastConversion<T>::rowCaption(int rowIndx) const
95{
96 return (rowIndx == 0) ? wxT("IN") : wxT("OUT");
97}
98
99template<enum Data::TimeSeriesType T>
100bool XCastConversion<T>::onMatrixResize(uint, uint, uint& newX, uint&)
101{
103 return false;
104 auto& matrix = (*pMatrix);
105 matrix[matrix.width - 1][0] = 0;
106 matrix[matrix.width - 1][1] = 0;
107 matrix.resizeWithoutDataLost(newX + 2, 2);
108 matrix[matrix.width - 1][0] = +std::numeric_limits<float>::max();
109 matrix.markAsModified();
110 MarkTheStudyAsModified();
111 return false;
112}
113
114template<enum Data::TimeSeriesType T>
116{
117 auto& matrix = *pMatrix;
118 if (matrix.height != 2)
119 {
120 // It may happen when the file is not loaded
121 matrix.reset(3, 2);
122 matrix.markAsModified();
123 MarkTheStudyAsModified();
124 }
125 if (matrix.width >= 3 && matrix.width <= Data::XCast::conversionMaxPoints)
126 {
127 matrix[0][0] = -std::numeric_limits<float>::max();
128 matrix[0][1] = matrix[1][1];
129 matrix[matrix.width - 1][0] = +std::numeric_limits<float>::max();
130 matrix[matrix.width - 1][1] = matrix[matrix.width - 2][1];
131 }
132 else
133 {
134 matrix.reset(3, 2);
135 matrix[0][0] = -std::numeric_limits<float>::max();
136 matrix[0][1] = 0.f;
137 matrix[1][0] = 0.f;
138 matrix[1][1] = 0.f;
139 matrix[2][0] = +std::numeric_limits<float>::max();
140 matrix[2][1] = 0.f;
141 }
142}
143
144template<enum Data::TimeSeriesType T>
150
151template<enum Data::TimeSeriesType T>
157
158} // namespace Renderer
159} // namespace Datagrid
160} // namespace Component
161} // namespace Antares
162
163#endif // __ANTARES_TOOLBOX_COMPONENT_DATAGRID_RENDERER_AREA_XCAST_CONVERTION_HXX__
virtual void onStudyClosed() override
The study has been closed.
Definition area.cpp:83
virtual void onStudyLoaded() override
Event: the study has been loaded.
Definition area.cpp:89
virtual void onStudyLoaded() override
Event: the study has been loaded.
Definition matrix.hxx:244
virtual void onStudyClosed() override
Event: the study has been closed.
Definition matrix.hxx:238
virtual ~XCastConversion()
Destructor.
Definition xcast-conversion.hxx:41
virtual wxString rowCaption(int rowIndx) const
Get the row caption.
Definition xcast-conversion.hxx:94
virtual void onMatrixLoad()
Event triggered right after a matrix was loaded by the renderer.
Definition xcast-conversion.hxx:115
virtual void onStudyClosed() override
Event: the study has been closed.
Definition xcast-conversion.hxx:145
virtual void onStudyLoaded() override
Event: the study has been loaded.
Definition xcast-conversion.hxx:152
virtual double cellNumericValue(int x, int y) const
Get the value of a cell.
Definition xcast-conversion.hxx:59
virtual wxString columnCaption(int colIndx) const
Get the column caption.
Definition xcast-conversion.hxx:47
virtual wxString cellValue(int x, int y) const
Get the value of a cell.
Definition xcast-conversion.hxx:53
XCastConversion(wxWindow *control, Toolbox::InputSelector::Area *notifier)
Constructor.
Definition xcast-conversion.hxx:35
virtual bool onMatrixResize(uint oldX, uint oldY, uint &newX, uint &newY)
Event trigerred before resizing a matrix.
Definition xcast-conversion.hxx:100
Definition for a single area.
Definition area.h:52
@ conversionMaxPoints
Hard limit for the number of points of the transfer function.
Definition xcast.h:81
Visual Component for displaying all available areas (and groups)
Definition area.h:41