SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUIJunctionWrapper.cpp
Go to the documentation of this file.
1 /****************************************************************************/
11 // }
12 /****************************************************************************/
13 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
14 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
15 /****************************************************************************/
16 //
17 // This file is part of SUMO.
18 // SUMO is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 /****************************************************************************/
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <string>
36 #include <utility>
37 #ifdef HAVE_OSG
38 #include <osg/Geometry>
39 #endif
40 #include <microsim/MSLane.h>
41 #include <microsim/MSJunction.h>
42 #include <utils/geom/Position.h>
43 #include <microsim/MSNet.h>
46 #include <gui/GUIGlobals.h>
49 #include "GUIJunctionWrapper.h"
53 #include <utils/gui/div/GLHelper.h>
56 
57 #ifdef CHECK_MEMORY_LEAKS
58 #include <foreign/nvwa/debug_new.h>
59 #endif // CHECK_MEMORY_LEAKS
60 
61 
62 // ===========================================================================
63 // method definitions
64 // ===========================================================================
66  : GUIGlObject(GLO_JUNCTION, junction.getID()),
67  myJunction(junction) {
68  if (myJunction.getShape().size() == 0) {
70  myBoundary = Boundary(pos.x() - 1., pos.y() - 1., pos.x() + 1., pos.y() + 1.);
71  } else {
73  }
75 #ifdef HAVE_INTERNAL_LANES
76  myIsInner = dynamic_cast<MSInternalJunction*>(&myJunction) != 0;
77 #else
78  myIsInner = false;
79 #endif
80 }
81 
82 
84 
85 
88  GUISUMOAbstractView& parent) {
89  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
90  buildPopupHeader(ret, app);
94  buildPositionCopyEntry(ret, false);
95  return ret;
96 }
97 
98 
102  return 0;
103 }
104 
105 
106 Boundary
108  Boundary b = myBoundary;
109  b.grow(20);
110  return b;
111 }
112 
113 
114 void
116  // check whether it is not too small
117  if (s.scale * myMaxSize < 1.) {
118  return;
119  }
120  if (!myIsInner) {
121  glPushName(getGlID());
122  glPushMatrix();
123  const SUMOReal colorValue = static_cast<SUMOReal>(s.junctionColorer.getActive() == 1 && gSelected.isSelected(getType(), getGlID()));
125  glTranslated(0, 0, getType());
127  glPopMatrix();
128  }
129  if (myIsInner) {
131  } else {
133  }
134  glPopName();
135 }
136 
137 
138 #ifdef HAVE_OSG
139 void
140 GUIJunctionWrapper::updateColor(const GUIVisualizationSettings& s) {
141  const SUMOReal colorValue = static_cast<SUMOReal>(s.junctionColorer.getActive() == 1 && gSelected.isSelected(getType(), getGlID()));
142  const RGBColor& col = s.junctionColorer.getScheme().getColor(colorValue);
143  osg::Vec4ubArray* colors = dynamic_cast<osg::Vec4ubArray*>(myGeom->getColorArray());
144  (*colors)[0].set(col.red(), col.green(), col.blue(), col.alpha());
145  myGeom->setColorArray(colors);
146 }
147 #endif
148 
149 
150 /****************************************************************************/
151 
GUIVisualizationTextSettings junctionName
SUMOReal getHeight() const
Returns the height of the boundary.
Definition: Boundary.cpp:142
SUMOReal getWidth() const
Returns the width of the boudary.
Definition: Boundary.cpp:136
const RGBColor getColor(const SUMOReal value) const
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
Stores the information about how to visualize structures.
The base class for an intersection.
Definition: MSJunction.h:57
const PositionVector & getShape() const
Returns this junction&#39;s shape.
Definition: MSJunction.h:84
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
T MAX2(T a, T b)
Definition: StdDefs.h:63
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
static void drawFilledPoly(const PositionVector &v, bool close)
Draws a filled polygon described by the list of points.
Definition: GLHelper.cpp:54
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used, also builds an entry for copying the geo-position.
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:115
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
SUMOReal scale
information about a lane&#39;s width (temporary, used for a single view)
SUMOReal myMaxSize
The maximum size (in either x-, or y-dimension) for determining whether to draw or not...
size_t getActive() const
Definition: GUIColorer.h:72
unsigned char blue() const
Returns the blue-amount of the color.
Definition: RGBColor.h:91
GUIJunctionWrapper(MSJunction &junction)
Constructor.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Definition: GUIGlObject.h:159
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:301
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
void set(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
assigns new values
Definition: RGBColor.cpp:85
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition: RGBColor.h:99
GUIVisualizationTextSettings internalJunctionName
GUIColorer junctionColorer
The junction colorer.
void drawName(const Position &pos, const SUMOReal scale, const GUIVisualizationTextSettings &settings, const SUMOReal angle=0) const
virtual ~GUIJunctionWrapper()
Destructor.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
Definition: Boundary.cpp:200
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
GUIColorScheme & getScheme()
Definition: GUIColorer.h:76
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
Boundary myBoundary
The represented junction&#39;s boundary.
The popup menu of a globject.
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
MSJunction & myJunction
A reference to the represented junction.
unsigned char green() const
Returns the green-amount of the color.
Definition: RGBColor.h:83
#define SUMOReal
Definition: config.h:221
unsigned char red() const
Returns the red-amount of the color.
Definition: RGBColor.h:75
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
GUISelectedStorage gSelected
A global holder of selected objects.
A window containing a gl-object&#39;s parameter.
bool myIsInner
whether this wraps an instance of MSInternalJunction
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
const Position & getPosition() const
Definition: MSJunction.cpp:58
a junction