45 TesselatedPolygon(
"",
"",
RGBColor::BLACK, {},
false,
false, 0, 0, 0,
"",
false,
"",
Parameterised::Map()),
46 GNEAdditional(
"", net,
GLO_POLYGON, tag,
GUIIconSubSys::getIcon(
GUIIcon::POLY),
"", {}, {}, {}, {}, {}, {}),
47mySimplifiedShape(
false) {
54 const RGBColor& color,
double layer,
double angle,
const std::string& imgFile,
bool relativePath,
const std::string& name,
56 TesselatedPolygon(id, type, color, shape, geo, fill, lineWidth, layer, angle, imgFile, relativePath, name, parameters),
57 GNEAdditional(id, net,
GLO_POLYGON,
SUMO_TAG_POLY,
GUIIconSubSys::getIcon(
GUIIcon::
POLY),
"", {}, {}, {}, {}, {}, {}),
58mySimplifiedShape(
false) {
66 for (
int i = 0; i < (int)
myGeoShape.size(); i++) {
70 for (
int i = 0; i < (int)
myGeoShape.size(); i++) {
83 TesselatedPolygon(id, getJuPedSimType(tag), getJuPedSimColor(tag), shape, geo, getJuPedSimFill(tag), 1,
84 getJuPedSimLayer(tag), 0,
"", false, name, parameters),
85 GNEAdditional(id, net, getJuPedSimGLO(tag), tag, getJuPedSimIcon(tag),
"", {}, {}, {}, {}, {}, {}),
86mySimplifiedShape(
false) {
90 for (
int i = 0; i < (int)
myGeoShape.size(); i++) {
94 for (
int i = 0; i < (int)
myGeoShape.size(); i++) {
134 if (shape.size() > 2) {
140 if ((index != -1) && shape[index].distanceSquaredTo2D(clickedPosition) < (snap_radius * snap_radius)) {
142 shape.erase(shape.begin() + index);
263 new FXMenuSeparator(ret);
279 new FXMenuSeparator(ret);
295 setFirstPoint->disable();
356 for (
const auto& shapePosition :
myShape) {
372 if (
myShape.
isClosed() && (index == 0 || index == (
int)modifiedShape.size() - 1) && (
myShape.size() > 2)) {
373 modifiedShape.erase(modifiedShape.begin());
374 modifiedShape.erase(modifiedShape.end() - 1);
375 modifiedShape.push_back(modifiedShape.front());
377 modifiedShape.erase(modifiedShape.begin() + index);
452 if (oldIndex >= (
int)
myShape.size()) {
454 }
else if (oldIndex == 0) {
455 WRITE_WARNING(
TL(
"Selected point must be different of the first point"))
459 for (
int i = oldIndex; i < (int)
myShape.size(); i++) {
460 newShape.push_back(
myShape[i]);
463 for (
int i = 1; i < oldIndex; i++) {
464 newShape.push_back(
myShape[i]);
466 newShape.push_back(newShape.front());
468 for (
int i = 0; i < oldIndex; i++) {
469 newShape.push_back(
myShape[i]);
500 simplifiedShape.push_back(simplifiedShape[0]);
528 return TL(
"Using GEO Shape");
536 return TL(
"No geo-conversion defined");
632 return canParse<PositionVector>(value);
635 return canParse<bool>(value);
637 return canParse<RGBColor>(value);
639 return canParse<bool>(value);
641 return canParse<double>(value) && (parse<double>(value) >= 0);
643 if (value ==
"default") {
646 return canParse<double>(value);
658 return canParse<bool>(value);
660 return canParse<double>(value);
662 return canParse<bool>(value);
666 if (canParse<bool>(value)) {
693 return myGEO ==
false;
701 return myGEO ==
true;
740 myShape = parse<PositionVector>(value);
743 for (
int i = 0; i < (int)
myGeoShape.size(); i++) {
759 for (
int i = 0; i < (int)
myShape.size(); i++) {
772 if (parse<bool>(value)) {
773 shape.push_back(shape.front());
784 myFill = parse<bool>(value);
791 if (value ==
"default") {
812 myGEO = parse<bool>(value);
820 if (parse<bool>(value)) {
864 const RGBColor& color,
const double exaggeration)
const {
884 const RGBColor& color,
const double exaggeration)
const {
888 glTranslated(0, 0, 0.1);
900 const RGBColor& color,
const double exaggeration)
const {
@ NETWORK_MOVE
mode for moving network elements
@ MID_GNE_POLYGON_CLOSE
close opened polygon
@ MID_GNE_POLYGON_SET_FIRST_POINT
Set a vertex of polygon as first vertex.
@ MID_GNE_POLYGON_SELECT
select elements within polygon boundary
@ MID_GNE_CUSTOM_GEOMETRYPOINT
set custom geometry point
@ MID_GNE_POLYGON_DELETE_GEOMETRY_POINT
delete geometry point
@ MID_GNE_POLYGON_OPEN
open closed polygon
@ MID_GNE_POLYGON_SIMPLIFY_SHAPE
simplify polygon geometry
GUIIcon
An enumeration of icons used by the gui applications.
#define WRITE_WARNING(msg)
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_POLY
begin/end of the description of a polygon
@ GNE_TAG_JPS_OBSTACLE
polygon used for draw juPedSim obstacles
@ GNE_TAG_JPS_WALKABLEAREA
polygon used for draw juPedSim walkable areas
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
@ GNE_ATTR_CLOSE_SHAPE
Close shape of a polygon (Used by GNEPolys)
@ SUMO_ATTR_SHAPE
edge: the shape in xml-definition
@ SUMO_ATTR_FILL
Fill the polygon.
@ SUMO_ATTR_LAYER
A layer number.
@ SUMO_ATTR_COLOR
A color information.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
A class that stores a 2D geometrical boundary.
Position getCenter() const
Returns the center of the boundary.
double ymin() const
Returns minimum y-coordinate.
double xmin() const
Returns minimum x-coordinate.
Boundary & grow(double by)
extends the boundary by the given amount
double ymax() const
Returns maximum y-coordinate.
double xmax() const
Returns maximum x-coordinate.
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
static void popMatrix()
pop matrix
static void drawBoundary(const GUIVisualizationSettings &s, const Boundary &b)
Draw a boundary (used for debugging)
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)
An Element which don't belong to GNENet but has influence in the simulation.
bool isValidAdditionalID(const std::string &value) const
check if a new additional ID is valid
void setAdditionalID(const std::string &newID)
set additional ID
GNEContour myAdditionalContour
variable used for draw additional contours
GUIGeometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
void calculateContourPolygons(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double layer, const double exaggeration, const bool filledShape) const
calculate contour for polygons
Boundary myAdditionalBoundary
Additional Boundary (used only by additionals placed over grid)
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
bool mySelected
boolean to check if this AC is selected (more quickly as checking GUIGlObjectStorage)
static const std::string True
true value in string format (used for comparing boolean values in getAttribute(......
void setCommonAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
const std::string & getTagStr() const
get tag assigned to this object in string format
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
bool isCommonValid(SumoXMLAttr key, const std::string &value)
void drawInLayer(const double typeOrLayer, const double extraOffset=0) const
draw element in the given layer, or in front if corresponding flag is enabled
void resetDefaultValues()
reset attribute carrier to their default values
GNENet * myNet
pointer to net
static const std::string False
true value in string format(used for comparing boolean values in getAttribute(...))
std::string getCommonAttribute(SumoXMLAttr key) const
const GNETagProperties & myTagProperty
reference to tagProperty associated with this attribute carrier
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
void clearContour() const
void clear contour
void drawDottedContourGeometryPoints(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const PositionVector &shape, const double radius, const double scale, const double lineWidth) const
draw dotted contour for geometry points
bool drawDottedContours(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const
draw dotted contours (basics, select, delete, inspect...)
GNEMoveOperation * calculateMoveShapeOperation(const GUIGlObject *obj, const PositionVector originalShape, const bool maintainShapeClosed)
calculate move shape operation
bool getMoveWholePolygons() const
move whole polygons
NetworkModeOptions * getNetworkModeOptions() const
get network mode options
PositionVector shapeToUpdate
shape to update (edited in moveElement)
A NBNetBuilder extended by visualisation and editing capabilities.
void addGLObjectIntoGrid(GNEAttributeCarrier *AC)
add GL Object into net
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
GNEViewNet * getViewNet() const
get view net
bool mySimplifiedShape
flag to indicate if polygon is simplified
std::string getAdditionalProblem() const override
return a string with the current additional problem (must be reimplemented in all detector children)
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
std::string getParentName() const override
Returns the name of the parent object.
double getAttributeDouble(SumoXMLAttr key) const override
bool isValid(SumoXMLAttr key, const std::string &value) override
method for checking if the key and their conrrespond attribute are valids
void updateGeometry() override
update pre-computed geometry information
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
void fixAdditionalProblem() override
fix additional problem (must be reimplemented in all detector children)
void writeAdditional(OutputDevice &device) const override
write additional element into a xml file
void drawPolygonNameAndType(const GUIVisualizationSettings &s) const
draw polygon name and type
GNEPoly(SumoXMLTag tag, GNENet *net)
default Constructor
GNEMoveOperation * getMoveOperation() override
get move operation
int getVertexIndex(Position pos, bool snapToGrid)
return index of a vertex of shape, or of a new vertex if position is over an shape's edge
PositionVector myGeoShape
Latitude of Polygon.
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
void closePolygon(bool allowUndo=true)
close polygon
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point
std::string getAttribute(SumoXMLAttr key) const override
bool checkDrawMoveContour() const override
check if draw move contour (red)
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList) override
commit move shape
bool isAdditionalValid() const override
check if current additional is valid to be written into XML (must be reimplemented in all detector ch...
void setMoveShape(const GNEMoveResult &moveResult) override
set move shape
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
method for setting the attribute and letting the object perform additional changes
void deleteGeometryPoint(const Position &pos, bool allowUndo=true)
delete the geometry point closest to the given pos
Position getPositionInView() const override
Returns position of shape in view.
void drawGeometryPoints(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw geometry points
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList) override
remove geometry point in the clicked position
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
void drawPolygon(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw polygon
bool isAttributeEnabled(SumoXMLAttr key) const override
void drawPolygonContour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw contour
bool isPolygonClosed() const
check if polygon is closed
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
void simplifyShape(bool allowUndo=true)
replace the current shape with a rectangle
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList) override
split geometry
void updateCenteringBoundary(const bool updateGrid) override
update centering boundary (implies change in RTREE)
const Parameterised::Map & getACParametersMap() const override
get parameters map
GUIGlID getGlID() const
Returns the numerical id of the object.
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
void openPolygon(bool allowUndo=true)
open polygon
bool isJuPedSimElement() const
return true if tag correspond to a JuPedSim element
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
const GUIGlObject * getGUIGlObjectFront() const
get front GUIGLObject or a pointer to nullptr
bool isCurrentlyMovingElements() const
check if an element is being moved
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
const GNEViewNetHelper::EditNetworkElementShapes & getEditNetworkElementShapes() const
get Edit Shape module
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
GNEViewParent * getViewParent() const
get the net object
bool checkOverLockedElement(const GUIGlObject *GLObject, const bool isSelected) const
check if given element is locked (used for drawing select and delete contour)
GNEUndoList * getUndoList() const
get the undoList object
const GNEViewNetHelper::ViewObjectsSelector & getViewObjectsSelector() const
get objects under cursor
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
const GNEViewNetHelper::DemandViewOptions & getDemandViewOptions() const
get demand view options
GNEMoveFrame * getMoveFrame() const
get frame for move elements
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel, const bool disable=false)
build menu command
static void drawGeometryPoints(const GUIVisualizationSettings::Detail d, const PositionVector &shape, const RGBColor &color, const double radius, const double exaggeration, const bool editingElevation)
draw geometry points
static void drawGeometry(const GUIVisualizationSettings::Detail d, const GUIGeometry &geometry, const double width, double offset=0)
draw geometry
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
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.
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
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
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
Position snapToActiveGrid(const Position &pos, bool snapXY=true) const
Returns a position that is mapped to the closest grid point if the grid is active.
const GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings (read only)
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
static int getTextureID(const std::string &filename, const bool mirrorX=false)
return texture id for the given filename (initialize on first use)
static void clearTextures()
clears loaded textures
Stores the information about how to visualize structures.
double polyCustomLayer
the custom layer for polygons
bool checkDrawPoly(const Boundary &b, const bool selected) const
check if draw polygon
Detail getDetailLevel(const double exaggeration) const
return the detail level
GUIVisualizationColorSettings colorSettings
color settings
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
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)
GUIVisualizationTextSettings polyName
GUIVisualizationSizeSettings polySize
GUIVisualizationTextSettings polyType
GUIVisualizationNeteditSizeSettings neteditSizeSettings
netedit size settings
double angle
The current view rotation angle.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
const std::string & getProjString() const
Returns the original projection definition.
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation.
std::string myID
The name of the object.
static const std::vector< SumoXMLTag > polygons
polygon namespace
Static storage of an output device and its base (abstract) implementation.
static bool areParametersValid(const std::string &value, bool report=false, const std::string kvsep="=", const std::string sep="|")
check if given string can be parsed to a parameters map "key1=value1|key2=value2|....
std::map< std::string, std::string > Map
parameters map
void setParametersStr(const std::string ¶msString, const std::string kvsep="=", const std::string sep="|")
set the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN"
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
std::string getParametersStr(const std::string kvsep="=", const std::string sep="|") const
Returns the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN".
A point in 2D or 3D with translation and scaling methods.
Position getPolygonCenter() const
Returns the arithmetic of all corner points.
void closePolygon()
ensures that the last position equals the first
int indexOfClosest(const Position &p, bool twoD=false) const
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
bool isClosed() const
check if PositionVector is closed
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
PositionVector myShape
The positions of the polygon.
double myLineWidth
The line width for drawing an unfilled polygon.
bool myGEO
specify if shape is handled as GEO coordinate (Main used in netedit)
void writeXML(OutputDevice &out, bool geo=false) const
bool myFill
Information whether the polygon has to be filled.
bool getFill() const
Returns whether the polygon is filled.
static bool isValidAttribute(const std::string &value)
whether the given string is a valid attribute for a certain key (for example, a name)
const std::string getShapeName() const
Returns the name of the Shape.
static const double DEFAULT_LAYER
void setShapeName(const std::string &name)
Sets a new shape name.
void setShapeLayer(const double layer)
Sets a new layer.
bool getShapeRelativePath() const
Returns the relativePath of the Shape.
const std::string & getShapeType() const
Returns the (abstract) type of the Shape.
void setShapeType(const std::string &type)
Sets a new type.
void setShapeRelativePath(bool relativePath)
Sets a new relativePath value.
virtual void setShapeNaviDegree(const double angle)
Sets a new angle in navigational degrees.
void setShapeImgFile(const std::string &imgFile)
Sets a new imgFile.
void setShapeColor(const RGBColor &col)
Sets a new color.
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
bool showShapes() const
check if shapes has to be drawn
bool showShapes() const
check if shapes has to be drawn
NetworkEditMode networkEditMode
the current Network edit mode
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
GNENetworkElement * getEditedNetworkElement() const
pointer to edited network element
static void drawLockIcon(const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, GUIGlObjectType type, const Position position, const double exaggeration, const double size=0.5, const double offsetx=0, const double offsety=0)
draw lock icon
bool editingElevation() const
check if we're editing elevation
RGBColor selectionColor
basic selection color
static const double segmentWidthSmall
width of small dotted contour segments
static const double segmentWidth
width of dotted contour segments
static const double polygonGeometryPointRadius
moving geometry point radius
static const double polygonContourWidth
polygon contour width
static const double polylineWidth
poly line width
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
bool show(const GUIGlObject *o) const
whether to show the text