Added support in DraftGui.todo.delay function to accept any number of arguments.
This commit is contained in:
committed by
Yorik van Havre
parent
c4fc02cbcf
commit
dc4fa6e804
@@ -2,7 +2,7 @@
|
||||
|
||||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2009 Yorik van Havre <yorik@uncreated.net> *
|
||||
#* Copyright (c) 2009 Yorik van Havre <yorik@uncreated.net> *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
#* it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||
@@ -31,7 +31,7 @@ __url__ = ["http://www.freecadweb.org"]
|
||||
# \brief GUI elements and utilities of the Draft workbench
|
||||
#
|
||||
# This module provides GUI tools for the Draft workbench, such as
|
||||
# toolbars and task panels, and Qt-dependent utilities such as
|
||||
# toolbars and task panels, and Qt-dependent utilities such as
|
||||
# a delayed (todo) commit system
|
||||
|
||||
'''
|
||||
@@ -123,7 +123,7 @@ class todo:
|
||||
itinerary = []
|
||||
commitlist = []
|
||||
afteritinerary = []
|
||||
|
||||
|
||||
@staticmethod
|
||||
def doTasks():
|
||||
#print("debug: doing delayed tasks: commitlist: ",todo.commitlist," itinerary: ",todo.itinerary)
|
||||
@@ -132,7 +132,7 @@ class todo:
|
||||
try:
|
||||
# print("debug: executing",f)
|
||||
if arg:
|
||||
f(arg)
|
||||
f(*arg)
|
||||
else:
|
||||
f()
|
||||
except:
|
||||
@@ -176,7 +176,7 @@ class todo:
|
||||
todo.afteritinerary = []
|
||||
|
||||
@staticmethod
|
||||
def delay (f, arg):
|
||||
def delay (f, *arg):
|
||||
# print("debug: delaying",f)
|
||||
if todo.itinerary == []:
|
||||
QtCore.QTimer.singleShot(0, todo.doTasks)
|
||||
@@ -212,9 +212,9 @@ def getDefaultUnit(dim):
|
||||
else:
|
||||
UOM = "xx"
|
||||
return UOM
|
||||
|
||||
|
||||
def makeFormatSpec(decimals=4,dim='Length'):
|
||||
''' return a % format spec with specified decimals for a specified
|
||||
''' return a % format spec with specified decimals for a specified
|
||||
dimension based on on user preference Units Schema'''
|
||||
if dim == 'Length':
|
||||
fmtSpec = "%." + str(decimals) + "f "+ getDefaultUnit('Length')
|
||||
@@ -225,7 +225,7 @@ def makeFormatSpec(decimals=4,dim='Length'):
|
||||
return fmtSpec
|
||||
|
||||
def displayExternal(internValue,decimals=None,dim='Length',showUnit=True,unit=None):
|
||||
'''return an internal value (ie mm) Length or Angle converted for display according
|
||||
'''return an internal value (ie mm) Length or Angle converted for display according
|
||||
to Units Schema in use. Unit can be used to force the value to express in a certain unit'''
|
||||
from FreeCAD import Units
|
||||
if dim == 'Length':
|
||||
@@ -268,7 +268,7 @@ class DraftDockWidget(QtGui.QWidget):
|
||||
self.emit(QtCore.SIGNAL("retranslate()"))
|
||||
else:
|
||||
QtGui.QWidget.changeEvent(self,event)
|
||||
|
||||
|
||||
class DraftLineEdit(QtGui.QLineEdit):
|
||||
"custom QLineEdit widget that has the power to catch Escape keypress"
|
||||
def __init__(self, parent=None):
|
||||
@@ -343,7 +343,7 @@ class DraftToolBar:
|
||||
self.uiloader = FreeCADGui.UiLoader()
|
||||
self.autogroup = None
|
||||
self.isCenterPlane = False
|
||||
|
||||
|
||||
if self.taskmode:
|
||||
# add only a dummy widget, since widgets are created on demand
|
||||
self.baseWidget = QtGui.QWidget()
|
||||
@@ -360,7 +360,7 @@ class DraftToolBar:
|
||||
self.tray.show()
|
||||
|
||||
else:
|
||||
# create the draft Toolbar
|
||||
# create the draft Toolbar
|
||||
self.draftWidget = QtGui.QDockWidget()
|
||||
self.baseWidget = DraftDockWidget()
|
||||
self.draftWidget.setObjectName("draftToolbar")
|
||||
@@ -369,7 +369,7 @@ class DraftToolBar:
|
||||
self.mw = FreeCADGui.getMainWindow()
|
||||
self.mw.addDockWidget(QtCore.Qt.TopDockWidgetArea,self.draftWidget)
|
||||
self.draftWidget.setVisible(False)
|
||||
self.draftWidget.toggleViewAction().setVisible(False)
|
||||
self.draftWidget.toggleViewAction().setVisible(False)
|
||||
self.baseWidget.setObjectName("draftToolbar")
|
||||
self.layout = QtGui.QHBoxLayout(self.baseWidget)
|
||||
self.layout.setObjectName("layout")
|
||||
@@ -379,7 +379,7 @@ class DraftToolBar:
|
||||
self.setupTray()
|
||||
self.setupStyle()
|
||||
self.retranslateUi(self.baseWidget)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# General UI setup
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -459,10 +459,10 @@ class DraftToolBar:
|
||||
cb.setObjectName(name)
|
||||
if hide: cb.hide()
|
||||
layout.addWidget(cb)
|
||||
|
||||
|
||||
def setupToolBar(self,task=False):
|
||||
"sets the draft toolbar up"
|
||||
|
||||
|
||||
# command
|
||||
|
||||
self.promptlabel = self._label("promptlabel", self.layout, hide=task)
|
||||
@@ -500,11 +500,11 @@ class DraftToolBar:
|
||||
self.zValue = self._inputfield("zValue", zl)
|
||||
self.zValue.setText(FreeCAD.Units.Quantity(0,FreeCAD.Units.Length).UserString)
|
||||
self.pointButton = self._pushbutton("addButton", bl, icon="Draft_AddPoint", width=100)
|
||||
|
||||
|
||||
# text
|
||||
|
||||
|
||||
self.textValue = self._lineedit("textValue", self.layout)
|
||||
|
||||
|
||||
# additional line controls
|
||||
|
||||
ll = QtGui.QHBoxLayout()
|
||||
@@ -520,28 +520,28 @@ class DraftToolBar:
|
||||
self.angleValue.setText(FreeCAD.Units.Quantity(0,FreeCAD.Units.Angle).UserString)
|
||||
|
||||
# shapestring
|
||||
|
||||
|
||||
self.labelSSize = self._label("labelSize", self.layout)
|
||||
self.SSizeValue = self._inputfield("SSizeValue", self.layout) #, width=60)
|
||||
self.SSizeValue = self._inputfield("SSizeValue", self.layout) #, width=60)
|
||||
self.SSizeValue.setText(FreeCAD.Units.Quantity(1,FreeCAD.Units.Length).UserString)
|
||||
self.labelSTrack = self._label("labelTracking", self.layout)
|
||||
self.STrackValue = self._inputfield("STrackValue", self.layout) #, width=60)
|
||||
self.STrackValue = self._inputfield("STrackValue", self.layout) #, width=60)
|
||||
self.STrackValue.setText(FreeCAD.Units.Quantity(0,FreeCAD.Units.Length).UserString)
|
||||
self.labelSString = self._label("labelString", self.layout)
|
||||
self.SStringValue = self._lineedit("SStringValue", self.layout)
|
||||
self.SStringValue = self._lineedit("SStringValue", self.layout)
|
||||
self.SStringValue.setText("")
|
||||
self.labelFFile = self._label("labelFFile", self.layout)
|
||||
self.FFileValue = self._lineedit("FFileValue", self.layout)
|
||||
self.chooserButton = self._pushbutton("chooserButton", self.layout, width=26)
|
||||
self.chooserButton.setText("...")
|
||||
self.SSize = 1
|
||||
self.STrack = 0
|
||||
|
||||
self.STrack = 0
|
||||
|
||||
# options
|
||||
|
||||
|
||||
fl = QtGui.QHBoxLayout()
|
||||
self.layout.addLayout(fl)
|
||||
self.numFacesLabel = self._label("numfaceslabel", fl)
|
||||
self.layout.addLayout(fl)
|
||||
self.numFacesLabel = self._label("numfaceslabel", fl)
|
||||
self.numFaces = self._spinbox("numFaces", fl, 3)
|
||||
ol = QtGui.QHBoxLayout()
|
||||
self.layout.addLayout(ol)
|
||||
@@ -588,14 +588,14 @@ class DraftToolBar:
|
||||
spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum,
|
||||
QtGui.QSizePolicy.Expanding)
|
||||
self.layout.addItem(spacerItem)
|
||||
|
||||
|
||||
|
||||
QtCore.QObject.connect(self.xValue,QtCore.SIGNAL("valueChanged(double)"),self.changeXValue)
|
||||
QtCore.QObject.connect(self.yValue,QtCore.SIGNAL("valueChanged(double)"),self.changeYValue)
|
||||
QtCore.QObject.connect(self.zValue,QtCore.SIGNAL("valueChanged(double)"),self.changeZValue)
|
||||
QtCore.QObject.connect(self.lengthValue,QtCore.SIGNAL("valueChanged(double)"),self.changeLengthValue)
|
||||
QtCore.QObject.connect(self.angleValue,QtCore.SIGNAL("valueChanged(double)"),self.changeAngleValue)
|
||||
QtCore.QObject.connect(self.angleLock,QtCore.SIGNAL("stateChanged(int)"),self.toggleAngle)
|
||||
QtCore.QObject.connect(self.angleLock,QtCore.SIGNAL("stateChanged(int)"),self.toggleAngle)
|
||||
QtCore.QObject.connect(self.radiusValue,QtCore.SIGNAL("valueChanged(double)"),self.changeRadiusValue)
|
||||
QtCore.QObject.connect(self.offsetValue,QtCore.SIGNAL("valueChanged(double)"),self.changeOffsetValue)
|
||||
QtCore.QObject.connect(self.xValue,QtCore.SIGNAL("returnPressed()"),self.checkx)
|
||||
@@ -634,7 +634,7 @@ class DraftToolBar:
|
||||
QtCore.QObject.connect(self.continueCmd,QtCore.SIGNAL("stateChanged(int)"),self.setContinue)
|
||||
QtCore.QObject.connect(self.isCopy,QtCore.SIGNAL("stateChanged(int)"),self.setCopymode)
|
||||
QtCore.QObject.connect(self.isRelative,QtCore.SIGNAL("stateChanged(int)"),self.setRelative)
|
||||
QtCore.QObject.connect(self.hasFill,QtCore.SIGNAL("stateChanged(int)"),self.setFill)
|
||||
QtCore.QObject.connect(self.hasFill,QtCore.SIGNAL("stateChanged(int)"),self.setFill)
|
||||
QtCore.QObject.connect(self.currentViewButton,QtCore.SIGNAL("clicked()"),self.selectCurrentView)
|
||||
QtCore.QObject.connect(self.resetPlaneButton,QtCore.SIGNAL("clicked()"),self.selectResetPlane)
|
||||
QtCore.QObject.connect(self.baseWidget,QtCore.SIGNAL("resized()"),self.relocate)
|
||||
@@ -648,8 +648,8 @@ class DraftToolBar:
|
||||
QtCore.QObject.connect(self.FFileValue,QtCore.SIGNAL("returnPressed()"),self.validateFile)
|
||||
QtCore.QObject.connect(self.gridValue,QtCore.SIGNAL("textEdited(QString)"),self.setGridSize)
|
||||
QtCore.QObject.connect(self.mainlineValue,QtCore.SIGNAL("valueChanged(int)"),self.setMainline)
|
||||
QtCore.QObject.connect(self.centerPlane,QtCore.SIGNAL("stateChanged(int)"),self.setCenterPlane)
|
||||
|
||||
QtCore.QObject.connect(self.centerPlane,QtCore.SIGNAL("stateChanged(int)"),self.setCenterPlane)
|
||||
|
||||
# following lines can cause a crash and are not needed anymore when using the task panel
|
||||
# http://forum.freecadweb.org/viewtopic.php?f=3&t=6952
|
||||
#QtCore.QObject.connect(self.FFileValue,QtCore.SIGNAL("escaped()"),self.escape)
|
||||
@@ -664,7 +664,7 @@ class DraftToolBar:
|
||||
# if Ui changed to have Size & Track visible at same time, use this
|
||||
#QtCore.QObject.connect(self.SSizeValue,QtCore.SIGNAL("returnPressed()"),self.checkSSize)
|
||||
#QtCore.QObject.connect(self.STrackValue,QtCore.SIGNAL("returnPressed()"),self.checkSTrack)
|
||||
|
||||
|
||||
def setupTray(self):
|
||||
"sets draft tray buttons up"
|
||||
|
||||
@@ -696,7 +696,7 @@ class DraftToolBar:
|
||||
self.applyButton = self._pushbutton("applyButton", self.toptray, hide=False, icon='Draft_Apply',width=22)
|
||||
self.autoGroupButton = self._pushbutton("autoGroup",self.bottomtray,icon="Draft_AutoGroup_off",hide=False,width=120)
|
||||
self.autoGroupButton.setText("None")
|
||||
|
||||
|
||||
self.wplabel.setToolTip(translate("draft", "Current working plane:",utf8_decode=True)+self.wplabel.text())
|
||||
self.constrButton.setToolTip(translate("draft", "Toggle construction mode"))
|
||||
self.colorButton.setToolTip(translate("draft", "Current line color"))
|
||||
@@ -730,7 +730,7 @@ class DraftToolBar:
|
||||
#---------------------------------------------------------------------------
|
||||
# language tools
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def retranslateUi(self, widget=None):
|
||||
self.promptlabel.setText(translate("draft", "active command:"))
|
||||
self.cmdlabel.setText(translate("draft", "None"))
|
||||
@@ -804,7 +804,7 @@ class DraftToolBar:
|
||||
self.mainlineLabel.setText(translate("draft", "Main line every"))
|
||||
self.mainlineValue.setToolTip(translate("draft", "The number of lines between main lines"))
|
||||
self.centerPlane.setText(translate("draft", "Center plane on view"))
|
||||
|
||||
|
||||
# Update the maximum width of the push buttons
|
||||
maxwidth = 66 # that's the default
|
||||
pb = []
|
||||
@@ -812,12 +812,12 @@ class DraftToolBar:
|
||||
w = self.layout.itemAt(i).widget()
|
||||
if w != None and w.inherits('QPushButton'):
|
||||
pb.append(w)
|
||||
|
||||
|
||||
for i in pb:
|
||||
fm = QtGui.QFontMetrics(i.font())
|
||||
fw = fm.width(i.text())
|
||||
fw = max(fw, maxwidth)
|
||||
|
||||
|
||||
maxwidth = maxwidth + 16 +10 # add icon width and a margin
|
||||
for i in pb:
|
||||
i.setMaximumWidth(maxwidth)
|
||||
@@ -862,11 +862,11 @@ class DraftToolBar:
|
||||
FreeCADGui.Control.closeDialog()
|
||||
todo.delay(FreeCADGui.Control.showDialog,dummy(extra))
|
||||
self.setTitle(title)
|
||||
|
||||
|
||||
def redraw(self):
|
||||
"utility function that is performed after each clicked point"
|
||||
self.checkLocal()
|
||||
|
||||
|
||||
def setFocus(self):
|
||||
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
|
||||
if p.GetBool("focusOnLength",False):
|
||||
@@ -894,7 +894,7 @@ class DraftToolBar:
|
||||
p = Draft.getParam("gridEvery",10)
|
||||
self.mainlineValue.setValue(p)
|
||||
self.centerPlane.show()
|
||||
|
||||
|
||||
def extraLineUi(self):
|
||||
'''shows length and angle controls'''
|
||||
self.labellength.show()
|
||||
@@ -946,7 +946,7 @@ class DraftToolBar:
|
||||
self.orientWPButton.show()
|
||||
self.undoButton.show()
|
||||
self.continueCmd.show()
|
||||
|
||||
|
||||
def circleUi(self):
|
||||
self.pointUi(translate("draft", "Circle"),icon="Draft_Circle")
|
||||
self.continueCmd.show()
|
||||
@@ -983,7 +983,7 @@ class DraftToolBar:
|
||||
todo.delay(self.setFocus,None)
|
||||
self.xValue.selectAll()
|
||||
self.showCommandOptions(title)
|
||||
|
||||
|
||||
def labelUi(self,title=translate("draft","Label"),callback=None):
|
||||
w = QtGui.QWidget()
|
||||
w.setWindowTitle(translate("draft","Label type", utf8_decode=True))
|
||||
@@ -1064,7 +1064,7 @@ class DraftToolBar:
|
||||
self.mainlineLabel.hide()
|
||||
self.mainlineValue.hide()
|
||||
self.centerPlane.hide()
|
||||
|
||||
|
||||
def trimUi(self,title=translate("draft","Trim")):
|
||||
self.taskUi(title)
|
||||
self.radiusUi()
|
||||
@@ -1089,7 +1089,7 @@ class DraftToolBar:
|
||||
self.textline=0
|
||||
self.continueCmd.show()
|
||||
|
||||
def SSUi(self):
|
||||
def SSUi(self):
|
||||
''' set up ui for ShapeString text entry '''
|
||||
self.hideXYZ()
|
||||
self.labelSString.show()
|
||||
@@ -1116,7 +1116,7 @@ class DraftToolBar:
|
||||
self.STrackValue.setText(FreeCAD.Units.Quantity(0,FreeCAD.Units.Length).UserString)
|
||||
self.STrackValue.show()
|
||||
todo.delay(self.STrackValue.setFocus,None)
|
||||
|
||||
|
||||
def SFileUi(self):
|
||||
''' set up UI for ShapeString font file selection '''
|
||||
self.labelSTrack.hide()
|
||||
@@ -1127,7 +1127,7 @@ class DraftToolBar:
|
||||
self.FFileValue.show()
|
||||
self.chooserButton.show()
|
||||
todo.delay(self.FFileValue.setFocus,None)
|
||||
|
||||
|
||||
def switchUi(self,store=True):
|
||||
if store:
|
||||
self.state = []
|
||||
@@ -1259,7 +1259,7 @@ class DraftToolBar:
|
||||
self.relativeMode = bool(val)
|
||||
if (not self.taskmode) or self.isTaskOn:
|
||||
self.isRelative.show()
|
||||
|
||||
|
||||
def setCopymode(self,val=0):
|
||||
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
|
||||
p.SetBool("copymodeValue",bool(val))
|
||||
@@ -1286,7 +1286,7 @@ class DraftToolBar:
|
||||
FreeCADGui.Control.closeDialog()
|
||||
panel = TaskPanel(extra,callback)
|
||||
FreeCADGui.Control.showDialog(panel)
|
||||
|
||||
|
||||
def setGridSize(self,text):
|
||||
"sets the Draft grid to the given grid size"
|
||||
try:
|
||||
@@ -1297,14 +1297,14 @@ class DraftToolBar:
|
||||
Draft.setParam("gridSpacing",q.Value)
|
||||
if hasattr(FreeCADGui,"Snapper"):
|
||||
FreeCADGui.Snapper.setGrid()
|
||||
|
||||
|
||||
def setMainline(self,val):
|
||||
"sets the grid main lines"
|
||||
if val > 1:
|
||||
Draft.setParam("gridEvery",val)
|
||||
if hasattr(FreeCADGui,"Snapper"):
|
||||
FreeCADGui.Snapper.setGrid()
|
||||
|
||||
|
||||
def setCenterPlane(self,val):
|
||||
self.isCenterPlane = bool(val)
|
||||
|
||||
@@ -1366,7 +1366,7 @@ class DraftToolBar:
|
||||
|
||||
def setFill(self,val):
|
||||
self.fillmode = bool(val)
|
||||
|
||||
|
||||
def apply(self):
|
||||
for i in FreeCADGui.Selection.getSelection():
|
||||
Draft.formatObject(i)
|
||||
@@ -1386,7 +1386,7 @@ class DraftToolBar:
|
||||
self.updateSnapper()
|
||||
else:
|
||||
self.validatePoint()
|
||||
|
||||
|
||||
def checkangle(self):
|
||||
self.angleValue.setFocus()
|
||||
self.angleValue.selectAll()
|
||||
@@ -1450,12 +1450,12 @@ class DraftToolBar:
|
||||
|
||||
def validateSNumeric(self):
|
||||
''' send valid numeric parameters to ShapeString '''
|
||||
if self.sourceCmd:
|
||||
if self.sourceCmd:
|
||||
if (self.labelSSize.isVisible()):
|
||||
try:
|
||||
SSize=float(self.SSize)
|
||||
except ValueError:
|
||||
FreeCAD.Console.PrintMessage(translate("draft", "Invalid Size value. Using 200.0."))
|
||||
FreeCAD.Console.PrintMessage(translate("draft", "Invalid Size value. Using 200.0."))
|
||||
self.sourceCmd.numericSSize(200.0)
|
||||
else:
|
||||
self.sourceCmd.numericSSize(SSize)
|
||||
@@ -1463,39 +1463,39 @@ class DraftToolBar:
|
||||
try:
|
||||
track=int(self.STrack)
|
||||
except ValueError:
|
||||
FreeCAD.Console.PrintMessage(translate("draft", "Invalid Tracking value. Using 0."))
|
||||
FreeCAD.Console.PrintMessage(translate("draft", "Invalid Tracking value. Using 0."))
|
||||
self.sourceCmd.numericSTrack(0)
|
||||
else:
|
||||
self.sourceCmd.numericSTrack(track)
|
||||
|
||||
def validateSString(self):
|
||||
''' send a valid text string to ShapeString as unicode '''
|
||||
if self.sourceCmd:
|
||||
if self.sourceCmd:
|
||||
if (self.labelSString.isVisible()):
|
||||
if self.SStringValue.text():
|
||||
#print("debug: D_G DraftToolBar.validateSString type(SStringValue.text): " str(type(self.SStringValue.text)))
|
||||
#self.sourceCmd.validSString(str(self.SStringValue.text())) # QString to QByteArray to PyString
|
||||
self.sourceCmd.validSString(self.SStringValue.text()) # PySide returns Unicode from QString
|
||||
else:
|
||||
FreeCAD.Console.PrintMessage(translate("draft", "Please enter a text string."))
|
||||
|
||||
|
||||
FreeCAD.Console.PrintMessage(translate("draft", "Please enter a text string."))
|
||||
|
||||
|
||||
def pickFile(self):
|
||||
''' invoke a font file chooser dialog and send result to ShapeString to'''
|
||||
if self.sourceCmd:
|
||||
if self.sourceCmd:
|
||||
if (self.chooserButton.isVisible()):
|
||||
try:
|
||||
dialogCaption = translate("draft", "Select a Font file")
|
||||
dialogDir = os.path.dirname(Draft.getParam("FontFile",)) # reasonable default?
|
||||
dialogFilter = "Fonts (*.ttf *.pfb *.otf);;All files (*.*)"
|
||||
fname = QtGui.QFileDialog.getOpenFileName(self.baseWidget,
|
||||
dialogCaption,
|
||||
dialogCaption,
|
||||
dialogDir,
|
||||
dialogFilter)
|
||||
# fname = utf8_decode(fname[0]) # 1947: utf8_decode fails ('ascii' codec can't encode character)
|
||||
# when fname[0] contains accented chars
|
||||
fname = fname[0].encode('utf8') #TODO: this needs changing for Py3??
|
||||
# accented chars cause "UnicodeEncodeError" failure in DraftGui.todo without
|
||||
# accented chars cause "UnicodeEncodeError" failure in DraftGui.todo without
|
||||
# .encode('utf8')
|
||||
|
||||
except Exception as e:
|
||||
@@ -1505,18 +1505,18 @@ class DraftToolBar:
|
||||
else:
|
||||
if fname[0]:
|
||||
self.FFileValue.setText(fname)
|
||||
self.sourceCmd.validFFile(fname)
|
||||
self.sourceCmd.validFFile(fname)
|
||||
else:
|
||||
FreeCAD.Console.PrintMessage("DraftGui.pickFile: no file selected.") # can this happen?
|
||||
|
||||
|
||||
def validateFile(self):
|
||||
''' check and send font file parameter to ShapeString as unicode'''
|
||||
if self.sourceCmd:
|
||||
if self.sourceCmd:
|
||||
if (self.labelFFile.isVisible()):
|
||||
if self.FFileValue.text():
|
||||
self.sourceCmd.validFFile(utf8_decode(self.FFileValue.text())) #QString to PyString
|
||||
else:
|
||||
FreeCAD.Console.PrintMessage(translate("draft", "Please enter a font file."))
|
||||
FreeCAD.Console.PrintMessage(translate("draft", "Please enter a font file."))
|
||||
|
||||
|
||||
def finish(self):
|
||||
@@ -1678,7 +1678,7 @@ class DraftToolBar:
|
||||
k.setFocus()
|
||||
k.selectAll()
|
||||
self.updateSnapper()
|
||||
|
||||
|
||||
def updateSnapper(self):
|
||||
"updates the snapper track line if applicable"
|
||||
if hasattr(FreeCADGui,"Snapper"):
|
||||
@@ -1701,7 +1701,7 @@ class DraftToolBar:
|
||||
def setCurrentText(self,tstr):
|
||||
if (not self.taskmode) or (self.taskmode and self.isTaskOn):
|
||||
self.textValue.setText(tstr)
|
||||
|
||||
|
||||
def sendText(self):
|
||||
'''
|
||||
this function sends the entered text to the active draft command
|
||||
@@ -1767,7 +1767,7 @@ class DraftToolBar:
|
||||
self.zValue.setText(displayExternal(dp.z,None,'Length'))
|
||||
else:
|
||||
self.zValue.setText(displayExternal(dp.z,None,'Length'))
|
||||
|
||||
|
||||
# set length and angle
|
||||
if last and dp and plane:
|
||||
self.lengthValue.setText(displayExternal(dp.Length,None,'Length'))
|
||||
@@ -1780,7 +1780,7 @@ class DraftToolBar:
|
||||
mask = "x"
|
||||
elif a in [90,270,-90]:
|
||||
mask = "y"
|
||||
|
||||
|
||||
# set masks
|
||||
if (mask == "x") or (self.mask == "x"):
|
||||
self.xValue.setEnabled(True)
|
||||
@@ -1804,8 +1804,8 @@ class DraftToolBar:
|
||||
self.yValue.setEnabled(True)
|
||||
self.zValue.setEnabled(True)
|
||||
self.setFocus()
|
||||
|
||||
|
||||
|
||||
|
||||
def getDefaultColor(self,type,rgb=False):
|
||||
"gets color from the preferences or toolbar"
|
||||
if type == "snap":
|
||||
@@ -1826,7 +1826,7 @@ class DraftToolBar:
|
||||
r = color.red()/255.0
|
||||
g = color.green()/255.0
|
||||
b = color.blue()/255.0
|
||||
else:
|
||||
else:
|
||||
print("draft: error: couldn't get a color for ",type," type.")
|
||||
if rgb:
|
||||
return("rgb("+str(int(r*255))+","+str(int(g*255))+","+str(int(b*255))+")")
|
||||
@@ -1836,7 +1836,7 @@ class DraftToolBar:
|
||||
def cross(self,on=True):
|
||||
"deprecated"
|
||||
pass
|
||||
|
||||
|
||||
def toggleConstrMode(self,checked):
|
||||
self.baseWidget.setStyleSheet("#constrButton:Checked {background-color: "+self.getDefaultColor("constr",rgb=True)+" }")
|
||||
self.constrMode = checked
|
||||
@@ -1930,7 +1930,7 @@ class DraftToolBar:
|
||||
|
||||
def setRadiusValue(self,val,unit=None):
|
||||
#print("DEBUG: setRadiusValue val: ", val, " unit: ", unit)
|
||||
if not isinstance(val, (int, float)): #??some code passes strings or ???
|
||||
if not isinstance(val, (int, float)): #??some code passes strings or ???
|
||||
t = val
|
||||
elif unit:
|
||||
t= displayExternal(val,None, unit)
|
||||
@@ -1939,10 +1939,10 @@ class DraftToolBar:
|
||||
t = displayExternal(val,None, None)
|
||||
self.radiusValue.setText(t)
|
||||
self.radiusValue.setFocus()
|
||||
|
||||
|
||||
def runAutoGroup(self):
|
||||
FreeCADGui.runCommand("Draft_AutoGroup")
|
||||
|
||||
|
||||
def setAutoGroup(self,value=None):
|
||||
if value == None:
|
||||
self.autogroup = None
|
||||
@@ -2026,7 +2026,7 @@ class DraftToolBar:
|
||||
|
||||
def changeSTrackValue(self,d):
|
||||
self.STrack = d
|
||||
|
||||
|
||||
def changeLengthValue(self,d):
|
||||
self.lvalue = d
|
||||
v = FreeCAD.Vector(self.x,self.y,self.z)
|
||||
@@ -2041,7 +2041,7 @@ class DraftToolBar:
|
||||
self.xValue.setText(displayExternal(v.x,None,'Length'))
|
||||
self.yValue.setText(displayExternal(v.y,None,'Length'))
|
||||
self.zValue.setText(displayExternal(v.z,None,'Length'))
|
||||
|
||||
|
||||
def changeAngleValue(self,d):
|
||||
self.avalue = d
|
||||
v = FreeCAD.Vector(self.x,self.y,self.z)
|
||||
@@ -2054,7 +2054,7 @@ class DraftToolBar:
|
||||
self.zValue.setText(displayExternal(v.z,None,'Length'))
|
||||
if self.angleLock.isChecked():
|
||||
FreeCADGui.Snapper.setAngle(self.angle)
|
||||
|
||||
|
||||
def toggleAngle(self,b):
|
||||
self.alock = self.angleLock.isChecked()
|
||||
if b:
|
||||
@@ -2091,7 +2091,7 @@ class DraftToolBar:
|
||||
def shouldShow(self):
|
||||
return (FreeCAD.ActiveDocument != None) and (FreeCADGui.Selection.getSelection() != [])
|
||||
|
||||
# OBSOLETE
|
||||
# OBSOLETE
|
||||
#class DraftTrayWatcher:
|
||||
# def __init__(self,traywidget):
|
||||
# self.form = traywidget
|
||||
@@ -2107,10 +2107,10 @@ class DraftToolBar:
|
||||
#self.tray.addLayout(self.bottomtray)
|
||||
#self.setupTray()
|
||||
#self.setupStyle()
|
||||
#w = DraftTrayWatcher(self.traywidget)
|
||||
#w = DraftTrayWatcher(self.traywidget)
|
||||
#FreeCADGui.Control.addTaskWatcher([w,DraftCreateWatcher(),DraftModifyWatcher()])
|
||||
FreeCADGui.Control.addTaskWatcher([DraftCreateWatcher(),DraftModifyWatcher()])
|
||||
|
||||
|
||||
def changeEvent(self, event):
|
||||
if event.type() == QtCore.QEvent.LanguageChange:
|
||||
#print("Language changed!")
|
||||
@@ -2137,12 +2137,12 @@ class DraftToolBar:
|
||||
else:
|
||||
self.draftWidget.setVisible(False)
|
||||
self.draftWidget.toggleViewAction().setVisible(False)
|
||||
|
||||
|
||||
|
||||
|
||||
class FacebinderTaskPanel:
|
||||
'''A TaskPanel for the facebinder'''
|
||||
def __init__(self):
|
||||
|
||||
|
||||
self.obj = None
|
||||
self.form = QtGui.QWidget()
|
||||
self.form.setObjectName("FacebinderTaskPanel")
|
||||
@@ -2191,7 +2191,7 @@ class FacebinderTaskPanel:
|
||||
item = QtGui.QTreeWidgetItem(self.tree)
|
||||
item.setText(0,f[0].Name)
|
||||
item.setIcon(0,QtGui.QIcon(":/icons/Tree_Part.svg"))
|
||||
item.setText(1,subf)
|
||||
item.setText(1,subf)
|
||||
else:
|
||||
item = QtGui.QTreeWidgetItem(self.tree)
|
||||
item.setText(0,f[0].Name)
|
||||
@@ -2306,7 +2306,7 @@ class ScaleTaskPanel:
|
||||
QtCore.QObject.connect(self.zValue,QtCore.SIGNAL("valueChanged(double)"),self.setValue)
|
||||
QtCore.QObject.connect(self.pickrefButton,QtCore.SIGNAL("clicked()"),self.pickRef)
|
||||
self.retranslateUi()
|
||||
|
||||
|
||||
def setValue(self,val=None):
|
||||
if self.lock.isChecked():
|
||||
self.xValue.setValue(val)
|
||||
@@ -2314,7 +2314,7 @@ class ScaleTaskPanel:
|
||||
self.zValue.setValue(val)
|
||||
if self.sourceCmd:
|
||||
self.sourceCmd.scaleGhost(self.xValue.value(),self.yValue.value(),self.zValue.value(),self.relative.isChecked())
|
||||
|
||||
|
||||
def retranslateUi(self,widget=None):
|
||||
self.form.setWindowTitle(QtGui.QApplication.translate("Draft", "Scale", None))
|
||||
self.xLabel.setText(QtGui.QApplication.translate("Draft", "X factor", None))
|
||||
@@ -2357,6 +2357,6 @@ class ScaleTaskPanel:
|
||||
if not hasattr(FreeCADGui,"draftToolBar"):
|
||||
FreeCADGui.draftToolBar = DraftToolBar()
|
||||
#----End of Python Features Definitions----#
|
||||
|
||||
|
||||
if not hasattr(FreeCADGui,"Snapper"):
|
||||
import DraftSnap
|
||||
|
||||
Reference in New Issue
Block a user