Merge pull request #2139 from larsbrubaker/design_tools

Merging in 1.7.1 improvements
This commit is contained in:
Lars Brubaker 2017-06-07 16:51:55 -07:00 committed by GitHub
commit 7e4f9bc562
16 changed files with 256 additions and 104 deletions

View file

@ -155,7 +155,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
if (currentLevelingFunctions == null
|| currentLevelingFunctions.NumberOfRadialSamples != numberOfRadialSamples
|| currentLevelingFunctions.BedCenter != bedCenter
|| currentLevelingFunctions.LevelingData != levelingData)
|| !levelingData.SamplesAreSame(currentLevelingFunctions.SampledPositions))
{
if (currentLevelingFunctions != null)
{
@ -178,7 +178,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
public RadialLevlingFunctions(int numberOfRadialSamples, PrintLevelingData levelingData, Vector2 bedCenter)
{
this.LevelingData = levelingData;
this.SampledPositions = new List<Vector3>(levelingData.SampledPositions);
this.BedCenter = bedCenter;
this.NumberOfRadialSamples = numberOfRadialSamples;
@ -190,10 +190,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
get; set;
}
public PrintLevelingData LevelingData
{
get; set;
}
public List<Vector3> SampledPositions { get; private set; }
public int NumberOfRadialSamples { get; set; }
@ -247,7 +244,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
public Vector3 GetPositionWithZOffset(Vector3 currentDestination)
{
if (LevelingData.SampledPositions.Count == NumberOfRadialSamples + 1)
if (SampledPositions.Count == NumberOfRadialSamples + 1)
{
Vector2 destinationFromCenter = new Vector2(currentDestination) - BedCenter;
@ -266,7 +263,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
lastIndex = 0;
}
Plane currentPlane = new Plane(LevelingData.SampledPositions[firstIndex], LevelingData.SampledPositions[lastIndex], LevelingData.SampledPositions[NumberOfRadialSamples]);
Plane currentPlane = new Plane(SampledPositions[firstIndex], SampledPositions[lastIndex], SampledPositions[NumberOfRadialSamples]);
double hitDistance = currentPlane.GetDistanceToIntersection(new Vector3(currentDestination.x, currentDestination.y, 0), Vector3.UnitZ);

View file

@ -29,6 +29,7 @@ either expressed or implied, of the FreeBSD Project.
using MatterHackers.Agg.UI;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.PrinterCommunication;
using MatterHackers.MatterControl.SlicerConfiguration;
using MatterHackers.MeshVisualizer;
using MatterHackers.VectorMath;
@ -172,6 +173,16 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
printLevelWizardWindow.Closed += (sender, e) =>
{
printLevelWizardWindow = null;
// make sure we raise the probe on close
if (ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.has_z_probe)
&& ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.use_z_probe)
&& ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.has_z_servo))
{
// make sure the servo is retracted
var servoRetract = ActiveSliceSettings.Instance.GetValue<double>(SettingsKey.z_servo_retracted_angle);
PrinterConnectionAndCommunication.Instance.SendLineToPrinterNow($"M280 S{servoRetract}");
}
};
}
else

View file

