Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEPOI.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// GUIPointOfInterest and NLHandler)
20/****************************************************************************/
21#include <config.h>
22
23#include <string>
24#include <netedit/GNENet.h>
25#include <netedit/GNEUndoList.h>
26#include <netedit/GNEViewNet.h>
39
40#include "GNEPOI.h"
42
43
44// ===========================================================================
45// method definitions
46// ===========================================================================
47
49 PointOfInterest("", "", RGBColor::BLACK, Position(0, 0), false, "", 0, false, 0, SUMOXMLDefinitions::POIIcons.getString(POIIcon::NONE), 0, 0, "", false, 0, 0, "", Parameterised::Map()),
50 GNEAdditional("", net, GLO_POI, tag, GUIIconSubSys::getIcon(GUIIcon::POI), "", {}, {}, {}, {}, {}, {}) {
51 // reset default values
52 resetDefaultValues();
53}
54
55
56GNEPOI::GNEPOI(GNENet* net, const std::string& id, const std::string& type, const RGBColor& color, const double xLon,
57 const double yLat, const bool geo, const std::string& icon, const double layer, const double angle,
58 const std::string& imgFile, const bool relativePath, const double width, const double height,
59 const std::string& name, const Parameterised::Map& parameters) :
60 PointOfInterest(id, type, color, Position(xLon, yLat), geo, "", 0, false, 0, icon, layer, angle, imgFile, relativePath, width, height, name, parameters),
62 "", {}, {}, {}, {}, {}, {}) {
63 // update position depending of GEO
64 if (geo) {
65 Position cartesian(x(), y());
67 set(cartesian.x(), cartesian.y());
68 }
69 // update geometry (needed for adjust myShapeWidth and myShapeHeight)
70 updateGeometry();
71 // update centering boundary without updating grid
72 updateCenteringBoundary(false);
73}
74
75
76GNEPOI::GNEPOI(GNENet* net, const std::string& id, const std::string& type, const RGBColor& color, GNELane* lane, const double posOverLane,
77 const bool friendlyPos, const double posLat, const std::string& icon, const double layer, const double angle,
78 const std::string& imgFile, const bool relativePath, const double width, const double height,
79 const std::string& name, const Parameterised::Map& parameters) :
80 PointOfInterest(id, type, color, Position(), false, lane->getID(), posOverLane, friendlyPos, posLat, icon, layer, angle, imgFile, relativePath, width, height, name, parameters),
81 GNEAdditional(id, net, GLO_POI, GNE_TAG_POILANE, GUIIconSubSys::getIcon(GUIIcon::POILANE), "", {}, {}, {lane}, {}, {}, {}) {
82 // update geometry (needed for adjust myShapeWidth and myShapeHeight)
83 updateGeometry();
84 // update centering boundary without updating grid
85 updateCenteringBoundary(false);
86}
87
88
90
91
97 // get snap radius
99 const double snapRadiusSquared = snapRadius * snapRadius;
100 // get mouse position
101 const Position mousePosition = myNet->getViewNet()->getPositionInformation();
102 // check if we're editing width or height
103 if ((myShapeWidth.size() == 0) || (myShapeHeight.size() == 0)) {
104 return nullptr;
105 } else if (myShapeHeight.front().distanceSquaredTo2D(mousePosition) <= snapRadiusSquared) {
106 // edit height
108 } else if (myShapeHeight.back().distanceSquaredTo2D(mousePosition) <= snapRadiusSquared) {
109 // edit height
111 } else if (myShapeWidth.front().distanceSquaredTo2D(mousePosition) <= snapRadiusSquared) {
112 // edit width
114 } else if (myShapeWidth.back().distanceSquaredTo2D(mousePosition) <= snapRadiusSquared) {
115 // edit width
117 } else {
118 return nullptr;
119 }
120 } else if (getTagProperty().getTag() == GNE_TAG_POILANE) {
121 // return move operation for POI placed over lane
122 return new GNEMoveOperation(this, getParentLanes().front(), myPosOverLane,
124 } else {
125 // return move operation for a position in view
126 return new GNEMoveOperation(this, *this);
127 }
128}
129
130
131void
132GNEPOI::removeGeometryPoint(const Position /*clickedPosition*/, GNEUndoList* /*undoList*/) {
133 // nothing to remove
134}
135
136
137std::string
139 return "";
140}
141
142
146 POIBaseObject->setTag(SUMO_TAG_POI);
147 // fill attributes
148 POIBaseObject->addStringAttribute(SUMO_ATTR_ID, myID);
159 return POIBaseObject;
160}
161
162
163void
165 if (getParentLanes().size() > 0) {
166 // obtain fixed position over lane
167 double fixedPositionOverLane = myPosOverLane > getParentLanes().at(0)->getLaneShape().length() ? getParentLanes().at(0)->getLaneShape().length() : myPosOverLane < 0 ? 0 : myPosOverLane;
168 // write POILane using POI::writeXML
169 writeXML(device, false, 0, getParentLanes().at(0)->getID(), fixedPositionOverLane, myFriendlyPos, myPosLat);
170 } else {
171 writeXML(device, myGeo);
172 }
173}
174
175
176bool
178 // only for POIS over lanes
179 if (getParentLanes().size() == 0) {
180 return true;
181 } else if (getFriendlyPos()) {
182 // with friendly position enabled position is "always fixed"
183 return true;
184 } else {
185 return fabs(myPosOverLane) <= getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength();
186 }
187}
188
189
190std::string
192 // only for POIS over lanes
193 if (getParentLanes().size() > 0) {
194 // obtain final length
195 const double len = getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength();
196 // check if detector has a problem
198 return "";
199 } else {
200 // declare variable for error position
201 std::string errorPosition;
202 // check positions over lane
203 if (myPosOverLane < 0) {
204 errorPosition = (toString(SUMO_ATTR_POSITION) + " < 0");
205 }
206 if (myPosOverLane > len) {
207 errorPosition = (toString(SUMO_ATTR_POSITION) + TL(" > lanes's length"));
208 }
209 return errorPosition;
210 }
211 } else {
212 return "";
213 }
214}
215
216
217void
219 // only for POIS over lanes
220 if (getParentLanes().size() > 0) {
221 // declare new position
222 double newPositionOverLane = myPosOverLane;
223 // declare new length (but unsed in this context)
224 double length = 0;
225 // fix pos and length with fixLanePosition
226 GNEAdditionalHandler::fixLanePosition(newPositionOverLane, length, getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength());
227 // set new position
229 }
230}
231
232
233void
235 // set position
236 if (getParentLanes().size() > 0) {
237 // obtain fixed position over lane
238 double fixedPositionOverLane = myPosOverLane > getParentLanes().at(0)->getLaneShapeLength() ? getParentLanes().at(0)->getLaneShapeLength() : myPosOverLane < 0 ? 0 : myPosOverLane;
239 // set new position regarding to lane
240 set(getParentLanes().at(0)->getLaneShape().positionAtOffset(fixedPositionOverLane * getParentLanes().at(0)->getLengthGeometryFactor(), -myPosLat));
241 }
242 // check if update width and height shapes
243 if ((getWidth() > 0) && (getHeight() > 0)) {
244 // calculate shape length
245 myShapeHeight.clear();
246 myShapeHeight.push_back(Position(0, getHeight() * -0.5));
247 myShapeHeight.push_back(Position(0, getHeight() * 0.5));
248 // move
249 myShapeHeight.add(*this);
250 // calculate shape width
251 PositionVector leftShape = myShapeHeight;
252 leftShape.move2side(getWidth() * -0.5);
253 PositionVector rightShape = myShapeHeight;
254 rightShape.move2side(getWidth() * 0.5);
255 myShapeWidth = {leftShape.getCentroid(), rightShape.getCentroid()};
256 }
257}
258
259
262 return *this;
263}
264
265
266double
268 return s.poiSize.getExaggeration(s, this);
269}
270
271
272void
273GNEPOI::updateCenteringBoundary(const bool updateGrid) {
274 // Remove object from net
275 if (updateGrid) {
277 }
278 // reset boundary
280 // add position (this POI)
282 // grow boundary
283 myAdditionalBoundary.grow(5 + std::max(getWidth() * 0.5, getHeight() * 0.5));
284 // add object into net
285 if (updateGrid) {
287 }
288}
289
290
291void
292GNEPOI::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
293 // nothing to split
294}
295
296
299 return GUIGlObject::getGlID();
300}
301
302
303bool
305 // get edit modes
306 const auto& editModes = myNet->getViewNet()->getEditModes();
307 // check if we're in move mode
308 if (!myNet->getViewNet()->isCurrentlyMovingElements() && editModes.isCurrentSupermodeNetwork() &&
310 (editModes.networkEditMode == NetworkEditMode::NETWORK_MOVE) && myNet->getViewNet()->checkOverLockedElement(this, mySelected)) {
311 // only move the first element
313 } else {
314 return false;
315 }
316}
317
318
319std::string
321 if (getParentLanes().size() > 0) {
322 return getParentLanes().front()->getID();
323 } else {
324 return myNet->getMicrosimID();
325 }
326}
327
328
331 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
332 buildPopupHeader(ret, app);
335 // build selection and show parameters menu
338 buildPositionCopyEntry(ret, app);
339 new FXMenuSeparator(ret);
340 // specific of non juPedSim polygons
342 // continue depending of lane number
343 if (getParentLanes().size() > 0) {
344 // add option for convert to GNEPOI
346 return ret;
347 } else {
348 // add option for convert to GNEPOI
350 }
351 }
352 return ret;
353}
354
355
356void
358 // first check if POI can be drawn
361 // draw boundaries
363 // obtain POIExaggeration
364 const double POIExaggeration = getExaggeration(s);
365 // get detail level
366 const auto d = s.getDetailLevel(POIExaggeration);
367 // check if draw moving geometry points (only if we have a defined image
368 const bool movingGeometryPoints = getShapeImgFile().empty() ? false : drawMovingGeometryPoints(false);
369 // draw geometry only if we'rent in drawForObjectUnderCursor mode
371 // draw POI
372 drawPOI(s, d, movingGeometryPoints);
373 // draw lock icon
375 // draw dotted contours
376 if (movingGeometryPoints) {
377 // get snap radius
379 const double snapRadiusSquared = snapRadius * snapRadius;
380 // get mouse position
381 const Position mousePosition = myNet->getViewNet()->getPositionInformation();
382 // check if we're editing width or height
383 if ((myShapeHeight.front().distanceSquaredTo2D(mousePosition) <= snapRadiusSquared) ||
384 (myShapeHeight.back().distanceSquaredTo2D(mousePosition) <= snapRadiusSquared)) {
387 } else if ((myShapeWidth.front().distanceSquaredTo2D(mousePosition) <= snapRadiusSquared) ||
388 (myShapeWidth.back().distanceSquaredTo2D(mousePosition) <= snapRadiusSquared)) {
391 }
392 } else {
394 }
395 }
396 // calculate contour
397 calculatePOIContour(s, d, POIExaggeration, movingGeometryPoints);
398 }
399}
400
401
402std::string
404 switch (key) {
405 case SUMO_ATTR_ID:
406 return myID;
407 case SUMO_ATTR_COLOR:
408 return toString(getShapeColor());
409 case SUMO_ATTR_LANE:
410 return myLane;
412 if (getParentLanes().size() > 0) {
413 return toString(myPosOverLane);
414 } else {
415 return toString(*this);
416 }
418 return toString(getFriendlyPos());
420 return toString(myPosLat);
421 case SUMO_ATTR_LON: {
422 // calculate geo position
423 Position GEOPosition(x(), y());
425 // return lon
426 return toString(GEOPosition.x(), 8);
427 }
428 case SUMO_ATTR_LAT: {
429 // calculate geo position
430 Position GEOPosition(x(), y());
432 // return lat
433 return toString(GEOPosition.y(), 8);
434 }
435 case SUMO_ATTR_TYPE:
436 return getShapeType();
437 case SUMO_ATTR_ICON:
438 return getIconStr();
439 case SUMO_ATTR_LAYER:
441 return "default";
442 } else {
443 return toString(getShapeLayer());
444 }
446 return getShapeImgFile();
449 case SUMO_ATTR_WIDTH:
450 return toString(getWidth());
451 case SUMO_ATTR_HEIGHT:
452 return toString(getHeight());
453 case SUMO_ATTR_ANGLE:
455 case SUMO_ATTR_NAME:
456 return getShapeName();
462 return "";
463 default:
464 throw InvalidArgument(getTagStr() + " attribute '" + toString(key) + "' not allowed");
465 }
466}
467
468
469double
471 throw InvalidArgument(getTagStr() + " attribute '" + toString(key) + "' not allowed");
472}
473
474
479
480
481void
482GNEPOI::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
483 switch (key) {
484 case SUMO_ATTR_ID:
485 case SUMO_ATTR_COLOR:
486 case SUMO_ATTR_LANE:
490 case SUMO_ATTR_LON:
491 case SUMO_ATTR_LAT:
492 case SUMO_ATTR_TYPE:
493 case SUMO_ATTR_ICON:
494 case SUMO_ATTR_LAYER:
497 case SUMO_ATTR_WIDTH:
498 case SUMO_ATTR_HEIGHT:
499 case SUMO_ATTR_ANGLE:
500 case SUMO_ATTR_NAME:
504 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
505 break;
506 default:
507 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
508 }
509}
510
511
512bool
513GNEPOI::isValid(SumoXMLAttr key, const std::string& value) {
514 switch (key) {
515 case SUMO_ATTR_ID:
517 case SUMO_ATTR_COLOR:
518 return canParse<RGBColor>(value);
519 case SUMO_ATTR_LANE:
520 return (myNet->getAttributeCarriers()->retrieveLane(value, false) != nullptr);
522 if (getParentLanes().size() > 0) {
523 return canParse<double>(value);
524 } else {
525 return canParse<Position>(value);
526 }
528 return canParse<bool>(value);
530 return canParse<double>(value);
531 case SUMO_ATTR_LON:
532 return canParse<double>(value);
533 case SUMO_ATTR_LAT:
534 return canParse<double>(value);
535 case SUMO_ATTR_TYPE:
536 return true;
537 case SUMO_ATTR_ICON:
539 case SUMO_ATTR_LAYER:
540 if (value == "default") {
541 return true;
542 } else {
543 return canParse<double>(value);
544 }
546 if (value == "") {
547 return true;
548 } else {
549 // check that image can be loaded
550 return GUITexturesHelper::getTextureID(value) != -1;
551 }
553 return canParse<bool>(value);
554 case SUMO_ATTR_WIDTH:
555 return canParse<double>(value) && (parse<double>(value) > 0);
556 case SUMO_ATTR_HEIGHT:
557 return canParse<double>(value) && (parse<double>(value) > 0);
558 case SUMO_ATTR_ANGLE:
559 return canParse<double>(value);
560 case SUMO_ATTR_NAME:
563 return canParse<bool>(value);
565 return areParametersValid(value);
566 default:
567 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
568 }
569}
570
571
572bool
574 // check if we're in supermode Network
576 return true;
577 } else {
578 return false;
579 }
580}
581
582
583std::string
585 return getTagStr() + ": " + getID();
586}
587
588
589std::string
591 return getTagStr();
592}
593
594// ===========================================================================
595// private
596// ===========================================================================
597
598void
600 const bool movingGeometryPoints) const {
601 if (GUIPointOfInterest::checkDraw(s, this)) {
602 // draw inner polygon
603 if (myNet->getViewNet()->getFrontAttributeCarrier() == this) {
606 } else {
609 }
610 // draw geometry points
611 if (movingGeometryPoints) {
612 if (myShapeHeight.size() > 0) {
615 }
616 if (myShapeWidth.size() > 0) {
619 }
620 }
621 }
622}
623
624
625void
627 const double exaggeration, const bool movingGeometryPoints) const {
628 // check if we're calculating the contour or the moving geometry points
629 if (movingGeometryPoints) {
634 } else if (getShapeImgFile().empty()) {
635 const double radius = getWidth() > getHeight() ? getWidth() : getHeight();
636 myAdditionalContour.calculateContourCircleShape(s, d, this, *this, radius * 0.5, getShapeLayer(), exaggeration);
637 } else {
638 myAdditionalContour.calculateContourRectangleShape(s, d, this, *this, getHeight() * 0.5, getWidth() * 0.5, getShapeLayer(), 0, 0, getShapeNaviDegree(), exaggeration);
639 }
640}
641
642
643void
644GNEPOI::setAttribute(SumoXMLAttr key, const std::string& value) {
645 switch (key) {
646 case SUMO_ATTR_ID: {
647 // update microsimID
648 setAdditionalID(value);
649 // set named ID
650 myID = value;
651 break;
652 }
653 case SUMO_ATTR_COLOR:
654 setShapeColor(parse<RGBColor>(value));
655 break;
656 case SUMO_ATTR_LANE:
657 myLane = value;
659 break;
660 case SUMO_ATTR_POSITION: {
661 if (getParentLanes().size() > 0) {
662 if (canParse<double>(value)) {
663 myPosOverLane = parse<double>(value);
664 }
665 } else {
666 // set position
667 set(parse<Position>(value));
668 }
669 // update centering boundary
671 // update geometry
673 break;
674 }
676 setFriendlyPos(parse<bool>(value));
677 break;
679 myPosLat = parse<double>(value);
680 // update centering boundary
682 // update geometry
684 break;
685 case SUMO_ATTR_LON: {
686 // calculate cartesian
687 Position cartesian(parse<double>(value), parse<double>(getAttribute(SUMO_ATTR_LAT)));
689 // set cartesian
690 set(cartesian);
691 // update centering boundary
693 // update geometry
695 break;
696 }
697 case SUMO_ATTR_LAT: {
698 // calculate cartesian
699 Position cartesian(parse<double>(getAttribute(SUMO_ATTR_LON)), parse<double>(value));
701 // set cartesian
702 set(cartesian);
703 // update centering boundary
705 // update geometry
707 break;
708 }
709 case SUMO_ATTR_TYPE:
710 setShapeType(value);
711 break;
712 case SUMO_ATTR_ICON:
713 setIcon(value);
714 break;
715 case SUMO_ATTR_LAYER:
716 if (value == "default") {
718 } else {
719 setShapeLayer(parse<double>(value));
720 }
721 break;
723 // first remove object from grid due img file affect to boundary
724 if (getID().size() > 0) {
726 }
727 setShapeImgFile(value);
728 // all textures must be refresh
730 // add object into grid again
731 if (getID().size() > 0) {
733 }
734 break;
736 setShapeRelativePath(parse<bool>(value));
737 break;
738 case SUMO_ATTR_WIDTH:
739 // set new width
740 setWidth(parse<double>(value));
741 // update centering boundary and geometry (except for templates)
742 if (getID().size() > 0) {
745 }
746 break;
747 case SUMO_ATTR_HEIGHT:
748 // set new height
749 setHeight(parse<double>(value));
750 // update centering boundary and geometry (except for templates)
751 if (getID().size() > 0) {
754 }
755 break;
756 case SUMO_ATTR_ANGLE:
757 setShapeNaviDegree(parse<double>(value));
758 break;
759 case SUMO_ATTR_NAME:
760 setShapeName(value);
761 break;
763 if (parse<bool>(value)) {
765 } else {
767 }
768 break;
771 break;
774 break;
775 default:
776 throw InvalidArgument(getTagStr() + " attribute '" + toString(key) + "' not allowed");
777 }
778}
779
780
781void
783 // check what are being updated
785 myShapeHeight = moveResult.shapeToUpdate;
786 } else if (moveResult.operationType == GNEMoveOperation::OperationType::WIDTH) {
787 myShapeWidth = moveResult.shapeToUpdate;
788 } else {
789 if (getTagProperty().getTag() == GNE_TAG_POILANE) {
790 myPosOverLane = moveResult.newFirstPos;
791 } else {
792 set(moveResult.shapeToUpdate.front());
793 }
794 // update geometry
796 }
797}
798
799
800void
801GNEPOI::commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) {
802 // check what are being updated
804 undoList->begin(this, "height of " + getTagStr());
806 undoList->end();
807 } else if (moveResult.operationType == GNEMoveOperation::OperationType::WIDTH) {
808 undoList->begin(this, "width of " + getTagStr());
810 undoList->end();
811 } else {
812 undoList->begin(this, "position of " + getTagStr());
813 if (getTagProperty().getTag() == GNE_TAG_POILANE) {
815 } else {
817 }
818 undoList->end();
819 }
820}
821
822/****************************************************************************/
@ NETWORK_MOVE
mode for moving network elements
@ MID_GNE_POI_TRANSFORM
Transform POI to POILane, and viceversa.
unsigned int GUIGlID
Definition GUIGlObject.h:43
@ GLO_FRONTELEMENT
front element (used in netedit)
@ GLO_POI
poi (over view, geo and lane)
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
#define TL(string)
Definition MsgHandler.h:315
POIIcon
POI icons.
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_POI
begin/end of the description of a Point of interest
@ GNE_TAG_POIGEO
Point of interest over view with GEO attributes.
@ GNE_TAG_POILANE
Point of interest over Lane.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_ICON
icon
@ SUMO_ATTR_LANE
@ SUMO_ATTR_LON
@ GNE_ATTR_SELECTED
element is selected
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
@ SUMO_ATTR_POSITION_LAT
@ SUMO_ATTR_NAME
@ SUMO_ATTR_LAYER
A layer number.
@ SUMO_ATTR_ANGLE
@ SUMO_ATTR_HEIGHT
@ SUMO_ATTR_FRIENDLY_POS
@ SUMO_ATTR_LAT
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_ID
@ SUMO_ATTR_IMGFILE
@ SUMO_ATTR_WIDTH
@ SUMO_ATTR_POSITION
@ GNE_ATTR_SHIFTLANEINDEX
shift lane index (only used by elements over lanes)
@ SUMO_ATTR_RELATIVEPATH
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition Boundary.cpp:78
void reset()
Resets the boundary.
Definition Boundary.cpp:66
Boundary & grow(double by)
extends the boundary by the given amount
Definition Boundary.cpp:343
void setTag(const SumoXMLTag tag)
set SumoBaseObject tag
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 drawBoundary(const GUIVisualizationSettings &s, const Boundary &b)
Draw a boundary (used for debugging)
Definition GLHelper.cpp:966
static bool checkLanePosition(double pos, const double length, const double laneLength, const bool friendlyPos)
check if the given position over a lane is valid
static void fixLanePosition(double &pos, double &length, const double laneLength)
fix given position over lane
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 drawRightGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw right geometry point
void setAdditionalID(const std::string &newID)
set additional ID
GNEContour myAdditionalContour
variable used for draw additional contours
void drawUpGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw up geometry point
void replaceAdditionalParentLanes(const std::string &value)
replace additional parent lanes
void shiftLaneIndex()
shift lane index
bool drawMovingGeometryPoints(const bool ignoreShift) const
check if draw additional extrem geometry points
void drawDownGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw down geometry point
Boundary myAdditionalBoundary
Additional Boundary (used only by additionals placed over grid)
void drawLeftGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw left geometry point
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.
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 calculateContourCircleShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const Position &pos, double radius, const double layer, const double scale) const
calculate contour (circle elements)
void calculateContourRectangleShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const Position &pos, const double width, const double height, const double layer, const double offsetX, const double offsetY, const double rot, const double scale) const
calculate contour (for rectangled elements)
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...)
const std::vector< GNELane * > & getParentLanes() const
get parent lanes
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition GNELane.h:46
bool getAllowChangeLane() const
allow change lane
CommonModeOptions * getCommonModeOptions() const
get common mode options
move operation
move result
double newFirstPos
new first position
const GNEMoveOperation::OperationType operationType
move operation
PositionVector shapeToUpdate
shape to update (edited in moveElement)
GNELane * retrieveLane(const std::string &id, bool hardFail=true, bool checkVolatileChange=false) const
get lane by id
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
void addGLObjectIntoGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1386
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1396
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:127
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2155
bool isValid(SumoXMLAttr key, const std::string &value) override
method for checking if the key and their correspond attribute are valids
Definition GNEPOI.cpp:513
Position getPositionInView() const override
Returns position of shape in view.
Definition GNEPOI.cpp:261
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
Definition GNEPOI.cpp:584
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GNEPOI.cpp:357
const Parameterised::Map & getACParametersMap() const override
get parameters map
Definition GNEPOI.cpp:476
GNEContour myMovingContourRight
variable used for moving contour right
Definition GNEPOI.h:247
PositionVector myShapeWidth
shape width of POI
Definition GNEPOI.h:232
void drawPOI(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const bool movingGeometryPoints) const
draw POI
Definition GNEPOI.cpp:599
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList) override
commit move shape
Definition GNEPOI.cpp:801
void calculatePOIContour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double exaggeration, const bool movingGeometryPoints) const
calculate contour
Definition GNEPOI.cpp:626
void updateCenteringBoundary(const bool updateGrid) override
update centering boundary (implies change in RTREE)
Definition GNEPOI.cpp:273
GNEContour myMovingContourLeft
variable used for moving contour left
Definition GNEPOI.h:244
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
Definition GNEPOI.cpp:590
std::string getParentName() const override
Returns the name of the parent object.
Definition GNEPOI.cpp:320
void fixAdditionalProblem() override
fix additional problem (must be reimplemented in all detector children)
Definition GNEPOI.cpp:218
std::string getAttribute(SumoXMLAttr key) const override
method for getting the Attribute of an XML key
Definition GNEPOI.cpp:403
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
Definition GNEPOI.cpp:267
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition GNEPOI.cpp:298
std::string getAdditionalProblem() const override
return a string with the current additional problem (must be reimplemented in all detector children)
Definition GNEPOI.cpp:191
~GNEPOI()
Destructor.
Definition GNEPOI.cpp:89
GNEMoveOperation * getMoveOperation() override
get move operation
Definition GNEPOI.cpp:93
bool isAttributeEnabled(SumoXMLAttr key) const override
Definition GNEPOI.cpp:573
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList) override
remove geometry point in the clicked position
Definition GNEPOI.cpp:132
double getAttributeDouble(SumoXMLAttr key) const override
Definition GNEPOI.cpp:470
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition GNEPOI.cpp:138
GNEContour myMovingContourDown
variable used for moving contour down
Definition GNEPOI.h:241
void writeAdditional(OutputDevice &device) const override
write additional element into a xml file
Definition GNEPOI.cpp:164
void updateGeometry() override
update pre-computed geometry information
Definition GNEPOI.cpp:234
bool checkDrawMoveContour() const override
check if draw move contour (red)
Definition GNEPOI.cpp:304
PositionVector myShapeHeight
shape height of POI
Definition GNEPOI.h:235
void setMoveShape(const GNEMoveResult &moveResult) override
set move shape
Definition GNEPOI.cpp:782
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList) override
split geometry
Definition GNEPOI.cpp:292
bool isAdditionalValid() const override
check if current additional is valid to be written into XML (must be reimplemented in all detector ch...
Definition GNEPOI.cpp:177
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
method for setting the attribute and letting the object perform additional changes
Definition GNEPOI.cpp:482
GNEPOI(SumoXMLTag tag, GNENet *net)
Constructor.
Definition GNEPOI.cpp:48
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GNEPOI.cpp:330
GNEContour myMovingContourUp
variable used for moving contour up
Definition GNEPOI.h:238
CommonXMLStructure::SumoBaseObject * getSumoBaseObject() const
get SUMOBaseObject with all POIattributes
Definition GNEPOI.cpp:144
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 GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
const GNEViewNetHelper::EditNetworkElementShapes & getEditNetworkElementShapes() const
get Edit Shape module
const GNEViewNetHelper::MouseButtonKeyPressed & getMouseButtonKeyPressed() const
get Key Pressed module
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.
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.
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
static bool checkDraw(const GUIVisualizationSettings &s, const GUIGlObject *o)
check if POI can be drawn
static void drawInnerPOI(const GUIVisualizationSettings &s, const PointOfInterest *POI, const GUIGlObject *o, const bool disableSelectionColor, const double layer, const double width, const double height)
draw inner POI (before pushName() )
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 poiUseCustomLayer
whether the rendering layer of POIs should be overriden
GUIVisualizationSizeSettings poiSize
bool checkDrawPOI(const double w, const double h, const Detail d, const bool selected) const
check if draw POI
Detail getDetailLevel(const double exaggeration) const
return the detail level
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
double poiCustomLayer
the custom layer for POIs
GUIVisualizationNeteditSizeSettings neteditSizeSettings
netedit size settings
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 > POIs
POIs namespace.
Static storage of an output device and its base (abstract) implementation.
C++ TraCI client API implementation.
An upper class for objects with additional parameters.
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-of-interest.
bool myGeo
flag to check if POI was loaded as GEO Position (main used by netedit)
bool getFriendlyPos() const
returns friendly position
void setHeight(double height)
set the image height of the POI
void setFriendlyPos(const bool friendlyPos)
set friendly position
double myPosLat
lateral position over lane in which this POI is placed (main used by netedit)
void setWidth(double width)
set the image width of the POI
double getHeight() const
Returns the image height of the POI.
bool myFriendlyPos
friendlyPos enable or disable friendly position for position over lane
std::string myLane
ID of lane in which this POI is placed (main used by netedit)
void setIcon(const std::string &icon)
set icon
double myPosOverLane
position over lane in which this POI is placed (main used by netedit)
double getWidth() const
Returns the image width of the POI.
const std::string & getIconStr() const
get icon(in string format)
void writeXML(OutputDevice &out, const bool geo=false, const double zOffset=0., const std::string laneID="", const double pos=0., const bool friendlyPos=false, const double posLat=0.) const
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
double length() const
Computes the length of the given vector.
Definition Position.h:172
Position()
default constructor
Definition Position.h:40
void set(double x, double y)
set positions x and y
Definition Position.h:85
double x() const
Returns the x-position.
Definition Position.h:55
double y() const
Returns the y-position.
Definition Position.h:60
A list of positions.
double length2D() const
Returns the length.
void add(double xoff, double yoff, double zoff)
void move2side(double amount, double maxExtension=100)
move position vector to side using certain amount
Position getCentroid() const
Returns the centroid (closes the polygon if unclosed)
static const RGBColor ORANGE
Definition RGBColor.h:191
class for maintaining associations between enums and xml-strings
static StringBijection< POIIcon > POIIcons
POI icon values.
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_POI
Definition Shape.h:45
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
bool hasString(const std::string &str) const
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 shiftKeyPressed() const
check if SHIFT is pressed during current event
static const double segmentWidthSmall
width of small dotted contour segments
static const double segmentWidth
width of dotted contour segments
static const double additionalGeometryPointRadius
moving additional geometry point radius
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values