--- a/eric6/Graphics/UMLGraphicsView.py Wed May 05 17:29:41 2021 +0200 +++ b/eric6/Graphics/UMLGraphicsView.py Wed May 05 18:17:24 2021 +0200 @@ -806,3 +806,35 @@ self.scene().addItem(assoc) return True, -1 + + def toDict(self): + """ + Public method to collect data to be persisted. + + @return dictionary containing data to be persisted + @rtype dict + """ + items = [] + for item in self.filteredItems(self.scene().items(), UMLItem): + items.append({ + "id": item.getId(), + "x": item.x(), + "y": item.y(), + "type": item.getItemType(), + "data": item.toDict() + }) + + from .AssociationItem import AssociationItem + associations = [ + assoc.toDict() + for assoc in self.filteredItems(self.scene().items(), + AssociationItem) + ] + + data = { + "diagram_name": self.diagramName, + "items": items, + "associations": associations, + } + + return data