@ -36,6 +36,7 @@ using MatterHackers.MeshVisualizer;
using MatterHackers.VectorMath;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
@ -210,7 +211,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
public static MeshLevlingFunctions GetLevelingFunctions(int gridWidth, int gridHeight, PrintLevelingData levelingData)
{
if (currentLevelingFunctions == null
|| currentLevelingFunctions.LevelingData != levelingData)
|| !levelingData.SamplesAreSame(currentLevelingFunctions.SampledPositions))
{
if (currentLevelingFunctions != null)
{
@ -234,7 +235,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
public MeshLevlingFunctions(int gridWidth, int gridHeight, PrintLevelingData levelingData)
{
this.LevelingData = levelingData;
this.SampledPositions = new List<Vector3>(levelingData.SampledPositions);
PrinterConnectionAndCommunication.Instance.PositionRead.RegisterEvent(PrinterReportedPosition, ref unregisterEvents);
@ -255,7 +256,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
}
// you can only set this on construction
public PrintLevelingData LevelingData { get; private set; }
public List<Vector3> SampledPositions { get; private set; }
public List<Region> Regions { get; private set; } = new List<Region>();

View file

@ -48,46 +48,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
}
}
public class LastPage3PointInstructions : InstructionsPage
{
protected WizardControl container;
private List<ProbePosition> probePositions = new List<ProbePosition>(3)
{
new ProbePosition(),new ProbePosition(),new ProbePosition()
};
public LastPage3PointInstructions(WizardControl container, string pageDescription, string instructionsText, List<ProbePosition> probePositions)
: base(pageDescription, instructionsText)
{
this.probePositions = probePositions;
this.container = container;
}
public override void PageIsBecomingActive()
{
Vector3 paperWidth = new Vector3(0, 0, ActiveSliceSettings.Instance.GetValue<double>(SettingsKey.manual_probe_paper_width));
PrintLevelingData levelingData = ActiveSliceSettings.Instance.Helpers.GetPrintLevelingData();
levelingData.SampledPositions.Clear();
levelingData.SampledPositions.Add(probePositions[0].position - paperWidth);
levelingData.SampledPositions.Add(probePositions[1].position - paperWidth);
levelingData.SampledPositions.Add(probePositions[2].position - paperWidth);
// Invoke setter forcing persistence of leveling data
ActiveSliceSettings.Instance.Helpers.SetPrintLevelingData(levelingData, true);
ActiveSliceSettings.Instance.Helpers.DoPrintLeveling ( true);
if(ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.z_homes_to_max))
{
PrinterConnectionAndCommunication.Instance.HomeAxis(PrinterConnectionAndCommunication.Axis.XYZ);
}
container.backButton.Enabled = false;
base.PageIsBecomingActive();
}
}
public class LastPagelInstructions : InstructionsPage
{
protected WizardControl container;
@ -105,10 +65,10 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
PrintLevelingData levelingData = ActiveSliceSettings.Instance.Helpers.GetPrintLevelingData();
levelingData.SampledPositions.Clear();
Vector3 paperWidth = new Vector3(0, 0, ActiveSliceSettings.Instance.GetValue<double>(SettingsKey.manual_probe_paper_width));
Vector3 zProbeOffset = new Vector3(0, 0, ActiveSliceSettings.Instance.GetValue<double>(SettingsKey.z_probe_z_offset));
for (int i = 0; i < probePositions.Count; i++)
{
levelingData.SampledPositions.Add(probePositions[i].position - paperWidth);
levelingData.SampledPositions.Add(probePositions[i].position - zProbeOffset);
}
// Invoke setter forcing persistence of leveling data
@ -358,6 +318,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
this.allowLessThan0 = allowLessThan0;
this.probePositions = probePositions;
this.lastReportedPosition = PrinterConnectionAndCommunication.Instance.LastReportedPosition;
this.probePositionsBeingEditedIndex = probePositionsBeingEditedIndex;
@ -393,7 +354,8 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
{
samples.Add(sampleRead);
if (samples.Count == NumberOfSamples)
int numberOfSamples = ActiveSliceSettings.Instance.GetValue<int>(SettingsKey.z_probe_samples);
if (samples.Count == numberOfSamples)
{
samples.Sort();
if (samples.Count > 3)
@ -419,7 +381,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
base.OnClosed(e);
}
readonly int NumberOfSamples = 5;
List<double> samples = new List<double>();
public override void PageIsBecomingActive()
@ -429,11 +390,27 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
base.PageIsBecomingActive();
if (ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.has_z_probe)
&& ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.use_z_probe)
&& ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.has_z_servo))
{
// make sure the servo is deployed
var servoDeploy = ActiveSliceSettings.Instance.GetValue<double>(SettingsKey.z_servo_depolyed_angle);
PrinterConnectionAndCommunication.Instance.SendLineToPrinterNow($"M280 S{servoDeploy}");
}
var feedRates = ActiveSliceSettings.Instance.Helpers.ManualMovementSpeeds();
var adjustedProbePosition = probeStartPosition;
// subtract out the probe offset
var probeOffset = ActiveSliceSettings.Instance.GetValue<Vector2>(SettingsKey.z_probe_xy_offset);
adjustedProbePosition -= new Vector3(probeOffset);
PrinterConnectionAndCommunication.Instance.MoveAbsolute(PrinterConnectionAndCommunication.Axis.Z, probeStartPosition.z, feedRates.z);
PrinterConnectionAndCommunication.Instance.MoveAbsolute(probeStartPosition, feedRates.x);
for (int i = 0; i < NumberOfSamples; i++)
PrinterConnectionAndCommunication.Instance.MoveAbsolute(adjustedProbePosition, feedRates.x);
int numberOfSamples = ActiveSliceSettings.Instance.GetValue<int>(SettingsKey.z_probe_samples);
for (int i = 0; i < numberOfSamples; i++)
{
PrinterConnectionAndCommunication.Instance.SendLineToPrinterNow("G30"); // probe the current position
}

View file

@ -159,5 +159,23 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
return true;
}
public bool SamplesAreSame(List<Vector3> sampledPositions)
{
if (sampledPositions.Count == SampledPositions.Count)
{
for (int i = 0; i < sampledPositions.Count; i++)
{
if (sampledPositions[i] != SampledPositions[i])
{
return false;
}
}
return true;
}
return false;
}
}
}

View file

@ -616,50 +616,55 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
public override void OnKeyDown(KeyEventArgs keyEvent)
{
switch (keyEvent.KeyCode)
var childWithFocus = this.ChildrenRecursive<GuiWidget>().Where(x => x.Focused).FirstOrDefault();
if (!(childWithFocus is InternalTextEditWidget))
{
case Keys.A:
if (keyEvent.Control)
{
SelectAll();
keyEvent.Handled = true;
keyEvent.SuppressKeyPress = true;
}
break;
switch (keyEvent.KeyCode)
{
case Keys.A:
if (keyEvent.Control)
{
SelectAll();
keyEvent.Handled = true;
keyEvent.SuppressKeyPress = true;
}
break;
case Keys.Z:
if (keyEvent.Control)
{
UndoBuffer.Undo();
keyEvent.Handled = true;
keyEvent.SuppressKeyPress = true;
}
break;
case Keys.Z:
if (keyEvent.Control)
{
UndoBuffer.Undo();
keyEvent.Handled = true;
keyEvent.SuppressKeyPress = true;
}
break;
case Keys.Y:
if (keyEvent.Control)
{
UndoBuffer.Redo();
keyEvent.Handled = true;
keyEvent.SuppressKeyPress = true;
}
break;
case Keys.Y:
if (keyEvent.Control)
{
UndoBuffer.Redo();
keyEvent.Handled = true;
keyEvent.SuppressKeyPress = true;
}
break;
case Keys.Delete:
case Keys.Back:
DeleteSelectedMesh();
break;
case Keys.Delete:
case Keys.Back:
DeleteSelectedMesh();
break;
case Keys.Escape:
if (CurrentSelectInfo.DownOnPart)
{
CurrentSelectInfo.DownOnPart = false;
case Keys.Escape:
if (CurrentSelectInfo.DownOnPart)
{
CurrentSelectInfo.DownOnPart = false;
Scene.SelectedItem.Matrix = transformOnMouseDown;
Scene.SelectedItem.Matrix = transformOnMouseDown;
Invalidate();
}
break;
Invalidate();
}
break;
}
}
base.OnKeyDown(keyEvent);

View file

@ -126,6 +126,5 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
return lineBeingSent;
}
}
}

View file

@ -1426,6 +1426,11 @@ namespace MatterHackers.MatterControl.PrinterCommunication
// marlin and repetier send a : before the number and then and ok
if (!GCodeFile.GetFirstNumberAfter(":", line, ref currentLineIndexToSend))
{
if(currentLineIndexToSend == allCheckSumLinesSent.Count)
{
// asking for the next line don't do anything, conitue with sending next instruction
return;
}
// smoothie sends an N before the number and no ok
if (GCodeFile.GetFirstNumberAfter("N", line, ref currentLineIndexToSend))
{

View file

@ -953,6 +953,16 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
}
}
// If we have print leveling turned on then make sure we don't have any leveling commands in the start gcode.
if (Math.Abs(GetValue<double>(SettingsKey.baby_step_z_offset)) > 2)
{
string location = "Location: 'Controls' -> 'Movement' -> 'Z Offset'".Localize();
string error = "Z Offset is too large.".Localize();
string details = "The Z Offset for your printer, sometimes called Babby Stepping, is greater than 2mm and invalid. Clear the value and re-level the bed.".Localize();
StyledMessageBox.ShowMessageBox(null, string.Format("{0}\n\n{1}\n\n{2}", error, details, location), "Calibration Error".Localize());
return false;
}
if (GetValue<double>(SettingsKey.first_layer_extrusion_width) > GetValue<double>(SettingsKey.nozzle_diameter) * 4)
{
string error = "'First Layer Extrusion Width' must be less than or equal to the 'Nozzle Diameter' * 4.".Localize();

View file

@ -95,7 +95,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
public const string layer_to_pause = nameof(layer_to_pause);
public const string leveling_manual_positions = nameof(leveling_manual_positions);
public const string make = nameof(make);
public const string manual_probe_paper_width = nameof(manual_probe_paper_width);
public const string z_probe_z_offset = nameof(z_probe_z_offset);
public const string merge_overlapping_lines = nameof(merge_overlapping_lines);
public const string min_fan_speed = nameof(min_fan_speed);
public const string model = nameof(model);
@ -120,7 +120,12 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
public const string start_gcode = nameof(start_gcode);
public const string temperature = nameof(temperature);
public const string use_z_probe = nameof(use_z_probe);
public const string z_probe_samples = nameof(z_probe_samples);
public const string has_z_probe = nameof(has_z_probe);
public const string has_z_servo = nameof(has_z_servo);
public const string z_probe_xy_offset = nameof(z_probe_xy_offset);
public const string z_servo_depolyed_angle = nameof(z_servo_depolyed_angle);
public const string z_servo_retracted_angle = nameof(z_servo_retracted_angle);
public const string windows_driver = nameof(windows_driver);
public const string z_can_be_negative = nameof(z_can_be_negative);
public const string z_homes_to_max = nameof(z_homes_to_max);

View file

@ -59,9 +59,14 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
SettingsKey.filament_density,
SettingsKey.filament_runout_sensor,
SettingsKey.leveling_manual_positions,
SettingsKey.manual_probe_paper_width,
SettingsKey.z_probe_z_offset,
SettingsKey.use_z_probe,
SettingsKey.z_probe_samples,
SettingsKey.has_z_probe,
SettingsKey.has_z_servo,
SettingsKey.z_probe_xy_offset,
SettingsKey.z_servo_depolyed_angle,
SettingsKey.z_servo_retracted_angle,
SettingsKey.pause_gcode,
SettingsKey.print_leveling_probe_start,
SettingsKey.print_leveling_required_to_print,

View file

@ -298,6 +298,10 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
savedStlCount++;
}
}
else
{
extruderFilesToSlice.Add(SaveAndGetFilenameForMaterial(meshGroup, materialsToInclude));
}
}
return extruderFilesToSlice.ToArray();

View file

@ -43,4 +43,4 @@ Under no circumstances shall MatterHackers, its directors, officers, employees o
8.1. This EULA comes into effect when you install the Software Product on your computer, and is effective for the entire period of use of the Software Product.
8.2 Any use in violation of this EULA shall constitute not only breach of this EULA, but a violation of national and international copyright laws. Any use of the Software Product that infringes upon MatterHackers' intellectual property rights or that is for commercial purposes will be investigated and MatterHackers shall have the right to take appropriate civil and criminal legal action.
8.3. Without prejudice to any other rights, MatterHackers may terminate this EULA if you fail to comply with the terms and conditions of this EULA. In such event, you must destroy all copies of the Software Product and all of its component parts.
8.3. Without prejudice to any other rights, MatterHackers may terminate this EULA if you fail to comply with the terms and conditions of this EULA. In such event, you must destroy all copies of the Software Product and all of its component parts.

View file

@ -312,6 +312,7 @@ Advanced
has_power_control
filament_runout_sensor
has_z_probe
has_z_servo
enable_network_printing
enable_sailfish_communication
Behavior
@ -332,8 +333,12 @@ Advanced
print_leveling_required_to_print
Probe Settings
print_leveling_probe_start
manual_probe_paper_width
use_z_probe
z_probe_samples
z_probe_xy_offset
z_probe_z_offset
z_servo_depolyed_angle
z_servo_retracted_angle
Print Recovery
Recover Settings
recover_is_enabled

View file

