/// <summary> /// Draws the series using the <see cref="IRenderContext2D" /> and the <see cref="IRenderPassData" /> passed in /// </summary> /// <param name="renderContext">The render context. This is a graphics object which has methods to draw lines, quads and polygons to the screen</param> /// <param name="renderPassData">The render pass data. Contains a resampled /// <see cref="IPointSeries" />, the /// <see cref="IndexRange" /> of points on the screen /// and the current YAxis and XAxis /// <see cref="ICoordinateCalculator{T}" /> to convert data-points to screen points</param> protected override void Draw(IRenderContext2D renderContext, IRenderPassData renderPassData) { base.Draw(renderContext, renderPassData); // Get the data from RenderPassData. See CustomRenderableSeries article which describes PointSeries relationship to DataSeries if (renderPassData.PointSeries.Count == 0) { return; } // Convert to Spline Series _splineSeries = ComputeSplineSeries(renderPassData.PointSeries, IsSplineEnabled, UpSampleFactor); // Get the coordinates of the first dataPoint var point = GetCoordinatesFor(_splineSeries[0].X, _splineSeries[0].Y); // Create a pen to draw the spline line. Make sure you dispose it! using (var linePen = renderContext.CreatePen(this.Stroke, this.AntiAliasing, this.StrokeThickness)) { // Create a line drawing context. Make sure you dispose it! // NOTE: You can create mutliple line drawing contexts to draw segments if you want // You can also call renderContext.DrawLine() and renderContext.DrawLines(), but the lineDrawingContext is higher performance using (var lineDrawingContext = renderContext.BeginLine(linePen, point.X, point.Y)) { for (int i = 1; i < _splineSeries.Count; i++) { point = GetCoordinatesFor(_splineSeries[i].X, _splineSeries[i].Y); lineDrawingContext.MoveTo(point.X, point.Y); } } } DrawPointMarkers(renderContext, renderPassData.PointSeries); }
private void CustomDraw(IRenderContext2D renderContext, IRenderPassData renderPassData) { var dataPointSeries = renderPassData.PointSeries as Point2DSeries; foreach (var pt in ptList) { System.Windows.Media.Color ptColor = System.Windows.Media.Color.FromArgb(pt.Color.A, pt.Color.R, pt.Color.G, pt.Color.B); var ptRefLocal = GetRenderingPoint(new Point(pt.Pt.X, pt.Pt.Y)); /// Create a pen to draw. Make sure you dispose it! using (var ptPen = renderContext.CreatePen(ptColor, this.AntiAliasing, (float)1)) { using (var ptBrush = renderContext.CreateBrush(new SolidColorBrush(ptColor))) { renderContext.DrawEllipse(ptPen, ptBrush, ptRefLocal, pt.Width, pt.Width); //using (var lineDrawingContext = renderContext.BeginLine(linePen, initialPoint.X, initialPoint.Y)) // { // lineDrawingContext.MoveTo(endPoint.X, endPoint.Y); // lineDrawingContext.End(); // } } } } }
protected override void Draw(IRenderContext2D renderContext, IRenderPassData renderPassData) { var xcal = renderPassData.XCoordinateCalculator; var ycal = renderPassData.YCoordinateCalculator; var surf = GetParentSurface(); var xrange = surf.XAxis.VisibleRange.AsDoubleRange(); var yrange = surf.YAxis.VisibleRange.AsDoubleRange(); var area = new Rect(xrange.Min, yrange.Min, xrange.Diff, yrange.Diff); var pixTakeCare = 3; var pixSizeX = (TReal)Math.Abs(xcal.GetDataValue(pixTakeCare) - xcal.GetDataValue(0.0)); var pixSizeY = (TReal)Math.Abs(ycal.GetDataValue(0.0) - ycal.GetDataValue(pixTakeCare)); var found = DataSeries.FindInArea(area, pixSizeX, pixSizeY); var brush = renderContext.CreateBrush(new SolidColorBrush(Colors.BlueViolet)); var pen = renderContext.CreatePen(Colors.Black, false, 1); foreach (var rect in found) { DrawRectangle(renderContext, pen, brush, xcal, ycal, (TReal)rect.X, (TReal)rect.Y, (TReal)rect.Width, (TReal)rect.Height); } brush.Dispose(); pen.Dispose(); var sdbg = DataSeries as Series4; //sdbg.DrawNodes(renderContext, xcal, ycal, area, pixSizeX, pixSizeY); }
protected override void Draw(IRenderContext2D renderContext, IRenderPassData renderPassData) { base.Draw(renderContext, renderPassData); // Create a line drawing context. Make sure you dispose it! // NOTE: You can create mutliple line drawing contexts to draw segments if you want // You can also call renderContext.DrawLine() and renderContext.DrawLines(), but the lineDrawingContext is higher performance CustomDraw(renderContext, renderPassData); }
/// <inheritdoc/> protected override IRenderPassData Animate(IRenderPassData rpd, double currentProgress) { if (rpd?.PointSeries != null) { CustomTransform(rpd.PointSeries, currentProgress); } return(rpd); }
protected override void InternalDraw(Abt.Controls.SciChart.Rendering.Common.IRenderContext2D renderContext, IRenderPassData renderPassData) { var pointSeries = CurrentRenderPassData.PointSeries; var shiftedLine = new LinesEnumerable(pointSeries, renderPassData.XCoordinateCalculator, renderPassData.YCoordinateCalculator, false).Select(u => new Point(u.X, u.Y - 5)); using (var segmentPen = renderContext.CreatePen(SeriesColor, AntiAliasing, StrokeThickness, Opacity, StrokeDashArray)) { renderContext.DrawLines(segmentPen, shiftedLine); } base.InternalDraw(renderContext, renderPassData); }
protected override void Draw(IRenderContext2D renderContext, IRenderPassData renderPassData) { base.Draw(renderContext, renderPassData); // Do the drawing for our timeline here // // Input data is type XyzPointSeries so must be cast var inputData = renderPassData.PointSeries as XyzPointSeries; // Get X,Y axis calculators var xCalc = renderPassData.XCoordinateCalculator; var yCalc = renderPassData.YCoordinateCalculator; // Compute some constants double yMid = YOffset; double halfHeight = Height * 0.5; // Iterate over the data for (int i = 0; i < inputData.Count; i++) { // Now compute the bounds of the box to draw for one data-points // XStart = X, XEnd = XStart + Y (we use Y for the length of the box) // YTop, YBottom defined by Height + YOffset properties double xStartCoord = xCalc.GetCoordinate(inputData.XValues[i]); double xEndCoord = xStartCoord + xCalc.GetCoordinate(inputData.YValues[i]); double yTop = yCalc.GetCoordinate(yMid + halfHeight); double yBottom = yCalc.GetCoordinate(yMid - halfHeight); // Get the color for this block int iColor = (int)inputData.ZPoints[i]; Color fill = iColor.ToColor(); // Brush creation can be expensive, cache brushes keyed on int color if you find this using (var scichartBrush = renderContext.CreateBrush(fill)) { // Draw a rectangle renderContext.FillRectangle(scichartBrush, new Point(xStartCoord, yBottom), new Point(xEndCoord, yTop)); // NOTE: // You can draw fill, stroke, and fills can be linear gradient brushes if you want. // Extra data can be passed through the Metadata parameter in XyzDataSeries } } }
protected override void Draw(IRenderContext2D renderContext, IRenderPassData renderPassData) { base.Draw(renderContext, renderPassData); // Create a line drawing context. Make sure you dispose it! // NOTE: You can create mutliple line drawing contexts to draw segments if you want // You can also call renderContext.DrawLine() and renderContext.DrawLines(), but the lineDrawingContext is higher performance foreach (var p in polygonList) { Polygon polygon = p.Value.polygon; if (polygon.Points.Count > 0) { Point initialPoint = GetRenderingPoint(polygon.Points[0]); System.Windows.Media.Color backgroundColor = System.Windows.Media.Color.FromArgb(p.Value.backgroundColor.A, p.Value.backgroundColor.R, p.Value.backgroundColor.G, p.Value.backgroundColor.B); using (var brush = renderContext.CreateBrush(backgroundColor)) { //IEnumerable<Point> points; // define your points renderContext.FillPolygon(brush, GetRenderingPoints(polygon.Points)); } //// Create a pen to draw. Make sure you dispose it! System.Windows.Media.Color borderColor = System.Windows.Media.Color.FromArgb(p.Value.borderColor.A, p.Value.borderColor.R, p.Value.borderColor.G, p.Value.borderColor.B); using (var linePen = renderContext.CreatePen(borderColor, this.AntiAliasing, p.Value.borderWidth, p.Value.borderOpacity, p.Value.borderDashPattern)) { using (var lineDrawingContext = renderContext.BeginLine(linePen, initialPoint.X, initialPoint.Y)) { for (int i = 1; i < polygon.Points.Count; i++) { lineDrawingContext.MoveTo(GetRenderingPoint(polygon.Points[i]).X, GetRenderingPoint(polygon.Points[i]).Y); } lineDrawingContext.End(); } } } } }
protected override void Draw(IRenderContext2D renderContext, IRenderPassData renderPassData) { var xcal = renderPassData.XCoordinateCalculator; var ycal = renderPassData.YCoordinateCalculator; var surf = GetParentSurface(); var xrange = surf.XAxis.VisibleRange.AsDoubleRange(); var yrange = surf.YAxis.VisibleRange.AsDoubleRange(); var area = new Rect(xrange.Min, yrange.Min, xrange.Diff, yrange.Diff); var found = DataSeries.FindInArea(area); var brush = renderContext.CreateBrush(new SolidColorBrush(Colors.BlueViolet)); var pen = renderContext.CreatePen(Colors.Black, false, 1); foreach (var index in found) { var xv = DataSeries.XValues[index]; var yv = DataSeries.YValues[index]; var wv = DataSeries.WidthValues[index]; var hv = DataSeries.HeightValues[index]; DrawRectangle(renderContext, pen, brush, xcal, ycal, xv, yv, wv, hv); } brush.Dispose(); pen.Dispose(); }
protected override void Draw(IRenderContext2D renderContext, IRenderPassData renderPassData) { base.Draw(renderContext, renderPassData); // Get the CustomPointRenderableSeries.PointMarker to draw at original points // Assumes you have declared one in XAML or code // // e.g. CustomPointRenderableSeries.PointMarker = new EllipsePointMarker(); // var pointMarker = base.GetPointMarker(); if (pointMarker != null) { // The resampled data for this render pass var dataPointSeries = renderPassData.PointSeries; var xCalc = renderPassData.XCoordinateCalculator; var yCalc = renderPassData.YCoordinateCalculator; // Begin a batched PointMarker draw operation pointMarker.BeginBatch(renderContext, pointMarker.Stroke, pointMarker.Fill); // Iterate over the data for (int i = 0; i < dataPointSeries.Count; i++) { // Convert data to coords double xCoord = xCalc.GetCoordinate(dataPointSeries.XValues[i]); double yCoord = yCalc.GetCoordinate(dataPointSeries.YValues[i]); int dataIndex = dataPointSeries.Indexes[i]; // Draw at current location pointMarker.MoveTo(renderContext, xCoord, yCoord, dataIndex); } // End the batch // Note: To change point color, start a new batch pointMarker.EndBatch(renderContext); } }
protected override void InternalDraw(IRenderContext2D renderContext, IRenderPassData renderPassData) { base.InternalDraw(renderContext, renderPassData); Debug.WriteLine("Drawing! Custom series..."); }