21 #ifndef __ANTARES_WINDOWS_XCAST_XCAST_HXX__
22 #define __ANTARES_WINDOWS_XCAST_XCAST_HXX__
25 #include <wx/statline.h>
26 #include "../../toolbox/components/datagrid/renderer/area/xcast-k.h"
27 #include "../../toolbox/components/datagrid/renderer/area/xcast-coefficients.h"
28 #include "../../toolbox/components/datagrid/renderer/area/xcast-translation.h"
29 #include "../../toolbox/components/datagrid/renderer/area/xcast-conversion.h"
30 #include "../../toolbox/validator.h"
31 #include "../../application/study.h"
32 #include "../../windows/inspector.h"
33 #include <ui/common/component/panel.h>
35 namespace Antares::Window
37 template<enum Data::TimeSeriesType T>
39 wxPanel(parent, wxID_ANY),
43 assert(pNotifier != NULL);
48 auto* hsizer =
new wxBoxSizer(wxVERTICAL);
49 this->SetSizer(hsizer);
53 notebook->
theme(Component::Notebook::themeLight);
59 pPageGeneral = notebook->add(grid, wxT(
"coeffs"), wxT(
"Coefficients"));
64 pPageDailyProfile = notebook->add(grid, wxT(
"Daily profile"));
69 pPageDailyProfile = notebook->add(grid, wxT(
"Translation"));
71 wxSizer* sizer =
new wxBoxSizer(wxVERTICAL);
72 hsizer->Add(sizer, 0, wxALL | wxEXPAND);
73 hsizer->Add(notebook, 1, wxALL | wxEXPAND);
76 auto* pGridSizer =
new wxFlexGridSizer(2, 0, 0);
82 t =
new wxStaticText(
this,
88 wxFont f = t->GetFont();
89 f.SetWeight(wxFONTWEIGHT_BOLD);
91 pGridSizer->Add(t, 0, wxRIGHT | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
93 edit =
new wxTextCtrl(
this,
99 Toolbox::Validator::Numeric());
100 pInstalledCapacity = edit;
101 pGridSizer->Add(edit, 1, wxALL | wxEXPAND, 1);
105 t =
new wxStaticText(
this,
107 wxT(
"Distribution : "),
111 pGridSizer->Add(t, 0, wxRIGHT | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
119 wxChoice* ch =
new wxChoice(
this, wxID_ANY, wxDefaultPosition, wxSize(-1, 22), list);
121 pGridSizer->Add(ch, 1, wxALL | wxEXPAND, 1);
124 t =
new wxStaticText(
this,
126 wxT(
"Translation : "),
130 pGridSizer->Add(t, 0, wxRIGHT | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
134 list.Add(wxT(
"Do not use"));
135 list.Add(wxT(
"Add BEFORE scaling"));
136 list.Add(wxT(
"Add AFTER scaling"));
137 useTranslation =
new wxChoice(
this, wxID_ANY, wxDefaultPosition, wxSize(-1, 22), list);
138 pGridSizer->Add(useTranslation, 1, wxALL | wxEXPAND, 1);
140 wxBoxSizer* divider =
new wxBoxSizer(wxHORIZONTAL);
142 divider->Add(pGridSizer, 0, wxALL | wxEXPAND, 7);
144 new wxStaticLine(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL),
148 divider->AddSpacer(15);
149 wxBoxSizer* transferSizer =
new wxBoxSizer(wxVERTICAL);
151 useConversion =
new wxCheckBox(
this, wxID_ANY, wxT(
" Use Conversion"));
152 transferSizer->AddSpacer(15);
153 transferSizer->Add(useConversion, 0, wxALL | wxEXPAND);
155 divider->Add(transferSizer, 1, wxALL | wxEXPAND);
157 sizer->Add(divider, 1, wxALL | wxEXPAND);
159 pDistribution->Connect(pDistribution->GetId(),
160 wxEVT_COMMAND_CHOICE_SELECTED,
164 useTranslation->Connect(useTranslation->GetId(),
165 wxEVT_COMMAND_CHOICE_SELECTED,
169 useConversion->Connect(useConversion->GetId(),
170 wxEVT_COMMAND_CHECKBOX_CLICKED,
178 wxSizer* ss =
new wxBoxSizer(wxVERTICAL);
183 ss->Add(grid, 0, wxALL | wxEXPAND);
184 ss->SetItemMinSize(grid, 100, 150);
187 pPageTranslation = notebook->add(panel, wxT(
"Conversion"));
196 pInstalledCapacity->Connect(pInstalledCapacity->GetId(),
197 wxEVT_COMMAND_TEXT_UPDATED,
206 template<enum Data::TimeSeriesType T>
209 ObserverAncestorType::destroyBoundEvents();
212 template<enum Data::TimeSeriesType T>
215 wxChoice* obj = (wxChoice*)evt.GetEventObject();
225 wxStringToString(obj->GetStringSelection(), s);
230 MarkTheStudyAsModified();
231 Window::Inspector::Refresh();
232 if (pGridCoeffs and pNotebook->selected()
233 and pNotebook->selected()->name() == wxT(
"coeffs"))
235 pGridCoeffs->Refresh();
241 template<enum Data::TimeSeriesType T>
242 void XCast<T>::onUpdateConversion(wxCommandEvent& evt)
258 MarkTheStudyAsModified();
259 Window::Inspector::Refresh();
263 template<enum Data::TimeSeriesType T>
264 void XCast<T>::onUpdateTSTranslationUse(wxCommandEvent& evt)
266 wxChoice* obj = (wxChoice*)evt.GetEventObject();
276 wxStringToString(obj->GetStringSelection(), s);
281 MarkTheStudyAsModified();
282 Window::Inspector::Refresh();
287 template<enum Data::TimeSeriesType T>
288 inline void XCast<T>::selectDefaultPage()
292 pPageGeneral->select();
296 template<enum Data::TimeSeriesType T>
297 void XCast<T>::onStudyClosed()
303 template<enum Data::TimeSeriesType T>
304 void XCast<T>::onAreaChanged(
Data::Area* area)
306 using namespace Yuni;
317 pInstalledCapacity->ChangeValue(DoubleToWxString(xcast->
capacity));
321 if (indx < 0 or indx > 5)
325 pDistribution->SetSelection(indx);
333 pInstalledCapacity->ChangeValue(wxT(
"0"));
334 pDistribution->SetSelection(1);
335 useConversion->SetValue(
false);
336 useTranslation->SetSelection(0);
339 template<enum Data::TimeSeriesType T>
340 void XCast<T>::onInstalledCapacityChanged(wxCommandEvent& evt)
347 evt.GetString().ToDouble(&d);
354 if (xcastData and not Yuni::Math::Equals(d, xcastData->
capacity))
357 MarkTheStudyAsModified();
A datagrid with virtual values.
Definition: component.h:84
Definition: xcast-coefficients.h:31
Definition: xcast-conversion.h:31
Definition: xcast-translation.h:31
Page * select(bool force=false)
Select the page.
Definition: notebook.cpp:868
Notebook.
Definition: notebook.h:36
void theme(Theme t)
Set the current theme.
Definition: notebook.h:289
Panel implementation.
Definition: panel.h:34
Definition for a single area.
Definition: area.h:51
Distribution distribution
The probability distribution to use.
Definition: xcast.h:182
double capacity
The installed capacity.
Definition: xcast.h:185
TSTranslationUse useTranslation
How to use the timeseries average.
Definition: xcast.h:179
bool useConversion
True to use the transfer function after the generation of the time-series.
Definition: xcast.h:188
Distribution
All available probability distribution.
Definition: xcast.h:61
@ dtMax
The maximum number of distributions.
Definition: xcast.h:75
@ dtNone
None.
Definition: xcast.h:63
static const char * DistributionToCString(Distribution d)
Convert a distribution into its human readable representation.
Definition: xcast.cpp:71
TSTranslationUse
Definition: xcast.h:85
static Distribution StringToDistribution(AnyString str)
Convert a CString into a probability distribution.
Definition: xcast.cpp:92
XCast(wxWindow *parent, Toolbox::InputSelector::Area *notifier)
Default constructor.
Definition: xcast.hxx:38
virtual ~XCast()
Destructor.
Definition: xcast.hxx:207