void QuenchFrame::OnLoadState(wxCommandEvent &event) { // Load the state of the controller, basically the entire Quench system if(!DoFileDialog(_T("Choose a program-state file to load:"),_T("Quench State (*.qst)|*.qst"),0)) return; _qCtrlr->LoadState(_file_dialog->GetPath().c_str()); }
void QuenchFrame::OnSavePathwaysPDB(wxCommandEvent &event) { if(!DoFileDialog(_T("Choose pathway database filename."),_T("Pathways (*.pdb)|*.pdb"),wxSAVE | wxOVERWRITE_PROMPT)) return; // cerr << _file_dialog->GetWildcard() << endl; DTIPathwaySelection selection = DTIPathwaySelection ::PruneHiddenFibers(&_qCtrlr->PDBHelper_().Assignment(), _qCtrlr->PathwayGroupArray_()); _qCtrlr->PDBHelper_().Save(_file_dialog->GetPath().c_str(), selection); }
bool QuenchFrame::DoSaveStateDialog() { if(!DoFileDialog(_T("Choose state filename."),_T("Quench State (*.qst)|*.qst"),wxSAVE | wxOVERWRITE_PROMPT)) return false; std::string path = _file_dialog->GetPath().c_str(); size_t foundExtensionQst = path.find(".qst"); // If they forgot to include '.qst' in the filename, add it for them: if (foundExtensionQst == std::string::npos) { path = path + ".qst"; } _qCtrlr->SaveState(path); return true; }
void QuenchFrame::OnLoadPathways(wxCommandEvent &event) { if(!DoFileDialog(_T("Choose a pathway file to load:"),_T("Pathways (*.pdb)|*.pdb"),wxOPEN|wxMULTIPLE)) return; int answer=wxNO; NButtonChoiceDialog afd(this, "Append or overwrite ?","\n\nDo you wish to append or overwrite fibers?\n","Append","Overwrite","Cancel"); if(_qCtrlr->PDBHelper_().PDB()) answer = afd.ShowModal(); if(answer != BUTTON_CHOICE_3) { wxArrayString pathNames; _file_dialog->GetPaths(pathNames); _qCtrlr->LoadPathways(pathNames, answer==BUTTON_CHOICE_1); } }
void QuenchFrame::OnLoadROINifti(wxCommandEvent &event) { // Later change this to handle multiple images. if(!DoFileDialog(_T("Choose NIFTI mask image to load:"),_T("NIFTI (*.nii;*.nii.gz;*.hdr)|*.nii;*.nii.gz;*.hdr"),wxMULTIPLE)) return; wxArrayString pathNames; wxArrayString fileNames; _file_dialog->GetPaths(pathNames); _file_dialog->GetFilenames(fileNames); for (int i = 0; i < (int)pathNames.Count(); i++) { _qCtrlr->LoadROINifti(pathNames[i].c_str(), fileNames[i].c_str()); } _menu_roi->Enable(Toggle_ROI_Editing_Mode, TRUE); _menu_roi->Enable(ROI_Properties, TRUE); _menu_roi->Enable(Delete_ROI, TRUE); }
void QuenchFrame::OnSaveROINifti(wxCommandEvent &event) { int result = _chdir("ROIs"); if(!DoFileDialog(_T("Choose ROI filename."),_T("NIFTI (*.nii.gz)|*.nii.gz"),wxSAVE | wxOVERWRITE_PROMPT)) return; if (result == 0) { // If we succeeded in changing the directory, change it back... _chdir(".."); } std::string path = _file_dialog->GetPath().c_str(); size_t foundExtensionNii = path.find(".nii"); size_t foundExtensionHdr = path.find(".hdr"); std::string fName = _file_dialog->GetFilename().c_str(); if (foundExtensionNii == std::string::npos && foundExtensionHdr == std::string::npos) { path = path + ".nii.gz"; fName = fName + ".nii.gz"; } _qCtrlr->SaveCurrentROINifti(path, fName); }
EFI_STATUS MainMenuSaveSeqFunc ( IN EFI_MENU_PAGE *Page ) { EFI_STATUS Status; EFI_FILE_DIALOG_CONTEXT *DialogContext; CHAR16 *FileName; EFI_DIALOG_CONTEXT MsgDialogContext; CHAR16 *MsgDialogTitle; DialogContext = NULL; // //allocate a new efi file dialog context. // Status = BS->AllocatePool ( EfiBootServicesData, sizeof(EFI_FILE_DIALOG_CONTEXT), (VOID **)&DialogContext ); if (EFI_ERROR (Status)) { return EFI_DEVICE_ERROR; } BS->SetMem (DialogContext, sizeof(EFI_FILE_DIALOG_CONTEXT), 0); DialogContext->DialogType = EFI_FILE_DIALOG_TYPE_SAVE_FILE; DialogContext->FileType = EFI_FILTER_FILE_TYPE_SEQ; // //get devicepath and filename through FileDialog // Status = DoFileDialog (DialogContext); if (EFI_ERROR (Status)) { MsgDialogTitle = StrDuplicate (L"Save Sequence Error!"); MsgDialogContext.Type = EFI_DIALOG_TYPE_MESSAGE; MenuPageRefresh (Page); DoDialog (MsgDialogTitle, &MsgDialogContext); } else if (DialogContext->DevicePath != NULL && DialogContext->FileName != NULL && DialogContext->FileName[0] != L'\0') { // //make up file name // if (StrLen (DialogContext->FileName) > 4 && StriCmp (DialogContext->FileName + StrLen (DialogContext->FileName) - 4, L".seq") == 0) { FileName = StrDuplicate (DialogContext->FileName); }else if ( StrLen (DialogContext->FileName) > 1 && StriCmp (DialogContext->FileName + StrLen (DialogContext->FileName) - 1, L".") == 0) { FileName = PoolPrint (L"%sseq", DialogContext->FileName); }else { FileName = PoolPrint (L"%s.seq", DialogContext->FileName); } if (FileName == NULL) { BS->FreePool (DialogContext->DevicePath); BS->FreePool (DialogContext->FileName); BS->FreePool (DialogContext); return EFI_DEVICE_ERROR; } Status = SaveTestSequence ( gFT->DevicePath, FileName, &gFT->TestCaseList ); if (EFI_ERROR (Status)) { MsgDialogTitle = StrDuplicate (L"Save sequence Error!"); } else { MsgDialogTitle = StrDuplicate (L"Save sequence Succeed!"); } MsgDialogContext.Type = EFI_DIALOG_TYPE_MESSAGE; MenuPageRefresh (Page); DoDialog (MsgDialogTitle, &MsgDialogContext); BS->FreePool (FileName); BS->FreePool (DialogContext->DevicePath); BS->FreePool (DialogContext->FileName); } else { if (DialogContext->FileName != NULL) { BS->FreePool (DialogContext->FileName); } if (DialogContext->DevicePath != NULL) { BS->FreePool (DialogContext->DevicePath); } } BS->FreePool (DialogContext); MenuPageRefresh (Page); return EFI_SUCCESS; }
EFI_STATUS MainMenuLoadSeqFunc ( IN EFI_MENU_PAGE *Page ) { EFI_STATUS Status; EFI_FILE_DIALOG_CONTEXT *DialogContext; CHAR16 *FileName; EFI_DIALOG_CONTEXT MsgDialogContext; CHAR16 *MsgDialogTitle; DialogContext = NULL; // //allocate a new efi file dialog context. // Status = BS->AllocatePool ( EfiBootServicesData, sizeof(EFI_FILE_DIALOG_CONTEXT), (VOID **)&DialogContext ); if (EFI_ERROR (Status)) { return EFI_DEVICE_ERROR; } BS->SetMem (DialogContext, sizeof(EFI_FILE_DIALOG_CONTEXT), 0); DialogContext->DialogType = EFI_FILE_DIALOG_TYPE_OPEN_FILE; DialogContext->FileType = EFI_FILTER_FILE_TYPE_SEQ; // //get filename through FileDialog // Status = DoFileDialog (DialogContext); if (EFI_ERROR (Status)) { MsgDialogTitle = StrDuplicate (L"Load Sequence Error!"); MsgDialogContext.Type = EFI_DIALOG_TYPE_MESSAGE; MenuPageRefresh (Page); DoDialog (MsgDialogTitle, &MsgDialogContext); } else if (DialogContext->DevicePath != NULL && DialogContext->FileName != NULL && DialogContext->FileName[0] != L'\0') { // //make up file name // FileName = StrDuplicate (DialogContext->FileName); if (FileName == NULL) { BS->FreePool (DialogContext->DevicePath); BS->FreePool (DialogContext->FileName); BS->FreePool (DialogContext); return EFI_DEVICE_ERROR; } Status = ResetTestCaseOrder (); Status = LoadTestSequence ( gFT->DevicePath, FileName, &gFT->TestCaseList ); if (EFI_ERROR (Status)) { MsgDialogTitle = StrDuplicate (L"Load Sequence Error!"); } else { MsgDialogTitle = StrDuplicate (L"Load Sequence Succeed!"); } MsgDialogContext.Type = EFI_DIALOG_TYPE_MESSAGE; MenuPageRefresh (Page); DoDialog (MsgDialogTitle, &MsgDialogContext); BS->FreePool (FileName); BS->FreePool (DialogContext->DevicePath); BS->FreePool (DialogContext->FileName); } else { if (DialogContext->FileName != NULL) { BS->FreePool (DialogContext->FileName); } if (DialogContext->DevicePath != NULL) { BS->FreePool (DialogContext->DevicePath); } } BS->FreePool (DialogContext); MenuPageRefresh (Page); return EFI_SUCCESS; }
VOID DisplayReportGenerator( IN EFI_MENU_PAGE *Page ) { EFI_STATUS Status; EFI_FILE_DIALOG_CONTEXT *DialogContext; CHAR16 *FileName; EFI_DIALOG_CONTEXT MsgDialogContext; CHAR16 *MsgDialogTitle; CHAR16 *LogFilePath; DialogContext = NULL; // //allocate a new efi file dialog context. // Status = BS->AllocatePool ( EfiBootServicesData, sizeof(EFI_FILE_DIALOG_CONTEXT), (VOID **)&DialogContext ); if (EFI_ERROR (Status)) { return; } BS->SetMem (DialogContext, sizeof(EFI_FILE_DIALOG_CONTEXT), 0); DialogContext->DialogType = EFI_FILE_DIALOG_TYPE_SAVE_FILE; DialogContext->FileType = EFI_FILTER_FILE_TYPE_CSV; // //get filename through FileDialog // Status = DoFileDialog (DialogContext); if (EFI_ERROR (Status)) { MsgDialogTitle = StrDuplicate (L"Generate Report Error!"); MsgDialogContext.Type = EFI_DIALOG_TYPE_MESSAGE; MenuPageRefresh (Page); DoDialog (MsgDialogTitle, &MsgDialogContext); } else if (DialogContext->DevicePath != NULL && DialogContext->FileName != NULL && DialogContext->FileName[0] != L'\0') { // //make up file name // if (StrLen (DialogContext->FileName) > 4 && StriCmp (DialogContext->FileName + StrLen (DialogContext->FileName) - 4, L".csv") == 0) { FileName = StrDuplicate (DialogContext->FileName); } else if ( StrLen (DialogContext->FileName) > 1 && StriCmp (DialogContext->FileName + StrLen (DialogContext->FileName) - 1, L".") == 0) { FileName = PoolPrint (L"%scsv", DialogContext->FileName); } else { FileName = PoolPrint (L"%s.csv", DialogContext->FileName); } if (FileName == NULL) { BS->FreePool (DialogContext->DevicePath); BS->FreePool (DialogContext->FileName); BS->FreePool (DialogContext); return; } MsgDialogTitle = StrDuplicate (L"Wait a few minutes..."); MsgDialogContext.Type = EFI_DIALOG_TYPE_REMINDER; MenuPageRefresh (Page); DoDialog (MsgDialogTitle, &MsgDialogContext); LogFilePath = PoolPrint ( L"%s\\%s", gFT->FilePath, EFI_SCT_PATH_LOG ); if (LogFilePath == NULL) { return; } // // Generate the report file // Status = GenerateReport ( gFT->DevicePath, LogFilePath, DialogContext->DevicePath, FileName ); if (EFI_ERROR (Status)) { MsgDialogTitle = StrDuplicate (L"Generate Report Error!"); } else { MsgDialogTitle = StrDuplicate (L"Generate Report Succeed!"); } MsgDialogContext.Type = EFI_DIALOG_TYPE_MESSAGE; DoDialog (MsgDialogTitle, &MsgDialogContext); BS->FreePool (FileName); BS->FreePool (DialogContext->DevicePath); BS->FreePool (DialogContext->FileName); } else { if (DialogContext->FileName != NULL) { BS->FreePool (DialogContext->FileName); } if (DialogContext->DevicePath != NULL) { BS->FreePool (DialogContext->DevicePath); } } BS->FreePool (DialogContext); MenuPageRefresh (Page); return; }
void QuenchFrame::OnLoadVolume(wxCommandEvent &event) { if(!DoFileDialog(_T("Choose a background image to load:"),_T("NIFTI (*.nii;*.nii.gz;*.hdr)|*.nii;*.nii.gz;*.hdr"),wxFD_OPEN)) return; _qCtrlr->LoadVolume(_file_dialog->GetPath().c_str()); }