DynExp
Highly flexible laboratory automation for dynamically changing experiments.
ParamsConfigDialog Class Reference

Defines the configuration dialog. The dialog must be displayed by calling ParamsConfigDialog::Display(). Do not use methods of QDialog! More...

+ Inheritance diagram for ParamsConfigDialog:

Classes

struct  Param
 Collection of data defining a single parameter to be managed by a ParamsConfigDialog instance. Used by ParamsConfigDialog::InsertWidget(). More...
 

Public Types

using NumberType = double
 Number type used for numeric parameters (DynExp::ParamsBase::Param) More...
 
using TextType = Util::TextType
 String type of text-type parameters (DynExp::ParamsBase::Param) More...
 
using TextRefType = Util::TextRefType
 Reference-to-string type of text-type parameters (DynExp::ParamsBase::Param) More...
 
using TextListType = Util::TextListType
 List type of text-type parameters. More...
 
using TextListIndexType = Util::TextListIndexType
 List index type of Util::TextListType. More...
 
using IndexType = qulonglong
 ID type of objects/items managed by DynExp. More...
 

Public Member Functions

 ParamsConfigDialog (QWidget *parent, const DynExp::DynExpCore &Core, std::string Title)
 Constructs a ParamsConfigDialog instance. More...
 
 ~ParamsConfigDialog ()=default
 
void AddParam (ParamInfo &&Info, const std::any Destiny, const NumberType Value, const NumberType MinValue, const NumberType MaxValue, const NumberType Precision, const NumberType Increment)
 Appends a parameter to the configuration dialog. More...
 
void AddParam (ParamInfo &&Info, const std::any Destiny, const TextType Value, const DynExp::TextUsageType TextUsage)
 Appends a parameter to the configuration dialog. More...
 
void AddParam (ParamInfo &&Info, const std::any Destiny, const TextRefType Value, const TextListType &TextList, const bool AllowResetToDefault)
 Appends a parameter to the configuration dialog. More...
 
void AddParam (ParamInfo &&Info, const std::any Destiny, const TextListIndexType Value, const TextListIndexType DefaultValue, const TextListType &TextList)
 Appends a parameter to the configuration dialog. More...
 
template<typename EnumType , std::enable_if_t< std::is_enum_v< EnumType >, int > = 0>
void AddParam (ParamInfo &&Info, const std::any Destiny, const EnumType Value, const EnumType DefaultValue, const Util::TextValueListType< EnumType > &TextValueList)
 Appends a parameter to the configuration dialog. More...
 
void AddParam (ParamInfo &&Info, const std::any Destiny, const DynExp::ItemIDType Value, bool IsOptional, std::string_view IconResourcePath, FunctionsToCallIfAcceptedType FunctionToCallIfAccepted, Util::TextValueListType< IndexType > &&ItemIDsWithLabels)
 Appends a parameter to the configuration dialog. More...
 
void AddParam (ParamInfo &&Info, const std::any Destiny, const std::vector< DynExp::ItemIDType > &Values, bool IsOptional, std::string_view IconResourcePath, FunctionsToCallIfAcceptedType FunctionToCallIfAccepted, Util::TextValueListType< IndexType > &&ItemIDsWithLabels)
 Appends a parameter to the configuration dialog. More...
 
size_t GetNumParams () const noexcept
 Returns the number of parameters added to the configuration dialog. More...
 
bool IsResetRequired () const noexcept
 Determines whether the DynExp::Object instance whose parameters have been edited needs to be reset to apply the changes. More...
 
bool Display (DynExp::Object *Object=nullptr)
 Displays the configuration dialog. More...
 

Private Types

using FunctionsToCallIfAcceptedType = std::function< void(void)>
 Signature of a function which is called when the ParamsConfigDialog is closed by the user by clicking the 'accept' button. More...
 

Private Slots

void OnOpenParam ()
 Called when clicking the 'Browse' button for a DynExp::TextUsageType::Path or DynExp::TextUsageType::Code parameter. More...
 
void OnEditParam ()
 Called when opening a TextEditor for a DynExp::TextUsageType::Code parameter. More...
 
void OnResetParam ()
 Called when resetting a parameter to its default value. More...
 
virtual void accept () override
 Called when the settings dialog is accepted clicking its 'OK' button. More...
 
virtual void reject () override
 Called when the settings dialog is rejected clicking its 'Cancel' button. More...
 

Private Member Functions

void InsertWidget (ParamInfo &&Info, Param &&ParamData)
 Creates Qt widgets for editing a parameter and inserts them into the configuration dialog. More...
 
template<typename ParamT >
void Assign (ParamT &Param, typename ParamT::UnderlyingType Value)
 When the settings dialog is closed by accepting it, assign a single value from the user interface to the actual parameter retrieved from ParamsConfigDialog::Param::Destiny. Updates ResetRequired. More...
 
template<typename ParamT >
void Assign (ParamT &Param, const std::vector< typename ParamT::UnderlyingType::value_type > &Values)
 When the settings dialog is closed by accepting it, assign a list of values from the user interface to the actual parameter retrieved from ParamsConfigDialog::Param::Destiny. Updates ResetRequired. More...
 
void HandleTextEditorDialogsOnClose ()
 Called when the settings dialog is closed. Removes the parent widget of text editors listed in TextEditorDialogs to keep them open after closing this dialog. More...
 

Private Attributes

const DynExp::DynExpCoreCore
 Reference to DynExp's core. More...
 
std::vector< ParamParamList
 List of all parameters assigned to this ParamsConfigDialog instance. More...
 
std::vector< FunctionsToCallIfAcceptedTypeFunctionsToCallIfAccepted
 List of functions to be called when acceptig the dialog. Refer to ParamsConfigDialog::FunctionsToCallIfAcceptedType. More...
 
DynExp::ObjectObject
 DynExp::Object whose parameters are edited. nullptr if a new DynExp::Object is created and synchronization to achieve thread-safety does not apply. More...
 
bool ResetRequired
 Becomes true if an existing DynExp::Object is edited and needs to be reset to apply changes after clicking the dialog's 'accept' button. More...
 
std::vector< TextEditor * > TextEditorDialogs
 Keeps a list of text editor dialogs so that their ownership can be removed when the ParamsConfigDialog instance is closed. More...
 
Ui::ParamsConfig ui
 Bundles Qt widgets of the ParamsConfigDialog instance's user interface. More...
 

Detailed Description

Defines the configuration dialog. The dialog must be displayed by calling ParamsConfigDialog::Display(). Do not use methods of QDialog!

Definition at line 71 of file ParamsConfig.h.

Member Typedef Documentation

◆ FunctionsToCallIfAcceptedType

using ParamsConfigDialog::FunctionsToCallIfAcceptedType = std::function<void(void)>
private

Signature of a function which is called when the ParamsConfigDialog is closed by the user by clicking the 'accept' button.

Definition at line 94 of file ParamsConfig.h.

◆ IndexType

using ParamsConfigDialog::IndexType = qulonglong

ID type of objects/items managed by DynExp.

It would be better to use DynExp::ItemIDType here, but this is incompatible with the g++ compiler. IndexType should equal ChoiceListDialog::IndexType.

Definition at line 87 of file ParamsConfig.h.

◆ NumberType

Number type used for numeric parameters (DynExp::ParamsBase::Param)

Definition at line 76 of file ParamsConfig.h.

◆ TextListIndexType

◆ TextListType

List type of text-type parameters.

Definition at line 79 of file ParamsConfig.h.

◆ TextRefType

Reference-to-string type of text-type parameters (DynExp::ParamsBase::Param)

Definition at line 78 of file ParamsConfig.h.

◆ TextType

String type of text-type parameters (DynExp::ParamsBase::Param)

Definition at line 77 of file ParamsConfig.h.

Constructor & Destructor Documentation

◆ ParamsConfigDialog()

ParamsConfigDialog::ParamsConfigDialog ( QWidget *  parent,
const DynExp::DynExpCore Core,
std::string  Title 
)

Constructs a ParamsConfigDialog instance.

Parameters
parentQWidget acting as a parent of this modal dialog
CoreReference to DynExp's core
TitleTitle to be displayed in the dialog's title bar

Definition at line 34 of file ParamsConfig.cpp.

