improved emulator simulation view
made it possible to turn the emulator speed to fast or slow in the terminal
This commit is contained in:
parent
ba934a3271
commit
0569948437
4 changed files with 34 additions and 4 deletions
|
|
@ -65,6 +65,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
private List<IDrawable> drawables = new List<IDrawable>();
|
||||
private List<IDrawableItem> itemDrawables = new List<IDrawableItem>();
|
||||
private Vector3 lastEmulatorPosition;
|
||||
private bool emulatorHooked;
|
||||
private long lastEmulatorDrawMs;
|
||||
|
||||
public bool AllowBedRenderingWhenEmpty { get; set; }
|
||||
|
||||
|
|
@ -467,6 +469,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
if (sceneContext.Printer.Connection.serialPort is PrinterEmulator.Emulator emulator)
|
||||
{
|
||||
void NozzlePositionChanged(object s, EventArgs e2)
|
||||
{
|
||||
// limit max number of updates per second to 10
|
||||
if (UiThread.CurrentTimerMs > lastEmulatorDrawMs + 100)
|
||||
{
|
||||
UiThread.RunOnIdle(Invalidate);
|
||||
// set it to now
|
||||
lastEmulatorDrawMs = UiThread.CurrentTimerMs;
|
||||
}
|
||||
}
|
||||
|
||||
var matrix = Matrix4X4.CreateTranslation(emulator.CurrentPosition + new Vector3(.5, .5, 5));
|
||||
GLHelper.Render(PlatonicSolids.CreateCube(1, 1, 10),
|
||||
MaterialRendering.Color(emulator.ExtruderIndex),
|
||||
|
|
@ -474,11 +487,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
RenderTypes.Shaded,
|
||||
matrix * World.ModelviewMatrix);
|
||||
|
||||
if (emulator.CurrentPosition != lastEmulatorPosition)
|
||||
if (!emulatorHooked)
|
||||
{
|
||||
Invalidate();
|
||||
emulator.DestinationChanged += NozzlePositionChanged;
|
||||
emulatorHooked = true;
|
||||
}
|
||||
|
||||
Closed += (s, e3) => emulator.DestinationChanged -= NozzlePositionChanged;
|
||||
|
||||
lastEmulatorPosition = emulator.CurrentPosition;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,18 @@ namespace MatterHackers.PrinterEmulator
|
|||
{
|
||||
Emulator.Instance = this;
|
||||
|
||||
string ChangeToSlow(string a)
|
||||
{
|
||||
this.RunSlow = true;
|
||||
return "ok\n";
|
||||
}
|
||||
|
||||
string ChangeToFast(string a)
|
||||
{
|
||||
this.RunSlow = false;
|
||||
return "ok\n";
|
||||
}
|
||||
|
||||
responses = new Dictionary<string, Func<string, string>>()
|
||||
{
|
||||
{ "A", Echo },
|
||||
|
|
@ -83,6 +95,8 @@ namespace MatterHackers.PrinterEmulator
|
|||
{ "M21", InitSdCard },
|
||||
{ "N", ParseChecksumLine },
|
||||
{ "T", SetExtruderIndex },
|
||||
{ "SLOW", ChangeToSlow },
|
||||
{ "FAST", ChangeToFast },
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 8449b769bba5f1592c3dab46997498d8123dfd61
|
||||
Subproject commit 08a6104c2ef9c1e6938e845777f2068eb62046e9
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit 762689f27eeeb61b1b31e7b60b5cdeceda12bf62
|
||||
Subproject commit 5aff427902346eeda87c1fe63f2057808bcc544d
|
||||
Loading…
Add table
Add a link
Reference in a new issue