Creating new ui

This commit is contained in:
LarsBrubaker 2021-05-15 22:33:27 -07:00
parent 77abea4335
commit 1fdba214b5
15 changed files with 388 additions and 256 deletions

View file

@ -2199,91 +2199,6 @@ namespace MatterHackers.MatterControl
return (slicingSucceeded, gcodeFilePath);
}
internal void GetViewOptionButtons(GuiWidget parent, ISceneContext sceneContext, PrinterConfig printer, ThemeConfig theme)
{
var bedButton = new RadioIconButton(StaticData.Instance.LoadIcon("bed.png", 16, 16, theme.InvertIcons), theme)
{
Name = "Bed Button",
ToolTipText = "Show Print Bed".Localize(),
Checked = sceneContext.RendererOptions.RenderBed,
Margin = theme.ButtonSpacing,
VAnchor = VAnchor.Absolute,
ToggleButton = true,
Height = theme.ButtonHeight,
Width = theme.ButtonHeight,
SiblingRadioButtonList = new List<GuiWidget>()
};
bedButton.CheckedStateChanged += (s, e) =>
{
sceneContext.RendererOptions.RenderBed = bedButton.Checked;
};
parent.AddChild(bedButton);
bool BuildHeightValid() => sceneContext.BuildHeight > 0;
var printAreaButton = new RadioIconButton(StaticData.Instance.LoadIcon("print_area.png", 16, 16, theme.InvertIcons), theme)
{
Name = "Bed Button",
ToolTipText = BuildHeightValid() ? "Show Print Area".Localize() : "Define printer build height to enable",
Checked = sceneContext.RendererOptions.RenderBuildVolume,
Margin = theme.ButtonSpacing,
VAnchor = VAnchor.Absolute,
ToggleButton = true,
Enabled = BuildHeightValid() && printer?.ViewState.ViewMode != PartViewMode.Layers2D,
Height = theme.ButtonHeight,
Width = theme.ButtonHeight,
SiblingRadioButtonList = new List<GuiWidget>()
};
printAreaButton.CheckedStateChanged += (s, e) =>
{
sceneContext.RendererOptions.RenderBuildVolume = printAreaButton.Checked;
};
parent.AddChild(printAreaButton);
this.BindBedOptions(parent, bedButton, printAreaButton, sceneContext.RendererOptions);
if (printer != null)
{
// Disable print area button in GCode2D view
void ViewModeChanged(object s, ViewModeChangedEventArgs e)
{
// Button is conditionally created based on BuildHeight, only set enabled if created
printAreaButton.Enabled = BuildHeightValid() && printer.ViewState.ViewMode != PartViewMode.Layers2D;
}
printer.ViewState.ViewModeChanged += ViewModeChanged;
parent.Closed += (s, e) =>
{
printer.ViewState.ViewModeChanged -= ViewModeChanged;
};
}
}
public void BindBedOptions(GuiWidget container, ICheckbox bedButton, ICheckbox printAreaButton, View3DConfig renderOptions)
{
void SyncProperties(object s, PropertyChangedEventArgs e)
{
switch (e.PropertyName)
{
case nameof(renderOptions.RenderBed):
bedButton.Checked = renderOptions.RenderBed;
break;
case nameof(renderOptions.RenderBuildVolume) when printAreaButton != null:
printAreaButton.Checked = renderOptions.RenderBuildVolume;
break;
}
}
renderOptions.PropertyChanged += SyncProperties;
container.Closed += (s, e) =>
{
renderOptions.PropertyChanged -= SyncProperties;
};
}
public void ShellOpenFile(string file)
{
UiThread.RunOnIdle(() => this.ShellFileOpened?.Invoke(this, file));

View file

@ -241,7 +241,8 @@ namespace MatterHackers.Plugins.EditorTools
private void ScaleProportional(double scale)
{
if (selectedItem is IScaleLocker scaleLocker)
if (context.GuiSurface.ModifierKeys != Keys.Shift
&& selectedItem is IScaleLocker scaleLocker)
{
switch (scaleLocker.LockProportion)
{
@ -263,6 +264,8 @@ namespace MatterHackers.Plugins.EditorTools
FinalState.Height = InitialState.Height * scale;
break;
}
scaleLocker.ScaledProportionally();
}
else
{

View file

@ -59,6 +59,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
[Description("Ensure that the part maintains its proportions.")]
public LockProportions LockProportion { get; set; } = LockProportions.X_Y_Z;
[MaxDecimalPlaces(3)]
public double Width
{
get => boundsSize.X;
@ -72,6 +73,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
}
}
[MaxDecimalPlaces(3)]
public double Depth
{
get => boundsSize.Y;
@ -85,6 +87,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
}
}
[MaxDecimalPlaces(3)]
public double Height
{
get => boundsSize.Z;

View file

@ -352,5 +352,9 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
}
}
}
public void ScaledProportionally()
{
}
}
}

