00001 #include "bcdisplayinfo.h"
00002 #include "bcsignals.h"
00003 #include "cursors.h"
00004 #include "histogram.h"
00005 #include "histogramconfig.h"
00006 #include "histogramwindow.h"
00007 #include "keys.h"
00008 #include "language.h"
00009
00010
00011 #include <unistd.h>
00012
00013 PLUGIN_THREAD_OBJECT(HistogramMain, HistogramThread, HistogramWindow)
00014
00015
00016
00017 HistogramWindow::HistogramWindow(HistogramMain *plugin, int x, int y)
00018 : BC_Window(plugin->gui_string,
00019 x,
00020 y,
00021 440,
00022 500,
00023 440,
00024 500,
00025 0,
00026 1,
00027 1)
00028 {
00029 this->plugin = plugin;
00030 }
00031
00032 HistogramWindow::~HistogramWindow()
00033 {
00034 }
00035
00036 #include "max_picon_png.h"
00037 #include "mid_picon_png.h"
00038 #include "min_picon_png.h"
00039 static VFrame max_picon_image(max_picon_png);
00040 static VFrame mid_picon_image(mid_picon_png);
00041 static VFrame min_picon_image(min_picon_png);
00042
00043 int HistogramWindow::create_objects()
00044 {
00045 int x = 10, y = 10, x1 = 10;
00046 BC_Title *title = 0;
00047
00048 max_picon = new BC_Pixmap(this, &max_picon_image);
00049 mid_picon = new BC_Pixmap(this, &mid_picon_image);
00050 min_picon = new BC_Pixmap(this, &min_picon_image);
00051 add_subwindow(mode_v = new HistogramMode(plugin,
00052 x,
00053 y,
00054 HISTOGRAM_VALUE,
00055 _("Value")));
00056 x += 70;
00057 add_subwindow(mode_r = new HistogramMode(plugin,
00058 x,
00059 y,
00060 HISTOGRAM_RED,
00061 _("Red")));
00062 x += 70;
00063 add_subwindow(mode_g = new HistogramMode(plugin,
00064 x,
00065 y,
00066 HISTOGRAM_GREEN,
00067 _("Green")));
00068 x += 70;
00069 add_subwindow(mode_b = new HistogramMode(plugin,
00070 x,
00071 y,
00072 HISTOGRAM_BLUE,
00073 _("Blue")));
00074
00075
00076
00077
00078
00079
00080
00081 x = x1;
00082 y += 30;
00083 add_subwindow(title = new BC_Title(x, y, _("Input X:")));
00084 x += title->get_w() + 10;
00085 input_x = new HistogramInputText(plugin,
00086 this,
00087 x,
00088 y,
00089 1);
00090 input_x->create_objects();
00091
00092 x += input_x->get_w() + 10;
00093 add_subwindow(title = new BC_Title(x, y, _("Input Y:")));
00094 x += title->get_w() + 10;
00095 input_y = new HistogramInputText(plugin,
00096 this,
00097 x,
00098 y,
00099 0);
00100 input_y->create_objects();
00101
00102 y += 30;
00103 x = x1;
00104
00105 canvas_w = get_w() - x - x;
00106 canvas_h = get_h() - y - 190;
00107 title1_x = x;
00108 title2_x = x + (int)(canvas_w * -MIN_INPUT / FLOAT_RANGE);
00109 title3_x = x + (int)(canvas_w * (1.0 - MIN_INPUT) / FLOAT_RANGE);
00110 title4_x = x + (int)(canvas_w);
00111 add_subwindow(canvas = new HistogramCanvas(plugin,
00112 this,
00113 x,
00114 y,
00115 canvas_w,
00116 canvas_h));
00117
00118 plugin->tabulate_curve(plugin->mode, 0);
00119 draw_canvas_overlay();
00120 canvas->flash();
00121
00122 y += canvas->get_h() + 1;
00123 add_subwindow(new BC_Title(title1_x,
00124 y,
00125 "-10%"));
00126 add_subwindow(new BC_Title(title2_x,
00127 y,
00128 "0%"));
00129 add_subwindow(new BC_Title(title3_x - get_text_width(MEDIUMFONT, "100"),
00130 y,
00131 "100%"));
00132 add_subwindow(new BC_Title(title4_x - get_text_width(MEDIUMFONT, "110"),
00133 y,
00134 "110%"));
00135
00136 y += 20;
00137 add_subwindow(title = new BC_Title(x, y, _("Output min:")));
00138 x += title->get_w() + 10;
00139 output_min = new HistogramOutputText(plugin,
00140 this,
00141 x,
00142 y,
00143 &plugin->config.output_min[plugin->mode]);
00144 output_min->create_objects();
00145 x += output_min->get_w() + 10;
00146 add_subwindow(new BC_Title(x, y, _("Output Max:")));
00147 x += title->get_w() + 10;
00148 output_max = new HistogramOutputText(plugin,
00149 this,
00150 x,
00151 y,
00152 &plugin->config.output_max[plugin->mode]);
00153 output_max->create_objects();
00154
00155 x = x1;
00156 y += 30;
00157
00158 add_subwindow(output = new HistogramSlider(plugin,
00159 this,
00160 x,
00161 y,
00162 get_w() - 20,
00163 30,
00164 0));
00165 output->update();
00166 y += 40;
00167
00168
00169 add_subwindow(automatic = new HistogramAuto(plugin,
00170 x,
00171 y));
00172
00173 x += 120;
00174 add_subwindow(new HistogramReset(plugin,
00175 x,
00176 y));
00177 x += 100;
00178 add_subwindow(new BC_Title(x, y, _("Threshold:")));
00179 x += 100;
00180 threshold = new HistogramOutputText(plugin,
00181 this,
00182 x,
00183 y,
00184 &plugin->config.threshold);
00185 threshold->create_objects();
00186
00187 x = x1;
00188 y += 30;
00189 add_subwindow(plot = new HistogramPlot(plugin,
00190 x,
00191 y));
00192
00193 y += plot->get_h() + 5;
00194 add_subwindow(split = new HistogramSplit(plugin,
00195 x,
00196 y));
00197
00198
00199 show_window();
00200
00201 return 0;
00202 }
00203
00204 WINDOW_CLOSE_EVENT(HistogramWindow)
00205
00206 int HistogramWindow::keypress_event()
00207 {
00208 int result = 0;
00209 if(get_keypress() == BACKSPACE ||
00210 get_keypress() == DELETE)
00211 {
00212 if(plugin->current_point >= 0)
00213 {
00214 HistogramPoint *current =
00215 plugin->config.points[plugin->mode].get_item_number(plugin->current_point);
00216 delete current;
00217 plugin->current_point = -1;
00218 update_input();
00219 update_canvas();
00220 plugin->send_configure_change();
00221 result = 1;
00222 }
00223 }
00224 return result;
00225 }
00226
00227 void HistogramWindow::update(int do_input)
00228 {
00229 automatic->update(plugin->config.automatic);
00230 threshold->update(plugin->config.threshold);
00231 update_mode();
00232
00233 if(do_input) update_input();
00234 update_output();
00235 }
00236
00237 void HistogramWindow::update_input()
00238 {
00239 input_x->update();
00240 input_y->update();
00241 }
00242
00243 void HistogramWindow::update_output()
00244 {
00245 output->update();
00246 output_min->update(plugin->config.output_min[plugin->mode]);
00247 output_max->update(plugin->config.output_max[plugin->mode]);
00248 }
00249
00250 void HistogramWindow::update_mode()
00251 {
00252 mode_v->update(plugin->mode == HISTOGRAM_VALUE ? 1 : 0);
00253 mode_r->update(plugin->mode == HISTOGRAM_RED ? 1 : 0);
00254 mode_g->update(plugin->mode == HISTOGRAM_GREEN ? 1 : 0);
00255 mode_b->update(plugin->mode == HISTOGRAM_BLUE ? 1 : 0);
00256 output_min->output = &plugin->config.output_min[plugin->mode];
00257 output_max->output = &plugin->config.output_max[plugin->mode];
00258 plot->update(plugin->config.plot);
00259 split->update(plugin->config.split);
00260 }
00261
00262 void HistogramWindow::draw_canvas_overlay()
00263 {
00264 canvas->set_color(0x00ff00);
00265 int y1;
00266
00267
00268
00269 for(int i = 0; i < canvas_w; i++)
00270 {
00271 float input = (float)i /
00272 canvas_w *
00273 FLOAT_RANGE +
00274 MIN_INPUT;
00275 float output = plugin->calculate_smooth(input, plugin->mode);
00276
00277 int y2 = canvas_h - (int)(output * canvas_h);
00278 if(i > 0)
00279 {
00280 canvas->draw_line(i - 1, y1, i, y2);
00281 }
00282 y1 = y2;
00283 }
00284
00285
00286 HistogramPoint *current = plugin->config.points[plugin->mode].first;
00287 int number = 0;
00288 while(current)
00289 {
00290 int x1;
00291 int y1;
00292 int x2;
00293 int y2;
00294 int x;
00295 int y;
00296 get_point_extents(current,
00297 &x1,
00298 &y1,
00299 &x2,
00300 &y2,
00301 &x,
00302 &y);
00303
00304 if(number == plugin->current_point)
00305 canvas->draw_box(x1, y1, x2 - x1, y2 - y1);
00306 else
00307 canvas->draw_rectangle(x1, y1, x2 - x1, y2 - y1);
00308 current = NEXT;
00309 number++;
00310 }
00311
00312
00313
00314 canvas->set_color(0xff0000);
00315 canvas->draw_line(title2_x - canvas->get_x(),
00316 0,
00317 title2_x - canvas->get_x(),
00318 canvas_h);
00319 canvas->draw_line(title3_x - canvas->get_x(),
00320 0,
00321 title3_x - canvas->get_x(),
00322 canvas_h);
00323 }
00324
00325 void HistogramWindow::update_canvas()
00326 {
00327 int *accum = plugin->accum[plugin->mode];
00328 int accum_per_canvas_i = HISTOGRAM_SLOTS / canvas_w + 1;
00329 float accum_per_canvas_f = (float)HISTOGRAM_SLOTS / canvas_w;
00330 int normalize = 0;
00331 int max = 0;
00332
00333
00334 plugin->tabulate_curve(plugin->mode, 0);
00335
00336 for(int i = 0; i < HISTOGRAM_SLOTS; i++)
00337 {
00338 if(accum && accum[i] > normalize) normalize = accum[i];
00339 }
00340
00341
00342 if(normalize)
00343 {
00344 for(int i = 0; i < canvas_w; i++)
00345 {
00346 int accum_start = (int)(accum_per_canvas_f * i);
00347 int accum_end = accum_start + accum_per_canvas_i;
00348 max = 0;
00349 for(int j = accum_start; j < accum_end; j++)
00350 {
00351 max = MAX(accum[j], max);
00352 }
00353
00354
00355 max = (int)(log(max) / log(normalize) * canvas_h);
00356
00357 canvas->set_color(0xffffff);
00358 canvas->draw_line(i, 0, i, canvas_h - max);
00359 canvas->set_color(0x000000);
00360 canvas->draw_line(i, canvas_h - max, i, canvas_h);
00361 }
00362 }
00363 else
00364 {
00365 canvas->set_color(0xffffff);
00366 canvas->draw_box(0, 0, canvas_w, canvas_h);
00367 }
00368
00369
00370 draw_canvas_overlay();
00371 canvas->flash();
00372 }
00373
00374 void HistogramWindow::get_point_extents(HistogramPoint *current,
00375 int *x1,
00376 int *y1,
00377 int *x2,
00378 int *y2,
00379 int *x,
00380 int *y)
00381 {
00382 *x = (int)((current->x - MIN_INPUT) * canvas_w / FLOAT_RANGE);
00383 *y = (int)(canvas_h - current->y * canvas_h);
00384 *x1 = *x - BOX_SIZE / 2;
00385 *y1 = *y - BOX_SIZE / 2;
00386 *x2 = *x1 + BOX_SIZE;
00387 *y2 = *y1 + BOX_SIZE;
00388 }
00389
00390
00391
00392
00393
00394
00395
00396 HistogramCanvas::HistogramCanvas(HistogramMain *plugin,
00397 HistogramWindow *gui,
00398 int x,
00399 int y,
00400 int w,
00401 int h)
00402 : BC_SubWindow(x,
00403 y,
00404 w,
00405 h,
00406 0xffffff)
00407 {
00408 this->plugin = plugin;
00409 this->gui = gui;
00410 }
00411
00412 int HistogramCanvas::button_press_event()
00413 {
00414 int result = 0;
00415 if(is_event_win() && cursor_inside())
00416 {
00417 if(!plugin->dragging_point &&
00418 (!plugin->config.automatic || plugin->mode == HISTOGRAM_VALUE))
00419 {
00420 HistogramPoint *new_point = 0;
00421 gui->deactivate();
00422
00423 HistogramPoint *current = plugin->config.points[plugin->mode].first;
00424 plugin->current_point = -1;
00425 while(current)
00426 {
00427 int x = (int)((current->x - MIN_INPUT) * gui->canvas_w / FLOAT_RANGE);
00428 int y = (int)(gui->canvas_h - current->y * gui->canvas_h);
00429
00430 if(get_cursor_x() >= x - BOX_SIZE / 2 &&
00431 get_cursor_y() >= y - BOX_SIZE / 2 &&
00432 get_cursor_x() < x + BOX_SIZE / 2 &&
00433 get_cursor_y() < y + BOX_SIZE / 2)
00434 {
00435 plugin->current_point =
00436 plugin->config.points[plugin->mode].number_of(current);
00437 plugin->point_x_offset = get_cursor_x() - x;
00438 plugin->point_y_offset = get_cursor_y() - y;
00439 break;
00440 }
00441 current = NEXT;
00442 }
00443
00444 if(plugin->current_point < 0)
00445 {
00446
00447 float current_x = (float)get_cursor_x() *
00448 FLOAT_RANGE /
00449 get_w() +
00450 MIN_INPUT;
00451 float current_y = 1.0 -
00452 (float)get_cursor_y() /
00453 get_h();
00454 new_point =
00455 plugin->config.points[plugin->mode].insert(current_x, current_y);
00456 plugin->current_point =
00457 plugin->config.points[plugin->mode].number_of(new_point);
00458 plugin->point_x_offset = 0;
00459 plugin->point_y_offset = 0;
00460 }
00461
00462 plugin->dragging_point = 1;
00463 result = 1;
00464
00465 plugin->config.boundaries();
00466 gui->update_input();
00467 gui->update_canvas();
00468 if(new_point)
00469 {
00470 plugin->send_configure_change();
00471 }
00472 }
00473 }
00474 return result;
00475 }
00476
00477 int HistogramCanvas::cursor_motion_event()
00478 {
00479 if(plugin->dragging_point)
00480 {
00481 float current_x =
00482 (float)(get_cursor_x() - plugin->point_x_offset) *
00483 FLOAT_RANGE /
00484 get_w() +
00485 MIN_INPUT;
00486 float current_y = 1.0 -
00487 (float)(get_cursor_y() - plugin->point_y_offset) /
00488 get_h();
00489 HistogramPoint *current_point =
00490 plugin->config.points[plugin->mode].get_item_number(plugin->current_point);
00491 current_point->x = current_x;
00492 current_point->y = current_y;
00493 plugin->config.boundaries();
00494 gui->update_input();
00495 gui->update_canvas();
00496 plugin->send_configure_change();
00497 return 1;
00498 }
00499 else
00500 if(is_event_win() && cursor_inside())
00501 {
00502 HistogramPoint *current = plugin->config.points[plugin->mode].first;
00503 int done = 0;
00504 while(current && !done)
00505 {
00506 int x1;
00507 int y1;
00508 int x2;
00509 int y2;
00510 int x;
00511 int y;
00512 gui->get_point_extents(current,
00513 &x1,
00514 &y1,
00515 &x2,
00516 &y2,
00517 &x,
00518 &y);
00519 int new_cursor = ARROW_CURSOR;
00520 if(get_cursor_x() >= x1 &&
00521 get_cursor_y() >= y1 &&
00522 get_cursor_x() < x2 &&
00523 get_cursor_y() < y2)
00524 {
00525 new_cursor = UPRIGHT_ARROW_CURSOR;
00526 done = 1;
00527 }
00528
00529 if(new_cursor != get_cursor())
00530 set_cursor(new_cursor);
00531
00532
00533 current = NEXT;
00534 }
00535 }
00536 return 0;
00537 }
00538
00539 int HistogramCanvas::button_release_event()
00540 {
00541 if(plugin->dragging_point)
00542 {
00543
00544 HistogramPoint *current =
00545 plugin->config.points[plugin->mode].get_item_number(plugin->current_point);
00546 HistogramPoint *prev = PREVIOUS;
00547 HistogramPoint *next = NEXT;
00548
00549 if((prev && prev->x >= current->x) ||
00550 (next && next->x <= current->x))
00551 {
00552 delete current;
00553 plugin->current_point = -1;
00554 plugin->config.boundaries();
00555 gui->update_input();
00556 gui->update_canvas();
00557 plugin->send_configure_change();
00558 }
00559
00560 plugin->dragging_point = 0;
00561 }
00562 return 0;
00563 }
00564
00565
00566
00567
00568
00569
00570
00571 HistogramReset::HistogramReset(HistogramMain *plugin,
00572 int x,
00573 int y)
00574 : BC_GenericButton(x, y, _("Reset"))
00575 {
00576 this->plugin = plugin;
00577 }
00578 int HistogramReset::handle_event()
00579 {
00580 plugin->config.reset(0);
00581 plugin->thread->window->update(1);
00582 plugin->thread->window->update_canvas();
00583 plugin->send_configure_change();
00584 return 1;
00585 }
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595 HistogramSlider::HistogramSlider(HistogramMain *plugin,
00596 HistogramWindow *gui,
00597 int x,
00598 int y,
00599 int w,
00600 int h,
00601 int is_input)
00602 : BC_SubWindow(x, y, w, h)
00603 {
00604 this->plugin = plugin;
00605 this->gui = gui;
00606 this->is_input = is_input;
00607 operation = NONE;
00608 }
00609
00610 int HistogramSlider::input_to_pixel(float input)
00611 {
00612 return (int)((input - MIN_INPUT) / FLOAT_RANGE * get_w());
00613 }
00614
00615 int HistogramSlider::button_press_event()
00616 {
00617 if(is_event_win() && cursor_inside())
00618 {
00619 int min;
00620 int max;
00621 int w = get_w();
00622 int h = get_h();
00623 int half_h = get_h() / 2;
00624
00625 gui->deactivate();
00626
00627 if(operation == NONE)
00628 {
00629 int x1 = input_to_pixel(plugin->config.output_min[plugin->mode]) -
00630 gui->mid_picon->get_w() / 2;
00631 int x2 = x1 + gui->mid_picon->get_w();
00632 if(get_cursor_x() >= x1 && get_cursor_x() < x2 &&
00633 get_cursor_y() >= half_h && get_cursor_y() < h)
00634 {
00635 operation = DRAG_MIN_OUTPUT;
00636 }
00637 }
00638
00639 if(operation == NONE)
00640 {
00641 int x1 = input_to_pixel(plugin->config.output_max[plugin->mode]) -
00642 gui->mid_picon->get_w() / 2;
00643 int x2 = x1 + gui->mid_picon->get_w();
00644 if(get_cursor_x() >= x1 && get_cursor_x() < x2 &&
00645 get_cursor_y() >= half_h && get_cursor_y() < h)
00646 {
00647 operation = DRAG_MAX_OUTPUT;
00648 }
00649 }
00650 return 1;
00651 }
00652 return 0;
00653 }
00654
00655 int HistogramSlider::button_release_event()
00656 {
00657 if(operation != NONE)
00658 {
00659 operation = NONE;
00660 return 1;
00661 }
00662 return 0;
00663 }
00664
00665 int HistogramSlider::cursor_motion_event()
00666 {
00667 if(operation != NONE)
00668 {
00669 float value = (float)get_cursor_x() / get_w() * FLOAT_RANGE + MIN_INPUT;
00670 CLAMP(value, MIN_INPUT, MAX_INPUT);
00671
00672 switch(operation)
00673 {
00674 case DRAG_MIN_OUTPUT:
00675 value = MIN(plugin->config.output_max[plugin->mode], value);
00676 plugin->config.output_min[plugin->mode] = value;
00677 break;
00678 case DRAG_MAX_OUTPUT:
00679 value = MAX(plugin->config.output_min[plugin->mode], value);
00680 plugin->config.output_max[plugin->mode] = value;
00681 break;
00682 }
00683
00684 plugin->config.boundaries();
00685 gui->update_output();
00686
00687 plugin->send_configure_change();
00688 return 1;
00689 }
00690 return 0;
00691 }
00692
00693 void HistogramSlider::update()
00694 {
00695 int w = get_w();
00696 int h = get_h();
00697 int half_h = get_h() / 2;
00698 int quarter_h = get_h() / 4;
00699 int mode = plugin->mode;
00700 int r = 0xff;
00701 int g = 0xff;
00702 int b = 0xff;
00703
00704 clear_box(0, 0, w, h);
00705
00706 switch(mode)
00707 {
00708 case HISTOGRAM_RED:
00709 g = b = 0x00;
00710 break;
00711 case HISTOGRAM_GREEN:
00712 r = b = 0x00;
00713 break;
00714 case HISTOGRAM_BLUE:
00715 r = g = 0x00;
00716 break;
00717 }
00718
00719 for(int i = 0; i < w; i++)
00720 {
00721 int color = (int)(i * 0xff / w);
00722 set_color(((r * color / 0xff) << 16) |
00723 ((g * color / 0xff) << 8) |
00724 (b * color / 0xff));
00725
00726 draw_line(i, 0, i, half_h);
00727 }
00728
00729 float min;
00730 float max;
00731 min = plugin->config.output_min[plugin->mode];
00732 max = plugin->config.output_max[plugin->mode];
00733
00734 draw_pixmap(gui->min_picon,
00735 input_to_pixel(min) - gui->min_picon->get_w() / 2,
00736 half_h + 1);
00737 draw_pixmap(gui->max_picon,
00738 input_to_pixel(max) - gui->max_picon->get_w() / 2,
00739 half_h + 1);
00740
00741 flash();
00742 flush();
00743 }
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753 HistogramAuto::HistogramAuto(HistogramMain *plugin,
00754 int x,
00755 int y)
00756 : BC_CheckBox(x, y, plugin->config.automatic, _("Automatic"))
00757 {
00758 this->plugin = plugin;
00759 }
00760
00761 int HistogramAuto::handle_event()
00762 {
00763 plugin->config.automatic = get_value();
00764 plugin->send_configure_change();
00765 return 1;
00766 }
00767
00768
00769
00770
00771 HistogramPlot::HistogramPlot(HistogramMain *plugin,
00772 int x,
00773 int y)
00774 : BC_CheckBox(x, y, plugin->config.plot, _("Plot histogram"))
00775 {
00776 this->plugin = plugin;
00777 }
00778
00779 int HistogramPlot::handle_event()
00780 {
00781 plugin->config.plot = get_value();
00782 plugin->send_configure_change();
00783 return 1;
00784 }
00785
00786
00787
00788
00789 HistogramSplit::HistogramSplit(HistogramMain *plugin,
00790 int x,
00791 int y)
00792 : BC_CheckBox(x, y, plugin->config.split, _("Split output"))
00793 {
00794 this->plugin = plugin;
00795 }
00796
00797 int HistogramSplit::handle_event()
00798 {
00799 plugin->config.split = get_value();
00800 plugin->send_configure_change();
00801 return 1;
00802 }
00803
00804
00805
00806 HistogramMode::HistogramMode(HistogramMain *plugin,
00807 int x,
00808 int y,
00809 int value,
00810 char *text)
00811 : BC_Radial(x, y, plugin->mode == value, text)
00812 {
00813 this->plugin = plugin;
00814 this->value = value;
00815 }
00816 int HistogramMode::handle_event()
00817 {
00818 plugin->mode = value;
00819 plugin->current_point= -1;
00820 plugin->thread->window->update_canvas();
00821 plugin->thread->window->update_mode();
00822 plugin->thread->window->update_input();
00823 plugin->thread->window->update_canvas();
00824 plugin->thread->window->update_output();
00825 plugin->thread->window->output->update();
00826
00827 return 1;
00828 }
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838 HistogramOutputText::HistogramOutputText(HistogramMain *plugin,
00839 HistogramWindow *gui,
00840 int x,
00841 int y,
00842 float *output)
00843 : BC_TumbleTextBox(gui,
00844 output ? (float)*output : 0.0,
00845 (float)MIN_INPUT,
00846 (float)MAX_INPUT,
00847 x,
00848 y,
00849 60)
00850 {
00851 this->plugin = plugin;
00852 this->output = output;
00853 set_precision(DIGITS);
00854 set_increment(PRECISION);
00855 }
00856
00857
00858 int HistogramOutputText::handle_event()
00859 {
00860 if(output)
00861 {
00862 *output = atof(get_text());
00863 }
00864
00865 plugin->thread->window->output->update();
00866 plugin->send_configure_change();
00867 return 1;
00868 }
00869
00870
00871
00872
00873
00874
00875
00876
00877 HistogramInputText::HistogramInputText(HistogramMain *plugin,
00878 HistogramWindow *gui,
00879 int x,
00880 int y,
00881 int do_x)
00882 : BC_TumbleTextBox(gui,
00883 0.0,
00884 (float)MIN_INPUT,
00885 (float)MAX_INPUT,
00886 x,
00887 y,
00888 60)
00889 {
00890 this->do_x = do_x;
00891 this->plugin = plugin;
00892 this->gui = gui;
00893 set_precision(DIGITS);
00894 set_increment(PRECISION);
00895 }
00896
00897
00898 int HistogramInputText::handle_event()
00899 {
00900 if(plugin->current_point >= 0 &&
00901 plugin->current_point < plugin->config.points[plugin->mode].total())
00902 {
00903 HistogramPoint *point =
00904 plugin->config.points[plugin->mode].get_item_number(
00905 plugin->current_point);
00906
00907 if(point)
00908 {
00909 if(do_x)
00910 point->x = atof(get_text());
00911 else
00912 point->y = atof(get_text());
00913
00914 plugin->config.boundaries();
00915 gui->update_canvas();
00916
00917 plugin->thread->window->output->update();
00918 plugin->send_configure_change();
00919 }
00920 }
00921 return 1;
00922 }
00923
00924 void HistogramInputText::update()
00925 {
00926 if(plugin->current_point >= 0 &&
00927 plugin->current_point < plugin->config.points[plugin->mode].total())
00928 {
00929 HistogramPoint *point =
00930
00931 plugin->config.points[plugin->mode].get_item_number(
00932 plugin->current_point);
00933
00934 if(point)
00935 {
00936 if(do_x)
00937 BC_TumbleTextBox::update(point->x);
00938 else
00939 BC_TumbleTextBox::update(point->y);
00940 }
00941 else
00942 {
00943 BC_TumbleTextBox::update((float)0.0);
00944 }
00945 }
00946 else
00947 {
00948 BC_TumbleTextBox::update((float)0.0);
00949 }
00950
00951 }
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965