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  // first clear vertices
100  myPOIVertices.clear();
101  // check if POI can be drawn
102  if(checkDraw(s)) {
103  // push name (needed for getGUIGlObjectsUnderCursor(...)
104  glPushName(getGlID());
105  // draw inner polygon
106  drawInnerPOI(s);
107  // pop name
108  glPopName();
109  }
110 }
111 
112 
113 void
115  const GUIColorer& c = s.poiColorer;
116  const int active = c.getActive();
117  if (s.netedit && active != 1 && gSelected.isSelected(GLO_POI, getGlID())) {
118  // override with special colors (unless the color scheme is based on selection)
119  GLHelper::setColor(RGBColor(0, 0, 204));
120  } else if (active == 0) {
122  } else if (active == 1) {
124  } else {
126  }
127 }
128 
129 
130 bool
132  // only continue if scale is valid
133  if (s.scale * (1.3 / 3.0) *s.poiSize.getExaggeration(s, this) < s.poiSize.minSize) {
134  return false;
135  }
136  return true;
137 }
138 
139 
140 void
142  const double exaggeration = s.poiSize.getExaggeration(s, this);
143  glPushMatrix();
144  setColor(s);
145  glTranslated(x(), y(), getShapeLayer());
146  glRotated(-getShapeNaviDegree(), 0, 0, 1);
147  // check if has to be drawn as a circle or with an image
150  if (textureID > 0) {
152  -myHalfImgWidth * exaggeration, -myHalfImgHeight * exaggeration,
153  myHalfImgWidth * exaggeration, myHalfImgHeight * exaggeration);
154  }
155  } else {
156  // fallback if no image is defined
157  if (s.drawForSelecting) {
158  GLHelper::drawFilledCircle((double) 1.3 * exaggeration, 8);
159  } else {
160  // draw filled circle saving vertices
161  myPOIVertices = GLHelper::drawFilledCircleReturnVertices((double) 1.3 * exaggeration, 16);
162  }
163  }
164  glPopMatrix();
165  if (!s.drawForSelecting) {
166  const Position namePos = *this;
167  drawName(namePos, s.scale, s.poiName, s.angle);
168  if (s.poiType.show) {
169  const Position p = namePos + Position(0, -0.6 * s.poiType.size / s.scale);
171  }
172  }
173 }
174 
175 /****************************************************************************/
176 
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:48
const std::string & getShapeImgFile() const
Returns the imgFile of the Shape.
Definition: Shape.h:104
GUIVisualizationTextSettings poiName
void drawInnerPOI(const GUIVisualizationSettings &s) const
draw inner POI (before pushName() )
Stores the information about how to visualize structures.
double y() const
Returns the y-position.
Definition: Position.h:62
static void drawTextSettings(const GUIVisualizationTextSettings &settings, const std::string &text, const Position &pos, const double scale, const double angle=0, const double layer=2048)
Definition: GLHelper.cpp:635
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:57
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:76
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:83
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
bool checkDraw(const GUIVisualizationSettings &s) const
check if POI can be drawn
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:90
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.
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.
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
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
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:97