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

Description

Command to change a double value.

Definition at line 24 of file SampleEditorCommands.h.

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

Public Member Functions

 CommandChangeValue (const QString &label, SampleEditorController *ec, double oldValue, double newValue, const QString &path, QUndoCommand *parent=nullptr)
 
int id () const override
 
bool mergeWith (const QUndoCommand *command) override
 
void redo () override
 
void undo () override
 

Private Attributes

SampleEditorControllerm_ec
 
bool m_isFirst = true
 
double m_newValue
 
double m_oldValue
 
QString m_path
 

Constructor & Destructor Documentation

◆ CommandChangeValue()

CommandChangeValue::CommandChangeValue ( const QString &  label,
SampleEditorController ec,
double  oldValue,
double  newValue,
const QString &  path,
QUndoCommand *  parent = nullptr 
)

Definition at line 76 of file SampleEditorCommands.cpp.

79  : QUndoCommand(parent)
80  , m_ec(ec)
81  , m_oldValue(oldValue)
82  , m_newValue(newValue)
83  , m_path(path)
84 {
85  setText("change " + label + "\n");
86 }
SampleEditorController * m_ec

Member Function Documentation

◆ id()

int CommandChangeValue::id ( ) const
override

Definition at line 88 of file SampleEditorCommands.cpp.

89 {
90  return COMMAND_ID_CHANGE_VALUE;
91 }

◆ mergeWith()

bool CommandChangeValue::mergeWith ( const QUndoCommand *  command)
override

Definition at line 93 of file SampleEditorCommands.cpp.

94 {
95  if (command->id() != id()) // make sure other is also a changeValue command
96  return false;
97 
98  const auto* const other = dynamic_cast<const CommandChangeValue*>(command);
99 
100  if (m_path != other->m_path)
101  return false;
102 
103  m_newValue = other->m_newValue;
104  return true;
105 }
@ other
The unit has no enum value defined in here (e.g. when defined as an explicit string)
Command to change a double value.

References m_newValue, m_path, and other.

◆ redo()

void CommandChangeValue::redo ( )
override

Definition at line 107 of file SampleEditorCommands.cpp.

108 {
109  if (m_isFirst)
110  m_isFirst = false;
111  else
113 }
void setDoubleFromUndo(double newValue, const QString &path)

References m_ec, m_isFirst, m_newValue, m_path, and SampleEditorController::setDoubleFromUndo().

Here is the call graph for this function:

◆ undo()

void CommandChangeValue::undo ( )
override

Definition at line 115 of file SampleEditorCommands.cpp.

116 {
118 }

References m_ec, m_oldValue, m_path, and SampleEditorController::setDoubleFromUndo().

Here is the call graph for this function:

Member Data Documentation

◆ m_ec

SampleEditorController* CommandChangeValue::m_ec
private

Definition at line 36 of file SampleEditorCommands.h.

Referenced by redo(), and undo().

◆ m_isFirst

bool CommandChangeValue::m_isFirst = true
private

Definition at line 40 of file SampleEditorCommands.h.

Referenced by redo().

◆ m_newValue

double CommandChangeValue::m_newValue
private

Definition at line 38 of file SampleEditorCommands.h.

Referenced by mergeWith(), and redo().

◆ m_oldValue

double CommandChangeValue::m_oldValue
private

Definition at line 37 of file SampleEditorCommands.h.

Referenced by undo().

◆ m_path

QString CommandChangeValue::m_path
private

Definition at line 39 of file SampleEditorCommands.h.

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


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