Пример #1
0
        public void PaintPreprocessing(IPaintContext paintContext, IPlotArea layer, PlotItemCollection coll)
        {
            if (!CanUseStyle(layer, coll, out var plotDataDict))
            {
                return;
            }
            else
            {
                paintContext.AddValue(this, plotDataDict);
            }

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

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

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

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

                        var rel = new Logical3D(
                            layer.XAxis.PhysicalVariantToNormal(pdata.GetXPhysical(originalIndex)),
                            layer.YAxis.PhysicalVariantToNormal(pdata.GetYPhysical(originalIndex)),
                            layer.ZAxis.PhysicalVariantToNormal(v));

                        layer.CoordinateSystem.LogicalToLayerCoordinates(rel, out var pabs);
                        pdata.PlotPointsInAbsoluteLayerCoordinates[j] = pabs;
                    }
                    // we have also to exchange the accessor for the physical z value and replace it by our own one
                    pdata.ZPhysicalAccessor = new IndexedPhysicalValueAccessor(delegate(int i)
                                                                               { return(localArray[i]); });
                    pdata.PreviousItemData = previousItemData;
                    previousItemData       = pdata;
                }
            }
        }
Пример #2
0
        public void PaintPreprocessing(IPaintContext paintContext, IPlotArea layer, PlotItemCollection coll)
        {
            if (!CanUseStyle(layer, coll, out var plotDataDict))
            {
                return;
            }
            else
            {
                paintContext.AddValue(this, plotDataDict);
            }

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

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

                    var gpi = pi as G3DPlotItem;
                    Processed3DPlotData pdata = plotDataDict[gpi];
                    if (null == pdata)
                    {
                        continue;
                    }

                    vArray = AddUp(vArray, pdata);

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

                            layer.CoordinateSystem.LogicalToLayerCoordinates(rel, out var pabs);
                            pdata.PlotPointsInAbsoluteLayerCoordinates[j] = pabs;
                        }
                    }

                    // we have also to exchange the accessor for the physical y value and replace it by our own one
                    var localArray       = (AltaxoVariant[])vArray.Clone();
                    var localArrayHolder = new LocalArrayHolder(localArray, pdata);
                    pdata.ZPhysicalAccessor = localArrayHolder.GetPhysical;
                    pdata.PreviousItemData  = previousItemData;
                    previousItemData        = pdata;
                }
            }
        }
Пример #3
0
		public void PaintPreprocessing(IPaintContext paintContext, IPlotArea layer, PlotItemCollection coll)
		{
			Dictionary<G3DPlotItem, Processed3DPlotData> plotDataDict = null;
			if (!CanUseStyle(layer, coll, out plotDataDict))
			{
				return;
			}
			else
			{
				paintContext.AddValue(this, plotDataDict);
			}

			AltaxoVariant[] vArray = null;
			// First, add up all items since we start always with the last item
			int idx = -1;
			Processed3DPlotData previousItemData = null;
			foreach (IGPlotItem pi in coll)
			{
				if (pi is G3DPlotItem)
				{
					idx++;

					G3DPlotItem gpi = pi as G3DPlotItem;
					Processed3DPlotData pdata = plotDataDict[gpi];
					vArray = AddUp(vArray, 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(pdata.GetYPhysical(originalIndex)),
							layer.ZAxis.PhysicalVariantToNormal(vArray[j]));

							PointD3D pabs;
							layer.CoordinateSystem.LogicalToLayerCoordinates(rel, out pabs);
							pdata.PlotPointsInAbsoluteLayerCoordinates[j] = pabs;
						}
					}

					// we have also to exchange the accessor for the physical y value and replace it by our own one
					AltaxoVariant[] localArray = (AltaxoVariant[])vArray.Clone();
					LocalArrayHolder localArrayHolder = new LocalArrayHolder(localArray, pdata);
					pdata.ZPhysicalAccessor = localArrayHolder.GetPhysical;
					pdata.PreviousItemData = previousItemData;
					previousItemData = pdata;
				}
			}
		}
