39 #ifdef CHECK_MEMORY_LEAKS
41 #endif // CHECK_MEMORY_LEAKS
51 GLdouble* vertex_data[4],
52 GLfloat weight[4], GLdouble** dataOut) {
57 vertex = (GLdouble*)malloc(7 *
sizeof(GLdouble));
59 vertex[0] = coords[0];
60 vertex[1] = coords[1];
61 vertex[2] = coords[2];
75 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
77 for (PositionVector::const_iterator i = v.begin(); i != v.end(); i++) {
79 glVertex2d(p.
x(), p.
y());
83 glVertex2d(p.
x(), p.
y());
94 GLUtesselator* tobj = gluNewTess();
95 gluTessCallback(tobj, GLU_TESS_VERTEX, (GLvoid(APIENTRY*)()) &glVertex3dv);
96 gluTessCallback(tobj, GLU_TESS_BEGIN, (GLvoid(APIENTRY*)()) &glBegin);
97 gluTessCallback(tobj, GLU_TESS_END, (GLvoid(APIENTRY*)()) &glEnd);
98 gluTessCallback(tobj, GLU_TESS_COMBINE, (GLvoid(APIENTRY*)()) &
combCallback);
99 gluTessProperty(tobj, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD);
100 gluTessBeginPolygon(tobj, NULL);
101 gluTessBeginContour(tobj);
102 double* points =
new double[(v.size() +
int(close)) * 3];
104 for (
size_t i = 0; i != v.size(); ++i) {
105 points[3 * i] = v[(
int)i].x();
106 points[3 * i + 1] = v[(
int)i].y();
107 points[3 * i + 2] = 0;
108 gluTessVertex(tobj, points + 3 * i, points + 3 * i);
111 const size_t i = v.size();
112 points[3 * i] = v[0].x();
113 points[3 * i + 1] = v[0].y();
114 points[3 * i + 2] = 0;
115 gluTessVertex(tobj, points + 3 * i, points + 3 * i);
117 gluTessEndContour(tobj);
118 gluTessEndPolygon(tobj);
127 glTranslated(beg.
x(), beg.
y(), 0);
128 glRotated(rot, 0, 0, 1);
130 glVertex2d(-width, 0);
131 glVertex2d(-width, -visLength);
132 glVertex2d(width, -visLength);
133 glVertex2d(width, 0);
144 glTranslated((beg2.
x() + beg1.
x())*.5, (beg2.
y() + beg1.
y())*.5, 0);
145 glRotated(rot, 0, 0, 1);
147 glVertex2d(-width, 0);
148 glVertex2d(-width, -visLength);
149 glVertex2d(width, -visLength);
150 glVertex2d(width, 0);
158 const std::vector<SUMOReal>& rots,
159 const std::vector<SUMOReal>& lengths,
161 int e = (
int) geom.size() - 1;
162 for (
int i = 0; i < e; i++) {
171 const std::vector<SUMOReal>& rots,
172 const std::vector<SUMOReal>& lengths,
174 int minS = (
int)
MIN4(rots.size(), lengths.size(), geom1.size(), geom2.size());
175 for (
int i = 0; i < minS; i++) {
183 int e = (
int) geom.size() - 1;
184 for (
int i = 0; i < e; i++) {
198 glTranslated(beg.
x(), beg.
y(), 0);
199 glRotated(rot, 0, 0, 1);
202 glVertex2d(0, -visLength);
212 glTranslated((beg2.
x() + beg1.
x())*.5, (beg2.
y() + beg1.
y())*.5, 0);
213 glRotated(rot, 0, 0, 1);
216 glVertex2d(0, -visLength);
226 int e = (
int) v.size() - 1;
227 for (
int i = 0; i < e; ++i) {
228 glVertex2d(v[i].x(), v[i].y());
229 glVertex2d(v[i + 1].x(), v[i + 1].y());
239 glVertex2d(beg.
x(), beg.
y());
240 glVertex2d(end.
x(), end.
y());
255 for (
int i = 0; i < 360; i += 10) {
261 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
262 std::pair<SUMOReal, SUMOReal> p1 =
264 for (
int i = (
int)(beg / 10); i < steps && (36.0 / (
SUMOReal) steps * (
SUMOReal) i) * 10 < end; i++) {
265 const std::pair<SUMOReal, SUMOReal>& p2 =
267 glBegin(GL_TRIANGLES);
268 glVertex2d(p1.first * width, p1.second * width);
269 glVertex2d(p2.first * width, p2.second * width);
274 const std::pair<SUMOReal, SUMOReal>& p2 =
276 glBegin(GL_TRIANGLES);
277 glVertex2d(p1.first * width, p1.second * width);
278 glVertex2d(p2.first * width, p2.second * width);
294 for (
int i = 0; i < 360; i += 10) {
300 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
301 std::pair<SUMOReal, SUMOReal> p1 =
303 for (
int i = (
int)(beg / 10); i < steps && (36.0 / (
SUMOReal) steps * (
SUMOReal) i) * 10 < end; i++) {
304 const std::pair<SUMOReal, SUMOReal>& p2 =
306 glBegin(GL_TRIANGLES);
307 glVertex2d(p1.first * width, p1.second * width);
308 glVertex2d(p2.first * width, p2.second * width);
309 glVertex2d(p2.first * iwidth, p2.second * iwidth);
311 glVertex2d(p2.first * iwidth, p2.second * iwidth);
312 glVertex2d(p1.first * iwidth, p1.second * iwidth);
313 glVertex2d(p1.first * width, p1.second * width);
317 const std::pair<SUMOReal, SUMOReal>& p2 =
319 glBegin(GL_TRIANGLES);
320 glVertex2d(p1.first * width, p1.second * width);
321 glVertex2d(p2.first * width, p2.second * width);
322 glVertex2d(p2.first * iwidth, p2.second * iwidth);
324 glVertex2d(p2.first * iwidth, p2.second * iwidth);
325 glVertex2d(p1.first * iwidth, p1.second * iwidth);
326 glVertex2d(p1.first * width, p1.second * width);
334 if (l.
length() < tLength) {
335 tWidth = tWidth * l.
length() / tLength;
340 glTranslated(rl.p1().x(), rl.p1().y(), 0);
342 glBegin(GL_TRIANGLES);
343 glVertex2d(0, -tLength);
344 glVertex2d(-tWidth, 0);
345 glVertex2d(+tWidth, 0);
360 glGetDoublev(GL_CURRENT_COLOR, current);
361 return RGBColor(static_cast<unsigned char>(current[0] * 255. + 0.5),
362 static_cast<unsigned char>(current[1] * 255. + 0.5),
363 static_cast<unsigned char>(current[2] * 255. + 0.5),
364 static_cast<unsigned char>(current[3] * 255. + 0.5));
373 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
375 glTranslated(pos.
x(), pos.
y(), layer);
379 glRotated(180, 1, 0, 0);
380 glRotated(angle, 0, 0, 1);
381 glTranslated(-w / 2., 0.4, 0);
392 if (boxAngle > 360) {
397 const SUMOReal borderWidth = size / 20;
398 const SUMOReal boxHeight = size * 0.8;
399 const SUMOReal boxWidth = stringWidth + size / 2;
401 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
402 glTranslated(0, 0, layer);
405 left.
sub(boxWidth / 2, -boxHeight / 2.7);
407 left.
add(borderWidth * 1.5, 0);
409 glTranslated(0, 0, 0.01);
410 drawBoxLine(left, boxAngle, boxWidth - 3 * borderWidth, boxHeight - 2 * borderWidth);
415 glTranslated(pos.
x(), pos.
y(), 0.01);
418 glRotated(180, 1, 0, 0);
419 glRotated(angle, 0, 0, 1);
420 glTranslated(-stringWidth / 2., 0, 0);
void sub(SUMOReal dx, SUMOReal dy)
Substracts the given position from this one.
SUMOReal atan2DegreeAngle() const
int pfDrawString(const char *c)
const Position & p2() const
void add(const Position &pos)
Adds the given position to this one.
T MIN4(T a, T b, T c, T d)
static void drawOutlineCircle(SUMOReal width, SUMOReal iwidth, int steps=8)
Draws an unfilled circle around (0,0)
void pfSetPosition(SUMOReal x, SUMOReal y)
static void drawFilledPoly(const PositionVector &v, bool close)
Draws a filled polygon described by the list of points.
SUMOReal distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
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
SUMOReal x() const
Returns the x-position.
#define UNUSED_PARAMETER(x)
unsigned char blue() const
Returns the blue-amount of the color.
static void drawFilledPolyTesselated(const PositionVector &v, bool close)
Draws a filled polygon described by the list of points.
static void drawFilledCircle(SUMOReal width, int steps=8)
Draws a filled circle around (0,0)
Position getPositionAtDistance(SUMOReal offset) const
static std::vector< std::pair< SUMOReal, SUMOReal > > myCircleCoords
Storage for precomputed sin/cos-values describing a circle.
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
A point in 2D or 3D with translation and scaling methods.
unsigned char alpha() const
Returns the alpha-amount of the color.
static void drawBoxLines(const PositionVector &geom, const std::vector< SUMOReal > &rots, const std::vector< SUMOReal > &lengths, SUMOReal width)
Draws thick lines.
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
static void drawBoxLine(const Position &beg, SUMOReal rot, SUMOReal visLength, SUMOReal width)
Draws a thick line.
void APIENTRY combCallback(GLdouble coords[3], GLdouble *vertex_data[4], GLfloat weight[4], GLdouble **dataOut)
void pfSetScale(SUMOReal s)
static void drawTriangleAtEnd(const Line &l, SUMOReal tLength, SUMOReal tWidth)
Draws a triangle at the end of the given line.
SUMOReal y() const
Returns the y-position.
SUMOReal pfdkGetStringWidth(const char *c)
static void drawLine(const Position &beg, SUMOReal rot, SUMOReal visLength)
Draws a thin line.
unsigned char green() const
Returns the green-amount of the color.
unsigned char red() const
Returns the red-amount of the color.
static RGBColor getColor()
gets the gl-color