#include "stdafx.h" #include "PoroMediaDialogShare.h" ////////////////////////////////////////////////////////////////////////////////////////////////// // // The following methods respond to common across all dialogs 'auto calc' features // ////////////////////////////////////////////////////////////////////////////////////////////////// void PoroMediaDialogShare::EditStartSlice() { if (!program_generated && check_auto_calc_params.GetCheck() ){ program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_start_slice_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); //get the new value int input_num = GetIntValFromField(&field_start_slice_cntrl); //if input is too large or to small, limit it automatically input_num = LimitFieldValueSE(&field_start_slice_cntrl, input_num, S_PLANE); // attempt to update/initialize '[' InitLeftBracket(input_num); // update first_slice variable to the new one first_slice_indx = input_num; // if the new first slice index is greater than last slice, update the last slice to same value if (first_slice_indx > GetIntValFromField(&field_end_slice_cntrl) ) { CString text; field_start_slice_cntrl.GetWindowText(text); field_end_slice_cntrl.SetWindowText(text); } // updates the width field to reflect changes program_generated = false; EditEndSlice(); field_start_slice_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void PoroMediaDialogShare::EditWidthSlices() { //mutex if (!program_generated && check_auto_calc_params.GetCheck() ) { program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_width_slices_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); //grab the new input int num_slices = GetIntValFromField(&field_width_slices_cntrl); //if input is too large or to small, limit it automatically num_slices = LimitFieldValueWidth(&field_width_slices_cntrl, num_slices, first_slice_indx, S_PLANE); //check that first_slice_indx has been initialized (otherwise we don't try doing autocalc, so do nothing) if (first_slice_indx >= 0){ //calculate the new end_slice val and display it SetIntValField(&field_end_slice_cntrl, first_slice_indx + num_slices - 1); //auto calc the XZ plane end depth based on the new width max_XY_depth = num_slices; //update bracket if input is not .stack type UpdateLeftBracket(); } program_generated = false; field_width_slices_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } //this update requires memory estimates float mb_needed = (float)GetIntValFromField(&field_width_X_cntrl)*GetIntValFromField(&field_width_Y_cntrl)*GetIntValFromField(&field_width_slices_cntrl)/1048576; mb_needed = req_mem_byte_multiplier*mb_needed; char txt[54]; if (mb_needed < 1000.0f) sprintf(txt, "Estimated RAM: %.2f MB", mb_needed); else if (mb_needed < 1000000.0f) sprintf(txt, "Estimated RAM: %.2f GB", mb_needed/1000); else sprintf(txt, "Estimated RAM: %.2f TB", mb_needed/1000000); txt_field_req_mem.SetWindowText(txt); } void PoroMediaDialogShare::EditEndSlice() { //mutex if (!program_generated && check_auto_calc_params.GetCheck() ){ program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_end_slice_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); //grab the new input int end_slice = GetIntValFromField(&field_end_slice_cntrl); //check valid input end_slice = LimitFieldValueSE(&field_end_slice_cntrl, end_slice, S_PLANE); //check that first_slice_indx has been initialized (otherwise we don't try doing autocalc, so do nothing) if (first_slice_indx >= 0){ max_XY_depth = end_slice - first_slice_indx + 1; //calculate the new width slice val and display it SetIntValField(&field_width_slices_cntrl, max_XY_depth ); ///only update bracket if end is larger than start if (end_slice > first_slice_indx) UpdateLeftBracket(); } program_generated = false; field_end_slice_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void PoroMediaDialogShare::EditStartx() { //mutex if (!program_generated && check_auto_calc_params.GetCheck() ){ program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_start_X_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); //grab the new input int num_slices = GetIntValFromField(&field_start_X_cntrl); //if input is too large or to small, limit it automatically num_slices = LimitFieldValueSE(&field_start_X_cntrl, num_slices, X_PLANE); first_X_indx = num_slices; // if the new first X indx is greater than end X, update the end X to same value if (first_X_indx > GetIntValFromField(&field_end_X_cntrl) ){ CString text; field_start_X_cntrl.GetWindowText(text); field_end_X_cntrl.SetWindowText(text); } program_generated = false; //autocalc width EditEndx(); field_start_X_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void PoroMediaDialogShare::EditWidthx() { //mutex if (!program_generated && check_auto_calc_params.GetCheck() ){ program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_width_X_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); //grab the new input int num_slices = GetIntValFromField(&field_width_X_cntrl); //if input is too large or to small, limit it automatically num_slices = LimitFieldValueWidth(&field_width_X_cntrl, num_slices, first_X_indx, X_PLANE); //check that first_slice_indx has been initialized (otherwise we don't try doing autocalc, so do nothing) if (first_X_indx > 0){ //calculate the new end_slice val and display it SetIntValField(&field_end_X_cntrl, first_X_indx + num_slices - 1); //auto calc the YZ plane end depth based on the new width max_YZ_depth = num_slices; } program_generated = false; field_width_X_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } //this updates required memory estimate float mb_needed = (float)GetIntValFromField(&field_width_X_cntrl)*GetIntValFromField(&field_width_Y_cntrl)*GetIntValFromField(&field_width_slices_cntrl)/1048576; mb_needed = req_mem_byte_multiplier*mb_needed; char txt[54]; if (mb_needed < 1000.0f) sprintf(txt, "Estimated RAM: %.2f MB", mb_needed); else if (mb_needed < 1000000.0f) sprintf(txt, "Estimated RAM: %.2f GB", mb_needed/1000); else sprintf(txt, "Estimated RAM: %.2f TB", mb_needed/1000000); txt_field_req_mem.SetWindowText(txt); } void PoroMediaDialogShare::EditEndx() { //mutex if (!program_generated && check_auto_calc_params.GetCheck() ){ program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_end_X_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); //grab the new input int end_slice = GetIntValFromField(&field_end_X_cntrl); //check valid input end_slice = LimitFieldValueSE(&field_end_X_cntrl, end_slice, X_PLANE); //check that first_slice_indx has been initialized (otherwise we don't try doing autocalc, so do nothing) if (first_X_indx > 0){ max_YZ_depth = end_slice - first_X_indx + 1; //calculate the new width slice val and display it SetIntValField(&field_width_X_cntrl, max_YZ_depth); } program_generated = false; field_end_X_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void PoroMediaDialogShare::EditStarty() { //mutex if (!program_generated && check_auto_calc_params.GetCheck() ){ program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_start_Y_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); //grab the new input int num_slices = GetIntValFromField(&field_start_Y_cntrl); //if input is too large or to small, limit it automatically num_slices = LimitFieldValueSE(&field_start_Y_cntrl, num_slices, Y_PLANE); first_Y_indx = num_slices; // if the new first X indx is greater than end X, update the end X to same value if (first_Y_indx > GetIntValFromField(&field_end_Y_cntrl) ){ CString text; field_start_Y_cntrl.GetWindowText(text); field_end_Y_cntrl.SetWindowText(text); } program_generated = false; //autocalc y width EditEndy(); field_start_Y_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void PoroMediaDialogShare::EditWidthy() { //mutex if (!program_generated && check_auto_calc_params.GetCheck() ){ program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_width_Y_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); //grab the new input int num_slices = GetIntValFromField(&field_width_Y_cntrl); //if input is too large or to small, limit it automatically num_slices = LimitFieldValueWidth(&field_width_Y_cntrl, num_slices, first_Y_indx, Y_PLANE); //check that first_slice_indx has been initialized (otherwise we don't try doing autocalc, so do nothing) if (first_Y_indx > 0){ //calculate the new end_slice val and display it SetIntValField(&field_end_Y_cntrl, first_Y_indx + num_slices - 1); //auto calc the XZ plane end depth based on the new width max_XZ_depth = num_slices; } program_generated = false; field_width_Y_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } //this updates required memory estimate float mb_needed = (float)GetIntValFromField(&field_width_X_cntrl)*GetIntValFromField(&field_width_Y_cntrl)*GetIntValFromField(&field_width_slices_cntrl)/1048576; mb_needed = req_mem_byte_multiplier*mb_needed; char txt[54]; if (mb_needed < 1000.0f) sprintf(txt, "Estimated RAM: %.2f MB", mb_needed); else if (mb_needed < 1000000.0f) sprintf(txt, "Estimated RAM: %.2f GB", mb_needed/1000); else sprintf(txt, "Estimated RAM: %.2f TB", mb_needed/1000000); txt_field_req_mem.SetWindowText(txt); } void PoroMediaDialogShare::EditEndy() { //mutex if (!program_generated && check_auto_calc_params.GetCheck() ){ program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_end_Y_cntrl.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); //grab the new input int end_slice = GetIntValFromField(&field_end_Y_cntrl); //check valid input end_slice = LimitFieldValueSE(&field_end_Y_cntrl, end_slice, Y_PLANE); //check that first_slice_indx has been initialized (otherwise we don't try doing autocalc, so do nothing) if (first_Y_indx > 0){ max_XZ_depth = end_slice - first_Y_indx + 1; //calculate the new width slice val and display it SetIntValField(&field_width_Y_cntrl, max_XZ_depth); } program_generated = false; field_end_Y_cntrl.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void PoroMediaDialogShare::EditManualThreshold() { if (!program_generated && check_auto_calc_params.GetCheck() ){ program_generated = true; //store original cursor position unsigned int orig_wParam, orig_lParam; field_manual_threshold.SendMessage(EM_GETSEL, (WPARAM)&orig_wParam, (LPARAM)&orig_lParam); int threshold = GetIntValFromField(&field_manual_threshold); //limit threshold to valid bounds if (threshold < 0) threshold = 0; if (threshold > 254) threshold = 254; SetIntValField(&field_manual_threshold, threshold); if (check_image_is_inverted.GetCheck()) pbar_threshold_sensitivity.SetPos(threshold); else pbar_threshold_sensitivity.SetPos(254 - threshold); program_generated = false; field_manual_threshold.SendMessage(EM_SETSEL, orig_wParam, orig_lParam); } } void PoroMediaDialogShare::ChangeComboThresholding() { //check if user selected manual thresholding if (combo_threshold_method.GetCurSel() == 0) { //enable or disable the manual threshold text and pbar field_manual_threshold.EnableWindow(); pbar_threshold_sensitivity.EnableWindow(); txt_field_threshold_val.EnableWindow(); txt_field_threshold_sensitive.EnableWindow(); } else { field_manual_threshold.EnableWindow(FALSE); pbar_threshold_sensitivity.EnableWindow(FALSE); txt_field_threshold_val.EnableWindow(FALSE); txt_field_threshold_sensitive.EnableWindow(FALSE); } }