Debian Codegraph @

avogadro/qtplugins/spacegroup/spacegroup.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_SPACEGROUP_H
7 #define AVOGADRO_QTPLUGINS_SPACEGROUP_H
8
9 #include <avogadro/qtgui/extensionplugin.h>
10
11 namespace Avogadro {
12 namespace QtPlugins {
13
14 /**
15 * @brief Space group features for crystals.
16 */
17 class SpaceGroup : public Avogadro::QtGui::ExtensionPlugin
18 {
19 Q_OBJECT
20 public:
21 explicit SpaceGroup(QObject* parent_ = nullptr);
22 ~SpaceGroup() override;
23
24 QString name() const override { return tr("SpaceGroup"); }
25 QString description() const override;
26 QList<QAction*> actions() const override;
27 QStringList menuPath(QAction*) const override;
28
29 bool handleCommand(const QString& command,
30 const QVariantMap& options) override;
31
32 void registerCommands() override;
33
34 public slots:
35 void setMolecule(QtGui::Molecule* mol) override;
36
37 void moleculeChanged(unsigned int changes);
38
39 private slots:
40 void updateActions();
41
42 void perceiveSpaceGroup();
43 void reduceToPrimitive();
44 void conventionalizeCell();
45 void symmetrize();
46 void fillUnitCell();
47 void fillTranslationalCell();
48 void reduceToAsymmetricUnit();
49 void setTolerance();
50
51 private:
52 // Pop up a dialog box and ask the user to select a space group.
53 // Returns the hall number for the selected space group.
54 // Returns 0 if the user canceled.
55 unsigned short selectSpaceGroup();
56
57 // Check if the cell appears to be primitive but the space group expects
58 // a centered cell. Warns the user and optionally conventionalizes.
59 // Returns true if we should proceed with filling, false if user canceled.
60 bool checkPrimitiveCell(unsigned short hallNumber);
61 QList<QAction*> m_actions;
62 QtGui::Molecule* m_molecule;
63 double m_spgTol;
64
65 QAction* m_perceiveSpaceGroupAction;
66 QAction* m_reduceToPrimitiveAction;
67 QAction* m_conventionalizeCellAction;
68 QAction* m_symmetrizeAction;
69 QAction* m_fillUnitCellAction;
70 QAction* m_fillTranslationalCellAction;
71 QAction* m_reduceToAsymmetricUnitAction;
72 QAction* m_setToleranceAction;
73
74 bool m_blockFillHeuristic = false;
75
76 const QString crystalSystem(unsigned short hallNumber);
77 const QString toleranceToString();
78 const QString symbolToString(unsigned short hallNumber,
79 bool replaceOverlines = false);
80 const QString hallSymbolToString(unsigned short hallNumber);
81
82 void fillHeuristic();
83 };
84
85 inline QString SpaceGroup::description() const
86 {
87 return tr("Space group features for crystals.");
88 }
89
90 } // namespace QtPlugins
91 } // namespace Avogadro
92
93 #endif // AVOGADRO_QTPLUGINS_SPACEGROUP_H