47 #ifndef _MIRA_PROPERTYHINT_H_ 48 #define _MIRA_PROPERTYHINT_H_ 93 PropertyHint(
const std::string& attribute,
const std::string& value) {
95 mAttributes->push_back(std::make_pair(attribute, value));
100 std::swap(mAttributes, other.mAttributes);
133 std::swap(mAttributes, other.mAttributes);
148 if(mAttributes!=NULL) {
150 *copy.mAttributes = *mAttributes;
158 bool has(
const std::string& attribute)
const 160 if(mAttributes!=NULL) {
161 for(
auto it=mAttributes->begin(); it!=mAttributes->end(); ++it)
163 if(it->first==attribute)
174 template <
typename T>
175 T
get(
const std::string& attribute,
const T& defaultValue = T())
const 177 if(mAttributes!=NULL) {
178 for(
auto it=mAttributes->begin(); it!=mAttributes->end(); ++it)
180 if(it->first==attribute)
181 return fromString<T>(it->second);
197 if(otherHint.mAttributes==NULL)
198 return std::move(hint);
200 if(hint.mAttributes==NULL) {
201 std::swap(hint.mAttributes, otherHint.mAttributes);
202 return std::move(hint);
205 assert(hint.mAttributes);
206 assert(otherHint.mAttributes);
209 hint.mAttributes->splice(hint.mAttributes->begin(), *otherHint.mAttributes,
210 otherHint.mAttributes->begin(), otherHint.mAttributes->end());
211 return std::move(hint);
233 namespace PropertyHints {
242 template <
typename T>
252 template <
typename T>
264 template <
typename T>
274 template <
typename T>
276 return minimum<T>(min) | maximum<T>(max);
316 template <
typename T>
318 return type(
"slider") | limits<T>(min,max) | step<T>(s);
327 template <
typename T>
329 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:115
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:328
PropertyHint maximum(const T &max)
Sets the attribute "maximum" to the specified value.
Definition: PropertyHint.h:253
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
PropertyHint enumeration(const std::string &values)
Sets the attribute "enumeration".
Definition: PropertyHint.h:306
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:317
PropertyHint & operator=(PropertyHint &&other) noexcept
move assignment operator
Definition: PropertyHint.h:132
Contains toString and fromString functions for converting data types to strings and the other way rou...
std::list< std::pair< std::string, std::string > > AttributeValueList
Definition: PropertyHint.h:86
bool has(const std::string &attribute) const
Returns true if the specified attribute exists.
Definition: PropertyHint.h:158
AttributeValueList toList() const
Returns the attributes/value list containing the property hints.
Definition: PropertyHint.h:110
A property hint gives optional instructions to the property editor, i.e.
Definition: PropertyHint.h:82
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:256
PropertyHint(const std::string &attribute, const std::string &value)
Constructs a single hint from the given attribute value pair.
Definition: PropertyHint.h:93
PropertyHint limits(const T &min, const T &max)
Sets both attributes "minimum" and "maximum" to the specified values.
Definition: PropertyHint.h:275
PropertyHint type(const std::string &t)
Sets the attribute "type" to the specified value.
Definition: PropertyHint.h:295
friend PropertyHint operator|(PropertyHint &&hint, PropertyHint &&otherHint)
Concatenates two hints.
Definition: PropertyHint.h:195
PropertyHint minimum(const T &min)
Sets the attribute "minimum" to the specified value.
Definition: PropertyHint.h:243
PropertyHint(PropertyHint &&other) noexcept
move constructor
Definition: PropertyHint.h:99
PropertyHint step(const T &step)
Sets the attribute "step" to the specified value.
Definition: PropertyHint.h:265
PropertyHint precision(int p)
Sets the attribute "precision".
Definition: PropertyHint.h:285
PropertyHint()
Definition: PropertyHint.h:90
PropertyHint clone() const
Creates an explicit copy as replacement for the copy constructor.
Definition: PropertyHint.h:145
~PropertyHint()
Definition: PropertyHint.h:103