From: Pablo d'A. <da...@us...> - 2007-04-15 20:59:45
|
Update of /cvsroot/hugin/hugin/src/common In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv20396/common Modified Files: utils.cpp Log Message: new progress report class Index: utils.cpp =================================================================== RCS file: /cvsroot/hugin/hugin/src/common/utils.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- utils.cpp 25 Jul 2006 21:13:27 -0000 1.12 +++ utils.cpp 15 Apr 2007 20:59:42 -0000 1.13 @@ -143,9 +143,50 @@ return number; } + utils::MultiProgressDisplay::MultiProgressDisplay(double minPrintStep) : m_minProgressStep(minPrintStep) { } +utils::StreamProgressReporter::StreamProgressReporter(double maxProgress, std::ostream & out) + : m_progress(0), m_maxProgress(maxProgress), m_stream(out) +{ + +} +utils::StreamProgressReporter::~StreamProgressReporter() +{ + m_stream << "\r" << std::flush; +} + +bool utils::StreamProgressReporter::increaseProgress(double delta) +{ + m_progress += delta; + print(); + // check for Ctrl-C ? + return true; +} + +bool utils::StreamProgressReporter::increaseProgress(double delta, const std::string & msg) +{ + m_message = msg; + m_progress += delta; + print(); + // check for Ctrl-C ? + return true; +} + +void utils::StreamProgressReporter::setMessage(const std::string & msg) +{ + m_message = msg; + print(); +} + +void utils::StreamProgressReporter::print() +{ + double prog = floor(m_progress/m_maxProgress*100); + if (prog > 100) prog = 100; + m_stream << "\r" << m_message << ": " << prog << "%" << std::flush; +} + |