 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
29 #define CIRCLE_RESOLUTION (double)10 // inverse in degrees
30 #define MAXIMUM_DOTTEDGEOMETRYLENGTH 500.0
58 myShapeRotations(shapeRotations),
59 myShapeLengths(shapeLengths) {
70 calculateShapeRotationsAndLengths();
79 const double shapeLength = shape.
length();
81 if (posOverShape < 0) {
84 }
else if (posOverShape > shapeLength) {
103 const double shapeLength = myShape.length2D();
105 if (starPosOverShape < 0) {
109 if (starPosOverShape < 0) {
110 endPosOverShape = shapeLength;
117 if ((endPosOverShape > shapeLength)) {
118 endPosOverShape = shapeLength;
121 if (endPosOverShape <= starPosOverShape) {
125 myShape = myShape.getSubpart2D(starPosOverShape, endPosOverShape);
127 calculateShapeRotationsAndLengths();
139 if ((beginTrimPosition != -1) || (endTrimPosition != -1)) {
141 const double shapeLength = myShape.
length2D();
143 if (beginTrimPosition < 0) {
144 beginTrimPosition = 0;
147 if (endTrimPosition < 0) {
148 endTrimPosition = shapeLength;
155 if ((endTrimPosition > shapeLength)) {
156 endTrimPosition = shapeLength;
159 if (endTrimPosition <= beginTrimPosition) {
163 myShape = myShape.getSubpart2D(beginTrimPosition, endTrimPosition);
166 myShape.push_front_noDoublePos(extraFirstPosition);
169 myShape.push_back_noDoublePos(extraLastPosition);
173 calculateShapeRotationsAndLengths();
182 myShape.push_back(position);
183 myShapeRotations.push_back(rotation);
190 myShape.scaleRelative(scale);
192 for (
auto& shapeLength : myShapeLengths) {
193 shapeLength *= scale;
204 const std::vector<double>&
206 return myShapeRotations;
210 const std::vector<double>&
212 return myShapeLengths;
219 myShapeRotations.clear();
220 myShapeLengths.clear();
227 myShapeRotations.clear();
228 myShapeLengths.clear();
230 int numberOfSegments = (int)myShape.size() - 1;
232 if (numberOfSegments >= 0) {
234 myShapeRotations.reserve(numberOfSegments);
235 myShapeLengths.reserve(numberOfSegments);
237 for (
int i = 0; i < numberOfSegments; i++) {
249 mySettings(settings),
258 return mySettings.dottedContourSettings.firstInspectedColor;
261 return mySettings.dottedContourSettings.secondInspectedColor;
266 return mySettings.dottedContourSettings.firstFrontColor;
269 return mySettings.dottedContourSettings.secondFrontColor;
330 myWidth(s.dottedContourSettings.segmentWidth) {
332 if (closeShape && (shape.size() > 2)) {
335 if (shape.size() > 1) {
337 for (
int i = 1; i < (int)shape.size(); i++) {
347 segment.shape = segment.shape.resample(segmentLength,
true);
356 const DottedGeometry& topDottedGeometry,
const bool drawFirstExtrem,
357 const DottedGeometry& botDottedGeometry,
const bool drawLastExtrem) :
358 myWidth(s.dottedContourSettings.segmentWidth) {
363 if (drawFirstExtrem &&
371 if (drawLastExtrem &&
396 myDottedGeometrySegments.clear();
398 for (
int i = 1; i < (int)lane->
getLaneShape().size(); i++) {
402 for (
auto& segment : myDottedGeometrySegments) {
406 calculateShapeRotationsAndLengths();
415 myDottedGeometrySegments.clear();
417 if (closeShape && (shape.size() > 2)) {
420 if (shape.size() > 1) {
422 for (
int i = 1; i < (int)shape.size(); i++) {
423 myDottedGeometrySegments.push_back(
Segment({shape[i - 1], shape[i]}));
426 for (
auto& segment : myDottedGeometrySegments) {
430 calculateShapeRotationsAndLengths();
438 const double width = (customWidth > 0)? customWidth : myWidth;
440 for (
auto& segment : myDottedGeometrySegments) {
442 for (
int i = 0; i < ((int)segment.shape.size() - 1); i++) {
455 for (
auto& segment : myDottedGeometrySegments) {
456 segment.shape.move2side(value);
476 for (
auto& segment : myDottedGeometrySegments) {
477 segment.offset *= -1;
485 for (
auto& segment : myDottedGeometrySegments) {
487 int numberOfSegments = (int)segment.shape.size() - 1;
489 if (numberOfSegments >= 0) {
491 segment.rotations.reserve(numberOfSegments);
492 segment.lengths.reserve(numberOfSegments);
494 for (
int i = 0; i < numberOfSegments; i++) {
495 segment.rotations.push_back(
calculateRotation(segment.shape[i], segment.shape[i + 1]));
496 segment.lengths.push_back(
calculateLength(segment.shape[i], segment.shape[i + 1]));
507 myFromLane(fromLane) {
514 const int numPoints = 5;
515 const int maximumLanes = 10;
517 myConnectionsMap.clear();
519 for (
const auto& outgoingEdge : myFromLane->getParentEdge()->getToJunction()->getGNEOutgoingEdges()) {
520 for (
const auto& outgoingLane : outgoingEdge->getLanes()) {
522 const NBEdge* NBEdgeFrom = myFromLane->getParentEdge()->getNBEdge();
523 const NBEdge* NBEdgeTo = outgoingLane->getParentEdge()->getNBEdge();
533 (
double) numPoints * (
double) NBEdgeFrom->
getNumLanes(),
534 (
double) numPoints * (
double) NBEdgeTo->
getNumLanes());
537 shape = {myFromLane->getLaneShape().back(), outgoingLane->getLaneShape().front()};
540 myConnectionsMap[outgoingLane].updateGeometry(shape);
548 return (myConnectionsMap.count(toLane) > 0);
554 return myConnectionsMap.at(toLane);
559 myFromLane(nullptr) {
569 return ((
double)atan2((second.
x() - first.
x()), (first.
y() - second.
y())) * (
double) 180.0 / (
double)
M_PI);
583 if (startLane && endLane && (startLane == endLane) && (startPos != -1) && (endPos != -1)) {
584 if (startPos >= endPos) {
589 if ((startPos != -1) && startLane) {
598 if ((endPos != -1) && endLane) {
622 glTranslated(posOverLane.
x(), posOverLane.
y(), 0);
666 const RGBColor& geometryPointColor,
const RGBColor& textColor,
const double radius,
const double exaggeration) {
670 const double exaggeratedRadio = (radius * exaggeration);
672 const double exaggeratedRadioSquared = (exaggeratedRadio * exaggeratedRadio);
674 for (
const auto& vertex : shape) {
680 glTranslated(vertex.x(), vertex.y(), 0.2);
699 }
else if ((vertex == shape.front()) && drawDetail) {
706 }
else if ((vertex == shape.back()) && (shape.isClosed() ==
false) && drawDetail) {
722 const RGBColor& hintColor,
const double radius,
const double exaggeration) {
728 const double exaggeratedRadio = (radius * exaggeration);
730 const double distanceToShape = shape.
distance2D(mousePosition);
732 const double squaredRadius = (radius * radius * exaggeration);
736 for (
int i = 0; i < (int)shape.size(); i++) {
738 if (shape[i].distanceSquaredTo2D(mousePosition) <= squaredRadius) {
743 if ((distanceToShape < exaggeratedRadio) && (index == -1)) {
747 const Position hintPos = shape.size() > 1 ? positionOverLane : shape[0];
751 glTranslated(hintPos.
x(), hintPos.
y(), 0.2);
765 const std::vector<double>& lengths,
const std::vector<RGBColor>& colors,
double width,
const bool onlyContour) {
792 glTranslated(posOverLane.
x(), posOverLane.
y(), 0);
798 }
else if (colors.size() > 0) {
833 DottedGeometry extremes(s, dottedGeometryTop, drawFrontExtreme, dottedGeometryBot, drawBackExtreme);
847 dottedGeometryColor.
reset();
862 const double exaggeration,
const double lineWidth) {
863 if (exaggeration > 0) {
892 const double width,
const double exaggeration,
const bool drawFirstExtrem,
const bool drawLastExtrem,
893 const double lineWidth) {
907 DottedGeometry extremes(s, topDottedGeometry, drawFirstExtrem, botDottedGeometry, drawLastExtrem);
921 dottedGeometryColor.
reset();
936 if ((radius * exaggeration) < 2) {
946 const double width,
const double height,
const double offsetX,
const double offsetY,
const double rot,
const double exaggeration) {
950 shape.push_back(
Position(0 + width, 0 + height));
951 shape.push_back(
Position(0 + width, 0 - height));
952 shape.push_back(
Position(0 - width, 0 - height));
953 shape.push_back(
Position(0 - width, 0 + height));
955 shape.
add(offsetX, offsetY, 0);
967 const RGBColor &color,
const bool drawEntire) {
976 glTranslated(0, 0, -1);
983 glTranslated(0, 0, 0.1);
987 }
else if (distanceSquared > 25) {
991 glTranslated(0, 0, 0.1);
996 if (distanceSquared > 100) {
1007 glTranslated(0, 0, 0.1);
1026 const RGBColor &color,
const bool drawEntire) {
1035 glTranslated(0, 0, -1);
1039 if (drawEntire || (distanceSquared < 25)) {
1046 glTranslated(0, 0, 0.1);
1054 glTranslated(0, 0, 0.1);
1059 if (distanceSquared > 100) {
1070 glTranslated(0, 0, 0.1);
1097 const double inc = 360 / (double)steps;
1099 for (
int i = 0; i <= steps; ++i) {
1101 vertexCircle.push_back(
Position(vertex.
x() * width, vertex.
y() * width));
1104 vertexCircle.
add(pos);
1105 return vertexCircle;
1112 glRotated((rot * -1) + 90, 0, 0, 1);
static double calculateLength(const Position &first, const Position &second)
return length between two points (used in geometric calculations)
bool drawForPositionSelection
whether drawing is performed for the purpose of selecting objects with a single click
static void drawDottedContourShape(const DottedContourType type, const GUIVisualizationSettings &s, const PositionVector &shape, const double width, const double exaggeration, const bool drawFirstExtrem, const bool drawLastExtrem, const double lineWidth=-1)
draw dotted contour for the given shape (used by additionals)
@ GLO_DOTTEDCONTOUR_INSPECTED
dotted contour inspected element (used in NETEDIT)
static PositionVector getVertexCircleAroundPosition(const Position &pos, const double width, const int steps=8)
get a circle around the given position
static const double arrowLength
arrow length
void moveShapeToSide(const double value)
move shape to side
static int angleLookup(const double angleDeg)
normalize angle for lookup in myCircleCoords
static const RGBColor BLACK
bool drawForRectangleSelection
whether drawing is performed for the purpose of selecting objects using a rectangle
void calculateShapeRotationsAndLengths()
calculate shape rotations and lengths
static const Position INVALID
used to indicate that a position is valid
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.
static void drawParentLine(const GUIVisualizationSettings &s, const Position &parent, const Position &child, const RGBColor &color, const bool drawEntire)
draw line between parent and children (used in NETEDIT)
void rotate2D(double angle)
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
Segment()
default constructor
void updateLane2laneConnection()
update
class for pack all variables related with DottedGeometry color
PositionVector computeSmoothShape(const PositionVector &begShape, const PositionVector &endShape, int numPoints, bool isTurnaround, double extrapolateBeg, double extrapolateEnd, NBNode *recordError=0, int shapeFlag=0) const
Compute a smooth curve between the given geometries.
static void drawDottedContourEdge(const DottedContourType type, const GUIVisualizationSettings &s, const GNEEdge *edge, const bool drawFrontExtreme, const bool drawBackExtreme)
draw dotted contour for the given dottedGeometries (used by edges)
#define CIRCLE_RESOLUTION
static const double segmentLength
length of dotted contour segments
void scaleRelative(double factor)
enlarges/shrinks the polygon by a factor based at the centroid
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static OptionsCont & getOptions()
Retrieves the options.
void changeColor()
change color
static void drawGeometryPoints(const GUIVisualizationSettings &s, const GNEViewNet *viewNet, const PositionVector &shape, const RGBColor &geometryPointColor, const RGBColor &textColor, const double radius, const double exaggeration)
draw geometry points
double length() const
Returns the length.
const RGBColor getColor(DottedContourType type)
get inspected color (and change flag)
DottedGeometryColor(const GUIVisualizationSettings &settings)
constructor
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
void invertOffset()
invert offset of all segments
void updateGeometry(const PositionVector &shape)
update entire geometry
static const double geometryPointsText
details for Geometry Points Texts
The representation of a single edge during network building.
static void pushMatrix()
push matrix
class for NETEDIT geometries over lanes
A road/street connecting two junctions (netedit-version)
void add(double xoff, double yoff, double zoff)
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
NBNode * getToNode() const
Returns the destination node of the edge.
static const RGBColor MAGENTA
GUIVisualizationDetailSettings detailSettings
detail settings
const PositionVector & getLaneShape() const
get elements shape
static void drawLaneGeometry(const GNEViewNet *viewNet, const PositionVector &shape, const std::vector< double > &rotations, const std::vector< double > &lengths, const std::vector< RGBColor > &colors, double width, const bool onlyContour=false)
draw lane geometry (use their own function due colors)
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
static const double arrowWidth
arrow width
void closePolygon()
ensures that the last position equals the first
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, const int align=0, double width=-1)
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
class for pack all variables related with DottedGeometry
int getNumLanes() const
Returns the number of lanes.
static void drawGeometry(const GNEViewNet *viewNet, const Geometry &geometry, const double width)
draw geometry
GUIVisualizationAdditionalSettings additionalSettings
Additional settings.
double scale
information about a lane's width (temporary, used for a single view)
A point in 2D or 3D with translation and scaling methods.
double x() const
Returns the x-position.
void append(const PositionVector &v, double sameThreshold=2.0)
static void rotateOverLane(const double rot)
rotate over lane (used by Lock icons, detector logos, etc.)
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
bool editingElevation() const
check if we're editing elevation
const double halfWidth
Draw as a normal lane, and reduce width to make sure that a selected edge can still be seen.
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
void setWidth(const double width)
change default width
void scaleGeometry(const double scale)
scale geometry
double length2D() const
Returns the length.
Position getPositionInformation() const
Returns the cursor's x/y position within the network.
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
bool exist(const GNELane *toLane) const
check if exist a lane2lane geometry for the given tolane
void clearGeometry()
clear geometry
const std::vector< double > & getShapeLengths() const
The lengths of the single shape parts.
static void drawChildLine(const GUIVisualizationSettings &s, const Position &child, const Position &parent, const RGBColor &color, const bool drawEntire)
draw line between child and parent (used in NETEDIT)
double distanceSquaredTo2D(const Position &p2) const
returns the square of the distance to another position (Only using x and y positions)
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)
int getCircleResolution() const
function to calculate circle resolution for all circles drawn in drawGL(...) functions
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
void updateDottedGeometry(const GUIVisualizationSettings &s, const GNELane *lane)
update DottedGeometry (using lane shape)
double myWidth
geometry width
const PositionVector & getLaneShape(int i) const
Returns the shape of the nth lane.
const GNEGeometry::Geometry & getLane2laneGeometry(const GNELane *toLane) const
get lane2lane geometry
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
const PositionVector & getShape() const
retrieve the junction shape
static void drawMovingHint(const GUIVisualizationSettings &s, const GNEViewNet *viewNet, const PositionVector &shape, const RGBColor &hintColor, const double radius, const double exaggeration)
draw moving hint
double y() const
Returns the y-position.
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
PositionVector reverse() const
reverse position vector
void drawDottedGeometry(DottedGeometryColor &dottedGeometryColor, GNEGeometry::DottedContourType type, const double customWidth=-1) const
draw inspected dottedShape
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
static void drawDottedContourClosedShape(const DottedContourType type, const GUIVisualizationSettings &s, const PositionVector &shape, const double exaggeration, const double lineWidth=-1)
draw dotted contour for the given closed shape (used by Juctions, shapes and TAZs)
#define MAXIMUM_DOTTEDGEOMETRYLENGTH
double getWidth() const
get width
static void popMatrix()
pop matrix
Geometry()
default constructor
static PositionVector myCircleCoords
Storage for precomputed sin/cos-values describing a circle.
GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings
static const double segmentWidth
width of dotted contour segments
static const double arrowOffset
arrow offset
@ GLO_DOTTEDCONTOUR_FRONT
dotted contour front element (used in NETEDIT)
DottedGeometry()
constructor
void reset()
rest Dotted Geometry Color
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
static void drawContourGeometry(const Geometry &geometry, const double width, const bool drawExtremes=false)
draw contour geometry
static void adjustStartPosGeometricPath(double &startPos, const GNELane *startLane, double &endPos, const GNELane *endLane)
adjust start and end positions in geometric path
std::vector< DottedGeometry::Segment > myDottedGeometrySegments
dotted element shape (note: It's centered in 0,0 due scaling)
static const RGBColor GREEN
static double calculateRotation(const Position &first, const Position &second)
return angle between two points (used in geometric calculations)
bool drawDetail(const double detail, const double exaggeration) const
check if details can be drawn for the given GUIVisualizationDetailSettings and current scale and exxa...
Lane2laneConnection()
constructor
Stores the information about how to visualize structures.
static void drawDottedSquaredShape(const DottedContourType type, const GUIVisualizationSettings &s, const Position &pos, const double width, const double height, const double offsetX, const double offsetY, const double rot, const double exaggeration)
draw dotted squared contour (used by additionals and demand elements)
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
double area() const
Returns the area (0 for non-closed)
NetworkEditMode networkEditMode
the current Network edit mode
void updateSinglePosGeometry(const Position &position, const double rotation)
update position and rotation
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
const PositionVector & getShape() const
The shape of the additional element.
static void drawDottedContourCircle(const DottedContourType type, const GUIVisualizationSettings &s, const Position &pos, const double radius, const double exaggeration)
draw dotted contour for the given Position and radius (used by Juctions and POIs)
void calculateShapeRotationsAndLengths()
calculate shape rotations and lengths
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
static void drawTriangleAtEnd(const Position &p1, const Position &p2, double tLength, double tWidth, const double extraOffset=0)
Draws a triangle at the end of the given line.
@ NETWORK_MOVE
mode for moving network elements
NBEdge * getTurnDestination(bool possibleDestination=false) const