NPlot.PlotSurface2D.Add C# (CSharp) Method

Add() public method

Adds a drawable object to the plot surface. If the object is an IPlot, the PlotSurface2D axes will also be updated.
public Add ( IDrawable p, int zOrder ) : void
p IDrawable The IDrawable object to add to the plot surface.
zOrder int The z-ordering when drawing (objects with lower numbers are drawn first)
return void
        public void Add(IDrawable p, int zOrder)
        {
            m_drawables.Add(p);
            m_zPositions.Add((double)zOrder);
            // fraction is to make key unique. With 10 million plots at same z, this buggers up.. 
            double fraction = (double)(++uniqueCounter_) / 10000000.0f;
            m_ordering.Add((double)zOrder + fraction, m_drawables.Count - 1);

            // if p is just an IDrawable, then it can't affect the axes.
            if (p is IPlot)
            {
                UpdateAxes(false);
            }
        }

Same methods

PlotSurface2D::Add ( IDrawable p ) : void

Usage Example

Esempio n. 1
0
        public Gdk.Pixbuf CreateIcon2D(Table2D table)
        {
            if (table.Ymin == table.Ymax)
            {
                return(GetNoDataPixBuf);
            }

            plotSurface.Clear();
            // needs to be set each time after Clear()
            plotSurface.Padding       = padding;
            plotSurface.SmoothingMode = SmoothingMode;

            float[] valuesY = table.GetValuesYasFloats();

            // y-values, x-values (!)
            LinePlot lp = new LinePlot(valuesY, table.ValuesX);

            lp.Pen = pen;

            plotSurface.Add(lp);

            plotSurface.XAxis1.Hidden = true;
            plotSurface.YAxis1.Hidden = true;

            using (System.Drawing.Graphics g = Graphics.FromImage(bitmap_cache)) {
                plotSurface.Draw(g, bounds);
            }

            if (memoryStream == null)
            {
                memoryStream = new System.IO.MemoryStream(MemoryStreamCapacity);
            }
            memoryStream.Position = 0;
            bitmap_cache.Save(memoryStream, imageFormat);
            memoryStream.Position = 0;
            // TODO create Pixbuf directly from bitmap if possible, avoiding MemoryStream
            return(new Gdk.Pixbuf(memoryStream));
        }