3 #ifndef SPECTMORPH_PROPERTY_HH 4 #define SPECTMORPH_PROPERTY_HH 18 virtual int min() = 0;
19 virtual int max() = 0;
20 virtual int get() = 0;
21 virtual void set (
int v) = 0;
23 virtual std::string label() = 0;
24 virtual std::string value_label() = 0;
27 template<
class MorphOp>
33 std::function<float(const MorphOp&)> get_value;
34 std::function<void (MorphOp&, float)> set_value;
37 const std::string& label,
38 const std::string& format,
39 std::function<
float(
const MorphOp&)> get_value,
40 std::function<
void (MorphOp&,
float)> set_value) :
44 get_value (get_value),
48 int min() {
return 0; }
49 int max() {
return 1000; }
50 int get() {
return lrint (value2ui (get_value (morph_op)) * 1000); }
51 void set (
int v) { set_value (morph_op, ui2value (v / 1000.)); }
53 virtual double value2ui (
double value) = 0;
54 virtual double ui2value (
double ui) = 0;
56 std::string label() {
return m_label; }
57 std::string value_label() {
return string_locale_printf (m_format.c_str(), get_value (morph_op)); }
60 template<
class MorphOp>
68 const std::string& label,
69 const std::string& format,
73 std::function<
float(
const MorphOp&)> get_value,
74 std::function<
void (MorphOp&,
float)> set_value) :
76 m_min_value (min_value),
77 m_max_value (max_value),
84 return sm_xparam_inv ((v - m_min_value) / (m_max_value - m_min_value), m_slope);
89 return sm_xparam (ui, m_slope) * (m_max_value - m_min_value) + m_min_value;
93 template<
class MorphOp>
100 const std::string& label,
101 const std::string& format,
104 std::function<
float(
const MorphOp&)> get_value,
105 std::function<
void (MorphOp&,
float)> set_value) :
107 m_min_value (min_value),
108 m_max_value (max_value)
114 return (log (v) - log (m_min_value)) / (log (m_max_value) - log (m_min_value));
119 return exp (ui * (log (m_max_value) - log (m_min_value)) + log (m_min_value));
123 template<
class MorphOp>
130 const std::string& label,
131 const std::string& format,
134 std::function<
float(
const MorphOp&)> get_value,
135 std::function<
void (MorphOp&,
float)> set_value) :
137 m_min_value (min_value),
138 m_max_value (max_value)
144 return (v - m_min_value) / (m_max_value - m_min_value);
149 return ui * (m_max_value - m_min_value) + m_min_value;
Definition: smproperty.hh:124
Definition: smproperty.hh:61
Definition: smproperty.hh:15
Definition: smproperty.hh:94
Definition: smproperty.hh:28
Definition: smalignedarray.cc:7