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-2026 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
25#include <netedit/GNENet.h>
27#include <netedit/GNEUndoList.h>
35
36#include "GNEPoly.h"
37
38// ===========================================================================
39// method definitions
40// ===========================================================================
41
43 TesselatedPolygon("", "", RGBColor::BLACK, {}, false, false, 0, 0, 0, "", "", Parameterised::Map()),
44 GNEAdditional(net, tag),
45myMoveElementShape(new GNEMoveElementShape(this)) {
46}
47
48
49GNEPoly::GNEPoly(const std::string& id, GNENet* net, FileBucket* fileBucket, const std::string& type, const PositionVector& shape,
50 bool geo, bool fill, double lineWidth, const RGBColor& color, double layer, double angle, const std::string& imgFile,
51 const std::string& name, const Parameterised::Map& parameters) :
52 TesselatedPolygon(id, type, color, shape, geo, fill, lineWidth, layer, angle, imgFile, "", parameters),
53 GNEAdditional(id, net, SUMO_TAG_POLY, fileBucket, name),
54 myMoveElementShape(new GNEMoveElementShape(this, myShape, false)),
55 myClosedShape(shape.isClosed()) {
56 // check if imgFile is valid
57 if (!imgFile.empty() && GUITexturesHelper::getTextureID(imgFile) == -1) {
59 }
60 // set GEO shape
62 if (geo) {
63 for (int i = 0; i < (int) myGeoShape.size(); i++) {
65 }
66 } else {
67 for (int i = 0; i < (int) myGeoShape.size(); i++) {
69 }
70 }
71 // update centering boundary without updating grid
73 // update geometry
75}
76
77
78GNEPoly::GNEPoly(SumoXMLTag tag, const std::string& id, GNENet* net, FileBucket* fileBucket, const PositionVector& shape,
79 bool geo, const std::string& name, const Parameterised::Map& parameters) :
80 TesselatedPolygon(id, getJuPedSimType(tag), getJuPedSimColor(tag), shape, geo, getJuPedSimFill(tag), 1,
81 getJuPedSimLayer(tag), 0, "", "", parameters),
82 GNEAdditional(id, net, tag, fileBucket, name),
83 myMoveElementShape(new GNEMoveElementShape(this, myShape, (tag == GNE_TAG_JPS_WALKABLEAREA) || (tag == GNE_TAG_JPS_OBSTACLE))),
84 myClosedShape(shape.isClosed()),
85 mySimplifiedShape(false) {
86 // set GEO shape
88 if (geo) {
89 for (int i = 0; i < (int) myGeoShape.size(); i++) {
91 }
92 } else {
93 for (int i = 0; i < (int) myGeoShape.size(); i++) {
95 }
96 }
97 // update centering boundary without updating grid
99 // update geometry
101}
102
103
107
108
113
114
117 return this;
118}
119
120
121const Parameterised*
123 return this;
124}
125
126
127std::string
129 return "";
130}
131
132
133void
135 // just update polygon geometry
137 myTesselation.clear();
138}
139
140
145
146
147double
149 return s.polySize.getExaggeration(s, this);
150}
151
152
153void
154GNEPoly::updateCenteringBoundary(const bool updateGrid) {
155 // Remove object from net
156 if (updateGrid) {
158 }
159 // use shape as boundary
161 // grow boundary
163 // add object into net
164 if (updateGrid) {
166 }
167}
168
169
170void
171GNEPoly::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
172 // nothing to split
173}
174
175
176void
178 device.openTag(SUMO_TAG_POLY);
179 // write common additional attributes
181 // write specific attributes
182 PositionVector shape = getShape();
183 if (myGEO) {
184 device.writeAttr(SUMO_ATTR_GEO, true);
185 for (int i = 0; i < (int) shape.size(); i++) {
187 }
188 }
189 if (getShapeType().size() > 0) {
191 }
194 if (getLineWidth() != 1) {
196 }
198
200 device.writeAttr(SUMO_ATTR_SHAPE, shape);
201 device.setPrecision();
204 }
207 }
208 writeParams(device);
209 device.closeTag();
210}
211
212
213bool
215 return true;
216}
217
218
219std::string
221 return "";
222}
223
224
225void
227 // nothing to fix
228}
229
230
233 return GUIGlObject::getGlID();
234}
235
236
237bool
239 // get edit modes
240 const auto& editModes = myNet->getViewNet()->getEditModes();
241 // check if we're in move mode
242 if (!myNet->getViewNet()->isCurrentlyMovingElements() && editModes.isCurrentSupermodeNetwork() &&
244 (editModes.networkEditMode == NetworkEditMode::NETWORK_MOVE) && myNet->getViewNet()->checkOverLockedElement(this, mySelected)) {
245 // only move the first element
247 } else {
248 return false;
249 }
250}
251
252
253std::string
255 return myNet->getMicrosimID();
256}
257
258
261 // create popup
262 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, this);
263 // build common options
265 FXMenuCommand* simplifyShape = GUIDesigns::buildFXMenuCommand(ret, TL("Simplify Shape"), TL("Replace current shape with a rectangle"), nullptr, &parent, MID_GNE_POLYGON_SIMPLIFY_SHAPE);
266 // disable simplify shape if polygon was already simplified
267 if (mySimplifiedShape || myShape.size() <= 2) {
268 simplifyShape->disable();
269 }
270 // only allow open/close for non juPedSim polygons
272 if (myShape.isClosed()) {
273 GUIDesigns::buildFXMenuCommand(ret, TL("Open shape"), TL("Open polygon's shape"), nullptr, &parent, MID_GNE_POLYGON_OPEN);
274 } else {
275 GUIDesigns::buildFXMenuCommand(ret, TL("Close shape"), TL("Close polygon's shape"), nullptr, &parent, MID_GNE_POLYGON_CLOSE);
276 }
277 }
278 GUIDesigns::buildFXMenuCommand(ret, TL("Select elements within polygon"), TL("Select elements within polygon boundary"), nullptr, &parent, MID_GNE_POLYGON_SELECT);
279 if (myShape.size() > 3) {
280 GUIDesigns::buildFXMenuCommand(ret, TL("Triangulate polygon"), TL("Convert the current polygon in triangles"), nullptr, &parent, MID_GNE_POLYGON_TRIANGULATE);
281 }
282 // create a extra FXMenuCommand if mouse is over a vertex
283 const int index = getVertexIndex(myNet->getViewNet()->getPositionInformation(), false);
284 if (index != -1) {
285 // add separator
286 new FXMenuSeparator(ret);
287 // check if we're in network mode
289 GUIDesigns::buildFXMenuCommand(ret, "Set custom Geometry Point", nullptr, &parent, MID_GNE_CUSTOM_GEOMETRYPOINT);
290 }
291 FXMenuCommand* removeGeometryPoint = GUIDesigns::buildFXMenuCommand(ret, TL("Remove geometry point"), TL("Remove geometry point under mouse"), nullptr, &parent, MID_GNE_POLYGON_DELETE_GEOMETRY_POINT);
292 FXMenuCommand* setFirstPoint = GUIDesigns::buildFXMenuCommand(ret, TL("Set first geometry point"), TL("Set first geometry point"), nullptr, &parent, MID_GNE_POLYGON_SET_FIRST_POINT);
293 // disable setFirstPoint if shape only have three points
294 if ((myShape.isClosed() && (myShape.size() <= 4)) || (!myShape.isClosed() && (myShape.size() <= 2))) {
295 removeGeometryPoint->disable();
296 }
297 // disable setFirstPoint if mouse is over first point
298 if (index == 0) {
299 setFirstPoint->disable();
300 }
301 }
302 return ret;
303}
304
305
306void
308 // first check if poly can be drawn
311 GUIPolygon::checkDraw(s, this, this)) {
312 // draw boundary
313 const auto boundary = getCenteringBoundary();
315 // get exaggeration
316 const double polyExaggeration = getExaggeration(s);
317 // get detail level
318 const auto d = s.getDetailLevel(polyExaggeration);
319 // draw geometry only if we'rent in drawForObjectUnderCursor mode
320 if (s.checkDrawPoly(boundary, isAttributeCarrierSelected())) {
321 // get colors
323 // push layer matrix
325 // translate to front
327 // draw polygon
328 drawPolygon(s, d, color, polyExaggeration);
329 // draw contour if don't move whole polygon
331 // get darker color
332 const RGBColor darkerColor = color.changedBrightness(-32);
333 // draw contour
334 drawPolygonContour(s, d, darkerColor, polyExaggeration);
335 // draw geometry points
336 drawGeometryPoints(s, d, darkerColor, polyExaggeration);
337 }
338 // pop layer matrix
340 // draw name and type
342 // draw lock icon
344 // draw dotted contour
346 }
347 // calculate contour
348 calculateContourPolygons(s, d, getShapeLayer(), polyExaggeration, getFill());
349 }
350}
351
352
353int
354GNEPoly::getVertexIndex(Position pos, bool snapToGrid) {
355 // check if position has to be snapped to grid
356 if (snapToGrid) {
357 pos = myNet->getViewNet()->snapToActiveGrid(pos);
358 }
359 // first check if vertex already exists
360 for (const auto& shapePosition : myShape) {
361 if (shapePosition.distanceTo2D(pos) < myNet->getViewNet()->getVisualisationSettings().neteditSizeSettings.polygonGeometryPointRadius) {
362 return myShape.indexOfClosest(shapePosition);
363 }
364 }
365 return -1;
366}
367
368
369void
370GNEPoly::deleteGeometryPoint(const Position& pos, bool allowUndo) {
371 if (myShape.size() > 1) {
372 // obtain index
373 PositionVector modifiedShape = myShape;
374 int index = modifiedShape.indexOfClosest(pos);
375 // remove point dependending of
376 if (myShape.isClosed() && (index == 0 || index == (int)modifiedShape.size() - 1) && (myShape.size() > 2)) {
377 modifiedShape.erase(modifiedShape.begin());
378 modifiedShape.erase(modifiedShape.end() - 1);
379 modifiedShape.push_back(modifiedShape.front());
380 } else {
381 modifiedShape.erase(modifiedShape.begin() + index);
382 }
383 // set new shape depending of allowUndo
384 if (allowUndo) {
385 myNet->getUndoList()->begin(this, "delete geometry point");
387 myNet->getUndoList()->end();
388 } else {
389 // first remove object from grid due shape is used for boundary
391 // set new shape
392 myShape = modifiedShape;
393 // disable simplified shape flag
394 mySimplifiedShape = false;
395 // add object into grid again
397 }
398 myTesselation.clear();
399 } else {
400 WRITE_WARNING(TL("Number of remaining points insufficient"))
401 }
402}
403
404
405bool
407 return myShape.isClosed();
408}
409
410
411void
412GNEPoly::openPolygon(bool allowUndo) {
413 // only open if shape is closed
414 if (myShape.isClosed()) {
415 if (allowUndo) {
416 myNet->getUndoList()->begin(this, "open polygon");
418 myNet->getUndoList()->end();
419 } else {
420 myShape.pop_back();
421 // disable simplified shape flag
422 mySimplifiedShape = false;
423 // update geometry to avoid grabbing Problems
425 }
426 } else {
427 WRITE_WARNING(TL("Polygon already opened"))
428 }
429}
430
431
432void
433GNEPoly::closePolygon(bool allowUndo) {
434 // only close if shape is opened
435 if (!myShape.isClosed()) {
436 if (allowUndo) {
437 myNet->getUndoList()->begin(this, "close shape");
439 myNet->getUndoList()->end();
440 } else {
442 // disable simplified shape flag
443 mySimplifiedShape = false;
444 // update geometry to avoid grabbing Problems
446 }
447 } else {
448 WRITE_WARNING(TL("Polygon already closed"))
449 }
450}
451
452
453void
454GNEPoly::changeFirstGeometryPoint(int oldIndex, bool allowUndo) {
455 // check that old index is correct
456 if (oldIndex >= (int)myShape.size()) {
457 throw InvalidArgument("Invalid old Index");
458 } else if (oldIndex == 0) {
459 WRITE_WARNING(TL("Selected point must be different of the first point"))
460 } else {
461 // Configure new shape
462 PositionVector newShape;
463 for (int i = oldIndex; i < (int)myShape.size(); i++) {
464 newShape.push_back(myShape[i]);
465 }
466 if (myShape.isClosed()) {
467 for (int i = 1; i < oldIndex; i++) {
468 newShape.push_back(myShape[i]);
469 }
470 newShape.push_back(newShape.front());
471 } else {
472 for (int i = 0; i < oldIndex; i++) {
473 newShape.push_back(myShape[i]);
474 }
475 }
476 // set new rotated shape
477 if (allowUndo) {
478 myNet->getUndoList()->begin(this, "change first geometry point");
480 myNet->getUndoList()->end();
481 } else {
482 // set new shape
483 myShape = newShape;
484 // disable simplified shape flag
485 mySimplifiedShape = false;
486 // update geometry to avoid grabbing Problems
488 }
489 }
490}
491
492
493void
494GNEPoly::simplifyShape(bool allowUndo) {
495 if (!mySimplifiedShape && myShape.size() > 2) {
496 const Boundary b = myShape.getBoxBoundary();
497 // create a square as simplified shape
498 PositionVector simplifiedShape;
499 simplifiedShape.push_back(Position(b.xmin(), b.ymin()));
500 simplifiedShape.push_back(Position(b.xmin(), b.ymax()));
501 simplifiedShape.push_back(Position(b.xmax(), b.ymax()));
502 simplifiedShape.push_back(Position(b.xmax(), b.ymin()));
503 if (myShape.isClosed()) {
504 simplifiedShape.push_back(simplifiedShape[0]);
505 }
506 // set new shape depending of allowUndo
507 if (allowUndo) {
508 myNet->getUndoList()->begin(this, "simplify shape");
510 myNet->getUndoList()->end();
511 } else {
512 // set new shape
513 myShape = simplifiedShape;
514 // update geometry to avoid grabbing Problems
516 }
517 // change flag after setting simplified shape
518 mySimplifiedShape = true;
519 } else {
520 WRITE_WARNING(TL("Polygon already simplified"))
521 }
522}
523
524
528 polygonBaseObject->setTag(myTagProperty->getTag());
529 // fill attributes
530 polygonBaseObject->addStringAttribute(SUMO_ATTR_ID, myID);
532 polygonBaseObject->addBoolAttribute(SUMO_ATTR_GEO, myGEO);
533 polygonBaseObject->addBoolAttribute(SUMO_ATTR_FILL, myFill);
535 polygonBaseObject->addColorAttribute(SUMO_ATTR_COLOR, getShapeColor());
536 polygonBaseObject->addStringAttribute(SUMO_ATTR_TYPE, getShapeType());
537 polygonBaseObject->addDoubleAttribute(SUMO_ATTR_LAYER, getShapeLayer());
541 return polygonBaseObject;
542}
543
544
545std::string
547 switch (key) {
548 case SUMO_ATTR_ID:
549 return myID;
550 case SUMO_ATTR_SHAPE:
551 if ((GeoConvHelper::getFinal().getProjString() != "!") && myGEO) {
552 return TL("Using GEO Shape");
553 } else {
554 return toString(myShape);
555 }
557 if (GeoConvHelper::getFinal().getProjString() != "!") {
559 } else {
560 return TL("No geo-conversion defined");
561 }
562 case SUMO_ATTR_COLOR:
563 return toString(getShapeColor());
564 case SUMO_ATTR_FILL:
565 return toString(myFill);
567 return toString(myLineWidth);
568 case SUMO_ATTR_LAYER:
569 return toString(getShapeLayer());
570 case SUMO_ATTR_TYPE:
571 return getShapeType();
573 return getShapeImgFile();
574 case SUMO_ATTR_ANGLE:
576 case SUMO_ATTR_GEO:
577 return toString(myGEO);
578 case SUMO_ATTR_NAME:
579 return myAdditionalName;
581 return toString(myClosedShape);
582 default:
583 return getCommonAttribute(key);
584 }
585}
586
587
588double
592
593
598
599
604
605
606void
607GNEPoly::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
608 if (value == getAttribute(key)) {
609 return; //avoid needless changes, later logic relies on the fact that attributes have changed
610 }
611 switch (key) {
612 case SUMO_ATTR_ID:
613 case SUMO_ATTR_SHAPE:
615 case SUMO_ATTR_COLOR:
616 case SUMO_ATTR_FILL:
618 case SUMO_ATTR_LAYER:
619 case SUMO_ATTR_TYPE:
621 case SUMO_ATTR_ANGLE:
622 case SUMO_ATTR_GEO:
623 case SUMO_ATTR_NAME:
625 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
626 break;
627 default:
628 setCommonAttribute(key, value, undoList);
629 break;
630 }
631}
632
633
634bool
635GNEPoly::isValid(SumoXMLAttr key, const std::string& value) {
636 switch (key) {
637 case SUMO_ATTR_ID:
639 case SUMO_ATTR_SHAPE:
641 // empty shapes AREN'T allowed
642 if (value.empty()) {
643 return false;
644 } else {
645 return canParse<PositionVector>(value);
646 }
647 case SUMO_ATTR_COLOR:
648 return canParse<RGBColor>(value);
649 case SUMO_ATTR_FILL:
650 return canParse<bool>(value);
652 return canParse<double>(value) && (parse<double>(value) >= 0);
653 case SUMO_ATTR_LAYER:
654 if (value.empty()) {
655 return true;
656 } else {
657 return canParse<double>(value);
658 }
659 case SUMO_ATTR_TYPE:
660 return true;
662 if (value == "") {
663 return true;
664 } else {
665 // check that image can be loaded
666 return GUITexturesHelper::getTextureID(value) != -1;
667 }
668 case SUMO_ATTR_ANGLE:
669 return canParse<double>(value);
670 case SUMO_ATTR_GEO:
671 return canParse<bool>(value);
672 case SUMO_ATTR_NAME:
675 return canParse<bool>(value);
676 default:
677 return isCommonAttributeValid(key, value);
678 }
679}
680
681
682bool
684 switch (key) {
685 case SUMO_ATTR_SHAPE:
686 if (GeoConvHelper::getFinal().getProjString() != "!") {
687 return myGEO == false;
688 } else {
689 return true;
690 }
691 case SUMO_ATTR_GEO:
692 return GeoConvHelper::getFinal().getProjString() != "!";
694 if (GeoConvHelper::getFinal().getProjString() != "!") {
695 return myGEO == true;
696 } else {
697 return false;
698 }
700 if (isTemplate()) {
701 return true;
702 } else {
703 return myShape.size() > 1;
704 }
705 default:
706 return true;
707 }
708}
709
710
711std::string
713 return getTagStr() + ": " + getID();
714}
715
716
717std::string
719 return getTagStr();
720}
721
722// ===========================================================================
723// private
724// ===========================================================================
725
726void
727GNEPoly::setAttribute(SumoXMLAttr key, const std::string& value) {
728 switch (key) {
729 case SUMO_ATTR_ID: {
730 // update microsimID
731 setAdditionalID(value);
732 // set named ID
733 myID = value;
734 break;
735 }
736 case SUMO_ATTR_SHAPE: {
737 // set new shape
738 myShape = parse<PositionVector>(value);
739 // set GEO shape
741 for (int i = 0; i < (int) myGeoShape.size(); i++) {
743 }
744 // disable simplified shape flag
745 mySimplifiedShape = false;
746 // update geometry
748 // update centering boundary
750 break;
751 }
752 case SUMO_ATTR_GEOSHAPE: {
753 // set new GEO shape
754 myGeoShape = parse<PositionVector>(value);
755 // set shape
757 for (int i = 0; i < (int) myShape.size(); i++) {
759 }
760 // disable simplified shape flag
761 mySimplifiedShape = false;
762 // update geometry
764 // update centering boundary
766 break;
767 }
768 case SUMO_ATTR_COLOR:
769 setShapeColor(parse<RGBColor>(value));
770 break;
771 case SUMO_ATTR_FILL:
772 myFill = parse<bool>(value);
774 break;
776 myLineWidth = parse<double>(value);
777 break;
778 case SUMO_ATTR_LAYER:
779 if (value.empty()) {
781 } else {
782 setShapeLayer(parse<double>(value));
783 }
784 break;
785 case SUMO_ATTR_TYPE:
786 setShapeType(value);
787 break;
789 setShapeImgFile(value);
790 // all textures must be refresh
792 break;
793 case SUMO_ATTR_ANGLE:
794 setShapeNaviDegree(parse<double>(value));
795 break;
796 case SUMO_ATTR_GEO:
797 myGEO = parse<bool>(value);
798 // update centering boundary
800 break;
801 case SUMO_ATTR_NAME:
802 myAdditionalName = value;
803 break;
805 myClosedShape = parse<bool>(value);
806 if (!isTemplate()) {
807 if (myClosedShape) {
810
811 } else {
814 }
815 // disable simplified shape flag
816 mySimplifiedShape = false;
817 // update geometry
819 // update centering boundary
821 }
822 break;
823 default:
824 setCommonAttribute(key, value);
825 break;
826 }
827}
828
829
830void
832 const RGBColor& color, const double exaggeration) const {
833 // check if we're drawing a polygon or a polyline
834 if (getFill()) {
835 // draw inner polygon
837 } else {
838 // push matrix
840 // set color
841 GLHelper::setColor(color);
842 // draw geometry (polyline)
844 // pop matrix
846 }
847}
848
849
850void
852 const RGBColor& color, const double exaggeration) const {
853 // push contour matrix
855 // translate to front
856 glTranslated(0, 0, 0.1);
857 // set color
858 GLHelper::setColor(color);
859 // draw polygon contour
861 // pop contour matrix
863}
864
865
866void
868 const RGBColor& color, const double exaggeration) const {
869 // draw shape points only in supermode network
871 // check if we're in move mode
873 // get geometry point sizes
874 const double geometryPointSize = s.neteditSizeSettings.polygonGeometryPointRadius * (moveMode ? 1 : 0.5);
875 // draw geometry points
876 GUIGeometry::drawGeometryPoints(d, myAdditionalGeometry.getShape(), color, geometryPointSize, exaggeration,
878 // draw dotted contours for geometry points if we're in move mode
879 if (moveMode) {
882 }
883 }
884}
885
886
887void
889 // get name position
891 // draw name
892 drawName(namePos, s.scale, s.polyName, s.angle);
893 // check if draw poly type
894 if (s.polyType.show(this)) {
895 const Position p = namePos + Position(0, -0.6 * s.polyType.size / s.scale);
897 }
898}
899
900/****************************************************************************/
@ NETWORK_MOVE
mode for moving network elements
@ MID_GNE_POLYGON_TRIANGULATE
triangulate polygon
@ 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
@ 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:44
#define WRITE_WARNING(msg)
Definition MsgHandler.h:286
#define TL(string)
Definition MsgHandler.h:304
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_POLY
begin/end of the description of a polygon
@ GNE_TAG_JPS_OBSTACLE
polygon used for draw juPedSim obstacles
@ GNE_TAG_JPS_WALKABLEAREA
polygon used for draw juPedSim walkable areas
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_LINEWIDTH
@ 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
int gPrecisionGeo
Definition StdDefs.cpp:29
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:109
double ymin() const
Returns minimum y-coordinate.
Definition Boundary.cpp:127
double xmin() const
Returns minimum x-coordinate.
Definition Boundary.cpp:115
Boundary & grow(double by)
extends the boundary by the given amount
Definition Boundary.cpp:340
double ymax() const
Returns maximum y-coordinate.
Definition Boundary.cpp:133
double xmax() const
Returns maximum x-coordinate.
Definition Boundary.cpp:121
void setTag(const SumoXMLTag tag)
set SumoBaseObject tag
void addPositionVectorAttribute(const SumoXMLAttr attr, const PositionVector &value)
add PositionVector attribute into current SumoBaseObject node
void addBoolAttribute(const SumoXMLAttr attr, const bool value)
add bool attribute into current SumoBaseObject node
void addDoubleAttribute(const SumoXMLAttr attr, const double value)
add double attribute into current SumoBaseObject node
void addStringAttribute(const SumoXMLAttr attr, const std::string &value)
add string attribute into current SumoBaseObject node
void addColorAttribute(const SumoXMLAttr attr, const RGBColor &value)
add color attribute into current SumoBaseObject node
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:649
static void popMatrix()
pop matrix
Definition GLHelper.cpp:131
static void drawBoundary(const GUIVisualizationSettings &s, const Boundary &b)
Draw a boundary (used for debugging)
Definition GLHelper.cpp:952
static void pushMatrix()
push matrix
Definition GLHelper.cpp:118
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:773
bool isValidAdditionalID(const std::string &value) const
check if a new additional ID is valid
void setAdditionalID(const std::string &newID)
set additional ID
GNEContour myAdditionalContour
variable used for draw additional contours
GUIGeometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
std::string myAdditionalName
name of additional
void calculateContourPolygons(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double layer, const double exaggeration, const bool filledShape) const
calculate contour for polygons
void writeAdditionalAttributes(OutputDevice &device) const
write common additional attributes
Boundary myAdditionalBoundary
Additional Boundary (used only by additionals placed over grid)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
bool mySelected
boolean to check if this AC is selected (more quickly as checking GUIGlObjectStorage)
const std::string getID() const override
get ID (all Attribute Carriers have one)
PositionVector getCommonAttributePositionVector(SumoXMLAttr key) const
void setCommonAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
const std::string & getTagStr() const
get tag assigned to this object in string format
bool isTemplate() const
check if this AC is template
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
void drawInLayer(const double typeOrLayer, const double extraOffset=0) const
draw element in the given layer, or in front if corresponding flag is enabled
GNENet * myNet
pointer to net
bool isCommonAttributeValid(SumoXMLAttr key, const std::string &value) const
std::string getCommonAttribute(SumoXMLAttr key) const
const GNETagProperties * myTagProperty
reference to tagProperty associated with this attribute carrier
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
void clearContour() const
void clear contour
void drawDottedContourGeometryPoints(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const PositionVector &shape, const double radius, const double scale, const double lineWidth) const
draw dotted contour for geometry points
bool drawDottedContours(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const
draw dotted contours (basics, select, delete, inspect...)
double getMovingAttributeDouble(SumoXMLAttr key) const override
get moving attribute double
Position getMovingAttributePosition(SumoXMLAttr key) const override
get moving attribute position
bool getMoveWholePolygons() const
check if option "move whole polygons" is enabled
NetworkMoveOptions * getNetworkMoveOptions() const
get network mode options
void addGLObjectIntoGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1444
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1454
GNEViewParent * getViewParent() const
get view parent (used for simplify code)
Definition GNENet.cpp:150
GNEUndoList * getUndoList() const
get undo list(used for simplify code)
Definition GNENet.cpp:156
GNEViewNet * getViewNet() const
get view net (used for simplify code)
Definition GNENet.cpp:144
Parameterised * getParameters() override
get parameters associated with this poly
Definition GNEPoly.cpp:116
bool mySimplifiedShape
flag to indicate if polygon is simplified
Definition GNEPoly.h:262
std::string getAdditionalProblem() const override
return a string with the current additional problem (must be reimplemented in all detector children)
Definition GNEPoly.cpp:220
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
Definition GNEPoly.cpp:712
std::string getParentName() const override
Returns the name of the parent object.
Definition GNEPoly.cpp:254
double getAttributeDouble(SumoXMLAttr key) const override
Definition GNEPoly.cpp:589
~GNEPoly()
Destructor.
Definition GNEPoly.cpp:104
bool isValid(SumoXMLAttr key, const std::string &value) override
method for checking if the key and their conrrespond attribute are valids
Definition GNEPoly.cpp:635
void updateGeometry() override
update pre-computed geometry information
Definition GNEPoly.cpp:134
GNEMoveElementShape * myMoveElementShape
move element shape
Definition GNEPoly.h:253
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
Definition GNEPoly.cpp:718
void fixAdditionalProblem() override
fix additional problem (must be reimplemented in all detector children)
Definition GNEPoly.cpp:226
void writeAdditional(OutputDevice &device) const override
write additional element into a xml file
Definition GNEPoly.cpp:177
void drawPolygonNameAndType(const GUIVisualizationSettings &s) const
draw polygon name and type
Definition GNEPoly.cpp:888
GNEPoly(SumoXMLTag tag, GNENet *net)
default Constructor
Definition GNEPoly.cpp:42
GNEMoveElement * getMoveElement() const override
methods to retrieve the elements linked to this poly
Definition GNEPoly.cpp:110
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:354
PositionVector myGeoShape
Latitude of Polygon.
Definition GNEPoly.h:256
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
Definition GNEPoly.cpp:148
void closePolygon(bool allowUndo=true)
close polygon
Definition GNEPoly.cpp:433
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point
Definition GNEPoly.cpp:454
std::string getAttribute(SumoXMLAttr key) const override
Definition GNEPoly.cpp:546
bool checkDrawMoveContour() const override
check if draw move contour (red)
Definition GNEPoly.cpp:238
bool isAdditionalValid() const override
check if current additional is valid to be written into XML (must be reimplemented in all detector ch...
Definition GNEPoly.cpp:214
Position getAttributePosition(SumoXMLAttr key) const override
Definition GNEPoly.cpp:595
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:607
void deleteGeometryPoint(const Position &pos, bool allowUndo=true)
delete the geometry point closest to the given pos
Definition GNEPoly.cpp:370
Position getPositionInView() const override
Returns position of shape in view.
Definition GNEPoly.cpp:142
void drawGeometryPoints(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw geometry points
Definition GNEPoly.cpp:867
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GNEPoly.cpp:307
PositionVector getAttributePositionVector(SumoXMLAttr key) const override
Definition GNEPoly.cpp:601
void drawPolygon(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw polygon
Definition GNEPoly.cpp:831
bool isAttributeEnabled(SumoXMLAttr key) const override
Definition GNEPoly.cpp:683
void drawPolygonContour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw contour
Definition GNEPoly.cpp:851
CommonXMLStructure::SumoBaseObject * getSumoBaseObject() const
get SUMOBaseObject with all polygon attributes
Definition GNEPoly.cpp:526
bool isPolygonClosed() const
check if polygon is closed
Definition GNEPoly.cpp:406
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GNEPoly.cpp:260
void simplifyShape(bool allowUndo=true)
replace the current shape with a rectangle
Definition GNEPoly.cpp:494
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList) override
split geometry
Definition GNEPoly.cpp:171
void updateCenteringBoundary(const bool updateGrid) override
update centering boundary (implies change in RTREE)
Definition GNEPoly.cpp:154
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition GNEPoly.cpp:232
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition GNEPoly.cpp:128
void openPolygon(bool allowUndo=true)
open polygon
Definition GNEPoly.cpp:412
bool myClosedShape
flag to indicate if polygon is closed
Definition GNEPoly.h:259
double getDefaultDoubleValue(SumoXMLAttr attr) const
get default double value
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
bool isJuPedSimElement() const
return true if tag correspond to a JuPedSim element
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...
const GUIGlObject * getGUIGlObjectFront() const
get front GUIGLObject or a pointer to nullptr
bool isCurrentlyMovingElements() const
check if an element is being moved
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
const GNEViewNetHelper::EditNetworkElementShapes & getEditNetworkElementShapes() const
get Edit Shape module
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
bool checkOverLockedElement(const GUIGlObject *GLObject, const bool isSelected) const
check if given element is locked (used for drawing select and delete contour)
const GNEViewNetHelper::ViewObjectsSelector & getViewObjectsSelector() const
get objects under cursor
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, const bool disable=false)
build menu command
The popup menu of a globject.
static void drawGeometryPoints(const GUIVisualizationSettings::Detail d, const PositionVector &shape, const RGBColor &color, const double radius, const double exaggeration, const bool editingElevation)
draw geometry points
static void drawGeometry(const GUIVisualizationSettings::Detail d, 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
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void buildPopUpMenuCommonOptions(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, GUISUMOAbstractView *parent, const SumoXMLTag tag, const bool selected, bool addSeparator=true)
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 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.
double polyCustomLayer
the custom layer for polygons
bool checkDrawPoly(const Boundary &b, const bool selected) const
check if draw polygon
Detail getDetailLevel(const double exaggeration) const
return the detail level
GUIVisualizationColorSettings colorSettings
color settings
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
bool polyUseCustomLayer
whether the rendering layer of polygons should be overriden
double scale
information about a lane's width (temporary, used for a single view)
GUIVisualizationTextSettings polyName
GUIVisualizationSizeSettings polySize
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.
const std::string & getProjString() const
Returns the original projection definition.
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 const std::vector< SumoXMLTag > polygons
polygon namespace
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void setPrecision(int precision=gPrecision)
Sets the precision or resets it to default.
An upper class for objects with additional parameters.
std::map< std::string, std::string > Map
parameters map
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.
Position getPolygonCenter() const
Returns the arithmetic of all corner points.
void closePolygon()
ensures that the last position equals the first
void openPolygon()
open polygon
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
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition RGBColor.cpp:200
const PositionVector & getShape() const
Returns the shape of the polygon.
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)
double getLineWidth() const
Returns whether the polygon is filled.
bool myFill
Information whether the polygon has to be filled.
bool getFill() const
Returns whether the polygon is filled.
static bool isValidAttribute(const std::string &value)
whether the given string is a valid attribute for a certain key (for example, a name)
void setShapeLayer(const double layer)
Sets a new layer.
Definition Shape.cpp:157
static const std::string DEFAULT_IMG_FILE
Definition Shape.h:47
const std::string & getShapeType() const
Returns the (abstract) type of the Shape.
Definition Shape.cpp:103
void setShapeType(const std::string &type)
Sets a new type.
Definition Shape.cpp:139
static const double DEFAULT_ANGLE
Definition Shape.h:46
virtual void setShapeNaviDegree(const double angle)
Sets a new angle in navigational degrees.
Definition Shape.cpp:163
void setShapeImgFile(const std::string &imgFile)
Sets a new imgFile.
Definition Shape.cpp:169
void setShapeColor(const RGBColor &col)
Sets a new color.
Definition Shape.cpp:145
double getShapeLayer() const
Returns the layer of the Shape.
Definition Shape.cpp:115
const std::string & getShapeImgFile() const
Returns the imgFile of the Shape.
Definition Shape.cpp:127
const RGBColor & getShapeColor() const
Returns the color of the Shape.
Definition Shape.cpp:109
double getShapeNaviDegree() const
Returns the angle of the Shape in navigational degrees.
Definition Shape.cpp:121
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
std::vector< GLPrimitive > myTesselation
id of the display list for the cached tesselation
Definition GUIPolygon.h:72
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
GNENetworkElement * getEditedNetworkElement() const
pointer to edited network element
static void drawLockIcon(const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, GUIGlObjectType type, const Position position, 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 segmentWidthSmall
width of small dotted contour segments
static const double segmentWidth
width of dotted contour segments
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