Mercurial > hg > svgui
comparison layer/SpectrogramLayer.cpp @ 55:128ebfeeebee
* Add Insert Instant function in main window
* Ensure selections and window geometry are saved in session file
* Add wait cursor on session file save
* Various improvements to display of texts in pane (clearer readability)
* Use commands for setting properties on layers and panes
(still need to batch up multiple sets on the same property)
* Fix failure of spectrogram to refresh when initial part became visible
* Some fixes & paint optimisations in View &c
* Make curve mode for time value layers work properly when resolution == 1
* Some vague improvements for time value layer vertical scale
author | Chris Cannam |
---|---|
date | Thu, 16 Mar 2006 18:46:00 +0000 |
parents | 97b0643bd799 |
children | 01ab51f72e84 |
comparison
equal
deleted
inserted
replaced
54:8dae7f6732c1 | 55:128ebfeeebee |
---|---|
172 return QString(); | 172 return QString(); |
173 } | 173 } |
174 | 174 |
175 int | 175 int |
176 SpectrogramLayer::getPropertyRangeAndValue(const PropertyName &name, | 176 SpectrogramLayer::getPropertyRangeAndValue(const PropertyName &name, |
177 int *min, int *max) const | 177 int *min, int *max) const |
178 { | 178 { |
179 int deft = 0; | 179 int deft = 0; |
180 | 180 |
181 int throwaway; | 181 int garbage0, garbage1; |
182 if (!min) min = &throwaway; | 182 if (!min) min = &garbage0; |
183 if (!max) max = &throwaway; | 183 if (!max) max = &garbage1; |
184 | 184 |
185 if (name == tr("Gain")) { | 185 if (name == tr("Gain")) { |
186 | 186 |
187 *min = -50; | 187 *min = -50; |
188 *max = 50; | 188 *max = 50; |
410 if (value == -50) setThreshold(0.0); | 410 if (value == -50) setThreshold(0.0); |
411 else setThreshold(AudioLevel::dB_to_multiplier(value)); | 411 else setThreshold(AudioLevel::dB_to_multiplier(value)); |
412 } else if (name == tr("Colour Rotation")) { | 412 } else if (name == tr("Colour Rotation")) { |
413 setColourRotation(value); | 413 setColourRotation(value); |
414 } else if (name == tr("Colour")) { | 414 } else if (name == tr("Colour")) { |
415 //!!! if (v) v->setLightBackground(value == 2); | |
416 switch (value) { | 415 switch (value) { |
417 default: | 416 default: |
418 case 0: setColourScheme(DefaultColours); break; | 417 case 0: setColourScheme(DefaultColours); break; |
419 case 1: setColourScheme(WhiteOnBlack); break; | 418 case 1: setColourScheme(WhiteOnBlack); break; |
420 case 2: setColourScheme(BlackOnWhite); break; | 419 case 2: setColourScheme(BlackOnWhite); break; |
580 } | 579 } |
581 | 580 |
582 void | 581 void |
583 SpectrogramLayer::setGain(float gain) | 582 SpectrogramLayer::setGain(float gain) |
584 { | 583 { |
584 std::cerr << "SpectrogramLayer::setGain(" << gain << ") (my gain is now " | |
585 << m_gain << ")" << std::endl; | |
586 | |
585 if (m_gain == gain) return; | 587 if (m_gain == gain) return; |
586 | 588 |
587 m_mutex.lock(); | 589 m_mutex.lock(); |
588 m_pixmapCacheInvalid = true; | 590 m_pixmapCacheInvalid = true; |
589 | 591 |
872 if (fillExtent >= m_lastFillExtent) { | 874 if (fillExtent >= m_lastFillExtent) { |
873 if (fillExtent >= m_model->getEndFrame() && m_lastFillExtent > 0) { | 875 if (fillExtent >= m_model->getEndFrame() && m_lastFillExtent > 0) { |
874 #ifdef DEBUG_SPECTROGRAM_REPAINT | 876 #ifdef DEBUG_SPECTROGRAM_REPAINT |
875 std::cerr << "complete!" << std::endl; | 877 std::cerr << "complete!" << std::endl; |
876 #endif | 878 #endif |
879 m_pixmapCacheInvalid = true; | |
877 emit modelChanged(); | 880 emit modelChanged(); |
878 m_pixmapCacheInvalid = true; | |
879 delete m_updateTimer; | 881 delete m_updateTimer; |
880 m_updateTimer = 0; | 882 m_updateTimer = 0; |
881 m_lastFillExtent = 0; | 883 m_lastFillExtent = 0; |
882 } else if (fillExtent > m_lastFillExtent) { | 884 } else if (fillExtent > m_lastFillExtent) { |
883 #ifdef DEBUG_SPECTROGRAM_REPAINT | 885 #ifdef DEBUG_SPECTROGRAM_REPAINT |
884 std::cerr << "SpectrogramLayer: emitting modelChanged(" | 886 std::cerr << "SpectrogramLayer: emitting modelChanged(" |
885 << m_lastFillExtent << "," << fillExtent << ")" << std::endl; | 887 << m_lastFillExtent << "," << fillExtent << ")" << std::endl; |
886 #endif | 888 #endif |
889 m_pixmapCacheInvalid = true; | |
887 emit modelChanged(m_lastFillExtent, fillExtent); | 890 emit modelChanged(m_lastFillExtent, fillExtent); |
888 m_pixmapCacheInvalid = true; | |
889 m_lastFillExtent = fillExtent; | 891 m_lastFillExtent = fillExtent; |
890 } | 892 } |
891 } else { | 893 } else { |
892 // if (v) { | 894 // if (v) { |
893 size_t sf = 0; | 895 size_t sf = 0; |
894 //!!! if (v->getStartFrame() > 0) sf = v->getStartFrame(); | 896 //!!! if (v->getStartFrame() > 0) sf = v->getStartFrame(); |
895 #ifdef DEBUG_SPECTROGRAM_REPAINT | 897 #ifdef DEBUG_SPECTROGRAM_REPAINT |
896 std::cerr << "SpectrogramLayer: going backwards, emitting modelChanged(" | 898 std::cerr << "SpectrogramLayer: going backwards, emitting modelChanged(" |
897 << sf << "," << m_model->getEndFrame() << ")" << std::endl; | 899 << sf << "," << m_model->getEndFrame() << ")" << std::endl; |
898 #endif | 900 #endif |
901 m_pixmapCacheInvalid = true; | |
899 emit modelChanged(sf, m_model->getEndFrame()); | 902 emit modelChanged(sf, m_model->getEndFrame()); |
900 m_pixmapCacheInvalid = true; | |
901 // } | 903 // } |
902 m_lastFillExtent = fillExtent; | 904 m_lastFillExtent = fillExtent; |
903 } | 905 } |
904 } | 906 } |
905 } | 907 } |
1204 } | 1206 } |
1205 | 1207 |
1206 void | 1208 void |
1207 SpectrogramLayer::Cache::resize(size_t width, size_t height) | 1209 SpectrogramLayer::Cache::resize(size_t width, size_t height) |
1208 { | 1210 { |
1209 std::cerr << "SpectrogramLayer::Cache[" << this << "]::resize(" << width << "x" << height << ")" << std::endl; | 1211 std::cerr << "SpectrogramLayer::Cache[" << this << "]::resize(" << width << "x" << height << " = " << width*height << ")" << std::endl; |
1210 | 1212 |
1211 if (m_width == width && m_height == height) return; | 1213 if (m_width == width && m_height == height) return; |
1212 | 1214 |
1213 resize(m_magnitude, width, height); | 1215 resize(m_magnitude, width, height); |
1214 resize(m_phase, width, height); | 1216 resize(m_phase, width, height); |
1696 } | 1698 } |
1697 | 1699 |
1698 void | 1700 void |
1699 SpectrogramLayer::paint(View *v, QPainter &paint, QRect rect) const | 1701 SpectrogramLayer::paint(View *v, QPainter &paint, QRect rect) const |
1700 { | 1702 { |
1703 if (m_colourScheme == BlackOnWhite) { | |
1704 v->setLightBackground(true); | |
1705 } else { | |
1706 v->setLightBackground(false); | |
1707 } | |
1708 | |
1701 // Profiler profiler("SpectrogramLayer::paint", true); | 1709 // Profiler profiler("SpectrogramLayer::paint", true); |
1702 #ifdef DEBUG_SPECTROGRAM_REPAINT | 1710 #ifdef DEBUG_SPECTROGRAM_REPAINT |
1703 std::cerr << "SpectrogramLayer::paint(): m_model is " << m_model << ", zoom level is " << v->getZoomLevel() << ", m_updateTimer " << m_updateTimer << ", pixmap cache invalid " << m_pixmapCacheInvalid << std::endl; | 1711 std::cerr << "SpectrogramLayer::paint(): m_model is " << m_model << ", zoom level is " << v->getZoomLevel() << ", m_updateTimer " << m_updateTimer << ", pixmap cache invalid " << m_pixmapCacheInvalid << std::endl; |
1704 #endif | 1712 #endif |
1705 | 1713 |