/// <summary> /// Caluclates the items <see cref="cache">cache</see> field to draw the function. /// </summary> public override void Calc(CalcThread t) { const float BIG = 1e20F; int X; float F; if (Recalc) { for (X = 0; X < t.w; X++) { if (t.stop) { break; } lock (this) { try { cache[X].X = X; F = (float)(t.h - 1 - (f(t.Graph.Model.x0 + X * t.dx) - t.Graph.Model.y0) / t.dy); if (float.IsInfinity(F) || float.IsNaN(F) || Math.Abs(F) > BIG) { F = 0; } cache[X].Y = F; } catch (ThreadAbortException ex) { throw ex; } catch { cache[X].Y = 0; } } t.OnStep(); } Recalc = t.stop; } }
/// <summary> /// Calculates the cache bitmap to draw the function. /// </summary> public override void Calc(CalcThread t) { int X, Y; if (Recalc) { Color c; double dzinv = 1 / t.dz; for (Y = 0; Y < t.h; Y++) { if (t.stop) { break; } for (X = 0; X < t.w; X++) { if (t.stop) { break; } try { c = f(t.Graph.Model.x0 + X * t.dx, t.Graph.Model.y0 + Y * t.dy); } catch (ThreadAbortException ex) { throw ex; } catch { c = Color.White; } lock (this) { cache.SetPixel(X, t.h - Y - 1, c); } } t.OnStep(); } Recalc = t.stop; } }
/// <summary> /// Calculates the cache bitmap to draw the function. /// </summary> public override void Calc(CalcThread t) { int X, Y; double fx, dzinv; Color c; if (Recalc) { dzinv = 1 / t.dz; for (Y = 0; Y < t.h; Y++) { if (t.stop) { break; } for (X = 0; X < t.w; X++) { if (t.stop) { break; } try { fx = (f(t.Graph.Model.x0 + X * t.dx, t.Graph.Model.y0 + Y * t.dy) - t.Graph.Model.z0) * dzinv; } catch (ThreadAbortException ex) { throw ex; } catch { fx = 0; } if (rgb) { c = RGBColor(fx); } else { c = FColor(fx); } lock (this) { cache.SetPixel(X, t.h - Y - 1, c); } } t.OnStep(); } Recalc = t.stop; } }
/// <summary> /// Calculates the image-cache for the data in the background. /// </summary> /// <param name="t">The calculating thread.</param> public override void Calc(CalcThread t) { t.pen.Color = color; PointF[] points = new PointF[Length]; Graphics g; lock (this) { g = Graphics.FromImage(cache); } float X, Y, DX, DY; for (int i = 0; i < Length; i++) { if (t.stop) break; try { X = (float)((x[i] - t.Graph.Model.x0)/t.dx); Y = t.h - 1 - (float)((y[i] - t.Graph.Model.y0)/t.dy); DX = (float)(dx[i]/t.dx)/2; DY = (float)(dy[i]/t.dy)/2; points[i].X = X; points[i].Y = Y; if (marks) { lock (this) { t.pen.DashStyle = DashStyle.Solid; t.pen.Width = lineWidth; if (DX < 3) DX = 5; else { g.DrawLine(t.pen, X-DX, Y-3, X-DX, Y+3); g.DrawLine(t.pen, X+DX, Y-3, X+DX, Y+3); } if (DY < 3) DY = 5; else { g.DrawLine(t.pen, X-3, Y-DY, X+3, Y-DY); g.DrawLine(t.pen, X-3, Y+DY, X+3, Y+DY); } g.DrawLine(t.pen, X-DX, Y, X+DX, Y); g.DrawLine(t.pen, X, Y-DY, X, Y+DY); } } } catch (System.Threading.ThreadAbortException ex) { throw ex; } catch {} t.OnStep(); } if (lines && !t.stop) { t.pen.DashStyle = lineStyle; t.pen.Width = lineWidth; try { lock (this) { g.DrawLines(t.pen, points); } } catch (System.Threading.ThreadAbortException ex) { throw ex; } catch {} } Recalc = t.stop; }
/// <summary> /// Calculates the cache bitmap to draw the function. /// </summary> public override void Calc(CalcThread t) { int X, Y; double fx, dzinv; Color c; if (Recalc) { dzinv = 1/t.dz; for (Y = 0; Y < t.h; Y++) { if (t.stop) break; for (X = 0; X < t.w; X++) { if (t.stop) break; try { fx = (f(t.Graph.Model.x0 + X*t.dx, t.Graph.Model.y0 + Y*t.dy) - t.Graph.Model.z0)*dzinv; } catch (ThreadAbortException ex) { throw ex; } catch { fx = 0; } if (rgb) c = RGBColor(fx); else c = FColor(fx); lock(this) { cache.SetPixel(X, t.h - Y - 1, c); } } t.OnStep(); } Recalc = t.stop; } }
/// <summary> /// Caluclates the items <see cref="cache">cache</see> field to draw the function. /// </summary> public override void Calc(CalcThread t) { const float BIG = 1e20F; int X; float F; if (Recalc) { for (X = 0; X < t.w; X++) { if (t.stop) break; lock(this) { try { cache[X].X = X; F = (float)(t.h - 1 - (f(t.Graph.Model.x0 + X*t.dx) - t.Graph.Model.y0)/t.dy); if (float.IsInfinity(F) || float.IsNaN(F) || Math.Abs(F) > BIG) F = 0; cache[X].Y = F; } catch (ThreadAbortException ex) { throw ex; } catch { cache[X].Y = 0; } } t.OnStep(); } Recalc = t.stop; } }
/// <summary> /// Calculates the cache bitmap to draw the function. /// </summary> public override void Calc(CalcThread t) { int X, Y; if (Recalc) { Color c; double dzinv = 1/t.dz; for (Y = 0; Y < t.h; Y++) { if (t.stop) break; for (X = 0; X < t.w; X++) { if (t.stop) break; try { c = f(t.Graph.Model.x0 + X*t.dx, t.Graph.Model.y0 + Y*t.dy); } catch (ThreadAbortException ex) { throw ex; } catch { c = Color.White; } lock(this) { cache.SetPixel(X, t.h - Y - 1, c); } } t.OnStep(); } Recalc = t.stop; } }
/// <summary> /// Calculates the image-cache for the data in the background. /// </summary> /// <param name="t">The calculating thread.</param> public override void Calc(CalcThread t) { t.pen.Color = color; PointF[] points = new PointF[Length]; Graphics g; lock (this) { g = Graphics.FromImage(cache); } float X, Y, DX, DY; for (int i = 0; i < Length; i++) { if (t.stop) { break; } try { X = (float)((x[i] - t.Graph.Model.x0) / t.dx); Y = t.h - 1 - (float)((y[i] - t.Graph.Model.y0) / t.dy); DX = (float)(dx[i] / t.dx) / 2; DY = (float)(dy[i] / t.dy) / 2; points[i].X = X; points[i].Y = Y; if (marks) { lock (this) { t.pen.DashStyle = DashStyle.Solid; t.pen.Width = lineWidth; if (DX < 3) { DX = 5; } else { g.DrawLine(t.pen, X - DX, Y - 3, X - DX, Y + 3); g.DrawLine(t.pen, X + DX, Y - 3, X + DX, Y + 3); } if (DY < 3) { DY = 5; } else { g.DrawLine(t.pen, X - 3, Y - DY, X + 3, Y - DY); g.DrawLine(t.pen, X - 3, Y + DY, X + 3, Y + DY); } g.DrawLine(t.pen, X - DX, Y, X + DX, Y); g.DrawLine(t.pen, X, Y - DY, X, Y + DY); } } } catch (System.Threading.ThreadAbortException ex) { throw ex; } catch {} t.OnStep(); } if (lines && !t.stop) { t.pen.DashStyle = lineStyle; t.pen.Width = lineWidth; try { lock (this) { g.DrawLines(t.pen, points); } } catch (System.Threading.ThreadAbortException ex) { throw ex; } catch {} } Recalc = t.stop; }