Improving path coordinates
This commit is contained in:
parent
07b16a2047
commit
cf608735bc
10 changed files with 85 additions and 75 deletions
|
|
@ -100,7 +100,7 @@ namespace MatterHackers.MatterControl
|
||||||
// this is for when base is working with generic meshes
|
// this is for when base is working with generic meshes
|
||||||
//IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && !(sceneContext.Scene.SelectedItem.IsPathObject()),
|
//IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && !(sceneContext.Scene.SelectedItem.IsPathObject()),
|
||||||
// this is for when only IPathObjects are working correctly
|
// this is for when only IPathObjects are working correctly
|
||||||
IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && sceneContext.Scene.SelectedItem.DescendantsAndSelf().Where(i => i is IPathObject3D).Any(),
|
IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && sceneContext.Scene.SelectedItem.DescendantsAndSelf().Where(i => i is IPathProvider).Any(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -391,7 +391,7 @@ namespace MatterHackers.MatterControl
|
||||||
},
|
},
|
||||||
Icon = (theme) => StaticData.Instance.LoadIcon("inflate_path.png", 16, 16).GrayToColor(theme.TextColor).SetPreMultiply(),
|
Icon = (theme) => StaticData.Instance.LoadIcon("inflate_path.png", 16, 16).GrayToColor(theme.TextColor).SetPreMultiply(),
|
||||||
HelpTextGetter = () => "A path must be selected".Localize().Stars(),
|
HelpTextGetter = () => "A path must be selected".Localize().Stars(),
|
||||||
IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && sceneContext.Scene.SelectedItem is IPathObject3D,
|
IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && sceneContext.Scene.SelectedItem is IPathProvider,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -405,15 +405,13 @@ namespace MatterHackers.MatterControl
|
||||||
{
|
{
|
||||||
var scene = sceneContext.Scene;
|
var scene = sceneContext.Scene;
|
||||||
var sceneItem = scene.SelectedItem;
|
var sceneItem = scene.SelectedItem;
|
||||||
var pathObject = sceneItem as IPathObject3D;
|
var pathObject = sceneItem as IPathProvider;
|
||||||
if (pathObject != null)
|
if (pathObject != null)
|
||||||
{
|
{
|
||||||
var extrude = new LinearExtrudeObject3D();
|
var extrude = new LinearExtrudeObject3D();
|
||||||
|
|
||||||
var itemClone = sceneItem.Clone();
|
var itemClone = sceneItem.Clone();
|
||||||
extrude.Children.Add(itemClone);
|
extrude.Children.Add(itemClone);
|
||||||
extrude.Matrix = itemClone.Matrix;
|
|
||||||
itemClone.Matrix = Matrix4X4.Identity;
|
|
||||||
|
|
||||||
scene.SelectedItem = null;
|
scene.SelectedItem = null;
|
||||||
scene.UndoBuffer.AddAndDo(new ReplaceCommand(new[] { sceneItem }, new[] { extrude }));
|
scene.UndoBuffer.AddAndDo(new ReplaceCommand(new[] { sceneItem }, new[] { extrude }));
|
||||||
|
|
@ -424,7 +422,7 @@ namespace MatterHackers.MatterControl
|
||||||
},
|
},
|
||||||
Icon = (theme) => StaticData.Instance.LoadIcon("linear_extrude.png", 16, 16).GrayToColor(theme.TextColor).SetPreMultiply(),
|
Icon = (theme) => StaticData.Instance.LoadIcon("linear_extrude.png", 16, 16).GrayToColor(theme.TextColor).SetPreMultiply(),
|
||||||
HelpTextGetter = () => "A path must be selected".Localize().Stars(),
|
HelpTextGetter = () => "A path must be selected".Localize().Stars(),
|
||||||
IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && sceneContext.Scene.SelectedItem is IPathObject3D,
|
IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && sceneContext.Scene.SelectedItem is IPathProvider,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -438,7 +436,7 @@ namespace MatterHackers.MatterControl
|
||||||
{
|
{
|
||||||
var scene = sceneContext.Scene;
|
var scene = sceneContext.Scene;
|
||||||
var sceneItem = scene.SelectedItem;
|
var sceneItem = scene.SelectedItem;
|
||||||
var pathObject = sceneItem as IPathObject3D;
|
var pathObject = sceneItem as IPathProvider;
|
||||||
if (pathObject != null)
|
if (pathObject != null)
|
||||||
{
|
{
|
||||||
var revolve = new RevolveObject3D();
|
var revolve = new RevolveObject3D();
|
||||||
|
|
@ -457,7 +455,7 @@ namespace MatterHackers.MatterControl
|
||||||
},
|
},
|
||||||
Icon = (theme) => StaticData.Instance.LoadIcon("revolve.png", 16, 16).GrayToColor(theme.TextColor).SetPreMultiply(),
|
Icon = (theme) => StaticData.Instance.LoadIcon("revolve.png", 16, 16).GrayToColor(theme.TextColor).SetPreMultiply(),
|
||||||
HelpTextGetter = () => "A path must be selected".Localize().Stars(),
|
HelpTextGetter = () => "A path must be selected".Localize().Stars(),
|
||||||
IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && sceneContext.Scene.SelectedItem is IPathObject3D,
|
IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && sceneContext.Scene.SelectedItem is IPathProvider,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -549,7 +547,7 @@ namespace MatterHackers.MatterControl
|
||||||
},
|
},
|
||||||
Icon = (theme) => StaticData.Instance.LoadIcon("outline.png", 16, 16).GrayToColor(theme.TextColor).SetPreMultiply(),
|
Icon = (theme) => StaticData.Instance.LoadIcon("outline.png", 16, 16).GrayToColor(theme.TextColor).SetPreMultiply(),
|
||||||
HelpTextGetter = () => "A path must be selected".Localize().Stars(),
|
HelpTextGetter = () => "A path must be selected".Localize().Stars(),
|
||||||
IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && sceneContext.Scene.SelectedItem is IPathObject3D,
|
IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && sceneContext.Scene.SelectedItem is IPathProvider,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -609,7 +607,7 @@ namespace MatterHackers.MatterControl
|
||||||
},
|
},
|
||||||
Icon = (theme) => StaticData.Instance.LoadIcon("smooth_path.png", 16, 16).GrayToColor(theme.TextColor).SetPreMultiply(),
|
Icon = (theme) => StaticData.Instance.LoadIcon("smooth_path.png", 16, 16).GrayToColor(theme.TextColor).SetPreMultiply(),
|
||||||
HelpTextGetter = () => "A path must be selected".Localize().Stars(),
|
HelpTextGetter = () => "A path must be selected".Localize().Stars(),
|
||||||
IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && sceneContext.Scene.SelectedItem is IPathObject3D,
|
IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && sceneContext.Scene.SelectedItem is IPathProvider,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -702,7 +700,7 @@ namespace MatterHackers.MatterControl
|
||||||
// all are path items
|
// all are path items
|
||||||
if (includePaths
|
if (includePaths
|
||||||
&& selectedItem.VisibleMeshes().Count() > 1
|
&& selectedItem.VisibleMeshes().Count() > 1
|
||||||
&& selectedItem.VisibleMeshes().All(i => i is IPathObject3D))
|
&& selectedItem.VisibleMeshes().All(i => i is IPathProvider))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -888,7 +886,7 @@ namespace MatterHackers.MatterControl
|
||||||
TitleGetter = () => "Combine".Localize(),
|
TitleGetter = () => "Combine".Localize(),
|
||||||
Action = (sceneContext) =>
|
Action = (sceneContext) =>
|
||||||
{
|
{
|
||||||
if (sceneContext.Scene.SelectedItem.VisibleMeshes().All(o => o is IPathObject3D))
|
if (sceneContext.Scene.SelectedItem.VisibleMeshes().All(o => o is IPathProvider))
|
||||||
{
|
{
|
||||||
new MergePathObject3D("Combine".Localize(), ClipperLib.ClipType.ctUnion).WrapSelectedItemAndSelect(sceneContext.Scene);
|
new MergePathObject3D("Combine".Localize(), ClipperLib.ClipType.ctUnion).WrapSelectedItemAndSelect(sceneContext.Scene);
|
||||||
}
|
}
|
||||||
|
|
@ -1055,7 +1053,7 @@ namespace MatterHackers.MatterControl
|
||||||
TitleGetter = () => "Intersect".Localize(),
|
TitleGetter = () => "Intersect".Localize(),
|
||||||
Action = (sceneContext) =>
|
Action = (sceneContext) =>
|
||||||
{
|
{
|
||||||
if (sceneContext.Scene.SelectedItem.VisibleMeshes().All(o => o is IPathObject3D))
|
if (sceneContext.Scene.SelectedItem.VisibleMeshes().All(o => o is IPathProvider))
|
||||||
{
|
{
|
||||||
new MergePathObject3D("Intersect".Localize(), ClipperLib.ClipType.ctIntersection).WrapSelectedItemAndSelect(sceneContext.Scene);
|
new MergePathObject3D("Intersect".Localize(), ClipperLib.ClipType.ctIntersection).WrapSelectedItemAndSelect(sceneContext.Scene);
|
||||||
}
|
}
|
||||||
|
|
@ -1079,7 +1077,7 @@ namespace MatterHackers.MatterControl
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item is IPathObject3D pathObject)
|
if (item is IPathProvider pathObject)
|
||||||
{
|
{
|
||||||
return pathObject.MeshIsSolidObject;
|
return pathObject.MeshIsSolidObject;
|
||||||
}
|
}
|
||||||
|
|
@ -1339,7 +1337,7 @@ namespace MatterHackers.MatterControl
|
||||||
TitleGetter = () => "Subtract".Localize(),
|
TitleGetter = () => "Subtract".Localize(),
|
||||||
Action = (sceneContext) =>
|
Action = (sceneContext) =>
|
||||||
{
|
{
|
||||||
if (sceneContext.Scene.SelectedItem.VisibleMeshes().All(o => o is IPathObject3D))
|
if (sceneContext.Scene.SelectedItem.VisibleMeshes().All(o => o is IPathProvider))
|
||||||
{
|
{
|
||||||
new SubtractPathObject3D().WrapSelectedItemAndSelect(sceneContext.Scene);
|
new SubtractPathObject3D().WrapSelectedItemAndSelect(sceneContext.Scene);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ using Polygons = System.Collections.Generic.List<System.Collections.Generic.List
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl.DesignTools
|
namespace MatterHackers.MatterControl.DesignTools
|
||||||
{
|
{
|
||||||
public class FindSliceObject3D : OperationSourceContainerObject3D, IPropertyGridModifier, IPathObject3D
|
public class FindSliceObject3D : OperationSourceContainerObject3D, IPropertyGridModifier, IPathProvider
|
||||||
{
|
{
|
||||||
public FindSliceObject3D()
|
public FindSliceObject3D()
|
||||||
{
|
{
|
||||||
|
|
@ -87,7 +87,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
{
|
{
|
||||||
var newPathObject = new CustomPathObject3D();
|
var newPathObject = new CustomPathObject3D();
|
||||||
|
|
||||||
var vertexStorage = new VertexStorage(this.GetVertexSource());
|
var vertexStorage = new VertexStorage(this.GetRawPath());
|
||||||
newPathObject.PathForEditing.SvgDString = vertexStorage.SvgDString;
|
newPathObject.PathForEditing.SvgDString = vertexStorage.SvgDString;
|
||||||
newPathObject.Rebuild();
|
newPathObject.Rebuild();
|
||||||
|
|
||||||
|
|
@ -198,7 +198,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public IVertexSource GetVertexSource()
|
public IVertexSource GetRawPath()
|
||||||
{
|
{
|
||||||
return VertexStorage;
|
return VertexStorage;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -184,14 +184,14 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
|
|
||||||
public static void FlattenToPathObject(this IObject3D item, UndoBuffer undoBuffer)
|
public static void FlattenToPathObject(this IObject3D item, UndoBuffer undoBuffer)
|
||||||
{
|
{
|
||||||
var pathItem = item as IPathObject3D;
|
var pathItem = item as IPathProvider;
|
||||||
if (pathItem?.GetVertexSource() != null)
|
if (pathItem?.GetRawPath() != null)
|
||||||
{
|
{
|
||||||
using (item.RebuildLock())
|
using (item.RebuildLock())
|
||||||
{
|
{
|
||||||
var newPathObject = new CustomPathObject3D();
|
var newPathObject = new CustomPathObject3D();
|
||||||
|
|
||||||
var vertexStorage = new VertexStorage(pathItem.GetVertexSource());
|
var vertexStorage = new VertexStorage(pathItem.GetRawPath());
|
||||||
newPathObject.PathForEditing.SvgDString = vertexStorage.SvgDString;
|
newPathObject.PathForEditing.SvgDString = vertexStorage.SvgDString;
|
||||||
|
|
||||||
newPathObject.CopyProperties(item, Object3DPropertyFlags.All);
|
newPathObject.CopyProperties(item, Object3DPropertyFlags.All);
|
||||||
|
|
@ -216,15 +216,15 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
|
|
||||||
public static void DrawPath(this IObject3D item)
|
public static void DrawPath(this IObject3D item)
|
||||||
{
|
{
|
||||||
var pathItem = item as IPathObject3D;
|
var pathItem = item as IPathProvider;
|
||||||
if (pathItem?.GetVertexSource() != null)
|
if (pathItem?.GetRawPath() != null)
|
||||||
{
|
{
|
||||||
bool first = true;
|
bool first = true;
|
||||||
var lastPosition = Vector2.Zero;
|
var lastPosition = Vector2.Zero;
|
||||||
var maxXYZ = item.GetAxisAlignedBoundingBox().MaxXYZ;
|
var maxXYZ = item.GetAxisAlignedBoundingBox().MaxXYZ;
|
||||||
maxXYZ = maxXYZ.Transform(item.Matrix.Inverted);
|
maxXYZ = maxXYZ.Transform(item.Matrix.Inverted);
|
||||||
var firstMove = Vector2.Zero;
|
var firstMove = Vector2.Zero;
|
||||||
foreach (var vertex in pathItem.GetVertexSource().Vertices())
|
foreach (var vertex in pathItem.GetRawPath().Vertices())
|
||||||
{
|
{
|
||||||
var position = vertex.Position;
|
var position = vertex.Position;
|
||||||
if (first)
|
if (first)
|
||||||
|
|
@ -273,15 +273,15 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
{
|
{
|
||||||
AxisAlignedBoundingBox box = AxisAlignedBoundingBox.Empty();
|
AxisAlignedBoundingBox box = AxisAlignedBoundingBox.Empty();
|
||||||
|
|
||||||
var pathItem = item as IPathObject3D;
|
var pathItem = item as IPathProvider;
|
||||||
|
|
||||||
if (pathItem?.GetVertexSource() != null)
|
if (pathItem?.GetRawPath() != null)
|
||||||
{
|
{
|
||||||
var lastPosition = Vector2.Zero;
|
var lastPosition = Vector2.Zero;
|
||||||
var maxXYZ = item.GetAxisAlignedBoundingBox().MaxXYZ;
|
var maxXYZ = item.GetAxisAlignedBoundingBox().MaxXYZ;
|
||||||
maxXYZ = maxXYZ.Transform(item.Matrix.Inverted);
|
maxXYZ = maxXYZ.Transform(item.Matrix.Inverted);
|
||||||
|
|
||||||
foreach (var vertex in pathItem.GetVertexSource().Vertices())
|
foreach (var vertex in pathItem.GetRawPath().Vertices())
|
||||||
{
|
{
|
||||||
var position = vertex.Position;
|
var position = vertex.Position;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ using MatterHackers.VectorMath;
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl.DesignTools.Primitives
|
namespace MatterHackers.MatterControl.DesignTools.Primitives
|
||||||
{
|
{
|
||||||
public class CustomPathObject3D : Object3D, IEditorDraw, IStaticThumbnail, IPathObject3D, IPrimaryOperationsSpecifier
|
public class CustomPathObject3D : Object3D, IEditorDraw, IStaticThumbnail, IPathProvider, IPrimaryOperationsSpecifier
|
||||||
{
|
{
|
||||||
public static double MinEdgeSize = .001;
|
public static double MinEdgeSize = .001;
|
||||||
|
|
||||||
|
|
@ -85,7 +85,7 @@ namespace MatterHackers.MatterControl.DesignTools.Primitives
|
||||||
return PathObject3DAbstract.GetOperations(this.GetType());
|
return PathObject3DAbstract.GetOperations(this.GetType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual IVertexSource GetVertexSource()
|
public virtual IVertexSource GetRawPath()
|
||||||
{
|
{
|
||||||
return PathForEditing;
|
return PathForEditing;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ using MatterHackers.VectorMath;
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl.DesignTools.Operations
|
namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
{
|
{
|
||||||
public class MergePathObject3D : OperationSourceContainerObject3D, IEditorDraw, IObject3DControlsProvider, IPrimaryOperationsSpecifier, IPathObject3D
|
public class MergePathObject3D : OperationSourceContainerObject3D, IEditorDraw, IObject3DControlsProvider, IPrimaryOperationsSpecifier, IPathProvider
|
||||||
{
|
{
|
||||||
private ClipperLib.ClipType clipType;
|
private ClipperLib.ClipType clipType;
|
||||||
private string operationName;
|
private string operationName;
|
||||||
|
|
@ -101,7 +101,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the mesh to show the path
|
// set the mesh to show the path
|
||||||
this.Mesh = this.GetVertexSource().Extrude(Constants.PathPolygonsHeight);
|
this.Mesh = this.GetRawPath().Extrude(Constants.PathPolygonsHeight);
|
||||||
|
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
{
|
{
|
||||||
|
|
@ -118,7 +118,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
SourceContainer.Visible = true;
|
SourceContainer.Visible = true;
|
||||||
RemoveAllButSource();
|
RemoveAllButSource();
|
||||||
|
|
||||||
var participants = SourceContainer.VisiblePaths();
|
var participants = SourceContainer.VisiblePathProviders();
|
||||||
var first = participants.First();
|
var first = participants.First();
|
||||||
var firstObject3D = first as Object3D;
|
var firstObject3D = first as Object3D;
|
||||||
if (participants.Count() < 2)
|
if (participants.Count() < 2)
|
||||||
|
|
@ -135,7 +135,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var resultsVertexSource = first.GetVertexSource().Transform(firstObject3D.WorldMatrix(this));
|
var resultsVertexSource = first.GetTransformedPath(this);
|
||||||
|
|
||||||
var totalOperations = participants.Count() - 1;
|
var totalOperations = participants.Count() - 1;
|
||||||
double amountPerOperation = 1.0 / totalOperations;
|
double amountPerOperation = 1.0 / totalOperations;
|
||||||
|
|
@ -143,15 +143,15 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
|
|
||||||
foreach (var item in participants)
|
foreach (var item in participants)
|
||||||
{
|
{
|
||||||
|
IVertexSource itemPath = item.GetTransformedPath(this);
|
||||||
if (item != first
|
if (item != first
|
||||||
&& item.GetVertexSource() != null)
|
&& itemPath != null)
|
||||||
{
|
{
|
||||||
var itemObject3D = item as Object3D;
|
var itemObject3D = item as Object3D;
|
||||||
var itemVertexSource = item.GetVertexSource().Transform(itemObject3D.WorldMatrix(this));
|
|
||||||
|
|
||||||
this.CopyProperties(firstObject3D, Object3DPropertyFlags.Color);
|
this.CopyProperties(firstObject3D, Object3DPropertyFlags.Color);
|
||||||
|
|
||||||
resultsVertexSource = resultsVertexSource.MergePaths(itemVertexSource, clipType);
|
resultsVertexSource = resultsVertexSource.MergePaths(itemPath, clipType);
|
||||||
|
|
||||||
ratioCompleted += amountPerOperation;
|
ratioCompleted += amountPerOperation;
|
||||||
reporter?.Invoke(ratioCompleted, null);
|
reporter?.Invoke(ratioCompleted, null);
|
||||||
|
|
@ -168,7 +168,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
return PathObject3DAbstract.GetOperations(this.GetType());
|
return PathObject3DAbstract.GetOperations(this.GetType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public IVertexSource GetVertexSource()
|
public IVertexSource GetRawPath()
|
||||||
{
|
{
|
||||||
return VertexStorage;
|
return VertexStorage;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,21 +40,21 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace MatterControlLib.DesignTools.Operations.Path
|
namespace MatterControlLib.DesignTools.Operations.Path
|
||||||
{
|
{
|
||||||
public abstract class PathObject3DAbstract : Object3D, IEditorDraw, IPrimaryOperationsSpecifier, IPathObject3D
|
public abstract class PathObject3DAbstract : Object3D, IEditorDraw, IPrimaryOperationsSpecifier, IPathProvider
|
||||||
{
|
{
|
||||||
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
|
public virtual void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
|
||||||
{
|
{
|
||||||
this.DrawPath();
|
this.DrawPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AxisAlignedBoundingBox GetEditorWorldspaceAABB(Object3DControlsLayer layer)
|
public virtual AxisAlignedBoundingBox GetEditorWorldspaceAABB(Object3DControlsLayer layer)
|
||||||
{
|
{
|
||||||
return this.GetWorldspaceAabbOfDrawPath();
|
return this.GetWorldspaceAabbOfDrawPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
public VertexStorage VertexStorage { get; set; } = new VertexStorage();
|
public VertexStorage VertexStorage { get; set; } = new VertexStorage();
|
||||||
|
|
||||||
public virtual IVertexSource GetVertexSource()
|
public virtual IVertexSource GetRawPath()
|
||||||
{
|
{
|
||||||
return VertexStorage;
|
return VertexStorage;
|
||||||
}
|
}
|
||||||
|
|
@ -92,7 +92,7 @@ namespace MatterControlLib.DesignTools.Operations.Path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<SceneOperation> GetOperations()
|
public virtual IEnumerable<SceneOperation> GetOperations()
|
||||||
{
|
{
|
||||||
return GetOperations(GetType());
|
return GetOperations(GetType());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
|
|
||||||
private double cacheHeight;
|
private double cacheHeight;
|
||||||
|
|
||||||
public override IVertexSource GetVertexSource()
|
public override IVertexSource GetRawPath()
|
||||||
{
|
{
|
||||||
var paths = this.CombinedVisibleChildrenPaths();
|
var paths = this.CombinedVisibleChildrenPaths();
|
||||||
if (paths == null)
|
if (paths == null)
|
||||||
|
|
@ -231,7 +231,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
});
|
});
|
||||||
|
|
||||||
// and create the base
|
// and create the base
|
||||||
var vertexSource = GetVertexSource();
|
var vertexSource = GetRawPath();
|
||||||
|
|
||||||
// Convert VertexSource into expected Polygons
|
// Convert VertexSource into expected Polygons
|
||||||
Polygons polygonShape = (vertexSource == null) ? null : vertexSource.CreatePolygons();
|
Polygons polygonShape = (vertexSource == null) ? null : vertexSource.CreatePolygons();
|
||||||
|
|
@ -302,7 +302,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
{
|
{
|
||||||
var outsidePolygons = new Polygons();
|
var outsidePolygons = new Polygons();
|
||||||
// remove all holes from the polygons so we only center the major outlines
|
// remove all holes from the polygons so we only center the major outlines
|
||||||
var polygons = GetVertexSource().CreatePolygons();
|
var polygons = GetRawPath().CreatePolygons();
|
||||||
polygons = polygons.GetCorrectedWinding();
|
polygons = polygons.GetCorrectedWinding();
|
||||||
|
|
||||||
foreach (var polygon in polygons)
|
foreach (var polygon in polygons)
|
||||||
|
|
@ -430,7 +430,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
changeSet.Add(nameof(ExtrusionHeight), BaseType != BaseTypes.None);
|
changeSet.Add(nameof(ExtrusionHeight), BaseType != BaseTypes.None);
|
||||||
changeSet.Add(nameof(Style), BaseType != BaseTypes.Circle);
|
changeSet.Add(nameof(Style), BaseType != BaseTypes.Circle);
|
||||||
|
|
||||||
var vertexSource = GetVertexSource();
|
var vertexSource = GetRawPath();
|
||||||
var meshSource = this.Descendants<IObject3D>().Where((i) => i.Mesh != null);
|
var meshSource = this.Descendants<IObject3D>().Where((i) => i.Mesh != null);
|
||||||
|
|
||||||
changeSet.Add(nameof(CalculationHeight), vertexSource == null && meshSource.Where(m => m.Mesh != null).Any());
|
changeSet.Add(nameof(CalculationHeight), vertexSource == null && meshSource.Where(m => m.Mesh != null).Any());
|
||||||
|
|
@ -456,9 +456,9 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
|
|
||||||
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
|
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
|
||||||
{
|
{
|
||||||
if (GetVertexSource() != null)
|
if (GetRawPath() != null)
|
||||||
{
|
{
|
||||||
layer.World.RenderPathOutline(CalcTransform(), GetVertexSource(), Agg.Color.Red, 5);
|
layer.World.RenderPathOutline(CalcTransform(), GetRawPath(), Agg.Color.Red, 5);
|
||||||
|
|
||||||
// turn the lighting back on
|
// turn the lighting back on
|
||||||
GL.Enable(EnableCap.Lighting);
|
GL.Enable(EnableCap.Lighting);
|
||||||
|
|
@ -467,10 +467,10 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
|
|
||||||
public AxisAlignedBoundingBox GetEditorWorldspaceAABB(Object3DControlsLayer layer)
|
public AxisAlignedBoundingBox GetEditorWorldspaceAABB(Object3DControlsLayer layer)
|
||||||
{
|
{
|
||||||
if (GetVertexSource() != null)
|
if (GetRawPath() != null)
|
||||||
{
|
{
|
||||||
// TODO: Untested.
|
// TODO: Untested.
|
||||||
return layer.World.GetWorldspaceAabbOfRenderPathOutline(CalcTransform(), GetVertexSource(), 5);
|
return layer.World.GetWorldspaceAabbOfRenderPathOutline(CalcTransform(), GetRawPath(), 5);
|
||||||
}
|
}
|
||||||
return AxisAlignedBoundingBox.Empty();
|
return AxisAlignedBoundingBox.Empty();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -132,12 +132,12 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
|
|
||||||
public override bool MeshIsSolidObject => Output == OutputDimensions.Output3D;
|
public override bool MeshIsSolidObject => Output == OutputDimensions.Output3D;
|
||||||
|
|
||||||
public override IVertexSource GetVertexSource()
|
public override IVertexSource GetRawPath()
|
||||||
{
|
{
|
||||||
if (Output == OutputDimensions.Output2D)
|
if (Output == OutputDimensions.Output2D)
|
||||||
{
|
{
|
||||||
return this.CombinedVisibleChildrenPaths();
|
return VertexStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -241,6 +241,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
};
|
};
|
||||||
list.Add(lineObject);
|
list.Add(lineObject);
|
||||||
|
|
||||||
|
var letterPaths = new List<IVertexSource>();
|
||||||
foreach (var letter in textToWrite.ToCharArray())
|
foreach (var letter in textToWrite.ToCharArray())
|
||||||
{
|
{
|
||||||
var style = new StyledTypeFace(ApplicationController.GetTypeFace(this.Font), pointSize);
|
var style = new StyledTypeFace(ApplicationController.GetTypeFace(this.Font), pointSize);
|
||||||
|
|
@ -285,10 +286,9 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
};
|
};
|
||||||
if (Output == OutputDimensions.Output2D)
|
if (Output == OutputDimensions.Output2D)
|
||||||
{
|
{
|
||||||
var pathObject = this as PathObject3DAbstract;
|
var letterPath = new VertexSourceApplyTransform(new VertexStorage(scaledLetterPrinter),
|
||||||
pathObject.VertexStorage = new VertexStorage(
|
Affine.NewTranslation(offset.X, offset.Y));
|
||||||
new VertexSourceApplyTransform(
|
letterPaths.Add(letterPath);
|
||||||
new VertexStorage(scaledLetterPrinter), Affine.NewTranslation(offset.X, offset.Y)));
|
|
||||||
}
|
}
|
||||||
offset.X += letterPrinter.GetSize(letter.ToString()).X * mmPerPoint;
|
offset.X += letterPrinter.GetSize(letter.ToString()).X * mmPerPoint;
|
||||||
break;
|
break;
|
||||||
|
|
@ -302,6 +302,11 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Output == OutputDimensions.Output2D)
|
||||||
|
{
|
||||||
|
this.VertexStorage = new VertexStorage(new CombinePaths(letterPaths));
|
||||||
|
}
|
||||||
|
|
||||||
for (var i = list.Count - 1; i >= 0; i--)
|
for (var i = list.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if (list[i].Children.Count == 0)
|
if (list[i].Children.Count == 0)
|
||||||
|
|
@ -370,17 +375,25 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawEditor(Object3DControlsLayer object3DControlLayer, DrawEventArgs e)
|
public override void DrawEditor(Object3DControlsLayer object3DControlLayer, DrawEventArgs e)
|
||||||
{
|
{
|
||||||
this.DrawPath();
|
if (Output == OutputDimensions.Output2D)
|
||||||
|
{
|
||||||
|
this.DrawPath();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AxisAlignedBoundingBox GetEditorWorldspaceAABB(Object3DControlsLayer layer)
|
public override AxisAlignedBoundingBox GetEditorWorldspaceAABB(Object3DControlsLayer layer)
|
||||||
{
|
{
|
||||||
return this.GetWorldspaceAabbOfDrawPath();
|
if (Output == OutputDimensions.Output2D)
|
||||||
}
|
{
|
||||||
|
return this.GetWorldspaceAabbOfDrawPath();
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerable<SceneOperation> GetOperations()
|
return AxisAlignedBoundingBox.Empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<SceneOperation> GetOperations()
|
||||||
{
|
{
|
||||||
if (Output == OutputDimensions.Output2D)
|
if (Output == OutputDimensions.Output2D)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
{
|
{
|
||||||
public class SubtractPathObject3D : OperationSourceContainerObject3D, IEditorDraw, IObject3DControlsProvider, IPrimaryOperationsSpecifier, IPathObject3D
|
public class SubtractPathObject3D : OperationSourceContainerObject3D, IEditorDraw, IObject3DControlsProvider, IPrimaryOperationsSpecifier, IPathProvider
|
||||||
{
|
{
|
||||||
public SubtractPathObject3D()
|
public SubtractPathObject3D()
|
||||||
{
|
{
|
||||||
|
|
@ -123,9 +123,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the mesh to show the path
|
// set the mesh to show the path
|
||||||
if (this.GetVertexSource() != null)
|
if (this.GetRawPath() != null)
|
||||||
{
|
{
|
||||||
var extrudeMesh = this.GetVertexSource().Extrude(Constants.PathPolygonsHeight);
|
var extrudeMesh = this.GetRawPath().Extrude(Constants.PathPolygonsHeight);
|
||||||
if (extrudeMesh.Vertices.Count() > 5)
|
if (extrudeMesh.Vertices.Count() > 5)
|
||||||
{
|
{
|
||||||
this.Mesh = extrudeMesh;
|
this.Mesh = extrudeMesh;
|
||||||
|
|
@ -175,14 +175,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
var removeVisibleItems = parentOfSubtractTargets.Children
|
var removeVisibleItems = parentOfSubtractTargets.Children
|
||||||
.Where((i) => SelectedChildren
|
.Where((i) => SelectedChildren
|
||||||
.Contains(i.ID))
|
.Contains(i.ID))
|
||||||
.SelectMany(c => c.VisiblePaths())
|
.SelectMany(c => c.VisiblePathProviders())
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var keepItems = parentOfSubtractTargets.Children
|
var keepItems = parentOfSubtractTargets.Children
|
||||||
.Where((i) => !SelectedChildren
|
.Where((i) => !SelectedChildren
|
||||||
.Contains(i.ID));
|
.Contains(i.ID));
|
||||||
|
|
||||||
var keepVisibleItems = keepItems.SelectMany(c => c.VisiblePaths()).ToList();
|
var keepVisibleItems = keepItems.SelectMany(c => c.VisiblePathProviders()).ToList();
|
||||||
|
|
||||||
if (removeVisibleItems.Any()
|
if (removeVisibleItems.Any()
|
||||||
&& keepVisibleItems.Any())
|
&& keepVisibleItems.Any())
|
||||||
|
|
@ -195,12 +195,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
foreach (var keep in keepVisibleItems)
|
foreach (var keep in keepVisibleItems)
|
||||||
{
|
{
|
||||||
var keepObject3D = keep as Object3D;
|
var keepObject3D = keep as Object3D;
|
||||||
var resultsVertexSource = keep.GetVertexSource().Transform(keepObject3D.Matrix);
|
var resultsVertexSource = keep.GetTransformedPath(this);
|
||||||
|
|
||||||
foreach (var remove in removeVisibleItems)
|
foreach (var remove in removeVisibleItems)
|
||||||
{
|
{
|
||||||
var removeObject3D = remove as Object3D;
|
resultsVertexSource = resultsVertexSource.MergePaths(remove.GetTransformedPath(this), ClipperLib.ClipType.ctDifference);
|
||||||
resultsVertexSource = resultsVertexSource.MergePaths(remove.GetVertexSource().Transform(removeObject3D.Matrix), ClipperLib.ClipType.ctDifference);
|
|
||||||
|
|
||||||
// report our progress
|
// report our progress
|
||||||
ratioCompleted += amountPerOperation;
|
ratioCompleted += amountPerOperation;
|
||||||
|
|
@ -216,7 +215,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.GetVertexSource().MergePaths(resultsVertexSource, ClipperLib.ClipType.ctUnion);
|
this.GetRawPath().MergePaths(resultsVertexSource, ClipperLib.ClipType.ctUnion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -261,7 +260,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
||||||
return PathObject3DAbstract.GetOperations(this.GetType());
|
return PathObject3DAbstract.GetOperations(this.GetType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public IVertexSource GetVertexSource()
|
public IVertexSource GetRawPath()
|
||||||
{
|
{
|
||||||
return VertexStorage;
|
return VertexStorage;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 65ed18943d895a552136fff3e82bd16809a0b8f5
|
Subproject commit d69357cc53c5e83c4722353de3c2030ef84e2475
|
||||||
Loading…
Add table
Add a link
Reference in a new issue