Mercurial > hg > svgui
comparison layer/Colour3DPlotLayer.cpp @ 467:76a47146f1f6
* try some qvectors
author | Chris Cannam |
---|---|
date | Thu, 22 Jan 2009 17:58:33 +0000 |
parents | b13dfc443e71 |
children | 762e96217900 |
comparison
equal
deleted
inserted
replaced
466:b13dfc443e71 | 467:76a47146f1f6 |
---|---|
670 } | 670 } |
671 | 671 |
672 paint.restore(); | 672 paint.restore(); |
673 } | 673 } |
674 | 674 |
675 void | 675 DenseThreeDimensionalModel::Column |
676 Colour3DPlotLayer::getColumn(size_t col, | 676 Colour3DPlotLayer::getColumn(size_t col) const |
677 DenseThreeDimensionalModel::Column &values) const | 677 { |
678 { | 678 DenseThreeDimensionalModel::Column values = m_model->getColumn(col); |
679 m_model->getColumn(col, values); | 679 if (!m_normalizeColumns) return values; |
680 | |
681 if (!m_normalizeColumns) return; | |
682 | 680 |
683 float colMax = 0.f, colMin = 0.f; | 681 float colMax = 0.f, colMin = 0.f; |
684 float min = 0.f, max = 0.f; | 682 float min = 0.f, max = 0.f; |
685 | 683 |
686 min = m_model->getMinimumLevel(); | 684 min = m_model->getMinimumLevel(); |
687 max = m_model->getMaximumLevel(); | 685 max = m_model->getMaximumLevel(); |
688 | 686 |
689 for (size_t y = 0; y < values.size(); ++y) { | 687 for (size_t y = 0; y < values.size(); ++y) { |
690 if (y == 0 || values[y] > colMax) colMax = values[y]; | 688 if (y == 0 || values.at(y) > colMax) colMax = values.at(y); |
691 if (y == 0 || values[y] < colMin) colMin = values[y]; | 689 if (y == 0 || values.at(y) < colMin) colMin = values.at(y); |
692 } | 690 } |
693 if (colMin == colMax) colMax = colMin + 1; | 691 if (colMin == colMax) colMax = colMin + 1; |
694 | 692 |
695 for (size_t y = 0; y < values.size(); ++y) { | 693 for (size_t y = 0; y < values.size(); ++y) { |
696 | 694 |
697 float value = values[y]; | 695 float value = values.at(y); |
698 float norm = (value - colMin) / (colMax - colMin); | 696 float norm = (value - colMin) / (colMax - colMin); |
699 value = min + (max - min) * norm; | 697 float newvalue = min + (max - min) * norm; |
700 | 698 |
701 values[y] = value; | 699 if (value != newvalue) values[y] = newvalue; |
702 } | 700 } |
703 } | 701 } |
704 | 702 |
705 void | 703 void |
706 Colour3DPlotLayer::fillCache(size_t firstBin, size_t lastBin) const | 704 Colour3DPlotLayer::fillCache(size_t firstBin, size_t lastBin) const |
771 } | 769 } |
772 | 770 |
773 // std::cerr << "Cache size " << cacheWidth << "x" << cacheHeight << " will be valid from " << m_cacheValidStart << " to " << m_cacheValidEnd << std::endl; | 771 // std::cerr << "Cache size " << cacheWidth << "x" << cacheHeight << " will be valid from " << m_cacheValidStart << " to " << m_cacheValidEnd << std::endl; |
774 | 772 |
775 DenseThreeDimensionalModel::Column values; | 773 DenseThreeDimensionalModel::Column values; |
776 values.reserve(cacheHeight); | |
777 | 774 |
778 float min = m_model->getMinimumLevel(); | 775 float min = m_model->getMinimumLevel(); |
779 float max = m_model->getMaximumLevel(); | 776 float max = m_model->getMaximumLevel(); |
780 | 777 |
781 if (m_colourScale == LogScale) { | 778 if (m_colourScale == LogScale) { |
800 | 797 |
801 if (normalizeVisible) { | 798 if (normalizeVisible) { |
802 | 799 |
803 for (size_t c = fillStart; c <= fillEnd; ++c) { | 800 for (size_t c = fillStart; c <= fillEnd; ++c) { |
804 | 801 |
805 values.clear(); | 802 values = getColumn(c); |
806 getColumn(c, values); | |
807 | 803 |
808 float colMax = 0.f, colMin = 0.f; | 804 float colMax = 0.f, colMin = 0.f; |
809 | 805 |
810 for (size_t y = 0; y < cacheHeight; ++y) { | 806 for (size_t y = 0; y < cacheHeight; ++y) { |
811 if (y >= values.size()) break; | 807 if (y >= values.size()) break; |
826 | 822 |
827 if (visibleMin == visibleMax) visibleMax = visibleMin + 1; | 823 if (visibleMin == visibleMax) visibleMax = visibleMin + 1; |
828 | 824 |
829 for (size_t c = fillStart; c <= fillEnd; ++c) { | 825 for (size_t c = fillStart; c <= fillEnd; ++c) { |
830 | 826 |
831 values.clear(); | 827 values = getColumn(c); |
832 getColumn(c, values); | |
833 | 828 |
834 for (size_t y = 0; y < cacheHeight; ++y) { | 829 for (size_t y = 0; y < cacheHeight; ++y) { |
835 | 830 |
836 float value = min; | 831 float value = min; |
837 if (y < values.size()) { | 832 if (y < values.size()) { |