// source\FiltersDialog.cpp : implementation file // #include "stdafx.h" #include "PoroMedia.h" #include "FiltersDialog.h" // FiltersDialog dialog IMPLEMENT_DYNAMIC(FiltersDialog, CDialog) FiltersDialog::FiltersDialog(CWnd* pParent /*=NULL*/) : CDialog(FiltersDialog::IDD, pParent) , field_rotate_XY_YZ_times_short(0) , field_rotate_XY_ZX_times_short(0) , field_filter_convolve_float(0) , field_filter_aniso_radius_float(0) { //contrast field_contrast_percentage_short = filter_contrast_percentage; //convolve field_filter_convolve_float = filter_convolve_radius; //aniso defaults field_filter_aniso_K_short = filter_aniso_K; if (filter_aniso_K_var) field_filter_aniso_K_short = filter_aniso_K_defVon; else field_filter_aniso_K_short = filter_aniso_K_defVoff;; field_filter_aniso_TAU_float = filter_aniso_TAU; field_filter_aniso_iterations_short = filter_aniso_iterations; field_filter_aniso_midpoint_short = filter_aniso_midpoint; field_filter_aniso_radius_float = filter_aniso_radius; //vox rem defaults field_voxrem_pore_um_vol_double = filter_voxrem_pore_um_vol; field_voxrem_fiber_um_vol_double = filter_voxrem_fiber_um_vol; //close field_filter_close_iterations_short = filter_close_iterations; field_filter_close_neighs_short = filter_close_neighs; } FiltersDialog::~FiltersDialog() { } void FiltersDialog::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); /* SHARED (can copy and paste between dialogs) */ BindCommonInputFields(pDX); DDX_Control(pDX, IDC_CHECK_SKIP_BINARIZE, check_skip_binarize); //convolve DDX_Control(pDX, IDC_COMBO_CONVOLVE_TYPE, combo_convolve_type); DDX_Control(pDX, IDC_EDIT_CONVOLVE_RADIUS, field_filter_convolve_cntrl); DDX_Text(pDX, IDC_EDIT_CONVOLVE_RADIUS, field_filter_convolve_float); DDV_MinMaxFloat(pDX, field_filter_convolve_float, 1, 30); DDX_Control(pDX, IDC_CHECK_CONVOLVE_SAVEBOUNDS, check_filter_convolve_savebounds); //contrast DDX_Control(pDX, IDC_EDIT_CONTRAST_PERCENT, field_contrast_percentage_cntrl); DDX_Text(pDX, IDC_EDIT_CONTRAST_PERCENT, field_contrast_percentage_short); DDV_MinMaxShort(pDX, field_contrast_percentage_short, 1, 40); //close DDX_Control(pDX, IDC_EDIT_CLOSE_ITERATIONS, field_filter_close_iterations_cntrl); DDX_Text(pDX, IDC_EDIT_CLOSE_ITERATIONS, field_filter_close_iterations_short); DDV_MinMaxShort(pDX, field_filter_close_iterations_short, 1, 100); DDX_Control(pDX, IDC_EDIT_CLOSE_NEIGHS, field_filter_close_neighs_cntrl); DDX_Text(pDX, IDC_EDIT_CLOSE_NEIGHS, field_filter_close_neighs_short); DDV_MinMaxShort(pDX, field_filter_close_neighs_short, 1, 25); DDX_Control(pDX, IDC_CHECK_CLOSE_EXTENDED, check_filter_close_extended); //anisotropic DDX_Control(pDX, IDC_EDIT_ANISO_K, field_filter_aniso_K_cntrl); DDX_Text(pDX, IDC_EDIT_ANISO_K, field_filter_aniso_K_short); DDV_MinMaxShort(pDX, field_filter_aniso_K_short, 1, 512); DDX_Control(pDX, IDC_EDIT_ANISO_TAU, field_filter_aniso_TAU_cntrl); DDX_Text(pDX, IDC_EDIT_ANISO_TAU, field_filter_aniso_TAU_float); DDV_MinMaxFloat(pDX, field_filter_aniso_TAU_float, 0.05f, 1.0f); DDX_Control(pDX, IDC_EDIT_ANISO_ITERATIONS, field_filter_aniso_iterations_cntrl); DDX_Text(pDX, IDC_EDIT_ANISO_ITERATIONS, field_filter_aniso_iterations_short); DDV_MinMaxShort(pDX, field_filter_aniso_iterations_short, 1, 200); DDX_Control(pDX, IDC_EDIT_ANISO_MIDPOINT, field_filter_aniso_midpoint_cntrl); DDX_Text(pDX, IDC_EDIT_ANISO_MIDPOINT, field_filter_aniso_midpoint_short); DDV_MinMaxShort(pDX, field_filter_aniso_midpoint_short, 0, 255); DDX_Control(pDX, IDC_CHECK_ANISO_FAST, check_filter_aniso_fast); DDX_Control(pDX, IDC_CHECK_ANISO_CON_BOOST, check_filter_aniso_conboost); DDX_Control(pDX, IDC_EDIT_ANISO_MIDPT_TXT, field_aniso_midpt_txt); DDX_Control(pDX, IDC_CHECK_ANISO_KVAR, check_filter_aniso_var); DDX_Control(pDX, IDC_COMBO_ANISO_DIFFCOEF, combo_filter_aniso_diffcoef); DDX_Control(pDX, IDC_CHECK_ANISO_SAVEBOUNDS, check_filter_aniso_savebounds); DDX_Control(pDX, IDC_EDIT_ANISO_RADIUS, field_filter_aniso_radius_cntrl); DDX_Text(pDX, IDC_EDIT_ANISO_RADIUS, field_filter_aniso_radius_float); //voxel remover DDX_Control(pDX, IDC_CHECK_VOXREM_RUN_PORE, check_voxrem_run_pores); DDX_Control(pDX, IDC_EDIT_VOXREM_VOL_vox_PORES, field_voxrem_pore_vox_vol_cntrl); DDX_Text(pDX, IDC_EDIT_VOXREM_VOL_vox_PORES, field_voxrem_pore_vox_vol_long); DDX_Control(pDX, IDC_EDIT_VOXREM_VOL_um_PORES, field_voxrem_pore_um_vol_cntrl); DDX_Text(pDX, IDC_EDIT_VOXREM_VOL_um_PORES, field_voxrem_pore_um_vol_double); DDX_Control(pDX, IDC_CHECK_VOXREM_RUN_FIBER, check_voxrem_run_fibers); DDX_Control(pDX, IDC_EDIT_VOXREM_VOL_vox_FIBERS, field_voxrem_fiber_vox_vol_cntrl); DDX_Text(pDX, IDC_EDIT_VOXREM_VOL_vox_FIBERS, field_voxrem_fiber_vox_vol_long); DDX_Control(pDX, IDC_EDIT_VOXREM_VOL_um_FIBERS, field_voxrem_fiber_um_vol_cntrl); DDX_Text(pDX, IDC_EDIT_VOXREM_VOL_um_FIBERS, field_voxrem_fiber_um_vol_double); //output options DDX_Control(pDX, IDC_EDIT_ROTATE_XY_YZ, field_rotate_XY_YZ_times_cntrl); DDX_Text(pDX, IDC_EDIT_ROTATE_XY_YZ, field_rotate_XY_YZ_times_short); DDV_MinMaxShort(pDX, field_rotate_XY_YZ_times_short, 0, 3); DDX_Control(pDX, IDC_EDIT_ROTATE_XY_ZX, field_rotate_XY_ZX_times_cntrl); DDX_Text(pDX, IDC_EDIT_ROTATE_XY_ZX, field_rotate_XY_ZX_times_short); DDV_MinMaxShort(pDX, field_rotate_XY_ZX_times_short, 0, 3); //saving options DDX_Control(pDX, IDC_CHECK_SAVE_RAW_FILES, check_save_raw_files); DDX_Control(pDX, IDC_CHECK_SAVE_BIN_STACK, check_save_bin_stack); DDX_Control(pDX, IDC_CHECK_SAVE_CBIN_STACK, check_save_cbin_stack); DDX_Control(pDX, IDC_CHECK_SAVE_BIN_FILES, check_save_bin_files); DDX_Control(pDX, IDC_CHECK_SAVE_CBIN_FILES, check_save_cbin_files); DDX_Control(pDX, IDC_CHECK_SAVE_INTERMEDIATE, check_save_intermediate_results); } BEGIN_MESSAGE_MAP(FiltersDialog, 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) //unique messages ON_EN_CHANGE(IDC_EDIT_PIXEL_SIZE, OnEnChangeEditPixelSize) ON_EN_CHANGE(IDC_EDIT_VOXREM_VOL_vox_PORES, OnEnChangeEditVoxremVolvoxPores) ON_EN_CHANGE(IDC_EDIT_VOXREM_VOL_um_PORES, OnEnChangeEditVoxremVolumPores) ON_EN_CHANGE(IDC_EDIT_VOXREM_VOL_vox_FIBERS, OnEnChangeEditVoxremVolvoxFibers) ON_EN_CHANGE(IDC_EDIT_VOXREM_VOL_um_FIBERS, OnEnChangeEditVoxremVolumFibers) ON_BN_CLICKED(IDC_CHECK_VOXREM_ENABLE, OnBnClickedCheckVoxremEnable) ON_BN_CLICKED(IDC_CHECK_ANISO_ENABLE, OnBnClickedCheckAnisoEnable) ON_EN_CHANGE(IDC_EDIT_ROTATE_XY_YZ, OnEnChangeEditRotateXyYz) ON_EN_CHANGE(IDC_EDIT_ROTATE_XY_ZX, OnEnChangeEditRotateXyZx) ON_BN_CLICKED(IDC_CHECK_CONTRAST_ENABLE, OnBnClickedCheckContrastEnable) ON_BN_CLICKED(IDC_CHECK_CONVOLVE_ENABLE, OnBnClickedCheckConvolveEnable) ON_BN_CLICKED(IDC_CHECK_CLOSE_ENABLE, OnBnClickedCheckCloseEnable) ON_BN_CLICKED(IDC_CHECK_CLOSE_EXTENDED, OnBnClickedCheckCloseExtended) ON_BN_CLICKED(IDC_CHECK_ANISO_CON_BOOST, OnBnClickedCheckAnisoConBoost) ON_BN_CLICKED(IDC_CHECK_ANISO_KVAR, OnBnClickedCheckAnisoKVar) ON_BN_CLICKED(IDC_CHECK_SKIP_BINARIZE, OnBnClickedCheckSkipBinarize) END_MESSAGE_MAP() // FiltersDialog message handlers void FiltersDialog::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 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 ( 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) { //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() ); pbar_simulation_progress.SetPos(0); DisableCommonInputs(); //create a filters work thread, which will also disable the restof the GUI, except for STOP button AfxBeginThread(FiltersSetup, this); } else AfxMessageBox(m_error); } void FiltersDialog::OnCancel() { if(!DestroyWindow()) AfxMessageBox("Could not destroy this window!!!"); delete this; } BOOL FiltersDialog::OnInitDialog() { program_generated = true; CDialog::OnInitDialog(); InitCommonInputFields(); program_generated = false; //save intermediate results by default check_save_intermediate_results.SetCheck(1); //convolve filter list box combo_convolve_type.AddString("Median"); combo_convolve_type.AddString("Median+Aver"); combo_convolve_type.AddString("Uniform"); combo_convolve_type.AddString("Linear"); combo_convolve_type.AddString("Exponential"); combo_convolve_type.AddString("Square"); combo_convolve_type.AddString("Debug"); combo_convolve_type.SetCurSel(filter_convolve_type); //aniso filter list box 0 = 1/[1+]^2, 1 = exp^2, 2 = exp^4, 3 = exp^n combo_filter_aniso_diffcoef.AddString("1/[1+]^2"); combo_filter_aniso_diffcoef.AddString("exp^2"); combo_filter_aniso_diffcoef.AddString("exp^4"); combo_filter_aniso_diffcoef.AddString("exp^n"); combo_filter_aniso_diffcoef.SetCurSel(filter_aniso_diff_coef); //txt aniso field_aniso_midpt_txt.SetWindowText("Midpoint"); //set default check boxes check_skip_binarize.SetCheck(true); //save check_save_bin_stack.SetCheck(true); check_save_cbin_stack.SetCheck(true); check_save_raw_stack.SetCheck(true); //convolve if (filter_convolve_savebounds) check_filter_convolve_savebounds.SetCheck(true); else check_filter_convolve_savebounds.SetCheck(false); //aniso if (filter_aniso_savebounds) check_filter_aniso_savebounds.SetCheck(true); else check_filter_aniso_savebounds.SetCheck(false); if (filter_aniso_fast) check_filter_aniso_fast.SetCheck(true); else check_filter_aniso_fast.SetCheck(false); if (filter_aniso_conboost) check_filter_aniso_conboost.SetCheck(true); else check_filter_aniso_conboost.SetCheck(false); if (filter_aniso_K_var) check_filter_aniso_var.SetCheck(true); else check_filter_aniso_var.SetCheck(false); //vox rem if (filter_voxrem_removal_run_4_pore) check_voxrem_run_pores.SetCheck(true); else check_voxrem_run_pores.SetCheck(false); if (filter_voxrem_removal_run_4_fiber) check_voxrem_run_fibers.SetCheck(true); else check_voxrem_run_fibers.SetCheck(false); //close if (filter_close_extended) check_filter_close_extended.SetCheck(true); else check_filter_close_extended.SetCheck(false); updateMemoryEstimate(); //auto calc voxel numbers in vox removal OnEnChangeEditVoxremVolumPores(); OnEnChangeEditVoxremVolumFibers(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void FiltersDialog::OnEnChangeEditPixelSize() { if (!program_generated) { program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_pixel_size_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); double pix_size = GetFloatValFromField(&field_pixel_size_cntrl); //pixel size can't be negative if (pix_size <= 0) pix_size = 0; SetFloatValField(&field_pixel_size_cntrl, pix_size); //refresh voxel volume, which also refreshes um^3 program_generated = false; OnEnChangeEditVoxremVolumPores(); //for pores OnEnChangeEditVoxremVolumFibers(); //for fibers //for fibers //restore original cursor position field_pixel_size_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void FiltersDialog::OnEnChangeEditVoxremVolvoxPores() { if (!program_generated) { program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_voxrem_pore_vox_vol_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); //grab pixel size and um^3 volume double pix_size = GetFloatValFromField(&field_pixel_size_cntrl); long total_vox = GetLongValFromField(&field_voxrem_pore_vox_vol_cntrl); //calc new um3 based on input double unit_vox_vol = pix_size * pix_size * pix_size; double um3_vol = unit_vox_vol * total_vox; SetFloatValField(&field_voxrem_pore_um_vol_cntrl, um3_vol); program_generated = false; //restore original cursor position field_voxrem_pore_vox_vol_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void FiltersDialog::OnEnChangeEditVoxremVolumPores() { if (!program_generated) { program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_voxrem_pore_um_vol_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); //grab pixel size and um^3 volume double pix_size = GetFloatValFromField(&field_pixel_size_cntrl); double um3_vol = GetFloatValFromField(&field_voxrem_pore_um_vol_cntrl); if (um3_vol < 0.0) um3_vol = 0.0; double unit_vox_vol = pix_size * pix_size * pix_size; //calc unit voxel volume long total_vox_cnt = (long)(um3_vol/unit_vox_vol + .5); //calc total voxel volume and round it SetLongValField(&field_voxrem_pore_vox_vol_cntrl, total_vox_cnt); um3_vol = total_vox_cnt * unit_vox_vol; //redo um^3 volume based on rounded value SetFloatValField(&field_voxrem_pore_um_vol_cntrl, um3_vol); program_generated = false; //restore original cursor position field_voxrem_pore_um_vol_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void FiltersDialog::OnEnChangeEditVoxremVolvoxFibers() { if (!program_generated) { program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_voxrem_fiber_vox_vol_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); //grab pixel size and um^3 volume double pix_size = GetFloatValFromField(&field_pixel_size_cntrl); long total_vox = GetLongValFromField(&field_voxrem_fiber_vox_vol_cntrl); //calc new um3 based on input double unit_vox_vol = pix_size * pix_size * pix_size; double um3_vol = unit_vox_vol * total_vox; SetFloatValField(&field_voxrem_fiber_um_vol_cntrl, um3_vol); program_generated = false; //restore original cursor position field_voxrem_fiber_vox_vol_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void FiltersDialog::OnEnChangeEditVoxremVolumFibers() { if (!program_generated) { program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_voxrem_fiber_um_vol_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); //grab pixel size and um^3 volume double pix_size = GetFloatValFromField(&field_pixel_size_cntrl); double um3_vol = GetFloatValFromField(&field_voxrem_fiber_um_vol_cntrl); if (um3_vol < 0.0) um3_vol = 0.0; double unit_vox_vol = pix_size * pix_size * pix_size; //calc unit voxel volume long total_vox_cnt = (long)(um3_vol/unit_vox_vol + .5); //calc total voxel volume and round it SetLongValField(&field_voxrem_fiber_vox_vol_cntrl, total_vox_cnt); um3_vol = total_vox_cnt * unit_vox_vol; //redo um^3 volume based on rounded value SetFloatValField(&field_voxrem_fiber_um_vol_cntrl, um3_vol); program_generated = false; //restore original cursor position field_voxrem_fiber_um_vol_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void FiltersDialog::OnBnClickedCheckVoxremEnable() { // enable all voxel rem options if checked if (check_filter_voxrem_enable.GetCheck()) { check_voxrem_run_pores.EnableWindow(true); field_voxrem_pore_vox_vol_cntrl.EnableWindow(true); field_voxrem_pore_um_vol_cntrl.EnableWindow(true); check_voxrem_run_fibers.EnableWindow(true); field_voxrem_fiber_vox_vol_cntrl.EnableWindow(true); field_voxrem_fiber_um_vol_cntrl.EnableWindow(true); } else //else disable { check_voxrem_run_pores.EnableWindow(false); field_voxrem_pore_vox_vol_cntrl.EnableWindow(false); field_voxrem_pore_um_vol_cntrl.EnableWindow(false); check_voxrem_run_fibers.EnableWindow(false); field_voxrem_fiber_vox_vol_cntrl.EnableWindow(false); field_voxrem_fiber_um_vol_cntrl.EnableWindow(false); } updateMemoryEstimate(); } void FiltersDialog::OnBnClickedCheckAnisoEnable() { // enable all anisotropic filtering options if checked if (check_filter_aniso_enable.GetCheck()) { check_filter_aniso_savebounds.EnableWindow(true); field_filter_aniso_radius_cntrl.EnableWindow(true); check_filter_aniso_fast.EnableWindow(true); check_filter_aniso_conboost.EnableWindow(true); check_filter_aniso_var.EnableWindow(true); combo_filter_aniso_diffcoef.EnableWindow(true); field_filter_aniso_K_cntrl.EnableWindow(true); field_filter_aniso_TAU_cntrl.EnableWindow(true); field_filter_aniso_iterations_cntrl.EnableWindow(true); if (check_filter_aniso_conboost.GetCheck()) { field_filter_aniso_midpoint_cntrl.EnableWindow(true); field_aniso_midpt_txt.EnableWindow(true); } } else //else disable { check_filter_aniso_savebounds.EnableWindow(false); field_filter_aniso_radius_cntrl.EnableWindow(false); check_filter_aniso_fast.EnableWindow(false); check_filter_aniso_conboost.EnableWindow(false); check_filter_aniso_var.EnableWindow(false); combo_filter_aniso_diffcoef.EnableWindow(false); field_filter_aniso_K_cntrl.EnableWindow(false); field_filter_aniso_TAU_cntrl.EnableWindow(false); field_filter_aniso_iterations_cntrl.EnableWindow(false); field_aniso_midpt_txt.EnableWindow(false); field_filter_aniso_midpoint_cntrl.EnableWindow(false); } updateMemoryEstimate(); } void FiltersDialog::OnBnClickedCheckAnisoConBoost() { if (check_filter_aniso_conboost.GetCheck()) { field_aniso_midpt_txt.EnableWindow(true); field_filter_aniso_midpoint_cntrl.EnableWindow(true); } else { field_aniso_midpt_txt.EnableWindow(false); field_filter_aniso_midpoint_cntrl.EnableWindow(false); } } void FiltersDialog::OnBnClickedCheckAnisoKVar() { if (check_filter_aniso_var.GetCheck()) { SetIntValField(&field_filter_aniso_K_cntrl, filter_aniso_K_defVon); } else { SetIntValField(&field_filter_aniso_K_cntrl, filter_aniso_K_defVoff); } } void FiltersDialog::OnBnClickedCheckContrastEnable() { // enable all contrast filtering options if checked if (check_filter_contrast_enable.GetCheck()) { field_contrast_percentage_cntrl.EnableWindow(true); } else //else disable { field_contrast_percentage_cntrl.EnableWindow(false); } updateMemoryEstimate(); } void FiltersDialog::OnBnClickedCheckConvolveEnable() { // enable all median filtering options if checked if (check_filter_convolve_enable.GetCheck()) { combo_convolve_type.EnableWindow(true); check_filter_convolve_savebounds.EnableWindow(true); field_filter_convolve_cntrl.EnableWindow(true); } else //else disable { combo_convolve_type.EnableWindow(false); check_filter_convolve_savebounds.EnableWindow(false); field_filter_convolve_cntrl.EnableWindow(false); } updateMemoryEstimate(); } void FiltersDialog::OnBnClickedCheckSkipBinarize() { if (check_skip_binarize.GetCheck()) { check_image_is_inverted.EnableWindow(false); combo_threshold_method.EnableWindow(false); field_manual_threshold.EnableWindow(false); } else { check_image_is_inverted.EnableWindow(); combo_threshold_method.EnableWindow(); field_manual_threshold.EnableWindow(); } } void FiltersDialog::OnBnClickedCheckCloseEnable() { // enable all median filtering options if checked if (check_filter_close_enable.GetCheck()) { field_filter_close_iterations_cntrl.EnableWindow(true); field_filter_close_neighs_cntrl.EnableWindow(true); check_filter_close_extended.EnableWindow(true); } else //else disable { field_filter_close_iterations_cntrl.EnableWindow(false); field_filter_close_neighs_cntrl.EnableWindow(false); check_filter_close_extended.EnableWindow(false); } updateMemoryEstimate(); } void FiltersDialog::OnBnClickedCheckCloseExtended() { char num[10]; if (check_filter_close_extended.GetCheck()) { sprintf(num, "%d", filter_close_neighs_ext); field_filter_close_neighs_cntrl.SetWindowText(num); } else { sprintf(num, "%d", filter_close_neighs_non); field_filter_close_neighs_cntrl.SetWindowText(num); } } void FiltersDialog::OnEnChangeEditRotateXyYz() { if (!program_generated) { program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_rotate_XY_YZ_times_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); //grab value, and make sure it's between 0 and 3 int rotate_num = GetIntValFromField(&field_rotate_XY_YZ_times_cntrl); if (rotate_num > 3) SetIntValField(&field_rotate_XY_YZ_times_cntrl, 3); if (rotate_num < 0) SetIntValField(&field_rotate_XY_YZ_times_cntrl, 0); program_generated = false; //restore original cursor position field_rotate_XY_YZ_times_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void FiltersDialog::OnEnChangeEditRotateXyZx() { if (!program_generated) { program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_rotate_XY_ZX_times_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); //grab value, and make sure it's between 0 and 3 int rotate_num = GetIntValFromField(&field_rotate_XY_ZX_times_cntrl); if (rotate_num > 3) SetIntValField(&field_rotate_XY_ZX_times_cntrl, 3); if (rotate_num < 0) SetIntValField(&field_rotate_XY_ZX_times_cntrl, 0); program_generated = false; //restore original cursor position field_rotate_XY_ZX_times_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } ////////////////////////////////////////////////////////////////////////////////////// // // // The following are messages that are dealt in similar matter for all PoroMedia dialogs // // ////////////////////////////////////////////////////////////////////////////////////// //when the stop button is pushed, initialize stop procedure void FiltersDialog::OnBnClickedStop() { StopRequest(); } //when input directory button is pushed void FiltersDialog::OnBnClickedButtonInputDirectory() { //grab file, do inits common to all poromedia dialogs ClickedInputDirectory(); //disable/enable appropriate additional save options based on input (some overrides) switch (input_file_ext) { case INPUT_IS_BMP: { //if BMP enable all save options check_save_raw_stack.EnableWindow(true); check_save_raw_files.EnableWindow(true); check_save_bin_stack.EnableWindow(true); check_save_bin_files.EnableWindow(true); check_save_cbin_stack.EnableWindow(true); check_save_cbin_files.EnableWindow(true); check_skip_binarize.EnableWindow(true); break; } case INPUT_IS_RAW_STACK: { //if RAW STACK then disable saving as RAW STACK check_save_raw_stack.EnableWindow(false); check_save_raw_files.EnableWindow(true); check_save_bin_stack.EnableWindow(true); check_save_bin_files.EnableWindow(true); check_save_cbin_stack.EnableWindow(true); check_save_cbin_files.EnableWindow(true); check_skip_binarize.EnableWindow(true); break; } case INPUT_IS_RAW: { //if RAW FILES then disable saving as RAW FILES check_save_raw_stack.EnableWindow(true); check_save_raw_files.EnableWindow(false); check_save_bin_stack.EnableWindow(true); check_save_bin_files.EnableWindow(true); check_save_cbin_stack.EnableWindow(true); check_save_cbin_files.EnableWindow(true); check_skip_binarize.EnableWindow(true); break; } case INPUT_IS_BIN_STACK: { //if BIN STACK then disable saving as BIN FILES and RAW check_save_raw_stack.EnableWindow(false); check_save_raw_files.EnableWindow(false); check_save_bin_stack.EnableWindow(false); check_save_bin_files.EnableWindow(true); check_save_cbin_stack.EnableWindow(true); check_save_cbin_files.EnableWindow(true); check_skip_binarize.EnableWindow(false); break; } case INPUT_IS_BIN: { //if BIN FILES then disable saving as BIN FILES and RAW check_save_raw_stack.EnableWindow(false); check_save_raw_files.EnableWindow(false); check_save_bin_stack.EnableWindow(true); check_save_bin_files.EnableWindow(false); check_save_cbin_stack.EnableWindow(true); check_save_cbin_files.EnableWindow(true); check_skip_binarize.EnableWindow(false); break; } case INPUT_IS_CBIN_STACK: { //if CBIN STACK then disable saving as BIN FILES and RAW check_save_raw_stack.EnableWindow(false); check_save_raw_files.EnableWindow(false); check_save_bin_stack.EnableWindow(true); check_save_bin_files.EnableWindow(true); check_save_cbin_stack.EnableWindow(false); check_save_cbin_files.EnableWindow(true); check_skip_binarize.EnableWindow(false); break; } case INPUT_IS_CBIN: { //if CBIN FILES then disable saving as CBIN FILES and RAW check_save_raw_stack.EnableWindow(false); check_save_raw_files.EnableWindow(false); check_save_bin_stack.EnableWindow(true); check_save_bin_files.EnableWindow(true); check_save_cbin_stack.EnableWindow(true); check_save_cbin_files.EnableWindow(false); check_skip_binarize.EnableWindow(false); } default: break; } } //when work directory button is pushed void FiltersDialog::OnBnClickedButtonWorkDirectory() { ClickedWorkDirectory(); } //threshold stuff void FiltersDialog::OnCbnSelchangeComboThresholdingMethod() { ChangeComboThresholding(); } void FiltersDialog::OnEnChangeEditManualThreshold() { EditManualThreshold(); } //the rest deals with start/width/end field autocalcs void FiltersDialog::OnEnChangeEditStartSlice() { EditStartSlice(); } void FiltersDialog::OnEnChangeEditWidthSlices() { EditWidthSlices(); } void FiltersDialog::OnEnChangeEditEndSlice() { EditEndSlice(); } void FiltersDialog::OnEnChangeEditStartx() { EditStartx(); } void FiltersDialog::OnEnChangeEditWidthx() { EditWidthx(); } void FiltersDialog::OnEnChangeEditEndx() { EditEndx(); } void FiltersDialog::OnEnChangeEditStarty() { EditStarty(); } void FiltersDialog::OnEnChangeEditWidthy() { EditWidthy(); } void FiltersDialog::OnEnChangeEditEndy() { EditEndy(); } void FiltersDialog::updateMemoryEstimate() { #define CONTRAST_ESTIMATE 1.0 #define CONVOLVE_ESTIMATE 1.0 #define ANISOTROPIC_ESTIMATE 1.0 #define VOX_REMOVAL_ESTIMATE 0.125 #define CLOSE_ESTIMATE 0.125 req_mem_byte_multiplier = 0.125f; if ( check_filter_contrast_enable.GetCheck() ) { if ( req_mem_byte_multiplier < CONTRAST_ESTIMATE ) req_mem_byte_multiplier = (float)CONTRAST_ESTIMATE; } if ( check_filter_convolve_enable.GetCheck() ) { if ( req_mem_byte_multiplier < CONVOLVE_ESTIMATE ) req_mem_byte_multiplier = (float)CONVOLVE_ESTIMATE; } if ( check_filter_aniso_enable.GetCheck() ) { if ( req_mem_byte_multiplier < ANISOTROPIC_ESTIMATE ) req_mem_byte_multiplier = (float)ANISOTROPIC_ESTIMATE; } if ( check_filter_voxrem_enable.GetCheck() ) { if ( req_mem_byte_multiplier < VOX_REMOVAL_ESTIMATE ) req_mem_byte_multiplier = (float)VOX_REMOVAL_ESTIMATE; } if ( check_filter_close_enable.GetCheck() ) { if ( req_mem_byte_multiplier < CLOSE_ESTIMATE ) req_mem_byte_multiplier = (float)CLOSE_ESTIMATE; } // Force window refresh OnEnChangeEditWidthx(); }