GUIGlObject_AbstractAdd.cpp

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // Base class for additional objects (emitter, detectors etc.)
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 "GUIGlObject_AbstractAdd.h"
00031 #include <cassert>
00032 #include <iostream>
00033 #include <utils/gui/div/GLHelper.h>
00034 #include <foreign/polyfonts/polyfonts.h>
00035 
00036 #ifdef CHECK_MEMORY_LEAKS
00037 #include <foreign/nvwa/debug_new.h>
00038 #endif // CHECK_MEMORY_LEAKS
00039 
00040 
00041 // ===========================================================================
00042 // static member definitions
00043 // ===========================================================================
00044 std::map<std::string, GUIGlObject_AbstractAdd*> GUIGlObject_AbstractAdd::myObjects;
00045 std::vector<GUIGlObject_AbstractAdd*> GUIGlObject_AbstractAdd::myObjectList;
00046 
00047 
00048 // ===========================================================================
00049 // method definitions
00050 // ===========================================================================
00051 GUIGlObject_AbstractAdd::GUIGlObject_AbstractAdd(GUIGlObjectStorage &idStorage,
00052         std::string fullName,
00053         GUIGlObjectType type) throw()
00054         : GUIGlObject(idStorage, fullName), myGlType(type) {
00056     myObjects[fullName] = this;
00057     myObjectList.push_back(this);
00058 }
00059 
00060 
00061 GUIGlObject_AbstractAdd::GUIGlObject_AbstractAdd(std::string fullName,
00062         GLuint glID,
00063         GUIGlObjectType type) throw()
00064         : GUIGlObject(fullName, glID), myGlType(type) {
00066     myObjects[fullName] = this;
00067     myObjectList.push_back(this);
00068 }
00069 
00070 
00071 GUIGlObject_AbstractAdd::~GUIGlObject_AbstractAdd() throw() {}
00072 
00073 
00074 
00075 GUIGlObjectType
00076 GUIGlObject_AbstractAdd::getType() const throw() {
00077     return myGlType;
00078 }
00079 
00080 
00081 void
00082 GUIGlObject_AbstractAdd::clearDictionary() {
00083     std::map<std::string, GUIGlObject_AbstractAdd*>::iterator i;
00084     for (i=myObjects.begin(); i!=myObjects.end(); i++) {
00086     }
00087     myObjects.clear();
00088     myObjectList.clear();
00089 }
00090 
00091 
00092 GUIGlObject_AbstractAdd *
00093 GUIGlObject_AbstractAdd::get(const std::string &name) {
00094     std::map<std::string, GUIGlObject_AbstractAdd*>::iterator i =
00095         myObjects.find(name);
00096     if (i==myObjects.end()) {
00097         return 0;
00098     }
00099     return (*i).second;
00100 }
00101 
00102 
00103 const std::vector<GUIGlObject_AbstractAdd*> &
00104 GUIGlObject_AbstractAdd::getObjectList() {
00105     return myObjectList;
00106 }
00107 
00108 
00109 std::vector<GLuint>
00110 GUIGlObject_AbstractAdd::getIDList() {
00111     std::vector<GLuint> ret;
00112     for (std::vector<GUIGlObject_AbstractAdd*>::iterator i=myObjectList.begin(); i!=myObjectList.end(); ++i) {
00113         ret.push_back((*i)->getGlID());
00114     }
00115     return ret;
00116 }
00117 
00118 
00119 void
00120 GUIGlObject_AbstractAdd::drawGLName(const Position2D &p, const std::string &id, SUMOReal nameScale) const {
00121     glPolygonOffset(0, -6);
00122     glPushMatrix();
00123     glTranslated(p.x(), p.y(), 0);
00124     glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
00125     pfSetPosition(0, 0);
00126     pfSetScale(nameScale);
00127     SUMOReal w = pfdkGetStringWidth(id.c_str());
00128     glRotated(180, 1, 0, 0);
00129     glTranslated(-w/2., 0.4, 0);
00130     pfDrawString(id.c_str());
00131     glPopMatrix();
00132 }
00133 
00134 
00135 /****************************************************************************/
00136 

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