Added UI page pocket extension; changed selection agent.

This commit is contained in:
markus
2018-08-24 17:43:34 -07:00
committed by wmayer
parent 4c04933fd7
commit 756f316831
7 changed files with 435 additions and 22 deletions

View File

@@ -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.'''

View File

@@ -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."))

View File

@@ -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,

View File

@@ -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