Skip to content

Commit

Permalink
PathHelix: Switch to QToolBox based task panel
Browse files Browse the repository at this point in the history
This makes it more consistent with the other Path operations
  • Loading branch information
lhuedepohl committed Jan 14, 2017
1 parent 0de0d8f commit f2faa50
Showing 1 changed file with 29 additions and 16 deletions.
45 changes: 29 additions & 16 deletions src/Mod/Path/PathScripts/PathHelix.py
Expand Up @@ -105,7 +105,8 @@ def helix_cut(center, r_out, r_in, dr, zmax, zmin, dz, safe_z, tool_diameter, vf
return

out = "(helix_cut <{0}, {1}>, {2})".format(center[0], center[1],
", ".join(map(str, (r_out, r_in, dr, zmax, zmin, dz, safe_z, tool_diameter, vfeed, hfeed, direction, startside))))
", ".join(map(str, (r_out, r_in, dr, zmax, zmin, dz, safe_z,
tool_diameter, vfeed, hfeed, direction, startside))))

x0, y0 = center
nz = max(int(ceil((zmax - zmin)/dz)), 2)
Expand Down Expand Up @@ -527,14 +528,28 @@ class TaskPanel(object):
def __init__(self, obj):
from Units import Quantity
self.obj = obj
self.previous_value = {}
self.form = QtGui.QToolBox()

ui = FreeCADGui.UiLoader()
layout = QtGui.QGridLayout()

headerStyle = "QLabel { font-weight: bold; font-size: large; }"
grayed_out = "background-color: #d0d0d0;"

self.previous_value = {}
def nextToolBoxItem(label, iconFile):
widget = QtGui.QWidget()
layout = QtGui.QGridLayout()
widget.setLayout(layout)
icon = QtGui.QIcon(iconFile)
self.form.addItem(widget, icon, label)
return layout

def addFiller():
row = layout.rowCount()
widget = QtGui.QWidget()
layout.addWidget(widget, row, 0, 1, 2)
layout.setRowStretch(row, 1)

layout = nextToolBoxItem("Geometry", ":/icons/PartDesign_InternalExternalGear.svg")

def addWidget(widget):
row = layout.rowCount()
Expand All @@ -545,11 +560,6 @@ def addWidgets(widget1, widget2):
layout.addWidget(widget1, row, 0)
layout.addWidget(widget2, row, 1)

def heading(label):
heading = QtGui.QLabel(label)
heading.setStyleSheet(headerStyle)
addWidget(heading)

def addQuantity(property, labelstring, activator=None, max=None):
self.previous_value[property] = getattr(self.obj, property)
widget = ui.createWidget("Gui::InputField")
Expand Down Expand Up @@ -645,7 +655,9 @@ def change(index):

addWidgets(self.addButton, self.delButton)

heading("Drill parameters")
# End of "Features" section

layout = nextToolBoxItem("Drill parameters", ":/icons/Path-OperationB.svg")
addCheckBox("Active", "Operation is active")
tool = PathUtils.getTool(self.obj, self.obj.ToolNumber)
if not tool:
Expand All @@ -659,13 +671,19 @@ def change(index):
addEnumeration("StartSide", "Start Side",
[("Start from inside", "inside"), ("Start from outside", "outside")])

heading("Cutting Depths")
# End of "Drill parameters" section
addFiller()

layout = nextToolBoxItem("Cutting Depths", ":/icons/Path-Depths.svg")
addQuantity("Clearance", "Clearance Distance")
addQuantity("StartDepth", "Absolute start height", "UseStartDepth")

fdcheckbox, fdinput = addQuantity("FinalDepth", "Absolute final height", "UseFinalDepth")
tdlabel, tdinput = addQuantity("ThroughDepth", "Extra drill depth\nfor open holes")

# End of "Cutting Depths" section
addFiller()

# make ThroughDepth and FinalDepth mutually exclusive
def fd_change(state):
if fdcheckbox.isChecked():
Expand All @@ -681,11 +699,6 @@ def td_change(quantity):
if obj.UseFinalDepth:
tdinput.setStyleSheet(grayed_out)

# add
widget = QtGui.QWidget()
widget.setLayout(layout)
self.form = widget

def addCylinders(self):
features_per_base = {}
for base, features in self.obj.Features:
Expand Down

0 comments on commit f2faa50

Please sign in to comment.