int DlgOtherAlgo::loadData() { //AfxMessageBox(TEXT("enter load")); if(bDataLoad == true) { AfxMessageBox(TEXT("sorry, you have loaded data already, if you want to reload, click the RESET button at first")); return -1; } if(getAlgo()!=0) { AfxMessageBox(TEXT("loadData, but cant get algorithm, try again")); return -1; } CString fname = _T(""); GetDlgItem(IDC_INPUTFILE)->GetWindowTextW(fname); string strname = ""; if(fname.IsEmpty()) { //strname =getDefFileName(algo_type); } else { fname = transFile2Path(fname); strname = CStr2Str(fname); } if(pOtherAlgo ==NULL) { AfxMessageBox(TEXT("Plz choose algorithm at first")); return -1; } pOtherAlgo->loadData(strname); bDataLoad = true; return 0; }
void MainWindow::slot_func_2d() { if(worker.system_use.load())return; QString system_str=ui->te_script->toPlainText(); if(sys->load_system(system_str)) { sys->setSolveMode(getAlgo()); if(ui->cb_param1->currentIndex()==ui->cb_param2->currentIndex()) { QMessageBox::information(this,"Bad Id for parametres",QString("p%1 == p%2").arg(ui->cb_param1->currentIndex()).arg(ui->cb_param2->currentIndex())); return; } // if(ui->cb_param1->currentIndex()>ui->cb_param2->currentIndex()) // { // int index=ui->cb_param1->currentIndex(); // ui->cb_param1->setCurrentIndex(ui->cb_param2->currentIndex()); // ui->cb_param2->setCurrentIndex(index); // } if(!sys->selectId1(ui->cb_param1->currentIndex())) { QMessageBox::information(this,"Bad Id for parametre 1",QString("p%1 is not defined in the system").arg(ui->cb_param1->currentIndex())); return; } if(!sys->selectId2(ui->cb_param2->currentIndex())) { QMessageBox::information(this,"Bad Id for parametre 2",QString("p%1 is not defined in the system").arg(ui->cb_param2->currentIndex())); return; } ui->progressBar->setRange(0,ui->sb_p0_res->value()-1); Box box(ui->sb_p0_min->value(), ui->sb_p0_max->value(), ui->sb_p0_res->value(), ui->sb_p1_min->value(), ui->sb_p1_max->value(), ui->sb_p1_res->value(), ui->sb_p2_min->value(), ui->sb_p2_max->value(), ui->sb_p2_res->value(), ui->cb_param1->currentIndex(), ui->cb_param2->currentIndex(), ui->cb_param3->currentIndex()); // QImage img=System::toImage(sys->solve_2D_p0p1(box, // (ColorMode)ui->cb__color_mode->currentIndex()), // (ScaleColorMode)ui->cb_scale_color_mode->currentIndex()); worker.calc(sys,box,(ColorMode)ui->cb__color_mode->currentIndex(),WorkerThread::IMAGE_2D_FUNC); } }
void MainWindow::slot_run_script() { if(worker.system_use.load())return; QString system_str=ui->te_script->toPlainText(); if(sys->load_system(system_str)) { sys->show(); sys->setSolveMode(getAlgo()); worker.solveSystem(sys); } }
int main(int argc, const char *argv[]) { int EXECUTE[NumAlgo]; char *ALGO_NAME[NumAlgo]; char *ALGO_DESCRIPTION[NumAlgo]; char *PATH[NumAlgo]; char filename[20], command[100]; int i,j; getAlgo(ALGO_NAME,EXECUTE); /* processing of input parameters */ if (argc==1) {printf("\n\tNo parameter given. Use -h for help.\n\n"); return 0;} if (!strcmp("-h", argv[1])) {printManual(); return 0;} int par = 1; while(par<argc) { int selected = 0; if (par<argc && !strcmp("-show", argv[par])) { par++; //shows all algorithms printf("The list of all string matching algorithms\n"); for(i=0; i<NumAlgo; i++) if(ALGO_NAME[i]) { printf("%s\n",ALGO_NAME[i]); } return 1; } if (par<argc && !strcmp("-which", argv[par])) { par++; //shows all selected algorithms printf("\n\tThe list of selected algorithms:\n"); for(i=0; i<NumAlgo; i++) if(ALGO_NAME[i] && EXECUTE[i]) { printf("\t-%s\n",ALGO_NAME[i]); } printf("\n"); return 1; } if (par<argc && !strcmp("-add", argv[par])) { par++; if(par>=argc) {printf("\n\n\tError in input parameters. Use -h for help.\n\n"); return 0;} strcpy(filename, argv[par++]); char path[50] = "source/bin/"; strcat(path,filename); FILE *fp = fopen(path, "r"); if( fp ) { //the file exists if(search_ALGO(ALGO_NAME,filename)>=0) printf("\n\n\tSMART error message\n\tError in input parameters....algorithm %s already in the set\n\n",filename); else { printf("\n\n\tAdding the algorithm %s to SMART\n",filename); fflush(stdout); printf("\tTesting the algorithm for correctness...."); fflush(stdout); //testing correctness of the algorithm sprintf(command,"./test ../bin/%s -nv",filename); fflush(stdout); if(system(command)) { printf("failed!\n"); printf("\tThe system is unable to add the algorithm %s to SMART.\n\tPlease, check for algorithm's correctness.\n\n",filename); } else { printf("ok\n"); for(i=0; i<NumAlgo && ALGO_NAME[i]; i++); EXECUTE[i] = 0; ALGO_NAME[i] = filename; printf("\tAlgorithm %s added succesfully.\n\n",filename); } } } else printf("\n\n\tSMART error message\n\tError in input parameters....program %s does not exist\n\n",path); } if (par<argc && !strcmp("-group", argv[par])) { par++; if(par>=argc) {printf("\n\n\tError in input parameters. Use -h for help.\n\n"); return 0;} strcpy(filename, argv[par++]); char path[50] = "source/bin/"; strcat(path,filename); FILE *fp = fopen(path, "r"); if( fp ) { //the file exists if(search_ALGO(ALGO_NAME,filename)>=0) printf("\n\n\tSMART error message\n\tError in input parameters....algorithm %s already in the set\n\n",filename); else { printf("\n\n\tAdding the algorithm %s to SMART\n",filename); fflush(stdout); printf("\tTesting the algorithm for correctness...."); fflush(stdout); //testing correctness of the algorithm sprintf(command,"./test ../bin/%s -nv",filename); fflush(stdout); if(system(command)) { printf("failed!\n"); printf("\tThe system is unable to add the algorithm %s to SMART.\n\tPlease, check for algorithm's correctness.\n\n",filename); } else { printf("ok\n"); for(i=0; i<NumAlgo && ALGO_NAME[i]; i++); EXECUTE[i] = 0; ALGO_NAME[i] = filename; printf("\tAlgorithm %s added succesfully.\n\n",filename); } } } else printf("\n\n\tSMART error message\n\tError in input parameters....program %s does not exist\n\n",path); } for(i=0; i<NumAlgo; i++) if(ALGO_NAME[i]) { if (par<argc && !strcmp(argv[par],ALGO_NAME[i])) { par++; if(EXECUTE[i]==0) { EXECUTE[i]=1; printf("\tThe %s algorithm has been selected\n",ALGO_NAME[i]); } else { EXECUTE[i]=0; printf("\tThe %s algorithm has been deselected\n",ALGO_NAME[i]); } selected = 1; } } if(selected) continue; if (par<argc && !strcmp("-all", argv[par])) { par++; for(i=0; i<NumAlgo; i++) if(ALGO_NAME[i]) EXECUTE[i]=1; continue; } if (par<argc && !strcmp("-none", argv[par])) { par++; for(i=0; i<NumAlgo; i++) if(ALGO_NAME[i]) EXECUTE[i]=0; continue; } if (par<argc) {printf("\tError in input parameters....no parameter %s\n\n",argv[par]); return 0;} } int order[NumAlgo]; for(i=0; i<NumAlgo; i++) order[i] = i; for(i=0; i<NumAlgo; i++) for(j=0; j<NumAlgo; j++) if(ALGO_NAME[order[j]] && ALGO_NAME[order[j+1]] && strcmp(ALGO_NAME[order[j]],ALGO_NAME[order[j+1]])>0) { int tmp = order[j]; order[j] = order[j+1]; order[j+1] = tmp; } FILE *fp = fopen("source/algorithms.h", "w"); for(j=0; j<NumAlgo; j++) if(ALGO_NAME[j]) fprintf(fp,"#%d #%s \n", EXECUTE[order[j]], ALGO_NAME[order[j]] ); fclose(fp); }