示例#1
0
        private static BrushX GetShadowBrush(BrushX mainBrush)
        {
            BrushX cachedShadowBrush = null;

            switch (mainBrush.BrushType)
            {
            default:
            case BrushType.SolidBrush:
                cachedShadowBrush = new BrushX(NamedColor.FromArgb(mainBrush.Color.Color.A, 0, 0, 0));
                break;

            case BrushType.HatchBrush:
                cachedShadowBrush = new BrushX(NamedColor.FromArgb(mainBrush.Color.Color.A, 0, 0, 0));
                break;

            case BrushType.TextureBrush:
                cachedShadowBrush = new BrushX(NamedColors.Black);
                break;

            case BrushType.LinearGradientBrush:
            case BrushType.PathGradientBrush:
                cachedShadowBrush           = mainBrush.Clone();
                cachedShadowBrush.Color     = NamedColor.FromArgb(mainBrush.Color.Color.A, 0, 0, 0);
                cachedShadowBrush.BackColor = NamedColor.FromArgb(mainBrush.BackColor.Color.A, 0, 0, 0);
                break;
            }
            return(cachedShadowBrush);
        }
示例#2
0
        public void Paint(IGraphicsContext3D g, IPlotArea layer, Processed3DPlotData pdata, Processed3DPlotData prevItemData, Processed3DPlotData nextItemData)
        {
            PlotRangeList rangeList = pdata.RangeList;
            var           ptArray   = pdata.PlotPointsInAbsoluteLayerCoordinates;

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

            // paint the scatter style
            if (!ScatterSymbols.NoSymbol.Instance.Equals(_symbolShape))
            {
                PointD3D pos = PointD3D.Empty;

                if (null == _cachedSymbolSizeForIndexFunction && null == _cachedColorForIndexFunction) // using a constant symbol size
                {
                    for (int r = 0; r < rangeList.Count; r++)
                    {
                        var range = rangeList[r];
                        int lower = range.LowerBound;
                        int upper = range.UpperBound;
                        for (int j = lower; j < upper; j += _skipFreq)
                        {
                            _symbolShape.Paint(g, _material, ptArray[j], _symbolSize);
                        } // end for all points in range
                    }     // end for all ranges
                }
                else      // using a variable symbol size or variable symbol color
                {
                    for (int r = 0; r < rangeList.Count; r++)
                    {
                        int lower  = rangeList[r].LowerBound;
                        int upper  = rangeList[r].UpperBound;
                        int offset = rangeList[r].OffsetToOriginal;
                        for (int j = lower; j < upper; j += _skipFreq)
                        {
                            if (null == _cachedColorForIndexFunction)
                            {
                                double customSymbolSize = _cachedSymbolSizeForIndexFunction(j + offset);
                                _symbolShape.Paint(g, _material, ptArray[j], customSymbolSize);
                            }
                            else
                            {
                                double customSymbolSize  = null == _cachedSymbolSizeForIndexFunction ? _symbolSize : _cachedSymbolSizeForIndexFunction(j + offset);
                                var    customSymbolColor = _cachedColorForIndexFunction(j + offset);
                                _symbolShape.Paint(g, _material.WithColor(NamedColor.FromArgb(customSymbolColor.A, customSymbolColor.R, customSymbolColor.G, customSymbolColor.B)), ptArray[j], customSymbolSize);
                            }
                        }
                    }
                }
            }
        }
