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, DEFAULT_LINEWIDTH, DEFAULT_LAYER,
48DEFAULT_ANGLE, DEFAULT_IMG_FILE, DEFAULT_NAME, DEFAULT_HEIGHT, DEFAULT_PARAMETERS),
49 GNEAdditional(net, tag),
50myMoveElementShape(new GNEMoveElementShape(this)) {
51}
52
53
54GNEPoly::GNEPoly(const std::string& id, GNENet* net, FileBucket* fileBucket, const std::string& type, const PositionVector& shape,
55 const bool geo, const bool fill, const double lineWidth, const RGBColor& color, const double layer, const double angle,
56 const std::string& imgFile, const std::string& name, const double height, const Parameterised::Map& parameters) :
57 TesselatedPolygon(id, type, color, shape, geo, fill, lineWidth, layer, angle, imgFile, "", height, parameters),
58 GNEAdditional(id, net, SUMO_TAG_POLY, fileBucket, name),
59 myMoveElementShape(new GNEMoveElementShape(this, myShape, false)),
60 myClosedShape(shape.isClosed()) {
61 // check if imgFile is valid
62 if (!imgFile.empty() && GUITexturesHelper::getTextureID(imgFile) == -1) {
64 }
65 // set GEO shape
67 if (geo) {
68 for (int i = 0; i < (int) myGeoShape.size(); i++) {
70 }
71 } else {
72 for (int i = 0; i < (int) myGeoShape.size(); i++) {
74 }
75 }
76 // update centering boundary without updating grid
78 // update geometry
80}
81
82
83GNEPoly::GNEPoly(SumoXMLTag tag, const std::string& id, GNENet* net, FileBucket* fileBucket, const PositionVector& shape,
84 const bool geo, const std::string& name, const Parameterised::Map& parameters) :
85 TesselatedPolygon(id, getJuPedSimType(tag), getJuPedSimColor(tag), shape, geo, getJuPedSimFill(tag), DEFAULT_LINEWIDTH,
86 getJuPedSimLayer(tag), DEFAULT_ANGLE, DEFAULT_IMG_FILE, DEFAULT_NAME, DEFAULT_HEIGHT, parameters),
87 GNEAdditional(id, net, tag, fileBucket, name),
88 myMoveElementShape(new GNEMoveElementShape(this, myShape, (tag == GNE_TAG_JPS_WALKABLEAREA) || (tag == GNE_TAG_JPS_OBSTACLE))),
89 myClosedShape(shape.isClosed()),
90 mySimplifiedShape(false) {
91 // set GEO shape
93 if (geo) {
94 for (int i = 0; i < (int) myGeoShape.size(); i++) {
96 }
97 } else {
98 for (int i = 0; i < (int) myGeoShape.size(); i++) {
100 }
101 }
102 // update centering boundary without updating grid
104 // update geometry
106}
107#ifdef _MSC_VER
108#pragma warning(pop)
109#endif
110
111
115
116
121
122
125 return this;
126}
127
128
129const Parameterised*
131 return this;
132}
133
134
135std::string
137 return "";
138}
139
140
141void
143 // just update polygon geometry
145 myTesselation.clear();
146}
147
148
153
154
155double
157 return s.polySize.getExaggeration(s, this);
158}
159
160
161void
162GNEPoly::updateCenteringBoundary(const bool updateGrid) {
163 // Remove object from net
164 if (updateGrid) {
166 }
167 // use shape as boundary
169 // grow boundary
171 // add object into net
172 if (updateGrid) {
174 }
175}
176
177
178void
179GNEPoly::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
180 // nothing to split
181}
182
183
184void
186 device.openTag(SUMO_TAG_POLY);
187 // write common additional attributes
189 // write specific attributes
190 PositionVector shape = getShape();
191 if (myGEO) {
192 device.writeAttr(SUMO_ATTR_GEO, true);
193 for (int i = 0; i < (int) shape.size(); i++) {
195 }
196 }
197 if (getShapeType().size() > 0) {
199 }
204 }
205 if (getHeight() != DEFAULT_HEIGHT) {
207 }
209
211 device.writeAttr(SUMO_ATTR_SHAPE, shape);
212 device.setPrecision();
215 }
218 }
219
220 writeParams(device);
221 device.closeTag();
222}
223
224
225bool
227 return true;
228}
229
230
231std::string
233 return "";
234}
235
236
237void
239 // nothing to fix
240}
241
242
245 return GUIGlObject::getGlID();
246}
247
248
249bool
251 // get edit modes
252 const auto& editModes = myNet->getViewNet()->getEditModes();
253 // check if we're in move mode
254 if (!myNet->getViewNet()->isCurrentlyMovingElements() && editModes.isCurrentSupermodeNetwork() &&
256 (editModes.networkEditMode == NetworkEditMode::NETWORK_MOVE) && myNet->getViewNet()->checkOverLockedElement(this, mySelected)) {
257 // only move the first element
259 } else {
260 return false;
261 }
262}
263
264
265std::string
267 return myNet->getMicrosimID();
268}
269
270
273 // create popup
274 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, this);
275 // build common options
277 FXMenuCommand* simplifyShape = GUIDesigns::buildFXMenuCommand(ret, TL("Simplify Shape"), TL("Replace current shape with a rectangle"), nullptr, &parent, MID_GNE_POLYGON_SIMPLIFY_SHAPE);
278 // disable simplify shape if polygon was already simplified
279 if (mySimplifiedShape || myShape.size() <= 2) {
280 simplifyShape->disable();
281 }
282 // only allow open/close for non juPedSim polygons
284 if (myShape.isClosed()) {
285 GUIDesigns::buildFXMenuCommand(ret, TL("Open shape"), TL("Open polygon's shape"), nullptr, &parent, MID_GNE_POLYGON_OPEN);
286 } else {
287 GUIDesigns::buildFXMenuCommand(ret, TL("Close shape"), TL("Close polygon's shape"), nullptr, &parent, MID_GNE_POLYGON_CLOSE);
288 }
289 }
290 GUIDesigns::buildFXMenuCommand(ret, TL("Select elements within polygon"), TL("Select elements within polygon boundary"), nullptr, &parent, MID_GNE_POLYGON_SELECT);
291 if (myShape.size() > 3) {
292 GUIDesigns::buildFXMenuCommand(ret, TL("Triangulate polygon"), TL("Convert the current polygon in triangles"), nullptr, &parent, MID_GNE_POLYGON_TRIANGULATE);
293 }
294 // create a extra FXMenuCommand if mouse is over a vertex
295 const int index = getVertexIndex(myNet->getViewNet()->getPositionInformation(), false);
296 if (index != -1) {
297 // add separator
298 new FXMenuSeparator(ret);
299 // check if we're in network mode
301 GUIDesigns::buildFXMenuCommand(ret, "Set custom Geometry Point", nullptr, &parent, MID_GNE_CUSTOM_GEOMETRYPOINT);
302 }
303 FXMenuCommand* removeGeometryPoint = GUIDesigns::buildFXMenuCommand(ret, TL("Remove geometry point"), TL("Remove geometry point under mouse"), nullptr, &parent, MID_GNE_POLYGON_DELETE_GEOMETRY_POINT);
304 FXMenuCommand* setFirstPoint = GUIDesigns::buildFXMenuCommand(ret, TL("Set first geometry point"), TL("Set first geometry point"), nullptr, &parent, MID_GNE_POLYGON_SET_FIRST_POINT);
305 // disable setFirstPoint if shape only have three points
306 if ((myShape.isClosed() && (myShape.size() <= 4)) || (!myShape.isClosed() && (myShape.size() <= 2))) {
307 removeGeometryPoint->disable();
308 }
309 // disable setFirstPoint if mouse is over first point
310 if (index == 0) {
311 setFirstPoint->disable();
312 }
313 }
314 return ret;
315}
316
317
318void
320 // first check if poly can be drawn
323 GUIPolygon::checkDraw(s, this, this)) {
324 // draw boundary
325 const auto boundary = getCenteringBoundary();
327 // get exaggeration
328 const double polyExaggeration = getExaggeration(s);
329 // get detail level
330 const auto d = s.getDetailLevel(polyExaggeration);
331 // draw geometry only if we'rent in drawForObjectUnderCursor mode
332 if (s.checkDrawPoly(boundary, isAttributeCarrierSelected())) {
333 // get colors
335 // push layer matrix
337 // translate to front
339 // draw polygon
340 drawPolygon(s, d, color, polyExaggeration);
341 // draw contour if don't move whole polygon
343 // get darker color
344 const RGBColor darkerColor = color.changedBrightness(-32);
345 // draw contour
346 drawPolygonContour(s, d, darkerColor, polyExaggeration);
347 // draw geometry points
348 drawGeometryPoints(s, d, darkerColor, polyExaggeration);
349 }
350 // pop layer matrix
352 // draw name and type
354 // draw lock icon
356 // draw dotted contour
358 }
359 // calculate contour
360 calculateContourPolygons(s, d, getShapeLayer(), polyExaggeration, getFill());
361 }
362}
363
364
365int
366GNEPoly::getVertexIndex(Position pos, bool snapToGrid) {
367 // check if position has to be snapped to grid
368 if (snapToGrid) {
369 pos = myNet->getViewNet()->snapToActiveGrid(pos);
370 }
371 // first check if vertex already exists
372 for (const auto& shapePosition : myShape) {
373 if (shapePosition.distanceTo2D(pos) < myNet->getViewNet()->getVisualisationSettings().neteditSizeSettings.polygonGeometryPointRadius) {
374 return myShape.indexOfClosest(shapePosition);
375 }
376 }
377 return -1;
378}
379
380
381void
382GNEPoly::deleteGeometryPoint(const Position& pos, bool allowUndo) {
383 if (myShape.size() > 1) {
384 // obtain index
385 PositionVector modifiedShape = myShape;
386 int index = modifiedShape.indexOfClosest(pos);
387 // remove point dependending of
388 if (myShape.isClosed() && (index == 0 || index == (int)modifiedShape.size() - 1) && (myShape.size() > 2)) {
389 modifiedShape.erase(modifiedShape.begin());
390 modifiedShape.erase(modifiedShape.end() - 1);
391 modifiedShape.push_back(modifiedShape.front());
392 } else {
393 modifiedShape.erase(modifiedShape.begin() + index);
394 }
395 // set new shape depending of allowUndo
396 if (allowUndo) {
397 myNet->getUndoList()->begin(this, "delete geometry point");
399 myNet->getUndoList()->end();
400 } else {
401 // first remove object from grid due shape is used for boundary
403 // set new shape
404 myShape = modifiedShape;
405 // disable simplified shape flag
406 mySimplifiedShape = false;
407 // add object into grid again
409 }
410 myTesselation.clear();
411 } else {
412 WRITE_WARNING(TL("Number of remaining points insufficient"))
413 }
414}
415
416
417bool
419 return myShape.isClosed();
420}
421
422
423void
424GNEPoly::openPolygon(bool allowUndo) {
425 // only open if shape is closed
426 if (myShape.isClosed()) {
427 if (allowUndo) {
428 myNet->getUndoList()->begin(this, "open polygon");
430 myNet->getUndoList()->end();
431 } else {
432 myShape.pop_back();
433 // disable simplified shape flag
434 mySimplifiedShape = false;
435 // update geometry to avoid grabbing Problems
437 }
438 } else {
439 WRITE_WARNING(TL("Polygon already opened"))
440 }
441}
442
443
444void
445GNEPoly::closePolygon(bool allowUndo) {
446 // only close if shape is opened
447 if (!myShape.isClosed()) {
448 if (allowUndo) {
449 myNet->getUndoList()->begin(this, "close shape");
451 myNet->getUndoList()->end();
452 } else {
454 // disable simplified shape flag
455 mySimplifiedShape = false;
456 // update geometry to avoid grabbing Problems
458 }
459 } else {
460 WRITE_WARNING(TL("Polygon already closed"))
461 }
462}
463
464
465void
466GNEPoly::changeFirstGeometryPoint(int oldIndex, bool allowUndo) {
467 // check that old index is correct
468 if (oldIndex >= (int)myShape.size()) {
469 throw InvalidArgument("Invalid old Index");
470 } else if (oldIndex == 0) {
471 WRITE_WARNING(TL("Selected point must be different of the first point"))
472 } else {
473 // Configure new shape
474 PositionVector newShape;
475 for (int i = oldIndex; i < (int)myShape.size(); i++) {
476 newShape.push_back(myShape[i]);
477 }
478 if (myShape.isClosed()) {
479 for (int i = 1; i < oldIndex; i++) {
480 newShape.push_back(myShape[i]);
481 }
482 newShape.push_back(newShape.front());
483 } else {
484 for (int i = 0; i < oldIndex; i++) {
485 newShape.push_back(myShape[i]);
486 }
487 }
488 // set new rotated shape
489 if (allowUndo) {
490 myNet->getUndoList()->begin(this, "change first geometry point");
492 myNet->getUndoList()->end();
493 } else {
494 // set new shape
495 myShape = newShape;
496 // disable simplified shape flag
497 mySimplifiedShape = false;
498 // update geometry to avoid grabbing Problems
500 }
501 }
502}
503
504
505void
506GNEPoly::simplifyShape(bool allowUndo) {
507 if (!mySimplifiedShape && myShape.size() > 2) {
508 const Boundary b = myShape.getBoxBoundary();
509 // create a square as simplified shape
510 PositionVector simplifiedShape;
511 simplifiedShape.push_back(Position(b.xmin(), b.ymin()));
512 simplifiedShape.push_back(Position(b.xmin(), b.ymax()));
513 simplifiedShape.push_back(Position(b.xmax(), b.ymax()));
514 simplifiedShape.push_back(Position(b.xmax(), b.ymin()));
515 if (myShape.isClosed()) {
516 simplifiedShape.push_back(simplifiedShape[0]);
517 }
518 // set new shape depending of allowUndo
519 if (allowUndo) {
520 myNet->getUndoList()->begin(this, "simplify shape");
522 myNet->getUndoList()->end();
523 } else {
524 // set new shape
525 myShape = simplifiedShape;
526 // update geometry to avoid grabbing Problems
528 }
529 // change flag after setting simplified shape
530 mySimplifiedShape = true;
531 } else {
532 WRITE_WARNING(TL("Polygon already simplified"))
533 }
534}
535
536
540 polygonBaseObject->setTag(myTagProperty->getTag());
541 // fill attributes
542 polygonBaseObject->addStringAttribute(SUMO_ATTR_ID, myID);
544 polygonBaseObject->addBoolAttribute(SUMO_ATTR_GEO, myGEO);
545 polygonBaseObject->addBoolAttribute(SUMO_ATTR_FILL, myFill);
547 polygonBaseObject->addColorAttribute(SUMO_ATTR_COLOR, getShapeColor());
548 polygonBaseObject->addStringAttribute(SUMO_ATTR_TYPE, getShapeType());
549 polygonBaseObject->addDoubleAttribute(SUMO_ATTR_LAYER, getShapeLayer());
553 polygonBaseObject->addDoubleAttribute(SUMO_ATTR_HEIGHT, myHeight);
554 return polygonBaseObject;
555}
556
557
558std::string
560 switch (key) {
561 case SUMO_ATTR_ID:
562 return myID;
563 case SUMO_ATTR_SHAPE:
564 if ((GeoConvHelper::getFinal().getProjString() != "!") && myGEO) {
565 return TL("Using GEO Shape");
566 } else {
567 return toString(myShape);
568 }
570 if (GeoConvHelper::getFinal().getProjString() != "!") {
572 } else {
573 return TL("No geo-conversion defined");
574 }
575 case SUMO_ATTR_COLOR:
576 return toString(getShapeColor());
577 case SUMO_ATTR_FILL:
578 return toString(myFill);
580 return toString(myLineWidth);
581 case SUMO_ATTR_LAYER:
582 return toString(getShapeLayer());
583 case SUMO_ATTR_TYPE:
584 return getShapeType();
586 return getShapeImgFile();
587 case SUMO_ATTR_ANGLE:
589 case SUMO_ATTR_GEO:
590 return toString(myGEO);
591 case SUMO_ATTR_NAME:
592 return myAdditionalName;
594 return toString(myClosedShape);
595 case SUMO_ATTR_HEIGHT:
596 return toString(myHeight);
597 default:
598 return getCommonAttribute(key);
599 }
600}
601
602
603double
607
608
613
614
619
620
621void
622GNEPoly::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
623 if (value == getAttribute(key)) {
624 return; //avoid needless changes, later logic relies on the fact that attributes have changed
625 }
626 switch (key) {
627 case SUMO_ATTR_ID:
628 case SUMO_ATTR_SHAPE:
630 case SUMO_ATTR_COLOR:
631 case SUMO_ATTR_FILL:
633 case SUMO_ATTR_LAYER:
634 case SUMO_ATTR_TYPE:
636 case SUMO_ATTR_ANGLE:
637 case SUMO_ATTR_GEO:
638 case SUMO_ATTR_NAME:
639 case SUMO_ATTR_HEIGHT:
641 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
642 break;
643 default:
644 setCommonAttribute(key, value, undoList);
645 break;
646 }
647}
648
649
650bool
651GNEPoly::isValid(SumoXMLAttr key, const std::string& value) {
652 switch (key) {
653 case SUMO_ATTR_ID:
655 case SUMO_ATTR_SHAPE:
657 // empty shapes AREN'T allowed
658 if (value.empty()) {
659 return false;
660 } else {
661 return canParse<PositionVector>(value);
662 }
663 case SUMO_ATTR_COLOR:
664 return canParse<RGBColor>(value);
665 case SUMO_ATTR_FILL:
666 return canParse<bool>(value);
668 return canParse<double>(value) && (parse<double>(value) >= 0);
669 case SUMO_ATTR_LAYER:
670 if (value.empty()) {
671 return true;
672 } else {
673 return canParse<double>(value);
674 }
675 case SUMO_ATTR_TYPE:
676 return true;
678 if (value == "") {
679 return true;
680 } else {
681 // check that image can be loaded
682 return GUITexturesHelper::getTextureID(value) != -1;
683 }
684 case SUMO_ATTR_ANGLE:
685 return canParse<double>(value);
686 case SUMO_ATTR_GEO:
687 return canParse<bool>(value);
688 case SUMO_ATTR_NAME:
690 case SUMO_ATTR_HEIGHT:
691 return canParse<double>(value) && (parse<double>(value) >= 0);
693 return canParse<bool>(value);
694 default:
695 return isCommonAttributeValid(key, value);
696 }
697}
698
699
700bool
702 switch (key) {
703 case SUMO_ATTR_SHAPE:
704 if (GeoConvHelper::getFinal().getProjString() != "!") {
705 return myGEO == false;
706 } else {
707 return true;
708 }
709 case SUMO_ATTR_GEO:
710 return GeoConvHelper::getFinal().getProjString() != "!";
712 if (GeoConvHelper::getFinal().getProjString() != "!") {
713 return myGEO == true;
714 } else {
715 return false;
716 }
718 if (isTemplate()) {
719 return true;
720 } else {
721 return myShape.size() > 1;
722 }
723 default:
724 return true;
725 }
726}
727
728
729std::string
731 return getTagStr() + ": " + getID();
732}
733
734
735std::string
737 return getTagStr();
738}
739
740// ===========================================================================
741// private
742// ===========================================================================
743
744void
745GNEPoly::setAttribute(SumoXMLAttr key, const std::string& value) {
746 switch (key) {
747 case SUMO_ATTR_ID: {
748 // update microsimID
749 setAdditionalID(value);
750 // set named ID
751 myID = value;
752 break;
753 }
754 case SUMO_ATTR_SHAPE: {
755 // set new shape
756 myShape = parse<PositionVector>(value);
757 // set GEO shape
759 for (int i = 0; i < (int) myGeoShape.size(); i++) {
761 }
762 // disable simplified shape flag
763 mySimplifiedShape = false;
764 // update geometry
766 // update centering boundary
768 break;
769 }
770 case SUMO_ATTR_GEOSHAPE: {
771 // set new GEO shape
772 myGeoShape = parse<PositionVector>(value);
773 // set shape
775 for (int i = 0; i < (int) myShape.size(); i++) {
777 }
778 // disable simplified shape flag
779 mySimplifiedShape = false;
780 // update geometry
782 // update centering boundary
784 break;
785 }
786 case SUMO_ATTR_COLOR:
787 setShapeColor(parse<RGBColor>(value));
788 break;
789 case SUMO_ATTR_FILL:
790 myFill = parse<bool>(value);
792 break;
794 myLineWidth = parse<double>(value);
795 break;
796 case SUMO_ATTR_LAYER:
797 if (value.empty()) {
799 } else {
800 setShapeLayer(parse<double>(value));
801 }
802 break;
803 case SUMO_ATTR_TYPE:
804 setShapeType(value);
805 break;
807 setShapeImgFile(value);
808 // all textures must be refresh
810 break;
811 case SUMO_ATTR_ANGLE:
812 setShapeNaviDegree(parse<double>(value));
813 break;
814 case SUMO_ATTR_GEO:
815 myGEO = parse<bool>(value);
816 // update centering boundary
818 break;
819 case SUMO_ATTR_NAME:
820 myAdditionalName = value;
821 break;
822 case SUMO_ATTR_HEIGHT:
823 myHeight = parse<double>(value);
824 break;
826 myClosedShape = parse<bool>(value);
827 if (!isTemplate()) {
828 if (myClosedShape) {
831
832 } else {
835 }
836 // disable simplified shape flag
837 mySimplifiedShape = false;
838 // update geometry
840 // update centering boundary
842 }
843 break;
844 default:
845 setCommonAttribute(key, value);
846 break;
847 }
848}
849
850
851void
853 const RGBColor& color, const double exaggeration) const {
854 // check if we're drawing a polygon or a polyline
855 if (getFill()) {
856 // draw inner polygon
858 } else {
859 // push matrix
861 // set color
862 GLHelper::setColor(color);
863 // draw geometry (polyline)
865 // pop matrix
867 }
868}
869
870
871void
873 const RGBColor& color, const double exaggeration) const {
874 // push contour matrix
876 // translate to front
877 glTranslated(0, 0, 0.1);
878 // set color
879 GLHelper::setColor(color);
880 // draw polygon contour
882 // pop contour matrix
884}
885
886
887void
889 const RGBColor& color, const double exaggeration) const {
890 // draw shape points only in supermode network
892 // check if we're in move mode
894 // get geometry point sizes
895 const double geometryPointSize = s.neteditSizeSettings.polygonGeometryPointRadius * (moveMode ? 1 : 0.5);
896 // draw geometry points
897 GUIGeometry::drawGeometryPoints(d, myAdditionalGeometry.getShape(), color, geometryPointSize, exaggeration,
900 // draw dotted contours for geometry points if we're in move mode
901 if (moveMode) {
904 }
905 }
906}
907
908
909void
911 // get name position
913 // draw name
914 drawName(namePos, s.scale, s.polyName, s.angle);
915 // check if draw poly type
916 if (s.polyType.show(this)) {
917 const Position p = namePos + Position(0, -0.6 * s.polyType.size / s.scale);
919 }
920}
921
922/****************************************************************************/
@ 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_HEIGHT
@ 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:124
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:232
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
Definition GNEPoly.cpp:730
std::string getParentName() const override
Returns the name of the parent object.
Definition GNEPoly.cpp:266
double getAttributeDouble(SumoXMLAttr key) const override
Definition GNEPoly.cpp:604
~GNEPoly()
Destructor.
Definition GNEPoly.cpp:112
bool isValid(SumoXMLAttr key, const std::string &value) override
method for checking if the key and their conrrespond attribute are valids
Definition GNEPoly.cpp:651
void updateGeometry() override
update pre-computed geometry information
Definition GNEPoly.cpp:142
GNEMoveElementShape * myMoveElementShape
move element shape
Definition GNEPoly.h:253
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
Definition GNEPoly.cpp:736
void fixAdditionalProblem() override
fix additional problem (must be reimplemented in all detector children)
Definition GNEPoly.cpp:238
void writeAdditional(OutputDevice &device) const override
write additional element into a xml file
Definition GNEPoly.cpp:185
void drawPolygonNameAndType(const GUIVisualizationSettings &s) const
draw polygon name and type
Definition GNEPoly.cpp:910
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:118
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:366
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:156
void closePolygon(bool allowUndo=true)
close polygon
Definition GNEPoly.cpp:445
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point
Definition GNEPoly.cpp:466
std::string getAttribute(SumoXMLAttr key) const override
Definition GNEPoly.cpp:559
bool checkDrawMoveContour() const override
check if draw move contour (red)
Definition GNEPoly.cpp:250
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:226
Position getAttributePosition(SumoXMLAttr key) const override
Definition GNEPoly.cpp:610
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:622
void deleteGeometryPoint(const Position &pos, bool allowUndo=true)
delete the geometry point closest to the given pos
Definition GNEPoly.cpp:382
Position getPositionInView() const override
Returns position of shape in view.
Definition GNEPoly.cpp:150
void drawGeometryPoints(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw geometry points
Definition GNEPoly.cpp:888
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GNEPoly.cpp:319
PositionVector getAttributePositionVector(SumoXMLAttr key) const override
Definition GNEPoly.cpp:616
void drawPolygon(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw polygon
Definition GNEPoly.cpp:852
bool isAttributeEnabled(SumoXMLAttr key) const override
Definition GNEPoly.cpp:701
void drawPolygonContour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw contour
Definition GNEPoly.cpp:872
CommonXMLStructure::SumoBaseObject * getSumoBaseObject() const
get SUMOBaseObject with all polygon attributes
Definition GNEPoly.cpp:538
bool isPolygonClosed() const
check if polygon is closed
Definition GNEPoly.cpp:418
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GNEPoly.cpp:272
void simplifyShape(bool allowUndo=true)
replace the current shape with a rectangle
Definition GNEPoly.cpp:506
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList) override
split geometry
Definition GNEPoly.cpp:179
void updateCenteringBoundary(const bool updateGrid) override
update centering boundary (implies change in RTREE)
Definition GNEPoly.cpp:162
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition GNEPoly.cpp:244
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition GNEPoly.cpp:136
void openPolygon(bool allowUndo=true)
open polygon
Definition GNEPoly.cpp:424
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 drawSymbols, 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, const bool escape=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:210
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 myHeight
The line width for drawing an unfilled polygon.
double getLineWidth() const
Returns the line width.
double getHeight() const
Returns the polygon height.
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)
static const double DEFAULT_HEIGHT
Definition Shape.h:50
void setShapeLayer(const double layer)
Sets a new layer.
Definition Shape.cpp:153
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:99
static const double DEFAULT_LINEWIDTH
Definition Shape.h:44
void setShapeType(const std::string &type)
Sets a new type.
Definition Shape.cpp:135
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:159
void setShapeImgFile(const std::string &imgFile)
Sets a new imgFile.
Definition Shape.cpp:165
void setShapeColor(const RGBColor &col)
Sets a new color.
Definition Shape.cpp:141
double getShapeLayer() const
Returns the layer of the Shape.
Definition Shape.cpp:111
const std::string & getShapeImgFile() const
Returns the imgFile of the Shape.
Definition Shape.cpp:123
const RGBColor & getShapeColor() const
Returns the color of the Shape.
Definition Shape.cpp:105
double getShapeNaviDegree() const
Returns the angle of the Shape in navigational degrees.
Definition Shape.cpp:117
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:79
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
bool showPolygonSymbols() const
check if draw polygon symbols
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