Snapping is finally working well.

This commit is contained in:
larsbrubaker 2016-02-20 09:17:25 -08:00
parent 9d60e4ee6a
commit 3173d056c6
4 changed files with 52 additions and 26 deletions

View file

@ -71,7 +71,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
RGBA_Bytes snapColorBorder = RGBA_Bytes.Red;
if (view3DWidget.DragingPart)
if (view3DWidget.DragingPart && view3DWidget.meshViewerWidget.SnapGridDistance > 0)
{
Vector3 lastHitPosition = view3DWidget.LastHitPosition;
double lineWidth = .5;

View file

@ -850,41 +850,37 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
Vector3 delta = info.hitPosition - CurrentSelectInfo.PlaneDownHitPos;
if (meshViewerWidget.SnapGridDistance > 0)
double snapGridDistance = meshViewerWidget.SnapGridDistance;
if (snapGridDistance > 0)
{
// snap this position to the grid
double snapGridDistance = meshViewerWidget.SnapGridDistance;
AxisAlignedBoundingBox selectedBounds = meshViewerWidget.GetBoundsForSelection();
double xSnapOffset = selectedBounds.minXYZ.x; ;
// snap the x position
if (CurrentSelectInfo.HitQuadrant == HitQuadrant.LB
|| CurrentSelectInfo.HitQuadrant == HitQuadrant.LT)
if (CurrentSelectInfo.HitQuadrant == HitQuadrant.RB
|| CurrentSelectInfo.HitQuadrant == HitQuadrant.RT)
{
double left = selectedBounds.minXYZ.x + delta.x;
double snappedLeft = ((int)((left / snapGridDistance) + .5)) * snapGridDistance;
delta.x = snappedLeft - selectedBounds.minXYZ.x;
}
else
{
double right = selectedBounds.maxXYZ.x - delta.x;
double snappedRight = ((int)((right / snapGridDistance) + .5)) * snapGridDistance;
delta.x = selectedBounds.maxXYZ.x - snappedRight;
// switch to the other side
xSnapOffset = selectedBounds.maxXYZ.x;
}
double xToSnap = xSnapOffset + delta.x;
double snappedX = ((int)((xToSnap / snapGridDistance) + .5)) * snapGridDistance;
delta.x = snappedX - xSnapOffset;
double ySnapOffset = selectedBounds.minXYZ.y; ;
// snap the y position
if (CurrentSelectInfo.HitQuadrant == HitQuadrant.LB
|| CurrentSelectInfo.HitQuadrant == HitQuadrant.RB)
if (CurrentSelectInfo.HitQuadrant == HitQuadrant.LT
|| CurrentSelectInfo.HitQuadrant == HitQuadrant.RT)
{
double bottom = selectedBounds.minXYZ.y + delta.y;
double snappedBottom = ((int)((bottom / snapGridDistance) + .5)) * snapGridDistance;
delta.y = snappedBottom - selectedBounds.minXYZ.y;
}
else
{
double top = selectedBounds.maxXYZ.y + delta.y;
double snappedTop = ((int)((top / snapGridDistance) + .5)) * snapGridDistance;
delta.y = snappedTop - selectedBounds.maxXYZ.y;
// switch to the other side
ySnapOffset = selectedBounds.maxXYZ.y;
}
double yToSnap = ySnapOffset + delta.y;
double snappedY = ((int)((yToSnap / snapGridDistance) + .5)) * snapGridDistance;
delta.y = snappedY - ySnapOffset;
}
// move the mesh back to the new position

View file

@ -4540,3 +4540,33 @@ Translated:Retraction On Tool Change
English:randomize_start
Translated:randomize_start
English:Forces the slicer to attempt to avoid having the perimeter line cross over existing perimeter lines. This can help with oozing or strings.
Translated:Forces the slicer to attempt to avoid having the perimeter line cross over existing perimeter lines. This can help with oozing or strings.
English:The height of the printer's printable volume, in millimeters. Serves no purpose for slicing, but controls the height of the visual print area displayed in 3D View.
Translated:The height of the printer's printable volume, in millimeters. Serves no purpose for slicing, but controls the height of the visual print area displayed in 3D View.
English:The speed at which outside, external, or the otherwise visible perimeters will print.
Translated:The speed at which outside, external, or the otherwise visible perimeters will print.
English:Used to specify if more than one extruder share a common heater cartridge.
Translated:Used to specify if more than one extruder share a common heater cartridge.
English:The actual diameter of the filament used for printing. Measure 5 times with calipers, throw out the top and bottom, and average the remaining 3.
Translated:The actual diameter of the filament used for printing. Measure 5 times with calipers, throw out the top and bottom, and average the remaining 3.
English:The height of the first layer. A first layer taller than the default layer height can ensure good adhesion to the build plate.
Translated:The height of the first layer. A first layer taller than the default layer height can ensure good adhesion to the build plate.
English:The printer has the ability to control the power supply. Enable this function to show the ATX Power Control section on the Controls pane.
Translated:The printer has the ability to control the power supply. Enable this function to show the ATX Power Control section on the Controls pane.
English:The number of loops to draw around parts. Used to provide additional bed adhesion
Translated:The number of loops to draw around parts. Used to provide additional bed adhesion
English:Skirt (Priming)
Translated:Skirt (Priming)
English:Brim (Hold Downs)
Translated:Brim (Hold Downs)

@ -1 +1 @@
Subproject commit 4b393dd15422765d9c8fae81b5e727396aafb340
Subproject commit f34ef1c5b7aee6ea303ee8b26448597229295651