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#include <config.h>
22
23#include <netedit/GNENet.h>
25#include <netedit/GNEUndoList.h>
26#include <netedit/GNEViewNet.h>
36
37#include "GNEPoly.h"
38
39// ===========================================================================
40// method definitions
41// ===========================================================================
42
44 TesselatedPolygon("", "", RGBColor::BLACK, {}, false, false, 0, 0, 0, "", "", Parameterised::Map()),
45GNEAdditional("", net, "", tag, "") {
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 myClosedShape(shape.isClosed()) {
55 // check if imgFile is valid
56 if (!imgFile.empty() && GUITexturesHelper::getTextureID(imgFile) == -1) {
58 }
59 // set GEO shape
61 if (geo) {
62 for (int i = 0; i < (int) myGeoShape.size(); i++) {
64 }
65 } else {
66 for (int i = 0; i < (int) myGeoShape.size(); i++) {
68 }
69 }
70 // update centering boundary without updating grid
72 // update geometry
74}
75
76
77GNEPoly::GNEPoly(SumoXMLTag tag, const std::string& id, GNENet* net, const std::string& filename, const PositionVector& shape,
78 bool geo, const std::string& name, const Parameterised::Map& parameters) :
79 TesselatedPolygon(id, getJuPedSimType(tag), getJuPedSimColor(tag), shape, geo, getJuPedSimFill(tag), 1,
80 getJuPedSimLayer(tag), 0, "", name, parameters),
81 GNEAdditional(id, net, filename, tag, ""),
82 myClosedShape(shape.isClosed()),
83 mySimplifiedShape(false) {
84 // set GEO shape
86 if (geo) {
87 for (int i = 0; i < (int) myGeoShape.size(); i++) {
89 }
90 } else {
91 for (int i = 0; i < (int) myGeoShape.size(); i++) {
93 }
94 }
95 // update centering boundary without updating grid
97 // update geometry
99}
100
101
103
104
107 // edit depending if shape is blocked
109 // move entire shape
110 return new GNEMoveOperation(this, myShape);
111 } else {
112 // continue depending of tag
113 switch (getTagProperty()->getTag()) {
116 // calculate move shape operation maintain shape closed
117 return calculateMoveShapeOperation(this, myShape, true);
118 default:
119 // calculate move shape operation
120 return calculateMoveShapeOperation(this, myShape, false);
121 }
122 }
123}
124
125
126void
127GNEPoly::removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList) {
128 // get original shape
129 PositionVector shape = myShape;
130 // check shape size
131 if (shape.size() > 2) {
132 // obtain index
133 int index = shape.indexOfClosest(clickedPosition);
134 // get snap radius
136 // check if we have to create a new index
137 if ((index != -1) && shape[index].distanceSquaredTo2D(clickedPosition) < (snap_radius * snap_radius)) {
138 // remove geometry point
139 shape.erase(shape.begin() + index);
140 // commit new shape
141 undoList->begin(this, "remove geometry point of " + getTagStr());
143 undoList->end();
144 }
145 }
146}
147
148
149std::string
151 return "";
152}
153
154
155void
157 // just update polygon geometry
159 myTesselation.clear();
160}
161
162
167
168
169double
171 return s.polySize.getExaggeration(s, this);
172}
173
174
175void
176GNEPoly::updateCenteringBoundary(const bool updateGrid) {
177 // Remove object from net
178 if (updateGrid) {
180 }
181 // use shape as boundary
183 // grow boundary
185 // add object into net
186 if (updateGrid) {
188 }
189}
190
191
192void
193GNEPoly::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
194 // nothing to split
195}
196
197
198void
200 writeXML(device, myGEO);
201}
202
203
204bool
206 return true;
207}
208
209
210std::string
212 return "";
213}
214
215
216void
218 // nothing to fix
219}
220
221
224 return GUIGlObject::getGlID();
225}
226
227
228bool
230 // get edit modes
231 const auto& editModes = myNet->getViewNet()->getEditModes();
232 // check if we're in move mode
233 if (!myNet->getViewNet()->isCurrentlyMovingElements() && editModes.isCurrentSupermodeNetwork() &&
235 (editModes.networkEditMode == NetworkEditMode::NETWORK_MOVE) && myNet->getViewNet()->checkOverLockedElement(this, mySelected)) {
236 // only move the first element
238 } else {
239 return false;
240 }
241}
242
243
244std::string
246 return myNet->getMicrosimID();
247}
248
249
252 // create popup
253 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, this);
254 // build common options
256 FXMenuCommand* simplifyShape = GUIDesigns::buildFXMenuCommand(ret, TL("Simplify Shape"), TL("Replace current shape with a rectangle"), nullptr, &parent, MID_GNE_POLYGON_SIMPLIFY_SHAPE);
257 // disable simplify shape if polygon was already simplified
258 if (mySimplifiedShape || myShape.size() <= 2) {
259 simplifyShape->disable();
260 }
261 // only allow open/close for non juPedSim polygons
263 if (myShape.isClosed()) {
264 GUIDesigns::buildFXMenuCommand(ret, TL("Open shape"), TL("Open polygon's shape"), nullptr, &parent, MID_GNE_POLYGON_OPEN);
265 } else {
266 GUIDesigns::buildFXMenuCommand(ret, TL("Close shape"), TL("Close polygon's shape"), nullptr, &parent, MID_GNE_POLYGON_CLOSE);
267 }
268 }
269 GUIDesigns::buildFXMenuCommand(ret, TL("Select elements within polygon"), TL("Select elements within polygon boundary"), nullptr, &parent, MID_GNE_POLYGON_SELECT);
270 if (myShape.size() > 3) {
271 GUIDesigns::buildFXMenuCommand(ret, TL("Triangulate polygon"), TL("Convert the current polygon in triangles"), nullptr, &parent, MID_GNE_POLYGON_TRIANGULATE);
272 }
273 // create a extra FXMenuCommand if mouse is over a vertex
274 const int index = getVertexIndex(myNet->getViewNet()->getPositionInformation(), false);
275 if (index != -1) {
276 // add separator
277 new FXMenuSeparator(ret);
278 // check if we're in network mode
280 GUIDesigns::buildFXMenuCommand(ret, "Set custom Geometry Point", nullptr, &parent, MID_GNE_CUSTOM_GEOMETRYPOINT);
281 }
282 FXMenuCommand* removeGeometryPoint = GUIDesigns::buildFXMenuCommand(ret, TL("Remove geometry point"), TL("Remove geometry point under mouse"), nullptr, &parent, MID_GNE_POLYGON_DELETE_GEOMETRY_POINT);
283 FXMenuCommand* setFirstPoint = GUIDesigns::buildFXMenuCommand(ret, TL("Set first geometry point"), TL("Set first geometry point"), nullptr, &parent, MID_GNE_POLYGON_SET_FIRST_POINT);
284 // disable setFirstPoint if shape only have three points
285 if ((myShape.isClosed() && (myShape.size() <= 4)) || (!myShape.isClosed() && (myShape.size() <= 2))) {
286 removeGeometryPoint->disable();
287 }
288 // disable setFirstPoint if mouse is over first point
289 if (index == 0) {
290 setFirstPoint->disable();
291 }
292 }
293 return ret;
294}
295
296
297void
299 // first check if poly can be drawn
302 GUIPolygon::checkDraw(s, this, this)) {
303 // draw boundary
304 const auto boundary = getCenteringBoundary();
306 // get exaggeration
307 const double polyExaggeration = getExaggeration(s);
308 // get detail level
309 const auto d = s.getDetailLevel(polyExaggeration);
310 // draw geometry only if we'rent in drawForObjectUnderCursor mode
311 if (s.checkDrawPoly(boundary, isAttributeCarrierSelected())) {
312 // get colors
314 // push layer matrix
316 // translate to front
318 // draw polygon
319 drawPolygon(s, d, color, polyExaggeration);
320 // draw contour if don't move whole polygon
322 // get darker color
323 const RGBColor darkerColor = color.changedBrightness(-32);
324 // draw contour
325 drawPolygonContour(s, d, darkerColor, polyExaggeration);
326 // draw geometry points
327 drawGeometryPoints(s, d, darkerColor, polyExaggeration);
328 }
329 // pop layer matrix
331 // draw name and type
333 // draw lock icon
335 // draw dotted contour
337 }
338 // calculate contour
339 calculateContourPolygons(s, d, getShapeLayer(), polyExaggeration, getFill());
340 }
341}
342
343
344int
345GNEPoly::getVertexIndex(Position pos, bool snapToGrid) {
346 // check if position has to be snapped to grid
347 if (snapToGrid) {
348 pos = myNet->getViewNet()->snapToActiveGrid(pos);
349 }
350 // first check if vertex already exists
351 for (const auto& shapePosition : myShape) {
352 if (shapePosition.distanceTo2D(pos) < myNet->getViewNet()->getVisualisationSettings().neteditSizeSettings.polygonGeometryPointRadius) {
353 return myShape.indexOfClosest(shapePosition);
354 }
355 }
356 return -1;
357}
358
359
360void
361GNEPoly::deleteGeometryPoint(const Position& pos, bool allowUndo) {
362 if (myShape.size() > 1) {
363 // obtain index
364 PositionVector modifiedShape = myShape;
365 int index = modifiedShape.indexOfClosest(pos);
366 // remove point dependending of
367 if (myShape.isClosed() && (index == 0 || index == (int)modifiedShape.size() - 1) && (myShape.size() > 2)) {
368 modifiedShape.erase(modifiedShape.begin());
369 modifiedShape.erase(modifiedShape.end() - 1);
370 modifiedShape.push_back(modifiedShape.front());
371 } else {
372 modifiedShape.erase(modifiedShape.begin() + index);
373 }
374 // set new shape depending of allowUndo
375 if (allowUndo) {
376 myNet->getViewNet()->getUndoList()->begin(this, "delete geometry point");
379 } else {
380 // first remove object from grid due shape is used for boundary
382 // set new shape
383 myShape = modifiedShape;
384 // disable simplified shape flag
385 mySimplifiedShape = false;
386 // add object into grid again
388 }
389 myTesselation.clear();
390 } else {
391 WRITE_WARNING(TL("Number of remaining points insufficient"))
392 }
393}
394
395
396bool
398 return myShape.isClosed();
399}
400
401
402void
403GNEPoly::openPolygon(bool allowUndo) {
404 // only open if shape is closed
405 if (myShape.isClosed()) {
406 if (allowUndo) {
407 myNet->getViewNet()->getUndoList()->begin(this, "open polygon");
410 } else {
411 myShape.pop_back();
412 // disable simplified shape flag
413 mySimplifiedShape = false;
414 // update geometry to avoid grabbing Problems
416 }
417 } else {
418 WRITE_WARNING(TL("Polygon already opened"))
419 }
420}
421
422
423void
424GNEPoly::closePolygon(bool allowUndo) {
425 // only close if shape is opened
426 if (!myShape.isClosed()) {
427 if (allowUndo) {
428 myNet->getViewNet()->getUndoList()->begin(this, "close shape");
431 } else {
433 // disable simplified shape flag
434 mySimplifiedShape = false;
435 // update geometry to avoid grabbing Problems
437 }
438 } else {
439 WRITE_WARNING(TL("Polygon already closed"))
440 }
441}
442
443
444void
445GNEPoly::changeFirstGeometryPoint(int oldIndex, bool allowUndo) {
446 // check that old index is correct
447 if (oldIndex >= (int)myShape.size()) {
448 throw InvalidArgument("Invalid old Index");
449 } else if (oldIndex == 0) {
450 WRITE_WARNING(TL("Selected point must be different of the first point"))
451 } else {
452 // Configure new shape
453 PositionVector newShape;
454 for (int i = oldIndex; i < (int)myShape.size(); i++) {
455 newShape.push_back(myShape[i]);
456 }
457 if (myShape.isClosed()) {
458 for (int i = 1; i < oldIndex; i++) {
459 newShape.push_back(myShape[i]);
460 }
461 newShape.push_back(newShape.front());
462 } else {
463 for (int i = 0; i < oldIndex; i++) {
464 newShape.push_back(myShape[i]);
465 }
466 }
467 // set new rotated shape
468 if (allowUndo) {
469 myNet->getViewNet()->getUndoList()->begin(this, "change first geometry point");
472 } else {
473 // set new shape
474 myShape = newShape;
475 // disable simplified shape flag
476 mySimplifiedShape = false;
477 // update geometry to avoid grabbing Problems
479 }
480 }
481}
482
483
484void
485GNEPoly::simplifyShape(bool allowUndo) {
486 if (!mySimplifiedShape && myShape.size() > 2) {
487 const Boundary b = myShape.getBoxBoundary();
488 // create a square as simplified shape
489 PositionVector simplifiedShape;
490 simplifiedShape.push_back(Position(b.xmin(), b.ymin()));
491 simplifiedShape.push_back(Position(b.xmin(), b.ymax()));
492 simplifiedShape.push_back(Position(b.xmax(), b.ymax()));
493 simplifiedShape.push_back(Position(b.xmax(), b.ymin()));
494 if (myShape.isClosed()) {
495 simplifiedShape.push_back(simplifiedShape[0]);
496 }
497 // set new shape depending of allowUndo
498 if (allowUndo) {
499 myNet->getViewNet()->getUndoList()->begin(this, "simplify shape");
502 } else {
503 // set new shape
504 myShape = simplifiedShape;
505 // update geometry to avoid grabbing Problems
507 }
508 // change flag after setting simplified shape
509 mySimplifiedShape = true;
510 } else {
511 WRITE_WARNING(TL("Polygon already simplified"))
512 }
513}
514
515
519 polygonBaseObject->setTag(myTagProperty->getTag());
520 // fill attributes
521 polygonBaseObject->addStringAttribute(SUMO_ATTR_ID, myID);
523 polygonBaseObject->addBoolAttribute(SUMO_ATTR_GEO, myGEO);
524 polygonBaseObject->addBoolAttribute(SUMO_ATTR_FILL, myFill);
526 polygonBaseObject->addColorAttribute(SUMO_ATTR_COLOR, getShapeColor());
527 polygonBaseObject->addStringAttribute(SUMO_ATTR_TYPE, getShapeType());
528 polygonBaseObject->addDoubleAttribute(SUMO_ATTR_LAYER, getShapeLayer());
531 polygonBaseObject->addStringAttribute(SUMO_ATTR_NAME, getShapeName());
532 return polygonBaseObject;
533}
534
535
536std::string
538 switch (key) {
539 case SUMO_ATTR_ID:
540 return myID;
541 case SUMO_ATTR_SHAPE:
542 if ((GeoConvHelper::getFinal().getProjString() != "!") && myGEO) {
543 return TL("Using GEO Shape");
544 } else {
545 return toString(myShape);
546 }
548 if (GeoConvHelper::getFinal().getProjString() != "!") {
550 } else {
551 return TL("No geo-conversion defined");
552 }
553 case SUMO_ATTR_COLOR:
554 return toString(getShapeColor());
555 case SUMO_ATTR_FILL:
556 return toString(myFill);
558 return toString(myLineWidth);
559 case SUMO_ATTR_LAYER:
560 return toString(getShapeLayer());
561 case SUMO_ATTR_TYPE:
562 return getShapeType();
564 return getShapeImgFile();
565 case SUMO_ATTR_ANGLE:
567 case SUMO_ATTR_GEO:
568 return toString(myGEO);
569 case SUMO_ATTR_NAME:
570 return getShapeName();
572 return toString(myClosedShape);
573 default:
574 return getCommonAttribute(this, key);
575 }
576}
577
578
579double
581 throw InvalidArgument(getTagStr() + " attribute '" + toString(key) + "' not allowed");
582}
583
584
589
590
591void
592GNEPoly::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
593 if (value == getAttribute(key)) {
594 return; //avoid needless changes, later logic relies on the fact that attributes have changed
595 }
596 switch (key) {
597 case SUMO_ATTR_ID:
598 case SUMO_ATTR_SHAPE:
600 case SUMO_ATTR_COLOR:
601 case SUMO_ATTR_FILL:
603 case SUMO_ATTR_LAYER:
604 case SUMO_ATTR_TYPE:
606 case SUMO_ATTR_ANGLE:
607 case SUMO_ATTR_GEO:
608 case SUMO_ATTR_NAME:
610 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
611 break;
612 default:
613 setCommonAttribute(key, value, undoList);
614 break;
615 }
616}
617
618
619bool
620GNEPoly::isValid(SumoXMLAttr key, const std::string& value) {
621 switch (key) {
622 case SUMO_ATTR_ID:
624 case SUMO_ATTR_SHAPE:
626 // empty shapes AREN'T allowed
627 if (value.empty()) {
628 return false;
629 } else {
630 return canParse<PositionVector>(value);
631 }
632 case SUMO_ATTR_COLOR:
633 return canParse<RGBColor>(value);
634 case SUMO_ATTR_FILL:
635 return canParse<bool>(value);
637 return canParse<double>(value) && (parse<double>(value) >= 0);
638 case SUMO_ATTR_LAYER:
639 if (value.empty()) {
640 return true;
641 } else {
642 return canParse<double>(value);
643 }
644 case SUMO_ATTR_TYPE:
645 return true;
647 if (value == "") {
648 return true;
649 } else {
650 // check that image can be loaded
651 return GUITexturesHelper::getTextureID(value) != -1;
652 }
653 case SUMO_ATTR_ANGLE:
654 return canParse<double>(value);
655 case SUMO_ATTR_GEO:
656 return canParse<bool>(value);
657 case SUMO_ATTR_NAME:
660 return canParse<bool>(value);
661 default:
662 return isCommonValid(key, value);
663 }
664}
665
666
667bool
669 switch (key) {
670 case SUMO_ATTR_SHAPE:
671 if (GeoConvHelper::getFinal().getProjString() != "!") {
672 return myGEO == false;
673 } else {
674 return true;
675 }
676 case SUMO_ATTR_GEO:
677 return GeoConvHelper::getFinal().getProjString() != "!";
679 if (GeoConvHelper::getFinal().getProjString() != "!") {
680 return myGEO == true;
681 } else {
682 return false;
683 }
685 if (isTemplate()) {
686 return true;
687 } else {
688 return myShape.size() > 1;
689 }
690 default:
691 return true;
692 }
693}
694
695
696std::string
698 return getTagStr() + ": " + getID();
699}
700
701
702std::string
704 return getTagStr();
705}
706
707// ===========================================================================
708// private
709// ===========================================================================
710
711void
712GNEPoly::setAttribute(SumoXMLAttr key, const std::string& value) {
713 switch (key) {
714 case SUMO_ATTR_ID: {
715 // update microsimID
716 setAdditionalID(value);
717 // set named ID
718 myID = value;
719 break;
720 }
721 case SUMO_ATTR_SHAPE: {
722 // set new shape
723 myShape = parse<PositionVector>(value);
724 // set GEO shape
726 for (int i = 0; i < (int) myGeoShape.size(); i++) {
728 }
729 // disable simplified shape flag
730 mySimplifiedShape = false;
731 // update geometry
733 // update centering boundary
735 break;
736 }
737 case SUMO_ATTR_GEOSHAPE: {
738 // set new GEO shape
739 myGeoShape = parse<PositionVector>(value);
740 // set shape
742 for (int i = 0; i < (int) myShape.size(); i++) {
744 }
745 // disable simplified shape flag
746 mySimplifiedShape = false;
747 // update geometry
749 // update centering boundary
751 break;
752 }
753 case SUMO_ATTR_COLOR:
754 setShapeColor(parse<RGBColor>(value));
755 break;
756 case SUMO_ATTR_FILL:
757 myFill = parse<bool>(value);
759 break;
761 myLineWidth = parse<double>(value);
762 break;
763 case SUMO_ATTR_LAYER:
764 if (value.empty()) {
766 } else {
767 setShapeLayer(parse<double>(value));
768 }
769 break;
770 case SUMO_ATTR_TYPE:
771 setShapeType(value);
772 break;
774 setShapeImgFile(value);
775 // all textures must be refresh
777 break;
778 case SUMO_ATTR_ANGLE:
779 setShapeNaviDegree(parse<double>(value));
780 break;
781 case SUMO_ATTR_GEO:
782 myGEO = parse<bool>(value);
783 // update centering boundary
785 break;
786 case SUMO_ATTR_NAME:
787 setShapeName(value);
788 break;
790 myClosedShape = parse<bool>(value);
791 if (!isTemplate()) {
792 if (myClosedShape) {
795
796 } else {
799 }
800 // disable simplified shape flag
801 mySimplifiedShape = false;
802 // update geometry
804 // update centering boundary
806 }
807 break;
808 default:
809 setCommonAttribute(this, key, value);
810 break;
811 }
812}
813
814
815void
817 // update new shape
818 myShape = moveResult.shapeToUpdate;
819 // update geometry
821}
822
823
824void
826 // commit new shape
827 undoList->begin(this, "moving " + toString(SUMO_ATTR_SHAPE) + " of " + getTagStr());
829 undoList->end();
830}
831
832
833void
835 const RGBColor& color, const double exaggeration) const {
836 // check if we're drawing a polygon or a polyline
837 if (getFill()) {
838 // draw inner polygon
840 } else {
841 // push matrix
843 // set color
844 GLHelper::setColor(color);
845 // draw geometry (polyline)
847 // pop matrix
849 }
850}
851
852
853void
855 const RGBColor& color, const double exaggeration) const {
856 // push contour matrix
858 // translate to front
859 glTranslated(0, 0, 0.1);
860 // set color
861 GLHelper::setColor(color);
862 // draw polygon contour
864 // pop contour matrix
866}
867
868
869void
871 const RGBColor& color, const double exaggeration) const {
872 // draw shape points only in supermode network
874 // check if we're in move mode
876 // get geometry point sizes
877 const double geometryPointSize = s.neteditSizeSettings.polygonGeometryPointRadius * (moveMode ? 1 : 0.5);
878 // draw geometry points
879 GUIGeometry::drawGeometryPoints(d, myAdditionalGeometry.getShape(), color, geometryPointSize, exaggeration,
881 // draw dotted contours for geometry points if we're in move mode
882 if (moveMode) {
885 }
886 }
887}
888
889
890void
892 // get name position
894 // draw name
895 drawName(namePos, s.scale, s.polyName, s.angle);
896 // check if draw poly type
897 if (s.polyType.show(this)) {
898 const Position p = namePos + Position(0, -0.6 * s.polyType.size / s.scale);
900 }
901}
902
903/****************************************************************************/
@ 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:287
#define TL(string)
Definition MsgHandler.h:305
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:28
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(...)
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 (more quickly as checking GUIGlObjectStorage)
std::string getCommonAttribute(const Parameterised *parameterised, 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
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
GNENet * myNet
pointer to net
bool isCommonValid(SumoXMLAttr key, const std::string &value) 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...)
GNEMoveOperation * calculateMoveShapeOperation(const GUIGlObject *obj, const PositionVector originalShape, const bool maintainShapeClosed)
calculate move shape operation
bool getMoveWholePolygons() const
check if option "move whole polygons" is enabled
NetworkMoveOptions * getNetworkMoveOptions() 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:1440
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1450
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2193
bool mySimplifiedShape
flag to indicate if polygon is simplified
Definition GNEPoly.h:242
std::string getAdditionalProblem() const override
return a string with the current additional problem (must be reimplemented in all detector children)
Definition GNEPoly.cpp:211
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
Definition GNEPoly.cpp:697
std::string getParentName() const override
Returns the name of the parent object.
Definition GNEPoly.cpp:245
double getAttributeDouble(SumoXMLAttr key) const override
Definition GNEPoly.cpp:580
~GNEPoly()
Destructor.
Definition GNEPoly.cpp:102
bool isValid(SumoXMLAttr key, const std::string &value) override
method for checking if the key and their conrrespond attribute are valids
Definition GNEPoly.cpp:620
void updateGeometry() override
update pre-computed geometry information
Definition GNEPoly.cpp:156
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
Definition GNEPoly.cpp:703
void fixAdditionalProblem() override
fix additional problem (must be reimplemented in all detector children)
Definition GNEPoly.cpp:217
void writeAdditional(OutputDevice &device) const override
write additional element into a xml file
Definition GNEPoly.cpp:199
void drawPolygonNameAndType(const GUIVisualizationSettings &s) const
draw polygon name and type
Definition GNEPoly.cpp:891
GNEPoly(SumoXMLTag tag, GNENet *net)
default Constructor
Definition GNEPoly.cpp:43
GNEMoveOperation * getMoveOperation() override
get move operation
Definition GNEPoly.cpp:106
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:345
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:170
void closePolygon(bool allowUndo=true)
close polygon
Definition GNEPoly.cpp:424
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point
Definition GNEPoly.cpp:445
std::string getAttribute(SumoXMLAttr key) const override
Definition GNEPoly.cpp:537
bool checkDrawMoveContour() const override
check if draw move contour (red)
Definition GNEPoly.cpp:229
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList) override
commit move shape
Definition GNEPoly.cpp:825
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:205
void setMoveShape(const GNEMoveResult &moveResult) override
set move shape
Definition GNEPoly.cpp:816
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:592
void deleteGeometryPoint(const Position &pos, bool allowUndo=true)
delete the geometry point closest to the given pos
Definition GNEPoly.cpp:361
Position getPositionInView() const override
Returns position of shape in view.
Definition GNEPoly.cpp:164
void drawGeometryPoints(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw geometry points
Definition GNEPoly.cpp:870
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList) override
remove geometry point in the clicked position
Definition GNEPoly.cpp:127
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GNEPoly.cpp:298
void drawPolygon(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw polygon
Definition GNEPoly.cpp:834
bool isAttributeEnabled(SumoXMLAttr key) const override
Definition GNEPoly.cpp:668
void drawPolygonContour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw contour
Definition GNEPoly.cpp:854
CommonXMLStructure::SumoBaseObject * getSumoBaseObject() const
get SUMOBaseObject with all polygon attributes
Definition GNEPoly.cpp:517
bool isPolygonClosed() const
check if polygon is closed
Definition GNEPoly.cpp:397
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GNEPoly.cpp:251
void simplifyShape(bool allowUndo=true)
replace the current shape with a rectangle
Definition GNEPoly.cpp:485
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList) override
split geometry
Definition GNEPoly.cpp:193
void updateCenteringBoundary(const bool updateGrid) override
update centering boundary (implies change in RTREE)
Definition GNEPoly.cpp:176
const Parameterised::Map & getACParametersMap() const override
get parameters map
Definition GNEPoly.cpp:586
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition GNEPoly.cpp:223
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition GNEPoly.cpp:150
void openPolygon(bool allowUndo=true)
open polygon
Definition GNEPoly.cpp:403
bool myClosedShape
flag to indicate if polygon is closed
Definition GNEPoly.h:239
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.
std::map< std::string, std::string > Map
parameters map
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
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
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:108
void setShapeName(const std::string &name)
Sets a new shape name.
Definition Shape.h:161
void setShapeLayer(const double layer)
Sets a new layer.
Definition Shape.h:142
const std::string & getShapeType() const
Returns the (abstract) type of the Shape.
Definition Shape.h:75
void setShapeType(const std::string &type)
Sets a new type.
Definition Shape.h:121
virtual void setShapeNaviDegree(const double angle)
Sets a new angle in navigational degrees.
Definition Shape.h:149
void setShapeImgFile(const std::string &imgFile)
Sets a new imgFile.
Definition Shape.h:156
void setShapeColor(const RGBColor &col)
Sets a new color.
Definition Shape.h:128
double getShapeLayer() const
Returns the layer of the Shape.
Definition Shape.h:89
const std::string & getShapeImgFile() const
Returns the imgFile of the Shape.
Definition Shape.h:103
const RGBColor & getShapeColor() const
Returns the color of the Shape.
Definition Shape.h:82
double getShapeNaviDegree() const
Returns the angle of the Shape in navigational degrees.
Definition Shape.h:96
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