CMS 3D CMS Logo

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