Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GUITransportableControl.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2012-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/****************************************************************************/
20// GUI-version of the person control for building gui persons
21/****************************************************************************/
22#include <config.h>
23
24#include <vector>
25#include <algorithm>
26#include "GUINet.h"
27#include "GUIContainer.h"
28#include "GUIPerson.h"
30
31
32// ===========================================================================
33// method definitions
34// ===========================================================================
36 MSTransportableControl(isPerson),
37 myIsPerson(isPerson)
38{}
39
40
43
44
47 SumoRNG* rng) const {
48 const double speedFactor = vtype->computeChosenSpeedDeviation(rng);
49 return new GUIPerson(pars, vtype, plan, speedFactor);
50}
51
52
57
58
59void
60GUITransportableControl::insertIDs(std::vector<GUIGlID>& into) {
61 into.reserve(myTransportables.size());
62 for (std::map<std::string, MSTransportable*>::const_iterator it = myTransportables.begin(); it != myTransportables.end(); ++it) {
63 if (it->second->getCurrentStageType() != MSStageType::WAITING_FOR_DEPART) {
64 if (myIsPerson) {
65 into.push_back(static_cast<const GUIPerson*>(it->second)->getGlID());
66 } else {
67 into.push_back(static_cast<const GUIContainer*>(it->second)->getGlID());
68 }
69 }
70 }
71}
72
73
74/****************************************************************************/
GUIGlID getGlID() const
Returns the numerical id of the object.
virtual MSTransportable * buildContainer(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan) const
Builds a new container.
void insertIDs(std::vector< GUIGlID > &into)
Returns the list of all known persons by gl-id.
virtual MSTransportable * buildPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, SumoRNG *rng) const
Builds a new person.
GUITransportableControl(const bool isPerson)
constructor
virtual ~GUITransportableControl()
destructor
std::map< std::string, MSTransportable * > myTransportables
all currently created transportables by id
std::vector< MSStage * > MSTransportablePlan
the structure holding the plan of a transportable
The car-following model and parameter.
double computeChosenSpeedDeviation(SumoRNG *rng, const double minDev=-1.) const
Computes and returns the speed deviation.
Structure representing possible vehicle parameter.