GUIPointOfInterest.cpp

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // The GUI-version of a point of interest
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright 2001-2010 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 #include "GUIPointOfInterest.h"
00031 #include <utils/gui/div/GUIParameterTableWindow.h>
00032 #include <utils/gui/globjects/GUIGLObjectPopupMenu.h>
00033 #include <utils/gui/div/GUIGlobalSelection.h>
00034 #include <utils/gui/windows/GUIMainWindow.h>
00035 #include <utils/gui/images/GUIIconSubSys.h>
00036 #include <utils/gui/windows/GUIAppEnum.h>
00037 #include <utils/gui/settings/GUIVisualizationSettings.h>
00038 #include <utils/gui/div/GLHelper.h>
00039 #include <foreign/polyfonts/polyfonts.h>
00040 
00041 #ifdef CHECK_MEMORY_LEAKS
00042 #include <foreign/nvwa/debug_new.h>
00043 #endif // CHECK_MEMORY_LEAKS
00044 
00045 
00046 // ===========================================================================
00047 // method definitions
00048 // ===========================================================================
00049 GUIPointOfInterest::GUIPointOfInterest(GUIGlObjectStorage &idStorage,
00050                                        int layer,
00051                                        const std::string &id,
00052                                        const std::string &type,
00053                                        const Position2D &p,
00054                                        const RGBColor &c) throw()
00055         : PointOfInterest(id, type, p, c),
00056         GUIGlObject_AbstractAdd(idStorage, "poi:"+id, GLO_SHAPE), myLayer(layer) {}
00057 
00058 
00059 GUIPointOfInterest::~GUIPointOfInterest() throw() {}
00060 
00061 
00062 GUIGLObjectPopupMenu *
00063 GUIPointOfInterest::getPopUpMenu(GUIMainWindow &app,
00064                                  GUISUMOAbstractView &parent) throw() {
00065 
00066     GUIGLObjectPopupMenu *ret = new GUIGLObjectPopupMenu(app, parent, *this);
00067     buildPopupHeader(ret, app, false);
00068     FXString t(myType.c_str());
00069     new FXMenuCommand(ret, "(" + t + ")", 0, 0, 0);
00070     new FXMenuSeparator(ret);
00071     buildCenterPopupEntry(ret);
00072     buildNameCopyPopupEntry(ret);
00073     buildSelectionPopupEntry(ret);
00074     buildPositionCopyEntry(ret, false);
00075     return ret;
00076 }
00077 
00078 
00079 GUIParameterTableWindow *
00080 GUIPointOfInterest::getParameterWindow(GUIMainWindow &,
00081                                        GUISUMOAbstractView &) throw() {
00082     return 0;
00083 }
00084 
00085 
00086 const std::string &
00087 GUIPointOfInterest::getMicrosimID() const throw() {
00088     return getID();
00089 }
00090 
00091 
00092 Boundary
00093 GUIPointOfInterest::getCenteringBoundary() const throw() {
00094     Boundary b;
00095     b.add(x(), y());
00096     b.grow(10);
00097     return b;
00098 }
00099 
00100 
00101 void
00102 GUIPointOfInterest::drawGL(const GUIVisualizationSettings &s) const throw() {
00103     if (s.scale*(1.3/3.0)<s.minPOISize) {
00104         return;
00105     }
00106     glPushMatrix();
00107     if (getLayer()==0) {
00108         glTranslated(0, 0, -.03);
00109     } else if (getLayer()>0) {
00110         glTranslated(0, 0, -.05-.01*(SUMOReal) getLayer());
00111     } else {
00112         glTranslated(0, 0, -.01*(SUMOReal) getLayer()+.01);
00113     }
00114     // (optional) set id
00115     if (s.needsGlID) {
00116         glPushName(getGlID());
00117     }
00118     glColor3d(red(),green(),blue());
00119     glTranslated(x(), y(), 0);
00120     GLHelper::drawFilledCircle((SUMOReal) 1.3*s.poiExaggeration, 16);
00121     if (s.drawPOIName) {
00122         glColor3d(s.poiNameColor.red(), s.poiNameColor.green(), s.poiNameColor.blue());
00123         glPushMatrix();
00124         glTranslated((SUMOReal) 1.32*s.poiExaggeration, (SUMOReal) 1.32*s.poiExaggeration, 0);
00125         glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
00126         pfSetPosition(0, 0);
00127         pfSetScale(s.poiNameSize / s.scale);
00128         glRotated(180, 1, 0, 0);
00129         pfDrawString(getID().c_str());
00130         glPopMatrix();
00131     }
00132     glTranslated(-x(), -y(), 0);
00133     // (optional) clear id
00134     if (s.needsGlID) {
00135         glPopName();
00136     }
00137     glPopMatrix();
00138 }
00139 
00140 
00141 int
00142 GUIPointOfInterest::getLayer() const {
00143     return myLayer;
00144 }
00145 
00146 
00147 
00148 /****************************************************************************/
00149 

Generated on Wed May 5 00:06:30 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6