Merge pull request #2240 from jlewin/design_tools
Update RenderType on settings change
This commit is contained in:
commit
b6189acd5f
4 changed files with 47 additions and 17 deletions
|
|
@ -62,17 +62,14 @@ namespace MatterHackers.MatterControl
|
|||
using PrintHistory;
|
||||
using SettingsManagement;
|
||||
|
||||
public class ApplicationConfig
|
||||
{
|
||||
public View3DConfig View3D { get; } = new View3DConfig();
|
||||
}
|
||||
|
||||
public class BedConfig
|
||||
{
|
||||
public event EventHandler ActiveLayerChanged;
|
||||
|
||||
public event EventHandler LoadedGCodeChanged;
|
||||
|
||||
public View3DConfig RendererOptions { get; } = new View3DConfig();
|
||||
|
||||
private GCodeFile loadedGCode;
|
||||
public GCodeFile LoadedGCode
|
||||
{
|
||||
|
|
@ -128,6 +125,12 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
if (this.RenderInfo != null)
|
||||
{
|
||||
if (RendererOptions.IsDirty)
|
||||
{
|
||||
this.RenderInfo.RefreshRenderType();
|
||||
RendererOptions.IsDirty = false;
|
||||
}
|
||||
|
||||
this.GCodeRenderer.Render3D(this.RenderInfo);
|
||||
}
|
||||
}
|
||||
|
|
@ -165,6 +168,8 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
public class View3DConfig
|
||||
{
|
||||
public bool IsDirty { get; internal set; }
|
||||
|
||||
public bool RenderGrid
|
||||
{
|
||||
get
|
||||
|
|
@ -180,6 +185,7 @@ namespace MatterHackers.MatterControl
|
|||
set
|
||||
{
|
||||
UserSettings.Instance.set("GcodeViewerRenderGrid", value.ToString());
|
||||
this.IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -189,6 +195,7 @@ namespace MatterHackers.MatterControl
|
|||
set
|
||||
{
|
||||
UserSettings.Instance.set("GcodeViewerRenderMoves", value.ToString());
|
||||
this.IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -198,6 +205,7 @@ namespace MatterHackers.MatterControl
|
|||
set
|
||||
{
|
||||
UserSettings.Instance.set("GcodeViewerRenderRetractions", value.ToString());
|
||||
this.IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -207,6 +215,7 @@ namespace MatterHackers.MatterControl
|
|||
set
|
||||
{
|
||||
UserSettings.Instance.set("GcodeViewerRenderSpeeds", value.ToString());
|
||||
this.IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -216,6 +225,7 @@ namespace MatterHackers.MatterControl
|
|||
set
|
||||
{
|
||||
UserSettings.Instance.set("GcodeViewerSimulateExtrusion", value.ToString());
|
||||
this.IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -225,6 +235,7 @@ namespace MatterHackers.MatterControl
|
|||
set
|
||||
{
|
||||
UserSettings.Instance.set("GcodeViewerTransparentExtrusion", value.ToString());
|
||||
this.IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -242,13 +253,18 @@ namespace MatterHackers.MatterControl
|
|||
set
|
||||
{
|
||||
UserSettings.Instance.set("GcodeViewerHideExtruderOffsets", value.ToString());
|
||||
this.IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool SyncToPrint
|
||||
{
|
||||
get => UserSettings.Instance.get("LayerViewSyncToPrint") == "True";
|
||||
set => UserSettings.Instance.set("LayerViewSyncToPrint", value.ToString());
|
||||
set
|
||||
{
|
||||
UserSettings.Instance.set("LayerViewSyncToPrint", value.ToString());
|
||||
this.IsDirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -272,8 +288,6 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
public PrinterConfig Printer { get; } = new PrinterConfig();
|
||||
|
||||
public ApplicationConfig Options { get; } = new ApplicationConfig();
|
||||
|
||||
public Action RedeemDesignCode;
|
||||
public Action EnterShareCode;
|
||||
|
||||
|
|
|
|||
|
|
@ -59,20 +59,23 @@ namespace MatterHackers.GCodeVisualizer
|
|||
|
||||
public double LayerScale { get; }
|
||||
|
||||
public RenderType CurrentRenderType { get; }
|
||||
public RenderType CurrentRenderType { get; private set; }
|
||||
|
||||
public double FeatureToStartOnRatio0To1 { get; set; }
|
||||
|
||||
public double FeatureToEndOnRatio0To1 { get; set; }
|
||||
|
||||
private Func<RenderType> GetRenderType;
|
||||
|
||||
public GCodeRenderInfo()
|
||||
{
|
||||
}
|
||||
|
||||
public GCodeRenderInfo(int startLayerIndex, int endLayerIndex,
|
||||
Affine transform, double layerScale, RenderType renderType,
|
||||
Affine transform, double layerScale,
|
||||
double featureToStartOnRatio0To1, double featureToEndOnRatio0To1,
|
||||
Vector2[] extruderOffsets,
|
||||
Func<RenderType> getRenderType,
|
||||
Func<int, RGBA_Bytes> getMaterialColor)
|
||||
{
|
||||
this.GetMaterialColor = getMaterialColor;
|
||||
|
|
@ -80,10 +83,21 @@ namespace MatterHackers.GCodeVisualizer
|
|||
this.EndLayerIndex = endLayerIndex;
|
||||
this.Transform = transform;
|
||||
this.LayerScale = layerScale;
|
||||
this.CurrentRenderType = renderType;
|
||||
|
||||
// Store delegate
|
||||
this.GetRenderType = getRenderType;
|
||||
|
||||
// Invoke delegate
|
||||
this.CurrentRenderType = this.GetRenderType();
|
||||
|
||||
this.FeatureToStartOnRatio0To1 = featureToStartOnRatio0To1;
|
||||
this.FeatureToEndOnRatio0To1 = featureToEndOnRatio0To1;
|
||||
this.extruderOffsets = extruderOffsets;
|
||||
}
|
||||
|
||||
public void RefreshRenderType()
|
||||
{
|
||||
this.CurrentRenderType = this.GetRenderType();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -89,7 +89,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
public GCode2DWidget(Vector2 gridSizeMm, Vector2 gridCenterMm)
|
||||
{
|
||||
options = ApplicationController.Instance.Options.View3D;
|
||||
options = ApplicationController.Instance.Printer.BedPlate.RendererOptions;
|
||||
printer = ApplicationController.Instance.Printer;
|
||||
|
||||
this.gridSizeMm = gridSizeMm;
|
||||
|
|
@ -186,7 +186,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
printer.BedPlate.ActiveLayerIndex,
|
||||
transform,
|
||||
layerScale,
|
||||
CreateRenderInfo(),
|
||||
printer.BedPlate.RenderInfo.FeatureToStartOnRatio0To1,
|
||||
printer.BedPlate.RenderInfo.FeatureToEndOnRatio0To1,
|
||||
new Vector2[]
|
||||
|
|
@ -194,6 +193,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
ActiveSliceSettings.Instance.Helpers.ExtruderOffset(0),
|
||||
ActiveSliceSettings.Instance.Helpers.ExtruderOffset(1)
|
||||
},
|
||||
this.CreateRenderInfo,
|
||||
MeshViewerWidget.GetMaterialColor);
|
||||
|
||||
//using (new PerformanceTimer("GCode Timer", "Render"))
|
||||
|
|
@ -208,7 +208,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
private RenderType CreateRenderInfo()
|
||||
{
|
||||
var options = ApplicationController.Instance.Options.View3D;
|
||||
var options = ApplicationController.Instance.Printer.BedPlate.RendererOptions;
|
||||
|
||||
RenderType renderType = RenderType.Extrusions;
|
||||
if (options.RenderMoves)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -102,7 +102,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
this.externalMeshViewer.TrackballTumbleWidget.DrawGlContent += TrackballTumbleWidget_DrawGlContent;
|
||||
|
||||
buttonFactory = ApplicationController.Instance.Theme.BreadCrumbButtonFactory;
|
||||
options = ApplicationController.Instance.Options.View3D;
|
||||
|
||||
options = ApplicationController.Instance.Printer.BedPlate.RendererOptions;
|
||||
printer = ApplicationController.Instance.Printer;
|
||||
printer.BedPlate.LoadedGCodeChanged += BedPlate_LoadedGCodeChanged;
|
||||
|
||||
|
|
@ -144,7 +145,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
1,
|
||||
Agg.Transform.Affine.NewIdentity(),
|
||||
1,
|
||||
this.GetRenderType(),
|
||||
0,
|
||||
1,
|
||||
new Vector2[]
|
||||
|
|
@ -152,6 +152,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
ActiveSliceSettings.Instance.Helpers.ExtruderOffset(0),
|
||||
ActiveSliceSettings.Instance.Helpers.ExtruderOffset(1)
|
||||
},
|
||||
this.GetRenderType,
|
||||
MeshViewerWidget.GetMaterialColor);
|
||||
}
|
||||
|
||||
|
|
@ -402,7 +403,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
private RenderType GetRenderType()
|
||||
{
|
||||
var options = ApplicationController.Instance.Options.View3D;
|
||||
var options = ApplicationController.Instance.Printer.BedPlate.RendererOptions;
|
||||
|
||||
RenderType renderType = RenderType.Extrusions;
|
||||
if (options.RenderMoves)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue