SUMO - Simulation of Urban MObility
GLHelper Class Reference

Some methods which help to draw certain geometrical objects in openGL. More...

#include <GLHelper.h>

Collaboration diagram for GLHelper:
Collaboration graph

Static Public Member Functions

static void debugVertices (const PositionVector &shape, double size, double layer=256)
 draw vertex numbers for the given shape (in a random color) More...
 
static void drawBoxLine (const Position &beg, double rot, double visLength, double width, double offset=0)
 Draws a thick line. More...
 
static void drawBoxLine (const Position &beg1, const Position &beg2, double rot, double visLength, double width)
 Draws a thick line using the mean of both given points as begin position. More...
 
static void drawBoxLines (const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double width, int cornerDetail=0, double offset=0)
 Draws thick lines. More...
 
static void drawBoxLines (const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, const std::vector< RGBColor > &cols, double width, int cornerDetail=0, double offset=0)
 Draws thick lines with varying color. More...
 
static void drawBoxLines (const PositionVector &geom1, const PositionVector &geom2, const std::vector< double > &rots, const std::vector< double > &lengths, double width)
 Draws thick lines using the mean of the points given in the point lists as begin positions. More...
 
static void drawBoxLines (const PositionVector &geom, double width)
 Draws thick lines. More...
 
static void drawFilledCircle (double width, int steps=8)
 Draws a filled circle around (0,0) More...
 
static void drawFilledCircle (double width, int steps, double beg, double end)
 Draws a filled circle around (0,0) More...
 
static void drawFilledPoly (const PositionVector &v, bool close)
 Draws a filled polygon described by the list of points. More...
 
static void drawFilledPolyTesselated (const PositionVector &v, bool close)
 Draws a filled polygon described by the list of points. More...
 
static void drawLine (const Position &beg, double rot, double visLength)
 Draws a thin line. More...
 
static void drawLine (const Position &beg1, const Position &beg2, double rot, double visLength)
 Draws a thin line using the mean of both given points as begin position. More...
 
static void drawLine (const PositionVector &v)
 Draws a thin line along the given position vector. More...
 
static void drawLine (const PositionVector &v, const std::vector< RGBColor > &cols)
 Draws a thin line along the given position vector with variable color. More...
 
static void drawLine (const Position &beg, const Position &end)
 Draws a thin line between the two points. More...
 
static void drawOutlineCircle (double width, double iwidth, int steps=8)
 Draws an unfilled circle around (0,0) More...
 
static void drawOutlineCircle (double width, double iwidth, int steps, double beg, double end)
 Draws an unfilled circle around (0,0) More...
 
static void drawText (const std::string &text, const Position &pos, const double layer, const double size, const RGBColor &col=RGBColor::BLACK, const double angle=0)
 draw Text with given parameters More...
 
static void drawTextAtEnd (const std::string &text, const PositionVector &shape, double x, double size, RGBColor color)
 draw text and the end of shape More...
 
static void drawTextBox (const std::string &text, const Position &pos, const double layer, const double size, const RGBColor &txtColor=RGBColor::BLACK, const RGBColor &bgColor=RGBColor::WHITE, const RGBColor &borderColor=RGBColor::BLACK, const double angle=0)
 draw Text box with given parameters More...
 
static void drawTriangleAtEnd (const Position &p1, const Position &p2, double tLength, double tWidth)
 Draws a triangle at the end of the given line. More...
 
static RGBColor getColor ()
 gets the gl-color More...
 
static void setColor (const RGBColor &c)
 Sets the gl-color to this value. More...
 

Static Private Member Functions

static int angleLookup (double angleDeg)
 normalize angle for lookup in myCircleCoords More...
 
static bool rightTurn (double angle1, double angle2)
 whether the road makes a right turn (or goes straight) More...
 

Static Private Attributes

static std::vector< std::pair< double, double > > myCircleCoords
 Storage for precomputed sin/cos-values describing a circle. More...
 

Detailed Description

Some methods which help to draw certain geometrical objects in openGL.

This class offers some static methods for drawing primitives in openGL.

Definition at line 50 of file GLHelper.h.

Member Function Documentation

◆ angleLookup()

int GLHelper::angleLookup ( double  angleDeg)
staticprivate

normalize angle for lookup in myCircleCoords

Definition at line 328 of file GLHelper.cpp.

References CIRCLE_RESOLUTION, and myCircleCoords.

Referenced by drawFilledCircle().

◆ debugVertices()

void GLHelper::debugVertices ( const PositionVector shape,
double  size,
double  layer = 256 
)
static

draw vertex numbers for the given shape (in a random color)

Definition at line 528 of file GLHelper.cpp.

References drawText(), RGBColor::fromHSV(), RandHelper::rand(), and toString().

Referenced by GUIPolygon::drawGL(), GUIJunctionWrapper::drawGL(), and GUILane::drawGL().

◆ drawBoxLine() [1/2]

void GLHelper::drawBoxLine ( const Position beg,
double  rot,
double  visLength,
double  width,
double  offset = 0 
)
static

Draws a thick line.

The line is drawn as a GL_QUADS.

Parameters
[in]begThe begin position of the line
[in]rotThe direction the line shall be drawn to (in radiants)
[in]visLengthThe length of the line
[in]widthThe width of the line
[in]offsetThe orthogonal offset

Definition at line 126 of file GLHelper.cpp.

References Position::x(), and Position::y().

Referenced by GUIBaseVehicle::drawAction_drawVehicleAsPoly(), GNELane::drawArrows(), GUILane::drawArrows(), drawBoxLines(), GNEDetectorExit::drawGL(), GNEDetectorEntry::drawGL(), GNEJunction::drawGL(), GUIBusStop::drawGL(), GUIE3Collector::MyWrapper::drawSingleCrossing(), and drawTextBox().

◆ drawBoxLine() [2/2]

void GLHelper::drawBoxLine ( const Position beg1,
const Position beg2,
double  rot,
double  visLength,
double  width 
)
static

Draws a thick line using the mean of both given points as begin position.

The line is drawn as a GL_QUADS.

Parameters
[in]beg1One of the begin positions of the line to use the mean of
[in]beg2One of the begin positions of the line to use the mean of
[in]rotThe direction the line shall be drawn to (in radiants)
[in]visLengthThe length of the line
[in]widthThe width of the line

Definition at line 142 of file GLHelper.cpp.

References Position::x(), and Position::y().

◆ drawBoxLines() [1/4]

void GLHelper::drawBoxLines ( const PositionVector geom,
const std::vector< double > &  rots,
const std::vector< double > &  lengths,
double  width,
int  cornerDetail = 0,
double  offset = 0 
)
static

Draws thick lines.

Each line is drawn using drawBoxLine.

Parameters
[in]geomThe list of begin positions of the lines
[in]rotsThe directions the lines shall be drawn to (in radiants)
[in]lengthsThe lengths of the lines
[in]widthThe width of the lines
[in]cornerDetailDetail level for filling the corners between angled segments
[in]theorthogonal offset
See also
drawBoxLine

Definition at line 172 of file GLHelper.cpp.

References drawBoxLine(), drawFilledCircle(), MIN2(), and rightTurn().

Referenced by GUIPerson::drawAction_drawWalkingareaPath(), GUIVehicle::drawBestLanes(), GNEDetectorE2::drawGL(), GNEBusStop::drawGL(), GNEContainerStop::drawGL(), GNEInternalLane::drawGL(), GNEChargingStation::drawGL(), GNELane::drawGL(), GUIChargingStation::drawGL(), GUIContainerStop::drawGL(), GUIBusStop::drawGL(), GNEConnection::drawGL(), GUIParkingArea::drawGL(), GUIE2Collector::MyWrapper::drawGL(), GUILane::drawGL(), GUIPerson::drawGLAdditional(), GUILane::drawMarkings(), GNELane::drawMarkings(), GUIVehicle::drawRouteHelper(), GUIMEVehicle::drawRouteHelper(), and GUIPolygon::performTesselation().

◆ drawBoxLines() [2/4]

void GLHelper::drawBoxLines ( const PositionVector geom,
const std::vector< double > &  rots,
const std::vector< double > &  lengths,
const std::vector< RGBColor > &  cols,
double  width,
int  cornerDetail = 0,
double  offset = 0 
)
static

Draws thick lines with varying color.

Each line is drawn using drawBoxLine.

Parameters
[in]geomThe list of begin positions of the lines
[in]rotsThe directions the lines shall be drawn to (in radiants)
[in]lengthsThe lengths of the lines
[in]colsThe colors of the lines
[in]widthThe width of the lines
[in]cornerDetailDetail level for filling the corners between angled segments
[in]theorthogonal offset
See also
drawBoxLine

Definition at line 214 of file GLHelper.cpp.

References drawBoxLine(), drawFilledCircle(), and setColor().

