comparison widgets/Pane.cpp @ 120:8dfa20f1c70a

* some work on scaling and zooming for spectrogram
author Chris Cannam
date Wed, 19 Jul 2006 16:55:29 +0000
parents 0f36cdf407a6
children 71992cee2ece
comparison
equal deleted inserted replaced
119:508276c923ba 120:8dfa20f1c70a
602 if (m_shiftPressed) { 602 if (m_shiftPressed) {
603 603
604 int x0 = std::min(m_clickPos.x(), m_mousePos.x()); 604 int x0 = std::min(m_clickPos.x(), m_mousePos.x());
605 int x1 = std::max(m_clickPos.x(), m_mousePos.x()); 605 int x1 = std::max(m_clickPos.x(), m_mousePos.x());
606 int w = x1 - x0; 606 int w = x1 - x0;
607
608 int y0 = std::min(m_clickPos.y(), m_mousePos.y());
609 int y1 = std::max(m_clickPos.y(), m_mousePos.y());
610 // int h = y1 - y0;
607 611
608 long newStartFrame = getFrameForX(x0); 612 long newStartFrame = getFrameForX(x0);
609 613
610 long visibleFrames = getEndFrame() - getStartFrame(); 614 long visibleFrames = getEndFrame() - getStartFrame();
611 if (newStartFrame <= -visibleFrames) { 615 if (newStartFrame <= -visibleFrames) {
623 627
624 // std::cerr << "start: " << m_startFrame << ", level " << m_zoomLevel << std::endl; 628 // std::cerr << "start: " << m_startFrame << ", level " << m_zoomLevel << std::endl;
625 setZoomLevel(getZoomConstraintBlockSize(newZoomLevel)); 629 setZoomLevel(getZoomConstraintBlockSize(newZoomLevel));
626 setStartFrame(newStartFrame); 630 setStartFrame(newStartFrame);
627 631
632 //!!! lots of faff, shouldn't be here
633
634 QString unit;
635 float min, max;
636 bool log;
637 Layer *layer = 0;
638 for (LayerList::const_iterator i = m_layers.begin();
639 i != m_layers.end(); ++i) {
640 if ((*i)->getValueExtents(min, max, log, unit) &&
641 (*i)->getDisplayExtents(min, max)) {
642 layer = *i;
643 break;
644 }
645 }
646
647 if (layer) {
648 if (log) {
649 min = (min < 0.0) ? -log10f(-min) : (min == 0.0) ? 0.0 : log10f(min);
650 max = (max < 0.0) ? -log10f(-max) : (max == 0.0) ? 0.0 : log10f(max);
651 }
652 float rmin = min + ((max - min) * (height() - y1)) / height();
653 float rmax = min + ((max - min) * (height() - y0)) / height();
654 std::cerr << "min: " << min << ", max: " << max << ", y0: " << y0 << ", y1: " << y1 << ", h: " << height() << ", rmin: " << rmin << ", rmax: " << rmax << std::endl;
655 if (log) {
656 rmin = powf(10, rmin);
657 rmax = powf(10, rmax);
658 }
659 std::cerr << "finally: rmin: " << rmin << ", rmax: " << rmax << " " << unit.toStdString() << std::endl;
660
661 layer->setDisplayExtents(rmin, rmax);
662 }
663
628 //cerr << "mouseReleaseEvent: start frame now " << m_startFrame << endl; 664 //cerr << "mouseReleaseEvent: start frame now " << m_startFrame << endl;
629 // update(); 665 // update();
630 } 666 }
631 667
632 } else if (mode == ViewManager::SelectMode) { 668 } else if (mode == ViewManager::SelectMode) {