Working on adding a print level sample position edit window .

Cleaned up the names of the functions to get the print level sample positions vs. the measured positions.
This commit is contained in:
larsbrubaker 2014-04-02 18:14:26 -07:00
parent 7020e33c67
commit afee787587
12 changed files with 318 additions and 169 deletions

View file

@ -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:

View file

@ -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");

View file

@ -383,7 +383,7 @@ namespace MatterHackers.MatterControl.DataStorage
/// Gets the 9 {3 * (x, y, z)} positions that were probed during the print leveling setup.
/// </summary>
/// <returns></returns>
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;

View file

@ -83,6 +83,7 @@
<Compile Include="CustomWidgets\ExportQueueItemWindow.cs" />
<Compile Include="CustomWidgets\ExportToFolderFeedbackWindow.cs" />
<Compile Include="EeProm\EePromMarlinSettings.cs" />
<Compile Include="PrinterControls\EditLevelingSettingsWindow.cs" />
<Compile Include="PrintHistory\PrintHistoryListControl.cs" />
<Compile Include="PrintHistory\PrintHistoryListItem.cs" />
<Compile Include="PrintHistory\PrintHistoryWidget.cs" />

View file

@ -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
}
/// <summary>
/// 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
/// </summary>
/// <param name="position0To2"></param>
/// <returns></returns>
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();
}
}

View file

@ -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<GuiWidget> listWithValues = new List<GuiWidget>();
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();
}
}
}

View file

@ -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;

View file

@ -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();
}
}
}

View file

@ -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);

View file

@ -115,7 +115,12 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
}
}
public Vector2 GetPrintLevelSamplePosition(int index)
/// <summary>
/// This returns one of the three positions that should be probed when leveling
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
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

View file

@ -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

View file

@ -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