SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00011 // } 00012 /****************************************************************************/ 00013 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00014 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00015 /****************************************************************************/ 00016 // 00017 // This file is part of SUMO. 00018 // SUMO is free software: you can redistribute it and/or modify 00019 // it under the terms of the GNU General Public License as published by 00020 // the Free Software Foundation, either version 3 of the License, or 00021 // (at your option) any later version. 00022 // 00023 /****************************************************************************/ 00024 00025 00026 // =========================================================================== 00027 // included modules 00028 // =========================================================================== 00029 #ifdef _MSC_VER 00030 #include <windows_config.h> 00031 #else 00032 #include <config.h> 00033 #endif 00034 00035 #ifdef WIN32 00036 #include <windows.h> 00037 #endif 00038 00039 #include <GL/gl.h> 00040 00041 #include <string> 00042 #include <utility> 00043 #include <microsim/MSLane.h> 00044 #include <microsim/MSJunction.h> 00045 #include <utils/geom/Position.h> 00046 #include <microsim/MSNet.h> 00047 #include <microsim/MSInternalJunction.h> 00048 #include <gui/GUIApplicationWindow.h> 00049 #include <gui/GUIGlobals.h> 00050 #include <utils/gui/windows/GUIAppEnum.h> 00051 #include <utils/gui/windows/GUISUMOAbstractView.h> 00052 #include "GUIJunctionWrapper.h" 00053 #include <utils/gui/globjects/GUIGLObjectPopupMenu.h> 00054 #include <utils/gui/div/GUIGlobalSelection.h> 00055 #include <utils/gui/div/GUIParameterTableWindow.h> 00056 #include <utils/gui/div/GLHelper.h> 00057 #include <foreign/polyfonts/polyfonts.h> 00058 00059 #ifdef CHECK_MEMORY_LEAKS 00060 #include <foreign/nvwa/debug_new.h> 00061 #endif // CHECK_MEMORY_LEAKS 00062 00063 00064 // =========================================================================== 00065 // method definitions 00066 // =========================================================================== 00067 GUIJunctionWrapper::GUIJunctionWrapper(MSJunction& junction) 00068 : GUIGlObject(GLO_JUNCTION, junction.getID()), 00069 myJunction(junction) { 00070 if (myJunction.getShape().size() == 0) { 00071 Position pos = myJunction.getPosition(); 00072 myBoundary = Boundary(pos.x() - 1., pos.y() - 1., pos.x() + 1., pos.y() + 1.); 00073 } else { 00074 myBoundary = myJunction.getShape().getBoxBoundary(); 00075 } 00076 myMaxSize = MAX2(myBoundary.getWidth(), myBoundary.getHeight()); 00077 #ifdef HAVE_INTERNAL_LANES 00078 myIsInner = dynamic_cast<MSInternalJunction*>(&myJunction) != 0; 00079 #else 00080 myIsInner = false; 00081 #endif 00082 } 00083 00084 00085 GUIJunctionWrapper::~GUIJunctionWrapper() {} 00086 00087 00088 GUIGLObjectPopupMenu* 00089 GUIJunctionWrapper::getPopUpMenu(GUIMainWindow& app, 00090 GUISUMOAbstractView& parent) { 00091 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this); 00092 buildPopupHeader(ret, app); 00093 buildCenterPopupEntry(ret); 00094 buildNameCopyPopupEntry(ret); 00095 buildSelectionPopupEntry(ret); 00096 buildPositionCopyEntry(ret, false); 00097 return ret; 00098 } 00099 00100 00101 GUIParameterTableWindow* 00102 GUIJunctionWrapper::getParameterWindow(GUIMainWindow& /*app*/, 00103 GUISUMOAbstractView&) { 00104 return 0; 00105 } 00106 00107 00108 Boundary 00109 GUIJunctionWrapper::getCenteringBoundary() const { 00110 Boundary b = myBoundary; 00111 b.grow(20); 00112 return b; 00113 } 00114 00115 00116 void 00117 GUIJunctionWrapper::drawGL(const GUIVisualizationSettings& s) const { 00118 // check whether it is not too small 00119 if (s.scale * myMaxSize < 1.) { 00120 return; 00121 } 00122 if (!myIsInner) { 00123 glPushName(getGlID()); 00124 glPushMatrix(); 00125 glColor3d(0, 0, 0); 00126 glTranslated(0, 0, getType()); 00127 GLHelper::drawFilledPoly(myJunction.getShape(), true); 00128 glPopMatrix(); 00129 } 00130 if (myIsInner) { 00131 drawName(myJunction.getPosition(), s.scale, s.internalJunctionName); 00132 } else { 00133 drawName(myJunction.getPosition(), s.scale, s.junctionName); 00134 } 00135 glPopName(); 00136 } 00137 00138 00139 /****************************************************************************/ 00140