Added UI page pocket extension; changed selection agent.
This commit is contained in:
@@ -96,6 +96,7 @@
|
||||
<file>panels/PageOpDeburrEdit.ui</file>
|
||||
<file>panels/PageOpDrillingEdit.ui</file>
|
||||
<file>panels/PageOpEngraveEdit.ui</file>
|
||||
<file>panels/PageOpExtensionEdit.ui</file>
|
||||
<file>panels/PageOpHelixEdit.ui</file>
|
||||
<file>panels/PageOpPocketFullEdit.ui</file>
|
||||
<file>panels/PageOpProfileFullEdit.ui</file>
|
||||
|
||||
335
src/Mod/Path/Gui/Resources/panels/PageOpExtensionEdit.ui
Normal file
335
src/Mod/Path/Gui/Resources/panels/PageOpExtensionEdit.ui
Normal file
@@ -0,0 +1,335 @@
|
||||
<?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>324</width>
|
||||
<height>550</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="negXInput">
|
||||
<property name="title">
|
||||
<string>Negative X</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="negXIcon">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../../../../../Gui/Icons/resource.qrc">:/icons/button_left.svg</pixmap>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::QuantitySpinBox" name="negXValue">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Size of extension for each edge.</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListView" name="negXList">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>List of edges to be extended.</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="negXAdd">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Add selected edge from 3d view to list.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../../Gui/Icons/resource.qrc">
|
||||
<normaloff>:/icons/list-add.svg</normaloff>:/icons/list-add.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="negXRemove">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Remove selected edge from list above.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../../Gui/Icons/resource.qrc">
|
||||
<normaloff>:/icons/list-remove.svg</normaloff>:/icons/list-remove.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QGroupBox" name="posYInput">
|
||||
<property name="title">
|
||||
<string>Positive Y</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="posYIcon">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../../../../../Gui/Icons/resource.qrc">:/icons/button_up.svg</pixmap>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::QuantitySpinBox" name="posYValue">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Size of extension for each edge.</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListView" name="posYList">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>List of edges to be extended.</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_8" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QPushButton" name="posYAdd">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Add selected edge from 3d view to list.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../../Gui/Icons/resource.qrc">
|
||||
<normaloff>:/icons/list-add.svg</normaloff>:/icons/list-add.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="posYRemove">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Remove selected edge from list above.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../../Gui/Icons/resource.qrc">
|
||||
<normaloff>:/icons/list-remove.svg</normaloff>:/icons/list-remove.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QGroupBox" name="posXInput">
|
||||
<property name="title">
|
||||
<string>Positive X</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="posXIcon">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../../../../../Gui/Icons/resource.qrc">:/icons/button_right.svg</pixmap>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::QuantitySpinBox" name="posXValue">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Size of extension for each edge.</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListView" name="posXList">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>List of edges to be extended.</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_4" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="posXAdd">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Add selected edge from 3d view to list.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../../Gui/Icons/resource.qrc">
|
||||
<normaloff>:/icons/list-add.svg</normaloff>:/icons/list-add.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="posXRemove">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Remove selected edge from list above.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../../Gui/Icons/resource.qrc">
|
||||
<normaloff>:/icons/list-remove.svg</normaloff>:/icons/list-remove.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="negYInput">
|
||||
<property name="title">
|
||||
<string>Negative Y</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="negYIcon">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../../../../../Gui/Icons/resource.qrc">:/icons/button_down.svg</pixmap>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::QuantitySpinBox" name="negYValue">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Size of extension for each edge.</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListView" name="negYList">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>List of edges to be extended.</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_6" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QPushButton" name="negYAdd">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Add selected edge from 3d view to list.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../../Gui/Icons/resource.qrc">
|
||||
<normaloff>:/icons/list-add.svg</normaloff>:/icons/list-add.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="negYRemove">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Remove selected edge from list above.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../../Gui/Icons/resource.qrc">
|
||||
<normaloff>:/icons/list-remove.svg</normaloff>:/icons/list-remove.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="info">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Panel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Requires "Use Outline"!</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::QuantitySpinBox</class>
|
||||
<extends>QDoubleSpinBox</extends>
|
||||
<header>Gui/QuantitySpinBox.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../../../../Gui/Icons/resource.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -47,7 +47,7 @@ class PathWorkbench (Workbench):
|
||||
"Path workbench"
|
||||
|
||||
def __init__(self):
|
||||
self.__class__.Icon = FreeCAD.getResourceDir() + "Mod/Path/Resources/icons/PathWorkbench.svg"
|
||||
self.__class__.Icon = FreeCAD.getResourceDir() + "Mod/Path/Gui/Resources/icons/PathWorkbench.svg"
|
||||
self.__class__.MenuText = "Path"
|
||||
self.__class__.ToolTip = "Path workbench"
|
||||
|
||||
|
||||
@@ -399,36 +399,41 @@ class TaskPanelBaseGeometryPage(TaskPanelPage):
|
||||
return 'edges'
|
||||
return 'nothing'
|
||||
|
||||
def addBaseGeometrySelection(self, sel):
|
||||
def selectionSupportedAsBaseGeometry(self, selection, ignoreErrors):
|
||||
if len(selection) != 1:
|
||||
if not ignoreErrors:
|
||||
PathLog.error(translate("PathProject", "Please select %s from a single solid" % self.featureName()))
|
||||
return False
|
||||
sel = selection[0]
|
||||
if sel.HasSubObjects:
|
||||
if not self.supportsVertexes() and sel.SubObjects[0].ShapeType == "Vertex":
|
||||
PathLog.error(translate("PathProject", "Vertexes are not supported"))
|
||||
if not self.supportsVertexes() and selection[0].SubObjects[0].ShapeType == "Vertex":
|
||||
if not ignoreErrors:
|
||||
PathLog.error(translate("PathProject", "Vertexes are not supported"))
|
||||
return False
|
||||
if not self.supportsEdges() and sel.SubObjects[0].ShapeType == "Edge":
|
||||
PathLog.error(translate("PathProject", "Edges are not supported"))
|
||||
if not self.supportsEdges() and selection[0].SubObjects[0].ShapeType == "Edge":
|
||||
if not ignoreErrors:
|
||||
PathLog.error(translate("PathProject", "Edges are not supported"))
|
||||
return False
|
||||
if not self.supportsFaces() and sel.SubObjects[0].ShapeType == "Face":
|
||||
PathLog.error(translate("PathProject", "Faces are not supported"))
|
||||
if not self.supportsFaces() and selection[0].SubObjects[0].ShapeType == "Face":
|
||||
if not ignoreErrors:
|
||||
PathLog.error(translate("PathProject", "Faces are not supported"))
|
||||
return False
|
||||
else:
|
||||
if not self.supportsPanels() or not 'Panel' in sel.Object.Name:
|
||||
PathLog.error(translate("PathProject", "Please select %s of a solid" % self.featureName()))
|
||||
if not ignoreErrors:
|
||||
PathLog.error(translate("PathProject", "Please select %s of a solid" % self.featureName()))
|
||||
return False
|
||||
|
||||
for sub in sel.SubElementNames:
|
||||
self.obj.Proxy.addBase(self.obj, sel.Object, sub)
|
||||
return True
|
||||
|
||||
|
||||
def addBaseGeometry(self, selection):
|
||||
PathLog.track(selection)
|
||||
#if len(selection) != 1:
|
||||
# PathLog.error(translate("PathProject", "Please select %s from a single solid" % self.featureName()))
|
||||
# return False
|
||||
changed = False
|
||||
for sel in selection:
|
||||
if self.addBaseGeometrySelection(sel):
|
||||
changed = True
|
||||
return changed
|
||||
if self.selectionSupportedAsBaseGeometry(selection, False):
|
||||
sel = selection[0]
|
||||
for sub in sel.SubElementNames:
|
||||
self.obj.Proxy.addBase(self.obj, sel.Object, sub)
|
||||
return True
|
||||
return False
|
||||
|
||||
def addBase(self):
|
||||
if self.addBaseGeometry(FreeCADGui.Selection.getSelectionEx()):
|
||||
@@ -475,6 +480,11 @@ class TaskPanelBaseGeometryPage(TaskPanelPage):
|
||||
if prop in ['Base']:
|
||||
self.setFields(obj)
|
||||
|
||||
def updateSelection(self, obj, sel):
|
||||
if self.selectionSupportedAsBaseGeometry(sel, True):
|
||||
self.form.addBase.setEnabled(True)
|
||||
else:
|
||||
self.form.addBase.setEnabled(False)
|
||||
|
||||
class TaskPanelBaseLocationPage(TaskPanelPage):
|
||||
'''Page controller for base locations. Uses PathGetPoint.'''
|
||||
|
||||
@@ -53,6 +53,9 @@ def translate(context, text, disambig=None):
|
||||
class ObjectPocket(PathPocketBase.ObjectPocket):
|
||||
'''Proxy object for Pocket operation.'''
|
||||
|
||||
def areaOpFeatures(self, obj):
|
||||
return super(self.__class__, self).areaOpFeatures(obj) | PathOp.FeatureLocations
|
||||
|
||||
def initPocketOp(self, obj):
|
||||
'''initPocketOp(obj) ... setup receiver'''
|
||||
obj.addProperty("App::PropertyBool", "UseOutline", "Pocket", QtCore.QT_TRANSLATE_NOOP("App::Property", "Uses the outline of the base geometry."))
|
||||
|
||||
@@ -23,17 +23,43 @@
|
||||
# ***************************************************************************
|
||||
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import PathScripts.PathOp as PathOp
|
||||
import PathScripts.PathOpGui as PathOpGui
|
||||
import PathScripts.PathPocketShape as PathPocketShape
|
||||
import PathScripts.PathPocketBaseGui as PathPocketBaseGui
|
||||
|
||||
from PySide import QtCore
|
||||
from PySide import QtCore, QtGui
|
||||
|
||||
__title__ = "Path Pocket Shape Operation UI"
|
||||
__author__ = "sliptonic (Brad Collette)"
|
||||
__url__ = "http://www.freecadweb.org"
|
||||
__doc__ = "Pocket Shape operation page controller and command implementation."
|
||||
|
||||
class TaskPanelExtensionPage(PathOpGui.TaskPanelPage):
|
||||
|
||||
def initPage(self, obj):
|
||||
self.extensions = [self.form.negXInput, self.form.posXInput, self.form.negYInput, self.form.posYInput]
|
||||
self.setTitle("Pocket Extensions")
|
||||
self.enabled = True
|
||||
self.enable(False)
|
||||
|
||||
def enable(self, ena):
|
||||
if ena != self.enabled:
|
||||
self.enabled = ena
|
||||
if ena:
|
||||
self.form.info.hide()
|
||||
for ext in self.extensions:
|
||||
ext.setEnabled(True)
|
||||
else:
|
||||
self.form.info.show()
|
||||
for ext in self.extensions:
|
||||
ext.setEnabled(False)
|
||||
|
||||
def getForm(self):
|
||||
return FreeCADGui.PySideUic.loadUi(":/panels/PageOpExtensionEdit.ui")
|
||||
|
||||
|
||||
class TaskPanelOpPage(PathPocketBaseGui.TaskPanelOpPage):
|
||||
'''Page controller class for Pocket operation'''
|
||||
|
||||
@@ -41,6 +67,16 @@ class TaskPanelOpPage(PathPocketBaseGui.TaskPanelOpPage):
|
||||
'''pocketFeatures() ... return FeaturePocket (see PathPocketBaseGui)'''
|
||||
return PathPocketBaseGui.FeaturePocket | PathPocketBaseGui.FeatureOutline
|
||||
|
||||
def taskPanelBaseLocationPage(self, obj, features):
|
||||
self.extensionsPanel = TaskPanelExtensionPage(obj, features)
|
||||
return self.extensionsPanel
|
||||
|
||||
def enableExtensions(self):
|
||||
self.extensionsPanel.enable(self.form.useOutline.isChecked())
|
||||
|
||||
def pageRegisterSignalHandlers(self):
|
||||
self.form.useOutline.clicked.connect(self.enableExtensions)
|
||||
|
||||
Command = PathOpGui.SetupOperation('Pocket Shape',
|
||||
PathPocketShape.Create,
|
||||
TaskPanelOpPage,
|
||||
|
||||
@@ -168,6 +168,30 @@ class ADAPTIVEGate:
|
||||
|
||||
return adaptive
|
||||
|
||||
class POCKETSHAPEGate:
|
||||
def allow(self, doc, obj, sub):
|
||||
|
||||
try:
|
||||
obj = obj.Shape
|
||||
except:
|
||||
return False
|
||||
|
||||
if obj.ShapeType == 'Edge':
|
||||
return True
|
||||
|
||||
elif obj.ShapeType == 'Face':
|
||||
return True
|
||||
|
||||
elif obj.ShapeType == 'Solid':
|
||||
if sub and (sub[0:4] == 'Face' or sub[0:4] == 'Edge'):
|
||||
return True
|
||||
|
||||
elif obj.ShapeType == 'Compound':
|
||||
if sub and (sub[0:4] == 'Face' or sub[0:4] == 'Edge'):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
class CONTOURGate:
|
||||
def allow(self, doc, obj, sub):
|
||||
pass
|
||||
@@ -204,6 +228,10 @@ def adaptiveselect():
|
||||
FreeCADGui.Selection.addSelectionGate(ADAPTIVEGate())
|
||||
FreeCAD.Console.PrintWarning("Adaptive Select Mode\n")
|
||||
|
||||
def pocketshapeselect():
|
||||
FreeCADGui.Selection.addSelectionGate(POCKETSHAPEGate())
|
||||
FreeCAD.Console.PrintWarning("Pocketing Select Mode (shape)\n")
|
||||
|
||||
def surfaceselect():
|
||||
FreeCADGui.Selection.addSelectionGate(MESHGate())
|
||||
FreeCAD.Console.PrintWarning("Surfacing Select Mode\n")
|
||||
@@ -218,7 +246,7 @@ def select(op):
|
||||
opsel['MillFace'] = pocketselect
|
||||
opsel['Pocket'] = pocketselect
|
||||
opsel['Pocket 3D'] = pocketselect
|
||||
opsel['Pocket Shape'] = pocketselect
|
||||
opsel['Pocket Shape'] = pocketshapeselect
|
||||
opsel['Profile Edges'] = eselect
|
||||
opsel['Profile Faces'] = profileselect
|
||||
opsel['Surface'] = surfaceselect
|
||||
|
||||
Reference in New Issue
Block a user