Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEContainer.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// Representation of containers in netedit
19/****************************************************************************/
21#include <netedit/GNENet.h>
22#include <netedit/GNEUndoList.h>
23#include <netedit/GNEViewNet.h>
29
30#include "GNEContainer.h"
31#include "GNERouteHandler.h"
32
33// ===========================================================================
34// FOX callback mapping
35// ===========================================================================
36
40
44
45// Object implementation
46FXIMPLEMENT(GNEContainer::GNEContainerPopupMenu, GUIGLObjectPopupMenu, containerPopupMenuMap, ARRAYNUMBER(containerPopupMenuMap))
47FXIMPLEMENT(GNEContainer::GNESelectedContainersPopupMenu, GUIGLObjectPopupMenu, selectedContainersPopupMenuMap, ARRAYNUMBER(selectedContainersPopupMenuMap))
48
49// ===========================================================================
50// GNEContainer::GNEContainerPopupMenu
51// ===========================================================================
52
54 GUIGLObjectPopupMenu(app, parent, *container),
55 myContainer(container),
56 myTransformToContainer(nullptr),
57 myTransformToContainerFlow(nullptr) {
58 // build header
59 myContainer->buildPopupHeader(this, app);
60 // build menu command for center button and copy cursor position to clipboard
61 myContainer->buildCenterPopupEntry(this);
62 myContainer->buildPositionCopyEntry(this, app);
63 // build menu commands for names
64 GUIDesigns::buildFXMenuCommand(this, ("Copy " + myContainer->getTagStr() + " name to clipboard").c_str(), nullptr, this, MID_COPY_NAME);
65 GUIDesigns::buildFXMenuCommand(this, ("Copy " + myContainer->getTagStr() + " typed name to clipboard").c_str(), nullptr, this, MID_COPY_TYPED_NAME);
66 new FXMenuSeparator(this);
67 // build selection and show parameters menu
68 myContainer->getNet()->getViewNet()->buildSelectionACPopupEntry(this, myContainer);
69 myContainer->buildShowParamsPopupEntry(this);
70 // add transform functions only in demand mode
71 if (myContainer->getNet()->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
72 // create menu pane for transform operations
73 FXMenuPane* transformOperation = new FXMenuPane(this);
74 this->insertMenuPaneChild(transformOperation);
75 new FXMenuCascade(this, "transform to", nullptr, transformOperation);
76 // Create menu comands for all transformations
77 myTransformToContainer = GUIDesigns::buildFXMenuCommand(transformOperation, "Container", GUIIconSubSys::getIcon(GUIIcon::CONTAINER), this, MID_GNE_CONTAINER_TRANSFORM);
78 myTransformToContainerFlow = GUIDesigns::buildFXMenuCommand(transformOperation, "ContainerFlow", GUIIconSubSys::getIcon(GUIIcon::CONTAINERFLOW), this, MID_GNE_CONTAINER_TRANSFORM);
79 // check what menu command has to be disabled
80 if (myContainer->getTagProperty().getTag() == SUMO_TAG_CONTAINER) {
81 myTransformToContainer->disable();
82 } else if (myContainer->getTagProperty().getTag() == SUMO_TAG_CONTAINERFLOW) {
83 myTransformToContainerFlow->disable();
84 }
85 }
86}
87
88
90
91
92long
93GNEContainer::GNEContainerPopupMenu::onCmdTransform(FXObject* obj, FXSelector, void*) {
94 if (obj == myTransformToContainer) {
96 } else if (obj == myTransformToContainerFlow) {
98 }
99 return 1;
100}
101
102
103// ===========================================================================
104// GNEContainer::GNESelectedContainersPopupMenu
105// ===========================================================================
106
107GNEContainer::GNESelectedContainersPopupMenu::GNESelectedContainersPopupMenu(GNEContainer* container, const std::vector<GNEContainer*>& selectedContainer, GUIMainWindow& app, GUISUMOAbstractView& parent) :
108 GUIGLObjectPopupMenu(app, parent, *container),
109 myContainerTag(container->getTagProperty().getTag()),
110 mySelectedContainers(selectedContainer),
111 myTransformToContainer(nullptr),
112 myTransformToContainerFlow(nullptr) {
113 // build header
114 container->buildPopupHeader(this, app);
115 // build menu command for center button and copy cursor position to clipboard
116 container->buildCenterPopupEntry(this);
117 container->buildPositionCopyEntry(this, app);
118 // build menu commands for names
119 GUIDesigns::buildFXMenuCommand(this, ("Copy " + container->getTagStr() + " name to clipboard").c_str(), nullptr, this, MID_COPY_NAME);
120 GUIDesigns::buildFXMenuCommand(this, ("Copy " + container->getTagStr() + " typed name to clipboard").c_str(), nullptr, this, MID_COPY_TYPED_NAME);
121 new FXMenuSeparator(this);
122 // build selection and show parameters menu
123 container->getNet()->getViewNet()->buildSelectionACPopupEntry(this, container);
124 container->buildShowParamsPopupEntry(this);
125 // add transform functions only in demand mode
126 if (container->getNet()->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
127 // create menu pane for transform operations
128 FXMenuPane* transformOperation = new FXMenuPane(this);
129 this->insertMenuPaneChild(transformOperation);
130 new FXMenuCascade(this, "transform to", nullptr, transformOperation);
131 // Create menu comands for all transformations
134 }
135}
136
137
139
140
141long
143 // iterate over all selected containers
144 for (const auto& container : mySelectedContainers) {
145 if ((obj == myTransformToContainer) &&
146 (container->getTagProperty().getTag() == myContainerTag)) {
148 } else if ((obj == myTransformToContainerFlow) &&
149 (container->getTagProperty().getTag() == myContainerTag)) {
151 }
152 }
153 return 1;
154}
155
156// ===========================================================================
157// member method definitions
158// ===========================================================================
159
162 GNEPathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {}, {}),
164 // reset default values
166 // set end and container per hours as default flow values
169}
170
171
173 GNEDemandElement(containerparameters.id, net, (tag == SUMO_TAG_CONTAINERFLOW) ? GLO_CONTAINERFLOW : GLO_CONTAINER, tag,
175 GNEPathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {pType}, {}),
176GNEDemandElementFlow(this, containerparameters) {
177 // set manually vtypeID (needed for saving)
178 vtypeid = pType->getID();
179}
180
181
183
184
187 const auto firstContainerPlan = getChildDemandElements().front();
188 // check first container plan
189 if (firstContainerPlan->getTagProperty().isPlanStopContainer()) {
190 return nullptr;
191 } else if (firstContainerPlan->getParentEdges().size() > 0) {
192 // get lane
193 const GNELane* lane = firstContainerPlan->getParentEdges().front()->getLaneByAllowedVClass(getVClass());
194 // declare departPos
195 double posOverLane = 0;
196 if (canParse<double>(getDepartPos())) {
197 posOverLane = parse<double>(getDepartPos());
198 }
199 // return move operation
200 return new GNEMoveOperation(this, lane, posOverLane, false);
201 } else {
202 return nullptr;
203 }
204}
205
206
207void
209 // attribute VType musn't be written if is DEFAULT_PEDTYPE_ID
211 // unset VType parameter
212 parametersSet &= ~VEHPARS_VTYPE_SET;
213 // write container attributes (VType will not be written)
215 // set VType parameter again
217 } else {
218 // write container attributes, including VType
220 }
221 // write flow attributes
222 writeFlowAttributes(this, device);
223 // write parameters
224 writeParams(device);
225 // write child demand elements associated to this container (Rides, Walks...)
226 for (const auto& containerPlan : getChildDemandElements()) {
227 containerPlan->writeDemandElement(device);
228 }
229 // close container tag
230 device.closeTag();
231}
232
233
236 if (getChildDemandElements().size() == 0) {
237 return Problem::NO_PLANS;
238 } else {
239 return Problem::OK;
240 }
241}
242
243
244std::string
246 if (getChildDemandElements().size() == 0) {
247 return "Container needs at least one plan";
248 } else {
249 return "";
250 }
251}
252
253
254void
256 // nothing to fix
257}
258
259
262 return getParentDemandElements().front()->getVClass();
263}
264
265
266const RGBColor&
268 return color;
269}
270
271
272void
274 // only update geometry of childrens
275 for (const auto& demandElement : getChildDemandElements()) {
276 demandElement->updateGeometry();
277 }
278}
279
280
285
286
289 // return a GNEContainerPopupMenu
290 return new GNEContainerPopupMenu(this, app, parent);
291}
292
293
294std::string
296 return getParentDemandElements().front()->getID();
297}
298
299
300double
304
305
308 Boundary containerBoundary;
309 if (getChildDemandElements().size() > 0) {
310 if (getChildDemandElements().front()->getTagProperty().isPlanStopContainer()) {
311 // use boundary of stop center
312 return getChildDemandElements().front()->getCenteringBoundary();
313 } else {
314 containerBoundary.add(getPositionInView());
315 }
316 } else {
317 containerBoundary = Boundary(-0.1, -0.1, 0.1, 0.1);
318 }
319 containerBoundary.grow(20);
320 return containerBoundary;
321}
322
323
324void
325GNEContainer::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/,
326 const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
327 // geometry of this element cannot be splitted
328}
329
330
331void
333 bool drawContainer = true;
334 // check if container can be drawn
336 drawContainer = false;
338 drawContainer = false;
340 drawContainer = false;
341 } else if (getChildDemandElements().empty()) {
342 drawContainer = false;
343 }
344 // continue if container can be drawn
345 if (drawContainer) {
346 // obtain exaggeration (and add the special containerExaggeration)
347 const double exaggeration = getExaggeration(s) + 10;
348 // get detail level
349 const auto d = s.getDetailLevel(exaggeration);
350 // obtain position
351 const Position containerPosition = getAttributePosition(SUMO_ATTR_DEPARTPOS);
352 if (containerPosition == Position::INVALID) {
353 return;
354 }
355 // draw geometry only if we'rent in drawForObjectUnderCursor mode
357 // obtain img file
358 const std::string file = getTypeParent()->getAttribute(SUMO_ATTR_IMGFILE);
359 // push draw matrix
361 // Start with the drawing of the area traslating matrix to origin
363 // translate and rotate
364 glTranslated(containerPosition.x(), containerPosition.y(), 0);
365 glRotated(90, 0, 0, 1);
366 // set container color
368 // set scale
369 glScaled(exaggeration, exaggeration, 1);
370 // draw container depending of detail level
371 switch (s.containerQuality) {
372 case 0:
373 case 1:
374 case 2:
376 break;
377 case 3:
378 default:
380 break;
381 }
382 // pop matrix
384 // draw line between junctions if container plan isn't valid
385 for (const auto& containerPlan : getChildDemandElements()) {
386 if (containerPlan->getTagProperty().isPlanContainer() && (containerPlan->getParentJunctions().size() > 0) &&
387 !myNet->getDemandPathManager()->isPathValid(containerPlan)) {
388 drawJunctionLine(containerPlan);
389 }
390 }
391 // draw stack label
392 if (myStackedLabelNumber > 0) {
393 drawStackLabel(myStackedLabelNumber, "container", Position(containerPosition.x() - 2.5, containerPosition.y() - 0.8), -90, 1.3, 5, getExaggeration(s));
395 // declare counter for stacked containers over stops
396 int stackedCounter = 0;
397 // get stoppingPlace
398 const auto stoppingPlace = getChildDemandElements().front()->getParentAdditionals().front();
399 // get stacked containers
400 for (const auto& stopContainer : stoppingPlace->getChildDemandElements()) {
401 if (stopContainer->getTagProperty().getTag() == GNE_TAG_STOPCONTAINER_CONTAINERSTOP) {
402 // get container parent
403 const auto containerParent = stopContainer->getParentDemandElements().front();
404 // check if the stop if the first container plan parent
405 if (stopContainer->getPreviousChildDemandElement(containerParent) == nullptr) {
406 stackedCounter++;
407 }
408 }
409 }
410 // if we have more than two stacked elements, draw label
411 if (stackedCounter > 1) {
412 drawStackLabel(stackedCounter, "container", Position(containerPosition.x() - 2.5, containerPosition.y() - 0.8), -90, 1.3, 5, getExaggeration(s));
413 }
414 }
415 // draw flow label
416 if (myTagProperty.isFlow()) {
417 drawFlowLabel(Position(containerPosition.x() - 1, containerPosition.y() - 4.25), -90, 1.8, 2, getExaggeration(s));
418 }
419 // draw name
420 drawName(containerPosition, s.scale, s.containerName, s.angle);
421 // draw lock icon
423 // draw dotted contour
425 }
426 // calculate contour
427 myContainerContour.calculateContourRectangleShape(s, d, this, containerPosition, 0.5, 0.18, getType(), -5.5, 0, 0, exaggeration, nullptr);
428 }
429}
430
431
432void
434 // compute all container plan children (because aren't computed in "computeDemandElements()")
435 for (const auto& demandElement : getChildDemandElements()) {
436 demandElement->computePathElement();
437 }
438}
439
440
441void
442GNEContainer::drawLanePartialGL(const GUIVisualizationSettings& /*s*/, const GNESegment* /*segment*/, const double /*offsetFront*/) const {
443 // Stops don't use drawJunctionPartialGL
444}
445
446
447void
448GNEContainer::drawJunctionPartialGL(const GUIVisualizationSettings& /*s*/, const GNESegment* /*segment*/, const double /*offsetFront*/) const {
449 // Stops don't use drawJunctionPartialGL
450}
451
452
453GNELane*
455 // use path lane of first container plan
456 return getChildDemandElements().front()->getFirstPathLane();
457}
458
459
460GNELane*
462 // use path lane of first container plan
463 return getChildDemandElements().front()->getLastPathLane();
464}
465
466
467std::string
469 // declare string error
470 std::string error;
471 switch (key) {
472 case SUMO_ATTR_ID:
473 return getMicrosimID();
474 case SUMO_ATTR_TYPE:
475 return getTypeParent()->getID();
476 case SUMO_ATTR_COLOR:
478 return toString(color);
479 } else {
481 }
484 return getDepartPos();
485 } else {
487 }
488 // Other
490 return getParametersStr();
491 default:
492 return getFlowAttribute(this, key);
493 }
494}
495
496
497double
499 switch (key) {
502 return departPos;
503 } else {
504 return 0;
505 }
506 default:
507 return getFlowAttributeDouble(key);
508 }
509}
510
511
514 switch (key) {
515 case SUMO_ATTR_DEPARTPOS: {
516 // first check number of child demand elements
517 if (getChildDemandElements().empty()) {
518 return Position();
519 }
520 // get container plan
521 const GNEDemandElement* containerPlan = getChildDemandElements().front();
522 // first check if first container plan is a stop
523 if (containerPlan->getTagProperty().isPlanStopContainer()) {
524 // stop center
525 return containerPlan->getPositionInView();
526 } else if (containerPlan->getTagProperty().planFromTAZ()) {
527 // TAZ
528 if (containerPlan->getParentAdditionals().front()->getAttribute(SUMO_ATTR_CENTER).empty()) {
529 return containerPlan->getParentAdditionals().front()->getAttributePosition(GNE_ATTR_TAZ_CENTROID);
530 } else {
531 return containerPlan->getParentAdditionals().front()->getAttributePosition(SUMO_ATTR_CENTER);
532 }
533 } else if (containerPlan->getTagProperty().planFromJunction()) {
534 // juncrtion
535 return containerPlan->getParentJunctions().front()->getPositionInView();
536 } else {
538 }
539 }
540 default:
541 throw InvalidArgument(getTagStr() + " doesn't have a Position attribute of type '" + toString(key) + "'");
542 }
543}
544
545
546void
547GNEContainer::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
548 switch (key) {
549 case SUMO_ATTR_ID:
550 case SUMO_ATTR_TYPE:
551 case SUMO_ATTR_COLOR:
553 // Other
555 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
556 break;
557 default:
558 setFlowAttribute(this, key, value, undoList);
559 break;
560 }
561}
562
563
564bool
565GNEContainer::isValid(SumoXMLAttr key, const std::string& value) {
566 // declare string error
567 std::string error;
568 switch (key) {
569 case SUMO_ATTR_ID:
571 case SUMO_ATTR_TYPE:
572 return (myNet->getAttributeCarriers()->retrieveDemandElements(NamespaceIDs::types, value, false) != nullptr);
573 case SUMO_ATTR_COLOR:
574 return canParse<RGBColor>(value);
575 case SUMO_ATTR_DEPARTPOS: {
576 double dummyDepartPos;
577 DepartPosDefinition dummyDepartPosProcedure;
578 parseDepartPos(value, myTagProperty.getTagStr(), id, dummyDepartPos, dummyDepartPosProcedure, error);
579 // if error is empty, given value is valid
580 return error.empty();
581 }
582 // Other
585 default:
586 return isValidFlowAttribute(this, key, value);
587 }
588}
589
590
591void
593 enableFlowAttribute(this, key, undoList);
594}
595
596
597void
599 disableFlowAttribute(this, key, undoList);
600}
601
602
603bool
607
608
609std::string
611 return getTagStr();
612}
613
614
615std::string
617 const auto& inspectedElements = myNet->getViewNet()->getInspectedElements();
618 // special case for Trips and flow
620 // check if we're inspecting an Edge
621 if (inspectedElements.getFirstAC() && (inspectedElements.getFirstAC()->getTagProperty().getTag() == SUMO_TAG_EDGE)) {
622 // check if edge correspond to a "from", "to" or "via" edge
623 if (inspectedElements.isACInspected(getParentEdges().front())) {
624 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (from)";
625 } else if (inspectedElements.isACInspected(getParentEdges().front())) {
626 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (to)";
627 } else {
628 // iterate over via
629 for (const auto& viaEdgeID : via) {
630 if (viaEdgeID == inspectedElements.getFirstAC()->getID()) {
631 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (via)";
632 }
633 }
634 }
635 }
636 }
637 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID);
638}
639
640
645
646// ===========================================================================
647// protected
648// ===========================================================================
649
652 // change color
653 if (drawUsingSelectColor()) {
655 } else {
656 return getColorByScheme(s.containerColorer, this);
657 }
658}
659
660
661void
663 // obtain width and length
664 const double length = getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
665 const double width = getTypeParent()->getAttributeDouble(SUMO_ATTR_WIDTH);
666 // draw pedestrian shape
667 glScaled(length * 0.2, width * 0.2, 1);
668 glBegin(GL_QUADS);
669 glVertex2d(0, 0.5);
670 glVertex2d(0, -0.5);
671 glVertex2d(-1, -0.5);
672 glVertex2d(-1, 0.5);
673 glEnd();
674 GLHelper::setColor(GLHelper::getColor().changedBrightness(-30));
675 glTranslated(0, 0, .045);
676 glBegin(GL_QUADS);
677 glVertex2d(-0.1, 0.4);
678 glVertex2d(-0.1, -0.4);
679 glVertex2d(-0.9, -0.4);
680 glVertex2d(-0.9, 0.4);
681 glEnd();
682}
683
684
685void
687 const std::string& file = getTypeParent()->getAttribute(SUMO_ATTR_IMGFILE);
688 // obtain width and length
689 const double length = getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
690 const double width = getTypeParent()->getAttributeDouble(SUMO_ATTR_WIDTH);
691 if (file != "") {
692 // @todo invent an option for controlling whether images should be rotated or not
693 //if (getVehicleType().getGuiShape() == SVS_CONTAINER) {
694 // glRotated(RAD2DEG(getAngle() + M_PI / 2.), 0, 0, 1);
695 //}
696 int textureID = GUITexturesHelper::getTextureID(file);
697 if (textureID > 0) {
698 const double exaggeration = s.containerSize.getExaggeration(s, this);
699 const double halfLength = length / 2.0 * exaggeration;
700 const double halfWidth = width / 2.0 * exaggeration;
701 GUITexturesHelper::drawTexturedBox(textureID, -halfWidth, -halfLength, halfWidth, halfLength);
702 }
703 } else {
704 // fallback if no image is defined
706 }
707}
708
709// ===========================================================================
710// private
711// ===========================================================================
712
714 containerPlan(_containerPlan),
715 edge(nullptr),
716 arrivalPos(-1) {
717}
718
719
721 containerPlan(nullptr),
722 edge(nullptr),
723 arrivalPos(-1) {
724}
725
726
727void
728GNEContainer::setAttribute(SumoXMLAttr key, const std::string& value) {
729 // declare string error
730 std::string error;
731 switch (key) {
732 case SUMO_ATTR_ID:
733 // update microsimID
734 setDemandElementID(value);
735 // update id
736 id = value;
737 break;
738 case SUMO_ATTR_TYPE:
739 if (getID().size() > 0) {
741 // set manually vtypeID (needed for saving)
742 vtypeid = value;
743 }
744 break;
745 case SUMO_ATTR_COLOR:
746 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
747 color = parse<RGBColor>(value);
748 // mark parameter as set
750 } else {
751 // set default value
752 color = parse<RGBColor>(myTagProperty.getDefaultValue(key));
753 // unset parameter
754 parametersSet &= ~VEHPARS_COLOR_SET;
755 }
756 break;
758 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
760 // mark parameter as set
762 } else {
763 // set default value
765 // unset parameter
766 parametersSet &= ~VEHPARS_DEPARTPOS_SET;
767 }
768 // compute container
770 break;
771 // Others
773 setParametersStr(value);
774 break;
775 default:
776 setFlowAttribute(this, key, value);
777 break;
778 }
779}
780
781
782void
784 // toggle flow attributes
785 toggleFlowAttribute(key, value);
786}
787
788
789void
791 // change departPos
793 departPos = moveResult.newFirstPos;
794 // update geometry
796}
797
798
799void
801 undoList->begin(this, "departPos of " + getTagStr());
802 // now set departPos
804 undoList->end();
805}
806
807/****************************************************************************/
FXDEFMAP(GNEContainer::GNEContainerPopupMenu) containerPopupMenuMap[]
@ MID_GNE_CONTAINER_TRANSFORM
transform container to another container type (ej: container to containerflow)
@ MID_COPY_TYPED_NAME
Copy typed object name - popup entry.
Definition GUIAppEnum.h:455
@ MID_COPY_NAME
Copy object name - popup entry.
Definition GUIAppEnum.h:453
@ GLO_CONTAINER
a container
@ GLO_CONTAINERFLOW
a person flow
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
@ CONTAINERFLOW
const std::string DEFAULT_CONTAINERTYPE_ID
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
DepartPosDefinition
Possible ways to choose the departure position.
@ GIVEN
The position is given.
const long long int VEHPARS_COLOR_SET
const long long int VEHPARS_DEPARTPOS_SET
const long long int VEHPARS_VTYPE_SET
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
@ SUMO_TAG_CONTAINERFLOW
@ GNE_TAG_STOPCONTAINER_CONTAINERSTOP
@ SUMO_TAG_FLOW
a flow definition using from and to edges or a route
@ SUMO_TAG_CONTAINER
@ SUMO_TAG_TRIP
a single trip definition (used by router)
@ SUMO_TAG_EDGE
begin/end of the description of an edge
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ GNE_ATTR_PLAN_GEOMETRY_STARTPOS
person/container geometry start position
@ GNE_ATTR_TAZ_CENTROID
TAZ Center (uses to return the TAZ centroid if center is not defined)
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
@ SUMO_ATTR_CONTAINERSPERHOUR
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_CENTER
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_ID
@ SUMO_ATTR_IMGFILE
@ SUMO_ATTR_WIDTH
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
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 RGBColor getColor()
gets the gl-color
Definition GLHelper.cpp:655
static void pushMatrix()
push matrix
Definition GLHelper.cpp:118
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
const std::string & getTagStr() const
get tag assigned to this object in string format
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
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
void resetDefaultValues()
reset attribute carrier to their default values
GNENet * myNet
pointer to net
GNENet * getNet() const
get pointer to net
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
class used in GUIGLObjectPopupMenu for container transformations
long onCmdTransform(FXObject *obj, FXSelector, void *)
Called to transform the current container to another container type.
class used in GUIGLObjectPopupMenu for single container transformations
long onCmdTransform(FXObject *obj, FXSelector, void *)
Called to transform the current container to another container type.
GNESelectedContainersPopupMenu(GNEContainer *container, const std::vector< GNEContainer * > &selectedContainer, GUIMainWindow &app, GUISUMOAbstractView &parent)
Constructor.
FXMenuCommand * myTransformToContainer
menu command for transform to container
FXMenuCommand * myTransformToContainerFlow
menu command for transform to containerFlow
Position getPositionInView() const
Returns position of demand element in view.
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
GNELane * getLastPathLane() const
get last path lane
void updateGeometry()
update pre-computed geometry information
Position getAttributePosition(SumoXMLAttr key) const
Problem isDemandElementValid() const
check if current demand element is valid to be written into XML (by default true, can be reimplemente...
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
const RGBColor & getColor() const
get color
GNEContainer(SumoXMLTag tag, GNENet *net)
default constructor
void toggleAttribute(SumoXMLAttr key, const bool value)
method for enable or disable the attribute and nothing else (used in GNEChange_ToggleAttribute)
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
void drawAction_drawAsPoly() const
draw container as poly
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over junction.
void writeDemandElement(OutputDevice &device) const
write demand element element into a xml file
void computePathElement()
compute pathElement
void drawAction_drawAsImage(const GUIVisualizationSettings &s) const
draw container as image
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
~GNEContainer()
destructor
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
std::string getParentName() const
Returns the name of the parent object.
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
RGBColor getDrawingColor(const GUIVisualizationSettings &s) const
get drawing color
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
GNEMoveOperation * getMoveOperation()
get move operation
double getAttributeDouble(SumoXMLAttr key) const
bool isAttributeEnabled(SumoXMLAttr key) const
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
GNEContour myContainerContour
variable used for contours
GNELane * getFirstPathLane() const
get first path lane
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over lane.
const Parameterised::Map & getACParametersMap() const
get parameters map
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform demand element changes
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
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...)
void calculateContourRectangleShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const Position &pos, const double width, const double height, const double layer, const double offsetX, const double offsetY, const double rot, const double scale, const GUIGlObject *boundaryParent) const
calculate contour (for rectangled elements)
void toggleFlowAttribute(const SumoXMLAttr attribute, const bool value)
toggle flow parameters (used in toggleAttribute(...) function of vehicles, persons and containers
void drawFlowLabel(const Position &position, const double rotation, const double width, const double length, const double exaggeration) const
draw flow label
std::string getFlowAttribute(const GNEDemandElement *flowElement, SumoXMLAttr key) const
inherited from GNEAttributeCarrier and adapted to GNEDemandElementFlow
void disableFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, GNEUndoList *undoList)
bool isFlowAttributeEnabled(SumoXMLAttr key) const
double getFlowAttributeDouble(SumoXMLAttr key) const
bool isValidFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, const std::string &value)
void writeFlowAttributes(const GNEDemandElement *flowElement, OutputDevice &device) const
write flow attributes
void enableFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, GNEUndoList *undoList)
void setFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
void replaceDemandElementParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace demand element parent
void drawStackLabel(const int number, const std::string &element, const Position &position, const double rotation, const double width, const double length, const double exaggeration) const
draw stack label
virtual double getAttributeDouble(SumoXMLAttr key) const =0
bool isValidDemandElementID(const std::string &value) const
check if a new demand element ID is valid
void drawJunctionLine(const GNEDemandElement *element) const
draw line between junctions
virtual std::string getAttribute(SumoXMLAttr key) const =0
void setDemandElementID(const std::string &newID)
set demand element id
GNEDemandElement * getTypeParent() const
get type parent (needed because first parent can be either type or typeDistribution)
int myStackedLabelNumber
stacked label number
virtual Position getPositionInView() const =0
Returns position of demand element in view.
RGBColor getColorByScheme(const GUIColorer &c, const SUMOVehicleParameter *parameters) const
get color by scheme (used by vehicles, persons and containers)
Problem
enum class for demandElement problems
virtual Position getAttributePosition(SumoXMLAttr key) const =0
const std::vector< GNEJunction * > & getParentJunctions() const
get parent junctions
const std::vector< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
const std::vector< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
const std::vector< GNEAdditional * > & getParentAdditionals() const
get parent additionals
const std::vector< GNEEdge * > & getParentEdges() const
get parent edges
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition GNELane.h:46
move operation
move result
double newFirstPos
new first position
GNEDemandElement * retrieveDemandElements(const std::vector< SumoXMLTag > types, const std::string &id, bool hardFail=true) const
Returns the named demand element.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
GNEPathManager * getDemandPathManager()
get demand path manager
Definition GNENet.cpp:145
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:127
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2163
bool isPathValid(const GNEPathElement *pathElement) const
check if path element is valid
static void transformToContainerFlow(GNEContainer *originalContainer)
transform routeFlow over an existent route
static void transformToContainer(GNEContainer *originalContainer)
transform container functions
bool planFromJunction() const
return true if tag correspond to a plan that starts in junction
bool isFlow() const
return true if tag correspond to a flow element
const std::string & getTagStr() const
get Tag vinculated with this attribute Property in String Format (used to avoid multiple calls to toS...
bool isPlanStopContainer() const
return true if tag correspond to a container stop plan
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
bool planFromTAZ() const
return true if tag correspond to a plan that starts in TAZ
const std::string & getDefaultValue(SumoXMLAttr attr) const
return the default value of the attribute of an element
SumoXMLTag getXMLTag() const
get XML tag
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 GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
GNEViewNetHelper::InspectedElements & getInspectedElements()
get inspected elements
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
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
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.
void insertMenuPaneChild(FXMenuPane *child)
Insert a sub-menu pane in this GUIGLObjectPopupMenu.
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 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 buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, const GUIMainWindow &app) const
Builds an entry which allows to copy the cursor position if geo projection is used,...
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
static void drawTexturedBox(int which, double size)
Draws a named texture as a box with the given size.
static int getTextureID(const std::string &filename, const bool mirrorX=false)
return texture id for the given filename (initialize on first use)
Stores the information about how to visualize structures.
GUIVisualizationSizeSettings containerSize
int containerQuality
The quality of container drawing.
Detail getDetailLevel(const double exaggeration) const
return the detail level
GUIVisualizationColorSettings colorSettings
color settings
bool checkDrawContainer(Detail d, const bool selected) const
check if draw container
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
double scale
information about a lane's width (temporary, used for a single view)
GUIVisualizationTextSettings containerName
GUIColorer containerColorer
The container colorer.
double angle
The current view rotation angle.
static const std::vector< SumoXMLTag > types
type namespace
static const std::vector< SumoXMLTag > containers
containers namespace
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
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
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
double y() const
Returns the y-position.
Definition Position.h:60
Structure representing possible vehicle parameter.
SumoXMLTag tag
The vehicle tag.
std::string vtypeid
The vehicle's type id.
std::vector< std::string > via
List of the via-edges the vehicle must visit.
long long int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
void write(OutputDevice &dev, const OptionsCont &oc, const SumoXMLTag altTag=SUMO_TAG_VEHICLE, const std::string &typeID="") const
Writes the parameters as a beginning element.
bool wasSet(long long int what) const
Returns whether the given parameter was set.
double departPos
(optional) The position the vehicle shall depart from
RGBColor color
The vehicle's color, TraCI may change this.
double arrivalPos
(optional) The position the vehicle shall arrive on
std::string getDepartPos() const
obtain depart pos parameter in string format
static bool parseDepartPos(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosDefinition &dpd, std::string &error)
Validates a given departPos value.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
bool showDemandElements() const
check if show demand elements checkbox is enabled
bool showNonInspectedDemandElements(const GNEDemandElement *demandElement) const
check if non inspected element has to be hidden
bool isCurrentSupermodeDemand() const
@check if current supermode is Demand
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 showDemandElements() const
check if show demand elements checkbox is enabled
RGBColor selectedContainerColor
container selection color
static const double segmentWidth
width of dotted contour segments
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values