From 344250b5c21b5e4ad3024a2e84e211e6f979c393 Mon Sep 17 00:00:00 2001 From: ml Date: Sun, 30 Oct 2016 23:34:05 -0700 Subject: [PATCH] Renamed tabs to tags. --- src/Mod/Path/CMakeLists.txt | 3 +- src/Mod/Path/Gui/Resources/Path.qrc | 2 +- ...{HoldingTabsEdit.ui => HoldingTagsEdit.ui} | 8 +- src/Mod/Path/InitGui.py | 4 +- ...ldingTabs.py => PathDressupHoldingTags.py} | 88 +++++++++++-------- 5 files changed, 58 insertions(+), 47 deletions(-) rename src/Mod/Path/Gui/Resources/panels/{HoldingTabsEdit.ui => HoldingTagsEdit.ui} (95%) rename src/Mod/Path/PathScripts/{PathDressupHoldingTabs.py => PathDressupHoldingTags.py} (90%) diff --git a/src/Mod/Path/CMakeLists.txt b/src/Mod/Path/CMakeLists.txt index 225732aa1440..729ecf124c59 100644 --- a/src/Mod/Path/CMakeLists.txt +++ b/src/Mod/Path/CMakeLists.txt @@ -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 @@ -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 diff --git a/src/Mod/Path/Gui/Resources/Path.qrc b/src/Mod/Path/Gui/Resources/Path.qrc index 7ad296a00a18..2f635be9e800 100644 --- a/src/Mod/Path/Gui/Resources/Path.qrc +++ b/src/Mod/Path/Gui/Resources/Path.qrc @@ -90,6 +90,6 @@ panels/DogboneEdit.ui panels/DlgSelectPostProcessor.ui preferences/PathJob.ui - panels/HoldingTabsEdit.ui + panels/HoldingTagsEdit.ui diff --git a/src/Mod/Path/Gui/Resources/panels/HoldingTabsEdit.ui b/src/Mod/Path/Gui/Resources/panels/HoldingTagsEdit.ui similarity index 95% rename from src/Mod/Path/Gui/Resources/panels/HoldingTabsEdit.ui rename to src/Mod/Path/Gui/Resources/panels/HoldingTagsEdit.ui index fa2ae49bc661..465b0ad6ee87 100644 --- a/src/Mod/Path/Gui/Resources/panels/HoldingTabsEdit.ui +++ b/src/Mod/Path/Gui/Resources/panels/HoldingTagsEdit.ui @@ -131,7 +131,7 @@ - <html><head/><body><p>Width of each tab.</p></body></html> + <html><head/><body><p>Width of each tag.</p></body></html> @@ -145,7 +145,7 @@ - <html><head/><body><p>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.</p></body></html> + <html><head/><body><p>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.</p></body></html> @@ -165,7 +165,7 @@ true - <html><head/><body><p>Angle of tab walls.</p></body></html> + <html><head/><body><p>Angle of tag walls.</p></body></html> @@ -205,7 +205,7 @@ - <html><head/><body><p>Enter the number of tabs you wish to have.</p><p><br/></p><p>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.</p></body></html> + <html><head/><body><p>Enter the number of tags you wish to have.</p><p><br/></p><p>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.</p></body></html> diff --git a/src/Mod/Path/InitGui.py b/src/Mod/Path/InitGui.py index 68bc0bdc7910..4659f587ff70 100644 --- a/src/Mod/Path/InitGui.py +++ b/src/Mod/Path/InitGui.py @@ -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 @@ -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"] diff --git a/src/Mod/Path/PathScripts/PathDressupHoldingTabs.py b/src/Mod/Path/PathScripts/PathDressupHoldingTags.py similarity index 90% rename from src/Mod/Path/PathScripts/PathDressupHoldingTabs.py rename to src/Mod/Path/PathScripts/PathDressupHoldingTags.py index 4da2cd2bffef..d9dc5b9c4715 100644 --- a/src/Mod/Path/PathScripts/PathDressupHoldingTabs.py +++ b/src/Mod/Path/PathScripts/PathDressupHoldingTags.py @@ -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.") @@ -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: @@ -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)): @@ -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 @@ -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 @@ -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: @@ -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): @@ -437,12 +437,14 @@ 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: @@ -450,6 +452,7 @@ def updateUI(self): def whenApplyClicked(self): + print("whenApplyClicked") self.cleanupUI() count = self.form.sbCount.value() @@ -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: @@ -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: @@ -492,6 +501,7 @@ def whenSpacingChanged(self): self.autoApply() def whenOkClicked(self): + print("whenOkClicked") self.whenApplyClicked() self.form.toolBox.setCurrentWidget(self.form.tbpTags) @@ -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', @@ -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)') @@ -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")