Got the bed control to be in sync with the extruder controls
This commit is contained in:
parent
0a569da477
commit
99d690e9b0
3 changed files with 104 additions and 76 deletions
|
|
@ -28,12 +28,14 @@ either expressed or implied, of the FreeBSD Project.
|
|||
*/
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.ImageProcessing;
|
||||
using MatterHackers.Agg.Platform;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.ConfigurationPage;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
|
||||
|
|
@ -41,12 +43,11 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
{
|
||||
internal class TemperatureWidgetBed : TemperatureWidgetBase
|
||||
{
|
||||
private EditableNumberDisplay settingsTemperature;
|
||||
private string sliceSettingsNote = "Note: Slice Settings are applied before the print actually starts. Changes while printing will not effect the active print.".Localize();
|
||||
private string waitingForBedToHeatMessage = "The bed is currently heating and its target temperature cannot be changed until it reaches {0}°C.\n\nYou can set the starting bed temperature in SETTINGS -> Filament -> Temperatures.\n\n{1}".Localize();
|
||||
private string waitingForBedToHeatTitle = "Waiting For Bed To Heat".Localize();
|
||||
|
||||
private TextWidget settingsTemperature;
|
||||
|
||||
public TemperatureWidgetBed(PrinterConnection printerConnection)
|
||||
: base(printerConnection, "150.3°")
|
||||
{
|
||||
|
|
@ -66,24 +67,13 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
printerConnection.BedTemperatureRead.RegisterEvent((s, e) => DisplayCurrentTemperature(), ref unregisterEvents);
|
||||
}
|
||||
|
||||
protected override int ActualTemperature => (int)printerConnection.ActualBedTemperature;
|
||||
protected override int TargetTemperature => (int)printerConnection.TargetBedTemperature;
|
||||
|
||||
protected override int ActualTemperature => (int)printerConnection.ActualBedTemperature;
|
||||
|
||||
protected override void SetTargetTemperature(double targetTemp)
|
||||
public override void OnClosed(ClosedEventArgs e)
|
||||
{
|
||||
double goalTemp = (int)(targetTemp + .5);
|
||||
if (printerConnection.PrinterIsPrinting
|
||||
&& printerConnection.DetailedPrintingState == DetailedPrintingState.HeatingBed
|
||||
&& goalTemp != printerConnection.TargetBedTemperature)
|
||||
{
|
||||
string message = string.Format(waitingForBedToHeatMessage, printerConnection.TargetBedTemperature, sliceSettingsNote);
|
||||
StyledMessageBox.ShowMessageBox(null, message, waitingForBedToHeatTitle);
|
||||
}
|
||||
else
|
||||
{
|
||||
printerConnection.TargetBedTemperature = (int)(targetTemp + .5);
|
||||
}
|
||||
ActiveSliceSettings.MaterialPresetChanged -= ActiveSliceSettings_MaterialPresetChanged;
|
||||
base.OnClosed(e);
|
||||
}
|
||||
|
||||
protected override GuiWidget GetPopupContent()
|
||||
|
|
@ -105,7 +95,10 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
};
|
||||
widget.AddChild(container);
|
||||
|
||||
container.AddChild(new SettingsItem(
|
||||
|
||||
GuiWidget hotendRow;
|
||||
|
||||
container.AddChild(hotendRow = new SettingsItem(
|
||||
"Heated Bed".Localize(),
|
||||
new SettingsItem.ToggleSwitchConfig()
|
||||
{
|
||||
|
|
@ -114,36 +107,37 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
{
|
||||
var goalTemp = itemChecked ? printerConnection.PrinterSettings.GetValue<double>(SettingsKey.bed_temperature) : 0;
|
||||
|
||||
if (printerConnection.PrinterIsPrinting
|
||||
&& printerConnection.DetailedPrintingState == DetailedPrintingState.HeatingBed
|
||||
&& goalTemp != printerConnection.TargetBedTemperature)
|
||||
if (itemChecked)
|
||||
{
|
||||
string sliceSettingsNote = "Note: Slice Settings are applied before the print actually starts. Changes while printing will not effect the active print.";
|
||||
string message = string.Format(
|
||||
"The bed is currently heating and its target temperature cannot be changed until it reaches {0}°C.\n\nYou can set the starting bed temperature in 'Slice Settings' -> 'Filament'.\n\n{1}",
|
||||
printerConnection.TargetBedTemperature,
|
||||
sliceSettingsNote);
|
||||
|
||||
StyledMessageBox.ShowMessageBox(null, message, "Waiting For Bed To Heat");
|
||||
SetTargetTemperature(settingsTemperature.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (itemChecked)
|
||||
{
|
||||
SetTargetTemperature(printerConnection.PrinterSettings.GetValue<double>(SettingsKey.bed_temperature));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetTargetTemperature(0);
|
||||
}
|
||||
SetTargetTemperature(0);
|
||||
}
|
||||
}
|
||||
},
|
||||
enforceGutter: false));
|
||||
|
||||
settingsTemperature = new TextWidget(printerConnection.PrinterSettings.GetValue<double>(SettingsKey.bed_temperature).ToString())
|
||||
CheckBox heatToggle = hotendRow.ChildrenRecursive<CheckBox>().FirstOrDefault();
|
||||
heatToggle.Name = "Toggle Heater";
|
||||
|
||||
// put in the temp control
|
||||
settingsTemperature = new EditableNumberDisplay(printerConnection.PrinterSettings.GetValue<double>(SettingsKey.bed_temperature), "000")
|
||||
{
|
||||
AutoExpandBoundsToText = true
|
||||
BorderColor = RGBA_Bytes.Black,
|
||||
Name = "Temperature Input"
|
||||
};
|
||||
settingsTemperature.ValueChanged += (s, e) =>
|
||||
{
|
||||
if (heatToggle.Checked)
|
||||
{
|
||||
SetTargetTemperature(settingsTemperature.Value);
|
||||
if (settingsTemperature.Value == 0)
|
||||
{
|
||||
heatToggle.Checked = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
container.AddChild(new SettingsItem(
|
||||
|
|
@ -151,11 +145,57 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
settingsTemperature,
|
||||
enforceGutter: false));
|
||||
|
||||
// add in the temp graph
|
||||
Action fillGraph = null;
|
||||
var graph = new DataViewGraph()
|
||||
{
|
||||
DynamiclyScaleRange = false,
|
||||
MinValue = 0,
|
||||
ShowGoal = true,
|
||||
GoalColor = ActiveTheme.Instance.PrimaryAccentColor,
|
||||
GoalValue = settingsTemperature.Value,
|
||||
MaxValue = 150, // could come from some profile value in the future
|
||||
Width = widget.Width - 20,
|
||||
Height = 35, // this works better if it is a common multiple of the Width
|
||||
Margin = new BorderDouble(0, 5, 0, 0),
|
||||
};
|
||||
settingsTemperature.ValueChanged += (s, e) =>
|
||||
{
|
||||
graph.GoalValue = settingsTemperature.Value;
|
||||
};
|
||||
fillGraph = () =>
|
||||
{
|
||||
graph.AddData(this.ActualTemperature);
|
||||
if (!this.HasBeenClosed)
|
||||
{
|
||||
UiThread.RunOnIdle(fillGraph, 1);
|
||||
}
|
||||
};
|
||||
|
||||
UiThread.RunOnIdle(fillGraph);
|
||||
container.AddChild(graph);
|
||||
|
||||
ActiveSliceSettings.MaterialPresetChanged += ActiveSliceSettings_MaterialPresetChanged;
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
protected override void SetTargetTemperature(double targetTemp)
|
||||
{
|
||||
double goalTemp = (int)(targetTemp + .5);
|
||||
if (printerConnection.PrinterIsPrinting
|
||||
&& printerConnection.DetailedPrintingState == DetailedPrintingState.HeatingBed
|
||||
&& goalTemp != printerConnection.TargetBedTemperature)
|
||||
{
|
||||
string message = string.Format(waitingForBedToHeatMessage, printerConnection.TargetBedTemperature, sliceSettingsNote);
|
||||
StyledMessageBox.ShowMessageBox(null, message, waitingForBedToHeatTitle);
|
||||
}
|
||||
else
|
||||
{
|
||||
printerConnection.TargetBedTemperature = (int)(targetTemp + .5);
|
||||
}
|
||||
}
|
||||
|
||||
private void ActiveSliceSettings_MaterialPresetChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (settingsTemperature != null && printerConnection.PrinterSettings != null)
|
||||
|
|
@ -163,11 +203,5 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
settingsTemperature.Text = printerConnection.PrinterSettings.GetValue(SettingsKey.bed_temperature);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnClosed(ClosedEventArgs e)
|
||||
{
|
||||
ActiveSliceSettings.MaterialPresetChanged -= ActiveSliceSettings_MaterialPresetChanged;
|
||||
base.OnClosed(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -35,7 +35,6 @@ using MatterHackers.Localizations;
|
|||
using MatterHackers.MatterControl.ConfigurationPage;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.MatterControl.PrinterControls;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
|
||||
namespace MatterHackers.MatterControl.ActionBar
|
||||
|
|
@ -43,7 +42,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
internal class ControlContentExtruder : FlowLayoutWidget
|
||||
{
|
||||
private int moveAmount = 1;
|
||||
PrinterConnection printerConnection;
|
||||
private PrinterConnection printerConnection;
|
||||
|
||||
internal ControlContentExtruder(PrinterConnection printerConnection, int extruderIndex, TextImageButtonFactory buttonFactory)
|
||||
: base(FlowDirection.TopToBottom)
|
||||
|
|
@ -170,15 +169,13 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
internal class TemperatureWidgetHotend : TemperatureWidgetBase
|
||||
{
|
||||
private TextImageButtonFactory buttonFactory;
|
||||
private int hotendIndex = -1;
|
||||
|
||||
private EditableNumberDisplay settingsTemperature;
|
||||
private string sliceSettingsNote = "Note: Slice Settings are applied before the print actually starts. Changes while printing will not effect the active print.".Localize();
|
||||
private string waitingForExtruderToHeatMessage = "The extruder is currently heating and its target temperature cannot be changed until it reaches {0}°C.\n\nYou can set the starting extruder temperature in 'Slice Settings' -> 'Filament'.\n\n{1}".Localize();
|
||||
|
||||
private TextImageButtonFactory buttonFactory;
|
||||
|
||||
private EditableNumberDisplay settingsTemperature;
|
||||
|
||||
public TemperatureWidgetHotend(PrinterConnection printerConnection, int hotendIndex, TextImageButtonFactory buttonFactory)
|
||||
: base(printerConnection, "150.3°")
|
||||
{
|
||||
|
|
@ -193,24 +190,13 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
printerConnection.HotendTemperatureRead.RegisterEvent((s, e) => DisplayCurrentTemperature(), ref unregisterEvents);
|
||||
}
|
||||
|
||||
protected override int ActualTemperature => (int)printerConnection.GetActualHotendTemperature(hotendIndex);
|
||||
protected override int TargetTemperature => (int)printerConnection.GetTargetHotendTemperature(hotendIndex);
|
||||
|
||||
protected override int ActualTemperature => (int)printerConnection.GetActualHotendTemperature(hotendIndex);
|
||||
|
||||
protected override void SetTargetTemperature(double targetTemp)
|
||||
public override void OnClosed(ClosedEventArgs e)
|
||||
{
|
||||
double goalTemp = (int)(targetTemp + .5);
|
||||
if (printerConnection.PrinterIsPrinting
|
||||
&& printerConnection.DetailedPrintingState == DetailedPrintingState.HeatingExtruder
|
||||
&& goalTemp != printerConnection.GetTargetHotendTemperature(hotendIndex))
|
||||
{
|
||||
string message = string.Format(waitingForExtruderToHeatMessage, printerConnection.GetTargetHotendTemperature(hotendIndex), sliceSettingsNote);
|
||||
StyledMessageBox.ShowMessageBox(null, message, "Waiting For Extruder To Heat".Localize());
|
||||
}
|
||||
else
|
||||
{
|
||||
printerConnection.SetTargetHotendTemperature(hotendIndex, (int)(targetTemp + .5));
|
||||
}
|
||||
ActiveSliceSettings.MaterialPresetChanged -= ActiveSliceSettings_MaterialPresetChanged;
|
||||
base.OnClosed(e);
|
||||
}
|
||||
|
||||
protected override GuiWidget GetPopupContent()
|
||||
|
|
@ -268,7 +254,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
if (heatToggle.Checked)
|
||||
{
|
||||
SetTargetTemperature(settingsTemperature.Value);
|
||||
if(settingsTemperature.Value == 0)
|
||||
if (settingsTemperature.Value == 0)
|
||||
{
|
||||
heatToggle.Checked = false;
|
||||
}
|
||||
|
|
@ -290,7 +276,6 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
MaxValue = 280, // could come from some profile value in the future
|
||||
Width = widget.Width - 20,
|
||||
Height = 35, // this works better if it is a common multiple of the Width
|
||||
|
||||
};
|
||||
settingsTemperature.ValueChanged += (s, e) =>
|
||||
{
|
||||
|
|
@ -306,7 +291,6 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
};
|
||||
|
||||
UiThread.RunOnIdle(fillGraph);
|
||||
|
||||
container.AddChild(graph);
|
||||
|
||||
// put in the material selector
|
||||
|
|
@ -363,7 +347,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
{
|
||||
AutoExpandBoundsToText = true,
|
||||
TextColor = RGBA_Bytes.Black,
|
||||
HAnchor = HAnchor.Left,
|
||||
HAnchor = HAnchor.Left,
|
||||
});
|
||||
container.AddChild(new ControlContentExtruder(printerConnection, extruderIndex, buttonFactory));
|
||||
}
|
||||
|
|
@ -378,6 +362,22 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
return widget;
|
||||
}
|
||||
|
||||
protected override void SetTargetTemperature(double targetTemp)
|
||||
{
|
||||
double goalTemp = (int)(targetTemp + .5);
|
||||
if (printerConnection.PrinterIsPrinting
|
||||
&& printerConnection.DetailedPrintingState == DetailedPrintingState.HeatingExtruder
|
||||
&& goalTemp != printerConnection.GetTargetHotendTemperature(hotendIndex))
|
||||
{
|
||||
string message = string.Format(waitingForExtruderToHeatMessage, printerConnection.GetTargetHotendTemperature(hotendIndex), sliceSettingsNote);
|
||||
StyledMessageBox.ShowMessageBox(null, message, "Waiting For Extruder To Heat".Localize());
|
||||
}
|
||||
else
|
||||
{
|
||||
printerConnection.SetTargetHotendTemperature(hotendIndex, (int)(targetTemp + .5));
|
||||
}
|
||||
}
|
||||
|
||||
private void ActiveSliceSettings_MaterialPresetChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (settingsTemperature != null && printerConnection.PrinterSettings != null)
|
||||
|
|
@ -385,11 +385,5 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
settingsTemperature.Text = printerConnection.PrinterSettings.GetValue(SettingsKey.temperature);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnClosed(ClosedEventArgs e)
|
||||
{
|
||||
ActiveSliceSettings.MaterialPresetChanged -= ActiveSliceSettings_MaterialPresetChanged;
|
||||
base.OnClosed(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -96,7 +96,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
{
|
||||
double xPos = Width - ((i * pixelSkip + TotalAdds) % Width);
|
||||
int inset = (int)((i % 2) == 0 ? Height / 6 : Height / 3);
|
||||
graphics2D.Line(xPos, inset, xPos, Height - inset, new RGBA_Bytes(backgroundGridColor, 64));
|
||||
graphics2D.Line(xPos, inset, xPos, Height - inset, new RGBA_Bytes(backgroundGridColor, 120));
|
||||
}
|
||||
|
||||
for (int i = 0; i < Width - 1; i++)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue