DynExp
Highly flexible laboratory automation for dynamically changing experiments.
Loading...
Searching...
No Matches
ParamsConfigDialog Class Reference

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

#include <ParamsConfig.h>

+ 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)
 
using TextType = Util::TextType
 " String type of text-type parameters (DynExp::ParamsBase::Param)
 
using TextRefType = Util::TextRefType
 Reference-to-string type of text-type parameters (DynExp::ParamsBase::Param)
 
using TextListType = Util::TextListType
 List type of text-type parameters.
 
using TextListIndexType = Util::TextListIndexType
 List index type of Util::TextListType.
 
using IndexType = qulonglong
 ID type of objects/items managed by DynExp.
 

Public Member Functions

 ParamsConfigDialog (QWidget *parent, const DynExp::DynExpCore &Core, std::string Title)
 Constructs a ParamsConfigDialog instance.
 
 ~ParamsConfigDialog ()
 
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.
 
void AddParam (ParamInfo &&Info, const std::any Destiny, const TextType Value, const DynExp::TextUsageType TextUsage)
 Appends a parameter to the configuration dialog.
 
void AddParam (ParamInfo &&Info, const std::any Destiny, const TextRefType Value, const TextListType &TextList, const bool AllowResetToDefault)
 Appends a parameter to the configuration dialog.
 
void AddParam (ParamInfo &&Info, const std::any Destiny, const TextListIndexType Value, const TextListIndexType DefaultValue, const TextListType &TextList)
 Appends a parameter to the configuration dialog.
 
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.
 
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.
 
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.
 
size_t GetNumParams () const noexcept
 Returns the number of parameters added to the configuration dialog.
 
bool IsResetRequired () const noexcept
 Determines whether the DynExp::Object instance whose parameters have been edited needs to be reset to apply the changes.
 
bool Display (DynExp::Object *Object=nullptr)
 Displays the configuration dialog.
 

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.
 

Private Slots

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

Private Member Functions

void InsertWidget (ParamInfo &&Info, Param &&ParamData)
 Creates Qt widgets for editing a parameter and inserts them into the configuration dialog.
 
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.
 
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.
 
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.
 

Private Attributes

std::unique_ptr< Ui::ParamsConfig > ui
 Bundles Qt widgets of the ParamsConfigDialog instance's user interface.
 
const DynExp::DynExpCoreCore
 Reference to DynExp's core.
 
std::vector< ParamParamList
 List of all parameters assigned to this ParamsConfigDialog instance.
 
std::vector< FunctionsToCallIfAcceptedTypeFunctionsToCallIfAccepted
 List of functions to be called when acceptig the dialog. Refer to ParamsConfigDialog::FunctionsToCallIfAcceptedType.
 
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.
 
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.
 
std::vector< TextEditor * > TextEditorDialogs
 Keeps a list of text editor dialogs so that their ownership can be removed when the ParamsConfigDialog instance is closed.
 

Detailed Description

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

Definition at line 75 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 98 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 91 of file ParamsConfig.h.

◆ NumberType

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

Definition at line 80 of file ParamsConfig.h.

◆ TextListIndexType

◆ TextListType

List type of text-type parameters.

Definition at line 83 of file ParamsConfig.h.

◆ TextRefType

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

Definition at line 82 of file ParamsConfig.h.

◆ TextType

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

"

Definition at line 81 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 35 of file ParamsConfig.cpp.

◆ ~ParamsConfigDialog()

ParamsConfigDialog::~ParamsConfigDialog ( )

Definition at line 45 of file ParamsConfig.cpp.

Member Function Documentation

◆ accept

void ParamsConfigDialog::accept ( )
overrideprivatevirtualslot

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

Definition at line 310 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 114 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 383 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 49 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 142 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 95 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 73 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 63 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 416 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 409 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 161 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 283 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 227 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 174 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 290 of file ParamsConfig.h.

◆ OnEditParam

void ParamsConfigDialog::OnEditParam ( )
privateslot

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

Definition at line 258 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 245 of file ParamsConfig.cpp.

◆ OnResetParam

void ParamsConfigDialog::OnResetParam ( )
privateslot

Called when resetting a parameter to its default value.

Definition at line 275 of file ParamsConfig.cpp.

◆ reject

void ParamsConfigDialog::reject ( )
overrideprivatevirtualslot

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

Definition at line 383 of file ParamsConfig.cpp.

Member Data Documentation

◆ Core

const DynExp::DynExpCore& ParamsConfigDialog::Core
private

Reference to DynExp's core.

Definition at line 343 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 354 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 360 of file ParamsConfig.h.

◆ ParamList

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

List of all parameters assigned to this ParamsConfigDialog instance.

Definition at line 348 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 366 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 372 of file ParamsConfig.h.

◆ ui

std::unique_ptr<Ui::ParamsConfig> ParamsConfigDialog::ui
private

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

Definition at line 338 of file ParamsConfig.h.


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