Mercurial > hg > svgui
comparison layer/Colour3DPlotLayer.cpp @ 1043:fccee028a522 3.0-integration
Merge from branch "spectrogram-minor-refactor"
author | Chris Cannam |
---|---|
date | Thu, 04 Feb 2016 11:18:08 +0000 |
parents | 25ec2390fad3 |
children | 40480e4bab6a |
comparison
equal
deleted
inserted
replaced
1042:cd9e76e755bf | 1043:fccee028a522 |
---|---|
23 | 23 |
24 #include <QPainter> | 24 #include <QPainter> |
25 #include <QImage> | 25 #include <QImage> |
26 #include <QRect> | 26 #include <QRect> |
27 #include <QTextStream> | 27 #include <QTextStream> |
28 #include <QSettings> | |
28 | 29 |
29 #include <iostream> | 30 #include <iostream> |
30 | 31 |
31 #include <cassert> | 32 #include <cassert> |
32 | 33 |
58 m_smooth(false), | 59 m_smooth(false), |
59 m_peakResolution(256), | 60 m_peakResolution(256), |
60 m_miny(0), | 61 m_miny(0), |
61 m_maxy(0) | 62 m_maxy(0) |
62 { | 63 { |
63 | 64 QSettings settings; |
65 settings.beginGroup("Preferences"); | |
66 setColourMap(settings.value("colour-3d-plot-colour", ColourMapper::Green).toInt()); | |
67 settings.endGroup(); | |
64 } | 68 } |
65 | 69 |
66 Colour3DPlotLayer::~Colour3DPlotLayer() | 70 Colour3DPlotLayer::~Colour3DPlotLayer() |
67 { | 71 { |
68 delete m_cache; | 72 delete m_cache; |
932 Colour3DPlotLayer::getColumn(int col) const | 936 Colour3DPlotLayer::getColumn(int col) const |
933 { | 937 { |
934 Profiler profiler("Colour3DPlotLayer::getColumn"); | 938 Profiler profiler("Colour3DPlotLayer::getColumn"); |
935 | 939 |
936 DenseThreeDimensionalModel::Column values = m_model->getColumn(col); | 940 DenseThreeDimensionalModel::Column values = m_model->getColumn(col); |
937 while (values.size() < m_model->getHeight()) values.push_back(0.f); | 941 values.resize(m_model->getHeight(), 0.f); |
938 if (!m_normalizeColumns && !m_normalizeHybrid) return values; | 942 if (!m_normalizeColumns && !m_normalizeHybrid) return values; |
939 | 943 |
940 double colMax = 0.f, colMin = 0.f; | 944 double colMax = 0.f, colMin = 0.f; |
941 double min = 0.f, max = 0.f; | 945 double min = 0.f, max = 0.f; |
942 | 946 |
947 int nv = int(values.size()); | |
948 | |
943 min = m_model->getMinimumLevel(); | 949 min = m_model->getMinimumLevel(); |
944 max = m_model->getMaximumLevel(); | 950 max = m_model->getMaximumLevel(); |
945 | 951 |
946 for (int y = 0; y < values.size(); ++y) { | 952 for (int y = 0; y < nv; ++y) { |
947 if (y == 0 || values.at(y) > colMax) colMax = values.at(y); | 953 if (y == 0 || values.at(y) > colMax) colMax = values.at(y); |
948 if (y == 0 || values.at(y) < colMin) colMin = values.at(y); | 954 if (y == 0 || values.at(y) < colMin) colMin = values.at(y); |
949 } | 955 } |
950 if (colMin == colMax) colMax = colMin + 1; | 956 if (colMin == colMax) colMax = colMin + 1; |
951 | 957 |
952 for (int y = 0; y < values.size(); ++y) { | 958 for (int y = 0; y < nv; ++y) { |
953 | 959 |
954 double value = values.at(y); | 960 double value = values.at(y); |
955 double norm = (value - colMin) / (colMax - colMin); | 961 double norm = (value - colMin) / (colMax - colMin); |
956 double newvalue = min + (max - min) * norm; | 962 double newvalue = min + (max - min) * norm; |
957 | 963 |
958 if (value != newvalue) values[y] = float(newvalue); | 964 if (value != newvalue) values[y] = float(newvalue); |
959 } | 965 } |
960 | 966 |
961 if (m_normalizeHybrid && (colMax > 0.0)) { | 967 if (m_normalizeHybrid && (colMax > 0.0)) { |
962 double logmax = log10(colMax); | 968 double logmax = log10(colMax); |
963 for (int y = 0; y < values.size(); ++y) { | 969 for (int y = 0; y < nv; ++y) { |
964 values[y] = float(values[y] * logmax); | 970 values[y] = float(values[y] * logmax); |
965 } | 971 } |
966 } | 972 } |
967 | 973 |
968 return values; | 974 return values; |
1130 values = getColumn(c); | 1136 values = getColumn(c); |
1131 | 1137 |
1132 double colMax = 0.f, colMin = 0.f; | 1138 double colMax = 0.f, colMin = 0.f; |
1133 | 1139 |
1134 for (int y = 0; y < cacheHeight; ++y) { | 1140 for (int y = 0; y < cacheHeight; ++y) { |
1135 if (y >= values.size()) break; | 1141 if (!in_range_for(values, y)) break; |
1136 if (y == 0 || values[y] > colMax) colMax = values[y]; | 1142 if (y == 0 || values[y] > colMax) colMax = values[y]; |
1137 if (y == 0 || values[y] < colMin) colMin = values[y]; | 1143 if (y == 0 || values[y] < colMin) colMin = values[y]; |
1138 } | 1144 } |
1139 | 1145 |
1140 if (c == fillStart || colMax > visibleMax) visibleMax = colMax; | 1146 if (c == fillStart || colMax > visibleMax) visibleMax = colMax; |
1180 } | 1186 } |
1181 | 1187 |
1182 for (int y = 0; y < cacheHeight; ++y) { | 1188 for (int y = 0; y < cacheHeight; ++y) { |
1183 | 1189 |
1184 double value = min; | 1190 double value = min; |
1185 if (y < values.size()) { | 1191 if (in_range_for(values, y)) { |
1186 value = values.at(y); | 1192 value = values.at(y); |
1187 } | 1193 } |
1188 | 1194 |
1189 value = value * m_gain; | 1195 value = value * m_gain; |
1190 | 1196 |