View file

@ -52,6 +52,8 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
public interface IScaleLocker
{
LockProportions LockProportion { get; }
void ScaledProportionally();
}
public class ScaleObject3D_3 : TransformWrapperObject3D, IObjectWithHeight, IObjectWithWidthAndDepth, IPropertyGridModifier, IScaleLocker
@ -247,6 +249,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
[ReadOnly(true)]
[MaxDecimalPlaces(2)]
[JsonIgnore]
[DisplayName("Width Percent")]
public double WidthPercentDisplay
{
get
@ -263,6 +266,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
[ReadOnly(true)]
[MaxDecimalPlaces(2)]
[JsonIgnore]
[DisplayName("Depth Percent")]
public double DepthPercentDisplay
{
get
@ -279,6 +283,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
[ReadOnly(true)]
[MaxDecimalPlaces(2)]
[JsonIgnore]
[DisplayName("Height Percent")]
public double HeightPercentDisplay
{
get
@ -370,8 +375,11 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
return Task.CompletedTask;
}
PublicPropertyChange change;
public void UpdateControls(PublicPropertyChange change)
{
this.change = change;
change.SetRowVisible(nameof(Width), () => ScaleType == ScaleTypes.Custom && ScaleMethod == ScaleMethods.Direct);
change.SetRowVisible(nameof(Depth), () => ScaleType == ScaleTypes.Custom && ScaleMethod == ScaleMethods.Direct);
change.SetRowVisible(nameof(Height), () => ScaleType == ScaleTypes.Custom && ScaleMethod == ScaleMethods.Direct);
@ -434,5 +442,19 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
}
}
}
public void ScaledProportionally()
{
// this does not work yet
// it needs to have an undo for the change to custom
// it needs to not cause extra undos to exist
return;
if (ScaleType != ScaleTypes.Custom)
{
ScaleType = ScaleTypes.Custom;
this.UpdateControls(new PublicPropertyChange(change.Context, "Rebuild_On_Scale"));
}
}
}
}

View file

@ -831,6 +831,26 @@ namespace MatterHackers.MatterControl.DesignTools
field.Content.HAnchor = HAnchor.Stretch;
rowContainer = field.Content;
}
void RefreshField(object s, InvalidateArgs e)
{
if (e.InvalidateType.HasFlag(InvalidateType.DisplayValues))
{
var newValue = property.Value.ToString();
if (field.Content is MHDropDownList dropDown)
{
if (field.Value != newValue)
{
field.SetValue(newValue, false);
dropDown.SelectedValue = newValue;
}
}
}
}
object3D.Invalidated += RefreshField;
field.Content.Closed += (s, e) => object3D.Invalidated -= RefreshField;
}
else if (propertyValue is IObject3D item
&& ApplicationController.Instance.Extensions.GetEditorsForType(property.PropertyType)?.FirstOrDefault() is IObject3DEditor iObject3DEditor)

View file

