ATLAS Offline Software
Loading...
Searching...
No Matches
VP1CustomTourEditor Class Reference

#include <VP1CustomTourEditor.h>

Inheritance diagram for VP1CustomTourEditor:
Collaboration diagram for VP1CustomTourEditor:

Classes

class  Imp

Public Slots

void setClipVolumePercentOfATLAS (double)

Signals

void clipVolumePercentOfATLAS (double)
void clipVolumeRadiusChanged (double)

Public Member Functions

 VP1CustomTourEditor (VP1ExaminerViewer *)
void setState (const QByteArray &)
QByteArray state () const
virtual ~VP1CustomTourEditor ()
void disableObjectWhenTourNotAvailable (QObject *)
bool tourAvailable () const
bool tourIsPerspective () const
void addTourToAnimationSequencer (AnimationSequencer &, bool jumpDirectlyToFirstFrame) const

Protected Member Functions

void closeEvent (QCloseEvent *)

Private Slots

void frameStepToEarlier ()
void frameStepToLater ()
void frameDelete ()
void frameShow ()
void buttonClicked ()
void swap (VP1CustomTourFrameWidget *, VP1CustomTourFrameWidget *)
void enabledFrameListChanged ()

Private Attributes

Impm_d

Detailed Description

Definition at line 26 of file VP1CustomTourEditor.h.

Constructor & Destructor Documentation

◆ VP1CustomTourEditor()

VP1CustomTourEditor::VP1CustomTourEditor ( VP1ExaminerViewer * viewer)

Definition at line 100 of file VP1CustomTourEditor.cxx.

101 : QWidget(0,Qt::WindowStaysOnTopHint), m_d(new Imp)
102{
103
104 m_d->theclass = this;
105 m_d->ui.setupUi(this);
106 m_d->ui.groupBox_utilityZoom->setChecked(false);
107 m_d->ui.widget_utilityZoomContents->setVisible(false);
108 m_d->viewer = viewer;
109 setWindowIcon(QIcon(QString(":/vp1/icons/icons/3d_32x32.png")));
110 m_d->frameHolderWidget = new QWidget;
111 m_d->ui.scrollArea->setWidgetResizable(true);
112 m_d->ui.scrollArea->setWidget(m_d->frameHolderWidget);
113
114 connect(new QShortcut(QKeySequence(Qt::Key_Escape), this),SIGNAL(activated()),this,SLOT(hide()));
115 connect(m_d->ui.pushButton_close,SIGNAL(clicked()),this,SLOT(hide()));
116
117 connect(m_d->ui.pushButton_addCurrentView,SIGNAL(clicked()),this,SLOT(buttonClicked()));
118 connect(m_d->ui.pushButton_refreshPreviews,SIGNAL(clicked()),this,SLOT(buttonClicked()));
119 connect(m_d->ui.pushButton_execute,SIGNAL(clicked()),this,SLOT(buttonClicked()));
120 connect(m_d->ui.pushButton_utilityZoomShow,SIGNAL(clicked()),this,SLOT(buttonClicked()));
121
122 m_d->objectsToDisableWhenTourUnavailable << m_d->ui.pushButton_execute;
123
125}

◆ ~VP1CustomTourEditor()

VP1CustomTourEditor::~VP1CustomTourEditor ( )
virtual

Definition at line 128 of file VP1CustomTourEditor.cxx.

129{
130 m_d->frameHolderWidget->deleteLater();
131 for (VP1CustomTourFrameWidget*frame : m_d->frames)
132 frame->deleteLater();
133 delete m_d;
134}

Member Function Documentation

◆ addTourToAnimationSequencer()

void VP1CustomTourEditor::addTourToAnimationSequencer ( AnimationSequencer & as,
bool jumpDirectlyToFirstFrame ) const

Definition at line 419 of file VP1CustomTourEditor.cxx.

420{
421 if (!tourAvailable())
422 return;
423 bool firstInDirectJump(jumpDirectlyToFirstFrame);
424 for (VP1CustomTourFrameWidget*frame : m_d->frames) {
425 if (frame->frameIsEnabled()) {
426 double t(frame->zoomToFrameTime());
427 if (firstInDirectJump) {
428 t = 0.0;
429 firstInDirectJump = false;
430 }
431
432 // std::cout<<"addTourToAnimationSequencer %="<<frame->clipVolumePercentOfATLAS()<<std::endl;
433 as.sequence().addFrame(frame->camState(),t,
435 frame->clipVolumePercentOfATLAS() );
436 if (frame->stayOnFrameTime()>0.0)
437 as.sequence().addFrame(frame->camState(),frame->stayOnFrameTime(),false, false, frame->clipVolumePercentOfATLAS());
438 }
439 }
440}
void addFrame(REGION reg, const SbVec3f &dir, const SbVec3f &upvec, double t, bool variableSpeed=false, bool forceCircular=false, double clip=100.0)
AnimationSequence & sequence()
const QByteArray & camState() const

◆ buttonClicked

void VP1CustomTourEditor::buttonClicked ( )
privateslot

Definition at line 299 of file VP1CustomTourEditor.cxx.

300{
301 if (m_d->ui.pushButton_addCurrentView==sender()) {
302 VP1CustomTourFrameWidget * frame = new VP1CustomTourFrameWidget(m_d->viewer->currentCamIsPerspective(),
303 m_d->viewer->currentCameraState());
304 m_d->addFrame(frame);
305 m_d->updateFrameSnapshot(frame);
306 m_d->updateFrameListVisuals();
307 } else if (m_d->ui.pushButton_refreshPreviews==sender()) {
308 for (VP1CustomTourFrameWidget*frame : m_d->frames)
309 m_d->updateFrameSnapshot(frame);
310 } else if (m_d->ui.pushButton_execute==sender()) {
311 m_d->viewer->startCustomTour();
312 } else if (m_d->ui.pushButton_utilityZoomShow==sender()) {
313 SoCamera * cam = m_d->viewer->getCamera();
314 SoNode * root = m_d->viewer->getSceneGraph();
315 if (!cam||!root||!root->getTypeId().isDerivedFrom(SoGroup::getClassTypeId()))
316 return;
317
318 double r(m_d->ui.doubleSpinBox_radius->value()*1000.0/*meters*/);
319 double theta(m_d->ui.doubleSpinBox_theta->value()/180.0*M_PI);
320 theta += M_PI;
321 while (theta<0) theta += 2*M_PI;
322 while (theta>2*M_PI) theta -= 2*M_PI;
323 double a(r/sqrt(3.0));
324 SbBox3f box(-a,-a,-a,a,a,a);
325 SbVec3f lookat = SbVec3f(sin(theta),0,cos(theta));
326 SbVec3f upvec = SbVec3f(0,1,0);
327 bool notifyenabled = cam->enableNotify(false);
328 m_d->viewer->resetCamera();
329 VP1CameraHelper::animatedZoomToBBox( cam,static_cast<SoGroup*>(root),
330 box, 0.0, 100.0, 1.0,lookat,upvec);
331 if (notifyenabled)
332 cam->enableNotify(true);//Don't touch here - to avoid showing
333 //the reset cam state (the camera helper
334 //will touch it when modifying it)
335 }
336}
#define M_PI
Scalar theta() const
theta method
static Double_t a
static VP1CameraHelper * animatedZoomToBBox(SoCamera *camera, SoGroup *sceneroot, const SbBox3f &box, double duration_in_secs=1.0, double clipVolPercent=100.0, double slack=1.0, const SbVec3f &lookat=SbVec3f(999, 999, 999), const SbVec3f &upvec=SbVec3f(999, 999, 999), bool varySpeed=true, bool forceCircular=false)
int r
Definition globals.cxx:22

◆ clipVolumePercentOfATLAS

void VP1CustomTourEditor::clipVolumePercentOfATLAS ( double )
signal

◆ clipVolumeRadiusChanged

void VP1CustomTourEditor::clipVolumeRadiusChanged ( double )
signal

◆ closeEvent()

void VP1CustomTourEditor::closeEvent ( QCloseEvent * ev)
protected

Definition at line 137 of file VP1CustomTourEditor.cxx.

138{
139 ev->ignore();
140 hide();
141}
int ev
Definition globals.cxx:25

◆ disableObjectWhenTourNotAvailable()

void VP1CustomTourEditor::disableObjectWhenTourNotAvailable ( QObject * o)

Definition at line 451 of file VP1CustomTourEditor.cxx.

452{
453 if (o)
454 m_d->objectsToDisableWhenTourUnavailable << o;
455}

◆ enabledFrameListChanged

void VP1CustomTourEditor::enabledFrameListChanged ( )
privateslot

