CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
BrowserTab.py
Go to the documentation of this file.
1 import logging
2 
3 from PyQt4.QtCore import SIGNAL,Qt
4 from PyQt4.QtGui import QFrame,QHeaderView,QToolButton,QStandardItemModel,QVBoxLayout,QSizePolicy
5 
6 from Vispa.Main.SplitterTab import SplitterTab
7 from Vispa.Gui.Header import FrameWithHeader
8 from Vispa.Gui.ZoomableScrollArea import ZoomableScrollArea
9 from Vispa.Gui.ZoomableScrollableWidgetOwner import ZoomableScrollableWidgetOwner
10 from Vispa.Gui.Zoomable import Zoomable
11 from Vispa.Views.AbstractView import NoneView
12 from Vispa.Views.TreeView import TreeView
13 
15  """ The BrowserTab has three views and is controlled by the BrowserControllerTab.
16  """
17  def __init__(self, parent=None, topLevelPropertyView=False):
18  logging.debug(__name__ + ": __init__")
19  SplitterTab.__init__(self, parent, topLevelPropertyView)
20 
21  self._treeView = None
22  self._centerView = None
23 
24  self.createTreeView()
25  self.createCenterView()
26  self.createPropertyView()
27  if topLevelPropertyView:
28  self.horizontalSplitter().setSizes([300, 400])
29  self.setSizes([700, 300])
30  else:
31  self.horizontalSplitter().setSizes([300, 400, 300])
32 
33  def createTreeView(self,parent=None):
34  """ Create the tree view.
35  """
36  if not parent:
37  parent=self.horizontalSplitter()
38 
40  self._treeviewArea.header().setText("Tree View")
41  self._treeviewArea.header().setToolTip("click on '>' for options of this view")
42  self._treeViewMenuButton = self._treeviewArea.header().createMenuButton()
43  self._treeView = TreeView(self._treeviewArea)
44  self._treeviewArea.addWidget(self._treeView)
45 
46  def createCenterView(self,parent=None):
47  """ Create the center view.
48  """
49  if not parent:
50  parent=self.horizontalSplitter()
51 
53  self._centerArea.header().setText("Center View")
54  self._centerArea.header().setToolTip("click on '>' for options of this view")
55  self._centerArea.header().createMenuButton()
56 
58  self._centerArea.addWidget(self._scrollArea)
59  self.setCenterView(NoneView())
60 
61  def setCenterView(self,view):
62  """ Set the center view.
63  """
64  logging.debug(self.__class__.__name__ +": setCenterView()")
65  if self.centerView():
66  self.centerView().close()
67  self._scrollArea.takeWidget()
68  self._centerView = view
69  if isinstance(self.centerView(), ZoomableScrollableWidgetOwner):
70  if isinstance(self.centerView(), Zoomable):
71  self.centerView().setZoom(self._scrollArea.zoom())
72  self._scrollArea.setWidget(self.centerView())
73  self._scrollArea.show()
74  else:
75  self.centerView().resize(self._scrollArea.size())
76  self._scrollArea.hide()
77  self._centerArea.layout().addWidget(self.centerView())
78  self.centerView().show()
79 
80  def treeView(self):
81  return self._treeView
82 
83  def centerView(self):
84  return self._centerView
85 
86  def setController(self, controller):
87  """ Sets controller for this tab and connects signals etc.
88  """
89  SplitterTab.setController(self, controller)
90  if self._scrollArea:
91  self.connect(self._scrollArea, SIGNAL('wheelZoom()'), controller.resetZoomButtonPressedBefore)
92  self.connect(self._scrollArea, SIGNAL("zoomChanged(float)"), controller.zoomChanged)
93  self.connect(self.centerViewMenuButton(), SIGNAL("clicked(bool)"), controller.centerViewMenuButtonClicked)
94  self.connect(self.treeViewMenuButton(), SIGNAL("clicked(bool)"), controller.treeViewMenuButtonClicked)
95 
96  def scrollArea(self):
97  return self._scrollArea
98 
99  def treeViewMenuButton(self):
100  return self._treeviewArea.header().menuButton()
101 
103  return self._centerArea.header().menuButton()
104 
105  def treeViewHeader(self):
106  return self._treeviewArea.header()
107 
108  def centerViewHeader(self):
109  return self._centerArea.header()
110 
111  def setCenterViewHeader(self,text):
112  self._centerArea.header().setText(text)
113 
114  def setTreeViewHeader(self,text):
115  self._treeviewArea.header().setText(text)