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-2025 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// Representation of containers in netedit
19/****************************************************************************/
20
22#include <netedit/GNENet.h>
24#include <netedit/GNEUndoList.h>
25#include <netedit/GNEViewNet.h>
31
32#include "GNEContainer.h"
33#include "GNERouteHandler.h"
34
35// ===========================================================================
36// FOX callback mapping
37// ===========================================================================
38
42
46
47// Object implementation
48FXIMPLEMENT(GNEContainer::GNEContainerPopupMenu, GUIGLObjectPopupMenu, containerPopupMenuMap, ARRAYNUMBER(containerPopupMenuMap))
49FXIMPLEMENT(GNEContainer::GNESelectedContainersPopupMenu, GUIGLObjectPopupMenu, selectedContainersPopupMenuMap, ARRAYNUMBER(selectedContainersPopupMenuMap))
50
51// ===========================================================================
52// GNEContainer::GNEContainerPopupMenu
53// ===========================================================================
54
56 GUIGLObjectPopupMenu(app, parent, container),
57 myContainer(container),
58 myTransformToContainer(nullptr),
59 myTransformToContainerFlow(nullptr) {
60 // build common options
61 container->buildPopUpMenuCommonOptions(this, app, container->myNet->getViewNet(), container->getTagProperty()->getTag(), container->isAttributeCarrierSelected());
62 // add transform functions only in demand mode
63 if (myContainer->getNet()->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
64 // create menu pane for transform operations
65 FXMenuPane* transformOperation = new FXMenuPane(this);
66 this->insertMenuPaneChild(transformOperation);
67 new FXMenuCascade(this, "transform to", nullptr, transformOperation);
68 // Create menu comands for all transformations
69 myTransformToContainer = GUIDesigns::buildFXMenuCommand(transformOperation, "Container", GUIIconSubSys::getIcon(GUIIcon::CONTAINER), this, MID_GNE_CONTAINER_TRANSFORM);
70 myTransformToContainerFlow = GUIDesigns::buildFXMenuCommand(transformOperation, "ContainerFlow", GUIIconSubSys::getIcon(GUIIcon::CONTAINERFLOW), this, MID_GNE_CONTAINER_TRANSFORM);
71 // check what menu command has to be disabled
72 if (myContainer->getTagProperty()->getTag() == SUMO_TAG_CONTAINER) {
73 myTransformToContainer->disable();
74 } else if (myContainer->getTagProperty()->getTag() == SUMO_TAG_CONTAINERFLOW) {
75 myTransformToContainerFlow->disable();
76 }
77 }
78}
79
80
82
83
84long
85GNEContainer::GNEContainerPopupMenu::onCmdTransform(FXObject* obj, FXSelector, void*) {
86 if (obj == myTransformToContainer) {
88 } else if (obj == myTransformToContainerFlow) {
90 }
91 return 1;
92}
93
94
95// ===========================================================================
96// GNEContainer::GNESelectedContainersPopupMenu
97// ===========================================================================
98
99GNEContainer::GNESelectedContainersPopupMenu::GNESelectedContainersPopupMenu(GNEContainer* container, const std::vector<GNEContainer*>& selectedContainer, GUIMainWindow& app, GUISUMOAbstractView& parent) :
100 GUIGLObjectPopupMenu(app, parent, container),
101 myContainerTag(container->getTagProperty()->getTag()),
102 mySelectedContainers(selectedContainer),
103 myTransformToContainer(nullptr),
104 myTransformToContainerFlow(nullptr) {
105 // build common options
106 container->buildPopUpMenuCommonOptions(this, app, container->myNet->getViewNet(), container->getTagProperty()->getTag(), container->isAttributeCarrierSelected());
107 // add transform functions only in demand mode
108 if (container->getNet()->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
109 // create menu pane for transform operations
110 FXMenuPane* transformOperation = new FXMenuPane(this);
111 this->insertMenuPaneChild(transformOperation);
112 new FXMenuCascade(this, "transform to", nullptr, transformOperation);
113 // Create menu comands for all transformations
116 }
117}
118
119
121
122
123long
125 // iterate over all selected containers
126 for (const auto& container : mySelectedContainers) {
127 if ((obj == myTransformToContainer) &&
128 (container->getTagProperty()->getTag() == myContainerTag)) {
130 } else if ((obj == myTransformToContainerFlow) &&
131 (container->getTagProperty()->getTag() == myContainerTag)) {
133 }
134 }
135 return 1;
136}
137
138
139// ===========================================================================
140// member method definitions
141// ===========================================================================
142#ifdef _MSC_VER
143#pragma warning(push)
144#pragma warning(disable: 4355) // mask warning about "this" in initializers
145#endif
149 // set end and container per hours as default flow values
152}
153
154
155GNEContainer::GNEContainer(SumoXMLTag tag, GNENet* net, const std::string& filename, GNEDemandElement* pType, const SUMOVehicleParameter& containerparameters) :
156 GNEDemandElement(containerparameters.id, net, filename, tag, GNEPathElement::Options::DEMAND_ELEMENT),
157 GNEDemandElementFlow(this, containerparameters) {
158 // set parents
159 setParent<GNEDemandElement*>(pType);
160 // set manually vtypeID (needed for saving)
161 vtypeid = pType->getID();
162}
163#ifdef _MSC_VER
164#pragma warning(pop)
165#endif
166
168
169
172 const auto firstContainerPlan = getChildDemandElements().front();
173 // check first container plan
174 if (firstContainerPlan->getTagProperty()->isPlanStopContainer()) {
175 return nullptr;
176 } else if (firstContainerPlan->getParentEdges().size() > 0) {
177 // get lane
178 const GNELane* lane = firstContainerPlan->getParentEdges().front()->getLaneByAllowedVClass(getVClass());
179 // declare departPos
180 double posOverLane = 0;
181 if (canParse<double>(getDepartPos())) {
182 posOverLane = parse<double>(getDepartPos());
183 }
184 // return move operation
185 return new GNEMoveOperation(this, lane, posOverLane, false);
186 } else {
187 return nullptr;
188 }
189}
190
191
192void
194 // attribute VType musn't be written if is DEFAULT_PEDTYPE_ID
196 // unset VType parameter
197 parametersSet &= ~VEHPARS_VTYPE_SET;
198 // write container attributes (VType will not be written)
200 // set VType parameter again
202 } else {
203 // write container attributes, including VType
205 }
206 // write flow attributes
207 writeFlowAttributes(this, device);
208 // write parameters
209 writeParams(device);
210 // write child demand elements associated to this container (Rides, Walks...)
211 for (const auto& containerPlan : getChildDemandElements()) {
212 containerPlan->writeDemandElement(device);
213 }
214 // close container tag
215 device.closeTag();
216}
217
218
221 if (getChildDemandElements().size() == 0) {
222 return Problem::NO_PLANS;
223 } else {
224 return Problem::OK;
225 }
226}
227
228
229std::string
231 if (getChildDemandElements().size() == 0) {
232 return "Container needs at least one plan";
233 } else {
234 return "";
235 }
236}
237
238
239void
241 // nothing to fix
242}
243
244
247 return getParentDemandElements().front()->getVClass();
248}
249
250
251const RGBColor&
253 return color;
254}
255
256
257void
259 // only update geometry of childrens
260 for (const auto& demandElement : getChildDemandElements()) {
261 demandElement->updateGeometry();
262 }
263}
264
265
270
271
274 // return a GNEContainerPopupMenu
275 return new GNEContainerPopupMenu(this, app, parent);
276}
277
278
279std::string
281 return getParentDemandElements().front()->getID();
282}
283
284
285double
289
290
293 Boundary containerBoundary;
294 if (getChildDemandElements().size() > 0) {
295 if (getChildDemandElements().front()->getTagProperty()->isPlanStopContainer()) {
296 // use boundary of stop center
297 return getChildDemandElements().front()->getCenteringBoundary();
298 } else {
299 containerBoundary.add(getPositionInView());
300 }
301 } else {
302 containerBoundary = Boundary(-0.1, -0.1, 0.1, 0.1);
303 }
304 containerBoundary.grow(20);
305 return containerBoundary;
306}
307
308
309void
310GNEContainer::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/,
311 const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
312 // geometry of this element cannot be splitted
313}
314
315
316void
318 bool drawContainer = true;
319 // check if container can be drawn
321 drawContainer = false;
323 drawContainer = false;
325 drawContainer = false;
326 } else if (getChildDemandElements().empty()) {
327 drawContainer = false;
328 }
329 // continue if container can be drawn
330 if (drawContainer) {
331 // obtain exaggeration (and add the special containerExaggeration)
332 const double exaggeration = getExaggeration(s) + 10;
333 // get detail level
334 const auto d = s.getDetailLevel(exaggeration);
335 // obtain position
336 const Position containerPosition = getAttributePosition(SUMO_ATTR_DEPARTPOS);
337 if (containerPosition == Position::INVALID) {
338 return;
339 }
340 // draw geometry only if we'rent in drawForObjectUnderCursor mode
342 // obtain img file
343 const std::string file = getTypeParent()->getAttribute(SUMO_ATTR_IMGFILE);
344 // push draw matrix
346 // Start with the drawing of the area traslating matrix to origin
348 // translate and rotate
349 glTranslated(containerPosition.x(), containerPosition.y(), 0);
350 glRotated(90, 0, 0, 1);
351 // set container color
353 // set scale
354 glScaled(exaggeration, exaggeration, 1);
355 // draw container depending of detail level
356 switch (s.containerQuality) {
357 case 0:
358 case 1:
359 case 2:
361 break;
362 case 3:
363 default:
365 break;
366 }
367 // pop matrix
369 // draw line between junctions if container plan isn't valid
370 for (const auto& containerPlan : getChildDemandElements()) {
371 if (containerPlan->getTagProperty()->isPlanContainer() && (containerPlan->getParentJunctions().size() > 0) &&
372 !myNet->getDemandPathManager()->isPathValid(containerPlan)) {
373 drawJunctionLine(containerPlan);
374 }
375 }
376 // draw stack label
377 if (myStackedLabelNumber > 0) {
378 drawStackLabel(myStackedLabelNumber, "container", Position(containerPosition.x() - 2.5, containerPosition.y() - 0.8), -90, 1.3, 5, getExaggeration(s));
380 // declare counter for stacked containers over stops
381 int stackedCounter = 0;
382 // get stoppingPlace
383 const auto stoppingPlace = getChildDemandElements().front()->getParentAdditionals().front();
384 // get stacked containers
385 for (const auto& stopContainer : stoppingPlace->getChildDemandElements()) {
386 if (stopContainer->getTagProperty()->getTag() == GNE_TAG_STOPCONTAINER_CONTAINERSTOP) {
387 // get container parent
388 const auto containerParent = stopContainer->getParentDemandElements().front();
389 // check if the stop if the first container plan parent
390 if (stopContainer->getPreviousChildDemandElement(containerParent) == nullptr) {
391 stackedCounter++;
392 }
393 }
394 }
395 // if we have more than two stacked elements, draw label
396 if (stackedCounter > 1) {
397 drawStackLabel(stackedCounter, "container", Position(containerPosition.x() - 2.5, containerPosition.y() - 0.8), -90, 1.3, 5, getExaggeration(s));
398 }
399 }
400 // draw flow label
401 if (myTagProperty->isFlow()) {
402 drawFlowLabel(Position(containerPosition.x() - 1, containerPosition.y() - 4.25), -90, 1.8, 2, getExaggeration(s));
403 }
404 // draw name
405 drawName(containerPosition, s.scale, s.containerName, s.angle);
406 // draw lock icon
408 // draw dotted contour
410 }
411 // calculate contour
412 myContainerContour.calculateContourRectangleShape(s, d, this, containerPosition, 0.5, 0.18, getType(), -5.5, 0, 0, exaggeration, nullptr);
413 }
414}
415
416
417void
419 // compute all container plan children (because aren't computed in "computeDemandElements()")
420 for (const auto& demandElement : getChildDemandElements()) {
421 demandElement->computePathElement();
422 }
423}
424
425
426void
427GNEContainer::drawLanePartialGL(const GUIVisualizationSettings& /*s*/, const GNESegment* /*segment*/, const double /*offsetFront*/) const {
428 // Stops don't use drawJunctionPartialGL
429}
430
431
432void
433GNEContainer::drawJunctionPartialGL(const GUIVisualizationSettings& /*s*/, const GNESegment* /*segment*/, const double /*offsetFront*/) const {
434 // Stops don't use drawJunctionPartialGL
435}
436
437
438GNELane*
440 // use path lane of first container plan
441 return getChildDemandElements().front()->getFirstPathLane();
442}
443
444
445GNELane*
447 // use path lane of first container plan
448 return getChildDemandElements().front()->getLastPathLane();
449}
450
451
452std::string
454 // declare string error
455 std::string error;
456 switch (key) {
457 case SUMO_ATTR_ID:
458 return getMicrosimID();
459 case SUMO_ATTR_TYPE:
460 return getTypeParent()->getID();
461 case SUMO_ATTR_COLOR:
463 return toString(color);
464 } else {
466 }
469 return getDepartPos();
470 } else {
472 }
473 default:
474 return getFlowAttribute(this, key);
475 }
476}
477
478
479double
481 switch (key) {
484 return departPos;
485 } else {
486 return 0;
487 }
488 default:
489 return getFlowAttributeDouble(key);
490 }
491}
492
493
496 switch (key) {
497 case SUMO_ATTR_DEPARTPOS: {
498 // first check number of child demand elements
499 if (getChildDemandElements().empty()) {
500 return Position();
501 }
502 // get container plan
503 const GNEDemandElement* containerPlan = getChildDemandElements().front();
504 // first check if first container plan is a stop
505 if (containerPlan->getTagProperty()->isPlanStopContainer()) {
506 // stop center
507 return containerPlan->getPositionInView();
508 } else if (containerPlan->getTagProperty()->planFromTAZ()) {
509 // TAZ
510 if (containerPlan->getParentAdditionals().front()->getAttribute(SUMO_ATTR_CENTER).empty()) {
511 return containerPlan->getParentAdditionals().front()->getAttributePosition(GNE_ATTR_TAZ_CENTROID);
512 } else {
513 return containerPlan->getParentAdditionals().front()->getAttributePosition(SUMO_ATTR_CENTER);
514 }
515 } else if (containerPlan->getTagProperty()->planFromJunction()) {
516 // juncrtion
517 return containerPlan->getParentJunctions().front()->getPositionInView();
518 } else {
520 }
521 }
522 default:
523 throw InvalidArgument(getTagStr() + " doesn't have a Position attribute of type '" + toString(key) + "'");
524 }
525}
526
527
528void
529GNEContainer::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
530 switch (key) {
531 case SUMO_ATTR_ID:
532 case SUMO_ATTR_TYPE:
533 case SUMO_ATTR_COLOR:
535 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
536 break;
537 default:
538 setFlowAttribute(this, key, value, undoList);
539 break;
540 }
541}
542
543
544bool
545GNEContainer::isValid(SumoXMLAttr key, const std::string& value) {
546 // declare string error
547 std::string error;
548 switch (key) {
549 case SUMO_ATTR_ID:
551 case SUMO_ATTR_TYPE:
552 return (myNet->getAttributeCarriers()->retrieveDemandElements(NamespaceIDs::types, value, false) != nullptr);
553 case SUMO_ATTR_COLOR:
554 return canParse<RGBColor>(value);
555 case SUMO_ATTR_DEPARTPOS: {
556 double dummyDepartPos;
557 DepartPosDefinition dummyDepartPosProcedure;
558 parseDepartPos(value, myTagProperty->getTagStr(), id, dummyDepartPos, dummyDepartPosProcedure, error);
559 // if error is empty, given value is valid
560 return error.empty();
561 }
562 default:
563 return isValidFlowAttribute(this, key, value);
564 }
565}
566
567
568void
570 enableFlowAttribute(this, key, undoList);
571}
572
573
574void
576 disableFlowAttribute(this, key, undoList);
577}
578
579
580bool
584
585
586std::string
588 return getTagStr();
589}
590
591
592std::string
594 const auto& inspectedElements = myNet->getViewNet()->getInspectedElements();
595 // special case for Trips and flow
597 // check if we're inspecting an Edge
598 if (inspectedElements.getFirstAC() && (inspectedElements.getFirstAC()->getTagProperty()->getTag() == SUMO_TAG_EDGE)) {
599 // check if edge correspond to a "from", "to" or "via" edge
600 if (inspectedElements.isACInspected(getParentEdges().front())) {
601 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (from)";
602 } else if (inspectedElements.isACInspected(getParentEdges().front())) {
603 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (to)";
604 } else {
605 // iterate over via
606 for (const auto& viaEdgeID : via) {
607 if (viaEdgeID == inspectedElements.getFirstAC()->getID()) {
608 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (via)";
609 }
610 }
611 }
612 }
613 }
614 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID);
615}
616
617
622
623// ===========================================================================
624// protected
625// ===========================================================================
626
629 // change color
630 if (drawUsingSelectColor()) {
632 } else {
633 return getColorByScheme(s.containerColorer, this);
634 }
635}
636
637
638void
640 // obtain width and length
641 const double length = getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
642 const double width = getTypeParent()->getAttributeDouble(SUMO_ATTR_WIDTH);
643 // draw pedestrian shape
644 glScaled(length * 0.2, width * 0.2, 1);
645 glBegin(GL_QUADS);
646 glVertex2d(0, 0.5);
647 glVertex2d(0, -0.5);
648 glVertex2d(-1, -0.5);
649 glVertex2d(-1, 0.5);
650 glEnd();
651 GLHelper::setColor(GLHelper::getColor().changedBrightness(-30));
652 glTranslated(0, 0, .045);
653 glBegin(GL_QUADS);
654 glVertex2d(-0.1, 0.4);
655 glVertex2d(-0.1, -0.4);
656 glVertex2d(-0.9, -0.4);
657 glVertex2d(-0.9, 0.4);
658 glEnd();
659}
660
661
662void
664 const std::string& file = getTypeParent()->getAttribute(SUMO_ATTR_IMGFILE);
665 // obtain width and length
666 const double length = getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
667 const double width = getTypeParent()->getAttributeDouble(SUMO_ATTR_WIDTH);
668 if (file != "") {
669 // @todo invent an option for controlling whether images should be rotated or not
670 //if (getVehicleType().getGuiShape() == SVS_CONTAINER) {
671 // glRotated(RAD2DEG(getAngle() + M_PI / 2.), 0, 0, 1);
672 //}
673 int textureID = GUITexturesHelper::getTextureID(file);
674 if (textureID > 0) {
675 const double exaggeration = s.containerSize.getExaggeration(s, this);
676 const double halfLength = length / 2.0 * exaggeration;
677 const double halfWidth = width / 2.0 * exaggeration;
678 GUITexturesHelper::drawTexturedBox(textureID, -halfWidth, -halfLength, halfWidth, halfLength);
679 }
680 } else {
681 // fallback if no image is defined
683 }
684}
685
686// ===========================================================================
687// private
688// ===========================================================================
689
691 containerPlan(_containerPlan),
692 edge(nullptr),
693 arrivalPos(-1) {
694}
695
696
698 containerPlan(nullptr),
699 edge(nullptr),
700 arrivalPos(-1) {
701}
702
703
704void
705GNEContainer::setAttribute(SumoXMLAttr key, const std::string& value) {
706 // declare string error
707 std::string error;
708 switch (key) {
709 case SUMO_ATTR_ID:
710 // update microsimID
711 setDemandElementID(value);
712 // update id
713 id = value;
714 break;
715 case SUMO_ATTR_TYPE:
716 if (getID().size() > 0) {
718 // set manually vtypeID (needed for saving)
719 vtypeid = value;
720 }
721 break;
722 case SUMO_ATTR_COLOR:
723 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
724 color = parse<RGBColor>(value);
725 // mark parameter as set
727 } else {
728 // set default value
729 color = parse<RGBColor>(myTagProperty->getDefaultStringValue(key));
730 // unset parameter
731 parametersSet &= ~VEHPARS_COLOR_SET;
732 }
733 break;
735 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
737 // mark parameter as set
739 } else {
740 // set default value
742 // unset parameter
743 parametersSet &= ~VEHPARS_DEPARTPOS_SET;
744 }
745 // compute container
747 break;
748 default:
749 setFlowAttribute(this, key, value);
750 break;
751 }
752}
753
754
755void
757 // toggle flow attributes
758 toggleFlowAttribute(key, value);
759}
760
761
762void
764 // change departPos
766 departPos = moveResult.newFirstPos;
767 // update geometry
769}
770
771
772void
774 undoList->begin(this, "departPos of " + getTagStr());
775 // now set departPos
777 undoList->end();
778}
779
780/****************************************************************************/
FXDEFMAP(GNEContainer::GNEContainerPopupMenu) containerPopupMenuMap[]
@ MID_GNE_CONTAINER_TRANSFORM
transform container to another container type (ej: container to containerflow)
@ 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)
@ 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:75
Boundary & grow(double by)
extends the boundary by the given amount
Definition Boundary.cpp:340
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:649
static void popMatrix()
pop matrix
Definition GLHelper.cpp:131
static 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
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
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
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 GNEHierarchicalContainerParents< GNEAdditional * > & getParentAdditionals() const
get parent additionals
const GNEHierarchicalContainerParents< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
const GNEHierarchicalContainerParents< GNEEdge * > & getParentEdges() const
get parent edges
const GNEHierarchicalContainerParents< GNEJunction * > & getParentJunctions() const
get parent junctions
const GNEHierarchicalContainerChildren< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
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:174
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:144
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2193
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
SumoXMLTag getXMLTag() const
default values
const std::string & getDefaultStringValue(SumoXMLAttr attr) const
default values
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
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.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void buildPopUpMenuCommonOptions(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, GUISUMOAbstractView *parent, const SumoXMLTag tag, const bool selected, bool addSeparator=true)
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
static 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.
std::map< std::string, std::string > Map
parameters map
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
static const Position INVALID
used to indicate that a position is valid
Definition Position.h:323
double x() const
Returns the x-position.
Definition Position.h:52
double y() const
Returns the y-position.
Definition Position.h:57
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