Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
component.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#ifndef __ANTARES_TOOLBOX_MAP_COMPONENT_H__
22#define __ANTARES_TOOLBOX_MAP_COMPONENT_H__
23
24#include <antares/study/study.h>
25#include "control.h"
26#include <wx/stattext.h>
27#include <ui/common/component/panel.h>
28#include "../button.h"
29#include "../notebook/mapnotebook.h"
30#include "settings.h"
31
32#include <wx/textctrl.h>
33
34namespace Antares
35{
36namespace Map
37{
41class Component final : public Antares::Component::Panel, public Yuni::IEventObserver<Component>
42{
43public:
45
46
49 Component(wxWindow* parent);
53 virtual ~Component();
55
57
58
66 void attachStudy(Data::Study::Ptr study);
67
71 void detachStudy(bool canRefresh = true);
72
77 Data::Study::Ptr attachedStudy();
79
81
82
88 bool loadFromStudy(Data::Study& study);
89
95
103 bool saveToStudy(Data::Study& study, bool incremental = true);
104
111 bool saveToAttachedStudy(bool incremental = true);
113
120 bool saveToImageFile(const AnyString& filePath, const MapRenderOptions& options);
122
123 void clear();
124
126
127
130 void recenterView();
131
132 void onCenterXY(void*);
133
137 void setFocus();
138
142 uint selectedAreaCount() const;
144
145 void drawerVisible();
146
147 void showLayerAll();
148
149 void forceReload();
150 void refresh();
151
156
157 void renameNodeFromArea(const Data::Area* area);
158
160
161
164 void unselectAll(bool canRefresh = true);
165
169 void selectAll();
170
174 void reverseSelection();
175
179 void selectOnly(const Data::Area::Vector& areas);
180
184 void selectOnly(const Data::Area::Vector& areas, const Data::AreaLink::Vector& links);
186
188
189
192 void reimportNodeColors(const Data::Area* area);
193
197 void moveNodeFromAreaX(const Data::Area* area, int x);
198
202 void moveNodeFromAreaY(const Data::Area* area, int y);
204
205 size_t getActiveLayerID()
206 {
207 return pMapActiveLayer ? pMapActiveLayer->getUid() : 0;
208 }
209
210public:
212 Yuni::Event<void(int, int)> onPopupEvent;
214 Yuni::Event<void(const wxString&)> onStatusBarText;
216 Yuni::Event<void(Component&)> onDblClick;
218 // Yuni::Event<void (void*)> onTextEnter;
219
220private:
221 class Drawer final : public Antares::Component::Panel
222 {
223 public:
224 Drawer(wxWindow* parent, Component& com) :
225 Antares::Component::Panel(parent), pComponent(com)
226 {
227 }
228 void onDraw(wxPaintEvent& evt);
229 void onSize(wxSizeEvent& evt);
230
231 private:
232 void drawFromDevice(wxDC& dc);
233
234 private:
235 Component& pComponent;
236 DECLARE_EVENT_TABLE()
237 };
238
239 void onApplicationQuit();
240
241 void onPageChanged(Antares::Component::MapNotebook::Page& page);
242
243 Antares::Component::MapNotebook::Page* addNewLayer(wxString pageName = wxString(""),
244 size_t uID = 0);
245 void addNewEmptyLayer()
246 {
247 addNewLayer();
248 }
249 void removeLayer(Antares::Component::MapNotebook::Page& page);
250
251 void evtOnPopupEvent(int x, int y);
252
253 void evtOnSelectionHide(wxCommandEvent&);
254
255 void evtOnSelectionShow(wxCommandEvent&);
256
257 void onCopy(void*);
258 void onCopyDropdown(Antares::Component::Button&, wxMenu& menu, void*);
259 void evtPopupCopy(wxCommandEvent&);
260 void evtPopupCopyAll(wxCommandEvent&);
261 void evtPopupCopyAllAreas(wxCommandEvent&);
262 void evtPopupCopyAllLinks(wxCommandEvent&);
263 void onPaste(void*);
264 void onPasteDropdown(Antares::Component::Button&, wxMenu& menu, void*);
265 void evtPopupPaste(wxCommandEvent&);
266 void evtPopupPasteSpecial(wxCommandEvent&);
267 void onSelectAll(void*);
268
269 void onNew(void*);
270 void onNewDropdown(Antares::Component::Button&, wxMenu& menu, void*);
271
272 template<unsigned int N>
273 inline void evtNewArea(wxCommandEvent&)
274 {
275 if (pMapActiveLayer)
276 pMapActiveLayer->addNewNode(N);
277 setFocus();
278 }
279
280 void onToggleMouseSelectionArea(void*);
281 void onToggleMouseSelectionLink(void*);
282 void onToggleMouseSelectionPlant(void*);
283 void onToggleMouseSelectionConstraint(void*);
284
285 void onCenter(void*);
286
287 void onEvtCenterXY(wxCommandEvent& WXUNUSED(event));
288
289private:
290 Control* pMapActiveLayer;
292 std::vector<Control*> mapLayersPtrList;
293
294 wxStaticText* pInfosAreaCount;
295 wxStaticText* pInfosConnxCount;
296 // Toggle buttons
297 // The class wxWindow is used here to not include button.h everywhere
298 // It is already such a pain to compile on Windows...
300 wxWindow* pBtnSelectionArea;
302 wxWindow* pBtnSelectionLink;
304 wxWindow* pBtnSelectionPlant;
306 wxWindow* pBtnSelectionConstraint;
307
308 // PopUp Menu
309 wxMenu* pSelectionPopUpMenu;
310
311}; // class Component
312
313} // namespace Map
314} // namespace Antares
315
316#endif // __ANTARES_TOOLBOX_MAP_COMPONENT_H__
Definition button.h:34
MapNotebook.
Definition mapnotebook.h:35
Definition notebook.h:62
Panel implementation.
Definition panel.h:36
Definition for a single area.
Definition area.h:52
Definition study.h:61
Standard study MAP.
Definition component.h:42
bool loadFromStudy(Data::Study &study)
Load the map's settings from an existing Antares study.
Definition component.cpp:542
void unselectAll(bool canRefresh=true)
Select all nodes of type "area".
Definition component.cpp:791
void refreshHeaderInformations()
Refresh the header informations (how many areas/connexions)
Definition component.cpp:713
bool saveToAttachedStudy(bool incremental=true)
Save the map's settings to the attached study (if any)
Definition component.cpp:598
void selectOnly(const Data::Area::Vector &areas)
Select only items from a list of areas.
Definition component.cpp:812
void reimportNodeColors(const Data::Area *area)
Refresh the internal cache about the color of a single area.
Definition component.cpp:756
void recenterView()
Recenter scrollbars to the center of the map.
Definition component.cpp:1096
void reverseSelection()
Reverse the selection.
Definition component.cpp:846
Data::Study::Ptr attachedStudy()
Get the study attached to the map.
Definition component.cpp:537
virtual ~Component()
Destructor.
Definition component.cpp:119
void moveNodeFromAreaX(const Data::Area *area, int x)
Refresh the internal cache about the X-coordinate of a single area.
Definition component.cpp:766
void attachStudy(Data::Study::Ptr study)
Attach a study to the map to reflect changes.
Definition component.cpp:473
void selectAll()
Select all nodes of type "area".
Definition component.cpp:802
Yuni::Event< void(int, int)> onPopupEvent
Popup event.
Definition component.h:212
void moveNodeFromAreaY(const Data::Area *area, int y)
Refresh the internal cache about the X-coordinate of a single area.
Definition component.cpp:776
uint selectedAreaCount() const
Get how many areas have been selected.
Definition component.cpp:786
void setFocus()
Set the focus to the map.
Definition component.cpp:652
bool saveToStudy(Data::Study &study, bool incremental=true)
Save the map's settings to a study.
Definition component.cpp:583
bool loadFromAttachedStudy()
Load the map's settings from the attached study.
Definition component.cpp:568
Yuni::Event< void(Component &)> onDblClick
Event: Double-Click on a item.
Definition component.h:216
bool saveToImageFile(const AnyString &filePath, const MapRenderOptions &options)
Save the map into an image file.
Definition component.cpp:604
Yuni::Event< void(const wxString &)> onStatusBarText
Status bar event.
Definition component.h:214
void detachStudy(bool canRefresh=true)
Detach the study (if any) currently attached to the map.
Definition component.cpp:527
const size_t & getUid() const
get Control id
Definition control.h:83
Definition settings.h:48