Draft: Moved SelectPlane stuff from DraftGui to its own ui file
This commit is contained in:
@@ -592,16 +592,12 @@ class DraftToolBar:
|
||||
|
||||
# options
|
||||
|
||||
self.WPLabel = self._label("WPLabel", self.layout,wrap=True)
|
||||
fl = QtGui.QHBoxLayout()
|
||||
self.layout.addLayout(fl)
|
||||
self.numFacesLabel = self._label("numfaceslabel", fl)
|
||||
self.numFaces = self._spinbox("numFaces", fl, 3)
|
||||
ol = QtGui.QHBoxLayout()
|
||||
self.layout.addLayout(ol)
|
||||
self.offsetLabel = self._label("offsetlabel", ol)
|
||||
self.offsetValue = self._inputfield("offsetValue", ol)
|
||||
self.offsetValue.setText(FreeCAD.Units.Quantity(0,FreeCAD.Units.Length).UserString)
|
||||
rl = QtGui.QHBoxLayout()
|
||||
self.layout.addLayout(rl)
|
||||
self.labelRadius = self._label("labelRadius", rl)
|
||||
@@ -629,44 +625,9 @@ class DraftToolBar:
|
||||
bl = QtGui.QHBoxLayout()
|
||||
self.layout.addLayout(bl)
|
||||
self.selectButton = self._pushbutton("selectButton", bl, icon='view-select')
|
||||
bl = QtGui.QHBoxLayout()
|
||||
self.layout.addLayout(bl)
|
||||
self.xyButton = self._pushbutton("xyButton", bl,icon="view-top")
|
||||
bl = QtGui.QHBoxLayout()
|
||||
self.layout.addLayout(bl)
|
||||
self.xzButton = self._pushbutton("xzButton", bl,icon="view-front")
|
||||
bl = QtGui.QHBoxLayout()
|
||||
self.layout.addLayout(bl)
|
||||
self.yzButton = self._pushbutton("yzButton", bl,icon="view-right")
|
||||
bl = QtGui.QHBoxLayout()
|
||||
self.layout.addLayout(bl)
|
||||
self.currentViewButton = self._pushbutton("view", bl,icon="view-isometric")
|
||||
bl = QtGui.QHBoxLayout()
|
||||
self.layout.addLayout(bl)
|
||||
self.resetPlaneButton = self._pushbutton("none", bl,icon="view-axonometric")
|
||||
|
||||
self.isCopy = self._checkbox("isCopy",self.layout,checked=False)
|
||||
self.isSubelementMode = self._checkbox("isSubelementMode",self.layout,checked=False)
|
||||
gl = QtGui.QHBoxLayout()
|
||||
self.layout.addLayout(gl)
|
||||
self.gridLabel = self._label("gridLabel", gl)
|
||||
self.gridValue = self._inputfield("gridValue", gl)
|
||||
self.gridValue.setText(FreeCAD.Units.Quantity(0,FreeCAD.Units.Length).UserString)
|
||||
ml = QtGui.QHBoxLayout()
|
||||
self.layout.addLayout(ml)
|
||||
self.mainlineLabel = self._label("mainlineLabel", ml)
|
||||
self.mainlineValue = self._spinbox("mainlineValue", ml)
|
||||
gl = QtGui.QHBoxLayout()
|
||||
self.layout.addLayout(gl)
|
||||
self.centerLabel = self._label("centerLabel", gl)
|
||||
self.centerPlane = self._checkbox("centerPlane",gl,checked = self.isCenterPlane)
|
||||
gl = QtGui.QHBoxLayout()
|
||||
self.layout.addLayout(gl)
|
||||
self.snapLabel = self._label("snapLabel", gl)
|
||||
self.snapValue = self._spinbox("snapValue", gl)
|
||||
self.snapValue.setValue(Draft.getParam("snapRange", 8))
|
||||
bl = QtGui.QHBoxLayout()
|
||||
self.layout.addLayout(bl)
|
||||
self.alignToWPButton = self._pushbutton("alignToWP", bl,icon="dagViewVisible")
|
||||
|
||||
# spacer
|
||||
if not self.taskmode:
|
||||
@@ -685,7 +646,6 @@ class DraftToolBar:
|
||||
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.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)
|
||||
QtCore.QObject.connect(self.yValue,QtCore.SIGNAL("returnPressed()"),self.checky)
|
||||
QtCore.QObject.connect(self.lengthValue,QtCore.SIGNAL("returnPressed()"),self.checkangle)
|
||||
@@ -703,8 +663,6 @@ class DraftToolBar:
|
||||
QtCore.QObject.connect(self.textValue,QtCore.SIGNAL("down()"),self.sendText)
|
||||
QtCore.QObject.connect(self.textValue,QtCore.SIGNAL("up()"),self.lineUp)
|
||||
QtCore.QObject.connect(self.zValue,QtCore.SIGNAL("returnPressed()"),self.setFocus)
|
||||
QtCore.QObject.connect(self.offsetValue,QtCore.SIGNAL("textEdited(QString)"),self.checkSpecialChars)
|
||||
QtCore.QObject.connect(self.offsetValue,QtCore.SIGNAL("returnPressed()"),self.validatePoint)
|
||||
QtCore.QObject.connect(self.addButton,QtCore.SIGNAL("toggled(bool)"),self.setAddMode)
|
||||
QtCore.QObject.connect(self.delButton,QtCore.SIGNAL("toggled(bool)"),self.setDelMode)
|
||||
QtCore.QObject.connect(self.sharpButton,QtCore.SIGNAL("toggled(bool)"),self.setSharpMode)
|
||||
@@ -717,15 +675,10 @@ class DraftToolBar:
|
||||
QtCore.QObject.connect(self.orientWPButton,QtCore.SIGNAL("pressed()"),self.orientWP)
|
||||
QtCore.QObject.connect(self.undoButton,QtCore.SIGNAL("pressed()"),self.undoSegment)
|
||||
QtCore.QObject.connect(self.selectButton,QtCore.SIGNAL("pressed()"),self.selectEdge)
|
||||
QtCore.QObject.connect(self.xyButton,QtCore.SIGNAL("clicked()"),self.selectXY)
|
||||
QtCore.QObject.connect(self.xzButton,QtCore.SIGNAL("clicked()"),self.selectXZ)
|
||||
QtCore.QObject.connect(self.yzButton,QtCore.SIGNAL("clicked()"),self.selectYZ)
|
||||
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.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)
|
||||
QtCore.QObject.connect(self.baseWidget,QtCore.SIGNAL("retranslate()"),self.retranslateUi)
|
||||
QtCore.QObject.connect(self.SSizeValue,QtCore.SIGNAL("valueChanged(double)"),self.changeSSizeValue)
|
||||
@@ -735,11 +688,7 @@ class DraftToolBar:
|
||||
QtCore.QObject.connect(self.SStringValue,QtCore.SIGNAL("returnPressed()"),self.validateSString)
|
||||
QtCore.QObject.connect(self.chooserButton,QtCore.SIGNAL("pressed()"),self.pickFile)
|
||||
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.snapValue,QtCore.SIGNAL("valueChanged(int)"),self.setSnapValue)
|
||||
QtCore.QObject.connect(self.alignToWPButton,QtCore.SIGNAL("clicked()"),self.alignToWP)
|
||||
|
||||
|
||||
# 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
|
||||
@@ -844,7 +793,6 @@ class DraftToolBar:
|
||||
self.finishButton.setToolTip(translate("draft", "Finishes the current drawing or editing operation"))
|
||||
self.continueCmd.setToolTip(translate("draft", "If checked, command will not finish until you press the command button again"))
|
||||
self.continueCmd.setText(translate("draft", "Continue")+" ("+inCommandShortcuts["Continue"][0]+")")
|
||||
self.WPLabel.setText(translate("draft", "Select a face or working plane proxy or 3 vertices, or choose one of the options below"))
|
||||
self.occOffset.setToolTip(translate("draft", "If checked, an OCC-style offset will be performed instead of the classic offset"))
|
||||
self.occOffset.setText(translate("draft", "&OCC-style offset"))
|
||||
self.addButton.setToolTip(translate("draft", "Add points to the current object"))
|
||||
@@ -865,17 +813,7 @@ class DraftToolBar:
|
||||
self.selectButton.setToolTip(translate("draft", "Selects an existing edge to be measured by this dimension"))
|
||||
self.numFacesLabel.setText(translate("draft", "Sides"))
|
||||
self.numFaces.setToolTip(translate("draft", "Number of sides"))
|
||||
self.offsetLabel.setText(translate("draft", "Offset"))
|
||||
self.xyButton.setText(translate("draft", "XY (top)"))
|
||||
self.xyButton.setToolTip(translate("draft", "Sets the working plane on the ground XY plane"))
|
||||
self.xzButton.setText(translate("draft", "XZ (front)"))
|
||||
self.xzButton.setToolTip(translate("draft", "Sets the working plane on the front XZ plane"))
|
||||
self.yzButton.setText(translate("draft", "YZ (side)"))
|
||||
self.yzButton.setToolTip(translate("draft", "Sets the working plane on the side YZ plane"))
|
||||
self.currentViewButton.setText(translate("draft", "View"))
|
||||
self.currentViewButton.setToolTip(translate("draft", "Sets the working plane perpendicular to the current view"))
|
||||
self.resetPlaneButton.setText(translate("draft", "Automatic"))
|
||||
self.resetPlaneButton.setToolTip(translate("draft", "The working plane adapts to the current view when a command is started"))
|
||||
|
||||
self.isCopy.setText(translate("draft", "Copy")+" ("+inCommandShortcuts["Copy"][0]+")")
|
||||
self.isCopy.setToolTip(translate("draft", "If checked, objects will be copied instead of moved. Preferences -> Draft -> Global copy mode to keep this mode in next commands"))
|
||||
self.isSubelementMode.setText(translate("draft", "Modify subelements")+" ("+inCommandShortcuts["SubelementMode"][0]+")")
|
||||
@@ -888,16 +826,6 @@ class DraftToolBar:
|
||||
self.labelSTrack.setText(translate("draft", "Tracking"))
|
||||
self.labelFFile.setText(translate("draft", "Full path to font file:"))
|
||||
self.chooserButton.setToolTip(translate("draft", "Open a FileChooser for font file"))
|
||||
self.gridLabel.setText(translate("draft", "Grid spacing"))
|
||||
self.gridValue.setToolTip(translate("draft", "The spacing between the grid lines"))
|
||||
self.mainlineLabel.setText(translate("draft", "Main line every"))
|
||||
self.mainlineValue.setToolTip(translate("draft", "The number of lines between main lines"))
|
||||
self.centerLabel.setText(translate("draft", "Center plane on view"))
|
||||
self.centerPlane.setToolTip(translate("draft", "Centers the working plane on the current view"))
|
||||
self.snapLabel.setText(translate("draft", "Snapping radius"))
|
||||
self.snapValue.setToolTip(translate("draft", "This is the distance in screen pixels under which a point will be snapped. You can also change the radius while drawing, using keys")+" "+inCommandShortcuts["Increase"][0]+" , "+inCommandShortcuts["Decrease"][0])
|
||||
self.alignToWPButton.setText(translate("draft", "Align view"))
|
||||
self.alignToWPButton.setToolTip(translate("draft", "Aligns the view direction to face the current working plane"))
|
||||
self.retranslateTray(widget)
|
||||
|
||||
# Update the maximum width of the push buttons
|
||||
@@ -1000,32 +928,6 @@ class DraftToolBar:
|
||||
self.radiusValue.setFocus()
|
||||
self.radiusValue.selectAll()
|
||||
|
||||
def selectPlaneUi(self):
|
||||
self.taskUi(title=translate("draft", "Working plane setup"),icon="Draft_SelectPlane")
|
||||
self.WPLabel.show()
|
||||
self.xyButton.show()
|
||||
self.xzButton.show()
|
||||
self.yzButton.show()
|
||||
self.currentViewButton.show()
|
||||
self.resetPlaneButton.show()
|
||||
self.offsetLabel.show()
|
||||
self.offsetValue.show()
|
||||
self.gridLabel.show()
|
||||
self.gridValue.show()
|
||||
p = Draft.getParam("gridSpacing",1.0)
|
||||
self.gridValue.setText(FreeCAD.Units.Quantity(p,FreeCAD.Units.Length).UserString)
|
||||
self.mainlineLabel.show()
|
||||
self.mainlineValue.show()
|
||||
p = Draft.getParam("gridEvery",10)
|
||||
self.mainlineValue.setValue(p)
|
||||
self.centerLabel.show()
|
||||
self.centerPlane.show()
|
||||
self.snapLabel.show()
|
||||
self.snapValue.show()
|
||||
p = Draft.getParam("snapRange", 8)
|
||||
self.snapValue.setValue(p)
|
||||
self.alignToWPButton.show()
|
||||
|
||||
def extraLineUi(self):
|
||||
'''shows length and angle controls'''
|
||||
self.labellength.show()
|
||||
@@ -1186,13 +1088,6 @@ class DraftToolBar:
|
||||
self.wipeButton.hide()
|
||||
self.orientWPButton.hide()
|
||||
self.selectButton.hide()
|
||||
self.xyButton.hide()
|
||||
self.xzButton.hide()
|
||||
self.yzButton.hide()
|
||||
self.currentViewButton.hide()
|
||||
self.resetPlaneButton.hide()
|
||||
self.offsetLabel.hide()
|
||||
self.offsetValue.hide()
|
||||
self.labelRadius.hide()
|
||||
self.radiusValue.hide()
|
||||
self.isCopy.hide()
|
||||
@@ -1208,16 +1103,7 @@ class DraftToolBar:
|
||||
self.labelFFile.hide()
|
||||
self.FFileValue.hide()
|
||||
self.chooserButton.hide()
|
||||
self.gridLabel.hide()
|
||||
self.gridValue.hide()
|
||||
self.mainlineLabel.hide()
|
||||
self.mainlineValue.hide()
|
||||
self.centerLabel.hide()
|
||||
self.centerPlane.hide()
|
||||
self.snapLabel.hide()
|
||||
self.snapValue.hide()
|
||||
self.WPLabel.hide()
|
||||
self.alignToWPButton.hide()
|
||||
|
||||
|
||||
def trimUi(self,title=translate("draft","Trim")):
|
||||
self.taskUi(title)
|
||||
@@ -1444,26 +1330,6 @@ class DraftToolBar:
|
||||
panel = TaskPanel(extra,callback)
|
||||
FreeCADGui.Control.showDialog(panel)
|
||||
|
||||
def setGridSize(self,text):
|
||||
"""sets the Draft grid to the given grid size"""
|
||||
try:
|
||||
q = FreeCAD.Units.Quantity(text)
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
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)
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Processing functions
|
||||
@@ -1570,14 +1436,6 @@ class DraftToolBar:
|
||||
print("debug: DraftGui.validatePoint: AttributeError")
|
||||
else:
|
||||
self.sourceCmd.numericRadius(rad)
|
||||
elif (self.offsetLabel.isVisible()):
|
||||
try:
|
||||
#offset=float(self.offsetValue.text())
|
||||
offset = self.offset
|
||||
except (ValueError, AttributeError):
|
||||
print("debug: DraftGui.validatePoint: AttributeError")
|
||||
else:
|
||||
self.sourceCmd.offsetHandler(offset)
|
||||
elif (self.labelx.isVisible()):
|
||||
try:
|
||||
#numx=float(self.xValue.text())
|
||||
@@ -1721,24 +1579,6 @@ class DraftToolBar:
|
||||
if hasattr(self.sourceCmd,"selectEdge"):
|
||||
self.sourceCmd.selectEdge()
|
||||
|
||||
def selectXY(self):
|
||||
self.sourceCmd.selectHandler("XY")
|
||||
|
||||
def selectXZ(self):
|
||||
self.sourceCmd.selectHandler("XZ")
|
||||
|
||||
def selectYZ(self):
|
||||
self.sourceCmd.selectHandler("YZ")
|
||||
|
||||
def selectCurrentView(self):
|
||||
self.sourceCmd.selectHandler("currentView")
|
||||
|
||||
def selectResetPlane(self):
|
||||
self.sourceCmd.selectHandler("reset")
|
||||
|
||||
def alignToWP(self):
|
||||
self.sourceCmd.selectHandler("alignToWP")
|
||||
|
||||
def undoSegment(self):
|
||||
"""undo last line segment"""
|
||||
if hasattr(self.sourceCmd,"undolast"):
|
||||
@@ -2191,11 +2031,6 @@ class DraftToolBar:
|
||||
Draft.setParam("snapRange",par+val)
|
||||
FreeCADGui.Snapper.showradius()
|
||||
|
||||
def setSnapValue(self,val):
|
||||
Draft.setParam("snapRange",val)
|
||||
if hasattr(FreeCADGui,"Snapper"):
|
||||
FreeCADGui.Snapper.showradius()
|
||||
|
||||
def constrain(self,val):
|
||||
if val == "angle":
|
||||
self.alock = not(self.alock)
|
||||
@@ -2221,9 +2056,6 @@ class DraftToolBar:
|
||||
def changeRadiusValue(self,d):
|
||||
self.radius = d
|
||||
|
||||
def changeOffsetValue(self,d):
|
||||
self.offset = d
|
||||
|
||||
def changeSSizeValue(self,d):
|
||||
self.SSize = d
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import FreeCADGui
|
||||
import math
|
||||
import Draft
|
||||
import DraftVecUtils
|
||||
from DraftGui import translate
|
||||
from DraftGui import todo, translate
|
||||
|
||||
def QT_TRANSLATE_NOOP(ctx,txt): return txt
|
||||
|
||||
@@ -42,6 +42,12 @@ class Draft_SelectPlane:
|
||||
|
||||
"""The Draft_SelectPlane FreeCAD command definition"""
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.ac = "FreeCAD.DraftWorkingPlane.alignToPointAndAxis"
|
||||
self.param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
|
||||
self.states = []
|
||||
|
||||
def GetResources(self):
|
||||
|
||||
return {'Pixmap' : 'Draft_SelectPlane',
|
||||
@@ -50,7 +56,7 @@ class Draft_SelectPlane:
|
||||
'ToolTip' : QT_TRANSLATE_NOOP("Draft_SelectPlane", "Select a working plane for geometry creation")}
|
||||
|
||||
def IsActive(self):
|
||||
|
||||
|
||||
if FreeCADGui.ActiveDocument:
|
||||
return True
|
||||
else:
|
||||
@@ -58,39 +64,77 @@ class Draft_SelectPlane:
|
||||
|
||||
def Activated(self):
|
||||
|
||||
if FreeCAD.activeDraftCommand:
|
||||
FreeCAD.activeDraftCommand.finish()
|
||||
FreeCAD.activeDraftCommand = self
|
||||
# reset variables
|
||||
self.view = Draft.get3DView()
|
||||
self.ui = FreeCADGui.draftToolBar
|
||||
self.featureName = "SelectPlane"
|
||||
self.ui.sourceCmd = self
|
||||
self.ui.setTitle(translate("draft","Set Working Plane"))
|
||||
self.ui.show()
|
||||
self.wpButton = FreeCADGui.draftToolBar.wplabel
|
||||
FreeCAD.DraftWorkingPlane.setup()
|
||||
if hasattr(FreeCADGui,"Snapper"):
|
||||
FreeCADGui.Snapper.setTrackers()
|
||||
self.offset = 0
|
||||
|
||||
# write current WP if states are empty
|
||||
if not self.states:
|
||||
p = FreeCAD.DraftWorkingPlane
|
||||
self.states.append([p.u, p.v, p.axis, p.position])
|
||||
|
||||
# try to find a WP from the current selection
|
||||
if self.handle():
|
||||
return
|
||||
self.ui.selectPlaneUi()
|
||||
FreeCAD.Console.PrintMessage(translate("draft", "Pick a face to define the drawing plane")+"\n")
|
||||
if FreeCAD.DraftWorkingPlane.alignToSelection(self.offset):
|
||||
|
||||
# try other method
|
||||
if FreeCAD.DraftWorkingPlane.alignToSelection():
|
||||
FreeCADGui.Selection.clearSelection()
|
||||
self.display(FreeCAD.DraftWorkingPlane.axis)
|
||||
self.finish()
|
||||
else:
|
||||
self.call = self.view.addEventCallback("SoEvent", self.action)
|
||||
return
|
||||
|
||||
m = translate("draft", "Pick a face, 3 vertices or a WP Proxy to define the drawing plane")
|
||||
FreeCAD.Console.PrintMessage(m+"\n")
|
||||
|
||||
from PySide import QtCore,QtGui
|
||||
|
||||
# create UI panel
|
||||
FreeCADGui.Control.closeDialog()
|
||||
self.taskd = SelectPlane_TaskPanel()
|
||||
|
||||
# fill values
|
||||
self.taskd.form.checkCenter.setChecked(self.param.GetBool("CenterPlaneOnView",False))
|
||||
q = FreeCAD.Units.Quantity(self.param.GetFloat("gridSpacing",1.0),FreeCAD.Units.Length)
|
||||
self.taskd.form.fieldGridSpacing.setText(q.UserString)
|
||||
self.taskd.form.fieldGridMainLine.setValue(self.param.GetInt("gridEvery",10))
|
||||
self.taskd.form.fieldSnapRadius.setValue(self.param.GetInt("snapRange",8))
|
||||
|
||||
# set icons
|
||||
self.taskd.form.setWindowIcon(QtGui.QIcon(":/icons/Draft_SelectPlane.svg"))
|
||||
self.taskd.form.buttonTop.setIcon(QtGui.QIcon(":/icons/view-top.svg"))
|
||||
self.taskd.form.buttonFront.setIcon(QtGui.QIcon(":/icons/view-front.svg"))
|
||||
self.taskd.form.buttonSide.setIcon(QtGui.QIcon(":/icons/view-right.svg"))
|
||||
self.taskd.form.buttonAlign.setIcon(QtGui.QIcon(":/icons/view-isometric.svg"))
|
||||
self.taskd.form.buttonAuto.setIcon(QtGui.QIcon(":/icons/view-axonometric.svg"))
|
||||
self.taskd.form.buttonMove.setIcon(QtGui.QIcon(":/icons/Draft_Move.svg"))
|
||||
self.taskd.form.buttonCenter.setIcon(QtGui.QIcon(":/icons/view-fullscreen.svg"))
|
||||
self.taskd.form.buttonPrevious.setIcon(QtGui.QIcon(":/icons/edit-undo.svg"))
|
||||
|
||||
# connect slots
|
||||
self.taskd.form.buttonTop.clicked.connect(self.onClickTop)
|
||||
self.taskd.form.buttonFront.clicked.connect(self.onClickFront)
|
||||
self.taskd.form.buttonSide.clicked.connect(self.onClickSide)
|
||||
self.taskd.form.buttonAlign.clicked.connect(self.onClickAlign)
|
||||
self.taskd.form.buttonAuto.clicked.connect(self.onClickAuto)
|
||||
self.taskd.form.buttonMove.clicked.connect(self.onClickMove)
|
||||
self.taskd.form.buttonCenter.clicked.connect(self.onClickCenter)
|
||||
self.taskd.form.buttonPrevious.clicked.connect(self.onClickPrevious)
|
||||
self.taskd.form.fieldGridSpacing.textEdited.connect(self.onSetGridSize)
|
||||
self.taskd.form.fieldGridMainLine.valueChanged.connect(self.onSetMainline)
|
||||
self.taskd.form.fieldSnapRadius.valueChanged.connect(self.onSetSnapRadius)
|
||||
|
||||
# rock 'n roll!
|
||||
FreeCADGui.Control.showDialog(self.taskd)
|
||||
self.call = self.view.addEventCallback("SoEvent", self.action)
|
||||
|
||||
def finish(self,close=False):
|
||||
|
||||
FreeCAD.activeDraftCommand = None
|
||||
if self.ui:
|
||||
self.ui.offUi()
|
||||
self.ui.sourceCmd = None
|
||||
FreeCAD.DraftWorkingPlane.restore()
|
||||
if hasattr(FreeCADGui,"Snapper"):
|
||||
FreeCADGui.Snapper.off()
|
||||
|
||||
# store values
|
||||
self.param.SetBool("CenterPlaneOnView",self.taskd.form.checkCenter.isChecked())
|
||||
|
||||
# terminate coin callbacks
|
||||
if self.call:
|
||||
try:
|
||||
self.view.removeEventCallback("SoEvent",self.call)
|
||||
@@ -99,26 +143,38 @@ class Draft_SelectPlane:
|
||||
pass
|
||||
self.call = None
|
||||
|
||||
# reset everything else
|
||||
FreeCADGui.Control.closeDialog()
|
||||
FreeCAD.DraftWorkingPlane.restore()
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
return True
|
||||
|
||||
def reject(self):
|
||||
|
||||
self.finish()
|
||||
return True
|
||||
|
||||
def action(self, arg):
|
||||
|
||||
|
||||
if arg["Type"] == "SoKeyboardEvent" and arg["Key"] == "ESCAPE":
|
||||
self.finish()
|
||||
if arg["Type"] == "SoMouseButtonEvent":
|
||||
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"):
|
||||
# coin detection happens before the selection got a chance of being updated, so we must delay
|
||||
DraftGui.todo.delay(self.checkSelection,None)
|
||||
todo.delay(self.checkSelection,None)
|
||||
|
||||
def checkSelection(self):
|
||||
|
||||
|
||||
if self.handle():
|
||||
self.finish()
|
||||
|
||||
def handle(self):
|
||||
|
||||
"""tries to build a WP. Returns True if successful"""
|
||||
|
||||
sel = FreeCADGui.Selection.getSelectionEx()
|
||||
if len(sel) == 1:
|
||||
sel = sel[0]
|
||||
self.ui = FreeCADGui.draftToolBar
|
||||
if Draft.getType(sel.Object) == "Axis":
|
||||
FreeCAD.DraftWorkingPlane.alignToEdges(sel.Object.Shape.Edges)
|
||||
self.display(FreeCAD.DraftWorkingPlane.axis)
|
||||
@@ -170,20 +226,20 @@ class Draft_SelectPlane:
|
||||
if o.Visibility != (v == "True"):
|
||||
FreeCADGui.doCommand("FreeCADGui.ActiveDocument.getObject(\""+k+"\").Visibility = "+v)
|
||||
self.display(FreeCAD.DraftWorkingPlane.axis)
|
||||
self.ui.wplabel.setText(sel.Object.Label)
|
||||
self.ui.wplabel.setToolTip(translate("draft", "Current working plane")+": "+self.ui.wplabel.text())
|
||||
self.wpButton.setText(sel.Object.Label)
|
||||
self.wpButton.setToolTip(translate("draft", "Current working plane")+": "+self.wpButton.text())
|
||||
return True
|
||||
elif Draft.getType(sel.Object) == "SectionPlane":
|
||||
FreeCAD.DraftWorkingPlane.setFromPlacement(sel.Object.Placement,rebase=True)
|
||||
FreeCAD.DraftWorkingPlane.weak = False
|
||||
self.display(FreeCAD.DraftWorkingPlane.axis)
|
||||
self.ui.wplabel.setText(sel.Object.Label)
|
||||
self.ui.wplabel.setToolTip(translate("draft", "Current working plane")+": "+self.ui.wplabel.text())
|
||||
self.wpButton.setText(sel.Object.Label)
|
||||
self.wpButton.setToolTip(translate("draft", "Current working plane")+": "+self.wpButton.text())
|
||||
return True
|
||||
elif sel.HasSubObjects:
|
||||
if len(sel.SubElementNames) == 1:
|
||||
if "Face" in sel.SubElementNames[0]:
|
||||
FreeCAD.DraftWorkingPlane.alignToFace(sel.SubObjects[0], self.offset)
|
||||
FreeCAD.DraftWorkingPlane.alignToFace(sel.SubObjects[0], self.taskd.form.fieldOffset.Value)
|
||||
self.display(FreeCAD.DraftWorkingPlane.axis)
|
||||
return True
|
||||
elif sel.SubElementNames[0] == "Plane":
|
||||
@@ -197,13 +253,13 @@ class Draft_SelectPlane:
|
||||
FreeCAD.DraftWorkingPlane.alignTo3Points(sel.SubObjects[0].Point,
|
||||
sel.SubObjects[1].Point,
|
||||
sel.SubObjects[2].Point,
|
||||
self.offset)
|
||||
self.taskd.form.fieldOffset.Value)
|
||||
self.display(FreeCAD.DraftWorkingPlane.axis)
|
||||
return True
|
||||
elif sel.Object.isDerivedFrom("Part::Feature"):
|
||||
if sel.Object.Shape:
|
||||
if len(sel.Object.Shape.Faces) == 1:
|
||||
FreeCAD.DraftWorkingPlane.alignToFace(sel.Object.Shape.Faces[0], self.offset)
|
||||
FreeCAD.DraftWorkingPlane.alignToFace(sel.Object.Shape.Faces[0], self.taskd.form.fieldOffset.Value)
|
||||
self.display(FreeCAD.DraftWorkingPlane.axis)
|
||||
return True
|
||||
elif sel:
|
||||
@@ -217,100 +273,220 @@ class Draft_SelectPlane:
|
||||
FreeCAD.DraftWorkingPlane.alignTo3Points(subs[0].Point,
|
||||
subs[1].Point,
|
||||
subs[2].Point,
|
||||
self.offset)
|
||||
self.taskd.form.fieldOffset.Value)
|
||||
self.display(FreeCAD.DraftWorkingPlane.axis)
|
||||
return True
|
||||
return False
|
||||
|
||||
def getCenterPoint(self,x,y,z):
|
||||
|
||||
if not self.ui.isCenterPlane:
|
||||
return "0,0,0"
|
||||
|
||||
if not self.taskd.form.checkCenter.isChecked():
|
||||
return FreeCAD.Vector()
|
||||
v = FreeCAD.Vector(x,y,z)
|
||||
cam1 = FreeCAD.Vector(FreeCADGui.ActiveDocument.ActiveView.getCameraNode().position.getValue().getValue())
|
||||
cam2 = FreeCADGui.ActiveDocument.ActiveView.getViewDirection()
|
||||
vcam1 = DraftVecUtils.project(cam1,v)
|
||||
a = vcam1.getAngle(cam2)
|
||||
if a < 0.0001:
|
||||
return "0,0,0"
|
||||
return FreeCAD.Vector()
|
||||
d = vcam1.Length
|
||||
L = d/math.cos(a)
|
||||
vcam2 = DraftVecUtils.scaleTo(cam2,L)
|
||||
cp = cam1.add(vcam2)
|
||||
return str(cp.x)+","+str(cp.y)+","+str(cp.z)
|
||||
return cp
|
||||
|
||||
def selectHandler(self, arg):
|
||||
def tostr(self,v):
|
||||
|
||||
"""makes a string from a vector or tuple"""
|
||||
|
||||
return "FreeCAD.Vector("+str(v[0])+","+str(v[1])+","+str(v[2])+")"
|
||||
|
||||
def getOffset(self):
|
||||
|
||||
"""returns the offset value as a float in mm"""
|
||||
|
||||
try:
|
||||
self.offset = float(self.ui.offset)
|
||||
o = float(self.taskd.form.fieldOffset.text())
|
||||
except:
|
||||
self.offset = 0
|
||||
if arg == "XY":
|
||||
FreeCADGui.doCommandGui("FreeCAD.DraftWorkingPlane.alignToPointAndAxis(FreeCAD.Vector("+self.getCenterPoint(0,0,1)+"), FreeCAD.Vector(0,0,1), "+str(self.offset)+")")
|
||||
self.display('Top')
|
||||
self.finish()
|
||||
elif arg == "XZ":
|
||||
FreeCADGui.doCommandGui("FreeCAD.DraftWorkingPlane.alignToPointAndAxis(FreeCAD.Vector("+self.getCenterPoint(0,-1,0)+"), FreeCAD.Vector(0,-1,0), "+str(self.offset)+")")
|
||||
self.display('Front')
|
||||
self.finish()
|
||||
elif arg == "YZ":
|
||||
FreeCADGui.doCommandGui("FreeCAD.DraftWorkingPlane.alignToPointAndAxis(FreeCAD.Vector("+self.getCenterPoint(1,0,0)+"), FreeCAD.Vector(1,0,0), "+str(self.offset)+")")
|
||||
self.display('Side')
|
||||
self.finish()
|
||||
elif arg == "currentView":
|
||||
d = self.view.getViewDirection().negative()
|
||||
FreeCADGui.doCommandGui("FreeCAD.DraftWorkingPlane.alignToPointAndAxis(FreeCAD.Vector("+self.getCenterPoint(d.x,d.y,d.z)+"), FreeCAD.Vector("+str(d.x)+","+str(d.y)+","+str(d.z)+"), "+str(self.offset)+")")
|
||||
self.display(d)
|
||||
self.finish()
|
||||
elif arg == "reset":
|
||||
FreeCADGui.doCommandGui("FreeCAD.DraftWorkingPlane.reset()")
|
||||
self.display('Auto')
|
||||
self.finish()
|
||||
elif arg == "alignToWP":
|
||||
o = FreeCAD.Units.Quantity(self.taskd.form.fieldOffset.text())
|
||||
o = o.Value
|
||||
return o
|
||||
|
||||
def onClickTop(self):
|
||||
|
||||
o = str(self.getOffset())
|
||||
FreeCADGui.doCommandGui(self.ac+"("+self.tostr(self.getCenterPoint(0,0,1))+","+self.tostr((0,0,1))+","+o+")")
|
||||
self.display('Top')
|
||||
self.finish()
|
||||
|
||||
def onClickFront(self):
|
||||
|
||||
o = str(self.getOffset())
|
||||
FreeCADGui.doCommandGui(self.ac+"("+self.tostr(self.getCenterPoint(0,-1,0))+","+self.tostr((0,-1,0))+","+o+")")
|
||||
self.display('Front')
|
||||
self.finish()
|
||||
|
||||
def onClickSide(self):
|
||||
|
||||
o = str(self.getOffset())
|
||||
FreeCADGui.doCommandGui(self.ac+"("+self.tostr(self.getCenterPoint(1,0,0))+","+self.tostr((1,0,0))+","+o+")")
|
||||
self.display('Side')
|
||||
self.finish()
|
||||
|
||||
def onClickAlign(self):
|
||||
|
||||
FreeCADGui.doCommandGui("FreeCAD.DraftWorkingPlane.setup(force=True)")
|
||||
d = self.view.getViewDirection().negative()
|
||||
self.display(d)
|
||||
self.finish()
|
||||
|
||||
def onClickAuto(self):
|
||||
|
||||
FreeCADGui.doCommandGui("FreeCAD.DraftWorkingPlane.reset()")
|
||||
self.display('Auto')
|
||||
self.finish()
|
||||
|
||||
def onClickMove(self):
|
||||
|
||||
sel = FreeCADGui.Selection.getSelectionEx()
|
||||
if sel:
|
||||
verts = []
|
||||
import Part
|
||||
for s in sel:
|
||||
for so in s.SubObjects:
|
||||
if isinstance(so,Part.Vertex):
|
||||
verts.append(so)
|
||||
if len(verts) == 1:
|
||||
target = verts[0].Point
|
||||
FreeCAD.DraftWorkingPlane.position = target
|
||||
self.display(target)
|
||||
self.finish()
|
||||
else:
|
||||
# move the WP to the center of the current view
|
||||
c = FreeCADGui.ActiveDocument.ActiveView.getCameraNode()
|
||||
r = FreeCAD.DraftWorkingPlane.getRotation().Rotation.Q
|
||||
c.orientation.setValue(r)
|
||||
p = FreeCAD.Vector(c.position.getValue().getValue())
|
||||
d = FreeCADGui.ActiveDocument.ActiveView.getViewDirection()
|
||||
pp = FreeCAD.DraftWorkingPlane.projectPoint(p,d)
|
||||
FreeCAD.DraftWorkingPlane.position = pp
|
||||
self.display(pp)
|
||||
self.finish()
|
||||
|
||||
def offsetHandler(self, arg):
|
||||
def onClickCenter(self):
|
||||
|
||||
c = FreeCADGui.ActiveDocument.ActiveView.getCameraNode()
|
||||
r = FreeCAD.DraftWorkingPlane.getRotation().Rotation.Q
|
||||
c.orientation.setValue(r)
|
||||
# calculate delta
|
||||
p = FreeCAD.Vector(c.position.getValue().getValue())
|
||||
pp = FreeCAD.DraftWorkingPlane.projectPoint(p)
|
||||
delta = pp.negative() # to bring it above the (0,0) point
|
||||
np = p.add(delta)
|
||||
c.position.setValue(tuple(np))
|
||||
self.finish()
|
||||
|
||||
def onClickPrevious(self):
|
||||
|
||||
self.offset = arg
|
||||
p = FreeCAD.DraftWorkingPlane
|
||||
if len(self.states) > 1:
|
||||
self.states.pop() # discard the last one
|
||||
s = self.states[-1]
|
||||
p.u = s[0]
|
||||
p.v = s[1]
|
||||
p.axis = s[2]
|
||||
p.position = s[3]
|
||||
FreeCADGui.Snapper.setGrid()
|
||||
self.finish()
|
||||
|
||||
def onSetGridSize(self,text):
|
||||
|
||||
try:
|
||||
q = FreeCAD.Units.Quantity(text)
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
self.param.SetFloat("gridSpacing",q.Value)
|
||||
if hasattr(FreeCADGui,"Snapper"):
|
||||
FreeCADGui.Snapper.setGrid()
|
||||
|
||||
def onSetMainline(self,i):
|
||||
|
||||
if i > 1:
|
||||
self.param.SetInt("gridEvery",i)
|
||||
if hasattr(FreeCADGui,"Snapper"):
|
||||
FreeCADGui.Snapper.setGrid()
|
||||
|
||||
def onSetSnapRadius(self,i):
|
||||
|
||||
self.param.SetInt("snapRange",i)
|
||||
if hasattr(FreeCADGui,"Snapper"):
|
||||
FreeCADGui.Snapper.showradius()
|
||||
|
||||
def display(self,arg):
|
||||
|
||||
if self.offset:
|
||||
if self.offset > 0: suffix = ' + '+str(self.offset)
|
||||
else: suffix = ' - '+str(self.offset)
|
||||
else: suffix = ''
|
||||
|
||||
"""sets the text of the WP button"""
|
||||
|
||||
o = self.getOffset()
|
||||
if o:
|
||||
if o > 0:
|
||||
suffix = ' +O'
|
||||
else:
|
||||
suffix = ' -O'
|
||||
else:
|
||||
suffix = ''
|
||||
vdir = FreeCAD.DraftWorkingPlane.axis
|
||||
vdir = '('+str(vdir.x)[:4]+','+str(vdir.y)[:4]+','+str(vdir.z)[:4]+')'
|
||||
vdir = " "+translate("draft","Dir")+": "+vdir
|
||||
if type(arg).__name__ == 'str':
|
||||
self.ui.wplabel.setText(arg+suffix)
|
||||
self.wpButton.setText(arg+suffix)
|
||||
if o != 0:
|
||||
o = " "+translate("draft","Offset")+": "+str(o)
|
||||
else:
|
||||
o = ""
|
||||
self.wpButton.setToolTip(translate("draft", "Current working plane")+": "+self.wpButton.text()+o+vdir)
|
||||
elif type(arg).__name__ == 'Vector':
|
||||
plv = 'd('+str(arg.x)+','+str(arg.y)+','+str(arg.z)+')'
|
||||
self.ui.wplabel.setText(plv+suffix)
|
||||
self.ui.wplabel.setToolTip(translate("draft", "Current working plane:")+self.ui.wplabel.text())
|
||||
plv = '('+str(arg.x)[:6]+','+str(arg.y)[:6]+','+str(arg.z)[:6]+')'
|
||||
self.wpButton.setText(translate("draft","Custom"))
|
||||
self.wpButton.setToolTip(translate("draft", "Current working plane")+": "+plv+vdir)
|
||||
p = FreeCAD.DraftWorkingPlane
|
||||
self.states.append([p.u, p.v, p.axis, p.position])
|
||||
FreeCADGui.doCommandGui("FreeCADGui.Snapper.setGrid()")
|
||||
|
||||
|
||||
|
||||
class SelectPlane_TaskPanel:
|
||||
|
||||
'''The editmode TaskPanel for Arch Material objects'''
|
||||
|
||||
def __init__(self):
|
||||
|
||||
import Draft_rc
|
||||
self.form = FreeCADGui.PySideUic.loadUi(":/ui/TaskSelectPlane.ui")
|
||||
|
||||
def getStandardButtons(self):
|
||||
|
||||
return 2097152 #int(QtGui.QDialogButtonBox.Close)
|
||||
|
||||
|
||||
|
||||
class Draft_SetWorkingPlaneProxy():
|
||||
|
||||
"""The Draft_SetWorkingPlaneProxy FreeCAD command definition"""
|
||||
|
||||
def GetResources(self):
|
||||
|
||||
|
||||
return {'Pixmap' : 'Draft_SelectPlane',
|
||||
'MenuText': QT_TRANSLATE_NOOP("Draft_SetWorkingPlaneProxy", "Create Working Plane Proxy"),
|
||||
'ToolTip': QT_TRANSLATE_NOOP("Draft_SetWorkingPlaneProxy", "Creates a proxy object from the current working plane")}
|
||||
|
||||
def IsActive(self):
|
||||
|
||||
|
||||
if FreeCADGui.ActiveDocument:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def Activated(self):
|
||||
|
||||
|
||||
if hasattr(FreeCAD,"DraftWorkingPlane"):
|
||||
FreeCAD.ActiveDocument.openTransaction("Create WP proxy")
|
||||
FreeCADGui.addModule("Draft")
|
||||
|
||||
@@ -138,5 +138,6 @@
|
||||
<file>ui/preferences-svg.ui</file>
|
||||
<file>ui/preferences-oca.ui</file>
|
||||
<file>ui/TaskShapeString.ui</file>
|
||||
<file>ui/TaskSelectPlane.ui</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
246
src/Mod/Draft/Resources/ui/TaskSelectPlane.ui
Normal file
246
src/Mod/Draft/Resources/ui/TaskSelectPlane.ui
Normal file
@@ -0,0 +1,246 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Form</class>
|
||||
<widget class="QWidget" name="Form">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>200</width>
|
||||
<height>547</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Working plane setup</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Select a face or working plane proxy or 3 vertices, or choose one of the options below</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonTop">
|
||||
<property name="toolTip">
|
||||
<string>Sets the working plane to the XY plane (ground plane)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Top (XY)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonFront">
|
||||
<property name="toolTip">
|
||||
<string>Sets the working plane to the XZ plane (front plane)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Front (XZ)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonSide">
|
||||
<property name="toolTip">
|
||||
<string>Sets the working plane to the YZ plane (side plane)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Side (YZ)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonAlign">
|
||||
<property name="toolTip">
|
||||
<string>Sets the working plane facing the current view</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Align to view</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonAuto">
|
||||
<property name="toolTip">
|
||||
<string>The working plane will align to the current view each time a command is started</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Automatic</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::InputField" name="fieldOffset">
|
||||
<property name="toolTip">
|
||||
<string>an optional offset to give to the working plane above its base position. Use this together with one of the buttons above</string>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Offset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="toolTip">
|
||||
<string>if this is checked, the working plane will be centered on the current view when pressing one of the buttons above</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Center plane on view</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="checkCenter">
|
||||
<property name="toolTip">
|
||||
<string>if this is checked, the working plane will be centered on the current view when pressing one of the buttons above</string>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Or select a single vertex to move the current working plane without changing its orienatation. Then, press the button below</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonMove">
|
||||
<property name="toolTip">
|
||||
<string>Moves the working plane without changing its orientation. If no point is selected, the plane will be moved to the center of the view</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Move working plane</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="toolTip">
|
||||
<string>The spacing between the smaller grid lines</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Grid spacing</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="Gui::InputField" name="fieldGridSpacing">
|
||||
<property name="toolTip">
|
||||
<string>The spacing between the smaller grid lines</string>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="toolTip">
|
||||
<string>the number of squares between each main line of the grid</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Main line every</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="fieldGridMainLine">
|
||||
<property name="toolTip">
|
||||
<string>the number of squares between each main line of the grid</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="fieldSnapRadius">
|
||||
<property name="toolTip">
|
||||
<string>The distance at which a point can be snapped to when approaching the mouse. You can alsochange this value by using the [ and ] keys while drawing</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="toolTip">
|
||||
<string>The distance at which a point can be snapped to when approaching the mouse. You can alsochange this value by using the [ and ] keys while drawing</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Snapping radius</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonCenter">
|
||||
<property name="toolTip">
|
||||
<string>Centers the view on the current working plane</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Center view</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonPrevious">
|
||||
<property name="toolTip">
|
||||
<string>Resets the working plane to its previous position</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Previous</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::InputField</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>Gui/InputField.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -57,7 +57,9 @@ class plane:
|
||||
The active document. Reset view when `doc` changes.
|
||||
weak : bool
|
||||
It is `True` if the plane has been defined by `setup()`
|
||||
or has been reset.
|
||||
or has been reset. A weak plane can be changed
|
||||
(it is the "auto" mode), while a strong plane will keep
|
||||
its position until weakened (it is "locked")
|
||||
u : Base::Vector3
|
||||
An axis (vector) that helps define the working plane.
|
||||
v : Base::Vector3
|
||||
@@ -651,7 +653,7 @@ class plane:
|
||||
# len(sex) > 2, look for point and line, three points, etc.
|
||||
return False
|
||||
|
||||
def setup(self, direction=None, point=None, upvec=None):
|
||||
def setup(self, direction=None, point=None, upvec=None, force=False):
|
||||
"""Setup the working plane if it exists but is undefined.
|
||||
|
||||
If `direction` and `point` are present,
|
||||
@@ -676,13 +678,15 @@ class plane:
|
||||
It defaults to `None`. It is the new `position` of the plane.
|
||||
upvec : Base::Vector3, optional
|
||||
It defaults to `None`. It is the new `v` orientation of the plane.
|
||||
force : Bool
|
||||
If True, it sets the plane even if the plane is not in weak mode
|
||||
|
||||
To do
|
||||
-----
|
||||
When the interface is not loaded it should fail and print
|
||||
a message, `FreeCAD.Console.PrintError()`.
|
||||
"""
|
||||
if self.weak:
|
||||
if self.weak or force:
|
||||
if direction and point:
|
||||
self.alignToPointAndAxis(point, direction, 0, upvec)
|
||||
else:
|
||||
@@ -704,7 +708,10 @@ class plane:
|
||||
vdir.negative(), 0, upvec)
|
||||
except:
|
||||
pass
|
||||
self.weak = True
|
||||
if force:
|
||||
self.weak = False
|
||||
else:
|
||||
self.weak = True
|
||||
|
||||
def reset(self):
|
||||
"""Reset the plane.
|
||||
|
||||
Reference in New Issue
Block a user