CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EdmBrowserTabController.py
Go to the documentation of this file.
1 import logging
2 import os.path
3 
4 from PyQt4.QtCore import SIGNAL,QPoint
5 from PyQt4.QtGui import QInputDialog,QMenu
6 
7 from Vispa.Plugins.EventBrowser.EventBrowserTabController import EventBrowserTabController
8 from Vispa.Plugins.EdmBrowser.EventContentDialog import EventContentDialog
9 
11 
12  def __init__(self, plugin):
13  EventBrowserTabController.__init__(self, plugin)
14  self._treeDepth=1
15 
16  #@staticmethod
18  """ Returns supported file type: root.
19  """
20  return [('root', 'EDM root file')]
21  staticSupportedFileTypes = staticmethod(staticSupportedFileTypes)
22 
23  def updateViewMenu(self):
24  EventBrowserTabController.updateViewMenu(self)
25  self.plugin().expandToDepthAction().setVisible(True)
26  self.plugin().boxContentAction().setVisible(False)
27  self.disconnect(self.tab().centerView(), SIGNAL("toggleCollapsed"), self.toggleCollapsed)
28  self.connect(self.tab().centerView(), SIGNAL("toggleCollapsed"), self.toggleCollapsed)
29 
30  def toggleCollapsed(self,object):
31  logging.debug(__name__ + ": toggleCollapsed()")
32  if not self.tab().centerView().isUpdated(object):
33  self.dataAccessor().read(object)
34  self.updateCenterView()
35 
36  def onTreeViewSelected(self,select):
37  EventBrowserTabController.onTreeViewSelected(self,self.dataAccessor().read(select,self._treeDepth))
38 
39  def onSelected(self,select):
40  EventBrowserTabController.onSelected(self,self.dataAccessor().read(select))
41 
42  def updateCenterView(self,propertyView=True):
43  if self.tab().treeView().selection():
44  self.dataAccessor().read(self.tab().treeView().selection(),self._treeDepth)
45  EventBrowserTabController.updateCenterView(self,propertyView)
46 
48  """ Show dialog and expand center view to depth.
49  """
50  if hasattr(QInputDialog, "getInteger"):
51  # Qt 4.3
52  (depth, ok) = QInputDialog.getInteger(self.tab(), "Expand to depth...", "Input depth:", self._treeDepth, 0)
53  else:
54  # Qt 4.5
55  (depth, ok) = QInputDialog.getInt(self.tab(), "Expand to depth...", "Input depth:", self._treeDepth, 0)
56  if ok:
57  self._treeDepth=depth
58  if self.tab().treeView().selection():
59  self.onTreeViewSelected(self.tab().treeView().selection())
60 
61  def centerViewMenuButtonClicked(self, point=None):
62  popup=QMenu(self.tab().centerViewMenuButton())
63  popup.addAction(self.plugin()._expandToDepthAction)
64  popup.addAction(self.plugin()._saveImageAction)
65  popup.addAction(self.plugin()._zoomAction)
66  popup.addAction(self.plugin()._filterAction)
67  popup.addSeparator()
68  for action in self.plugin().viewMenu().actions():
69  if action.data().toString()!="":
70  popup.addAction(action)
71  if not isinstance(point,QPoint):
72  point=self.tab().centerViewMenuButton().mapToGlobal(QPoint(self.tab().centerViewMenuButton().width(),0))
73  popup.exec_(point)
74 
76  self.dataAccessor().setFilterBranches(not self.dataAccessor().filterBranches())
77  self.updateContent()
78  self.saveIni()
79 
81  self.dataAccessor().setUnderscoreProperties(not self.dataAccessor().underscoreProperties())
82  self.tab().propertyView().setDataObject(None)
83  self.updateCenterView()
84  self.saveIni()
85 
86  def loadIni(self):
87  """ read options from ini """
88  EventBrowserTabController.loadIni(self)
89  ini = self.plugin().application().ini()
90  if ini.has_option("edm", "filter branches"):
91  self.dataAccessor().setFilterBranches(ini.get("edm", "filter branches")=="True")
92  if ini.has_option("edm", "underscore properties"):
93  self.dataAccessor().setUnderscoreProperties(ini.get("edm", "underscore properties")=="True")
94  self.plugin().hideUnderscorePropertiesAction().setChecked(not self.dataAccessor().underscoreProperties())
95 
96  def saveIni(self):
97  """ write options to ini """
98  EventBrowserTabController.saveIni(self)
99  ini = self.plugin().application().ini()
100  if not ini.has_section("edm"):
101  ini.add_section("edm")
102  ini.set("edm", "filter branches", self.dataAccessor().filterBranches())
103  ini.set("edm", "underscore properties", self.dataAccessor().underscoreProperties())
104  self.plugin().application().writeIni()
105 
106  def eventContent(self):
107  """ Open event content dialog """
108  logging.debug(__name__ + ": eventContent")
109  dialog=EventContentDialog(self.tab(),"This dialog let's you compare the contents of your edm root file with another dataformat / edm root file. You can compare either to a dataformat definition from a txt file (e.g. RECO_3_3_0) or any edm root file by selecting an input file.")
110  branches=[branch[0].split("_") for branch in self.dataAccessor().filteredBranches()]
111  name = os.path.splitext(os.path.basename(self._filename))[0]
112  dialog.setEventContent(name,branches)
113  dialog.exec_()
roAction_t actions[nactions]
Definition: GenABIO.cc:187
selection
main part
Definition: corrVsCorr.py:98
std::string toString(const char *format,...)
Definition: xdaq_compat.cc:4
double split
Definition: MVATrainer.cc:139