CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ZoomableScrollableWidgetOwner.py
Go to the documentation of this file.
1 import logging
2 
3 from PyQt4.QtGui import *
4 
5 from Vispa.Gui.ZoomableWidget import ZoomableWidget
6 from Vispa.Gui.ZoomableScrollArea import ZoomableScrollArea
7 from Vispa.Gui.ConnectableWidgetOwner import ConnectableWidgetOwner
8 
10  """ Area for drawing connectable widgets.
11  """
12  def __init__(self, parent=None):
13  logging.debug(__name__ + ": __init__")
14  ZoomableWidget.__init__(self, parent)
15  ConnectableWidgetOwner.__init__(self)
16 
17  def setZoom(self, zoom):
18  """ Sets zoom.
19  """
20  ZoomableWidget.setZoom(self, zoom)
21  # make sure connections are updated after widgets were moved
22  # setZoom function of ZoomableWidget does not guarantee connections are updated after widgets
23  self.updateConnections()
24 
25  def autosizeScrollArea(self):
26  """ If this window is widget of a ZoomableScrollArea tell scroll area to autosize.
27  """
28  if self.parent() and isinstance(self.parent().parent(), ZoomableScrollArea):
29  # Why parent().parent()?
30  # parent() is QScrollArea.viewport(), basically the QScrollArea without scroll bars
31  # parent().parent() is eventually the QScrollArea
32  self.parent().parent().autosizeScrollWidget()
33 
34  def widgetDragged(self, widget):
35  """ Calls autosizeScrollArea().
36  """
37  ConnectableWidgetOwner.widgetDragged(self, widget)
38  self.autosizeScrollArea()