3 * Copyright (C) 1997-2011 Adam Williams <broadcast at earthling dot net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "bcsignals.h"
26 #include "scopewindow.h"
34 ScopePackage::ScopePackage()
44 ScopeUnit::ScopeUnit(ScopeGUI *gui,
55 void ScopeUnit::draw_point(unsigned char **rows,
62 unsigned char *pixel = rows[y] + x * 4;
68 #define PROCESS_PIXEL(column) \
70 /* Calculate histogram */ \
73 int v_i = (intensity - FLOAT_MIN) * (TOTAL_BINS / (FLOAT_MAX - FLOAT_MIN)); \
74 CLAMP(v_i, 0, TOTAL_BINS - 1); \
80 int r_i = (r - FLOAT_MIN) * (TOTAL_BINS / (FLOAT_MAX - FLOAT_MIN)); \
81 int g_i = (g - FLOAT_MIN) * (TOTAL_BINS / (FLOAT_MAX - FLOAT_MIN)); \
82 int b_i = (b - FLOAT_MIN) * (TOTAL_BINS / (FLOAT_MAX - FLOAT_MIN)); \
83 CLAMP(r_i, 0, TOTAL_BINS - 1); \
84 CLAMP(g_i, 0, TOTAL_BINS - 1); \
85 CLAMP(b_i, 0, TOTAL_BINS - 1); \
91 /* Calculate waveform */ \
92 if(use_wave || use_wave_parade) \
94 x = (column) * wave_w / w; \
95 if(x >= 0 && x < wave_w) \
100 (int)((r - FLOAT_MIN) / \
101 (FLOAT_MAX - FLOAT_MIN) * \
104 if(y >= 0 && y < wave_h) \
105 draw_point(waveform_rows, x / 3, y, 0xff, 0x0, 0x0); \
108 (int)((g - FLOAT_MIN) / \
109 (FLOAT_MAX - FLOAT_MIN) * \
112 if(y >= 0 && y < wave_h) \
113 draw_point(waveform_rows, x / 3 + wave_w / 3, y, 0x0, 0xff, 0x0); \
116 (int)((b - FLOAT_MIN) / \
117 (FLOAT_MAX - FLOAT_MIN) * \
120 if(y >= 0 && y < wave_h) \
121 draw_point(waveform_rows, x / 3 + wave_w / 3 * 2, y, 0x0, 0x0, 0xff); \
127 (int)((intensity - FLOAT_MIN) / \
128 (FLOAT_MAX - FLOAT_MIN) * \
131 if(y >= 0 && y < wave_h) \
132 draw_point(waveform_rows, \
142 /* Calculate vectorscope */ \
145 float adjacent = cos((h + 90) / 360 * 2 * M_PI); \
146 float opposite = sin((h + 90) / 360 * 2 * M_PI); \
148 x = (int)(vector_w / 2 + \
149 adjacent * (s) / (FLOAT_MAX) * radius); \
151 y = (int)(vector_h / 2 - \
152 opposite * (s) / (FLOAT_MAX) * radius); \
155 CLAMP(x, 0, vector_w - 1); \
156 CLAMP(y, 0, vector_h - 1); \
158 /* Get color with full saturation & value */ \
159 float r_f, g_f, b_f; \
160 HSV::hsv_to_rgb(r_f, \
167 draw_point(vector_rows, \
170 (int)(CLIP(r_f, 0, 1) * 255), \
171 (int)(CLIP(g_f, 0, 1) * 255), \
172 (int)(CLIP(b_f, 0, 1) * 255)); \
176 #define PROCESS_RGB_PIXEL(column, max) \
178 r = (float)*row++ / max; \
179 g = (float)*row++ / max; \
180 b = (float)*row++ / max; \
188 PROCESS_PIXEL(column) \
191 #define PROCESS_YUV_PIXEL(column, \
196 YUV::yuv.yuv_to_rgb_f(r, g, b, (float)y_in / 255, (float)(u_in - 0x80) / 255, (float)(v_in - 0x80) / 255); \
204 PROCESS_PIXEL(column) \
208 void ScopeUnit::process_package(LoadPackage *package)
210 ScopePackage *pkg = (ScopePackage*)package;
216 int use_hist = gui->use_hist;
217 int use_hist_parade = gui->use_hist_parade;
218 int use_vector = gui->use_vector;
219 int use_wave = gui->use_wave;
220 int use_wave_parade = gui->use_wave_parade;
221 BC_Bitmap *waveform_bitmap = gui->waveform_bitmap;
222 BC_Bitmap *vector_bitmap = gui->vector_bitmap;
223 int wave_h = waveform_bitmap->get_h();
224 int wave_w = waveform_bitmap->get_w();
225 int vector_h = vector_bitmap->get_h();
226 int vector_w = vector_bitmap->get_w();
228 int w = gui->output_frame->get_w();
229 float radius = MIN(gui->vector_w / 2, gui->vector_h / 2);
234 unsigned char **waveform_rows = waveform_bitmap->get_row_pointers();
235 unsigned char **vector_rows = vector_bitmap->get_row_pointers();
238 switch(gui->output_frame->get_color_model())
241 for(int i = pkg->row1; i < pkg->row2; i++)
243 unsigned char *row = gui->output_frame->get_rows()[i];
244 for(int j = 0; j < w; j++)
246 PROCESS_RGB_PIXEL(j, 255)
252 for(int i = pkg->row1; i < pkg->row2; i++)
254 unsigned char *row = gui->output_frame->get_rows()[i];
255 for(int j = 0; j < w; j++)
257 PROCESS_RGB_PIXEL(j, 255)
264 for(int i = pkg->row1; i < pkg->row2; i++)
266 float *row = (float*)gui->output_frame->get_rows()[i];
267 for(int j = 0; j < w; j++)
269 PROCESS_RGB_PIXEL(j, 1.0)
275 for(int i = pkg->row1; i < pkg->row2; i++)
277 float *row = (float*)gui->output_frame->get_rows()[i];
278 for(int j = 0; j < w; j++)
280 PROCESS_RGB_PIXEL(j, 1.0)
287 for(int i = pkg->row1; i < pkg->row2; i++)
289 unsigned char *row = gui->output_frame->get_rows()[i];
290 for(int j = 0; j < w; j++)
292 PROCESS_YUV_PIXEL(j, row[0], row[1], row[2])
299 for(int i = pkg->row1; i < pkg->row2; i++)
301 unsigned char *row = gui->output_frame->get_rows()[i];
302 for(int j = 0; j < w; j++)
304 PROCESS_YUV_PIXEL(j, row[0], row[1], row[2])
312 for(int i = pkg->row1; i < pkg->row2; i++)
314 unsigned char *y_row = gui->output_frame->get_y() + i * gui->output_frame->get_w();
315 unsigned char *u_row = gui->output_frame->get_u() + (i / 2) * (gui->output_frame->get_w() / 2);
316 unsigned char *v_row = gui->output_frame->get_v() + (i / 2) * (gui->output_frame->get_w() / 2);
317 for(int j = 0; j < w; j += 2)
319 PROCESS_YUV_PIXEL(j, *y_row, *u_row, *v_row);
321 PROCESS_YUV_PIXEL(j + 1, *y_row, *u_row, *v_row);
331 for(int i = pkg->row1; i < pkg->row2; i++)
333 unsigned char *row = gui->output_frame->get_rows()[i];
334 for(int j = 0; j < gui->output_frame->get_w(); j += 2)
336 PROCESS_YUV_PIXEL(j, row[0], row[1], row[3]);
337 PROCESS_YUV_PIXEL(j + 1, row[2], row[1], row[3]);
344 printf("ScopeUnit::process_package %d: color_model=%d unrecognized\n",
346 gui->output_frame->get_color_model());
357 ScopeEngine::ScopeEngine(ScopeGUI *gui, int cpus)
358 : LoadServer(cpus, cpus)
360 //printf("ScopeEngine::ScopeEngine %d cpus=%d\n", __LINE__, cpus);
364 ScopeEngine::~ScopeEngine()
368 void ScopeEngine::init_packages()
370 for(int i = 0; i < LoadServer::get_total_packages(); i++)
372 ScopePackage *pkg = (ScopePackage*)get_package(i);
373 pkg->row1 = gui->output_frame->get_h() * i / LoadServer::get_total_packages();
374 pkg->row2 = gui->output_frame->get_h() * (i + 1) / LoadServer::get_total_packages();
377 for(int i = 0; i < get_total_clients(); i++)
379 ScopeUnit *unit = (ScopeUnit*)get_client(i);
380 for(int j = 0; j < HIST_SECTIONS; j++)
381 bzero(unit->bins[j], sizeof(int) * TOTAL_BINS);
386 LoadClient* ScopeEngine::new_client()
388 return new ScopeUnit(gui, this);
391 LoadPackage* ScopeEngine::new_package()
393 return new ScopePackage;
396 void ScopeEngine::process()
400 for(int i = 0; i < HIST_SECTIONS; i++)
401 bzero(gui->bins[i], sizeof(int) * TOTAL_BINS);
403 for(int i = 0; i < get_total_clients(); i++)
405 ScopeUnit *unit = (ScopeUnit*)get_client(i);
406 for(int j = 0; j < HIST_SECTIONS; j++)
408 for(int k = 0; k < TOTAL_BINS; k++)
410 gui->bins[j][k] += unit->bins[j][k];
418 ScopeGUI::ScopeGUI(Theme *theme,
424 : PluginClientWindow(_(PROGRAM_NAME ": Scopes"),
442 ScopeGUI::ScopeGUI(PluginClient *plugin,
445 : PluginClientWindow(plugin,
456 this->theme = plugin->get_theme();
457 this->cpus = plugin->PluginClient::smp + 1;
461 ScopeGUI::~ScopeGUI()
463 delete waveform_bitmap;
464 delete vector_bitmap;
468 void ScopeGUI::reset()
482 wave_w = wave_h = vector_w = vector_h = 0;
486 void ScopeGUI::create_objects()
488 if(use_hist && use_hist_parade)
493 if(use_wave && use_wave_parade)
498 if(!engine) engine = new ScopeEngine(this,
501 lock_window("ScopeGUI::create_objects");
504 int x = theme->widget_border;
505 int y = theme->widget_border;
508 add_subwindow(hist_on = new ScopeToggle(this,
512 x += hist_on->get_w() + theme->widget_border;
514 add_subwindow(hist_parade_on = new ScopeToggle(this,
518 x += hist_parade_on->get_w() + theme->widget_border;
520 add_subwindow(waveform_on = new ScopeToggle(this,
524 x += waveform_on->get_w() + theme->widget_border;
525 add_subwindow(waveform_parade_on = new ScopeToggle(this,
529 x += waveform_parade_on->get_w() + theme->widget_border;
531 add_subwindow(vector_on = new ScopeToggle(this,
535 x += vector_on->get_w() + theme->widget_border;
537 add_subwindow(value_text = new BC_Title(x, y, ""));
538 x += value_text->get_w() + theme->widget_border;
540 y += vector_on->get_h() + theme->widget_border;
561 void ScopeGUI::create_panels()
563 calculate_sizes(get_w(), get_h());
566 if((use_wave || use_wave_parade))
570 add_subwindow(waveform = new ScopeWaveform(this,
575 waveform->create_objects();
579 waveform->reposition_window(wave_x,
583 waveform->clear_box(0, 0, wave_w, wave_h);
587 if(!(use_wave || use_wave_parade) && waveform)
597 add_subwindow(vectorscope = new ScopeVectorscope(this,
602 vectorscope->create_objects();
606 vectorscope->reposition_window(vector_x,
610 vectorscope->clear_box(0, 0, vector_w, vector_h);
614 if(!use_vector && vectorscope)
620 if((use_hist || use_hist_parade))
624 // printf("ScopeGUI::create_panels %d %d %d %d %d\n", __LINE__, hist_x,
628 add_subwindow(histogram = new ScopeHistogram(this,
633 histogram->create_objects();
637 histogram->reposition_window(hist_x,
641 histogram->clear_box(0, 0, hist_w, hist_h);
645 if(!(use_hist || use_hist_parade))
655 draw_overlays(1, 1, 0);
658 void ScopeGUI::clear_points(int flash)
660 if(histogram) histogram->clear_point();
661 if(waveform) waveform->clear_point();
662 if(vectorscope) vectorscope->clear_point();
663 if(histogram && flash) histogram->flash(0);
664 if(waveform && flash) waveform->flash(0);
665 if(vectorscope && flash) vectorscope->flash(0);
668 void ScopeGUI::toggle_event()
673 void ScopeGUI::calculate_sizes(int w, int h)
675 int margin = theme->widget_border;
676 int text_w = get_text_width(SMALLFONT, "000") + margin * 2;
677 int total_panels = ((use_hist || use_hist_parade) ? 1 : 0) +
678 ((use_wave || use_wave_parade) ? 1 : 0) +
679 (use_vector ? 1 : 0);
682 int panel_w = (w - margin) / (total_panels > 0 ? total_panels : 1);
683 // Vectorscope determines the size of everything else
688 vector_x = w - panel_w + text_w;
689 vector_w = w - margin - vector_x;
690 vector_y = vector_on->get_h() + margin * 2;
691 vector_h = h - vector_y - margin;
693 if(vector_w > vector_h)
696 vector_x = w - theme->widget_border - vector_w;
701 panel_w = (vector_x - text_w - margin) / total_panels;
704 // Histogram is always 1st panel
705 if(use_hist || use_hist_parade)
708 hist_y = vector_on->get_h() + margin * 2;
709 hist_w = panel_w - margin;
710 hist_h = h - hist_y - margin;
716 if(use_wave || use_wave_parade)
719 wave_y = vector_on->get_h() + margin * 2;
720 wave_w = panel_w - margin - text_w;
721 wave_h = h - wave_y - margin;
727 void ScopeGUI::allocate_bitmaps()
729 if(waveform_bitmap) delete waveform_bitmap;
730 if(vector_bitmap) delete vector_bitmap;
734 // printf("ScopeGUI::allocate_bitmaps %d %d %d %d %d\n",
742 waveform_bitmap = new_bitmap(w, h);
743 w = MAX(vector_w, 16);
744 h = MAX(vector_h, 16);
745 vector_bitmap = new_bitmap(w, h);
749 int ScopeGUI::resize_event(int w, int h)
751 clear_box(0, 0, w, h);
754 calculate_sizes(w, h);
758 waveform->reposition_window(wave_x, wave_y, wave_w, wave_h);
759 waveform->clear_box(0, 0, wave_w, wave_h);
764 histogram->reposition_window(hist_x, hist_y, hist_w, hist_h);
765 histogram->clear_box(0, 0, hist_w, hist_h);
770 vectorscope->reposition_window(vector_x, vector_y, vector_w, vector_h);
771 vectorscope->clear_box(0, 0, vector_w, vector_h);
778 draw_overlays(1, 1, 1);
783 int ScopeGUI::translation_event()
788 PluginClientWindow::translation_event();
793 void ScopeGUI::draw_overlays(int overlays, int borders, int flush)
795 BC_Resources *resources = BC_WindowBase::get_resources();
796 int text_color = GREEN;
797 if(resources->bg_color == 0xffffff)
802 if(overlays && borders)
804 clear_box(0, 0, get_w(), get_h());
810 set_color(text_color);
813 if(histogram && (use_hist || use_hist_parade))
815 histogram->draw_line(hist_w * -FLOAT_MIN / (FLOAT_MAX - FLOAT_MIN),
817 hist_w * -FLOAT_MIN / (FLOAT_MAX - FLOAT_MIN),
819 histogram->draw_line(hist_w * (1.0 - FLOAT_MIN) / (FLOAT_MAX - FLOAT_MIN),
821 hist_w * (1.0 - FLOAT_MIN) / (FLOAT_MAX - FLOAT_MIN),
824 histogram->draw_point();
830 if(waveform && (use_wave || use_wave_parade))
832 set_color(text_color);
833 for(int i = 0; i <= WAVEFORM_DIVISIONS; i++)
835 int y = wave_h * i / WAVEFORM_DIVISIONS;
836 int text_y = y + wave_y + get_text_ascent(SMALLFONT) / 2;
837 CLAMP(text_y, waveform->get_y() + get_text_ascent(SMALLFONT), waveform->get_y() + waveform->get_h() - 1);
838 char string[BCTEXTLEN];
839 sprintf(string, "%d",
841 i * (FLOAT_MAX - FLOAT_MIN) / WAVEFORM_DIVISIONS) * 100));
842 int text_x = wave_x - get_text_width(SMALLFONT, string) - theme->widget_border;
843 draw_text(text_x, text_y, string);
845 int y1 = CLAMP(y, 0, waveform->get_h() - 1);
846 waveform->draw_line(0, y1, wave_w, y1);
847 //waveform->draw_rectangle(0, 0, wave_w, wave_h);
850 waveform->draw_point();
856 // Vectorscope overlay
857 if(vectorscope && use_vector)
859 set_color(text_color);
860 int radius = MIN(vector_w / 2, vector_h / 2);
861 for(int i = 1; i <= VECTORSCOPE_DIVISIONS; i += 2)
863 int x = vector_w / 2 - radius * i / VECTORSCOPE_DIVISIONS;
864 int y = vector_h / 2 - radius * i / VECTORSCOPE_DIVISIONS;
865 int text_y = y + vector_y + get_text_ascent(SMALLFONT) / 2;
866 int w = radius * i / VECTORSCOPE_DIVISIONS * 2;
867 int h = radius * i / VECTORSCOPE_DIVISIONS * 2;
868 char string[BCTEXTLEN];
870 sprintf(string, "%d",
871 (int)((FLOAT_MAX / VECTORSCOPE_DIVISIONS * i) * 100));
872 int text_x = vector_x - get_text_width(SMALLFONT, string) - theme->widget_border;
873 draw_text(text_x, text_y, string);
874 //printf("ScopeGUI::draw_overlays %d %d %d %s\n", __LINE__, text_x, text_y, string);
876 vectorscope->draw_circle(x, y, w, h);
877 //vectorscope->draw_rectangle(0, 0, vector_w, vector_h);
879 // vectorscope->draw_circle(vector_w / 2 - radius,
880 // vector_h / 2 - radius,
885 vectorscope->draw_point();
887 vectorscope->flash(0);
890 set_font(MEDIUMFONT);
896 if(use_hist || use_hist_parade)
898 draw_3d_border(hist_x - 2,
908 if(use_wave || use_wave_parade)
910 draw_3d_border(wave_x - 2,
922 draw_3d_border(vector_x - 2,
934 if(flush) this->flush();
939 void ScopeGUI::process(VFrame *output_frame)
941 lock_window("ScopeGUI::process");
942 this->output_frame = output_frame;
943 frame_w = output_frame->get_w();
944 //float radius = MIN(vector_w / 2, vector_h / 2);
946 bzero(waveform_bitmap->get_data(), waveform_bitmap->get_data_size());
947 bzero(vector_bitmap->get_data(), vector_bitmap->get_data_size());
954 histogram->draw(0, 0);
959 waveform->draw_bitmap(waveform_bitmap,
967 vectorscope->draw_bitmap(vector_bitmap,
973 draw_overlays(1, 0, 1);
978 void ScopeGUI::update_toggles()
980 hist_parade_on->update(use_hist_parade);
981 hist_on->update(use_hist);
982 waveform_parade_on->update(use_wave_parade);
983 waveform_on->update(use_wave);
984 vector_on->update(use_vector);
996 ScopePanel::ScopePanel(ScopeGUI *gui,
1001 : BC_SubWindow(x, y, w, h, BLACK)
1007 void ScopePanel::create_objects()
1009 set_cursor(CROSS_CURSOR, 0, 0);
1010 clear_box(0, 0, get_w(), get_h());
1013 void ScopePanel::update_point(int x, int y)
1017 void ScopePanel::draw_point()
1021 void ScopePanel::clear_point()
1025 int ScopePanel::button_press_event()
1027 if(is_event_win() && cursor_inside())
1029 gui->clear_points(1);
1032 int x = get_cursor_x();
1033 int y = get_cursor_y();
1034 CLAMP(x, 0, get_w() - 1);
1035 CLAMP(y, 0, get_h() - 1);
1043 int ScopePanel::cursor_motion_event()
1047 int x = get_cursor_x();
1048 int y = get_cursor_y();
1049 CLAMP(x, 0, get_w() - 1);
1050 CLAMP(y, 0, get_h() - 1);
1058 int ScopePanel::button_release_event()
1076 ScopeWaveform::ScopeWaveform(ScopeGUI *gui,
1081 : ScopePanel(gui, x, y, w, h)
1087 void ScopeWaveform::update_point(int x, int y)
1092 int frame_x = x * gui->frame_w / get_w();
1094 if(gui->use_wave_parade)
1096 if(x > get_w() / 3 * 2)
1097 frame_x = (x - get_w() / 3 * 2) * gui->frame_w / (get_w() / 3);
1100 frame_x = (x - get_w() / 3) * gui->frame_w / (get_w() / 3);
1102 frame_x = x * gui->frame_w / (get_w() / 3);
1105 float value = ((float)get_h() - y) / get_h() * (FLOAT_MAX - FLOAT_MIN) + FLOAT_MIN;
1107 char string[BCTEXTLEN];
1108 sprintf(string, "X: %d Value: %.3f", frame_x, value);
1109 gui->value_text->update(string, 0);
1115 void ScopeWaveform::draw_point()
1120 set_color(0xffffff);
1122 draw_line(0, drag_y, get_w(), drag_y);
1123 draw_line(drag_x, 0, drag_x, get_h());
1129 void ScopeWaveform::clear_point()
1142 ScopeVectorscope::ScopeVectorscope(ScopeGUI *gui,
1147 : ScopePanel(gui, x, y, w, h)
1153 void ScopeVectorscope::clear_point()
1161 void ScopeVectorscope::update_point(int x, int y)
1166 int radius = MIN(get_w() / 2, get_h() / 2);
1167 drag_radius = sqrt(SQR(x - get_w() / 2) + SQR(y - get_h() / 2));
1168 drag_angle = atan2(y - get_h() / 2, x - get_w() / 2);
1170 drag_radius = MIN(drag_radius, radius);
1172 float saturation = (float)drag_radius / radius * FLOAT_MAX;
1173 float hue = -drag_angle * 360 / 2 / M_PI - 90;
1174 if(hue < 0) hue += 360;
1176 char string[BCTEXTLEN];
1177 sprintf(string, "Hue: %.3f Sat: %.3f", hue, saturation);
1178 gui->value_text->update(string, 0);
1185 void ScopeVectorscope::draw_point()
1189 int radius = MIN(get_w() / 2, get_h() / 2);
1191 set_color(0xff0000);
1193 draw_circle(get_w() / 2 - drag_radius,
1194 get_h() / 2 - drag_radius,
1198 draw_line(get_w() / 2,
1200 get_w() / 2 + radius * cos(drag_angle),
1201 get_h() / 2 + radius * sin(drag_angle));
1209 ScopeHistogram::ScopeHistogram(ScopeGUI *gui,
1214 : ScopePanel(gui, x, y, w, h)
1219 void ScopeHistogram::clear_point()
1226 void ScopeHistogram::draw_point()
1231 set_color(0xffffff);
1233 draw_line(drag_x, 0, drag_x, get_h());
1239 void ScopeHistogram::update_point(int x, int y)
1243 float value = (float)x / get_w() * (FLOAT_MAX - FLOAT_MIN) + FLOAT_MIN;
1245 char string[BCTEXTLEN];
1246 sprintf(string, "Value: %.3f", value);
1247 gui->value_text->update(string, 0);
1255 void ScopeHistogram::draw_mode(int mode, int color, int y, int h)
1257 // Highest of all bins
1259 for(int i = 0; i < TOTAL_BINS; i++)
1261 if(gui->bins[mode][i] > normalize) normalize = gui->bins[mode][i];
1267 for(int i = 0; i < get_w(); i++)
1269 int accum_start = (int)(i * TOTAL_BINS / get_w());
1270 int accum_end = (int)((i + 1) * TOTAL_BINS / get_w());
1271 CLAMP(accum_start, 0, TOTAL_BINS);
1272 CLAMP(accum_end, 0, TOTAL_BINS);
1275 for(int k = accum_start; k < accum_end; k++)
1277 max = MAX(gui->bins[mode][k], max);
1280 // max = max * h / normalize;
1281 max = (int)(log(max) / log(normalize) * h);
1283 draw_line(i, y + h - max, i, y + h);
1287 void ScopeHistogram::draw(int flash, int flush)
1289 clear_box(0, 0, get_w(), get_h());
1291 if(gui->use_hist_parade)
1293 draw_mode(0, 0xff0000, 0, get_h() / 3);
1294 draw_mode(1, 0x00ff00, get_h() / 3, get_h() / 3);
1295 draw_mode(2, 0x0000ff, get_h() / 3 * 2, get_h() / 3);
1299 draw_mode(3, LTGREY, 0, get_h());
1302 if(flash) this->flash(0);
1303 if(flush) this->flush();
1311 ScopeToggle::ScopeToggle(ScopeGUI *gui,
1317 get_image_set(gui, value),
1321 this->value = value;
1322 if(value == &gui->use_hist_parade)
1324 set_tooltip(_("Histogram Parade"));
1327 if(value == &gui->use_hist)
1329 set_tooltip(_("Histogram"));
1332 if(value == &gui->use_wave_parade)
1334 set_tooltip(_("Waveform Parade"));
1337 if(value == &gui->use_wave)
1339 set_tooltip(_("Waveform"));
1343 set_tooltip(_("Vectorscope"));
1347 VFrame** ScopeToggle::get_image_set(ScopeGUI *gui, int *value)
1349 if(value == &gui->use_hist_parade)
1351 return gui->theme->get_image_set("histogram_rgb_toggle");
1354 if(value == &gui->use_hist)
1356 return gui->theme->get_image_set("histogram_toggle");
1359 if(value == &gui->use_wave_parade)
1361 return gui->theme->get_image_set("waveform_rgb_toggle");
1364 if(value == &gui->use_wave)
1366 return gui->theme->get_image_set("waveform_toggle");
1370 return gui->theme->get_image_set("scope_toggle");
1374 int ScopeToggle::handle_event()
1376 *value = get_value();
1377 if(value == &gui->use_hist_parade)
1379 if(get_value()) gui->use_hist = 0;
1382 if(value == &gui->use_hist)
1384 if(get_value()) gui->use_hist_parade = 0;
1387 if(value == &gui->use_wave_parade)
1389 if(get_value()) gui->use_wave = 0;
1392 if(value == &gui->use_wave)
1394 if(get_value()) gui->use_wave_parade = 0;
1398 gui->toggle_event();
1399 gui->update_toggles();
1400 gui->create_panels();