Draft: allow to use different snapping task dialogs

This commit is contained in:
Yorik van Havre
2019-05-10 22:27:08 -03:00
parent eb47cf84a0
commit d72d5a5b21
3 changed files with 27 additions and 10 deletions

View File

@@ -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()

View File

@@ -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)

View File

@@ -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)