Improving path handling
This commit is contained in:
parent
5db2bfae47
commit
07b16a2047
23 changed files with 253 additions and 86 deletions
|
|
@ -30,6 +30,7 @@ either expressed or implied, of the FreeBSD Project.
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MatterControlLib.DesignTools.Operations.Path;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Agg.VertexSource;
|
||||
|
|
@ -193,7 +194,7 @@ namespace MatterHackers.Plugins.EditorTools
|
|||
|
||||
lastItem = selectedItem;
|
||||
|
||||
if (selectedItem is PathContainerObject3D pathObject)
|
||||
if (selectedItem is PathObject3DAbstract pathObject)
|
||||
{
|
||||
var vertexStorage = pathObject.VertexStorage;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,11 +29,13 @@ either expressed or implied, of the FreeBSD Project.
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using MatterControlLib.DesignTools.Operations.Path;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Agg.VertexSource;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.DesignTools.Operations;
|
||||
using MatterHackers.MatterControl.DesignTools.Primitives;
|
||||
using MatterHackers.PolygonMesh;
|
||||
using MatterHackers.PolygonMesh.Csg;
|
||||
using MatterHackers.PolygonMesh.Processors;
|
||||
|
|
@ -83,10 +85,11 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
|
||||
public override void Apply(UndoBuffer undoBuffer)
|
||||
{
|
||||
var newPathObject = new PathObject3D()
|
||||
{
|
||||
VertexStorage = new VertexStorage(this.GetVertexSource())
|
||||
};
|
||||
var newPathObject = new CustomPathObject3D();
|
||||
|
||||
var vertexStorage = new VertexStorage(this.GetVertexSource());
|
||||
newPathObject.PathForEditing.SvgDString = vertexStorage.SvgDString;
|
||||
newPathObject.Rebuild();
|
||||
|
||||
base.Apply(undoBuffer, new IObject3D[] { newPathObject });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ using System;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using ClipperLib;
|
||||
using MatterControlLib.DesignTools.Operations.Path;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.Image.ThresholdFunctions;
|
||||
|
|
@ -55,7 +56,7 @@ using Polygons = System.Collections.Generic.List<System.Collections.Generic.List
|
|||
namespace MatterHackers.MatterControl.DesignTools
|
||||
{
|
||||
[Obsolete("Use ImageToPathObject3D_2 instead", false)]
|
||||
public class ImageToPathObject3D : PathContainerObject3D, IEditorDraw, IObject3DControlsProvider
|
||||
public class ImageToPathObject3D : PathObject3DAbstract, IEditorDraw, IObject3DControlsProvider
|
||||
{
|
||||
private ThresholdFunctions _featureDetector = ThresholdFunctions.Silhouette;
|
||||
|
||||
|
|
@ -205,16 +206,6 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
object3DControlsLayer.AddControls(ControlTypes.Standard2D);
|
||||
}
|
||||
|
||||
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
|
||||
{
|
||||
this.DrawPath();
|
||||
}
|
||||
|
||||
public AxisAlignedBoundingBox GetEditorWorldspaceAABB(Object3DControlsLayer layer)
|
||||
{
|
||||
return this.GetWorldspaceAabbOfDrawPath();
|
||||
}
|
||||
|
||||
public override bool CanApply => true;
|
||||
|
||||
public override bool MeshIsSolidObject => false;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ using System.ComponentModel;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using ClipperLib;
|
||||
using MatterControlLib.DesignTools.Operations.Path;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.Image.ThresholdFunctions;
|
||||
|
|
@ -52,7 +53,7 @@ using Polygons = System.Collections.Generic.List<System.Collections.Generic.List
|
|||
namespace MatterHackers.MatterControl.DesignTools
|
||||
{
|
||||
[HideMeterialAndColor]
|
||||
public class ImageToPathObject3D_2 : PathContainerObject3D, IImageProvider, IObject3DControlsProvider, IPropertyGridModifier, IEditorWidgetModifier
|
||||
public class ImageToPathObject3D_2 : PathObject3DAbstract, IImageProvider, IObject3DControlsProvider, IPropertyGridModifier, IEditorWidgetModifier
|
||||
{
|
||||
public ImageToPathObject3D_2()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using ClipperLib;
|
||||
using MatterControlLib.DesignTools.Operations.Path;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Transform;
|
||||
using MatterHackers.Agg.UI;
|
||||
|
|
@ -41,6 +42,7 @@ using MatterHackers.DataConverters2D;
|
|||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.DataConverters3D.UndoCommands;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.DesignTools.Primitives;
|
||||
using MatterHackers.MatterControl.PartPreviewWindow.View3D;
|
||||
using MatterHackers.RenderOpenGl.OpenGl;
|
||||
using MatterHackers.VectorMath;
|
||||
|
|
@ -187,8 +189,13 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
|||
{
|
||||
using (item.RebuildLock())
|
||||
{
|
||||
var newPathObject = new PathObject3D();
|
||||
newPathObject.VertexStorage = new VertexStorage(pathItem.GetVertexSource());
|
||||
var newPathObject = new CustomPathObject3D();
|
||||
|
||||
var vertexStorage = new VertexStorage(pathItem.GetVertexSource());
|
||||
newPathObject.PathForEditing.SvgDString = vertexStorage.SvgDString;
|
||||
|
||||
newPathObject.CopyProperties(item, Object3DPropertyFlags.All);
|
||||
newPathObject.Rebuild();
|
||||
|
||||
// and replace us with the children
|
||||
var replaceCommand = new ReplaceCommand(new[] { item }, new[] { newPathObject });
|
||||
|
|
|
|||
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
Copyright (c) 2023, Lars Brubaker
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using MatterControlLib.DesignTools.Operations.Path;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Agg.VertexSource;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.DesignTools.Operations;
|
||||
using MatterHackers.MatterControl.PartPreviewWindow;
|
||||
using MatterHackers.PolygonMesh.Processors;
|
||||
using MatterHackers.VectorMath;
|
||||
|
||||
namespace MatterHackers.MatterControl.DesignTools.Primitives
|
||||
{
|
||||
public class CustomPathObject3D : Object3D, IEditorDraw, IStaticThumbnail, IPathObject3D, IPrimaryOperationsSpecifier
|
||||
{
|
||||
public static double MinEdgeSize = .001;
|
||||
|
||||
public CustomPathObject3D()
|
||||
{
|
||||
// make sure the path editor is registered
|
||||
PropertyEditor.RegisterEditor(typeof(PathEditorFactory.EditableVertexStorage), new PathEditorFactory());
|
||||
|
||||
Name = "Custom Path".Localize();
|
||||
Color = Operations.Object3DExtensions.PrimitiveColors["Cube"];
|
||||
}
|
||||
|
||||
public override bool CanApply => false;
|
||||
|
||||
public bool MeshIsSolidObject => false;
|
||||
|
||||
[PathEditorFactory.ShowOrigin]
|
||||
public PathEditorFactory.EditableVertexStorage PathForEditing { get; set; } = new PathEditorFactory.EditableVertexStorage();
|
||||
|
||||
public string ThumbnailName => "Custom Path";
|
||||
|
||||
public static async Task<CustomPathObject3D> Create()
|
||||
{
|
||||
var item = new CustomPathObject3D();
|
||||
await item.Rebuild();
|
||||
return item;
|
||||
}
|
||||
|
||||
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
|
||||
{
|
||||
this.DrawPath();
|
||||
}
|
||||
|
||||
public AxisAlignedBoundingBox GetEditorWorldspaceAABB(Object3DControlsLayer layer)
|
||||
{
|
||||
return this.GetWorldspaceAabbOfDrawPath();
|
||||
}
|
||||
|
||||
public IEnumerable<SceneOperation> GetOperations()
|
||||
{
|
||||
return PathObject3DAbstract.GetOperations(this.GetType());
|
||||
}
|
||||
|
||||
public virtual IVertexSource GetVertexSource()
|
||||
{
|
||||
return PathForEditing;
|
||||
}
|
||||
|
||||
public override async void OnInvalidate(InvalidateArgs invalidateArgs)
|
||||
{
|
||||
if (invalidateArgs.InvalidateType.HasFlag(InvalidateType.Properties) && invalidateArgs.Source == this)
|
||||
{
|
||||
await Rebuild();
|
||||
}
|
||||
else if (Expressions.NeedRebuild(this, invalidateArgs))
|
||||
{
|
||||
await Rebuild();
|
||||
}
|
||||
else if (invalidateArgs.InvalidateType.HasFlag(InvalidateType.Path))
|
||||
{
|
||||
await Rebuild();
|
||||
}
|
||||
else if (invalidateArgs.InvalidateType.HasFlag(InvalidateType.Children))
|
||||
|
||||
{
|
||||
base.OnInvalidate(invalidateArgs);
|
||||
}
|
||||
}
|
||||
|
||||
public override Task Rebuild()
|
||||
{
|
||||
this.DebugDepth("Rebuild");
|
||||
|
||||
using (RebuildLock())
|
||||
{
|
||||
if (PathForEditing.Count == 0)
|
||||
{
|
||||
var maxWidthDepth = 20;
|
||||
var bottom = -10;
|
||||
var top = 10;
|
||||
|
||||
var bottomPoint = new Vector2(maxWidthDepth, bottom * 10);
|
||||
var topPoint = new Vector2(maxWidthDepth, top * 10);
|
||||
var middlePoint = (bottomPoint + topPoint) / 2;
|
||||
middlePoint.X *= 2;
|
||||
|
||||
var Point1 = new Vector2(maxWidthDepth, bottom);
|
||||
var Point2 = new Vector2(maxWidthDepth, bottom + (top - bottom) * .2);
|
||||
var Point3 = new Vector2(maxWidthDepth * 1.5, bottom + (top - bottom) * .2);
|
||||
var Point4 = new Vector2(maxWidthDepth * 1.5, bottom + (top - bottom) * .5);
|
||||
var Point5 = new Vector2(maxWidthDepth * 1.5, bottom + (top - bottom) * .8);
|
||||
var Point6 = new Vector2(maxWidthDepth, bottom + (top - bottom) * .8);
|
||||
var Point7 = new Vector2(maxWidthDepth, top);
|
||||
|
||||
var newPath = new VertexStorage();
|
||||
newPath.MoveTo(Point1);
|
||||
newPath.Curve4(Point2, Point3, Point4);
|
||||
newPath.Curve4(Point5, Point6, Point7);
|
||||
newPath.ClosePolygon();
|
||||
|
||||
PathForEditing.SvgDString = newPath.SvgDString;
|
||||
}
|
||||
|
||||
using (new CenterAndHeightMaintainer(this))
|
||||
{
|
||||
Mesh = PathForEditing.Extrude(Constants.PathPolygonsHeight);
|
||||
}
|
||||
}
|
||||
|
||||
this.CancelAllParentBuilding();
|
||||
Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Path));
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -32,6 +32,7 @@ using System.ComponentModel;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using ClipperLib;
|
||||
using MatterControlLib.DesignTools.Operations.Path;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Agg.VertexSource;
|
||||
using MatterHackers.DataConverters2D;
|
||||
|
|
@ -50,7 +51,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
|||
Sharp,
|
||||
}
|
||||
|
||||
public class InflatePathObject3D : PathContainerObject3D, IEditorDraw, IObject3DControlsProvider
|
||||
public class InflatePathObject3D : PathObject3DAbstract, IEditorDraw, IObject3DControlsProvider
|
||||
{
|
||||
public InflatePathObject3D()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ using System.Collections.Generic;
|
|||
using System.ComponentModel;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MatterControlLib.DesignTools.Operations.Path;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.DataConverters3D.UndoCommands;
|
||||
|
|
@ -43,7 +44,7 @@ using MatterHackers.VectorMath;
|
|||
|
||||
namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||
{
|
||||
public class LinearExtrudeObject3D : PathContainerObject3D, IPrimaryOperationsSpecifier, IPropertyGridModifier
|
||||
public class LinearExtrudeObject3D : PathObject3DAbstract, IPrimaryOperationsSpecifier, IPropertyGridModifier
|
||||
{
|
||||
[Description("The height of the extrusion")]
|
||||
[Slider(.1, 50, Easing.EaseType.Quadratic, useSnappingGrid: true)]
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MatterControlLib.DesignTools.Operations.Path;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Agg.VertexSource;
|
||||
using MatterHackers.DataConverters3D;
|
||||
|
|
@ -164,7 +165,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
|||
|
||||
public IEnumerable<SceneOperation> GetOperations()
|
||||
{
|
||||
return PathContainerObject3D.GetOperations(this.GetType());
|
||||
return PathObject3DAbstract.GetOperations(this.GetType());
|
||||
}
|
||||
|
||||
public IVertexSource GetVertexSource()
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ using System.ComponentModel;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using ClipperLib;
|
||||
using MatterControlLib.DesignTools.Operations.Path;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Agg.VertexSource;
|
||||
|
|
@ -45,7 +46,7 @@ using MatterHackers.VectorMath;
|
|||
|
||||
namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||
{
|
||||
public class OutlinePathObject3D : PathContainerObject3D, IEditorDraw, IObject3DControlsProvider
|
||||
public class OutlinePathObject3D : PathObject3DAbstract, IEditorDraw, IObject3DControlsProvider
|
||||
{
|
||||
public OutlinePathObject3D()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,11 +30,12 @@ either expressed or implied, of the FreeBSD Project.
|
|||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Agg.VertexSource;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.MatterControl.DesignTools;
|
||||
using MatterHackers.VectorMath;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MatterHackers.MatterControl.DesignTools
|
||||
namespace MatterControlLib.DesignTools.Operations.Path
|
||||
{
|
||||
public class PathEditorFactory : IPropertyEditorFactory
|
||||
{
|
||||
|
|
@ -34,13 +34,14 @@ using MatterHackers.Agg.UI;
|
|||
using MatterHackers.Agg.VertexSource;
|
||||
using MatterHackers.ImageProcessing;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.DesignTools;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.VectorMath;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace MatterHackers.MatterControl.DesignTools
|
||||
namespace MatterControlLib.DesignTools.Operations.Path
|
||||
{
|
||||
interface IPathEditorDraw
|
||||
{
|
||||
|
|
@ -117,7 +118,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
this.vertexChanged = vertexChanged;
|
||||
this.theme = theme;
|
||||
this.vertexStorage = vertexStorage;
|
||||
this.beforeLastChange = new VertexStorage();
|
||||
beforeLastChange = new VertexStorage();
|
||||
beforeLastChange.SvgDString = vertexStorage.SvgDString;
|
||||
|
||||
var toolBar = new FlowLayoutWidget()
|
||||
|
|
@ -129,7 +130,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
|
||||
toolBar.VAnchor |= VAnchor.Bottom;
|
||||
|
||||
this.AddChild(toolBar);
|
||||
AddChild(toolBar);
|
||||
|
||||
AddControlsToToolBar(theme, toolBar);
|
||||
}
|
||||
|
|
@ -143,7 +144,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
AddPositionControls(theme, toolBar);
|
||||
}
|
||||
|
||||
public static readonly int VectorXYEditWidth = (int)(60 * GuiWidget.DeviceScale + .5);
|
||||
public static readonly int VectorXYEditWidth = (int)(60 * DeviceScale + .5);
|
||||
|
||||
private void AddPositionControls(ThemeConfig theme, FlowLayoutWidget toolBar)
|
||||
{
|
||||
|
|
@ -551,7 +552,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
}
|
||||
else if (mouseDelta.Y > 0)
|
||||
{
|
||||
zoomDelta = 1 + (1 * mouseDelta.Y / 100);
|
||||
zoomDelta = 1 + 1 * mouseDelta.Y / 100;
|
||||
}
|
||||
|
||||
var mousePreScale = mouseDownPosition;
|
||||
|
|
@ -562,7 +563,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
var mousePostScale = mouseDownPosition;
|
||||
TotalTransform.inverse_transform(ref mousePostScale);
|
||||
|
||||
unscaledRenderOffset += (mousePostScale - mousePreScale);
|
||||
unscaledRenderOffset += mousePostScale - mousePreScale;
|
||||
scaleChanged?.Invoke(unscaledRenderOffset, layerScale);
|
||||
break;
|
||||
|
||||
|
|
@ -587,7 +588,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
if (FirstWidgetUnderMouse) // TODO: find a good way to decide if you are what the wheel is trying to do
|
||||
{
|
||||
const double deltaFor1Click = 120;
|
||||
double scaleAmount = (mouseEvent.WheelDelta / deltaFor1Click) * .1;
|
||||
double scaleAmount = mouseEvent.WheelDelta / deltaFor1Click * .1;
|
||||
|
||||
ScalePartAndFixPosition(mouseEvent, layerScale + layerScale * scaleAmount);
|
||||
|
||||
|
|
@ -613,7 +614,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
var mousePostScale = new Vector2(mouseEvent.X, mouseEvent.Y);
|
||||
TotalTransform.inverse_transform(ref mousePostScale);
|
||||
|
||||
unscaledRenderOffset += (mousePostScale - mousePreScale);
|
||||
unscaledRenderOffset += mousePostScale - mousePreScale;
|
||||
|
||||
scaleChanged?.Invoke(unscaledRenderOffset, layerScale);
|
||||
}
|
||||
|
|
@ -30,15 +30,17 @@ either expressed or implied, of the FreeBSD Project.
|
|||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Agg.VertexSource;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.MatterControl;
|
||||
using MatterHackers.MatterControl.DesignTools;
|
||||
using MatterHackers.MatterControl.DesignTools.Operations;
|
||||
using MatterHackers.MatterControl.PartPreviewWindow;
|
||||
using MatterHackers.VectorMath;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MatterHackers.MatterControl.DesignTools
|
||||
namespace MatterControlLib.DesignTools.Operations.Path
|
||||
{
|
||||
public abstract class PathContainerObject3D : Object3D, IEditorDraw, IPrimaryOperationsSpecifier, IPathObject3D
|
||||
public abstract class PathObject3DAbstract : Object3D, IEditorDraw, IPrimaryOperationsSpecifier, IPathObject3D
|
||||
{
|
||||
public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
|
||||
{
|
||||
|
|
@ -50,13 +52,27 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
return this.GetWorldspaceAabbOfDrawPath();
|
||||
}
|
||||
|
||||
public VertexStorage VertexStorage { get; set; }
|
||||
public VertexStorage VertexStorage { get; set; } = new VertexStorage();
|
||||
|
||||
public virtual IVertexSource GetVertexSource()
|
||||
{
|
||||
return VertexStorage;
|
||||
}
|
||||
|
||||
public override bool CanApply => true;
|
||||
|
||||
public override void Apply(UndoBuffer undoBuffer)
|
||||
{
|
||||
if (MeshIsSolidObject)
|
||||
{
|
||||
base.Apply(undoBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.FlattenToPathObject(undoBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract bool MeshIsSolidObject { get; }
|
||||
|
||||
public static IEnumerable<SceneOperation> GetOperations(Type type)
|
||||
|
|
@ -78,16 +94,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
|
||||
public IEnumerable<SceneOperation> GetOperations()
|
||||
{
|
||||
return GetOperations(this.GetType());
|
||||
return GetOperations(GetType());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is a class that is specifically holding a path and the mesh is a visualization of the path
|
||||
/// </summary>
|
||||
public class PathObject3D : PathContainerObject3D
|
||||
{
|
||||
// Report that the Mesh is a visual representation of the Path and not a solid object
|
||||
public override bool MeshIsSolidObject => false;
|
||||
}
|
||||
}
|
||||
|
|
@ -31,6 +31,7 @@ using System;
|
|||
using System.ComponentModel;
|
||||
using System.Threading.Tasks;
|
||||
using ClipperLib;
|
||||
using MatterControlLib.DesignTools.Operations.Path;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Agg.VertexSource;
|
||||
using MatterHackers.DataConverters2D;
|
||||
|
|
@ -44,7 +45,7 @@ using Polygons = System.Collections.Generic.List<System.Collections.Generic.List
|
|||
|
||||
namespace MatterHackers.MatterControl.DesignTools.Operations
|
||||
{
|
||||
public class SmoothPathObject3D : PathContainerObject3D, IEditorDraw, IObject3DControlsProvider
|
||||
public class SmoothPathObject3D : PathObject3DAbstract, IEditorDraw, IObject3DControlsProvider
|
||||
{
|
||||
public SmoothPathObject3D()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ either expressed or implied, of the FreeBSD Project.
|
|||
*/
|
||||
|
||||
using CsvHelper.Configuration.Attributes;
|
||||
using MatterControlLib.DesignTools.Operations.Path;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Transform;
|
||||
using MatterHackers.Agg.UI;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ using System.ComponentModel;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using ClipperLib;
|
||||
using MatterControlLib.DesignTools.Operations.Path;
|
||||
using MatterHackers.Agg.Transform;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Agg.VertexSource;
|
||||
|
|
@ -61,7 +62,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
Outline
|
||||
}
|
||||
|
||||
public class BaseObject3D : PathContainerObject3D, IPropertyGridModifier, IEditorDraw
|
||||
public class BaseObject3D : PathObject3DAbstract, IPropertyGridModifier, IEditorDraw
|
||||
{
|
||||
public enum CenteringTypes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ either expressed or implied, of the FreeBSD Project.
|
|||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using MatterControlLib.DesignTools.Operations.Path;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Agg.VertexSource;
|
||||
using MatterHackers.DataConverters3D;
|
||||
|
|
@ -39,7 +40,7 @@ using MatterHackers.VectorMath;
|
|||
|
||||
namespace MatterHackers.MatterControl.DesignTools.Primitives
|
||||
{
|
||||
public class BoxPathObject3D : PathContainerObject3D, IObject3DControlsProvider, IEditorDraw, IPropertyGridModifier, IStaticThumbnail
|
||||
public class BoxPathObject3D : PathObject3DAbstract, IObject3DControlsProvider, IEditorDraw, IPropertyGridModifier, IStaticThumbnail
|
||||
{
|
||||
public BoxPathObject3D()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ using System.Collections.Generic;
|
|||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using MatterControlLib.DesignTools.Operations.Path;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Font;
|
||||
using MatterHackers.Agg.Transform;
|
||||
|
|
@ -61,7 +62,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
}
|
||||
|
||||
[HideChildrenFromTreeView]
|
||||
public class TextObject3D : PathContainerObject3D, IPropertyGridModifier, IEditorDraw, IPrimaryOperationsSpecifier
|
||||
public class TextObject3D : PathObject3DAbstract, IPropertyGridModifier, IEditorDraw, IPrimaryOperationsSpecifier
|
||||
{
|
||||
private bool refreshToolBar;
|
||||
|
||||
|
|
@ -284,7 +285,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
};
|
||||
if (Output == OutputDimensions.Output2D)
|
||||
{
|
||||
var pathObject = this as PathContainerObject3D;
|
||||
var pathObject = this as PathObject3DAbstract;
|
||||
pathObject.VertexStorage = new VertexStorage(
|
||||
new VertexSourceApplyTransform(
|
||||
new VertexStorage(scaledLetterPrinter), Affine.NewTranslation(offset.X, offset.Y)));
|
||||
|
|
@ -383,7 +384,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
{
|
||||
if (Output == OutputDimensions.Output2D)
|
||||
{
|
||||
return PathContainerObject3D.GetOperations(this.GetType());
|
||||
return PathObject3DAbstract.GetOperations(this.GetType());
|
||||
}
|
||||
|
||||
// return no enumerations
|
||||
|
|
|
|||
|
|
@ -29,12 +29,9 @@ either expressed or implied, of the FreeBSD Project.
|
|||
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Platform;
|
||||
using MatterHackers.Agg.VertexSource;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.DesignTools;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MatterHackers.MatterControl.Library
|
||||
{
|
||||
|
|
@ -106,24 +103,6 @@ namespace MatterHackers.MatterControl.Library
|
|||
"Calibration Face".Localize(),
|
||||
async () => await XyCalibrationFaceObject3D.Create())
|
||||
{ DateCreated = new System.DateTime(index++) },
|
||||
new GeneratorItem(
|
||||
"Path".Localize(),
|
||||
() =>
|
||||
{
|
||||
var storage = new VertexStorage();
|
||||
storage.MoveTo(5, 5);
|
||||
storage.LineTo(10, 5);
|
||||
storage.LineTo(7.5, 10);
|
||||
storage.ClosePolygon();
|
||||
|
||||
var path = new PathObject3D()
|
||||
{
|
||||
VertexStorage = storage
|
||||
};
|
||||
|
||||
return Task.FromResult<IObject3D>(path);
|
||||
})
|
||||
{ DateCreated = new System.DateTime(index++) },
|
||||
},
|
||||
Name = "Experimental".Localize()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -58,6 +58,10 @@ namespace MatterHackers.MatterControl.Library
|
|||
"Box".Localize(),
|
||||
async () => await BoxPathObject3D.Create())
|
||||
{ DateCreated = new DateTime(index++) },
|
||||
new GeneratorItem(
|
||||
"Custom Path".Localize(),
|
||||
async () => await CustomPathObject3D.Create())
|
||||
{ DateCreated = new DateTime(index++) },
|
||||
#if DEBUG
|
||||
new GeneratorItem(
|
||||
"Triangle".Localize(),
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ of the authors and should not be interpreted as representing official policies,
|
|||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using MatterControlLib.DesignTools.Operations.Path;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Agg.VertexSource;
|
||||
|
|
@ -257,7 +258,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
|
|||
|
||||
public IEnumerable<SceneOperation> GetOperations()
|
||||
{
|
||||
return PathContainerObject3D.GetOperations(this.GetType());
|
||||
return PathObject3DAbstract.GetOperations(this.GetType());
|
||||
}
|
||||
|
||||
public IVertexSource GetVertexSource()
|
||||
|
|
|
|||
|
|
@ -1279,6 +1279,9 @@ Translated:Curve
|
|||
English:Custom Object Builder
|
||||
Translated:Custom Object Builder
|
||||
|
||||
English:Custom Path
|
||||
Translated:Custom Path
|
||||
|
||||
English:Custom Points
|
||||
Translated:Custom Points
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 2ba5e9779639090ffa4b632aeb014e4b59256ae6
|
||||
Subproject commit 65ed18943d895a552136fff3e82bd16809a0b8f5
|
||||
Loading…
Add table
Add a link
Reference in a new issue