Debian Codegraph @

avogadro/qtplugins/surfaces/surfaces.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_SURFACES_H
7 #define AVOGADRO_QTPLUGINS_SURFACES_H
8
9 #include <avogadro/qtgui/extensionplugin.h>
10
11 #include <tinycolormap.hpp>
12
13 #include <avogadro/core/color3f.h>
14
15 #include <QtCore/QFutureWatcher>
16
17 class QAction;
18 class QDialog;
19
20 namespace Avogadro {
21
22 namespace QtGui {
23 class MeshGenerator;
24 class GaussianSetConcurrent;
25 class SlaterSetConcurrent;
26 class TimedProgressDialog;
27 } // namespace QtGui
28
29 namespace Core {
30 class BasisSet;
31 class Cube;
32 class Mesh;
33 } // namespace Core
34
35 namespace QtPlugins {
36
37 /**
38 * @brief The Surfaces plugin registers quantum file formats, adds several
39 * menu entries to calculate surfaces, including QM ones.
40 */
41
42 class SurfaceDialog;
43
44 class Surfaces : public QtGui::ExtensionPlugin
45 {
46 Q_OBJECT
47
48 public:
49 explicit Surfaces(QObject* parent = nullptr);
50 ~Surfaces() override;
51
52 enum Type
53 {
54 VanDerWaals,
55 SolventAccessible,
56 SolventExcluded,
57 ElectrostaticPotential,
58 ElectronDensity,
59 MolecularOrbital,
60 SpinDensity,
61 FromFile,
62 Unknown
63 };
64
65 enum ColorProperty
66 {
67 None,
68 ByElectrostaticPotential
69 };
70
71 QString name() const override { return tr("Surfaces"); }
72 QString description() const override
73 {
74 return tr("Read and render surfaces.");
75 }
76
77 QList<QAction*> actions() const override;
78
79 QStringList menuPath(QAction*) const override;
80
81 void setMolecule(QtGui::Molecule* mol) override;
82
83 void registerCommands() override;
84
85 public slots:
86 bool handleCommand(const QString& command,
87 const QVariantMap& options) override;
88 void moleculeChanged(unsigned int changes);
89
90 private slots:
91 void surfacesActivated();
92 void calculateSurface();
93 void calculateEDT(Type type = Unknown, float defaultResolution = 0.0);
94 void performEDTStep(); // EDT step for SolventExcluded
95 void calculateQM(Type type = Unknown, int index = -1, bool betaSpin = false,
96 float isoValue = 0.0, float defaultResolution = 0.0);
97 void calculateCube(int index = -1, float isoValue = 0.0);
98
99 void stepChanged(int);
100
101 void displayMesh();
102 void meshFinished();
103
104 void colorMesh();
105 void colorMeshByPotential();
106
107 void recordMovie();
108 void movieFrame();
109
110 private:
111 float resolution(float specified = 0.0);
112 Core::Color3f chargeGradient(double value, double clamp,
113 tinycolormap::ColormapType colormap) const;
114 tinycolormap::ColormapType getColormapFromString(const QString& name) const;
115
116 QList<QAction*> m_actions;
117 QtGui::TimedProgressDialog* m_progressDialog = nullptr;
118
119 QtGui::Molecule* m_molecule = nullptr;
120 Core::BasisSet* m_basis = nullptr;
121
122 QtGui::GaussianSetConcurrent* m_gaussianConcurrent = nullptr;
123 QtGui::SlaterSetConcurrent* m_slaterConcurrent = nullptr;
124
125 Core::Cube* m_cube = nullptr;
126 std::vector<Core::Cube*> m_cubes;
127 /* One QFutureWatcher per asynchronous slot function, e.g.:*/
128 /* calculateEDT() -> [performEDTStep()] -> displayMesh() */
129 QFutureWatcher<void> m_performEDTStepWatcher;
130 QFutureWatcher<void> m_displayMeshWatcher;
131 Core::Mesh* m_mesh1 = nullptr;
132 Core::Mesh* m_mesh2 = nullptr;
133 /* displayMesh() -> meshFinished() */
134 QtGui::MeshGenerator* m_meshGenerator1 = nullptr;
135 QtGui::MeshGenerator* m_meshGenerator2 = nullptr;
136
137 float m_isoValue = 0.025;
138 int m_smoothingPasses = 2;
139 int m_meshesLeft = 0;
140
141 bool m_recordingMovie = false;
142 int m_currentFrame = 0;
143 int m_frameCount = 1;
144 QString m_baseFileName;
145 int m_numberLength = 1;
146
147 SurfaceDialog* m_dialog = nullptr;
148
149 class PIMPL;
150 PIMPL* d = nullptr;
151 };
152 } // namespace QtPlugins
153 } // namespace Avogadro
154
155 #endif // AVOGADRO_QTPLUGINS_SURFACES_H