// TortuosityDialog.cpp : implementation file // #include "stdafx.h" #include "TortuosityDialog.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // TortuosityDialog dialog TortuosityDialog::TortuosityDialog(CWnd* pParent /*=NULL*/) : CDialog(TortuosityDialog::IDD, pParent) { //{{AFX_DATA_INIT(TortuosityDialog) //unique field_run_num_XY_int = 1000; field_run_num_YZ_int = 1000; field_run_num_XZ_int = 1000; field_end_depth_XY_int = 0; field_end_depth_YZ_int = 0; field_end_depth_XZ_int = 0; field_num_save_tracers_XY_int = 0; field_num_save_tracers_YZ_int = 0; field_num_save_tracers_XZ_int = 0; field_output_dist_res_int = 32; flag_XY_run_all = false; flag_YZ_run_all = false; flag_XZ_run_all = false; //}}AFX_DATA_INIT // PoroMediaDialogShare(); } void TortuosityDialog::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); /* SHARED (can copy and paste between dialogs) */ BindCommonInputFields(pDX); /* TORTUOSITY SPECIFIC SETTINGS */ DDX_Control(pDX, IDC_CHECK_XY_RUN, check_run_XY_cntrl); DDX_Control(pDX, IDC_CHECK_YZ_RUN, check_run_YZ_cntrl); DDX_Control(pDX, IDC_CHECK_XZ_RUN, check_run_XZ_cntrl); DDX_Control(pDX, IDC_EDIT_XY_RUN_NUM, field_run_num_XY_cntrl); DDX_Text(pDX, IDC_EDIT_XY_RUN_NUM, field_run_num_XY_int); DDX_Control(pDX, IDC_EDIT_YZ_RUN_NUM, field_run_num_YZ_cntrl); DDX_Text(pDX, IDC_EDIT_YZ_RUN_NUM, field_run_num_YZ_int); DDX_Control(pDX, IDC_EDIT_XZ_RUN_NUM, field_run_num_XZ_cntrl); DDX_Text(pDX, IDC_EDIT_XZ_RUN_NUM, field_run_num_XZ_int); DDX_Control(pDX, IDC_CHECK_XY_RUNALL, check_runall_XY); DDX_Control(pDX, IDC_CHECK_YZ_RUNALL, check_runall_YZ); DDX_Control(pDX, IDC_CHECK_XZ_RUNALL, check_runall_XZ); DDX_Control(pDX, IDC_EDIT_XY_END_DEPTH, field_end_depth_XY_cntrl); DDX_Text(pDX, IDC_EDIT_XY_END_DEPTH, field_end_depth_XY_int); DDX_Control(pDX, IDC_EDIT_YZ_END_DEPTH, field_end_depth_YZ_cntrl); DDX_Text(pDX, IDC_EDIT_YZ_END_DEPTH, field_end_depth_YZ_int); DDX_Control(pDX, IDC_EDIT_XZ_END_DEPTH, field_end_depth_XZ_cntrl); DDX_Text(pDX, IDC_EDIT_XZ_END_DEPTH, field_end_depth_XZ_int); DDX_Control(pDX, IDC_EDIT_XY_NUM_TRACERS_TO_SAVE, field_num_save_tracers_XY_cntrl); DDX_Text(pDX, IDC_EDIT_XY_NUM_TRACERS_TO_SAVE, field_num_save_tracers_XY_int); DDX_Control(pDX, IDC_EDIT_YZ_NUM_TRACERS_TO_SAVE, field_num_save_tracers_YZ_cntrl); DDX_Text(pDX, IDC_EDIT_YZ_NUM_TRACERS_TO_SAVE, field_num_save_tracers_YZ_int); DDX_Control(pDX, IDC_EDIT_XZ_NUM_TRACERS_TO_SAVE, field_num_save_tracers_XZ_cntrl); DDX_Text(pDX, IDC_EDIT_XZ_NUM_TRACERS_TO_SAVE, field_num_save_tracers_XZ_int); //advanced options DDX_Control(pDX, IDC_CHECK_ENABLE_ADD_OPTIONS, check_enable_add_options); DDX_Control(pDX, IDC_EDIT_DISTRES, field_output_dist_res_cntrl); DDX_Text(pDX, IDC_EDIT_DISTRES, field_output_dist_res_int); } BEGIN_MESSAGE_MAP(TortuosityDialog, 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) //tort dialog specific messages ON_BN_CLICKED(IDC_CHECK_XY_RUNALL, OnBnClickedCheckXyRunall) ON_BN_CLICKED(IDC_CHECK_YZ_RUNALL, OnBnClickedCheckYzRunall) ON_BN_CLICKED(IDC_CHECK_XZ_RUNALL, OnBnClickedCheckXzRunall) ON_BN_CLICKED(IDC_CHECK_ENABLE_ADD_OPTIONS, OnBnClickedCheckEnableAddOptions) END_MESSAGE_MAP() /////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // TortuosityDialog message handlers void TortuosityDialog::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."; } else if ( (!check_run_XY_cntrl.GetCheck()) && (!check_run_XZ_cntrl.GetCheck()) && (!check_run_YZ_cntrl.GetCheck()) ){ is_dataright=false; m_error = "You should select at least one type of analysis to perform."; } else if ( (!check_runall_XY.GetCheck()) && (field_run_num_XY_int < 1) && (check_run_XY_cntrl.GetCheck()) ){//run number check is_dataright=false; m_error = "You should either hit ALL for XY plane tracer run number, or have at least 1 run specified."; } else if ( (!check_runall_YZ.GetCheck()) && (field_run_num_YZ_int < 1) && (check_run_YZ_cntrl.GetCheck())){ is_dataright=false; m_error = "You should either hit ALL for YZ plane tracer run number, or have at least 1 run specified."; } else if ( (!check_runall_XZ.GetCheck()) && (field_run_num_XZ_int < 1) && (check_run_XZ_cntrl.GetCheck())){ is_dataright=false; m_error = "You should either hit ALL for XZ plane tracer run number, or have at least 1 run specified."; } else if ( ((field_end_depth_XY_int > max_XY_depth) || (field_end_depth_XY_int < 1)) && (check_run_XY_cntrl.GetCheck()) ){//depth check is_dataright=false; m_error = "The max depth of XY plane run does not fit within user specified bounds."; } else if ( ((field_end_depth_YZ_int > max_YZ_depth) || (field_end_depth_YZ_int < 1)) && (check_run_YZ_cntrl.GetCheck()) ){ is_dataright=false; m_error = "The max depth of YZ plane run does not fit within user specified bounds."; } else if ( ((field_end_depth_XZ_int > max_XZ_depth) || (field_end_depth_XZ_int < 1)) && (check_run_XZ_cntrl.GetCheck()) ){ is_dataright=false; m_error = "The max depth of XZ plane run does not fit within user specified bounds."; } else if ( field_output_dist_res_int < 1){// distribution res check is_dataright=false; m_error = "The output distribution resolution should be greater than 0."; } 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 tortuosity work thread, which will also disable the restof the GUI, except for STOP button AfxBeginThread(TortSetup, this); } else AfxMessageBox(m_error); } void TortuosityDialog::OnCancel() { if(!DestroyWindow()) AfxMessageBox("Could not destroy this window!!!"); delete this; } BOOL TortuosityDialog::OnInitDialog() { program_generated = true; CDialog::OnInitDialog(); InitCommonInputFields(); program_generated = false; return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void TortuosityDialog::OnBnClickedCheckEnableAddOptions() { flag_add_options = !flag_add_options; //enable or disable all the advanced windows check_runall_XY.EnableWindow(flag_add_options); field_end_depth_XY_cntrl.EnableWindow(flag_add_options); field_num_save_tracers_XY_cntrl.EnableWindow(flag_add_options); check_runall_YZ.EnableWindow(flag_add_options); field_end_depth_YZ_cntrl.EnableWindow(flag_add_options); field_num_save_tracers_YZ_cntrl.EnableWindow(flag_add_options); check_runall_XZ.EnableWindow(flag_add_options); field_end_depth_XZ_cntrl.EnableWindow(flag_add_options); field_num_save_tracers_XZ_cntrl.EnableWindow(flag_add_options); program_generated = false; } //following three deal with enabling/disabling run number field, when user checks/unchecks 'run_all' void TortuosityDialog::OnBnClickedCheckXyRunall() { flag_XY_run_all = !flag_XY_run_all; //disable/enable number of runs field if(flag_XY_run_all){ field_run_num_XY_cntrl.EnableWindow(false); SetIntValField(&field_run_num_XY_cntrl, 0); } else{ field_run_num_XY_cntrl.EnableWindow(true); SetIntValField(&field_run_num_XY_cntrl, 1000); } } void TortuosityDialog::OnBnClickedCheckYzRunall() { flag_YZ_run_all = !flag_YZ_run_all; //disable/enable number of runs field if(flag_YZ_run_all){ field_run_num_YZ_cntrl.EnableWindow(false); SetIntValField(&field_run_num_YZ_cntrl, 0); } else{ field_run_num_YZ_cntrl.EnableWindow(true); SetIntValField(&field_run_num_YZ_cntrl, 1000); } } void TortuosityDialog::OnBnClickedCheckXzRunall() { flag_XZ_run_all = !flag_XZ_run_all; //disable/enable number of runs field if(flag_XZ_run_all){ field_run_num_XZ_cntrl.EnableWindow(false); SetIntValField(&field_run_num_XZ_cntrl, 0); } else{ field_run_num_XZ_cntrl.EnableWindow(true); SetIntValField(&field_run_num_XZ_cntrl, 1000); } } /* The following are messages that are dealt in similar matter for all PoroMedia dialogs */ //when the stop button is pushed, initialize stop procedure void TortuosityDialog::OnBnClickedStop() { StopRequest(); } //when input directory button is pushed void TortuosityDialog::OnBnClickedButtonInputDirectory() { //grab file, do inits common to all poromedia dialogs ClickedInputDirectory(); } //when work directory button is pushed void TortuosityDialog::OnBnClickedButtonWorkDirectory() { ClickedWorkDirectory(); } //threshold stuff void TortuosityDialog::OnCbnSelchangeComboThresholdingMethod() { ChangeComboThresholding(); } void TortuosityDialog::OnEnChangeEditManualThreshold() { EditManualThreshold(); } //the rest deals with start/width/end field autocalcs void TortuosityDialog::OnEnChangeEditStartSlice() { EditStartSlice(); } void TortuosityDialog::OnEnChangeEditWidthSlices() { EditWidthSlices(); //set new depth in depth field SetIntValField(&field_end_depth_XY_cntrl, max_XY_depth); } void TortuosityDialog::OnEnChangeEditEndSlice() { EditEndSlice(); //auto calc the XY plane end depth based on the new width SetIntValField(&field_end_depth_XY_cntrl, max_XY_depth); } void TortuosityDialog::OnEnChangeEditStartx() { EditStartx(); } void TortuosityDialog::OnEnChangeEditWidthx() { EditWidthx(); //autocalc max depth SetIntValField(&field_end_depth_YZ_cntrl, max_YZ_depth); } void TortuosityDialog::OnEnChangeEditEndx() { EditEndx(); //auto calc the YZ plane end depth based on the new width SetIntValField(&field_end_depth_YZ_cntrl, max_YZ_depth); } void TortuosityDialog::OnEnChangeEditStarty() { EditStarty(); } void TortuosityDialog::OnEnChangeEditWidthy() { EditWidthy(); //auto calc max XZ depth SetIntValField(&field_end_depth_XZ_cntrl, max_XZ_depth); } void TortuosityDialog::OnEnChangeEditEndy() { EditEndy(); //auto calc the XZ plane end depth based on the new width SetIntValField(&field_end_depth_XZ_cntrl, max_XZ_depth); }