Debian Codegraph @

avogadro/qtplugins/playertool/playertool.h

raw
1 /******************************************************************************
2 This source file is part of the Avogadro project.
3 This source code is released under the 3-Clause BSD License, (see "LICENSE").
4 ******************************************************************************/
5
6 #ifndef AVOGADRO_QTPLUGINS_PLAYERTOOL_H
7 #define AVOGADRO_QTPLUGINS_PLAYERTOOL_H
8
9 #include <avogadro/qtgui/toolplugin.h>
10
11 #include <avogadro/core/avogadrocore.h>
12
13 #include <QtCore/QTimer>
14
15 class QLabel;
16 class QSpinBox;
17 class QCheckBox;
18 class QOpenGLWidget;
19 class QPushButton;
20 class QSlider;
21
22 namespace Avogadro {
23 namespace QtPlugins {
24
25 /**
26 * @brief PlayerTool enables playback of trajectories.
27 */
28 class PlayerTool : public QtGui::ToolPlugin
29 {
30 Q_OBJECT
31 public:
32 explicit PlayerTool(QObject* p = nullptr);
33 ~PlayerTool() override;
34
35 QString name() const override { return tr("Player tool"); }
36 QString description() const override { return tr("Play back trajectories"); }
37 unsigned char priority() const override { return 80; }
38 QAction* activateAction() const override { return m_activateAction; }
39 QWidget* toolWidget() const override;
40 void setIcon(bool darkTheme = false) override;
41
42 QUndoCommand* mousePressEvent(QMouseEvent* e) override;
43 QUndoCommand* mouseReleaseEvent(QMouseEvent* e) override;
44 QUndoCommand* mouseDoubleClickEvent(QMouseEvent* e) override;
45 QUndoCommand* keyPressEvent(QKeyEvent* e) override;
46
47 public slots:
48 void setMolecule(QtGui::Molecule*) override;
49 void setGLRenderer(Rendering::GLRenderer* renderer) override;
50 void setActiveWidget(QWidget* widget) override;
51
52 protected slots:
53 void back();
54 void forward();
55 void play();
56 void stop();
57 void animate(int advance = 1);
58
59 void recordMovie();
60 void sliderPositionChanged(int k);
61 void spinnerPositionChanged(int k);
62 void firstFramePositionChanged(int k);
63 void lastFramePositionChanged(int k);
64 void updateLimits();
65
66 private:
67 QAction* m_activateAction;
68 QtGui::Molecule* m_molecule;
69 Rendering::GLRenderer* m_renderer;
70 int m_currentFrame;
71 mutable QWidget* m_toolWidget;
72 QTimer m_timer;
73 mutable QSpinBox* m_animationFPS;
74 mutable QSpinBox* m_frameIdx;
75 mutable QSpinBox* m_firstFrameIdx;
76 mutable QSpinBox* m_lastFrameIdx;
77 mutable QCheckBox* m_dynamicBonding;
78 mutable QOpenGLWidget* m_glWidget;
79 mutable QSlider* m_slider;
80 mutable QPushButton* playButton;
81 };
82
83 inline void PlayerTool::setMolecule(QtGui::Molecule* mol)
84 {
85 if (m_molecule != mol) {
86 m_molecule = mol;
87 m_currentFrame = 0;
88 updateLimits();
89 }
90 }
91
92 inline void PlayerTool::setGLRenderer(Rendering::GLRenderer* renderer)
93 {
94 m_renderer = renderer;
95 }
96
97 } // namespace QtPlugins
98 } // namespace Avogadro
99
100 #endif // AVOGADRO_QTPLUGINS_PLAYERTOOL_H