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()->isMovingElement() && editModes.isCurrentSupermodeNetwork() &&
209  (editModes.networkEditMode == NetworkEditMode::NETWORK_MOVE) && myNet->getViewNet()->checkOverLockedElement(this, mySelected)) {
210  // only move the first element
212  } else {
213  return false;
214  }
215 }
216 
217 
218 void
220  // just update geometry
222  // update geometry of TAZRelDatas
223  for (const auto& TAZRelData : getChildGenericDatas()) {
224  TAZRelData->updateGeometry();
225  }
226  myTesselation.clear();
227 }
228 
229 
230 Position
232  return myShape.getCentroid();
233 }
234 
235 
236 double
238  return s.polySize.getExaggeration(s, this);
239 }
240 
241 
242 void
243 GNETAZ::updateCenteringBoundary(const bool updateGrid) {
244  // Remove object from net
245  if (updateGrid) {
247  for (const auto& TAZRelData : getChildGenericDatas()) {
248  myNet->removeGLObjectFromGrid(TAZRelData);
249  }
250  }
251  // use shape as boundary
253  // add center
256  }
257  // grow boundary
259  // add object into net
260  if (updateGrid) {
261  myNet->addGLObjectIntoGrid(this);
262  for (const auto& TAZRelData : getChildGenericDatas()) {
263  TAZRelData->updateGeometry();
264  myNet->addGLObjectIntoGrid(TAZRelData);
265  }
266  }
267 }
268 
269 
270 void
271 GNETAZ::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
272  // Nothing to split
273 }
274 
275 
276 std::string
278  return myNet->getMicrosimID();
279 }
280 
281 
284  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
285  buildPopupHeader(ret, app);
288  // build selection and show parameters menu
291  // create a extra FXMenuCommand if mouse is over a vertex
292  const int index = getVertexIndex(myNet->getViewNet()->getPositionInformation(), false);
293  if (index != -1) {
294  // check if we're in network mode
296  GUIDesigns::buildFXMenuCommand(ret, TL("Set custom Geometry Point"), nullptr, &parent, MID_GNE_CUSTOM_GEOMETRYPOINT);
297  }
298  }
299  return ret;
300 }
301 
302 
303 void
305  // draw boundaries
307  // first check if poly can be drawn
308  if (myNet->getViewNet()->getDemandViewOptions().showShapes() && GUIPolygon::checkDraw(s, this, this)) {
309  // get exaggeration
310  const double TAZExaggeration = getExaggeration(s);
311  // get detail level
312  const auto d = s.getDetailLevel(TAZExaggeration);
313  // draw geometry only if we'rent in drawForObjectUnderCursor mode
314  if (!s.drawForViewObjectsHandler) {
315  // Obtain constants
316  const Position mousePosition = myNet->getViewNet()->getPositionInformation();
317  const bool drawFill = (myNet->getViewNet()->getEditModes().isCurrentSupermodeData() && myNet->getViewNet()->getDataViewOptions().TAZDrawFill()) ? true : getFill();
318  // get colors
319  const RGBColor color = GUIPolygon::setColor(s, this, this, drawUsingSelectColor(), -1);
320  const RGBColor darkerColor = color.changedBrightness(-32);
321  // push layer matrix
323  // translate to front
325  // check if we're drawing a polygon or a polyline
327  // draw inner polygon
328  const int alphaOverride = myNet->getViewNet()->getDataViewOptions().TAZDrawFill() ? 128 : -1;
329  GUIPolygon::drawInnerPolygon(s, this, this, myAdditionalGeometry.getShape(), 0, drawFill, drawUsingSelectColor(), alphaOverride, true);
330  } else {
331  // push matrix
333  // set color
334  GLHelper::setColor(color);
335  // draw geometry (polyline)
337  // pop matrix
339  }
340  // draw contour if shape isn't blocked
342  // push contour matrix
344  // translate to front
345  glTranslated(0, 0, 0.1);
346  // set color
347  GLHelper::setColor(darkerColor);
348  // draw polygon contour
350  // pop contour matrix
352  // draw shape points only in Network supemode
354  // check if we're in move mode
356  // get geometry point sizes
357  const double geometryPointSize = s.neteditSizeSettings.polygonGeometryPointRadius * (moveMode ? 1 : 0.5);
358  // draw geometry points
359  GUIGeometry::drawGeometryPoints(d, myAdditionalGeometry.getShape(), darkerColor, geometryPointSize, TAZExaggeration,
361  // draw dotted contours for geometry points if we're in move mode
362  if (moveMode) {
364  TAZExaggeration, s.dottedContourSettings.segmentWidthSmall);
365  }
366  }
367  }
368  // draw center
369  const double centerRadius = s.neteditSizeSettings.polygonGeometryPointRadius * TAZExaggeration;
370  // push center matrix
372  // move to vertex
373  glTranslated(myTAZCenter.x(), myTAZCenter.y(), GLO_JUNCTION + 0.3);
374  // set color
375  GLHelper::setColor(darkerColor);
376  // draw circle
377  GLHelper::drawFilledCircleDetailled(d, centerRadius);
378  // move to front
379  glTranslated(0, 0, 0.1);
380  // set color
381  GLHelper::setColor(color);
382  // draw circle
383  GLHelper::drawFilledCircleDetailled(d, centerRadius * 0.8);
384  // pop center matrix
386  // pop layer matrix
388  // draw lock icon
390  // draw name
392  // check if draw poly type
393  if (s.polyType.show(this)) {
396  }
397  // get contour width
399  // draw dotted contour
400  myAdditionalContour.drawDottedContours(s, d, this, contourWidth, true);
401  // draw TAZ Center dotted contour
402  myTAZCenterContour.drawDottedContours(s, d, this, contourWidth, true);
403  }
404  // draw demand element children
406  // calculate contour
407  calculateContourPolygons(s, d, TAZExaggeration, true);
408  // calculate contour for TAZ Center
410  }
411 }
412 
413 
414 std::string
416  switch (key) {
417  case SUMO_ATTR_ID:
418  return getMicrosimID();
419  case SUMO_ATTR_SHAPE:
420  return toString(myShape);
421  case SUMO_ATTR_CENTER:
422  if (myTAZCenter == myShape.getCentroid()) {
423  return "";
424  } else {
425  return toString(myTAZCenter);
426  }
427  case SUMO_ATTR_COLOR:
428  return toString(getShapeColor());
429  case SUMO_ATTR_NAME:
430  return getShapeName();
431  case SUMO_ATTR_FILL:
432  return toString(myFill);
433  case SUMO_ATTR_EDGES: {
434  std::vector<std::string> edgeIDs;
435  for (const auto& TAZChild : getChildAdditionals()) {
436  edgeIDs.push_back(TAZChild->getAttribute(SUMO_ATTR_EDGE));
437  }
438  return toString(edgeIDs);
439  }
440  case GNE_ATTR_SELECTED:
442  case GNE_ATTR_PARAMETERS:
443  return getParametersStr();
444  case GNE_ATTR_MIN_SOURCE:
446  return "undefined";
447  } else {
448  return toString(myMinWeightSource);
449  }
450  case GNE_ATTR_MIN_SINK:
452  return "undefined";
453  } else {
454  return toString(myMinWeightSink);
455  }
456  case GNE_ATTR_MAX_SOURCE:
458  return "undefined";
459  } else {
460  return toString(myMaxWeightSource);
461  }
462  case GNE_ATTR_MAX_SINK:
464  return "undefined";
465  } else {
466  return toString(myMaxWeightSink);
467  }
470  return "undefined";
471  } else {
473  }
476  return "undefined";
477  } else {
479  }
480  default:
481  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
482  }
483 }
484 
485 
486 double
488  switch (key) {
489  case GNE_ATTR_MIN_SOURCE:
490  return myMinWeightSource;
491  case GNE_ATTR_MIN_SINK:
492  return myMinWeightSink;
493  case GNE_ATTR_MAX_SOURCE:
494  return myMaxWeightSource;
495  case GNE_ATTR_MAX_SINK:
496  return myMaxWeightSink;
498  return myAverageWeightSource;
500  return myAverageWeightSink;
501  default:
502  throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
503  }
504 }
505 
506 
507 Position
509  switch (key) {
510  case SUMO_ATTR_CENTER:
511  return myTAZCenter;
512  default:
513  throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
514  }
515 }
516 
517 
518 const Parameterised::Map&
520  return getParametersMap();
521 }
522 
523 
524 void
525 GNETAZ::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
526  if (value == getAttribute(key)) {
527  return; //avoid needless changes, later logic relies on the fact that attributes have changed
528  }
529  switch (key) {
530  case SUMO_ATTR_ID:
531  case SUMO_ATTR_SHAPE:
532  case SUMO_ATTR_CENTER:
533  case SUMO_ATTR_COLOR:
534  case SUMO_ATTR_NAME:
535  case SUMO_ATTR_FILL:
536  case SUMO_ATTR_EDGES:
537  case GNE_ATTR_SELECTED:
538  case GNE_ATTR_PARAMETERS:
539  GNEChange_Attribute::changeAttribute(this, key, value, undoList);
540  break;
541  default:
542  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
543  }
544 }
545 
546 
547 bool
548 GNETAZ::isValid(SumoXMLAttr key, const std::string& value) {
549  switch (key) {
550  case SUMO_ATTR_ID:
552  case SUMO_ATTR_SHAPE:
553  if (value.empty()) {
554  return false;
555  } else {
556  return canParse<PositionVector>(value);
557  }
558  case SUMO_ATTR_CENTER:
559  if (value.empty()) {
560  return true;
561  } else {
562  return canParse<Position>(value);
563  }
564  case SUMO_ATTR_COLOR:
565  return canParse<RGBColor>(value);
566  case SUMO_ATTR_NAME:
568  case SUMO_ATTR_FILL:
569  return canParse<bool>(value);
570  case SUMO_ATTR_EDGES:
571  if (value.empty()) {
572  return true;
573  } else {
575  }
576  case GNE_ATTR_SELECTED:
577  return canParse<bool>(value);
578  case GNE_ATTR_PARAMETERS:
579  return areParametersValid(value);
580  default:
581  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
582  }
583 }
584 
585 
586 std::string
588  return getTagStr() + ":" + getID();
589 }
590 
591 
592 std::string
594  return getTagStr();
595 }
596 
597 
598 void
600  // reset all statistic variables
607  // declare an extra variables for saving number of children
608  int numberOfSources = 0;
609  int numberOfSinks = 0;
610  // iterate over child additional
611  for (const auto& TAZChild : getChildAdditionals()) {
612  if (TAZChild->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) {
613  const double weight = TAZChild->getAttributeDouble(SUMO_ATTR_WEIGHT);
614  // check max Weight
615  if ((myMaxWeightSource == INVALID_DOUBLE) || (myMaxWeightSource < weight)) {
616  myMaxWeightSource = weight;
617  }
618  // check min Weight
619  if ((myMinWeightSource == INVALID_DOUBLE) || (weight < myMinWeightSource)) {
620  myMinWeightSource = weight;
621  }
622  // update Average
623  myAverageWeightSource += weight;
624  // update number of sources
625  numberOfSources++;
626  } else if (TAZChild->getTagProperty().getTag() == SUMO_TAG_TAZSINK) {
627  const double weight = TAZChild->getAttributeDouble(SUMO_ATTR_WEIGHT);
628  // check max Weight
629  if ((myMaxWeightSink == INVALID_DOUBLE) || myMaxWeightSink < weight) {
630  myMaxWeightSink = weight;
631  }
632  // check min Weight
633  if ((myMinWeightSink == INVALID_DOUBLE) || (weight < myMinWeightSink)) {
634  myMinWeightSink = weight;
635  }
636  // update Average
637  myAverageWeightSink += weight;
638  // update number of sinks
639  numberOfSinks++;
640  }
641  }
642  // calculate average
643  if (numberOfSources > 0) {
644  myAverageWeightSource /= numberOfSources;
645  }
646  if (numberOfSinks > 0) {
647  myAverageWeightSink /= numberOfSinks;
648  }
649 }
650 
651 // ===========================================================================
652 // private
653 // ===========================================================================
654 
655 void
656 GNETAZ::setAttribute(SumoXMLAttr key, const std::string& value) {
657  switch (key) {
658  case SUMO_ATTR_ID:
659  // update microsimID
660  setAdditionalID(value);
661  break;
662  case SUMO_ATTR_SHAPE: {
663  const bool updateCenter = (myTAZCenter == myShape.getCentroid());
664  // set new shape
665  myShape = parse<PositionVector>(value);
666  // always close shape
667  if ((myShape.size() > 1) && (myShape.front() != myShape.back())) {
668  myShape.push_back(myShape.front());
669  }
670  // update center
671  if (myShape.size() == 0) {
672  myTAZCenter = Position(0, 0, 0);
673  } else if (updateCenter) {
675  }
676  // update geometry
677  updateGeometry();
678  // update centering boundary
679  if (!isTemplate()) {
681  }
682  break;
683  }
684  case SUMO_ATTR_CENTER:
685  if (value.empty()) {
687  } else {
688  myTAZCenter = parse<Position>(value);
689  }
690  // update geometry
691  updateGeometry();
692  // update centering boundary
693  if (!isTemplate()) {
695  }
696  break;
697  case SUMO_ATTR_COLOR:
698  setShapeColor(parse<RGBColor>(value));
699  break;
700  case SUMO_ATTR_NAME:
701  setShapeName(value);
702  break;
703  case SUMO_ATTR_FILL:
704  myFill = parse<bool>(value);
705  break;
706  case SUMO_ATTR_EDGES:
707  break;
708  case GNE_ATTR_SELECTED:
709  if (parse<bool>(value)) {
711  } else {
713  }
714  break;
715  case GNE_ATTR_PARAMETERS:
716  setParametersStr(value);
717  break;
718  default:
719  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
720  }
721 }
722 
723 
724 void
727  // update new center
728  myTAZCenter = moveResult.shapeToUpdate.front();
730  // update new shape and center
732  myShape = moveResult.shapeToUpdate;
733  // update geometry
735  } else {
736  // get lastIndex
737  const int lastIndex = (int)moveResult.shapeToUpdate.size() - 1;
738  // update new shape
739  myShape = moveResult.shapeToUpdate;
740  // adjust first and last position
741  if (moveResult.geometryPointsToMove.front() == 0) {
742  myShape[lastIndex] = moveResult.shapeToUpdate[0];
743  } else if (moveResult.geometryPointsToMove.front() == lastIndex) {
744  myShape[0] = moveResult.shapeToUpdate[lastIndex];
745  }
747  // update geometry
749  }
750  myTesselation.clear();
751 }
752 
753 
754 void
755 GNETAZ::commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) {
757  // commit center
758  undoList->begin(this, "moving " + toString(SUMO_ATTR_CENTER) + " of " + getTagStr());
759  GNEChange_Attribute::changeAttribute(this, SUMO_ATTR_CENTER, toString(moveResult.shapeToUpdate.front()), undoList);
760  undoList->end();
762  // calculate offset between old and new shape
763  Position newCenter = myTAZCenter;
764  newCenter.add(moveResult.shapeToUpdate.getCentroid() - myShape.getCentroid());
765  // commit new shape and center
766  undoList->begin(this, "moving " + toString(SUMO_ATTR_SHAPE) + " of " + getTagStr());
769  undoList->end();
770  } else {
771  // get lastIndex
772  const int lastIndex = (int)moveResult.shapeToUpdate.size() - 1;
773  // close shapeToUpdate
774  auto closedShape = moveResult.shapeToUpdate;
775  // adjust first and last position
776  if (moveResult.geometryPointsToMove.front() == 0) {
777  closedShape[lastIndex] = moveResult.shapeToUpdate[0];
778  } else if (moveResult.geometryPointsToMove.front() == lastIndex) {
779  closedShape[0] = moveResult.shapeToUpdate[lastIndex];
780  }
781  // commit new shape
782  undoList->begin(this, "moving " + toString(SUMO_ATTR_SHAPE) + " of " + getTagStr());
783  GNEChange_Attribute::changeAttribute(this, SUMO_ATTR_SHAPE, toString(closedShape), undoList);
784  undoList->end();
785  }
786 }
787 
788 /****************************************************************************/
@ NETWORK_MOVE
mode for moving network elements
@ MID_GNE_CUSTOM_GEOMETRYPOINT
set custom geometry point
Definition: GUIAppEnum.h:1019
@ 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_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< 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:1282
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition: GNENet.cpp:1291
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2055
Position getPositionInView() const
Returns position of additional in view.
Definition: GNETAZ.cpp:231
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
Definition: GNETAZ.cpp:243
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:304
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNETAZ.cpp:587
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:237
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Definition: GNETAZ.cpp:271
Position getAttributePosition(SumoXMLAttr key) const
Definition: GNETAZ.cpp:508
~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:725
void updateGeometry()
update pre-computed geometry information
Definition: GNETAZ.cpp:219
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their correspondent attribute are valids
Definition: GNETAZ.cpp:548
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:593
std::string getParentName() const
Returns the name of the parent object.
Definition: GNETAZ.cpp:277
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:415
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNETAZ.cpp:283
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:525
static const double myHintSizeSquared
squaredhint size of vertex
Definition: GNETAZ.h:206
void updateTAZStatistic()
update TAZ Statistic
Definition: GNETAZ.cpp:599
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:755
const Parameterised::Map & getACParametersMap() const
get parameters map
Definition: GNETAZ.cpp:519
double getAttributeDouble(SumoXMLAttr key) const
Definition: GNETAZ.cpp:487
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
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
Definition: GNEViewNet.cpp:727
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:703
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
Definition: GNEViewNet.cpp:715
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, double typeOrLayer, const double extraOffset=0)
draw front attributeCarrier
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)
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.
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.
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)
bool drawForViewObjectsHandler
whether drawing is performed for the purpose of selecting objects in view using ViewObjectsHandler
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:276
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:317
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
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