A few fixes for issues with the graphics dialogs.

Sat, 08 Sep 2012 17:36:14 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 08 Sep 2012 17:36:14 +0200
changeset 2027
144463496a54
parent 2026
18f2b30ed046
child 2028
30247d523fdb

A few fixes for issues with the graphics dialogs.

APIs/Python3/eric5.api file | annotate | diff | comparison | revisions
Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
Documentation/Source/eric5.E5Graphics.E5GraphicsView.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Graphics.ApplicationDiagram.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Graphics.ImportsDiagram.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Graphics.PackageDiagram.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Graphics.UMLClassDiagram.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Graphics.UMLDialog.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Graphics.UMLGraphicsView.html file | annotate | diff | comparison | revisions
E5Graphics/E5GraphicsView.py file | annotate | diff | comparison | revisions
Graphics/ApplicationDiagram.py file | annotate | diff | comparison | revisions
Graphics/ImportsDiagram.py file | annotate | diff | comparison | revisions
Graphics/PackageDiagram.py file | annotate | diff | comparison | revisions
Graphics/UMLClassDiagram.py file | annotate | diff | comparison | revisions
Graphics/UMLDialog.py file | annotate | diff | comparison | revisions
Graphics/UMLGraphicsView.py file | annotate | diff | comparison | revisions
--- a/APIs/Python3/eric5.api	Sat Sep 08 13:02:43 2012 +0200
+++ b/APIs/Python3/eric5.api	Sat Sep 08 17:36:14 2012 +0200
@@ -1127,6 +1127,7 @@
 eric5.E5Graphics.E5ArrowItem.WideArrow?7
 eric5.E5Graphics.E5GraphicsView.E5GraphicsView._getDiagramRect?5(border=0)
 eric5.E5Graphics.E5GraphicsView.E5GraphicsView._getDiagramSize?5(border=0)
+eric5.E5Graphics.E5GraphicsView.E5GraphicsView.autoAdjustSceneSize?4(limit=False)
 eric5.E5Graphics.E5GraphicsView.E5GraphicsView.filteredItems?4(items)
 eric5.E5Graphics.E5GraphicsView.E5GraphicsView.printDiagram?4(printer, diagramName="")
 eric5.E5Graphics.E5GraphicsView.E5GraphicsView.resizeScene?4(amount, isWidth=True)
@@ -1615,7 +1616,6 @@
 eric5.Globals.settingsNameOrganization?7
 eric5.Globals.settingsNameRecent?7
 eric5.Graphics.ApplicationDiagram.ApplicationDiagram.relayout?4()
-eric5.Graphics.ApplicationDiagram.ApplicationDiagram.show?4()
 eric5.Graphics.ApplicationDiagram.ApplicationDiagram?1(project, parent=None, name=None, noModules=False)
 eric5.Graphics.AssociationItem.AssociationItem.unassociate?4()
 eric5.Graphics.AssociationItem.AssociationItem.widgetMoved?4()
@@ -1646,7 +1646,6 @@
 eric5.Graphics.GraphicsUtilities._buildChildrenLists?5(routes)
 eric5.Graphics.GraphicsUtilities.sort?4(nodes, routes, noRecursion=False)
 eric5.Graphics.ImportsDiagram.ImportsDiagram.relayout?4()
-eric5.Graphics.ImportsDiagram.ImportsDiagram.show?4()
 eric5.Graphics.ImportsDiagram.ImportsDiagram?1(project, package, parent=None, name=None, showExternalImports=False)
 eric5.Graphics.ModuleItem.ModuleItem.paint?4(painter, option, widget=None)
 eric5.Graphics.ModuleItem.ModuleItem.setModel?4(model)
@@ -1656,7 +1655,6 @@
 eric5.Graphics.ModuleItem.ModuleModel.getName?4()
 eric5.Graphics.ModuleItem.ModuleModel?1(name, classlist=[])
 eric5.Graphics.PackageDiagram.PackageDiagram.relayout?4()
-eric5.Graphics.PackageDiagram.PackageDiagram.show?4()
 eric5.Graphics.PackageDiagram.PackageDiagram?1(project, package, parent=None, name=None, noAttrs=False)
 eric5.Graphics.PackageItem.PackageItem.paint?4(painter, option, widget=None)
 eric5.Graphics.PackageItem.PackageItem.setModel?4(model)
@@ -1677,10 +1675,11 @@
 eric5.Graphics.SvgDiagram.SvgDiagram.wheelEvent?4(evt)
 eric5.Graphics.SvgDiagram.SvgDiagram?1(svgFile, parent=None, name=None)
 eric5.Graphics.UMLClassDiagram.UMLClassDiagram.relayout?4()
