Debian Codegraph @

avogadro/qtplugins/crystal/unitcelldialog.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_UNITCELLDIALOG_H
7 #define AVOGADRO_QTPLUGINS_UNITCELLDIALOG_H
8
9 #include <QtWidgets/QDialog>
10
11 #include <avogadro/core/avogadrocore.h>
12 #include <avogadro/core/matrix.h>
13 #include <avogadro/core/unitcell.h>
14
15 class QPlainTextEdit;
16
17 namespace Avogadro {
18
19 namespace QtGui {
20 class Molecule;
21 }
22
23 namespace QtPlugins {
24
25 namespace Ui {
26 class UnitCellDialog;
27 }
28
29 /**
30 * @brief The UnitCellDialog class provides a dialog for editing a molecule's
31 * unit cell.
32 */
33 class UnitCellDialog : public QDialog
34 {
35 Q_OBJECT
36
37 public:
38 enum Mode
39 {
40 Clean,
41 Invalid,
42 Parameters,
43 CellMatrix,
44 FractionalMatrix
45 };
46
47 explicit UnitCellDialog(QWidget* parent = nullptr);
48 ~UnitCellDialog() override;
49
50 void setMolecule(QtGui::Molecule* molecule);
51
52 public slots:
53 void moleculeChanged(unsigned int changes);
54
55 void parametersEdited();
56 void cellMatrixEdited();
57 void fractionalMatrixEdited();
58
59 void apply();
60 void revert();
61
62 private:
63 bool isCrystal() const;
64
65 void setMode(Mode m);
66
67 void enableParameters(bool e);
68 void enableCellMatrix(bool e);
69 void enableFractionalMatrix(bool e);
70 void enableApply(bool e);
71 void enableRevert(bool e);
72
73 void blockParametersSignals(bool e);
74 void blockCellMatrixSignals(bool e);
75 void blockFractionalMatrixSignals(bool e);
76
77 // m_tempCell --> ui
78 void revertParameters();
79 void revertCellMatrix();
80 void revertFractionalMatrix();
81
82 // ui --> m_tempCell
83 void updateParameters();
84 void updateCellMatrix();
85 void updateFractionalMatrix();
86
87 bool validateCellMatrix();
88 bool validateFractionalMatrix();
89
90 static void initializeMatrixEditor(QPlainTextEdit* edit);
91 static bool validateMatrixEditor(QPlainTextEdit* edit);
92 static QString matrixToString(const Matrix3& mat);
93 static Matrix3 stringToMatrix(const QString& str);
94
95 private:
96 Ui::UnitCellDialog* m_ui;
97 QtGui::Molecule* m_molecule;
98 Core::UnitCell m_tempCell;
99 Mode m_mode;
100 };
101
102 } // namespace QtPlugins
103 } // namespace Avogadro
104 #endif // AVOGADRO_QTPLUGINS_UNITCELLDIALOG_H