⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dialogs.cpp

📁 Ocr source code. provides an Ocr engine that works in C++ language.
💻 CPP
📖 第 1 页 / 共 3 页
字号:
     close_buttonbox.set_layout(Gtk::BUTTONBOX_END);     close_buttonbox.pack_end(close_button);     get_vbox()->pack_start(close_buttonbox);     close_button.signal_clicked().connect(sigc::mem_fun(*this,                                           &cfg_dialog::on_close_button_click));     show_all_children();}void cfg_dialog::on_cfg_profile_browse() {     Gtk::FileChooserDialog dialog("Choose the profile",                                    Gtk::FILE_CHOOSER_ACTION_OPEN);     dialog.set_transient_for(*this);     dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);     dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);     int run_result = dialog.run();     if(run_result == Gtk::RESPONSE_OK)          pro_text.set_text(dialog.get_filename());}void cfg_dialog::on_cfg_profile_dir_browse() {     Gtk::FileChooserDialog dialog("Choose the profile directory",                                    Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);     dialog.set_transient_for(*this);     dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);     dialog.add_button("Select Folder", Gtk::RESPONSE_OK);     int run_result = dialog.run();     if(run_result == Gtk::RESPONSE_OK)          prodir_text.set_text(dialog.get_filename());}void cfg_dialog::on_cfg_save_dir_browse() {     Gtk::FileChooserDialog dialog("Choose the save directory",                                    Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);     dialog.set_transient_for(*this);     dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);     dialog.add_button("Select Folder", Gtk::RESPONSE_OK);     int run_result = dialog.run();     if(run_result == Gtk::RESPONSE_OK)          savedir_text.set_text(dialog.get_filename());}void cfg_dialog::on_cfg_scan_dir_browse() {     Gtk::FileChooserDialog dialog("Choose the scan directory",                                    Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);     dialog.set_transient_for(*this);     dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);     dialog.add_button("Select Folder", Gtk::RESPONSE_OK);     int run_result = dialog.run();     if(run_result == Gtk::RESPONSE_OK)          scandir_text.set_text(dialog.get_filename());}void cfg_dialog::on_cfg_log_dir_browse() {     Gtk::FileChooserDialog dialog("Choose the log directory",                                    Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);     dialog.set_transient_for(*this);     dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);     dialog.add_button("Select Folder", Gtk::RESPONSE_OK);     int run_result = dialog.run();     if(run_result == Gtk::RESPONSE_OK)          logdir_text.set_text(dialog.get_filename());}void cfg_dialog::on_cfg_log_file_browse() {     Gtk::FileChooserDialog dialog("Choose the log file",                                    Gtk::FILE_CHOOSER_ACTION_OPEN);     dialog.set_transient_for(*this);     dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);     dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);     int run_result = dialog.run();     if(run_result == Gtk::RESPONSE_OK)          logfile_text.set_text(dialog.get_filename());}void cfg_dialog::on_close_button_click() {     // general config:     bool reload_profile = false;     if(cfg_profile != pro_text.get_text())          reload_profile = true;         cfg_profile = pro_text.get_text();     cfg_profile_dir = prodir_text.get_text();     cfg_save_dir = savedir_text.get_text();     cfg_scan_dir = scandir_text.get_text();     cfg_log_dir = logdir_text.get_text();     cfg_log_file = logfile_text.get_text();     // parsing config:     ZERO_INST_PR0_PGIVEN = atof(ZI_PR0_PG_text.get_text().c_str());     if(ZERO_INST_PR0_PGIVEN < 0.0)          ZERO_INST_PR0_PGIVEN = 0.0;     else if(ZERO_INST_PR0_PGIVEN > 1.0)          ZERO_INST_PR0_PGIVEN = 1.0;     ZERO_INST_PR1_PGIVEN = atof(ZI_PR1_PG_text.get_text().c_str());     if(ZERO_INST_PR1_PGIVEN < 0.0)          ZERO_INST_PR1_PGIVEN = 0.0;     else if(ZERO_INST_PR1_PGIVEN > 1.0)          ZERO_INST_PR1_PGIVEN = 1.0;     ZERO_INST_PR0_PGC = atof(ZI_PR0_PGC_text.get_text().c_str());     if(ZERO_INST_PR0_PGC < 0.0)          ZERO_INST_PR0_PGC = 0.0;     else if(ZERO_INST_PR0_PGC > 1.0)          ZERO_INST_PR0_PGC = 1.0;     ZERO_INST_PR1_PGC = atof(ZI_PR1_PGC_text.get_text().c_str());     if(ZERO_INST_PR1_PGC < 0.0)          ZERO_INST_PR1_PGC = 0.0;     else if(ZERO_INST_PR1_PGC > 1.0)          ZERO_INST_PR1_PGC = 1.0;          PR_SCALING_FACTOR = atof(PRSF_text.get_text().c_str());     if(PR_SCALING_FACTOR < 0)          PR_SCALING_FACTOR = (-1.0)*PR_SCALING_FACTOR;          parse_dialog_num_matches = atoi(p_dialog_matches_text.get_text().c_str());     if(parse_dialog_num_matches > NUM_TRAINED_CHARS)          parse_dialog_num_matches = NUM_TRAINED_CHARS;     else if(parse_dialog_num_matches < 0)          parse_dialog_num_matches = 1;          bool need_refresh = false;     if((atoi(ignore_edges_top_text.get_text().c_str()) !=          scan_ignore_edges_top) ||         (atoi(ignore_edges_bottom_text.get_text().c_str()) !=         scan_ignore_edges_bottom) ||        (atoi(ignore_edges_left_text.get_text().c_str()) !=         scan_ignore_edges_left) ||        (atoi(ignore_edges_right_text.get_text().c_str()) !=         scan_ignore_edges_right))          need_refresh = true;          scan_ignore_edges_top = atoi(ignore_edges_top_text.get_text().c_str());     if(scan_ignore_edges_top < 0)          scan_ignore_edges_top = 0;     scan_ignore_edges_bottom=atoi(ignore_edges_bottom_text.get_text().c_str());     if(scan_ignore_edges_bottom < 0)          scan_ignore_edges_bottom = 0;     scan_ignore_edges_left = atoi(ignore_edges_left_text.get_text().c_str());     if(scan_ignore_edges_left < 0)          scan_ignore_edges_left = 0;     scan_ignore_edges_right = atoi(ignore_edges_right_text.get_text().c_str());     if(scan_ignore_edges_right < 0)          scan_ignore_edges_right = 0;     if(need_refresh && (prog_mode == NORMAL))          signals.do_main_refresh();     else if(need_refresh && (prog_mode == TRAINING))          signals.do_tr_refresh();     if(atoi(space_int_padding_text.get_text().c_str()) < 0)          space_int_padding = 0;     else          space_int_padding = atoi(space_int_padding_text.get_text().c_str());     if(atoi(lineh_int_padding_text.get_text().c_str()) < 0)          line_height_int_padding = 0;     else          line_height_int_padding =                                atoi(lineh_int_padding_text.get_text().c_str());     // misc config:     int Rl, Ru, Gl, Gu, Bl, Bu, temp;     Rl = atoi(rgb_int_r_lower_entry.get_text().c_str());     Ru = atoi(rgb_int_r_upper_entry.get_text().c_str());     Gl = atoi(rgb_int_g_lower_entry.get_text().c_str());     Gu = atoi(rgb_int_g_upper_entry.get_text().c_str());     Bl = atoi(rgb_int_b_lower_entry.get_text().c_str());     Bu = atoi(rgb_int_b_upper_entry.get_text().c_str());       if(Rl < 0)          Rl = 0;     else if(Rl > 255)          Rl = 255;     if(Ru < 0)          Ru = 0;     else if(Ru > 255)          Ru = 255;     if(Rl > Ru) {          temp = Rl;          Rl = Ru;          Ru = temp;     }          if(Gl < 0)          Gl = 0;     else if(Gl > 255)          Gl = 255;     if(Gu < 0)          Gu = 0;     else if(Gu > 255)          Gu = 255;     if(Gl > Gu) {          temp = Gl;          Gl = Gu;          Gu = temp;     }          if(Bl < 0)          Bl = 0;     else if(Bl > 255)          Bl = 255;     if(Bu < 0)          Bu = 0;     else if(Bu > 255)          Bu = 255;     if(Bl > Bu) {          temp = Bl;          Bl = Bu;          Bu = temp;     }         grid_rgb_int.Rl = Rl;     grid_rgb_int.Ru = Ru;     grid_rgb_int.Gl = Gl;     grid_rgb_int.Gu = Gu;     grid_rgb_int.Bl = Bl;     grid_rgb_int.Bu = Bu;     // training config:     int gsx, gsy, gcx, gcy, interpx, s_lower, s_upper, lh_lower, lh_upper;          // check for profile / new gridcell conflicts:     gsx = atoi(gsx_entry.get_text().c_str());     gsy = atoi(gsy_entry.get_text().c_str());     gcx = atoi(gcx_entry.get_text().c_str());     gcy = atoi(gcy_entry.get_text().c_str());          if((tr_profile == NULL) && (prof == NULL)) {               if(gsx <= 0)               gsx = 1;          if(gsy <= 0)               gsy = 1;          if(gcx <= 0)               gcx = 1;          if(gcy <= 0)               gcy = 1;          if((gsx % gcx) != 0)               gsx = gsx + (gcx - (gsx % gcx));          if((gsy % gcy) != 0)               gsy = gsy + (gcy - (gsy % gcy));          trcfg_grid_size_x = gsx;          trcfg_grid_size_y = gsy;          trcfg_gridcell_size_x = gcx;          trcfg_gridcell_size_y = gcy;     }     else if((trcfg_grid_size_x != gsx) || (trcfg_grid_size_y != gsy) ||             (trcfg_gridcell_size_x != gcx) || (trcfg_gridcell_size_y != gcy)) {          popup_message(*this, "The grid(cell) sizes changed are not consistent with the current profile(s). Try clearing the profile(s) first");     }          interpx = atoi(interpx_entry.get_text().c_str());     if(interpx <= 0)          interpx = 1;     trcfg_intersect_px = interpx;     s_lower = atoi(spaceint_lower_entry.get_text().c_str());     s_upper = atoi(spaceint_upper_entry.get_text().c_str());     if(s_lower < 0)          s_lower = 0;     if(s_upper < 0)          s_upper = 0;     if(s_lower > s_upper) {          temp = s_lower;          s_lower = s_upper;          s_upper = temp;     }     trcfg_space_int.lower = s_lower;     trcfg_space_int.upper = s_upper;     lh_lower = atoi(linehint_lower_entry.get_text().c_str());     lh_upper = atoi(linehint_upper_entry.get_text().c_str());     if(lh_lower < 0)          lh_lower = 0;     if(lh_upper < 0)          lh_upper = 0;     if(lh_lower > lh_upper) {          temp = lh_lower;          lh_lower = lh_upper;          lh_upper = temp;     }     trcfg_line_height_int.lower = lh_lower;     trcfg_line_height_int.upper = lh_upper;          if(reload_profile)          load_profile_from_file(cfg_profile);     write_config_file(CONFIG_FILE_PATH);     hide();}/////// show parse stats dialog:int parse_dialog_num_matches = 5;parse_stats_da::parse_stats_da() : grid_char_da() {     signals.signal_grid_cfg_new_letter().connect(sigc::mem_fun(*this,                                       &parse_stats_da::on_new_grid_cfg_letter));}parse_stats_dialog::parse_stats_dialog() : grid_fill_check("display grid fill"),                                           prev_button("<- prev"),                                            next_button("next ->")  {     set_title("Parse Stats");     get_vbox()->set_spacing(10);     middle_hbox.set_spacing(10);     arrows_buttonbox.set_layout(Gtk::BUTTONBOX_SPREAD);          cur_pl = pf->plist->pl_begin;     if(cur_pl != NULL)          cur_pc = cur_pl->pc_begin;     if(cur_pc == NULL)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -