Move MatterControl source code into a subdirectory

This commit is contained in:
Nettika 2026-01-28 21:30:58 -08:00
parent 2c6e34243a
commit 70af2d9ae8
Signed by: nettika
SSH key fingerprint: SHA256:f+PJrfIq49zrQ6dQrHj18b+PJKmAldeAMiGdj8IzXCA
2007 changed files with 13 additions and 8 deletions

View file

@ -0,0 +1,55 @@
/*
Copyright (c) 2018, Lars Brubaker, 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.
*/
using System;
using System.Text.RegularExpressions;
namespace MatterHackers.MatterControl.SlicerConfiguration
{
public class GCodeMacro
{
public string Name { get; set; }
public string GCode { get; set; }
public DateTime LastModified { get; set; }
public static string FixMacroName(string input)
{
int lengthLimit = 24;
string result = Regex.Replace(input, @"\r\n?|\n", " ");
if (result.Length > lengthLimit)
{
result = result.Substring(0, lengthLimit) + "...";
}
return result;
}
}
}

View file

@ -0,0 +1,55 @@
/*
Copyright (c) 2019, Lars Brubaker, 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.
*/
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MatterHackers.Agg;
using MatterHackers.DataConverters3D;
namespace MatterHackers.MatterControl.SlicerConfiguration
{
public enum PrinterType
{
FFF,
SLA
}
public interface IObjectSlicer
{
Task<bool> Slice(IEnumerable<IObject3D> itemsOnBed, PrinterSettings printerSettings, string filePath, Action<double, string> progressReporter, CancellationToken cancellationToken);
Dictionary<string, ExportField> Exports { get; }
PrinterType PrinterType { get; }
bool ValidateFile(string filePath);
}
}

View file

