Example #1
0
        public void Paint(Graphics g, IPlotArea layer, Altaxo.Graph.Gdi.Plot.Data.Processed2DPlotData pdata, Processed2DPlotData prevItemData, Processed2DPlotData nextItemData)
        {
            if (_fillToPrevPlotItem && null != prevItemData)
            {
                PaintFillToPrevPlotItem(g, layer, pdata, prevItemData);
            }

            if (_fillToNextPlotItem && null != nextItemData)
            {
                // ensure that brush and pen are cached
                if (null != _fillBrush)
                {
                    _fillBrush.SetEnvironment(new RectangleD2D(PointD2D.Empty, layer.Size), BrushX.GetEffectiveMaximumResolution(g, 1));
                }

                PlotRangeList rangeList    = pdata.RangeList;
                int           rangelistlen = rangeList.Count;

                if (rangelistlen > 0)
                {
                    // we have to ignore the missing points here, thus all ranges can be plotted
                    // as one range, i.e. continuously
                    // for this, we create the totalRange, which contains all ranges
                    var totalRange = new PlotRange(rangeList[0].LowerBound, rangeList[rangelistlen - 1].UpperBound);
                    _cachedPaintOneRange(g, pdata, totalRange, layer, nextItemData);
                }
            }
        }
Example #2
0
        public void GetFillPath(GraphicsPath gp, IPlotArea layer, Processed2DPlotData pdata, CSPlaneID fillDirection)
        {
            PointF[] plotPositions = pdata.PlotPointsInAbsoluteLayerCoordinates;
            if (0 != _cachedLogicalShiftX || 0 != _cachedLogicalShiftY)
            {
                plotPositions = Processed2DPlotData.GetPlotPointsInAbsoluteLayerCoordinatesWithShift(pdata, layer, _cachedLogicalShiftX, _cachedLogicalShiftY);
            }

            PlotRangeList rangeList = pdata.RangeList;

            fillDirection = layer.UpdateCSPlaneID(fillDirection);

            int rangelistlen = rangeList.Count;

            if (_ignoreMissingDataPoints)
            {
                // in case we ignore the missing points, all ranges can be plotted
                // as one range, i.e. continuously
                // for this, we create the totalRange, which contains all ranges
                var totalRange = new PlotRange(rangeList[0].LowerBound, rangeList[rangelistlen - 1].UpperBound);
                _connectionStyle.FillOneRange(gp, pdata, totalRange, layer, fillDirection, _ignoreMissingDataPoints, _connectCircular, plotPositions, _cachedLogicalShiftX, _cachedLogicalShiftY);
            }
            else // we not ignore missing points, so plot all ranges separately
            {
                for (int i = 0; i < rangelistlen; i++)
                {
                    _connectionStyle.FillOneRange(gp, pdata, rangeList[i], layer, fillDirection, _ignoreMissingDataPoints, _connectCircular, plotPositions, _cachedLogicalShiftX, _cachedLogicalShiftY);
                }
            }
        }
Example #3
0
		/// <summary>
		/// Template to make a line draw.
		/// </summary>
		/// <param name="g">Graphics context.</param>
		/// <param name="pdata">The plot data. Don't use the Range property of the pdata, since it is overriden by the next argument.</param>
		/// <param name="range">The plot range to use.</param>
		/// <param name="layer">Graphics layer.</param>
		/// <param name="pen">The pen to draw the line.</param>
		/// <param name="symbolGap">The size of the symbol gap. Argument is the original index of the data. The return value is the absolute symbol gap at this index.
		/// This function is null if no symbol gap is required.</param>
		/// <param name="skipFrequency">Skip frequency. Normally 1, thus all gaps are taken into account. If 2, only every 2nd gap is taken into account, and so on.</param>
		/// <param name="connectCircular">If true, the end of the line is connected with the start of the line.</param>
		public abstract void Paint(
			IGraphicsContext3D g,
			Processed3DPlotData pdata,
			PlotRange range,
			IPlotArea layer,
			PenX3D pen,
			Func<int, double> symbolGap,
			int skipFrequency,
			bool connectCircular);
