49 bool fill,
double layer,
double angle,
const std::string& imgFile):
50 SUMOPolygon(id, type, color, shape, geo, fill, layer, angle, imgFile),
67 FXString t(
myType.c_str());
68 new FXMenuCommand(ret,
"(" + t +
")", 0, 0, 0);
69 new FXMenuSeparator(ret);
106 const GLubyte* estring;
108 estring = gluErrorString(errorCode);
109 fprintf(stderr,
"Tessellation Error: %s\n", estring);
118 glVertex3dv((GLdouble*) vertex);
122 GLdouble* vertex_data[4],
123 GLfloat weight[4], GLdouble** dataOut) {
128 vertex = (GLdouble*) malloc(7 *
sizeof(GLdouble));
130 vertex[0] = coords[0];
131 vertex[1] = coords[1];
132 vertex[2] = coords[2];
182 if (textureID >= 0) {
183 glEnable(GL_TEXTURE_2D);
184 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
185 glDisable(GL_CULL_FACE);
186 glDisable(GL_DEPTH_TEST);
187 glDisable(GL_LIGHTING);
188 glDisable(GL_COLOR_MATERIAL);
189 glDisable(GL_ALPHA_TEST);
191 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
192 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
193 glBindTexture(GL_TEXTURE_2D, textureID);
194 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
195 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
197 glEnable(GL_TEXTURE_GEN_S);
198 glEnable(GL_TEXTURE_GEN_T);
199 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
200 glTexGenfv(GL_S, GL_OBJECT_PLANE,
xPlane);
201 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
202 glTexGenfv(GL_T, GL_OBJECT_PLANE,
yPlane);
208 if (textureID >= 0) {
209 glEnable(GL_DEPTH_TEST);
210 glBindTexture(GL_TEXTURE_2D, 0);
211 glDisable(GL_TEXTURE_2D);
212 glDisable(GL_TEXTURE_GEN_S);
213 glDisable(GL_TEXTURE_GEN_T);
215 #ifdef GUIPolygon_DEBUG_DRAW_VERTICES 241 double* points =
new double[
myShape.size() * 3];
242 GLUtesselator* tobj = gluNewTess();
243 gluTessCallback(tobj, GLU_TESS_VERTEX, (GLvoid(APIENTRY*)()) &glVertex3dv);
244 gluTessCallback(tobj, GLU_TESS_BEGIN, (GLvoid(APIENTRY*)()) &
beginCallback);
245 gluTessCallback(tobj, GLU_TESS_END, (GLvoid(APIENTRY*)()) &
endCallback);
247 gluTessCallback(tobj, GLU_TESS_COMBINE, (GLvoid(APIENTRY*)()) &
combineCallback);
248 gluTessProperty(tobj, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD);
249 gluTessBeginPolygon(tobj, NULL);
250 gluTessBeginContour(tobj);
251 for (
int i = 0; i != (int)
myShape.size(); ++i) {
252 points[3 * i] =
myShape[(int) i].x();
253 points[3 * i + 1] =
myShape[(int) i].y();
254 points[3 * i + 2] = 0;
255 gluTessVertex(tobj, points + 3 * i, points + 3 * i);
257 gluTessEndContour(tobj);
259 gluTessEndPolygon(tobj);
278 throw ProcessError(
"GUIPolygon::storeTesselation() could not create display list");
PositionVector myShape
The positions of the polygon.
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0) const
draw name of item
const std::string & getImgFile() const
Returns the imgFile of the Shape.
double scale
information about a lane's width (temporary, used for a single view)
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
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.
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
virtual void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Stores the information about how to visualize structures.
static void debugVertices(const PositionVector &shape, double size, double layer=256)
draw vertex numbers for the given shape (in a random color)
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
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, int align=0, double width=-1)
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
void storeTesselation(double lineWidth) const
store the drawing commands in a display list
const std::map< std::string, std::string > & getMap() const
Returns the inner key/value map.
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
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
std::string myType
The type of the Shape.
GUIVisualizationSizeSettings polySize
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
virtual void setShape(const PositionVector &shape)
Sets the shape of the polygon.
double getWidth() const
Returns the width of the boudary (x-axis)
double getExaggeration(const GUIVisualizationSettings &s, double factor=20) const
return the drawing size including exaggeration and constantSize values
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
double minSize
The minimum size to draw this object.
double getHeight() const
Returns the height of the boundary (y-axis)
A point in 2D or 3D with translation and scaling methods.
GUIVisualizationTextSettings polyType
static int getTextureID(const std::string &filename, const bool mirrorX=false)
return texture id for the given filename (initialize on first use)
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
bool getFill() const
Returns whether the polygon is filled.
Boundary & grow(double by)
extends the boundary by the given amount
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
virtual void setShape(const PositionVector &shape)
set a new shape and update the tesselation
const RGBColor & getColor() const
Returns the color of the Shape.
double getLayer() const
Returns the layer of the Shape.
void APIENTRY beginCallback(GLenum which)
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.
double myLineWidth
the previous line width for deciding whether the display list must be refreshed
Position getPolygonCenter() const
Returns the arithmetic of all corner points.
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
void mkItem(const char *name, bool dynamic, ValueSource< unsigned > *src)
Adds a row which obtains its value from an unsigned-ValueSource.
GUISelectedStorage gSelected
A global holder of selected objects.
double getNaviDegree() const
Returns the angle of the Shape in navigational degrees.
A window containing a gl-object's parameter.
GUIPolygon(const std::string &id, const std::string &type, const RGBColor &color, const PositionVector &shape, bool geo, bool fill, double layer=0, double angle=0, const std::string &imgFile="")
Constructor.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
void performTesselation(double lineWidth) const
void APIENTRY errorCallback(GLenum errorCode)
GUIVisualizationTextSettings polyName