Merge pull request #4911 from sliptonic/feature/nopathjob
[Path] Make Job and Operation visibility more natural
This commit is contained in:
@@ -281,12 +281,13 @@ class ObjectJob:
|
||||
|
||||
def setupOperations(self, obj):
|
||||
"""setupOperations(obj)... setup the Operations group for the Job object."""
|
||||
ops = FreeCAD.ActiveDocument.addObject(
|
||||
"Path::FeatureCompoundPython", "Operations"
|
||||
)
|
||||
# ops = FreeCAD.ActiveDocument.addObject(
|
||||
# "Path::FeatureCompoundPython", "Operations"
|
||||
# )
|
||||
ops = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroup","Operations")
|
||||
if ops.ViewObject:
|
||||
ops.ViewObject.Proxy = 0
|
||||
ops.ViewObject.Visibility = False
|
||||
# ops.ViewObject.Proxy = 0
|
||||
ops.ViewObject.Visibility = True
|
||||
|
||||
obj.Operations = ops
|
||||
obj.setEditorMode("Operations", 2) # hide
|
||||
@@ -658,7 +659,7 @@ class ObjectJob:
|
||||
|
||||
def execute(self, obj):
|
||||
if getattr(obj, "Operations", None):
|
||||
obj.Path = obj.Operations.Path
|
||||
#obj.Path = obj.Operations.Path
|
||||
self.getCycleTime()
|
||||
|
||||
def getCycleTime(self):
|
||||
@@ -708,7 +709,7 @@ class ObjectJob:
|
||||
else:
|
||||
group.append(op)
|
||||
self.obj.Operations.Group = group
|
||||
op.Path.Center = self.obj.Operations.Path.Center
|
||||
# op.Path.Center = self.obj.Operations.Path.Center
|
||||
|
||||
def nextToolNumber(self):
|
||||
# returns the next available toolnumber in the job
|
||||
@@ -848,5 +849,6 @@ def Create(name, base, templateFile=None):
|
||||
else:
|
||||
models = base
|
||||
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
|
||||
obj.addExtension("App::GroupExtensionPython")
|
||||
obj.Proxy = ObjectJob(obj, models, templateFile)
|
||||
return obj
|
||||
|
||||
@@ -241,6 +241,7 @@ class ViewProvider:
|
||||
self.obj.Stock.ViewObject.Proxy.onEdit(_OpenCloseResourceEditor)
|
||||
|
||||
def rememberBaseVisibility(self, obj, base):
|
||||
PathLog.track()
|
||||
if base.ViewObject:
|
||||
orig = PathUtil.getPublicObject(obj.Proxy.baseObject(obj, base))
|
||||
self.baseVisibility[base.Name] = (
|
||||
@@ -253,6 +254,7 @@ class ViewProvider:
|
||||
base.ViewObject.Visibility = True
|
||||
|
||||
def forgetBaseVisibility(self, obj, base):
|
||||
PathLog.track()
|
||||
if self.baseVisibility.get(base.Name):
|
||||
visibility = self.baseVisibility[base.Name]
|
||||
visibility[0].ViewObject.Visibility = visibility[1]
|
||||
@@ -260,6 +262,7 @@ class ViewProvider:
|
||||
del self.baseVisibility[base.Name]
|
||||
|
||||
def setupEditVisibility(self, obj):
|
||||
PathLog.track()
|
||||
self.baseVisibility = {}
|
||||
for base in obj.Model.Group:
|
||||
self.rememberBaseVisibility(obj, base)
|
||||
@@ -270,6 +273,7 @@ class ViewProvider:
|
||||
self.obj.Stock.ViewObject.Visibility = True
|
||||
|
||||
def resetEditVisibility(self, obj):
|
||||
PathLog.track()
|
||||
for base in obj.Model.Group:
|
||||
self.forgetBaseVisibility(obj, base)
|
||||
if obj.Stock and obj.Stock.ViewObject:
|
||||
@@ -1581,6 +1585,7 @@ def Create(base, template=None):
|
||||
try:
|
||||
obj = PathJob.Create("Job", base, template)
|
||||
obj.ViewObject.Proxy = ViewProvider(obj.ViewObject)
|
||||
obj.ViewObject.addExtension("Gui::ViewProviderGroupExtensionPython")
|
||||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
obj.Document.recompute()
|
||||
obj.ViewObject.Proxy.editObject(obj.Stock)
|
||||
|
||||
@@ -218,6 +218,11 @@ class TaskPanelPage(object):
|
||||
def _installTCUpdate(self):
|
||||
return hasattr(self.form, "toolController")
|
||||
|
||||
def setParent(self, parent):
|
||||
'''setParent() ... used to transfer parent object link to child class.
|
||||
Do not overwrite.'''
|
||||
self.parent = parent
|
||||
|
||||
def onDirtyChanged(self, callback):
|
||||
"""onDirtyChanged(callback) ... set callback when dirty state changes."""
|
||||
self.signalDirtyChanged = callback
|
||||
@@ -1166,6 +1171,7 @@ class TaskPanel(object):
|
||||
self.form = forms
|
||||
|
||||
self.selectionFactory = selectionFactory
|
||||
self.obj = obj
|
||||
self.isdirty = deleteOnReject
|
||||
self.visibility = obj.ViewObject.Visibility
|
||||
obj.ViewObject.Visibility = True
|
||||
@@ -1372,7 +1378,7 @@ def Create(res):
|
||||
obj = res.objFactory(res.name, obj=None, parentJob=res.job)
|
||||
if obj.Proxy:
|
||||
obj.ViewObject.Proxy = ViewProvider(obj.ViewObject, res)
|
||||
obj.ViewObject.Visibility = False
|
||||
obj.ViewObject.Visibility = True
|
||||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
|
||||
obj.ViewObject.Document.setEdit(obj.ViewObject, 0)
|
||||
|
||||
Reference in New Issue
Block a user