SUMO - Simulation of Urban MObility
GLHelper.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // Some methods which help to draw certain geometrical objects in openGL
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef GLHelper_h
23 #define GLHelper_h
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 <vector>
36 #include <utility>
37 #include <utils/common/RGBColor.h>
39 
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
50 class GLHelper {
51 public:
58  static void drawFilledPoly(const PositionVector& v, bool close);
59 
60 
68  static void drawFilledPolyTesselated(const PositionVector& v, bool close);
69 
70 
81  static void drawBoxLine(const Position& beg, SUMOReal rot,
82  SUMOReal visLength, SUMOReal width, SUMOReal offset = 0);
83 
84 
95  static void drawBoxLine(const Position& beg1, const Position& beg2,
96  SUMOReal rot, SUMOReal visLength, SUMOReal width);
97 
98 
111  static void drawBoxLines(const PositionVector& geom,
112  const std::vector<SUMOReal>& rots, const std::vector<SUMOReal>& lengths,
113  SUMOReal width, int cornerDetail = 0, SUMOReal offset = 0);
114 
128  static void drawBoxLines(const PositionVector& geom,
129  const std::vector<SUMOReal>& rots, const std::vector<SUMOReal>& lengths,
130  const std::vector<RGBColor>& cols,
131  SUMOReal width, int cornerDetail = 0, SUMOReal offset = 0);
132 
133 
145  static void drawBoxLines(const PositionVector& geom1,
146  const PositionVector& geom2,
147  const std::vector<SUMOReal>& rots, const std::vector<SUMOReal>& lengths,
148  SUMOReal width);
149 
150 
160  static void drawBoxLines(const PositionVector& geom, SUMOReal width);
161 
162 
171  static void drawLine(const Position& beg, SUMOReal rot,
172  SUMOReal visLength);
173 
174 
184  static void drawLine(const Position& beg1, const Position& beg2,
185  SUMOReal rot, SUMOReal visLength);
186 
187 
194  static void drawLine(const PositionVector& v);
195 
196 
203  static void drawLine(const PositionVector& v, const std::vector<RGBColor>& cols);
204 
205 
213  static void drawLine(const Position& beg, const Position& end);
214 
215 
223  static void drawFilledCircle(SUMOReal width, int steps = 8);
224 
225 
235  static void drawFilledCircle(SUMOReal width, int steps,
236  SUMOReal beg, SUMOReal end);
237 
238 
247  static void drawOutlineCircle(SUMOReal width, SUMOReal iwidth,
248  int steps = 8);
249 
250 
261  static void drawOutlineCircle(SUMOReal width, SUMOReal iwidth,
262  int steps, SUMOReal beg, SUMOReal end);
263 
264 
272  static void drawTriangleAtEnd(const Position& p1, const Position& p2,
273  SUMOReal tLength, SUMOReal tWidth);
274 
276  static void setColor(const RGBColor& c);
277 
279  static RGBColor getColor();
280 
282  static void drawText(const std::string& text, const Position& pos,
283  const SUMOReal layer, const SUMOReal size,
284  const RGBColor& col = RGBColor::BLACK, const SUMOReal angle = 0);
285 
287  static void drawTextBox(const std::string& text, const Position& pos,
288  const SUMOReal layer, const SUMOReal size,
289  const RGBColor& txtColor = RGBColor::BLACK,
290  const RGBColor& bgColor = RGBColor::WHITE,
291  const RGBColor& borderColor = RGBColor::BLACK,
292  const SUMOReal angle = 0);
293 
295  static void debugVertices(const PositionVector& shape, SUMOReal size, SUMOReal layer = 256);
296 
297 private:
299  static size_t angleLookup(SUMOReal angleDeg);
300 
302  static bool rightTurn(SUMOReal angle1, SUMOReal angle2);
303 
304 private:
306  static std::vector<std::pair<SUMOReal, SUMOReal> > myCircleCoords;
307 
308 };
309 
310 
311 #endif
312 
313 /****************************************************************************/
314 
static void debugVertices(const PositionVector &shape, SUMOReal size, SUMOReal layer=256)
draw vertex numbers for the given shape (in a random color)
Definition: GLHelper.cpp:518
static const RGBColor WHITE
Definition: RGBColor.h:196
static void drawOutlineCircle(SUMOReal width, SUMOReal iwidth, int steps=8)
Draws an unfilled circle around (0,0)
Definition: GLHelper.cpp:375
static void drawBoxLines(const PositionVector &geom, const std::vector< SUMOReal > &rots, const std::vector< SUMOReal > &lengths, SUMOReal width, int cornerDetail=0, SUMOReal offset=0)
Draws thick lines.
Definition: GLHelper.cpp:176
static void drawBoxLine(const Position &beg, SUMOReal rot, SUMOReal visLength, SUMOReal width, SUMOReal offset=0)
Draws a thick line.
Definition: GLHelper.cpp:130
static void drawFilledPoly(const PositionVector &v, bool close)
Draws a filled polygon described by the list of points.
Definition: GLHelper.cpp:76
static const RGBColor BLACK
Definition: RGBColor.h:197
static void drawText(const std::string &text, const Position &pos, const SUMOReal layer, const SUMOReal size, const RGBColor &col=RGBColor::BLACK, const SUMOReal angle=0)
draw Text with given parameters
Definition: GLHelper.cpp:460
Some methods which help to draw certain geometrical objects in openGL.
Definition: GLHelper.h:50
static void drawTriangleAtEnd(const Position &p1, const Position &p2, SUMOReal tLength, SUMOReal tWidth)
Draws a triangle at the end of the given line.
Definition: GLHelper.cpp:422
static void drawFilledPolyTesselated(const PositionVector &v, bool close)
Draws a filled polygon described by the list of points.
Definition: GLHelper.cpp:95
static bool rightTurn(SUMOReal angle1, SUMOReal angle2)
whether the road makes a right turn (or goes straight)
Definition: GLHelper.cpp:163
static void drawFilledCircle(SUMOReal width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:344
static size_t angleLookup(SUMOReal angleDeg)
normalize angle for lookup in myCircleCoords
Definition: GLHelper.cpp:332
static std::vector< std::pair< SUMOReal, SUMOReal > > myCircleCoords
Storage for precomputed sin/cos-values describing a circle.
Definition: GLHelper.h:306
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:443
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
static void drawTextBox(const std::string &text, const Position &pos, const SUMOReal layer, const SUMOReal size, const RGBColor &txtColor=RGBColor::BLACK, const RGBColor &bgColor=RGBColor::WHITE, const RGBColor &borderColor=RGBColor::BLACK, const SUMOReal angle=0)
draw Text box with given parameters
Definition: GLHelper.cpp:478
static void drawLine(const Position &beg, SUMOReal rot, SUMOReal visLength)
Draws a thin line.
Definition: GLHelper.cpp:269
#define SUMOReal
Definition: config.h:214
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:449