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