70 const RGBColor& color,
double layer,
double angle,
const std::string& imgFile,
bool movementBlocked,
bool shapeBlocked) :
71 GUIPolygon(id, type, color, shape, geo, fill, layer, angle, imgFile),
73 myNetElementShapeEdited(NULL),
74 myClosedShape(shape.front() == shape.back()),
75 mySimplifiedShape(false),
76 myCurrentMovingVertexIndex(-1) {
83 for (
int i = 0; i < (int)
myGeoShape.size(); i++) {
97 if (index < (
int)
myShape.size()) {
147 if (shapeToCommit.size() !=
myShape.size()) {
151 if (shapeToCommit.size() > 1 && shapeToCommit.front().distanceTo2D(shapeToCommit.back()) < (2 *
myHintSize)) {
152 shapeToCommit.pop_back();
153 shapeToCommit.push_back(shapeToCommit.front());
215 simplifyShape->disable();
232 removeGeometryPoint->disable();
236 setFirstPoint->disable();
264 bool mouseOverVertex =
false;
270 RGBColor invertedColor, darkerColor;
293 if (modeMove && (i.distanceTo(mousePosition) <
myHintSize)) {
294 mouseOverVertex =
true;
302 if (i == myShape.front()) {
308 }
else if ((i == myShape.back()) && (
myClosedShape ==
false)) {
320 glTranslated(PostionOverShapeLine.
x(), PostionOverShapeLine.
y(),
GLO_POLYGON + 0.04);
337 return myShape.indexOfClosest(i);
341 if (createIfNoExist && (myShape.distance2D(pos) <
myHintSize)) {
342 return myShape.insertAtClosest(pos);
356 if (
myClosedShape && (index == 0 || index == (
int)modifiedShape.size() - 1)) {
357 modifiedShape.erase(modifiedShape.begin());
358 modifiedShape.erase(modifiedShape.end() - 1);
359 myShape.push_back(modifiedShape.front());
361 modifiedShape.erase(modifiedShape.begin() + index);
453 if (oldIndex >= (
int)
myShape.size()) {
455 }
else if (oldIndex == 0) {
456 WRITE_WARNING(
"Selected point must be different of the first point")
460 for (
int i = oldIndex; i < (int)
myShape.size(); i++) {
461 newShape.push_back(
myShape[i]);
464 for (
int i = 1; i < oldIndex; i++) {
465 newShape.push_back(
myShape[i]);
467 newShape.push_back(newShape.front());
469 for (
int i = 0; i < oldIndex; i++) {
470 newShape.push_back(
myShape[i]);
502 simplifiedShape.push_back(simplifiedShape[0]);
596 return (shape.size() > 0);
599 return canParse<RGBColor>(value);
601 return canParse<bool>(value);
603 return canParse<double>(value);
616 return canParse<double>(value);
618 return canParse<bool>(value);
620 return canParse<bool>(value);
622 return canParse<bool>(value);
624 if (canParse<bool>(value)) {
651 std::string oldID =
myID;
662 for (
int i = 0; i < (int)
myGeoShape.size(); i++) {
681 for (
int i = 0; i < (int)
myShape.size(); i++) {
695 myColor = parse<RGBColor>(value);
698 myFill = parse<bool>(value);
701 myLayer = parse<double>(value);
713 myGEO = parse<bool>(value);
PositionVector myShape
The positions of the polygon.
double ymin() const
Returns minimum y-coordinate.
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)
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 movementBlocked, bool shapeBlocked)
Constructor.
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.
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) ...
void refreshElement(GUIGlObject *o)
refreshes boundary information for o and update
block shape of a graphic element (Used mainly in GNEShapes)
const std::string & getParentName() const
Returns the name of the parent object.
int indexOfClosest(const Position &p) const
index of the closest position to p
static const RGBColor selectedLaneColor
color of selected lane
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
Stores the information about how to visualize structures.
bool isPolygonClosed() const
check if polygon is closed
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 updateGeometry()
update pre-computed geometry information
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.
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
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
A NBNetBuilder extended by visualisation and editing capabilities.
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.
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 bool isValidFilename(const std::string &value)
true if value is a valid file value
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
GNENet * myNet
the net to inform about updates
A class that stores a 2D geometrical boundary.
void closePolygon(bool allowUndo=true)
close polygon
#define WRITE_WARNING(msg)
std::string myType
The type of the Shape.
GUIVisualizationSizeSettings polySize
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
static bool isValidID(const std::string &value)
true if value is a valid sumo ID
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 myBlockShape
flag for block shape
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
simplify polygon geometry
double getNaviDegree() const
Returns the angle of the Shape in navigational degrees.
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 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.
static const double myHintSize
hint size of vertex
Position getPolygonCenter() const
Returns the arithmetic of all corner points.
friend class GNEChange_Attribute
declare friend class
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.
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
This functions has to be implemented in all GNEAttributeCarriers.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
EditMode getCurrentEditMode() const
get the current edit mode
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 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
virtual void updateGeometry()=0
update pre-computed geometry information
Position getPositionInView() const
Returns position of additional in view.
GUIGlID getGlID() const
Returns the numerical id of the object.
void setNaviDegree(const double angle)
Sets a new angle in navigational degrees.
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
std::string myImgFile
The angle of the Shape.
GNENetElement * getShapeEditedElement() const
retrieve the junction of which the shape is being edited
RGBColor myColor
The color of the Shape.
void setImgFile(const std::string &imgFile)
Sets a new imgFile.
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...
double myLayer
The layer of the Shape.
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.
Set a vertex of polygon as first verte.
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
void add(double xoff, double yoff, double zoff)
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.
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
void closePolygon()
ensures that the last position equals the first
GUISelectedStorage gSelected
A global holder of selected objects.
A window containing a gl-object's parameter.
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point
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 occured errors.
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 RGBColor getColor()
gets the gl-color
SumoXMLTag getTag() const
get XML Tag assigned to this object