@ -0,0 +1,150 @@
/*
Copyright (c) 2018, Lars Brubaker, 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.
*/
using System;
using System.Collections.Generic;
using MatterHackers.VectorMath;
using MIConvexHull;
namespace MatterHackers.MatterControl.SlicerConfiguration
{
public class PrintLevelingData
{
public PrintLevelingData()
{
}
public List<Vector3> SampledPositions = new List<Vector3>();
public LevelingSystem LevelingSystem { get; set; }
public DateTime CreationDate { get; set; }
public double BedTemperature { get; set; }
public bool IssuedLevelingTempWarning { get; set; }
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;
}
public IEnumerable<(Vector3 v0, Vector3 v1, Vector3 v2)> GetLevelingTriangles()
{
// get the delaunay triangulation
var zDictionary = new Dictionary<(double, double), double>();
var vertices = new List<DefaultVertex>();
if (SampledPositions.Count > 2)
{
foreach (var sample in SampledPositions)
{
vertices.Add(new DefaultVertex()
{
Position = new double[] { sample.X, sample.Y }
});
var key = (sample.X, sample.Y);
if (!zDictionary.ContainsKey(key))
{
zDictionary.Add(key, sample.Z);
}
}
}
else
{
vertices.Add(new DefaultVertex()
{
Position = new double[] { 0, 0 }
});
zDictionary.Add((0, 0), 0);
vertices.Add(new DefaultVertex()
{
Position = new double[] { 200, 0 }
});
zDictionary.Add((200, 0), 0);
vertices.Add(new DefaultVertex()
{
Position = new double[] { 100, 200 }
});
zDictionary.Add((100, 200), 0);
}
int extraXPosition = -50000;
vertices.Add(new DefaultVertex()
{
Position = new double[] { extraXPosition, vertices[0].Position[1] }
});
var positions = new List<(Vector3, Vector3, Vector3)>();
try
{
var triangles = DelaunayTriangulation<DefaultVertex, DefaultTriangulationCell<DefaultVertex>>.Create(vertices, .001);
// make all the triangle planes for these triangles
foreach (var triangle in triangles.Cells)
{
var p0 = triangle.Vertices[0].Position;
var p1 = triangle.Vertices[1].Position;
var p2 = triangle.Vertices[2].Position;
if (p0[0] != extraXPosition && p1[0] != extraXPosition && p2[0] != extraXPosition)
{
var v0 = new Vector3(p0[0], p0[1], zDictionary[(p0[0], p0[1])]);
var v1 = new Vector3(p1[0], p1[1], zDictionary[(p1[0], p1[1])]);
var v2 = new Vector3(p2[0], p2[1], zDictionary[(p2[0], p2[1])]);
// add all the regions
positions.Add((v0, v1, v2));
}
}
}
catch
{
}
foreach(var position in positions)
{
yield return position;
}
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,441 @@
/*
Copyright (c) 2018, Lars Brubaker, 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.
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml;
using SettingsDictionary = System.Collections.Generic.Dictionary<string, string>;
namespace MatterHackers.MatterControl.SlicerConfiguration
{
public class PrinterSettingsLayer : SettingsDictionary
{
public PrinterSettingsLayer() { }
public PrinterSettingsLayer(IDictionary<string, string> settingsDictionary)
{
foreach (var keyValue in settingsDictionary)
{
this[keyValue.Key] = keyValue.Value;
}
}
public string LayerID
{
get
{
string layerKey = ValueOrDefault("layer_id");
if (string.IsNullOrEmpty(layerKey))
{
// Generate a new GUID when missing or empty. We can't do this in the constructor as the dictionary deserialization will fail if
// an existing key exists for layer_id and on new empty layers, we still need to construct an initial identifier.
layerKey = Guid.NewGuid().ToString();
LayerID = layerKey;
}
return layerKey;
}
set => this["layer_id"] = value;
}
public string Name
{
get => ValueOrDefault(SettingsKey.layer_name);
set => this[SettingsKey.layer_name] = value;
}
public string Source
{
get => ValueOrDefault("layer_source");
set => this["layer_source"] = value;
}
public string ETag
{
get => ValueOrDefault("layer_etag");
set => this["layer_etag"] = value;
}
public string ValueOrDefault(string key, string defaultValue = "")
{
this.TryGetValue(key, out string foundValue);
return foundValue ?? defaultValue;
}
public static PrinterSettingsLayer LoadFromIni(TextReader reader)
{
var layer = new PrinterSettingsLayer();
string line;
while ((line = reader.ReadLine()) != null)
{
var segments = line.Split('=');
if (!line.StartsWith("#") && !string.IsNullOrEmpty(line))
{
string key = segments[0].Trim();
layer[key] = segments[1].Trim();
}
}
return layer;
}
public static PrinterSettingsLayer LoadFromIni(string filePath)
{
var settings = from line in File.ReadAllLines(filePath)
let segments = line.Split('=')
where !line.StartsWith("#") && !string.IsNullOrEmpty(line) && segments.Length == 2
select new
{
Key = segments[0].Trim(),
Value = segments[1].Trim()
};
var layer = new PrinterSettingsLayer();
foreach (var setting in settings)
{
layer[setting.Key] = setting.Value;
}
return layer;
}
public PrinterSettingsLayer Clone()
{
string id = Guid.NewGuid().ToString();
return new PrinterSettingsLayer(this)
{
LayerID = id,
Name = this.Name,
ETag = this.ETag,
Source = this.Source
};
}
public static Dictionary<string, PrinterSettingsLayer> LoadMaterialSettingsFromFff(string settingsFilePath)
{
return LoadNamedSettigs(settingsFilePath, "autoConfigureMaterial");
}
private static Dictionary<string, PrinterSettingsLayer> LoadNamedSettigs(string settingsFilePath, string xmlNodes)
{
var xmlDoc = new XmlDocument();
xmlDoc.Load(settingsFilePath);
var profile = xmlDoc.SelectSingleNode("profile");
profile.ReadNumber("defaultSpeed", out double defaultSpeed, (value) => value / 60.0);
var materials = new Dictionary<string, PrinterSettingsLayer>();
var materialNodes = profile.SelectNodes(xmlNodes);
for (var i = 0; i < materialNodes.Count; i++)
{
var materialNode = materialNodes[i];
var material = new PrinterSettingsLayer();
materialNode.ReadSettings(material, false, defaultSpeed);
var materialName = materialNode.Attributes["name"].InnerText;
material[SettingsKey.layer_name] = materialName;
materials.Add(materialName, material);
}
return materials;
}
public static Dictionary<string, PrinterSettingsLayer> LoadQualitySettingsFromFff(string settingsFilePath)
{
return LoadNamedSettigs(settingsFilePath, "autoConfigureQuality");
}
public static PrinterSettingsLayer LoadFromFff(string settingsFilePath)
{
var xmlDoc = new XmlDocument();
xmlDoc.Load(settingsFilePath);
var profile = xmlDoc.SelectSingleNode("profile");
var layer = new PrinterSettingsLayer();
layer[SettingsKey.printer_name] = profile.Attributes["name"].InnerText;
profile.ReadNumber("defaultSpeed", out double defaultSpeed, (value) => value / 60.0);
profile.ReadSettings(layer, true, defaultSpeed);
return layer;
}
}
public static class XmlDocSettingsReader
{
public static void ReadSettings(this XmlNode profile, PrinterSettingsLayer layer, bool inculdePrinterSettings, double defaultSpeed)
{
if (inculdePrinterSettings)
{
// printer hardware settings
profile.SetNumber(layer, "toolheadNumber", SettingsKey.extruder_count);
profile.SetNumber(layer, "baudRateOverride", SettingsKey.baud_rate);
profile.SetNumber(layer, "filamentDiameters", SettingsKey.filament_diameter);
// bed setting
profile.ReadNumber("strokeXoverride", out double xSize);
profile.ReadNumber("strokeYoverride", out double ySize);
layer[SettingsKey.bed_size] = $"{xSize},{ySize}";
profile.SetNumber(layer, "strokeZoverride", SettingsKey.build_height);
profile.ReadNumber("originOffsetXoverride", out double xOrigin);
profile.ReadNumber("originOffsetYoverride", out double yOrigin);
layer[SettingsKey.print_center] = $"{xSize / 2 - xOrigin},{ySize / 2 - yOrigin}";
profile.ReadNumber("machineTypeOverride", out double machineType);
if (machineType == 1)
{
layer[SettingsKey.bed_shape] = "circular";
}
// homing info
profile.ReadNumber("homeZdirOverride", out double zDir);
if (zDir == 1)
{
layer[SettingsKey.z_homes_to_max] = "1";
}
}
profile.SetCommaString(layer, "startingGcode", SettingsKey.start_gcode);
if (inculdePrinterSettings
&& layer.ContainsKey(SettingsKey.start_gcode)
&& layer[SettingsKey.start_gcode].Contains("G29") == true)
{
layer[SettingsKey.has_hardware_leveling] = "1";
}
profile.SetCommaString(layer, "endingGcode", SettingsKey.end_gcode);
// default material settings
profile.Set(layer, "printMaterial", "printMaterial");
profile.Set(layer, "printQuality", "printQuality");
profile.SetNumber(layer, "filamentDensities", SettingsKey.filament_density);
profile.SetNumber(layer, "filamentPricesPerKg", SettingsKey.filament_cost);
// layers
profile.SetNumber(layer, "layerHeight", SettingsKey.layer_height);
profile.SetNumber(layer, "topSolidLayers", SettingsKey.top_solid_layers);
profile.SetNumber(layer, "bottomSolidLayers", SettingsKey.bottom_solid_layers);
profile.SetNumber(layer, "externalInfillAngles", SettingsKey.fill_angle);
profile.SetPercent(layer, "infillPercentage", SettingsKey.fill_density);
// speeds
profile.SetNumber(layer, "defaultSpeed", SettingsKey.infill_speed, (value) => value / 60.0);
if (layer.ContainsKey(SettingsKey.infill_speed))
{
defaultSpeed = double.Parse(layer[SettingsKey.infill_speed]);
}
profile.SetPercent(layer, "firstLayerUnderspeed", SettingsKey.first_layer_speed, (value) => value * 100);
layer[SettingsKey.perimeter_speed] = defaultSpeed.ToString();
layer[SettingsKey.interface_layer_speed] = defaultSpeed.ToString();
profile.SetPercent(layer, "outlineUnderspeed", SettingsKey.external_perimeter_speed, (value) => value * 100);
profile.SetPercent(layer, "solidInfillUnderspeed", SettingsKey.top_solid_infill_speed, (value) => value * 100);
profile.SetNumber(layer, "supportUnderspeed", SettingsKey.support_material_speed, (value) => value * defaultSpeed);
profile.SetNumber(layer, "bridgingSpeedMultiplier", SettingsKey.bridge_speed, (value) => value * defaultSpeed);
profile.SetNumber(layer, "rapidXYspeed", SettingsKey.travel_speed, (value) => value / 60.0);
// perimeters
profile.SetNumber(layer, "perimeterOutlines", SettingsKey.perimeters);
profile.SetBool(layer, "printPerimetersInsideOut", SettingsKey.external_perimeters_first, true);
profile.SetBool(layer, "avoidCrossingOutline", SettingsKey.avoid_crossing_perimeters);
profile.SetBool(layer, "maxMovementDetourFactor", SettingsKey.avoid_crossing_max_ratio);
// support
profile.SetNumber(layer, "supportGridSpacing", SettingsKey.support_material_spacing);
profile.SetNumber(layer, "supportAngles", SettingsKey.support_material_infill_angle);
profile.SetNumber(layer, "maxOverhangAngle", SettingsKey.fill_angle);
// raft settings
profile.SetBool(layer, "useRaft", SettingsKey.create_raft);
profile.SetNumber(layer, "raftExtruder", SettingsKey.raft_extruder);
profile.SetNumber(layer, "raftOffset", SettingsKey.raft_extra_distance_around_part);
profile.SetNumber(layer, "raftSeparationDistance", SettingsKey.raft_air_gap);
// skirt settings
profile.SetBool(layer, "useSkirt", SettingsKey.create_skirt);
profile.SetNumber(layer, "skirtOffset", SettingsKey.skirt_distance);
profile.SetNumber(layer, "skirtOutlines", SettingsKey.skirts);
// fan settings
if (profile.IsSet("adjustSpeedForCooling"))
{
profile.SetNumber(layer, "minSpeedLayerTime", SettingsKey.slowdown_below_layer_time);
// profile.SetNumber(layer, "minCoolingSpeedSlowdown", SettingsKey.);
}
profile.SetNumber(layer, "bridgingFanSpeed", SettingsKey.bridge_fan_speed);
// extruder
var extruder = profile.SelectSingleNode("extruder");
if (extruder != null)
{
if (inculdePrinterSettings)
{
extruder.SetNumber(layer, "diameter", SettingsKey.nozzle_diameter);
}
extruder.SetNumber(layer, "extrusionMultiplier", SettingsKey.extrusion_multiplier);
extruder.SetNumber(layer, "retractionSpeed", SettingsKey.retract_speed);
extruder.SetNumber(layer, "retractionDistance", SettingsKey.retract_length);
extruder.SetNumber(layer, "extraRestartDistance", SettingsKey.retract_restart_extra);
extruder.SetNumber(layer, "retractionZLift", SettingsKey.retract_lift);
extruder.SetNumber(layer, "coastingDistance", SettingsKey.coast_at_end_distance, (rawValue) =>
{
if (extruder.IsSet("useCoasting"))
{
return rawValue;
}
return 0;
});
}
var tempControlers = profile.SelectNodes("temperatureController");
for (var i = 0; i < tempControlers.Count; i++)
{
var tempControler = tempControlers[i];
var innerText = tempControler.InnerText;
var bed = tempControler.SelectNodes("isHeatedBed")[0].InnerText;
if (bed == "1")
{
layer[SettingsKey.bed_temperature] = tempControler.SelectNodes("setpoint")[0].Attributes["temperature"].InnerText;
}
else
{
layer[SettingsKey.temperature] = tempControler.SelectNodes("setpoint")[0].Attributes["temperature"].InnerText;
}
}
}
public static void SetNumber(this XmlNode node,
PrinterSettingsLayer layer,
string fffSetting,
string mcSetting,
Func<double, double> convert = null)
{
// read valid settings and map
if (node.ReadNumber(fffSetting, out double result, convert))
{
layer[mcSetting] = result.ToString();
}
}
public static void SetPercent(this XmlNode node,
PrinterSettingsLayer layer,
string fffSetting,
string mcSetting,
Func<double, double> convert = null)
{
// read valid settings and map
if (node.ReadNumber(fffSetting, out double result, convert))
{
layer[mcSetting] = result.ToString() + "%";
}
}
public static bool ReadNumber(this XmlNode node, string fffSetting, out double value, Func<double, double> convert = null)
{
value = double.MinValue;
// read valid settings and map
var settings = node.SelectNodes(fffSetting);
if (settings.Count > 0)
{
var innerText = settings[0].InnerText;
if (innerText.Contains('|'))
{
innerText = innerText.Split('|')[0];
}
if (double.TryParse(innerText, out double result))
{
if (convert != null)
{
result = convert(result);
}
value = result;
return true;
}
}
return false;
}
public static void SetBool(this XmlNode node, PrinterSettingsLayer layer, string fffSetting, string mcSetting, bool invert = false)
{
var settings = node.SelectNodes(fffSetting);
if (settings.Count > 0)
{
if (double.TryParse(settings[0].InnerText, out double result))
{
var value = result == 1 ? true : false;
value = invert ? !value : value;
layer[mcSetting] = value ? "1" : "0";
}
}
}
public static void Set(this XmlNode node, PrinterSettingsLayer layer, string fffSetting, string mcSetting)
{
// read valid settings and map
var settings = node.SelectNodes(fffSetting);
if (settings.Count > 0)
{
layer[mcSetting] = settings[0].InnerText;
}
}
public static bool IsSet(this XmlNode node, string fffSetting)
{
// read valid settings and map
var settings = node.SelectNodes(fffSetting);
if (settings.Count > 0)
{
if (settings[0].InnerText == "1")
{
return true;
}
}
return false;
}
public static void SetCommaString(this XmlNode node, PrinterSettingsLayer layer, string fffSetting, string mcSetting)
{
// read valid settings and map
var settings = node.SelectNodes(fffSetting);
if (settings.Count > 0)
{
var gCode = settings[0].InnerText;
// do some string replacements
gCode = gCode.Replace("bed0_temperature", "bed_temperature");
gCode = gCode.Replace("extruder0_temperature", "temperature");
layer[mcSetting] = gCode.Replace(",", "\\n");
}
}
}
}

View file

@ -0,0 +1,119 @@
/*
Copyright (c) 2016, Lars Brubaker, 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.
*/
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System;
using System.IO;
using Newtonsoft.Json.Linq;
using System.Text;
namespace MatterHackers.MatterControl.SlicerConfiguration
{
public static class ProfileMigrations
{
public static string MigrateDocument(string filePath, int fromVersion = -1)
{
var jObject = JObject.Parse(File.ReadAllText(filePath));
/*
if (fromVersion < 201605131)
{
var materialLayers = jObject["MaterialLayers"] as JObject;
if (materialLayers != null)
{
foreach (JProperty layer in materialLayers.Properties().ToList())
{
layer.Remove();
string layerID = Guid.NewGuid().ToString();
var body = layer.Value as JObject;
body["MatterControl.LayerID"] = layerID;
body["MatterControl.LayerName"] = layer.Name;
materialLayers[layerID] = layer.Value;
}
}
var qualityLayers = jObject["QualityLayers"] as JObject;
if (qualityLayers != null)
{
foreach (JProperty layer in qualityLayers.Properties().ToList())
{
layer.Remove();
string layerID = Guid.NewGuid().ToString();
var body = layer.Value as JObject;
body["MatterControl.LayerID"] = layerID;
body["MatterControl.LayerName"] = layer.Name;
qualityLayers[layerID] = layer.Value;
}
}
jObject["DocumentVersion"] = 201605131;
}
if (fromVersion < 201605132)
{
string printerID = Guid.NewGuid().ToString();
jObject.Remove("DocumentPath");
jObject["ID"] = printerID;
jObject["DocumentVersion"] = 201605132;
File.Delete(filePath);
filePath = Path.Combine(Path.GetDirectoryName(filePath), printerID + ProfileManager.ProfileExtension);
}
*/
if (fromVersion < 201606271)
{
JObject oemProfile = jObject["OemProfile"] as JObject;
if (oemProfile != null)
{
jObject.Property("OemProfile").Remove();
jObject["OemLayer"] = oemProfile["OemLayer"];
}
jObject["DocumentVersion"] = 201606271;
}
File.WriteAllText(
filePath,
JsonConvert.SerializeObject(jObject, Formatting.Indented));
return filePath;
}
}
}

View file

@ -0,0 +1,427 @@
/*
Copyright (c) 2019, Lars Brubaker, 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.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using MatterHackers.VectorMath;
using Newtonsoft.Json;
namespace MatterHackers.MatterControl.SlicerConfiguration
{
public class SettingsHelpers
{
private readonly PrinterSettings printerSettings;
private PrintLevelingData _printLevelingData = null;
public SettingsHelpers(PrinterSettings printerSettings)
{
this.printerSettings = printerSettings;
}
public double ExtruderTargetTemperature(int extruderIndex)
{
if (extruderIndex == 0)
{
return printerSettings.GetValue<double>(SettingsKey.temperature);
}
else
{
// Check if there is a material override for this extruder
// Otherwise, use the SettingsLayers that is bound to this extruder
if (extruderIndex < printerSettings.GetValue<int>(SettingsKey.extruder_count))
{
return printerSettings.GetValue<double>($"{SettingsKey.temperature}{extruderIndex}");
}
// else return the normal settings cascade
return printerSettings.GetValue<double>(SettingsKey.temperature);
}
}
public int[] LayerToPauseOn()
{
string[] userValues = printerSettings.GetValue("layer_to_pause").Split(';');
return userValues.Where(v => int.TryParse(v, out int temp)).Select(v =>
{
// Convert from 0 based index to 1 based index
int val = int.Parse(v);
// Special case for user entered zero that pushes 0 to 1, otherwise val = val - 1 for 1 based index
return val == 0 ? 1 : val - 1;
}).ToArray();
}
public void SetBaudRate(string baudRate)
{
printerSettings.SetValue(SettingsKey.baud_rate, baudRate);
}
public string ComPort()
{
return printerSettings.GetValue($"{Environment.MachineName}_com_port");
}
public void SetComPort(string port)
{
printerSettings.SetValue($"{Environment.MachineName}_com_port", port);
}
public void SetComPort(string port, PrinterSettingsLayer layer)
{
printerSettings.SetValue($"{Environment.MachineName}_com_port", port, layer);
}
public void SetDriverType(string driver)
{
printerSettings.SetValue(SettingsKey.driver_type, driver);
}
public void SetDeviceToken(string token)
{
if (printerSettings.GetValue(SettingsKey.device_token) != token)
{
printerSettings.SetValue(SettingsKey.device_token, token);
}
}
public void SetName(string name)
{
printerSettings.SetValue(SettingsKey.printer_name, name);
}
public PrintLevelingData PrintLevelingData
{
get
{
if (_printLevelingData == null)
{
// Load from settings if missing
var jsonData = printerSettings.GetValue(SettingsKey.print_leveling_data);
if (!string.IsNullOrEmpty(jsonData))
{
_printLevelingData = JsonConvert.DeserializeObject<PrintLevelingData>(jsonData);
}
// TODO: When this case is hit, it's certain to produce impossible to troubleshoot behavior where leveled printers suddenly act erratically.
// Investigate a better solution - ideally we'd mark that leveling is invalid and have a validation error preventing printing/export/general use
if (_printLevelingData == null)
{
_printLevelingData = new PrintLevelingData();
}
}
return _printLevelingData;
}
set
{
// Store new reference
_printLevelingData = value;
// Persist to settings
printerSettings.SetValue(SettingsKey.print_leveling_data, JsonConvert.SerializeObject(value));
}
}
private readonly List<(Regex Regex, string Replacement)> _writeLineReplacements = new List<(Regex Regex, string Replacement)>();
private string writeRegexString = "";
private static readonly Regex GetQuotedParts = new Regex(@"([""'])(\\?.)*?\1", RegexOptions.Compiled);
public List<(Regex Regex, string Replacement)> WriteLineReplacements
{
get
{
lock (_writeLineReplacements)
{
if (writeRegexString != printerSettings.GetValue(SettingsKey.write_regex))
{
_writeLineReplacements.Clear();
writeRegexString = printerSettings.GetValue(SettingsKey.write_regex);
foreach (string regExLine in writeRegexString.Split(new string[] { "\\n" }, StringSplitOptions.RemoveEmptyEntries))
{
var matches = GetQuotedParts.Matches(regExLine);
if (matches.Count == 2)
{
var search = matches[0].Value.Substring(1, matches[0].Value.Length - 2);
var replace = matches[1].Value.Substring(1, matches[1].Value.Length - 2);
_writeLineReplacements.Add((new Regex(search, RegexOptions.Compiled), replace));
}
}
}
}
return _writeLineReplacements;
}
}
public bool ProbeBeingUsed
{
get
{
return printerSettings.GetValue<bool>(SettingsKey.has_z_probe)
&& printerSettings.GetValue<bool>(SettingsKey.use_z_probe);
}
}
public bool ValidateLevelingWithProbe
{
get
{
return ProbeBeingUsed
&& printerSettings.GetValue<bool>(SettingsKey.validate_leveling);
}
}
public bool ActiveMaterialHasAnyBedTemperatures
{
get
{
void IncrementIfSet(string settingKey, ref int count)
{
var materialBedTemp = printerSettings.GetValue<double>(settingKey, printerSettings.MaterialLayerCascade);
if (materialBedTemp > 0)
{
count++;
}
}
var bedTemperatureCount = 0;
IncrementIfSet(SettingsKey.bed_temperature_blue_tape, ref bedTemperatureCount);
IncrementIfSet(SettingsKey.bed_temperature_buildtak, ref bedTemperatureCount);
IncrementIfSet(SettingsKey.bed_temperature_garolite, ref bedTemperatureCount);
IncrementIfSet(SettingsKey.bed_temperature_glass, ref bedTemperatureCount);
IncrementIfSet(SettingsKey.bed_temperature_kapton, ref bedTemperatureCount);
IncrementIfSet(SettingsKey.bed_temperature_pei, ref bedTemperatureCount);
IncrementIfSet(SettingsKey.bed_temperature_pp, ref bedTemperatureCount);
return bedTemperatureCount > 0;
}
}
public double ActiveBedTemperature
{
get
{
return printerSettings.GetValue<double>(ActiveBedTemperatureSetting);
}
}
public string ActiveBedTemperatureSetting
{
get
{
if (!printerSettings.GetValue<bool>(SettingsKey.has_swappable_bed)
|| !ActiveMaterialHasAnyBedTemperatures)
{
return SettingsKey.bed_temperature;
}
switch (printerSettings.GetValue(SettingsKey.bed_surface))
{
case "Blue Tape":
return SettingsKey.bed_temperature_blue_tape;
case "BuildTak":
return SettingsKey.bed_temperature_buildtak;
case "Garolite":
return SettingsKey.bed_temperature_garolite;
case "Glass":
return SettingsKey.bed_temperature_glass;
case "Kapton":
return SettingsKey.bed_temperature_kapton;
case "PEI":
return SettingsKey.bed_temperature_pei;
case "Polypropylene":
return SettingsKey.bed_temperature_pp;
default:
return SettingsKey.bed_temperature;
}
}
}
public void DoPrintLeveling(bool doLeveling)
{
// Early exit if already set
if (doLeveling == printerSettings.GetValue<bool>(SettingsKey.print_leveling_enabled))
{
return;
}
printerSettings.SetValue(SettingsKey.print_leveling_enabled, doLeveling ? "1" : "0");
printerSettings.OnPrintLevelingEnabledChanged(this, null);
}
public void SetExtruderZOffset(int extruderIndex, double newZOffset)
{
// Get the existing offset, update Z, persist
var offset = this.ExtruderOffset(extruderIndex);
offset.Z = newZOffset;
this.SetExtruderOffset(extruderIndex, offset);
}
public void SetExtruderOffset(int extruderIndex, Vector3 newOffset)
{
var offsetsVector3 = new List<Vector3>();
string currentOffsets = printerSettings.GetValue(SettingsKey.extruder_offset);
string[] offsets = currentOffsets.Split(',');
foreach (string offset in offsets)
{
string[] xyz = offset.Split('x');
if (xyz.Length == 2)
{
var zOffset = printerSettings.GetValue<double>(SettingsKey.z_offset);
offsetsVector3.Add(new Vector3(double.Parse(xyz[0]), double.Parse(xyz[1]), -zOffset));
}
else
{
offsetsVector3.Add(new Vector3(double.Parse(xyz[0]), double.Parse(xyz[1]), double.Parse(xyz[2])));
}
}
while (offsetsVector3.Count <= extruderIndex)
{
offsetsVector3.Add(Vector3.Zero);
}
offsetsVector3[extruderIndex] = newOffset;
// now save it
var first = true;
var newValue = "";
foreach (var offset in offsetsVector3)
{
if (!first)
{
newValue += ",";
}
newValue += $"{offset.X:0.###}x{offset.Y:0.###}x{offset.Z:0.###}";
first = false;
}
printerSettings.SetValue(SettingsKey.extruder_offset, newValue);
}
public Vector3 ExtruderOffset(int extruderIndex)
{
string currentOffsets = printerSettings.GetValue(SettingsKey.extruder_offset);
string[] offsets = currentOffsets.Split(',');
int count = 0;
foreach (string offset in offsets)
{
if (count == extruderIndex)
{
string[] xyz = offset.Split('x');
if (xyz.Length == 2)
{
// Import deprecated z_offset data if missing
var zOffset = printerSettings.GetValue<double>(SettingsKey.z_offset);
return new Vector3(double.Parse(xyz[0]), double.Parse(xyz[1]), -zOffset);
}
else
{
return new Vector3(double.Parse(xyz[0]), double.Parse(xyz[1]), double.Parse(xyz[2]));
}
}
count++;
}
return Vector3.Zero;
}
public Vector3 ManualMovementSpeeds()
{
var feedRate = new Vector3(3000, 3000, 315);
string savedSettings = printerSettings.GetValue(SettingsKey.manual_movement_speeds);
if (!string.IsNullOrEmpty(savedSettings))
{
var segments = savedSettings.Split(',');
feedRate.X = double.Parse(segments[1]);
feedRate.Y = double.Parse(segments[3]);
feedRate.Z = double.Parse(segments[5]);
}
return feedRate;
}
public Dictionary<string, double> GetMovementSpeeds()
{
var speeds = new Dictionary<string, double>();
string movementSpeedsString = GetMovementSpeedsString();
string[] allSpeeds = movementSpeedsString.Split(',');
for (int i = 0; i < allSpeeds.Length / 2; i++)
{
speeds.Add(allSpeeds[i * 2 + 0], double.Parse(allSpeeds[i * 2 + 1]));
}
return speeds;
}
public string GetMovementSpeedsString()
{
string presets = "x,3000,y,3000,z,315,e0,150"; // stored x,value,y,value,z,value,e1,value,e2,value,e3,value,...
string savedSettings = printerSettings.GetValue(SettingsKey.manual_movement_speeds);
if (!string.IsNullOrEmpty(savedSettings))
{
presets = savedSettings;
}
return presets;
}
public int HotendCount()
{
if (printerSettings.GetValue<bool>(SettingsKey.extruders_share_temperature))
{
return 1;
}
return printerSettings.GetValue<int>(SettingsKey.extruder_count);
}
}
}

View file

@ -0,0 +1,324 @@
/*
Copyright (c) 2018, Lars Brubaker, 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.SlicerConfiguration
{
public static class SettingsKey
{
public const string active_material_key = nameof(active_material_key);
public const string active_quality_key = nameof(active_quality_key);
public const string additional_printing_errors = nameof(additional_printing_errors);
public const string air_gap_speed = nameof(air_gap_speed);
public const string auto_connect = nameof(auto_connect);
public const string auto_release_motors = nameof(auto_release_motors);
public const string avoid_crossing_max_ratio = nameof(avoid_crossing_max_ratio);
public const string avoid_crossing_perimeters = nameof(avoid_crossing_perimeters);
public const string baby_step_z_offset = nameof(baby_step_z_offset);
public const string backup_firmware_before_update = nameof(backup_firmware_before_update);
public const string baud_rate = nameof(baud_rate);
public const string bed_remove_part_temperature = nameof(bed_remove_part_temperature);
public const string bed_shape = nameof(bed_shape);
public const string bed_size = nameof(bed_size);
public const string bed_surface = nameof(bed_surface);
public const string bed_temperature = nameof(bed_temperature);
public const string bed_temperature_blue_tape = nameof(bed_temperature_blue_tape);
public const string bed_temperature_buildtak = nameof(bed_temperature_buildtak);
public const string bed_temperature_garolite = nameof(bed_temperature_garolite);
public const string bed_temperature_glass = nameof(bed_temperature_glass);
public const string bed_temperature_kapton = nameof(bed_temperature_kapton);
public const string bed_temperature_pei = nameof(bed_temperature_pei);
public const string bed_temperature_pp = nameof(bed_temperature_pp);
public const string before_toolchange_gcode = nameof(before_toolchange_gcode);
public const string before_toolchange_gcode_1 = nameof(before_toolchange_gcode_1);
public const string before_toolchange_gcode_2 = nameof(before_toolchange_gcode_2);
public const string before_toolchange_gcode_3 = nameof(before_toolchange_gcode_3);
public const string bottom_infill_speed = nameof(bottom_infill_speed);
public const string bottom_solid_layers = nameof(bottom_solid_layers);
public const string bridge_fan_speed = nameof(bridge_fan_speed);
public const string bridge_over_infill = nameof(bridge_over_infill);
public const string bridge_speed = nameof(bridge_speed);
public const string brim_extruder = nameof(brim_extruder);
public const string brims = nameof(brims);
public const string brims_layers = nameof(brims_layers);
public const string build_height = nameof(build_height);
public const string calibration_files = nameof(calibration_files);
public const string cancel_gcode = nameof(cancel_gcode);
public const string clear_bed_gcode = nameof(clear_bed_gcode);
public const string coast_at_end_distance = nameof(coast_at_end_distance);
public const string com_port = nameof(com_port);
public const string complete_objects = nameof(complete_objects);
public const string conductive_pad_center = nameof(conductive_pad_center);
public const string conductive_probe_min_z = nameof(conductive_probe_min_z);
public const string connect_gcode = nameof(connect_gcode);
public const string cool_extruder_lift = nameof(cool_extruder_lift);
public const string cooling = nameof(cooling);
public const string create_brim = nameof(create_brim);
public const string create_per_layer_internal_support = nameof(create_per_layer_internal_support);
public const string create_per_layer_support = nameof(create_per_layer_support);
public const string create_raft = nameof(create_raft);
public const string create_skirt = nameof(create_skirt);
public const string created_date = nameof(created_date);
public const string default_acceleration = nameof(default_acceleration);
public const string default_material_presets = nameof(default_material_presets);
public const string device_token = nameof(device_token);
public const string device_type = nameof(device_type);
public const string disable_fan_first_layers = nameof(disable_fan_first_layers);
public const string driver_type = nameof(driver_type);
public const string emulate_endstops = nameof(emulate_endstops);
public const string enable_fan = nameof(enable_fan);
public const string enable_firmware_sounds = nameof(enable_firmware_sounds);
public const string enable_line_splitting = nameof(enable_line_splitting);
public const string enable_network_printing = nameof(enable_network_printing);
public const string enable_retractions = nameof(enable_retractions);
public const string enable_sailfish_communication = nameof(enable_sailfish_communication);
public const string end_gcode = nameof(end_gcode);
public const string expand_thin_walls = nameof(expand_thin_walls);
public const string external_perimeter_extrusion_width = nameof(external_perimeter_extrusion_width);
public const string external_perimeter_speed = nameof(external_perimeter_speed);
public const string external_perimeters_first = nameof(external_perimeters_first);
public const string extruder_count = nameof(extruder_count);
public const string extruder_offset = nameof(extruder_offset);
public const string extruder_wipe_temperature = nameof(extruder_wipe_temperature);
public const string extruders_share_temperature = nameof(extruders_share_temperature);
public const string extrusion_multiplier = nameof(extrusion_multiplier);
public const string extrusion_ratio = nameof(extrusion_ratio);
public const string feedrate_ratio = nameof(feedrate_ratio);
public const string filament_1_has_been_loaded = nameof(filament_1_has_been_loaded);
public const string filament_cost = nameof(filament_cost);
public const string filament_density = nameof(filament_density);
public const string filament_diameter = nameof(filament_diameter);
public const string filament_has_been_loaded = nameof(filament_has_been_loaded);
public const string filament_runout_sensor = nameof(filament_runout_sensor);
public const string fill_angle = nameof(fill_angle);
public const string fill_density = nameof(fill_density);
public const string fill_pattern = nameof(fill_pattern);
public const string fill_thin_gaps = nameof(fill_thin_gaps);
public const string firmware_type = nameof(firmware_type);
public const string first_layer_bed_temperature = nameof(first_layer_bed_temperature);
public const string first_layer_extrusion_width = nameof(first_layer_extrusion_width);
public const string first_layer_height = nameof(first_layer_height);
public const string first_layer_speed = nameof(first_layer_speed);
public const string first_layer_temperature = nameof(first_layer_temperature);
public const string fuzzy_thickness = nameof(fuzzy_thickness);
public const string fuzzy_frequency = nameof(fuzzy_frequency);
public const string g0 = nameof(g0);
public const string has_c_axis = nameof(has_c_axis);
public const string has_conductive_nozzle = nameof(has_conductive_nozzle);
public const string has_fan = nameof(has_fan);
public const string has_fan_per_extruder = nameof(has_fan_per_extruder);
public const string has_hardware_leveling = nameof(has_hardware_leveling);
public const string has_heated_bed = nameof(has_heated_bed);
public const string has_independent_z_motors = nameof(has_independent_z_motors);
public const string has_power_control = nameof(has_power_control);
public const string has_sd_card_reader = nameof(has_sd_card_reader);
public const string has_swappable_bed = nameof(has_swappable_bed);
public const string has_z_probe = nameof(has_z_probe);
public const string has_z_servo = nameof(has_z_servo);
public const string heat_extruder_before_homing = nameof(heat_extruder_before_homing);
public const string inactive_cool_down = nameof(inactive_cool_down);
public const string include_firmware_updater = nameof(include_firmware_updater);
public const string infill_overlap_perimeter = nameof(infill_overlap_perimeter);
public const string infill_speed = nameof(infill_speed);
public const string infill_type = nameof(infill_type);
public const string insert_filament_1_markdown = nameof(insert_filament_1_markdown);
public const string insert_filament_markdown2 = nameof(insert_filament_markdown2);
public const string interface_layer_speed = nameof(interface_layer_speed);
public const string ip_address = nameof(ip_address);
public const string ip_port = nameof(ip_port);
public const string jerk_velocity = nameof(jerk_velocity);
public const string laser_speed_025 = nameof(laser_speed_025);
public const string laser_speed_100 = nameof(laser_speed_100);
public const string layer_gcode = nameof(layer_gcode);
public const string layer_height = nameof(layer_height);
public const string layer_name = nameof(layer_name);
public const string layer_to_pause = nameof(layer_to_pause);
public const string leveling_sample_points = nameof(leveling_sample_points);
public const string load_filament_length = nameof(load_filament_length);
public const string load_filament_speed = nameof(load_filament_speed);
public const string make = nameof(make);
public const string manual_movement_speeds = nameof(manual_movement_speeds);
public const string material_color = nameof(material_color);
public const string material_color_1 = nameof(material_color_1);
public const string material_color_2 = nameof(material_color_2);
public const string material_color_3 = nameof(material_color_3);
public const string material_sku = nameof(material_sku);
public const string max_acceleration = nameof(max_acceleration);
public const string max_fan_speed = nameof(max_fan_speed);
public const string max_fan_speed_layer_time = nameof(max_fan_speed_layer_time);
public const string max_print_speed = nameof(max_print_speed);
public const string max_velocity = nameof(max_velocity);
public const string measure_probe_offset_conductively = nameof(measure_probe_offset_conductively);
public const string merge_overlapping_lines = nameof(merge_overlapping_lines);
public const string min_extrusion_before_retract = nameof(min_extrusion_before_retract);
public const string min_fan_speed = nameof(min_fan_speed);
public const string min_fan_speed_absolute = nameof(min_fan_speed_absolute);
public const string min_fan_speed_layer_time = nameof(min_fan_speed_layer_time);
public const string min_print_speed = nameof(min_print_speed);
public const string min_skirt_length = nameof(min_skirt_length);
public const string model = nameof(model);
public const string monotonic_solid_infill = nameof(monotonic_solid_infill);
public const string nozzle_diameter = nameof(nozzle_diameter);
public const string number_of_first_layers = nameof(number_of_first_layers);
public const string oem_profile_token = nameof(oem_profile_token);
public const string output_only_first_layer = nameof(output_only_first_layer);
public const string pause_gcode = nameof(pause_gcode);
public const string perimeter_acceleration = nameof(perimeter_acceleration);
public const string perimeter_extrusion_width = nameof(perimeter_extrusion_width);
public const string perimeter_speed = nameof(perimeter_speed);
public const string perimeter_start_end_overlap = nameof(perimeter_start_end_overlap);
public const string perimeters = nameof(perimeters);
public const string print_center = nameof(print_center);
public const string print_leveling_data = nameof(print_leveling_data);
public const string print_leveling_enabled = nameof(print_leveling_enabled);
public const string print_leveling_insets = nameof(print_leveling_insets);
public const string print_leveling_probe_start = nameof(print_leveling_probe_start);
public const string print_leveling_required_to_print = nameof(print_leveling_required_to_print);
public const string print_leveling_solution = nameof(print_leveling_solution);
public const string print_time_estimate_multiplier = nameof(print_time_estimate_multiplier);
public const string printer_name = nameof(printer_name);
public const string printer_sku = nameof(printer_sku);
public const string probe_has_been_calibrated = nameof(probe_has_been_calibrated);
public const string probe_offset = nameof(probe_offset);
public const string progress_reporting = nameof(progress_reporting);
public const string publish_bed_image = nameof(publish_bed_image);
public const string raft_air_gap = nameof(raft_air_gap);
public const string raft_extra_distance_around_part = nameof(raft_extra_distance_around_part);
public const string raft_extruder = nameof(raft_extruder);
public const string raft_layers = nameof(raft_layers);
public const string raft_print_speed = nameof(raft_print_speed);
public const string read_regex = nameof(read_regex);
public const string recover_first_layer_speed = nameof(recover_first_layer_speed);
public const string recover_is_enabled = nameof(recover_is_enabled);
public const string recover_position_before_z_home = nameof(recover_position_before_z_home);
public const string repair_outlines_extensive_stitching = nameof(repair_outlines_extensive_stitching);
public const string repair_outlines_keep_open = nameof(repair_outlines_keep_open);
public const string report_runout_sensor_data = nameof(report_runout_sensor_data);
public const string reset_long_extrusion = nameof(reset_long_extrusion);
public const string resin_cost = nameof(resin_cost);
public const string resin_density = nameof(resin_density);
public const string resume_gcode = nameof(resume_gcode);
public const string retract_before_travel = nameof(retract_before_travel);
public const string retract_before_travel_avoid = nameof(retract_before_travel_avoid);
public const string retract_length = nameof(retract_length);
public const string retract_length_tool_change = nameof(retract_length_tool_change);
public const string retract_lift = nameof(retract_lift);
public const string retract_restart_extra = nameof(retract_restart_extra);
public const string retract_restart_extra_time_to_apply = nameof(retract_restart_extra_time_to_apply);
public const string retract_restart_extra_toolchange = nameof(retract_restart_extra_toolchange);
public const string retract_speed = nameof(retract_speed);
public const string retract_when_changing_islands = nameof(retract_when_changing_islands);
public const string running_clean_1_markdown = nameof(running_clean_1_markdown);
public const string running_clean_markdown2 = nameof(running_clean_markdown2);
public const string runout_sensor_check_distance = nameof(runout_sensor_check_distance);
public const string runout_sensor_trigger_ratio = nameof(runout_sensor_trigger_ratio);
public const string seam_placement = nameof(seam_placement);
public const string seconds_to_reheat = nameof(seconds_to_reheat);
public const string selector_ip_address = nameof(selector_ip_address);
public const string send_with_checksum = nameof(send_with_checksum);
public const string show_reset_connection = nameof(show_reset_connection);
public const string skirt_distance = nameof(skirt_distance);
public const string skirt_height = nameof(skirt_height);
public const string skirts = nameof(skirts);
public const string sla_auto_support = nameof(sla_auto_support);
public const string sla_base_exposure_time = nameof(sla_base_exposure_time);
public const string sla_base_layers = nameof(sla_base_layers);
public const string sla_base_lift_distance = nameof(sla_base_lift_distance);
public const string sla_base_lift_speed = nameof(sla_base_lift_speed);
public const string sla_base_min_off_time = nameof(sla_base_min_off_time);
public const string sla_create_raft = nameof(sla_create_raft);
public const string sla_decend_speed = nameof(sla_decend_speed);
public const string sla_exposure_time = nameof(sla_exposure_time);
public const string sla_layer_height = nameof(sla_layer_height);
public const string sla_lift_distance = nameof(sla_lift_distance);
public const string sla_lift_speed = nameof(sla_lift_speed);
public const string sla_min_off_time = nameof(sla_min_off_time);
public const string sla_mirror_mode = nameof(sla_mirror_mode);
public const string sla_printable_area_inset = nameof(sla_printable_area_inset);
public const string sla_resolution = nameof(sla_resolution);
public const string slice_engine = nameof(slice_engine);
public const string slowdown_below_layer_time = nameof(slowdown_below_layer_time);
public const string small_perimeter_speed = nameof(small_perimeter_speed);
public const string solid_fill_pattern = nameof(solid_fill_pattern);
public const string solid_infill_extrusion_width = nameof(solid_infill_extrusion_width);
public const string solid_infill_speed = nameof(solid_infill_speed);
public const string solid_shell = nameof(solid_shell);
public const string spiral_vase = nameof(spiral_vase);
public const string standby_temperature_delta = nameof(standby_temperature_delta);
public const string start_gcode = nameof(start_gcode);
public const string start_perimeters_at_concave_points = nameof(start_perimeters_at_concave_points);
public const string start_perimeters_at_non_overhang = nameof(start_perimeters_at_non_overhang);
public const string support_air_gap = nameof(support_air_gap);
public const string support_grab_distance = nameof(support_grab_distance);
public const string support_material_create_perimeter = nameof(support_material_create_perimeter);
public const string support_material_extruder = nameof(support_material_extruder);
public const string support_material_infill_angle = nameof(support_material_infill_angle);
public const string support_material_interface_extruder = nameof(support_material_interface_extruder);
public const string support_material_interface_layers = nameof(support_material_interface_layers);
public const string support_material_spacing = nameof(support_material_spacing);
public const string support_material_speed = nameof(support_material_speed);
public const string support_material_xy_distance = nameof(support_material_xy_distance);
public const string support_percent = nameof(support_percent);
public const string support_type = nameof(support_type);
public const string t0_inset = nameof(t0_inset);
public const string t1_extrusion_move_speed_multiplier = nameof(t1_extrusion_move_speed_multiplier);
public const string t1_inset = nameof(t1_inset);
public const string temperature = nameof(temperature);
public const string temperature1 = nameof(temperature1);
public const string temperature2 = nameof(temperature2);
public const string temperature3 = nameof(temperature3);
public const string thin_walls = nameof(thin_walls);
public const string threads = nameof(threads);
public const string toolchange_gcode = nameof(toolchange_gcode);
public const string toolchange_gcode_1 = nameof(toolchange_gcode_1);
public const string toolchange_gcode_2 = nameof(toolchange_gcode_2);
public const string toolchange_gcode_3 = nameof(toolchange_gcode_3);
public const string top_infill_extrusion_width = nameof(top_infill_extrusion_width);
public const string top_solid_infill_speed = nameof(top_solid_infill_speed);
public const string top_solid_layers = nameof(top_solid_layers);
public const string travel_speed = nameof(travel_speed);
public const string trim_filament_markdown = nameof(trim_filament_markdown);
public const string unload_filament_length = nameof(unload_filament_length);
public const string use_firmware_retraction = nameof(use_firmware_retraction);
public const string use_relative_e_distances = nameof(use_relative_e_distances);
public const string use_z_probe = nameof(use_z_probe);
public const string validate_layer_height = nameof(validate_layer_height);
public const string validate_leveling = nameof(validate_leveling);
public const string validation_threshold = nameof(validation_threshold);
public const string wipe_shield_distance = nameof(wipe_shield_distance);
public const string wipe_tower_perimeters_per_extruder = nameof(wipe_tower_perimeters_per_extruder);
public const string wipe_tower_size = nameof(wipe_tower_size);
public const string write_regex = nameof(write_regex);
public const string xy_offsets_have_been_calibrated = nameof(xy_offsets_have_been_calibrated);
public const string z_homes_to_max = nameof(z_homes_to_max);
public const string z_offset = nameof(z_offset);
public const string z_probe_samples = nameof(z_probe_samples);
public const string z_servo_depolyed_angle = nameof(z_servo_depolyed_angle);
public const string z_servo_retracted_angle = nameof(z_servo_retracted_angle);
}
}

View file

@ -0,0 +1,183 @@
/*
Copyright (c) 2019, Kevin Pope, 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.
*/
using System;
using System.Collections.Generic;
namespace MatterHackers.MatterControl.SlicerConfiguration
{
public class SettingsLayout
{
public SettingsSection[] SlicingSections { get; } =
new[]
{
new SettingsSection("Slice Simple"),
new SettingsSection("Slice Intermediate"),
new SettingsSection("Slice Advanced")
};
public SettingsSection[] PrinterSections { get; } =
new[]
{
new SettingsSection("Printer Simple"),
new SettingsSection("Printer Intermediate"),
new SettingsSection("Printer Advanced")
};
public SettingsSection AllSliceSettings => SlicingSections[2];
public SettingsSection AllPrinterSettings => PrinterSections[2];
internal SettingsLayout()
{
// slice settings
CreateLayout(SlicingSections[0], SliceSettingsLayouts.SliceSettings(), (setting) =>
{
if (PrinterSettings.SettingsData.TryGetValue(setting, out SliceSettingData data))
{
return data.RequiredDisplayDetail == SliceSettingData.DisplayDetailRequired.Simple;
}
return false;
});
CreateLayout(SlicingSections[1], SliceSettingsLayouts.SliceSettings(), (setting) =>
{
if (PrinterSettings.SettingsData.TryGetValue(setting, out SliceSettingData data))
{
return data.RequiredDisplayDetail != SliceSettingData.DisplayDetailRequired.Advanced;
}
return false;
});
CreateLayout(SlicingSections[2], SliceSettingsLayouts.SliceSettings());
// printer settings
CreateLayout(PrinterSections[0], SliceSettingsLayouts.PrinterSettings(), (setting) =>
{
if (PrinterSettings.SettingsData.TryGetValue(setting, out SliceSettingData data))
{
return data.RequiredDisplayDetail == SliceSettingData.DisplayDetailRequired.Simple;
}
return false;
});
CreateLayout(PrinterSections[1], SliceSettingsLayouts.PrinterSettings(), (setting) =>
{
if (PrinterSettings.SettingsData.TryGetValue(setting, out SliceSettingData data))
{
return data.RequiredDisplayDetail != SliceSettingData.DisplayDetailRequired.Advanced;
}
return false;
});
CreateLayout(PrinterSections[2], SliceSettingsLayouts.PrinterSettings());
}
private void CreateLayout(SettingsSection section, (string categoryName, (string groupName, string[] settings)[] groups)[] layout, Func<string, bool> includeSetting = null)
{
foreach (var (categoryName, groups) in layout)
{
var categoryToAddTo = new Category(categoryName, section);
section.Categories.Add(categoryToAddTo);
foreach (var (groupName, settings) in groups)
{
var groupToAddTo = new Group(groupName, categoryToAddTo);
categoryToAddTo.Groups.Add(groupToAddTo);
foreach (var setting in settings)
{
if (PrinterSettings.SettingsData.TryGetValue(setting, out SliceSettingData data)
&& includeSetting?.Invoke(setting) != false)
{
groupToAddTo.Settings.Add(data);
data.OrganizerGroup = groupToAddTo;
section.AddSetting(data.SlicerConfigName, groupToAddTo);
}
}
}
}
}
/// <summary>
/// This is the 'Slice Settings' or the 'Printer' settings sections
/// </summary>
public class SettingsSection
{
private Dictionary<string, Group> subgroups = new Dictionary<string, Group>();
public SettingsSection(string settingsSectionName)
{
this.Name = settingsSectionName;
}
public string Name { get; set; }
public List<Category> Categories { get; private set; } = new List<Category>();
internal void AddSetting(string slicerConfigName, Group organizerGroup)
{
subgroups.Add(slicerConfigName, organizerGroup);
}
public bool ContainsKey(string settingsKey) => subgroups.ContainsKey(settingsKey);
}
public class Category
{
public Category(string categoryName, SettingsSection settingsSection)
{
this.Name = categoryName;
this.SettingsSection = settingsSection;
}
public string Name { get; set; }
public List<Group> Groups { get; private set; } = new List<Group>();
public SettingsSection SettingsSection { get; }
}
public class Group
{
public Group(string displayName, Category organizerCategory)
{
this.Name = displayName;
this.Category = organizerCategory;
}
public string Name { get; }
public List<SliceSettingData> Settings { get; private set; } = new List<SliceSettingData>();
public Category Category { get; }
}
}
}

View file

@ -0,0 +1,77 @@
/*
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.
*/
using MatterHackers.Agg;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.SlicerConfiguration;
namespace MatterHackers.MatterControl
{
public class SettingsValidationError : ValidationError
{
public SettingsValidationError(string settingsName, string presentationNameOverride = null)
: base(settingsName)
{
this.CanonicalSettingsName = settingsName;
if (string.IsNullOrEmpty(presentationNameOverride))
{
this.PresentationName = PrinterSettings.SettingsData[settingsName].PresentationName;
}
else
{
PresentationName = presentationNameOverride;
}
}
public string CanonicalSettingsName { get; }
public string PresentationName { get; }
public string Location => SettingsLocation(this.CanonicalSettingsName);
public string ValueDetails { get; set; }
private static string SettingsLocation(string settingsKey)
{
var settingData = PrinterSettings.SettingsData[settingsKey];
var setingsSectionName = settingData.OrganizerGroup.Category.SettingsSection.Name;
if (setingsSectionName == "Advanced")
{
setingsSectionName = "Slice Settings";
}
return "Location of the '{0}' setting".Localize().FormatWith(settingData.PresentationName.Localize()) + ":"
+ "\n" + setingsSectionName.Localize()
+ "\n - " + settingData.OrganizerGroup.Category.Name.Localize()
+ "\n - " + settingData.OrganizerGroup.Name.Localize()
+ "\n - " + settingData.PresentationName.Localize();
}
}
}

View file

@ -0,0 +1,121 @@
/*
Copyright (c) 2018, Kevin Pope, 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.
*/
using System;
using System.Collections.Generic;
using MatterHackers.MatterControl.SlicerConfiguration.MappingClasses;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace MatterHackers.MatterControl.SlicerConfiguration
{
public class QuickMenuNameValue
{
public string MenuName;
public string Value;
}
public class SliceSettingData
{
[JsonConverter(typeof(StringEnumConverter))]
public enum DataEditTypes
{
BOUNDS,
CHECK_BOX,
COLOR,
COM_PORT,
DOUBLE,
DOUBLE_OR_PERCENT,
EXTRUDER_LIST,
HARDWARE_PRESENT,
INT,
INT_OR_MM,
IP_LIST,
LIST,
MARKDOWN_TEXT,
MULTI_LINE_TEXT,
OFFSET,
OFFSET3,
POSITIVE_DOUBLE,
POSITIVE_DOUBLE_OR_INCOMPATIBLE,
READONLY_STRING,
SLICE_ENGINE,
STRING,
VECTOR2,
VECTOR3,
VECTOR4,
WIDE_STRING,
};
public string SlicerConfigName { get; set; }
public string PresentationName { get; set; }
public Func<PrinterSettings, bool> Show { get; set; }
public string EnableIfSet { get; set; }
public string DefaultValue { get; set; }
public DataEditTypes DataEditType { get; set; }
public string HelpText { get; set; } = "";
public string Units { get; set; } = "";
public string ListValues { get; set; } = "";
public bool ShowAsOverride { get; set; } = true;
public List<QuickMenuNameValue> QuickMenuSettings = new List<QuickMenuNameValue>();
public List<Dictionary<string, string>> SetSettingsOnChange = new List<Dictionary<string, string>>();
public bool ResetAtEndOfPrint { get; set; } = false;
public bool RebuildGCodeOnChange { get; set; } = true;
public Func<int, string> PerToolName { get; set; } = null;
public enum UiUpdateRequired { None, SliceSettings, Application };
public UiUpdateRequired UiUpdate { get; set; } = UiUpdateRequired.None;
public SettingsLayout.Group OrganizerGroup { get; set; }
public ValueConverter Converter { get; set; }
/// <summary>
/// The display minimum display detail that must be set for this setting to be visible
/// </summary>
public enum DisplayDetailRequired { Simple, Intermediate, Advanced }
public DisplayDetailRequired RequiredDisplayDetail { get; internal set; } = DisplayDetailRequired.Intermediate;
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,492 @@
/*
Copyright (c) 2019, Lars Brubaker, 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.SlicerConfiguration
{
public static class SliceSettingsLayouts
{
private static (string categoryName, (string groupName, string[] settings)[] groups)[] sliceSettings;
private static (string categoryName, (string groupName, string[] settings)[] groups)[] printerSettings;
public static (string categoryName, (string groupName, string[] settings)[] groups)[] SliceSettings()
{
if (sliceSettings == null)
{
sliceSettings = new[]
{
("General", new[]
{
("General", new[]
{
SettingsKey.layer_height,
SettingsKey.first_layer_height,
SettingsKey.perimeters,
SettingsKey.top_solid_layers,
SettingsKey.bottom_solid_layers,
SettingsKey.fill_density,
SettingsKey.infill_type,
// add settings specific to SLA
SettingsKey.sla_layer_height,
SettingsKey.sla_decend_speed,
}),
("Normal Layers", new[] // this is for SLA resin printing
{
SettingsKey.sla_exposure_time,
SettingsKey.sla_lift_distance,
SettingsKey.sla_lift_speed,
SettingsKey.sla_min_off_time,
}),
("Base Layers", new[] // this is for SLA resin printing
{
SettingsKey.sla_base_layers,
SettingsKey.sla_base_exposure_time,
SettingsKey.sla_base_lift_distance,
SettingsKey.sla_base_lift_speed,
SettingsKey.sla_base_min_off_time,
}),
("Layers / Surface", new[]
{
SettingsKey.avoid_crossing_perimeters,
SettingsKey.avoid_crossing_max_ratio,
SettingsKey.external_perimeters_first,
SettingsKey.perimeter_start_end_overlap,
SettingsKey.merge_overlapping_lines,
SettingsKey.seam_placement,
SettingsKey.expand_thin_walls,
SettingsKey.coast_at_end_distance,
SettingsKey.monotonic_solid_infill,
SettingsKey.fuzzy_thickness,
SettingsKey.fuzzy_frequency,
}),
("Infill", new[]
{
SettingsKey.fill_angle,
SettingsKey.infill_overlap_perimeter,
SettingsKey.fill_thin_gaps,
}),
("Extruder Change", new[]
{
SettingsKey.wipe_shield_distance,
SettingsKey.wipe_tower_size,
SettingsKey.wipe_tower_perimeters_per_extruder,
}),
("Advanced", new[]
{
SettingsKey.spiral_vase,
SettingsKey.layer_to_pause,
}),
}),
("Speed", new[]
{
("Laser Speed", new[]
{
SettingsKey.laser_speed_025,
SettingsKey.laser_speed_100,
}),
("Infill Speeds", new[]
{
SettingsKey.first_layer_speed,
SettingsKey.infill_speed,
SettingsKey.top_solid_infill_speed,
SettingsKey.raft_print_speed,
}),
("Perimeter Speeds", new[]
{
SettingsKey.perimeter_speed,
SettingsKey.external_perimeter_speed,
SettingsKey.perimeter_acceleration,
SettingsKey.default_acceleration,
}),
("Other Speeds", new[]
{
SettingsKey.support_material_speed,
SettingsKey.interface_layer_speed,
SettingsKey.air_gap_speed,
SettingsKey.bridge_speed,
SettingsKey.travel_speed,
SettingsKey.number_of_first_layers,
SettingsKey.bridge_over_infill,
SettingsKey.t1_extrusion_move_speed_multiplier,
}),
("Speed Overrides", new []
{
SettingsKey.max_print_speed,
}),
("Cooling", new[]
{
SettingsKey.slowdown_below_layer_time,
SettingsKey.min_print_speed,
}),
}),
("Adhesion", new[]
{
("Bed", new []
{
SettingsKey.bed_surface,
}),
("Skirt", new[]
{
SettingsKey.create_skirt,
SettingsKey.skirts,
SettingsKey.skirt_distance,
SettingsKey.min_skirt_length,
}),
("Raft", new[]
{
SettingsKey.create_raft,
SettingsKey.raft_extra_distance_around_part,
SettingsKey.raft_air_gap,
SettingsKey.raft_extruder,
// add settings specific to SLA
SettingsKey.sla_create_raft,
}),
("Brim", new[]
{
SettingsKey.create_brim,
SettingsKey.brims,
SettingsKey.brims_layers,
SettingsKey.brim_extruder,
}),
}),
("Support", new[]
{
("General", new[]
{
SettingsKey.support_material_create_perimeter,
SettingsKey.support_material_interface_layers,
SettingsKey.support_material_xy_distance,
SettingsKey.support_air_gap,
SettingsKey.support_type,
SettingsKey.support_material_spacing,
SettingsKey.support_material_infill_angle,
SettingsKey.support_material_extruder,
SettingsKey.support_material_interface_extruder,
}),
("Automatic", new[]
{
SettingsKey.create_per_layer_support,
SettingsKey.create_per_layer_internal_support,
SettingsKey.support_percent,
SettingsKey.support_grab_distance,
// add settings specific to SLA
SettingsKey.sla_auto_support,
}),
}),
("Resin", new[]
{
("Properties", new []
{
SettingsKey.resin_density,
SettingsKey.resin_cost,
}),
}),
("Filament", new[]
{
("Properties", new[]
{
SettingsKey.material_color,
SettingsKey.material_color_1,
SettingsKey.material_color_2,
SettingsKey.material_color_3,
SettingsKey.filament_diameter,
SettingsKey.filament_density,
SettingsKey.filament_cost,
SettingsKey.temperature,
SettingsKey.temperature1,
SettingsKey.temperature2,
SettingsKey.temperature3,
SettingsKey.bed_temperature,
SettingsKey.bed_temperature_blue_tape,
SettingsKey.bed_temperature_buildtak,
SettingsKey.bed_temperature_garolite,
SettingsKey.bed_temperature_glass,
SettingsKey.bed_temperature_kapton,
SettingsKey.bed_temperature_pei,
SettingsKey.bed_temperature_pp,
SettingsKey.inactive_cool_down,
SettingsKey.seconds_to_reheat,
}),
("Fan", new[]
{
SettingsKey.enable_fan,
SettingsKey.min_fan_speed_layer_time,
SettingsKey.max_fan_speed_layer_time,
SettingsKey.min_fan_speed,
SettingsKey.max_fan_speed,
SettingsKey.bridge_fan_speed,
SettingsKey.disable_fan_first_layers,
SettingsKey.min_fan_speed_absolute,
}),
("Retraction", new[]
{
SettingsKey.enable_retractions,
SettingsKey.retract_length,
SettingsKey.retract_restart_extra,
SettingsKey.retract_restart_extra_time_to_apply,
SettingsKey.retract_speed,
SettingsKey.retract_lift,
SettingsKey.retract_when_changing_islands,
SettingsKey.min_extrusion_before_retract,
SettingsKey.retract_before_travel,
SettingsKey.retract_before_travel_avoid,
SettingsKey.retract_length_tool_change,
SettingsKey.retract_restart_extra_toolchange,
}),
("Advanced", new[]
{
SettingsKey.extruder_wipe_temperature,
SettingsKey.bed_remove_part_temperature,
SettingsKey.extrusion_multiplier,
SettingsKey.first_layer_extrusion_width,
SettingsKey.external_perimeter_extrusion_width,
}),
}),
};
}
return sliceSettings;
}
public static (string categoryName, (string groupName, string[] settings)[] groups)[] PrinterSettings()
{
if (printerSettings == null)
{
printerSettings = new (string categoryName, (string groupName, string[] settings)[] groups)[]
{
("General", new[]
{
("General", new[]
{
SettingsKey.make,
SettingsKey.model,
SettingsKey.auto_connect,
SettingsKey.baud_rate,
SettingsKey.com_port,
SettingsKey.selector_ip_address,
SettingsKey.ip_address,
SettingsKey.ip_port,
}),
("Bed", new[]
{
SettingsKey.bed_size,
SettingsKey.print_center,
SettingsKey.build_height,
SettingsKey.bed_shape,
// add settings specific to SLA
SettingsKey.sla_resolution,
SettingsKey.sla_printable_area_inset,
SettingsKey.sla_mirror_mode,
}),
("Extruders", new[]
{
SettingsKey.extruder_count,
SettingsKey.nozzle_diameter,
SettingsKey.t0_inset,
SettingsKey.t1_inset,
SettingsKey.extruders_share_temperature,
SettingsKey.extruder_offset,
}),
}),
("Features", new (string groupName, string[] settings)[]
{
("Leveling", new[]
{
SettingsKey.print_leveling_solution,
SettingsKey.print_leveling_insets,
SettingsKey.leveling_sample_points,
SettingsKey.print_leveling_required_to_print,
}),
("Print Recovery", new[]
{
SettingsKey.recover_is_enabled,
SettingsKey.recover_first_layer_speed,
SettingsKey.recover_position_before_z_home,
}),
("Probe", new[]
{
SettingsKey.print_leveling_probe_start,
SettingsKey.use_z_probe,
SettingsKey.validate_leveling,
SettingsKey.validation_threshold,
SettingsKey.z_probe_samples,
SettingsKey.probe_offset,
SettingsKey.z_servo_depolyed_angle,
SettingsKey.z_servo_retracted_angle,
SettingsKey.measure_probe_offset_conductively,
SettingsKey.conductive_pad_center,
SettingsKey.conductive_probe_min_z,
}),
("Behavior", new[]
{
SettingsKey.slice_engine,
SettingsKey.heat_extruder_before_homing,
SettingsKey.auto_release_motors,
SettingsKey.validate_layer_height,
SettingsKey.emulate_endstops,
SettingsKey.send_with_checksum,
SettingsKey.additional_printing_errors,
SettingsKey.reset_long_extrusion,
SettingsKey.output_only_first_layer,
SettingsKey.g0,
SettingsKey.progress_reporting,
SettingsKey.include_firmware_updater,
SettingsKey.backup_firmware_before_update,
SettingsKey.enable_firmware_sounds,
}),
("Diagnostics", new[]
{
SettingsKey.report_runout_sensor_data,
}),
("Printer Help", new[]
{
SettingsKey.trim_filament_markdown,
SettingsKey.insert_filament_markdown2,
SettingsKey.running_clean_markdown2,
SettingsKey.insert_filament_1_markdown,
SettingsKey.running_clean_1_markdown,
SettingsKey.printer_sku,
SettingsKey.created_date,
}),
}),
("Hardware", new (string groupName, string[] settings)[]
{
("Hardware", new[]
{
SettingsKey.firmware_type,
SettingsKey.show_reset_connection,
SettingsKey.z_homes_to_max,
SettingsKey.has_fan,
SettingsKey.has_fan_per_extruder,
SettingsKey.has_hardware_leveling,
SettingsKey.has_independent_z_motors,
SettingsKey.has_heated_bed,
SettingsKey.has_swappable_bed,
SettingsKey.has_sd_card_reader,
SettingsKey.has_power_control,
SettingsKey.filament_runout_sensor,
SettingsKey.runout_sensor_check_distance,
SettingsKey.runout_sensor_trigger_ratio,
SettingsKey.has_z_probe,
SettingsKey.has_z_servo,
SettingsKey.has_conductive_nozzle,
SettingsKey.has_c_axis,
SettingsKey.enable_network_printing,
SettingsKey.enable_sailfish_communication,
SettingsKey.max_acceleration,
SettingsKey.max_velocity,
SettingsKey.jerk_velocity,
SettingsKey.print_time_estimate_multiplier,
SettingsKey.load_filament_length,
SettingsKey.unload_filament_length,
SettingsKey.load_filament_speed,
}),
}),
("G-Code", new[]
{
("Printer Control", new[]
{
SettingsKey.start_gcode,
SettingsKey.end_gcode,
SettingsKey.layer_gcode,
SettingsKey.connect_gcode,
SettingsKey.clear_bed_gcode,
}),
("User Control", new[]
{
SettingsKey.cancel_gcode,
SettingsKey.pause_gcode,
SettingsKey.resume_gcode,
}),
("Multi-Extruder", new[]
{
SettingsKey.before_toolchange_gcode,
SettingsKey.toolchange_gcode,
SettingsKey.before_toolchange_gcode_1,
SettingsKey.toolchange_gcode_1,
SettingsKey.before_toolchange_gcode_2,
SettingsKey.toolchange_gcode_2,
SettingsKey.before_toolchange_gcode_3,
SettingsKey.toolchange_gcode_3,
}),
("Filters", new[]
{
SettingsKey.write_regex,
SettingsKey.read_regex,
}),
}),
};
}
return printerSettings;
}
public static bool ContainesKey((string categoryName, (string groupName, string[] settings)[] groups)[] settingsGrouping, string key)
{
foreach (var category in settingsGrouping)
{
foreach (var group in category.groups)
{
foreach (var setting in group.settings)
{
if (setting == key)
{
return true;
}
}
}
}
return false;
}
public static (int index, string category, string group, string key) GetLayout(string key)
{
// find the setting in SliceSettings()
var settings = SliceSettings();
var index = 0;
foreach (var category in settings)
{
foreach (var group in category.groups)
{
foreach (var setting in group.settings)
{
if (setting == key)
{
return (index, category.categoryName, group.groupName, key);
}
// increment after every setting
index++;
}
}
}
return (-1, "", "", key);
}
}
}

View file

@ -0,0 +1,82 @@
/*
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.
*/
using MatterHackers.Localizations;
using MatterHackers.MatterControl.SlicerConfiguration;
namespace MatterHackers.MatterControl
{
public enum ValidationErrorLevel
{
Information,
Warning,
Error
}
public class ValidationError
{
public ValidationError(string id)
{
this.ID = id;
}
public string ID { get; }
public string Error { get; set; }
public string Details { get; set; }
public ValidationErrorLevel ErrorLevel { get; set; } = ValidationErrorLevel.Error;
public NamedAction FixAction { get; set; }
}
public static class ValidationErrors
{
public static readonly string BedLevelingMesh = nameof(BedLevelingMesh);
public static readonly string BedLevelingTemperature = nameof(BedLevelingTemperature);
public static readonly string BedSurfaceNotSelected = nameof(BedSurfaceNotSelected);
public static readonly string ExceptionDuringSliceSettingsValidation = nameof(ExceptionDuringSliceSettingsValidation);
public static readonly string IncompatibleBedSurfaceAndMaterial = nameof(IncompatibleBedSurfaceAndMaterial);
public static readonly string ItemCannotBeExported = nameof(ItemCannotBeExported);
public static readonly string ItemToAMFExportInvalid = nameof(ItemToAMFExportInvalid);
public static readonly string ItemTo3MFExportInvalid = nameof(ItemTo3MFExportInvalid);
public static readonly string ItemToSTLExportInvalid = nameof(ItemToSTLExportInvalid);
public static readonly string MaterialNotSelected = nameof(MaterialNotSelected);
public static readonly string BedTemperatureError = nameof(BedTemperatureError);
public static readonly string NoItemsToExport = nameof(NoItemsToExport);
public static readonly string NoPrintableParts = nameof(NoPrintableParts);
public static readonly string NoZipItemsToExport = nameof(NoZipItemsToExport);
public static readonly string PrinterDisconnected = nameof(PrinterDisconnected);
public static readonly string PrinterSetupRequired = nameof(PrinterSetupRequired);
public static readonly string SettingsUpdateAvailable = nameof(SettingsUpdateAvailable);
public static readonly string UnsupportedParts = nameof(UnsupportedParts);
public static readonly string ZOffset = nameof(ZOffset);
}
}