comparison layer/TimeValueLayer.cpp @ 100:0db5e7492ce8

* Add units repository, and unit property on time-value and note layers.
author Chris Cannam
date Thu, 11 May 2006 15:02:14 +0000
parents 453f7da3534e
children 0f36cdf407a6
comparison
equal deleted inserted replaced
99:453f7da3534e 100:0db5e7492ce8
70 { 70 {
71 PropertyList list; 71 PropertyList list;
72 list.push_back("Colour"); 72 list.push_back("Colour");
73 list.push_back("Plot Type"); 73 list.push_back("Plot Type");
74 list.push_back("Vertical Scale"); 74 list.push_back("Vertical Scale");
75 list.push_back("Scale Units");
75 return list; 76 return list;
76 } 77 }
77 78
78 QString 79 QString
79 TimeValueLayer::getPropertyLabel(const PropertyName &name) const 80 TimeValueLayer::getPropertyLabel(const PropertyName &name) const
80 { 81 {
81 if (name == "Colour") return tr("Colour"); 82 if (name == "Colour") return tr("Colour");
82 if (name == "Plot Type") return tr("Plot Type"); 83 if (name == "Plot Type") return tr("Plot Type");
83 if (name == "Vertical Scale") return tr("Vertical Scale"); 84 if (name == "Vertical Scale") return tr("Vertical Scale");
85 if (name == "Scale Units") return tr("Scale Units");
84 return ""; 86 return "";
85 } 87 }
86 88
87 Layer::PropertyType 89 Layer::PropertyType
88 TimeValueLayer::getPropertyType(const PropertyName &name) const 90 TimeValueLayer::getPropertyType(const PropertyName &name) const
89 { 91 {
90 return ValueProperty; 92 if (name == "Scale Units") return UnitsProperty;
93 else return ValueProperty;
91 } 94 }
92 95
93 int 96 int
94 TimeValueLayer::getPropertyRangeAndValue(const PropertyName &name, 97 TimeValueLayer::getPropertyRangeAndValue(const PropertyName &name,
95 int *min, int *max) const 98 int *min, int *max) const
121 124
122 if (min) *min = 0; 125 if (min) *min = 0;
123 if (max) *max = 3; 126 if (max) *max = 3;
124 127
125 deft = int(m_verticalScale); 128 deft = int(m_verticalScale);
129
130 } else if (name == "Scale Units") {
131
132 if (m_model) {
133 deft = UnitDatabase::getInstance()->getUnitId
134 (m_model->getScaleUnits());
135 }
126 136
127 } else { 137 } else {
128 138
129 deft = Layer::getPropertyRangeAndValue(name, min, max); 139 deft = Layer::getPropertyRangeAndValue(name, min, max);
130 } 140 }
183 } 193 }
184 } else if (name == "Plot Type") { 194 } else if (name == "Plot Type") {
185 setPlotStyle(PlotStyle(value)); 195 setPlotStyle(PlotStyle(value));
186 } else if (name == "Vertical Scale") { 196 } else if (name == "Vertical Scale") {
187 setVerticalScale(VerticalScale(value)); 197 setVerticalScale(VerticalScale(value));
198 } else if (name == "Scale Units") {
199 if (m_model) {
200 m_model->setScaleUnits
201 (UnitDatabase::getInstance()->getUnitById(value));
202 emit modelChanged();
203 }
188 } 204 }
189 } 205 }
190 206
191 void 207 void
192 TimeValueLayer::setBaseColour(QColor colour) 208 TimeValueLayer::setBaseColour(QColor colour)