示例#3
0
        private void PaintOneRange(Graphics g, IPlotArea layer, IPlotRange range, Processed2DPlotData pdata)
        {
            // adjust the skip frequency if it was not set appropriate
            if (_skipFrequency <= 0)
            {
                _skipFrequency = 1;
            }

            var dropTargets = new List <CSPlaneID>(_dropTargets.Select(id => layer.UpdateCSPlaneID(id)));

            if (_additionalDropTargetIsEnabled)
            {
                CSPlaneID userPlane;
                if (_additionalDropTargetUsePhysicalBaseValue)
                {
                    userPlane = new CSPlaneID(_additionalDropTargetPerpendicularAxis, layer.Scales[_additionalDropTargetPerpendicularAxis].PhysicalVariantToNormal(_additionalDropTargetBaseValue));
                }
                else
                {
                    userPlane = new CSPlaneID(_additionalDropTargetPerpendicularAxis, _additionalDropTargetBaseValue);
                }
                dropTargets.Add(userPlane);
            }

            // paint the scatter style

            PointD3D pos   = PointD3D.Empty;
            var      gpath = new GraphicsPath();

            if (null == _cachedSymbolSizeForIndexFunction && null == _cachedColorForIndexFunction) // using a constant symbol size and constant color
            {
                // update pen widths
                var    pen = _pen.Clone();
                double w1  = _lineWidth1Offset + _lineWidth1Factor * _cachedSymbolSize;
                pen.Width = w1;

                var gapStart = 0.5 * (_gapAtStartOffset + _gapAtStartFactor * _cachedSymbolSize);
                var gapEnd   = 0.5 * (_gapAtEndOffset + _gapAtEndFactor * _cachedSymbolSize);

                int lower = range.LowerBound;
                int upper = range.UpperBound;

                for (int j = lower; j < upper; j += _skipFrequency)
                {
                    var originalRowIndex = range.GetOriginalRowIndexFromPlotPointIndex(j);

                    Logical3D r3d = layer.GetLogical3D(pdata, originalRowIndex);
                    r3d.RX += _cachedLogicalShiftX;
                    r3d.RY += _cachedLogicalShiftY;

                    foreach (CSPlaneID id in dropTargets)
                    {
                        gpath.Reset();
                        layer.CoordinateSystem.GetIsolineFromPointToPlane(gpath, r3d, id);
                        PointF[] shortenedPathPoints = null;
                        if (gapStart != 0 || gapEnd != 0)
                        {
                            gpath.Flatten();
                            var pathPoints = gpath.PathPoints;
                            shortenedPathPoints = GdiExtensionMethods.ShortenedBy(pathPoints, RADouble.NewAbs(gapStart), RADouble.NewAbs(gapEnd));
                            if (null != shortenedPathPoints)
                            {
                                g.DrawLines(pen, shortenedPathPoints);
                            }
                        }
                        else
                        {
                            g.DrawPath(pen, gpath);
                        }
                    }
                }
            }
            else // using a variable symbol size or variable symbol color
            {
                int lower = range.LowerBound;
                int upper = range.UpperBound;
                for (int j = lower; j < upper; j += _skipFrequency)
                {
                    var originalRowIndex = range.GetOriginalRowIndexFromPlotPointIndex(j);
                    var pen = _pen.Clone();
                    if (null == _cachedColorForIndexFunction)
                    {
                        _cachedSymbolSize = _cachedSymbolSizeForIndexFunction(originalRowIndex);
                        double w1 = _lineWidth1Offset + _lineWidth1Factor * _cachedSymbolSize;
                        pen.Width = w1;
                    }
                    else
                    {
                        _cachedSymbolSize = null == _cachedSymbolSizeForIndexFunction ? _cachedSymbolSize : _cachedSymbolSizeForIndexFunction(originalRowIndex);
                        double w1 = _lineWidth1Offset + _lineWidth1Factor * _cachedSymbolSize;

                        var customSymbolColor = _cachedColorForIndexFunction(originalRowIndex);
                        pen.Width = w1;
                        pen.Color = NamedColor.FromArgb(customSymbolColor.A, customSymbolColor.R, customSymbolColor.G, customSymbolColor.B);
                    }

                    var gapStart = 0.5 * (_gapAtStartOffset + _gapAtStartFactor * _cachedSymbolSize);
                    var gapEnd   = 0.5 * (_gapAtEndOffset + _gapAtEndFactor * _cachedSymbolSize);

                    Logical3D r3d = layer.GetLogical3D(pdata, originalRowIndex);
                    r3d.RX += _cachedLogicalShiftX;
                    r3d.RY += _cachedLogicalShiftY;

                    foreach (CSPlaneID id in _dropTargets)
                    {
                        gpath.Reset();
                        layer.CoordinateSystem.GetIsolineFromPointToPlane(gpath, r3d, id);
                        PointF[] shortenedPathPoints = null;
                        if (gapStart != 0 || gapEnd != 0)
                        {
                            gpath.Flatten();
                            var pathPoints = gpath.PathPoints;
                            shortenedPathPoints = GdiExtensionMethods.ShortenedBy(pathPoints, RADouble.NewAbs(gapStart), RADouble.NewAbs(gapEnd));
                            if (null != shortenedPathPoints)
                            {
                                g.DrawLines(pen, shortenedPathPoints);
                            }
                        }
                        else
                        {
                            g.DrawPath(pen, gpath);
                        }
                    }
                }
            }
        }
