![]() |
CTK
0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
|
A Qt based implementation of the module front end. More...
#include <Libs/CommandLineModules/Frontend/QtGui/ctkCmdLineModuleFrontendQtGui.h>
Public Member Functions | |
ctkCmdLineModuleFrontendQtGui (const ctkCmdLineModuleReference &moduleRef) | |
virtual QObject * | guiHandle () const |
Create the actual Qt GUI. More... | |
virtual QList< QString > | parameterNames () const |
Returns a list of all valid parameter names. More... | |
virtual void | setParameterContainerEnabled (const bool &enabled) |
There is a container QWidget within each group box, so you can set the container widget to enabled/disabled, thereby affecting all child widgets, without overwriting the enabled/disabled status of the child widget. More... | |
virtual void | setValue (const QString ¶meter, const QVariant &value, int role=DisplayRole) |
Sets the parameter value. More... | |
virtual QVariant | value (const QString ¶meter, int role=LocalResourceRole) const |
Retrieves the current parameter value using the default QObject property for parameter values. More... | |
virtual | ~ctkCmdLineModuleFrontendQtGui () |
![]() | |
virtual ctkCmdLineModuleFuture | future () const |
Return the ctkCmdLineModuleFuture, derived from QFuture to provide asynchronous processing and interaction with the running frontend. More... | |
bool | isPaused () const |
Indicates if the currently associated ctkCmdLineModuleFuture Object is in state "paused". More... | |
bool | isRunning () const |
Indicates if the currently associated ctkCmdLineModuleFuture object is in state "running". More... | |
QUrl | location () const |
Returns a QUrl to define the location of the module that is run. More... | |
ctkCmdLineModuleReference | moduleReference () const |
Returns a ctkCmdLineModuleReference value object that refers and provides access to the module. More... | |
QList< ctkCmdLineModuleParameter > | parameters (const QString &type=QString(), ParameterFilters filters=All) |
Useful method to return subsets of parameter objects, searhing by type for example "image" and filter for example "input"/"output". More... | |
void | resetValues () |
virtual void | setValues (const QHash< QString, QVariant > &values) |
Enables the parameter values to be set. More... | |
virtual QHash< QString, QVariant > | values () const |
Returns a map of parameter names and values. More... | |
virtual | ~ctkCmdLineModuleFrontend () |
Protected Member Functions | |
QVariant | customValue (const QString ¶meter, const QString &propertyName=QString()) const |
Get the value of the given parameter using the given property name. More... | |
void | setCustomValue (const QString ¶meter, const QVariant &value, const QString &propertyName=QString()) |
Set the value of the given parameter to value using the given property name. More... | |
virtual QUiLoader * | uiLoader () const |
Get the QUiLoader for instantiating widgets. More... | |
virtual ctkCmdLineModuleXslTransform * | xslTransform () const |
Get XSL transform used to transfrom the module XML description to a Qt .ui file. More... | |
![]() | |
ctkCmdLineModuleFrontend (const ctkCmdLineModuleReference &moduleRef) | |
Constructor. More... | |
Additional Inherited Members | |
![]() | |
enum | ParameterFilter { Input = 0x01 , Output = 0x02 , All = Input | Output } |
enum | ParameterValueRole { LocalResourceRole = 0 , DisplayRole = 1 , UserRole = 8 } |
![]() | |
void | started () |
This signal is emitted when the frontend is run. More... | |
void | valueChanged (const QString ¶meter, const QVariant &value) |
This signal is emitted whenever a parameter value is changed by using the ctkCmdLineModuleFrontend class. More... | |
A Qt based implementation of the module front end.
This class is able to generate a Qt widgets based GUI from the XML description of a given module. It uses a customizable XML stylesheet to transform the raw XML description into a .ui file which is fed into a QUiLoader to generate the GUI at runtime.
Sub-classes have several possibilities to customize the generated GUI:
All widget classes are assumed to expose a readable and writable QObject property for storing and retrieving current front-end values via the DisplayRole role.
The following table lists the available XSL parameters (setable via ctkCmdLineModuleXslTransform::bindVariable()), and their default values for all parameter types and created container widgets:
Parameter Type | XSL Parameters | |||
---|---|---|---|---|
Widget Class | Default | Property Name (DisplayRole) | Default | |
boolean | booleanWidget | QCheckBox | booleanValueProperty | checked |
integer | integerWidget | QSpinBox | integerValueProperty | value |
float | floatingWidget | QDoubleSpinBox | floatValueProperty | value |
double | floatingWidget | QDoubleSpinBox | floatValueProperty | value |
string | vectorWidget | QLineEdit | vectorValueProperty | text |
integer-vector | vectorWidget | QLineEdit | vectorValueProperty | text |
float-vector | vectorWidget | QLineEdit | vectorValueProperty | value |
double-vector | vectorWidget | QLineEdit | vectorValueProperty | value |
string-vector | vectorWidget | QLineEdit | vectorValueProperty | value |
integer-enumeration | enumWidget | QComboBox (ctkCmdLineModuleQtUiLoader instantiates a custom private QComboBox sub-class) | enumerationValueProperty | currentEnumeration |
float-enumeration | enumWidget | QComboBox | enumerationValueProperty | currentEnumeration |
double-enumeration | enumWidget | QComboBox | enumerationValueProperty | currentEnumeration |
string-enumeration | enumWidget | QComboBox | enumerationValueProperty | currentEnumeration |
file (input channel) | fileInputWidget | ctkPathLineEdit | fileInputValueProperty | currentPath |
file (output channel) | fileOutputWidget | ctkPathLineEdit | fileOutputValueProperty | currentPath |
geometry (input channel) | fileInputWidget | ctkPathLineEdit | geometryInputValueProperty | currentPath |
geometry (output channel) | fileOutputWidget | ctkPathLineEdit | geometryOutputValueProperty | currentPath |
directory | directoryWidget | ctkPathLineEdit | directoryValueProperty | currentPath |
point | pointWidget | ctkCoordinatesWidget | pointValueProperty | coordinates |
region | pointWidget | ctkCoordinatesWidget | pointValueProperty | coordinates |
image (input channel) | imageInputWidget | ctkPathLineEdit | imageInputValueProperty | currentPath |
image (output channel) | imageOutputWidget | ctkPathLineEdit | imageOutputValueProperty | currentPath |
[main container] | executableWidget | QWidget | n/a | n/a |
[group container] | parametersWidget | ctkCollapsibleGroupBox | n/a | n/a |
[unknown type] | unsupportedWidget | QLabel | n/a | n/a |
In addition, for image and file, input and output, it is normally necessary to define a set property within the generated .ui file to contain various configuration flags to pass to the widget. For example, ctkPathLineEdit has a "filters" property that can be used to configure the dialog behaviour when the browse button is pressed. The following XSL parameters are available to create a set property and are also setable via ctkCmdLineModuleXslTransform::bindVariable(). If the empty string is bound to the Set Property Name, the set property will be omitted.
Parameter Type | XSL Parameters | |||
---|---|---|---|---|
Set Property Name | Default | Set Property Value | Default | |
file (input channel) | fileInputSetProperty | filters | fileInputSetValue | ctkPathLineEdit::Files|ctkPathLineEdit::Readable |
file (output channel) | fileOutputSetProperty | filters | fileOutputSetValue | ctkPathLineEdit::Files|ctkPathLineEdit::Writable |
image (input channel) | imageInputSetProperty | filters | imageInputSetProperty | ctkPathLineEdit::Files|ctkPathLineEdit::Readable |
image (output channel) | imageOutputSetProperty | filters | imageOutputSetProperty | ctkPathLineEdit::Files|ctkPathLineEdit::Writable |
Definition at line 123 of file ctkCmdLineModuleFrontendQtGui.h.
ctkCmdLineModuleFrontendQtGui::ctkCmdLineModuleFrontendQtGui | ( | const ctkCmdLineModuleReference & | moduleRef | ) |
|
virtual |
|
protected |
Get the value of the given parameter using the given property name.
parameter | The parameter name. |
propertyName | The property name from which to get the value. |
If propertyName
is empty, this method returns the value of the property used store the values for the DisplayRole role.
Sub-classes can use this method to retrieve values for custom roles.
|
virtual |
Create the actual Qt GUI.
The returned object is either NULL or can always be casted to QWidget*.
Implements ctkCmdLineModuleFrontend.
|
virtual |
Returns a list of all valid parameter names.
Reimplemented from ctkCmdLineModuleFrontend.
|
protected |
Set the value of the given parameter to value
using the given property name.
parameter | The parameter name. |
value | The new value. |
propertyName | The property name for which to set the value. |
If propertyName
is empty, this method sets the value of the property used store the values for the DisplayRole role.
Sub-classes can use this method to set values for custom roles.
|
virtual |
There is a container QWidget within each group box, so you can set the container widget to enabled/disabled, thereby affecting all child widgets, without overwriting the enabled/disabled status of the child widget.
enabled | if true then enabled else disabled |
|
virtual |
Sets the parameter value.
parameter | |
value | |
role | This implementation does nothing if the role parameter does not equal ctkCmdLineModuleFrontend::DisplayRole. If it does, it sets the value of the default QObject property to the provided value. |
Implements ctkCmdLineModuleFrontend.
|
protectedvirtual |
Get the QUiLoader for instantiating widgets.
Override this method to provide your own QUiLoader sub-class for application-specific customization of certain widgets.
|
virtual |
Retrieves the current parameter value using the default QObject property for parameter values.
parameter | |
role | This implementation ignores the role argument and always returns the value held by the default property, which usually correspongs to the DisplayRole. |
Implements ctkCmdLineModuleFrontend.
|
protectedvirtual |
Get XSL transform used to transfrom the module XML description to a Qt .ui file.
Override this method to either customize the default transformation or completely provide your own.