Debian Codegraph @

avogadro/qtplugins/plotxrd/plotxrd.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_PLOTXRD_H
7 #define AVOGADRO_QTPLUGINS_PLOTXRD_H
8
9 #include <avogadro/qtgui/extensionplugin.h>
10
11 #include <memory>
12
13 // Forward declarations
14 class QByteArray;
15
16 namespace Avogadro {
17
18 namespace QtGui {
19 class ChartDialog;
20 }
21
22 namespace QtPlugins {
23
24 class XrdOptionsDialog;
25
26 // First item in the pair is 2*theta. Second is the intensity.
27 typedef std::vector<std::pair<double, double>> XrdData;
28
29 /**
30 * @brief Generate and plot a theoretical XRD pattern using ObjCryst++
31 */
32 class PlotXrd : public Avogadro::QtGui::ExtensionPlugin
33 {
34 Q_OBJECT
35 public:
36 explicit PlotXrd(QObject* parent_ = nullptr);
37 ~PlotXrd() override;
38
39 QString name() const override { return tr("PlotXrd"); }
40 QString description() const override;
41 QList<QAction*> actions() const override;
42 QStringList menuPath(QAction*) const override;
43
44 public slots:
45 void setMolecule(QtGui::Molecule* mol) override;
46
47 void moleculeChanged(unsigned int changes);
48
49 private slots:
50 void updateActions();
51
52 void displayDialog();
53
54 private:
55 // Generate an Xrd pattern from a crystal
56 // Writes the results to @p results, which is a vector of pairs of doubles
57 // (see definition above).
58 // err will be set to an error string if the function fails.
59 // wavelength is an Angstroms.
60 // peakwidth is in degrees.
61 // numpoints is an unsigned integer.
62 // max2theta is in degrees.
63 static bool generateXrdPattern(const QtGui::Molecule& mol, XrdData& results,
64 QString& err, double wavelength = 1.505600,
65 double peakwidth = 0.529580,
66 size_t numpoints = 1000,
67 double max2theta = 162.0);
68
69 // Use QProcess to execute genXrdPattern
70 // If the GENXRDPATTERN_EXECUTABLE environment variable is set, that will be
71 // used for the executable. Otherwise, it will search for the executable in
72 // some common places and use it if it can be found.
73 static bool executeGenXrdPattern(const QStringList& args,
74 const QByteArray& input, QByteArray& output,
75 QString& err);
76
77 QList<QAction*> m_actions;
78 QtGui::Molecule* m_molecule;
79
80 std::unique_ptr<XrdOptionsDialog> m_xrdOptionsDialog;
81 std::unique_ptr<QAction> m_displayDialogAction;
82 QScopedPointer<QtGui::ChartDialog> m_chartDialog;
83 };
84
85 inline QString PlotXrd::description() const
86 {
87 return tr("Generate and plot a theoretical XRD pattern using ObjCryst++.");
88 }
89
90 } // namespace QtPlugins
91 } // namespace Avogadro
92
93 #endif // AVOGADRO_QTPLUGINS_PLOTXRD_H