comparison layer/Colour3DPlotLayer.cpp @ 509:f8b98f63f200

* Add Absolute plot scale, in colour 3d plot layer only for the moment
author Chris Cannam
date Wed, 25 Feb 2009 17:41:34 +0000
parents 2613bc1b2823
children 4ba0476ebbb6
comparison
equal deleted inserted replaced
508:1d605a89fd9b 509:f8b98f63f200
210 if (!deflt) deflt = &garbage2; 210 if (!deflt) deflt = &garbage2;
211 211
212 if (name == "Colour Scale") { 212 if (name == "Colour Scale") {
213 213
214 *min = 0; 214 *min = 0;
215 *max = 2; 215 *max = 3;
216 *deflt = (int)LinearScale; 216 *deflt = (int)LinearScale;
217 217
218 val = (int)m_colourScale; 218 val = (int)m_colourScale;
219 219
220 } else if (name == "Colour") { 220 } else if (name == "Colour") {
263 switch (value) { 263 switch (value) {
264 default: 264 default:
265 case 0: return tr("Linear"); 265 case 0: return tr("Linear");
266 case 1: return tr("Log"); 266 case 1: return tr("Log");
267 case 2: return tr("+/-1"); 267 case 2: return tr("+/-1");
268 case 3: return tr("Absolute");
268 } 269 }
269 } 270 }
270 return tr("<unknown>"); 271 return tr("<unknown>");
271 } 272 }
272 273
277 switch (value) { 278 switch (value) {
278 default: 279 default:
279 case 0: setColourScale(LinearScale); break; 280 case 0: setColourScale(LinearScale); break;
280 case 1: setColourScale(LogScale); break; 281 case 1: setColourScale(LogScale); break;
281 case 2: setColourScale(PlusMinusOneScale); break; 282 case 2: setColourScale(PlusMinusOneScale); break;
283 case 3: setColourScale(AbsoluteScale); break;
282 } 284 }
283 } else if (name == "Colour") { 285 } else if (name == "Colour") {
284 setColourMap(value); 286 setColourMap(value);
285 } else if (name == "Normalize Columns") { 287 } else if (name == "Normalize Columns") {
286 setNormalizeColumns(value ? true : false); 288 setNormalizeColumns(value ? true : false);
602 if (m_colourScale == LogScale) { 604 if (m_colourScale == LogScale) {
603 LogRange::mapRange(mmin, mmax); 605 LogRange::mapRange(mmin, mmax);
604 } else if (m_colourScale == PlusMinusOneScale) { 606 } else if (m_colourScale == PlusMinusOneScale) {
605 mmin = -1.f; 607 mmin = -1.f;
606 mmax = 1.f; 608 mmax = 1.f;
609 } else if (m_colourScale == AbsoluteScale) {
610 if (mmin < 0) {
611 if (fabsf(mmin) > fabsf(mmax)) mmax = fabsf(mmin);
612 else mmax = fabsf(mmax);
613 mmin = 0;
614 } else {
615 mmin = fabsf(mmin);
616 mmax = fabsf(mmax);
617 }
607 } 618 }
608 619
609 if (max == min) max = min + 1.0; 620 if (max == min) max = min + 1.0;
610 if (mmax == mmin) mmax = mmin + 1.0; 621 if (mmax == mmin) mmax = mmin + 1.0;
611 622
842 if (m_colourScale == LogScale) { 853 if (m_colourScale == LogScale) {
843 LogRange::mapRange(min, max); 854 LogRange::mapRange(min, max);
844 } else if (m_colourScale == PlusMinusOneScale) { 855 } else if (m_colourScale == PlusMinusOneScale) {
845 min = -1.f; 856 min = -1.f;
846 max = 1.f; 857 max = 1.f;
858 } else if (m_colourScale == AbsoluteScale) {
859 if (min < 0) {
860 if (fabsf(min) > fabsf(max)) max = fabsf(min);
861 else max = fabsf(max);
862 min = 0;
863 } else {
864 min = fabsf(min);
865 max = fabsf(max);
866 }
847 } 867 }
848 868
849 if (max == min) max = min + 1.0; 869 if (max == min) max = min + 1.0;
850 870
851 ColourMapper mapper(m_colourMap, 0.f, 255.f); 871 ColourMapper mapper(m_colourMap, 0.f, 255.f);
884 904
885 if (m_colourScale == LogScale) { 905 if (m_colourScale == LogScale) {
886 visibleMin = LogRange::map(visibleMin); 906 visibleMin = LogRange::map(visibleMin);
887 visibleMax = LogRange::map(visibleMax); 907 visibleMax = LogRange::map(visibleMax);
888 if (visibleMin > visibleMax) std::swap(visibleMin, visibleMax); 908 if (visibleMin > visibleMax) std::swap(visibleMin, visibleMax);
909 } else if (m_colourScale == AbsoluteScale) {
910 if (visibleMin < 0) {
911 if (fabsf(visibleMin) > fabsf(visibleMax)) visibleMax = fabsf(visibleMin);
912 else visibleMax = fabsf(visibleMax);
913 visibleMin = 0;
914 } else {
915 visibleMin = fabsf(visibleMin);
916 visibleMax = fabsf(visibleMax);
917 }
889 } 918 }
890 } 919 }
891 920
892 if (visibleMin == visibleMax) visibleMax = visibleMin + 1; 921 if (visibleMin == visibleMax) visibleMax = visibleMin + 1;
893 922
910 value = values.at(y); 939 value = values.at(y);
911 } 940 }
912 941
913 if (m_colourScale == LogScale) { 942 if (m_colourScale == LogScale) {
914 value = LogRange::map(value); 943 value = LogRange::map(value);
944 } else if (m_colourScale == AbsoluteScale) {
945 value = fabsf(value);
915 } 946 }
916 947
917 if (normalizeVisible) { 948 if (normalizeVisible) {
918 float norm = (value - visibleMin) / (visibleMax - visibleMin); 949 float norm = (value - visibleMin) / (visibleMax - visibleMin);
919 value = min + (max - min) * norm; 950 value = min + (max - min) * norm;
1063 if (sx >= 0 && sx < m_cache->width() && 1094 if (sx >= 0 && sx < m_cache->width() &&
1064 sy >= 0 && sy < m_cache->height()) { 1095 sy >= 0 && sy < m_cache->height()) {
1065 pixel = m_cache->pixel(sx, sy); 1096 pixel = m_cache->pixel(sx, sy);
1066 } 1097 }
1067 1098
1068 QRect r(rx0, ry0 - h / (symax - symin) - 1, 1099 QRect r(rx0, ry0 - h / (symax - symin),
1069 rw, h / (symax - symin) + 1); 1100 rw, h / (symax - symin) + 1);
1070 1101
1071 if (rw == 1) { 1102 if (rw == 1) {
1072 paint.setPen(pixel); 1103 paint.setPen(pixel);
1073 paint.setBrush(Qt::NoBrush); 1104 paint.setBrush(Qt::NoBrush);