43 #ifdef CHECK_MEMORY_LEAKS
45 #endif // CHECK_MEMORY_LEAKS
54 Polygon(id, type, color, shape, fill, layer, angle, imgFile),
71 FXString t(
myType.c_str());
73 new FXMenuSeparator(ret);
103 const GLubyte* estring;
105 estring = gluErrorString(errorCode);
106 fprintf(stderr,
"Tessellation Error: %s\n", estring);
115 glVertex3dv((GLdouble*) vertex);
119 GLdouble* vertex_data[4],
120 GLfloat weight[4], GLdouble** dataOut) {
125 vertex = (GLdouble*) malloc(7 *
sizeof(GLdouble));
127 vertex[0] = coords[0];
128 vertex[1] = coords[1];
129 vertex[2] = coords[2];
172 if (textureID >= 0) {
173 glEnable(GL_TEXTURE_2D);
174 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
175 glDisable(GL_CULL_FACE);
176 glDisable(GL_DEPTH_TEST);
177 glDisable(GL_LIGHTING);
178 glDisable(GL_COLOR_MATERIAL);
179 glDisable(GL_ALPHA_TEST);
181 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
182 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
183 glBindTexture(GL_TEXTURE_2D, textureID);
184 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
185 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
187 glEnable(GL_TEXTURE_GEN_S);
188 glEnable(GL_TEXTURE_GEN_T);
189 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
190 glTexGenfv(GL_S, GL_OBJECT_PLANE,
xPlane);
191 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
192 glTexGenfv(GL_T, GL_OBJECT_PLANE,
yPlane);
198 if (textureID >= 0) {
199 glEnable(GL_DEPTH_TEST);
200 glBindTexture(GL_TEXTURE_2D, 0);
201 glDisable(GL_TEXTURE_2D);
202 glDisable(GL_TEXTURE_GEN_S);
203 glDisable(GL_TEXTURE_GEN_T);
214 Polygon::setShape(shape);
223 double* points =
new double[
myShape.size() * 3];
224 GLUtesselator* tobj = gluNewTess();
225 gluTessCallback(tobj, GLU_TESS_VERTEX, (GLvoid(APIENTRY*)()) &glVertex3dv);
226 gluTessCallback(tobj, GLU_TESS_BEGIN, (GLvoid(APIENTRY*)()) &
beginCallback);
227 gluTessCallback(tobj, GLU_TESS_END, (GLvoid(APIENTRY*)()) &
endCallback);
229 gluTessCallback(tobj, GLU_TESS_COMBINE, (GLvoid(APIENTRY*)()) &
combineCallback);
230 gluTessProperty(tobj, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD);
231 gluTessBeginPolygon(tobj, NULL);
232 gluTessBeginContour(tobj);
233 for (
size_t i = 0; i !=
myShape.size(); ++i) {
236 points[3 * i + 2] = 0;
237 gluTessVertex(tobj, points + 3 * i, points + 3 * i);
239 gluTessEndContour(tobj);
241 gluTessEndPolygon(tobj);
261 throw ProcessError(
"GUIPolygon::storeTesselation() could not create display list");
SUMOReal getHeight() const
Returns the height of the boundary.
const std::string & getImgFile() const
Returns the imgFile of the Shape.
SUMOReal getWidth() const
Returns the width of the boudary.
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
float polyExaggeration
The additional shapes (upscale)
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Stores the information about how to visualize structures.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
GUIPolygon(const std::string &id, const std::string &type, const RGBColor &color, const PositionVector &shape, bool fill, SUMOReal layer=0, SUMOReal angle=0, const std::string &imgFile="")
Constructor.
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.
#define UNUSED_PARAMETER(x)
A class that stores a 2D geometrical boundary.
GLuint myDisplayList
id of the display list for the cached tesselation
SUMOReal scale
information about a lane's width (temporary, used for a single view)
std::string myType
The type of the Shape.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
void performTesselation(SUMOReal lineWidth) const
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
void storeTesselation(SUMOReal lineWidth) const
store the drawing commands in a display list
static void drawBoxLines(const PositionVector &geom, const std::vector< SUMOReal > &rots, const std::vector< SUMOReal > &lengths, SUMOReal width)
Draws thick lines.
virtual void setShape(const PositionVector &shape)
set a new shape and update the tesselation
void drawName(const Position &pos, const SUMOReal scale, const GUIVisualizationTextSettings &settings, const SUMOReal angle=0) const
const RGBColor & getColor() const
Returns the color of the Shape.
SUMOReal myLineWidth
the previous line width for deciding whether the display list must be refreshed
void APIENTRY beginCallback(GLenum which)
void add(SUMOReal x, SUMOReal y)
Makes the boundary include the given coordinate.
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
void APIENTRY endCallback(void)
void APIENTRY combineCallback(GLdouble coords[3], GLdouble *vertex_data[4], GLfloat weight[4], GLdouble **dataOut)
A mutex encapsulator which locks/unlocks the given mutex on construction/destruction, respectively.
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
void APIENTRY vertexCallback(GLvoid *vertex)
MFXMutex myLock
The mutex used to avoid concurrent updates of the shape.
static void drawLine(const Position &beg, SUMOReal rot, SUMOReal visLength)
Draws a thin line.
SUMOReal getLayer() const
Returns the layer of the Shape.
Position getPolygonCenter() const
Returns the arithmetic of all corner points.
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
A window containing a gl-object's parameter.
PositionVector myShape
The positions of the polygon.
bool getFill() const
Returns whether the polygon is filled.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
float minPolySize
The minimum size of shapes to let them be drawn.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
void APIENTRY errorCallback(GLenum errorCode)
static int getTextureID(const std::string &filename)
return texture id for the given filename (initialize on first use)
GUIVisualizationTextSettings polyName