Example #4
0
 /// <summary>
 /// Template to make a line draw.
 /// </summary>
 /// <param name="g">Graphics context.</param>
 /// <param name="pdata">The plot data. Don't use the Range property of the pdata, since it is overriden by the next argument.</param>
 /// <param name="range">The plot range to use.</param>
 /// <param name="layer">Graphics layer.</param>
 /// <param name="pen">The pen to draw the line.</param>
 /// <param name="symbolGap">The size of the symbol gap. Argument is the original index of the data. The return value is the absolute symbol gap at this index.
 /// This function is null if no symbol gap is required.</param>
 /// <param name="skipFrequency">Skip frequency. Normally 1, thus all gaps are taken into account. If 2, only every 2nd gap is taken into account, and so on.</param>
 /// <param name="connectCircular">If true, the end of the line is connected with the start of the line.</param>
 public abstract void Paint(
     IGraphicsContext3D g,
     Processed3DPlotData pdata,
     PlotRange range,
     IPlotArea layer,
     PenX3D pen,
     Func <int, double> symbolGap,
     int skipFrequency,
     bool connectCircular);
Example #5
0
        public override void Run(RenderControl render)
        {
            if (!ReadData())
            {
                return;
            }

            var matplot = Matplot.Create("MyMatlab 2020");

            var xRange = new PlotRange(mMinX, mMaxX - 1, 1);
            var yRange = new PlotRange(mMinY, mMaxY - 1, 1);

            matplot.AddSurface(xRange, yRange, (idxU, idxV, u, v) =>
            {
                double x = u;
                double y = v;
                double z = mData[idxU + 1][idxV + 1];

                return(new GPnt(x, y, z));
            });

            var node = matplot.Build(ColorMapKeyword.Create(EnumSystemColorMap.Cooltowarm));

            node.SetPickable(false);

            var pw = new PaletteWidget();

            pw.Update(matplot.GetColorTable());

            render.ShowSceneNode(pw);
            render.ShowSceneNode(node);

            var material = MeshPhongMaterial.Create("font-x");

            material.SetColor(Vector3.Red);
            var shape = FontManager.Instance().CreateMesh("Create a better world!");

            shape.SetMaterial(material);
            var text = new TextSceneNode(shape, 24, true);
            //var text = new TextSceneNode("Wow", 24, new Vector3(1, 1, 0), Vector3.Red, false);
            var tag = TagNode2D.Create(text, new Vector3(15), new Vector3(0));

            render.ShowSceneNode(tag);
        }
        public override void Run(RenderControl render)
        {
            var matplot = Matplot.Create("MyMatlab");

            var xRange = new PlotRange(0, 3.14f * 2, 0.1f);
            var yRange = new PlotRange(0, 3.14f * 2, 0.1f);

            matplot.AddSurface(xRange, yRange, (idxU, idxV, u, v) =>
            {
                double x = u;
                double y = v;
                double z = Math.Sin(u) + Math.Cos(v);

                return(new GPnt(x, y, z));
            });

            var node = matplot.Build(ColorMapKeyword.Create(EnumSystemColorMap.Rainbow));

            node.SetPickable(false);
            render.ShowSceneNode(node);
        }
Example #7
0
        public void Paint(IGraphicsContext3D g, IPlotArea layer, Processed3DPlotData pdata, Processed3DPlotData prevItemData, Processed3DPlotData nextItemData)
        {
            var linePoints   = pdata.PlotPointsInAbsoluteLayerCoordinates;
            var rangeList    = pdata.RangeList;
            var symbolGap    = _symbolSize;
            int rangelistlen = rangeList.Count;

            Func <int, double> symbolGapFunction = null;

            if (_useSymbolGap)
            {
                if (null != _cachedSymbolSizeForIndexFunction && !_independentSymbolSize)
                {
                    symbolGapFunction = (idx) => _symbolGapOffset + _symbolGapFactor * _cachedSymbolSizeForIndexFunction(idx);
                }
                else
                {
                    symbolGapFunction = (idx) => _symbolGapOffset + _symbolGapFactor * _symbolSize;
                }
            }

            if (_ignoreMissingDataPoints)
            {
                // in case we ignore the missing points, all ranges can be plotted
                // as one range, i.e. continuously
                // for this, we create the totalRange, which contains all ranges
                var totalRange = new PlotRange(rangeList[0].LowerBound, rangeList[rangelistlen - 1].UpperBound);
                _connectionStyle.Paint(g, pdata, totalRange, layer, _linePen, symbolGapFunction, _skipFreq, _connectCircular);
            }
            else // we not ignore missing points, so plot all ranges separately
            {
                for (int i = 0; i < rangelistlen; i++)
                {
                    _connectionStyle.Paint(g, pdata, rangeList[i], layer, _linePen, symbolGapFunction, _skipFreq, _connectCircular);
                }
            }
        }
