diff --git a/MatterControl.csproj b/MatterControl.csproj index 30d5c7474..6e9320a09 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -107,6 +107,10 @@ {74F6BB6C-9D02-4512-A59A-21940E35C532} Gui + + {d3e41b4e-bfbb-44ca-94c8-95c00f754fdd} + VectorMath + {b0aed568-8796-42b9-baa9-ebc796134e78} MatterSlice diff --git a/MatterControlLib/ApplicationView/SceneOperations.cs b/MatterControlLib/ApplicationView/SceneOperations.cs index 1be4d832f..cd447c0bc 100644 --- a/MatterControlLib/ApplicationView/SceneOperations.cs +++ b/MatterControlLib/ApplicationView/SceneOperations.cs @@ -97,7 +97,10 @@ namespace MatterHackers.MatterControl }, Icon = (invertIcon) => StaticData.Instance.LoadIcon("add_base.png", 16, 16, invertIcon).SetPreMultiply(), HelpTextResolver = () => "*A path must be selected*".Localize(), - IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && !(sceneContext.Scene.SelectedItem is IPathObject), + // this is for when base is working with generic meshes + //IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && !(sceneContext.Scene.SelectedItem is IPathObject), + // this is for when only IPathObjects are working correctly + IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && sceneContext.Scene.SelectedItem.DescendantsAndSelf().Where(i => i is IPathObject).Any(), }; } diff --git a/MatterControlLib/DesignTools/Primitives/BaseObject3D.cs b/MatterControlLib/DesignTools/Primitives/BaseObject3D.cs index bb1ba147e..5f139fcda 100644 --- a/MatterControlLib/DesignTools/Primitives/BaseObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/BaseObject3D.cs @@ -39,7 +39,10 @@ using MatterHackers.Agg.VertexSource; using MatterHackers.DataConverters2D; using MatterHackers.DataConverters3D; using MatterHackers.Localizations; +using MatterHackers.MatterControl.PartPreviewWindow; using MatterHackers.PolygonMesh.Csg; +using MatterHackers.RenderOpenGl; +using MatterHackers.RenderOpenGl.OpenGl; using MatterHackers.VectorMath; using Newtonsoft.Json; using Polygon = System.Collections.Generic.List; @@ -56,7 +59,7 @@ namespace MatterHackers.MatterControl.DesignTools Outline } - public class BaseObject3D : Object3D, IPropertyGridModifier + public class BaseObject3D : Object3D, IPropertyGridModifier, IEditorDraw { public enum CenteringTypes { @@ -138,14 +141,23 @@ namespace MatterHackers.MatterControl.DesignTools return totalSlice.CreateVertexStorage(); } - [JsonIgnore] - public IVertexSource VertexSource + private bool OutlineIsFromMesh { get { var vertexSource = (IPathObject)this.Descendants().FirstOrDefault((i) => i is IPathObject); var hasMesh = this.Descendants().Where(m => m.Mesh != null).Any(); - if (vertexSource?.VertexSource == null && hasMesh) + + return vertexSource?.VertexSource == null && hasMesh; + } + } + + [JsonIgnore] + public IVertexSource VertexSource + { + get + { + if (OutlineIsFromMesh) { if (meshVertexCache.vertexSource == null || meshVertexCache.height != CalculationHeight) { @@ -158,6 +170,7 @@ namespace MatterHackers.MatterControl.DesignTools return meshVertexCache.vertexSource; } + var vertexSource = (IPathObject)this.Descendants().FirstOrDefault((i) => i is IPathObject); return vertexSource?.VertexSource; } @@ -443,5 +456,18 @@ namespace MatterHackers.MatterControl.DesignTools change.SetRowVisible(kvp.Key, () => kvp.Value); } } + + public void DrawEditor(Object3DControlsLayer layer, List transparentMeshes, DrawEventArgs e) + { + if (OutlineIsFromMesh) + { + var aabb = this.GetAxisAlignedBoundingBox(this.WorldMatrix()); + // ExtrusionHeight + layer.World.RenderPathOutline(this.WorldMatrix() * Matrix4X4.CreateTranslation(0, 0, CalculationHeight - aabb.MinXYZ.Z + ExtrusionHeight), VertexSource, Agg.Color.Red, 5); + + // turn the lighting back on + GL.Enable(EnableCap.Lighting); + } + } } } \ No newline at end of file diff --git a/Program.cs b/Program.cs index cd521c096..2c346338f 100644 --- a/Program.cs +++ b/Program.cs @@ -36,6 +36,7 @@ using System.Runtime.InteropServices; using System.ServiceModel; using System.ServiceModel.Description; using System.Threading; +using MatterControl.Printing; using MatterHackers.Agg; using MatterHackers.Agg.Platform; using MatterHackers.Agg.UI; @@ -43,6 +44,7 @@ using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.SettingsManagement; using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.SerialPortCommunication.FrostedSerial; +using MatterHackers.VectorMath; using Microsoft.Extensions.Configuration; using Mindscape.Raygun4Net; using Photon.Parts; @@ -92,7 +94,7 @@ namespace MatterHackers.MatterControl [STAThread] public static void Main(string[] args) { -#if false +#if false // this is for some early testing of SLA output var test = new PhotonFile(); void Progress(string message) { @@ -113,6 +115,36 @@ namespace MatterHackers.MatterControl } #endif +#if false // this is for processing print log exports + var filename = "C:\\Users\\LarsBrubaker\\Downloads\\210309 B2 print_log.txt"; + var lines = File.ReadAllLines(filename); + var newPosition = default(Vector3); + var ePosition = 0.0; + var instruction = 0; + var layer = 0; + using (var writetext = new StreamWriter("C:\\Temp\\printlog.gcode")) + { + foreach (var line in lines) + { + if (line.Contains(" G1 ")) + { + GCodeFile.GetFirstNumberAfter("X", line, ref newPosition.X); + GCodeFile.GetFirstNumberAfter("Y", line, ref newPosition.Y); + GCodeFile.GetFirstNumberAfter("Z", line, ref newPosition.Z); + GCodeFile.GetFirstNumberAfter("E", line, ref ePosition); + + writetext.WriteLine($"G1 X{newPosition.X} Y{newPosition.Y} Z{newPosition.Z} E{ePosition}"); + instruction++; + + if(instruction % 500 == 0) + { + writetext.WriteLine($"; LAYER:{layer++}"); + } + } + } + } +#endif + // Set the global culture for the app, current thread and all new threads CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture; CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture; diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 859bcc06d..e6bd74906 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 859bcc06d3dd9afb98f6a395ca730230321bc985 +Subproject commit e6bd74906e62891c0e62d5129f30dfd2672bf55a