Antares Simulator
Power System Simulator
link-property-buttons.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 #pragma once
22 
23 #include <wx/frame.h>
24 #include <wx/sizer.h>
25 #include "yuni/core/event/interfaces.h"
26 #include "../toolbox/components/button.h"
27 #include "antares/study/area/links.h"
28 
29 namespace Antares::Window
30 {
31 // =========================
32 // Abstract link button
33 // =========================
34 class linkButton: public wxFrame
35 {
36 public:
37  virtual void update(Data::AreaLink* link) = 0;
38 
39 protected:
40  Component::Button* getButton() const
41  {
42  return button_;
43  }
44 
45  void setButton(Component::Button* button)
46  {
47  button_ = button;
48  }
49 
50 private:
51  Component::Button* button_ = nullptr;
52 };
53 
54 // ==================================
55 // Abstract menu link button
56 // ==================================
57 class menuLinkButton: public linkButton, public Yuni::IEventObserver<menuLinkButton>
58 {
59 public:
60  static Yuni::Event<void(Antares::Data::AreaLink*)> onSelectionChanges;
61 
63  ~menuLinkButton() override;
64 
65  bool hasNoButton() const
66  {
67  return !getButton();
68  }
69 
70 protected:
71  Data::AreaLink* getCurrentLink() const
72  {
73  return currentLink_;
74  }
75 
76  void setCurrentLink(Data::AreaLink* link)
77  {
78  currentLink_ = link;
79  }
80 
81  virtual void onPopupMenu(Component::Button&, wxMenu& menu, void*) = 0;
82  void bindButtonToPopupMenu() const;
83 
84  void broadCastChange() const;
85  void broadCastChangeOutside() const;
86 
87 private:
88  Data::AreaLink* currentLink_ = nullptr;
89  Yuni::Bind<void(Antares::Component::Button&, wxMenu&, void*)> onPopup_;
90 };
91 
92 // =========================
93 // NTC usage button
94 // =========================
96 {
97 public:
98  ntcUsageButton(wxWindow* parent, wxFlexGridSizer* sizer_flex_grid);
99 
100  void update(Data::AreaLink* link) override;
101 
102 private:
103  void onPopupMenu(Component::Button&, wxMenu& menu, void*) override;
104 
105  void onSelectUseNTC(wxCommandEvent&);
106  void onSelectSetToNull(wxCommandEvent&);
107  void onSelectSetToInfinite(wxCommandEvent&);
108 };
109 
110 // ============================
111 // Hurdle costs usage button
112 // ============================
114 {
115 public:
116  hurdleCostsUsageButton(wxWindow* parent, wxFlexGridSizer* sizer_flex_grid);
117 
118  void update(Data::AreaLink* link) override;
119 
120 private:
121  void onPopupMenu(Component::Button&, wxMenu& menu, void*) override;
122 
123  void onSelectUse(wxCommandEvent&);
124  void onSelectIgnore(wxCommandEvent&);
125 };
126 
127 // =========================
128 // Asset type button
129 // =========================
131 {
132 public:
133  assetTypeButton(wxWindow* parent, wxFlexGridSizer* sizer_flex_grid);
134 
135  void update(Data::AreaLink* link) override;
136 
137 private:
138  void onPopupMenu(Component::Button&, wxMenu& menu, void*) override;
139 
140  void onSelectAC(wxCommandEvent&);
141  void onSelectDC(wxCommandEvent&);
142  void onSelectGas(wxCommandEvent&);
143  void onSelectVirt(wxCommandEvent&);
144  void onSelectOther(wxCommandEvent&);
145 };
146 
147 // =========================
148 // Caption button
149 // =========================
151 {
152 public:
153  captionButton(wxWindow* parent, wxFlexGridSizer* sizer_flex_grid);
154 
155  void update(Data::AreaLink* link) override;
156 
157  void setCaption(const wxString& caption) const
158  {
159  getButton()->caption(caption);
160  }
161 
162 private:
163  void onPopupMenu(Component::Button&, wxMenu& menu, void*) override;
164 
165  void onEditCaption(wxCommandEvent&);
166  void onButtonEditCaption(void*);
167 
168  // Private data members
169  Component::Button* alias_button_ = nullptr;
170  wxBoxSizer* local_horizontal_sizer_ = nullptr;
171  wxStaticText* caption_label_ = nullptr;
172  wxWindow* caption_text_ = nullptr;
173  wxFlexGridSizer* sizer_flex_grid_;
174 };
175 
176 // =========================
177 // Loop flow usage button
178 // =========================
180 {
181 public:
182  loopFlowUsageButton(wxWindow* parent, wxFlexGridSizer* sizer_flex_grid);
183 
184  void update(Data::AreaLink* link) override;
185 };
186 
187 // ============================
188 // Phase shifter usage button
189 // ============================
191 {
192 public:
193  phaseShifterUsageButton(wxWindow* parent, wxFlexGridSizer* sizer_flex_grid);
194 
195  void update(Data::AreaLink* link) override;
196 };
197 
198 } // namespace Antares::Window
Definition: button.h:32
const wxString & caption() const
Get the caption of the button.
Definition: button.hxx:96
Definition: link-property-buttons.h:131
Definition: link-property-buttons.h:151
Definition: link-property-buttons.h:114
Definition: link-property-buttons.h:35
Definition: link-property-buttons.h:180
Definition: link-property-buttons.h:58
Definition: link-property-buttons.h:96
Definition: link-property-buttons.h:191