Assembly: Make ExplodedView: a group extension. So that we don't mimick group. Fixing the delete exploded view group issue
This commit is contained in:
committed by
Chris Hennes
parent
18f63edadb
commit
b29f2cdfe2
@@ -83,13 +83,20 @@ class CommandCreateView:
|
||||
######### Exploded View Object ###########
|
||||
class ExplodedView:
|
||||
def __init__(self, expView):
|
||||
expView.addProperty(
|
||||
"App::PropertyLinkList", "Moves", "Exploded View", "Move objects of the exploded view."
|
||||
)
|
||||
expView.Proxy = self
|
||||
expView.addExtension("App::GroupExtensionPython")
|
||||
|
||||
self.stepsChangedCallback = None
|
||||
|
||||
def onDocumentRestored(self, expView):
|
||||
self.migrationScript(expView)
|
||||
|
||||
def migrationScript(self, expView):
|
||||
if hasattr(expView, "Moves"):
|
||||
expView.addExtension("App::GroupExtensionPython")
|
||||
expView.Group = expView.Moves
|
||||
expView.removeProperty("Moves")
|
||||
|
||||
def dumps(self):
|
||||
return None
|
||||
|
||||
@@ -97,7 +104,7 @@ class ExplodedView:
|
||||
return None
|
||||
|
||||
def onChanged(self, viewObj, prop):
|
||||
if prop == "Moves" and hasattr(self, "stepsChangedCallback"):
|
||||
if prop == "Group" and hasattr(self, "stepsChangedCallback"):
|
||||
if self.stepsChangedCallback is not None:
|
||||
self.stepsChangedCallback()
|
||||
|
||||
@@ -113,7 +120,7 @@ class ExplodedView:
|
||||
positions = [] # [[p1start, p1end], [p2start, p2end], ...]
|
||||
if com is None:
|
||||
com, size = UtilsAssembly.getComAndSize(self.getAssembly(viewObj))
|
||||
for move in viewObj.Moves:
|
||||
for move in viewObj.Group:
|
||||
positions = positions + move.Proxy.applyStep(move, com, size)
|
||||
|
||||
return positions
|
||||
@@ -192,7 +199,7 @@ class ViewProviderExplodedView:
|
||||
return None
|
||||
|
||||
def claimChildren(self):
|
||||
return self.app_obj.Moves
|
||||
return self.app_obj.Group
|
||||
|
||||
def doubleClicked(self, vobj):
|
||||
task = Gui.Control.activeTaskDialog()
|
||||
@@ -442,7 +449,7 @@ class ExplodedViewSelGate:
|
||||
# Objects within the assembly.
|
||||
return True
|
||||
|
||||
if obj in self.viewObj.Moves:
|
||||
if obj in self.viewObj.Group:
|
||||
# Enable selection of steps object
|
||||
return True
|
||||
|
||||
@@ -495,7 +502,7 @@ class TaskAssemblyCreateView(QtCore.QObject):
|
||||
if viewObj:
|
||||
App.setActiveTransaction("Edit Exploded View")
|
||||
self.viewObj = viewObj
|
||||
for move in self.viewObj.Moves:
|
||||
for move in self.viewObj.Group:
|
||||
move.Visibility = True
|
||||
self.onMovesChanged()
|
||||
|
||||
@@ -524,10 +531,10 @@ class TaskAssemblyCreateView(QtCore.QObject):
|
||||
def accept(self):
|
||||
self.deactivate()
|
||||
UtilsAssembly.restoreAssemblyPartsPlacements(self.assembly, self.initialPlcs)
|
||||
for move in self.viewObj.Moves:
|
||||
for move in self.viewObj.Group:
|
||||
move.Visibility = False
|
||||
commands = ""
|
||||
for move in self.viewObj.Moves:
|
||||
for move in self.viewObj.Group:
|
||||
more = UtilsAssembly.generatePropertySettings(move)
|
||||
commands = commands + more
|
||||
Gui.doCommand(commands[:-1]) # Don't use the last \n
|
||||
@@ -634,7 +641,7 @@ class TaskAssemblyCreateView(QtCore.QObject):
|
||||
self.viewObj.Proxy.applyMoves(self.viewObj, self.com, self.size)
|
||||
|
||||
self.form.stepList.clear()
|
||||
for move in self.viewObj.Moves:
|
||||
for move in self.viewObj.Group:
|
||||
self.form.stepList.addItem(move.Name)
|
||||
|
||||
def onItemClicked(self, item):
|
||||
@@ -733,10 +740,10 @@ class TaskAssemblyCreateView(QtCore.QObject):
|
||||
listOfSubs.append(ref[1][0])
|
||||
self.currentStep.References = [self.selectedRefs[0][0], listOfSubs]
|
||||
|
||||
# Note: self.viewObj.Moves.append(self.currentStep) does not work
|
||||
listOfMoves = self.viewObj.Moves
|
||||
# Note: self.viewObj.Group.append(self.currentStep) does not work
|
||||
listOfMoves = self.viewObj.Group
|
||||
listOfMoves.append(self.currentStep)
|
||||
self.viewObj.Moves = listOfMoves
|
||||
self.viewObj.Group = listOfMoves
|
||||
|
||||
def dismissCurrentStep(self):
|
||||
if self.currentStep is None:
|
||||
@@ -844,10 +851,10 @@ class TaskAssemblyCreateView(QtCore.QObject):
|
||||
sorted_indexes = sorted(selected_indexes, key=lambda x: x.row(), reverse=True)
|
||||
for index in sorted_indexes:
|
||||
row = index.row()
|
||||
if row < len(self.viewObj.Moves):
|
||||
move = self.viewObj.Moves[row]
|
||||
if row < len(self.viewObj.Group):
|
||||
move = self.viewObj.Group[row]
|
||||
# First remove the link from the viewObj
|
||||
self.viewObj.Moves.remove(move)
|
||||
self.viewObj.Group.remove(move)
|
||||
# Delete the object
|
||||
move.Document.removeObject(move.Name)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user