Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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-2023 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>
36
37#include "GNETAZ.h"
38
39
40// ===========================================================================
41// static members
42// ===========================================================================
43const double GNETAZ::myHintSize = 0.8;
44const double GNETAZ::myHintSizeSquared = 0.64;
45
46
47// ===========================================================================
48// member method definitions
49// ===========================================================================
50
52 GNEAdditional("", net, GLO_TAZ, SUMO_TAG_TAZ, GUIIconSubSys::getIcon(GUIIcon::TAZ), "", {}, {}, {}, {}, {}, {}),
54 myMaxWeightSource(0),
55 myMinWeightSource(0),
56 myAverageWeightSource(0),
57 myMaxWeightSink(0),
58 myMinWeightSink(0),
59myAverageWeightSink(0) {
60 // reset default values
61 resetDefaultValues();
62}
63
64
65GNETAZ::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 Parameterised::Map& parameters) :
67 GNEAdditional(id, net, GLO_TAZ, SUMO_TAG_TAZ, GUIIconSubSys::getIcon(GUIIcon::TAZ), "", {}, {}, {}, {}, {}, {}),
69myTAZCenter(center),
70myMaxWeightSource(0),
71myMinWeightSource(0),
72myAverageWeightSource(0),
73myMaxWeightSink(0),
74myMinWeightSink(0),
75myAverageWeightSink(0) {
76 // update centering boundary without updating grid
77 updateCenteringBoundary(false);
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
104int
105GNETAZ::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
120void
121GNETAZ::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
154void
156 // first open TAZ tag
157 device.openTag(SUMO_TAG_TAZ);
158 // write TAZ attributes
159 device.writeAttr(SUMO_ATTR_ID, getID());
163 }
164 if (myFill) {
165 device.writeAttr(SUMO_ATTR_FILL, true);
166 }
167 if (getShapeName().size() > 0) {
169 }
171 // sort all Source/Sinks by ID
172 std::map<std::pair<std::string, SumoXMLTag>, GNEAdditional*> sortedSourceSinks;
173 for (const auto& sourceSink : getChildAdditionals()) {
174 sortedSourceSinks[std::make_pair(sourceSink->getAttribute(SUMO_ATTR_EDGE), sourceSink->getTagProperty().getTag())] = sourceSink;
175 }
176 // write all TAZ Source/sinks
177 for (const auto& sortedSourceSink : sortedSourceSinks) {
178 sortedSourceSink.second->writeAdditional(device);
179 }
180 // write params
181 writeParams(device);
182 // close TAZ tag
183 device.closeTag();
184}
185
186
187bool
189 return true;
190}
191
192
193std::string
195 return "";
196}
197
198
199void
201 // nothing to fix
202}
203
204
205void
207 // just update geometry
209 // update geometry of TAZRelDatas
210 for (const auto& TAZRelData : getChildGenericDatas()) {
211 TAZRelData->updateGeometry();
212 }
213 myTesselation.clear();
214}
215
216
219 return myShape.getCentroid();
220}
221
222
223double
225 return s.polySize.getExaggeration(s, this);
226}
227
228
229void
230GNETAZ::updateCenteringBoundary(const bool updateGrid) {
231 // Remove object from net
232 if (updateGrid) {
234 for (const auto& TAZRelData : getChildGenericDatas()) {
235 myNet->removeGLObjectFromGrid(TAZRelData);
236 }
237 }
238 // use shape as boundary
240 // add center
243 }
244 // grow boundary
246 // add object into net
247 if (updateGrid) {
249 for (const auto& TAZRelData : getChildGenericDatas()) {
250 TAZRelData->updateGeometry();
251 myNet->addGLObjectIntoGrid(TAZRelData);
252 }
253 }
254}
255
256
257void
258GNETAZ::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
259 // Nothing to split
260}
261
262
263std::string
265 return myNet->getMicrosimID();
266}
267
268
271 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
272 buildPopupHeader(ret, app);
275 // build selection and show parameters menu
278 // create a extra FXMenuCommand if mouse is over a vertex
279 const int index = getVertexIndex(myNet->getViewNet()->getPositionInformation(), false);
280 if (index != -1) {
281 // check if we're in network mode
283 GUIDesigns::buildFXMenuCommand(ret, TL("Set custom Geometry Point"), nullptr, &parent, MID_GNE_CUSTOM_GEOMETRYPOINT);
284 }
285 }
286 return ret;
287}
288
289
290void
292 // check if boundary has to be drawn
293 if (s.drawBoundaries) {
295 }
296 // first check if poly can be drawn
298 // check if draw start und end
299 const bool drawExtremeSymbols = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
301 // Obtain constants
302 const double TAZExaggeration = getExaggeration(s);
303 const Position mousePosition = myNet->getViewNet()->getPositionInformation();
304 const bool drawFill = (myNet->getViewNet()->getEditModes().isCurrentSupermodeData() && myNet->getViewNet()->getDataViewOptions().TAZDrawFill()) ? true : getFill();
305 // get colors
306 const RGBColor color = GUIPolygon::setColor(s, this, this, drawUsingSelectColor(), -1);
307 const RGBColor invertedColor = color.invertedColor();
308 const RGBColor darkerColor = color.changedBrightness(-32);
309 // avoid draw invisible elements
310 if (color.alpha() != 0) {
311 // push name (needed for getGUIGlObjectsUnderCursor(...)
313 // push layer matrix
315 // translate to front
317 // check if we're drawing a polygon or a polyline
320 // check if mouse is within geometry
321 if (myAdditionalGeometry.getShape().around(mousePosition)) {
322 // push matrix
324 // move to mouse position
325 glTranslated(mousePosition.x(), mousePosition.y(), 0);
326 // set color
327 GLHelper::setColor(color);
328 // draw circle
330 // pop matrix
332 }
333 } else {
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 }
338 } else {
339 // push matrix
341 // set color
342 GLHelper::setColor(color);
343 // draw geometry (polyline)
345 // pop matrix
347 }
348 // draw contour if shape isn't blocked
350 // push contour matrix
352 // translate to front
353 glTranslated(0, 0, 0.1);
354 // set color
355 GLHelper::setColor(darkerColor);
356 // draw polygon contour
358 // pop contour matrix
360 // draw shape points only in Network supemode
362 // check move mode flag
364 // draw geometry points
366 s.neteditSizeSettings.polygonGeometryPointRadius * (moveMode ? 1 : 0.5), TAZExaggeration,
367 myNet->getViewNet()->getNetworkViewOptions().editingElevation(), drawExtremeSymbols);
368 // draw moving hint points
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
385 // move to front
386 glTranslated(0, 0, 0.1);
387 // set color
388 GLHelper::setColor(color);
389 // draw circle
390 GLHelper::drawFilledCircle(centerRadius * 0.8, s.getCircleResolution());
391 // pop center matrix
393 // pop layer matrix
395 // pop name
397 // draw lock icon
399 }
400 // draw name
402 // check if mouse is over element
404 // draw dotted contours
405 drawDottedContours(s, TAZExaggeration);
406 // check if draw poly type
407 if (s.polyType.show(this)) {
410 }
411 // draw child demand elements
412 for (const auto& demandElement : getChildDemandElements()) {
413 demandElement->drawGL(s);
414 }
415 }
416}
417
418
419std::string
421 switch (key) {
422 case SUMO_ATTR_ID:
423 return getMicrosimID();
424 case SUMO_ATTR_SHAPE:
425 return toString(myShape);
426 case SUMO_ATTR_CENTER:
428 return "";
429 } else {
430 return toString(myTAZCenter);
431 }
432 case SUMO_ATTR_COLOR:
433 return toString(getShapeColor());
434 case SUMO_ATTR_NAME:
435 return getShapeName();
436 case SUMO_ATTR_FILL:
437 return toString(myFill);
438 case SUMO_ATTR_EDGES: {
439 std::vector<std::string> edgeIDs;
440 for (const auto& TAZChild : getChildAdditionals()) {
441 edgeIDs.push_back(TAZChild->getAttribute(SUMO_ATTR_EDGE));
442 }
443 return toString(edgeIDs);
444 }
448 return getParametersStr();
451 return "undefined";
452 } else {
454 }
457 return "undefined";
458 } else {
460 }
463 return "undefined";
464 } else {
466 }
469 return "undefined";
470 } else {
472 }
475 return "undefined";
476 } else {
478 }
481 return "undefined";
482 } else {
484 }
485 default:
486 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
487 }
488}
489
490
491double
493 switch (key) {
495 return myMinWeightSource;
497 return myMinWeightSink;
499 return myMaxWeightSource;
501 return myMaxWeightSink;
505 return myAverageWeightSink;
506 default:
507 throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
508 }
509}
510
511
514 switch (key) {
515 case SUMO_ATTR_CENTER:
516 return myTAZCenter;
517 default:
518 throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
519 }
520}
521
522
525 return getParametersMap();
526}
527
528
529void
530GNETAZ::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
531 if (value == getAttribute(key)) {
532 return; //avoid needless changes, later logic relies on the fact that attributes have changed
533 }
534 switch (key) {
535 case SUMO_ATTR_ID:
536 case SUMO_ATTR_SHAPE:
537 case SUMO_ATTR_CENTER:
538 case SUMO_ATTR_COLOR:
539 case SUMO_ATTR_NAME:
540 case SUMO_ATTR_FILL:
541 case SUMO_ATTR_EDGES:
544 undoList->changeAttribute(new GNEChange_Attribute(this, key, value));
545 break;
546 default:
547 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
548 }
549}
550
551
552bool
553GNETAZ::isValid(SumoXMLAttr key, const std::string& value) {
554 switch (key) {
555 case SUMO_ATTR_ID:
557 (myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_TAZ, value, false) == nullptr) &&
558 (myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_POLY, value, false) == nullptr);
559 case SUMO_ATTR_SHAPE:
560 if (value.empty()) {
561 return false;
562 } else {
563 return canParse<PositionVector>(value);
564 }
565 case SUMO_ATTR_CENTER:
566 if (value.empty()) {
567 return true;
568 } else {
569 return canParse<Position>(value);
570 }
571 case SUMO_ATTR_COLOR:
572 return canParse<RGBColor>(value);
573 case SUMO_ATTR_NAME:
575 case SUMO_ATTR_FILL:
576 return canParse<bool>(value);
577 case SUMO_ATTR_EDGES:
578 if (value.empty()) {
579 return true;
580 } else {
582 }
584 return canParse<bool>(value);
586 return areParametersValid(value);
587 default:
588 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
589 }
590}
591
592
593std::string
595 return getTagStr() + ":" + getID();
596}
597
598
599std::string
601 return getTagStr();
602}
603
604
605void
607 // reset all stadistic variables
614 // declare an extra variables for saving number of children
615 int numberOfSources = 0;
616 int numberOfSinks = 0;
617 // iterate over child additional
618 for (const auto& TAZChild : getChildAdditionals()) {
619 if (TAZChild->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) {
620 const double weight = TAZChild->getAttributeDouble(SUMO_ATTR_WEIGHT);
621 // check max Weight
622 if ((myMaxWeightSource == INVALID_DOUBLE) || (myMaxWeightSource < weight)) {
623 myMaxWeightSource = weight;
624 }
625 // check min Weight
626 if ((myMinWeightSource == INVALID_DOUBLE) || (weight < myMinWeightSource)) {
627 myMinWeightSource = weight;
628 }
629 // update Average
630 myAverageWeightSource += weight;
631 // update number of sources
632 numberOfSources++;
633 } else if (TAZChild->getTagProperty().getTag() == SUMO_TAG_TAZSINK) {
634 const double weight = TAZChild->getAttributeDouble(SUMO_ATTR_WEIGHT);
635 // check max Weight
636 if ((myMaxWeightSink == INVALID_DOUBLE) || myMaxWeightSink < weight) {
637 myMaxWeightSink = weight;
638 }
639 // check min Weight
640 if ((myMinWeightSink == INVALID_DOUBLE) || (weight < myMinWeightSink)) {
641 myMinWeightSink = weight;
642 }
643 // update Average
644 myAverageWeightSink += weight;
645 // update number of sinks
646 numberOfSinks++;
647 }
648 }
649 // calculate average
650 if (numberOfSources > 0) {
651 myAverageWeightSource /= numberOfSources;
652 }
653 if (numberOfSinks > 0) {
654 myAverageWeightSink /= numberOfSinks;
655 }
656}
657
658// ===========================================================================
659// private
660// ===========================================================================
661
662void
663GNETAZ::drawDottedContours(const GUIVisualizationSettings& s, const double TAZExaggeration) const {
664 // get TAZRelDataFrame
665 const auto TAZRelDataFrame = myNet->getViewNet()->getViewParent()->getTAZRelDataFrame();
666 // dotted contour for inspect
669 }
670 // dotted contour for front
671 if (myNet->getViewNet()->getFrontAttributeCarrier() == this) {
673 }
674 // delete contour
675 if (myNet->getViewNet()->drawDeleteContour(this, this)) {
677 }
678 // select contour
679 if (myNet->getViewNet()->drawSelectContour(this, this)) {
681 }
682 // dotted contour for first TAZ
685 }
686 // dotted contour for second TAZ
689 }
690 // check if we're selecting TAZs
692 // check if we're creating a trip or flow over taz
694 if (templateAC && ((templateAC->getTagProperty().getTag() == GNE_TAG_TRIP_TAZS) || (templateAC->getTagProperty().getTag() == GNE_TAG_TRIP_TAZS))) {
696 }
697 }
698 // now check if mouse is over TAZ
699 if (TAZRelDataFrame->shown() && (gPostDrawing.markedTAZ == nullptr) && ((TAZRelDataFrame->getFirstTAZ() == nullptr) || (TAZRelDataFrame->getSecondTAZ() == nullptr))) {
700 // get dotted contour type
701 const auto dottedContourType = (TAZRelDataFrame->getFirstTAZ() == nullptr) ? GUIDottedGeometry::DottedContourType::FROMTAZ : GUIDottedGeometry::DottedContourType::TOTAZ;
702 // draw depending if is closed
706 }
707 } else {
708 // scale shape
709 auto scaledShape = myAdditionalGeometry.getShape();
710 scaledShape.scaleAbsolute(1);
711 // check if mouse is around scaled shape
712 if ((scaledShape.around(myNet->getViewNet()->getPositionInformation()) && (scaledShape.distance2D(myNet->getViewNet()->getPositionInformation()) <= 1.3)) ||
715 }
716 }
717 }
718}
719
720
721void
722GNETAZ::setAttribute(SumoXMLAttr key, const std::string& value) {
723 switch (key) {
724 case SUMO_ATTR_ID:
725 // update microsimID
726 setMicrosimID(value);
727 break;
728 case SUMO_ATTR_SHAPE: {
729 const bool updateCenter = (myTAZCenter == myShape.getCentroid());
730 // set new shape
731 myShape = parse<PositionVector>(value);
732 // always close shape
733 if ((myShape.size() > 1) && (myShape.front() != myShape.back())) {
734 myShape.push_back(myShape.front());
735 }
736 // update center
737 if (myShape.size() == 0) {
738 myTAZCenter = Position(0, 0, 0);
739 } else if (updateCenter) {
741 }
742 // update geometry
744 // update centering boundary
745 if (!isTemplate()) {
747 }
748 break;
749 }
750 case SUMO_ATTR_CENTER:
751 if (value.empty()) {
753 } else {
754 myTAZCenter = parse<Position>(value);
755 }
756 // update geometry
758 // update centering boundary
759 if (!isTemplate()) {
761 }
762 break;
763 case SUMO_ATTR_COLOR:
764 setShapeColor(parse<RGBColor>(value));
765 break;
766 case SUMO_ATTR_NAME:
767 setShapeName(value);
768 break;
769 case SUMO_ATTR_FILL:
770 myFill = parse<bool>(value);
771 break;
772 case SUMO_ATTR_EDGES:
773 break;
775 if (parse<bool>(value)) {
777 } else {
779 }
780 break;
782 setParametersStr(value);
783 break;
784 default:
785 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
786 }
787}
788
789
790void
793 // update new center
794 myTAZCenter = moveResult.shapeToUpdate.front();
796 // update new shape and center
798 myShape = moveResult.shapeToUpdate;
799 // update geometry
801 } else {
802 // get lastIndex
803 const int lastIndex = (int)moveResult.shapeToUpdate.size() - 1;
804 // update new shape
805 myShape = moveResult.shapeToUpdate;
806 // adjust first and last position
807 if (moveResult.geometryPointsToMove.front() == 0) {
808 myShape[lastIndex] = moveResult.shapeToUpdate[0];
809 } else if (moveResult.geometryPointsToMove.front() == lastIndex) {
810 myShape[0] = moveResult.shapeToUpdate[lastIndex];
811 }
813 // update geometry
815 }
816 myTesselation.clear();
817}
818
819
820void
821GNETAZ::commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) {
823 // commit center
824 undoList->begin(GUIIcon::TAZ, "moving " + toString(SUMO_ATTR_CENTER) + " of " + getTagStr());
825 undoList->changeAttribute(new GNEChange_Attribute(this, SUMO_ATTR_CENTER, toString(moveResult.shapeToUpdate.front())));
826 undoList->end();
828 // calculate offset between old and new shape
829 Position newCenter = myTAZCenter;
830 newCenter.add(moveResult.shapeToUpdate.getCentroid() - myShape.getCentroid());
831 // commit new shape and center
832 undoList->begin(GUIIcon::TAZ, "moving " + toString(SUMO_ATTR_SHAPE) + " of " + getTagStr());
833 undoList->changeAttribute(new GNEChange_Attribute(this, SUMO_ATTR_CENTER, toString(newCenter)));
835 undoList->end();
836 } else {
837 // get lastIndex
838 const int lastIndex = (int)moveResult.shapeToUpdate.size() - 1;
839 // close shapeToUpdate
840 auto closedShape = moveResult.shapeToUpdate;
841 // adjust first and last position
842 if (moveResult.geometryPointsToMove.front() == 0) {
843 closedShape[lastIndex] = moveResult.shapeToUpdate[0];
844 } else if (moveResult.geometryPointsToMove.front() == lastIndex) {
845 closedShape[0] = moveResult.shapeToUpdate[lastIndex];
846 }
847 // commit new shape
848 undoList->begin(GUIIcon::TAZ, "moving " + toString(SUMO_ATTR_SHAPE) + " of " + getTagStr());
849 undoList->changeAttribute(new GNEChange_Attribute(this, SUMO_ATTR_SHAPE, toString(closedShape)));
850 undoList->end();
851 }
852}
853
854/****************************************************************************/
@ NETWORK_MOVE
mode for moving network elements
@ DEMAND_VEHICLE
Mode for editing vehicles.
@ MID_GNE_CUSTOM_GEOMETRYPOINT
set custom geometry point
Definition GUIAppEnum.h:991
@ GLO_JUNCTION
a junction
@ GLO_TAZ
Traffic Assignment Zones (TAZs)
GUIPostDrawing gPostDrawing
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
#define TL(string)
Definition MsgHandler.h:287
@ GNE_TAG_TRIP_TAZS
a single trip definition that uses 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
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:300
static void drawBoundary(const Boundary &b)
Draw a boundary (used for debugging)
Definition GLHelper.cpp:897
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:583
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition GLHelper.cpp:498
static void pushName(unsigned int name)
push Name
Definition GLHelper.cpp:139
static void popMatrix()
pop matrix
Definition GLHelper.cpp:130
static void popName()
pop Name
Definition GLHelper.cpp:148
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:716
An Element which don't belong to GNENet but has influence in the simulation.
virtual void writeAdditional(OutputDevice &device) const =0
write additional element into a xml file
GUIGeometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
Boundary myAdditionalBoundary
Additional Boundary.
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
friend class GNEChange_Attribute
declare friend class
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
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 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)
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
void addGLObjectIntoGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1248
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1260
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:120
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2030
Position getPositionInView() const
Returns position of additional in view.
Definition GNETAZ.cpp:218
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
Definition GNETAZ.cpp:230
std::string getAdditionalProblem() const
return a string with the current additional problem (must be reimplemented in all detector children)
Definition GNETAZ.cpp:194
double myMaxWeightSink
Max Sink weight.
Definition GNETAZ.h:207
Position myTAZCenter
TAZ center.
Definition GNETAZ.h:188
static const double myHintSize
hint size of vertex
Definition GNETAZ.h:192
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition GNETAZ.cpp:291
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition GNETAZ.cpp:594
bool isAdditionalValid() const
check if current additional is valid to be writed into XML (must be reimplemented in all detector chi...
Definition GNETAZ.cpp:188
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
Definition GNETAZ.cpp:224
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Definition GNETAZ.cpp:258
Position getAttributePosition(SumoXMLAttr key) const
Definition GNETAZ.cpp:513
void drawDottedContours(const GUIVisualizationSettings &s, const double TAZExaggeration) const
draw dotted contours
Definition GNETAZ.cpp:663
~GNETAZ()
GNETAZ Destructor.
Definition GNETAZ.cpp:83
double myAverageWeightSource
Average source weight.
Definition GNETAZ.h:204
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition GNETAZ.cpp:791
void updateTAZStadistic()
update TAZ Stadistic
Definition GNETAZ.cpp:606
void updateGeometry()
update pre-computed geometry information
Definition GNETAZ.cpp:206
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their correspondent attribute are valids
Definition GNETAZ.cpp:553
double myMinWeightSink
Min Sink weight.
Definition GNETAZ.h:210
GNEMoveOperation * getMoveOperation()
get move operation
Definition GNETAZ.cpp:87
double myAverageWeightSink
Average Sink weight.
Definition GNETAZ.h:213
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition GNETAZ.cpp:600
std::string getParentName() const
Returns the name of the parent object.
Definition GNETAZ.cpp:264
void fixAdditionalProblem()
fix additional problem (must be reimplemented in all detector children)
Definition GNETAZ.cpp:200
void writeAdditional(OutputDevice &device) const
write additional element into a xml file
Definition GNETAZ.cpp:155
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:420
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition GNETAZ.cpp:270
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:530
static const double myHintSizeSquared
squaredhint size of vertex
Definition GNETAZ.h:195
double myMinWeightSource
Min source weight.
Definition GNETAZ.h:201
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:821
const Parameterised::Map & getACParametersMap() const
get parameters map
Definition GNETAZ.cpp:524
double getAttributeDouble(SumoXMLAttr key) const
Definition GNETAZ.cpp:492
double myMaxWeightSource
Max source weight.
Definition GNETAZ.h:198
GNETAZ(GNENet *net)
@default GNETAZ Constructor
Definition GNETAZ.cpp:51
GNEAdditional * getSecondTAZ() const
get first selected TAZ Element
GNEAdditional * getFirstTAZ() const
get first selected TAZ Element
GNEAttributeCarrier * getCurrentTemplateAC() const
get current templateAC
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
GNETagSelector * getVehicleTagSelector() const
get vehicle tag selector (needed for transform vehicles)
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
const GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
bool drawSelectContour(const GUIGlObject *GLObject, const GNEAttributeCarrier *AC) const
check if draw select contour
bool drawDeleteContour(const GUIGlObject *GLObject, const GNEAttributeCarrier *AC) const
check if draw delete contour
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
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.
bool isAttributeCarrierInspected(const GNEAttributeCarrier *AC) const
check if attribute carrier is being inspected
const GNEViewNetHelper::DemandViewOptions & getDemandViewOptions() const
get demand view options
GNETAZRelDataFrame * getTAZRelDataFrame() const
get frame for DATA_TAZRELDATA
GNEMoveFrame * getMoveFrame() const
get frame for move elements
GNEVehicleFrame * getVehicleFrame() const
get frame for DEMAND_VEHICLE
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel)
build menu command
static void drawDottedContourClosedShape(const GUIVisualizationSettings &s, const DottedContourType type, const PositionVector &shape, const double exaggeration, const double customWidth=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
static void drawMovingHint(const GUIVisualizationSettings &s, const Position &mousePos, const PositionVector &shape, const RGBColor &hintColor, const double radius, const double exaggeration)
draw moving hint
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.
bool mouseWithinGeometry(const Position center, const double radius) const
check if mouse is within elements geometry (for circles)
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 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() )
static bool checkDraw(const GUIVisualizationSettings &s, const SUMOPolygon *polygon, const GUIGlObject *o)
check if Polygon can be drawn
static RGBColor setColor(const GUIVisualizationSettings &s, const SUMOPolygon *polygon, const GUIGlObject *o, bool disableSelectionColor, int alphaOverride)
set color
const GUIGlObject * markedTAZ
marked TAZ (used in create TAZRel mode)
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 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
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.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
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
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:259
static const Position INVALID
used to indicate that a position is valid
Definition Position.h:300
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.
void scaleAbsolute(double offset)
enlarges/shrinks the polygon by an absolute offset based at the centroid
Position getPolygonCenter() const
Returns the arithmetic of all corner points.
void closePolygon()
ensures that the last position equals the first
double distance2D(const Position &p, bool perpendicular=false) const
closest 2D-distance to point p (or -1 if perpendicular is true and the point is beyond this vector)
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 around(const Position &p, double offset=0) const
Returns the information whether the position vector describes a polygon lying around the given point.
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition RGBColor.cpp:92
RGBColor invertedColor() const
obtain inverted of current RGBColor
Definition RGBColor.cpp:183
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.
bool myFill
Information whether the polygon has to be filled.
bool getFill() const
Returns whether the polygon is filled.
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:110
static const bool DEFAULT_RELATIVEPATH
Definition Shape.h:48
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
const std::string & getShapeType() const
Returns the (abstract) type of the Shape.
Definition Shape.h:77
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 RGBColor & getShapeColor() const
Returns the color of the Shape.
Definition Shape.h:84
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
DemandEditMode demandEditMode
the current Demand edit mode
NetworkEditMode networkEditMode
the current Network edit mode
bool isCurrentSupermodeDemand() const
@check if current supermode is Demand
bool isCurrentSupermodeData() const
@check if current supermode is Data
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
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