diff --git a/MatterControlLib/ApplicationView/SceneOperations.cs b/MatterControlLib/ApplicationView/SceneOperations.cs index b12f6552f..9b015641a 100644 --- a/MatterControlLib/ApplicationView/SceneOperations.cs +++ b/MatterControlLib/ApplicationView/SceneOperations.cs @@ -908,6 +908,14 @@ namespace MatterHackers.MatterControl { SceneOperations.ById("LinearExtrude"), SceneOperations.ById("Revolve"), SceneOperations.ById("InflatePath"), SceneOperations.ById("OutlinePath") }); + PrimaryOperations.Add(typeof(TextPathObject3D), new List + { + SceneOperations.ById("LinearExtrude"), SceneOperations.ById("Revolve"), SceneOperations.ById("InflatePath"), SceneOperations.ById("OutlinePath") + }); + PrimaryOperations.Add(typeof(BoxPathObject3D), new List + { + SceneOperations.ById("LinearExtrude"), SceneOperations.ById("Revolve"), SceneOperations.ById("InflatePath"), SceneOperations.ById("OutlinePath") + }); PrimaryOperations.Add(typeof(InflatePathObject3D), new List { SceneOperations.ById("LinearExtrude"), SceneOperations.ById("Revolve"), SceneOperations.ById("OutlinePath") diff --git a/MatterControlLib/DesignTools/Operations/Path/InflatePathObject3D.cs b/MatterControlLib/DesignTools/Operations/Path/InflatePathObject3D.cs index aed00d6ba..7f3f3a3b1 100644 --- a/MatterControlLib/DesignTools/Operations/Path/InflatePathObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/Path/InflatePathObject3D.cs @@ -58,7 +58,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations } [Description("The amount to expand the path lines.")] - public DoubleOrExpression Inflate { get; set; } + public DoubleOrExpression Inflate { get; set; } = 1; [EnumDisplay(Mode = EnumDisplayAttribute.PresentationMode.Buttons)] public ExpandStyles Style { get; set; } = ExpandStyles.Sharp; diff --git a/MatterControlLib/DesignTools/Primitives/BoxPathObject3D.cs b/MatterControlLib/DesignTools/Primitives/BoxPathObject3D.cs index 996d995f8..18ad6d1db 100644 --- a/MatterControlLib/DesignTools/Primitives/BoxPathObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/BoxPathObject3D.cs @@ -125,7 +125,7 @@ namespace MatterHackers.MatterControl.DesignTools } } - Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh)); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Path)); return Task.CompletedTask; } } diff --git a/MatterControlLib/DesignTools/Primitives/PrimitiveObject3D.cs b/MatterControlLib/DesignTools/Primitives/PrimitiveObject3D.cs index af79d8dba..704cd80f2 100644 --- a/MatterControlLib/DesignTools/Primitives/PrimitiveObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/PrimitiveObject3D.cs @@ -27,9 +27,7 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ -using System.Threading.Tasks; using MatterHackers.DataConverters3D; -using MatterHackers.Localizations; using MatterHackers.PolygonMesh; namespace MatterHackers.MatterControl.DesignTools diff --git a/MatterControlLib/DesignTools/Primitives/TextPathObject3D.cs b/MatterControlLib/DesignTools/Primitives/TextPathObject3D.cs index 42d9b9ac8..bcf9eede6 100644 --- a/MatterControlLib/DesignTools/Primitives/TextPathObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/TextPathObject3D.cs @@ -64,9 +64,9 @@ namespace MatterHackers.MatterControl.DesignTools } [DisplayName("Text")] - public string Text { get; set; } = "Text"; + public StringOrExpression Text { get; set; } = "Text"; - public double PointSize { get; set; } = 24; + public DoubleOrExpression PointSize { get; set; } = 24; [Sortable] [JsonConverter(typeof(StringEnumConverter))] @@ -120,7 +120,7 @@ namespace MatterHackers.MatterControl.DesignTools { double pointsToMm = 0.352778; - var printer = new TypeFacePrinter(Text, new StyledTypeFace(ApplicationController.GetTypeFace(Font), PointSize)) + var printer = new TypeFacePrinter(Text.Value(this), new StyledTypeFace(ApplicationController.GetTypeFace(Font), PointSize.Value(this))) { ResolutionScale = 10 }; @@ -147,7 +147,9 @@ namespace MatterHackers.MatterControl.DesignTools vertexSource = (VertexStorage)vertexSource.Union(vertexSource); this.VertexSource = vertexSource; - base.Mesh = null; + + // set the mesh to show the path + this.Mesh = this.VertexSource.Extrude(Constants.PathPolygonsHeight); } Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Path)); @@ -163,6 +165,12 @@ namespace MatterHackers.MatterControl.DesignTools using (this.RebuildLock()) { var bounds = this.VertexSource.GetBounds(); + + if (bounds.Width == 0 || bounds.Height == 0) + { + bounds = new Agg.RectangleDouble(0, 0, 60, 20); + } + var center = bounds.Center; var mesh = PlatonicSolids.CreateCube(Math.Max(8, bounds.Width), Math.Max(8, bounds.Height), 0.2); @@ -178,7 +186,7 @@ namespace MatterHackers.MatterControl.DesignTools private Mesh InitMesh() { - if (!string.IsNullOrWhiteSpace(Text)) + if (!string.IsNullOrWhiteSpace(Text.Value(this))) { } diff --git a/MatterControlLib/PartPreviewWindow/ItemColorButton.cs b/MatterControlLib/PartPreviewWindow/ItemColorButton.cs index 96a7df3ba..3730a0cb4 100644 --- a/MatterControlLib/PartPreviewWindow/ItemColorButton.cs +++ b/MatterControlLib/PartPreviewWindow/ItemColorButton.cs @@ -76,27 +76,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow HAnchor = HAnchor.Center, VAnchor = VAnchor.Center, DisabledColor = theme.MinimalShade, - Border = 1, - BorderColor = theme.BorderColor20, + BorderColor = theme.TextColor, Selectable = false }; this.DynamicPopupContent = () => { -#if true popupContent = NewColorSelector(theme, colorButton.BackgroundColor, menuTheme, (color) => colorButton.BackgroundColor = color); -#else - return new ColorSwatchSelector(menuTheme, - buttonSize: 16, - buttonSpacing: new BorderDouble(1, 1, 0, 0), - colorNotifier: (newColor) => colorButton.BackgroundColor = newColor) - { - Padding = theme.DefaultContainerPadding, - BackgroundColor = menuTheme.BackgroundColor, - HAnchor = HAnchor.Fit, - VAnchor = VAnchor.Fit - }; -#endif return popupContent; }; @@ -108,6 +94,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow this.AddChild(colorButton); } + public override void OnDraw(Graphics2D graphics2D) + { + base.OnDraw(graphics2D); + } + public static GuiWidget NewColorSelector(ThemeConfig theme, Color selectedColor, ThemeConfig menuTheme, Action update) { var content = new FlowLayoutWidget(FlowDirection.LeftToRight) @@ -167,6 +158,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { HAnchor = HAnchor.Fit }; + var htmlColor = rightContent.AddChild(rowContainer); var colorContent = rightContent.AddChild(new FlowLayoutWidget() @@ -204,6 +196,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow VAnchor = VAnchor.Absolute, ToolTipText = "Clear any assigned color. This may allow component colors to be visible.".Localize(), }); + resetButton.Click += (s, e) => { // The colorChanged action displays the given color - use .MinimalHighlight rather than no color @@ -217,6 +210,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow HAnchor = HAnchor.Fit | HAnchor.Left, VAnchor = VAnchor.Absolute }); + selectButton.Click += (s, e) => { // change to an eye dropper mode in the design view to allow for color selection @@ -226,6 +220,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow picker.SelectedColor = color; }); }; + selectButton.Visible = false; if (selectButton.Width < resetButton.Width) diff --git a/MatterControlLib/PartPreviewWindow/ItemMaterialButton.cs b/MatterControlLib/PartPreviewWindow/ItemMaterialButton.cs index 3add8be04..5b59a1bfb 100644 --- a/MatterControlLib/PartPreviewWindow/ItemMaterialButton.cs +++ b/MatterControlLib/PartPreviewWindow/ItemMaterialButton.cs @@ -50,7 +50,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { this.currentIndex = initialMaterialIndex; this.ToolTipText = "Material".Localize(); - var scaledButtonSize = 14 * GuiWidget.DeviceScale; + var scaledButtonSize = 24 * GuiWidget.DeviceScale; Width = 30 * GuiWidget.DeviceScale; Height = 30 * GuiWidget.DeviceScale; @@ -83,12 +83,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { Width = scaledButtonSize, Height = scaledButtonSize, + BackgroundRadius = scaledButtonSize / 2, + BackgroundOutlineWidth = 1, HAnchor = HAnchor.Center, VAnchor = VAnchor.Center, - DrawGrid = true, DisabledColor = theme.MinimalShade, - Border = 1, - BorderColor = theme.BorderColor20, + BorderColor = theme.TextColor, Selectable = false, }; diff --git a/MatterControlLib/PartPreviewWindow/MaterialControls.cs b/MatterControlLib/PartPreviewWindow/MaterialControls.cs index 7c2468894..4ed7d705a 100644 --- a/MatterControlLib/PartPreviewWindow/MaterialControls.cs +++ b/MatterControlLib/PartPreviewWindow/MaterialControls.cs @@ -66,13 +66,16 @@ namespace MatterHackers.MatterControl.PartPreviewWindow VAnchor = VAnchor.Fit }; - var scaledButtonSize = 16 * GuiWidget.DeviceScale; + var scaledButtonSize = 24 * GuiWidget.DeviceScale; GuiWidget colorButton; buttonView.AddChild(colorButton = new ItemColorButton(theme, MaterialRendering.Color(printer, extruderIndex, theme.BorderColor)) { Width = scaledButtonSize, Height = scaledButtonSize, + BackgroundRadius = scaledButtonSize / 2, + BackgroundOutlineWidth = 1, + BorderColor = theme.TextColor, VAnchor = VAnchor.Center, Margin = new BorderDouble(3, 0, 5, 0), }); @@ -84,7 +87,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow var radioButtonView = new RadioButtonView(buttonView) { - TextColor = theme.TextColor + TextColor = theme.TextColor, + Selectable = false }; radioButtonView.RadioCircle.Margin = radioButtonView.RadioCircle.Margin.Clone(right: 5); @@ -99,35 +103,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow materialButtons.Add(radioButton); this.AddChild(radioButton); - radioButton.MouseMove += (s, e) => - { - var screenSpace = radioButton.TransformToScreenSpace(e.Position); - var colorButtonSpace = colorButton.TransformFromScreenSpace(screenSpace); - if (colorButton.LocalBounds.Contains(colorButtonSpace)) - { - var parent = colorButton.Parent; - while (parent != radioButton) - { - parent.Selectable = true; - parent = parent.Parent; - } - } - else - { - var parent = colorButton.Parent; - while (parent != radioButton) - { - parent.Selectable = false; - parent = parent.Parent; - } - } - }; - - radioButton.MouseLeaveBounds += (s, e) => - { - - }; - int localExtruderIndex = extruderIndex; radioButton.Click += (sender, e) => { diff --git a/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs b/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs index 7d7956a1f..8c44f58b3 100644 --- a/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs +++ b/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs @@ -257,12 +257,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow colorField.Content.MouseDown += (s, e) => { - // make sure the render mode is set to shaded or outline - if (sceneContext.ViewState.RenderType != RenderOpenGl.RenderTypes.Shaded - && sceneContext.ViewState.RenderType != RenderOpenGl.RenderTypes.Outlines) + // make sure the render mode is set to shaded or outline + if (sceneContext.ViewState.RenderType != RenderOpenGl.RenderTypes.Shaded + && sceneContext.ViewState.RenderType != RenderOpenGl.RenderTypes.Outlines) { - // make sure the render mode is set to outline - sceneContext.ViewState.RenderType = RenderOpenGl.RenderTypes.Outlines; + // make sure the render mode is set to outline + sceneContext.ViewState.RenderType = RenderOpenGl.RenderTypes.Outlines; } }; @@ -289,8 +289,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { if (sceneContext.ViewState.RenderType != RenderOpenGl.RenderTypes.Materials) { - // make sure the render mode is set to material - sceneContext.ViewState.RenderType = RenderOpenGl.RenderTypes.Materials; + // make sure the render mode is set to material + sceneContext.ViewState.RenderType = RenderOpenGl.RenderTypes.Materials; } }; diff --git a/MatterControlLib/PartPreviewWindow/View3D/ColorSwatchSelector.cs b/MatterControlLib/PartPreviewWindow/View3D/ColorSwatchSelector.cs index e2e2194b3..e304335f1 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/ColorSwatchSelector.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/ColorSwatchSelector.cs @@ -126,8 +126,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow this.DisabledColor = color.ToGrayscale(); } - public bool DrawGrid { get; set; } - public override Color BackgroundColor { get => this.Enabled ? base.BackgroundColor : this.DisabledColor; @@ -139,31 +137,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public Color DisabledColor { get; set; } - public override void OnDraw(Graphics2D graphics2D) - { - if (this.DrawGrid) - { - var numberOfStripes = 3; - - int ix = 20; - - for (var i = 0; i < numberOfStripes * 2; i++) - { - var thickness = ix / numberOfStripes; - - graphics2D.Line( - i * thickness + thickness / 2 - ix, - 0, - i * thickness + thickness / 2, - ix, - Color.Gray, - 0.05); - } - } - - base.OnDraw(graphics2D); - } - public Color SourceColor { get; set; } } diff --git a/MatterControlLib/SlicerConfiguration/UIFields/ExpressionField.cs b/MatterControlLib/SlicerConfiguration/UIFields/ExpressionField.cs index b65b78341..a7bc3deb7 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/ExpressionField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/ExpressionField.cs @@ -99,7 +99,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration else { textEditWidget.MaximumSize = new VectorMath.Vector2(startingTextEditWidth, textEditWidget.MaximumSize.Y); - textEditWidget.HAnchor = HAnchor.Right; + textEditWidget.HAnchor = HAnchor.Right | HAnchor.Fit; } }