示例#4
0
        private void PaintOneRange(
            Graphics g,
            IPlotArea layer,
            PointF[] plotPositions,
            IPlotRange range,
            IScatterSymbol scatterSymbol,
            ref CachedPathData cachedPathData,
            ref CachedBrushData cachedBrushData)
        {
            var ptArray = plotPositions;

            float xpos = 0, ypos = 0;
            float xdiff, ydiff;

            int originalIndex;

            // save the graphics stat since we have to translate the origin
            System.Drawing.Drawing2D.GraphicsState gs = g.Save();

            if (null == _cachedSymbolSizeForIndexFunction && null == _cachedColorForIndexFunction) // using a constant symbol size
            {
                // calculate the path only once
                CalculatePaths(scatterSymbol, _symbolSize, ref cachedPathData);
                CalculateBrushes(scatterSymbol, _color, cachedPathData, ref cachedBrushData);

                for (int plotPointIndex = range.LowerBound; plotPointIndex < range.UpperBound; plotPointIndex += _skipFreq)
                {
                    xdiff = ptArray[plotPointIndex].X - xpos;
                    ydiff = ptArray[plotPointIndex].Y - ypos;
                    xpos  = ptArray[plotPointIndex].X;
                    ypos  = ptArray[plotPointIndex].Y;
                    g.TranslateTransform(xdiff, ydiff);

                    if (null != cachedPathData.InsetPath)
                    {
                        g.FillPath(cachedBrushData.InsetBrush, cachedPathData.InsetPath);
                    }

                    if (null != cachedPathData.FillPath)
                    {
                        g.FillPath(cachedBrushData.FillBrush, cachedPathData.FillPath);
                    }

                    if (null != cachedPathData.FramePath)
                    {
                        g.FillPath(cachedBrushData.FrameBrush, cachedPathData.FramePath);
                    }
                } // end for
            }
            else  // using a variable symbol size or variable symbol color
            {
                CalculatePaths(scatterSymbol, _symbolSize, ref cachedPathData);
                CalculateBrushes(scatterSymbol, _color, cachedPathData, ref cachedBrushData);

                for (int plotPointIndex = range.LowerBound; plotPointIndex < range.UpperBound; plotPointIndex += _skipFreq)
                {
                    originalIndex = range.GetOriginalRowIndexFromPlotPointIndex(plotPointIndex);

                    if (null == _cachedColorForIndexFunction)
                    {
                        double customSymbolSize = _cachedSymbolSizeForIndexFunction(originalIndex);
                        CalculatePaths(scatterSymbol, customSymbolSize, ref cachedPathData);
                    }
                    else
                    {
                        double customSymbolSize  = null == _cachedSymbolSizeForIndexFunction ? _symbolSize : _cachedSymbolSizeForIndexFunction(originalIndex);
                        var    customSymbolColor = _cachedColorForIndexFunction(originalIndex);
                        CalculatePaths(scatterSymbol, customSymbolSize, ref cachedPathData);
                        CalculateBrushes(scatterSymbol, NamedColor.FromArgb(customSymbolColor.A, customSymbolColor.R, customSymbolColor.G, customSymbolColor.B), cachedPathData, ref cachedBrushData);
                    }

                    xdiff = ptArray[plotPointIndex].X - xpos;
                    ydiff = ptArray[plotPointIndex].Y - ypos;
                    xpos  = ptArray[plotPointIndex].X;
                    ypos  = ptArray[plotPointIndex].Y;
                    g.TranslateTransform(xdiff, ydiff);

                    if (null != cachedPathData.InsetPath)
                    {
                        g.FillPath(cachedBrushData.InsetBrush, cachedPathData.InsetPath);
                    }

                    if (null != cachedPathData.FillPath)
                    {
                        g.FillPath(cachedBrushData.FillBrush, cachedPathData.FillPath);
                    }

                    if (null != cachedPathData.FramePath)
                    {
                        g.FillPath(cachedBrushData.FrameBrush, cachedPathData.FramePath);
                    }
                }
            }

            g.Restore(gs); // Restore the graphics state
        }
