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