Eclipse 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-2019 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 
131  virtual const std::string getOptionalName() const;
132 
135  virtual void setMicrosimID(const std::string& newID);
136 
139  GUIGlObjectType getType() const;
140 
142  virtual Boundary getCenteringBoundary() const = 0;
143 
146  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
147 
148  virtual double getColorValue(const GUIVisualizationSettings& /*s*/, int /*activeScheme*/) const {
149  return 0;
150  }
152 
157  virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const;
158 
159 #ifdef HAVE_OSG
160  osg::Node* getNode() const;
162 
164  void setNode(osg::Node* node);
165 #endif
166 
171  void addParameterTable(GUIParameterTableWindow* w);
172 
175  void removeParameterTable(GUIParameterTableWindow* w);
177 
179  void drawName(const Position& pos, const double scale, const GUIVisualizationTextSettings& settings, const double angle = 0) const;
180 
181 protected:
184 
188  void buildPopupHeader(GUIGLObjectPopupMenu* ret, GUIMainWindow& app, bool addSeparator = true);
189 
194  void buildCenterPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
195 
200  void buildNameCopyPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
201 
206  void buildSelectionPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
207 
212  void buildShowParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
213 
218  void buildShowTypeParamsPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
219 
225  void buildPositionCopyEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
226 
231  void buildShowManipulatorPopupEntry(GUIGLObjectPopupMenu* ret, bool addSeparator = true);
233 
234 protected:
236  void buildShapePopupOptions(GUIMainWindow& app, GUIGLObjectPopupMenu* ret, const std::string& type);
237 
239  void buildAdditionalsPopupOptions(GUIMainWindow& app, GUIGLObjectPopupMenu* ret, const std::string& type);
240 
241 private:
244 
247 
249  std::string myMicrosimID;
250 
252  std::string myFullName;
253 
255  std::set<GUIParameterTableWindow*> myParamWindows;
256 
258  std::string createFullName() const;
259 
260 #ifdef HAVE_OSG
261  osg::Node* myOSGNode;
263 #endif
264 
266  // static StringBijection<SumoXMLLinkStateValue> LinkStates;
267 
269  static StringBijection<GUIGlObjectType>::Entry GUIGlObjectTypeNamesInitializer[];
270 
271 private:
273  GUIGlObject(const GUIGlObject&) = delete;
274 
276  GUIGlObject& operator=(const GUIGlObject&) = delete;
277 };
278 #endif
279 
280 /****************************************************************************/
281 
GUIGlObjectType
GUIGlID myGlID
The numerical id of the object.
Definition: GUIGlObject.h:243
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:249
A storage for of displayed objects via their numerical id.
const GUIGlObjectType myGLObjectType
The type of the object.
Definition: GUIGlObject.h:246
unsigned int GUIGlID
Definition: GUIGlObject.h:43
virtual double getColorValue(const GUIVisualizationSettings &, int) const
Definition: GUIGlObject.h:148
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:252
std::set< GUIParameterTableWindow * > myParamWindows
Parameter table windows which refer to this object.
Definition: GUIGlObject.h:255
A window containing a gl-object&#39;s parameter.