/// <summary> /// Initializes a new instance of the <see cref="ScatterSegment3D"/> class. /// </summary> /// <param name="x1">The X1 Value</param> /// <param name="y1">The Y1 Value</param> /// <param name="startDepth">The Start Depth</param> /// <param name="endDepth">The End Depth</param> /// <param name="scatterSeries3D">The Scatter Series</param> public ScatterSegment3D(double x1, double y1, double startDepth, double endDepth, ScatterSeries3D scatterSeries3D) { Series = scatterSeries3D; SetData(x1, y1, startDepth, endDepth); }
/// <summary> /// Updates the segments based on its data point value. This method is not /// intended to be called explicitly outside the Chart but it can be overridden by /// any derived class. /// </summary> /// <param name="transformer">Represents the view port of chart control.(refer <see cref="IChartTransformer"/>)</param> public override void Update(IChartTransformer transformer) { Rect rect; double x, y, width, height; if (transformer == null) { return; } var cartesianTransformer = transformer as ChartTransform.ChartCartesianTransformer; if (cartesianTransformer == null) { return; } if (double.IsNaN(YData) && !Series.ShowEmptyPoints) { return; } ScatterSeries3D series = (Series as ScatterSeries3D); var xBase = cartesianTransformer.XAxis.IsLogarithmic ? ((LogarithmicAxis3D)cartesianTransformer.XAxis).LogarithmicBase : 1; var yBase = cartesianTransformer.YAxis.IsLogarithmic ? ((LogarithmicAxis3D)cartesianTransformer.YAxis).LogarithmicBase : 1; var xIsLogarithmic = cartesianTransformer.XAxis.IsLogarithmic; var yIsLogarithmic = cartesianTransformer.YAxis.IsLogarithmic; var xValue = xIsLogarithmic ? Math.Log(X, xBase) : X; var yValue = yIsLogarithmic ? Math.Log(Y, yBase) : Y; var yStart = cartesianTransformer.YAxis.VisibleRange.Start; var yEnd = cartesianTransformer.YAxis.VisibleRange.End; var xStart = cartesianTransformer.XAxis.VisibleRange.Start; var xEnd = cartesianTransformer.XAxis.VisibleRange.End; var zSeries = this.Series as XyzDataSeries3D; bool isZAxis = cartesianTransformer.ZAxis != null && zSeries.ActualZAxis != null && (zSeries as XyzDataSeries3D).ActualZValues != null; Point tlpoint = new Point(0, 0); double frontDepth = 0d; double backDepth = 0d; if (isZAxis) { var z1value = startDepth; var z2value = endDepth; var depthDelta = (this.Series as ScatterSeries3D).GetSegmentDepth((this.Series.ActualArea as SfChart3D).ActualDepth).Delta / 2; var zStart = cartesianTransformer.ZAxis.VisibleRange.Start; var zEnd = cartesianTransformer.ZAxis.VisibleRange.End; var zIsLogarithmic = cartesianTransformer.ZAxis.IsLogarithmic; var zBase = zIsLogarithmic ? ((LogarithmicAxis3D)cartesianTransformer.ZAxis).LogarithmicBase : 1; var actualZ1 = zIsLogarithmic ? Math.Log(z1value, zBase) : z1value; var actualZ2 = zIsLogarithmic ? Math.Log(z2value, zBase) : z2value; if (!(actualZ1 <= zEnd && actualZ2 >= zStart)) { return; } var zLogStart = zIsLogarithmic ? Math.Pow(zBase, zStart) : zStart; var zLogEnd = zIsLogarithmic ? Math.Pow(zBase, zEnd) : zEnd; var tldpoint = cartesianTransformer.TransformToVisible3D(xValue, yValue, actualZ1 <zStart?zLogStart : actualZ1> zEnd ? zLogEnd : z1value); tlpoint = new Point(tldpoint.X, tldpoint.Y); frontDepth = (z1value == zStart) ? tldpoint.Z : tldpoint.Z - ScatterHeight / 2 < tldpoint.Z - depthDelta ? tldpoint.Z - depthDelta : tldpoint.Z - ScatterHeight / 2; backDepth = (z2value == zEnd) ? tldpoint.Z : tldpoint.Z + ScatterHeight / 2 > tldpoint.Z + depthDelta ? tldpoint.Z + depthDelta : tldpoint.Z + ScatterHeight / 2; } else { tlpoint = transformer.TransformToVisible(X, Y); } if (!series.Area.SeriesClipRect.Contains(tlpoint) && ((xValue != xEnd && xValue != xStart) || (yValue != yEnd && yValue != yStart)) && !(series.IsTransposed)) { return; } if (series.ScatterHeight <= 0 || series.ScatterWidth <= 0) { return; } x = (xValue == (series.IsTransposed ? xEnd : xStart)) ? tlpoint.X : tlpoint.X - (series.IsTransposed ? ScatterHeight / 2 : ScatterWidth / 2); y = (yValue == (series.IsTransposed ? yStart : yEnd)) ? tlpoint.Y : tlpoint.Y - (series.IsTransposed ? ScatterWidth / 2 : ScatterHeight / 2); width = (xValue == xStart) || (xValue == xEnd) ? ScatterWidth / 2 : ScatterWidth; height = (yValue == yStart) || (yValue == yEnd) ? ScatterHeight / 2 : ScatterHeight; rect = new Rect(x, y, width, height); if (!series.IsTransposed) { // Clipping segment of nearest range point if (!Series.ActualArea.SeriesClipRect.Contains(new Point(x, y))) { rect = new Rect(x, Series.ActualArea.SeriesClipRect.Top, width, height + y); } if (!Series.ActualArea.SeriesClipRect.Contains(new Point(rect.Left, rect.Bottom))) { rect = new Rect(x, y, width, Math.Abs(height + (Series.ActualArea.SeriesClipRect.Bottom - rect.Bottom) > ScatterHeight ? height : height + (Series.ActualArea.SeriesClipRect.Bottom - rect.Bottom))); } if (!Series.ActualArea.SeriesClipRect.Contains(new Point(rect.Left, rect.Top))) { var modifiedWidth = Math.Abs(width - (Series.ActualXAxis.RenderedRect.X - rect.X)); rect = new Rect(Series.ActualXAxis.RenderedRect.X, y, modifiedWidth, rect.Height); } if (!Series.ActualArea.SeriesClipRect.Contains(new Point(rect.Left + rect.Width, rect.Top))) { var modifiedWidth = Math.Abs(rect.Width + (Series.ActualArea.SeriesClipRect.Right - rect.Right)); rect = new Rect(rect.X, rect.Y, modifiedWidth, rect.Height); } } else { rect = new Rect(x, y, height, width); if (x < tlpoint.X && xValue == xStart && yValue == yStart) { rect = new Rect(tlpoint.X, y, height, width); } if (y < tlpoint.Y && yValue == yStart) { rect = new Rect(tlpoint.X, tlpoint.Y, height, width); } if (y == tlpoint.Y && yValue == yStart) { rect = new Rect(tlpoint.X, tlpoint.Y - ScatterWidth / 2, height, width); } if (y < tlpoint.Y && xValue == xEnd) { rect = new Rect(tlpoint.X, tlpoint.Y, height, width); } if (x == tlpoint.X && xValue == xEnd) { rect = new Rect(tlpoint.X, tlpoint.Y, height, width); } if (x == tlpoint.X && xValue == xEnd && yValue != yStart) { rect = new Rect(tlpoint.X - ScatterHeight / 2, tlpoint.Y, height, width); } } var area = Series.ActualArea as SfChart3D; Vector3D tlfVector = new Vector3D(0, 0, 0); Vector3D brbVector = new Vector3D(0, 0, 0); if (isZAxis) { tlfVector = new Vector3D(rect.Left, rect.Top, frontDepth); brbVector = new Vector3D(rect.Right, rect.Bottom, backDepth); } else { tlfVector = new Vector3D(rect.Left, rect.Top, startDepth); brbVector = new Vector3D(rect.Right, rect.Bottom, startDepth + ScatterHeight > endDepth ? endDepth : startDepth + ScatterHeight); } if (plans == null) { plans = Polygon3D.CreateBox( tlfVector, brbVector, this, series.Segments.IndexOf(this), area.Graphics3D, Stroke, Interior, StrokeThickness, Series.IsActualTransposed); } else { Polygon3D.UpdateBox(plans, tlfVector, brbVector, Interior, Visibility.Visible); } }