◆ drawBoxLines() [3/4]

void GLHelper::drawBoxLines ( const PositionVector geom1,
const PositionVector geom2,
const std::vector< double > &  rots,
const std::vector< double > &  lengths,
double  width 
)
static

Draws thick lines using the mean of the points given in the point lists as begin positions.

Each line is drawn using drawBoxLine.

Parameters
[in]geom1One of the lists to obtain the lines' begin positions to use the mean of
[in]geom2One of the lists to obtain the lines' begin positions to use the mean of
[in]rotsThe directions the lines shall be drawn to (in radiants)
[in]lengthsThe lengths of the lines
[in]widthThe width of the lines
See also
drawBoxLine

Definition at line 238 of file GLHelper.cpp.

References drawBoxLine(), and MIN4().

◆ drawBoxLines() [4/4]

void GLHelper::drawBoxLines ( const PositionVector geom,
double  width 
)
static

Draws thick lines.

Widths and length are computed internally by this method, each line is then drawn using drawBoxLine.

Parameters
[in]geomThe list of begin positions of the lines
[in]widthThe width of the lines
See also
drawBoxLine

Definition at line 251 of file GLHelper.cpp.

References Position::distanceTo(), drawBoxLine(), RAD2DEG, Position::x(), and Position::y().

◆ drawFilledCircle() [1/2]

◆ drawFilledCircle() [2/2]

void GLHelper::drawFilledCircle ( double  width,
int  steps,
double  beg,
double  end 
)
static

Draws a filled circle around (0,0)

The circle is drawn use GL_TRIANGLES.

Parameters
[in]widthThe width of the circle
[in]stepsThe number of steps to divide the circle into
[in]begThe begin angle in degress
[in]endThe end angle in degress

Definition at line 346 of file GLHelper.cpp.

References angleLookup(), CIRCLE_RESOLUTION, DEG2RAD, and myCircleCoords.

◆ drawFilledPoly()

void GLHelper::drawFilledPoly ( const PositionVector v,
bool  close 
)
static

Draws a filled polygon described by the list of points.

Note
this only works well for convex polygons
Parameters
[in]vThe polygon to draw
[in]closeWhether the first point shall be appended

Definition at line 72 of file GLHelper.cpp.

References Position::x(), and Position::y().

Referenced by GNEJunction::drawGL(), GUIJunctionWrapper::drawGL(), and GUILane::drawGL().

◆ drawFilledPolyTesselated()

void GLHelper::drawFilledPolyTesselated ( const PositionVector v,
bool  close 
)
static

Draws a filled polygon described by the list of points.

Note
this works for convex and concave polygons but is slower than drawFilledPoly
Parameters
[in]vThe polygon to draw
[in]closeWhether the first point shall be appended

Definition at line 91 of file GLHelper.cpp.

References combCallback().

Referenced by GNEJunction::drawGL(), GUIJunctionWrapper::drawGL(), and GUILane::drawGL().

◆ drawLine() [1/5]

void GLHelper::drawLine ( const Position beg,
double  rot,
double  visLength 
)
static

Draws a thin line.

The line is drawn as a GL_LINES.

Parameters
[in]begThe begin position of the line
[in]rotThe direction the line shall be drawn to (in radiants)
[in]visLengthThe length of the line

Definition at line 265 of file GLHelper.cpp.

References Position::x(), and Position::y().

Referenced by GUIVehicle::drawAction_drawPersonsAndContainers(), GUIVehicle::drawBestLanes(), GNEInternalLane::drawGL(), GNELane::drawGL(), GNEConnection::drawGL(), GUIE2Collector::MyWrapper::drawGL(), GUILane::drawGL(), GNEAdditional::drawParentAndChildrenConnections(), and GUIPolygon::performTesselation().

◆ drawLine() [2/5]

void GLHelper::drawLine ( const Position beg1,
const Position beg2,
double  rot,
double  visLength 
)
static

Draws a thin line using the mean of both given points as begin position.

The line is drawn as a GL_LINES.

Parameters
[in]beg1One of the begin positions of the line to use the mean of
[in]beg2One of the begin positions of the line to use the mean of
[in]rotThe direction the line shall be drawn to (in radiants)
[in]visLengthThe length of the line

Definition at line 278 of file GLHelper.cpp.

References Position::x(), and Position::y().

◆ drawLine() [3/5]

void GLHelper::drawLine ( const PositionVector v)
static

Draws a thin line along the given position vector.

The line is drawn as a GL_LINES.

