// source\ExtrasDialog.cpp : implementation file // #include "stdafx.h" #include "ExtrasDialog.h" // ExtrasDialog dialog IMPLEMENT_DYNAMIC(ExtrasDialog, CDialog) ExtrasDialog::ExtrasDialog(CWnd* pParent /*=NULL*/) : CDialog(ExtrasDialog::IDD, pParent) , field_boundary_erode_short(0) , field_resize_to_wz_short(1) , field_resize_to_wy_short(1) , field_resize_to_wx_short(1) , field_resize_to_mult_short(0) , field_downscale_ratio_short(0) , field_edge_solid_val_int(0) , field_edge_background_int(0) { field_crop_z_start_int = 0; field_crop_z_width_int = 0; field_crop_z_end_int = 0; field_crop_y_start_int = 0; field_crop_y_width_int = 0; field_crop_y_end_int = 0; field_crop_x_start_int = 0; field_crop_x_width_int = 0; field_crop_x_end_int = 0; /*bits for dialog section disabling: (for this one, we have NO filters, binarize, or file_save BINARIZE_CONTROLS 1 FILTER_CONTROLS 2 FILESAVE_CONTROLS 4 PROGRESS_CONTROLS 8 MEMORY_CONTROLS 16*/ dialog_inactive_flags = BINARIZE_CONTROLS | FILTER_CONTROLS | FILESAVE_CONTROLS; save_intermediate_results = false; } ExtrasDialog::~ExtrasDialog() { } void ExtrasDialog::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); /* SHARED (for Yves :can copy and paste between dialogs) */ BindCommonInputFields(pDX); //////////////////////////////////////// DDX_Control(pDX, IDC_CHECK_HISTOGRAM, check_histogram); DDX_Control(pDX, IDC_CHECK_RUN_RESIZE_TO, check_run_resize_to); DDX_Control(pDX, IDC_CHECK_DEBUG, check_debug); DDX_Text(pDX, IDC_EDIT_BOUNDARY_ERODE, field_boundary_erode_short); DDV_MinMaxShort(pDX, field_boundary_erode_short, 0, 1000); DDX_Text(pDX, IDC_EDIT_RESIZE_TO_WZ, field_resize_to_wz_short); DDV_MinMaxShort(pDX, field_resize_to_wz_short, 1, 32000); DDX_Text(pDX, IDC_EDIT_RESIZE_TO_WY, field_resize_to_wy_short); DDV_MinMaxShort(pDX, field_resize_to_wy_short, 1, 32000); DDX_Text(pDX, IDC_EDIT_RESIZE_TO_WX, field_resize_to_wx_short); DDV_MinMaxShort(pDX, field_resize_to_wx_short, 1, 32000); DDX_Text(pDX, IDC_EDIT_RESIZE_TO_MULT, field_resize_to_mult_short); DDV_MinMaxShort(pDX, field_resize_to_mult_short, 0, 32); DDX_Text(pDX, IDC_EDIT_DOWNSCALE_RATIO, field_downscale_ratio_short); DDV_MinMaxShort(pDX, field_downscale_ratio_short, 0, 32); DDX_Control(pDX, IDC_CHECK_RUN_EDGE, check_run_edge); DDX_Text(pDX, IDC_EDIT_SOLID_VAL, field_edge_solid_val_int); DDV_MinMaxInt(pDX, field_edge_solid_val_int, 0, 255); DDX_Text(pDX, IDC_EDIT_BACKGRND_VAL, field_edge_background_int); DDV_MinMaxInt(pDX, field_edge_background_int, 0, 255); DDX_Control(pDX, IDC_CHECK_RUN_DRAWING, check_run_drawing); DDX_Control(pDX, IDC_CHECK_DO_NOT_READ_INPUT, check_do_not_read_input ); DDX_Text(pDX, IDC_EDIT_CROP_START_Z, field_crop_z_start_int); DDV_MinMaxInt(pDX, field_crop_z_start_int, 0, 65535); DDX_Text(pDX, IDC_EDIT_CROP_WIDTH_Z, field_crop_z_width_int); DDV_MinMaxInt(pDX, field_crop_z_width_int, 0, 65535); DDX_Text(pDX, IDC_EDIT_CROP_END_Z, field_crop_z_end_int); DDV_MinMaxInt(pDX, field_crop_z_end_int, 0, 65535); DDX_Text(pDX, IDC_EDIT_CROP_START_Y, field_crop_y_start_int); DDV_MinMaxInt(pDX, field_crop_y_start_int, 0, 65535); DDX_Text(pDX, IDC_EDIT_CROP_WIDTH_Y, field_crop_y_width_int); DDV_MinMaxInt(pDX, field_crop_y_width_int, 0, 65535); DDX_Text(pDX, IDC_EDIT_CROP_END_Y, field_crop_y_end_int); DDV_MinMaxInt(pDX, field_crop_y_end_int, 0, 65535); DDX_Text(pDX, IDC_EDIT_CROP_START_X, field_crop_x_start_int); DDV_MinMaxInt(pDX, field_crop_x_start_int, 0, 65535); DDX_Text(pDX, IDC_EDIT_CROP_WIDTH_X, field_crop_x_width_int); DDV_MinMaxInt(pDX, field_crop_x_width_int, 0, 65535); DDX_Text(pDX, IDC_EDIT_CROP_END_X, field_crop_x_end_int); DDV_MinMaxInt(pDX, field_crop_x_end_int, 0, 65535); DDX_Control(pDX, IDC_CHECK_STACK_CROP, check_crop_enable); } BEGIN_MESSAGE_MAP(ExtrasDialog, CDialog) //messages similar to all dialogs (for Yves :copy and paste) 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) ////////////////////////////////////// END_MESSAGE_MAP() // ExtrasDialog message handlers void ExtrasDialog::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 ( 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."; } // For now force end to be addition of start width in crop field field_crop_z_end_int = field_crop_z_start_int + field_crop_z_width_int - 1; field_crop_y_end_int = field_crop_y_start_int + field_crop_y_width_int - 1; field_crop_x_end_int = field_crop_x_start_int + field_crop_x_width_int - 1; 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() ); DisableCommonInputs(); pbar_simulation_progress.SetPos(0); //create a sphere work thread, which will also disable the restof the GUI, except for STOP button AfxBeginThread(ExtrasSetup, this); } else AfxMessageBox(m_error); } void ExtrasDialog::OnCancel() { if(!DestroyWindow()) AfxMessageBox("Could not destroy this window!!!"); delete this; } BOOL ExtrasDialog::OnInitDialog() { program_generated = true; CDialog::OnInitDialog(); InitCommonInputFields(); program_generated = false; //init dialog specific stuff //check_save_sphere_map.SetCheck(true); //check_use_dt.SetCheck(false); //check_calc_even_diam.SetCheck(true); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return 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 ExtrasDialog::OnBnClickedStop() { StopRequest(); } //when input directory button is pushed void ExtrasDialog::OnBnClickedButtonInputDirectory() { //grab file, do inits common to all poromedia dialogs ClickedInputDirectory(); } //when work directory button is pushed void ExtrasDialog::OnBnClickedButtonWorkDirectory() { ClickedWorkDirectory(); } //threshold stuff void ExtrasDialog::OnCbnSelchangeComboThresholdingMethod() { ChangeComboThresholding(); } void ExtrasDialog::OnEnChangeEditManualThreshold() { EditManualThreshold(); } //the rest deals with start/width/end field autocalcs void ExtrasDialog::OnEnChangeEditStartSlice() { EditStartSlice(); } void ExtrasDialog::OnEnChangeEditWidthSlices() { EditWidthSlices(); } void ExtrasDialog::OnEnChangeEditEndSlice() { EditEndSlice(); } void ExtrasDialog::OnEnChangeEditStartx() { EditStartx(); } void ExtrasDialog::OnEnChangeEditWidthx() { EditWidthx(); } void ExtrasDialog::OnEnChangeEditEndx() { EditEndx(); } void ExtrasDialog::OnEnChangeEditStarty() { EditStarty(); } void ExtrasDialog::OnEnChangeEditWidthy() { EditWidthy(); } void ExtrasDialog::OnEnChangeEditEndy() { EditEndy(); }