BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
SampleEditorCommands.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/SampleDesigner/SampleEditorCommands.h
6 //! @brief Defines command classes for LayerOrientedSampleEditor
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2021
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_SAMPLEEDITORCOMMANDS_H
16 #define BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_SAMPLEEDITORCOMMANDS_H
17 
18 #include <QUndoCommand>
19 
21 class LayerItem;
22 
23 //! Command to change a double value
24 class CommandChangeValue : public QUndoCommand {
25 public:
26  CommandChangeValue(const QString& label, SampleEditorController* ec, double oldValue,
27  double newValue, const QString& path, QUndoCommand* parent = nullptr);
28 
29  int id() const override;
30  bool mergeWith(const QUndoCommand* command) override;
31 
32  void redo() override;
33  void undo() override;
34 
35 private:
37  double m_oldValue;
38  double m_newValue;
39  QString m_path;
40  bool m_isFirst = true;
41 };
42 
43 //! Command to add a layer to a sample
44 class CommandAddLayer : public QUndoCommand {
45 public:
46  CommandAddLayer(SampleEditorController* ec, int atIndex, QUndoCommand* parent = nullptr);
47 
48  void redo() override;
49  void undo() override;
50 
51 private:
53  int m_atIndex;
54 };
55 
56 //! Command to remove a layer from a sample
57 class CommandRemoveLayer : public QUndoCommand {
58 public:
60  QUndoCommand* parent = nullptr);
61 
62  void redo() override;
63  void undo() override;
64 
65 private:
67  QByteArray m_layerItemBackup;
69 };
70 
71 
72 #endif // BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_SAMPLEEDITORCOMMANDS_H
Command to add a layer to a sample.
void undo() override
SampleEditorController * m_ec
void redo() override
CommandAddLayer(SampleEditorController *ec, int atIndex, QUndoCommand *parent=nullptr)
Command to change a double value.
bool mergeWith(const QUndoCommand *command) override
int id() const override
SampleEditorController * m_ec
CommandChangeValue(const QString &label, SampleEditorController *ec, double oldValue, double newValue, const QString &path, QUndoCommand *parent=nullptr)
Command to remove a layer from a sample.
SampleEditorController * m_ec
CommandRemoveLayer(SampleEditorController *ec, LayerItem *layerItem, QUndoCommand *parent=nullptr)
Class to modify a sample from the layer oriented sample editor.