-eric5.Graphics.UMLClassDiagram.UMLClassDiagram.show?4()
 eric5.Graphics.UMLClassDiagram.UMLClassDiagram?1(project, file, parent=None, name=None, noAttrs=False)
 eric5.Graphics.UMLDialog.UMLDialog.setDiagramName?4(name)
-eric5.Graphics.UMLDialog.UMLDialog?1(diagramName="Unnamed", parent=None, name=None)
+eric5.Graphics.UMLDialog.UMLDialog.show?4()
+eric5.Graphics.UMLDialog.UMLDialog?1(buildFunction=None, diagramName="Unnamed", parent=None, name=None)
+eric5.Graphics.UMLGraphicsView.UMLGraphicsView.autoAdjustSceneSize?4(limit=False)
 eric5.Graphics.UMLGraphicsView.UMLGraphicsView.event?4(evt)
 eric5.Graphics.UMLGraphicsView.UMLGraphicsView.filteredItems?4(items)
 eric5.Graphics.UMLGraphicsView.UMLGraphicsView.gestureEvent?4(evt)
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Help/source.qhp	Sat Sep 08 13:02:43 2012 +0200
+++ b/Documentation/Help/source.qhp	Sat Sep 08 17:36:14 2012 +0200
@@ -1280,7 +1280,6 @@
       <keyword name="ApplicationDiagram.__buildPackages" id="ApplicationDiagram.__buildPackages" ref="eric5.Graphics.ApplicationDiagram.html#ApplicationDiagram.__buildPackages" />
       <keyword name="ApplicationDiagram.__createAssociations" id="ApplicationDiagram.__createAssociations" ref="eric5.Graphics.ApplicationDiagram.html#ApplicationDiagram.__createAssociations" />
       <keyword name="ApplicationDiagram.relayout" id="ApplicationDiagram.relayout" ref="eric5.Graphics.ApplicationDiagram.html#ApplicationDiagram.relayout" />
-      <keyword name="ApplicationDiagram.show" id="ApplicationDiagram.show" ref="eric5.Graphics.ApplicationDiagram.html#ApplicationDiagram.show" />
       <keyword name="ApplicationPage" id="ApplicationPage" ref="eric5.Preferences.ConfigurationPages.ApplicationPage.html#ApplicationPage" />
       <keyword name="ApplicationPage (Constructor)" id="ApplicationPage (Constructor)" ref="eric5.Preferences.ConfigurationPages.ApplicationPage.html#ApplicationPage.__init__" />
       <keyword name="ApplicationPage (Module)" id="ApplicationPage (Module)" ref="eric5.Preferences.ConfigurationPages.ApplicationPage.html" />
@@ -3307,6 +3306,7 @@
       <keyword name="E5GraphicsView.__getDiagram" id="E5GraphicsView.__getDiagram" ref="eric5.E5Graphics.E5GraphicsView.html#E5GraphicsView.__getDiagram" />
       <keyword name="E5GraphicsView._getDiagramRect" id="E5GraphicsView._getDiagramRect" ref="eric5.E5Graphics.E5GraphicsView.html#E5GraphicsView._getDiagramRect" />
       <keyword name="E5GraphicsView._getDiagramSize" id="E5GraphicsView._getDiagramSize" ref="eric5.E5Graphics.E5GraphicsView.html#E5GraphicsView._getDiagramSize" />
+      <keyword name="E5GraphicsView.autoAdjustSceneSize" id="E5GraphicsView.autoAdjustSceneSize" ref="eric5.E5Graphics.E5GraphicsView.html#E5GraphicsView.autoAdjustSceneSize" />
       <keyword name="E5GraphicsView.filteredItems" id="E5GraphicsView.filteredItems" ref="eric5.E5Graphics.E5GraphicsView.html#E5GraphicsView.filteredItems" />
       <keyword name="E5GraphicsView.printDiagram" id="E5GraphicsView.printDiagram" ref="eric5.E5Graphics.E5GraphicsView.html#E5GraphicsView.printDiagram" />
       <keyword name="E5GraphicsView.resizeScene" id="E5GraphicsView.resizeScene" ref="eric5.E5Graphics.E5GraphicsView.html#E5GraphicsView.resizeScene" />
@@ -6231,7 +6231,6 @@
       <keyword name="ImportsDiagram.__buildModulesDict" id="ImportsDiagram.__buildModulesDict" ref="eric5.Graphics.ImportsDiagram.html#ImportsDiagram.__buildModulesDict" />
       <keyword name="ImportsDiagram.__createAssociations" id="ImportsDiagram.__createAssociations" ref="eric5.Graphics.ImportsDiagram.html#ImportsDiagram.__createAssociations" />
       <keyword name="ImportsDiagram.relayout" id="ImportsDiagram.relayout" ref="eric5.Graphics.ImportsDiagram.html#ImportsDiagram.relayout" />
