Refactoring print <-> setup... button to have better state
This commit is contained in:
parent
2c5208a845
commit
46d076fc66
3 changed files with 50 additions and 41 deletions
|
|
@ -25,16 +25,32 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
{
|
||||
}
|
||||
|
||||
public bool HasBeenRunAndEnabled(PrinterConfig printer)
|
||||
public static bool NeedsToBeRun(PrinterConfig printer)
|
||||
{
|
||||
PrintLevelingData levelingData = printer.Settings.Helpers.GetPrintLevelingData();
|
||||
|
||||
var required = printer.Settings.GetValue<bool>(SettingsKey.print_leveling_required_to_print);
|
||||
if (required && levelingData == null)
|
||||
{
|
||||
// need but don't have data
|
||||
return true;
|
||||
}
|
||||
|
||||
var enabled = ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.print_leveling_enabled);
|
||||
// check if leveling is turned on
|
||||
if(!ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.print_leveling_enabled))
|
||||
if (required && !enabled)
|
||||
{
|
||||
// need but not turned on
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!required && !enabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// check that there are no duplicate points
|
||||
var positionCounts = from x in SampledPositions
|
||||
var positionCounts = from x in levelingData.SampledPositions
|
||||
group x by x into g
|
||||
let count = g.Count()
|
||||
orderby count descending
|
||||
|
|
@ -44,14 +60,14 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
{
|
||||
if(x.Count > 1)
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// check that the solution last measured is the currently selected solution
|
||||
if(printer.Settings.GetValue<LevelingSystem>(SettingsKey.print_leveling_solution) != LevelingSystem)
|
||||
if(printer.Settings.GetValue<LevelingSystem>(SettingsKey.print_leveling_solution) != levelingData.LevelingSystem)
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// check that the bed temperature at probe time was close enough to the current print bed temp
|
||||
|
|
@ -60,47 +76,46 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
: 0;
|
||||
|
||||
// check that it is within 10 degrees
|
||||
if(Math.Abs(reqiredLevlingTemp - BedTemperature) > 10)
|
||||
if(Math.Abs(reqiredLevlingTemp - levelingData.BedTemperature) > 10)
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// check that the number of poins sampled is correct for the solution
|
||||
switch (LevelingSystem)
|
||||
switch (levelingData.LevelingSystem)
|
||||
{
|
||||
case LevelingSystem.Probe3Points:
|
||||
if (SampledPositions.Count != 3) // different criteria for what is not initialized
|
||||
if (levelingData.SampledPositions.Count != 3) // different criteria for what is not initialized
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case LevelingSystem.Probe7PointRadial:
|
||||
if (SampledPositions.Count != 7) // different criteria for what is not initialized
|
||||
if (levelingData.SampledPositions.Count != 7) // different criteria for what is not initialized
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case LevelingSystem.Probe13PointRadial:
|
||||
if (SampledPositions.Count != 13) // different criteria for what is not initialized
|
||||
if (levelingData.SampledPositions.Count != 13) // different criteria for what is not initialized
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case LevelingSystem.Probe3x3Mesh:
|
||||
if (SampledPositions.Count != 9) // different criteria for what is not initialized
|
||||
if (levelingData.SampledPositions.Count != 9) // different criteria for what is not initialized
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case LevelingSystem.Probe5x5Mesh:
|
||||
if (SampledPositions.Count != 25) // different criteria for what is not initialized
|
||||
if (levelingData.SampledPositions.Count != 25) // different criteria for what is not initialized
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -108,7 +123,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool SamplesAreSame(List<Vector3> sampledPositions)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue