comparison layer/Colour3DPlotLayer.cpp @ 1019:25ec2390fad3 colourschemes

Convert 3d model column type from QVector to std::vector; replace another user of ResizeableBitset
author Chris Cannam
date Fri, 22 Jan 2016 13:39:45 +0000
parents 072f0db59081
children 40480e4bab6a
comparison
equal deleted inserted replaced
1018:072f0db59081 1019:25ec2390fad3
936 Colour3DPlotLayer::getColumn(int col) const 936 Colour3DPlotLayer::getColumn(int col) const
937 { 937 {
938 Profiler profiler("Colour3DPlotLayer::getColumn"); 938 Profiler profiler("Colour3DPlotLayer::getColumn");
939 939
940 DenseThreeDimensionalModel::Column values = m_model->getColumn(col); 940 DenseThreeDimensionalModel::Column values = m_model->getColumn(col);
941 while (values.size() < m_model->getHeight()) values.push_back(0.f); 941 values.resize(m_model->getHeight(), 0.f);
942 if (!m_normalizeColumns && !m_normalizeHybrid) return values; 942 if (!m_normalizeColumns && !m_normalizeHybrid) return values;
943 943
944 double colMax = 0.f, colMin = 0.f; 944 double colMax = 0.f, colMin = 0.f;
945 double min = 0.f, max = 0.f; 945 double min = 0.f, max = 0.f;
946 946
947 int nv = int(values.size());
948
947 min = m_model->getMinimumLevel(); 949 min = m_model->getMinimumLevel();
948 max = m_model->getMaximumLevel(); 950 max = m_model->getMaximumLevel();
949 951
950 for (int y = 0; y < values.size(); ++y) { 952 for (int y = 0; y < nv; ++y) {
951 if (y == 0 || values.at(y) > colMax) colMax = values.at(y); 953 if (y == 0 || values.at(y) > colMax) colMax = values.at(y);
952 if (y == 0 || values.at(y) < colMin) colMin = values.at(y); 954 if (y == 0 || values.at(y) < colMin) colMin = values.at(y);
953 } 955 }
954 if (colMin == colMax) colMax = colMin + 1; 956 if (colMin == colMax) colMax = colMin + 1;
955 957
956 for (int y = 0; y < values.size(); ++y) { 958 for (int y = 0; y < nv; ++y) {
957 959
958 double value = values.at(y); 960 double value = values.at(y);
959 double norm = (value - colMin) / (colMax - colMin); 961 double norm = (value - colMin) / (colMax - colMin);
960 double newvalue = min + (max - min) * norm; 962 double newvalue = min + (max - min) * norm;
961 963
962 if (value != newvalue) values[y] = float(newvalue); 964 if (value != newvalue) values[y] = float(newvalue);
963 } 965 }
964 966
965 if (m_normalizeHybrid && (colMax > 0.0)) { 967 if (m_normalizeHybrid && (colMax > 0.0)) {
966 double logmax = log10(colMax); 968 double logmax = log10(colMax);
967 for (int y = 0; y < values.size(); ++y) { 969 for (int y = 0; y < nv; ++y) {
968 values[y] = float(values[y] * logmax); 970 values[y] = float(values[y] * logmax);
969 } 971 }
970 } 972 }
971 973
972 return values; 974 return values;
1134 values = getColumn(c); 1136 values = getColumn(c);
1135 1137
1136 double colMax = 0.f, colMin = 0.f; 1138 double colMax = 0.f, colMin = 0.f;
1137 1139
1138 for (int y = 0; y < cacheHeight; ++y) { 1140 for (int y = 0; y < cacheHeight; ++y) {
1139 if (y >= values.size()) break; 1141 if (!in_range_for(values, y)) break;
1140 if (y == 0 || values[y] > colMax) colMax = values[y]; 1142 if (y == 0 || values[y] > colMax) colMax = values[y];
1141 if (y == 0 || values[y] < colMin) colMin = values[y]; 1143 if (y == 0 || values[y] < colMin) colMin = values[y];
1142 } 1144 }
1143 1145
1144 if (c == fillStart || colMax > visibleMax) visibleMax = colMax; 1146 if (c == fillStart || colMax > visibleMax) visibleMax = colMax;
1184 } 1186 }
1185 1187
1186 for (int y = 0; y < cacheHeight; ++y) { 1188 for (int y = 0; y < cacheHeight; ++y) {
1187 1189
1188 double value = min; 1190 double value = min;
1189 if (y < values.size()) { 1191 if (in_range_for(values, y)) {
1190 value = values.at(y); 1192 value = values.at(y);
1191 } 1193 }
1192 1194
1193 value = value * m_gain; 1195 value = value * m_gain;
1194 1196