17 #include "ui_vp1customtoureditor.h"
26 #include <Inventor/nodes/SoGroup.h>
27 #include <Inventor/nodes/SoCamera.h>
28 #include <Inventor/SbBox.h>
32 #include <QCloseEvent>
34 #include <QtCoreVersion>
42 Ui::VP1CustomTourEditorForm
ui;
45 QList<VP1CustomTourFrameWidget*>
frames;
51 int& nEnabledOrthographicFrames )
const;
61 QList<QByteArray> frameStates;
64 s.ignoreWidget(frame);
67 s.save(
m_d->
ui.doubleSpinBox_theta);
68 s.save(
m_d->
ui.doubleSpinBox_radius);
69 s.save(
m_d->
ui.groupBox_utilityZoom);
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);
90 m_d->
ui.widget_utilityZoomContents->setVisible(
m_d->
ui.groupBox_utilityZoom->isChecked());
92 for (QByteArray ba2 : frameStates)
101 : QWidget(0,Qt::WindowStaysOnTopHint), m_d(
new Imp)
105 m_d->
ui.setupUi(
this);
106 m_d->
ui.groupBox_utilityZoom->setChecked(
false);
107 m_d->
ui.widget_utilityZoomContents->setVisible(
false);
109 setWindowIcon(QIcon(QString(
":/vp1/icons/icons/3d_32x32.png")));
111 m_d->
ui.scrollArea->setWidgetResizable(
true);
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()));
132 frame->deleteLater();
160 bool save = frameHolderWidget->updatesEnabled();
162 frameHolderWidget->setUpdatesEnabled(
false);
163 int sliderpos=ui.scrollArea->verticalScrollBar()->value();
164 for (QObject * o : frameHolderWidget->children()) {
165 if (o->isWidgetType()) {
166 static_cast<QWidget*
>(o)->setVisible(
false);
170 delete frameHolderWidget->layout();
171 QVBoxLayout * vlayout =
new QVBoxLayout;
173 vlayout->addWidget(frame);
174 frame->setParent(frameHolderWidget);
175 frame->setVisible(
true);
177 vlayout->addStretch(1);
178 frameHolderWidget->setLayout(vlayout);
179 updateFrameStepControlsEnablement();
180 sliderpos=
std::max(ui.scrollArea->verticalScrollBar()->minimum(),
181 std::min(ui.scrollArea->verticalScrollBar()->maximum(),sliderpos));
182 ui.scrollArea->verticalScrollBar()->setValue(sliderpos);
183 theclass->enabledFrameListChanged();
185 frameHolderWidget->setUpdatesEnabled(
true);
195 #if QTCORE_VERSION >= 0x050D00
196 m_d->
frames.swapItemsAt(iframe-1,iframe);
211 #if QTCORE_VERSION >= 0x050D00
212 m_d->
frames.swapItemsAt(iframe,iframe+1);
226 frame->deleteLater();
240 SoCamera * cam =
m_d->
viewer->getCamera();
242 if (!cam||!
root||!
root->getTypeId().isDerivedFrom(SoGroup::getClassTypeId()))
255 SoCamera * cam =
m_d->
viewer->getCamera();
266 for (
int i = 0;
i < frames.count(); ++
i) {
268 bool earlier(
true), later(
true);
271 if (
i==frames.count()-1)
282 int iframe1(
m_d->
frames.indexOf(frame1));
283 int iframe2(
m_d->
frames.indexOf(frame2));
284 if ( iframe1==iframe2
290 #if QTCORE_VERSION >= 0x050D00
291 m_d->
frames.swapItemsAt(iframe1,iframe2);
301 if (
m_d->
ui.pushButton_addCurrentView==sender()) {
307 }
else if (
m_d->
ui.pushButton_refreshPreviews==sender()) {
310 }
else if (
m_d->
ui.pushButton_execute==sender()) {
312 }
else if (
m_d->
ui.pushButton_utilityZoomShow==sender()) {
313 SoCamera * cam =
m_d->
viewer->getCamera();
315 if (!cam||!
root||!
root->getTypeId().isDerivedFrom(SoGroup::getClassTypeId()))
318 double r(
m_d->
ui.doubleSpinBox_radius->value()*1000.0);
323 double a(
r/sqrt(3.0));
324 SbBox3f box(-
a,-
a,-
a,
a,
a,
a);
326 SbVec3f upvec = SbVec3f(0,1,0);
327 bool notifyenabled = cam->enableNotify(
false);
330 box, 0.0, 100.0, 1.0,lookat,upvec);
332 cam->enableNotify(
true);
349 int& nEnabledOrthographicFrames )
const
351 nEnabledPerspectiveFrames = 0;
352 nEnabledOrthographicFrames = 0;
354 if (frame->frameIsEnabled()) {
355 if (frame->camStateIsPerspective())
356 ++nEnabledPerspectiveFrames;
358 ++nEnabledOrthographicFrames;
361 return nEnabledPerspectiveFrames+nEnabledOrthographicFrames;
368 int nEnabledPerspectiveFrames, nEnabledOrthographicFrames;
370 nEnabledOrthographicFrames );
374 s =
"Add at least two frames for tour";
377 if (nEnabledPerspectiveFrames>0&&nEnabledOrthographicFrames>0) {
378 s =
"Mixed camera types are forbidden";
381 if (nEnabledPerspectiveFrames>0)
382 s=
"Perspective camera tour";
384 s=
"Orthographic camera tour";
387 m_d->
ui.label_statustext->setText(
s);
390 if (o->isWidgetType())
391 static_cast<QWidget*
>(o)->setEnabled(enable);
393 static_cast<QAction*
>(o)->setEnabled(enable);
400 int nEnabledPerspectiveFrames, nEnabledOrthographicFrames;
402 nEnabledOrthographicFrames );
403 if (nEnabledPerspectiveFrames>0&&nEnabledOrthographicFrames>0)
411 int nEnabledPerspectiveFrames, nEnabledOrthographicFrames;
413 nEnabledOrthographicFrames );
415 return nEnabledOrthographicFrames==0;
423 bool firstInDirectJump(jumpDirectlyToFirstFrame);
427 if (firstInDirectJump) {
429 firstInDirectJump =
false;