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 Types | Signals | Public Member Functions | Protected Member Functions | Friends | List of all members
ctkCmdLineModuleFrontend Class Referenceabstract

Abstract base class for all front-end command line module implementations. More...

#include <Libs/CommandLineModules/Core/ctkCmdLineModuleFrontend.h>

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

Public Types

enum  ParameterFilter { Input = 0x01 , Output = 0x02 , All = Input | Output }
 
enum  ParameterValueRole { LocalResourceRole = 0 , DisplayRole = 1 , UserRole = 8 }
 

Signals

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

Public Member Functions

virtual ctkCmdLineModuleFuture future () const
 Return the ctkCmdLineModuleFuture, derived from QFuture to provide asynchronous processing and interaction with the running frontend. More...
 
virtual QObject * guiHandle () const =0
 Returns the GUI representation. 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...
 
virtual QList< QString > parameterNames () const
 Returns a list of all valid parameter names. 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 setValue (const QString &parameter, const QVariant &value, int role=DisplayRole)=0
 Set the value of a certain parameter. More...
 
virtual void setValues (const QHash< QString, QVariant > &values)
 Enables the parameter values to be set. More...
 
virtual QVariant value (const QString &parameter, int role=LocalResourceRole) const =0
 GUIs will need to be able to read parameters, here we retrieve by role. More...
 
virtual QHash< QString, QVariant > values () const
 Returns a map of parameter names and values. More...
 
virtual ~ctkCmdLineModuleFrontend ()
 

Protected Member Functions

 ctkCmdLineModuleFrontend (const ctkCmdLineModuleReference &moduleRef)
 Constructor. More...
 

Friends

struct ctkCmdLineModuleFrontendPrivate
 
class ctkCmdLineModuleManager
 
class ctkCmdLineModulePrivate
 

Detailed Description

Abstract base class for all front-end command line module implementations.

A module front-end represents a set of current parameter values for a specific module. A front-end instance is usually associated with a graphical user interface, accessible via guiHandle(). This allows users to interactively change parameter values of the module.

See also
ctkCmdLineModuleFrontendQtGui
ctkCmdLineModuleFrontendQtWebKit

Definition at line 52 of file ctkCmdLineModuleFrontend.h.

Member Enumeration Documentation

◆ ParameterFilter

Enumerator
Input 

Parameters with channel = "input"

Output 

Parameter with channel = "output"

All 

A convenience enum value combining Input and Output.

Definition at line 93 of file ctkCmdLineModuleFrontend.h.

◆ ParameterValueRole

Enumerator
LocalResourceRole 

Data returned using this role must not be of any type not supported by QVariant by default. For complex parameter types (like file, image, geometry, etc.) the data must be convertible to a QString pointing to a local resource.

This role is usually used by backends for retrieving data and is mainly important for data which acts as a handle to the real data (e.g. a backend usually needs to get the absolute path to a local file for the current value of an input image parameter, instead of the image label displayed in a GUI).

DisplayRole 

Describes data suitable for displaying in a GUI. For many parameter types (e.g. scalar and vector parameters) data returned by this role will be the same as returned by the LocalResourceRole role.

UserRole 

This role can be used in custom frontends to return a QVariant containing for example an in-memory representation of a complex object. One can then either convert the in-memory representation to a local resource before running a module such that arbitrary backends relying on the LocalResourceRole role can process the data. Or one creates a custom backend which knows how to handle QVariants returned by this role.

Definition at line 59 of file ctkCmdLineModuleFrontend.h.

Constructor & Destructor Documentation

◆ ~ctkCmdLineModuleFrontend()

virtual ctkCmdLineModuleFrontend::~ctkCmdLineModuleFrontend ( )
virtual

◆ ctkCmdLineModuleFrontend()

ctkCmdLineModuleFrontend::ctkCmdLineModuleFrontend ( const ctkCmdLineModuleReference moduleRef)
protected

Constructor.

Member Function Documentation

◆ future()

virtual ctkCmdLineModuleFuture ctkCmdLineModuleFrontend::future ( ) const
virtual

Return the ctkCmdLineModuleFuture, derived from QFuture to provide asynchronous processing and interaction with the running frontend.

Note that the future returned by this method will be different after the frontend was started. Either use isRunning() to check wether this frontend is currently running or connect to the started() signal.

See also
ctkCmdLineModuleFuture

◆ guiHandle()

virtual QObject* ctkCmdLineModuleFrontend::guiHandle ( ) const
pure virtual

Returns the GUI representation.

Returns
A GUI handle that can then be embeded in an application window for instance.

The returned object is a handle to the real GUI toolkit specific object representing the user interface. For Qt based front-ends, the returned object is usually a QWidget instance pointing to the main container widget for the GUI. See the documentation of the front-end sub-class for specific information.

Implemented in ctkCmdLineModuleFrontendQtGui.

◆ isPaused()

bool ctkCmdLineModuleFrontend::isPaused ( ) const

Indicates if the currently associated ctkCmdLineModuleFuture Object is in state "paused".

Returns
true if paused and false otherwise.

◆ isRunning()

bool ctkCmdLineModuleFrontend::isRunning ( ) const

Indicates if the currently associated ctkCmdLineModuleFuture object is in state "running".

Returns
true if running and false otherwise.

◆ location()

QUrl ctkCmdLineModuleFrontend::location ( ) const

Returns a QUrl to define the location of the module that is run.

For a local process this may be the file location of the command line module. For other implementations, such as a web-service, this could be a web URL.

Returns
QUrl A resource independent URL defining where the module is.

◆ moduleReference()

ctkCmdLineModuleReference ctkCmdLineModuleFrontend::moduleReference ( ) const

Returns a ctkCmdLineModuleReference value object that refers and provides access to the module.

Returns
ctkCmdLineModuleReference

◆ parameterNames()

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

Returns a list of all valid parameter names.

Reimplemented in ctkCmdLineModuleFrontendQtGui.

◆ parameters()

QList<ctkCmdLineModuleParameter> ctkCmdLineModuleFrontend::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".

Parameters
typeThe type of parameter, as defined in the XML element.
filtersflag to define whether we want input/output.
Returns
QList of ctkCmdLineModuleParameter depending on type and filters.
See also
ParameterFilter

◆ resetValues()

void ctkCmdLineModuleFrontend::resetValues ( )

◆ setValue()

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

Set the value of a certain parameter.

Parameters
parameterThe name of the parameter, as defined in the XML.
valueThe value for that parameter.
roleThe role for which to set the data.
See also
ParameterValueRole

Implemented in ctkCmdLineModuleFrontendQtGui.

◆ setValues()

virtual void ctkCmdLineModuleFrontend::setValues ( const QHash< QString, QVariant > &  values)
virtual

Enables the parameter values to be set.

◆ started

void ctkCmdLineModuleFrontend::started ( )
signal

This signal is emitted when the frontend is run.

You can use this signal to get the ctkCmdLineModuleFuture instance from future() to interact with the running frontend.

◆ value()

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

GUIs will need to be able to read parameters, here we retrieve by role.

Returns
QVariant
See also
ParameterValueRole

Implemented in ctkCmdLineModuleFrontendQtGui.

◆ valueChanged

void ctkCmdLineModuleFrontend::valueChanged ( const QString &  parameter,
const QVariant &  value 
)
signal

This signal is emitted whenever a parameter value is changed by using the ctkCmdLineModuleFrontend class.

Parameters
parameterThe parameter name.
valueThe new parameter value.

Please note that this signal is not emitted if a parameter value is changed in the generated GUI.

◆ values()

virtual QHash<QString,QVariant> ctkCmdLineModuleFrontend::values ( ) const
virtual

Returns a map of parameter names and values.

Friends And Related Function Documentation

◆ ctkCmdLineModuleFrontendPrivate

friend struct ctkCmdLineModuleFrontendPrivate
friend

Definition at line 265 of file ctkCmdLineModuleFrontend.h.

◆ ctkCmdLineModuleManager

friend class ctkCmdLineModuleManager
friend

Definition at line 266 of file ctkCmdLineModuleFrontend.h.

◆ ctkCmdLineModulePrivate

friend class ctkCmdLineModulePrivate
friend

Definition at line 267 of file ctkCmdLineModuleFrontend.h.


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