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
42#ifdef _MSC_VER
43#pragma warning(push)
44#pragma warning(disable: 4355) // mask warning about "this" in initializers
45#endif
47 TesselatedPolygon("", "", RGBColor::BLACK, {}, false, false, 0, 0, 0, "", "", Parameterised::Map()),
48 GNEAdditional(net, tag),
49myMoveElementShape(new GNEMoveElementShape(this)) {
50}
51
52
53GNEPoly::GNEPoly(const std::string& id, GNENet* net, FileBucket* fileBucket, const std::string& type, const PositionVector& shape,
54 bool geo, bool fill, double lineWidth, const RGBColor& color, double layer, double angle, const std::string& imgFile,
55 const std::string& name, const Parameterised::Map& parameters) :
56 TesselatedPolygon(id, type, color, shape, geo, fill, lineWidth, layer, angle, imgFile, "", parameters),
57 GNEAdditional(id, net, SUMO_TAG_POLY, fileBucket, name),
58 myMoveElementShape(new GNEMoveElementShape(this, myShape, false)),
59 myClosedShape(shape.isClosed()) {
60 // check if imgFile is valid
61 if (!imgFile.empty() && GUITexturesHelper::getTextureID(imgFile) == -1) {
63 }
64 // set GEO shape
66 if (geo) {
67 for (int i = 0; i < (int) myGeoShape.size(); i++) {
69 }
70 } else {
71 for (int i = 0; i < (int) myGeoShape.size(); i++) {
73 }
74 }
75 // update centering boundary without updating grid
77 // update geometry
79}
80
81
82GNEPoly::GNEPoly(SumoXMLTag tag, const std::string& id, GNENet* net, FileBucket* fileBucket, const PositionVector& shape,
83 bool geo, const std::string& name, const Parameterised::Map& parameters) :
84 TesselatedPolygon(id, getJuPedSimType(tag), getJuPedSimColor(tag), shape, geo, getJuPedSimFill(tag), 1,
85 getJuPedSimLayer(tag), 0, "", "", parameters),
86 GNEAdditional(id, net, tag, fileBucket, name),
87 myMoveElementShape(new GNEMoveElementShape(this, myShape, (tag == GNE_TAG_JPS_WALKABLEAREA) || (tag == GNE_TAG_JPS_OBSTACLE))),
88 myClosedShape(shape.isClosed()),
89 mySimplifiedShape(false) {
90 // set GEO shape
92 if (geo) {
93 for (int i = 0; i < (int) myGeoShape.size(); i++) {
95 }
96 } else {
97 for (int i = 0; i < (int) myGeoShape.size(); i++) {
99 }
100 }
101 // update centering boundary without updating grid
103 // update geometry
105}
106#ifdef _MSC_VER
107#pragma warning(pop)
108#endif
109
110
114
115
120
121
124 return this;
125}
126
127
128const Parameterised*
130 return this;
131}
132
133
134std::string
136 return "";
137}
138
139
140void
142 // just update polygon geometry
144 myTesselation.clear();
145}
146
147
152
153
154double
156 return s.polySize.getExaggeration(s, this);
157}
158
159
160void
161GNEPoly::updateCenteringBoundary(const bool updateGrid) {
162 // Remove object from net
163 if (updateGrid) {
165 }
166 // use shape as boundary
168 // grow boundary
170 // add object into net
171 if (updateGrid) {
173 }
174}
175
176
177void
178GNEPoly::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
179 // nothing to split
180}
181
182
183void
185 device.openTag(SUMO_TAG_POLY);
186 // write common additional attributes
188 // write specific attributes
189 PositionVector shape = getShape();
190 if (myGEO) {
191 device.writeAttr(SUMO_ATTR_GEO, true);
192 for (int i = 0; i < (int) shape.size(); i++) {
194 }
195 }
196 if (getShapeType().size() > 0) {
198 }
201 if (getLineWidth() != 1) {
203 }
205
207 device.writeAttr(SUMO_ATTR_SHAPE, shape);
208 device.setPrecision();
211 }
214 }
215 writeParams(device);
216 device.closeTag();
217}
218
219
220bool
222 return true;
223}
224
225
226std::string
228 return "";
229}
230
231
232void
234 // nothing to fix
235}
236
237
240 return GUIGlObject::getGlID();
241}
242
243
244bool
246 // get edit modes
247 const auto& editModes = myNet->getViewNet()->getEditModes();
248 // check if we're in move mode
249 if (!myNet->getViewNet()->isCurrentlyMovingElements() && editModes.isCurrentSupermodeNetwork() &&
251 (editModes.networkEditMode == NetworkEditMode::NETWORK_MOVE) && myNet->getViewNet()->checkOverLockedElement(this, mySelected)) {
252 // only move the first element
254 } else {
255 return false;
256 }
257}
258
259
260std::string
262 return myNet->getMicrosimID();
263}
264
265
268 // create popup
269 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, this);
270 // build common options
272 FXMenuCommand* simplifyShape = GUIDesigns::buildFXMenuCommand(ret, TL("Simplify Shape"), TL("Replace current shape with a rectangle"), nullptr, &parent, MID_GNE_POLYGON_SIMPLIFY_SHAPE);
273 // disable simplify shape if polygon was already simplified
274 if (mySimplifiedShape || myShape.size() <= 2) {
275 simplifyShape->disable();
276 }
277 // only allow open/close for non juPedSim polygons
279 if (myShape.isClosed()) {
280 GUIDesigns::buildFXMenuCommand(ret, TL("Open shape"), TL("Open polygon's shape"), nullptr, &parent, MID_GNE_POLYGON_OPEN);
281 } else {
282 GUIDesigns::buildFXMenuCommand(ret, TL("Close shape"), TL("Close polygon's shape"), nullptr, &parent, MID_GNE_POLYGON_CLOSE);
283 }
284 }
285 GUIDesigns::buildFXMenuCommand(ret, TL("Select elements within polygon"), TL("Select elements within polygon boundary"), nullptr, &parent, MID_GNE_POLYGON_SELECT);
286 if (myShape.size() > 3) {
287 GUIDesigns::buildFXMenuCommand(ret, TL("Triangulate polygon"), TL("Convert the current polygon in triangles"), nullptr, &parent, MID_GNE_POLYGON_TRIANGULATE);
288 }
289 // create a extra FXMenuCommand if mouse is over a vertex
290 const int index = getVertexIndex(myNet->getViewNet()->getPositionInformation(), false);
291 if (index != -1) {
292 // add separator
293 new FXMenuSeparator(ret);
294 // check if we're in network mode
296 GUIDesigns::buildFXMenuCommand(ret, "Set custom Geometry Point", nullptr, &parent, MID_GNE_CUSTOM_GEOMETRYPOINT);
297 }
298 FXMenuCommand* removeGeometryPoint = GUIDesigns::buildFXMenuCommand(ret, TL("Remove geometry point"), TL("Remove geometry point under mouse"), nullptr, &parent, MID_GNE_POLYGON_DELETE_GEOMETRY_POINT);
299 FXMenuCommand* setFirstPoint = GUIDesigns::buildFXMenuCommand(ret, TL("Set first geometry point"), TL("Set first geometry point"), nullptr, &parent, MID_GNE_POLYGON_SET_FIRST_POINT);
300 // disable setFirstPoint if shape only have three points
301 if ((myShape.isClosed() && (myShape.size() <= 4)) || (!myShape.isClosed() && (myShape.size() <= 2))) {
302 removeGeometryPoint->disable();
303 }
304 // disable setFirstPoint if mouse is over first point
305 if (index == 0) {
306 setFirstPoint->disable();
307 }
308 }
309 return ret;
310}
311
312
313void
315 // first check if poly can be drawn
318 GUIPolygon::checkDraw(s, this, this)) {
319 // draw boundary
320 const auto boundary = getCenteringBoundary();
322 // get exaggeration
323 const double polyExaggeration = getExaggeration(s);
324 // get detail level
325 const auto d = s.getDetailLevel(polyExaggeration);
326 // draw geometry only if we'rent in drawForObjectUnderCursor mode
327 if (s.checkDrawPoly(boundary, isAttributeCarrierSelected())) {
328 // get colors
330 // push layer matrix
332 // translate to front
334 // draw polygon
335 drawPolygon(s, d, color, polyExaggeration);
336 // draw contour if don't move whole polygon
338 // get darker color
339 const RGBColor darkerColor = color.changedBrightness(-32);
340 // draw contour
341 drawPolygonContour(s, d, darkerColor, polyExaggeration);
342 // draw geometry points
343 drawGeometryPoints(s, d, darkerColor, polyExaggeration);
344 }
345 // pop layer matrix
347 // draw name and type
349 // draw lock icon
351 // draw dotted contour
353 }
354 // calculate contour
355 calculateContourPolygons(s, d, getShapeLayer(), polyExaggeration, getFill());
356 }
357}
358
359
360int
361GNEPoly::getVertexIndex(Position pos, bool snapToGrid) {
362 // check if position has to be snapped to grid
363 if (snapToGrid) {
364 pos = myNet->getViewNet()->snapToActiveGrid(pos);
365 }
366 // first check if vertex already exists
367 for (const auto& shapePosition : myShape) {
368 if (shapePosition.distanceTo2D(pos) < myNet->getViewNet()->getVisualisationSettings().neteditSizeSettings.polygonGeometryPointRadius) {
369 return myShape.indexOfClosest(shapePosition);
370 }
371 }
372 return -1;
373}
374
375
376void
377GNEPoly::deleteGeometryPoint(const Position& pos, bool allowUndo) {
378 if (myShape.size() > 1) {
379 // obtain index
380 PositionVector modifiedShape = myShape;
381 int index = modifiedShape.indexOfClosest(pos);
382 // remove point dependending of
383 if (myShape.isClosed() && (index == 0 || index == (int)modifiedShape.size() - 1) && (myShape.size() > 2)) {
384 modifiedShape.erase(modifiedShape.begin());
385 modifiedShape.erase(modifiedShape.end() - 1);
386 modifiedShape.push_back(modifiedShape.front());
387 } else {
388 modifiedShape.erase(modifiedShape.begin() + index);
389 }
390 // set new shape depending of allowUndo
391 if (allowUndo) {
392 myNet->getUndoList()->begin(this, "delete geometry point");
394 myNet->getUndoList()->end();
395 } else {
396 // first remove object from grid due shape is used for boundary
398 // set new shape
399 myShape = modifiedShape;
400 // disable simplified shape flag
401 mySimplifiedShape = false;
402 // add object into grid again
404 }
405 myTesselation.clear();
406 } else {
407 WRITE_WARNING(TL("Number of remaining points insufficient"))
408 }
409}
410
411
412bool
414 return myShape.isClosed();
415}
416
417
418void
419GNEPoly::openPolygon(bool allowUndo) {
420 // only open if shape is closed
421 if (myShape.isClosed()) {
422 if (allowUndo) {
423 myNet->getUndoList()->begin(this, "open polygon");
425 myNet->getUndoList()->end();
426 } else {
427 myShape.pop_back();
428 // disable simplified shape flag
429 mySimplifiedShape = false;
430 // update geometry to avoid grabbing Problems
432 }
433 } else {
434 WRITE_WARNING(TL("Polygon already opened"))
435 }
436}
437
438
439void
440GNEPoly::closePolygon(bool allowUndo) {
441 // only close if shape is opened
442 if (!myShape.isClosed()) {
443 if (allowUndo) {
444 myNet->getUndoList()->begin(this, "close shape");
446 myNet->getUndoList()->end();
447 } else {
449 // disable simplified shape flag
450 mySimplifiedShape = false;
451 // update geometry to avoid grabbing Problems
453 }
454 } else {
455 WRITE_WARNING(TL("Polygon already closed"))
456 }
457}
458
459
460void
461GNEPoly::changeFirstGeometryPoint(int oldIndex, bool allowUndo) {
462 // check that old index is correct
463 if (oldIndex >= (int)myShape.size()) {
464 throw InvalidArgument("Invalid old Index");
465 } else if (oldIndex == 0) {
466 WRITE_WARNING(TL("Selected point must be different of the first point"))
467 } else {
468 // Configure new shape
469 PositionVector newShape;
470 for (int i = oldIndex; i < (int)myShape.size(); i++) {
471 newShape.push_back(myShape[i]);
472 }
473 if (myShape.isClosed()) {
474 for (int i = 1; i < oldIndex; i++) {
475 newShape.push_back(myShape[i]);
476 }
477 newShape.push_back(newShape.front());
478 } else {
479 for (int i = 0; i < oldIndex; i++) {
480 newShape.push_back(myShape[i]);
481 }
482 }
483 // set new rotated shape
484 if (allowUndo) {
485 myNet->getUndoList()->begin(this, "change first geometry point");
487 myNet->getUndoList()->end();
488 } else {
489 // set new shape
490 myShape = newShape;
491 // disable simplified shape flag
492 mySimplifiedShape = false;
493 // update geometry to avoid grabbing Problems
495 }
496 }
497}
498
499
500void
501GNEPoly::simplifyShape(bool allowUndo) {
502 if (!mySimplifiedShape && myShape.size() > 2) {
503 const Boundary b = myShape.getBoxBoundary();
504 // create a square as simplified shape
505 PositionVector simplifiedShape;
506 simplifiedShape.push_back(Position(b.xmin(), b.ymin()));
507 simplifiedShape.push_back(Position(b.xmin(), b.ymax()));
508 simplifiedShape.push_back(Position(b.xmax(), b.ymax()));
509 simplifiedShape.push_back(Position(b.xmax(), b.ymin()));
510 if (myShape.isClosed()) {
511 simplifiedShape.push_back(simplifiedShape[0]);
512 }
513 // set new shape depending of allowUndo
514 if (allowUndo) {
515 myNet->getUndoList()->begin(this, "simplify shape");
517 myNet->getUndoList()->end();
518 } else {
519 // set new shape
520 myShape = simplifiedShape;
521 // update geometry to avoid grabbing Problems
523 }
524 // change flag after setting simplified shape
525 mySimplifiedShape = true;
526 } else {
527 WRITE_WARNING(TL("Polygon already simplified"))
528 }
529}
530
531
535 polygonBaseObject->setTag(myTagProperty->getTag());
536 // fill attributes
537 polygonBaseObject->addStringAttribute(SUMO_ATTR_ID, myID);
539 polygonBaseObject->addBoolAttribute(SUMO_ATTR_GEO, myGEO);
540 polygonBaseObject->addBoolAttribute(SUMO_ATTR_FILL, myFill);
542 polygonBaseObject->addColorAttribute(SUMO_ATTR_COLOR, getShapeColor());
543 polygonBaseObject->addStringAttribute(SUMO_ATTR_TYPE, getShapeType());
544 polygonBaseObject->addDoubleAttribute(SUMO_ATTR_LAYER, getShapeLayer());
548 return polygonBaseObject;
549}
550
551
552std::string
554 switch (key) {
555 case SUMO_ATTR_ID:
556 return myID;
557 case SUMO_ATTR_SHAPE:
558 if ((GeoConvHelper::getFinal().getProjString() != "!") && myGEO) {
559 return TL("Using GEO Shape");
560 } else {
561 return toString(myShape);
562 }
564 if (GeoConvHelper::getFinal().getProjString() != "!") {
566 } else {
567 return TL("No geo-conversion defined");
568 }
569 case SUMO_ATTR_COLOR:
570 return toString(getShapeColor());
571 case SUMO_ATTR_FILL:
572 return toString(myFill);
574 return toString(myLineWidth);
575 case SUMO_ATTR_LAYER:
576 return toString(getShapeLayer());
577 case SUMO_ATTR_TYPE:
578 return getShapeType();
580 return getShapeImgFile();
581 case SUMO_ATTR_ANGLE:
583 case SUMO_ATTR_GEO:
584 return toString(myGEO);
585 case SUMO_ATTR_NAME:
586 return myAdditionalName;
588 return toString(myClosedShape);
589 default:
590 return getCommonAttribute(key);
591 }
592}
593
594
595double
599
600
605
606
611
612
613void
614GNEPoly::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
615 if (value == getAttribute(key)) {
616 return; //avoid needless changes, later logic relies on the fact that attributes have changed
617 }
618 switch (key) {
619 case SUMO_ATTR_ID:
620 case SUMO_ATTR_SHAPE:
622 case SUMO_ATTR_COLOR:
623 case SUMO_ATTR_FILL:
625 case SUMO_ATTR_LAYER:
626 case SUMO_ATTR_TYPE:
628 case SUMO_ATTR_ANGLE:
629 case SUMO_ATTR_GEO:
630 case SUMO_ATTR_NAME:
632 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
633 break;
634 default:
635 setCommonAttribute(key, value, undoList);
636 break;
637 }
638}
639
640
641bool
642GNEPoly::isValid(SumoXMLAttr key, const std::string& value) {
643 switch (key) {
644 case SUMO_ATTR_ID:
646 case SUMO_ATTR_SHAPE:
648 // empty shapes AREN'T allowed
649 if (value.empty()) {
650 return false;
651 } else {
652 return canParse<PositionVector>(value);
653 }
654 case SUMO_ATTR_COLOR:
655 return canParse<RGBColor>(value);
656 case SUMO_ATTR_FILL:
657 return canParse<bool>(value);
659 return canParse<double>(value) && (parse<double>(value) >= 0);
660 case SUMO_ATTR_LAYER:
661 if (value.empty()) {
662 return true;
663 } else {
664 return canParse<double>(value);
665 }
666 case SUMO_ATTR_TYPE:
667 return true;
669 if (value == "") {
670 return true;
671 } else {
672 // check that image can be loaded
673 return GUITexturesHelper::getTextureID(value) != -1;
674 }
675 case SUMO_ATTR_ANGLE:
676 return canParse<double>(value);
677 case SUMO_ATTR_GEO:
678 return canParse<bool>(value);
679 case SUMO_ATTR_NAME:
682 return canParse<bool>(value);
683 default:
684 return isCommonAttributeValid(key, value);
685 }
686}
687
688
689bool
691 switch (key) {
692 case SUMO_ATTR_SHAPE:
693 if (GeoConvHelper::getFinal().getProjString() != "!") {
694 return myGEO == false;
695 } else {
696 return true;
697 }
698 case SUMO_ATTR_GEO:
699 return GeoConvHelper::getFinal().getProjString() != "!";
701 if (GeoConvHelper::getFinal().getProjString() != "!") {
702 return myGEO == true;
703 } else {
704 return false;
705 }
707 if (isTemplate()) {
708 return true;
709 } else {
710 return myShape.size() > 1;
711 }
712 default:
713 return true;
714 }
715}
716
717
718std::string
720 return getTagStr() + ": " + getID();
721}
722
723
724std::string
726 return getTagStr();
727}
728
729// ===========================================================================
730// private
731// ===========================================================================
732
733void
734GNEPoly::setAttribute(SumoXMLAttr key, const std::string& value) {
735 switch (key) {
736 case SUMO_ATTR_ID: {
737 // update microsimID
738 setAdditionalID(value);
739 // set named ID
740 myID = value;
741 break;
742 }
743 case SUMO_ATTR_SHAPE: {
744 // set new shape
745 myShape = parse<PositionVector>(value);
746 // set GEO shape
748 for (int i = 0; i < (int) myGeoShape.size(); i++) {
750 }
751 // disable simplified shape flag
752 mySimplifiedShape = false;
753 // update geometry
755 // update centering boundary
757 break;
758 }
759 case SUMO_ATTR_GEOSHAPE: {
760 // set new GEO shape
761 myGeoShape = parse<PositionVector>(value);
762 // set shape
764 for (int i = 0; i < (int) myShape.size(); i++) {
766 }
767 // disable simplified shape flag
768 mySimplifiedShape = false;
769 // update geometry
771 // update centering boundary
773 break;
774 }
775 case SUMO_ATTR_COLOR:
776 setShapeColor(parse<RGBColor>(value));
777 break;
778 case SUMO_ATTR_FILL:
779 myFill = parse<bool>(value);
781 break;
783 myLineWidth = parse<double>(value);
784 break;
785 case SUMO_ATTR_LAYER:
786 if (value.empty()) {
788 } else {
789 setShapeLayer(parse<double>(value));
790 }
791 break;
792 case SUMO_ATTR_TYPE:
793 setShapeType(value);
794 break;
796 setShapeImgFile(value);
797 // all textures must be refresh
799 break;
800 case SUMO_ATTR_ANGLE:
801 setShapeNaviDegree(parse<double>(value));
802 break;
803 case SUMO_ATTR_GEO:
804 myGEO = parse<bool>(value);
805 // update centering boundary
807 break;
808 case SUMO_ATTR_NAME:
809 myAdditionalName = value;
810 break;
812 myClosedShape = parse<bool>(value);
813 if (!isTemplate()) {
814 if (myClosedShape) {
817
818 } else {
821 }
822 // disable simplified shape flag
823 mySimplifiedShape = false;
824 // update geometry
826 // update centering boundary
828 }
829 break;
830 default:
831 setCommonAttribute(key, value);
832 break;
833 }
834}
835
836
837void
839 const RGBColor& color, const double exaggeration) const {
840 // check if we're drawing a polygon or a polyline
841 if (getFill()) {
842 // draw inner polygon
844 } else {
845 // push matrix
847 // set color
848 GLHelper::setColor(color);
849 // draw geometry (polyline)
851 // pop matrix
853 }
854}
855
856
857void
859 const RGBColor& color, const double exaggeration) const {
860 // push contour matrix
862 // translate to front
863 glTranslated(0, 0, 0.1);
864 // set color
865 GLHelper::setColor(color);
866 // draw polygon contour
868 // pop contour matrix
870}
871
872
873void
875 const RGBColor& color, const double exaggeration) const {
876 // draw shape points only in supermode network
878 // check if we're in move mode
880 // get geometry point sizes
881 const double geometryPointSize = s.neteditSizeSettings.polygonGeometryPointRadius * (moveMode ? 1 : 0.5);
882 // draw geometry points
883 GUIGeometry::drawGeometryPoints(d, myAdditionalGeometry.getShape(), color, geometryPointSize, exaggeration,
885 // draw dotted contours for geometry points if we're in move mode
886 if (moveMode) {
889 }
890 }
891}
892
893
894void
896 // get name position
898 // draw name
899 drawName(namePos, s.scale, s.polyName, s.angle);
900 // check if draw poly type
901 if (s.polyType.show(this)) {
902 const Position p = namePos + Position(0, -0.6 * s.polyType.size / s.scale);
904 }
905}
906
907/****************************************************************************/
@ 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:49
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:1449
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1459
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:123
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:227
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
Definition GNEPoly.cpp:719
std::string getParentName() const override
Returns the name of the parent object.
Definition GNEPoly.cpp:261
double getAttributeDouble(SumoXMLAttr key) const override
Definition GNEPoly.cpp:596
~GNEPoly()
Destructor.
Definition GNEPoly.cpp:111
bool isValid(SumoXMLAttr key, const std::string &value) override
method for checking if the key and their conrrespond attribute are valids
Definition GNEPoly.cpp:642
void updateGeometry() override
update pre-computed geometry information
Definition GNEPoly.cpp:141
GNEMoveElementShape * myMoveElementShape
move element shape
Definition GNEPoly.h:253
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
Definition GNEPoly.cpp:725
void fixAdditionalProblem() override
fix additional problem (must be reimplemented in all detector children)
Definition GNEPoly.cpp:233
void writeAdditional(OutputDevice &device) const override
write additional element into a xml file
Definition GNEPoly.cpp:184
void drawPolygonNameAndType(const GUIVisualizationSettings &s) const
draw polygon name and type
Definition GNEPoly.cpp:895
GNEPoly(SumoXMLTag tag, GNENet *net)
default Constructor
Definition GNEPoly.cpp:46
GNEMoveElement * getMoveElement() const override
methods to retrieve the elements linked to this poly
Definition GNEPoly.cpp:117
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:361
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:155
void closePolygon(bool allowUndo=true)
close polygon
Definition GNEPoly.cpp:440
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point
Definition GNEPoly.cpp:461
std::string getAttribute(SumoXMLAttr key) const override
Definition GNEPoly.cpp:553
bool checkDrawMoveContour() const override
check if draw move contour (red)
Definition GNEPoly.cpp:245
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:221
Position getAttributePosition(SumoXMLAttr key) const override
Definition GNEPoly.cpp:602
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:614
void deleteGeometryPoint(const Position &pos, bool allowUndo=true)
delete the geometry point closest to the given pos
Definition GNEPoly.cpp:377
Position getPositionInView() const override
Returns position of shape in view.
Definition GNEPoly.cpp:149
void drawGeometryPoints(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw geometry points
Definition GNEPoly.cpp:874
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GNEPoly.cpp:314
PositionVector getAttributePositionVector(SumoXMLAttr key) const override
Definition GNEPoly.cpp:608
void drawPolygon(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw polygon
Definition GNEPoly.cpp:838
bool isAttributeEnabled(SumoXMLAttr key) const override
Definition GNEPoly.cpp:690
void drawPolygonContour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw contour
Definition GNEPoly.cpp:858
CommonXMLStructure::SumoBaseObject * getSumoBaseObject() const
get SUMOBaseObject with all polygon attributes
Definition GNEPoly.cpp:533
bool isPolygonClosed() const
check if polygon is closed
Definition GNEPoly.cpp:413
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GNEPoly.cpp:267
void simplifyShape(bool allowUndo=true)
replace the current shape with a rectangle
Definition GNEPoly.cpp:501
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList) override
split geometry
Definition GNEPoly.cpp:178
void updateCenteringBoundary(const bool updateGrid) override
update centering boundary (implies change in RTREE)
Definition GNEPoly.cpp:161
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition GNEPoly.cpp:239
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition GNEPoly.cpp:135
void openPolygon(bool allowUndo=true)
open polygon
Definition GNEPoly.cpp:419
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:124
static const std::vector< SumoXMLTag > polygons
polygon namespace
Static storage of an output device and its base (abstract) implementation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const ATTR_TYPE &attr, const T &val, const bool isNull=false)
writes a named attribute
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