68 const RGBColor& color,
double layer,
double angle,
const std::string& imgFile,
bool relativePath,
bool movementBlocked,
bool shapeBlocked) :
69 GUIPolygon(id, type, color, shape, geo, fill, layer, angle, imgFile, relativePath),
71 myNetElementShapeEdited(nullptr),
72 myClosedShape(shape.front() == shape.back()),
73 mySimplifiedShape(false),
74 myCurrentMovingVertexIndex(-1) {
81 for (
int i = 0; i < (int)
myGeoShape.size(); i++) {
107 if (index < (
int)
myShape.size()) {
175 if (shapeToCommit.size() !=
myShape.size()) {
179 if (shapeToCommit.size() > 1 && shapeToCommit.front().distanceTo2D(shapeToCommit.back()) < (2 *
myHintSize)) {
180 shapeToCommit.pop_back();
181 shapeToCommit.push_back(shapeToCommit.front());
242 simplifyShape->disable();
259 removeGeometryPoint->disable();
263 setFirstPoint->disable();
297 bool mouseOverVertex =
false;
302 RGBColor invertedColor, darkerColor;
324 if (modeMove && (i.distanceTo(mousePosition) <
myHintSize)) {
325 mouseOverVertex =
true;
352 Position hintPos = myShape.size() > 1 ? myShape.positionAtOffset2D(myShape.nearest_offset_to_point2D(mousePosition)) : myShape[0];
374 return myShape.indexOfClosest(i);
378 if (createIfNoExist && (myShape.distance2D(pos) <
myHintSize)) {
379 return myShape.insertAtClosest(pos);
393 if (
myClosedShape && (index == 0 || index == (
int)modifiedShape.size() - 1)) {
394 modifiedShape.erase(modifiedShape.begin());
395 modifiedShape.erase(modifiedShape.end() - 1);
396 myShape.push_back(modifiedShape.front());
398 modifiedShape.erase(modifiedShape.begin() + index);
492 if (oldIndex >= (
int)
myShape.size()) {
494 }
else if (oldIndex == 0) {
495 WRITE_WARNING(
"Selected point must be different of the first point")
499 for (
int i = oldIndex; i < (int)
myShape.size(); i++) {
500 newShape.push_back(
myShape[i]);
503 for (
int i = 1; i < oldIndex; i++) {
504 newShape.push_back(
myShape[i]);
506 newShape.push_back(newShape.front());
508 for (
int i = 0; i < oldIndex; i++) {
509 newShape.push_back(
myShape[i]);
542 simplifiedShape.push_back(simplifiedShape[0]);
545 simplifiedShape.push_back(
myShape.front());
546 simplifiedShape.push_back(
myShape.back());
654 return (shape.size() > 0);
657 return canParse<RGBColor>(value);
659 return canParse<bool>(value);
661 if (value ==
"default") {
664 return canParse<double>(value);
676 return canParse<bool>(value);
678 return canParse<double>(value);
680 return canParse<bool>(value);
682 return canParse<bool>(value);
684 return canParse<bool>(value);
686 if (canParse<bool>(value)) {
701 return canParse<bool>(value);
761 result += i.first +
"=" + i.second +
"|";
764 if (!result.empty()) {
771 std::vector<std::pair<std::string, std::string> >
773 std::vector<std::pair<std::string, std::string> > result;
776 result.push_back(std::make_pair(i.first, i.second));
787 std::vector<std::string> parsedValues;
790 parsedValues.push_back(stValues.
next());
793 for (
auto i : parsedValues) {
794 std::vector<std::string> parsedParameters;
797 parsedParameters.push_back(stParam.
next());
801 setParameter(parsedParameters.front(), parsedParameters.back());
816 std::string oldID =
myID;
828 for (
int i = 0; i < (int)
myGeoShape.size(); i++) {
847 for (
int i = 0; i < (int)
myShape.size(); i++) {
864 myFill = parse<bool>(value);
867 if (value ==
"default") {
888 myGEO = parse<bool>(value);
909 if (parse<bool>(value)) {
bool around(const Position &p, double offset=0) const
Returns the information whether the position vector describes a polygon lying around the given point...
PositionVector myShape
The positions of the polygon.
void endGeometryMoving()
begin movement (used when user click over edge to start a movement, to avoid problems with problems w...
double ymin() const
Returns minimum y-coordinate.
const GNEAttributeCarrier * getACUnderCursor() const
get AttributeCarrier under cursor
void openPolygon(bool allowUndo=true)
open polygon
double xmax() const
Returns maximum x-coordinate.
double scale
information about a lane's width (temporary, used for a single view)
bool myGEO
specify if shape is handled as GEO coordinate (Main used in netedit)
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
bool myFill
Information whether the polygon has to be filled.
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.
const std::string & getShapeImgFile() const
Returns the imgFile of the Shape.
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
double distance2D(const Position &p, bool perpendicular=false) const
closest 2D-distance to point p (or -1 if perpendicular is true and the point is beyond this vector) ...
block shape of a graphic element (Used mainly in GNEShapes)
std::string getParentName() const
Returns the name of the parent object.
int indexOfClosest(const Position &p) const
index of the closest position to p
void setShapeColor(const RGBColor &col)
Sets a new color.
void setShapeRelativePath(bool relativePath)
Sets a new relativePath value.
GNEPoly(GNENet *net, const std::string &id, const std::string &type, const PositionVector &shape, bool geo, bool fill, const RGBColor &color, double layer, double angle, const std::string &imgFile, bool relativePath, bool movementBlocked, bool shapeBlocked)
Constructor.
static const RGBColor selectedLaneColor
color of selected lane
virtual void updateGeometry(bool updateGrid)=0
update pre-computed geometry information
bool addGenericParameter(const std::string &key, const std::string &value)
add generic parameter
Stores the information about how to visualize structures.
bool isPolygonClosed() const
check if polygon is closed
void setShapeType(const std::string &type)
Sets a new type.
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
double y() const
Returns the y-position.
void commitShapeChange(const PositionVector &oldShape, GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of changeShapeGeometry(...)
void unsetParameter(const std::string &key)
Removes a parameter.
double x() const
Returns the x-position.
Close shape of a polygon (Used by GNEPolys)
int getVertexIndex(const Position &pos, bool createIfNoExist=true)
return index of a vertex of shape, or of a new vertex if position is over an shape's edge ...
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
bool removeGenericParameter(const std::string &key)
remove generic parameter
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)
GNEPoly * retrievePolygon(const std::string &id, bool failHard=true) const
get Polygon by id
A NBNetBuilder extended by visualisation and editing capabilities.
const PositionVector & getShape() const
Returns whether the shape of the polygon.
bool mySimplifiedShape
flag to indicate if polygon is simplified
void p_begin(const std::string &description)
Begin undo command sub-group. This begins a new group of commands that are treated as a single comman...
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
PositionVector myGeoShape
Latitude of Polygon.
static const double myHintSizeSquared
squaredhint size of vertex
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
RGBColor invertedColor() const
obtain inverted of current RGBColor
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
static bool isValidGenericParameterKey(const std::string &value)
whether the given string is a valid key for a generic parameter
GNENet * myNet
the net to inform about updates
A class that stores a 2D geometrical boundary.
void selectAttributeCarrier(bool changeFlag=true)
void closePolygon(bool allowUndo=true)
close polygon
#define WRITE_WARNING(msg)
const std::string & getShapeType() const
Returns the (abstract) type of the Shape.
GUIVisualizationSizeSettings polySize
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
void setShapeImgFile(const std::string &imgFile)
Sets a new imgFile.
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
static void clearTextures()
clears loaded textures
GNENetElement * myNetElementShapeEdited
junction of which the shape is being edited (optional)
GNEUndoList * getUndoList() const
get the undoList object
void removeDoublePoints(double minDist=POSITION_EPS, bool assertLength=false)
Removes positions if too near.
bool getShapeRelativePath() const
Returns the relativePath of the Shape.
void startGeometryMoving()
bool myBlockShape
flag for block shape
static bool isValidGenericParameterValue(const std::string &value)
whether the given string is a valid value for a generic parameter
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
bool knowsParameter(const std::string &key) const
Returns whether the parameter is known.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
bool myBlockMovement
flag to block movement
void writeShape(OutputDevice &device)
writte shape element into a xml file
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
void mouseOverObject(const GUIVisualizationSettings &s) const
method for check if mouse is over objects
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise, the sub-group will be added as a new command into parent group. A matching begin() must have been called previously.
A point in 2D or 3D with translation and scaling methods.
bool updateGenericParameterValue(const std::string &key, const std::string &newValue)
update value generic parameter
static bool isGenericParametersValid(const std::string &value)
check if given string can be parsed to a map/list of generic parameters
void removeGLObjectFromGrid(GUIGlObject *o)
add GL Object into net
static const double myHintSize
hint size of vertex
double distanceSquaredTo(const Position &p2) const
returns the square of the distance to another position
Position getPolygonCenter() const
Returns the arithmetic of all corner points.
friend class GNEChange_Attribute
declare friend class
const RGBColor & getShapeColor() const
Returns the color of the Shape.
int myCurrentMovingVertexIndex
index of vertex that is been moved (-1 means that none vertex is been moved)
static int getTextureID(const std::string &filename, const bool mirrorX=false)
return texture id for the given filename (initialize on first use)
block movement of a graphic element
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
double xmin() const
Returns minimum x-coordinate.
void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
bool updateGenericParameter(const std::string &oldKey, const std::string &newKey)
update generic parameter
edge: the shape in xml-definition
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
void deleteGeometryPoint(const Position &pos, bool allowUndo=true)
delete the geometry point closest to the given pos
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes ...
void changeShapeID(GNEShape *s, const std::string &OldID)
change Shape ID
std::string getAttribute(SumoXMLAttr key) const
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
double getShapeLayer() const
Returns the layer of the Shape.
EditMode getCurrentEditMode() const
get the current edit mode
static bool isValidNetID(const std::string &value)
whether the given string is a valid id for a network element
std::string myID
The name of the object.
int moveVertexShape(const int index, const Position &oldPos, const Position &offset)
change position of a vertex of shape without commiting change
virtual void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
void setACUnderCursor(const GNEAttributeCarrier *AC)
set attributeCarrier under cursor
Set a vertex of polygon as first verte.
void setShapeEditedElement(GNENetElement *element)
retrieve the netElement of which the shape is being edited
void simplifyShape(bool allowUndo=true)
replace the current shape with a rectangle
Position getPositionInView() const
Returns position of additional in view.
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
static void drawShapeDottedContour(const int type, const PositionVector &shape, const double width)
draw a dotted contour around the given Non closed shape with certain width
GUIGlID getGlID() const
Returns the numerical id of the object.
simplify polygon geometry
bool isClosed() const
check if PositionVector is closed
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
GNENetElement * getShapeEditedElement() const
retrieve the junction of which the shape is being edited
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
static int getCircleResolution(const GUIVisualizationSettings &settings)
function to calculate circle resolution for all circles drawn in drawGL(...) functions ...
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
std::vector< std::pair< std::string, std::string > > getGenericParameters() const
return generic parameters as vector of pairs format
const std::map< std::string, std::string > & getParametersMap() const
Returns the inner key/value map.
GUIGlID getGlID() const
Returns the numerical id of the object.
void writeXML(OutputDevice &out, bool geo=false)
double getExaggeration(const GUIVisualizationSettings &s, double factor=20) const
return the drawing size including exaggeration and constantSize values
Static storage of an output device and its base (abstract) implementation.
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation. ...
Position getPositionInformation() const
Returns the cursor's x/y position within the network.
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
static const RGBColor selectionColor
bool myClosedShape
flag to indicate if polygon is open or closed
std::string getGenericParametersStr() const
return generic parameters in string format
void add(double xoff, double yoff, double zoff)
bool drawForSelecting
whether drawing is performed for the purpose of selecting objects
double ymax() const
Returns maximum y-coordinate.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
void closePolygon()
ensures that the last position equals the first
void addGLObjectIntoGrid(GUIGlObject *o)
add GL Object into net
A window containing a gl-object's parameter.
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point
void setShapeLayer(const double layer)
Sets a new layer.
void updateGeometry(bool updateGrid)
update pre-computed geometry information
static PositionVector parseShapeReporting(const std::string &shpdef, const std::string &objecttype, const char *objectid, bool &ok, bool allowEmpty, bool report=true)
Builds a PositionVector from a string representation, reporting occurred errors.
double getShapeNaviDegree() const
Returns the angle of the Shape in navigational degrees.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
begin/end of the description of a polygon
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
GNEViewNet * getViewNet() const
get view net
void moveEntireShape(const PositionVector &oldShape, const Position &offset)
move entire shape without commiting change
static const double DEFAULT_LAYER
void setShapeNaviDegree(const double angle)
Sets a new angle in navigational degrees.
void clearParameter()
Clears the parameter map.
static RGBColor getColor()
gets the gl-color
SumoXMLTag getTag() const
get XML Tag assigned to this object