add task panel for dragknife
This commit is contained in:
@@ -94,6 +94,7 @@
|
||||
<file>panels/DlgToolEdit.ui</file>
|
||||
<file>panels/DogboneEdit.ui</file>
|
||||
<file>panels/DressupPathBoundary.ui</file>
|
||||
<file>panels/DragKnifeEdit.ui</file>
|
||||
<file>panels/HoldingTagsEdit.ui</file>
|
||||
<file>panels/PageBaseGeometryEdit.ui</file>
|
||||
<file>panels/PageBaseHoleGeometryEdit.ui</file>
|
||||
|
||||
110
src/Mod/Path/Gui/Resources/panels/DragKnifeEdit.ui
Normal file
110
src/Mod/Path/Gui/Resources/panels/DragKnifeEdit.ui
Normal file
@@ -0,0 +1,110 @@
|
||||
<?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>376</width>
|
||||
<height>387</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dragknife Dressup</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>275</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblFilterAngle">
|
||||
<property name="text">
|
||||
<string>Filter Angle</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lblPivotHeight">
|
||||
<property name="text">
|
||||
<string>Pivot Height</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2" colspan="2">
|
||||
<widget class="Gui::QuantitySpinBox" name="offsetDistance">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Distance the point trails behind the spindle</p></body></html></string>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">mm</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>100.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>2.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lblOffSetDistance">
|
||||
<property name="text">
|
||||
<string>Offset Distance</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2" colspan="2">
|
||||
<widget class="Gui::QuantitySpinBox" name="pivotHeight">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Height to raise during corner action</p></body></html></string>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">mm</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>100.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>4.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" colspan="2">
|
||||
<widget class="Gui::QuantitySpinBox" name="filterAngle">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Angles less than filter angle will not receive corner actions</p></body></html></string>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">deg</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::QuantitySpinBox</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>Gui/QuantitySpinBox.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -28,6 +28,7 @@ import Path
|
||||
from PySide import QtCore
|
||||
import math
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
import PathScripts.PathGui as PathGui
|
||||
|
||||
# lazily loaded modules
|
||||
from lazy_loader.lazy_loader import LazyLoader
|
||||
@@ -38,10 +39,12 @@ __doc__ = """Dragknife Dressup object and FreeCAD command"""
|
||||
if FreeCAD.GuiUp:
|
||||
import FreeCADGui
|
||||
|
||||
|
||||
# Qt translation handling
|
||||
def translate(context, text, disambig=None):
|
||||
return QtCore.QCoreApplication.translate(context, text, disambig)
|
||||
|
||||
|
||||
movecommands = ['G1', 'G01', 'G2', 'G02', 'G3', 'G03']
|
||||
rapidcommands = ['G0', 'G00']
|
||||
arccommands = ['G2', 'G3', 'G02', 'G03']
|
||||
@@ -52,8 +55,8 @@ currLocation = {}
|
||||
class ObjectDressup:
|
||||
|
||||
def __init__(self, obj):
|
||||
obj.addProperty("App::PropertyLink", "Base", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "The base path to modify"))
|
||||
obj.addProperty("App::PropertyAngle", "filterangle", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "Angles less than filter angle will not receive corner actions"))
|
||||
obj.addProperty("App::PropertyLink", "Base", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "The base path to modify"))
|
||||
obj.addProperty("App::PropertyAngle", "filterAngle", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "Angles less than filter angle will not receive corner actions"))
|
||||
obj.addProperty("App::PropertyFloat", "offset", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "Distance the point trails behind the spindle"))
|
||||
obj.addProperty("App::PropertyFloat", "pivotheight", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "Height to raise during corner action"))
|
||||
|
||||
@@ -66,7 +69,8 @@ class ObjectDressup:
|
||||
return None
|
||||
|
||||
def shortcut(self, queue):
|
||||
'''Determines whether its shorter to twist CW or CCW to align with the next move'''
|
||||
'''Determines whether its shorter to twist CW or CCW to align with
|
||||
the next move'''
|
||||
# get the vector of the last move
|
||||
|
||||
if queue[1].Name in arccommands:
|
||||
@@ -127,7 +131,7 @@ class ObjectDressup:
|
||||
|
||||
def arcExtension(self, obj, queue):
|
||||
'''returns gcode for arc extension'''
|
||||
global currLocation # pylint: disable=global-statement
|
||||
global currLocation # pylint: disable=global-statement
|
||||
results = []
|
||||
|
||||
offset = obj.offset
|
||||
@@ -166,7 +170,7 @@ class ObjectDressup:
|
||||
'''returns gcode to do an arc move toward an arc to perform
|
||||
a corner action twist. Includes lifting and plungeing the knife'''
|
||||
|
||||
global currLocation # pylint: disable=global-statement
|
||||
global currLocation # pylint: disable=global-statement
|
||||
pivotheight = obj.pivotheight
|
||||
offset = obj.offset
|
||||
results = []
|
||||
@@ -233,7 +237,7 @@ class ObjectDressup:
|
||||
|
||||
def lineExtension(self, obj, queue):
|
||||
'''returns gcode for line extension'''
|
||||
global currLocation # pylint: disable=global-statement
|
||||
global currLocation # pylint: disable=global-statement
|
||||
|
||||
offset = float(obj.offset)
|
||||
results = []
|
||||
@@ -259,7 +263,7 @@ class ObjectDressup:
|
||||
def lineTwist(self, obj, queue, lastXY, twistCW=False):
|
||||
'''returns gcode to do an arc move toward a line to perform
|
||||
a corner action twist. Includes lifting and plungeing the knife'''
|
||||
global currLocation # pylint: disable=global-statement
|
||||
global currLocation # pylint: disable=global-statement
|
||||
pivotheight = obj.pivotheight
|
||||
offset = obj.offset
|
||||
|
||||
@@ -310,7 +314,7 @@ class ObjectDressup:
|
||||
|
||||
def execute(self, obj):
|
||||
newpath = []
|
||||
global currLocation # pylint: disable=global-statement
|
||||
global currLocation # pylint: disable=global-statement
|
||||
|
||||
if not obj.Base:
|
||||
return
|
||||
@@ -384,7 +388,7 @@ class ObjectDressup:
|
||||
# check if the inciden angle incident exceeds the filter
|
||||
incident_angle = self.getIncidentAngle(queue)
|
||||
|
||||
if abs(incident_angle) >= obj.filterangle:
|
||||
if abs(incident_angle) >= obj.filterAngle:
|
||||
if self.shortcut(queue) == "CW":
|
||||
# if incident_angle >= 0:
|
||||
twistCW = True
|
||||
@@ -430,6 +434,56 @@ class ObjectDressup:
|
||||
obj.Path = path
|
||||
|
||||
|
||||
class TaskPanel:
|
||||
|
||||
def __init__(self, obj):
|
||||
self.obj = obj
|
||||
self.form = FreeCADGui.PySideUic.loadUi(":/panels/DragKnifeEdit.ui")
|
||||
self.filterAngle = PathGui.QuantitySpinBox(self.form.filterAngle, obj, 'filterAngle')
|
||||
self.offsetDistance = PathGui.QuantitySpinBox(self.form.offsetDistance, obj, 'offset')
|
||||
self.pivotHeight = PathGui.QuantitySpinBox(self.form.pivotHeight, obj, 'pivotheight')
|
||||
|
||||
FreeCAD.ActiveDocument.openTransaction(translate("Path_DressupDragKnife", "Edit Dragknife 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.filterAngle.updateProperty()
|
||||
self.offsetDistance.updateProperty()
|
||||
self.pivotHeight.updateProperty()
|
||||
self.updateUI()
|
||||
|
||||
self.obj.Proxy.execute(self.obj)
|
||||
|
||||
def updateUI(self):
|
||||
self.filterAngle.updateSpinBox()
|
||||
self.offsetDistance.updateSpinBox()
|
||||
self.pivotHeight.updateSpinBox()
|
||||
|
||||
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):
|
||||
@@ -454,6 +508,10 @@ class ViewProviderDressup:
|
||||
|
||||
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 claimChildren(self):
|
||||
@@ -521,9 +579,10 @@ class CommandDressupDragknife:
|
||||
FreeCADGui.doCommand('job.Proxy.addOperation(obj, base)')
|
||||
FreeCADGui.doCommand('obj.ViewObject.Proxy = PathScripts.PathDressupDragknife.ViewProviderDressup(obj.ViewObject)')
|
||||
FreeCADGui.doCommand('Gui.ActiveDocument.getObject(base.Name).Visibility = False')
|
||||
FreeCADGui.doCommand('obj.filterangle = 20')
|
||||
FreeCADGui.doCommand('obj.filterAngle = 20')
|
||||
FreeCADGui.doCommand('obj.offset = 2')
|
||||
FreeCADGui.doCommand('obj.pivotheight = 4')
|
||||
FreeCADGui.doCommand('obj.ViewObject.Document.setEdit(obj.ViewObject, 0)')
|
||||
|
||||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
Reference in New Issue
Block a user