Ejemplo n.º 1
0
/* end_progress(progress, done)
 * Do one final update of the progress display (set to 100% if done is set to
 * true), and then release the progress data structures.
 */
void end_progress(void *pv, int done) {
    struct progress *p = pv;
    if (done == 2)
        progbar(20, 100.0);
    else
        progbar(p->lastpcnt * (20.0 / 100.0), p->lastpcnt);

    {
        float rate = ((float)p->lastdl) / (p->lasttime - p->starttime + 0.5);
        printf(" %.1f kBps ", rate / 1000.0);
    }
    puts(done == 2 ? "DONE    \n" : !done ? "aborted    \n" : "        \n");
    fflush(stdout);
    free(p);
}
Ejemplo n.º 2
0
/* do_progress(progress, percent, total_bytes_retrieved
 * Updates the supplied progress structure with the new % done given, and
 * recalculates the rolling download rate given the supplied
 * total_bytes_retrieved (and the current time) */
void do_progress(void *pv, float pcnt, long long newdl) {
    struct progress *p = pv;
    /* If new or if time has passed, update progress display & data */
    time_t newtime = time(NULL);
    if (p->lasttime != newtime) {
        int passed = p->lasttime ? newtime - p->lasttime : 0;
        if (!p->lasttime)
            p->starttime = newtime;
        p->lasttime = newtime;

        /* Update progress bar displayed */
        progbar(pcnt * (20.0 / 100.0), pcnt);

        /* Each time 1s has passed, we update and redisplay our download rate */
        if (passed) {
            float rate = newdl - p->lastdl;
            int sleft = (100.0f - pcnt) / (pcnt - p->lastpcnt);
            if (passed != 1) {
                rate /= passed;
                sleft *= passed;
            }
            printf(" %.1f kBps ", rate / 1000.0);
            if (sleft < 60 * 1000)
                printf("%d:%02d ETA  ", sleft / 60, sleft % 60);
            else
                puts("        ");
        }
        p->lastdl = newdl;
        p->lastpcnt = pcnt;
        fflush(stdout);
    }
}
Ejemplo n.º 3
0
/* do_progress(progress, percent, total_bytes_retrieved
 * Updates the supplied progress structure with the new % done given, and
 * recalculates the rolling download rate given the supplied
 * total_bytes_retrieved (and the current time) */
void do_progress(struct progress *p, float pcnt, long long newdl) {
    time_t newtime = time(NULL);
    if (!p->num_history)
        p->starttime = newtime;
    else if (p->history[p->num_history-1].hist_time == newtime)
        return;

    /* Add to the history, rolling off some old history if needed. */
    if (p->num_history >= HISTORY) {
        p->num_history = HISTORY-1;
        memmove(p->history, &(p->history[1]), (HISTORY-1)*sizeof(p->history[0]));
    }
    p->history[p->num_history].hist_time = newtime;
    p->history[p->num_history].dl        = newdl;
    p->history[p->num_history].pcnt      = pcnt;
    p->num_history++;
    
    /* Update progress bar displayed */
    progbar(pcnt * (20.0 / 100.0), pcnt);

    /* If we have more than one data point, we can calculate and show rates */
    if (p->num_history > 1) {
        int passed = p->history[p->num_history-1].hist_time - p->history[0].hist_time;
        float rate = (p->history[p->num_history-1].dl - p->history[0].dl) / (float)passed;
        float pcnt_change = (p->history[p->num_history-1].pcnt - p->history[0].pcnt);
        int sleft = (100.0f - pcnt) * passed / pcnt_change;
        printf(" %.1f kBps ", rate / 1000.0);
        if (sleft < 60 * 1000)
            printf("%d:%02d ETA  ", sleft / 60, sleft % 60);
        else
            fputs("           ", stdout);
    }
    fflush(stdout);
}
Ejemplo n.º 4
0
/* end_progress(progress, done)
 * Do one final update of the progress display (set to 100% if done is set to
 * true), and then release the progress data structures.
 */
void end_progress(struct progress *p, int done) {
    if (done == 2)
        progbar(20, 100.0);
    else {
        float lastpcnt = p->history[p->num_history-1].pcnt;
        progbar(lastpcnt * (20.0 / 100.0), lastpcnt);
    }

    {   /* For the final display, show the rate for the whole download. */
        float rate = (float)(p->history[p->num_history-1].dl) /
            (p->history[p->num_history-1].hist_time - p->starttime + 0.5);
        printf(" %.1f kBps ", rate / 1000.0);
    }
    puts(done == 2 ? "DONE    \n" : !done ? "aborted    \n" : "        \n");
    fflush(stdout);
    free(p);
}
Ejemplo n.º 5
0
void MainWindow::generateMeshFromLST( std::string lstfile)
{

    if(lstfile == ""  )
        return;
    cout << "ff " << lstfile << endl;

    QProgressDialog progbar(this);
    //p.setCancelButton(NULL);
    progbar.setRange(0, 100);
    progbar.setModal(true);
    progbar.show();
    setCursor(QCursor(Qt::WaitCursor));
    progbar.setCursor(QCursor(Qt::ArrowCursor));

    progbar.setValue(0);
    progbar.setLabelText("Parsing LST File");

    displayWidget->LoadLST(lstfile );

    progbar.setValue(99);
    progbar.setLabelText("Generating Mesh");


    displayWidget->GenerateMeshFromLST(&progbar);
    progbar.setValue(99);

    progbar.setVisible(false);

    QProgressDialog subdivisionProgbar(this);
    subdivisionProgbar.setRange(0, 100);
    subdivisionProgbar.setModal(true);
    subdivisionProgbar.show();
    subdivisionProgbar.setCursor(QCursor(Qt::ArrowCursor));
    subdivisionProgbar.setLabelText("Applying Loop Sudivision");
    subdivisionProgbar.setValue(0);

    displayWidget->ApplySubdivisionToMesh(subdivs, &subdivisionProgbar);
    subdivisionProgbar.setValue(99);
}