comparison layer/SpectrumLayer.cpp @ 1362:d79e21855aef

Add mechanism for saving/loading colour maps by name/id rather than by numerical index, for future compatibility when adding to or changing the supported colour maps. Add two new colour maps (and one old one). Write out backward-compatible numerical indices for use when reloading in older versions. Also add a mechanism to invert the colour map, though I don't think it turns out useful enough to include in the UI.
author Chris Cannam
date Thu, 18 Oct 2018 13:21:56 +0100
parents fc9d9f1103fa
children 2df1af7ac752
comparison
equal deleted inserted replaced
1361:2e3b3fadba27 1362:d79e21855aef
416 if (fn.pointSize() > 8) { 416 if (fn.pointSize() > 8) {
417 fn.setPointSize(fn.pointSize() - 1); 417 fn.setPointSize(fn.pointSize() - 1);
418 paint.setFont(fn); 418 paint.setFont(fn);
419 } 419 }
420 420
421 ColourMapper mapper(m_colourMap, 0, 1); 421 ColourMapper mapper(m_colourMap, m_colourInverted, 0, 1);
422 paint.setPen(mapper.getContrastingColour()); 422 paint.setPen(mapper.getContrastingColour());
423 423
424 int xorigin = m_xorigins[v->getId()]; 424 int xorigin = m_xorigins[v->getId()];
425 paint.drawLine(xorigin, cursorPos.y(), v->getPaintWidth(), cursorPos.y()); 425 paint.drawLine(xorigin, cursorPos.y(), v->getPaintWidth(), cursorPos.y());
426 paint.drawLine(cursorPos.x(), cursorPos.y(), cursorPos.x(), v->getPaintHeight()); 426 paint.drawLine(cursorPos.x(), cursorPos.y(), cursorPos.x(), v->getPaintHeight());
616 paint.save(); 616 paint.save();
617 paint.setRenderHint(QPainter::Antialiasing, false); 617 paint.setRenderHint(QPainter::Antialiasing, false);
618 618
619 ColourMapper mapper = 619 ColourMapper mapper =
620 hasLightBackground() ? 620 hasLightBackground() ?
621 ColourMapper(ColourMapper::BlackOnWhite, 0, 1) : 621 ColourMapper(ColourMapper::BlackOnWhite, m_colourInverted, 0, 1) :
622 ColourMapper(ColourMapper::WhiteOnBlack, 0, 1); 622 ColourMapper(ColourMapper::WhiteOnBlack, m_colourInverted, 0, 1);
623 623
624 int peakminbin = 0; 624 int peakminbin = 0;
625 int peakmaxbin = fft->getHeight() - 1; 625 int peakmaxbin = fft->getHeight() - 1;
626 double peakmaxfreq = Pitch::getFrequencyForPitch(128); 626 double peakmaxfreq = Pitch::getFrequencyForPitch(128);
627 peakmaxbin = int(((peakmaxfreq * fft->getHeight() * 2) / fft->getSampleRate())); 627 peakmaxbin = int(((peakmaxfreq * fft->getHeight() * 2) / fft->getSampleRate()));