Merge pull request #2861 from mlampert/bugfix/various

Path: various bugfixes
This commit is contained in:
sliptonic
2020-01-04 14:32:02 -06:00
committed by GitHub
40 changed files with 197 additions and 269 deletions

View File

@@ -35,6 +35,7 @@ from PathScripts.PathUtils import findParentJob
if FreeCAD.GuiUp:
import FreeCADGui
from PySide import QtCore
from PySide import QtGui
else:
def translate(ctxt, txt):
return txt
@@ -68,7 +69,8 @@ class _CommandSelectLoop:
self.obj = sel.Object
self.sub = sel.SubElementNames
if sel.SubObjects:
self.active = self.formsPartOfALoop(sel.Object, sel.SubObjects[0], sel.SubElementNames)
#self.active = self.formsPartOfALoop(sel.Object, sel.SubObjects[0], sel.SubElementNames)
self.active = True
else:
self.active = False
return self.active
@@ -102,6 +104,10 @@ class _CommandSelectLoop:
for i in loopwire.Edges:
if e.hashCode() == i.hashCode():
FreeCADGui.Selection.addSelection(obj, "Edge" + str(elist.index(e) + 1))
elif FreeCAD.GuiUp:
QtGui.QMessageBox.information(None,
QtCore.QT_TRANSLATE_NOOP('Path_SelectLoop', 'Feature Completion'),
QtCore.QT_TRANSLATE_NOOP('Path_SelectLoop', 'Closed loop detection failed.'))
def formsPartOfALoop(self, obj, sub, names):
try:

View File

@@ -59,13 +59,8 @@ def translate(context, text, disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
class ObjectOp(PathOp.ObjectOp):

View File

@@ -32,13 +32,8 @@ import math
from PySide import QtCore
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
# Qt translation handling

View File

@@ -168,10 +168,12 @@ class ViewProviderDressup:
def onDelete(self, arg1=None, arg2=None):
'''this makes sure that the base operation is added back to the project and visible'''
# pylint: disable=unused-argument
FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True
job = PathUtils.findParentJob(arg1.Object)
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
arg1.Object.Base = None
if arg1.Object and arg1.Object.Base:
FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True
job = PathUtils.findParentJob(arg1.Object)
if job:
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
arg1.Object.Base = None
return True
class CommandPathDressup:

View File

@@ -37,13 +37,8 @@ from PySide import QtCore
LOG_MODULE = PathLog.thisModule()
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, LOG_MODULE)
PathLog.setLevel(PathLog.Level.DEBUG, LOG_MODULE)
else:
PathLog.setLevel(PathLog.Level.NOTICE, LOG_MODULE)
PathLog.setLevel(PathLog.Level.NOTICE, LOG_MODULE)
#PathLog.setLevel(PathLog.Level.DEBUG, LOG_MODULE)
# Qt translation handling
@@ -1051,10 +1046,12 @@ class ViewProviderDressup:
def onDelete(self, arg1=None, arg2=None):
'''this makes sure that the base operation is added back to the project and visible'''
# pylint: disable=unused-argument
FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True
job = PathUtils.findParentJob(arg1.Object)
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
arg1.Object.Base = None
if arg1.Object and arg1.Object.Base:
FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True
job = PathUtils.findParentJob(arg1.Object)
if job:
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
arg1.Object.Base = None
return True

View File

@@ -465,10 +465,12 @@ class ViewProviderDressup:
def onDelete(self, arg1=None, arg2=None):
# pylint: disable=unused-argument
FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True
job = PathUtils.findParentJob(arg1.Object.Base)
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
arg1.Object.Base = None
if arg1.Object and arg1.Object.Base:
FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True
job = PathUtils.findParentJob(arg1.Object.Base)
if job:
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
arg1.Object.Base = None
return True

View File

@@ -322,10 +322,12 @@ class ViewProviderDressup:
'''this makes sure that the base operation is added back to the project and visible'''
# pylint: disable=unused-argument
PathLog.debug("Deleting Dressup")
FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True
job = PathUtils.findParentJob(self.obj)
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
arg1.Object.Base = None
if arg1.Object and arg1.Object.Base:
FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True
job = PathUtils.findParentJob(self.obj)
if job:
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
arg1.Object.Base = None
return True
def __getstate__(self):

