void LabeledImage::load(string host) { loadMetadata(host); loadRois(host); }
int AspFrame::loadSession(char *path) { struct stat fstat; string dir=""; char sessionFile[MAXSTR2],file[MAXSTR2]; if(stat(path, &fstat) != 0) { Winfoprintf("Error: cannot find %s.",path); return 0; } else if(fstat.st_mode & S_IFDIR) { // is a directory dir = string(path); sprintf(sessionFile,"%s/aspSession",path); } else { string tmp = string(path); dir = tmp.substr(0,tmp.find_last_of("/")); sprintf(sessionFile,"%s",path); } FILE *fp; if(!(fp = fopen(sessionFile, "r"))) { Winfoprintf("Failed to open session file %s.",sessionFile); return 0; } traceList->clearList(); selTraceList->clearList(); peakList->clearList(); integList->clearList(); annoList->clearList(); char buf[MAXSTR2], words[MAXWORDNUM][MAXSTR2], *tokptr; int nw, count=0; int ntraces = 0; char str[MAXSTR2]; string root=""; while (fgets(buf,sizeof(buf),fp)) { if(strlen(buf) < 1 || buf[0] == '#') continue; // break buf into tok of parameter names nw=0; tokptr = strtok(buf, ", :\n\r"); while(tokptr != NULL) { if(strlen(tokptr) > 0) { strcpy(words[nw], tokptr); nw++; } tokptr = strtok(NULL, ", :\n\r"); } if(nw < 2) continue; if(strcasecmp(words[0],"disFlags")==0 && nw > 4) { //e.g. disFlags: 0 132096 0 256 disFlag = atoi(words[1]); axisFlag = atoi(words[2]); annoFlag = atoi(words[3]); specFlag = atoi(words[4]); if(nw > 5) peakFlag = atoi(words[5]); if(nw > 6) integFlag = atoi(words[6]); } else if(strcasecmp(words[0],"disParams")==0 && nw > 1) { //e.g. disParams: 22.000000 8.000000 if(nw > 2) { P_setreal(CURRENT, "vp", atof(words[1]), 1); P_setreal(CURRENT, "vo", atof(words[2]), 1); } } else if(strcasecmp(words[0],"root")==0 && nw > 1) { root=string(words[1]); if(root.find_last_of("/") == root.length()-1) root=root.substr(0,root.length()-1); } else if(strcasecmp(words[0],"procpar")==0 && nw > 1) { P_read(CURRENT,words[1]); } else if(nw > 11 && strstr(words[0],"load") == words[0]) { if(root != "" && words[2][0] != '/') { strcpy(str,words[2]); sprintf(words[2],"%s/%s",root.c_str(),str); } //e.g. load 1 /tmp/spec.fdf spec1 spec1 0 -2.022703 14.022636 1.000000 0.000000 11 0 //e.g. load 2 /tmp/spec.fdf spec1 spec1 1 -2.022703 14.022636 1.000000 0.000000 11 0 // each line corresponds to a AspTrace spAspTrace_t trace = spAspTrace_t(new AspTrace(words,nw)); trace->rootPath=string(root); sprintf(str,"%s:%d",trace->dataKey.c_str(),trace->dataInd); string newKey = string(str); traceList->addTrace(newKey, trace); selTraceList->maxInd= traceList->getSize(); ntraces++; count++; } else if(nw > 11 && (strstr(words[0],"add") == words[0] || strstr(words[0],"sub") == words[0] || strstr(words[0],"rep") == words[0])) { if(root != "" && words[2][0] != '/') { strcpy(str,words[2]); sprintf(words[2],"%s/%s",root.c_str(),str); } //e.g. add 1 /tmp/spec.fdf spec1 spec1 0 -2.022703 14.022636 1.000000 0.000000 11 0 //e.g. sub 1 /tmp/spec.fdf spec1 spec1 1 -2.022703 14.022636 1.000000 0.000000 11 0 // each line corresponds to a AspTrace to be add/sub to a specified trace spAspTrace_t trace = spAspTrace_t(new AspTrace(words,nw)); trace->rootPath=string(root); int flag = (strstr(words[0],"sub") == words[0]) ? SUB_TRACE:ADD_TRACE; if(strstr(words[0],"rep") == words[0]) flag = REP_TRACE; spAspTrace_t sumTrace = traceList->getTraceByInd(atoi(words[1])-1); if(sumTrace != nullAspTrace) sumTrace->sumTrace(trace,flag); else { sprintf(str,"%s:%d",trace->dataKey.c_str(),trace->dataInd); string newKey = string(str); traceList->addTrace(newKey, trace); selTraceList->maxInd= traceList->getSize(); } count++; } else if(strcasecmp(words[0],"color")==0 && nw > 4) { spAspTrace_t trace = traceList->getTraceByInd(atoi(words[1])-1); if(trace != nullAspTrace) { double min = atof(words[3]); double max = atof(words[4]); string str = string(""); spAspTrace_t sumTrace = spAspTrace_t(new AspTrace(0,str,str,0,0,min,max)); sumTrace->colorStr=string(words[2]); list<spAspTrace_t> *sumList = trace->getSumTraceList(); sumList->push_back(sumTrace); } } else if(strcasecmp(words[0],"displayed_traces")==0 && nw > 1) { //e.g. displayed_traces: 1 2 3 4 5 6 7 8 9 10 int i; for(i=1; i<nw;i++) { spAspTrace_t trace = traceList->getTraceByInd(atoi(words[i])-1); if(trace != nullAspTrace) { trace->selected=false; selTraceList->addTrace(trace->getKeyInd(), trace); } } selTraceList->maxInd= traceList->getSize(); } else if(strcasecmp(words[0],"roiFile")==0 && nw > 1) { sprintf(file,"%s/%s",dir.c_str(),words[1]); loadRois(file); } else if(strcasecmp(words[0],"annoFile")==0 && nw > 1) { spAspFrame_t frame = AspFrameMgr::get()->getFrame(this); sprintf(file,"%s/%s",dir.c_str(),words[1]); AspDisAnno::load(frame, file); } else if(strcasecmp(words[0],"peakFile")==0 && nw > 1) { sprintf(file,"%s/%s",dir.c_str(),words[1]); spAspFrame_t frame = AspFrameMgr::get()->getFrame(this); AspDisPeaks::load(frame, file); } else if(strcasecmp(words[0],"integFile")==0 && nw > 1) { sprintf(file,"%s/%s",dir.c_str(),words[1]); spAspFrame_t frame = AspFrameMgr::get()->getFrame(this); AspDisInteg::load(frame, file); } } // display all traces if displayed_traces: is missing if(selTraceList->getSize() < 1) { for(int i=0; i<traceList->getSize(); i++) { spAspTrace_t trace = traceList->getTraceByInd(i); if(trace != nullAspTrace) { trace->selected=false; selTraceList->addTrace(trace->getKeyInd(), trace); } } } fclose(fp); if(specFlag) { AspMouse::setState(AspMouse::cursor1); Wsetgraphicsdisplay(""); } else { AspMouse::setState(AspMouse::noState); } getDefaultDataInfo(true); draw(); return count; }