SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00010 // Base class for all objects that may be displayed within the openGL-gui 00011 /****************************************************************************/ 00012 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00013 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00014 /****************************************************************************/ 00015 // 00016 // This file is part of SUMO. 00017 // SUMO is free software: you can redistribute it and/or modify 00018 // it under the terms of the GNU General Public License as published by 00019 // the Free Software Foundation, either version 3 of the License, or 00020 // (at your option) any later version. 00021 // 00022 /****************************************************************************/ 00023 #ifndef GUIGlObject_h 00024 #define GUIGlObject_h 00025 00026 00027 // =========================================================================== 00028 // included modules 00029 // =========================================================================== 00030 #ifdef _MSC_VER 00031 #include <windows_config.h> 00032 #else 00033 #include <config.h> 00034 #endif 00035 00036 #include <string> 00037 #include <set> 00038 #include "GUIGlObjectTypes.h" 00039 #include <utils/geom/Boundary.h> 00040 #include <utils/common/StdDefs.h> 00041 #include <utils/common/StringBijection.h> 00042 #include <utils/common/RGBColor.h> 00043 00044 00045 // =========================================================================== 00046 // definitions 00047 // =========================================================================== 00048 typedef unsigned int GUIGlID; 00049 00050 00051 // =========================================================================== 00052 // class declarations 00053 // =========================================================================== 00054 class GUIGlObjectStorage; 00055 class GUIParameterTableWindow; 00056 class GUIMainWindow; 00057 class GUIGLObjectPopupMenu; 00058 class GUISUMOAbstractView; 00059 class GUIVisualizationSettings; 00060 struct GUIVisualizationTextSettings; 00061 #ifdef HAVE_OSG 00062 namespace osg { 00063 class Node; 00064 } 00065 #endif 00066 00067 00068 // =========================================================================== 00069 // class definitions 00070 // =========================================================================== 00071 class GUIGlObject { 00072 public: 00081 GUIGlObject(GUIGlObjectType type, const std::string& microsimID); 00082 00083 00092 GUIGlObject(const std::string& prefix, GUIGlObjectType type, const std::string& microsimID); 00093 00094 00096 virtual ~GUIGlObject() ; 00097 00099 static StringBijection<GUIGlObjectType> TypeNames; 00100 00103 00107 const std::string& getFullName() const { 00108 return myFullName; 00109 } 00110 00111 00115 GUIGlID getGlID() const { 00116 return myGlID; 00117 } 00119 00120 00122 00123 00130 virtual GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) = 0; 00131 00132 00139 virtual GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) = 0; 00140 00141 00146 const std::string& getMicrosimID() const { 00147 return myMicrosimID; 00148 }; 00149 00150 00152 void setMicrosimID(const std::string& newID); 00153 00154 00159 GUIGlObjectType getType() const { 00160 return myGLObjectType; 00161 }; 00162 00163 00168 virtual Boundary getCenteringBoundary() const = 0; 00169 00170 00174 virtual void drawGL(const GUIVisualizationSettings& s) const = 0; 00176 00177 00182 virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const { 00183 UNUSED_PARAMETER(&s); 00184 UNUSED_PARAMETER(parent); 00185 }; 00186 00187 #ifdef HAVE_OSG 00188 void setNode(osg::Node* node) { 00189 myOSGNode = node; 00190 } 00191 00192 osg::Node* getNode() const { 00193 return myOSGNode; 00194 } 00195 #endif 00196 00199 00203 void addParameterTable(GUIParameterTableWindow* w) ; 00204 00205 00209 void removeParameterTable(GUIParameterTableWindow* w) ; 00211 00212 00213 void drawName(const Position& pos, const SUMOReal scale, 00214 const GUIVisualizationTextSettings& settings, const SUMOReal angle = 0) const; 00215 00216 00217 protected: 00219 00220 00225 void buildPopupHeader(GUIGLObjectPopupMenu* ret, GUIMainWindow& app, bool addSeparator = true) ; 00226 00227 00232 void buildCenterPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true) ; 00233 00234 00239 void buildNameCopyPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true) ; 00240 00241 00246 void buildSelectionPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true) ; 00247 00248 00253 void buildShowParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true) ; 00254 00255 00261 void buildPositionCopyEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true) ; 00262 00263 00268 void buildShowManipulatorPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true) ; 00270 00271 protected: 00272 /* usually names are prefixed by a type-specific string. this method can be 00273 * used to change the default */ 00274 void setPrefix(const std::string& prefix); 00275 00276 private: 00278 GUIGlID myGlID; 00279 00281 const GUIGlObjectType myGLObjectType; 00282 00283 std::string myMicrosimID; 00284 00285 std::string myPrefix; 00286 00287 std::string myFullName; 00288 00290 std::set<GUIParameterTableWindow*> myParamWindows; 00291 00292 std::string createFullName() const; 00293 00294 #ifdef HAVE_OSG 00295 osg::Node* myOSGNode; 00296 #endif 00297 00298 // static StringBijection<SumoXMLLinkStateValue> LinkStates; 00299 00300 static StringBijection<GUIGlObjectType>::Entry GUIGlObjectTypeNamesInitializer[]; 00301 00302 private: 00304 GUIGlObject(const GUIGlObject&); 00305 00307 GUIGlObject& operator=(const GUIGlObject&); 00308 00309 }; 00310 #endif 00311 00312 /****************************************************************************/ 00313