2016-03-20 22:15:50 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2016, Timothy Stack
|
|
|
|
*
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright notice, this
|
|
|
|
* list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
* * Neither the name of Timothy Stack nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY
|
|
|
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
|
|
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
|
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* @file spectroview_curses.hh
|
|
|
|
*/
|
|
|
|
|
2020-08-31 05:13:56 +00:00
|
|
|
#ifndef spectro_source_hh
|
|
|
|
#define spectro_source_hh
|
2016-03-20 22:15:50 +00:00
|
|
|
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
|
|
|
|
2016-03-23 06:19:26 +00:00
|
|
|
#include "ansi_scrubber.hh"
|
2016-03-20 22:15:50 +00:00
|
|
|
#include "textview_curses.hh"
|
|
|
|
|
|
|
|
struct spectrogram_bounds {
|
|
|
|
spectrogram_bounds()
|
|
|
|
: sb_begin_time(0),
|
|
|
|
sb_end_time(0),
|
|
|
|
sb_min_value_out(0.0),
|
|
|
|
sb_max_value_out(0.0),
|
|
|
|
sb_count(0) {
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
time_t sb_begin_time;
|
|
|
|
time_t sb_end_time;
|
|
|
|
double sb_min_value_out;
|
|
|
|
double sb_max_value_out;
|
|
|
|
int64_t sb_count;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct spectrogram_thresholds {
|
|
|
|
int st_green_threshold;
|
|
|
|
int st_yellow_threshold;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct spectrogram_request {
|
|
|
|
spectrogram_request(spectrogram_bounds &sb)
|
|
|
|
: sr_bounds(sb), sr_width(0), sr_column_size(0) {
|
|
|
|
};
|
|
|
|
|
|
|
|
spectrogram_bounds &sr_bounds;
|
|
|
|
unsigned long sr_width;
|
|
|
|
time_t sr_begin_time;
|
|
|
|
time_t sr_end_time;
|
|
|
|
double sr_column_size;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct spectrogram_row {
|
|
|
|
spectrogram_row() : sr_values(NULL), sr_width(0) {
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
~spectrogram_row() {
|
2020-09-03 05:36:26 +00:00
|
|
|
delete[] this->sr_values;
|
2016-03-20 22:15:50 +00:00
|
|
|
}
|
|
|
|
|
2016-03-23 06:19:26 +00:00
|
|
|
struct row_bucket {
|
|
|
|
row_bucket() : rb_counter(0), rb_marks(0) { };
|
|
|
|
|
|
|
|
int rb_counter;
|
|
|
|
int rb_marks;
|
|
|
|
};
|
|
|
|
|
|
|
|
row_bucket *sr_values;
|
2016-03-20 22:15:50 +00:00
|
|
|
unsigned long sr_width;
|
|
|
|
double sr_column_size;
|
|
|
|
|
2016-03-23 06:19:26 +00:00
|
|
|
void add_value(spectrogram_request &sr, double value, bool marked) {
|
2016-03-20 22:15:50 +00:00
|
|
|
long index = lrint((value - sr.sr_bounds.sb_min_value_out) / sr.sr_column_size);
|
|
|
|
|
2016-03-23 06:19:26 +00:00
|
|
|
this->sr_values[index].rb_counter += 1;
|
|
|
|
if (marked) {
|
|
|
|
this->sr_values[index].rb_marks += 1;
|
|
|
|
}
|
2016-03-20 22:15:50 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
class spectrogram_value_source {
|
|
|
|
public:
|
|
|
|
virtual ~spectrogram_value_source() { };
|
|
|
|
|
|
|
|
virtual void spectro_bounds(spectrogram_bounds &sb_out) = 0;
|
|
|
|
|
|
|
|
virtual void spectro_row(spectrogram_request &sr,
|
|
|
|
spectrogram_row &row_out) = 0;
|
2016-03-23 06:19:26 +00:00
|
|
|
|
|
|
|
virtual void spectro_mark(textview_curses &tc,
|
|
|
|
time_t begin_time, time_t end_time,
|
|
|
|
double range_min, double range_max) = 0;
|
2016-03-20 22:15:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class spectrogram_source
|
|
|
|
: public text_sub_source,
|
|
|
|
public text_time_translator,
|
2016-03-23 06:19:26 +00:00
|
|
|
public list_overlay_source,
|
|
|
|
public list_input_delegate {
|
2016-03-20 22:15:50 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
spectrogram_source()
|
|
|
|
: ss_granularity(60),
|
2016-03-23 06:19:26 +00:00
|
|
|
ss_value_source(NULL),
|
|
|
|
ss_cursor_column(-1) {
|
2016-03-20 22:15:50 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
void invalidate() {
|
|
|
|
this->ss_cached_bounds.sb_count = 0;
|
|
|
|
this->ss_row_cache.clear();
|
2016-03-23 06:19:26 +00:00
|
|
|
this->ss_cursor_column = -1;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool list_input_handle_key(listview_curses &lv, int ch) {
|
|
|
|
switch (ch) {
|
|
|
|
case 'm': {
|
|
|
|
if (this->ss_cursor_top < 0 ||
|
2016-05-04 04:01:39 +00:00
|
|
|
(size_t) this->ss_cursor_top >= this->text_line_count() ||
|
2016-03-23 06:19:26 +00:00
|
|
|
this->ss_cursor_column == -1 ||
|
|
|
|
this->ss_value_source == NULL) {
|
|
|
|
alerter::singleton().chime();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned long width;
|
|
|
|
vis_line_t height;
|
|
|
|
|
|
|
|
lv.get_dimensions(height, width);
|
|
|
|
|
|
|
|
spectrogram_bounds &sb = this->ss_cached_bounds;
|
2018-09-29 07:20:45 +00:00
|
|
|
struct timeval begin_time = this->time_for_row(this->ss_cursor_top);
|
|
|
|
struct timeval end_time = begin_time;
|
|
|
|
|
|
|
|
end_time.tv_sec += this->ss_granularity;
|
2016-03-23 06:19:26 +00:00
|
|
|
double range_min, range_max, column_size;
|
|
|
|
|
|
|
|
column_size = (sb.sb_max_value_out - sb.sb_min_value_out) /
|
|
|
|
(double) (width - 1);
|
|
|
|
range_min = sb.sb_min_value_out + this->ss_cursor_column * column_size;
|
|
|
|
range_max = range_min + column_size + column_size * 0.01;
|
|
|
|
this->ss_value_source->spectro_mark((textview_curses &) lv,
|
2018-09-29 07:20:45 +00:00
|
|
|
begin_time.tv_sec, end_time.tv_sec,
|
2016-03-23 06:19:26 +00:00
|
|
|
range_min, range_max);
|
|
|
|
this->invalidate();
|
|
|
|
lv.reload_data();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
case KEY_LEFT:
|
|
|
|
case KEY_RIGHT: {
|
|
|
|
unsigned long width;
|
|
|
|
vis_line_t height;
|
|
|
|
string_attrs_t sa;
|
|
|
|
|
|
|
|
this->ss_cursor_top = lv.get_top();
|
|
|
|
lv.get_dimensions(height, width);
|
|
|
|
|
|
|
|
this->text_attrs_for_line((textview_curses &) lv, this->ss_cursor_top, sa);
|
|
|
|
|
|
|
|
if (sa.empty()) {
|
|
|
|
this->ss_cursor_column = -1;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
string_attrs_t::iterator current;
|
|
|
|
|
|
|
|
struct line_range lr(this->ss_cursor_column, this->ss_cursor_column + 1);
|
|
|
|
|
|
|
|
current = find_string_attr(sa, lr);
|
|
|
|
|
|
|
|
if (current != sa.end()) {
|
|
|
|
if (ch == KEY_LEFT) {
|
|
|
|
if (current == sa.begin()) {
|
|
|
|
current = sa.end();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
--current;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
++current;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (current == sa.end()) {
|
|
|
|
if (ch == KEY_LEFT) {
|
|
|
|
current = sa.end();
|
|
|
|
--current;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
current = sa.begin();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this->ss_cursor_column = current->sa_range.lr_start;
|
|
|
|
|
|
|
|
lv.reload_data();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
2016-03-20 22:15:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
bool list_value_for_overlay(const listview_curses &lv,
|
2018-05-17 14:06:50 +00:00
|
|
|
int y, int bottom,
|
|
|
|
vis_line_t row,
|
2016-03-20 22:15:50 +00:00
|
|
|
attr_line_t &value_out) {
|
|
|
|
if (y != 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string &line = value_out.get_string();
|
|
|
|
char buf[128];
|
|
|
|
vis_line_t height;
|
|
|
|
unsigned long width;
|
|
|
|
|
|
|
|
lv.get_dimensions(height, width);
|
|
|
|
|
|
|
|
this->cache_bounds();
|
|
|
|
|
|
|
|
if (this->ss_cached_line_count == 0) {
|
|
|
|
value_out.with_ansi_string(
|
|
|
|
ANSI_ROLE("error: no log data"),
|
|
|
|
view_colors::VCR_ERROR);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
spectrogram_bounds &sb = this->ss_cached_bounds;
|
|
|
|
spectrogram_thresholds &st = this->ss_cached_thresholds;
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "Min: %'.10lg", sb.sb_min_value_out);
|
|
|
|
line = buf;
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf),
|
|
|
|
ANSI_ROLE(" ") " 1-%'d "
|
|
|
|
ANSI_ROLE(" ") " %'d-%'d "
|
|
|
|
ANSI_ROLE(" ") " %'d+",
|
|
|
|
view_colors::VCR_LOW_THRESHOLD,
|
|
|
|
st.st_green_threshold - 1,
|
|
|
|
view_colors::VCR_MED_THRESHOLD,
|
|
|
|
st.st_green_threshold,
|
|
|
|
st.st_yellow_threshold - 1,
|
|
|
|
view_colors::VCR_HIGH_THRESHOLD,
|
|
|
|
st.st_yellow_threshold);
|
|
|
|
line.append(width / 2 - strlen(buf) / 3 - line.length(), ' ');
|
|
|
|
line.append(buf);
|
|
|
|
scrub_ansi_string(line, value_out.get_attrs());
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "Max: %'.10lg", sb.sb_max_value_out);
|
|
|
|
line.append(width - strlen(buf) - line.length() - 2, ' ');
|
|
|
|
line.append(buf);
|
|
|
|
|
|
|
|
value_out.with_attr(string_attr(
|
|
|
|
line_range(0, -1),
|
|
|
|
&view_curses::VC_STYLE,
|
|
|
|
A_UNDERLINE));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
size_t text_line_count() {
|
|
|
|
if (this->ss_value_source == NULL) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
this->cache_bounds();
|
|
|
|
|
|
|
|
return this->ss_cached_line_count;
|
|
|
|
};
|
|
|
|
|
|
|
|
size_t text_line_width(textview_curses &tc) {
|
2017-03-31 14:01:11 +00:00
|
|
|
if (tc.get_window() == NULL) {
|
|
|
|
return 80;
|
|
|
|
}
|
|
|
|
|
2016-03-20 22:15:50 +00:00
|
|
|
unsigned long width;
|
|
|
|
vis_line_t height;
|
|
|
|
|
|
|
|
tc.get_dimensions(height, width);
|
|
|
|
return width;
|
|
|
|
};
|
|
|
|
|
2018-05-10 13:44:03 +00:00
|
|
|
size_t text_size_for_line(textview_curses &tc, int row, line_flags_t flags) {
|
2016-03-20 22:15:50 +00:00
|
|
|
return 0;
|
|
|
|
};
|
|
|
|
|
2018-09-29 07:20:45 +00:00
|
|
|
struct timeval time_for_row(int row) {
|
|
|
|
struct timeval retval { 0, 0 };
|
2016-03-20 22:15:50 +00:00
|
|
|
|
|
|
|
this->cache_bounds();
|
2018-09-29 07:20:45 +00:00
|
|
|
retval.tv_sec =
|
|
|
|
rounddown(this->ss_cached_bounds.sb_begin_time, this->ss_granularity) +
|
|
|
|
row * this->ss_granularity;
|
2016-03-20 22:15:50 +00:00
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2018-09-29 07:20:45 +00:00
|
|
|
int row_for_time(struct timeval time_bucket) {
|
2016-03-20 22:15:50 +00:00
|
|
|
if (this->ss_value_source == NULL) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
time_t diff;
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
this->cache_bounds();
|
2018-09-29 07:20:45 +00:00
|
|
|
if (time_bucket.tv_sec < this->ss_cached_bounds.sb_begin_time) {
|
2016-03-20 22:15:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-09-29 07:20:45 +00:00
|
|
|
diff = time_bucket.tv_sec - this->ss_cached_bounds.sb_begin_time;
|
2016-03-20 22:15:50 +00:00
|
|
|
retval = diff / this->ss_granularity;
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
void text_value_for_line(textview_curses &tc,
|
|
|
|
int row,
|
|
|
|
std::string &value_out,
|
2018-05-10 13:44:03 +00:00
|
|
|
line_flags_t flags) {
|
2016-03-23 06:19:26 +00:00
|
|
|
spectrogram_row &s_row = this->load_row(tc, row);
|
|
|
|
|
2018-09-29 07:20:45 +00:00
|
|
|
struct timeval row_time;
|
2016-03-20 22:15:50 +00:00
|
|
|
char tm_buffer[128];
|
|
|
|
struct tm tm;
|
|
|
|
|
|
|
|
row_time = this->time_for_row(row);
|
|
|
|
|
2018-09-29 07:20:45 +00:00
|
|
|
gmtime_r(&row_time.tv_sec, &tm);
|
2016-03-20 22:15:50 +00:00
|
|
|
strftime(tm_buffer, sizeof(tm_buffer), " %a %b %d %H:%M:%S", &tm);
|
|
|
|
|
|
|
|
value_out = tm_buffer;
|
2016-03-23 06:19:26 +00:00
|
|
|
value_out.resize(s_row.sr_width, ' ');
|
|
|
|
|
2016-05-04 04:01:39 +00:00
|
|
|
for (size_t lpc = 0; lpc <= s_row.sr_width; lpc++) {
|
2016-03-23 06:19:26 +00:00
|
|
|
if (s_row.sr_values[lpc].rb_marks) {
|
|
|
|
value_out[lpc] = 'x';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this->ss_cursor_top == row && this->ss_cursor_column != -1) {
|
|
|
|
if (value_out[this->ss_cursor_column] == 'x') {
|
|
|
|
value_out[this->ss_cursor_column] = '*';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
value_out[this->ss_cursor_column] = '+';
|
|
|
|
}
|
|
|
|
}
|
2016-03-20 22:15:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void text_attrs_for_line(textview_curses &tc,
|
|
|
|
int row,
|
|
|
|
string_attrs_t &value_out) {
|
|
|
|
if (this->ss_value_source == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
view_colors &vc = view_colors::singleton();
|
|
|
|
spectrogram_thresholds &st = this->ss_cached_thresholds;
|
2016-03-23 06:19:26 +00:00
|
|
|
spectrogram_row &s_row = this->load_row(tc, row);
|
2016-03-20 22:15:50 +00:00
|
|
|
|
2016-05-04 04:01:39 +00:00
|
|
|
for (int lpc = 0; lpc <= (int) s_row.sr_width; lpc++) {
|
2016-03-23 06:19:26 +00:00
|
|
|
int col_value = s_row.sr_values[lpc].rb_counter;
|
2016-03-20 22:15:50 +00:00
|
|
|
|
|
|
|
if (col_value == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
int color;
|
|
|
|
|
|
|
|
if (col_value < st.st_green_threshold) {
|
|
|
|
color = COLOR_GREEN;
|
|
|
|
}
|
|
|
|
else if (col_value < st.st_yellow_threshold) {
|
|
|
|
color = COLOR_YELLOW;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
color = COLOR_RED;
|
|
|
|
}
|
2020-11-13 05:58:40 +00:00
|
|
|
value_out.emplace_back(
|
2016-03-20 22:15:50 +00:00
|
|
|
line_range(lpc, lpc + 1),
|
|
|
|
&view_curses::VC_STYLE,
|
|
|
|
vc.ansi_color_pair(COLOR_BLACK, color)
|
2020-11-13 05:58:40 +00:00
|
|
|
);
|
2016-03-20 22:15:50 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void cache_bounds() {
|
|
|
|
if (this->ss_value_source == NULL) {
|
|
|
|
this->ss_cached_bounds.sb_count = 0;
|
|
|
|
this->ss_cached_bounds.sb_begin_time = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
spectrogram_bounds sb;
|
|
|
|
|
|
|
|
this->ss_value_source->spectro_bounds(sb);
|
|
|
|
|
|
|
|
if (sb.sb_count == this->ss_cached_bounds.sb_count) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this->ss_cached_bounds = sb;
|
|
|
|
|
|
|
|
if (sb.sb_count == 0) {
|
|
|
|
this->ss_cached_line_count = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-31 03:18:28 +00:00
|
|
|
time_t grain_begin_time = rounddown(sb.sb_begin_time, this->ss_granularity);
|
|
|
|
time_t grain_end_time = roundup_size(sb.sb_end_time, this->ss_granularity);
|
|
|
|
|
|
|
|
time_t diff = std::max((time_t) 1, grain_end_time - grain_begin_time);
|
2016-03-20 22:15:50 +00:00
|
|
|
this->ss_cached_line_count =
|
|
|
|
(diff + this->ss_granularity - 1) / this->ss_granularity;
|
|
|
|
|
|
|
|
int64_t samples_per_row = sb.sb_count / this->ss_cached_line_count;
|
|
|
|
spectrogram_thresholds &st = this->ss_cached_thresholds;
|
|
|
|
|
|
|
|
st.st_yellow_threshold = samples_per_row / 2;
|
|
|
|
st.st_green_threshold = st.st_yellow_threshold / 2;
|
|
|
|
|
|
|
|
if (st.st_green_threshold <= 1) {
|
|
|
|
st.st_green_threshold = 2;
|
|
|
|
}
|
|
|
|
if (st.st_yellow_threshold <= st.st_green_threshold) {
|
|
|
|
st.st_yellow_threshold = st.st_green_threshold + 1;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-03-23 06:19:26 +00:00
|
|
|
spectrogram_row &load_row(textview_curses &tc, int row) {
|
|
|
|
this->cache_bounds();
|
|
|
|
|
|
|
|
unsigned long width;
|
|
|
|
vis_line_t height;
|
|
|
|
|
|
|
|
tc.get_dimensions(height, width);
|
|
|
|
width -= 2;
|
|
|
|
|
|
|
|
spectrogram_bounds &sb = this->ss_cached_bounds;
|
|
|
|
spectrogram_request sr(sb);
|
|
|
|
time_t row_time;
|
|
|
|
|
|
|
|
sr.sr_width = width;
|
|
|
|
row_time = rounddown(sb.sb_begin_time, this->ss_granularity) +
|
|
|
|
row * this->ss_granularity;
|
|
|
|
sr.sr_begin_time = row_time;
|
|
|
|
sr.sr_end_time = row_time + this->ss_granularity;
|
|
|
|
|
|
|
|
sr.sr_column_size = (sb.sb_max_value_out - sb.sb_min_value_out) /
|
|
|
|
(double) (width - 1);
|
|
|
|
|
|
|
|
spectrogram_row &s_row = this->ss_row_cache[row_time];
|
|
|
|
|
2020-09-03 05:36:26 +00:00
|
|
|
if (s_row.sr_values == nullptr ||
|
2016-03-23 06:19:26 +00:00
|
|
|
s_row.sr_width != width ||
|
|
|
|
s_row.sr_column_size != sr.sr_column_size) {
|
|
|
|
s_row.sr_width = width;
|
|
|
|
s_row.sr_column_size = sr.sr_column_size;
|
2020-09-03 05:36:26 +00:00
|
|
|
delete[] s_row.sr_values;
|
2016-03-23 06:19:26 +00:00
|
|
|
s_row.sr_values = new spectrogram_row::row_bucket[width + 1];
|
|
|
|
this->ss_value_source->spectro_row(sr, s_row);
|
|
|
|
}
|
|
|
|
|
|
|
|
return s_row;
|
|
|
|
}
|
|
|
|
|
2016-03-20 22:15:50 +00:00
|
|
|
int ss_granularity;
|
|
|
|
spectrogram_value_source *ss_value_source;
|
|
|
|
spectrogram_bounds ss_cached_bounds;
|
|
|
|
spectrogram_thresholds ss_cached_thresholds;
|
|
|
|
size_t ss_cached_line_count;
|
|
|
|
std::map<time_t, spectrogram_row> ss_row_cache;
|
2016-03-23 06:19:26 +00:00
|
|
|
vis_line_t ss_cursor_top;
|
|
|
|
int ss_cursor_column;
|
2016-03-20 22:15:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|