Пример #4
0
        public void PaintPreprocessing(System.Drawing.Graphics g, IPaintContext paintContext, IPlotArea layer, PlotItemCollection coll)
        {
            var paintData = new CachedPaintData
            {
                _clippingColl = new System.Drawing.Region[coll.Count],
                _plotDataColl = new Processed2DPlotData[coll.Count],
                _xincColl     = new double[coll.Count],
                _yincColl     = new double[coll.Count]
            };

            paintContext.AddValue(this, paintData);

            // First prepare
            int idx = -1;
            Processed2DPlotData previousPlotData = null;

            for (int i = 0; i < coll.Count; i++)
            {
                if (coll[i] is G2DPlotItem)
                {
                    idx++;
                    double currxinc = paintData._xincColl[i] = idx * _xinc * _scaleXInc;
                    double curryinc = paintData._yincColl[i] = idx * _yinc * _scaleYInc;

                    var gpi = coll[i] as G2DPlotItem;
                    Processed2DPlotData plotdata = paintData._plotDataColl[i] = gpi.GetRangesAndPoints(layer);
                    plotdata.PreviousItemData = previousPlotData;
                    previousPlotData          = plotdata;

                    int j = -1;
                    foreach (int rowIndex in plotdata.RangeList.OriginalRowIndices())
                    {
                        j++;

                        AltaxoVariant xx = plotdata.GetXPhysical(rowIndex) + currxinc;
                        AltaxoVariant yy = plotdata.GetYPhysical(rowIndex) + curryinc;

                        var rel = new Logical3D(layer.XAxis.PhysicalVariantToNormal(xx), layer.YAxis.PhysicalVariantToNormal(yy));
                        layer.CoordinateSystem.LogicalToLayerCoordinates(rel, out var xabs, out var yabs);
                        plotdata.PlotPointsInAbsoluteLayerCoordinates[j] = new System.Drawing.PointF((float)xabs, (float)yabs);
                    }

                    // if clipping is used, we must get a clipping region for every plot item
                    // and combine the regions from
                    if (_useClipping)
                    {
                        if (i == 0)
                        {
                            paintData._clippingColl[i] = g.Clip;
                        }

                        Plot.Styles.LinePlotStyle linestyle = null;
                        foreach (Plot.Styles.IG2DPlotStyle st in gpi.Style)
                        {
                            if (st is Plot.Styles.LinePlotStyle)
                            {
                                linestyle = st as Plot.Styles.LinePlotStyle;
                                break;
                            }
                        }

                        if (null != linestyle)
                        {
                            var path = new System.Drawing.Drawing2D.GraphicsPath();
                            linestyle.GetFillPath(path, layer, plotdata, CSPlaneID.Bottom);
                            if ((i + 1) < paintData._clippingColl.Length)
                            {
                                paintData._clippingColl[i + 1] = paintData._clippingColl[i].Clone();
                                paintData._clippingColl[i + 1].Exclude(path);
                            }
                        }
                        else
                        {
                            if ((i + 1) < paintData._clippingColl.Length)
                            {
                                paintData._clippingColl[i + 1] = paintData._clippingColl[i];
                            }
                        }
                    }
                }
            }
        }
