SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUIChrgStn.cpp
Go to the documentation of this file.
1 /****************************************************************************/
11 // A lane area vehicles can halt at (gui-version)
12 /****************************************************************************/
13 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
14 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
15 /****************************************************************************/
16 //
17 // This file is part of SUMO.
18 // SUMO is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 /****************************************************************************/
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <string>
38 #include <utils/geom/Line.h>
39 #include <utils/geom/Boundary.h>
40 #include <utils/gui/div/GLHelper.h>
41 #include <utils/common/ToString.h>
42 #include <microsim/MSNet.h>
43 #include <microsim/MSLane.h>
44 #include <microsim/MSEdge.h>
45 #include "GUINet.h"
46 #include "GUIEdge.h"
47 #include "GUIPerson.h"
48 #include "GUIChrgStn.h"
51 #include <gui/GUIGlobals.h>
57 #include <utils/geom/GeomHelper.h>
59 
60 #ifdef CHECK_MEMORY_LEAKS
61 #include <foreign/nvwa/debug_new.h>
62 #endif // CHECK_MEMORY_LEAKS
63 
64 
65 // ===========================================================================
66 // method definitions
67 // ===========================================================================
68 GUIChrgStn::GUIChrgStn(const std::string& id, const std::vector<std::string>& lines, MSLane& lane,
69  SUMOReal frompos, SUMOReal topos, SUMOReal new_chrgpower, SUMOReal new_efficiency, SUMOReal new_ChargeInTransit, SUMOReal new_ChargeDelay)
70  : MSChrgStn(id, lines, lane, frompos, topos, new_chrgpower, new_efficiency, new_ChargeInTransit, new_ChargeDelay),
71  GUIGlObject_AbstractAdd("chargingStation", GLO_TRIGGER, id) {
72  myFGShape = lane.getShape();
73  myFGShape = myFGShape.getSubpart(frompos, topos);
74  myFGShapeRotations.reserve(myFGShape.size() - 1);
75  myFGShapeLengths.reserve(myFGShape.size() - 1);
76  int e = (int) myFGShape.size() - 1;
77  for (int i = 0; i < e; ++i) {
78  const Position& f = myFGShape[i];
79  const Position& s = myFGShape[i + 1];
80  myFGShapeLengths.push_back(f.distanceTo(s));
81  myFGShapeRotations.push_back((SUMOReal) atan2((s.x() - f.x()), (f.y() - s.y())) * (SUMOReal) 180.0 / (SUMOReal) PI);
82  }
84  tmp.move2side(1.5);
85  myFGSignPos = tmp.getLineCenter();
86  myFGSignRot = 0;
87  if (tmp.length() != 0) {
89  myFGSignRot -= 90;
90  }
91 
92  chrgpower = new_chrgpower;
93  efficiency = new_efficiency;
94  chargeInTransit = new_ChargeInTransit;
95  chargeDelay = new_ChargeDelay;
96 }
97 
98 
100 {}
101 
102 
106  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this, 6);
107 
108  // add items
109  ret->mkItem("begin position [m]", false, myBegPos);
110  ret->mkItem("end position [m]", false, myEndPos);
111  ret->mkItem("charging power [W]", false, chrgpower);
112  ret->mkItem("charging efficiency []", false, efficiency);
113  ret->mkItem("charge in transit [0/1]", false, chargeInTransit);
114  ret->mkItem("charge delay [s]", false, chargeDelay);
115 
116  // close building
117  ret->closeBuilding();
118  return ret;
119 }
120 
121 
124  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
125  buildPopupHeader(ret, app);
130  buildPositionCopyEntry(ret, false);
131  return ret;
132 }
133 
134 Boundary
137  b.grow(20);
138  return b;
139 }
140 
141 
142 void
144 
145  glPushName(getGlID());
146  glPushMatrix();
147  RGBColor blue(114, 210, 252, 255);
148  RGBColor green(76, 170, 50, 255);
149  RGBColor yellow(255, 235, 0, 255);
150  // draw the area
151  glTranslated(0, 0, getType());
152  GLHelper::setColor(blue);
154 
155  // draw details unless zoomed out to far
156  const SUMOReal exaggeration = s.addSize.getExaggeration(s);
157  if (s.scale * exaggeration >= 10) {
178  // draw the sign
179  glTranslated(myFGSignPos.x(), myFGSignPos.y(), 0);
180  int noPoints = 9;
181  if (s.scale * exaggeration > 25) {
182  noPoints = MIN2((int)(9.0 + (s.scale * exaggeration) / 10.0), 36);
183  }
184 
185  glScaled(exaggeration, exaggeration, 1);
186  GLHelper::setColor(blue);
187  GLHelper::drawFilledCircle((SUMOReal) 1.1, noPoints);
188  glTranslated(0, 0, .1);
189 
190  GLHelper::setColor(yellow);
191  GLHelper::drawFilledCircle((SUMOReal) 0.9, noPoints);
192 
193  if (s.scale * exaggeration >= 4.5) {
194  GLHelper::drawText("C", Position(), .1, 1.6 * exaggeration, green, myFGSignRot);
195  }
196 
228  glTranslated(5, 0, 0);
229 
230  }
231  glPopMatrix();
232  glPopName();
233  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
234  // there should be no persons on a chargingStation
235  //for (std::vector<MSPerson*>::const_iterator i = myWaitingPersons.begin(); i != myWaitingPersons.end(); ++i) {
236  // glTranslated(0, 1, 0); // make multiple persons viewable
237  // static_cast<GUIPerson*>(*i)->drawGL(s);
238  //}
239 
240 }
241 
242 /****************************************************************************/
a lane speed trigger,
Position myFGSignPos
The position of the sign.
Definition: GUIChrgStn.h:160
GUIVisualizationTextSettings addName
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
std::vector< SUMOReal > myFGShapeLengths
The lengths of the shape parts.
Definition: GUIChrgStn.h:154
Stores the information about how to visualize structures.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GUIChrgStn.cpp:123
static void drawBoxLines(const PositionVector &geom, const std::vector< SUMOReal > &rots, const std::vector< SUMOReal > &lengths, SUMOReal width, int cornerDetail=0, SUMOReal offset=0)
Draws thick lines.
Definition: GLHelper.cpp:176
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
std::vector< SUMOReal > myFGShapeRotations
The rotations of the shape parts.
Definition: GUIChrgStn.h:151
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUIChrgStn.cpp:104
SUMOReal distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:229
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:459
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
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:115
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
SUMOReal efficiency
efficiency of the Charging Station
Definition: GUIChrgStn.h:141
SUMOReal scale
information about a lane&#39;s width (temporary, used for a single view)
static void drawFilledCircle(SUMOReal width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:344
GUIVisualizationSizeSettings addSize
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Definition: GUIGlObject.h:159
#define PI
Definition: polyfonts.c:61
PositionVector myFGShape
The shape.
Definition: GUIChrgStn.h:157
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:442
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUIChrgStn.cpp:143
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
SUMOReal myEndPos
The end position this bus stop is located at.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUIChrgStn.cpp:135
A list of positions.
SUMOReal chrgpower
chrgpower of the Charging Station
Definition: GUIChrgStn.h:138
SUMOReal myBegPos
The begin position this bus stop is located at.
T MIN2(T a, T b)
Definition: StdDefs.h:68
void drawName(const Position &pos, const SUMOReal scale, const GUIVisualizationTextSettings &settings, const SUMOReal angle=0) const
SUMOReal length() const
Returns the length.
SUMOReal rotationDegreeAtOffset(SUMOReal pos) const
Returns the rotation at the given length.
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
Definition: Boundary.cpp:200
GUIChrgStn(const std::string &id, const std::vector< std::string > &lines, MSLane &lane, SUMOReal frompos, SUMOReal topos, SUMOReal new_chrgpower, SUMOReal new_efficiency, SUMOReal new_ChargeInTransit, SUMOReal new_ChargeDelay)
Constructor.
Definition: GUIChrgStn.cpp:68
SUMOReal myFGSignRot
The rotation of the sign.
Definition: GUIChrgStn.h:163
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
The popup menu of a globject.
SUMOReal chargeInTransit
allow charge in transit
Definition: GUIChrgStn.h:144
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
SUMOReal chargeDelay
charge delay
Definition: GUIChrgStn.h:147
Position getLineCenter() const
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:323
void move2side(SUMOReal amount)
#define SUMOReal
Definition: config.h:215
~GUIChrgStn()
Destructor.
Definition: GUIChrgStn.cpp:99
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
void mkItem(const char *name, bool dynamic, ValueSource< unsigned > *src)
Adds a row which obtains its value from an unsigned-ValueSource.
void closeBuilding()
Closes the building of the table.
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
A window containing a gl-object&#39;s parameter.
PositionVector getSubpart(SUMOReal beginOffset, SUMOReal endOffset) const
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.