/// <summary> /// Draws all the network lines. /// </summary> /// <param name="Network">The network from which to draw buses.</param> /// <param name="colorMap">A map of the colours to use from the specified gradient.</param> /// <param name="drawingContext">The target that we should draw to.</param> protected void DrawLines(NetworkModel Network, AdaptiveGradientMap <Tuple <Brush, Pen> > colorMap, DrawingContext drawingContext) { //Draw all the lines. foreach (Line line in Network.Lines) { if (line.ConnectedTo.Count() != 2) { continue; } Bus bus1 = (Bus)line.ConnectedTo.ElementAt(0); Bus bus2 = (Bus)line.ConnectedTo.ElementAt(1); if (!(bus1.Location.HasValue && bus2.Location.HasValue)) { continue; } //color based on average value. var bCol1 = BusVisibleTransform(bus1) ? BusColorTransform(bus1) : 0; var bCol2 = BusVisibleTransform(bus2) ? BusColorTransform(bus2) : 0; double v_avg = (bCol1 + bCol2) / 2; drawingContext.DrawLine( colorMap.Map(v_avg).Item2, //choose the right color for the value ScaledLocation(bus1.Location.Value), //scale the locations to image coordinates. ScaledLocation(bus2.Location.Value) ); } }
/// <summary> /// Draws all the network buses, using the specified value transforms. /// </summary> /// <param name="Network">The network from which to draw buses.</param> /// <param name="colorMap">A map of the colours to use from the specified gradient.</param> /// <param name="busSizeLimits">The limits of <see cref="BusSizeTransform"/>, /// used for scaling from that space to /// [<see cref="BusSizeMin"/>, <see cref="BusSizeMax"/>].</param> /// <param name="ringColorPen">A pen for drawing rings.</param> /// <param name="drawingContext">The target that we should draw to.</param> protected void DrawBuses(NetworkModel Network, AdaptiveGradientMap <Tuple <Brush, Pen> > colorMap, Limits busSizeLimits, Pen ringColorPen, DrawingContext drawingContext) { //Draw all the buses. foreach (var bus in Network.Buses.Values) { if (!(BusVisibleTransform(bus) && bus.Location.HasValue)) { continue; } var bSize = busSizeLimits.ValueScaledToLimits(BusSizeTransform(bus)); //value-dependant fill, no outline, centre is scaled, radius of 2 (small dots). drawingContext.DrawEllipse( colorMap.Map(BusColorTransform(bus)).Item1, null, ScaledLocation(bus.Location.Value), bSize, bSize); //Bus Ring if (RingEnabledTransform(bus)) { var ringRadius = RingDistanceFromCenter ? /*true*/ RingDistanceTransform(bus) : /*false*/ bSize + RingDistanceTransform(bus); drawingContext.DrawEllipse(null, ringColorPen, ScaledLocation(bus.Location.Value), ringRadius, ringRadius); } } }
/// <summary> /// Draws all the network lines. /// </summary> /// <param name="Network">The network from which to draw buses.</param> /// <param name="colorMap">A map of the colours to use from the specified gradient.</param> /// <param name="drawingContext">The target that we should draw to.</param> protected void DrawLines(NetworkModel Network, AdaptiveGradientMap<Tuple<Brush, Pen>> colorMap, DrawingContext drawingContext) { //Draw all the lines. foreach (Line line in Network.Lines) { if (line.ConnectedTo.Count() != 2) continue; Bus bus1 = (Bus)line.ConnectedTo.ElementAt(0); Bus bus2 = (Bus)line.ConnectedTo.ElementAt(1); if (!(bus1.Location.HasValue && bus2.Location.HasValue)) continue; //color based on average value. var bCol1 = BusVisibleTransform(bus1) ? BusColorTransform(bus1) : 0; var bCol2 = BusVisibleTransform(bus2) ? BusColorTransform(bus2) : 0; double v_avg = (bCol1 + bCol2) / 2; drawingContext.DrawLine( colorMap.Map(v_avg).Item2, //choose the right color for the value ScaledLocation(bus1.Location.Value), //scale the locations to image coordinates. ScaledLocation(bus2.Location.Value) ); } }
/// <summary> /// Draws all the network buses, using the specified value transforms. /// </summary> /// <param name="Network">The network from which to draw buses.</param> /// <param name="colorMap">A map of the colours to use from the specified gradient.</param> /// <param name="busSizeLimits">The limits of <see cref="BusSizeTransform"/>, /// used for scaling from that space to /// [<see cref="BusSizeMin"/>, <see cref="BusSizeMax"/>].</param> /// <param name="ringColorPen">A pen for drawing rings.</param> /// <param name="drawingContext">The target that we should draw to.</param> protected void DrawBuses(NetworkModel Network, AdaptiveGradientMap<Tuple<Brush, Pen>> colorMap, Limits busSizeLimits, Pen ringColorPen, DrawingContext drawingContext) { //Draw all the buses. foreach (var bus in Network.Buses.Values) { if (!(BusVisibleTransform(bus) && bus.Location.HasValue)) continue; var bSize = busSizeLimits.ValueScaledToLimits(BusSizeTransform(bus)); //value-dependant fill, no outline, centre is scaled, radius of 2 (small dots). drawingContext.DrawEllipse( colorMap.Map(BusColorTransform(bus)).Item1, null, ScaledLocation(bus.Location.Value), bSize, bSize); //Bus Ring if (RingEnabledTransform(bus)) { var ringRadius = RingDistanceFromCenter ? /*true*/ RingDistanceTransform(bus) : /*false*/ bSize + RingDistanceTransform(bus); drawingContext.DrawEllipse(null, ringColorPen, ScaledLocation(bus.Location.Value), ringRadius, ringRadius); } } }