From de8a959ad5eac7a4fe130133d4a4f14598b0f4aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 6 Feb 2013 13:36:25 +0100 Subject: [PATCH] caf: Fixed bug in progress calculation resulting in the progress neary standing still on sub sub levels p4#: 20391 --- cafUserInterface/cafProgressInfo.cpp | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/cafUserInterface/cafProgressInfo.cpp b/cafUserInterface/cafProgressInfo.cpp index 48ab5a35ea..49c4b3096f 100644 --- a/cafUserInterface/cafProgressInfo.cpp +++ b/cafUserInterface/cafProgressInfo.cpp @@ -189,15 +189,14 @@ static std::vector& progressSpanStack() return m_progressSpanStack; } - //-------------------------------------------------------------------------------------------------- -/// Calculate the total number of progress values we would need if we only look at the levels from -/// \a levelDepth and below (increasing subdivision) +/// Calculate the total maximum value for the progress bar composed +/// of the complete stack //-------------------------------------------------------------------------------------------------- -static size_t subLevelsMaxProgressValue(size_t levelDepth) +static size_t currentTotalMaxProgressValue() { size_t levCount = 1; - for (; levelDepth < maxProgressStack().size(); ++levelDepth) + for (size_t levelDepth = 0; levelDepth < maxProgressStack().size(); ++levelDepth) { levCount *= maxProgressStack()[levelDepth]; } @@ -209,21 +208,16 @@ static size_t subLevelsMaxProgressValue(size_t levelDepth) //-------------------------------------------------------------------------------------------------- static size_t currentTotalProgress() { - size_t progress = 0; - for (size_t i = 0; i < progressStack().size(); ++i) + double progress = 0; + for (int i = static_cast(progressStack().size()) - 1; i >= 0; --i) { size_t span = (i < 1) ? 1 : progressSpanStack()[i-1]; - progress = progress + span*progressStack()[i]* subLevelsMaxProgressValue(i+1); + progress = span*(progress + progressStack()[i])/maxProgressStack()[i]; } - return progress; -} -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -static size_t currentTotalMaxProgressValue() -{ - return subLevelsMaxProgressValue(0); + size_t totalIntProgress = static_cast(currentTotalMaxProgressValue()*progress); + + return totalIntProgress; } //-------------------------------------------------------------------------------------------------- @@ -336,7 +330,7 @@ void ProgressInfoStatic::incrementProgress() if (!isUpdatePossible()) return; assert(progressStack().size()); - ProgressInfoStatic::setProgress(progressStack().back() += progressSpanStack().back()); + ProgressInfoStatic::setProgress(progressStack().back() + progressSpanStack().back()); }