50 const GLubyte* estring;
52 estring = gluErrorString(errorCode);
53 fprintf(stderr,
"Tessellation Error: %s\n", estring);
64 glVertex3dv((GLdouble*) vertex);
69 GLdouble* vertex_data[4],
70 GLfloat weight[4], GLdouble** dataOut) {
75 vertex = (GLdouble*) malloc(7 *
sizeof(GLdouble));
77 vertex[0] = coords[0];
78 vertex[1] = coords[1];
79 vertex[2] = coords[2];
93 bool fill,
double lineWidth,
double layer,
double angle,
const std::string& imgFile,
95 SUMOPolygon(id, type, color, shape, geo, fill, lineWidth, layer, angle, imgFile, relativePath),
98 myRotatedShape(nullptr) {
116 new FXMenuSeparator(ret);
152 FXMutexLock locker(
myLock);
172 FXMutexLock locker(
myLock);
195 double* points =
new double[shape.size() * 3];
196 GLUtesselator* tobj = gluNewTess();
197 gluTessCallback(tobj, GLU_TESS_VERTEX, (GLvoid(APIENTRY*)()) &glVertex3dv);
198 gluTessCallback(tobj, GLU_TESS_BEGIN, (GLvoid(APIENTRY*)()) &
beginCallback);
199 gluTessCallback(tobj, GLU_TESS_END, (GLvoid(APIENTRY*)()) &
endCallback);
201 gluTessCallback(tobj, GLU_TESS_COMBINE, (GLvoid(APIENTRY*)()) &
combineCallback);
202 gluTessProperty(tobj, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD);
203 gluTessBeginPolygon(tobj,
nullptr);
204 gluTessBeginContour(tobj);
205 for (
int i = 0; i != (int)shape.size(); ++i) {
206 points[3 * i] = shape[(int) i].x();
207 points[3 * i + 1] = shape[(int) i].y();
208 points[3 * i + 2] = 0;
209 gluTessVertex(tobj, points + 3 * i, points + 3 * i);
211 gluTessEndContour(tobj);
213 gluTessEndPolygon(tobj);
231 throw ProcessError(
"GUIPolygon::storeTesselation() could not create display list");
246 }
else if (active == 0) {
248 }
else if (active == 1) {
266 if (polygon->
getShape().size() < 3) {
270 if (polygon->
getShape().size() < 2) {
280 const PositionVector shape,
double layer,
bool disableSelectionColor) {
282 glTranslated(0, 0, layer);
283 setColor(s, polygon, o, disableSelectionColor);
292 if (textureID >= 0) {
293 glEnable(GL_TEXTURE_2D);
294 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
295 glDisable(GL_CULL_FACE);
296 glDisable(GL_DEPTH_TEST);
297 glDisable(GL_LIGHTING);
298 glDisable(GL_COLOR_MATERIAL);
299 glDisable(GL_ALPHA_TEST);
301 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
302 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
303 glBindTexture(GL_TEXTURE_2D, textureID);
304 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
305 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
307 glEnable(GL_TEXTURE_GEN_S);
308 glEnable(GL_TEXTURE_GEN_T);
309 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
310 glTexGenfv(GL_S, GL_OBJECT_PLANE,
xPlane);
311 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
312 glTexGenfv(GL_T, GL_OBJECT_PLANE,
yPlane);
318 if (textureID >= 0) {
319 glEnable(GL_DEPTH_TEST);
320 glBindTexture(GL_TEXTURE_2D, 0);
321 glDisable(GL_TEXTURE_2D);
322 glDisable(GL_TEXTURE_GEN_S);
323 glDisable(GL_TEXTURE_GEN_T);
325 #ifdef GUIPolygon_DEBUG_DRAW_VERTICES
GUISelectedStorage gSelected
A global holder of selected objects.
void APIENTRY errorCallback(GLenum errorCode)
void APIENTRY vertexCallback(GLvoid *vertex)
void APIENTRY combineCallback(GLdouble coords[3], GLdouble *vertex_data[4], GLfloat weight[4], GLdouble **dataOut)
void APIENTRY beginCallback(GLenum which)
void APIENTRY endCallback(void)
#define UNUSED_PARAMETER(x)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
A class that stores a 2D geometrical boundary.
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Boundary & grow(double by)
extends the boundary by the given amount
double getHeight() const
Returns the height of the boundary (y-axis)
double getWidth() const
Returns the width of the boudary (x-axis)
static void debugVertices(const PositionVector &shape, double size, double layer=256)
draw vertex numbers for the given shape (in a random color)
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
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.
static void drawTextSettings(const GUIVisualizationTextSettings &settings, const std::string &text, const Position &pos, const double scale, const double angle=0, const double layer=2048, const int align=0)
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel)
build menu command
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used,...
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
GUIGlID getGlID() const
Returns the numerical id of the object.
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0) const
draw name of item
A window containing a gl-object's parameter.
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
virtual void setShape(const PositionVector &shape)
set a new shape and update the tesselation
static bool checkDraw(const GUIVisualizationSettings &s, const SUMOPolygon *polygon, const GUIGlObject *o)
check if Polygon can be drawn
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
void storeTesselation(const bool fill, const PositionVector &shape, double lineWidth) const
store the drawing commands in a display list
static void setColor(const GUIVisualizationSettings &s, const SUMOPolygon *polygon, const GUIGlObject *o, bool disableSelectionColor)
set color
PositionVector * myRotatedShape
shape rotated on the centroid, if rotation is needed, nullptr otherwise
GLuint myDisplayList
id of the display list for the cached tesselation
static void drawInnerPolygon(const GUIVisualizationSettings &s, const SUMOPolygon *polygon, const GUIGlObject *o, const PositionVector shape, double layer, bool disableSelectionColor)
draw inner Polygon (before pushName() )
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
static void performTesselation(const bool fill, const PositionVector &shape, const double lineWidth)
FXMutex myLock
The mutex used to avoid concurrent updates of the shape.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
GUIPolygon(const std::string &id, const std::string &type, const RGBColor &color, const PositionVector &shape, bool geo, bool fill, double lineWidth, double layer=0, double angle=0, const std::string &imgFile="", bool relativePath=false)
Constructor.
virtual void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
const T getColor(const double value) const
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
static int getTextureID(const std::string &filename, const bool mirrorX=false)
return texture id for the given filename (initialize on first use)
Stores the information about how to visualize structures.
GUIColorer polyColorer
The polygon colorer.
double scale
information about a lane's width (temporary, used for a single view)
bool netedit
Whether the settings are for Netedit.
GUIVisualizationTextSettings polyName
GUIVisualizationSizeSettings polySize
GUIVisualizationTextSettings polyType
double angle
The current view rotation angle.
A point in 2D or 3D with translation and scaling methods.
void rotate2D(double angle)
Position getPolygonCenter() const
Returns the arithmetic of all corner points.
void add(double xoff, double yoff, double zoff)
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
void sub(double xoff, double yoff, double zoff)
Position getCentroid() const
Returns the centroid (closes the polygon if unclosed)
const PositionVector & getShape() const
Returns whether the shape of the polygon.
PositionVector myShape
The positions of the polygon.
virtual void setShape(const PositionVector &shape)
Sets the shape of the polygon.
double getLineWidth() const
Returns whether the polygon is filled.
bool getFill() const
Returns whether the polygon is filled.
const RGBColor & getShapeColor() const
Returns the color of the Shape.
const std::string & getShapeImgFile() const
Returns the imgFile of the Shape.
double getShapeLayer() const
Returns the layer of the Shape.
double getShapeNaviDegree() const
Returns the angle of the Shape in navigational degrees.
const std::string & getShapeType() const
Returns the (abstract) type of the Shape.
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
double minSize
The minimum size to draw this object.