Antares Simulator
Power System Simulator
constraintsbuilder.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 #ifndef __ANTARES_APPLICATION_WINDOW_CONSTRAINTSBUILDER_H__
22 #define __ANTARES_APPLICATION_WINDOW_CONSTRAINTSBUILDER_H__
23 
24 #include <memory>
25 #include <ui/common/component/spotlight.h>
26 #include <wx/checkbox.h>
27 #include <wx/dialog.h>
28 #include <wx/radiobut.h>
29 #include <wx/sizer.h>
30 #include <wx/timer.h>
31 
32 #include <yuni/core/event.h>
33 #include <yuni/thread/thread.h>
34 
35 #include "antares/solver/constraints-builder/cbuilder.h"
36 
37 #include "../../toolbox/components/datagrid/component.h"
38 #include "../../toolbox/components/datagrid/renderer/constraintsbuilder/links.h"
39 
40 namespace Antares::Window
41 {
42 class ConstraintsBuilderWizard final: public wxDialog
43 {
44 public:
50  using FileMappingPtr = std::shared_ptr<FileMapping>;
51 
52  enum IDs
53  {
54  mnIDCancel = wxID_HIGHEST + 1,
55  mnIDPrefixMesh,
56  mnIDPrefixGrid,
57  mnIDPrefixNetwork,
58  mnIDAutoClean,
59  mnIDUpdateInfo,
60  mnIDUpdateFileMapping,
61  mnIDGridUpdate
62  };
63 
64 public:
66 
67 
70  ConstraintsBuilderWizard(wxFrame* parent);
72  virtual ~ConstraintsBuilderWizard();
73  void onIncludeLoopFlow(wxCommandEvent& evt);
74  void onUsePhaseShift(wxCommandEvent& evt);
75  void onUpdateLinesStatus(void*);
76  void onCheckNodalLoopFlow(wxCommandEvent& evt);
77  void onUpdateInfiniteValue(wxCommandEvent& evt);
79 
80  void fileMapping(FileMappingPtr m);
81 
85  void refreshGrid();
86 
90  bool saveToFile(const Yuni::String& filename) const;
91 
92  const Yuni::String& cBuilderInfoFile() const
93  {
94  return pInfoFilename;
95  }
96 
97  void cBuilderInfoFile(const Yuni::String& f)
98  {
99  pInfoFilename = f;
100  }
101 
102  void beforeUpdate(int, int);
103  void afterUpdate(int, int);
104 
105 private:
106  void onCancel(void*);
107  void onBuild(void*);
108  void onDelete(void*);
109 
110  void onPrefix(Component::Button&, wxMenu& menu, void*);
111  void evtPrefixChanged(wxCommandEvent& evt);
112  void enableAll(bool v);
113 
114  void gridAppend(wxFlexGridSizer& sizer,
115  const wxString& title,
116  const wxString& key,
117  wxWindow* value,
118  bool bold = false);
119 
120  void updateBeginningHourLabel(wxEvent& evt);
121 
122  void updateEndHourLabel(wxEvent& evt);
123 
124 private:
125  wxStaticText* mapName;
126  wxStaticText* startingHourLabel;
127  wxStaticText* endHourLabel;
128  wxTextCtrl* startingHourCtrl;
129  wxTextCtrl* endHourCtrl;
130  wxSizer* startingHourSizer;
131  wxSizer* endHourSizer;
132  wxFlexGridSizer* pFlexSizer;
133 
134  wxCheckBox* pIncludeLoopFlow;
135  wxCheckBox* pIncludePhaseShifts;
136  wxCheckBox* pCheckNodalLoopFlow;
137  wxTextCtrl* pInfiniteValue;
138 
139  Yuni::String pInfoFilename;
140 
141  wxButton* pBtnDelete;
142  wxButton* pBtnBuild;
143  Component::Button* pBtnPrefix;
144  wxTimer* pProceedTimer;
145 
147 
148  wxRadioButton* pPrefixMesh;
149  wxRadioButton* pPrefixGrid;
150  wxRadioButton* pPrefixNetwork;
151 
152  bool pDelete;
153  wxStaticText* pTextDelete;
154 
155  FileMappingPtr pFileMapping;
156 
158  RendererType* pRenderer;
159 
160  CBuilder* pCBuilder;
161 
162  DECLARE_EVENT_TABLE()
163 
164 }; // class ConstraintsBuilderWizard
165 
166 } // namespace Antares::Window
167 
168 #endif // __ANTARES_APPLICATION_WINDOW_CONSTRAINTSBUILDER_H__
Definition: cbuilder.h:218
Definition: button.h:32
A datagrid with virtual values.
Definition: component.h:84
Definition: constraintsbuilder.h:43
ConstraintsBuilderWizard(wxFrame *parent)
Default constructor, with a parent frame.
Definition: constraintsbuilder.cpp:74
bool saveToFile(const Yuni::String &filename) const
Export all infos into an INI file.
Definition: constraintsbuilder.cpp:718
Component::Datagrid::Renderer::ConstraintsBuilder::Links::Map FileMapping
File mapping.
Definition: constraintsbuilder.h:46
virtual ~ConstraintsBuilderWizard()
Destructor.
Definition: constraintsbuilder.cpp:462
std::shared_ptr< FileMapping > FileMappingPtr
Smartptr for file mapping.
Definition: constraintsbuilder.h:50
void refreshGrid()
Force the refresh of the grid.