writing tests for sheets

This commit is contained in:
Lars Brubaker 2021-06-02 14:30:29 -07:00
parent 3d068ef868
commit 0dcb08e1cc
6 changed files with 74 additions and 19 deletions

View file

@ -147,7 +147,6 @@ namespace MatterHackers.Plugins.EditorTools
public void ScaleDepth(double newDepth)
{
FinalState = new ScaleStates(InitialState);
FinalState.Depth = newDepth;
if (context.GuiSurface.ModifierKeys == Keys.Shift || selectedItem is IScaleLocker)
{
@ -159,7 +158,6 @@ namespace MatterHackers.Plugins.EditorTools
public void ScaleDiameter(double newSize, int index)
{
FinalState = new ScaleStates(InitialState);
FinalState.Diameters[index] = newSize;
if (context.GuiSurface.ModifierKeys == Keys.Shift)
{
@ -171,7 +169,6 @@ namespace MatterHackers.Plugins.EditorTools
public void ScaleHeight(double newHeight)
{
FinalState = new ScaleStates(InitialState);
FinalState.Height = newHeight;
if (context.GuiSurface.ModifierKeys == Keys.Shift || selectedItem is IScaleLocker)
{
@ -183,7 +180,6 @@ namespace MatterHackers.Plugins.EditorTools
public void ScaleWidth(double newWidth)
{
FinalState = new ScaleStates(InitialState);
FinalState.Width = newWidth;
if (context.GuiSurface.ModifierKeys == Keys.Shift || selectedItem is IScaleLocker)
{
@ -221,11 +217,12 @@ namespace MatterHackers.Plugins.EditorTools
}
InitialState.Matrix = selectedItem.Matrix;
FinalState = new ScaleStates(InitialState);
}
internal void ScaleWidthDepth(double newWidth, double newDepth)
{
FinalState = new ScaleStates(InitialState);
FinalState.Width = newWidth;
FinalState.Depth = newDepth;
if (context.GuiSurface.ModifierKeys == Keys.Shift || selectedItem is IScaleLocker)

View file

@ -84,6 +84,8 @@ namespace MatterHackers.MatterControl.DesignTools
{
using (RebuildLock())
{
// update the table info
SheetData.Recalculate();
// send a message to all our siblings and their children
SendInvalidateToAll();
}
@ -143,6 +145,11 @@ namespace MatterHackers.MatterControl.DesignTools
}
}
}
if (inputExpression.Length > 0 && inputExpression[0] == '=')
{
inputExpression = inputExpression.Substring(1);
}
// look through all the parents
foreach (var parent in owner.Parents())

View file

@ -183,7 +183,6 @@ namespace MatterHackers.MatterControl.DesignTools
private void Recalculate()
{
sheetData.Recalculate();
sheetObject.Invalidate(InvalidateType.SheetUpdated);
}
}

View file

@ -213,8 +213,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
Action<double> setWidth = (newWidth) => width.Expression = newWidth.ToString();
Func<double> getDepth = () => depth.Value(item);
Action<double> setDepth = (newDepth) => depth.Expression = newDepth.ToString();
Func<double> getHeight = () => height.Value(item);
Action<double> setHeight = (newHeight) => height.Expression = newHeight.ToString();
Func<double> getHeight = null;
Action<double> setHeight = null;
if (height != null)
{
getHeight = () => height.Value(item);
setHeight = (newHeight) => height.Expression = newHeight.ToString();
}
if (width != null
&& !width.IsEquation

View file

@ -424,9 +424,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
renderRoundedGroup(.3, .25);
renderRoundedGroup(.1, .5 + .1);
// render the perspective and turntable group background
// renderRoundedGroup(.1, 1 - .1); // when we have both ortho and turntable
renderRoundedGroup(.001, 1 - .127); // when we only have turntable
void renderRoundedLine(double lineWidth, double heightBelowCenter)
{
@ -480,12 +480,15 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{
ToolTipText = "Turntable Mode".Localize(),
Margin = theme.ButtonSpacing,
Padding = 2,
ToggleButton = true,
SiblingRadioButtonList = new List<GuiWidget>(),
Checked = turntableEnabled,
BorderColor = hudStrokeColor,
};
// AddRoundButton(turnTableButton, RotatedMargin(turnTableButton, -MathHelper.Tau * .4)); // 2 button position
AddRoundButton(turnTableButton, RotatedMargin(turnTableButton, -MathHelper.Tau * .375));
AddRoundButton(turnTableButton, RotatedMargin(turnTableButton, -MathHelper.Tau * .30));
turnTableButton.CheckedStateChanged += (s, e) =>
{
UserSettings.Instance.set(UserSettingsKey.TurntableMode, turnTableButton.Checked.ToString());