Antares Simulator
Power System Simulator
connection.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 #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 
29 namespace Antares::Map
30 {
31 // Forward declaration
32 namespace Tool
33 {
34 class Tool;
35 }
36 
37 class Connection: public Item
38 {
39 public:
40  enum Direction
41  {
42  dirNone,
43  dirDirect,
44  dirIndirect,
45  };
46 
47 public:
49 
50 
55  virtual ~Connection();
57 
59 
60 
63  bool isVisibleOnLayer(const size_t& layerID) const;
65 
67  virtual Type type() const;
68 
69  Item* leftSide()
70  {
71  return pA;
72  }
73 
74  const Item* leftSide() const
75  {
76  return pA;
77  }
78 
79  Item* rightSide()
80  {
81  return pB;
82  }
83 
84  const Item* rightSide() const
85  {
86  return pB;
87  }
88 
89  Direction arrowDirection() const
90  {
91  return pArrowDirection;
92  }
93 
94  void arrowDirection(const Direction& d);
95 
96  Direction direction() const
97  {
98  return pDirection;
99  }
100 
101  void direction(const Direction& d);
102 
106  virtual void refreshCache(wxDC& dc);
107 
108  virtual bool contains(const int x, const int y, double& distance);
109 
110  virtual bool isContained(const int x1, const int y1, const int x2, const int y2) const;
111 
112  virtual void draw(DrawingContext& dc);
113 
114  virtual void extendBoundingBox(wxPoint& topLeft, wxPoint& bottomRight);
115 
117 
118  virtual bool selected() const;
121  virtual void selected(bool v);
123 
125 
130 
136 
137 private:
138  void drawArrow(wxDC& dc, const Direction direction, const wxPoint& rA, const wxPoint& rB);
139 
140  void destroyTools();
141  void createTools();
142 
143 private:
144  Item* pA;
145  Item* pB;
146  Direction pDirection;
147  Direction pArrowDirection;
148 
149  wxPoint pCachedAbsolutePosition;
150  wxPoint pCachedSize;
151  wxPoint pCachedMiddlePoint;
152  wxPoint pCachedTextPos;
154  bool pCachedError;
155 
156  bool pHaveTools;
157  Tool::Tool* pToolDirection;
158 
159  Data::AreaLink* pAttachedAreaLink;
160 
161  wxPen pDefaultPen;
162  wxPen pErrorPen;
163 
164 }; // class Connection
165 
166 } // namespace Antares::Map
167 
168 #include "connection.hxx"
169 
170 #endif // __ANTARES_TOOLBOX_MAP_CONNECTION_H__
Definition: connection.h:38
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:289
void createANewConnectionIfNeeded()
Create a link if the internal pointers are nil.
Definition: connection.cpp:252
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:301
virtual ~Connection()
Destructor.
Definition: connection.cpp:142
virtual void draw(DrawingContext &dc)
Draw the node.
Definition: connection.cpp:368
Data::AreaLink * attachedAreaLink() const
Get the attached link.
Definition: connection.hxx:36
bool isVisibleOnLayer(const size_t &layerID) const
Get the visivility for a layerId.
Definition: connection.cpp:179
virtual void extendBoundingBox(wxPoint &topLeft, wxPoint &bottomRight)
Extends the bounding box.
Definition: connection.cpp:491
Connection(Manager &manager, Item *a, Item *b)
Default constructor.
Definition: connection.cpp:104
virtual Type type() const
Type of the node.
Definition: connection.hxx:26
virtual bool selected() const
Get if the item is selected.
Definition: connection.hxx:31
virtual void refreshCache(wxDC &dc)
Refresh the cache (even if not invalidated)
Definition: connection.cpp:201
Drawing Context.
Definition: drawingcontext.h:41
Definition: item.h:39
Manager & manager()
Get the manager.
Definition: item.h:90
A convenient container for nodes on the graph.
Definition: manager.h:44
Visual component to make an action on the selected items.
Definition: tool.h:48