From 1e4b9400f01d08994c1ca96e51a0ee779e2d1618 Mon Sep 17 00:00:00 2001 From: LarsBrubaker Date: Thu, 24 Sep 2020 22:35:03 -0700 Subject: [PATCH] closer to building --- MatterControlLib/ApplicationView/ISceneContext.cs | 6 ++++++ .../DesignTools/EditorTools/LithophanePlugin.cs | 14 +++++++------- .../Providers/MatterControl/PrimitivesContainer.cs | 5 ++--- .../PartPreviewWindow/View3D/View3DWidget.cs | 6 +++--- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/MatterControlLib/ApplicationView/ISceneContext.cs b/MatterControlLib/ApplicationView/ISceneContext.cs index b6ccaa306..451dbeff2 100644 --- a/MatterControlLib/ApplicationView/ISceneContext.cs +++ b/MatterControlLib/ApplicationView/ISceneContext.cs @@ -92,6 +92,7 @@ namespace MatterHackers.MatterControl // **** Printer specific **** // ******************************************************* event EventHandler ActiveLayerChanged; + event EventHandler LoadedGCodeChanged; int ActiveLayerIndex { get; set; } @@ -105,9 +106,13 @@ namespace MatterHackers.MatterControl double BuildHeight { get; } Mesh BuildVolumeMesh { get; } + Mesh Mesh { get; } + PrinterConfig Printer { get; set; } + Mesh PrinterShape { get; } + View3DConfig RendererOptions { get; } GCodeRenderInfo RenderInfo { get; set; } @@ -115,6 +120,7 @@ namespace MatterHackers.MatterControl void InvalidateBedMesh(); void LoadGCode(Stream stream, CancellationToken cancellationToken, Action progressReporter); + void LoadActiveSceneGCode(string filePath, CancellationToken cancellationToken, Action progressReporter); Task StashAndPrint(IEnumerable selectedLibraryItems); diff --git a/MatterControlLib/DesignTools/EditorTools/LithophanePlugin.cs b/MatterControlLib/DesignTools/EditorTools/LithophanePlugin.cs index 74cd72cae..025d0243e 100644 --- a/MatterControlLib/DesignTools/EditorTools/LithophanePlugin.cs +++ b/MatterControlLib/DesignTools/EditorTools/LithophanePlugin.cs @@ -73,24 +73,24 @@ namespace MatterHackers.MatterControl.Plugins.Lithophane public void Initialize() { ApplicationController.Instance.Graph.RegisterOperation( - new Library.NodeOperation() + new SceneOperation() { OperationID = "Lithophane".Localize(), - Title = "Lithophane".Localize(), - MappedTypes = new List { typeof(ImageObject3D) }, + TitleResolver = () => "Lithophane".Localize(), + OperationType = typeof(ImageObject3D), ResultType = typeof(LithophaneObject3D), - Operation = (sceneItem, scene) => + Action = (sceneContext) => { + var scene = sceneContext.Scene; + var sceneItem = scene.SelectedItem; if (sceneItem is IObject3D imageObject) { WrapWith(sceneItem, new LithophaneObject3D(), scene); } - - return Task.CompletedTask; }, IsEnabled = (sceneItem) => true, IsVisible = (sceneItem) => true, - IconCollector = (invertIcon) => AggContext.StaticData.LoadIcon("lithophane.png", 16, 16, invertIcon) + Icon = (invertIcon) => AggContext.StaticData.LoadIcon("lithophane.png", 16, 16, invertIcon) }); } diff --git a/MatterControlLib/Library/Providers/MatterControl/PrimitivesContainer.cs b/MatterControlLib/Library/Providers/MatterControl/PrimitivesContainer.cs index 4dc760e51..a3d1a1b15 100644 --- a/MatterControlLib/Library/Providers/MatterControl/PrimitivesContainer.cs +++ b/MatterControlLib/Library/Providers/MatterControl/PrimitivesContainer.cs @@ -110,7 +110,7 @@ namespace MatterHackers.MatterControl.Library #if DEBUG new GeneratorItem( () => "XY Calibration".Localize(), - async() => await XyCalibrationFaceObject3D.Create()) + async () => await XyCalibrationFaceObject3D.Create()) { DateCreated = new System.DateTime(index++) }, #endif new GeneratorItem( @@ -129,7 +129,7 @@ namespace MatterHackers.MatterControl.Library tempScene.SelectedItem = imageObject; // Invoke ImageConverter operation, passing image and scene - ApplicationController.Instance.Graph.Operations["ImageConverter"].Operation(imageObject, tempScene); + ApplicationController.Instance.Graph.Operations["ImageConverter"].Action(imageObject, tempScene); // Return replacement object constructed in ImageConverter operation var constructedComponent = tempScene.SelectedItem; @@ -142,7 +142,6 @@ namespace MatterHackers.MatterControl.Library () => "Measure Tool".Localize(), async () => await MeasureToolObject3D.Create()) { DateCreated = new System.DateTime(index++) }, - }; string title = "Primitive Shapes".Localize(); diff --git a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs index cc864ef50..9bf2c330f 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs @@ -188,7 +188,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow if (sourceEvent.Button == MouseButtons.Right) { - var popupMenu = ApplicationController.Instance.GetActionMenuForSceneItem((IObject3D)treeView.SelectedNode.Tag, Scene, true, this); + var popupMenu = ApplicationController.Instance.GetActionMenuForSceneItem(true, this); popupMenu.ShowMenu(clickedWidget, sourceEvent); } } @@ -1524,7 +1524,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow private void ShowPartContextMenu(MouseEventArgs mouseEvent, IObject3D selectedItem) { - var popupMenu = ApplicationController.Instance.GetActionMenuForSceneItem(selectedItem, Scene, true, this); + var popupMenu = ApplicationController.Instance.GetActionMenuForSceneItem(true, this); popupMenu.ShowMenu(this, mouseEvent); } @@ -1639,7 +1639,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow treeView.SelectedNode = null; } - selectedObjectPanel.SetActiveItem(selectedItem); + selectedObjectPanel.SetActiveItem(this.sceneContext); } }