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-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18//
19/****************************************************************************/
20#include <config.h>
21
22#include <netedit/GNENet.h>
23#include <netedit/GNEUndoList.h>
24#include <netedit/GNEViewNet.h>
34
35#include "GNETAZ.h"
36
37
38// ===========================================================================
39// static members
40// ===========================================================================
41const double GNETAZ::myHintSize = 0.8;
42const double GNETAZ::myHintSizeSquared = 0.64;
43
44
45// ===========================================================================
46// member method definitions
47// ===========================================================================
48
50 GNEAdditional("", net, GLO_TAZ, SUMO_TAG_TAZ, GUIIconSubSys::getIcon(GUIIcon::TAZ), "", {}, {}, {}, {}, {}, {}),
52 myMaxWeightSource(0),
53 myMinWeightSource(0),
54 myAverageWeightSource(0),
55 myMaxWeightSink(0),
56 myMinWeightSink(0),
57myAverageWeightSink(0) {
58 // reset default values
59 resetDefaultValues();
60}
61
62
63GNETAZ::GNETAZ(const std::string& id, GNENet* net, const PositionVector& shape, const Position& center, const bool fill,
64 const RGBColor& color, const std::string& name, const Parameterised::Map& parameters) :
65 GNEAdditional(id, net, GLO_TAZ, SUMO_TAG_TAZ, GUIIconSubSys::getIcon(GUIIcon::TAZ), "", {}, {}, {}, {}, {}, {}),
67myTAZCenter(center),
68myMaxWeightSource(0),
69myMinWeightSource(0),
70myAverageWeightSource(0),
71myMaxWeightSink(0),
72myMinWeightSink(0),
73myAverageWeightSink(0) {
74 // update centering boundary without updating grid
75 updateCenteringBoundary(false);
76 // update geometry
77 updateGeometry();
78}
79
80
82
83
86 // get snap radius
88 // check if we're moving center or shape
89 if (myTAZCenter.distanceSquaredTo2D(myNet->getViewNet()->getPositionInformation()) < (snap_radius * snap_radius)) {
90 // move entire shape
91 return new GNEMoveOperation(this, myTAZCenter);
93 // move entire shape
94 return new GNEMoveOperation(this, myShape);
95 } else {
96 // calculate move shape operation
97 return calculateMoveShapeOperation(this, myShape, true);
98 }
99}
100
101
102int
103GNETAZ::getVertexIndex(Position pos, bool snapToGrid) {
104 // check if position has to be snapped to grid
105 if (snapToGrid) {
106 pos = myNet->getViewNet()->snapToActiveGrid(pos);
107 }
108 // first check if vertex already exists
109 for (const auto& shapePosition : myShape) {
110 if (shapePosition.distanceTo2D(pos) < myNet->getViewNet()->getVisualisationSettings().neteditSizeSettings.polygonGeometryPointRadius) {
111 return myShape.indexOfClosest(shapePosition);
112 }
113 }
114 return -1;
115}
116
117
118void
119GNETAZ::removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList) {
120 // get original shape
121 PositionVector shape = myShape;
122 // check shape size
123 if (shape.size() > 3) {
124 // obtain index
125 int index = shape.indexOfClosest(clickedPosition);
126 // get last index
127 const int lastIndex = ((int)shape.size() - 1);
128 // get snap radius
130 // check if we have to create a new index
131 if ((index != -1) && shape[index].distanceSquaredTo2D(clickedPosition) < (snap_radius * snap_radius)) {
132 // check if we're deleting the first point
133 if ((index == 0) || (index == lastIndex)) {
134 // remove both geometry point
135 shape.erase(shape.begin() + lastIndex);
136 shape.erase(shape.begin());
137 // close shape
138 shape.closePolygon();
139 } else {
140 // remove geometry point
141 shape.erase(shape.begin() + index);
142 }
143 // commit new shape
144 undoList->begin(this, "remove geometry point of " + getTagStr());
146 undoList->end();
147 }
148 }
149}
150
151
152void
154 // first open TAZ tag
155 device.openTag(SUMO_TAG_TAZ);
156 // write TAZ attributes
157 device.writeAttr(SUMO_ATTR_ID, getID());
161 }
162 if (myFill) {
163 device.writeAttr(SUMO_ATTR_FILL, true);
164 }
165 if (getShapeName().size() > 0) {
167 }
169 // sort all Source/Sinks by ID
170 std::map<std::pair<std::string, SumoXMLTag>, GNEAdditional*> sortedSourceSinks;
171 for (const auto& sourceSink : getChildAdditionals()) {
172 sortedSourceSinks[std::make_pair(sourceSink->getAttribute(SUMO_ATTR_EDGE), sourceSink->getTagProperty().getTag())] = sourceSink;
173 }
174 // write all TAZ Source/sinks
175 for (const auto& sortedSourceSink : sortedSourceSinks) {
176 sortedSourceSink.second->writeAdditional(device);
177 }
178 // write params
179 writeParams(device);
180 // close TAZ tag
181 device.closeTag();
182}
183
184
185bool
187 return true;
188}
189
190
191std::string
193 return "";
194}
195
196
197void
199 // nothing to fix
200}
201
202
203bool
205 // get edit modes
206 const auto& editModes = myNet->getViewNet()->getEditModes();
207 // check if we're in move mode
208 if (!myNet->getViewNet()->isCurrentlyMovingElements() && editModes.isCurrentSupermodeNetwork() &&
210 (editModes.networkEditMode == NetworkEditMode::NETWORK_MOVE) && myNet->getViewNet()->checkOverLockedElement(this, mySelected)) {
211 // only move the first element
213 } else {
214 return false;
215 }
216}
217
218
219void
221 // just update geometry
223 // update geometry of child plan elements
224 for (const auto& demandElements : getChildDemandElements()) {
225 demandElements->updateGeometry();
226 }
227 // update geometry of childTAZRelDatas
228 for (const auto& TAZRelData : getChildGenericDatas()) {
229 TAZRelData->updateGeometry();
230 }
231 myTesselation.clear();
232}
233
234
237 return myShape.getCentroid();
238}
239
240
241double
243 return s.polySize.getExaggeration(s, this);
244}
245
246
247void
248GNETAZ::updateCenteringBoundary(const bool updateGrid) {
249 // Remove object from net
250 if (updateGrid) {
252 for (const auto& TAZRelData : getChildGenericDatas()) {
253 myNet->removeGLObjectFromGrid(TAZRelData);
254 }
255 }
256 // use shape as boundary
258 // add center
261 }
262 // grow boundary
264 // add object into net
265 if (updateGrid) {
267 for (const auto& TAZRelData : getChildGenericDatas()) {
268 TAZRelData->updateGeometry();
269 myNet->addGLObjectIntoGrid(TAZRelData);
270 }
271 }
272}
273
274
275void
276GNETAZ::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
277 // Nothing to split
278}
279
280
281std::string
283 return myNet->getMicrosimID();
284}
285
286
289 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
290 buildPopupHeader(ret, app);
293 // build selection and show parameters menu
296 // create a extra FXMenuCommand if mouse is over a vertex
297 const int index = getVertexIndex(myNet->getViewNet()->getPositionInformation(), false);
298 if (index != -1) {
299 // check if we're in network mode
301 GUIDesigns::buildFXMenuCommand(ret, TL("Set custom Geometry Point"), nullptr, &parent, MID_GNE_CUSTOM_GEOMETRYPOINT);
302 }
303 }
304 return ret;
305}
306
307
308void
310 // first check if poly can be drawn
312 GUIPolygon::checkDraw(s, this, this)) {
313 // draw boundary
314 const auto boundary = getCenteringBoundary();
315 GLHelper::drawBoundary(s, boundary);
316 // get exaggeration
317 const double TAZExaggeration = getExaggeration(s);
318 // get detail level
319 const auto d = s.getDetailLevel(TAZExaggeration);
320 // draw geometry only if we'rent in drawForObjectUnderCursor mode
321 if (s.checkDrawPoly(boundary, isAttributeCarrierSelected())) {
322 // Obtain constants
323 const Position mousePosition = myNet->getViewNet()->getPositionInformation();
324 const bool drawFill = (myNet->getViewNet()->getEditModes().isCurrentSupermodeData() && myNet->getViewNet()->getDataViewOptions().TAZDrawFill()) ? true : getFill();
325 // get colors
326 const RGBColor color = GUIPolygon::setColor(s, this, this, drawUsingSelectColor(), -1);
327 const RGBColor darkerColor = color.changedBrightness(-32);
328 // push layer matrix
330 // translate to front
332 // check if we're drawing a polygon or a polyline
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 } else {
338 // push matrix
340 // set color
341 GLHelper::setColor(color);
342 // draw geometry (polyline)
344 // pop matrix
346 }
347 // draw contour if shape isn't blocked
349 // push contour matrix
351 // translate to front
352 glTranslated(0, 0, 0.1);
353 // set color
354 GLHelper::setColor(darkerColor);
355 // draw polygon contour
357 // pop contour matrix
359 // draw shape points only in Network supemode
361 // check if we're in move mode
363 // get geometry point sizes
364 const double geometryPointSize = s.neteditSizeSettings.polygonGeometryPointRadius * (moveMode ? 1 : 0.5);
365 // draw geometry points
366 GUIGeometry::drawGeometryPoints(d, myAdditionalGeometry.getShape(), darkerColor, geometryPointSize, TAZExaggeration,
368 // draw dotted contours for geometry points if we're in move mode
369 if (moveMode) {
371 TAZExaggeration, s.dottedContourSettings.segmentWidthSmall);
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::drawFilledCircleDetailled(d, centerRadius * 0.8);
391 // pop center matrix
393 // pop layer matrix
395 // draw lock icon
397 // draw name
399 // check if draw poly type
400 if (s.polyType.show(this)) {
403 }
404 // get contour width
406 // draw dotted contour
407 myAdditionalContour.drawDottedContours(s, d, this, contourWidth, true);
408 // draw TAZ Center dotted contour
409 myTAZCenterContour.drawDottedContours(s, d, this, contourWidth, true);
410 }
411 // draw demand element children
413 // calculate contour
415 calculateContourPolygons(s, d, getShapeLayer(), TAZExaggeration, true);
416 } else {
417 calculateContourPolygons(s, d, getShapeLayer(), TAZExaggeration, getFill());
418 }
419 // calculate contour for TAZ Center
421 }
422}
423
424
425std::string
427 switch (key) {
428 case SUMO_ATTR_ID:
429 return getMicrosimID();
430 case SUMO_ATTR_SHAPE:
431 return toString(myShape);
432 case SUMO_ATTR_CENTER:
434 return "";
435 } else {
436 return toString(myTAZCenter);
437 }
438 case SUMO_ATTR_COLOR:
439 return toString(getShapeColor());
440 case SUMO_ATTR_NAME:
441 return getShapeName();
442 case SUMO_ATTR_FILL:
443 return toString(myFill);
444 case SUMO_ATTR_EDGES: {
445 std::vector<std::string> edgeIDs;
446 for (const auto& TAZChild : getChildAdditionals()) {
447 edgeIDs.push_back(TAZChild->getAttribute(SUMO_ATTR_EDGE));
448 }
449 return toString(edgeIDs);
450 }
454 return getParametersStr();
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 }
487 return "undefined";
488 } else {
490 }
491 default:
492 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
493 }
494}
495
496
497double
499 switch (key) {
501 return myMinWeightSource;
503 return myMinWeightSink;
505 return myMaxWeightSource;
507 return myMaxWeightSink;
511 return myAverageWeightSink;
512 default:
513 throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
514 }
515}
516
517
520 switch (key) {
521 case SUMO_ATTR_CENTER:
522 return myTAZCenter;
524 return myShape.getCentroid();
525 default:
526 throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
527 }
528}
529
530
533 return getParametersMap();
534}
535
536
537void
538GNETAZ::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
539 if (value == getAttribute(key)) {
540 return; //avoid needless changes, later logic relies on the fact that attributes have changed
541 }
542 switch (key) {
543 case SUMO_ATTR_ID:
544 case SUMO_ATTR_SHAPE:
545 case SUMO_ATTR_CENTER:
546 case SUMO_ATTR_COLOR:
547 case SUMO_ATTR_NAME:
548 case SUMO_ATTR_FILL:
549 case SUMO_ATTR_EDGES:
552 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
553 break;
554 default:
555 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
556 }
557}
558
559
560bool
561GNETAZ::isValid(SumoXMLAttr key, const std::string& value) {
562 switch (key) {
563 case SUMO_ATTR_ID:
565 case SUMO_ATTR_SHAPE:
566 if (value.empty()) {
567 return false;
568 } else {
569 return canParse<PositionVector>(value);
570 }
571 case SUMO_ATTR_CENTER:
572 if (value.empty()) {
573 return true;
574 } else {
575 return canParse<Position>(value);
576 }
577 case SUMO_ATTR_COLOR:
578 return canParse<RGBColor>(value);
579 case SUMO_ATTR_NAME:
581 case SUMO_ATTR_FILL:
582 return canParse<bool>(value);
583 case SUMO_ATTR_EDGES:
584 if (value.empty()) {
585 return true;
586 } else {
588 }
590 return canParse<bool>(value);
592 return areParametersValid(value);
593 default:
594 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
595 }
596}
597
598
599std::string
601 return getTagStr() + ":" + getID();
602}
603
604
605std::string
607 return getTagStr();
608}
609
610
611void
613 // reset all statistic variables
620 // declare an extra variables for saving number of children
621 int numberOfSources = 0;
622 int numberOfSinks = 0;
623 // iterate over child additional
624 for (const auto& TAZChild : getChildAdditionals()) {
625 if (TAZChild->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) {
626 const double weight = TAZChild->getAttributeDouble(SUMO_ATTR_WEIGHT);
627 // check max Weight
628 if ((myMaxWeightSource == INVALID_DOUBLE) || (myMaxWeightSource < weight)) {
629 myMaxWeightSource = weight;
630 }
631 // check min Weight
632 if ((myMinWeightSource == INVALID_DOUBLE) || (weight < myMinWeightSource)) {
633 myMinWeightSource = weight;
634 }
635 // update Average
636 myAverageWeightSource += weight;
637 // update number of sources
638 numberOfSources++;
639 } else if (TAZChild->getTagProperty().getTag() == SUMO_TAG_TAZSINK) {
640 const double weight = TAZChild->getAttributeDouble(SUMO_ATTR_WEIGHT);
641 // check max Weight
642 if ((myMaxWeightSink == INVALID_DOUBLE) || myMaxWeightSink < weight) {
643 myMaxWeightSink = weight;
644 }
645 // check min Weight
646 if ((myMinWeightSink == INVALID_DOUBLE) || (weight < myMinWeightSink)) {
647 myMinWeightSink = weight;
648 }
649 // update Average
650 myAverageWeightSink += weight;
651 // update number of sinks
652 numberOfSinks++;
653 }
654 }
655 // calculate average
656 if (numberOfSources > 0) {
657 myAverageWeightSource /= numberOfSources;
658 }
659 if (numberOfSinks > 0) {
660 myAverageWeightSink /= numberOfSinks;
661 }
662}
663
664// ===========================================================================
665// private
666// ===========================================================================
667
668void
669GNETAZ::setAttribute(SumoXMLAttr key, const std::string& value) {
670 switch (key) {
671 case SUMO_ATTR_ID:
672 // update microsimID
673 setAdditionalID(value);
674 break;
675 case SUMO_ATTR_SHAPE: {
676 const bool updateCenter = (myTAZCenter == myShape.getCentroid());
677 // set new shape
678 myShape = parse<PositionVector>(value);
679 // always close shape
680 if ((myShape.size() > 1) && (myShape.front() != myShape.back())) {
681 myShape.push_back(myShape.front());
682 }
683 // update center
684 if (myShape.size() == 0) {
685 myTAZCenter = Position(0, 0, 0);
686 } else if (updateCenter) {
688 }
689 // update geometry
691 // update centering boundary
692 if (!isTemplate()) {
694 }
695 break;
696 }
697 case SUMO_ATTR_CENTER:
698 if (value.empty()) {
700 } else {
701 myTAZCenter = parse<Position>(value);
702 }
703 // update geometry
705 // update centering boundary
706 if (!isTemplate()) {
708 }
709 break;
710 case SUMO_ATTR_COLOR:
711 setShapeColor(parse<RGBColor>(value));
712 break;
713 case SUMO_ATTR_NAME:
714 setShapeName(value);
715 break;
716 case SUMO_ATTR_FILL:
717 myFill = parse<bool>(value);
719 break;
720 case SUMO_ATTR_EDGES:
721 break;
723 if (parse<bool>(value)) {
725 } else {
727 }
728 break;
730 setParametersStr(value);
731 break;
732 default:
733 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
734 }
735}
736
737
738void
741 // update new center
742 myTAZCenter = moveResult.shapeToUpdate.front();
744 // update new shape and center
746 myShape = moveResult.shapeToUpdate;
747 // update geometry
749 } else {
750 // get lastIndex
751 const int lastIndex = (int)moveResult.shapeToUpdate.size() - 1;
752 // update new shape
753 myShape = moveResult.shapeToUpdate;
754 // adjust first and last position
755 if (moveResult.geometryPointsToMove.front() == 0) {
756 myShape[lastIndex] = moveResult.shapeToUpdate[0];
757 } else if (moveResult.geometryPointsToMove.front() == lastIndex) {
758 myShape[0] = moveResult.shapeToUpdate[lastIndex];
759 }
761 // update geometry
763 }
764 myTesselation.clear();
765}
766
767
768void
769GNETAZ::commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) {
771 // commit center
772 undoList->begin(this, "moving " + toString(SUMO_ATTR_CENTER) + " of " + getTagStr());
774 undoList->end();
776 // calculate offset between old and new shape
777 Position newCenter = myTAZCenter;
778 newCenter.add(moveResult.shapeToUpdate.getCentroid() - myShape.getCentroid());
779 // commit new shape and center
780 undoList->begin(this, "moving " + toString(SUMO_ATTR_SHAPE) + " of " + getTagStr());
783 undoList->end();
784 } else {
785 // get lastIndex
786 const int lastIndex = (int)moveResult.shapeToUpdate.size() - 1;
787 // close shapeToUpdate
788 auto closedShape = moveResult.shapeToUpdate;
789 // adjust first and last position
790 if (moveResult.geometryPointsToMove.front() == 0) {
791 closedShape[lastIndex] = moveResult.shapeToUpdate[0];
792 } else if (moveResult.geometryPointsToMove.front() == lastIndex) {
793 closedShape[0] = moveResult.shapeToUpdate[lastIndex];
794 }
795 // commit new shape
796 undoList->begin(this, "moving " + toString(SUMO_ATTR_SHAPE) + " of " + getTagStr());
798 undoList->end();
799 }
800}
801
802/****************************************************************************/
@ NETWORK_MOVE
mode for moving network elements
@ MID_GNE_CUSTOM_GEOMETRYPOINT
set custom geometry point
@ GLO_JUNCTION
a junction
@ GLO_TAZ
Traffic Assignment Zones (TAZs)
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
#define TL(string)
Definition MsgHandler.h:315
@ SUMO_TAG_TAZ
a traffic assignment zone
@ SUMO_TAG_TAZSINK
a sink within a district (connection road)
@ SUMO_TAG_TAZSOURCE
a source within a district (connection road)
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ GNE_ATTR_MAX_SOURCE
max source (used only by TAZs)
@ SUMO_ATTR_EDGE
@ GNE_ATTR_MAX_SINK
max sink (used only by TAZs)
@ GNE_ATTR_AVERAGE_SINK
average sink (used only by TAZs)
@ GNE_ATTR_SELECTED
element is selected
@ GNE_ATTR_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
@ 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:343
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:654
static void popMatrix()
pop matrix
Definition GLHelper.cpp:130
static void drawBoundary(const GUIVisualizationSettings &s, const Boundary &b)
Draw a boundary (used for debugging)
Definition GLHelper.cpp:966
static void drawFilledCircleDetailled(const GUIVisualizationSettings::Detail d, const double radius)
Draws a filled circle around (0,0) depending of level of detail.
Definition GLHelper.cpp:539
static void pushMatrix()
push matrix
Definition GLHelper.cpp:117
static void drawTextSettings(const GUIVisualizationTextSettings &settings, const std::string &text, const Position &pos, const double scale, const double angle=0, const double layer=2048, const int align=0)
Definition GLHelper.cpp:787
An Element which don't belong to GNENet but has influence in the simulation.
bool isValidAdditionalID(const std::string &value) const
check if a new additional ID is valid
virtual void writeAdditional(OutputDevice &device) const =0
write additional element into a xml file
void setAdditionalID(const std::string &newID)
set additional ID
GNEContour myAdditionalContour
variable used for draw additional contours
GUIGeometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
bool checkDrawFromContour() const
check if draw from contour (green)
void 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 (instead of GUIGlObjectStorage)
const std::string & getTagStr() const
get tag assigned to this object in string format
bool isTemplate() const
check if this AC is template
void unselectAttributeCarrier(const bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
GNENet * myNet
pointer to net
void selectAttributeCarrier(const bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
void calculateContourCircleShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const Position &pos, double radius, const double layer, const double scale) const
calculate contour (circle elements)
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 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 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 GUIGlObject *obj, const PositionVector originalShape, const bool maintainShapeClosed)
calculate move shape operation
bool getMoveWholePolygons() const
move whole polygons
NetworkModeOptions * getNetworkModeOptions() const
get network mode options
move operation
move result
const GNEMoveOperation::OperationType operationType
move operation
std::vector< int > geometryPointsToMove
shape points to move (of shapeToMove)
PositionVector shapeToUpdate
shape to update (edited in moveElement)
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
void addGLObjectIntoGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1386
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1396
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2155
Position getPositionInView() const
Returns position of additional in view.
Definition GNETAZ.cpp:236
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
Definition GNETAZ.cpp:248
std::string getAdditionalProblem() const
return a string with the current additional problem (must be reimplemented in all detector children)
Definition GNETAZ.cpp:192
double myMaxWeightSink
Max Sink weight.
Definition GNETAZ.h:218
Position myTAZCenter
TAZ center.
Definition GNETAZ.h:196
static const double myHintSize
hint size of vertex
Definition GNETAZ.h:203
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition GNETAZ.cpp:309
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition GNETAZ.cpp:600
GNEContour myTAZCenterContour
TAZ center contour.
Definition GNETAZ.h:199
bool isAdditionalValid() const
check if current additional is valid to be written into XML (must be reimplemented in all detector ch...
Definition GNETAZ.cpp:186
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
Definition GNETAZ.cpp:242
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Definition GNETAZ.cpp:276
Position getAttributePosition(SumoXMLAttr key) const
Definition GNETAZ.cpp:519
~GNETAZ()
GNETAZ Destructor.
Definition GNETAZ.cpp:81
double myAverageWeightSource
Average source weight.
Definition GNETAZ.h:215
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition GNETAZ.cpp:739
void updateGeometry()
update pre-computed geometry information
Definition GNETAZ.cpp:220
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their correspondent attribute are valids
Definition GNETAZ.cpp:561
double myMinWeightSink
Min Sink weight.
Definition GNETAZ.h:221
GNEMoveOperation * getMoveOperation()
get move operation
Definition GNETAZ.cpp:85
double myAverageWeightSink
Average Sink weight.
Definition GNETAZ.h:224
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition GNETAZ.cpp:606
std::string getParentName() const
Returns the name of the parent object.
Definition GNETAZ.cpp:282
void fixAdditionalProblem()
fix additional problem (must be reimplemented in all detector children)
Definition GNETAZ.cpp:198
void writeAdditional(OutputDevice &device) const
write additional element into a xml file
Definition GNETAZ.cpp:153
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
Definition GNETAZ.cpp:119
std::string getAttribute(SumoXMLAttr key) const
Definition GNETAZ.cpp:426
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition GNETAZ.cpp:288
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:538
static const double myHintSizeSquared
squaredhint size of vertex
Definition GNETAZ.h:206
void updateTAZStatistic()
update TAZ Statistic
Definition GNETAZ.cpp:612
double myMinWeightSource
Min source weight.
Definition GNETAZ.h:212
int getVertexIndex(Position pos, bool snapToGrid)
return index of a vertex of shape, or of a new vertex if position is over an shape's edge
Definition GNETAZ.cpp:103
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition GNETAZ.cpp:769
const Parameterised::Map & getACParametersMap() const
get parameters map
Definition GNETAZ.cpp:532
double getAttributeDouble(SumoXMLAttr key) const
Definition GNETAZ.cpp:498
double myMaxWeightSource
Max source weight.
Definition GNETAZ.h:209
bool checkDrawMoveContour() const
check if draw move contour (red)
Definition GNETAZ.cpp:204
GNETAZ(GNENet *net)
@default GNETAZ Constructor
Definition GNETAZ.cpp:49
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
const GUIGlObject * getGUIGlObjectFront() const
get front 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
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, double typeOrLayer, const double extraOffset=0)
draw front attributeCarrier
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
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
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.
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
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.
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:281
static const Position INVALID
used to indicate that a position is valid
Definition Position.h:322
double x() const
Returns the x-position.
Definition Position.h:55
void add(const Position &pos)
Adds the given position to this one.
Definition Position.h:132
double y() const
Returns the y-position.
Definition Position.h:60
A list of positions.
Position getPolygonCenter() const
Returns the arithmetic of all corner points.
void closePolygon()
ensures that the last position equals the first
int indexOfClosest(const Position &p, bool twoD=false) const
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
Position getCentroid() const
Returns the centroid (closes the polygon if unclosed)
static const RGBColor BLACK
Definition RGBColor.h:193
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition RGBColor.cpp:200
PositionVector myShape
The positions of the polygon.
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)
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
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