72 const RGBColor& color,
double layer,
double angle,
const std::string& imgFile,
bool movementBlocked,
bool shapeBlocked) :
73 GUIPolygon(id, type, color, shape, fill, layer, angle, imgFile),
75 myShapeEditedJunction(NULL),
76 myClosedShape(shape.front() == shape.back()),
77 mySimplifiedShape(false),
78 myCurrentMovingVertexIndex(-1) {
94 if (index < (
int)
myShape.size()) {
124 i->setx(i->x() - offset.
x());
125 i->sety(i->y() - offset.
y());
142 if (shapeToCommit.size() !=
myShape.size()) {
146 if (shapeToCommit.front().distanceTo2D(shapeToCommit.back()) < (2 *
myHintSize)) {
147 shapeToCommit.pop_back();
148 shapeToCommit.push_back(shapeToCommit.front());
195 simplifyShape->disable();
212 removeGeometryPoint->disable();
216 setFirstPoint->disable();
220 (
dynamic_cast<GNEViewNet&
>(parent)).markPopupPosition();
246 bool mouseOverVertex =
false;
252 RGBColor invertedColor, darkerColor;
275 if (modeMove && (i.distanceTo(mousePosition) <
myHintSize)) {
276 mouseOverVertex =
true;
284 if (i == myShape.front()) {
290 }
else if ((i == myShape.back()) && (
myClosedShape ==
false)) {
302 glTranslated(PostionOverShapeLine.
x(), PostionOverShapeLine.
y(),
GLO_POLYGON + 0.04);
318 return myShape.indexOfClosest(i);
322 if (createIfNoExist && (myShape.distance2D(pos) <
myHintSize)) {
323 return myShape.insertAtClosest(pos);
397 if (oldIndex >= (
int)
myShape.size()) {
399 }
else if (oldIndex == 0) {
400 WRITE_WARNING(
"Selected point must be different of the first point")
404 for (
int i = oldIndex; i < (int)
myShape.size(); i++) {
405 newShape.push_back(
myShape[i]);
408 for (
int i = 1; i < oldIndex; i++) {
409 newShape.push_back(
myShape[i]);
411 newShape.push_back(newShape.front());
413 for (
int i = 0; i < oldIndex; i++) {
414 newShape.push_back(
myShape[i]);
446 simplifiedShape.push_back(simplifiedShape[0]);
475 if (
myClosedShape && (index == 0 || index == (
int)modifiedShape.size() - 1)) {
476 modifiedShape.erase(modifiedShape.begin());
477 modifiedShape.erase(modifiedShape.end() - 1);
478 myShape.push_back(modifiedShape.front());
480 modifiedShape.erase(modifiedShape.begin() + index);
568 return (shape.size() > 0);
571 return canParse<RGBColor>(value);
573 return canParse<bool>(value);
575 return canParse<double>(value);
588 return canParse<double>(value);
590 return canParse<bool>(value);
592 return canParse<bool>(value);
594 if (canParse<bool>(value)) {
621 std::string oldID =
myID;
639 myColor = parse<RGBColor>(value);
642 myFill = parse<bool>(value);
645 myLayer = parse<double>(value);
EditMode getCurrentEditMode() const
get the current edit mode
PositionVector myShape
The positions of the polygon.
double xmax() const
Returns maximum x-coordinate.
void openPolygon(bool allowUndo=true)
open polygon
double scale
information about a lane's width (temporary, used for a single view)
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.
GNEPoly(GNENet *net, const std::string &id, const std::string &type, const PositionVector &shape, bool fill, const RGBColor &color, double layer, double angle, const std::string &imgFile, bool movementBlocked, bool shapeBlocked)
Constructor.
block shape of a graphic element (Used mainly in GNEShapes)
static const RGBColor selectedLaneColor
color of selected lane
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
virtual void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Set a vertex of polygon as first verte.
double ymax() const
Returns maximum y-coordinate.
double x() const
Returns the x-position.
Stores the information about how to visualize structures.
void commitShapeChange(const PositionVector &oldShape, GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of changeShapeGeometry(...)
simplify polygon geometry
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
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.
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) ...
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.
GNEJunction * myShapeEditedJunction
junction of which the shape is being edited (optional)
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
GUIGlID getGlID() const
Returns the numerical id of the object.
A class that stores a 2D geometrical boundary.
void closePolygon(bool allowUndo=true)
close polygon
#define WRITE_WARNING(msg)
GNEUndoList * getUndoList() const
get the undoList object
std::string myType
The type of the Shape.
GUIVisualizationSizeSettings polySize
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
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
void refreshPolygon(GNEPoly *p)
refresh polygon in view net
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
void removeDoublePoints(double minDist=POSITION_EPS, bool assertLength=false)
Removes positions if too near.
double getExaggeration(const GUIVisualizationSettings &s, double factor=20) const
return the drawing size including exaggeration and constantSize values
bool myBlockShape
flag for block shape
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
Position getPositionInView() const
Returns position of additional in view.
void writeShape(OutputDevice &device)
writte shape element into a xml file
int moveVertexShape(int index, const Position &newPos)
change position of a vertex of shape without commiting change
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.
RGBColor invertedColor() const
obtain inverted of current RGBColor
int indexOfClosest(const Position &p) const
index of the closest position to p
static const double myHintSize
hint size of vertex
friend class GNEChange_Attribute
declare friend class
double y() const
Returns the y-position.
void changePolygonID(GNEPoly *poly, const std::string &OldID)
change Polygon ID
int myCurrentMovingVertexIndex
index of vertex that is been moved (-1 means that none vertex is been moved)
GNEPoly * retrievePolygon(const std::string &id, bool failHard=true) const
get Polygon by id
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.
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
edge: the shape in xml-definition
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes ...
GNEJunction * getShapeEditedJunction() const
retrieve the junction of which the shape is being edited
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
void deleteGeometryNear(const Position &pos, bool allowUndo=true)
delete the geometry point closest to the given pos
bool isPolygonClosed() const
check if polygon is closed
std::string myID
The name of the object.
void simplifyShape(bool allowUndo=true)
replace the current shape with a rectangle
const std::string & getParentName() const
Returns the name of the parent object.
double xmin() const
Returns minimum x-coordinate.
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.
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.
double ymin() const
Returns minimum y-coordinate.
double myLayer
The layer of the Shape.
void writeXML(OutputDevice &out, bool geo=false)
SumoXMLTag getTag() const
get XML Tag assigned to this object
Static storage of an output device and its base (abstract) implementation.
static const RGBColor selectionColor
void setShapeEditedJunction(GNEJunction *junction)
retrieve the junction of which the shape is being edited
Position getPolygonCenter() const
Returns the arithmetic of all corner points.
bool myClosedShape
flag to indicate if polygon is open or closed
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)
draw Text with given parameters
Position getPositionInformation() const
Returns the cursor's x/y position within the network.
void closePolygon()
ensures that the last position equals the first
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
GUISelectedStorage gSelected
A global holder of selected objects.
double getNaviDegree() const
Returns the angle of the Shape in navigational degrees.
A window containing a gl-object's parameter.
std::string getAttribute(SumoXMLAttr key) const
This functions has to be implemented in allGNEAttributeCarrier.
GNEViewNet * getViewNet() const
get view net
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
void moveEntireShape(const PositionVector &oldShape, const Position &offset)
move entire shape without commiting change
static RGBColor getColor()
gets the gl-color