diff --git a/Resources/panels/FlangeParameters.ui b/Resources/panels/FlangeParameters.ui index b271bbf..d6d016e 100644 --- a/Resources/panels/FlangeParameters.ui +++ b/Resources/panels/FlangeParameters.ui @@ -1,289 +1,703 @@ - SMFlangeTaskPanel - + FlangeParameters + 0 0 - 259 - 506 + 336 + 450 + + + 0 + 0 + + Flange Parameters - + - - + + 0 - - - - Select - - - true - - - false - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - 0 - 0 - - - - true - - - - Name - - - - - SubElement - - - - - - - - Bend - - - - - - Type - - - - - - - - Material Outside - - - - - Material Inside + + + General + + + + + + 0 - - - - Thickness Outside - - - - - Offset - - - - - - - - Offset - - - - - - - false - - - mm - - - - - - - Radius - - - - - - - mm - - - 0.000000000000000 - - - - - - - - 0 - 0 - - - - Angle - - - - - - - deg - - - -360.000000000000000 - - - 360.000000000000000 - - - 90.000000000000000 - - - - - - - Length - - - - - - - mm - - - 0.000000000000000 - - - - - - - 0 - - - - - Length mode - - - - - - + + - Leg + Select - - - - Outer Sharp + + true - - - - Inner Sharp + + false - - - - Tangential + + + + + + Qt::Horizontal - - - - - - - - - + + + 40 + 20 + + + + + + + + + + + 0 + 0 + + + + true + + - Unfold + Name - - - - + + - Reversed + SubElement - - - - - - - - - - - Side Offsets - - - - - - Side A - - - - - - - mm - - - - - - - Side B - - - - - - - true - - - mm - - - - + + + + + + + Bend + + + + + + Type + + + + + + + + Material Outside + + + + + Material Inside + + + + + Thickness Outside + + + + + Offset + + + + + + + + Offset + + + + + + + false + + + mm + + + + + + + Radius + + + + + + + mm + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + Angle + + + + + + + deg + + + -360.000000000000000 + + + 360.000000000000000 + + + 90.000000000000000 + + + + + + + Length + + + + + + + mm + + + 0.000000000000000 + + + + + + + 0 + + + + + Length mode + + + + + + + + Leg + + + + + Outer Sharp + + + + + Inner Sharp + + + + + Tangential + + + + + + + + + + + + Unfold + + + + + + + Reversed + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Offsets + + + + + + + 0 + 0 + + + + Side Offsets + + + + + + Gap A + + + + + + + true + + + mm + + + + + + + Gap B + + + + + + + true + + + mm + + + + + + + Extend A + + + + + + + true + + + mm + + + + + + + Extend B + + + + + + + mm + + + + + + + + + + Relief Cuts + + + + + + Width + + + + + + + + 0 + 0 + + + + Depth + + + + + + + mm + + + 0.000000000000000 + + + + + + + mm + + + 0.000000000000000 + + + + + + + 1 + + + + + Rectangle + + + true + + + reliefTypeButtonGroup + + + + + + + Round + + + reliefTypeButtonGroup + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 177 + + + + + + + + + Miter + + + + + + Auto Miter + + + + + + + + 0 + 0 + + + + + + + + + + Minimum Gap + + + + + + + Maximum Extend Distance + + + + + + + mm + + + 0.000000000000000 + + + + + + + mm + + + 0.000000000000000 + + + + + + + + + + Manual Miter + + + + + + deg + + + -360.000000000000000 + + + 360.000000000000000 + + + + + + + deg + + + -360.000000000000000 + + + 360.000000000000000 + + + + + + + Angle 2 + + + + + + + Angle 1 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Perforation + + + + + + Perforate + + + + + + + Perforation Parameters + + + + + + Angle + + + + + + + true + + + mm + + + + + + + Initial Cut Length + + + + + + + true + + + mm + + + + + + + Max Cut Length + + + + + + + true + + + mm + + + + + + + Max Tab Length + + + + + + + true + + + mm + + + + + + + + + + Qt::Vertical + + + + 20 + 253 + + + + + + @@ -295,17 +709,9 @@
Gui/QuantitySpinBox.h
- - tree - BendType - Offset - Radius - Angle - Length - UnfoldCheckbox - ReversedCheckbox - extend1 - + + +
diff --git a/SheetMetalCmd.py b/SheetMetalCmd.py index 645f3b0..03a7241 100644 --- a/SheetMetalCmd.py +++ b/SheetMetalCmd.py @@ -675,17 +675,17 @@ def smMiter( # Part.show(edge_len,'edge_len') # check faces intersect each other - for i in range(len(facelist)): - for j in range(len(lenedgelist)): + for i, face in enumerate(facelist): + for j, lenedge in enumerate(lenedgelist): if ( i != j - and facelist[i].isCoplanar(facelist[j]) - and not (getParallel(lenedgelist[i], lenedgelist[j])) + and face.isCoplanar(facelist[j]) + and not (getParallel(lenedgelist[i], lenedge)) ): # Part.show(lenedgelist[i],'edge_len1') - # Part.show(lenedgelist[j],'edge_len2') + # Part.show(lenedge,'edge_len2') gaps1, extgap1, cornerPoint1 = getGap( - lenedgelist[i], lenedgelist[j], maxExtendGap, mingap + lenedgelist[i], lenedge, maxExtendGap, mingap ) gaps2, extgap2, cornerPoint2 = getGap( tranedgelist[i], tranedgelist[j], maxExtendGap, mingap @@ -693,12 +693,12 @@ def smMiter( # print([gaps1,gaps2, extgap1, extgap2]) gaps = max(gaps1, gaps2) extgap = min(extgap1, extgap2) - p1 = lenedgelist[j].valueAt(lenedgelist[j].FirstParameter) - p2 = lenedgelist[j].valueAt(lenedgelist[j].LastParameter) - Angle = LineAngle(lenedgelist[i], lenedgelist[j]) + p1 = lenedge.valueAt(lenedge.FirstParameter) + p2 = lenedge.valueAt(lenedge.LastParameter) + Angle = LineAngle(lenedgelist[i], lenedge) # print(Angle) if gaps > 0.0: - # walledge_common = lenedgelist[j].section(lenedgelist[i]) + # walledge_common = lenedge.section(lenedgelist[i]) # vp1 = walledge_common.Vertexes[0].Point dist1 = (p1 - cornerPoint1).Length dist2 = (p2 - cornerPoint1).Length @@ -715,7 +715,7 @@ def smMiter( else: gap2List[j] = 0.0 elif extgap != 0.0 and (extgap + mingap) < maxExtendGap: - wallface_common = facelist[j].common(facelist[i]) + wallface_common = facelist[j].common(face) dist1 = (p1 - cornerPoint1).Length dist2 = (p2 - cornerPoint1).Length if abs(dist1) < abs(dist2): @@ -736,13 +736,13 @@ def smMiter( extgap2List[j] = extgap else: extgap2List[j] = 0.0 - elif i != j and not (getParallel(lenedgelist[i], lenedgelist[j])): + elif i != j and not (getParallel(lenedgelist[i], lenedge)): # Part.show(lenedgelist[i],'edge_len1') - # Part.show(lenedgelist[j],'edge_len2') + # Part.show(lenedge,'edge_len2') # Part.show(tranedgelist[i],'edge_len1') # Part.show(tranedgelist[j],'edge_len2') gaps1, extgap1, cornerPoint1 = getGap( - lenedgelist[i], lenedgelist[j], maxExtendGap, mingap + lenedgelist[i], lenedge, maxExtendGap, mingap ) gaps2, extgap2, cornerPoint2 = getGap( tranedgelist[i], tranedgelist[j], maxExtendGap, mingap @@ -750,12 +750,12 @@ def smMiter( # print([gaps1, gaps2, extgap1, extgap2]) gaps = max(gaps1, gaps2) extgap = min(extgap1, extgap2) - p1 = lenedgelist[j].valueAt(lenedgelist[j].FirstParameter) - p2 = lenedgelist[j].valueAt(lenedgelist[j].LastParameter) + p1 = lenedge.valueAt(lenedge.FirstParameter) + p2 = lenedge.valueAt(lenedge.LastParameter) if gaps > 0.0: - wallface_common = facelist[j].section(facelist[i]) + wallface_common = facelist[j].section(face) # Part.show(facelist[j],'facelist') - # Part.show(facelist[i],'facelist') + # Part.show(face,'facelist') wallface_common1 = tranfacelist[j].section(tranfacelist[i]) # Part.show(tranfacelist[j],'tranfacelist') # Part.show(tranfacelist[i],'tranfacelist') @@ -1775,7 +1775,7 @@ def setEdit(self, vobj, mode): def unsetEdit(self, vobj, mode): Gui.Control.closeDialog() - Gui.Selection.setSelectionStyle(Gui.Selection.SelectionStyle.NormalSelection) + SheetMetalTools.smSelectNormal() self.Object.baseObject[0].ViewObject.Visibility = False self.Object.ViewObject.Visibility = True return False @@ -1857,7 +1857,7 @@ def setEdit(self, vobj, mode): def unsetEdit(self, vobj, mode): Gui.Control.closeDialog() - Gui.Selection.setSelectionStyle(Gui.Selection.SelectionStyle.NormalSelection) + SheetMetalTools.smSelectNormal() self.Object.baseObject[0].ViewObject.Visibility = False self.Object.ViewObject.Visibility = True return False @@ -1868,31 +1868,39 @@ class SMBendWallTaskPanel: def __init__(self, obj): self.obj = obj - self.form = SheetMetalTools.taskLoadUI("FlangeParameters.ui", "FlangeAdvancedParameters.ui") + self.form = SheetMetalTools.taskLoadUI("FlangeParameters.ui") self.updateForm() # flange parameters connects SheetMetalTools.taskConnectSelection( - self.form[0].AddRemove, self.form[0].tree, self.obj, ["Face", "Edge"]) - SheetMetalTools.taskConnectEnum(self, self.form[0].BendType, "BendType", self.bendTypeUpdated) - SheetMetalTools.taskConnectSpin(self, self.form[0].Offset, "offset") - SheetMetalTools.taskConnectSpin(self, self.form[0].Radius, "radius") - SheetMetalTools.taskConnectSpin(self, self.form[0].Angle, "angle") - SheetMetalTools.taskConnectSpin(self, self.form[0].Length, "length") - SheetMetalTools.taskConnectEnum(self, self.form[0].LengthSpec, "LengthSpec") - SheetMetalTools.taskConnectCheck(self, self.form[0].UnfoldCheckbox, "unfold") - SheetMetalTools.taskConnectCheck(self, self.form[0].ReversedCheckbox, "invert") - SheetMetalTools.taskConnectSpin(self, self.form[0].extend1, "extend1") - SheetMetalTools.taskConnectSpin(self, self.form[0].extend2, "extend2") + self.form.AddRemove, self.form.tree, self.obj, ["Face", "Edge"]) + SheetMetalTools.taskConnectEnum(self, self.form.BendType, "BendType", self.bendTypeUpdated) + SheetMetalTools.taskConnectSpin(self, self.form.Offset, "offset") + SheetMetalTools.taskConnectSpin(self, self.form.Radius, "radius") + SheetMetalTools.taskConnectSpin(self, self.form.Angle, "angle") + SheetMetalTools.taskConnectSpin(self, self.form.Length, "length") + SheetMetalTools.taskConnectEnum(self, self.form.LengthSpec, "LengthSpec") + SheetMetalTools.taskConnectCheck(self, self.form.UnfoldCheckbox, "unfold") + SheetMetalTools.taskConnectCheck(self, self.form.ReversedCheckbox, "invert") + SheetMetalTools.taskConnectSpin(self, self.form.gap1, "gap1") + SheetMetalTools.taskConnectSpin(self, self.form.gap2, "gap2") + SheetMetalTools.taskConnectSpin(self, self.form.extend1, "extend1") + SheetMetalTools.taskConnectSpin(self, self.form.extend2, "extend2") # advanced flange parameters connects - self.form[1].reliefTypeButtonGroup.buttonToggled.connect(self.reliefTypeUpdated) - SheetMetalTools.taskConnectSpin(self, self.form[1].reliefWidth, "reliefw") - SheetMetalTools.taskConnectSpin(self, self.form[1].reliefDepth, "reliefd") - SheetMetalTools.taskConnectCheck(self, self.form[1].autoMiterCheckbox, "AutoMiter") - SheetMetalTools.taskConnectSpin(self, self.form[1].minGap, "minGap") - SheetMetalTools.taskConnectSpin(self, self.form[1].maxExDist, "maxExtendDist") - SheetMetalTools.taskConnectSpin(self, self.form[1].miterAngle1, "miterangle1") - SheetMetalTools.taskConnectSpin(self, self.form[1].miterAngle2, "miterangle2") + self.form.reliefTypeButtonGroup.buttonToggled.connect(self.reliefTypeUpdated) + SheetMetalTools.taskConnectSpin(self, self.form.reliefWidth, "reliefw") + SheetMetalTools.taskConnectSpin(self, self.form.reliefDepth, "reliefd") + SheetMetalTools.taskConnectCheck(self, self.form.autoMiterCheckbox, "AutoMiter") + SheetMetalTools.taskConnectSpin(self, self.form.minGap, "minGap") + SheetMetalTools.taskConnectSpin(self, self.form.maxExDist, "maxExtendDist") + SheetMetalTools.taskConnectSpin(self, self.form.miterAngle1, "miterangle1") + SheetMetalTools.taskConnectSpin(self, self.form.miterAngle2, "miterangle2") + # perforation + SheetMetalTools.taskConnectCheck(self, self.form.checkPerforate, "Perforate", self.perforateChanged) + SheetMetalTools.taskConnectSpin(self, self.form.perforateAngle, "PerforationAngle") + SheetMetalTools.taskConnectSpin(self, self.form.perforateInitialCutLen, "PerforationInitialLength") + SheetMetalTools.taskConnectSpin(self, self.form.perforateMaxCutLen, "PerforationMaxLength") + SheetMetalTools.taskConnectSpin(self, self.form.perforateMaxTabLen, "NonperforationMaxLength") def isAllowedAlterSelection(self): return True @@ -1905,33 +1913,36 @@ def isAllowedAlterView(self): def bendTypeUpdated(self, value): if self.obj.BendType == "Offset": - self.form[0].Offset.setEnabled(True) + self.form.Offset.setEnabled(True) else: - self.form[0].Offset.setEnabled(False) + self.form.Offset.setEnabled(False) def reliefTypeUpdated(self): self.obj.reliefType = ( - "Rectangle" if self.form[1].reliefRectangle.isChecked() else "Round" + "Rectangle" if self.form.reliefRectangle.isChecked() else "Round" ) self.obj.Document.recompute() def updateForm(self): - self.form[0].Offset.setEnabled(self.obj.BendType == "Offset") - SheetMetalTools.taskPopulateSelectionList(self.form[0].tree, self.obj.baseObject) + self.form.Offset.setEnabled(self.obj.BendType == "Offset") + SheetMetalTools.taskPopulateSelectionList(self.form.tree, self.obj.baseObject) # Advanced parameters update if self.obj.reliefType == "Rectangle": - self.form[1].reliefRectangle.setChecked(True) + self.form.reliefRectangle.setChecked(True) else: - self.form[1].reliefRound.setChecked(True) + self.form.reliefRound.setChecked(True) + + def perforateChanged(self, isPerforate): + self.form.groupPerforate.setEnabled(isPerforate) def accept(self): - SheetMetalTools.taskAccept(self, self.form[0].AddRemove) + SheetMetalTools.taskAccept(self, self.form.AddRemove) SheetMetalTools.taskSaveDefaults(self.obj, smAddWallDefaults, smAddWallDefaultVars) return True def reject(self): - SheetMetalTools.taskReject(self, self.form[0].AddRemove) + SheetMetalTools.taskReject(self, self.form.AddRemove) class AddWallCommandClass: """Add Wall command""" diff --git a/SheetMetalTools.py b/SheetMetalTools.py index 49727c0..37bdd07 100644 --- a/SheetMetalTools.py +++ b/SheetMetalTools.py @@ -41,6 +41,15 @@ def addSelection(self, document, obj, element, position): smSingleSelObserver = SMSingleSelectionObserver() Gui.Selection.addObserver(smSingleSelObserver) + def smSelectGreedy(): + if hasattr(Gui.Selection, "setSelectionStyle"): # compatibility with FC link version + Gui.Selection.setSelectionStyle(Gui.Selection.SelectionStyle.GreedySelection) + + def smSelectNormal(): + if hasattr(Gui.Selection, "setSelectionStyle"): # compatibility with FC link version + Gui.Selection.setSelectionStyle(Gui.Selection.SelectionStyle.NormalSelection) + + def smHideObjects(*args): for arg in args: if arg: @@ -94,12 +103,12 @@ def _taskToggleSelectionMode(isChecked, addRemoveButton, treeWidget, obj, allowe obj.baseObject[0].Visibility=True Gui.Selection.clearSelection() Gui.Selection.addSelection(obj.baseObject[0],obj.baseObject[1]) - Gui.Selection.setSelectionStyle(Gui.Selection.SelectionStyle.GreedySelection) + smSelectGreedy() addRemoveButton.setText('Preview') else: updateSelectionElements(obj, allowedTypes) Gui.Selection.clearSelection() - Gui.Selection.setSelectionStyle(Gui.Selection.SelectionStyle.NormalSelection) + smSelectNormal() obj.Document.recompute() obj.baseObject[0].Visibility=False obj.Visibility=True @@ -183,6 +192,8 @@ def taskConnectSpin(task, formvar, objvar, callback = None): def taskConnectCheck(task, formvar, objvar, callback = None): formvar.setChecked(getattr(task.obj, objvar)) + if callback is not None: + callback(formvar.isChecked()) formvar.toggled.connect(lambda value: _taskUpdateValue(value, task.obj, objvar, callback)) def taskConnectEnum(task, formvar, objvar, callback = None): @@ -203,7 +214,7 @@ def taskAccept(task, addRemoveButton = None): def taskReject(task, addRemoveButton = None): if addRemoveButton is not None and addRemoveButton.isChecked(): - Gui.Selection.setSelectionStyle(Gui.Selection.SelectionStyle.NormalSelection) + smSelectNormal() if smSingleSelObserver.button is not None: smSingleSelObserver.button.toggle() FreeCAD.ActiveDocument.abortTransaction()