Line data Source code
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 : /****************************************************************************/
14 : /// @file GUITransportableControl.cpp
15 : /// @author Daniel Krajzewicz
16 : /// @author Jakob Erdmann
17 : /// @author Michael Behrisch
18 : /// @date Wed, 13.06.2012
19 : ///
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"
29 : #include "GUITransportableControl.h"
30 :
31 :
32 : // ===========================================================================
33 : // method definitions
34 : // ===========================================================================
35 1574 : GUITransportableControl::GUITransportableControl(const bool isPerson) :
36 : MSTransportableControl(isPerson),
37 1574 : myIsPerson(isPerson)
38 1574 : {}
39 :
40 :
41 3136 : GUITransportableControl::~GUITransportableControl() {
42 3136 : }
43 :
44 :
45 : MSTransportable*
46 27709 : GUITransportableControl::buildPerson(const SUMOVehicleParameter* pars, MSVehicleType* vtype, MSTransportable::MSTransportablePlan* plan,
47 : SumoRNG* rng) const {
48 27709 : const double speedFactor = vtype->computeChosenSpeedDeviation(rng);
49 27709 : return new GUIPerson(pars, vtype, plan, speedFactor);
50 : }
51 :
52 :
53 : MSTransportable*
54 422 : GUITransportableControl::buildContainer(const SUMOVehicleParameter* pars, MSVehicleType* vtype, MSTransportable::MSTransportablePlan* plan) const {
55 422 : return new GUIContainer(pars, vtype, plan);
56 : }
57 :
58 :
59 : void
60 0 : GUITransportableControl::insertIDs(std::vector<GUIGlID>& into) {
61 0 : into.reserve(myTransportables.size());
62 0 : for (std::map<std::string, MSTransportable*>::const_iterator it = myTransportables.begin(); it != myTransportables.end(); ++it) {
63 0 : if (it->second->getCurrentStageType() != MSStageType::WAITING_FOR_DEPART) {
64 0 : if (myIsPerson) {
65 0 : into.push_back(static_cast<const GUIPerson*>(it->second)->getGlID());
66 : } else {
67 0 : into.push_back(static_cast<const GUIContainer*>(it->second)->getGlID());
68 : }
69 : }
70 : }
71 0 : }
72 :
73 :
74 : /****************************************************************************/
|