Navigation Menu

Skip to content

Commit

Permalink
Cleaned up Path op utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
mlampert committed Jul 10, 2019
1 parent 32ce6cc commit 5659a0e
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 33 deletions.
15 changes: 8 additions & 7 deletions src/Mod/Path/PathScripts/PathAdaptive.py
Expand Up @@ -55,8 +55,6 @@ def convertTo2d(pathArray):
topZ = 10

def sceneDrawPath(path, color=(0, 0, 1)):
global sceneGraph
global scenePathNodes
coPoint = coin.SoCoordinate3()

pts = []
Expand All @@ -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)

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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -307,6 +307,7 @@ def GenerateGCode(op,obj,adaptiveResults, helixDiameter):
lz = z

def Execute(op,obj):
# pylint: disable=global-statement
global sceneGraph
global topZ

Expand Down Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Path/PathScripts/PathArray.py
Expand Up @@ -29,7 +29,7 @@
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):
Expand Down Expand Up @@ -213,6 +213,7 @@ def execute(self, obj):
class ViewProviderArray:

def __init__(self, vobj):
self.Object = vobj.Object
vobj.Proxy = self

def attach(self, vobj):
Expand Down
13 changes: 8 additions & 5 deletions src/Mod/Path/PathScripts/PathCollision.py
Expand Up @@ -50,20 +50,21 @@ def __init__(self, obj):
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):
Expand All @@ -73,9 +74,11 @@ def __getstate__(self):
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

Expand All @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Path/PathScripts/PathComment.py
Expand Up @@ -82,6 +82,7 @@ def getIcon(self): # optional
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)
Expand All @@ -105,7 +106,7 @@ def IsActive(self):
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):
Expand Down
7 changes: 4 additions & 3 deletions src/Mod/Path/PathScripts/PathCopy.py
Expand Up @@ -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):
Expand Down Expand Up @@ -57,6 +57,7 @@ def execute(self, obj):
class ViewProviderPathCopy:

def __init__(self, vobj):
self.Object = vobj.Object
vobj.Proxy = self

def attach(self, vobj):
Expand Down Expand Up @@ -84,7 +85,7 @@ def IsActive(self):
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):
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Path/PathScripts/PathCustom.py
Expand Up @@ -26,7 +26,7 @@
import Path
from PySide import QtCore

"""Path Custom object and FreeCAD command"""
__doc__ = """Path Custom object and FreeCAD command"""


# Qt translation handling
Expand Down Expand Up @@ -68,7 +68,7 @@ def IsActive(self):
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):
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Path/PathScripts/PathFixture.py
Expand Up @@ -83,6 +83,7 @@ def getIcon(self): # optional
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)
Expand Down Expand Up @@ -118,7 +119,7 @@ def IsActive(self):
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):
Expand Down
8 changes: 4 additions & 4 deletions src/Mod/Path/PathScripts/PathHop.py
Expand Up @@ -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):
Expand Down Expand Up @@ -73,11 +73,11 @@ def execute(self, obj):
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"
Expand All @@ -100,7 +100,7 @@ def IsActive(self):
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):
Expand Down
7 changes: 3 additions & 4 deletions src/Mod/Path/PathScripts/PathInspect.py
Expand Up @@ -78,12 +78,12 @@ def convertcolor(c):

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)


Expand Down Expand Up @@ -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
Expand All @@ -221,7 +220,7 @@ def IsActive(self):
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):
Expand Down
5 changes: 3 additions & 2 deletions src/Mod/Path/PathScripts/PathPlane.py
Expand Up @@ -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):
Expand Down Expand Up @@ -79,6 +79,7 @@ def getIcon(self): # optional
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)
Expand Down Expand Up @@ -114,7 +115,7 @@ def IsActive(self):
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):
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Path/PathScripts/PathSimpleCopy.py
Expand Up @@ -26,7 +26,7 @@
import PathScripts
from PySide import QtCore

"""Path SimpleCopy command"""
__doc__ = """Path SimpleCopy command"""


# Qt translation handling
Expand All @@ -47,7 +47,7 @@ def IsActive(self):
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):
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Path/PathScripts/PathStop.py
Expand Up @@ -85,6 +85,7 @@ def getIcon(self): # optional
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)
Expand All @@ -108,7 +109,7 @@ def IsActive(self):
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):
Expand Down

0 comments on commit 5659a0e

Please sign in to comment.