The Curve tool can rebuild when its children change

Adding Rebuliding and Rebuild to IObject3D
This commit is contained in:
Lars Brubaker 2018-05-22 09:45:01 -07:00
parent 410c95d613
commit ca438aba4b
30 changed files with 68 additions and 46 deletions

View file

@ -31,7 +31,7 @@ using MatterHackers.Agg.UI;
namespace MatterHackers.MatterControl.DesignTools
{
public interface IRebuildable
public interface IPublicPropertyObject
{
void Rebuild(UndoBuffer undoBuffer);
}

View file

@ -42,7 +42,7 @@ using Newtonsoft.Json;
namespace MatterHackers.MatterControl.Plugins.Lithophane
{
public class LithophaneObject3D : Object3D, IRebuildable
public class LithophaneObject3D : Object3D, IPublicPropertyObject
{
[JsonIgnore]
public ImageObject3D Image => this.Children.OfType<ImageObject3D>().FirstOrDefault();

View file

@ -178,7 +178,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
}
[HideUpdateButtonAttribute]
public class Align3D : Object3D, IRebuildable, IPropertyGridModifier
public class Align3D : Object3D, IPublicPropertyObject, IPropertyGridModifier
{
// We need to serialize this so we can remove the arrange and get back to the objects before arranging
public List<Aabb> OriginalChildrenBounds = new List<Aabb>();

View file

@ -35,7 +35,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools.Operations
{
public class ArrayAdvanced3D : Object3D, IRebuildable
public class ArrayAdvanced3D : Object3D, IPublicPropertyObject
{
public ArrayAdvanced3D()
{

View file

@ -35,7 +35,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools.Operations
{
public class ArrayLinear3D : Object3D, IRebuildable
public class ArrayLinear3D : Object3D, IPublicPropertyObject
{
public ArrayLinear3D()
{

View file

@ -36,7 +36,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools.Operations
{
public class ArrayRadial3D : Object3D, IRebuildable
public class ArrayRadial3D : Object3D, IPublicPropertyObject
{
public ArrayRadial3D()
{

View file

@ -39,7 +39,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools
{
public class CurveObject3D : MeshWrapperObject3D, IRebuildable
public class CurveObject3D : MeshWrapperObject3D, IPublicPropertyObject
{
public double Diameter { get; set; } = 0;
@ -50,8 +50,10 @@ namespace MatterHackers.MatterControl.DesignTools
{
}
public void Rebuild(UndoBuffer undoBuffer)
public override void Rebuild(UndoBuffer undoBuffer)
{
ResetMeshWrappers();
var meshWrapper = this.Descendants()
.Where((obj) => obj.OwnerID == this.ID).ToList();
@ -119,6 +121,9 @@ namespace MatterHackers.MatterControl.DesignTools
transformedMesh.CalculateNormals();
}
}
// Let the base know it needs to rebuild
base.Rebuild(undoBuffer);
}
}
}

View file

@ -46,7 +46,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
public enum MaintainRatio { None, X_Y, X_Y_Z }
[HideUpdateButtonAttribute]
public class FitToBounds3D : Object3D, IRebuildable, IEditorDraw, IPropertyGridModifier
public class FitToBounds3D : Object3D, IPublicPropertyObject, IEditorDraw, IPropertyGridModifier
{
[Description("Set the shape the part will be fit into.")]
public FitType FitType { get; set; } = FitType.Box;

View file

@ -38,7 +38,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools
{
public class PinchObject3D : MeshWrapperObject3D, IRebuildable
public class PinchObject3D : MeshWrapperObject3D, IPublicPropertyObject
{
[DisplayName("Back Ratio")]
public double PinchRatio { get; set; } = 1;

View file

@ -38,7 +38,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
using Polygon = List<IntPoint>;
using Polygons = List<List<IntPoint>>;
public class SmoothPath : Object3D, IRebuildable
public class SmoothPath : Object3D, IPublicPropertyObject
{
public Polygons PathData;

View file

@ -43,7 +43,7 @@ namespace MatterHackers.MatterControl.DesignTools
using Polygons = List<List<IntPoint>>;
public enum BaseTypes { None, Rectangle, Circle, /* Oval, Frame,*/ Outline, };
public class BaseObject3D : Object3D, IRebuildable, IPropertyGridModifier
public class BaseObject3D : Object3D, IPublicPropertyObject, IPropertyGridModifier
{
readonly double scalingForClipper = 1000;

View file

@ -40,7 +40,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools
{
[HideUpdateButtonAttribute]
public class ConeObject3D : Object3D, IRebuildable
public class ConeObject3D : Object3D, IPublicPropertyObject
{
public ConeObject3D()
{

View file

@ -36,7 +36,7 @@ using MatterHackers.PolygonMesh;
namespace MatterHackers.MatterControl.DesignTools
{
[HideUpdateButtonAttribute]
public class CubeObject3D : Object3D, IRebuildable
public class CubeObject3D : Object3D, IPublicPropertyObject
{
public CubeObject3D()
{

View file

@ -40,7 +40,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools
{
[HideUpdateButtonAttribute]
public class CylinderObject3D : Object3D, IRebuildable, IPropertyGridModifier
public class CylinderObject3D : Object3D, IPublicPropertyObject, IPropertyGridModifier
{
public CylinderObject3D()
{

View file

@ -39,7 +39,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools
{
[HideUpdateButtonAttribute]
public class HalfCylinderObject3D : Object3D, IRebuildable
public class HalfCylinderObject3D : Object3D, IPublicPropertyObject
{
public HalfCylinderObject3D()
{

View file

@ -39,7 +39,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools
{
[HideUpdateButtonAttribute]
public class HalfSphereObject3D : Object3D, IRebuildable
public class HalfSphereObject3D : Object3D, IPublicPropertyObject
{
public HalfSphereObject3D()
{

View file

@ -39,7 +39,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools
{
[HideUpdateButtonAttribute]
public class HalfWedgeObject3D : Object3D, IRebuildable
public class HalfWedgeObject3D : Object3D, IPublicPropertyObject
{
public HalfWedgeObject3D()
{

View file

@ -41,7 +41,7 @@ using Newtonsoft.Json;
namespace MatterHackers.MatterControl.DesignTools
{
public class ImageObject3D : AssetObject3D, IRebuildable
public class ImageObject3D : AssetObject3D, IPublicPropertyObject
{
private const double DefaultSizeMm = 60;

View file

@ -38,7 +38,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools
{
[HideUpdateButtonAttribute]
public class PyramidObject3D : Object3D, IRebuildable
public class PyramidObject3D : Object3D, IPublicPropertyObject
{
public PyramidObject3D()
{

View file

@ -41,7 +41,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools
{
[HideUpdateButtonAttribute]
public class RingObject3D : Object3D, IRebuildable, IPropertyGridModifier
public class RingObject3D : Object3D, IPublicPropertyObject, IPropertyGridModifier
{
public RingObject3D()
{

View file

@ -39,7 +39,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools
{
[HideUpdateButtonAttribute]
public class SphereObject3D : Object3D, IRebuildable, IPropertyGridModifier
public class SphereObject3D : Object3D, IPublicPropertyObject, IPropertyGridModifier
{
public SphereObject3D()
{

View file

@ -44,7 +44,7 @@ using Newtonsoft.Json.Converters;
namespace MatterHackers.MatterControl.DesignTools
{
public class TextObject3D : Object3D, IRebuildable
public class TextObject3D : Object3D, IPublicPropertyObject
{
public TextObject3D()
{
@ -85,7 +85,7 @@ namespace MatterHackers.MatterControl.DesignTools
undoBuffer.AddAndDo(new ReplaceCommand(new List<IObject3D> { this }, new List<IObject3D> { newContainer }));
}
public void Rebuild(UndoBuffer undoBuffer)
public override void Rebuild(UndoBuffer undoBuffer)
{
var aabb = this.GetAxisAlignedBoundingBox();
@ -120,6 +120,9 @@ namespace MatterHackers.MatterControl.DesignTools
// If the part was already created and at a height, maintain the height.
PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z);
}
// Let the base know it needs to rebuild
base.Rebuild(undoBuffer);
}
}
}

View file

@ -41,7 +41,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools
{
[HideUpdateButtonAttribute]
public class TorusObject3D : Object3D, IRebuildable, IPropertyGridModifier
public class TorusObject3D : Object3D, IPublicPropertyObject, IPropertyGridModifier
{
public TorusObject3D()
{

View file

@ -39,7 +39,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools
{
[HideUpdateButtonAttribute]
public class WedgeObject3D : Object3D, IRebuildable
public class WedgeObject3D : Object3D, IPublicPropertyObject
{
public WedgeObject3D()
{

View file

@ -80,7 +80,7 @@ namespace MatterHackers.MatterControl.DesignTools
public bool Unlocked { get; } = true;
public IEnumerable<Type> SupportedTypes() => new Type[] { typeof(IRebuildable) };
public IEnumerable<Type> SupportedTypes() => new Type[] { typeof(IPublicPropertyObject) };
private static Type[] allowedTypes =
{
@ -160,7 +160,7 @@ namespace MatterHackers.MatterControl.DesignTools
{
var undoBuffer = view3DWidget.sceneContext.Scene.UndoBuffer;
var rebuildable = context.item as IRebuildable;
var rebuildable = context.item as IPublicPropertyObject;
var propertyGridModifier = context.item as IPropertyGridModifier;
var editableProperties = GetEditablePropreties(context.item);
@ -192,7 +192,7 @@ namespace MatterHackers.MatterControl.DesignTools
private static void AddPropertyEditor(PublicPropertyEditor publicPropertyEditor,
View3DWidget view3DWidget, FlowLayoutWidget editControlsContainer, ThemeConfig theme,
UndoBuffer undoBuffer, IRebuildable rebuildable, IPropertyGridModifier propertyGridModifier,
UndoBuffer undoBuffer, IPublicPropertyObject rebuildable, IPropertyGridModifier propertyGridModifier,
EditableProperty property, PPEContext context)
{
GuiWidget rowContainer = null;
@ -538,7 +538,7 @@ namespace MatterHackers.MatterControl.DesignTools
}
}
private static GuiWidget CreateEnumEditor(PPEContext context, IRebuildable item,
private static GuiWidget CreateEnumEditor(PPEContext context, IPublicPropertyObject item,
EditableProperty property, Type propertyType, object value, string displayName,
ThemeConfig theme,
UndoBuffer undoBuffer)