Put in a gcode animator (sync to print)

Put in support for a bed image.
This commit is contained in:
larsbrubaker 2014-05-23 14:19:20 -07:00
parent 9d3a930aec
commit 1af9f45da6
5 changed files with 122 additions and 26 deletions

View file

@ -58,6 +58,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
CheckBox expandModelOptions;
CheckBox expandDisplayOptions;
CheckBox animatePrint;
GuiWidget gcodeDispalyWidget;
@ -117,6 +118,28 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
CloseOnIdle();
};
}
else
{
animatePrint = new CheckBox("Sync To Print".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor);
animatePrint.Checked = false;
animatePrint.VAnchor = VAnchor.ParentCenter;
animatePrint.CheckedStateChanged += (sender, e) =>
{
if (animatePrint.Checked)
{
SetAnimationPosition();
}
else
{
if (layerEndRenderRatioSlider != null)
{
layerEndRenderRatioSlider.Value = 1;
layerStartRenderRatioSlider.Value = 0;
}
}
};
layerSelectionButtonsPanel.AddChild(animatePrint);
}
FlowLayoutWidget centerPartPreviewAndControls = new FlowLayoutWidget(FlowDirection.LeftToRight);
centerPartPreviewAndControls.AnchorAll();
@ -193,6 +216,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
AddHandlers();
}
private void SetAnimationPosition()
{
int currentLayer = PrinterCommunication.Instance.CurrentlyPrintingLayer;
if (currentLayer >= 1)
{
selectLayerSlider.Value = currentLayer-1;
layerEndRenderRatioSlider.Value = PrinterCommunication.Instance.RatioIntoCurrentLayer;
layerStartRenderRatioSlider.Value = 0;
}
}
private FlowLayoutWidget CreateRightButtonPanel()
{
FlowLayoutWidget buttonRightPanel = new FlowLayoutWidget(FlowDirection.TopToBottom);
@ -257,7 +291,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
if (gcodeViewWidget != null && gcodeViewWidget.LoadedGCode != null)
{
int secondsRemaining = (int)gcodeViewWidget.LoadedGCode.GCodeCommandQueue[0].secondsToEndFromHere;
int secondsRemaining = (int)gcodeViewWidget.LoadedGCode.Instruction(0).secondsToEndFromHere;
int hoursRemaining = (int)(secondsRemaining / (60 * 60));
int minutesRemaining = (int)((secondsRemaining + 30) / 60 - hoursRemaining * 60); // +30 for rounding
secondsRemaining = secondsRemaining % 60;
@ -418,6 +452,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
bool hookedParentKeyDown = false;
public override void OnDraw(Graphics2D graphics2D)
{
if (animatePrint != null && animatePrint.Checked)
{
SetAnimationPosition();
}
if (!hookedParentKeyDown)
{
GuiWidget parent = Parent;
@ -493,7 +532,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
SetProcessingMessage("");
if (gcodeViewWidget != null
&& gcodeViewWidget.LoadedGCode != null
&& gcodeViewWidget.LoadedGCode.GCodeCommandQueue.Count > 0)
&& gcodeViewWidget.LoadedGCode.Count > 0)
{
CreateOptionsContent();