Merge pull request #5415 from larsbrubaker/main

main
This commit is contained in:
Lars Brubaker 2023-01-12 15:09:49 -08:00 committed by GitHub
commit 5754796ac7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 39 additions and 19 deletions

View file

@ -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));

View file

@ -44,9 +44,9 @@ namespace MatterHackers.MatterControl.DesignTools
/// </summary>
public class ImageContentProvider : ISceneContentProvider
{
public Task<IObject3D> CreateItem(ILibraryItem item, Action<double, string> reporter)
public async Task<IObject3D> CreateItem(ILibraryItem item, Action<double, string> reporter)
{
return Task.Run<IObject3D>(async () =>
return await Task.Run<IObject3D>(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);
}
}

View file

@ -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");

View file

@ -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)

View file

@ -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);
}
}

View file

@ -69,8 +69,6 @@ namespace MatterHackers.MatterControl
private static RaygunClient _raygunClient;
[DllImport("Shcore.dll")]
static extern int SetProcessDpiAwareness(int PROCESS_DPI_AWARENESS);

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="1200pt" height="1200pt" version="1.1" viewBox="0 0 1200 1200" xmlns="http://www.w3.org/2000/svg">
<path d="m1195.7 774.73-170.89-590.41c-8.375-24.121-31.105-40.297-56.652-40.32h-736.31c-26.039 0.16797-49.055 16.992-57.121 41.762l-170.4 588.48c-2.8906 9.3242-4.3555 19.043-4.3203 28.801v204.96c0 53.016 42.984 96 96 96h1008c53.016 0 96-42.984 96-96v-204.96c-0.023438-9.6094-1.4766-19.152-4.3086-28.309zm-974.89-574.57c1.6094-4.7656 6.0117-8.0156 11.039-8.1602h736.32c4.6797-0.097656 8.9883 2.5195 11.039 6.7188l152.16 525.59c-8.8672-2.7383-18.082-4.1875-27.359-4.3086h-1008c-9.2773 0.12109-18.504 1.5703-27.359 4.3086zm931.2 807.84c0 26.508-21.492 48-48 48h-1008c-26.508 0-48-21.492-48-48v-192c0-26.508 21.492-48 48-48h1008c26.508 0 48 21.492 48 48zm-912-96c0 26.508-21.492 48-48 48s-48-21.492-48-48 21.492-48 48-48 48 21.492 48 48zm144 0c0 26.508-21.492 48-48 48s-48-21.492-48-48 21.492-48 48-48 48 21.492 48 48zm144 0c0 26.508-21.492 48-48 48s-48-21.492-48-48 21.492-48 48-48 48 21.492 48 48zm96-48h432v48h-432z"/>
</svg>

After

Width:  |  Height:  |  Size: 1 KiB

@ -1 +1 @@
Subproject commit 90fc0d026d710888e4ed65adc57c28f239334f09
Subproject commit 8dcbd095680bdf8c1c3b99dd2bf9b0d48cecb443