Microscopic Traffic Simulator

- Main Page
- Packages
- Classes
- Files

- File List

CanvasViewModel.cs
Go to the documentation of this file.
1 using Microscopic_Traffic_Simulator.ViewModels.Messages;
2 using Microscopic_Traffic_Simulator___Model.CellularTopologyObjects;
3 using Microscopic_Traffic_Simulator___Model.GeometricObjects;
4 using Microscopic_Traffic_Simulator___Model.GeometricObjects.Lanes;
5 using Microscopic_Traffic_Simulator___Model.TrafficObjects;
6 using System.Windows;
7
8 namespace Microscopic_Traffic_Simulator.ViewModels
9 {
13 class CanvasViewModel : ViewModelBase
14 {
18 private GeometricTopology geometricTopology;
22 internal GeometricTopology GeometricTopology { get { return geometricTopology; } }
23
27 private CellularTopology cellularTopology;
31 internal CellularTopology CellularTopology { get { return cellularTopology; } }
32
33 private BuildingMode buildingMode;
34 internal BuildingMode BuildingMode { get { return buildingMode; } }
35
39 private LaneType currentLaneType;
43 internal LaneType CurrentLaneType { get { return currentLaneType; } }
44
49 internal CanvasViewModel(Messenger messenger)
50 {
51 this.messenger = messenger;
52 this.messenger.GetEvent<ConstructionViewModel.GeometricTopologyMessage>().Subscribe(
53 geometricTopology => this.geometricTopology = geometricTopology);
54 this.messenger.GetEvent<SimulationControlViewModel.CellularTopologyMessage>().Subscribe(
55 cellularTopology => this.cellularTopology = cellularTopology);
56 this.messenger.GetEvent<ConstructionViewModel.BuildCellularTopologyMessage>().Subscribe(
57 (geometricTopology, parameters) => buildingMode = BuildingMode.None);
58 this.messenger.GetEvent<ConstructionViewModel.LaneTypeChangedMessage>().Subscribe(i => currentLaneType = i);
59 this.messenger.GetEvent<ConstructionViewModel.IsConstructionModeChangedMessage>().Subscribe(
60 i => buildingMode = i);
61 }
62
68 internal void BuildNewStraightLane(Point startPoint, Point endPoint)
69 {
70 geometricTopology.AddLane(new StraightLane(startPoint, endPoint));
71 messenger.GetEvent<ConstructionViewModel.GeometricTopologyModifiedMessage>().Publish();
72 }
73
81 internal void BuildNewBezierLaneLane(Point startPoint, Point firstControlPoint, Point secondControlPoint,
82 Point endPoint)
83 {
84 geometricTopology.AddLane(new BezierLane(startPoint, firstControlPoint, secondControlPoint, endPoint));
85 messenger.GetEvent<ConstructionViewModel.GeometricTopologyModifiedMessage>().Publish();
86 }
87
88 internal static void CreateGeneratorForLane(Lane laneWhereGeneratorToAdd)
89 {
90 laneWhereGeneratorToAdd.StartNode.Generator = new Generator();
91 }
92 }
93 }
Microscopic_Traffic_Simulator___Model.GeometricObjects.GeometricTopology
Class representing geometric topology of road network.
Definition: GeometricTopology.cs:14
Microscopic_Traffic_Simulator.ViewModels.Messages
Definition: Message.cs:4
Microscopic_Traffic_Simulator___Model.GeometricObjects.Lanes.StraightLane
Represents single straight lane.
Definition: StraightLane.cs:11
System
Microscopic_Traffic_Simulator___Model.TrafficObjects.Generator
Represents generator of cars.
Definition: Generator.cs:13
Microscopic_Traffic_Simulator.ViewModels.ConstructionViewModel
Viewmodel for construction panel.
Definition: ConstructionViewModel.cs:25
Microscopic_Traffic_Simulator.ViewModels.Messages.Messenger
Class representing messenger for communicating between viewmodels.
Definition: Messenger.cs:9
Microscopic_Traffic_Simulator___Model.GeometricObjects.Lanes.Lane.StartNode
StartNode StartNode
Node on the input end of lane.
Definition: Lane.cs:23
Microscopic_Traffic_Simulator.ViewModels.SimulationControlViewModel.CellularTopologyMessage
Class for sending message with built cellular topology.
Definition: SimulationControlViewModel.cs:19
Microscopic_Traffic_Simulator.ViewModels
Definition: CanvasViewModel.cs:8
Microscopic_Traffic_Simulator___Model.GeometricObjects.Lanes.BezierLane
Represents single bezier lane.
Definition: BezierLane.cs:11
Microscopic_Traffic_Simulator.ViewModels.ConstructionViewModel.LaneTypeChangedMessage
Contains information about change of lane type and actual current lane type.
Definition: ConstructionViewModel.cs:47
Microscopic_Traffic_Simulator.ViewModels.CanvasViewModel
Viewmodel for canvas panel.
Definition: CanvasViewModel.cs:13
Microscopic_Traffic_Simulator___Model.TrafficObjects
Definition: Generator.cs:7
Microscopic_Traffic_Simulator.ViewModels.ConstructionViewModel.GeometricTopologyModifiedMessage
Message for sending information about modification of geometric topology.
Definition: ConstructionViewModel.cs:36
Microscopic_Traffic_Simulator.ViewModels.ViewModelBase
Definition: ViewModelBase.cs:8
Microscopic_Traffic_Simulator___Model.GeometricObjects.GeometricTopology.AddLane
void AddLane(Lane newLane)
Adds new lane to geometric topology.
Definition: GeometricTopology.cs:34
Microscopic_Traffic_Simulator___Model.GeometricObjects.Lanes.Lane
Represent single lane.
Definition: Lane.cs:14
Microscopic_Traffic_Simulator
Definition: App.xaml.cs:12
Microscopic_Traffic_Simulator.ViewModels.ConstructionViewModel.GeometricTopologyMessage
Message for sending geometric topology to other viewmodels after creating or opening geomtric topolog...
Definition: ConstructionViewModel.cs:31
Microscopic_Traffic_Simulator.ViewModels.ConstructionViewModel.IsConstructionModeChangedMessage
Message about change of the CurrentBuildingMode containing new value as parameter ...
Definition: ConstructionViewModel.cs:52
Microscopic_Traffic_Simulator.ViewModels.ConstructionViewModel.BuildCellularTopologyMessage
Message for sending geometric topology simulation control viewmodel to build cellular topology from i...
Definition: ConstructionViewModel.cs:42
Microscopic_Traffic_Simulator___Model.CellularTopologyObjects.CellularTopology
Class representing cellular topology.
Definition: CellularTopology.cs:16
Microscopic_Traffic_Simulator___Model.CellularTopologyObjects
Definition: Car.cs:6
Microscopic_Traffic_Simulator.ViewModels.SimulationControlViewModel
Viewmodel for simulation control.
Definition: SimulationControlViewModel.cs:14
Microscopic_Traffic_Simulator___Model.GeometricObjects.Lanes
Definition: BezierLane.cs:5
Microscopic_Traffic_Simulator___Model.GeometricObjects
Definition: GeometricTopology.cs:8
Microscopic_Traffic_Simulator___Model