MeVisLab Toolbox Reference
mlParameterInfoUtils.h
Go to the documentation of this file.
1// Copyright (c) Fraunhofer MEVIS, Germany. All rights reserved.
2// **InsertLicense** code
3//------------------------------------------------------------------------------
4
5#pragma once
6
9#include <mlRangeCasts.h>
10#include <FMEThirdPartyWarningsDisable.h>
11#include <QVariant>
12#include <FMEThirdPartyWarningsRestore.h>
13
14
16
17namespace parameter_info_utils {
18
19 template < class ValueType >
21 {
24 {
25 result << vec[ i ];
26 }
27 return result;
28 }
29
30 template < class ValueType, size_t N, class DC >
32 {
34 for (size_t i = 0; i < N; ++i )
35 {
36 result << vec[ i ];
37 }
38 return result;
39 }
40
41 /*
42 * Note that QVariant::fromValue() does not work for all types, so need some specializations.
43 * Just using result << v results in other problems, e.g. there not being an non-ambiguous
44 * auto-conversion to QVariant for int64_t on gcc.
45 */
46 template <class ValueType >
47 void AppendToQVariantList( QVariantList& result, const ValueType& v )
48 {
49 result << QVariant::fromValue( v );
50 }
51
52 inline void AppendToQVariantList( QVariantList& result, const char* v )
53 {
54 result << QString::fromUtf8( v );
55 }
56
57 inline void AppendToQVariantList( QVariantList& result, const std::string& v )
58 {
59 result << QString::fromStdString( v );
60 }
61
62 template < class Iterable >
64 {
66 for ( const auto& v: iterable )
67 {
69 }
70 return result;
71 }
72
74 {
76 result.insert( 0, ToQVariantList( box.v1) );
77 result.insert( 1, ToQVariantList( box.v2) );
78 return result;
79 }
80
81//--------------------------------------------------------------------------
82 inline QVariantList ToQVariant( const ImageVector& vec )
83 {
84 return ToQVariantList( vec );
85 }
86
87 template < class ValueType, size_t N >
92
93 template < class ValueType >
94 QVariantList ToQVariant( const std::vector< ValueType >& vec )
95 {
96 return IterableToQVariantList( vec );
97 }
98
99 inline QVariantList ToQVariant( const SubImageBox& box )
100 {
101 return ToQVariantList( box );
102 }
103
104 inline QVariant ToQVariant( const std::string& x ) { return { QString::fromStdString( x ) }; }
105 inline QVariant ToQVariant( const char* x ) { return { x }; }
106
107 inline QVariant ToQVariant( bool x ) { return { x }; }
108 inline QVariant ToQVariant( MLuint8 x ) { return { x }; }
109 inline QVariant ToQVariant( MLint8 x ) { return { x }; }
110 inline QVariant ToQVariant( MLuint16 x ) { return { x }; }
111 inline QVariant ToQVariant( MLint16 x ) { return { x }; }
112 inline QVariant ToQVariant( MLuint32 x ) { return { x }; }
113 inline QVariant ToQVariant( MLint32 x ) { return { x }; }
114 inline QVariant ToQVariant( MLuint64 x ) { return { x }; }
115 inline QVariant ToQVariant( MLint64 x ) { return { x }; }
116 inline QVariant ToQVariant( MLfloat x ) { return { x }; }
117 inline QVariant ToQVariant( MLdouble x ) { return { x }; }
118
119}
120
@ N
Template class for vector arithmetic with floating point data types.
ImageVector is the 6D TVector specialization used by the ML for all image indexing.
VectorType v1
Corner v1 of the subimage region (included in region).
VectorType v2
Corner v2 of the subimage region (also included in region!).
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
UINT64 MLuint64
Introduce platform independent 64 bit unsigned integer type.
Definition mlTypeDefs.h:425
unsigned int MLuint32
Definition mlTypeDefs.h:185
unsigned char MLuint8
Definition mlTypeDefs.h:109
double MLdouble
Definition mlTypeDefs.h:217
unsigned short MLuint16
Definition mlTypeDefs.h:142
signed short MLint16
Definition mlTypeDefs.h:125
char MLint8
Definition mlTypeDefs.h:97
INT64 MLint64
Include 64 bit integer support for Windows or Unix.
Definition mlTypeDefs.h:412
signed int MLint32
Definition mlTypeDefs.h:161
float MLfloat
Definition mlTypeDefs.h:201
QVariantList ToQVariantList(const TImageVector< ValueType > &vec)
QVariantList FloatVectorToQVariantList(const FloatingPointVector< ValueType, N, DC > &vec)
QVariantList IterableToQVariantList(const Iterable &iterable)
void AppendToQVariantList(QVariantList &result, const ValueType &v)
QVariantList ToQVariant(const ImageVector &vec)