Skip to content

Commit

Permalink
Renamed tabs to tags.
Browse files Browse the repository at this point in the history
  • Loading branch information
mlampert committed Nov 17, 2016
1 parent 79935ee commit 344250b
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 47 deletions.
3 changes: 2 additions & 1 deletion src/Mod/Path/CMakeLists.txt
Expand Up @@ -38,7 +38,7 @@ SET(PathScripts_SRCS
PathScripts/PathDrilling.py
PathScripts/PathDressup.py
PathScripts/DragknifeDressup.py
PathScripts/PathDressupHoldingTabs.py
PathScripts/PathDressupHoldingTags.py
PathScripts/PathHop.py
PathScripts/PathUtils.py
PathScripts/PathSelection.py
Expand All @@ -48,6 +48,7 @@ SET(PathScripts_SRCS
PathScripts/PathJob.py
PathScripts/PathStock.py
PathScripts/PathPlane.py
PathScripts/PathPocket.py
PathScripts/PathPost.py
PathScripts/PathPostProcessor.py
PathScripts/PathLoadTool.py
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Path/Gui/Resources/Path.qrc
Expand Up @@ -90,6 +90,6 @@
<file>panels/DogboneEdit.ui</file>
<file>panels/DlgSelectPostProcessor.ui</file>
<file>preferences/PathJob.ui</file>
<file>panels/HoldingTabsEdit.ui</file>
<file>panels/HoldingTagsEdit.ui</file>
</qresource>
</RCC>
Expand Up @@ -131,7 +131,7 @@
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="dsbWidth">
<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>
</widget>
</item>
Expand All @@ -145,7 +145,7 @@
<item row="5" column="1">
<widget class="QDoubleSpinBox" name="dsbHeight">
<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>
</widget>
</item>
Expand All @@ -165,7 +165,7 @@
<bool>true</bool>
</property>
<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>
</widget>
</item>
Expand Down Expand Up @@ -205,7 +205,7 @@
<item row="0" column="1">
<widget class="QSpinBox" name="sbCount">
<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>
</widget>
</item>
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Path/InitGui.py
Expand Up @@ -75,7 +75,7 @@ def Initialize(self):
from PathScripts import PathProfileEdges
from PathScripts import DogboneDressup
from PathScripts import PathMillFace
from PathScripts import PathDressupHoldingTabs
from PathScripts import PathDressupHoldingTags
import PathCommands

# build commands list
Expand All @@ -85,7 +85,7 @@ def Initialize(self):
twodopcmdlist = ["Path_Contour", "Path_Profile", "Path_Profile_Edges", "Path_Pocket", "Path_Drilling", "Path_Engrave", "Path_MillFace"]
threedopcmdlist = ["Path_Surfacing"]
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"]
#modcmdmore = ["Path_Hop",]
#remotecmdlist = ["Path_Remote"]
Expand Down
Expand Up @@ -142,7 +142,7 @@ def findBottomWire(self, edges):
wire = Part.Wire(bottom)
if wire.isClosed():
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
raise ValueError("Selected path doesn't seem to be a Profile operation.")

Expand All @@ -168,12 +168,12 @@ def generateTags(self, obj, count=None, width=None, height=None, angle=90, spaci
# debugMarker(e.Vertexes[0].Point, 'base', (0.0, 1.0, 1.0), 0.2)

if spacing:
tabDistance = spacing
tagDistance = spacing
else:
if count:
tabDistance = self.base.Length / count
tagDistance = self.base.Length / count
else:
tabDistance = self.base.Length / 4
tagDistance = self.base.Length / 4
if width:
W = width
else:
Expand All @@ -184,7 +184,7 @@ def generateTags(self, obj, count=None, width=None, height=None, angle=90, spaci
H = self.tagHeight()


# start assigning tabs on the longest segment
# start assigning tags on the longest segment
maxLen = self.longestPathEdge().Length
startIndex = 0
for i in range(0, len(self.base.Edges)):
Expand All @@ -194,55 +194,55 @@ def generateTags(self, obj, count=None, width=None, height=None, angle=90, spaci
break

startEdge = self.base.Edges[startIndex]
startCount = int(startEdge.Length / tabDistance) + 1
startCount = int(startEdge.Length / tagDistance) + 1

lastTabLength = (startEdge.Length + (startCount - 1) * tabDistance) / 2
if lastTabLength < 0 or lastTabLength > startEdge.Length:
lastTabLength = startEdge.Length / 2
lastTagLength = (startEdge.Length + (startCount - 1) * tagDistance) / 2
if lastTagLength < 0 or lastTagLength > startEdge.Length:
lastTagLength = startEdge.Length / 2
currentLength = startEdge.Length

minLength = 2. * W

#print("start index=%-2d -> count=%d (length=%.2f, distance=%.2f)" % (startIndex, startCount, startEdge.Length, tabDistance))
#print(" -> lastTabLength=%.2f)" % lastTabLength)
#print("start index=%-2d -> count=%d (length=%.2f, distance=%.2f)" % (startIndex, startCount, startEdge.Length, tagDistance))
#print(" -> lastTagLength=%.2f)" % lastTagLength)
#print(" -> currentLength=%.2f)" % currentLength)

tabs = { startIndex: startCount }
edgeDict = { startIndex: startCount }

for i in range(startIndex + 1, len(self.base.Edges)):
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):
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 = []

for (i, count) in tabs.iteritems():
for (i, count) in edgeDict.iteritems():
edge = self.base.Edges[i]
#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)
distance = (edge.LastParameter - edge.FirstParameter) / count
for j in range(0, count):
tab = edge.Curve.value((j+0.5) * distance)
tags.append(Tag(tab.x, tab.y, W, H, angle, True))
tag = edge.Curve.value((j+0.5) * distance)
tags.append(Tag(tag.x, tag.y, W, H, angle, True))

return tags

def processEdge(self, index, edge, currentLength, lastTabLength, tabDistance, minLength, tabs):
tabCount = 0
def processEdge(self, index, edge, currentLength, lastTagLength, tagDistance, minLength, edgeDict):
tagCount = 0
currentLength += edge.Length
if edge.Length > minLength:
while lastTabLength + tabDistance < currentLength:
tabCount += 1
lastTabLength += tabDistance
if tabCount > 0:
#print(" index=%d -> count=%d" % (index, tabCount))
tabs[index] = tabCount
while lastTagLength + tagDistance < currentLength:
tagCount += 1
lastTagLength += tagDistance
if tagCount > 0:
#print(" index=%d -> count=%d" % (index, tagCount))
edgeDict[index] = tagCount
#else:
#print(" skipping=%-2d (%.2f)" % (index, edge.Length))

return (currentLength, lastTabLength)
return (currentLength, lastTagLength)

def tagHeight(self):
return self.maxZ - self.minZ
Expand Down Expand Up @@ -309,7 +309,7 @@ def execute(self, obj):
for tag in tags:
tagID += 1
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)
self.fingerprint = [tag.toString() for tag in tags]
self.tags = tags
Expand All @@ -329,13 +329,13 @@ def setup(self, obj):
try:
pathData = PathData(obj)
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

## setup the object's properties, in case they're not set yet
#obj.Count = self.tabCount(obj)
#obj.Angle = self.tabAngle(obj)
#obj.Blacklist = self.tabBlacklist(obj)
#obj.Count = self.tagCount(obj)
#obj.Angle = self.tagAngle(obj)
#obj.Blacklist = self.tagBlacklist(obj)

# if the heigt isn't set, use the height of the path
#if not hasattr(obj, "Height") or not obj.Height:
Expand Down Expand Up @@ -379,7 +379,7 @@ class TaskPanel:

def __init__(self, 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"))

def reject(self):
Expand Down Expand Up @@ -437,19 +437,22 @@ def updateTags(self):
self.form.twTags.blockSignals(False)

def cleanupUI(self):
print("cleanupUI")
if debugDressup:
for obj in FreeCAD.ActiveDocument.Objects:
if obj.Name.startswith('tag'):
FreeCAD.ActiveDocument.removeObject(obj.Name)

def updateUI(self):
print("updateUI")
self.cleanupUI()
self.getFields()
if debugDressup:
FreeCAD.ActiveDocument.recompute()


def whenApplyClicked(self):
print("whenApplyClicked")
self.cleanupUI()

count = self.form.sbCount.value()
Expand All @@ -459,16 +462,20 @@ def whenApplyClicked(self):
angle = self.form.dsbAngle.value()

tags = self.obj.Proxy.generateTags(self.obj, count, width, height, angle, spacing)

self.obj.Proxy.setTags(self.obj, tags)
self.updateTags()
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()

def autoApply(self):
print("autoApply")
if self.form.cbAutoApply.checkState() == QtCore.Qt.CheckState.Checked:
self.whenApplyClicked()

def updateTagSpacing(self, count):
print("updateTagSpacing")
if count == 0:
spacing = 0
else:
Expand All @@ -478,10 +485,12 @@ def updateTagSpacing(self, count):
self.form.dsbSpacing.blockSignals(False)

def whenCountChanged(self):
print("whenCountChanged")
self.updateTagSpacing(self.form.sbCount.value())
self.autoApply()

def whenSpacingChanged(self):
print("whenSpacingChanged")
if self.form.dsbSpacing.value() == 0:
count = 0
else:
Expand All @@ -492,6 +501,7 @@ def whenSpacingChanged(self):
self.autoApply()

def whenOkClicked(self):
print("whenOkClicked")
self.whenApplyClicked()
self.form.toolBox.setCurrentWidget(self.form.tbpTags)

Expand Down Expand Up @@ -579,7 +589,7 @@ def onDelete(self, arg1=None, arg2=None):
PathUtils.addToJob(arg1.Object.Base)
return True

class CommandPathDressupHoldingTabs:
class CommandPathDressupHoldingTags:

def GetResources(self):
return {'Pixmap': 'Path-Dressup',
Expand Down Expand Up @@ -610,12 +620,12 @@ def Activated(self):

# everything ok!
FreeCAD.ActiveDocument.openTransaction(translate("PathDressup_HoldingTags", "Create HoldingTags Dress-up"))
FreeCADGui.addModule("PathScripts.PathDressupHoldingTabs")
FreeCADGui.addModule("PathScripts.PathDressupHoldingTags")
FreeCADGui.addModule("PathScripts.PathUtils")
FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "HoldingTabsDressup")')
FreeCADGui.doCommand('dbo = PathScripts.PathDressupHoldingTabs.ObjectDressup(obj)')
FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "HoldingTagsDressup")')
FreeCADGui.doCommand('dbo = PathScripts.PathDressupHoldingTags.ObjectDressup(obj)')
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('Gui.ActiveDocument.getObject(obj.Base.Name).Visibility = False')
FreeCADGui.doCommand('dbo.setup(obj)')
Expand All @@ -624,6 +634,6 @@ def Activated(self):

if FreeCAD.GuiUp:
# 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")

0 comments on commit 344250b

Please sign in to comment.