47 #ifndef _MIRA_PROPERTYHINT_H_ 48 #define _MIRA_PROPERTYHINT_H_ 94 PropertyHint(
const std::string& attribute,
const std::string& value) {
96 mAttributes->push_back(std::make_pair(attribute, value));
101 std::swap(mAttributes, other.mAttributes);
134 std::swap(mAttributes, other.mAttributes);
149 if(mAttributes!=NULL) {
151 *copy.mAttributes = *mAttributes;
159 bool has(
const std::string& attribute)
const 161 if(mAttributes!=NULL) {
162 for(
auto it=mAttributes->begin(); it!=mAttributes->end(); ++it)
164 if(it->first==attribute)
175 template <
typename T>
176 T
get(
const std::string& attribute,
const T& defaultValue = T())
const 178 if(mAttributes!=NULL) {
179 for(
auto it=mAttributes->begin(); it!=mAttributes->end(); ++it)
181 if(it->first==attribute)
182 return fromString<T>(it->second);
198 if(otherHint.mAttributes==NULL)
199 return std::move(hint);
201 if(hint.mAttributes==NULL) {
202 std::swap(hint.mAttributes, otherHint.mAttributes);
203 return std::move(hint);
206 assert(hint.mAttributes);
207 assert(otherHint.mAttributes);
210 hint.mAttributes->splice(hint.mAttributes->begin(), *otherHint.mAttributes,
211 otherHint.mAttributes->begin(), otherHint.mAttributes->end());
212 return std::move(hint);
234 namespace PropertyHints {
243 template <
typename T>
253 template <
typename T>
265 template <
typename T>
275 template <
typename T>
277 return minimum<T>(min) | maximum<T>(max);
317 template <
typename T>
319 return type(
"slider") | limits<T>(min,max) | step<T>(s);
328 template <
typename T>
330 return type(
"spin") | limits<T>(min,max) | step<T>(s);
void fromList(const AttributeValueList &list)
Sets the property hints from the specified list of attribute/value pairs.
Definition: PropertyHint.h:116
PropertyHint spin(const T &min, const T &max, const T &s)
Sets the attribute "type" to the value "spinbox" and sets the "minimum", "maximum" and "step" attribu...
Definition: PropertyHint.h:329
PropertyHint maximum(const T &max)
Sets the attribute "maximum" to the specified value.
Definition: PropertyHint.h:254
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
Contains fromString functions for converting strings to data types.
PropertyHint enumeration(const std::string &values)
Sets the attribute "enumeration".
Definition: PropertyHint.h:307
PropertyHint slider(const T &min, const T &max, const T &s)
Sets the attribute "type" to the value "slider" and sets the "minimum", "maximum" and "step" attribut...
Definition: PropertyHint.h:318
PropertyHint & operator=(PropertyHint &&other) noexcept
move assignment operator
Definition: PropertyHint.h:133
Contains toString functions for converting data types to strings.
std::list< std::pair< std::string, std::string > > AttributeValueList
Definition: PropertyHint.h:87
bool has(const std::string &attribute) const
Returns true if the specified attribute exists.
Definition: PropertyHint.h:159
AttributeValueList toList() const
Returns the attributes/value list containing the property hints.
Definition: PropertyHint.h:111
A property hint gives optional instructions to the property editor, i.e.
Definition: PropertyHint.h:83
std::string toString(const T &value, int precision=-1)
Converts any data type to string (the data type must support the stream << operator).
Definition: ToString.h:158
PropertyHint(const std::string &attribute, const std::string &value)
Constructs a single hint from the given attribute value pair.
Definition: PropertyHint.h:94
PropertyHint limits(const T &min, const T &max)
Sets both attributes "minimum" and "maximum" to the specified values.
Definition: PropertyHint.h:276
PropertyHint type(const std::string &t)
Sets the attribute "type" to the specified value.
Definition: PropertyHint.h:296
friend PropertyHint operator|(PropertyHint &&hint, PropertyHint &&otherHint)
Concatenates two hints.
Definition: PropertyHint.h:196
PropertyHint minimum(const T &min)
Sets the attribute "minimum" to the specified value.
Definition: PropertyHint.h:244
PropertyHint(PropertyHint &&other) noexcept
move constructor
Definition: PropertyHint.h:100
PropertyHint step(const T &step)
Sets the attribute "step" to the specified value.
Definition: PropertyHint.h:266
PropertyHint precision(int p)
Sets the attribute "precision".
Definition: PropertyHint.h:286
PropertyHint()
Definition: PropertyHint.h:91
PropertyHint clone() const
Creates an explicit copy as replacement for the copy constructor.
Definition: PropertyHint.h:146
~PropertyHint()
Definition: PropertyHint.h:104