commit
362be76526
9 changed files with 103 additions and 77 deletions
|
|
@ -149,12 +149,11 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
}
|
||||
else
|
||||
{
|
||||
var firtSheet = this.Descendants<SheetObject3D>().FirstOrDefault();
|
||||
if (firtSheet != null)
|
||||
var controledSheet = ControledSheet;
|
||||
if (controledSheet != null)
|
||||
{
|
||||
// We don't have any cache of the cell content, get the current content
|
||||
double.TryParse(firtSheet.SheetData.GetCellValue(cellId2), out double value);
|
||||
cellData2 = value.ToString();
|
||||
cellData2 = controledSheet.SheetData.GetCellValue(cellId2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -164,6 +163,8 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
return (null, null);
|
||||
}
|
||||
|
||||
private SheetObject3D ControledSheet => this.Descendants<SheetObject3D>().ToArray()[0];//.FirstOrDefault();
|
||||
// this.Children.Where(s => s is SheetObject3D).FirstOrDefault() as SheetObject3D;
|
||||
|
||||
private void RecalculateSheet()
|
||||
{
|
||||
|
|
@ -174,10 +175,10 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
if (cellData.StartsWith("="))
|
||||
{
|
||||
var expression = new DoubleOrExpression(cellData);
|
||||
var firtSheet = this.Descendants<SheetObject3D>().FirstOrDefault();
|
||||
if (firtSheet != null)
|
||||
var controledSheet = ControledSheet;
|
||||
if (controledSheet != null)
|
||||
{
|
||||
var cell = firtSheet.SheetData[cellId];
|
||||
var cell = controledSheet.SheetData[cellId];
|
||||
if (cell != null)
|
||||
{
|
||||
cell.Expression = expression.Value(this).ToString();
|
||||
|
|
@ -189,16 +190,16 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
if (SurfacedEditors.Any(se => se.StartsWith("!"))
|
||||
&& !this.RebuildLocked)
|
||||
{
|
||||
var firtSheet = this.Descendants<SheetObject3D>().FirstOrDefault();
|
||||
var controledSheet = ControledSheet;
|
||||
|
||||
var componentLock = this.RebuildLock();
|
||||
firtSheet.SheetData.Recalculate();
|
||||
controledSheet.SheetData.Recalculate();
|
||||
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
// wait until the sheet is done rebuilding (or 30 seconds)
|
||||
var startTime = UiThread.CurrentTimerMs;
|
||||
while (firtSheet.RebuildLocked
|
||||
while (controledSheet.RebuildLocked
|
||||
&& startTime + 30000 < UiThread.CurrentTimerMs)
|
||||
{
|
||||
Thread.Sleep(1);
|
||||
|
|
|
|||
|
|
@ -118,14 +118,17 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
&& lineToWrite.StartsWith("; LAYER_HEIGHT:"))
|
||||
{
|
||||
double layerHeight = 0;
|
||||
// this gives us the layer height we will be at AFTER this layer is done printing
|
||||
if (GCodeFile.GetFirstNumberAfter("; LAYER_HEIGHT", lineToWrite, ref layerHeight, out _, stopCheckingString: ":"))
|
||||
{
|
||||
accumulatedLayerHeight += layerHeight;
|
||||
// check if we are above the accumulated at the start of the layer but before adding in this layer height
|
||||
if (accumulatedLayerHeight > WorldZ)
|
||||
{
|
||||
hasBeenReached = true;
|
||||
yield return $"{GCodeToSend} ; G-Code from Scene Object";
|
||||
}
|
||||
|
||||
accumulatedLayerHeight += layerHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,38 +59,18 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
{
|
||||
lock (locker)
|
||||
{
|
||||
if (!tabelCalculated)
|
||||
{
|
||||
BuildTableConstants();
|
||||
}
|
||||
|
||||
var cell = this[cellId];
|
||||
|
||||
if (cell != null)
|
||||
{
|
||||
var expression = cell.Expression;
|
||||
{
|
||||
return GetCellValue(cell);
|
||||
}
|
||||
|
||||
if (expression.StartsWith("="))
|
||||
{
|
||||
expression = expression.Substring(1);
|
||||
var evaluator = new Expression(expression.ToLower());
|
||||
AddConstants(evaluator);
|
||||
var value = evaluator.calculate();
|
||||
|
||||
return value.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
// return the expression without evaluation
|
||||
return expression;
|
||||
}
|
||||
}
|
||||
|
||||
return "0";
|
||||
return "0";
|
||||
}
|
||||
}
|
||||
|
||||
public string EvaluateExpression(string expression)
|
||||
public string GetCellValue(TableCell cell)
|
||||
{
|
||||
lock (locker)
|
||||
{
|
||||
|
|
@ -99,11 +79,42 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
BuildTableConstants();
|
||||
}
|
||||
|
||||
if(expression.StartsWith("="))
|
||||
var expression = cell.Expression;
|
||||
|
||||
if (expression.StartsWith("="))
|
||||
{
|
||||
expression = expression.Substring(1);
|
||||
var evaluator = new Expression(expression.ToLower());
|
||||
AddConstants(evaluator);
|
||||
var value = evaluator.calculate();
|
||||
|
||||
return value.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
// return the expression without evaluation
|
||||
return expression;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string EvaluateExpression(string inExpression)
|
||||
{
|
||||
lock (locker)
|
||||
{
|
||||
if (!tabelCalculated)
|
||||
{
|
||||
BuildTableConstants();
|
||||
}
|
||||
|
||||
var expression = inExpression;
|
||||
|
||||
if (expression.StartsWith("="))
|
||||
{
|
||||
// to handle string values we first check if the expression is a cell reference
|
||||
expression = expression.Substring(1).Trim();
|
||||
|
||||
// if it is a direct cell reference than return that cells value
|
||||
// if it might be a direct cell reference check for column row data
|
||||
if (expression.Length == 2)
|
||||
{
|
||||
var column = (uint)expression.Substring(0, 1).ToUpper()[0] - 'A';
|
||||
|
|
@ -113,9 +124,24 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
return GetCellValue(CellId((int)column, (int)row));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var evaluator = new Expression(expression.ToLower());
|
||||
// check if it is the exact name of a cell
|
||||
foreach (var row in Rows)
|
||||
{
|
||||
foreach (var cell in row.Cells)
|
||||
{
|
||||
if (expression.Equals(cell.Name, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return GetCellValue(cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// fall through to evaluate the expression
|
||||
}
|
||||
|
||||
var evaluator = new Expression(expression.ToLower());
|
||||
AddConstants(evaluator);
|
||||
var value = evaluator.calculate();
|
||||
|
||||
|
|
|
|||
|
|
@ -507,26 +507,20 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
return (T)(object)inputExpression;
|
||||
}
|
||||
|
||||
if (double.TryParse(inputExpression, out var result))
|
||||
double.TryParse(inputExpression, out var result);
|
||||
|
||||
if (typeof(T) == typeof(double))
|
||||
{
|
||||
if (typeof(T) == typeof(double))
|
||||
{
|
||||
return (T)(object)result;
|
||||
}
|
||||
if (typeof(T) == typeof(int))
|
||||
{
|
||||
return (T)(object)(int)Math.Round(result);
|
||||
}
|
||||
return (T)(object)result;
|
||||
}
|
||||
if (typeof(T) == typeof(int))
|
||||
{
|
||||
return (T)(object)(int)Math.Round(result);
|
||||
}
|
||||
|
||||
if (typeof(T) == typeof(double))
|
||||
{
|
||||
return (T)(object)0;
|
||||
}
|
||||
|
||||
return (T)(object)(int)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find the sheet that the given item will reference
|
||||
|
|
|
|||
|
|
@ -331,9 +331,9 @@ namespace MatterHackers.MatterControl.Library.Export
|
|||
|
||||
accumulatedStream = new BabyStepsStream(printer, accumulatedStream);
|
||||
|
||||
accumulatedStream = new RemoveNOPsStream(printer, accumulatedStream);
|
||||
|
||||
accumulatedStream = new RunSceneGCodeProcesorsStream(printer, accumulatedStream, queuedCommandStream);
|
||||
|
||||
accumulatedStream = new RemoveNOPsStream(printer, accumulatedStream);
|
||||
|
||||
accumulatedStream = new ProcessWriteRegexStream(printer, accumulatedStream, queuedCommandStream);
|
||||
|
||||
|
|
|
|||
|
|
@ -65,6 +65,18 @@ namespace MatterHackers.MatterControl.Library
|
|||
{
|
||||
Category = this.Name
|
||||
});
|
||||
|
||||
Items.Add(new GeneratorItem(
|
||||
"Pause".Localize(),
|
||||
async () =>
|
||||
{
|
||||
var gcodeObject = await SendGCodeObject3D.Create();
|
||||
gcodeObject.GCodeToSend = "M226";
|
||||
return gcodeObject;
|
||||
})
|
||||
{
|
||||
Category = this.Name
|
||||
});
|
||||
}
|
||||
|
||||
private class StaticDataItem : ILibraryAssetStream
|
||||
|
|
|
|||
|
|
@ -595,23 +595,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
if (cell != null)
|
||||
{
|
||||
// create an expresion editor
|
||||
var field = new ExpressionField(theme)
|
||||
var field = new TextField(theme)
|
||||
{
|
||||
Name = cellId + " Field"
|
||||
Name = cellId + " Field",
|
||||
};
|
||||
field.Initialize(0);
|
||||
if (cellData.Contains("="))
|
||||
{
|
||||
field.SetValue(cellData, false);
|
||||
}
|
||||
else // make sure it is formatted
|
||||
{
|
||||
double.TryParse(cellData, out double value);
|
||||
var format = "0." + new string('#', 5);
|
||||
field.SetValue(value.ToString(format), false);
|
||||
}
|
||||
|
||||
field.ClearUndoHistory();
|
||||
field.SetValue(cellData, false);
|
||||
field.ClearUndoHistory();
|
||||
field.Content.HAnchor = HAnchor.Stretch;
|
||||
|
||||
var doOrUndoing = false;
|
||||
field.ValueChanged += (s, e) =>
|
||||
|
|
@ -624,7 +615,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
doOrUndoing = true;
|
||||
editorList[editorIndex] = "!" + cellId + "," + oldValue;
|
||||
var expression = new DoubleOrExpression(oldValue);
|
||||
var expression = new StringOrExpression(oldValue);
|
||||
cell.Expression = expression.Value(componentObject).ToString();
|
||||
componentObject.Invalidate(InvalidateType.SheetUpdated);
|
||||
doOrUndoing = false;
|
||||
|
|
@ -633,7 +624,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
doOrUndoing = true;
|
||||
editorList[editorIndex] = "!" + cellId + "," + newValue;
|
||||
var expression = new DoubleOrExpression(newValue);
|
||||
var expression = new StringOrExpression(newValue);
|
||||
cell.Expression = expression.Value(componentObject).ToString();
|
||||
componentObject.Invalidate(InvalidateType.SheetUpdated);
|
||||
doOrUndoing = false;
|
||||
|
|
|
|||
|
|
@ -2442,8 +2442,6 @@ Make sure that your printer is turned on. Some printers will appear to be connec
|
|||
{
|
||||
accumulatedStream = new SendProgressStream(gCodeFileSwitcher, Printer);
|
||||
}
|
||||
|
||||
accumulatedStream = pauseHandlingStream = new PauseHandlingStream(Printer, accumulatedStream);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -2494,8 +2492,9 @@ Make sure that your printer is turned on. Some printers will appear to be connec
|
|||
accumulatedStream = softwareEndstopsExStream12;
|
||||
}
|
||||
|
||||
accumulatedStream = new RemoveNOPsStream(Printer, accumulatedStream);
|
||||
accumulatedStream = pauseHandlingStream = new PauseHandlingStream(Printer, accumulatedStream);
|
||||
accumulatedStream = new RunSceneGCodeProcesorsStream(Printer, accumulatedStream, queuedCommandStream);
|
||||
accumulatedStream = new RemoveNOPsStream(Printer, accumulatedStream);
|
||||
|
||||
processWriteRegexStream = new ProcessWriteRegexStream(Printer, accumulatedStream, queuedCommandStream);
|
||||
accumulatedStream = processWriteRegexStream;
|
||||
|
|
|
|||
BIN
StaticData/Images/Thumbnails/11153474566755746919-256x256.png
Normal file
BIN
StaticData/Images/Thumbnails/11153474566755746919-256x256.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
Loading…
Add table
Add a link
Reference in a new issue