commit
5a4a8a2f3d
13 changed files with 292 additions and 137 deletions
|
|
@ -2251,12 +2251,12 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
printer.Connection.PrintingItemName = printItemName;
|
||||
|
||||
var errors = SettingsValidation.SettingsValid(printer);
|
||||
var errors = printer.ValidateSettings();
|
||||
if(errors.Count > 0)
|
||||
{
|
||||
StyledMessageBox.ShowMessageBox(String.Join("\n__________________\n\n", errors.ToArray()), "Slice Error".Localize());
|
||||
this.ShowValidationErrors("Export Error".Localize(), errors);
|
||||
}
|
||||
else // there are no erros continue printing
|
||||
else // there are no errors continue printing
|
||||
{
|
||||
// last let's check if there is any support in the scene and if it looks like it is needed
|
||||
if (GenerateSupportPanel.RequiresSupport(printer.Bed.Scene))
|
||||
|
|
@ -2369,6 +2369,25 @@ If you experience adhesion problems, please re-run leveling."
|
|||
}
|
||||
}
|
||||
|
||||
public void ShowValidationErrors(string windowTitle, List<ValidationError> errors)
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
// Project to newline separated Error/Details/Location string
|
||||
var formattedErrors = errors.Select(err =>
|
||||
{
|
||||
// Conditionally combine Error/Details/Location when not empty
|
||||
return err.Error +
|
||||
((string.IsNullOrWhiteSpace(err.Details)) ? "" : $"\n\n{err.Details}") +
|
||||
((string.IsNullOrWhiteSpace(err.Location)) ? "" : $"\n\n{err.Location}");
|
||||
}).ToArray();
|
||||
|
||||
StyledMessageBox.ShowMessageBox(
|
||||
string.Join("\n__________________\n\n", formattedErrors),
|
||||
windowTitle);
|
||||
});
|
||||
}
|
||||
|
||||
public void ResetTranslationMap()
|
||||
{
|
||||
LoadTranslationMap();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2018, Lars Brubaker
|
||||
Copyright (c) 2019, Lars Brubaker, John Lewin
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -37,11 +37,11 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
public static class SettingsValidation
|
||||
{
|
||||
public static List<string> SettingsValid(PrinterConfig printer)
|
||||
public static List<ValidationError> ValidateSettings(this PrinterConfig printer)
|
||||
{
|
||||
var settings = printer.Settings;
|
||||
|
||||
var errors = new List<string>();
|
||||
var errors = new List<ValidationError>();
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -49,34 +49,46 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
if (settings.GetValue<double>(SettingsKey.layer_height) > settings.GetValue<double>(SettingsKey.nozzle_diameter))
|
||||
{
|
||||
var error = "{0} must be less than or equal to the {1}.".Localize().FormatWith(
|
||||
GetSettingsName(SettingsKey.layer_height), GetSettingsName(SettingsKey.nozzle_diameter));
|
||||
var details = "{0} = {1}\n{2} = {3}".FormatWith(GetSettingsName(SettingsKey.layer_height),
|
||||
settings.GetValue<double>(SettingsKey.layer_height),
|
||||
GetSettingsName(SettingsKey.nozzle_diameter),
|
||||
settings.GetValue<double>(SettingsKey.nozzle_diameter));
|
||||
var location = GetSettingsLocation(SettingsKey.layer_height);
|
||||
errors.Add("{0}\n\n{1}\n\n{2}".FormatWith(error, details, location));
|
||||
|
||||
errors.Add(
|
||||
new ValidationError()
|
||||
{
|
||||
Error = "{0} must be less than or equal to the {1}.".Localize().FormatWith(
|
||||
GetSettingsName(SettingsKey.layer_height), GetSettingsName(SettingsKey.nozzle_diameter)),
|
||||
Details = details,
|
||||
Location = GetSettingsLocation(SettingsKey.layer_height)
|
||||
});
|
||||
}
|
||||
else if (settings.GetValue<double>(SettingsKey.layer_height) <= 0)
|
||||
{
|
||||
var error = "{0} must be greater than 0.".Localize().FormatWith(
|
||||
GetSettingsName(SettingsKey.layer_height));
|
||||
var location = GetSettingsLocation(SettingsKey.layer_height);
|
||||
errors.Add($"{error}\n\n{location}");
|
||||
errors.Add(
|
||||
new ValidationError()
|
||||
{
|
||||
Error = "{0} must be greater than 0.".Localize().FormatWith(GetSettingsName(SettingsKey.layer_height)),
|
||||
Location = GetSettingsLocation(SettingsKey.layer_height)
|
||||
});
|
||||
}
|
||||
else if (settings.GetValue<double>(SettingsKey.first_layer_height) > settings.GetValue<double>(SettingsKey.nozzle_diameter))
|
||||
{
|
||||
var error = "{0} must be less than or equal to the {1}.".Localize().FormatWith(
|
||||
GetSettingsName(SettingsKey.layer_height),
|
||||
GetSettingsName(SettingsKey.nozzle_diameter));
|
||||
var details = "{0} = {1}\n{2} = {3}".FormatWith(
|
||||
GetSettingsName(SettingsKey.first_layer_height),
|
||||
settings.GetValue<double>(SettingsKey.first_layer_height),
|
||||
GetSettingsName(SettingsKey.nozzle_diameter),
|
||||
settings.GetValue<double>(SettingsKey.nozzle_diameter));
|
||||
var location = GetSettingsLocation(SettingsKey.first_layer_height);
|
||||
errors.Add("{0}\n\n{1}\n\n{2}".FormatWith(error, details, location));
|
||||
|
||||
errors.Add(
|
||||
new ValidationError()
|
||||
{
|
||||
Error = "{0} must be less than or equal to the {1}.".Localize().FormatWith(
|
||||
GetSettingsName(SettingsKey.layer_height),
|
||||
GetSettingsName(SettingsKey.nozzle_diameter)),
|
||||
Details = details,
|
||||
Location = GetSettingsLocation(SettingsKey.first_layer_height)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -89,18 +101,24 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
if (startGCodeLine.StartsWith("G29"))
|
||||
{
|
||||
var location = GetSettingsLocation(SettingsKey.start_gcode);
|
||||
var error = "Start G-Code cannot contain G29 if Print Recovery is enabled.".Localize();
|
||||
var details = "Your Start G-Code should not contain a G29 if you are planning on using Print Recovery. Change your start G-Code or turn off Print Recovery.".Localize();
|
||||
errors.Add("{0}\n\n{1}\n\n{2}".FormatWith(error, details, location));
|
||||
errors.Add(
|
||||
new ValidationError()
|
||||
{
|
||||
Error = "Start G-Code cannot contain G29 if Print Recovery is enabled.".Localize(),
|
||||
Details = "Your Start G-Code should not contain a G29 if you are planning on using Print Recovery. Change your start G-Code or turn off Print Recovery.".Localize(),
|
||||
Location = GetSettingsLocation(SettingsKey.start_gcode)
|
||||
});
|
||||
}
|
||||
|
||||
if (startGCodeLine.StartsWith("G30"))
|
||||
{
|
||||
var location = GetSettingsLocation(SettingsKey.start_gcode);
|
||||
var error = "Start G-Code cannot contain G30 if Print Leveling is enabled.".Localize();
|
||||
var details = "Your Start G-Code should not contain a G30 if you are planning on using Print Recovery. Change your start G-Code or turn off Print Recovery.".Localize();
|
||||
errors.Add("{0}\n\n{1}\n\n{2}".FormatWith(error, details, location));
|
||||
errors.Add(
|
||||
new ValidationError()
|
||||
{
|
||||
Error = "Start G-Code cannot contain G30 if Print Leveling is enabled.".Localize(),
|
||||
Details = "Your Start G-Code should not contain a G30 if you are planning on using Print Recovery. Change your start G-Code or turn off Print Recovery.".Localize(),
|
||||
Location = GetSettingsLocation(SettingsKey.start_gcode)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -112,18 +130,24 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
if (startGCodeLine.StartsWith("G29"))
|
||||
{
|
||||
var location = GetSettingsLocation(SettingsKey.start_gcode);
|
||||
var error = "Start G-Code cannot contain G29 if Print Leveling is enabled.".Localize();
|
||||
var details = "Your Start G-Code should not contain a G29 if you are planning on using print leveling. Change your start G-Code or turn off print leveling.".Localize();
|
||||
errors.Add("{0}\n\n{1}\n\n{2}".FormatWith(error, details, location));
|
||||
errors.Add(
|
||||
new ValidationError()
|
||||
{
|
||||
Error = "Start G-Code cannot contain G29 if Print Leveling is enabled.".Localize(),
|
||||
Details = "Your Start G-Code should not contain a G29 if you are planning on using print leveling. Change your start G-Code or turn off print leveling.".Localize(),
|
||||
Location = GetSettingsLocation(SettingsKey.start_gcode)
|
||||
});
|
||||
}
|
||||
|
||||
if (startGCodeLine.StartsWith("G30"))
|
||||
{
|
||||
var location = GetSettingsLocation(SettingsKey.start_gcode);
|
||||
var error = "Start G-Code cannot contain G30 if Print Leveling is enabled.".Localize();
|
||||
var details = "Your Start G-Code should not contain a G30 if you are planning on using print leveling. Change your start G-Code or turn off print leveling.".Localize();
|
||||
errors.Add("{0}\n\n{1}\n\n{2}".FormatWith(error, details, location));
|
||||
errors.Add(
|
||||
new ValidationError()
|
||||
{
|
||||
Error = "Start G-Code cannot contain G30 if Print Leveling is enabled.".Localize(),
|
||||
Details = "Your Start G-Code should not contain a G30 if you are planning on using print leveling. Change your start G-Code or turn off print leveling.".Localize(),
|
||||
Location = GetSettingsLocation(SettingsKey.start_gcode)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -131,106 +155,141 @@ namespace MatterHackers.MatterControl
|
|||
// If we have print leveling turned on then make sure we don't have any leveling commands in the start gcode.
|
||||
if (Math.Abs(settings.GetValue<double>(SettingsKey.baby_step_z_offset)) > 2)
|
||||
{
|
||||
var location = "Location".Localize() + ":";
|
||||
location += "\n" + "Controls".Localize();
|
||||
location += "\n • " + "Movement".Localize();
|
||||
location += "\n • " + "Z Offset".Localize();
|
||||
var error = "Z Offset is too large.".Localize();
|
||||
var details = "The Z Offset for your printer, sometimes called Baby Stepping, is greater than 2mm and invalid. Clear the value and re-level the bed.".Localize();
|
||||
errors.Add("{0}\n\n{1}\n\n{2}".FormatWith(error, details, location));
|
||||
// Static path generation for non-SliceSettings value
|
||||
var location = "Location".Localize() + ":"
|
||||
+ "\n" + "Controls".Localize()
|
||||
+ "\n • " + "Movement".Localize()
|
||||
+ "\n • " + "Z Offset".Localize();
|
||||
|
||||
errors.Add(
|
||||
new ValidationError()
|
||||
{
|
||||
Error = "Z Offset is too large.".Localize(),
|
||||
Details = "The Z Offset for your printer, sometimes called Baby Stepping, is greater than 2mm and invalid. Clear the value and re-level the bed.".Localize(),
|
||||
Location = location
|
||||
});
|
||||
}
|
||||
|
||||
if (settings.GetValue<double>(SettingsKey.first_layer_extrusion_width) > settings.GetValue<double>(SettingsKey.nozzle_diameter) * 4)
|
||||
{
|
||||
var error = "{0} must be less than or equal to the {1} * 4.".Localize().FormatWith(
|
||||
GetSettingsName(SettingsKey.first_layer_extrusion_width),
|
||||
GetSettingsName(SettingsKey.nozzle_diameter));
|
||||
var details = "{0} = {1}\n{2} = {3}".FormatWith(
|
||||
GetSettingsName(SettingsKey.first_layer_extrusion_width),
|
||||
settings.GetValue<double>(SettingsKey.first_layer_extrusion_width),
|
||||
GetSettingsName(SettingsKey.nozzle_diameter),
|
||||
settings.GetValue<double>(SettingsKey.nozzle_diameter));
|
||||
string location = GetSettingsLocation(SettingsKey.first_layer_extrusion_width);
|
||||
errors.Add("{0}\n\n{1}\n\n{2}".FormatWith(error, details, location));
|
||||
|
||||
errors.Add(
|
||||
new ValidationError()
|
||||
{
|
||||
Error = "{0} must be less than or equal to the {1} * 4.".Localize().FormatWith(
|
||||
GetSettingsName(SettingsKey.first_layer_extrusion_width),
|
||||
GetSettingsName(SettingsKey.nozzle_diameter)),
|
||||
Details = details,
|
||||
Location = GetSettingsLocation(SettingsKey.first_layer_extrusion_width)
|
||||
});
|
||||
}
|
||||
|
||||
if (settings.GetValue<double>(SettingsKey.first_layer_extrusion_width) <= 0)
|
||||
{
|
||||
var error = "{0} must be greater than 0.".Localize().FormatWith(
|
||||
GetSettingsName(SettingsKey.first_layer_extrusion_width));
|
||||
var details = "{0} = {1}".FormatWith(
|
||||
GetSettingsName(SettingsKey.first_layer_extrusion_width),
|
||||
settings.GetValue<double>(SettingsKey.first_layer_extrusion_width));
|
||||
string location = GetSettingsLocation(SettingsKey.first_layer_extrusion_width);
|
||||
errors.Add("{0}\n\n{1}\n\n{2}".FormatWith(error, details, location));
|
||||
errors.Add(
|
||||
new ValidationError()
|
||||
{
|
||||
Error = "{0} must be greater than 0.".Localize().FormatWith(
|
||||
GetSettingsName(SettingsKey.first_layer_extrusion_width)),
|
||||
Details = "{0} = {1}".FormatWith(
|
||||
GetSettingsName(SettingsKey.first_layer_extrusion_width),
|
||||
settings.GetValue<double>(SettingsKey.first_layer_extrusion_width)),
|
||||
Location = GetSettingsLocation(SettingsKey.first_layer_extrusion_width)
|
||||
});
|
||||
}
|
||||
|
||||
if (settings.GetValue<double>(SettingsKey.external_perimeter_extrusion_width) > settings.GetValue<double>(SettingsKey.nozzle_diameter) * 4)
|
||||
{
|
||||
var error = "{0} must be less than or equal to the {1} * 4.".Localize().FormatWith(
|
||||
GetSettingsName(SettingsKey.external_perimeter_extrusion_width),
|
||||
GetSettingsName(SettingsKey.nozzle_diameter));
|
||||
var details = "{0} = {1}\n{2} = {3}".FormatWith(
|
||||
GetSettingsName(SettingsKey.external_perimeter_extrusion_width),
|
||||
settings.GetValue<double>(SettingsKey.external_perimeter_extrusion_width),
|
||||
GetSettingsName(SettingsKey.nozzle_diameter),
|
||||
settings.GetValue<double>(SettingsKey.nozzle_diameter));
|
||||
string location = GetSettingsLocation(SettingsKey.external_perimeter_extrusion_width);
|
||||
errors.Add("{0}\n\n{1}\n\n{2}".FormatWith(error, details, location));
|
||||
|
||||
errors.Add(
|
||||
new ValidationError()
|
||||
{
|
||||
Error = "{0} must be less than or equal to the {1} * 4.".Localize().FormatWith(
|
||||
GetSettingsName(SettingsKey.external_perimeter_extrusion_width),
|
||||
GetSettingsName(SettingsKey.nozzle_diameter)),
|
||||
Details = details,
|
||||
Location = GetSettingsLocation(SettingsKey.external_perimeter_extrusion_width)
|
||||
});
|
||||
}
|
||||
|
||||
if (settings.GetValue<double>(SettingsKey.external_perimeter_extrusion_width) <= 0)
|
||||
{
|
||||
var error = "{0} must be greater than 0.".Localize().FormatWith(
|
||||
GetSettingsName(SettingsKey.external_perimeter_extrusion_width));
|
||||
var details = "{0} = {1}".FormatWith(
|
||||
GetSettingsName(SettingsKey.external_perimeter_extrusion_width),
|
||||
settings.GetValue<double>(SettingsKey.external_perimeter_extrusion_width));
|
||||
var location = GetSettingsLocation(SettingsKey.external_perimeter_extrusion_width);
|
||||
errors.Add("{0}\n\n{1}\n\n{2}".FormatWith(error, details, location));
|
||||
|
||||
errors.Add(
|
||||
new ValidationError()
|
||||
{
|
||||
Error = "{0} must be greater than 0.".Localize().FormatWith(
|
||||
GetSettingsName(SettingsKey.external_perimeter_extrusion_width)),
|
||||
Details = "{0} = {1}".FormatWith(
|
||||
GetSettingsName(SettingsKey.external_perimeter_extrusion_width),
|
||||
settings.GetValue<double>(SettingsKey.external_perimeter_extrusion_width)),
|
||||
Location = GetSettingsLocation(SettingsKey.external_perimeter_extrusion_width)
|
||||
});
|
||||
}
|
||||
|
||||
if (settings.GetValue<double>(SettingsKey.min_fan_speed) > 100)
|
||||
{
|
||||
var error = "The {0} can only go as high as 100%.".Localize().FormatWith(
|
||||
GetSettingsName(SettingsKey.min_fan_speed));
|
||||
var details = "It is currently set to {0}.".Localize().FormatWith(
|
||||
settings.GetValue<double>(SettingsKey.min_fan_speed));
|
||||
var location = GetSettingsLocation(SettingsKey.min_fan_speed);
|
||||
errors.Add("{0}\n\n{1}\n\n{2}".FormatWith(error, details, location));
|
||||
errors.Add(
|
||||
new ValidationError()
|
||||
{
|
||||
Error = "The {0} can only go as high as 100%.".Localize().FormatWith(
|
||||
GetSettingsName(SettingsKey.min_fan_speed)),
|
||||
Details = "It is currently set to {0}.".Localize().FormatWith(
|
||||
settings.GetValue<double>(SettingsKey.min_fan_speed)),
|
||||
Location = GetSettingsLocation(SettingsKey.min_fan_speed)
|
||||
});
|
||||
}
|
||||
|
||||
if (settings.GetValue<double>(SettingsKey.max_fan_speed) > 100)
|
||||
{
|
||||
var error = "The {0} can only go as high as 100%.".Localize().FormatWith(
|
||||
GetSettingsName(SettingsKey.max_fan_speed));
|
||||
var details = "It is currently set to {0}.".Localize().FormatWith(
|
||||
settings.GetValue<double>(SettingsKey.max_fan_speed));
|
||||
var location = GetSettingsLocation(SettingsKey.max_fan_speed);
|
||||
errors.Add("{0}\n\n{1}\n\n{2}".FormatWith(error, details, location));
|
||||
errors.Add(
|
||||
new ValidationError()
|
||||
{
|
||||
Error = "The {0} can only go as high as 100%.".Localize().FormatWith(
|
||||
GetSettingsName(SettingsKey.max_fan_speed)),
|
||||
Details = "It is currently set to {0}.".Localize().FormatWith(
|
||||
settings.GetValue<double>(SettingsKey.max_fan_speed)),
|
||||
Location = GetSettingsLocation(SettingsKey.max_fan_speed)
|
||||
});
|
||||
}
|
||||
|
||||
if (settings.GetValue<int>(SettingsKey.extruder_count) < 1)
|
||||
{
|
||||
var error = "The {0} must be at least 1.".Localize().FormatWith(
|
||||
GetSettingsName(SettingsKey.extruder_count));
|
||||
var details = "It is currently set to {0}.".Localize().FormatWith(
|
||||
settings.GetValue<int>(SettingsKey.extruder_count));
|
||||
var location = GetSettingsLocation(SettingsKey.extruder_count);
|
||||
errors.Add("{0}\n\n{1}\n\n{2}".FormatWith(error, details, location));
|
||||
errors.Add(
|
||||
new ValidationError()
|
||||
{
|
||||
Error = "The {0} must be at least 1.".Localize().FormatWith(
|
||||
GetSettingsName(SettingsKey.extruder_count)),
|
||||
Details= "It is currently set to {0}.".Localize().FormatWith(
|
||||
settings.GetValue<int>(SettingsKey.extruder_count)),
|
||||
Location = GetSettingsLocation(SettingsKey.extruder_count)
|
||||
});
|
||||
}
|
||||
|
||||
if (settings.GetValue<double>(SettingsKey.fill_density) < 0 || settings.GetValue<double>(SettingsKey.fill_density) > 1)
|
||||
{
|
||||
var error = "The {0} must be between 0 and 1.".Localize().FormatWith(
|
||||
GetSettingsName(SettingsKey.fill_density));
|
||||
var details = "It is currently set to {0}.".Localize().FormatWith(
|
||||
settings.GetValue<double>(SettingsKey.fill_density));
|
||||
var location = GetSettingsLocation(SettingsKey.filament_density);
|
||||
errors.Add("{0}\n\n{1}\n\n{2}".FormatWith(error, details, location));
|
||||
errors.Add(
|
||||
new ValidationError()
|
||||
{
|
||||
Error = "The {0} must be between 0 and 1.".Localize().FormatWith(
|
||||
GetSettingsName(SettingsKey.fill_density)),
|
||||
Details = "It is currently set to {0}.".Localize().FormatWith(
|
||||
settings.GetValue<double>(SettingsKey.fill_density)),
|
||||
Location = GetSettingsLocation(SettingsKey.filament_density)
|
||||
});
|
||||
}
|
||||
|
||||
// marlin firmware can only take a max of 128 bytes in a single instrection, make sure no lines are longer than that
|
||||
// marlin firmware can only take a max of 128 bytes in a single instruction, make sure no lines are longer than that
|
||||
ValidateGCodeLinesShortEnough(SettingsKey.cancel_gcode, printer, errors);
|
||||
ValidateGCodeLinesShortEnough(SettingsKey.connect_gcode, printer, errors);
|
||||
ValidateGCodeLinesShortEnough(SettingsKey.end_gcode, printer, errors);
|
||||
|
|
@ -256,8 +315,12 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
errors.Add(e.Message);
|
||||
errors.Add(e.StackTrace.Replace("\r", ""));
|
||||
errors.Add(
|
||||
new ValidationError()
|
||||
{
|
||||
Error = "Unexpected error validating settings".Localize(),
|
||||
Details = e.Message
|
||||
});
|
||||
}
|
||||
|
||||
return errors;
|
||||
|
|
@ -276,13 +339,11 @@ namespace MatterHackers.MatterControl
|
|||
setingsSectionName = "Slice Settings";
|
||||
}
|
||||
|
||||
var location = "Location".Localize() + ":";
|
||||
location += "\n" + setingsSectionName.Localize();
|
||||
location += "\n • " + category.Name.Localize();
|
||||
location += "\n • " + subGroup.Group.Name.Localize();
|
||||
location += "\n • " + settingData.PresentationName.Localize();
|
||||
|
||||
return location;
|
||||
return "Location".Localize() + ":"
|
||||
+ "\n" + setingsSectionName.Localize()
|
||||
+ "\n • " + category.Name.Localize()
|
||||
+ "\n • " + subGroup.Group.Name.Localize()
|
||||
+ "\n • " + settingData.PresentationName.Localize();
|
||||
}
|
||||
|
||||
private static string GetSettingsName(string settingsKey)
|
||||
|
|
@ -291,7 +352,7 @@ namespace MatterHackers.MatterControl
|
|||
return settingData.PresentationName.Localize();
|
||||
}
|
||||
|
||||
private static bool ValidateGCodeLinesShortEnough(string gCodeSetting, PrinterConfig printer, List<string> errors)
|
||||
private static bool ValidateGCodeLinesShortEnough(string gCodeSetting, PrinterConfig printer, List<ValidationError> errors)
|
||||
{
|
||||
string[] gCodeString = printer.Settings.GetValue(SettingsKey.start_gcode).Replace("\\n", "\n").Split('\n');
|
||||
|
||||
|
|
@ -305,12 +366,16 @@ namespace MatterHackers.MatterControl
|
|||
SliceSettingData data = SettingsOrganizer.Instance.GetSettingsData(gCodeSetting);
|
||||
if (data != null)
|
||||
{
|
||||
var location = GetSettingsLocation(gCodeSetting);
|
||||
|
||||
var error = "All G-Code lines mush be shorter than 100 characters (excluding comments).".Localize().FormatWith(data.PresentationName);
|
||||
var details = "Found a line that is {0} characters long.\n{1}...".Localize().FormatWith(length, trimedLine.Substring(0, 20));
|
||||
errors.Add("{0}\n\n{1}\n\n{2}".FormatWith(error, details, location));
|
||||
errors.Add(
|
||||
new ValidationError()
|
||||
{
|
||||
Error = "All G-Code lines mush be shorter than 100 characters (excluding comments).".Localize().FormatWith(data.PresentationName),
|
||||
Details = details,
|
||||
Location = GetSettingsLocation(gCodeSetting)
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -318,7 +383,7 @@ namespace MatterHackers.MatterControl
|
|||
return true;
|
||||
}
|
||||
|
||||
private static void ValidateGoodSpeedSettingGreaterThan0(string speedSetting, PrinterConfig printer, List<string> errors)
|
||||
private static void ValidateGoodSpeedSettingGreaterThan0(string speedSetting, PrinterConfig printer, List<ValidationError> errors)
|
||||
{
|
||||
var actualSpeedValueString = printer.Settings.GetValue(speedSetting);
|
||||
var speedValueString = actualSpeedValueString;
|
||||
|
|
@ -326,9 +391,10 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
speedValueString = speedValueString.Substring(0, speedValueString.Length - 1);
|
||||
}
|
||||
|
||||
bool valueWasNumber = true;
|
||||
double speedToCheck;
|
||||
if (!double.TryParse(speedValueString, out speedToCheck))
|
||||
|
||||
if (!double.TryParse(speedValueString, out double speedToCheck))
|
||||
{
|
||||
valueWasNumber = false;
|
||||
}
|
||||
|
|
@ -340,11 +406,13 @@ namespace MatterHackers.MatterControl
|
|||
SliceSettingData data = SettingsOrganizer.Instance.GetSettingsData(speedSetting);
|
||||
if (data != null)
|
||||
{
|
||||
var location = GetSettingsLocation(speedSetting);
|
||||
|
||||
var error = "The {0} must be greater than 0.".Localize().FormatWith(data.PresentationName);
|
||||
var details = "It is currently set to {0}.".Localize().FormatWith(actualSpeedValueString);
|
||||
errors.Add("{0}\n\n{1}\n\n{2}".FormatWith(error, details, location));
|
||||
errors.Add(
|
||||
new ValidationError()
|
||||
{
|
||||
Error = "The {0} must be greater than 0.".Localize().FormatWith(data.PresentationName),
|
||||
Details = "It is currently set to {0}.".Localize().FormatWith(actualSpeedValueString),
|
||||
Location = GetSettingsLocation(speedSetting)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
44
MatterControlLib/ApplicationView/ValidationError.cs
Normal file
44
MatterControlLib/ApplicationView/ValidationError.cs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
Copyright (c) 2019, John Lewin
|
||||
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.
|
||||
*/
|
||||
|
||||
namespace MatterHackers.MatterControl
|
||||
{
|
||||
public class ValidationError
|
||||
{
|
||||
public string Error { get; set; }
|
||||
|
||||
public string Details { get; set; }
|
||||
|
||||
public string Source { get; set; }
|
||||
|
||||
public string SourceName { get; set; }
|
||||
|
||||
public string Location { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -226,7 +226,7 @@ namespace MatterHackers.MatterControl
|
|||
savePath += targetExtension;
|
||||
}
|
||||
|
||||
List<string> exportErrors = null;
|
||||
List<ValidationError> exportErrors = null;
|
||||
|
||||
if (activePlugin != null)
|
||||
{
|
||||
|
|
@ -243,10 +243,7 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
else
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
StyledMessageBox.ShowMessageBox(String.Join("\n__________________\n\n", exportErrors.ToArray()), "Export Error".Localize());
|
||||
});
|
||||
ApplicationController.Instance.ShowValidationErrors("Export Error".Localize(), exportErrors);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,10 +117,10 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
[Range(3, 360, ErrorMessage = "Value for {0} must be between {1} and {2}.")]
|
||||
[Description("Ensurs the rotated part has a minimum number of sides per complete rotation")]
|
||||
public double MinSidesPerRotation { get; set; } = 3;
|
||||
|
||||
|
||||
// holds where we rotate the object
|
||||
Vector2 rotationCenter;
|
||||
|
||||
|
||||
public CurveObject3D()
|
||||
{
|
||||
Name = "Curve".Localize();
|
||||
|
|
@ -267,7 +267,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
&& layer.Scene.SelectedItem != null
|
||||
&& layer.Scene.SelectedItem.DescendantsAndSelf().Where((i) => i == this).Any())
|
||||
{
|
||||
// we want to measure the
|
||||
// we want to measure the
|
||||
var currentMatrixInv = Matrix.Inverted;
|
||||
var aabb = this.GetAxisAlignedBoundingBox(currentMatrixInv);
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ namespace MatterHackers.MatterControl.Library.Export
|
|||
|
||||
public bool ExportPossible(ILibraryAsset libraryItem) => true;
|
||||
|
||||
public async Task<List<string>> Generate(IEnumerable<ILibraryItem> libraryItems, string outputPath, IProgress<ProgressStatus> progress, CancellationToken cancellationToken)
|
||||
public async Task<List<ValidationError>> Generate(IEnumerable<ILibraryItem> libraryItems, string outputPath, IProgress<ProgressStatus> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var streamItems = libraryItems.OfType<ILibraryAssetStream>();
|
||||
if (streamItems.Any())
|
||||
|
|
@ -92,7 +92,13 @@ namespace MatterHackers.MatterControl.Library.Export
|
|||
return null;
|
||||
}
|
||||
|
||||
return new List<string>() { "No items to Export".Localize() };
|
||||
return new List<ValidationError>()
|
||||
{
|
||||
new ValidationError()
|
||||
{
|
||||
Error = "No items to Export".Localize()
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ namespace MatterHackers.MatterControl.Library.Export
|
|||
return container;
|
||||
}
|
||||
|
||||
public virtual async Task<List<string>> Generate(IEnumerable<ILibraryItem> libraryItems, string outputPath, IProgress<ProgressStatus> progress, CancellationToken cancellationToken)
|
||||
public virtual async Task<List<ValidationError>> Generate(IEnumerable<ILibraryItem> libraryItems, string outputPath, IProgress<ProgressStatus> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var firstItem = libraryItems.OfType<ILibraryAsset>().FirstOrDefault();
|
||||
if (firstItem != null)
|
||||
|
|
@ -217,7 +217,7 @@ namespace MatterHackers.MatterControl.Library.Export
|
|||
printer.Settings.SetValue(SettingsKey.spiral_vase, "1");
|
||||
}
|
||||
|
||||
var errors = SettingsValidation.SettingsValid(printer);
|
||||
var errors = printer.ValidateSettings();
|
||||
|
||||
if(errors.Count > 0)
|
||||
{
|
||||
|
|
@ -264,7 +264,14 @@ namespace MatterHackers.MatterControl.Library.Export
|
|||
}
|
||||
}
|
||||
|
||||
return new List<string>() { "Item cannot be exported".Localize() + " " + firstItem != null ? firstItem.ToString() : "" };
|
||||
return new List<ValidationError>
|
||||
{
|
||||
new ValidationError()
|
||||
{
|
||||
Error = "Item cannot be exported".Localize(),
|
||||
Details = firstItem?.ToString() ?? ""
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public bool ApplyLeveling { get; set; } = true;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
void Initialize(PrinterConfig printer);
|
||||
|
||||
Task<List<string>> Generate(IEnumerable<ILibraryItem> libraryItems, string outputPath, IProgress<ProgressStatus> progress, CancellationToken cancellationToken);
|
||||
Task<List<ValidationError>> Generate(IEnumerable<ILibraryItem> libraryItems, string outputPath, IProgress<ProgressStatus> progress, CancellationToken cancellationToken);
|
||||
|
||||
bool Enabled { get; }
|
||||
string DisabledReason { get; }
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ namespace MatterHackers.MatterControl.Library.Export
|
|||
|
||||
public bool ExportPossible(ILibraryAsset libraryItem) => true;
|
||||
|
||||
public async Task<List<string>> Generate(IEnumerable<ILibraryItem> libraryItems, string outputPath, IProgress<ProgressStatus> progress, CancellationToken cancellationToken)
|
||||
public async Task<List<ValidationError>> Generate(IEnumerable<ILibraryItem> libraryItems, string outputPath, IProgress<ProgressStatus> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var firstItem = libraryItems.OfType<ILibraryAsset>().FirstOrDefault();
|
||||
if (firstItem is ILibraryAsset libraryItem)
|
||||
|
|
@ -72,7 +72,14 @@ namespace MatterHackers.MatterControl.Library.Export
|
|||
}
|
||||
}
|
||||
|
||||
return new List<string>() { "Item cannot be exported as STL".Localize() + " " + firstItem != null ? firstItem.ToString() : "" };
|
||||
return new List<ValidationError>()
|
||||
{
|
||||
new ValidationError()
|
||||
{
|
||||
Error = "Item cannot be exported as STL".Localize(),
|
||||
Details = firstItem?.ToString() ?? ""
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ namespace MatterHackers.MatterControl.Library.Export
|
|||
|
||||
public bool ExportPossible(ILibraryAsset libraryItem) => true;
|
||||
|
||||
public async Task<List<string>> Generate(IEnumerable<ILibraryItem> libraryItems, string outputPath, IProgress<ProgressStatus> progress, CancellationToken cancellationToken)
|
||||
public async Task<List<ValidationError>> Generate(IEnumerable<ILibraryItem> libraryItems, string outputPath, IProgress<ProgressStatus> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var streamItems = libraryItems.OfType<ILibraryAssetStream>();
|
||||
if (streamItems.Any())
|
||||
|
|
@ -101,7 +101,13 @@ namespace MatterHackers.MatterControl.Library.Export
|
|||
return null;
|
||||
}
|
||||
|
||||
return new List<string>() { "No Items to Export".Localize() };
|
||||
return new List<ValidationError>()
|
||||
{
|
||||
new ValidationError()
|
||||
{
|
||||
Error = "No Items to Export".Localize()
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -543,14 +543,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
bool doSlicing = !activelySlicing && printer.Bed.EditContext.SourceItem != null;
|
||||
if (doSlicing)
|
||||
{
|
||||
var errors = SettingsValidation.SettingsValid(printer);
|
||||
var errors = printer.ValidateSettings();
|
||||
if(errors.Count > 0)
|
||||
{
|
||||
doSlicing = false;
|
||||
StyledMessageBox.ShowMessageBox(String.Join("\n__________________\n\n", errors.ToArray()), "Slicing Error".Localize());
|
||||
ApplicationController.Instance.ShowValidationErrors("Slicing Error".Localize(), errors);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(doSlicing)
|
||||
{
|
||||
activelySlicing = true;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ using MatterHackers.Localizations;
|
|||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||
|
|
@ -101,11 +102,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
bool doSlicing = !activelySlicing && printer.Bed.EditContext.SourceItem != null;
|
||||
if (doSlicing)
|
||||
{
|
||||
var errors = SettingsValidation.SettingsValid(printer);
|
||||
var errors = printer.ValidateSettings();
|
||||
if (errors.Count > 0)
|
||||
{
|
||||
doSlicing = false;
|
||||
StyledMessageBox.ShowMessageBox(String.Join("\n__________________\n\n", errors.ToArray()), "Slicing Error".Localize());
|
||||
ApplicationController.Instance.ShowValidationErrors("Slicing Error".Localize(), errors);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ namespace MatterHackers.MatterControl.Plugins.X3GDriver
|
|||
|
||||
public override bool ExportPossible(ILibraryAsset libraryItem) => true;
|
||||
|
||||
public override async Task<List<string>> Generate(IEnumerable<ILibraryItem> libraryItems, string outputPath, IProgress<ProgressStatus> progress, CancellationToken cancellationToken)
|
||||
public override async Task<List<ValidationError>> Generate(IEnumerable<ILibraryItem> libraryItems, string outputPath, IProgress<ProgressStatus> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
string gcodePath = Path.ChangeExtension(outputPath, "_gcode");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue