Antares Simulator
Power System Simulator
bindingconstraint.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_BINDING_CONSTRAINT_H__
22 #define __ANTARES_TOOLBOX_MAP_BINDING_CONSTRAINT_H__
23 
24 #include "item.h"
25 
26 namespace Antares::Map
27 {
28 class BindingConstraint final: public Item
29 {
30 public:
32 
33 
40  virtual ~BindingConstraint();
41 
43 
47  virtual Type type() const
48  {
49  return tyBindingConstraint;
50  }
51 
53 
54  virtual bool selected() const
55  {
56  return pSelected;
57  }
58 
59  virtual void selected(bool v);
61 
63 
64 
67  virtual void refreshCache(wxDC& dc);
68 
70 
72 
73 
76  virtual bool contains(const int, const int, double& /* distance */)
77  {
78  return false;
79  }
80 
86  virtual bool isContained(const int, const int, const int, const int) const
87  {
88  return false;
89  }
90 
94  virtual void draw(DrawingContext& dc);
95  virtual void drawExternalDrawer(DrawingContext& dc);
96 
98 
102  virtual void extendBoundingBox(wxPoint&, wxPoint&)
103  {
104  }
105 
106  void clear();
107 
108  bool empty() const
109  {
110  return pConnections.empty();
111  }
112 
113  uint count() const
114  {
115  return (uint)pConnections.size();
116  }
117 
118  void add(Item* item);
119 
120  bool remove(Item* item);
121 
122 private:
123  struct Infos
124  {
125  public:
126  Infos():
127  weight(1.),
128  selected(false)
129  {
130  }
131 
132  Infos(const Infos& c):
133  weight(c.weight),
134  selected(false)
135  {
136  }
137 
138  double weight;
139  bool selected;
140  };
141 
142  using Connections = std::map<Connection*, Infos>;
143  Connections pConnections;
144 
145  struct TextPart
146  {
147  TextPart():
148  text(),
149  color(0, 0, 0),
150  size(0, 0)
151  {
152  }
153 
154  TextPart(const wxString& s, const int r, const int g, const int b):
155  text(s),
156  color(r, g, b)
157  {
158  }
159 
160  wxString text;
161  wxColour color;
162  wxSize size;
163 
164  void refreshCache(wxDC& dc);
165  };
166 
167  std::vector<TextPart> pTextParts;
168 
169 }; // class BindingConstraint
170 
171 } // namespace Antares::Map
172 
173 #endif // __ANTARES_TOOLBOX_MAP_BINDING_CONSTRAINT_H__
Definition: bindingconstraint.h:29
virtual void extendBoundingBox(wxPoint &, wxPoint &)
Extends the bounding box.
Definition: bindingconstraint.h:102
BindingConstraint(Manager &manager)
Constructor.
Definition: bindingconstraint.cpp:28
virtual void refreshCache(wxDC &dc)
Refresh the cache (even if not invalidated)
Definition: bindingconstraint.cpp:128
virtual ~BindingConstraint()
Destructor.
Definition: bindingconstraint.cpp:33
virtual Type type() const
Type.
Definition: bindingconstraint.h:47
virtual bool isContained(const int, const int, const int, const int) const
Get if the drawing representation of the node is contained inside a bounding box.
Definition: bindingconstraint.h:86
virtual void draw(DrawingContext &dc)
Draw the node.
Definition: bindingconstraint.cpp:43
virtual bool contains(const int, const int, double &)
Get if the drawing representation of the node contains the point (x,y)
Definition: bindingconstraint.h:76
Drawing Context.
Definition: drawingcontext.h:41
Definition: item.h:39
Manager & manager()
Get the manager.
Definition: item.h:90
bool pSelected
Selected.
Definition: item.h:285
Item(Manager &manager, const int zPos=0)
Constructor.
Definition: item.cpp:28
A convenient container for nodes on the graph.
Definition: manager.h:44