/home/docs/checkouts/readthedocs.org/user_builds/mathvizanimator/checkouts/latest/libs/mva_workflow/include/workflow/renderer.h Source File

MathVizAnimator: /home/docs/checkouts/readthedocs.org/user_builds/mathvizanimator/checkouts/latest/libs/mva_workflow/include/workflow/renderer.h Source File
MathVizAnimator  0.0.1
renderer.h
1 /* mathvizanimator
2  * Copyright (C) 2023 codingwithmagga
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef LIBS_MVA_WORKFLOW_INCLUDE_WORKFLOW_RENDERER_H_
19 #define LIBS_MVA_WORKFLOW_INCLUDE_WORKFLOW_RENDERER_H_
20 
21 #include <QFileInfo>
22 #include <QObject>
23 #include <QProcess>
24 #include <QSharedPointer>
25 
26 #include "item_observer.h"
27 
28 class Renderer : public QObject {
29  Q_OBJECT
30 
31  public:
32  struct ProjectSettings {
33  QSize size = QSize(1024, 768);
34  qint32 fps = 24;
35  qint32 video_length = 5;
36  QColor background_color = QColor("black");
37  };
38 
39  explicit Renderer(QObject* parent = Q_NULLPTR);
40 
41  ProjectSettings projectSettings() const;
42  void setProjectSettings(const ProjectSettings& new_project_settings);
43 
44  void setProjectSize(const QSize new_project_size);
45  void setFPS(const qint32 new_fps);
46  void setVideoLength(const qint32 new_video_length);
47  void setBackgroundColor(const QColor& new_background_color);
48 
49  QImage createImage(const QList<QSharedPointer<ItemObserver>>& item_list, const qreal current_time) const;
50 
51  public slots:
52  void render(const QList<QSharedPointer<ItemObserver>>& item_list, const QFileInfo& video_file);
53 
54  signals:
55  void finishedRendering(const QFileInfo& video_file);
56 
57  private slots:
58  void renderingProcessStarted(const QList<QSharedPointer<ItemObserver>>& item_list);
59  void renderingProcessFinished(const QFileInfo& video_file, qint32 exitCode, QProcess::ExitStatus exitStatus);
60 
61  private:
62  ProjectSettings m_project_settings;
63  QMap<qint32, QSharedPointer<QProcess>> m_render_process_map;
64 
65  qint32 m_next_process_id = 0;
66 };
67 
68 class RenderProcess : public QProcess {
69  Q_OBJECT
70 
71  public:
72  explicit RenderProcess(const qint32 id, QObject* parent = Q_NULLPTR)
73  : QProcess { parent }
74  , m_id(id)
75  {
76  }
77 
78  qint32 id() const { return m_id; }
79 
80  private:
81  const qint32 m_id;
82 };
83 
84 #endif // LIBS_MVA_WORKFLOW_INCLUDE_WORKFLOW_RENDERER_H_
Definition: renderer.h:68
Definition: renderer.h:28
Definition: renderer.h:32