string ImgOverlay::extractPlane(spGframe_t gf, spDataInfo_t overlayData) { if(overlayData == (spDataInfo_t)NULL) return ""; spViewInfo_t view = gf->getFirstView(); if(view == nullView) return ""; // get baseData spImgInfo_t img = view->imgInfo; if(img == nullImg) return ""; spDataInfo_t baseData = img->getDataInfo(); // determin size for overlay plane int bfast = baseData->getFast(); int bmedium = baseData->getMedium(); int ofast = overlayData->getFast(); int omedium = overlayData->getMedium(); double blpe,olpe,blro,olro; DDLSymbolTable *bst = baseData->st; DDLSymbolTable *ost = overlayData->st; if(!bst || !ost) return ""; bst->GetValue("roi",blpe, 0); bst->GetValue("roi",blro, 1); ost->GetValue("roi",olpe, 0); ost->GetValue("roi",olro, 1); int nfast = (int)(blpe*ofast/olpe); int nmedium = (int)(blro*omedium/olro); double scalex = (blpe*ofast)/(olpe*bfast); double scaley = (blro*omedium)/(olro*bmedium); // new data struct for extracted plane // The only difference from baseData is ds2d->data, and data size nfast, nmedium. dataStruct_t *ds2d = new dataStruct_t; if(!ds2d) { return ""; } memcpy(ds2d, baseData->dataStruct, sizeof(*ds2d)); ds2d->data = NULL; ds2d->auxparms = NULL; float *buf = new float[nfast*nmedium]; if(buf == NULL) { delete ds2d; Winfoprintf("VolData: allocate memory returned NULL pointer."); return ""; } int np = rebinOverlayData(gf, overlayData, nfast,nmedium, scalex, scaley, buf,false); if(np<1) { delete[] buf; delete ds2d; return ""; } DDLSymbolTable *st = (DDLSymbolTable *)baseData->st->CloneList(false); DDLSymbolTable *st2 = new DDLSymbolTable(); // New 2D datainfo spDataInfo_t datainfo = spDataInfo_t(new DataInfo(ds2d, st, st2)); if(datainfo == (spDataInfo_t)NULL) { delete ds2d; delete st2; Winfoprintf("VolData: allocate memory returned NULL pointer."); return ""; } datainfo->st->SetData((float *)buf, sizeof(float) * nfast * nmedium); delete[] buf; // update header char floatStr[16]; strcpy(floatStr, "float"); datainfo->st->SetValue("rank", 2); datainfo->st->SetValue("bits", 32); datainfo->st->SetValue("storage", floatStr); datainfo->st->SetValue("matrix", nfast, 0); datainfo->st->SetValue("matrix", nmedium, 1); string newpath = overlayData->getFilepath()+string("_")+baseData->getShortName(); datainfo->st->SetValue("filename", newpath.c_str()); DataManager *dm = DataManager::get(); string key = dm->loadFile(newpath.c_str(), datainfo->st, datainfo->st2); //Winfoprintf("-----key %s",key.c_str()); //ReviewQueue::get()->addImagePlane(dataInfo, key); datainfo->st = NULL; return key; }
int main(int argc, char** argv) { DataManager* data = DataManager::instanceOf(); if(argc >=2) { if(strcmp(argv[1],"-o")==0) { string file_name(argv[2]); data->loadFile(file_name); } } string input; do { cout << endl; if(data->getList().size() > 0) { data->getList().getTaskList(); cout << endl; } cout << "opcje do wyboru:" << endl; cout << "open" << endl; cout << "create" << endl; cout << "exit" << endl; if(data->getList().size() > 0) { cout << "save" << endl; cout << "setdate" << endl; cout << "settime" << endl; cout << "setdescription" << endl; cout << "settitle" << endl; cout << "setpriority" << endl; cout << "setseverity" << endl; } cout << endl << "->"; getline(cin,input); if(input == "open") { getline(cin,input); data->loadFile(input); if(data->auth_required()) { for(int i = 0; i < 3; ++i) { cout << "password:"******"Welcome" << endl; else cout << "access danied" << endl; input = ""; } continue; } } int i = 0; if(input == "save") { cout << "Podaj nazwe pliku:" << endl; getline(cin,input); if( data->saveToFile(input) ) { cout << "Zapisano" << endl; } else { cerr << "Nie udało się zapisać" << endl; } } string tmp; if(input == "create") { cout << "podaj tytul" << endl; getline(cin,tmp); int id = data->addTask(tmp); data->getList(); set_date(id); set_time(id); } if(input == "setpass") { bool fine = true; string opass, npass; if(data->auth_required()) { cout << "podaj aktualne haslo:" << endl; getline(cin,opass); fine = data->auth(opass); if(!fine) cout << "haslo nieprawidlowe" << endl; } if(fine) { cout << "podaj nowe haslo" << endl; getline(cin,npass); data->setPasscode(opass,npass); } } if(input == "setdate") { i = get_task_id(); set_date(i); } if(input == "settime") { i = get_task_id(); set_time(i); } if(input == "setdescription") { Todos::iterator it = get_task_by_id(); if(it != data->getList().end()) { cout << "podaj opis" << endl; getline(cin,tmp); it->setDescription(tmp); } } if(input == "settitle") { Todos::iterator it = get_task_by_id(); if(it != data->getList().end()) { cout << "podaj tytul" << endl; getline (cin,tmp); it->setTitle(tmp); } } if(input == "setpriority") { Todos::iterator it = get_task_by_id(); if(it != data->getList().end()) { cout << "podaj priorytet" << endl; getline (cin,tmp); it->setPriority(tmp); } } if(input == "setseverity") { Todos::iterator it = get_task_by_id(); if(it != data->getList().end()) { cout << "podaj severity" << endl; getline (cin,tmp); it->setSeverity(tmp); } } } while(input != "exit" && input != "quit"); }