1 /* === S Y N F I G ========================================================= */
2 /*! \file tool/renderprogress.h
3 ** \brief RenderProgress class
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2007, 2008 Chris Moore
11 ** This package is free software; you can redistribute it and/or
12 ** modify it under the terms of the GNU General Public License as
13 ** published by the Free Software Foundation; either version 2 of
14 ** the License, or (at your option) any later version.
16 ** This package is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** General Public License for more details.
22 /* ========================================================================= */
24 #ifndef __SYNFIG_RENDERPROGRESS_H
25 #define __SYNFIG_RENDERPROGRESS_H
29 using namespace synfig;
31 #include <synfig/string.h>
32 #include "definitions.h"
34 class RenderProgress : public synfig::ProgressCallback
39 int clk_scanline; // The scanline at which the clock was reset
45 RenderProgress():clk_scanline(0), last_time(0) { }
48 task(const String &thetask)
55 error(const String &task)
57 std::cout<<_("error")<<": "<<task<<std::endl;
62 warning(const String &task)
64 std::cout<<_("warning")<<": "<<task<<std::endl;
69 amount_complete(int scanline, int h)
71 if(be_quiet)return true;
74 const float time(clk()*(float)(h-scanline)/(float)(scanline-clk_scanline));
75 const float delta(time-last_time);
77 int weeks=0,days=0,hours=0,minutes=0,seconds=0;
89 //cerr<<"reset"<<endl;
91 clk_scanline=scanline;
97 clk_scanline=scanline;
101 minutes++,seconds-=60;
109 cerr<<taskname<<": "<<_("Line")<<" "<<scanline<<_(" of ")<<h<<" -- ";
110 //cerr<<time/(h-clk_scanline)<<" ";
112 if(delta>=-time/(h-clk_scanline) )
115 if(delta>=0 && clk()>4.0 && scanline>clk_scanline+200)
117 //cerr<<"reset"<<endl;
119 clk_scanline=scanline;
123 /// TRANSLATORS This "w" stands for weeks
124 cerr<<weeks<<_("w ");
126 /// TRANSLATORS This "d" stands for days
129 /// TRANSLATORS This "h" stands for hours
130 cerr<<hours<<_("h ");
132 /// TRANSLATORS This "m" stands for minutes
133 cerr<<minutes<<_("m ");
135 /// TRANSLATORS This "s" stands for seconds
136 cerr<<seconds<<_("s ");
141 cerr<<taskname<<": "<<_("DONE")<<" "<<endl;;