ATLAS Offline Software
VP1CustomTourFrameWidget.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 // //
8 // Implementation of class VP1CustomTourFrameWidget //
9 // //
10 // Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
11 // Initial version: September 2008 //
12 // //
14 
16 #include "VP1Base/VP1Serialise.h"
17 #include "VP1Base/VP1Deserialise.h"
18 #include "ui_vp1customtourframewidget.h"
19 
20 #include <QMouseEvent>
21 #include <QDragEnterEvent>
22 #include <QDropEvent>
23 #include <QPainter>
24 #include <QMimeData>
25 #include <QBuffer>
26 #include <QDrag>
27 #include <QtWidgetsVersion>
28 
29 //____________________________________________________________________
31 public:
34  void init();//call at end of VP1CustomTourFrameWidget constructor(s)
35  Ui::VP1CustomTourFrameWidgetForm ui;
38  QByteArray camState;
39 
40 };
41 
42 //____________________________________________________________________
44  : theclass(tc), camPerspective(true)
45 {
46  ui.setupUi(theclass);
47  ui.label_snapshot->setText("");
48 
49  int maxheight = static_cast<int>(0.5+QFontMetricsF(ui.pushButton_remove->font()).height()*1.05+2);
50  ui.pushButton_remove->setMaximumHeight(maxheight);
51  ui.pushButton_show->setMaximumHeight(maxheight);
52  ui.checkBox_frameEnabled->setMaximumHeight(maxheight);
53  ui.label_snapshot->setMinimumSize(QSize(snapShotWidth(),snapShotHeight()));
54  ui.label_snapshot->setMaximumSize(QSize(snapShotWidth(),snapShotHeight()));
55 
56  connect(ui.pushButton_moveEarlier,SIGNAL(clicked()),theclass,SLOT(buttonClicked()));
57  connect(ui.pushButton_moveLater,SIGNAL(clicked()),theclass,SLOT(buttonClicked()));
58  connect(ui.pushButton_remove,SIGNAL(clicked()),theclass,SLOT(buttonClicked()));
59  connect(ui.pushButton_show,SIGNAL(clicked()),theclass,SLOT(buttonClicked()));
60  connect(ui.checkBox_frameEnabled,SIGNAL(toggled(bool)),theclass,SLOT(frameEnabledToggled()));
61 
62  theclass->setAcceptDrops(true);
63  ui.label_camtypeicon->setText("");
64 }
65 
66 //____________________________________________________________________
68 {
69  ui.label_camtypeicon->setPixmap(QPixmap( camPerspective
70  ?":/icons/icons/perspective.png"
71  :":/icons/icons/ortho.png") );
72 
73  theclass->frameEnabledToggled();
74 }
75 
76 //____________________________________________________________________
78  const QByteArray& camState,
79  QWidget * parent)
80  : QFrame(parent), m_d(new Imp(this))
81 {
82  m_d->camPerspective = camPerspective;
84  m_d->init();
85 }
86 
87 //____________________________________________________________________
88 VP1CustomTourFrameWidget::VP1CustomTourFrameWidget( const QByteArray& serialisedFrame,
89  QWidget * parent )
90  : QFrame(parent), m_d(new Imp(this))
91 {
92  VP1Deserialise s(serialisedFrame);
93  m_d->camState = s.restoreByteArray();
94  m_d->camPerspective = s.restoreBool();
95  s.restore(m_d->ui.doubleSpinBox_zoomToFrameTime);
96  s.restore(m_d->ui.doubleSpinBox_stayOnFrameTime);
97  if (s.version()>0) {
98  s.restore(m_d->ui.doubleSpinBox_clipVolumePercentOfATLAS);
99  }
100  s.restore(m_d->ui.comboBox_approachMethod);
101  s.restore(m_d->ui.checkBox_frameEnabled);
102  QPixmap pm = s.restore<QPixmap>();
103  if (!pm.isNull())
104  m_d->ui.label_snapshot->setPixmap(pm);
105  s.warnUnrestored(this);
106  m_d->init();
107 }
108 
109 //____________________________________________________________________
111 {
112  VP1Serialise s(1/*version*/);
113  s.save(m_d->camState);
114  s.save(m_d->camPerspective);
115  s.save(m_d->ui.doubleSpinBox_zoomToFrameTime);
116  s.save(m_d->ui.doubleSpinBox_stayOnFrameTime);
117  s.save(m_d->ui.doubleSpinBox_clipVolumePercentOfATLAS);
118  s.save(m_d->ui.comboBox_approachMethod);
119  s.save(m_d->ui.checkBox_frameEnabled);
120 #if QTWIDGETS_VERSION >= 0x050F00
121  s.save(m_d->ui.label_snapshot->pixmap(Qt::ReturnByValue));
122 #else
123  s.save(m_d->ui.label_snapshot->pixmap() ? *(m_d->ui.label_snapshot->pixmap()) : QPixmap());
124 #endif
125  s.warnUnsaved(this);
126  return s.result();
127 }
128 
129 //____________________________________________________________________
131 {
132  delete m_d;
133 }
134 
135 //____________________________________________________________________
137 {
138  if (sender()==m_d->ui.pushButton_moveEarlier)
139  emit requestStepToEarlier();
140  else if (sender()==m_d->ui.pushButton_moveLater)
141  emit requestStepToLater();
142  else if (sender()==m_d->ui.pushButton_remove)
143  emit requestDelete();
144  else if (sender()==m_d->ui.pushButton_show)
145  emit requestShow();
146 }
147 
148 //____________________________________________________________________
150 {
151 
152  return m_d->ui.checkBox_frameEnabled->isChecked();
153 }
154 
155 //____________________________________________________________________
157 {
158  return m_d->ui.comboBox_approachMethod->currentIndex()==0;
159 }
160 //____________________________________________________________________
162 {
163  return m_d->ui.comboBox_approachMethod->currentIndex()==2;
164 }
165 
166 //____________________________________________________________________
168 {
169  return m_d->ui.doubleSpinBox_zoomToFrameTime->value();
170 }
171 
172 //____________________________________________________________________
174 {
175  return m_d->ui.doubleSpinBox_stayOnFrameTime->value();
176 }
177 
178 //____________________________________________________________________
180 {
181  return m_d->ui.doubleSpinBox_clipVolumePercentOfATLAS->value();
182 }
183 
184 //____________________________________________________________________
186 {
187  return m_d->camPerspective;
188 }
189 
190 //____________________________________________________________________
191 const QByteArray& VP1CustomTourFrameWidget::camState() const
192 {
193  return m_d->camState;
194 }
195 
196 //____________________________________________________________________
198 {
199  m_d->ui.pushButton_moveEarlier->setVisible(b);
200 }
201 
202 //____________________________________________________________________
204 {
205  m_d->ui.pushButton_moveLater->setVisible(b);
206 }
207 
208 //____________________________________________________________________
210 {
211  if (event->button() == Qt::LeftButton)
212  m_d->dragStartPosition = event->pos();
213  QFrame::mousePressEvent(event);
214 }
215 
216 //____________________________________________________________________
218 {
219  if (!(event->buttons() & Qt::LeftButton))
220  return;
221  if ((event->pos() - m_d->dragStartPosition).manhattanLength()
222  < QApplication::startDragDistance())
223  return;
224  QDrag *drag = new QDrag(this);
225  QMimeData *mimeData = new QMimeData;
226  mimeData->setData("vp1/customtourframe", QByteArray() );
227  drag->setMimeData(mimeData);//drag assumes ownership of mimeData
228 #if QTWIDGETS_VERSION >= 0x050F00
229  QPixmap pm = m_d->ui.label_snapshot->pixmap(Qt::ReturnByValue);
230 #else
231  QPixmap pm = m_d->ui.label_snapshot->pixmap() ? *(m_d->ui.label_snapshot->pixmap()) : QPixmap();
232 #endif
233  if (!pm.isNull())
234  drag->setPixmap(pm );
235  drag->exec(Qt::CopyAction | Qt::MoveAction);
236 }
237 
238 //____________________________________________________________________
240 {
241  if (event->source()&&event->source()!=this && event->mimeData()->hasFormat("vp1/customtourframe"))
242  event->acceptProposedAction();
243 }
244 
245 //____________________________________________________________________
247 {
248  QByteArray data = event->mimeData()->data("vp1/customtourframe");
249  event->acceptProposedAction();
250  VP1CustomTourFrameWidget * source = dynamic_cast<VP1CustomTourFrameWidget *>(event->source());
251  emit requestSwap(this,source);
252 }
253 
254 //____________________________________________________________________
256 {
257  if (pm.isNull())
258  return;
259  m_d->ui.label_snapshot->setPixmap(pm);
260 }
261 
262 //____________________________________________________________________
264 {
265  m_d->ui.label_snapshot->setEnabled(frameIsEnabled());
266  m_d->ui.label_camtypeicon->setEnabled(frameIsEnabled());
268 }
VP1Serialise.h
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
VP1Deserialise.h
VP1Serialise
Definition: VP1Serialise.h:45
VP1CustomTourFrameWidget::camState
const QByteArray & camState() const
Definition: VP1CustomTourFrameWidget.cxx:191
VP1CustomTourFrameWidget::Imp::dragStartPosition
QPoint dragStartPosition
Definition: VP1CustomTourFrameWidget.cxx:36
VP1CustomTourFrameWidget::frameEnableStateChanged
void frameEnableStateChanged()
VP1CustomTourFrameWidget::Imp::theclass
VP1CustomTourFrameWidget * theclass
Definition: VP1CustomTourFrameWidget.cxx:33
VP1CustomTourFrameWidget::zoomToFrameWithVariableSpeed
bool zoomToFrameWithVariableSpeed() const
Definition: VP1CustomTourFrameWidget.cxx:156
fillPileUpNoiseLumi.connect
string connect
Definition: fillPileUpNoiseLumi.py:70
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
VP1CustomTourFrameWidget::snapShotWidth
static int snapShotWidth()
Definition: VP1CustomTourFrameWidget.h:48
VP1CustomTourFrameWidget::requestSwap
void requestSwap(VP1CustomTourFrameWidget *, VP1CustomTourFrameWidget *)
VP1CustomTourFrameWidget::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event)
Definition: VP1CustomTourFrameWidget.cxx:217
VP1CustomTourFrameWidget::requestShow
void requestShow()
VP1CustomTourFrameWidget::setStepToLaterControlsEnabled
void setStepToLaterControlsEnabled(bool)
Definition: VP1CustomTourFrameWidget.cxx:203
VP1CustomTourFrameWidget::requestStepToLater
void requestStepToLater()
VP1CustomTourFrameWidget::zoomToFrameTime
double zoomToFrameTime() const
Definition: VP1CustomTourFrameWidget.cxx:167
VP1CustomTourFrameWidget::dropEvent
void dropEvent(QDropEvent *event)
Definition: VP1CustomTourFrameWidget.cxx:246
VP1CustomTourFrameWidget::requestDelete
void requestDelete()
VP1CustomTourFrameWidget::frameEnabledToggled
void frameEnabledToggled()
Definition: VP1CustomTourFrameWidget.cxx:263
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
VP1CustomTourFrameWidget::Imp
Definition: VP1CustomTourFrameWidget.cxx:30
VP1CustomTourFrameWidget::zoomToFrameForcedCircular
bool zoomToFrameForcedCircular() const
Definition: VP1CustomTourFrameWidget.cxx:161
VP1CustomTourFrameWidget::Imp::camPerspective
bool camPerspective
Definition: VP1CustomTourFrameWidget.cxx:37
test_pyathena.parent
parent
Definition: test_pyathena.py:15
VP1CustomTourFrameWidget::clipVolumePercentOfATLAS
double clipVolumePercentOfATLAS() const
Definition: VP1CustomTourFrameWidget.cxx:179
VP1Deserialise
Definition: VP1Deserialise.h:44
VP1CustomTourFrameWidget::serialise
QByteArray serialise() const
Definition: VP1CustomTourFrameWidget.cxx:110
VP1CustomTourFrameWidget::buttonClicked
void buttonClicked()
Definition: VP1CustomTourFrameWidget.cxx:136
VP1CustomTourFrameWidget::setStepToEarlierControlsEnabled
void setStepToEarlierControlsEnabled(bool)
Definition: VP1CustomTourFrameWidget.cxx:197
VP1CustomTourFrameWidget::m_d
Imp * m_d
Definition: VP1CustomTourFrameWidget.h:73
VP1CustomTourFrameWidget::dragEnterEvent
void dragEnterEvent(QDragEnterEvent *event)
Definition: VP1CustomTourFrameWidget.cxx:239
VP1CustomTourFrameWidget.h
VP1CustomTourFrameWidget::requestStepToEarlier
void requestStepToEarlier()
VP1CustomTourFrameWidget::stayOnFrameTime
double stayOnFrameTime() const
Definition: VP1CustomTourFrameWidget.cxx:173
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
VP1CustomTourFrameWidget::Imp::camState
QByteArray camState
Definition: VP1CustomTourFrameWidget.cxx:38
VP1CustomTourFrameWidget::mousePressEvent
void mousePressEvent(QMouseEvent *event)
Definition: VP1CustomTourFrameWidget.cxx:209
VP1CustomTourFrameWidget::~VP1CustomTourFrameWidget
virtual ~VP1CustomTourFrameWidget()
Definition: VP1CustomTourFrameWidget.cxx:130
VP1CustomTourFrameWidget::setSnapshot
void setSnapshot(QPixmap)
Definition: VP1CustomTourFrameWidget.cxx:255
VP1CustomTourFrameWidget::Imp::init
void init()
Definition: VP1CustomTourFrameWidget.cxx:67
copySelective.source
string source
Definition: copySelective.py:32
VP1CustomTourFrameWidget::frameIsEnabled
bool frameIsEnabled() const
Definition: VP1CustomTourFrameWidget.cxx:149
VP1CustomTourFrameWidget::snapShotHeight
static int snapShotHeight()
Definition: VP1CustomTourFrameWidget.h:49
VP1CustomTourFrameWidget
Definition: VP1CustomTourFrameWidget.h:23
VP1CustomTourFrameWidget::camStateIsPerspective
bool camStateIsPerspective() const
Definition: VP1CustomTourFrameWidget.cxx:185
VP1CustomTourFrameWidget::VP1CustomTourFrameWidget
VP1CustomTourFrameWidget(bool camPerspective, const QByteArray &camState, QWidget *parent=0)
Definition: VP1CustomTourFrameWidget.cxx:77
VP1CustomTourFrameWidget::Imp::ui
Ui::VP1CustomTourFrameWidgetForm ui
Definition: VP1CustomTourFrameWidget.cxx:35
VP1CustomTourFrameWidget::Imp::Imp
Imp(VP1CustomTourFrameWidget *theclass)
Definition: VP1CustomTourFrameWidget.cxx:43