comparison layer/SpectrumLayer.cpp @ 216:34bbbcb3c01f sv1-1.0pre1

* Make getPropertyRangeAndValue return the default separately from the current value. Previously some contexts were incorrectly treating the current value as a default.
author Chris Cannam
date Fri, 02 Mar 2007 14:00:12 +0000
parents 45e995ed84d9
children 8dc50f57d480
comparison
equal deleted inserted replaced
215:d2334a77db73 216:34bbbcb3c01f
129 return SliceLayer::getPropertyGroupName(name); 129 return SliceLayer::getPropertyGroupName(name);
130 } 130 }
131 131
132 int 132 int
133 SpectrumLayer::getPropertyRangeAndValue(const PropertyName &name, 133 SpectrumLayer::getPropertyRangeAndValue(const PropertyName &name,
134 int *min, int *max) const 134 int *min, int *max, int *deflt) const
135 { 135 {
136 int deft = 0; 136 int val = 0;
137 137
138 int garbage0, garbage1; 138 int garbage0, garbage1, garbage2;
139 if (!min) min = &garbage0; 139 if (!min) min = &garbage0;
140 if (!max) max = &garbage1; 140 if (!max) max = &garbage1;
141 if (!deflt) deflt = &garbage2;
141 142
142 if (name == "Window Size") { 143 if (name == "Window Size") {
143 144
144 *min = 0; 145 *min = 0;
145 *max = 10; 146 *max = 10;
147 *deflt = 5;
146 148
147 deft = 0; 149 val = 0;
148 int ws = m_windowSize; 150 int ws = m_windowSize;
149 while (ws > 32) { ws >>= 1; deft ++; } 151 while (ws > 32) { ws >>= 1; val ++; }
150 152
151 } else if (name == "Window Increment") { 153 } else if (name == "Window Increment") {
152 154
153 *min = 0; 155 *min = 0;
154 *max = 5; 156 *max = 5;
157 *deflt = 2;
155 158
156 deft = m_windowHopLevel; 159 val = m_windowHopLevel;
157 160
158 } else { 161 } else {
159 162
160 deft = SliceLayer::getPropertyRangeAndValue(name, min, max); 163 val = SliceLayer::getPropertyRangeAndValue(name, min, max, deflt);
161 } 164 }
162 165
163 return deft; 166 return val;
164 } 167 }
165 168
166 QString 169 QString
167 SpectrumLayer::getPropertyValueLabel(const PropertyName &name, 170 SpectrumLayer::getPropertyValueLabel(const PropertyName &name,
168 int value) const 171 int value) const