Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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-2025 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>
25#include <netedit/GNEViewNet.h>
35
36#include "GNETAZ.h"
37
38// ===========================================================================
39// static members
40// ===========================================================================
41
42const double GNETAZ::myHintSize = 0.8;
43const double GNETAZ::myHintSizeSquared = 0.64;
44
45// ===========================================================================
46// member method definitions
47// ===========================================================================
48
50 GNEAdditional("", net, "", SUMO_TAG_TAZ, ""),
52}
53
54
55GNETAZ::GNETAZ(const std::string& id, GNENet* net, const std::string& filename, const PositionVector& shape, const Position& center, const bool fill,
56 const RGBColor& color, const std::string& name, const Parameterised::Map& parameters) :
57 GNEAdditional(id, net, filename, SUMO_TAG_TAZ, ""),
58 TesselatedPolygon(id, "", color, shape, false, fill, 1, Shape::DEFAULT_LAYER, Shape::DEFAULT_ANGLE, Shape::DEFAULT_IMG_FILE, name, parameters),
59 myTAZCenter(center) {
60 // update centering boundary without updating grid
62 // update geometry
64}
65
66
68
69
72 // get snap radius
74 // check if we're moving center or shape
75 if (myTAZCenter.distanceSquaredTo2D(myNet->getViewNet()->getPositionInformation()) < (snap_radius * snap_radius)) {
76 // move entire shape
77 return new GNEMoveOperation(this, myTAZCenter);
79 // move entire shape
80 return new GNEMoveOperation(this, myShape);
81 } else {
82 // calculate move shape operation
83 return calculateMoveShapeOperation(this, myShape, true);
84 }
85}
86
87
88int
89GNETAZ::getVertexIndex(Position pos, bool snapToGrid) {
90 // check if position has to be snapped to grid
91 if (snapToGrid) {
92 pos = myNet->getViewNet()->snapToActiveGrid(pos);
93 }
94 // first check if vertex already exists
95 for (const auto& shapePosition : myShape) {
97 return myShape.indexOfClosest(shapePosition);
98 }
99 }
100 return -1;
101}
102
103
104void
105GNETAZ::removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList) {
106 // get original shape
107 PositionVector shape = myShape;
108 // check shape size
109 if (shape.size() > 3) {
110 // obtain index
111 int index = shape.indexOfClosest(clickedPosition);
112 // get last index
113 const int lastIndex = ((int)shape.size() - 1);
114 // get snap radius
116 // check if we have to create a new index
117 if ((index != -1) && shape[index].distanceSquaredTo2D(clickedPosition) < (snap_radius * snap_radius)) {
118 // check if we're deleting the first point
119 if ((index == 0) || (index == lastIndex)) {
120 // remove both geometry point
121 shape.erase(shape.begin() + lastIndex);
122 shape.erase(shape.begin());
123 // close shape
124 shape.closePolygon();
125 } else {
126 // remove geometry point
127 shape.erase(shape.begin() + index);
128 }
129 // commit new shape
130 undoList->begin(this, "remove geometry point of " + getTagStr());
132 undoList->end();
133 }
134 }
135}
136
137
138void
140 // first open TAZ tag
141 device.openTag(SUMO_TAG_TAZ);
142 // write TAZ attributes
143 device.writeAttr(SUMO_ATTR_ID, getID());
147 }
148 if (myFill) {
149 device.writeAttr(SUMO_ATTR_FILL, true);
150 }
151 if (getShapeName().size() > 0) {
153 }
155 // sort all Source/Sinks by ID
156 std::map<std::pair<std::string, SumoXMLTag>, GNETAZSourceSink*> sortedSourceSinks;
157 for (const auto& sourceSink : getChildTAZSourceSinks()) {
158 sortedSourceSinks[std::make_pair(sourceSink->getAttribute(SUMO_ATTR_EDGE), sourceSink->getTagProperty()->getTag())] = sourceSink;
159 }
160 // write all TAZ Source/sinks
161 for (const auto& sortedSourceSink : sortedSourceSinks) {
162 sortedSourceSink.second->writeTAZSourceSink(device);
163 }
164 // write params
165 writeParams(device);
166 // close TAZ tag
167 device.closeTag();
168}
169
170
171bool
173 return true;
174}
175
176
177std::string
179 return "";
180}
181
182
183void
185 // nothing to fix
186}
187
188
189bool
191 // get edit modes
192 const auto& editModes = myNet->getViewNet()->getEditModes();
193 // check if we're in move mode
194 if (!myNet->getViewNet()->isCurrentlyMovingElements() && editModes.isCurrentSupermodeNetwork() &&
196 (editModes.networkEditMode == NetworkEditMode::NETWORK_MOVE) && myNet->getViewNet()->checkOverLockedElement(this, mySelected)) {
197 // only move the first element
199 } else {
200 return false;
201 }
202}
203
204
205void
207 // just update geometry
209 // update geometry of child plan elements
210 for (const auto& demandElements : getChildDemandElements()) {
211 demandElements->updateGeometry();
212 }
213 // update geometry of childTAZRelDatas
214 for (const auto& TAZRelData : getChildGenericDatas()) {
215 TAZRelData->updateGeometry();
216 }
217 myTesselation.clear();
218}
219
220
223 return myShape.getCentroid();
224}
225
226
227double
229 return s.polySize.getExaggeration(s, this);
230}
231
232
233void
234GNETAZ::updateCenteringBoundary(const bool updateGrid) {
235 // Remove object from net
236 if (updateGrid) {
238 for (const auto& TAZRelData : getChildGenericDatas()) {
239 myNet->removeGLObjectFromGrid(TAZRelData);
240 }
241 }
242 // use shape as boundary
244 // add center
247 }
248 // grow boundary
250 // add object into net
251 if (updateGrid) {
253 for (const auto& TAZRelData : getChildGenericDatas()) {
254 TAZRelData->updateGeometry();
255 myNet->addGLObjectIntoGrid(TAZRelData);
256 }
257 }
258}
259
260
261void
262GNETAZ::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
263 // Nothing to split
264}
265
266
267std::string
269 return myNet->getMicrosimID();
270}
271
272
275 // create popup
276 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, this);
277 // build common options
279 // create a extra FXMenuCommand if mouse is over a vertex
280 const int index = getVertexIndex(myNet->getViewNet()->getPositionInformation(), false);
281 if (index != -1) {
282 // add separator
283 new FXMenuSeparator(ret);
284 // check if we're in network mode
286 GUIDesigns::buildFXMenuCommand(ret, TL("Set custom Geometry Point"), nullptr, &parent, MID_GNE_CUSTOM_GEOMETRYPOINT);
287 }
288 }
289 return ret;
290}
291
292
293void
295 // first check if poly can be drawn
297 GUIPolygon::checkDraw(s, this, this)) {
298 // draw boundary
299 const auto boundary = getCenteringBoundary();
300 GLHelper::drawBoundary(s, boundary);
301 // get exaggeration
302 const double TAZExaggeration = getExaggeration(s);
303 // get detail level
304 const auto d = s.getDetailLevel(TAZExaggeration);
305 // draw geometry only if we'rent in drawForObjectUnderCursor mode
306 if (s.checkDrawPoly(boundary, isAttributeCarrierSelected())) {
307 // Obtain constants
308 const bool drawFill = (myNet->getViewNet()->getEditModes().isCurrentSupermodeData() && myNet->getViewNet()->getDataViewOptions().TAZDrawFill()) ? true : getFill();
309 // get colors
310 const RGBColor color = GUIPolygon::setColor(s, this, this, drawUsingSelectColor(), -1);
311 const RGBColor darkerColor = color.changedBrightness(-32);
312 // push layer matrix
314 // translate to front
316 // check if we're drawing a polygon or a polyline
318 // draw inner polygon
319 const int alphaOverride = myNet->getViewNet()->getDataViewOptions().TAZDrawFill() ? 128 : -1;
320 GUIPolygon::drawInnerPolygon(s, this, this, myAdditionalGeometry.getShape(), 0, drawFill, drawUsingSelectColor(), alphaOverride, true);
321 } else {
322 // push matrix
324 // set color
325 GLHelper::setColor(color);
326 // draw geometry (polyline)
328 // pop matrix
330 }
331 // draw contour if shape isn't blocked
333 // push contour matrix
335 // translate to front
336 glTranslated(0, 0, 0.1);
337 // set color
338 GLHelper::setColor(darkerColor);
339 // draw polygon contour
341 // pop contour matrix
343 // draw shape points only in Network supemode
345 // check if we're in move mode
347 // get geometry point sizes
348 const double geometryPointSize = s.neteditSizeSettings.polygonGeometryPointRadius * (moveMode ? 1 : 0.5);
349 // draw geometry points
350 GUIGeometry::drawGeometryPoints(d, myAdditionalGeometry.getShape(), darkerColor, geometryPointSize, TAZExaggeration,
352 // draw dotted contours for geometry points if we're in move mode
353 if (moveMode) {
355 TAZExaggeration, s.dottedContourSettings.segmentWidthSmall);
356 }
357 }
358 }
359 // draw center
360 const double centerRadius = s.neteditSizeSettings.polygonGeometryPointRadius * TAZExaggeration;
361 // push center matrix
363 // move to vertex
364 glTranslated(myTAZCenter.x(), myTAZCenter.y(), GLO_JUNCTION + 0.3);
365 // set color
366 GLHelper::setColor(darkerColor);
367 // draw circle
369 // move to front
370 glTranslated(0, 0, 0.1);
371 // set color
372 GLHelper::setColor(color);
373 // draw circle
374 GLHelper::drawFilledCircleDetailled(d, centerRadius * 0.8);
375 // pop center matrix
377 // pop layer matrix
379 // draw lock icon
381 // draw name
383 // check if draw poly type
384 if (s.polyType.show(this)) {
387 }
388 // get contour width
390 // draw dotted contour
391 myAdditionalContour.drawDottedContours(s, d, this, contourWidth, true);
392 // draw TAZ Center dotted contour
393 myTAZCenterContour.drawDottedContours(s, d, this, contourWidth, true);
394 }
395 // draw demand element children
397 // calculate contour
399 calculateContourPolygons(s, d, getShapeLayer(), TAZExaggeration, true);
400 } else {
401 calculateContourPolygons(s, d, getShapeLayer(), TAZExaggeration, getFill());
402 }
403 // calculate contour for TAZ Center
405 }
406}
407
408
409std::string
411 switch (key) {
412 case SUMO_ATTR_ID:
413 return getMicrosimID();
414 case SUMO_ATTR_SHAPE:
415 return toString(myShape);
416 case SUMO_ATTR_CENTER:
418 return "";
419 } else {
420 return toString(myTAZCenter);
421 }
422 case SUMO_ATTR_COLOR:
423 return toString(getShapeColor());
424 case SUMO_ATTR_NAME:
425 return getShapeName();
426 case SUMO_ATTR_FILL:
427 return toString(myFill);
428 case SUMO_ATTR_EDGES: {
429 std::vector<std::string> edgeIDs;
430 for (const auto& TAZSourceSink : getChildTAZSourceSinks()) {
431 edgeIDs.push_back(TAZSourceSink->getAttribute(SUMO_ATTR_EDGE));
432 }
433 return toString(edgeIDs);
434 }
436 return toString(myEdgesWithin);
439 return "undefined";
440 } else {
442 }
445 return "undefined";
446 } else {
448 }
451 return "undefined";
452 } else {
454 }
457 return "undefined";
458 } else {
460 }
463 return "undefined";
464 } else {
466 }
469 return "undefined";
470 } else {
472 }
473 default:
474 return getCommonAttribute(this, key);
475 }
476}
477
478
479double
481 switch (key) {
483 return myMinWeightSource;
485 return myMinWeightSink;
487 return myMaxWeightSource;
489 return myMaxWeightSink;
493 return myAverageWeightSink;
494 default:
495 throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
496 }
497}
498
499
502 switch (key) {
503 case SUMO_ATTR_CENTER:
504 return myTAZCenter;
506 return myShape.getCentroid();
507 default:
508 throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
509 }
510}
511
512
515 return getParametersMap();
516}
517
518
519void
520GNETAZ::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
521 if (value == getAttribute(key)) {
522 return; //avoid needless changes, later logic relies on the fact that attributes have changed
523 }
524 switch (key) {
525 case SUMO_ATTR_ID:
526 case SUMO_ATTR_SHAPE:
527 case SUMO_ATTR_CENTER:
528 case SUMO_ATTR_COLOR:
529 case SUMO_ATTR_NAME:
530 case SUMO_ATTR_FILL:
531 case SUMO_ATTR_EDGES:
533 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
534 break;
535 default:
536 setCommonAttribute(key, value, undoList);
537 break;
538 }
539}
540
541
542bool
543GNETAZ::isValid(SumoXMLAttr key, const std::string& value) {
544 switch (key) {
545 case SUMO_ATTR_ID:
547 case SUMO_ATTR_SHAPE:
548 if (value.empty()) {
549 return false;
550 } else {
551 return canParse<PositionVector>(value);
552 }
553 case SUMO_ATTR_CENTER:
554 if (value.empty()) {
555 return true;
556 } else {
557 return canParse<Position>(value);
558 }
559 case SUMO_ATTR_COLOR:
560 return canParse<RGBColor>(value);
561 case SUMO_ATTR_NAME:
563 case SUMO_ATTR_FILL:
564 return canParse<bool>(value);
565 case SUMO_ATTR_EDGES:
566 if (value.empty()) {
567 return true;
568 } else {
570 }
572 return canParse<bool>(value);
573 default:
574 return isCommonValid(key, value);
575 }
576}
577
578
579std::string
581 return getTagStr() + ":" + getID();
582}
583
584
585std::string
587 return getTagStr();
588}
589
590
591void
593 // reset all statistic variables
600 // declare an extra variables for saving number of children
601 int numberOfSources = 0;
602 int numberOfSinks = 0;
603 // iterate over child additional
604 for (const auto& TAZSourceSink : getChildTAZSourceSinks()) {
605 if (TAZSourceSink->getTagProperty()->getTag() == SUMO_TAG_TAZSOURCE) {
606 const double weight = TAZSourceSink->getAttributeDouble(SUMO_ATTR_WEIGHT);
607 // check max Weight
608 if ((myMaxWeightSource == INVALID_DOUBLE) || (myMaxWeightSource < weight)) {
609 myMaxWeightSource = weight;
610 }
611 // check min Weight
612 if ((myMinWeightSource == INVALID_DOUBLE) || (weight < myMinWeightSource)) {
613 myMinWeightSource = weight;
614 }
615 // update Average
616 myAverageWeightSource += weight;
617 // update number of sources
618 numberOfSources++;
619 } else if (TAZSourceSink->getTagProperty()->getTag() == SUMO_TAG_TAZSINK) {
620 const double weight = TAZSourceSink->getAttributeDouble(SUMO_ATTR_WEIGHT);
621 // check max Weight
622 if ((myMaxWeightSink == INVALID_DOUBLE) || myMaxWeightSink < weight) {
623 myMaxWeightSink = weight;
624 }
625 // check min Weight
626 if ((myMinWeightSink == INVALID_DOUBLE) || (weight < myMinWeightSink)) {
627 myMinWeightSink = weight;
628 }
629 // update Average
630 myAverageWeightSink += weight;
631 // update number of sinks
632 numberOfSinks++;
633 }
634 }
635 // calculate average
636 if (numberOfSources > 0) {
637 myAverageWeightSource /= numberOfSources;
638 }
639 if (numberOfSinks > 0) {
640 myAverageWeightSink /= numberOfSinks;
641 }
642}
643
644// ===========================================================================
645// private
646// ===========================================================================
647
648void
649GNETAZ::setAttribute(SumoXMLAttr key, const std::string& value) {
650 switch (key) {
651 case SUMO_ATTR_ID:
652 // update microsimID
653 setAdditionalID(value);
654 break;
655 case SUMO_ATTR_SHAPE: {
656 const bool updateCenter = (myTAZCenter == myShape.getCentroid());
657 // set new shape
658 myShape = parse<PositionVector>(value);
659 // always close shape
660 if ((myShape.size() > 1) && (myShape.front() != myShape.back())) {
661 myShape.push_back(myShape.front());
662 }
663 // update center
664 if (myShape.size() == 0) {
665 myTAZCenter = Position(0, 0, 0);
666 } else if (updateCenter) {
668 }
669 // update geometry
671 // update centering boundary
672 if (!isTemplate()) {
674 }
675 break;
676 }
677 case SUMO_ATTR_CENTER:
678 if (value.empty()) {
680 } else {
681 myTAZCenter = parse<Position>(value);
682 }
683 // update geometry
685 // update centering boundary
686 if (!isTemplate()) {
688 }
689 break;
690 case SUMO_ATTR_COLOR:
691 setShapeColor(parse<RGBColor>(value));
692 break;
693 case SUMO_ATTR_NAME:
694 setShapeName(value);
695 break;
696 case SUMO_ATTR_FILL:
697 myFill = parse<bool>(value);
699 break;
700 case SUMO_ATTR_EDGES:
701 break;
703 myEdgesWithin = parse<bool>(value);
704 break;
705 default:
706 setCommonAttribute(this, key, value);
707 break;
708 }
709}
710
711
712void
715 // update new center
716 myTAZCenter = moveResult.shapeToUpdate.front();
718 // update new shape and center
720 myShape = moveResult.shapeToUpdate;
721 // update geometry
723 } else {
724 // get lastIndex
725 const int lastIndex = (int)moveResult.shapeToUpdate.size() - 1;
726 // update new shape
727 myShape = moveResult.shapeToUpdate;
728 // adjust first and last position
729 if (moveResult.geometryPointsToMove.front() == 0) {
730 myShape[lastIndex] = moveResult.shapeToUpdate[0];
731 } else if (moveResult.geometryPointsToMove.front() == lastIndex) {
732 myShape[0] = moveResult.shapeToUpdate[lastIndex];
733 }
735 // update geometry
737 }
738 myTesselation.clear();
739}
740
741
742void
743GNETAZ::commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) {
745 // commit center
746 undoList->begin(this, "moving " + toString(SUMO_ATTR_CENTER) + " of " + getTagStr());
748 undoList->end();
750 // calculate offset between old and new shape
751 Position newCenter = myTAZCenter;
752 newCenter.add(moveResult.shapeToUpdate.getCentroid() - myShape.getCentroid());
753 // commit new shape and center
754 undoList->begin(this, "moving " + toString(SUMO_ATTR_SHAPE) + " of " + getTagStr());
757 undoList->end();
758 } else {
759 // get lastIndex
760 const int lastIndex = (int)moveResult.shapeToUpdate.size() - 1;
761 // close shapeToUpdate
762 auto closedShape = moveResult.shapeToUpdate;
763 // adjust first and last position
764 if (moveResult.geometryPointsToMove.front() == 0) {
765 closedShape[lastIndex] = moveResult.shapeToUpdate[0];
766 } else if (moveResult.geometryPointsToMove.front() == lastIndex) {
767 closedShape[0] = moveResult.shapeToUpdate[lastIndex];
768 }
769 // commit new shape
770 undoList->begin(this, "moving " + toString(SUMO_ATTR_SHAPE) + " of " + getTagStr());
772 undoList->end();
773 }
774}
775
776/****************************************************************************/
@ NETWORK_MOVE
mode for moving network elements
@ MID_GNE_CUSTOM_GEOMETRYPOINT
set custom geometry point
@ GLO_JUNCTION
a junction
#define TL(string)
Definition MsgHandler.h:305
@ SUMO_TAG_TAZ
a traffic assignment zone
@ SUMO_TAG_TAZSINK
a sink within a district (connection road)
@ SUMO_TAG_TAZSOURCE
a source within a district (connection road)
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ GNE_ATTR_MAX_SOURCE
max source (used only by TAZs)
@ SUMO_ATTR_EDGE
@ GNE_ATTR_MAX_SINK
max sink (used only by TAZs)
@ GNE_ATTR_AVERAGE_SINK
average sink (used only by TAZs)
@ GNE_ATTR_TAZ_CENTROID
TAZ Center (uses to return the TAZ centroid if center is not defined)
@ GNE_ATTR_MIN_SINK
min sink (used only by TAZs)
@ SUMO_ATTR_EDGES
the edges of a route
@ 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_EDGES_WITHIN
virtual attribute used for use edges within during TAZ creation
@ 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:75
Boundary & grow(double by)
extends the boundary by the given amount
Definition Boundary.cpp:340
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:649
static void popMatrix()
pop matrix
Definition GLHelper.cpp:131
static void drawBoundary(const GUIVisualizationSettings &s, const Boundary &b)
Draw a boundary (used for debugging)
Definition GLHelper.cpp:952
static void drawFilledCircleDetailled(const GUIVisualizationSettings::Detail d, const double radius)
Draws a filled circle around (0,0) depending of level of detail.
Definition GLHelper.cpp:534
static void pushMatrix()
push matrix
Definition GLHelper.cpp:118
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:773
bool isValidAdditionalID(const std::string &value) const
check if a new additional ID is valid
void setAdditionalID(const std::string &newID)
set additional ID
GNEContour myAdditionalContour
variable used for draw additional contours
GUIGeometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
bool checkDrawFromContour() const
check if draw from contour (green)
void resetAdditionalContour()
reset additional contour
void drawDemandElementChildren(const GUIVisualizationSettings &s) const
draw demand element children
bool checkDrawToContour() const
check if draw from contour (magenta)
void calculateContourPolygons(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double layer, const double exaggeration, const bool filledShape) const
calculate contour for polygons
Boundary myAdditionalBoundary
Additional Boundary (used only by additionals placed over grid)
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
bool mySelected
boolean to check if this AC is selected (more quickly as checking GUIGlObjectStorage)
std::string getCommonAttribute(const Parameterised *parameterised, SumoXMLAttr key) const
void setCommonAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
const std::string & getTagStr() const
get tag assigned to this object in string format
bool isTemplate() const
check if this AC is template
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
void drawInLayer(const double typeOrLayer, const double extraOffset=0) const
draw element in the given layer, or in front if corresponding flag is enabled
GNENet * myNet
pointer to net
bool isCommonValid(SumoXMLAttr key, const std::string &value) const
const GNETagProperties * myTagProperty
reference to tagProperty associated with this attribute carrier
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
void drawDottedContourGeometryPoints(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const PositionVector &shape, const double radius, const double scale, const double lineWidth) const
draw dotted contour for geometry points
void calculateContourCircleShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const Position &pos, double radius, const double layer, const double scale, const GUIGlObject *boundaryParent) const
calculate contour (circle elements)
bool drawDottedContours(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const
draw dotted contours (basics, select, delete, inspect...)
const GNEHierarchicalContainerChildren< GNEGenericData * > & getChildGenericDatas() const
return child generic data elements
const GNEHierarchicalContainerChildrenSet< GNETAZSourceSink * > & getChildTAZSourceSinks() const
return child TAZSourceSinks (Set)
const GNEHierarchicalContainerChildren< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
GNEMoveOperation * calculateMoveShapeOperation(const GUIGlObject *obj, const PositionVector originalShape, const bool maintainShapeClosed)
calculate move shape operation
bool getMoveWholePolygons() const
check if option "move whole polygons" is enabled
NetworkMoveOptions * getNetworkMoveOptions() const
get network mode options
move operation
move result
const GNEMoveOperation::OperationType operationType
move operation
std::vector< int > geometryPointsToMove
shape points to move (of shapeToMove)
PositionVector shapeToUpdate
shape to update (edited in moveElement)
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
void addGLObjectIntoGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1443
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1453
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2195
Position getPositionInView() const
Returns position of additional in view.
Definition GNETAZ.cpp:222
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
Definition GNETAZ.cpp:234
std::string getAdditionalProblem() const
return a string with the current additional problem (must be reimplemented in all detector children)
Definition GNETAZ.cpp:178
double myMaxWeightSink
Max Sink weight.
Definition GNETAZ.h:219
Position myTAZCenter
TAZ center.
Definition GNETAZ.h:194
static const double myHintSize
hint size of vertex
Definition GNETAZ.h:204
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition GNETAZ.cpp:294
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition GNETAZ.cpp:580
GNEContour myTAZCenterContour
TAZ center contour.
Definition GNETAZ.h:197
bool myEdgesWithin
use edges whithin during creation (only in edit mode)
Definition GNETAZ.h:200
bool isAdditionalValid() const
check if current additional is valid to be written into XML (must be reimplemented in all detector ch...
Definition GNETAZ.cpp:172
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
Definition GNETAZ.cpp:228
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Definition GNETAZ.cpp:262
Position getAttributePosition(SumoXMLAttr key) const
Definition GNETAZ.cpp:501
~GNETAZ()
GNETAZ Destructor.
Definition GNETAZ.cpp:67
double myAverageWeightSource
Average source weight.
Definition GNETAZ.h:216
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition GNETAZ.cpp:713
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:543
double myMinWeightSink
Min Sink weight.
Definition GNETAZ.h:222
GNEMoveOperation * getMoveOperation()
get move operation
Definition GNETAZ.cpp:71
double myAverageWeightSink
Average Sink weight.
Definition GNETAZ.h:225
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition GNETAZ.cpp:586
std::string getParentName() const
Returns the name of the parent object.
Definition GNETAZ.cpp:268
void fixAdditionalProblem()
fix additional problem (must be reimplemented in all detector children)
Definition GNETAZ.cpp:184
void writeAdditional(OutputDevice &device) const
write additional element into a xml file
Definition GNETAZ.cpp:139
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
Definition GNETAZ.cpp:105
std::string getAttribute(SumoXMLAttr key) const
Definition GNETAZ.cpp:410
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition GNETAZ.cpp:274
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:520
static const double myHintSizeSquared
squaredhint size of vertex
Definition GNETAZ.h:207
void updateTAZStatistic()
update TAZ Statistic
Definition GNETAZ.cpp:592
double myMinWeightSource
Min source weight.
Definition GNETAZ.h:213
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:89
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition GNETAZ.cpp:743
const Parameterised::Map & getACParametersMap() const
get parameters map
Definition GNETAZ.cpp:514
double getAttributeDouble(SumoXMLAttr key) const
Definition GNETAZ.cpp:480
double myMaxWeightSource
Max source weight.
Definition GNETAZ.h:210
bool checkDrawMoveContour() const
check if draw move contour (red)
Definition GNETAZ.cpp:190
GNETAZ(GNENet *net)
@default GNETAZ Constructor
Definition GNETAZ.cpp:49
void writeTAZSourceSink(OutputDevice &device) const
write TAZ sourceSink
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
const GUIGlObject * getGUIGlObjectFront() const
get front GUIGLObject or a pointer to nullptr
bool isCurrentlyMovingElements() const
check if an element is being moved
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
const GNEViewNetHelper::EditNetworkElementShapes & getEditNetworkElementShapes() const
get Edit Shape module
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
GNEViewParent * getViewParent() const
get the net object
bool checkOverLockedElement(const GUIGlObject *GLObject, const bool isSelected) const
check if given element is locked (used for drawing select and delete contour)
const GNEViewNetHelper::ViewObjectsSelector & getViewObjectsSelector() const
get objects under cursor
const GNEViewNetHelper::DemandViewOptions & getDemandViewOptions() const
get demand view options
GNEMoveFrame * getMoveFrame() const
get frame for move elements
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel, const bool disable=false)
build menu command
The popup menu of a globject.
static void drawGeometryPoints(const GUIVisualizationSettings::Detail d, const PositionVector &shape, const RGBColor &color, const double radius, const double exaggeration, const bool editingElevation)
draw geometry points
static void drawGeometry(const GUIVisualizationSettings::Detail d, const GUIGeometry &geometry, const double width, double offset=0)
draw geometry
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void buildPopUpMenuCommonOptions(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, GUISUMOAbstractView *parent, const SumoXMLTag tag, const bool selected, bool addSeparator=true)
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
Position snapToActiveGrid(const Position &pos, bool snapXY=true) const
Returns a position that is mapped to the closest grid point if the grid is active.
const GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings (read only)
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
Stores the information about how to visualize structures.
bool checkDrawPoly(const Boundary &b, const bool selected) const
check if draw polygon
Detail getDetailLevel(const double exaggeration) const
return the detail level
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
double scale
information about a lane's width (temporary, used for a single view)
GUIVisualizationTextSettings polyName
GUIVisualizationSizeSettings polySize
GUIVisualizationTextSettings polyType
GUIVisualizationNeteditSizeSettings neteditSizeSettings
netedit size settings
double angle
The current view rotation angle.
static const std::vector< SumoXMLTag > polygons
polygon namespace
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.
std::map< std::string, std::string > Map
parameters map
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
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:278
static const Position INVALID
used to indicate that a position is valid
Definition Position.h:319
double x() const
Returns the x-position.
Definition Position.h:52
void add(const Position &pos)
Adds the given position to this one.
Definition Position.h:129
double y() const
Returns the y-position.
Definition Position.h:57
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)
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 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)
A 2D- or 3D-Shape.
Definition Shape.h:38
const std::string getShapeName() const
Returns the name of the Shape.
Definition Shape.h:108
static const double DEFAULT_LAYER
Definition Shape.h:43
void setShapeName(const std::string &name)
Sets a new shape name.
Definition Shape.h:161
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:75
static const double DEFAULT_ANGLE
Definition Shape.h:46
void setShapeColor(const RGBColor &col)
Sets a new color.
Definition Shape.h:128
double getShapeLayer() const
Returns the layer of the Shape.
Definition Shape.h:89
const RGBColor & getShapeColor() const
Returns the color of the Shape.
Definition Shape.h:82
std::vector< GLPrimitive > myTesselation
id of the display list for the cached tesselation
Definition GUIPolygon.h:72
bool TAZDrawFill() const
check if toggle TAZ draw fill checkbox is enabled
bool showShapes() const
check if shapes has to be drawn
NetworkEditMode networkEditMode
the current Network edit mode
bool isCurrentSupermodeData() const
@check if current supermode is Data
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
GNENetworkElement * getEditedNetworkElement() const
pointer to edited network element
static void drawLockIcon(const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, GUIGlObjectType type, const Position position, const double exaggeration, const double size=0.5, const double offsetx=0, const double offsety=0)
draw lock icon
bool editingElevation() const
check if we're editing elevation
static const double segmentWidthSmall
width of small dotted contour segments
static const double segmentWidth
width of dotted contour segments
static const double segmentWidthLarge
width of large dotted contour segments
static const double polygonGeometryPointRadius
moving geometry point radius
static const double polygonContourWidth
polygon contour width
static const double polylineWidth
poly line width
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
bool show(const GUIGlObject *o) const
whether to show the text