diff --git a/PartPreviewWindow/View3D/View3DWidget.cs b/PartPreviewWindow/View3D/View3DWidget.cs index 80e882374..175fff4b7 100644 --- a/PartPreviewWindow/View3D/View3DWidget.cs +++ b/PartPreviewWindow/View3D/View3DWidget.cs @@ -1301,7 +1301,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { BorderDouble buttonMargin = new BorderDouble(top: 3); - expandRotateOptions = expandMenuOptionFactory.GenerateCheckBoxButton(LocalizedString.Get("Rotate"), "icon_arrow_right_no_border_32x32.png", "icon_arrow_down_no_border_32x32.png"); + expandRotateOptions = expandMenuOptionFactory.GenerateCheckBoxButton("Rotate".Localize().ToUpper(), "icon_arrow_right_no_border_32x32.png", "icon_arrow_down_no_border_32x32.png"); expandRotateOptions.Margin = new BorderDouble(bottom: 2); buttonRightPanel.AddChild(expandRotateOptions); @@ -1310,7 +1310,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow rotateOptionContainer.Visible = false; buttonRightPanel.AddChild(rotateOptionContainer); - expandScaleOptions = expandMenuOptionFactory.GenerateCheckBoxButton(LocalizedString.Get("Scale"), "icon_arrow_right_no_border_32x32.png", "icon_arrow_down_no_border_32x32.png"); + expandScaleOptions = expandMenuOptionFactory.GenerateCheckBoxButton("Scale".Localize().ToUpper(), "icon_arrow_right_no_border_32x32.png", "icon_arrow_down_no_border_32x32.png"); expandScaleOptions.Margin = new BorderDouble(bottom: 2); buttonRightPanel.AddChild(expandScaleOptions); @@ -1321,7 +1321,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow // put in the mirror options { - expandMirrorOptions = expandMenuOptionFactory.GenerateCheckBoxButton(LocalizedString.Get("Mirror"), "icon_arrow_right_no_border_32x32.png", "icon_arrow_down_no_border_32x32.png"); + expandMirrorOptions = expandMenuOptionFactory.GenerateCheckBoxButton("Mirror".Localize().ToUpper(), "icon_arrow_right_no_border_32x32.png", "icon_arrow_down_no_border_32x32.png"); expandMirrorOptions.Margin = new BorderDouble(bottom: 2); buttonRightPanel.AddChild(expandMirrorOptions); @@ -1336,7 +1336,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow // put in the material options int numberOfExtruders = ActiveSliceSettings.Instance.ExtruderCount; - expandMaterialOptions = expandMenuOptionFactory.GenerateCheckBoxButton(LocalizedString.Get("Materials"), "icon_arrow_right_no_border_32x32.png", "icon_arrow_down_no_border_32x32.png"); + expandMaterialOptions = expandMenuOptionFactory.GenerateCheckBoxButton("Materials".Localize().ToUpper(), "icon_arrow_right_no_border_32x32.png", "icon_arrow_down_no_border_32x32.png"); expandMaterialOptions.Margin = new BorderDouble(bottom: 2); if (numberOfExtruders > 1) @@ -1353,7 +1353,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow // put in the view options { - expandViewOptions = expandMenuOptionFactory.GenerateCheckBoxButton(LocalizedString.Get("Display"), "icon_arrow_right_no_border_32x32.png", "icon_arrow_down_no_border_32x32.png"); + expandViewOptions = expandMenuOptionFactory.GenerateCheckBoxButton("Display".Localize().ToUpper(), "icon_arrow_right_no_border_32x32.png", "icon_arrow_down_no_border_32x32.png"); expandViewOptions.Margin = new BorderDouble(bottom: 2); buttonRightPanel.AddChild(expandViewOptions); @@ -1362,7 +1362,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow viewOptionContainer.Padding = new BorderDouble(left: 4); viewOptionContainer.Visible = false; { - CheckBox showBedCheckBox = new CheckBox(LocalizedString.Get("Show Print Bed"), textColor: ActiveTheme.Instance.PrimaryTextColor); + CheckBox showBedCheckBox = new CheckBox("Show Print Bed".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor); showBedCheckBox.Checked = true; showBedCheckBox.CheckedStateChanged += (sender, e) => { @@ -1372,7 +1372,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow if (buildHeight > 0) { - CheckBox showBuildVolumeCheckBox = new CheckBox(LocalizedString.Get("Show Print Area"), textColor: ActiveTheme.Instance.PrimaryTextColor); + CheckBox showBuildVolumeCheckBox = new CheckBox("Show Print Area".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor); showBuildVolumeCheckBox.Checked = false; showBuildVolumeCheckBox.Margin = new BorderDouble(bottom: 5); showBuildVolumeCheckBox.CheckedStateChanged += (sender, e) => diff --git a/PartPreviewWindow/ViewGcodeBasic.cs b/PartPreviewWindow/ViewGcodeBasic.cs index 0bb803619..67024ef95 100644 --- a/PartPreviewWindow/ViewGcodeBasic.cs +++ b/PartPreviewWindow/ViewGcodeBasic.cs @@ -330,11 +330,15 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { renderType |= RenderType.SpeedColors; } - if (gcodeViewWidget.SimulateExtrusion) - { - renderType |= RenderType.SimulateExtrusion; - } - if (gcodeViewWidget.HideExtruderOffsets) + if (gcodeViewWidget.SimulateExtrusion) + { + renderType |= RenderType.SimulateExtrusion; + } + if (gcodeViewWidget.TransparentExtrusion) + { + renderType |= RenderType.TransparentExtrusion; + } + if (gcodeViewWidget.HideExtruderOffsets) { renderType |= RenderType.HideExtruderOffsets; } @@ -432,7 +436,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow modelInfoContainer.HAnchor = HAnchor.ParentLeftRight; modelInfoContainer.Padding = new BorderDouble(5); - string printTimeLabel = "Print Time".Localize().ToUpper(); + string printTimeLabel = "Print Time".Localize(); string printTimeLabelFull = string.Format("{0}:", printTimeLabel); // put in the print time modelInfoContainer.AddChild(new TextWidget(printTimeLabelFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10)); @@ -463,7 +467,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow //modelInfoContainer.AddChild(new TextWidget("Size:", textColor: ActiveTheme.Instance.PrimaryTextColor)); - string filamentLengthLabel = "Filament Length".Localize().ToUpper(); + string filamentLengthLabel = "Filament Length".Localize(); string filamentLengthLabelFull = string.Format("{0}:", filamentLengthLabel); // show the filament used modelInfoContainer.AddChild(new TextWidget(filamentLengthLabelFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 9)); @@ -476,7 +480,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow modelInfoContainer.AddChild(estimatedPrintTime); } - string filamentVolumeLabel = "Filament Volume".Localize().ToUpper(); + string filamentVolumeLabel = "Filament Volume".Localize(); string filamentVolumeLabelFull = string.Format("{0}:", filamentVolumeLabel); modelInfoContainer.AddChild(new TextWidget(filamentVolumeLabelFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 9)); { @@ -488,7 +492,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow modelInfoContainer.AddChild(estimatedPrintTime); } - string weightLabel = "Est. Weight".Localize().ToUpper(); + string weightLabel = "Est. Weight".Localize(); string weightLabelFull = string.Format("{0}:", weightLabel); modelInfoContainer.AddChild(new TextWidget(weightLabelFull, pointSize: 9, textColor: ActiveTheme.Instance.PrimaryTextColor)); { @@ -555,7 +559,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow // put in a show grid check box { - CheckBox showGrid = new CheckBox(LocalizedString.Get("Grid"), textColor: ActiveTheme.Instance.PrimaryTextColor); + CheckBox showGrid = new CheckBox(LocalizedString.Get("Print Bed"), textColor: ActiveTheme.Instance.PrimaryTextColor); showGrid.Checked = gcodeViewWidget.RenderGrid; meshViewerWidget.RenderBed = showGrid.Checked; showGrid.CheckedStateChanged += (sender, e) => @@ -623,8 +627,24 @@ namespace MatterHackers.MatterControl.PartPreviewWindow layerInfoContainer.AddChild(simulateExtrusion); } - // put in a simulate extrusion checkbox - if (ActiveSliceSettings.Instance.ExtruderCount > 1) + // put in a render extrusion transparent checkbox + { + CheckBox transparentExtrusion = new CheckBox(LocalizedString.Get("Transparent"), textColor: ActiveTheme.Instance.PrimaryTextColor) + { + Checked = gcodeViewWidget.TransparentExtrusion, + Margin = new BorderDouble(5, 0, 0, 0) * TextWidget.GlobalPointSizeScaleRatio, + HAnchor = HAnchor.ParentLeft, + }; + + transparentExtrusion.CheckedStateChanged += (sender, e) => + { + gcodeViewWidget.TransparentExtrusion = transparentExtrusion.Checked; + }; + layerInfoContainer.AddChild(transparentExtrusion); + } + + // put in a simulate extrusion checkbox + if (ActiveSliceSettings.Instance.ExtruderCount > 1) { CheckBox hideExtruderOffsets = new CheckBox("Hide Offsets", textColor: ActiveTheme.Instance.PrimaryTextColor); hideExtruderOffsets.Checked = gcodeViewWidget.HideExtruderOffsets; diff --git a/PartPreviewWindow/ViewGcodeWidget.cs b/PartPreviewWindow/ViewGcodeWidget.cs index 39b2ac9c2..1076fe940 100644 --- a/PartPreviewWindow/ViewGcodeWidget.cs +++ b/PartPreviewWindow/ViewGcodeWidget.cs @@ -39,6 +39,7 @@ using MatterHackers.VectorMath; using System; using System.ComponentModel; using System.Diagnostics; +using System.Threading.Tasks; namespace MatterHackers.MatterControl.PartPreviewWindow { @@ -104,17 +105,27 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } } - public bool SimulateExtrusion - { - get { return (UserSettings.Instance.get("GcodeViewerSimulateExtrusion") == "True"); } - set - { - UserSettings.Instance.set("GcodeViewerSimulateExtrusion", value.ToString()); - Invalidate(); - } - } + public bool SimulateExtrusion + { + get { return (UserSettings.Instance.get("GcodeViewerSimulateExtrusion") == "True"); } + set + { + UserSettings.Instance.set("GcodeViewerSimulateExtrusion", value.ToString()); + Invalidate(); + } + } - public bool HideExtruderOffsets + public bool TransparentExtrusion + { + get { return (UserSettings.Instance.get("GcodeViewerTransparentExtrusion") == "True"); } + set + { + UserSettings.Instance.set("GcodeViewerTransparentExtrusion", value.ToString()); + Invalidate(); + } + } + + public bool HideExtruderOffsets { get { @@ -281,26 +292,23 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } } - private void initialLoading_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) - { - SetGCodeAfterLoad((GCodeFile)e.Result); + private async void initialLoading_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) + { + SetGCodeAfterLoad((GCodeFile)e.Result); - backgroundWorker = new BackgroundWorker(); - backgroundWorker.WorkerReportsProgress = true; - backgroundWorker.WorkerSupportsCancellation = true; + gCodeRenderer = new GCodeRenderer(loadedGCode); - backgroundWorker.ProgressChanged += new ProgressChangedEventHandler(postLoadInitialization_ProgressChanged); - backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(postLoadInitialization_RunWorkerCompleted); + await Task.Run(() => + { + DoPostLoadInitialization(); + } + ); - backgroundWorker.DoWork += new DoWorkEventHandler(DoPostLoadInitialization); - - gCodeRenderer = new GCodeRenderer(loadedGCode); - backgroundWorker.RunWorkerAsync(gCodeRenderer); + postLoadInitialization_RunWorkerCompleted(); } - public static void DoPostLoadInitialization(object sender, DoWorkEventArgs doWorkEventArgs) + public void DoPostLoadInitialization() { - GCodeRenderer gCodeRenderer = (GCodeRenderer)doWorkEventArgs.Argument; try { if (gCodeRenderer.GCodeFileToDraw != null) @@ -324,7 +332,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } } - private void postLoadInitialization_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) + private void postLoadInitialization_RunWorkerCompleted() { if (DoneLoading != null) { @@ -339,68 +347,77 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { if (loadedGCode != null) { - //using (new PerformanceTimer("GCode Timer", "Total")) - { - Affine transform = TotalTransform; + //using (new PerformanceTimer("GCode Timer", "Total")) + { + Affine transform = TotalTransform; - if (RenderGrid) - { - //using (new PerformanceTimer("GCode Timer", "Render Grid")) - { - double gridLineWidths = 0.2 * layerScale; + if (RenderGrid) + { + //using (new PerformanceTimer("GCode Timer", "Render Grid")) + { + double gridLineWidths = 0.2 * layerScale; - Graphics2DOpenGL graphics2DGl = graphics2D as Graphics2DOpenGL; - if (graphics2DGl != null) - { - GlRenderGrid(graphics2DGl, transform, gridLineWidths); - } - else - { - CreateGrid(transform); + Graphics2DOpenGL graphics2DGl = graphics2D as Graphics2DOpenGL; + if (graphics2DGl != null) + { + GlRenderGrid(graphics2DGl, transform, gridLineWidths); + } + else + { + CreateGrid(transform); - Stroke stroke = new Stroke(grid, gridLineWidths); - graphics2D.Render(stroke, gridColor); - } - } - } + Stroke stroke = new Stroke(grid, gridLineWidths); + graphics2D.Render(stroke, gridColor); + } + } + } - RenderType renderType = RenderType.Extrusions; - if (RenderMoves) - { - renderType |= RenderType.Moves; - } - if (RenderRetractions) - { - renderType |= RenderType.Retractions; - } - if (RenderSpeeds) - { - renderType |= RenderType.SpeedColors; - } - if (SimulateExtrusion) - { - renderType |= RenderType.SimulateExtrusion; - } - if (HideExtruderOffsets) - { - renderType |= RenderType.HideExtruderOffsets; - } + GCodeRenderInfo renderInfo = new GCodeRenderInfo(activeLayerIndex, activeLayerIndex, transform, layerScale, CreateRenderInfo(), + FeatureToStartOnRatio0To1, FeatureToEndOnRatio0To1, + new Vector2[] { ActiveSliceSettings.Instance.GetOffset(0), ActiveSliceSettings.Instance.GetOffset(1) }); - GCodeRenderInfo renderInfo = new GCodeRenderInfo(activeLayerIndex, activeLayerIndex, transform, layerScale, renderType, - FeatureToStartOnRatio0To1, FeatureToEndOnRatio0To1, - new Vector2[] { ActiveSliceSettings.Instance.GetOffset(0), ActiveSliceSettings.Instance.GetOffset(1) }); - - //using (new PerformanceTimer("GCode Timer", "Render")) - { - gCodeRenderer.Render(graphics2D, renderInfo); - } - } - } + //using (new PerformanceTimer("GCode Timer", "Render")) + { + gCodeRenderer.Render(graphics2D, renderInfo); + } + } + } base.OnDraw(graphics2D); } - private void GlRenderGrid(Graphics2DOpenGL graphics2DGl, Affine transform, double width) + private RenderType CreateRenderInfo() + { + RenderType renderType = RenderType.Extrusions; + if (RenderMoves) + { + renderType |= RenderType.Moves; + } + if (RenderRetractions) + { + renderType |= RenderType.Retractions; + } + if (RenderSpeeds) + { + renderType |= RenderType.SpeedColors; + } + if (SimulateExtrusion) + { + renderType |= RenderType.SimulateExtrusion; + } + if (TransparentExtrusion) + { + renderType |= RenderType.TransparentExtrusion; + } + if (HideExtruderOffsets) + { + renderType |= RenderType.HideExtruderOffsets; + } + + return renderType; + } + + private void GlRenderGrid(Graphics2DOpenGL graphics2DGl, Affine transform, double width) { graphics2DGl.PreRender(); GL.Begin(BeginMode.Triangles); diff --git a/Submodules/MatterSlice b/Submodules/MatterSlice index 721634489..a93734065 160000 --- a/Submodules/MatterSlice +++ b/Submodules/MatterSlice @@ -1 +1 @@ -Subproject commit 721634489abd1574811367c55c68d28f41859904 +Subproject commit a9373406537b96a198ce2ef81b436ea9840706cf diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 44ae2505e..da60e2a60 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 44ae2505ee332847a880c95f0c2415e971638b08 +Subproject commit da60e2a608b257720e7a5a6019b66768ce789aaf