| 85 | } |
| 86 | |
| 87 | void FluxViewerControl::UpdateScale() |
| 88 | { |
| 89 | auto size = GetSize(); |
| 90 | nanoseconds_t thumbSize = size.GetWidth() * _nanosecondsPerPixel; |
| 91 | _scrollbar->SetScrollbar(_scrollPosition / 1000, |
| 92 | thumbSize / 1000, |
| 93 | _totalDuration / 1000, |
| 94 | thumbSize / 2000); |
| 95 | |
| 96 | int totalPixels = (_totalDuration / _nanosecondsPerPixel) + 1; |
| 97 | if ((totalPixels != _densityMap.size()) && |
| 98 | (_nanosecondsPerPixel > RENDER_LIMIT)) |
| 99 | { |
| 100 | _densityMap.resize(totalPixels); |
| 101 | std::fill(_densityMap.begin(), _densityMap.end(), 0.0); |
| 102 | |
| 103 | int i = 0; |
| 104 | for (const auto& trackdata : _flux->trackDatas) |
| 105 | { |
| 106 | FluxmapReader fmr(*trackdata->fluxmap); |
| 107 | while (!fmr.eof()) |
| 108 | { |
| 109 | unsigned ticks; |
| 110 | if (!fmr.findEvent(F_BIT_PULSE, ticks)) |
| 111 | break; |
| 112 | |
| 113 | int fx = fmr.tell().ns() / _nanosecondsPerPixel; |
| 114 | _densityMap.at(i + fx)++; |
| 115 | } |
| 116 | i += trackdata->fluxmap->duration() / _nanosecondsPerPixel; |
| 117 | } |
| 118 | |
| 119 | double max = *std::max_element(_densityMap.begin(), _densityMap.end()); |
| 120 | for (auto& d : _densityMap) |
| 121 | d /= max; |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | static int interpolate(int lo, int hi, float factor) |
| 126 | { |