test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ZoomableWidget.py
Go to the documentation of this file.
1 import logging
2 import os.path
3 
4 from PyQt4.QtCore import *
5 from PyQt4.QtGui import *
6 
7 from Vispa.Gui.Zoomable import Zoomable
8 from Vispa.Share.ImageExporter import ImageExporter
9 
10 class ZoomableWidget(QWidget, Zoomable):
11 
12  def __init__(self, parent=None):
13  """ Constructor
14  """
15  QWidget.__init__(self, parent)
16  Zoomable.__init__(self)
17  self._imageExporter = None
18 
19  if isinstance(self.parent(), ZoomableWidget):
20  self.setZoom(self.parent().zoom())
21 
22  def setZoom(self, zoom):
23  """ Sets zoom of this widget and of it's children.
24  """
25  Zoomable.setZoom(self, zoom)
26 
27  for child in self.children():
28  if isinstance(child, Zoomable):
29  child.setZoom(zoom)
30  self.update()
31 
32  def exportImage(self, filename=None):
33  if not self._imageExporter:
34  self._imageExporter = ImageExporter(self)
35 
36  if not filename:
37  self._imageExporter.exportImageDialog(self)
38  else:
39  self._imageExporter.exportImage(self, filename)