-      <keyword name="ImportsDiagram.show" id="ImportsDiagram.show" ref="eric5.Graphics.ImportsDiagram.html#ImportsDiagram.show" />
       <keyword name="IndexGenerator" id="IndexGenerator" ref="eric5.DocumentationTools.IndexGenerator.html#IndexGenerator" />
       <keyword name="IndexGenerator (Constructor)" id="IndexGenerator (Constructor)" ref="eric5.DocumentationTools.IndexGenerator.html#IndexGenerator.__init__" />
       <keyword name="IndexGenerator (Module)" id="IndexGenerator (Module)" ref="eric5.DocumentationTools.IndexGenerator.html" />
@@ -7146,7 +7145,6 @@
       <keyword name="PackageDiagram.__createAssociations" id="PackageDiagram.__createAssociations" ref="eric5.Graphics.PackageDiagram.html#PackageDiagram.__createAssociations" />
       <keyword name="PackageDiagram.__getCurrentShape" id="PackageDiagram.__getCurrentShape" ref="eric5.Graphics.PackageDiagram.html#PackageDiagram.__getCurrentShape" />
       <keyword name="PackageDiagram.relayout" id="PackageDiagram.relayout" ref="eric5.Graphics.PackageDiagram.html#PackageDiagram.relayout" />
-      <keyword name="PackageDiagram.show" id="PackageDiagram.show" ref="eric5.Graphics.PackageDiagram.html#PackageDiagram.show" />
       <keyword name="PackageItem" id="PackageItem" ref="eric5.Graphics.PackageItem.html#PackageItem" />
       <keyword name="PackageItem (Constructor)" id="PackageItem (Constructor)" ref="eric5.Graphics.PackageItem.html#PackageItem.__init__" />
       <keyword name="PackageItem (Module)" id="PackageItem (Module)" ref="eric5.Graphics.PackageItem.html" />
@@ -10618,11 +10616,11 @@
       <keyword name="UMLClassDiagram.__createAssociations" id="UMLClassDiagram.__createAssociations" ref="eric5.Graphics.UMLClassDiagram.html#UMLClassDiagram.__createAssociations" />
       <keyword name="UMLClassDiagram.__getCurrentShape" id="UMLClassDiagram.__getCurrentShape" ref="eric5.Graphics.UMLClassDiagram.html#UMLClassDiagram.__getCurrentShape" />
       <keyword name="UMLClassDiagram.relayout" id="UMLClassDiagram.relayout" ref="eric5.Graphics.UMLClassDiagram.html#UMLClassDiagram.relayout" />
-      <keyword name="UMLClassDiagram.show" id="UMLClassDiagram.show" ref="eric5.Graphics.UMLClassDiagram.html#UMLClassDiagram.show" />
       <keyword name="UMLDialog" id="UMLDialog" ref="eric5.Graphics.UMLDialog.html#UMLDialog" />
       <keyword name="UMLDialog (Constructor)" id="UMLDialog (Constructor)" ref="eric5.Graphics.UMLDialog.html#UMLDialog.__init__" />
       <keyword name="UMLDialog (Module)" id="UMLDialog (Module)" ref="eric5.Graphics.UMLDialog.html" />
       <keyword name="UMLDialog.setDiagramName" id="UMLDialog.setDiagramName" ref="eric5.Graphics.UMLDialog.html#UMLDialog.setDiagramName" />
+      <keyword name="UMLDialog.show" id="UMLDialog.show" ref="eric5.Graphics.UMLDialog.html#UMLDialog.show" />
       <keyword name="UMLGraphicsView" id="UMLGraphicsView" ref="eric5.Graphics.UMLGraphicsView.html#UMLGraphicsView" />
       <keyword name="UMLGraphicsView (Constructor)" id="UMLGraphicsView (Constructor)" ref="eric5.Graphics.UMLGraphicsView.html#UMLGraphicsView.__init__" />
       <keyword name="UMLGraphicsView (Module)" id="UMLGraphicsView (Module)" ref="eric5.Graphics.UMLGraphicsView.html" />
@@ -10641,6 +10639,7 @@
       <keyword name="UMLGraphicsView.__sceneChanged" id="UMLGraphicsView.__sceneChanged" ref="eric5.Graphics.UMLGraphicsView.html#UMLGraphicsView.__sceneChanged" />
       <keyword name="UMLGraphicsView.__setSize" id="UMLGraphicsView.__setSize" ref="eric5.Graphics.UMLGraphicsView.html#UMLGraphicsView.__setSize" />
       <keyword name="UMLGraphicsView.__zoom" id="UMLGraphicsView.__zoom" ref="eric5.Graphics.UMLGraphicsView.html#UMLGraphicsView.__zoom" />
