Renamed BitTemplate to BitShape for clarity

This commit is contained in:
Markus Lampert
2019-11-01 14:04:34 -07:00
parent fee1ddf73a
commit db1f97b16e
21 changed files with 73 additions and 73 deletions

View File

@@ -155,10 +155,10 @@ SET(Tools_Library_SRCS
Tools/Library/endmills.fctl
)
SET(Tools_Template_SRCS
Tools/Template/drill-straight.fcstd
Tools/Template/endmill-straight.fcstd
Tools/Template/v-bit.fcstd
SET(Tools_Shape_SRCS
Tools/Shape/drill-straight.fcstd
Tools/Shape/endmill-straight.fcstd
Tools/Shape/v-bit.fcstd
)
SET(PathTests_SRCS
@@ -207,7 +207,7 @@ SET(all_files
${PathScripts_post_SRCS}
${Tools_Bit_SRCS}
${Tools_Library_SRCS}
${Tools_Template_SRCS}
${Tools_Shape_SRCS}
${Path_Images}
)
@@ -264,9 +264,9 @@ INSTALL(
INSTALL(
FILES
${Tools_Template_SRCS}
${Tools_Shape_SRCS}
DESTINATION
Mod/Path/Tools/Template
Mod/Path/Tools/Shape
)
INSTALL(

View File

@@ -78,10 +78,10 @@
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="templatePath"/>
<widget class="QLineEdit" name="shapePath"/>
</item>
<item>
<widget class="QToolButton" name="templateSet">
<widget class="QToolButton" name="shapeSet">
<property name="text">
<string>...</string>
</property>

View File

@@ -43,7 +43,7 @@ PostProcessorOutputPolicy = "PostProcessorOutputPolicy"
LastPathToolBit = "LastPathToolBit"
LastPathToolLibrary = "LastPathToolLibrary"
LastPathToolTemplate = "LastPathToolTemplate"
LastPathToolShape = "LastPathToolShape"
# Linear tolerance to use when generating Paths, eg when tessellating geometry
GeometryTolerance = "GeometryTolerance"
@@ -133,8 +133,8 @@ def searchPathsTool(sub='Bit'):
paths.append(lastPathToolBit())
if 'Library' == sub:
paths.append(lastPathToolLibrary())
if 'Template' == sub:
paths.append(lastPathToolTemplate())
if 'Shape' == sub:
paths.append(lastPathToolShape())
def appendPath(p, sub):
if p:
@@ -210,8 +210,8 @@ def lastPathToolLibrary():
def setLastPathToolLibrary(path):
return preferences().SetString(LastPathToolLibrary, path)
def lastPathToolTemplate():
return preferences().GetString(LastPathToolTemplate, pathDefaultToolsPath('Template'))
def setLastPathToolTemplate(path):
return preferences().SetString(LastPathToolTemplate, path)
def lastPathToolShape():
return preferences().GetString(LastPathToolShape, pathDefaultToolsPath('Shape'))
def setLastPathToolShape(path):
return preferences().SetString(LastPathToolShape, path)

View File

@@ -82,9 +82,9 @@ def _findTool(path, typ, dbg=False):
return searchFor(path, '')
def findTemplate(path):
'''findTemplate(path) ... search for path, full and partially in all known template directories.'''
return _findTool(path, 'Template')
def findShape(path):
'''findShape(path) ... search for path, full and partially in all known shape directories.'''
return _findTool(path, 'Shape')
def findBit(path):
if path.endswith('.fctb'):
@@ -121,14 +121,14 @@ PropertyGroupAttribute = 'Attribute'
class ToolBit(object):
def __init__(self, obj, templateFile):
PathLog.track(obj.Label, templateFile)
def __init__(self, obj, shapeFile):
PathLog.track(obj.Label, shapeFile)
self.obj = obj
obj.addProperty('App::PropertyFile', 'BitTemplate', 'Base', translate('PathToolBit', 'Template for bit shape'))
obj.addProperty('App::PropertyFile', 'BitShape', 'Base', translate('PathToolBit', 'Shape for bit shape'))
obj.addProperty('App::PropertyLink', 'BitBody', 'Base', translate('PathToolBit', 'The parametrized body representing the tool bit'))
obj.addProperty('App::PropertyFile', 'File', 'Base', translate('PathToolBit', 'The file of the tool'))
if templateFile is not None:
obj.BitTemplate = templateFile
if shapeFile is not None:
obj.BitShape = shapeFile
self._setupBitShape(obj)
self.onDocumentRestored(obj)
@@ -149,7 +149,7 @@ class ToolBit(object):
return [prop for prop in obj.PropertiesList if obj.getGroupOfProperty(prop) == PropertyGroupAttribute]
def onDocumentRestored(self, obj):
obj.setEditorMode('BitTemplate', 1)
obj.setEditorMode('BitShape', 1)
obj.setEditorMode('BitBody', 2)
obj.setEditorMode('File', 1)
obj.setEditorMode('Shape', 2)
@@ -162,7 +162,7 @@ class ToolBit(object):
def onChanged(self, obj, prop):
PathLog.track(obj.Label, prop)
if prop == 'BitTemplate' and not 'Restore' in obj.State:
if prop == 'BitShape' and not 'Restore' in obj.State:
self._setupBitShape(obj)
#elif obj.getGroupOfProperty(prop) == PropertyGroupBit:
# self._updateBitShape(obj, [prop])
@@ -185,7 +185,7 @@ class ToolBit(object):
obj.Shape = Part.Shape()
def _loadBitBody(self, obj, path=None):
p = path if path else obj.BitTemplate
p = path if path else obj.BitShape
docOpened = False
doc = None
for d in FreeCAD.listDocuments():
@@ -193,9 +193,9 @@ class ToolBit(object):
doc = FreeCAD.getDocument(d)
break
if doc is None:
p = findTemplate(p)
if not path and p != obj.BitTemplate:
obj.BitTemplate = p
p = findShape(p)
if not path and p != obj.BitShape:
obj.BitShape = p
doc = FreeCAD.open(p)
docOpened = True
return (doc, docOpened)
@@ -257,8 +257,8 @@ class ToolBit(object):
PathUtil.setProperty(obj, prop, value)
def getBitThumbnail(self, obj):
if obj.BitTemplate:
with open(obj.BitTemplate, 'rb') as fd:
if obj.BitShape:
with open(obj.BitShape, 'rb') as fd:
zf = zipfile.ZipFile(fd)
pf = zf.open('thumbnails/Thumbnail.png', 'r')
data = pf.read()
@@ -270,7 +270,7 @@ class ToolBit(object):
def saveToFile(self, obj, path, setFile=True):
try:
with open(path, 'w') as fp:
json.dump(self.templateAttrs(obj), fp, indent=' ')
json.dump(self.shapeAttrs(obj), fp, indent=' ')
if setFile:
obj.File = path
return True
@@ -278,11 +278,11 @@ class ToolBit(object):
PathLog.error("Could not save tool %s to %s (%s)" % (obj.Label, path, e))
raise
def templateAttrs(self, obj):
def shapeAttrs(self, obj):
attrs = {}
attrs['version'] = 2 # Path.Tool is version 1
attrs['name'] = obj.Label
attrs['template'] = obj.BitTemplate
attrs['shape'] = obj.BitShape
params = {}
for name in self.propertyNamesBit(obj):
params[name] = PathUtil.getPropertyValueString(obj, name)
@@ -311,7 +311,7 @@ class AttributePrototype(PathSetupSheetOpPrototype.OpPrototype):
class ToolBitFactory(object):
def CreateFromAttrs(self, attrs, name='ToolBit'):
obj = Factory.Create(name, attrs['template'])
obj = Factory.Create(name, attrs['shape'])
obj.Label = attrs['name']
params = attrs['parameter']
for prop in params:
@@ -335,9 +335,9 @@ class ToolBitFactory(object):
PathLog.error("%s not a valid tool file (%s)" % (path, e))
raise
def Create(self, name='ToolBit', templateFile=None):
def Create(self, name='ToolBit', shapeFile=None):
obj = FreeCAD.ActiveDocument.addObject('Part::FeaturePython', name)
obj.Proxy = ToolBit(obj, templateFile)
obj.Proxy = ToolBit(obj, shapeFile)
return obj
Factory = ToolBitFactory()

View File

@@ -56,8 +56,8 @@ class ToolBitEditor(object):
parentWidget.layout().addWidget(self.form)
self.tool = tool
if not tool.BitTemplate:
self.tool.BitTemplate = 'src/Mod/Path/Tools/Template/endmill-straight.fcstd'
if not tool.BitShape:
self.tool.BitShape = 'src/Mod/Path/Tools/Shape/endmill-straight.fcstd'
self.tool.Proxy.loadBitBody(self.tool)
self.setupTool(self.tool)
self.setupAttributes(self.tool)
@@ -147,13 +147,13 @@ class ToolBitEditor(object):
def updateUI(self):
PathLog.track()
self.form.toolName.setText(self.tool.Label)
self.form.templatePath.setText(self.tool.BitTemplate)
self.form.shapePath.setText(self.tool.BitShape)
for editor in self.bitEditor:
self.bitEditor[editor].updateSpinBox()
def updateTemplate(self):
self.tool.BitTemplate = str(self.form.templatePath.text())
def updateShape(self):
self.tool.BitShape = str(self.form.shapePath.text())
self.setupTool(self.tool)
self.form.toolName.setText(self.tool.Label)
@@ -163,7 +163,7 @@ class ToolBitEditor(object):
def updateTool(self):
PathLog.track()
self.tool.Label = str(self.form.toolName.text())
self.tool.BitTemplate = str(self.form.templatePath.text())
self.tool.BitShape = str(self.form.shapePath.text())
for editor in self.bitEditor:
self.bitEditor[editor].updateProperty()
@@ -177,23 +177,23 @@ class ToolBitEditor(object):
self.updateUI()
self.form.blockSignals(False)
def selectTemplate(self):
path = self.tool.BitTemplate
def selectShape(self):
path = self.tool.BitShape
if not path:
path = PathPreferences.lastPathToolTemplate()
path = PathPreferences.lastPathToolShape()
foo = QtGui.QFileDialog.getOpenFileName(self.form,
"Path - Tool Template",
"Path - Tool Shape",
path,
"*.fcstd")
if foo and foo[0]:
PathPreferences.setLastPathToolTemplate(os.path.dirname(foo[0]))
self.form.templatePath.setText(foo[0])
self.updateTemplate()
PathPreferences.setLastPathToolShape(os.path.dirname(foo[0]))
self.form.shapePath.setText(foo[0])
self.updateShape()
def setupUI(self):
PathLog.track()
self.updateUI()
self.form.toolName.editingFinished.connect(self.refresh)
self.form.templatePath.editingFinished.connect(self.updateTemplate)
self.form.templateSet.clicked.connect(self.selectTemplate)
self.form.shapePath.editingFinished.connect(self.updateShape)
self.form.shapeSet.clicked.connect(self.selectShape)

View File

@@ -255,11 +255,11 @@ class ToolBitSelector(object):
class ToolBitGuiFactory(PathToolBit.ToolBitFactory):
def Create(self, name='ToolBit', templateFile=None):
def Create(self, name='ToolBit', shapeFile=None):
'''Create(name = 'ToolBit') ... creates a new tool bit.
It is assumed the tool will be edited immediately so the internal bit body is still attached.'''
FreeCAD.ActiveDocument.openTransaction(translate('PathToolBit', 'Create ToolBit'))
tool = PathToolBit.ToolBitFactory.Create(self, name, templateFile)
tool = PathToolBit.ToolBitFactory.Create(self, name, shapeFile)
PathIconViewProvider.Attach(tool.ViewObject, name)
FreeCAD.ActiveDocument.commitTransaction()
return tool

View File

@@ -147,15 +147,15 @@ class ToolBitLibrary(object):
toolName.setData(tool['name'], PySide.QtCore.Qt.EditRole)
toolName.setEditable(False)
toolTemplate = PySide.QtGui.QStandardItem()
toolTemplate.setData(os.path.splitext(os.path.basename(tool['template']))[0], PySide.QtCore.Qt.EditRole)
toolTemplate.setEditable(False)
toolShape = PySide.QtGui.QStandardItem()
toolShape.setData(os.path.splitext(os.path.basename(tool['shape']))[0], PySide.QtCore.Qt.EditRole)
toolShape.setEditable(False)
toolDiameter = PySide.QtGui.QStandardItem()
toolDiameter.setData(tool['parameter']['Diameter'], PySide.QtCore.Qt.EditRole)
toolDiameter.setEditable(False)
self.model.appendRow([toolNr, toolName, toolTemplate, toolDiameter])
self.model.appendRow([toolNr, toolName, toolShape, toolDiameter])
def toolAdd(self):
PathLog.track()
@@ -276,7 +276,7 @@ class ToolBitLibrary(object):
self.updateToolbar()
def columnNames(self):
return ['Nr', 'Tool', 'Template', 'Diameter']
return ['Nr', 'Tool', 'Shape', 'Diameter']
def setupUI(self):
PathLog.track('+')

View File

@@ -86,7 +86,7 @@ def isValidBaseObject(obj):
# Can't link to anything inside a geo feature group anymore
PathLog.debug("%s is inside a geo feature group" % obj.Label)
return False
if hasattr(obj, 'BitBody') and hasattr(obj, 'BitTemplate'):
if hasattr(obj, 'BitBody') and hasattr(obj, 'BitShape'):
# ToolBit's are not valid base objects
return False
if obj.TypeId in NotValidBaseTypeIds:

View File

@@ -1,7 +1,7 @@
{
"version": 1,
"name": "T1",
"template": "src/Mod/Path/Tools/Template/endmill-straight.fcstd",
"template": "src/Mod/Path/Tools/Shape/endmill-straight.fcstd",
"parameter": {
"CuttingEdgeHeight": "30.000 mm",
"Diameter": "1.000 mm",

View File

@@ -1,7 +1,7 @@
{
"version": 1,
"name": "T2",
"template": "src/Mod/Path/Tools/Template/endmill-straight.fcstd",
"template": "src/Mod/Path/Tools/Shape/endmill-straight.fcstd",
"parameter": {
"CuttingEdgeHeight": "30.000 mm",
"Diameter": "2.000 mm",

View File

@@ -1,7 +1,7 @@
{
"version": 1,
"name": "T3",
"template": "src/Mod/Path/Tools/Template/endmill-straight.fcstd",
"template": "src/Mod/Path/Tools/Shape/endmill-straight.fcstd",
"parameter": {
"CuttingEdgeHeight": "30.000 mm",
"Diameter": "3.000 mm",

View File

@@ -1,7 +1,7 @@
{
"version": 1,
"name": "T4",
"template": "src/Mod/Path/Tools/Template/endmill-straight.fcstd",
"template": "src/Mod/Path/Tools/Shape/endmill-straight.fcstd",
"parameter": {
"CuttingEdgeHeight": "30.000 mm",
"Diameter": "4.000 mm",

View File

@@ -1,7 +1,7 @@
{
"version": 1,
"name": "T5",
"template": "src/Mod/Path/Tools/Template/endmill-straight.fcstd",
"template": "src/Mod/Path/Tools/Shape/endmill-straight.fcstd",
"parameter": {
"CuttingEdgeHeight": "30.000 mm",
"Diameter": "5.000 mm",

View File

@@ -1,7 +1,7 @@
{
"version": 1,
"name": "T6",
"template": "src/Mod/Path/Tools/Template/endmill-straight.fcstd",
"template": "src/Mod/Path/Tools/Shape/endmill-straight.fcstd",
"parameter": {
"CuttingEdgeHeight": "30.000 mm",
"Diameter": "6.000 mm",

View File

@@ -1,7 +1,7 @@
{
"version": 1,
"name": "T7",
"template": "src/Mod/Path/Tools/Template/endmill-straight.fcstd",
"template": "src/Mod/Path/Tools/Shape/endmill-straight.fcstd",
"parameter": {
"CuttingEdgeHeight": "30.000 mm",
"Diameter": "7.000 mm",

View File

@@ -1,7 +1,7 @@
{
"version": 1,
"name": "T8",
"template": "src/Mod/Path/Tools/Template/endmill-straight.fcstd",
"template": "src/Mod/Path/Tools/Shape/endmill-straight.fcstd",
"parameter": {
"CuttingEdgeHeight": "30.000 mm",
"Diameter": "8.000 mm",

View File

@@ -1,7 +1,7 @@
{
"version": 1,
"name": "T9",
"template": "src/Mod/Path/Tools/Template/endmill-straight.fcstd",
"template": "src/Mod/Path/Tools/Shape/endmill-straight.fcstd",
"parameter": {
"CuttingEdgeHeight": "30.000 mm",
"Diameter": "9.000 mm",

View File

@@ -43,7 +43,7 @@ The following directory structure is used for supplied (shipped with FreeCAD) to
Tools
+ Bit
+ Library
+ Template
+ Shape
```
Strictly speaking a user is free to store their tools wherever they want and however they want. By default the file
@@ -62,7 +62,7 @@ TechDraw's templates.
1. Save the tool under path/file that makes sense to you
## How to create a new tool bit Template
## How to create a new tool bit Shape
A tool bit template represents the physical shape of a tool. It does not completely desribe the bit - for that some
additional parameters are needed which will be added when an actual bit is parametrized from the template.
@@ -80,7 +80,7 @@ additional parameters are needed which will be added when an actual bit is param
1. Any unnamed constraint will not be editable for a specific tool
1. Once the sketch is fully constrained, close the sketch
1. Rotate the sketch around the z-axis
1. Save the document as a new file in the Template directory
1. Save the document as a new file in the Shape directory
* Before saving the document make sure you have _Save Thumbnail_ selected, and _Add program logo_ deselected in
FreeCAD's preferences.
* Also make sure to switch to _Front View_ and _Fit content to screen_