SUMO - Simulation of Urban MObility
GUIPointOfInterest.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // The GUI-version of a point of interest
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
34 #include <utils/gui/div/GLHelper.h>
36 #include "GUIPointOfInterest.h"
37 
38 
39 // ===========================================================================
40 // static members
41 // ===========================================================================
42 
43 std::vector<Position> GUIPointOfInterest::myPOIVertices;
44 
45 
46 // ===========================================================================
47 // method definitions
48 // ===========================================================================
49 
50 GUIPointOfInterest::GUIPointOfInterest(const std::string& id, const std::string& type,
51  const RGBColor& color, const Position& pos, bool geo,
52  const std::string& lane, double posOverLane, double posLat,
53  double layer, double angle, const std::string& imgFile,
54  bool relativePath, double width, double height) :
55  PointOfInterest(id, type, color, pos, geo, lane, posOverLane, posLat, layer, angle, imgFile, relativePath, width, height),
57 }
58 
59 
61 
62 
65  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
66  // build shape header
68  return ret;
69 }
70 
71 
74  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this, 3 + (int)getParametersMap().size());
75  // add items
76  ret->mkItem("type", false, getShapeType());
77  ret->mkItem("layer", false, getShapeLayer());
78  ret->closeBuilding(this);
79  return ret;
80 }
81 
82 
85  Boundary b;
86  b.add(x(), y());
90  } else {
91  b.grow(3);
92  }
93  return b;
94 }
95 
96 
97 void
99  const double exaggeration = s.poiSize.getExaggeration(s);
100  // first clear vertices
101  myPOIVertices.clear();
102  // only continue if scale is valid
103  if (s.scale * (1.3 / 3.0) *exaggeration < s.poiSize.minSize) {
104  return;
105  }
106  glPushName(getGlID());
107  glPushMatrix();
108  setColor(s);
109  glTranslated(x(), y(), getShapeLayer());
110  glRotated(-getShapeNaviDegree(), 0, 0, 1);
111 
114  if (textureID > 0) {
116  -myHalfImgWidth * exaggeration, -myHalfImgHeight * exaggeration,
117  myHalfImgWidth * exaggeration, myHalfImgHeight * exaggeration);
118  }
119  } else {
120  // fallback if no image is defined
121  if (s.drawForSelecting) {
122  GLHelper::drawFilledCircle((double) 1.3 * exaggeration, 8);
123  } else {
124  // draw filled circle saving vertices
125  myPOIVertices = GLHelper::drawFilledCircleReturnVertices((double) 1.3 * exaggeration, 16);
126  }
127  }
128  glPopMatrix();
129  if (!s.drawForSelecting) {
130  const Position namePos = *this;
131  drawName(namePos, s.scale, s.poiName, s.angle);
132  if (s.poiType.show) {
133  GLHelper::drawText(getShapeType(), namePos + Position(0, -0.6 * s.poiType.size / s.scale),
134  GLO_MAX, s.poiType.size / s.scale, s.poiType.color);
135  }
136  }
137  glPopName();
138 }
139 
140 
141 void
143  const GUIColorer& c = s.poiColorer;
144  const int active = c.getActive();
145  if (s.netedit && active != 1 && gSelected.isSelected(GLO_POI, getGlID())) {
146  // override with special colors (unless the color scheme is based on selection)
147  GLHelper::setColor(RGBColor(0, 0, 204));
148  } else if (active == 0) {
150  } else if (active == 1) {
152  } else {
154  }
155 }
156 
157 /****************************************************************************/
158 
static void drawTexturedBox(int which, double size)
Draws a named texture as a box with the given size.
double scale
information about a lane&#39;s width (temporary, used for a single view)
void buildShapePopupOptions(GUIMainWindow &app, GUIGLObjectPopupMenu *ret, const std::string &type)
build basic shape popup options. Used to unify pop-ups menu in netedit and SUMO-GUI ...
GUIVisualizationTextSettings poiType
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
static const std::string DEFAULT_IMG_FILE
Definition: Shape.h:47
const std::string & getShapeImgFile() const
Returns the imgFile of the Shape.
Definition: Shape.h:103
GUIVisualizationTextSettings poiName
Stores the information about how to visualize structures.
double y() const
Returns the y-position.
Definition: Position.h:61
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
double x() const
Returns the x-position.
Definition: Position.h:56
static void drawText(const std::string &text, const Position &pos, const double layer, const double size, const RGBColor &col=RGBColor::BLACK, const double angle=0, int align=0, double width=-1)
Definition: GLHelper.cpp:611
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
bool netedit
Whether the settings are for Netedit.
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:344
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
const std::string & getShapeType() const
Returns the (abstract) type of the Shape.
Definition: Shape.h:75
double myHalfImgHeight
The half height of the image when rendering this POI.
GUIColorer poiColorer
The POI colorer.
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:573
double minSize
The minimum size to draw this object.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
const RGBColor & getShapeColor() const
Returns the color of the Shape.
Definition: Shape.h:82
static std::vector< Position > drawFilledCircleReturnVertices(double width, int steps=8)
Draws a filled circle around (0,0) returning circle vertex.
Definition: GLHelper.cpp:350
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
static int getTextureID(const std::string &filename, const bool mirrorX=false)
return texture id for the given filename (initialize on first use)
void setColor(const GUIVisualizationSettings &s) const
set color
double myHalfImgWidth
The half width of the image when rendering this POI.
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0) const
draw name of item
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:301
double angle
The current view rotation angle.
const T getColor(const double value) const
virtual ~GUIPointOfInterest()
Destructor.
void growHeight(double by)
Increases the height of the boundary (y-axis)
Definition: Boundary.cpp:317
double getShapeLayer() const
Returns the layer of the Shape.
Definition: Shape.h:89
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
GUIVisualizationSizeSettings poiSize
static std::vector< Position > myPOIVertices
after every iteration of drawgl, position of vertices that make the circle are saved here...
The popup menu of a globject.
void growWidth(double by)
Increases the width of the boundary (x-axis)
Definition: Boundary.cpp:310
const std::map< std::string, std::string > & getParametersMap() const
Returns the inner key/value map.
GUIGlID getGlID() const
Returns the numerical id of the object.
double getExaggeration(const GUIVisualizationSettings &s, double factor=20) const
return the drawing size including exaggeration and constantSize values
GUIPointOfInterest(const std::string &id, const std::string &type, const RGBColor &color, const Position &pos, bool geo, const std::string &lane, double posOverLane, double posLat, double layer, double angle, const std::string &imgFile, bool relativePath, double width, double height)
Constructor.
A point-of-interest.
empty max
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:79
bool drawForSelecting
whether drawing is performed for the purpose of selecting objects
Position()
default constructor
Definition: Position.h:42
GUISelectedStorage gSelected
A global holder of selected objects.
A window containing a gl-object&#39;s parameter.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
double getShapeNaviDegree() const
Returns the angle of the Shape in navigational degrees.
Definition: Shape.h:96