Skip to content

Commit

Permalink
Refresh on LoadingPercentage change
Browse files Browse the repository at this point in the history
  • Loading branch information
arkypita committed Jul 3, 2024
1 parent a603520 commit 58585e1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 22 deletions.
59 changes: 38 additions & 21 deletions LaserGRBL/Obj3D/Objects3D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,27 +258,44 @@ protected override void CallDisplayList(OpenGL gl)

}

public class Grbl3D : Object3D
{
public readonly GrblCore Core;
private readonly bool mJustLaserOffMovements;
private Object3DDisplayList mBoundingBoxDisplayList;
public Color Color;
public Color BoundingBoxColor;
public double LoadingPercentage { get; private set; } = 0;
public bool ShowBoundingBox { get; set; } = true;
private const int BOUNDING_RECT_LINE_WIDTH = 1;
private const int BOUNDING_RECT_STIPPLE = 10;

public Grbl3D(GrblCore core, string name, bool justLaserOffMovements, Color color, Color boundingBoxColor) : base(name, core.PreviewLineSize.Value)
{
Core = core;
mJustLaserOffMovements = justLaserOffMovements;
Color = color;
BoundingBoxColor = boundingBoxColor;
}

protected override void Draw()
public class Grbl3D : Object3D
{
public readonly GrblCore Core;
private readonly bool mJustLaserOffMovements;
private Object3DDisplayList mBoundingBoxDisplayList;
public Color Color;
public Color BoundingBoxColor;
private double mLoadingPercentage = 0;
public bool ShowBoundingBox { get; set; } = true;
private const int BOUNDING_RECT_LINE_WIDTH = 1;
private const int BOUNDING_RECT_STIPPLE = 10;

public delegate void OnLoadingPercentageChangeDlg();
public static event OnLoadingPercentageChangeDlg OnLoadingPercentageChange;

public Grbl3D(GrblCore core, string name, bool justLaserOffMovements, Color color, Color boundingBoxColor) : base(name, core.PreviewLineSize.Value)
{
Core = core;
mJustLaserOffMovements = justLaserOffMovements;
Color = color;
BoundingBoxColor = boundingBoxColor;
}


public double LoadingPercentage
{
get { return mLoadingPercentage; }
private set
{
if (value != mLoadingPercentage)
{
mLoadingPercentage = value;
OnLoadingPercentageChange?.Invoke();
}
}
}

protected override void Draw()
{
NewDisplayList(true, BOUNDING_RECT_LINE_WIDTH, BOUNDING_RECT_STIPPLE);
float zPos = 0;
Expand Down
8 changes: 7 additions & 1 deletion LaserGRBL/UserControls/GrblPanel3D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public GrblPanel3D()
MouseMove += GrblSceneControl_MouseMove;
MouseUp += GrblSceneControl_MouseUp;
MouseLeave += GrblSceneControl_MouseLeave;
Grbl3D.OnLoadingPercentageChange += Grbl3D_OnLoadingPercentageChange;
Resize += GrblPanel3D_Resize;
Disposed += GrblPanel3D_Disposed;
mCamera.Position = new Vertex(0, 0, 0);
Expand Down Expand Up @@ -169,7 +170,7 @@ public GrblPanel3D()
*/
}

private static double GetRulerStep(double n)
private static double GetRulerStep(double n)
{
int digitCount = Convert.ToInt32(Math.Max(3, Math.Floor(Math.Log10(n) + 1)));
int power = Convert.ToInt32(Math.Pow(10, digitCount - 1));
Expand Down Expand Up @@ -1118,6 +1119,11 @@ public void TimerUpdate()
Invalidate();
}

private void Grbl3D_OnLoadingPercentageChange()
{
Invalidate();
}

public void OnColorChange()
{
mBackgroundColor = ColorScheme.PreviewBackColor;
Expand Down

0 comments on commit 58585e1

Please sign in to comment.