Commit 21d379d2353d41d6935ae349d9a5e7340f9d19da
1 parent
a2959d5a
ProgressCounter updates
Showing
3 changed files
with
13 additions
and
25 deletions
openbr/core/core.cpp
| @@ -148,9 +148,11 @@ struct AlgorithmCore | @@ -148,9 +148,11 @@ struct AlgorithmCore | ||
| 148 | if (data.empty()) | 148 | if (data.empty()) |
| 149 | return files; | 149 | return files; |
| 150 | 150 | ||
| 151 | + // Store totalSteps for ProgressCounter | ||
| 152 | + Globals->totalSteps = data.length(); | ||
| 153 | + | ||
| 151 | // Trust me, this makes complete sense. | 154 | // Trust me, this makes complete sense. |
| 152 | // We're just going to make a pipe with a placeholder first transform | 155 | // We're just going to make a pipe with a placeholder first transform |
| 153 | - Globals->totalSteps = data.length(); | ||
| 154 | QString pipeDesc = "Identity+GalleryOutput("+gallery.flat()+")+ProgressCounter("+QString::number(data.length())+")+Discard"; | 156 | QString pipeDesc = "Identity+GalleryOutput("+gallery.flat()+")+ProgressCounter("+QString::number(data.length())+")+Discard"; |
| 155 | QScopedPointer<Transform> basePipe(Transform::make(pipeDesc,NULL)); | 157 | QScopedPointer<Transform> basePipe(Transform::make(pipeDesc,NULL)); |
| 156 | 158 |
openbr/gui/progress.cpp
| @@ -26,7 +26,7 @@ br::Progress::Progress(QWidget *parent) | @@ -26,7 +26,7 @@ br::Progress::Progress(QWidget *parent) | ||
| 26 | void br::Progress::checkProgress() | 26 | void br::Progress::checkProgress() |
| 27 | { | 27 | { |
| 28 | const int progress = 100 * br_progress(); | 28 | const int progress = 100 * br_progress(); |
| 29 | - const bool visible = progress >= 0; | 29 | + const bool visible = progress >= 0 && progress < 100; |
| 30 | 30 | ||
| 31 | if (visible) { | 31 | if (visible) { |
| 32 | showMessage(br_most_recent_message()); | 32 | showMessage(br_most_recent_message()); |
openbr/plugins/misc.cpp
| @@ -514,28 +514,20 @@ class ProgressCounterTransform : public TimeVaryingTransform | @@ -514,28 +514,20 @@ class ProgressCounterTransform : public TimeVaryingTransform | ||
| 514 | void projectUpdate(const TemplateList &src, TemplateList &dst) | 514 | void projectUpdate(const TemplateList &src, TemplateList &dst) |
| 515 | { | 515 | { |
| 516 | dst = src; | 516 | dst = src; |
| 517 | - qint64 elapsed = timer.elapsed(); | ||
| 518 | - calls++; | ||
| 519 | - set_calls++; | ||
| 520 | - // updated every 10 seconds | ||
| 521 | - if (elapsed > 5 * 1000) { | ||
| 522 | - float f_elapsed = elapsed / 1000.0f; | ||
| 523 | - // remaining calls (according to our input variable) | ||
| 524 | - int remaining = totalTemplates - calls; | ||
| 525 | - // calls / second | ||
| 526 | - float speed = set_calls / f_elapsed; | ||
| 527 | 517 | ||
| 528 | - float p = 100 * float(calls) / totalTemplates; | 518 | + qint64 elapsed = timer.elapsed(); |
| 529 | 519 | ||
| 530 | - // seconds remaining | ||
| 531 | - int s = float(remaining) / speed; | 520 | + // updated every second |
| 521 | + if (elapsed > 1000) { | ||
| 522 | + float p = br_progress(); | ||
| 523 | + int s = br_time_remaining(); | ||
| 532 | 524 | ||
| 533 | - fprintf(stderr, "%05.2f%% ELAPSED=%s REMAINING=%s COUNT=%g \r", p, QtUtils::toTime(Globals->startTime.elapsed()/1000.0f).toStdString().c_str(), QtUtils::toTime(s).toStdString().c_str(), float(calls)); | 525 | + fprintf(stderr, "%05.2f%% ELAPSED=%s REMAINING=%s COUNT=%g \r", p, QtUtils::toTime(Globals->startTime.elapsed()/1000.0f).toStdString().c_str(), QtUtils::toTime(s).toStdString().c_str(), Globals->currentStep); |
| 534 | 526 | ||
| 535 | timer.start(); | 527 | timer.start(); |
| 536 | - set_calls = 0; | ||
| 537 | } | 528 | } |
| 538 | 529 | ||
| 530 | + Globals->currentStep++; | ||
| 539 | 531 | ||
| 540 | return; | 532 | return; |
| 541 | } | 533 | } |
| @@ -548,24 +540,18 @@ class ProgressCounterTransform : public TimeVaryingTransform | @@ -548,24 +540,18 @@ class ProgressCounterTransform : public TimeVaryingTransform | ||
| 548 | void finalize(TemplateList & data) | 540 | void finalize(TemplateList & data) |
| 549 | { | 541 | { |
| 550 | (void) data; | 542 | (void) data; |
| 551 | - float p = 100 * float(calls) / totalTemplates; | ||
| 552 | - qDebug("%05.2f%% ELAPSED=%s REMAINING=%s COUNT=%g \r", p, QtUtils::toTime(Globals->startTime.elapsed()/1000.0f).toStdString().c_str(), QtUtils::toTime(0).toStdString().c_str(), float(calls)); | 543 | + float p = br_progress(); |
| 544 | + qDebug("%05.2f%% ELAPSED=%s REMAINING=%s COUNT=%g \r", p, QtUtils::toTime(Globals->startTime.elapsed()/1000.0f).toStdString().c_str(), QtUtils::toTime(0).toStdString().c_str(), Globals->currentStep); | ||
| 553 | } | 545 | } |
| 554 | 546 | ||
| 555 | void init() | 547 | void init() |
| 556 | { | 548 | { |
| 557 | - calls = 0; | ||
| 558 | - set_calls = 0; | ||
| 559 | timer.start(); | 549 | timer.start(); |
| 560 | } | 550 | } |
| 561 | 551 | ||
| 562 | public: | 552 | public: |
| 563 | ProgressCounterTransform() : TimeVaryingTransform(false,false) {} | 553 | ProgressCounterTransform() : TimeVaryingTransform(false,false) {} |
| 564 | - bool initialized; | ||
| 565 | QElapsedTimer timer; | 554 | QElapsedTimer timer; |
| 566 | - qint64 calls; | ||
| 567 | - qint64 set_calls; | ||
| 568 | - | ||
| 569 | }; | 555 | }; |
| 570 | 556 | ||
| 571 | BR_REGISTER(Transform, ProgressCounterTransform) | 557 | BR_REGISTER(Transform, ProgressCounterTransform) |