From ffe200c19fc6470a137eba1749390e0371ea8db8 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Mon, 29 Dec 2014 16:31:30 -0800 Subject: [PATCH] Made the average timer a shared resource Put in the interface material extruder setting --- MatterControlApplication.cs | 13 ++++--------- PartPreviewWindow/PartPreviewMainWindow.cs | 14 ++++++++++++++ .../SlicerMapping/EngineMappingMatterSlice.cs | 2 ++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/MatterControlApplication.cs b/MatterControlApplication.cs index db5d945cf..88a01e1a2 100644 --- a/MatterControlApplication.cs +++ b/MatterControlApplication.cs @@ -280,10 +280,7 @@ namespace MatterHackers.MatterControl Stopwatch totalDrawTime = new Stopwatch(); int drawCount = 0; - static readonly int averageCount = 64; - int averageIndex = 0; - int[] averageMsArray = new int[averageCount]; - int totalMsInArray = 0; + AverageMillisecondTimer millisecondTimer = new AverageMillisecondTimer(); Gaming.Game.DataViewGraph msGraph = new Gaming.Game.DataViewGraph(new Vector2(20, 500), 50, 50, 0, 200); public override void OnDraw(Graphics2D graphics2D) @@ -292,15 +289,13 @@ namespace MatterHackers.MatterControl GuiWidget.DrawCount = 0; base.OnDraw(graphics2D); totalDrawTime.Stop(); - totalMsInArray -= averageMsArray[averageIndex % averageCount]; - averageMsArray[averageIndex % averageCount] = (int)totalDrawTime.ElapsedMilliseconds; - totalMsInArray += averageMsArray[averageIndex % averageCount]; - averageIndex++; + + millisecondTimer.Update((int)totalDrawTime.ElapsedMilliseconds); if (ShowMemoryUsed) { long memory = GC.GetTotalMemory(false); - this.Title = "Allocated = {0:n0} : {1:000}ms, d{2} Size = {3}x{4}, onIdle = {5:00}:{6:00}, drawCount = {7}".FormatWith(memory, totalMsInArray/averageCount, drawCount++, this.Width, this.Height, UiThread.CountExpired, UiThread.Count, GuiWidget.DrawCount); + this.Title = "Allocated = {0:n0} : {1:000}ms, d{2} Size = {3}x{4}, onIdle = {5:00}:{6:00}, drawCount = {7}".FormatWith(memory, millisecondTimer.GetAverage(), drawCount++, this.Width, this.Height, UiThread.CountExpired, UiThread.Count, GuiWidget.DrawCount); if (DoCGCollectEveryDraw) { GC.Collect(); diff --git a/PartPreviewWindow/PartPreviewMainWindow.cs b/PartPreviewWindow/PartPreviewMainWindow.cs index 0f6af13eb..7a4c48b28 100644 --- a/PartPreviewWindow/PartPreviewMainWindow.cs +++ b/PartPreviewWindow/PartPreviewMainWindow.cs @@ -70,6 +70,20 @@ namespace MatterHackers.MatterControl.PartPreviewWindow ShowAsSystemWindow(); } +#if __ANDROID__ + Stopwatch totalDrawTime = new Stopwatch(); + AverageMillisecondTimer millisecondTimer = new AverageMillisecondTimer(); + public override void OnDraw(Graphics2D graphics2D) + { + totalDrawTime.Restart(); + base.OnDraw(graphics2D); + totalDrawTime.Stop(); + + millisecondTimer.Update((int)totalDrawTime.ElapsedMilliseconds); + millisecondTimer.DrawTopCenter(this, graphics2D); + } +#endif + private void AddHandlers() { ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents); diff --git a/SlicerConfiguration/SlicerMapping/EngineMappingMatterSlice.cs b/SlicerConfiguration/SlicerMapping/EngineMappingMatterSlice.cs index 8641a75c1..f7c542e99 100644 --- a/SlicerConfiguration/SlicerMapping/EngineMappingMatterSlice.cs +++ b/SlicerConfiguration/SlicerMapping/EngineMappingMatterSlice.cs @@ -236,6 +236,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration //supportExtruder=1 new ValuePlusConstant("supportExtruder", "support_material_extruder", -1), + new ValuePlusConstant("supportExtruder", "support_material_interface_extruder", -1), + new ValuePlusConstant("raftExtruder", "raft_extruder", -1), //supportLineSpacing=2