BornAgain
1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
|
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.
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) | |
InstrumentItem * | addCopy (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... | |
InstrumentCollection * | collectedItems () |
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 | |
InstrumentCollection * | m_instruments |
The edited/controlled instruments. This pointer is borrowed, not owned. More... | |
InstrumentsEditController::InstrumentsEditController | ( | InstrumentCollection * | instruments | ) |
Definition at line 18 of file InstrumentsEditController.cpp.
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.
References InstrumentCollection::insertCopy(), instrumentAddedOrRemoved(), m_instruments, GUI::RealSpace::Particles::name(), and InstrumentItem::setInstrumentName().
Referenced by InstrumentLibrary::add(), and InstrumentListModel::copyInstrument().
T * InstrumentsEditController::addInstrument |
Add an instrument and emit the respective signal.
Definition at line 91 of file InstrumentsEditController.h.
References InstrumentCollection::addInstrument(), instrumentAddedOrRemoved(), and m_instruments.
Referenced by InstrumentListModel::addNewInstrument().
InstrumentCollection * InstrumentsEditController::collectedItems | ( | ) |
The list of existing instruments.
Definition at line 23 of file InstrumentsEditController.cpp.
References m_instruments.
Referenced by InstrumentListModel::addNewInstrument(), InstrumentListModel::copyInstrument(), InstrumentListModel::data(), InstrumentListModel::instrumentForIndex(), InstrumentListModel::onInstrumentNameChanged(), and InstrumentListModel::rowCount().
|
signal |
Signals a change in the list of instruments.
Referenced by InstrumentLibrary::InstrumentLibrary(), LinkInstrumentManager::LinkInstrumentManager(), ProjectDocument::ProjectDocument(), RealDataPropertiesWidget::RealDataPropertiesWidget(), addCopy(), addInstrument(), and removeInstrument().
|
signal |
Signals any change in the settings of the given instrument.
Signals also a name change, which has its own additional signal
Referenced by InstrumentLibrary::InstrumentLibrary(), LinkInstrumentManager::LinkInstrumentManager(), ProjectDocument::ProjectDocument(), InstrumentView::hideEvent(), InstrumentEditController::notifyInclinationAxisChanged(), InstrumentEditController::notifyInstrumentChanged(), notifyInstrumentChanged(), InstrumentEditController::notifyWavelengthDistributionChanged(), InstrumentEditController::setDouble(), setInstrumentName(), InstrumentView::showEvent(), and updateInstrumentToRealDataItem().
|
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().
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.
References instrumentChanged().
Referenced by InstrumentLibraryEditor::onInstrumentChangedByEditor(), and InstrumentView::onInstrumentChangedByEditor().
void InstrumentsEditController::removeInstrument | ( | InstrumentItem * | instrument | ) |
Add an instrument and emit the respective signal.
Definition at line 28 of file InstrumentsEditController.cpp.
References instrumentAddedOrRemoved(), m_instruments, and InstrumentCollection::removeInstrument().
Referenced by InstrumentListModel::removeInstrument().
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.
References instrumentChanged(), InstrumentItem::instrumentName(), instrumentNameChanged(), GUI::RealSpace::Particles::name(), and InstrumentItem::setInstrumentName().
Referenced by InstrumentListModel::addNewInstrument(), InstrumentView::onInstrumentNameEdited(), and InstrumentEditController::setInstrumentName().
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.
References instrumentChanged(), and InstrumentItem::updateToRealData().
Referenced by LinkInstrumentManager::canLinkDataToInstrument().
|
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().