+      <keyword name="UMLGraphicsView.autoAdjustSceneSize" id="UMLGraphicsView.autoAdjustSceneSize" ref="eric5.Graphics.UMLGraphicsView.html#UMLGraphicsView.autoAdjustSceneSize" />
       <keyword name="UMLGraphicsView.event" id="UMLGraphicsView.event" ref="eric5.Graphics.UMLGraphicsView.html#UMLGraphicsView.event" />
       <keyword name="UMLGraphicsView.filteredItems" id="UMLGraphicsView.filteredItems" ref="eric5.Graphics.UMLGraphicsView.html#UMLGraphicsView.filteredItems" />
       <keyword name="UMLGraphicsView.gestureEvent" id="UMLGraphicsView.gestureEvent" ref="eric5.Graphics.UMLGraphicsView.html#UMLGraphicsView.gestureEvent" />
--- a/Documentation/Source/eric5.E5Graphics.E5GraphicsView.html	Sat Sep 08 13:02:43 2012 +0200
+++ b/Documentation/Source/eric5.E5Graphics.E5GraphicsView.html	Sat Sep 08 17:36:14 2012 +0200
@@ -70,6 +70,9 @@
 <td><a href="#E5GraphicsView._getDiagramSize">_getDiagramSize</a></td>
 <td>Protected method to calculate the minimum size fitting the diagram.</td>
 </tr><tr>
+<td><a href="#E5GraphicsView.autoAdjustSceneSize">autoAdjustSceneSize</a></td>
+<td>Public method to adjust the scene size to the diagram size.</td>
+</tr><tr>
 <td><a href="#E5GraphicsView.filteredItems">filteredItems</a></td>
 <td>Public method to filter a list of items.</td>
 </tr><tr>
@@ -170,6 +173,17 @@
 <dd>
 the minimum size (QSizeF)
 </dd>
+</dl><a NAME="E5GraphicsView.autoAdjustSceneSize" ID="E5GraphicsView.autoAdjustSceneSize"></a>
+<h4>E5GraphicsView.autoAdjustSceneSize</h4>
+<b>autoAdjustSceneSize</b>(<i>limit=False</i>)
+<p>
+        Public method to adjust the scene size to the diagram size.
+</p><dl>
+<dt><i>limit</i></dt>
+<dd>
+flag indicating to limit the scene to the
+            initial size (boolean)
+</dd>
 </dl><a NAME="E5GraphicsView.filteredItems" ID="E5GraphicsView.filteredItems"></a>
 <h4>E5GraphicsView.filteredItems</h4>
 <b>filteredItems</b>(<i>items</i>)
@@ -238,10 +252,10 @@
 </p><dl>
 <dt><i>width</i></dt>
 <dd>
-width for the scene (integer)
+width for the scene (real)
 </dd><dt><i>height</i></dt>
 <dd>
-height for the scene (integer)
+height for the scene (real)
 </dd>
 </dl><a NAME="E5GraphicsView.setZoom" ID="E5GraphicsView.setZoom"></a>
 <h4>E5GraphicsView.setZoom</h4>
--- a/Documentation/Source/eric5.Graphics.ApplicationDiagram.html	Sat Sep 08 13:02:43 2012 +0200
+++ b/Documentation/Source/eric5.Graphics.ApplicationDiagram.html	Sat Sep 08 17:36:14 2012 +0200
@@ -75,9 +75,6 @@
 </tr><tr>
 <td><a href="#ApplicationDiagram.relayout">relayout</a></td>
 <td>Method to relayout the diagram.</td>
-</tr><tr>
-<td><a href="#ApplicationDiagram.show">show</a></td>
-<td>Overriden method to show the dialog.</td>
 </tr>
 </table>
 <h3>Static Methods</h3>
@@ -154,11 +151,6 @@
 <b>relayout</b>(<i></i>)
 <p>
         Method to relayout the diagram.
-</p><a NAME="ApplicationDiagram.show" ID="ApplicationDiagram.show"></a>
-<h4>ApplicationDiagram.show</h4>
-<b>show</b>(<i></i>)
-<p>
-        Overriden method to show the dialog.
 </p>
 <div align="right"><a href="#top">Up</a></div>
 <hr />
--- a/Documentation/Source/eric5.Graphics.ImportsDiagram.html	Sat Sep 08 13:02:43 2012 +0200
+++ b/Documentation/Source/eric5.Graphics.ImportsDiagram.html	Sat Sep 08 17:36:14 2012 +0200
@@ -78,9 +78,6 @@
 </tr><tr>
 <td><a href="#ImportsDiagram.relayout">relayout</a></td>
 <td>Method to relayout the diagram.</td>
-</tr><tr>
-<td><a href="#ImportsDiagram.show">show</a></td>
-<td>Overriden method to show the dialog.</td>
 </tr>
 </table>
 <h3>Static Methods</h3>
@@ -161,11 +158,6 @@
 <b>relayout</b>(<i></i>)
 <p>
         Method to relayout the diagram.
-</p><a NAME="ImportsDiagram.show" ID="ImportsDiagram.show"></a>
-<h4>ImportsDiagram.show</h4>
-<b>show</b>(<i></i>)
-<p>
-        Overriden method to show the dialog.
 </p>
 <div align="right"><a href="#top">Up</a></div>
 <hr />
--- a/Documentation/Source/eric5.Graphics.PackageDiagram.html	Sat Sep 08 13:02:43 2012 +0200
+++ b/Documentation/Source/eric5.Graphics.PackageDiagram.html	Sat Sep 08 17:36:14 2012 +0200
@@ -84,9 +84,6 @@
 </tr><tr>
 <td><a href="#PackageDiagram.relayout">relayout</a></td>
 <td>Method to relayout the diagram.</td>
-</tr><tr>
-<td><a href="#PackageDiagram.show">show</a></td>
-<td>Overriden method to show the dialog.</td>
 </tr>
 </table>
 <h3>Static Methods</h3>
@@ -210,11 +207,6 @@
 <b>relayout</b>(<i></i>)
 <p>
         Method to relayout the diagram.
-</p><a NAME="PackageDiagram.show" ID="PackageDiagram.show"></a>
-<h4>PackageDiagram.show</h4>
-<b>show</b>(<i></i>)
-<p>
-        Overriden method to show the dialog.
 </p>
 <div align="right"><a href="#top">Up</a></div>
 <hr />
--- a/Documentation/Source/eric5.Graphics.UMLClassDiagram.html	Sat Sep 08 13:02:43 2012 +0200
+++ b/Documentation/Source/eric5.Graphics.UMLClassDiagram.html	Sat Sep 08 17:36:14 2012 +0200
@@ -81,9 +81,6 @@
 </tr><tr>
 <td><a href="#UMLClassDiagram.relayout">relayout</a></td>
 <td>Public method to relayout the diagram.</td>
-</tr><tr>
-<td><a href="#UMLClassDiagram.show">show</a></td>
-<td>Overriden method to show the dialog.</td>
 </tr>
 </table>
 <h3>Static Methods</h3>
@@ -197,11 +194,6 @@
 <b>relayout</b>(<i></i>)
 <p>
         Public method to relayout the diagram.
-</p><a NAME="UMLClassDiagram.show" ID="UMLClassDiagram.show"></a>
-<h4>UMLClassDiagram.show</h4>
-<b>show</b>(<i></i>)
-<p>
-        Overriden method to show the dialog.
 </p>
 <div align="right"><a href="#top">Up</a></div>
 <hr />
--- a/Documentation/Source/eric5.Graphics.UMLDialog.html	Sat Sep 08 13:02:43 2012 +0200
+++ b/Documentation/Source/eric5.Graphics.UMLDialog.html	Sat Sep 08 17:36:14 2012 +0200
@@ -63,6 +63,9 @@
 </tr><tr>
 <td><a href="#UMLDialog.setDiagramName">setDiagramName</a></td>
 <td>Public slot to set the diagram name.</td>
+</tr><tr>
+<td><a href="#UMLDialog.show">show</a></td>
+<td>Overriden method to show the dialog.</td>
 </tr>
 </table>
 <h3>Static Methods</h3>
@@ -71,11 +74,17 @@
 </table>
 <a NAME="UMLDialog.__init__" ID="UMLDialog.__init__"></a>
 <h4>UMLDialog (Constructor)</h4>
-<b>UMLDialog</b>(<i>diagramName="Unnamed", parent=None, name=None</i>)
+<b>UMLDialog</b>(<i>buildFunction=None, diagramName="Unnamed", parent=None, name=None</i>)
 <p>
         Constructor
 </p><dl>
-<dt><i>parent</i></dt>
+<dt><i>buildFunction</i></dt>
+<dd>
+function to build the diagram contents (function)
+</dd><dt><i>diagramName</i></dt>
+<dd>
+name of the diagram (string)
+</dd><dt><i>parent</i></dt>
 <dd>
 parent widget of the view (QWidget)
 </dd><dt><i>name</i></dt>
@@ -92,7 +101,12 @@
 <dd>
 diagram name (string)
 </dd>
