// create or close gnuplot window void OnPlotActionActivated(object sender, System.EventArgs e) { try { // gnuplot process itself can be slow to startup // so this does not prevent closing it immediatly when pressed twice //plotExternalAction.Sensitive = false; switch (CurrentUI) { case ActiveUI.View2D: Table2D table2D = dataView2DGtk.Selected; if (table2D != null) { GnuPlot.ToggleGnuPlot(table2D); } break; case ActiveUI.View3D: Table3D table3D = dataView3DGtk.Selected; if (table3D != null) { GnuPlot.ToggleGnuPlot(table3D); } break; } } catch (GnuPlotProcessException ex) { Console.Error.WriteLine(ex); ErrorMsg("Error launching gnuplot!", ex.Message + "\n\nHave you installed gnuplot?" + "\nYou also may need to edit file '" + appName + ".exe.config'." + "\nCurrent platform-ID is '" + System.Environment.OSVersion.Platform.ToString() + "'." + "\nSee 'README.txt' for details."); } catch (GnuPlotException ex) { Console.Error.WriteLine(ex); ErrorMsg("Error launching gnuplot!", ex.Message); } }
static Hitbox() { ReactionMatrix = new Table2D <Type, Action <Hitbox, Hitbox> >(); ReactionMatrix[Type.Offensive, Type.Damageable] = delegate(Hitbox src, Hitbox dst) { if (dst.Damageable != null) { dst.Damageable.Damage(src, src.BaseDamage); } if (dst.Knockbackable != null) { //TODO : FIX dst.Knockbackable.Knockback(src, Vector2.one); } DrawEffect(src, dst); }; ReactionMatrix[Type.Offensive, Type.Absorb] = delegate(Hitbox src, Hitbox dst) { ExecuteInterface <IAbsorbable>(Type.Absorb, src, dst, h => h.Absorbable, (a, o) => a.Absorb(o)); }; ReactionMatrix[Type.Offensive, Type.Reflective] = delegate(Hitbox src, Hitbox dst) { ExecuteInterface <IReflectable>(Type.Reflective, src, dst, h => h.Reflectable, (r, o) => r.Reflect(o)); }; ReactionMatrix[Type.Offensive, Type.Invincible] = DrawEffect; }
/// <summary> /// Constructor /// </summary> /// <param name="symbol">Symbol of variable</param> /// <param name="measure">Measure</param> /// <param name="detector">Detector of variables</param> internal VariableMeasurement(string symbol, IMeasurement measure, IVariableDetector detector) { this.symbol = symbol; this.measurement = measure; this.detector = detector; object par = measure.Type; if (par is IOneVariableFunction) { func = par as IOneVariableFunction; operationDetector = new OneVariableFunctionDetector(detector); funcwrapper = new OneVariableFunctionDetector(func); } else if (par is Table2D) { table2D = par as Table2D; } else if (par is Table3D) { table3D = par as Table3D; } /*!!! else if (par is FuncReturn) * { * funcReturn = par as FuncReturn; * //operationDetector = new FormulaEditor.Func.FuncDetector(detector, ) * }*/ else { acceptor = this; } tree = new ObjectFormulaTree(this, new List <ObjectFormulaTree>()); }
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); }
protected override void OnTableTypeChanged(TreeIter iter, TableType newTableType) { Table2D table2D = (Table2D)treeModel.GetValue(iter, (int)ColumnNr2D.Obj); viewModel.ChangeTableType(table2D, newTableType); viewModel.SetNodeContentTypeChanged(iter, table2D); }
public void SetNodeContent(TreeIter iter, Table2D table2D) { 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.Multiplier, table2D.Multiplier); store.SetValue(iter, (int)ColumnNr2D.Offset, table2D.Offset); store.SetValue(iter, (int)ColumnNr2D.Location, table2D.Location); store.SetValue(iter, (int)ColumnNr2D.XPos, table2D.RangeX.Pos); store.SetValue(iter, (int)ColumnNr2D.YPos, table2D.RangeY.Pos); store.SetValue(iter, (int)ColumnNr2D.Description, table2D.Description); Toggle(iter, table2D.Selected); SetNodeContentTypeChanged(iter, table2D); }
internal FormTable2D(IObjectLabel label, Action action, Table2D table) : this() { userControlTable2DTab.Action = action; this.label = label; this.table = table; UpdateFormUI(); }
private void CovertUnitSlopeOrWindCorrTable(Table2D item, bool lengthUnitIsMeter) { if (lengthUnitIsMeter == false) { item.x.Multiply(Constants.FtMeterRatio); item.f.Multiply(Constants.FtMeterRatio); } }
public void TableTooSmallNotValid() { Assert.Throws <ArgumentException>(() => { var table = new Table2D(x, y, new[] { f[0], f[1] }); table.Validate(); }); }
private static void SetUnitSlopeOrWindTable(Table2D table, bool lengthIsMeter) { // If length unit is feet, convert them to meter. if (lengthIsMeter == false) { table.f.Multiply(FtMeterRatio); table.x.Multiply(FtMeterRatio); } }
// double click or Enter key void HandleTreeViewRowActivated(object o, RowActivatedArgs args) { Table2D table2D = Selected; if (table2D != null && Activated != null) { Activated(this, new ActionEventArgs(table2D)); } }
void Show2D(Table2D table) { if (table == null) { return; } plot2D.Draw(table); plotSurface.Refresh(); }
public void FindMaps(int startPos, int lastPos, out IList <Table2D> list2D, out IList <Table3D> list3D) { this.startPos = startPos; // smallest 2D table record size is 12 bytes lastPos = Math.Min(lastPos, Size - 1 - 12); this.lastPos = lastPos; // Restricting pointers to a realistic range improves detection accuracy. // Using conservative settings here: // In Subaru ROMs at least first 8 KiB usually contain low level stuff, no maps. Table.PosMin = 8 * KiB; Table.PosMax = Size - 1; // default capacities suitable for current (MY2015 2MiB) diesel ROMs list2D = new List <Table2D> (1500); list3D = new List <Table3D> (1300); OnProgressChanged(0); this.percentDoneLastReport = 0; // records need to be 4-byte-aligned anyway // --> much faster than just ++pos, also skips a few false positives for (long pos = startPos; pos <= lastPos; pos = NextAlignedPos(pos, 4)) { stream.Position = pos; CheckProgress(pos); // try Table3D first as it contains more struct info; more info to validate = better detection Table3D info3D = Table3D.TryParseValid(this.stream); if (info3D != null) { list3D.Add(info3D); // this is often a valid next pos, already aligned pos = stream.Position; } else { // must back off stream.Position = pos; // not 3D, try 2D Table2D info2D = Table2D.TryParseValid(this.stream); if (info2D != null) { list2D.Add(info2D); // this is often a valid next pos, already aligned pos = stream.Position; } else { // nothing valid, try at next possible location pos++; } } } OnProgressChanged(100); }
/* * public IList<Table3D> FindMaps3D () * { * return FindMaps3D (0); * } * * public IList<Table3D> FindMaps3D (int startPos) * { * // should stop at EOF * return FindMaps3D (startPos, (int)fs.Length); * } * * public IList<Table3D> FindMaps3D (int startPos, int lastPos) * { * this.startPos = startPos; * lastPos = Math.Min (lastPos, (int)fs.Length); * this.lastPos = lastPos; * OnProgressChanged (0); * this.percentDoneLastReport = 0; * List<Table3D> list3D = new List<Table3D> (800); * * for (long pos = startPos; pos <= lastPos;) { * // check for end of file * if (pos >= fs.Length) * break; * fs.Position = pos; * CheckProgress (pos); * * Table3D info3D = Table3D.TryParseValid (this.fs); * if (info3D != null) { * list3D.Add (info3D); * pos = fs.Position; * } else { * // not valid, try at next possible location * pos++; * } * } * OnProgressChanged (100); * return list3D; * } */ public void FindMaps(int startPos, int lastPos, out IList <Table2D> list2D, out IList <Table3D> list3D) { this.startPos = startPos; lastPos = Math.Min(lastPos, (int)fs.Length); this.lastPos = lastPos; // Restricting pointers to a range can improve detection accuracy. // Using conservative settings here: Table.PosMin = 8 * 1024; Table.PosMax = (int)fs.Length - 1; // default capacities suitable for SH7059 diesel ROMs list2D = new List <Table2D> (800); list3D = new List <Table3D> (1000); OnProgressChanged(0); this.percentDoneLastReport = 0; for (long pos = startPos; pos <= lastPos;) { // check for end of file if (pos >= fs.Length) { break; } fs.Position = pos; CheckProgress(pos); // try Table3D first as it contains more struct info; more info to validate = better detection Table3D info3D = Table3D.TryParseValid(this.fs); if (info3D != null) { list3D.Add(info3D); pos = fs.Position; } else { // must back off fs.Position = pos; // not 3D, try 2D Table2D info2D = Table2D.TryParseValid(this.fs); if (info2D != null) { list2D.Add(info2D); pos = fs.Position; } else { // nothing valid, try at next possible location pos++; } } } OnProgressChanged(100); }
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)), Table.CommentValuesStats(table2D.Xmin, table2D.Xmax), GetAxisXElement(X_axisX, table2D.RangeX.Pos, table2D.NameX, table2D.UnitX), Table.CommentValuesStats(table2D.Ymin, table2D.Ymax, table2D.Yavg), GetValuesElement(table2D.RangeY.Pos, table2D.UnitY, table2D.TableType), new XElement(X_description, table2D.Description))); }
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); } }
static void ScriptGnuplot2D(StreamWriter sw, Table2D table2D) { WriteLine(sw, SetLabel("xlabel", table2D.NameX, false, table2D.UnitX)); WriteLine(sw, SetLabel("ylabel", table2D.Title, false, table2D.UnitY)); WriteLine(sw, SetLabel("title", table2D.Title, false, table2D.UnitY)); // Min/Max/Avg label might obscure title etc. //sw.WriteLine ("set label 1 \"" + AnnotationStr (table2D) + "\" at screen 0.01,0.96 front left textcolor rgb \"blue\""); // Windows: use single instead of double quotes because would interpret backslashes in path sw.WriteLine("call '{0}' '{1}'", FindFileInCurrentOrAppFolder(TemplateFile2D), BinaryFile); }
public MainWindow(string[] args) : base(Gtk.WindowType.Toplevel) { // Execute Gtk# visual designer generated code (MonoDevelop http://monodevelop.com/ ) // Obviously, Visual Studio doesn't have a Gtk# designer, you'll have to code all UI stuff by yourself. // Compiling existing generated UI code within Visual Studio does work however. Build(); this.Icon = MainClass.AppIcon; dataView3DModelGtk = new DataView3DModelGtk(this.data); dataView3DGtk = new DataView3DGtk(dataView3DModelGtk, treeview3D); dataView3DGtk.Activated += delegate(object sender, ActionEventArgs e) { Table3D table3D = (Table3D)e.Tag; if (table3D != null) { this.Show3D(table3D); } }; dataView2DModelGtk = new DataView2DModelGtk(this.data); dataView2DGtk = new DataView2DGtk(dataView2DModelGtk, treeview2D); dataView2DGtk.Activated += delegate(object sender, ActionEventArgs e) { Table2D table2D = (Table2D)e.Tag; if (table2D != null) { this.Show2D(table2D); } }; plot2D = new Plot2D(plotSurface); this.vpaned2D.Add2(plotSurface); global::Gtk.Paned.PanedChild pc = ((global::Gtk.Paned.PanedChild)(this.vpaned2D[plotSurface])); // to resize both panes proportionally when parent (main window) resizes pc.Resize = false; // pc.Shrink = false; this.vpaned2D.ShowAll(); this.notebook1.Page = 1; if (Config.IconsOnByDefault) { iconsAction.Active = true; dataView2DGtk.ShowIcons = true; dataView3DGtk.ShowIcons = true; } // program arguments: first argument is ROM path to auto-load if (args != null && args.Length > 0 && !string.IsNullOrEmpty(args[0])) { OpenRom(args[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 + "\""); }
protected override void UpdateModel(TreeIter iter) { // prevent loop when content might change in here (i.e. toggle) SetHandleRowChanged(false); Table2D table = store.GetValue(iter, (int)ColumnNr2D.Obj) as Table2D; if (table == null) { return; } string nameX = (string)store.GetValue(iter, (int)ColumnNr2D.NameX); string unitX = (string)store.GetValue(iter, (int)ColumnNr2D.UnitX); nameX = nameX.Trim(); unitX = unitX.Trim(); if (unitX != table.UnitX || nameX != table.NameX) { var shared = data.FindTablesSameAxisX(table); if (shared.Count > 0) { Console.WriteLine("AxisX shared {0} times.", shared.Count); #if SelectShared ToggleAll(false); foreach (var t in shared) { t.Selected = true; TreeIter iterDup; if (FindIter(t, out iterDup)) { Toggle(iterDup, true); } } #endif } } table.Category = (string)store.GetValue(iter, (int)ColumnNr2D.Category); table.Title = (string)store.GetValue(iter, (int)ColumnNr2D.Title); table.UnitY = (string)store.GetValue(iter, (int)ColumnNr2D.UnitY); table.NameX = nameX; table.UnitX = unitX; table.Description = (string)store.GetValue(iter, (int)ColumnNr2D.Description); table.Selected = IsToggled(iter); SetHandleRowChanged(true); }
private void AssertTable(string source) { var table = TableReader2D.Read(source); var expected = new Table2D( Arr(1500.0, 1600.0, 1800.0), Arr(-40.0, 10.0, 14.0), Arr( Arr(51.2, 47.0, 46.7), Arr(52.8, 48.5, 48.1), Arr(55.9, 51.3, 51.0) )); Assert.IsTrue(table.Equals(expected, delta)); }
private void AssertTable(string source) { var table = TableReader2D.Read(source); var expected = new Table2D( new[] { 1500.0, 1600.0, 1800.0 }, new[] { -40.0, 10.0, 14.0 }, new[] { new[] { 51.2, 47.0, 46.7 }, new[] { 52.8, 48.5, 48.1 }, new[] { 55.9, 51.3, 51.0 } }); Assert.IsTrue(table.Equals(expected, delta)); }
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]); } }
void UpdateModel(TreeIter iter) { Table2D table = store.GetValue(iter, (int)ColumnNr2D.Obj) as Table2D; if (table == null) { return; } table.Category = (string)store.GetValue(iter, (int)ColumnNr2D.Category); table.Title = (string)store.GetValue(iter, (int)ColumnNr2D.Title); table.UnitY = (string)store.GetValue(iter, (int)ColumnNr2D.UnitY); table.NameX = (string)store.GetValue(iter, (int)ColumnNr2D.NameX); table.UnitX = (string)store.GetValue(iter, (int)ColumnNr2D.UnitX); table.Description = (string)store.GetValue(iter, (int)ColumnNr2D.Description); }
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); }
/// <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! }
void CreateAllIcons() { TreeIter iter; if (!store.GetIterFirst(out iter)) { return; } do { Table2D table2D = (Table2D)store.GetValue(iter, (int)ColumnNr2D.Obj); Gdk.Pixbuf pixbuf = plotIcon.CreateIcon2D(table2D); // copy needed to work properly, closure does not recognize and copy updated ref var ? TreeIter iterCopy = iter; // update model reference in GUI Thread to make sure UI display is ok Application.Invoke(delegate { store.SetValue(iterCopy, (int)ColumnNr2D.Icon, pixbuf); }); } while (store.IterNext(ref iter)); plotIcon.CleanupTemp(); }
public int TryMergeWith(IList <Table2D> toUpdate) { Console.WriteLine("Merging " + this.xml2D.Count.ToString() + " 2D XML items"); int count = 0; foreach (Table2D table in xml2D) { Table2D found = null; int v; v = table.Location; if (v > 0) { found = toUpdate.Where(t => t.Location == v).FirstOrDefault(); } else { v = table.RangeY.Pos; found = toUpdate.Where(t => t.RangeY.Pos == v).FirstOrDefault(); if (found == null) { v = table.RangeX.Pos; found = toUpdate.Where(t => t.RangeX.Pos == v).FirstOrDefault(); } } // TODO add further match checking and conflict resolving if (found != null) { Merge(found, table); ++count; } else { Console.Error.WriteLine("Could not find this Table2D from XML: " + table.ToString()); } } return(count); }
static Hitbox() { ReactionMatrix = new Table2D <Type, Action <Hitbox, Hitbox> >(); _hitboxes = new List <Hitbox>(); ReactionMatrix[Type.Offensive, Type.Damageable] = delegate(Hitbox src, Hitbox dst) { if (dst.Damageable != null) { dst.Damageable.Damage(src, src.BaseDamage); } if (dst.Knockbackable != null) { var angle = Mathf.Deg2Rad * src.Angle; dst.Knockbackable.Knockback(src, new Vector2(Mathf.Cos(angle), Mathf.Sin(angle))); } DrawEffect(src, dst); }; ReactionMatrix[Type.Offensive, Type.Absorb] = ExecuteInterface <IAbsorbable>(h => h.Absorbable, (a, o) => a.Absorb(o)); ReactionMatrix[Type.Offensive, Type.Reflective] = ExecuteInterface <IReflectable>(h => h.Reflectable, (a, o) => a.Reflect(o)); ReactionMatrix[Type.Offensive, Type.Invincible] = DrawEffect; }
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)); }