Eclipse SUMO - Simulation of Urban MObility
GUIPolygon.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
20 // The GUI-version of a polygon
21 /****************************************************************************/
22 #pragma once
23 #include <config.h>
24 
25 #include <string>
30 
31 
32 // ===========================================================================
33 // class definitions
34 // ===========================================================================
35 
37 struct GLPrimitive {
38  GLenum type;
39  std::vector<Position> vert;
40 };
41 
42 
44 
45 public:
46 
60  TesselatedPolygon(const std::string& id, const std::string& type, const RGBColor& color, const PositionVector& shape,
61  bool geo, bool fill, double lineWidth, double layer = 0, double angle = 0, const std::string& imgFile = "",
62  bool relativePath = false, const std::string& name = DEFAULT_NAME,
63  const Parameterised::Map& parameters = DEFAULT_PARAMETERS):
64  SUMOPolygon(id, type, color, shape, geo, fill, lineWidth, layer, angle, imgFile, relativePath, name, parameters)
65  {}
66 
69 
71  void drawTesselation(const PositionVector& shape) const;
72 
74  mutable std::vector<GLPrimitive> myTesselation;
75 };
76 
77 /*
78  * @class GUIPolygon
79  * @brief The GUI-version of a polygon
80  */
82 
83 public:
97  GUIPolygon(const std::string& id, const std::string& type, const RGBColor& color, const PositionVector& shape,
98  bool geo, bool fill, double lineWidth, double layer = 0, double angle = 0, const std::string& imgFile = "",
99  bool relativePath = false, const std::string& name = DEFAULT_NAME);
100 
102  ~GUIPolygon();
103 
105 
106 
115 
124 
126  double getExaggeration(const GUIVisualizationSettings& s) const override;
127 
133  Boundary getCenteringBoundary() const override;
134 
139  virtual void drawGL(const GUIVisualizationSettings& s) const override;
140 
141  double getClickPriority() const override {
142  return getShapeLayer();
143  }
144 
146  virtual const std::string getOptionalName() const override {
147  return getShapeName();
148  }
150 
152  virtual void setShape(const PositionVector& shape) override;
153 
157  virtual void setShapeNaviDegree(const double angle) override {
159  if (angle != 0.) {
160  setShape(myShape);
161  }
162  }
163 
165  static RGBColor setColor(const GUIVisualizationSettings& s, const SUMOPolygon* polygon, const GUIGlObject* o, bool disableSelectionColor, int alphaOverride);
166 
168  static bool checkDraw(const GUIVisualizationSettings& s, const SUMOPolygon* polygon, const GUIGlObject* o);
169 
171  static void drawInnerPolygon(const GUIVisualizationSettings& s, const TesselatedPolygon* polygon, const GUIGlObject* o,
172  const PositionVector shape, const double layer, const bool fill,
173  const bool disableSelectionColor = false,
174  const int alphaOverride = -1,
175  const bool disableText = false);
176 
177  inline void activate(bool isActive) {
179  }
180 
181  inline bool isActive(void) const {
182  return myIsActive;
183  }
184 
185 private:
187  mutable FXMutex myLock;
188 
191 
194 };
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
The popup menu of a globject.
A window containing a gl-object's parameter.
bool isActive(void) const
Definition: GUIPolygon.h:181
static void drawInnerPolygon(const GUIVisualizationSettings &s, const TesselatedPolygon *polygon, const GUIGlObject *o, const PositionVector shape, const double layer, const bool fill, const bool disableSelectionColor=false, const int alphaOverride=-1, const bool disableText=false)
draw inner Polygon (before pushName() )
Definition: GUIPolygon.cpp:342
static bool checkDraw(const GUIVisualizationSettings &s, const SUMOPolygon *polygon, const GUIGlObject *o)
check if Polygon can be drawn
Definition: GUIPolygon.cpp:320
virtual void setShapeNaviDegree(const double angle) override
Sets a new angle in navigational degrees.
Definition: GUIPolygon.h:157
virtual void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition: GUIPolygon.cpp:251
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUIPolygon.cpp:241
double getClickPriority() const override
Returns the priority of receiving mouse clicks.
Definition: GUIPolygon.h:141
PositionVector * myRotatedShape
shape rotated on the centroid, if rotation is needed, nullptr otherwise
Definition: GUIPolygon.h:190
GUIPolygon(const std::string &id, const std::string &type, const RGBColor &color, const PositionVector &shape, bool geo, bool fill, double lineWidth, double layer=0, double angle=0, const std::string &imgFile="", bool relativePath=false, const std::string &name=DEFAULT_NAME)
Constructor.
Definition: GUIPolygon.cpp:187
~GUIPolygon()
Destructor.
Definition: GUIPolygon.cpp:200
FXMutex myLock
The mutex used to avoid concurrent updates of the shape.
Definition: GUIPolygon.h:187
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
Definition: GUIPolygon.cpp:222
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition: GUIPolygon.cpp:206
virtual const std::string getOptionalName() const override
Returns the name of the object (default "")
Definition: GUIPolygon.h:146
static RGBColor setColor(const GUIVisualizationSettings &s, const SUMOPolygon *polygon, const GUIGlObject *o, bool disableSelectionColor, int alphaOverride)
set color
Definition: GUIPolygon.cpp:291
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
Definition: GUIPolygon.cpp:235
void activate(bool isActive)
Definition: GUIPolygon.h:177
bool myIsActive
Is the polygon will be drawn or not.
Definition: GUIPolygon.h:193
virtual void setShape(const PositionVector &shape) override
set a new shape and update the tesselation
Definition: GUIPolygon.cpp:270
Stores the information about how to visualize structures.
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45
A list of positions.
PositionVector myShape
The positions of the polygon.
Definition: SUMOPolygon.h:136
const std::string getShapeName() const
Returns the name of the Shape.
Definition: Shape.h:110
virtual void setShapeNaviDegree(const double angle)
Sets a new angle in navigational degrees.
Definition: Shape.h:157
static const std::string DEFAULT_NAME
Definition: Shape.h:51
double getShapeLayer() const
Returns the layer of the Shape.
Definition: Shape.h:91
static const Parameterised::Map DEFAULT_PARAMETERS
Definition: Shape.h:52
std::vector< GLPrimitive > myTesselation
id of the display list for the cached tesselation
Definition: GUIPolygon.h:74
~TesselatedPolygon()
Destructor.
Definition: GUIPolygon.h:68
TesselatedPolygon(const std::string &id, const std::string &type, const RGBColor &color, const PositionVector &shape, bool geo, bool fill, double lineWidth, double layer=0, double angle=0, const std::string &imgFile="", bool relativePath=false, const std::string &name=DEFAULT_NAME, const Parameterised::Map &parameters=DEFAULT_PARAMETERS)
Constructor.
Definition: GUIPolygon.h:60
void drawTesselation(const PositionVector &shape) const
perform the tesselation / drawing
Definition: GUIPolygon.cpp:117
most likely I'm reinventing the wheel here
Definition: GUIPolygon.h:37
std::vector< Position > vert
Definition: GUIPolygon.h:39
GLenum type
Definition: GUIPolygon.h:38