Draft: Don't snap to ImagePlanes
This commit is contained in:
@@ -57,6 +57,7 @@ __title__ = "FreeCAD Draft Snap tools"
|
||||
__author__ = "Yorik van Havre"
|
||||
__url__ = "https://www.freecadweb.org"
|
||||
|
||||
UNSNAPPABLES = ('Image::ImagePlane',)
|
||||
|
||||
class Snapper:
|
||||
"""Classes to manage snapping in Draft and Arch.
|
||||
@@ -125,7 +126,7 @@ class Snapper:
|
||||
|
||||
# snap keys, it's important that they are in this order for
|
||||
# saving in preferences and for properly restoring the toolbar
|
||||
self.snaps = ['Lock', # 0
|
||||
self.snaps = ['Lock', # 0
|
||||
'Near', # 1 former "passive" snap
|
||||
'Extension', # 2
|
||||
'Parallel', # 3
|
||||
@@ -311,6 +312,8 @@ class Snapper:
|
||||
point, eline = self.snapToExtensions(point, lastpoint,
|
||||
constrain, eline)
|
||||
|
||||
# Check if we have an object under the cursor and try to
|
||||
# snap to it
|
||||
_view = Draft.get3DView()
|
||||
objectsUnderCursor = _view.getObjectsInfo((screenpos[0], screenpos[1]))
|
||||
if objectsUnderCursor:
|
||||
@@ -319,8 +322,10 @@ class Snapper:
|
||||
self.snapInfo = objectsUnderCursor[self.snapObjectIndex]
|
||||
|
||||
if self.snapInfo and "Component" in self.snapInfo:
|
||||
return self.snapToObject(lastpoint, active, constrain,
|
||||
osnap = self.snapToObject(lastpoint, active, constrain,
|
||||
eline, point, oldActive)
|
||||
if osnap:
|
||||
return osnap
|
||||
|
||||
# Nothing has been snapped.
|
||||
# Check for grid snap and ext crossings
|
||||
@@ -352,6 +357,7 @@ class Snapper:
|
||||
def snapToObject(self, lastpoint, active, constrain,
|
||||
eline, point, oldActive):
|
||||
"""Snap to an object."""
|
||||
|
||||
parent = self.snapInfo.get('ParentObject', None)
|
||||
if parent:
|
||||
subname = self.snapInfo['SubName']
|
||||
@@ -368,6 +374,9 @@ class Snapper:
|
||||
snaps = []
|
||||
self.lastSnappedObject = obj
|
||||
|
||||
if obj and (Draft.getType(obj) in UNSNAPPABLES):
|
||||
return []
|
||||
|
||||
if hasattr(obj.ViewObject, "Selectable"):
|
||||
if not obj.ViewObject.Selectable:
|
||||
self.spoint = self.cstr(lastpoint, constrain, point)
|
||||
@@ -609,9 +618,9 @@ class Snapper:
|
||||
self.setCursor(tsnap[1])
|
||||
return tsnap[2], eline
|
||||
|
||||
for o in (self.lastObj[1], self.lastObj[0]):
|
||||
if o and (self.isEnabled('Extension')
|
||||
or self.isEnabled('Parallel')):
|
||||
for o in (self.lastObj[1], self.lastObj[0]):
|
||||
if o and (self.isEnabled('Extension')
|
||||
or self.isEnabled('Parallel')):
|
||||
ob = App.ActiveDocument.getObject(o)
|
||||
if not ob:
|
||||
continue
|
||||
@@ -1480,8 +1489,8 @@ class Snapper:
|
||||
Parameters:
|
||||
commands Snap command list,
|
||||
use: get_draft_snap_commands():
|
||||
context The toolbar or action group the buttons have
|
||||
to be added to
|
||||
context The toolbar or action group the buttons have
|
||||
to be added to
|
||||
button_suffix The suffix that have to be applied to the command name
|
||||
to define the button name
|
||||
"""
|
||||
@@ -1492,7 +1501,7 @@ class Snapper:
|
||||
gb = self.init_grid_button(self.toolbar)
|
||||
context.addAction(gb)
|
||||
QtCore.QObject.connect(gb, QtCore.SIGNAL("triggered()"),
|
||||
lambda f=Gui.doCommand,
|
||||
lambda f=Gui.doCommand,
|
||||
arg='Gui.runCommand("Draft_ToggleGrid")':f(arg))
|
||||
continue
|
||||
# setup toolbar buttons
|
||||
@@ -1508,7 +1517,7 @@ class Snapper:
|
||||
context.addAction(b)
|
||||
QtCore.QObject.connect(b,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
lambda f=Gui.doCommand,
|
||||
lambda f=Gui.doCommand,
|
||||
arg=command:f(arg))
|
||||
|
||||
for b in context.actions():
|
||||
@@ -1520,7 +1529,7 @@ class Snapper:
|
||||
"""Add grid button to the given toolbar"""
|
||||
b = QtGui.QAction(context)
|
||||
b.setIcon(QtGui.QIcon.fromTheme("Draft", QtGui.QIcon(":/icons/"
|
||||
"Draft_Grid.svg")))
|
||||
"Draft_Grid.svg")))
|
||||
b.setText(QtCore.QCoreApplication.translate("Draft_Snap", "Toggles Grid On/Off"))
|
||||
b.setToolTip(QtCore.QCoreApplication.translate("Draft_Snap", "Toggle Draft Grid"))
|
||||
b.setObjectName("Grid_Button")
|
||||
@@ -1703,7 +1712,7 @@ class Snapper:
|
||||
self.trackers[8].append(self.extLine2)
|
||||
self.trackers[9].append(self.holdTracker)
|
||||
self.activeview = v
|
||||
|
||||
|
||||
if self.grid and (not self.forceGridOff):
|
||||
self.grid.set()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user