Merge pull request #21128 from jffmichi/fix_array_dressup
CAM: bring Array dressup in line with existing dressups
This commit is contained in:
@@ -60,7 +60,6 @@ SET(PathPythonDressup_SRCS
|
||||
Path/Dressup/__init__.py
|
||||
Path/Dressup/Utils.py
|
||||
Path/Dressup/Array.py
|
||||
Path/Dressup/Base.py
|
||||
Path/Dressup/Boundary.py
|
||||
Path/Dressup/DogboneII.py
|
||||
Path/Dressup/Tags.py
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
import FreeCAD
|
||||
import Path
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
from Path.Dressup.Base import DressupBase
|
||||
import Path.Dressup.Utils as PathDressup
|
||||
import random
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
|
||||
@@ -33,10 +33,14 @@ __doc__ = """CAM Array dressup"""
|
||||
translate = FreeCAD.Qt.translate
|
||||
|
||||
|
||||
class DressupArray(DressupBase):
|
||||
class DressupArray:
|
||||
def __init__(self, obj, base, job):
|
||||
super().__init__(obj, base)
|
||||
|
||||
obj.addProperty(
|
||||
"App::PropertyLink",
|
||||
"Base",
|
||||
"Path",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The base toolpath to modify"),
|
||||
)
|
||||
obj.addProperty(
|
||||
"App::PropertyEnumeration",
|
||||
"Type",
|
||||
@@ -119,7 +123,6 @@ class DressupArray(DressupBase):
|
||||
self.obj = obj
|
||||
obj.Base = base
|
||||
|
||||
obj.Active = True
|
||||
# assigning array tells the type of possible enum choices
|
||||
obj.Type = ["Linear1D", "Linear2D", "Polar"]
|
||||
# assign value
|
||||
@@ -178,14 +181,14 @@ class DressupArray(DressupBase):
|
||||
obj.Base = None
|
||||
return True
|
||||
|
||||
def dressupExecute(self, obj):
|
||||
def execute(self, obj):
|
||||
|
||||
if not obj.Base or not obj.Base.isDerivedFrom("Path::Feature") or not obj.Base.Path:
|
||||
Path.Log.error(translate("PathArray", "Base is empty or an invalid object."))
|
||||
return None
|
||||
|
||||
# Do not generate paths and clear current Path data if operation not active
|
||||
if not obj.Active:
|
||||
if not PathDressup.baseOp(obj.Base).Active:
|
||||
if obj.Path:
|
||||
obj.Path = Path.Path()
|
||||
return
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
|
||||
from Path.Op.Base import ObjectOp
|
||||
|
||||
|
||||
class DressupBase:
|
||||
"""
|
||||
Base class for all dressups to provide common interface with the rest of CAM
|
||||
One major example is making sure all dressups export base operation settings
|
||||
like coolant, tool controller, etc.
|
||||
"""
|
||||
|
||||
def setup_coolant_property(self, obj):
|
||||
if not hasattr(obj, "CoolantMode"):
|
||||
obj.addProperty(
|
||||
"App::PropertyEnumeration",
|
||||
"CoolantMode",
|
||||
"CoolantMode",
|
||||
QT_TRANSLATE_NOOP("App::Property", "Default coolant mode."),
|
||||
)
|
||||
|
||||
for n in ObjectOp.opPropertyEnumerations():
|
||||
if n[0] == "CoolantMode":
|
||||
setattr(obj, n[0], n[1])
|
||||
|
||||
def setup_tool_controller_property(self, obj):
|
||||
if not hasattr(obj, "ToolController"):
|
||||
obj.addProperty(
|
||||
"App::PropertyLink",
|
||||
"ToolController",
|
||||
"Path",
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"The tool controller that will be used to calculate the path",
|
||||
),
|
||||
)
|
||||
|
||||
def __init__(self, obj, base):
|
||||
|
||||
obj.addProperty(
|
||||
"App::PropertyLink",
|
||||
"Base",
|
||||
"Base",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The base path to modify"),
|
||||
)
|
||||
|
||||
obj.addProperty(
|
||||
"App::PropertyBool",
|
||||
"Active",
|
||||
"Path",
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property", "Make False, to prevent operation from generating code"
|
||||
),
|
||||
)
|
||||
|
||||
self.setup_coolant_property(obj)
|
||||
self.setup_tool_controller_property(obj)
|
||||
|
||||
def onDocumentRestored(self, obj):
|
||||
"""
|
||||
Called then document is being restored. Often used for object migrations,
|
||||
adding missing properties, etc.
|
||||
Do not overwrite - child classes should use dressupOnDocumentRestored().
|
||||
"""
|
||||
self.setup_coolant_property(obj)
|
||||
self.setup_tool_controller_property(obj)
|
||||
|
||||
def dressupOnDocumentRestored(self, obj):
|
||||
"""Overwrite this method for custom handling."""
|
||||
pass
|
||||
|
||||
def execute(self, obj):
|
||||
"""
|
||||
Export common properties from base object and
|
||||
run dressupExecute()
|
||||
"""
|
||||
|
||||
if hasattr(obj, "Base") and hasattr(obj.Base, "CoolantMode"):
|
||||
obj.CoolantMode = obj.Base.CoolantMode
|
||||
|
||||
if hasattr(obj, "Base") and hasattr(obj.Base, "ToolController"):
|
||||
obj.ToolController = obj.Base.ToolController
|
||||
|
||||
return self.dressupExecute(obj)
|
||||
|
||||
def dressupExecute(self, obj):
|
||||
"""
|
||||
Called whenever receiver should be recalculated.
|
||||
Should be overwritten by subclasses.
|
||||
"""
|
||||
pass
|
||||
Reference in New Issue
Block a user