0000908: Ability to lock snap angle in Draft by pressing L

By pressing the L key while drawing with the Draft workbench, the
current angle shown on screen is kept, until L is pressed again.
This commit is contained in:
Yorik van Havre 2013-09-15 17:39:27 -03:00
parent 42fdbefc54
commit 1f479d513d
2 changed files with 22 additions and 3 deletions

View File

@ -1139,7 +1139,10 @@ class DraftToolBar:
self.displayPoint()
elif txt.endsWith("z"):
self.constrain("z")
self.displayPoint()
self.displayPoint()
elif txt.endsWith("l"):
self.constrain("angle")
self.displayPoint()
elif txt.endsWith("c"):
if self.closeButton.isVisible():
self.closeLine()
@ -1362,7 +1365,9 @@ class DraftToolBar:
FreeCADGui.Snapper.showradius()
def constrain(self,val):
if self.mask == val:
if val == "angle":
FreeCADGui.Snapper.setAngle()
elif self.mask == val:
self.mask = None
if hasattr(FreeCADGui,"Snapper"):
FreeCADGui.Snapper.mask = None

View File

@ -764,6 +764,13 @@ class Snapper:
self.toolbar.hide()
self.mask = None
self.lastArchPoint = None
def setAngle(self):
"keeps the current angle"
if isinstance(self.mask,FreeCAD.Vector):
self.mask = None
elif self.trackLine.Visible:
self.mask = self.trackLine.p2().sub(self.trackLine.p1())
def constrain(self,point,basepoint=None,axis=None):
'''constrain(point,basepoint=None,axis=None: Returns a
@ -809,8 +816,15 @@ class Snapper:
self.constraintAxis = FreeCAD.DraftWorkingPlane.u
elif self.affinity == "y":
self.constraintAxis = FreeCAD.DraftWorkingPlane.v
else:
elif self.affinity == "z":
self.constraintAxis = FreeCAD.DraftWorkingPlane.axis
elif isinstance(self.affinity,FreeCAD.Vector):
self.constraintAxis = self.affinity
else:
self.constraintAxis = None
if not self.constraintAxis:
return point
# calculating constrained point
cdelta = DraftVecUtils.project(delta,self.constraintAxis)