-</dl>
+</dl><a NAME="UMLDialog.show" ID="UMLDialog.show"></a>
+<h4>UMLDialog.show</h4>
+<b>show</b>(<i></i>)
+<p>
+        Overriden method to show the dialog.
+</p>
 <div align="right"><a href="#top">Up</a></div>
 <hr />
 </body></html>
\ No newline at end of file
--- a/Documentation/Source/eric5.Graphics.UMLGraphicsView.html	Sat Sep 08 13:02:43 2012 +0200
+++ b/Documentation/Source/eric5.Graphics.UMLGraphicsView.html	Sat Sep 08 17:36:14 2012 +0200
@@ -113,6 +113,9 @@
 <td><a href="#UMLGraphicsView.__zoom">__zoom</a></td>
 <td>Private method to handle the zoom context menu action.</td>
 </tr><tr>
+<td><a href="#UMLGraphicsView.autoAdjustSceneSize">autoAdjustSceneSize</a></td>
+<td>Public method to adjust the scene size to the diagram size.</td>
+</tr><tr>
 <td><a href="#UMLGraphicsView.event">event</a></td>
 <td>Protected method handling events.</td>
 </tr><tr>
@@ -246,7 +249,18 @@
 <b>__zoom</b>(<i></i>)
 <p>
         Private method to handle the zoom context menu action.
-</p><a NAME="UMLGraphicsView.event" ID="UMLGraphicsView.event"></a>
+</p><a NAME="UMLGraphicsView.autoAdjustSceneSize" ID="UMLGraphicsView.autoAdjustSceneSize"></a>
+<h4>UMLGraphicsView.autoAdjustSceneSize</h4>
+<b>autoAdjustSceneSize</b>(<i>limit=False</i>)
+<p>
+        Public method to adjust the scene size to the diagram size.
+</p><dl>
+<dt><i>limit</i></dt>
+<dd>
+flag indicating to limit the scene to the
+            initial size (boolean)
+</dd>
+</dl><a NAME="UMLGraphicsView.event" ID="UMLGraphicsView.event"></a>
 <h4>UMLGraphicsView.event</h4>
 <b>event</b>(<i>evt</i>)
 <p>
--- a/E5Graphics/E5GraphicsView.py	Sat Sep 08 13:02:43 2012 +0200
+++ b/E5Graphics/E5GraphicsView.py	Sat Sep 08 17:36:14 2012 +0200
@@ -29,18 +29,14 @@
         super().__init__(scene, parent)
         self.setObjectName("E5GraphicsView")
         
+        self.__initialSceneSize = self.scene().sceneRect().size()
         self.setBackgroundBrush(QBrush(Qt.white))
         self.setRenderHint(QPainter.Antialiasing, True)
         self.setDragMode(QGraphicsView.RubberBandDrag)
         self.setAlignment(Qt.Alignment(Qt.AlignLeft | Qt.AlignTop))
         self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
         self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
