Debian Codegraph @

avogadro/qtplugins/openbabel/openbabel.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_OPENBABEL_H
7 #define AVOGADRO_QTPLUGINS_OPENBABEL_H
8
9 #include "conformersearchdialog.h"
10
11 #include <avogadro/qtgui/extensionplugin.h>
12
13 #include <QtCore/QMultiMap>
14
15 class QAction;
16 class QProgressDialog;
17
18 namespace Avogadro {
19 namespace QtPlugins {
20
21 class OBProcess;
22
23 /**
24 * @brief The OpenBabel class implements the ExtensionPlugin interface to
25 * expose some OpenBabel functionality.
26 *
27 * @todo The readMolecule method will need to be updated if we allow
28 * multimolecule files to load with the Io::CmlReader.
29 */
30 class OpenBabel : public QtGui::ExtensionPlugin
31 {
32 Q_OBJECT
33
34 public:
35 explicit OpenBabel(QObject* parent = nullptr);
36 ~OpenBabel() override;
37
38 QString name() const override { return tr("OpenBabel"); }
39
40 QString description() const override
41 {
42 return tr("Interact with OpenBabel utilities.");
43 }
44
45 QList<QAction*> actions() const override;
46
47 QStringList menuPath(QAction*) const override;
48
49 QList<Io::FileFormat*> fileFormats() const override;
50
51 QString openBabelInfo() const;
52
53 public slots:
54 void setMolecule(QtGui::Molecule* mol) override;
55
56 bool readMolecule(QtGui::Molecule& mol) override;
57
58 private slots:
59 void refreshReadFormats();
60 void handleReadFormatUpdate(const QMultiMap<QString, QString>& fmts);
61
62 void refreshWriteFormats();
63 void handleWriteFormatUpdate(const QMultiMap<QString, QString>& fmts);
64
65 void refreshForceFields();
66 void handleForceFieldsUpdate(const QMultiMap<QString, QString>& ffMap);
67
68 void refreshCharges();
69 void handleChargesUpdate(const QMultiMap<QString, QString>& chargeMap);
70
71 void onConfigureGeometryOptimization();
72 void onConfigureConformerSearch();
73
74 void onOptimizeGeometry();
75 void onOptimizeGeometryStatusUpdate(int step, int numSteps, double energy,
76 double lastEnergy);
77 void onOptimizeGeometryFinished(const QByteArray& output);
78
79 void onGenerateConformers();
80 void onConformerStatusUpdate(int step, int numSteps, double energy,
81 double lastEnergy);
82 void onGenerateConformersFinished(const QByteArray& output);
83
84 void onPerceiveBonds();
85 void onPerceiveBondsFinished(const QByteArray& output);
86
87 void onAddHydrogens();
88 void onAddHydrogensPh();
89 void onRemoveHydrogens();
90 void onHydrogenOperationFinished(const QByteArray& cml);
91
92 private:
93 void initializeProgressDialog(const QString& title, const QString& label,
94 int min, int max, int value,
95 bool showDialog = true);
96 void showProcessInUseError(const QString& title) const;
97 QString autoDetectForceField() const;
98
99 QtGui::Molecule* m_molecule;
100 OBProcess* m_process;
101 QList<QAction*> m_actions;
102 QList<QByteArray> m_moleculeQueue;
103 bool m_readFormatsPending;
104 bool m_writeFormatsPending;
105 QMultiMap<QString, QString> m_readFormats;
106 QMultiMap<QString, QString> m_writeFormats;
107 QMultiMap<QString, QString> m_forceFields;
108 QMultiMap<QString, QString> m_charges;
109 std::string m_defaultFormat;
110 QProgressDialog* m_progress;
111
112 ConformerSearchDialog* m_conformerSearchDialog;
113 };
114
115 } // namespace QtPlugins
116 } // namespace Avogadro
117
118 #endif // AVOGADRO_QTPLUGINS_OPENBABEL_H