void CScreenHostOptionFile::Rename(const wchar_t* oldName,const wchar_t* newName) { if (!newName || !newName[0]) return; CHostOptionsMapMgr::Instance().Rename( oldName, newName ); CreateFileList(); }
static HWND InitInstance(HWND pWnd, TODAYLISTITEM *ptli) { WNDCLASS wc; hInst = ptli->hinstDLL; CreateFileList(); //ウィンドウクラスの登録 wc.style = CS_HREDRAW | CS_VREDRAW; wc.hCursor = 0; wc.lpszMenuName = 0; wc.lpfnWndProc = (WNDPROC)WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = ptli->hinstDLL; wc.hIcon = NULL; wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wc.lpszClassName = MAIN_WND_CLASS; UnregisterClass(MAIN_WND_CLASS, ptli->hinstDLL); RegisterClass(&wc); Refresh = TRUE; //ウィンドウの作成 return CreateWindow(MAIN_WND_CLASS, WINDOW_TITLE, WS_CHILD | WS_VISIBLE, CW_DEFAULT, CW_DEFAULT, 0, 0, pWnd, NULL, ptli->hinstDLL, NULL); }
void CScreenHostOptionFile::OnFocus(bool bFocus) { if (bFocus) { UpdateName(); CreateFileList(); } else { UpdateData( true ); g_pProfileMgr->GetCurrentProfile()->Save( ); } CBaseScreen::OnFocus(bFocus); }
void CScreenHostOptionFile::Delete(const wchar_t* pwsName) { char szPath[MAX_PATH*2]; const char* szFileName = CHostOptionsMapMgr::Instance().GetFileNameFromFriendlyName( pwsName ); if( szFileName ) GameModeMgr::Instance( ).GetOptionsFilePath( szFileName, szPath, LTARRAYSIZE( szPath )); else GameModeMgr::Instance( ).GetOptionsFilePath( MPW2A( pwsName ).c_str( ), szPath, LTARRAYSIZE( szPath )); LTFileOperations::DeleteFile( szPath ); CHostOptionsMapMgr::Instance().Delete( pwsName ); CreateFileList(); }
void CScreenHostOptionFile::New(const wchar_t* pwsName ) { if( !LTFileOperations::DirectoryExists( GameModeMgr::Instance( ).GetOptionsFolder( ))) { if( !LTFileOperations::CreateNewDirectory( GameModeMgr::Instance( ).GetOptionsFolder( ))) { //TODO: error message return; } } // check if this name exists in the map file if( CHostOptionsMapMgr::Instance().IsFriendlyNameMapped(pwsName) ) { MBCreate mb; mb.eType = LTMB_OK; g_pInterfaceMgr->ShowMessageBox("IDS_OPTIONFILE_EXISTS",&mb); return; } // create a new file name that is in ANSI char szFileTitle[64]; char szPath[MAX_PATH*2]; for(uint32 nFile=0;;++nFile) { LTSNPrintF( szFileTitle, LTARRAYSIZE(szFileTitle), "ServerOptions%.4d", nFile ); GameModeMgr::Instance( ).GetOptionsFilePath( szFileTitle, szPath, LTARRAYSIZE( szPath )); if( !LTFileOperations::FileExists(szPath) && !CHostOptionsMapMgr::Instance().IsFileNameMapped(szPath) ) break; } // add this combination CHostOptionsMapMgr::Instance().Add( szFileTitle, pwsName ); g_pProfileMgr->GetCurrentProfile()->m_sServerOptionsFile = szFileTitle; CreateFileList(); Escape( ); }
void CameraThread(cyg_addrword_t pParam) { //IMG_COMP_INFO iPreImage; #ifdef RECORDER LIST *plPic2Mail; //待发文件列表 time_t tMail; //上次发送邮件的时间 BOOL bSendIpMail = FALSE; #endif MSG_T msg; //消息 unsigned int usedlen=0; BOOL bExit = FALSE; //退出标志 //BOOL bSendIpMail = TRUE; //是否发送IPdata的标志 BOOL RecordInit = FALSE; UsedBuf* AsBuf = (UsedBuf*)pParam; W99702_DATA_EXCHANGE_T g_dataW99702; memset(&g_dataW99702, 0, sizeof(W99702_DATA_EXCHANGE_T)); if (AsBuf == NULL) { diag_printf("Camera do not have enough buf\n"); return; } g_WebCamState.acImgBuf[0] = (char *)Asmalloc(AsBuf,&usedlen,MAX_CAMERA_IMG_LENGTH); g_WebCamState.acImgBuf[1] = (char *)Asmalloc(AsBuf,&usedlen,MAX_CAMERA_IMG_LENGTH); if((g_WebCamState.acImgBuf[0] == NULL) || (g_WebCamState.acImgBuf[1] == NULL)) { diag_printf("not enough buf for camera\n"); return; } /*assigned buffer for rtsp and recorder*/ if(Buffer_Assign() == FALSE) { diag_printf("not enough buffer for rtsp"); return; } #ifdef RECORDER plPic2Mail =(LIST*) CreateFileList(); tMail = mytime(); #endif //iPreImage.pcBmpBuf = NULL; while (!bExit) { int iC = 0, tm; if (!TryGetMsg(g_pMsgCamera, &msg)) { #ifdef RECORDER Do_TestSendIpMail(&bSendIpMail); #endif W99702_OpenCamera(&g_dataW99702,AsBuf,&usedlen); } else if (msg.lMsg == MSG_QUIT) break; else { if (msg.lMsg == MSG_CAMERA_MONITOR_RECT || msg.lMsg == MSG_CUSTOM_PROC) free((void *)msg.lData); continue; } g_WebCamState.ucCamera = CAMERA_ON; SetCameraInitState(); iC = 0;tm = mytime(); //cyg_thread_create(PTD_PRIORITY, &GetAudioThread, (cyg_addrword_t) &g_dataW99702, "ptdGetAudio", ptdGetAudio_stack, STACKSIZE2, &ptdGetAudio_handle, &g_ptdGetAudio); //if ( ptdGetAudio_handle == NULL) //{ // fprintf(stderr, "Thread for ftp creation failed!\n"); // return; //} //cyg_thread_resume(ptdGetAudio_handle); while (!bExit) { if (!TryGetMsg(g_pMsgCamera, &msg)) { int iNextReadyImg; char *pcJpeg; int *piJpegLen; #ifdef RECORDER Do_TestSendIpMail(&bSendIpMail); #endif iNextReadyImg = g_WebCamState.iReadyImg + 1; if (iNextReadyImg >= 2) iNextReadyImg = 0; pcJpeg = g_WebCamState.acImgBuf[iNextReadyImg]; piJpegLen = &g_WebCamState.iImgBufLen[iNextReadyImg]; if (W99702_GetOneImage(pcJpeg, MAX_CAMERA_IMG_LENGTH, piJpegLen,&g_dataW99702,RecordInit) && (g_pOnGetImage == NULL || (*g_pOnGetImage)(pcJpeg, *piJpegLen))) { BOOL bMotionDetected = FALSE; if (TRUE) //!bErrorImage) { SaveJpeg(pcJpeg, *piJpegLen, bMotionDetected); } } else { diag_printf("Return false\n"); //break; //读图像错误,退出,等待用户再次开启 } } else { diag_printf("Get message: %d\n", msg.lMsg); switch(msg.lMsg) { case MSG_EXTERNEL_DETECTOR: //?????? break; case MSG_QUIT: bExit = TRUE; break; case MSG_CAMERA_MOTION: #ifdef RECORDER wb702EnableMotionDetect ((g_ConfigParam.ucMotionDetectWay == MOTION_DETECT_SOFT ? TRUE : FALSE), CMD_MOTION_DETECT_MIDDLE); if(g_ConfigParam.ucMotionDetectWay == MOTION_DETECT_SOFT) { recorder_memset(); RecordInit = TRUE; diag_printf("Montion Dectect Enable!\n"); } else { RecordInit = FALSE; recorder_dis(); diag_printf("Montion Dectect Disable!\n"); } #endif break; case MSG_CAMERA_DIRECTION: { int iResX, iResY; CMD_ROTATE_E eRotate = -1; W99702_GetImageResolution ( &iResX, &iResY); switch (msg.lData) { case 0x00: eRotate = CMD_ROTATE_NORMAL; break; case 0x01: eRotate = CMD_ROTATE_FLIP; break; case 0x02: eRotate = CMD_ROTATE_MIRROR; break; case 0x03: eRotate = CMD_ROTATE_R180; break; default: eRotate = -1; } if (eRotate != -1) { wb702SetLocalVideoSource (iResX, iResY, eRotate); g_WebCamState.eRotate = eRotate; g_WebCamState.ucX_Direction = (unsigned char) ((msg.lData & 0x02) >> 1); g_WebCamState.ucY_Direction = (unsigned char) (msg.lData & 0x01); } } break; case MSG_CAMERA_RES: { BOOL bRt = FALSE; /*H163 not support 320*240 and 640*480, if set these resolution revert to 352*288*/ switch (msg.lData) { case 0: bRt = W99702_SetImageResolution(176, 144,&g_dataW99702); break; case 1: { if (g_ConfigParam.eVideoFormat == CMD_VIDEO_H263) { msg.lData = 2; //Try 352*288 bRt = W99702_SetImageResolution(352, 288,&g_dataW99702); } else bRt = W99702_SetImageResolution(320, 240,&g_dataW99702); break; } case 2: bRt = W99702_SetImageResolution(352, 288,&g_dataW99702); break; case 3: { if (g_ConfigParam.eVideoFormat == CMD_VIDEO_H263) { msg.lData = 2; //Try 352*288 bRt = W99702_SetImageResolution(352, 288,&g_dataW99702); } else bRt = W99702_SetImageResolution(640, 480,&g_dataW99702); break; } default: ; } if (bRt == TRUE) { g_WebCamState.ucResolution = msg.lData; } } break; case MSG_CAMERA_QUALITY: if (W99702_SetImageQuality( msg.lData,&g_dataW99702)) g_WebCamState.ucCompressionRatio = msg.lData; break; case MSG_CAMERA_FRAMERATE: if (W99702_SetFramerate( msg.lData,&g_dataW99702)) g_WebCamState.ucFramerate = msg.lData; break; case MSG_CAMERA_BRIGHTNESS: if((W99702_SetImageBrightness((int)msg.lData, &g_dataW99702)) == TRUE) g_WebCamState.ucBright = msg.lData; diag_printf("Image brightness is %d\n",g_WebCamState.ucBright); break; case MSG_SPEAKER_VOLUME: if(( W99702_SetSpeakerVolume((int)msg.lData,&g_dataW99702))==TRUE) g_WebCamState.ucSpeakerVolume = msg.lData; diag_printf("Speaker volume is %d\n",g_WebCamState.ucSpeakerVolume); break; case MSG_MIC_VOLUME: if(( W99702_SetMicVolume((int)msg.lData,&g_dataW99702))==TRUE) g_WebCamState.ucMicVolume = msg.lData; diag_printf("mic volume is %d\n",g_WebCamState.ucMicVolume); break; case MSG_SET_LOGO: { int i; wb702EnableDrawImageTime(false); for(i = 0; i < 2; i++) { switch(g_ConfigParam.ShowPos[i]) { case 0: wb702SetDrawContent(i, g_ConfigParam.ShowString[i],0,0); break; case 1: wb702SetDrawContent(i, g_ConfigParam.ShowString[i],-1,0); break; case 2: wb702SetDrawContent(i, g_ConfigParam.ShowString[i],0,-1); break; case 3: wb702SetDrawContent(i, g_ConfigParam.ShowString[i],-1,-1); break; default: break; } diag_printf("show string %s at position %d\n",g_ConfigParam.ShowString[i],g_ConfigParam.ShowPos[i]); } break; } default: diag_printf("Unknown msg: %d\n", msg.lMsg); } } } //Audio_Exit(); W99702_CloseCamera(&g_dataW99702); g_WebCamState.ucCamera = CAMERA_OFF; #ifdef RECORDER Do_TestSendMail(&plPic2Mail, &tMail, TRUE); #endif }
void Do_TestSendMail(LIST **pplPic2Mail, time_t *ptLastMail, BOOL bForceSend) { char *pcContent; int i; int iLenList; time_t tThisMail; iLenList = httpGetListLength(*pplPic2Mail); cyg_mutex_lock(&g_ptmConfigParam); tThisMail = mytime(); if ( iLenList > 0 && (bForceSend || iLenList >= MAX_IMAGE_IN_ON_MAIL || tThisMail - *ptLastMail > 10)) { if (g_ConfigParam.acMailSender[0] != '\0' && g_ConfigParam.acMailReceiver[0] != '\0' && g_ConfigParam.acMailServer[0] != '\0') { int j; LISTNODE *pNode; FILE_BUF_T *pFb; MAIL_MEM* mail_mem = NULL; pcContent = malloc(256 * iLenList + strlen(g_cst_pcHtmlTemplate1) + strlen(g_cst_pcHtmlTemplate2)); if (pcContent != NULL) { j = 0; j += sprintf(pcContent+j, "%s", g_cst_pcHtmlTemplate1); if (*pplPic2Mail != NULL) { for (i=0, pNode = (*pplPic2Mail)->pFirstNode; pNode != (*pplPic2Mail)->pLastNode && i<iLenList; pNode = pNode->pNextNode, i++) { pFb = (FILE_BUF_T *)pNode->pValue; if (pFb) { char acTime[32]; time_t tRealTime; struct tm tmGRealTime; cyg_mutex_lock(&g_ptmTimeSetting); tRealTime = pFb->st.st_mtime + g_lTimeDelay1970_InSec - (GetSystemTimeZone() + g_lTimeDelayZone_InSec); cyg_mutex_unlock(&g_ptmTimeSetting); //cyg_thread_yield(); gmtime_r(&tRealTime, &tmGRealTime); asctime_r(&tmGRealTime, acTime); j += sprintf(pcContent+j, "<font id=oTimeList>%s:</font><br><img id=oImgList src='cid:Attachment%d'><p>", acTime, i); } } } j += sprintf(pcContent+j, "%s", g_cst_pcHtmlTemplate2); if(get_mail_mem(&mail_mem) == FALSE) diag_printf("Not enough mail memory!\n"); else { sendMailMsg( g_ConfigParam.acMailSender, g_ConfigParam.acMailReceiver,"","", (g_ConfigParam.acMailSubject[0]=='\0'?"Web Camera Warning!":g_ConfigParam.acMailSubject), pcContent, 1, *pplPic2Mail, g_ConfigParam.acMailServer, g_ConfigParam.acMailUser, (g_ConfigParam.bMailCheck?g_ConfigParam.acMailPassword:NULL), MAIL_MOTION_DETECTED, mail_mem); } free(pcContent); } else PRINT_MEM_OUT; } else g_WebCamState.ucEmail = '\2'; DeleteFileList(*pplPic2Mail); *pplPic2Mail = (LIST*)CreateFileList(); *ptLastMail = tThisMail; } cyg_mutex_unlock(&g_ptmConfigParam); //cyg_thread_yield(); }
int BatchedFolderRegistration( int argc, char* argv[] ) { ctkCommandLineParser parser; parser.setArgumentPrefix("--","-"); // Add command line argument names parser.addArgument("help", "h",ctkCommandLineParser::Bool, "Show this help text"); parser.addArgument("xml", "x",ctkCommandLineParser::Bool, "Print a XML description of this modules command line interface"); //parser.addArgument("usemask", "u", QVariant::Bool, "Use segmentations (derived resources) to exclude areas from registration metrics"); parser.addArgument("input", "i", ctkCommandLineParser::String, "Input folder",us::Any(),false); parser.addArgument("output", "o", ctkCommandLineParser::String, "Output folder (ending with /)",us::Any(),false); parser.addArgument("fixed", "f", ctkCommandLineParser::String, "Suffix for fixed image",us::Any(),false); parser.addArgument("moving", "m", ctkCommandLineParser::String, "Suffix for moving images",us::Any(),false); parser.addArgument("derived", "d", ctkCommandLineParser::String, "Derived resources suffixes (replaces suffix for moving images); comma separated",us::Any(),true); parser.addArgument("silent", "s", ctkCommandLineParser::Bool, "No xml progress output."); // Feature currently disabled //parser.addArgument("resample", "r", QVariant::String, "Reference Image for resampling (optional), is not applied to tensor data"); map<string, us::Any> parsedArgs = parser.parseArguments(argc, argv); // Handle special arguments bool silent = false; { if (parsedArgs.size() == 0) { MITK_ERROR << "Missig arguements" ; return EXIT_FAILURE; } if (parsedArgs.count("xml")) { MITK_ERROR << "This is to be handled by shell script"; return EXIT_SUCCESS; } if (parsedArgs.count("silent")) silent = true; // Show a help message if ( parsedArgs.count("help") || parsedArgs.count("h")) { std::cout << parser.helpText(); return EXIT_SUCCESS; } } std::string outputPath = us::any_cast<string>(parsedArgs["output"]); std::string refPattern = us::any_cast<string>(parsedArgs["fixed"]); std::string inputPath = us::any_cast<string>(parsedArgs["input"]); std::string movingImgPattern = us::any_cast<string>(parsedArgs["moving"]); //QString resampleReference = parsedArgs["resample"].toString(); //bool maskTumor = parsedArgs["usemask"].toBool(); // if derived sources pattern is provided, populate QStringList with possible filename postfixes std::vector<std::string> derPatterns; if (parsedArgs.count("derived") || parsedArgs.count("d") ) { std::string arg = us::any_cast<string>(parsedArgs["derived"]); derPatterns = split(arg ,','); } MITK_INFO << "Input Folder : " << inputPath; MITK_INFO << "Looking for reference image ..."; FileListType referenceFileList = CreateFileList(inputPath,refPattern); if (referenceFileList.size() != 1) { MITK_ERROR << "None or more than one possible reference images (" << refPattern <<") found. Exiting." << referenceFileList.size(); MITK_INFO << "Choose a fixed arguement that is unique in the given folder!"; return EXIT_FAILURE; } std::string referenceFileName = referenceFileList.at(0); MITK_INFO << "Loading Reference (fixed) image: " << referenceFileName; mitk::Image::Pointer refImage = mitk::IOUtil::LoadImage(referenceFileName); if (refImage.IsNull()) MITK_ERROR << "Loaded fixed image is NULL"; // Copy reference image to destination std::string savePathAndFileName = GetSavePath(outputPath, referenceFileName); mitk::IOUtil::SaveImage(refImage, savePathAndFileName); // Copy all derived resources also to output folder, adding _reg suffix referenceFileList = CreateDerivedFileList(referenceFileName, movingImgPattern,derPatterns); CopyResources(referenceFileList, outputPath); std::string derivedResourceFilename; mitk::Image::Pointer referenceMask = NULL; // union of all segmentations if (!silent) { // XML Output to report progress std::cout << "<filter-start>"; std::cout << "<filter-name>Batched Registration</filter-name>"; std::cout << "<filter-comment>Starting registration ... </filter-comment>"; std::cout << "</filter-start>"; } // Now iterate over all files and register them to the reference image, // also register derived resources based on file patterns // ------------------------------------------------------------------------------ // Create File list FileListType movingImagesList = CreateFileList(inputPath, movingImgPattern); // TODO Reactivate Resampling Feature // mitk::Image::Pointer resampleImage = NULL; // if (QFileInfo(resampleReference).isFile()) // { // resampleImage = mitk::IOUtil::LoadImage(resampleReference.toStdString()); // } for (unsigned int i =0; i < movingImagesList.size(); i++) { std::string fileMorphName = movingImagesList.at(i); if (fileMorphName == referenceFileName) { // do not process reference image again continue; } MITK_INFO << "Processing image " << fileMorphName; // 1 Register morphological file to reference image if (!itksys::SystemTools::FileExists(fileMorphName.c_str())) { MITK_WARN << "File does not exit. Skipping entry."; continue; } // Origin of images is cancelled // TODO make this optional!! double transf[6]; double offset[3]; { mitk::Image::Pointer movingImage = mitk::IOUtil::LoadImage(fileMorphName); MITK_ERROR << "REF COUNT MOVING 0 " << movingImage->GetReferenceCount(); if (movingImage.IsNull()) MITK_ERROR << "Loaded moving image is NULL"; // Store transformation, apply it to morph file MITK_INFO << "----------Registering moving image to reference----------"; MITK_ERROR << "REF COUNT MOVING 1 " << movingImage->GetReferenceCount(); //mitk::RegistrationWrapper::GetTransformation(refImage, movingImage, transf, offset, referenceMask); MITK_ERROR << "REF COUNT MOVING 2 " << movingImage->GetReferenceCount(); mitk::RegistrationWrapper::ApplyTransformationToImage(movingImage, transf,offset, NULL); // , resampleImage MITK_ERROR << "REF COUNT MOVING 3 " << movingImage->GetReferenceCount(); savePathAndFileName = GetSavePath(outputPath, fileMorphName); std::string fileType = itksys::SystemTools::GetFilenameExtension(fileMorphName); SaveImage(savePathAndFileName,movingImage,fileType ); } if (!silent) { std::cout << "<filter-progress-text progress=\"" << (float)i / (float)movingImagesList.size() << "\" >.</filter-progress-text>"; } // Now parse all derived resource and apply the above calculated transformation to them // ------------------------------------------------------------------------------------ FileListType fList = CreateDerivedFileList(fileMorphName, movingImgPattern,derPatterns); if (fList.size() > 0) MITK_INFO << "----------DERIVED RESOURCES ---------"; for (unsigned int j=0; j < fList.size(); j++) { derivedResourceFilename = fList.at(j); MITK_INFO << "----Processing derived resource " << derivedResourceFilename << " ..."; mitk::Image::Pointer derivedMovingResource = mitk::IOUtil::LoadImage(derivedResourceFilename); // Apply transformation to derived resource, treat derived resource as binary mitk::RegistrationWrapper::ApplyTransformationToImage(derivedMovingResource, transf,offset, NULL, true); savePathAndFileName = GetSavePath(outputPath, derivedResourceFilename); std::string fileType = itksys::SystemTools::GetFilenameExtension(derivedResourceFilename); SaveImage(savePathAndFileName,derivedMovingResource,fileType ); } } if (!silent) std::cout << "<filter-end/>"; return EXIT_SUCCESS; }
int main(int argc,char *argv[]) { int i=0,t1,t2,k; FILE *fsft1,*fsft2; size_t ecode; /* Reads command line arguments into the CommandLineArgs struct. In the absence of command line arguments it sets some defaults */ if (ReadCommandLine(argc,argv,&CommandLineArgs)) return 1; /* Sets global variables and sticks them into the GlobalVariables struct */ if (CreateFileList(CommandLineArgs)) return 2; if (AllocateMem(CommandLineArgs)) return 3; while(i<filenumber) { fsft1=fopen(filelist[i],"r"); /* read in the header from the file */ ecode=fread((void*)&header,sizeof(header),1,fsft1); if (ecode!=1) { fprintf(stderr,"No header in data file %s\n",filelist[i]); return 1; } /* check that data is correct endian order */ if (header.endian!=1.0) { fprintf(stderr,"First object in file %s is not (double)1.0!\n",filelist[i]); fprintf(stderr,"It could be a file format error (big/little\n"); fprintf(stderr,"endian) or the file might be corrupted\n\n"); return 2; } fclose(fsft1); t1=header.gps_sec; timestamps.gpsSeconds=header.gps_sec; timestamps.gpsNanoSeconds=header.gps_nsec; fsft2=fopen(filelist[i+CommandLineArgs.number-1],"r"); /* read in the header from the file */ ecode=fread((void*)&header,sizeof(header),1,fsft2); if (ecode!=1) { fprintf(stderr,"No header in data file %s\n",filelist[i]); return 1; } /* check that data is correct endian order */ if (header.endian!=1.0) { fprintf(stderr,"First object in file %s is not (double)1.0!\n",filelist[i]); fprintf(stderr,"It could be a file format error (big/little\n"); fprintf(stderr,"endian) or the file might be corrupted\n\n"); return 2; } fclose(fsft2); t2=header.gps_sec+sTsft; /* if( (int)((t2-t1)/lTsft +0.5) == 1) */ /* { */ fprintf(stdout,"Combining SFTs %d thru %d\n",i,i+CommandLineArgs.number-1); /* Have CommandLineArgs.number consecutive SFTs */ if (ReadSFTs(CommandLineArgs,i)) return 3; if (CSFTs(CommandLineArgs)) return 4; i += CommandLineArgs.number; /* } */ /* else i++; */ } /* Free the SFT data */ for (k=0;k<CommandLineArgs.number;k++) { LALFree(SFTData[k]->fft->data->data); LALFree(SFTData[k]->fft->data); LALFree(SFTData[k]->fft); LALFree(SFTData[k]); } LALFree(SFTData); LALFree(sinVal); LALFree(cosVal); LALCheckMemoryLeaks(); return 0; }
int main( int argc, char* argv[] ) { mitkCommandLineParser parser; parser.setArgumentPrefix("--","-"); parser.setTitle("Folder Registration"); parser.setCategory("Preprocessing Tools"); parser.setDescription("For detail description see http://docs.mitk.org/nightly/DiffusionMiniApps.html"); parser.setContributor("MBI"); // Add command line argument names parser.addArgument("help", "h",mitkCommandLineParser::Bool, "Help", "Show this help text"); //parser.addArgument("usemask", "u", QVariant::Bool, "Use segmentations (derived resources) to exclude areas from registration metrics"); parser.addArgument("input", "i", mitkCommandLineParser::InputDirectory, "Input:", "Input folder",us::Any(),false); parser.addArgument("output", "o", mitkCommandLineParser::OutputDirectory, "Output:", "Output folder (ending with /)",us::Any(),false); parser.addArgument("fixed", "f", mitkCommandLineParser::String, "Fixed images:", "Suffix for fixed image (if none is supplied first file matching moving pattern is chosen)",us::Any(),true); parser.addArgument("moving", "m", mitkCommandLineParser::String, "Moving images:", "Suffix for moving images",us::Any(),false); parser.addArgument("derived", "d", mitkCommandLineParser::String, "Derived resources:", "Derived resources suffixes (replaces suffix for moving images); comma separated",us::Any(),true); parser.addArgument("silent", "s", mitkCommandLineParser::Bool, "Silent:", "No xml progress output."); parser.addArgument("resample", "r", mitkCommandLineParser::String, "Resample (x,y,z)mm:", "Resample provide x,y,z spacing in mm (e.g. -r 1,1,3), is not applied to tensor data",us::Any()); parser.addArgument("binary", "b", mitkCommandLineParser::Bool, "Binary:", "Speficies that derived resource are binary (interpolation using nearest neighbor)",us::Any()); parser.addArgument("correct-origin", "c", mitkCommandLineParser::Bool, "Origin correction:", "Correct for large origin displacement. Use switch when you reveive: Joint PDF summed to zero ",us::Any()); parser.addArgument("sinc-int", "s", mitkCommandLineParser::Bool, "Windowed-sinc interpolation:", "Use windowed-sinc interpolation (3) instead of linear interpolation ",us::Any()); map<string, us::Any> parsedArgs = parser.parseArguments(argc, argv); // Handle special arguments bool silent = false; bool isBinary = false; bool alignOrigin = false; bool useLinearInterpol = true; { if (parsedArgs.size() == 0) { return EXIT_FAILURE; } if (parsedArgs.count("sinc-int")) useLinearInterpol = false; if (parsedArgs.count("silent")) silent = true; if (parsedArgs.count("binary")) isBinary = true; if (parsedArgs.count("correct-origin")) alignOrigin = true; // Show a help message if ( parsedArgs.count("help") || parsedArgs.count("h")) { std::cout << parser.helpText(); return EXIT_SUCCESS; } } std::string refPattern = ""; bool useFirstMoving = false; std::string movingImgPattern = us::any_cast<string>(parsedArgs["moving"]); if (parsedArgs.count("fixed")) { refPattern = us::any_cast<string>(parsedArgs["fixed"]); } else { useFirstMoving = true; refPattern = movingImgPattern; } std::string outputPath = us::any_cast<string>(parsedArgs["output"]); std::string inputPath = us::any_cast<string>(parsedArgs["input"]); //QString resampleReference = parsedArgs["resample"].toString(); //bool maskTumor = parsedArgs["usemask"].toBool(); // if derived sources pattern is provided, populate QStringList with possible filename postfixes std::vector<std::string> derPatterns; if (parsedArgs.count("derived") || parsedArgs.count("d") ) { std::string arg = us::any_cast<string>(parsedArgs["derived"]); derPatterns = split(arg ,','); } std::vector<std::string> spacings; float spacing[3]; bool doResampling = false; if (parsedArgs.count("resample") || parsedArgs.count("d") ) { std::string arg = us::any_cast<string>(parsedArgs["resample"]); spacings = split(arg ,','); spacing[0] = atoi(spacings.at(0).c_str()); spacing[1] = atoi(spacings.at(1).c_str()); spacing[2] = atoi(spacings.at(2).c_str()); doResampling = true; } MITK_INFO << "Input Folder : " << inputPath; MITK_INFO << "Looking for reference image ..."; FileListType referenceFileList = CreateFileList(inputPath,refPattern); if ((!useFirstMoving && referenceFileList.size() != 1) || (useFirstMoving && referenceFileList.size() == 0)) { MITK_ERROR << "None or more than one possible reference images (" << refPattern <<") found. Exiting." << referenceFileList.size(); MITK_INFO << "Choose a fixed arguement that is unique in the given folder!"; return EXIT_FAILURE; } std::string referenceFileName = referenceFileList.at(0); MITK_INFO << "Loading Reference (fixed) image: " << referenceFileName; std::string fileType = itksys::SystemTools::GetFilenameExtension(referenceFileName); mitk::Image::Pointer refImage = ExtractFirstTS(mitk::IOUtil::LoadImage(referenceFileName), fileType); mitk::Image::Pointer resampleReference = NULL; if (doResampling) { refImage = ResampleBySpacing(refImage,spacing); resampleReference = refImage; } if (refImage.IsNull()) MITK_ERROR << "Loaded fixed image is NULL"; // Copy reference image to destination std::string savePathAndFileName = GetSavePath(outputPath, referenceFileName); mitk::IOUtil::SaveImage(refImage, savePathAndFileName); // Copy all derived resources also to output folder, adding _reg suffix referenceFileList = CreateDerivedFileList(referenceFileName, movingImgPattern,derPatterns); CopyResources(referenceFileList, outputPath); std::string derivedResourceFilename; mitk::Image::Pointer referenceMask = NULL; // union of all segmentations if (!silent) { // XML Output to report progress std::cout << "<filter-start>"; std::cout << "<filter-name>Batched Registration</filter-name>"; std::cout << "<filter-comment>Starting registration ... </filter-comment>"; std::cout << "</filter-start>"; } // Now iterate over all files and register them to the reference image, // also register derived resources based on file patterns // ------------------------------------------------------------------------------ // Create File list FileListType movingImagesList = CreateFileList(inputPath, movingImgPattern); // TODO Reactivate Resampling Feature // mitk::Image::Pointer resampleImage = NULL; // if (QFileInfo(resampleReference).isFile()) // { // resampleImage = mitk::IOUtil::LoadImage(resampleReference.toStdString()); // } for (unsigned int i =0; i < movingImagesList.size(); i++) { std::string fileMorphName = movingImagesList.at(i); if (fileMorphName == referenceFileName) { // do not process reference image again continue; } MITK_INFO << "Processing image " << fileMorphName; // 1 Register morphological file to reference image if (!itksys::SystemTools::FileExists(fileMorphName.c_str())) { MITK_WARN << "File does not exit. Skipping entry."; continue; } // Origin of images is cancelled // TODO make this optional!! double transf[6]; double offset[3]; { std::string fileType = itksys::SystemTools::GetFilenameExtension(fileMorphName); mitk::Image::Pointer movingImage = ExtractFirstTS(mitk::IOUtil::LoadImage(fileMorphName), fileType); if (movingImage.IsNull()) MITK_ERROR << "Loaded moving image is NULL"; // Store transformation, apply it to morph file MITK_INFO << "----------Registering moving image to reference----------"; mitk::RegistrationWrapper::GetTransformation(refImage, movingImage, transf, offset, alignOrigin, referenceMask); mitk::RegistrationWrapper::ApplyTransformationToImage(movingImage, transf,offset, resampleReference); // , resampleImage savePathAndFileName = GetSavePath(outputPath, fileMorphName); if (fileType == ".dwi") fileType = "dwi"; if (movingImage->GetData() == nullptr) MITK_INFO <<"POST DATA is null"; mitk::IOUtil::Save(movingImage, savePathAndFileName); } if (!silent) { std::cout << "<filter-progress-text progress=\"" << (float)i / (float)movingImagesList.size() << "\" >.</filter-progress-text>"; } // Now parse all derived resource and apply the above calculated transformation to them // ------------------------------------------------------------------------------------ FileListType fList = CreateDerivedFileList(fileMorphName, movingImgPattern,derPatterns); if (fList.size() > 0) MITK_INFO << "----------DERIVED RESOURCES ---------"; for (unsigned int j=0; j < fList.size(); j++) { derivedResourceFilename = fList.at(j); MITK_INFO << "----Processing derived resorce " << derivedResourceFilename << " ..."; std::string fileType = itksys::SystemTools::GetFilenameExtension(derivedResourceFilename); mitk::Image::Pointer derivedMovingResource = ExtractFirstTS(mitk::IOUtil::LoadImage(derivedResourceFilename), fileType); // Apply transformation to derived resource, treat derived resource as binary mitk::RegistrationWrapper::ApplyTransformationToImage(derivedMovingResource, transf,offset, resampleReference,isBinary); savePathAndFileName = GetSavePath(outputPath, derivedResourceFilename); mitk::IOUtil::SaveImage(derivedMovingResource, savePathAndFileName); } } if (!silent) std::cout << "<filter-end/>"; return EXIT_SUCCESS; }
void Application::ShowMainGUIWindow() { //Settings ImVec4 const headingClr(1.0f, 0.0f, 1.0f, 1.0f); int const nSpacing = 3; float const sliderOffset = -90.0f; float const vRotMins[2] = { 0.0f, 0.0f }; float const vRotMaxs[2] = { Dg::Constants<float>::PI * 2.0f, Dg::Constants<float>::PI }; char const * vRotformats[2] = { "yaw = %.2f", "pitch = %.2f" }; float const powers2[2] = { 1.0f, 1.0f }; float const posMins[3] = { -10.0f, -10.0f, -10.0f }; float const posMaxs[3] = { 10.0f, 10.0f, 10.0f }; char const * posFormats[3] = { "x = %.2f", "y = %.2f", "z = %.2f" }; float const powers3[3] = { 1.0f, 1.0f, 1.0f }; //Statics for saving... static int save_currentItem = -1; static int save_lastItem = -2; static char save_buf[128] = {}; static std::string save_finalFile; //Statics for opening... static int open_currentItem = -1; ImGui::Begin("Editor"); //---------------------------------------------------------------------------------- // Menu Bar //---------------------------------------------------------------------------------- if (ImGui::BeginMenuBar()) { if (ImGui::BeginMenu("File")) { if (ImGui::MenuItem("New")) { m_windowStack.push(Modal::NewProjectRequest); if (m_projData.dirty) { m_windowStack.push(Modal::SavePrompt); } } if (ImGui::MenuItem("Open")) { m_windowStack.push(Modal::OpenWindow); if (m_projData.dirty) { m_windowStack.push(Modal::SavePrompt); } } if (ImGui::MenuItem("Save")) { if (m_projData.name == "") { m_windowStack.push(Modal::SaveAsWindow); } else { Event_SaveProject e; e.SetFileName(m_projectPath + m_projData.name + "." + m_fileExt); m_eventManager.PushEvent(e); } } if (ImGui::MenuItem("Save As..")) { m_windowStack.push(Modal::SaveAsWindow); } ImGui::Separator(); if (ImGui::MenuItem("Quit", "Esc")) { m_shouldQuit = true; } ImGui::EndMenu(); } if (ImGui::BeginMenu("Options")) { ImGui::MenuItem("Example UI", NULL, &UI::showExampleWindow); ImGui::Separator(); ImGui::MenuItem("Blending", NULL, &UI::showAlphaBlendingWindow); ImGui::MenuItem("Metrics", NULL, &UI::showMetrics); ImGui::EndMenu(); } if (ImGui::BeginMenu("Help")) { if (ImGui::MenuItem("View Help", NULL, &UI::showHelp)) { m_windowStack.push(Modal::ViewHelp); } ImGui::Separator(); if (ImGui::MenuItem("About", NULL, &UI::showAbout)) { m_windowStack.push(Modal::ViewAbout); } ImGui::EndMenu(); } ImGui::EndMenuBar(); } //---------------------------------------------------------------------------------- // Help Window //---------------------------------------------------------------------------------- if (!m_windowStack.empty() && m_windowStack.top() == Modal::ViewHelp) { ImGui::OpenPopup("Help"); } if (ImGui::BeginPopupModal("Help", NULL, ImGuiWindowFlags_AlwaysAutoResize)) { ImGui::Text("Helpful tips:"); ImGui::BulletText("Add / remove particle emitters and attractors."); ImGui::BulletText("Unchecking the 'Relative Force' option may increase performance"); ImGui::Text(""); ImGui::SameLine(ImGui::GetWindowWidth() - 140.0f); if (ImGui::Button("OK", ImVec2(130, 0))) { UI::showHelp = false; m_windowStack.pop(); ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } //---------------------------------------------------------------------------------- // About Window //---------------------------------------------------------------------------------- if (!m_windowStack.empty() && m_windowStack.top() == Modal::ViewAbout) { ImGui::OpenPopup("About"); } if (ImGui::BeginPopupModal("About", NULL, ImGuiWindowFlags_AlwaysAutoResize)) { ImGui::Text("A simple particle system using components from the Dg library."); if (ImGui::Button("OK", ImVec2(130, 0))) { UI::showAbout = false; m_windowStack.pop(); ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } //---------------------------------------------------------------------------------- // New Project created info box //---------------------------------------------------------------------------------- if (!m_windowStack.empty() && m_windowStack.top() == Modal::NewProjectRequest) { Event_NewProject e; m_eventManager.PushEvent(e); m_windowStack.pop(); } //---------------------------------------------------------------------------------- // Save Prompt //---------------------------------------------------------------------------------- if (!m_windowStack.empty() && m_windowStack.top() == Modal::SavePrompt) { ImGui::OpenPopup("Save current Project?"); } if (ImGui::BeginPopupModal("Save current Project?", NULL, ImGuiWindowFlags_AlwaysAutoResize)) { bool finished = false; if (ImGui::Button("Yes", ImVec2(80, 0))) { m_windowStack.pop(); m_windowStack.push(Modal::SaveAsWindow); ImGui::CloseCurrentPopup(); } ImGui::SameLine(); if (ImGui::Button("No", ImVec2(80, 0))) { m_windowStack.pop(); ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } //---------------------------------------------------------------------------------- // Overwrite Prompt //---------------------------------------------------------------------------------- if (!m_windowStack.empty() && m_windowStack.top() == Modal::OverwriteWindow) { ImGui::OpenPopup("Overwrite?"); } if (ImGui::BeginPopupModal("Overwrite?", NULL, ImGuiWindowFlags_AlwaysAutoResize)) { ImGui::Text("File already exists. Overwrite?"); if (ImGui::Button("Yes", ImVec2(80, 0))) { //Save... m_projData.name = std::string(save_buf); Event_SaveProject e; e.SetFileName(save_finalFile); m_eventManager.PushEvent(e); //Reset memset(save_buf, 0, sizeof(save_buf) / sizeof(char)); save_lastItem = -2; save_currentItem = -1; m_windowStack.pop(); ImGui::CloseCurrentPopup(); } ImGui::SameLine(); if (ImGui::Button("No", ImVec2(80, 0))) { m_windowStack.pop(); m_windowStack.push(Modal::SaveAsWindow); ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } //---------------------------------------------------------------------------------- // Save As Window //---------------------------------------------------------------------------------- if (!m_windowStack.empty() && m_windowStack.top() == Modal::SaveAsWindow) { ImGui::OpenPopup("Save As.."); } if (ImGui::BeginPopupModal("Save As..", NULL, ImGuiWindowFlags_AlwaysAutoResize)) { std::vector<std::string> files = GetProjects(); CreateFileList(files, "Files", &save_currentItem); if (save_currentItem != save_lastItem && save_currentItem >= 0) { strcpy_s(save_buf, 128, files[save_currentItem].data()); save_lastItem = save_currentItem; } ImGui::InputText("File name", save_buf, 128); bool shouldClose = false; bool shouldReset = true; if (ImGui::Button("Save", ImVec2(120, 0))) { save_finalFile = m_projectPath + std::string(save_buf); std::string dotExt = std::string(".") + m_fileExt; if (save_finalFile.rfind(dotExt) != save_finalFile.size() - 4) { save_finalFile += dotExt; } m_windowStack.pop(); shouldClose = true; if (FileExists(save_finalFile)) { m_windowStack.push(Modal::OverwriteWindow); shouldReset = false; } else { //Save... m_projData.name = std::string(save_buf); Event_SaveProject e; e.SetFileName(save_finalFile); m_eventManager.PushEvent(e); } } ImGui::SameLine(); if (ImGui::Button("Cancel", ImVec2(120, 0))) { m_windowStack.pop(); shouldClose = true; } if (shouldClose) { if (shouldReset) { memset(save_buf, 0, sizeof(save_buf) / sizeof(save_buf[0])); save_lastItem = -2; save_currentItem = -1; } ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } //---------------------------------------------------------------------------------- // Open Project Window //---------------------------------------------------------------------------------- if (!m_windowStack.empty() && m_windowStack.top() == Modal::OpenWindow) { ImGui::OpenPopup("Open file"); } if (ImGui::BeginPopupModal("Open file", NULL, ImGuiWindowFlags_AlwaysAutoResize)) { std::vector<std::string> files = GetProjects(); CreateFileList(files, "Files", &open_currentItem); bool finished = false; if (ImGui::Button("Open", ImVec2(120, 0))) { if (open_currentItem != -1) { m_projData.name = files[open_currentItem]; Event_LoadProject e; e.SetFileName(m_projectPath + files[open_currentItem]); m_eventManager.PushEvent(e); } finished = true; } ImGui::SameLine(); if (ImGui::Button("Cancel", ImVec2(120, 0))) { finished = true; } if (finished) { open_currentItem = -1; m_windowStack.pop(); ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } //---------------------------------------------------------------------------------- // General particle sytem options //---------------------------------------------------------------------------------- if (ImGui::CollapsingHeader("Particle system options", ImGuiTreeNodeFlags_DefaultOpen)) { ImGui::TextColored(headingClr, "Optional updaters"); ImGui::Checkbox("Color", &m_projData.parSysOpts[0].useUpdaterColor); ImGui::Checkbox("Size", &m_projData.parSysOpts[0].useUpdaterSize); ImGui::Checkbox("Relative force", &m_projData.parSysOpts[0].useUpdaterRelativeForce); } //---------------------------------------------------------------------------------- // Emitters //---------------------------------------------------------------------------------- if (ImGui::CollapsingHeader("Emitters", ImGuiTreeNodeFlags_DefaultOpen)) { if (ImGui::Button("Add Emitter")) { m_projData.newEmitters++; } ImGui::SameLine(); if (ImGui::Button("Kill Emitter") && m_projData.emitterFocus >= 0 && m_projData.emitterFocus < m_projData.eData.size()) { m_projData.eData[m_projData.emitterFocus].first.shouldDie = true; } //This doesn't work :( Have to use char** //typedef char inner_array_t[32]; //inner_array_t * currentEmitters = new inner_array_t[4]; char ** currentEmitters = new char*[m_projData.eData.size()]; for (int i = 0; i < m_projData.eData.size(); ++i) { currentEmitters[i] = new char[32](); sprintf_s(currentEmitters[i], 32, "Emitter %i", m_projData.eData[i].first.ID); } ImGui::PushItemWidth(sliderOffset); ImGui::ListBox("Emitter", &m_projData.emitterFocus, (char const **)currentEmitters, (int)m_projData.eData.size(), 5); ImGui::PopItemWidth(); ImGui::Separator(); for (int i = 0; i < m_projData.eData.size(); ++i) { delete[] currentEmitters[i]; } delete[] currentEmitters; if (m_projData.eData.size() > 0) { EmitterData & curEmData = m_projData.eData[m_projData.emitterFocus].first; CreateSpacing(nSpacing); ImGui::Checkbox("Turn emitter off/on", &curEmData.on); CreateSpacing(nSpacing); ImGui::TextColored(headingClr, "Emission method"); ImGui::RadioButton("Linear", &curEmData.type, E_Emitter_Linear); ImGui::SameLine(); ImGui::RadioButton("Random", &curEmData.type, E_Emitter_Random); CreateSpacing(nSpacing); ImGui::TextColored(headingClr, "Define emitter shape"); ImGui::RadioButton("Point", &curEmData.posGenMethod, E_GenPosPoint); ImGui::SameLine(); //ImGui::RadioButton("Box", &curEmData.posGenMethod, E_GenPosBox); ImGui::SameLine(); ImGui::RadioButton("Sphere", &curEmData.posGenMethod, E_GenPosSphere); if (curEmData.posGenMethod == E_GenPosBox) { float mins[3] = { 0.0f, 0.0f, 0.0f }; float maxs[3] = { 10.0f, 10.0f, 10.0f }; char const * formats[3] = { "l = %.2f", "w = %.2f", "h = %.2f" }; ImGui::PushItemWidth(sliderOffset); ImGui::SliderFloatNi("Dimensions", &curEmData.boxDim[0], 3, mins, maxs, formats, powers3); ImGui::PopItemWidth(); } if (curEmData.posGenMethod == E_GenPosSphere) { CreateSpacing(nSpacing); ImGui::TextColored(headingClr, "Define sphere geometry"); ImGui::PushItemWidth(sliderOffset); ImGui::SliderFloat("Radius", &curEmData.transform[6], 0.0f, 10.0f, "%.1f"); ImGui::PopItemWidth(); } { CreateSpacing(nSpacing); ImGui::TextColored(headingClr, "Place Emitter"); ImGui::PushItemWidth(sliderOffset); ImGui::SliderFloatNi("Position", &curEmData.transform[0], 3, posMins, posMaxs, posFormats, powers3); ImGui::PopItemWidth(); } //TODO 2D placer //if (UI::showEmitterPlacer) //{ //ImGui::Begin("Place Emitter"); ImGui::PushStyleColor(ImGuiCol_Button, ImColor::HSV(1 / 7.0f, 0.6f, 0.6f)); //ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImColor::HSV(1 / 7.0f, 0.7f, 0.6f)); //ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImColor::HSV(1 / 7.0f, 0.8f, 0.6f)); //ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0)); //ImGui::Button("Drag Me", ImVec2(100.0f, 100.0f)); //ImGui::PopStyleVar(); //ImGui::PopStyleColor(3); //if (ImGui::IsItemActive()) //{ //ImVec2 rect_min = ImGui::GetItemRectMin(); //ImVec2 rect_max = ImGui::GetItemRectMax(); // //ImVec2 relPos; //relPos.x = (ImGui::GetIO().MousePos.x - rect_min.x) / (rect_max.x / rect_min.x); //relPos.y = (ImGui::GetIO().MousePos.y - rect_min.y) / (rect_max.y / rect_min.y); // //ImGui::Text("Rel pos (%.1f, %.1f)", relPos.x, relPos.y); //} //if (ImGui::Button("Close")) //{ //UI::showEmitterPlacer = false; //} //ImGui::End(); //} if (curEmData.posGenMethod == E_GenPosBox) { float mins[3] = { 0.0f, 0.0f, 0.0f }; float maxs[3] = { Dg::Constants<float>::PI * 2.0f, Dg::Constants<float>::PI * 2.0f, Dg::Constants<float>::PI * 2.0f }; char const * formats[3] = { "rz = %.2f", "ry = %.2f", "rx = %.2f" }; float powers[3] = { 1.0f, 1.0f, 1.0f }; ImGui::PushItemWidth(sliderOffset); ImGui::SliderFloatNi("Rotation", &curEmData.transform[3], 3, mins, maxs, formats, powers); ImGui::PopItemWidth(); } CreateSpacing(nSpacing); ImGui::TextColored(headingClr, "Define Initial velocity vector"); ImGui::RadioButton("Direction", &curEmData.velGenMethod, E_GenVelCone); ImGui::SameLine(); ImGui::RadioButton("Outwards", &curEmData.velGenMethod, E_GenVelOutwards); if (curEmData.velGenMethod == E_GenVelCone) { float mins[3] = { 0.0f, 0.0f, 0.0f }; float maxs[3] = { Dg::Constants<float>::PI * 2.0f, Dg::Constants<float>::PI, Dg::Constants<float>::PI }; char const * formats[3] = { "yaw = %.2f", "pitch = %.2f", "spread = %.2f" }; float powers[3] = { 1.0f, 1.0f, 1.0f }; ImGui::PushItemWidth(sliderOffset); ImGui::SliderFloatNi("yaw, pitch, sprd", &curEmData.velCone[0], 3, mins, maxs, formats, powers); ImGui::PopItemWidth(); } CreateSpacing(nSpacing); ImGui::TextColored(headingClr, "Other attributes"); ImGui::PushItemWidth(sliderOffset); ImGui::ColorEdit4("Start color", curEmData.colors); ImGui::ColorEdit4("End color", &curEmData.colors[4]); ImGui::SliderFloat("Rate", &curEmData.rate, 0.0f, 500.0f, "%.2f par/s", 2.0f); ImGui::SliderFloat("Velocity", &curEmData.velocity, 0.0f, 10.0f, "%.2f m/s"); if (m_projData.parSysOpts[0].useUpdaterRelativeForce) { ImGui::SliderFloat("Rel force", &curEmData.relativeForce, 0.0f, 10.0f, "%.4f m/s", 3.0f); } ImGui::SliderFloat("Life", &curEmData.life, 0.0f, 60.0f, "%.2f s"); ImGui::SliderFloat("Start size", curEmData.sizes, 0.0f, 1.0f, "%.2f m"); ImGui::SliderFloat("End size", &curEmData.sizes[1], 0.0f, 1.0f, "%.2f m"); ImGui::PopItemWidth(); } } //---------------------------------------------------------------------------------- // Attractors //---------------------------------------------------------------------------------- if (ImGui::CollapsingHeader("Attractors", ImGuiTreeNodeFlags_DefaultOpen)) { if (ImGui::Button("Add Attractor")) { m_projData.newAttractors++; } ImGui::SameLine(); if (ImGui::Button("Kill Attractor") && m_projData.attrFocus < m_projData.aData.size() && m_projData.attrFocus >= 0) { m_projData.aData[m_projData.attrFocus].first.shouldDie = true; } char ** currentAttractors = new char*[m_projData.aData.size()]; for (int i = 0; i < m_projData.aData.size(); ++i) { currentAttractors[i] = new char[32](); sprintf_s(currentAttractors[i], 32, "Attractor %i", m_projData.aData[i].first.ID); } ImGui::PushItemWidth(sliderOffset); ImGui::ListBox("Attractor", &m_projData.attrFocus, (char const **)currentAttractors, (int)m_projData.aData.size(), 5); ImGui::PopItemWidth(); ImGui::Separator(); for (int i = 0; i < m_projData.aData.size(); ++i) { delete[] currentAttractors[i]; } delete[] currentAttractors; if (m_projData.aData.size() > 0) { CreateSpacing(nSpacing); AttractorData & curAttData = m_projData.aData[m_projData.attrFocus].first; ImGui::Checkbox("Show attractor", &curAttData.show); ImGui::TextColored(headingClr, "Attractor type"); ImGui::PushItemWidth(sliderOffset); const char* attrForces[] = { "Force is constant", "Force is a function of distance", "Force is a function of sq distance" }; ImGui::ListBox("Force", &curAttData.attenuationMethod, attrForces, ((int)(sizeof(attrForces) / sizeof(*attrForces))), 3); const char* attrShapes[] = { "Global", "Point", "Line", "Plane" }; ImGui::ListBox("Shape", &curAttData.type, attrShapes, ((int)(sizeof(attrShapes) / sizeof(*attrShapes))), 5); CreateSpacing(nSpacing); ImGui::TextColored(headingClr, "Strength"); ImGui::SliderFloat("Strength", &curAttData.strength, -100.0f, 100.0f, "%.2f m/s"); ImGui::SliderFloat("Max accel", &curAttData.maxAppliedAccelMag, 0.0f, 500.0f, "%.2f m/s", 2.0f); CreateSpacing(nSpacing); ImGui::TextColored(headingClr, "Position Attractor"); switch (curAttData.type) { case E_AttGlobal: { ImGui::SliderFloatNi("Accel dir", &curAttData.transform[3], 2, vRotMins, vRotMaxs, vRotformats, powers2); break; } case E_AttPoint: { ImGui::SliderFloatNi("Att Pos", &curAttData.transform[0], 3, posMins, posMaxs, posFormats, powers3); break; } case E_AttLine: { ImGui::SliderFloatNi("Line origin", &curAttData.transform[0], 3, posMins, posMaxs, posFormats, powers3); ImGui::SliderFloatNi("Line dir", &curAttData.transform[3], 2, vRotMins, vRotMaxs, vRotformats, powers2); break; } case E_AttPlane: { ImGui::SliderFloatNi("Normal", &curAttData.transform[3], 2, vRotMins, vRotMaxs, vRotformats, powers2); ImGui::SliderFloatNi("Plane origin", &curAttData.transform[0], 3, posMins, posMaxs, posFormats, powers3); break; } default: //E_AttNone: { break; } } ImGui::PopItemWidth(); } } ImGui::End(); }
void MainWindow::OnEditCopy(void) { CString errStr, fileList; SelectionSet selSet; UINT myFormat; bool isOpen = false; HGLOBAL hGlobal; LPVOID pGlobal; uint8_t* buf = NULL; long bufLen = -1; /* associate a number with the format name */ myFormat = RegisterClipboardFormat(kClipboardFmtName); if (myFormat == 0) { CheckedLoadString(&errStr, IDS_CLIPBOARD_REGFAILED); ShowFailureMsg(this, errStr, IDS_FAILED); goto bail; } LOGI("myFormat = %u", myFormat); /* open & empty the clipboard, even if we fail later */ if (OpenClipboard() == false) { CheckedLoadString(&errStr, IDS_CLIPBOARD_OPENFAILED); ShowFailureMsg(this, errStr, IDS_FAILED); goto bail; } isOpen = true; EmptyClipboard(); /* * Create a selection set with the entries. * * Strictly speaking we don't need the directories, since we recreate * them as needed. However, storing them explicitly will allow us * to preserve empty subdirs. */ selSet.CreateFromSelection(fpContentList, GenericEntry::kAnyThread | GenericEntry::kAllowDirectory); if (selSet.GetNumEntries() == 0) { CheckedLoadString(&errStr, IDS_CLIPBOARD_NOITEMS); MessageBox(errStr, L"No match", MB_OK | MB_ICONEXCLAMATION); goto bail; } /* * Make a big string with a file listing. */ fileList = CreateFileList(&selSet); /* * Add the string to the clipboard. The clipboard will own the memory we * allocate. */ size_t neededLen = (fileList.GetLength() + 1) * sizeof(WCHAR); hGlobal = ::GlobalAlloc(GHND | GMEM_SHARE, neededLen); if (hGlobal == NULL) { LOGI("Failed allocating %d bytes", neededLen); CheckedLoadString(&errStr, IDS_CLIPBOARD_ALLOCFAILED); ShowFailureMsg(this, errStr, IDS_FAILED); goto bail; } LOGI(" Allocated %ld bytes for file list on clipboard", neededLen); pGlobal = ::GlobalLock(hGlobal); ASSERT(pGlobal != NULL); wcscpy((WCHAR*) pGlobal, fileList); ::GlobalUnlock(hGlobal); SetClipboardData(CF_UNICODETEXT, hGlobal); /* * Create a (potentially very large) buffer with the contents of the * files in it. This may fail for any number of reasons. */ hGlobal = CreateFileCollection(&selSet); if (hGlobal != NULL) { SetClipboardData(myFormat, hGlobal); // beep annoys me on copy //SuccessBeep(); } bail: CloseClipboard(); }