Separated several classes into header files from tool main.cpp
authorDiego Barrios Romero <eldruin@gmailcom>
Wed, 17 Feb 2010 00:25:52 +0000 (01:25 +0100)
committerDiego Barrios Romero <eldruin@gmailcom>
Thu, 18 Feb 2010 21:58:30 +0000 (22:58 +0100)
synfig-core/src/tool/Makefile.am
synfig-core/src/tool/definitions.h [new file with mode: 0644]
synfig-core/src/tool/job.h [new file with mode: 0644]
synfig-core/src/tool/main.cpp
synfig-core/src/tool/progress.h [new file with mode: 0644]
synfig-core/src/tool/renderprogress.h [new file with mode: 0644]

index dabe04e..2109b1d 100644 (file)
@@ -14,8 +14,11 @@ INCLUDES = \
 bin_PROGRAMS = \
        synfig
 
-
 synfig_SOURCES = \
+       definitions.h \
+       progress.h \
+       renderprogress.h \
+       job.h \ 
        main.cpp
 
 synfig_LDADD = \
diff --git a/synfig-core/src/tool/definitions.h b/synfig-core/src/tool/definitions.h
new file mode 100644 (file)
index 0000000..bea4b7d
--- /dev/null
@@ -0,0 +1,71 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file tool/definitions.h
+**     \brief Definitions for synfig tool
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 2008 Chris Moore
+**
+**     This package is free software; you can redistribute it and/or
+**     modify it under the terms of the GNU General Public License as
+**     published by the Free Software Foundation; either version 2 of
+**     the License, or (at your option) any later version.
+**
+**     This package is distributed in the hope that it will be useful,
+**     but WITHOUT ANY WARRANTY; without even the implied warranty of
+**     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+**     General Public License for more details.
+**     \endlegal
+*/
+/* ========================================================================= */
+
+#ifndef __SYNFIG_DEFINITIONS_H
+#define __SYNFIG_DEFINITIONS_H
+
+/* === M A C R O S ========================================================= */
+
+#ifdef ENABLE_NLS
+#undef _
+#define _(x) gettext(x)
+#else
+#undef _
+#define _(x) (x)
+#endif
+
+enum exit_code
+{
+       SYNFIGTOOL_OK                           = 0,
+       SYNFIGTOOL_FILENOTFOUND         = 1,
+       SYNFIGTOOL_BORED                        = 2,
+       SYNFIGTOOL_HELP                         = 3,
+       SYNFIGTOOL_UNKNOWNARGUMENT      = 4,
+       SYNFIGTOOL_UNKNOWNERROR         = 5,
+       SYNFIGTOOL_INVALIDTARGET        = 6,
+       SYNFIGTOOL_RENDERFAILURE        = 7,
+       SYNFIGTOOL_BLANK                        = 8,
+       SYNFIGTOOL_BADVERSION           = 9,
+       SYNFIGTOOL_MISSINGARGUMENT      =10
+};
+
+#ifndef VERSION
+#define VERSION "unknown"
+#define PACKAGE "synfig-tool"
+#endif
+
+#ifdef DEFAULT_QUALITY
+#undef DEFAULT_QUALITY
+#endif
+
+#define DEFAULT_QUALITY                2
+#define VERBOSE_OUT(x) if(verbosity>=(x))std::cerr
+
+/* === G L O B A L S ======================================================= */
+
+extern const char *progname;
+extern int verbosity;
+extern bool be_quiet;
+extern bool print_benchmarks;
+
+#endif
diff --git a/synfig-core/src/tool/job.h b/synfig-core/src/tool/job.h
new file mode 100644 (file)
index 0000000..e0bc66f
--- /dev/null
@@ -0,0 +1,62 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file tool/job.h
+**     \brief Job class
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 2008 Chris Moore
+**
+**     This package is free software; you can redistribute it and/or
+**     modify it under the terms of the GNU General Public License as
+**     published by the Free Software Foundation; either version 2 of
+**     the License, or (at your option) any later version.
+**
+**     This package is distributed in the hope that it will be useful,
+**     but WITHOUT ANY WARRANTY; without even the implied warranty of
+**     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+**     General Public License for more details.
+**     \endlegal
+*/
+/* ========================================================================= */
+
+#ifndef __SYNFIG_JOB_H
+#define __SYNFIG_JOB_H
+
+using namespace synfig;
+
+#include <synfig/string.h>
+#include <synfig/canvas.h>
+#include <synfig/target.h>
+#include "definitions.h"
+
+struct Job
+{
+       String filename;
+       String outfilename;
+
+       RendDesc desc;
+
+       Canvas::Handle root;
+       Canvas::Handle canvas;
+       Target::Handle target;
+
+       int quality;
+       bool sifout;
+       bool list_canvases;
+
+       bool canvas_info, canvas_info_all, canvas_info_time_start, canvas_info_time_end, canvas_info_frame_rate,
+                canvas_info_frame_start, canvas_info_frame_end, canvas_info_w, canvas_info_h, canvas_info_image_aspect,
+                canvas_info_pw, canvas_info_ph, canvas_info_pixel_aspect, canvas_info_tl, canvas_info_br,
+                canvas_info_physical_w, canvas_info_physical_h, canvas_info_x_res, canvas_info_y_res, canvas_info_span,
+                canvas_info_interlaced, canvas_info_antialias, canvas_info_clamp, canvas_info_flags, canvas_info_focus,
+                canvas_info_bg_color, canvas_info_metadata;
+
+       Job()
+       {
+               canvas_info = canvas_info_all = canvas_info_time_start = canvas_info_time_end = canvas_info_frame_rate = canvas_info_frame_start = canvas_info_frame_end = canvas_info_w = canvas_info_h = canvas_info_image_aspect = canvas_info_pw = canvas_info_ph = canvas_info_pixel_aspect = canvas_info_tl = canvas_info_br = canvas_info_physical_w = canvas_info_physical_h = canvas_info_x_res = canvas_info_y_res = canvas_info_span = canvas_info_interlaced = canvas_info_antialias = canvas_info_clamp = canvas_info_flags = canvas_info_focus = canvas_info_bg_color = canvas_info_metadata = false;
+       };
+};
+
+#endif
index e325515..064959a 100644 (file)
 #include <synfig/main.h>
 #include <synfig/guid.h>
 #include <autorevision.h>
