#include "stdafx.h" #include "RwInput.h" using namespace std; //test for corrupt file // -------------------------------------------------------------------------------------------- // // Description - // -------------------------------------------------------------------------------------------- void disable_inputs( RW_Dialog *rw_dlg_ptr ) { // Note: common inputs disabled in dialog class //run settings //in same order as of GUI rw_dlg_ptr->field_rw_NUM_SUB_CUBES_cntrl.EnableWindow(FALSE); rw_dlg_ptr->field_rw_SIZE_SUB_CUBES_cntrl.EnableWindow(FALSE); rw_dlg_ptr->field_rw_SIZE_SUB_CUBES_MICRONS_cntrl.EnableWindow(FALSE); rw_dlg_ptr->field_rw_DISTANCE_FROM_CENTER_cntrl.EnableWindow(FALSE); rw_dlg_ptr->field_rw_DISTANCE_FROM_CENTER_MICRONS_cntrl.EnableWindow(FALSE); rw_dlg_ptr->field_rw_MAX_NUM_TRACERS_cntrl.EnableWindow(FALSE); rw_dlg_ptr->field_rw_MAX_DISTANCE_cntrl.EnableWindow(FALSE); rw_dlg_ptr->field_rw_MAX_DISTANCE_LAMBDA_cntrl.EnableWindow(FALSE); rw_dlg_ptr->field_rw_MAX_JUMP_SIZE_cntrl.EnableWindow(FALSE); rw_dlg_ptr->field_rw_MAX_JUMP_SIZE_LAMBDA_cntrl.EnableWindow(FALSE); rw_dlg_ptr->field_rw_DATACOLLECTIONPOINT_INCREMENT_cntrl.EnableWindow(FALSE); rw_dlg_ptr->field_rw_DATACOLLECTIONPOINT_INCREMENT_LAMBDA_cntrl.EnableWindow(FALSE); rw_dlg_ptr->field_rw_ROD_cntrl.EnableWindow(FALSE); rw_dlg_ptr->field_rw_LAMBDA_cntrl.EnableWindow(FALSE); rw_dlg_ptr->field_rw_LAMBDA_FOR_FIBER_cntrl.EnableWindow(FALSE); rw_dlg_ptr->field_rw_FPT_BOUNDARY_LAYER_LAMBDA_cntrl.EnableWindow(FALSE); rw_dlg_ptr->field_rw_FPT_BOUNDARY_LAYER_MICRONS_cntrl.EnableWindow(FALSE); //parameters (lower half of GUI) //true RW etc rw_dlg_ptr->CHECK_TRUE_RANDOM_WALK.EnableWindow(FALSE); rw_dlg_ptr->CHECK_SUB_ROI_SPHERE.EnableWindow(FALSE); rw_dlg_ptr->CHECK_RW_MIRROR.EnableWindow(FALSE); rw_dlg_ptr->CHECK_RW_MIRROR_INFINITE.EnableWindow(FALSE); rw_dlg_ptr->field_rw_MAX_DISPLACEMENT_DIAG_cntrl.EnableWindow(FALSE); rw_dlg_ptr->CHECK_RW_RANDOM_START.EnableWindow(FALSE); rw_dlg_ptr->field_rw_MIN_DIST_EDGES_PIXEL_cntrl.EnableWindow(FALSE); rw_dlg_ptr->field_rw_MIN_DIST_EDGES_MICRON_cntrl.EnableWindow(FALSE); rw_dlg_ptr->CHECK_CV.EnableWindow(FALSE); rw_dlg_ptr->field_rw_CV_NUM_TRACERS_cntrl.EnableWindow(FALSE); rw_dlg_ptr->field_rw_CV_CRITERIA_cntrl.EnableWindow(FALSE); rw_dlg_ptr->field_rw_CV_NEW_DATA_cntrl.EnableWindow(FALSE); //results rw_dlg_ptr->CHECK_SAVE_DETAILED_TRACE.EnableWindow(FALSE); rw_dlg_ptr->CHECK_SAVE_RW_RAW_DATA.EnableWindow(FALSE); rw_dlg_ptr->field_rw_NUM_BUCKETS1_cntrl.EnableWindow(FALSE); rw_dlg_ptr->field_rw_PERCENT_MAX_DISTANCE_cntrl.EnableWindow(FALSE); rw_dlg_ptr->field_rw_NUM_BUCKETS2_cntrl.EnableWindow(FALSE); rw_dlg_ptr->field_rw_PERCENT_DENSEST_BUCKET_cntrl.EnableWindow(FALSE); //batch mode rw_dlg_ptr->CHECK_RW_BATCH_MODE.EnableWindow(FALSE); } // -------------------------------------------------------------------------------------------- // // Description - // -------------------------------------------------------------------------------------------- void enable_inputs( RW_Dialog *rw_dlg_ptr ) { // Enable the common inputs rw_dlg_ptr->EnableCommonInputs( ); //run settings //rw_dlg_ptr->field_rw_PERCENT_DENSEST_BUCKET_cntrl.EnableWindow(TRUE); //rw_dlg_ptr->field_rw_PERCENT_MAX_DISTANCE_cntrl.EnableWindow(TRUE); //rw_dlg_ptr->field_rw_DATACOLLECTIONPOINT_INCREMENT_cntrl.EnableWindow(TRUE); //rw_dlg_ptr->field_rw_ROD_cntrl.EnableWindow(TRUE); //rw_dlg_ptr->field_rw_LAMBDA_cntrl.EnableWindow(TRUE); //rw_dlg_ptr->field_rw_LAMBDA_FOR_FIBER_cntrl.EnableWindow(TRUE); //rw_dlg_ptr->field_rw_MAX_JUMP_SIZE_cntrl.EnableWindow(TRUE); //rw_dlg_ptr->field_rw_MAX_DISTANCE_cntrl.EnableWindow(TRUE); //rw_dlg_ptr->field_rw_DISTANCE_FROM_CENTER_cntrl.EnableWindow(TRUE); //rw_dlg_ptr->field_rw_DISTANCE_FROM_CENTER_MICRONS_cntrl.EnableWindow(TRUE); //rw_dlg_ptr->field_rw_SIZE_SUB_CUBES_cntrl.EnableWindow(TRUE); //rw_dlg_ptr->field_rw_SIZE_SUB_CUBES_MICRONS_cntrl.EnableWindow(TRUE); //rw_dlg_ptr->field_rw_NUM_BUCKETS1_cntrl.EnableWindow(TRUE); //rw_dlg_ptr->field_rw_NUM_BUCKETS2_cntrl.EnableWindow(TRUE); //rw_dlg_ptr->field_rw_NUM_SUB_CUBES_cntrl.EnableWindow(TRUE); //rw_dlg_ptr->field_rw_MAX_NUM_TRACERS_cntrl.EnableWindow(TRUE); //rw_dlg_ptr->field_rw_ //rw_dlg_ptr->CHECK_SAVE_DETAILED_TRACE.EnableWindow(TRUE); //rw_dlg_ptr->CHECK_SUB_ROI_SPHERE.EnableWindow(TRUE); //rw_dlg_ptr->CHECK_TRUE_RANDOM_WALK.EnableWindow(TRUE); rw_dlg_ptr->field_rw_NUM_SUB_CUBES_cntrl.EnableWindow(TRUE); rw_dlg_ptr->field_rw_SIZE_SUB_CUBES_cntrl.EnableWindow(TRUE); rw_dlg_ptr->field_rw_SIZE_SUB_CUBES_MICRONS_cntrl.EnableWindow(TRUE); rw_dlg_ptr->field_rw_DISTANCE_FROM_CENTER_cntrl.EnableWindow(TRUE); rw_dlg_ptr->field_rw_DISTANCE_FROM_CENTER_MICRONS_cntrl.EnableWindow(TRUE); rw_dlg_ptr->field_rw_MAX_NUM_TRACERS_cntrl.EnableWindow(TRUE); rw_dlg_ptr->field_rw_MAX_DISTANCE_cntrl.EnableWindow(TRUE); rw_dlg_ptr->field_rw_MAX_DISTANCE_LAMBDA_cntrl.EnableWindow(TRUE); rw_dlg_ptr->field_rw_MAX_JUMP_SIZE_cntrl.EnableWindow(TRUE); rw_dlg_ptr->field_rw_MAX_JUMP_SIZE_LAMBDA_cntrl.EnableWindow(TRUE); rw_dlg_ptr->field_rw_DATACOLLECTIONPOINT_INCREMENT_cntrl.EnableWindow(TRUE); rw_dlg_ptr->field_rw_DATACOLLECTIONPOINT_INCREMENT_LAMBDA_cntrl.EnableWindow(TRUE); rw_dlg_ptr->field_rw_ROD_cntrl.EnableWindow(TRUE); rw_dlg_ptr->field_rw_LAMBDA_cntrl.EnableWindow(TRUE); rw_dlg_ptr->field_rw_LAMBDA_FOR_FIBER_cntrl.EnableWindow(TRUE); rw_dlg_ptr->field_rw_FPT_BOUNDARY_LAYER_LAMBDA_cntrl.EnableWindow(TRUE); rw_dlg_ptr->field_rw_FPT_BOUNDARY_LAYER_MICRONS_cntrl.EnableWindow(TRUE); //parameters (lower half of GUI) //true RW etc rw_dlg_ptr->CHECK_TRUE_RANDOM_WALK.EnableWindow(TRUE); rw_dlg_ptr->CHECK_SUB_ROI_SPHERE.EnableWindow(TRUE); rw_dlg_ptr->CHECK_RW_MIRROR.EnableWindow(TRUE); rw_dlg_ptr->CHECK_RW_MIRROR_INFINITE.EnableWindow(TRUE); rw_dlg_ptr->field_rw_MAX_DISPLACEMENT_DIAG_cntrl.EnableWindow(TRUE); rw_dlg_ptr->CHECK_RW_RANDOM_START.EnableWindow(TRUE); rw_dlg_ptr->field_rw_MIN_DIST_EDGES_PIXEL_cntrl.EnableWindow(TRUE); rw_dlg_ptr->field_rw_MIN_DIST_EDGES_MICRON_cntrl.EnableWindow(TRUE); rw_dlg_ptr->CHECK_CV.EnableWindow(TRUE); rw_dlg_ptr->field_rw_CV_NUM_TRACERS_cntrl.EnableWindow(TRUE); rw_dlg_ptr->field_rw_CV_CRITERIA_cntrl.EnableWindow(TRUE); rw_dlg_ptr->field_rw_CV_NEW_DATA_cntrl.EnableWindow(TRUE); //results rw_dlg_ptr->CHECK_SAVE_DETAILED_TRACE.EnableWindow(TRUE); rw_dlg_ptr->CHECK_SAVE_RW_RAW_DATA.EnableWindow(TRUE); rw_dlg_ptr->field_rw_NUM_BUCKETS1_cntrl.EnableWindow(TRUE); rw_dlg_ptr->field_rw_PERCENT_MAX_DISTANCE_cntrl.EnableWindow(TRUE); rw_dlg_ptr->field_rw_NUM_BUCKETS2_cntrl.EnableWindow(TRUE); rw_dlg_ptr->field_rw_PERCENT_DENSEST_BUCKET_cntrl.EnableWindow(TRUE); //batch mode rw_dlg_ptr->CHECK_RW_BATCH_MODE.EnableWindow(TRUE); //check that dialog makes sense (some fields should be disabled depending on some check buttons rw_dlg_ptr->OnBnClickedButton_true_RW_only(); rw_dlg_ptr->OnBnClickedButton_mirror(); rw_dlg_ptr->OnBnClickedButton_RW_MIRROR_INFINITE(); rw_dlg_ptr->OnBnClickedButton_RANDOM_START(); rw_dlg_ptr->OnBnClickedButton_CV(); // Flash for 3 seconds to alert user that we are done rw_dlg_ptr->FlashWindowEx( FLASHW_TRAY, 3, 0 ); } // -------------------------------------------------------------------------------------------- // // Description - // -------------------------------------------------------------------------------------------- UINT RW_Setup( LPVOID pParam ) { char rw_directory[MAX_FILE_STR_LEN], data_out_prefix[MAX_FILE_STR_LEN]; RW_Dialog *RW_Dlg = (RW_Dialog*) pParam; //RW_Dlg->txt_field_progress.SetWindowText("test"); //y // Disable dialog inputs disable_inputs( RW_Dlg ); // Create a new sphere result directory if needed sprintf( rw_directory, "%sRandomWalk", RW_Dlg->field_directory_work_str ); if ( !CreateDirectory(rw_directory, NULL) ) { write_to_log("RandomWalk: %s directory already exists, new one will not be created.", rw_directory); } sprintf( rw_directory, "%s\\%s", data_out_prefix, RW_Dlg->field_name_output_str ); sprintf( data_out_prefix, "%s", rw_directory ); if ( 0 == RW_Dlg->CHECK_RW_BATCH_MODE.GetCheck() ) {//normal mode - no batch file // Convert input to DS_1b_cube DS_1b_cube *input_cube_ptr = RW_Dlg->Dlg_Input_to_cDS( ); // Start random walk write_to_log("**DATE**"); simultaneous_diffusion( input_cube_ptr, RW_Dlg ); write_to_log("**DATE**"); delete input_cube_ptr; } else {//batch mode, need input file selected, and file "rw_batch_file.txt" present in input file folder with samples named "*(x_y_z).1b.raw" char batch_mode_file_name[1024]; sprintf(batch_mode_file_name, "%srw_batch_file.txt", RW_Dlg->field_directory_work_str); write_to_log("RandomWalk: BATCH mode from %s", batch_mode_file_name); ifstream batch_mode_file_input; batch_mode_file_input.open(batch_mode_file_name, ios::in); if(!batch_mode_file_input) write_to_log("RW batch mode: file rw_batch_file.txt NOT present in input file folder"); char *line_batch_file; line_batch_file = new char [1024]; batch_mode_file_input.getline(line_batch_file, 1024, '\n'); char *directory_name; directory_name = new char [1024]; //directory_name = RW_Dlg->input_directory_name; //sprintf(directory_name, "%s%s", RW_Dlg->input_directory_name, "batch_mode\\"); strcpy(directory_name, RW_Dlg->input_directory_name); short int line_number = 1; //while ( (!batch_mode_file_input.eof()) & (!RW_Dlg->stop_request) ) while ( !batch_mode_file_input.eof() ) { // read line of batch file to get name, dimensions //DS_1b_cube *input_cube_ptr = new input_cube_ptr(BIN_file, INPUT_IS_CBIN_STACK, 0, unsigned short nwZ, unsigned short nwY, unsigned short nwX) //RW_Dlg->fiel //use same folder for output as file "rw_batch_file.txt" folder //sprintf(RW_Dlg->field_directory_work_str, "%s", RW_Dlg->input_directory_name); //set input file from line #x of batch_file //RW_Dlg->input_file_name = line_batch_file; batch_mode_file_input.close(); //so user can add samples live to the batch_file //enable_inputs(RW_Dlg); //enables ClickedInputDirectory_auto to modify dialog values RW_Dlg->ClickedInputDirectory_auto( directory_name, line_batch_file ); //disable_inputs(RW_Dlg); //UpdateData(TRUE); DS_1b_cube *input_cube_ptr = RW_Dlg->Dlg_Input_to_cDS(); //disable_inputs(RW_Dlg); //enable slice width field RW_Dlg->field_width_slices_cntrl.EnableWindow(FALSE); RW_Dlg->field_width_X_cntrl.EnableWindow(FALSE); RW_Dlg->field_width_Y_cntrl.EnableWindow(FALSE); //IDC_CHECK_SKIP_BINARIZE needs to be disabled too //sprintf(input_directory, "%s", dlg->input_directory_name); //sprintf(input_full_name, "%s%s", dlg->input_directory, dlg->input_file_name_cut); //sprintf(work_directory, "%s", dlg->field_directory_work_str); //sprintf(output_full_name, "%s%s", dlg->work_directory, dlg->field_name_output_str); // Start random walk write_to_log("**DATE**"); simultaneous_diffusion( input_cube_ptr, RW_Dlg ); delete input_cube_ptr; if (RW_Dlg->stop_request) RW_Dlg->stop_request = false; //will not interrupt batch mode, only skip to the next sample (user considered enough tracers already collected) //read following line in batch file batch_mode_file_input.open(batch_mode_file_name, ios::in); line_number ++; for (short int i = 1; i <= line_number; i++) batch_mode_file_input.getline(line_batch_file, 1024, '\n'); } delete [] line_batch_file; delete directory_name; batch_mode_file_input.close(); write_to_log("**DATE**"); //if (RW_Dlg->stop_request) // write_to_log("stop_request received, batch mode interrupted"); } // Done enable_inputs(RW_Dlg); RW_Dlg->txt_field_progress.SetWindowText("Done with RW analysis!"); return 0; }