10 #include "ui_animationDlg.h"
22 #include <QApplication>
24 #include <QDialogButtonBox>
25 #include <QMdiSubWindow>
26 #include <QProgressDialog>
27 #include <QPushButton>
28 #include <QtConcurrentRun>
32 class AnimationDialogInternal :
public Ui::AnimationParamDlg {
34 AnimationDialogInternal() {}
36 ~AnimationDialogInternal() {}
42 :
ccOverlayDialog(parent, Qt::Tool), m_app(app), m_pickingHub(pickingHub) {
43 this->Internal =
new AnimationDialogInternal();
44 this->Internal->setupUi(
this);
46 this->Internal->EnablePickingAxis->setChecked(
false);
47 this->Internal->SavingViewports->setChecked(
false);
48 enablePickRotationAxis(
false);
50 connect(this->Internal->closeButtonBox, &QDialogButtonBox::clicked,
this,
51 &ecvAnimationParamDlg::onClose);
52 QObject::connect(this->Internal->EnablePickingAxis, &QCheckBox::toggled,
53 this, &ecvAnimationParamDlg::enablePickRotationAxis);
55 QObject::connect(this->Internal->angleButton, &QPushButton::clicked,
this,
56 &ecvAnimationParamDlg::angleStep);
58 QObject::connect(this->Internal->startAnimationButton,
59 &QPushButton::clicked,
this,
61 QObject::connect(this->Internal->resetAnimationButton,
62 &QPushButton::clicked,
this, &ecvAnimationParamDlg::reset);
64 QObject::connect(this->Internal->pickingAxisStartToolButton,
65 &QToolButton::toggled,
this,
67 QObject::connect(this->Internal->pickingAxisEndToolButton,
68 &QToolButton::toggled,
this,
75 return this->Internal->rotationAngle->value();
79 return this->Internal->SavingViewports->isChecked();
89 QProgressDialog progressDialog(
90 QString(
"Saving Viewport number: %1").arg(viewport_num),
"Cancel",
93 progressDialog.setWindowTitle(
"Rendering");
95 progressDialog.setWindowTitle(
"Preview");
98 progressDialog.show();
99 progressDialog.setModal(
false);
100 progressDialog.setAutoClose(
false);
101 QApplication::processEvents();
103 int fps = this->Internal->fpsSpinBox->value();
105 qint64 delay_ms =
static_cast<int>(1000 / fps);
118 progressDialog.setLabelText(
119 QString(
"Saving Viewport number: %1").arg(++viewport_num));
121 progressDialog.setLabelText(QString(
"Render viewport to DB tree"));
124 progressDialog.setValue(viewport_num);
125 progressDialog.update();
126 QApplication::processEvents();
127 if (progressDialog.wasCanceled()) {
131 qint64 dt_ms =
timer.elapsed();
134 if (dt_ms < delay_ms) {
135 int wait_ms =
static_cast<int>(delay_ms - dt_ms);
149 if (this->Internal->pickingAxisStartToolButton->isChecked()) {
150 axisType = AxisType::AXIS_START;
151 }
else if (this->Internal->pickingAxisEndToolButton->isChecked()) {
152 axisType = AxisType::AXIS_END;
157 if (axisType == AxisType::AXIS_START) {
159 }
else if (axisType == AxisType::AXIS_END) {
177 if (this->Internal->pickingAxisStartToolButton->isChecked()) {
178 axisType = AxisType::AXIS_START;
179 }
else if (this->Internal->pickingAxisEndToolButton->isChecked()) {
180 axisType = AxisType::AXIS_END;
185 if (axisType == AxisType::AXIS_START) {
187 }
else if (axisType == AxisType::AXIS_END) {
206 QWidget* associatedWin =
207 (qWin ?
static_cast<QWidget*
>(qWin->widget()) :
nullptr);
221 if (this->Internal->pickingAxisStartToolButton->isChecked()) {
225 if (this->Internal->pickingAxisEndToolButton->isChecked()) {
231 oldWin->disconnect(
this);
237 this, &QWidget::hide);
244 setEnabled(win !=
nullptr);
249 if (this->Internal->EnablePickingAxis->isChecked()) {
250 CCVector3d axisStart(this->Internal->axisStartXDoubleSpinBox->value(),
251 this->Internal->axisStartYDoubleSpinBox->value(),
252 this->Internal->axisStartZDoubleSpinBox->value());
253 CCVector3d axisEnd(this->Internal->axisEndXDoubleSpinBox->value(),
254 this->Internal->axisEndYDoubleSpinBox->value(),
255 this->Internal->axisEndZDoubleSpinBox->value());
256 return axisEnd - axisStart;
259 return CCVector3d(this->Internal->axisXDoubleSpinBox->value(),
260 this->Internal->axisYDoubleSpinBox->value(),
261 this->Internal->axisZDoubleSpinBox->value());
266 if (AxisType::AXIS_START == axisType) {
267 this->Internal->axisStartXDoubleSpinBox->blockSignals(
true);
268 this->Internal->axisStartYDoubleSpinBox->blockSignals(
true);
269 this->Internal->axisStartZDoubleSpinBox->blockSignals(
true);
270 this->Internal->axisStartXDoubleSpinBox->setValue(P.
x);
271 this->Internal->axisStartYDoubleSpinBox->setValue(P.
y);
272 this->Internal->axisStartZDoubleSpinBox->setValue(P.
z);
273 this->Internal->axisStartXDoubleSpinBox->blockSignals(
false);
274 this->Internal->axisStartYDoubleSpinBox->blockSignals(
false);
275 this->Internal->axisStartZDoubleSpinBox->blockSignals(
false);
276 }
else if (AxisType::AXIS_END == axisType) {
277 this->Internal->axisEndXDoubleSpinBox->blockSignals(
true);
278 this->Internal->axisEndYDoubleSpinBox->blockSignals(
true);
279 this->Internal->axisEndZDoubleSpinBox->blockSignals(
true);
280 this->Internal->axisEndXDoubleSpinBox->setValue(P.
x);
281 this->Internal->axisEndYDoubleSpinBox->setValue(P.
y);
282 this->Internal->axisEndZDoubleSpinBox->setValue(P.
z);
283 this->Internal->axisEndXDoubleSpinBox->blockSignals(
false);
284 this->Internal->axisEndYDoubleSpinBox->blockSignals(
false);
285 this->Internal->axisEndZDoubleSpinBox->blockSignals(
false);
289 void ecvAnimationParamDlg::reset() {
295 void ecvAnimationParamDlg::enablePickRotationAxis(
bool state) {
296 auto&
internal = (*this->Internal);
297 internal.pickingAxisStartToolButton->setEnabled(state);
298 internal.axisStartXDoubleSpinBox->setEnabled(state);
299 internal.axisStartYDoubleSpinBox->setEnabled(state);
300 internal.axisStartZDoubleSpinBox->setEnabled(state);
301 internal.pickingAxisEndToolButton->setEnabled(state);
302 internal.axisEndXDoubleSpinBox->setEnabled(state);
303 internal.axisEndYDoubleSpinBox->setEnabled(state);
304 internal.axisEndZDoubleSpinBox->setEnabled(state);
305 internal.axisXDoubleSpinBox->setEnabled(!state);
306 internal.axisYDoubleSpinBox->setEnabled(!state);
307 internal.axisZDoubleSpinBox->setEnabled(!state);
311 void ecvAnimationParamDlg::angleStep() {
327 "Can't start the picking process (another tool is "
352 this->Internal->pickingAxisStartToolButton->blockSignals(
true);
353 this->Internal->pickingAxisStartToolButton->setChecked(state);
354 this->Internal->pickingAxisStartToolButton->blockSignals(
false);
359 this->Internal->pickingAxisEndToolButton->blockSignals(
true);
360 this->Internal->pickingAxisEndToolButton->setChecked(state);
361 this->Internal->pickingAxisEndToolButton->blockSignals(
false);
Vector3Tpl< double > CCVector3d
Double 3D Vector.
static bool Error(const char *format,...)
Display an error dialog with formatted message.
void doActionSaveViewportAsCamera()
static Vector3Tpl fromArray(const int a[3])
Constructor from an int array.
Hierarchical CLOUDVIEWER Object.
Generic overlay dialog interface.
virtual bool start()
Starts process.
bool m_processing
Running/processing state.
QWidget * m_associatedWin
Associated (MDI) window.
virtual bool linkWith(QWidget *win)
Links the overlay dialog with a MDI window.
Point/triangle picking hub.
void removeListener(ccPickingListener *listener, bool autoStopPickingIfLast=true)
Removes a listener.
bool addListener(ccPickingListener *listener, bool exclusive=false, bool autoStartPicking=true, ecvDisplayTools::PICKING_MODE mode=ecvDisplayTools::POINT_OR_TRIANGLE_PICKING)
Adds a listener.
void updateRotationAxisPoint(AxisType axisType, const CCVector3d &P)
Updates dialog values with axis point.
bool start() override
Starts process.
MainWindow * getMainWindow()
CCVector3d getRotationAxis() const
ecvViewportParameters viewportParamsHistory
void startAnimation()
Start animation.
void initWith(QWidget *win)
Inits dialog values with specified window.
void onItemPicked(const PickedItem &pi) override
Method called whenever an item is picked.
ecvAnimationParamDlg(QWidget *parent, MainWindow *app, ccPickingHub *pickingHub)
Default constructor.
double getRotationAngle() const
void updateAxisStartToolState(bool state)
void enableListener(bool state)
bool linkWith(QWidget *win) override
Links the overlay dialog with a MDI window.
void updateAxisEndToolState(bool state)
ccPickingHub * m_pickingHub
Picking hub.
void processPickedItem(ccHObject *, unsigned, int, int, const CCVector3 &)
~ecvAnimationParamDlg() override
Destructor.
bool isSavingViewport() const
void Sleep(int milliseconds)