mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
caf::ProgressInfo: Added some more descriptions and warnings on misuse. Added debug helper variables.
This commit is contained in:
parent
364c202391
commit
193193d35f
@ -67,6 +67,26 @@ namespace caf {
|
|||||||
/// progInfo.setProgressDescription("Building geometry");
|
/// progInfo.setProgressDescription("Building geometry");
|
||||||
/// ... buildGeometry();
|
/// ... buildGeometry();
|
||||||
/// progInfo.incrementProgress(); // not needed really, because the destructor will send the progress to top.
|
/// progInfo.incrementProgress(); // not needed really, because the destructor will send the progress to top.
|
||||||
|
///
|
||||||
|
/// There are one particular limitation: The progress will not work correctly if the higher level
|
||||||
|
/// ProgressInfo object does not increment progress between the creation and operation of two (or more)
|
||||||
|
/// independent lower level ProgressInfo objects. If not, the progress will restart (within its limits)
|
||||||
|
/// for each progress object that is operating.
|
||||||
|
///
|
||||||
|
/// caf::ProgressInfo progInfoHighLevel(3, "Open File");
|
||||||
|
///
|
||||||
|
/// {
|
||||||
|
/// caf::ProgressInfo progInfoLowLevel(10, "");
|
||||||
|
/// }
|
||||||
|
/// // NEEDS progInfoHighLevel.incrementProgress() here !!
|
||||||
|
/// {
|
||||||
|
/// caf::ProgressInfo progInfoLowLevel(10, "");
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// It is not allowed to have several ProgressInfo objects in the same scope level
|
||||||
|
///
|
||||||
|
/// caf::ProgressInfo progInfo1(10, "");
|
||||||
|
/// caf::ProgressInfo progInfo2(10, ""); //<-- Will not work well
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -233,6 +253,8 @@ namespace caf {
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
static size_t currentTotalMaxProgressValue()
|
static size_t currentTotalMaxProgressValue()
|
||||||
{
|
{
|
||||||
|
std::vector<size_t>& maxProgressStack_v = maxProgressStack();
|
||||||
|
|
||||||
size_t levCount = 1;
|
size_t levCount = 1;
|
||||||
for (size_t levelDepth = 0; levelDepth < maxProgressStack().size(); ++levelDepth)
|
for (size_t levelDepth = 0; levelDepth < maxProgressStack().size(); ++levelDepth)
|
||||||
{
|
{
|
||||||
@ -247,6 +269,11 @@ namespace caf {
|
|||||||
static size_t currentTotalProgress()
|
static size_t currentTotalProgress()
|
||||||
{
|
{
|
||||||
double progress = 0;
|
double progress = 0;
|
||||||
|
|
||||||
|
std::vector<size_t>& progressStack_v = progressStack();
|
||||||
|
std::vector<size_t>& progressSpanStack_v = progressSpanStack();
|
||||||
|
std::vector<size_t>& maxProgressStack_v = maxProgressStack();
|
||||||
|
|
||||||
for (int i = static_cast<int>(progressStack().size()) - 1; i >= 0; --i)
|
for (int i = static_cast<int>(progressStack().size()) - 1; i >= 0; --i)
|
||||||
{
|
{
|
||||||
size_t span = (i < 1) ? 1 : progressSpanStack()[i - 1];
|
size_t span = (i < 1) ? 1 : progressSpanStack()[i - 1];
|
||||||
@ -301,6 +328,10 @@ namespace caf {
|
|||||||
{
|
{
|
||||||
if (!isUpdatePossible()) return;
|
if (!isUpdatePossible()) return;
|
||||||
|
|
||||||
|
std::vector<size_t>& progressStack_v = progressStack();
|
||||||
|
std::vector<size_t>& progressSpanStack_v = progressSpanStack();
|
||||||
|
std::vector<size_t>& maxProgressStack_v = maxProgressStack();
|
||||||
|
|
||||||
if (!maxProgressStack().size())
|
if (!maxProgressStack().size())
|
||||||
{
|
{
|
||||||
//progressDialog()->setWindowModality(Qt::ApplicationModal);
|
//progressDialog()->setWindowModality(Qt::ApplicationModal);
|
||||||
@ -347,6 +378,10 @@ namespace caf {
|
|||||||
{
|
{
|
||||||
if (!isUpdatePossible()) return;
|
if (!isUpdatePossible()) return;
|
||||||
|
|
||||||
|
std::vector<size_t>& progressStack_v = progressStack();
|
||||||
|
std::vector<size_t>& progressSpanStack_v = progressSpanStack();
|
||||||
|
std::vector<size_t>& maxProgressStack_v = maxProgressStack();
|
||||||
|
|
||||||
if (progressValue == progressStack().back()) return; // Do nothing if no progress.
|
if (progressValue == progressStack().back()) return; // Do nothing if no progress.
|
||||||
|
|
||||||
// Guard against the max value set for this level
|
// Guard against the max value set for this level
|
||||||
@ -375,6 +410,10 @@ namespace caf {
|
|||||||
{
|
{
|
||||||
if (!isUpdatePossible()) return;
|
if (!isUpdatePossible()) return;
|
||||||
|
|
||||||
|
std::vector<size_t>& progressStack_v = progressStack();
|
||||||
|
std::vector<size_t>& progressSpanStack_v = progressSpanStack();
|
||||||
|
std::vector<size_t>& maxProgressStack_v = maxProgressStack();
|
||||||
|
|
||||||
assert(progressStack().size());
|
assert(progressStack().size());
|
||||||
ProgressInfoStatic::setProgress(progressStack().back() + progressSpanStack().back());
|
ProgressInfoStatic::setProgress(progressStack().back() + progressSpanStack().back());
|
||||||
}
|
}
|
||||||
@ -400,6 +439,10 @@ namespace caf {
|
|||||||
{
|
{
|
||||||
if (!isUpdatePossible()) return;
|
if (!isUpdatePossible()) return;
|
||||||
|
|
||||||
|
std::vector<size_t>& progressStack_v = progressStack();
|
||||||
|
std::vector<size_t>& progressSpanStack_v = progressSpanStack();
|
||||||
|
std::vector<size_t>& maxProgressStack_v = maxProgressStack();
|
||||||
|
|
||||||
assert(maxProgressStack().size() && progressStack().size() && progressSpanStack().size() && titleStack().size() && descriptionStack().size());
|
assert(maxProgressStack().size() && progressStack().size() && progressSpanStack().size() && titleStack().size() && descriptionStack().size());
|
||||||
|
|
||||||
// Set progress to max value, and leave it there until somebody touches the progress again
|
// Set progress to max value, and leave it there until somebody touches the progress again
|
||||||
|
Loading…
Reference in New Issue
Block a user