View File

@@ -66,7 +66,8 @@ class DressupPathBoundary(object):
def onDelete(self, obj, args):
if obj.Base:
job = PathUtils.findParentJob(obj)
job.Proxy.addOperation(obj.Base, obj)
if job:
job.Proxy.addOperation(obj.Base, obj)
if obj.Base.ViewObject:
obj.Base.ViewObject.Visibility = True
obj.Base = None

View File

@@ -191,7 +191,8 @@ class DressupPathBoundaryViewProvider(object):
return [self.obj.Base, self.obj.Stock]
def onDelete(self, vobj, args=None):
vobj.Object.Proxy.onDelete(vobj.Object, args)
if vobj.Object and vobj.Object.Proxy:
vobj.Object.Proxy.onDelete(vobj.Object, args)
return True
def setEdit(self, vobj, mode=0):

View File

@@ -654,10 +654,12 @@ class ViewProviderDressup:
'''this makes sure that the base operation is added back to the project and visible'''
# pylint: disable=unused-argument
PathLog.debug("Deleting Dressup")
FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True
job = PathUtils.findParentJob(self.obj)
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
arg1.Object.Base = None
if arg1.Object and arg1.Object.Base:
FreeCADGui.ActiveDocument.getObject(arg1.Object.Base.Name).Visibility = True
job = PathUtils.findParentJob(self.obj)
if job:
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
arg1.Object.Base = None
return True
def __getstate__(self):

View File

@@ -33,8 +33,8 @@ import math
from PathScripts.PathDressupTagPreferences import HoldingTagPreferences
from PySide import QtCore
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule()
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule()
# Qt translation handling

View File

@@ -422,8 +422,9 @@ class PathDressupTagViewProvider:
if self.obj.Base.ViewObject:
self.obj.Base.ViewObject.Visibility = True
job = PathUtils.findParentJob(self.obj)
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
arg1.Object.Base = None
if arg1.Object and arg1.Object.Base and job:
job.Proxy.addOperation(arg1.Object.Base, arg1.Object)
arg1.Object.Base = None
# if self.debugDisplay():
# self.vobj.Debug.removeObjectsFromDocument()
# self.vobj.Debug.Document.removeObject(self.vobj.Debug.Name)

View File

@@ -48,13 +48,8 @@ __created__ = "2014"
__scriptVersion__ = "1c testing"
__lastModified__ = "2019-06-25 14:49 CST"
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
# Qt translation handling

View File

@@ -35,13 +35,8 @@ from PySide import QtCore
__doc__ = "Class and implementation of Path Engrave operation"
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
# Qt translation handling
@@ -84,6 +79,7 @@ class ObjectEngrave(PathEngraveBase.ObjectOp):
jobshapes = []
if len(obj.Base) >= 1: # user has selected specific subelements
PathLog.track(len(obj.Base))
wires = []
for base, subs in obj.Base:
edges = []
@@ -103,7 +99,10 @@ class ObjectEngrave(PathEngraveBase.ObjectOp):
wires.extend(basewires)
jobshapes.append(Part.makeCompound(wires))
else: # Use the Job Base object
elif len(obj.BaseShapes) > 0: # user added specific shapes
jobshapes.extend([base.Shape for base in obj.BaseShapes])
else:
PathLog.track(self.model)
for base in self.model:
PathLog.track(base.Label)
if base.isDerivedFrom('Part::Part2DObject'):
@@ -121,15 +120,15 @@ class ObjectEngrave(PathEngraveBase.ObjectOp):
if len(jobshapes) > 0:
PathLog.debug('processing {} jobshapes'.format(len(jobshapes)))
PathLog.track()
wires = []
for shape in jobshapes:
shapeWires = shape.Wires
PathLog.debug('jobshape has {} edges'.format(len(shape.Edges)))
self.commandlist.append(Path.Command('G0', {'Z': obj.ClearanceHeight.Value, 'F': self.vertRapid}))
shapeWires = shape.Wires
self.buildpathocc(obj, shape.Wires, self.getZValues(obj))
self.buildpathocc(obj, shapeWires, self.getZValues(obj))
wires.extend(shapeWires)
self.wires = wires
PathLog.debug('processing {} jobshapes -> {} wires'.format(len(jobshapes), len(wires)))
# the last command is a move to clearance, which is automatically added by PathOp
if self.commandlist:
self.commandlist.pop()

