MeVisLab Toolbox Reference
mlParameterInfoDoc.h
Go to the documentation of this file.
1// Copyright (c) Fraunhofer MEVIS, Germany. All rights reserved.
2// **InsertLicense** code
3
4#pragma once
5#include "mlParameterInfo.h"
8
9ML_START_NAMESPACE
10
40class MyAlgorithm : public BaseWithParameterInfo {
41
42private:
44 ParameterInfo _getParameterInfo() const override;
45
46 int _exampleInt{ 4711 };
47 double _exampleDouble{ 47.11 };
48 std::string _exampleString{ "Some String" };
49
50 // Complex data types
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 } };
54
55 ML_CLASS_HEADER( BaseWithParameterInfoExample )
56};
57
58ML_END_NAMESPACE
59 \endcode
60
61 In the MeVisLab network, we would want the ParameterInfoInspector module to show for that object:
62
63 \code{.json}
64 {
65 "ExampleInt": 4711,
66 "ExampleDouble": 47.11,
67 "ExampleString": "Some String",
68 "ComplexDatatypes": {
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 ] ]
72 }
73 }
74 \endcode
75
76 We could achieve this with this implementation in the corresponding source file:
77 \code{.cpp}
78// [...]
79
80void MyAlgorithm::_getParameterInfo() const {
81 ParameterInfo pi;
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;
91 return pi;
92}
93
94ML_CLASS_SOURCE( MyAlgorithm, BaseWithParameterInfo )
95
96// [...]
97 \endcode
98 */
99
100
101
102
103ML_END_NAMESPACE