diff --git a/MatterControlLib/ApplicationView/SceneOperations.cs b/MatterControlLib/ApplicationView/SceneOperations.cs index 480700aed..b12f6552f 100644 --- a/MatterControlLib/ApplicationView/SceneOperations.cs +++ b/MatterControlLib/ApplicationView/SceneOperations.cs @@ -322,6 +322,7 @@ namespace MatterHackers.MatterControl "$.Children.Children.Children.Children.AnalysisType", "$.Children.Children.Children.Children.TransparencyMessage", "$.Children.Children.Children.Children.Histogram", + "$.Children.Children.Children.Children.MinSurfaceArea", "$.Children", } }; diff --git a/MatterControlLib/DesignTools/Attributes/SliderAttribute.cs b/MatterControlLib/DesignTools/Attributes/SliderAttribute.cs index f82742540..4e8360b11 100644 --- a/MatterControlLib/DesignTools/Attributes/SliderAttribute.cs +++ b/MatterControlLib/DesignTools/Attributes/SliderAttribute.cs @@ -27,6 +27,7 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ +using MatterHackers.VectorMath; using System; namespace MatterHackers.MatterControl.DesignTools @@ -34,15 +35,17 @@ namespace MatterHackers.MatterControl.DesignTools [AttributeUsage(AttributeTargets.Property)] public class SliderAttribute : Attribute { - public SliderAttribute(double min, double max, double increment) + public SliderAttribute(double min, double max, Easing.EaseType easingType = Easing.EaseType.Linear, Easing.EaseOption easeOption = Easing.EaseOption.Out) { this.Min = min; this.Max = max; - this.Incement = increment; + this.EasingType = easingType; + this.EaseOption = easeOption; } public double Min { get; set; } public double Max { get; set; } - public double Incement { get; set; } + public Easing.EaseType EasingType { get; set; } + public Easing.EaseOption EaseOption { get; } } } \ No newline at end of file diff --git a/MatterControlLib/DesignTools/LithophaneObject3D.cs b/MatterControlLib/DesignTools/LithophaneObject3D.cs index 2d4c54479..164c4a62f 100644 --- a/MatterControlLib/DesignTools/LithophaneObject3D.cs +++ b/MatterControlLib/DesignTools/LithophaneObject3D.cs @@ -57,7 +57,7 @@ namespace MatterHackers.MatterControl.Plugins.Lithophane [DisplayName("Pixels Per mm"), Range(0.5, 3, ErrorMessage = "Value for {0} must be between {1} and {2}.")] public double PixelsPerMM { get; set; } = 1.5; - [Slider(0.5, 3, .2)] + [Slider(0.5, 3)] public double Height { get; set; } = 2.5; public int Width { get; set; } = 150; diff --git a/MatterControlLib/DesignTools/Obsolete/CurveObject3D.cs b/MatterControlLib/DesignTools/Obsolete/CurveObject3D.cs index e6eb9373d..029c695dd 100644 --- a/MatterControlLib/DesignTools/Obsolete/CurveObject3D.cs +++ b/MatterControlLib/DesignTools/Obsolete/CurveObject3D.cs @@ -66,13 +66,14 @@ namespace MatterHackers.MatterControl.DesignTools [DisplayName("Bend Up")] public bool BendCcw { get; set; } = true; + [Slider(1, 400, Easing.EaseType.Quadratic)] public double Diameter { get; set; } = double.MinValue; - [Slider(3, 360, 1)] + [Slider(3, 360)] [Description("Ensures the rotated part has a minimum number of sides per complete rotation")] public double MinSidesPerRotation { get; set; } = 3; - [Slider(0, 100, 1)] + [Slider(0, 100)] [Description("Where to start the bend as a percent of the width of the part")] public double StartPercent { get; set; } = 50; diff --git a/MatterControlLib/DesignTools/Operations/ArrayLinearObject3D.cs b/MatterControlLib/DesignTools/Operations/ArrayLinearObject3D.cs index 606ee0c0f..518d4310a 100644 --- a/MatterControlLib/DesignTools/Operations/ArrayLinearObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/ArrayLinearObject3D.cs @@ -96,7 +96,9 @@ namespace MatterHackers.MatterControl.DesignTools.Operations { if(SheetObject3D.HasParametersWithActiveFunctions(child)) { - child.Invalidate(new InvalidateArgs(child, InvalidateType.Properties)); + // This really needs to be 'Has Perameters With index at this level' + // And is not the source object (only the copies should try to re-build (that might fix the recursion bug without the extra filtering) + //child.Invalidate(new InvalidateArgs(child, InvalidateType.Properties)); } } diff --git a/MatterControlLib/DesignTools/Operations/CurveObject3D_2.cs b/MatterControlLib/DesignTools/Operations/CurveObject3D_2.cs index 908622cc3..cfe504612 100644 --- a/MatterControlLib/DesignTools/Operations/CurveObject3D_2.cs +++ b/MatterControlLib/DesignTools/Operations/CurveObject3D_2.cs @@ -64,11 +64,11 @@ namespace MatterHackers.MatterControl.DesignTools public double Diameter { get; set; } = double.MaxValue; - [Slider(3, 360, 1)] + [Slider(3, 360)] [Description("Ensures the rotated part has a minimum number of sides per complete rotation")] public double MinSidesPerRotation { get; set; } = 30; - [Slider(0, 100, 1)] + [Slider(0, 100)] [Description("Where to start the bend as a percent of the width of the part")] public double StartPercent { get; set; } = 50; diff --git a/MatterControlLib/DesignTools/Operations/CurveObject3D_3.cs b/MatterControlLib/DesignTools/Operations/CurveObject3D_3.cs index 7fe5853db..4d809c497 100644 --- a/MatterControlLib/DesignTools/Operations/CurveObject3D_3.cs +++ b/MatterControlLib/DesignTools/Operations/CurveObject3D_3.cs @@ -86,7 +86,7 @@ namespace MatterHackers.MatterControl.DesignTools [DescriptionImage("https://lh3.googleusercontent.com/h-s2FyBKO5etYDr_9YSLtGmGmQTcmSGMu4p0mRqX4_7Z62Ndn2QRLoFICC6X9scbhr1EP29RiYRj4EmhLMUwiNTAG-PIiFbzI_jAses")] public BendDirections BendDirection { get; set; } = BendDirections.Bend_Up; - [Slider(0, 100, 1)] + [Slider(0, 100)] [Description("Where to start the bend as a percent from the left side")] [DescriptionImage("https://lh3.googleusercontent.com/eOeWjr98uz_E924PnNaXrasepv15nWEuvhqH-jbaQyvrOVdX5MHXF00HdZQGC8NLpJc9ok1sToMtyPx1wnnDgFwTTGA5MjoMFu612AY1")] public double StartPercent { get; set; } = 50; @@ -95,7 +95,7 @@ namespace MatterHackers.MatterControl.DesignTools [Description("Split the mesh so it has enough geometry to create a smooth curve")] public bool SplitMesh { get; set; } = true; - [Slider(3, 360, 1)] + [Slider(3, 360)] [Description("Ensures the rotated part has a minimum number of sides per complete rotation")] [DescriptionImage("https://lh3.googleusercontent.com/p9MyKu3AFP55PnobUKZQPqf6iAx11GzXyX-25f1ddrUnfCt8KFGd1YtHOR5HqfO0mhlX2ZVciZV4Yn0Kzfm43SErOS_xzgsESTu9scux")] public double MinSidesPerRotation { get; set; } = 30; diff --git a/MatterControlLib/DesignTools/Operations/Image/Histogram.cs b/MatterControlLib/DesignTools/Operations/Image/Histogram.cs index 755541152..a51e97c10 100644 --- a/MatterControlLib/DesignTools/Operations/Image/Histogram.cs +++ b/MatterControlLib/DesignTools/Operations/Image/Histogram.cs @@ -335,7 +335,10 @@ namespace MatterHackers.MatterControl.DesignTools graphShape.MoveTo(0, bottom); for (int i = 0; i < 256; i++) { - graphShape.LineTo(i, bottom + counts[i] * graphHeight / max ); + graphShape.LineTo(i, bottom + Easing.Exponential.Out(counts[i] / max) * graphHeight); + // graphShape.LineTo(i, bottom + Easing.Cubic.Out(counts[i] / max) * graphHeight); + // graphShape.LineTo(i, bottom + Easing.Exponential.Out(counts[i] / max) * graphHeight); + // graphShape.LineTo(i, bottom + counts[i] / max * graphHeight); } graphShape.LineTo(256, bottom); graphShape.LineTo(0, bottom); diff --git a/MatterControlLib/DesignTools/Operations/Image/ImageToPathObject3D.cs b/MatterControlLib/DesignTools/Operations/Image/ImageToPathObject3D.cs index 957524931..70a86097c 100644 --- a/MatterControlLib/DesignTools/Operations/Image/ImageToPathObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/Image/ImageToPathObject3D.cs @@ -173,10 +173,10 @@ namespace MatterHackers.MatterControl.DesignTools [JsonIgnore] private ImageBuffer Image => this.Descendants().FirstOrDefault()?.Image; - [Slider(0, 1, .05)] + [Slider(0, 1)] public DoubleOrExpression RangeStart { get; set; } = .1; - [Slider(0, 1, .05)] + [Slider(0, 1)] public DoubleOrExpression RangeEnd { get; set; } = 1; public IVertexSource VertexSource { get; set; } = new VertexStorage(); diff --git a/MatterControlLib/DesignTools/Operations/Image/ImageToPathObject3D_2.cs b/MatterControlLib/DesignTools/Operations/Image/ImageToPathObject3D_2.cs index c85f2bfa2..18a3f006e 100644 --- a/MatterControlLib/DesignTools/Operations/Image/ImageToPathObject3D_2.cs +++ b/MatterControlLib/DesignTools/Operations/Image/ImageToPathObject3D_2.cs @@ -168,7 +168,7 @@ namespace MatterHackers.MatterControl.DesignTools [DisplayName("Select Range")] public Histogram Histogram { get; set; } = new Histogram(); - [Slider(0, 10, 1)] + [Slider(0, 150, Easing.EaseType.Quadratic)] [Description("The minimum area each loop needs to be for inclusion")] public double MinSurfaceArea {get; set; } = 1; @@ -186,6 +186,9 @@ namespace MatterHackers.MatterControl.DesignTools public override bool CanFlatten => true; + [HideFromEditor] + public int NumLineLoops { get; set; } + public override void Flatten(UndoBuffer undoBuffer) { this.FlattenToPathObject(undoBuffer); @@ -210,7 +213,9 @@ namespace MatterHackers.MatterControl.DesignTools int pixelsToIntPointsScale = 1000; var lineLoops = marchingSquaresData.CreateLineLoops(pixelsToIntPointsScale); - if (MinSurfaceArea > 0) + NumLineLoops = lineLoops.Count; + + if (NumLineLoops > 1 && MinSurfaceArea > 0) { var minimumSurfaceArea = Math.Pow(MinSurfaceArea * 1000, 2); @@ -429,6 +434,7 @@ namespace MatterHackers.MatterControl.DesignTools change.SetRowVisible(nameof(Histogram), () => AnalysisType != AnalysisTypes.Transparency); change.SetRowVisible(nameof(MinSurfaceArea), () => AnalysisType != AnalysisTypes.Transparency); change.SetRowVisible(nameof(TransparencyMessage), () => AnalysisType == AnalysisTypes.Transparency); + change.SetRowVisible(nameof(MinSurfaceArea), () => NumLineLoops > 1); } } } \ No newline at end of file diff --git a/MatterControlLib/DesignTools/Operations/TwistObject3D.cs b/MatterControlLib/DesignTools/Operations/TwistObject3D.cs index 2393371a1..822217cc7 100644 --- a/MatterControlLib/DesignTools/Operations/TwistObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/TwistObject3D.cs @@ -212,7 +212,7 @@ namespace MatterHackers.MatterControl.DesignTools // look for an x value that equals the goal for (int j = 0; j < 64; j++) { - var xAtY = Easing.Specify(EasingType, EasingOption, current); + var xAtY = Easing.Calculate(EasingType, EasingOption, current); if (xAtY < goal) { current += next; @@ -275,7 +275,7 @@ namespace MatterHackers.MatterControl.DesignTools else { ratio = (position.Z - bottom) / size; - ratio = Easing.Specify(EasingType, EasingOption, ratio); + ratio = Easing.Calculate(EasingType, EasingOption, ratio); } } diff --git a/MatterControlLib/DesignTools/Primitives/CubeObject3D.cs b/MatterControlLib/DesignTools/Primitives/CubeObject3D.cs index a2f1a6c91..b34b2fa66 100644 --- a/MatterControlLib/DesignTools/Primitives/CubeObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/CubeObject3D.cs @@ -49,7 +49,7 @@ namespace MatterHackers.MatterControl.DesignTools /// This is the actual serialized with that can use expressions /// [MaxDecimalPlaces(2)] - [Slider(1, 100, 1)] + [Slider(1, 100)] public DoubleOrExpression Width { get; set; } = 20; [MaxDecimalPlaces(2)] diff --git a/MatterControlLib/DesignTools/PublicPropertyEditor.cs b/MatterControlLib/DesignTools/PublicPropertyEditor.cs index fc639c822..14b3097ca 100644 --- a/MatterControlLib/DesignTools/PublicPropertyEditor.cs +++ b/MatterControlLib/DesignTools/PublicPropertyEditor.cs @@ -76,7 +76,7 @@ namespace MatterHackers.MatterControl.DesignTools }; public const BindingFlags OwnedPropertiesOnly = BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly; - private List rows = new List(); + private SafeList rows = new SafeList(); public GuiWidget Create(IObject3D item, UndoBuffer undoBuffer, ThemeConfig theme) { @@ -211,7 +211,7 @@ namespace MatterHackers.MatterControl.DesignTools } } - private static SettingsRow CreateSettingsRow(EditableProperty property, GuiWidget content, ThemeConfig theme, List rows = null) + private static SettingsRow CreateSettingsRow(EditableProperty property, GuiWidget content, ThemeConfig theme, SafeList rows = null) { var row = new SettingsRow(property.DisplayName.Localize(), property.Description, content, theme); if (rows != null) @@ -307,20 +307,26 @@ namespace MatterHackers.MatterControl.DesignTools if (field is DoubleField doubleField) { - slider.Value = doubleField.DoubleValue; + slider.Value = Easing.CalculateInverse(sliderAttribute.EasingType, + sliderAttribute.EaseOption, + doubleField.DoubleValue); var changeDueToSlider = false; doubleField.ValueChanged += (s, e) => { if (!changeDueToSlider) { - slider.Value = doubleField.DoubleValue; + slider.Value = Easing.CalculateInverse(sliderAttribute.EasingType, + sliderAttribute.EaseOption, + doubleField.DoubleValue); ; } }; slider.ValueChanged += (s, e) => { changeDueToSlider = true; - doubleField.SetValue(slider.Value.ToString(), true); + doubleField.SetValue(Easing.Calculate(sliderAttribute.EasingType, + sliderAttribute.EaseOption, + slider.Value).ToString(), true); changeDueToSlider = false; }; @@ -344,7 +350,7 @@ namespace MatterHackers.MatterControl.DesignTools return field.Content; } - public static GuiWidget CreatePropertyEditor(List rows, EditableProperty property, UndoBuffer undoBuffer, PPEContext context, ThemeConfig theme) + public static GuiWidget CreatePropertyEditor(SafeList rows, EditableProperty property, UndoBuffer undoBuffer, PPEContext context, ThemeConfig theme) { var localItem = context.item; var object3D = property.Item; diff --git a/MatterControlLib/PartPreviewWindow/GenerateSupportPanel.cs b/MatterControlLib/PartPreviewWindow/GenerateSupportPanel.cs index c3bbd490b..1b32b0b01 100644 --- a/MatterControlLib/PartPreviewWindow/GenerateSupportPanel.cs +++ b/MatterControlLib/PartPreviewWindow/GenerateSupportPanel.cs @@ -58,7 +58,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow // Add an editor field for the SupportGenerator.SupportType PropertyInfo propertyInfo = typeof(SupportGenerator).GetProperty(nameof(SupportGenerator.SupportType)); - var rows = new List(); + var rows = new SafeList(); var editor = PublicPropertyEditor.CreatePropertyEditor( rows, diff --git a/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs b/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs index 046c2ccb6..7d7956a1f 100644 --- a/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs +++ b/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs @@ -299,7 +299,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow new SettingsRow("Material".Localize(), null, materialField.Content, theme)); } - var rows = new List(); + var rows = new SafeList(); // put in the normal editor if (selectedItem is ComponentObject3D componentObject diff --git a/MatterControlLib/SlicerConfiguration/SettingsRow.cs b/MatterControlLib/SlicerConfiguration/SettingsRow.cs index 4afaaad97..49c992066 100644 --- a/MatterControlLib/SlicerConfiguration/SettingsRow.cs +++ b/MatterControlLib/SlicerConfiguration/SettingsRow.cs @@ -117,7 +117,7 @@ namespace MatterHackers.MatterControl.CustomWidgets this.PerformLayout(); } - public SettingsRow SetTextRightMargin(List rows) + public SettingsRow SetTextRightMargin(SafeList rows) { var spacing = 11 * GuiWidget.DeviceScale; var maxTextWidth = 0.0; diff --git a/Submodules/MatterSlice b/Submodules/MatterSlice index 9352d2118..75f6c6920 160000 --- a/Submodules/MatterSlice +++ b/Submodules/MatterSlice @@ -1 +1 @@ -Subproject commit 9352d21185adb4d111970d985c48d1c93f716d82 +Subproject commit 75f6c6920ada5316768e890fc221f141393fd9cd diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 0cc956c6c..c4d395b08 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 0cc956c6ccb27e52962662c73f27d82a16e00cbd +Subproject commit c4d395b08e2185e20f72990354aa133fc73eacdf