diff --git a/DesignTools/Interfaces/IRebuildable.cs b/DesignTools/Interfaces/IPublicPropertyObject.cs similarity index 97% rename from DesignTools/Interfaces/IRebuildable.cs rename to DesignTools/Interfaces/IPublicPropertyObject.cs index 35a55049e..2b78eaf4e 100644 --- a/DesignTools/Interfaces/IRebuildable.cs +++ b/DesignTools/Interfaces/IPublicPropertyObject.cs @@ -31,7 +31,7 @@ using MatterHackers.Agg.UI; namespace MatterHackers.MatterControl.DesignTools { - public interface IRebuildable + public interface IPublicPropertyObject { void Rebuild(UndoBuffer undoBuffer); } diff --git a/DesignTools/LithophaneObject3D.cs b/DesignTools/LithophaneObject3D.cs index a09eda600..a62f87eec 100644 --- a/DesignTools/LithophaneObject3D.cs +++ b/DesignTools/LithophaneObject3D.cs @@ -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().FirstOrDefault(); diff --git a/DesignTools/Operations/Align3D.cs b/DesignTools/Operations/Align3D.cs index 1bcd3b50b..deb9ad3cc 100644 --- a/DesignTools/Operations/Align3D.cs +++ b/DesignTools/Operations/Align3D.cs @@ -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 OriginalChildrenBounds = new List(); diff --git a/DesignTools/Operations/ArrayAdvanced3D.cs b/DesignTools/Operations/ArrayAdvanced3D.cs index a5468ccc8..630997e41 100644 --- a/DesignTools/Operations/ArrayAdvanced3D.cs +++ b/DesignTools/Operations/ArrayAdvanced3D.cs @@ -35,7 +35,7 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools.Operations { - public class ArrayAdvanced3D : Object3D, IRebuildable + public class ArrayAdvanced3D : Object3D, IPublicPropertyObject { public ArrayAdvanced3D() { diff --git a/DesignTools/Operations/ArrayLinear3D.cs b/DesignTools/Operations/ArrayLinear3D.cs index 87846bdc0..9ebbba9ae 100644 --- a/DesignTools/Operations/ArrayLinear3D.cs +++ b/DesignTools/Operations/ArrayLinear3D.cs @@ -35,7 +35,7 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools.Operations { - public class ArrayLinear3D : Object3D, IRebuildable + public class ArrayLinear3D : Object3D, IPublicPropertyObject { public ArrayLinear3D() { diff --git a/DesignTools/Operations/ArrayRadial3D.cs b/DesignTools/Operations/ArrayRadial3D.cs index be372bb0c..918bb4020 100644 --- a/DesignTools/Operations/ArrayRadial3D.cs +++ b/DesignTools/Operations/ArrayRadial3D.cs @@ -36,7 +36,7 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools.Operations { - public class ArrayRadial3D : Object3D, IRebuildable + public class ArrayRadial3D : Object3D, IPublicPropertyObject { public ArrayRadial3D() { diff --git a/DesignTools/Operations/CurveObject3D.cs b/DesignTools/Operations/CurveObject3D.cs index ba6a81660..fb61cfc6a 100644 --- a/DesignTools/Operations/CurveObject3D.cs +++ b/DesignTools/Operations/CurveObject3D.cs @@ -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); } } } \ No newline at end of file diff --git a/DesignTools/Operations/FitToBounds3D.cs b/DesignTools/Operations/FitToBounds3D.cs index 3aab9177f..4d0a72c3d 100644 --- a/DesignTools/Operations/FitToBounds3D.cs +++ b/DesignTools/Operations/FitToBounds3D.cs @@ -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; diff --git a/DesignTools/Operations/PinchEditor.cs b/DesignTools/Operations/PinchEditor.cs index 339383484..3fa2c3c06 100644 --- a/DesignTools/Operations/PinchEditor.cs +++ b/DesignTools/Operations/PinchEditor.cs @@ -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; diff --git a/DesignTools/Operations/SmoothPath.cs b/DesignTools/Operations/SmoothPath.cs index 545ab7fa9..133c9f288 100644 --- a/DesignTools/Operations/SmoothPath.cs +++ b/DesignTools/Operations/SmoothPath.cs @@ -38,7 +38,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations using Polygon = List; using Polygons = List>; - public class SmoothPath : Object3D, IRebuildable + public class SmoothPath : Object3D, IPublicPropertyObject { public Polygons PathData; diff --git a/DesignTools/Primitives/BaseObject3D.cs b/DesignTools/Primitives/BaseObject3D.cs index afae74c3a..6ec3dea00 100644 --- a/DesignTools/Primitives/BaseObject3D.cs +++ b/DesignTools/Primitives/BaseObject3D.cs @@ -43,7 +43,7 @@ namespace MatterHackers.MatterControl.DesignTools using Polygons = List>; 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; diff --git a/DesignTools/Primitives/ConeObject3D.cs b/DesignTools/Primitives/ConeObject3D.cs index 5e17236c2..1793a468d 100644 --- a/DesignTools/Primitives/ConeObject3D.cs +++ b/DesignTools/Primitives/ConeObject3D.cs @@ -40,7 +40,7 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools { [HideUpdateButtonAttribute] - public class ConeObject3D : Object3D, IRebuildable + public class ConeObject3D : Object3D, IPublicPropertyObject { public ConeObject3D() { diff --git a/DesignTools/Primitives/CubeObject3D.cs b/DesignTools/Primitives/CubeObject3D.cs index 3368f22cf..8b750ff42 100644 --- a/DesignTools/Primitives/CubeObject3D.cs +++ b/DesignTools/Primitives/CubeObject3D.cs @@ -36,7 +36,7 @@ using MatterHackers.PolygonMesh; namespace MatterHackers.MatterControl.DesignTools { [HideUpdateButtonAttribute] - public class CubeObject3D : Object3D, IRebuildable + public class CubeObject3D : Object3D, IPublicPropertyObject { public CubeObject3D() { diff --git a/DesignTools/Primitives/CylinderObject3D.cs b/DesignTools/Primitives/CylinderObject3D.cs index 5b5945549..8d24262ba 100644 --- a/DesignTools/Primitives/CylinderObject3D.cs +++ b/DesignTools/Primitives/CylinderObject3D.cs @@ -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() { diff --git a/DesignTools/Primitives/HalfCylinderObject3D.cs b/DesignTools/Primitives/HalfCylinderObject3D.cs index 9385aae1a..c51a8ba61 100644 --- a/DesignTools/Primitives/HalfCylinderObject3D.cs +++ b/DesignTools/Primitives/HalfCylinderObject3D.cs @@ -39,7 +39,7 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools { [HideUpdateButtonAttribute] - public class HalfCylinderObject3D : Object3D, IRebuildable + public class HalfCylinderObject3D : Object3D, IPublicPropertyObject { public HalfCylinderObject3D() { diff --git a/DesignTools/Primitives/HalfSphereObject3D.cs b/DesignTools/Primitives/HalfSphereObject3D.cs index cf30cd7bb..9c7bb9dd6 100644 --- a/DesignTools/Primitives/HalfSphereObject3D.cs +++ b/DesignTools/Primitives/HalfSphereObject3D.cs @@ -39,7 +39,7 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools { [HideUpdateButtonAttribute] - public class HalfSphereObject3D : Object3D, IRebuildable + public class HalfSphereObject3D : Object3D, IPublicPropertyObject { public HalfSphereObject3D() { diff --git a/DesignTools/Primitives/HalfWedgeObject3D.cs b/DesignTools/Primitives/HalfWedgeObject3D.cs index b04b0a0b4..fd1218bf8 100644 --- a/DesignTools/Primitives/HalfWedgeObject3D.cs +++ b/DesignTools/Primitives/HalfWedgeObject3D.cs @@ -39,7 +39,7 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools { [HideUpdateButtonAttribute] - public class HalfWedgeObject3D : Object3D, IRebuildable + public class HalfWedgeObject3D : Object3D, IPublicPropertyObject { public HalfWedgeObject3D() { diff --git a/DesignTools/Primitives/ImageObject3D.cs b/DesignTools/Primitives/ImageObject3D.cs index b5b908438..8141c49bb 100644 --- a/DesignTools/Primitives/ImageObject3D.cs +++ b/DesignTools/Primitives/ImageObject3D.cs @@ -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; diff --git a/DesignTools/Primitives/PyramidObject3D.cs b/DesignTools/Primitives/PyramidObject3D.cs index 0a36cf5cd..e6986906d 100644 --- a/DesignTools/Primitives/PyramidObject3D.cs +++ b/DesignTools/Primitives/PyramidObject3D.cs @@ -38,7 +38,7 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools { [HideUpdateButtonAttribute] - public class PyramidObject3D : Object3D, IRebuildable + public class PyramidObject3D : Object3D, IPublicPropertyObject { public PyramidObject3D() { diff --git a/DesignTools/Primitives/RingObject3D.cs b/DesignTools/Primitives/RingObject3D.cs index 1245a9197..343aad276 100644 --- a/DesignTools/Primitives/RingObject3D.cs +++ b/DesignTools/Primitives/RingObject3D.cs @@ -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() { diff --git a/DesignTools/Primitives/SphereObject3D.cs b/DesignTools/Primitives/SphereObject3D.cs index 40f857128..8d04a34d5 100644 --- a/DesignTools/Primitives/SphereObject3D.cs +++ b/DesignTools/Primitives/SphereObject3D.cs @@ -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() { diff --git a/DesignTools/Primitives/TextObject3D.cs b/DesignTools/Primitives/TextObject3D.cs index 5712be6a5..b77bcc149 100644 --- a/DesignTools/Primitives/TextObject3D.cs +++ b/DesignTools/Primitives/TextObject3D.cs @@ -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 { this }, new List { 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); } } } \ No newline at end of file diff --git a/DesignTools/Primitives/TorusObject3D.cs b/DesignTools/Primitives/TorusObject3D.cs index 59a4b4382..f41a62b28 100644 --- a/DesignTools/Primitives/TorusObject3D.cs +++ b/DesignTools/Primitives/TorusObject3D.cs @@ -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() { diff --git a/DesignTools/Primitives/WedgeObject3D.cs b/DesignTools/Primitives/WedgeObject3D.cs index c20bfbb33..f20869710 100644 --- a/DesignTools/Primitives/WedgeObject3D.cs +++ b/DesignTools/Primitives/WedgeObject3D.cs @@ -39,7 +39,7 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools { [HideUpdateButtonAttribute] - public class WedgeObject3D : Object3D, IRebuildable + public class WedgeObject3D : Object3D, IPublicPropertyObject { public WedgeObject3D() { diff --git a/DesignTools/PublicPropertyEditor.cs b/DesignTools/PublicPropertyEditor.cs index 31a5311da..852f0f4a7 100644 --- a/DesignTools/PublicPropertyEditor.cs +++ b/DesignTools/PublicPropertyEditor.cs @@ -80,7 +80,7 @@ namespace MatterHackers.MatterControl.DesignTools public bool Unlocked { get; } = true; - public IEnumerable SupportedTypes() => new Type[] { typeof(IRebuildable) }; + public IEnumerable 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) diff --git a/MatterControl.csproj b/MatterControl.csproj index 983e14b8b..be54b9cf3 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -82,6 +82,7 @@ + @@ -124,7 +125,6 @@ - diff --git a/PartPreviewWindow/View3D/Actions/MeshWrapperObject3D.cs b/PartPreviewWindow/View3D/Actions/MeshWrapperObject3D.cs index fcad12115..cd8031917 100644 --- a/PartPreviewWindow/View3D/Actions/MeshWrapperObject3D.cs +++ b/PartPreviewWindow/View3D/Actions/MeshWrapperObject3D.cs @@ -27,11 +27,13 @@ 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.Linq; using MatterHackers.Agg.UI; using MatterHackers.DataConverters3D; using MatterHackers.DataConverters3D.UndoCommands; +using MatterHackers.MatterControl.DesignTools.Operations; using MatterHackers.PolygonMesh; namespace MatterHackers.MatterControl.PartPreviewWindow.View3D @@ -57,7 +59,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D { child.OutputType = PrintOutputTypes.Default; } - // collapes our children into our parent + + // collapse our children into our parent base.Remove(undoBuffer); } @@ -89,9 +92,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D public static void WrapSelection(MeshWrapperObject3D meshWrapper, InteractiveScene scene) { - if (scene.HasSelection) + var selectedItem = scene.SelectedItem; + if (selectedItem != null) { - var selectedItem = scene.SelectedItem; scene.SelectedItem = null; List originalItems; @@ -130,29 +133,40 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D } }); + AddMeshWrapperToAllChildren(); + } + + private void AddMeshWrapperToAllChildren() + { // Wrap every first descendant that has a mesh foreach (var child in this.VisibleMeshes().ToList()) { - // wrap the child - child.object3D.Parent.Children.Modify((list) => + if (child.object3D.OwnerID != this.ID) { - list.Remove(child.object3D); - list.Add(new MeshWrapper(child.object3D, this.ID)); - }); + // wrap the child + child.object3D.Parent.Children.Modify((list) => + { + list.Remove(child.object3D); + list.Add(new MeshWrapper(child.object3D, this.ID)); + }); + } } } public void ResetMeshWrappers() { + // if there are not already, wrap all meshes with our id (some inner object may have changed it's meshes) + AddMeshWrapperToAllChildren(); + this.Mesh = null; var participants = this.Descendants().Where(o => o.OwnerID == this.ID).ToList(); foreach (var item in participants) { - item.Visible = true; + var firstChild = item.Children.First(); // set the mesh back to the child mesh - item.Mesh = item.Children.First().Mesh; - // and set the color back - item.Color = item.Children.First().Color; + item.Mesh = firstChild.Mesh; + // and reset the properties + firstChild.CopyProperties(firstChild); } } } diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index e89443cc4..5c85549d0 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit e89443cc472308fcbf407581d30f358c557a7394 +Subproject commit 5c85549d073d6a033a26875289a01ad26ff3909c diff --git a/TextCreator/Braille/BrailleCardObject3D.cs b/TextCreator/Braille/BrailleCardObject3D.cs index c9626d791..713657da1 100644 --- a/TextCreator/Braille/BrailleCardObject3D.cs +++ b/TextCreator/Braille/BrailleCardObject3D.cs @@ -45,7 +45,7 @@ using Newtonsoft.Json.Converters; namespace MatterHackers.MatterControl.DesignTools { [WebPageLink("About Braille", "https://en.wikipedia.org/wiki/Braille")] - public class BrailleCardObject3D : Object3D, IRebuildable + public class BrailleCardObject3D : Object3D, IPublicPropertyObject { public BrailleCardObject3D() { diff --git a/TextCreator/Braille/BrailleObject3D.cs b/TextCreator/Braille/BrailleObject3D.cs index 436c6bae5..a12a9fd40 100644 --- a/TextCreator/Braille/BrailleObject3D.cs +++ b/TextCreator/Braille/BrailleObject3D.cs @@ -45,7 +45,7 @@ using Newtonsoft.Json.Converters; namespace MatterHackers.MatterControl.DesignTools { [WebPageLink("About Braille", "https://en.wikipedia.org/wiki/Braille")] - public class BrailleObject3D : Object3D, IRebuildable + public class BrailleObject3D : Object3D, IPublicPropertyObject { public BrailleObject3D() {