src/eric7/Graphics/UMLGraphicsView.py

branch
eric7
changeset 10922
36a90a94765c
parent 10917
4f40180b98dc
child 11006
a671918232f3
--- a/src/eric7/Graphics/UMLGraphicsView.py	Mon Sep 23 14:37:31 2024 +0200
+++ b/src/eric7/Graphics/UMLGraphicsView.py	Tue Sep 24 17:52:41 2024 +0200
@@ -54,7 +54,12 @@
         @param parent parent widget of the view
         @type QWidget
         """
-        EricGraphicsView.__init__(self, scene, parent)
+        EricGraphicsView.__init__(
+            self,
+            scene,
+            drawingMode=Preferences.getGraphics("DrawingMode"),
+            parent=parent,
+        )
         self.setObjectName("UMLGraphicsView")
         self.setViewportUpdateMode(QGraphicsView.ViewportUpdateMode.FullViewportUpdate)
 
@@ -467,7 +472,16 @@
 
         printDialog = QPrintDialog(printer, self)
         if printDialog.exec():
-            super().printDiagram(printer, self.diagramName)
+            super().printDiagram(
+                printer,
+                margins=QMarginsF(
+                    Preferences.getPrinter("LeftMargin"),
+                    Preferences.getPrinter("TopMargin"),
+                    Preferences.getPrinter("RightMargin"),
+                    Preferences.getPrinter("BottomMargin"),
+                ),
+                diagramName=self.diagramName,
+            )
 
     def printPreviewDiagram(self):
         """
@@ -507,7 +521,16 @@
         @param printer reference to the printer object
         @type QPrinter
         """
-        super().printDiagram(printer, self.diagramName)
+        super().printDiagram(
+            printer,
+            margins=QMarginsF(
+                Preferences.getPrinter("LeftMargin"),
+                Preferences.getPrinter("TopMargin"),
+                Preferences.getPrinter("RightMargin"),
+                Preferences.getPrinter("BottomMargin"),
+            ),
+            diagramName=self.diagramName,
+        )
 
     def setDiagramName(self, name):
         """
@@ -762,6 +785,9 @@
             return False, 0
         self.diagramName = data[0].split(": ", 1)[1].strip()
 
+        colors = self.getDrawingColors(
+            drawingMode=Preferences.getGraphics("DrawingMode")
+        )
         for linenum, line in enumerate(data[1:], start=1):
             if not line.startswith(("item:", "association:")):
                 return False, linenum
@@ -775,17 +801,11 @@
                     y = float(y.split("=", 1)[1].strip())
                     itemType = itemType.split("=", 1)[1].strip()
                     if itemType == ClassItem.ItemType:
-                        itm = ClassItem(
-                            x=0, y=0, scene=self.scene(), colors=self.getDrawingColors()
-                        )
+                        itm = ClassItem(x=0, y=0, scene=self.scene(), colors=colors)
                     elif itemType == ModuleItem.ItemType:
-                        itm = ModuleItem(
-                            x=0, y=0, scene=self.scene(), colors=self.getDrawingColors()
-                        )
+                        itm = ModuleItem(x=0, y=0, scene=self.scene(), colors=colors)
                     elif itemType == PackageItem.ItemType:
-                        itm = PackageItem(
-                            x=0, y=0, scene=self.scene(), colors=self.getDrawingColors()
-                        )
+                        itm = PackageItem(x=0, y=0, scene=self.scene(), colors=colors)
                     itm.setPos(x, y)
                     itm.setId(itemId)
                     umlItems[itemId] = itm
@@ -849,26 +869,27 @@
         from .UMLItem import UMLItem
 
         umlItems = {}
+        colors = self.getDrawingColors(
+            drawingMode=Preferences.getGraphics("DrawingMode")
+        )
 
         try:
             self.diagramName = data["diagram_name"]
             for itemData in data["items"]:
                 if itemData["type"] == UMLItem.ItemType:
-                    itm = UMLItem.fromDict(itemData, colors=self.getDrawingColors())
+                    itm = UMLItem.fromDict(itemData, colors=colors)
                 elif itemData["type"] == ClassItem.ItemType:
-                    itm = ClassItem.fromDict(itemData, colors=self.getDrawingColors())
+                    itm = ClassItem.fromDict(itemData, colors=colors)
                 elif itemData["type"] == ModuleItem.ItemType:
-                    itm = ModuleItem.fromDict(itemData, colors=self.getDrawingColors())
+                    itm = ModuleItem.fromDict(itemData, colors=colors)
                 elif itemData["type"] == PackageItem.ItemType:
-                    itm = PackageItem.fromDict(itemData, colors=self.getDrawingColors())
+                    itm = PackageItem.fromDict(itemData, colors=colors)
                 if itm is not None:
                     umlItems[itm.getId()] = itm
                     self.scene().addItem(itm)
 
             for assocData in data["associations"]:
-                assoc = AssociationItem.fromDict(
-                    assocData, umlItems, colors=self.getDrawingColors()
-                )
+                assoc = AssociationItem.fromDict(assocData, umlItems, colors=colors)
                 self.scene().addItem(assoc)
 
             return True

eric ide

mercurial