SUMO - Simulation of Urban MObility

GUIJunctionWrapper.cpp

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