Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Show a simple representation of the tool
Builds a representation of the tool and shows it while the task dialog is open.

Next:  Need to make the representation more accurate with respect
to end shape, corner radius, etc.

Need to improve the tool library handling

Need to improve the tool selection process.
  • Loading branch information
sliptonic authored and yorikvanhavre committed Jul 12, 2016
1 parent c5d35a0 commit 19306c6
Showing 1 changed file with 22 additions and 50 deletions.
72 changes: 22 additions & 50 deletions src/Mod/Path/PathScripts/PathLoadTool.py
Expand Up @@ -29,6 +29,7 @@
# import PathGui
import PathScripts
import PathUtils
import Part
# from PathScripts import PathProject
from PySide import QtCore, QtGui

Expand All @@ -43,7 +44,7 @@ def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)


class LoadTool:
class LoadTool():
def __init__(self, obj):
obj.addProperty("App::PropertyIntegerConstraint", "ToolNumber", "Tool", "The active tool")
obj.ToolNumber = (0, 0, 10000, 1)
Expand All @@ -67,6 +68,7 @@ def execute(self, obj):
obj.Label = obj.Name + ": UNDEFINED TOOL"



commands = ""
commands += "(" + obj.Label + ")"+'\n'
commands += 'M6T'+str(obj.ToolNumber)+'\n'
Expand All @@ -77,7 +79,6 @@ def execute(self, obj):
else:
commands += 'M4S' + str(obj.SpindleSpeed) + '\n'

obj.Path = Path.Path(commands)

def onChanged(self, obj, prop):
mode = 2
Expand All @@ -90,6 +91,7 @@ def onChanged(self, obj, prop):


class _ViewProviderLoadTool:

def __init__(self, vobj):
vobj.Proxy = self
mode = 2
Expand Down Expand Up @@ -134,11 +136,14 @@ def setEdit(self, vobj, mode):
taskd.obj = vobj.Object
FreeCADGui.Control.showDialog(taskd)
taskd.setupUi()

FreeCAD.ActiveDocument.recompute()

return True

def unsetEdit(self, vobj, mode):
# this is executed when the user cancels or terminates edit mode
pass
return False


class CommandPathLoadTool:
Expand Down Expand Up @@ -186,15 +191,20 @@ def __init__(self):
self.form = FreeCADGui.PySideUic.loadUi(":/panels/ToolControl.ui")
#self.form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Path/ToolControl.ui")
self.updating = False
self.toolrep = None


def accept(self):
self.getFields()

FreeCADGui.ActiveDocument.resetEdit()
FreeCADGui.Control.closeDialog()
if self.toolrep is not None:
FreeCAD.ActiveDocument.removeObject(self.toolrep.Name)
FreeCAD.ActiveDocument.recompute()
FreeCADGui.Selection.removeObserver(self.s)


def reject(self):
FreeCADGui.Control.closeDialog()
FreeCAD.ActiveDocument.recompute()
Expand Down Expand Up @@ -241,13 +251,6 @@ def setFields(self):
self.form.txtToolDiameter.setText("UNDEFINED")


# self.form.cboToolSelect.addItem(tool.Name)

# index = self.form.cboToolSelect.findText(self.obj.SpindleDir, QtCore.Qt.MatchFixedString)
# if index >= 0:
# self.form.cboSpindleDirection.setCurrentIndex(index)


def open(self):
self.s = SelObserver()
# install the function mode resident
Expand All @@ -263,51 +266,20 @@ def edit(self, item, column):

def resetObject(self, remove=None):
"transfers the values from the widget to the object"
# loc = []
# h = []
# l = []
# a = []

# for i in range(self.form.tagTree.topLevelItemCount()):
# it = self.form.tagTree.findItems(
# str(i+1), QtCore.Qt.MatchExactly, 0)[0]
# if (remove is None) or (remove != i):
# if it.text(1):
# x = float(it.text(1).split()[0].rstrip(","))
# y = float(it.text(1).split()[1].rstrip(","))
# z = float(it.text(1).split()[2].rstrip(","))
# loc.append(Vector(x, y, z))

# else:
# loc.append(0.0)
# if it.text(2):
# h.append(float(it.text(2)))
# else:
# h.append(4.0)
# if it.text(3):
# l.append(float(it.text(3)))
# else:
# l.append(5.0)
# if it.text(4):
# a.append(float(it.text(4)))
# else:
# a.append(45.0)

# self.obj.locs = loc
# self.obj.heights = h
# self.obj.lengths = l
# self.obj.angles = a

# self.obj.touch()
FreeCAD.ActiveDocument.recompute()

def setupUi(self):
pass
# Connect Signals and Slots
# Base Controls
# self.form.baseList.itemSelectionChanged.connect(self.itemActivated)
# setup the form fields
self.setFields()

# build the tool representation
if self.form.txtToolDiameter.text() != "UNDEFINED":
radius = float(self.form.txtToolDiameter.text()) / 2
length = radius * 8
t = Part.makeCylinder(radius, length)
self.toolrep = FreeCAD.ActiveDocument.addObject("Part::Feature", "tool")
self.toolrep.Shape = t

class SelObserver:
def __init__(self):
pass
Expand Down

0 comments on commit 19306c6

Please sign in to comment.