Renamed tabs to tags.

This commit is contained in:
ml 2016-10-30 23:34:05 -07:00 committed by Markus Lampert
parent 79935ee025
commit 344250b5c2
5 changed files with 58 additions and 47 deletions

View File

@ -38,7 +38,7 @@ SET(PathScripts_SRCS
PathScripts/PathDrilling.py PathScripts/PathDrilling.py
PathScripts/PathDressup.py PathScripts/PathDressup.py
PathScripts/DragknifeDressup.py PathScripts/DragknifeDressup.py
PathScripts/PathDressupHoldingTabs.py PathScripts/PathDressupHoldingTags.py
PathScripts/PathHop.py PathScripts/PathHop.py
PathScripts/PathUtils.py PathScripts/PathUtils.py
PathScripts/PathSelection.py PathScripts/PathSelection.py
@ -48,6 +48,7 @@ SET(PathScripts_SRCS
PathScripts/PathJob.py PathScripts/PathJob.py
PathScripts/PathStock.py PathScripts/PathStock.py
PathScripts/PathPlane.py PathScripts/PathPlane.py
PathScripts/PathPocket.py
PathScripts/PathPost.py PathScripts/PathPost.py
PathScripts/PathPostProcessor.py PathScripts/PathPostProcessor.py
PathScripts/PathLoadTool.py PathScripts/PathLoadTool.py

View File

@ -90,6 +90,6 @@
<file>panels/DogboneEdit.ui</file> <file>panels/DogboneEdit.ui</file>
<file>panels/DlgSelectPostProcessor.ui</file> <file>panels/DlgSelectPostProcessor.ui</file>
<file>preferences/PathJob.ui</file> <file>preferences/PathJob.ui</file>
<file>panels/HoldingTabsEdit.ui</file> <file>panels/HoldingTagsEdit.ui</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -131,7 +131,7 @@
<item row="4" column="1"> <item row="4" column="1">
<widget class="QDoubleSpinBox" name="dsbWidth"> <widget class="QDoubleSpinBox" name="dsbWidth">
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Width of each tab.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Width of each tag.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -145,7 +145,7 @@
<item row="5" column="1"> <item row="5" column="1">
<widget class="QDoubleSpinBox" name="dsbHeight"> <widget class="QDoubleSpinBox" name="dsbHeight">
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The height of the holding tab measured from the bottom of the path. By default this is set to the (estimated) height of the path.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The height of the holding tag measured from the bottom of the path. By default this is set to the (estimated) height of the path.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -165,7 +165,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Angle of tab walls.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Angle of tag walls.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -205,7 +205,7 @@
<item row="0" column="1"> <item row="0" column="1">
<widget class="QSpinBox" name="sbCount"> <widget class="QSpinBox" name="sbCount">
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enter the number of tabs you wish to have.&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;Note that sometimes it's necessary to enter a larger than desired count number and disable the ones tabs you don't want in order to get the holding tab layout you want.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enter the number of tags you wish to have.&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;Note that sometimes it's necessary to enter a larger than desired count number and disable the ones tags you don't want in order to get the holding tag layout you want.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -75,7 +75,7 @@ class PathWorkbench (Workbench):
from PathScripts import PathProfileEdges from PathScripts import PathProfileEdges
from PathScripts import DogboneDressup from PathScripts import DogboneDressup
from PathScripts import PathMillFace from PathScripts import PathMillFace
from PathScripts import PathDressupHoldingTabs from PathScripts import PathDressupHoldingTags
import PathCommands import PathCommands
# build commands list # build commands list
@ -85,7 +85,7 @@ class PathWorkbench (Workbench):
twodopcmdlist = ["Path_Contour", "Path_Profile", "Path_Profile_Edges", "Path_Pocket", "Path_Drilling", "Path_Engrave", "Path_MillFace"] twodopcmdlist = ["Path_Contour", "Path_Profile", "Path_Profile_Edges", "Path_Pocket", "Path_Drilling", "Path_Engrave", "Path_MillFace"]
threedopcmdlist = ["Path_Surfacing"] threedopcmdlist = ["Path_Surfacing"]
modcmdlist = ["Path_Copy", "Path_CompoundExtended", "Path_Array", "Path_SimpleCopy" ] modcmdlist = ["Path_Copy", "Path_CompoundExtended", "Path_Array", "Path_SimpleCopy" ]
dressupcmdlist = ["Dogbone_Dressup", "DragKnife_Dressup", "PathDressup_HoldingTabs"] dressupcmdlist = ["Dogbone_Dressup", "DragKnife_Dressup", "PathDressup_HoldingTags"]
extracmdlist = ["Path_SelectLoop"] extracmdlist = ["Path_SelectLoop"]
#modcmdmore = ["Path_Hop",] #modcmdmore = ["Path_Hop",]
#remotecmdlist = ["Path_Remote"] #remotecmdlist = ["Path_Remote"]

View File

@ -142,7 +142,7 @@ class PathData:
wire = Part.Wire(bottom) wire = Part.Wire(bottom)
if wire.isClosed(): if wire.isClosed():
return wire return wire
# if we get here there are already holding tabs, or we're not looking at a profile # if we get here there are already holding tags, or we're not looking at a profile
# let's try and insert the missing pieces - another day # let's try and insert the missing pieces - another day
raise ValueError("Selected path doesn't seem to be a Profile operation.") raise ValueError("Selected path doesn't seem to be a Profile operation.")
@ -168,12 +168,12 @@ class PathData:
# debugMarker(e.Vertexes[0].Point, 'base', (0.0, 1.0, 1.0), 0.2) # debugMarker(e.Vertexes[0].Point, 'base', (0.0, 1.0, 1.0), 0.2)
if spacing: if spacing:
tabDistance = spacing tagDistance = spacing
else: else:
if count: if count:
tabDistance = self.base.Length / count tagDistance = self.base.Length / count
else: else:
tabDistance = self.base.Length / 4 tagDistance = self.base.Length / 4
if width: if width:
W = width W = width
else: else:
@ -184,7 +184,7 @@ class PathData:
H = self.tagHeight() H = self.tagHeight()
# start assigning tabs on the longest segment # start assigning tags on the longest segment
maxLen = self.longestPathEdge().Length maxLen = self.longestPathEdge().Length
startIndex = 0 startIndex = 0
for i in range(0, len(self.base.Edges)): for i in range(0, len(self.base.Edges)):
@ -194,55 +194,55 @@ class PathData:
break break
startEdge = self.base.Edges[startIndex] startEdge = self.base.Edges[startIndex]
startCount = int(startEdge.Length / tabDistance) + 1 startCount = int(startEdge.Length / tagDistance) + 1
lastTabLength = (startEdge.Length + (startCount - 1) * tabDistance) / 2 lastTagLength = (startEdge.Length + (startCount - 1) * tagDistance) / 2
if lastTabLength < 0 or lastTabLength > startEdge.Length: if lastTagLength < 0 or lastTagLength > startEdge.Length:
lastTabLength = startEdge.Length / 2 lastTagLength = startEdge.Length / 2
currentLength = startEdge.Length currentLength = startEdge.Length
minLength = 2. * W minLength = 2. * W
#print("start index=%-2d -> count=%d (length=%.2f, distance=%.2f)" % (startIndex, startCount, startEdge.Length, tabDistance)) #print("start index=%-2d -> count=%d (length=%.2f, distance=%.2f)" % (startIndex, startCount, startEdge.Length, tagDistance))
#print(" -> lastTabLength=%.2f)" % lastTabLength) #print(" -> lastTagLength=%.2f)" % lastTagLength)
#print(" -> currentLength=%.2f)" % currentLength) #print(" -> currentLength=%.2f)" % currentLength)
tabs = { startIndex: startCount } edgeDict = { startIndex: startCount }
for i in range(startIndex + 1, len(self.base.Edges)): for i in range(startIndex + 1, len(self.base.Edges)):
edge = self.base.Edges[i] edge = self.base.Edges[i]
(currentLength, lastTabLength) = self.processEdge(i, edge, currentLength, lastTabLength, tabDistance, minLength, tabs) (currentLength, lastTagLength) = self.processEdge(i, edge, currentLength, lastTagLength, tagDistance, minLength, edgeDict)
for i in range(0, startIndex): for i in range(0, startIndex):
edge = self.base.Edges[i] edge = self.base.Edges[i]
(currentLength, lastTabLength) = self.processEdge(i, edge, currentLength, lastTabLength, tabDistance, minLength, tabs) (currentLength, lastTagLength) = self.processEdge(i, edge, currentLength, lastTagLength, tagDistance, minLength, edgeDict)
tags = [] tags = []
for (i, count) in tabs.iteritems(): for (i, count) in edgeDict.iteritems():
edge = self.base.Edges[i] edge = self.base.Edges[i]
#debugMarker(edge.Vertexes[0].Point, 'base', (1.0, 0.0, 0.0), 0.2) #debugMarker(edge.Vertexes[0].Point, 'base', (1.0, 0.0, 0.0), 0.2)
#debugMarker(edge.Vertexes[1].Point, 'base', (0.0, 1.0, 0.0), 0.2) #debugMarker(edge.Vertexes[1].Point, 'base', (0.0, 1.0, 0.0), 0.2)
distance = (edge.LastParameter - edge.FirstParameter) / count distance = (edge.LastParameter - edge.FirstParameter) / count
for j in range(0, count): for j in range(0, count):
tab = edge.Curve.value((j+0.5) * distance) tag = edge.Curve.value((j+0.5) * distance)
tags.append(Tag(tab.x, tab.y, W, H, angle, True)) tags.append(Tag(tag.x, tag.y, W, H, angle, True))
return tags return tags
def processEdge(self, index, edge, currentLength, lastTabLength, tabDistance, minLength, tabs): def processEdge(self, index, edge, currentLength, lastTagLength, tagDistance, minLength, edgeDict):
tabCount = 0 tagCount = 0
currentLength += edge.Length currentLength += edge.Length
if edge.Length > minLength: if edge.Length > minLength:
while lastTabLength + tabDistance < currentLength: while lastTagLength + tagDistance < currentLength:
tabCount += 1 tagCount += 1
lastTabLength += tabDistance lastTagLength += tagDistance
if tabCount > 0: if tagCount > 0:
#print(" index=%d -> count=%d" % (index, tabCount)) #print(" index=%d -> count=%d" % (index, tagCount))
tabs[index] = tabCount edgeDict[index] = tagCount
#else: #else:
#print(" skipping=%-2d (%.2f)" % (index, edge.Length)) #print(" skipping=%-2d (%.2f)" % (index, edge.Length))
return (currentLength, lastTabLength) return (currentLength, lastTagLength)
def tagHeight(self): def tagHeight(self):
return self.maxZ - self.minZ return self.maxZ - self.minZ
@ -309,7 +309,7 @@ class ObjectDressup:
for tag in tags: for tag in tags:
tagID += 1 tagID += 1
if tag.enabled: if tag.enabled:
print("x=%s, y=%s, z=%s" % (tag.x, tag.y, pathData.minZ)) #print("x=%s, y=%s, z=%s" % (tag.x, tag.y, pathData.minZ))
debugMarker(FreeCAD.Vector(tag.x, tag.y, pathData.minZ), "tag-%02d" % tagID , (1.0, 0.0, 1.0), 0.5) debugMarker(FreeCAD.Vector(tag.x, tag.y, pathData.minZ), "tag-%02d" % tagID , (1.0, 0.0, 1.0), 0.5)
self.fingerprint = [tag.toString() for tag in tags] self.fingerprint = [tag.toString() for tag in tags]
self.tags = tags self.tags = tags
@ -329,13 +329,13 @@ class ObjectDressup:
try: try:
pathData = PathData(obj) pathData = PathData(obj)
except ValueError: except ValueError:
FreeCAD.Console.PrintError(translate("PathDressup_HoldingTags", "Cannot insert holding tabs for this path - please select a Profile path\n")) FreeCAD.Console.PrintError(translate("PathDressup_HoldingTags", "Cannot insert holding tags for this path - please select a Profile path\n"))
return None return None
## setup the object's properties, in case they're not set yet ## setup the object's properties, in case they're not set yet
#obj.Count = self.tabCount(obj) #obj.Count = self.tagCount(obj)
#obj.Angle = self.tabAngle(obj) #obj.Angle = self.tagAngle(obj)
#obj.Blacklist = self.tabBlacklist(obj) #obj.Blacklist = self.tagBlacklist(obj)
# if the heigt isn't set, use the height of the path # if the heigt isn't set, use the height of the path
#if not hasattr(obj, "Height") or not obj.Height: #if not hasattr(obj, "Height") or not obj.Height:
@ -379,7 +379,7 @@ class TaskPanel:
def __init__(self, obj): def __init__(self, obj):
self.obj = obj self.obj = obj
self.form = FreeCADGui.PySideUic.loadUi(":/panels/HoldingTabsEdit.ui") self.form = FreeCADGui.PySideUic.loadUi(":/panels/HoldingTagsEdit.ui")
FreeCAD.ActiveDocument.openTransaction(translate("PathDressup_HoldingTags", "Edit HoldingTags Dress-up")) FreeCAD.ActiveDocument.openTransaction(translate("PathDressup_HoldingTags", "Edit HoldingTags Dress-up"))
def reject(self): def reject(self):
@ -437,12 +437,14 @@ class TaskPanel:
self.form.twTags.blockSignals(False) self.form.twTags.blockSignals(False)
def cleanupUI(self): def cleanupUI(self):
print("cleanupUI")
if debugDressup: if debugDressup:
for obj in FreeCAD.ActiveDocument.Objects: for obj in FreeCAD.ActiveDocument.Objects:
if obj.Name.startswith('tag'): if obj.Name.startswith('tag'):
FreeCAD.ActiveDocument.removeObject(obj.Name) FreeCAD.ActiveDocument.removeObject(obj.Name)
def updateUI(self): def updateUI(self):
print("updateUI")
self.cleanupUI() self.cleanupUI()
self.getFields() self.getFields()
if debugDressup: if debugDressup:
@ -450,6 +452,7 @@ class TaskPanel:
def whenApplyClicked(self): def whenApplyClicked(self):
print("whenApplyClicked")
self.cleanupUI() self.cleanupUI()
count = self.form.sbCount.value() count = self.form.sbCount.value()
@ -459,16 +462,20 @@ class TaskPanel:
angle = self.form.dsbAngle.value() angle = self.form.dsbAngle.value()
tags = self.obj.Proxy.generateTags(self.obj, count, width, height, angle, spacing) tags = self.obj.Proxy.generateTags(self.obj, count, width, height, angle, spacing)
self.obj.Proxy.setTags(self.obj, tags) self.obj.Proxy.setTags(self.obj, tags)
self.updateTags() self.updateTags()
if debugDressup: if debugDressup:
# this causes a big of an echo and a double click on the spin buttons, don't know why though
FreeCAD.ActiveDocument.recompute() FreeCAD.ActiveDocument.recompute()
def autoApply(self): def autoApply(self):
print("autoApply")
if self.form.cbAutoApply.checkState() == QtCore.Qt.CheckState.Checked: if self.form.cbAutoApply.checkState() == QtCore.Qt.CheckState.Checked:
self.whenApplyClicked() self.whenApplyClicked()
def updateTagSpacing(self, count): def updateTagSpacing(self, count):
print("updateTagSpacing")
if count == 0: if count == 0:
spacing = 0 spacing = 0
else: else:
@ -478,10 +485,12 @@ class TaskPanel:
self.form.dsbSpacing.blockSignals(False) self.form.dsbSpacing.blockSignals(False)
def whenCountChanged(self): def whenCountChanged(self):
print("whenCountChanged")
self.updateTagSpacing(self.form.sbCount.value()) self.updateTagSpacing(self.form.sbCount.value())
self.autoApply() self.autoApply()
def whenSpacingChanged(self): def whenSpacingChanged(self):
print("whenSpacingChanged")
if self.form.dsbSpacing.value() == 0: if self.form.dsbSpacing.value() == 0:
count = 0 count = 0
else: else:
@ -492,6 +501,7 @@ class TaskPanel:
self.autoApply() self.autoApply()
def whenOkClicked(self): def whenOkClicked(self):
print("whenOkClicked")
self.whenApplyClicked() self.whenApplyClicked()
self.form.toolBox.setCurrentWidget(self.form.tbpTags) self.form.toolBox.setCurrentWidget(self.form.tbpTags)
@ -579,7 +589,7 @@ class ViewProviderDressup:
PathUtils.addToJob(arg1.Object.Base) PathUtils.addToJob(arg1.Object.Base)
return True return True
class CommandPathDressupHoldingTabs: class CommandPathDressupHoldingTags:
def GetResources(self): def GetResources(self):
return {'Pixmap': 'Path-Dressup', return {'Pixmap': 'Path-Dressup',
@ -610,12 +620,12 @@ class CommandPathDressupHoldingTabs:
# everything ok! # everything ok!
FreeCAD.ActiveDocument.openTransaction(translate("PathDressup_HoldingTags", "Create HoldingTags Dress-up")) FreeCAD.ActiveDocument.openTransaction(translate("PathDressup_HoldingTags", "Create HoldingTags Dress-up"))
FreeCADGui.addModule("PathScripts.PathDressupHoldingTabs") FreeCADGui.addModule("PathScripts.PathDressupHoldingTags")
FreeCADGui.addModule("PathScripts.PathUtils") FreeCADGui.addModule("PathScripts.PathUtils")
FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "HoldingTabsDressup")') FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "HoldingTagsDressup")')
FreeCADGui.doCommand('dbo = PathScripts.PathDressupHoldingTabs.ObjectDressup(obj)') FreeCADGui.doCommand('dbo = PathScripts.PathDressupHoldingTags.ObjectDressup(obj)')
FreeCADGui.doCommand('obj.Base = FreeCAD.ActiveDocument.' + selection[0].Name) FreeCADGui.doCommand('obj.Base = FreeCAD.ActiveDocument.' + selection[0].Name)
FreeCADGui.doCommand('PathScripts.PathDressupHoldingTabs.ViewProviderDressup(obj.ViewObject)') FreeCADGui.doCommand('PathScripts.PathDressupHoldingTags.ViewProviderDressup(obj.ViewObject)')
FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)') FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)')
FreeCADGui.doCommand('Gui.ActiveDocument.getObject(obj.Base.Name).Visibility = False') FreeCADGui.doCommand('Gui.ActiveDocument.getObject(obj.Base.Name).Visibility = False')
FreeCADGui.doCommand('dbo.setup(obj)') FreeCADGui.doCommand('dbo.setup(obj)')
@ -624,6 +634,6 @@ class CommandPathDressupHoldingTabs:
if FreeCAD.GuiUp: if FreeCAD.GuiUp:
# register the FreeCAD command # register the FreeCAD command
FreeCADGui.addCommand('PathDressup_HoldingTags', CommandPathDressupHoldingTabs()) FreeCADGui.addCommand('PathDressup_HoldingTags', CommandPathDressupHoldingTags())
FreeCAD.Console.PrintLog("Loading PathDressupHoldingTabs... done\n") FreeCAD.Console.PrintLog("Loading PathDressupHoldingTags... done\n")