Eclipse SUMO - Simulation of Urban MObility
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>
27 #include <netedit/GNEViewParent.h>
30 #include <utils/gui/div/GLHelper.h>
38 #include <utils/xml/NamespaceIDs.h>
39 
40 #include "GNEPOI.h"
41 #include "GNEAdditionalHandler.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 
56 GNEPOI::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),
61  GNEAdditional(id, net, GLO_POI, geo ? GNE_TAG_POIGEO : SUMO_TAG_POI, geo ? GUIIconSubSys::getIcon(GUIIcon::POIGEO) : GUIIconSubSys::getIcon(GUIIcon::POI),
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 
76 GNEPOI::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  // get mouse position
100  const Position mousePosition = myNet->getViewNet()->getPositionInformation();
101  // check if we're editing width or height
102  if ((myShapeWidth.size() == 0) || (myShapeHeight.size() == 0)) {
103  return nullptr;
104  } else if (myShapeHeight.front().distanceSquaredTo2D(mousePosition) <= (snap_radius * snap_radius)) {
105  // edit height
107  } else if (myShapeHeight.back().distanceSquaredTo2D(mousePosition) <= (snap_radius * snap_radius)) {
108  // edit height
110  } else if (myShapeWidth.front().distanceSquaredTo2D(mousePosition) <= (snap_radius * snap_radius)) {
111  // edit width
113  } else if (myShapeWidth.back().distanceSquaredTo2D(mousePosition) <= (snap_radius * snap_radius)) {
114  // edit width
116  } else {
117  return nullptr;
118  }
119  } else if (getTagProperty().getTag() == GNE_TAG_POILANE) {
120  // return move operation for POI placed over lane
121  return new GNEMoveOperation(this, getParentLanes().front(), myPosOverLane,
123  } else {
124  // return move operation for a position in view
125  return new GNEMoveOperation(this, *this);
126  }
127 }
128 
129 
130 void
131 GNEPOI::removeGeometryPoint(const Position /*clickedPosition*/, GNEUndoList* /*undoList*/) {
132  // nothing to remove
133 }
134 
135 
136 std::string
138  return "";
139 }
140 
141 
145  POIBaseObject->setTag(SUMO_TAG_POI);
146  // fill attributes
147  POIBaseObject->addStringAttribute(SUMO_ATTR_ID, myID);
150  POIBaseObject->addStringAttribute(SUMO_ATTR_ICON, getIconStr());
153  POIBaseObject->addDoubleAttribute(SUMO_ATTR_WIDTH, getWidth());
154  POIBaseObject->addDoubleAttribute(SUMO_ATTR_HEIGHT, getHeight());
158  return POIBaseObject;
159 }
160 
161 
162 void
164  if (getParentLanes().size() > 0) {
165  // obtain fixed position over lane
166  double fixedPositionOverLane = myPosOverLane > getParentLanes().at(0)->getLaneShape().length() ? getParentLanes().at(0)->getLaneShape().length() : myPosOverLane < 0 ? 0 : myPosOverLane;
167  // write POILane using POI::writeXML
168  writeXML(device, false, 0, getParentLanes().at(0)->getID(), fixedPositionOverLane, myFriendlyPos, myPosLat);
169  } else {
170  writeXML(device, myGeo);
171  }
172 }
173 
174 
175 bool
177  // only for POIS over lanes
178  if (getParentLanes().size() == 0) {
179  return true;
180  } else if (getFriendlyPos()) {
181  // with friendly position enabled position is "always fixed"
182  return true;
183  } else {
184  return fabs(myPosOverLane) <= getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength();
185  }
186 }
187 
188 
189 std::string
191  // only for POIS over lanes
192  if (getParentLanes().size() > 0) {
193  // obtain final length
194  const double len = getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength();
195  // check if detector has a problem
197  return "";
198  } else {
199  // declare variable for error position
200  std::string errorPosition;
201  // check positions over lane
202  if (myPosOverLane < 0) {
203  errorPosition = (toString(SUMO_ATTR_POSITION) + " < 0");
204  }
205  if (myPosOverLane > len) {
206  errorPosition = (toString(SUMO_ATTR_POSITION) + TL(" > lanes's length"));
207  }
208  return errorPosition;
209  }
210  } else {
211  return "";
212  }
213 }
214 
215 
216 void
218  // only for POIS over lanes
219  if (getParentLanes().size() > 0) {
220  // declare new position
221  double newPositionOverLane = myPosOverLane;
222  // declare new length (but unsed in this context)
223  double length = 0;
224  // fix pos and length with fixLanePosition
225  GNEAdditionalHandler::fixLanePosition(newPositionOverLane, length, getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength());
226  // set new position
227  setAttribute(SUMO_ATTR_POSITION, toString(newPositionOverLane), myNet->getViewNet()->getUndoList());
228  }
229 }
230 
231 
232 void
234  // set position
235  if (getParentLanes().size() > 0) {
236  // obtain fixed position over lane
237  double fixedPositionOverLane = myPosOverLane > getParentLanes().at(0)->getLaneShapeLength() ? getParentLanes().at(0)->getLaneShapeLength() : myPosOverLane < 0 ? 0 : myPosOverLane;
238  // set new position regarding to lane
239  set(getParentLanes().at(0)->getLaneShape().positionAtOffset(fixedPositionOverLane * getParentLanes().at(0)->getLengthGeometryFactor(), -myPosLat));
240  }
241  // check if update width and height shapes
242  if ((getWidth() > 0) && (getHeight() > 0)) {
243  // calculate shape length
244  myShapeHeight.clear();
245  myShapeHeight.push_back(Position(0, getHeight() * -0.5));
246  myShapeHeight.push_back(Position(0, getHeight() * 0.5));
247  // move
248  myShapeHeight.add(*this);
249  // calculate shape width
250  PositionVector leftShape = myShapeHeight;
251  leftShape.move2side(getWidth() * -0.5);
252  PositionVector rightShape = myShapeHeight;
253  rightShape.move2side(getWidth() * 0.5);
254  myShapeWidth = {leftShape.getCentroid(), rightShape.getCentroid()};
255  }
256 }
257 
258 
259 Position
261  return *this;
262 }
263 
264 
265 double
267  return s.poiSize.getExaggeration(s, this);
268 }
269 
270 
271 void
272 GNEPOI::updateCenteringBoundary(const bool updateGrid) {
273  // Remove object from net
274  if (updateGrid) {
276  }
277  // reset boundary
279  // add position (this POI)
280  myAdditionalBoundary.add(*this);
281  // grow boundary
282  myAdditionalBoundary.grow(5 + std::max(getWidth() * 0.5, getHeight() * 0.5));
283  // add object into net
284  if (updateGrid) {
285  myNet->addGLObjectIntoGrid(this);
286  }
287 }
288 
289 
290 void
291 GNEPOI::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
292  // nothing to split
293 }
294 
295 
296 GUIGlID
298  return GUIGlObject::getGlID();
299 }
300 
301 
302 bool
304  // get edit modes
305  const auto& editModes = myNet->getViewNet()->getEditModes();
306  // check if we're in move mode
307  if (!myNet->getViewNet()->isMovingElement() && editModes.isCurrentSupermodeNetwork() &&
308  (editModes.networkEditMode == NetworkEditMode::NETWORK_MOVE) && myNet->getViewNet()->checkOverLockedElement(this, mySelected)) {
309  // only move the first element
311  } else {
312  return false;
313  }
314 }
315 
316 
317 std::string
319  if (getParentLanes().size() > 0) {
320  return getParentLanes().front()->getID();
321  } else {
322  return myNet->getMicrosimID();
323  }
324 }
325 
326 
329  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
330  buildPopupHeader(ret, app);
333  // build selection and show parameters menu
336  buildPositionCopyEntry(ret, app);
337  new FXMenuSeparator(ret);
338  // specific of non juPedSim polygons
340  // continue depending of lane number
341  if (getParentLanes().size() > 0) {
342  // add option for convert to GNEPOI
344  return ret;
345  } else {
346  // add option for convert to GNEPOI
348  }
349  }
350  return ret;
351 }
352 
353 
354 void
356  // draw boundaries
358  // first check if POI can be drawn
360  // obtain POIExaggeration
361  const double POIExaggeration = getExaggeration(s);
362  // get detail level
363  const auto d = s.getDetailLevel(POIExaggeration);
364  // draw geometry only if we'rent in drawForObjectUnderCursor mode
365  if (!s.drawForViewObjectsHandler) {
366  // draw POI
367  drawPOI(s, d);
368  // draw lock icon
370  // draw dotted contour
372  }
373  // calculate contour
374  calculatePOIContour(s, d, POIExaggeration);
375  }
376 }
377 
378 
379 std::string
381  switch (key) {
382  case SUMO_ATTR_ID:
383  return myID;
384  case SUMO_ATTR_COLOR:
385  return toString(getShapeColor());
386  case SUMO_ATTR_LANE:
387  return myLane;
388  case SUMO_ATTR_POSITION:
389  if (getParentLanes().size() > 0) {
390  return toString(myPosOverLane);
391  } else {
392  return toString(*this);
393  }
395  return toString(getFriendlyPos());
397  return toString(myPosLat);
398  case SUMO_ATTR_LON: {
399  // calculate geo position
400  Position GEOPosition(x(), y());
401  GeoConvHelper::getFinal().cartesian2geo(GEOPosition);
402  // return lon
403  return toString(GEOPosition.x(), 8);
404  }
405  case SUMO_ATTR_LAT: {
406  // calculate geo position
407  Position GEOPosition(x(), y());
408  GeoConvHelper::getFinal().cartesian2geo(GEOPosition);
409  // return lat
410  return toString(GEOPosition.y(), 8);
411  }
412  case SUMO_ATTR_TYPE:
413  return getShapeType();
414  case SUMO_ATTR_ICON:
415  return getIconStr();
416  case SUMO_ATTR_LAYER:
418  return "default";
419  } else {
420  return toString(getShapeLayer());
421  }
422  case SUMO_ATTR_IMGFILE:
423  return getShapeImgFile();
425  return toString(getShapeRelativePath());
426  case SUMO_ATTR_WIDTH:
427  return toString(getWidth());
428  case SUMO_ATTR_HEIGHT:
429  return toString(getHeight());
430  case SUMO_ATTR_ANGLE:
431  return toString(getShapeNaviDegree());
432  case SUMO_ATTR_NAME:
433  return getShapeName();
434  case GNE_ATTR_SELECTED:
436  case GNE_ATTR_PARAMETERS:
439  return "";
440  default:
441  throw InvalidArgument(getTagStr() + " attribute '" + toString(key) + "' not allowed");
442  }
443 }
444 
445 
446 double
448  throw InvalidArgument(getTagStr() + " attribute '" + toString(key) + "' not allowed");
449 }
450 
451 
452 const Parameterised::Map&
455 }
456 
457 
458 void
459 GNEPOI::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
460  switch (key) {
461  case SUMO_ATTR_ID:
462  case SUMO_ATTR_COLOR:
463  case SUMO_ATTR_LANE:
464  case SUMO_ATTR_POSITION:
467  case SUMO_ATTR_LON:
468  case SUMO_ATTR_LAT:
469  case SUMO_ATTR_TYPE:
470  case SUMO_ATTR_ICON:
471  case SUMO_ATTR_LAYER:
472  case SUMO_ATTR_IMGFILE:
474  case SUMO_ATTR_WIDTH:
475  case SUMO_ATTR_HEIGHT:
476  case SUMO_ATTR_ANGLE:
477  case SUMO_ATTR_NAME:
478  case GNE_ATTR_SELECTED:
479  case GNE_ATTR_PARAMETERS:
481  GNEChange_Attribute::changeAttribute(this, key, value, undoList);
482  break;
483  default:
484  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
485  }
486 }
487 
488 
489 bool
490 GNEPOI::isValid(SumoXMLAttr key, const std::string& value) {
491  switch (key) {
492  case SUMO_ATTR_ID:
494  case SUMO_ATTR_COLOR:
495  return canParse<RGBColor>(value);
496  case SUMO_ATTR_LANE:
497  return (myNet->getAttributeCarriers()->retrieveLane(value, false) != nullptr);
498  case SUMO_ATTR_POSITION:
499  if (getParentLanes().size() > 0) {
500  return canParse<double>(value);
501  } else {
502  return canParse<Position>(value);
503  }
505  return canParse<bool>(value);
507  return canParse<double>(value);
508  case SUMO_ATTR_LON:
509  return canParse<double>(value);
510  case SUMO_ATTR_LAT:
511  return canParse<double>(value);
512  case SUMO_ATTR_TYPE:
513  return true;
514  case SUMO_ATTR_ICON:
516  case SUMO_ATTR_LAYER:
517  if (value == "default") {
518  return true;
519  } else {
520  return canParse<double>(value);
521  }
522  case SUMO_ATTR_IMGFILE:
523  if (value == "") {
524  return true;
525  } else {
526  // check that image can be loaded
527  return GUITexturesHelper::getTextureID(value) != -1;
528  }
530  return canParse<bool>(value);
531  case SUMO_ATTR_WIDTH:
532  return canParse<double>(value) && (parse<double>(value) > 0);
533  case SUMO_ATTR_HEIGHT:
534  return canParse<double>(value) && (parse<double>(value) > 0);
535  case SUMO_ATTR_ANGLE:
536  return canParse<double>(value);
537  case SUMO_ATTR_NAME:
539  case GNE_ATTR_SELECTED:
540  return canParse<bool>(value);
541  case GNE_ATTR_PARAMETERS:
542  return areParametersValid(value);
543  default:
544  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
545  }
546 }
547 
548 
549 bool
551  // check if we're in supermode Network
553  return true;
554  } else {
555  return false;
556  }
557 }
558 
559 
560 std::string
562  return getTagStr() + ": " + getID();
563 }
564 
565 
566 std::string
568  return getTagStr();
569 }
570 
571 // ===========================================================================
572 // private
573 // ===========================================================================
574 
575 void
577  if (GUIPointOfInterest::checkDraw(s, this)) {
578  // draw inner polygon
579  if (myNet->getViewNet()->getFrontAttributeCarrier() == this) {
582  } else {
585  }
586  // draw an orange square mode if there is an image(see #4036)
587  if (!getShapeImgFile().empty() && OptionsCont::getOptions().getBool("gui-testing")) {
588  // Add a draw matrix for drawing logo
590  glTranslated(x(), y(), getType() + 0.01);
592  GLHelper::drawBoxLine(Position(0, 1), 0, 2, 1);
594  }
595  // draw geometry points
596  if (myShapeHeight.size() > 0) {
599  }
600  if (myShapeWidth.size() > 0) {
603  }
604  }
605 }
606 
607 
608 void
610  const double exaggeration) const {
611  // draw contour depending of shape img file
612  if (getShapeImgFile().empty()) {
613  myAdditionalContour.calculateContourCircleShape(s, d, this, *this, 1.3, exaggeration);
614  } else {
615  myAdditionalContour.calculateContourRectangleShape(s, d, this, *this, getHeight() * 0.5, getWidth() * 0.5, 0, 0, getShapeNaviDegree(), exaggeration);
616  }
617 }
618 
619 
620 void
621 GNEPOI::setAttribute(SumoXMLAttr key, const std::string& value) {
622  switch (key) {
623  case SUMO_ATTR_ID: {
624  // update microsimID
625  setAdditionalID(value);
626  // set named ID
627  myID = value;
628  break;
629  }
630  case SUMO_ATTR_COLOR:
631  setShapeColor(parse<RGBColor>(value));
632  break;
633  case SUMO_ATTR_LANE:
634  myLane = value;
636  break;
637  case SUMO_ATTR_POSITION: {
638  if (getParentLanes().size() > 0) {
639  if (canParse<double>(value)) {
640  myPosOverLane = parse<double>(value);
641  }
642  } else {
643  // set position
644  set(parse<Position>(value));
645  }
646  // update centering boundary
648  // update geometry
649  updateGeometry();
650  break;
651  }
653  setFriendlyPos(parse<bool>(value));
654  break;
656  myPosLat = parse<double>(value);
657  // update centering boundary
659  // update geometry
660  updateGeometry();
661  break;
662  case SUMO_ATTR_LON: {
663  // calculate cartesian
664  Position cartesian(parse<double>(value), parse<double>(getAttribute(SUMO_ATTR_LAT)));
666  // set cartesian
667  set(cartesian);
668  // update centering boundary
670  // update geometry
671  updateGeometry();
672  break;
673  }
674  case SUMO_ATTR_LAT: {
675  // calculate cartesian
676  Position cartesian(parse<double>(getAttribute(SUMO_ATTR_LON)), parse<double>(value));
678  // set cartesian
679  set(cartesian);
680  // update centering boundary
682  // update geometry
683  updateGeometry();
684  break;
685  }
686  case SUMO_ATTR_TYPE:
687  setShapeType(value);
688  break;
689  case SUMO_ATTR_ICON:
690  setIcon(value);
691  break;
692  case SUMO_ATTR_LAYER:
693  if (value == "default") {
695  } else {
696  setShapeLayer(parse<double>(value));
697  }
698  break;
699  case SUMO_ATTR_IMGFILE:
700  // first remove object from grid due img file affect to boundary
701  if (getID().size() > 0) {
703  }
704  setShapeImgFile(value);
705  // all textures must be refresh
707  // add object into grid again
708  if (getID().size() > 0) {
709  myNet->addGLObjectIntoGrid(this);
710  }
711  break;
713  setShapeRelativePath(parse<bool>(value));
714  break;
715  case SUMO_ATTR_WIDTH:
716  // set new width
717  setWidth(parse<double>(value));
718  // update centering boundary and geometry (except for templates)
719  if (getID().size() > 0) {
721  updateGeometry();
722  }
723  break;
724  case SUMO_ATTR_HEIGHT:
725  // set new height
726  setHeight(parse<double>(value));
727  // update centering boundary and geometry (except for templates)
728  if (getID().size() > 0) {
730  updateGeometry();
731  }
732  break;
733  case SUMO_ATTR_ANGLE:
734  setShapeNaviDegree(parse<double>(value));
735  break;
736  case SUMO_ATTR_NAME:
737  setShapeName(value);
738  break;
739  case GNE_ATTR_SELECTED:
740  if (parse<bool>(value)) {
742  } else {
744  }
745  break;
746  case GNE_ATTR_PARAMETERS:
748  break;
750  shiftLaneIndex();
751  break;
752  default:
753  throw InvalidArgument(getTagStr() + " attribute '" + toString(key) + "' not allowed");
754  }
755 }
756 
757 
758 void
760  // check what are being updated
762  myShapeHeight = moveResult.shapeToUpdate;
763  } else if (moveResult.operationType == GNEMoveOperation::OperationType::WIDTH) {
764  myShapeWidth = moveResult.shapeToUpdate;
765  } else {
766  if (getTagProperty().getTag() == GNE_TAG_POILANE) {
767  myPosOverLane = moveResult.newFirstPos;
768  } else {
769  set(moveResult.shapeToUpdate.front());
770  }
771  // update geometry
772  updateGeometry();
773  }
774 }
775 
776 
777 void
778 GNEPOI::commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) {
779  // check what are being updated
781  undoList->begin(this, "height of " + getTagStr());
782  setAttribute(SUMO_ATTR_HEIGHT, toString(moveResult.shapeToUpdate.length2D()), undoList);
783  undoList->end();
784  } else if (moveResult.operationType == GNEMoveOperation::OperationType::WIDTH) {
785  undoList->begin(this, "width of " + getTagStr());
786  setAttribute(SUMO_ATTR_WIDTH, toString(moveResult.shapeToUpdate.length2D()), undoList);
787  undoList->end();
788  } else {
789  undoList->begin(this, "position of " + getTagStr());
790  if (getTagProperty().getTag() == GNE_TAG_POILANE) {
792  } else {
794  }
795  undoList->end();
796  }
797 }
798 
799 /****************************************************************************/
@ NETWORK_MOVE
mode for moving network elements
@ MID_GNE_POI_TRANSFORM
Transform POI to POILane, and viceversa.
Definition: GUIAppEnum.h:1310
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:319
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 setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:654
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:130
static void drawBoundary(const GUIVisualizationSettings &s, const Boundary &b)
Draw a boundary (used for debugging)
Definition: GLHelper.cpp:967
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition: GLHelper.cpp:295
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:117
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.
Definition: GNEAdditional.h:49
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
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 scale) const
calculate contour (circle elements)
Definition: GNEContour.cpp:117
void calculateContourRectangleShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const Position &pos, const double width, const double height, const double offsetX, const double offsetY, const double rot, const double scale) const
calculate contour (for rectangled elements)
Definition: GNEContour.cpp:103
void drawDottedContours(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const
drawing contour functions
Definition: GNEContour.cpp:265
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:1282
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition: GNENet.cpp:1291
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:122
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2055
bool isValid(SumoXMLAttr key, const std::string &value) override
method for checking if the key and their correspond attribute are valids
Definition: GNEPOI.cpp:490
Position getPositionInView() const override
Returns position of shape in view.
Definition: GNEPOI.cpp:260
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
Definition: GNEPOI.cpp:561
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition: GNEPOI.cpp:355
const Parameterised::Map & getACParametersMap() const override
get parameters map
Definition: GNEPOI.cpp:453
void drawPOI(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d) const
draw POI
Definition: GNEPOI.cpp:576
PositionVector myShapeWidth
shape width of POI
Definition: GNEPOI.h:232
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList) override
commit move shape
Definition: GNEPOI.cpp:778
void updateCenteringBoundary(const bool updateGrid) override
update centering boundary (implies change in RTREE)
Definition: GNEPOI.cpp:272
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNEPOI.cpp:567
std::string getParentName() const override
Returns the name of the parent object.
Definition: GNEPOI.cpp:318
void fixAdditionalProblem() override
fix additional problem (must be reimplemented in all detector children)
Definition: GNEPOI.cpp:217
std::string getAttribute(SumoXMLAttr key) const override
method for getting the Attribute of an XML key
Definition: GNEPOI.cpp:380
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
Definition: GNEPOI.cpp:266
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GNEPOI.cpp:297
std::string getAdditionalProblem() const override
return a string with the current additional problem (must be reimplemented in all detector children)
Definition: GNEPOI.cpp:190
~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:550
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList) override
remove geometry point in the clicked position
Definition: GNEPOI.cpp:131
double getAttributeDouble(SumoXMLAttr key) const override
Definition: GNEPOI.cpp:447
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition: GNEPOI.cpp:137
void writeAdditional(OutputDevice &device) const override
write additional element into a xml file
Definition: GNEPOI.cpp:163
void updateGeometry() override
update pre-computed geometry information
Definition: GNEPOI.cpp:233
bool checkDrawMoveContour() const override
check if draw move contour (red)
Definition: GNEPOI.cpp:303
PositionVector myShapeHeight
shape height of POI
Definition: GNEPOI.h:235
void setMoveShape(const GNEMoveResult &moveResult) override
set move shape
Definition: GNEPOI.cpp:759
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList) override
split geometry
Definition: GNEPOI.cpp:291
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:176
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:459
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:328
void calculatePOIContour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double exaggeration) const
calculate contour
Definition: GNEPOI.cpp:609
CommonXMLStructure::SumoBaseObject * getSumoBaseObject() const
get SUMOBaseObject with all POIattributes
Definition: GNEPOI.cpp:143
bool isJuPedSimElement() const
return true if tag correspond to a JuPedSim element
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
const GUIGlObject * getGUIGlObjectFront() const
get front attribute carrier or a pointer to nullptr
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
Definition: GNEViewNet.cpp:727
const GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:703
const GNEViewNetHelper::MouseButtonKeyPressed & getMouseButtonKeyPressed() const
get Key Pressed module
Definition: GNEViewNet.cpp:733
bool isMovingElement() const
check if an element is being moved
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
Definition: GNEViewNet.cpp:468
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
Definition: GNEViewNet.cpp:538
const GNEViewNetHelper::DemandViewOptions & getDemandViewOptions() const
get demand view options
Definition: GNEViewNet.cpp:721
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
Definition: GUIDesigns.cpp:42
The popup menu of a globject.
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.
Definition: GUIGlObject.h:156
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.h:143
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.
Definition: GUIGlObject.h:104
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.
GUIVisualizationSizeSettings poiSize
Detail getDetailLevel(const double exaggeration) const
return the detail level
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
bool drawForViewObjectsHandler
whether drawing is performed for the purpose of selecting objects in view using ViewObjectsHandler
GUIVisualizationNeteditSizeSettings neteditSizeSettings
netedit size settings
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
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.
Definition: NamespaceIDs.h:50
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:60
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
C++ TraCI client API implementation.
Definition: POI.h:34
An upper class for objects with additional parameters.
Definition: Parameterised.h:41
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
Definition: Parameterised.h:45
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
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
const RGBColor & getShapeColor() const
Returns the color of the Shape.
Definition: Shape.h:84
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
const std::string & getShapeImgFile() const
Returns the imgFile of the Shape.
Definition: Shape.h:105
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
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
double getShapeNaviDegree() const
Returns the angle of the Shape in navigational degrees.
Definition: Shape.h:98
const std::string & getShapeType() const
Returns the (abstract) type of the Shape.
Definition: Shape.h:77
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
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 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