MeVisLab Toolbox Reference
ParameterInfo

Overview

Example

Say, we want to disclose the parameterization of a class MyAlgorithm:

The header file of an example object we want to provide the parameter info of:

ML_START_NAMESPACE
class MyAlgorithm : public BaseWithParameterInfo {
private:
ParameterInfo _getParameterInfo() const override;
int _exampleInt{ 4711 };
double _exampleDouble{ 47.11 };
std::string _exampleString{ "Some String" };
// Complex data types
ml::ImageVector _exampleImageVector{ 1, 2, 3, 4, 5, 6 };
ml::Vector3 _exampleFloatVector{ 1.1, 2.2, 3.3 };
ml::SubImageBox _exampleSubImageBox{ { 1, 2, 3, 4, 5, 6 }, { 1, 2, 3, 4, 5, 6 } };
ML_CLASS_HEADER( BaseWithParameterInfoExample )
};
ML_END_NAMESPACE
#define ML_CLASS_HEADER(className)
Tvec3< MLdouble > Vector3
A vector with three components of type double.
Definition mlVector3.h:286
TSubImageBox< MLint > SubImageBox
Defines the standard SubImageBox type used in the ML. Its size varies with the size of the MLint type...
TImageVector< MLint > ImageVector
Defines the standard ImageVector type that is used by the ML for indexing and coordinates.

In the MeVisLab network, we would want the ParameterInfoInspector module to show for that object:

{
"ExampleInt": 4711,
"ExampleDouble": 47.11,
"ExampleString": "Some String",
"ComplexDatatypes": {
"ExampleImageVector": [ 1, 2, 3, 4, 5, 6 ],
"ExampleFloatVector": [ 1.1, 2.2, 3.3 ],
"ExampleSubImageBox": [ [ 1, 2, 3, 4, 5, 6 ], [ 1, 2, 3, 4, 5, 6 ] ]
}
}

We could achieve this with this implementation in the corresponding source file:

// [...]
void MyAlgorithm::_getParameterInfo() const {
ParameterInfo pi;
// Values need to be (convertible to) QVariant. This is how it works:
pi[ "ExampleInt" ] = _exampleInt;
pi[ "ExampleDouble" ] = _exampleDouble;
pi[ "ExampleString" ] = QString::fromStdString( _exampleString );
ParameterInfo complexPi;
complexPi[ "ExampleImageVector" ] = parameter_info_utils::ToQVariantList( _exampleImageVector );
complexPi[ "ExampleFloatVector" ] = parameter_info_utils::FloatVectorToQVariantList( _exampleFloatVector );
complexPi[ "ExampleSubImageBox" ] = parameter_info_utils::ToQVariantList( _exampleSubImageBox );
pi[ "ComplexDatatypes" ] = complexPi;
return pi;
}
ML_CLASS_SOURCE( MyAlgorithm, BaseWithParameterInfo )
// [...]
#define ML_CLASS_SOURCE(className, parentName)
QVariantList ToQVariantList(const TImageVector< ValueType > &vec)
QVariantList FloatVectorToQVariantList(const FloatingPointVector< ValueType, N, DC > &vec)