ImFusion SDK 4.3
PropertiesWidget Class Reference

#include <ImFusion/GUI/PropertiesWidget.h>

The PropertiesWidget class provides a widget for Properties. More...

+ Inheritance diagram for PropertiesWidget:

Detailed Description

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().

See also
Object Serialization

Example:

QGridLayout* layout = new QGridLayout;
// create controls for Param1 and Param2 which are ParamType Double and String
QDoubleSpinBox* param1 = new QDoubleSpinBox;
param1->setProperty("param", "Param1");
layout->addWidget(param1, 0, 0);
QLineEdit* param2 = new QLineEdit;
param2->setProperty("param", "Param2");
layout->addWidget(param2, 0, 1);
// create a control for Param1 of the sub-properties Subprop
QSpinBox* subparam1 = new QSpinBox;
subparam1->setProperty("param", "Subprop/Param1");
layout->addWidget(subparam1, 1, 0, 1, 2);
// the template can include any widget
QPushButton* button = new QPushButton("A Button");
layout->addWidget(button, 2, 0, 1, 2);
// make sure that the widget you pass as a template is
setLayout(layout);
m_algorithm->configuration(&p);
// create a new PropertiesWidget that uses this widget as template
// add the PropertiesWidget to this widget
layout->addWidget(pw, 3, 0, 1, 2);

With the following properties:

p->setParam("Param1", 1.0);
p->setParam("Param2", "Spam");
p->setParam("Param Outside", 1);
p->setParamAttributes("Param Outside", "min: 0, max: 10");
ImFusion::Properties* sub = p->addSubProperties("Subprop");
sub->setParam("Param1", 10);

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 &parameter, 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.
 
- Public Member Functions inherited from Configurable
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
 
Configurableoperator= (const Configurable &)
 
Configurableoperator= (Configurable &&) noexcept
 
- Public Member Functions inherited from SignalReceiver
 SignalReceiver ()=default
 Default constructor.
 
 SignalReceiver (const SignalReceiver &other)
 Copy constructor, does not copy any existing signal connections from other.
 
SignalReceiveroperator= (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

- Public Attributes inherited from Configurable
Signal signalParametersChanged
 Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted.
 
- Protected Member Functions inherited from SignalReceiver
void disconnectAll ()
 Disconnects all existing connections.
 
- Protected Attributes inherited from Configurable
std::vector< Paramm_params
 List of all registered Parameter and SubProperty instances.
 

Constructor & Destructor Documentation

◆ PropertiesWidget()

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.

Member Function Documentation

◆ setSplitCamelCase()

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

◆ setCustomControl()

virtual void setCustomControl ( const std::string & parameter,
ParamControl * control )
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

◆ setCustomWidget()

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

◆ configure()

void configure ( const Properties * p)
overridevirtual

Updates the current widgets with the parameters from p.

Reimplemented from Configurable.

◆ configuration()

void configuration ( Properties * p) const
overridevirtual

Retrieves the values from the widgets and stores them in p.

Reimplemented from Configurable.

◆ updateControls()

void updateControls ( const Properties * p)

Updates existing controls with the parameters from p.

Note
This will only update controls that were initially created by configure(). That means that p must be a subset of the initial widget configuration for changes to take effect.

◆ updateUiTemplateParams()

void updateUiTemplateParams ( )

Re-scans the given UI template for widgets with 'param' properties.

Note
Since PropertiesWidget caches the param-widget map for the UI template, make sure to call this method when you change any of the 'param' properties of the UI template after you created the PropertiesWidget.

◆ setUpdateResetMatrix()

void setUpdateResetMatrix ( bool update)
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.

◆ parameterChanged

void parameterChanged ( const std::string & name)
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').


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close