Better display of 3d view editor values
This commit is contained in:
parent
58f6645fdf
commit
e1490772e3
8 changed files with 75 additions and 53 deletions
|
|
@ -31,6 +31,7 @@ using System;
|
|||
using System.Diagnostics;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Agg.VertexSource;
|
||||
|
||||
namespace MatterHackers.MatterControl.CustomWidgets
|
||||
{
|
||||
|
|
@ -42,20 +43,39 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
private RunningInterval runningInterval;
|
||||
private ThemeConfig theme;
|
||||
|
||||
public InlineEditControl(string defaultSizeString = "-0000.00", Agg.Font.Justification justification = Agg.Font.Justification.Left)
|
||||
public InlineEditControl(string defaultSizeString = "-0000.00")
|
||||
{
|
||||
theme = AppContext.Theme;
|
||||
base.Visible = false;
|
||||
|
||||
double pointSize = 12;
|
||||
double pointSize = 10;
|
||||
|
||||
numberDisplay = new TextWidget(defaultSizeString, 0, 0, pointSize, justification: justification, textColor: theme.TextColor)
|
||||
this.Padding = new BorderDouble(3);
|
||||
|
||||
numberDisplay = new TextWidget(defaultSizeString, 0, 0, pointSize, justification: Agg.Font.Justification.Center, textColor: theme.TextColor)
|
||||
{
|
||||
Visible = false,
|
||||
VAnchor = VAnchor.Bottom,
|
||||
HAnchor = HAnchor.Left,
|
||||
Text = "0",
|
||||
AutoExpandBoundsToText = true,
|
||||
};
|
||||
|
||||
this.BeforeDraw += (s, e) =>
|
||||
{
|
||||
if (s is GuiWidget widget)
|
||||
{
|
||||
var test = true;
|
||||
if (test)
|
||||
{
|
||||
// return;
|
||||
}
|
||||
|
||||
var bounds = widget.LocalBounds;
|
||||
e.Graphics2D.Render(new RoundedRect(bounds, 3 * GuiWidget.DeviceScale), theme.BackgroundColor.WithAlpha(200));
|
||||
}
|
||||
};
|
||||
|
||||
AddChild(numberDisplay);
|
||||
|
||||
numberEdit = new MHNumberEdit(0, theme, pixelWidth: numberDisplay.Width, allowNegatives: true, allowDecimals: true)
|
||||
|
|
@ -68,7 +88,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
numberEdit.ActuallNumberEdit.InternalNumberEdit.TextChanged += (s, e) =>
|
||||
{
|
||||
numberDisplay.Text = GetDisplayString == null ? "None" : GetDisplayString.Invoke(Value);
|
||||
base.OnTextChanged(e);
|
||||
this.OnTextChanged(e);
|
||||
};
|
||||
numberEdit.ActuallNumberEdit.InternalNumberEdit.MaxDecimalsPlaces = 2;
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
xValueDisplayInfo = new InlineEditControl()
|
||||
{
|
||||
ForceHide = ForceHideScale,
|
||||
GetDisplayString = (value) => "{0:0.0}mm".FormatWith(value),
|
||||
GetDisplayString = (value) => "{0:0.0}".FormatWith(value),
|
||||
};
|
||||
|
||||
xValueDisplayInfo.EditComplete += EditComplete;
|
||||
|
|
@ -92,7 +92,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
yValueDisplayInfo = new InlineEditControl()
|
||||
{
|
||||
ForceHide = ForceHideScale,
|
||||
GetDisplayString = (value) => "{0:0.0}mm".FormatWith(value)
|
||||
GetDisplayString = (value) => "{0:0.0}".FormatWith(value)
|
||||
};
|
||||
|
||||
yValueDisplayInfo.EditComplete += EditComplete;
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
|
||||
return false;
|
||||
},
|
||||
GetDisplayString = (value) => "{0:0.0}mm".FormatWith(value)
|
||||
GetDisplayString = (value) => "{0:0.0}".FormatWith(value)
|
||||
};
|
||||
|
||||
zValueDisplayInfo.VisibleChanged += (s, e) =>
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ of the authors and should not be interpreted as representing official policies,
|
|||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
|
|
@ -36,7 +35,6 @@ using System.Threading.Tasks;
|
|||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Platform;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Agg.VertexSource;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.PartPreviewWindow;
|
||||
|
|
@ -51,6 +49,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
public class MeasureToolObject3D : Object3D, IObject3DControlsProvider, IEditorDraw
|
||||
{
|
||||
private static Mesh shape = null;
|
||||
private List<IObject3DControl> editorControls;
|
||||
|
||||
public MeasureToolObject3D()
|
||||
{
|
||||
|
|
@ -91,45 +90,50 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
|
||||
public List<IObject3DControl> GetObject3DControls(Object3DControlsLayer object3DControlsLayer)
|
||||
{
|
||||
return new List<IObject3DControl>
|
||||
if (editorControls == null)
|
||||
{
|
||||
new TracedPositionObject3DControl(object3DControlsLayer,
|
||||
this,
|
||||
() =>
|
||||
editorControls = new List<IObject3DControl>
|
||||
{
|
||||
return PositionsHaveBeenSet ? StartPosition : StartPosition.Transform(Matrix);
|
||||
},
|
||||
(position) =>
|
||||
{
|
||||
if (!PositionsHaveBeenSet)
|
||||
new TracedPositionObject3DControl(object3DControlsLayer,
|
||||
this,
|
||||
() =>
|
||||
{
|
||||
PositionsHaveBeenSet = true;
|
||||
EndPosition = EndPosition.Transform(this.Matrix);
|
||||
}
|
||||
|
||||
StartPosition = position;
|
||||
Distance = (StartPosition - EndPosition).Length;
|
||||
UiThread.RunOnIdle(() => Invalidate(InvalidateType.DisplayValues));
|
||||
}),
|
||||
new TracedPositionObject3DControl(object3DControlsLayer,
|
||||
this,
|
||||
() =>
|
||||
{
|
||||
return PositionsHaveBeenSet ? EndPosition : EndPosition.Transform(Matrix);
|
||||
},
|
||||
(position) =>
|
||||
{
|
||||
if (!PositionsHaveBeenSet)
|
||||
return PositionsHaveBeenSet ? StartPosition : StartPosition.Transform(Matrix);
|
||||
},
|
||||
(position) =>
|
||||
{
|
||||
PositionsHaveBeenSet = true;
|
||||
StartPosition = StartPosition.Transform(this.Matrix);
|
||||
}
|
||||
if (!PositionsHaveBeenSet)
|
||||
{
|
||||
PositionsHaveBeenSet = true;
|
||||
EndPosition = EndPosition.Transform(this.Matrix);
|
||||
}
|
||||
|
||||
EndPosition = position;
|
||||
Distance = (StartPosition - EndPosition).Length;
|
||||
UiThread.RunOnIdle(() => Invalidate(InvalidateType.DisplayValues));
|
||||
}),
|
||||
};
|
||||
StartPosition = position;
|
||||
Distance = (StartPosition - EndPosition).Length;
|
||||
UiThread.RunOnIdle(() => Invalidate(InvalidateType.DisplayValues));
|
||||
}),
|
||||
new TracedPositionObject3DControl(object3DControlsLayer,
|
||||
this,
|
||||
() =>
|
||||
{
|
||||
return PositionsHaveBeenSet ? EndPosition : EndPosition.Transform(Matrix);
|
||||
},
|
||||
(position) =>
|
||||
{
|
||||
if (!PositionsHaveBeenSet)
|
||||
{
|
||||
PositionsHaveBeenSet = true;
|
||||
StartPosition = StartPosition.Transform(this.Matrix);
|
||||
}
|
||||
|
||||
EndPosition = position;
|
||||
Distance = (StartPosition - EndPosition).Length;
|
||||
UiThread.RunOnIdle(() => Invalidate(InvalidateType.DisplayValues));
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
return editorControls;
|
||||
}
|
||||
|
||||
public override async void OnInvalidate(InvalidateArgs invalidateType)
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public static Mesh CreateSphere(double diameter = 1, int sides = 30, int latitudeSides = 30, double startingAngle = 0, double endingAngle = MathHelper.Tau)
|
||||
public static Mesh CreateSphere(double diameter = 1, int sides = 30, int latitudeSides = 30, double startingAngleDeg = 0, double endingAngleDeg = 360)
|
||||
{
|
||||
var path = new VertexStorage();
|
||||
var angleDelta = MathHelper.Tau / 2 / latitudeSides;
|
||||
|
|
@ -135,8 +135,8 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
path.LineTo(new Vector2(radius * Math.Cos(angle), radius * Math.Sin(angle)));
|
||||
}
|
||||
|
||||
var startAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(startingAngle));
|
||||
var endAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(endingAngle));
|
||||
var startAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(startingAngleDeg));
|
||||
var endAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(endingAngleDeg));
|
||||
var steps = Math.Max(1, (int)(sides * MathHelper.Tau / Math.Abs(MathHelper.GetDeltaAngle(startAngle, endAngle)) + .5));
|
||||
return VertexSourceToMesh.Revolve(path,
|
||||
steps,
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
{
|
||||
public class TracedPositionObject3DControl : IObject3DControl
|
||||
{
|
||||
private readonly double blockSize = 9 * GuiWidget.DeviceScale;
|
||||
private readonly double blockSize = 11 * GuiWidget.DeviceScale;
|
||||
|
||||
private ITraceable collisionVolume;
|
||||
private ThemeConfig theme;
|
||||
|
|
@ -65,7 +65,8 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
this.context = context;
|
||||
this.getPosition = getPosition;
|
||||
this.setPosition = setPosition;
|
||||
this.shape = PlatonicSolids.CreateCube(); // SphereObject3D.CreateSphere();
|
||||
this.shape = PlatonicSolids.CreateCube();
|
||||
this.shape = SphereObject3D.CreateSphere(1, 15, 10);
|
||||
collisionVolume = shape.CreateBVHData();
|
||||
this.owner = owner;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
return false;
|
||||
},
|
||||
GetDisplayString = (value) => "{0:0.0#}mm".FormatWith(value)
|
||||
GetDisplayString = (value) => "{0:0.0#}".FormatWith(value)
|
||||
};
|
||||
|
||||
zHeightDisplayInfo.VisibleChanged += (s, e) =>
|
||||
|
|
|
|||
|
|
@ -909,16 +909,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
// Invoke existing IEditorDraw when iterating items
|
||||
if (selectedItem is IEditorDraw editorDraw)
|
||||
{
|
||||
// TODO: Putting the drawing code in the IObject3D means almost certain bindings to MatterControl in IObject3D. If instead
|
||||
// we had a UI layer object that used binding to register scene drawing hooks for specific types, we could avoid the bindings
|
||||
editorDraw.DrawEditor(this, transparentMeshes, e);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in scene.Children)
|
||||
{
|
||||
if (item.Visible
|
||||
&& (item != selectedItem))
|
||||
if (item.Visible)
|
||||
{
|
||||
DrawObject(item, transparentMeshes, e);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue