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