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

Description

Single-instrument-adapter to InstrumentsEditorController.

InstrumentsEditorController is not instrument-wise, but handles all instruments. This is sometimes unhandy, e.g. if the changed instrument has to be passed through many hierarchies to only be able to notify correctly. Instantiate this class instead and pass it to editors.

Calling notification methods or change methods also take care of dependent data, like in notifyWavelengthDistributionChanged().

Definition at line 33 of file InstrumentEditController.h.

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

Public Member Functions

 InstrumentEditController (InstrumentsEditController *ec, InstrumentItem *instrument)
 
void notifyInclinationAxisChanged ()
 Update dependent data and emit a changed signal. More...
 
void notifyInstrumentChanged ()
 Call this if any instrument value has been changed outside this controller. More...
 
void notifyWavelengthDistributionChanged ()
 Update dependent data and emit a changed signal. More...
 
void setDouble (DoubleDescriptor &d, double newValue)
 Sets the double and emits InstrumentsEditController::instrumentChanged if the double changed. More...
 
void setInstrumentName (const QString &name)
 Set the instrument name and emit the respective signal. More...
 

Private Attributes

InstrumentsEditControllerm_ec
 
InstrumentItemm_instrumentItem
 

Constructor & Destructor Documentation

◆ InstrumentEditController()

InstrumentEditController::InstrumentEditController ( InstrumentsEditController ec,
InstrumentItem instrument 
)

Definition at line 21 of file InstrumentEditController.cpp.

23  : m_instrumentItem(instrument)
24  , m_ec(ec)
25 {
26 }
InstrumentsEditController * m_ec

Member Function Documentation

◆ notifyInclinationAxisChanged()

void InstrumentEditController::notifyInclinationAxisChanged ( )

Update dependent data and emit a changed signal.

Definition at line 58 of file InstrumentEditController.cpp.

59 {
60  // update wavelength. This is necessary after a change in the inclination axis type
61  if (auto* specularBeam = dynamic_cast<SpecularBeamItem*>(m_instrumentItem->beamItem()))
62  specularBeam->updateWavelength();
64 }
virtual BeamItem * beamItem() const
void instrumentChanged(const InstrumentItem *instrument)
Signals any change in the settings of the given instrument.

References InstrumentItem::beamItem(), InstrumentsEditController::instrumentChanged(), m_ec, and m_instrumentItem.

Referenced by SpecularBeamEditor::SpecularBeamEditor().

Here is the call graph for this function:

◆ notifyInstrumentChanged()

void InstrumentEditController::notifyInstrumentChanged ( )

Call this if any instrument value has been changed outside this controller.

emits InstrumentsEditController::instrumentChanged For example if a double has been changed, but setDouble() has not been called

Definition at line 41 of file InstrumentEditController.cpp.

References InstrumentsEditController::instrumentChanged(), m_ec, and m_instrumentItem.

◆ notifyWavelengthDistributionChanged()

void InstrumentEditController::notifyWavelengthDistributionChanged ( )

Update dependent data and emit a changed signal.

Definition at line 46 of file InstrumentEditController.cpp.

47 {
48  // update values in pointwise axis. This is necessary after a change of the mean value of the
49  // wavelength.
50  if (auto* specularBeam = dynamic_cast<SpecularBeamItem*>(m_instrumentItem->beamItem())) {
51  if (auto* pw = dynamic_cast<PointwiseAxisItem*>(specularBeam->inclinationAxis()))
52  pw->updateIndicators();
53  }
54 
56 }
Item for non-uniform axis with specified coordinates.

References InstrumentItem::beamItem(), InstrumentsEditController::instrumentChanged(), m_ec, and m_instrumentItem.

Referenced by SpecularBeamEditor::SpecularBeamEditor().

Here is the call graph for this function:

◆ setDouble()

void InstrumentEditController::setDouble ( DoubleDescriptor d,
double  newValue 
)

Sets the double and emits InstrumentsEditController::instrumentChanged if the double changed.

Definition at line 33 of file InstrumentEditController.cpp.

34 {
35  if (d.get() != newValue) {
36  d.set(newValue);
38  }
39 }
function< void(double)> set
function to set the value
function< double()> get
function to get the current value

References DoubleDescriptor::get, InstrumentsEditController::instrumentChanged(), m_ec, m_instrumentItem, and DoubleDescriptor::set.

◆ setInstrumentName()

void InstrumentEditController::setInstrumentName ( const QString &  name)

Set the instrument name and emit the respective signal.

The signal is emitted by the parent InstrumentsEditController.

Definition at line 28 of file InstrumentEditController.cpp.

29 {
31 }
void setInstrumentName(InstrumentItem *instrument, const QString &name)
Set an instrument's name and emit the respective signal.
QString const & name(EShape k)
Definition: particles.cpp:20

References m_ec, m_instrumentItem, GUI::RealSpace::Particles::name(), and InstrumentsEditController::setInstrumentName().

Here is the call graph for this function:

Member Data Documentation

◆ m_ec

◆ m_instrumentItem

InstrumentItem* InstrumentEditController::m_instrumentItem
private

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