Mantid
|
This class defines a widget for selecting an instrument known to Mantid. More...
#include <InstrumentSelector.h>
Public Slots | |
void | fillWithInstrumentsFromFacility (const QString &name=QString()) |
Update list for a new facility. More... | |
Signals | |
void | configValueChanged (const QString &, const QString &, const QString &) |
void | instrumentListUpdated () |
Signals that the list of instruments has been updated. More... | |
void | instrumentSelectionChanged (const QString &) |
Indicate that the instrument selection has changed. More... | |
Public Member Functions | |
bool | getAutoUpdate () |
Returns true of auto reloading on facility change is enabled. More... | |
QString | getFacility () |
Get the name of the facility instrumetns are currently loaded from. More... | |
QStringList | getTechniques () const |
Return the list of techniques. More... | |
InstrumentSelector (QWidget *parent=nullptr, bool init=true) | |
Default Constructor. More... | |
void | setAutoUpdate (bool autoUpdate) |
Enable or disable reloading on facility change. More... | |
void | setFacility (const QString &facilityName) |
Load instruments from a given facility. More... | |
void | setTechniques (const QStringList &techniques) |
Set the list of techniques. More... | |
void | updateInstrumentOnSelection (const bool storeChanges) |
Sets whether to update the default instrument on selection change. More... | |
~InstrumentSelector () override | |
Destructor. More... | |
Properties | |
QString | facility |
QStringList | techniques |
bool | updateOnFacilityChange |
Private Slots | |
void | updateInstrument (const QString &name) |
Handle an instrument seelction. More... | |
Private Member Functions | |
void | filterByTechniquesAtFacility (const QStringList &techniques, const Mantid::Kernel::FacilityInfo &facility) |
Filter the list to only show those supporting the given technique. More... | |
void | handleConfigChange (Mantid::Kernel::ConfigValChangeNotification_ptr pNf) |
Private Attributes | |
Poco::NObserver< InstrumentSelector, Mantid::Kernel::ConfigValChangeNotification > | m_changeObserver |
Poco Observer for Config Service Notifications. More... | |
const Mantid::Kernel::FacilityInfo * | m_currentFacility |
The current facility. More... | |
bool | m_init |
Should the object be initialized. More... | |
QString | m_selectedInstrument |
The last selected instrument. More... | |
bool | m_storeChanges |
Should the default instrument be changed when the selection changes. More... | |
QStringList | m_techniques |
A list of technqiues. More... | |
bool | m_updateOnFacilityChange |
If the instrument list should be reloaded when the facility changes. More... | |
This class defines a widget for selecting an instrument known to Mantid.
Definition at line 30 of file InstrumentSelector.h.
MantidQt::MantidWidgets::InstrumentSelector::InstrumentSelector | ( | QWidget * | parent = nullptr , |
bool | init = true |
||
) |
Default Constructor.
Default constructor.
parent | :: A widget to act as this widget's parent (default = NULL) |
init | :: If true then the widget will be populated with the instrument list (default = true) |
Definition at line 29 of file InstrumentSelector.cpp.
References Mantid::Kernel::ConfigServiceImpl::addObserver(), fillWithInstrumentsFromFacility(), Mantid::Kernel::SingletonHolder< T >::Instance(), m_changeObserver, and updateInstrument().
|
override |
Destructor.
Destructor for InstrumentSelector De-subscribes this object from the Poco NotificationCentre.
Definition at line 49 of file InstrumentSelector.cpp.
References Mantid::Kernel::SingletonHolder< T >::Instance(), m_changeObserver, and m_init.
|
signal |
|
slot |
Update list for a new facility.
Populate list with instruments from the named facility.
Note the current list is cleared.
name | :: The name of the facility whose instruments should be placed in the list. An empty string uses the default facility defined in Mantid. |
Definition at line 126 of file InstrumentSelector.cpp.
References addItem(), filterByTechniquesAtFacility(), Mantid::Kernel::ConfigServiceImpl::getFacility(), Mantid::Kernel::ConfigServiceImpl::getFacilityNames(), index, Mantid::Kernel::SingletonHolder< T >::Instance(), Mantid::Kernel::FacilityInfo::instrument(), instrumentListUpdated(), Mantid::Kernel::FacilityInfo::instruments(), m_currentFacility, m_techniques, Mantid::Kernel::InstrumentInfo::shortName(), and updateInstrument().
Referenced by handleConfigChange(), InstrumentSelector(), and setFacility().
|
private |
Filter the list to only show those supporting the given technique.
techniques | :: A string list containing the names of a techniques to filter the instrument list by |
facility | :: A FacilityInfo object |
Definition at line 216 of file InstrumentSelector.cpp.
References count, facility, instrumentListUpdated(), removeItem(), and techniques.
Referenced by fillWithInstrumentsFromFacility(), and setTechniques().
bool MantidQt::MantidWidgets::InstrumentSelector::getAutoUpdate | ( | ) |
Returns true of auto reloading on facility change is enabled.
Returns if the list of instruments will be refeshed when the facility changes.
Definition at line 67 of file InstrumentSelector.cpp.
References m_updateOnFacilityChange.
QString MantidQt::MantidWidgets::InstrumentSelector::getFacility | ( | ) |
Get the name of the facility instrumetns are currently loaded from.
Returns the name of the facility from which instruments are listed.
Definition at line 91 of file InstrumentSelector.cpp.
References m_currentFacility, and Mantid::Kernel::FacilityInfo::name().
QStringList MantidQt::MantidWidgets::InstrumentSelector::getTechniques | ( | ) | const |
Return the list of techniques.
Return the list of techniques that are supported by the instruments in the widget.
Definition at line 60 of file InstrumentSelector.cpp.
References m_techniques.
|
private |
Definition at line 99 of file InstrumentSelector.cpp.
References fillWithInstrumentsFromFacility(), m_currentFacility, m_updateOnFacilityChange, and Mantid::Kernel::FacilityInfo::name().
|
signal |
Signals that the list of instruments has been updated.
Referenced by fillWithInstrumentsFromFacility(), and filterByTechniquesAtFacility().
|
signal |
Indicate that the instrument selection has changed.
The parameter will contain the new name
Referenced by updateInstrument().
void MantidQt::MantidWidgets::InstrumentSelector::setAutoUpdate | ( | bool | autoUpdate | ) |
Enable or disable reloading on facility change.
Sets if the list of instruments should be updated folowing a facility change.
autoUpdate | If instruments are to be updated |
Definition at line 73 of file InstrumentSelector.cpp.
References m_updateOnFacilityChange.
void MantidQt::MantidWidgets::InstrumentSelector::setFacility | ( | const QString & | facilityName | ) |
Load instruments from a given facility.
Sets the facility instruments should be loaded from and refeshes the list.
facilityName | Name of facilty |
Definition at line 97 of file InstrumentSelector.cpp.
References fillWithInstrumentsFromFacility().
void MantidQt::MantidWidgets::InstrumentSelector::setTechniques | ( | const QStringList & | techniques | ) |
Set the list of techniques.
techniques | :: Only those instruments that support these techniques will be shown |
Definition at line 80 of file InstrumentSelector.cpp.
References count, filterByTechniquesAtFacility(), m_currentFacility, m_techniques, and techniques.
|
privateslot |
Handle an instrument seelction.
Handle an instrument being selected from the drop down.
Set the named instrument as the default for Mantid if desired and emit the signal if the new instrument is different to that which was previously selected.
name | :: A string containing the new instrument to set as the default |
Definition at line 192 of file InstrumentSelector.cpp.
References Mantid::Kernel::Logger::debug(), Mantid::API::g_log, Mantid::Kernel::SingletonHolder< T >::Instance(), instrumentSelectionChanged(), m_selectedInstrument, and m_storeChanges.
Referenced by fillWithInstrumentsFromFacility(), and InstrumentSelector().
void MantidQt::MantidWidgets::InstrumentSelector::updateInstrumentOnSelection | ( | const bool | storeChanges | ) |
Sets whether to update the default instrument on selection change.
storeChanges | :: True = store change on selection change |
Definition at line 180 of file InstrumentSelector.cpp.
References m_storeChanges.
|
private |
Poco Observer for Config Service Notifications.
Definition at line 80 of file InstrumentSelector.h.
Referenced by InstrumentSelector(), and ~InstrumentSelector().
|
private |
The current facility.
Definition at line 85 of file InstrumentSelector.h.
Referenced by fillWithInstrumentsFromFacility(), getFacility(), handleConfigChange(), and setTechniques().
|
private |
Should the object be initialized.
Definition at line 87 of file InstrumentSelector.h.
Referenced by ~InstrumentSelector().
|
private |
The last selected instrument.
Definition at line 93 of file InstrumentSelector.h.
Referenced by updateInstrument().
|
private |
Should the default instrument be changed when the selection changes.
Definition at line 89 of file InstrumentSelector.h.
Referenced by updateInstrument(), and updateInstrumentOnSelection().
|
private |
A list of technqiues.
Only those instruments supporting these techniques are shown.
Definition at line 83 of file InstrumentSelector.h.
Referenced by fillWithInstrumentsFromFacility(), getTechniques(), and setTechniques().
|
private |
If the instrument list should be reloaded when the facility changes.
Definition at line 91 of file InstrumentSelector.h.
Referenced by getAutoUpdate(), handleConfigChange(), and setAutoUpdate().
|
readwrite |
Definition at line 30 of file InstrumentSelector.h.
Referenced by filterByTechniquesAtFacility().
|
readwrite |
Definition at line 30 of file InstrumentSelector.h.
Referenced by filterByTechniquesAtFacility(), and setTechniques().
|
readwrite |
Definition at line 30 of file InstrumentSelector.h.