|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // A lane area vehicles can halt at (gui-version) 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This program is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU General Public License as published by 00015 // the Free Software Foundation; either version 2 of the License, or 00016 // (at your option) any later version. 00017 // 00018 /****************************************************************************/ 00019 00020 00021 // =========================================================================== 00022 // included modules 00023 // =========================================================================== 00024 #ifdef _MSC_VER 00025 #include <windows_config.h> 00026 #else 00027 #include <config.h> 00028 #endif 00029 00030 #ifdef _WIN32 00031 #include <windows.h> 00032 #endif 00033 00034 #include <GL/gl.h> 00035 00036 #include <string> 00037 #include <utils/common/MsgHandler.h> 00038 #include <utils/geom/PositionVector.h> 00039 #include <utils/geom/Line.h> 00040 #include <utils/geom/Boundary.h> 00041 #include <utils/gui/div/GLHelper.h> 00042 #include <utils/common/ToString.h> 00043 #include <microsim/MSNet.h> 00044 #include <microsim/MSLane.h> 00045 #include <microsim/MSEdge.h> 00046 #include <guisim/GUINet.h> 00047 #include <guisim/GUIEdge.h> 00048 #include "GUIBusStop.h" 00049 #include <utils/gui/globjects/GUIGLObjectPopupMenu.h> 00050 #include <utils/gui/windows/GUIAppEnum.h> 00051 #include <gui/GUIGlobals.h> 00052 #include <utils/gui/div/GUIParameterTableWindow.h> 00053 #include <gui/GUIApplicationWindow.h> 00054 #include <utils/gui/images/GUITexturesHelper.h> 00055 #include <microsim/logging/FunctionBinding.h> 00056 #include <utils/gui/div/GUIGlobalSelection.h> 00057 #include <foreign/polyfonts/polyfonts.h> 00058 #include <utils/geom/GeomHelper.h> 00059 #include <gui/GUIApplicationWindow.h> 00060 #include <guisim/GUIBusStop.h> 00061 00062 #ifdef CHECK_MEMORY_LEAKS 00063 #include <foreign/nvwa/debug_new.h> 00064 #endif // CHECK_MEMORY_LEAKS 00065 00066 00067 // =========================================================================== 00068 // method definitions 00069 // =========================================================================== 00070 GUIBusStop::GUIBusStop(const std::string& id, const std::vector<std::string> &lines, MSLane& lane, 00071 SUMOReal frompos, SUMOReal topos) throw() 00072 : MSBusStop(id, lines, lane, frompos, topos), 00073 GUIGlObject_AbstractAdd("bus_stop", GLO_TRIGGER, id) { 00074 myFGShape = lane.getShape(); 00075 myFGShape.move2side((SUMOReal) 1.65); 00076 myFGShape = myFGShape.getSubpart(frompos, topos); 00077 myFGShapeRotations.reserve(myFGShape.size()-1); 00078 myFGShapeLengths.reserve(myFGShape.size()-1); 00079 int e = (int) myFGShape.size() - 1; 00080 for (int i=0; i<e; ++i) { 00081 const Position& f = myFGShape[i]; 00082 const Position& s = myFGShape[i+1]; 00083 myFGShapeLengths.push_back(f.distanceTo(s)); 00084 myFGShapeRotations.push_back((SUMOReal) atan2((s.x()-f.x()), (f.y()-s.y()))*(SUMOReal) 180.0/(SUMOReal) PI); 00085 } 00086 PositionVector tmp = myFGShape; 00087 tmp.move2side(1.5); 00088 myFGSignPos = tmp.getLineCenter(); 00089 myFGSignRot = 0; 00090 if (tmp.length()!=0) { 00091 myFGSignRot = myFGShape.rotationDegreeAtLengthPosition(SUMOReal((myFGShape.length() / 2.))); 00092 myFGSignRot -= 90; 00093 } 00094 } 00095 00096 00097 GUIBusStop::~GUIBusStop() throw() {} 00098 00099 00100 GUIGLObjectPopupMenu* 00101 GUIBusStop::getPopUpMenu(GUIMainWindow& app, 00102 GUISUMOAbstractView& parent) throw() { 00103 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this); 00104 buildPopupHeader(ret, app); 00105 buildCenterPopupEntry(ret); 00106 buildNameCopyPopupEntry(ret); 00107 buildSelectionPopupEntry(ret); 00108 buildPositionCopyEntry(ret, false); 00109 return ret; 00110 } 00111 00112 00113 GUIParameterTableWindow* 00114 GUIBusStop::getParameterWindow(GUIMainWindow&, 00115 GUISUMOAbstractView&) throw() { 00116 return 0; 00117 } 00118 00119 00120 void 00121 GUIBusStop::drawGL(const GUIVisualizationSettings& s) const throw() { 00122 glPushName(getGlID()); 00123 glPushMatrix(); 00124 RGBColor green(76./255., 170./255., 50./255.); 00125 RGBColor yellow(255./255., 235./255., 0./255.); 00126 // draw the area 00127 size_t i; 00128 glTranslated(0, 0, getType()); 00129 GLHelper::setColor(green); 00130 GLHelper::drawBoxLines(myFGShape, myFGShapeRotations, myFGShapeLengths, 1.0); 00131 // draw details unless zoomed out to far 00132 if (s.scale* s.addExaggeration>=10) { 00133 // draw the lines 00134 for (i=0; i!=myLines.size(); ++i) { 00135 glPushMatrix(); 00136 glTranslated(myFGSignPos.x(), myFGSignPos.y(), 0); 00137 glRotated(180, 1, 0, 0); 00138 glRotated(myFGSignRot, 0, 0, 1); 00139 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); 00140 pfSetPosition(0, 0); 00141 pfSetScale(1.f); 00142 glScaled(s.addExaggeration, s.addExaggeration, 1); 00143 glTranslated(1.2, -(double)i, 0); 00144 pfDrawString(myLines[i].c_str()); 00145 glPopMatrix(); 00146 } 00147 // draw the sign 00148 glTranslated(myFGSignPos.x(), myFGSignPos.y(), 0); 00149 int noPoints = 9; 00150 if (s.scale*s.addExaggeration>25) { 00151 noPoints = MIN2((int)(9.0 + (s.scale*s.addExaggeration) / 10.0), 36); 00152 } 00153 glScaled(s.addExaggeration, s.addExaggeration, 1); 00154 GLHelper::drawFilledCircle((SUMOReal) 1.1, noPoints); 00155 glTranslated(0, 0, .1); 00156 GLHelper::setColor(yellow); 00157 GLHelper::drawFilledCircle((SUMOReal) 0.9, noPoints); 00158 if (s.scale* s.addExaggeration>=4.5) { 00159 GLHelper::drawText("H", Position(), .1, 1.6 * s.addExaggeration, green, myFGSignRot); 00160 } 00161 } 00162 glPopMatrix(); 00163 drawName(getCenteringBoundary().getCenter(), s.scale, s.addName); 00164 glPopName(); 00165 } 00166 00167 00168 Boundary 00169 GUIBusStop::getCenteringBoundary() const throw() { 00170 Boundary b = myFGShape.getBoxBoundary(); 00171 b.grow(20); 00172 return b; 00173 } 00174 00175 00176 00177 /****************************************************************************/ 00178