CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
StartupScreen.py
Go to the documentation of this file.
1 import logging
2 
3 from PyQt4.QtCore import SIGNAL,QRect,QSize,QPoint
4 from PyQt4.QtGui import QToolButton,QIcon,QPixmap,QGridLayout,QLabel,QListWidget,QWidget
5 from PyQt4.QtSvg import QSvgRenderer, QSvgWidget
6 
7 from Vispa.Gui.VispaWidget import VispaWidget
8 
9 import Resources
10 
12 
13  # inherited parameters
14  BACKGROUND_SHAPE = 'ROUNDRECT'
15  SELECTABLE_FLAG = False
16  AUTOSIZE = True
17  AUTOSIZE_KEEP_ASPECT_RATIO = False
18 
19  PROTOTYPING_DESCRIPTION = """Prototyping"""
20 
21  EXECUTING_DESCRIPTION = """Executing"""
22 
23  VERIFYING_DESCRIPTION = """Verifying"""
24 
25  def __init__(self, parent):
27  self._descriptionActiveRects = [QRect(), QRect(), QRect()] # descriptions will be visible if mouse cursor is in the rect
28  VispaWidget.__init__(self, parent)
29  self._filenewIcon = QIcon(QPixmap(":/resources/filenew.svg"))
30  self._fileopenIcon = QIcon(QPixmap(":/resources/fileopen.svg"))
31  self.setImage(QSvgRenderer(":/resources/startup_development_cycle.svg"))
32  self.setDragable(False)
33  self.setMouseTracking(True) # receive mouse events even if no button is pressed
34  self._hideDescriptions = False
35 
39 
40  def createDescriptionWidget(self, arrowDirection, description):
41  widget = VispaWidget(self.parent())
42  widget.enableAutosizing(True, False)
43  widget.setSelectable(False)
44  widget.setArrowShape(arrowDirection)
45  widget.setVisible(not self._hideDescriptions)
46  widget.setDragable(False)
47  self._descriptionWidgets.append(widget)
48  return widget
49 
51  self._prototypingDescriptionWidget = self.createDescriptionWidget(VispaWidget.ARROW_SHAPE_BOTTOM, self.PROTOTYPING_DESCRIPTION)
52 
53  bodyWidget = QWidget(self._prototypingDescriptionWidget)
54  bodyWidget.setLayout(QGridLayout())
55  bodyWidget.layout().setContentsMargins(0, 0, 0, 0)
56 
57  bodyWidget.layout().addWidget(QLabel("Design physics analysis:"), 0, 0)
58  analysisDesignerButton = QToolButton()
59  analysisDesignerButton.setText("Analysis Designer")
60  analysisDesignerButton.setIcon(self._filenewIcon)
61  self.connect(analysisDesignerButton, SIGNAL("clicked(bool)"), self.parent().newAnalysisDesignerSlot)
62  bodyWidget.layout().addWidget(analysisDesignerButton, 0, 1)
63  bodyWidget.layout().addWidget(QLabel("Create physics event:"), 1, 0)
64  pxlButton = QToolButton()
65  pxlButton.setText("PXL Editor")
66  pxlButton.setIcon(self._filenewIcon)
67  self.connect(pxlButton, SIGNAL("clicked(bool)"), self.parent().newPxlSlot)
68  bodyWidget.layout().addWidget(pxlButton, 1, 1)
69 
70  self._prototypingDescriptionWidget.setBodyWidget(bodyWidget)
71 
73  self._executionDescriptionWidget = self.createDescriptionWidget(VispaWidget.ARROW_SHAPE_RIGHT, self.EXECUTING_DESCRIPTION)
74 
75  bodyWidget = QWidget(self._executionDescriptionWidget)
76  bodyWidget.setLayout(QGridLayout())
77  bodyWidget.layout().setContentsMargins(0, 0, 0, 0)
78 
79  label=QLabel("Open and run existing analysis:")
80  bodyWidget.layout().addWidget(label, 0, 0)
81  analysisDesignerButton = QToolButton()
82  analysisDesignerButton.setText("Open analysis file")
83  analysisDesignerButton.setIcon(self._fileopenIcon)
84  self.connect(analysisDesignerButton, SIGNAL("clicked(bool)"), self.parent().openAnalysisFileSlot)
85  bodyWidget.layout().addWidget(analysisDesignerButton, 0, 1)
87  self._analysisDesignerRecentFilesList.setFixedSize(label.sizeHint().width()+analysisDesignerButton.sizeHint().width(),150)
88  self.connect(self._analysisDesignerRecentFilesList, SIGNAL("doubleClicked(QModelIndex)"), self.parent().openAnalysisFileSlot)
89  bodyWidget.layout().addWidget(self._analysisDesignerRecentFilesList, 1, 0, 1, 2)
90 
91  self._executionDescriptionWidget.setBodyWidget(bodyWidget)
92 
95 
97  self._verifyingDescriptionWidget = self.createDescriptionWidget(VispaWidget.ARROW_SHAPE_LEFT, self.VERIFYING_DESCRIPTION)
98 
99  bodyWidget = QWidget(self._verifyingDescriptionWidget)
100  bodyWidget.setLayout(QGridLayout())
101  bodyWidget.layout().setContentsMargins(0, 0, 0, 0)
102 
103  label=QLabel("Browse an existing PXL data file:")
104  bodyWidget.layout().addWidget(label, 0, 0)
105  analysisDesignerButton = QToolButton()
106  analysisDesignerButton.setText("Open PXL file")
107  analysisDesignerButton.setIcon(self._fileopenIcon)
108  self.connect(analysisDesignerButton, SIGNAL("clicked(bool)"), self.parent().openPxlFileSlot)
109  bodyWidget.layout().addWidget(analysisDesignerButton, 0, 1)
110  self._pxlEditorRecentFilesList=QListWidget()
111  self._pxlEditorRecentFilesList.setFixedSize(label.sizeHint().width()+analysisDesignerButton.sizeHint().width(),150)
112  self.connect(self._pxlEditorRecentFilesList, SIGNAL("doubleClicked(QModelIndex)"), self.parent().openPxlFileSlot)
113  bodyWidget.layout().addWidget(self._pxlEditorRecentFilesList, 1, 0, 1, 2)
114 
115  self._verifyingDescriptionWidget.setBodyWidget(bodyWidget)
116 
118  return self._pxlEditorRecentFilesList
119 
120  def mouseMoveEvent(self, event):
121  if bool(event.buttons()):
122  VispaWidget.mouseMoveEvent(self, event)
123  elif self._hideDescriptions:
124  for i in range(len(self._descriptionWidgets)):
125  self._descriptionWidgets[i].setVisible(self._descriptionActiveRects[i].contains(event.pos()))
126 
127  def moveEvent(self, event):
128  VispaWidget.moveEvent(self, event)
130 
131  def rearangeContent(self):
132  VispaWidget.rearangeContent(self)
134 
136  self._activeSize = QSize(0.3 * self.width(), 0.1 * self.height())
137  self._prototypingRect = QRect(QPoint(0.5 * (self.width() - self._activeSize.width()), 0), self._activeSize)
138  self._executionRect = QRect(QPoint(0, 0.635 * self.height()), self._activeSize)
139  self._verifyingRect = QRect(QPoint(self.width() -self._activeSize.width(), 0.635 * self.height()), self._activeSize)
143 
144  self._prototypingDescriptionWidget.move(self.mapToParent(self._prototypingRect.topLeft()) + QPoint((self._prototypingRect.width() - self._prototypingDescriptionWidget.width()) * 0.5, - self._prototypingDescriptionWidget.height()))
145  self._executionDescriptionWidget.move(self.mapToParent(self._executionRect.topLeft()) - QPoint(self._executionDescriptionWidget.width(), - 0.5 * (self._executionRect.height() - self._executionDescriptionWidget.height())))
146  self._verifyingDescriptionWidget.move(self.mapToParent(self._verifyingRect.topRight()) - QPoint(0, - 0.5 * (self._verifyingRect.height() - self._verifyingDescriptionWidget.height())))
147 
148  def boundingRect(self):
149  br = VispaWidget.boundingRect(self)
150  for w in self._descriptionWidgets:
151  br = br.united(w.boundingRect())
152  return br
153 
154  def setVisible(self, visible):
155  VispaWidget.setVisible(self, visible)
156  self._executionDescriptionWidget.setVisible(visible and not self._hideDescriptions)
157  self._prototypingDescriptionWidget.setVisible(visible and not self._hideDescriptions)
158  self._verifyingDescriptionWidget.setVisible(visible and not self._hideDescriptions)
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:38