test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EdmBrowserPlugin.py
Go to the documentation of this file.
1 import os.path
2 import logging
3 
4 from Vispa.Main.Application import Application
5 from Vispa.Plugins.EventBrowser.EventBrowserPlugin import EventBrowserPlugin
6 from Vispa.Views.TableView import TableView
7 from Vispa.Share.ThreadChain import ThreadChain
8 from Vispa.Main.Exceptions import NoCurrentTabControllerException,PluginIgnoredException,exception_traceback
9 
10 try:
11  from Vispa.Plugins.EdmBrowser.EdmDataAccessor import EdmDataAccessor
12 except Exception as e:
13  raise PluginIgnoredException("cannot import CMSSW: " + str(e))
14 
15 from Vispa.Plugins.EdmBrowser.EdmBrowserTab import EdmBrowserTab
16 from Vispa.Plugins.EdmBrowser.EdmBrowserBoxView import EdmBrowserBoxView
17 from Vispa.Plugins.EdmBrowser.EdmBrowserTabController import EdmBrowserTabController
18 
20  """ The EdmBrowserPlugin opens edm root files in the EventBrowserTab.
21  """
22 
23  def __init__(self, application=None, name=None):
24  logging.debug(__name__ + ": __init__")
25  EventBrowserPlugin.__init__(self, application)
26  self.registerFiletypesFromTabController(EdmBrowserTabController)
27 
28  def startUp(self):
29  EventBrowserPlugin.startUp(self)
30  self.addCenterView(EdmBrowserBoxView)
31  self.addCenterView(TableView)
32 
33  def newTab(self):
34  """ Create EdmBrowserTab and add to MainWindow.
35  """
36  logging.debug(__name__ + ": newTab")
37  tab = EdmBrowserTab(self.application().mainWindow())
38 
39  controller = EdmBrowserTabController(self)
40  controller.setDataAccessor(EdmDataAccessor())
41  tab.setController(controller)
42 
43  controller.boxContentDialog().addButton("&Label", "str(object.Label)")
44  controller.boxContentDialog().addButton("&Type", "str(object.Type)")
45  controller.boxContentDialog().addButton("&Name", "str(object.Name)")
46  controller.boxContentDialog().addButton("&Pt", "str(object.Pt)")
47 
48  self.application().mainWindow().addTab(tab)
49  return tab
50 
51  def _expandToDepth(self):
52  """ Calls expandToDepthDialog() function of current tab controller.
53  """
54  try:
55  self.application().currentTabController().expandToDepthDialog()
56  except NoCurrentTabControllerException:
57  logging.warning(self.__class__.__name__ + ": _expandToDepth() - No tab controller found.")
58 
59  def _fillMenu(self):
60  """ Fill specific menu.
61  """
62  EventBrowserPlugin._fillMenu(self)
63  self._filterBranchesAction = self.application().createAction('&Filter invalid branches', self._filterBranches, "Ctrl+Shift+F")
64  self._filterBranchesAction.setCheckable(True)
65  self._filterBranchesAction.setChecked(True)
66  self._viewMenu.addAction(self._filterBranchesAction)
67  self._hideUnderscorePropertiesAction = self.application().createAction('&Hide _underscore properties', self._hideUnderscoreProperties, "Ctrl+Shift+U")
68  self._hideUnderscorePropertiesAction.setCheckable(True)
69  self._hideUnderscorePropertiesAction.setChecked(True)
70  self._viewMenu.addAction(self._hideUnderscorePropertiesAction)
71  self._viewMenu.addSeparator()
72  self._eventContentAction = self.application().createAction('&Browse event content...', self._eventContent, "Ctrl+Shift+C")
73  self._viewMenu.addAction(self._eventContentAction)
74  self._viewMenu.addSeparator()
75 
77  return self._filterBranchesAction
78 
79  def _filterBranches(self):
80  try:
81  self.application().currentTabController().toggleFilterBranches()
82  except NoCurrentTabControllerException:
83  logging.warning(self.__class__.__name__ + ": _filterBranches() - No tab controller found.")
84 
85  def eventContentAction(self):
86  return self._eventContentAction
87 
88  def _eventContent(self):
89  try:
90  self.application().currentTabController().eventContent()
91  except NoCurrentTabControllerException:
92  logging.warning(self.__class__.__name__ + ": _eventContent() - No tab controller found.")
93 
96 
98  try:
99  self.application().currentTabController().toggleUnderscoreProperties()
100  except NoCurrentTabControllerException:
101  logging.warning(self.__class__.__name__ + ": _hideUnderscoreProperties() - No tab controller found.")