Fix selection boxes occasionally being super hard to resize.

Box was using the wrong plane as the drag reference plane
This commit is contained in:
David Vierra 2015-06-06 19:57:45 -10:00
parent 5de661cab9
commit ac495f1d87

View File

@ -14,7 +14,11 @@ log = logging.getLogger(__name__)
class BoxHandle(scenegraph.Node, QtCore.QObject): class BoxHandle(scenegraph.Node, QtCore.QObject):
# The face that was clicked on
dragResizeFace = None dragResizeFace = None
# The dimension of the imaginary plane perpendicular to the clicked face
# that the drag will move across
dragResizeDimension = None dragResizeDimension = None
dragResizePosition = None dragResizePosition = None
@ -77,15 +81,14 @@ class BoxHandle(scenegraph.Node, QtCore.QObject):
side = self.dragResizeFace & 1 side = self.dragResizeFace & 1
dragdim = self.dragResizeFace >> 1 dragdim = self.dragResizeFace >> 1
origin, size = list(box.origin), list(box.size)
o, s = list(box.origin), list(box.size)
if side: if side:
o[dragdim] += s[dragdim] origin[dragdim] += size[dragdim]
s[dragdim] = 0 size[dragdim] = 0
otherSide = BoundingBox(o, s) otherSide = BoundingBox(origin, size)
o[dragdim] = int(numpy.floor(point[dragdim] + 0.5)) origin[dragdim] = int(numpy.floor(point[dragdim] + 0.5))
thisSide = BoundingBox(o, s) thisSide = BoundingBox(origin, size)
return thisSide.union(otherSide) return thisSide.union(otherSide)
@ -127,9 +130,12 @@ class BoxHandle(scenegraph.Node, QtCore.QObject):
# Choose a dimension perpendicular to the dragged face # Choose a dimension perpendicular to the dragged face
# Try not to pick a dimension close to edge-on with the view vector # Try not to pick a dimension close to edge-on with the view vector
dim = ((face.dimension + 1) % 3) dim = ((face.dimension + 1) % 3)
dim1 = (dim+1) % 3
vector = event.view.cameraVector.abs() vector = event.view.cameraVector.abs()
if vector[dim] < 0.1: if vector[dim1] > vector[dim]:
dim = ((dim+1) % 3) dim = dim1
self.dragResizeDimension = dim self.dragResizeDimension = dim
self.dragResizePosition = point[self.dragResizeDimension] self.dragResizePosition = point[self.dragResizeDimension]