48#define MAX_COMBINE_INDEX 1024
78 GLdouble* p3 = (GLdouble*) vertex;
85 GLdouble* vertex_data[4],
86 GLfloat weight[4], GLdouble** dataOut) {
97 const GLubyte* estring;
99 estring = gluErrorString(errorCode);
100 fprintf(stderr,
"Tessellation Error: %s\n", estring);
121 size_t numPoints = shape.size() * 3;
123 numPoints += hole.size() * 3;
125 double* points =
new double[numPoints];
126 GLUtesselator* tobj = gluNewTess();
129#pragma warning(disable: 4191)
131#if defined(__GNUC__) && __GNUC__ >= 8
132#pragma GCC diagnostic push
133#pragma GCC diagnostic ignored "-Wcast-function-type"
140#if defined(__GNUC__) && __GNUC__ >= 8
141#pragma GCC diagnostic pop
146 gluTessProperty(tobj, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD);
147 gluTessBeginPolygon(tobj,
nullptr);
148 gluTessBeginContour(tobj);
149 for (
int i = 0; i < (int)shape.size(); i++) {
150 points[3 * i] = shape[i].x();
151 points[3 * i + 1] = shape[i].y();
152 points[3 * i + 2] = 0.;
153 gluTessVertex(tobj, points + 3 * i, points + 3 * i);
155 gluTessEndContour(tobj);
156 size_t startIndex = shape.size() * 3;
158 gluTessBeginContour(tobj);
159 for (
int i = 0; i < (int)hole.size(); i++) {
160 points[startIndex + 3 * i] = hole[i].x();
161 points[startIndex + 3 * i + 1] = hole[i].y();
162 points[startIndex + 3 * i + 2] = 0.;
163 gluTessVertex(tobj, points + startIndex + 3 * i, points + startIndex + 3 * i);
165 startIndex += hole.size() * 3;
166 gluTessEndContour(tobj);
168 gluTessEndPolygon(tobj);
176 glVertex3d(p.x(), p.y(), p.z());
189 double lineWidth,
double layer,
double angle,
const std::string& imgFile,
190 bool relativePath,
const std::string& name):
191 TesselatedPolygon(id, type, color, shape, geo, fill, lineWidth, layer, angle, imgFile, relativePath, name),
193 myRotatedShape(nullptr) {
211 new FXMenuSeparator(ret);
254 FXMutexLock locker(
myLock);
271 FXMutexLock locker(
myLock);
298 }
else if (active == 0) {
300 }
else if (active == 1) {
302 }
else if (active == 2) {
306 std::hash<const SUMOPolygon*> ptr_hash;
307 const double hue = (double)(ptr_hash(polygon) % 360);
308 const double sat = (double)((ptr_hash(polygon) / 360) % 67) / 100.0 + 0.33;
311 if (alphaOverride >= 0 && alphaOverride <= 255) {
312 color.
setAlpha((
unsigned char)alphaOverride);
329 if (polygon->
getShape().size() < 3) {
333 if (polygon->
getShape().size() < 2) {
344 const bool disableSelectionColor,
const int alphaOverride,
const bool disableText) {
346 glTranslated(0, 0, layer);
347 setColor(s, polygon, o, disableSelectionColor, alphaOverride);
356 if (textureID >= 0) {
357 glEnable(GL_TEXTURE_2D);
358 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
359 glDisable(GL_CULL_FACE);
360 glDisable(GL_DEPTH_TEST);
361 glDisable(GL_LIGHTING);
362 glDisable(GL_COLOR_MATERIAL);
363 glDisable(GL_ALPHA_TEST);
365 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
366 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
367 glBindTexture(GL_TEXTURE_2D, textureID);
368 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
369 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
371 glEnable(GL_TEXTURE_GEN_S);
372 glEnable(GL_TEXTURE_GEN_T);
373 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
374 glTexGendv(GL_S, GL_OBJECT_PLANE,
xPlane);
375 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
376 glTexGendv(GL_T, GL_OBJECT_PLANE,
yPlane);
386 if (textureID >= 0) {
387 glEnable(GL_DEPTH_TEST);
388 glBindTexture(GL_TEXTURE_2D, 0);
389 glDisable(GL_TEXTURE_2D);
390 glDisable(GL_TEXTURE_GEN_S);
391 glDisable(GL_TEXTURE_GEN_T);
GUISelectedStorage gSelected
A global holder of selected objects.
GUIIcon
An enumeration of icons used by the gui applications.
void CALLBACK errorCallback(GLenum errorCode)
static const GLdouble INV_POLY_TEX_DIM
void CALLBACK combineCallback(GLdouble coords[3], GLdouble *vertex_data[4], GLfloat weight[4], GLdouble **dataOut)
const TesselatedPolygon * myCurrentTesselated
GLdouble myCombineVertices[MAX_COMBINE_INDEX][3]
#define MAX_COMBINE_INDEX
static const GLdouble yPlane[]
void CALLBACK beginCallback(GLenum which)
void CALLBACK endCallback(void)
std::vector< Position > myCurrentPoints
void CALLBACK vertexCallback(GLvoid *vertex)
static const GLdouble xPlane[]
#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 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 pushName(unsigned int name)
push Name
static void popMatrix()
pop matrix
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 debugVertices(const PositionVector &shape, const GUIVisualizationTextSettings &settings, double scale, double layer=1024)
draw vertex numbers for the given shape (in a random color)
static void popName()
pop Name
static void pushMatrix()
push matrix
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, const bool disable=false)
build menu command
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.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
virtual double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, const GUIMainWindow &app) const
Builds an entry which allows to copy the cursor position if geo projection is used,...
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, bool forceShow=false) 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.
static void drawInnerPolygon(const GUIVisualizationSettings &s, const TesselatedPolygon *polygon, const GUIGlObject *o, const PositionVector shape, const double layer, const bool fill, const bool disableSelectionColor=false, const int alphaOverride=-1, const bool disableText=false)
draw inner Polygon (before pushName() )
static bool checkDraw(const GUIVisualizationSettings &s, const SUMOPolygon *polygon, const GUIGlObject *o)
check if Polygon can be drawn
virtual void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
PositionVector * myRotatedShape
shape rotated on the centroid, if rotation is needed, nullptr otherwise
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, const std::string &name=DEFAULT_NAME)
Constructor.
FXMutex myLock
The mutex used to avoid concurrent updates of the shape.
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
static RGBColor setColor(const GUIVisualizationSettings &s, const SUMOPolygon *polygon, const GUIGlObject *o, bool disableSelectionColor, int alphaOverride)
set color
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
bool myIsActive
Is the polygon will be drawn or not.
virtual void setShape(const PositionVector &shape) override
set a new shape and update the tesselation
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.
double polyCustomLayer
the custom layer for polygons
GUIVisualizationTextSettings geometryIndices
GUIColorer polyColorer
The polygon colorer.
bool polyUseCustomLayer
whether the rendering layer of polygons should be overriden
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.
Position getCentroid() const
Returns the centroid (closes the polygon if unclosed)
void sub(const Position &offset)
void setAlpha(unsigned char alpha)
Sets a new alpha value.
static RGBColor fromHSV(double h, double s, double v)
Converts the given hsv-triplet to rgb, inspired by http://alvyray.com/Papers/CG/hsv2rgb....
const PositionVector & getShape() const
Returns the shape of the polygon.
PositionVector myShape
The positions of the polygon.
double getLineWidth() const
Returns whether the polygon is filled.
virtual void setShape(const PositionVector &shape)
Sets the shape of the polygon.
std::vector< PositionVector > myHoles
The collection of the holes of the polygon, each given by a sequence of coodinates.
bool getFill() const
Returns whether the polygon is filled.
const std::string getShapeName() const
Returns the name of the Shape.
const std::string & getShapeType() const
Returns the (abstract) type of the Shape.
double getShapeLayer() const
Returns the layer of the Shape.
const std::string & getShapeImgFile() const
Returns the imgFile of the Shape.
const RGBColor & getShapeColor() const
Returns the color of the Shape.
double getShapeNaviDegree() const
Returns the angle of the Shape in navigational degrees.
std::vector< GLPrimitive > myTesselation
id of the display list for the cached tesselation
void drawTesselation(const PositionVector &shape) const
perform the tesselation / drawing
most likely I'm reinventing the wheel here
std::vector< Position > vert
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.
bool show(const GUIGlObject *o) const
whether to show the text