Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
tool.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_TOOLS_TOOL_H__
22#define __ANTARES_TOOLBOX_MAP_TOOLS_TOOL_H__
23
24#include <vector>
25#include "../drawingcontext.h"
26
27namespace Antares
28{
29namespace Map
30{
31namespace Tool
32{
36enum LifeSpan
37{
39 lifeSpanMouseSelection,
44 lifeSpanImmortality,
45
46}; // enum LifeSpan
47
51class Tool
52{
53public:
55
56
62 Tool(Manager& manager, const char* icon);
64 virtual ~Tool();
66
68
69 Manager& manager()
70 {
71 return pManager;
72 }
73 const Manager& manager() const
74 {
75 return pManager;
76 }
78
80
81
82 int x() const
83 {
84 return pX;
85 }
87 void x(const int v)
88 {
89 pX = v;
90 }
92
94
95 int y() const
96 {
97 return pY;
98 }
100 void y(const int v)
101 {
102 pY = v;
103 }
105
107
108
109 uint width() const
110 {
111 return pWidth;
112 }
114 uint height() const
115 {
116 return pHeight;
117 }
119
121
122
123 const wxBitmap* icon() const
124 {
125 return pIcon;
126 }
134 void icon(const char* filename);
135 //}
136
138
139
140 LifeSpan lifeSpan() const
141 {
142 return lifeSpanMouseSelection;
143 }
145
147
148
156 bool contains(const int x, const int y) const
157 {
158 return x >= pX && x <= pX + pWidth && y >= pY && y <= pY + pHeight;
159 }
160
169 virtual void draw(DrawingContext& dc,
170 const bool mouseDown,
171 const wxPoint& position,
172 const wxPoint& absolute) const;
173
175
185 virtual bool actionIsImmediate() const
186 {
187 return true;
188 }
189
195 virtual bool onMouseUp(const int mx, const int my) = 0;
196
197protected:
201 int pX;
203 int pY;
209 wxBitmap* pIcon;
210
211}; // class Tool
212
214using List = std::vector<Tool*>;
215
216} // namespace Tool
217} // namespace Map
218} // namespace Antares
219
220#endif // __ANTARES_TOOLBOX_MAP_TOOLS_TOOL_H__
Drawing Context.
Definition drawingcontext.h:43
A convenient container for nodes on the graph.
Definition manager.h:46
Visual component to make an action on the selected items.
Definition tool.h:52
virtual bool actionIsImmediate() const
Get if the action triggered by the tool is immediate.
Definition tool.h:185
bool contains(const int x, const int y) const
Get if a point is insided the bounding box of the tool.
Definition tool.h:156
const wxBitmap * icon() const
Get the icon of the tool, NULL if not available.
Definition tool.h:123
Manager & pManager
The parent manager.
Definition tool.h:199
int pWidth
Width.
Definition tool.h:205
LifeSpan lifeSpan() const
Get the lifespan of the tool.
Definition tool.h:140
int pHeight
Height.
Definition tool.h:207
int pX
The X-Coordinate.
Definition tool.h:201
wxBitmap * pIcon
Icon.
Definition tool.h:209
uint width() const
Get the width of the tool.
Definition tool.h:109
virtual ~Tool()
Destructor.
Definition tool.cpp:38
virtual bool onMouseUp(const int mx, const int my)=0
Event: The user has clicked on the tool.
int pY
The Y-Coordinate.
Definition tool.h:203
virtual void draw(DrawingContext &dc, const bool mouseDown, const wxPoint &position, const wxPoint &absolute) const
Draw the tool.
Definition tool.cpp:49
int y() const
Get the Y-Coordinate of the tool.
Definition tool.h:95
uint height() const
Get the height of the tool.
Definition tool.h:114
void y(const int v)
Set the Y-Coordinate of the tool.
Definition tool.h:100
void x(const int v)
Set the X-Coordinate of the tool.
Definition tool.h:87
int x() const
Get the X-Coordinate of the tool.
Definition tool.h:82