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