Draft: allow to use different snapping task dialogs
This commit is contained in:
@@ -945,6 +945,9 @@ class DraftToolBar:
|
||||
if p.GetBool("focusOnLength",False) and self.lengthValue.isVisible():
|
||||
self.lengthValue.setFocus()
|
||||
self.lengthValue.selectAll()
|
||||
elif self.angleLock.isVisible() and self.angleLock.isChecked():
|
||||
self.lengthValue.setFocus()
|
||||
self.lengthValue.selectAll()
|
||||
elif f==None or f=="x":
|
||||
self.xValue.setFocus()
|
||||
self.xValue.selectAll()
|
||||
@@ -998,11 +1001,11 @@ class DraftToolBar:
|
||||
self.angleValue.hide()
|
||||
self.angleLock.hide()
|
||||
|
||||
def lineUi(self,title=None):
|
||||
def lineUi(self,title=None,cancel=None,extra=None,getcoords=None,rel=False):
|
||||
if title:
|
||||
self.pointUi(title,icon="Draft_Line")
|
||||
self.pointUi(title,cancel,extra,getcoords,rel,icon="Draft_Line")
|
||||
else:
|
||||
self.pointUi(translate("draft", "Line"),icon="Draft_Line")
|
||||
self.pointUi(translate("draft", "Line"),cancel,extra,getcoords,rel,icon="Draft_Line")
|
||||
self.extraLineUi()
|
||||
self.xValue.setEnabled(True)
|
||||
self.yValue.setEnabled(True)
|
||||
@@ -1010,11 +1013,11 @@ class DraftToolBar:
|
||||
self.undoButton.show()
|
||||
self.continueCmd.show()
|
||||
|
||||
def wireUi(self,title=None):
|
||||
def wireUi(self,title=None,cancel=None,extra=None,getcoords=None,rel=False):
|
||||
if title:
|
||||
self.pointUi(title)
|
||||
self.pointUi(title,cancel,extra,getcoords,rel)
|
||||
else:
|
||||
self.pointUi(translate("draft", "DWire"),icon="Draft_Wire")
|
||||
self.pointUi(translate("draft", "DWire"),cancel,extra,getcoords,rel,icon="Draft_Wire")
|
||||
self.xValue.setEnabled(True)
|
||||
self.yValue.setEnabled(True)
|
||||
self.isRelative.show()
|
||||
|
||||
@@ -1133,10 +1133,10 @@ class Snapper:
|
||||
if self.constrainLine:
|
||||
self.constrainLine.off()
|
||||
|
||||
def getPoint(self,last=None,callback=None,movecallback=None,extradlg=None):
|
||||
def getPoint(self,last=None,callback=None,movecallback=None,extradlg=None,title=None,mode="point"):
|
||||
|
||||
"""
|
||||
getPoint([last],[callback],[movecallback],[extradlg]) : gets a 3D point
|
||||
getPoint([last],[callback],[movecallback],[extradlg],[title]) : gets a 3D point
|
||||
from the screen. You can provide an existing point, in that case additional
|
||||
snap options and a tracker are available.
|
||||
You can also pass a function as callback, which will get called
|
||||
@@ -1155,6 +1155,8 @@ class Snapper:
|
||||
|
||||
If the callback function accepts more than one argument, it will also receive
|
||||
the last snapped object. Finally, a qt widget can be passed as an extra taskbox.
|
||||
title is the title of the point task box
|
||||
mode is the dialog box you want (default is point, you can also use wire and line)
|
||||
|
||||
If getPoint() is invoked without any argument, nothing is done but the callbacks
|
||||
are removed, so it can be used as a cancel function.
|
||||
@@ -1233,8 +1235,17 @@ class Snapper:
|
||||
callback(None)
|
||||
|
||||
# adding callback functions
|
||||
if mode == "line":
|
||||
interface = self.ui.lineUi
|
||||
elif mode == "wire":
|
||||
interface = self.ui.wireUi
|
||||
else:
|
||||
interface = self.ui.pointUi
|
||||
if callback:
|
||||
self.ui.pointUi(cancel=cancel,getcoords=getcoords,extra=extradlg,rel=bool(last))
|
||||
if title:
|
||||
interface(title=title,cancel=cancel,getcoords=getcoords,extra=extradlg,rel=bool(last))
|
||||
else:
|
||||
interface(cancel=cancel,getcoords=getcoords,extra=extradlg,rel=bool(last))
|
||||
self.callbackClick = self.view.addEventCallbackPivy(coin.SoMouseButtonEvent.getClassTypeId(),click)
|
||||
self.callbackMove = self.view.addEventCallbackPivy(coin.SoLocation2Event.getClassTypeId(),move)
|
||||
|
||||
|
||||
@@ -2547,6 +2547,7 @@ class Modifier(DraftTool):
|
||||
|
||||
def __init__(self):
|
||||
DraftTool.__init__(self)
|
||||
self.copymode = False
|
||||
|
||||
class Move(Modifier):
|
||||
"The Draft_Move FreeCAD command definition"
|
||||
@@ -2581,8 +2582,10 @@ class Move(Modifier):
|
||||
self.selected_objects = FreeCADGui.Selection.getSelection()
|
||||
self.selected_objects = Draft.getGroupContents(self.selected_objects, addgroups=True, spaces=True, noarchchild=True)
|
||||
self.selected_subelements = FreeCADGui.Selection.getSelectionEx()
|
||||
self.ui.pointUi(self.name)
|
||||
self.ui.lineUi(self.name)
|
||||
self.ui.modUi()
|
||||
if self.copymode:
|
||||
self.ui.isCopy.setChecked(True)
|
||||
self.ui.xValue.setFocus()
|
||||
self.ui.xValue.selectAll()
|
||||
self.call = self.view.addEventCallback("SoEvent", self.action)
|
||||
|
||||
Reference in New Issue
Block a user