Microscopic Traffic Simulator
TopologyRenderer.cs
Go to the documentation of this file.
3 using System.Collections.Generic;
4 using System.Windows;
5 using System.Windows.Media;
6 
7 namespace Microscopic_Traffic_Simulator.Renderers
8 {
13  {
14  private const double GeneratorCircleRadius = 2.0;
15 
19  private 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 }
Class representing geometric topology of road network.
StartNode StartNode
Node on the input end of lane.
Definition: Lane.cs:23
Point SecondControlLocation
Second control location of point.
Definition: BezierLane.cs:70
Node EndNode
Node on the output end of lane.
Definition: Lane.cs:32
ReadOnlyCollection< Lane > Lanes
Lanes in geometric topology. </summary
Class for creating geometry with bezier curve from canvas-coordinated points.
override void Render(Point currentMouseLocation)
Redraw geometric topology on drawing visual. Current mouse location