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  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 
131 void
132 GNEPOI::removeGeometryPoint(const Position /*clickedPosition*/, GNEUndoList* /*undoList*/) {
133  // nothing to remove
134 }
135 
136 
137 std::string
139  return "";
140 }
141 
142 
146  POIBaseObject->setTag(SUMO_TAG_POI);
147  // fill attributes
148  POIBaseObject->addStringAttribute(SUMO_ATTR_ID, myID);
151  POIBaseObject->addStringAttribute(SUMO_ATTR_ICON, getIconStr());
154  POIBaseObject->addDoubleAttribute(SUMO_ATTR_WIDTH, getWidth());
155  POIBaseObject->addDoubleAttribute(SUMO_ATTR_HEIGHT, getHeight());
159  return POIBaseObject;
160 }
161 
162 
163 void
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 
176 bool
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 
190 std::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 
217 void
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
228  setAttribute(SUMO_ATTR_POSITION, toString(newPositionOverLane), myNet->getViewNet()->getUndoList());
229  }
230 }
231 
232 
233 void
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 
260 Position
262  return *this;
263 }
264 
265 
266 double
268  return s.poiSize.getExaggeration(s, this);
269 }
270 
271 
272 void
273 GNEPOI::updateCenteringBoundary(const bool updateGrid) {
274  // Remove object from net
275  if (updateGrid) {
277  }
278  // reset boundary
280  // add position (this POI)
281  myAdditionalBoundary.add(*this);
282  // grow boundary
283  myAdditionalBoundary.grow(5 + std::max(getWidth() * 0.5, getHeight() * 0.5));
284  // add object into net
285  if (updateGrid) {
286  myNet->addGLObjectIntoGrid(this);
287  }
288 }
289 
290 
291 void
292 GNEPOI::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
293  // nothing to split
294 }
295 
296 
297 GUIGlID
299  return GUIGlObject::getGlID();
300 }
301 
302 
303 bool
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 
319 std::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 
356 void
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 
402 std::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;
411  case SUMO_ATTR_POSITION:
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());
424  GeoConvHelper::getFinal().cartesian2geo(GEOPosition);
425  // return lon
426  return toString(GEOPosition.x(), 8);
427  }
428  case SUMO_ATTR_LAT: {
429  // calculate geo position
430  Position GEOPosition(x(), y());
431  GeoConvHelper::getFinal().cartesian2geo(GEOPosition);
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  }
445  case SUMO_ATTR_IMGFILE:
446  return getShapeImgFile();
448  return toString(getShapeRelativePath());
449  case SUMO_ATTR_WIDTH:
450  return toString(getWidth());
451  case SUMO_ATTR_HEIGHT:
452  return toString(getHeight());
453  case SUMO_ATTR_ANGLE:
454  return toString(getShapeNaviDegree());
455  case SUMO_ATTR_NAME:
456  return getShapeName();
457  case GNE_ATTR_SELECTED:
459  case GNE_ATTR_PARAMETERS:
462  return "";
463  default:
464  throw InvalidArgument(getTagStr() + " attribute '" + toString(key) + "' not allowed");
465  }
466 }
467 
468 
469 double
471  throw InvalidArgument(getTagStr() + " attribute '" + toString(key) + "' not allowed");
472 }
473 
474 
475 const Parameterised::Map&
478 }
479 
480 
481 void
482 GNEPOI::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:
487  case SUMO_ATTR_POSITION:
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:
495  case SUMO_ATTR_IMGFILE:
497  case SUMO_ATTR_WIDTH:
498  case SUMO_ATTR_HEIGHT:
499  case SUMO_ATTR_ANGLE:
500  case SUMO_ATTR_NAME:
501  case GNE_ATTR_SELECTED:
502  case GNE_ATTR_PARAMETERS:
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 
512 bool
513 GNEPOI::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);
521  case SUMO_ATTR_POSITION:
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  }
545  case SUMO_ATTR_IMGFILE:
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:
562  case GNE_ATTR_SELECTED:
563  return canParse<bool>(value);
564  case GNE_ATTR_PARAMETERS:
565  return areParametersValid(value);
566  default:
567  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
568  }
569 }
570 
571 
572 bool
574  // check if we're in supermode Network
576  return true;
577  } else {
578  return false;
579  }
580 }
581 
582 
583 std::string
585  return getTagStr() + ": " + getID();
586 }
587 
588 
589 std::string
591  return getTagStr();
592 }
593 
594 // ===========================================================================
595 // private
596 // ===========================================================================
597 
598 void
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 
625 void
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  myAdditionalContour.calculateContourCircleShape(s, d, this, *this, 1.3, exaggeration);
636  } else {
637  myAdditionalContour.calculateContourRectangleShape(s, d, this, *this, getHeight() * 0.5, getWidth() * 0.5, 0, 0, getShapeNaviDegree(), exaggeration);
638  }
639 }
640 
641 
642 void
643 GNEPOI::setAttribute(SumoXMLAttr key, const std::string& value) {
644  switch (key) {
645  case SUMO_ATTR_ID: {
646  // update microsimID
647  setAdditionalID(value);
648  // set named ID
649  myID = value;
650  break;
651  }
652  case SUMO_ATTR_COLOR:
653  setShapeColor(parse<RGBColor>(value));
654  break;
655  case SUMO_ATTR_LANE:
656  myLane = value;
658  break;
659  case SUMO_ATTR_POSITION: {
660  if (getParentLanes().size() > 0) {
661  if (canParse<double>(value)) {
662  myPosOverLane = parse<double>(value);
663  }
664  } else {
665  // set position
666  set(parse<Position>(value));
667  }
668  // update centering boundary
670  // update geometry
671  updateGeometry();
672  break;
673  }
675  setFriendlyPos(parse<bool>(value));
676  break;
678  myPosLat = parse<double>(value);
679  // update centering boundary
681  // update geometry
682  updateGeometry();
683  break;
684  case SUMO_ATTR_LON: {
685  // calculate cartesian
686  Position cartesian(parse<double>(value), parse<double>(getAttribute(SUMO_ATTR_LAT)));
688  // set cartesian
689  set(cartesian);
690  // update centering boundary
692  // update geometry
693  updateGeometry();
694  break;
695  }
696  case SUMO_ATTR_LAT: {
697  // calculate cartesian
698  Position cartesian(parse<double>(getAttribute(SUMO_ATTR_LON)), parse<double>(value));
700  // set cartesian
701  set(cartesian);
702  // update centering boundary
704  // update geometry
705  updateGeometry();
706  break;
707  }
708  case SUMO_ATTR_TYPE:
709  setShapeType(value);
710  break;
711  case SUMO_ATTR_ICON:
712  setIcon(value);
713  break;
714  case SUMO_ATTR_LAYER:
715  if (value == "default") {
717  } else {
718  setShapeLayer(parse<double>(value));
719  }
720  break;
721  case SUMO_ATTR_IMGFILE:
722  // first remove object from grid due img file affect to boundary
723  if (getID().size() > 0) {
725  }
726  setShapeImgFile(value);
727  // all textures must be refresh
729  // add object into grid again
730  if (getID().size() > 0) {
731  myNet->addGLObjectIntoGrid(this);
732  }
733  break;
735  setShapeRelativePath(parse<bool>(value));
736  break;
737  case SUMO_ATTR_WIDTH:
738  // set new width
739  setWidth(parse<double>(value));
740  // update centering boundary and geometry (except for templates)
741  if (getID().size() > 0) {
743  updateGeometry();
744  }
745  break;
746  case SUMO_ATTR_HEIGHT:
747  // set new height
748  setHeight(parse<double>(value));
749  // update centering boundary and geometry (except for templates)
750  if (getID().size() > 0) {
752  updateGeometry();
753  }
754  break;
755  case SUMO_ATTR_ANGLE:
756  setShapeNaviDegree(parse<double>(value));
757  break;
758  case SUMO_ATTR_NAME:
759  setShapeName(value);
760  break;
761  case GNE_ATTR_SELECTED:
762  if (parse<bool>(value)) {
764  } else {
766  }
767  break;
768  case GNE_ATTR_PARAMETERS:
770  break;
772  shiftLaneIndex();
773  break;
774  default:
775  throw InvalidArgument(getTagStr() + " attribute '" + toString(key) + "' not allowed");
776  }
777 }
778 
779 
780 void
782  // check what are being updated
784  myShapeHeight = moveResult.shapeToUpdate;
785  } else if (moveResult.operationType == GNEMoveOperation::OperationType::WIDTH) {
786  myShapeWidth = moveResult.shapeToUpdate;
787  } else {
788  if (getTagProperty().getTag() == GNE_TAG_POILANE) {
789  myPosOverLane = moveResult.newFirstPos;
790  } else {
791  set(moveResult.shapeToUpdate.front());
792  }
793  // update geometry
794  updateGeometry();
795  }
796 }
797 
798 
799 void
800 GNEPOI::commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) {
801  // check what are being updated
803  undoList->begin(this, "height of " + getTagStr());
804  setAttribute(SUMO_ATTR_HEIGHT, toString(moveResult.shapeToUpdate.length2D()), undoList);
805  undoList->end();
806  } else if (moveResult.operationType == GNEMoveOperation::OperationType::WIDTH) {
807  undoList->begin(this, "width of " + getTagStr());
808  setAttribute(SUMO_ATTR_WIDTH, toString(moveResult.shapeToUpdate.length2D()), undoList);
809  undoList->end();
810  } else {
811  undoList->begin(this, "position of " + getTagStr());
812  if (getTagProperty().getTag() == GNE_TAG_POILANE) {
814  } else {
816  }
817  undoList->end();
818  }
819 }
820 
821 /****************************************************************************/
@ NETWORK_MOVE
mode for moving network elements
@ MID_GNE_POI_TRANSFORM
Transform POI to POILane, and viceversa.
Definition: GUIAppEnum.h:1336
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 drawBoundary(const GUIVisualizationSettings &s, const Boundary &b)
Draw a boundary (used for debugging)
Definition: GLHelper.cpp:967
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
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 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:1368
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition: GNENet.cpp:1378
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:123
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2136
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:800
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:781
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 attribute carrier or a pointer to nullptr
bool isCurrentlyMovingElements() const
check if an element is being moved
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
Definition: GNEViewNet.cpp:747
const GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:723
const GNEViewNetHelper::EditNetworkElementShapes & getEditNetworkElementShapes() const
get Edit Shape module
Definition: GNEViewNet.cpp:759
const GNEViewNetHelper::MouseButtonKeyPressed & getMouseButtonKeyPressed() const
get Key Pressed module
Definition: GNEViewNet.cpp:753
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:477
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
Definition: GNEViewNet.cpp:553
const GNEViewNetHelper::DemandViewOptions & getDemandViewOptions() const
get demand view options
Definition: GNEViewNet.cpp:741
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
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
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 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
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
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
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