Microscopic Traffic Simulator

- Main Page
- Packages
- Classes
- Files

- File List

TopologyRenderer.cs
Go to the documentation of this file.
1 using Microscopic_Traffic_Simulator___Model.GeometricObjects;
2 using Microscopic_Traffic_Simulator___Model.GeometricObjects.Lanes;
3 using System.Collections.Generic;
4 using System.Windows;
5 using System.Windows.Media;
6
7 namespace Microscopic_Traffic_Simulator.Renderers
8 {
12 class TopologyRenderer : VisualCanvasRenderer
13 {
14 private const double GeneratorCircleRadius = 2.0;
15
19 private GeometricTopology geometricTopology;
23 internal GeometricTopology GeometricTopology
24 {
25 set { geometricTopology = value; }
26 }
27
32 internal TopologyRenderer(DrawingVisual visual) : base(visual) { }
33
38 protected override void Render(Point currentMouseLocation)
39 {
40 RenderTopology();
41 }
42
46 internal void RenderTopology()
47 {
48 using (DrawingContext dc = visual.RenderOpen())
49 {
50 //new ZoomValuesGenerator().Draw(dc);
51 foreach (var lane in geometricTopology.Lanes)
52 {
53 if (lane is StraightLane)
54 {
55 dc.DrawLine(new Pen(Brushes.Black, 1),
56 TransformRealWorldPoint(lane.StartNode.Location),
57 TransformRealWorldPoint(lane.EndNode.Location));
58 }
59 else if (lane is BezierLane)
60 {
61 BezierLane bezierLane = lane as BezierLane;
62 dc.DrawGeometry(null, new Pen(Brushes.Black, 1), new BezierCurveGeometryCreator().GetBezierCurveGeometry(
63 TransformRealWorldPoint(bezierLane.StartNode.Location),
64 TransformRealWorldPoint(bezierLane.EndNode.Location),
65 TransformRealWorldPoint(bezierLane.FirstControlLocation),
66 TransformRealWorldPoint(bezierLane.SecondControlLocation)));
67 }
68
69 if (lane.StartNode.ContainsGenerator)
70 {
71 dc.DrawEllipse(Brushes.Blue, null, TransformRealWorldPoint(lane.StartNode.Location),
72 GeneratorCircleRadius, GeneratorCircleRadius);
73 }
74 }
75 }
76 }
77 }
78 }
Microscopic_Traffic_Simulator___Model.GeometricObjects.GeometricTopology
Class representing geometric topology of road network.
Definition: GeometricTopology.cs:14
Microscopic_Traffic_Simulator.Renderers.TopologyRenderer
Geometric topology renderer.
Definition: TopologyRenderer.cs:12
Microscopic_Traffic_Simulator___Model.GeometricObjects.Lanes.StraightLane
Represents single straight lane.
Definition: StraightLane.cs:11
System
Microscopic_Traffic_Simulator.Renderers.VisualCanvasRenderer
Base class for drawing visual renderer.
Definition: VisualCanvasRenderer.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___Model.GeometricObjects.Lanes.BezierLane.SecondControlLocation
Point SecondControlLocation
Second control location of point.
Definition: BezierLane.cs:70
Microscopic_Traffic_Simulator___Model.GeometricObjects.Lanes.BezierLane
Represents single bezier lane.
Definition: BezierLane.cs:11
Microscopic_Traffic_Simulator___Model.GeometricObjects.Lanes.Lane.EndNode
Node EndNode
Node on the output end of lane.
Definition: Lane.cs:32
Microscopic_Traffic_Simulator___Model.GeometricObjects.GeometricTopology.Lanes
ReadOnlyCollection< Lane > Lanes
Lanes in geometric topology. </summary
Definition: GeometricTopology.cs:23
Microscopic_Traffic_Simulator
Definition: App.xaml.cs:12
Microscopic_Traffic_Simulator.Renderers.BezierCurveGeometryCreator
Class for creating geometry with bezier curve from canvas-coordinated points.
Definition: BezierCurveGeometryCreator.cs:10
Microscopic_Traffic_Simulator___Model.GeometricObjects.Lanes
Definition: BezierLane.cs:5
Microscopic_Traffic_Simulator___Model.GeometricObjects.Lanes.BezierLane.FirstControlLocation
Point FirstControlLocation
First control location of point.
Definition: BezierLane.cs:57
Microscopic_Traffic_Simulator___Model.GeometricObjects
Definition: GeometricTopology.cs:8
Microscopic_Traffic_Simulator.Renderers.TopologyRenderer.Render
override void Render(Point currentMouseLocation)
Redraw geometric topology on drawing visual. Current mouse location
Definition: TopologyRenderer.cs:38
Microscopic_Traffic_Simulator___Model