Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
link-property-buttons.h
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#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
29namespace Antares
30{
31namespace Window
32{
33// =========================
34// Abstract link button
35// =========================
36class linkButton : public wxFrame
37{
38public:
39 virtual void update(Data::AreaLink* link) = 0;
40
41protected:
42 Component::Button* getButton() const
43 {
44 return button_;
45 }
46 void setButton(Component::Button* button)
47 {
48 button_ = button;
49 }
50
51private:
52 Component::Button* button_ = nullptr;
53};
54
55// ==================================
56// Abstract menu link button
57// ==================================
58class menuLinkButton : public linkButton, public Yuni::IEventObserver<menuLinkButton>
59{
60public:
61 static Yuni::Event<void(Antares::Data::AreaLink*)> onSelectionChanges;
62
64 ~menuLinkButton() override;
65
66 bool hasNoButton() const
67 {
68 return !getButton();
69 }
70
71protected:
72 Data::AreaLink* getCurrentLink() const
73 {
74 return currentLink_;
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
87private:
88 Data::AreaLink* currentLink_ = nullptr;
89 Yuni::Bind<void(Antares::Component::Button&, wxMenu&, void*)> onPopup_;
90};
91
92// =========================
93// NTC usage button
94// =========================
96{
97public:
98 ntcUsageButton(wxWindow* parent, wxFlexGridSizer* sizer_flex_grid);
99
100 void update(Data::AreaLink* link) override;
101
102private:
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{
115public:
116 hurdleCostsUsageButton(wxWindow* parent, wxFlexGridSizer* sizer_flex_grid);
117
118 void update(Data::AreaLink* link) override;
119
120private:
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{
132public:
133 assetTypeButton(wxWindow* parent, wxFlexGridSizer* sizer_flex_grid);
134
135 void update(Data::AreaLink* link) override;
136
137private:
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{
152public:
153 captionButton(wxWindow* parent, wxFlexGridSizer* sizer_flex_grid);
154
155 void update(Data::AreaLink* link) override;
156 void setCaption(const wxString& caption) const
157 {
158 getButton()->caption(caption);
159 }
160
161private:
162 void onPopupMenu(Component::Button&, wxMenu& menu, void*) override;
163
164 void onEditCaption(wxCommandEvent&);
165 void onButtonEditCaption(void*);
166
167 // Private data members
168 Component::Button* alias_button_ = nullptr;
169 wxBoxSizer* local_horizontal_sizer_ = nullptr;
170 wxStaticText* caption_label_ = nullptr;
171 wxWindow* caption_text_ = nullptr;
172 wxFlexGridSizer* sizer_flex_grid_;
173};
174
175// =========================
176// Loop flow usage button
177// =========================
179{
180public:
181 loopFlowUsageButton(wxWindow* parent, wxFlexGridSizer* sizer_flex_grid);
182
183 void update(Data::AreaLink* link) override;
184};
185
186// ============================
187// Phase shifter usage button
188// ============================
190{
191public:
192 phaseShifterUsageButton(wxWindow* parent, wxFlexGridSizer* sizer_flex_grid);
193
194 void update(Data::AreaLink* link) override;
195};
196
197} // namespace Window
198} // namespace Antares
Definition button.h:34
const wxString & caption() const
Get the caption of the button.
Definition button.hxx:92
Definition link-property-buttons.h:131
Definition link-property-buttons.h:151
Definition link-property-buttons.h:114
Definition link-property-buttons.h:37
Definition link-property-buttons.h:179
Definition link-property-buttons.h:59
Definition link-property-buttons.h:96
Definition link-property-buttons.h:190