Eclipse SUMO - Simulation of Urban MObility
GNEGeometry.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2021 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // File for geometry classes and functions
19 /****************************************************************************/
20 #include <utils/geom/GeomHelper.h>
21 #include <utils/gui/div/GLHelper.h>
24 
25 #include "GNEGeometry.h"
26 #include "GNENet.h"
27 #include "GNEViewNet.h"
28 
29 #define CIRCLE_RESOLUTION (double)10 // inverse in degrees
30 #define MAXIMUM_DOTTEDGEOMETRYLENGTH 500.0
31 
32 // ===========================================================================
33 // static member definitions
34 // ===========================================================================
36 
37 // ===========================================================================
38 // method definitions
39 // ===========================================================================
40 
41 // ---------------------------------------------------------------------------
42 // GNEGeometry::Geometry - methods
43 // ---------------------------------------------------------------------------
44 
46 }
47 
48 
50  myShape(shape) {
51  // calculate shape rotation and lenghts
53 }
54 
55 
56 GNEGeometry::Geometry::Geometry(const PositionVector& shape, const std::vector<double>& shapeRotations, const std::vector<double>& shapeLengths) :
57  myShape(shape),
58  myShapeRotations(shapeRotations),
59  myShapeLengths(shapeLengths) {
60 }
61 
62 
63 void
65  // clear geometry
66  clearGeometry();
67  // update shape
68  myShape = shape;
69  // calculate shape rotation and lenghts
70  calculateShapeRotationsAndLengths();
71 }
72 
73 
74 void
75 GNEGeometry::Geometry::updateGeometry(const PositionVector& shape, const double posOverShape, const double lateralOffset) {
76  // first clear geometry
77  clearGeometry();
78  // get shape length
79  const double shapeLength = shape.length();
80  // calculate position and rotation
81  if (posOverShape < 0) {
82  myShape.push_back(shape.positionAtOffset(0, lateralOffset));
83  myShapeRotations.push_back(shape.rotationDegreeAtOffset(0));
84  } else if (posOverShape > shapeLength) {
85  myShape.push_back(shape.positionAtOffset(shapeLength, lateralOffset));
86  myShapeRotations.push_back(shape.rotationDegreeAtOffset(shapeLength));
87  } else {
88  myShape.push_back(shape.positionAtOffset(posOverShape, lateralOffset));
89  myShapeRotations.push_back(shape.rotationDegreeAtOffset(posOverShape));
90  }
91 }
92 
93 
94 void
95 GNEGeometry::Geometry::updateGeometry(const PositionVector& shape, double starPosOverShape, double endPosOverShape, const double lateralOffset) {
96  // first clear geometry
97  clearGeometry();
98  // set new shape
99  myShape = shape;
100  // set lateral offset
101  myShape.move2side(lateralOffset);
102  // get shape lenght
103  const double shapeLength = myShape.length2D();
104  // set initial beginTrim value
105  if (starPosOverShape < 0) {
106  endPosOverShape = 0;
107  }
108  // set initial endtrim value
109  if (starPosOverShape < 0) {
110  endPosOverShape = shapeLength;
111  }
112  // check maximum beginTrim
113  if (starPosOverShape > (shapeLength - POSITION_EPS)) {
114  endPosOverShape = (shapeLength - POSITION_EPS);
115  }
116  // check maximum endTrim
117  if ((endPosOverShape > shapeLength)) {
118  endPosOverShape = shapeLength;
119  }
120  // check sub-vector
121  if (endPosOverShape <= starPosOverShape) {
122  endPosOverShape = endPosOverShape + POSITION_EPS;
123  }
124  // trim shape
125  myShape = myShape.getSubpart2D(starPosOverShape, endPosOverShape);
126  // calculate shape rotation and lenghts
127  calculateShapeRotationsAndLengths();
128 }
129 
130 
131 void
132 GNEGeometry::Geometry::updateGeometry(const PositionVector& shape, double beginTrimPosition, double endTrimPosition,
133  const Position& extraFirstPosition, const Position& extraLastPosition) {
134  // first clear geometry
135  clearGeometry();
136  // set new shape
137  myShape = shape;
138  // check trim values
139  if ((beginTrimPosition != -1) || (endTrimPosition != -1)) {
140  // get shape lenght
141  const double shapeLength = myShape.length2D();
142  // set initial beginTrim value
143  if (beginTrimPosition < 0) {
144  beginTrimPosition = 0;
145  }
146  // set initial endtrim value
147  if (endTrimPosition < 0) {
148  endTrimPosition = shapeLength;
149  }
150  // check maximum beginTrim
151  if (beginTrimPosition > (shapeLength - POSITION_EPS)) {
152  beginTrimPosition = (shapeLength - POSITION_EPS);
153  }
154  // check maximum endTrim
155  if ((endTrimPosition > shapeLength)) {
156  endTrimPosition = shapeLength;
157  }
158  // check sub-vector
159  if (endTrimPosition <= beginTrimPosition) {
160  endTrimPosition = endTrimPosition + POSITION_EPS;
161  }
162  // trim shape
163  myShape = myShape.getSubpart2D(beginTrimPosition, endTrimPosition);
164  // add extra positions
165  if (extraFirstPosition != Position::INVALID) {
166  myShape.push_front_noDoublePos(extraFirstPosition);
167  }
168  if (extraLastPosition != Position::INVALID) {
169  myShape.push_back_noDoublePos(extraLastPosition);
170  }
171  }
172  // calculate shape rotation and lenghts
173  calculateShapeRotationsAndLengths();
174 }
175 
176 
177 void
178 GNEGeometry::Geometry::updateSinglePosGeometry(const Position& position, const double rotation) {
179  // first clear geometry
180  clearGeometry();
181  // set position and rotation
182  myShape.push_back(position);
183  myShapeRotations.push_back(rotation);
184 }
185 
186 
187 void
189  // scale shape and lenghts
190  myShape.scaleRelative(scale);
191  // scale lenghts
192  for (auto& shapeLength : myShapeLengths) {
193  shapeLength *= scale;
194  }
195 }
196 
197 
198 const PositionVector&
200  return myShape;
201 }
202 
203 
204 const std::vector<double>&
206  return myShapeRotations;
207 }
208 
209 
210 const std::vector<double>&
212  return myShapeLengths;
213 }
214 
215 
217  // clear geometry containers
218  myShape.clear();
219  myShapeRotations.clear();
220  myShapeLengths.clear();
221 }
222 
223 
224 void
226  // clear rotations and lengths
227  myShapeRotations.clear();
228  myShapeLengths.clear();
229  // Get number of parts of the shape
230  int numberOfSegments = (int)myShape.size() - 1;
231  // If number of segments is more than 0
232  if (numberOfSegments >= 0) {
233  // Reserve memory (To improve efficiency)
234  myShapeRotations.reserve(numberOfSegments);
235  myShapeLengths.reserve(numberOfSegments);
236  // Calculate lengths and rotations for every shape
237  for (int i = 0; i < numberOfSegments; i++) {
238  myShapeRotations.push_back(calculateRotation(myShape[i], myShape[i + 1]));
239  myShapeLengths.push_back(calculateLength(myShape[i], myShape[i + 1]));
240  }
241  }
242 }
243 
244 // ---------------------------------------------------------------------------
245 // GNEGeometry::DottedGeometryColor - methods
246 // ---------------------------------------------------------------------------
247 
249  mySettings(settings),
250  myColorFlag(true) {}
251 
252 
253 const RGBColor
255  if (type == DottedContourType::INSPECT) {
256  if (myColorFlag) {
257  myColorFlag = false;
258  return mySettings.dottedContourSettings.firstInspectedColor;
259  } else {
260  myColorFlag = true;
261  return mySettings.dottedContourSettings.secondInspectedColor;
262  }
263  } else if (type == DottedContourType::FRONT) {
264  if (myColorFlag) {
265  myColorFlag = false;
266  return mySettings.dottedContourSettings.firstFrontColor;
267  } else {
268  myColorFlag = true;
269  return mySettings.dottedContourSettings.secondFrontColor;
270  }
271  } else if (type == DottedContourType::GREEN) {
272  if (myColorFlag) {
273  myColorFlag = false;
274  return RGBColor::GREEN;
275  } else {
276  myColorFlag = true;
278  }
279  } else if (type == DottedContourType::MAGENTA) {
280  if (myColorFlag) {
281  myColorFlag = false;
282  return RGBColor::MAGENTA;
283  } else {
284  myColorFlag = true;
286  }
287  } else {
288  return RGBColor::BLACK;
289  }
290 }
291 
292 
293 void
295  if (myColorFlag) {
296  myColorFlag = false;
297  } else {
298  myColorFlag = true;
299  }
300 }
301 
302 
303 void
305  myColorFlag = true;
306 }
307 
308 // ---------------------------------------------------------------------------
309 // GNEGeometry::DottedGeometry - methods
310 // ---------------------------------------------------------------------------
311 
312 
314  offset(-1) {
315 }
316 
317 
319  shape(newShape),
320  offset(-1) {
321 }
322 
323 
325  myWidth(0) {
326 }
327 
328 
330  myWidth(s.dottedContourSettings.segmentWidth) {
331  // check if shape has to be closed
332  if (closeShape && (shape.size() > 2)) {
333  shape.closePolygon();
334  }
335  if (shape.size() > 1) {
336  // get shape
337  for (int i = 1; i < (int)shape.size(); i++) {
338  myDottedGeometrySegments.push_back(Segment({shape[i - 1], shape[i]}));
339  }
340  // calculate segment length
341  double segmentLength = s.dottedContourSettings.segmentLength;
342  if (shape.length2D() > MAXIMUM_DOTTEDGEOMETRYLENGTH) {
343  segmentLength = shape.length2D() / (MAXIMUM_DOTTEDGEOMETRYLENGTH * 0.5);
344  }
345  // resample
346  for (auto& segment : myDottedGeometrySegments) {
347  segment.shape = segment.shape.resample(segmentLength, true);
348  }
349  // calculate shape rotations and lenghts
351  }
352 }
353 
354 
356  const DottedGeometry& topDottedGeometry, const bool drawFirstExtrem,
357  const DottedGeometry& botDottedGeometry, const bool drawLastExtrem) :
358  myWidth(s.dottedContourSettings.segmentWidth) {
359  // check size of both geometries
360  if ((topDottedGeometry.myDottedGeometrySegments.size() > 0) &&
361  (botDottedGeometry.myDottedGeometrySegments.size() > 0)) {
362  // add extremes
363  if (drawFirstExtrem &&
364  (topDottedGeometry.myDottedGeometrySegments.front().shape.size() > 0) &&
365  (botDottedGeometry.myDottedGeometrySegments.front().shape.size() > 0)) {
366  // add first extreme
368  topDottedGeometry.myDottedGeometrySegments.front().shape.front(),
369  botDottedGeometry.myDottedGeometrySegments.front().shape.front()}));
370  }
371  if (drawLastExtrem &&
372  (topDottedGeometry.myDottedGeometrySegments.back().shape.size() > 0) &&
373  (botDottedGeometry.myDottedGeometrySegments.back().shape.size() > 0)) {
374  // add last extreme
376  topDottedGeometry.myDottedGeometrySegments.back().shape.back(),
377  botDottedGeometry.myDottedGeometrySegments.back().shape.back()}));
378  // invert offset of second dotted geometry
379  myDottedGeometrySegments.back().offset *= -1;
380  }
381  }
382  // resample
383  for (auto& segment : myDottedGeometrySegments) {
384  segment.shape = segment.shape.resample(s.dottedContourSettings.segmentLength, true);
385  }
386  // calculate shape rotations and lenghts
388 }
389 
390 
391 void
393  // update settings and width
395  // reset segments
396  myDottedGeometrySegments.clear();
397  // get shape
398  for (int i = 1; i < (int)lane->getLaneShape().size(); i++) {
399  myDottedGeometrySegments.push_back(Segment({lane->getLaneShape()[i - 1], lane->getLaneShape()[i]}));
400  }
401  // resample
402  for (auto& segment : myDottedGeometrySegments) {
403  segment.shape = segment.shape.resample(s.dottedContourSettings.segmentLength, true);
404  }
405  // calculate shape rotations and lenghts
406  calculateShapeRotationsAndLengths();
407 }
408 
409 
410 void
412  // update settings and width
414  // reset segments
415  myDottedGeometrySegments.clear();
416  // check if shape has to be closed
417  if (closeShape && (shape.size() > 2)) {
418  shape.closePolygon();
419  }
420  if (shape.size() > 1) {
421  // get shape
422  for (int i = 1; i < (int)shape.size(); i++) {
423  myDottedGeometrySegments.push_back(Segment({shape[i - 1], shape[i]}));
424  }
425  // resample
426  for (auto& segment : myDottedGeometrySegments) {
427  segment.shape = segment.shape.resample(s.dottedContourSettings.segmentLength, true);
428  }
429  // calculate shape rotations and lenghts
430  calculateShapeRotationsAndLengths();
431  }
432 }
433 
434 
435 void
437  // get width
438  const double width = (customWidth > 0)? customWidth : myWidth;
439  // iterate over all segments
440  for (auto& segment : myDottedGeometrySegments) {
441  // iterate over shape
442  for (int i = 0; i < ((int)segment.shape.size() - 1); i++) {
443  // set color
444  GLHelper::setColor(dottedGeometryColor.getColor(type));
445  // draw box line
446  GLHelper::drawBoxLine(segment.shape[i], segment.rotations.at(i), segment.lengths.at(i), width, 0);
447  }
448  }
449 }
450 
451 
452 void
454  // move 2 side
455  for (auto& segment : myDottedGeometrySegments) {
456  segment.shape.move2side(value);
457  }
458 }
459 
460 
461 double
463  return myWidth;
464 }
465 
466 
467 void
469  myWidth = width;
470 }
471 
472 
473 void
475  // iterate over all segments
476  for (auto& segment : myDottedGeometrySegments) {
477  segment.offset *= -1;
478  }
479 }
480 
481 
482 void
484  // iterate over all segments
485  for (auto& segment : myDottedGeometrySegments) {
486  // Get number of parts of the shape
487  int numberOfSegments = (int)segment.shape.size() - 1;
488  // If number of segments is more than 0
489  if (numberOfSegments >= 0) {
490  // Reserve memory (To improve efficiency)
491  segment.rotations.reserve(numberOfSegments);
492  segment.lengths.reserve(numberOfSegments);
493  // Calculate lengths and rotations for every shape
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]));
497  }
498  }
499  }
500 }
501 
502 // ---------------------------------------------------------------------------
503 // GNEGeometry::Lane2laneConnection - methods
504 // ---------------------------------------------------------------------------
505 
507  myFromLane(fromLane) {
508 }
509 
510 
511 void
513  // declare numPoints
514  const int numPoints = 5;
515  const int maximumLanes = 10;
516  // clear connectionsMap
517  myConnectionsMap.clear();
518  // iterate over outgoingEdge's lanes
519  for (const auto& outgoingEdge : myFromLane->getParentEdge()->getToJunction()->getGNEOutgoingEdges()) {
520  for (const auto& outgoingLane : outgoingEdge->getLanes()) {
521  // get NBEdges from and to
522  const NBEdge* NBEdgeFrom = myFromLane->getParentEdge()->getNBEdge();
523  const NBEdge* NBEdgeTo = outgoingLane->getParentEdge()->getNBEdge();
524  // declare shape
525  PositionVector shape;
526  // only create smooth shapes if Edge From has as maximum 10 lanes
527  if ((NBEdgeFrom->getNumLanes() <= maximumLanes) && (NBEdgeFrom->getToNode()->getShape().area() > 4)) {
528  // calculate smoot shape
529  shape = NBEdgeFrom->getToNode()->computeSmoothShape(
530  NBEdgeFrom->getLaneShape(myFromLane->getIndex()),
531  NBEdgeTo->getLaneShape(outgoingLane->getIndex()),
532  numPoints, NBEdgeFrom->getTurnDestination() == NBEdgeTo,
533  (double) numPoints * (double) NBEdgeFrom->getNumLanes(),
534  (double) numPoints * (double) NBEdgeTo->getNumLanes());
535  } else {
536  // create a shape using lane shape extremes
537  shape = {myFromLane->getLaneShape().back(), outgoingLane->getLaneShape().front()};
538  }
539  // update connection map
540  myConnectionsMap[outgoingLane].updateGeometry(shape);
541  }
542  }
543 }
544 
545 
546 bool
548  return (myConnectionsMap.count(toLane) > 0);
549 }
550 
551 
554  return myConnectionsMap.at(toLane);
555 }
556 
557 
559  myFromLane(nullptr) {
560 }
561 
562 // ---------------------------------------------------------------------------
563 // GNEGeometry - methods
564 // ---------------------------------------------------------------------------
565 
566 double
567 GNEGeometry::calculateRotation(const Position& first, const Position& second) {
568  // return rotation (angle) of the vector constructed by points first and second
569  return ((double)atan2((second.x() - first.x()), (first.y() - second.y())) * (double) 180.0 / (double)M_PI);
570 }
571 
572 
573 double
574 GNEGeometry::calculateLength(const Position& first, const Position& second) {
575  // return 2D distance between two points
576  return first.distanceTo2D(second);
577 }
578 
579 
580 void
581 GNEGeometry::adjustStartPosGeometricPath(double& startPos, const GNELane* startLane, double& endPos, const GNELane* endLane) {
582  // adjust both, if start and end lane are the same
583  if (startLane && endLane && (startLane == endLane) && (startPos != -1) && (endPos != -1)) {
584  if (startPos >= endPos) {
585  endPos = (startPos + POSITION_EPS);
586  }
587  }
588  // adjust startPos
589  if ((startPos != -1) && startLane) {
590  if (startPos < POSITION_EPS) {
591  startPos = POSITION_EPS;
592  }
593  if (startPos > (startLane->getLaneShape().length() - POSITION_EPS)) {
594  startPos = (startLane->getLaneShape().length() - POSITION_EPS);
595  }
596  }
597  // adjust endPos
598  if ((endPos != -1) && endLane) {
599  if (endPos < POSITION_EPS) {
600  endPos = POSITION_EPS;
601  }
602  if (endPos > (endLane->getLaneShape().length() - POSITION_EPS)) {
603  endPos = (endLane->getLaneShape().length() - POSITION_EPS);
604  }
605  }
606 }
607 
608 
609 void
610 GNEGeometry::drawGeometry(const GNEViewNet* viewNet, const Geometry& geometry, const double width) {
611  // continue depending of draw for position selection
613  // obtain mouse Position
614  const Position mousePosition = viewNet->getPositionInformation();
615  // obtain position over lane relative to mouse position
616  const Position posOverLane = geometry.getShape().positionAtOffset2D(geometry.getShape().nearest_offset_to_point2D(mousePosition));
617  // if mouse is over segment
618  if (posOverLane.distanceSquaredTo2D(mousePosition) <= (width * width)) {
619  // push matrix
621  // translate to position over lane
622  glTranslated(posOverLane.x(), posOverLane.y(), 0);
623  // Draw circle
625  // pop draw matrix
627  }
628  } else if (viewNet->getVisualisationSettings().scale * width < 1) {
629  // draw line (needed for zoom out)
630  GLHelper::drawLine(geometry.getShape());
631  } else {
632  GLHelper::drawBoxLines(geometry.getShape(), geometry.getShapeRotations(), geometry.getShapeLengths(), width);
633  }
634 }
635 
636 
637 void
638 GNEGeometry::drawContourGeometry(const Geometry& geometry, const double width, const bool drawExtremes) {
639  // get shapes
640  PositionVector shapeA = geometry.getShape();
641  PositionVector shapeB = geometry.getShape();
642  // move both shapes
643  shapeA.move2side((width - 0.1));
644  shapeB.move2side((width - 0.1) * -1);
645  // check if we have to drawn extremes
646  if (drawExtremes) {
647  // reverse shape B
648  shapeB = shapeB.reverse();
649  // append shape B to shape A
650  shapeA.append(shapeB, 0);
651  // close shape A
652  shapeA.closePolygon();
653  // draw box lines using shapeA
654  GLHelper::drawBoxLines(shapeA, 0.1);
655  } else {
656  // draw box lines using shapeA
657  GLHelper::drawBoxLines(shapeA, 0.1);
658  // draw box lines using shapeA
659  GLHelper::drawBoxLines(shapeB, 0.1);
660  }
661 }
662 
663 
664 void
666  const RGBColor& geometryPointColor, const RGBColor& textColor, const double radius, const double exaggeration) {
667  // get mouse position
668  const Position mousePosition = viewNet->getPositionInformation();
669  // get exaggeratedRadio
670  const double exaggeratedRadio = (radius * exaggeration);
671  // get radius squared
672  const double exaggeratedRadioSquared = (exaggeratedRadio * exaggeratedRadio);
673  // iterate over shape
674  for (const auto& vertex : shape) {
675  // if drawForPositionSelection is enabled, check distance between mouse and vertex
676  if (!s.drawForPositionSelection || (mousePosition.distanceSquaredTo2D(vertex) <= exaggeratedRadioSquared)) {
677  // push geometry point matrix
679  // move to vertex
680  glTranslated(vertex.x(), vertex.y(), 0.2);
681  // set color
682  GLHelper::setColor(geometryPointColor);
683  // draw circle
684  GLHelper::drawFilledCircle(exaggeratedRadio, s.getCircleResolution());
685  // pop geometry point matrix
687  // draw elevation or special symbols (Start, End and Block)
689  // get draw detail
690  const bool drawDetail = s.drawDetail(s.detailSettings.geometryPointsText, exaggeration);
691  // draw text
692  if (viewNet->getNetworkViewOptions().editingElevation()) {
693  // Push Z matrix
695  // draw Z (elevation)
696  GLHelper::drawText(toString(vertex.z()), vertex, 0.3, 0.7, textColor);
697  // pop Z matrix
699  } else if ((vertex == shape.front()) && drawDetail) {
700  // push "S" matrix
702  // draw a "s" over first point
703  GLHelper::drawText("S", vertex, 0.3, 2 * exaggeratedRadio, textColor);
704  // pop "S" matrix
706  } else if ((vertex == shape.back()) && (shape.isClosed() == false) && drawDetail) {
707  // push "E" matrix
709  // draw a "e" over last point if polygon isn't closed
710  GLHelper::drawText("E", vertex, 0.3, 2 * exaggeratedRadio, textColor);
711  // pop "E" matrix
713  }
714  }
715  }
716  }
717 }
718 
719 
720 void
722  const RGBColor& hintColor, const double radius, const double exaggeration) {
723  // first NetworkEditMode
725  // get mouse position
726  const Position mousePosition = viewNet->getPositionInformation();
727  // get exaggeratedRadio
728  const double exaggeratedRadio = (radius * exaggeration);
729  // obtain distance to shape
730  const double distanceToShape = shape.distance2D(mousePosition);
731  // obtain squared radius
732  const double squaredRadius = (radius * radius * exaggeration);
733  // declare index
734  int index = -1;
735  // iterate over shape
736  for (int i = 0; i < (int)shape.size(); i++) {
737  // check distance
738  if (shape[i].distanceSquaredTo2D(mousePosition) <= squaredRadius) {
739  index = i;
740  }
741  }
742  // continue depending of distance to shape
743  if ((distanceToShape < exaggeratedRadio) && (index == -1)) {
744  // obtain position over lane
745  const Position positionOverLane = shape.positionAtOffset2D(shape.nearest_offset_to_point2D(mousePosition));
746  // calculate hintPos
747  const Position hintPos = shape.size() > 1 ? positionOverLane : shape[0];
748  // push hintPos matrix
750  // translate to hintPos
751  glTranslated(hintPos.x(), hintPos.y(), 0.2);
752  // set color
753  GLHelper::setColor(hintColor);
754  // draw filled circle
755  GLHelper:: drawFilledCircle(exaggeratedRadio, s.getCircleResolution());
756  // pop hintPos matrix
758  }
759  }
760 }
761 
762 
763 void
764 GNEGeometry::drawLaneGeometry(const GNEViewNet* viewNet, const PositionVector& shape, const std::vector<double>& rotations,
765  const std::vector<double>& lengths, const std::vector<RGBColor>& colors, double width, const bool onlyContour) {
766  // first check if we're in draw a contour or for selecting cliking mode
767  if (onlyContour) {
768  // get shapes
769  PositionVector shapeA = shape;
770  PositionVector shapeB = shape;
771  // move both shapes
772  shapeA.move2side((width - 0.1));
773  shapeB.move2side((width - 0.1) * -1);
774  // reverse shape B
775  shapeB = shapeB.reverse();
776  // append shape B to shape A
777  shapeA.append(shapeB, 0);
778  // close shape A
779  shapeA.closePolygon();
780  // draw box lines using shapeA
781  GLHelper::drawBoxLines(shapeA, 0.1);
782  } else if (viewNet->getVisualisationSettings().drawForPositionSelection) {
783  // obtain mouse Position
784  const Position mousePosition = viewNet->getPositionInformation();
785  // obtain position over lane relative to mouse position
786  const Position posOverLane = shape.positionAtOffset2D(shape.nearest_offset_to_point2D(mousePosition));
787  // if mouse is over segment
788  if (posOverLane.distanceSquaredTo2D(mousePosition) <= (width * width)) {
789  // push matrix
791  // translate to position over lane
792  glTranslated(posOverLane.x(), posOverLane.y(), 0);
793  // Draw circle
795  // pop draw matrix
797  }
798  } else if (colors.size() > 0) {
799  // draw box lines with own colors
800  GLHelper::drawBoxLines(shape, rotations, lengths, colors, width);
801  } else {
802  // draw box lines with current color
803  GLHelper::drawBoxLines(shape, rotations, lengths, width);
804  }
805 }
806 
807 
808 void
809 GNEGeometry::drawDottedContourEdge(const DottedContourType type, const GUIVisualizationSettings& s, const GNEEdge* edge, const bool drawFrontExtreme, const bool drawBackExtreme) {
810  if (edge->getLanes().size() == 1) {
811  GNELane::LaneDrawingConstants laneDrawingConstants(s, edge->getLanes().front());
812  GNEGeometry::drawDottedContourShape(type, s, edge->getLanes().front()->getLaneShape(), laneDrawingConstants.halfWidth, 1, drawFrontExtreme, drawBackExtreme);
813  } else {
814  // set left hand flag
815  const bool lefthand = OptionsCont::getOptions().getBool("lefthand");
816  // obtain lanes
817  const GNELane* topLane = lefthand ? edge->getLanes().back() : edge->getLanes().front();
818  const GNELane* botLane = lefthand ? edge->getLanes().front() : edge->getLanes().back();
819  // obtain a copy of both geometries
820  GNEGeometry::DottedGeometry dottedGeometryTop(s, topLane->getLaneShape(), false);
821  GNEGeometry::DottedGeometry dottedGeometryBot(s, botLane->getLaneShape(), false);
822  // obtain both LaneDrawingConstants
823  GNELane::LaneDrawingConstants laneDrawingConstantsFront(s, topLane);
824  GNELane::LaneDrawingConstants laneDrawingConstantsBack(s, botLane);
825  // move shapes to side
826  dottedGeometryTop.moveShapeToSide(laneDrawingConstantsFront.halfWidth);
827  dottedGeometryBot.moveShapeToSide(laneDrawingConstantsBack.halfWidth * -1);
828  // invert offset of top dotted geometry
829  dottedGeometryTop.invertOffset();
830  // declare DottedGeometryColor
831  DottedGeometryColor dottedGeometryColor(s);
832  // calculate extremes
833  DottedGeometry extremes(s, dottedGeometryTop, drawFrontExtreme, dottedGeometryBot, drawBackExtreme);
834  // Push draw matrix
836  // draw inspect or front dotted contour
837  if (type == DottedContourType::FRONT) {
838  // translate to front
839  glTranslated(0, 0, GLO_DOTTEDCONTOUR_FRONT);
840  } else {
841  // translate to front
842  glTranslated(0, 0, GLO_DOTTEDCONTOUR_INSPECTED);
843  }
844  // draw top dotted geometry
845  dottedGeometryTop.drawDottedGeometry(dottedGeometryColor, type);
846  // reset color
847  dottedGeometryColor.reset();
848  // draw top dotted geometry
849  dottedGeometryBot.drawDottedGeometry(dottedGeometryColor, type);
850  // change color
851  dottedGeometryColor.changeColor();
852  // draw extrem dotted geometry
853  extremes.drawDottedGeometry(dottedGeometryColor, type);
854  // pop matrix
856  }
857 }
858 
859 
860 void
862  const double exaggeration, const double lineWidth) {
863  if (exaggeration > 0) {
864  // declare DottedGeometryColor
865  DottedGeometryColor dottedGeometryColor(s);
866  // scale shape using exaggeration and default dotted geometry width
867  PositionVector scaledShape = shape;
868  // scale exaggeration
869  scaledShape.scaleRelative(exaggeration);
870  // calculate dotted geometry
871  GNEGeometry::DottedGeometry dottedGeometry(s, scaledShape, true);
872  // Push draw matrix
874  // draw inspect or front dotted contour
875  if (type == DottedContourType::FRONT) {
876  // translate to front
877  glTranslated(0, 0, GLO_DOTTEDCONTOUR_INSPECTED);
878  } else {
879  // translate to front
880  glTranslated(0, 0, GLO_DOTTEDCONTOUR_INSPECTED);
881  }
882  // draw dotted geometry
883  dottedGeometry.drawDottedGeometry(dottedGeometryColor, type, lineWidth);
884  // pop matrix
886  }
887 }
888 
889 
890 void
892  const double width, const double exaggeration, const bool drawFirstExtrem, const bool drawLastExtrem,
893  const double lineWidth) {
894  // declare DottedGeometryColor
895  DottedGeometryColor dottedGeometryColor(s);
896  // calculate center dotted geometry
897  GNEGeometry::DottedGeometry dottedGeometry(s, shape, false);
898  // make a copy of dotted geometry
899  DottedGeometry topDottedGeometry = dottedGeometry;
900  DottedGeometry botDottedGeometry = dottedGeometry;
901  // move geometries top and bot
902  topDottedGeometry.moveShapeToSide(width * exaggeration);
903  botDottedGeometry.moveShapeToSide(width * exaggeration* -1);
904  // invert offset of top dotted geometry
905  topDottedGeometry.invertOffset();
906  // calculate extremes
907  DottedGeometry extremes(s, topDottedGeometry, drawFirstExtrem, botDottedGeometry, drawLastExtrem);
908  // Push draw matrix
910  // translate to front
911  if (type == DottedContourType::FRONT) {
912  // translate to front
913  glTranslated(0, 0, GLO_DOTTEDCONTOUR_FRONT);
914  } else {
915  // translate to front
916  glTranslated(0, 0, GLO_DOTTEDCONTOUR_INSPECTED);
917  }
918  // draw top dotted geometry
919  topDottedGeometry.drawDottedGeometry(dottedGeometryColor, type, lineWidth);
920  // reset color
921  dottedGeometryColor.reset();
922  // draw top dotted geometry
923  botDottedGeometry.drawDottedGeometry(dottedGeometryColor, type, lineWidth);
924  // change color
925  dottedGeometryColor.changeColor();
926  // draw extrem dotted geometry
927  extremes.drawDottedGeometry(dottedGeometryColor, type, lineWidth);
928  // pop matrix
930 }
931 
932 
933 void
934 GNEGeometry::drawDottedContourCircle(const DottedContourType type, const GUIVisualizationSettings& s, const Position& pos, const double radius, const double exaggeration) {
935  // continue depending of exaggeratedRadio
936  if ((radius * exaggeration) < 2) {
937  drawDottedContourClosedShape(type, s, getVertexCircleAroundPosition(pos, radius, 8), exaggeration);
938  } else {
939  drawDottedContourClosedShape(type, s, getVertexCircleAroundPosition(pos, radius, 16), exaggeration);
940  }
941 }
942 
943 
944 void
946  const double width, const double height, const double offsetX, const double offsetY, const double rot, const double exaggeration) {
947  // create shape
948  PositionVector shape;
949  // make rectangle
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));
954  // move shape
955  shape.add(offsetX, offsetY, 0);
956  // rotate shape
957  shape.rotate2D(DEG2RAD((rot * -1) + 90));
958  // move to position
959  shape.add(pos);
960  // draw using drawDottedContourClosedShape
961  drawDottedContourClosedShape(type, s, shape, exaggeration);
962 }
963 
964 
965 void
967  const RGBColor &color, const bool drawEntire) {
969  // calculate rotation
970  const double rot = RAD2DEG(parent.angleTo2D(child)) + 90;
971  // calculate distance between origin and destiny
972  const double distanceSquared = parent.distanceSquaredTo2D(child);
973  // Add a draw matrix for details
975  // move back
976  glTranslated(0, 0, -1);
977  // draw box line
978  if (drawEntire) {
979  // draw first box line
981  GLHelper::drawBoxLine(parent, rot, sqrt(distanceSquared), .05);
982  // move front
983  glTranslated(0, 0, 0.1);
984  // draw second box line with lenght 5
985  GLHelper::setColor(color);
986  GLHelper::drawBoxLine(parent, rot, sqrt(distanceSquared), .04);
987  } else if (distanceSquared > 25) {
988  // draw first box line with lenght 5
990  GLHelper::drawBoxLine(parent, rot, 5, .05);
991  glTranslated(0, 0, 0.1);
992  // draw second box line with lenght 5
993  GLHelper::setColor(color);
994  GLHelper::drawBoxLine(parent, rot, 5, .04);
995  // draw arrow depending of distanceSquared (10*10)
996  if (distanceSquared > 100) {
997  // calculate positionVector between both points
998  const PositionVector vector = {parent, child};
999  // draw first arrow at end
1002  vector.positionAtOffset2D(5),
1006  // move front
1007  glTranslated(0, 0, 0.1);
1008  // draw second arrow at end
1009  GLHelper::setColor(color);
1011  vector.positionAtOffset2D(5),
1012  s.additionalSettings.arrowWidth - 0.01,
1013  s.additionalSettings.arrowLength - 0.01,
1014  s.additionalSettings.arrowOffset - 0.01);
1015  }
1016  }
1017  // pop draw matrix
1019  }
1020 }
1021 
1022 
1023 
1024 void
1026  const RGBColor &color, const bool drawEntire) {
1028  // calculate distance between origin and destiny
1029  const double distanceSquared = child.distanceSquaredTo2D(parent);
1030  // calculate rotation
1031  const double rot = RAD2DEG(child.angleTo2D(parent)) + 90;
1032  // Add a draw matrix for details
1034  // move back
1035  glTranslated(0, 0, -1);
1036  // set color
1037  GLHelper::setColor(color);
1038  // draw box line
1039  if (drawEntire || (distanceSquared < 25)) {
1040  // set color
1041  GLHelper::setColor(color);
1042  // draw first box line
1044  GLHelper::drawBoxLine(child, rot, sqrt(distanceSquared), .05);
1045  // move front
1046  glTranslated(0, 0, 0.1);
1047  // draw second box line with lenght 5
1048  GLHelper::setColor(color);
1049  GLHelper::drawBoxLine(child, rot, sqrt(distanceSquared), .04);
1050  } else {
1051  // draw first box line with lenght 5
1053  GLHelper::drawBoxLine(child, rot, 5, .05);
1054  glTranslated(0, 0, 0.1);
1055  // draw second box line with lenght 5
1056  GLHelper::setColor(color);
1057  GLHelper::drawBoxLine(child, rot, 5, .04);
1058  // draw arrow depending of distanceSquared (10*10)
1059  if (distanceSquared > 100) {
1060  // calculate positionVector between both points
1061  const PositionVector vector = {child, parent};
1062  // draw first arrow at end
1065  vector.positionAtOffset2D(5),
1069  // move front
1070  glTranslated(0, 0, 0.1);
1071  // draw second arrow at end
1072  GLHelper::setColor(color);
1074  vector.positionAtOffset2D(5),
1075  s.additionalSettings.arrowWidth - 0.01,
1076  s.additionalSettings.arrowLength - 0.01,
1077  s.additionalSettings.arrowOffset - 0.01);
1078  }
1079  }
1080  // pop draw matrix
1082  }
1083 }
1084 
1085 
1087 GNEGeometry::getVertexCircleAroundPosition(const Position& pos, const double width, const int steps) {
1088  // first check if we have to fill myCircleCoords (only once)
1089  if (myCircleCoords.size() == 0) {
1090  for (int i = 0; i <= (int)(360 * CIRCLE_RESOLUTION); ++i) {
1091  const double x = (double) sin(DEG2RAD(i / CIRCLE_RESOLUTION));
1092  const double y = (double) cos(DEG2RAD(i / CIRCLE_RESOLUTION));
1093  myCircleCoords.push_back(Position(x, y));
1094  }
1095  }
1096  PositionVector vertexCircle;
1097  const double inc = 360 / (double)steps;
1098  // obtain all vertices
1099  for (int i = 0; i <= steps; ++i) {
1100  const Position& vertex = myCircleCoords[GNEGeometry::angleLookup(i * inc)];
1101  vertexCircle.push_back(Position(vertex.x() * width, vertex.y() * width));
1102  }
1103  // move result using position
1104  vertexCircle.add(pos);
1105  return vertexCircle;
1106 }
1107 
1108 
1109 void
1110 GNEGeometry::rotateOverLane(const double rot) {
1111  // rotate using rotation calculated in PositionVector
1112  glRotated((rot * -1) + 90, 0, 0, 1);
1113 }
1114 
1115 
1116 int
1117 GNEGeometry::angleLookup(const double angleDeg) {
1118  const int numCoords = (int)myCircleCoords.size() - 1;
1119  int index = ((int)(floor(angleDeg * CIRCLE_RESOLUTION + 0.5))) % numCoords;
1120  if (index < 0) {
1121  index += numCoords;
1122  }
1123  assert(index >= 0);
1124  return (int)index;
1125 }
1126 
1127 
1128 /****************************************************************************/
GNEGeometry::calculateLength
static double calculateLength(const Position &first, const Position &second)
return length between two points (used in geometric calculations)
Definition: GNEGeometry.cpp:574
GUIVisualizationSettings::drawForPositionSelection
bool drawForPositionSelection
whether drawing is performed for the purpose of selecting objects with a single click
Definition: GUIVisualizationSettings.h:895
GNEGeometry::drawDottedContourShape
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)
Definition: GNEGeometry.cpp:891
GLO_DOTTEDCONTOUR_INSPECTED
@ GLO_DOTTEDCONTOUR_INSPECTED
dotted contour inspected element (used in NETEDIT)
Definition: GUIGlObjectTypes.h:228
GNEGeometry::getVertexCircleAroundPosition
static PositionVector getVertexCircleAroundPosition(const Position &pos, const double width, const int steps=8)
get a circle around the given position
Definition: GNEGeometry.cpp:1087
GUIVisualizationAdditionalSettings::arrowLength
static const double arrowLength
arrow length
Definition: GUIVisualizationSettings.h:355
GNEGeometry::DottedGeometry::moveShapeToSide
void moveShapeToSide(const double value)
move shape to side
Definition: GNEGeometry.cpp:453
GNEGeometry::angleLookup
static int angleLookup(const double angleDeg)
normalize angle for lookup in myCircleCoords
Definition: GNEGeometry.cpp:1117
RGBColor::BLACK
static const RGBColor BLACK
Definition: RGBColor.h:190
GUIVisualizationSettings::drawForRectangleSelection
bool drawForRectangleSelection
whether drawing is performed for the purpose of selecting objects using a rectangle
Definition: GUIVisualizationSettings.h:898
GNEGeometry::DottedGeometry::calculateShapeRotationsAndLengths
void calculateShapeRotationsAndLengths()
calculate shape rotations and lengths
Definition: GNEGeometry.cpp:483
Position::INVALID
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:293
OptionsCont.h
GLHelper::drawBoxLines
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.
Definition: GLHelper.cpp:277
GNEGeometry::drawParentLine
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)
Definition: GNEGeometry.cpp:966
PositionVector::rotate2D
void rotate2D(double angle)
Definition: PositionVector.cpp:1512
GNEGeometry::Geometry::getShapeRotations
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
Definition: GNEGeometry.cpp:205
GNEGeometry::DottedGeometry::Segment::Segment
Segment()
default constructor
Definition: GNEGeometry.cpp:313
GNEGeometry::Lane2laneConnection::updateLane2laneConnection
void updateLane2laneConnection()
update
Definition: GNEGeometry.cpp:512
GNEGeometry::DottedGeometryColor
class for pack all variables related with DottedGeometry color
Definition: GNEGeometry.h:125
NBNode::computeSmoothShape
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.
Definition: NBNode.cpp:514
GNEGeometry::drawDottedContourEdge
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)
Definition: GNEGeometry.cpp:809
CIRCLE_RESOLUTION
#define CIRCLE_RESOLUTION
Definition: GNEGeometry.cpp:29
GUIVisualizationDottedContourSettings::segmentLength
static const double segmentLength
length of dotted contour segments
Definition: GUIVisualizationSettings.h:432
PositionVector::scaleRelative
void scaleRelative(double factor)
enlarges/shrinks the polygon by a factor based at the centroid
Definition: PositionVector.cpp:464
OptionsCont::getBool
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
Definition: OptionsCont.cpp:230
OptionsCont::getOptions
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
GNEViewNet
Definition: GNEViewNet.h:41
GNEGeometry::DottedGeometryColor::changeColor
void changeColor()
change color
Definition: GNEGeometry.cpp:294
GNEGeometry::drawGeometryPoints
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
Definition: GNEGeometry.cpp:665
RAD2DEG
#define RAD2DEG(x)
Definition: GeomHelper.h:36
PositionVector::length
double length() const
Returns the length.
Definition: PositionVector.cpp:492
GLHelper.h
GNEGeometry::DottedGeometryColor::getColor
const RGBColor getColor(DottedContourType type)
get inspected color (and change flag)
Definition: GNEGeometry.cpp:254
GNEGeometry::DottedGeometryColor::DottedGeometryColor
DottedGeometryColor(const GUIVisualizationSettings &settings)
constructor
Definition: GNEGeometry.cpp:248
PositionVector
A list of positions.
Definition: PositionVector.h:43
GLHelper::setColor
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:507
GNEGeometry::DottedGeometry::invertOffset
void invertOffset()
invert offset of all segments
Definition: GNEGeometry.cpp:474
GNEGeometry::Geometry::updateGeometry
void updateGeometry(const PositionVector &shape)
update entire geometry
Definition: GNEGeometry.cpp:64
GUIVisualizationDetailSettings::geometryPointsText
static const double geometryPointsText
details for Geometry Points Texts
Definition: GUIVisualizationSettings.h:496
NBEdge
The representation of a single edge during network building.
Definition: NBEdge.h:91
GLHelper::pushMatrix
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:114
GNEGeometry::Geometry
class for NETEDIT geometries over lanes
Definition: GNEGeometry.h:56
GNEEdge
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:50
PositionVector::add
void add(double xoff, double yoff, double zoff)
Definition: PositionVector.cpp:625
GLHelper::drawFilledCircle
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:431
PositionVector::nearest_offset_to_point2D
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
Definition: PositionVector.cpp:825
RGBColor
Definition: RGBColor.h:38
NBEdge::getToNode
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:533
RGBColor::MAGENTA
static const RGBColor MAGENTA
Definition: RGBColor.h:187
GUIVisualizationSettings::detailSettings
GUIVisualizationDetailSettings detailSettings
detail settings
Definition: GUIVisualizationSettings.h:961
GNEGeometry::DottedContourType::FRONT
@ FRONT
GNELane::getLaneShape
const PositionVector & getLaneShape() const
get elements shape
Definition: GNELane.cpp:129
GNEGeometry::drawLaneGeometry
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)
Definition: GNEGeometry.cpp:764
GNEGeometry::DottedContourType::MAGENTA
@ MAGENTA
GNEGeometry::DottedContourType
DottedContourType
Definition: GNEGeometry.h:116
GNEViewNet::getNetworkViewOptions
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
Definition: GNEViewNet.cpp:515
GUIVisualizationAdditionalSettings::arrowWidth
static const double arrowWidth
arrow width
Definition: GUIVisualizationSettings.h:352
PositionVector::closePolygon
void closePolygon()
ensures that the last position equals the first
Definition: PositionVector.cpp:1240
GNEViewNet.h
GLHelper::drawText
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)
Definition: GLHelper.cpp:603
PositionVector::positionAtOffset
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
Definition: PositionVector.cpp:247
PositionVector::rotationDegreeAtOffset
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
Definition: PositionVector.cpp:318
GNEGeometry::DottedGeometry
class for pack all variables related with DottedGeometry
Definition: GNEGeometry.h:152
NBEdge::getNumLanes
int getNumLanes() const
Returns the number of lanes.
Definition: NBEdge.h:507
GNEGeometry::drawGeometry
static void drawGeometry(const GNEViewNet *viewNet, const Geometry &geometry, const double width)
draw geometry
Definition: GNEGeometry.cpp:610
GUIVisualizationSettings::additionalSettings
GUIVisualizationAdditionalSettings additionalSettings
Additional settings.
Definition: GUIVisualizationSettings.h:946
GUIVisualizationSettings::scale
double scale
information about a lane's width (temporary, used for a single view)
Definition: GUIVisualizationSettings.h:883
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
Position::x
double x() const
Returns the x-position.
Definition: Position.h:55
PositionVector::append
void append(const PositionVector &v, double sameThreshold=2.0)
Definition: PositionVector.cpp:704
GNEGeometry::rotateOverLane
static void rotateOverLane(const double rot)
rotate over lane (used by Lock icons, detector logos, etc.)
Definition: GNEGeometry.cpp:1110
GLHelper::drawLine
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
Definition: GLHelper.cpp:369
GNEViewNetHelper::NetworkViewOptions::editingElevation
bool editingElevation() const
check if we're editing elevation
Definition: GNEViewNetHelper.cpp:2204
GNELane::LaneDrawingConstants::halfWidth
const double halfWidth
Draw as a normal lane, and reduce width to make sure that a selected edge can still be seen.
Definition: GNELane.h:67
GUIVisualizationSettings::dottedContourSettings
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
Definition: GUIVisualizationSettings.h:955
GNEGeometry::DottedGeometry::setWidth
void setWidth(const double width)
change default width
Definition: GNEGeometry.cpp:468
GNEGeometry::Geometry::scaleGeometry
void scaleGeometry(const double scale)
scale geometry
Definition: GNEGeometry.cpp:188
PositionVector::length2D
double length2D() const
Returns the length.
Definition: PositionVector.cpp:505
GUISUMOAbstractView::getPositionInformation
Position getPositionInformation() const
Returns the cursor's x/y position within the network.
Definition: GUISUMOAbstractView.cpp:190
GNEEdge::getLanes
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition: GNEEdge.cpp:777
GNEGeometry::Lane2laneConnection::exist
bool exist(const GNELane *toLane) const
check if exist a lane2lane geometry for the given tolane
Definition: GNEGeometry.cpp:547
GNEGeometry::Geometry::clearGeometry
void clearGeometry()
clear geometry
Definition: GNEGeometry.cpp:216
GNEGeometry::Geometry::getShapeLengths
const std::vector< double > & getShapeLengths() const
The lengths of the single shape parts.
Definition: GNEGeometry.cpp:211
DEG2RAD
#define DEG2RAD(x)
Definition: GeomHelper.h:35
GNEGeometry::drawChildLine
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)
Definition: GNEGeometry.cpp:1025
Position::distanceSquaredTo2D
double distanceSquaredTo2D(const Position &p2) const
returns the square of the distance to another position (Only using x and y positions)
Definition: Position.h:257
PositionVector::distance2D
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)
Definition: PositionVector.cpp:1268
GUIVisualizationSettings::getCircleResolution
int getCircleResolution() const
function to calculate circle resolution for all circles drawn in drawGL(...) functions
Definition: GUIVisualizationSettings.cpp:2067
GNEGeometry::DottedContourType::GREEN
@ GREEN
Position::angleTo2D
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position
Definition: Position.h:262
GNELane::LaneDrawingConstants
FOX-declaration.
Definition: GNELane.h:51
Position::distanceTo2D
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:252
GNEGeometry::DottedGeometry::updateDottedGeometry
void updateDottedGeometry(const GUIVisualizationSettings &s, const GNELane *lane)
update DottedGeometry (using lane shape)
Definition: GNEGeometry.cpp:392
GNEGeometry::DottedGeometry::myWidth
double myWidth
geometry width
Definition: GNEGeometry.h:213
GLIncludes.h
NBEdge::getLaneShape
const PositionVector & getLaneShape(int i) const
Returns the shape of the nth lane.
Definition: NBEdge.cpp:913
GNEGeometry::DottedContourType::INSPECT
@ INSPECT
GNEGeometry::Lane2laneConnection::getLane2laneGeometry
const GNEGeometry::Geometry & getLane2laneGeometry(const GNELane *toLane) const
get lane2lane geometry
Definition: GNEGeometry.cpp:553
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
NBNode::getShape
const PositionVector & getShape() const
retrieve the junction shape
Definition: NBNode.cpp:2380
GNEGeometry.h
GNEGeometry::drawMovingHint
static void drawMovingHint(const GUIVisualizationSettings &s, const GNEViewNet *viewNet, const PositionVector &shape, const RGBColor &hintColor, const double radius, const double exaggeration)
draw moving hint
Definition: GNEGeometry.cpp:721
Position::y
double y() const
Returns the y-position.
Definition: Position.h:60
PositionVector::positionAtOffset2D
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
Definition: PositionVector.cpp:272
M_PI
#define M_PI
Definition: odrSpiral.cpp:40
PositionVector::reverse
PositionVector reverse() const
reverse position vector
Definition: PositionVector.cpp:1095
GNEGeometry::DottedGeometry::drawDottedGeometry
void drawDottedGeometry(DottedGeometryColor &dottedGeometryColor, GNEGeometry::DottedContourType type, const double customWidth=-1) const
draw inspected dottedShape
Definition: GNEGeometry.cpp:436
GLHelper::drawBoxLine
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition: GLHelper.cpp:231
GNEGeometry::drawDottedContourClosedShape
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)
Definition: GNEGeometry.cpp:861
MAXIMUM_DOTTEDGEOMETRYLENGTH
#define MAXIMUM_DOTTEDGEOMETRYLENGTH
Definition: GNEGeometry.cpp:30
GNEGeometry::DottedGeometry::getWidth
double getWidth() const
get width
Definition: GNEGeometry.cpp:462
GNEGeometry::DottedGeometry::Segment
dotted geometry segment
Definition: GNEGeometry.h:156
GLHelper::popMatrix
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:123
GNEGeometry::Geometry::Geometry
Geometry()
default constructor
Definition: GNEGeometry.cpp:45
GNEGeometry::myCircleCoords
static PositionVector myCircleCoords
Storage for precomputed sin/cos-values describing a circle.
Definition: GNEGeometry.h:316
GUISUMOAbstractView::getVisualisationSettings
GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings
Definition: GUISUMOAbstractView.cpp:1424
GUIVisualizationDottedContourSettings::segmentWidth
static const double segmentWidth
width of dotted contour segments
Definition: GUIVisualizationSettings.h:429
GUIVisualizationAdditionalSettings::arrowOffset
static const double arrowOffset
arrow offset
Definition: GUIVisualizationSettings.h:358
GLO_DOTTEDCONTOUR_FRONT
@ GLO_DOTTEDCONTOUR_FRONT
dotted contour front element (used in NETEDIT)
Definition: GUIGlObjectTypes.h:225
GNEGeometry::DottedGeometry::DottedGeometry
DottedGeometry()
constructor
Definition: GNEGeometry.cpp:324
GeomHelper.h
GNEGeometry::DottedGeometryColor::reset
void reset()
rest Dotted Geometry Color
Definition: GNEGeometry.cpp:304
GNEViewNet::getEditModes
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:503
GNEGeometry::drawContourGeometry
static void drawContourGeometry(const Geometry &geometry, const double width, const bool drawExtremes=false)
draw contour geometry
Definition: GNEGeometry.cpp:638
GNEGeometry::adjustStartPosGeometricPath
static void adjustStartPosGeometricPath(double &startPos, const GNELane *startLane, double &endPos, const GNELane *endLane)
adjust start and end positions in geometric path
Definition: GNEGeometry.cpp:581
GNEGeometry::DottedGeometry::myDottedGeometrySegments
std::vector< DottedGeometry::Segment > myDottedGeometrySegments
dotted element shape (note: It's centered in 0,0 due scaling)
Definition: GNEGeometry.h:216
RGBColor::GREEN
static const RGBColor GREEN
Definition: RGBColor.h:183
GNEGeometry::calculateRotation
static double calculateRotation(const Position &first, const Position &second)
return angle between two points (used in geometric calculations)
Definition: GNEGeometry.cpp:567
GUIVisualizationSettings::drawDetail
bool drawDetail(const double detail, const double exaggeration) const
check if details can be drawn for the given GUIVisualizationDetailSettings and current scale and exxa...
Definition: GUIVisualizationSettings.cpp:2057
GNEGeometry::Lane2laneConnection::Lane2laneConnection
Lane2laneConnection()
constructor
Definition: GNEGeometry.cpp:558
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:546
GNEGeometry::drawDottedSquaredShape
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)
Definition: GNEGeometry.cpp:945
RGBColor::changedBrightness
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:197
PositionVector::area
double area() const
Returns the area (0 for non-closed)
Definition: PositionVector.cpp:518
GNEViewNetHelper::EditModes::networkEditMode
NetworkEditMode networkEditMode
the current Network edit mode
Definition: GNEViewNetHelper.h:492
POSITION_EPS
#define POSITION_EPS
Definition: config.h:172
GNEGeometry::Geometry::updateSinglePosGeometry
void updateSinglePosGeometry(const Position &position, const double rotation)
update position and rotation
Definition: GNEGeometry.cpp:178
GNELane
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:45
GNEGeometry::Geometry::getShape
const PositionVector & getShape() const
The shape of the additional element.
Definition: GNEGeometry.cpp:199
GNEGeometry::drawDottedContourCircle
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)
Definition: GNEGeometry.cpp:934
GNEGeometry::Geometry::calculateShapeRotationsAndLengths
void calculateShapeRotationsAndLengths()
calculate shape rotations and lengths
Definition: GNEGeometry.cpp:225
GNENet.h
PositionVector::move2side
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
Definition: PositionVector.cpp:1112
GLHelper::drawTriangleAtEnd
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.
Definition: GLHelper.cpp:485
NetworkEditMode::NETWORK_MOVE
@ NETWORK_MOVE
mode for moving network elements
NBEdge::getTurnDestination
NBEdge * getTurnDestination(bool possibleDestination=false) const
Definition: NBEdge.cpp:3457