diff --git a/src/Mod/Path/Gui/Resources/panels/HoldingTagsEdit.ui b/src/Mod/Path/Gui/Resources/panels/HoldingTagsEdit.ui
index b73529606d..e70f85dc40 100644
--- a/src/Mod/Path/Gui/Resources/panels/HoldingTagsEdit.ui
+++ b/src/Mod/Path/Gui/Resources/panels/HoldingTagsEdit.ui
@@ -6,8 +6,8 @@
0
0
- 399
- 582
+ 289
+ 466
@@ -17,6 +17,12 @@
-
+
+ 0
+
+
+ 0
+
-
@@ -44,42 +50,6 @@
- -
-
-
- Auto Generate
-
-
-
-
-
-
- 2
-
-
-
- -
-
-
- false
-
-
- Replace All
-
-
-
- -
-
-
- Number of Tags
-
-
- Qt::AlignCenter
-
-
-
-
-
-
@@ -167,6 +137,54 @@
+ -
+
+
+ false
+
+
+ Copy From
+
+
+
-
+
+
+ -
+
+
+ Replace All
+
+
+
+
+
+
+ -
+
+
+ Auto Generate
+
+
+
-
+
+
+ 2
+
+
+
+ -
+
+
+ false
+
+
+ Replace All
+
+
+
+
+
+
diff --git a/src/Mod/Path/PathScripts/PathDressupHoldingTags.py b/src/Mod/Path/PathScripts/PathDressupHoldingTags.py
index 667d054eda..6c454e4415 100644
--- a/src/Mod/Path/PathScripts/PathDressupHoldingTags.py
+++ b/src/Mod/Path/PathScripts/PathDressupHoldingTags.py
@@ -36,13 +36,8 @@ from PathScripts.PathDressupTagPreferences import HoldingTagPreferences
from PathScripts.PathUtils import waiting_effects
from PySide import QtCore
-LOGLEVEL = False
-
-if LOGLEVEL:
- PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
- PathLog.trackModule()
-else:
- PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
+PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
+#PathLog.trackModule()
failures = []
@@ -144,7 +139,7 @@ class Tag:
self.isSquare = True
self.solid = Part.makeCylinder(r1, height)
radius = min(min(self.radius, r1), self.height)
- PathLog.debug("Part.makeCone(%f, %f)" % (r1, height))
+ PathLog.debug("Part.makeCylinder(%f, %f)" % (r1, height))
elif self.angle > 0.0 and height > 0.0:
# cone
rad = math.radians(self.angle)
@@ -609,9 +604,9 @@ class PathData:
else:
tagDistance = self.baseWire.Length / (count if count else 4)
- W = width if width else self.defaultTagWidth()
+ W = width if width else self.defaultTagWidth()
H = height if height else self.defaultTagHeight()
- A = angle if angle else self.defaultTagAngle()
+ A = angle if angle else self.defaultTagAngle()
R = radius if radius else self.defaultTagRadius()
# start assigning tags on the longest segment
@@ -663,6 +658,31 @@ class PathData:
return tags
+ def copyTags(self, obj, fromObj, width, height, angle, radius):
+ print("copyTags(%s, %s, %.2f, %.2f, %.2f, %.2f" % (obj.Label, fromObj.Label, width, height, angle, radius))
+ W = width if width else self.defaultTagWidth()
+ H = height if height else self.defaultTagHeight()
+ A = angle if angle else self.defaultTagAngle()
+ R = radius if radius else self.defaultTagRadius()
+
+ tags = []
+ j = 0
+ for i, pos in enumerate(fromObj.Positions):
+ print("tag[%d]" % i)
+ if not i in fromObj.Disabled:
+ dist = self.baseWire.distToShape(Part.Vertex(FreeCAD.Vector(pos.x, pos.y, self.minZ)))
+ if dist[0] < W:
+ print("tag[%d/%d]: (%.2f, %.2f, %.2f)" % (i, j, pos.x, pos.y, self.minZ))
+ at = dist[1][0][0]
+ tags.append(Tag(j, at.x, at.y, W, H, A, R, True))
+ j += 1
+ else:
+ PathLog.warning("Tag[%d] (%.2f, %.2f, %.2f) is too far away to copy: %.2f (%.2f)" % (i, pos.x, pos.y, self.minZ, dist[0], W))
+ else:
+ PathLog.info("tag[%d]: not enabled, skipping" % i)
+ print("copied %d tags" % len(tags))
+ return tags
+
def processEdge(self, index, edge, currentLength, lastTagLength, tagDistance, minLength, edgeDict):
tagCount = 0
currentLength += edge.Length
@@ -781,6 +801,18 @@ class ObjectTagDressup:
obj.Disabled = []
return False
+ def copyTags(self, obj, fromObj):
+ obj.Width = fromObj.Width
+ obj.Height = fromObj.Height
+ obj.Angle = fromObj.Angle
+ obj.Radius = fromObj.Radius
+ obj.SegmentationFactor = fromObj.SegmentationFactor
+
+ self.tags = self.pathData.copyTags(obj, fromObj, obj.Width.Value, obj.Height.Value, obj.Angle, obj.Radius.Value)
+ obj.Positions = [tag.originAt(self.pathData.minZ) for tag in self.tags]
+ obj.Disabled = []
+ return False
+
def isValidTagStartIntersection(self, edge, i):
if PathGeom.pointsCoincide(i, edge.valueAt(edge.LastParameter)):
return False
diff --git a/src/Mod/Path/PathScripts/PathDressupTagGui.py b/src/Mod/Path/PathScripts/PathDressupTagGui.py
index a14cb6c261..bc87bed323 100644
--- a/src/Mod/Path/PathScripts/PathDressupTagGui.py
+++ b/src/Mod/Path/PathScripts/PathDressupTagGui.py
@@ -191,6 +191,18 @@ class PathDressupTagTaskPanel:
self.Disabled = self.obj.Disabled
self.updateTagsView()
+ def copyNewTags(self):
+ sel = self.form.cbSource.currentText()
+ tags = [o for o in FreeCAD.ActiveDocument.Objects if sel == o.Label]
+ if 1 == len(tags):
+ if not self.obj.Proxy.copyTags(self.obj, tags[0]):
+ self.obj.Proxy.execute(self.obj)
+ self.Positions = self.obj.Positions
+ self.Disabled = self.obj.Disabled
+ self.updateTagsView()
+ else:
+ PathLog.error(translate('Path_DressupTag', 'Cannot copy tags - internal error')+'\n')
+
def updateModel(self):
self.getFields()
self.updateTagsView()
@@ -279,6 +291,15 @@ class PathDressupTagTaskPanel:
else:
self.form.cbTagGeneration.setEnabled(False)
+ enableCopy = False
+ for tags in sorted([o.Label for o in FreeCAD.ActiveDocument.Objects if 'DressupTag' in o.Name]):
+ if tags != self.obj.Label:
+ enableCopy = True
+ self.form.cbSource.addItem(tags)
+ if enableCopy:
+ self.form.gbCopy.setEnabled(True)
+ self.form.pbCopy.clicked.connect(self.copyNewTags)
+
self.form.lwTags.itemChanged.connect(self.whenTagsViewChanged)
self.form.lwTags.itemSelectionChanged.connect(self.whenTagSelectionChanged)
self.form.lwTags.itemActivated.connect(self.editTag)