|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // The gui-version of the MSInstantInductLoop 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This file is part of SUMO. 00014 // SUMO is free software: you can redistribute it and/or modify 00015 // it under the terms of the GNU General Public License as published by 00016 // the Free Software Foundation, either version 3 of the License, or 00017 // (at your option) any later version. 00018 // 00019 /****************************************************************************/ 00020 00021 00022 // =========================================================================== 00023 // included modules 00024 // =========================================================================== 00025 #ifdef _MSC_VER 00026 #include <windows_config.h> 00027 #else 00028 #include <config.h> 00029 #endif 00030 00031 #include <microsim/output/MSInstantInductLoop.h> 00032 #include <utils/gui/globjects/GUIGlObject.h> 00033 #include <utils/geom/PositionVector.h> 00034 #include "GUILaneWrapper.h" 00035 #include "GUIInstantInductLoop.h" 00036 #include <utils/gui/div/GLHelper.h> 00037 #include <utils/geom/Line.h> 00038 #include <utils/gui/div/GUIParameterTableWindow.h> 00039 #include <microsim/logging/FuncBinding_IntParam.h> 00040 #include <microsim/logging/FunctionBinding.h> 00041 #include <microsim/MSLane.h> 00042 #include "GUIEdge.h" 00043 00044 #ifdef _WIN32 00045 #include <windows.h> 00046 #endif 00047 00048 #include <GL/gl.h> 00049 00050 #ifdef CHECK_MEMORY_LEAKS 00051 #include <foreign/nvwa/debug_new.h> 00052 #endif // CHECK_MEMORY_LEAKS 00053 00054 00055 // =========================================================================== 00056 // method definitions 00057 // =========================================================================== 00058 /* ------------------------------------------------------------------------- 00059 * GUIInstantInductLoop-methods 00060 * ----------------------------------------------------------------------- */ 00061 GUIInstantInductLoop::GUIInstantInductLoop(const std::string& id, OutputDevice& od, 00062 MSLane* const lane, SUMOReal positionInMeters) 00063 : MSInstantInductLoop(id, od, lane, positionInMeters) {} 00064 00065 00066 GUIInstantInductLoop::~GUIInstantInductLoop() {} 00067 00068 00069 GUIDetectorWrapper* 00070 GUIInstantInductLoop::buildDetectorGUIRepresentation() { 00071 return new MyWrapper(*this, static_cast<GUIEdge&>(getLane()->getEdge()).getLaneGeometry(getLane()), myPosition); 00072 } 00073 00074 00075 /* ------------------------------------------------------------------------- 00076 * GUIInstantInductLoop::MyWrapper-methods 00077 * ----------------------------------------------------------------------- */ 00078 GUIInstantInductLoop::MyWrapper::MyWrapper(GUIInstantInductLoop& detector, 00079 GUILaneWrapper& wrapper, SUMOReal pos) 00080 : GUIDetectorWrapper("instant induct loop", detector.getID()), 00081 myDetector(detector), myPosition(pos) { 00082 const PositionVector& v = wrapper.getShape(); 00083 myFGPosition = v.positionAtLengthPosition(pos); 00084 Line l(v.getBegin(), v.getEnd()); 00085 SUMOReal sgPos = pos / v.length() * l.length(); 00086 myBoundary.add(myFGPosition.x() + (SUMOReal) 5.5, myFGPosition.y() + (SUMOReal) 5.5); 00087 myBoundary.add(myFGPosition.x() - (SUMOReal) 5.5, myFGPosition.y() - (SUMOReal) 5.5); 00088 myFGRotation = -v.rotationDegreeAtLengthPosition(pos); 00089 } 00090 00091 00092 GUIInstantInductLoop::MyWrapper::~MyWrapper() {} 00093 00094 00095 Boundary 00096 GUIInstantInductLoop::MyWrapper::getCenteringBoundary() const { 00097 Boundary b(myBoundary); 00098 b.grow(20); 00099 return b; 00100 } 00101 00102 00103 00104 GUIParameterTableWindow* 00105 GUIInstantInductLoop::MyWrapper::getParameterWindow(GUIMainWindow& app, 00106 GUISUMOAbstractView& /*parent !!! recheck this - never needed?*/) { 00107 GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this, 7); 00108 // add items 00109 // parameter 00110 ret->mkItem("position [m]", false, myPosition); 00111 ret->mkItem("lane", false, myDetector.getLane()->getID()); 00112 // values 00113 // close building 00114 ret->closeBuilding(); 00115 return ret; 00116 } 00117 00118 00119 void 00120 GUIInstantInductLoop::MyWrapper::drawGL(const GUIVisualizationSettings& s) const { 00121 glPushName(getGlID()); 00122 SUMOReal width = (SUMOReal) 2.0 * s.scale; 00123 glLineWidth(1.0); 00124 // shape 00125 glColor3d(1, 0, 1); 00126 glPushMatrix(); 00127 glTranslated(0, 0, getType()); 00128 glTranslated(myFGPosition.x(), myFGPosition.y(), 0); 00129 glRotated(myFGRotation, 0, 0, 1); 00130 glScaled(s.addExaggeration, s.addExaggeration, 1); 00131 glBegin(GL_QUADS); 00132 glVertex2d(0 - 1.0, 2); 00133 glVertex2d(-1.0, -2); 00134 glVertex2d(1.0, -2); 00135 glVertex2d(1.0, 2); 00136 glEnd(); 00137 glTranslated(0, 0, .01); 00138 glBegin(GL_LINES); 00139 glVertex2d(0, 2 - .1); 00140 glVertex2d(0, -2 + .1); 00141 glEnd(); 00142 00143 // outline 00144 if (width * s.addExaggeration > 1) { 00145 glColor3d(1, 1, 1); 00146 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 00147 glBegin(GL_QUADS); 00148 glVertex2f(0 - 1.0, 2); 00149 glVertex2f(-1.0, -2); 00150 glVertex2f(1.0, -2); 00151 glVertex2f(1.0, 2); 00152 glEnd(); 00153 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); 00154 } 00155 00156 // position indicator 00157 if (width * s.addExaggeration > 1) { 00158 glRotated(90, 0, 0, -1); 00159 glColor3d(1, 1, 1); 00160 glBegin(GL_LINES); 00161 glVertex2d(0, 1.7); 00162 glVertex2d(0, -1.7); 00163 glEnd(); 00164 } 00165 glPopMatrix(); 00166 drawName(getCenteringBoundary().getCenter(), s.scale, s.addName); 00167 glPopName(); 00168 } 00169 00170 00171 GUIInstantInductLoop& 00172 GUIInstantInductLoop::MyWrapper::getLoop() { 00173 return myDetector; 00174 } 00175 00176 00177 00178 /****************************************************************************/ 00179