Exemple #1
0
        public Table2D Copy()
        {
            Table2D c = new Table2D();

            c.countX        = countX;
            c.tableType     = tableType;
            c.typeUncertain = typeUncertain;

            c.multiplier = multiplier;
            c.offset     = offset;

            c.location = location;
            c.rangeX   = rangeX;
            c.rangeY   = rangeY;
            c.hasMAC   = hasMAC;

            c.valuesX         = valuesX;
            c.valuesY         = valuesY;
            c.valuesYasFloats = valuesYasFloats;
            c.valuesYmin      = valuesYmin;
            c.valuesYmax      = valuesYmax;
            c.valuesYavg      = valuesYavg;

            // metadata
            c.title       = title ?? string.Empty;
            c.category    = category ?? string.Empty;
            c.description = description ?? string.Empty;
            c.nameX       = nameX ?? string.Empty;
            c.unitX       = unitX ?? string.Empty;
            c.unitY       = unitY ?? string.Empty;

            return(c);
        }
Exemple #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!
        }
Exemple #3
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]);
     }
 }
Exemple #4
0
        static void ScriptGnuplot2D(TextWriter tw, Table2D table2D)
        {
            // easy test:
            // tw.WriteLine ("plot sin(x), cos(x)"); return;

            tw.WriteLine (SetLabel ("xlabel", table2D.NameX, false, table2D.UnitX));
            tw.WriteLine (SetLabel ("ylabel", table2D.Title, false, table2D.UnitY));
            tw.WriteLine (SetLabel ("title", table2D.Title, false, table2D.UnitY));

            // Min/Max/Avg label might obscure title etc.
            //tw.WriteLine ("set label 1 \"" + AnnotationStr (table2D) + "\" at screen 0.01,0.96 front left textcolor rgb \"blue\"");

            tw.WriteLine ("load \"" + TemplateFile2D + "\"");
        }
        public void SetNodeContent(TreeIter iter, Table2D table2D)
        {
            // TODO optimize when columns are final

            store.SetValue (iter, (int)ColumnNr2D.Obj, table2D);

            store.SetValue (iter, (int)ColumnNr2D.Category, table2D.Category);
            store.SetValue (iter, (int)ColumnNr2D.Toggle, false);
            store.SetValue (iter, (int)ColumnNr2D.Title, table2D.Title);
            store.SetValue (iter, (int)ColumnNr2D.UnitY, table2D.UnitY);

            store.SetValue (iter, (int)ColumnNr2D.NameX, table2D.NameX);
            store.SetValue (iter, (int)ColumnNr2D.UnitX, table2D.UnitX);

            store.SetValue (iter, (int)ColumnNr2D.CountX, table2D.CountX);

            store.SetValue (iter, (int)ColumnNr2D.Xmin, table2D.Xmin);
            store.SetValue (iter, (int)ColumnNr2D.Xmax, table2D.Xmax);

            store.SetValue (iter, (int)ColumnNr2D.Location, table2D.Location);
            store.SetValue (iter, (int)ColumnNr2D.YPos, table2D.RangeY.Pos);
            store.SetValue (iter, (int)ColumnNr2D.Description, table2D.Description);

            SetNodeContentTypeChanged (iter, table2D);
        }
 public void ChangeTableType(Table2D table2D, TableType newType)
 {
     data.ChangeTableType(table2D, newType);
 }
 void CreateSetNewIcon(TreeIter iter, Table2D table2D)
 {
     store.SetValue (iter, (int)ColumnNr2D.Icon, plotIcon.CreateIcon2D (table2D));
 }
        public void SetNodeContentTypeChanged(TreeIter iter, Table2D table2D)
        {
            store.SetValue (iter, (int)ColumnNr2D.Type, (int)table2D.TableType);
            store.SetValue (iter, (int)ColumnNr2D.Ymin, table2D.Ymin);
            store.SetValue (iter, (int)ColumnNr2D.Yavg, table2D.Yavg);
            store.SetValue (iter, (int)ColumnNr2D.Ymax, table2D.Ymax);

            if (iconsCached)
                CreateSetNewIcon (iter, table2D);
        }
Exemple #9
0
 void Show2D(Table2D table)
 {
     if (table == null)
         return;
     plot2D.Draw (table);
     plotSurface.Refresh ();
 }
Exemple #10
0
 void Merge(Table2D original, Table2D newTable)
 {
     MergeCommon (original, newTable);
 }
Exemple #11
0
        static Table2D ParseTable2D(XElement el)
        {
            Table2D table2D = new Table2D ();
            ParseCommon (el, table2D);

            int? address;
            string name, unit;
            XElement subEl;
            subEl = el.Element (X_axisX);
            if (subEl != null) {
                ParseAxis (subEl, out address, out name, out unit);
                table2D.NameX = name;
                table2D.UnitX = unit;
                if (address.HasValue)
                    table2D.RangeX = new Util.Range (address.Value, 0);
            }

            subEl = el.Element (X_values);
            if (subEl != null) {
                TableType? tableType;
                ParseValues (subEl, out address, out unit, out tableType);
                table2D.UnitY = unit;
                if (address.HasValue)
                    table2D.RangeY = new Util.Range (address.Value, 0);
                if (tableType.HasValue)
                    table2D.TableType = tableType.Value;
            }

            table2D.Description = (string)el.Element (X_description);

            return table2D;
        }
Exemple #12
0
 static XElement GetXElement(Table2D table2D)
 {
     return new XElement (X_table2D, new XAttribute (X_category, table2D.Category), new XAttribute (X_name, table2D.Title), new XAttribute (X_address, HexNum (table2D.Location)), ValueRangeComment (table2D.Xmin, table2D.Xmax), GetAxisXElement (X_axisX, table2D.RangeX.Pos, table2D.NameX, table2D.UnitX), ValueRangeComment (table2D.Ymin, table2D.Ymax), GetValuesElement (table2D.RangeY.Pos, table2D.UnitY, table2D.TableType), new XElement (X_description, table2D.Description));
 }
Exemple #13
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);
        }
Exemple #14
0
        public Table2D Copy()
        {
            Table2D c = new Table2D ();
            c.countX = countX;
            c.tableType = tableType;
            c.typeUncertain = typeUncertain;

            c.multiplier = multiplier;
            c.offset = offset;

            c.location = location;
            c.rangeX = rangeX;
            c.rangeY = rangeY;
            c.hasMAC = hasMAC;

            c.valuesX = valuesX;
            c.valuesY = valuesY;
            c.valuesYasFloats = valuesYasFloats;
            c.valuesYmin = valuesYmin;
            c.valuesYmax = valuesYmax;
            c.valuesYavg = valuesYavg;

            // metadata
            c.title = title ?? string.Empty;
            c.category = category ?? string.Empty;
            c.description = description ?? string.Empty;
            c.nameX = nameX ?? string.Empty;
            c.unitX = unitX ?? string.Empty;
            c.unitY = unitY ?? string.Empty;

            return c;
        }
Exemple #15
0
 public void ChangeTableType(Table2D table2D, TableType newType)
 {
     table2D.ChangeTypeToAndReload (newType, rom.Stream);
 }