◆ ~ParamsConfigDialog()

ParamsConfigDialog::~ParamsConfigDialog ( )
default

Member Function Documentation

◆ accept

void ParamsConfigDialog::accept ( )
overrideprivatevirtualslot

Called when the settings dialog is accepted clicking its 'OK' button.

Definition at line 304 of file ParamsConfig.cpp.

◆ AddParam() [1/7]

void ParamsConfigDialog::AddParam ( ParamInfo &&  Info,
const std::any  Destiny,
const DynExp::ItemIDType  Value,
bool  IsOptional,
std::string_view  IconResourcePath,
FunctionsToCallIfAcceptedType  FunctionToCallIfAccepted,
Util::TextValueListType< IndexType > &&  ItemIDsWithLabels 
)

Appends a parameter to the configuration dialog.

Parameters
InfoParameter title and description to be displayed in the dialog
DestinyParameter holding the value to be edited. Expects the type LinkParamRefWrapperType.
ValueIndex of the entry in ItemIDsWithLabels to select initially
IsOptionalDetermines whether this parameter is optional. Optional parameters do not have to point to a valid object ID. If true, a 'None' entry with value DynExp::ItemIDNotSet is appended to ItemIDsWithLabels.
IconResourcePathQt resource path describing an icon being displayed along with this parameter
FunctionToCallIfAcceptedRefer to FunctionsToCallIfAccepted.
ItemIDsWithLabelsList mapping the IDs of selectable DynExp::Object instances to text entries

Definition at line 108 of file ParamsConfig.cpp.

◆ AddParam() [2/7]

template<typename EnumType , std::enable_if_t< std::is_enum_v< EnumType >, int > >
void ParamsConfigDialog::AddParam ( ParamInfo &&  Info,
const std::any  Destiny,
const EnumType  Value,
const EnumType  DefaultValue,
const Util::TextValueListType< EnumType > &  TextValueList 
)

Appends a parameter to the configuration dialog.

Template Parameters
EnumTypeEnumeration type which is convertible to a numeric type (only unscoped enumerations)
Parameters
InfoParameter title and description to be displayed in the dialog
DestinyParameter holding the value to be edited. Expects the type ParamRefWrapperType instantiated with DestinyType as DynExp::ParamsBase::EnumParamSignedIntegerType if EnumType's underlying type is signed or with DestinyType as DynExp::ParamsBase::EnumParamUnsignedIntegerType if EnumType's underlying type is unsigned.
ValueInitial enum value to be displayed in the configuration dialog for this parameter.
DefaultValueDefaultValue Refer to ParamsConfigDialog::Param::DefaultIndex.
TextValueListList mapping the enum items' values to text entries

Definition at line 379 of file ParamsConfig.h.

◆ AddParam() [3/7]

void ParamsConfigDialog::AddParam ( ParamInfo &&  Info,
const std::any  Destiny,
const NumberType  Value,
const NumberType  MinValue,
const NumberType  MaxValue,
const NumberType  Precision,
const NumberType  Increment 
)

Appends a parameter to the configuration dialog.

Parameters
InfoParameter title and description to be displayed in the dialog
DestinyParameter holding the value to be edited. Expects the type ParamRefWrapperType instantiated with DestinyType as NumberType.
ValueInitial value to be displayed in the configuration dialog for this parameter
MinValueMinimal allowed value
MaxValueMaximal allowed value
PrecisionValue precision
IncrementValue increment

Definition at line 43 of file ParamsConfig.cpp.

◆ AddParam() [4/7]

void ParamsConfigDialog::AddParam ( ParamInfo &&  Info,
const std::any  Destiny,
const std::vector< DynExp::ItemIDType > &  Values,
bool  IsOptional,
std::string_view  IconResourcePath,
FunctionsToCallIfAcceptedType  FunctionToCallIfAccepted,
Util::TextValueListType< IndexType > &&  ItemIDsWithLabels 
)

Appends a parameter to the configuration dialog.