+#include "definitions.h"
+#include "progress.h"
+#include "renderprogress.h"
+#include "job.h"
 #endif
 
 using namespace std;
 using namespace etl;
 using namespace synfig;
 
-/* === M A C R O S ========================================================= */
-
-#ifdef ENABLE_NLS
-#undef _
-#define _(x) gettext(x)
-#else
-#undef _
-#define _(x) (x)
-#endif
-
-enum exit_code
-{
-       SYNFIGTOOL_OK                           = 0,
-       SYNFIGTOOL_FILENOTFOUND         = 1,
-       SYNFIGTOOL_BORED                        = 2,
-       SYNFIGTOOL_HELP                         = 3,
-       SYNFIGTOOL_UNKNOWNARGUMENT      = 4,
-       SYNFIGTOOL_UNKNOWNERROR         = 5,
-       SYNFIGTOOL_INVALIDTARGET        = 6,
-       SYNFIGTOOL_RENDERFAILURE        = 7,
-       SYNFIGTOOL_BLANK                        = 8,
-       SYNFIGTOOL_BADVERSION           = 9,
-       SYNFIGTOOL_MISSINGARGUMENT      =10
-};
-
-#ifndef VERSION
-#define VERSION "unknown"
-#define PACKAGE "synfig-tool"
-#endif
-
-#ifdef DEFAULT_QUALITY
-#undef DEFAULT_QUALITY
-#endif
-
-#define DEFAULT_QUALITY                2
-#define VERBOSE_OUT(x) if(verbosity>=(x))std::cerr
-
 /* === G L O B A L S ======================================================= */
 
 const char *progname;
