Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
connection.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_CONNECTION_H__
22#define __ANTARES_TOOLBOX_MAP_CONNECTION_H__
23
24#include "item.h"
25#include "node.h"
26#include "../tools/tool.h"
27#include <antares/study/area/area.h>
28
29namespace Antares
30{
31namespace Map
32{
33// Forward declaration
34namespace Tool
35{
36class Tool;
37}
38
39class Connection : public Item
40{
41public:
42 enum Direction
43 {
44 dirNone,
45 dirDirect,
46 dirIndirect,
47 };
48
49public:
51
52
57 virtual ~Connection();
59
61
62
65 bool isVisibleOnLayer(const size_t& layerID) const;
67
69 virtual Type type() const;
70
71 Item* leftSide()
72 {
73 return pA;
74 }
75 const Item* leftSide() const
76 {
77 return pA;
78 }
79
80 Item* rightSide()
81 {
82 return pB;
83 }
84 const Item* rightSide() const
85 {
86 return pB;
87 }
88
89 Direction arrowDirection() const
90 {
91 return pArrowDirection;
92 }
93 void arrowDirection(const Direction& d);
94
95 Direction direction() const
96 {
97 return pDirection;
98 }
99 void direction(const Direction& d);
100
104 virtual void refreshCache(wxDC& dc);
105
106 virtual bool contains(const int x, const int y, double& distance);
107
108 virtual bool isContained(const int x1, const int y1, const int x2, const int y2) const;
109
110 virtual void draw(DrawingContext& dc);
111
112 virtual void extendBoundingBox(wxPoint& topLeft, wxPoint& bottomRight);
113
115
116
117 virtual bool selected() const;
119 virtual void selected(bool v);
121
123
124
128
134
135private:
136 void drawArrow(wxDC& dc, const Direction direction, const wxPoint& rA, const wxPoint& rB);
137
138 void destroyTools();
139 void createTools();
140
141private:
142 Item* pA;
143 Item* pB;
144 Direction pDirection;
145 Direction pArrowDirection;
146
147 wxPoint pCachedAbsolutePosition;
148 wxPoint pCachedSize;
149 wxPoint pCachedMiddlePoint;
150 wxPoint pCachedTextPos;
152 bool pCachedError;
153
154 bool pHaveTools;
155 Tool::Tool* pToolDirection;
156
157 Data::AreaLink* pAttachedAreaLink;
158
159 wxPen pDefaultPen;
160 wxPen pErrorPen;
161
162}; // class Connection
163
164} // namespace Map
165} // namespace Antares
166
167#include "connection.hxx"
168
169#endif // __ANTARES_TOOLBOX_MAP_CONNECTION_H__
Definition connection.h:40
virtual bool contains(const int x, const int y, double &distance)
Get if the drawing representation of the node contains the point (x,y)
Definition connection.cpp:259
void createANewConnectionIfNeeded()
Create a link if the internal pointers are nil.
Definition connection.cpp:228
virtual bool isContained(const int x1, const int y1, const int x2, const int y2) const
Get if the drawing representation of the node is contained inside a bounding box.
Definition connection.cpp:267
virtual ~Connection()
Destructor.
Definition connection.cpp:137
virtual void draw(DrawingContext &dc)
Draw the node.
Definition connection.cpp:334
Data::AreaLink * attachedAreaLink() const
Get the attached link.
Definition connection.hxx:38
bool isVisibleOnLayer(const size_t &layerID) const
Get the visivility for a layerId.
Definition connection.cpp:168
virtual void extendBoundingBox(wxPoint &topLeft, wxPoint &bottomRight)
Extends the bounding box.
Definition connection.cpp:448
virtual Type type() const
Type of the node.
Definition connection.hxx:28
virtual bool selected() const
Get if the item is selected.
Definition connection.hxx:33
virtual void refreshCache(wxDC &dc)
Refresh the cache (even if not invalidated)
Definition connection.cpp:189
Drawing Context.
Definition drawingcontext.h:43
Definition item.h:41
Manager & manager()
Get the manager.
Definition item.h:91
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