void Show3D(Tables.Denso.Table3D table) { if (table == null) { return; } navbarwidget.CurrentPos = table.Location; navbarwidget.SetMarkedPositions(new int[] { table.RangeX.Pos, table.RangeY.Pos, table.RangeZ.Pos }); var valuesZ = table.GetValuesZasFloats(); var tableUI = new GtkWidgets.TableWidget3D(coloring, table.ValuesX, table.ValuesY, valuesZ, table.Xmin, table.Xmax, table.Ymin, table.Ymax, table.Zmin, table.Zmax); tableUI.TitleMarkup = Util.Markup.NameUnit_Large(table.Title, table.UnitZ); tableUI.AxisXMarkup = Util.Markup.NameUnit(table.NameX, table.UnitX); tableUI.AxisYMarkup = Util.Markup.NameUnit(table.NameY, table.UnitY); tableUI.FormatValues = ScoobyRom.Data.AutomaticValueFormat(valuesZ, table.Zmin, table.Zmax); // 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(); }
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.selected = selected; 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); }
/// <summary> /// Draws NPlot.ImagePlot (heatmap). /// 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; }
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.Multiplier, table3D.Multiplier); store.SetValue (iter, (int)ColumnNr3D.Offset, table3D.Offset); store.SetValue (iter, (int)ColumnNr3D.XPos, table3D.RangeX.Pos); store.SetValue (iter, (int)ColumnNr3D.YPos, table3D.RangeY.Pos); 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); Toggle (iter, table3D.Selected); SetNodeContentTypeChanged (iter, table3D); }
void Merge(Table3D original, Table3D newTable) { MergeCommon (original, newTable); original.NameY = UpdateString (original.NameY, newTable.NameY); original.UnitZ = UpdateString (original.UnitZ, newTable.UnitZ); }
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; }
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)), Table.CommentValuesStats (table3D.Xmin, table3D.Xmax), GetAxisXElement (X_axisX, table3D.RangeX.Pos, table3D.NameX, table3D.UnitX), Table.CommentValuesStats (table3D.Ymin, table3D.Ymax), GetAxisXElement (X_axisY, table3D.RangeY.Pos, table3D.NameY, table3D.UnitY), Table.CommentValuesStats (table3D.Zmin, table3D.Zmax, table3D.Zavg), GetValuesElement (table3D.RangeZ.Pos, table3D.UnitZ, table3D.TableType), new XElement (X_description, table3D.Description)); }
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.selected = selected; 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; }
// 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]); } } }
static void ScriptGnuplot3D(StreamWriter sw, Table3D table3D) { WriteLine (sw, SetLabel ("xlabel", table3D.NameX, true, table3D.UnitX)); WriteLine (sw, SetLabel ("ylabel", table3D.NameY, true, table3D.UnitY)); // use title instead of zlabel as it would need extra space WriteLine (sw, SetLabel ("title", table3D.Title, false, table3D.UnitZ)); WriteLine (sw, "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" // call gnuplot script, also pass argument to it (path to temporary binary data file) // Windows: do not use double quotes - does not recognize paths containing "\" then sw.WriteLine ("call '{0}' '{1}'", FindFileInCurrentOrAppFolder (TemplateFile3D), BinaryFile); }
static string AnnotationStr(Table3D table3D) { return string.Format ("Min: {0}\\nMax: {1}\\nAvg: {2}", table3D.Zmin.ToString (), table3D.Zmax.ToString (), table3D.Zavg.ToString ()); }