// RW_Dialog.cpp : implementation file #include "stdafx.h" #include "RW_Dialog.h" #include "PoroMedia.h" RW_Dialog::RW_Dialog(CWnd* pParent /*=NULL*/) : CDialog(RW_Dialog::IDD, pParent) { dialog_inactive_flags = FILTER_CONTROLS | FILESAVE_CONTROLS;// | PROGRESS_CONTROLS;// | MEMORY_CONTROLS; //y //default values field_rw_NUM_SUB_CUBES_int = 1; field_rw_SIZE_SUB_CUBES_float = 1; field_rw_DISTANCE_FROM_CENTER_float = (float)0; field_rw_MAX_NUM_TRACERS_int = 100000; field_rw_MAX_DISTANCE_float = 200000;//(float)pow((float)10, 6); field_rw_MAX_JUMP_SIZE_LAMBDA_float = (float)500; //500 lambda = 70 microns @ .7 micron/pixel = 100 pixels field_rw_DATACOLLECTIONPOINT_INCREMENT_float = (float)200; field_rw_ROD_float = (float)0; //.04 field_rw_LAMBDA_float = (float)1; field_rw_LAMBDA_FOR_FIBER_float = (float)1; field_rw_FPT_BOUNDARY_LAYER_LAMBDA_float = (float)5; field_rw_MAX_DISPLACEMENT_DIAG_COEFF_float = (float)1000; field_rw_MIN_DIST_EDGES_PIXEL_float = (float)20; field_rw_CV_NUM_TRACERS_int = (int)2000; field_rw_CV_CRITERIA_float = (float).001; field_rw_CV_NEW_DATA_float = (float).1; field_rw_NUM_BUCKETS1_int = 50; field_rw_PERCENT_MAX_DISTANCE_float = (float)1; //will use for stats a bucket which has an av distance of at most xx% of max distance field_rw_NUM_BUCKETS2_int = 50; field_rw_PERCENT_DENSEST_BUCKET_float = (float)0; //will use for stats a bucket with at least xx% datapoints of most populated bucket //field_rw_MAX_RAM_float = (float)0; } RW_Dialog::~RW_Dialog() //y { } void RW_Dialog::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); // SHARED (can copy and paste between dialogs) BindCommonInputFields(pDX); //parameters (upper half of GUI) DDX_Control(pDX, IDC_EDIT_NUM_SUB_CUBES, field_rw_NUM_SUB_CUBES_cntrl); DDX_Text(pDX, IDC_EDIT_NUM_SUB_CUBES, field_rw_NUM_SUB_CUBES_int); DDX_Control(pDX, IDC_EDIT_SIZE_SUB_CUBE, field_rw_SIZE_SUB_CUBES_cntrl); DDX_Text(pDX, IDC_EDIT_SIZE_SUB_CUBE, field_rw_SIZE_SUB_CUBES_float); DDX_Control(pDX, IDC_EDIT_SIZE_SUB_CUBE_MICRONS, field_rw_SIZE_SUB_CUBES_MICRONS_cntrl); DDX_Text(pDX, IDC_EDIT_SIZE_SUB_CUBE_MICRONS, field_rw_SIZE_SUB_CUBES_MICRONS_float); DDX_Control(pDX, IDC_EDIT_DISTANCE_FROM_CENTER, field_rw_DISTANCE_FROM_CENTER_cntrl); DDX_Text(pDX, IDC_EDIT_DISTANCE_FROM_CENTER, field_rw_DISTANCE_FROM_CENTER_float); DDX_Control(pDX, IDC_EDIT_DISTANCE_FROM_CENTER_MICRONS, field_rw_DISTANCE_FROM_CENTER_MICRONS_cntrl); DDX_Text(pDX, IDC_EDIT_DISTANCE_FROM_CENTER_MICRONS, field_rw_DISTANCE_FROM_CENTER_MICRONS_float); DDX_Control(pDX, IDC_EDIT_NUM_TRACERS, field_rw_MAX_NUM_TRACERS_cntrl); DDX_Text(pDX, IDC_EDIT_NUM_TRACERS, field_rw_MAX_NUM_TRACERS_int); DDX_Control(pDX, IDC_EDIT_MAX_DISTANCE, field_rw_MAX_DISTANCE_cntrl); DDX_Text(pDX, IDC_EDIT_MAX_DISTANCE, field_rw_MAX_DISTANCE_float); DDX_Control(pDX, IDC_EDIT_MAX_DISTANCE_LAMBDA, field_rw_MAX_DISTANCE_LAMBDA_cntrl); DDX_Text(pDX, IDC_EDIT_MAX_DISTANCE_LAMBDA, field_rw_MAX_DISTANCE_LAMBDA_float); DDX_Control(pDX, IDC_EDIT_MAX_JUMP_SIZE, field_rw_MAX_JUMP_SIZE_cntrl); DDX_Text(pDX, IDC_EDIT_MAX_JUMP_SIZE, field_rw_MAX_JUMP_SIZE_float); DDX_Control(pDX, IDC_EDIT_MAX_JUMP_SIZE_LAMBDA, field_rw_MAX_JUMP_SIZE_LAMBDA_cntrl); DDX_Text(pDX, IDC_EDIT_MAX_JUMP_SIZE_LAMBDA, field_rw_MAX_JUMP_SIZE_LAMBDA_float); DDX_Control(pDX, IDC_EDIT_DATACOLLECTIONPOINT_INCREMENT, field_rw_DATACOLLECTIONPOINT_INCREMENT_cntrl); DDX_Text(pDX, IDC_EDIT_DATACOLLECTIONPOINT_INCREMENT, field_rw_DATACOLLECTIONPOINT_INCREMENT_float); DDX_Control(pDX, IDC_EDIT_DATACOLLECTIONPOINT_INCREMENT_LAMBDA, field_rw_DATACOLLECTIONPOINT_INCREMENT_LAMBDA_cntrl); DDX_Text(pDX, IDC_EDIT_DATACOLLECTIONPOINT_INCREMENT_LAMBDA, field_rw_DATACOLLECTIONPOINT_INCREMENT_LAMBDA_float); DDX_Control(pDX, IDC_EDIT_ROD, field_rw_ROD_cntrl); DDX_Text(pDX, IDC_EDIT_ROD, field_rw_ROD_float); DDV_MinMaxFloat(pDX, field_rw_ROD_float, 0, 1000); //to allow rod >1 DDX_Control(pDX, IDC_EDIT_LAMBDA, field_rw_LAMBDA_cntrl); DDX_Text(pDX, IDC_EDIT_LAMBDA, field_rw_LAMBDA_float); DDX_Control(pDX, IDC_EDIT_LAMBDA_FOR_FIBER, field_rw_LAMBDA_FOR_FIBER_cntrl); DDX_Text(pDX, IDC_EDIT_LAMBDA_FOR_FIBER, field_rw_LAMBDA_FOR_FIBER_float); DDX_Control(pDX, IDC_EDIT_FPT_BOUNDARY_LAYER_LAMBDA, field_rw_FPT_BOUNDARY_LAYER_LAMBDA_cntrl); DDX_Text(pDX, IDC_EDIT_FPT_BOUNDARY_LAYER_LAMBDA, field_rw_FPT_BOUNDARY_LAYER_LAMBDA_float); DDX_Control(pDX, IDC_EDIT_FPT_BOUNDARY_LAYER_MICRONS, field_rw_FPT_BOUNDARY_LAYER_MICRONS_cntrl); DDX_Text(pDX, IDC_EDIT_FPT_BOUNDARY_LAYER_MICRONS, field_rw_FPT_BOUNDARY_LAYER_MICRONS_float); //parameters (lower half of GUI) //true RW etc DDX_Control(pDX, IDC_CHECK_true_RW_only, CHECK_TRUE_RANDOM_WALK); DDX_Control(pDX, IDC_CHECK_SUB_ROI_SPHERE, CHECK_SUB_ROI_SPHERE); DDX_Control(pDX, IDC_CHECK_mirror, CHECK_RW_MIRROR); DDX_Control(pDX, IDC_CHECK_RW_MIRROR_INFINITE, CHECK_RW_MIRROR_INFINITE); DDX_Control(pDX, IDC_EDIT_MAX_DISPLACEMENT_DIAG, field_rw_MAX_DISPLACEMENT_DIAG_cntrl); DDX_Text(pDX, IDC_EDIT_MAX_DISPLACEMENT_DIAG, field_rw_MAX_DISPLACEMENT_DIAG_COEFF_float); DDX_Control(pDX, IDC_CHECK_RANDOM_START, CHECK_RW_RANDOM_START); DDX_Control(pDX, IDC_EDIT_MIN_DIST_EDGES_PIXEL, field_rw_MIN_DIST_EDGES_PIXEL_cntrl); DDX_Text(pDX, IDC_EDIT_MIN_DIST_EDGES_PIXEL, field_rw_MIN_DIST_EDGES_PIXEL_float); DDX_Control(pDX, IDC_EDIT_MIN_DIST_EDGES_MICRON, field_rw_MIN_DIST_EDGES_MICRON_cntrl); DDX_Text(pDX, IDC_EDIT_MIN_DIST_EDGES_MICRON, field_rw_MIN_DIST_EDGES_MICRON_float); DDX_Control(pDX, IDC_CHECK_CV, CHECK_CV); DDX_Control(pDX, IDC_EDIT_CV_NUM_TRACERS, field_rw_CV_NUM_TRACERS_cntrl); DDX_Text(pDX, IDC_EDIT_CV_NUM_TRACERS, field_rw_CV_NUM_TRACERS_int); DDX_Control(pDX, IDC_EDIT_CV_CRITERIA, field_rw_CV_CRITERIA_cntrl); DDX_Text(pDX, IDC_EDIT_CV_CRITERIA, field_rw_CV_CRITERIA_float); DDV_MinMaxFloat(pDX, field_rw_CV_CRITERIA_float, 0, 1); DDX_Control(pDX, IDC_EDIT_CV_NEW_DATA, field_rw_CV_NEW_DATA_cntrl); DDX_Text(pDX, IDC_EDIT_CV_NEW_DATA, field_rw_CV_NEW_DATA_float); DDV_MinMaxFloat(pDX, field_rw_CV_NEW_DATA_float, 0, 1); //results DDX_Control(pDX, IDC_CHECK_SAVE_DETAILED_TRACE, CHECK_SAVE_DETAILED_TRACE); DDX_Control(pDX, IDC_CHECK_SAVE_RW_RAW_DATA, CHECK_SAVE_RW_RAW_DATA); DDX_Control(pDX, IDC_EDIT_NUM_BUCKETS1, field_rw_NUM_BUCKETS1_cntrl); DDX_Text(pDX, IDC_EDIT_NUM_BUCKETS1, field_rw_NUM_BUCKETS1_int); DDX_Control(pDX, IDC_EDIT_PERCENT_MAX_DISTANCE, field_rw_PERCENT_MAX_DISTANCE_cntrl); DDX_Text(pDX, IDC_EDIT_PERCENT_MAX_DISTANCE, field_rw_PERCENT_MAX_DISTANCE_float); DDV_MinMaxFloat(pDX, field_rw_PERCENT_MAX_DISTANCE_float, 0, 1); DDX_Control(pDX, IDC_EDIT_NUM_BUCKETS2, field_rw_NUM_BUCKETS2_cntrl); DDX_Text(pDX, IDC_EDIT_NUM_BUCKETS2, field_rw_NUM_BUCKETS2_int); DDX_Control(pDX, IDC_EDIT_PERCENT_DENSEST_BUCKET, field_rw_PERCENT_DENSEST_BUCKET_cntrl); DDX_Text(pDX, IDC_EDIT_PERCENT_DENSEST_BUCKET, field_rw_PERCENT_DENSEST_BUCKET_float); DDV_MinMaxFloat(pDX, field_rw_PERCENT_DENSEST_BUCKET_float, 0, 1); //batch mode DDX_Control(pDX, IDC_CHECK_RW_BATCH_MODE, CHECK_RW_BATCH_MODE); //max RAM (in MB) DDX_Control(pDX, IDC_EDIT_RW_MAX_RAM, field_rw_MAX_RAM_cntrl); DDX_Text(pDX, IDC_EDIT_RW_MAX_RAM, field_rw_MAX_RAM_float); } BEGIN_MESSAGE_MAP(RW_Dialog, 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_PIXEL_SIZE, OnEnChangeEditPixelSize) 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) // RW specific messages ON_EN_CHANGE(IDC_EDIT_NUM_SUB_CUBES, OnEnChangeEditNumSubCubes) ON_EN_CHANGE(IDC_EDIT_ROD, OnEnChangeEditRod) ON_EN_CHANGE(IDC_EDIT_LAMBDA, OnEnChangeLambda) ON_EN_CHANGE(IDC_EDIT_LAMBDA_FOR_FIBER, OnEnChangeLambdaForFiber) ON_EN_CHANGE(IDC_EDIT_SIZE_SUB_CUBE, OnEnChangeEditSizeSubCube) ON_EN_CHANGE(IDC_EDIT_SIZE_SUB_CUBE_MICRONS, OnEnChangeEditSizeSubCubeMicrons) ON_EN_CHANGE(IDC_EDIT_DISTANCE_FROM_CENTER, OnEnChangeEditDistanceFromCenter) ON_EN_CHANGE(IDC_EDIT_DISTANCE_FROM_CENTER_MICRONS, OnEnChangeEditDistanceFromCenterMicrons) ON_EN_CHANGE(IDC_EDIT_NUM_TRACERS, OnEnChangeNumberTracers) ON_EN_CHANGE(IDC_EDIT_MAX_DISTANCE_LAMBDA, OnEnChangeEditMaxDistanceLambda) ON_EN_CHANGE(IDC_EDIT_MAX_DISTANCE, OnEnChangeEditMaxDistanceMicrons) ON_EN_CHANGE(IDC_EDIT_MAX_JUMP_SIZE_LAMBDA, OnEnChangeEditMaxJumpSizeLambda) ON_EN_CHANGE(IDC_EDIT_MAX_JUMP_SIZE, OnEnChangeEditMaxJumpSizeMicrons) ON_EN_CHANGE(IDC_EDIT_DATACOLLECTIONPOINT_INCREMENT_LAMBDA, OnEnChangeEditDataCollPointIncrementLambda) ON_EN_CHANGE(IDC_EDIT_DATACOLLECTIONPOINT_INCREMENT, OnEnChangeEditDataCollPointIncrementMicrons) ON_EN_CHANGE(IDC_EDIT_FPT_BOUNDARY_LAYER_LAMBDA, OnEnChangeEditFPTBoundaryLayerLambda) ON_EN_CHANGE(IDC_EDIT_FPT_BOUNDARY_LAYER_MICRONS, OnEnChangeEditFPTBoundaryLayerMicrons) ON_EN_CHANGE(IDC_EDIT_MIN_DIST_EDGES_PIXEL, OnEnChangeEditMIN_DIST_EDGES_PIXEL) ON_EN_CHANGE(IDC_EDIT_MIN_DIST_EDGES_MICRON, OnEnChangeEditMIN_DIST_EDGES_MICRON) ON_BN_CLICKED(IDC_CHECK_true_RW_only, OnBnClickedButton_true_RW_only) ON_BN_CLICKED(IDC_CHECK_mirror, OnBnClickedButton_mirror) ON_BN_CLICKED(IDC_CHECK_RW_MIRROR_INFINITE, OnBnClickedButton_RW_MIRROR_INFINITE) ON_BN_CLICKED(IDC_CHECK_RANDOM_START, OnBnClickedButton_RANDOM_START) ON_BN_CLICKED(IDC_CHECK_CV, OnBnClickedButton_CV) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // RW_Dialog message handlers ///////////////////////////////////////////////////////////////////////////// void RW_Dialog::OnOK() { // 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."; } if ( is_dataright ) {//problem in batch mode case. will add the same feature in simultneous_diffusion.cpp to fix it. //delete '[' and everything after it - BMP case -> not happening here input_file_name_cut = input_file_name; int index; index = input_file_name_cut.GetLength() - 1 ; while (index >= 0 ) { if ( input_file_name_cut[index] == '(' ) break; index--; } //if (left_bracket_indx > 0) // input_file_name_cut.Delete(left_bracket_indx, input_file_name.GetLength() ); if (index > 0) input_file_name_cut.Delete(index, input_file_name_cut.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(RW_Setup, this); } else { AfxMessageBox(m_error); } } void RW_Dialog::OnCancel() { // TODO: Add extra cleanup here CDialog::OnCancel(); } BOOL RW_Dialog::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here CHECK_TRUE_RANDOM_WALK.SetCheck( false ); CHECK_SUB_ROI_SPHERE.SetCheck( true ); CHECK_SAVE_DETAILED_TRACE.SetCheck( false ); CHECK_RW_MIRROR.SetCheck( true ); CHECK_SAVE_RW_RAW_DATA.SetCheck( true ); CHECK_RW_MIRROR_INFINITE.SetCheck( true ); CHECK_CV.SetCheck( true ); CHECK_RW_RANDOM_START.SetCheck( true ); //field_rw_MAX_RAM_cntrl.EnableWindow(FALSE); //SetFloatValField(&field_rw_MAX_RAM_cntrl, 0); //calc default lambda value double lambda_micron; //calculateLambda { double sigma; double kB; // at T=298K and P=1atm sigma = (double)2.551*pow((double)10, -10); // collision diameter in angstroms = 0.1 nm = 10^-10 m kB = (double)1.3806*pow((double)10, -23); // J/K lambda_micron = kB*(double)298/((double)1.013*pow((double)10, 5)); // kB*T / 1atm lambda_micron /= ((double)(1.4142136*3.1415927)*sigma*sigma); // /sqrt(2)/pi/sigma^2 lambda_micron *= pow((double)10, 6); // convert from m to microns (result ~.14 um) } program_generated = true; SetFloatValField(&field_rw_LAMBDA_cntrl, lambda_micron); SetFloatValField(&field_rw_ROD_cntrl, field_rw_ROD_float); program_generated = false; //estimated mem use req_mem_byte_multiplier = 1.25; OnEnChangeEditRod(); OnEnChangeEditSizeSubCube(); OnEnChangeEditDistanceFromCenter(); OnEnChangeEditMaxDistanceMicrons(); OnEnChangeEditMaxJumpSizeLambda(); OnEnChangeEditDataCollPointIncrementMicrons(); OnEnChangeEditFPTBoundaryLayerLambda(); OnEnChangeEditMIN_DIST_EDGES_PIXEL(); OnBnClickedButton_true_RW_only(); OnBnClickedButton_mirror(); OnBnClickedButton_RW_MIRROR_INFINITE(); OnBnClickedButton_RANDOM_START(); OnBnClickedButton_CV(); OnEnChangeNumberTracers(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void RW_Dialog::OnEnChangeEditPixelSize() //problem -> doesnt work { 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); } program_generated = false; //restore original cursor position field_pixel_size_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } OnEnChangeEditSizeSubCube(); OnEnChangeEditDistanceFromCenter(); } void RW_Dialog::OnEnChangeEditNumSubCubes() { if (!program_generated) { program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_rw_NUM_SUB_CUBES_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); //grab original sub-cube size double original_size_sub_cube, new_size_sub_cube; original_size_sub_cube = GetFloatValFromField(&field_rw_SIZE_SUB_CUBES_cntrl); int wX, wY, wZ; wX = GetIntValFromField(&field_width_X_cntrl); wY = GetIntValFromField(&field_width_Y_cntrl); wZ = GetIntValFromField(&field_width_slices_cntrl); //wZ should be the min, but need to check if (wZ <= wX) { if (wZ <= wY) new_size_sub_cube = (float)wZ; else new_size_sub_cube = (float)wY; } else { if (wX <= wY) new_size_sub_cube = (float)wX; else new_size_sub_cube = (float)wY; } //set new sub-cube size value //if (original_size_sub_cube < (float)1) // original_size_sub_cube = (float)1; if (new_size_sub_cube == 0) new_size_sub_cube = original_size_sub_cube; //SetFloatValField(&field_rw_SIZE_SUB_CUBES_cntrl, min(new_size_sub_cube, original_size_sub_cube) ); SetFloatValField(&field_rw_SIZE_SUB_CUBES_cntrl, new_size_sub_cube); program_generated = false; //restore original cursor position field_rw_NUM_SUB_CUBES_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } OnEnChangeEditSizeSubCube(); } void RW_Dialog::OnEnChangeEditRod() { if (!program_generated) { program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_rw_ROD_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); //grab rod double rod; rod = GetFloatValFromField(&field_rw_ROD_cntrl); //if (rod < 0) //coomented out to allow rod>1 // rod = (double)0; //else if (rod > 1) // rod = (double)1; //calc lambda values based on input double lambda_micron; lambda_micron = GetFloatValFromField(&field_rw_LAMBDA_cntrl); ////calculateLambda //{ // double sigma; // double kB; // at T=298K and P=1atm // sigma = (double)2.551*pow((double)10, -10); // collision diameter in angstroms = 0.1 nm = 10^-10 m // kB = (double)1.3806*pow((double)10, -23); // J/K // lambda_micron = kB*(double)298/((double)1.013*pow((double)10, 5)); // kB*T / 1atm // lambda_micron /= ((double)(1.4142136*3.1415927)*sigma*sigma); // /sqrt(2)/pi/sigma^2 // lambda_micron *= pow((double)10, 6); // convert from m to microns (result ~.14 um) //} //SetFloatValField(&field_rw_LAMBDA_cntrl, lambda_micron); //calculateLambdaForFiber double lambdaForFiber_micron = rod * lambda_micron; SetFloatValField(&field_rw_LAMBDA_FOR_FIBER_cntrl, lambdaForFiber_micron); SetFloatValField(&field_rw_ROD_cntrl, rod); program_generated = false; //restore original cursor position field_rw_ROD_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void RW_Dialog::OnEnChangeLambda() {//this is if user can modify lambda via the dialog if (!program_generated) { //grab lambda & rod { double Lambda; Lambda = GetFloatValFromField(&field_rw_LAMBDA_cntrl); double rod; rod = GetFloatValFromField(&field_rw_ROD_cntrl); //set lambda for fiber double LambdaForFiber; LambdaForFiber = rod * Lambda; SetFloatValField(&field_rw_LAMBDA_FOR_FIBER_cntrl, LambdaForFiber); } OnEnChangeEditFPTBoundaryLayerMicrons(); OnEnChangeEditMaxDistanceMicrons(); OnEnChangeEditMaxJumpSizeMicrons(); OnEnChangeEditDataCollPointIncrementMicrons(); } } void RW_Dialog::OnEnChangeLambdaForFiber() { if (!program_generated) { program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_rw_LAMBDA_FOR_FIBER_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); //grab lambda & LambdaForFiber double Lambda; Lambda = GetFloatValFromField(&field_rw_LAMBDA_cntrl); double LambdaForFiber; LambdaForFiber = GetFloatValFromField(&field_rw_LAMBDA_FOR_FIBER_cntrl); //calc rod double rod; rod = LambdaForFiber / Lambda; SetFloatValField(&field_rw_ROD_cntrl, rod); program_generated = false; //restore original cursor position field_rw_LAMBDA_FOR_FIBER_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } OnEnChangeEditRod(); //to check if the 0<=rod<=1 condition was exceeded } void RW_Dialog::OnEnChangeEditSizeSubCube() { if (!program_generated) { program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_rw_SIZE_SUB_CUBES_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); //grab pixel size and SizeSubCube double pix_size = GetFloatValFromField(&field_pixel_size_cntrl); double SizeSubCube = GetFloatValFromField(&field_rw_SIZE_SUB_CUBES_cntrl); double max_size_sub_cube; int wX, wY, wZ; wX = GetIntValFromField(&field_width_X_cntrl); wY = GetIntValFromField(&field_width_Y_cntrl); wZ = GetIntValFromField(&field_width_slices_cntrl); //wZ should be the min, but need to check if (wZ <= wX) { if (wZ <= wY) max_size_sub_cube = (float)wZ; else max_size_sub_cube = (float)wY; } else { if (wX <= wY) max_size_sub_cube = (float)wX; else max_size_sub_cube = (float)wY; } if ( 0 == CHECK_RW_MIRROR.GetCheck() ) //to not create issues when mirroring SizeSubCube = min(SizeSubCube, max_size_sub_cube); //not to exceed sample physical dimensions //calc new value based on field_rw_SIZE_SUB_CUBES SetFloatValField(&field_rw_SIZE_SUB_CUBES_cntrl, SizeSubCube); SetFloatValField(&field_rw_SIZE_SUB_CUBES_MICRONS_cntrl, pix_size*SizeSubCube); program_generated = false; //restore original cursor position field_rw_SIZE_SUB_CUBES_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void RW_Dialog::OnEnChangeEditSizeSubCubeMicrons() { if (!program_generated) { program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_rw_SIZE_SUB_CUBES_MICRONS_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); //grab pixel size and SizeSubCubeMicrons double pix_size = GetFloatValFromField(&field_pixel_size_cntrl); double SizeSubCubeMicrons = GetFloatValFromField(&field_rw_SIZE_SUB_CUBES_MICRONS_cntrl); //calc new value based on input SetFloatValField(&field_rw_SIZE_SUB_CUBES_cntrl, SizeSubCubeMicrons/pix_size); SetFloatValField(&field_rw_MAX_JUMP_SIZE_cntrl, SizeSubCubeMicrons/2); program_generated = false; //restore original cursor position field_rw_SIZE_SUB_CUBES_MICRONS_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } OnEnChangeEditSizeSubCube(); OnEnChangeEditMaxJumpSizeMicrons(); } void RW_Dialog::OnEnChangeEditDistanceFromCenter() { if (!program_generated) { program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_rw_DISTANCE_FROM_CENTER_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); //grab pixel size and DistanceFromCenter double pix_size = GetFloatValFromField(&field_pixel_size_cntrl); long DistanceFromCenter = GetLongValFromField(&field_rw_DISTANCE_FROM_CENTER_cntrl); //calc new value based on input SetFloatValField(&field_rw_DISTANCE_FROM_CENTER_MICRONS_cntrl, DistanceFromCenter*pix_size); program_generated = false; //restore original cursor position field_rw_DISTANCE_FROM_CENTER_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void RW_Dialog::OnEnChangeEditDistanceFromCenterMicrons() { if (!program_generated) { program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_rw_DISTANCE_FROM_CENTER_MICRONS_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); //grab pixel size and DistanceFromCenterMicrons double pix_size = GetFloatValFromField(&field_pixel_size_cntrl); double DistanceFromCenterMicrons = GetFloatValFromField(&field_rw_DISTANCE_FROM_CENTER_MICRONS_cntrl); //calc new value based on input SetFloatValField(&field_rw_DISTANCE_FROM_CENTER_cntrl, DistanceFromCenterMicrons/pix_size); program_generated = false; //restore original cursor position field_rw_DISTANCE_FROM_CENTER_MICRONS_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void RW_Dialog::OnEnChangeEditMaxDistanceLambda() { if (!program_generated) { program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_rw_MAX_DISTANCE_LAMBDA_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); double lambda = GetFloatValFromField(&field_rw_LAMBDA_cntrl); double MAX_DISTANCE_LAMBDA = GetFloatValFromField(&field_rw_MAX_DISTANCE_LAMBDA_cntrl); //set new value SetFloatValField(&field_rw_MAX_DISTANCE_cntrl, MAX_DISTANCE_LAMBDA*lambda); program_generated = false; //restore original cursor position field_rw_MAX_DISTANCE_LAMBDA_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void RW_Dialog::OnEnChangeEditMaxDistanceMicrons() { if (!program_generated) { program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_rw_MAX_DISTANCE_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); double lambda = GetFloatValFromField(&field_rw_LAMBDA_cntrl); double MAX_DISTANCE = GetFloatValFromField(&field_rw_MAX_DISTANCE_cntrl); //set new value SetFloatValField(&field_rw_MAX_DISTANCE_LAMBDA_cntrl, MAX_DISTANCE/lambda); OnEnChangeNumberTracers(); program_generated = false; //restore original cursor position field_rw_MAX_DISTANCE_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void RW_Dialog::OnEnChangeEditMaxJumpSizeLambda() { if (!program_generated) { program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_rw_MAX_JUMP_SIZE_LAMBDA_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); { double lambda = GetFloatValFromField(&field_rw_LAMBDA_cntrl); double MAX_JUMP_SIZE_LAMBDA = GetFloatValFromField(&field_rw_MAX_JUMP_SIZE_LAMBDA_cntrl); //set new value SetFloatValField(&field_rw_MAX_JUMP_SIZE_cntrl, MAX_JUMP_SIZE_LAMBDA*lambda); } program_generated = false; //restore original cursor position field_rw_MAX_JUMP_SIZE_LAMBDA_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void RW_Dialog::OnEnChangeEditMaxJumpSizeMicrons() { if (!program_generated) { program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_rw_MAX_JUMP_SIZE_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); { double lambda = GetFloatValFromField(&field_rw_LAMBDA_cntrl); double MAX_JUMP_SIZE = GetFloatValFromField(&field_rw_MAX_JUMP_SIZE_cntrl); //set new value SetFloatValField(&field_rw_MAX_JUMP_SIZE_LAMBDA_cntrl, MAX_JUMP_SIZE/lambda); } program_generated = false; //restore original cursor position field_rw_MAX_JUMP_SIZE_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void RW_Dialog::OnEnChangeEditDataCollPointIncrementLambda() { if (!program_generated) { program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_rw_DATACOLLECTIONPOINT_INCREMENT_LAMBDA_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); { double lambda = GetFloatValFromField(&field_rw_LAMBDA_cntrl); double DATACOLLECTIONPOINT_INCREMENT_LAMBDA = GetFloatValFromField(&field_rw_DATACOLLECTIONPOINT_INCREMENT_LAMBDA_cntrl); //set new value SetFloatValField(&field_rw_DATACOLLECTIONPOINT_INCREMENT_cntrl, DATACOLLECTIONPOINT_INCREMENT_LAMBDA*lambda); } program_generated = false; //restore original cursor position field_rw_DATACOLLECTIONPOINT_INCREMENT_LAMBDA_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void RW_Dialog::OnEnChangeEditDataCollPointIncrementMicrons() { if (!program_generated) { program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_rw_DATACOLLECTIONPOINT_INCREMENT_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); { double lambda = GetFloatValFromField(&field_rw_LAMBDA_cntrl); double DATACOLLECTIONPOINT_INCREMENT = GetFloatValFromField(&field_rw_DATACOLLECTIONPOINT_INCREMENT_cntrl); //set new value SetFloatValField(&field_rw_DATACOLLECTIONPOINT_INCREMENT_LAMBDA_cntrl, DATACOLLECTIONPOINT_INCREMENT/lambda); } OnEnChangeNumberTracers(); program_generated = false; //restore original cursor position field_rw_DATACOLLECTIONPOINT_INCREMENT_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void RW_Dialog::OnEnChangeEditFPTBoundaryLayerLambda() { if (!program_generated) { program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_rw_FPT_BOUNDARY_LAYER_LAMBDA_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); { double lambda = GetFloatValFromField(&field_rw_LAMBDA_cntrl); double FPT_BOUNDARY_LAYER_LAMBDA = GetFloatValFromField(&field_rw_FPT_BOUNDARY_LAYER_LAMBDA_cntrl); //set new value SetFloatValField(&field_rw_FPT_BOUNDARY_LAYER_MICRONS_cntrl, FPT_BOUNDARY_LAYER_LAMBDA*lambda); } program_generated = false; //restore original cursor position field_rw_FPT_BOUNDARY_LAYER_LAMBDA_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void RW_Dialog::OnEnChangeEditFPTBoundaryLayerMicrons() { if (!program_generated) { program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_rw_FPT_BOUNDARY_LAYER_MICRONS_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); { double lambda = GetFloatValFromField(&field_rw_LAMBDA_cntrl); double FPT_BOUNDARY_LAYER_MICRONS = GetFloatValFromField(&field_rw_FPT_BOUNDARY_LAYER_MICRONS_cntrl); //set new value SetFloatValField(&field_rw_FPT_BOUNDARY_LAYER_LAMBDA_cntrl, FPT_BOUNDARY_LAYER_MICRONS/lambda); } program_generated = false; //restore original cursor position field_rw_FPT_BOUNDARY_LAYER_MICRONS_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void RW_Dialog::OnEnChangeEditMIN_DIST_EDGES_PIXEL() { if (!program_generated) { program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_rw_MIN_DIST_EDGES_PIXEL_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); { //grab pixel size double pix_size = GetFloatValFromField(&field_pixel_size_cntrl); double MIN_DIST_EDGES_PIXEL = GetFloatValFromField(&field_rw_MIN_DIST_EDGES_PIXEL_cntrl); //set new value SetFloatValField(&field_rw_MIN_DIST_EDGES_MICRON_cntrl, MIN_DIST_EDGES_PIXEL*pix_size); } program_generated = false; //restore original cursor position field_rw_MIN_DIST_EDGES_PIXEL_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void RW_Dialog::OnEnChangeEditMIN_DIST_EDGES_MICRON() { if (!program_generated) { program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_rw_MIN_DIST_EDGES_MICRON_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); { //grab pixel size double pix_size = GetFloatValFromField(&field_pixel_size_cntrl); double MIN_DIST_EDGES_MICRON = GetFloatValFromField(&field_rw_MIN_DIST_EDGES_MICRON_cntrl); //set new value SetFloatValField(&field_rw_MIN_DIST_EDGES_PIXEL_cntrl, MIN_DIST_EDGES_MICRON/pix_size); } program_generated = false; //restore original cursor position field_rw_MIN_DIST_EDGES_MICRON_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 RW_Dialog::OnBnClickedStop() { StopRequest(); } //when input directory button is pushed void RW_Dialog::OnBnClickedButtonInputDirectory() { //grab file, do inits common to all poromedia dialogs ClickedInputDirectory(); OnEnChangeEditNumSubCubes(); OnEnChangeNumberTracers(); } //when work directory button is pushed void RW_Dialog::OnBnClickedButtonWorkDirectory() { ClickedWorkDirectory(); } //threshold stuff void RW_Dialog::OnCbnSelchangeComboThresholdingMethod() { ChangeComboThresholding(); } void RW_Dialog::OnEnChangeEditManualThreshold() { EditManualThreshold(); } //the rest deals with start/width/end field autocalcs void RW_Dialog::OnEnChangeEditStartSlice() { EditStartSlice(); } void RW_Dialog::OnEnChangeEditWidthSlices() { EditWidthSlices(); OnEnChangeEditNumSubCubes(); } void RW_Dialog::OnEnChangeEditEndSlice() { EditEndSlice(); } void RW_Dialog::OnEnChangeEditStartx() { EditStartx(); } void RW_Dialog::OnEnChangeEditWidthx() { EditWidthx(); OnEnChangeEditNumSubCubes(); } void RW_Dialog::OnEnChangeEditEndx() { EditEndx(); } void RW_Dialog::OnEnChangeEditStarty() { EditStarty(); } void RW_Dialog::OnEnChangeEditWidthy() { EditWidthy(); OnEnChangeEditNumSubCubes(); } void RW_Dialog::OnEnChangeEditEndy() { EditEndy(); } void RW_Dialog::OnBnClickedButton_true_RW_only() { if ( 1 == CHECK_TRUE_RANDOM_WALK.GetCheck() ) { field_rw_FPT_BOUNDARY_LAYER_LAMBDA_cntrl.EnableWindow(FALSE); field_rw_FPT_BOUNDARY_LAYER_MICRONS_cntrl.EnableWindow(FALSE); } else { field_rw_FPT_BOUNDARY_LAYER_LAMBDA_cntrl.EnableWindow(TRUE); field_rw_FPT_BOUNDARY_LAYER_MICRONS_cntrl.EnableWindow(TRUE); } } void RW_Dialog::OnBnClickedButton_mirror() { if ( 1 == CHECK_RW_MIRROR.GetCheck() ) { field_rw_NUM_SUB_CUBES_cntrl.EnableWindow(FALSE); field_rw_SIZE_SUB_CUBES_cntrl.EnableWindow(FALSE); field_rw_SIZE_SUB_CUBES_MICRONS_cntrl.EnableWindow(FALSE); CHECK_RW_MIRROR_INFINITE.EnableWindow(TRUE); field_rw_MAX_DISPLACEMENT_DIAG_cntrl.EnableWindow(TRUE); OnBnClickedButton_RW_MIRROR_INFINITE(); } else { field_rw_NUM_SUB_CUBES_cntrl.EnableWindow(TRUE); field_rw_SIZE_SUB_CUBES_cntrl.EnableWindow(TRUE); field_rw_SIZE_SUB_CUBES_MICRONS_cntrl.EnableWindow(TRUE); CHECK_SUB_ROI_SPHERE.EnableWindow(TRUE); CHECK_RW_MIRROR_INFINITE.EnableWindow(FALSE); field_rw_MAX_DISPLACEMENT_DIAG_cntrl.EnableWindow(FALSE); } } void RW_Dialog::OnBnClickedButton_RW_MIRROR_INFINITE() { if ( 1 == CHECK_RW_MIRROR_INFINITE.GetCheck() ) { field_rw_MAX_DISPLACEMENT_DIAG_cntrl.EnableWindow(TRUE); CHECK_SUB_ROI_SPHERE.EnableWindow(FALSE); } else { field_rw_MAX_DISPLACEMENT_DIAG_cntrl.EnableWindow(FALSE); CHECK_SUB_ROI_SPHERE.EnableWindow(TRUE); } } void RW_Dialog::OnBnClickedButton_RANDOM_START() { if ( 1 == CHECK_RW_RANDOM_START.GetCheck() ) { //field_rw_NUM_SUB_CUBES_cntrl.EnableWindow(FALSE); //field_rw_SIZE_SUB_CUBES_cntrl.EnableWindow(FALSE); //field_rw_SIZE_SUB_CUBES_MICRONS_cntrl.EnableWindow(FALSE); field_rw_DISTANCE_FROM_CENTER_cntrl.EnableWindow(FALSE); field_rw_DISTANCE_FROM_CENTER_MICRONS_cntrl.EnableWindow(FALSE); field_rw_MIN_DIST_EDGES_PIXEL_cntrl.EnableWindow(TRUE); field_rw_MIN_DIST_EDGES_MICRON_cntrl.EnableWindow(TRUE); } else { //field_rw_NUM_SUB_CUBES_cntrl.EnableWindow(TRUE); //field_rw_SIZE_SUB_CUBES_cntrl.EnableWindow(TRUE); //field_rw_SIZE_SUB_CUBES_MICRONS_cntrl.EnableWindow(TRUE); field_rw_DISTANCE_FROM_CENTER_cntrl.EnableWindow(TRUE); field_rw_DISTANCE_FROM_CENTER_MICRONS_cntrl.EnableWindow(TRUE); field_rw_MIN_DIST_EDGES_PIXEL_cntrl.EnableWindow(FALSE); field_rw_MIN_DIST_EDGES_MICRON_cntrl.EnableWindow(FALSE); } } void RW_Dialog::OnBnClickedButton_CV() { if ( 1 == CHECK_CV.GetCheck() ) { field_rw_CV_NUM_TRACERS_cntrl.EnableWindow(TRUE); field_rw_CV_CRITERIA_cntrl.EnableWindow(TRUE); field_rw_CV_NEW_DATA_cntrl.EnableWindow(TRUE); } else { field_rw_CV_NUM_TRACERS_cntrl.EnableWindow(FALSE); field_rw_CV_CRITERIA_cntrl.EnableWindow(FALSE); field_rw_CV_NEW_DATA_cntrl.EnableWindow(FALSE); } } void RW_Dialog::OnEnChangeNumberTracers() { float MaxRAM; MaxRAM = (float)GetIntValFromField(&field_width_slices_cntrl); MaxRAM *= (float)GetIntValFromField(&field_width_X_cntrl); MaxRAM *= (float)GetIntValFromField(&field_width_Y_cntrl); MaxRAM *= (float)9/(float)8 /(float)1000000; //input cube (1b) + dist transform (8b) //in MB MaxRAM += (float)GetIntValFromField(&field_rw_MAX_NUM_TRACERS_cntrl) \ *(float)GetFloatValFromField(&field_rw_MAX_DISTANCE_cntrl) / (float)GetIntValFromField(&field_rw_DATACOLLECTIONPOINT_INCREMENT_cntrl) \ *(float)23.1 /(float)1000000; //add tracers //23.1MB/10^6tracers SetFloatValField(&field_rw_MAX_RAM_cntrl, MaxRAM); }