2014-01-29 19:09:30 -08:00
|
|
|
|
/*
|
2014-02-15 18:06:03 -08:00
|
|
|
|
Copyright (c) 2014, Lars Brubaker
|
2014-01-29 19:09:30 -08:00
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
|
|
|
|
1. Redistributions of source code must retain the above copyright notice, this
|
|
|
|
|
|
list of conditions and the following disclaimer.
|
|
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
|
this list of conditions and the following disclaimer in the documentation
|
|
|
|
|
|
and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
|
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
|
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
|
|
|
|
The views and conclusions contained in the software and documentation are those
|
|
|
|
|
|
of the authors and should not be interpreted as representing official policies,
|
|
|
|
|
|
either expressed or implied, of the FreeBSD Project.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.ComponentModel;
|
2014-04-15 18:13:27 -07:00
|
|
|
|
using System.IO;
|
2014-01-29 19:09:30 -08:00
|
|
|
|
using MatterHackers.Agg;
|
|
|
|
|
|
using MatterHackers.Agg.UI;
|
|
|
|
|
|
using MatterHackers.GCodeVisualizer;
|
2014-02-04 13:30:42 -08:00
|
|
|
|
using MatterHackers.Localizations;
|
2014-04-15 18:13:27 -07:00
|
|
|
|
using MatterHackers.MatterControl.PrintQueue;
|
|
|
|
|
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
|
|
|
|
|
using MatterHackers.VectorMath;
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
|
|
|
|
|
namespace MatterHackers.MatterControl.PartPreviewWindow
|
|
|
|
|
|
{
|
2014-04-04 18:52:51 -07:00
|
|
|
|
public class GcodeViewBasic : PartPreviewWidget
|
2014-01-29 19:09:30 -08:00
|
|
|
|
{
|
|
|
|
|
|
public Slider selectLayerSlider;
|
2014-03-11 10:41:39 -07:00
|
|
|
|
public Slider layerStartRenderRatioSlider;
|
2014-03-15 09:47:51 -07:00
|
|
|
|
public Slider layerEndRenderRatioSlider;
|
2014-01-29 19:09:30 -08:00
|
|
|
|
TextWidget gcodeProcessingStateInfoText;
|
|
|
|
|
|
GCodeViewWidget gcodeViewWidget;
|
|
|
|
|
|
PrintItemWrapper printItem;
|
|
|
|
|
|
bool startedSliceFromGenerateButton = false;
|
|
|
|
|
|
Button generateGCodeButton;
|
|
|
|
|
|
FlowLayoutWidget buttonBottomPanel;
|
2014-04-27 17:19:06 -07:00
|
|
|
|
FlowLayoutWidget layerSelectionButtonsPanel;
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
|
|
|
|
|
FlowLayoutWidget modelOptionsContainer;
|
|
|
|
|
|
FlowLayoutWidget displayOptionsContainer;
|
|
|
|
|
|
|
|
|
|
|
|
CheckBox expandModelOptions;
|
|
|
|
|
|
CheckBox expandDisplayOptions;
|
2014-05-23 14:19:20 -07:00
|
|
|
|
CheckBox animatePrint;
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
|
|
|
|
|
GuiWidget gcodeDispalyWidget;
|
|
|
|
|
|
|
|
|
|
|
|
GetSizeFunction bedSizeFunction;
|
|
|
|
|
|
GetSizeFunction bedCenterFunction;
|
2014-04-21 15:00:32 -07:00
|
|
|
|
EventHandler unregisterEvents;
|
2014-04-09 21:47:00 -07:00
|
|
|
|
bool widgetHasCloseButton;
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
|
|
|
|
|
public delegate Vector2 GetSizeFunction();
|
|
|
|
|
|
|
2014-04-09 21:47:00 -07:00
|
|
|
|
public GcodeViewBasic(PrintItemWrapper printItem, GetSizeFunction bedSizeFunction, GetSizeFunction bedCenterFunction, bool addCloseButton)
|
2014-01-29 19:09:30 -08:00
|
|
|
|
{
|
2014-04-09 21:47:00 -07:00
|
|
|
|
widgetHasCloseButton = addCloseButton;
|
2014-01-29 19:09:30 -08:00
|
|
|
|
this.printItem = printItem;
|
|
|
|
|
|
|
|
|
|
|
|
this.bedSizeFunction = bedSizeFunction;
|
|
|
|
|
|
this.bedCenterFunction = bedCenterFunction;
|
|
|
|
|
|
|
|
|
|
|
|
CreateAndAddChildren(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-04-17 18:03:30 -07:00
|
|
|
|
static string slicingErrorMessage = "Slicing Error.\nPlease review your slice settings.".Localize();
|
|
|
|
|
|
static string pressGenerateMessage = "Press 'generate' to view layers".Localize();
|
|
|
|
|
|
static string fileNotFoundMessage = "File not found on disk.".Localize();
|
2014-01-29 19:09:30 -08:00
|
|
|
|
void CreateAndAddChildren(object state)
|
|
|
|
|
|
{
|
|
|
|
|
|
RemoveAllChildren();
|
2014-04-17 18:03:30 -07:00
|
|
|
|
gcodeViewWidget = null;
|
|
|
|
|
|
gcodeProcessingStateInfoText = null;
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
|
|
|
|
|
FlowLayoutWidget mainContainerTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
|
|
|
|
|
mainContainerTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
|
|
|
|
|
|
mainContainerTopToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;
|
|
|
|
|
|
|
|
|
|
|
|
buttonBottomPanel = new FlowLayoutWidget(FlowDirection.LeftToRight);
|
|
|
|
|
|
buttonBottomPanel.HAnchor = HAnchor.ParentLeftRight;
|
|
|
|
|
|
buttonBottomPanel.Padding = new BorderDouble(3, 3);
|
|
|
|
|
|
buttonBottomPanel.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
|
|
|
|
|
|
2014-03-11 15:24:47 -07:00
|
|
|
|
generateGCodeButton = textImageButtonFactory.Generate(LocalizedString.Get("Generate"));
|
2014-01-29 19:09:30 -08:00
|
|
|
|
generateGCodeButton.Click += new ButtonBase.ButtonEventHandler(generateButton_Click);
|
|
|
|
|
|
buttonBottomPanel.AddChild(generateGCodeButton);
|
|
|
|
|
|
|
2014-04-27 17:19:06 -07:00
|
|
|
|
layerSelectionButtonsPanel = new FlowLayoutWidget(FlowDirection.RightToLeft);
|
|
|
|
|
|
layerSelectionButtonsPanel.HAnchor = HAnchor.ParentLeftRight;
|
|
|
|
|
|
layerSelectionButtonsPanel.Padding = new BorderDouble(0);
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
2014-04-27 17:19:06 -07:00
|
|
|
|
GuiWidget holdPanelOpen = new GuiWidget(1, generateGCodeButton.Height);
|
|
|
|
|
|
layerSelectionButtonsPanel.AddChild(holdPanelOpen);
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
2014-04-09 21:47:00 -07:00
|
|
|
|
if (widgetHasCloseButton)
|
|
|
|
|
|
{
|
|
|
|
|
|
Button closeButton = textImageButtonFactory.Generate(LocalizedString.Get("Close"));
|
2014-04-27 17:19:06 -07:00
|
|
|
|
layerSelectionButtonsPanel.AddChild(closeButton);
|
2014-04-09 21:47:00 -07:00
|
|
|
|
closeButton.Click += (sender, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
CloseOnIdle();
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
2014-05-23 14:19:20 -07:00
|
|
|
|
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);
|
|
|
|
|
|
}
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
|
|
|
|
|
FlowLayoutWidget centerPartPreviewAndControls = new FlowLayoutWidget(FlowDirection.LeftToRight);
|
|
|
|
|
|
centerPartPreviewAndControls.AnchorAll();
|
|
|
|
|
|
|
|
|
|
|
|
gcodeDispalyWidget = new GuiWidget(HAnchor.ParentLeftRight, Agg.UI.VAnchor.ParentBottomTop);
|
|
|
|
|
|
|
2014-04-17 13:23:44 -07:00
|
|
|
|
SetProcessingMessage("Press 'Add' to select an item.".Localize());
|
2014-03-03 08:03:23 -08:00
|
|
|
|
if (printItem != null)
|
2014-01-29 19:09:30 -08:00
|
|
|
|
{
|
2014-04-17 13:23:44 -07:00
|
|
|
|
SetProcessingMessage(LocalizedString.Get("Loading GCode..."));
|
2014-03-03 08:03:23 -08:00
|
|
|
|
if (Path.GetExtension(printItem.FileLocation).ToUpper() == ".GCODE")
|
2014-01-29 19:09:30 -08:00
|
|
|
|
{
|
2014-03-03 08:03:23 -08:00
|
|
|
|
gcodeDispalyWidget.AddChild(CreateGCodeViewWidget(printItem.FileLocation));
|
2014-01-29 19:09:30 -08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2014-03-07 09:50:41 -08:00
|
|
|
|
if (File.Exists(printItem.FileLocation))
|
2014-03-03 08:03:23 -08:00
|
|
|
|
{
|
2014-03-07 09:50:41 -08:00
|
|
|
|
string gcodePathAndFileName = printItem.GCodePathAndFileName;
|
|
|
|
|
|
bool gcodeFileIsComplete = printItem.IsGCodeFileComplete(gcodePathAndFileName);
|
|
|
|
|
|
|
2014-04-17 18:03:30 -07:00
|
|
|
|
if (printItem.SlicingHadError)
|
2014-03-07 09:50:41 -08:00
|
|
|
|
{
|
2014-04-17 18:03:30 -07:00
|
|
|
|
SetProcessingMessage(slicingErrorMessage);
|
2014-03-07 09:50:41 -08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2014-04-17 18:03:30 -07:00
|
|
|
|
SetProcessingMessage(pressGenerateMessage);
|
2014-03-07 09:50:41 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (File.Exists(gcodePathAndFileName) && gcodeFileIsComplete)
|
|
|
|
|
|
{
|
|
|
|
|
|
gcodeDispalyWidget.AddChild(CreateGCodeViewWidget(gcodePathAndFileName));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// we only hook these up to make sure we can regenerate the gcode when we want
|
2014-04-21 15:00:32 -07:00
|
|
|
|
printItem.SlicingOutputMessage.RegisterEvent(sliceItem_SlicingOutputMessage, ref unregisterEvents);
|
|
|
|
|
|
printItem.SlicingDone.RegisterEvent(sliceItem_Done, ref unregisterEvents);
|
2014-03-03 08:03:23 -08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2014-04-17 18:03:30 -07:00
|
|
|
|
SetProcessingMessage(string.Format("{0}\n'{1}'", fileNotFoundMessage, printItem.Name));
|
2014-03-03 08:03:23 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2014-01-29 19:09:30 -08:00
|
|
|
|
}
|
2014-04-15 12:12:40 -07:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
generateGCodeButton.Visible = false;
|
|
|
|
|
|
}
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
|
|
|
|
|
centerPartPreviewAndControls.AddChild(gcodeDispalyWidget);
|
|
|
|
|
|
|
2014-04-27 17:19:06 -07:00
|
|
|
|
buttonRightPanel = CreateRightButtonPanel();
|
2014-01-29 19:09:30 -08:00
|
|
|
|
centerPartPreviewAndControls.AddChild(buttonRightPanel);
|
|
|
|
|
|
|
|
|
|
|
|
// add in a spacer
|
2014-04-27 17:19:06 -07:00
|
|
|
|
layerSelectionButtonsPanel.AddChild(new GuiWidget(HAnchor.ParentLeftRight));
|
|
|
|
|
|
buttonBottomPanel.AddChild(layerSelectionButtonsPanel);
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
|
|
|
|
|
mainContainerTopToBottom.AddChild(centerPartPreviewAndControls);
|
|
|
|
|
|
mainContainerTopToBottom.AddChild(buttonBottomPanel);
|
|
|
|
|
|
this.AddChild(mainContainerTopToBottom);
|
|
|
|
|
|
|
2014-04-04 18:52:51 -07:00
|
|
|
|
Add2DViewControls();
|
2014-01-29 19:09:30 -08:00
|
|
|
|
translateButton.Click += (sender, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
gcodeViewWidget.TransformState = GCodeViewWidget.ETransformState.Move;
|
|
|
|
|
|
};
|
|
|
|
|
|
scaleButton.Click += (sender, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
gcodeViewWidget.TransformState = GCodeViewWidget.ETransformState.Scale;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2014-04-04 18:52:51 -07:00
|
|
|
|
AddHandlers();
|
2014-01-29 19:09:30 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2014-05-23 14:19:20 -07:00
|
|
|
|
private void SetAnimationPosition()
|
|
|
|
|
|
{
|
|
|
|
|
|
int currentLayer = PrinterCommunication.Instance.CurrentlyPrintingLayer;
|
|
|
|
|
|
if (currentLayer >= 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectLayerSlider.Value = currentLayer-1;
|
|
|
|
|
|
layerEndRenderRatioSlider.Value = PrinterCommunication.Instance.RatioIntoCurrentLayer;
|
|
|
|
|
|
layerStartRenderRatioSlider.Value = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-04-27 17:19:06 -07:00
|
|
|
|
private FlowLayoutWidget CreateRightButtonPanel()
|
2014-01-29 19:09:30 -08:00
|
|
|
|
{
|
|
|
|
|
|
FlowLayoutWidget buttonRightPanel = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
|
|
|
|
|
buttonRightPanel.Width = 200;
|
|
|
|
|
|
{
|
|
|
|
|
|
BorderDouble buttonMargin = new BorderDouble(top: 3);
|
|
|
|
|
|
|
2014-04-17 18:03:30 -07:00
|
|
|
|
string label = "Model".Localize().ToUpper();
|
2014-03-21 16:18:47 -07:00
|
|
|
|
expandModelOptions = expandMenuOptionFactory.GenerateCheckBoxButton(label, "icon_arrow_right_no_border_32x32.png", "icon_arrow_down_no_border_32x32.png");
|
2014-01-29 19:09:30 -08:00
|
|
|
|
expandModelOptions.Margin = new BorderDouble(bottom: 2);
|
|
|
|
|
|
buttonRightPanel.AddChild(expandModelOptions);
|
|
|
|
|
|
expandModelOptions.Checked = true;
|
|
|
|
|
|
|
|
|
|
|
|
modelOptionsContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
|
|
|
|
|
modelOptionsContainer.HAnchor = HAnchor.ParentLeftRight;
|
|
|
|
|
|
//modelOptionsContainer.Visible = false;
|
|
|
|
|
|
buttonRightPanel.AddChild(modelOptionsContainer);
|
|
|
|
|
|
|
2014-04-10 14:07:25 -07:00
|
|
|
|
expandDisplayOptions = expandMenuOptionFactory.GenerateCheckBoxButton("Display".Localize().ToUpper(), "icon_arrow_right_no_border_32x32.png", "icon_arrow_down_no_border_32x32.png");
|
2014-01-29 19:09:30 -08:00
|
|
|
|
expandDisplayOptions.Margin = new BorderDouble(bottom: 2);
|
|
|
|
|
|
buttonRightPanel.AddChild(expandDisplayOptions);
|
|
|
|
|
|
expandDisplayOptions.Checked = true;
|
|
|
|
|
|
|
|
|
|
|
|
displayOptionsContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
|
|
|
|
|
displayOptionsContainer.HAnchor = HAnchor.ParentLeftRight;
|
|
|
|
|
|
//displayOptionsContainer.Visible = false;
|
|
|
|
|
|
buttonRightPanel.AddChild(displayOptionsContainer);
|
|
|
|
|
|
|
|
|
|
|
|
GuiWidget verticalSpacer = new GuiWidget();
|
|
|
|
|
|
verticalSpacer.VAnchor = VAnchor.ParentBottomTop;
|
|
|
|
|
|
buttonRightPanel.AddChild(verticalSpacer);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
buttonRightPanel.Padding = new BorderDouble(6, 6);
|
|
|
|
|
|
buttonRightPanel.Margin = new BorderDouble(0, 1);
|
|
|
|
|
|
buttonRightPanel.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
|
|
|
|
|
buttonRightPanel.VAnchor = VAnchor.ParentBottomTop;
|
|
|
|
|
|
|
|
|
|
|
|
return buttonRightPanel;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void CreateOptionsContent()
|
|
|
|
|
|
{
|
|
|
|
|
|
AddModelInfo(modelOptionsContainer);
|
|
|
|
|
|
AddDisplayControls(displayOptionsContainer);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void AddModelInfo(FlowLayoutWidget buttonPanel)
|
|
|
|
|
|
{
|
|
|
|
|
|
textImageButtonFactory.FixedWidth = 44;
|
|
|
|
|
|
|
|
|
|
|
|
FlowLayoutWidget modelInfoContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
|
|
|
|
|
modelInfoContainer.HAnchor = HAnchor.ParentLeftRight;
|
|
|
|
|
|
modelInfoContainer.Padding = new BorderDouble(5);
|
|
|
|
|
|
|
2014-04-10 14:07:25 -07:00
|
|
|
|
string printTimeLabel = "Print Time".Localize().ToUpper();
|
|
|
|
|
|
string printTimeLabelFull = string.Format ("{0}:", printTimeLabel);
|
2014-01-29 19:09:30 -08:00
|
|
|
|
// put in the print time
|
2014-04-10 14:07:25 -07:00
|
|
|
|
modelInfoContainer.AddChild(new TextWidget(printTimeLabelFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize:10));
|
2014-01-29 19:09:30 -08:00
|
|
|
|
{
|
|
|
|
|
|
string timeRemainingText = "---";
|
|
|
|
|
|
|
|
|
|
|
|
if (gcodeViewWidget != null && gcodeViewWidget.LoadedGCode != null)
|
|
|
|
|
|
{
|
2014-05-23 14:19:20 -07:00
|
|
|
|
int secondsRemaining = (int)gcodeViewWidget.LoadedGCode.Instruction(0).secondsToEndFromHere;
|
2014-01-29 19:09:30 -08:00
|
|
|
|
int hoursRemaining = (int)(secondsRemaining / (60 * 60));
|
|
|
|
|
|
int minutesRemaining = (int)((secondsRemaining + 30) / 60 - hoursRemaining * 60); // +30 for rounding
|
|
|
|
|
|
secondsRemaining = secondsRemaining % 60;
|
|
|
|
|
|
if (hoursRemaining > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
timeRemainingText = string.Format("{0} h, {1} min", hoursRemaining, minutesRemaining);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
timeRemainingText = string.Format("{0} min", minutesRemaining);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-03-21 16:18:47 -07:00
|
|
|
|
GuiWidget estimatedPrintTime = new TextWidget(string.Format("{0}", timeRemainingText), textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 14);
|
|
|
|
|
|
//estimatedPrintTime.HAnchor = Agg.UI.HAnchor.ParentLeft;
|
|
|
|
|
|
estimatedPrintTime.Margin = new BorderDouble(0, 9, 0 ,3);
|
2014-01-29 19:09:30 -08:00
|
|
|
|
modelInfoContainer.AddChild(estimatedPrintTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-03-21 16:18:47 -07:00
|
|
|
|
//modelInfoContainer.AddChild(new TextWidget("Size:", textColor: ActiveTheme.Instance.PrimaryTextColor));
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
2014-04-15 10:11:56 -07:00
|
|
|
|
string filamentLengthLabel = "Filament Length".Localize().ToUpper();
|
|
|
|
|
|
string filamentLengthLabelFull = string.Format ("{0}:", filamentLengthLabel);
|
2014-01-29 19:09:30 -08:00
|
|
|
|
// show the filament used
|
2014-04-15 10:11:56 -07:00
|
|
|
|
modelInfoContainer.AddChild(new TextWidget(filamentLengthLabelFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 9));
|
2014-01-29 19:09:30 -08:00
|
|
|
|
{
|
|
|
|
|
|
double filamentUsed = gcodeViewWidget.LoadedGCode.GetFilamentUsedMm(ActiveSliceSettings.Instance.NozzleDiameter);
|
|
|
|
|
|
|
2014-03-21 16:18:47 -07:00
|
|
|
|
GuiWidget estimatedPrintTime = new TextWidget(string.Format("{0:0.0} mm", filamentUsed), pointSize: 14, textColor: ActiveTheme.Instance.PrimaryTextColor);
|
|
|
|
|
|
//estimatedPrintTime.HAnchor = Agg.UI.HAnchor.ParentLeft;
|
|
|
|
|
|
estimatedPrintTime.Margin = new BorderDouble(0, 9, 0, 3);
|
2014-01-29 19:09:30 -08:00
|
|
|
|
modelInfoContainer.AddChild(estimatedPrintTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-04-10 14:07:25 -07:00
|
|
|
|
string filamentVolumeLabel = "Filament Volume".Localize().ToUpper();
|
|
|
|
|
|
string filamentVolumeLabelFull = string.Format("{0}:", filamentVolumeLabel);
|
|
|
|
|
|
modelInfoContainer.AddChild(new TextWidget(filamentVolumeLabelFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 9));
|
2014-01-29 19:09:30 -08:00
|
|
|
|
{
|
2014-03-24 07:06:07 -07:00
|
|
|
|
double filamentMm3 = gcodeViewWidget.LoadedGCode.GetFilamentCubicMm(ActiveSliceSettings.Instance.FilamentDiameter);
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
2014-03-21 16:18:47 -07:00
|
|
|
|
GuiWidget estimatedPrintTime = new TextWidget(string.Format("{0:0.00} cm3", filamentMm3 / 1000), pointSize:14, textColor: ActiveTheme.Instance.PrimaryTextColor);
|
|
|
|
|
|
//estimatedPrintTime.HAnchor = Agg.UI.HAnchor.ParentLeft;
|
|
|
|
|
|
estimatedPrintTime.Margin = new BorderDouble(0, 9, 0, 3);
|
2014-01-29 19:09:30 -08:00
|
|
|
|
modelInfoContainer.AddChild(estimatedPrintTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-04-10 14:07:25 -07:00
|
|
|
|
string weightLabel = "Est. Weight".Localize().ToUpper();
|
|
|
|
|
|
string weightLabelFull = string.Format("{0}:", weightLabel);
|
|
|
|
|
|
modelInfoContainer.AddChild(new TextWidget(weightLabelFull, pointSize: 9, textColor: ActiveTheme.Instance.PrimaryTextColor));
|
2014-01-29 19:09:30 -08:00
|
|
|
|
{
|
|
|
|
|
|
var density = 1.0;
|
|
|
|
|
|
string filamentType = "PLA";
|
|
|
|
|
|
if (filamentType == "ABS")
|
|
|
|
|
|
{
|
|
|
|
|
|
density = 1.04;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (filamentType == "PLA")
|
|
|
|
|
|
{
|
|
|
|
|
|
density = 1.24;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-03-24 07:06:07 -07:00
|
|
|
|
double filamentWeightGrams = gcodeViewWidget.LoadedGCode.GetFilamentWeightGrams(ActiveSliceSettings.Instance.FilamentDiameter, density);
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
2014-03-21 16:18:47 -07:00
|
|
|
|
GuiWidget estimatedPrintTime = new TextWidget(string.Format("{0:0.00} g", filamentWeightGrams), pointSize: 14, textColor: ActiveTheme.Instance.PrimaryTextColor);
|
|
|
|
|
|
//estimatedPrintTime.HAnchor = Agg.UI.HAnchor.ParentLeft;
|
|
|
|
|
|
estimatedPrintTime.Margin = new BorderDouble(0, 9, 0, 3);
|
2014-01-29 19:09:30 -08:00
|
|
|
|
modelInfoContainer.AddChild(estimatedPrintTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-03-21 16:18:47 -07:00
|
|
|
|
//modelInfoContainer.AddChild(new TextWidget("Layer Count:", textColor: ActiveTheme.Instance.PrimaryTextColor));
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
|
|
|
|
|
buttonPanel.AddChild(modelInfoContainer);
|
|
|
|
|
|
|
|
|
|
|
|
textImageButtonFactory.FixedWidth = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void AddLayerInfo(FlowLayoutWidget buttonPanel)
|
|
|
|
|
|
{
|
|
|
|
|
|
textImageButtonFactory.FixedWidth = 44;
|
|
|
|
|
|
|
|
|
|
|
|
FlowLayoutWidget layerInfoContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
|
|
|
|
|
layerInfoContainer.HAnchor = HAnchor.ParentLeftRight;
|
|
|
|
|
|
layerInfoContainer.Padding = new BorderDouble(5);
|
|
|
|
|
|
|
2014-03-21 16:18:47 -07:00
|
|
|
|
layerInfoContainer.AddChild(new TextWidget("Layer Number:", textColor: ActiveTheme.Instance.PrimaryTextColor));
|
|
|
|
|
|
layerInfoContainer.AddChild(new TextWidget("Layer Height:", textColor: ActiveTheme.Instance.PrimaryTextColor));
|
|
|
|
|
|
layerInfoContainer.AddChild(new TextWidget("Num GCodes:", textColor: ActiveTheme.Instance.PrimaryTextColor));
|
|
|
|
|
|
layerInfoContainer.AddChild(new TextWidget("Filament Used:", textColor: ActiveTheme.Instance.PrimaryTextColor));
|
|
|
|
|
|
layerInfoContainer.AddChild(new TextWidget("Weight:", textColor: ActiveTheme.Instance.PrimaryTextColor));
|
|
|
|
|
|
layerInfoContainer.AddChild(new TextWidget("Print Time:", textColor: ActiveTheme.Instance.PrimaryTextColor));
|
|
|
|
|
|
layerInfoContainer.AddChild(new TextWidget("Extrude Speeds:", textColor: ActiveTheme.Instance.PrimaryTextColor));
|
|
|
|
|
|
layerInfoContainer.AddChild(new TextWidget("Move Speeds:", textColor: ActiveTheme.Instance.PrimaryTextColor));
|
|
|
|
|
|
layerInfoContainer.AddChild(new TextWidget("Retract Speeds:", textColor: ActiveTheme.Instance.PrimaryTextColor));
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
|
|
|
|
|
buttonPanel.AddChild(layerInfoContainer);
|
|
|
|
|
|
|
|
|
|
|
|
textImageButtonFactory.FixedWidth = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void AddDisplayControls(FlowLayoutWidget buttonPanel)
|
|
|
|
|
|
{
|
|
|
|
|
|
textImageButtonFactory.FixedWidth = 44;
|
|
|
|
|
|
|
|
|
|
|
|
FlowLayoutWidget layerInfoContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
|
|
|
|
|
layerInfoContainer.HAnchor = HAnchor.ParentLeftRight;
|
|
|
|
|
|
layerInfoContainer.Padding = new BorderDouble(5);
|
|
|
|
|
|
|
|
|
|
|
|
// put in a show grid check box
|
2014-03-21 16:18:47 -07:00
|
|
|
|
CheckBox showGrid = new CheckBox(LocalizedString.Get("Show Grid"), textColor: ActiveTheme.Instance.PrimaryTextColor);
|
2014-01-29 19:09:30 -08:00
|
|
|
|
showGrid.Checked = gcodeViewWidget.RenderGrid;
|
|
|
|
|
|
showGrid.CheckedStateChanged += (sender, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
gcodeViewWidget.RenderGrid = showGrid.Checked;
|
|
|
|
|
|
};
|
|
|
|
|
|
layerInfoContainer.AddChild(showGrid);
|
|
|
|
|
|
|
|
|
|
|
|
// put in a show moves checkbox
|
2014-03-21 16:18:47 -07:00
|
|
|
|
CheckBox showMoves = new CheckBox(LocalizedString.Get("Show Moves"), textColor: ActiveTheme.Instance.PrimaryTextColor);
|
2014-01-29 19:09:30 -08:00
|
|
|
|
showMoves.Checked = gcodeViewWidget.RenderMoves;
|
|
|
|
|
|
showMoves.CheckedStateChanged += (sender, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
gcodeViewWidget.RenderMoves = showMoves.Checked;
|
|
|
|
|
|
};
|
|
|
|
|
|
layerInfoContainer.AddChild(showMoves);
|
|
|
|
|
|
|
2014-02-17 14:36:24 -08:00
|
|
|
|
// put in a show Retractions checkbox
|
2014-03-21 16:18:47 -07:00
|
|
|
|
CheckBox showRetractions = new CheckBox(LocalizedString.Get("Show Retractions"), textColor: ActiveTheme.Instance.PrimaryTextColor);
|
2014-02-17 14:36:24 -08:00
|
|
|
|
showRetractions.Checked = gcodeViewWidget.RenderRetractions;
|
|
|
|
|
|
showRetractions.CheckedStateChanged += (sender, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
gcodeViewWidget.RenderRetractions = showRetractions.Checked;
|
|
|
|
|
|
};
|
|
|
|
|
|
layerInfoContainer.AddChild(showRetractions);
|
|
|
|
|
|
|
2014-03-21 16:18:47 -07:00
|
|
|
|
//layerInfoContainer.AddChild(new CheckBox("Show Retractions", textColor: ActiveTheme.Instance.PrimaryTextColor));
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
|
|
|
|
|
buttonPanel.AddChild(layerInfoContainer);
|
|
|
|
|
|
|
|
|
|
|
|
textImageButtonFactory.FixedWidth = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnParentChanged(EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnParentChanged(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string partToStartLoadingOnFirstDraw = null;
|
|
|
|
|
|
private GuiWidget CreateGCodeViewWidget(string pathAndFileName)
|
|
|
|
|
|
{
|
|
|
|
|
|
gcodeViewWidget = new GCodeViewWidget(bedSizeFunction(), bedCenterFunction());
|
|
|
|
|
|
gcodeViewWidget.DoneLoading += DoneLoadingGCode;
|
|
|
|
|
|
gcodeViewWidget.LoadingProgressChanged += LoadingProgressChanged;
|
|
|
|
|
|
partToStartLoadingOnFirstDraw = pathAndFileName;
|
|
|
|
|
|
|
|
|
|
|
|
return gcodeViewWidget;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool hookedParentKeyDown = false;
|
|
|
|
|
|
public override void OnDraw(Graphics2D graphics2D)
|
|
|
|
|
|
{
|
2014-05-23 14:19:20 -07:00
|
|
|
|
if (animatePrint != null && animatePrint.Checked)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetAnimationPosition();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-01-29 19:09:30 -08:00
|
|
|
|
if (!hookedParentKeyDown)
|
|
|
|
|
|
{
|
2014-04-20 22:09:10 -07:00
|
|
|
|
GuiWidget parent = Parent;
|
|
|
|
|
|
while (parent as SystemWindow == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
parent = parent.Parent;
|
|
|
|
|
|
}
|
|
|
|
|
|
parent.KeyDown += Parent_KeyDown;
|
2014-01-29 19:09:30 -08:00
|
|
|
|
hookedParentKeyDown = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (partToStartLoadingOnFirstDraw != null)
|
|
|
|
|
|
{
|
2014-03-01 08:06:43 -08:00
|
|
|
|
gcodeViewWidget.LoadInBackground(partToStartLoadingOnFirstDraw);
|
2014-01-29 19:09:30 -08:00
|
|
|
|
partToStartLoadingOnFirstDraw = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
base.OnDraw(graphics2D);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Parent_KeyDown(object sender, KeyEventArgs keyEvent)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (keyEvent.KeyCode == Keys.Up)
|
|
|
|
|
|
{
|
2014-03-25 13:38:56 -07:00
|
|
|
|
if (gcodeViewWidget != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
gcodeViewWidget.ActiveLayerIndex = (gcodeViewWidget.ActiveLayerIndex + 1);
|
|
|
|
|
|
}
|
2014-01-29 19:09:30 -08:00
|
|
|
|
}
|
|
|
|
|
|
else if (keyEvent.KeyCode == Keys.Down)
|
|
|
|
|
|
{
|
2014-03-25 13:38:56 -07:00
|
|
|
|
if (gcodeViewWidget != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
gcodeViewWidget.ActiveLayerIndex = (gcodeViewWidget.ActiveLayerIndex - 1);
|
|
|
|
|
|
}
|
2014-01-29 19:09:30 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-04-17 13:23:44 -07:00
|
|
|
|
private void SetProcessingMessage(string message)
|
2014-01-29 19:09:30 -08:00
|
|
|
|
{
|
2014-04-17 13:23:44 -07:00
|
|
|
|
if (gcodeProcessingStateInfoText == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
gcodeProcessingStateInfoText = new TextWidget(message);
|
|
|
|
|
|
gcodeProcessingStateInfoText.HAnchor = HAnchor.ParentCenter;
|
|
|
|
|
|
gcodeProcessingStateInfoText.VAnchor = VAnchor.ParentCenter;
|
|
|
|
|
|
gcodeProcessingStateInfoText.AutoExpandBoundsToText = true;
|
|
|
|
|
|
|
|
|
|
|
|
GuiWidget labelContainer = new GuiWidget();
|
|
|
|
|
|
labelContainer.AnchorAll();
|
|
|
|
|
|
labelContainer.AddChild(gcodeProcessingStateInfoText);
|
|
|
|
|
|
labelContainer.Selectable = false;
|
|
|
|
|
|
|
|
|
|
|
|
gcodeDispalyWidget.AddChild(labelContainer);
|
|
|
|
|
|
}
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
2014-04-17 13:23:44 -07:00
|
|
|
|
if (message == "")
|
|
|
|
|
|
{
|
|
|
|
|
|
gcodeProcessingStateInfoText.BackgroundColor = new RGBA_Bytes();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
gcodeProcessingStateInfoText.BackgroundColor = RGBA_Bytes.White;
|
|
|
|
|
|
}
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
2014-04-17 13:23:44 -07:00
|
|
|
|
gcodeProcessingStateInfoText.Text = message;
|
2014-01-29 19:09:30 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LoadingProgressChanged(object sender, ProgressChangedEventArgs e)
|
|
|
|
|
|
{
|
2014-04-17 13:23:44 -07:00
|
|
|
|
SetProcessingMessage(string.Format("Loading GCode {0}%...", e.ProgressPercentage));
|
2014-01-29 19:09:30 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DoneLoadingGCode(object sender, EventArgs e)
|
|
|
|
|
|
{
|
2014-04-17 13:23:44 -07:00
|
|
|
|
SetProcessingMessage("");
|
2014-01-29 19:09:30 -08:00
|
|
|
|
if (gcodeViewWidget != null
|
|
|
|
|
|
&& gcodeViewWidget.LoadedGCode != null
|
2014-05-23 14:19:20 -07:00
|
|
|
|
&& gcodeViewWidget.LoadedGCode.Count > 0)
|
2014-01-29 19:09:30 -08:00
|
|
|
|
{
|
|
|
|
|
|
CreateOptionsContent();
|
|
|
|
|
|
|
|
|
|
|
|
SetLayerWidget setLayerWidget = new SetLayerWidget(gcodeViewWidget);
|
|
|
|
|
|
setLayerWidget.VAnchor = Agg.UI.VAnchor.ParentTop;
|
2014-04-27 17:19:06 -07:00
|
|
|
|
layerSelectionButtonsPanel.AddChild(setLayerWidget);
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
|
|
|
|
|
LayerNavigationWidget navigationWidget = new LayerNavigationWidget(gcodeViewWidget);
|
|
|
|
|
|
navigationWidget.Margin = new BorderDouble(0, 0, 20, 0);
|
2014-04-27 17:19:06 -07:00
|
|
|
|
layerSelectionButtonsPanel.AddChild(navigationWidget);
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
2014-02-18 10:26:11 -08:00
|
|
|
|
selectLayerSlider = new Slider(new Vector2(), 10, 0, gcodeViewWidget.LoadedGCode.NumChangesInZ - 1, Orientation.Vertical);
|
2014-01-29 19:09:30 -08:00
|
|
|
|
selectLayerSlider.ValueChanged += new EventHandler(selectLayerSlider_ValueChanged);
|
|
|
|
|
|
gcodeViewWidget.ActiveLayerChanged += new EventHandler(gcodeViewWidget_ActiveLayerChanged);
|
|
|
|
|
|
AddChild(selectLayerSlider);
|
2014-03-11 10:41:39 -07:00
|
|
|
|
|
2014-03-15 14:02:43 -07:00
|
|
|
|
AddChild(new TextWidget(LocalizedString.Get("start:"), 50, 77, 10, Agg.Font.Justification.Right));
|
2014-03-11 10:41:39 -07:00
|
|
|
|
layerStartRenderRatioSlider = new Slider(new Vector2(), 10);
|
|
|
|
|
|
layerStartRenderRatioSlider.ValueChanged += new EventHandler(layerStartRenderRatioSlider_ValueChanged);
|
|
|
|
|
|
AddChild(layerStartRenderRatioSlider);
|
|
|
|
|
|
|
2014-03-15 14:02:43 -07:00
|
|
|
|
AddChild(new TextWidget(LocalizedString.Get("end:"), 50, 57, 10, Agg.Font.Justification.Right));
|
2014-03-15 09:47:51 -07:00
|
|
|
|
layerEndRenderRatioSlider = new Slider(new Vector2(), 10);
|
|
|
|
|
|
layerEndRenderRatioSlider.Value = 1;
|
|
|
|
|
|
layerEndRenderRatioSlider.ValueChanged += new EventHandler(layerEndRenderRatioSlider_ValueChanged);
|
|
|
|
|
|
AddChild(layerEndRenderRatioSlider);
|
|
|
|
|
|
|
2014-03-11 10:41:39 -07:00
|
|
|
|
SetSliderSizes();
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
2014-02-24 10:59:25 -08:00
|
|
|
|
// let's change the active layer so that it is set to the first layer with data
|
|
|
|
|
|
gcodeViewWidget.ActiveLayerIndex = gcodeViewWidget.ActiveLayerIndex + 1;
|
|
|
|
|
|
gcodeViewWidget.ActiveLayerIndex = gcodeViewWidget.ActiveLayerIndex - 1;
|
|
|
|
|
|
|
2014-01-29 19:09:30 -08:00
|
|
|
|
BoundsChanged += new EventHandler(PartPreviewGCode_BoundsChanged);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-03-11 10:41:39 -07:00
|
|
|
|
void layerStartRenderRatioSlider_ValueChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
2014-03-15 09:47:51 -07:00
|
|
|
|
if (layerEndRenderRatioSlider.Value < layerStartRenderRatioSlider.Value)
|
|
|
|
|
|
{
|
|
|
|
|
|
layerEndRenderRatioSlider.Value = layerStartRenderRatioSlider.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gcodeViewWidget.FeatureToStartOnRatio0To1 = layerStartRenderRatioSlider.Value;
|
|
|
|
|
|
gcodeViewWidget.FeatureToEndOnRatio0To1 = layerEndRenderRatioSlider.Value;
|
2014-03-15 11:58:48 -07:00
|
|
|
|
gcodeViewWidget.Invalidate();
|
2014-03-15 09:47:51 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void layerEndRenderRatioSlider_ValueChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (layerStartRenderRatioSlider.Value > layerEndRenderRatioSlider.Value)
|
|
|
|
|
|
{
|
|
|
|
|
|
layerStartRenderRatioSlider.Value = layerEndRenderRatioSlider.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gcodeViewWidget.FeatureToStartOnRatio0To1 = layerStartRenderRatioSlider.Value;
|
|
|
|
|
|
gcodeViewWidget.FeatureToEndOnRatio0To1 = layerEndRenderRatioSlider.Value;
|
2014-03-15 11:58:48 -07:00
|
|
|
|
gcodeViewWidget.Invalidate();
|
2014-03-11 10:41:39 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2014-01-29 19:09:30 -08:00
|
|
|
|
void gcodeViewWidget_ActiveLayerChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (gcodeViewWidget.ActiveLayerIndex != (int)(selectLayerSlider.Value + .5))
|
|
|
|
|
|
{
|
|
|
|
|
|
selectLayerSlider.Value = gcodeViewWidget.ActiveLayerIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void selectLayerSlider_ValueChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
gcodeViewWidget.ActiveLayerIndex = (int)(selectLayerSlider.Value + .5);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PartPreviewGCode_BoundsChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
2014-03-11 10:41:39 -07:00
|
|
|
|
SetSliderSizes();
|
2014-01-29 19:09:30 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2014-03-11 10:41:39 -07:00
|
|
|
|
void SetSliderSizes()
|
2014-01-29 19:09:30 -08:00
|
|
|
|
{
|
2014-03-15 11:59:30 -07:00
|
|
|
|
selectLayerSlider.OriginRelativeParent = new Vector2(gcodeDispalyWidget.Width - 20, 100);
|
2014-01-29 19:09:30 -08:00
|
|
|
|
selectLayerSlider.TotalWidthInPixels = gcodeDispalyWidget.Height - 80;
|
2014-03-11 10:41:39 -07:00
|
|
|
|
|
2014-03-15 11:58:48 -07:00
|
|
|
|
layerStartRenderRatioSlider.OriginRelativeParent = new Vector2(60, 80);
|
|
|
|
|
|
layerStartRenderRatioSlider.TotalWidthInPixels = gcodeDispalyWidget.Width - 100;
|
2014-03-15 09:47:51 -07:00
|
|
|
|
|
2014-03-15 11:58:48 -07:00
|
|
|
|
layerEndRenderRatioSlider.OriginRelativeParent = new Vector2(60, 60);
|
|
|
|
|
|
layerEndRenderRatioSlider.TotalWidthInPixels = gcodeDispalyWidget.Width - 100;
|
2014-01-29 19:09:30 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void AddHandlers()
|
|
|
|
|
|
{
|
|
|
|
|
|
expandModelOptions.CheckedStateChanged += new CheckBox.CheckedStateChangedEventHandler(expandModelOptions_CheckedStateChanged);
|
2014-04-17 18:03:30 -07:00
|
|
|
|
expandDisplayOptions.CheckedStateChanged += new CheckBox.CheckedStateChangedEventHandler(expandDisplayOptions_CheckedStateChanged);
|
2014-01-29 19:09:30 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void expandModelOptions_CheckedStateChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
modelOptionsContainer.Visible = expandModelOptions.Checked;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-04-17 18:03:30 -07:00
|
|
|
|
void expandDisplayOptions_CheckedStateChanged(object sender, EventArgs e)
|
2014-01-29 19:09:30 -08:00
|
|
|
|
{
|
|
|
|
|
|
displayOptionsContainer.Visible = expandDisplayOptions.Checked;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnClosed(EventArgs e)
|
|
|
|
|
|
{
|
2014-04-20 22:09:10 -07:00
|
|
|
|
GuiWidget parent = Parent;
|
|
|
|
|
|
while (parent as SystemWindow == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
parent = parent.Parent;
|
|
|
|
|
|
}
|
|
|
|
|
|
parent.KeyDown -= Parent_KeyDown;
|
|
|
|
|
|
|
2014-04-21 15:00:32 -07:00
|
|
|
|
if (unregisterEvents != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
unregisterEvents(this, null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-03-03 08:03:23 -08:00
|
|
|
|
if (printItem != null)
|
2014-01-29 19:09:30 -08:00
|
|
|
|
{
|
2014-04-21 15:00:32 -07:00
|
|
|
|
printItem.SlicingOutputMessage.UnregisterEvent(sliceItem_SlicingOutputMessage, ref unregisterEvents);
|
|
|
|
|
|
printItem.SlicingDone.UnregisterEvent(sliceItem_Done, ref unregisterEvents);
|
2014-03-03 08:03:23 -08:00
|
|
|
|
if (startedSliceFromGenerateButton && printItem.CurrentlySlicing)
|
|
|
|
|
|
{
|
|
|
|
|
|
SlicingQueue.Instance.CancelCurrentSlicing();
|
|
|
|
|
|
}
|
2014-01-29 19:09:30 -08:00
|
|
|
|
}
|
|
|
|
|
|
base.OnClosed(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void generateButton_Click(object sender, MouseEventArgs mouseEvent)
|
2014-02-15 18:26:16 -08:00
|
|
|
|
{
|
|
|
|
|
|
UiThread.RunOnIdle(DoGenerateButton_Click, sender);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DoGenerateButton_Click(object state)
|
2014-01-29 19:09:30 -08:00
|
|
|
|
{
|
2014-04-14 16:45:08 -07:00
|
|
|
|
if (ActiveSliceSettings.Instance.IsValid() && printItem != null)
|
2014-01-29 19:09:30 -08:00
|
|
|
|
{
|
2014-02-15 18:26:16 -08:00
|
|
|
|
((Button)state).Visible = false;
|
2014-01-29 19:09:30 -08:00
|
|
|
|
SlicingQueue.Instance.QueuePartForSlicing(printItem);
|
|
|
|
|
|
startedSliceFromGenerateButton = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sliceItem_SlicingOutputMessage(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
StringEventArgs message = e as StringEventArgs;
|
|
|
|
|
|
if (message != null && message.Data != null)
|
|
|
|
|
|
{
|
2014-04-17 13:23:44 -07:00
|
|
|
|
SetProcessingMessage(message.Data);
|
2014-01-29 19:09:30 -08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2014-04-17 13:23:44 -07:00
|
|
|
|
SetProcessingMessage("");
|
2014-01-29 19:09:30 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sliceItem_Done(object sender, EventArgs e)
|
|
|
|
|
|
{
|
2014-03-03 15:50:23 -08:00
|
|
|
|
// We can add this while we have it open (when we are done loading).
|
|
|
|
|
|
// So we need to make sure we only have it added once. This will be ok to run when
|
|
|
|
|
|
// not added or when added and will ensure we only have one hook.
|
2014-04-21 15:00:32 -07:00
|
|
|
|
printItem.SlicingOutputMessage.UnregisterEvent(sliceItem_SlicingOutputMessage, ref unregisterEvents);
|
|
|
|
|
|
printItem.SlicingDone.UnregisterEvent(sliceItem_Done, ref unregisterEvents);
|
2014-03-03 15:50:23 -08:00
|
|
|
|
|
2014-01-29 19:09:30 -08:00
|
|
|
|
UiThread.RunOnIdle(CreateAndAddChildren);
|
|
|
|
|
|
startedSliceFromGenerateButton = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class SetLayerWidget : FlowLayoutWidget
|
|
|
|
|
|
{
|
|
|
|
|
|
NumberEdit editCurrentLayerIndex;
|
|
|
|
|
|
Button setLayerButton;
|
|
|
|
|
|
GCodeViewWidget gcodeViewWidget;
|
|
|
|
|
|
TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
|
|
|
|
|
|
|
|
|
|
|
|
public SetLayerWidget(GCodeViewWidget gcodeViewWidget)
|
|
|
|
|
|
:base(FlowDirection.LeftToRight)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.gcodeViewWidget = gcodeViewWidget;
|
2014-03-21 16:18:47 -07:00
|
|
|
|
|
|
|
|
|
|
textImageButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
|
|
|
|
|
textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
|
|
|
|
|
textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
|
|
|
|
|
textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
|
|
|
|
|
editCurrentLayerIndex = new NumberEdit(1, pixelWidth: 40);
|
|
|
|
|
|
editCurrentLayerIndex.VAnchor = VAnchor.ParentCenter;
|
|
|
|
|
|
editCurrentLayerIndex.Margin = new BorderDouble(5, 0);
|
|
|
|
|
|
editCurrentLayerIndex.EditComplete += new EventHandler(editCurrentLayerIndex_EditComplete);
|
|
|
|
|
|
this.AddChild(editCurrentLayerIndex);
|
|
|
|
|
|
gcodeViewWidget.ActiveLayerChanged += new EventHandler(gcodeViewWidget_ActiveLayerChanged);
|
|
|
|
|
|
|
2014-03-11 15:24:47 -07:00
|
|
|
|
setLayerButton = textImageButtonFactory.Generate(LocalizedString.Get("Go"));
|
2014-01-29 19:09:30 -08:00
|
|
|
|
setLayerButton.VAnchor = Agg.UI.VAnchor.ParentCenter;
|
|
|
|
|
|
setLayerButton.Click += new Button.ButtonEventHandler(layerCountTextWidget_EditComplete);
|
|
|
|
|
|
this.AddChild(setLayerButton);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void gcodeViewWidget_ActiveLayerChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
editCurrentLayerIndex.Value = gcodeViewWidget.ActiveLayerIndex + 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void editCurrentLayerIndex_EditComplete(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
gcodeViewWidget.ActiveLayerIndex = ((int)editCurrentLayerIndex.Value - 1);
|
|
|
|
|
|
editCurrentLayerIndex.Value = gcodeViewWidget.ActiveLayerIndex + 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void layerCountTextWidget_EditComplete(object sender, MouseEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
gcodeViewWidget.ActiveLayerIndex = ((int)editCurrentLayerIndex.Value - 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class LayerNavigationWidget : FlowLayoutWidget
|
|
|
|
|
|
{
|
|
|
|
|
|
Button prevLayerButton;
|
|
|
|
|
|
Button nextLayerButton;
|
|
|
|
|
|
TextWidget layerCountTextWidget;
|
|
|
|
|
|
GCodeViewWidget gcodeViewWidget;
|
|
|
|
|
|
TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
|
|
|
|
|
|
|
|
|
|
|
|
public LayerNavigationWidget(GCodeViewWidget gcodeViewWidget)
|
|
|
|
|
|
:base(FlowDirection.LeftToRight)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.gcodeViewWidget = gcodeViewWidget;
|
|
|
|
|
|
|
2014-03-21 16:18:47 -07:00
|
|
|
|
textImageButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
|
|
|
|
|
textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
|
|
|
|
|
textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
|
|
|
|
|
textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
2014-01-29 19:09:30 -08:00
|
|
|
|
|
|
|
|
|
|
prevLayerButton = textImageButtonFactory.Generate("<<");
|
|
|
|
|
|
prevLayerButton.Click += new Button.ButtonEventHandler(prevLayer_ButtonClick);
|
|
|
|
|
|
this.AddChild(prevLayerButton);
|
|
|
|
|
|
|
|
|
|
|
|
layerCountTextWidget = new TextWidget("/1____", 12);
|
|
|
|
|
|
layerCountTextWidget.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
|
|
|
|
|
layerCountTextWidget.VAnchor = VAnchor.ParentCenter;
|
|
|
|
|
|
layerCountTextWidget.AutoExpandBoundsToText = true;
|
|
|
|
|
|
layerCountTextWidget.Margin = new BorderDouble(5, 0);
|
|
|
|
|
|
this.AddChild(layerCountTextWidget);
|
|
|
|
|
|
|
|
|
|
|
|
nextLayerButton = textImageButtonFactory.Generate(">>");
|
|
|
|
|
|
nextLayerButton.Click += new Button.ButtonEventHandler(nextLayer_ButtonClick);
|
|
|
|
|
|
this.AddChild(nextLayerButton);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nextLayer_ButtonClick(object sender, MouseEventArgs mouseEvent)
|
|
|
|
|
|
{
|
|
|
|
|
|
gcodeViewWidget.ActiveLayerIndex = (gcodeViewWidget.ActiveLayerIndex + 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void prevLayer_ButtonClick(object sender, MouseEventArgs mouseEvent)
|
|
|
|
|
|
{
|
|
|
|
|
|
gcodeViewWidget.ActiveLayerIndex = (gcodeViewWidget.ActiveLayerIndex - 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnDraw(Graphics2D graphics2D)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (gcodeViewWidget.LoadedGCode != null)
|
|
|
|
|
|
{
|
2014-02-18 10:26:11 -08:00
|
|
|
|
layerCountTextWidget.Text = string.Format("{0} / {1}", gcodeViewWidget.ActiveLayerIndex + 1, gcodeViewWidget.LoadedGCode.NumChangesInZ.ToString());
|
2014-01-29 19:09:30 -08:00
|
|
|
|
}
|
|
|
|
|
|
base.OnDraw(graphics2D);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|