SUMO - Simulation of Urban MObility
GUIPointOfInterest.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // The GUI-version of a point of interest
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
41 #include <utils/gui/div/GLHelper.h>
44 #include "GUIPointOfInterest.h"
45 
46 #ifdef CHECK_MEMORY_LEAKS
47 #include <foreign/nvwa/debug_new.h>
48 #endif // CHECK_MEMORY_LEAKS
49 
50 
51 // ===========================================================================
52 // method definitions
53 // ===========================================================================
54 GUIPointOfInterest::GUIPointOfInterest(const std::string& id, const std::string& type,
55  const RGBColor& color, const Position& pos,
56  SUMOReal layer, SUMOReal angle, const std::string& imgFile,
57  SUMOReal width, SUMOReal height) :
58  PointOfInterest(id, type, color, pos, layer, angle, imgFile, width, height),
59  GUIGlObject_AbstractAdd("poi", GLO_POI, id) {
60 }
61 
62 
64 
65 
68  GUISUMOAbstractView& parent) {
69 
70  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
71  buildPopupHeader(ret, app, false);
72  FXString t(myType.c_str());
73  new FXMenuCommand(ret, "(" + t + ")", 0, 0, 0);
74  new FXMenuSeparator(ret);
78  buildPositionCopyEntry(ret, false);
79  return ret;
80 }
81 
82 
86  return 0;
87 }
88 
89 
92  Boundary b;
93  b.add(x(), y());
94  if (myImgFile != DEFAULT_IMG_FILE) {
97  } else {
98  b.grow(3);
99  }
100  return b;
101 }
102 
103 
104 void
106  const SUMOReal exaggeration = s.poiSize.getExaggeration(s);
107  if (s.scale * (1.3 / 3.0) *exaggeration < s.poiSize.minSize) {
108  return;
109  }
110  glPushName(getGlID());
111  glPushMatrix();
113  glTranslated(x(), y(), getLayer());
114  glRotated(-getNaviDegree(), 0, 0, 1);
115 
116  if (myImgFile != DEFAULT_IMG_FILE) {
118  if (textureID > 0) {
120  -myHalfImgWidth * exaggeration, -myHalfImgHeight * exaggeration,
121  myHalfImgWidth * exaggeration, myHalfImgHeight * exaggeration);
122  }
123  } else {
124  // fallback if no image is defined
125  GLHelper::drawFilledCircle((SUMOReal) 1.3 * exaggeration, 16);
126  }
127  glPopMatrix();
128  const Position namePos = Position(x() + 1.32 * exaggeration, y() + 1.32 * exaggeration);
129  drawName(namePos, s.scale, s.poiName);
130  if (s.poiType.show) {
131  GLHelper::drawText(myType, namePos + Position(0, -0.6 * s.poiType.size / s.scale),
132  GLO_MAX, s.poiType.size / s.scale, s.poiType.color);
133  }
134  glPopName();
135 }
136 /****************************************************************************/
137 
void growWidth(SUMOReal by)
Definition: Boundary.cpp:210
GUIVisualizationTextSettings poiType
static const std::string DEFAULT_IMG_FILE
Definition: Shape.h:152
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
GUIVisualizationTextSettings poiName
Stores the information about how to visualize structures.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
static void drawText(const std::string &text, const Position &pos, const SUMOReal layer, const SUMOReal size, const RGBColor &col=RGBColor::BLACK, const SUMOReal angle=0)
draw Text with given parameters
Definition: GLHelper.cpp:460
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used, also builds an entry for copying the geo-position.
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:123
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
SUMOReal scale
information about a lane&#39;s width (temporary, used for a single view)
std::string myType
The type of the Shape.
Definition: Shape.h:158
static void drawFilledCircle(SUMOReal width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:344
SUMOReal myHalfImgWidth
The half width of the image when rendering this POI.
static void drawTexturedBox(unsigned int which, SUMOReal size)
Draws a named texture as a box with the given size.
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:443
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
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)
GUIPointOfInterest(const std::string &id, const std::string &type, const RGBColor &color, const Position &pos, SUMOReal layer, SUMOReal angle, const std::string &imgFile, SUMOReal width, SUMOReal height)
Constructor.
float minSize
The minimum size to draw this object.
virtual ~GUIPointOfInterest()
Destructor.
void drawName(const Position &pos, const SUMOReal scale, const GUIVisualizationTextSettings &settings, const SUMOReal angle=0) const
const RGBColor & getColor() const
Returns the color of the Shape.
Definition: Shape.h:79
GUIVisualizationSizeSettings poiSize
void add(SUMOReal x, SUMOReal y)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:76
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
Definition: Boundary.cpp:201
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
std::string myImgFile
The angle of the Shape.
Definition: Shape.h:170
The popup menu of a globject.
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
SUMOReal myHalfImgHeight
The half height of the image when rendering this POI.
#define SUMOReal
Definition: config.h:213
A point-of-interest.
empty max
void growHeight(SUMOReal by)
Definition: Boundary.cpp:217
SUMOReal getLayer() const
Returns the layer of the Shape.
Definition: Shape.h:87
Position()
default constructor
Definition: Position.h:49
A window containing a gl-object&#39;s parameter.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
SUMOReal getNaviDegree() const
Returns the angle of the Shape in navigational degrees.
Definition: Shape.h:94
SUMOReal getExaggeration(const GUIVisualizationSettings &s) const
return the drawing size including exaggeration and constantSize values
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.