CAM: Fix Dressups icon Active state

This commit is contained in:
tarman3
2025-10-18 12:46:02 +03:00
parent 6eafca89e3
commit 478f8a0c76
14 changed files with 93 additions and 13 deletions

View File

@@ -164,6 +164,8 @@ class DressupArray:
def onChanged(self, obj, prop):
if prop == "Type":
self.setEditorModes(obj)
if prop == "Path" and obj.ViewObject:
obj.ViewObject.signalChangeIcon()
def onDocumentRestored(self, obj):
"""onDocumentRestored(obj) ... Called automatically when document is restored."""

View File

@@ -93,6 +93,10 @@ class DressupPathBoundary(object):
def loads(self, state):
return None
def onChanged(self, obj, prop):
if prop == "Path" and obj.ViewObject:
obj.ViewObject.signalChangeIcon()
def onDocumentRestored(self, obj):
self.obj = obj
if not hasattr(obj, "KeepToolDown"):

View File

@@ -275,6 +275,10 @@ class Proxy(object):
def loads(self, state):
return None
def onChanged(self, obj, prop):
if prop == "Path" and obj.ViewObject:
obj.ViewObject.signalChangeIcon()
def toolRadius(self, obj):
return PathDressup.toolController(obj.Base).Tool.Diameter.Value / 2

View File

@@ -3,6 +3,7 @@ import FreeCAD
import Path
import Path.Base.Util as PathUtil
import Path.Dressup.Array as DressupArray
import Path.Dressup.Utils as PathDressup
import Path.Main.Stock as PathStock
import PathScripts.PathUtils as PathUtils
@@ -49,6 +50,12 @@ class DressupArrayViewProvider(object):
def clearTaskPanel(self):
pass
def getIcon(self):
if getattr(PathDressup.baseOp(self.obj), "Active", True):
return ":/icons/CAM_Dressup.svg"
else:
return ":/icons/CAM_OpActive.svg"
class CommandPathDressupArray:
def GetResources(self):

View File

@@ -24,6 +24,7 @@ import Path
import math
import Path.Base.Gui.Util as PathGuiUtil
import PathScripts.PathUtils as PathUtils
import Path.Dressup.Utils as PathDressup
from PySide.QtCore import QT_TRANSLATE_NOOP
if False:
@@ -148,6 +149,8 @@ class ObjectDressup:
job = PathUtils.findParentJob(obj)
if job:
job.Proxy.setCenterOfRotation(self.center(obj))
if prop == "Path" and obj.ViewObject:
obj.ViewObject.signalChangeIcon()
def center(self, obj):
return FreeCAD.Vector(0, 0, 0 - obj.Radius.Value)
@@ -244,6 +247,12 @@ class ViewProviderDressup:
arg1.Object.Base = None
return True
def getIcon(self):
if getattr(PathDressup.baseOp(self.obj), "Active", True):
return ":/icons/CAM_Dressup.svg"
else:
return ":/icons/CAM_OpActive.svg"
class CommandPathDressup:
def GetResources(self):

View File

@@ -25,6 +25,7 @@ import FreeCAD
import FreeCADGui
import Path
import Path.Dressup.Boundary as PathDressupPathBoundary
import Path.Dressup.Utils as PathDressup
import PathGui
if False:
@@ -239,6 +240,12 @@ class DressupPathBoundaryViewProvider(object):
def clearTaskPanel(self):
self.panel = None
def getIcon(self):
if getattr(PathDressup.baseOp(self.obj), "Active", True):
return ":/icons/CAM_Dressup.svg"
else:
return ":/icons/CAM_OpActive.svg"
def Create(base, name="DressupPathBoundary"):
FreeCAD.ActiveDocument.openTransaction("Create a Boundary dressup")

View File

