Ejemplo n.º 1
0
        public Table3D Copy()
        {
            Table3D c = new Table3D();

            c.location = location;

            c.countX = countX;
            c.countY = countY;

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

            c.rangeX = rangeX;
            c.rangeY = rangeY;
            c.rangeZ = rangeZ;

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

            // copy array references only for best performance, no deep copy
            c.valuesX = valuesX;
            c.valuesY = valuesY;
            c.valuesZ = valuesZ;

            c.valuesZasFloats = valuesZasFloats;
            c.valuesZmin      = Zmin;
            c.valuesZmax      = Zmax;
            c.valuesZavg      = valuesZavg;

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

            return(c);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Draws NPlot.ImagePlot.
        /// Does Clear(), axis are hidden.
        /// Can be used for icons as well.
        /// </summary>
        /// <param name="plotSurface2D">
        /// A <see cref="IPlotSurface2D"/>
        /// </param>
        /// <param name="table">
        /// A <see cref="Table3D"/>
        /// </param>
        public static void Draw(IPlotSurface2D plotSurface2D, Table3D table)
        {
            float[] valuesZ = table.GetValuesZasFloats ();

            // NPlot ImagePlot, needs 2D-array of type double
            int cyi = table.CountY - 1;
            int cx = table.CountX;
            double[,] data = new double[table.CountY, cx];
            for (int i = 0; i < valuesZ.Length; i++) {
                // [row, col], include y-reordering, same effect as plotSurface.YAxis1.Reversed
                // not using using YAxis1.Reversed seems to avoid a display bug (white row sometimes included)
                data[cyi - i / cx, i % cx] = valuesZ[i];
            }

            var ip = new ImagePlot (data);
            ip.Gradient = gradient;

            plotSurface2D.Clear ();
            plotSurface2D.Add (ip);

            plotSurface2D.XAxis1.Hidden = true;
            plotSurface2D.YAxis1.Hidden = true;
        }
Ejemplo n.º 3
0
        //        static string AnnotationStr (Table2D table2D)
        //        {
        //            return string.Format ("Min: {0} Max: {1} Avg: {2}", table2D.Ymin.ToString (), table2D.Ymax.ToString (), table2D.Yavg.ToString ());
        //        }
        // TODO investigate piping binary data via standard input, avoiding temp file
        // However temp file might be useful for manual gnuplot experiments.
        static void WriteGnuPlotBinary(BinaryWriter bw, Table3D table3D)
        {
            /* from gnuplot help PDF page 157, "matrix binary":

                    Single precision floats are stored in a binary file as follows:
                    <N+1> <y0>   <y1>   <y2>  ... <yN>
                    <x0> <z0,0> <z0,1> <z0,2> ... <z0,N>
                    <x1> <z1,0> <z1,1> <z1,2> ... <z1,N>
                    */
            // x <-> y designation from above (manual) seems wrong as xlabel etc. matches code below!

            float[] valuesX = table3D.ValuesX;
            // write first float: <N+1>
            bw.Write ((float)(valuesX.Length));

            // x axis
            foreach (var x in valuesX) {
                bw.Write (x);
            }

            float[] valuesY = table3D.ValuesY;
            float[] valuesZ = table3D.GetValuesZasFloats ();
            for (int iy = 0; iy < valuesY.Length; iy++) {
                bw.Write (valuesY[iy]);
                for (int ix = 0; ix < valuesX.Length; ix++) {
                    bw.Write (valuesZ[ix + iy * valuesX.Length]);
                }
            }
        }
Ejemplo n.º 4
0
        static void ScriptGnuplot3D(TextWriter tw, Table3D table3D)
        {
            tw.WriteLine (SetLabel ("xlabel", table3D.NameX, true, table3D.UnitX));
            tw.WriteLine (SetLabel ("ylabel", table3D.NameY, true, table3D.UnitY));
            // use title instead of zlabel as it would need extra space
            tw.WriteLine (SetLabel ("title", table3D.Title, false, table3D.UnitZ));

            tw.WriteLine ("set label 1 \"" + AnnotationStr (table3D) + "\" at screen 0.01,0.95 front left textcolor rgb \"blue\"");
            //set label 1 "Annotation Label" at screen 0.01,0.95 front left textcolor rgb "blue"

            tw.WriteLine ("load \"" + TemplateFile3D + "\"");
        }
Ejemplo n.º 5
0
 static string AnnotationStr(Table3D table3D)
 {
     return string.Format ("Min: {0}\\nMax: {1}\\nAvg: {2}", table3D.Zmin.ToString (), table3D.Zmax.ToString (), table3D.Zavg.ToString ());
 }
Ejemplo n.º 6
0
        public Table3D Copy()
        {
            Table3D c = new Table3D ();
            c.location = location;

            c.countX = countX;
            c.countY = countY;

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

            c.rangeX = rangeX;
            c.rangeY = rangeY;
            c.rangeZ = rangeZ;

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

            // copy array references only for best performance, no deep copy
            c.valuesX = valuesX;
            c.valuesY = valuesY;
            c.valuesZ = valuesZ;

            c.valuesZasFloats = valuesZasFloats;
            c.valuesZmin = Zmin;
            c.valuesZmax = Zmax;
            c.valuesZavg = valuesZavg;

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

            return c;
        }
Ejemplo n.º 7
0
    void Show3D(Table3D table)
    {
        if (table == null)
            return;
        var valuesZ = table.GetValuesZasFloats ();
        var tableUI = new GtkWidgets.TableWidget (coloring, table.ValuesX, table.ValuesY, valuesZ, table.Zmin, table.Zmax);
        tableUI.TitleMarkup = GtkWidgets.TableWidget.MakeTitleMarkup (table.Title, table.UnitZ);
        tableUI.AxisMarkupX = GtkWidgets.TableWidget.MakeMarkup (table.NameX, table.UnitX);
        tableUI.AxisMarkupY = GtkWidgets.TableWidget.MakeMarkup (table.NameY, table.UnitY);

        // HACK FormatValues, no good digits algorithm yet
        int digits = ScoobyRom.Data.AutomaticMinDigits(valuesZ);
        if (digits <= 3)
        {
            tableUI.FormatValues = ScoobyRom.Data.ValueFormat(digits);
        }
        else{
            tableUI.FormatValues = table.Zmax < 30 ? "0.00" : "0.0";
            if (table.Zmax < 10)
                tableUI.FormatValues = "0.000";
        }

        // Viewport needed for ScrolledWindow to work as generated table widget has no scroll support
        var viewPort = new Gtk.Viewport ();
        viewPort.Add (tableUI.Create ());

        Gtk.Widget previous = this.scrolledwindowTable3D.Child;
        if (previous != null)
            this.scrolledwindowTable3D.Remove (previous);
        // previous.Dispose () or previous.Destroy () cause NullReferenceException!

        this.scrolledwindowTable3D.Add (viewPort);
        this.scrolledwindowTable3D.ShowAll ();
    }
Ejemplo n.º 8
0
        static Table3D ParseTable3D(XElement el)
        {
            Table3D table3D = new Table3D ();
            ParseCommon (el, table3D);

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

            subEl = el.Element (X_axisY);
            if (subEl != null) {
                ParseAxis (subEl, out address, out name, out unit);
                table3D.NameY = name;
                table3D.UnitY = unit;
                if (address.HasValue)
                    table3D.RangeY = new Util.Range (address.Value, 0);
            }

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

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

            return table3D;
        }
Ejemplo n.º 9
0
        void Merge(Table3D original, Table3D newTable)
        {
            MergeCommon (original, newTable);

            original.NameY = UpdateString (original.NameY, newTable.NameY);
            original.UnitZ = UpdateString (original.UnitZ, newTable.UnitZ);
        }
Ejemplo n.º 10
0
        public void SetNodeContent(TreeIter iter, Table3D table3D)
        {
            // TODO optimize when columns are final

            store.SetValue (iter, (int)ColumnNr3D.Obj, table3D);

            store.SetValue (iter, (int)ColumnNr3D.Category, table3D.Category);
            store.SetValue (iter, (int)ColumnNr3D.Toggle, false);
            store.SetValue (iter, (int)ColumnNr3D.Title, table3D.Title);
            store.SetValue (iter, (int)ColumnNr3D.UnitZ, table3D.UnitZ);

            store.SetValue (iter, (int)ColumnNr3D.NameX, table3D.NameX);
            store.SetValue (iter, (int)ColumnNr3D.NameY, table3D.NameY);
            store.SetValue (iter, (int)ColumnNr3D.UnitX, table3D.UnitX);
            store.SetValue (iter, (int)ColumnNr3D.UnitY, table3D.UnitY);

            store.SetValue (iter, (int)ColumnNr3D.CountX, table3D.CountX);
            store.SetValue (iter, (int)ColumnNr3D.CountY, table3D.CountY);
            store.SetValue (iter, (int)ColumnNr3D.CountZ, table3D.CountZ);

            store.SetValue (iter, (int)ColumnNr3D.Xmin, table3D.Xmin);
            store.SetValue (iter, (int)ColumnNr3D.Xmax, table3D.Xmax);
            store.SetValue (iter, (int)ColumnNr3D.Ymin, table3D.Ymin);
            store.SetValue (iter, (int)ColumnNr3D.Ymax, table3D.Ymax);

            store.SetValue (iter, (int)ColumnNr3D.ZPos, table3D.RangeZ.Pos);
            store.SetValue (iter, (int)ColumnNr3D.Location, table3D.Location);
            store.SetValue (iter, (int)ColumnNr3D.Description, table3D.Description);

            SetNodeContentTypeChanged (iter, table3D);
        }
Ejemplo n.º 11
0
 static XElement GetXElement(Table3D table3D)
 {
     return new XElement (X_table3D, new XAttribute (X_category, table3D.Category), new XAttribute (X_name, table3D.Title), new XAttribute (X_address, HexNum (table3D.Location)), ValueRangeComment (table3D.Xmin, table3D.Xmax), GetAxisXElement (X_axisX, table3D.RangeX.Pos, table3D.NameX, table3D.UnitX), ValueRangeComment (table3D.Ymin, table3D.Ymax), GetAxisXElement (X_axisY, table3D.RangeY.Pos, table3D.NameY, table3D.UnitY), ValueRangeComment (table3D.Zmin, table3D.Zmax), GetValuesElement (table3D.RangeZ.Pos, table3D.UnitZ, table3D.TableType),
     new XElement (X_description, table3D.Description));
 }
Ejemplo n.º 12
0
 public void ChangeTableType(Table3D table3D, TableType newType)
 {
     data.ChangeTableType(table3D, newType);
 }
Ejemplo n.º 13
0
 void CreateSetNewIcon(TreeIter iter, Table3D table3D)
 {
     store.SetValue (iter, (int)ColumnNr3D.Icon, plotIcon.CreateIcon3D (table3D));
 }
Ejemplo n.º 14
0
        public void SetNodeContentTypeChanged(TreeIter iter, Table3D table3D)
        {
            store.SetValue (iter, (int)ColumnNr3D.Type, (int)table3D.TableType);
            store.SetValue (iter, (int)ColumnNr3D.Zmin, table3D.Zmin);
            store.SetValue (iter, (int)ColumnNr3D.Zavg, table3D.Zavg);
            store.SetValue (iter, (int)ColumnNr3D.Zmax, table3D.Zmax);

            if (iconsCached)
                CreateSetNewIcon (iter, table3D);
        }
Ejemplo n.º 15
0
        public Gdk.Pixbuf CreateIcon3D(Table3D table)
        {
            if (table.Zmin == table.Zmax)
                return GetNoDataPixBuf;

            Plot3D.Draw (plotSurface, table);

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

            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);
        }
Ejemplo n.º 16
0
 public void ChangeTableType(Table3D table3D, TableType newType)
 {
     table3D.ChangeTypeToAndReload (newType, rom.Stream);
 }