![]() |
ImFusion SDK 4.3
|
#include <ImFusion/GUI/PropertiesWidget.h>
The PropertiesWidget class provides a widget for Properties. More...
The PropertiesWidget class provides a widget for Properties.
PropertiesWidget creates a input widget for each parameter in a Properties instance. Which kind of widget is created depends on the ParamType of the parameter, e.g. a double parameter is represented by a QDoubleSpinBox. The paramAttributes will be reflected by the widget (e.g. min/max values). PropertiesWidget creates a GroupBox holding a sub-PropertiesWidget for each subproperty of a Properties instance.
As with other Configurable classes, the Properties instance passed to the constructor or to configure is only used to initialize the widgets but will not be stored by the PropertiesWidget. Therefore if the user changes a parameter, the corresponding value is NOT updated in the Properties instance. Instead the current values can be retrieved with the configuration method.
By default, the PropertiesWidget arranges the parameters as a vertical list with a label containing the parameter name on the left and the widget for the value on the right. The sub-properties are represented by sub-PropertiesWidgets that are always inserted after the list of parameters. The parameters and sub-properties are sorted by the same order they are stored in the Properties.
Alternatively, the PropertiesWidget can also utilize an existing widget UI as a template and use specific widgets in this template as controls for parameters. The PropertiesWidget won't take ownership over the template, neither will the template be added to a layout. Each widget in the template that should represent a parameter, must have a dynamic property called 'param' that has the parameter name as a value. To assign a widget to a parameter in a sub-property, use the name of the sub-property as a prefix path, e.g. the parameter 'foo' in the sub-property 'bar' would be called 'bar/foo'. The widget must be of the same widget type as the default widget type of the parameter, e.g. a ParamType::Double requires a QDoubleSpinBox, while a ParamType::Enum requires a QComboBox. For a list of default widget types for each ParamType, see createDefaultParamControl. If a parameter does not have a matching widget in the template, the previous default behaviour will be used. The widgets used for parameters are not deleted or re-created by the PropertiesWidget. Template widgets will not be assigned a label with the parameter name. When changing any of the template widget's 'param' properties after creating the PropertiesWidget, make sure to call updateUiTemplateParams().
Example:
With the following properties:
Signals | |
void | parameterChanged (const std::string &name) |
Emitted when parameter 'name' was changed. | |
Public Member Functions | |
PropertiesWidget (QWidget *parent=0) | |
Creates an empty PropertiesWidget. | |
PropertiesWidget (const Properties *p, QWidget *uiTemplate=0, QWidget *parent=0) | |
Creates a PropertiesWidget and initializes it with the given Properties. | |
void | setSplitCamelCase (bool enable) |
Splits parameter names into words for display. | |
virtual void | setCustomControl (const std::string ¶meter, ParamControl *control) |
Assignes a custom widget to the given parameter. | |
void | setCustomWidget (const std::string &subPropertyName, std::unique_ptr< QWidget > widget) |
Assign a custom widget to the subproperty. | |
void | configure (const Properties *p) override |
Updates the current widgets with the parameters from p. | |
void | configuration (Properties *p) const override |
Retrieves the values from the widgets and stores them in p. | |
void | updateControls (const Properties *p) |
Updates existing controls with the parameters from p. | |
void | updateUiTemplateParams () |
Re-scans the given UI template for widgets with 'param' properties. | |
void | setUpdateResetMatrix (bool update) |
Set this flag to indicate that EigenMatrixParamControls should update the reset-matrix or not. | |
![]() | |
virtual void | configureDefaults () |
Retrieve the properties of this object, replaces values with their defaults and sets it again. | |
void | registerParameter (ParameterBase *param) |
Register the given Parameter or SubProperty, so that it will be configured during configure()/configuration(). | |
void | unregisterParameter (const ParameterBase *param) |
Remove the given Parameter or SubProperty from the list of registered parameters. | |
Configurable (const Configurable &rhs) | |
Configurable (Configurable &&rhs) noexcept | |
Configurable & | operator= (const Configurable &) |
Configurable & | operator= (Configurable &&) noexcept |
![]() | |
SignalReceiver ()=default | |
Default constructor. | |
SignalReceiver (const SignalReceiver &other) | |
Copy constructor, does not copy any existing signal connections from other. | |
SignalReceiver & | operator= (SignalReceiver rhs) |
Assignment operator, disconnects all existing connections, does not copy any existing signal connections from rhs. | |
virtual | ~SignalReceiver () |
Virtual destructor disconnects from all connected signals. | |
Additional Inherited Members | |
![]() | |
Signal | signalParametersChanged |
Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted. | |
![]() | |
void | disconnectAll () |
Disconnects all existing connections. | |
![]() | |
std::vector< Param > | m_params |
List of all registered Parameter and SubProperty instances. | |
PropertiesWidget | ( | const Properties * | p, |
QWidget * | uiTemplate = 0, | ||
QWidget * | parent = 0 ) |
Creates a PropertiesWidget and initializes it with the given Properties.
An optional QWidget can be passed as a UI template. The PropertiesWidget will use specific widgets in the UI template for parameters instead of creating new widgets by it's own. The widget belonging to a parameter is expected to have a QObject property with the name 'param' and the parameter name as value.
void setSplitCamelCase | ( | bool | enable | ) |
Splits parameter names into words for display.
This only changes the displayed parameter name not the name in the properties. Example:
someExampleParameter -> Some example parameter
|
virtual |
Assignes a custom widget to the given parameter.
The PropertiesWidget will claim ownership of the ParamControl and may re-parent its widget. The widget of the control will only be visible if the parameter is part of the Properties. The control object will remain valid throughout the livetime of the PropertiesWidget, independent of the visibility of the widget. The custom control will not be used until the widget is configured again
void setCustomWidget | ( | const std::string & | subPropertyName, |
std::unique_ptr< QWidget > | widget ) |
Assign a custom widget to the subproperty.
This widget will not be re-configured. If widget
inherits from Configurable, then configure/configuration will be called on it for the given subProperty from PropertiesWidget::configure/configuration. In addition, in this case the widget's signalParametersChanged will be connected to the PropertiesWidget's parameterChanged signal. Otherwise it is the responsibility of the widget to handle all signals and re-configure its parameters if present. To take an effect, the PropertiesWidget should get configured after calling this function. Note: if there are multiple subProperties with the same name, only one widget will be added for the last subProperty
|
overridevirtual |
Updates the current widgets with the parameters from p.
Reimplemented from Configurable.
|
overridevirtual |
Retrieves the values from the widgets and stores them in p.
Reimplemented from Configurable.
void updateControls | ( | const Properties * | p | ) |
Updates existing controls with the parameters from p.
void updateUiTemplateParams | ( | ) |
Re-scans the given UI template for widgets with 'param' properties.
|
inline |
Set this flag to indicate that EigenMatrixParamControls
should update the reset-matrix or not.
This flag is set in DefaultAlgorithmController::paramChanged
and used by PropertiesWidget
class to set the corresponding flag in EigenMatrixParamControls
. This mechanism is used to avoid updating the reset-matrix when changes are GUI changes internal to EigenMatrixParamControls
. See also SUITE-3626.
|
signal |
Emitted when parameter 'name' was changed.
Also emitted when a parameter in a sub-properties changes, in which case 'name' will be prefix with the sub-properties path (e.g. 'subprop/param').