Example #8
0
		public void GetFillPath(GraphicsPath gp, IPlotArea layer, Processed2DPlotData pdata, CSPlaneID fillDirection)
		{
			PointF[] plotPositions = pdata.PlotPointsInAbsoluteLayerCoordinates;
			if (0 != _cachedLogicalShiftX || 0 != _cachedLogicalShiftY)
			{
				plotPositions = Processed2DPlotData.GetPlotPointsInAbsoluteLayerCoordinatesWithShift(pdata, layer, _cachedLogicalShiftX, _cachedLogicalShiftY);
			}

			PlotRangeList rangeList = pdata.RangeList;
			fillDirection = layer.UpdateCSPlaneID(fillDirection);

			int rangelistlen = rangeList.Count;

			if (this._ignoreMissingDataPoints)
			{
				// in case we ignore the missing points, all ranges can be plotted
				// as one range, i.e. continuously
				// for this, we create the totalRange, which contains all ranges
				PlotRange totalRange = new PlotRange(rangeList[0].LowerBound, rangeList[rangelistlen - 1].UpperBound);
				_connectionStyle.FillOneRange(gp, pdata, totalRange, layer, fillDirection, _ignoreMissingDataPoints, _connectCircular, plotPositions, _cachedLogicalShiftX, _cachedLogicalShiftY);
			}
			else // we not ignore missing points, so plot all ranges separately
			{
				for (int i = 0; i < rangelistlen; i++)
				{
					_connectionStyle.FillOneRange(gp, pdata, rangeList[i], layer, fillDirection, _ignoreMissingDataPoints, _connectCircular, plotPositions, _cachedLogicalShiftX, _cachedLogicalShiftY);
				}
			}
		}