Definition at line 366 of file VP1CustomTourEditor.cxx.

367{
368 int nEnabledPerspectiveFrames, nEnabledOrthographicFrames;
369 int n = m_d->countEnabledFrames( nEnabledPerspectiveFrames,
370 nEnabledOrthographicFrames );
371 QString s("dummy");
372 bool enable(true);
373 if (n<2) {
374 s = "Add at least two frames for tour";
375 enable=false;
376 } else {
377 if (nEnabledPerspectiveFrames>0&&nEnabledOrthographicFrames>0) {
378 s = "Mixed camera types are forbidden";
379 enable=false;
380 } else {
381 if (nEnabledPerspectiveFrames>0)
382 s="Perspective camera tour";
383 else
384 s="Orthographic camera tour";
385 }
386 }
387 m_d->ui.label_statustext->setText(s);
388
389 for (QObject * o : m_d->objectsToDisableWhenTourUnavailable) {
390 if (o->isWidgetType())
391 static_cast<QWidget*>(o)->setEnabled(enable);
392 else
393 static_cast<QAction*>(o)->setEnabled(enable);
394 }
395}

◆ frameDelete

void VP1CustomTourEditor::frameDelete ( )
privateslot

Definition at line 220 of file VP1CustomTourEditor.cxx.

221{
222 VP1CustomTourFrameWidget * frame = dynamic_cast<VP1CustomTourFrameWidget*>(sender());
223 if (!frame)
224 return;
225 m_d->frames.removeAll(frame);
226 frame->deleteLater();
227 m_d->updateFrameStepControlsEnablement();
229}

◆ frameShow

void VP1CustomTourEditor::frameShow ( )
privateslot

Definition at line 232 of file VP1CustomTourEditor.cxx.

233{
234 VP1CustomTourFrameWidget * frame = dynamic_cast<VP1CustomTourFrameWidget*>(sender());
235 if (!frame)
236 return;
237
238 if (frame->camStateIsPerspective()==m_d->viewer->currentCamIsPerspective()) {
239 //Zoom there:
240 SoCamera * cam = m_d->viewer->getCamera();
241 SoNode * root = m_d->viewer->getSceneGraph();
242 if (!cam||!root||!root->getTypeId().isDerivedFrom(SoGroup::getClassTypeId()))
243 return;
244
245 if (m_d->viewer->isAnimating())
246 m_d->viewer->stopAnimating();
247 VP1CameraHelper::animatedZoomToCameraState( cam,static_cast<SoGroup*>(root),frame->camState(),
248 frame->zoomToFrameTime(),
251 frame->zoomToFrameForcedCircular() );
252 } else {
253 //Go there directly:
254 m_d->viewer->toggleCameraType();
255 SoCamera * cam = m_d->viewer->getCamera();
256 if (!cam)
257 return;
258 QByteArray ba(frame->camState());
260 }
261}
static VP1CameraHelper * animatedZoomToCameraState(SoCamera *camera, SoGroup *sceneroot, const QByteArray &camstate, double duration_in_secs=1.0, double clipVolPercent=100.0, double lastClipVolPercent=100.0, bool varySpeed=true, bool forceCircular=false)
static bool deserializeSoCameraParameters(QByteArray &, SoCamera &)

◆ frameStepToEarlier

void VP1CustomTourEditor::frameStepToEarlier ( )
privateslot

Definition at line 190 of file VP1CustomTourEditor.cxx.

191{
192 int iframe(m_d->frames.indexOf(dynamic_cast<VP1CustomTourFrameWidget*>(sender())));
193 if (iframe<=0)
194 return;//not found or already at start
195#if QTCORE_VERSION >= 0x050D00
196 m_d->frames.swapItemsAt(iframe-1,iframe);
197#else
198 m_d->frames.swap(iframe-1,iframe);
199#endif
200 m_d->updateFrameListVisuals();
201}

◆ frameStepToLater

void VP1CustomTourEditor::frameStepToLater ( )
privateslot

Definition at line 204 of file VP1CustomTourEditor.cxx.

205{
206 int iframe(m_d->frames.indexOf(dynamic_cast<VP1CustomTourFrameWidget*>(sender())));
207 if (iframe<0)
208 return;
209 if (iframe>=m_d->frames.count()-1)
210 return;//already at end
211#if QTCORE_VERSION >= 0x050D00
212 m_d->frames.swapItemsAt(iframe,iframe+1);
213#else
214 m_d->frames.swap(iframe,iframe+1);
215#endif
216 m_d->updateFrameListVisuals();
217}

◆ setClipVolumePercentOfATLAS

void VP1CustomTourEditor::setClipVolumePercentOfATLAS ( double percent)
slot

Definition at line 442 of file VP1CustomTourEditor.cxx.

442 {
443 emit clipVolumePercentOfATLAS( percent );
444
445 // Let's assume ATLAS is 40m long. So emit this.
446 emit clipVolumeRadiusChanged( percent * 400 );
447}
void clipVolumeRadiusChanged(double)
void clipVolumePercentOfATLAS(double)

◆ setState()

void VP1CustomTourEditor::setState ( const QByteArray & ba)

Definition at line 75 of file VP1CustomTourEditor.cxx.

76{
77 for (VP1CustomTourFrameWidget*frame : m_d->frames)
78 frame->deleteLater();
79 m_d->frames.clear();
80
81 VP1Deserialise s(ba);
82 if (s.version()!=0)
83 return;
84 QList<QByteArray> frameStates = s.restore<QList<QByteArray> >();
85 s.restore(m_d->ui.doubleSpinBox_theta);
86 s.restore(m_d->ui.doubleSpinBox_radius);
87 s.restore(m_d->ui.groupBox_utilityZoom);
88 s.warnUnrestored(this);
89
90 m_d->ui.widget_utilityZoomContents->setVisible(m_d->ui.groupBox_utilityZoom->isChecked());
91
92 for (const QByteArray& ba2 : frameStates)
93 m_d->addFrame(new VP1CustomTourFrameWidget(ba2));
94 m_d->updateFrameListVisuals();
96}

◆ state()

QByteArray VP1CustomTourEditor::state ( ) const

Definition at line 58 of file VP1CustomTourEditor.cxx.

59{
60 VP1Serialise s(0/*version*/);
61 QList<QByteArray> frameStates;
62 for (VP1CustomTourFrameWidget*frame : m_d->frames) {
63 frameStates << frame->serialise();
64 s.ignoreWidget(frame);
65 }
66 s.save(frameStates);
67 s.save(m_d->ui.doubleSpinBox_theta);
68 s.save(m_d->ui.doubleSpinBox_radius);
69 s.save(m_d->ui.groupBox_utilityZoom);
70 s.warnUnsaved(this);
71 return s.result();
72}

◆ swap

void VP1CustomTourEditor::swap ( VP1CustomTourFrameWidget * frame1,
VP1CustomTourFrameWidget * frame2 )
privateslot

Definition at line 279 of file VP1CustomTourEditor.cxx.

281{
282 int iframe1(m_d->frames.indexOf(frame1));
283 int iframe2(m_d->frames.indexOf(frame2));
284 if ( iframe1==iframe2
285 ||iframe1<0
286 ||iframe2<0
287 ||iframe1>=m_d->frames.count()
288 ||iframe2>=m_d->frames.count() )
289 return;
290#if QTCORE_VERSION >= 0x050D00
291 m_d->frames.swapItemsAt(iframe1,iframe2);
292#else
293 m_d->frames.swap(iframe1,iframe2);
294#endif
295 m_d->updateFrameListVisuals();
296}

◆ tourAvailable()

bool VP1CustomTourEditor::tourAvailable ( ) const

Definition at line 398 of file VP1CustomTourEditor.cxx.

399{
400 int nEnabledPerspectiveFrames, nEnabledOrthographicFrames;
401 int n = m_d->countEnabledFrames( nEnabledPerspectiveFrames,
402 nEnabledOrthographicFrames );
403 if (nEnabledPerspectiveFrames>0&&nEnabledOrthographicFrames>0)
404 return false;
405 return n>=2;
406}

◆ tourIsPerspective()

bool VP1CustomTourEditor::tourIsPerspective ( ) const

Definition at line 409 of file VP1CustomTourEditor.cxx.

410{
411 int nEnabledPerspectiveFrames, nEnabledOrthographicFrames;
412 m_d->countEnabledFrames( nEnabledPerspectiveFrames,
413 nEnabledOrthographicFrames );
414
415 return nEnabledOrthographicFrames==0;
416}

Member Data Documentation

◆ m_d

Imp* VP1CustomTourEditor::m_d
private

Definition at line 67 of file VP1CustomTourEditor.h.


The documentation for this class was generated from the following files: