From b7a543680349dfc7fefbe878e42462d1995e45c3 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Wed, 28 Dec 2022 14:14:38 -0800 Subject: [PATCH 1/3] refactoring --- .../ApplicationView/ApplicationController.cs | 2 +- .../Library/ContentProviders/ImageContentProvider.cs | 6 +++--- .../PartPreviewWindow/View3D/CameraFittingUtil.cs | 12 ++++++------ .../View3D/TrackballTumbleWidgetExtended.cs | 10 +++++----- Program.cs | 2 -- Submodules/agg-sharp | 2 +- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/MatterControlLib/ApplicationView/ApplicationController.cs b/MatterControlLib/ApplicationView/ApplicationController.cs index de4e91a32..10676da47 100644 --- a/MatterControlLib/ApplicationView/ApplicationController.cs +++ b/MatterControlLib/ApplicationView/ApplicationController.cs @@ -1103,7 +1103,7 @@ namespace MatterHackers.MatterControl else { // If there are no printers setup show the export dialog but have the gcode option disabled - if (ProfileManager.Instance.ActiveProfiles.Count() == 0 + if (!ProfileManager.Instance.ActiveProfiles.Any() || ProfileManager.Instance.ActiveProfiles.Count() > 1) { DialogWindow.Show(new ExportPrintItemPage(libraryItems, centerOnBed, null)); diff --git a/MatterControlLib/Library/ContentProviders/ImageContentProvider.cs b/MatterControlLib/Library/ContentProviders/ImageContentProvider.cs index edbe5bac5..b02913480 100644 --- a/MatterControlLib/Library/ContentProviders/ImageContentProvider.cs +++ b/MatterControlLib/Library/ContentProviders/ImageContentProvider.cs @@ -44,9 +44,9 @@ namespace MatterHackers.MatterControl.DesignTools /// public class ImageContentProvider : ISceneContentProvider { - public Task CreateItem(ILibraryItem item, Action reporter) + public async Task CreateItem(ILibraryItem item, Action reporter) { - return Task.Run(async () => + return await Task.Run(async () => { var imageBuffer = await this.LoadImage(item); if (imageBuffer != null) @@ -61,7 +61,7 @@ namespace MatterHackers.MatterControl.DesignTools { using (var streamAndLength = await streamInterface.GetStream(null)) { - assetPath = AssetObject3D.AssetManager.StoreStream(streamAndLength.Stream, Path.GetExtension(streamInterface.FileName), false, CancellationToken.None, null).Result; + assetPath = await AssetObject3D.AssetManager.StoreStream(streamAndLength.Stream, Path.GetExtension(streamInterface.FileName), false, CancellationToken.None, null); } } diff --git a/MatterControlLib/PartPreviewWindow/View3D/CameraFittingUtil.cs b/MatterControlLib/PartPreviewWindow/View3D/CameraFittingUtil.cs index 348da3146..494cda11b 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/CameraFittingUtil.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/CameraFittingUtil.cs @@ -79,13 +79,13 @@ namespace MatterHackers const double OrthographicLargeZRangeScaledDistanceBetweenNearAndObject = 1.0; #endif - public struct Result + public struct FitResult { public Vector3 CameraPosition; public double OrthographicViewspaceHeight; } - public static Result ComputeOrthographicCameraFit(WorldView world, double centerOffsetX, double zNear, double zFar, AxisAlignedBoundingBox worldspaceAABB) + public static FitResult ComputeOrthographicCameraFit(WorldView world, double centerOffsetX, double zNear, double zFar, AxisAlignedBoundingBox worldspaceAABB) { Vector3[] worldspacePoints = worldspaceAABB.GetCorners(); Vector3[] viewspacePoints = worldspacePoints.Select(x => x.TransformPosition(world.ModelviewMatrix)).ToArray(); @@ -138,10 +138,10 @@ namespace MatterHackers #endif Vector3 worldspaceCameraPosition = viewspaceCameraPosition.TransformPosition(world.InverseModelviewMatrix); - return new Result { CameraPosition = worldspaceCameraPosition, OrthographicViewspaceHeight = targetViewspaceSize.Y }; + return new FitResult { CameraPosition = worldspaceCameraPosition, OrthographicViewspaceHeight = targetViewspaceSize.Y }; } - public static Result ComputePerspectiveCameraFit(WorldView world, double centerOffsetX, AxisAlignedBoundingBox worldspaceAABB) + public static FitResult ComputePerspectiveCameraFit(WorldView world, double centerOffsetX, AxisAlignedBoundingBox worldspaceAABB) { System.Diagnostics.Debug.Assert(!world.IsOrthographic); @@ -169,7 +169,7 @@ namespace MatterHackers switch (PerspectiveFittingAlgorithm) { case EPerspectiveFittingAlgorithm.TrialAndError: - return new Result { CameraPosition = TryPerspectiveCameraFitByIterativeAdjust(world, centerOffsetX, worldspaceAABB) }; + return new FitResult { CameraPosition = TryPerspectiveCameraFitByIterativeAdjust(world, centerOffsetX, worldspaceAABB) }; case EPerspectiveFittingAlgorithm.Sphere: default: viewspaceCameraPosition = PerspectiveCameraFitToSphere(reducedWorld, viewspaceCenter, viewspacePoints); @@ -188,7 +188,7 @@ namespace MatterHackers break; } - return new Result { CameraPosition = viewspaceCameraPosition.TransformPosition(world.InverseModelviewMatrix) }; + return new FitResult { CameraPosition = viewspaceCameraPosition.TransformPosition(world.InverseModelviewMatrix) }; } static bool NeedsToBeSmaller(RectangleDouble partScreenBounds, RectangleDouble goalBounds) diff --git a/MatterControlLib/PartPreviewWindow/View3D/TrackballTumbleWidgetExtended.cs b/MatterControlLib/PartPreviewWindow/View3D/TrackballTumbleWidgetExtended.cs index 22bf75643..569e78b07 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/TrackballTumbleWidgetExtended.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/TrackballTumbleWidgetExtended.cs @@ -551,22 +551,22 @@ namespace MatterHackers.MatterControl.PartPreviewWindow // Using fake values for near/far. // ComputeOrthographicCameraFit may move the camera to wherever as long as the scene is centered, then // GetNearFar will figure out the near/far planes in the next projection update. - CameraFittingUtil.Result result = CameraFittingUtil.ComputeOrthographicCameraFit(world, CenterOffsetX, 0, 1, box); + CameraFittingUtil.FitResult fitResult = CameraFittingUtil.ComputeOrthographicCameraFit(world, CenterOffsetX, 0, 1, box); WorldView tempWorld = new WorldView(world.Width, world.Height); - tempWorld.CalculateOrthogrphicMatrixOffCenterWithViewspaceHeight(world.Width, world.Height, CenterOffsetX, result.OrthographicViewspaceHeight, 0, 1); + tempWorld.CalculateOrthogrphicMatrixOffCenterWithViewspaceHeight(world.Width, world.Height, CenterOffsetX, fitResult.OrthographicViewspaceHeight, 0, 1); double endViewspaceHeight = tempWorld.NearPlaneHeightInViewspace; double startViewspaceHeight = world.NearPlaneHeightInViewspace; AnimateOrthographicTranslationAndHeight( world.EyePosition, startViewspaceHeight, - result.CameraPosition, endViewspaceHeight + fitResult.CameraPosition, endViewspaceHeight ); } else { - CameraFittingUtil.Result result = CameraFittingUtil.ComputePerspectiveCameraFit(world, CenterOffsetX, box); - AnimateTranslation(result.CameraPosition, world.EyePosition); + CameraFittingUtil.FitResult fitResult = CameraFittingUtil.ComputePerspectiveCameraFit(world, CenterOffsetX, box); + AnimateTranslation(fitResult.CameraPosition, world.EyePosition); } } diff --git a/Program.cs b/Program.cs index 2993eac33..b586f5cb0 100644 --- a/Program.cs +++ b/Program.cs @@ -69,8 +69,6 @@ namespace MatterHackers.MatterControl private static RaygunClient _raygunClient; - - [DllImport("Shcore.dll")] static extern int SetProcessDpiAwareness(int PROCESS_DPI_AWARENESS); diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 90fc0d026..2b3175da4 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 90fc0d026d710888e4ed65adc57c28f239334f09 +Subproject commit 2b3175da4640913781a8b41e782199bb10c8448b From 93aecc937f137c82137cb1a0c99055f998dd24ea Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Mon, 9 Jan 2023 13:39:20 -0800 Subject: [PATCH 2/3] Add available drives to computer --- .../ComputerCollectionContainer.cs | 20 +++++++++++++++++- StaticData/Icons/Library/hard-drive.png | Bin 0 -> 5478 bytes StaticData/Icons/Library/hard-drive.svg | 4 ++++ Submodules/agg-sharp | 2 +- 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 StaticData/Icons/Library/hard-drive.png create mode 100644 StaticData/Icons/Library/hard-drive.svg diff --git a/MatterControlLib/Library/Providers/MatterControl/ComputerCollectionContainer.cs b/MatterControlLib/Library/Providers/MatterControl/ComputerCollectionContainer.cs index 2d9067cef..5a4598c1e 100644 --- a/MatterControlLib/Library/Providers/MatterControl/ComputerCollectionContainer.cs +++ b/MatterControlLib/Library/Providers/MatterControl/ComputerCollectionContainer.cs @@ -27,6 +27,7 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ +using System; using System.IO; using MatterHackers.Agg; using MatterHackers.Agg.Platform; @@ -95,7 +96,24 @@ namespace MatterHackers.MatterControl.Library })); } - if (ProfileManager.Instance != null) + foreach (var drive in DriveInfo.GetDrives()) + { + this.ChildContainers.Add( + new DynamicContainerLink( + drive.Name, + StaticData.Instance.LoadIcon(Path.Combine("Library", "folder.png")), + StaticData.Instance.LoadIcon(Path.Combine("Library", "hard-drive.png")), + () => new FileSystemContainer(drive.RootDirectory.FullName) + { + UseIncrementedNameDuringTypeChange = true, + DefaultSort = new LibrarySortBehavior() + { + SortKey = SortKey.ModifiedDate, + } + })); + } + + if (ProfileManager.Instance != null) { var userDirectory = ProfileManager.Instance.UserProfilesDirectory; var libraryFiles = Directory.GetFiles(userDirectory, "*.library"); diff --git a/StaticData/Icons/Library/hard-drive.png b/StaticData/Icons/Library/hard-drive.png new file mode 100644 index 0000000000000000000000000000000000000000..ca0582b1a2629dfd5ba81417508395b913ff60fd GIT binary patch literal 5478 zcmeAS@N?(olHy`uVBq!ia0y~yU~m9o4mJh`hEUYlS{wuRI znAvJnzA)MfAB(R)_kmp~)n9Q{j|;QAfx60uED z=feH3|8cj!%ak5^;Zl6do>=Cul?w4@;_s>)pU;-ZQHWHu_XI#98t5I~^)JccL%$?gr6c7yG*IXb3Z3 zU*a*B%U5c5-jxSQPXupVNXXOKefg+G@okmIr%Z0Dc#E??*|yRB;cf9-X`e41+V*V2 z9nRpH3T{81JeINhn{cjFq=RpNGVA^s;Ts+vQ`+w3!z?%}JfM{Q$He%{kF*q4XrFrB zk;1ZVo>1t^`Li9&G7h@9*3NU>RL7~{Vz9QLjfKUb*G2PU;u*IV2P+2A9p{90HZiO$ zYM(6QDs;m_|MHI`8UCrMCG1}w8!>ZEZ4rK^5W=ACcJ$xI7dM<;T^FxXGc7$EHEGEV zlcgz{v0X=xBpGZ?Nz1$0)$JbcpZ9Lw-js7q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@!9;Aw$~zf%CX{xr5&DsP!fKIAgS_|(gMagv2W6T?S{huR z5L$U=uXO!=EfLdzl-rDVz2>o)Y2D0K{jFs;|5&W*Zw{T=s<*ky7#nJZxU+0hcn?@| zmc{*TH9oK?vS!CZfdu1Qe?^@B^ZGCy3)$B%oy99{d(rz@@Qi5^lJ}L&p4uogM7*B( z{&9)w(PMLNXkCrD)8o%@`$I-!s`K10Y^QYY|C{`Y?~@Qa1oZBA4|{p%p}fl?(1?Vm LtDnm{r-UW|a9mQ4 literal 0 HcmV?d00001 diff --git a/StaticData/Icons/Library/hard-drive.svg b/StaticData/Icons/Library/hard-drive.svg new file mode 100644 index 000000000..d86b517a8 --- /dev/null +++ b/StaticData/Icons/Library/hard-drive.svg @@ -0,0 +1,4 @@ + + + + diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 2b3175da4..7402c44c7 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 2b3175da4640913781a8b41e782199bb10c8448b +Subproject commit 7402c44c7895eb96df6abcd48fb760a2f2bcf8d9 From 172e9514a00950850e4362f2d3932a37610a3179 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Thu, 12 Jan 2023 15:09:21 -0800 Subject: [PATCH 3/3] Fixing error with bad bounds --- Submodules/agg-sharp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 7402c44c7..8dcbd0956 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 7402c44c7895eb96df6abcd48fb760a2f2bcf8d9 +Subproject commit 8dcbd095680bdf8c1c3b99dd2bf9b0d48cecb443