Added gui support for lead in/out dressup

This commit is contained in:
Patrick Felixberger
2020-12-23 12:05:49 +01:00
parent 58dccfea48
commit 9e9c1ed21b
4 changed files with 425 additions and 1 deletions

View File

@@ -97,6 +97,7 @@
<file>panels/DogboneEdit.ui</file>
<file>panels/DressupPathBoundary.ui</file>
<file>panels/DragKnifeEdit.ui</file>
<file>panels/DressUpLeadInOutEdit.ui</file>
<file>panels/HoldingTagsEdit.ui</file>
<file>panels/PageBaseGeometryEdit.ui</file>
<file>panels/PageBaseHoleGeometryEdit.ui</file>

View File

@@ -0,0 +1,340 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TaskPanel</class>
<widget class="QWidget" name="TaskPanel">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>372</width>
<height>518</height>
</rect>
</property>
<property name="windowTitle">
<string>LeadInOut</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QToolBox" name="toolBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>400</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<property name="tabSpacing">
<number>6</number>
</property>
<widget class="QWidget" name="Dressup">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>354</width>
<height>470</height>
</rect>
</property>
<attribute name="label">
<string>Dressup</string>
</attribute>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>351</width>
<height>391</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>6</number>
</property>
<item row="6" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QCheckBox" name="chkLayers">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Apply Lead In/Out on all layers&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Include Layers</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkUseCRC">
<property name="text">
<string>Use Machine CRC</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Extend In:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="dsbExtendIn">
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Extend Out:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="dsbExtendOut">
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="chkLeadIn">
<property name="text">
<string>Enable LeadIn</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkLeadOut">
<property name="text">
<string>Enable LeadOut</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Length / Radius:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="dsbLen">
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Style In:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cboStyleIn">
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text">
<string>Arc</string>
</property>
</item>
<item>
<property name="text">
<string>Tangent</string>
</property>
</item>
<item>
<property name="text">
<string>Perpendicular</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Style Out:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cboStyleOut">
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text">
<string>Arc</string>
</property>
</item>
<item>
<property name="text">
<string>Tangent</string>
</property>
</item>
<item>
<property name="text">
<string>Perpendicular</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QCheckBox" name="chkKeepToolDown">
<property name="text">
<string>Keep Tool Down</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkRapidPlunge">
<property name="text">
<string>Rapid Plunge</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Radius / Center:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cboRadius">
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text">
<string>Radius</string>
</property>
</item>
<item>
<property name="text">
<string>Center</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -1108,6 +1108,7 @@ class CommandDressupDogbone:
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
if FreeCAD.GuiUp:
import FreeCADGui
from PySide import QtGui

View File

@@ -463,6 +463,81 @@ class ObjectDressup:
commands = newpath
return Path.Path(commands)
class TaskPanel:
def __init__(self, obj):
self.obj = obj
self.form = FreeCADGui.PySideUic.loadUi(":/panels/DressUpLeadInOutEdit.ui")
FreeCAD.ActiveDocument.openTransaction(translate("Path_DressupLeadInOut", "Edit LeadInOut Dress-up"))
def reject(self):
FreeCAD.ActiveDocument.abortTransaction()
FreeCADGui.Control.closeDialog()
FreeCAD.ActiveDocument.recompute()
def accept(self):
self.getFields()
FreeCAD.ActiveDocument.commitTransaction()
FreeCADGui.ActiveDocument.resetEdit()
FreeCADGui.Control.closeDialog()
FreeCAD.ActiveDocument.recompute()
def getFields(self):
self.obj.LeadIn = self.form.chkLeadIn.isChecked()
self.obj.LeadOut = self.form.chkLeadOut.isChecked()
self.obj.Length = self.form.dsbLen.value()
self.obj.ExtendLeadIn = self.form.dsbExtendIn.value()
self.obj.ExtendLeadOut = self.form.dsbExtendOut.value()
self.obj.StyleOn = str(self.form.cboStyleIn.currentText())
self.obj.StyleOff = str(self.form.cboStyleOut.currentText())
self.obj.RadiusCenter = str(self.form.cboRadius.currentText())
self.obj.RapidPlunge = self.form.chkRapidPlunge.isChecked()
self.obj.IncludeLayers = self.form.chkLayers.isChecked()
self.obj.KeepToolDown = self.form.chkKeepToolDown.isChecked()
self.obj.UseMachineCRC = self.form.chkUseCRC.isChecked()
self.updateUI()
self.obj.Proxy.execute(self.obj)
def updateUI(self):
self.form.chkLeadIn.setChecked(self.obj.LeadIn)
self.form.chkLeadOut.setChecked(self.obj.LeadOut)
self.form.chkRapidPlunge.setChecked(self.obj.RapidPlunge)
self.form.chkLayers.setChecked(self.obj.IncludeLayers)
self.form.chkKeepToolDown.setChecked(self.obj.KeepToolDown)
self.form.chkUseCRC.setChecked(self.obj.UseMachineCRC)
self.form.dsbLen.setValue(self.obj.Length)
self.form.dsbExtendIn.setValue(self.obj.ExtendLeadIn)
#self.form.dsbExtendIn.setEnabled(self.obj.LeadIn)
self.form.dsbExtendOut.setValue(self.obj.ExtendLeadOut)
#self.form.dsbExtendOut.setEnabled(self.obj.LeadOut)
self.form.cboStyleIn.setCurrentIndex(self.form.cboStyleIn.findText(self.obj.StyleOn))
#self.form.cboStyleIn.setEnabled(self.obj.LeadIn)
self.form.cboStyleOut.setCurrentIndex(self.form.cboStyleIn.findText(self.obj.StyleOff))
#self.form.cboStyleOut.setEnabled(self.obj.LeadOut)
self.form.cboRadius.setCurrentIndex(self.form.cboRadius.findText(self.obj.RadiusCenter))
def updateModel(self):
self.getFields()
FreeCAD.ActiveDocument.recompute()
def setFields(self):
self.updateUI()
def open(self):
pass
def setupUi(self):
self.setFields()
class ViewProviderDressup:
def __init__(self, vobj):
@@ -484,6 +559,14 @@ class ViewProviderDressup:
# FreeCADGui.ActiveDocument.getObject(obj.Base.Name).Visibility = False
return [self.obj.Base]
def setEdit(self, vobj, mode=0):
# pylint: disable=unused-argument
FreeCADGui.Control.closeDialog()
panel = TaskPanel(vobj.Object)
FreeCADGui.Control.showDialog(panel)
panel.setupUi()
return True
def onDelete(self, arg1=None, arg2=None):
'''this makes sure that the base operation is added back to the project and visible'''
# pylint: disable=unused-argument
@@ -519,7 +602,6 @@ class CommandPathDressupLeadInOut:
return False
def Activated(self):
# check that the selection contains exactly what we want
selection = FreeCADGui.Selection.getSelection()
if len(selection) != 1: