Пример #1
0
 static void WriteGnuPlotBinary(BinaryWriter bw, Table2D table2D)
 {
     float[] valuesX = table2D.ValuesX;
     bw.Write((float)(valuesX.Length));
     foreach (var x in valuesX)
     {
         bw.Write(x);
     }
     // same format as 3D but only write a single row
     float[] valuesY = table2D.GetValuesYasFloats();
     bw.Write(0f);
     for (int ix = 0; ix < valuesX.Length; ix++)
     {
         bw.Write(valuesY [ix]);
     }
 }
Пример #2
0
        /// <summary>
        /// Might need Refresh () afterwards!
        /// </summary>
        /// <param name="table2D">
        /// A <see cref="Table2D"/>
        /// </param>
        public void Draw(Table2D table2D)
        {
            float[] valuesY = table2D.GetValuesYasFloats();

            // clear everything. reset fonts. remove plot components etc.
            this.plotSurface2D.Clear();
            plotSurface2D.Padding       = 0;
            plotSurface2D.SmoothingMode = SmoothingMode;

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

            lp.Pen = pen;

            PointPlot pp = new PointPlot(marker);

            pp.AbscissaData = table2D.ValuesX;
            pp.OrdinateData = valuesY;

            Grid myGrid = new Grid();

            myGrid.VerticalGridType   = Grid.GridType.Coarse;
            myGrid.HorizontalGridType = Grid.GridType.Coarse;

            plotSurface2D.Add(myGrid);
            plotSurface2D.Add(lp);
            plotSurface2D.Add(pp);

            plotSurface2D.TitleFont = titleFont;
            plotSurface2D.Title     = table2D.Title;

            plotSurface2D.XAxis1.LabelFont = labelFont;
            plotSurface2D.XAxis1.Label     = AxisText(table2D.NameX, table2D.UnitX);
            // could use ex: plotSurface2D.YAxis1.NumberFormat = "0.000";
            plotSurface2D.XAxis1.TickTextFont = tickTextFont;

            plotSurface2D.YAxis1.LabelFont    = labelFont;
            plotSurface2D.YAxis1.Label        = AxisText(table2D.Title, table2D.UnitY);
            plotSurface2D.YAxis1.TickTextFont = tickTextFont;

            // Refresh () not part of interface!
        }
Пример #3
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));
        }