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 <utils/gui/globjects/GUIGlObject.h> 00032 #include <utils/geom/PositionVector.h> 00033 #include "GUILaneWrapper.h" 00034 #include "GUIInstantInductLoop.h" 00035 #include <utils/gui/div/GLHelper.h> 00036 #include <utils/geom/Line.h> 00037 #include <utils/gui/div/GUIParameterTableWindow.h> 00038 #include <microsim/logging/FuncBinding_IntParam.h> 00039 #include <microsim/logging/FunctionBinding.h> 00040 #include <microsim/output/MSInstantInductLoop.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 myBoundary.add(myFGPosition.x() + (SUMOReal) 5.5, myFGPosition.y() + (SUMOReal) 5.5); 00085 myBoundary.add(myFGPosition.x() - (SUMOReal) 5.5, myFGPosition.y() - (SUMOReal) 5.5); 00086 myFGRotation = -v.rotationDegreeAtLengthPosition(pos); 00087 } 00088 00089 00090 GUIInstantInductLoop::MyWrapper::~MyWrapper() {} 00091 00092 00093 Boundary 00094 GUIInstantInductLoop::MyWrapper::getCenteringBoundary() const { 00095 Boundary b(myBoundary); 00096 b.grow(20); 00097 return b; 00098 } 00099 00100 00101 00102 GUIParameterTableWindow* 00103 GUIInstantInductLoop::MyWrapper::getParameterWindow(GUIMainWindow& app, 00104 GUISUMOAbstractView& /*parent !!! recheck this - never needed?*/) { 00105 GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this, 7); 00106 // add items 00107 // parameter 00108 ret->mkItem("position [m]", false, myPosition); 00109 ret->mkItem("lane", false, myDetector.getLane()->getID()); 00110 // values 00111 // close building 00112 ret->closeBuilding(); 00113 return ret; 00114 } 00115 00116 00117 void 00118 GUIInstantInductLoop::MyWrapper::drawGL(const GUIVisualizationSettings& s) const { 00119 glPushName(getGlID()); 00120 SUMOReal width = (SUMOReal) 2.0 * s.scale; 00121 glLineWidth(1.0); 00122 // shape 00123 glColor3d(1, 0, 1); 00124 glPushMatrix(); 00125 glTranslated(0, 0, getType()); 00126 glTranslated(myFGPosition.x(), myFGPosition.y(), 0); 00127 glRotated(myFGRotation, 0, 0, 1); 00128 glScaled(s.addExaggeration, s.addExaggeration, 1); 00129 glBegin(GL_QUADS); 00130 glVertex2d(0 - 1.0, 2); 00131 glVertex2d(-1.0, -2); 00132 glVertex2d(1.0, -2); 00133 glVertex2d(1.0, 2); 00134 glEnd(); 00135 glTranslated(0, 0, .01); 00136 glBegin(GL_LINES); 00137 glVertex2d(0, 2 - .1); 00138 glVertex2d(0, -2 + .1); 00139 glEnd(); 00140 00141 // outline 00142 if (width * s.addExaggeration > 1) { 00143 glColor3d(1, 1, 1); 00144 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 00145 glBegin(GL_QUADS); 00146 glVertex2f(0 - 1.0, 2); 00147 glVertex2f(-1.0, -2); 00148 glVertex2f(1.0, -2); 00149 glVertex2f(1.0, 2); 00150 glEnd(); 00151 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); 00152 } 00153 00154 // position indicator 00155 if (width * s.addExaggeration > 1) { 00156 glRotated(90, 0, 0, -1); 00157 glColor3d(1, 1, 1); 00158 glBegin(GL_LINES); 00159 glVertex2d(0, 1.7); 00160 glVertex2d(0, -1.7); 00161 glEnd(); 00162 } 00163 glPopMatrix(); 00164 drawName(getCenteringBoundary().getCenter(), s.scale, s.addName); 00165 glPopName(); 00166 } 00167 00168 00169 GUIInstantInductLoop& 00170 GUIInstantInductLoop::MyWrapper::getLoop() { 00171 return myDetector; 00172 } 00173 00174 00175 00176 /****************************************************************************/ 00177