Fix a bug in intersect objects

improve subtract processing
improve subtract editor rendering
clean up editor draw aip
This commit is contained in:
Lars Brubaker 2021-11-19 15:44:00 -08:00
parent dd8404644c
commit 1ccca5779a
40 changed files with 195 additions and 178 deletions

View file

@ -353,8 +353,15 @@ namespace MatterHackers.PolygonMesh
}
else
{
var preAddCount = resultsMesh.Vertices.Count;
// mesh the new polygon and add it to the resultsMesh
polygonShape.Vertices().TriangulateFaces(null, resultsMesh, 0, flattenedMatrixInverted);
// TODO: map all the added vertices that can be back to the original polygon positions
// for (int i = preAddCount; i< resultsMesh.Vertices.Count; i++)
{
}
}
if (resultsMesh.Faces.Count - faceCountPreAdd > 0)
@ -395,7 +402,7 @@ namespace MatterHackers.PolygonMesh
// check if more than one mesh has this polygons on this plan
var flattenedMatrix = CoPlanarFaces.GetFlattenedMatrix(plane);
// depending on the opperation add or remove polygons that are planar
// depending on the operation add or remove polygons that are planar
switch (operation)
{
case CsgModes.Union:

View file

@ -34,8 +34,11 @@ namespace MatterHackers.MatterControl.DesignTools
[AttributeUsage(AttributeTargets.Class)]
public class ShowUpdateButtonAttribute : Attribute
{
public ShowUpdateButtonAttribute()
public bool SuppressPropertyChangeUpdates { get; set; }
public ShowUpdateButtonAttribute(bool suppressPropertyChangeUpdates)
{
SuppressPropertyChangeUpdates = suppressPropertyChangeUpdates;
}
}
}

View file

@ -33,12 +33,15 @@ using MatterHackers.MatterControl.PartPreviewWindow;
namespace MatterHackers.MatterControl.DesignTools
{
public interface ISelectedEditorDraw
public interface IEditorDraw
{
void DrawEditor(Object3DControlsLayer object3DControlLayer, List<Object3DView> transparentMeshes, DrawEventArgs e);
void DrawEditor(Object3DControlsLayer object3DControlLayer, DrawEventArgs e);
}
public interface IAlwaysEditorDraw : ISelectedEditorDraw
public interface ICustomEditorDraw : IEditorDraw
{
void AddEditorTransparents(Object3DControlsLayer object3DControlLayer, List<Object3DView> transparentMeshes, DrawEventArgs e);
bool DoEditorDraw(bool isSelected);
}
}

View file

@ -43,7 +43,7 @@ using Newtonsoft.Json;
namespace MatterHackers.MatterControl.Plugins.Lithophane
{
[ShowUpdateButton]
[ShowUpdateButton(true)]
public class LithophaneObject3D : Object3D
{
public LithophaneObject3D()

View file

@ -53,7 +53,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools
{
[Obsolete("Use CurveObject3D_3 instead", false)]
public class CurveObject3D : MeshWrapperObject3D, ISelectedEditorDraw
public class CurveObject3D : MeshWrapperObject3D, IEditorDraw
{
// holds where we rotate the object
private Vector2 rotationCenter;
@ -77,7 +77,7 @@ namespace MatterHackers.MatterControl.DesignTools
[Description("Where to start the bend as a percent of the width of the part")]
public double StartPercent { get; set; } = 50;
public void DrawEditor(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{
if (layer.Scene.SelectedItem != null
&& layer.Scene.SelectedItem.DescendantsAndSelf().Where((i) => i == this).Any())

View file

@ -64,7 +64,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
}
[Obsolete("Not used anymore. Replaced with FitToBoundsObject3D_3", true)]
public class FitToBoundsObject3D : Object3D, ISelectedEditorDraw, IPropertyGridModifier
public class FitToBoundsObject3D : Object3D, IEditorDraw, IPropertyGridModifier
{
[Description("Set the shape the part will be fit into.")]
public FitType FitType { get; set; } = FitType.Box;
@ -268,7 +268,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
ScaleItem.Matrix = Object3DExtensions.ApplyAtPosition(ScaleItem.Matrix, aabb.Center, Matrix4X4.CreateScale(scale));
}
public void DrawEditor(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{
if (layer.Scene.SelectedItem != null
&& layer.Scene.SelectedItem.DescendantsAndSelf().Where((i) => i == this).Any())

View file

@ -42,7 +42,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools.Operations
{
public class ArrayRadialObject3D : ArrayObject3D, ISelectedEditorDraw
public class ArrayRadialObject3D : ArrayObject3D, IEditorDraw
{
public ArrayRadialObject3D()
{
@ -138,7 +138,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
});
}
public void DrawEditor(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{
layer.World.RenderDirectionAxis(Axis, this.WorldMatrix(), 30);
}

View file

@ -52,7 +52,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools
{
[Obsolete("Use CurveObject3D_3 instead", false)]
public class CurveObject3D_2 : OperationSourceContainerObject3D, ISelectedEditorDraw
public class CurveObject3D_2 : OperationSourceContainerObject3D, IEditorDraw
{
public CurveObject3D_2()
{
@ -75,7 +75,7 @@ namespace MatterHackers.MatterControl.DesignTools
[Description("Split the mesh so it has enough geometry to create a smooth curve")]
public bool SplitMesh { get; set; } = true;
public void DrawEditor(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{
var sourceAabb = this.SourceContainer.GetAxisAlignedBoundingBox();
var distance = Diameter / 2 + sourceAabb.YSize / 2;

View file

@ -46,7 +46,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools
{
public class CurveObject3D_3 : OperationSourceContainerObject3D, IPropertyGridModifier, ISelectedEditorDraw
public class CurveObject3D_3 : OperationSourceContainerObject3D, IPropertyGridModifier, IEditorDraw
{
public CurveObject3D_3()
{
@ -102,7 +102,7 @@ namespace MatterHackers.MatterControl.DesignTools
[DescriptionImage("https://lh3.googleusercontent.com/p9MyKu3AFP55PnobUKZQPqf6iAx11GzXyX-25f1ddrUnfCt8KFGd1YtHOR5HqfO0mhlX2ZVciZV4Yn0Kzfm43SErOS_xzgsESTu9scux")]
public DoubleOrExpression MinSidesPerRotation { get; set; } = 30;
public void DrawEditor(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{
var diameter = Diameter.Value(this);
var startPercent = StartPercent.Value(this);

View file

@ -49,7 +49,7 @@ using System.Threading.Tasks;
namespace MatterHackers.MatterControl.DesignTools.Operations
{
[Obsolete("Not used anymore. Replaced with FitToBoundsObject3D_3", true)]
public class FitToBoundsObject3D_2 : TransformWrapperObject3D, ISelectedEditorDraw
public class FitToBoundsObject3D_2 : TransformWrapperObject3D, IEditorDraw
{
private Vector3 boundsSize;
private InvalidateType additonalInvalidate;
@ -150,7 +150,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
return fitToBounds;
}
public void DrawEditor(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{
var aabb = UntransformedChildren.GetAxisAlignedBoundingBox();
var center = aabb.Center;

View file

@ -43,7 +43,7 @@ using System.Threading.Tasks;
namespace MatterHackers.MatterControl.DesignTools.Operations
{
public class FitToBoundsObject3D_3 : TransformWrapperObject3D, ISelectedEditorDraw
public class FitToBoundsObject3D_3 : TransformWrapperObject3D, IEditorDraw
{
private InvalidateType additonalInvalidate;
@ -111,7 +111,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
return fitToBounds;
}
public void DrawEditor(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{
var aabb = UntransformedChildren.GetAxisAlignedBoundingBox();
var center = aabb.Center;

View file

@ -49,7 +49,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools.Operations
{
public class FitToCylinderObject3D : TransformWrapperObject3D, ISelectedEditorDraw
public class FitToCylinderObject3D : TransformWrapperObject3D, IEditorDraw
{
public FitToCylinderObject3D()
{
@ -105,7 +105,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
return fitToBounds;
}
public void DrawEditor(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{
var aabb = this.WorldAxisAlignedBoundingBox();
layer.World.RenderCylinderOutline(Matrix4X4.Identity, aabb.Center, Diameter, aabb.ZSize, 90, Color.Red);

View file

@ -57,7 +57,7 @@ using Polygons = System.Collections.Generic.List<System.Collections.Generic.List
namespace MatterHackers.MatterControl.DesignTools
{
[Obsolete("Use ImageToPathObject3D_2 instead", false)]
public class ImageToPathObject3D : Object3D, IPathObject, ISelectedEditorDraw, IObject3DControlsProvider
public class ImageToPathObject3D : Object3D, IPathObject, IEditorDraw, IObject3DControlsProvider
{
private ThresholdFunctions _featureDetector = ThresholdFunctions.Silhouette;
@ -209,7 +209,7 @@ namespace MatterHackers.MatterControl.DesignTools
object3DControlsLayer.AddControls(ControlTypes.Standard2D);
}
public void DrawEditor(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{
this.DrawPath();
}

View file

@ -52,7 +52,7 @@ using Polygons = System.Collections.Generic.List<System.Collections.Generic.List
namespace MatterHackers.MatterControl.DesignTools
{
[HideMeterialAndColor]
public class ImageToPathObject3D_2 : Object3D, IImageProvider, IPathObject, ISelectedEditorDraw, IObject3DControlsProvider, IPropertyGridModifier, IEditorWidgetModifier
public class ImageToPathObject3D_2 : Object3D, IImageProvider, IPathObject, IEditorDraw, IObject3DControlsProvider, IPropertyGridModifier, IEditorWidgetModifier
{
public ImageToPathObject3D_2()
{
@ -180,7 +180,7 @@ namespace MatterHackers.MatterControl.DesignTools
object3DControlsLayer.AddControls(ControlTypes.Standard2D);
}
public void DrawEditor(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{
this.DrawPath();
}

View file

@ -37,7 +37,7 @@ using System.Collections.Generic;
namespace MatterHackers.MatterControl.DesignTools
{
public class PathObject3D : Object3D, IPathObject, ISelectedEditorDraw
public class PathObject3D : Object3D, IPathObject, IEditorDraw
{
[JsonIgnore]
private IVertexSource _vertexSource = new VertexStorage();
@ -54,7 +54,7 @@ namespace MatterHackers.MatterControl.DesignTools
}
}
public void DrawEditor(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{
this.DrawPath();
}

View file

@ -48,7 +48,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
Sharp,
}
public class InflatePathObject3D : Object3D, IPathObject, ISelectedEditorDraw, IObject3DControlsProvider
public class InflatePathObject3D : Object3D, IPathObject, IEditorDraw, IObject3DControlsProvider
{
public IVertexSource VertexSource { get; set; } = new VertexStorage();
@ -135,7 +135,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
return joinType;
}
public void DrawEditor(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{
this.DrawPath();
}

View file

@ -42,7 +42,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools.Operations
{
public class MergePathObject3D : OperationSourceContainerObject3D, IPathObject, ISelectedEditorDraw, IObject3DControlsProvider
public class MergePathObject3D : OperationSourceContainerObject3D, IPathObject, IEditorDraw, IObject3DControlsProvider
{
private ClipperLib.ClipType clipType;
private string operationName;
@ -56,7 +56,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
public IVertexSource VertexSource { get; set; } = new VertexStorage();
public void DrawEditor(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{
this.DrawPath();
}

View file

@ -43,7 +43,7 @@ using MatterHackers.MatterControl.PartPreviewWindow;
namespace MatterHackers.MatterControl.DesignTools.Operations
{
public class OutlinePathObject3D : Object3D, IPathObject, ISelectedEditorDraw, IObject3DControlsProvider
public class OutlinePathObject3D : Object3D, IPathObject, IEditorDraw, IObject3DControlsProvider
{
public IVertexSource VertexSource { get; set; } = new VertexStorage();
@ -152,7 +152,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
(VertexSource as VertexStorage).Add(0, 0, ShapePath.FlagsAndCommand.Stop);
}
public void DrawEditor(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{
this.DrawPath();
}

View file

@ -46,7 +46,7 @@ using Newtonsoft.Json;
namespace MatterHackers.MatterControl.DesignTools.Operations
{
public class RevolveObject3D : Object3D, ISelectedEditorDraw
public class RevolveObject3D : Object3D, IEditorDraw
{
[MaxDecimalPlaces(2)]
public DoubleOrExpression AxisPosition { get; set; } = 0;
@ -130,7 +130,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
}
}
public void DrawEditor(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{
var child = this.Children.FirstOrDefault();
if (child is IPathObject pathObject)

View file

@ -43,7 +43,7 @@ using Polygons = System.Collections.Generic.List<System.Collections.Generic.List
namespace MatterHackers.MatterControl.DesignTools.Operations
{
public class SmoothPathObject3D : Object3D, IPathObject, ISelectedEditorDraw, IObject3DControlsProvider
public class SmoothPathObject3D : Object3D, IPathObject, IEditorDraw, IObject3DControlsProvider
{
public IVertexSource VertexSource { get; set; } = new VertexStorage();
@ -177,7 +177,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
VertexSource = outputPolygons.CreateVertexStorage();
}
public void DrawEditor(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{
this.DrawPath();
}

View file

@ -42,7 +42,7 @@ using Newtonsoft.Json;
namespace MatterHackers.MatterControl.DesignTools.Operations
{
public class RotateObject3D_2 : TransformWrapperObject3D, ISelectedEditorDraw
public class RotateObject3D_2 : TransformWrapperObject3D, IEditorDraw
{
public RotateObject3D_2()
{
@ -111,7 +111,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
}
}
public void DrawEditor(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{
if (layer.Scene.SelectedItem != null
&& layer.Scene.SelectedItem.DescendantsAndSelf().Where((i) => i == this).Any())

View file

@ -48,7 +48,7 @@ using Newtonsoft.Json;
namespace MatterHackers.MatterControl.DesignTools.Operations
{
[Obsolete("Use ScaleObject3D_3 instead", false)]
public class ScaleObject3D : TransformWrapperObject3D, ISelectedEditorDraw, IPropertyGridModifier
public class ScaleObject3D : TransformWrapperObject3D, IEditorDraw, IPropertyGridModifier
{
public enum ScaleType
{
@ -199,7 +199,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
[Description("This is the position to perform the scale about.")]
public Vector3 ScaleAbout { get; set; }
public void DrawEditor(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{
if (layer.Scene.SelectedItem != null
&& layer.Scene.SelectedItem.DescendantsAndSelf().Where((i) => i == this).Any())

View file

@ -48,7 +48,7 @@ using Newtonsoft.Json;
namespace MatterHackers.MatterControl.DesignTools
{
public class TwistObject3D : OperationSourceContainerObject3D, IPropertyGridModifier, ISelectedEditorDraw
public class TwistObject3D : OperationSourceContainerObject3D, IPropertyGridModifier, IEditorDraw
{
public TwistObject3D()
{
@ -129,7 +129,7 @@ namespace MatterHackers.MatterControl.DesignTools
}
}
public void DrawEditor(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{
var sourceAabb = this.SourceContainer.GetAxisAlignedBoundingBox();
var rotationCenter = SourceContainer.GetSmallestEnclosingCircleAlongZ().Center + RotationOffset;

View file

@ -59,7 +59,7 @@ namespace MatterHackers.MatterControl.DesignTools
Outline
}
public class BaseObject3D : Object3D, IPropertyGridModifier, ISelectedEditorDraw
public class BaseObject3D : Object3D, IPropertyGridModifier, IEditorDraw
{
public enum CenteringTypes
{
@ -454,7 +454,7 @@ namespace MatterHackers.MatterControl.DesignTools
}
}
public void DrawEditor(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{
if (OutlineIsFromMesh)
{

View file

@ -41,7 +41,7 @@ using Newtonsoft.Json;
namespace MatterHackers.MatterControl.DesignTools
{
public class BoxPathObject3D : PrimitiveObject3D, IPathObject, IObject3DControlsProvider, ISelectedEditorDraw
public class BoxPathObject3D : PrimitiveObject3D, IPathObject, IObject3DControlsProvider, IEditorDraw
{
public BoxPathObject3D()
{
@ -66,7 +66,7 @@ namespace MatterHackers.MatterControl.DesignTools
}
}
public void DrawEditor(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{
this.DrawPath();
}

View file

@ -51,7 +51,7 @@ namespace MatterHackers.MatterControl.DesignTools
[HideMeterialAndColor]
[WebPageLink("Resources", "Markdown Help", "https://guides.github.com/features/mastering-markdown/")]
[MarkDownDescription("Used to add description within then scene. The object on the bed will not print.")]
public class DescriptionObject3D : Object3D, IObject3DControlsProvider, IAlwaysEditorDraw, IEditorButtonProvider
public class DescriptionObject3D : Object3D, IObject3DControlsProvider, ICustomEditorDraw, IEditorButtonProvider
{
private MarkdownWidget markdownWidget;
private Object3DControlsLayer controlLayer;
@ -104,6 +104,9 @@ namespace MatterHackers.MatterControl.DesignTools
}
}
public bool DoEditorDraw(bool isSelected) => true;
[HideFromEditor]
public Vector3 LocalPosition { get; set; }
@ -239,7 +242,9 @@ namespace MatterHackers.MatterControl.DesignTools
}
}
public void DrawEditor(Object3DControlsLayer controlLayer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void AddEditorTransparents(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e) { }
public void DrawEditor(Object3DControlsLayer controlLayer, DrawEventArgs e)
{
EnsureTracedPositionControl(controlLayer);

View file

@ -49,7 +49,7 @@ namespace MatterHackers.MatterControl.DesignTools
{
[MarkDownDescription("Drag the spheres to the locations you would like to measure the distance between. The object on the bed will not print.")]
[HideMeterialAndColor]
public class MeasureToolObject3D : Object3D, IObject3DControlsProvider, IAlwaysEditorDraw, IEditorButtonProvider
public class MeasureToolObject3D : Object3D, IObject3DControlsProvider, ICustomEditorDraw, IEditorButtonProvider
{
private static Mesh shape = null;
private List<IObject3DControl> editorControls = null;
@ -80,6 +80,8 @@ namespace MatterHackers.MatterControl.DesignTools
return item;
}
public bool DoEditorDraw(bool isSelected) => true;
[HideFromEditor]
private Vector3 worldStartPosition
{
@ -226,7 +228,9 @@ namespace MatterHackers.MatterControl.DesignTools
return Task.CompletedTask;
}
public void DrawEditor(Object3DControlsLayer controlLayer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void AddEditorTransparents(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e) { }
public void DrawEditor(Object3DControlsLayer controlLayer, DrawEventArgs e)
{
if (!PositionsHaveBeenSet)
{

View file

@ -42,7 +42,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools
{
public class SetTemperatureObject3D : Object3D, IObject3DControlsProvider, IGCodeTransformer, ISelectedEditorDraw
public class SetTemperatureObject3D : Object3D, IObject3DControlsProvider, IGCodeTransformer, IEditorDraw
{
private bool hasBeenReached;
private double accumulatedLayerHeight;
@ -136,7 +136,7 @@ namespace MatterHackers.MatterControl.DesignTools
accumulatedLayerHeight = 0;
}
public void DrawEditor(Object3DControlsLayer object3DControlLayer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void DrawEditor(Object3DControlsLayer object3DControlLayer, DrawEventArgs e)
{
if (displayInfo.temp == double.MinValue
|| displayInfo.temp != Temperature

View file

@ -47,7 +47,7 @@ using Newtonsoft.Json.Converters;
namespace MatterHackers.MatterControl.DesignTools
{
public class TextPathObject3D : Object3D, IPathObject, ISelectedEditorDraw
public class TextPathObject3D : Object3D, IPathObject, IEditorDraw
{
public TextPathObject3D()
{
@ -193,7 +193,7 @@ namespace MatterHackers.MatterControl.DesignTools
return null;
}
public void DrawEditor(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{
this.DrawPath();
}

View file

@ -585,7 +585,9 @@ namespace MatterHackers.MatterControl.DesignTools
if (property.Item is OperationSourceContainerObject3D sourceContainer)
{
Action selected = null;
if (!(localItem.GetType().GetCustomAttributes(typeof(ShowUpdateButtonAttribute), true).FirstOrDefault() is ShowUpdateButtonAttribute showUpdate))
var showUpdate = localItem.GetType().GetCustomAttributes(typeof(ShowUpdateButtonAttribute), true).FirstOrDefault() as ShowUpdateButtonAttribute;
if (showUpdate == null
|| !showUpdate.SuppressPropertyChangeUpdates)
{
selected = () =>
{

View file

@ -43,6 +43,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
{
[ShowUpdateButton(false)]
public class CombineObject3D_2 : OperationSourceContainerObject3D, IPropertyGridModifier
{
public CombineObject3D_2()

View file

@ -42,6 +42,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
{
[ShowUpdateButton(false)]
public class IntersectionObject3D_2 : OperationSourceContainerObject3D, IPropertyGridModifier
{
public IntersectionObject3D_2()
@ -124,6 +125,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
}
var items = participants.Select(i => (i.Mesh, i.WorldMatrix(SourceContainer)));
#if false
var resultsMesh = BooleanProcessing.DoArray(items,
BooleanProcessing.CsgModes.Intersect,
Processing,
@ -131,6 +133,51 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
OutputResolution,
reporter,
cancellationToken);
#else
var totalOperations = items.Count() - 1;
double amountPerOperation = 1.0 / totalOperations;
double percentCompleted = 0;
var progressStatus = new ProgressStatus();
var resultsMesh = items.First().Item1;
var keepWorldMatrix = items.First().Item2;
bool first = true;
foreach (var next in items)
{
if (first)
{
first = false;
continue;
}
resultsMesh = BooleanProcessing.Do(resultsMesh,
keepWorldMatrix,
// other mesh
next.Item1,
next.Item2,
// operation type
BooleanProcessing.CsgModes.Intersect,
Processing,
InputResolution,
OutputResolution,
// reporting
reporter,
amountPerOperation,
percentCompleted,
progressStatus,
cancellationToken);
// after the first time we get a result the results mesh is in the right coordinate space
keepWorldMatrix = Matrix4X4.Identity;
// report our progress
percentCompleted += amountPerOperation;
progressStatus.Progress0To1 = percentCompleted;
reporter?.Report(progressStatus);
}
#endif
if (resultsMesh != null)
{

View file

@ -48,7 +48,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
{
[Obsolete("Use SubtractAndReplaceObject3D_2 instead", false)]
[ShowUpdateButton]
[ShowUpdateButton(true)]
public class SubtractAndReplaceObject3D : MeshWrapperObject3D, ISelectableChildContainer
{
public SubtractAndReplaceObject3D()

View file

@ -45,14 +45,19 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
{
[ShowUpdateButton]
public class SubtractAndReplaceObject3D_2 : OperationSourceContainerObject3D, ISelectableChildContainer, ISelectedEditorDraw, IPropertyGridModifier
[ShowUpdateButton(false)]
public class SubtractAndReplaceObject3D_2 : OperationSourceContainerObject3D, ISelectableChildContainer, ICustomEditorDraw, IPropertyGridModifier
{
public SubtractAndReplaceObject3D_2()
{
Name = "Subtract and Replace";
}
public bool DoEditorDraw(bool isSelected)
{
return isSelected;
}
[HideFromEditor]
public SelectedChildren ComputedChildren { get; set; } = new SelectedChildren();
@ -77,89 +82,30 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
private BooleanProcessing.ProcessingResolution InputResolution { get; set; } = BooleanProcessing.ProcessingResolution._64;
#endif
public void DrawEditor(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void AddEditorTransparents(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
{
var parentOfSourceItems = this.SourceContainer.DescendantsAndSelfMultipleChildrenFirstOrSelf();
if (layer.Scene.SelectedItem != null
&& layer.Scene.SelectedItem == this)
{
var parentOfSubtractTargets = this.SourceContainer.DescendantsAndSelfMultipleChildrenFirstOrSelf();
var sourceItems = parentOfSourceItems.Children.ToList();
var removeObjects = parentOfSubtractTargets.Children
.Where(i => SelectedChildren.Contains(i.ID))
.SelectMany(c => c.VisibleMeshes())
.ToList();
foreach (var paintItem in sourceItems)
foreach (var item in removeObjects)
{
var paintItemResults = this.Children.Where(i => i.OwnerID == paintItem.ID);
var wasSelected = ComputedChildren.Contains(paintItem.ID);
var currentlySelected = SelectedChildren.Contains(paintItem.ID);
if (currentlySelected)
{
// if this is selected always paint a transparent source
foreach (var item in paintItem.VisibleMeshes())
{
transparentMeshes.Add(new Object3DView(item, new Color(item.WorldColor(this.SourceContainer), 80)));
var color = item.WorldColor(checkOutputType: true);
transparentMeshes.Add(new Object3DView(item, color.WithAlpha(color.Alpha0To1 * .2)));
}
// if it was also selected in before (the results are right)
if (wasSelected)
}
}
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{
// paint solid results
if (paintItemResults != null)
{
foreach (var paintItemResult in paintItemResults)
{
foreach (var item in paintItemResult.VisibleMeshes())
{
GLHelper.Render(item.Mesh,
item.WorldColor(),
item.WorldMatrix(),
RenderTypes.Outlines,
item.WorldMatrix() * layer.World.ModelviewMatrix);
}
}
}
}
}
else if (wasSelected)
{
// it is not selected now but was selected before (changed state)
// pant the solid source
foreach (var item in paintItem.VisibleMeshes())
{
GLHelper.Render(item.Mesh,
item.WorldColor(),
item.WorldMatrix(),
RenderTypes.Outlines,
item.WorldMatrix() * layer.World.ModelviewMatrix);
}
}
else // it is not selected now and was not before (same state)
{
// paint the results
if (paintItemResults != null && paintItemResults.Count() > 0)
{
foreach (var paintItemResult in paintItemResults)
{
foreach (var item in paintItemResult.VisibleMeshes())
{
GLHelper.Render(item.Mesh,
item.WorldColor(),
item.WorldMatrix(),
RenderTypes.Outlines,
item.WorldMatrix() * layer.World.ModelviewMatrix);
}
}
}
else // we don't have any results yet
{
foreach (var item in paintItem.VisibleMeshes())
{
GLHelper.Render(item.Mesh,
item.WorldColor(),
item.WorldMatrix(),
RenderTypes.Outlines,
item.WorldMatrix() * layer.World.ModelviewMatrix);
}
}
}
}
return;
}
public override async void OnInvalidate(InvalidateArgs invalidateType)

View file

@ -46,7 +46,7 @@ using MatterHackers.PolygonMesh;
namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
{
[Obsolete("Use SubtractObject3D_2 instead", false)]
[ShowUpdateButton]
[ShowUpdateButton(true)]
public class SubtractObject3D : MeshWrapperObject3D, ISelectableChildContainer
{
public SubtractObject3D()

View file

@ -45,8 +45,8 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
{
[ShowUpdateButton]
public class SubtractObject3D_2 : OperationSourceContainerObject3D, ISelectableChildContainer, ISelectedEditorDraw, IPropertyGridModifier
[ShowUpdateButton(false)]
public class SubtractObject3D_2 : OperationSourceContainerObject3D, ISelectableChildContainer, ICustomEditorDraw, IPropertyGridModifier
{
public SubtractObject3D_2()
{
@ -76,7 +76,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
public bool RemoveSubtractObjects { get; set; } = true;
public void DrawEditor(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public bool DoEditorDraw(bool isSelected)
{
return isSelected;
}
public void AddEditorTransparents(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
{
if (layer.Scene.SelectedItem != null
&& layer.Scene.SelectedItem == this)
@ -90,30 +95,16 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
foreach (var item in removeObjects)
{
transparentMeshes.Add(new Object3DView(item, new Color(item.WorldColor(this.SourceContainer), 80)));
var color = item.WorldColor(checkOutputType: true);
transparentMeshes.Add(new Object3DView(item, color.WithAlpha(color.Alpha0To1 * .2)));
}
var keepItems = parentOfSubtractTargets.Children
.Where(i => !SelectedChildren.Contains(i.ID))
.ToList();
}
}
foreach (var keepItem in keepItems)
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{
var drawItem = keepItem;
var keepItemResult = this.Children.Where(i => i.OwnerID == keepItem.ID).FirstOrDefault();
drawItem = keepItemResult != null ? keepItemResult : drawItem;
foreach (var item in drawItem.VisibleMeshes())
{
GLHelper.Render(item.Mesh,
item.WorldColor(),
item.WorldMatrix(),
RenderTypes.Outlines,
item.WorldMatrix() * layer.World.ModelviewMatrix);
}
}
}
return;
}
public override async void OnInvalidate(InvalidateArgs invalidateArgs)

View file

@ -46,7 +46,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
{
public class SubtractPathObject3D : OperationSourceContainerObject3D, IPathObject, ISelectedEditorDraw, IObject3DControlsProvider
public class SubtractPathObject3D : OperationSourceContainerObject3D, IPathObject, IEditorDraw, IObject3DControlsProvider
{
public SubtractPathObject3D()
{
@ -58,7 +58,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
public IVertexSource VertexSource { get; set; } = new VertexStorage();
public void DrawEditor(Object3DControlsLayer layer, List<Object3DView> transparentMeshes, DrawEventArgs e)
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{
this.DrawPath();
}

View file

@ -897,14 +897,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
private Color GetItemColor(IObject3D item, IObject3D selectedItem)
{
Color drawColor = item.WorldColor();
if (item.WorldOutputType() == PrintOutputTypes.Support)
var drawColor = item.WorldColor();
var drawColorWithOutputType = item.WorldColor(checkOutputType: true);
if (drawColor != drawColorWithOutputType)
{
drawColor = new Color(Color.Yellow, 120);
}
else if (item.WorldOutputType() == PrintOutputTypes.WipeTower)
{
drawColor = new Color(Color.Cyan, 120);
// color bering set by output type
drawColor = drawColorWithOutputType;
}
else if (sceneContext.ViewState.RenderType == RenderTypes.Materials)
{
@ -1079,7 +1077,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
}
}
foreach (var item in scene.Descendants().Where(i => i is IAlwaysEditorDraw))
foreach (var item in scene.Descendants().Where(i => i is ICustomEditorDraw customEditorDraw1 && customEditorDraw1.DoEditorDraw(i == selectedItem)))
{
editorDrawItems.Add(item);
}
@ -1138,6 +1136,16 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
break;
}
// Add transparent draws to the editor
foreach (var item in editorDrawItems)
{
// Invoke existing IEditorDraw when iterating items
if (item is ICustomEditorDraw cutomEditorDraw)
{
cutomEditorDraw.AddEditorTransparents(this, transparentMeshes, e);
}
}
// Draw transparent objects
foreach (var item in transparentMeshes)
{
@ -1163,9 +1171,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
foreach (var item in editorDrawItems)
{
// Invoke existing IEditorDraw when iterating items
if (item is ISelectedEditorDraw editorDraw)
if (item is IEditorDraw editorDraw)
{
editorDraw.DrawEditor(this, transparentMeshes, e);
editorDraw.DrawEditor(this, e);
}
}

@ -1 +1 @@
Subproject commit f010c985ba1978c5b769fc2f8fe8e0766f79838f
Subproject commit d06b8eb8d323ae2c978299a7d665e13cd6cc3833

@ -1 +1 @@
Subproject commit 628760e12e9a38dce1d8ae6d8b3a4860dad22320
Subproject commit edc43b496910736bb4b0925ef6f9d865500ec0c4