2010 Winter Project Week Command Line Module Simple Return Types
From NAMIC
Key Investigators
- GE: Jim Miller
Objective
Extend the Command Line Module infrastructure to allow for simple return types (int, scalar, string).
Update
Since the Winter Project Week, I have been able send simple Return Parameters from a Command Line Module to Slicer. Types supported include integer, float, double, string, boolean, integer-vector, float-vector, double-vector, string-vector, integer-enumeration, float-enumeration, double-enumeration, and string-enumeration.
Specifying a Return Parameter
Return Parameters are specified in the Module Description XML. They have no "flag", no "long flag", and no "index". They have a "channel" of "output".
<float>
<name>afloatreturn</name>
<label>A floating point return value</label>
<channel>output</channel>
<default>7.0</default>
<description>An example of a float return type</description>
</float>
Using a Return Parameter
An extra parameter is passed to the module "--returnparameterfile" that is the filename in which to write Return Parameters. Format of the file is one line per parameter, with the line specified as "name = value", where "name" is the name of the parameter in the XML Module Description file.
std::ofstream rts; rts.open(returnParameterFile.c_str()); rts << "afloatreturn = 34.2" << std::endl; rts.close();
User interface for Return Parameters
Return Parameters appear in the Module GUI side panel like any other parameter. The difference is that they cannot be modified by the user. The values are updated when the module completes.
Modifications
Most of the Command Line Module infrastructure was modified to support Return Parameter: ModuleDescriptionParser, GenerateCPL, CommandLineModule, SlicerApplicationLogic.
Next steps
- Points and regions
- Separate nodes in MRML for primitive types?