@ -583,6 +583,20 @@
"ReloadUiWhenChanged": true,
"RebuildGCodeOnChange": false
},
{
"QuickMenuSettings": [ ],
"SetSettingsOnChange": [ ],
"SlicerConfigName": "has_z_servo",
"PresentationName": "Has Z Servo",
"HelpText": "The printer has a servo for lowering and rasing the z probe.",
"DataEditType": "HARDWARE_PRESENT",
"ShowAsOverride": true,
"ShowIfSet": "has_z_probe",
"ResetAtEndOfPrint": false,
"DefaultValue": "0",
"ReloadUiWhenChanged": true,
"RebuildGCodeOnChange": false
},
{
"QuickMenuSettings": [ ],
"SetSettingsOnChange": [ ],
@ -746,7 +760,7 @@
},
{
"SlicerConfigName": "print_leveling_probe_start",
"PresentationName": "Probe Start Height",
"PresentationName": "Start Height",
"HelpText": "The starting height (z) of the print head before probing each print level position.",
"DataEditType": "DOUBLE",
"ExtraSettings": "mm",
@ -755,9 +769,9 @@
"RebuildGCodeOnChange": false
},
{
"SlicerConfigName": "manual_probe_paper_width",
"PresentationName": "Manual Probe Paper Width",
"HelpText": "The thickness of the paper (or other calibration device) used to perform manual bed probe. For automatic (G30) bed probing, this is the offset of the probe from the tip of the nozzle.",
"SlicerConfigName": "z_probe_z_offset",
"PresentationName": "Z Offset",
"HelpText": "The distance the z probe is from the extruder in z. For manual probing, this is thickness of the paper (or other calibration device).",
"DataEditType": "DOUBLE",
"ExtraSettings": "mm",
"ShowIfSet": "!has_hardware_leveling",
@ -766,13 +780,70 @@
},
{
"SlicerConfigName": "use_z_probe",
"PresentationName": "Use Z Probe",
"PresentationName": "Use Automatic Z Probe",
"HelpText": "Enable this if your printer has hardware support for G30 (automatic bed probing) and you want to use it rather than manually measuring the probe positions.",
"DataEditType": "CHECK_BOX",
"ShowAsOverride": true,
"ShowIfSet": "!has_hardware_leveling&has_z_probe",
"ResetAtEndOfPrint": false,
"RebuildGCodeOnChange": false,
"ReloadUiWhenChanged": true,
"DefaultValue": "0"
},
{
"QuickMenuSettings": [ ],
"SetSettingsOnChange": [ ],
"SlicerConfigName": "z_probe_xy_offset",
"PresentationName": "XY Offset",
"HelpText": "The distance the z probe is from the extruder in x and y.",
"DataEditType": "VECTOR2",
"ExtraSettings": "mm",
"ShowAsOverride": true,
"ShowIfSet": "!has_hardware_leveling&has_z_probe&use_z_probe",
"ResetAtEndOfPrint": false,
"RebuildGCodeOnChange": false,
"DefaultValue": "0,0"
},
{
"QuickMenuSettings": [ ],
"SetSettingsOnChange": [ ],
"SlicerConfigName": "z_probe_samples",
"PresentationName": "Number of Samples",
"HelpText": "The number of times to sample each probe position (results will be averaged).",
"DataEditType": "INT",
"ExtraSettings": "",
"ShowAsOverride": true,
"ShowIfSet": "!has_hardware_leveling&has_z_probe&use_z_probe",
"ResetAtEndOfPrint": false,
"RebuildGCodeOnChange": false,
"DefaultValue": "1"
},
{
"QuickMenuSettings": [ ],
"SetSettingsOnChange": [ ],
"SlicerConfigName": "z_servo_depolyed_angle",
"PresentationName": "Lower / Deploy",
"HelpText": "This is the angle that lowers or deploys the z probe.",
"DataEditType": "POSITIVE_DOUBLE",
"ExtraSettings": "°",
"ShowAsOverride": true,
"ShowIfSet": "!has_hardware_leveling&has_z_probe&use_z_probe&has_z_servo",
"ResetAtEndOfPrint": false,
"RebuildGCodeOnChange": false,
"DefaultValue": "0"
},
{
"QuickMenuSettings": [ ],
"SetSettingsOnChange": [ ],
"SlicerConfigName": "z_servo_retracted_angle",
"PresentationName": "Raise / Stow",
"HelpText": "This is the angle that raises or stows the z probe.",
"DataEditType": "POSITIVE_DOUBLE",
"ExtraSettings": "°",
"ShowAsOverride": true,
"ShowIfSet": "!has_hardware_leveling&has_z_probe&use_z_probe&has_z_servo",
"ResetAtEndOfPrint": false,
"RebuildGCodeOnChange": false,
"DefaultValue": "0"
},
{

View file

@ -6208,3 +6208,42 @@ Translated:Add to Plate
English:Text Size
Translated:Text Size
English:The printer has a servo for lowering and rasing the z probe.
Translated:The printer has a servo for lowering and rasing the z probe.
English:The distance the z probe is from the extruder in z. For manual probing, this is thickness of the paper (or other calibration device).
Translated:The distance the z probe is from the extruder in z. For manual probing, this is thickness of the paper (or other calibration device).
English:The distance the z probe is from the extruder in x and y.
Translated:The distance the z probe is from the extruder in x and y.
English:The number of times to sample each probe position (results will be averaged).
Translated:The number of times to sample each probe position (results will be averaged).
English:This is the angle that lowers or deploys the z probe.
Translated:This is the angle that lowers or deploys the z probe.
English:This is the angle that raises or stows the z probe.
Translated:This is the angle that raises or stows the z probe.
English:Has Z Servo
Translated:Has Z Servo
English:Start Height
Translated:Start Height
English:Use Automatic Z Probe
Translated:Use Automatic Z Probe
English:Number of Samples
Translated:Number of Samples
English:XY Offset
Translated:XY Offset
English:Lower / Deploy
Translated:Lower / Deploy
English:Raise / Stow
Translated:Raise / Stow