Example #9
0
		/// <summary>
		/// Template to make a line draw.
		/// </summary>
		/// <param name="g">Graphics context.</param>
		/// <param name="pdata">The plot data. Don't use the Range property of the pdata, since it is overriden by the next argument.</param>
		/// <param name="range">The plot range to use.</param>
		/// <param name="layer">Graphics layer.</param>
		/// <param name="pen">The pen to draw the line.</param>
		/// <param name="symbolGap">The size of the symbol gap. Argument is the original index of the data. The return value is the absolute symbol gap at this index. This function is null if no symbol gap is required.</param>
		/// <param name="skipFrequency">Skip frequency. Normally 1, thus all gaps are taken into account. If 2, only every 2nd gap is taken into account, and so on.</param>
		/// <param name="connectCircular">If true, the end of the line is connected with the start of the line.</param>
		public override void Paint(
			IGraphicsContext3D g,
			Processed3DPlotData pdata,
			PlotRange range,
			IPlotArea layer,
			PenX3D pen,
			Func<int, double> symbolGap,
			int skipFrequency,
			bool connectCircular)
		{
			var linePoints = pdata.PlotPointsInAbsoluteLayerCoordinates;
			var linepts = new PointD3D[range.Length + (connectCircular ? 1 : 0)];
			Array.Copy(linePoints, range.LowerBound, linepts, 0, range.Length); // Extract
			if (connectCircular) linepts[linepts.Length - 1] = linepts[0];
			int lastIdx = range.Length - 1 + (connectCircular ? 1 : 0);
			var layerSize = layer.Size;

			if (symbolGap != null)
			{
				if (skipFrequency <= 1) // skip all scatter symbol gaps -> thus skipOffset can be ignored
				{
					for (int i = 0; i < lastIdx; i++)
					{
						int originalIndex = range.OffsetToOriginal + i;
						var diff = linepts[i + 1] - linepts[i];
						double gapAtStart = symbolGap(originalIndex);
						double gapAtEnd = i != (range.Length-1) ? symbolGap(originalIndex + 1) : symbolGap(range.OffsetToOriginal);
						var relAtStart = 0.5 * gapAtStart / diff.Length; // 0.5 because symbolGap is the full gap between two lines, thus between the symbol center and the beginning of the line it is only 1/2
						var relAtEnd = 0.5 * gapAtEnd / diff.Length; // 0.5 because symbolGap is the full gap between two lines, thus between the symbol center and the beginning of the line it is only 1/2
						if ((relAtStart + relAtEnd) < 1) // a line only appears if sum of the gaps  is smaller than 1
						{
							var start = linepts[i] + relAtStart * diff;
							var stop = linepts[i + 1] - relAtEnd * diff;

							g.DrawLine(pen, start, stop);
						}
					} // end for
				} // skipFrequency was 1
				else // skipFrequency is > 1
				{
					for (int i = 0; i < lastIdx; i += skipFrequency)
					{
						int originalRowIndex = range.OriginalFirstPoint + i;

						double gapAtStart = symbolGap(originalRowIndex);
						double gapAtEnd = i != range.Length ? symbolGap(originalRowIndex + skipFrequency) : symbolGap(range.OffsetToOriginal);

						IPolylineD3D polyline = SharpPolylineD3D.FromPointsWithPossibleDublettes(linepts.Skip(i).Take(1 + skipFrequency));
						polyline = polyline.ShortenedBy(RADouble.NewAbs(gapAtStart / 2), RADouble.NewAbs(gapAtEnd / 2));

						if (null != polyline)
							g.DrawLine(pen, polyline);
					} // end for.
				}
			}
			else // no line symbol gap required, so we can use DrawLines to draw the lines
			{
				if (linepts.Length > 1) // we don't want to have a drawing exception if number of points is only one
				{
					g.DrawLine(pen, SharpPolylineD3D.FromPointsWithPossibleDublettes(linepts));
				}
			}
		}
Example #10
0
        public void StraightConnection_PaintOneRange(
            Graphics g,
            Processed2DPlotData pdata,
            PlotRange range,
            IPlotArea layer,
            Processed2DPlotData previousData)
        {
            PointF[] linePoints = pdata.PlotPointsInAbsoluteLayerCoordinates;
            var      linepts    = new PointF[range.Length];

            Array.Copy(linePoints, range.LowerBound, linepts, 0, range.Length); // Extract
            int lastIdx = range.Length - 1;

            // Try to find points with a similar x value on otherlinepoints
            double firstLogicalX      = layer.XAxis.PhysicalVariantToNormal(pdata.GetXPhysical(range.OriginalFirstPoint));
            double lastLogicalX       = layer.XAxis.PhysicalVariantToNormal(pdata.GetXPhysical(range.OriginalLastPoint));
            double minDistanceToFirst = double.MaxValue;
            double minDistanceToLast  = double.MaxValue;
            int    minIdxFirst        = -1;
            int    minIdxLast         = -1;

            foreach (var rangeP in previousData.RangeList)
            {
                for (int i = rangeP.LowerBound; i < rangeP.UpperBound; ++i)
                {
                    double logicalX = layer.XAxis.PhysicalVariantToNormal(previousData.GetXPhysical(i + rangeP.OffsetToOriginal));
                    if (Math.Abs(logicalX - firstLogicalX) < minDistanceToFirst)
                    {
                        minDistanceToFirst = Math.Abs(logicalX - firstLogicalX);
                        minIdxFirst        = i;
                    }
                    if (Math.Abs(logicalX - lastLogicalX) < minDistanceToLast)
                    {
                        minDistanceToLast = Math.Abs(logicalX - lastLogicalX);
                        minIdxLast        = i;
                    }
                }
            }

            // if nothing found, use the outmost boundaries of the plot points of the other data item
            if (minIdxFirst < 0)
            {
                minIdxFirst = 0;
            }
            if (minIdxLast < 0)
            {
                minIdxLast = previousData.PlotPointsInAbsoluteLayerCoordinates.Length - 1;
            }

            var otherLinePoints = new PointF[minIdxLast + 1 - minIdxFirst];

            Array.Copy(previousData.PlotPointsInAbsoluteLayerCoordinates, minIdxFirst, otherLinePoints, 0, otherLinePoints.Length);
            Array.Reverse(otherLinePoints);

            // now paint this

            var gp        = new GraphicsPath();
            var layerSize = layer.Size;

            gp.StartFigure();
            gp.AddLines(linepts);
            gp.AddLines(otherLinePoints);
            gp.CloseFigure();

            if (_fillBrush.IsVisible)
            {
                g.FillPath(_fillBrush, gp);
            }

            if (null != _framePen)
            {
                g.DrawPath(_framePen, gp);
            }

            gp.Reset();
        } // end function PaintOneRange