@@ -101,182 +68,13 @@ int verbosity=0;
 bool be_quiet=false;
 bool print_benchmarks=false;
 
-/* === M E T H O D S ======================================================= */
-
-class Progress : public synfig::ProgressCallback
-{
-       const char *program;
-
-public:
-
-       Progress(const char *name):program(name) { }
-
-       virtual bool
-       task(const String &task)
-       {
-               VERBOSE_OUT(1)<<program<<": "<<task<<std::endl;
-               return true;
-       }
-
-       virtual bool
-       error(const String &task)
-       {
-               std::cerr<<program<<": "<<_("error")<<": "<<task<<std::endl;
-               return true;
-       }
-
-       virtual bool
-       warning(const String &task)
-       {
-               std::cerr<<program<<": "<<_("warning")<<": "<<task<<std::endl;
-               return true;
-       }
-
-       virtual bool
-       amount_complete(int /*current*/, int /*total*/)
-       {
-               return true;
-       }
-};
-
-class RenderProgress : public synfig::ProgressCallback
-{
-       string taskname;
-
-       etl::clock clk;
-       int clk_scanline; // The scanline at which the clock was reset
-       etl::clock clk2;
-
-       float last_time;
-public:
-
-       RenderProgress():clk_scanline(0), last_time(0) { }
-
-       virtual bool
-       task(const String &thetask)
-       {
-               taskname=thetask;
-               return true;
-       }
-
-       virtual bool
-       error(const String &task)
-       {
-               std::cout<<_("error")<<": "<<task<<std::endl;
-               return true;
-       }
-
-       virtual bool
-       warning(const String &task)
-       {
-               std::cout<<_("warning")<<": "<<task<<std::endl;
-               return true;
-       }
-
-       virtual bool
-       amount_complete(int scanline, int h)
-       {
-               if(be_quiet)return true;
-               if(scanline!=h)
-               {
-                       const float time(clk()*(float)(h-scanline)/(float)(scanline-clk_scanline));
-                       const float delta(time-last_time);
-
-                       int weeks=0,days=0,hours=0,minutes=0,seconds=0;
-
-                       last_time=time;
-
-                       if(clk2()<0.2)
-                               return true;
-                       clk2.reset();
-
-                       if(scanline)
-                               seconds=(int)time+1;
-                       else
-                       {
-                               //cerr<<"reset"<<endl;
-                               clk.reset();
-                               clk_scanline=scanline;
-                       }
-
-                       if(seconds<0)
-                       {
-                               clk.reset();
-                               clk_scanline=scanline;
-                               seconds=0;
-                       }
-                       while(seconds>=60)
-                               minutes++,seconds-=60;
-                       while(minutes>=60)
-                               hours++,minutes-=60;
-                       while(hours>=24)
-                               days++,hours-=24;
-                       while(days>=7)
-                               weeks++,days-=7;
-
-                       cerr<<taskname<<": "<<_("Line")<<" "<<scanline<<_(" of ")<<h<<" -- ";
-                       //cerr<<time/(h-clk_scanline)<<" ";
-                       /*
-                       if(delta>=-time/(h-clk_scanline)  )
-                               cerr<<">";
-                       */
-                       if(delta>=0 && clk()>4.0 && scanline>clk_scanline+200)
-                       {
-                               //cerr<<"reset"<<endl;
-                               clk.reset();
-                               clk_scanline=scanline;
-                       }
-
-                       if(weeks)
-                               cerr<<weeks<<"w ";
-                       if(days)
-                               cerr<<days<<"d ";
-                       if(hours)
-                               cerr<<hours<<"h ";
-                       if(minutes)
-                               cerr<<minutes<<"m ";
-                       if(seconds)
-                               cerr<<seconds<<"s ";
-
-                       cerr<<"           \r";
-               }
-               else
-                       cerr<<taskname<<": "<<_("DONE")<<"                        "<<endl;;
-               return true;
-       }
-};
-
-struct Job
-{
-       String filename;
-       String outfilename;
-
-       RendDesc desc;
-
-       Canvas::Handle root;
-       Canvas::Handle canvas;
-       Target::Handle target;
-
-       int quality;
-       bool sifout;
-       bool list_canvases;
-
-       bool canvas_info, canvas_info_all, canvas_info_time_start, canvas_info_time_end, canvas_info_frame_rate,
-                canvas_info_frame_start, canvas_info_frame_end, canvas_info_w, canvas_info_h, canvas_info_image_aspect,
-                canvas_info_pw, canvas_info_ph, canvas_info_pixel_aspect, canvas_info_tl, canvas_info_br,
-                canvas_info_physical_w, canvas_info_physical_h, canvas_info_x_res, canvas_info_y_res, canvas_info_span,
-                canvas_info_interlaced, canvas_info_antialias, canvas_info_clamp, canvas_info_flags, canvas_info_focus,
-                canvas_info_bg_color, canvas_info_metadata;
-
-       Job()
-       {
-               canvas_info = canvas_info_all = canvas_info_time_start = canvas_info_time_end = canvas_info_frame_rate = canvas_info_frame_start = canvas_info_frame_end = canvas_info_w = canvas_info_h = canvas_info_image_aspect = canvas_info_pw = canvas_info_ph = canvas_info_pixel_aspect = canvas_info_tl = canvas_info_br = canvas_info_physical_w = canvas_info_physical_h = canvas_info_x_res = canvas_info_y_res = canvas_info_span = canvas_info_interlaced = canvas_info_antialias = canvas_info_clamp = canvas_info_flags = canvas_info_focus = canvas_info_bg_color = canvas_info_metadata = false;
-       };
-};
+/* === T Y P E D E F S ===================================================== */
 
 typedef list<String> arg_list_t;
 typedef list<Job> job_list_t;
 
