Merge branch 'development' of https://github.com/MatterHackers/MatterControl into development

This commit is contained in:
Kevin Pope 2014-05-07 15:59:49 -07:00
commit b6ddc0e122
5 changed files with 95 additions and 148 deletions

View file

@ -310,79 +310,6 @@ enableOozeShield = 0;
}
}
public class MapStartGCode : InjectGCodeCommands
{
public override string MappedValue
{
get
{
StringBuilder curaStartGCode = new StringBuilder();
foreach (string line in PreStartGCode())
{
curaStartGCode.Append(line + "\n");
}
curaStartGCode.Append(base.MappedValue);
bool first = true;
foreach (string line in PostStartGCode())
{
if (!first)
{
curaStartGCode.Append("\n");
}
curaStartGCode.Append(line);
first = false;
}
return curaStartGCode.ToString();
}
}
public MapStartGCode(string cura, string slicer)
: base(cura, slicer)
{
}
public List<string> PreStartGCode()
{
string startGCode = ActiveSliceSettings.Instance.GetActiveValue("start_gcode");
string[] preStartGCodeLines = startGCode.Split(new string[] { "\\n" }, StringSplitOptions.RemoveEmptyEntries);
List<string> preStartGCode = new List<string>();
preStartGCode.Add("; automatic settings before start_gcode");
AddDefaultIfNotPresent(preStartGCode, "G21", preStartGCodeLines, "set units to millimeters");
AddDefaultIfNotPresent(preStartGCode, "M107", preStartGCodeLines, "fan off");
double bed_temperature = double.Parse(ActiveSliceSettings.Instance.GetActiveValue("bed_temperature"));
if (bed_temperature > 0)
{
string setBedTempString = string.Format("M190 S{0}", bed_temperature);
AddDefaultIfNotPresent(preStartGCode, setBedTempString, preStartGCodeLines, "wait for bed temperature to be reached");
}
string setTempString = string.Format("M104 S{0}", ActiveSliceSettings.Instance.GetActiveValue("temperature"));
AddDefaultIfNotPresent(preStartGCode, setTempString, preStartGCodeLines, "set temperature");
preStartGCode.Add("; settings from start_gcode");
return preStartGCode;
}
public List<string> PostStartGCode()
{
string startGCode = ActiveSliceSettings.Instance.GetActiveValue("start_gcode");
string[] postStartGCodeLines = startGCode.Split(new string[] { "\\n" }, StringSplitOptions.RemoveEmptyEntries);
List<string> postStartGCode = new List<string>();
postStartGCode.Add("; automatic settings after start_gcode");
string setTempString = string.Format("M109 S{0}", ActiveSliceSettings.Instance.GetActiveValue("temperature"));
AddDefaultIfNotPresent(postStartGCode, setTempString, postStartGCodeLines, "wait for temperature");
AddDefaultIfNotPresent(postStartGCode, "G90", postStartGCodeLines, "use absolute coordinates");
postStartGCode.Add(string.Format("{0} ; {1}", "G92 E0", "reset the expected extruder position"));
AddDefaultIfNotPresent(postStartGCode, "M82", postStartGCodeLines, "use absolute distance for extrusion");
return postStartGCode;
}
}
public class MapEndGCode : InjectGCodeCommands
{
public override string MappedValue

View file

@ -401,79 +401,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
}
}
public class MapStartGCode : InjectGCodeCommands
{
public override string MappedValue
{
get
{
StringBuilder startGCode = new StringBuilder();
foreach (string line in PreStartGCode())
{
startGCode.Append(line + "\n");
}
startGCode.Append(base.MappedValue);
bool first = true;
foreach (string line in PostStartGCode())
{
if (!first)
{
startGCode.Append("\n");
}
startGCode.Append(line);
first = false;
}
return startGCode.ToString();
}
}
public MapStartGCode(string mappedKey, string slicer)
: base(mappedKey, slicer)
{
}
public List<string> PreStartGCode()
{
string startGCode = ActiveSliceSettings.Instance.GetActiveValue("start_gcode");
string[] preStartGCodeLines = startGCode.Split(new string[] { "\\n" }, StringSplitOptions.RemoveEmptyEntries);
List<string> preStartGCode = new List<string>();
preStartGCode.Add("; automatic settings before start_gcode");
AddDefaultIfNotPresent(preStartGCode, "G21", preStartGCodeLines, "set units to millimeters");
AddDefaultIfNotPresent(preStartGCode, "M107", preStartGCodeLines, "fan off");
double bed_temperature = double.Parse(ActiveSliceSettings.Instance.GetActiveValue("bed_temperature"));
if (bed_temperature > 0)
{
string setBedTempString = string.Format("M190 S{0}", bed_temperature);
AddDefaultIfNotPresent(preStartGCode, setBedTempString, preStartGCodeLines, "wait for bed temperature to be reached");
}
string setTempString = string.Format("M104 S{0}", ActiveSliceSettings.Instance.GetActiveValue("temperature"));
AddDefaultIfNotPresent(preStartGCode, setTempString, preStartGCodeLines, "set temperature");
preStartGCode.Add("; settings from start_gcode");
return preStartGCode;
}
public List<string> PostStartGCode()
{
string startGCode = ActiveSliceSettings.Instance.GetActiveValue("start_gcode");
string[] postStartGCodeLines = startGCode.Split(new string[] { "\\n" }, StringSplitOptions.RemoveEmptyEntries);
List<string> postStartGCode = new List<string>();
postStartGCode.Add("; automatic settings after start_gcode");
string setTempString = string.Format("M109 S{0}", ActiveSliceSettings.Instance.GetActiveValue("temperature"));
AddDefaultIfNotPresent(postStartGCode, setTempString, postStartGCodeLines, "wait for temperature");
AddDefaultIfNotPresent(postStartGCode, "G90", postStartGCodeLines, "use absolute coordinates");
postStartGCode.Add(string.Format("{0} ; {1}", "G92 E0", "reset the expected extruder position"));
AddDefaultIfNotPresent(postStartGCode, "M82", postStartGCodeLines, "use absolute distance for extrusion");
return postStartGCode;
}
}
public class MapEndGCode : InjectGCodeCommands
{
public override string MappedValue

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using MatterHackers.MatterControl;
using MatterHackers.Agg;
namespace MatterHackers.MatterControl.SlicerConfiguration
{
@ -41,6 +42,98 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
}
}
public class MapStartGCode : InjectGCodeCommands
{
public override string MappedValue
{
get
{
StringBuilder newStartGCode = new StringBuilder();
foreach (string line in PreStartGCode())
{
newStartGCode.Append(line + "\n");
}
newStartGCode.Append(ReplaceMacroValues(base.MappedValue));
bool first = true;
foreach (string line in PostStartGCode())
{
if (!first)
{
newStartGCode.Append("\n");
}
newStartGCode.Append(line);
first = false;
}
return newStartGCode.ToString();
}
}
string[] replaceWithSettingsStrings = new string[]
{
"first_layer_temperature",
"temperature",
"first_layer_bed_temperature",
"bed_temperature",
};
private string ReplaceMacroValues(string gcodeWithMacros)
{
foreach (string name in replaceWithSettingsStrings)
{
string thingToReplace = "{" + "{0}.FormatWith(name)" + "}";
gcodeWithMacros = gcodeWithMacros.Replace(thingToReplace, ActiveSliceSettings.Instance.GetActiveValue(name));
}
return gcodeWithMacros;
}
public MapStartGCode(string mappedKey, string originalKey)
: base(mappedKey, originalKey)
{
}
public List<string> PreStartGCode()
{
string startGCode = ActiveSliceSettings.Instance.GetActiveValue("start_gcode");
string[] preStartGCodeLines = startGCode.Split(new string[] { "\\n" }, StringSplitOptions.RemoveEmptyEntries);
List<string> preStartGCode = new List<string>();
preStartGCode.Add("; automatic settings before start_gcode");
AddDefaultIfNotPresent(preStartGCode, "G21", preStartGCodeLines, "set units to millimeters");
AddDefaultIfNotPresent(preStartGCode, "M107", preStartGCodeLines, "fan off");
double bed_temperature = double.Parse(ActiveSliceSettings.Instance.GetActiveValue("bed_temperature"));
if (bed_temperature > 0)
{
string setBedTempString = string.Format("M190 S{0}", bed_temperature);
AddDefaultIfNotPresent(preStartGCode, setBedTempString, preStartGCodeLines, "wait for bed temperature to be reached");
}
string setTempString = string.Format("M104 S{0}", ActiveSliceSettings.Instance.GetActiveValue("temperature"));
AddDefaultIfNotPresent(preStartGCode, setTempString, preStartGCodeLines, "set temperature");
preStartGCode.Add("; settings from start_gcode");
return preStartGCode;
}
public List<string> PostStartGCode()
{
string startGCode = ActiveSliceSettings.Instance.GetActiveValue("start_gcode");
string[] postStartGCodeLines = startGCode.Split(new string[] { "\\n" }, StringSplitOptions.RemoveEmptyEntries);
List<string> postStartGCode = new List<string>();
postStartGCode.Add("; automatic settings after start_gcode");
string setTempString = "M109 S{0}".FormatWith(ActiveSliceSettings.Instance.GetActiveValue("temperature"));
AddDefaultIfNotPresent(postStartGCode, setTempString, postStartGCodeLines, "wait for temperature");
AddDefaultIfNotPresent(postStartGCode, "G90", postStartGCodeLines, "use absolute coordinates");
postStartGCode.Add(string.Format("{0} ; {1}", "G92 E0", "reset the expected extruder position"));
AddDefaultIfNotPresent(postStartGCode, "M82", postStartGCodeLines, "use absolute distance for extrusion");
return postStartGCode;
}
}
public class MapItemToBool : MapItem
{
public override string MappedValue

View file

@ -89,7 +89,7 @@ solid_infill_every_layers = 0
solid_infill_extrusion_width = 0
solid_infill_speed = 60
spiral_vase = 0
start_gcode = G28 ; home all axes\nG1 Z5 F5000 ; lift nozzle
start_gcode = G28 ; home all axes\nG1 Z5 F5000 ; lift nozzle\n109 S{temperature} ; set the extruder temp and wait\nG29 ; probe bed\n
support_material = 1
support_material_angle = 0
support_material_enforce_layers = 0

View file

@ -89,7 +89,7 @@ solid_infill_every_layers = 0
solid_infill_extrusion_width = 0
solid_infill_speed = 60
spiral_vase = 0
start_gcode = G28 ; home all axes\nG1 Z5 F5000 ; lift nozzle
start_gcode = G28 ; home all axes\nG1 Z5 F5000 ; lift nozzle\n109 S{temperature} ; set the extruder temp and wait\nG29 ; probe bed\n
support_material = 1
support_material_angle = 0
support_material_enforce_layers = 0