public static bool SetupRequired(PrinterConfig printer, bool requiresLoadedFilament) { return(printer == null || LevelingValidation.NeedsToBeRun(printer) || // PrintLevelingWizard ZCalibrationWizard.NeedsToBeRun(printer) || (requiresLoadedFilament && LoadFilamentWizard.NeedsToBeRun0(printer)) || (requiresLoadedFilament && LoadFilamentWizard.NeedsToBeRun1(printer)) || XyCalibrationWizard.NeedsToBeRun(printer)); }
public static bool SetupRequired(PrinterConfig printer, bool requiresLoadedFilament) { // TODO: Verify invoked with low frequency var printerShim = ApplicationController.Instance.Shim(printer); return(LevelingValidation.NeedsToBeRun(printerShim) || // PrintLevelingWizard ZCalibrationWizard.NeedsToBeRun(printer) || (requiresLoadedFilament && LoadFilamentWizard.NeedsToBeRun0(printer)) || (requiresLoadedFilament && LoadFilamentWizard.NeedsToBeRun1(printer)) || XyCalibrationWizard.NeedsToBeRun(printer)); }
private async Task PrintCalibrationPart(XyCalibrationWizard calibrationWizard) { var scene = new Object3D(); // create the calibration objects IObject3D item = await CreateCalibrationObject(printer, calibrationWizard); // add the calibration object to the bed scene.Children.Add(item); // move the part to the center of the bed var bedBounds = printer.Settings.BedBounds; var aabb = item.GetAxisAlignedBoundingBox(); item.Matrix *= Matrix4X4.CreateTranslation(bedBounds.Center.X - aabb.MinXYZ.X - aabb.XSize / 2, bedBounds.Center.Y - aabb.MinXYZ.Y - aabb.YSize / 2, -aabb.MinXYZ.Z); // register callbacks for print completion printer.Connection.Disposed += this.Connection_Disposed; printer.Connection.CancelCompleted += this.Connection_PrintCanceled; printer.Connection.CommunicationStateChanged += this.Connection_CommunicationStateChanged; // hide this window this.DialogWindow.Visible = false; string gcodePath = EditContext.GCodeFilePath(printer, scene); printer.Connection.CommunicationState = CommunicationStates.PreparingToPrint; (bool slicingSucceeded, string finalGCodePath) = await ApplicationController.Instance.SliceItemLoadOutput( printer, scene, gcodePath); // Only start print if slicing completed if (slicingSucceeded) { await printer.Bed.LoadContent(new EditContext() { SourceItem = new FileSystemFileItem(gcodePath), ContentStore = null // No content store for GCode }); await printer.Connection.StartPrint(finalGCodePath, printingMode : PrinterConnection.PrintingModes.Calibration); ApplicationController.Instance.MonitorPrintTask(printer); } else { printer.Connection.CommunicationState = CommunicationStates.Connected; } }
public XyCalibrationSelectPage(XyCalibrationWizard calibrationWizard) : base(calibrationWizard) { this.WindowTitle = "Nozzle Offset Calibration Wizard".Localize(); this.HeaderText = "Nozzle Offset Calibration".Localize() + ":"; this.Name = "Nozzle Offset Calibration Wizard"; contentRow.Padding = theme.DefaultContainerPadding; // default to normal offset calibrationWizard.Offset = printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter) / 3.0; contentRow.AddChild(new TextWidget("Choose the calibration you would like to perform.".Localize(), textColor: theme.TextColor, pointSize: theme.DefaultFontSize) { Margin = new Agg.BorderDouble(0, 15, 0, 0) }); contentRow.AddChild(coarseCalibration = new RadioButton("Coarse Calibration: If your printer is way off".Localize(), textColor: theme.TextColor, fontSize: theme.DefaultFontSize) { Checked = calibrationWizard.Quality == QualityType.Coarse }); coarseCalibration.CheckedStateChanged += (s, e) => { calibrationWizard.Quality = QualityType.Coarse; calibrationWizard.Offset = printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter); }; contentRow.AddChild(normalCalibration = new RadioButton("Normal Calibration: Start here".Localize(), textColor: theme.TextColor, fontSize: theme.DefaultFontSize) { Checked = calibrationWizard.Quality == QualityType.Normal }); normalCalibration.CheckedStateChanged += (s, e) => { calibrationWizard.Quality = QualityType.Normal; calibrationWizard.Offset = printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter) / 3.0; }; contentRow.AddChild(fineCalibration = new RadioButton("Fine Calibration: When you want that extra precision".Localize(), textColor: theme.TextColor, fontSize: theme.DefaultFontSize) { Checked = calibrationWizard.Quality == QualityType.Fine }); fineCalibration.CheckedStateChanged += (s, e) => { calibrationWizard.Quality = QualityType.Fine; calibrationWizard.Offset = printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter) / 9.0; }; }
public XyCalibrationCollectDataPage(XyCalibrationWizard calibrationWizard) : base(calibrationWizard) { this.calibrationWizard = calibrationWizard; this.WindowTitle = "Nozzle Offset Calibration Wizard".Localize(); this.HeaderText = "Nozzle Offset Calibration".Localize(); contentRow.Padding = theme.DefaultContainerPadding; contentRow.AddChild( new TextWidget("Remove the calibration part from the bed and compare the sides of the pads in each axis.".Localize(), textColor: theme.TextColor, pointSize: theme.DefaultFontSize) { Margin = new BorderDouble(0, 15, 0, 0) }); contentRow.AddChild( new TextWidget("Pick the pad that is the most aligned with the base, the pad that is the most balance and centered.".Localize(), textColor: theme.TextColor, pointSize: theme.DefaultFontSize) { Margin = new BorderDouble(0, 15, 0, 0) }); // disable the next button until we receive data about both the x and y axis alignment NextButton.Enabled = false; var calibrationRow = new GuiWidget() { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch }; contentRow.AddChild(calibrationRow); calibrationRow.AddChild( new CalibrationTabWidget(calibrationWizard, NextButton, theme) { HAnchor = HAnchor.Center | HAnchor.Absolute, VAnchor = VAnchor.Center | VAnchor.Absolute, Width = 350, Height = 350 }); }
public XyCalibrationSelectPage(XyCalibrationWizard calibrationWizard) : base(calibrationWizard) { this.WindowTitle = "Nozzle Offset Calibration Wizard".Localize(); this.HeaderText = "Calibration Print".Localize(); contentRow.Padding = theme.DefaultContainerPadding; // default to normal offset calibrationWizard.Offset = printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter) / 3.0; contentRow.AddChild( new TextWidget( "This wizard will close to print a calibration part and resume after the print completes.".Localize(), textColor: theme.TextColor, pointSize: theme.DefaultFontSize) { Margin = new BorderDouble(bottom: theme.DefaultContainerPadding) }); contentRow.AddChild( new TextWidget( "Calibration Mode".Localize(), textColor: theme.TextColor, pointSize: theme.DefaultFontSize) { Margin = new BorderDouble(0, theme.DefaultContainerPadding) }); var column = new FlowLayoutWidget(FlowDirection.TopToBottom) { Margin = new BorderDouble(left: theme.DefaultContainerPadding), HAnchor = HAnchor.Stretch, }; contentRow.AddChild(column); var coarseText = calibrationWizard.Quality == QualityType.Coarse ? "Initial (Recommended)".Localize() : "Coarse".Localize(); column.AddChild(coarseCalibration = new RadioButton(coarseText, textColor: theme.TextColor, fontSize: theme.DefaultFontSize) { Checked = calibrationWizard.Quality == QualityType.Coarse }); coarseCalibration.CheckedStateChanged += (s, e) => { calibrationWizard.Quality = QualityType.Coarse; calibrationWizard.Offset = printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter); }; var normalText = calibrationWizard.Quality == QualityType.Normal ? "Normal (Recommended)".Localize() : "Normal".Localize(); column.AddChild(normalCalibration = new RadioButton(normalText, textColor: theme.TextColor, fontSize: theme.DefaultFontSize) { Checked = calibrationWizard.Quality == QualityType.Normal }); normalCalibration.CheckedStateChanged += (s, e) => { calibrationWizard.Quality = QualityType.Normal; calibrationWizard.Offset = printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter) / 3.0; }; column.AddChild(fineCalibration = new RadioButton("Fine".Localize(), textColor: theme.TextColor, fontSize: theme.DefaultFontSize) { Checked = calibrationWizard.Quality == QualityType.Fine }); fineCalibration.CheckedStateChanged += (s, e) => { calibrationWizard.Quality = QualityType.Fine; calibrationWizard.Offset = printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter) / 9.0; }; int tabIndex = 0; if (printer.Settings.GetValue <double>(SettingsKey.layer_height) < printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter) / 2) { // The layer height is very small and it will be hard to see features. Show a warning. AddSettingsRow(contentRow, printer, "The calibration object will printer better if the layer hight is set to a larger value. It is recommended that your increase it.".Localize(), SettingsKey.layer_height, theme, ref tabIndex); } if (printer.Settings.GetValue <bool>(SettingsKey.create_raft)) { // The layer height is very small and it will be hard to see features. Show a warning. AddSettingsRow(contentRow, printer, "A raft is not needed for the calibration object. It is recommended that you turn it off.".Localize(), SettingsKey.create_raft, theme, ref tabIndex); } this.NextButton.Visible = false; // add in the option to tell the system the printer is already calibrated var alreadyCalibratedButton = theme.CreateDialogButton("Already Calibrated".Localize()); alreadyCalibratedButton.Name = "Already Calibrated Button"; alreadyCalibratedButton.Click += (s, e) => { printer.Settings.SetValue(SettingsKey.xy_offsets_have_been_calibrated, "1"); FinishWizard(); }; this.AddPageAction(alreadyCalibratedButton); var startCalibrationPrint = theme.CreateDialogButton("Start Print".Localize()); startCalibrationPrint.Name = "Start Calibration Print"; startCalibrationPrint.Click += async(s, e) => { var preCalibrationPrintViewMode = printer.ViewState.ViewMode; // create the calibration objects IObject3D item = await CreateCalibrationObject(printer, calibrationWizard); var calibrationObjectPrinter = new CalibrationObjectPrinter(printer, item); // hide this window this.DialogWindow.Visible = false; await calibrationObjectPrinter.PrintCalibrationPart(); // Restore the original DialogWindow this.DialogWindow.Visible = true; // Restore to original view mode printer.ViewState.ViewMode = preCalibrationPrintViewMode; this.MoveToNextPage(); }; this.AcceptButton = startCalibrationPrint; this.AddPageAction(startCalibrationPrint); }
private static async Task <IObject3D> CreateCalibrationObject(PrinterConfig printer, XyCalibrationWizard calibrationWizard) { var layerHeight = printer.Settings.GetValue <double>(SettingsKey.layer_height); var firstLayerHeight = printer.Settings.GetValue <double>(SettingsKey.first_layer_height); switch (calibrationWizard.Quality) { case QualityType.Coarse: return(await XyCalibrationTabObject3D.Create( 1, Math.Max(firstLayerHeight * 2, layerHeight * 2), calibrationWizard.Offset, printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter), printer.Settings.GetValue <double>(SettingsKey.wipe_tower_size))); default: return(await XyCalibrationFaceObject3D.Create( 1, firstLayerHeight + layerHeight, layerHeight, calibrationWizard.Offset, printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter), printer.Settings.GetValue <double>(SettingsKey.wipe_tower_size), 4)); } }
public XyCalibrationSelectPage(XyCalibrationWizard calibrationWizard) : base(calibrationWizard) { this.WindowTitle = "Nozzle Offset Calibration Wizard".Localize(); this.HeaderText = "Calibration Print".Localize(); preCalibrationPrintViewMode = printer.ViewState.ViewMode; contentRow.Padding = theme.DefaultContainerPadding; // default to normal offset calibrationWizard.Offset = printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter) / 3.0; contentRow.AddChild( new TextWidget( "This wizard will close to print a calibration part and resume after the print completes.".Localize(), textColor: theme.TextColor, pointSize: theme.DefaultFontSize) { Margin = new BorderDouble(bottom: theme.DefaultContainerPadding) }); contentRow.AddChild( new TextWidget( "Calibration Mode".Localize(), textColor: theme.TextColor, pointSize: theme.DefaultFontSize) { Margin = new BorderDouble(0, theme.DefaultContainerPadding) }); var column = new FlowLayoutWidget(FlowDirection.TopToBottom) { Margin = new BorderDouble(left: theme.DefaultContainerPadding), HAnchor = HAnchor.Stretch, }; contentRow.AddChild(column); var coarseText = calibrationWizard.Quality == QualityType.Coarse ? "Initial (Recommended)".Localize() : "Coarse".Localize(); column.AddChild(coarseCalibration = new RadioButton(coarseText, textColor: theme.TextColor, fontSize: theme.DefaultFontSize) { Checked = calibrationWizard.Quality == QualityType.Coarse }); coarseCalibration.CheckedStateChanged += (s, e) => { calibrationWizard.Quality = QualityType.Coarse; calibrationWizard.Offset = printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter); }; var normalText = calibrationWizard.Quality == QualityType.Normal ? "Normal (Recommended)".Localize() : "Normal".Localize(); column.AddChild(normalCalibration = new RadioButton(normalText, textColor: theme.TextColor, fontSize: theme.DefaultFontSize) { Checked = calibrationWizard.Quality == QualityType.Normal }); normalCalibration.CheckedStateChanged += (s, e) => { calibrationWizard.Quality = QualityType.Normal; calibrationWizard.Offset = printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter) / 3.0; }; column.AddChild(fineCalibration = new RadioButton("Fine".Localize(), textColor: theme.TextColor, fontSize: theme.DefaultFontSize) { Checked = calibrationWizard.Quality == QualityType.Fine }); fineCalibration.CheckedStateChanged += (s, e) => { calibrationWizard.Quality = QualityType.Fine; calibrationWizard.Offset = printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter) / 9.0; }; this.NextButton.Visible = false; // add in the option to tell the system the printer is already calibrated var alreadyCalibratedButton = theme.CreateDialogButton("Already Calibrated".Localize()); alreadyCalibratedButton.Name = "Already Calibrated Button"; alreadyCalibratedButton.Click += (s, e) => { printer.Settings.SetValue(SettingsKey.xy_offsets_have_been_calibrated, "1"); this.FinishWizard(); }; this.AddPageAction(alreadyCalibratedButton); var startCalibrationPrint = theme.CreateDialogButton("Start Print".Localize()); startCalibrationPrint.Name = "Start Calibration Print"; startCalibrationPrint.Click += async(s, e) => { await PrintCalibrationPart(calibrationWizard); }; this.AcceptButton = startCalibrationPrint; this.AddPageAction(startCalibrationPrint); }
public CalibrationTabWidget(XyCalibrationWizard calibrationWizard, TextButton nextButton, ThemeConfig theme) { this.calibrationWizard = calibrationWizard; this.theme = theme; this.NextButton = nextButton; tabBaseColor = new Color(theme.SlightShade.ToColorF(), theme.SlightShade.Alpha0To1 * 1.2); double barWidth = 30; double barHeight = 300; double left = LocalBounds.Left + 15; double bottom = LocalBounds.Bottom + 15; double right = left + barHeight; var a = new Vector2(left, bottom); var b = new Vector2(left, bottom + barHeight); var c = new Vector2(left + barWidth, bottom + barHeight); var d = new Vector2(left + barWidth, bottom + barWidth); var e = new Vector2(right, bottom + barWidth); var f = new Vector2(right + (barWidth * .7), bottom + (barWidth / 2)); var g = new Vector2(right, bottom); var m = new Vector2(b.X + (barWidth / 2), b.Y + (barWidth * .6)); var n = new Vector2(m.X, b.Y); var r = new Vector2(b.X, m.Y); var tabShape2 = new VertexStorage(); tabShape2.Add(a.X, a.Y, FlagsAndCommand.MoveTo); // A tabShape2.LineTo(b); // A - B tabShape2.curve3(r.X, r.Y, m.X, m.Y); // B -> C tabShape2.curve3(c.X, c.Y); tabShape2.LineTo(d); // C -> D tabShape2.LineTo(e); // D -> E tabShape2.LineTo(f); // E -> F tabShape2.LineTo(g); // F -> G tabShape2.ClosePolygon(); int highlightStroke = 2; int highlightOffset = 8; int highlightWidth = 16; double x1 = d.X + highlightOffset; double x2 = x1 + highlightWidth; double y1 = d.Y + highlightOffset; double y2 = c.Y - highlightOffset; double midY = y1 + (y2 - y1) / 2; var highlighter = new VertexStorage(); highlighter.MoveTo(x1, y1); highlighter.LineTo(x2, y1); highlighter.LineTo(x2, midY); highlighter.LineTo(x2 + highlightOffset, midY); highlighter.LineTo(x2, midY); highlighter.LineTo(x2, y2); highlighter.LineTo(x1, y2); xHighlighter = new Stroke(highlighter, highlightStroke); xLabel = new TextWidget("Select the most centered pad", pointSize: theme.DefaultFontSize, textColor: theme.TextColor) { HAnchor = HAnchor.Absolute, VAnchor = VAnchor.Absolute }; xLabel.Position = new Vector2(x2 + highlightOffset * 2, midY - xLabel.Height / 2); this.AddChild(xLabel); x1 = d.X + highlightOffset; y1 = d.Y + 50; x1 = d.X + highlightOffset; x2 = e.X - highlightOffset; y1 = d.Y + highlightOffset; y2 = y1 + highlightWidth; double midX = x1 + (x2 - x1) / 2; highlighter = new VertexStorage(); highlighter.MoveTo(x1, y1); highlighter.LineTo(x1, y2); highlighter.LineTo(midX, y2); highlighter.LineTo(midX, y2 + highlightOffset); highlighter.LineTo(midX, y2); highlighter.LineTo(x2, y2); highlighter.LineTo(x2, y1); yHighlighter = new Stroke(highlighter, highlightStroke); yLabel = new TextWidget("Select the most centered pad", pointSize: theme.DefaultFontSize, textColor: theme.TextColor) { HAnchor = HAnchor.Absolute, VAnchor = VAnchor.Absolute, Visible = false, }; this.AddChild(yLabel); yLabel.Position = new Vector2(midX - yLabel.Width / 2, y2 + (highlightOffset * 2)); yHighlighter = new Stroke(highlighter, highlightStroke); int padCount = 7; double cellSize = (barHeight - barWidth) / padCount; int padding = (int)(cellSize * .3); double padSize = cellSize - padding; var titles = new[] { "-3", "-2", "-1", "0", "+1", "+2", "+3" }; for (var i = 0; i < padCount; i++) { this.AddChild(new CalibrationPad(titles[i], theme, pointSize: theme.DefaultFontSize - 1) { Position = new Vector2(left, bottom + 3 + barWidth + (cellSize * i)), Height = padSize, Width = barWidth, Index = i, IsActive = i == 3, Axis = PrinterConnection.Axis.X }); this.AddChild(new CalibrationPad(titles[i], theme, pointSize: theme.DefaultFontSize - 1) { Position = new Vector2(left + 3 + barWidth + (cellSize * i), bottom), Height = barWidth, Width = padSize, Index = i, IsActive = i == 3, Axis = PrinterConnection.Axis.Y }); } foreach (var calibrationPad in this.Children.OfType <CalibrationPad>()) { calibrationPad.Click += this.CalibrationPad_Click; calibrationPad.Hovered += this.CalibrationPad_Hovered; } tabShape = new FlattenCurves(tabShape2); tabStroke = new Stroke(tabShape); }
public XyCalibrationSelectPage(XyCalibrationWizard calibrationWizard) : base(calibrationWizard) { this.WindowTitle = "Nozzle Offset Calibration Wizard".Localize(); this.HeaderText = "Calibration Print".Localize(); preCalibrationPrintViewMode = printer.ViewState.ViewMode; contentRow.Padding = theme.DefaultContainerPadding; // default to normal offset calibrationWizard.Offset = printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter) / 3.0; contentRow.AddChild( new TextWidget( "This wizard will close to print a calibration part and resume after the print completes.".Localize(), textColor: theme.TextColor, pointSize: theme.DefaultFontSize) { Margin = new BorderDouble(bottom: theme.DefaultContainerPadding) }); contentRow.AddChild( new TextWidget( "Calibration Mode".Localize(), textColor: theme.TextColor, pointSize: theme.DefaultFontSize) { Margin = new BorderDouble(0, theme.DefaultContainerPadding) }); var column = new FlowLayoutWidget(FlowDirection.TopToBottom) { Margin = new BorderDouble(left: theme.DefaultContainerPadding), HAnchor = HAnchor.Stretch, }; contentRow.AddChild(column); var coarseText = calibrationWizard.Quality == QualityType.Coarse ? "Initial (Recommended)".Localize() : "Coarse".Localize(); column.AddChild(coarseCalibration = new RadioButton(coarseText, textColor: theme.TextColor, fontSize: theme.DefaultFontSize) { Checked = calibrationWizard.Quality == QualityType.Coarse }); coarseCalibration.CheckedStateChanged += (s, e) => { calibrationWizard.Quality = QualityType.Coarse; calibrationWizard.Offset = printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter); }; var normalText = calibrationWizard.Quality == QualityType.Normal ? "Normal (Recommended)".Localize() : "Normal".Localize(); column.AddChild(normalCalibration = new RadioButton(normalText, textColor: theme.TextColor, fontSize: theme.DefaultFontSize) { Checked = calibrationWizard.Quality == QualityType.Normal }); normalCalibration.CheckedStateChanged += (s, e) => { calibrationWizard.Quality = QualityType.Normal; calibrationWizard.Offset = printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter) / 3.0; }; column.AddChild(fineCalibration = new RadioButton("Fine".Localize(), textColor: theme.TextColor, fontSize: theme.DefaultFontSize) { Checked = calibrationWizard.Quality == QualityType.Fine }); fineCalibration.CheckedStateChanged += (s, e) => { calibrationWizard.Quality = QualityType.Fine; calibrationWizard.Offset = printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter) / 9.0; }; var settingsContext = new SettingsContext(printer, null, NamedSettingsLayers.All); int tabIndex = 0; var allUiFields = new Dictionary <string, UIField>(); var settingAdded = false; void AddSettingsRow(string warning, string key) { if (!settingAdded) { contentRow.AddChild( new TextWidget( "Recommended Settings Changes".Localize() + ":", textColor: theme.TextColor, pointSize: theme.DefaultFontSize) { Margin = new BorderDouble(10, 0, 0, 20) }); settingAdded = true; } contentRow.AddChild( new WrappedTextWidget( warning, textColor: theme.TextColor, pointSize: theme.DefaultFontSize) { Margin = new BorderDouble(0, 10, 0, 20) }); var settingsData = PrinterSettings.SettingsData[key]; var row = SliceSettingsTabView.CreateItemRow(settingsData, settingsContext, printer, theme, ref tabIndex, allUiFields); if (row is SliceSettingsRow settingsRow) { settingsRow.ArrowDirection = ArrowDirection.Left; } contentRow.AddChild(row); } if (printer.Settings.GetValue <double>(SettingsKey.layer_height) < printer.Settings.GetValue <double>(SettingsKey.nozzle_diameter) / 2) { // The layer height is very small and it will be hard to see features. Show a warning. AddSettingsRow("The calibration object will printer better if the layer hight is set to a larger value. It is recommended that your increase it.".Localize(), SettingsKey.layer_height); } if (printer.Settings.GetValue <bool>(SettingsKey.create_raft)) { // The layer height is very small and it will be hard to see features. Show a warning. AddSettingsRow("A raft is not needed for the calibration object. It is recommended that you turn it off.".Localize(), SettingsKey.create_raft); } this.NextButton.Visible = false; // add in the option to tell the system the printer is already calibrated var alreadyCalibratedButton = theme.CreateDialogButton("Already Calibrated".Localize()); alreadyCalibratedButton.Name = "Already Calibrated Button"; alreadyCalibratedButton.Click += (s, e) => { printer.Settings.SetValue(SettingsKey.xy_offsets_have_been_calibrated, "1"); this.FinishWizard(); }; this.AddPageAction(alreadyCalibratedButton); var startCalibrationPrint = theme.CreateDialogButton("Start Print".Localize()); startCalibrationPrint.Name = "Start Calibration Print"; startCalibrationPrint.Click += async(s, e) => { await PrintCalibrationPart(calibrationWizard); }; this.AcceptButton = startCalibrationPrint; this.AddPageAction(startCalibrationPrint); }
public XyCalibrationCollectDataPage(XyCalibrationWizard calibrationWizard) : base(calibrationWizard) { this.calibrationWizard = calibrationWizard; this.WindowTitle = "Nozzle Offset Calibration Wizard".Localize(); this.HeaderText = "Nozzle Offset Calibration".Localize() + ":"; this.Name = "Nozzle Offset Calibration Wizard"; contentRow.Padding = theme.DefaultContainerPadding; contentRow.AddChild(new TextWidget("Pick the most balanced result for each axis.".Localize(), textColor: theme.TextColor, pointSize: theme.DefaultFontSize) { Margin = new Agg.BorderDouble(0, 15, 0, 0) }); // disable the next button until we receive data about both the x and y axis alignment NextButton.Enabled = false; var xButtonsGroup = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Fit | HAnchor.Left }; contentRow.AddChild(xButtonsGroup); xButtons = new List <RadioButton>(); xButtons.Add(new RadioButton("-3".Localize(), textColor: theme.TextColor, fontSize: theme.DefaultFontSize)); xButtons.Add(new RadioButton("-2".Localize(), textColor: theme.TextColor, fontSize: theme.DefaultFontSize)); xButtons.Add(new RadioButton("-1".Localize(), textColor: theme.TextColor, fontSize: theme.DefaultFontSize)); xButtons.Add(new RadioButton(" 0".Localize(), textColor: theme.TextColor, fontSize: theme.DefaultFontSize)); xButtons.Add(new RadioButton("+1".Localize(), textColor: theme.TextColor, fontSize: theme.DefaultFontSize)); xButtons.Add(new RadioButton("+2".Localize(), textColor: theme.TextColor, fontSize: theme.DefaultFontSize)); xButtons.Add(new RadioButton("+3".Localize(), textColor: theme.TextColor, fontSize: theme.DefaultFontSize)); foreach (var button in xButtons) { xButtonsGroup.AddChild(button); button.CheckedStateChanged += XButton_CheckedStateChanged; } var yButtonsGroup = new FlowLayoutWidget() { HAnchor = HAnchor.Fit | HAnchor.Left }; contentRow.AddChild(yButtonsGroup); yButtonsGroup.AddChild(new GuiWidget(24 * GuiWidget.DeviceScale, 16)); yButtons = new List <RadioButton>(); yButtons.Add(new RadioButton("-3".Localize(), textColor: theme.TextColor, fontSize: theme.DefaultFontSize)); yButtons.Add(new RadioButton("-2".Localize(), textColor: theme.TextColor, fontSize: theme.DefaultFontSize)); yButtons.Add(new RadioButton("-1".Localize(), textColor: theme.TextColor, fontSize: theme.DefaultFontSize)); yButtons.Add(new RadioButton(" 0".Localize(), textColor: theme.TextColor, fontSize: theme.DefaultFontSize)); yButtons.Add(new RadioButton("+1".Localize(), textColor: theme.TextColor, fontSize: theme.DefaultFontSize)); yButtons.Add(new RadioButton("+2".Localize(), textColor: theme.TextColor, fontSize: theme.DefaultFontSize)); yButtons.Add(new RadioButton("+3".Localize(), textColor: theme.TextColor, fontSize: theme.DefaultFontSize)); foreach (var button in yButtons) { var column = new FlowLayoutWidget(FlowDirection.TopToBottom); yButtonsGroup.AddChild(column); button.HAnchor = HAnchor.Center; column.AddChild(button); column.AddChild(new TextWidget(button.Text, textColor: theme.TextColor, pointSize: theme.DefaultFontSize) { HAnchor = HAnchor.Left }); button.Text = ""; button.CheckedStateChanged += YButton_CheckedStateChanged; } }
public XyCalibrationDataRecieved(XyCalibrationWizard calibrationWizard) : base(calibrationWizard) { this.WindowTitle = "Nozzle Offset Calibration Wizard".Localize(); this.HeaderText = "Nozzle Offset Calibration".Localize() + ":"; this.Name = "Nozzle Offset Calibration Wizard"; contentRow.Padding = theme.DefaultContainerPadding; calibrationWizard.PrintAgain = false; // check if we picked an outside of the calibration if (calibrationWizard.XPick == 0 || calibrationWizard.XPick == 6 || calibrationWizard.YPick == 0 || calibrationWizard.YPick == 6) { // offer to re-run the calibration with the same settings as last time contentRow.AddChild(new TextWidget("Your printer has been adjusted but we need to run calibrating again to improve accuracy.".Localize(), textColor: theme.TextColor, pointSize: theme.DefaultFontSize) { Margin = new Agg.BorderDouble(0, 15, 0, 0) }); calibrationWizard.PrintAgain = true; } else { switch (calibrationWizard.Quality) { case QualityType.Coarse: // if we are on coarse calibration offer to move down to normal contentRow.AddChild(new TextWidget("Coarse calibration complete, we will now do a normal calibration to improve accuracy.".Localize(), textColor: theme.TextColor, pointSize: theme.DefaultFontSize) { Margin = new Agg.BorderDouble(0, 15, 0, 0) }); // switch to normal calibration calibrationWizard.Quality = QualityType.Normal; calibrationWizard.PrintAgain = true; break; case QualityType.Normal: // let the user know they are done with calibration, but if they would like they can print a fine calibration for even better results // add a button to request fine calibration var normalMessage = "Your nozzles should now be calibrated.".Localize(); normalMessage += "\n\n" + "You can continue to ultra fine calibration, but for most uses this is not necessary.".Localize(); contentRow.AddChild(new TextWidget(normalMessage, textColor: theme.TextColor, pointSize: theme.DefaultFontSize) { Margin = new Agg.BorderDouble(0, 15, 0, 0) }); var startFineCalibratingButton = theme.CreateDialogButton("Print Ultra Fine Calibration".Localize()); startFineCalibratingButton.HAnchor = HAnchor.Fit | HAnchor.Right; startFineCalibratingButton.VAnchor = VAnchor.Absolute; startFineCalibratingButton.Name = "Fine Calibration Print"; startFineCalibratingButton.Click += (s, e) => { // switch to fine calibrationWizard.Quality = QualityType.Fine; // start up at the print window calibrationWizard.PrintAgain = true; this.NextButton.InvokeClick(); }; contentRow.AddChild(startFineCalibratingButton); break; case QualityType.Fine: // done! contentRow.AddChild(new TextWidget("Offset Calibration complete.".Localize(), textColor: theme.TextColor, pointSize: theme.DefaultFontSize) { Margin = new Agg.BorderDouble(0, 15, 0, 0) }); break; } } if (!calibrationWizard.PrintAgain) { // this is the last page of the wizard hide the next button this.NextButton.Visible = false; var doneButton = theme.CreateDialogButton("Done".Localize()); doneButton.Name = "Done Calibration Print"; theme.ApplyPrimaryActionStyle(doneButton); this.AddPageAction(doneButton); doneButton.Click += (s, e) => { printer.Settings.SetValue(SettingsKey.xy_offsets_have_been_calibrated, "1"); // close this wizard this.DialogWindow.ClosePage(); }; } }
public XyCalibrationStartPrintPage(XyCalibrationWizard calibrationWizard) : base(calibrationWizard) { this.WindowTitle = "Nozzle Offset Calibration Wizard".Localize(); this.HeaderText = "Nozzle Offset Calibration".Localize(); this.Name = "Nozzle Offset Calibration Wizard"; var content = "Here is what we are going to do:".Localize(); content += "\n\n • " + "Stash your current bed".Localize(); content += "\n • " + "Print the calibration object".Localize(); content += "\n • " + "Collect data".Localize(); content += "\n • " + "Restore your current bed, after all calibration is complete".Localize(); contentRow.AddChild(this.CreateTextField(content)); contentRow.Padding = theme.DefaultContainerPadding; this.NextButton.Visible = false; var startCalibrationPrint = theme.CreateDialogButton("Start Print".Localize()); startCalibrationPrint.Name = "Start Calibration Print"; startCalibrationPrint.Click += async(s, e) => { var scene = new Object3D(); // create the calibration objects IObject3D item = await CreateCalibrationObject(printer, calibrationWizard); // add the calibration object to the bed scene.Children.Add(item); // move the part to the center of the bed var bedBounds = printer.Bed.Bounds; var aabb = item.GetAxisAlignedBoundingBox(); item.Matrix *= Matrix4X4.CreateTranslation(bedBounds.Center.X - aabb.MinXYZ.X - aabb.XSize / 2, bedBounds.Center.Y - aabb.MinXYZ.Y - aabb.YSize / 2, -aabb.MinXYZ.Z); // register callbacks for print completion printer.Connection.Disposed += this.Connection_Disposed; printer.Connection.PrintCanceled += this.Connection_PrintCanceled; printer.Connection.CommunicationStateChanged += this.Connection_CommunicationStateChanged; this.MoveToNextPage(); // hide this window this.DialogWindow.Visible = false; string gcodePath = EditContext.GCodeFilePath(printer, scene); printer.Connection.CommunicationState = CommunicationStates.PreparingToPrint; (bool slicingSucceeded, string finalGCodePath) = await ApplicationController.Instance.SliceItemLoadOutput( printer, scene, gcodePath); // Only start print if slicing completed if (slicingSucceeded) { await printer.Bed.LoadContent(new EditContext() { SourceItem = new FileSystemFileItem(gcodePath), ContentStore = null // No content store for GCode }); await printer.Connection.StartPrint(finalGCodePath, allowRecovery : false); ApplicationController.Instance.MonitorPrintTask(printer); } else { printer.Connection.CommunicationState = CommunicationStates.Connected; } }; theme.ApplyPrimaryActionStyle(startCalibrationPrint); this.AddPageAction(startCalibrationPrint); }