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-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// A class for visualizing and editing POIS in netedit (adapted from
19// GUIPolygon and NLHandler)
20/****************************************************************************/
21#include <config.h>
22
23#include <string>
26#include <netedit/GNENet.h>
27#include <netedit/GNEUndoList.h>
28#include <netedit/GNEViewNet.h>
36
37#include "GNEPoly.h"
38
39
40// ===========================================================================
41// method definitions
42// ===========================================================================
43
45 TesselatedPolygon("", "", RGBColor::BLACK, {}, false, false, 0, 0, 0, "", false, "", Parameterised::Map()),
46 GNEAdditional("", net, GLO_POLYGON, tag, GUIIconSubSys::getIcon(GUIIcon::POLY), "", {}, {}, {}, {}, {}, {}),
47mySimplifiedShape(false) {
48 // reset default values
50}
51
52
53GNEPoly::GNEPoly(GNENet* net, const std::string& id, const std::string& type, const PositionVector& shape, bool geo, bool fill, double lineWidth,
54 const RGBColor& color, double layer, double angle, const std::string& imgFile, bool relativePath, const std::string& name,
55 const Parameterised::Map& parameters) :
56 TesselatedPolygon(id, type, color, shape, geo, fill, lineWidth, layer, angle, imgFile, relativePath, name, parameters),
57 GNEAdditional(id, net, GLO_POLYGON, SUMO_TAG_POLY, GUIIconSubSys::getIcon(GUIIcon::POLY), "", {}, {}, {}, {}, {}, {}),
58mySimplifiedShape(false) {
59 // check if imgFile is valid
60 if (!imgFile.empty() && GUITexturesHelper::getTextureID(imgFile) == -1) {
62 }
63 // set GEO shape
65 if (geo) {
66 for (int i = 0; i < (int) myGeoShape.size(); i++) {
68 }
69 } else {
70 for (int i = 0; i < (int) myGeoShape.size(); i++) {
72 }
73 }
74 // update centering boundary without updating grid
76 // update geometry
78}
79
80
81GNEPoly::GNEPoly(SumoXMLTag tag, GNENet* net, const std::string& id, const PositionVector& shape, bool geo, const std::string& name,
82 const Parameterised::Map& parameters) :
83 TesselatedPolygon(id, getJuPedSimType(tag), getJuPedSimColor(tag), shape, geo, getJuPedSimFill(tag), 1,
84 getJuPedSimLayer(tag), 0, "", false, name, parameters),
85 GNEAdditional(id, net, getJuPedSimGLO(tag), tag, getJuPedSimIcon(tag), "", {}, {}, {}, {}, {}, {}),
86mySimplifiedShape(false) {
87 // set GEO shape
89 if (geo) {
90 for (int i = 0; i < (int) myGeoShape.size(); i++) {
92 }
93 } else {
94 for (int i = 0; i < (int) myGeoShape.size(); i++) {
96 }
97 }
98 // update centering boundary without updating grid
100 // update geometry
102}
103
104
106
107
110 // edit depending if shape is blocked
112 // move entire shape
113 return new GNEMoveOperation(this, myShape);
114 } else {
115 // continue depending of tag
116 switch (getTagProperty().getTag()) {
119 // calculate move shape operation maintain shape closed
120 return calculateMoveShapeOperation(this, myShape, true);
121 default:
122 // calculate move shape operation
123 return calculateMoveShapeOperation(this, myShape, false);
124 }
125 }
126}
127
128
129void
130GNEPoly::removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList) {
131 // get original shape
132 PositionVector shape = myShape;
133 // check shape size
134 if (shape.size() > 2) {
135 // obtain index
136 int index = shape.indexOfClosest(clickedPosition);
137 // get snap radius
139 // check if we have to create a new index
140 if ((index != -1) && shape[index].distanceSquaredTo2D(clickedPosition) < (snap_radius * snap_radius)) {
141 // remove geometry point
142 shape.erase(shape.begin() + index);
143 // commit new shape
144 undoList->begin(this, "remove geometry point of " + getTagStr());
146 undoList->end();
147 }
148 }
149}
150
151
152std::string
154 return "";
155}
156
157
158void
160 // just update polygon geometry
162 myTesselation.clear();
163}
164
165
170
171
172double
174 return s.polySize.getExaggeration(s, this);
175}
176
177
178void
179GNEPoly::updateCenteringBoundary(const bool updateGrid) {
180 // Remove object from net
181 if (updateGrid) {
183 }
184 // use shape as boundary
186 // grow boundary
188 // add object into net
189 if (updateGrid) {
191 }
192}
193
194
195void
196GNEPoly::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
197 // nothing to split
198}
199
200
201void
203 writeXML(device, myGEO);
204}
205
206
207bool
209 return true;
210}
211
212
213std::string
215 return "";
216}
217
218
219void
221 // nothing to fix
222}
223
224
227 return GUIGlObject::getGlID();
228}
229
230
231bool
233 // get edit modes
234 const auto& editModes = myNet->getViewNet()->getEditModes();
235 // check if we're in move mode
236 if (!myNet->getViewNet()->isCurrentlyMovingElements() && editModes.isCurrentSupermodeNetwork() &&
238 (editModes.networkEditMode == NetworkEditMode::NETWORK_MOVE) && myNet->getViewNet()->checkOverLockedElement(this, mySelected)) {
239 // only move the first element
241 } else {
242 return false;
243 }
244}
245
246
247std::string
249 return myNet->getMicrosimID();
250}
251
252
255 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
256 buildPopupHeader(ret, app);
259 // build selection and show parameters menu
262 buildPositionCopyEntry(ret, app);
263 new FXMenuSeparator(ret);
264 FXMenuCommand* simplifyShape = GUIDesigns::buildFXMenuCommand(ret, TL("Simplify Shape"), TL("Replace current shape with a rectangle"), nullptr, &parent, MID_GNE_POLYGON_SIMPLIFY_SHAPE);
265 // disable simplify shape if polygon was already simplified
266 if (mySimplifiedShape || myShape.size() <= 2) {
267 simplifyShape->disable();
268 }
269 // only allow open/close for non juPedSim polygons
271 if (myShape.isClosed()) {
272 GUIDesigns::buildFXMenuCommand(ret, TL("Open shape"), TL("Open polygon's shape"), nullptr, &parent, MID_GNE_POLYGON_OPEN);
273 } else {
274 GUIDesigns::buildFXMenuCommand(ret, TL("Close shape"), TL("Close polygon's shape"), nullptr, &parent, MID_GNE_POLYGON_CLOSE);
275 }
276 }
277 GUIDesigns::buildFXMenuCommand(ret, TL("Select elements within polygon"), TL("Select elements within polygon boundary"), nullptr, &parent, MID_GNE_POLYGON_SELECT);
278 // add separator
279 new FXMenuSeparator(ret);
280 // create a extra FXMenuCommand if mouse is over a vertex
281 const int index = getVertexIndex(myNet->getViewNet()->getPositionInformation(), false);
282 if (index != -1) {
283 // check if we're in network mode
285 GUIDesigns::buildFXMenuCommand(ret, "Set custom Geometry Point", nullptr, &parent, MID_GNE_CUSTOM_GEOMETRYPOINT);
286 }
287 FXMenuCommand* removeGeometryPoint = GUIDesigns::buildFXMenuCommand(ret, TL("Remove geometry point"), TL("Remove geometry point under mouse"), nullptr, &parent, MID_GNE_POLYGON_DELETE_GEOMETRY_POINT);
288 FXMenuCommand* setFirstPoint = GUIDesigns::buildFXMenuCommand(ret, TL("Set first geometry point"), TL("Set first geometry point"), nullptr, &parent, MID_GNE_POLYGON_SET_FIRST_POINT);
289 // disable setFirstPoint if shape only have three points
290 if ((myShape.isClosed() && (myShape.size() <= 4)) || (!myShape.isClosed() && (myShape.size() <= 2))) {
291 removeGeometryPoint->disable();
292 }
293 // disable setFirstPoint if mouse is over first point
294 if (index == 0) {
295 setFirstPoint->disable();
296 }
297 }
298 return ret;
299}
300
301
302void
304 // first check if poly can be drawn
307 GUIPolygon::checkDraw(s, this, this)) {
308 // draw boundary
309 const auto boundary = getCenteringBoundary();
311 // get exaggeration
312 const double polyExaggeration = getExaggeration(s);
313 // get detail level
314 const auto d = s.getDetailLevel(polyExaggeration);
315 // draw geometry only if we'rent in drawForObjectUnderCursor mode
316 if (s.checkDrawPoly(boundary, isAttributeCarrierSelected())) {
317 // get colors
319 // push layer matrix
321 // translate to front
323 // draw polygon
324 drawPolygon(s, d, color, polyExaggeration);
325 // draw contour if don't move whole polygon
327 // get darker color
328 const RGBColor darkerColor = color.changedBrightness(-32);
329 // draw contour
330 drawPolygonContour(s, d, darkerColor, polyExaggeration);
331 // draw geometry points
332 drawGeometryPoints(s, d, darkerColor, polyExaggeration);
333 }
334 // pop layer matrix
336 // draw name and type
338 // draw lock icon
340 // draw dotted contour
342 }
343 // calculate contour
344 calculateContourPolygons(s, d, getShapeLayer(), polyExaggeration, getFill());
345 }
346}
347
348
349int
350GNEPoly::getVertexIndex(Position pos, bool snapToGrid) {
351 // check if position has to be snapped to grid
352 if (snapToGrid) {
353 pos = myNet->getViewNet()->snapToActiveGrid(pos);
354 }
355 // first check if vertex already exists
356 for (const auto& shapePosition : myShape) {
357 if (shapePosition.distanceTo2D(pos) < myNet->getViewNet()->getVisualisationSettings().neteditSizeSettings.polygonGeometryPointRadius) {
358 return myShape.indexOfClosest(shapePosition);
359 }
360 }
361 return -1;
362}
363
364
365void
366GNEPoly::deleteGeometryPoint(const Position& pos, bool allowUndo) {
367 if (myShape.size() > 1) {
368 // obtain index
369 PositionVector modifiedShape = myShape;
370 int index = modifiedShape.indexOfClosest(pos);
371 // remove point dependending of
372 if (myShape.isClosed() && (index == 0 || index == (int)modifiedShape.size() - 1) && (myShape.size() > 2)) {
373 modifiedShape.erase(modifiedShape.begin());
374 modifiedShape.erase(modifiedShape.end() - 1);
375 modifiedShape.push_back(modifiedShape.front());
376 } else {
377 modifiedShape.erase(modifiedShape.begin() + index);
378 }
379 // set new shape depending of allowUndo
380 if (allowUndo) {
381 myNet->getViewNet()->getUndoList()->begin(this, "delete geometry point");
384 } else {
385 // first remove object from grid due shape is used for boundary
387 // set new shape
388 myShape = modifiedShape;
389 // disable simplified shape flag
390 mySimplifiedShape = false;
391 // add object into grid again
393 }
394 myTesselation.clear();
395 } else {
396 WRITE_WARNING(TL("Number of remaining points insufficient"))
397 }
398}
399
400
401bool
403 return myShape.isClosed();
404}
405
406
407void
408GNEPoly::openPolygon(bool allowUndo) {
409 // only open if shape is closed
410 if (myShape.isClosed()) {
411 if (allowUndo) {
412 myNet->getViewNet()->getUndoList()->begin(this, "open polygon");
415 } else {
416 myShape.pop_back();
417 // disable simplified shape flag
418 mySimplifiedShape = false;
419 // update geometry to avoid grabbing Problems
421 }
422 } else {
423 WRITE_WARNING(TL("Polygon already opened"))
424 }
425}
426
427
428void
429GNEPoly::closePolygon(bool allowUndo) {
430 // only close if shape is opened
431 if (!myShape.isClosed()) {
432 if (allowUndo) {
433 myNet->getViewNet()->getUndoList()->begin(this, "close shape");
436 } else {
438 // disable simplified shape flag
439 mySimplifiedShape = false;
440 // update geometry to avoid grabbing Problems
442 }
443 } else {
444 WRITE_WARNING(TL("Polygon already closed"))
445 }
446}
447
448
449void
450GNEPoly::changeFirstGeometryPoint(int oldIndex, bool allowUndo) {
451 // check that old index is correct
452 if (oldIndex >= (int)myShape.size()) {
453 throw InvalidArgument("Invalid old Index");
454 } else if (oldIndex == 0) {
455 WRITE_WARNING(TL("Selected point must be different of the first point"))
456 } else {
457 // Configure new shape
458 PositionVector newShape;
459 for (int i = oldIndex; i < (int)myShape.size(); i++) {
460 newShape.push_back(myShape[i]);
461 }
462 if (myShape.isClosed()) {
463 for (int i = 1; i < oldIndex; i++) {
464 newShape.push_back(myShape[i]);
465 }
466 newShape.push_back(newShape.front());
467 } else {
468 for (int i = 0; i < oldIndex; i++) {
469 newShape.push_back(myShape[i]);
470 }
471 }
472 // set new rotated shape
473 if (allowUndo) {
474 myNet->getViewNet()->getUndoList()->begin(this, "change first geometry point");
477 } else {
478 // set new shape
479 myShape = newShape;
480 // disable simplified shape flag
481 mySimplifiedShape = false;
482 // update geometry to avoid grabbing Problems
484 }
485 }
486}
487
488
489void
490GNEPoly::simplifyShape(bool allowUndo) {
491 if (!mySimplifiedShape && myShape.size() > 2) {
492 const Boundary b = myShape.getBoxBoundary();
493 // create a square as simplified shape
494 PositionVector simplifiedShape;
495 simplifiedShape.push_back(Position(b.xmin(), b.ymin()));
496 simplifiedShape.push_back(Position(b.xmin(), b.ymax()));
497 simplifiedShape.push_back(Position(b.xmax(), b.ymax()));
498 simplifiedShape.push_back(Position(b.xmax(), b.ymin()));
499 if (myShape.isClosed()) {
500 simplifiedShape.push_back(simplifiedShape[0]);
501 }
502 // set new shape depending of allowUndo
503 if (allowUndo) {
504 myNet->getViewNet()->getUndoList()->begin(this, "simplify shape");
507 } else {
508 // set new shape
509 myShape = simplifiedShape;
510 // update geometry to avoid grabbing Problems
512 }
513 // change flag after setting simplified shape
514 mySimplifiedShape = true;
515 } else {
516 WRITE_WARNING(TL("Polygon already simplified"))
517 }
518}
519
520
521std::string
523 switch (key) {
524 case SUMO_ATTR_ID:
525 return myID;
526 case SUMO_ATTR_SHAPE:
527 return toString(myShape);
530 case SUMO_ATTR_COLOR:
531 return toString(getShapeColor());
532 case SUMO_ATTR_FILL:
533 return toString(myFill);
535 return toString(myLineWidth);
536 case SUMO_ATTR_LAYER:
538 return "default";
539 } else {
540 return toString(getShapeLayer());
541 }
542 case SUMO_ATTR_TYPE:
543 return getShapeType();
545 return getShapeImgFile();
548 case SUMO_ATTR_ANGLE:
550 case SUMO_ATTR_GEO:
551 return toString(myGEO);
552 case SUMO_ATTR_NAME:
553 return getShapeName();
555 return toString(myShape.isClosed());
560 default:
561 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
562 }
563}
564
565
566double
568 throw InvalidArgument(getTagStr() + " attribute '" + toString(key) + "' not allowed");
569}
570
571
576
577
578void
579GNEPoly::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
580 if (value == getAttribute(key)) {
581 return; //avoid needless changes, later logic relies on the fact that attributes have changed
582 }
583 switch (key) {
584 case SUMO_ATTR_ID:
585 case SUMO_ATTR_SHAPE:
587 case SUMO_ATTR_COLOR:
588 case SUMO_ATTR_FILL:
590 case SUMO_ATTR_LAYER:
591 case SUMO_ATTR_TYPE:
594 case SUMO_ATTR_ANGLE:
595 case SUMO_ATTR_GEO:
596 case SUMO_ATTR_NAME:
600 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
601 break;
602 default:
603 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
604 }
605}
606
607
608bool
609GNEPoly::isValid(SumoXMLAttr key, const std::string& value) {
610 switch (key) {
611 case SUMO_ATTR_ID:
613 case SUMO_ATTR_SHAPE:
615 // empty shapes AREN'T allowed
616 if (value.empty()) {
617 return false;
618 } else {
619 return canParse<PositionVector>(value);
620 }
621 case SUMO_ATTR_COLOR:
622 return canParse<RGBColor>(value);
623 case SUMO_ATTR_FILL:
624 return canParse<bool>(value);
626 return canParse<double>(value) && (parse<double>(value) >= 0);
627 case SUMO_ATTR_LAYER:
628 if (value == "default") {
629 return true;
630 } else {
631 return canParse<double>(value);
632 }
633 case SUMO_ATTR_TYPE:
634 return true;
636 if (value == "") {
637 return true;
638 } else {
639 // check that image can be loaded
640 return GUITexturesHelper::getTextureID(value) != -1;
641 }
643 return canParse<bool>(value);
644 case SUMO_ATTR_ANGLE:
645 return canParse<double>(value);
646 case SUMO_ATTR_GEO:
647 return canParse<bool>(value);
648 case SUMO_ATTR_NAME:
651 if (canParse<bool>(value)) {
652 bool closePolygon = parse<bool>(value);
653 if (closePolygon && (myShape.begin() == myShape.end())) {
654 // Polygon already closed, then invalid value
655 return false;
656 } else if (!closePolygon && (myShape.begin() != myShape.end())) {
657 // Polygon already open, then invalid value
658 return false;
659 } else {
660 return true;
661 }
662 } else {
663 return false;
664 }
666 return canParse<bool>(value);
668 return areParametersValid(value);
669 default:
670 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
671 }
672}
673
674
675bool
677 // check if we're in supermode Network
679 return true;
680 } else {
681 return false;
682 }
683}
684
685
686std::string
688 return getTagStr() + ": " + getID();
689}
690
691
692std::string
694 return getTagStr();
695}
696
697// ===========================================================================
698// private
699// ===========================================================================
700
701void
702GNEPoly::setAttribute(SumoXMLAttr key, const std::string& value) {
703 switch (key) {
704 case SUMO_ATTR_ID: {
705 // update microsimID
706 setAdditionalID(value);
707 // set named ID
708 myID = value;
709 break;
710 }
711 case SUMO_ATTR_SHAPE: {
712 // set new shape
713 myShape = parse<PositionVector>(value);
714 // set GEO shape
716 for (int i = 0; i < (int) myGeoShape.size(); i++) {
718 }
719 // disable simplified shape flag
720 mySimplifiedShape = false;
721 // update geometry
723 // update centering boundary
725 break;
726 }
727 case SUMO_ATTR_GEOSHAPE: {
728 // set new GEO shape
729 myGeoShape = parse<PositionVector>(value);
730 // set shape
732 for (int i = 0; i < (int) myShape.size(); i++) {
734 }
735 // disable simplified shape flag
736 mySimplifiedShape = false;
737 // update geometry
739 // update centering boundary
741 break;
742 }
743 case SUMO_ATTR_COLOR:
744 setShapeColor(parse<RGBColor>(value));
745 break;
746 case SUMO_ATTR_FILL:
747 myFill = parse<bool>(value);
749 break;
751 myLineWidth = parse<double>(value);
752 break;
753 case SUMO_ATTR_LAYER:
754 if (value == "default") {
756 } else {
757 setShapeLayer(parse<double>(value));
758 }
759 break;
760 case SUMO_ATTR_TYPE:
761 setShapeType(value);
762 break;
764 setShapeImgFile(value);
765 // all textures must be refresh
767 break;
769 setShapeRelativePath(parse<bool>(value));
770 break;
771 case SUMO_ATTR_ANGLE:
772 setShapeNaviDegree(parse<double>(value));
773 break;
774 case SUMO_ATTR_GEO:
775 myGEO = parse<bool>(value);
776 // update centering boundary
778 break;
779 case SUMO_ATTR_NAME:
780 setShapeName(value);
781 break;
783 if (parse<bool>(value)) {
786 } else {
787 myShape.pop_back();
788 myGeoShape.pop_back();
789 }
790 // disable simplified shape flag
791 mySimplifiedShape = false;
792 // update geometry
794 // update centering boundary
796 break;
798 if (parse<bool>(value)) {
800 } else {
802 }
803 break;
806 break;
807 default:
808 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
809 }
810}
811
812
813void
815 // update new shape
816 myShape = moveResult.shapeToUpdate;
817 // update geometry
819}
820
821
822void
824 // commit new shape
825 undoList->begin(this, "moving " + toString(SUMO_ATTR_SHAPE) + " of " + getTagStr());
827 undoList->end();
828}
829
830
831void
833 const RGBColor& color, const double exaggeration) const {
834 // check if we're drawing a polygon or a polyline
835 if (getFill()) {
836 // draw inner polygon
838 } else {
839 // push matrix
841 // set color
842 GLHelper::setColor(color);
843 // draw geometry (polyline)
845 // pop matrix
847 }
848}
849
850
851void
853 const RGBColor& color, const double exaggeration) const {
854 // push contour matrix
856 // translate to front
857 glTranslated(0, 0, 0.1);
858 // set color
859 GLHelper::setColor(color);
860 // draw polygon contour
862 // pop contour matrix
864}
865
866
867void
869 const RGBColor& color, const double exaggeration) const {
870 // draw shape points only in supermode network
872 // check if we're in move mode
874 // get geometry point sizes
875 const double geometryPointSize = s.neteditSizeSettings.polygonGeometryPointRadius * (moveMode ? 1 : 0.5);
876 // draw geometry points
877 GUIGeometry::drawGeometryPoints(d, myAdditionalGeometry.getShape(), color, geometryPointSize, exaggeration,
879 // draw dotted contours for geometry points if we're in move mode
880 if (moveMode) {
883 }
884 }
885}
886
887
888void
890 // get name position
892 // draw name
893 drawName(namePos, s.scale, s.polyName, s.angle);
894 // check if draw poly type
895 if (s.polyType.show(this)) {
896 const Position p = namePos + Position(0, -0.6 * s.polyType.size / s.scale);
898 }
899}
900
901/****************************************************************************/
@ NETWORK_MOVE
mode for moving network elements
@ MID_GNE_POLYGON_CLOSE
close opened polygon
@ MID_GNE_POLYGON_SET_FIRST_POINT
Set a vertex of polygon as first vertex.
@ MID_GNE_POLYGON_SELECT
select elements within polygon boundary
@ MID_GNE_CUSTOM_GEOMETRYPOINT
set custom geometry point
@ MID_GNE_POLYGON_DELETE_GEOMETRY_POINT
delete geometry point
@ MID_GNE_POLYGON_OPEN
open closed polygon
@ MID_GNE_POLYGON_SIMPLIFY_SHAPE
simplify polygon geometry
unsigned int GUIGlID
Definition GUIGlObject.h:43
@ GLO_POLYGON
polygon
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
#define WRITE_WARNING(msg)
Definition MsgHandler.h:295
#define TL(string)
Definition MsgHandler.h:315
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.
@ GNE_ATTR_SELECTED
element is selected
@ SUMO_ATTR_LINEWIDTH
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
@ SUMO_ATTR_GEO
@ SUMO_ATTR_GEOSHAPE
@ GNE_ATTR_CLOSE_SHAPE
Close shape of a polygon (Used by GNEPolys)
@ SUMO_ATTR_SHAPE
edge: the shape in xml-definition
@ SUMO_ATTR_FILL
Fill the polygon.
@ SUMO_ATTR_NAME
@ SUMO_ATTR_LAYER
A layer number.
@ SUMO_ATTR_ANGLE
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_ID
@ SUMO_ATTR_IMGFILE
@ SUMO_ATTR_RELATIVEPATH
int gPrecisionGeo
Definition StdDefs.cpp:27
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
Position getCenter() const
Returns the center of the boundary.
Definition Boundary.cpp:112
double ymin() const
Returns minimum y-coordinate.
Definition Boundary.cpp:130
double xmin() const
Returns minimum x-coordinate.
Definition Boundary.cpp:118
Boundary & grow(double by)
extends the boundary by the given amount
Definition Boundary.cpp:343
double ymax() const
Returns maximum y-coordinate.
Definition Boundary.cpp:136
double xmax() const
Returns maximum x-coordinate.
Definition Boundary.cpp:124
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:654
static void popMatrix()
pop matrix
Definition GLHelper.cpp:130
static void drawBoundary(const GUIVisualizationSettings &s, const Boundary &b)
Draw a boundary (used for debugging)
Definition GLHelper.cpp:966
static void pushMatrix()
push matrix
Definition GLHelper.cpp:117
static void drawTextSettings(const GUIVisualizationTextSettings &settings, const std::string &text, const Position &pos, const double scale, const double angle=0, const double layer=2048, const int align=0)
Definition GLHelper.cpp:787
An Element which don't belong to GNENet but has influence in the simulation.
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(...)
void calculateContourPolygons(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double layer, const double exaggeration, const bool filledShape) const
calculate contour for polygons
Boundary myAdditionalBoundary
Additional Boundary (used only by additionals placed over grid)
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
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 (instead of GUIGlObjectStorage)
const std::string & getTagStr() const
get tag assigned to this object in string format
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
void unselectAttributeCarrier(const bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
void resetDefaultValues()
reset attribute carrier to their default values
GNENet * myNet
pointer to net
void selectAttributeCarrier(const bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
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
void 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...)
GNEMoveOperation * calculateMoveShapeOperation(const GUIGlObject *obj, const PositionVector originalShape, const bool maintainShapeClosed)
calculate move shape operation
bool getMoveWholePolygons() const
move whole polygons
NetworkModeOptions * getNetworkModeOptions() const
get network mode options
move operation
move result
PositionVector shapeToUpdate
shape to update (edited in moveElement)
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
void addGLObjectIntoGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1378
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1388
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2147
bool mySimplifiedShape
flag to indicate if polygon is simplified
Definition GNEPoly.h:239
std::string getAdditionalProblem() const override
return a string with the current additional problem (must be reimplemented in all detector children)
Definition GNEPoly.cpp:214
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
Definition GNEPoly.cpp:687
std::string getParentName() const override
Returns the name of the parent object.
Definition GNEPoly.cpp:248
double getAttributeDouble(SumoXMLAttr key) const override
Definition GNEPoly.cpp:567
~GNEPoly()
Destructor.
Definition GNEPoly.cpp:105
bool isValid(SumoXMLAttr key, const std::string &value) override
method for checking if the key and their conrrespond attribute are valids
Definition GNEPoly.cpp:609
void updateGeometry() override
update pre-computed geometry information
Definition GNEPoly.cpp:159
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
Definition GNEPoly.cpp:693
void fixAdditionalProblem() override
fix additional problem (must be reimplemented in all detector children)
Definition GNEPoly.cpp:220
void writeAdditional(OutputDevice &device) const override
write additional element into a xml file
Definition GNEPoly.cpp:202
void drawPolygonNameAndType(const GUIVisualizationSettings &s) const
draw polygon name and type
Definition GNEPoly.cpp:889
GNEPoly(SumoXMLTag tag, GNENet *net)
default Constructor
Definition GNEPoly.cpp:44
GNEMoveOperation * getMoveOperation() override
get move operation
Definition GNEPoly.cpp:109
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:350
PositionVector myGeoShape
Latitude of Polygon.
Definition GNEPoly.h:236
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
Definition GNEPoly.cpp:173
void closePolygon(bool allowUndo=true)
close polygon
Definition GNEPoly.cpp:429
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point
Definition GNEPoly.cpp:450
std::string getAttribute(SumoXMLAttr key) const override
Definition GNEPoly.cpp:522
bool checkDrawMoveContour() const override
check if draw move contour (red)
Definition GNEPoly.cpp:232
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList) override
commit move shape
Definition GNEPoly.cpp:823
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:208
void setMoveShape(const GNEMoveResult &moveResult) override
set move shape
Definition GNEPoly.cpp:814
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:579
void deleteGeometryPoint(const Position &pos, bool allowUndo=true)
delete the geometry point closest to the given pos
Definition GNEPoly.cpp:366
Position getPositionInView() const override
Returns position of shape in view.
Definition GNEPoly.cpp:167
void drawGeometryPoints(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw geometry points
Definition GNEPoly.cpp:868
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList) override
remove geometry point in the clicked position
Definition GNEPoly.cpp:130
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GNEPoly.cpp:303
void drawPolygon(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw polygon
Definition GNEPoly.cpp:832
bool isAttributeEnabled(SumoXMLAttr key) const override
Definition GNEPoly.cpp:676
void drawPolygonContour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw contour
Definition GNEPoly.cpp:852
bool isPolygonClosed() const
check if polygon is closed
Definition GNEPoly.cpp:402
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GNEPoly.cpp:254
void simplifyShape(bool allowUndo=true)
replace the current shape with a rectangle
Definition GNEPoly.cpp:490
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList) override
split geometry
Definition GNEPoly.cpp:196
void updateCenteringBoundary(const bool updateGrid) override
update centering boundary (implies change in RTREE)
Definition GNEPoly.cpp:179
const Parameterised::Map & getACParametersMap() const override
get parameters map
Definition GNEPoly.cpp:573
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition GNEPoly.cpp:226
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition GNEPoly.cpp:153
void openPolygon(bool allowUndo=true)
open polygon
Definition GNEPoly.cpp:408
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 attribute carrier 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
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, double typeOrLayer, const double extraOffset=0)
draw front attributeCarrier
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
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
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.
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, const GUIMainWindow &app) const
Builds an entry which allows to copy the cursor position if geo projection is used,...
GUIGlID getGlID() const
Returns the numerical id of the object.
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
static void drawInnerPolygon(const GUIVisualizationSettings &s, const TesselatedPolygon *polygon, const GUIGlObject *o, const PositionVector shape, const double layer, const bool fill, const bool disableSelectionColor=false, const int alphaOverride=-1, const bool disableText=false)
draw inner Polygon (before pushName() )
static bool checkDraw(const GUIVisualizationSettings &s, const SUMOPolygon *polygon, const GUIGlObject *o)
check if Polygon can be drawn
Position snapToActiveGrid(const Position &pos, bool snapXY=true) const
Returns a position that is mapped to the closest grid point if the grid is active.
const GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings (read only)
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
static int getTextureID(const std::string &filename, const bool mirrorX=false)
return texture id for the given filename (initialize on first use)
static void clearTextures()
clears loaded textures
Stores the information about how to visualize structures.
bool 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
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.
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.
static bool areParametersValid(const std::string &value, bool report=false, const std::string kvsep="=", const std::string sep="|")
check if given string can be parsed to a parameters map "key1=value1|key2=value2|....
std::map< std::string, std::string > Map
parameters map
void setParametersStr(const std::string &paramsString, const std::string kvsep="=", const std::string sep="|")
set the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN"
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
std::string getParametersStr(const std::string kvsep="=", const std::string sep="|") const
Returns the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN".
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.
Position getPolygonCenter() const
Returns the arithmetic of all corner points.
void closePolygon()
ensures that the last position equals the first
int indexOfClosest(const Position &p, bool twoD=false) const
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
bool isClosed() const
check if PositionVector is closed
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition RGBColor.cpp:200
PositionVector myShape
The positions of the polygon.
double myLineWidth
The line width for drawing an unfilled polygon.
bool myGEO
specify if shape is handled as GEO coordinate (Main used in netedit)
void writeXML(OutputDevice &out, bool geo=false) const
bool myFill
Information whether the polygon has to be filled.
bool getFill() const
Returns whether the polygon is filled.
static bool isValidAttribute(const std::string &value)
whether the given string is a valid attribute for a certain key (for example, a name)
const std::string getShapeName() const
Returns the name of the Shape.
Definition Shape.h:110
static const double DEFAULT_LAYER
Definition Shape.h:43
void setShapeName(const std::string &name)
Sets a new shape name.
Definition Shape.h:169
void setShapeLayer(const double layer)
Sets a new layer.
Definition Shape.h:150
bool getShapeRelativePath() const
Returns the relativePath of the Shape.
Definition Shape.h:117
const std::string & getShapeType() const
Returns the (abstract) type of the Shape.
Definition Shape.h:77
void setShapeType(const std::string &type)
Sets a new type.
Definition Shape.h:129
void setShapeRelativePath(bool relativePath)
Sets a new relativePath value.
Definition Shape.h:176
virtual void setShapeNaviDegree(const double angle)
Sets a new angle in navigational degrees.
Definition Shape.h:157
void setShapeImgFile(const std::string &imgFile)
Sets a new imgFile.
Definition Shape.h:164
void setShapeColor(const RGBColor &col)
Sets a new color.
Definition Shape.h:136
double getShapeLayer() const
Returns the layer of the Shape.
Definition Shape.h:91
const std::string & getShapeImgFile() const
Returns the imgFile of the Shape.
Definition Shape.h:105
const RGBColor & getShapeColor() const
Returns the color of the Shape.
Definition Shape.h:84
double getShapeNaviDegree() const
Returns the angle of the Shape in navigational degrees.
Definition Shape.h:98
std::vector< GLPrimitive > myTesselation
id of the display list for the cached tesselation
Definition GUIPolygon.h:74
bool showShapes() const
check if shapes has to be drawn
bool showShapes() const
check if shapes has to be drawn
NetworkEditMode networkEditMode
the current Network edit mode
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
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