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 /****************************************************************************/
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, false);
107  // pop name
108  glPopName();
109  }
110 }
111 
112 
113 void
114 GUIPointOfInterest::setColor(const GUIVisualizationSettings& s, bool disableSelectionColor) const {
115  const GUIColorer& c = s.poiColorer;
116  const int active = c.getActive();
117  if (s.netedit && active != 1 && gSelected.isSelected(GLO_POI, getGlID()) && disableSelectionColor) {
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
141 GUIPointOfInterest::drawInnerPOI(const GUIVisualizationSettings& s, bool disableSelectionColor) const {
142  const double exaggeration = s.poiSize.getExaggeration(s, this);
143  glPushMatrix();
144  setColor(s, disableSelectionColor);
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 
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:701
GUIParameterTableWindow
A window containing a gl-object's parameter.
Definition: GUIParameterTableWindow.h:63
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:73
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:355
Shape::getShapeNaviDegree
double getShapeNaviDegree() const
Returns the angle of the Shape in navigational degrees.
Definition: Shape.h:97
GUIVisualizationSettings::angle
double angle
The current view rotation angle.
Definition: GUIVisualizationSettings.h:403
GUIGLObjectPopupMenu.h
GUIGlobalSelection.h
GUIPointOfInterest::getPopUpMenu
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GUIPointOfInterest.cpp:64
GUIPointOfInterest::checkDraw
bool checkDraw(const GUIVisualizationSettings &s) const
check if POI can be drawn
Definition: GUIPointOfInterest.cpp:131
GUIVisualizationSettings::netedit
bool netedit
Whether the settings are for Netedit.
Definition: GUIVisualizationSettings.h:400
Shape::getShapeImgFile
const std::string & getShapeImgFile() const
Returns the imgFile of the Shape.
Definition: Shape.h:104
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:50
GUIGlObject_AbstractAdd
Definition: GUIGlObject_AbstractAdd.h:40
GUIGLObjectPopupMenu
The popup menu of a globject.
Definition: GUIGLObjectPopupMenu.h:48
GLHelper::setColor
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:616
Shape::getShapeColor
const RGBColor & getShapeColor() const
Returns the color of the Shape.
Definition: Shape.h:83
GUIParameterTableWindow::closeBuilding
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
Definition: GUIParameterTableWindow.cpp:220
GUITexturesHelper::drawTexturedBox
static void drawTexturedBox(int which, double size)
Draws a named texture as a box with the given size.
Definition: GUITexturesHelper.cpp:73
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:40
Parameterised::getParametersMap
const std::map< std::string, std::string > & getParametersMap() const
Returns the inner key/value map.
Definition: Parameterised.cpp:105
PointOfInterest::myHalfImgWidth
double myHalfImgWidth
The half width of the image when rendering this POI.
Definition: PointOfInterest.h:189
GUIPointOfInterest::setColor
void setColor(const GUIVisualizationSettings &s, bool forceSelectionColor) const
set color
Definition: GUIPointOfInterest.cpp:114
GUIVisualizationSettings::poiSize
GUIVisualizationSizeSettings poiSize
Definition: GUIVisualizationSettings.h:595
GUIPointOfInterest.h
Shape::getShapeLayer
double getShapeLayer() const
Returns the layer of the Shape.
Definition: Shape.h:90
GUIPropertySchemeStorage::getScheme
T & getScheme()
Definition: GUIPropertySchemeStorage.h:80
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:109
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:141
GUIGlObject::getGlID
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.cpp:150
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
GUIVisualizationSettings::scale
double scale
information about a lane's width (temporary, used for a single view)
Definition: GUIVisualizationSettings.h:623
PointOfInterest::myHalfImgHeight
double myHalfImgHeight
The half height of the image when rendering this POI.
Definition: PointOfInterest.h:192
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
Position::x
double x() const
Returns the x-position.
Definition: Position.h:57
Boundary::add
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:79
GLO_POI
a poi
Definition: GUIGlObjectTypes.h:107
Shape::getShapeType
const std::string & getShapeType() const
Returns the (abstract) type of the Shape.
Definition: Shape.h:76
GUIVisualizationTextSettings::show
bool show
flag show
Definition: GUIVisualizationSettings.h:69
GUIPointOfInterest::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUIPointOfInterest.cpp:98
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:126
GUIVisualizationSizeSettings::minSize
double minSize
The minimum size to draw this object.
Definition: GUIVisualizationSettings.h:104
Boundary::growWidth
void growWidth(double by)
Increases the width of the boundary (x-axis)
Definition: Boundary.cpp:310
GUIPointOfInterest::getParameterWindow
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUIPointOfInterest.cpp:73
GUIIconSubSys.h
GLIncludes.h
GUIVisualizationSettings::poiType
GUIVisualizationTextSettings poiType
Definition: GUIVisualizationSettings.h:601
GUIVisualizationSettings::poiName
GUIVisualizationTextSettings poiName
Definition: GUIVisualizationSettings.h:598
GUIMainWindow
Definition: GUIMainWindow.h:47
Position::y
double y() const
Returns the y-position.
Definition: Position.h:62
GUIPointOfInterest::~GUIPointOfInterest
virtual ~GUIPointOfInterest()
Destructor.
Definition: GUIPointOfInterest.cpp:60
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:303
gSelected
GUISelectedStorage gSelected
A global holder of selected objects.
Definition: GUIGlobalSelection.cpp:34
GUIVisualizationTextSettings::size
double size
text size
Definition: GUIVisualizationSettings.h:72
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:84
PointOfInterest
A point-of-interest.
Definition: PointOfInterest.h:44
Boundary::grow
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:301
GUIVisualizationSettings::poiColorer
GUIColorer poiColorer
The POI colorer.
Definition: GUIVisualizationSettings.h:592
Shape::DEFAULT_IMG_FILE
static const std::string DEFAULT_IMG_FILE
Definition: Shape.h:48
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:346
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:113
GUIPropertyScheme::getColor
const T getColor(const double value) const
Definition: GUIPropertyScheme.h:111
GUIPropertySchemeStorage::getActive
int getActive() const
Definition: GUIPropertySchemeStorage.h:76
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:317
GUIPropertySchemeStorage< GUIColorScheme >
GUIVisualizationSettings::drawForSelecting
bool drawForSelecting
whether drawing is performed for the purpose of selecting objects
Definition: GUIVisualizationSettings.h:635
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:95
Position::Position
Position()
default constructor
Definition: Position.h:42