-        
-        # available as of Qt 4.3
-        try:
-            self.setViewportUpdateMode(QGraphicsView.SmartViewportUpdate)
-        except AttributeError:
-            pass
+        self.setViewportUpdateMode(QGraphicsView.SmartViewportUpdate)
         
         self.setWhatsThis(self.trUtf8("<b>Graphics View</b>\n"
             "<p>This graphics view is used to show a diagram. \n"
@@ -119,13 +115,29 @@
         """
         Public method to set the scene size.
         
-        @param width width for the scene (integer)
-        @param height height for the scene (integer)
+        @param width width for the scene (real)
+        @param height height for the scene (real)
         """
         rect = self.scene().sceneRect()
         rect.setHeight(height)
         rect.setWidth(width)
-        self.setSceneRect(rect)
+        self.scene().setSceneRect(rect)
+        
+    def autoAdjustSceneSize(self, limit=False):
+        """
+        Public method to adjust the scene size to the diagram size.
+        
+        @param limit flag indicating to limit the scene to the
+            initial size (boolean)
+        """
+        size = self._getDiagramSize(10)
+        if limit:
+            newWidth = max(size.width(), self.__initialSceneSize.width())
+            newHeight = max(size.height(), self.__initialSceneSize.height())
+        else:
+            newWidth = size.width()
+            newHeight = size.height()
+        self.setSceneSize(newWidth, newHeight)
         
     def _getDiagramRect(self, border=0):
         """
--- a/Graphics/ApplicationDiagram.py	Sat Sep 08 13:02:43 2012 +0200
+++ b/Graphics/ApplicationDiagram.py	Sat Sep 08 17:36:14 2012 +0200
@@ -39,7 +39,7 @@
         self.project = project
         self.noModules = noModules
         
-        UMLDialog.__init__(self, parent=parent)
+        UMLDialog.__init__(self, buildFunction=self.__buildPackages, parent=parent)
         self.setDiagramName(
             self.trUtf8("Application Diagram {0}").format(project.getProjectName()))
         
@@ -213,6 +213,7 @@
         self.umlView.setSceneSize(sceneRect.width(), sceneRect.height())
         
         self.__createAssociations(shapes)
+        self.umlView.autoAdjustSceneSize(limit=True)
         
     def __addPackage(self, name, modules, x, y):
         """
@@ -242,13 +243,6 @@
                         Imports)
                 self.scene.addItem(assoc)
         
-    def show(self):
-        """
-        Overriden method to show the dialog.
-        """
-        self.__buildPackages()
-        UMLDialog.show(self)
-        
     def relayout(self):
         """
         Method to relayout the diagram.
--- a/Graphics/ImportsDiagram.py	Sat Sep 08 13:02:43 2012 +0200
+++ b/Graphics/ImportsDiagram.py	Sat Sep 08 17:36:14 2012 +0200
@@ -41,7 +41,7 @@
         @keyparam showExternalImports flag indicating to show exports from outside
             the package (boolean)
         """
-        UMLDialog.__init__(self, parent=parent)
+        UMLDialog.__init__(self, buildFunction=self.__buildImports, parent=parent)
         
         self.showExternalImports = showExternalImports
         self.packagePath = Utilities.normabspath(package)
@@ -211,6 +211,7 @@
         self.umlView.setSceneSize(sceneRect.width(), sceneRect.height())
         
         self.__createAssociations(shapes)
+        self.umlView.autoAdjustSceneSize(limit=True)
         
     def __addModule(self, name, classes, x, y):
         """
@@ -240,13 +241,6 @@
                         Imports)
                 self.scene.addItem(assoc)
         
-    def show(self):
-        """
-        Overriden method to show the dialog.
-        """
-        self.__buildImports()
-        UMLDialog.show(self)
-        
     def relayout(self):
         """
         Method to relayout the diagram.
--- a/Graphics/PackageDiagram.py	Sat Sep 08 13:02:43 2012 +0200
+++ b/Graphics/PackageDiagram.py	Sat Sep 08 17:36:14 2012 +0200
@@ -37,7 +37,7 @@
         @param name name of the view widget (string)
         @keyparam noAttrs flag indicating, that no attributes should be shown (boolean)
         """
-        UMLDialog.__init__(self, parent=parent)
+        UMLDialog.__init__(self, buildFunction=self.__buildClasses, parent=parent)
         
         self.package = Utilities.normabspath(package)
         self.allClasses = {}
@@ -192,6 +192,7 @@
             
         self.__arrangeClasses(nodes, routes[:])
         self.__createAssociations(routes)
+        self.umlView.autoAdjustSceneSize(limit=True)
         
     def __arrangeClasses(self, nodes, routes, whiteSpaceFactor=1.2):
         """
@@ -308,13 +309,6 @@
                         topToBottom=True)
                 self.scene.addItem(assoc)
         
-    def show(self):
-        """
-        Overriden method to show the dialog.
-        """
-        self.__buildClasses()
-        UMLDialog.show(self)
-        
     def relayout(self):
         """
         Method to relayout the diagram.
--- a/Graphics/UMLClassDiagram.py	Sat Sep 08 13:02:43 2012 +0200
+++ b/Graphics/UMLClassDiagram.py	Sat Sep 08 17:36:14 2012 +0200
@@ -34,7 +34,7 @@
         @param name name of the view widget (string)
         @keyparam noAttrs flag indicating, that no attributes should be shown (boolean)
         """
-        UMLDialog.__init__(self, parent=parent)
+        UMLDialog.__init__(self, buildFunction=self.__buildClasses, parent=parent)
         
         self.file = file
         self.noAttrs = noAttrs
@@ -137,6 +137,7 @@
         if classesFound:
             self.__arrangeClasses(nodes, routes[:])
             self.__createAssociations(routes)
+            self.umlView.autoAdjustSceneSize(limit=True)
         else:
             ct = QGraphicsTextItem(None, self.scene)
             ct.setHtml(
@@ -183,9 +184,13 @@
         
         # add in some whitespace
         width = width * whiteSpaceFactor
-        rawHeight = height
+##        rawHeight = height
         height = height * whiteSpaceFactor - 20
-        verticalWhiteSpace = (height - rawHeight) / (len(generations) - 1.0 or 2.0)
+##        verticalWhiteSpace = max(
+##            (height - rawHeight) / (len(generations) - 1.0 or 2.0),
+##            40.0
+##        )
+        verticalWhiteSpace = 40.0
         
         sceneRect = self.umlView.sceneRect()
         width += 50.0
@@ -262,13 +267,6 @@
                         topToBottom=True)
                 self.scene.addItem(assoc)
         
