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 }
452 return getParametersStr();
455 return "undefined";
456 } else {
458 }
461 return "undefined";
462 } else {
464 }
467 return "undefined";
468 } else {
470 }
473 return "undefined";
474 } else {
476 }
479 return "undefined";
480 } else {
482 }
485 return "undefined";
486 } else {
488 }
489 default:
490 return getCommonAttribute(key);
491 }
492}
493
494
495double
497 switch (key) {
499 return myMinWeightSource;
501 return myMinWeightSink;
503 return myMaxWeightSource;
505 return myMaxWeightSink;
509 return myAverageWeightSink;
510 default:
511 throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
512 }
513}
514
515
518 switch (key) {
519 case SUMO_ATTR_CENTER:
520 return myTAZCenter;
522 return myShape.getCentroid();
523 default:
524 throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
525 }
526}
527
528
531 return getParametersMap();
532}
533
534
535void
536GNETAZ::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
537 if (value == getAttribute(key)) {
538 return; //avoid needless changes, later logic relies on the fact that attributes have changed
539 }
540 switch (key) {
541 case SUMO_ATTR_ID:
542 case SUMO_ATTR_SHAPE:
543 case SUMO_ATTR_CENTER:
544 case SUMO_ATTR_COLOR:
545 case SUMO_ATTR_NAME:
546 case SUMO_ATTR_FILL:
547 case SUMO_ATTR_EDGES:
549 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
550 break;
551 default:
552 setCommonAttribute(key, value, undoList);
553 break;
554 }
555}
556
557
558bool
559GNETAZ::isValid(SumoXMLAttr key, const std::string& value) {
560 switch (key) {
561 case SUMO_ATTR_ID:
563 case SUMO_ATTR_SHAPE:
564 if (value.empty()) {
565 return false;
566 } else {
567 return canParse<PositionVector>(value);
568 }
569 case SUMO_ATTR_CENTER:
570 if (value.empty()) {
571 return true;
572 } else {
573 return canParse<Position>(value);
574 }
575 case SUMO_ATTR_COLOR:
576 return canParse<RGBColor>(value);
577 case SUMO_ATTR_NAME:
579 case SUMO_ATTR_FILL:
580 return canParse<bool>(value);
581 case SUMO_ATTR_EDGES:
582 if (value.empty()) {
583 return true;
584 } else {
586 }
588 return areParametersValid(value);
589 default:
590 return isCommonValid(key, value);
591 }
592}
593
594
595std::string
597 return getTagStr() + ":" + getID();
598}
599
600
601std::string
603 return getTagStr();
604}
605
606
607void
609 // reset all statistic variables
616 // declare an extra variables for saving number of children
617 int numberOfSources = 0;
618 int numberOfSinks = 0;
619 // iterate over child additional
620 for (const auto& TAZChild : getChildAdditionals()) {
621 if (TAZChild->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) {
622 const double weight = TAZChild->getAttributeDouble(SUMO_ATTR_WEIGHT);
623 // check max Weight
624 if ((myMaxWeightSource == INVALID_DOUBLE) || (myMaxWeightSource < weight)) {
625 myMaxWeightSource = weight;
626 }
627 // check min Weight
628 if ((myMinWeightSource == INVALID_DOUBLE) || (weight < myMinWeightSource)) {
629 myMinWeightSource = weight;
630 }
631 // update Average
632 myAverageWeightSource += weight;
633 // update number of sources
634 numberOfSources++;
635 } else if (TAZChild->getTagProperty().getTag() == SUMO_TAG_TAZSINK) {
636 const double weight = TAZChild->getAttributeDouble(SUMO_ATTR_WEIGHT);
637 // check max Weight
638 if ((myMaxWeightSink == INVALID_DOUBLE) || myMaxWeightSink < weight) {
639 myMaxWeightSink = weight;
640 }
641 // check min Weight
642 if ((myMinWeightSink == INVALID_DOUBLE) || (weight < myMinWeightSink)) {
643 myMinWeightSink = weight;
644 }
645 // update Average
646 myAverageWeightSink += weight;
647 // update number of sinks
648 numberOfSinks++;
649 }
650 }
651 // calculate average
652 if (numberOfSources > 0) {
653 myAverageWeightSource /= numberOfSources;
654 }
655 if (numberOfSinks > 0) {
656 myAverageWeightSink /= numberOfSinks;
657 }
658}
659
660// ===========================================================================
661// private
662// ===========================================================================
663
664void
665GNETAZ::setAttribute(SumoXMLAttr key, const std::string& value) {
666 switch (key) {
667 case SUMO_ATTR_ID:
668 // update microsimID
669 setAdditionalID(value);
670 break;
671 case SUMO_ATTR_SHAPE: {
672 const bool updateCenter = (myTAZCenter == myShape.getCentroid());
673 // set new shape
674 myShape = parse<PositionVector>(value);
675 // always close shape
676 if ((myShape.size() > 1) && (myShape.front() != myShape.back())) {
677 myShape.push_back(myShape.front());
678 }
679 // update center
680 if (myShape.size() == 0) {
681 myTAZCenter = Position(0, 0, 0);
682 } else if (updateCenter) {
684 }
685 // update geometry
687 // update centering boundary
688 if (!isTemplate()) {
690 }
691 break;
692 }
693 case SUMO_ATTR_CENTER:
694 if (value.empty()) {
696 } else {
697 myTAZCenter = parse<Position>(value);
698 }
699 // update geometry
701 // update centering boundary
702 if (!isTemplate()) {
704 }
705 break;
706 case SUMO_ATTR_COLOR:
707 setShapeColor(parse<RGBColor>(value));
708 break;
709 case SUMO_ATTR_NAME:
710 setShapeName(value);
711 break;
712 case SUMO_ATTR_FILL:
713 myFill = parse<bool>(value);
715 break;
716 case SUMO_ATTR_EDGES:
717 break;
719 setParametersStr(value);
720 break;
721 default:
722 setCommonAttribute(key, value);
723 break;
724 }
725}
726
727
728void
731 // update new center
732 myTAZCenter = moveResult.shapeToUpdate.front();
734 // update new shape and center
736 myShape = moveResult.shapeToUpdate;
737 // update geometry
739 } else {
740 // get lastIndex
741 const int lastIndex = (int)moveResult.shapeToUpdate.size() - 1;
742 // update new shape
743 myShape = moveResult.shapeToUpdate;
744 // adjust first and last position
745 if (moveResult.geometryPointsToMove.front() == 0) {
746 myShape[lastIndex] = moveResult.shapeToUpdate[0];
747 } else if (moveResult.geometryPointsToMove.front() == lastIndex) {
748 myShape[0] = moveResult.shapeToUpdate[lastIndex];
749 }
751 // update geometry
753 }
754 myTesselation.clear();
755}
756
757
758void
759GNETAZ::commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) {
761 // commit center
762 undoList->begin(this, "moving " + toString(SUMO_ATTR_CENTER) + " of " + getTagStr());
764 undoList->end();
766 // calculate offset between old and new shape
767 Position newCenter = myTAZCenter;
768 newCenter.add(moveResult.shapeToUpdate.getCentroid() - myShape.getCentroid());
769 // commit new shape and center
770 undoList->begin(this, "moving " + toString(SUMO_ATTR_SHAPE) + " of " + getTagStr());
773 undoList->end();
774 } else {
775 // get lastIndex
776 const int lastIndex = (int)moveResult.shapeToUpdate.size() - 1;
777 // close shapeToUpdate
778 auto closedShape = moveResult.shapeToUpdate;
779 // adjust first and last position
780 if (moveResult.geometryPointsToMove.front() == 0) {
781 closedShape[lastIndex] = moveResult.shapeToUpdate[0];
782 } else if (moveResult.geometryPointsToMove.front() == lastIndex) {
783 closedShape[0] = moveResult.shapeToUpdate[lastIndex];
784 }
785 // commit new shape
786 undoList->begin(this, "moving " + toString(SUMO_ATTR_SHAPE) + " of " + getTagStr());
788 undoList->end();
789 }
790}
791
792/****************************************************************************/
@ 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_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: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:961
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:782
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 (more quickly as checking GUIGlObjectStorage)
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.
bool isCommonValid(SumoXMLAttr key, const std::string &value)
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
std::string getCommonAttribute(SumoXMLAttr key) const
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 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:1390
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1400
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2163
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:596
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:517
~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:729
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:559
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:602
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:536
static const double myHintSizeSquared
squaredhint size of vertex
Definition GNETAZ.h:206
void updateTAZStatistic()
update TAZ Statistic
Definition GNETAZ.cpp:608
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:759
const Parameterised::Map & getACParametersMap() const
get parameters map
Definition GNETAZ.cpp:530
double getAttributeDouble(SumoXMLAttr key) const
Definition GNETAZ.cpp:496
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
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