SUMO - Simulation of Urban MObility
GUIGlObject.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 // Base class for all objects that may be displayed within the openGL-gui
19 /****************************************************************************/
20 #ifndef GUIGlObject_h
21 #define GUIGlObject_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <string>
30 #include <set>
31 #include "GUIGlObjectTypes.h"
32 #include <utils/geom/Boundary.h>
33 #include <utils/common/StdDefs.h>
36 #include <utils/common/RGBColor.h>
37 
38 
39 // ===========================================================================
40 // definitions
41 // ===========================================================================
42 
43 typedef unsigned int GUIGlID;
44 
45 // ===========================================================================
46 // class declarations
47 // ===========================================================================
48 
49 class GUIGlObjectStorage;
51 class GUIMainWindow;
56 #ifdef HAVE_OSG
57 namespace osg {
58 class Node;
59 }
60 #endif
61 
62 // ===========================================================================
63 // class definitions
64 // ===========================================================================
65 
66 class GUIGlObject {
67 public:
70  static const GUIGlID INVALID_ID;
71 
81  GUIGlObject(GUIGlObjectType type, const std::string& microsimID);
82 
84  virtual ~GUIGlObject();
85 
90  const std::string& getFullName() const;
91 
94  virtual std::string getParentName() const;
95 
98  GUIGlID getGlID() const;
100 
103 
109  virtual GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) = 0;
110 
117  virtual GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) = 0;
118 
125  virtual GUIParameterTableWindow* getTypeParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent);
126 
128  virtual const std::string& getMicrosimID() const;
129 
132  virtual void setMicrosimID(const std::string& newID);
133 
136  GUIGlObjectType getType() const;
137 
139  virtual Boundary getCenteringBoundary() const = 0;
140 
143  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
144 
145  virtual double getColorValue(const GUIVisualizationSettings& /*s*/, int /*activeScheme*/) const {
146  return 0;
147  }
149 
154  virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const;
155 
156 #ifdef HAVE_OSG
157  osg::Node* getNode() const;
159 
161  void setNode(osg::Node* node);
162 #endif
163 
168  void addParameterTable(GUIParameterTableWindow* w);
169 
172  void removeParameterTable(GUIParameterTableWindow* w);
174 
176  void drawName(const Position& pos, const double scale, const GUIVisualizationTextSettings& settings, const double angle = 0) const;
177 
178 protected:
181 
185  void buildPopupHeader(GUIGLObjectPopupMenu* ret, GUIMainWindow& app, bool addSeparator = true);
186 
191  void buildCenterPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
192 
197  void buildNameCopyPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
198 
203  void buildSelectionPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
204 
209  void buildShowParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
210 
215  void buildShowTypeParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
216 
222  void buildPositionCopyEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
223 
228  void buildShowManipulatorPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
230 
231 protected:
233  void buildShapePopupOptions(GUIMainWindow& app, GUIGLObjectPopupMenu* ret, const std::string& type);
234 
236  void buildAdditionalsPopupOptions(GUIMainWindow& app, GUIGLObjectPopupMenu* ret, const std::string& type);
237 
238 private:
241 
244 
246  std::string myMicrosimID;
247 
249  std::string myFullName;
250 
252  std::set<GUIParameterTableWindow*> myParamWindows;
253 
255  std::string createFullName() const;
256 
257 #ifdef HAVE_OSG
258  osg::Node* myOSGNode;
260 #endif
261 
263  // static StringBijection<SumoXMLLinkStateValue> LinkStates;
264 
266  static StringBijection<GUIGlObjectType>::Entry GUIGlObjectTypeNamesInitializer[];
267 
268 private:
270  GUIGlObject(const GUIGlObject&) = delete;
271 
273  GUIGlObject& operator=(const GUIGlObject&) = delete;
274 };
275 #endif
276 
277 /****************************************************************************/
278 
GUIGlObjectType
GUIGlID myGlID
The numerical id of the object.
Definition: GUIGlObject.h:240
Stores the information about how to visualize structures.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
std::string myMicrosimID
ID of GL object.
Definition: GUIGlObject.h:246
A storage for of displayed objects via their numerical id.
const GUIGlObjectType myGLObjectType
The type of the object.
Definition: GUIGlObject.h:243
unsigned int GUIGlID
Definition: GUIGlObject.h:43
virtual double getColorValue(const GUIVisualizationSettings &, int) const
Definition: GUIGlObject.h:145
static StringBijection< GUIGlObjectType > TypeNames
associates object types with strings
Definition: GUIGlObject.h:69
static const GUIGlID INVALID_ID
Definition: GUIGlObject.h:70
The popup menu of a globject.
std::string myFullName
full name of GL Object
Definition: GUIGlObject.h:249
std::set< GUIParameterTableWindow * > myParamWindows
Parameter table windows which refer to this object.
Definition: GUIGlObject.h:252
A window containing a gl-object&#39;s parameter.