Cleaned up Path op utilities
This commit is contained in:
@@ -55,8 +55,6 @@ scenePathNodes = [] #for scene cleanup aftewards
|
||||
topZ = 10
|
||||
|
||||
def sceneDrawPath(path, color=(0, 0, 1)):
|
||||
global sceneGraph
|
||||
global scenePathNodes
|
||||
coPoint = coin.SoCoordinate3()
|
||||
|
||||
pts = []
|
||||
@@ -76,8 +74,6 @@ def sceneDrawPath(path, color=(0, 0, 1)):
|
||||
scenePathNodes.append(pathNode) #for scene cleanup afterwards
|
||||
|
||||
def sceneClean():
|
||||
global scenePathNodes
|
||||
|
||||
for n in scenePathNodes:
|
||||
sceneGraph.removeChild(n)
|
||||
|
||||
@@ -91,6 +87,7 @@ def discretize(edge, flipDirection = False):
|
||||
return pts
|
||||
|
||||
def GenerateGCode(op,obj,adaptiveResults, helixDiameter):
|
||||
# pylint: disable=unused-argument
|
||||
if len(adaptiveResults) == 0 or len(adaptiveResults[0]["AdaptivePaths"]) == 0:
|
||||
return
|
||||
|
||||
@@ -138,6 +135,9 @@ def GenerateGCode(op,obj,adaptiveResults, helixDiameter):
|
||||
|
||||
|
||||
|
||||
# ml: this is dangerous because it'll hide all unused variables hence forward
|
||||
# however, I don't know wht lx and ly signify so I leave them for now
|
||||
# pylint: disable=unused-variable
|
||||
lx = adaptiveResults[0]["HelixCenterPoint"][0]
|
||||
ly = adaptiveResults[0]["HelixCenterPoint"][1]
|
||||
lz = passStartDepth
|
||||
@@ -307,6 +307,7 @@ def GenerateGCode(op,obj,adaptiveResults, helixDiameter):
|
||||
lz = z
|
||||
|
||||
def Execute(op,obj):
|
||||
# pylint: disable=global-statement
|
||||
global sceneGraph
|
||||
global topZ
|
||||
|
||||
@@ -400,11 +401,11 @@ def Execute(op,obj):
|
||||
adaptiveResults = None
|
||||
|
||||
if obj.AdaptiveOutputState != None and obj.AdaptiveOutputState != "":
|
||||
adaptiveResults = obj.AdaptiveOutputState
|
||||
adaptiveResults = obj.AdaptiveOutputState
|
||||
|
||||
if json.dumps(obj.AdaptiveInputState) != json.dumps(inputStateObject):
|
||||
inputStateChanged = True
|
||||
adaptiveResults = None
|
||||
inputStateChanged = True
|
||||
adaptiveResults = None
|
||||
|
||||
# progress callback fn, if return true it will stop processing
|
||||
def progressFn(tpaths):
|
||||
|
||||
@@ -29,7 +29,7 @@ import PathScripts
|
||||
from PySide import QtCore
|
||||
import math
|
||||
|
||||
"""Path Array object and FreeCAD command"""
|
||||
__doc__ = """Path Array object and FreeCAD command"""
|
||||
|
||||
# Qt translation handling
|
||||
def translate(context, text, disambig=None):
|
||||
@@ -213,6 +213,7 @@ class ObjectArray:
|
||||
class ViewProviderArray:
|
||||
|
||||
def __init__(self, vobj):
|
||||
self.Object = vobj.Object
|
||||
vobj.Proxy = self
|
||||
|
||||
def attach(self, vobj):
|
||||
|
||||
@@ -50,20 +50,21 @@ class _CollisionSim:
|
||||
obj.Proxy = self
|
||||
|
||||
def execute(self, fp):
|
||||
"'''Do something when doing a recomputation, this method is mandatory'''"
|
||||
pass
|
||||
'''Do something when doing a recomputation, this method is mandatory'''
|
||||
print('_CollisionSim', fp)
|
||||
|
||||
|
||||
class _ViewProviderCollisionSim:
|
||||
def __init__(self, vobj):
|
||||
self.Object = vobj.Object
|
||||
vobj.Proxy = self
|
||||
vobj.addProperty("App::PropertyLink", "Original", "reference", QtCore.QT_TRANSLATE_NOOP("App::Property", "The base object this collision refers to"))
|
||||
|
||||
def attach(self, vobj):
|
||||
self.Object = vobj.Object
|
||||
return
|
||||
|
||||
def setEdit(self, vobj, mode=0):
|
||||
# pylint: disable=unused-argument
|
||||
return True
|
||||
|
||||
def getIcon(self):
|
||||
@@ -73,9 +74,11 @@ class _ViewProviderCollisionSim:
|
||||
return None
|
||||
|
||||
def __setstate__(self, state):
|
||||
# pylint: disable=unused-argument
|
||||
return None
|
||||
|
||||
def onDelete(self, feature, subelements):
|
||||
# pylint: disable=unused-argument
|
||||
feature.Original.ViewObject.Visibility = True
|
||||
return True
|
||||
|
||||
@@ -101,9 +104,9 @@ def getCollisionObject(baseobject, simobject):
|
||||
colorassignment = []
|
||||
gougedShape = baseobject.Shape.cut(simobject)
|
||||
|
||||
for idx, i in enumerate(gougedShape.Faces):
|
||||
for i in gougedShape.Faces:
|
||||
match = False
|
||||
for jdx, j in enumerate(cVol.Faces):
|
||||
for j in cVol.Faces:
|
||||
if __compareBBSpace(i.BoundBox, j.BoundBox):
|
||||
match = True
|
||||
if match is True:
|
||||
|
||||
@@ -82,6 +82,7 @@ class _ViewProviderComment:
|
||||
return ":/icons/Path-Comment.svg"
|
||||
|
||||
def onChanged(self, vobj, prop): # optional
|
||||
# pylint: disable=unused-argument
|
||||
mode = 2
|
||||
vobj.setEditorMode('LineWidth', mode)
|
||||
vobj.setEditorMode('MarkerColor', mode)
|
||||
@@ -105,7 +106,7 @@ class CommandPathComment:
|
||||
if FreeCAD.ActiveDocument is not None:
|
||||
for o in FreeCAD.ActiveDocument.Objects:
|
||||
if o.Name[:3] == "Job":
|
||||
return True
|
||||
return True
|
||||
return False
|
||||
|
||||
def Activated(self):
|
||||
|
||||
@@ -24,9 +24,9 @@
|
||||
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
from PySide import QtCore, QtGui
|
||||
from PySide import QtCore
|
||||
|
||||
"""Path Copy object and FreeCAD command"""
|
||||
__doc__ = """Path Copy object and FreeCAD command"""
|
||||
|
||||
# Qt translation handling
|
||||
def translate(context, text, disambig=None):
|
||||
@@ -57,6 +57,7 @@ class ObjectPathCopy:
|
||||
class ViewProviderPathCopy:
|
||||
|
||||
def __init__(self, vobj):
|
||||
self.Object = vobj.Object
|
||||
vobj.Proxy = self
|
||||
|
||||
def attach(self, vobj):
|
||||
@@ -84,7 +85,7 @@ class CommandPathCopy:
|
||||
if FreeCAD.ActiveDocument is not None:
|
||||
for o in FreeCAD.ActiveDocument.Objects:
|
||||
if o.Name[:3] == "Job":
|
||||
return True
|
||||
return True
|
||||
return False
|
||||
|
||||
def Activated(self):
|
||||
|
||||
@@ -26,7 +26,7 @@ import FreeCADGui
|
||||
import Path
|
||||
from PySide import QtCore
|
||||
|
||||
"""Path Custom object and FreeCAD command"""
|
||||
__doc__ = """Path Custom object and FreeCAD command"""
|
||||
|
||||
|
||||
# Qt translation handling
|
||||
@@ -68,7 +68,7 @@ class CommandPathCustom:
|
||||
if FreeCAD.ActiveDocument is not None:
|
||||
for o in FreeCAD.ActiveDocument.Objects:
|
||||
if o.Name[:3] == "Job":
|
||||
return True
|
||||
return True
|
||||
return False
|
||||
|
||||
def Activated(self):
|
||||
|
||||
@@ -83,6 +83,7 @@ class _ViewProviderFixture:
|
||||
return ":/icons/Path-Datums.svg"
|
||||
|
||||
def onChanged(self, vobj, prop): # optional
|
||||
# pylint: disable=unused-argument
|
||||
mode = 2
|
||||
vobj.setEditorMode('LineWidth', mode)
|
||||
vobj.setEditorMode('MarkerColor', mode)
|
||||
@@ -118,7 +119,7 @@ class CommandPathFixture:
|
||||
if FreeCAD.ActiveDocument is not None:
|
||||
for o in FreeCAD.ActiveDocument.Objects:
|
||||
if o.Name[:3] == "Job":
|
||||
return True
|
||||
return True
|
||||
return False
|
||||
|
||||
def Activated(self):
|
||||
|
||||
@@ -25,9 +25,9 @@
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import Path
|
||||
from PySide import QtCore, QtGui
|
||||
from PySide import QtCore
|
||||
|
||||
"""Path Hop object and FreeCAD command"""
|
||||
__doc__ = """Path Hop object and FreeCAD command"""
|
||||
|
||||
# Qt translation handling
|
||||
def translate(context, text, disambig=None):
|
||||
@@ -73,11 +73,11 @@ class ObjectHop:
|
||||
class ViewProviderPathHop:
|
||||
|
||||
def __init__(self, vobj):
|
||||
self.Object = vobj.Object
|
||||
vobj.Proxy = self
|
||||
|
||||
def attach(self, vobj):
|
||||
self.Object = vobj.Object
|
||||
return
|
||||
|
||||
def getIcon(self):
|
||||
return ":/icons/Path-Hop.svg"
|
||||
@@ -100,7 +100,7 @@ class CommandPathHop:
|
||||
if FreeCAD.ActiveDocument is not None:
|
||||
for o in FreeCAD.ActiveDocument.Objects:
|
||||
if o.Name[:3] == "Job":
|
||||
return True
|
||||
return True
|
||||
return False
|
||||
|
||||
def Activated(self):
|
||||
|
||||
@@ -78,12 +78,12 @@ class GCodeHighlighter(QtGui.QSyntaxHighlighter):
|
||||
|
||||
def highlightBlock(self, text):
|
||||
|
||||
for pattern, format in self.highlightingRules:
|
||||
for pattern, fmt in self.highlightingRules:
|
||||
expression = QtCore.QRegExp(pattern)
|
||||
index = expression.indexIn(text)
|
||||
while index >= 0:
|
||||
length = expression.matchedLength()
|
||||
self.setFormat(index, length, format)
|
||||
self.setFormat(index, length, fmt)
|
||||
index = expression.indexIn(text, index + length)
|
||||
|
||||
|
||||
@@ -201,7 +201,6 @@ def show(obj):
|
||||
# exec_() returns 0 or 1 depending on the button pressed (Ok or
|
||||
# Cancel)
|
||||
if result:
|
||||
import Path
|
||||
p = Path.Path(dia.editor.toPlainText())
|
||||
FreeCAD.ActiveDocument.openTransaction("Edit Path")
|
||||
obj.Path = p
|
||||
@@ -221,7 +220,7 @@ class CommandPathInspect:
|
||||
if FreeCAD.ActiveDocument is not None:
|
||||
for o in FreeCAD.ActiveDocument.Objects:
|
||||
if o.Name[:3] == "Job":
|
||||
return True
|
||||
return True
|
||||
return False
|
||||
|
||||
def Activated(self):
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import Path
|
||||
from PySide import QtCore, QtGui
|
||||
from PySide import QtCore
|
||||
|
||||
# Qt translation handling
|
||||
def translate(context, text, disambig=None):
|
||||
@@ -79,6 +79,7 @@ class _ViewProviderPlane:
|
||||
return ":/icons/Path-Plane.svg"
|
||||
|
||||
def onChanged(self, vobj, prop): # optional
|
||||
# pylint: disable=unused-argument
|
||||
mode = 2
|
||||
vobj.setEditorMode('LineWidth', mode)
|
||||
vobj.setEditorMode('MarkerColor', mode)
|
||||
@@ -114,7 +115,7 @@ class CommandPathPlane:
|
||||
if FreeCAD.ActiveDocument is not None:
|
||||
for o in FreeCAD.ActiveDocument.Objects:
|
||||
if o.Name[:3] == "Job":
|
||||
return True
|
||||
return True
|
||||
return False
|
||||
|
||||
def Activated(self):
|
||||
|
||||
@@ -26,7 +26,7 @@ import FreeCADGui
|
||||
import PathScripts
|
||||
from PySide import QtCore
|
||||
|
||||
"""Path SimpleCopy command"""
|
||||
__doc__ = """Path SimpleCopy command"""
|
||||
|
||||
|
||||
# Qt translation handling
|
||||
@@ -47,7 +47,7 @@ class CommandPathSimpleCopy:
|
||||
try:
|
||||
obj = FreeCADGui.Selection.getSelectionEx()[0].Object
|
||||
return isinstance(obj.Proxy, PathScripts.PathOp.ObjectOp)
|
||||
except Exception:
|
||||
except Exception: # pylint: disable=broad-except
|
||||
return False
|
||||
|
||||
def Activated(self):
|
||||
|
||||
@@ -85,6 +85,7 @@ class _ViewProviderStop:
|
||||
return ":/icons/Path-Stop.svg"
|
||||
|
||||
def onChanged(self, vobj, prop): # optional
|
||||
# pylint: disable=unused-argument
|
||||
mode = 2
|
||||
vobj.setEditorMode('LineWidth', mode)
|
||||
vobj.setEditorMode('MarkerColor', mode)
|
||||
@@ -108,7 +109,7 @@ class CommandPathStop:
|
||||
if FreeCAD.ActiveDocument is not None:
|
||||
for o in FreeCAD.ActiveDocument.Objects:
|
||||
if o.Name[:3] == "Job":
|
||||
return True
|
||||
return True
|
||||
return False
|
||||
|
||||
def Activated(self):
|
||||
|
||||
Reference in New Issue
Block a user