comparison layer/WaveformLayer.cpp @ 918:4fe7a09be0fe osx-retina

Many fixes for the previous stuff
author Chris Cannam
date Tue, 17 Mar 2015 16:56:03 +0000
parents 94e4952a6774
children 2adca8f05583
comparison
equal deleted inserted replaced
917:77a1d42353ce 918:4fe7a09be0fe
324 m_cacheValid = false; 324 m_cacheValid = false;
325 emit layerParametersChanged(); 325 emit layerParametersChanged();
326 } 326 }
327 327
328 int 328 int
329 WaveformLayer::getCompletion(View *) const 329 WaveformLayer::getCompletion(LayerGeometryProvider *) const
330 { 330 {
331 int completion = 100; 331 int completion = 100;
332 if (!m_model || !m_model->isOK()) return completion; 332 if (!m_model || !m_model->isOK()) return completion;
333 if (m_model->isReady(&completion)) return 100; 333 if (m_model->isReady(&completion)) return 100;
334 return completion; 334 return completion;
397 397
398 return channels; 398 return channels;
399 } 399 }
400 400
401 bool 401 bool
402 WaveformLayer::isLayerScrollable(const View *) const 402 WaveformLayer::isLayerScrollable(const LayerGeometryProvider *) const
403 { 403 {
404 return !m_autoNormalize; 404 return !m_autoNormalize;
405 } 405 }
406 406
407 static float meterdbs[] = { -40, -30, -20, -15, -10, 407 static float meterdbs[] = { -40, -30, -20, -15, -10,
408 -5, -3, -2, -1, -0.5, 0 }; 408 -5, -3, -2, -1, -0.5, 0 };
409 409
410 bool 410 bool
411 WaveformLayer::getSourceFramesForX(View *v, int x, int modelZoomLevel, 411 WaveformLayer::getSourceFramesForX(LayerGeometryProvider *v, int x, int modelZoomLevel,
412 sv_frame_t &f0, sv_frame_t &f1) const 412 sv_frame_t &f0, sv_frame_t &f1) const
413 { 413 {
414 sv_frame_t viewFrame = v->getFrameForX(x); 414 sv_frame_t viewFrame = v->getFrameForX(x);
415 if (viewFrame < 0) { 415 if (viewFrame < 0) {
416 f0 = 0; 416 f0 = 0;
431 431
432 return (f0 < m_model->getEndFrame()); 432 return (f0 < m_model->getEndFrame());
433 } 433 }
434 434
435 float 435 float
436 WaveformLayer::getNormalizeGain(View *v, int channel) const 436 WaveformLayer::getNormalizeGain(LayerGeometryProvider *v, int channel) const
437 { 437 {
438 sv_frame_t startFrame = v->getStartFrame(); 438 sv_frame_t startFrame = v->getStartFrame();
439 sv_frame_t endFrame = v->getEndFrame(); 439 sv_frame_t endFrame = v->getEndFrame();
440 440
441 sv_frame_t modelStart = m_model->getStartFrame(); 441 sv_frame_t modelStart = m_model->getStartFrame();
951 if (otherChannelRanges != ranges) delete otherChannelRanges; 951 if (otherChannelRanges != ranges) delete otherChannelRanges;
952 delete ranges; 952 delete ranges;
953 } 953 }
954 954
955 QString 955 QString
956 WaveformLayer::getFeatureDescription(View *v, QPoint &pos) const 956 WaveformLayer::getFeatureDescription(LayerGeometryProvider *v, QPoint &pos) const
957 { 957 {
958 int x = pos.x(); 958 int x = pos.x();
959 959
960 if (!m_model || !m_model->isOK()) return ""; 960 if (!m_model || !m_model->isOK()) return "";
961 961
1034 1034
1035 return text; 1035 return text;
1036 } 1036 }
1037 1037
1038 int 1038 int
1039 WaveformLayer::getYForValue(const View *v, double value, int channel) const 1039 WaveformLayer::getYForValue(const LayerGeometryProvider *v, double value, int channel) const
1040 { 1040 {
1041 int channels = 0, minChannel = 0, maxChannel = 0; 1041 int channels = 0, minChannel = 0, maxChannel = 0;
1042 bool mergingChannels = false, mixingChannels = false; 1042 bool mergingChannels = false, mixingChannels = false;
1043 1043
1044 channels = getChannelArrangement(minChannel, maxChannel, 1044 channels = getChannelArrangement(minChannel, maxChannel,
1045 mergingChannels, mixingChannels); 1045 mergingChannels, mixingChannels);
1046 if (channels == 0) return 0; 1046 if (channels == 0) return 0;
1047 if (maxChannel < minChannel || channel < minChannel) return 0; 1047 if (maxChannel < minChannel || channel < minChannel) return 0;
1048 1048
1049 int h = v->height(); 1049 int h = v->getPaintHeight();
1050 int m = (h / channels) / 2; 1050 int m = (h / channels) / 2;
1051 1051
1052 if ((m_scale == dBScale || m_scale == MeterScale) && 1052 if ((m_scale == dBScale || m_scale == MeterScale) &&
1053 m_channelMode != MergeChannels) { 1053 m_channelMode != MergeChannels) {
1054 m = (h / channels); 1054 m = (h / channels);
1077 1077
1078 return my - vy; 1078 return my - vy;
1079 } 1079 }
1080 1080
1081 double 1081 double
1082 WaveformLayer::getValueForY(const View *v, int y, int &channel) const 1082 WaveformLayer::getValueForY(const LayerGeometryProvider *v, int y, int &channel) const
1083 { 1083 {
1084 int channels = 0, minChannel = 0, maxChannel = 0; 1084 int channels = 0, minChannel = 0, maxChannel = 0;
1085 bool mergingChannels = false, mixingChannels = false; 1085 bool mergingChannels = false, mixingChannels = false;
1086 1086
1087 channels = getChannelArrangement(minChannel, maxChannel, 1087 channels = getChannelArrangement(minChannel, maxChannel,
1088 mergingChannels, mixingChannels); 1088 mergingChannels, mixingChannels);
1089 if (channels == 0) return 0; 1089 if (channels == 0) return 0;
1090 if (maxChannel < minChannel) return 0; 1090 if (maxChannel < minChannel) return 0;
1091 1091
1092 int h = v->height(); 1092 int h = v->getPaintHeight();
1093 int m = (h / channels) / 2; 1093 int m = (h / channels) / 2;
1094 1094
1095 if ((m_scale == dBScale || m_scale == MeterScale) && 1095 if ((m_scale == dBScale || m_scale == MeterScale) &&
1096 m_channelMode != MergeChannels) { 1096 m_channelMode != MergeChannels) {
1097 m = (h / channels); 1097 m = (h / channels);
1123 1123
1124 return value / m_gain; 1124 return value / m_gain;
1125 } 1125 }
1126 1126
1127 bool 1127 bool
1128 WaveformLayer::getYScaleValue(const View *v, int y, 1128 WaveformLayer::getYScaleValue(const LayerGeometryProvider *v, int y,
1129 double &value, QString &unit) const 1129 double &value, QString &unit) const
1130 { 1130 {
1131 int channel; 1131 int channel;
1132 1132
1133 value = getValueForY(v, y, channel); 1133 value = getValueForY(v, y, channel);
1149 1149
1150 return true; 1150 return true;
1151 } 1151 }
1152 1152
1153 bool 1153 bool
1154 WaveformLayer::getYScaleDifference(const View *v, int y0, int y1, 1154 WaveformLayer::getYScaleDifference(const LayerGeometryProvider *v, int y0, int y1,
1155 double &diff, QString &unit) const 1155 double &diff, QString &unit) const
1156 { 1156 {
1157 int c0, c1; 1157 int c0, c1;
1158 double v0 = getValueForY(v, y0, c0); 1158 double v0 = getValueForY(v, y0, c0);
1159 double v1 = getValueForY(v, y1, c1); 1159 double v1 = getValueForY(v, y1, c1);
1187 1187
1188 return true; 1188 return true;
1189 } 1189 }
1190 1190
1191 int 1191 int
1192 WaveformLayer::getVerticalScaleWidth(View *, bool, QPainter &paint) const 1192 WaveformLayer::getVerticalScaleWidth(LayerGeometryProvider *, bool, QPainter &paint) const
1193 { 1193 {
1194 if (m_scale == LinearScale) { 1194 if (m_scale == LinearScale) {
1195 return paint.fontMetrics().width("0.0") + 13; 1195 return paint.fontMetrics().width("0.0") + 13;
1196 } else { 1196 } else {
1197 return std::max(paint.fontMetrics().width(tr("0dB")), 1197 return std::max(paint.fontMetrics().width(tr("0dB")),
1198 paint.fontMetrics().width(tr("-Inf"))) + 13; 1198 paint.fontMetrics().width(tr("-Inf"))) + 13;
1199 } 1199 }
1200 } 1200 }
1201 1201
1202 void 1202 void
1203 WaveformLayer::paintVerticalScale(View *v, bool, QPainter &paint, QRect rect) const 1203 WaveformLayer::paintVerticalScale(LayerGeometryProvider *v, bool, QPainter &paint, QRect rect) const
1204 { 1204 {
1205 if (!m_model || !m_model->isOK()) { 1205 if (!m_model || !m_model->isOK()) {
1206 return; 1206 return;
1207 } 1207 }
1208 1208