eric6/Graphics/UMLDiagramBuilder.py

Sat, 11 Apr 2020 14:13:25 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 11 Apr 2020 14:13:25 +0200
changeset 7522
e0e05a1b576f
parent 7360
9190402e4505
child 7780
41420f82c0ac
permissions
-rw-r--r--

Styles: added some Qt style sheets and some highlighter styles.

2031
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
3 # Copyright (c) 2012 - 2020 Detlev Offenbach <detlev@die-offenbachs.de>
2031
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the UML diagram builder base class.
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
10
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
11 from PyQt5.QtCore import QObject
2031
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 class UMLDiagramBuilder(QObject):
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 """
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 Class implementing the UML diagram builder base class.
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 """
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 def __init__(self, dialog, view, project):
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 Constructor
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 @param dialog reference to the UML dialog (UMLDialog)
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 @param view reference to the view object (UMLGraphicsView)
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 @param project reference to the project object (Project)
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
26 super(UMLDiagramBuilder, self).__init__(dialog)
2031
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 self.umlView = view
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 self.scene = self.umlView.scene()
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 self.project = project
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
2033
4b99609f6a87 Some more refactorings to prepare loading graphics diagrams from file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
32 def initialize(self):
4b99609f6a87 Some more refactorings to prepare loading graphics diagrams from file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
33 """
4b99609f6a87 Some more refactorings to prepare loading graphics diagrams from file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
34 Public method to initialize the object.
4b99609f6a87 Some more refactorings to prepare loading graphics diagrams from file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
35 """
4b99609f6a87 Some more refactorings to prepare loading graphics diagrams from file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
36 return
4b99609f6a87 Some more refactorings to prepare loading graphics diagrams from file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
37
2031
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 def buildDiagram(self):
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 """
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 Public method to build the diagram.
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 This class must be implemented in subclasses.
2953
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
43
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
44 @exception NotImplementedError raised to indicate that this class
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
45 must be subclassed
2031
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 """
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 raise NotImplementedError(
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 "Method 'buildDiagram' must be implemented in subclasses.")
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
2033
4b99609f6a87 Some more refactorings to prepare loading graphics diagrams from file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
50 def getPersistenceData(self):
4b99609f6a87 Some more refactorings to prepare loading graphics diagrams from file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
51 """
4b99609f6a87 Some more refactorings to prepare loading graphics diagrams from file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
52 Public method to get a string for data to be persisted.
4b99609f6a87 Some more refactorings to prepare loading graphics diagrams from file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
53
4b99609f6a87 Some more refactorings to prepare loading graphics diagrams from file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
54 @return persisted data string (string)
4b99609f6a87 Some more refactorings to prepare loading graphics diagrams from file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
55 """
4b99609f6a87 Some more refactorings to prepare loading graphics diagrams from file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
56 return ""
4b99609f6a87 Some more refactorings to prepare loading graphics diagrams from file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2031
diff changeset
57
2034
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
58 def parsePersistenceData(self, version, data):
2031
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 """
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 Public method to parse persisted data.
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61
2034
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
62 @param version version of the data (string)
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
63 @param data persisted data to be parsed (string)
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
64 @return flag indicating success (boolean)
2031
c36c2eb62a75 Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 """
2034
8de0fc1f7fef Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2033
diff changeset
66 return True

eric ide

mercurial