Improving BaseObject

Creating debug tools for print log output
This commit is contained in:
Lars Brubaker 2021-03-09 14:42:44 -08:00
parent 005b868c4d
commit f73ca75084
5 changed files with 72 additions and 7 deletions

View file

@ -107,6 +107,10 @@
<Project>{74F6BB6C-9D02-4512-A59A-21940E35C532}</Project>
<Name>Gui</Name>
</ProjectReference>
<ProjectReference Include="Submodules\agg-sharp\VectorMath\VectorMath.csproj">
<Project>{d3e41b4e-bfbb-44ca-94c8-95c00f754fdd}</Project>
<Name>VectorMath</Name>
</ProjectReference>
<ProjectReference Include="Submodules\MatterSlice\MatterSlice.csproj">
<Project>{b0aed568-8796-42b9-baa9-ebc796134e78}</Project>
<Name>MatterSlice</Name>

View file

@ -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(),
};
}

View file

@ -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<ClipperLib.IntPoint>;
@ -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<IObject3D>().FirstOrDefault((i) => i is IPathObject);
var hasMesh = this.Descendants<IObject3D>().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<IObject3D>().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<Object3DView> 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);
}
}
}
}

View file

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

@ -1 +1 @@
Subproject commit 859bcc06d3dd9afb98f6a395ca730230321bc985
Subproject commit e6bd74906e62891c0e62d5129f30dfd2672bf55a