Added job export dialog to Job Editor.
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>650</width>
|
||||
<height>887</height>
|
||||
<width>371</width>
|
||||
<height>711</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -190,7 +190,36 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<widget class="QWidget" name="exportButtonBox" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>267</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="exportButton">
|
||||
<property name="text">
|
||||
<string>Export</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="dialogButtonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
@@ -210,12 +239,12 @@
|
||||
<tabstop>settingOperationDepths</tabstop>
|
||||
<tabstop>settingToolRapid</tabstop>
|
||||
<tabstop>toolsList</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
<tabstop>dialogButtonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<sender>dialogButtonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>Dialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
@@ -231,7 +260,7 @@
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<sender>dialogButtonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>Dialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PathEdit</class>
|
||||
<widget class="QTabWidget" name="PathEdit">
|
||||
<class>pathEdit</class>
|
||||
<widget class="QTabWidget" name="pathEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@@ -22,7 +22,7 @@
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_12">
|
||||
<item>
|
||||
<widget class="QToolBox" name="toolBox_3">
|
||||
<widget class="QToolBox" name="jobBox">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@@ -91,7 +91,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_6">
|
||||
<widget class="QWidget" name="templateExport">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@@ -103,6 +103,7 @@
|
||||
<attribute name="label">
|
||||
<string>Template Export</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_13"/>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -135,7 +135,20 @@ class DlgJobTemplateExport:
|
||||
def __init__(self, job, parent=None):
|
||||
self.job = job
|
||||
self.dialog = FreeCADGui.PySideUic.loadUi(":/panels/DlgJobTemplateExport.ui")
|
||||
if parent:
|
||||
self.dialog.setParent(parent)
|
||||
parent.layout().addWidget(self.dialog)
|
||||
self.dialog.dialogButtonBox.hide()
|
||||
else:
|
||||
self.dialog.exportButtonBox.hide()
|
||||
self.updateUI()
|
||||
self.dialog.toolsGroup.clicked.connect(self.checkUncheckTools)
|
||||
|
||||
def exportButton(self):
|
||||
return self.dialog.exportButton
|
||||
|
||||
def updateUI(self):
|
||||
job = self.job
|
||||
if job.PostProcessor:
|
||||
ppHint = "%s %s %s" % (job.PostProcessor, job.PostProcessorArgs, job.PostProcessorOutputFile)
|
||||
self.dialog.postProcessingHint.setText(ppHint)
|
||||
@@ -168,19 +181,20 @@ class DlgJobTemplateExport:
|
||||
self.dialog.settingToolRapid.setChecked(rapidChanged)
|
||||
self.dialog.settingOperationDepths.setChecked(depthsChanged)
|
||||
self.dialog.settingOperationHeights.setChecked(heightsChanged)
|
||||
|
||||
self.dialog.settingsOpsList.clear()
|
||||
for op in opsWithSettings:
|
||||
item = QtGui.QListWidgetItem(op)
|
||||
item.setCheckState(QtCore.Qt.CheckState.Checked)
|
||||
self.dialog.settingsOpsList.addItem(item)
|
||||
|
||||
self.dialog.toolsList.clear()
|
||||
for tc in sorted(job.ToolController, key=lambda o: o.Label):
|
||||
item = QtGui.QListWidgetItem(tc.Label)
|
||||
item.setData(self.DataObject, tc)
|
||||
item.setCheckState(QtCore.Qt.CheckState.Checked)
|
||||
self.dialog.toolsList.addItem(item)
|
||||
|
||||
self.dialog.toolsGroup.clicked.connect(self.checkUncheckTools)
|
||||
|
||||
def checkUncheckTools(self):
|
||||
state = QtCore.Qt.CheckState.Checked if self.dialog.toolsGroup.isChecked() else QtCore.Qt.CheckState.Unchecked
|
||||
for i in range(self.dialog.toolsList.count()):
|
||||
@@ -260,12 +274,16 @@ class CommandJobTemplateExport:
|
||||
job = self.GetJob()
|
||||
dialog = DlgJobTemplateExport(job)
|
||||
if dialog.exec_() == 1:
|
||||
foo = QtGui.QFileDialog.getSaveFileName(QtGui.QApplication.activeWindow(),
|
||||
"Path - Job Template",
|
||||
PathPreferences.filePath(),
|
||||
"job_*.json")[0]
|
||||
if foo:
|
||||
self.Execute(job, foo, dialog)
|
||||
self.SaveDialog(job, dialog)
|
||||
|
||||
@classmethod
|
||||
def SaveDialog(cls, job, dialog):
|
||||
foo = QtGui.QFileDialog.getSaveFileName(QtGui.QApplication.activeWindow(),
|
||||
"Path - Job Template",
|
||||
PathPreferences.filePath(),
|
||||
"job_*.json")[0]
|
||||
if foo:
|
||||
cls.Execute(job, foo, dialog)
|
||||
|
||||
@classmethod
|
||||
def Execute(cls, job, path, dialog=None):
|
||||
|
||||
@@ -27,6 +27,7 @@ import DraftVecUtils
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import PathScripts.PathJob as PathJob
|
||||
import PathScripts.PathJobCmd as PathJobCmd
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import PathScripts.PathGui as PathGui
|
||||
import PathScripts.PathLog as PathLog
|
||||
@@ -456,6 +457,7 @@ class TaskPanel:
|
||||
self.obj = vobj.Object
|
||||
self.deleteOnReject = deleteOnReject
|
||||
self.form = FreeCADGui.PySideUic.loadUi(":/panels/PathEdit.ui")
|
||||
self.template = PathJobCmd.DlgJobTemplateExport(self.obj, self.form.jobBox.widget(1))
|
||||
|
||||
vUnit = FreeCAD.Units.Quantity(1, FreeCAD.Units.Velocity).getUserPreferred()[2]
|
||||
self.form.toolControllerList.horizontalHeaderItem(1).setText('#')
|
||||
@@ -790,6 +792,8 @@ class TaskPanel:
|
||||
pass
|
||||
item.setText("%g" % getattr(tc, prop).Value)
|
||||
|
||||
self.template.updateUI()
|
||||
|
||||
def orientSelected(self, axis):
|
||||
def flipSel(sel):
|
||||
PathLog.debug("flip")
|
||||
@@ -914,10 +918,13 @@ class TaskPanel:
|
||||
PathLog.error(translate('PathJob', "Unsupported stock type %s (%d)") % (self.form.stock.currentText(), index))
|
||||
self.stockEdit.activate(self.obj, index == -1)
|
||||
|
||||
def updateStock(self):
|
||||
if -1 != index:
|
||||
self.template.updateUI()
|
||||
|
||||
def updateStock(self):
|
||||
self.updateStockEditor(self.form.stock.currentIndex())
|
||||
|
||||
def centerInStock(self):
|
||||
def centerInStock(self):
|
||||
bbb = self.obj.Base.Shape.BoundBox
|
||||
bbs = self.obj.Stock.Shape.BoundBox
|
||||
by = bbs.Center - bbb.Center
|
||||
@@ -959,6 +966,14 @@ class TaskPanel:
|
||||
self.form.centerInStock.setEnabled(False)
|
||||
self.form.centerInStockXY.setEnabled(False)
|
||||
|
||||
def tabPageChanged(self, index):
|
||||
if index == 0:
|
||||
# update the template with potential changes
|
||||
self.getFields()
|
||||
self.setupGlobal.accept()
|
||||
self.setupOps.accept()
|
||||
self.obj.Document.recompute()
|
||||
self.template.updateUI()
|
||||
|
||||
def setupUi(self, activate):
|
||||
self.setupGlobal.setupUi()
|
||||
@@ -1023,6 +1038,13 @@ class TaskPanel:
|
||||
if activate in ['Workplan', 'Operations']:
|
||||
self.form.setCurrentIndex(4)
|
||||
|
||||
self.form.currentChanged.connect(self.tabPageChanged)
|
||||
self.template.exportButton().clicked.connect(self.templateExport)
|
||||
|
||||
def templateExport(self):
|
||||
self.getFields()
|
||||
PathJobCmd.CommandJobTemplateExport.SaveDialog(self.obj, self.template)
|
||||
|
||||
def open(self):
|
||||
FreeCADGui.Selection.addObserver(self)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user