00001 /****************************************************************************/ 00007 // The class responsible for building and deletion of vehicles (gui-version) 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 <microsim/MSCORN.h> 00031 #include "GUIVehicleControl.h" 00032 #include "GUIVehicle.h" 00033 #include "GUINet.h" 00034 #include <gui/GUIGlobals.h> 00035 #include <utils/gui/globjects/GUIGlObjectStorage.h> 00036 00037 #ifdef CHECK_MEMORY_LEAKS 00038 #include <foreign/nvwa/debug_new.h> 00039 #endif // CHECK_MEMORY_LEAKS 00040 00041 00042 // =========================================================================== 00043 // member method definitions 00044 // =========================================================================== 00045 GUIVehicleControl::GUIVehicleControl() throw() 00046 : MSVehicleControl() {} 00047 00048 00049 GUIVehicleControl::~GUIVehicleControl() throw() {} 00050 00051 00052 MSVehicle * 00053 GUIVehicleControl::buildVehicle(SUMOVehicleParameter* defs, 00054 const MSRoute* route, const MSVehicleType* type) throw(ProcessError) { 00055 myLoadedVehNo++; 00056 MSVehicle *built = new GUIVehicle(GUIGlObjectStorage::gIDStorage, defs, route, type, myLoadedVehNo-1); 00057 MSNet::getInstance()->informVehicleStateListener(built, MSNet::VEHICLE_STATE_BUILT); 00058 return built; 00059 } 00060 00061 00062 void 00063 GUIVehicleControl::deleteVehicle(MSVehicle *veh) throw() { 00064 static_cast<GUIVehicle*>(veh)->setRemoved(); 00065 if (GUIGlObjectStorage::gIDStorage.remove(static_cast<GUIVehicle*>(veh)->getGlID())) { 00066 MSVehicleControl::deleteVehicle(veh); 00067 } 00068 } 00069 00070 00071 void 00072 GUIVehicleControl::insertVehicleIDs(std::vector<GLuint> &into) throw() { 00073 into.reserve(myVehicleDict.size()); 00074 for (VehicleDictType::iterator i=myVehicleDict.begin(); i!=myVehicleDict.end(); ++i) { 00075 MSVehicle *veh = (*i).second; 00076 if (veh->isOnRoad()) { 00077 into.push_back(static_cast<GUIVehicle*>((*i).second)->getGlID()); 00078 } 00079 } 00080 } 00081 00082 00083 00084 /****************************************************************************/ 00085
1.5.6