#include "stdafx.h" #include "MedialDialog.h" // MedialDialog dialog IMPLEMENT_DYNAMIC(MedialDialog, CDialog) MedialDialog::MedialDialog(CWnd* pParent /*=NULL*/) : CDialog(MedialDialog::IDD, pParent) , field_cache_ram_limit_int(0) { dialog_inactive_flags = BINARIZE_CONTROLS | FILTER_CONTROLS | FILESAVE_CONTROLS; is_bs_input_valid = false; is_ss_input_valid = false; is_cl_input_valid = false; is_ma_input_valid = false; } MedialDialog::~MedialDialog() { } void MedialDialog::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); /* SHARED (can copy and paste between dialogs) */ BindCommonInputFields(pDX); // Output checks DDX_Control(pDX, IDC_CHECK_SAVE_BS, check_save_bs_cube); DDX_Control(pDX, IDC_CHECK_SAVE_SS, check_save_ss_cube); DDX_Control(pDX, IDC_CHECK_SAVE_CL, check_save_cl_cube); DDX_Control(pDX, IDC_CHECK_SAVE_BS_RGB, check_save_bs_cube_rgb); DDX_Control(pDX, IDC_CHECK_SAVE_SS_RGB, check_save_ss_cube_rgb); DDX_Control(pDX, IDC_CHECK_SAVE_CL_RGB, check_save_cl_cube_rgb); DDX_Control(pDX, IDC_CHECK_MARK_CL_MAX, check_mark_cl_max); DDX_Control(pDX, IDC_CHECK_SAVE_SP, check_save_sp_cube); DDX_Control(pDX, IDC_CHECK_SAVE_MA_1BIT, check_save_medial_axis_1bit); DDX_Control(pDX, IDC_CHECK_SAVE_MA_DETAILED, check_save_medial_axis_detailed); DDX_Control(pDX, IDC_CHECK_SAVE_MA_GRAPH, check_save_medial_axis_graph); // Options DDX_Control(pDX, IDC_CHECK_BOUND_ARE_FIBER, check_bounds_are_fiber); DDX_Control(pDX, IDC_COMBO_RP_METHOD, combo_rp_method); DDX_Control(pDX, IDC_CHECK_RUN_ON_FIBER, check_run_on_fiber); DDX_Control(pDX, IDC_CHECK_LOG_DELETED_PATHS, check_log_deleted_paths); DDX_Control(pDX, IDC_CHECK_LOG_FORCED_LINKS, check_log_forced_links); DDX_Control(pDX, IDC_CHECK_ENABLE_CACHING, check_enable_caching_from_disc); DDX_Control(pDX, IDC_EDIT_AVAILABLE_RAM, field_cache_ram_limit_cntrl); DDX_Text(pDX, IDC_EDIT_AVAILABLE_RAM, field_cache_ram_limit_int); // Analysis DDX_Control(pDX, IDC_EDIT_NODE_DENSITY_CUBE_uM, field_node_dens_um_cube_cntrl); DDX_Text(pDX, IDC_EDIT_NODE_DENSITY_CUBE_uM, field_node_dens_um_cube_float); // Optional inputs DDX_Control(pDX, IDC_CHECK_BS_INPUT, check_bs_input); DDX_Control(pDX, IDC_CHECK_SS_INPUT, check_ss_input); DDX_Control(pDX, IDC_CHECK_CL_INPUT, check_cl_input); DDX_Control(pDX, IDC_CHECK_SAVE_MA_INPUT, check_ma_input); DDX_Control(pDX, IDC_BUTTON_BS_CUBE_INPUT, button_bs_cube); DDX_Control(pDX, IDC_BUTTON_SS_CUBE_INPUT, button_ss_cube); DDX_Control(pDX, IDC_BUTTON_CL_CUBE_INPUT, button_cl_cube); DDX_Control(pDX, IDC_BUTTON_FINAL_MA_INPUT, button_ma_cube); DDX_Control(pDX, IDC_EDIT_BS_CUBE_INPUT, field_bs_file_name_cntrl); DDX_Control(pDX, IDC_EDIT_SS_CUBE_INPUT, field_ss_file_name_cntrl); DDX_Control(pDX, IDC_EDIT_CL_CUBE_INPUT, field_cl_file_name_cntrl); DDX_Control(pDX, IDC_EDIT_FINAL_MA_INPUT, field_ma_file_name_cntrl); DDX_Control(pDX, IDC_CHECK_SAVE_NETWORK_GRAPH_TXT, check_network_graph_txt); } BEGIN_MESSAGE_MAP(MedialDialog, CDialog) //messages similar to all dialogs ON_BN_CLICKED(IDC_BUTTON_INPUT_DIRECTORY, OnBnClickedButtonInputDirectory) ON_BN_CLICKED(IDC_BUTTON_WORK_DIRECTORY, OnBnClickedButtonWorkDirectory) ON_CBN_SELCHANGE(IDC_COMBO_THRESHOLDING_METHOD, OnCbnSelchangeComboThresholdingMethod) ON_EN_CHANGE(IDC_EDIT_MANUAL_THRESHOLD, OnEnChangeEditManualThreshold) ON_BN_CLICKED(IDSTOP, OnBnClickedStop) ON_EN_CHANGE(IDC_EDIT_WIDTH_SLICES, OnEnChangeEditWidthSlices) ON_EN_CHANGE(IDC_EDIT_END_SLICE, OnEnChangeEditEndSlice) ON_EN_CHANGE(IDC_EDIT_WIDTHX, OnEnChangeEditWidthx) ON_EN_CHANGE(IDC_EDIT_ENDX, OnEnChangeEditEndx) ON_EN_CHANGE(IDC_EDIT_WIDTHY, OnEnChangeEditWidthy) ON_EN_CHANGE(IDC_EDIT_ENDY, OnEnChangeEditEndy) ON_EN_CHANGE(IDC_EDIT_START_SLICE, OnEnChangeEditStartSlice) ON_EN_CHANGE(IDC_EDIT_STARTX, OnEnChangeEditStartx) ON_EN_CHANGE(IDC_EDIT_STARTY, OnEnChangeEditStarty) ON_BN_CLICKED(IDC_BUTTON_BS_CUBE_INPUT, &MedialDialog::OnBnClickedButtonBsCubeInput) ON_BN_CLICKED(IDC_BUTTON_SS_CUBE_INPUT, &MedialDialog::OnBnClickedButtonSsCubeInput) ON_BN_CLICKED(IDC_BUTTON_CL_CUBE_INPUT, &MedialDialog::OnBnClickedButtonClCubeInput) ON_BN_CLICKED(IDC_BUTTON_FINAL_MA_INPUT, &MedialDialog::OnBnClickedButtonFinalMaInput) ON_BN_CLICKED(IDC_CHECK_BS_INPUT, &MedialDialog::OnBnClickedCheckBsInput) ON_BN_CLICKED(IDC_CHECK_SS_INPUT, &MedialDialog::OnBnClickedCheckSsInput) ON_BN_CLICKED(IDC_CHECK_CL_INPUT, &MedialDialog::OnBnClickedCheckClInput) ON_BN_CLICKED(IDC_CHECK_SAVE_MA_INPUT, &MedialDialog::OnBnClickedCheckSaveMaInput) ON_BN_CLICKED(IDC_CHECK_ENABLE_CACHING, &MedialDialog::OnBnClickedCheckEnableCaching) END_MESSAGE_MAP() // MedialDialog message handlers void MedialDialog::OnOK() { // TODO: Add extra validation here bool is_dataright=true; CString m_error; // have windows auto check the parameters, and fill out variables if (!UpdateData(TRUE)) return; /* no need to check: input directory, file need to check (in this order): valid output directory valid output file prefix at least one type of run is selected either number of runs specified (> 0), or 'run all' check box marked (for all 3 run types) end depth is <= appropriate planes depth distribution res >= 1 the rest is auto checked by UpdateData(TRUE) */ if ( field_directory_work_str.IsEmpty() ) { //make sure there is an output directory is_dataright=false; m_error = "You must select a valid output directory."; } else if ( (check_bs_input.GetCheck()) && (is_bs_input_valid==false) ) { is_dataright=false; m_error = "If BS input checked, must provide valid BS file."; } else if ( (check_ss_input.GetCheck()) && (is_ss_input_valid==false) ) { is_dataright=false; m_error = "If SS input checked, must provide valid SS file."; } else if ( (check_cl_input.GetCheck()) && (is_cl_input_valid==false) ) { is_dataright=false; m_error = "If CL input checked, must provide valid CL file."; } else if ( (check_ma_input.GetCheck()) && (is_ma_input_valid==false) ) { is_dataright=false; m_error = "If MA input checked, must provide valid MA file."; } else if ( field_name_output_str.IsEmpty() ) { //make sure there is a output file prefix is_dataright=false; m_error = "You must select a valid output file prefix."; } if( is_dataright ) { // Invalidate optinal inputs for whatever checks are disabled if ( !check_bs_input.GetCheck() ) { is_bs_input_valid = false; } if ( !check_ss_input.GetCheck() ) { is_ss_input_valid = false; } if ( !check_cl_input.GetCheck() ) { is_cl_input_valid = false; } if ( !check_ma_input.GetCheck() ) { is_ma_input_valid = false; } //delete '[' and everything after it input_file_name_cut = input_file_name; if (left_bracket_indx > 0) input_file_name_cut.Delete(left_bracket_indx, input_file_name.GetLength() ); DisableCommonInputs(); pbar_simulation_progress.SetPos(0); //create a tortuosity work thread, which will also disable the restof the GUI, except for STOP button AfxBeginThread(MedialSetup, this); } else AfxMessageBox(m_error); } void MedialDialog::OnCancel() { if(!DestroyWindow()) AfxMessageBox("Could not destroy this window!!!"); delete this; } BOOL MedialDialog::OnInitDialog() { program_generated = true; CDialog::OnInitDialog(); InitCommonInputFields(); program_generated = false; // Saving check_save_bs_cube.SetCheck(true); check_save_ss_cube.SetCheck(true); check_save_cl_cube.SetCheck(true); check_save_bs_cube_rgb.SetCheck(false); check_save_ss_cube_rgb.SetCheck(false); check_save_cl_cube_rgb.SetCheck(false); check_mark_cl_max.SetCheck(false); check_save_sp_cube.SetCheck(true); check_save_medial_axis_1bit.SetCheck(true); check_save_medial_axis_detailed.SetCheck(true); check_save_medial_axis_graph.SetCheck(true); check_network_graph_txt.SetCheck(true); // Options check_bounds_are_fiber.SetCheck(false); check_run_on_fiber.SetCheck(false); check_log_deleted_paths.SetCheck(false); check_log_forced_links.SetCheck(false); check_enable_caching_from_disc.SetCheck(false); field_cache_ram_limit_cntrl.EnableWindow(false); button_bs_cube.EnableWindow(false); button_ss_cube.EnableWindow(false); button_cl_cube.EnableWindow(false); button_ma_cube.EnableWindow(false); field_bs_file_name_cntrl.EnableWindow(false); field_ss_file_name_cntrl.EnableWindow(false); field_cl_file_name_cntrl.EnableWindow(false); field_ma_file_name_cntrl.EnableWindow(false); combo_rp_method.AddString("Furthest Point From Start"); combo_rp_method.AddString("Maximum BS Value"); combo_rp_method.SetCurSel(0); field_node_dens_um_cube_cntrl.SetWindowText("35.0"); req_mem_byte_multiplier = (1.20f)*(sizeof(ss_t) + sizeof(bs_t) + sizeof(cl_t) + 0.125f*3); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void MedialDialog::OnBnClickedButtonBsCubeInput() { is_bs_input_valid = SimpleFileBrowser( input_bs_cube_file_name ); if ( is_bs_input_valid == true ) { field_bs_file_name_cntrl.SetWindowTextA( input_bs_cube_file_name ); } } void MedialDialog::OnBnClickedButtonSsCubeInput() { is_ss_input_valid = SimpleFileBrowser( input_ss_cube_file_name ); if ( is_ss_input_valid == true ) { field_ss_file_name_cntrl.SetWindowTextA( input_ss_cube_file_name ); } } void MedialDialog::OnBnClickedButtonClCubeInput() { is_cl_input_valid = SimpleFileBrowser( input_cl_cube_file_name ); if ( is_cl_input_valid == true ) { field_cl_file_name_cntrl.SetWindowTextA( input_cl_cube_file_name ); } } void MedialDialog::OnBnClickedButtonFinalMaInput() { is_ma_input_valid = SimpleFileBrowser( input_ma_cube_file_name ); if ( is_ma_input_valid == true ) { field_ma_file_name_cntrl.SetWindowTextA( input_ma_cube_file_name ); } } void MedialDialog::OnBnClickedCheckBsInput() { if ( check_bs_input.GetCheck() ) { field_bs_file_name_cntrl.EnableWindow(true); button_bs_cube.EnableWindow(true); } else { field_bs_file_name_cntrl.EnableWindow(false); button_bs_cube.EnableWindow(false); is_bs_input_valid = false; } } void MedialDialog::OnBnClickedCheckSsInput() { if ( check_ss_input.GetCheck() ) { field_ss_file_name_cntrl.EnableWindow(true); button_ss_cube.EnableWindow(true); } else { field_ss_file_name_cntrl.EnableWindow(false); button_ss_cube.EnableWindow(false); is_ss_input_valid = false; } } void MedialDialog::OnBnClickedCheckClInput() { if ( check_cl_input.GetCheck() ) { field_cl_file_name_cntrl.EnableWindow(true); button_cl_cube.EnableWindow(true); } else { field_cl_file_name_cntrl.EnableWindow(false); button_cl_cube.EnableWindow(false); is_cl_input_valid = false; } } void MedialDialog::OnBnClickedCheckSaveMaInput() { if ( check_ma_input.GetCheck() ) { field_ma_file_name_cntrl.EnableWindow(true); button_ma_cube.EnableWindow(true); // Do not need CL or SS input cubes if MA enabled check_cl_input.SetCheck(false); check_cl_input.EnableWindow(false); field_cl_file_name_cntrl.EnableWindow(false); button_cl_cube.EnableWindow(false); is_cl_input_valid = false; check_ss_input.SetCheck(false); check_ss_input.EnableWindow(false); field_ss_file_name_cntrl.EnableWindow(false); button_ss_cube.EnableWindow(false); is_ss_input_valid = false; } else { field_ma_file_name_cntrl.EnableWindow(false); button_ma_cube.EnableWindow(false); is_ma_input_valid = false; // Re-enable SS and CL inputs check_cl_input.EnableWindow(true); check_ss_input.EnableWindow(true); } } void MedialDialog::OnBnClickedCheckEnableCaching() { if ( check_enable_caching_from_disc.GetCheck() ) { field_cache_ram_limit_cntrl.EnableWindow(true); } else { field_cache_ram_limit_cntrl.EnableWindow(false); } } // ======================================================================================== // ======================================================================================== // ======================================================================================== // ---------------------------------------------------------------------------------------- // The following are messages that are dealt in similar matter for all PoroMedia dialogs // ---------------------------------------------------------------------------------------- // ======================================================================================== // ======================================================================================== // ======================================================================================== //when the stop button is pushed, initialize stop procedure void MedialDialog::OnBnClickedStop() { StopRequest(); } //when input directory button is pushed void MedialDialog::OnBnClickedButtonInputDirectory() { //grab file, do inits common to all poromedia dialogs ClickedInputDirectory(); } //when work directory button is pushed void MedialDialog::OnBnClickedButtonWorkDirectory() { ClickedWorkDirectory(); } //threshold stuff void MedialDialog::OnCbnSelchangeComboThresholdingMethod() { ChangeComboThresholding(); } void MedialDialog::OnEnChangeEditManualThreshold() { EditManualThreshold(); } //the rest deals with start/width/end field autocalcs void MedialDialog::OnEnChangeEditStartSlice() { EditStartSlice(); } void MedialDialog::OnEnChangeEditWidthSlices() { EditWidthSlices(); } void MedialDialog::OnEnChangeEditEndSlice() { EditEndSlice(); } void MedialDialog::OnEnChangeEditStartx() { EditStartx(); } void MedialDialog::OnEnChangeEditWidthx() { EditWidthx(); } void MedialDialog::OnEnChangeEditEndx() { EditEndx(); } void MedialDialog::OnEnChangeEditStarty() { EditStarty(); } void MedialDialog::OnEnChangeEditWidthy() { EditWidthy(); } void MedialDialog::OnEnChangeEditEndy() { EditEndy(); }