CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
Public Member Functions | Protected Member Functions | List of all members
ctkCmdLineModuleFrontendQtGui Class Reference

A Qt based implementation of the module front end. More...

#include <Libs/CommandLineModules/Frontend/QtGui/ctkCmdLineModuleFrontendQtGui.h>

Inheritance diagram for ctkCmdLineModuleFrontendQtGui:
Inheritance graph
[legend]
Collaboration diagram for ctkCmdLineModuleFrontendQtGui:
Collaboration graph
[legend]

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 &parameter, const QVariant &value, int role=DisplayRole)
 Sets the parameter value. More...
 
virtual QVariant value (const QString &parameter, int role=LocalResourceRole) const
 Retrieves the current parameter value using the default QObject property for parameter values. More...
 
virtual ~ctkCmdLineModuleFrontendQtGui ()
 
- Public Member Functions inherited from ctkCmdLineModuleFrontend
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< ctkCmdLineModuleParameterparameters (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 &parameter, const QString &propertyName=QString()) const
 Get the value of the given parameter using the given property name. More...
 
void setCustomValue (const QString &parameter, 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 ctkCmdLineModuleXslTransformxslTransform () const
 Get XSL transform used to transfrom the module XML description to a Qt .ui file. More...
 
- Protected Member Functions inherited from ctkCmdLineModuleFrontend
 ctkCmdLineModuleFrontend (const ctkCmdLineModuleReference &moduleRef)
 Constructor. More...
 

Additional Inherited Members

- Public Types inherited from ctkCmdLineModuleFrontend
enum  ParameterFilter { Input = 0x01 , Output = 0x02 , All = Input | Output }
 
enum  ParameterValueRole { LocalResourceRole = 0 , DisplayRole = 1 , UserRole = 8 }
 
- Signals inherited from ctkCmdLineModuleFrontend
void started ()
 This signal is emitted when the frontend is run. More...
 
void valueChanged (const QString &parameter, const QVariant &value)
 This signal is emitted whenever a parameter value is changed by using the ctkCmdLineModuleFrontend class. More...
 

Detailed Description

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 TypeXSL Parameters
Widget ClassDefaultProperty Name (DisplayRole)Default
booleanbooleanWidgetQCheckBoxbooleanValuePropertychecked
integerintegerWidgetQSpinBoxintegerValuePropertyvalue
floatfloatingWidgetQDoubleSpinBoxfloatValuePropertyvalue
doublefloatingWidgetQDoubleSpinBoxfloatValuePropertyvalue
stringvectorWidgetQLineEditvectorValuePropertytext
integer-vectorvectorWidgetQLineEditvectorValuePropertytext
float-vectorvectorWidgetQLineEditvectorValuePropertyvalue
double-vectorvectorWidgetQLineEditvectorValuePropertyvalue
string-vectorvectorWidgetQLineEditvectorValuePropertyvalue
integer-enumerationenumWidgetQComboBox (ctkCmdLineModuleQtUiLoader instantiates a custom private QComboBox sub-class)enumerationValuePropertycurrentEnumeration
float-enumerationenumWidgetQComboBoxenumerationValuePropertycurrentEnumeration
double-enumerationenumWidgetQComboBoxenumerationValuePropertycurrentEnumeration
string-enumerationenumWidgetQComboBoxenumerationValuePropertycurrentEnumeration
file (input channel)fileInputWidgetctkPathLineEditfileInputValuePropertycurrentPath
file (output channel)fileOutputWidgetctkPathLineEditfileOutputValuePropertycurrentPath
geometry (input channel)fileInputWidgetctkPathLineEditgeometryInputValuePropertycurrentPath
geometry (output channel)fileOutputWidgetctkPathLineEditgeometryOutputValuePropertycurrentPath
directorydirectoryWidgetctkPathLineEditdirectoryValuePropertycurrentPath
pointpointWidgetctkCoordinatesWidgetpointValuePropertycoordinates
regionpointWidgetctkCoordinatesWidgetpointValuePropertycoordinates
image (input channel)imageInputWidgetctkPathLineEditimageInputValuePropertycurrentPath
image (output channel)imageOutputWidgetctkPathLineEditimageOutputValuePropertycurrentPath
[main container]executableWidgetQWidgetn/an/a
[group container]parametersWidgetctkCollapsibleGroupBoxn/an/a
[unknown type]unsupportedWidgetQLabeln/an/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 TypeXSL Parameters
Set Property NameDefaultSet Property ValueDefault
file (input channel)fileInputSetPropertyfiltersfileInputSetValuectkPathLineEdit::Files|ctkPathLineEdit::Readable
file (output channel)fileOutputSetPropertyfiltersfileOutputSetValuectkPathLineEdit::Files|ctkPathLineEdit::Writable
image (input channel)imageInputSetPropertyfiltersimageInputSetPropertyctkPathLineEdit::Files|ctkPathLineEdit::Readable
image (output channel)imageOutputSetPropertyfiltersimageOutputSetPropertyctkPathLineEdit::Files|ctkPathLineEdit::Writable

Definition at line 123 of file ctkCmdLineModuleFrontendQtGui.h.

Constructor & Destructor Documentation

◆ ctkCmdLineModuleFrontendQtGui()

ctkCmdLineModuleFrontendQtGui::ctkCmdLineModuleFrontendQtGui ( const ctkCmdLineModuleReference moduleRef)

◆ ~ctkCmdLineModuleFrontendQtGui()

virtual ctkCmdLineModuleFrontendQtGui::~ctkCmdLineModuleFrontendQtGui ( )
virtual

Member Function Documentation

◆ customValue()

QVariant ctkCmdLineModuleFrontendQtGui::customValue ( const QString &  parameter,
const QString &  propertyName = QString() 
) const
protected

Get the value of the given parameter using the given property name.

Parameters
parameterThe parameter name.
propertyNameThe property name from which to get the value.
Returns
The parameter value for the given property name.

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.

◆ guiHandle()

virtual QObject* ctkCmdLineModuleFrontendQtGui::guiHandle ( ) const
virtual

Create the actual Qt GUI.

Returns
The parent widget for the created GUI.

The returned object is either NULL or can always be casted to QWidget*.

Implements ctkCmdLineModuleFrontend.

◆ parameterNames()

virtual QList<QString> ctkCmdLineModuleFrontendQtGui::parameterNames ( ) const
virtual

Returns a list of all valid parameter names.

Reimplemented from ctkCmdLineModuleFrontend.

◆ setCustomValue()

void ctkCmdLineModuleFrontendQtGui::setCustomValue ( const QString &  parameter,
const QVariant &  value,
const QString &  propertyName = QString() 
)
protected

Set the value of the given parameter to value using the given property name.

Parameters
parameterThe parameter name.
valueThe new value.
propertyNameThe 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.

◆ setParameterContainerEnabled()

virtual void ctkCmdLineModuleFrontendQtGui::setParameterContainerEnabled ( const bool &  enabled)
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.

Parameters
enabledif true then enabled else disabled

◆ setValue()

virtual void ctkCmdLineModuleFrontendQtGui::setValue ( const QString &  parameter,
const QVariant &  value,
int  role = DisplayRole 
)
virtual

Sets the parameter value.

Parameters
parameter
value
roleThis 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.
See also
ctkCmdLineModuleFrontend::setValue()

Implements ctkCmdLineModuleFrontend.

◆ uiLoader()

virtual QUiLoader* ctkCmdLineModuleFrontendQtGui::uiLoader ( ) const
protectedvirtual

Get the QUiLoader for instantiating widgets.

Returns
The QUiLoader.

Override this method to provide your own QUiLoader sub-class for application-specific customization of certain widgets.

See also
ctkCmdLineModuleQtUiLoader

◆ value()

virtual QVariant ctkCmdLineModuleFrontendQtGui::value ( const QString &  parameter,
int  role = LocalResourceRole 
) const
virtual

Retrieves the current parameter value using the default QObject property for parameter values.

Parameters
parameter
roleThis implementation ignores the role argument and always returns the value held by the default property, which usually correspongs to the DisplayRole.
See also
ctkCmdLineModuleFrontend::value()

Implements ctkCmdLineModuleFrontend.

◆ xslTransform()

virtual ctkCmdLineModuleXslTransform* ctkCmdLineModuleFrontendQtGui::xslTransform ( ) const
protectedvirtual

Get XSL transform used to transfrom the module XML description to a Qt .ui file.

Returns
The XSL transform.

Override this method to either customize the default transformation or completely provide your own.

See also
ctkCmdLineModuleXslTransform

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