diff --git a/ConfigurationPage/ConfigurationPage.cs b/ConfigurationPage/ConfigurationPage.cs index 6734ae920..9a55b7ef0 100644 --- a/ConfigurationPage/ConfigurationPage.cs +++ b/ConfigurationPage/ConfigurationPage.cs @@ -286,9 +286,7 @@ namespace MatterHackers.MatterControl Slider feedRateRatioSlider; Slider extrusionRatioSlider; NumberEdit extrusionValue; - PrintLevelWizardWindow printLevelWizardWindow; - - + PrintLevelWizardWindow printLevelWizardWindow; public override void OnClosed(EventArgs e) { @@ -299,10 +297,8 @@ namespace MatterHackers.MatterControl base.OnClosed(e); } - TextWidget printLevelingStatusLabel; - private void AddPrintLevelingControls(FlowLayoutWidget controlsTopToBottomLayout) { printLevelContainer = new DisableableWidget(); @@ -310,10 +306,23 @@ namespace MatterHackers.MatterControl controlsTopToBottomLayout.AddChild(printLevelContainer); } + EditLevelingSettingsWindow editLevelingSettingsWindow; private GuiWidget CreatePrintLevelingControlsContainer() { - GroupBox printLevelingControlsContainer; - printLevelingControlsContainer = new GroupBox(LocalizedString.Get("Automatic Calibration")); + Button editButton; + GroupBox printLevelingControlsContainer = new GroupBox(textImageButtonFactory.GenerateGroupBoxLableWithEdit(LocalizedString.Get("Automatic Calibration"), out editButton)); + editButton.Click += (sender, e) => + { + if (editLevelingSettingsWindow == null) + { + editLevelingSettingsWindow = new EditLevelingSettingsWindow(); + editLevelingSettingsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { editLevelingSettingsWindow = null; }; + } + else + { + editLevelingSettingsWindow.BringToFront(); + } + }; printLevelingControlsContainer.Margin = new BorderDouble(0); printLevelingControlsContainer.TextColor = ActiveTheme.Instance.PrimaryTextColor; @@ -444,7 +453,7 @@ namespace MatterHackers.MatterControl case PrinterCommunication.CommunicationStates.AttemptingToConnect: case PrinterCommunication.CommunicationStates.FailedToConnect: eePromControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled); - printLevelContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled); + printLevelContainer.SetEnableLevel(DisableableWidget.EnableLevel.ConfigOnly); break; case PrinterCommunication.CommunicationStates.FinishedPrint: diff --git a/ConfigurationPage/PrintLevelWizard.cs b/ConfigurationPage/PrintLevelWizard.cs index 39e5f1f1f..b7f1c772e 100644 --- a/ConfigurationPage/PrintLevelWizard.cs +++ b/ConfigurationPage/PrintLevelWizard.cs @@ -109,7 +109,7 @@ namespace MatterHackers.MatterControl probePositions[1].position.x, probePositions[1].position.y, probePositions[1].position.z, probePositions[2].position.x, probePositions[2].position.y, probePositions[2].position.z, }; - ActivePrinterProfile.Instance.SetPrintLevelingProbePositions(printLevelPositions3x3); + ActivePrinterProfile.Instance.SetPrintLevelingMeasuredPositions(printLevelPositions3x3); ActivePrinterProfile.Instance.DoPrintLeveling = true; base.PageIsBecomingActive(); @@ -341,7 +341,7 @@ namespace MatterHackers.MatterControl printLevelWizard.AddPage(new FirstPageInstructions(pageOneInstructions)); printLevelWizard.AddPage(new HomePrinterPage(homingPageInstructions)); - Vector2 probeBackCenter = ActiveSliceSettings.Instance.GetPrintLevelSamplePosition(0); + Vector2 probeBackCenter = ActiveSliceSettings.Instance.GetPrintLevelPositionToSample(0); string lowPrecisionPositionLbl = LocalizedString.Get ("Position"); string lowPrecisionLbl = LocalizedString.Get ("Low Precision"); @@ -357,7 +357,7 @@ namespace MatterHackers.MatterControl string highPrecisionLbl = LocalizedString.Get("High Precision"); printLevelWizard.AddPage(new GetUltraFineBedHeight(string.Format("{0} {1} 1 - {2}", Step(), precisionPositionLbl, highPrecisionLbl), probePositions[0])); - Vector2 probeFrontLeft = ActiveSliceSettings.Instance.GetPrintLevelSamplePosition(1); + Vector2 probeFrontLeft = ActiveSliceSettings.Instance.GetPrintLevelPositionToSample(1); string positionLblTwo = LocalizedString.Get("Position"); string lowPrecisionTwoLbl = LocalizedString.Get("Low Precision"); string medPrecisionTwoLbl = LocalizedString.Get("Medium Precision"); @@ -366,7 +366,7 @@ namespace MatterHackers.MatterControl printLevelWizard.AddPage(new GetFineBedHeight(string.Format("{0} {1} 2 - {2}", Step(), positionLblTwo,medPrecisionTwoLbl), probePositions[1])); printLevelWizard.AddPage(new GetUltraFineBedHeight(string.Format("{0} {1} 2 - {2}", Step(), positionLblTwo,highPrecisionTwoLbl), probePositions[1])); - Vector2 probeFrontRight = ActiveSliceSettings.Instance.GetPrintLevelSamplePosition(2); + Vector2 probeFrontRight = ActiveSliceSettings.Instance.GetPrintLevelPositionToSample(2); string positionLabelThree = LocalizedString.Get("Position"); string lowPrecisionLblThree = LocalizedString.Get("Low Precision"); string medPrecisionLblThree = LocalizedString.Get("Medium Precision"); diff --git a/DataStorage/Models.cs b/DataStorage/Models.cs index 66bc89134..52d3550ca 100644 --- a/DataStorage/Models.cs +++ b/DataStorage/Models.cs @@ -383,7 +383,7 @@ namespace MatterHackers.MatterControl.DataStorage /// Gets the 9 {3 * (x, y, z)} positions that were probed during the print leveling setup. /// /// - public double[] GetPrintLevelingPositions() + public double[] GetPrintLevelingMeasuredPositions() { double[] positions = new double[9]; @@ -402,7 +402,7 @@ namespace MatterHackers.MatterControl.DataStorage return positions; } - public void SetPrintLevelingPositions(double[] printLevelingPositions3_xyz) + public void SetPrintLevelingMeasuredPositions(double[] printLevelingPositions3_xyz) { StringBuilder allValues = new StringBuilder(); bool first = true; diff --git a/MatterControl.csproj b/MatterControl.csproj index 4268c2ddf..e04c0367c 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -83,6 +83,7 @@ + diff --git a/PrinterCommunication/ActivePrinterProfile.cs b/PrinterCommunication/ActivePrinterProfile.cs index 4739056a9..62717877e 100644 --- a/PrinterCommunication/ActivePrinterProfile.cs +++ b/PrinterCommunication/ActivePrinterProfile.cs @@ -171,9 +171,9 @@ namespace MatterHackers.MatterControl if (DoPrintLeveling) { PrintLeveling.Instance.SetPrintLevelingEquation( - GetPrintLevelingProbePosition(0), - GetPrintLevelingProbePosition(1), - GetPrintLevelingProbePosition(2), + GetPrintLevelingMeasuredPosition(0), + GetPrintLevelingMeasuredPosition(1), + GetPrintLevelingMeasuredPosition(2), ActiveSliceSettings.Instance.PrintCenter); } } @@ -181,16 +181,15 @@ namespace MatterHackers.MatterControl } /// - /// This function returns one of the three positions that will be probed when setting - /// up print leveling. + /// This function returns one of the three positions as it was actually measured /// /// /// - public Vector3 GetPrintLevelingProbePosition(int position0To2) + public Vector3 GetPrintLevelingMeasuredPosition(int position0To2) { if (ActivePrinter != null) { - double[] positions = ActivePrinter.GetPrintLevelingPositions(); + double[] positions = ActivePrinter.GetPrintLevelingMeasuredPositions(); switch (position0To2) { case 0: @@ -207,11 +206,11 @@ namespace MatterHackers.MatterControl return Vector3.Zero; } - public void SetPrintLevelingProbePositions(double[] printLevelingPositions3_xyz) + public void SetPrintLevelingMeasuredPositions(double[] printLevelingPositions3_xyz) { if (ActivePrinter != null) { - ActivePrinter.SetPrintLevelingPositions(printLevelingPositions3_xyz); + ActivePrinter.SetPrintLevelingMeasuredPositions(printLevelingPositions3_xyz); ActivePrinter.Commit(); } } diff --git a/PrinterControls/EditLevelingSettingsWindow.cs b/PrinterControls/EditLevelingSettingsWindow.cs new file mode 100644 index 000000000..597b7ad05 --- /dev/null +++ b/PrinterControls/EditLevelingSettingsWindow.cs @@ -0,0 +1,238 @@ +/* +Copyright (c) 2014, Kevin Pope +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.Collections.Generic; +using System.Linq; +using System.IO; +using System.Text; + +using MatterHackers.Agg; +using MatterHackers.Agg.UI; +using MatterHackers.VectorMath; +using MatterHackers.Agg.Image; +using MatterHackers.MatterControl.DataStorage; +using MatterHackers.Localizations; +using MatterHackers.MatterControl.SlicerConfiguration; + +namespace MatterHackers.MatterControl +{ + public class EditLevelingSettingsWindow : SystemWindow + { + protected TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory(); + EventHandler functionToCallOnSave; + List listWithValues = new List(); + + public EditLevelingSettingsWindow() + : base(320, 360) + { + Title = LocalizedString.Get("Leveling Settings".Localize()); + + FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); + topToBottom.AnchorAll(); + topToBottom.Padding = new BorderDouble(3, 0, 3, 5); + + FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight); + headerRow.HAnchor = HAnchor.ParentLeftRight; + headerRow.Margin = new BorderDouble(0, 3, 0, 0); + headerRow.Padding = new BorderDouble(0, 3, 0, 3); + + { + string movementSpeedsLbl = LocalizedString.Get("Sampled Positions".Localize()); + TextWidget elementHeader = new TextWidget(string.Format("{0}:", movementSpeedsLbl), pointSize: 14); + elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; + elementHeader.HAnchor = HAnchor.ParentLeftRight; + elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom; + + headerRow.AddChild(elementHeader); + } + + topToBottom.AddChild(headerRow); + + FlowLayoutWidget presetsFormContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); + //ListBox printerListContainer = new ListBox(); + { + presetsFormContainer.HAnchor = HAnchor.ParentLeftRight; + presetsFormContainer.VAnchor = VAnchor.ParentBottomTop; + presetsFormContainer.Padding = new BorderDouble(3); + presetsFormContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; + } + + topToBottom.AddChild(presetsFormContainer); + + BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; + + int oldHeight = textImageButtonFactory.FixedHeight; + textImageButtonFactory.FixedHeight = 30; + + TextWidget tempTypeLabel = new TextWidget(Title, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10); + tempTypeLabel.Margin = new BorderDouble(3); + tempTypeLabel.HAnchor = HAnchor.ParentLeft; + presetsFormContainer.AddChild(tempTypeLabel); + + FlowLayoutWidget leftRightLabels = new FlowLayoutWidget(); + leftRightLabels.Padding = new BorderDouble(3, 6); + leftRightLabels.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; + + GuiWidget hLabelSpacer = new GuiWidget(); + hLabelSpacer.HAnchor = HAnchor.ParentLeftRight; + + GuiWidget tempLabelContainer = new GuiWidget(); + tempLabelContainer.Width = 76; + tempLabelContainer.Height = 16; + tempLabelContainer.Margin = new BorderDouble(3, 0); + + TextWidget tempLabel = new TextWidget(string.Format("mm / minute"), textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10); + tempLabel.HAnchor = HAnchor.ParentLeft; + tempLabel.VAnchor = VAnchor.ParentCenter; + + tempLabelContainer.AddChild(tempLabel); + + leftRightLabels.AddChild(hLabelSpacer); + leftRightLabels.AddChild(tempLabelContainer); + + presetsFormContainer.AddChild(leftRightLabels); + + // put in the movement edit controls + Vector2 probeBackCenter = ActiveSliceSettings.Instance.GetPrintLevelPositionToSample(0); + + Vector3 position0 = ActivePrinterProfile.Instance.GetPrintLevelingMeasuredPosition(0); + Vector3 position1 = ActivePrinterProfile.Instance.GetPrintLevelingMeasuredPosition(1); + Vector3 position2 = ActivePrinterProfile.Instance.GetPrintLevelingMeasuredPosition(2); + + + string[] settingsArray = "{0},{1},{2},{3},{4},{5},{6},{7},{8}".FormatWith( + position0.x, position0.y, position0.z, + position1.x, position0.y, position1.z, + position2.x, position0.y, position2.z).Split(','); + int preset_count = 1; + int tab_index = 0; + for (int i = 0; i < settingsArray.Count() - 1; i += 2) + { + FlowLayoutWidget leftRightEdit = new FlowLayoutWidget(); + leftRightEdit.Padding = new BorderDouble(3); + leftRightEdit.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; + TextWidget axisLabel; + if (settingsArray[i].StartsWith("e")) + { + int extruderIndex = (int)double.Parse(settingsArray[i].Substring(1)) + 1; + string extruderLableTxt = LocalizedString.Get("Extruder"); + axisLabel = new TextWidget(string.Format("{0} {1}", extruderLableTxt, extruderIndex), textColor: ActiveTheme.Instance.PrimaryTextColor); + } + else + { + string axisLableText = LocalizedString.Get("Axis"); + axisLabel = new TextWidget(string.Format("{0} {1}", axisLableText, settingsArray[i]), textColor: ActiveTheme.Instance.PrimaryTextColor); + } + axisLabel.VAnchor = VAnchor.ParentCenter; + leftRightEdit.AddChild(axisLabel); + + GuiWidget hSpacer = new GuiWidget(); + hSpacer.HAnchor = HAnchor.ParentLeftRight; + + leftRightEdit.AddChild(hSpacer); + + // we add this to the listWithValues to make sure we build the string correctly on save. + TextWidget typeEdit = new TextWidget(settingsArray[i]); + listWithValues.Add(typeEdit); + + double movementSpeed = 0; + double.TryParse(settingsArray[i + 1], out movementSpeed); + MHNumberEdit valueEdit = new MHNumberEdit(movementSpeed, allowNegatives:true, allowDecimals: true, minValue: 0, pixelWidth: 60, tabIndex: tab_index++); + valueEdit.Margin = new BorderDouble(3); + leftRightEdit.AddChild(valueEdit); + listWithValues.Add(valueEdit); + + //leftRightEdit.AddChild(textImageButtonFactory.Generate("Delete")); + presetsFormContainer.AddChild(leftRightEdit); + preset_count += 1; + } + + textImageButtonFactory.FixedHeight = oldHeight; + + ShowAsSystemWindow(); + + Button savePresetsButton = textImageButtonFactory.Generate(LocalizedString.Get("Save")); + savePresetsButton.Click += new ButtonBase.ButtonEventHandler(save_Click); + + Button cancelPresetsButton = textImageButtonFactory.Generate(LocalizedString.Get("Cancel")); + cancelPresetsButton.Click += (sender, e) => + { + UiThread.RunOnIdle((state) => + { + Close(); + }); + }; + + FlowLayoutWidget buttonRow = new FlowLayoutWidget(); + buttonRow.HAnchor = HAnchor.ParentLeftRight; + buttonRow.Padding = new BorderDouble(0, 3); + + GuiWidget hButtonSpacer = new GuiWidget(); + hButtonSpacer.HAnchor = HAnchor.ParentLeftRight; + + buttonRow.AddChild(savePresetsButton); + buttonRow.AddChild(hButtonSpacer); + buttonRow.AddChild(cancelPresetsButton); + + topToBottom.AddChild(buttonRow); + + AddChild(topToBottom); + } + + void save_Click(object sender, MouseEventArgs mouseEvent) + { + UiThread.RunOnIdle(DoSave_Click); + } + + void DoSave_Click(object state) + { + PrintLeveling.Instance.SetPrintLevelingEquation( + ActivePrinterProfile.Instance.GetPrintLevelingMeasuredPosition(0), + ActivePrinterProfile.Instance.GetPrintLevelingMeasuredPosition(1), + ActivePrinterProfile.Instance.GetPrintLevelingMeasuredPosition(2), + ActiveSliceSettings.Instance.PrintCenter); + + bool first = true; + StringBuilder settingString = new StringBuilder(); + foreach (GuiWidget valueToAdd in listWithValues) + { + if (!first) + { + settingString.Append(","); + } + + settingString.Append(valueToAdd.Text); + first = false; + } + functionToCallOnSave(this, new StringEventArgs(settingString.ToString())); + Close(); + } + } +} \ No newline at end of file diff --git a/PrinterControls/EditManualMovementSpeedsWindow.cs b/PrinterControls/EditManualMovementSpeedsWindow.cs index 8e7ed4004..64afad83a 100644 --- a/PrinterControls/EditManualMovementSpeedsWindow.cs +++ b/PrinterControls/EditManualMovementSpeedsWindow.cs @@ -63,7 +63,7 @@ namespace MatterHackers.MatterControl headerRow.Padding = new BorderDouble(0, 3, 0, 3); { - string movementSpeedsLbl = LocalizedString.Get("Movement Speeds Presets"); + string movementSpeedsLbl = LocalizedString.Get("Movement Speeds Presets".Localize()); TextWidget elementHeader = new TextWidget(string.Format("{0}:",movementSpeedsLbl), pointSize: 14); elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; elementHeader.HAnchor = HAnchor.ParentLeftRight; diff --git a/PrinterControls/ManualPrinterControls.cs b/PrinterControls/ManualPrinterControls.cs index 682312cb7..48460bec4 100644 --- a/PrinterControls/ManualPrinterControls.cs +++ b/PrinterControls/ManualPrinterControls.cs @@ -54,8 +54,6 @@ namespace MatterHackers.MatterControl } } - - public class ManualPrinterControls : GuiWidget { readonly double minExtrutionRatio = .5; @@ -70,8 +68,6 @@ namespace MatterHackers.MatterControl Button homeXButton; Button homeYButton; Button homeZButton; - Button enablePrintLevelingButton; - Button disablePrintLevelingButton; DisableableWidget extruderTemperatureControlWidget; DisableableWidget bedTemperatureControlWidget; @@ -81,7 +77,6 @@ namespace MatterHackers.MatterControl DisableableWidget tuningAdjustmentControlsContainer; DisableableWidget terminalCommunicationsContainer; DisableableWidget sdCardManagerContainer; - DisableableWidget printLevelContainer; DisableableWidget macroControls; TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory(); @@ -139,7 +134,7 @@ namespace MatterHackers.MatterControl } } - EditManualMovementSpeedsWindow editSettingsWindow; + EditManualMovementSpeedsWindow editManualMovementSettingsWindow; public ManualPrinterControls() { SetDisplayAttributes(); @@ -294,17 +289,17 @@ namespace MatterHackers.MatterControl private void AddMovementControls(FlowLayoutWidget controlsTopToBottomLayout) { Button editButton; - GroupBox movementControlsGroupBox = new GroupBox(textImageButtonFactory.GenerateGroupBoxLableWithEdit(LocalizedString.Get("Movement Controls"), out editButton)); + GroupBox movementControlsGroupBox = new GroupBox(textImageButtonFactory.GenerateGroupBoxLableWithEdit("Movement Controls".Localize(), out editButton)); editButton.Click += (sender, e) => { - if (editSettingsWindow == null) + if (editManualMovementSettingsWindow == null) { - editSettingsWindow = new EditManualMovementSpeedsWindow("Movement Speeds", GetMovementSpeedsString(), SetMovementSpeeds); - editSettingsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { editSettingsWindow = null; }; + editManualMovementSettingsWindow = new EditManualMovementSpeedsWindow("Movement Speeds".Localize(), GetMovementSpeedsString(), SetMovementSpeeds); + editManualMovementSettingsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { editManualMovementSettingsWindow = null; }; } else { - editSettingsWindow.BringToFront(); + editManualMovementSettingsWindow.BringToFront(); } }; @@ -400,7 +395,6 @@ namespace MatterHackers.MatterControl Slider feedRateRatioSlider; Slider extrusionRatioSlider; NumberEdit extrusionValue; - PrintLevelWizardWindow printLevelWizardWindow; private void AddAdjustmentControls(FlowLayoutWidget controlsTopToBottomLayout) { @@ -515,102 +509,6 @@ namespace MatterHackers.MatterControl feedRateValue.Value = ((int)(PrinterCommunication.Instance.FeedRateRatio * 100 + .5)) / 100.0; } - TextWidget printLevelingStatusLabel; - - private GuiWidget CreatePrintLevelingControlsContainer() - { - GroupBox printLevelingControlsContainer; - printLevelingControlsContainer = new GroupBox(LocalizedString.Get("Automatic Calibration")); - - printLevelingControlsContainer.Margin = new BorderDouble(0); - printLevelingControlsContainer.TextColor = ActiveTheme.Instance.PrimaryTextColor; - printLevelingControlsContainer.BorderColor = ActiveTheme.Instance.PrimaryTextColor; - printLevelingControlsContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; - printLevelingControlsContainer.Height = 68; - - { - FlowLayoutWidget buttonBar = new FlowLayoutWidget(); - buttonBar.HAnchor |= HAnchor.ParentLeftRight; - buttonBar.VAnchor |= Agg.UI.VAnchor.ParentCenter; - buttonBar.Margin = new BorderDouble(0, 0, 0, 0); - buttonBar.Padding = new BorderDouble(0); - - this.textImageButtonFactory.FixedHeight = TallButtonHeight; - - Button runPrintLevelingButton = textImageButtonFactory.Generate(LocalizedString.Get("CONFIGURE")); - runPrintLevelingButton.Margin = new BorderDouble(left:6); - runPrintLevelingButton.VAnchor = VAnchor.ParentCenter; - runPrintLevelingButton.Click += new ButtonBase.ButtonEventHandler(runPrintLeveling_Click); - - Agg.Image.ImageBuffer levelingImage = new Agg.Image.ImageBuffer(); - ImageIO.LoadImageData(Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath,"Icons", "PrintStatusControls", "leveling-24x24.png"), levelingImage); - ImageWidget levelingIcon = new ImageWidget(levelingImage); - levelingIcon.Margin = new BorderDouble (right: 6); - - enablePrintLevelingButton = textImageButtonFactory.Generate(LocalizedString.Get("ENABLE")); - enablePrintLevelingButton.Margin = new BorderDouble(left:6); - enablePrintLevelingButton.VAnchor = VAnchor.ParentCenter; - enablePrintLevelingButton.Click += new ButtonBase.ButtonEventHandler(enablePrintLeveling_Click); - - disablePrintLevelingButton = textImageButtonFactory.Generate(LocalizedString.Get("DISABLE")); - disablePrintLevelingButton.Margin = new BorderDouble(left:6); - disablePrintLevelingButton.VAnchor = VAnchor.ParentCenter; - disablePrintLevelingButton.Click += new ButtonBase.ButtonEventHandler(disablePrintLeveling_Click); - - CheckBox doLevelingCheckBox = new CheckBox(LocalizedString.Get("Enable Automatic Print Leveling")); - doLevelingCheckBox.Margin = new BorderDouble(left: 3); - doLevelingCheckBox.TextColor = ActiveTheme.Instance.PrimaryTextColor; - doLevelingCheckBox.VAnchor = VAnchor.ParentCenter; - doLevelingCheckBox.Checked = ActivePrinterProfile.Instance.DoPrintLeveling; - - printLevelingStatusLabel = new TextWidget (""); - printLevelingStatusLabel.AutoExpandBoundsToText = true; - printLevelingStatusLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; - printLevelingStatusLabel.VAnchor = VAnchor.ParentCenter; - - GuiWidget hSpacer = new GuiWidget (); - hSpacer.HAnchor = HAnchor.ParentLeftRight; - - buttonBar.AddChild(levelingIcon); - //buttonBar.AddChild(doLevelingCheckBox); - buttonBar.AddChild (printLevelingStatusLabel); - buttonBar.AddChild (hSpacer); - buttonBar.AddChild(enablePrintLevelingButton); - buttonBar.AddChild(disablePrintLevelingButton); - buttonBar.AddChild(runPrintLevelingButton); - doLevelingCheckBox.CheckedStateChanged += (sender, e) => - { - ActivePrinterProfile.Instance.DoPrintLeveling = doLevelingCheckBox.Checked; - }; - ActivePrinterProfile.Instance.DoPrintLevelingChanged.RegisterEvent((sender, e) => - { - SetPrintLevelButtonVisiblity(); - - }, ref unregisterEvents); - - printLevelingControlsContainer.AddChild(buttonBar); - } - SetPrintLevelButtonVisiblity (); - return printLevelingControlsContainer; - } - - private void OpenPrintLevelWizard() - { - if (printLevelWizardWindow == null) - { - printLevelWizardWindow = new PrintLevelWizardWindow(); - printLevelWizardWindow.Closed += (sender, e) => - { - printLevelWizardWindow = null; - }; - printLevelWizardWindow.ShowAsSystemWindow(); - } - else - { - printLevelWizardWindow.BringToFront(); - } - } - private GuiWidget CreateTerminalControlsContainer() { GroupBox terminalControlsContainer; @@ -922,31 +820,6 @@ namespace MatterHackers.MatterControl //this.Invalidate(); } - void enablePrintLeveling_Click(object sender, MouseEventArgs mouseEvent) - { - ActivePrinterProfile.Instance.DoPrintLeveling = true; - } - - void disablePrintLeveling_Click(object sender, MouseEventArgs mouseEvent) - { - ActivePrinterProfile.Instance.DoPrintLeveling = false; - } - - void SetPrintLevelButtonVisiblity() - { - enablePrintLevelingButton.Visible = !ActivePrinterProfile.Instance.DoPrintLeveling; - disablePrintLevelingButton.Visible = ActivePrinterProfile.Instance.DoPrintLeveling; - - if (ActivePrinterProfile.Instance.DoPrintLeveling) { - printLevelingStatusLabel.Text = LocalizedString.Get ("Automatic Print Leveling (enabled)"); - } - else - { - printLevelingStatusLabel.Text = LocalizedString.Get ("Automatic Print Leveling (disabled)"); - } - } - - void disableMotors_Click(object sender, MouseEventArgs mouseEvent) { PrinterCommunication.Instance.ReleaseMotors(); @@ -976,10 +849,5 @@ namespace MatterHackers.MatterControl { base.OnClosing(out CancelClose); } - - void runPrintLeveling_Click(object sender, MouseEventArgs mouseEvent) - { - OpenPrintLevelWizard(); - } } } diff --git a/PrinterControls/PrintLeveling.cs b/PrinterControls/PrintLeveling.cs index 1e118182b..85c8b2271 100644 --- a/PrinterControls/PrintLeveling.cs +++ b/PrinterControls/PrintLeveling.cs @@ -58,9 +58,9 @@ namespace MatterHackers.MatterControl Vector3 outPosition1 = Vector3.TransformPosition(position1, makePointsFlatMatrix); Vector3 outPosition2 = Vector3.TransformPosition(position2, makePointsFlatMatrix); - Vector3 printPosition0 = new Vector3(ActiveSliceSettings.Instance.GetPrintLevelSamplePosition(0), 0); - Vector3 printPosition1 = new Vector3(ActiveSliceSettings.Instance.GetPrintLevelSamplePosition(1), 0); - Vector3 printPosition2 = new Vector3(ActiveSliceSettings.Instance.GetPrintLevelSamplePosition(2), 0); + Vector3 printPosition0 = new Vector3(ActiveSliceSettings.Instance.GetPrintLevelPositionToSample(0), 0); + Vector3 printPosition1 = new Vector3(ActiveSliceSettings.Instance.GetPrintLevelPositionToSample(1), 0); + Vector3 printPosition2 = new Vector3(ActiveSliceSettings.Instance.GetPrintLevelPositionToSample(2), 0); Vector3 leveledPositon0 = Vector3.TransformPosition(printPosition0, bedLevelMatrix); Vector3 leveledPositon1 = Vector3.TransformPosition(printPosition1, bedLevelMatrix); diff --git a/SlicerConfiguration/ActiveSliceSettings.cs b/SlicerConfiguration/ActiveSliceSettings.cs index ada709ce6..6d1d26745 100644 --- a/SlicerConfiguration/ActiveSliceSettings.cs +++ b/SlicerConfiguration/ActiveSliceSettings.cs @@ -115,7 +115,12 @@ namespace MatterHackers.MatterControl.SlicerConfiguration } } - public Vector2 GetPrintLevelSamplePosition(int index) + /// + /// This returns one of the three positions that should be probed when leveling + /// + /// + /// + public Vector2 GetPrintLevelPositionToSample(int index) { Vector2 bedSize = ActiveSliceSettings.Instance.BedSize; Vector2 printCenter = ActiveSliceSettings.Instance.PrintCenter; @@ -167,9 +172,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration if (ActivePrinterProfile.Instance.ActivePrinter != null) { PrintLeveling.Instance.SetPrintLevelingEquation( - ActivePrinterProfile.Instance.GetPrintLevelingProbePosition(0), - ActivePrinterProfile.Instance.GetPrintLevelingProbePosition(1), - ActivePrinterProfile.Instance.GetPrintLevelingProbePosition(2), + ActivePrinterProfile.Instance.GetPrintLevelingMeasuredPosition(0), + ActivePrinterProfile.Instance.GetPrintLevelingMeasuredPosition(1), + ActivePrinterProfile.Instance.GetPrintLevelingMeasuredPosition(2), ActiveSliceSettings.Instance.PrintCenter); } #endif diff --git a/SlicerConfiguration/SlicingQueue.cs b/SlicerConfiguration/SlicingQueue.cs index d12ed458b..0ffa80133 100644 --- a/SlicerConfiguration/SlicingQueue.cs +++ b/SlicerConfiguration/SlicingQueue.cs @@ -237,6 +237,23 @@ namespace MatterHackers.MatterControl.SlicerConfiguration #if DEBUG if (ActivePrinterProfile.Instance.ActiveSliceEngineType == ActivePrinterProfile.SlicingEngineTypes.MatterSlice) { + MatterHackers.MatterSlice.LogOutput.GetLogWrites += (sender, args) => + { + string message = sender as string; + if (message != null) + { + message = message.Replace("=>", "").Trim(); + if (message.Contains(".gcode")) + { + message = "Saving intermediate file"; + } + message += "..."; + UiThread.RunOnIdle((state) => + { + itemToSlice.OnSlicingOutputMessage(new StringEventArgs(message)); + }); + } + }; MatterSlice.MatterSlice.ProcessArgs(slicerProcess.StartInfo.Arguments); } else diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index 755c7b868..34604ef9c 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -1674,3 +1674,15 @@ Translated:Item selected. Press 'Start' to begin your print. English:Disconnecting Translated:Disconnecting +English:Leveling Settings +Translated:Leveling Settings + +English:Movement Speeds Presets +Translated:Movement Speeds Presets + +English:Axis +Translated:Axis + +English:Sampled Positions +Translated:Sampled Positions +