示例#5
0
        public void Paint(IGraphicsContext3D g, IPlotArea layer, Processed3DPlotData pdata, Processed3DPlotData prevItemData, Processed3DPlotData nextItemData)
        {
            PlotRangeList rangeList = pdata.RangeList;
            var           ptArray   = pdata.PlotPointsInAbsoluteLayerCoordinates;

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

            var dropTargets = new List <CSPlaneID>(_dropTargets.Select(id => layer.UpdateCSPlaneID(id)));

            if (_additionalDropTargetIsEnabled)
            {
                CSPlaneID userPlane;
                if (_additionalDropTargetUsePhysicalBaseValue)
                {
                    userPlane = new CSPlaneID(_additionalDropTargetPerpendicularAxis, layer.Scales[_additionalDropTargetPerpendicularAxis].PhysicalVariantToNormal(_additionalDropTargetBaseValue));
                }
                else
                {
                    userPlane = new CSPlaneID(_additionalDropTargetPerpendicularAxis, _additionalDropTargetBaseValue);
                }
                dropTargets.Add(userPlane);
            }

            // paint the scatter style

            PointD3D pos = PointD3D.Empty;

            if (null == _cachedSymbolSizeForIndexFunction && null == _cachedColorForIndexFunction) // using a constant symbol size and constant color
            {
                var pen = _pen;
                // update pen widths
                double w1 = _lineWidth1Offset + _lineWidth1Factor * _cachedSymbolSize;
                double w2 = _lineWidth2Offset + _lineWidth2Factor * _cachedSymbolSize;
                pen = pen.WithThickness1(w1).WithThickness2(w2);

                var gapStart = 0.5 * (_gapAtStartOffset + _gapAtStartFactor * _cachedSymbolSize);
                var gapEnd   = 0.5 * (_gapAtEndOffset + _gapAtEndFactor * _cachedSymbolSize);

                for (int r = 0; r < rangeList.Count; r++)
                {
                    var range = rangeList[r];
                    int lower = range.LowerBound;
                    int upper = range.UpperBound;

                    for (int j = lower; j < upper; j += _skipFreq)
                    {
                        Logical3D r3d = layer.GetLogical3D(pdata, j + range.OffsetToOriginal);
                        foreach (CSPlaneID id in dropTargets)
                        {
                            layer.CoordinateSystem.GetIsolineFromPointToPlane(r3d, id, out var isoLine);
                            if (gapStart != 0 || gapEnd != 0)
                            {
                                isoLine = isoLine.ShortenedBy(RADouble.NewAbs(gapStart), RADouble.NewAbs(gapEnd));
                            }

                            if (null != isoLine)
                            {
                                g.DrawLine(pen, isoLine);
                            }
                        }
                    }
                } // for each range
            }
            else  // using a variable symbol size or variable symbol color
            {
                for (int r = 0; r < rangeList.Count; r++)
                {
                    var range  = rangeList[r];
                    int lower  = range.LowerBound;
                    int upper  = range.UpperBound;
                    int offset = range.OffsetToOriginal;
                    for (int j = lower; j < upper; j += _skipFreq)
                    {
                        var pen = _pen;
                        if (null == _cachedColorForIndexFunction)
                        {
                            _cachedSymbolSize = _cachedSymbolSizeForIndexFunction(j + offset);
                            double w1 = _lineWidth1Offset + _lineWidth1Factor * _cachedSymbolSize;
                            double w2 = _lineWidth2Offset + _lineWidth2Factor * _cachedSymbolSize;
                            pen = _pen.WithThickness1(w1).WithThickness2(w2);
                        }
                        else
                        {
                            _cachedSymbolSize = null == _cachedSymbolSizeForIndexFunction ? _cachedSymbolSize : _cachedSymbolSizeForIndexFunction(j + offset);
                            double w1 = _lineWidth1Offset + _lineWidth1Factor * _cachedSymbolSize;
                            double w2 = _lineWidth2Offset + _lineWidth2Factor * _cachedSymbolSize;

                            var customSymbolColor = _cachedColorForIndexFunction(j + offset);
                            pen = _pen.WithThickness1(w1).WithThickness2(w2).WithColor(NamedColor.FromArgb(customSymbolColor.A, customSymbolColor.R, customSymbolColor.G, customSymbolColor.B));
                        }

                        var gapStart = 0.5 * (_gapAtStartOffset + _gapAtStartFactor * _cachedSymbolSize);
                        var gapEnd   = 0.5 * (_gapAtEndOffset + _gapAtEndFactor * _cachedSymbolSize);

                        Logical3D r3d = layer.GetLogical3D(pdata, j + rangeList[r].OffsetToOriginal);
                        foreach (CSPlaneID id in _dropTargets)
                        {
                            layer.CoordinateSystem.GetIsolineFromPointToPlane(r3d, id, out var isoLine);

                            if (gapStart != 0 || gapEnd != 0)
                            {
                                isoLine = isoLine.ShortenedBy(RADouble.NewAbs(gapStart), RADouble.NewAbs(gapEnd));
                            }
                            if (null != isoLine)
                            {
                                g.DrawLine(pen, isoLine);
                            }
                        }
                    }
                }
            }
        }