diff --git a/MatterControlLib/DesignTools/Primitives/SetTemperatureObject3D.cs b/MatterControlLib/DesignTools/Primitives/SetTemperatureObject3D.cs index f553a1d89..4e583f1c3 100644 --- a/MatterControlLib/DesignTools/Primitives/SetTemperatureObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/SetTemperatureObject3D.cs @@ -31,6 +31,9 @@ using System.Collections.Generic; using System.Threading.Tasks; using MatterControl.Printing; using MatterHackers.Agg; +using MatterHackers.Agg.Image; +using MatterHackers.Agg.UI; +using MatterHackers.Agg.VertexSource; using MatterHackers.DataConverters3D; using MatterHackers.Localizations; using MatterHackers.MatterControl.PartPreviewWindow; @@ -39,7 +42,7 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools { - public class SetTemperatureObject3D : Object3D, IObject3DControlsProvider, IGCodeTransformer + public class SetTemperatureObject3D : Object3D, IObject3DControlsProvider, IGCodeTransformer, IEditorDraw { private bool hasBeenReached; private double accumulatedLayerHeight; @@ -47,8 +50,11 @@ namespace MatterHackers.MatterControl.DesignTools public SetTemperatureObject3D() { Name = "Set Temperature".Localize(); - Color = new Color(.11, .98, .26, .2); - Mesh = PlatonicSolids.CreateCube(40, 40, 0.2); + Color = Color.White.WithAlpha(.2); + Mesh = new RoundedRect(-20, -20, 20, 20, 3) + { + ResolutionScale = 10 + }.Extrude(.2); } public static async Task Create() @@ -99,10 +105,16 @@ namespace MatterHackers.MatterControl.DesignTools Invalidate(InvalidateType.DisplayValues); } + UpdateTexture(); + Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh)); return Task.CompletedTask; } + private double WorldZ => default(Vector3).Transform(this.WorldMatrix()).Z; + + private (double temp, double worldZ) displayInfo = (double.MinValue, double.MinValue); + public IEnumerable ProcessCGcode(string lineToWrite, PrinterConfig printer) { if (!hasBeenReached @@ -112,9 +124,7 @@ namespace MatterHackers.MatterControl.DesignTools if (GCodeFile.GetFirstNumberAfter("; LAYER_HEIGHT", lineToWrite, ref layerHeight, out _, stopCheckingString: ":")) { accumulatedLayerHeight += layerHeight; - var worldPosition = default(Vector3); - worldPosition = worldPosition.Transform(this.WorldMatrix()); - if (accumulatedLayerHeight > worldPosition.Z) + if (accumulatedLayerHeight > WorldZ) { hasBeenReached = true; yield return $"M104 S{Temperature} ; Change Layer Temperature"; @@ -128,5 +138,41 @@ namespace MatterHackers.MatterControl.DesignTools hasBeenReached = false; accumulatedLayerHeight = 0; } + + public void DrawEditor(Object3DControlsLayer object3DControlLayer, List transparentMeshes, DrawEventArgs e) + { + if (displayInfo.temp == double.MinValue + || displayInfo.temp != Temperature + || displayInfo.worldZ != WorldZ) + { + UpdateTexture(); + } + } + + private void UpdateTexture() + { + Mesh.FaceTextures.Clear(); + displayInfo.temp = Temperature; + displayInfo.worldZ = WorldZ; + var theme = AppContext.Theme; + var texture = new ImageBuffer(128, 128, 32); + var graphics2D = texture.NewGraphics2D(); + graphics2D.Clear(theme.BackgroundColor); + graphics2D.DrawString($"Height: {displayInfo.worldZ:0.##}", + texture.Width / 2, + texture.Height / 5 * 3, + 15, + Agg.Font.Justification.Center, + Agg.Font.Baseline.BoundsCenter, + theme.TextColor); + graphics2D.DrawString($"Temp: {displayInfo.temp:0.##}", + texture.Width / 2, + texture.Height / 5 * 2, + 15, + Agg.Font.Justification.Center, + Agg.Font.Baseline.BoundsCenter, + theme.TextColor); + Mesh.PlaceTextureOnFaces(0, texture); + } } } \ No newline at end of file diff --git a/MatterControlLib/DesignTools/Primitives/TemperatureTowerObject3D.cs b/MatterControlLib/DesignTools/Primitives/TemperatureTowerObject3D.cs index af6d46d8f..f7243095b 100644 --- a/MatterControlLib/DesignTools/Primitives/TemperatureTowerObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/TemperatureTowerObject3D.cs @@ -54,6 +54,7 @@ namespace MatterHackers.MatterControl.DesignTools public TemperatureTowerObject3D() { Name = "Temperature Tower".Localize(); + Color = Color.White; if (shape == null) { @@ -172,7 +173,6 @@ namespace MatterHackers.MatterControl.DesignTools PointSize = 10, NameToWrite = $"{temp:0.##}", Matrix = Matrix4X4.CreateRotationX(MathHelper.Tau / 4) * Matrix4X4.CreateTranslation(0, -4.3, .8), - Color = Color.Transparent }; text.Rebuild().Wait(); var textBounds = text.GetAxisAlignedBoundingBox(); diff --git a/MatterControlLib/DesignTools/PublicPropertyEditor.cs b/MatterControlLib/DesignTools/PublicPropertyEditor.cs index b75009b6d..c39ec497c 100644 --- a/MatterControlLib/DesignTools/PublicPropertyEditor.cs +++ b/MatterControlLib/DesignTools/PublicPropertyEditor.cs @@ -326,6 +326,7 @@ namespace MatterHackers.MatterControl.DesignTools } object3D.Invalidated += RefreshField; + field.Content.Descendants().First().Name = property.DisplayName + " Edit"; field.Content.Closed += (s, e) => object3D.Invalidated -= RefreshField; rowContainer = CreateSettingsRow(property, field, theme); diff --git a/MatterControlLib/Library/Providers/MatterControl/PrimitivesContainer.cs b/MatterControlLib/Library/Providers/MatterControl/PrimitivesContainer.cs index 847aec020..6a430c335 100644 --- a/MatterControlLib/Library/Providers/MatterControl/PrimitivesContainer.cs +++ b/MatterControlLib/Library/Providers/MatterControl/PrimitivesContainer.cs @@ -78,7 +78,6 @@ namespace MatterHackers.MatterControl.Library () => "Text".Localize(), async () => await TextObject3D.Create()) { DateCreated = new System.DateTime(index++) }, - new GeneratorItem( () => "Cylinder".Localize(), async () => await CylinderObject3D.Create()) diff --git a/MatterControlLib/PartPreviewWindow/View3D/Object3DControlsLayer.cs b/MatterControlLib/PartPreviewWindow/View3D/Object3DControlsLayer.cs index 705c55227..29b670625 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Object3DControlsLayer.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Object3DControlsLayer.cs @@ -752,11 +752,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow if (!item.RebuildLocked) { item.Mesh.FaceTextures.TryGetValue(0, out FaceTextureData faceTexture); - bool viewOnlyTexture = faceTexture?.image == Object3DControlsLayer.viewOnlyTexture; + bool faceIsTextured = faceTexture?.image != null; // if not persistable and has view only texture, remove the view only texture if it has it if (item.WorldPersistable() - && viewOnlyTexture) + && faceIsTextured) { // make sure it does not have the view only texture using (item.RebuildLock()) @@ -765,7 +765,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } } else if (!item.WorldPersistable() - && !viewOnlyTexture + && !faceIsTextured && !item.RebuildLocked) { // add a view only texture if it does not have one diff --git a/StaticData/Images/Thumbnails/425727187812222155-256x256.png b/StaticData/Images/Thumbnails/425727187812222155-256x256.png index 70ec35b08..102cedb56 100644 Binary files a/StaticData/Images/Thumbnails/425727187812222155-256x256.png and b/StaticData/Images/Thumbnails/425727187812222155-256x256.png differ diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index c18ecbe08..6206906c7 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit c18ecbe08a331cfd860edc7e635cbb82e044fe5b +Subproject commit 6206906c77413f6c5c3b11bc1ffffd8a9e13d619 diff --git a/Tests/MatterControl.AutomationTests/PrintingTests.cs b/Tests/MatterControl.AutomationTests/PrintingTests.cs index 19a408281..309705445 100644 --- a/Tests/MatterControl.AutomationTests/PrintingTests.cs +++ b/Tests/MatterControl.AutomationTests/PrintingTests.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; +using MatterHackers.Agg; using MatterHackers.Agg.UI; using MatterHackers.GuiAutomation; using MatterHackers.MatterControl.PrinterCommunication; @@ -380,6 +381,42 @@ namespace MatterHackers.MatterControl.Tests.Automation }, maxTimeToRun: 180); } + [Test, Category("Emulator")] + public async Task TemperatureTowerWorks() + { + await MatterControlUtilities.RunTest((testRunner) => + { + using (var emulator = testRunner.LaunchAndConnectToPrinterEmulator()) + { + Assert.AreEqual(1, ApplicationController.Instance.ActivePrinters.Count(), "One printer should exist after add"); + + var printer = testRunner.FirstPrinter(); + + bool foundTemp = false; + printer.Connection.LineSent += (s, e) => + { + if (e.StartsWith("M104 S222.2")) + { + foundTemp = true; + } + }; + + // print a part + testRunner.AddItemToBedplate() + .AddItemToBedplate(partName: "Row Item Set Temperature") + .DragDropByName("MoveInZControl", "MoveInZControl", offsetDrag: new Point2D(0, 0), offsetDrop: new Point2D(0, 10)) + .ClickByName("Temperature Edit") + .Type("222.2") + .StartPrint(printer) + .WaitFor(() => printer.Connection.CommunicationState == CommunicationStates.Connected); + + Assert.IsTrue(foundTemp); + } + + return Task.CompletedTask; + }, maxTimeToRun: 180); + } + [Test, Category("Emulator")] public async Task RecoveryT1NoProbe() {