Improved leveling polygon selection
Limit recalculating slice settings display
This commit is contained in:
parent
85754f8ea3
commit
90177b9d95
5 changed files with 48 additions and 18 deletions
|
|
@ -41,11 +41,9 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
{
|
||||
private Vector2 bedSize;
|
||||
private Dictionary<(int, int), int> positionToRegion = new Dictionary<(int, int), int>();
|
||||
private PrinterConfig printer;
|
||||
|
||||
public LevelingFunctions(PrinterConfig printer, PrintLevelingData levelingData)
|
||||
{
|
||||
this.printer = printer;
|
||||
this.SampledPositions = new List<Vector3>(levelingData.SampledPositions);
|
||||
|
||||
bedSize = printer.Settings.GetValue<Vector2>(SettingsKey.bed_size);
|
||||
|
|
@ -186,6 +184,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
|
||||
private LevelingTriangle GetCorrectRegion(Vector3 currentDestination)
|
||||
{
|
||||
var position2D = new Vector2(currentDestination);
|
||||
int xIndex = (int)Math.Round(currentDestination.X * 100 / bedSize.X);
|
||||
int yIndex = (int)Math.Round(currentDestination.Y * 100 / bedSize.Y);
|
||||
|
||||
|
|
@ -198,12 +197,13 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
currentDestination.Z = 0;
|
||||
for (int regionIndex = 0; regionIndex < Regions.Count; regionIndex++)
|
||||
{
|
||||
var dist = (Regions[regionIndex].Center - currentDestination).LengthSquared;
|
||||
if (Regions[regionIndex].PointInPolyXY(currentDestination.X, currentDestination.Y))
|
||||
if (Regions[regionIndex].PointInPolyXY(position2D))
|
||||
{
|
||||
// we found the one it is in
|
||||
return Regions[regionIndex];
|
||||
}
|
||||
|
||||
var dist = Regions[regionIndex].DistanceXY(position2D);
|
||||
if (dist < bestDist)
|
||||
{
|
||||
bestIndex = regionIndex;
|
||||
|
|
@ -236,9 +236,9 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
|
||||
public Vector3 GetPositionWithZOffset(Vector3 currentDestination)
|
||||
{
|
||||
var destinationAtZ0 = new Vector3(currentDestination.X, currentDestination.Y, 0);
|
||||
|
||||
var destinationAtZ0 = new Vector3(currentDestination.X, currentDestination.Y, 0);
|
||||
double hitDistance = this.Plane.GetDistanceToIntersection(destinationAtZ0, Vector3.UnitZ);
|
||||
|
||||
currentDestination.Z += hitDistance;
|
||||
|
||||
return currentDestination;
|
||||
|
|
@ -254,16 +254,28 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
return -1;
|
||||
}
|
||||
|
||||
public bool PointInPolyXY(double x, double y)
|
||||
public double DistanceXY(Vector2 position)
|
||||
{
|
||||
var vertex0 = new Vector2(V0[0], V0[1]);
|
||||
var vertex1 = new Vector2(V1[0], V1[1]);
|
||||
var vertex2 = new Vector2(V2[0], V2[1]);
|
||||
|
||||
var distToEdge0 = Vector2.DistancePointToLine(position, vertex0, vertex1);
|
||||
var distToEdge1 = Vector2.DistancePointToLine(position, vertex1, vertex2);
|
||||
var distToEdge2 = Vector2.DistancePointToLine(position, vertex2, vertex0);
|
||||
|
||||
return Math.Min(distToEdge0, Math.Min(distToEdge1, distToEdge2));
|
||||
}
|
||||
|
||||
public bool PointInPolyXY(Vector2 position)
|
||||
{
|
||||
// check the bounding rect
|
||||
Vector2 vertex0 = new Vector2(V0[0], V0[1]);
|
||||
Vector2 vertex1 = new Vector2(V1[0], V1[1]);
|
||||
Vector2 vertex2 = new Vector2(V2[0], V2[1]);
|
||||
Vector2 hitPosition = new Vector2(x, y);
|
||||
int sumOfLineSides = FindSideOfLine(vertex0, vertex1, hitPosition);
|
||||
sumOfLineSides += FindSideOfLine(vertex1, vertex2, hitPosition);
|
||||
sumOfLineSides += FindSideOfLine(vertex2, vertex0, hitPosition);
|
||||
var vertex0 = new Vector2(V0[0], V0[1]);
|
||||
var vertex1 = new Vector2(V1[0], V1[1]);
|
||||
var vertex2 = new Vector2(V2[0], V2[1]);
|
||||
int sumOfLineSides = FindSideOfLine(vertex0, vertex1, position);
|
||||
sumOfLineSides += FindSideOfLine(vertex1, vertex2, position);
|
||||
sumOfLineSides += FindSideOfLine(vertex2, vertex0, position);
|
||||
if (sumOfLineSides == -3 || sumOfLineSides == 3)
|
||||
{
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ namespace MatterHackers.MatterControl.Library.Export
|
|||
return null;
|
||||
}
|
||||
}
|
||||
else if (firstItem.AssetPath == Printer.Bed.EditContext.SourceFilePath)
|
||||
else if (assetStream?.ContentType == "mcx")
|
||||
{
|
||||
// If item is bedplate, save any pending changes before starting the print
|
||||
await ApplicationController.Instance.Tasks.Execute("Saving".Localize(), Printer, Printer.Bed.SaveChanges);
|
||||
|
|
|
|||
|
|
@ -632,6 +632,23 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
FinishProjectionSwitch();
|
||||
|
||||
var rayAtMousePosition = world.GetRayForLocalBounds(mousePosition);
|
||||
|
||||
// TODO:
|
||||
// Check if we are in a GCode View
|
||||
var showingGCode = false;
|
||||
if (showingGCode)
|
||||
{
|
||||
// find the layer height that we are currenly showing
|
||||
// create a plane at that height
|
||||
// check if the ray intersects this plane
|
||||
// if we are above the plane set our origin to this intersection
|
||||
// if we are below the plane set it as a limit to the cast distance distance
|
||||
|
||||
// Consideration: Think about what to do if we would be hitting the top of the part that is the layer height plane.
|
||||
// The issue is that there is no mesh geometry at that height but the user will see gcode that they might think
|
||||
// they should be able to click on.
|
||||
}
|
||||
|
||||
var intersectionInfo = Object3DControlLayer.Scene.GetBVHData().GetClosestIntersection(rayAtMousePosition);
|
||||
var rayAtScreenCenter = world.GetRayForLocalBounds(new Vector2(Width / 2, Height / 2));
|
||||
if (intersectionInfo != null)
|
||||
|
|
|
|||
|
|
@ -471,10 +471,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
{
|
||||
var data = GetStyleData(printer, theme, settingsContext, settingData.SlicerConfigName, settingData.ShowAsOverride);
|
||||
|
||||
if (this.HighlightColor != data.highlightColor)
|
||||
if (this.HighlightColor != data.highlightColor
|
||||
&& this.Parent != null)
|
||||
{
|
||||
this.HighlightColor = data.highlightColor;
|
||||
// make sur the value is also updated
|
||||
// make sure the value is also updated
|
||||
printer.Settings.OnSettingChanged(settingData.SlicerConfigName);
|
||||
}
|
||||
if (restoreButton != null)
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 1fca5e0a2e913392761a3cb5fc6ab9f8abbc1c52
|
||||
Subproject commit 444ce54704973489addef582e27353a0f84b59ac
|
||||
Loading…
Add table
Add a link
Reference in a new issue