Cleaning up
This commit is contained in:
parent
d9d20774e8
commit
a22301101d
5 changed files with 32 additions and 21 deletions
|
|
@ -888,9 +888,9 @@ namespace MatterHackers.MatterControl
|
||||||
TitleGetter = () => "Combine".Localize(),
|
TitleGetter = () => "Combine".Localize(),
|
||||||
Action = (sceneContext) =>
|
Action = (sceneContext) =>
|
||||||
{
|
{
|
||||||
if (sceneContext.Scene.SelectedItem.VisiblePaths().Count() > 1)
|
if (sceneContext.Scene.SelectedItem.VisibleMeshes().All(o => o is IPathEditorDraw))
|
||||||
{
|
{
|
||||||
new MergePathObject3D("Combine".Localize(), ClipperLib.ClipType.ctUnion).WrapSelectedItemAndSelect(sceneContext.Scene);
|
new MergePathObject3D("Combine".Localize(), ClipperLib.ClipType.ctUnion).WrapSelectedItemAndSelect(sceneContext.Scene);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -1055,9 +1055,9 @@ namespace MatterHackers.MatterControl
|
||||||
TitleGetter = () => "Intersect".Localize(),
|
TitleGetter = () => "Intersect".Localize(),
|
||||||
Action = (sceneContext) =>
|
Action = (sceneContext) =>
|
||||||
{
|
{
|
||||||
if (sceneContext.Scene.SelectedItem.VisiblePaths().Count() > 1)
|
if (sceneContext.Scene.SelectedItem.VisibleMeshes().All(o => o is IPathEditorDraw))
|
||||||
{
|
{
|
||||||
new MergePathObject3D("Intersect".Localize(), ClipperLib.ClipType.ctIntersection).WrapSelectedItemAndSelect(sceneContext.Scene);
|
new MergePathObject3D("Intersect".Localize(), ClipperLib.ClipType.ctIntersection).WrapSelectedItemAndSelect(sceneContext.Scene);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -1356,9 +1356,9 @@ namespace MatterHackers.MatterControl
|
||||||
TitleGetter = () => "Subtract".Localize(),
|
TitleGetter = () => "Subtract".Localize(),
|
||||||
Action = (sceneContext) =>
|
Action = (sceneContext) =>
|
||||||
{
|
{
|
||||||
if (sceneContext.Scene.SelectedItem.VisiblePaths().Count() > 1)
|
if (sceneContext.Scene.SelectedItem.VisibleMeshes().All(o => o is IPathEditorDraw))
|
||||||
{
|
{
|
||||||
new SubtractPathObject3D().WrapSelectedItemAndSelect(sceneContext.Scene);
|
new SubtractPathObject3D().WrapSelectedItemAndSelect(sceneContext.Scene);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ using Polygons = System.Collections.Generic.List<System.Collections.Generic.List
|
||||||
namespace MatterHackers.MatterControl.DesignTools
|
namespace MatterHackers.MatterControl.DesignTools
|
||||||
{
|
{
|
||||||
[Obsolete("Use ImageToPathObject3D_2 instead", false)]
|
[Obsolete("Use ImageToPathObject3D_2 instead", false)]
|
||||||
public class ImageToPathObject3D : Object3D, IEditorDraw, IObject3DControlsProvider
|
public class ImageToPathObject3D : PathObject3D, IEditorDraw, IObject3DControlsProvider
|
||||||
{
|
{
|
||||||
private ThresholdFunctions _featureDetector = ThresholdFunctions.Silhouette;
|
private ThresholdFunctions _featureDetector = ThresholdFunctions.Silhouette;
|
||||||
|
|
||||||
|
|
@ -217,6 +217,8 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
|
|
||||||
public override bool CanApply => true;
|
public override bool CanApply => true;
|
||||||
|
|
||||||
|
public override bool MeshIsSolidObject => false;
|
||||||
|
|
||||||
public override void Apply(UndoBuffer undoBuffer)
|
public override void Apply(UndoBuffer undoBuffer)
|
||||||
{
|
{
|
||||||
this.FlattenToPathObject(undoBuffer);
|
this.FlattenToPathObject(undoBuffer);
|
||||||
|
|
|
||||||
|
|
@ -182,12 +182,13 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
|
|
||||||
public static void FlattenToPathObject(this IObject3D item, UndoBuffer undoBuffer)
|
public static void FlattenToPathObject(this IObject3D item, UndoBuffer undoBuffer)
|
||||||
{
|
{
|
||||||
if (item.GetVertexSource() != null)
|
var pathItem = item as IPathObject3D;
|
||||||
|
if (pathItem?.GetVertexSource() != null)
|
||||||
{
|
{
|
||||||
using (item.RebuildLock())
|
using (item.RebuildLock())
|
||||||
{
|
{
|
||||||
var newPathObject = new PathObject3D();
|
var newPathObject = new PathObject3D();
|
||||||
newPathObject.VertexStorage = new VertexStorage(item.GetVertexSource());
|
newPathObject.VertexStorage = new VertexStorage(pathItem.GetVertexSource());
|
||||||
|
|
||||||
// and replace us with the children
|
// and replace us with the children
|
||||||
var replaceCommand = new ReplaceCommand(new[] { item }, new[] { newPathObject });
|
var replaceCommand = new ReplaceCommand(new[] { item }, new[] { newPathObject });
|
||||||
|
|
@ -208,14 +209,15 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
|
|
||||||
public static void DrawPath(this IObject3D item)
|
public static void DrawPath(this IObject3D item)
|
||||||
{
|
{
|
||||||
if (item.GetVertexSource() != null)
|
var pathItem = item as IPathObject3D;
|
||||||
|
if (pathItem?.GetVertexSource() != 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 item.GetVertexSource().Vertices())
|
foreach (var vertex in pathItem.GetVertexSource().Vertices())
|
||||||
{
|
{
|
||||||
var position = vertex.Position;
|
var position = vertex.Position;
|
||||||
if (first)
|
if (first)
|
||||||
|
|
@ -264,13 +266,15 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||||
{
|
{
|
||||||
AxisAlignedBoundingBox box = AxisAlignedBoundingBox.Empty();
|
AxisAlignedBoundingBox box = AxisAlignedBoundingBox.Empty();
|
||||||
|
|
||||||
if (item.GetVertexSource() != null)
|
var pathItem = item as IPathObject3D;
|
||||||
|
|
||||||
|
if (pathItem?.GetVertexSource() != 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 item.GetVertexSource().Vertices())
|
foreach (var vertex in pathItem.GetVertexSource().Vertices())
|
||||||
{
|
{
|
||||||
var position = vertex.Position;
|
var position = vertex.Position;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
Outline
|
Outline
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BaseObject3D : Object3D, IPropertyGridModifier, IEditorDraw
|
public class BaseObject3D : PathObject3D, IPropertyGridModifier, IEditorDraw
|
||||||
{
|
{
|
||||||
public enum CenteringTypes
|
public enum CenteringTypes
|
||||||
{
|
{
|
||||||
|
|
@ -113,7 +113,9 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
[EnumDisplay(Mode = EnumDisplayAttribute.PresentationMode.Buttons)]
|
[EnumDisplay(Mode = EnumDisplayAttribute.PresentationMode.Buttons)]
|
||||||
public CenteringTypes Centering { get; set; } = CenteringTypes.Weighted;
|
public CenteringTypes Centering { get; set; } = CenteringTypes.Weighted;
|
||||||
|
|
||||||
public override void Cancel(UndoBuffer undoBuffer)
|
public override bool MeshIsSolidObject => true;
|
||||||
|
|
||||||
|
public override void Cancel(UndoBuffer undoBuffer)
|
||||||
{
|
{
|
||||||
using (RebuildLock())
|
using (RebuildLock())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
}
|
}
|
||||||
|
|
||||||
[HideChildrenFromTreeView]
|
[HideChildrenFromTreeView]
|
||||||
public class TextObject3D : Object3D, IPropertyGridModifier, IEditorDraw, IPrimaryOperationsSpecifier
|
public class TextObject3D : PathObject3D, IPropertyGridModifier, IEditorDraw, IPrimaryOperationsSpecifier
|
||||||
{
|
{
|
||||||
private bool refreshToolBar;
|
private bool refreshToolBar;
|
||||||
|
|
||||||
|
|
@ -129,7 +129,9 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
|
|
||||||
public override bool CanApply => true;
|
public override bool CanApply => true;
|
||||||
|
|
||||||
public override IVertexSource GetVertexSource()
|
public override bool MeshIsSolidObject => Output == OutputDimensions.Output3D;
|
||||||
|
|
||||||
|
public override IVertexSource GetVertexSource()
|
||||||
{
|
{
|
||||||
if (Output == OutputDimensions.Output2D)
|
if (Output == OutputDimensions.Output2D)
|
||||||
{
|
{
|
||||||
|
|
@ -282,7 +284,8 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
};
|
};
|
||||||
if (Output == OutputDimensions.Output2D)
|
if (Output == OutputDimensions.Output2D)
|
||||||
{
|
{
|
||||||
letterObject.VertexStorage = new VertexStorage(
|
var pathObject = this as PathObject3D;
|
||||||
|
pathObject.VertexStorage = new VertexStorage(
|
||||||
new VertexSourceApplyTransform(
|
new VertexSourceApplyTransform(
|
||||||
new VertexStorage(scaledLetterPrinter), Affine.NewTranslation(offset.X, offset.Y)));
|
new VertexStorage(scaledLetterPrinter), Affine.NewTranslation(offset.X, offset.Y)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue