Graphics/PixmapDiagram.py

changeset 2992
dbdf27746da5
parent 2334
fc69ad77e18a
child 3020
542e97d4ecb3
child 3057
10516539f238
--- a/Graphics/PixmapDiagram.py	Sun Oct 06 19:52:33 2013 +0200
+++ b/Graphics/PixmapDiagram.py	Mon Oct 07 19:10:11 2013 +0200
@@ -8,8 +8,9 @@
 """
 
 from PyQt4.QtCore import Qt, QSize, QEvent
-from PyQt4.QtGui import QLabel, QPalette, QSizePolicy, QScrollArea, QAction, QMenu, \
-    QToolBar, QImage, QPixmap, QPrinter, QPrintDialog, QPainter, QFont, QColor
+from PyQt4.QtGui import QLabel, QPalette, QSizePolicy, QScrollArea, QAction, \
+    QMenu, QToolBar, QImage, QPixmap, QPrinter, QPrintDialog, QPainter, \
+    QFont, QColor
 
 from E5Gui import E5MessageBox
 from E5Gui.E5MainWindow import E5MainWindow
@@ -51,7 +52,8 @@
         self.pixmapLabel = QLabel()
         self.pixmapLabel.setObjectName("pixmapLabel")
         self.pixmapLabel.setBackgroundRole(QPalette.Base)
-        self.pixmapLabel.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
+        self.pixmapLabel.setSizePolicy(
+            QSizePolicy.Ignored, QSizePolicy.Ignored)
         self.pixmapLabel.setScaledContents(True)
         
         self.pixmapView = QScrollArea()
@@ -61,7 +63,8 @@
         
         self.setCentralWidget(self.pixmapView)
         
-        self.__zoomWidget = E5ZoomWidget(UI.PixmapCache.getPixmap("zoomOut.png"),
+        self.__zoomWidget = E5ZoomWidget(
+            UI.PixmapCache.getPixmap("zoomOut.png"),
             UI.PixmapCache.getPixmap("zoomIn.png"),
             UI.PixmapCache.getPixmap("zoomReset.png"), self)
         self.statusBar().addPermanentWidget(self.__zoomWidget)
@@ -215,9 +218,9 @@
                 self.__doZoom(int(pinch.scaleFactor() * 100))
             evt.accept()
     
-    ############################################################################
+    ###########################################################################
     ## Private menu handling methods below.
-    ############################################################################
+    ###########################################################################
     
     def __adjustScrollBar(self, scrollBar, factor):
         """
@@ -252,11 +255,14 @@
         """
         oldValue = self.__zoom()
         if value != oldValue:
-            self.pixmapLabel.resize(value / 100 * self.pixmapLabel.pixmap().size())
+            self.pixmapLabel.resize(
+                value / 100 * self.pixmapLabel.pixmap().size())
             
             factor = value / oldValue
-            self.__adjustScrollBar(self.pixmapView.horizontalScrollBar(), factor)
-            self.__adjustScrollBar(self.pixmapView.verticalScrollBar(), factor)
+            self.__adjustScrollBar(
+                self.pixmapView.horizontalScrollBar(), factor)
+            self.__adjustScrollBar(
+                self.pixmapView.verticalScrollBar(), factor)
             
             self.__zoomWidget.setValue(value)
         
@@ -288,7 +294,8 @@
         
         @return current zoom factor in percent (integer)
         """
-        return int(self.pixmapLabel.width() / self.pixmapLabel.pixmap().width() * 100.0)
+        return int(self.pixmapLabel.width() / 
+                   self.pixmapLabel.pixmap().width() * 100.0)
         
     def __printDiagram(self):
         """
@@ -354,18 +361,18 @@
         fm = painter.fontMetrics()
         fontHeight = fm.lineSpacing()
         marginX = printer.pageRect().x() - printer.paperRect().x()
-        marginX = \
-            Preferences.getPrinter("LeftMargin") * int(printer.resolution() / 2.54) \
-            - marginX
+        marginX = Preferences.getPrinter("LeftMargin") * \
+            int(printer.resolution() / 2.54) - marginX
         marginY = printer.pageRect().y() - printer.paperRect().y()
-        marginY = \
-            Preferences.getPrinter("TopMargin") * int(printer.resolution() / 2.54) \
-            - marginY
+        marginY = Preferences.getPrinter("TopMargin") * \
+            int(printer.resolution() / 2.54) - marginY
 
-        width = printer.width() - marginX \
-            - Preferences.getPrinter("RightMargin") * int(printer.resolution() / 2.54)
-        height = printer.height() - fontHeight - 4 - marginY \
-            - Preferences.getPrinter("BottomMargin") * int(printer.resolution() / 2.54)
+        width = printer.width() - marginX - \
+            Preferences.getPrinter("RightMargin") * \
+            int(printer.resolution() / 2.54)
+        height = printer.height() - fontHeight - 4 - marginY - \
+            Preferences.getPrinter("BottomMargin") * \
+            int(printer.resolution() / 2.54)
 
         # write a foot note
         s = self.trUtf8("Diagram: {0}").format(self.getDiagramName())
@@ -382,7 +389,8 @@
         size = self.pixmapLabel.pixmap().size()
         size.scale(QSize(width - 10, height - 10),  # 5 px inner margin
             Qt.KeepAspectRatio)
-        painter.setViewport(marginX + 5, marginY + 5, size.width(), size.height())
+        painter.setViewport(marginX + 5, marginY + 5,
+                            size.width(), size.height())
         painter.setWindow(self.pixmapLabel.pixmap().rect())
         painter.drawPixmap(0, 0, self.pixmapLabel.pixmap())
         painter.end()

eric ide

mercurial