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

Description

Class to modify the instruments list or a single instrument and provide the necessary signaling within BornAgain.

An instance of this class is held in the project document (ProjectDocument). Whenever you want to modify instruments of the current project, use this instance to ensure proper signaling of changes. If you change an instrument without using any method in this class, you have to notify this class about the modification by calling notifyInstrumentChanged.

If you want to be notified about any changes of instruments in the current project, listen to the signals of this instance.

For uses other than the instruments in the current project (like e.g. for the instruments library), you can create a dedicated instance and handle the instrument collection in question with this separate instance.

Definition at line 40 of file InstrumentsEditController.h.

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

Signals

void instrumentAddedOrRemoved ()
 Signals a change in the list of instruments. More...
 
void instrumentChanged (const InstrumentItem *instrument)
 Signals any change in the settings of the given instrument. More...
 
void instrumentNameChanged (const InstrumentItem *instrument)
 Signals name change of the given instrument. More...
 

Public Member Functions

 InstrumentsEditController (InstrumentCollection *instruments)
 
InstrumentItemaddCopy (const InstrumentItem *instrument, const QString &name)
 Copy an instrument, set its name and emit the respective signal. More...
 
template<typename T >
T * addInstrument ()
 Add an instrument and emit the respective signal. More...
 
InstrumentCollectioncollectedItems ()
 The list of existing instruments. More...
 
void notifyInstrumentChanged (InstrumentItem *instrument)
 Simply emits the instrumentChanged signal. Call this whenever you change an instrument's data without using this edit controller. By calling this method, the listeners will be notified about the changes. More...
 
void removeInstrument (InstrumentItem *instrument)
 Add an instrument and emit the respective signal. More...
 
void setInstrumentName (InstrumentItem *instrument, const QString &name)
 Set an instrument's name and emit the respective signal. More...
 
void updateInstrumentToRealDataItem (InstrumentItem *instrument, const RealDataItem *realDataItem)
 Calls the instrument's updateToRealData and emits the respective signal. More...
 

Private Attributes

InstrumentCollectionm_instruments
 The edited/controlled instruments. This pointer is borrowed, not owned. More...
 

Constructor & Destructor Documentation

◆ InstrumentsEditController()

InstrumentsEditController::InstrumentsEditController ( InstrumentCollection instruments)

Definition at line 18 of file InstrumentsEditController.cpp.

19  : m_instruments(instruments)
20 {
21 }
InstrumentCollection * m_instruments
The edited/controlled instruments. This pointer is borrowed, not owned.

Member Function Documentation

◆ addCopy()

InstrumentItem * InstrumentsEditController::addCopy ( const InstrumentItem instrument,
const QString &  name 
)

Copy an instrument, set its name and emit the respective signal.

Definition at line 34 of file InstrumentsEditController.cpp.

36 {
37  InstrumentItem* copy = m_instruments->insertCopy(*instrument);
38  copy->setInstrumentName(name);
40  return copy;
41 }
InstrumentItem * insertCopy(const InstrumentItem &source)
Inserts a deep copy (also of any non xml data in a pointwise axis) The id will not be copied,...
Abstract base class for instrument-specific item classes.
void setInstrumentName(const QString &instrumentName)
void instrumentAddedOrRemoved()
Signals a change in the list of instruments.
QString const & name(EShape k)
Definition: particles.cpp:20

References InstrumentCollection::insertCopy(), instrumentAddedOrRemoved(), m_instruments, GUI::RealSpace::Particles::name(), and InstrumentItem::setInstrumentName().

Referenced by InstrumentLibrary::add(), and InstrumentListModel::copyInstrument().

Here is the call graph for this function:

◆ addInstrument()

template<typename T >
T * InstrumentsEditController::addInstrument

Add an instrument and emit the respective signal.

Definition at line 91 of file InstrumentsEditController.h.

92 {
93  auto* t = m_instruments->addInstrument<T>();
95  return t;
96 }

