First cut on splitting GUI into generic part and op specifics.
This commit is contained in:
committed by
Yorik van Havre
parent
8d562e692d
commit
45b890b308
@@ -62,6 +62,9 @@
|
||||
<file>panels/HoldingTagsEdit.ui</file>
|
||||
<file>panels/JobEdit.ui</file>
|
||||
<file>panels/MillFaceEdit.ui</file>
|
||||
<file>panels/PageOpContourEdit.ui</file>
|
||||
<file>panels/PageHeightsEdit.ui</file>
|
||||
<file>panels/PageDepthsEdit.ui</file>
|
||||
<file>panels/PocketEdit.ui</file>
|
||||
<file>panels/PointEdit.ui</file>
|
||||
<file>panels/ProfileEdgesEdit.ui</file>
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>352</width>
|
||||
<height>400</height>
|
||||
<width>445</width>
|
||||
<height>451</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
@@ -23,132 +23,15 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QToolBox" name="toolBox">
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="Depths">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>108</width>
|
||||
<height>92</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="icon">
|
||||
<iconset resource="../Path.qrc">
|
||||
<normaloff>:/icons/Path-Depths.svg</normaloff>:/icons/Path-Depths.svg</iconset>
|
||||
</attribute>
|
||||
<attribute name="label">
|
||||
<string>Depths</string>
|
||||
</attribute>
|
||||
<layout class="QFormLayout" name="formLayout_3">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Start Depth</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="Gui::InputField" name="finalDepth">
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">mm</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Final Depth</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Step Down</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="Gui::InputField" name="startDepth">
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">mm</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="Gui::InputField" name="stepDown">
|
||||
<property name="minimum" stdset="0">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">mm</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="Heights">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>141</width>
|
||||
<height>65</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="icon">
|
||||
<iconset resource="../Path.qrc">
|
||||
<normaloff>:/icons/Path-Heights.svg</normaloff>:/icons/Path-Heights.svg</iconset>
|
||||
</attribute>
|
||||
<attribute name="label">
|
||||
<string>Heights</string>
|
||||
</attribute>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="Gui::InputField" name="safeHeight">
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">mm</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Safe Height</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="Gui::InputField" name="clearanceHeight">
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">mm</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Clearance Height</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>336</width>
|
||||
<height>303</height>
|
||||
<width>427</width>
|
||||
<height>396</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="icon">
|
||||
|
||||
51
src/Mod/Path/Gui/Resources/panels/PageDepthsEdit.ui
Normal file
51
src/Mod/Path/Gui/Resources/panels/PageDepthsEdit.ui
Normal file
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Form</class>
|
||||
<widget class="QWidget" name="Form">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>394</width>
|
||||
<height>403</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLineEdit" name="startDepth"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Start Depth</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLineEdit" name="finalDepth"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Final Depth</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLineEdit" name="steopDown"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Step Down</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
50
src/Mod/Path/Gui/Resources/panels/PageHeightsEdit.ui
Normal file
50
src/Mod/Path/Gui/Resources/panels/PageHeightsEdit.ui
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Form</class>
|
||||
<widget class="QWidget" name="Form">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>447</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="Gui::InputField" name="safeHeight"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Safe Height</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="Gui::InputField" name="clearanceHeight"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Clearance Height</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::InputField</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>Gui/InputField.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../Path.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
95
src/Mod/Path/Gui/Resources/panels/PageOpContourEdit.ui
Normal file
95
src/Mod/Path/Gui/Resources/panels/PageOpContourEdit.ui
Normal file
@@ -0,0 +1,95 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Form</class>
|
||||
<widget class="QWidget" name="Form">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>424</width>
|
||||
<height>428</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Tool Controller</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="toolController"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Direction</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="direction">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>CW</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>CCW</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="useStartPoint">
|
||||
<property name="text">
|
||||
<string>Use Start Point</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="useCompensation">
|
||||
<property name="text">
|
||||
<string>Use Compensation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Extra Offset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="Gui::InputField" name="extraOffset"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::InputField</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>Gui/InputField.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -44,11 +44,12 @@ PathLog.trackModule()
|
||||
def translate(context, text, disambig=None):
|
||||
return QtCore.QCoreApplication.translate(context, text, disambig)
|
||||
|
||||
FeatureTool = 0x01
|
||||
FeatureDepths = 0x02
|
||||
FeatureHeights = 0x04
|
||||
FeatureStartPoint = 0x08
|
||||
|
||||
class ObjectOp(object):
|
||||
FeatureTool = 0x01
|
||||
FeatureDepths = 0x02
|
||||
FeatureHeights = 0x04
|
||||
FeatureStartPoint = 0x08
|
||||
|
||||
def __init__(self, obj):
|
||||
PathLog.track()
|
||||
@@ -56,19 +57,19 @@ class ObjectOp(object):
|
||||
obj.addProperty("App::PropertyBool", "Active", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "Make False, to prevent operation from generating code"))
|
||||
obj.addProperty("App::PropertyString", "Comment", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "An optional comment for this Contour"))
|
||||
|
||||
if self.FeatureTool & self.opFeatures(obj):
|
||||
if FeatureTool & self.opFeatures(obj):
|
||||
obj.addProperty("App::PropertyLink", "ToolController", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "The tool controller that will be used to calculate the path"))
|
||||
|
||||
if self.FeatureDepths & self.opFeatures(obj):
|
||||
if FeatureDepths & self.opFeatures(obj):
|
||||
obj.addProperty("App::PropertyDistance", "StepDown", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Incremental Step Down of Tool"))
|
||||
obj.addProperty("App::PropertyDistance", "StartDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Starting Depth of Tool- first cut depth in Z"))
|
||||
obj.addProperty("App::PropertyDistance", "FinalDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Final Depth of Tool- lowest value in Z"))
|
||||
|
||||
if self.FeatureHeights & self.opFeatures(obj):
|
||||
if FeatureHeights & self.opFeatures(obj):
|
||||
obj.addProperty("App::PropertyDistance", "ClearanceHeight", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "The height needed to clear clamps and obstructions"))
|
||||
obj.addProperty("App::PropertyDistance", "SafeHeight", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Rapid Safety Height between locations."))
|
||||
|
||||
if self.FeatureStartPoint & self.opFeatures(obj):
|
||||
if FeatureStartPoint & self.opFeatures(obj):
|
||||
obj.addProperty("App::PropertyVector", "StartPoint", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "The start point of this path"))
|
||||
obj.addProperty("App::PropertyBool", "UseStartPoint", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "make True, if specifying a Start Point"))
|
||||
|
||||
@@ -90,7 +91,7 @@ class ObjectOp(object):
|
||||
return None
|
||||
|
||||
def opFeatures(self, obj):
|
||||
return self.FeatureTool | self.FeatureDepths | self.FeatureHeights | self.FeatureStartPoint
|
||||
return FeatureTool | FeatureDepths | FeatureHeights | FeatureStartPoint
|
||||
|
||||
def onChanged(self, obj, prop):
|
||||
if prop in ['AreaParams', 'PathParams', 'removalshape']:
|
||||
@@ -102,10 +103,10 @@ class ObjectOp(object):
|
||||
|
||||
obj.Active = True
|
||||
|
||||
if self.FeatureTool & self.opFeatures(obj):
|
||||
if FeatureTool & self.opFeatures(obj):
|
||||
obj.ToolController = PathUtils.findToolController(obj)
|
||||
|
||||
if self.FeatureDepths & self.opFeatures(obj):
|
||||
if FeatureDepths & self.opFeatures(obj):
|
||||
try:
|
||||
shape = self.opShapeForDepths(obj)
|
||||
except:
|
||||
@@ -121,7 +122,7 @@ class ObjectOp(object):
|
||||
obj.FinalDepth = 0.0
|
||||
obj.StepDown = 1.0
|
||||
|
||||
if self.FeatureHeights & self.opFeatures(obj):
|
||||
if FeatureHeights & self.opFeatures(obj):
|
||||
try:
|
||||
shape = self.opShapeForDepths(obj)
|
||||
except:
|
||||
@@ -135,7 +136,7 @@ class ObjectOp(object):
|
||||
obj.ClearanceHeight = 10.0
|
||||
obj.SafeHeight = 8.0
|
||||
|
||||
if self.FeatureStartPoint & self.opFeatures(obj):
|
||||
if FeatureStartPoint & self.opFeatures(obj):
|
||||
obj.UseStartPoint = False
|
||||
|
||||
self.opSetDefaultValues(obj)
|
||||
@@ -233,7 +234,7 @@ class ObjectOp(object):
|
||||
|
||||
shape = self.opShape(obj, commandlist)
|
||||
|
||||
if self.FeatureStartPoint and obj.UseStartPoint:
|
||||
if FeatureStartPoint and obj.UseStartPoint:
|
||||
start = obj.StartPoint
|
||||
else:
|
||||
start = FreeCAD.Vector()
|
||||
|
||||
243
src/Mod/Path/PathScripts/PathAreaOpGui.py
Normal file
243
src/Mod/Path/PathScripts/PathAreaOpGui.py
Normal file
@@ -0,0 +1,243 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# ***************************************************************************
|
||||
# * *
|
||||
# * Copyright (c) 2017 sliptonic <shopinthewoods@gmail.com> *
|
||||
# * *
|
||||
# * This program is free software; you can redistribute it and/or modify *
|
||||
# * it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||
# * as published by the Free Software Foundation; either version 2 of *
|
||||
# * the License, or (at your option) any later version. *
|
||||
# * for detail see the LICENCE text file. *
|
||||
# * *
|
||||
# * This program is distributed in the hope that it will be useful, *
|
||||
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
# * GNU Library General Public License for more details. *
|
||||
# * *
|
||||
# * You should have received a copy of the GNU Library General Public *
|
||||
# * License along with this program; if not, write to the Free Software *
|
||||
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
||||
# * USA *
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import Path
|
||||
import PathScripts.PathAreaOp as PathAreaOp
|
||||
import PathScripts.PathContour as PathContour
|
||||
import PathScripts.PathLog as PathLog
|
||||
import PathScripts.PathSelection as PathSelection
|
||||
|
||||
from PathScripts import PathUtils
|
||||
from PySide import QtCore, QtGui
|
||||
|
||||
def translate(context, text, disambig=None):
|
||||
return QtCore.QCoreApplication.translate(context, text, disambig)
|
||||
|
||||
|
||||
class ViewProvider(object):
|
||||
|
||||
def __init__(self, vobj):
|
||||
PathLog.track()
|
||||
vobj.Proxy = self
|
||||
|
||||
def attach(self, vobj):
|
||||
PathLog.track()
|
||||
self.Object = vobj.Object
|
||||
return
|
||||
|
||||
def deleteObjectsOnReject(self):
|
||||
PathLog.track()
|
||||
return hasattr(self, 'deleteOnReject') and self.deleteOnReject
|
||||
|
||||
def setEdit(self, vobj, mode=0):
|
||||
PathLog.track()
|
||||
FreeCADGui.Control.closeDialog()
|
||||
page = self.getTaskPanelOpPage(vobj.Object)
|
||||
selection = self.getSelectionFactory()
|
||||
taskd = TaskPanel(vobj.Object, self.deleteObjectsOnReject(), page, selection)
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
taskd.setupUi()
|
||||
self.deleteOnReject = False
|
||||
return True
|
||||
|
||||
def getIcon(self):
|
||||
return ":/icons/Path-Contour.svg"
|
||||
|
||||
def __getstate__(self):
|
||||
PathLog.track()
|
||||
return None
|
||||
|
||||
def __setstate__(self, state):
|
||||
PathLog.track()
|
||||
return None
|
||||
|
||||
class TaskPanelPage(object):
|
||||
def __init__(self, obj):
|
||||
self.obj = obj
|
||||
self.form = self.getForm()
|
||||
self.setDirty()
|
||||
self.setTitle('-')
|
||||
|
||||
def setDirty(self):
|
||||
self.isdirty = True
|
||||
def setClean(self):
|
||||
self.isdirty = False
|
||||
|
||||
def pageGetFields(self):
|
||||
self.getFields(self, obj)
|
||||
self.setDirty()
|
||||
|
||||
def pageSetFields(self):
|
||||
self.setFields(self.obj)
|
||||
|
||||
def pageRegisterSignalHandlers(self):
|
||||
for signal in self.getSignalsForUpdate(self.obj):
|
||||
signal.connect(self.pageGetFields)
|
||||
|
||||
def setTitle(self, title):
|
||||
self.title = title
|
||||
def getTitle(self, obj):
|
||||
return self.title
|
||||
|
||||
class TaskPanelHeightsPage(TaskPanelPage):
|
||||
def getForm(self):
|
||||
return FreeCADGui.PySideUic.loadUi(":/panels/PageHeightsEdit.ui")
|
||||
|
||||
def getTitle(self, obj):
|
||||
return translate("Path_AreaOp", "Heights")
|
||||
|
||||
def getFields(self, obj):
|
||||
obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value
|
||||
obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value
|
||||
|
||||
def setFields(self, obj):
|
||||
self.form.safeHeight.setText(FreeCAD.Units.Quantity(obj.SafeHeight.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.clearanceHeight.setText(FreeCAD.Units.Quantity(obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString)
|
||||
|
||||
def getSignalsForUpdate(self, obj):
|
||||
return [self.form.safeHeight.editingFinished, self.form.clearanceHeight.editingFinished]
|
||||
|
||||
class TaskPanel(object):
|
||||
|
||||
def __init__(self, obj, deleteOnReject, page, selectionFactory):
|
||||
FreeCAD.ActiveDocument.openTransaction(translate("Path_AreaOp", "AreaOp Operation"))
|
||||
self.form = QtGui.QToolBox()
|
||||
self.deleteOnReject = deleteOnReject
|
||||
self.featurePages = []
|
||||
|
||||
if PathAreaOp.FeatureHeights & obj.Proxy.opFeatures(obj):
|
||||
self.featurePages.append(TaskPanelHeightsPage(obj))
|
||||
|
||||
page.setTitle(translate('PathAreaOp', 'Operation'))
|
||||
self.featurePages.append(page)
|
||||
|
||||
for page in self.featurePages:
|
||||
self.form.addItem(page.form, page.getTitle(obj))
|
||||
|
||||
self.selectionFactory = selectionFactory
|
||||
self.obj = obj
|
||||
self.isdirty = True
|
||||
|
||||
def isDirty(self):
|
||||
for page in self.featurePages:
|
||||
if page.isdirty:
|
||||
return True
|
||||
return self.isdirty
|
||||
|
||||
def setClean(self):
|
||||
self.isdirty = False
|
||||
for page in self.featurePages:
|
||||
page.setClean()
|
||||
|
||||
def accept(self):
|
||||
FreeCADGui.Control.closeDialog()
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
FreeCADGui.Selection.removeObserver(self.s)
|
||||
if self.isDirty():
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
def reject(self):
|
||||
FreeCADGui.Control.closeDialog()
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
FreeCAD.ActiveDocument.abortTransaction()
|
||||
FreeCADGui.Selection.removeObserver(self.s)
|
||||
if self.deleteOnReject:
|
||||
FreeCAD.ActiveDocument.openTransaction(translate("Path_AreaOp", "Uncreate AreaOp Operation"))
|
||||
FreeCAD.ActiveDocument.removeObject(self.obj.Name)
|
||||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
def clicked(self, button):
|
||||
if button == QtGui.QDialogButtonBox.Apply:
|
||||
self.panelGetFields()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
self.setClean()
|
||||
|
||||
def panelGetFields(self):
|
||||
PathLog.track()
|
||||
for page in self.featurePages:
|
||||
page.pageGetFields(self.obj)
|
||||
self.opGetFields(self.obj)
|
||||
|
||||
def panelSetFields(self):
|
||||
PathLog.track()
|
||||
for page in self.featurePages:
|
||||
page.pageSetFields()
|
||||
|
||||
def open(self):
|
||||
self.s = SelObserver(self.selectionFactory)
|
||||
# install the function mode resident
|
||||
FreeCADGui.Selection.addObserver(self.s)
|
||||
|
||||
def getStandardButtons(self):
|
||||
return int(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Apply | QtGui.QDialogButtonBox.Cancel)
|
||||
|
||||
def setupUi(self):
|
||||
PathLog.track()
|
||||
self.panelSetFields()
|
||||
for page in self.featurePages:
|
||||
page.pageRegisterSignalHandlers()
|
||||
|
||||
class SelObserver:
|
||||
|
||||
def __init__(self, factory):
|
||||
factory()
|
||||
|
||||
def __del__(self):
|
||||
PathSelection.clear()
|
||||
|
||||
def addSelection(self, doc, obj, sub, pnt):
|
||||
FreeCADGui.doCommand('Gui.Selection.addSelection(FreeCAD.ActiveDocument.' + obj + ')')
|
||||
FreeCADGui.updateGui()
|
||||
|
||||
class _CommandSetStartPoint:
|
||||
def GetResources(self):
|
||||
return {'Pixmap': 'Path-StartPoint',
|
||||
'MenuText': QtCore.QT_TRANSLATE_NOOP("Path_AreaOp", "Pick Start Point"),
|
||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Path_AreaOp", "Pick Start Point")}
|
||||
|
||||
def IsActive(self):
|
||||
if FreeCAD.ActiveDocument is None:
|
||||
return False
|
||||
sel = FreeCADGui.Selection.getSelection()
|
||||
if not sel:
|
||||
return False
|
||||
obj = sel[0]
|
||||
return obj and hasattr(obj, 'StartPoint')
|
||||
|
||||
def setpoint(self, point, o):
|
||||
obj = FreeCADGui.Selection.getSelection()[0]
|
||||
obj.StartPoint.x = point.x
|
||||
obj.StartPoint.y = point.y
|
||||
obj.StartPoint.z = obj.ClearanceHeight.Value
|
||||
|
||||
def Activated(self):
|
||||
FreeCADGui.Snapper.getPoint(callback=self.setpoint)
|
||||
|
||||
FreeCADGui.addCommand('Set_StartPoint', _CommandSetStartPoint())
|
||||
|
||||
FreeCAD.Console.PrintLog("Loading PathAreaOpGui... done\n")
|
||||
@@ -25,8 +25,10 @@
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import Path
|
||||
import PathScripts.PathAreaOpGui as PathAreaOpGui
|
||||
import PathScripts.PathContour as PathContour
|
||||
import PathScripts.PathLog as PathLog
|
||||
import PathScripts.PathSelection as PathSelection
|
||||
|
||||
from PathScripts import PathUtils
|
||||
from PySide import QtCore, QtGui
|
||||
@@ -34,60 +36,74 @@ from PySide import QtCore, QtGui
|
||||
def translate(context, text, disambig=None):
|
||||
return QtCore.QCoreApplication.translate(context, text, disambig)
|
||||
|
||||
class _ViewProviderContour:
|
||||
class TaskPanelOpPage(PathAreaOpGui.TaskPanelPage):
|
||||
|
||||
def __init__(self, vobj):
|
||||
PathLog.track()
|
||||
vobj.Proxy = self
|
||||
def opSelectionFactory(self):
|
||||
return PathSelection.contourselect
|
||||
|
||||
def attach(self, vobj):
|
||||
PathLog.track()
|
||||
self.Object = vobj.Object
|
||||
return
|
||||
def getForm(self):
|
||||
return FreeCADGui.PySideUic.loadUi(":/panels/PageOpContourEdit.ui")
|
||||
|
||||
def deleteObjectsOnReject(self):
|
||||
def getFields(self, obj):
|
||||
PathLog.track()
|
||||
return hasattr(self, 'deleteOnReject') and self.deleteOnReject
|
||||
self.obj.OffsetExtra = FreeCAD.Units.Quantity(self.form.extraOffset.text()).Value
|
||||
self.obj.UseComp = self.form.useCompensation.isChecked()
|
||||
self.obj.Direction = str(self.form.direction.currentText())
|
||||
tc = PathUtils.findToolController(self.obj, self.form.toolController.currentText())
|
||||
self.obj.ToolController = tc
|
||||
|
||||
def setEdit(self, vobj, mode=0):
|
||||
def setFields(self, obj):
|
||||
PathLog.track()
|
||||
FreeCADGui.Control.closeDialog()
|
||||
taskd = TaskPanel(vobj.Object, self.deleteObjectsOnReject())
|
||||
taskd.obj = vobj.Object
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
taskd.setupUi()
|
||||
self.deleteOnReject = False
|
||||
return True
|
||||
self.form.extraOffset.setText(FreeCAD.Units.Quantity(self.obj.OffsetExtra.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.useCompensation.setChecked(self.obj.UseComp)
|
||||
# self.form.useStartPoint.setChecked(self.obj.UseStartPoint)
|
||||
|
||||
index = self.form.direction.findText(
|
||||
self.obj.Direction, QtCore.Qt.MatchFixedString)
|
||||
if index >= 0:
|
||||
self.form.direction.blockSignals(True)
|
||||
self.form.direction.setCurrentIndex(index)
|
||||
self.form.direction.blockSignals(False)
|
||||
|
||||
controllers = PathUtils.getToolControllers(self.obj)
|
||||
labels = [c.Label for c in controllers]
|
||||
self.form.toolController.blockSignals(True)
|
||||
self.form.toolController.addItems(labels)
|
||||
self.form.toolController.blockSignals(False)
|
||||
|
||||
if self.obj.ToolController is None:
|
||||
self.obj.ToolController = PathUtils.findToolController(self.obj)
|
||||
|
||||
if self.obj.ToolController is not None:
|
||||
index = self.form.toolController.findText(
|
||||
self.obj.ToolController.Label, QtCore.Qt.MatchFixedString)
|
||||
if index >= 0:
|
||||
self.form.toolController.blockSignals(True)
|
||||
self.form.toolController.setCurrentIndex(index)
|
||||
self.form.toolController.blockSignals(False)
|
||||
else:
|
||||
self.obj.ToolController = PathUtils.findToolController(self.obj)
|
||||
|
||||
def getSignalsForUpdate(self, obj):
|
||||
PathLog.track()
|
||||
signals = []
|
||||
signals.append(self.form.direction.currentIndexChanged)
|
||||
signals.append(self.form.toolController.currentIndexChanged)
|
||||
signals.append(self.form.useCompensation.clicked)
|
||||
signals.append(self.form.useStartPoint.clicked)
|
||||
signals.append(self.form.extraOffset.editingFinished)
|
||||
return signals
|
||||
|
||||
class _ViewProviderContour(PathAreaOpGui.ViewProvider):
|
||||
|
||||
def getTaskPanelOpPage(self, obj):
|
||||
return TaskPanelOpPage(obj)
|
||||
|
||||
def getIcon(self):
|
||||
return ":/icons/Path-Contour.svg"
|
||||
|
||||
def __getstate__(self):
|
||||
PathLog.track()
|
||||
return None
|
||||
|
||||
def __setstate__(self, state):
|
||||
PathLog.track()
|
||||
return None
|
||||
|
||||
|
||||
class _CommandSetStartPoint:
|
||||
def GetResources(self):
|
||||
return {'Pixmap': 'Path-StartPoint',
|
||||
'MenuText': QtCore.QT_TRANSLATE_NOOP("Path_Contour", "Pick Start Point"),
|
||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Path_Contour", "Pick Start Point")}
|
||||
|
||||
def IsActive(self):
|
||||
return FreeCAD.ActiveDocument is not None
|
||||
|
||||
def setpoint(self, point, o):
|
||||
obj = FreeCADGui.Selection.getSelection()[0]
|
||||
obj.StartPoint.x = point.x
|
||||
obj.StartPoint.y = point.y
|
||||
obj.StartPoint.z = obj.ClearanceHeight.Value
|
||||
|
||||
def Activated(self):
|
||||
FreeCADGui.Snapper.getPoint(callback=self.setpoint)
|
||||
def getSelectionFactory(self):
|
||||
return PathSelection.contourselect
|
||||
|
||||
def Create(name):
|
||||
FreeCAD.ActiveDocument.openTransaction(translate("Path", "Create a Contour"))
|
||||
@@ -116,148 +132,7 @@ class CommandPathContour:
|
||||
def Activated(self):
|
||||
return Create("Contour")
|
||||
|
||||
class TaskPanel:
|
||||
def __init__(self, obj, deleteOnReject):
|
||||
FreeCAD.ActiveDocument.openTransaction(translate("Path_Contour", "Contour Operation"))
|
||||
self.form = FreeCADGui.PySideUic.loadUi(":/panels/ContourEdit.ui")
|
||||
self.deleteOnReject = deleteOnReject
|
||||
self.isDirty = True
|
||||
|
||||
def accept(self):
|
||||
FreeCADGui.Control.closeDialog()
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
FreeCADGui.Selection.removeObserver(self.s)
|
||||
if self.isDirty:
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
def reject(self):
|
||||
FreeCADGui.Control.closeDialog()
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
FreeCAD.ActiveDocument.abortTransaction()
|
||||
FreeCADGui.Selection.removeObserver(self.s)
|
||||
if self.deleteOnReject:
|
||||
FreeCAD.ActiveDocument.openTransaction(translate("Path_Contour", "Uncreate Contour Operation"))
|
||||
FreeCAD.ActiveDocument.removeObject(self.obj.Name)
|
||||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
def clicked(self, button):
|
||||
if button == QtGui.QDialogButtonBox.Apply:
|
||||
self.getFields()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
self.isDirty = False
|
||||
|
||||
def getFields(self):
|
||||
PathLog.track()
|
||||
if self.obj:
|
||||
if hasattr(self.obj, "StartDepth"):
|
||||
self.obj.StartDepth = FreeCAD.Units.Quantity(self.form.startDepth.text()).Value
|
||||
if hasattr(self.obj, "FinalDepth"):
|
||||
self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value
|
||||
if hasattr(self.obj, "SafeHeight"):
|
||||
self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value
|
||||
if hasattr(self.obj, "ClearanceHeight"):
|
||||
self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value
|
||||
if hasattr(self.obj, "StepDown"):
|
||||
self.obj.StepDown = FreeCAD.Units.Quantity(self.form.stepDown.text()).Value
|
||||
if hasattr(self.obj, "OffsetExtra"):
|
||||
self.obj.OffsetExtra = FreeCAD.Units.Quantity(self.form.extraOffset.text()).Value
|
||||
if hasattr(self.obj, "UseComp"):
|
||||
self.obj.UseComp = self.form.useCompensation.isChecked()
|
||||
# if hasattr(self.obj, "UseStartPoint"):
|
||||
# self.obj.UseStartPoint = self.form.useStartPoint.isChecked()
|
||||
if hasattr(self.obj, "Direction"):
|
||||
self.obj.Direction = str(self.form.direction.currentText())
|
||||
if hasattr(self.obj, "ToolController"):
|
||||
tc = PathUtils.findToolController(self.obj, self.form.uiToolController.currentText())
|
||||
self.obj.ToolController = tc
|
||||
self.isDirty = True
|
||||
|
||||
def setFields(self):
|
||||
PathLog.track()
|
||||
self.form.startDepth.setText(FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.finalDepth.setText(FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.stepDown.setText(FreeCAD.Units.Quantity(self.obj.StepDown.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.safeHeight.setText(FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.clearanceHeight.setText(FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.extraOffset.setText(FreeCAD.Units.Quantity(self.obj.OffsetExtra.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.useCompensation.setChecked(self.obj.UseComp)
|
||||
# self.form.useStartPoint.setChecked(self.obj.UseStartPoint)
|
||||
|
||||
index = self.form.direction.findText(
|
||||
self.obj.Direction, QtCore.Qt.MatchFixedString)
|
||||
if index >= 0:
|
||||
self.form.direction.blockSignals(True)
|
||||
self.form.direction.setCurrentIndex(index)
|
||||
self.form.direction.blockSignals(False)
|
||||
|
||||
controllers = PathUtils.getToolControllers(self.obj)
|
||||
labels = [c.Label for c in controllers]
|
||||
self.form.uiToolController.blockSignals(True)
|
||||
self.form.uiToolController.addItems(labels)
|
||||
self.form.uiToolController.blockSignals(False)
|
||||
|
||||
if self.obj.ToolController is None:
|
||||
self.obj.ToolController = PathUtils.findToolController(self.obj)
|
||||
|
||||
if self.obj.ToolController is not None:
|
||||
index = self.form.uiToolController.findText(
|
||||
self.obj.ToolController.Label, QtCore.Qt.MatchFixedString)
|
||||
if index >= 0:
|
||||
self.form.uiToolController.blockSignals(True)
|
||||
self.form.uiToolController.setCurrentIndex(index)
|
||||
self.form.uiToolController.blockSignals(False)
|
||||
else:
|
||||
self.obj.ToolController = PathUtils.findToolController(self.obj)
|
||||
|
||||
def open(self):
|
||||
self.s = SelObserver()
|
||||
# install the function mode resident
|
||||
FreeCADGui.Selection.addObserver(self.s)
|
||||
|
||||
def getStandardButtons(self):
|
||||
return int(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Apply | QtGui.QDialogButtonBox.Cancel)
|
||||
|
||||
def setupUi(self):
|
||||
PathLog.track()
|
||||
# Connect Signals and Slots
|
||||
# Depths
|
||||
self.form.startDepth.editingFinished.connect(self.getFields)
|
||||
self.form.finalDepth.editingFinished.connect(self.getFields)
|
||||
self.form.stepDown.editingFinished.connect(self.getFields)
|
||||
|
||||
# Heights
|
||||
self.form.safeHeight.editingFinished.connect(self.getFields)
|
||||
self.form.clearanceHeight.editingFinished.connect(self.getFields)
|
||||
|
||||
# operation
|
||||
self.form.direction.currentIndexChanged.connect(self.getFields)
|
||||
self.form.uiToolController.currentIndexChanged.connect(self.getFields)
|
||||
self.form.useCompensation.clicked.connect(self.getFields)
|
||||
self.form.useStartPoint.clicked.connect(self.getFields)
|
||||
self.form.extraOffset.editingFinished.connect(self.getFields)
|
||||
|
||||
self.setFields()
|
||||
|
||||
|
||||
class SelObserver:
|
||||
def __init__(self):
|
||||
import PathScripts.PathSelection as PST
|
||||
PST.contourselect()
|
||||
|
||||
def __del__(self):
|
||||
import PathScripts.PathSelection as PST
|
||||
PST.clear()
|
||||
|
||||
def addSelection(self, doc, obj, sub, pnt):
|
||||
FreeCADGui.doCommand('Gui.Selection.addSelection(FreeCAD.ActiveDocument.' + obj + ')')
|
||||
FreeCADGui.updateGui()
|
||||
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
# register the FreeCAD command
|
||||
FreeCADGui.addCommand('Path_Contour', CommandPathContour())
|
||||
FreeCADGui.addCommand('Set_StartPoint', _CommandSetStartPoint())
|
||||
# register the FreeCAD command
|
||||
FreeCADGui.addCommand('Path_Contour', CommandPathContour())
|
||||
|
||||
FreeCAD.Console.PrintLog("Loading PathContourGui... done\n")
|
||||
|
||||
Reference in New Issue
Block a user