Пример #5
0
		public void PaintPreprocessing(System.Drawing.Graphics g, IPaintContext paintContext, IPlotArea layer, PlotItemCollection coll)
		{
			var paintData = new CachedPaintData
			{
				_clippingColl = new System.Drawing.Region[coll.Count],
				_plotDataColl = new Processed2DPlotData[coll.Count],
				_xincColl = new double[coll.Count],
				_yincColl = new double[coll.Count]
			};

			paintContext.AddValue(this, paintData);

			// First prepare
			int idx = -1;
			Processed2DPlotData previousPlotData = null;
			for (int i = 0; i < coll.Count; i++)
			{
				if (coll[i] is G2DPlotItem)
				{
					idx++;
					double currxinc = paintData._xincColl[i] = idx * _xinc * _scaleXInc;
					double curryinc = paintData._yincColl[i] = idx * _yinc * _scaleYInc;

					G2DPlotItem gpi = coll[i] as G2DPlotItem;
					Processed2DPlotData plotdata = paintData._plotDataColl[i] = gpi.GetRangesAndPoints(layer);
					plotdata.PreviousItemData = previousPlotData;
					previousPlotData = plotdata;

					int j = -1;
					foreach (int rowIndex in plotdata.RangeList.OriginalRowIndices())
					{
						j++;

						AltaxoVariant xx = plotdata.GetXPhysical(rowIndex) + currxinc;
						AltaxoVariant yy = plotdata.GetYPhysical(rowIndex) + curryinc;

						Logical3D rel = new Logical3D(layer.XAxis.PhysicalVariantToNormal(xx), layer.YAxis.PhysicalVariantToNormal(yy));
						double xabs, yabs;
						layer.CoordinateSystem.LogicalToLayerCoordinates(rel, out xabs, out yabs);
						plotdata.PlotPointsInAbsoluteLayerCoordinates[j] = new System.Drawing.PointF((float)xabs, (float)yabs);
					}

					// if clipping is used, we must get a clipping region for every plot item
					// and combine the regions from
					if (_useClipping)
					{
						if (i == 0)
							paintData._clippingColl[i] = g.Clip;

						Plot.Styles.LinePlotStyle linestyle = null;
						foreach (Plot.Styles.IG2DPlotStyle st in gpi.Style)
						{
							if (st is Plot.Styles.LinePlotStyle)
							{
								linestyle = st as Plot.Styles.LinePlotStyle;
								break;
							}
						}

						if (null != linestyle)
						{
							GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
							linestyle.GetFillPath(path, layer, plotdata, CSPlaneID.Bottom);
							if ((i + 1) < paintData._clippingColl.Length)
							{
								paintData._clippingColl[i + 1] = (Region)paintData._clippingColl[i].Clone();
								paintData._clippingColl[i + 1].Exclude(path);
							}
						}
						else
						{
							if ((i + 1) < paintData._clippingColl.Length)
								paintData._clippingColl[i + 1] = paintData._clippingColl[i];
						}
					}
				}
			}
		}
Пример #6
0
		public void PaintPreprocessing(IPaintContext paintContext, IPlotArea layer, PlotItemCollection coll)
		{
			Dictionary<G3DPlotItem, Processed3DPlotData> plotDataDict = null;
			if (!CanUseStyle(layer, coll, out plotDataDict))
			{
				return;
			}
			else
			{
				paintContext.AddValue(this, plotDataDict);
			}

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

			// now plot the data - the summed up y is in yArray
			AltaxoVariant[] vArray = null;
			Processed3DPlotData previousItemData = null;
			foreach (IGPlotItem pi in coll)
			{
				if (pi is G3DPlotItem)
				{
					var gpi = pi as G3DPlotItem;
					var pdata = plotDataDict[gpi];
					vArray = AbsoluteStackTransform.AddUp(vArray, pdata);
					AltaxoVariant[] localArray = new AltaxoVariant[vArray.Length];

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

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

						PointD3D pabs;
						layer.CoordinateSystem.LogicalToLayerCoordinates(rel, out pabs);
						pdata.PlotPointsInAbsoluteLayerCoordinates[j] = pabs;
					}
					// we have also to exchange the accessor for the physical z value and replace it by our own one
					pdata.ZPhysicalAccessor = new IndexedPhysicalValueAccessor(delegate (int i) { return localArray[i]; });
					pdata.PreviousItemData = previousItemData;
					previousItemData = pdata;
				}
			}
		}