References InstrumentCollection::addInstrument(), instrumentAddedOrRemoved(), and m_instruments.

Referenced by InstrumentListModel::addNewInstrument().

Here is the call graph for this function:

◆ collectedItems()

◆ instrumentAddedOrRemoved

void InstrumentsEditController::instrumentAddedOrRemoved ( )
signal

◆ instrumentChanged

◆ instrumentNameChanged

void InstrumentsEditController::instrumentNameChanged ( const InstrumentItem instrument)
signal

Signals name change of the given instrument.

In addition to this, instrumentChanged() will be emitted as well.

Referenced by InstrumentListModel::InstrumentListModel(), RealDataPropertiesWidget::RealDataPropertiesWidget(), and setInstrumentName().

◆ notifyInstrumentChanged()

void InstrumentsEditController::notifyInstrumentChanged ( InstrumentItem instrument)

Simply emits the instrumentChanged signal. Call this whenever you change an instrument's data without using this edit controller. By calling this method, the listeners will be notified about the changes.

Definition at line 59 of file InstrumentsEditController.cpp.

60 {
61  emit instrumentChanged(instrument);
62 }
void instrumentChanged(const InstrumentItem *instrument)
Signals any change in the settings of the given instrument.

References instrumentChanged().

Referenced by InstrumentLibraryEditor::onInstrumentChangedByEditor(), and InstrumentView::onInstrumentChangedByEditor().

◆ removeInstrument()

void InstrumentsEditController::removeInstrument ( InstrumentItem instrument)

Add an instrument and emit the respective signal.

Definition at line 28 of file InstrumentsEditController.cpp.

29 {
30  m_instruments->removeInstrument(instrument);
32 }
void removeInstrument(InstrumentItem *instrument)

References instrumentAddedOrRemoved(), m_instruments, and InstrumentCollection::removeInstrument().

Referenced by InstrumentListModel::removeInstrument().

Here is the call graph for this function:

◆ setInstrumentName()

void InstrumentsEditController::setInstrumentName ( InstrumentItem instrument,
const QString &  name 
)

Set an instrument's name and emit the respective signal.

Definition at line 43 of file InstrumentsEditController.cpp.

44 {
45  if (instrument->instrumentName() != name) {
46  instrument->setInstrumentName(name);
47  emit instrumentNameChanged(instrument);
48  emit instrumentChanged(instrument);
49  }
50 }
QString instrumentName() const
void instrumentNameChanged(const InstrumentItem *instrument)
Signals name change of the given instrument.

References instrumentChanged(), InstrumentItem::instrumentName(), instrumentNameChanged(), GUI::RealSpace::Particles::name(), and InstrumentItem::setInstrumentName().

Referenced by InstrumentListModel::addNewInstrument(), InstrumentView::onInstrumentNameEdited(), and InstrumentEditController::setInstrumentName().

Here is the call graph for this function:

◆ updateInstrumentToRealDataItem()

void InstrumentsEditController::updateInstrumentToRealDataItem ( InstrumentItem instrument,
const RealDataItem realDataItem 
)

Calls the instrument's updateToRealData and emits the respective signal.

Definition at line 52 of file InstrumentsEditController.cpp.

54 {
55  instrument->updateToRealData(realDataItem);
56  emit instrumentChanged(instrument);
57 }
virtual void updateToRealData(const RealDataItem *item)=0

References instrumentChanged(), and InstrumentItem::updateToRealData().

Referenced by LinkInstrumentManager::canLinkDataToInstrument().

Here is the call graph for this function:

Member Data Documentation

◆ m_instruments

InstrumentCollection* InstrumentsEditController::m_instruments
private

The edited/controlled instruments. This pointer is borrowed, not owned.

Definition at line 86 of file InstrumentsEditController.h.

Referenced by addCopy(), addInstrument(), collectedItems(), and removeInstrument().


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