 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
47 const RGBColor& color,
double layer,
double angle,
const std::string& imgFile,
bool relativePath,
bool movementBlocked,
bool shapeBlocked) :
48 GUIPolygon(id, type, color, shape, geo, fill, lineWidth, layer, angle, imgFile, relativePath),
49 GNEShape(net,
SUMO_TAG_POLY, movementBlocked, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}),
50 myNetElementShapeEdited(
nullptr),
51 myBlockShape(shapeBlocked),
52 myClosedShape(shape.front() == shape.back()),
53 mySimplifiedShape(
false),
54 myCurrentMovingVertexIndex(-1) {
61 for (
int i = 0; i < (int) myGeoShape.size(); i++) {
106 if (index < (
int)
myShape.size()) {
168 if (shapeToCommit.size() > 1 && shapeToCommit.front().distanceTo2D(shapeToCommit.back()) < (2 *
myHintSize)) {
169 shapeToCommit.pop_back();
170 shapeToCommit.push_back(shapeToCommit.front());
247 new FXMenuCommand(ret,
"Open shape\t\tOpen polygon's shape",
nullptr, &parent,
MID_GNE_POLYGON_OPEN);
249 new FXMenuCommand(ret,
"Close shape\t\tClose polygon's shape",
nullptr, &parent,
MID_GNE_POLYGON_CLOSE);
259 removeGeometryPoint->disable();
263 setFirstPoint->disable();
285 const double vertexWidthSquared = (vertexWidth * vertexWidth);
286 const double contourWidth = (
myHintSize / 4.0) * polyExaggeration;
298 glTranslated(mousePosition.
x(), mousePosition.
y(),
GLO_POLYGON + 0.04);
308 if (s.
scale * vertexWidth > 1.) {
310 bool mouseOverVertex =
false;
314 RGBColor invertedColor, darkerColor;
329 if (positionOverLane.
distanceSquaredTo2D(mousePosition) <= (contourWidth * contourWidth)) {
333 glTranslated(positionOverLane.
x(), positionOverLane.
y(), 0);
345 for (
const auto vertex :
myShape) {
348 glTranslated(vertex.x(), vertex.y(),
GLO_POLYGON + 0.02);
351 mouseOverVertex =
true;
363 glTranslated(vertex.x(), vertex.y(),
getType() + 1);
372 glTranslated(vertex.x(), vertex.y(),
GLO_POLYGON + 0.03);
379 glTranslated(vertex.x(), vertex.y(),
GLO_POLYGON + 0.03);
422 if (createIfNoExist) {
437 if (
myClosedShape && (index == 0 || index == (
int)modifiedShape.size() - 1) && (
myShape.size() > 2)) {
438 modifiedShape.erase(modifiedShape.begin());
439 modifiedShape.erase(modifiedShape.end() - 1);
440 modifiedShape.push_back(modifiedShape.front());
442 modifiedShape.erase(modifiedShape.begin() + index);
542 if (oldIndex >= (
int)
myShape.size()) {
544 }
else if (oldIndex == 0) {
545 WRITE_WARNING(
"Selected point must be different of the first point")
549 for (
int i = oldIndex; i < (int)
myShape.size(); i++) {
550 newShape.push_back(
myShape[i]);
553 for (
int i = 1; i < oldIndex; i++) {
554 newShape.push_back(
myShape[i]);
556 newShape.push_back(newShape.front());
558 for (
int i = 0; i < oldIndex; i++) {
559 newShape.push_back(
myShape[i]);
592 simplifiedShape.push_back(simplifiedShape[0]);
595 simplifiedShape.push_back(
myShape.front());
596 simplifiedShape.push_back(
myShape.back());
708 return canParse<PositionVector>(value);
711 return canParse<RGBColor>(value);
713 return canParse<bool>(value);
715 return canParse<double>(value) && (parse<double>(value) >= 0);
717 if (value ==
"default") {
720 return canParse<double>(value);
732 return canParse<bool>(value);
734 return canParse<double>(value);
736 return canParse<bool>(value);
738 return canParse<bool>(value);
740 return canParse<bool>(value);
742 if (canParse<bool>(value)) {
757 return canParse<bool>(value);
787 std::string oldID =
myID;
795 myShape = parse<PositionVector>(value);
798 for (
int i = 0; i < (int)
myGeoShape.size(); i++) {
816 for (
int i = 0; i < (int)
myShape.size(); i++) {
833 myFill = parse<bool>(value);
839 if (value ==
"default") {
860 myGEO = parse<bool>(value);
881 if (parse<bool>(value)) {
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Boundary myMovingGeometryBoundary
boundary used during moving of elements
void setShapeType(const std::string &type)
Sets a new type.
GUIVisualizationSizeSettings polySize
bool drawForPositionSelection
whether drawing is performed for the purpose of selecting objects with a single click
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
static RGBColor getColor()
gets the gl-color
A window containing a gl-object's parameter.
std::string getParametersStr() const
Returns the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN".
Position getPolygonCenter() const
Returns the arithmetic of all corner points.
const std::string getID() const
function to support debugging
std::string getParentName() const
Returns the name of the parent object.
#define WRITE_WARNING(msg)
begin/end of the description of a polygon
void writeXML(OutputDevice &out, bool geo=false)
void openPolygon(bool allowUndo=true)
open polygon
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation.
double ymin() const
Returns minimum y-coordinate.
Static storage of an output device and its base (abstract) implementation.
double getShapeNaviDegree() const
Returns the angle of the Shape in navigational degrees.
void selectAttributeCarrier(bool changeFlag=true)
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
bool drawForRectangleSelection
whether drawing is performed for the purpose of selecting objects using a rectangle
bool drawBoundaries
enable or disable draw boundaries
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.
Set a vertex of polygon as first verte.
void removeGLObjectFromGrid(GUIGlObject *o)
add GL Object into net
A NBNetBuilder extended by visualisation and editing capabilities.
virtual void updateGeometry()=0
update pre-computed geometry information
void updateGeometry()
update pre-computed geometry information
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
static const double DEFAULT_LAYER
bool mySimplifiedShape
flag to indicate if polygon is simplified
double xmax() const
Returns maximum x-coordinate.
bool isPolygonClosed() const
check if polygon is closed
void commitShapeChange(const PositionVector &oldShape, GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of changeShapeGeometry(....
void setShapeImgFile(const std::string &imgFile)
Sets a new imgFile.
PositionVector myGeoShape
Latitude of Polygon.
const std::string & getShapeImgFile() const
Returns the imgFile of the Shape.
void changeShapeID(GNEShape *s, const std::string &OldID)
change Shape ID
GNEPoly(GNENet *net, const std::string &id, const std::string &type, const PositionVector &shape, bool geo, bool fill, double lineWidth, const RGBColor &color, double layer, double angle, const std::string &imgFile, bool relativePath, bool movementBlocked, bool shapeBlocked)
Constructor.
PositionVector myShape
The positions of the polygon.
void setColor(const GUIVisualizationSettings &s, bool disableSelectionColor) const
set color
double myLineWidth
The line width for drawing an unfilled polygon.
bool isClosed() const
check if PositionVector is closed
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
const RGBColor & getShapeColor() const
Returns the color of the Shape.
SumoXMLTag
Numbers representing SUMO-XML - element names.
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.
static const double geometryPointsText
details for Geometry Points Texts
void setShapeRelativePath(bool relativePath)
Sets a new relativePath value.
static void drawBoundary(const Boundary &b)
Draw a boundary (used for debugging)
GNEPoly * retrievePolygon(const std::string &id, bool failHard=true) const
get Polygon by id
friend class GNEChange_Attribute
declare friend class
GNENetElement * myNetElementShapeEdited
junction of which the shape is being edited (optional)
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
void add(double xoff, double yoff, double zoff)
void drawInnerPolygon(const GUIVisualizationSettings &s, bool disableSelectionColor) const
draw inner Polygon (before pushName() )
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
bool isPolygonBlocked() const
return true if polygon is blocked
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)
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
void closePolygon(bool allowUndo=true)
close polygon
void reset()
Resets the boundary.
const GNEViewNetHelper::EditShapes & getEditShapes() const
get Edit Shape modul
int size() const
Returns the number of stored items within the container.
bool myGEO
specify if shape is handled as GEO coordinate (Main used in netedit)
GUIVisualizationDetailSettings detailSettings
detail settings
double xmin() const
Returns minimum x-coordinate.
double getShapeLayer() const
Returns the layer of the Shape.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
GUIVisualizationSettings * getVisualisationSettings() const
get visualitation settings
static const double myHintSize
hint size of vertex
bool around(const Position &p, double offset=0) const
Returns the information whether the position vector describes a polygon lying around the given point.
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
int myCurrentMovingVertexIndex
index of vertex that is been moved (-1 means that none vertex is been moved)
void closePolygon()
ensures that the last position equals the first
GNENet * myNet
the net to inform about updates
GUIGlID getGlID() const
Returns the numerical id of the object.
void startGeometryMoving()
const GNEAttributeCarrier * getDottedAC() const
get AttributeCarrier under cursor
A class that stores a 2D geometrical boundary.
static void drawShapeDottedContourAroundClosedShape(const GUIVisualizationSettings &s, const int type, const PositionVector &shape)
draw a dotted contour around the given closed shape with certain width
parameters "key1=value1|key2=value2|...|keyN=valueN"
Close shape of a polygon (Used by GNEPolys)
static const RGBColor BLUE
double scale
information about a lane's width (temporary, used for a single view)
Network mode (Edges, junctions, etc..)
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
Supermode currentSupermode
the current supermode
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
A point in 2D or 3D with translation and scaling methods.
void writeShape(OutputDevice &device)
writte shape element into a xml file
double x() const
Returns the x-position.
block shape of a graphic element (Used mainly in GNEShapes)
GNEUndoList * getUndoList() const
get the undoList object
const GNEViewNetHelper::DemandViewOptions & getDemandViewOptions() const
get demand view options
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
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
bool editingElevation() const
check if we're editing elevation
const std::string & getShapeType() const
Returns the (abstract) type of the Shape.
std::string getAttribute(SumoXMLAttr key) const
int indexOfClosest(const Position &p) const
index of the closest position to p
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Position getPositionInformation() const
Returns the cursor's x/y position within the network.
bool getShapeRelativePath() const
Returns the relativePath of the Shape.
bool showShapes() const
check if shapes has to be hide
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
const PositionVector & getShape() const
Returns whether the shape of the polygon.
int insertAtClosest(const Position &p, bool interpolateZ)
inserts p between the two closest positions
bool myBlockMovement
flag to block movement
GNEViewNet * getViewNet() const
get view net
double distanceSquaredTo2D(const Position &p2) const
returns the square of the distance to another position (Only using x and y positions)
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
GUIVisualizationColorSettings colorSettings
color settings
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
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)
RGBColor selectionColor
basic selection color
int getCircleResolution() const
function to calculate circle resolution for all circles drawn in drawGL(...) functions
int moveVertexShape(const int index, const Position &oldPos, const Position &offset)
change position of a vertex of shape without commiting change
void setParametersStr(const std::string ¶msString)
set the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN"
const GUIGlObject * getGUIGlObject() const
get GUIGlObject associated to this GNEShape
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
void addGLObjectIntoGrid(GUIGlObject *o)
add GL Object into net
double y() const
Returns the y-position.
static bool isValidTypeID(const std::string &value)
whether the given string is a valid id for an edge or vehicle type
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
static bool areParametersValid(const std::string &value, bool report=false)
check if given string can be parsed to a parameters map "key1=value1|key2=value2|....
Demanding mode (Routes, Vehicles etc..)
void setShapeLayer(const double layer)
Sets a new layer.
block movement of a graphic element
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
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
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
Position getPositionInView() const
Returns position of additional in view.
virtual void setShapeNaviDegree(const double angle)
Sets a new angle in navigational degrees.
GUIGlID getGlID() const
Returns the numerical id of the object.
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
static void clearTextures()
clears loaded textures
RGBColor invertedColor() const
obtain inverted of current RGBColor
bool myFill
Information whether the polygon has to be filled.
GNENetElement * getShapeEditedElement() const
retrieve the junction of which the shape is being edited
bool isInitialised() const
check if Boundary is Initialised
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
bool drawDetail(const double detail, const double exaggeration) const
check if details can be drawn for the given GUIVisualizationDetailSettings and current scale and exxa...
simplify polygon geometry
const std::string & getTagStr() const
get tag assigned to this object in string format
bool getFill() const
Returns whether the polygon is filled.
const Polygons & getPolygons() const
Returns all polygons.
Stores the information about how to visualize structures.
bool myBlockShape
flag for block shape
std::string myID
The name of the object.
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.
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
bool editingNetElementShapes
flag to edit net element shapes
bool checkDraw(const GUIVisualizationSettings &s) const
check if Polygon can be drawn
static int getTextureID(const std::string &filename, const bool mirrorX=false)
return texture id for the given filename (initialize on first use)
int getVertexIndex(Position pos, bool createIfNoExist, bool snapToGrid)
return index of a vertex of shape, or of a new vertex if position is over an shape's edge
edge: the shape in xml-definition
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
NetworkEditMode networkEditMode
the current Network edit mode
void moveEntireShape(const PositionVector &oldShape, const Position &offset)
move entire shape without commiting change
bool myClosedShape
flag to indicate if polygon is open or closed
mode for moving network elements
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
void setShapeColor(const RGBColor &col)
Sets a new color.
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
void endGeometryMoving()
begin movement (used when user click over edge to start a movement, to avoid problems with problems w...
void removeDoublePoints(double minDist=POSITION_EPS, bool assertLength=false)
Removes positions if too near.
bool isAttributeEnabled(SumoXMLAttr key) const
double ymax() const
Returns maximum y-coordinate.
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point