Merge pull request #960 from larsbrubaker/master

Converted more settings methods to GetValue<T>
This commit is contained in:
Lars Brubaker 2016-06-16 07:15:17 -07:00 committed by GitHub
commit 64b7eb37a5
19 changed files with 92 additions and 143 deletions

View file

@ -44,11 +44,11 @@ namespace MatterHackers.MatterControl.Plugins.BrailleBuilder
BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
double buildHeight = ActiveSliceSettings.Instance.BuildHeight(); double buildHeight = ActiveSliceSettings.Instance.GetValue<double>("build_height");
part3DView = new View3DBrailleBuilder( part3DView = new View3DBrailleBuilder(
new Vector3(ActiveSliceSettings.Instance.BedSize(), buildHeight), new Vector3(ActiveSliceSettings.Instance.GetValue<Vector2>("bed_size"), buildHeight),
ActiveSliceSettings.Instance.BedCenter(), ActiveSliceSettings.Instance.GetValue<Vector2>("print_center"),
ActiveSliceSettings.Instance.BedShape()); ActiveSliceSettings.Instance.BedShape());
#if __ANDROID__ #if __ANDROID__

View file

@ -57,7 +57,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
&& lineBeingSent.Length > 2 && lineBeingSent.Length > 2
&& lineBeingSent[2] == ' ') && lineBeingSent[2] == ' ')
{ {
return GetLevelingFunctions(numberOfRadialSamples, settings.GetPrintLevelingData(), ActiveSliceSettings.Instance.BedCenter()) return GetLevelingFunctions(numberOfRadialSamples, settings.GetPrintLevelingData(), ActiveSliceSettings.Instance.GetValue<Vector2>("print_center"))
.DoApplyLeveling(lineBeingSent, currentDestination, movementMode); .DoApplyLeveling(lineBeingSent, currentDestination, movementMode);
} }
@ -67,7 +67,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
public override Vector2 GetPrintLevelPositionToSample(int index, double radius) public override Vector2 GetPrintLevelPositionToSample(int index, double radius)
{ {
PrintLevelingData levelingData = ActiveSliceSettings.Instance.GetPrintLevelingData(); PrintLevelingData levelingData = ActiveSliceSettings.Instance.GetPrintLevelingData();
return GetLevelingFunctions(numberOfRadialSamples, levelingData, ActiveSliceSettings.Instance.BedCenter()) return GetLevelingFunctions(numberOfRadialSamples, levelingData, ActiveSliceSettings.Instance.GetValue<Vector2>("print_center"))
.GetPrintLevelPositionToSample(index, radius); .GetPrintLevelPositionToSample(index, radius);
} }

View file

