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-2017 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 
47 // ===========================================================================
48 // method definitions
49 // ===========================================================================
50 GUIPointOfInterest::GUIPointOfInterest(const std::string& id, const std::string& type,
51  const RGBColor& color, const Position& pos,
52  double layer, double angle, const std::string& imgFile,
53  double width, double height) :
54  PointOfInterest(id, type, color, pos, layer, angle, imgFile, width, height),
55  GUIGlObject_AbstractAdd("poi", GLO_POI, id) {
56 }
57 
58 
60 
61 
64  GUISUMOAbstractView& parent) {
65 
66  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
67  buildPopupHeader(ret, app, false);
68  FXString t(myType.c_str());
69  new FXMenuCommand(ret, "(" + t + ")", 0, 0, 0);
70  new FXMenuSeparator(ret);
74  buildShowParamsPopupEntry(ret, false);
75  buildPositionCopyEntry(ret, false);
76  return ret;
77 }
78 
79 
84  new GUIParameterTableWindow(app, *this, 3 + (int)getMap().size());
85  // add items
86  ret->mkItem("type", false, myType);
87  ret->mkItem("layer", false, getLayer());
88  ret->closeBuilding(this);
89  return ret;
90 }
91 
92 
95  Boundary b;
96  b.add(x(), y());
97  if (myImgFile != DEFAULT_IMG_FILE) {
100  } else {
101  b.grow(3);
102  }
103  return b;
104 }
105 
106 
107 void
109  const double exaggeration = s.poiSize.getExaggeration(s);
110  if (s.scale * (1.3 / 3.0) *exaggeration < s.poiSize.minSize) {
111  return;
112  }
113  glPushName(getGlID());
114  glPushMatrix();
115  // set color depending of selection
117  GLHelper::setColor(RGBColor(0, 0, 204));
118  } else {
120  }
121  glTranslated(x(), y(), getLayer());
122  glRotated(-getNaviDegree(), 0, 0, 1);
123 
124  if (myImgFile != DEFAULT_IMG_FILE) {
126  if (textureID > 0) {
128  -myHalfImgWidth * exaggeration, -myHalfImgHeight * exaggeration,
129  myHalfImgWidth * exaggeration, myHalfImgHeight * exaggeration);
130  }
131  } else {
132  // fallback if no image is defined
133  GLHelper::drawFilledCircle((double) 1.3 * exaggeration, 16);
134  }
135  glPopMatrix();
136  const Position namePos = Position(x() + 1.32 * exaggeration, y() + 1.32 * exaggeration);
137  drawName(namePos, s.scale, s.poiName);
138  if (s.poiType.show) {
139  GLHelper::drawText(myType, namePos + Position(0, -0.6 * s.poiType.size / s.scale),
140  GLO_MAX, s.poiType.size / s.scale, s.poiType.color);
141  }
142  glPopName();
143 }
144 /****************************************************************************/
145 
static void drawTexturedBox(int which, double size)
Draws a named texture as a box with the given size.
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0) const
draw name of item
double scale
information about a lane&#39;s width (temporary, used for a single view)
GUIVisualizationTextSettings poiType
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
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
double x() const
Returns the x-position.
Definition: Position.h:63
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.
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
const std::map< std::string, std::string > & getMap() const
Returns the inner key/value map.
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:339
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.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
std::string myType
The type of the Shape.
Definition: Shape.h:158
double myHalfImgHeight
The half height of the image when rendering this POI.
double getExaggeration(const GUIVisualizationSettings &s, double factor=20) const
return the drawing size including exaggeration and constantSize values
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:438
double minSize
The minimum size to draw this object.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
double y() const
Returns the y-position.
Definition: Position.h:68
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.
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:302
virtual ~GUIPointOfInterest()
Destructor.
const RGBColor & getColor() const
Returns the color of the Shape.
Definition: Shape.h:79
void growHeight(double by)
Increases the height of the boundary (y-axis)
Definition: Boundary.cpp:318
double getLayer() const
Returns the layer of the Shape.
Definition: Shape.h:87
GUIVisualizationSizeSettings poiSize
std::string myImgFile
The angle of the Shape.
Definition: Shape.h:170
GUIPointOfInterest(const std::string &id, const std::string &type, const RGBColor &color, const Position &pos, double layer, double angle, const std::string &imgFile, double width, double height)
Constructor.
The popup menu of a globject.
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
void growWidth(double by)
Increases the width of the boundary (x-axis)
Definition: Boundary.cpp:311
A point-of-interest.
empty max
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)
draw Text with given parameters
Definition: GLHelper.cpp:455
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:86
Position()
default constructor
Definition: Position.h:49
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.
double getNaviDegree() const
Returns the angle of the Shape in navigational degrees.
Definition: Shape.h:94
A window containing a gl-object&#39;s parameter.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.