+/* === M E T H O D S ======================================================= */
+
 void guid_test()
 {
        cout<<"GUID Test"<<endl;
diff --git a/synfig-core/src/tool/progress.h b/synfig-core/src/tool/progress.h
new file mode 100644 (file)
index 0000000..76ce97e
--- /dev/null
@@ -0,0 +1,70 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file tool/progress.h
+**     \brief Progress class
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 2008 Chris Moore
+**
+**     This package is free software; you can redistribute it and/or
+**     modify it under the terms of the GNU General Public License as
+**     published by the Free Software Foundation; either version 2 of
+**     the License, or (at your option) any later version.
+**
+**     This package is distributed in the hope that it will be useful,
+**     but WITHOUT ANY WARRANTY; without even the implied warranty of
+**     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+**     General Public License for more details.
+**     \endlegal
+*/
+/* ========================================================================= */
+
+#ifndef __SYNFIG_PROGRESS_H
+#define __SYNFIG_PROGRESS_H
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+
+#include <synfig/string.h>
+#include "definitions.h"
+
+class Progress : public synfig::ProgressCallback
+{
+       const char *program;
+
+public:
+
+       Progress(const char *name):program(name) { }
+
+       virtual bool
+       task(const String &task)
+       {
+               VERBOSE_OUT(1)<<program<<": "<<task<<std::endl;
+               return true;
+       }
+
+       virtual bool
+       error(const String &task)
+       {
+               std::cerr<<program<<": "<<_("error")<<": "<<task<<std::endl;
+               return true;
+       }
+
+       virtual bool
+       warning(const String &task)
+       {
+               std::cerr<<program<<": "<<_("warning")<<": "<<task<<std::endl;
+               return true;
+       }
+
+       virtual bool
+       amount_complete(int /*current*/, int /*total*/)
+       {
+               return true;
+       }
+};
+
+#endif
diff --git a/synfig-core/src/tool/renderprogress.h b/synfig-core/src/tool/renderprogress.h
new file mode 100644 (file)
index 0000000..34aee80
--- /dev/null
@@ -0,0 +1,141 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file tool/renderprogress.h
+**     \brief RenderProgress class
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 2008 Chris Moore
+**
+**     This package is free software; you can redistribute it and/or
+**     modify it under the terms of the GNU General Public License as
+**     published by the Free Software Foundation; either version 2 of
+**     the License, or (at your option) any later version.
+**
+**     This package is distributed in the hope that it will be useful,
+**     but WITHOUT ANY WARRANTY; without even the implied warranty of
+**     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+**     General Public License for more details.
+**     \endlegal
+*/
+/* ========================================================================= */
+
+#ifndef __SYNFIG_RENDERPROGRESS_H
+#define __SYNFIG_RENDERPROGRESS_H
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+
+#include <synfig/string.h>
+#include "definitions.h"
+
+class RenderProgress : public synfig::ProgressCallback
+{
+       string taskname;
+
+       etl::clock clk;
+       int clk_scanline; // The scanline at which the clock was reset
+       etl::clock clk2;
+
+       float last_time;
+public:
+
+       RenderProgress():clk_scanline(0), last_time(0) { }
+
+       virtual bool
+       task(const String &thetask)
+       {
+               taskname=thetask;
+               return true;
+       }
+
+       virtual bool
+       error(const String &task)
+       {
+               std::cout<<_("error")<<": "<<task<<std::endl;
+               return true;
+       }
+
+       virtual bool
+       warning(const String &task)
+       {
+               std::cout<<_("warning")<<": "<<task<<std::endl;
+               return true;
+       }
+
+       virtual bool
+       amount_complete(int scanline, int h)
+       {
+               if(be_quiet)return true;
+               if(scanline!=h)
+               {
+                       const float time(clk()*(float)(h-scanline)/(float)(scanline-clk_scanline));
+                       const float delta(time-last_time);
+
+                       int weeks=0,days=0,hours=0,minutes=0,seconds=0;
+
+                       last_time=time;
+
+                       if(clk2()<0.2)
+                               return true;
+                       clk2.reset();
+
+                       if(scanline)
+                               seconds=(int)time+1;
+                       else
+                       {
+                               //cerr<<"reset"<<endl;
+                               clk.reset();
+                               clk_scanline=scanline;
+                       }
+
+                       if(seconds<0)
+                       {
+                               clk.reset();
+                               clk_scanline=scanline;
+                               seconds=0;
+                       }
+                       while(seconds>=60)
+                               minutes++,seconds-=60;
+                       while(minutes>=60)
+                               hours++,minutes-=60;
+                       while(hours>=24)
+                               days++,hours-=24;
+                       while(days>=7)
+                               weeks++,days-=7;
+
+                       cerr<<taskname<<": "<<_("Line")<<" "<<scanline<<_(" of ")<<h<<" -- ";
+                       //cerr<<time/(h-clk_scanline)<<" ";
+                       /*
+                       if(delta>=-time/(h-clk_scanline)  )
+                               cerr<<">";
+                       */
+                       if(delta>=0 && clk()>4.0 && scanline>clk_scanline+200)
+                       {
+                               //cerr<<"reset"<<endl;
+                               clk.reset();
+                               clk_scanline=scanline;
+                       }
+
+                       if(weeks)
+                               cerr<<weeks<<"w ";
+                       if(days)
+                               cerr<<days<<"d ";
+                       if(hours)
+                               cerr<<hours<<"h ";
+                       if(minutes)
+                               cerr<<minutes<<"m ";
+                       if(seconds)
+                               cerr<<seconds<<"s ";
+
+                       cerr<<"           \r";
+               }
+               else
+                       cerr<<taskname<<": "<<_("DONE")<<"                        "<<endl;;
+               return true;
+       }
+};
+
+#endif