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