Merge branch 'main' into fix-custom-attribute-edit
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
|
||||
import FreeCAD
|
||||
import Path
|
||||
import PathGui
|
||||
import importlib
|
||||
|
||||
__title__ = "CAM Icon ViewProvider"
|
||||
|
||||
@@ -28,7 +28,6 @@ import FreeCADGui
|
||||
import Path
|
||||
import Path.Base.Gui.GetPoint as PathGetPoint
|
||||
import Path.Dressup.Tags as PathDressupTag
|
||||
import PathGui
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
|
||||
|
||||
@@ -63,6 +62,7 @@ class PathDressupTagTaskPanel:
|
||||
self.jvoVisible = self.jvo.isVisible()
|
||||
if self.jvoVisible:
|
||||
self.jvo.hide()
|
||||
self.obj.ViewObject.show()
|
||||
else:
|
||||
self.jvoVisible = jvoVisibility
|
||||
self.pt = FreeCAD.Vector(0, 0, 0)
|
||||
@@ -452,7 +452,7 @@ class PathDressupTagViewProvider:
|
||||
tags = []
|
||||
for i, p in enumerate(positions):
|
||||
tag = HoldingTagMarker(self.obj.Proxy.pointAtBottom(self.obj, p), self.colors)
|
||||
tag.setEnabled(not i in disabled)
|
||||
tag.setEnabled(i not in disabled)
|
||||
tags.append(tag)
|
||||
self.switch.addChild(tag.sep)
|
||||
self.tags = tags
|
||||
@@ -524,7 +524,7 @@ class PathDressupTagViewProvider:
|
||||
|
||||
def addSelection(self, doc, obj, sub, point):
|
||||
Path.Log.track(doc, obj, sub, point)
|
||||
if self.panel:
|
||||
if hasattr(self, "panel") and self.panel:
|
||||
i = self.tagAtPoint(point, sub is None)
|
||||
self.panel.selectTagWithId(i)
|
||||
FreeCADGui.updateGui()
|
||||
|
||||
@@ -49,7 +49,7 @@ def debugEdge(edge, prefix, force=False):
|
||||
if force or Path.Log.getLevel(Path.Log.thisModule()) == Path.Log.Level.DEBUG:
|
||||
pf = edge.valueAt(edge.FirstParameter)
|
||||
pl = edge.valueAt(edge.LastParameter)
|
||||
if type(edge.Curve) == Part.Line or type(edge.Curve) == Part.LineSegment:
|
||||
if type(edge.Curve) in [Part.Line, Part.LineSegment]:
|
||||
print(
|
||||
"%s %s((%.2f, %.2f, %.2f) - (%.2f, %.2f, %.2f))"
|
||||
% (prefix, type(edge.Curve), pf.x, pf.y, pf.z, pl.x, pl.y, pl.z)
|
||||
@@ -197,17 +197,13 @@ class Tag:
|
||||
self.solid = self.solid.makeFillet(radius, [self.solid.Edges[0]])
|
||||
|
||||
def filterIntersections(self, pts, face):
|
||||
if (
|
||||
type(face.Surface) == Part.Cone
|
||||
or type(face.Surface) == Part.Cylinder
|
||||
or type(face.Surface) == Part.Toroid
|
||||
):
|
||||
if type(face.Surface) in [Part.Cone, Part.Cylinder, Part.Toroid]:
|
||||
Path.Log.track("it's a cone/cylinder, checking z")
|
||||
return list([pt for pt in pts if pt.z >= self.bottom() and pt.z <= self.top()])
|
||||
if type(face.Surface) == Part.Plane:
|
||||
if type(face.Surface) is Part.Plane:
|
||||
Path.Log.track("it's a plane, checking R")
|
||||
c = face.Edges[0].Curve
|
||||
if type(c) == Part.Circle:
|
||||
if type(c) is Part.Circle:
|
||||
return list(
|
||||
[
|
||||
pt
|
||||
@@ -457,13 +453,13 @@ class MapWireToTag:
|
||||
break
|
||||
elif Path.Geom.pointsCoincide(p2, p0):
|
||||
flipped = Path.Geom.flipEdge(e)
|
||||
if not flipped is None:
|
||||
if flipped is not None:
|
||||
outputEdges.append((flipped, True))
|
||||
else:
|
||||
p0 = None
|
||||
cnt = 0
|
||||
for p in reversed(e.discretize(Deflection=0.01)):
|
||||
if not p0 is None:
|
||||
if p0 is not None:
|
||||
outputEdges.append((Part.Edge(Part.LineSegment(p0, p)), True))
|
||||
cnt = cnt + 1
|
||||
p0 = p
|
||||
@@ -623,7 +619,7 @@ class _RapidEdges:
|
||||
self.rapid = rapid
|
||||
|
||||
def isRapid(self, edge):
|
||||
if type(edge.Curve) == Part.Line or type(edge.Curve) == Part.LineSegment:
|
||||
if type(edge.Curve) in [Part.Line, Part.LineSegment]:
|
||||
v0 = edge.Vertexes[0]
|
||||
v1 = edge.Vertexes[1]
|
||||
for r in self.rapid:
|
||||
@@ -790,7 +786,7 @@ class PathData:
|
||||
j = 0
|
||||
for i, pos in enumerate(fromObj.Positions):
|
||||
print("tag[%d]" % i)
|
||||
if not i in fromObj.Disabled:
|
||||
if i not in fromObj.Disabled:
|
||||
dist = self.baseWire.distToShape(
|
||||
Part.Vertex(FreeCAD.Vector(pos.x, pos.y, self.minZ))
|
||||
)
|
||||
@@ -1038,9 +1034,7 @@ class ObjectTagDressup:
|
||||
commands = []
|
||||
lastEdge = 0
|
||||
lastTag = 0
|
||||
# sameTag = None
|
||||
t = 0
|
||||
# inters = None
|
||||
edge = None
|
||||
|
||||
segm = 50
|
||||
@@ -1065,7 +1059,6 @@ class ObjectTagDressup:
|
||||
edge = pathData.edges[lastEdge]
|
||||
debugEdge(edge, "======= new edge: %d/%d" % (lastEdge, len(pathData.edges)))
|
||||
lastEdge += 1
|
||||
# sameTag = None
|
||||
|
||||
if mapper:
|
||||
mapper.add(edge)
|
||||
@@ -1136,7 +1129,7 @@ class ObjectTagDressup:
|
||||
obj.Height.Value,
|
||||
obj.Angle,
|
||||
obj.Radius,
|
||||
not i in disabledIn,
|
||||
i not in disabledIn,
|
||||
)
|
||||
tag.createSolidsAt(self.pathData.minZ, self.toolRadius)
|
||||
rawTags.append(tag)
|
||||
|
||||
@@ -88,17 +88,17 @@ class GuiImageBuilder(ImageBuilder):
|
||||
def prepare_view(self, obj):
|
||||
# Create a new view
|
||||
Path.Log.debug("CAM - Preparing view\n")
|
||||
FreeCADGui.runCommand("Std_ViewCreate", 0)
|
||||
|
||||
# Get the activeview and configure it
|
||||
aview = FreeCADGui.ActiveDocument.ActiveView
|
||||
aview.setAnimationEnabled(False)
|
||||
aview.viewIsometric()
|
||||
|
||||
FreeCADGui.SendMsgToActiveView("PerspectiveCamera")
|
||||
|
||||
# resize the window
|
||||
mw = FreeCADGui.getMainWindow()
|
||||
num_windows = len(mw.getWindows())
|
||||
|
||||
# Create and configure the view
|
||||
view = FreeCADGui.ActiveDocument.createView("Gui::View3DInventor")
|
||||
view.setAnimationEnabled(False)
|
||||
view.viewIsometric()
|
||||
view.setCameraType("Perspective")
|
||||
|
||||
# Resize the window
|
||||
mdi = mw.findChild(QtGui.QMdiArea)
|
||||
view_window = mdi.activeSubWindow()
|
||||
view_window.resize(500, 500)
|
||||
@@ -109,17 +109,19 @@ class GuiImageBuilder(ImageBuilder):
|
||||
self.record_visibility()
|
||||
obj.Visibility = True
|
||||
|
||||
# Return the index of the new window (= old number of windows)
|
||||
return num_windows
|
||||
|
||||
def record_visibility(self):
|
||||
self.visible = [o for o in self.doc.Document.Objects if o.Visibility]
|
||||
for o in self.doc.Document.Objects:
|
||||
o.Visibility = False
|
||||
|
||||
def destroy_view(self):
|
||||
def destroy_view(self, idx):
|
||||
Path.Log.debug("CAM - destroying view\n")
|
||||
mw = FreeCADGui.getMainWindow()
|
||||
windows = mw.getWindows()
|
||||
toRemove = windows[1]
|
||||
mw.removeWindow(toRemove)
|
||||
mw.removeWindow(windows[idx])
|
||||
|
||||
def restore_visibility(self):
|
||||
Path.Log.debug("CAM - Restoring visibility\n")
|
||||
@@ -134,10 +136,10 @@ class GuiImageBuilder(ImageBuilder):
|
||||
|
||||
file_path = os.path.join(self.file_path, image_name)
|
||||
|
||||
self.prepare_view(obj)
|
||||
idx = self.prepare_view(obj)
|
||||
|
||||
self.capture_image(file_path)
|
||||
self.destroy_view()
|
||||
self.destroy_view(idx)
|
||||
|
||||
result = f"{file_path}_t.png"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user