Eclipse 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-2019 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 /****************************************************************************/
16 // The GUI-version of a point of interest
17 /****************************************************************************/
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
33 #include <utils/gui/div/GLHelper.h>
35 #include "GUIPointOfInterest.h"
36 
37 
38 // ===========================================================================
39 // static members
40 // ===========================================================================
41 
42 std::vector<Position> GUIPointOfInterest::myPOIVertices;
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  bool relativePath, double width, double height) :
54  PointOfInterest(id, type, color, pos, geo, lane, posOverLane, posLat, layer, angle, imgFile, relativePath, width, height),
56 }
57 
58 
60 
61 
64  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
65  // build shape header
67  return ret;
68 }
69 
70 
73  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this, 3 + (int)getParametersMap().size());
74  // add items
75  ret->mkItem("type", false, getShapeType());
76  ret->mkItem("layer", false, getShapeLayer());
77  ret->closeBuilding(this);
78  return ret;
79 }
80 
81 
84  Boundary b;
85  b.add(x(), y());
89  } else {
90  b.grow(3);
91  }
92  return b;
93 }
94 
95 
96 void
98  // first clear vertices
99  myPOIVertices.clear();
100  // check if POI can be drawn
101  if (checkDraw(s)) {
102  // push name (needed for getGUIGlObjectsUnderCursor(...)
103  glPushName(getGlID());
104  // draw inner polygon
105  drawInnerPOI(s, false);
106  // pop name
107  glPopName();
108  }
109 }
110 
111 
112 void
113 GUIPointOfInterest::setColor(const GUIVisualizationSettings& s, bool disableSelectionColor) const {
114  const GUIColorer& c = s.poiColorer;
115  const int active = c.getActive();
116  if (s.netedit && active != 1 && gSelected.isSelected(GLO_POI, getGlID()) && disableSelectionColor) {
117  // override with special colors (unless the color scheme is based on selection)
118  GLHelper::setColor(RGBColor(0, 0, 204));
119  } else if (active == 0) {
121  } else if (active == 1) {
123  } else {
125  }
126 }
127 
128 
129 bool
131  // only continue if scale is valid
132  if (s.scale * (1.3 / 3.0) *s.poiSize.getExaggeration(s, this) < s.poiSize.minSize) {
133  return false;
134  }
135  return true;
136 }
137 
138 
139 void
140 GUIPointOfInterest::drawInnerPOI(const GUIVisualizationSettings& s, bool disableSelectionColor) const {
141  const double exaggeration = s.poiSize.getExaggeration(s, this);
142  glPushMatrix();
143  setColor(s, disableSelectionColor);
144  glTranslated(x(), y(), getShapeLayer());
145  glRotated(-getShapeNaviDegree(), 0, 0, 1);
146  // check if has to be drawn as a circle or with an image
149  if (textureID > 0) {
151  -myHalfImgWidth * exaggeration, -myHalfImgHeight * exaggeration,
152  myHalfImgWidth * exaggeration, myHalfImgHeight * exaggeration);
153  }
154  } else {
155  // fallback if no image is defined
157  GLHelper::drawFilledCircle((double) 1.3 * exaggeration, 8);
158  } else {
159  // draw filled circle saving vertices
160  myPOIVertices = GLHelper::drawFilledCircleReturnVertices((double) 1.3 * exaggeration, 16);
161  }
162  }
163  glPopMatrix();
164  if (!s.drawForRectangleSelection) {
165  const Position namePos = *this;
166  drawName(namePos, s.scale, s.poiName, s.angle);
167  if (s.poiType.show) {
168  const Position p = namePos + Position(0, -0.6 * s.poiType.size / s.scale);
170  }
171  }
172 }
173 
174 /****************************************************************************/
175 
GLHelper::drawTextSettings
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:706
GUIParameterTableWindow
A window containing a gl-object's parameter.
Definition: GUIParameterTableWindow.h:62
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:72
GUIParameterTableWindow.h
GUIGlObject::drawName
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0) const
draw name of item
Definition: GUIGlObject.cpp:354
Shape::getShapeNaviDegree
double getShapeNaviDegree() const
Returns the angle of the Shape in navigational degrees.
Definition: Shape.h:96
GUIVisualizationSettings::angle
double angle
The current view rotation angle.
Definition: GUIVisualizationSettings.h:405
GUIVisualizationSettings::drawForRectangleSelection
bool drawForRectangleSelection
whether drawing is performed for the purpose of selecting objects using a rectangle
Definition: GUIVisualizationSettings.h:647
GUIGLObjectPopupMenu.h
GUIGlobalSelection.h
GUIPointOfInterest::getPopUpMenu
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GUIPointOfInterest.cpp:63
GUIPointOfInterest::checkDraw
bool checkDraw(const GUIVisualizationSettings &s) const
check if POI can be drawn
Definition: GUIPointOfInterest.cpp:130
GUIVisualizationSettings::netedit
bool netedit
Whether the settings are for Netedit.
Definition: GUIVisualizationSettings.h:402
Shape::getShapeImgFile
const std::string & getShapeImgFile() const
Returns the imgFile of the Shape.
Definition: Shape.h:103
GUIVisualizationSettings.h
GLHelper.h
GUIPointOfInterest::GUIPointOfInterest
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.
Definition: GUIPointOfInterest.cpp:49
GUIGlObject_AbstractAdd
Definition: GUIGlObject_AbstractAdd.h:39
GUIGLObjectPopupMenu
The popup menu of a globject.
Definition: GUIGLObjectPopupMenu.h:47
GLHelper::setColor
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:621
Shape::getShapeColor
const RGBColor & getShapeColor() const
Returns the color of the Shape.
Definition: Shape.h:82
GUIParameterTableWindow::closeBuilding
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
Definition: GUIParameterTableWindow.cpp:219
GUITexturesHelper::drawTexturedBox
static void drawTexturedBox(int which, double size)
Draws a named texture as a box with the given size.
Definition: GUITexturesHelper.cpp:72
GUIMainWindow.h
GUIAppEnum.h
GLHelper::drawFilledCircle
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:348
RGBColor
Definition: RGBColor.h:39
Parameterised::getParametersMap
const std::map< std::string, std::string > & getParametersMap() const
Returns the inner key/value map.
Definition: Parameterised.cpp:106
PointOfInterest::myHalfImgWidth
double myHalfImgWidth
The half width of the image when rendering this POI.
Definition: PointOfInterest.h:188
GUIPointOfInterest::setColor
void setColor(const GUIVisualizationSettings &s, bool forceSelectionColor) const
set color
Definition: GUIPointOfInterest.cpp:113
GUIVisualizationSettings::poiSize
GUIVisualizationSizeSettings poiSize
Definition: GUIVisualizationSettings.h:604
GUIPointOfInterest.h
Shape::getShapeLayer
double getShapeLayer() const
Returns the layer of the Shape.
Definition: Shape.h:89
GUIPropertySchemeStorage::getScheme
T & getScheme()
Definition: GUIPropertySchemeStorage.h:79
GUIParameterTableWindow::mkItem
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
Definition: GUIParameterTableWindow.h:108
GUITexturesHelper.h
GLHelper::drawFilledCircleReturnVertices
static std::vector< Position > drawFilledCircleReturnVertices(double width, int steps=8)
Draws a filled circle around (0,0) returning circle vertex.
Definition: GLHelper.cpp:354
GUIPointOfInterest::drawInnerPOI
void drawInnerPOI(const GUIVisualizationSettings &s, bool forceSelectionColor) const
draw inner POI (before pushName() )
Definition: GUIPointOfInterest.cpp:140
GUIGlObject::getGlID
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.cpp:149
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
GUIVisualizationSettings::scale
double scale
information about a lane's width (temporary, used for a single view)
Definition: GUIVisualizationSettings.h:632
PointOfInterest::myHalfImgHeight
double myHalfImgHeight
The half height of the image when rendering this POI.
Definition: PointOfInterest.h:191
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
Position::x
double x() const
Returns the x-position.
Definition: Position.h:56
Boundary::add
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:78
GLO_POI
a poi
Definition: GUIGlObjectTypes.h:106
Shape::getShapeType
const std::string & getShapeType() const
Returns the (abstract) type of the Shape.
Definition: Shape.h:75
GUIVisualizationTextSettings::show
bool show
flag show
Definition: GUIVisualizationSettings.h:68
GUIPointOfInterest::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUIPointOfInterest.cpp:97
GUIPointOfInterest::myPOIVertices
static std::vector< Position > myPOIVertices
after every iteration of drawgl, position of vertices that make the circle are saved here....
Definition: GUIPointOfInterest.h:125
GUIVisualizationSizeSettings::minSize
double minSize
The minimum size to draw this object.
Definition: GUIVisualizationSettings.h:103
Boundary::growWidth
void growWidth(double by)
Increases the width of the boundary (x-axis)
Definition: Boundary.cpp:309
GUIPointOfInterest::getParameterWindow
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUIPointOfInterest.cpp:72
GUIIconSubSys.h
GLIncludes.h
GUIVisualizationSettings::poiType
GUIVisualizationTextSettings poiType
Definition: GUIVisualizationSettings.h:610
GUIVisualizationSettings::poiName
GUIVisualizationTextSettings poiName
Definition: GUIVisualizationSettings.h:607
GUIMainWindow
Definition: GUIMainWindow.h:46
Position::y
double y() const
Returns the y-position.
Definition: Position.h:61
GUIPointOfInterest::~GUIPointOfInterest
virtual ~GUIPointOfInterest()
Destructor.
Definition: GUIPointOfInterest.cpp:59
GUIGlObject::buildShapePopupOptions
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
Definition: GUIGlObject.cpp:302
gSelected
GUISelectedStorage gSelected
A global holder of selected objects.
Definition: GUIGlobalSelection.cpp:33
GUIVisualizationTextSettings::size
double size
text size
Definition: GUIVisualizationSettings.h:71
config.h
GUIPointOfInterest::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUIPointOfInterest.cpp:83
PointOfInterest
A point-of-interest.
Definition: PointOfInterest.h:43
Boundary::grow
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:300
GUIVisualizationSettings::poiColorer
GUIColorer poiColorer
The POI colorer.
Definition: GUIVisualizationSettings.h:601
Shape::DEFAULT_IMG_FILE
static const std::string DEFAULT_IMG_FILE
Definition: Shape.h:47
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:345
GUITexturesHelper::getTextureID
static int getTextureID(const std::string &filename, const bool mirrorX=false)
return texture id for the given filename (initialize on first use)
Definition: GUITexturesHelper.cpp:112
GUIPropertyScheme::getColor
const T getColor(const double value) const
Definition: GUIPropertyScheme.h:110
GUIPropertySchemeStorage::getActive
int getActive() const
Definition: GUIPropertySchemeStorage.h:75
GUIVisualizationSizeSettings::getExaggeration
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
Definition: GUIVisualizationSettings.cpp:212
Boundary::growHeight
void growHeight(double by)
Increases the height of the boundary (y-axis)
Definition: Boundary.cpp:316
GUIPropertySchemeStorage< GUIColorScheme >
GUISelectedStorage::isSelected
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
Definition: GUISelectedStorage.cpp:94
Position::Position
Position()
default constructor
Definition: Position.h:41