Example #11
0
		public void StraightConnection_PaintOneRange(
			Graphics g,
			Processed2DPlotData pdata,
			PlotRange range,
			IPlotArea layer,
			Processed2DPlotData previousData)
		{
			PointF[] linePoints = pdata.PlotPointsInAbsoluteLayerCoordinates;
			PointF[] linepts = new PointF[range.Length];
			Array.Copy(linePoints, range.LowerBound, linepts, 0, range.Length); // Extract
			int lastIdx = range.Length - 1;

			// Try to find points with a similar x value on otherlinepoints
			double firstLogicalX = layer.XAxis.PhysicalVariantToNormal(pdata.GetXPhysical(range.OriginalFirstPoint));
			double lastLogicalX = layer.XAxis.PhysicalVariantToNormal(pdata.GetXPhysical(range.OriginalLastPoint));
			double minDistanceToFirst = double.MaxValue;
			double minDistanceToLast = double.MaxValue;
			int minIdxFirst = -1;
			int minIdxLast = -1;
			foreach (var rangeP in previousData.RangeList)
			{
				for (int i = rangeP.LowerBound; i < rangeP.UpperBound; ++i)
				{
					double logicalX = layer.XAxis.PhysicalVariantToNormal(previousData.GetXPhysical(i + rangeP.OffsetToOriginal));
					if (Math.Abs(logicalX - firstLogicalX) < minDistanceToFirst)
					{
						minDistanceToFirst = Math.Abs(logicalX - firstLogicalX);
						minIdxFirst = i;
					}
					if (Math.Abs(logicalX - lastLogicalX) < minDistanceToLast)
					{
						minDistanceToLast = Math.Abs(logicalX - lastLogicalX);
						minIdxLast = i;
					}
				}
			}

			// if nothing found, use the outmost boundaries of the plot points of the other data item
			if (minIdxFirst < 0)
				minIdxFirst = 0;
			if (minIdxLast < 0)
				minIdxLast = previousData.PlotPointsInAbsoluteLayerCoordinates.Length - 1;

			PointF[] otherLinePoints = new PointF[minIdxLast + 1 - minIdxFirst];
			Array.Copy(previousData.PlotPointsInAbsoluteLayerCoordinates, minIdxFirst, otherLinePoints, 0, otherLinePoints.Length);
			Array.Reverse(otherLinePoints);

			// now paint this

			GraphicsPath gp = new GraphicsPath();
			var layerSize = layer.Size;

			gp.StartFigure();
			gp.AddLines(linepts);
			gp.AddLines(otherLinePoints);
			gp.CloseFigure();

			if (_fillBrush.IsVisible)
			{
				g.FillPath(this._fillBrush, gp);
			}

			if (null != _framePen)
				g.DrawPath(_framePen, gp);

			gp.Reset();
		} // end function PaintOneRange
