Mercurial > hg > svgui
comparison layer/TimeValueLayer.cpp @ 664:62330d542e1d
Do not pad edges of scale extent when auto-aligning to another layer
author | Chris Cannam |
---|---|
date | Tue, 16 Jul 2013 13:22:31 +0100 |
parents | c6d705bf1672 |
children | ab9fefdaa103 |
comparison
equal
deleted
inserted
replaced
644:8ce18ec36fae | 664:62330d542e1d |
---|---|
744 { | 744 { |
745 min = 0.0; | 745 min = 0.0; |
746 max = 0.0; | 746 max = 0.0; |
747 log = false; | 747 log = false; |
748 | 748 |
749 bool haveAutoAlignment = false; | |
750 | |
749 if (shouldAutoAlign()) { | 751 if (shouldAutoAlign()) { |
750 | 752 |
751 if (!v->getValueExtents(m_model->getScaleUnits(), min, max, log)) { | 753 if (!v->getValueExtents(m_model->getScaleUnits(), min, max, log)) { |
752 min = m_model->getValueMinimum(); | 754 min = m_model->getValueMinimum(); |
753 max = m_model->getValueMaximum(); | 755 max = m_model->getValueMaximum(); |
754 } else if (log) { | 756 } else { |
755 LogRange::mapRange(min, max); | 757 haveAutoAlignment = true; |
758 if (log) { | |
759 LogRange::mapRange(min, max); | |
760 } | |
756 } | 761 } |
757 | 762 |
758 } else if (m_verticalScale == PlusMinusOneScale) { | 763 } else if (m_verticalScale == PlusMinusOneScale) { |
759 | 764 |
760 min = -1.0; | 765 min = -1.0; |
772 | 777 |
773 #ifdef DEBUG_TIME_VALUE_LAYER | 778 #ifdef DEBUG_TIME_VALUE_LAYER |
774 std::cerr << "TimeValueLayer::getScaleExtents: min = " << min << ", max = " << max << std::endl; | 779 std::cerr << "TimeValueLayer::getScaleExtents: min = " << min << ", max = " << max << std::endl; |
775 #endif | 780 #endif |
776 | 781 |
777 if (max == min) { | 782 if (!haveAutoAlignment) { |
778 max = max + 0.5; | 783 |
779 min = min - 0.5; | 784 if (max == min) { |
780 } else { | 785 max = max + 0.5; |
781 float margin = (max - min) / 10.0; | 786 min = min - 0.5; |
782 max = max + margin; | 787 } else { |
783 min = min - margin; | 788 float margin = (max - min) / 10.0; |
784 } | 789 max = max + margin; |
785 | 790 min = min - margin; |
786 #ifdef DEBUG_TIME_VALUE_LAYER | 791 } |
787 std::cerr << "TimeValueLayer::getScaleExtents: min = " << min << ", max = " << max << " (after adjustment)" << std::endl; | 792 |
788 #endif | 793 #ifdef DEBUG_TIME_VALUE_LAYER |
794 std::cerr << "TimeValueLayer::getScaleExtents: min = " << min << ", max = " << max << " (after adjustment)" << std::endl; | |
795 #endif | |
796 } | |
789 } | 797 } |
790 | 798 |
791 int | 799 int |
792 TimeValueLayer::getYForValue(View *v, float val) const | 800 TimeValueLayer::getYForValue(View *v, float val) const |
793 { | 801 { |