Parameters
InfoParameter title and description to be displayed in the dialog
DestinyParameter holding the value to be edited. Expects the type LinkListParamRefWrapperType.
ValuesIndices of the entries in ItemIDsWithLabels to select initially
IsOptionalDetermines whether this parameter is optional. Optional parameters do not have to point to valid object IDs.
IconResourcePathQt resource path describing an icon being displayed along with this parameter
FunctionToCallIfAcceptedRefer to FunctionsToCallIfAccepted.
ItemIDsWithLabelsList mapping the IDs of selectable DynExp::Object instances to text entries

Definition at line 136 of file ParamsConfig.cpp.

◆ AddParam() [5/7]

void ParamsConfigDialog::AddParam ( ParamInfo &&  Info,
const std::any  Destiny,
const TextListIndexType  Value,
const TextListIndexType  DefaultValue,
const TextListType TextList 
)

Appends a parameter to the configuration dialog.

Parameters
InfoParameter title and description to be displayed in the dialog
DestinyParameter holding the value to be edited. Expects the type ParamRefWrapperType instantiated with DestinyType as IndexType.
ValueIndex of the entry in TextList to select initially
DefaultValueRefer to ParamsConfigDialog::Param::DefaultIndex.
TextListList of text entries from which the user can select one
Exceptions
Util::EmptyExceptionis thrown if TextList is empty.
Util::OutOfRangeExceptionis thrown if Value or DefaultValue are larger than the amount of entries in TextList.

Definition at line 89 of file ParamsConfig.cpp.

◆ AddParam() [6/7]

void ParamsConfigDialog::AddParam ( ParamInfo &&  Info,
const std::any  Destiny,
const TextRefType  Value,
const TextListType TextList,
const bool  AllowResetToDefault 
)

Appends a parameter to the configuration dialog.

Parameters
InfoParameter title and description to be displayed in the dialog
DestinyParameter holding the value to be edited. Expects the type ParamRefWrapperType instantiated with DestinyType as TextType.
ValueInitial value to be displayed in the configuration dialog for this parameter. The text must match one of the entries in TextList. If it does not match any entry, the first entry of TextList will be selected.
TextListList of text entries from which the user can select one
AllowResetToDefaultRefer to ParamsConfigDialog::Param::AllowResetToDefault.
Exceptions
Util::EmptyExceptionis thrown if TextList is empty.

Definition at line 67 of file ParamsConfig.cpp.

◆ AddParam() [7/7]

void ParamsConfigDialog::AddParam ( ParamInfo &&  Info,
const std::any  Destiny,
const TextType  Value,
const DynExp::TextUsageType  TextUsage 
)

Appends a parameter to the configuration dialog.

Parameters
InfoParameter title and description to be displayed in the dialog
DestinyParameter holding the value to be edited. Expects the type ParamRefWrapperType instantiated with DestinyType as TextType.
ValueInitial value to be displayed in the configuration dialog for this parameter
TextUsageRefer to DynExp::TextUsageType.

Definition at line 57 of file ParamsConfig.cpp.

◆ Assign() [1/2]

template<typename ParamT >
void ParamsConfigDialog::Assign ( ParamT &  Param,
const std::vector< typename ParamT::UnderlyingType::value_type > &  Values 
)
private

When the settings dialog is closed by accepting it, assign a list of values from the user interface to the actual parameter retrieved from ParamsConfigDialog::Param::Destiny. Updates ResetRequired.

Template Parameters
ParamTParameter type derived from DynExp::ParamsBase::TypedParamBase
Parameters
ParamParameter to update
ValuesList of value to set the parameter to

Definition at line 412 of file ParamsConfig.h.

◆ Assign() [2/2]

template<typename ParamT >
void ParamsConfigDialog::Assign ( ParamT &  Param,
typename ParamT::UnderlyingType  Value 
)
private

When the settings dialog is closed by accepting it, assign a single value from the user interface to the actual parameter retrieved from ParamsConfigDialog::Param::Destiny. Updates ResetRequired.

Template Parameters
ParamTParameter type derived from DynExp::ParamsBase::TypedParamBase
Parameters
ParamParameter to update
ValueValue to set the parameter to

Definition at line 405 of file ParamsConfig.h.

◆ Display()

bool ParamsConfigDialog::Display ( DynExp::Object Object = nullptr)

Displays the configuration dialog.