Parameters
[in]vThe positions vector to use

Definition at line 293 of file GLHelper.cpp.

◆ drawLine() [4/5]

void GLHelper::drawLine ( const PositionVector v,
const std::vector< RGBColor > &  cols 
)
static

Draws a thin line along the given position vector with variable color.

The line is drawn as a GL_LINES.

Parameters
[in]vThe positions vector to use

Definition at line 305 of file GLHelper.cpp.

References setColor().

◆ drawLine() [5/5]

void GLHelper::drawLine ( const Position beg,
const Position end 
)
static

Draws a thin line between the two points.

The line is drawn as a GL_LINES.

Parameters
[in]begBegin of the line
[in]endEnd of the line

Definition at line 319 of file GLHelper.cpp.

References Position::x(), and Position::y().

◆ drawOutlineCircle() [1/2]

void GLHelper::drawOutlineCircle ( double  width,
double  iwidth,
int  steps = 8 
)
static

Draws an unfilled circle around (0,0)

The circle is drawn by calling drawOutlineCircle(width, iwidth, steps, 0, 360).

Parameters
[in]widthThe (outer) width of the circle
[in]iwidthThe inner width of the circle
[in]stepsThe number of steps to divide the circle into

Definition at line 371 of file GLHelper.cpp.

Referenced by GNELane::drawArrows(), and GUIBaseVehicle::drawOnPos().

◆ drawOutlineCircle() [2/2]

void GLHelper::drawOutlineCircle ( double  width,
double  iwidth,
int  steps,
double  beg,
double  end 
)
static

Draws an unfilled circle around (0,0)

The circle is drawn use GL_TRIANGLES.

Parameters
[in]widthThe (outer) width of the circle
[in]iwidthThe inner width of the circle
[in]stepsThe number of steps to divide the circle into
[in]begThe begin angle in degress
[in]endThe end angle in degress

Definition at line 377 of file GLHelper.cpp.

References DEG2RAD, and myCircleCoords.

◆ drawText()

◆ drawTextAtEnd()

void GLHelper::drawTextAtEnd ( const std::string &  text,
const PositionVector shape,
double  x,
double  size,
RGBColor  color 
)
static

draw text and the end of shape

Definition at line 514 of file GLHelper.cpp.

References drawText(), RAD2DEG, Position::x(), and Position::y().

Referenced by GNELane::drawLinkNo(), GUILane::drawLinkNo(), GNELane::drawTLSLinkNo(), and GUILane::drawTLSLinkNo().

◆ drawTextBox()

void GLHelper::drawTextBox ( const std::string &  text,
const Position pos,
const double  layer,
const double  size,
const RGBColor txtColor = RGBColor::BLACK,
const RGBColor bgColor = RGBColor::WHITE,
const RGBColor borderColor = RGBColor::BLACK,
const double  angle = 0 
)
static

◆ drawTriangleAtEnd()

void GLHelper::drawTriangleAtEnd ( const Position p1,
const Position p2,
double  tLength,
double  tWidth 
)
static

Draws a triangle at the end of the given line.

Parameters
[in]p1The start of the line at which end the triangle shall be drawn
[in]p2The end of the line at which end the triangle shall be drawn
[in]tLengthThe length of the triangle
[in]tWidthThe width of the triangle

Definition at line 418 of file GLHelper.cpp.

References Position::angleTo2D(), Position::distanceTo(), GeomHelper::naviDegree(), PositionVector::positionAtOffset(), Position::x(), and Position::y().

Referenced by GNELane::drawArrows(), GUILane::drawArrows(), GNEDetectorExit::drawGL(), GNEDetectorEntry::drawGL(), GNELane::drawLane2LaneConnections(), GUILane::drawLane2LaneConnections(), and GUIE3Collector::MyWrapper::drawSingleCrossing().

◆ getColor()

◆ rightTurn()

bool GLHelper::rightTurn ( double  angle1,
double  angle2 
)
staticprivate

whether the road makes a right turn (or goes straight)

Definition at line 159 of file GLHelper.cpp.

Referenced by drawBoxLines().

◆ setColor()

Field Documentation

◆ myCircleCoords

std::vector< std::pair< double, double > > GLHelper::myCircleCoords
staticprivate

Storage for precomputed sin/cos-values describing a circle.

Definition at line 309 of file GLHelper.h.

Referenced by angleLookup(), drawFilledCircle(), and drawOutlineCircle().


The documentation for this class was generated from the following files: