00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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/Position2DVector.h>
00039 #include <utils/geom/Line2D.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 <utils/gui/globjects/GUIGlObjectStorage.h>
00058 #include <foreign/polyfonts/polyfonts.h>
00059 #include <utils/geom/GeomHelper.h>
00060 #include <gui/GUIApplicationWindow.h>
00061 #include <guisim/GUIBusStop.h>
00062
00063 #ifdef CHECK_MEMORY_LEAKS
00064 #include <foreign/nvwa/debug_new.h>
00065 #endif // CHECK_MEMORY_LEAKS
00066
00067
00068
00069
00070
00071 GUIBusStop::GUIBusStop(const std::string &id, MSNet &,
00072 const std::vector<std::string> &lines, MSLane &lane,
00073 SUMOReal frompos, SUMOReal topos) throw()
00074 : MSBusStop(id, lines, lane, frompos, topos),
00075 GUIGlObject_AbstractAdd(GUIGlObjectStorage::gIDStorage, "bus_stop:" + id, GLO_TRIGGER) {
00076 myFGShape = lane.getShape();
00077 myFGShape.move2side((SUMOReal) 1.65);
00078 myFGShape = myFGShape.getSubpart(frompos, topos);
00079 myFGShapeRotations.reserve(myFGShape.size()-1);
00080 myFGShapeLengths.reserve(myFGShape.size()-1);
00081 int e = (int) myFGShape.size() - 1;
00082 for (int i=0; i<e; ++i) {
00083 const Position2D &f = myFGShape[i];
00084 const Position2D &s = myFGShape[i+1];
00085 myFGShapeLengths.push_back(f.distanceTo(s));
00086 myFGShapeRotations.push_back((SUMOReal) atan2((s.x()-f.x()), (f.y()-s.y()))*(SUMOReal) 180.0/(SUMOReal) PI);
00087 }
00088 Position2DVector tmp = myFGShape;
00089 tmp.move2side(1.5);
00090 myFGSignPos = tmp.getLineCenter();
00091 myFGSignRot = 0;
00092 if (tmp.length()!=0) {
00093 myFGSignRot = myFGShape.rotationDegreeAtLengthPosition(SUMOReal((myFGShape.length() / 2.)));
00094 myFGSignRot -= 90;
00095 }
00096 }
00097
00098
00099 GUIBusStop::~GUIBusStop() throw() {}
00100
00101
00102 GUIGLObjectPopupMenu *
00103 GUIBusStop::getPopUpMenu(GUIMainWindow &app,
00104 GUISUMOAbstractView &parent) throw() {
00105 GUIGLObjectPopupMenu *ret = new GUIGLObjectPopupMenu(app, parent, *this);
00106 buildPopupHeader(ret, app);
00107 buildCenterPopupEntry(ret);
00108 buildNameCopyPopupEntry(ret);
00109 buildSelectionPopupEntry(ret);
00110 buildPositionCopyEntry(ret, false);
00111 return ret;
00112 }
00113
00114
00115 GUIParameterTableWindow *
00116 GUIBusStop::getParameterWindow(GUIMainWindow &,
00117 GUISUMOAbstractView &) throw() {
00118 return 0;
00119 }
00120
00121
00122 const std::string &
00123 GUIBusStop::getMicrosimID() const throw() {
00124 return getID();
00125 }
00126
00127
00128 void
00129 GUIBusStop::drawGL(const GUIVisualizationSettings &s) const throw() {
00130
00131 if (s.needsGlID) {
00132 glPushName(getGlID());
00133 }
00134 glTranslated(0, 0, -.03);
00135
00136 glColor3d(76./255., 170./255., 50./255.);
00137 size_t i;
00138 GLHelper::drawBoxLines(myFGShape, myFGShapeRotations, myFGShapeLengths, 1.0);
00139
00140 if (s.scale*s.addExaggeration>=10) {
00141 glTranslated(0, 0, -.01);
00142 glColor3d(76./255., 170./255., 50./255.);
00143 for (i=0; i!=myLines.size(); ++i) {
00144 glPushMatrix();
00145 glTranslated(myFGSignPos.x(), myFGSignPos.y(), 0);
00146 glRotated(180, 1, 0, 0);
00147 glRotated(myFGSignRot, 0, 0, 1);
00148 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
00149 pfSetPosition(0, 0);
00150 pfSetScale(1.f);
00151 glScaled(s.addExaggeration, s.addExaggeration, 1);
00152 glTranslated(1.2, -(double)i, 0);
00153 pfDrawString(myLines[i].c_str());
00154 glPopMatrix();
00155 }
00156 glTranslated(0, 0, .01);
00157 }
00158
00159
00160 glPushMatrix();
00161 glTranslated(myFGSignPos.x(), myFGSignPos.y(), 0);
00162 int noPoints = 9;
00163 if (s.scale*s.addExaggeration>25) {
00164 noPoints = (int)(9.0 + (s.scale*s.addExaggeration) / 10.0);
00165 if (noPoints>36) {
00166 noPoints = 36;
00167 }
00168 }
00169 glScaled(s.addExaggeration, s.addExaggeration, 1);
00170 glColor3d(76./255., 170./255., 50./255.);
00171 GLHelper::drawFilledCircle((SUMOReal) 1.1, noPoints);
00172 if (s.scale*s.addExaggeration>=10) {
00173 glTranslated(0, 0, -.01);
00174 glColor3d(255./255., 235./255., 0./255.);
00175 GLHelper::drawFilledCircle((SUMOReal) 0.9, noPoints);
00176 glTranslated(0, 0, .01);
00177
00178
00179 if (s.scale*s.addExaggeration>=4.5) {
00180 glColor3d(76./255., 170./255., 50./255.);
00181 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
00182 glRotated(180, 1, 0, 0);
00183 glRotated(myFGSignRot, 0, 0, 1);
00184 glTranslated(0, 0, .02);
00185 pfSetPosition(0, 0);
00186 pfSetScale(1.6f);
00187 SUMOReal w = pfdkGetStringWidth("H");
00188 glTranslated(-w/2., 0.4, 0);
00189 pfDrawString("H");
00190 glTranslated(0, 0, -.02);
00191 }
00192 }
00193 glPopMatrix();
00194 glTranslated(0, 0, .03);
00195
00196 if (s.drawAddName) {
00197 drawGLName(getCenteringBoundary().getCenter(), getMicrosimID(), s.addNameSize / s.scale);
00198 }
00199
00200 if (s.needsGlID) {
00201 glPopName();
00202 }
00203 }
00204
00205
00206 Boundary
00207 GUIBusStop::getCenteringBoundary() const throw() {
00208 Boundary b = myFGShape.getBoxBoundary();
00209 b.grow(20);
00210 return b;
00211 }
00212
00213
00214
00215
00216