Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEPoly.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2023 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// A class for visualizing and editing POIS in netedit (adapted from
19// GUIPolygon and NLHandler)
20/****************************************************************************/
21#include <config.h>
22
23#include <string>
26#include <netedit/GNENet.h>
27#include <netedit/GNEUndoList.h>
28#include <netedit/GNEViewNet.h>
35
36#include "GNEPoly.h"
37
38
39// ===========================================================================
40// method definitions
41// ===========================================================================
42
44 TesselatedPolygon("", "", RGBColor::BLACK, {}, false, false, 0, 0, 0, "", false, "", Parameterised::Map()),
45 GNEAdditional("", net, GLO_POLYGON, SUMO_TAG_POLY, GUIIconSubSys::getIcon(GUIIcon::POLY), "", {}, {}, {}, {}, {}, {}),
46mySimplifiedShape(false) {
47 // reset default values
49}
50
51
52GNEPoly::GNEPoly(GNENet* net, const std::string& id, const std::string& type, const PositionVector& shape, bool geo, bool fill, double lineWidth,
53 const RGBColor& color, double layer, double angle, const std::string& imgFile, bool relativePath, const std::string& name,
54 const Parameterised::Map& parameters) :
55 TesselatedPolygon(id, type, color, shape, geo, fill, lineWidth, layer, angle, imgFile, relativePath, name, parameters),
56 GNEAdditional(id, net, GLO_POLYGON, SUMO_TAG_POLY, GUIIconSubSys::getIcon(GUIIcon::POLY), "", {}, {}, {}, {}, {}, {}),
57mySimplifiedShape(false) {
58 // check if imgFile is valid
59 if (!imgFile.empty() && GUITexturesHelper::getTextureID(imgFile) == -1) {
61 }
62 // set GEO shape
64 if (geo) {
65 for (int i = 0; i < (int) myGeoShape.size(); i++) {
67 }
68 } else {
69 for (int i = 0; i < (int) myGeoShape.size(); i++) {
71 }
72 }
73 // update centering boundary without updating grid
75 // update geometry
77}
78
79
81
82
85 // edit depending if shape is blocked
87 // move entire shape
88 return new GNEMoveOperation(this, myShape);
89 } else {
90 // calculate move shape operation
93 }
94}
95
96
97void
98GNEPoly::removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList) {
99 // get original shape
100 PositionVector shape = myShape;
101 // check shape size
102 if (shape.size() > 2) {
103 // obtain index
104 int index = shape.indexOfClosest(clickedPosition);
105 // get snap radius
107 // check if we have to create a new index
108 if ((index != -1) && shape[index].distanceSquaredTo2D(clickedPosition) < (snap_radius * snap_radius)) {
109 // remove geometry point
110 shape.erase(shape.begin() + index);
111 // commit new shape
112 undoList->begin(GUIIcon::POLY, "remove geometry point of " + getTagStr());
113 undoList->changeAttribute(new GNEChange_Attribute(this, SUMO_ATTR_SHAPE, toString(shape)));
114 undoList->end();
115 }
116 }
117}
118
119
120std::string
122 return "";
123}
124
125
126void
128 // just update geometry
130 myTesselation.clear();
131}
132
133
138
139
140double
142 return s.polySize.getExaggeration(s, this);
143}
144
145
146void
147GNEPoly::updateCenteringBoundary(const bool updateGrid) {
148 // Remove object from net
149 if (updateGrid) {
151 }
152 // use shape as boundary
154 // grow boundary
156 // add object into net
157 if (updateGrid) {
159 }
160}
161
162
163void
164GNEPoly::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
165 // nothing to split
166}
167
168
169void
171 writeXML(device, myGEO);
172}
173
174
175bool
177 return true;
178}
179
180
181std::string
183 return "";
184}
185
186
187void
189 // nothing to fix
190}
191
192
195 return GUIGlObject::getGlID();
196}
197
198
199std::string
201 return myNet->getMicrosimID();
202}
203
204
207 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
208 buildPopupHeader(ret, app);
211 // build selection and show parameters menu
214 FXMenuCommand* simplifyShape = GUIDesigns::buildFXMenuCommand(ret, TL("Simplify Shape") + std::string("\t\t") + TL("Replace current shape with a rectangle"), nullptr, &parent, MID_GNE_POLYGON_SIMPLIFY_SHAPE);
215 // disable simplify shape if polygon was already simplified
216 if (mySimplifiedShape || myShape.size() <= 2) {
217 simplifyShape->disable();
218 }
219 if (myShape.isClosed()) {
220 GUIDesigns::buildFXMenuCommand(ret, TL("Open shape") + std::string("\t\t") + TL("Open polygon's shape"), nullptr, &parent, MID_GNE_POLYGON_OPEN);
221 } else {
222 GUIDesigns::buildFXMenuCommand(ret, TL("Close shape") + std::string("\t\t") + TL("Close polygon's shape"), nullptr, &parent, MID_GNE_POLYGON_CLOSE);
223 }
224 GUIDesigns::buildFXMenuCommand(ret, TL("Select elements within polygon") + std::string("\t\t") + TL("Select elements within polygon boundary"), nullptr, &parent, MID_GNE_POLYGON_SELECT);
225 // add separator
226 new FXMenuSeparator(ret);
227 // create a extra FXMenuCommand if mouse is over a vertex
228 const int index = getVertexIndex(myNet->getViewNet()->getPositionInformation(), false);
229 if (index != -1) {
230 // check if we're in network mode
232 GUIDesigns::buildFXMenuCommand(ret, "Set custom Geometry Point", nullptr, &parent, MID_GNE_CUSTOM_GEOMETRYPOINT);
233 }
234 FXMenuCommand* removeGeometryPoint = GUIDesigns::buildFXMenuCommand(ret, TL("Remove geometry point") + std::string("\t\t") + TL("Remove geometry point under mouse"), nullptr, &parent, MID_GNE_POLYGON_DELETE_GEOMETRY_POINT);
235 FXMenuCommand* setFirstPoint = GUIDesigns::buildFXMenuCommand(ret, TL("Set first geometry point") + std::string("\t\t") + TL("Set first geometry point"), nullptr, &parent, MID_GNE_POLYGON_SET_FIRST_POINT);
236 // disable setFirstPoint if shape only have three points
237 if ((myShape.isClosed() && (myShape.size() <= 4)) || (!myShape.isClosed() && (myShape.size() <= 2))) {
238 removeGeometryPoint->disable();
239 }
240 // disable setFirstPoint if mouse is over first point
241 if (index == 0) {
242 setFirstPoint->disable();
243 }
244 }
245 return ret;
246}
247
248
249void
251 // check if boundary has to be drawn
252 if (s.drawBoundaries) {
254 }
255 // first check if poly can be drawn
258 GUIPolygon::checkDraw(s, this, this)) {
259 // check if draw start und end
260 const bool drawExtremeSymbols = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
262 // Obtain constants
263 const double polyExaggeration = getExaggeration(s);
264 const Position mousePosition = myNet->getViewNet()->getPositionInformation();
265 // get colors
267 const RGBColor invertedColor = color.invertedColor();
268 const RGBColor darkerColor = color.changedBrightness(-32);
269 // avoid draw invisible elements
270 if (color.alpha() != 0) {
271 // push name (needed for getGUIGlObjectsUnderCursor(...)
273 // push layer matrix
275 // translate to front
277 // check if we're drawing a polygon or a polyline
278 if (getFill()) {
280 // check if mouse is within geometry
281 if (myPolygonGeometry.getShape().around(mousePosition)) {
282 // push matrix
284 // move to mouse position
285 glTranslated(mousePosition.x(), mousePosition.y(), 0);
286 // set color
287 GLHelper::setColor(color);
288 // draw circle
290 // pop matrix
292 }
293 } else {
294 // draw inner polygon
296 }
297 } else {
298 // push matrix
300 // set color
301 GLHelper::setColor(color);
302 // draw geometry (polyline)
304 // pop matrix
306 }
307 }
308 // draw contour if shape isn't blocked
310 // push contour matrix
312 // translate to front
313 glTranslated(0, 0, 0.1);
314 // set color
315 GLHelper::setColor(darkerColor);
316 // draw polygon contour
318 // pop contour matrix
320 // draw shape points only in Network supemode
322 // check move mode flag
324 // draw geometry points
326 s.neteditSizeSettings.polygonGeometryPointRadius * (moveMode ? 1 : 0.5), polyExaggeration,
327 myNet->getViewNet()->getNetworkViewOptions().editingElevation(), drawExtremeSymbols);
328 // draw moving hint points
332 }
333 }
334 }
335 // check if mouse is over element
338 } else {
340 }
341 // inspect contour
343 // draw depending if is closed
346 } else {
348 polyExaggeration, true, true);
349 }
350 }
351 // dotted contour
352 if (myNet->getViewNet()->getFrontAttributeCarrier() == this) {
353 // draw depending if is closed
356 } else {
358 polyExaggeration, true, true);
359 }
360 }
361 // delete contour
362 if (myNet->getViewNet()->drawDeleteContour(this, this)) {
363 // draw depending if is closed
366 } else {
368 polyExaggeration, true, true);
369 }
370 }
371 // select contour
372 if (myNet->getViewNet()->drawSelectContour(this, this)) {
373 // draw depending if is closed
376 } else {
378 polyExaggeration, true, true);
379 }
380 }
381 // draw lock icon
383 // pop layer matrix
385 // pop name
387 // get name position
389 // draw name
390 drawName(namePos, s.scale, s.polyName, s.angle);
391 // check if draw poly type
392 if (s.polyType.show(this)) {
393 const Position p = namePos + Position(0, -0.6 * s.polyType.size / s.scale);
395 }
396 }
397}
398
399
400int
401GNEPoly::getVertexIndex(Position pos, bool snapToGrid) {
402 // check if position has to be snapped to grid
403 if (snapToGrid) {
404 pos = myNet->getViewNet()->snapToActiveGrid(pos);
405 }
406 // first check if vertex already exists
407 for (const auto& shapePosition : myShape) {
408 if (shapePosition.distanceTo2D(pos) < myNet->getViewNet()->getVisualisationSettings().neteditSizeSettings.polygonGeometryPointRadius) {
409 return myShape.indexOfClosest(shapePosition);
410 }
411 }
412 return -1;
413}
414
415
416void
417GNEPoly::deleteGeometryPoint(const Position& pos, bool allowUndo) {
418 if (myShape.size() > 1) {
419 // obtain index
420 PositionVector modifiedShape = myShape;
421 int index = modifiedShape.indexOfClosest(pos);
422 // remove point dependending of
423 if (myShape.isClosed() && (index == 0 || index == (int)modifiedShape.size() - 1) && (myShape.size() > 2)) {
424 modifiedShape.erase(modifiedShape.begin());
425 modifiedShape.erase(modifiedShape.end() - 1);
426 modifiedShape.push_back(modifiedShape.front());
427 } else {
428 modifiedShape.erase(modifiedShape.begin() + index);
429 }
430 // set new shape depending of allowUndo
431 if (allowUndo) {
432 myNet->getViewNet()->getUndoList()->begin(GUIIcon::POLY, "delete geometry point");
435 } else {
436 // first remove object from grid due shape is used for boundary
438 // set new shape
439 myShape = modifiedShape;
440 // disable simplified shape flag
441 mySimplifiedShape = false;
442 // add object into grid again
444 }
445 myTesselation.clear();
446 } else {
447 WRITE_WARNING(TL("Number of remaining points insufficient"))
448 }
449}
450
451
452bool
454 return myShape.isClosed();
455}
456
457
458void
459GNEPoly::openPolygon(bool allowUndo) {
460 // only open if shape is closed
461 if (myShape.isClosed()) {
462 if (allowUndo) {
463 myNet->getViewNet()->getUndoList()->begin(GUIIcon::POLY, "open polygon");
466 } else {
467 myShape.pop_back();
468 // disable simplified shape flag
469 mySimplifiedShape = false;
470 // update geometry to avoid grabbing Problems
472 }
473 } else {
474 WRITE_WARNING(TL("Polygon already opened"))
475 }
476}
477
478
479void
480GNEPoly::closePolygon(bool allowUndo) {
481 // only close if shape is opened
482 if (myShape.isClosed() == false) {
483 if (allowUndo) {
484 myNet->getViewNet()->getUndoList()->begin(GUIIcon::POLY, "close shape");
487 } else {
489 // disable simplified shape flag
490 mySimplifiedShape = false;
491 // update geometry to avoid grabbing Problems
493 }
494 } else {
495 WRITE_WARNING(TL("Polygon already closed"))
496 }
497}
498
499
500void
501GNEPoly::changeFirstGeometryPoint(int oldIndex, bool allowUndo) {
502 // check that old index is correct
503 if (oldIndex >= (int)myShape.size()) {
504 throw InvalidArgument("Invalid old Index");
505 } else if (oldIndex == 0) {
506 WRITE_WARNING(TL("Selected point must be different of the first point"))
507 } else {
508 // Configure new shape
509 PositionVector newShape;
510 for (int i = oldIndex; i < (int)myShape.size(); i++) {
511 newShape.push_back(myShape[i]);
512 }
513 if (myShape.isClosed()) {
514 for (int i = 1; i < oldIndex; i++) {
515 newShape.push_back(myShape[i]);
516 }
517 newShape.push_back(newShape.front());
518 } else {
519 for (int i = 0; i < oldIndex; i++) {
520 newShape.push_back(myShape[i]);
521 }
522 }
523 // set new rotated shape
524 if (allowUndo) {
525 myNet->getViewNet()->getUndoList()->begin(GUIIcon::POLY, "change first geometry point");
528 } else {
529 // set new shape
530 myShape = newShape;
531 // disable simplified shape flag
532 mySimplifiedShape = false;
533 // update geometry to avoid grabbing Problems
535 }
536 }
537}
538
539
540void
541GNEPoly::simplifyShape(bool allowUndo) {
542 if (!mySimplifiedShape && myShape.size() > 2) {
543 const Boundary b = myShape.getBoxBoundary();
544 PositionVector simplifiedShape;
545 if (myShape.isClosed()) {
546 // create a square as simplified shape
547 simplifiedShape.push_back(Position(b.xmin(), b.ymin()));
548 simplifiedShape.push_back(Position(b.xmin(), b.ymax()));
549 simplifiedShape.push_back(Position(b.xmax(), b.ymax()));
550 simplifiedShape.push_back(Position(b.xmax(), b.ymin()));
551 simplifiedShape.push_back(simplifiedShape[0]);
552 } else {
553 // create a line as simplified shape
554 simplifiedShape.push_back(myShape.front());
555 simplifiedShape.push_back(myShape.back());
556 }
557 // set new shape depending of allowUndo
558 if (allowUndo) {
559 myNet->getViewNet()->getUndoList()->begin(GUIIcon::POLY, "simplify shape");
562 } else {
563 // set new shape
564 myShape = simplifiedShape;
565 // update geometry to avoid grabbing Problems
567 }
568 // change flag after setting simplified shape
569 mySimplifiedShape = true;
570 } else {
571 WRITE_WARNING(TL("Polygon already simplified"))
572 }
573}
574
575
576std::string
578 switch (key) {
579 case SUMO_ATTR_ID:
580 return myID;
581 case SUMO_ATTR_SHAPE:
582 return toString(myShape);
585 case SUMO_ATTR_COLOR:
586 return toString(getShapeColor());
587 case SUMO_ATTR_FILL:
588 return toString(myFill);
590 return toString(myLineWidth);
591 case SUMO_ATTR_LAYER:
593 return "default";
594 } else {
595 return toString(getShapeLayer());
596 }
597 case SUMO_ATTR_TYPE:
598 return getShapeType();
600 return getShapeImgFile();
603 case SUMO_ATTR_ANGLE:
605 case SUMO_ATTR_GEO:
606 return toString(myGEO);
607 case SUMO_ATTR_NAME:
608 return getShapeName();
610 return toString(myShape.isClosed());
615 default:
616 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
617 }
618}
619
620
621double
623 throw InvalidArgument(getTagStr() + " attribute '" + toString(key) + "' not allowed");
624}
625
626
631
632
633void
634GNEPoly::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
635 if (value == getAttribute(key)) {
636 return; //avoid needless changes, later logic relies on the fact that attributes have changed
637 }
638 switch (key) {
639 case SUMO_ATTR_ID:
640 case SUMO_ATTR_SHAPE:
642 case SUMO_ATTR_COLOR:
643 case SUMO_ATTR_FILL:
645 case SUMO_ATTR_LAYER:
646 case SUMO_ATTR_TYPE:
649 case SUMO_ATTR_ANGLE:
650 case SUMO_ATTR_GEO:
651 case SUMO_ATTR_NAME:
655 undoList->changeAttribute(new GNEChange_Attribute(this, key, value));
656 break;
657 default:
658 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
659 }
660}
661
662
663bool
664GNEPoly::isValid(SumoXMLAttr key, const std::string& value) {
665 switch (key) {
666 case SUMO_ATTR_ID:
668 (myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_TAZ, value, false) == nullptr) &&
669 (myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_POLY, value, false) == nullptr);
670 case SUMO_ATTR_SHAPE:
672 // empty shapes AREN'T allowed
673 if (value.empty()) {
674 return false;
675 } else {
676 return canParse<PositionVector>(value);
677 }
678 case SUMO_ATTR_COLOR:
679 return canParse<RGBColor>(value);
680 case SUMO_ATTR_FILL:
681 return canParse<bool>(value);
683 return canParse<double>(value) && (parse<double>(value) >= 0);
684 case SUMO_ATTR_LAYER:
685 if (value == "default") {
686 return true;
687 } else {
688 return canParse<double>(value);
689 }
690 case SUMO_ATTR_TYPE:
691 return true;
693 if (value == "") {
694 return true;
695 } else {
696 // check that image can be loaded
697 return GUITexturesHelper::getTextureID(value) != -1;
698 }
700 return canParse<bool>(value);
701 case SUMO_ATTR_ANGLE:
702 return canParse<double>(value);
703 case SUMO_ATTR_GEO:
704 return canParse<bool>(value);
705 case SUMO_ATTR_NAME:
708 if (canParse<bool>(value)) {
709 bool closePolygon = parse<bool>(value);
710 if (closePolygon && (myShape.begin() == myShape.end())) {
711 // Polygon already closed, then invalid value
712 return false;
713 } else if (!closePolygon && (myShape.begin() != myShape.end())) {
714 // Polygon already open, then invalid value
715 return false;
716 } else {
717 return true;
718 }
719 } else {
720 return false;
721 }
723 return canParse<bool>(value);
725 return areParametersValid(value);
726 default:
727 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
728 }
729}
730
731
732bool
734 // check if we're in supermode Network
736 return true;
737 } else {
738 return false;
739 }
740}
741
742
743std::string
745 return getTagStr() + ": " + getID();
746}
747
748
749std::string
751 return getTagStr();
752}
753
754// ===========================================================================
755// private
756// ===========================================================================
757
758void
759GNEPoly::setAttribute(SumoXMLAttr key, const std::string& value) {
760 switch (key) {
761 case SUMO_ATTR_ID: {
762 // update microsimID
763 setMicrosimID(value);
764 // set named ID
765 myID = value;
766 break;
767 }
768 case SUMO_ATTR_SHAPE: {
769 // set new shape
770 myShape = parse<PositionVector>(value);
771 // set GEO shape
773 for (int i = 0; i < (int) myGeoShape.size(); i++) {
775 }
776 // disable simplified shape flag
777 mySimplifiedShape = false;
778 // update geometry
780 // update centering boundary
782 break;
783 }
784 case SUMO_ATTR_GEOSHAPE: {
785 // set new GEO shape
786 myGeoShape = parse<PositionVector>(value);
787 // set shape
789 for (int i = 0; i < (int) myShape.size(); i++) {
791 }
792 // disable simplified shape flag
793 mySimplifiedShape = false;
794 // update geometry
796 // update centering boundary
798 break;
799 }
800 case SUMO_ATTR_COLOR:
801 setShapeColor(parse<RGBColor>(value));
802 break;
803 case SUMO_ATTR_FILL:
804 myFill = parse<bool>(value);
805 break;
807 myLineWidth = parse<double>(value);
808 break;
809 case SUMO_ATTR_LAYER:
810 if (value == "default") {
812 } else {
813 setShapeLayer(parse<double>(value));
814 }
815 break;
816 case SUMO_ATTR_TYPE:
817 setShapeType(value);
818 break;
820 setShapeImgFile(value);
821 // all textures must be refresh
823 break;
825 setShapeRelativePath(parse<bool>(value));
826 break;
827 case SUMO_ATTR_ANGLE:
828 setShapeNaviDegree(parse<double>(value));
829 break;
830 case SUMO_ATTR_GEO:
831 myGEO = parse<bool>(value);
832 // update centering boundary
834 break;
835 case SUMO_ATTR_NAME:
836 setShapeName(value);
837 break;
839 if (parse<bool>(value)) {
842 } else {
843 myShape.pop_back();
844 myGeoShape.pop_back();
845 }
846 // disable simplified shape flag
847 mySimplifiedShape = false;
848 // update geometry
850 // update centering boundary
852 break;
854 if (parse<bool>(value)) {
856 } else {
858 }
859 break;
862 break;
863 default:
864 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
865 }
866}
867
868
869void
871 // update new shape
872 myShape = moveResult.shapeToUpdate;
873 // update geometry
875}
876
877
878void
880 // commit new shape
881 undoList->begin(GUIIcon::POLY, "moving " + toString(SUMO_ATTR_SHAPE) + " of " + getTagStr());
883 undoList->end();
884}
885
886/****************************************************************************/
@ NETWORK_MOVE
mode for moving network elements
@ MID_GNE_POLYGON_CLOSE
close opened polygon
@ MID_GNE_POLYGON_SET_FIRST_POINT
Set a vertex of polygon as first vertex.
@ MID_GNE_POLYGON_SELECT
select elements within polygon boundary
@ MID_GNE_CUSTOM_GEOMETRYPOINT
set custom geometry point
Definition GUIAppEnum.h:991
@ MID_GNE_POLYGON_DELETE_GEOMETRY_POINT
delete geometry point
@ MID_GNE_POLYGON_OPEN
open closed polygon
@ MID_GNE_POLYGON_SIMPLIFY_SHAPE
simplify polygon geometry
unsigned int GUIGlID
Definition GUIGlObject.h:43
@ GLO_POLYGON
a polygon
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
#define WRITE_WARNING(msg)
Definition MsgHandler.h:270
#define TL(string)
Definition MsgHandler.h:287
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_TAZ
a traffic assignment zone
@ SUMO_TAG_POLY
begin/end of the description of a polygon
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ GNE_ATTR_SELECTED
element is selected
@ SUMO_ATTR_LINEWIDTH
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
@ SUMO_ATTR_GEO
@ SUMO_ATTR_GEOSHAPE
@ GNE_ATTR_CLOSE_SHAPE
Close shape of a polygon (Used by GNEPolys)
@ SUMO_ATTR_SHAPE
edge: the shape in xml-definition
@ SUMO_ATTR_FILL
Fill the polygon.
@ SUMO_ATTR_NAME
@ SUMO_ATTR_LAYER
A layer number.
@ SUMO_ATTR_ANGLE
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_ID
@ SUMO_ATTR_IMGFILE
@ SUMO_ATTR_RELATIVEPATH
int gPrecisionGeo
Definition StdDefs.cpp:27
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
Position getCenter() const
Returns the center of the boundary.
Definition Boundary.cpp:112
double ymin() const
Returns minimum y-coordinate.
Definition Boundary.cpp:130
double xmin() const
Returns minimum x-coordinate.
Definition Boundary.cpp:118
Boundary & grow(double by)
extends the boundary by the given amount
Definition Boundary.cpp:300
double ymax() const
Returns maximum y-coordinate.
Definition Boundary.cpp:136
double xmax() const
Returns maximum x-coordinate.
Definition Boundary.cpp:124
static void drawBoundary(const Boundary &b)
Draw a boundary (used for debugging)
Definition GLHelper.cpp:897
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:583
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition GLHelper.cpp:498
static void pushName(unsigned int name)
push Name
Definition GLHelper.cpp:139
static void popMatrix()
pop matrix
Definition GLHelper.cpp:130
static void popName()
pop Name
Definition GLHelper.cpp:148
static void pushMatrix()
push matrix
Definition GLHelper.cpp:117
static void drawTextSettings(const GUIVisualizationTextSettings &settings, const std::string &text, const Position &pos, const double scale, const double angle=0, const double layer=2048, const int align=0)
Definition GLHelper.cpp:716
An Element which don't belong to GNENet but has influence in the simulation.
Boundary myAdditionalBoundary
Additional Boundary.
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
friend class GNEChange_Attribute
declare friend class
const std::string & getTagStr() const
get tag assigned to this object in string format
void unselectAttributeCarrier(const bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
void resetDefaultValues()
reset attribute carrier to their default values
GNENet * myNet
pointer to net
void selectAttributeCarrier(const bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
GNEMoveOperation * calculateMoveShapeOperation(const PositionVector originalShape, const Position mousePosition, const double snapRadius, const bool onlyContour)
calculate move shape operation
bool getMoveWholePolygons() const
move whole polygons
NetworkModeOptions * getNetworkModeOptions() const
get network mode options
move operation
move result
PositionVector shapeToUpdate
shape to update (edited in moveElement)
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
void addGLObjectIntoGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1248
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1260
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:120
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2030
bool mySimplifiedShape
flag to indicate if polygon is simplified
Definition GNEPoly.h:223
std::string getAdditionalProblem() const override
return a string with the current additional problem (must be reimplemented in all detector children)
Definition GNEPoly.cpp:182
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
Definition GNEPoly.cpp:744
std::string getParentName() const override
Returns the name of the parent object.
Definition GNEPoly.cpp:200
double getAttributeDouble(SumoXMLAttr key) const override
Definition GNEPoly.cpp:622
~GNEPoly()
Destructor.
Definition GNEPoly.cpp:80
bool isValid(SumoXMLAttr key, const std::string &value) override
method for checking if the key and their conrrespond attribute are valids
Definition GNEPoly.cpp:664
void updateGeometry() override
update pre-computed geometry information
Definition GNEPoly.cpp:127
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
Definition GNEPoly.cpp:750
void fixAdditionalProblem() override
fix additional problem (must be reimplemented in all detector children)
Definition GNEPoly.cpp:188
void writeAdditional(OutputDevice &device) const override
write additional element into a xml file
Definition GNEPoly.cpp:170
GNEMoveOperation * getMoveOperation() override
get move operation
Definition GNEPoly.cpp:84
int getVertexIndex(Position pos, bool snapToGrid)
return index of a vertex of shape, or of a new vertex if position is over an shape's edge
Definition GNEPoly.cpp:401
PositionVector myGeoShape
Latitude of Polygon.
Definition GNEPoly.h:220
GUIGeometry myPolygonGeometry
geometry for lengths/rotations
Definition GNEPoly.h:226
GNEPoly(GNENet *net)
default Constructor
Definition GNEPoly.cpp:43
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
Definition GNEPoly.cpp:141
void closePolygon(bool allowUndo=true)
close polygon
Definition GNEPoly.cpp:480
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point
Definition GNEPoly.cpp:501
std::string getAttribute(SumoXMLAttr key) const override
Definition GNEPoly.cpp:577
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList) override
commit move shape
Definition GNEPoly.cpp:879
bool isAdditionalValid() const override
check if current additional is valid to be writed into XML (must be reimplemented in all detector chi...
Definition GNEPoly.cpp:176
void setMoveShape(const GNEMoveResult &moveResult) override
set move shape
Definition GNEPoly.cpp:870
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
method for setting the attribute and letting the object perform additional changes
Definition GNEPoly.cpp:634
void deleteGeometryPoint(const Position &pos, bool allowUndo=true)
delete the geometry point closest to the given pos
Definition GNEPoly.cpp:417
Position getPositionInView() const override
Returns position of shape in view.
Definition GNEPoly.cpp:135
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList) override
remove geometry point in the clicked position
Definition GNEPoly.cpp:98
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GNEPoly.cpp:250
bool isAttributeEnabled(SumoXMLAttr key) const override
Definition GNEPoly.cpp:733
bool isPolygonClosed() const
check if polygon is closed
Definition GNEPoly.cpp:453
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GNEPoly.cpp:206
void simplifyShape(bool allowUndo=true)
replace the current shape with a rectangle
Definition GNEPoly.cpp:541
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList) override
split geometry
Definition GNEPoly.cpp:164
void updateCenteringBoundary(const bool updateGrid) override
update centering boundary (implies change in RTREE)
Definition GNEPoly.cpp:147
const Parameterised::Map & getACParametersMap() const override
get parameters map
Definition GNEPoly.cpp:628
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition GNEPoly.cpp:194
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition GNEPoly.cpp:121
void openPolygon(bool allowUndo=true)
open polygon
Definition GNEPoly.cpp:459
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
void changeAttribute(GNEChange_Attribute *change)
special method for change attributes, avoid empty changes, always execute
bool isObjectLocked(GUIGlObjectType objectType, const bool selected) const
check if given GLObject is locked for inspect, select, delete and move
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
const GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
bool drawSelectContour(const GUIGlObject *GLObject, const GNEAttributeCarrier *AC) const
check if draw select contour
bool drawDeleteContour(const GUIGlObject *GLObject, const GNEAttributeCarrier *AC) const
check if draw delete contour
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, double typeOrLayer, const double extraOffset=0)
draw front attributeCarrier
GNEViewParent * getViewParent() const
get the net object
GNEUndoList * getUndoList() const
get the undoList object
GNEViewNetHelper::LockManager & getLockManager()
get lock manager
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
bool isAttributeCarrierInspected(const GNEAttributeCarrier *AC) const
check if attribute carrier is being inspected
const GNEViewNetHelper::DemandViewOptions & getDemandViewOptions() const
get demand view options
GNEMoveFrame * getMoveFrame() const
get frame for move elements
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel)
build menu command
static void drawDottedContourClosedShape(const GUIVisualizationSettings &s, const DottedContourType type, const PositionVector &shape, const double exaggeration, const double customWidth=1)
draw dotted contour for the given closed shape (used by Juctions, shapes and TAZs)
static void drawDottedContourShape(const GUIVisualizationSettings &s, const DottedContourType type, const PositionVector &shape, const double width, const double exaggeration, const bool drawFirstExtrem, const bool drawLastExtrem)
draw dotted contour for the given shape (used by additionals)
The popup menu of a globject.
static void drawGeometryPoints(const GUIVisualizationSettings &s, const Position &mousePos, const PositionVector &shape, const RGBColor &geometryPointColor, const RGBColor &textColor, const double radius, const double exaggeration, const bool editingElevation, const bool drawExtremeSymbols)
draw geometry points
static void drawGeometry(const GUIVisualizationSettings &s, const Position &mousePos, const GUIGeometry &geometry, const double width, double offset=0)
draw geometry
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
static void drawMovingHint(const GUIVisualizationSettings &s, const Position &mousePos, const PositionVector &shape, const RGBColor &hintColor, const double radius, const double exaggeration)
draw moving hint
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
bool mouseWithinGeometry(const Position center, const double radius) const
check if mouse is within elements geometry (for circles)
GUIGlID getGlID() const
Returns the numerical id of the object.
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
static void drawInnerPolygon(const GUIVisualizationSettings &s, const TesselatedPolygon *polygon, const GUIGlObject *o, const PositionVector shape, const double layer, const bool fill, const bool disableSelectionColor=false, const int alphaOverride=-1, const bool disableText=false)
draw inner Polygon (before pushName() )
static bool checkDraw(const GUIVisualizationSettings &s, const SUMOPolygon *polygon, const GUIGlObject *o)
check if Polygon can be drawn
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.
const GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings (read only)
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
static int getTextureID(const std::string &filename, const bool mirrorX=false)
return texture id for the given filename (initialize on first use)
static void clearTextures()
clears loaded textures
Stores the information about how to visualize structures.
bool drawBoundaries
enable or disable draw boundaries
bool drawForPositionSelection
whether drawing is performed for the purpose of selecting objects with a single click
bool drawMovingGeometryPoint(const double exaggeration, const double radius) const
check if moving geometry point can be draw
GUIVisualizationColorSettings colorSettings
color settings
double scale
information about a lane's width (temporary, used for a single view)
GUIVisualizationTextSettings polyName
GUIVisualizationSizeSettings polySize
int getCircleResolution() const
function to calculate circle resolution for all circles drawn in drawGL(...) functions
GUIVisualizationTextSettings polyType
GUIVisualizationNeteditSizeSettings neteditSizeSettings
netedit size settings
double angle
The current view rotation angle.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation.
std::string myID
The name of the object.
Definition Named.h:125
Static storage of an output device and its base (abstract) implementation.
static bool areParametersValid(const std::string &value, bool report=false, const std::string kvsep="=", const std::string sep="|")
check if given string can be parsed to a parameters map "key1=value1|key2=value2|....
std::map< std::string, std::string > Map
parameters map
void setParametersStr(const std::string &paramsString, const std::string kvsep="=", const std::string sep="|")
set the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN"
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
std::string getParametersStr(const std::string kvsep="=", const std::string sep="|") const
Returns the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN".
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
double x() const
Returns the x-position.
Definition Position.h:55
double y() const
Returns the y-position.
Definition Position.h:60
A list of positions.
Position getPolygonCenter() const
Returns the arithmetic of all corner points.
void closePolygon()
ensures that the last position equals the first
int indexOfClosest(const Position &p, bool twoD=false) const
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
bool isClosed() const
check if PositionVector is closed
bool around(const Position &p, double offset=0) const
Returns the information whether the position vector describes a polygon lying around the given point.
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition RGBColor.cpp:92
RGBColor invertedColor() const
obtain inverted of current RGBColor
Definition RGBColor.cpp:183
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition RGBColor.cpp:200
PositionVector myShape
The positions of the polygon.
double myLineWidth
The line width for drawing an unfilled polygon.
bool myGEO
specify if shape is handled as GEO coordinate (Main used in netedit)
void writeXML(OutputDevice &out, bool geo=false) const
bool myFill
Information whether the polygon has to be filled.
bool getFill() const
Returns whether the polygon is filled.
static bool isValidAdditionalID(const std::string &value)
whether the given string is a valid id for an additional object
static bool isValidAttribute(const std::string &value)
whether the given string is a valid attribute for a certain key (for example, a name)
const std::string getShapeName() const
Returns the name of the Shape.
Definition Shape.h:110
static const double DEFAULT_LAYER
Definition Shape.h:43
void setShapeName(const std::string &name)
Sets a new shape name.
Definition Shape.h:169
void setShapeLayer(const double layer)
Sets a new layer.
Definition Shape.h:150
bool getShapeRelativePath() const
Returns the relativePath of the Shape.
Definition Shape.h:117
const std::string & getShapeType() const
Returns the (abstract) type of the Shape.
Definition Shape.h:77
void setShapeType(const std::string &type)
Sets a new type.
Definition Shape.h:129
void setShapeRelativePath(bool relativePath)
Sets a new relativePath value.
Definition Shape.h:176
virtual void setShapeNaviDegree(const double angle)
Sets a new angle in navigational degrees.
Definition Shape.h:157
void setShapeImgFile(const std::string &imgFile)
Sets a new imgFile.
Definition Shape.h:164
void setShapeColor(const RGBColor &col)
Sets a new color.
Definition Shape.h:136
double getShapeLayer() const
Returns the layer of the Shape.
Definition Shape.h:91
const std::string & getShapeImgFile() const
Returns the imgFile of the Shape.
Definition Shape.h:105
const RGBColor & getShapeColor() const
Returns the color of the Shape.
Definition Shape.h:84
double getShapeNaviDegree() const
Returns the angle of the Shape in navigational degrees.
Definition Shape.h:98
std::vector< GLPrimitive > myTesselation
id of the display list for the cached tesselation
Definition GUIPolygon.h:74
bool showShapes() const
check if shapes has to be drawn
bool showShapes() const
check if shapes has to be drawn
NetworkEditMode networkEditMode
the current Network edit mode
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
static void drawLockIcon(const GNEAttributeCarrier *AC, GUIGlObjectType type, const Position viewPosition, const double exaggeration, const double size=0.5, const double offsetx=0, const double offsety=0)
draw lock icon
bool editingElevation() const
check if we're editing elevation
RGBColor selectionColor
basic selection color
static const double polygonGeometryPointRadius
moving geometry point radius
static const double polygonContourWidth
polygon contour width
static const double polylineWidth
poly line width
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
bool show(const GUIGlObject *o) const
whether to show the text