Improving path handling

This commit is contained in:
Lars Brubaker 2023-12-01 11:36:08 -08:00
parent 5db2bfae47
commit 07b16a2047
23 changed files with 253 additions and 86 deletions

View file

@ -30,6 +30,7 @@ either expressed or implied, of the FreeBSD Project.
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using MatterControlLib.DesignTools.Operations.Path;
using MatterHackers.Agg; using MatterHackers.Agg;
using MatterHackers.Agg.UI; using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource; using MatterHackers.Agg.VertexSource;
@ -45,7 +46,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.Plugins.EditorTools namespace MatterHackers.Plugins.EditorTools
{ {
public class PathControl : IObject3DControl, IObject3DControlsProvider public class PathControl : IObject3DControl, IObject3DControlsProvider
{ {
private readonly IObject3DControlContext context; private readonly IObject3DControlContext context;
@ -193,7 +194,7 @@ namespace MatterHackers.Plugins.EditorTools
lastItem = selectedItem; lastItem = selectedItem;
if (selectedItem is PathContainerObject3D pathObject) if (selectedItem is PathObject3DAbstract pathObject)
{ {
var vertexStorage = pathObject.VertexStorage; var vertexStorage = pathObject.VertexStorage;

View file

@ -29,11 +29,13 @@ either expressed or implied, of the FreeBSD Project.
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using MatterControlLib.DesignTools.Operations.Path;
using MatterHackers.Agg.UI; using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource; using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters3D; using MatterHackers.DataConverters3D;
using MatterHackers.Localizations; using MatterHackers.Localizations;
using MatterHackers.MatterControl.DesignTools.Operations; using MatterHackers.MatterControl.DesignTools.Operations;
using MatterHackers.MatterControl.DesignTools.Primitives;
using MatterHackers.PolygonMesh; using MatterHackers.PolygonMesh;
using MatterHackers.PolygonMesh.Csg; using MatterHackers.PolygonMesh.Csg;
using MatterHackers.PolygonMesh.Processors; using MatterHackers.PolygonMesh.Processors;
@ -83,12 +85,13 @@ namespace MatterHackers.MatterControl.DesignTools
public override void Apply(UndoBuffer undoBuffer) public override void Apply(UndoBuffer undoBuffer)
{ {
var newPathObject = new PathObject3D() var newPathObject = new CustomPathObject3D();
{
VertexStorage = new VertexStorage(this.GetVertexSource())
};
base.Apply(undoBuffer, new IObject3D[] { newPathObject }); var vertexStorage = new VertexStorage(this.GetVertexSource());
newPathObject.PathForEditing.SvgDString = vertexStorage.SvgDString;
newPathObject.Rebuild();
base.Apply(undoBuffer, new IObject3D[] { newPathObject });
} }
private void RemoveFacesAboveCut(Mesh mesh) private void RemoveFacesAboveCut(Mesh mesh)

View file

@ -36,6 +36,7 @@ using System;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using ClipperLib; using ClipperLib;
using MatterControlLib.DesignTools.Operations.Path;
using MatterHackers.Agg; using MatterHackers.Agg;
using MatterHackers.Agg.Image; using MatterHackers.Agg.Image;
using MatterHackers.Agg.Image.ThresholdFunctions; using MatterHackers.Agg.Image.ThresholdFunctions;
@ -55,7 +56,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 : PathContainerObject3D, IEditorDraw, IObject3DControlsProvider public class ImageToPathObject3D : PathObject3DAbstract, IEditorDraw, IObject3DControlsProvider
{ {
private ThresholdFunctions _featureDetector = ThresholdFunctions.Silhouette; private ThresholdFunctions _featureDetector = ThresholdFunctions.Silhouette;
@ -205,16 +206,6 @@ namespace MatterHackers.MatterControl.DesignTools
object3DControlsLayer.AddControls(ControlTypes.Standard2D); 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 CanApply => true;
public override bool MeshIsSolidObject => false; public override bool MeshIsSolidObject => false;

View file

@ -33,6 +33,7 @@ using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using ClipperLib; using ClipperLib;
using MatterControlLib.DesignTools.Operations.Path;
using MatterHackers.Agg; using MatterHackers.Agg;
using MatterHackers.Agg.Image; using MatterHackers.Agg.Image;
using MatterHackers.Agg.Image.ThresholdFunctions; using MatterHackers.Agg.Image.ThresholdFunctions;
@ -51,8 +52,8 @@ using Polygons = System.Collections.Generic.List<System.Collections.Generic.List
namespace MatterHackers.MatterControl.DesignTools namespace MatterHackers.MatterControl.DesignTools
{ {
[HideMeterialAndColor] [HideMeterialAndColor]
public class ImageToPathObject3D_2 : PathContainerObject3D, IImageProvider, IObject3DControlsProvider, IPropertyGridModifier, IEditorWidgetModifier public class ImageToPathObject3D_2 : PathObject3DAbstract, IImageProvider, IObject3DControlsProvider, IPropertyGridModifier, IEditorWidgetModifier
{ {
public ImageToPathObject3D_2() public ImageToPathObject3D_2()
{ {

View file

@ -33,6 +33,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using ClipperLib; using ClipperLib;
using MatterControlLib.DesignTools.Operations.Path;
using MatterHackers.Agg; using MatterHackers.Agg;
using MatterHackers.Agg.Transform; using MatterHackers.Agg.Transform;
using MatterHackers.Agg.UI; using MatterHackers.Agg.UI;
@ -41,6 +42,7 @@ using MatterHackers.DataConverters2D;
using MatterHackers.DataConverters3D; using MatterHackers.DataConverters3D;
using MatterHackers.DataConverters3D.UndoCommands; using MatterHackers.DataConverters3D.UndoCommands;
using MatterHackers.Localizations; using MatterHackers.Localizations;
using MatterHackers.MatterControl.DesignTools.Primitives;
using MatterHackers.MatterControl.PartPreviewWindow.View3D; using MatterHackers.MatterControl.PartPreviewWindow.View3D;
using MatterHackers.RenderOpenGl.OpenGl; using MatterHackers.RenderOpenGl.OpenGl;
using MatterHackers.VectorMath; using MatterHackers.VectorMath;
@ -187,11 +189,16 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
{ {
using (item.RebuildLock()) using (item.RebuildLock())
{ {
var newPathObject = new PathObject3D(); var newPathObject = new CustomPathObject3D();
newPathObject.VertexStorage = new VertexStorage(pathItem.GetVertexSource());
// and replace us with the children var vertexStorage = new VertexStorage(pathItem.GetVertexSource());
var replaceCommand = new ReplaceCommand(new[] { item }, new[] { newPathObject }); 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 });
if (undoBuffer != null) if (undoBuffer != null)
{ {

View file

@ -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;
}
}
}

View file

@ -32,6 +32,7 @@ using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using ClipperLib; using ClipperLib;
using MatterControlLib.DesignTools.Operations.Path;
using MatterHackers.Agg.UI; using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource; using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters2D; using MatterHackers.DataConverters2D;
@ -43,14 +44,14 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools.Operations namespace MatterHackers.MatterControl.DesignTools.Operations
{ {
public enum ExpandStyles public enum ExpandStyles
{ {
Flat, Flat,
Round, Round,
Sharp, Sharp,
} }
public class InflatePathObject3D : PathContainerObject3D, IEditorDraw, IObject3DControlsProvider public class InflatePathObject3D : PathObject3DAbstract, IEditorDraw, IObject3DControlsProvider
{ {
public InflatePathObject3D() public InflatePathObject3D()
{ {

View file

@ -32,6 +32,7 @@ using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MatterControlLib.DesignTools.Operations.Path;
using MatterHackers.Agg.UI; using MatterHackers.Agg.UI;
using MatterHackers.DataConverters3D; using MatterHackers.DataConverters3D;
using MatterHackers.DataConverters3D.UndoCommands; using MatterHackers.DataConverters3D.UndoCommands;
@ -43,7 +44,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools.Operations namespace MatterHackers.MatterControl.DesignTools.Operations
{ {
public class LinearExtrudeObject3D : PathContainerObject3D, IPrimaryOperationsSpecifier, IPropertyGridModifier public class LinearExtrudeObject3D : PathObject3DAbstract, IPrimaryOperationsSpecifier, IPropertyGridModifier
{ {
[Description("The height of the extrusion")] [Description("The height of the extrusion")]
[Slider(.1, 50, Easing.EaseType.Quadratic, useSnappingGrid: true)] [Slider(.1, 50, Easing.EaseType.Quadratic, useSnappingGrid: true)]

View file

@ -32,6 +32,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MatterControlLib.DesignTools.Operations.Path;
using MatterHackers.Agg.UI; using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource; using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters3D; using MatterHackers.DataConverters3D;
@ -164,7 +165,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
public IEnumerable<SceneOperation> GetOperations() public IEnumerable<SceneOperation> GetOperations()
{ {
return PathContainerObject3D.GetOperations(this.GetType()); return PathObject3DAbstract.GetOperations(this.GetType());
} }
public IVertexSource GetVertexSource() public IVertexSource GetVertexSource()

View file

@ -33,6 +33,7 @@ using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using ClipperLib; using ClipperLib;
using MatterControlLib.DesignTools.Operations.Path;
using MatterHackers.Agg; using MatterHackers.Agg;
using MatterHackers.Agg.UI; using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource; using MatterHackers.Agg.VertexSource;
@ -45,7 +46,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools.Operations namespace MatterHackers.MatterControl.DesignTools.Operations
{ {
public class OutlinePathObject3D : PathContainerObject3D, IEditorDraw, IObject3DControlsProvider public class OutlinePathObject3D : PathObject3DAbstract, IEditorDraw, IObject3DControlsProvider
{ {
public OutlinePathObject3D() public OutlinePathObject3D()
{ {

View file

@ -30,11 +30,12 @@ either expressed or implied, of the FreeBSD Project.
using MatterHackers.Agg.UI; using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource; using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters3D; using MatterHackers.DataConverters3D;
using MatterHackers.MatterControl.DesignTools;
using MatterHackers.VectorMath; using MatterHackers.VectorMath;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace MatterHackers.MatterControl.DesignTools namespace MatterControlLib.DesignTools.Operations.Path
{ {
public class PathEditorFactory : IPropertyEditorFactory public class PathEditorFactory : IPropertyEditorFactory
{ {

View file

@ -34,13 +34,14 @@ using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource; using MatterHackers.Agg.VertexSource;
using MatterHackers.ImageProcessing; using MatterHackers.ImageProcessing;
using MatterHackers.Localizations; using MatterHackers.Localizations;
using MatterHackers.MatterControl.DesignTools;
using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.MatterControl.SlicerConfiguration;
using MatterHackers.VectorMath; using MatterHackers.VectorMath;
using System; using System;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
namespace MatterHackers.MatterControl.DesignTools namespace MatterControlLib.DesignTools.Operations.Path
{ {
interface IPathEditorDraw interface IPathEditorDraw
{ {
@ -117,7 +118,7 @@ namespace MatterHackers.MatterControl.DesignTools
this.vertexChanged = vertexChanged; this.vertexChanged = vertexChanged;
this.theme = theme; this.theme = theme;
this.vertexStorage = vertexStorage; this.vertexStorage = vertexStorage;
this.beforeLastChange = new VertexStorage(); beforeLastChange = new VertexStorage();
beforeLastChange.SvgDString = vertexStorage.SvgDString; beforeLastChange.SvgDString = vertexStorage.SvgDString;
var toolBar = new FlowLayoutWidget() var toolBar = new FlowLayoutWidget()
@ -129,7 +130,7 @@ namespace MatterHackers.MatterControl.DesignTools
toolBar.VAnchor |= VAnchor.Bottom; toolBar.VAnchor |= VAnchor.Bottom;
this.AddChild(toolBar); AddChild(toolBar);
AddControlsToToolBar(theme, toolBar); AddControlsToToolBar(theme, toolBar);
} }
@ -143,7 +144,7 @@ namespace MatterHackers.MatterControl.DesignTools
AddPositionControls(theme, toolBar); 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) private void AddPositionControls(ThemeConfig theme, FlowLayoutWidget toolBar)
{ {
@ -295,14 +296,14 @@ namespace MatterHackers.MatterControl.DesignTools
hasBeenStartupPositioned = true; hasBeenStartupPositioned = true;
} }
if(editableProperty.Source is IPathEditorDraw pathEditorDraw) if (editableProperty.Source is IPathEditorDraw pathEditorDraw)
{ {
pathEditorDraw.BeforePathEditorDraw(graphics2D, this); pathEditorDraw.BeforePathEditorDraw(graphics2D, this);
} }
new VertexSourceApplyTransform(vertexStorage, TotalTransform).RenderPath(graphics2D, theme.TextColor, 2, true, theme.PrimaryAccentColor.Blend(theme.TextColor, .5), theme.PrimaryAccentColor); new VertexSourceApplyTransform(vertexStorage, TotalTransform).RenderPath(graphics2D, theme.TextColor, 2, true, theme.PrimaryAccentColor.Blend(theme.TextColor, .5), theme.PrimaryAccentColor);
if(editableProperty.PropertyInfo.GetCustomAttributes(true).OfType<PathEditorFactory.ShowOriginAttribute>().FirstOrDefault() is PathEditorFactory.ShowOriginAttribute showAxisAttribute) if (editableProperty.PropertyInfo.GetCustomAttributes(true).OfType<PathEditorFactory.ShowOriginAttribute>().FirstOrDefault() is PathEditorFactory.ShowOriginAttribute showAxisAttribute)
{ {
var leftOrigin = new Vector2(-10000, 0); var leftOrigin = new Vector2(-10000, 0);
var rightOrigin = new Vector2(10000, 0); var rightOrigin = new Vector2(10000, 0);
@ -353,9 +354,9 @@ namespace MatterHackers.MatterControl.DesignTools
if (selectedPointIndex == -1) if (selectedPointIndex == -1)
{ {
xEditWidget.Text = "---"; xEditWidget.Text = "---";
xEditWidget.Enabled= false; xEditWidget.Enabled = false;
yEditWidget.Text = "---"; yEditWidget.Text = "---";
yEditWidget.Enabled= false; yEditWidget.Enabled = false;
sharpButton.Enabled = false; sharpButton.Enabled = false;
alignedButton.Enabled = false; alignedButton.Enabled = false;
@ -395,7 +396,7 @@ namespace MatterHackers.MatterControl.DesignTools
xEditWidget.Value = selected.Position.X; xEditWidget.Value = selected.Position.X;
yEditWidget.Value = selected.Position.Y; yEditWidget.Value = selected.Position.Y;
switch(selected.Hint) switch (selected.Hint)
{ {
case CommandHint.C4Point: case CommandHint.C4Point:
case CommandHint.C4ControlToPoint: case CommandHint.C4ControlToPoint:
@ -551,7 +552,7 @@ namespace MatterHackers.MatterControl.DesignTools
} }
else if (mouseDelta.Y > 0) else if (mouseDelta.Y > 0)
{ {
zoomDelta = 1 + (1 * mouseDelta.Y / 100); zoomDelta = 1 + 1 * mouseDelta.Y / 100;
} }
var mousePreScale = mouseDownPosition; var mousePreScale = mouseDownPosition;
@ -562,7 +563,7 @@ namespace MatterHackers.MatterControl.DesignTools
var mousePostScale = mouseDownPosition; var mousePostScale = mouseDownPosition;
TotalTransform.inverse_transform(ref mousePostScale); TotalTransform.inverse_transform(ref mousePostScale);
unscaledRenderOffset += (mousePostScale - mousePreScale); unscaledRenderOffset += mousePostScale - mousePreScale;
scaleChanged?.Invoke(unscaledRenderOffset, layerScale); scaleChanged?.Invoke(unscaledRenderOffset, layerScale);
break; 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 if (FirstWidgetUnderMouse) // TODO: find a good way to decide if you are what the wheel is trying to do
{ {
const double deltaFor1Click = 120; const double deltaFor1Click = 120;
double scaleAmount = (mouseEvent.WheelDelta / deltaFor1Click) * .1; double scaleAmount = mouseEvent.WheelDelta / deltaFor1Click * .1;
ScalePartAndFixPosition(mouseEvent, layerScale + layerScale * scaleAmount); ScalePartAndFixPosition(mouseEvent, layerScale + layerScale * scaleAmount);
@ -613,7 +614,7 @@ namespace MatterHackers.MatterControl.DesignTools
var mousePostScale = new Vector2(mouseEvent.X, mouseEvent.Y); var mousePostScale = new Vector2(mouseEvent.X, mouseEvent.Y);
TotalTransform.inverse_transform(ref mousePostScale); TotalTransform.inverse_transform(ref mousePostScale);
unscaledRenderOffset += (mousePostScale - mousePreScale); unscaledRenderOffset += mousePostScale - mousePreScale;
scaleChanged?.Invoke(unscaledRenderOffset, layerScale); scaleChanged?.Invoke(unscaledRenderOffset, layerScale);
} }

View file

@ -30,15 +30,17 @@ either expressed or implied, of the FreeBSD Project.
using MatterHackers.Agg.UI; using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource; using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters3D; using MatterHackers.DataConverters3D;
using MatterHackers.MatterControl;
using MatterHackers.MatterControl.DesignTools;
using MatterHackers.MatterControl.DesignTools.Operations; using MatterHackers.MatterControl.DesignTools.Operations;
using MatterHackers.MatterControl.PartPreviewWindow; using MatterHackers.MatterControl.PartPreviewWindow;
using MatterHackers.VectorMath; using MatterHackers.VectorMath;
using System; using System;
using System.Collections.Generic; 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) public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e)
{ {
@ -50,13 +52,27 @@ namespace MatterHackers.MatterControl.DesignTools
return this.GetWorldspaceAabbOfDrawPath(); return this.GetWorldspaceAabbOfDrawPath();
} }
public VertexStorage VertexStorage { get; set; } public VertexStorage VertexStorage { get; set; } = new VertexStorage();
public virtual IVertexSource GetVertexSource() public virtual IVertexSource GetVertexSource()
{ {
return VertexStorage; 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 abstract bool MeshIsSolidObject { get; }
public static IEnumerable<SceneOperation> GetOperations(Type type) public static IEnumerable<SceneOperation> GetOperations(Type type)
@ -78,16 +94,7 @@ namespace MatterHackers.MatterControl.DesignTools
public IEnumerable<SceneOperation> GetOperations() 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;
}
} }

View file

@ -31,6 +31,7 @@ using System;
using System.ComponentModel; using System.ComponentModel;
using System.Threading.Tasks; using System.Threading.Tasks;
using ClipperLib; using ClipperLib;
using MatterControlLib.DesignTools.Operations.Path;
using MatterHackers.Agg.UI; using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource; using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters2D; using MatterHackers.DataConverters2D;
@ -44,7 +45,7 @@ using Polygons = System.Collections.Generic.List<System.Collections.Generic.List
namespace MatterHackers.MatterControl.DesignTools.Operations namespace MatterHackers.MatterControl.DesignTools.Operations
{ {
public class SmoothPathObject3D : PathContainerObject3D, IEditorDraw, IObject3DControlsProvider public class SmoothPathObject3D : PathObject3DAbstract, IEditorDraw, IObject3DControlsProvider
{ {
public SmoothPathObject3D() public SmoothPathObject3D()
{ {

View file

@ -28,6 +28,7 @@ either expressed or implied, of the FreeBSD Project.
*/ */
using CsvHelper.Configuration.Attributes; using CsvHelper.Configuration.Attributes;
using MatterControlLib.DesignTools.Operations.Path;
using MatterHackers.Agg; using MatterHackers.Agg;
using MatterHackers.Agg.Transform; using MatterHackers.Agg.Transform;
using MatterHackers.Agg.UI; using MatterHackers.Agg.UI;

View file

@ -33,6 +33,7 @@ using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using ClipperLib; using ClipperLib;
using MatterControlLib.DesignTools.Operations.Path;
using MatterHackers.Agg.Transform; using MatterHackers.Agg.Transform;
using MatterHackers.Agg.UI; using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource; using MatterHackers.Agg.VertexSource;
@ -52,7 +53,7 @@ using Polygons = System.Collections.Generic.List<System.Collections.Generic.List
namespace MatterHackers.MatterControl.DesignTools namespace MatterHackers.MatterControl.DesignTools
{ {
public enum BaseTypes public enum BaseTypes
{ {
None, None,
Rectangle, Rectangle,
@ -61,7 +62,7 @@ namespace MatterHackers.MatterControl.DesignTools
Outline Outline
} }
public class BaseObject3D : PathContainerObject3D, IPropertyGridModifier, IEditorDraw public class BaseObject3D : PathObject3DAbstract, IPropertyGridModifier, IEditorDraw
{ {
public enum CenteringTypes public enum CenteringTypes
{ {

View file

@ -29,6 +29,7 @@ either expressed or implied, of the FreeBSD Project.
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using MatterControlLib.DesignTools.Operations.Path;
using MatterHackers.Agg.UI; using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource; using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters3D; using MatterHackers.DataConverters3D;
@ -39,7 +40,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools.Primitives namespace MatterHackers.MatterControl.DesignTools.Primitives
{ {
public class BoxPathObject3D : PathContainerObject3D, IObject3DControlsProvider, IEditorDraw, IPropertyGridModifier, IStaticThumbnail public class BoxPathObject3D : PathObject3DAbstract, IObject3DControlsProvider, IEditorDraw, IPropertyGridModifier, IStaticThumbnail
{ {
public BoxPathObject3D() public BoxPathObject3D()
{ {

View file

@ -32,6 +32,7 @@ using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using MatterControlLib.DesignTools.Operations.Path;
using MatterHackers.Agg; using MatterHackers.Agg;
using MatterHackers.Agg.Font; using MatterHackers.Agg.Font;
using MatterHackers.Agg.Transform; using MatterHackers.Agg.Transform;
@ -61,7 +62,7 @@ namespace MatterHackers.MatterControl.DesignTools
} }
[HideChildrenFromTreeView] [HideChildrenFromTreeView]
public class TextObject3D : PathContainerObject3D, IPropertyGridModifier, IEditorDraw, IPrimaryOperationsSpecifier public class TextObject3D : PathObject3DAbstract, IPropertyGridModifier, IEditorDraw, IPrimaryOperationsSpecifier
{ {
private bool refreshToolBar; private bool refreshToolBar;
@ -284,7 +285,7 @@ namespace MatterHackers.MatterControl.DesignTools
}; };
if (Output == OutputDimensions.Output2D) if (Output == OutputDimensions.Output2D)
{ {
var pathObject = this as PathContainerObject3D; var pathObject = this as PathObject3DAbstract;
pathObject.VertexStorage = new VertexStorage( 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)));
@ -383,7 +384,7 @@ namespace MatterHackers.MatterControl.DesignTools
{ {
if (Output == OutputDimensions.Output2D) if (Output == OutputDimensions.Output2D)
{ {
return PathContainerObject3D.GetOperations(this.GetType()); return PathObject3DAbstract.GetOperations(this.GetType());
} }
// return no enumerations // return no enumerations

View file

@ -29,12 +29,9 @@ either expressed or implied, of the FreeBSD Project.
using MatterHackers.Agg; using MatterHackers.Agg;
using MatterHackers.Agg.Platform; using MatterHackers.Agg.Platform;
using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters3D;
using MatterHackers.Localizations; using MatterHackers.Localizations;
using MatterHackers.MatterControl.DesignTools; using MatterHackers.MatterControl.DesignTools;
using System.IO; using System.IO;
using System.Threading.Tasks;
namespace MatterHackers.MatterControl.Library namespace MatterHackers.MatterControl.Library
{ {
@ -106,24 +103,6 @@ namespace MatterHackers.MatterControl.Library
"Calibration Face".Localize(), "Calibration Face".Localize(),
async () => await XyCalibrationFaceObject3D.Create()) async () => await XyCalibrationFaceObject3D.Create())
{ DateCreated = new System.DateTime(index++) }, { 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() Name = "Experimental".Localize()
}) })

View file

@ -58,6 +58,10 @@ namespace MatterHackers.MatterControl.Library
"Box".Localize(), "Box".Localize(),
async () => await BoxPathObject3D.Create()) async () => await BoxPathObject3D.Create())
{ DateCreated = new DateTime(index++) }, { DateCreated = new DateTime(index++) },
new GeneratorItem(
"Custom Path".Localize(),
async () => await CustomPathObject3D.Create())
{ DateCreated = new DateTime(index++) },
#if DEBUG #if DEBUG
new GeneratorItem( new GeneratorItem(
"Triangle".Localize(), "Triangle".Localize(),

View file

@ -27,6 +27,7 @@ of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project. either expressed or implied, of the FreeBSD Project.
*/ */
using MatterControlLib.DesignTools.Operations.Path;
using MatterHackers.Agg; using MatterHackers.Agg;
using MatterHackers.Agg.UI; using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource; using MatterHackers.Agg.VertexSource;
@ -257,7 +258,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
public IEnumerable<SceneOperation> GetOperations() public IEnumerable<SceneOperation> GetOperations()
{ {
return PathContainerObject3D.GetOperations(this.GetType()); return PathObject3DAbstract.GetOperations(this.GetType());
} }
public IVertexSource GetVertexSource() public IVertexSource GetVertexSource()

View file

@ -1279,6 +1279,9 @@ Translated:Curve
English:Custom Object Builder English:Custom Object Builder
Translated:Custom Object Builder Translated:Custom Object Builder
English:Custom Path
Translated:Custom Path
English:Custom Points English:Custom Points
Translated:Custom Points Translated:Custom Points

@ -1 +1 @@
Subproject commit 2ba5e9779639090ffa4b632aeb014e4b59256ae6 Subproject commit 65ed18943d895a552136fff3e82bd16809a0b8f5