|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // Base class for all objects that may be displayed within the openGL-gui 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 #ifndef GUIGlObject_h 00020 #define GUIGlObject_h 00021 00022 00023 // =========================================================================== 00024 // included modules 00025 // =========================================================================== 00026 #ifdef _MSC_VER 00027 #include <windows_config.h> 00028 #else 00029 #include <config.h> 00030 #endif 00031 00032 #include <string> 00033 #include <set> 00034 #include "GUIGlObjectTypes.h" 00035 #include <utils/geom/Boundary.h> 00036 #include <utils/common/StdDefs.h> 00037 #include <utils/common/StringBijection.h> 00038 #include <utils/common/RGBColor.h> 00039 00040 00041 // =========================================================================== 00042 // definitions 00043 // =========================================================================== 00044 typedef unsigned int GUIGlID; 00045 00046 00047 // =========================================================================== 00048 // class declarations 00049 // =========================================================================== 00050 class GUIGlObjectStorage; 00051 class GUIParameterTableWindow; 00052 class GUIMainWindow; 00053 class GUIGLObjectPopupMenu; 00054 class GUISUMOAbstractView; 00055 class GUIVisualizationSettings; 00056 struct GUIVisualizationTextSettings; 00057 00058 00059 // =========================================================================== 00060 // class definitions 00061 // =========================================================================== 00062 class GUIGlObject { 00063 public: 00072 GUIGlObject(GUIGlObjectType type, const std::string& microsimID); 00073 00074 00083 GUIGlObject(const std::string& prefix, GUIGlObjectType type, const std::string& microsimID); 00084 00085 00087 virtual ~GUIGlObject() throw(); 00088 00090 static StringBijection<GUIGlObjectType> TypeNames; 00091 00094 00098 const std::string& getFullName() const { 00099 return myFullName; 00100 } 00101 00102 00106 GUIGlID getGlID() const throw() { 00107 return myGlID; 00108 } 00110 00111 00113 00114 00121 virtual GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) throw() = 0; 00122 00123 00130 virtual GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) throw() = 0; 00131 00132 00137 const std::string& getMicrosimID() const { 00138 return myMicrosimID; 00139 }; 00140 00141 00143 void setMicrosimID(const std::string& newID); 00144 00145 00150 GUIGlObjectType getType() const { 00151 return myGLObjectType; 00152 }; 00153 00154 00159 virtual Boundary getCenteringBoundary() const throw() = 0; 00160 00161 00165 virtual void drawGL(const GUIVisualizationSettings& s) const throw() = 0; 00167 00168 00173 virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const throw() { 00174 UNUSED_PARAMETER(&s); 00175 UNUSED_PARAMETER(parent); 00176 }; 00177 00178 00179 00182 00186 void addParameterTable(GUIParameterTableWindow* w) throw(); 00187 00188 00192 void removeParameterTable(GUIParameterTableWindow* w) throw(); 00194 00195 00196 void drawName(const Position& pos, const SUMOReal scale, 00197 const GUIVisualizationTextSettings& settings, const SUMOReal angle=0) const; 00198 00199 00200 protected: 00202 00203 00208 void buildPopupHeader(GUIGLObjectPopupMenu* ret, GUIMainWindow& app, bool addSeparator=true) throw(); 00209 00210 00215 void buildCenterPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator=true) throw(); 00216 00217 00222 void buildNameCopyPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator=true) throw(); 00223 00224 00229 void buildSelectionPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator=true) throw(); 00230 00231 00236 void buildShowParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator=true) throw(); 00237 00238 00244 void buildPositionCopyEntry(GUIGLObjectPopupMenu* ret, bool addSeparator=true) throw(); 00245 00246 00251 void buildShowManipulatorPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator=true) throw(); 00253 00254 protected: 00255 /* usually names are prefixed by a type-specific string. this method can be 00256 * used to change the default */ 00257 void setPrefix(const std::string& prefix); 00258 00259 private: 00261 GUIGlID myGlID; 00262 00264 const GUIGlObjectType myGLObjectType; 00265 00266 std::string myMicrosimID; 00267 00268 std::string myPrefix; 00269 00270 std::string myFullName; 00271 00273 std::set<GUIParameterTableWindow*> myParamWindows; 00274 00275 std::string createFullName() const; 00276 00277 00278 // static StringBijection<SumoXMLLinkStateValue> LinkStates; 00279 00280 static StringBijection<GUIGlObjectType>::Entry GUIGlObjectTypeNamesInitializer[]; 00281 00282 }; 00283 #endif 00284 00285 /****************************************************************************/ 00286