-    def show(self):
-        """
-        Overriden method to show the dialog.
-        """
-        self.__buildClasses()
-        UMLDialog.show(self)
-        
     def relayout(self):
         """
         Public method to relayout the diagram.
--- a/Graphics/UMLDialog.py	Sat Sep 08 13:02:43 2012 +0200
+++ b/Graphics/UMLDialog.py	Sat Sep 08 17:36:14 2012 +0200
@@ -20,10 +20,12 @@
     """
     Class implementing a dialog showing UML like diagrams.
     """
-    def __init__(self, diagramName="Unnamed", parent=None, name=None):
+    def __init__(self, buildFunction=None, diagramName="Unnamed", parent=None, name=None):
         """
         Constructor
         
+        @param buildFunction function to build the diagram contents (function)
+        @param diagramName name of the diagram (string)
         @param parent parent widget of the view (QWidget)
         @param name name of the view widget (string)
         """
@@ -34,6 +36,7 @@
         else:
             self.setObjectName(name)
         
+        self.buildFunction = buildFunction
         self.scene = QGraphicsScene(0.0, 0.0, 800.0, 600.0)
         self.umlView = UMLGraphicsView(self.scene, diagramName, self, "umlView")
         
@@ -60,3 +63,11 @@
         @param name diagram name (string)
         """
         self.umlView.setDiagramName(name)
+    
+    def show(self):
+        """
+        Overriden method to show the dialog.
+        """
+        if self.buildFunction:
+            self.buildFunction()
+        super().show()
--- a/Graphics/UMLGraphicsView.py	Sat Sep 08 13:02:43 2012 +0200
+++ b/Graphics/UMLGraphicsView.py	Sat Sep 08 17:36:14 2012 +0200
@@ -8,7 +8,7 @@
 """
 
 from PyQt4.QtCore import pyqtSignal, Qt, QSignalMapper, QFileInfo, QEvent
-from PyQt4.QtGui import QAction, QToolBar, QDialog, QPrinter, QPrintDialog
+from PyQt4.QtGui import QGraphicsView, QAction, QToolBar, QDialog, QPrinter, QPrintDialog
 
 from E5Graphics.E5GraphicsView import E5GraphicsView
 
@@ -45,6 +45,7 @@
         E5GraphicsView.__init__(self, scene, parent)
         if name:
             self.setObjectName(name)
+        self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate)
         
         self.diagramName = diagramName
         
@@ -180,11 +181,11 @@
         """
         diagramSize = self._getDiagramSize(10)
         sceneRect = self.scene().sceneRect()
-        if (sceneRect.width() - self.deltaSize) <= diagramSize.width():
+        if (sceneRect.width() - self.deltaSize) < diagramSize.width():
             self.decWidthAct.setEnabled(False)
         else:
             self.decWidthAct.setEnabled(True)
-        if (sceneRect.height() - self.deltaSize) <= diagramSize.height():
+        if (sceneRect.height() - self.deltaSize) < diagramSize.height():
             self.decHeightAct.setEnabled(False)
         else:
             self.decHeightAct.setEnabled(True)
@@ -200,6 +201,19 @@
         else:
             self.deleteShapeAct.setEnabled(False)
         
+        sceneRect = self.scene().sceneRect()
+        newWidth = width = sceneRect.width()
+        newHeight = height = sceneRect.height()
+        rect = self._getDiagramRect(10)
+        if width < rect.width():
+            newWidth = rect.width()
+        if height < rect.height():
+            newHeight = rect.height()
+        
+        if newHeight != height or newWidth != width:
+            self.setSceneSize(newWidth, newHeight)
+            self.__checkSizeActions()
+        
     def initToolBar(self):
         """
         Public method to populate a toolbar with our actions.
@@ -321,6 +335,16 @@
             self.setSceneSize(width, height)
         self.__checkSizeActions()
         
+    def autoAdjustSceneSize(self, limit=False):
+        """
+        Public method to adjust the scene size to the diagram size.
+        
+        @param limit flag indicating to limit the scene to the
+            initial size (boolean)
+        """
+        super().autoAdjustSceneSize(limit=limit)
+        self.__checkSizeActions()
+        
     def __saveImage(self):
         """
         Private method to handle the save context menu entry.
@@ -360,9 +384,7 @@
         Private method to handle the re-layout context menu entry.
         """
         scene = self.scene()
-        for itm in list(scene.items())[:]:
-            if itm.scene() == scene:
-                scene.removeItem(itm)
+        scene.clear()
         self.relayout.emit()
         
     def __printDiagram(self):

eric ide

mercurial