Skip to content

Commit

Permalink
Addressed pylint warnings for PathDressups
Browse files Browse the repository at this point in the history
  • Loading branch information
mlampert committed Jul 1, 2019
1 parent f16703e commit 04b4db1
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 31 deletions.
10 changes: 6 additions & 4 deletions src/Mod/Path/PathScripts/PathDressupAxisMap.py
Expand Up @@ -32,7 +32,7 @@
if FreeCAD.GuiUp:
import FreeCADGui

"""Axis remapping Dressup object and FreeCAD command. This dressup remaps one axis of motion to another.
__doc__ = """Axis remapping Dressup object and FreeCAD command. This dressup remaps one axis of motion to another.
For example, you can re-map the Y axis to A to control a 4th axis rotary."""

# Qt translation handling
Expand Down Expand Up @@ -141,7 +141,7 @@ def center(self, obj):
class ViewProviderDressup:

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

def attach(self, vobj):
self.obj = vobj.Object
Expand All @@ -167,13 +167,15 @@ def __setstate__(self, state):

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
return True

class CommandPathDressup:
# pylint: disable=no-init

def GetResources(self):
return {'Pixmap': 'Path-Dressup',
Expand All @@ -185,7 +187,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 Expand Up @@ -213,7 +215,7 @@ def Activated(self):
FreeCADGui.doCommand('obj.Base = base')
FreeCADGui.doCommand('obj.Radius = 45')
FreeCADGui.doCommand('job.Proxy.addOperation(obj, base)')
FreeCADGui.doCommand('PathScripts.PathDressupAxisMap.ViewProviderDressup(obj.ViewObject)')
FreeCADGui.doCommand('obj.ViewObject.Proxy = PathScripts.PathDressupAxisMap.ViewProviderDressup(obj.ViewObject)')
FreeCADGui.doCommand('Gui.ActiveDocument.getObject(base.Name).Visibility = False')
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
Expand Down
26 changes: 14 additions & 12 deletions src/Mod/Path/PathScripts/PathDressupDragknife.py
Expand Up @@ -30,7 +30,7 @@
import DraftVecUtils as D
import PathScripts.PathUtils as PathUtils

"""Dragknife Dressup object and FreeCAD command"""
__doc__ = """Dragknife Dressup object and FreeCAD command"""

if FreeCAD.GuiUp:
import FreeCADGui
Expand Down Expand Up @@ -66,8 +66,6 @@ def shortcut(self, queue):
'''Determines whether its shorter to twist CW or CCW to align with the next move'''
# get the vector of the last move

global arccommands

if queue[1].Name in arccommands:
arcLoc = FreeCAD.Vector(queue[2].x + queue[1].I, queue[2].y + queue[1].J, currLocation['Z'])
radvector = arcLoc.sub(queue[1].Placement.Base) # .sub(arcLoc) # vector of chord from center to point
Expand All @@ -94,7 +92,6 @@ def segmentAngleXY(self, prevCommand, currCommand, endpos=False, currentZ=0):
requires the previous command in order to calculate arcs correctly
if endpos = True, return the angle at the end of the segment.'''

global arccommands
if currCommand.Name in arccommands:
arcLoc = FreeCAD.Vector((prevCommand.x + currCommand.I), (prevCommand.y + currCommand.J), currentZ)
if endpos is True:
Expand Down Expand Up @@ -127,7 +124,7 @@ def getIncidentAngle(self, queue):

def arcExtension(self, obj, queue):
'''returns gcode for arc extension'''
global currLocation
global currLocation # pylint: disable=global-statement
results = []

offset = obj.offset
Expand Down Expand Up @@ -166,7 +163,7 @@ def arcTwist(self, obj, queue, lastXY, twistCW=False):
'''returns gcode to do an arc move toward an arc to perform
a corner action twist. Includes lifting and plungeing the knife'''

global currLocation
global currLocation # pylint: disable=global-statement
pivotheight = obj.pivotheight
offset = obj.offset
results = []
Expand Down Expand Up @@ -233,7 +230,7 @@ def arcTwist(self, obj, queue, lastXY, twistCW=False):

def lineExtension(self, obj, queue):
'''returns gcode for line extension'''
global currLocation
global currLocation # pylint: disable=global-statement

offset = float(obj.offset)
results = []
Expand All @@ -259,7 +256,7 @@ def lineExtension(self, obj, queue):
def lineTwist(self, obj, queue, lastXY, twistCW=False):
'''returns gcode to do an arc move toward a line to perform
a corner action twist. Includes lifting and plungeing the knife'''
global currLocation
global currLocation # pylint: disable=global-statement
pivotheight = obj.pivotheight
offset = obj.offset

Expand Down Expand Up @@ -310,7 +307,7 @@ def lineTwist(self, obj, queue, lastXY, twistCW=False):

def execute(self, obj):
newpath = []
global currLocation
global currLocation # pylint: disable=global-statement

if not obj.Base:
return
Expand Down Expand Up @@ -433,7 +430,7 @@ def execute(self, obj):
class ViewProviderDressup:

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

def attach(self, vobj):
self.Object = vobj.Object
Expand All @@ -449,9 +446,11 @@ def attach(self, vobj):
# FreeCADGui.ActiveDocument.getObject(obj.Base.Name).Visibility = False

def unsetEdit(self, vobj, mode=0):
# pylint: disable=unused-argument
return False

def setEdit(self, vobj, mode=0):
# pylint: disable=unused-argument
return True

def claimChildren(self):
Expand All @@ -461,9 +460,11 @@ def __getstate__(self):
return None

def __setstate__(self, state):
# pylint: disable=unused-argument
return None

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)
Expand All @@ -472,6 +473,7 @@ def onDelete(self, arg1=None, arg2=None):


class CommandDressupDragknife:
# pylint: disable=no-init

def GetResources(self):
return {'Pixmap': 'Path-Dressup',
Expand All @@ -482,7 +484,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 Expand Up @@ -512,7 +514,7 @@ def Activated(self):
FreeCADGui.doCommand('job = PathScripts.PathUtils.findParentJob(base)')
FreeCADGui.doCommand('obj.Base = base')
FreeCADGui.doCommand('job.Proxy.addOperation(obj, base)')
FreeCADGui.doCommand('PathScripts.PathDressupDragknife.ViewProviderDressup(obj.ViewObject)')
FreeCADGui.doCommand('obj.ViewObject.Proxy = PathScripts.PathDressupDragknife.ViewProviderDressup(obj.ViewObject)')
FreeCADGui.doCommand('Gui.ActiveDocument.getObject(base.Name).Visibility = False')
FreeCADGui.doCommand('obj.filterangle = 20')
FreeCADGui.doCommand('obj.offset = 2')
Expand Down
29 changes: 17 additions & 12 deletions src/Mod/Path/PathScripts/PathDressupLeadInOut.py
Expand Up @@ -34,7 +34,7 @@

from PySide import QtCore

"""LeadInOut Dressup MASHIN-CRC USE ROLL-ON ROLL-OFF to profile"""
__doc__ = """LeadInOut Dressup MASHIN-CRC USE ROLL-ON ROLL-OFF to profile"""

if FreeCAD.GuiUp:
import FreeCADGui
Expand All @@ -48,7 +48,6 @@ def translate(text, context="Path_DressupLeadInOut", disambig=None):
movecommands = ['G1', 'G01', 'G2', 'G02', 'G3', 'G03']
rapidcommands = ['G0', 'G00']
arccommands = ['G2', 'G3', 'G02', 'G03']
global currLocation
currLocation = {}


Expand All @@ -70,10 +69,14 @@ def __init__(self, obj):
obj.RadiusCenter = ["Radius", "Center"]
obj.Proxy = self

self.wire = None
self.rapids = None

def __getstate__(self):
return None

def __setstate__(self, state):
# pylint: disable=unused-argument
return None

def setup(self, obj):
Expand Down Expand Up @@ -122,7 +125,6 @@ def normalize(self, Vector):

def getLeadStart(self, obj, queue, action):
'''returns Lead In G-code.'''
global currLocation
results = []
# zdepth = currLocation["Z"]
op = PathDressup.baseOp(obj.Base)
Expand Down Expand Up @@ -171,10 +173,10 @@ def getLeadStart(self, obj, queue, action):
extendcommand = Path.Command('G1', {"X": leadstart.x, "Y": leadstart.y, "Z": p1.z, "F": vertFeed})
results.append(extendcommand)
if obj.UseMachineCRC:
if self.getDirectionOfPath(obj) == 'right':
results.append(Path.Command('G42', {'D': toolnummer}))
else:
results.append(Path.Command('G41', {'D': toolnummer}))
if self.getDirectionOfPath(obj) == 'right':
results.append(Path.Command('G42', {'D': toolnummer}))
else:
results.append(Path.Command('G41', {'D': toolnummer}))
if obj.StyleOn == 'Arc':
arcmove = Path.Command(arcdir, {"X": p0.x, "Y": p0.y, "I": offsetvector.x, "J": offsetvector.y, "F": horizFeed}) # add G2/G3 move
results.append(arcmove)
Expand All @@ -187,7 +189,7 @@ def getLeadStart(self, obj, queue, action):

def getLeadEnd(self, obj, queue, action):
'''returns the Gcode of LeadOut.'''
global currLocation
# pylint: disable=unused-argument
results = []
horizFeed = PathDressup.toolController(obj.Base).HorizFeed.Value
R = obj.Length.Value # Radius of roll or length
Expand Down Expand Up @@ -228,7 +230,7 @@ def getLeadEnd(self, obj, queue, action):
return results

def generateLeadInOutCurve(self, obj):
global currLocation
global currLocation # pylint: disable=global-statement
firstmove = Path.Command("G0", {"X": 0, "Y": 0, "Z": 0})
currLocation.update(firstmove.Parameters)
newpath = []
Expand Down Expand Up @@ -298,7 +300,7 @@ def generateLeadInOutCurve(self, obj):
class ViewProviderDressup:

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

def attach(self, vobj):
self.obj = vobj.Object
Expand All @@ -317,8 +319,9 @@ def claimChildren(self):
return [self.obj.Base]

def onDelete(self, arg1=None, arg2=None):
PathLog.debug("Deleting Dressup")
'''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)
Expand All @@ -329,10 +332,12 @@ def __getstate__(self):
return None

def __setstate__(self, state):
# pylint: disable=unused-argument
return None


class CommandPathDressupLeadInOut:
# pylint: disable=no-init

def GetResources(self):
return {'Pixmap': 'Path-Dressup',
Expand Down Expand Up @@ -370,7 +375,7 @@ def Activated(self):
FreeCADGui.doCommand('job = PathScripts.PathUtils.findParentJob(base)')
FreeCADGui.doCommand('obj.Base = base')
FreeCADGui.doCommand('job.Proxy.addOperation(obj, base)')
FreeCADGui.doCommand('PathScripts.PathDressupLeadInOut.ViewProviderDressup(obj.ViewObject)')
FreeCADGui.doCommand('obj.ViewObject.Proxy = PathScripts.PathDressupLeadInOut.ViewProviderDressup(obj.ViewObject)')
FreeCADGui.doCommand('Gui.ActiveDocument.getObject(base.Name).Visibility = False')
FreeCADGui.doCommand('dbo.setup(obj)')
FreeCAD.ActiveDocument.commitTransaction()
Expand Down
19 changes: 16 additions & 3 deletions src/Mod/Path/PathScripts/PathDressupRampEntry.py
Expand Up @@ -60,6 +60,15 @@ def __init__(self, obj):
obj.Proxy = self
self.setEditorProperties(obj)

# initialized later
self.wire = None
self.angle = None
self.rapids = None
self.method = None
self.outedges = None
self.ignoreAboveEnabled = None
self.ignoreAbove = None

def __getstate__(self):
return None

Expand Down Expand Up @@ -366,6 +375,7 @@ def createRampMethod1(self, rampedges, p0, projectionlen, rampangle):
curPoint = p0 # start from the upper point of plunge
done = False
goingForward = True
i = 0
while not done:
for i, redge in enumerate(rampedges):
if redge.Length >= rampremaining:
Expand Down Expand Up @@ -432,6 +442,7 @@ def createRampMethod3(self, rampedges, p0, projectionlen, rampangle):
curPoint = p0 # start from the upper point of plunge
done = False

i = 0
while not done:
for i, redge in enumerate(rampedges):
if redge.Length >= rampremaining:
Expand Down Expand Up @@ -621,7 +632,7 @@ def createCommands(self, obj, edges):
class ViewProviderDressup:

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

def attach(self, vobj):
self.obj = vobj.Object
Expand All @@ -640,8 +651,9 @@ def claimChildren(self):
return [self.obj.Base]

def onDelete(self, arg1=None, arg2=None):
PathLog.debug("Deleting Dressup")
'''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)
Expand All @@ -656,6 +668,7 @@ def __setstate__(self, state):


class CommandPathDressupRampEntry:
# pylint: disable=no-init

def GetResources(self):
return {'Pixmap': 'Path-Dressup',
Expand Down Expand Up @@ -693,7 +706,7 @@ def Activated(self):
FreeCADGui.doCommand('job = PathScripts.PathUtils.findParentJob(base)')
FreeCADGui.doCommand('obj.Base = base')
FreeCADGui.doCommand('job.Proxy.addOperation(obj, base)')
FreeCADGui.doCommand('PathScripts.PathDressupRampEntry.ViewProviderDressup(obj.ViewObject)')
FreeCADGui.doCommand('obj.ViewObject.Proxy = PathScripts.PathDressupRampEntry.ViewProviderDressup(obj.ViewObject)')
FreeCADGui.doCommand('Gui.ActiveDocument.getObject(base.Name).Visibility = False')
FreeCADGui.doCommand('dbo.setup(obj)')
FreeCAD.ActiveDocument.commitTransaction()
Expand Down

0 comments on commit 04b4db1

Please sign in to comment.