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.org/sumo
3 // Copyright (C) 2001-2022 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>
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 
51 {}, {}, {}, {}, {}, {}, {}, {},
52 std::map<std::string, std::string>()),
54  myMaxWeightSource(0),
55  myMinWeightSource(0),
56  myAverageWeightSource(0),
57  myMaxWeightSink(0),
58  myMinWeightSink(0),
59 myAverageWeightSink(0) {
60  // reset default values
61  resetDefaultValues();
62 }
63 
64 
65 GNETAZ::GNETAZ(const std::string& id, GNENet* net, const PositionVector& shape, const Position& center, const bool fill,
66  const RGBColor& color, const std::string& name, const std::map<std::string, std::string>& parameters) :
68 {}, {}, {}, {}, {}, {}, {}, {},
69 parameters),
71 myTAZCenter(center),
72 myMaxWeightSource(0),
73 myMinWeightSource(0),
74 myAverageWeightSource(0),
75 myMaxWeightSink(0),
76 myMinWeightSink(0),
77 myAverageWeightSink(0) {
78  // update geometry
79  updateGeometry();
80 }
81 
82 
84 
85 
88  // get snap radius
90  // check if we're moving center or shape
91  if (myTAZCenter.distanceSquaredTo2D(myNet->getViewNet()->getPositionInformation()) < (snap_radius * snap_radius)) {
92  // move entire shape
93  return new GNEMoveOperation(this, myTAZCenter);
95  // move entire shape
96  return new GNEMoveOperation(this, myShape);
97  } else {
98  // calculate move shape operation
100  }
101 }
102 
103 
104 int
105 GNETAZ::getVertexIndex(Position pos, bool snapToGrid) {
106  // check if position has to be snapped to grid
107  if (snapToGrid) {
108  pos = myNet->getViewNet()->snapToActiveGrid(pos);
109  }
110  // first check if vertex already exists
111  for (const auto& shapePosition : myShape) {
112  if (shapePosition.distanceTo2D(pos) < myNet->getViewNet()->getVisualisationSettings().neteditSizeSettings.polygonGeometryPointRadius) {
113  return myShape.indexOfClosest(shapePosition);
114  }
115  }
116  return -1;
117 }
118 
119 
120 void
121 GNETAZ::removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList) {
122  // get original shape
123  PositionVector shape = myShape;
124  // check shape size
125  if (shape.size() > 3) {
126  // obtain index
127  int index = shape.indexOfClosest(clickedPosition);
128  // get last index
129  const int lastIndex = ((int)shape.size() - 1);
130  // get snap radius
132  // check if we have to create a new index
133  if ((index != -1) && shape[index].distanceSquaredTo2D(clickedPosition) < (snap_radius * snap_radius)) {
134  // check if we're deleting the first point
135  if ((index == 0) || (index == lastIndex)) {
136  // remove both geometry point
137  shape.erase(shape.begin() + lastIndex);
138  shape.erase(shape.begin());
139  // close shape
140  shape.closePolygon();
141  } else {
142  // remove geometry point
143  shape.erase(shape.begin() + index);
144  }
145  // commit new shape
146  undoList->begin(GUIIcon::TAZ, "remove geometry point of " + getTagStr());
147  undoList->changeAttribute(new GNEChange_Attribute(this, SUMO_ATTR_SHAPE, toString(shape)));
148  undoList->end();
149  }
150  }
151 }
152 
153 
154 const PositionVector&
156  return myShape;
157 }
158 
159 
160 void
162  // first open TAZ tag
163  device.openTag(SUMO_TAG_TAZ);
164  // write TAZ attributes
165  device.writeAttr(SUMO_ATTR_ID, getID());
167  if (myTAZCenter != myShape.getCentroid()) {
169  }
170  if (myFill) {
171  device.writeAttr(SUMO_ATTR_FILL, true);
172  }
173  if (getShapeName().size() > 0) {
175  }
177  // sort all Source/Sinks by ID
178  std::map<std::pair<std::string, SumoXMLTag>, GNETAZElement*> sortedSourceSinks;
179  for (const auto& sourceSink : getChildTAZElements()) {
180  sortedSourceSinks[std::make_pair(sourceSink->getAttribute(SUMO_ATTR_EDGE), sourceSink->getTagProperty().getTag())] = sourceSink;
181  }
182  // write all TAZ Source/sinks
183  for (const auto& sortedSourceSink : sortedSourceSinks) {
184  sortedSourceSink.second->writeTAZElement(device);
185  }
186  // write params
188  // close TAZ tag
189  device.closeTag();
190 }
191 
192 
193 void
195  // just update geometry
197  // update geometry of TAZRelDatas
198  for (const auto& TAZRelData : getChildGenericDatas()) {
199  TAZRelData->updateGeometry();
200  }
201 }
202 
203 
204 Position
206  return myShape.getCentroid();
207 }
208 
209 
210 double
212  return s.polySize.getExaggeration(s, this);
213 }
214 
215 
216 Boundary
218  // Return Boundary depending if myMovingGeometryBoundary is initialised (important for move geometry)
221  } else if (myShape.size() > 0) {
223  // add center
224  b.add(myTAZCenter);
225  b.grow(40);
226  return b;
227  } else {
228  return Boundary(-0.1, -0.1, 0.1, 0.1);
229  }
230 }
231 
232 
233 std::string
235  return myNet->getMicrosimID();
236 }
237 
238 
241  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
242  buildPopupHeader(ret, app);
245  // build selection and show parameters menu
248  // create a extra FXMenuCommand if mouse is over a vertex
249  const int index = getVertexIndex(myNet->getViewNet()->getPositionInformation(), false);
250  if (index != -1) {
251  // check if we're in network mode
253  GUIDesigns::buildFXMenuCommand(ret, "Set custom Geometry Point", nullptr, &parent, MID_GNE_CUSTOM_GEOMETRYPOINT);
254  }
255  }
256  return ret;
257 }
258 
259 
260 void
262  // check if boundary has to be drawn
263  if (s.drawBoundaries) {
265  }
266  // first check if poly can be drawn
267  if (myNet->getViewNet()->getDemandViewOptions().showShapes() && GUIPolygon::checkDraw(s, this, this)) {
268  // check if draw start und end
269  const bool drawExtremeSymbols = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
271  // Obtain constants
272  const double TAZExaggeration = getExaggeration(s);
273  const Position mousePosition = myNet->getViewNet()->getPositionInformation();
274  // get colors
276  const RGBColor invertedColor = color.invertedColor();
277  const RGBColor darkerColor = color.changedBrightness(-32);
278  // push name (needed for getGUIGlObjectsUnderCursor(...)
280  // push layer matrix
282  // translate to front
284  // check if we're drawing a polygon or a polyline
286  if (s.drawForPositionSelection) {
287  // check if mouse is within geometry
288  if (myTAZGeometry.getShape().around(mousePosition)) {
289  // push matrix
291  // move to mouse position
292  glTranslated(mousePosition.x(), mousePosition.y(), 0);
293  // set color
294  GLHelper::setColor(color);
295  // draw circle
297  // pop matrix
299  }
300  } else {
301  // draw inner polygon
302  const int alphaOverride = myNet->getViewNet()->getDataViewOptions().TAZDrawFill() ? 128 : -1;
303  GUIPolygon::drawInnerPolygon(s, this, this, myTAZGeometry.getShape(), true, 0, drawUsingSelectColor(), alphaOverride);
304  }
305  } else {
306  // push matrix
308  // set color
309  GLHelper::setColor(color);
310  // draw geometry (polyline)
312  // pop matrix
314  }
315  // draw contour if shape isn't blocked
317  // push contour matrix
319  // translate to front
320  glTranslated(0, 0, 0.1);
321  // set color
322  GLHelper::setColor(darkerColor);
323  // draw polygon contour
325  // pop contour matrix
327  // draw shape points only in Network supemode
329  // check move mode flag
331  // draw geometry points
333  s.neteditSizeSettings.polygonGeometryPointRadius * (moveMode ? 1 : 0.5), TAZExaggeration,
334  myNet->getViewNet()->getNetworkViewOptions().editingElevation(), drawExtremeSymbols);
335  // draw moving hint points
339  }
340  }
341  }
342  // draw center
343  const double centerRadius = s.neteditSizeSettings.polygonGeometryPointRadius * TAZExaggeration;
344  // push center matrix
346  // move to vertex
347  glTranslated(myTAZCenter.x(), myTAZCenter.y(), 0.3);
348  // set color
349  GLHelper::setColor(darkerColor);
350  // draw circle
352  // move to front
353  glTranslated(0, 0, 0.1);
354  // set color
355  GLHelper::setColor(color);
356  // draw circle
357  GLHelper::drawFilledCircle(centerRadius * 0.8, s.getCircleResolution());
358  // pop center matrix
360  // draw dotted contours
361  drawDottedContours(s, TAZExaggeration);
362  // pop layer matrix
364  // pop name
366  // draw lock icon
368  // get name position
369  const Position& namePos = myTAZGeometry.getShape().getPolygonCenter();
370  // draw name
372  // check if draw poly type
373  if (s.polyType.show(this)) {
374  const Position p = namePos + Position(0, -0.6 * s.polyType.size / s.scale);
376  }
377  }
378 }
379 
380 
381 std::string
383  switch (key) {
384  case SUMO_ATTR_ID:
385  return getID();
386  case SUMO_ATTR_SHAPE:
387  return toString(myShape);
388  case SUMO_ATTR_CENTER:
389  if (myTAZCenter == myShape.getCentroid()) {
390  return "";
391  } else {
392  return toString(myTAZCenter);
393  }
394  case SUMO_ATTR_COLOR:
395  return toString(getShapeColor());
396  case SUMO_ATTR_NAME:
397  return getShapeName();
398  case SUMO_ATTR_FILL:
399  return toString(myFill);
400  case SUMO_ATTR_EDGES: {
401  std::vector<std::string> edgeIDs;
402  for (const auto& TAZChild : getChildAdditionals()) {
403  edgeIDs.push_back(TAZChild->getAttribute(SUMO_ATTR_EDGE));
404  }
405  return toString(edgeIDs);
406  }
407  case GNE_ATTR_SELECTED:
409  case GNE_ATTR_PARAMETERS:
411  case GNE_ATTR_MIN_SOURCE:
413  return "undefined";
414  } else {
415  return toString(myMinWeightSource);
416  }
417  case GNE_ATTR_MIN_SINK:
419  return "undefined";
420  } else {
421  return toString(myMinWeightSink);
422  }
423  case GNE_ATTR_MAX_SOURCE:
425  return "undefined";
426  } else {
427  return toString(myMaxWeightSource);
428  }
429  case GNE_ATTR_MAX_SINK:
431  return "undefined";
432  } else {
433  return toString(myMaxWeightSink);
434  }
437  return "undefined";
438  } else {
440  }
443  return "undefined";
444  } else {
446  }
447  default:
448  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
449  }
450 }
451 
452 
453 double
455  switch (key) {
456  case GNE_ATTR_MIN_SOURCE:
457  return myMinWeightSource;
458  case GNE_ATTR_MIN_SINK:
459  return myMinWeightSink;
460  case GNE_ATTR_MAX_SOURCE:
461  return myMaxWeightSource;
462  case GNE_ATTR_MAX_SINK:
463  return myMaxWeightSink;
465  return myAverageWeightSource;
467  return myAverageWeightSink;
468  default:
469  throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
470  }
471 }
472 
473 
474 Position
476  switch (key) {
477  case SUMO_ATTR_CENTER:
478  return myTAZCenter;
479  default:
480  throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
481  }
482 }
483 
484 
485 void
486 GNETAZ::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
487  if (value == getAttribute(key)) {
488  return; //avoid needless changes, later logic relies on the fact that attributes have changed
489  }
490  switch (key) {
491  case SUMO_ATTR_ID:
492  case SUMO_ATTR_SHAPE:
493  case SUMO_ATTR_CENTER:
494  case SUMO_ATTR_COLOR:
495  case SUMO_ATTR_NAME:
496  case SUMO_ATTR_FILL:
497  case SUMO_ATTR_EDGES:
498  case GNE_ATTR_SELECTED:
499  case GNE_ATTR_PARAMETERS:
500  undoList->changeAttribute(new GNEChange_Attribute(this, key, value));
501  break;
502  default:
503  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
504  }
505 }
506 
507 
508 bool
509 GNETAZ::isValid(SumoXMLAttr key, const std::string& value) {
510  switch (key) {
511  case SUMO_ATTR_ID:
513  (myNet->getAttributeCarriers()->retrieveTAZElement(SUMO_TAG_TAZ, value, false) == nullptr) &&
514  (myNet->getAttributeCarriers()->retrieveShape(SUMO_TAG_POLY, value, false) == nullptr);
515  case SUMO_ATTR_SHAPE:
516  if (value.empty()) {
517  return false;
518  } else {
519  return canParse<PositionVector>(value);
520  }
521  case SUMO_ATTR_CENTER:
522  if (value.empty()) {
523  return true;
524  } else {
525  return canParse<Position>(value);
526  }
527  case SUMO_ATTR_COLOR:
528  return canParse<RGBColor>(value);
529  case SUMO_ATTR_NAME:
531  case SUMO_ATTR_FILL:
532  return canParse<bool>(value);
533  case SUMO_ATTR_EDGES:
534  if (value.empty()) {
535  return true;
536  } else {
538  }
539  case GNE_ATTR_SELECTED:
540  return canParse<bool>(value);
541  case GNE_ATTR_PARAMETERS:
542  return Parameterised::areParametersValid(value);
543  default:
544  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
545  }
546 }
547 
548 
549 bool
551  return true;
552 }
553 
554 
555 std::string
557  return getTagStr() + ":" + getID();
558 }
559 
560 
561 std::string
563  return getTagStr();
564 }
565 
566 
567 void
569  // reset all stadistic variables
576  // declare an extra variables for saving number of children
577  int numberOfSources = 0;
578  int numberOfSinks = 0;
579  // iterate over child additional
580  for (const auto& TAZChild : getChildTAZElements()) {
581  if (TAZChild->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) {
582  const double weight = TAZChild->getAttributeDouble(SUMO_ATTR_WEIGHT);
583  // check max Weight
584  if ((myMaxWeightSource == INVALID_DOUBLE) || (myMaxWeightSource < weight)) {
585  myMaxWeightSource = weight;
586  }
587  // check min Weight
588  if ((myMinWeightSource == INVALID_DOUBLE) || (weight < myMinWeightSource)) {
589  myMinWeightSource = weight;
590  }
591  // update Average
592  myAverageWeightSource += weight;
593  // update number of sources
594  numberOfSources++;
595  } else if (TAZChild->getTagProperty().getTag() == SUMO_TAG_TAZSINK) {
596  const double weight = TAZChild->getAttributeDouble(SUMO_ATTR_WEIGHT);
597  // check max Weight
598  if ((myMaxWeightSink == INVALID_DOUBLE) || myMaxWeightSink < weight) {
599  myMaxWeightSink = weight;
600  }
601  // check min Weight
602  if ((myMinWeightSink == INVALID_DOUBLE) || (weight < myMinWeightSink)) {
603  myMinWeightSink = weight;
604  }
605  // update Average
606  myAverageWeightSink += weight;
607  // update number of sinks
608  numberOfSinks++;
609  }
610  }
611  // calculate average
612  if (numberOfSources > 0) {
613  myAverageWeightSource /= numberOfSources;
614  }
615  if (numberOfSinks > 0) {
616  myAverageWeightSink /= numberOfSinks;
617  }
618 }
619 
620 // ===========================================================================
621 // private
622 // ===========================================================================
623 
624 void
625 GNETAZ::drawDottedContours(const GUIVisualizationSettings& s, const double TAZExaggeration) const {
626  // flag for draw fill
627  const bool drawFill = getFill() || myNet->getViewNet()->getDataViewOptions().TAZDrawFill() || myTAZGeometry.getShape().isClosed();
628  // dotted contour for inspect
630  // draw depending if is closed
631  if (drawFill) {
633  } else {
635  TAZExaggeration, 1, 1);
636  }
637  }
638  // dotted contour for front
639  if ((myNet->getViewNet()->getFrontAttributeCarrier() == this)) {
640  // draw depending if is closed
641  if (drawFill) {
643  } else {
645  TAZExaggeration, 1, 1);
646  }
647  }
648  // dotted contour for first TAZ
649  if ((myNet->getViewNet()->getViewParent()->getTAZRelDataFrame()->getFirstTAZ() == this)) {
650  // draw depending if is closed
651  if (drawFill) {
653  } else {
655  TAZExaggeration, 1, 1);
656  }
657  }
658  // dotted contour for second TAZ
659  if ((myNet->getViewNet()->getViewParent()->getTAZRelDataFrame()->getSecondTAZ() == this)) {
660  // draw depending if is closed
661  if (drawFill) {
663  } else {
665  TAZExaggeration, 1, 1);
666  }
667  }
668 }
669 
670 
671 void
672 GNETAZ::setAttribute(SumoXMLAttr key, const std::string& value) {
673  switch (key) {
674  case SUMO_ATTR_ID:
675  // update microsimID
676  setMicrosimID(value);
677  break;
678  case SUMO_ATTR_SHAPE: {
679  const bool updateCenter = (myTAZCenter == myShape.getCentroid());
680  // remove TAZ and TAZRelDatas
681  if (getID().size() > 0) {
683  for (const auto& TAZRelData : getChildGenericDatas()) {
684  myNet->removeGLObjectFromGrid(TAZRelData);
685  }
686  }
687  myShape = parse<PositionVector>(value);
688  // always close shape
689  if ((myShape.size() > 1) && (myShape.front() != myShape.back())) {
690  myShape.push_back(myShape.front());
691  }
692  // update center
693  if (myShape.size() == 0) {
694  myTAZCenter = Position(0, 0, 0);
695  } else if (updateCenter) {
697  }
698  // add TAZ and TAZRelDatas
699  if (getID().size() > 0) {
700  myNet->addGLObjectIntoGrid(this);
701  for (const auto& TAZRelData : getChildGenericDatas()) {
702  TAZRelData->updateGeometry();
703  myNet->addGLObjectIntoGrid(TAZRelData);
704  }
705  }
706  break;
707  }
708  case SUMO_ATTR_CENTER:
709  // remove TAZ and TAZRelDatas
710  if (getID().size() > 0) {
712  for (const auto& TAZRelData : getChildGenericDatas()) {
713  myNet->removeGLObjectFromGrid(TAZRelData);
714  }
715  }
716  if (value.empty()) {
718  } else {
719  myTAZCenter = parse<Position>(value);
720  }
721  // add TAZ and TAZRelDatas
722  if (getID().size() > 0) {
723  myNet->addGLObjectIntoGrid(this);
724  for (const auto& TAZRelData : getChildGenericDatas()) {
725  TAZRelData->updateGeometry();
726  myNet->addGLObjectIntoGrid(TAZRelData);
727  }
728  }
729  break;
730  case SUMO_ATTR_COLOR:
731  setShapeColor(parse<RGBColor>(value));
732  break;
733  case SUMO_ATTR_NAME:
734  setShapeName(value);
735  break;
736  case SUMO_ATTR_FILL:
737  myFill = parse<bool>(value);
738  break;
739  case SUMO_ATTR_EDGES:
740  break;
741  case GNE_ATTR_SELECTED:
742  if (parse<bool>(value)) {
744  } else {
746  }
747  break;
748  case GNE_ATTR_PARAMETERS:
750  break;
751  default:
752  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
753  }
754 }
755 
756 
757 void
760  // update new center
761  myTAZCenter = moveResult.shapeToUpdate.front();
763  // update new shape and center
765  myShape = moveResult.shapeToUpdate;
766  // update geometry
768  } else {
769  // get lastIndex
770  const int lastIndex = (int)moveResult.shapeToUpdate.size() - 1;
771  // update new shape
772  myShape = moveResult.shapeToUpdate;
773  // adjust first and last position
774  if (moveResult.geometryPointsToMove.front() == 0) {
775  myShape[lastIndex] = moveResult.shapeToUpdate[0];
776  } else if (moveResult.geometryPointsToMove.front() == lastIndex) {
777  myShape[0] = moveResult.shapeToUpdate[lastIndex];
778  }
780  // update geometry
782  }
783 }
784 
785 
786 void
787 GNETAZ::commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) {
789  // commit center
790  undoList->begin(GUIIcon::TAZ, "moving " + toString(SUMO_ATTR_CENTER) + " of " + getTagStr());
791  undoList->changeAttribute(new GNEChange_Attribute(this, SUMO_ATTR_CENTER, toString(moveResult.shapeToUpdate.front())));
792  undoList->end();
794  // calculate offset between old and new shape
795  Position newCenter = myTAZCenter;
796  newCenter.add(moveResult.shapeToUpdate.getCentroid() - myShape.getCentroid());
797  // commit new shape and center
798  undoList->begin(GUIIcon::TAZ, "moving " + toString(SUMO_ATTR_SHAPE) + " of " + getTagStr());
799  undoList->changeAttribute(new GNEChange_Attribute(this, SUMO_ATTR_CENTER, toString(newCenter)));
800  undoList->changeAttribute(new GNEChange_Attribute(this, SUMO_ATTR_SHAPE, toString(moveResult.shapeToUpdate)));
801  undoList->end();
802  } else {
803  // get lastIndex
804  const int lastIndex = (int)moveResult.shapeToUpdate.size() - 1;
805  // close shapeToUpdate
806  auto closedShape = moveResult.shapeToUpdate;
807  // adjust first and last position
808  if (moveResult.geometryPointsToMove.front() == 0) {
809  closedShape[lastIndex] = moveResult.shapeToUpdate[0];
810  } else if (moveResult.geometryPointsToMove.front() == lastIndex) {
811  closedShape[0] = moveResult.shapeToUpdate[lastIndex];
812  }
813  // commit new shape
814  undoList->begin(GUIIcon::TAZ, "moving " + toString(SUMO_ATTR_SHAPE) + " of " + getTagStr());
815  undoList->changeAttribute(new GNEChange_Attribute(this, SUMO_ATTR_SHAPE, toString(closedShape)));
816  undoList->end();
817  }
818 }
819 
820 /****************************************************************************/
@ NETWORK_MOVE
mode for moving network elements
@ MID_GNE_CUSTOM_GEOMETRYPOINT
set custom geometry point
Definition: GUIAppEnum.h:875
@ GLO_TAZ
Traffic Assignment Zones (TAZs)
@ SUMO_TAG_TAZ
a traffic assignment zone
@ SUMO_TAG_TAZSINK
a sink within a district (connection road)
@ SUMO_TAG_POLY
begin/end of the description of a polygon
@ 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
Definition: StdDefs.h:63
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:77
bool isInitialised() const
check if Boundary is Initialised
Definition: Boundary.cpp:215
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:299
static void drawBoundary(const Boundary &b)
Draw a boundary (used for debugging)
Definition: GLHelper.cpp:801
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:507
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:431
static void pushName(unsigned int name)
push Name
Definition: GLHelper.cpp:132
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:123
static void popName()
pop Name
Definition: GLHelper.cpp:141
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:114
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:640
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
friend class GNEChange_Attribute
declare friend class
const std::string & getTagStr() const
get tag assigned to this object in string format
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 std::vector< GNETAZElement * > & getChildTAZElements() const
get child TAZElements
const std::vector< GNEAdditional * > & getChildAdditionals() const
return child additionals
const std::vector< GNEGenericData * > & getChildGenericDatas() const
return child generic data elements
GNEMoveOperation * calculateMoveShapeOperation(const PositionVector originalShape, const Position mousePosition, const double snapRadius, const bool onlyContour)
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)
GNETAZElement * retrieveTAZElement(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named TAZElement.
GNEShape * retrieveShape(SumoXMLTag, const std::string &id, bool hardFail=true) const
Returns the named shape.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
void addGLObjectIntoGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition: GNENet.cpp:1210
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition: GNENet.cpp:1222
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:125
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1964
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNETAZElement.h:45
virtual void writeTAZElement(OutputDevice &device) const =0
writte TAZElement element into a xml file
Position getPositionInView() const
Returns position of additional in view.
Definition: GNETAZ.cpp:205
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNETAZ.cpp:550
double myMaxWeightSink
Max Sink weight.
Definition: GNETAZ.h:196
const PositionVector & getTAZElementShape() const
get TAZ Shape
Definition: GNETAZ.cpp:155
Position myTAZCenter
TAZ center.
Definition: GNETAZ.h:177
static const double myHintSize
hint size of vertex
Definition: GNETAZ.h:181
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNETAZ.cpp:261
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNETAZ.cpp:556
const std::string & getID() const
needed to avoid diamond Problem between GUIPolygon and GNETAZElement
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration asociated with this GLObject
Definition: GNETAZ.cpp:211
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNETAZ.cpp:217
Position getAttributePosition(SumoXMLAttr key) const
Definition: GNETAZ.cpp:475
void drawDottedContours(const GUIVisualizationSettings &s, const double TAZExaggeration) const
draw dotted contours
Definition: GNETAZ.cpp:625
~GNETAZ()
GNETAZ Destructor.
Definition: GNETAZ.cpp:83
double myAverageWeightSource
Average source weight.
Definition: GNETAZ.h:193
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition: GNETAZ.cpp:758
void updateTAZStadistic()
update TAZ Stadistic
Definition: GNETAZ.cpp:568
void writeTAZElement(OutputDevice &device) const
writte TAZElement element into a xml file
Definition: GNETAZ.cpp:161
void updateGeometry()
update pre-computed geometry information
Definition: GNETAZ.cpp:194
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNETAZ.cpp:509
double myMinWeightSink
Min Sink weight.
Definition: GNETAZ.h:199
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNETAZ.cpp:87
double myAverageWeightSink
Average Sink weight.
Definition: GNETAZ.h:202
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNETAZ.cpp:562
std::string getParentName() const
Returns the name of the parent object (if any)
Definition: GNETAZ.cpp:234
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
Definition: GNETAZ.cpp:121
std::string getAttribute(SumoXMLAttr key) const
Definition: GNETAZ.cpp:382
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNETAZ.cpp:240
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform TAZElement changes
Definition: GNETAZ.cpp:486
GUIGeometry myTAZGeometry
geometry for lenghts/rotations
Definition: GNETAZ.h:174
static const double myHintSizeSquared
squaredhint size of vertex
Definition: GNETAZ.h:184
double myMinWeightSource
Min source weight.
Definition: GNETAZ.h:190
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:105
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition: GNETAZ.cpp:787
double getAttributeDouble(SumoXMLAttr key) const
Definition: GNETAZ.cpp:454
Boundary myMovingGeometryBoundary
boundary used during moving of elements
Definition: GNETAZ.h:171
double myMaxWeightSource
Max source weight.
Definition: GNETAZ.h:187
GNETAZ(GNENet *net)
@default GNETAZ Constructor
Definition: GNETAZ.cpp:49
GNETAZElement * getSecondTAZ() const
get first selected TAZ Element
GNETAZElement * getFirstTAZ() const
get first selected TAZ 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...
void changeAttribute(GNEChange_Attribute *change)
special method for change attributes, avoid empty changes, always execute
bool isObjectLocked(GUIGlObjectType objectType, const bool selected) const
check if given GLObject is locked for inspect, select, delete and move
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
Definition: GNEViewNet.cpp:537
const GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:513
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
Definition: GNEViewNet.cpp:525
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, double typeOrLayer, const double extraOffset=0)
draw front attributeCarrier
GNEViewParent * getViewParent() const
get the net object
GNEViewNetHelper::LockManager & getLockManager()
get lock manager
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
Definition: GNEViewNet.cpp:432
bool isAttributeCarrierInspected(const GNEAttributeCarrier *AC) const
check if attribute carrier is being inspected
const GNEViewNetHelper::DemandViewOptions & getDemandViewOptions() const
get demand view options
Definition: GNEViewNet.cpp:531
GNETAZRelDataFrame * getTAZRelDataFrame() const
get frame for DATA_TAZRELDATA
GNEMoveFrame * getMoveFrame() const
get frame for move elements
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel)
build menu command
Definition: GUIDesigns.cpp:42
static void drawDottedContourShape(const DottedContourType type, const GUIVisualizationSettings &s, const PositionVector &shape, const double width, const double exaggeration, const bool drawFirstExtrem, const bool drawLastExtrem, const double lineWidth=-1)
draw dotted contour for the given shape (used by additionals)
static void drawDottedContourClosedShape(const DottedContourType type, const GUIVisualizationSettings &s, const PositionVector &shape, const double exaggeration, const double lineWidth=-1)
draw dotted contour for the given closed shape (used by Juctions, shapes and TAZs)
The popup menu of a globject.
static void drawGeometryPoints(const GUIVisualizationSettings &s, const Position &mousePos, const PositionVector &shape, const RGBColor &geometryPointColor, const RGBColor &textColor, const double radius, const double exaggeration, const bool editingElevation, const bool drawExtremeSymbols)
draw geometry points
static void drawGeometry(const GUIVisualizationSettings &s, const Position &mousePos, 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:58
static void drawMovingHint(const GUIVisualizationSettings &s, const Position &mousePos, const PositionVector &shape, const RGBColor &hintColor, const double radius, const double exaggeration)
draw moving hint
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
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.
GUIGlID getGlID() const
Returns the numerical id of the object.
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
static bool checkDraw(const GUIVisualizationSettings &s, const SUMOPolygon *polygon, const GUIGlObject *o)
check if Polygon can be drawn
Definition: GUIPolygon.cpp:280
static void drawInnerPolygon(const GUIVisualizationSettings &s, const SUMOPolygon *polygon, const GUIGlObject *o, const PositionVector shape, const bool drawFill, double layer, bool disableSelectionColor, int alphaOverride=-1)
draw inner Polygon (before pushName() )
Definition: GUIPolygon.cpp:302
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.
GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings
Position getPositionInformation() const
Returns the cursor's x/y position within the network.
Stores the information about how to visualize structures.
bool drawBoundaries
enable or disable draw boundaries
bool drawForPositionSelection
whether drawing is performed for the purpose of selecting objects with a single click
bool drawMovingGeometryPoint(const double exaggeration, const double radius) const
check if moving geometry point can be draw
GUIVisualizationColorSettings colorSettings
color settings
double scale
information about a lane's width (temporary, used for a single view)
GUIVisualizationTextSettings polyName
GUIVisualizationSizeSettings polySize
int getCircleResolution() const
function to calculate circle resolution for all circles drawn in drawGL(...) functions
GUIVisualizationTextSettings polyType
GUIVisualizationNeteditSizeSettings neteditSizeSettings
netedit size settings
double angle
The current view rotation angle.
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:248
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|....
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"
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:257
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:125
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)
bool isClosed() const
check if PositionVector is closed
bool around(const Position &p, double offset=0) const
Returns the information whether the position vector describes a polygon lying around the given point.
RGBColor invertedColor() const
obtain inverted of current RGBColor
Definition: RGBColor.cpp:180
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:197
PositionVector myShape
The positions of the polygon.
Definition: SUMOPolygon.h:121
bool myFill
Information whether the polygon has to be filled.
Definition: SUMOPolygon.h:127
bool getFill() const
Returns whether the polygon is filled.
Definition: SUMOPolygon.cpp:58
static bool isValidAdditionalID(const std::string &value)
whether the given string is a valid id for an additional object
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:109
static const bool DEFAULT_RELATIVEPATH
Definition: Shape.h:47
const RGBColor & getShapeColor() const
Returns the color of the Shape.
Definition: Shape.h:83
static const double DEFAULT_LAYER
Definition: Shape.h:42
void setShapeName(const std::string &name)
Sets a new shape name.
Definition: Shape.h:168
static const std::string DEFAULT_IMG_FILE
Definition: Shape.h:46
static const double DEFAULT_ANGLE
Definition: Shape.h:45
void setShapeColor(const RGBColor &col)
Sets a new color.
Definition: Shape.h:135
double getShapeLayer() const
Returns the layer of the Shape.
Definition: Shape.h:90
const std::string & getShapeType() const
Returns the (abstract) type of the Shape.
Definition: Shape.h:76
bool TAZDrawFill() const
check if toogle TAZ draw fill checkbox is enabled
bool showShapes() const
check if shapes has to be drawn
NetworkEditMode networkEditMode
the current Network edit mode
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
static void drawLockIcon(const GNEAttributeCarrier *AC, GUIGlObjectType type, const Position viewPosition, 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
RGBColor selectionColor
basic selection color
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