ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
qAnimationDlg.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 // ##########################################################################
11 // # #
12 // # CloudViewer PLUGIN: qAnimation #
13 // # #
14 // # This program is free software; you can redistribute it and/or modify #
15 // # it under the terms of the GNU General Public License as published by #
16 // # the Free Software Foundation; version 2 or later of the License. #
17 // # #
18 // # This program is distributed in the hope that it will be useful, #
19 // # but WITHOUT ANY WARRANTY; without even the implied warranty of #
20 // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
21 // # GNU General Public License for more details. #
22 // # #
23 // # COPYRIGHT: Ryan Wicks, 2G Robotics Inc., 2015 #
24 // # #
25 // ##########################################################################
26 
27 // CV_DB_LIB
28 #include <ecvViewportParameters.h>
29 
30 // Qt
31 #include <QDialog>
32 
33 // System
34 #include <QProgressDialog>
35 #include <vector>
36 
37 #include "ui_animationDlg.h"
38 
39 class ccMesh;
40 class ccPolyline;
41 class cc2DViewportObject;
42 class QListWidgetItem;
43 #ifdef QFFMPEG_SUPPORT
44 class QVideoEncoder;
45 #endif
46 
48 class qAnimationDlg : public QDialog, public Ui::AnimationDialog {
49  Q_OBJECT
50 
51 public:
53  qAnimationDlg(QWidget* view3d, QWidget* parent = nullptr);
54 
56  virtual ~qAnimationDlg();
57 
59  bool init(const std::vector<cc2DViewportObject*>& viewports,
60  const std::vector<ccMesh*>& meshes);
61 
64  bool updateTextures() const;
65 
66 protected:
67  void onFPSChanged(int);
68  void onTotalTimeChanged(double);
69  void onStepTimeChanged(double);
70  void onLoopToggled(bool);
71  void onCurrentStepChanged(int);
72  void onBrowseButtonClicked();
74  void onAutoStepsDurationToggled(bool);
75  void onSmoothTrajectoryToggled(bool);
76  void onSmoothRatioChanged(double);
77 
78  void preview();
79  void renderAnimation() { render(false); }
80  void renderFrames() { render(true); }
81  void onAccept();
82  void onReject();
83 
84  void onItemChanged(QListWidgetItem*);
85 
86 protected: // methods
87  int getCurrentStepIndex();
88  size_t countEnabledSteps() const;
89 
90  bool smoothModeEnabled() const;
91 
92  int countFrames(size_t startIndex = 0);
93 
94  void applyViewport(const ecvViewportParameters& viewportParameters);
95 
96  double computeTotalTime();
97 
99  void updateTotalDuration();
100  bool updateCameraTrajectory();
102 
103  bool getNextSegment(size_t& vp1, size_t& vp2) const;
104 
105  void render(bool asSeparateFrames);
106 
107  bool smoothTrajectory(double ratio, unsigned iterationCount);
108 
110  struct Step {
115  double duration_sec = 0.0;
116  double length = 0.0;
118  };
119 
120  typedef std::vector<Step> Trajectory;
121  typedef std::vector<ccMesh*> MeshList;
122 
123  bool getCompressedTrajectory(Trajectory& compressedTrajectory) const;
124 
126 
127 protected: // members
133 
135  QWidget* m_view3d;
136  void textureAnimationPreview(const QStringList& texture_files,
137  QProgressDialog& progressDialog);
138  bool textureAnimationRender(const QStringList& texture_files,
139  QProgressDialog& progressDialog,
140  bool asSeparateFrames
141 #ifdef QFFMPEG_SUPPORT
142  ,
143  QScopedPointer<QVideoEncoder>& encoder
144 #endif
145  );
146 };
Video encoder based on FFmpeg.
Definition: QVideoEncoder.h:14
2D viewport object
Triangular mesh.
Definition: ecvMesh.h:35
Colored polyline.
Definition: ecvPolyline.h:24
Standard parameters for GL displays/viewports.
Dialog for qAnimation plugin.
Definition: qAnimationDlg.h:48
Trajectory m_smoothVideoSteps
Smoothed animation.
int countFrames(size_t startIndex=0)
void renderFrames()
Definition: qAnimationDlg.h:80
void onTotalTimeChanged(double)
int getCurrentStepIndex()
bool updateCameraTrajectory()
bool getNextSegment(size_t &vp1, size_t &vp2) const
bool smoothTrajectory(double ratio, unsigned iterationCount)
std::vector< Step > Trajectory
size_t countEnabledSteps() const
MeshList m_mesh_list
void textureAnimationPreview(const QStringList &texture_files, QProgressDialog &progressDialog)
void onBrowseTexturesButtonClicked()
void onCurrentStepChanged(int)
QWidget * m_view3d
Associated 3D view.
std::vector< ccMesh * > MeshList
qAnimationDlg(QWidget *view3d, QWidget *parent=nullptr)
Default constructor.
void renderAnimation()
Definition: qAnimationDlg.h:79
void onSmoothRatioChanged(double)
void updateSmoothTrajectoryDurations()
void onStepTimeChanged(double)
Trajectory m_videoSteps
Animation.
void onItemChanged(QListWidgetItem *)
bool exportTrajectoryOnExit()
bool updateTextures() const
bool getCompressedTrajectory(Trajectory &compressedTrajectory) const
void onFPSChanged(int)
void updateTotalDuration()
double computeTotalTime()
virtual ~qAnimationDlg()
Destrcuctor.
bool smoothModeEnabled() const
void onAutoStepsDurationToggled(bool)
void onLoopToggled(bool)
void updateCurrentStepDuration()
bool textureAnimationRender(const QStringList &texture_files, QProgressDialog &progressDialog, bool asSeparateFrames)
void onBrowseButtonClicked()
ccPolyline * getTrajectory()
bool init(const std::vector< cc2DViewportObject * > &viewports, const std::vector< ccMesh * > &meshes)
Initialize the dialog with a set of viewports.
void applyViewport(const ecvViewportParameters &viewportParameters)
bool updateSmoothCameraTrajectory()
void onSmoothTrajectoryToggled(bool)
void render(bool asSeparateFrames)
Simple step (viewport + time)
cc2DViewportObject * viewport
CCVector3d cameraCenter
ecvViewportParameters viewportParams