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>
35
36#include "GNETAZ.h"
37
38
39// ===========================================================================
40// static members
41// ===========================================================================
42const double GNETAZ::myHintSize = 0.8;
43const double GNETAZ::myHintSizeSquared = 0.64;
44
45
46// ===========================================================================
47// member method definitions
48// ===========================================================================
49
51 GNEAdditional("", net, GLO_TAZ, SUMO_TAG_TAZ, GUIIconSubSys::getIcon(GUIIcon::TAZ), "", {}, {}, {}, {}, {}, {}),
53 myMaxWeightSource(0),
54 myMinWeightSource(0),
55 myAverageWeightSource(0),
56 myMaxWeightSink(0),
57 myMinWeightSink(0),
58myAverageWeightSink(0) {
59 // reset default values
60 resetDefaultValues();
61}
62
63
64GNETAZ::GNETAZ(const std::string& id, GNENet* net, const PositionVector& shape, const Position& center, const bool fill,
65 const RGBColor& color, const std::string& name, const Parameterised::Map& parameters) :
66 GNEAdditional(id, net, GLO_TAZ, SUMO_TAG_TAZ, GUIIconSubSys::getIcon(GUIIcon::TAZ), "", {}, {}, {}, {}, {}, {}),
68myTAZCenter(center),
69myMaxWeightSource(0),
70myMinWeightSource(0),
71myAverageWeightSource(0),
72myMaxWeightSink(0),
73myMinWeightSink(0),
74myAverageWeightSink(0) {
75 // update centering boundary without updating grid
76 updateCenteringBoundary(false);
77 // update geometry
78 updateGeometry();
79}
80
81
83
84
87 // get snap radius
89 // check if we're moving center or shape
90 if (myTAZCenter.distanceSquaredTo2D(myNet->getViewNet()->getPositionInformation()) < (snap_radius * snap_radius)) {
91 // move entire shape
92 return new GNEMoveOperation(this, myTAZCenter);
94 // move entire shape
95 return new GNEMoveOperation(this, myShape);
96 } else {
97 // calculate move shape operation
99 }
100}
101
102
103int
104GNETAZ::getVertexIndex(Position pos, bool snapToGrid) {
105 // check if position has to be snapped to grid
106 if (snapToGrid) {
107 pos = myNet->getViewNet()->snapToActiveGrid(pos);
108 }
109 // first check if vertex already exists
110 for (const auto& shapePosition : myShape) {
111 if (shapePosition.distanceTo2D(pos) < myNet->getViewNet()->getVisualisationSettings().neteditSizeSettings.polygonGeometryPointRadius) {
112 return myShape.indexOfClosest(shapePosition);
113 }
114 }
115 return -1;
116}
117
118
119void
120GNETAZ::removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList) {
121 // get original shape
122 PositionVector shape = myShape;
123 // check shape size
124 if (shape.size() > 3) {
125 // obtain index
126 int index = shape.indexOfClosest(clickedPosition);
127 // get last index
128 const int lastIndex = ((int)shape.size() - 1);
129 // get snap radius
131 // check if we have to create a new index
132 if ((index != -1) && shape[index].distanceSquaredTo2D(clickedPosition) < (snap_radius * snap_radius)) {
133 // check if we're deleting the first point
134 if ((index == 0) || (index == lastIndex)) {
135 // remove both geometry point
136 shape.erase(shape.begin() + lastIndex);
137 shape.erase(shape.begin());
138 // close shape
139 shape.closePolygon();
140 } else {
141 // remove geometry point
142 shape.erase(shape.begin() + index);
143 }
144 // commit new shape
145 undoList->begin(GUIIcon::TAZ, "remove geometry point of " + getTagStr());
146 undoList->changeAttribute(new GNEChange_Attribute(this, SUMO_ATTR_SHAPE, toString(shape)));
147 undoList->end();
148 }
149 }
150}
151
152
153void
155 // first open TAZ tag
156 device.openTag(SUMO_TAG_TAZ);
157 // write TAZ attributes
158 device.writeAttr(SUMO_ATTR_ID, getID());
162 }
163 if (myFill) {
164 device.writeAttr(SUMO_ATTR_FILL, true);
165 }
166 if (getShapeName().size() > 0) {
168 }
170 // sort all Source/Sinks by ID
171 std::map<std::pair<std::string, SumoXMLTag>, GNEAdditional*> sortedSourceSinks;
172 for (const auto& sourceSink : getChildAdditionals()) {
173 sortedSourceSinks[std::make_pair(sourceSink->getAttribute(SUMO_ATTR_EDGE), sourceSink->getTagProperty().getTag())] = sourceSink;
174 }
175 // write all TAZ Source/sinks
176 for (const auto& sortedSourceSink : sortedSourceSinks) {
177 sortedSourceSink.second->writeAdditional(device);
178 }
179 // write params
180 writeParams(device);
181 // close TAZ tag
182 device.closeTag();
183}
184
185
186void
188 // just update geometry
190 // update geometry of TAZRelDatas
191 for (const auto& TAZRelData : getChildGenericDatas()) {
192 TAZRelData->updateGeometry();
193 }
194 myTesselation.clear();
195}
196
197
200 return myShape.getCentroid();
201}
202
203
204double
206 return s.polySize.getExaggeration(s, this);
207}
208
209
210void
211GNETAZ::updateCenteringBoundary(const bool updateGrid) {
212 // Remove object from net
213 if (updateGrid) {
215 for (const auto& TAZRelData : getChildGenericDatas()) {
216 myNet->removeGLObjectFromGrid(TAZRelData);
217 }
218 }
219 // use shape as boundary
221 // add center
223 // grow boundary
225 // add object into net
226 if (updateGrid) {
228 for (const auto& TAZRelData : getChildGenericDatas()) {
229 TAZRelData->updateGeometry();
230 myNet->addGLObjectIntoGrid(TAZRelData);
231 }
232 }
233}
234
235
236void
237GNETAZ::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
238 // Nothing to split
239}
240
241
242std::string
244 return myNet->getMicrosimID();
245}
246
247
250 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
251 buildPopupHeader(ret, app);
254 // build selection and show parameters menu
257 // create a extra FXMenuCommand if mouse is over a vertex
258 const int index = getVertexIndex(myNet->getViewNet()->getPositionInformation(), false);
259 if (index != -1) {
260 // check if we're in network mode
262 GUIDesigns::buildFXMenuCommand(ret, "Set custom Geometry Point", nullptr, &parent, MID_GNE_CUSTOM_GEOMETRYPOINT);
263 }
264 }
265 return ret;
266}
267
268
269void
271 // check if boundary has to be drawn
272 if (s.drawBoundaries) {
274 }
275 // first check if poly can be drawn
277 // check if draw start und end
278 const bool drawExtremeSymbols = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
280 // Obtain constants
281 const double TAZExaggeration = getExaggeration(s);
282 const Position mousePosition = myNet->getViewNet()->getPositionInformation();
283 const bool drawFill = (myNet->getViewNet()->getEditModes().isCurrentSupermodeData() && myNet->getViewNet()->getDataViewOptions().TAZDrawFill()) ? true : getFill();
284 // get colors
285 const RGBColor color = GUIPolygon::setColor(s, this, this, drawUsingSelectColor(), -1);
286 const RGBColor invertedColor = color.invertedColor();
287 const RGBColor darkerColor = color.changedBrightness(-32);
288 // push name (needed for getGUIGlObjectsUnderCursor(...)
290 // push layer matrix
292 // translate to front
294 // check if we're drawing a polygon or a polyline
297 // check if mouse is within geometry
298 if (myAdditionalGeometry.getShape().around(mousePosition)) {
299 // push matrix
301 // move to mouse position
302 glTranslated(mousePosition.x(), mousePosition.y(), 0);
303 // set color
304 GLHelper::setColor(color);
305 // draw circle
307 // pop matrix
309 }
310 } else {
311 // draw inner polygon
312 const int alphaOverride = myNet->getViewNet()->getDataViewOptions().TAZDrawFill() ? 128 : -1;
313 GUIPolygon::drawInnerPolygon(s, this, this, myAdditionalGeometry.getShape(), 0, drawFill, drawUsingSelectColor(), alphaOverride, true);
314 }
315 } else {
316 // push matrix
318 // set color
319 GLHelper::setColor(color);
320 // draw geometry (polyline)
322 // pop matrix
324 }
325 // draw contour if shape isn't blocked
327 // push contour matrix
329 // translate to front
330 glTranslated(0, 0, 0.1);
331 // set color
332 GLHelper::setColor(darkerColor);
333 // draw polygon contour
335 // pop contour matrix
337 // draw shape points only in Network supemode
339 // check move mode flag
341 // draw geometry points
343 s.neteditSizeSettings.polygonGeometryPointRadius * (moveMode ? 1 : 0.5), TAZExaggeration,
344 myNet->getViewNet()->getNetworkViewOptions().editingElevation(), drawExtremeSymbols);
345 // draw moving hint points
349 }
350 }
351 }
352 // draw center
353 const double centerRadius = s.neteditSizeSettings.polygonGeometryPointRadius * TAZExaggeration;
354 // push center matrix
356 // move to vertex
357 glTranslated(myTAZCenter.x(), myTAZCenter.y(), 0.3);
358 // set color
359 GLHelper::setColor(darkerColor);
360 // draw circle
362 // move to front
363 glTranslated(0, 0, 0.1);
364 // set color
365 GLHelper::setColor(color);
366 // draw circle
367 GLHelper::drawFilledCircle(centerRadius * 0.8, s.getCircleResolution());
368 // pop center matrix
370 // pop layer matrix
372 // pop name
374 // draw lock icon
376 // get name position
378 // draw name
380 // check if mouse is over element
382 // draw dotted contours
383 drawDottedContours(s, TAZExaggeration);
384 // check if draw poly type
385 if (s.polyType.show(this)) {
386 const Position p = namePos + Position(0, -0.6 * s.polyType.size / s.scale);
388 }
389 }
390}
391
392
393std::string
395 switch (key) {
396 case SUMO_ATTR_ID:
397 return getMicrosimID();
398 case SUMO_ATTR_SHAPE:
399 return toString(myShape);
400 case SUMO_ATTR_CENTER:
402 return "";
403 } else {
404 return toString(myTAZCenter);
405 }
406 case SUMO_ATTR_COLOR:
407 return toString(getShapeColor());
408 case SUMO_ATTR_NAME:
409 return getShapeName();
410 case SUMO_ATTR_FILL:
411 return toString(myFill);
412 case SUMO_ATTR_EDGES: {
413 std::vector<std::string> edgeIDs;
414 for (const auto& TAZChild : getChildAdditionals()) {
415 edgeIDs.push_back(TAZChild->getAttribute(SUMO_ATTR_EDGE));
416 }
417 return toString(edgeIDs);
418 }
422 return getParametersStr();
425 return "undefined";
426 } else {
428 }
431 return "undefined";
432 } else {
434 }
437 return "undefined";
438 } else {
440 }
443 return "undefined";
444 } else {
446 }
449 return "undefined";
450 } else {
452 }
455 return "undefined";
456 } else {
458 }
459 default:
460 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
461 }
462}
463
464
465double
467 switch (key) {
469 return myMinWeightSource;
471 return myMinWeightSink;
473 return myMaxWeightSource;
475 return myMaxWeightSink;
479 return myAverageWeightSink;
480 default:
481 throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
482 }
483}
484
485
488 switch (key) {
489 case SUMO_ATTR_CENTER:
490 return myTAZCenter;
491 default:
492 throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
493 }
494}
495
496
499 return getParametersMap();
500}
501
502
503void
504GNETAZ::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
505 if (value == getAttribute(key)) {
506 return; //avoid needless changes, later logic relies on the fact that attributes have changed
507 }
508 switch (key) {
509 case SUMO_ATTR_ID:
510 case SUMO_ATTR_SHAPE:
511 case SUMO_ATTR_CENTER:
512 case SUMO_ATTR_COLOR:
513 case SUMO_ATTR_NAME:
514 case SUMO_ATTR_FILL:
515 case SUMO_ATTR_EDGES:
518 undoList->changeAttribute(new GNEChange_Attribute(this, key, value));
519 break;
520 default:
521 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
522 }
523}
524
525
526bool
527GNETAZ::isValid(SumoXMLAttr key, const std::string& value) {
528 switch (key) {
529 case SUMO_ATTR_ID:
531 (myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_TAZ, value, false) == nullptr) &&
532 (myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_POLY, value, false) == nullptr);
533 case SUMO_ATTR_SHAPE:
534 if (value.empty()) {
535 return false;
536 } else {
537 return canParse<PositionVector>(value);
538 }
539 case SUMO_ATTR_CENTER:
540 if (value.empty()) {
541 return true;
542 } else {
543 return canParse<Position>(value);
544 }
545 case SUMO_ATTR_COLOR:
546 return canParse<RGBColor>(value);
547 case SUMO_ATTR_NAME:
549 case SUMO_ATTR_FILL:
550 return canParse<bool>(value);
551 case SUMO_ATTR_EDGES:
552 if (value.empty()) {
553 return true;
554 } else {
556 }
558 return canParse<bool>(value);
560 return areParametersValid(value);
561 default:
562 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
563 }
564}
565
566
567std::string
569 return getTagStr() + ":" + getID();
570}
571
572
573std::string
575 return getTagStr();
576}
577
578
579void
581 // reset all stadistic variables
588 // declare an extra variables for saving number of children
589 int numberOfSources = 0;
590 int numberOfSinks = 0;
591 // iterate over child additional
592 for (const auto& TAZChild : getChildAdditionals()) {
593 if (TAZChild->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) {
594 const double weight = TAZChild->getAttributeDouble(SUMO_ATTR_WEIGHT);
595 // check max Weight
596 if ((myMaxWeightSource == INVALID_DOUBLE) || (myMaxWeightSource < weight)) {
597 myMaxWeightSource = weight;
598 }
599 // check min Weight
600 if ((myMinWeightSource == INVALID_DOUBLE) || (weight < myMinWeightSource)) {
601 myMinWeightSource = weight;
602 }
603 // update Average
604 myAverageWeightSource += weight;
605 // update number of sources
606 numberOfSources++;
607 } else if (TAZChild->getTagProperty().getTag() == SUMO_TAG_TAZSINK) {
608 const double weight = TAZChild->getAttributeDouble(SUMO_ATTR_WEIGHT);
609 // check max Weight
610 if ((myMaxWeightSink == INVALID_DOUBLE) || myMaxWeightSink < weight) {
611 myMaxWeightSink = weight;
612 }
613 // check min Weight
614 if ((myMinWeightSink == INVALID_DOUBLE) || (weight < myMinWeightSink)) {
615 myMinWeightSink = weight;
616 }
617 // update Average
618 myAverageWeightSink += weight;
619 // update number of sinks
620 numberOfSinks++;
621 }
622 }
623 // calculate average
624 if (numberOfSources > 0) {
625 myAverageWeightSource /= numberOfSources;
626 }
627 if (numberOfSinks > 0) {
628 myAverageWeightSink /= numberOfSinks;
629 }
630}
631
632// ===========================================================================
633// private
634// ===========================================================================
635
636void
637GNETAZ::drawDottedContours(const GUIVisualizationSettings& s, const double TAZExaggeration) const {
638 // get TAZRelDataFrame
639 const auto TAZRelDataFrame = myNet->getViewNet()->getViewParent()->getTAZRelDataFrame();
640 // dotted contour for inspect
643 }
644 // dotted contour for front
645 if (myNet->getViewNet()->getFrontAttributeCarrier() == this) {
647 }
648 // delete contour
649 if (myNet->getViewNet()->drawDeleteContour(this, this)) {
651 }
652 // select contour
653 if (myNet->getViewNet()->drawSelectContour(this, this)) {
655 }
656 // dotted contour for first TAZ
657 if ((myNet->getViewNet()->getViewParent()->getTAZRelDataFrame()->getFirstTAZ() == this)) {
659 }
660 // dotted contour for second TAZ
663 }
664 // now check if mouse is over TAZ
665 if (TAZRelDataFrame->shown() && (gPostDrawing.markedTAZ == nullptr) && ((TAZRelDataFrame->getFirstTAZ() == nullptr) || (TAZRelDataFrame->getSecondTAZ() == nullptr))) {
666 // get dotted contour type
667 const auto dottedContourType = (TAZRelDataFrame->getFirstTAZ() == nullptr) ? GUIDottedGeometry::DottedContourType::FROMTAZ : GUIDottedGeometry::DottedContourType::TOTAZ;
668 // draw depending if is closed
672 }
673 } else {
674 // scale shape
675 auto scaledShape = myAdditionalGeometry.getShape();
676 scaledShape.scaleAbsolute(1);
677 // check if mouse is around scaled shape
678 if ((scaledShape.around(myNet->getViewNet()->getPositionInformation()) && (scaledShape.distance2D(myNet->getViewNet()->getPositionInformation()) <= 1.3)) ||
681 }
682 }
683 }
684}
685
686
687void
688GNETAZ::setAttribute(SumoXMLAttr key, const std::string& value) {
689 switch (key) {
690 case SUMO_ATTR_ID:
691 // update microsimID
692 setMicrosimID(value);
693 break;
694 case SUMO_ATTR_SHAPE: {
695 const bool updateCenter = (myTAZCenter == myShape.getCentroid());
696 // set new shape
697 myShape = parse<PositionVector>(value);
698 // always close shape
699 if ((myShape.size() > 1) && (myShape.front() != myShape.back())) {
700 myShape.push_back(myShape.front());
701 }
702 // update center
703 if (myShape.size() == 0) {
704 myTAZCenter = Position(0, 0, 0);
705 } else if (updateCenter) {
707 }
708 // update geometry
710 // update centering boundary
711 if (!isTemplate()) {
713 }
714 break;
715 }
716 case SUMO_ATTR_CENTER:
717 if (value.empty()) {
719 } else {
720 myTAZCenter = parse<Position>(value);
721 }
722 // update geometry
724 // update centering boundary
725 if (!isTemplate()) {
727 }
728 break;
729 case SUMO_ATTR_COLOR:
730 setShapeColor(parse<RGBColor>(value));
731 break;
732 case SUMO_ATTR_NAME:
733 setShapeName(value);
734 break;
735 case SUMO_ATTR_FILL:
736 myFill = parse<bool>(value);
737 break;
738 case SUMO_ATTR_EDGES:
739 break;
741 if (parse<bool>(value)) {
743 } else {
745 }
746 break;
748 setParametersStr(value);
749 break;
750 default:
751 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
752 }
753}
754
755
756void
759 // update new center
760 myTAZCenter = moveResult.shapeToUpdate.front();
762 // update new shape and center
764 myShape = moveResult.shapeToUpdate;
765 // update geometry
767 } else {
768 // get lastIndex
769 const int lastIndex = (int)moveResult.shapeToUpdate.size() - 1;
770 // update new shape
771 myShape = moveResult.shapeToUpdate;
772 // adjust first and last position
773 if (moveResult.geometryPointsToMove.front() == 0) {
774 myShape[lastIndex] = moveResult.shapeToUpdate[0];
775 } else if (moveResult.geometryPointsToMove.front() == lastIndex) {
776 myShape[0] = moveResult.shapeToUpdate[lastIndex];
777 }
779 // update geometry
781 }
782 myTesselation.clear();
783}
784
785
786void
787GNETAZ::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)));
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:952
@ GLO_TAZ
Traffic Assignment Zones (TAZs)
GUIPostDrawing gPostDrawing
GUIIcon
An enumeration of icons used by the gui applications.
Definition: GUIIcons.h:33
@ 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:60
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:894
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.
Definition: GNEAdditional.h:48
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< 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:1245
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition: GNENet.cpp:1257
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:132
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1987
Position getPositionInView() const
Returns position of additional in view.
Definition: GNETAZ.cpp:199
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
Definition: GNETAZ.cpp:211
double myMaxWeightSink
Max Sink weight.
Definition: GNETAZ.h:188
Position myTAZCenter
TAZ center.
Definition: GNETAZ.h:169
static const double myHintSize
hint size of vertex
Definition: GNETAZ.h:173
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNETAZ.cpp:270
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNETAZ.cpp:568
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
Definition: GNETAZ.cpp:205
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Definition: GNETAZ.cpp:237
Position getAttributePosition(SumoXMLAttr key) const
Definition: GNETAZ.cpp:487
void drawDottedContours(const GUIVisualizationSettings &s, const double TAZExaggeration) const
draw dotted contours
Definition: GNETAZ.cpp:637
~GNETAZ()
GNETAZ Destructor.
Definition: GNETAZ.cpp:82
double myAverageWeightSource
Average source weight.
Definition: GNETAZ.h:185
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition: GNETAZ.cpp:757
void updateTAZStadistic()
update TAZ Stadistic
Definition: GNETAZ.cpp:580
void updateGeometry()
update pre-computed geometry information
Definition: GNETAZ.cpp:187
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their correspondent attribute are valids
Definition: GNETAZ.cpp:527
double myMinWeightSink
Min Sink weight.
Definition: GNETAZ.h:191
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNETAZ.cpp:86
double myAverageWeightSink
Average Sink weight.
Definition: GNETAZ.h:194
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNETAZ.cpp:574
std::string getParentName() const
Returns the name of the parent object (if any)
Definition: GNETAZ.cpp:243
void writeAdditional(OutputDevice &device) const
write additional element into a xml file
Definition: GNETAZ.cpp:154
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
Definition: GNETAZ.cpp:120
std::string getAttribute(SumoXMLAttr key) const
Definition: GNETAZ.cpp:394
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNETAZ.cpp:249
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:504
static const double myHintSizeSquared
squaredhint size of vertex
Definition: GNETAZ.h:176
double myMinWeightSource
Min source weight.
Definition: GNETAZ.h:182
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:104
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition: GNETAZ.cpp:787
const Parameterised::Map & getACParametersMap() const
get parameters map
Definition: GNETAZ.cpp:498
double getAttributeDouble(SumoXMLAttr key) const
Definition: GNETAZ.cpp:466
double myMaxWeightSource
Max source weight.
Definition: GNETAZ.h:179
GNETAZ(GNENet *net)
@default GNETAZ Constructor
Definition: GNETAZ.cpp:50
GNEAdditional * getSecondTAZ() const
get first selected TAZ Element
GNEAdditional * 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:656
const GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:632
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
Definition: GNEViewNet.cpp:644
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:474
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:650
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 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
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
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.h:141
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 mouseWithinGeometry(const Position center, const double radius) const
check if mouse is within elements geometry (for circles)
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:154
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:102
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:329
static bool checkDraw(const GUIVisualizationSettings &s, const SUMOPolygon *polygon, const GUIGlObject *o)
check if Polygon can be drawn
Definition: GUIPolygon.cpp:307
static RGBColor setColor(const GUIVisualizationSettings &s, const SUMOPolygon *polygon, const GUIGlObject *o, bool disableSelectionColor, int alphaOverride)
set color
Definition: GUIPolygon.cpp:278
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.
Definition: OutputDevice.h:61
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:251
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
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: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.
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.
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.
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: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
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 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