Antares Simulator
Power System Simulator
node.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_NODE_H__
22 #define __ANTARES_TOOLBOX_MAP_NODE_H__
23 
24 #include <antares/study/study.h>
25 #include <set>
26 #include "item.h"
27 #include "../drawingcontext.h"
28 
29 namespace Antares::Map
30 {
31 // Forward declaration of the manager
32 class Manager;
33 class DrawingContext;
34 
38 class Node: public Item
39 {
40 public:
42 
43 
48 
52  Node(Manager& manager, const wxString& id);
53 
57  virtual ~Node();
58 
60 
62 
63 
66  bool isVisibleOnLayer(const size_t& layerID) const;
67 
69 
70  virtual Type type() const
71  {
72  return tyNode;
73  }
74 
76 
77  const wxString& id() const
78  {
79  return pId;
80  }
81 
83 
84  void position(const int x, const int y);
85 
92  virtual void move(const int x, const int y);
93 
95 
96 
100  virtual void refreshCache(wxDC& dc);
101 
105  const wxPoint& cachedPosition() const
106  {
107  return pCachedPosition;
108  }
109 
113  const wxPoint& cachedSize() const
114  {
115  return pCachedSize;
116  }
117 
119 
121 
122 
127  virtual bool contains(const int x, const int y, double& distance);
128 
134  virtual bool isContained(const int x1, const int y1, const int x2, const int y2) const;
135 
139  virtual void draw(DrawingContext& dc);
140 
142 
143  virtual void extendBoundingBox(wxPoint& topLeft, wxPoint& bottomRight);
144 
145  Data::Area* attachedArea() const
146  {
147  return pAttachedArea;
148  }
149 
150  void attachedArea(Data::Area* a)
151  {
152  pAttachedArea = a;
153  }
154 
158  void addLayerVisibility(size_t id = 0);
159  void removeLayerVisibility(size_t id);
160 
161 protected:
162  virtual void captionHasChanged();
163  virtual void positionHasChanged();
164  virtual void colorHasChanged();
165 
166  void createANewAreaIfNotAlreadyAttached();
167 
168 private:
170  wxString pId;
171 
172  wxPoint pCachedPosition;
173  wxPoint pCachedSize;
174  wxColour pCachedColorGradientStart;
175  wxColour pCachedColorGradientEnd;
176  wxColour pCachedColorGradientStart2;
177  wxColour pCachedColorGradientEnd2;
178 
179  wxColour pCachedColorText;
180  wxPen pBorderPen;
181  wxPen pShadowPen;
182 
183  Data::Area* pAttachedArea;
184 
185 }; // class Node
186 
187 } // namespace Antares::Map
188 
189 #endif // __ANTARES_TOOLBOX_MAP_NODE_H__
Definition for a single area.
Definition: area.h:51
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
A node in a map.
Definition: node.h:39
virtual void refreshCache(wxDC &dc)
Refresh the cache (even if not invalidated)
Definition: node.cpp:122
virtual Type type() const
Type.
Definition: node.h:70
virtual ~Node()
Destructor.
Definition: node.cpp:87
const wxPoint & cachedPosition() const
Get the cached position.
Definition: node.h:105
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: node.cpp:251
virtual void draw(DrawingContext &dc)
Draw the node.
Definition: node.cpp:284
void addLayerVisibility(size_t id=0)
make this node visible/invisible in a layer
Definition: node.cpp:385
virtual void extendBoundingBox(wxPoint &topLeft, wxPoint &bottomRight)
Extends the bounding box.
Definition: node.cpp:362
const wxPoint & cachedSize() const
Get the cached size.
Definition: node.h:113
Node(Manager &manager)
Default constructor.
Definition: node.cpp:56
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: node.cpp:238
bool isVisibleOnLayer(const size_t &layerID) const
Get the visivility for a layerId.
Definition: node.cpp:111
virtual void move(const int x, const int y)
Move the node.
Definition: node.cpp:273