4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "arraylist.h"
27 #include "batchrender.inc"
30 #include "browsebutton.inc"
31 #include "filexml.inc"
32 #include "formattools.h"
33 #include "indexable.inc"
34 #include "keyframe.inc"
35 #include "mwindow.inc"
36 #include "preferences.inc"
38 #include "timeentry.h"
41 ENABLED_COL, LABELED_COL, FARMED_COL,
42 OUTPUT_COL, EDL_COL, ELAPSED_COL,
46 class BatchRenderMenuItem : public BC_MenuItem
49 BatchRenderMenuItem(MWindow *mwindow);
59 BatchRenderJob(const char *tag,
60 Preferences *preferences, int labeled, int farmed);
61 BatchRenderJob(Preferences *preferences, int labeled, int farmed);
62 BatchRenderJob(const char *tag);
63 virtual ~BatchRenderJob();
64 virtual BatchRenderJob *copy();
65 virtual void load(FileXML *file);
66 virtual void save(FileXML *file);
67 virtual int get_strategy();
68 virtual char *create_script(EDL *edl, ArrayList<Indexable *> *idxbls);
69 void copy_from(BatchRenderJob *src);
72 // Source EDL to render
73 char edl_path[BCTEXTLEN];
74 // Destination file for output
78 // Amount of time elapsed in last render operation
80 Preferences *preferences;
84 class BatchRenderWarnJob
87 BatchRenderWarnJob() { no = 0; path = 0; }
88 ~BatchRenderWarnJob() { delete [] path; }
93 class BatchRenderWarnJobs : public ArrayList<BatchRenderWarnJob>
96 BatchRenderWarnJobs() {}
97 ~BatchRenderWarnJobs() {}
98 void add(int no, const char *path) {
99 BatchRenderWarnJob &job = append();
100 job.no = no; job.path = cstrdup(path);
104 class BatchRenderThread : public BC_DialogThread
107 BatchRenderThread(MWindow *mwindow=0);
108 ~BatchRenderThread();
109 void handle_close_event(int result);
110 BC_Window* new_gui();
112 int test_edl_files();
113 int test_errmsg(BatchRenderWarnJobs &err_jobs, const char *msg, int *warn);
114 void calculate_dest_paths(ArrayList<char*> *paths,
115 Preferences *preferences);
116 void reset(const char *path=0);
117 // Load batch rendering jobs
118 void load_jobs(char *path, Preferences *preferences);
119 // Not applicable to western civilizations
120 void save_jobs(char *path=0);
121 void load_defaults(BC_Hash *defaults);
122 void save_defaults(BC_Hash *defaults);
123 // Create path for persistent storage functions
124 char* create_path(char *string);
127 void update_selected_edl();
128 void use_current_edl();
129 // Conditionally returns the job or the default job based on current_job
130 BatchRenderJob* get_current_job();
131 Asset* get_current_asset();
132 char* get_current_edl();
133 // For command line usage
134 void start_rendering(char *config_path, char *batch_path);
136 void start_rendering();
137 void stop_rendering();
138 // Highlight the currently rendering job.
139 void update_active(int number);
140 void update_done(int number, int create_list, double elapsed_time);
141 void move_batch(int src, int dst);
142 void start(int do_farmed, int do_labeled);
143 static void trap_hook(FILE *fp, void *vp);
146 char batch_path[BCTEXTLEN];
147 double current_start;
149 BatchRenderJob *default_job;
150 ArrayList<BatchRenderJob*> jobs;
151 BC_Hash *boot_defaults;
152 Preferences *preferences;
156 static const char *column_titles[BATCHRENDER_COLUMNS];
157 static int column_widths[BATCHRENDER_COLUMNS];
158 int list_width[BATCHRENDER_COLUMNS];
163 // job being rendered
171 class BatchRenderEDLPath : public BC_TextBox
174 BatchRenderEDLPath(BatchRenderThread *thread, int x, int y, int w,
177 BatchRenderThread *thread;
181 class BatchRenderCurrentEDL : public BC_GenericButton
184 BatchRenderCurrentEDL(BatchRenderThread *thread, int x, int y);
186 BatchRenderThread *thread;
190 class BatchRenderUpdateEDL : public BC_GenericButton
193 BatchRenderUpdateEDL(BatchRenderThread *thread, int x, int y);
195 BatchRenderThread *thread;
199 class BatchRenderNew : public BC_GenericButton
202 BatchRenderNew(BatchRenderThread *thread, int x, int y);
204 BatchRenderThread *thread;
207 class BatchRenderDelete : public BC_GenericButton
210 BatchRenderDelete(BatchRenderThread *thread, int x, int y);
212 BatchRenderThread *thread;
217 class BatchRenderSaveList : public BC_GenericButton, public Thread
220 BatchRenderSaveList(BatchRenderThread *thread, int x, int y);
221 ~BatchRenderSaveList();
223 BatchRenderThread *thread;
227 virtual int keypress_event();
231 class BatchRenderLoadList : public BC_GenericButton, public Thread
234 BatchRenderLoadList(BatchRenderThread *thread, int x, int y);
235 ~BatchRenderLoadList();
237 BatchRenderThread *thread;
241 virtual int keypress_event();
247 class BatchRenderList : public BC_ListBox
250 BatchRenderList(BatchRenderThread *thread, int x, int y, int w, int h);
252 int selection_changed();
253 int column_resize_event();
254 int drag_start_event();
255 int drag_motion_event();
256 int drag_stop_event();
258 BatchRenderThread *thread;
260 class BatchRenderStart : public BC_GenericButton
263 BatchRenderStart(BatchRenderThread *thread, int x, int y);
265 BatchRenderThread *thread;
268 class BatchRenderStop : public BC_GenericButton
271 BatchRenderStop(BatchRenderThread *thread, int x, int y);
273 BatchRenderThread *thread;
276 class BatchRenderWarning : public BC_CheckBox
279 BatchRenderWarning(BatchRenderThread *thread, int x, int y);
281 BatchRenderThread *thread;
284 class BatchRenderCancel : public BC_GenericButton
287 BatchRenderCancel(BatchRenderThread *thread, int x, int y);
289 int keypress_event();
290 BatchRenderThread *thread;
294 class BatchFormat : public FormatTools
297 BatchFormat(MWindow *mwindow, BatchRenderGUI *gui, Asset *asset);
306 class BatchRenderUseFarm : public BC_CheckBox
309 BatchRenderUseFarm(BatchRenderThread *thread, int x, int y, int *output);
311 void update(int *output);
313 BatchRenderThread *thread;
318 class BatchRenderHelp : public BC_GenericButton
321 BatchRenderHelp(BatchRenderThread *thread, int x, int y);
323 BatchRenderThread *thread;
326 class BatchRenderGUI : public BC_Window
329 BatchRenderGUI(MWindow *mwindow,
330 BatchRenderThread *thread,
337 void create_objects();
338 int resize_event(int w, int h);
339 int translation_event();
341 void create_list(int update_widget);
343 void button_enable();
344 void button_disable();
346 ArrayList<BC_ListBoxItem*> list_items[BATCHRENDER_COLUMNS];
347 const char *list_titles[BATCHRENDER_COLUMNS];
348 int list_width[BATCHRENDER_COLUMNS], list_columns;
351 BatchRenderThread *thread;
352 BC_Title *output_path_title;
353 BatchFormat *format_tools;
354 BrowseButton *edl_path_browse;
355 BatchRenderEDLPath *edl_path_text;
356 BC_Title *edl_path_title;
357 // BC_Title *status_title;
358 // BC_Title *status_text;
359 // BC_ProgressBar *progress_bar;
360 BC_Title *list_title;
361 BC_Title *batch_path;
362 BatchRenderNew *new_batch;
363 BatchRenderDelete *delete_batch;
364 BatchRenderSaveList *savelist_batch;
365 BatchRenderLoadList *loadlist_batch;
366 BatchRenderWarning *warning;
367 BatchRenderList *batch_list;
368 BatchRenderStart *start_button;
369 BatchRenderStop *stop_button;
370 BatchRenderCancel *cancel_button;
371 BatchRenderCurrentEDL *use_current_edl;
372 BatchRenderUpdateEDL *update_selected_edl;
373 BatchRenderUseFarm *use_renderfarm;
374 BatchRenderHelp *help_button;