Example #12
0
		private void PaintFillToPrevPlotItem(Graphics g, IPlotArea layer, Altaxo.Graph.Gdi.Plot.Data.Processed2DPlotData pdata, Processed2DPlotData prevItemData)
		{
			// ensure that brush and pen are cached
			if (null != _fillBrush)
			{
				_fillBrush.SetEnvironment(new RectangleD2D(PointD2D.Empty, layer.Size), BrushX.GetEffectiveMaximumResolution(g, 1));
			}

			PlotRangeList rangeList = pdata.RangeList;
			int rangelistlen = rangeList.Count;

			// we have to ignore the missing points here, thus all ranges can be plotted
			// as one range, i.e. continuously
			// for this, we create the totalRange, which contains all ranges
			PlotRange totalRange = new PlotRange(rangeList[0].LowerBound, rangeList[rangelistlen - 1].UpperBound, rangeList[0].OffsetToOriginal);
			_cachedPaintOneRange(g, pdata, totalRange, layer, prevItemData);
		}
Example #13
0
        public void Paint(Graphics g, IPlotArea layer, Processed2DPlotData pdata)
        {
            PlotRangeList rangeList = pdata.RangeList;

            PointF[] ptArray = pdata.PlotPointsInAbsoluteLayerCoordinates;

            // adjust the skip frequency if it was not set appropriate
            if (_skipFreq <= 0)
            {
                _skipFreq = 1;
            }

            // paint the drop style
            if (this.DropLine.Count > 0)
            {
                foreach (CSPlaneID id in _dropLine)
                {
                    layer.UpdateCSPlaneID(id);
                }

                int       rangeidx = 0;
                PlotRange range    = pdata.RangeList[rangeidx];
                for (int j = 0; j < ptArray.Length; j += _skipFreq)
                {
                    // syncronize range
                    while (j >= range.UpperBound)
                    {
                        rangeidx++;
                        range = pdata.RangeList[rangeidx];
                    }

                    Logical3D r3d = layer.GetLogical3D(pdata, j + range.OffsetToOriginal);
                    foreach (CSPlaneID id in _dropLine)
                    {
                        layer.CoordinateSystem.DrawIsolineFromPointToPlane(g, this._pen, r3d, id);
                    }
                }
            } // end paint the drop style


            // paint the scatter style
            if (this.Shape != XYPlotScatterStyles.Shape.NoSymbol)
            {
                // save the graphics stat since we have to translate the origin
                System.Drawing.Drawing2D.GraphicsState gs = g.Save();


                float xpos = 0, ypos = 0;
                float xdiff, ydiff;
                for (int j = 0; j < ptArray.Length; j += _skipFreq)
                {
                    xdiff = ptArray[j].X - xpos;
                    ydiff = ptArray[j].Y - ypos;
                    xpos  = ptArray[j].X;
                    ypos  = ptArray[j].Y;
                    g.TranslateTransform(xdiff, ydiff);
                    this.Paint(g);
                } // end for

                g.Restore(gs); // Restore the graphics state
            }
        }
