Eclipse SUMO - Simulation of Urban MObility
GNETAZ.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 //
19 /****************************************************************************/
20 #include <config.h>
21 
22 #include <netedit/GNENet.h>
23 #include <netedit/GNEUndoList.h>
24 #include <netedit/GNEViewNet.h>
25 #include <netedit/GNEViewParent.h>
29 #include <utils/gui/div/GLHelper.h>
33 #include <utils/xml/NamespaceIDs.h>
34 
35 #include "GNETAZ.h"
36 
37 
38 // ===========================================================================
39 // static members
40 // ===========================================================================
41 const double GNETAZ::myHintSize = 0.8;
42 const double GNETAZ::myHintSizeSquared = 0.64;
43 
44 
45 // ===========================================================================
46 // member method definitions
47 // ===========================================================================
48 
50  GNEAdditional("", net, GLO_TAZ, SUMO_TAG_TAZ, GUIIconSubSys::getIcon(GUIIcon::TAZ), "", {}, {}, {}, {}, {}, {}),
52  myMaxWeightSource(0),
53  myMinWeightSource(0),
54  myAverageWeightSource(0),
55  myMaxWeightSink(0),
56  myMinWeightSink(0),
57 myAverageWeightSink(0) {
58  // reset default values
59  resetDefaultValues();
60 }
61 
62 
63 GNETAZ::GNETAZ(const std::string& id, GNENet* net, const PositionVector& shape, const Position& center, const bool fill,
64  const RGBColor& color, const std::string& name, const Parameterised::Map& parameters) :
65  GNEAdditional(id, net, GLO_TAZ, SUMO_TAG_TAZ, GUIIconSubSys::getIcon(GUIIcon::TAZ), "", {}, {}, {}, {}, {}, {}),
67 myTAZCenter(center),
68 myMaxWeightSource(0),
69 myMinWeightSource(0),
70 myAverageWeightSource(0),
71 myMaxWeightSink(0),
72 myMinWeightSink(0),
73 myAverageWeightSink(0) {
74  // update centering boundary without updating grid
75  updateCenteringBoundary(false);
76  // update geometry
77  updateGeometry();
78 }
79 
80 
82 
83 
86  // get snap radius
88  // check if we're moving center or shape
89  if (myTAZCenter.distanceSquaredTo2D(myNet->getViewNet()->getPositionInformation()) < (snap_radius * snap_radius)) {
90  // move entire shape
91  return new GNEMoveOperation(this, myTAZCenter);
93  // move entire shape
94  return new GNEMoveOperation(this, myShape);
95  } else {
96  // calculate move shape operation
97  return calculateMoveShapeOperation(this, myShape, true);
98  }
99 }
100 
101 
102 int
103 GNETAZ::getVertexIndex(Position pos, bool snapToGrid) {
104  // check if position has to be snapped to grid
105  if (snapToGrid) {
106  pos = myNet->getViewNet()->snapToActiveGrid(pos);
107  }
108  // first check if vertex already exists
109  for (const auto& shapePosition : myShape) {
110  if (shapePosition.distanceTo2D(pos) < myNet->getViewNet()->getVisualisationSettings().neteditSizeSettings.polygonGeometryPointRadius) {
111  return myShape.indexOfClosest(shapePosition);
112  }
113  }
114  return -1;
115 }
116 
117 
118 void
119 GNETAZ::removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList) {
120  // get original shape
121  PositionVector shape = myShape;
122  // check shape size
123  if (shape.size() > 3) {
124  // obtain index
125  int index = shape.indexOfClosest(clickedPosition);
126  // get last index
127  const int lastIndex = ((int)shape.size() - 1);
128  // get snap radius
130  // check if we have to create a new index
131  if ((index != -1) && shape[index].distanceSquaredTo2D(clickedPosition) < (snap_radius * snap_radius)) {
132  // check if we're deleting the first point
133  if ((index == 0) || (index == lastIndex)) {
134  // remove both geometry point
135  shape.erase(shape.begin() + lastIndex);
136  shape.erase(shape.begin());
137  // close shape
138  shape.closePolygon();
139  } else {
140  // remove geometry point
141  shape.erase(shape.begin() + index);
142  }
143  // commit new shape
144  undoList->begin(this, "remove geometry point of " + getTagStr());
146  undoList->end();
147  }
148  }
149 }
150 
151 
152 void
154  // first open TAZ tag
155  device.openTag(SUMO_TAG_TAZ);
156  // write TAZ attributes
157  device.writeAttr(SUMO_ATTR_ID, getID());
159  if (myTAZCenter != myShape.getCentroid()) {
161  }
162  if (myFill) {
163  device.writeAttr(SUMO_ATTR_FILL, true);
164  }
165  if (getShapeName().size() > 0) {
167  }
169  // sort all Source/Sinks by ID
170  std::map<std::pair<std::string, SumoXMLTag>, GNEAdditional*> sortedSourceSinks;
171  for (const auto& sourceSink : getChildAdditionals()) {
172  sortedSourceSinks[std::make_pair(sourceSink->getAttribute(SUMO_ATTR_EDGE), sourceSink->getTagProperty().getTag())] = sourceSink;
173  }
174  // write all TAZ Source/sinks
175  for (const auto& sortedSourceSink : sortedSourceSinks) {
176  sortedSourceSink.second->writeAdditional(device);
177  }
178  // write params
179  writeParams(device);
180  // close TAZ tag
181  device.closeTag();
182 }
183 
184 
185 bool
187  return true;
188 }
189 
190 
191 std::string
193  return "";
194 }
195 
196 
197 void
199  // nothing to fix
200 }
201 
202 
203 bool
205  // get edit modes
206  const auto& editModes = myNet->getViewNet()->getEditModes();
207  // check if we're in move mode
208  if (!myNet->getViewNet()->isCurrentlyMovingElements() && editModes.isCurrentSupermodeNetwork() &&
210  (editModes.networkEditMode == NetworkEditMode::NETWORK_MOVE) && myNet->getViewNet()->checkOverLockedElement(this, mySelected)) {
211  // only move the first element
213  } else {
214  return false;
215  }
216 }
217 
218 
219 void
221  // just update geometry
223  // update geometry of child plan elements
224  for (const auto& demandElements : getChildDemandElements()) {
225  demandElements->updateGeometry();
226  }
227  // update geometry of childTAZRelDatas
228  for (const auto& TAZRelData : getChildGenericDatas()) {
229  TAZRelData->updateGeometry();
230  }
231  myTesselation.clear();
232 }
233 
234 
235 Position
237  return myShape.getCentroid();
238 }
239 
240 
241 double
243  return s.polySize.getExaggeration(s, this);
244 }
245 
246 
247 void
248 GNETAZ::updateCenteringBoundary(const bool updateGrid) {
249  // Remove object from net
250  if (updateGrid) {
252  for (const auto& TAZRelData : getChildGenericDatas()) {
253  myNet->removeGLObjectFromGrid(TAZRelData);
254  }
255  }
256  // use shape as boundary
258  // add center
261  }
262  // grow boundary
264  // add object into net
265  if (updateGrid) {
266  myNet->addGLObjectIntoGrid(this);
267  for (const auto& TAZRelData : getChildGenericDatas()) {
268  TAZRelData->updateGeometry();
269  myNet->addGLObjectIntoGrid(TAZRelData);
270  }
271  }
272 }
273 
274 
275 void
276 GNETAZ::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
277  // Nothing to split
278 }
279 
280 
281 std::string
283  return myNet->getMicrosimID();
284 }
285 
286 
289  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
290  buildPopupHeader(ret, app);
293  // build selection and show parameters menu
296  // create a extra FXMenuCommand if mouse is over a vertex
297  const int index = getVertexIndex(myNet->getViewNet()->getPositionInformation(), false);
298  if (index != -1) {
299  // check if we're in network mode
301  GUIDesigns::buildFXMenuCommand(ret, TL("Set custom Geometry Point"), nullptr, &parent, MID_GNE_CUSTOM_GEOMETRYPOINT);
302  }
303  }
304  return ret;
305 }
306 
307 
308 void
310  // first check if poly can be drawn
312  GUIPolygon::checkDraw(s, this, this)) {
313  // draw boundary
314  const auto boundary = getCenteringBoundary();
315  GLHelper::drawBoundary(s, boundary);
316  // get exaggeration
317  const double TAZExaggeration = getExaggeration(s);
318  // get detail level
319  const auto d = s.getDetailLevel(TAZExaggeration);
320  // draw geometry only if we'rent in drawForObjectUnderCursor mode
321  if (s.checkDrawPoly(boundary, isAttributeCarrierSelected())) {
322  // Obtain constants
323  const Position mousePosition = myNet->getViewNet()->getPositionInformation();
324  const bool drawFill = (myNet->getViewNet()->getEditModes().isCurrentSupermodeData() && myNet->getViewNet()->getDataViewOptions().TAZDrawFill()) ? true : getFill();
325  // get colors
326  const RGBColor color = GUIPolygon::setColor(s, this, this, drawUsingSelectColor(), -1);
327  const RGBColor darkerColor = color.changedBrightness(-32);
328  // push layer matrix
330  // translate to front
332  // check if we're drawing a polygon or a polyline
334  // draw inner polygon
335  const int alphaOverride = myNet->getViewNet()->getDataViewOptions().TAZDrawFill() ? 128 : -1;
336  GUIPolygon::drawInnerPolygon(s, this, this, myAdditionalGeometry.getShape(), 0, drawFill, drawUsingSelectColor(), alphaOverride, true);
337  } else {
338  // push matrix
340  // set color
341  GLHelper::setColor(color);
342  // draw geometry (polyline)
344  // pop matrix
346  }
347  // draw contour if shape isn't blocked
349  // push contour matrix
351  // translate to front
352  glTranslated(0, 0, 0.1);
353  // set color
354  GLHelper::setColor(darkerColor);
355  // draw polygon contour
357  // pop contour matrix
359  // draw shape points only in Network supemode
361  // check if we're in move mode
363  // get geometry point sizes
364  const double geometryPointSize = s.neteditSizeSettings.polygonGeometryPointRadius * (moveMode ? 1 : 0.5);
365  // draw geometry points
366  GUIGeometry::drawGeometryPoints(d, myAdditionalGeometry.getShape(), darkerColor, geometryPointSize, TAZExaggeration,
368  // draw dotted contours for geometry points if we're in move mode
369  if (moveMode) {
371  TAZExaggeration, s.dottedContourSettings.segmentWidthSmall);
372  }
373  }
374  }
375  // draw center
376  const double centerRadius = s.neteditSizeSettings.polygonGeometryPointRadius * TAZExaggeration;
377  // push center matrix
379  // move to vertex
380  glTranslated(myTAZCenter.x(), myTAZCenter.y(), GLO_JUNCTION + 0.3);
381  // set color
382  GLHelper::setColor(darkerColor);
383  // draw circle
384  GLHelper::drawFilledCircleDetailled(d, centerRadius);
385  // move to front
386  glTranslated(0, 0, 0.1);
387  // set color
388  GLHelper::setColor(color);
389  // draw circle
390  GLHelper::drawFilledCircleDetailled(d, centerRadius * 0.8);
391  // pop center matrix
393  // pop layer matrix
395  // draw lock icon
397  // draw name
399  // check if draw poly type
400  if (s.polyType.show(this)) {
403  }
404  // get contour width
406  // draw dotted contour
407  myAdditionalContour.drawDottedContours(s, d, this, contourWidth, true);
408  // draw TAZ Center dotted contour
409  myTAZCenterContour.drawDottedContours(s, d, this, contourWidth, true);
410  }
411  // draw demand element children
413  // calculate contour
414  calculateContourPolygons(s, d, TAZExaggeration, true);
415  // calculate contour for TAZ Center
417  }
418 }
419 
420 
421 std::string
423  switch (key) {
424  case SUMO_ATTR_ID:
425  return getMicrosimID();
426  case SUMO_ATTR_SHAPE:
427  return toString(myShape);
428  case SUMO_ATTR_CENTER:
429  if (myTAZCenter == myShape.getCentroid()) {
430  return "";
431  } else {
432  return toString(myTAZCenter);
433  }
434  case SUMO_ATTR_COLOR:
435  return toString(getShapeColor());
436  case SUMO_ATTR_NAME:
437  return getShapeName();
438  case SUMO_ATTR_FILL:
439  return toString(myFill);
440  case SUMO_ATTR_EDGES: {
441  std::vector<std::string> edgeIDs;
442  for (const auto& TAZChild : getChildAdditionals()) {
443  edgeIDs.push_back(TAZChild->getAttribute(SUMO_ATTR_EDGE));
444  }
445  return toString(edgeIDs);
446  }
447  case GNE_ATTR_SELECTED:
449  case GNE_ATTR_PARAMETERS:
450  return getParametersStr();
451  case GNE_ATTR_MIN_SOURCE:
453  return "undefined";
454  } else {
455  return toString(myMinWeightSource);
456  }
457  case GNE_ATTR_MIN_SINK:
459  return "undefined";
460  } else {
461  return toString(myMinWeightSink);
462  }
463  case GNE_ATTR_MAX_SOURCE:
465  return "undefined";
466  } else {
467  return toString(myMaxWeightSource);
468  }
469  case GNE_ATTR_MAX_SINK:
471  return "undefined";
472  } else {
473  return toString(myMaxWeightSink);
474  }
477  return "undefined";
478  } else {
480  }
483  return "undefined";
484  } else {
486  }
487  default:
488  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
489  }
490 }
491 
492 
493 double
495  switch (key) {
496  case GNE_ATTR_MIN_SOURCE:
497  return myMinWeightSource;
498  case GNE_ATTR_MIN_SINK:
499  return myMinWeightSink;
500  case GNE_ATTR_MAX_SOURCE:
501  return myMaxWeightSource;
502  case GNE_ATTR_MAX_SINK:
503  return myMaxWeightSink;
505  return myAverageWeightSource;
507  return myAverageWeightSink;
508  default:
509  throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
510  }
511 }
512 
513 
514 Position
516  switch (key) {
517  case SUMO_ATTR_CENTER:
518  return myTAZCenter;
520  return myShape.getCentroid();
521  default:
522  throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
523  }
524 }
525 
526 
527 const Parameterised::Map&
529  return getParametersMap();
530 }
531 
532 
533 void
534 GNETAZ::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
535  if (value == getAttribute(key)) {
536  return; //avoid needless changes, later logic relies on the fact that attributes have changed
537  }
538  switch (key) {
539  case SUMO_ATTR_ID:
540  case SUMO_ATTR_SHAPE:
541  case SUMO_ATTR_CENTER:
542  case SUMO_ATTR_COLOR:
543  case SUMO_ATTR_NAME:
544  case SUMO_ATTR_FILL:
545  case SUMO_ATTR_EDGES:
546  case GNE_ATTR_SELECTED:
547  case GNE_ATTR_PARAMETERS:
548  GNEChange_Attribute::changeAttribute(this, key, value, undoList);
549  break;
550  default:
551  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
552  }
553 }
554 
555 
556 bool
557 GNETAZ::isValid(SumoXMLAttr key, const std::string& value) {
558  switch (key) {
559  case SUMO_ATTR_ID:
561  case SUMO_ATTR_SHAPE:
562  if (value.empty()) {
563  return false;
564  } else {
565  return canParse<PositionVector>(value);
566  }
567  case SUMO_ATTR_CENTER:
568  if (value.empty()) {
569  return true;
570  } else {
571  return canParse<Position>(value);
572  }
573  case SUMO_ATTR_COLOR:
574  return canParse<RGBColor>(value);
575  case SUMO_ATTR_NAME:
577  case SUMO_ATTR_FILL:
578  return canParse<bool>(value);
579  case SUMO_ATTR_EDGES:
580  if (value.empty()) {
581  return true;
582  } else {
584  }
585  case GNE_ATTR_SELECTED:
586  return canParse<bool>(value);
587  case GNE_ATTR_PARAMETERS:
588  return areParametersValid(value);
589  default:
590  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
591  }
592 }
593 
594 
595 std::string
597  return getTagStr() + ":" + getID();
598 }
599 
600 
601 std::string
603  return getTagStr();
604 }
605 
606 
607 void
609  // reset all statistic variables
616  // declare an extra variables for saving number of children
617  int numberOfSources = 0;
618  int numberOfSinks = 0;
619  // iterate over child additional
620  for (const auto& TAZChild : getChildAdditionals()) {
621  if (TAZChild->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) {
622  const double weight = TAZChild->getAttributeDouble(SUMO_ATTR_WEIGHT);
623  // check max Weight
624  if ((myMaxWeightSource == INVALID_DOUBLE) || (myMaxWeightSource < weight)) {
625  myMaxWeightSource = weight;
626  }
627  // check min Weight
628  if ((myMinWeightSource == INVALID_DOUBLE) || (weight < myMinWeightSource)) {
629  myMinWeightSource = weight;
630  }
631  // update Average
632  myAverageWeightSource += weight;
633  // update number of sources
634  numberOfSources++;
635  } else if (TAZChild->getTagProperty().getTag() == SUMO_TAG_TAZSINK) {
636  const double weight = TAZChild->getAttributeDouble(SUMO_ATTR_WEIGHT);
637  // check max Weight
638  if ((myMaxWeightSink == INVALID_DOUBLE) || myMaxWeightSink < weight) {
639  myMaxWeightSink = weight;
640  }
641  // check min Weight
642  if ((myMinWeightSink == INVALID_DOUBLE) || (weight < myMinWeightSink)) {
643  myMinWeightSink = weight;
644  }
645  // update Average
646  myAverageWeightSink += weight;
647  // update number of sinks
648  numberOfSinks++;
649  }
650  }
651  // calculate average
652  if (numberOfSources > 0) {
653  myAverageWeightSource /= numberOfSources;
654  }
655  if (numberOfSinks > 0) {
656  myAverageWeightSink /= numberOfSinks;
657  }
658 }
659 
660 // ===========================================================================
661 // private
662 // ===========================================================================
663 
664 void
665 GNETAZ::setAttribute(SumoXMLAttr key, const std::string& value) {
666  switch (key) {
667  case SUMO_ATTR_ID:
668  // update microsimID
669  setAdditionalID(value);
670  break;
671  case SUMO_ATTR_SHAPE: {
672  const bool updateCenter = (myTAZCenter == myShape.getCentroid());
673  // set new shape
674  myShape = parse<PositionVector>(value);
675  // always close shape
676  if ((myShape.size() > 1) && (myShape.front() != myShape.back())) {
677  myShape.push_back(myShape.front());
678  }
679  // update center
680  if (myShape.size() == 0) {
681  myTAZCenter = Position(0, 0, 0);
682  } else if (updateCenter) {
684  }
685  // update geometry
686  updateGeometry();
687  // update centering boundary
688  if (!isTemplate()) {
690  }
691  break;
692  }
693  case SUMO_ATTR_CENTER:
694  if (value.empty()) {
696  } else {
697  myTAZCenter = parse<Position>(value);
698  }
699  // update geometry
700  updateGeometry();
701  // update centering boundary
702  if (!isTemplate()) {
704  }
705  break;
706  case SUMO_ATTR_COLOR:
707  setShapeColor(parse<RGBColor>(value));
708  break;
709  case SUMO_ATTR_NAME:
710  setShapeName(value);
711  break;
712  case SUMO_ATTR_FILL:
713  myFill = parse<bool>(value);
714  break;
715  case SUMO_ATTR_EDGES:
716  break;
717  case GNE_ATTR_SELECTED:
718  if (parse<bool>(value)) {
720  } else {
722  }
723  break;
724  case GNE_ATTR_PARAMETERS:
725  setParametersStr(value);
726  break;
727  default:
728  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
729  }
730 }
731 
732 
733 void
736  // update new center
737  myTAZCenter = moveResult.shapeToUpdate.front();
739  // update new shape and center
741  myShape = moveResult.shapeToUpdate;
742  // update geometry
744  } else {
745  // get lastIndex
746  const int lastIndex = (int)moveResult.shapeToUpdate.size() - 1;
747  // update new shape
748  myShape = moveResult.shapeToUpdate;
749  // adjust first and last position
750  if (moveResult.geometryPointsToMove.front() == 0) {
751  myShape[lastIndex] = moveResult.shapeToUpdate[0];
752  } else if (moveResult.geometryPointsToMove.front() == lastIndex) {
753  myShape[0] = moveResult.shapeToUpdate[lastIndex];
754  }
756  // update geometry
758  }
759  myTesselation.clear();
760 }
761 
762 
763 void
764 GNETAZ::commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) {
766  // commit center
767  undoList->begin(this, "moving " + toString(SUMO_ATTR_CENTER) + " of " + getTagStr());
768  GNEChange_Attribute::changeAttribute(this, SUMO_ATTR_CENTER, toString(moveResult.shapeToUpdate.front()), undoList);
769  undoList->end();
771  // calculate offset between old and new shape
772  Position newCenter = myTAZCenter;
773  newCenter.add(moveResult.shapeToUpdate.getCentroid() - myShape.getCentroid());
774  // commit new shape and center
775  undoList->begin(this, "moving " + toString(SUMO_ATTR_SHAPE) + " of " + getTagStr());
778  undoList->end();
779  } else {
780  // get lastIndex
781  const int lastIndex = (int)moveResult.shapeToUpdate.size() - 1;
782  // close shapeToUpdate
783  auto closedShape = moveResult.shapeToUpdate;
784  // adjust first and last position
785  if (moveResult.geometryPointsToMove.front() == 0) {
786  closedShape[lastIndex] = moveResult.shapeToUpdate[0];
787  } else if (moveResult.geometryPointsToMove.front() == lastIndex) {
788  closedShape[0] = moveResult.shapeToUpdate[lastIndex];
789  }
790  // commit new shape
791  undoList->begin(this, "moving " + toString(SUMO_ATTR_SHAPE) + " of " + getTagStr());
792  GNEChange_Attribute::changeAttribute(this, SUMO_ATTR_SHAPE, toString(closedShape), undoList);
793  undoList->end();
794  }
795 }
796 
797 /****************************************************************************/
@ NETWORK_MOVE
mode for moving network elements
@ MID_GNE_CUSTOM_GEOMETRYPOINT
set custom geometry point
Definition: GUIAppEnum.h:1023
@ GLO_JUNCTION
a junction
@ GLO_TAZ
Traffic Assignment Zones (TAZs)
GUIIcon
An enumeration of icons used by the gui applications.
Definition: GUIIcons.h:33
#define TL(string)
Definition: MsgHandler.h:315
@ SUMO_TAG_TAZ
a traffic assignment zone
@ SUMO_TAG_TAZSINK
a sink within a district (connection road)
@ SUMO_TAG_TAZSOURCE
a source within a district (connection road)
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ GNE_ATTR_MAX_SOURCE
max source (used only by TAZs)
@ SUMO_ATTR_EDGE
@ GNE_ATTR_MAX_SINK
max sink (used only by TAZs)
@ GNE_ATTR_AVERAGE_SINK
average sink (used only by TAZs)
@ GNE_ATTR_SELECTED
element is selected
@ GNE_ATTR_TAZ_CENTROID
TAZ Center (uses to return the TAZ centroid if center is not defined)
@ GNE_ATTR_MIN_SINK
min sink (used only by TAZs)
@ SUMO_ATTR_EDGES
the edges of a route
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
@ SUMO_ATTR_SHAPE
edge: the shape in xml-definition
@ SUMO_ATTR_WEIGHT
@ SUMO_ATTR_FILL
Fill the polygon.
@ SUMO_ATTR_NAME
@ SUMO_ATTR_CENTER
@ GNE_ATTR_AVERAGE_SOURCE
average source (used only by TAZs)
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_ID
@ GNE_ATTR_MIN_SOURCE
min source (used only by TAZs)
const double INVALID_DOUBLE
invalid double
Definition: StdDefs.h:64
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
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:319
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 drawFilledCircleDetailled(const GUIVisualizationSettings::Detail d, const double radius)
Draws a filled circle around (0,0) depending of level of detail.
Definition: GLHelper.cpp:539
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:117
static void drawTextSettings(const GUIVisualizationTextSettings &settings, const std::string &text, const Position &pos, const double scale, const double angle=0, const double layer=2048, const int align=0)
Definition: GLHelper.cpp:787
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
virtual void writeAdditional(OutputDevice &device) const =0
write additional element into a xml file
void setAdditionalID(const std::string &newID)
set additional ID
GNEContour myAdditionalContour
variable used for draw additional contours
GUIGeometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
bool checkDrawFromContour() const
check if draw from contour (green)
void drawDemandElementChildren(const GUIVisualizationSettings &s) const
draw demand element children
bool checkDrawToContour() const
check if draw from contour (magenta)
void calculateContourPolygons(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double exaggeration, const bool contouredShape) const
calculate contour for polygons
Boundary myAdditionalBoundary
Additional Boundary (used only by additionals placed over grid)
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
bool mySelected
boolean to check if this AC is selected (instead of GUIGlObjectStorage)
const std::string & getTagStr() const
get tag assigned to this object in string format
bool isTemplate() const
check if this AC is template
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
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 drawDottedContourGeometryPoints(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const PositionVector &shape, const double radius, const double scale, const double lineWidth) const
draw dotted contour for geometry points
Definition: GNEContour.cpp:307
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< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
const std::vector< GNEAdditional * > & getChildAdditionals() const
return child additionals
const std::vector< GNEGenericData * > & getChildGenericDatas() const
return child generic data elements
GNEMoveOperation * calculateMoveShapeOperation(const GUIGlObject *obj, const PositionVector originalShape, const bool maintainShapeClosed)
calculate move shape operation
bool getMoveWholePolygons() const
move whole polygons
NetworkModeOptions * getNetworkModeOptions() const
get network mode options
move operation
move result
const GNEMoveOperation::OperationType operationType
move operation
std::vector< int > geometryPointsToMove
shape points to move (of shapeToMove)
PositionVector shapeToUpdate
shape to update (edited in moveElement)
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
void addGLObjectIntoGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition: GNENet.cpp:1368
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition: GNENet.cpp:1378
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2136
Position getPositionInView() const
Returns position of additional in view.
Definition: GNETAZ.cpp:236
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
Definition: GNETAZ.cpp:248
std::string getAdditionalProblem() const
return a string with the current additional problem (must be reimplemented in all detector children)
Definition: GNETAZ.cpp:192
double myMaxWeightSink
Max Sink weight.
Definition: GNETAZ.h:218
Position myTAZCenter
TAZ center.
Definition: GNETAZ.h:196
static const double myHintSize
hint size of vertex
Definition: GNETAZ.h:203
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNETAZ.cpp:309
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNETAZ.cpp:596
GNEContour myTAZCenterContour
TAZ center contour.
Definition: GNETAZ.h:199
bool isAdditionalValid() const
check if current additional is valid to be written into XML (must be reimplemented in all detector ch...
Definition: GNETAZ.cpp:186
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
Definition: GNETAZ.cpp:242
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Definition: GNETAZ.cpp:276
Position getAttributePosition(SumoXMLAttr key) const
Definition: GNETAZ.cpp:515
~GNETAZ()
GNETAZ Destructor.
Definition: GNETAZ.cpp:81
double myAverageWeightSource
Average source weight.
Definition: GNETAZ.h:215
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition: GNETAZ.cpp:734
void updateGeometry()
update pre-computed geometry information
Definition: GNETAZ.cpp:220
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their correspondent attribute are valids
Definition: GNETAZ.cpp:557
double myMinWeightSink
Min Sink weight.
Definition: GNETAZ.h:221
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNETAZ.cpp:85
double myAverageWeightSink
Average Sink weight.
Definition: GNETAZ.h:224
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNETAZ.cpp:602
std::string getParentName() const
Returns the name of the parent object.
Definition: GNETAZ.cpp:282
void fixAdditionalProblem()
fix additional problem (must be reimplemented in all detector children)
Definition: GNETAZ.cpp:198
void writeAdditional(OutputDevice &device) const
write additional element into a xml file
Definition: GNETAZ.cpp:153
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
Definition: GNETAZ.cpp:119
std::string getAttribute(SumoXMLAttr key) const
Definition: GNETAZ.cpp:422
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNETAZ.cpp:288
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes
Definition: GNETAZ.cpp:534
static const double myHintSizeSquared
squaredhint size of vertex
Definition: GNETAZ.h:206
void updateTAZStatistic()
update TAZ Statistic
Definition: GNETAZ.cpp:608
double myMinWeightSource
Min source weight.
Definition: GNETAZ.h:212
int getVertexIndex(Position pos, bool snapToGrid)
return index of a vertex of shape, or of a new vertex if position is over an shape's edge
Definition: GNETAZ.cpp:103
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition: GNETAZ.cpp:764
const Parameterised::Map & getACParametersMap() const
get parameters map
Definition: GNETAZ.cpp:528
double getAttributeDouble(SumoXMLAttr key) const
Definition: GNETAZ.cpp:494
double myMaxWeightSource
Max source weight.
Definition: GNETAZ.h:209
bool checkDrawMoveContour() const
check if draw move contour (red)
Definition: GNETAZ.cpp:204
GNETAZ(GNENet *net)
@default GNETAZ Constructor
Definition: GNETAZ.cpp:49
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 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::NetworkViewOptions & getNetworkViewOptions() const
get network view options
Definition: GNEViewNet.cpp:735
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, double typeOrLayer, const double extraOffset=0)
draw front attributeCarrier
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)
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.
static void drawGeometryPoints(const GUIVisualizationSettings::Detail d, const PositionVector &shape, const RGBColor &color, const double radius, const double exaggeration, const bool editingElevation)
draw geometry points
static void drawGeometry(const GUIVisualizationSettings::Detail d, const GUIGeometry &geometry, const double width, double offset=0)
draw geometry
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
Definition: GUIGeometry.cpp:59
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 drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
static void drawInnerPolygon(const GUIVisualizationSettings &s, const TesselatedPolygon *polygon, const GUIGlObject *o, const PositionVector shape, const double layer, const bool fill, const bool disableSelectionColor=false, const int alphaOverride=-1, const bool disableText=false)
draw inner Polygon (before pushName() )
Definition: GUIPolygon.cpp:342
static bool checkDraw(const GUIVisualizationSettings &s, const SUMOPolygon *polygon, const GUIGlObject *o)
check if Polygon can be drawn
Definition: GUIPolygon.cpp:320
static RGBColor setColor(const GUIVisualizationSettings &s, const SUMOPolygon *polygon, const GUIGlObject *o, bool disableSelectionColor, int alphaOverride)
set color
Definition: GUIPolygon.cpp:291
Position snapToActiveGrid(const Position &pos, bool snapXY=true) const
Returns a position that is mapped to the closest grid point if the grid is active.
const GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings (read only)
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
Stores the information about how to visualize structures.
bool checkDrawPoly(const Boundary &b, const bool selected) const
check if draw polygon
Detail getDetailLevel(const double exaggeration) const
return the detail level
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
double scale
information about a lane's width (temporary, used for a single view)
GUIVisualizationTextSettings polyName
GUIVisualizationSizeSettings polySize
GUIVisualizationTextSettings polyType
GUIVisualizationNeteditSizeSettings neteditSizeSettings
netedit size settings
double angle
The current view rotation angle.
static const std::vector< SumoXMLTag > polygons
polygon namespace
Definition: NamespaceIDs.h:47
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:254
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
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.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
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 in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
double distanceSquaredTo2D(const Position &p2) const
returns the square of the distance to another position (Only using x and y positions)
Definition: Position.h:281
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:322
double x() const
Returns the x-position.
Definition: Position.h:55
void add(const Position &pos)
Adds the given position to this one.
Definition: Position.h:132
double y() const
Returns the y-position.
Definition: Position.h:60
A list of positions.
Position getPolygonCenter() const
Returns the arithmetic of all corner points.
void closePolygon()
ensures that the last position equals the first
int indexOfClosest(const Position &p, bool twoD=false) const
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
Position getCentroid() const
Returns the centroid (closes the polygon if unclosed)
static const RGBColor BLACK
Definition: RGBColor.h:193
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:200
PositionVector myShape
The positions of the polygon.
Definition: SUMOPolygon.h:136
bool myFill
Information whether the polygon has to be filled.
Definition: SUMOPolygon.h:145
bool getFill() const
Returns whether the polygon is filled.
Definition: SUMOPolygon.cpp:63
static bool isValidListOfTypeID(const std::string &value)
whether the given string is a valid list of ids for an edge or vehicle type (empty aren't allowed)
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 bool DEFAULT_RELATIVEPATH
Definition: Shape.h:48
const RGBColor & getShapeColor() const
Returns the color of the Shape.
Definition: Shape.h:84
static const double DEFAULT_LAYER
Definition: Shape.h:43
void setShapeName(const std::string &name)
Sets a new shape name.
Definition: Shape.h:169
static const std::string DEFAULT_IMG_FILE
Definition: Shape.h:47
static const double DEFAULT_ANGLE
Definition: Shape.h:46
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 & getShapeType() const
Returns the (abstract) type of the Shape.
Definition: Shape.h:77
std::vector< GLPrimitive > myTesselation
id of the display list for the cached tesselation
Definition: GUIPolygon.h:74
bool TAZDrawFill() const
check if toggle TAZ draw fill checkbox is enabled
bool showShapes() const
check if shapes has to be drawn
NetworkEditMode networkEditMode
the current Network edit mode
bool isCurrentSupermodeData() const
@check if current supermode is Data
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
GNENetworkElement * getEditedNetworkElement() const
pointer to edited network element
static void drawLockIcon(const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, GUIGlObjectType type, const Position position, const double exaggeration, const double size=0.5, const double offsetx=0, const double offsety=0)
draw lock icon
bool editingElevation() const
check if we're editing elevation
static const double segmentWidthSmall
width of small dotted contour segments
static const double segmentWidth
width of dotted contour segments
static const double segmentWidthLarge
width of large dotted contour segments
static const double polygonGeometryPointRadius
moving geometry point radius
static const double polygonContourWidth
polygon contour width
static const double polylineWidth
poly line width
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
bool show(const GUIGlObject *o) const
whether to show the text