Debian Codegraph @

avogadro/qtplugins/surfaces/orbitals.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_ORBITALS_H
7 #define AVOGADRO_QTPLUGINS_ORBITALS_H
8
9 #include <avogadro/core/basisset.h>
10 #include <avogadro/qtgui/extensionplugin.h>
11
12 #include <QtCore/QFutureWatcher>
13
14 class QAction;
15 class QDialog;
16 class QProgressDialog;
17
18 namespace Avogadro {
19
20 namespace QtGui {
21 class MeshGenerator;
22 class GaussianSetConcurrent;
23 class SlaterSetConcurrent;
24 } // namespace QtGui
25
26 namespace Core {
27 class BasisSet;
28 class Cube;
29 class Mesh;
30 } // namespace Core
31
32 namespace QtPlugins {
33
34 /**
35 * @brief The Orbital plugin shows a window with a list of orbitals and
36 * .. renders selected orbitals
37 */
38 class OrbitalSettingsDialog;
39 class OrbitalWidget;
40
41 class Orbitals : public QtGui::ExtensionPlugin
42 {
43 Q_OBJECT
44
45 public:
46 explicit Orbitals(QObject* parent = nullptr);
47 ~Orbitals() override;
48
49 QString name() const override { return tr("Orbital Window"); }
50 QString description() const override { return tr("Display orbital lists."); }
51
52 QList<QAction*> actions() const override;
53
54 QStringList menuPath(QAction*) const override;
55
56 void setMolecule(QtGui::Molecule* mol) override;
57
58 enum CalcState
59 {
60 NotStarted = 0,
61 Running,
62 Completed,
63 Canceled
64 };
65
66 struct calcInfo
67 {
68 Core::Mesh* posMesh;
69 Core::Mesh* negMesh;
70 Core::Cube* cube;
71 unsigned int orbital;
72 Core::BasisSet::ElectronType electronType;
73 double resolution;
74 double isovalue;
75 unsigned int priority;
76 CalcState state;
77 };
78
79 public slots:
80 void moleculeChanged(unsigned int changes);
81 void openDialog();
82
83 private slots:
84 void loadBasis();
85 void loadOrbitals();
86
87 /**
88 * Re-render an orbital at a higher resolution
89 *
90 * @param orbital The orbital to render
91 * @param resolution The resolution of the cube
92 * @param electronType The electron type (Paired, Alpha, or Beta)
93 */
94 void calculateOrbitalFromWidget(unsigned int orbital, double resolution,
95 Core::BasisSet::ElectronType electronType);
96
97 /**
98 * Calculate all molecular orbitals at low priority and moderate
99 * resolution.
100 */
101 void precalculateOrbitals();
102
103 /**
104 * Add an orbital calculation to the queue. Lower priority values
105 * run first. Do not set automatic calculations to priority zero,
106 * this is reserved for user requested calculations and will run
107 * first, displaying a progress dialog.
108 *
109 * @param orbital Orbital number
110 * @param resolution Resolution of grid
111 * @param isoval Isovalue for surface
112 * @param electronType The electron type (Paired, Alpha, or Beta)
113 * @param priority Priority. Default = 0 (user requested)
114 */
115 void addCalculationToQueue(unsigned int orbital, double resolution,
116 double isoval,
117 Core::BasisSet::ElectronType electronType,
118 unsigned int priority = 0);
119 /**
120 * Check that no calculations are currently running and start the
121 * highest priority calculation.
122 */
123 void checkQueue();
124
125 /**
126 * Start or resume the calculation at the indicated index of the
127 * queue.
128 */
129 void startCalculation(unsigned int queueIndex);
130
131 void calculateCube();
132 void calculateCubeDone();
133 void calculatePosMesh();
134 void calculatePosMeshDone();
135 void calculateNegMesh();
136 void calculateNegMeshDone();
137 void calculationComplete();
138 void meshComplete();
139
140 /**
141 * Draw the indicated orbital on the GLWidget
142 */
143 void renderOrbital(unsigned int orbital,
144 Core::BasisSet::ElectronType electronType);
145
146 private:
147 QAction* m_action;
148
149 QtGui::Molecule* m_molecule = nullptr;
150 Core::BasisSet* m_basis = nullptr;
151
152 QList<calcInfo> m_queue;
153 int m_currentRunningCalculation = -1;
154 bool m_runningCube = false;
155 int m_currentMeshCalculation = -1;
156 int m_nextMeshCalculation = -1;
157
158 QtGui::GaussianSetConcurrent* m_gaussianConcurrent = nullptr;
159 QtGui::SlaterSetConcurrent* m_slaterConcurrent = nullptr;
160
161 QFutureWatcher<void> m_displayMeshWatcher;
162 QtGui::MeshGenerator* m_meshGenerator = nullptr;
163
164 float m_isoValue = 0.03;
165 int m_smoothingPasses = 1;
166 int m_meshesLeft = 0;
167 bool m_updateMesh = false;
168
169 OrbitalWidget* m_dialog = nullptr;
170 // OrbitalSettingsDialog* m_orbitalSettingsDialog = nullptr;
171 };
172
173 } // namespace QtPlugins
174 } // namespace Avogadro
175
176 #endif // AVOGADRO_QTPLUGINS_ORBITALS_H