Exemplo n.º 1
0
        public void Paint(System.Drawing.Graphics g, IPlotArea layer, PlotItemCollection coll)
        {
            Dictionary <G2DPlotItem, Processed2DPlotData> plotDataDict;

            if (!CanUseStyle(layer, coll, out plotDataDict))
            {
                CoordinateTransformingStyleBase.Paint(g, layer, coll);
                return;
            }

            AltaxoVariant[] ysumArray = null;
            foreach (IGPlotItem pi in coll)
            {
                if (pi is G2DPlotItem)
                {
                    G2DPlotItem         gpi   = pi as G2DPlotItem;
                    Processed2DPlotData pdata = plotDataDict[gpi];
                    ysumArray = AbsoluteStackTransform.AddUp(ysumArray, pdata);
                }
            }



            // now plot the data - the summed up y is in yArray
            AltaxoVariant[]     yArray           = null;
            Processed2DPlotData previousItemData = null;

            foreach (IGPlotItem pi in coll)
            {
                if (pi is G2DPlotItem)
                {
                    G2DPlotItem         gpi   = pi as G2DPlotItem;
                    Processed2DPlotData pdata = plotDataDict[gpi];
                    yArray = AbsoluteStackTransform.AddUp(yArray, pdata);
                    AltaxoVariant[] localArray = new AltaxoVariant[yArray.Length];

                    int j = -1;
                    foreach (int originalIndex in pdata.RangeList.OriginalRowIndices())
                    {
                        j++;
                        AltaxoVariant y = 100 * yArray[j] / ysumArray[j];
                        localArray[j] = y;

                        Logical3D rel = new Logical3D(
                            layer.XAxis.PhysicalVariantToNormal(pdata.GetXPhysical(originalIndex)),
                            layer.YAxis.PhysicalVariantToNormal(y));

                        double xabs, yabs;
                        layer.CoordinateSystem.LogicalToLayerCoordinates(rel, out xabs, out yabs);
                        pdata.PlotPointsInAbsoluteLayerCoordinates[j] = new System.Drawing.PointF((float)xabs, (float)yabs);
                    }
                    // we have also to exchange the accessor for the physical y value and replace it by our own one
                    pdata.YPhysicalAccessor = new IndexedPhysicalValueAccessor(delegate(int i) { return(localArray[i]); });
                    pdata.PreviousItemData  = previousItemData;
                    previousItemData        = pdata;
                }
            }

            for (int i = coll.Count - 1; i >= 0; --i)
            {
                IGPlotItem pi = coll[i];
                if (pi is G2DPlotItem)
                {
                    G2DPlotItem         gpi   = pi as G2DPlotItem;
                    Processed2DPlotData pdata = plotDataDict[gpi];
                    gpi.Paint(g, layer, pdata);
                }
                else
                {
                    pi.Paint(g, layer);
                }
            }
        }
Exemplo n.º 2
0
        public void Paint(System.Drawing.Graphics g, IPlotArea layer, PlotItemCollection coll)
        {
            Dictionary <G2DPlotItem, Processed2DPlotData> plotDataDict;

            if (!CanUseStyle(layer, coll, out plotDataDict))
            {
                CoordinateTransformingStyleBase.Paint(g, layer, coll);
                return;
            }

            AltaxoVariant[] yArray = null;
            // First, add up all items since we start always with the last item
            int idx = -1;
            Processed2DPlotData previousItemData = null;

            foreach (IGPlotItem pi in coll)
            {
                if (pi is G2DPlotItem)
                {
                    idx++;

                    G2DPlotItem         gpi   = pi as G2DPlotItem;
                    Processed2DPlotData pdata = plotDataDict[gpi];
                    yArray = AddUp(yArray, pdata);

                    if (idx > 0) // this is not the first item
                    {
                        int j = -1;
                        foreach (int originalIndex in pdata.RangeList.OriginalRowIndices())
                        {
                            j++;
                            Logical3D rel = new Logical3D(
                                layer.XAxis.PhysicalVariantToNormal(pdata.GetXPhysical(originalIndex)),
                                layer.YAxis.PhysicalVariantToNormal(yArray[j]));

                            double xabs, yabs;
                            layer.CoordinateSystem.LogicalToLayerCoordinates(rel, out xabs, out yabs);
                            pdata.PlotPointsInAbsoluteLayerCoordinates[j] = new System.Drawing.PointF((float)xabs, (float)yabs);
                        }
                    }

                    // we have also to exchange the accessor for the physical y value and replace it by our own one
                    AltaxoVariant[] localArray = (AltaxoVariant[])yArray.Clone();
                    pdata.YPhysicalAccessor = new IndexedPhysicalValueAccessor(delegate(int i) { return(localArray[i]); });
                    pdata.PreviousItemData  = previousItemData;
                    previousItemData        = pdata;
                }
            }

            for (int i = coll.Count - 1; i >= 0; --i)
            {
                IGPlotItem pi = coll[i];
                if (pi is G2DPlotItem)
                {
                    G2DPlotItem         gpi   = pi as G2DPlotItem;
                    Processed2DPlotData pdata = plotDataDict[gpi];
                    gpi.Paint(g, layer, pdata);
                }
                else
                {
                    pi.Paint(g, layer);
                }
            }
        }