The beginning of variable support
This commit is contained in:
parent
8a66242699
commit
4f3a241e86
22 changed files with 187 additions and 85 deletions
|
|
@ -49,12 +49,20 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
private List<Func<double>> getDiameters;
|
||||
|
||||
private List<Action<double>> setDiameters;
|
||||
private Func<double> getHeight;
|
||||
private Action<double> setHeight;
|
||||
|
||||
public ScaleController(List<Func<double>> getDiameters = null, List<Action<double>> setDiameters = null)
|
||||
public ScaleController(Func<double> getHeight,
|
||||
Action<double> setHeight,
|
||||
List<Func<double>> getDiameters = null,
|
||||
List<Action<double>> setDiameters = null)
|
||||
{
|
||||
this.getDiameters = getDiameters;
|
||||
this.setDiameters = setDiameters;
|
||||
|
||||
this.getHeight = getHeight;
|
||||
this.setHeight = setHeight;
|
||||
|
||||
if (getDiameters != null)
|
||||
{
|
||||
for (int i = 0; i < getDiameters.Count; i++)
|
||||
|
|
@ -96,10 +104,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
widthDepthItem.Depth = InitialState.Depth;
|
||||
}
|
||||
|
||||
if (selectedItem is IObjectWithHeight heightItem)
|
||||
{
|
||||
heightItem.Height= InitialState.Height;
|
||||
}
|
||||
setHeight?.Invoke(InitialState.Height);
|
||||
|
||||
if (setDiameters != null)
|
||||
{
|
||||
|
|
@ -187,9 +192,9 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
InitialState.Depth = widthDepthItem.Depth;
|
||||
}
|
||||
|
||||
if (selectedItem is IObjectWithHeight heightItem)
|
||||
if (getHeight != null)
|
||||
{
|
||||
InitialState.Height = heightItem.Height;
|
||||
InitialState.Height = getHeight();
|
||||
}
|
||||
|
||||
if (getDiameters != null)
|
||||
|
|
@ -287,10 +292,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
widthDepthItem.Depth = states.Depth;
|
||||
}
|
||||
|
||||
if (item is IObjectWithHeight heightItem)
|
||||
{
|
||||
heightItem.Height = states.Height;
|
||||
}
|
||||
setHeight?.Invoke(states.Height);
|
||||
|
||||
if (setDiameters != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -72,6 +72,8 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
private readonly double angleOffset;
|
||||
|
||||
public ScaleDiameterControl(IObject3DControlContext context,
|
||||
Func<double> getHeight,
|
||||
Action<double> setHeight,
|
||||
List<Func<double>> getDiameters,
|
||||
List<Action<double>> setDiameters,
|
||||
int diameterIndex,
|
||||
|
|
@ -87,7 +89,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
this.angleOffset = angleOffset;
|
||||
theme = MatterControl.AppContext.Theme;
|
||||
|
||||
scaleController = new ScaleController(getDiameters, setDiameters);
|
||||
scaleController = new ScaleController(getHeight, setHeight, getDiameters, setDiameters);
|
||||
|
||||
diameterValueDisplayInfo = new InlineEditControl()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -66,14 +66,20 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
private Vector3 originalPointToMove;
|
||||
|
||||
private ScaleController scaleController;
|
||||
private readonly Func<double> getHeight;
|
||||
|
||||
public ScaleHeightControl(IObject3DControlContext context, List<Func<double>> getDiameters = null, List<Action<double>> setDiameters = null)
|
||||
public ScaleHeightControl(IObject3DControlContext context,
|
||||
Func<double> getHeight,
|
||||
Action<double> setHeight,
|
||||
List<Func<double>> getDiameters = null,
|
||||
List<Action<double>> setDiameters = null)
|
||||
: base(context)
|
||||
{
|
||||
theme = MatterControl.AppContext.Theme;
|
||||
|
||||
scaleController = new ScaleController(getDiameters, setDiameters);
|
||||
|
||||
scaleController = new ScaleController(getHeight, setHeight, getDiameters, setDiameters);
|
||||
this.getHeight = getHeight;
|
||||
|
||||
heightValueDisplayInfo = new InlineEditControl()
|
||||
{
|
||||
ForceHide = () =>
|
||||
|
|
@ -335,11 +341,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
{
|
||||
if (MouseDownOnControl)
|
||||
{
|
||||
if (activeSelectedItem is IObjectWithHeight heightObject
|
||||
&& heightObject.Height != scaleController.InitialState.Height)
|
||||
{
|
||||
scaleController.EditComplete();
|
||||
}
|
||||
scaleController.EditComplete();
|
||||
|
||||
Object3DControlContext.Scene.ShowSelectionShadow = true;
|
||||
}
|
||||
|
|
@ -405,10 +407,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
int j = 0;
|
||||
|
||||
Vector2 heightDisplayCenter = (((lines[j] + lines[j + 1]) / 2) + ((lines[j + 2] + lines[j + 3]) / 2)) / 2;
|
||||
if (activeSelectedItem is IObjectWithHeight heightObject)
|
||||
{
|
||||
heightValueDisplayInfo.Value = heightObject.Height;
|
||||
}
|
||||
heightValueDisplayInfo.Value = getHeight();
|
||||
|
||||
heightValueDisplayInfo.OriginRelativeParent = heightDisplayCenter + new Vector2(10, -heightValueDisplayInfo.LocalBounds.Center.Y);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,13 +67,18 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
|
||||
private Vector3 initialHitPosition;
|
||||
|
||||
private ScaleController scaleController = new ScaleController();
|
||||
private ScaleController scaleController;
|
||||
|
||||
public ScaleWidthDepthCornerControl(IObject3DControlContext object3DControlContext, int quadrant)
|
||||
public ScaleWidthDepthCornerControl(IObject3DControlContext object3DControlContext,
|
||||
Func<double> getHeight,
|
||||
Action<double> setHeight,
|
||||
int quadrant)
|
||||
: base(object3DControlContext)
|
||||
{
|
||||
theme = MatterControl.AppContext.Theme;
|
||||
|
||||
scaleController = new ScaleController(getHeight, setHeight);
|
||||
|
||||
xValueDisplayInfo = new InlineEditControl()
|
||||
{
|
||||
ForceHide = ForceHideScale,
|
||||
|
|
|
|||
|
|
@ -67,13 +67,18 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
|
||||
private Vector3 initialHitPosition;
|
||||
|
||||
private ScaleController scaleController = new ScaleController();
|
||||
private ScaleController scaleController;
|
||||
|
||||
public ScaleWidthDepthEdgeControl(IObject3DControlContext context, int edgeIndex)
|
||||
public ScaleWidthDepthEdgeControl(IObject3DControlContext context,
|
||||
Func<double> getHeight,
|
||||
Action<double> setHeight,
|
||||
int edgeIndex)
|
||||
: base(context)
|
||||
{
|
||||
theme = MatterControl.AppContext.Theme;
|
||||
|
||||
scaleController = new ScaleController(getHeight, setHeight);
|
||||
|
||||
xValueDisplayInfo = new InlineEditControl()
|
||||
{
|
||||
ForceHide = ForceHideScale,
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||
{
|
||||
public class FitToBoundsObject3D_3 : TransformWrapperObject3D, ISelectedEditorDraw, IObjectWithWidthAndDepth, IObjectWithHeight
|
||||
public class FitToBoundsObject3D_3 : TransformWrapperObject3D, ISelectedEditorDraw, IObjectWithWidthAndDepth
|
||||
{
|
||||
private Vector3 boundsSize;
|
||||
private InvalidateType additonalInvalidate;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ using Newtonsoft.Json;
|
|||
namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||
{
|
||||
[Obsolete("Use ScaleObject3D_3 instead", false)]
|
||||
public class ScaleObject3D_2 : TransformWrapperObject3D, IObjectWithHeight, IObjectWithWidthAndDepth, IPropertyGridModifier, IScaleLocker
|
||||
public class ScaleObject3D_2 : TransformWrapperObject3D, IObjectWithWidthAndDepth, IPropertyGridModifier, IScaleLocker
|
||||
{
|
||||
public enum ScaleTypes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
|||
void ScaledProportionally();
|
||||
}
|
||||
|
||||
public class ScaleObject3D_3 : TransformWrapperObject3D, IObjectWithHeight, IObjectWithWidthAndDepth, IPropertyGridModifier, IScaleLocker
|
||||
public class ScaleObject3D_3 : TransformWrapperObject3D, IObjectWithWidthAndDepth, IPropertyGridModifier, IScaleLocker
|
||||
{
|
||||
public enum ScaleTypes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ using MatterHackers.Plugins.EditorTools;
|
|||
|
||||
namespace MatterHackers.MatterControl.DesignTools
|
||||
{
|
||||
public class ConeObject3D : PrimitiveObject3D, IObjectWithHeight, IObject3DControlsProvider
|
||||
public class ConeObject3D : PrimitiveObject3D, IObject3DControlsProvider
|
||||
{
|
||||
public ConeObject3D()
|
||||
{
|
||||
|
|
@ -105,13 +105,19 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
|
||||
public void AddObject3DControls(Object3DControlsLayer object3DControlsLayer)
|
||||
{
|
||||
double getHeight() => Height;
|
||||
void setHeight(double height) => Height = height;
|
||||
var getDiameters = new List<Func<double>>() { () => Diameter };
|
||||
var setDiameters = new List<Action<double>>() { (diameter) => Diameter = diameter };
|
||||
object3DControlsLayer.Object3DControls.Add(new ScaleDiameterControl(object3DControlsLayer,
|
||||
getHeight,
|
||||
setHeight,
|
||||
getDiameters,
|
||||
setDiameters,
|
||||
0));
|
||||
object3DControlsLayer.Object3DControls.Add(new ScaleHeightControl(object3DControlsLayer,
|
||||
getHeight,
|
||||
setHeight,
|
||||
getDiameters,
|
||||
setDiameters));
|
||||
object3DControlsLayer.AddControls(ControlTypes.MoveInZ);
|
||||
|
|
|
|||
|
|
@ -27,14 +27,63 @@ of the authors and should not be interpreted as representing official policies,
|
|||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.PartPreviewWindow;
|
||||
using MatterHackers.Plugins.EditorTools;
|
||||
using MatterHackers.PolygonMesh;
|
||||
|
||||
namespace MatterHackers.MatterControl.DesignTools
|
||||
{
|
||||
public class CubeObject3D : PrimitiveObject3D, IObjectWithHeight, IObjectWithWidthAndDepth
|
||||
[TypeConverter(typeof(DoubleExpresion))]
|
||||
public class DoubleExpresion
|
||||
{
|
||||
public string Expresion { get; set; }
|
||||
|
||||
public double Value(IObject3D owner)
|
||||
{
|
||||
if (double.TryParse(Expresion, out double result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
return SheetObject3D.FindTableAndValue<double>(owner, Expresion);
|
||||
}
|
||||
|
||||
public DoubleExpresion(double value)
|
||||
{
|
||||
Expresion = value.ToString();
|
||||
}
|
||||
|
||||
public DoubleExpresion(string value)
|
||||
{
|
||||
Expresion = value;
|
||||
}
|
||||
|
||||
public static implicit operator DoubleExpresion(double value)
|
||||
{
|
||||
return new DoubleExpresion(value);
|
||||
}
|
||||
|
||||
public static implicit operator DoubleExpresion(string value)
|
||||
{
|
||||
return new DoubleExpresion(value);
|
||||
}
|
||||
}
|
||||
|
||||
public class SheetObject3D : Object3D
|
||||
{
|
||||
public static T FindTableAndValue<T>(IObject3D owner, string expresion)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class CubeObject3D : PrimitiveObject3D, IObject3DControlsProvider
|
||||
{
|
||||
public CubeObject3D()
|
||||
{
|
||||
|
|
@ -44,14 +93,17 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
|
||||
public override string ThumbnailName => "Cube";
|
||||
|
||||
/// <summary>
|
||||
/// This is the actual serialized with that can use expressions
|
||||
/// </summary>
|
||||
[MaxDecimalPlaces(2)]
|
||||
public double Width { get; set; } = 20;
|
||||
public DoubleExpresion Width { get; set; } = 20;
|
||||
|
||||
[MaxDecimalPlaces(2)]
|
||||
public double Depth { get; set; } = 20;
|
||||
public DoubleExpresion Depth { get; set; } = 20;
|
||||
|
||||
[MaxDecimalPlaces(2)]
|
||||
public double Height { get; set; } = 20;
|
||||
public DoubleExpresion Height { get; set; } = 20;
|
||||
|
||||
public static async Task<CubeObject3D> Create()
|
||||
{
|
||||
|
|
@ -73,6 +125,17 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
return item;
|
||||
}
|
||||
|
||||
public void AddObject3DControls(Object3DControlsLayer object3DControlsLayer)
|
||||
{
|
||||
double getHeight() => Height.Value(this);
|
||||
void setHeight(double height) => Height = height;
|
||||
|
||||
var controls = object3DControlsLayer.Object3DControls;
|
||||
|
||||
controls.Add(new ScaleHeightControl(object3DControlsLayer, getHeight, setHeight));
|
||||
object3DControlsLayer.AddWidthDepthControls(getHeight, setHeight);
|
||||
}
|
||||
|
||||
public override async void OnInvalidate(InvalidateArgs invalidateType)
|
||||
{
|
||||
if (invalidateType.InvalidateType.HasFlag(InvalidateType.Properties)
|
||||
|
|
@ -94,7 +157,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
{
|
||||
using (new CenterAndHeightMaintainer(this))
|
||||
{
|
||||
Mesh = PlatonicSolids.CreateCube(Width, Depth, Height);
|
||||
Mesh = PlatonicSolids.CreateCube(Width.Value(this), Depth.Value(this), Height.Value(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -103,11 +166,6 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
}
|
||||
}
|
||||
|
||||
public interface IObjectWithHeight
|
||||
{
|
||||
double Height { get; set; }
|
||||
}
|
||||
|
||||
public interface IObjectWithWidthAndDepth
|
||||
{
|
||||
double Width { get; set; }
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ using MatterHackers.VectorMath;
|
|||
|
||||
namespace MatterHackers.MatterControl.DesignTools
|
||||
{
|
||||
public class CylinderObject3D : PrimitiveObject3D, IPropertyGridModifier, IObjectWithHeight, IObject3DControlsProvider
|
||||
public class CylinderObject3D : PrimitiveObject3D, IPropertyGridModifier, IObject3DControlsProvider
|
||||
{
|
||||
public CylinderObject3D()
|
||||
{
|
||||
|
|
@ -225,20 +225,28 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
|
||||
public void AddObject3DControls(Object3DControlsLayer object3DControlsLayer)
|
||||
{
|
||||
double getHeight() => Height;
|
||||
void setHeight(double height) => Height = height;
|
||||
var getDiameters = new List<Func<double>>() { () => Diameter, () => DiameterTop };
|
||||
var setDiameters = new List<Action<double>>() { (diameter) => Diameter = diameter, (diameter) => DiameterTop = diameter };
|
||||
object3DControlsLayer.Object3DControls.Add(new ScaleDiameterControl(object3DControlsLayer,
|
||||
getHeight,
|
||||
setHeight,
|
||||
getDiameters,
|
||||
setDiameters,
|
||||
0,
|
||||
controlVisible: () => true));
|
||||
object3DControlsLayer.Object3DControls.Add(new ScaleDiameterControl(object3DControlsLayer,
|
||||
getHeight,
|
||||
setHeight,
|
||||
getDiameters,
|
||||
setDiameters,
|
||||
1,
|
||||
ObjectSpace.Placement.Top,
|
||||
controlVisible: () => Advanced));
|
||||
object3DControlsLayer.Object3DControls.Add(new ScaleHeightControl(object3DControlsLayer,
|
||||
getHeight,
|
||||
setHeight,
|
||||
getDiameters,
|
||||
setDiameters));
|
||||
object3DControlsLayer.AddControls(ControlTypes.MoveInZ);
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
|
||||
public void AddObject3DControls(Object3DControlsLayer object3DControlsLayer)
|
||||
{
|
||||
object3DControlsLayer.AddControls(ControlTypes.ScaleWidthDepth);
|
||||
object3DControlsLayer.AddWidthDepthControls(null, null);
|
||||
object3DControlsLayer.AddControls(ControlTypes.MoveInZ);
|
||||
object3DControlsLayer.AddControls(ControlTypes.RotateXYZ);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,6 +135,8 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
public void AddObject3DControls(Object3DControlsLayer object3DControlsLayer)
|
||||
{
|
||||
object3DControlsLayer.Object3DControls.Add(new ScaleDiameterControl(object3DControlsLayer,
|
||||
null,
|
||||
null,
|
||||
new List<Func<double>>() { () => Diameter },
|
||||
new List<Action<double>>() { (diameter) => Diameter = diameter },
|
||||
0));
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ using MatterHackers.VectorMath;
|
|||
|
||||
namespace MatterHackers.MatterControl.DesignTools
|
||||
{
|
||||
public class HalfWedgeObject3D : PrimitiveObject3D, IObjectWithHeight, IObjectWithWidthAndDepth
|
||||
public class HalfWedgeObject3D : PrimitiveObject3D, IObjectWithWidthAndDepth
|
||||
{
|
||||
public HalfWedgeObject3D()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ using MatterHackers.VectorMath;
|
|||
|
||||
namespace MatterHackers.MatterControl.DesignTools
|
||||
{
|
||||
public class PyramidObject3D : PrimitiveObject3D, IObjectWithHeight, IObjectWithWidthAndDepth
|
||||
public class PyramidObject3D : PrimitiveObject3D, IObjectWithWidthAndDepth
|
||||
{
|
||||
public PyramidObject3D()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ using MatterHackers.VectorMath;
|
|||
|
||||
namespace MatterHackers.MatterControl.DesignTools
|
||||
{
|
||||
public class RingObject3D : PrimitiveObject3D, IPropertyGridModifier, IObjectWithHeight, IObject3DControlsProvider
|
||||
public class RingObject3D : PrimitiveObject3D, IPropertyGridModifier, IObject3DControlsProvider
|
||||
{
|
||||
public RingObject3D()
|
||||
{
|
||||
|
|
@ -160,18 +160,26 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
|
||||
public void AddObject3DControls(Object3DControlsLayer object3DControlsLayer)
|
||||
{
|
||||
double getHeight() => Height;
|
||||
void setHeight(double height) => Height = height;
|
||||
var getDiameters = new List<Func<double>>() { () => OuterDiameter, () => InnerDiameter };
|
||||
var setDiameters = new List<Action<double>>() { (diameter) => OuterDiameter = diameter, (diameter) => InnerDiameter = diameter };
|
||||
object3DControlsLayer.Object3DControls.Add(new ScaleDiameterControl(object3DControlsLayer,
|
||||
getHeight,
|
||||
setHeight,
|
||||
getDiameters,
|
||||
setDiameters,
|
||||
0));
|
||||
object3DControlsLayer.Object3DControls.Add(new ScaleDiameterControl(object3DControlsLayer,
|
||||
getHeight,
|
||||
setHeight,
|
||||
getDiameters,
|
||||
setDiameters,
|
||||
1,
|
||||
angleOffset: -MathHelper.Tau / 32));
|
||||
object3DControlsLayer.Object3DControls.Add(new ScaleHeightControl(object3DControlsLayer,
|
||||
getHeight,
|
||||
setHeight,
|
||||
getDiameters,
|
||||
setDiameters));
|
||||
object3DControlsLayer.AddControls(ControlTypes.MoveInZ);
|
||||
|
|
|
|||
|
|
@ -189,6 +189,8 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
public void AddObject3DControls(Object3DControlsLayer object3DControlsLayer)
|
||||
{
|
||||
object3DControlsLayer.Object3DControls.Add(new ScaleDiameterControl(object3DControlsLayer,
|
||||
null,
|
||||
null,
|
||||
new List<Func<double>>() { () => Diameter },
|
||||
new List<Action<double>>() { (diameter) => Diameter = diameter },
|
||||
0,
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ using Newtonsoft.Json.Converters;
|
|||
namespace MatterHackers.MatterControl.DesignTools
|
||||
{
|
||||
[HideChildrenFromTreeView]
|
||||
public class TextObject3D : Object3D, IObjectWithHeight
|
||||
public class TextObject3D : Object3D
|
||||
{
|
||||
public TextObject3D()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -170,11 +170,15 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
var getDiameters = new List<Func<double>>() { () => OuterDiameter, () => InnerDiameter };
|
||||
var setDiameters = new List<Action<double>>() { (diameter) => OuterDiameter = diameter, (diameter) => InnerDiameter = diameter };
|
||||
object3DControlsLayer.Object3DControls.Add(new ScaleDiameterControl(object3DControlsLayer,
|
||||
null,
|
||||
null,
|
||||
getDiameters,
|
||||
setDiameters,
|
||||
0,
|
||||
ObjectSpace.Placement.Center));
|
||||
object3DControlsLayer.Object3DControls.Add(new ScaleDiameterControl(object3DControlsLayer,
|
||||
null,
|
||||
null,
|
||||
getDiameters,
|
||||
setDiameters,
|
||||
1,
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ using MatterHackers.VectorMath;
|
|||
|
||||
namespace MatterHackers.MatterControl.DesignTools
|
||||
{
|
||||
public class WedgeObject3D : PrimitiveObject3D, IPropertyGridModifier, IObjectWithHeight, IObjectWithWidthAndDepth
|
||||
public class WedgeObject3D : PrimitiveObject3D, IPropertyGridModifier, IObjectWithWidthAndDepth
|
||||
{
|
||||
public WedgeObject3D()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
private static readonly Type[] AllowedTypes =
|
||||
{
|
||||
typeof(double), typeof(int), typeof(char), typeof(string), typeof(bool),
|
||||
typeof(DoubleExpresion),
|
||||
typeof(Color),
|
||||
typeof(Vector2), typeof(Vector3), typeof(Vector4),
|
||||
typeof(DirectionVector), typeof(DirectionAxis),
|
||||
|
|
@ -667,6 +668,28 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
(value) => { return ((bool)value) ? "1" : "0"; });
|
||||
rowContainer = CreateSettingsRow(property, field, theme);
|
||||
}
|
||||
else if (propertyValue is DoubleExpresion doubleExpresion)
|
||||
{
|
||||
// create a string editor
|
||||
var field = new TextField(theme);
|
||||
field.Initialize(0);
|
||||
field.SetValue(doubleExpresion.Expresion, false);
|
||||
field.ClearUndoHistory();
|
||||
field.Content.HAnchor = HAnchor.Stretch;
|
||||
RegisterValueChanged(field,
|
||||
(valueString) => new DoubleExpresion(valueString),
|
||||
(value) =>
|
||||
{
|
||||
return ((DoubleExpresion)value).Expresion;
|
||||
});
|
||||
rowContainer = CreateSettingsRow(property, field, theme);
|
||||
|
||||
var label = rowContainer.Children.First();
|
||||
|
||||
var spacer = rowContainer.Children.OfType<HorizontalSpacer>().FirstOrDefault();
|
||||
spacer.HAnchor = HAnchor.Absolute;
|
||||
spacer.Width = Math.Max(0, 100 - label.Width);
|
||||
}
|
||||
else if (propertyValue is string stringValue)
|
||||
{
|
||||
if (readOnly)
|
||||
|
|
|
|||
|
|
@ -55,11 +55,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
MoveInZ = 1 << 0,
|
||||
RotateXYZ = 1 << 1,
|
||||
RotateZ = 1 << 2,
|
||||
ScaleWidthDepth = 1 << 3,
|
||||
ScaleMatrixXY = 1 << 4,
|
||||
Shadow = 1 << 5,
|
||||
SnappingIndicators = 1 << 6,
|
||||
ScaleHeight = 1 << 7,
|
||||
ScaleMatrixXY = 1 << 3,
|
||||
Shadow = 1 << 4,
|
||||
SnappingIndicators = 1 << 5,
|
||||
|
||||
Standard2D = MoveInZ | Shadow | SnappingIndicators | RotateZ | ScaleMatrixXY
|
||||
}
|
||||
|
|
@ -178,24 +176,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
else
|
||||
{
|
||||
// add default controls
|
||||
if (selectedItem is IObjectWithHeight heightObject)
|
||||
{
|
||||
// When this is ready make the debug behavior the only behavior
|
||||
Object3DControls.Add(new ScaleHeightControl(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
Object3DControls.Add(new ScaleMatrixTopControl(this));
|
||||
}
|
||||
Object3DControls.Add(new ScaleMatrixTopControl(this));
|
||||
|
||||
if (selectedItem is IObjectWithWidthAndDepth widthAndDepth)
|
||||
{
|
||||
AddControls(ControlTypes.ScaleWidthDepth);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddControls(ControlTypes.ScaleMatrixXY);
|
||||
}
|
||||
AddControls(ControlTypes.ScaleMatrixXY);
|
||||
|
||||
AddControls(ControlTypes.RotateXYZ
|
||||
| ControlTypes.MoveInZ
|
||||
|
|
@ -224,6 +207,15 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
base.OnDraw(graphics2D);
|
||||
}
|
||||
|
||||
public void AddWidthDepthControls(Func<double> getHeight, Action<double> setHeight)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
Object3DControls.Add(new ScaleWidthDepthCornerControl(this, getHeight, setHeight, i));
|
||||
Object3DControls.Add(new ScaleWidthDepthEdgeControl(this, getHeight, setHeight, i));
|
||||
}
|
||||
}
|
||||
|
||||
public void AddControls(ControlTypes controls)
|
||||
{
|
||||
if (controls.HasFlag(ControlTypes.RotateXYZ))
|
||||
|
|
@ -244,11 +236,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
Object3DControls.Add(new MoveInZControl(this));
|
||||
}
|
||||
|
||||
if (controls.HasFlag(ControlTypes.ScaleHeight))
|
||||
{
|
||||
Object3DControls.Add(new ScaleHeightControl(this));
|
||||
}
|
||||
|
||||
if (controls.HasFlag(ControlTypes.ScaleMatrixXY))
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
|
|
@ -258,15 +245,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
}
|
||||
}
|
||||
|
||||
if (controls.HasFlag(ControlTypes.ScaleWidthDepth))
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
Object3DControls.Add(new ScaleWidthDepthCornerControl(this, i));
|
||||
Object3DControls.Add(new ScaleWidthDepthEdgeControl(this, i));
|
||||
}
|
||||
}
|
||||
|
||||
if (controls.HasFlag(ControlTypes.Shadow))
|
||||
{
|
||||
Object3DControls.Add(new SelectionShadow(this));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue