SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GUITriggerBuilder.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // Builds trigger objects for guisim
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <string>
34 #include <fstream>
36 #include <guisim/GUINet.h>
38 #include <guisim/GUIBusStop.h>
40 #include <guisim/GUICalibrator.h>
41 #include "GUITriggerBuilder.h"
42 
43 #ifdef CHECK_MEMORY_LEAKS
44 #include <foreign/nvwa/debug_new.h>
45 #endif // CHECK_MEMORY_LEAKS
46 
47 
48 // ===========================================================================
49 // method definitions
50 // ===========================================================================
52 
53 
55 
56 
59  const std::string& id, const std::vector<MSLane*>& destLanes,
60  const std::string& file) {
61  GUILaneSpeedTrigger* lst = new GUILaneSpeedTrigger(id, destLanes, file);
62  static_cast<GUINet&>(net).getVisualisationSpeedUp().addAdditionalGLObject(lst);
63  return lst;
64 }
65 
66 
68 GUITriggerBuilder::buildRerouter(MSNet& net, const std::string& id,
69  MSEdgeVector& edges,
70  SUMOReal prob, const std::string& file, bool off) {
71  GUITriggeredRerouter* rr = new GUITriggeredRerouter(id, edges, prob, file, off,
72  dynamic_cast<GUINet&>(net).getVisualisationSpeedUp());
73  return rr;
74 }
75 
76 
77 void
78 GUITriggerBuilder::buildBusStop(MSNet& net, const std::string& id,
79  const std::vector<std::string>& lines,
80  MSLane* lane,
81  SUMOReal frompos, SUMOReal topos) {
82  GUIBusStop* stop = new GUIBusStop(id, lines, *lane, frompos, topos);
83  if (!net.addBusStop(stop)) {
84  delete stop;
85  throw InvalidArgument("Could not build bus stop '" + id + "'; probably declared twice.");
86  }
87  static_cast<GUINet&>(net).getVisualisationSpeedUp().addAdditionalGLObject(stop);
88 }
89 
90 void
91 GUITriggerBuilder::buildContainerStop(MSNet& net, const std::string& id,
92  const std::vector<std::string>& lines,
93  MSLane* lane,
94  SUMOReal frompos, SUMOReal topos) {
95  GUIContainerStop* stop = new GUIContainerStop(id, lines, *lane, frompos, topos);
96  if (!net.addContainerStop(stop)) {
97  delete stop;
98  throw InvalidArgument("Could not build container stop '" + id + "'; probably declared twice.");
99  }
100  static_cast<GUINet&>(net).getVisualisationSpeedUp().addAdditionalGLObject(stop);
101 }
102 
103 
105 GUITriggerBuilder::buildCalibrator(MSNet& net, const std::string& id,
106  MSEdge* edge, SUMOReal pos,
107  const std::string& file,
108  const std::string& outfile,
109  const SUMOTime freq,
110  const MSRouteProbe* probe) {
111  GUICalibrator* cali = new GUICalibrator(id, edge, pos, file, outfile, freq, probe);
112  static_cast<GUINet&>(net).getVisualisationSpeedUp().addAdditionalGLObject(cali);
113  return cali;
114 }
115 
116 
117 /****************************************************************************/
118 
A lane area vehicles can halt at (gui-version)
Definition: GUIBusStop.h:71
virtual MSLaneSpeedTrigger * buildLaneSpeedTrigger(MSNet &net, const std::string &id, const std::vector< MSLane * > &destLanes, const std::string &file)
Builds a lane speed trigger.
Changes the speed allowed on a set of lanes (gui version)
Definition: GUICalibrator.h:53
Reroutes vehicles passing an edge One rerouter can be active on multiple edges. To reduce drawing loa...
virtual MSCalibrator * buildCalibrator(MSNet &net, const std::string &id, MSEdge *edge, SUMOReal pos, const std::string &file, const std::string &outfile, const SUMOTime freq, const MSRouteProbe *probe)
builds a microscopic calibrator
Writes routes of vehicles passing a certain edge.
Definition: MSRouteProbe.h:68
~GUITriggerBuilder()
Destructor.
virtual void buildBusStop(MSNet &net, const std::string &id, const std::vector< std::string > &lines, MSLane *lane, SUMOReal frompos, SUMOReal topos)
Builds a bus stop.
The simulated network and simulation perfomer.
Definition: MSNet.h:94
bool addBusStop(MSBusStop *busStop)
Adds a bus stop.
Definition: MSNet.cpp:742
Changes the speed allowed on a set of lanes.
virtual MSTriggeredRerouter * buildRerouter(MSNet &net, const std::string &id, MSEdgeVector &edges, SUMOReal prob, const std::string &file, bool off)
builds an rerouter
virtual void buildContainerStop(MSNet &net, const std::string &id, const std::vector< std::string > &lines, MSLane *lane, SUMOReal frompos, SUMOReal topos)
Builds a container stop.
A road/street connecting two junctions.
Definition: MSEdge.h:81
GUITriggerBuilder()
Constructor.
bool addContainerStop(MSContainerStop *containerStop)
Adds a container stop.
Definition: MSNet.cpp:767
Reroutes vehicles passing an edge.
A lane area vehicles can halt at (gui-version)
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:90
int SUMOTime
Definition: SUMOTime.h:43
Calibrates the flow on a segment to a specified one.
Definition: MSCalibrator.h:57
#define SUMOReal
Definition: config.h:218
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:78
Changes the speed allowed on a set of lanes (gui version)
Representation of a lane in the micro simulation.
Definition: MSLane.h:77