1 /* === S Y N F I G ========================================================= */ 2 /*! \file tool/renderprogress.h 3 ** \brief RenderProgress class 4 ** 5 ** $Id$ 6 ** 7 ** \legal 8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley 9 ** Copyright (c) 2007, 2008 Chris Moore 10 ** Copyright (c) 2014, 2015 Diego Barrios Romero 11 ** 12 ** This package is free software; you can redistribute it and/or 13 ** modify it under the terms of the GNU General Public License as 14 ** published by the Free Software Foundation; either version 2 of 15 ** the License, or (at your option) any later version. 16 ** 17 ** This package is distributed in the hope that it will be useful, 18 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 19 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 ** General Public License for more details. 21 ** \endlegal 22 */ 23 /* ========================================================================= */ 24 25 #ifndef __SYNFIG_RENDERPROGRESS_H 26 #define __SYNFIG_RENDERPROGRESS_H 27 28 #include <string> 29 #include <iosfwd> 30 #include <boost/chrono.hpp> 31 #include <synfig/progresscallback.h> 32 #include "definitions.h" 33 34 35 //! Prints the progress and estimated time left to the console 36 class RenderProgress : public synfig::ProgressCallback 37 { 38 public: 39 40 RenderProgress(); 41 42 virtual bool task(const std::string& taskname); 43 44 virtual bool error(const std::string& task); 45 46 virtual bool warning(const std::string& task); 47 48 virtual bool amount_complete(int scanline, int height); 49 private: 50 std::string taskname_; 51 int last_frame_; 52 size_t last_printed_line_length_; 53 54 typedef boost::chrono::system_clock Clock; 55 typedef boost::chrono::duration<double> Duration; 56 Clock::time_point start_timepoint_; 57 Clock::time_point last_timepoint_; 58 double remaining_rendered_proportion_; 59 60 void printRemainingTime(std::ostream& os, double remaining_seconds) const; 61 62 void printRemainingTime(std::ostream& os, 63 const int seconds, const int minutes, 64 const int hours, const int days, 65 const int weeks) const; 66 std::string extendLineToClearRest(std::string line, 67 size_t last_line_length) const; 68 }; 69 70 #endif 71