@ -77,7 +77,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
public Vector2 GetPrintLevelPositionToSample(int index, double radius) public Vector2 GetPrintLevelPositionToSample(int index, double radius)
{ {
Vector2 bedCenter = ActiveSliceSettings.Instance.BedCenter(); Vector2 bedCenter = ActiveSliceSettings.Instance.GetValue<Vector2>("print_center");
if (index < NumberOfRadialSamples) if (index < NumberOfRadialSamples)
{ {
Vector2 position = new Vector2(radius, 0); Vector2 position = new Vector2(radius, 0);
@ -212,7 +212,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
string medPrecisionLabel = "Medium Precision".Localize(); string medPrecisionLabel = "Medium Precision".Localize();
string highPrecisionLabel = "High Precision".Localize(); string highPrecisionLabel = "High Precision".Localize();
double bedRadius = Math.Min(ActiveSliceSettings.Instance.BedSize().x, ActiveSliceSettings.Instance.BedSize().y) / 2; double bedRadius = Math.Min(ActiveSliceSettings.Instance.GetValue<Vector2>("bed_size").x, ActiveSliceSettings.Instance.GetValue<Vector2>("bed_size").y) / 2;
double startProbeHeight = 5; double startProbeHeight = 5;
for (int i = 0; i < numberOfRadialSamples + 1; i++) for (int i = 0; i < numberOfRadialSamples + 1; i++)
@ -267,7 +267,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
&& lineBeingSent[2] == ' ') && lineBeingSent[2] == ' ')
{ {
PrintLevelingData levelingData = ActiveSliceSettings.Instance.GetPrintLevelingData(); PrintLevelingData levelingData = ActiveSliceSettings.Instance.GetPrintLevelingData();
return GetLevelingFunctions(numberOfRadialSamples, levelingData, ActiveSliceSettings.Instance.BedCenter()) return GetLevelingFunctions(numberOfRadialSamples, levelingData, ActiveSliceSettings.Instance.GetValue<Vector2>("print_center"))
.DoApplyLeveling(lineBeingSent, currentDestination, movementMode); .DoApplyLeveling(lineBeingSent, currentDestination, movementMode);
} }
@ -277,7 +277,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
public override Vector2 GetPrintLevelPositionToSample(int index, double radius) public override Vector2 GetPrintLevelPositionToSample(int index, double radius)
{ {
PrintLevelingData levelingData = ActiveSliceSettings.Instance.GetPrintLevelingData(); PrintLevelingData levelingData = ActiveSliceSettings.Instance.GetPrintLevelingData();
return GetLevelingFunctions(numberOfRadialSamples, levelingData, ActiveSliceSettings.Instance.BedCenter()) return GetLevelingFunctions(numberOfRadialSamples, levelingData, ActiveSliceSettings.Instance.GetValue<Vector2>("print_center"))
.GetPrintLevelPositionToSample(index, radius); .GetPrintLevelPositionToSample(index, radius);
} }

View file

@ -79,8 +79,8 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
public static Vector2 GetPrintLevelPositionToSample(int index) public static Vector2 GetPrintLevelPositionToSample(int index)
{ {
Vector2 bedSize = ActiveSliceSettings.Instance.BedSize(); Vector2 bedSize = ActiveSliceSettings.Instance.GetValue<Vector2>("bed_size");
Vector2 printCenter = ActiveSliceSettings.Instance.PrintCenter(); Vector2 printCenter = ActiveSliceSettings.Instance.GetValue<Vector2>("print_center");
switch (ActiveSliceSettings.Instance.BedShape()) switch (ActiveSliceSettings.Instance.BedShape())
{ {

View file

@ -63,7 +63,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
public override void PageIsBecomingActive() public override void PageIsBecomingActive()
{ {
Vector3 paperWidth = new Vector3(0, 0, ActiveSliceSettings.Instance.ProbePaperWidth()); Vector3 paperWidth = new Vector3(0, 0, ActiveSliceSettings.Instance.GetValue<double>("manual_probe_paper_width"));
PrintLevelingData levelingData = ActiveSliceSettings.Instance.GetPrintLevelingData(); PrintLevelingData levelingData = ActiveSliceSettings.Instance.GetPrintLevelingData();
levelingData.SampledPosition0 = probePositions[0].position - paperWidth; levelingData.SampledPosition0 = probePositions[0].position - paperWidth;
@ -93,7 +93,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
{ {
PrintLevelingData levelingData = ActiveSliceSettings.Instance.GetPrintLevelingData(); PrintLevelingData levelingData = ActiveSliceSettings.Instance.GetPrintLevelingData();
levelingData.SampledPositions.Clear(); levelingData.SampledPositions.Clear();
Vector3 paperWidth = new Vector3(0, 0, ActiveSliceSettings.Instance.ProbePaperWidth()); Vector3 paperWidth = new Vector3(0, 0, ActiveSliceSettings.Instance.GetValue<double>("manual_probe_paper_width"));
for (int i = 0; i < probePositions.Length; i++) for (int i = 0; i < probePositions.Length; i++)
{ {
levelingData.SampledPositions.Add(probePositions[i].position - paperWidth); levelingData.SampledPositions.Add(probePositions[i].position - paperWidth);
@ -193,7 +193,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
// auto back probe // auto back probe
Vector3 probeOffset2 = probePositions[4].position; Vector3 probeOffset2 = probePositions[4].position;
Vector3 paperWidth = new Vector3(0, 0, ActiveSliceSettings.Instance.ProbePaperWidth()); Vector3 paperWidth = new Vector3(0, 0, ActiveSliceSettings.Instance.GetValue<double>("manual_probe_paper_width"));
PrintLevelingData levelingData = ActiveSliceSettings.Instance.GetPrintLevelingData(); PrintLevelingData levelingData = ActiveSliceSettings.Instance.GetPrintLevelingData();
levelingData.SampledPosition0 = userBedSample0 - paperWidth; levelingData.SampledPosition0 = userBedSample0 - paperWidth;

View file

@ -90,13 +90,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
private void RecreateBed() private void RecreateBed()
{ {
double buildHeight = ActiveSliceSettings.Instance.BuildHeight(); double buildHeight = ActiveSliceSettings.Instance.GetValue<double>("build_height");
UiThread.RunOnIdle((Action)(() => UiThread.RunOnIdle((Action)(() =>
{ {
meshViewerWidget.CreatePrintBed( meshViewerWidget.CreatePrintBed(
new Vector3(ActiveSliceSettings.Instance.BedSize(), buildHeight), new Vector3(ActiveSliceSettings.Instance.GetValue<Vector2>("bed_size"), buildHeight),
ActiveSliceSettings.Instance.BedCenter(), ActiveSliceSettings.Instance.GetValue<Vector2>("print_center"),
ActiveSliceSettings.Instance.BedShape()); ActiveSliceSettings.Instance.BedShape());
PutOemImageOnBed(); PutOemImageOnBed();
})); }));

View file

@ -95,12 +95,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
selectedTabColor = ActiveTheme.Instance.SecondaryAccentColor; selectedTabColor = ActiveTheme.Instance.SecondaryAccentColor;
} }
double buildHeight = ActiveSliceSettings.Instance.BuildHeight(); double buildHeight = ActiveSliceSettings.Instance.GetValue<double>("build_height");
// put in the 3D view // put in the 3D view
partPreviewView = new View3DWidget(printItem, partPreviewView = new View3DWidget(printItem,
new Vector3(ActiveSliceSettings.Instance.BedSize(), buildHeight), new Vector3(ActiveSliceSettings.Instance.GetValue<Vector2>("bed_size"), buildHeight),
ActiveSliceSettings.Instance.BedCenter(), ActiveSliceSettings.Instance.GetValue<Vector2>("print_center"),
ActiveSliceSettings.Instance.BedShape(), ActiveSliceSettings.Instance.BedShape(),
windowMode, windowMode,
autoRotate3DView, autoRotate3DView,
@ -116,8 +116,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
} }
viewGcodeBasic = new ViewGcodeBasic(printItem, viewGcodeBasic = new ViewGcodeBasic(printItem,
new Vector3(ActiveSliceSettings.Instance.BedSize(), buildHeight), new Vector3(ActiveSliceSettings.Instance.GetValue<Vector2>("bed_size"), buildHeight),
ActiveSliceSettings.Instance.BedCenter(), ActiveSliceSettings.Instance.GetValue<Vector2>("print_center"),
ActiveSliceSettings.Instance.BedShape(), gcodeWindowMode); ActiveSliceSettings.Instance.BedShape(), gcodeWindowMode);
if (windowMode == View3DWidget.WindowMode.StandAlone) if (windowMode == View3DWidget.WindowMode.StandAlone)

View file

@ -101,7 +101,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
// offset them to the center of the bed // offset them to the center of the bed
for (int i = 0; i < asyncMeshGroups.Count; i++) for (int i = 0; i < asyncMeshGroups.Count; i++)
{ {
asyncMeshGroupTransforms[i] *= Matrix4X4.CreateTranslation(new Vector3(ActiveSliceSettings.Instance.BedCenter(), 0)); asyncMeshGroupTransforms[i] *= Matrix4X4.CreateTranslation(new Vector3(ActiveSliceSettings.Instance.GetValue<Vector2>("print_center"), 0));
} }
PartHasBeenChanged(); PartHasBeenChanged();

View file

@ -1324,7 +1324,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
if (ActiveSliceSettings.Instance?.GetValue<bool>("center_part_on_bed") == true) if (ActiveSliceSettings.Instance?.GetValue<bool>("center_part_on_bed") == true)
{ {
doCentering = MeshViewerWidget.CenterPartAfterLoad.DO; doCentering = MeshViewerWidget.CenterPartAfterLoad.DO;
bedCenter = ActiveSliceSettings.Instance.BedCenter(); bedCenter = ActiveSliceSettings.Instance.GetValue<Vector2>("print_center");
} }
meshViewerWidget.LoadMesh(printItemWrapper.FileLocation, doCentering, bedCenter); meshViewerWidget.LoadMesh(printItemWrapper.FileLocation, doCentering, bedCenter);
@ -2110,8 +2110,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{ {
AxisAlignedBoundingBox allBounds = MeshViewerWidget.GetAxisAlignedBoundingBox(MeshGroups); AxisAlignedBoundingBox allBounds = MeshViewerWidget.GetAxisAlignedBoundingBox(MeshGroups);
bool onBed = allBounds.minXYZ.z > -.001 && allBounds.minXYZ.z < .001; // really close to the bed bool onBed = allBounds.minXYZ.z > -.001 && allBounds.minXYZ.z < .001; // really close to the bed
RectangleDouble bedRect = new RectangleDouble(0, 0, ActiveSliceSettings.Instance.BedSize().x, ActiveSliceSettings.Instance.BedSize().y); RectangleDouble bedRect = new RectangleDouble(0, 0, ActiveSliceSettings.Instance.GetValue<Vector2>("bed_size").x, ActiveSliceSettings.Instance.GetValue<Vector2>("bed_size").y);
bedRect.Offset(ActiveSliceSettings.Instance.BedCenter() - ActiveSliceSettings.Instance.BedSize() / 2); bedRect.Offset(ActiveSliceSettings.Instance.GetValue<Vector2>("print_center") - ActiveSliceSettings.Instance.GetValue<Vector2>("bed_size") / 2);
bool inBounds = bedRect.Contains(new Vector2(allBounds.minXYZ)) && bedRect.Contains(new Vector2(allBounds.maxXYZ)); bool inBounds = bedRect.Contains(new Vector2(allBounds.minXYZ)) && bedRect.Contains(new Vector2(allBounds.maxXYZ));

View file

@ -126,11 +126,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|| stringEvent.Data == "bed_shape" || stringEvent.Data == "bed_shape"
|| stringEvent.Data == "center_part_on_bed") || stringEvent.Data == "center_part_on_bed")
{ {
viewerVolume = new Vector3(ActiveSliceSettings.Instance.BedSize(), ActiveSliceSettings.Instance.BuildHeight()); viewerVolume = new Vector3(ActiveSliceSettings.Instance.GetValue<Vector2>("bed_size"), ActiveSliceSettings.Instance.GetValue<double>("build_height"));
bedShape = ActiveSliceSettings.Instance.BedShape(); bedShape = ActiveSliceSettings.Instance.BedShape();
bedCenter = ActiveSliceSettings.Instance.BedCenter(); bedCenter = ActiveSliceSettings.Instance.GetValue<Vector2>("print_center");
double buildHeight = ActiveSliceSettings.Instance.BuildHeight(); double buildHeight = ActiveSliceSettings.Instance.GetValue<double>("build_height");
UiThread.RunOnIdle(() => UiThread.RunOnIdle(() =>
{ {
@ -474,7 +474,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
// show the filament used // show the filament used
modelInfoContainer.AddChild(new TextWidget(filamentLengthLabelFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 9)); modelInfoContainer.AddChild(new TextWidget(filamentLengthLabelFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 9));
{ {
double filamentUsed = gcodeViewWidget.LoadedGCode.GetFilamentUsedMm(ActiveSliceSettings.Instance.FilamentDiameter()); double filamentUsed = gcodeViewWidget.LoadedGCode.GetFilamentUsedMm(ActiveSliceSettings.Instance.GetValue<double>("filament_diameter"));
GuiWidget estimatedPrintTime = new TextWidget(string.Format("{0:0.0} mm", filamentUsed), pointSize: 14, textColor: ActiveTheme.Instance.PrimaryTextColor); GuiWidget estimatedPrintTime = new TextWidget(string.Format("{0:0.0} mm", filamentUsed), pointSize: 14, textColor: ActiveTheme.Instance.PrimaryTextColor);
//estimatedPrintTime.HAnchor = Agg.UI.HAnchor.ParentLeft; //estimatedPrintTime.HAnchor = Agg.UI.HAnchor.ParentLeft;
@ -486,7 +486,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
string filamentVolumeLabelFull = string.Format("{0}:", filamentVolumeLabel); string filamentVolumeLabelFull = string.Format("{0}:", filamentVolumeLabel);
modelInfoContainer.AddChild(new TextWidget(filamentVolumeLabelFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 9)); modelInfoContainer.AddChild(new TextWidget(filamentVolumeLabelFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 9));
{ {
double filamentMm3 = gcodeViewWidget.LoadedGCode.GetFilamentCubicMm(ActiveSliceSettings.Instance.FilamentDiameter()); double filamentMm3 = gcodeViewWidget.LoadedGCode.GetFilamentCubicMm(ActiveSliceSettings.Instance.GetValue<double>("filament_diameter"));
GuiWidget estimatedPrintTime = new TextWidget(string.Format("{0:0.00} cm3", filamentMm3 / 1000), pointSize: 14, textColor: ActiveTheme.Instance.PrimaryTextColor); GuiWidget estimatedPrintTime = new TextWidget(string.Format("{0:0.00} cm3", filamentMm3 / 1000), pointSize: 14, textColor: ActiveTheme.Instance.PrimaryTextColor);
//estimatedPrintTime.HAnchor = Agg.UI.HAnchor.ParentLeft; //estimatedPrintTime.HAnchor = Agg.UI.HAnchor.ParentLeft;
@ -509,7 +509,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
density = 1.24; density = 1.24;
} }
double filamentWeightGrams = gcodeViewWidget.LoadedGCode.GetFilamentWeightGrams(ActiveSliceSettings.Instance.FilamentDiameter(), density); double filamentWeightGrams = gcodeViewWidget.LoadedGCode.GetFilamentWeightGrams(ActiveSliceSettings.Instance.GetValue<double>("filament_diameter"), density);
GuiWidget estimatedPrintTime = new TextWidget(string.Format("{0:0.00} g", filamentWeightGrams), pointSize: 14, textColor: ActiveTheme.Instance.PrimaryTextColor); GuiWidget estimatedPrintTime = new TextWidget(string.Format("{0:0.00} g", filamentWeightGrams), pointSize: 14, textColor: ActiveTheme.Instance.PrimaryTextColor);
//estimatedPrintTime.HAnchor = Agg.UI.HAnchor.ParentLeft; //estimatedPrintTime.HAnchor = Agg.UI.HAnchor.ParentLeft;

View file

@ -301,7 +301,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{ {
try try
{ {
gCodeRenderer.GCodeFileToDraw?.GetFilamentUsedMm(ActiveSliceSettings.Instance.FilamentDiameter()); gCodeRenderer.GCodeFileToDraw?.GetFilamentUsedMm(ActiveSliceSettings.Instance.GetValue<double>("filament_diameter"));
} }
catch (Exception e) catch (Exception e)
{ {

View file

@ -41,6 +41,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
enum ResumeState { RemoveHeating, Raising, Homing, FindingResumeLayer, SkippingGCode, PrimingAndMovingToStart, PrintingSlow, PrintingToEnd } enum ResumeState { RemoveHeating, Raising, Homing, FindingResumeLayer, SkippingGCode, PrimingAndMovingToStart, PrintingSlow, PrintingToEnd }
private GCodeFileStream internalStream; private GCodeFileStream internalStream;
private double percentDone; private double percentDone;
double resumeFeedRate;
PrinterMove lastDestination; PrinterMove lastDestination;
QueuedCommandsStream queuedCommands; QueuedCommandsStream queuedCommands;
@ -51,6 +52,13 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
this.internalStream = internalStream; this.internalStream = internalStream;
this.percentDone = percentDone; this.percentDone = percentDone;
resumeFeedRate = ActiveSliceSettings.Instance.GetValue<double>("resume_first_layer_speed");
if (resumeFeedRate == 0)
{
resumeFeedRate = 10;
}
resumeFeedRate *= 60;
queuedCommands = new QueuedCommandsStream(null); queuedCommands = new QueuedCommandsStream(null);
} }
@ -110,7 +118,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
// home y // home y
queuedCommands.Add("G28 Y0"); queuedCommands.Add("G28 Y0");
// move to the place we can home z from // move to the place we can home z from
Vector2 resumePositionXy = ActiveSliceSettings.Instance.ActiveVector2("resume_position_before_z_home"); Vector2 resumePositionXy = ActiveSliceSettings.Instance.GetValue<Vector2>("resume_position_before_z_home");
queuedCommands.Add("G1 X{0:0.000}Y{1:0.000}F{2}".FormatWith(resumePositionXy.x, resumePositionXy.y, MovementControls.XSpeed)); queuedCommands.Add("G1 X{0:0.000}Y{1:0.000}F{2}".FormatWith(resumePositionXy.x, resumePositionXy.y, MovementControls.XSpeed));
// home z // home z
queuedCommands.Add("G28 Z0"); queuedCommands.Add("G28 Z0");
@ -165,7 +173,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
if (ActiveSliceSettings.Instance.GetValue("z_homes_to_max") == "0") // we are homed to the bed if (ActiveSliceSettings.Instance.GetValue("z_homes_to_max") == "0") // we are homed to the bed
{ {
// move to the height we can resume printing from // move to the height we can resume printing from
Vector2 resumePositionXy = ActiveSliceSettings.Instance.ActiveVector2("resume_position_before_z_home"); Vector2 resumePositionXy = ActiveSliceSettings.Instance.GetValue<Vector2>("resume_position_before_z_home");
queuedCommands.Add(CreateMovementLine(new PrinterMove(new VectorMath.Vector3(resumePositionXy.x, resumePositionXy.y, lastDestination.position.z + 5), 0, MovementControls.ZSpeed))); queuedCommands.Add(CreateMovementLine(new PrinterMove(new VectorMath.Vector3(resumePositionXy.x, resumePositionXy.y, lastDestination.position.z + 5), 0, MovementControls.ZSpeed)));
// move just above the actual print position // move just above the actual print position
queuedCommands.Add(CreateMovementLine(new PrinterMove(lastDestination.position + new VectorMath.Vector3(0, 0, 5), 0, MovementControls.XSpeed))); queuedCommands.Add(CreateMovementLine(new PrinterMove(lastDestination.position + new VectorMath.Vector3(0, 0, 5), 0, MovementControls.XSpeed)));
@ -188,25 +196,20 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
case ResumeState.PrintingSlow: case ResumeState.PrintingSlow:
{ {
string lineToSend = internalStream.ReadLine(); string lineToSend = internalStream.ReadLine();
if (lineToSend != null if (lineToSend == null)
&& lineToSend.StartsWith("; LAYER:"))
{ {
if (lineToSend != null return null;
&& LineIsMovement(lineToSend)) }
if (!lineToSend.StartsWith("; LAYER:"))
{
// have not seen the end of this layer so keep printing slow
if (LineIsMovement(lineToSend))
{ {
PrinterMove currentMove = GetPosition(lineToSend, lastDestination); PrinterMove currentMove = GetPosition(lineToSend, lastDestination);
PrinterMove moveToSend = currentMove; PrinterMove moveToSend = currentMove;
double feedRate; moveToSend.feedRate = resumeFeedRate;
string firstLayerSpeed = ActiveSliceSettings.Instance.GetValue("resume_first_layer_speed");
if (!double.TryParse(firstLayerSpeed, out feedRate))
{
feedRate = 10;
}
feedRate *= 60;
moveToSend.feedRate = feedRate;
lineToSend = CreateMovementLine(moveToSend, lastDestination); lineToSend = CreateMovementLine(moveToSend, lastDestination);
lastDestination = currentMove; lastDestination = currentMove;
@ -217,6 +220,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
} }
} }
// we only fall through to here after seeing the next "; Layer:"
resumeState = ResumeState.PrintingToEnd; resumeState = ResumeState.PrintingToEnd;
return ""; return "";

View file

@ -211,7 +211,7 @@ namespace MatterHackers.MatterControl.PrintQueue
if (ActiveSliceSettings.Instance != null) if (ActiveSliceSettings.Instance != null)
{ {
activeFilamentDiameter = 3; activeFilamentDiameter = 3;
if (ActiveSliceSettings.Instance.FilamentDiameter() < 2) if (ActiveSliceSettings.Instance.GetValue<double>("filament_diameter") < 2)
{ {
activeFilamentDiameter = 1.75; activeFilamentDiameter = 1.75;
} }

View file

@ -244,11 +244,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
return targetTemp; return targetTemp;
} }
public int SupportExtruder()
{
return int.Parse(GetValue("support_material_extruder"));
}
public int[] LayerToPauseOn() public int[] LayerToPauseOn()
{ {
string[] userValues = GetValue("layer_to_pause").Split(';'); string[] userValues = GetValue("layer_to_pause").Split(';');
@ -264,21 +259,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
}).ToArray(); }).ToArray();
} }
public double ProbePaperWidth()
{
return double.Parse(GetValue("manual_probe_paper_width"));
}
public int RaftExtruder()
{
return int.Parse(GetValue("raft_extruder"));
}
public double MaxFanSpeed()
{
return ParseDouble(GetValue("max_fan_speed"));
}
public double FillDensity() public double FillDensity()
{ {
string fillDensityValueString = GetValue("fill_density"); string fillDensityValueString = GetValue("fill_density");
@ -304,14 +284,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
return layeredProfile.GetMaterialPresetKey(extruderIndex); return layeredProfile.GetMaterialPresetKey(extruderIndex);
} }
public double FirstLayerExtrusionWidth()
{
AsPercentOfReferenceOrDirect mapper = new AsPercentOfReferenceOrDirect("first_layer_extrusion_width", "notused", "nozzle_diameter");
double firstLayerValue = ParseDouble(mapper.Value);
return firstLayerValue;
}
private static double ParseDouble(string firstLayerValueString) private static double ParseDouble(string firstLayerValueString)
{ {
double firstLayerValue; double firstLayerValue;
@ -322,16 +294,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
return firstLayerValue; return firstLayerValue;
} }
public double LayerHeight()
{
return ParseDouble(GetValue("layer_height"));
}
public Vector2 BedSize()
{
return ActiveVector2("bed_size");
}
public MeshVisualizer.MeshViewerWidget.BedShape BedShape() public MeshVisualizer.MeshViewerWidget.BedShape BedShape()
{ {
switch (GetValue("bed_shape")) switch (GetValue("bed_shape"))
@ -351,21 +313,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
} }
} }
public Vector2 BedCenter()
{
return ActiveVector2("print_center");
}
public double BuildHeight()
{
return ParseDouble(GetValue("build_height"));
}
public Vector2 PrintCenter()
{
return ActiveVector2("print_center");
}
public int ExtruderCount() public int ExtruderCount()
{ {
if (this.GetValue<bool>("extruders_share_temperature")) if (this.GetValue<bool>("extruders_share_temperature"))
@ -401,11 +348,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
return Vector2.Zero; return Vector2.Zero;
} }
public double FilamentDiameter()
{
return ParseDouble(GetValue("filament_diameter"));
}
private PrintLevelingData printLevelingData = null; private PrintLevelingData printLevelingData = null;
public PrintLevelingData GetPrintLevelingData() public PrintLevelingData GetPrintLevelingData()
{ {
@ -420,7 +362,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
printLevelingData.SampledPosition0, printLevelingData.SampledPosition0,
printLevelingData.SampledPosition1, printLevelingData.SampledPosition1,
printLevelingData.SampledPosition2, printLevelingData.SampledPosition2,
ActiveSliceSettings.Instance.PrintCenter()); ActiveSliceSettings.Instance.GetValue<Vector2>("print_center"));
} }
return printLevelingData; return printLevelingData;
@ -452,7 +394,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
levelingData.SampledPosition0, levelingData.SampledPosition0,
levelingData.SampledPosition1, levelingData.SampledPosition1,
levelingData.SampledPosition2, levelingData.SampledPosition2,
ActiveSliceSettings.Instance.PrintCenter()); ActiveSliceSettings.Instance.GetValue<Vector2>("print_center"));
} }
} }
@ -508,6 +450,18 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
int.TryParse(this.GetValue(settingsKey), out result); int.TryParse(this.GetValue(settingsKey), out result);
return (T)(object)(result); return (T)(object)(result);
} }
else if(typeof(T) == typeof(Vector2))
{
string[] twoValues = GetValue(settingsKey).Split(',');
if (twoValues.Length != 2)
{
throw new Exception(string.Format("Not parsing {0} as a Vector2", settingsKey));
}
Vector2 valueAsVector2 = new Vector2();
valueAsVector2.x = ParseDouble(twoValues[0]);
valueAsVector2.y = ParseDouble(twoValues[1]);
return (T)(object)(valueAsVector2);
}
else if (typeof(T) == typeof(double)) else if (typeof(T) == typeof(double))
{ {
string settingsStringh = GetValue(settingsKey); string settingsStringh = GetValue(settingsKey);
@ -518,7 +472,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
if (settingsKey == "first_layer_height") if (settingsKey == "first_layer_height")
{ {
return (T)(object)(LayerHeight() * ratio); return (T)(object)(GetValue<double>("layer_height") * ratio);
}
else if(settingsKey == "first_layer_extrusion_width")
{
return (T)(object)(GetValue<double>("layer_height") * ratio);
} }
return (T)(object)(ratio); return (T)(object)(ratio);
@ -583,19 +541,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
} }
} }
public Vector2 ActiveVector2(string sliceSetting)
{
string[] twoValues = GetValue(sliceSetting).Split(',');
if (twoValues.Length != 2)
{
throw new Exception(string.Format("Not parsing {0} as a Vector2", sliceSetting));
}
Vector2 valueAsVector2 = new Vector2();
valueAsVector2.x = ParseDouble(twoValues[0]);
valueAsVector2.y = ParseDouble(twoValues[1]);
return valueAsVector2;
}
public void ExportAsMatterControlConfig() public void ExportAsMatterControlConfig()
{ {
FileDialog.SaveFileDialog( FileDialog.SaveFileDialog(
@ -664,10 +609,10 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{ {
try try
{ {
if (LayerHeight() > GetValue<double>("nozzle_diameter")) if (GetValue<double>("layer_height") > GetValue<double>("nozzle_diameter"))
{ {
string error = "'Layer Height' must be less than or equal to the 'Nozzle Diameter'.".Localize(); string error = "'Layer Height' must be less than or equal to the 'Nozzle Diameter'.".Localize();
string details = string.Format("Layer Height = {0}\nNozzle Diameter = {1}".Localize(), LayerHeight(), GetValue<double>("nozzle_diameter")); string details = string.Format("Layer Height = {0}\nNozzle Diameter = {1}".Localize(), GetValue<double>("layer_height"), GetValue<double>("nozzle_diameter"));
string location = "Location: 'Settings & Controls' -> 'Settings' -> 'General' -> 'Layers/Surface'".Localize(); string location = "Location: 'Settings & Controls' -> 'Settings' -> 'General' -> 'Layers/Surface'".Localize();
StyledMessageBox.ShowMessageBox(null, string.Format("{0}\n\n{1}\n\n{2}", error, details, location), "Slice Error".Localize()); StyledMessageBox.ShowMessageBox(null, string.Format("{0}\n\n{1}\n\n{2}", error, details, location), "Slice Error".Localize());
return false; return false;
@ -707,7 +652,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
} }
} }
if (FirstLayerExtrusionWidth() > GetValue<double>("nozzle_diameter") * 4) if (GetValue<double>("first_layer_extrusion_width") > GetValue<double>("nozzle_diameter") * 4)
{ {
string error = "'First Layer Extrusion Width' must be less than or equal to the 'Nozzle Diameter' * 4.".Localize(); string error = "'First Layer Extrusion Width' must be less than or equal to the 'Nozzle Diameter' * 4.".Localize();
string details = string.Format("First Layer Extrusion Width = {0}\nNozzle Diameter = {1}".Localize(), GetValue("first_layer_extrusion_width"), GetValue<double>("nozzle_diameter")); string details = string.Format("First Layer Extrusion Width = {0}\nNozzle Diameter = {1}".Localize(), GetValue("first_layer_extrusion_width"), GetValue<double>("nozzle_diameter"));
@ -716,7 +661,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
return false; return false;
} }
if (FirstLayerExtrusionWidth() <= 0) if (GetValue<double>("first_layer_extrusion_width") <= 0)
{ {
string error = "'First Layer Extrusion Width' must be greater than 0.".Localize(); string error = "'First Layer Extrusion Width' must be greater than 0.".Localize();
string details = string.Format("First Layer Extrusion Width = {0}".Localize(), GetValue("first_layer_extrusion_width")); string details = string.Format("First Layer Extrusion Width = {0}".Localize(), GetValue("first_layer_extrusion_width"));
@ -734,10 +679,10 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
return false; return false;
} }
if (MaxFanSpeed() > 100) if (GetValue<double>("max_fan_speed") > 100)
{ {
string error = "The Maximum Fan Speed can only go as high as 100%.".Localize(); string error = "The Maximum Fan Speed can only go as high as 100%.".Localize();
string details = string.Format("It is currently set to {0}.".Localize(), MaxFanSpeed()); string details = string.Format("It is currently set to {0}.".Localize(), GetValue<double>("max_fan_speed"));
string location = "Location: 'Settings & Controls' -> 'Settings' -> 'Filament' -> 'Cooling'".Localize(); string location = "Location: 'Settings & Controls' -> 'Settings' -> 'Filament' -> 'Cooling'".Localize();
StyledMessageBox.ShowMessageBox(null, string.Format("{0}\n\n{1}\n\n{2}", error, details, location), "Slice Error".Localize()); StyledMessageBox.ShowMessageBox(null, string.Format("{0}\n\n{1}\n\n{2}", error, details, location), "Slice Error".Localize());
return false; return false;

View file

@ -229,7 +229,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{ {
get get
{ {
Vector2 PrinteCenter = ActiveSliceSettings.Instance.PrintCenter(); Vector2 PrinteCenter = ActiveSliceSettings.Instance.GetValue<Vector2>("print_center");
return (PrinteCenter.x * 1000).ToString(); return (PrinteCenter.x * 1000).ToString();
} }
} }
@ -246,7 +246,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{ {
get get
{ {
Vector2 PrinteCenter = ActiveSliceSettings.Instance.PrintCenter(); Vector2 PrinteCenter = ActiveSliceSettings.Instance.GetValue<Vector2>("print_center");
return (PrinteCenter.y * 1000).ToString(); return (PrinteCenter.y * 1000).ToString();
} }
} }
@ -288,7 +288,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{ {
double lengthToExtrudeMm = ParseDouble(base.Value); double lengthToExtrudeMm = ParseDouble(base.Value);
// we need to convert mm of filament to mm of extrusion path // we need to convert mm of filament to mm of extrusion path
double amountOfFilamentCubicMms = ActiveSliceSettings.Instance.FilamentDiameter() * MathHelper.Tau * lengthToExtrudeMm; double amountOfFilamentCubicMms = ActiveSliceSettings.Instance.GetValue<double>("filament_diameter") * MathHelper.Tau * lengthToExtrudeMm;
double extrusionSquareSize = ActiveSliceSettings.Instance.GetValue<double>("first_layer_height") * ActiveSliceSettings.Instance.GetValue<double>("nozzle_diameter"); double extrusionSquareSize = ActiveSliceSettings.Instance.GetValue<double>("first_layer_height") * ActiveSliceSettings.Instance.GetValue<double>("nozzle_diameter");
double lineLength = amountOfFilamentCubicMms / extrusionSquareSize; double lineLength = amountOfFilamentCubicMms / extrusionSquareSize;

View file

@ -310,7 +310,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{ {
get get
{ {
Vector2 PrinteCenter = ActiveSliceSettings.Instance.PrintCenter(); Vector2 PrinteCenter = ActiveSliceSettings.Instance.GetValue<Vector2>("print_center");
return "[{0},{1}]".FormatWith(PrinteCenter.x, PrinteCenter.y); return "[{0},{1}]".FormatWith(PrinteCenter.x, PrinteCenter.y);
} }
@ -330,7 +330,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{ {
double lengthToExtrudeMm = ParseDouble(base.Value); double lengthToExtrudeMm = ParseDouble(base.Value);
// we need to convert mm of filament to mm of extrusion path // we need to convert mm of filament to mm of extrusion path
double amountOfFilamentCubicMms = ActiveSliceSettings.Instance.FilamentDiameter() * MathHelper.Tau * lengthToExtrudeMm; double amountOfFilamentCubicMms = ActiveSliceSettings.Instance.GetValue<double>("filament_diameter") * MathHelper.Tau * lengthToExtrudeMm;
double extrusionSquareSize = ActiveSliceSettings.Instance.GetValue<double>("first_layer_height") * ActiveSliceSettings.Instance.GetValue<double>("nozzle_diameter"); double extrusionSquareSize = ActiveSliceSettings.Instance.GetValue<double>("first_layer_height") * ActiveSliceSettings.Instance.GetValue<double>("nozzle_diameter");
double lineLength = amountOfFilamentCubicMms / extrusionSquareSize; double lineLength = amountOfFilamentCubicMms / extrusionSquareSize;

View file

@ -177,9 +177,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
// If we have support enabled and are using an extruder other than 0 for it // If we have support enabled and are using an extruder other than 0 for it
if (ActiveSliceSettings.Instance.GetValue<bool>("support_material")) if (ActiveSliceSettings.Instance.GetValue<bool>("support_material"))
{ {
if (ActiveSliceSettings.Instance.SupportExtruder() != 0) if (ActiveSliceSettings.Instance.GetValue<int>("support_material_extruder") != 0)
{ {
int supportExtruder = Math.Max(0, Math.Min(ActiveSliceSettings.Instance.ExtruderCount() - 1, ActiveSliceSettings.Instance.SupportExtruder() - 1)); int supportExtruder = Math.Max(0, Math.Min(ActiveSliceSettings.Instance.ExtruderCount() - 1, ActiveSliceSettings.Instance.GetValue<int>("support_material_extruder") - 1));
extrudersUsed[supportExtruder] = true; extrudersUsed[supportExtruder] = true;
} }
} }
@ -187,9 +187,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
// If we have raft enabled and are using an extruder other than 0 for it // If we have raft enabled and are using an extruder other than 0 for it
if (ActiveSliceSettings.Instance.GetValue<bool>("create_raft")) if (ActiveSliceSettings.Instance.GetValue<bool>("create_raft"))
{ {
if (ActiveSliceSettings.Instance.RaftExtruder() != 0) if (ActiveSliceSettings.Instance.GetValue<int>("raft_extruder") != 0)
{ {
int raftExtruder = Math.Max(0, Math.Min(ActiveSliceSettings.Instance.ExtruderCount() - 1, ActiveSliceSettings.Instance.RaftExtruder() - 1)); int raftExtruder = Math.Max(0, Math.Min(ActiveSliceSettings.Instance.ExtruderCount() - 1, ActiveSliceSettings.Instance.GetValue<int>("raft_extruder") - 1));
extrudersUsed[raftExtruder] = true; extrudersUsed[raftExtruder] = true;
} }
} }

@ -1 +1 @@
Subproject commit 7ddec45bb3886ec3f619a3d608eb147e7b1ba613 Subproject commit 02f057d6f7ba993ec5206b1857cf82721bd973a2

View file

@ -44,11 +44,11 @@ namespace MatterHackers.MatterControl.Plugins.TextCreator
BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
double buildHeight = ActiveSliceSettings.Instance.BuildHeight(); double buildHeight = ActiveSliceSettings.Instance.GetValue<double>("build_height");
part3DView = new View3DTextCreator( part3DView = new View3DTextCreator(
new Vector3(ActiveSliceSettings.Instance.BedSize(), buildHeight), new Vector3(ActiveSliceSettings.Instance.GetValue<Vector2>("bed_size"), buildHeight),
ActiveSliceSettings.Instance.BedCenter(), ActiveSliceSettings.Instance.GetValue<Vector2>("print_center"),
ActiveSliceSettings.Instance.BedShape()); ActiveSliceSettings.Instance.BedShape());
#if __ANDROID__ #if __ANDROID__