@@ -25,6 +25,7 @@ import FreeCAD
import FreeCADGui
import Path
import Path.Dressup.DogboneII as DogboneII
import Path.Dressup.Utils as PathDressup
import PathScripts.PathUtils as PathUtils
if False:
@@ -299,6 +300,12 @@ class ViewProviderDressup(object):
arg1.Object.Base = None
return True
def getIcon(self):
if getattr(PathDressup.baseOp(self.obj), "Active", True):
return ":/icons/CAM_Dressup.svg"
else:
return ":/icons/CAM_OpActive.svg"
def Create(base, name="DressupDogbone"):
"""

View File

@@ -25,6 +25,7 @@ import Path.Base.Gui.Util as PathGuiUtil
from PySide import QtCore
import math
import PathScripts.PathUtils as PathUtils
import Path.Dressup.Utils as PathDressup
from PySide.QtCore import QT_TRANSLATE_NOOP
# lazily loaded modules
@@ -86,6 +87,10 @@ class ObjectDressup:
def loads(self, state):
return None
def onChanged(self, obj, prop):
if prop == "Path" and obj.ViewObject:
obj.ViewObject.signalChangeIcon()
def shortcut(self, queue):
"""Determines whether its shorter to twist CW or CCW to align with
the next move"""
@@ -571,6 +576,12 @@ class ViewProviderDressup:
arg1.Object.Base = None
return True
def getIcon(self):
if getattr(PathDressup.baseOp(self.Object), "Active", True):
return ":/icons/CAM_Dressup.svg"
else:
return ":/icons/CAM_OpActive.svg"
class CommandDressupDragknife:
def GetResources(self):

View File

@@ -168,6 +168,10 @@ class ObjectDressup:
def loads(self, state):
return None
def onChanged(self, obj, prop):
if prop == "Path" and obj.ViewObject:
obj.ViewObject.signalChangeIcon()
def setup(self, obj):
obj.LeadIn = True
obj.LeadOut = True
@@ -1342,6 +1346,12 @@ class ViewProviderDressup:
def clearTaskPanel(self):
self.panel = None
def getIcon(self):
if getattr(PathDressup.baseOp(self.obj), "Active", True):
return ":/icons/CAM_Dressup.svg"
else:
return ":/icons/CAM_OpActive.svg"
class CommandPathDressupLeadInOut:
def GetResources(self):

View File

@@ -284,6 +284,8 @@ class ObjectDressup:
def onChanged(self, obj, prop):
if prop in ["RampFeedRate", "UseStartDepth"]:
self.setEditorProperties(obj)
if prop == "Path" and obj.ViewObject:
obj.ViewObject.signalChangeIcon()
def setEditorProperties(self, obj):
if hasattr(obj, "UseStartDepth"):
@@ -357,7 +359,7 @@ class ObjectDressup:
last_params.update(params)
if cmd.Name in Path.Geom.CmdMoveAll and (
not "X" in params or not "Y" in params or not "Z" in params
"X" not in params or "Y" not in params or "Z" not in params
):
params["X"] = params.get("X", start_point[0])
params["Y"] = params.get("Y", start_point[1])
@@ -757,6 +759,12 @@ class ViewProviderDressup:
def loads(self, state):
return None
def getIcon(self):
if getattr(PathDressup.baseOp(self.obj), "Active", True):
return ":/icons/CAM_Dressup.svg"
else:
return ":/icons/CAM_OpActive.svg"
class CommandPathDressupRampEntry:
def GetResources(self):

View File

@@ -28,6 +28,7 @@ import Path
import Path.Base.Gui.GetPoint as PathGetPoint
import Path.Dressup.Tags as PathDressupTag
import PathScripts.PathUtils as PathUtils
import Path.Dressup.Utils as PathDressup
if False:
@@ -528,6 +529,12 @@ class PathDressupTagViewProvider:
self.panel.selectTagWithId(i)
FreeCADGui.updateGui()
def getIcon(self):
if getattr(PathDressup.baseOp(self.obj), "Active", True):
return ":/icons/CAM_Dressup.svg"
else:
return ":/icons/CAM_OpActive.svg"
def Create(baseObject, name="DressupTag"):
"""

View File

@@ -27,6 +27,7 @@ import FreeCAD
import FreeCADGui
import Path
import PathScripts.PathUtils as PathUtils
import Path.Dressup.Utils as PathDressup
from PySide import QtGui
from PySide.QtCore import QT_TRANSLATE_NOOP
@@ -93,9 +94,11 @@ class ObjectDressup:
def loads(self, state):
return None
def onChanged(self, fp, prop):
def onChanged(self, obj, prop):
if str(prop) == "probefile":
self._loadFile(fp, fp.probefile)
self._loadFile(obj, obj.probefile)
if prop == "Path" and obj.ViewObject:
obj.ViewObject.signalChangeIcon()
def _bilinearInterpolate(self, surface, x, y):
p1 = FreeCAD.Vector(x, y, 100.0)
@@ -106,7 +109,7 @@ class ObjectDressup:
return points[0].Z
def _loadFile(self, obj, filename):
if filename == "":
if not filename:
return
f1 = open(filename, "r")
@@ -327,6 +330,12 @@ class ViewProviderDressup:
arg1.Object.Base = None
return True
def getIcon(self):
if getattr(PathDressup.baseOp(self.obj), "Active", True):
return ":/icons/CAM_Dressup.svg"
else:
return ":/icons/CAM_OpActive.svg"
class CommandPathDressup:
def GetResources(self):

View File

@@ -970,6 +970,10 @@ class ObjectTagDressup:
self.mappers = []
return None
def onChanged(self, obj, prop):
if prop == "Path" and obj.ViewObject:
obj.ViewObject.signalChangeIcon()
def onDocumentRestored(self, obj):
self.obj = obj

View File

@@ -189,15 +189,6 @@ class _ToggleOperation:
for sel in selection:
baseOp = Path.Dressup.Utils.baseOp(sel)
baseOp.Active = not baseOp.Active
if sel == baseOp:
# selected not a Dressup
baseOp.ViewObject.Visibility = baseOp.Active
elif not baseOp.Active:
# only hide operation under Dressup
baseOp.ViewObject.Visibility = False
elif baseOp.Active:
# only unhide Dressup
sel.ViewObject.Visibility = True
FreeCAD.ActiveDocument.recompute()