void GCDCGraphs::OnPaint(wxPaintEvent& e) { if (m_draws_wdg->GetSelectedDraw() == NULL) return; wxBufferedPaintDC pdc(this); wxGraphicsContext* dc = wxGraphicsContext::Create(pdc); dc->SetFont(GetFont(), *wxWHITE); RecalculateMargins(*dc); DrawBackground(*dc); dc->SetBrush(*wxWHITE_BRUSH); dc->SetPen(wxPen(wxColour(255, 255, 255, 255), 1, wxSOLID)); DrawXAxis(*dc); DrawXAxisVals(*dc); DrawYAxis(*dc); DrawYAxisVals(*dc); DrawUnit(*dc); DrawWindowInfo(*dc); DrawSeasonsLimitsInfo(*dc); if (m_draws_wdg->GetNoData() == true) DrawNoData(*dc); else DrawGraphs(*dc); DrawRemarksBitmaps(*dc); if (m_draw_param_name) DrawParamName(*dc); delete dc; }
int main(){ int i,newdata; if (Graphics) GUI(); init(); while (!done){ if (Graphics){ Events(newdata); GetGraphics(); DrawGraphs(); } else {done=1;Pause=0;} if (!Pause||sstep){ sstep=0; newdata=1; for (i=0;i<Repeat;i++){ iterations++; circleBC(); iteration(); iterationColloid(); TotMomentum(); analysis(iterations); } } else sleep(1); } return 0; }
int main(){ int i; init(); GUI(); while (!done){ Events(1); /* Whenever there are new data the argument of Events() should be nonzero. This will set the requests for data so that you can calculate them on demand only. For this simple program you can always set it to one. */ DrawGraphs(); if (!pause || sstep){ sstep=0; for (i=0;i<Repeat;i++) iterate(); } else { sleep(1);/*when the program is waiting it returns the CPU time to the operating system */ } } return 0; }
// Never change if not neccesary int main(int argc, char *argv[]){ int n, newdata = 0; time_t BEGIN_T; char name[256], hname[128]; FILE *out; srand(time(NULL)); //printf("%d\n", argc); if(argc < 1) { printf("Usage: %s [GUI 1 or 0]\n", argv[0]); } else { //PARAM = atof(argv[1]); if (argc == 2) graphics = atoi(argv[1]); } if (graphics) GUI(); if (!graphics) printf("Running PARAM = %f on %dx%d Lattice with %d iterations\n",PARAM,XMAX,YMAX,iteration_max); if (!graphics) Pause = 0; Init(); //test for speed BEGIN_T = time(NULL); for (n=0;n<10;n++) iteration1(); if (!graphics) printf("sec/iteration: %s\n", wtime_string( (double)(time(NULL)-BEGIN_T)/10) ); Init(); //Just reset sprintf(name,"data-%f.txt",PARAM); out = fopen(name,"w+"); //Write some information gethostname(hname,(size_t)sizeof(hname)); fprintf(out,"#Size: %dx%d\n#PARAM: %f\n#itertions: %d\n#Repeat: %d\n#sec/iteration: %s\n#Host: %s\n#PID: %d\n#---BEGIN DATA---\n\n\n",XMAX,YMAX,PARAM,iteration_max,repeat,wtime_string( (double)(time(NULL)-BEGIN_T)/10 ), hname, getpid() ); fclose(out); //Now start simulation BEGIN_T = time(NULL); while ( (iterations<iteration_max)&&(!done) ){//Begin Main Loop if (graphics) { Events(newdata); GetGraphics(); DrawGraphs(); } else { //done=1; //Pause=0; } if (!Pause||singlestep) { singlestep = 0; newdata = 1; for (n=0;n<repeat;n++) { iterations++; iteration1(); } //analysis(); if (!graphics) repeat *= 1.1; if (!graphics) printf("ETA: %s\n", wtime_string( (double)(time(NULL)-BEGIN_T)*(iteration_max-iterations)/iterations) ); if (repeat==0) Init(); } else sleep(1); }//End Main Loop return 0; }