comparison layer/TimeValueLayer.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 6969f21da18a
children 28c8e8e3c537
comparison
equal deleted inserted replaced
215:d2334a77db73 216:34bbbcb3c01f
107 return QString(); 107 return QString();
108 } 108 }
109 109
110 int 110 int
111 TimeValueLayer::getPropertyRangeAndValue(const PropertyName &name, 111 TimeValueLayer::getPropertyRangeAndValue(const PropertyName &name,
112 int *min, int *max) const 112 int *min, int *max, int *deflt) const
113 { 113 {
114 //!!! factor this colour handling stuff out into a colour manager class 114 //!!! factor this colour handling stuff out into a colour manager class
115 115
116 int deft = 0; 116 int val = 0;
117 117
118 if (name == "Colour") { 118 if (name == "Colour") {
119 119
120 if (m_plotStyle == PlotSegmentation) { 120 if (m_plotStyle == PlotSegmentation) {
121 121
122 if (min) *min = 0; 122 if (min) *min = 0;
123 if (max) *max = ColourMapper::getColourMapCount() - 1; 123 if (max) *max = ColourMapper::getColourMapCount() - 1;
124 124 if (deflt) *deflt = 0;
125 deft = m_colourMap; 125
126 val = m_colourMap;
126 127
127 } else { 128 } else {
128 129
129 if (min) *min = 0; 130 if (min) *min = 0;
130 if (max) *max = 5; 131 if (max) *max = 5;
131 132 if (deflt) *deflt = 0;
132 if (m_colour == Qt::black) deft = 0; 133
133 else if (m_colour == Qt::darkRed) deft = 1; 134 if (m_colour == Qt::black) val = 0;
134 else if (m_colour == Qt::darkBlue) deft = 2; 135 else if (m_colour == Qt::darkRed) val = 1;
135 else if (m_colour == Qt::darkGreen) deft = 3; 136 else if (m_colour == Qt::darkBlue) val = 2;
136 else if (m_colour == QColor(200, 50, 255)) deft = 4; 137 else if (m_colour == Qt::darkGreen) val = 3;
137 else if (m_colour == QColor(255, 150, 50)) deft = 5; 138 else if (m_colour == QColor(200, 50, 255)) val = 4;
139 else if (m_colour == QColor(255, 150, 50)) val = 5;
138 } 140 }
139 141
140 } else if (name == "Plot Type") { 142 } else if (name == "Plot Type") {
141 143
142 if (min) *min = 0; 144 if (min) *min = 0;
143 if (max) *max = 5; 145 if (max) *max = 5;
146 if (deflt) *deflt = int(PlotConnectedPoints);
144 147
145 deft = int(m_plotStyle); 148 val = int(m_plotStyle);
146 149
147 } else if (name == "Vertical Scale") { 150 } else if (name == "Vertical Scale") {
148 151
149 if (min) *min = 0; 152 if (min) *min = 0;
150 if (max) *max = 3; 153 if (max) *max = 3;
154 if (deflt) *deflt = int(AutoAlignScale);
151 155
152 deft = int(m_verticalScale); 156 val = int(m_verticalScale);
153 157
154 } else if (name == "Scale Units") { 158 } else if (name == "Scale Units") {
155 159
160 if (deflt) *deflt = 0;
156 if (m_model) { 161 if (m_model) {
157 deft = UnitDatabase::getInstance()->getUnitId 162 val = UnitDatabase::getInstance()->getUnitId
158 (m_model->getScaleUnits()); 163 (m_model->getScaleUnits());
159 } 164 }
160 165
161 } else { 166 } else {
162 167
163 deft = Layer::getPropertyRangeAndValue(name, min, max); 168 val = Layer::getPropertyRangeAndValue(name, min, max, deflt);
164 } 169 }
165 170
166 return deft; 171 return val;
167 } 172 }
168 173
169 QString 174 QString
170 TimeValueLayer::getPropertyValueLabel(const PropertyName &name, 175 TimeValueLayer::getPropertyValueLabel(const PropertyName &name,
171 int value) const 176 int value) const