7 Module implementing the UMLItem base class. |
7 Module implementing the UMLItem base class. |
8 """ |
8 """ |
9 |
9 |
10 |
10 |
11 from PyQt5.QtCore import Qt, QSizeF |
11 from PyQt5.QtCore import Qt, QSizeF |
|
12 from PyQt5.QtGui import QColor, QPen |
12 from PyQt5.QtWidgets import QGraphicsItem, QGraphicsRectItem, QStyle |
13 from PyQt5.QtWidgets import QGraphicsItem, QGraphicsRectItem, QStyle |
13 |
14 |
14 import Preferences |
15 import Preferences |
15 |
16 |
16 |
17 |
39 """ |
40 """ |
40 Class implementing the UMLItem base class. |
41 Class implementing the UMLItem base class. |
41 """ |
42 """ |
42 ItemType = "UMLItem" |
43 ItemType = "UMLItem" |
43 |
44 |
44 def __init__(self, model=None, x=0, y=0, rounded=False, parent=None): |
45 def __init__(self, model=None, x=0, y=0, rounded=False, colors=None, |
|
46 parent=None): |
45 """ |
47 """ |
46 Constructor |
48 Constructor |
47 |
49 |
48 @param model UML model containing the item data (UMLModel) |
50 @param model UML model containing the item data |
49 @param x x-coordinate (integer) |
51 @type UMLModel |
50 @param y y-coordinate (integer) |
52 @param x x-coordinate |
51 @param rounded flag indicating a rounded corner (boolean) |
53 @type int |
52 @keyparam parent reference to the parent object (QGraphicsItem) |
54 @param y y-coordinate |
|
55 @type int |
|
56 @param rounded flag indicating a rounded corner |
|
57 @type bool |
|
58 @param colors tuple containing the foreground and background colors |
|
59 @type tuple of (QColor, QColor) |
|
60 @param parent reference to the parent object |
|
61 @type QGraphicsItem |
53 """ |
62 """ |
54 super(UMLItem, self).__init__(parent) |
63 super(UMLItem, self).__init__(parent) |
55 self.model = model |
64 self.model = model |
|
65 |
|
66 if colors is None: |
|
67 self._colors = (QColor(Qt.black), QColor(Qt.white)) |
|
68 else: |
|
69 self._colors = colors |
|
70 self.setPen(QPen(self._colors[0])) |
56 |
71 |
57 # TODO: set pen according to user selected color |
72 # TODO: set pen according to user selected color |
58 self.font = Preferences.getGraphics("Font") |
73 self.font = Preferences.getGraphics("Font") |
59 self.margin = 5 |
74 self.margin = 5 |
60 self.associations = [] |
75 self.associations = [] |