BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
CommandRemoveLayer Class Reference

Description

Command to remove a layer from a sample.

Definition at line 57 of file SampleEditorCommands.h.

Inheritance diagram for CommandRemoveLayer:
[legend]
Collaboration diagram for CommandRemoveLayer:
[legend]

Public Member Functions

 CommandRemoveLayer (SampleEditorController *ec, LayerItem *layerItem, QUndoCommand *parent=nullptr)
 
void redo () override
 
void undo () override
 

Private Attributes

SampleEditorControllerm_ec
 
int m_indexOfLayer
 
QByteArray m_layerItemBackup
 

Constructor & Destructor Documentation

◆ CommandRemoveLayer()

CommandRemoveLayer::CommandRemoveLayer ( SampleEditorController ec,
LayerItem layerItem,
QUndoCommand *  parent = nullptr 
)

Definition at line 30 of file SampleEditorCommands.cpp.

32  : QUndoCommand(parent)
33  , m_ec(ec)
34 {
35  setText("Remove layer");
36  m_indexOfLayer = ec->sampleItem()->layers().indexOf(layerItem);
38 }
SampleEditorController * m_ec
QVector< LayerItem * > layers() const
MultiLayerItem * sampleItem() const
The item on which this controller operates.
QByteArray createBackup(const T *t)
Definition: Backup.h:24

References GUI::Util::createBackup(), MultiLayerItem::layers(), m_indexOfLayer, m_layerItemBackup, and SampleEditorController::sampleItem().

Here is the call graph for this function:

Member Function Documentation

◆ redo()

void CommandRemoveLayer::redo ( )
override

Definition at line 40 of file SampleEditorCommands.cpp.

41 {
43 }
void removeLayerFromUndo(int atIndex)

References m_ec, m_indexOfLayer, and SampleEditorController::removeLayerFromUndo().

Here is the call graph for this function:

◆ undo()

void CommandRemoveLayer::undo ( )
override

Definition at line 45 of file SampleEditorCommands.cpp.

46 {
47  LayerItem* restoredLayer = m_ec->sampleItem()->addLayer(m_indexOfLayer);
49  m_ec->sampleForm()->onLayerAdded(restoredLayer);
50  emit m_ec->modified();
51 }
void onLayerAdded(LayerItem *layerItem)
Create widgets for the new layer.
LayerItem * addLayer(int index=-1)
Creates and inserts a layer at given index.
MultiLayerForm * sampleForm() const
The current form.
void restoreBackup(T *t, const QByteArray &backup)
Definition: Backup.h:36

References MultiLayerItem::addLayer(), m_ec, m_indexOfLayer, m_layerItemBackup, SampleEditorController::modified(), MultiLayerForm::onLayerAdded(), GUI::Util::restoreBackup(), SampleEditorController::sampleForm(), and SampleEditorController::sampleItem().

Here is the call graph for this function:

Member Data Documentation

◆ m_ec

SampleEditorController* CommandRemoveLayer::m_ec
private

Definition at line 66 of file SampleEditorCommands.h.

Referenced by redo(), and undo().

◆ m_indexOfLayer

int CommandRemoveLayer::m_indexOfLayer
private

Definition at line 68 of file SampleEditorCommands.h.

Referenced by CommandRemoveLayer(), redo(), and undo().

◆ m_layerItemBackup

QByteArray CommandRemoveLayer::m_layerItemBackup
private

Definition at line 67 of file SampleEditorCommands.h.

Referenced by CommandRemoveLayer(), and undo().


The documentation for this class was generated from the following files: