CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Zoomable.py
Go to the documentation of this file.
1 class Zoomable(object):
2  """ Interface for zoomable objects.
3  """
4  def __init__(self):
5  self._zoomFactor = 1.0 # not just set self._zoomFactor
6  self.setZoom(100) # call setZoom() because it might be overwritten
7 
8  def setZoom(self, zoom):
9  """Takes zoom factor in percent.
10  """
11  # prevent division by zero
12  self._zoomFactor = 0.01 * max(abs(zoom), 0.000001)
13 
14  def zoom(self):
15  """Returns zoom factor in percent.
16  """
17  return self._zoomFactor * 100.0
18 
19  def zoomFactor(self):
20  return self._zoomFactor
21 
22  def incrementZoom(self):
23  """Increment zoom by 10 %
24  """
25  self.setZoom(self._zoomFactor * 110)
26 
27  def decrementZoom(self):
28  """Decrement zome by 10 %
29  """
30  self.setZoom(self._zoomFactor * 90)
31 
#define abs(x)
Definition: mlp_lapack.h:159
const T & max(const T &a, const T &b)
list object
Definition: dbtoconf.py:77