Parameters
ObjectDynExp::Object whose parameters are edited. Refer to ParamsConfigDialog::Object.
Returns
Returns true if 'OK' has been clicked accepting the dialog. Otherwise, returns false.

Definition at line 155 of file ParamsConfig.cpp.

◆ GetNumParams()

size_t ParamsConfigDialog::GetNumParams ( ) const
inlinenoexcept

Returns the number of parameters added to the configuration dialog.

Returns
Size of ParamList

Definition at line 279 of file ParamsConfig.h.

◆ HandleTextEditorDialogsOnClose()

void ParamsConfigDialog::HandleTextEditorDialogsOnClose ( )
private

Called when the settings dialog is closed. Removes the parent widget of text editors listed in TextEditorDialogs to keep them open after closing this dialog.

Definition at line 221 of file ParamsConfig.cpp.

◆ InsertWidget()

void ParamsConfigDialog::InsertWidget ( ParamInfo &&  Info,
Param &&  ParamData 
)
private

Creates Qt widgets for editing a parameter and inserts them into the configuration dialog.

Parameters
InfoParameter title and description to be displayed in the dialog
ParamDataType and properties of the parameter to add controls to the user interface for

Definition at line 168 of file ParamsConfig.cpp.

◆ IsResetRequired()

bool ParamsConfigDialog::IsResetRequired ( ) const
inlinenoexcept

Determines whether the DynExp::Object instance whose parameters have been edited needs to be reset to apply the changes.

Returns
Returns ResetRequired.

Definition at line 286 of file ParamsConfig.h.

◆ OnEditParam

void ParamsConfigDialog::OnEditParam ( )
privateslot

Called when opening a TextEditor for a DynExp::TextUsageType::Code parameter.

Definition at line 252 of file ParamsConfig.cpp.

◆ OnOpenParam

void ParamsConfigDialog::OnOpenParam ( )
privateslot

Called when clicking the 'Browse' button for a DynExp::TextUsageType::Path or DynExp::TextUsageType::Code parameter.

Definition at line 239 of file ParamsConfig.cpp.

◆ OnResetParam

void ParamsConfigDialog::OnResetParam ( )
privateslot

Called when resetting a parameter to its default value.

Definition at line 269 of file ParamsConfig.cpp.

◆ reject

void ParamsConfigDialog::reject ( )
overrideprivatevirtualslot

Called when the settings dialog is rejected clicking its 'Cancel' button.

Definition at line 377 of file ParamsConfig.cpp.

Member Data Documentation

◆ Core

const DynExp::DynExpCore& ParamsConfigDialog::Core
private

Reference to DynExp's core.

Definition at line 334 of file ParamsConfig.h.

◆ FunctionsToCallIfAccepted

std::vector<FunctionsToCallIfAcceptedType> ParamsConfigDialog::FunctionsToCallIfAccepted
private

List of functions to be called when acceptig the dialog. Refer to ParamsConfigDialog::FunctionsToCallIfAcceptedType.

Definition at line 345 of file ParamsConfig.h.

◆ Object

DynExp::Object* ParamsConfigDialog::Object
private

DynExp::Object whose parameters are edited. nullptr if a new DynExp::Object is created and synchronization to achieve thread-safety does not apply.

Definition at line 351 of file ParamsConfig.h.

◆ ParamList

std::vector<Param> ParamsConfigDialog::ParamList
private

List of all parameters assigned to this ParamsConfigDialog instance.

Definition at line 339 of file ParamsConfig.h.

◆ ResetRequired

bool ParamsConfigDialog::ResetRequired
private

Becomes true if an existing DynExp::Object is edited and needs to be reset to apply changes after clicking the dialog's 'accept' button.

Definition at line 357 of file ParamsConfig.h.

◆ TextEditorDialogs

std::vector<TextEditor*> ParamsConfigDialog::TextEditorDialogs
private

Keeps a list of text editor dialogs so that their ownership can be removed when the ParamsConfigDialog instance is closed.

Definition at line 363 of file ParamsConfig.h.

◆ ui

Ui::ParamsConfig ParamsConfigDialog::ui
private

Bundles Qt widgets of the ParamsConfigDialog instance's user interface.

Definition at line 368 of file ParamsConfig.h.


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