Debian Codegraph @

avogadro/qtopengl/activeobjects.h

raw
1 /* This source file is part of the Avogadro project.
2 It is released under the 3-Clause BSD License, see "LICENSE". */
3
4 #ifndef AVOGADRO_QTOPENGL_ACTIVEOBJECTS_H
5 #define AVOGADRO_QTOPENGL_ACTIVEOBJECTS_H
6
7 #include "avogadroqtopenglexport.h"
8
9 #include <QtCore/QObject>
10
11 // #include "glwidget.h"
12
13 #include <QtCore/QPointer>
14
15 class QWidget;
16 namespace Avogadro {
17 namespace QtGui {
18 class Molecule;
19 }
20 namespace QtOpenGL {
21 class GLWidget;
22 /**
23 * @class ActiveObjects activeobjects.h <avogadro/qtopengl/activeobjects.h>
24 * @brief Singleton to provide access to active objects.
25 *
26 * This class provides access to the active objects in the running application.
27 * If you write an application using the Avogadro libraries you need to keep
28 * this class updated with changes in active objects in order for built in
29 * features to work as expected.
30 *
31 * All returned objects are owned by the running application, nullptr indicates
32 * that there is no currently active object of that type.
33 */
34 class AVOGADROQTOPENGL_EXPORT ActiveObjects : public QObject
35 {
36 Q_OBJECT
37
38 public:
39 /** Return a reference to the singleton instance that can be queried. */
40 static ActiveObjects& instance();
41
42 /** Get the active GLWidget. **/
43 GLWidget* activeGLWidget() const;
44
45 /**
46 * Get the active widget.
47 */
48 QWidget* activeWidget() const;
49
50 /**
51 * Get the active molecule.
52 */
53 QtGui::Molecule* activeMolecule() const;
54
55 public slots:
56 /** Set the active GLWidget. */
57 void setActiveGLWidget(GLWidget* glWidget);
58
59 /** Set the active widget. */
60 void setActiveWidget(QWidget* widget);
61
62 /** Set the active molecule. */
63 void setActiveMolecule(QtGui::Molecule* molecule);
64
65 signals:
66 /** The active GL widget changed. */
67 void activeGLWidgetChanged(GLWidget* glWidget);
68
69 /** The active widget changed. */
70 void activeWidgetChanged(QWidget* widget);
71
72 /** The active molecule changed. */
73 void activeMoleculeChanged(QtGui::Molecule* molecule);
74
75 private:
76 ActiveObjects();
77 ~ActiveObjects() override;
78 Q_DISABLE_COPY(ActiveObjects)
79
80 GLWidget* m_glWidget = nullptr;
81 QWidget* m_widget = nullptr;
82 QtGui::Molecule* m_molecule = nullptr;
83 };
84
85 } // namespace QtOpenGL
86 } // namespace Avogadro
87
88 #endif // AVOGADRO_QTOPENGL_ACTIVEOBJECTS_H