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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // The GUI-version of a point of interest
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
40 #include <utils/gui/div/GLHelper.h>
42 #include "GUIPointOfInterest.h"
43 
44 
45 // ===========================================================================
46 // method definitions
47 // ===========================================================================
48 
49 GUIPointOfInterest::GUIPointOfInterest(const std::string& id, const std::string& type,
50  const RGBColor& color, const Position& pos, bool geo,
51  const std::string& lane, double posOverLane, double posLat,
52  double layer, double angle, const std::string& imgFile,
53  double width, double height) :
54  PointOfInterest(id, type, color, pos, geo, lane, posOverLane, posLat, layer, angle, imgFile, width, height),
55  GUIGlObject_AbstractAdd("poi", GLO_POI, id) {
56 }
57 
58 
60 
61 
64  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
65  // build shape header
66  buildShapePopupOptions(app, ret, myType);
67  return ret;
68 }
69 
70 
73  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this, 3 + (int)getMap().size());
74  // add items
75  ret->mkItem("type", false, myType);
76  ret->mkItem("layer", false, getLayer());
77  ret->closeBuilding(this);
78  return ret;
79 }
80 
81 
84  Boundary b;
85  b.add(x(), y());
86  if (myImgFile != DEFAULT_IMG_FILE) {
89  } else {
90  b.grow(3);
91  }
92  return b;
93 }
94 
95 
96 void
98  const double exaggeration = s.poiSize.getExaggeration(s);
99  if (s.scale * (1.3 / 3.0) *exaggeration < s.poiSize.minSize) {
100  return;
101  }
102  glPushName(getGlID());
103  glPushMatrix();
104  // set color depending of selection
106  GLHelper::setColor(RGBColor(0, 0, 204));
107  } else {
109  }
110  glTranslated(x(), y(), getLayer());
111  glRotated(-getNaviDegree(), 0, 0, 1);
112 
113  if (myImgFile != DEFAULT_IMG_FILE) {
115  if (textureID > 0) {
117  -myHalfImgWidth * exaggeration, -myHalfImgHeight * exaggeration,
118  myHalfImgWidth * exaggeration, myHalfImgHeight * exaggeration);
119  }
120  } else {
121  // fallback if no image is defined
122  GLHelper::drawFilledCircle((double) 1.3 * exaggeration, 16);
123  }
124  glPopMatrix();
125  const Position namePos = *this;
126  drawName(namePos, s.scale, s.poiName);
127  if (s.poiType.show) {
128  GLHelper::drawText(myType, namePos + Position(0, -0.6 * s.poiType.size / s.scale),
129  GLO_MAX, s.poiType.size / s.scale, s.poiType.color);
130  }
131  glPopName();
132 }
133 
134 /****************************************************************************/
135 
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:151
GUIVisualizationTextSettings poiName
Stores the information about how to visualize structures.
double y() const
Returns the y-position.
Definition: Position.h:67
double x() const
Returns the x-position.
Definition: Position.h:62
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:487
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:350
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, double width, double height)
Constructor.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
std::string myType
The type of the Shape.
Definition: Shape.h:157
double getLayer() const
Returns the layer of the Shape.
Definition: Shape.h:86
double myHalfImgHeight
The half height of the image when rendering this POI.
double getNaviDegree() const
Returns the angle of the Shape in navigational degrees.
Definition: Shape.h:93
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:449
double minSize
The minimum size to draw this object.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
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)
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
virtual ~GUIPointOfInterest()
Destructor.
void growHeight(double by)
Increases the height of the boundary (y-axis)
Definition: Boundary.cpp:317
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
GUIVisualizationSizeSettings poiSize
const RGBColor & getColor() const
Returns the color of the Shape.
Definition: Shape.h:78
const std::map< std::string, std::string > & getMap() const
Returns the inner key/value map.
std::string myImgFile
The angle of the Shape.
Definition: Shape.h:169
The popup menu of a globject.
void growWidth(double by)
Increases the width of the boundary (x-axis)
Definition: Boundary.cpp:310
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
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:85
Position()
default constructor
Definition: Position.h:48
void mkItem(const char *name, bool dynamic, ValueSource< unsigned > *src)
Adds a row which obtains its value from an unsigned-ValueSource.
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.