40class MyAlgorithm : public BaseWithParameterInfo {
44 ParameterInfo _getParameterInfo() const override;
46 int _exampleInt{ 4711 };
47 double _exampleDouble{ 47.11 };
48 std::string _exampleString{ "Some String" };
51 ml::ImageVector _exampleImageVector{ 1, 2, 3, 4, 5, 6 };
52 ml::Vector3 _exampleFloatVector{ 1.1, 2.2, 3.3 };
53 ml::SubImageBox _exampleSubImageBox{ { 1, 2, 3, 4, 5, 6 }, { 1, 2, 3, 4, 5, 6 } };
55 ML_CLASS_HEADER( BaseWithParameterInfoExample )
61 In the MeVisLab network, we would want the ParameterInfoInspector module to show for that object:
66 "ExampleDouble": 47.11,
67 "ExampleString": "Some String",
69 "ExampleImageVector": [ 1, 2, 3, 4, 5, 6 ],
70 "ExampleFloatVector": [ 1.1, 2.2, 3.3 ],
71 "ExampleSubImageBox": [ [ 1, 2, 3, 4, 5, 6 ], [ 1, 2, 3, 4, 5, 6 ] ]
76 We could achieve this with this implementation in the corresponding source file:
80void MyAlgorithm::_getParameterInfo() const {
82 // Values need to be (convertible to) QVariant. This is how it works:
83 pi[ "ExampleInt" ] = _exampleInt;
84 pi[ "ExampleDouble" ] = _exampleDouble;
85 pi[ "ExampleString" ] = QString::fromStdString( _exampleString );
86 ParameterInfo complexPi;
87 complexPi[ "ExampleImageVector" ] = parameter_info_utils::ToQVariantList( _exampleImageVector );
88 complexPi[ "ExampleFloatVector" ] = parameter_info_utils::FloatVectorToQVariantList( _exampleFloatVector );
89 complexPi[ "ExampleSubImageBox" ] = parameter_info_utils::ToQVariantList( _exampleSubImageBox );
90 pi[ "ComplexDatatypes" ] = complexPi;
94ML_CLASS_SOURCE( MyAlgorithm, BaseWithParameterInfo )