From cd6ae9e889707f28a0a07c7f808c5f863f09bf9c Mon Sep 17 00:00:00 2001 From: John Lewin Date: Tue, 19 Dec 2017 14:47:33 -0800 Subject: [PATCH 1/4] Add mesh extensions only property --- SettingsManagement/ApplicationSettings.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SettingsManagement/ApplicationSettings.cs b/SettingsManagement/ApplicationSettings.cs index 37097fa00..4d45f3eca 100644 --- a/SettingsManagement/ApplicationSettings.cs +++ b/SettingsManagement/ApplicationSettings.cs @@ -20,7 +20,8 @@ namespace MatterHackers.MatterControl public class ApplicationSettings { - public static string LibraryFilterFileExtensions { get; } = ".stl,.obj,.amf,.gcode,.mcx"; + public static string LibraryMeshFileExtensions { get; } = ".stl,.obj,.amf,.mcx"; + public static string LibraryFilterFileExtensions { get; } = LibraryMeshFileExtensions + ",.gcode"; public static string OpenPrintableFileParams { get; } = "STL, AMF, OBJ, ZIP, GCODE, MCX|*.stl;*.amf;*.obj;*.zip;*.gcode;*.mcx"; public static string OpenDesignFileParams { get; } = "STL, AMF, OBJ, ZIP, GCODE, MCX|*.stl;*.amf;*.obj;*.zip;*.gcode;*.mcx"; From 505bf0ba161db2b35ed0137cc9907ea8604055f0 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Tue, 19 Dec 2017 14:48:36 -0800 Subject: [PATCH 2/4] Fix whitespace --- PartPreviewWindow/View3D/View3DWidget.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PartPreviewWindow/View3D/View3DWidget.cs b/PartPreviewWindow/View3D/View3DWidget.cs index 61d2f1d7b..a363eb6e8 100644 --- a/PartPreviewWindow/View3D/View3DWidget.cs +++ b/PartPreviewWindow/View3D/View3DWidget.cs @@ -1417,8 +1417,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { // Project DragFiles to IEnumerable this.StartDragDrop( - mouseEvent.DragFiles.Select(path => new FileSystemFileItem(path)), - screenSpaceMousePosition: this.TransformToScreenSpace(mouseEvent.Position)); + mouseEvent.DragFiles.Select(path => new FileSystemFileItem(path)), + screenSpaceMousePosition: this.TransformToScreenSpace(mouseEvent.Position), + trackSourceFiles: true); } } From 80278f130b50c9132ac9c392adfd074e990f15f6 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Tue, 19 Dec 2017 14:49:48 -0800 Subject: [PATCH 3/4] Add trackSourceFiles param to conditionally set MeshPath on targets --- Library/Widgets/InsertionGroup.cs | 2 +- PartPreviewWindow/View3D/View3DWidget.cs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Library/Widgets/InsertionGroup.cs b/Library/Widgets/InsertionGroup.cs index ffe34c9b3..d8ff3baa0 100644 --- a/Library/Widgets/InsertionGroup.cs +++ b/Library/Widgets/InsertionGroup.cs @@ -59,7 +59,7 @@ namespace MatterHackers.MatterControl.PrintLibrary } // TODO: Figure out how best to collapse the InsertionGroup after the load task completes - public InsertionGroup(IEnumerable items, View3DWidget view3DWidget, InteractiveScene scene, Vector2 bedCenter, Func dragOperationActive) + public InsertionGroup(IEnumerable items, View3DWidget view3DWidget, InteractiveScene scene, Vector2 bedCenter, Func dragOperationActive, bool trackSourceFiles = false) { // Add a temporary placeholder to give us some bounds this.Mesh = InsertionGroup.placeHolderMesh; diff --git a/PartPreviewWindow/View3D/View3DWidget.cs b/PartPreviewWindow/View3D/View3DWidget.cs index a363eb6e8..383018509 100644 --- a/PartPreviewWindow/View3D/View3DWidget.cs +++ b/PartPreviewWindow/View3D/View3DWidget.cs @@ -877,7 +877,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } } - private void StartDragDrop(IEnumerable items, Vector2 screenSpaceMousePosition) + private void StartDragDrop(IEnumerable items, Vector2 screenSpaceMousePosition, bool trackSourceFiles = false) { this.DragOperationActive = true; @@ -904,7 +904,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow this, this.Scene, sceneContext.BedCenter, - () => this.DragOperationActive); + () => this.DragOperationActive, + trackSourceFiles); // Find intersection position of the mouse with the bed plane var intersectInfo = GetIntersectPosition(screenSpaceMousePosition); From 45f71f29a9493124608df4316e68fc120629bcf7 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Tue, 19 Dec 2017 14:50:50 -0800 Subject: [PATCH 4/4] Conditionally set MeshPath on dragdrop operations from the shell - Issue MatterHackers/MCCentral#2409 MeshWrapper Children not persisted and loaded to MCX --- Library/Interfaces/LibraryExtensionMethods.cs | 6 ++++++ Library/Providers/LibraryConfig.cs | 7 +++++++ Library/Widgets/InsertionGroup.cs | 8 ++++++++ Submodules/agg-sharp | 2 +- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Library/Interfaces/LibraryExtensionMethods.cs b/Library/Interfaces/LibraryExtensionMethods.cs index f02843777..a6dd14cec 100644 --- a/Library/Interfaces/LibraryExtensionMethods.cs +++ b/Library/Interfaces/LibraryExtensionMethods.cs @@ -53,5 +53,11 @@ namespace MatterHackers.MatterControl.Library || (item is ILibraryContentStream contentStream && ApplicationController.Instance.Library.IsContentFileType(contentStream.FileName)); } + + public static bool IsMeshFileType(this ILibraryItem item) + { + return item is ILibraryContentStream contentStream + && ApplicationController.Instance.Library.IsMeshFileType(contentStream.FileName); + } } } diff --git a/Library/Providers/LibraryConfig.cs b/Library/Providers/LibraryConfig.cs index 0b44eec9e..5d40f0092 100644 --- a/Library/Providers/LibraryConfig.cs +++ b/Library/Providers/LibraryConfig.cs @@ -187,6 +187,13 @@ namespace MatterHackers.MatterControl.Library || ApplicationController.Instance.Library.ContentProviders.Keys.Contains(fileExtensionLower)); } + public bool IsMeshFileType(string fileName) + { + string fileExtensionLower = Path.GetExtension(fileName).ToLower().Trim('.'); + return !string.IsNullOrEmpty(fileExtensionLower) + && ApplicationSettings.LibraryMeshFileExtensions.Contains(fileExtensionLower); + } + /// /// Notifies listeners that the ActiveContainer Changed /// diff --git a/Library/Widgets/InsertionGroup.cs b/Library/Widgets/InsertionGroup.cs index d8ff3baa0..8c58a5ced 100644 --- a/Library/Widgets/InsertionGroup.cs +++ b/Library/Widgets/InsertionGroup.cs @@ -116,6 +116,14 @@ namespace MatterHackers.MatterControl.PrintLibrary loadedItem.Matrix = loadedItem.Matrix * Matrix4X4.CreateTranslation((double)-aabb.Center.X, (double)-aabb.Center.Y, (double)-aabb.minXYZ.Z) * placeholderItem.Matrix; loadedItem.Color = loadedItem.Color; + // Set mesh path if tracking requested + if (trackSourceFiles + && item is FileSystemFileItem fileItem + && item.IsMeshFileType()) + { + loadedItem.MeshPath = fileItem.Path; + } + // Notification should force invalidate and redraw //progressReporter?.Invoke(1, ""); diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 37dcb2f6f..0e1228349 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 37dcb2f6fed1868eb9e557d82ef7be1b893ff332 +Subproject commit 0e12283490c83827df27ee0caaa10d510b3814c1