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-2025 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, const std::string& filename, 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, name, parameters),
53 GNEAdditional(id, net, filename, SUMO_TAG_POLY, ""),
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, const std::string& filename, 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, "", name, parameters),
82 GNEAdditional(id, net, filename, tag, ""),
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 // temporal name
182 if (getShapeName().size() > 0) {
184 }
185 // write specific attributes
186 PositionVector shape = getShape();
187 if (myGEO) {
188 device.writeAttr(SUMO_ATTR_GEO, true);
189 for (int i = 0; i < (int) shape.size(); i++) {
191 }
192 }
193 if (getShapeType().size() > 0) {
195 }
198 if (getLineWidth() != 1) {
200 }
202
204 device.writeAttr(SUMO_ATTR_SHAPE, shape);
205 device.setPrecision();
208 }
211 }
212 writeParams(device);
213 device.closeTag();
214}
215
216
217bool
219 return true;
220}
221
222
223std::string
225 return "";
226}
227
228
229void
231 // nothing to fix
232}
233
234
237 return GUIGlObject::getGlID();
238}
239
240
241bool
243 // get edit modes
244 const auto& editModes = myNet->getViewNet()->getEditModes();
245 // check if we're in move mode
246 if (!myNet->getViewNet()->isCurrentlyMovingElements() && editModes.isCurrentSupermodeNetwork() &&
248 (editModes.networkEditMode == NetworkEditMode::NETWORK_MOVE) && myNet->getViewNet()->checkOverLockedElement(this, mySelected)) {
249 // only move the first element
251 } else {
252 return false;
253 }
254}
255
256
257std::string
259 return myNet->getMicrosimID();
260}
261
262
265 // create popup
266 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, this);
267 // build common options
269 FXMenuCommand* simplifyShape = GUIDesigns::buildFXMenuCommand(ret, TL("Simplify Shape"), TL("Replace current shape with a rectangle"), nullptr, &parent, MID_GNE_POLYGON_SIMPLIFY_SHAPE);
270 // disable simplify shape if polygon was already simplified
271 if (mySimplifiedShape || myShape.size() <= 2) {
272 simplifyShape->disable();
273 }
274 // only allow open/close for non juPedSim polygons
276 if (myShape.isClosed()) {
277 GUIDesigns::buildFXMenuCommand(ret, TL("Open shape"), TL("Open polygon's shape"), nullptr, &parent, MID_GNE_POLYGON_OPEN);
278 } else {
279 GUIDesigns::buildFXMenuCommand(ret, TL("Close shape"), TL("Close polygon's shape"), nullptr, &parent, MID_GNE_POLYGON_CLOSE);
280 }
281 }
282 GUIDesigns::buildFXMenuCommand(ret, TL("Select elements within polygon"), TL("Select elements within polygon boundary"), nullptr, &parent, MID_GNE_POLYGON_SELECT);
283 if (myShape.size() > 3) {
284 GUIDesigns::buildFXMenuCommand(ret, TL("Triangulate polygon"), TL("Convert the current polygon in triangles"), nullptr, &parent, MID_GNE_POLYGON_TRIANGULATE);
285 }
286 // create a extra FXMenuCommand if mouse is over a vertex
287 const int index = getVertexIndex(myNet->getViewNet()->getPositionInformation(), false);
288 if (index != -1) {
289 // add separator
290 new FXMenuSeparator(ret);
291 // check if we're in network mode
293 GUIDesigns::buildFXMenuCommand(ret, "Set custom Geometry Point", nullptr, &parent, MID_GNE_CUSTOM_GEOMETRYPOINT);
294 }
295 FXMenuCommand* removeGeometryPoint = GUIDesigns::buildFXMenuCommand(ret, TL("Remove geometry point"), TL("Remove geometry point under mouse"), nullptr, &parent, MID_GNE_POLYGON_DELETE_GEOMETRY_POINT);
296 FXMenuCommand* setFirstPoint = GUIDesigns::buildFXMenuCommand(ret, TL("Set first geometry point"), TL("Set first geometry point"), nullptr, &parent, MID_GNE_POLYGON_SET_FIRST_POINT);
297 // disable setFirstPoint if shape only have three points
298 if ((myShape.isClosed() && (myShape.size() <= 4)) || (!myShape.isClosed() && (myShape.size() <= 2))) {
299 removeGeometryPoint->disable();
300 }
301 // disable setFirstPoint if mouse is over first point
302 if (index == 0) {
303 setFirstPoint->disable();
304 }
305 }
306 return ret;
307}
308
309
310void
312 // first check if poly can be drawn
315 GUIPolygon::checkDraw(s, this, this)) {
316 // draw boundary
317 const auto boundary = getCenteringBoundary();
319 // get exaggeration
320 const double polyExaggeration = getExaggeration(s);
321 // get detail level
322 const auto d = s.getDetailLevel(polyExaggeration);
323 // draw geometry only if we'rent in drawForObjectUnderCursor mode
324 if (s.checkDrawPoly(boundary, isAttributeCarrierSelected())) {
325 // get colors
327 // push layer matrix
329 // translate to front
331 // draw polygon
332 drawPolygon(s, d, color, polyExaggeration);
333 // draw contour if don't move whole polygon
335 // get darker color
336 const RGBColor darkerColor = color.changedBrightness(-32);
337 // draw contour
338 drawPolygonContour(s, d, darkerColor, polyExaggeration);
339 // draw geometry points
340 drawGeometryPoints(s, d, darkerColor, polyExaggeration);
341 }
342 // pop layer matrix
344 // draw name and type
346 // draw lock icon
348 // draw dotted contour
350 }
351 // calculate contour
352 calculateContourPolygons(s, d, getShapeLayer(), polyExaggeration, getFill());
353 }
354}
355
356
357int
358GNEPoly::getVertexIndex(Position pos, bool snapToGrid) {
359 // check if position has to be snapped to grid
360 if (snapToGrid) {
361 pos = myNet->getViewNet()->snapToActiveGrid(pos);
362 }
363 // first check if vertex already exists
364 for (const auto& shapePosition : myShape) {
365 if (shapePosition.distanceTo2D(pos) < myNet->getViewNet()->getVisualisationSettings().neteditSizeSettings.polygonGeometryPointRadius) {
366 return myShape.indexOfClosest(shapePosition);
367 }
368 }
369 return -1;
370}
371
372
373void
374GNEPoly::deleteGeometryPoint(const Position& pos, bool allowUndo) {
375 if (myShape.size() > 1) {
376 // obtain index
377 PositionVector modifiedShape = myShape;
378 int index = modifiedShape.indexOfClosest(pos);
379 // remove point dependending of
380 if (myShape.isClosed() && (index == 0 || index == (int)modifiedShape.size() - 1) && (myShape.size() > 2)) {
381 modifiedShape.erase(modifiedShape.begin());
382 modifiedShape.erase(modifiedShape.end() - 1);
383 modifiedShape.push_back(modifiedShape.front());
384 } else {
385 modifiedShape.erase(modifiedShape.begin() + index);
386 }
387 // set new shape depending of allowUndo
388 if (allowUndo) {
389 myNet->getViewNet()->getUndoList()->begin(this, "delete geometry point");
392 } else {
393 // first remove object from grid due shape is used for boundary
395 // set new shape
396 myShape = modifiedShape;
397 // disable simplified shape flag
398 mySimplifiedShape = false;
399 // add object into grid again
401 }
402 myTesselation.clear();
403 } else {
404 WRITE_WARNING(TL("Number of remaining points insufficient"))
405 }
406}
407
408
409bool
411 return myShape.isClosed();
412}
413
414
415void
416GNEPoly::openPolygon(bool allowUndo) {
417 // only open if shape is closed
418 if (myShape.isClosed()) {
419 if (allowUndo) {
420 myNet->getViewNet()->getUndoList()->begin(this, "open polygon");
423 } else {
424 myShape.pop_back();
425 // disable simplified shape flag
426 mySimplifiedShape = false;
427 // update geometry to avoid grabbing Problems
429 }
430 } else {
431 WRITE_WARNING(TL("Polygon already opened"))
432 }
433}
434
435
436void
437GNEPoly::closePolygon(bool allowUndo) {
438 // only close if shape is opened
439 if (!myShape.isClosed()) {
440 if (allowUndo) {
441 myNet->getViewNet()->getUndoList()->begin(this, "close shape");
444 } else {
446 // disable simplified shape flag
447 mySimplifiedShape = false;
448 // update geometry to avoid grabbing Problems
450 }
451 } else {
452 WRITE_WARNING(TL("Polygon already closed"))
453 }
454}
455
456
457void
458GNEPoly::changeFirstGeometryPoint(int oldIndex, bool allowUndo) {
459 // check that old index is correct
460 if (oldIndex >= (int)myShape.size()) {
461 throw InvalidArgument("Invalid old Index");
462 } else if (oldIndex == 0) {
463 WRITE_WARNING(TL("Selected point must be different of the first point"))
464 } else {
465 // Configure new shape
466 PositionVector newShape;
467 for (int i = oldIndex; i < (int)myShape.size(); i++) {
468 newShape.push_back(myShape[i]);
469 }
470 if (myShape.isClosed()) {
471 for (int i = 1; i < oldIndex; i++) {
472 newShape.push_back(myShape[i]);
473 }
474 newShape.push_back(newShape.front());
475 } else {
476 for (int i = 0; i < oldIndex; i++) {
477 newShape.push_back(myShape[i]);
478 }
479 }
480 // set new rotated shape
481 if (allowUndo) {
482 myNet->getViewNet()->getUndoList()->begin(this, "change first geometry point");
485 } else {
486 // set new shape
487 myShape = newShape;
488 // disable simplified shape flag
489 mySimplifiedShape = false;
490 // update geometry to avoid grabbing Problems
492 }
493 }
494}
495
496
497void
498GNEPoly::simplifyShape(bool allowUndo) {
499 if (!mySimplifiedShape && myShape.size() > 2) {
500 const Boundary b = myShape.getBoxBoundary();
501 // create a square as simplified shape
502 PositionVector simplifiedShape;
503 simplifiedShape.push_back(Position(b.xmin(), b.ymin()));
504 simplifiedShape.push_back(Position(b.xmin(), b.ymax()));
505 simplifiedShape.push_back(Position(b.xmax(), b.ymax()));
506 simplifiedShape.push_back(Position(b.xmax(), b.ymin()));
507 if (myShape.isClosed()) {
508 simplifiedShape.push_back(simplifiedShape[0]);
509 }
510 // set new shape depending of allowUndo
511 if (allowUndo) {
512 myNet->getViewNet()->getUndoList()->begin(this, "simplify shape");
515 } else {
516 // set new shape
517 myShape = simplifiedShape;
518 // update geometry to avoid grabbing Problems
520 }
521 // change flag after setting simplified shape
522 mySimplifiedShape = true;
523 } else {
524 WRITE_WARNING(TL("Polygon already simplified"))
525 }
526}
527
528
532 polygonBaseObject->setTag(myTagProperty->getTag());
533 // fill attributes
534 polygonBaseObject->addStringAttribute(SUMO_ATTR_ID, myID);
536 polygonBaseObject->addBoolAttribute(SUMO_ATTR_GEO, myGEO);
537 polygonBaseObject->addBoolAttribute(SUMO_ATTR_FILL, myFill);
539 polygonBaseObject->addColorAttribute(SUMO_ATTR_COLOR, getShapeColor());
540 polygonBaseObject->addStringAttribute(SUMO_ATTR_TYPE, getShapeType());
541 polygonBaseObject->addDoubleAttribute(SUMO_ATTR_LAYER, getShapeLayer());
544 polygonBaseObject->addStringAttribute(SUMO_ATTR_NAME, getShapeName());
545 return polygonBaseObject;
546}
547
548
549std::string
551 switch (key) {
552 case SUMO_ATTR_ID:
553 return myID;
554 case SUMO_ATTR_SHAPE:
555 if ((GeoConvHelper::getFinal().getProjString() != "!") && myGEO) {
556 return TL("Using GEO Shape");
557 } else {
558 return toString(myShape);
559 }
561 if (GeoConvHelper::getFinal().getProjString() != "!") {
563 } else {
564 return TL("No geo-conversion defined");
565 }
566 case SUMO_ATTR_COLOR:
567 return toString(getShapeColor());
568 case SUMO_ATTR_FILL:
569 return toString(myFill);
571 return toString(myLineWidth);
572 case SUMO_ATTR_LAYER:
573 return toString(getShapeLayer());
574 case SUMO_ATTR_TYPE:
575 return getShapeType();
577 return getShapeImgFile();
578 case SUMO_ATTR_ANGLE:
580 case SUMO_ATTR_GEO:
581 return toString(myGEO);
582 case SUMO_ATTR_NAME:
583 return getShapeName();
585 return toString(myClosedShape);
586 default:
587 return getCommonAttribute(key);
588 }
589}
590
591
592double
596
597
602
603
608
609
610void
611GNEPoly::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
612 if (value == getAttribute(key)) {
613 return; //avoid needless changes, later logic relies on the fact that attributes have changed
614 }
615 switch (key) {
616 case SUMO_ATTR_ID:
617 case SUMO_ATTR_SHAPE:
619 case SUMO_ATTR_COLOR:
620 case SUMO_ATTR_FILL:
622 case SUMO_ATTR_LAYER:
623 case SUMO_ATTR_TYPE:
625 case SUMO_ATTR_ANGLE:
626 case SUMO_ATTR_GEO:
627 case SUMO_ATTR_NAME:
629 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
630 break;
631 default:
632 setCommonAttribute(key, value, undoList);
633 break;
634 }
635}
636
637
638bool
639GNEPoly::isValid(SumoXMLAttr key, const std::string& value) {
640 switch (key) {
641 case SUMO_ATTR_ID:
643 case SUMO_ATTR_SHAPE:
645 // empty shapes AREN'T allowed
646 if (value.empty()) {
647 return false;
648 } else {
649 return canParse<PositionVector>(value);
650 }
651 case SUMO_ATTR_COLOR:
652 return canParse<RGBColor>(value);
653 case SUMO_ATTR_FILL:
654 return canParse<bool>(value);
656 return canParse<double>(value) && (parse<double>(value) >= 0);
657 case SUMO_ATTR_LAYER:
658 if (value.empty()) {
659 return true;
660 } else {
661 return canParse<double>(value);
662 }
663 case SUMO_ATTR_TYPE:
664 return true;
666 if (value == "") {
667 return true;
668 } else {
669 // check that image can be loaded
670 return GUITexturesHelper::getTextureID(value) != -1;
671 }
672 case SUMO_ATTR_ANGLE:
673 return canParse<double>(value);
674 case SUMO_ATTR_GEO:
675 return canParse<bool>(value);
676 case SUMO_ATTR_NAME:
679 return canParse<bool>(value);
680 default:
681 return isCommonAttributeValid(key, value);
682 }
683}
684
685
686bool
688 switch (key) {
689 case SUMO_ATTR_SHAPE:
690 if (GeoConvHelper::getFinal().getProjString() != "!") {
691 return myGEO == false;
692 } else {
693 return true;
694 }
695 case SUMO_ATTR_GEO:
696 return GeoConvHelper::getFinal().getProjString() != "!";
698 if (GeoConvHelper::getFinal().getProjString() != "!") {
699 return myGEO == true;
700 } else {
701 return false;
702 }
704 if (isTemplate()) {
705 return true;
706 } else {
707 return myShape.size() > 1;
708 }
709 default:
710 return true;
711 }
712}
713
714
715std::string
717 return getTagStr() + ": " + getID();
718}
719
720
721std::string
723 return getTagStr();
724}
725
726// ===========================================================================
727// private
728// ===========================================================================
729
730void
731GNEPoly::setAttribute(SumoXMLAttr key, const std::string& value) {
732 switch (key) {
733 case SUMO_ATTR_ID: {
734 // update microsimID
735 setAdditionalID(value);
736 // set named ID
737 myID = value;
738 break;
739 }
740 case SUMO_ATTR_SHAPE: {
741 // set new shape
742 myShape = parse<PositionVector>(value);
743 // set GEO shape
745 for (int i = 0; i < (int) myGeoShape.size(); i++) {
747 }
748 // disable simplified shape flag
749 mySimplifiedShape = false;
750 // update geometry
752 // update centering boundary
754 break;
755 }
756 case SUMO_ATTR_GEOSHAPE: {
757 // set new GEO shape
758 myGeoShape = parse<PositionVector>(value);
759 // set shape
761 for (int i = 0; i < (int) myShape.size(); i++) {
763 }
764 // disable simplified shape flag
765 mySimplifiedShape = false;
766 // update geometry
768 // update centering boundary
770 break;
771 }
772 case SUMO_ATTR_COLOR:
773 setShapeColor(parse<RGBColor>(value));
774 break;
775 case SUMO_ATTR_FILL:
776 myFill = parse<bool>(value);
778 break;
780 myLineWidth = parse<double>(value);
781 break;
782 case SUMO_ATTR_LAYER:
783 if (value.empty()) {
785 } else {
786 setShapeLayer(parse<double>(value));
787 }
788 break;
789 case SUMO_ATTR_TYPE:
790 setShapeType(value);
791 break;
793 setShapeImgFile(value);
794 // all textures must be refresh
796 break;
797 case SUMO_ATTR_ANGLE:
798 setShapeNaviDegree(parse<double>(value));
799 break;
800 case SUMO_ATTR_GEO:
801 myGEO = parse<bool>(value);
802 // update centering boundary
804 break;
805 case SUMO_ATTR_NAME:
806 setShapeName(value);
807 break;
809 myClosedShape = parse<bool>(value);
810 if (!isTemplate()) {
811 if (myClosedShape) {
814
815 } else {
818 }
819 // disable simplified shape flag
820 mySimplifiedShape = false;
821 // update geometry
823 // update centering boundary
825 }
826 break;
827 default:
828 setCommonAttribute(key, value);
829 break;
830 }
831}
832
833
834void
836 const RGBColor& color, const double exaggeration) const {
837 // check if we're drawing a polygon or a polyline
838 if (getFill()) {
839 // draw inner polygon
841 } else {
842 // push matrix
844 // set color
845 GLHelper::setColor(color);
846 // draw geometry (polyline)
848 // pop matrix
850 }
851}
852
853
854void
856 const RGBColor& color, const double exaggeration) const {
857 // push contour matrix
859 // translate to front
860 glTranslated(0, 0, 0.1);
861 // set color
862 GLHelper::setColor(color);
863 // draw polygon contour
865 // pop contour matrix
867}
868
869
870void
872 const RGBColor& color, const double exaggeration) const {
873 // draw shape points only in supermode network
875 // check if we're in move mode
877 // get geometry point sizes
878 const double geometryPointSize = s.neteditSizeSettings.polygonGeometryPointRadius * (moveMode ? 1 : 0.5);
879 // draw geometry points
880 GUIGeometry::drawGeometryPoints(d, myAdditionalGeometry.getShape(), color, geometryPointSize, exaggeration,
882 // draw dotted contours for geometry points if we're in move mode
883 if (moveMode) {
886 }
887 }
888}
889
890
891void
893 // get name position
895 // draw name
896 drawName(namePos, s.scale, s.polyName, s.angle);
897 // check if draw poly type
898 if (s.polyType.show(this)) {
899 const Position p = namePos + Position(0, -0.6 * s.polyType.size / s.scale);
901 }
902}
903
904/****************************************************************************/
@ 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.
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)
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
bool mySelected
boolean to check if this AC is selected (more quickly as checking GUIGlObjectStorage)
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
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
void addGLObjectIntoGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1440
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1450
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2193
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:224
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
Definition GNEPoly.cpp:716
std::string getParentName() const override
Returns the name of the parent object.
Definition GNEPoly.cpp:258
double getAttributeDouble(SumoXMLAttr key) const override
Definition GNEPoly.cpp:593
~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:639
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:722
void fixAdditionalProblem() override
fix additional problem (must be reimplemented in all detector children)
Definition GNEPoly.cpp:230
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:892
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:358
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:437
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point
Definition GNEPoly.cpp:458
std::string getAttribute(SumoXMLAttr key) const override
Definition GNEPoly.cpp:550
bool checkDrawMoveContour() const override
check if draw move contour (red)
Definition GNEPoly.cpp:242
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:218
Position getAttributePosition(SumoXMLAttr key) const override
Definition GNEPoly.cpp:599
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:611
void deleteGeometryPoint(const Position &pos, bool allowUndo=true)
delete the geometry point closest to the given pos
Definition GNEPoly.cpp:374
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:871
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GNEPoly.cpp:311
PositionVector getAttributePositionVector(SumoXMLAttr key) const override
Definition GNEPoly.cpp:605
void drawPolygon(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw polygon
Definition GNEPoly.cpp:835
bool isAttributeEnabled(SumoXMLAttr key) const override
Definition GNEPoly.cpp:687
void drawPolygonContour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw contour
Definition GNEPoly.cpp:855
CommonXMLStructure::SumoBaseObject * getSumoBaseObject() const
get SUMOBaseObject with all polygon attributes
Definition GNEPoly.cpp:530
bool isPolygonClosed() const
check if polygon is closed
Definition GNEPoly.cpp:410
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GNEPoly.cpp:264
void simplifyShape(bool allowUndo=true)
replace the current shape with a rectangle
Definition GNEPoly.cpp:498
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:236
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:416
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
GNEViewParent * getViewParent() const
get the net object
bool checkOverLockedElement(const GUIGlObject *GLObject, const bool isSelected) const
check if given element is locked (used for drawing select and delete contour)
GNEUndoList * getUndoList() const
get the undoList object
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 setShapeName(const std::string &name)
Sets a new shape name.
Definition Shape.cpp:174
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 std::string & getShapeName() const
Returns the name of the Shape.
Definition Shape.cpp:133
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