@ -322,7 +322,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
ShowObjectEditor((editor, object3D, object3D.Name), selectedItem);
}
}
else if (JsonPath.JsonPathContext.ReflectionValueSystem.LastMemberValue is ReflectionTarget reflectionTarget)
else if (JsonPathContext.ReflectionValueSystem.LastMemberValue is ReflectionTarget reflectionTarget)
{
var context = new PPEContext();

View file

@ -638,6 +638,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
var rect = LocalBounds;
var centerY = rect.YCenter;
if (this.Parent == null)
{
return;
}
var siblings = this.Parent.Children.OfType<ChromeTab>().ToList();
int position = siblings.IndexOf(this);

View file

@ -346,12 +346,24 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
}
}
private bool CanSelectObject()
{
var view3D = this.Parents<View3DWidget>().First();
if (view3D != null)
{
return view3D.TrackballTumbleWidget.TransformState == VectorMath.TrackBall.TrackBallTransformType.None;
}
return true;
}
public override void OnMouseDown(MouseEventArgs mouseEvent)
{
base.OnMouseDown(mouseEvent);
var ray = this.World.GetRayForLocalBounds(mouseEvent.Position);
if (this.Scene.SelectedItem != null
&& CanSelectObject()
&& !SuppressObject3DControls
&& FindHitObject3DControl(ray, out mouseDownObject3DControl, out IntersectInfo info))
{
@ -369,7 +381,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
base.OnMouseMove(mouseEvent);
if (SuppressObject3DControls
|| !this.PositionWithinLocalBounds(mouseEvent.X, mouseEvent.Y))
|| !this.PositionWithinLocalBounds(mouseEvent.X, mouseEvent.Y)
|| !CanSelectObject())
{
return;
}
@ -407,32 +420,31 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{
Invalidate();
if (SuppressObject3DControls)
if (!SuppressObject3DControls
&& CanSelectObject())
{
return;
}
Ray ray = this.World.GetRayForLocalBounds(mouseEvent.Position);
bool anyObject3DControlVolumeHit = FindHitObject3DControl(ray, out IObject3DControl object3DControl, out IntersectInfo info);
var mouseEvent3D = new Mouse3DEventArgs(mouseEvent, ray, info);
Ray ray = this.World.GetRayForLocalBounds(mouseEvent.Position);
bool anyObject3DControlVolumeHit = FindHitObject3DControl(ray, out IObject3DControl object3DControl, out IntersectInfo info);
var mouseEvent3D = new Mouse3DEventArgs(mouseEvent, ray, info);
if (MouseDownOnObject3DControlVolume && mouseDownObject3DControl != null)
{
mouseDownObject3DControl.OnMouseUp(mouseEvent3D);
SelectedObject3DControl = null;
mouseDownObject3DControl = null;
}
else
{
mouseDownObject3DControl = null;
if (anyObject3DControlVolumeHit)
if (MouseDownOnObject3DControlVolume && mouseDownObject3DControl != null)
{
object3DControl.OnMouseUp(mouseEvent3D);
}
mouseDownObject3DControl.OnMouseUp(mouseEvent3D);
SelectedObject3DControl = null;
SelectedObject3DControl = null;
mouseDownObject3DControl = null;
}
else
{
mouseDownObject3DControl = null;
if (anyObject3DControlVolumeHit)
{
object3DControl.OnMouseUp(mouseEvent3D);
}
SelectedObject3DControl = null;
}
}
base.OnMouseUp(mouseEvent);

View file

@ -41,7 +41,6 @@ using MatterHackers.PolygonMesh;
using MatterHackers.RayTracer;
using MatterHackers.RenderOpenGl;
using MatterHackers.VectorMath;
using MatterHackers.VectorMath.TrackBall;
namespace MatterHackers.MatterControl.PartPreviewWindow
{

View file

@ -28,7 +28,10 @@ either expressed or implied, of the FreeBSD Project.
*/
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
@ -38,6 +41,7 @@ using AngleSharp.Html.Parser;
using MatterHackers.Agg;
using MatterHackers.Agg.Platform;
using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters3D;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.CustomWidgets;
@ -63,7 +67,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
private readonly TreeView treeView;
private readonly ViewStyleButton modelViewStyleButton;
private ViewStyleButton modelViewStyleButton;
private readonly PrinterConfig printer;
@ -262,84 +266,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
historyAndProperties.Panel2.AddChild(selectedObjectPanel);
splitContainer.AddChild(modelViewSidePanel);
var tumbleCubeControl = new TumbleCubeControl(this.Object3DControlLayer, theme, TrackballTumbleWidget)
{
Margin = new BorderDouble(0, 0, 10, 35),
VAnchor = VAnchor.Top,
HAnchor = HAnchor.Right,
Name = "Tumble Cube Control"
};
this.Object3DControlLayer.AddChild(tumbleCubeControl);
var viewOptionsBar = new FlowLayoutWidget()
{
HAnchor = HAnchor.Right | HAnchor.Fit,
VAnchor = VAnchor.Top | VAnchor.Fit,
// Margin = new BorderDouble(top: tumbleCubeControl.Height + tumbleCubeControl.Margin.Height + 2),
BackgroundColor = theme.MinimalShade,
Name = "View Options Bar"
};
this.Object3DControlLayer.AddChild(viewOptionsBar);
var homeButton = new IconButton(StaticData.Instance.LoadIcon("fa-home_16.png", 16, 16, theme.InvertIcons), theme)
{
VAnchor = VAnchor.Absolute,
ToolTipText = "Reset View".Localize(),
Margin = theme.ButtonSpacing
};
homeButton.Click += (s, e) => viewControls3D.NotifyResetView();
viewOptionsBar.AddChild(homeButton);
#if DEBUG
var renderOptionsButton = new RenderOptionsButton(theme, this.Object3DControlLayer)
{
ToolTipText = "Model View Style".Localize(),
PopupMate = new MatePoint()
{
Mate = new MateOptions(MateEdge.Left, MateEdge.Top)
},
AnchorMate = new MatePoint()
{
Mate = new MateOptions(MateEdge.Left, MateEdge.Bottom)
}
};
viewOptionsBar.AddChild(renderOptionsButton);
#endif
modelViewStyleButton = new ViewStyleButton(sceneContext, theme)
{
ToolTipText = "Model View Style".Localize(),
PopupMate = new MatePoint()
{
Mate = new MateOptions(MateEdge.Left, MateEdge.Top)
}
};
modelViewStyleButton.AnchorMate.Mate.VerticalEdge = MateEdge.Bottom;
modelViewStyleButton.AnchorMate.Mate.HorizontalEdge = MateEdge.Left;
viewOptionsBar.AddChild(modelViewStyleButton);
if (printer?.ViewState != null)
{
printer.ViewState.ViewModeChanged += this.ViewState_ViewModeChanged;
}
ApplicationController.Instance.GetViewOptionButtons(viewOptionsBar, sceneContext, printer, theme);
// now add the grid snap button
var gridSnapButton = new GridOptionsPanel(Object3DControlLayer, theme)
{
ToolTipText = "Snap Grid".Localize(),
PopupMate = new MatePoint()
{
Mate = new MateOptions(MateEdge.Right, MateEdge.Top)
}
};
gridSnapButton.AnchorMate.Mate.VerticalEdge = MateEdge.Bottom;
gridSnapButton.AnchorMate.Mate.HorizontalEdge = MateEdge.Right;
viewOptionsBar.AddChild(gridSnapButton);
CreateTumbleCubeAndControls(theme);
this.Object3DControlLayer.AfterDraw += AfterDraw3DContent;
@ -366,6 +293,280 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
}
}
private void CreateTumbleCubeAndControls(ThemeConfig theme)
{
var controlLayer = this.Object3DControlLayer;
var scale = GuiWidget.DeviceScale;
var tumbleCubeControl = new TumbleCubeControl(controlLayer, theme, TrackballTumbleWidget)
{
Margin = new BorderDouble(0, 0, 40, 45),
VAnchor = VAnchor.Top,
HAnchor = HAnchor.Right,
Name = "Tumble Cube Control"
};
var cubeCenterFromRightTop = new Vector2(tumbleCubeControl.Margin.Right * scale + tumbleCubeControl.Width / 2,
tumbleCubeControl.Margin.Top * scale + tumbleCubeControl.Height / 2);
controlLayer.AddChild(tumbleCubeControl);
GuiWidget AddRoundButton(GuiWidget widget, Vector2 offset)
{
widget.BackgroundRadius = new RadiusCorners(widget.Width / 2);
widget.BackgroundOutlineWidth = 1;
widget.VAnchor = VAnchor.Top;
widget.HAnchor = HAnchor.Right;
widget.Margin = new BorderDouble(0, 0, offset.X, offset.Y);
return controlLayer.AddChild(widget);
}
Vector2 RotatedMargin(GuiWidget widget, double angle)
{
var radius = 120;
var widgetCenter = new Vector2(widget.Width / 2, widget.Height / 2);
// divide by scale to convert from pixels to margin units
return (cubeCenterFromRightTop - widgetCenter - new Vector2(0, radius).GetRotated(angle)) / scale;
}
// add the view controls
var buttonGroupA = new ObservableCollection<GuiWidget>();
var partSelectButton = new RadioIconButton(StaticData.Instance.LoadIcon(Path.Combine("ViewTransformControls", "partSelect.png"), 16, 16, theme.InvertIcons), theme)
{
SiblingRadioButtonList = buttonGroupA,
ToolTipText = "Select Part".Localize(),
Margin = theme.ButtonSpacing
};
AddRoundButton(partSelectButton, RotatedMargin(partSelectButton, MathHelper.Tau * .15));
partSelectButton.Click += (s, e) => viewControls3D.ActiveButton = ViewControls3DButtons.PartSelect;
buttonGroupA.Add(partSelectButton);
var rotateButton = new RadioIconButton(StaticData.Instance.LoadIcon(Path.Combine("ViewTransformControls", "rotate.png"), 16, 16, theme.InvertIcons), theme)
{
SiblingRadioButtonList = buttonGroupA,
ToolTipText = "Rotate (Alt + Left Mouse)".Localize(),
Margin = theme.ButtonSpacing
};
AddRoundButton(rotateButton, RotatedMargin(rotateButton, MathHelper.Tau * .05));
rotateButton.Click += (s, e) => viewControls3D.ActiveButton = ViewControls3DButtons.Rotate;
buttonGroupA.Add(rotateButton);
var translateButton = new RadioIconButton(StaticData.Instance.LoadIcon(Path.Combine("ViewTransformControls", "translate.png"), 16, 16, theme.InvertIcons), theme)
{
SiblingRadioButtonList = buttonGroupA,
ToolTipText = "Move (Shift + Left Mouse)".Localize(),
Margin = theme.ButtonSpacing
};
AddRoundButton(translateButton, RotatedMargin(translateButton , - MathHelper.Tau * .05));
translateButton.Click += (s, e) => viewControls3D.ActiveButton = ViewControls3DButtons.Translate;
buttonGroupA.Add(translateButton);
var scaleButton = new RadioIconButton(StaticData.Instance.LoadIcon(Path.Combine("ViewTransformControls", "scale.png"), 16, 16, theme.InvertIcons), theme)
{
SiblingRadioButtonList = buttonGroupA,
ToolTipText = "Zoom (Ctrl + Left Mouse)".Localize(),
Margin = theme.ButtonSpacing
};
AddRoundButton(scaleButton, RotatedMargin(scaleButton, - MathHelper.Tau * .15));
scaleButton.Click += (s, e) => viewControls3D.ActiveButton = ViewControls3DButtons.Scale;
buttonGroupA.Add(scaleButton);
// add the background render for the view controls
controlLayer.BeforeDraw += (s, e) =>
{
var tumbleCubeRadius = tumbleCubeControl.Width / 2;
var tumbleCubeCenter = new Vector2(controlLayer.Width - tumbleCubeControl.Margin.Right * scale - tumbleCubeRadius,
controlLayer.Height - tumbleCubeControl.Margin.Top * scale - tumbleCubeRadius);
void renderRoundedGroup(double spanRatio, double startRatio)
{
var angle = MathHelper.Tau * spanRatio;
var width = 20 * scale;
var start = MathHelper.Tau * startRatio - angle / 2;
var end = MathHelper.Tau * startRatio + angle / 2;
var arc = new Arc(tumbleCubeCenter, tumbleCubeRadius + 10 * scale + width / 2, start, end);
var background = new Stroke(arc, width * scale);
background.LineCap = LineCap.Round;
e.Graphics2D.Render(new Stroke(background, scale), Color.Black);
}
renderRoundedGroup(.31, .25);
renderRoundedGroup(.11, .5 + .1);
renderRoundedGroup(.11, 1 - .1);
// e.Graphics2D.Circle(controlLayer.Width - cubeCenterFromRightTop.X, controlLayer.Height - cubeCenterFromRightTop.Y, 150, Color.Cyan);
};
// add the home button
var homeButton = new IconButton(StaticData.Instance.LoadIcon("fa-home_16.png", 16, 16, theme.InvertIcons), theme)
{
ToolTipText = "Reset View".Localize(),
Margin = theme.ButtonSpacing
};
AddRoundButton(homeButton, RotatedMargin(homeButton, MathHelper.Tau * .3)).Click += (s, e) => viewControls3D.NotifyResetView();
var zoomToSelectionButton = new IconButton(StaticData.Instance.LoadIcon("fa-home_16.png", 16, 16, theme.InvertIcons), theme)
{
ToolTipText = "Zoom to Selection".Localize(),
Margin = theme.ButtonSpacing
};
AddRoundButton(zoomToSelectionButton, RotatedMargin(zoomToSelectionButton, MathHelper.Tau * .4)).Click += (s, e) => viewControls3D.NotifyResetView();
var turnTableButton = new IconButton(StaticData.Instance.LoadIcon("fa-home_16.png", 16, 16, theme.InvertIcons), theme)
{
ToolTipText = "Turn Table".Localize(),
Margin = theme.ButtonSpacing
};
AddRoundButton(turnTableButton, RotatedMargin(turnTableButton, - MathHelper.Tau * .4)).Click += (s, e) => viewControls3D.NotifyResetView();
var othrographicButton = new IconButton(StaticData.Instance.LoadIcon("fa-home_16.png", 16, 16, theme.InvertIcons), theme)
{
ToolTipText = "Orthographic".Localize(),
Margin = theme.ButtonSpacing
};
AddRoundButton(othrographicButton, RotatedMargin(othrographicButton, -MathHelper.Tau * .3)).Click += (s, e) => viewControls3D.NotifyResetView();
// put in the bed and build volume buttons
AddBedAndBuildVolumeButtons(controlLayer, sceneContext, printer, theme);
// put in the list buttons
modelViewStyleButton = new ViewStyleButton(sceneContext, theme)
{
ToolTipText = "Model View Style".Localize(),
PopupMate = new MatePoint()
{
Mate = new MateOptions(MateEdge.Left, MateEdge.Top)
}
};
modelViewStyleButton.AnchorMate.Mate.VerticalEdge = MateEdge.Bottom;
modelViewStyleButton.AnchorMate.Mate.HorizontalEdge = MateEdge.Left;
AddRoundButton(modelViewStyleButton, new Vector2(80, 230));
if (printer?.ViewState != null)
{
printer.ViewState.ViewModeChanged += this.ViewState_ViewModeChanged;
}
// now add the grid snap button
var gridSnapButton = new GridOptionsPanel(Object3DControlLayer, theme)
{
ToolTipText = "Snap Grid".Localize(),
PopupMate = new MatePoint()
{
Mate = new MateOptions(MateEdge.Right, MateEdge.Top)
}
};
gridSnapButton.AnchorMate.Mate.VerticalEdge = MateEdge.Bottom;
gridSnapButton.AnchorMate.Mate.HorizontalEdge = MateEdge.Right;
AddRoundButton(gridSnapButton, new Vector2(80, 260));
#if DEBUG
var renderOptionsButton = new RenderOptionsButton(theme, this.Object3DControlLayer)
{
ToolTipText = "Debug Render Options".Localize(),
PopupMate = new MatePoint()
{
Mate = new MateOptions(MateEdge.Left, MateEdge.Top)
},
AnchorMate = new MatePoint()
{
Mate = new MateOptions(MateEdge.Left, MateEdge.Bottom)
}
};
AddRoundButton(renderOptionsButton, new Vector2(80, 290));
#endif
}
internal void AddBedAndBuildVolumeButtons(GuiWidget parent, ISceneContext sceneContext, PrinterConfig printer, ThemeConfig theme)
{
var bedButton = new RadioIconButton(StaticData.Instance.LoadIcon("bed.png", 16, 16, theme.InvertIcons), theme)
{
Name = "Bed Button",
ToolTipText = "Show Print Bed".Localize(),
Checked = sceneContext.RendererOptions.RenderBed,
Margin = new BorderDouble(0, 0, 70, 200),
VAnchor = VAnchor.Top,
HAnchor = HAnchor.Right,
ToggleButton = true,
Height = theme.ButtonHeight,
Width = theme.ButtonHeight,
SiblingRadioButtonList = new List<GuiWidget>()
};
bedButton.CheckedStateChanged += (s, e) =>
{
sceneContext.RendererOptions.RenderBed = bedButton.Checked;
};
parent.AddChild(bedButton);
bool BuildHeightValid() => sceneContext.BuildHeight > 0;
var printAreaButton = new RadioIconButton(StaticData.Instance.LoadIcon("print_area.png", 16, 16, theme.InvertIcons), theme)
{
Name = "Bed Button",
ToolTipText = BuildHeightValid() ? "Show Print Area".Localize() : "Define printer build height to enable",
Checked = sceneContext.RendererOptions.RenderBuildVolume,
Margin = new BorderDouble(0, 0, 90, 200),
VAnchor = VAnchor.Top,
HAnchor = HAnchor.Right,
ToggleButton = true,
Enabled = BuildHeightValid() && printer?.ViewState.ViewMode != PartViewMode.Layers2D,
Height = theme.ButtonHeight,
Width = theme.ButtonHeight,
SiblingRadioButtonList = new List<GuiWidget>()
};
printAreaButton.CheckedStateChanged += (s, e) =>
{
sceneContext.RendererOptions.RenderBuildVolume = printAreaButton.Checked;
};
parent.AddChild(printAreaButton);
this.BindBedOptions(parent, bedButton, printAreaButton, sceneContext.RendererOptions);
if (printer != null)
{
// Disable print area button in GCode2D view
void ViewModeChanged(object s, ViewModeChangedEventArgs e)
{
// Button is conditionally created based on BuildHeight, only set enabled if created
printAreaButton.Enabled = BuildHeightValid() && printer.ViewState.ViewMode != PartViewMode.Layers2D;
}
printer.ViewState.ViewModeChanged += ViewModeChanged;
parent.Closed += (s, e) =>
{
printer.ViewState.ViewModeChanged -= ViewModeChanged;
};
}
}
public void BindBedOptions(GuiWidget container, ICheckbox bedButton, ICheckbox printAreaButton, View3DConfig renderOptions)
{
void SyncProperties(object s, PropertyChangedEventArgs e)
{
switch (e.PropertyName)
{
case nameof(renderOptions.RenderBed):
bedButton.Checked = renderOptions.RenderBed;
break;
case nameof(renderOptions.RenderBuildVolume) when printAreaButton != null:
printAreaButton.Checked = renderOptions.RenderBuildVolume;
break;
}
}
renderOptions.PropertyChanged += SyncProperties;
container.Closed += (s, e) =>
{
renderOptions.PropertyChanged -= SyncProperties;
};
}
private void GetNearFar(out double zNear, out double zFar)
{
zNear = .1;
@ -1067,15 +1268,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{
this.Object3DControlLayer.SuppressObject3DControls = true;
var info = new IntersectInfo();
IObject3D hitObject = FindHitObject3D(mouseEvent.Position, out info);
IObject3D hitObject = FindHitObject3D(mouseEvent.Position, out IntersectInfo info);
if (hitObject == null)
{
if (selectedItem != null)
{
Scene.ClearSelection();
selectedItem = null;
}
// start a selection rect

View file

@ -208,60 +208,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
undoButton.Enabled = undoBuffer.UndoCount > 0;
redoButton.Enabled = undoBuffer.RedoCount > 0;
var buttonGroupA = new ObservableCollection<GuiWidget>();
if (UserSettings.Instance.IsTouchScreen)
{
iconPath = Path.Combine("ViewTransformControls", "rotate.png");
rotateButton = new RadioIconButton(StaticData.Instance.LoadIcon(iconPath, 32, 32, theme.InvertIcons), theme)
{
SiblingRadioButtonList = buttonGroupA,
ToolTipText = "Rotate (Alt + Left Mouse)".Localize(),
Margin = theme.ButtonSpacing
};
rotateButton.Click += (s, e) => this.ActiveButton = ViewControls3DButtons.Rotate;
buttonGroupA.Add(rotateButton);
AddChild(rotateButton);
iconPath = Path.Combine("ViewTransformControls", "translate.png");
translateButton = new RadioIconButton(StaticData.Instance.LoadIcon(iconPath, 32, 32, theme.InvertIcons), theme)
{
SiblingRadioButtonList = buttonGroupA,
ToolTipText = "Move (Shift + Left Mouse)".Localize(),
Margin = theme.ButtonSpacing
};
translateButton.Click += (s, e) => this.ActiveButton = ViewControls3DButtons.Translate;
buttonGroupA.Add(translateButton);
AddChild(translateButton);
iconPath = Path.Combine("ViewTransformControls", "scale.png");
scaleButton = new RadioIconButton(StaticData.Instance.LoadIcon(iconPath, 32, 32, theme.InvertIcons), theme)
{
SiblingRadioButtonList = buttonGroupA,
ToolTipText = "Zoom (Ctrl + Left Mouse)".Localize(),
Margin = theme.ButtonSpacing
};
scaleButton.Click += (s, e) => this.ActiveButton = ViewControls3DButtons.Scale;
buttonGroupA.Add(scaleButton);
AddChild(scaleButton);
rotateButton.Checked = true;
// Add vertical separator
this.AddChild(new ToolbarSeparator(theme.GetBorderColor(50), theme.SeparatorMargin));
iconPath = Path.Combine("ViewTransformControls", "partSelect.png");
partSelectButton = new RadioIconButton(StaticData.Instance.LoadIcon(iconPath, 32, 32, theme.InvertIcons), theme)
{
SiblingRadioButtonList = buttonGroupA,
ToolTipText = "Select Part".Localize(),
Margin = theme.ButtonSpacing
};
partSelectButton.Click += (s, e) => this.ActiveButton = ViewControls3DButtons.PartSelect;
buttonGroupA.Add(partSelectButton);
AddChild(partSelectButton);
}
operationButtons = new Dictionary<GuiWidget, SceneOperation>();
// Add Selected IObject3D -> Operations to toolbar

View file

@ -92,11 +92,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
switch (enumDisplayAttibute.Mode)
{
case EnumDisplayAttribute.PresentationMode.IconRow:
AddIconRow(enumItems);
AddIconRow(enumItems, enumDescriptions);
break;
case EnumDisplayAttribute.PresentationMode.Tabs:
AddTabs(enumItems);
AddTabs(enumItems, enumDescriptions);
break;
case EnumDisplayAttribute.PresentationMode.Buttons:
@ -108,7 +108,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
}
}
private void AddTabs(IEnumerable<(string Key, string Value)> enumItems)
private void AddTabs(IEnumerable<(string Key, string Value)> enumItems, List<string> descriptions)
{
var menuRow = new FlowLayoutWidget()
{
@ -120,7 +120,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
var localIndex = index;
var radioButton = new RadioTextButton(enumItem.Value, theme);
var radioButton = new RadioTextButton(enumItem.Value, theme)
{
ToolTipText = descriptions[index]
};
menuRow.AfterDraw += (s, e) =>
{
e.Graphics2D.Rectangle(menuRow.LocalBounds.Left, 0, menuRow.LocalBounds.Right, 2, theme.PrimaryAccentColor);
@ -209,7 +213,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
this.Content = menuRow;
}
private void AddIconRow(IEnumerable<(string Key, string Value)> enumItems)
private void AddIconRow(IEnumerable<(string Key, string Value)> enumItems, List<string> descriptions)
{
var iconsRow = new FlowLayoutWidget();
@ -236,7 +240,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
var radioButton = new RadioIconButton(iconImage, theme)
{
ToolTipText = enumItem.Key
ToolTipText = descriptions[index] == null ? enumItem.Key : descriptions[index],
};
radioButtonSize = new Vector2(radioButton.Width, radioButton.Height);

View file

@ -50,7 +50,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
printer.Settings.SetValue(SettingsKey.selector_ip_address, defaultOption.Text);
};
UiThread.RunOnIdle(RebuildMenuItems);
// Prevent droplist interaction when connected
void CommunicationStateChanged(object s, EventArgs e)
@ -74,6 +73,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
widget.AddChild(refreshButton);
this.Content = widget;
UiThread.RunOnIdle(RebuildMenuItems);
}
protected override void OnValueChanged(FieldChangedEventArgs fieldChangedEventArgs)

@ -1 +1 @@
Subproject commit 94af999a2008864fcd1671f6c0c5d05159ea38dd
Subproject commit 21557b54a3e5b88eb386b9fe688899bd944d8824