refactoring
This commit is contained in:
parent
d9522fdcac
commit
b7a5436803
6 changed files with 16 additions and 18 deletions
|
|
@ -1103,7 +1103,7 @@ namespace MatterHackers.MatterControl
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If there are no printers setup show the export dialog but have the gcode option disabled
|
// 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)
|
|| ProfileManager.Instance.ActiveProfiles.Count() > 1)
|
||||||
{
|
{
|
||||||
DialogWindow.Show(new ExportPrintItemPage(libraryItems, centerOnBed, null));
|
DialogWindow.Show(new ExportPrintItemPage(libraryItems, centerOnBed, null));
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,9 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ImageContentProvider : ISceneContentProvider
|
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);
|
var imageBuffer = await this.LoadImage(item);
|
||||||
if (imageBuffer != null)
|
if (imageBuffer != null)
|
||||||
|
|
@ -61,7 +61,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
||||||
{
|
{
|
||||||
using (var streamAndLength = await streamInterface.GetStream(null))
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,13 +79,13 @@ namespace MatterHackers
|
||||||
const double OrthographicLargeZRangeScaledDistanceBetweenNearAndObject = 1.0;
|
const double OrthographicLargeZRangeScaledDistanceBetweenNearAndObject = 1.0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public struct Result
|
public struct FitResult
|
||||||
{
|
{
|
||||||
public Vector3 CameraPosition;
|
public Vector3 CameraPosition;
|
||||||
public double OrthographicViewspaceHeight;
|
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[] worldspacePoints = worldspaceAABB.GetCorners();
|
||||||
Vector3[] viewspacePoints = worldspacePoints.Select(x => x.TransformPosition(world.ModelviewMatrix)).ToArray();
|
Vector3[] viewspacePoints = worldspacePoints.Select(x => x.TransformPosition(world.ModelviewMatrix)).ToArray();
|
||||||
|
|
@ -138,10 +138,10 @@ namespace MatterHackers
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Vector3 worldspaceCameraPosition = viewspaceCameraPosition.TransformPosition(world.InverseModelviewMatrix);
|
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);
|
System.Diagnostics.Debug.Assert(!world.IsOrthographic);
|
||||||
|
|
||||||
|
|
@ -169,7 +169,7 @@ namespace MatterHackers
|
||||||
switch (PerspectiveFittingAlgorithm)
|
switch (PerspectiveFittingAlgorithm)
|
||||||
{
|
{
|
||||||
case EPerspectiveFittingAlgorithm.TrialAndError:
|
case EPerspectiveFittingAlgorithm.TrialAndError:
|
||||||
return new Result { CameraPosition = TryPerspectiveCameraFitByIterativeAdjust(world, centerOffsetX, worldspaceAABB) };
|
return new FitResult { CameraPosition = TryPerspectiveCameraFitByIterativeAdjust(world, centerOffsetX, worldspaceAABB) };
|
||||||
case EPerspectiveFittingAlgorithm.Sphere:
|
case EPerspectiveFittingAlgorithm.Sphere:
|
||||||
default:
|
default:
|
||||||
viewspaceCameraPosition = PerspectiveCameraFitToSphere(reducedWorld, viewspaceCenter, viewspacePoints);
|
viewspaceCameraPosition = PerspectiveCameraFitToSphere(reducedWorld, viewspaceCenter, viewspacePoints);
|
||||||
|
|
@ -188,7 +188,7 @@ namespace MatterHackers
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Result { CameraPosition = viewspaceCameraPosition.TransformPosition(world.InverseModelviewMatrix) };
|
return new FitResult { CameraPosition = viewspaceCameraPosition.TransformPosition(world.InverseModelviewMatrix) };
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool NeedsToBeSmaller(RectangleDouble partScreenBounds, RectangleDouble goalBounds)
|
static bool NeedsToBeSmaller(RectangleDouble partScreenBounds, RectangleDouble goalBounds)
|
||||||
|
|
|
||||||
|
|
@ -551,22 +551,22 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||||
// Using fake values for near/far.
|
// Using fake values for near/far.
|
||||||
// ComputeOrthographicCameraFit may move the camera to wherever as long as the scene is centered, then
|
// 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.
|
// 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);
|
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 endViewspaceHeight = tempWorld.NearPlaneHeightInViewspace;
|
||||||
double startViewspaceHeight = world.NearPlaneHeightInViewspace;
|
double startViewspaceHeight = world.NearPlaneHeightInViewspace;
|
||||||
|
|
||||||
AnimateOrthographicTranslationAndHeight(
|
AnimateOrthographicTranslationAndHeight(
|
||||||
world.EyePosition, startViewspaceHeight,
|
world.EyePosition, startViewspaceHeight,
|
||||||
result.CameraPosition, endViewspaceHeight
|
fitResult.CameraPosition, endViewspaceHeight
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CameraFittingUtil.Result result = CameraFittingUtil.ComputePerspectiveCameraFit(world, CenterOffsetX, box);
|
CameraFittingUtil.FitResult fitResult = CameraFittingUtil.ComputePerspectiveCameraFit(world, CenterOffsetX, box);
|
||||||
AnimateTranslation(result.CameraPosition, world.EyePosition);
|
AnimateTranslation(fitResult.CameraPosition, world.EyePosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,8 +69,6 @@ namespace MatterHackers.MatterControl
|
||||||
|
|
||||||
private static RaygunClient _raygunClient;
|
private static RaygunClient _raygunClient;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[DllImport("Shcore.dll")]
|
[DllImport("Shcore.dll")]
|
||||||
static extern int SetProcessDpiAwareness(int PROCESS_DPI_AWARENESS);
|
static extern int SetProcessDpiAwareness(int PROCESS_DPI_AWARENESS);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 90fc0d026d710888e4ed65adc57c28f239334f09
|
Subproject commit 2b3175da4640913781a8b41e782199bb10c8448b
|
||||||
Loading…
Add table
Add a link
Reference in a new issue