View File

@@ -34,13 +34,8 @@ from PySide import QtCore
__doc__ = "Base class for all ops in the engrave family."
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
# Qt translation handling
def translate(context, text, disambig=None):

View File

@@ -36,13 +36,8 @@ __author__ = "sliptonic (Brad Collette)"
__url__ = "http://www.freecadweb.org"
__doc__ = "Engrave operation page controller and command implementation."
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
def translate(context, text, disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
@@ -53,6 +48,13 @@ class TaskPanelBaseGeometryPage(PathOpGui.TaskPanelBaseGeometryPage):
def super(self):
return super(TaskPanelBaseGeometryPage, self)
def selectionSupportedAsBaseGeometry(self, selection, ignoreErrors):
# allow selection of an entire 2D object, which is generally not the case
if len(selection) == 1 and not selection[0].HasSubObjects and selection[0].Object.isDerivedFrom('Part::Part2DObject'):
return True
# Let general logic handle all other cases.
return self.super().selectionSupportedAsBaseGeometry(selection, ignoreErrors)
def addBaseGeometry(self, selection):
added = False
shapes = self.obj.BaseShapes

View File

@@ -38,13 +38,8 @@ __doc__ = "Functions to extract and convert between Path.Command and Part.Edge a
Tolerance = 0.000001
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
# Qt translation handling
def translate(context, text, disambig=None):
@@ -255,7 +250,7 @@ def cmdsForEdge(edge, flip = False, useHelixForBSpline = True, segm = 50, hSpeed
p2 = edge.valueAt((edge.FirstParameter + edge.LastParameter)/2)
p3 = pt
if (type(edge.Curve) == Part.Circle and isRoughly(edge.Curve.Axis.x, 0) and isRoughly(edge.Curve.Axis.y, 0)) or (useHelixForBSpline and type(edge.Curve) == Part.BSplineCurve):
if hasattr(edge.Curve, 'Axis') and ((type(edge.Curve) == Part.Circle and isRoughly(edge.Curve.Axis.x, 0) and isRoughly(edge.Curve.Axis.y, 0)) or (useHelixForBSpline and type(edge.Curve) == Part.BSplineCurve)):
# This is an arc or a helix and it should be represented by a simple G2/G3 command
if edge.Curve.Axis.z < 0:
cmd = 'G2' if not flip else 'G3'
@@ -523,8 +518,11 @@ def flipEdge(edge):
# Now the edge always starts at 0 and LastParameter is the value range
arc = Part.Edge(circle, 0, edge.LastParameter - edge.FirstParameter)
return arc
elif Part.BSplineCurve == type(edge.Curve):
spline = edge.Curve
elif type(edge.Curve) in [Part.BSplineCurve, Part.BezierCurve]:
if type(edge.Curve) == Part.BSplineCurve:
spline = edge.Curve
else:
spline = edge.Curve.toBSpline()
mults = spline.getMultiplicities()
weights = spline.getWeights()
@@ -556,4 +554,6 @@ def flipWire(wire):
'''Flip the entire wire and all its edges so it is being processed the other way around.'''
edges = [flipEdge(e) for e in wire.Edges]
edges.reverse()
PathLog.debug(edges)
return Part.Wire(edges)

View File

@@ -31,13 +31,8 @@ __author__ = "sliptonic (Brad Collette)"
__url__ = "http://www.freecadweb.org"
__doc__ = "ViewProvider who's main and only task is to assign an icon."
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
class ViewProvider(object):
'''Generic view provider to assign an icon.'''

View File

@@ -37,13 +37,8 @@ import json
from PathScripts.PathPostProcessor import PostProcessor
from PySide import QtCore
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
# Qt translation handling

View File

@@ -38,13 +38,8 @@ from collections import Counter
def translate(context, text, disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
class _ItemDelegate(QtGui.QStyledItemDelegate):

View File

@@ -43,13 +43,8 @@ __scriptVersion__ = "1d usable"
__lastModified__ = "2019-07-22 23:49 CST"
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
# Qt translation handling

View File

@@ -38,13 +38,8 @@ __author__ = "sliptonic (Brad Collette)"
__url__ = "http://www.freecadweb.org"
__doc__ = "Base class and properties implementation for all Path operations."
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule()
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule()
# Qt translation handling

View File

@@ -502,9 +502,9 @@ class TaskPanelBaseGeometryPage(TaskPanelPage):
for i in range(self.form.baseList.count()):
item = self.form.baseList.item(i)
obj = item.data(self.DataObject)
sub = str(item.data(self.DataObjectSub))
sub = item.data(self.DataObjectSub)
if sub:
base = (obj, sub)
base = (obj, str(sub))
newlist.append(base)
PathLog.debug("Setting new base: %s -> %s" % (self.obj.Base, newlist))
self.obj.Base = newlist

View File

@@ -35,13 +35,8 @@ __author__ = "sliptonic (Brad Collette)"
__url__ = "http://www.freecadweb.org"
__doc__ = "Collection of functions used by various Path operations. The functions are specific to Path and the algorithms employed by Path's operations."
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
PrintWireDebug = False

View File

@@ -40,13 +40,8 @@ __created__ = "2014"
__scriptVersion__ = "2g testing"
__lastModified__ = "2019-07-20 22:02 CST"
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
# Qt translation handling

View File

@@ -33,13 +33,8 @@ __author__ = "sliptonic (Brad Collette)"
__url__ = "http://www.freecadweb.org"
__doc__ = "Base class and implementation for Path pocket operations."
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
# Qt translation handling
def translate(context, text, disambig=None):

View File

@@ -43,13 +43,8 @@ __created__ = "2017"
__scriptVersion__ = "2i usable"
__lastModified__ = "2019-09-07 08:32 CST"
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
# Qt translation handling
@@ -97,24 +92,29 @@ def selectOffsetWire(feature, wires):
def extendWire(feature, wire, length):
'''extendWire(wire, length) ... return a closed Wire which extends wire by length'''
off2D = wire.makeOffset2D(length)
endPts = endPoints(wire)
edges = [e for e in off2D.Edges if Part.Circle != type(e.Curve) or not includesPoint(e.Curve.Center, endPts)]
wires = [Part.Wire(e) for e in Part.sortEdges(edges)]
offset = selectOffsetWire(feature, wires)
ePts = endPoints(offset)
l0 = (ePts[0] - endPts[0]).Length
l1 = (ePts[1] - endPts[0]).Length
edges = wire.Edges
if l0 < l1:
edges.append(Part.Edge(Part.LineSegment(endPts[0], ePts[0])))
edges.extend(offset.Edges)
edges.append(Part.Edge(Part.LineSegment(endPts[1], ePts[1])))
else:
edges.append(Part.Edge(Part.LineSegment(endPts[1], ePts[0])))
edges.extend(offset.Edges)
edges.append(Part.Edge(Part.LineSegment(endPts[0], ePts[1])))
return Part.Wire(edges)
PathLog.track(length)
if length and length != 0:
off2D = wire.makeOffset2D(length)
endPts = endPoints(wire)
if endPts:
edges = [e for e in off2D.Edges if Part.Circle != type(e.Curve) or not includesPoint(e.Curve.Center, endPts)]
wires = [Part.Wire(e) for e in Part.sortEdges(edges)]
offset = selectOffsetWire(feature, wires)
ePts = endPoints(offset)
if ePts and len(ePts) > 1:
l0 = (ePts[0] - endPts[0]).Length
l1 = (ePts[1] - endPts[0]).Length
edges = wire.Edges
if l0 < l1:
edges.append(Part.Edge(Part.LineSegment(endPts[0], ePts[0])))
edges.extend(offset.Edges)
edges.append(Part.Edge(Part.LineSegment(endPts[1], ePts[1])))
else:
edges.append(Part.Edge(Part.LineSegment(endPts[1], ePts[0])))
edges.extend(offset.Edges)
edges.append(Part.Edge(Part.LineSegment(endPts[0], ePts[1])))
return Part.Wire(edges)
return None
class Extension(object):
DirectionNormal = 0
@@ -122,6 +122,7 @@ class Extension(object):
DirectionY = 2
def __init__(self, obj, feature, sub, length, direction):
PathLog.debug("Extension(%s, %s, %s, %.2f, %s" % (obj.Label, feature, sub, length, direction))
self.obj = obj
self.feature = feature
self.sub = sub
@@ -149,8 +150,11 @@ class Extension(object):
def _getEdgeNumbers(self):
if 'Wire' in self.sub:
return [nr for nr in self.sub[5:-1].split(',')]
return [self.sub[4:]]
numbers = [nr for nr in self.sub[5:-1].split(',')]
else:
numbers = [self.sub[4:]]
PathLog.debug("_getEdgeNumbers() -> %s" % numbers)
return numbers
def _getEdgeNames(self):
return ["Edge%s" % nr for nr in self._getEdgeNumbers()]
@@ -180,32 +184,47 @@ class Extension(object):
def getWire(self):
PathLog.track()
if PathGeom.isRoughly(0, self.length.Value) or not self.sub:
PathLog.debug("no extension, length=%.2f, sub=%s" % (self.length.Value, self.sub))
return None
feature = self.obj.Shape.getElement(self.feature)
edges = self._getEdges()
sub = Part.Wire(edges)
sub = Part.Wire(Part.sortEdges(edges)[0])
if 1 == len(edges):
PathLog.debug("Extending single edge wire")
edge = edges[0]
if Part.Circle == type(edge.Curve) and not endPoints(edge):
if Part.Circle == type(edge.Curve):
circle = edge.Curve
# for a circle we have to figure out if it's a hole or a cylinder
p0 = edge.valueAt(edge.FirstParameter)
normal = (edge.Curve.Center - p0).normalize()
direction = self._getDirectedNormal(p0, normal)
if direction is None:
return None
if PathGeom.pointsCoincide(normal, direction):
r = circle.Radius - self.length.Value
else:
r = circle.Radius + self.length.Value
# assuming the offset produces a valid circle - go for it
if r > 0:
c1 = Part.makeCircle(r, circle.Center, circle.Axis, edge.FirstParameter * 180 / math.pi, edge.LastParameter * 180 / math.pi)
return [Part.Wire([edge]), Part.Wire([c1])]
e3 = Part.makeCircle(r, circle.Center, circle.Axis, edge.FirstParameter * 180 / math.pi, edge.LastParameter * 180 / math.pi)
if endPoints(edge):
# need to construct the arc slice
e0 = Part.makeLine(edge.valueAt(edge.FirstParameter), e3.valueAt(e3.FirstParameter))
e2 = Part.makeLine(edge.valueAt(edge.LastParameter), e3.valueAt(e3.LastParameter))
return Part.Wire([e0, edge, e2, e3])
return Part.Wire([e3])
# the extension is bigger than the hole - so let's just cover the whole hole
if endPoints(edge):
# if the resulting arc is smaller than the radius, create a pie slice
PathLog.track()
center = circle.Center
e0 = Part.makeLine(center, edge.valueAt(edge.FirstParameter))
e2 = Part.makeLine(edge.valueAt(edge.LastParameter), center)
return Part.Wire([e0, edge, e2])
PathLog.track()
return Part.Wire([edge])
else:

View File

@@ -43,13 +43,8 @@ __doc__ = "Pocket Shape operation page controller and command implementation."
def translate(context, text, disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
class _Extension(object):
ColourEnabled = (1.0, .5, 1.0)
@@ -119,10 +114,12 @@ class _Extension(object):
return not self.root is None
def show(self):
self.switch.whichChild = coin.SO_SWITCH_ALL
if self.switch:
self.switch.whichChild = coin.SO_SWITCH_ALL
def hide(self):
self.switch.whichChild = coin.SO_SWITCH_NONE
if self.switch:
self.switch.whichChild = coin.SO_SWITCH_NONE
def enable(self, ena = True):
if ena:
@@ -231,7 +228,7 @@ class TaskPanelExtensionPage(PathOpGui.TaskPanelPage):
self.setExtensions(self.extensions)
def createItemForBaseModel(self, base, sub, edges, extensions):
PathLog.track()
PathLog.track(base.Label, sub, '+', len(edges), len(base.Shape.getElement(sub).Edges))
ext = _Extension(self.obj, base, sub, None)
item = QtGui.QStandardItem()
item.setData(sub, QtCore.Qt.EditRole)
@@ -241,17 +238,18 @@ class TaskPanelExtensionPage(PathOpGui.TaskPanelPage):
extendCorners = self.form.extendCorners.isChecked()
def createSubItem(label, ext0):
self.switch.addChild(ext0.root)
item0 = QtGui.QStandardItem()
item0.setData(label, QtCore.Qt.EditRole)
item0.setData(ext0, self.DataObject)
item0.setCheckable(True)
for e in extensions:
if e.obj == base and e.sub == label:
item0.setCheckState(QtCore.Qt.Checked)
ext0.enable()
break
item.appendRow([item0])
if ext0.root:
self.switch.addChild(ext0.root)
item0 = QtGui.QStandardItem()
item0.setData(label, QtCore.Qt.EditRole)
item0.setData(ext0, self.DataObject)
item0.setCheckable(True)
for e in extensions:
if e.obj == base and e.sub == label:
item0.setCheckState(QtCore.Qt.Checked)
ext0.enable()
break
item.appendRow([item0])
extensionEdges = {}
for edge in base.Shape.getElement(sub).Edges:
@@ -305,7 +303,8 @@ class TaskPanelExtensionPage(PathOpGui.TaskPanelPage):
def removeItemSwitch(item, ext):
# pylint: disable=unused-argument
ext.hide()
self.switch.removeChild(ext.root)
if ext.root:
self.switch.removeChild(ext.root)
self.forAllItemsCall(removeItemSwitch)
self.model.clear()

View File

@@ -41,7 +41,7 @@ from PySide import QtCore, QtGui
LOG_MODULE = PathLog.thisModule()
PathLog.setLevel(PathLog.Level.DEBUG, LOG_MODULE)
PathLog.setLevel(PathLog.Level.INFO, LOG_MODULE)
# Qt translation handling

View File

@@ -32,13 +32,8 @@ __author__ = "sliptonic (Brad Collette)"
__url__ = "http://www.freecadweb.org"
__doc__ = "Base class and implementation for Path profile operations."
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
# Qt translation handling
def translate(context, text, disambig=None):

View File

@@ -36,13 +36,8 @@ from PySide import QtCore
FreeCAD.setLogLevel('Path.Area', 0)
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
# Qt translation handling
def translate(context, text, disambig=None):

View File

@@ -33,13 +33,8 @@ import PathScripts.PathUtils as PathUtils
from DraftGeomUtils import findWires
from PySide import QtCore
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
# Qt translation handling

View File

@@ -43,8 +43,7 @@ __created__ = "2014"
__scriptVersion__ = "2j usable"
__lastModified__ = "2019-07-25 14:48 CST"
LOGLEVEL = PathLog.Level.INFO # change to .DEBUG to enable debugging messages
PathLog.setLevel(LOGLEVEL, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
# Qt translation handling
def translate(context, text, disambig=None):

View File

@@ -29,11 +29,8 @@ import PathScripts.PathLog as PathLog
import PathScripts.PathUtils as PathUtils
import math
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
class PathBaseGate(object):
# pylint: disable=no-init

View File

@@ -36,13 +36,8 @@ __doc__ = "A container for all default values and job specific configuration val
_RegisteredOps = {}
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule()
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
def translate(context, text, disambig=None):
return PySide.QtCore.QCoreApplication.translate(context, text, disambig)

View File

@@ -30,13 +30,8 @@ __url__ = "http://www.freecadweb.org"
__doc__ = "Prototype objects to allow extraction of setup sheet values and editing."
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
class Property(object):
'''Base class for all prototype properties'''

View File

@@ -30,14 +30,8 @@ import math
from PySide import QtCore
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
# Qt translation handling
def translate(context, text, disambig=None):

View File

@@ -77,13 +77,8 @@ __created__ = "2016"
__scriptVersion__ = "3t Usable"
__lastModified__ = "2019-05-10 10:37 CST"
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
# Qt translation handling

View File

@@ -38,13 +38,8 @@ from PathScripts import PathLog
from PySide import QtCore
from PySide import QtGui
LOGLEVEL = False
if LOGLEVEL:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
else:
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
def translate(context, text, disambig=None):

View File

@@ -29,8 +29,8 @@ import PathScripts.PathJob as PathJob
import PathScripts.PathLog as PathLog
import PathTests.PathTestUtils as PathTestUtils
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
class TestPathHelix(PathTestUtils.PathTestBase):