// source\PorositySSADialog.cpp : implementation file // #include "stdafx.h" #include "PorositySSADialog.h" // PorositySSADialog dialog IMPLEMENT_DYNAMIC(PorositySSADialog, CDialog) PorositySSADialog::PorositySSADialog(CWnd* pParent /*=NULL*/) : CDialog(PorositySSADialog::IDD, pParent) , field_buckets_short(30) , field_bucket_size_mult_int(1) { } PorositySSADialog::~PorositySSADialog() { } void PorositySSADialog::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); /* SHARED (can copy and paste between dialogs) */ BindCommonInputFields(pDX); /* POROSITY SPECIFIC */ DDX_Control(pDX, IDC_CHECK_RUN_3D_STRUCT, check_run_3D_struct); DDX_Control(pDX, IDC_EDIT_BUCKETS, field_buckets_cntrl); DDX_Text(pDX, IDC_EDIT_BUCKETS, field_buckets_short); DDV_MinMaxShort(pDX, field_buckets_short, 1, 1000); DDX_Control(pDX, IDC_CHECK_BUCKET_SIZE_MULT_OF_PIXEL, check_bucket_match_pixel_size); DDX_Control(pDX, IDC_EDIT_BUCKET_PIXEL_MULT, field_bucket_size_mult_cntrl); DDX_Text(pDX, IDC_EDIT_BUCKET_PIXEL_MULT, field_bucket_size_mult_int); } BEGIN_MESSAGE_MAP(PorositySSADialog, 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_CHECK_BUCKET_SIZE_MULT_OF_PIXEL, OnBnClickedCheckBucketMatchPixelSize) END_MESSAGE_MAP() // PorositySSADialog message handlers void PorositySSADialog::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 pixel size > 0 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 ( field_pixel_size_float <= 0 ) { //make sure pixel size is greater than 0 is_dataright=false; m_error = "You must select a pixel size 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() ); pbar_simulation_progress.SetPos(0); DisableCommonInputs(); //create a porositySSA work thread, which will also disable the restof the GUI, except for STOP button AfxBeginThread(PorositySSASetup, this); } else AfxMessageBox(m_error); } void PorositySSADialog::OnCancel() { if(!DestroyWindow()) AfxMessageBox("Could not destroy this window!!!"); delete this; } BOOL PorositySSADialog::OnInitDialog() { program_generated = true; CDialog::OnInitDialog(); InitCommonInputFields(); check_run_3D_struct.SetCheck(BST_CHECKED); check_bucket_match_pixel_size.SetCheck(BST_UNCHECKED); field_bucket_size_mult_cntrl.SetWindowTextA("1"); field_bucket_size_mult_cntrl.EnableWindow(FALSE); program_generated = false; return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } // Changes fields that are enabled/disabled when bucket size match pixel // size option is changed void PorositySSADialog::OnBnClickedCheckBucketMatchPixelSize() { // If check is set, do the following // 1) disable number of buckets field and set it to 1000 // 2) enable bucket size multiplier field if ( check_bucket_match_pixel_size.GetCheck() ) { field_buckets_cntrl.EnableWindow(FALSE); SetIntValField(&field_buckets_cntrl, 1000); field_bucket_size_mult_cntrl.EnableWindow(TRUE); } // Otherwise // 1) set number of buckets back to default, re-enable field // 2) disable bucket size multiplier field else { SetIntValField(&field_buckets_cntrl, 30); field_buckets_cntrl.EnableWindow(TRUE); field_bucket_size_mult_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 PorositySSADialog::OnBnClickedStop() { StopRequest(); } //when input directory button is pushed void PorositySSADialog::OnBnClickedButtonInputDirectory() { //grab file, do inits common to all poromedia dialogs ClickedInputDirectory(); } //when work directory button is pushed void PorositySSADialog::OnBnClickedButtonWorkDirectory() { ClickedWorkDirectory(); } //threshold stuff void PorositySSADialog::OnCbnSelchangeComboThresholdingMethod() { ChangeComboThresholding(); } void PorositySSADialog::OnEnChangeEditManualThreshold() { EditManualThreshold(); } //the rest deals with start/width/end field autocalcs void PorositySSADialog::OnEnChangeEditStartSlice() { EditStartSlice(); } void PorositySSADialog::OnEnChangeEditWidthSlices() { EditWidthSlices(); } void PorositySSADialog::OnEnChangeEditEndSlice() { EditEndSlice(); } void PorositySSADialog::OnEnChangeEditStartx() { EditStartx(); } void PorositySSADialog::OnEnChangeEditWidthx() { EditWidthx(); } void PorositySSADialog::OnEnChangeEditEndx() { EditEndx(); } void PorositySSADialog::OnEnChangeEditStarty() { EditStarty(); } void PorositySSADialog::OnEnChangeEditWidthy() { EditWidthy(); } void PorositySSADialog::OnEnChangeEditEndy() { EditEndy(); }