diff --git a/src/Mod/Draft/DraftSnap.py b/src/Mod/Draft/DraftSnap.py index 204afde016..63a7425dfd 100644 --- a/src/Mod/Draft/DraftSnap.py +++ b/src/Mod/Draft/DraftSnap.py @@ -987,7 +987,8 @@ class Snapper: self.radius = 0 self.setCursor() if hideSnapBar or Draft.getParam("hideSnapBar",False): - self.toolbar.hide() + if hasattr(self,"toolbar") and self.toolbar: + self.toolbar.hide() self.mask = None self.lastArchPoint = None self.selectMode = False diff --git a/src/Mod/Path/PathScripts/PathDressupHoldingTags.py b/src/Mod/Path/PathScripts/PathDressupHoldingTags.py index 79f55f7351..c5b49c403e 100644 --- a/src/Mod/Path/PathScripts/PathDressupHoldingTags.py +++ b/src/Mod/Path/PathScripts/PathDressupHoldingTags.py @@ -653,7 +653,7 @@ class PathData: def pointIsOnPath(self, p): v = Part.Vertex(FreeCAD.Vector(p.x, p.y, self.minZ)) - PathLog.info("pt = (%f, %f, %f)" % (v.X, v.Y, v.Z)) + PathLog.debug("pt = (%f, %f, %f)" % (v.X, v.Y, v.Z)) for e in self.bottomEdges: indent = "{} ".format(e.distToShape(v)[0]) debugEdge(e, indent, True) diff --git a/src/Mod/Path/PathScripts/PathDressupTagGui.py b/src/Mod/Path/PathScripts/PathDressupTagGui.py index 163c18b44b..6b6a7410a8 100644 --- a/src/Mod/Path/PathScripts/PathDressupTagGui.py +++ b/src/Mod/Path/PathScripts/PathDressupTagGui.py @@ -58,7 +58,7 @@ class PathDressupTagTaskPanel: self.obj.Proxy.obj = obj self.viewProvider = viewProvider self.form = FreeCADGui.PySideUic.loadUi(":/panels/HoldingTagsEdit.ui") - self.getPoint = PathGetPoint.TaskPanel(self.form.removeEditAddGroup) + self.getPoint = PathGetPoint.TaskPanel(self.form.removeEditAddGroup, True) self.jvo = PathUtils.findParentJob(obj).ViewObject if jvoVisibility is None: FreeCAD.ActiveDocument.openTransaction(translate("PathDressup_HoldingTags", "Edit HoldingTags Dress-up")) diff --git a/src/Mod/Path/PathScripts/PathGetPoint.py b/src/Mod/Path/PathScripts/PathGetPoint.py index b4793fc654..4bc53e0937 100644 --- a/src/Mod/Path/PathScripts/PathGetPoint.py +++ b/src/Mod/Path/PathScripts/PathGetPoint.py @@ -25,6 +25,7 @@ import Draft import FreeCAD import FreeCADGui +import PathScripts.PathLog as PathLog from PySide import QtCore, QtGui from pivy import coin @@ -34,6 +35,8 @@ __author__ = "sliptonic (Brad Collette)" __url__ = "http://www.freecadweb.org" __doc__ = "Helper class to use FreeCADGUi.Snapper to let the user enter arbitray points while the task panel is active." +PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule()) + class TaskPanel: '''Use an instance of this class in another TaskPanel to invoke the snapper. Create the instance in the TaskPanel's constructors and invoke getPoint(whenDone, start) whenever a new point is @@ -41,7 +44,7 @@ class TaskPanel: provided in the constructor. The (only) public API function other than the constructor is getPoint(whenDone, start). ''' - def __init__(self, form): + def __init__(self, form, onPath=False): '''__init___(form) ... form will be replaced by PointEdit.ui while the Snapper is active.''' self.formOrig = form self.formPoint = FreeCADGui.PySideUic.loadUi(":/panels/PointEdit.ui") @@ -52,6 +55,8 @@ class TaskPanel: self.setupUi() self.buttonBox = None + self.onPath = onPath + self.obj = None def setupUi(self): '''setupUi() ... internal function - do not call.''' @@ -95,19 +100,34 @@ class TaskPanel: self.formPoint.ifValueX.selectAll() def mouseMove(cb): + p = None event = cb.getEvent() pos = event.getPosition() - cntrl = event.wasCtrlDown() - shift = event.wasShiftDown() - self.pt = FreeCADGui.Snapper.snap(pos, lastpoint=start, active=cntrl, constrain=shift) - plane = FreeCAD.DraftWorkingPlane - p = plane.getLocalCoords(self.pt) - displayPoint(p) + if self.onPath: + screenpos = tuple(pos.getValue()) + snapInfo = Draft.get3DView().getObjectInfo((screenpos[0],screenpos[1])) + if snapInfo: + obj = FreeCAD.ActiveDocument.getObject(snapInfo['Object']) + if hasattr(obj, 'Path'): + self.obj = obj + p = FreeCAD.Vector(snapInfo['x'], snapInfo['y'], snapInfo['z']) + else: + self.obj = None + else: + cntrl = event.wasCtrlDown() + shift = event.wasShiftDown() + self.pt = FreeCADGui.Snapper.snap(pos, lastpoint=start, active=cntrl, constrain=shift) + plane = FreeCAD.DraftWorkingPlane + p = plane.getLocalCoords(self.pt) + self.obj = FreeCADGui.Snapper.lastSnappedObject + if p: + displayPoint(p) def click(cb): event = cb.getEvent() if event.getButton() == 1 and event.getState() == coin.SoMouseButtonEvent.DOWN: - accept() + if self.obj: + accept() def accept(): if start: @@ -137,7 +157,6 @@ class TaskPanel: def pointFinish(self, ok, cleanup = True): '''pointFinish(ok, cleanup=True) ... internal function - do not call.''' - obj = FreeCADGui.Snapper.lastSnappedObject if cleanup: self.removeGlobalCallbacks() @@ -150,7 +169,7 @@ class TaskPanel: self.formOrig.setFocus() if ok: - self.pointWhenDone(self.pt, obj) + self.pointWhenDone(self.pt, self.obj) else: self.pointWhenDone(None, None)