ATLAS Offline Software
Loading...
Searching...
No Matches
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
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//____________________________________________________________________
31public:
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;
83 m_d->camState = camState;
84 m_d->init();
85}
86
87//____________________________________________________________________
88VP1CustomTourFrameWidget::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//____________________________________________________________________
134
135//____________________________________________________________________
137{
138 if (sender()==m_d->ui.pushButton_moveEarlier)
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//____________________________________________________________________
191const 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}
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
static Double_t tc
Imp(VP1CustomTourFrameWidget *theclass)
Ui::VP1CustomTourFrameWidgetForm ui
const QByteArray & camState() const
void requestSwap(VP1CustomTourFrameWidget *, VP1CustomTourFrameWidget *)
void mouseMoveEvent(QMouseEvent *event)
void dragEnterEvent(QDragEnterEvent *event)
VP1CustomTourFrameWidget(bool camPerspective, const QByteArray &camState, QWidget *parent=0)
void mousePressEvent(QMouseEvent *event)