Example #14
0
        /// <summary>
        /// Template to make a line draw.
        /// </summary>
        /// <param name="g">Graphics context.</param>
        /// <param name="pdata">The plot data. Don't use the Range property of the pdata, since it is overriden by the next argument.</param>
        /// <param name="range">The plot range to use.</param>
        /// <param name="layer">Graphics layer.</param>
        /// <param name="pen">The pen to draw the line.</param>
        /// <param name="symbolGap">The size of the symbol gap. Argument is the original index of the data. The return value is the absolute symbol gap at this index. This function is null if no symbol gap is required.</param>
        /// <param name="skipFrequency">Skip frequency. Normally 1, thus all gaps are taken into account. If 2, only every 2nd gap is taken into account, and so on.</param>
        /// <param name="connectCircular">If true, the end of the line is connected with the start of the line.</param>
        public override void Paint(
            IGraphicsContext3D g,
            Processed3DPlotData pdata,
            PlotRange range,
            IPlotArea layer,
            PenX3D pen,
            Func <int, double> symbolGap,
            int skipFrequency,
            bool connectCircular)
        {
            var linePoints = pdata.PlotPointsInAbsoluteLayerCoordinates;
            var linepts    = new PointD3D[range.Length + (connectCircular ? 1 : 0)];

            Array.Copy(linePoints, range.LowerBound, linepts, 0, range.Length); // Extract
            if (connectCircular)
            {
                linepts[linepts.Length - 1] = linepts[0];
            }
            int lastIdx   = range.Length - 1 + (connectCircular ? 1 : 0);
            var layerSize = layer.Size;

            if (symbolGap != null)
            {
                if (skipFrequency <= 1) // skip all scatter symbol gaps -> thus skipOffset can be ignored
                {
                    for (int i = 0; i < lastIdx; i++)
                    {
                        int    originalIndex = range.OffsetToOriginal + i;
                        var    diff          = linepts[i + 1] - linepts[i];
                        double gapAtStart    = symbolGap(originalIndex);
                        double gapAtEnd      = i != (range.Length - 1) ? symbolGap(originalIndex + 1) : symbolGap(range.OffsetToOriginal);
                        var    relAtStart    = 0.5 * gapAtStart / diff.Length; // 0.5 because symbolGap is the full gap between two lines, thus between the symbol center and the beginning of the line it is only 1/2
                        var    relAtEnd      = 0.5 * gapAtEnd / diff.Length;   // 0.5 because symbolGap is the full gap between two lines, thus between the symbol center and the beginning of the line it is only 1/2
                        if ((relAtStart + relAtEnd) < 1)                       // a line only appears if sum of the gaps  is smaller than 1
                        {
                            var start = linepts[i] + relAtStart * diff;
                            var stop  = linepts[i + 1] - relAtEnd * diff;

                            g.DrawLine(pen, start, stop);
                        }
                    } // end for
                }     // skipFrequency was 1
                else  // skipFrequency is > 1
                {
                    for (int i = 0; i < lastIdx; i += skipFrequency)
                    {
                        int originalRowIndex = range.OriginalFirstPoint + i;

                        double gapAtStart = symbolGap(originalRowIndex);
                        double gapAtEnd   = i != range.Length ? symbolGap(originalRowIndex + skipFrequency) : symbolGap(range.OffsetToOriginal);

                        IPolylineD3D polyline = SharpPolylineD3D.FromPointsWithPossibleDublettes(linepts.Skip(i).Take(1 + skipFrequency));
                        polyline = polyline.ShortenedBy(RADouble.NewAbs(gapAtStart / 2), RADouble.NewAbs(gapAtEnd / 2));

                        if (null != polyline)
                        {
                            g.DrawLine(pen, polyline);
                        }
                    } // end for.
                }
            }
            else // no line symbol gap required, so we can use DrawLines to draw the lines
            {
                if (linepts.Length > 1) // we don't want to have a drawing exception if number of points is only one
                {
                    g.DrawLine(pen, SharpPolylineD3D.FromPointsWithPossibleDublettes(linepts));
                }
            }
        }
Example #15
0
		public void Paint(IGraphicsContext3D g, IPlotArea layer, Processed3DPlotData pdata, Processed3DPlotData prevItemData, Processed3DPlotData nextItemData)
		{
			var linePoints = pdata.PlotPointsInAbsoluteLayerCoordinates;
			var rangeList = pdata.RangeList;
			var symbolGap = _symbolSize;
			int rangelistlen = rangeList.Count;

			Func<int, double> symbolGapFunction = null;

			if (_useSymbolGap)
			{
				if (null != _cachedSymbolSizeForIndexFunction && !_independentSymbolSize)
				{
					symbolGapFunction = (idx) => _symbolGapOffset + _symbolGapFactor * _cachedSymbolSizeForIndexFunction(idx);
				}
				else
				{
					symbolGapFunction = (idx) => _symbolGapOffset + _symbolGapFactor * _symbolSize;
				}
			}

			if (this._ignoreMissingDataPoints)
			{
				// in case we ignore the missing points, all ranges can be plotted
				// as one range, i.e. continuously
				// for this, we create the totalRange, which contains all ranges
				PlotRange totalRange = new PlotRange(rangeList[0].LowerBound, rangeList[rangelistlen - 1].UpperBound);
				_connectionStyle.Paint(g, pdata, totalRange, layer, _linePen, symbolGapFunction, _skipFreq, _connectCircular);
			}
			else // we not ignore missing points, so plot all ranges separately
			{
				for (int i = 0; i < rangelistlen; i++)
				{
					_connectionStyle.Paint(g, pdata, rangeList[i], layer, _linePen, symbolGapFunction, _skipFreq, _connectCircular);
				}
			}
		}