|
Diego Barrios Romero |
ffa0f8 |
/* === S Y N F I G ========================================================= */
|
|
Diego Barrios Romero |
ffa0f8 |
/*! \file tool/optionsprocessor.cpp
|
|
Diego Barrios Romero |
ffa0f8 |
** \brief Synfig Tool Options Processor Class
|
|
Diego Barrios Romero |
ffa0f8 |
**
|
|
Diego Barrios Romero |
ffa0f8 |
** $Id$
|
|
Diego Barrios Romero |
ffa0f8 |
**
|
|
Diego Barrios Romero |
ffa0f8 |
** \legal
|
|
Diego Barrios Romero |
ffa0f8 |
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
|
|
Diego Barrios Romero |
ffa0f8 |
** Copyright (c) 2007, 2008 Chris Moore
|
|
Diego Barrios Romero |
088628 |
** Copyright (c) 2009-2014 Diego Barrios Romero
|
|
Diego Barrios Romero |
ffa0f8 |
**
|
|
Diego Barrios Romero |
ffa0f8 |
** This package is free software; you can redistribute it and/or
|
|
Diego Barrios Romero |
ffa0f8 |
** modify it under the terms of the GNU General Public License as
|
|
Diego Barrios Romero |
ffa0f8 |
** published by the Free Software Foundation; either version 2 of
|
|
Diego Barrios Romero |
ffa0f8 |
** the License, or (at your option) any later version.
|
|
Diego Barrios Romero |
ffa0f8 |
**
|
|
Diego Barrios Romero |
ffa0f8 |
** This package is distributed in the hope that it will be useful,
|
|
Diego Barrios Romero |
ffa0f8 |
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Diego Barrios Romero |
ffa0f8 |
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Diego Barrios Romero |
ffa0f8 |
** General Public License for more details.
|
|
Diego Barrios Romero |
ffa0f8 |
** \endlegal
|
|
Diego Barrios Romero |
ffa0f8 |
*/
|
|
Diego Barrios Romero |
ffa0f8 |
/* ========================================================================= */
|
|
Diego Barrios Romero |
ffa0f8 |
|
|
Diego Barrios Romero |
53159b |
#ifdef USING_PCH
|
|
Diego Barrios Romero |
53159b |
# include "pch.h"
|
|
Diego Barrios Romero |
53159b |
#else
|
|
Diego Barrios Romero |
53159b |
#ifdef HAVE_CONFIG_H
|
|
Diego Barrios Romero |
53159b |
# include <config.h></config.h>
|
|
Diego Barrios Romero |
53159b |
#endif
|
|
Diego Barrios Romero |
53159b |
|
|
Diego Barrios Romero |
ffa0f8 |
#include <iostream></iostream>
|
|
|
3e2a84 |
//#include <boost format.hpp=""></boost>
|
|
Diego Barrios Romero |
ffa0f8 |
|
|
Diego Barrios Romero |
ffa0f8 |
#include <autorevision.h></autorevision.h>
|
|
Diego Barrios Romero |
ffa0f8 |
#include <synfig general.h=""></synfig>
|
|
bw |
94d8a6 |
#include <synfig localization.h=""></synfig>
|
|
Diego Barrios Romero |
ffa0f8 |
#include <synfig canvas.h=""></synfig>
|
|
|
eca4bf |
#include <synfig canvasfilenaming.h=""></synfig>
|
|
|
133def |
#include <synfig context.h=""></synfig>
|
|
Diego Barrios Romero |
ffa0f8 |
#include <synfig target.h=""></synfig>
|
|
Diego Barrios Romero |
b0b7fc |
#include <synfig layer.h=""></synfig>
|
|
Diego Barrios Romero |
b0b7fc |
#include <synfig module.h=""></synfig>
|
|
Diego Barrios Romero |
0b9c51 |
#include <synfig main.h=""></synfig>
|
|
Diego Barrios Romero |
b0b7fc |
#include <synfig importer.h=""></synfig>
|
|
Diego Barrios Romero |
71669d |
#include <synfig loadcanvas.h=""></synfig>
|
|
Diego Barrios Romero |
53159b |
#include <synfig guid.h=""></synfig>
|
|
caryoscelus |
6523b8 |
#include <synfig valuenode_registry.h=""></synfig>
|
|
|
bcf554 |
#include <synfig filesystemgroup.h=""></synfig>
|
|
|
d4b6c4 |
#include <synfig filesystemnative.h=""></synfig>
|
|
|
bcf554 |
#include <synfig filecontainerzip.h=""></synfig>
|
|
Diego Barrios Romero |
ffa0f8 |
|
|
Diego Barrios Romero |
ffa0f8 |
#include "definitions.h"
|
|
Diego Barrios Romero |
ffa0f8 |
#include "job.h"
|
|
Diego Barrios Romero |
d406bf |
#include "synfigtoolexception.h"
|
|
Diego Barrios Romero |
ffa0f8 |
#include "printing_functions.h"
|
|
Diego Barrios Romero |
ffa0f8 |
#include "optionsprocessor.h"
|
|
Diego Barrios Romero |
ffa0f8 |
|
|
Diego Barrios Romero |
53159b |
#endif
|
|
Diego Barrios Romero |
53159b |
|
|
Diego Barrios Romero |
ffa0f8 |
using namespace std;
|
|
Diego Barrios Romero |
b0b7fc |
using namespace synfig;
|
|
Diego Barrios Romero |
0b9c51 |
|
|
|
891c49 |
template<typename t=""></typename>
|
|
|
891c49 |
void SynfigCommandLineParser::add_option(Glib::OptionGroup& og, const std::string& name, const gchar& short_name,
|
|
|
891c49 |
T& entry, const std::string& description, const Glib::ustring& arg_description) {
|
|
|
891c49 |
|
|
|
891c49 |
Glib::OptionEntry new_entry;
|
|
|
891c49 |
new_entry.set_long_name(name);
|
|
|
891c49 |
if (short_name != ' ') new_entry.set_short_name(short_name);
|
|
|
891c49 |
new_entry.set_description(description);
|
|
|
891c49 |
new_entry.set_arg_description(arg_description);
|
|
|
891c49 |
og.add_entry(new_entry, entry);
|
|
|
891c49 |
}
|
|
|
891c49 |
|
|
|
891c49 |
// we need explicit method in case of different string/filename encodings
|
|
|
891c49 |
void SynfigCommandLineParser::add_option_filename(Glib::OptionGroup& og, const std::string& name, const gchar& short_name, std::string& entry, const std::string& description, const Glib::ustring& arg_description) {
|
|
|
891c49 |
Glib::OptionEntry new_entry;
|
|
|
891c49 |
new_entry.set_long_name(name);
|
|
|
891c49 |
if (short_name != ' ') new_entry.set_short_name(short_name);
|
|
|
891c49 |
new_entry.set_description(description);
|
|
|
891c49 |
new_entry.set_arg_description(arg_description);
|
|
|
891c49 |
og.add_entry_filename(new_entry, entry);
|
|
|
891c49 |
}
|
|
|
891c49 |
|
|
|
891c49 |
|
|
|
891c49 |
SynfigCommandLineParser::SynfigCommandLineParser() :
|
|
|
891c49 |
og_set("settings", _("Settings"), _("Show settings help")),
|
|
|
891c49 |
og_switch("switch", _("Switch options"), _("Show switch help")),
|
|
|
891c49 |
og_misc("misc", _("Misc options"), _("Show Misc options help")),
|
|
|
891c49 |
og_ffmpeg("ffmpeg", _("FFMPEG target options"), _("Show FFMPEG target options help")),
|
|
|
891c49 |
og_info("info", _("Synfig info options"), _("Show Synfig info options help")),
|
|
|
891c49 |
#ifdef _DEBUG
|
|
|
30c9aa |
og_debug("debug", _("Synfig debug flags"), _("Show Synfig debug flags help")),
|
|
|
891c49 |
#endif
|
|
|
891c49 |
set_target(),
|
|
|
891c49 |
set_width(),
|
|
|
891c49 |
set_height(),
|
|
|
891c49 |
set_span(),
|
|
|
891c49 |
set_antialias(),
|
|
|
891c49 |
set_quality(),
|
|
|
891c49 |
set_gamma(),
|
|
|
891c49 |
set_num_threads(),
|
|
|
891c49 |
set_input_file(),
|
|
|
891c49 |
set_output_file(),
|
|
|
891c49 |
set_sequence_separator(),
|
|
|
891c49 |
set_canvas_id(),
|
|
|
891c49 |
set_fps(),
|
|
|
891c49 |
set_time(),
|
|
|
891c49 |
set_begin_time(),
|
|
|
891c49 |
set_start_time(),
|
|
|
891c49 |
set_end_time(),
|
|
|
891c49 |
set_dpi(),
|
|
|
891c49 |
set_dpi_x(),
|
|
|
891c49 |
set_dpi_y(),
|
|
|
891c49 |
|
|
|
891c49 |
// Switch group
|
|
|
891c49 |
sw_verbosity(),
|
|
|
891c49 |
sw_quiet(),
|
|
|
891c49 |
sw_print_benchmarks(),
|
|
|
891c49 |
sw_extract_alpha(),
|
|
|
891c49 |
|
|
|
891c49 |
// Misc group
|
|
|
891c49 |
misc_append_filename(),
|
|
|
891c49 |
misc_canvas_info(),
|
|
|
891c49 |
misc_canvases(),
|
|
|
891c49 |
|
|
|
891c49 |
//FFMPEG group
|
|
|
891c49 |
video_codec(),
|
|
|
891c49 |
video_bitrate(),
|
|
|
891c49 |
|
|
|
891c49 |
// Debug group
|
|
|
891c49 |
#ifdef _DEBUG
|
|
|
891c49 |
debug_guid(),
|
|
|
891c49 |
debug_signal(),
|
|
|
891c49 |
#endif
|
|
|
891c49 |
|
|
|
891c49 |
// Synfig info group
|
|
|
891c49 |
show_help(),
|
|
|
891c49 |
show_importers(),
|
|
|
891c49 |
show_build_info(),
|
|
|
891c49 |
show_layers_list(),
|
|
|
891c49 |
show_layer_info(),
|
|
|
891c49 |
show_license(),
|
|
|
891c49 |
show_modules(),
|
|
|
891c49 |
show_targets(),
|
|
|
891c49 |
show_codecs(),
|
|
|
891c49 |
show_value_nodes(),
|
|
|
891c49 |
show_version()
|
|
Diego Barrios Romero |
0b9c51 |
{
|
|
|
891c49 |
Glib::init();
|
|
|
891c49 |
|
|
|
891c49 |
//og_set("settings", "Settings", "Show settings help");
|
|
|
891c49 |
add_option(og_set, "target", 't', set_target, _("Specify output target (Default: PNG)"), "module");
|
|
|
891c49 |
add_option(og_set, "width", 'w', set_width, _("Set the image width in pixels (Use zero for file default)"), "NUM");
|
|
|
891c49 |
add_option(og_set, "height", 'h', set_height, _("Set the image height in pixels (Use zero for file default)"), "NUM");
|
|
|
891c49 |
add_option(og_set, "span", 's', set_span, _("Set the diagonal size of image window (Span)"), "NUM");
|
|
|
891c49 |
add_option(og_set, "antialias", 'a', set_antialias, _("Set antialias amount for parametric renderer."), "1..30");
|
|
|
891c49 |
//og_set.add_option("quality", 'Q', quality_arg_desc, etl::strprintf(_("Specify image quality for accelerated renderer (Default: %d)"), DEFAULT_QUALITY).c_str(), "NUM");
|
|
|
891c49 |
add_option(og_set, "gamma", 'g', set_gamma, _("Gamma"), "2.2");
|
|
|
891c49 |
add_option(og_set, "threads", 'T', set_num_threads, _("Enable multithreaded renderer using the specified number of threads"), "NUM");
|
|
|
891c49 |
add_option(og_set, "input-file", 'i', set_input_file, _("Specify input filename"), "filename");
|
|
|
891c49 |
add_option(og_set, "output-file", 'o', set_output_file, _("Specify output filename"), "filename");
|
|
|
891c49 |
add_option(og_set, "sequence-separator", ' ', set_sequence_separator, _("Output file sequence separator string (Use double quotes if you want to use spaces)"), "string");
|
|
|
891c49 |
add_option(og_set, "canvas", 'c', set_canvas_id, _("Render the canvas with the given id instead of the root."), "id");
|
|
|
891c49 |
add_option(og_set, "fps", ' ', set_fps, _("Set the frame rate"), "NUM");
|
|
|
891c49 |
add_option(og_set, "time", ' ', set_time, _("Render a single frame at <seconds>"), "seconds");</seconds>
|
|
|
891c49 |
add_option(og_set, "begin-time", ' ', set_begin_time, _("Set the starting time"), "seconds");
|
|
|
891c49 |
add_option(og_set, "start-time", ' ', set_start_time, _("Set the starting time"), "seconds");
|
|
|
891c49 |
add_option(og_set, "end-time", ' ', set_end_time, _("Set the ending time"), "seconds");
|
|
|
891c49 |
add_option(og_set, "dpi", ' ', set_dpi, _("Set the physical resolution (Dots-per-inch)"), "NUM");
|
|
|
891c49 |
add_option(og_set, "dpi-x", ' ', set_dpi_x, _("Set the physical X resolution (Dots-per-inch)"), "NUM");
|
|
|
891c49 |
add_option(og_set, "dpi-y", ' ', set_dpi_y, _("Set the physical Y resolution (Dots-per-inch)"), "NUM");
|
|
|
891c49 |
|
|
|
891c49 |
// Switch options
|
|
|
891c49 |
//og_switch("switch", _("Switch options"), "Show switch help");
|
|
|
891c49 |
add_option(og_switch, "verbose", 'v', sw_verbosity, _("Output verbosity level"), "NUM");
|
|
|
891c49 |
add_option(og_switch, "quiet", 'q', sw_quiet, _("Quiet mode (No progress/time-remaining display)"), "");
|
|
|
891c49 |
add_option(og_switch, "benchmarks", 'b', sw_print_benchmarks, _("Print benchmarks"), "");
|
|
|
891c49 |
add_option(og_switch, "extract-alpha", 'x', sw_extract_alpha, _("Extract alpha"), "");
|
|
|
891c49 |
|
|
|
891c49 |
//SynfigOptionGroup og_misc("misc", _("Misc options"), "Show Misc options help");
|
|
|
891c49 |
add_option_filename(og_misc, "append", ' ', misc_append_filename, _("Append layers in <filename> to composition"), _("filename"));</filename>
|
|
|
891c49 |
add_option(og_misc, "canvas-info", ' ', misc_canvas_info, _("Print out specified details of the root canvas"), _("fields"));
|
|
|
891c49 |
add_option(og_misc, "canvases", ' ', misc_canvases, _("Print out the list of exported canvases in the composition"), "");
|
|
|
891c49 |
|
|
|
891c49 |
//SynfigOptionGroup og_ffmpeg("ffmpeg", _("FFMPEG target options"), "Show FFMPEG target options help");
|
|
|
891c49 |
add_option(og_ffmpeg, "video-codec", ' ', video_codec, _("Set the codec for the video. See --target-video-codecs"), _("codec"));
|
|
|
891c49 |
add_option(og_ffmpeg, "video-bitrate", ' ', video_bitrate, _("Set the bitrate for the output video"), _("bitrate"));
|
|
|
891c49 |
|
|
|
891c49 |
//SynfigOptionGroup og_info("info", _("Synfig info options"), "Show Synfig info options help");
|
|
|
891c49 |
add_option(og_info, "help", ' ', show_help, _("Produce this help message"), "");
|
|
|
891c49 |
add_option(og_info, "importers", ' ', show_importers, _("Print out the list of available importers"), "");
|
|
|
891c49 |
add_option(og_info, "info", ' ', show_build_info, _("Print out misc build information"), "");
|
|
|
891c49 |
add_option(og_info, "layers", ' ', show_layers_list, _("Print out the list of available layers"), "");
|
|
|
891c49 |
add_option(og_info, "layer-info", ' ', show_layer_info, _("Print out layer's description, parameter info, etc."), _("layer-name"));
|
|
|
891c49 |
add_option(og_info, "license", ' ', show_license, _("Print out license information"), "");
|
|
|
891c49 |
add_option(og_info, "modules", ' ', show_modules, _("Print out the list of loaded modules"), "");
|
|
|
891c49 |
add_option(og_info, "targets", ' ', show_targets, _("Print out the list of available targets"), "");
|
|
|
891c49 |
add_option(og_info, "target-video-codecs",' ', show_codecs, _("Print out the list of available video codecs when encoding through FFMPEG"), "");
|
|
|
891c49 |
add_option(og_info, "valuenodes", ' ', show_value_nodes, _("Print out the list of available ValueNodes"), "");
|
|
|
891c49 |
add_option(og_info, "version", ' ', show_version, _("Print out version information"), "");
|
|
|
891c49 |
|
|
|
891c49 |
#ifdef _DEBUG
|
|
|
891c49 |
//SynfigOptionGroup og_debug("debug", _("Synfig debug flags"), "Show Synfig debug flags help");
|
|
|
891c49 |
add_option(og_debug, "guid-test", ' ', debug_guid, _("Test GUID generation"), "");
|
|
|
891c49 |
add_option(og_debug, "signal-test", ' ', debug_signal, _("Test signal implementation"), "");
|
|
|
891c49 |
#endif
|
|
|
891c49 |
|
|
|
891c49 |
// remaining options
|
|
|
891c49 |
Glib::OptionEntry entry_remaining;
|
|
|
891c49 |
entry_remaining.set_long_name(G_OPTION_REMAINING);
|
|
|
891c49 |
entry_remaining.set_arg_description(G_OPTION_REMAINING);
|
|
|
891c49 |
og_info.add_entry(entry_remaining, remaining_options_list);
|
|
|
891c49 |
|
|
|
891c49 |
context.add_group(og_set);
|
|
|
891c49 |
context.add_group(og_switch);
|
|
|
891c49 |
context.add_group(og_misc);
|
|
|
891c49 |
context.add_group(og_ffmpeg);
|
|
|
891c49 |
//context.add_group(og_info);
|
|
|
891c49 |
context.set_main_group(og_info); // remaining args works only in main group (OMG!)
|
|
|
891c49 |
#ifdef _DEBUG
|
|
|
891c49 |
context.add_group(og_debug);
|
|
|
891c49 |
#endif
|
|
|
891c49 |
|
|
Diego Barrios Romero |
0b9c51 |
_allowed_video_codecs.push_back(VideoCodec("flv", "Flash Video (FLV) / Sorenson Spark / Sorenson H.263."));
|
|
Diego Barrios Romero |
0b9c51 |
_allowed_video_codecs.push_back(VideoCodec("h263p", "H.263+ / H.263-1998 / H.263 version 2."));
|
|
Diego Barrios Romero |
0b9c51 |
_allowed_video_codecs.push_back(VideoCodec("huffyuv", "Huffyuv / HuffYUV."));
|
|
Diego Barrios Romero |
0b9c51 |
_allowed_video_codecs.push_back(VideoCodec("libtheora", "libtheora Theora."));
|
|
Diego Barrios Romero |
0b9c51 |
_allowed_video_codecs.push_back(VideoCodec("libx264", "H.264 / AVC / MPEG-4 AVC."));
|
|
Diego Barrios Romero |
0b9c51 |
_allowed_video_codecs.push_back(VideoCodec("libx264-lossless", "H.264 / AVC / MPEG-4 AVC (LossLess)."));
|
|
Diego Barrios Romero |
0b9c51 |
_allowed_video_codecs.push_back(VideoCodec("mjpeg", "MJPEG (Motion JPEG)."));
|
|
Diego Barrios Romero |
0b9c51 |
_allowed_video_codecs.push_back(VideoCodec("mpeg1video", "Raw MPEG-1 video."));
|
|
Diego Barrios Romero |
0b9c51 |
_allowed_video_codecs.push_back(VideoCodec("mpeg2video", "Raw MPEG-2 video."));
|
|
Diego Barrios Romero |
0b9c51 |
_allowed_video_codecs.push_back(VideoCodec("mpeg4", "MPEG-4 part 2 (XviD/DivX)."));
|
|
Diego Barrios Romero |
0b9c51 |
_allowed_video_codecs.push_back(VideoCodec("msmpeg4", "MPEG-4 part 2 Microsoft variant version 3."));
|
|
Diego Barrios Romero |
0b9c51 |
_allowed_video_codecs.push_back(VideoCodec("msmpeg4v1", "MPEG-4 part 2 Microsoft variant version 1."));
|
|
Diego Barrios Romero |
0b9c51 |
_allowed_video_codecs.push_back(VideoCodec("msmpeg4v2", "MPEG-4 part 2 Microsoft variant version 2."));
|
|
Diego Barrios Romero |
0b9c51 |
_allowed_video_codecs.push_back(VideoCodec("wmv1", "Windows Media Video 7."));
|
|
Diego Barrios Romero |
0b9c51 |
_allowed_video_codecs.push_back(VideoCodec("wmv2", "Windows Media Video 8."));
|
|
|
891c49 |
|
|
|
891c49 |
}
|
|
|
891c49 |
|
|
|
891c49 |
bool SynfigCommandLineParser::parse(int argc, char* argv[])
|
|
|
891c49 |
{
|
|
|
891c49 |
|
|
|
891c49 |
#ifdef GLIBMM_EXCEPTIONS_ENABLED
|
|
|
891c49 |
try
|
|
|
891c49 |
{
|
|
|
891c49 |
context.parse(argc, argv);
|
|
|
891c49 |
}
|
|
|
891c49 |
catch(const Glib::Error& ex)
|
|
|
891c49 |
{
|
|
|
891c49 |
std::cout << "Exception: " << ex.what() << std::endl;
|
|
|
891c49 |
return false;
|
|
|
891c49 |
}
|
|
|
891c49 |
#else
|
|
|
891c49 |
std::auto_ptr<glib::error> ex;</glib::error>
|
|
|
891c49 |
context.parse(argc, argv, ex);
|
|
|
891c49 |
if(ex.get())
|
|
|
891c49 |
{
|
|
|
891c49 |
std::cout << "Exception: " << ex->what() << std::endl;
|
|
|
891c49 |
return false;
|
|
|
891c49 |
}
|
|
|
891c49 |
#endif //GLIBMM_EXCEPTIONS_ENABLED
|
|
|
891c49 |
|
|
|
891c49 |
// set input filename from remaining options if it not already filled
|
|
|
891c49 |
if (!remaining_options_list.empty() && set_input_file.empty()) set_input_file = remaining_options_list.front();
|
|
|
891c49 |
|
|
|
891c49 |
return true;
|
|
Diego Barrios Romero |
0b9c51 |
}
|
|
Diego Barrios Romero |
71669d |
|
|
|
891c49 |
void SynfigCommandLineParser::extract_canvas_info(Job& job)
|
|
Diego Barrios Romero |
71669d |
{
|
|
Diego Barrios Romero |
71669d |
job.canvas_info = true;
|
|
Diego Barrios Romero |
71669d |
string value;
|
|
|
891c49 |
string values = misc_canvas_info;//_vm["canvas-info"].as<string>();</string>
|
|
Diego Barrios Romero |
71669d |
|
|
Diego Barrios Romero |
71669d |
std::string::size_type pos;
|
|
Diego Barrios Romero |
71669d |
while (!values.empty())
|
|
Diego Barrios Romero |
71669d |
{
|
|
Diego Barrios Romero |
71669d |
pos = values.find_first_of(',');
|
|
Diego Barrios Romero |
71669d |
if (pos == std::string::npos)
|
|
Diego Barrios Romero |
71669d |
{
|
|
Diego Barrios Romero |
71669d |
value = values;
|
|
Diego Barrios Romero |
71669d |
values = "";
|
|
Diego Barrios Romero |
71669d |
}
|
|
Diego Barrios Romero |
71669d |
else
|
|
Diego Barrios Romero |
71669d |
{
|
|
Diego Barrios Romero |
71669d |
value = values.substr(0, pos);
|
|
Diego Barrios Romero |
71669d |
values = values.substr(pos+1);
|
|
Diego Barrios Romero |
71669d |
}
|
|
Diego Barrios Romero |
71669d |
if (value == "all")
|
|
Diego Barrios Romero |
71669d |
{
|
|
Diego Barrios Romero |
71669d |
job.canvas_info_all = true;
|
|
Diego Barrios Romero |
71669d |
return;
|
|
Diego Barrios Romero |
71669d |
}
|
|
Diego Barrios Romero |
71669d |
|
|
Diego Barrios Romero |
71669d |
if (value == "time_start") job.canvas_info_time_start = true;
|
|
Diego Barrios Romero |
71669d |
else if (value == "time_end") job.canvas_info_time_end = true;
|
|
Diego Barrios Romero |
71669d |
else if (value == "frame_rate") job.canvas_info_frame_rate = true;
|
|
Diego Barrios Romero |
71669d |
else if (value == "frame_start") job.canvas_info_frame_start = true;
|
|
Diego Barrios Romero |
71669d |
else if (value == "frame_end") job.canvas_info_frame_end = true;
|
|
Diego Barrios Romero |
71669d |
else if (value == "w") job.canvas_info_w = true;
|
|
Diego Barrios Romero |
71669d |
else if (value == "h") job.canvas_info_h = true;
|
|
Diego Barrios Romero |
71669d |
else if (value == "image_aspect") job.canvas_info_image_aspect = true;
|
|
Diego Barrios Romero |
71669d |
else if (value == "pw") job.canvas_info_pw = true;
|
|
Diego Barrios Romero |
71669d |
else if (value == "ph") job.canvas_info_ph = true;
|
|
Diego Barrios Romero |
71669d |
else if (value == "pixel_aspect") job.canvas_info_pixel_aspect = true;
|
|
Diego Barrios Romero |
71669d |
else if (value == "tl") job.canvas_info_tl = true;
|
|
Diego Barrios Romero |
71669d |
else if (value == "br") job.canvas_info_br = true;
|
|
Diego Barrios Romero |
71669d |
else if (value == "physical_w") job.canvas_info_physical_w = true;
|
|
Diego Barrios Romero |
71669d |
else if (value == "physical_h") job.canvas_info_physical_h = true;
|
|
Diego Barrios Romero |
71669d |
else if (value == "x_res") job.canvas_info_x_res = true;
|
|
Diego Barrios Romero |
71669d |
else if (value == "y_res") job.canvas_info_y_res = true;
|
|
Diego Barrios Romero |
71669d |
else if (value == "span") job.canvas_info_span = true;
|
|
Diego Barrios Romero |
71669d |
else if (value == "interlaced") job.canvas_info_interlaced = true;
|
|
Diego Barrios Romero |
71669d |
else if (value == "antialias") job.canvas_info_antialias = true;
|
|
Diego Barrios Romero |
71669d |
else if (value == "clamp") job.canvas_info_clamp = true;
|
|
Diego Barrios Romero |
71669d |
else if (value == "flags") job.canvas_info_flags = true;
|
|
Diego Barrios Romero |
71669d |
else if (value == "focus") job.canvas_info_focus = true;
|
|
Diego Barrios Romero |
71669d |
else if (value == "bg_color") job.canvas_info_bg_color = true;
|
|
Diego Barrios Romero |
71669d |
else if (value == "metadata") job.canvas_info_metadata = true;
|
|
Diego Barrios Romero |
71669d |
else
|
|
Diego Barrios Romero |
71669d |
{
|
|
Carlos Lopez |
ac6eb5 |
cerr << _("Unrecognised canvas variable: ") << "'" << value.c_str() << "'" << endl;
|
|
Diego Barrios Romero |
71669d |
cerr << _("Recognized variables are:") << endl <<
|
|
Diego Barrios Romero |
71669d |
" all, time_start, time_end, frame_rate, frame_start, frame_end, w, h," << endl <<
|
|
Diego Barrios Romero |
71669d |
" image_aspect, pw, ph, pixel_aspect, tl, br, physical_w, physical_h," << endl <<
|
|
Diego Barrios Romero |
71669d |
" x_res, y_res, span, interlaced, antialias, clamp, flags," << endl <<
|
|
Diego Barrios Romero |
71669d |
" focus, bg_color, metadata" << endl;
|
|
Diego Barrios Romero |
71669d |
}
|
|
Diego Barrios Romero |
71669d |
|
|
Diego Barrios Romero |
71669d |
if (pos == std::string::npos)
|
|
Diego Barrios Romero |
71669d |
break;
|
|
Diego Barrios Romero |
71669d |
};
|
|
Diego Barrios Romero |
71669d |
}
|
|
Diego Barrios Romero |
ffa0f8 |
|
|
|
891c49 |
void SynfigCommandLineParser::process_settings_options()
|
|
Diego Barrios Romero |
ffa0f8 |
{
|
|
|
891c49 |
if (sw_verbosity > 0)
|
|
Diego Barrios Romero |
ffa0f8 |
{
|
|
|
891c49 |
SynfigToolGeneralOptions::instance()->set_verbosity(sw_verbosity);
|
|
Diego Barrios Romero |
0b9c51 |
VERBOSE_OUT(1) << _("verbosity set to ")
|
|
Diego Barrios Romero |
0b9c51 |
<< SynfigToolGeneralOptions::instance()->get_verbosity()
|
|
Diego Barrios Romero |
0b9c51 |
<< std::endl;
|
|
Diego Barrios Romero |
ffa0f8 |
}
|
|
Diego Barrios Romero |
ffa0f8 |
|
|
|
891c49 |
if (sw_print_benchmarks)
|
|
Diego Barrios Romero |
0b9c51 |
{
|
|
Diego Barrios Romero |
0b9c51 |
SynfigToolGeneralOptions::instance()->set_should_print_benchmarks(true);
|
|
Diego Barrios Romero |
0b9c51 |
}
|
|
Diego Barrios Romero |
ffa0f8 |
|
|
|
891c49 |
if (sw_quiet)
|
|
Diego Barrios Romero |
0b9c51 |
{
|
|
Diego Barrios Romero |
0b9c51 |
SynfigToolGeneralOptions::instance()->set_should_be_quiet(true);
|
|
Diego Barrios Romero |
0b9c51 |
}
|
|
Diego Barrios Romero |
c5f825 |
|
|
|
891c49 |
if (set_num_threads > 0)
|
|
Diego Barrios Romero |
0b9c51 |
{
|
|
|
891c49 |
SynfigToolGeneralOptions::instance()->set_threads(set_num_threads);
|
|
Diego Barrios Romero |
0b9c51 |
}
|
|
Diego Barrios Romero |
c5f825 |
|
|
Diego Barrios Romero |
0b9c51 |
VERBOSE_OUT(1) << _("Threads set to ")
|
|
Diego Barrios Romero |
0b9c51 |
<< SynfigToolGeneralOptions::instance()->get_threads() << std::endl;
|
|
Diego Barrios Romero |
ffa0f8 |
}
|
|
Diego Barrios Romero |
ffa0f8 |
|
|
|
891c49 |
//void OptionsProcessor::process_info_options()
|
|
|
891c49 |
void SynfigCommandLineParser::process_info_options()
|
|
Diego Barrios Romero |
ffa0f8 |
{
|
|
|
891c49 |
if (show_help)
|
|
Diego Barrios Romero |
ffa0f8 |
{
|
|
Diego Barrios Romero |
ffa0f8 |
print_usage();
|
|
|
891c49 |
//cout << _po_visible;
|
|
Diego Barrios Romero |
ffa0f8 |
|
|
Diego Barrios Romero |
d406bf |
throw (SynfigToolException(SYNFIGTOOL_HELP));
|
|
Diego Barrios Romero |
ffa0f8 |
}
|
|
Diego Barrios Romero |
ffa0f8 |
|
|
|
891c49 |
if (show_build_info)
|
|
Diego Barrios Romero |
ffa0f8 |
{
|
|
Diego Barrios Romero |
ffa0f8 |
cout << PACKAGE "-" VERSION << endl;
|
|
Diego Barrios Romero |
ffa0f8 |
#ifdef DEVEL_VERSION
|
|
Diego Barrios Romero |
ffa0f8 |
cout << endl << DEVEL_VERSION << endl << endl;
|
|
Diego Barrios Romero |
ffa0f8 |
#endif
|
|
Diego Barrios Romero |
ffa0f8 |
cout << "Compiled on " __DATE__ /* " at "__TIME__ */;
|
|
Diego Barrios Romero |
ffa0f8 |
#ifdef __GNUC__
|
|
Diego Barrios Romero |
ffa0f8 |
cout << " with GCC " << __VERSION__;
|
|
Diego Barrios Romero |
ffa0f8 |
#endif
|
|
Diego Barrios Romero |
ffa0f8 |
#ifdef _MSC_VER
|
|
Diego Barrios Romero |
ffa0f8 |
cout << " with Microsoft Visual C++ "
|
|
Diego Barrios Romero |
ffa0f8 |
<< (_MSC_VER>>8) << '.' << (_MSC_VER&255);
|
|
Diego Barrios Romero |
ffa0f8 |
#endif
|
|
Diego Barrios Romero |
ffa0f8 |
#ifdef __TCPLUSPLUS__
|
|
Diego Barrios Romero |
ffa0f8 |
cout << " with Borland Turbo C++ "
|
|
Diego Barrios Romero |
ffa0f8 |
<< (__TCPLUSPLUS__>>8) << '.'
|
|
Diego Barrios Romero |
ffa0f8 |
<< ((__TCPLUSPLUS__&255)>>4) << '.'
|
|
Diego Barrios Romero |
ffa0f8 |
<< (__TCPLUSPLUS__&15);
|
|
Diego Barrios Romero |
ffa0f8 |
#endif
|
|
Diego Barrios Romero |
ffa0f8 |
cout << endl << SYNFIG_COPYRIGHT << endl;
|
|
Diego Barrios Romero |
ffa0f8 |
cout << endl;
|
|
Diego Barrios Romero |
ffa0f8 |
|
|
Diego Barrios Romero |
d406bf |
throw (SynfigToolException(SYNFIGTOOL_HELP));
|
|
Diego Barrios Romero |
ffa0f8 |
}
|
|
Diego Barrios Romero |
ffa0f8 |
|
|
|
891c49 |
if (show_version)
|
|
Diego Barrios Romero |
ffa0f8 |
{
|
|
Diego Barrios Romero |
ffa0f8 |
cerr << PACKAGE << " " << VERSION << endl;
|
|
Diego Barrios Romero |
ffa0f8 |
|
|
Diego Barrios Romero |
d406bf |
throw (SynfigToolException(SYNFIGTOOL_HELP));
|
|
Diego Barrios Romero |
ffa0f8 |
}
|
|
Diego Barrios Romero |
ffa0f8 |
|
|
|
891c49 |
if (show_license)
|
|
Diego Barrios Romero |
ffa0f8 |
{
|
|
Diego Barrios Romero |
ffa0f8 |
cerr << PACKAGE << " " << VERSION << endl;
|
|
Diego Barrios Romero |
ffa0f8 |
cout << SYNFIG_COPYRIGHT << endl << endl;
|
|
Diego Barrios Romero |
ffa0f8 |
cerr << SYNFIG_LICENSE << endl << endl;
|
|
Diego Barrios Romero |
ffa0f8 |
|
|
Diego Barrios Romero |
d406bf |
throw (SynfigToolException(SYNFIGTOOL_HELP));
|
|
Diego Barrios Romero |
ffa0f8 |
}
|
|
Diego Barrios Romero |
ffa0f8 |
|
|
|
891c49 |
if (show_codecs)
|
|
Diego Barrios Romero |
ffa0f8 |
{
|
|
Diego Barrios Romero |
ffa0f8 |
print_target_video_codecs_help();
|
|
Diego Barrios Romero |
ffa0f8 |
|
|
Diego Barrios Romero |
d406bf |
throw (SynfigToolException(SYNFIGTOOL_HELP));
|
|
Diego Barrios Romero |
ffa0f8 |
}
|
|
Diego Barrios Romero |
ffa0f8 |
|
|
|
891c49 |
if (show_layers_list)
|
|
Diego Barrios Romero |
b0b7fc |
{
|
|
Diego Barrios Romero |
b0b7fc |
synfig::Layer::Book::iterator iter =
|
|
Diego Barrios Romero |
b0b7fc |
synfig::Layer::book().begin();
|
|
Diego Barrios Romero |
b0b7fc |
for(; iter != synfig::Layer::book().end(); iter++)
|
|
Diego Barrios Romero |
b0b7fc |
if (iter->second.category != CATEGORY_DO_NOT_USE)
|
|
Carlos Lopez |
ac6eb5 |
cout << (iter->first).c_str() << endl;
|
|
Diego Barrios Romero |
b0b7fc |
|
|
Diego Barrios Romero |
d406bf |
throw (SynfigToolException(SYNFIGTOOL_HELP));
|
|
Diego Barrios Romero |
b0b7fc |
}
|
|
Diego Barrios Romero |
b0b7fc |
|
|
|
891c49 |
if (!show_layer_info.empty())
|
|
Diego Barrios Romero |
b0b7fc |
{
|
|
|
891c49 |
Layer::Handle layer = synfig::Layer::create(show_layer_info.c_str());
|
|
Diego Barrios Romero |
b0b7fc |
|
|
Diego Barrios Romero |
0d46b7 |
cout << _("Layer Name: ") << layer->get_name() << endl;
|
|
Diego Barrios Romero |
b0b7fc |
cout << _("Localized Layer Name: ")
|
|
Diego Barrios Romero |
0d46b7 |
<< layer->get_local_name() << endl;
|
|
Diego Barrios Romero |
0d46b7 |
cout << _("Version: ") << layer->get_version() << endl;
|
|
Diego Barrios Romero |
b0b7fc |
|
|
Diego Barrios Romero |
b0b7fc |
Layer::Vocab vocab = layer->get_param_vocab();
|
|
Diego Barrios Romero |
b0b7fc |
for(; !vocab.empty(); vocab.pop_front())
|
|
Diego Barrios Romero |
b0b7fc |
{
|
|
Carlos Lopez |
ac6eb5 |
cout << _("param - ") << vocab.front().get_name().c_str();
|
|
Diego Barrios Romero |
b0b7fc |
if(!vocab.front().get_critical())
|
|
Diego Barrios Romero |
b0b7fc |
cout << _(" (not critical)");
|
|
Diego Barrios Romero |
b0b7fc |
cout << endl << _("\tLocalized Name: ")
|
|
Carlos Lopez |
ac6eb5 |
<< vocab.front().get_local_name().c_str() << endl;
|
|
Diego Barrios Romero |
b0b7fc |
|
|
Diego Barrios Romero |
b0b7fc |
if(!vocab.front().get_description().empty())
|
|
Diego Barrios Romero |
b0b7fc |
cout << _("\tDescription: ")
|
|
Carlos Lopez |
ac6eb5 |
<< vocab.front().get_description().c_str() << endl;
|
|
Diego Barrios Romero |
b0b7fc |
|
|
Diego Barrios Romero |
b0b7fc |
if(!vocab.front().get_hint().empty())
|
|
Diego Barrios Romero |
b0b7fc |
cout << _("\tHint: ")
|
|
Carlos Lopez |
ac6eb5 |
<< vocab.front().get_hint().c_str() << endl;
|
|
Diego Barrios Romero |
b0b7fc |
}
|
|
Diego Barrios Romero |
b0b7fc |
|
|
Diego Barrios Romero |
d406bf |
throw (SynfigToolException(SYNFIGTOOL_HELP));
|
|
Diego Barrios Romero |
b0b7fc |
}
|
|
Diego Barrios Romero |
b0b7fc |
|
|
|
891c49 |
if (show_modules)
|
|
Diego Barrios Romero |
b0b7fc |
{
|
|
Diego Barrios Romero |
b0b7fc |
synfig::Module::Book::iterator iter =
|
|
Diego Barrios Romero |
b0b7fc |
synfig::Module::book().begin();
|
|
Diego Barrios Romero |
b0b7fc |
for(; iter != synfig::Module::book().end(); iter++)
|
|
Carlos Lopez |
ac6eb5 |
cout << (iter->first).c_str() << endl;
|
|
Diego Barrios Romero |
b0b7fc |
|
|
Diego Barrios Romero |
d406bf |
throw (SynfigToolException(SYNFIGTOOL_HELP));
|
|
Diego Barrios Romero |
b0b7fc |
}
|
|
Diego Barrios Romero |
b0b7fc |
|
|
|
891c49 |
if (show_targets)
|
|
Diego Barrios Romero |
b0b7fc |
{
|
|
Diego Barrios Romero |
b0b7fc |
synfig::Target::Book::iterator iter =
|
|
Diego Barrios Romero |
b0b7fc |
synfig::Target::book().begin();
|
|
Diego Barrios Romero |
b0b7fc |
for(; iter != synfig::Target::book().end(); iter++)
|
|
Carlos Lopez |
ac6eb5 |
cout << (iter->first).c_str() << endl;
|
|
Diego Barrios Romero |
b0b7fc |
|
|
Diego Barrios Romero |
d406bf |
throw (SynfigToolException(SYNFIGTOOL_HELP));
|
|
Diego Barrios Romero |
b0b7fc |
}
|
|
Diego Barrios Romero |
b0b7fc |
|
|
|
891c49 |
if (show_value_nodes)
|
|
Diego Barrios Romero |
b0b7fc |
{
|
|
caryoscelus |
776e15 |
synfig::ValueNodeRegistry::Book::iterator iter =
|
|
caryoscelus |
776e15 |
synfig::ValueNodeRegistry::book().begin();
|
|
caryoscelus |
776e15 |
for(; iter != synfig::ValueNodeRegistry::book().end(); iter++)
|
|
Carlos Lopez |
ac6eb5 |
cout << (iter->first).c_str() << endl;
|
|
Diego Barrios Romero |
b0b7fc |
|
|
Diego Barrios Romero |
d406bf |
throw (SynfigToolException(SYNFIGTOOL_HELP));
|
|
Diego Barrios Romero |
b0b7fc |
}
|
|
Diego Barrios Romero |
b0b7fc |
|
|
|
891c49 |
if (show_importers)
|
|
Diego Barrios Romero |
b0b7fc |
{
|
|
Diego Barrios Romero |
b0b7fc |
synfig::Importer::Book::iterator iter =
|
|
Diego Barrios Romero |
b0b7fc |
synfig::Importer::book().begin();
|
|
Diego Barrios Romero |
b0b7fc |
for(; iter != synfig::Importer::book().end(); iter++)
|
|
Carlos Lopez |
ac6eb5 |
cout << (iter->first).c_str() << endl;
|
|
Diego Barrios Romero |
b0b7fc |
|
|
Diego Barrios Romero |
d406bf |
throw (SynfigToolException(SYNFIGTOOL_HELP));
|
|
Diego Barrios Romero |
b0b7fc |
}
|
|
Diego Barrios Romero |
ffa0f8 |
}
|
|
Diego Barrios Romero |
ffa0f8 |
|
|
|
891c49 |
//RendDesc OptionsProcessor::extract_renddesc(const RendDesc& renddesc)
|
|
|
891c49 |
RendDesc SynfigCommandLineParser::extract_renddesc(const RendDesc& renddesc)
|
|
Diego Barrios Romero |
c8e79a |
{
|
|
Diego Barrios Romero |
c8e79a |
RendDesc desc = renddesc;
|
|
Diego Barrios Romero |
c8e79a |
int w, h;
|
|
Diego Barrios Romero |
c8e79a |
float span;
|
|
Diego Barrios Romero |
c8e79a |
span = w = h = 0;
|
|
Diego Barrios Romero |
c8e79a |
|
|
|
891c49 |
w = set_width;
|
|
Diego Barrios Romero |
c8e79a |
|
|
|
891c49 |
h = set_height;
|
|
Diego Barrios Romero |
c8e79a |
|
|
|
891c49 |
if (set_antialias > 0)
|
|
Diego Barrios Romero |
c8e79a |
{
|
|
|
891c49 |
int a = set_antialias;
|
|
Diego Barrios Romero |
c8e79a |
desc.set_antialias(a);
|
|
|
3e2a84 |
synfig::info(_("Antialiasing set to %d, "
|
|
|
3e2a84 |
"(%d samples per pixel)"), a, (a*a));
|
|
|
3e2a84 |
/*VERBOSE_OUT(1) << boost::format(_("Antialiasing set to %d, "
|
|
Diego Barrios Romero |
0d46b7 |
"(%d samples per pixel)")) % a % (a*a)
|
|
|
3e2a84 |
<< std::endl;*/
|
|
Diego Barrios Romero |
c8e79a |
}
|
|
|
891c49 |
if (set_span > 0)
|
|
Diego Barrios Romero |
c8e79a |
{
|
|
|
891c49 |
span = set_span;
|
|
|
3e2a84 |
synfig::info(_("Span set to %d units"), span);
|
|
|
3e2a84 |
/*VERBOSE_OUT(1) << boost::format(_("Span set to %d units")) % span
|
|
|
3e2a84 |
<< std::endl;*/
|
|
Diego Barrios Romero |
c8e79a |
}
|
|
|
891c49 |
if (set_fps > 0)
|
|
Diego Barrios Romero |
c8e79a |
{
|
|
|
891c49 |
float fps = (float)set_fps;
|
|
Diego Barrios Romero |
c8e79a |
desc.set_frame_rate(fps);
|
|
|
3e2a84 |
synfig::info(_("Frame rate set to %d frames per "
|
|
|
3e2a84 |
"second"), fps);
|
|
|
3e2a84 |
/*VERBOSE_OUT(1) << boost::format(_("Frame rate set to %d frames per "
|
|
|
3e2a84 |
"second")) % fps << std::endl;*/
|
|
Diego Barrios Romero |
c8e79a |
}
|
|
|
891c49 |
if (set_dpi > 0)
|
|
Diego Barrios Romero |
c8e79a |
{
|
|
Diego Barrios Romero |
c8e79a |
float dpi, dots_per_meter;
|
|
|
891c49 |
dpi = (float)set_dpi;
|
|
|
891c49 |
dots_per_meter = dpi * 39.3700787402; // TODO: ???
|
|
Diego Barrios Romero |
c8e79a |
desc.set_x_res(dots_per_meter);
|
|
Diego Barrios Romero |
c8e79a |
desc.set_y_res(dots_per_meter);
|
|
|
3e2a84 |
synfig::info(_("Physical resolution set to %f "
|
|
|
3e2a84 |
"dpi"), dpi);
|
|
|
3e2a84 |
/*VERBOSE_OUT(1) << boost::format(_("Physical resolution set to %f "
|
|
|
3e2a84 |
"dpi")) % dpi << std::endl;*/
|
|
Diego Barrios Romero |
c8e79a |
}
|
|
|
891c49 |
if (set_dpi_x)
|
|
Diego Barrios Romero |
c8e79a |
{
|
|
Diego Barrios Romero |
c8e79a |
float dpi, dots_per_meter;
|
|
|
891c49 |
dpi = (float)set_dpi_x;
|
|
Diego Barrios Romero |
c8e79a |
dots_per_meter = dpi * 39.3700787402;
|
|
Diego Barrios Romero |
c8e79a |
desc.set_x_res(dots_per_meter);
|
|
|
3e2a84 |
synfig::info(_("Physical X resolution set to %f "
|
|
|
3e2a84 |
"dpi"), dpi);
|
|
|
3e2a84 |
/*VERBOSE_OUT(1) << boost::format(_("Physical X resolution set to %f "
|
|
|
3e2a84 |
"dpi")) % dpi << std::endl;*/
|
|
Diego Barrios Romero |
c8e79a |
}
|
|
|
891c49 |
if (set_dpi_y)
|
|
Diego Barrios Romero |
c8e79a |
{
|
|
Diego Barrios Romero |
c8e79a |
float dpi, dots_per_meter;
|
|
|
891c49 |
dpi = (float)set_dpi_x;
|
|
Diego Barrios Romero |
c8e79a |
dots_per_meter = dpi * 39.3700787402;
|
|
Diego Barrios Romero |
c8e79a |
desc.set_y_res(dots_per_meter);
|
|
|
3e2a84 |
synfig::info(_("Physical Y resolution set to %f "
|
|
|
3e2a84 |
"dpi"), dpi);
|
|
|
3e2a84 |
/*VERBOSE_OUT(1) << boost::format(_("Physical Y resolution set to %f "
|
|
|
3e2a84 |
"dpi")) % dpi << std::endl;*/
|
|
Diego Barrios Romero |
c8e79a |
}
|
|
|
891c49 |
if (!set_start_time.empty())
|
|
Diego Barrios Romero |
c8e79a |
{
|
|
|
891c49 |
desc.set_time_start(Time(set_start_time.c_str(), desc.get_frame_rate()));
|
|
Diego Barrios Romero |
c8e79a |
}
|
|
|
891c49 |
if (!set_begin_time.empty())
|
|
Diego Barrios Romero |
c8e79a |
{
|
|
|
891c49 |
desc.set_time_start(Time(set_begin_time.c_str(), desc.get_frame_rate()));
|
|
Diego Barrios Romero |
c8e79a |
}
|
|
|
891c49 |
if (!set_end_time.empty())
|
|
Diego Barrios Romero |
c8e79a |
{
|
|
|
891c49 |
desc.set_time_end(Time(set_end_time.c_str(), desc.get_frame_rate()));
|
|
Diego Barrios Romero |
c8e79a |
}
|
|
|
891c49 |
if (!set_time.empty())
|
|
Diego Barrios Romero |
c8e79a |
{
|
|
|
891c49 |
desc.set_time(Time(set_time.c_str(), desc.get_frame_rate()));
|
|
Diego Barrios Romero |
c8e79a |
|
|
Diego Barrios Romero |
c8e79a |
VERBOSE_OUT(1) << _("Rendering frame at ")
|
|
Diego Barrios Romero |
0d46b7 |
<< desc.get_time_start().get_string(desc.get_frame_rate())
|
|
Diego Barrios Romero |
c8e79a |
<< endl;
|
|
Diego Barrios Romero |
c8e79a |
}
|
|
|
891c49 |
if (set_gamma > 0)
|
|
Diego Barrios Romero |
c8e79a |
{
|
|
Diego Barrios Romero |
c8e79a |
synfig::warning(_("Gamma argument is currently ignored"));
|
|
Diego Barrios Romero |
c8e79a |
//int gamma;
|
|
Diego Barrios Romero |
c8e79a |
//gamma = _vm["gamma"].as<int>();</int>
|
|
Diego Barrios Romero |
c8e79a |
//desc.set_gamma(Gamma(gamma));
|
|
Diego Barrios Romero |
c8e79a |
}
|
|
Diego Barrios Romero |
c8e79a |
|
|
Diego Barrios Romero |
0d46b7 |
if (w || h)
|
|
Diego Barrios Romero |
c8e79a |
{
|
|
Diego Barrios Romero |
c8e79a |
// scale properly
|
|
Diego Barrios Romero |
c8e79a |
if (!w)
|
|
Diego Barrios Romero |
c8e79a |
w = desc.get_w() * h / desc.get_h();
|
|
Diego Barrios Romero |
c8e79a |
else if (!h)
|
|
Diego Barrios Romero |
c8e79a |
h = desc.get_h() * w / desc.get_w();
|
|
Diego Barrios Romero |
c8e79a |
|
|
Diego Barrios Romero |
0d46b7 |
desc.set_wh(w, h);
|
|
|
3e2a84 |
VERBOSE_OUT(1) << etl::strprintf(_("Resolution set to %dx%d."), w, h) << std::endl;
|
|
Diego Barrios Romero |
c8e79a |
}
|
|
Diego Barrios Romero |
c8e79a |
|
|
Diego Barrios Romero |
c8e79a |
if(span)
|
|
Diego Barrios Romero |
c8e79a |
desc.set_span(span);
|
|
Diego Barrios Romero |
c8e79a |
|
|
Diego Barrios Romero |
c8e79a |
return desc;
|
|
Diego Barrios Romero |
c8e79a |
}
|
|
Diego Barrios Romero |
c8e79a |
|
|
|
891c49 |
//TargetParam OptionsProcessor::extract_targetparam()
|
|
|
891c49 |
TargetParam SynfigCommandLineParser::extract_targetparam()
|
|
Diego Barrios Romero |
c8e79a |
{
|
|
Diego Barrios Romero |
c8e79a |
TargetParam params;
|
|
Diego Barrios Romero |
c8e79a |
|
|
Diego Barrios Romero |
750284 |
// Both parameters are co-dependent
|
|
|
891c49 |
if (!(video_codec.empty() && video_bitrate == 0))
|
|
Diego Barrios Romero |
750284 |
throw (SynfigToolException(SYNFIGTOOL_MISSINGARGUMENT,
|
|
Diego Barrios Romero |
750284 |
_("Both video codec and bitrate parameters are necessary.")));
|
|
Diego Barrios Romero |
750284 |
|
|
|
891c49 |
if (!video_codec.empty())
|
|
Diego Barrios Romero |
c8e79a |
{
|
|
|
891c49 |
params.video_codec = video_codec;
|
|
Diego Barrios Romero |
c8e79a |
|
|
Diego Barrios Romero |
c8e79a |
// video_codec string to lowercase
|
|
Diego Barrios Romero |
c8e79a |
transform (params.video_codec.begin(),
|
|
Diego Barrios Romero |
c8e79a |
params.video_codec.end(),
|
|
Diego Barrios Romero |
c8e79a |
params.video_codec.begin(),
|
|
Diego Barrios Romero |
c8e79a |
::tolower);
|
|
Diego Barrios Romero |
c8e79a |
|
|
Diego Barrios Romero |
c8e79a |
bool found = false;
|
|
Diego Barrios Romero |
c8e79a |
// Check if the given video codec is allowed.
|
|
Diego Barrios Romero |
0b9c51 |
for (std::vector<videocodec>::const_iterator itr = _allowed_video_codecs.begin();</videocodec>
|
|
Diego Barrios Romero |
0b9c51 |
itr != _allowed_video_codecs.end(); ++itr)
|
|
Diego Barrios Romero |
0b9c51 |
{
|
|
Diego Barrios Romero |
0b9c51 |
if (params.video_codec == itr->name)
|
|
Diego Barrios Romero |
0b9c51 |
{
|
|
Diego Barrios Romero |
c8e79a |
found = true;
|
|
Diego Barrios Romero |
0b9c51 |
}
|
|
Diego Barrios Romero |
0b9c51 |
}
|
|
Diego Barrios Romero |
c8e79a |
|
|
Diego Barrios Romero |
750284 |
if (!found)
|
|
Diego Barrios Romero |
0b9c51 |
{
|
|
Diego Barrios Romero |
0d46b7 |
throw SynfigToolException(SYNFIGTOOL_UNKNOWNARGUMENT,
|
|
|
103db6 |
etl::strprintf(_("Video codec \"%s\" is not supported."), params.video_codec.c_str()));
|
|
Diego Barrios Romero |
0b9c51 |
}
|
|
Diego Barrios Romero |
750284 |
|
|
|
3e2a84 |
VERBOSE_OUT(1) << _("Target video codec set to: ") << params.video_codec << std::endl;
|
|
Diego Barrios Romero |
c8e79a |
}
|
|
|
891c49 |
if (video_bitrate > 0)
|
|
Diego Barrios Romero |
c8e79a |
{
|
|
|
891c49 |
params.bitrate = video_bitrate;
|
|
Diego Barrios Romero |
0d46b7 |
VERBOSE_OUT(1) << _("Target bitrate set to: ") << params.bitrate << "k."
|
|
Diego Barrios Romero |
0d46b7 |
<< std::endl;
|
|
Diego Barrios Romero |
c8e79a |
}
|
|
|
891c49 |
if (!set_sequence_separator.empty())
|
|
Diego Barrios Romero |
c8e79a |
{
|
|
|
891c49 |
params.sequence_separator = set_sequence_separator;
|
|
Diego Barrios Romero |
0d46b7 |
VERBOSE_OUT(1) << _("Output file sequence separator set to: '")
|
|
Diego Barrios Romero |
0d46b7 |
<< params.sequence_separator
|
|
Diego Barrios Romero |
0d46b7 |
<< "'."
|
|
Diego Barrios Romero |
0d46b7 |
<< std::endl;
|
|
Diego Barrios Romero |
c8e79a |
}
|
|
Diego Barrios Romero |
c8e79a |
|
|
Diego Barrios Romero |
c8e79a |
return params;
|
|
Diego Barrios Romero |
c8e79a |
}
|
|
Diego Barrios Romero |
c8e79a |
|
|
|
891c49 |
//Job OptionsProcessor::extract_job()
|
|
|
891c49 |
Job SynfigCommandLineParser::extract_job()
|
|
Diego Barrios Romero |
71669d |
{
|
|
Diego Barrios Romero |
71669d |
Job job;
|
|
Diego Barrios Romero |
71669d |
|
|
Diego Barrios Romero |
71669d |
// Common input file loading
|
|
|
891c49 |
if (!set_input_file.empty())
|
|
Diego Barrios Romero |
71669d |
{
|
|
|
891c49 |
job.filename = set_input_file;
|
|
Diego Barrios Romero |
71669d |
|
|
Diego Barrios Romero |
71669d |
// Open the composition
|
|
Diego Barrios Romero |
71669d |
string errors, warnings;
|
|
Diego Barrios Romero |
71669d |
try
|
|
Diego Barrios Romero |
71669d |
{
|
|
|
eca4bf |
if (FileSystem::Handle file_system = CanvasFileNaming::make_filesystem(job.filename))
|
|
|
bcf554 |
{
|
|
|
3d2479 |
FileSystem::Identifier identifier = file_system->get_identifier(CanvasFileNaming::project_file(job.filename));
|
|
|
eca4bf |
job.root = open_canvas_as(identifier, job.filename, errors, warnings);
|
|
|
eca4bf |
}
|
|
|
eca4bf |
else
|
|
|
bcf554 |
{
|
|
|
eca4bf |
errors.append("Cannot open container " + job.filename + "\n");
|
|
|
bcf554 |
}
|
|
Diego Barrios Romero |
71669d |
}
|
|
Diego Barrios Romero |
71669d |
catch(runtime_error& x)
|
|
Diego Barrios Romero |
71669d |
{
|
|
Diego Barrios Romero |
71669d |
job.root = 0;
|
|
Diego Barrios Romero |
71669d |
}
|
|
Diego Barrios Romero |
71669d |
|
|
Diego Barrios Romero |
71669d |
// By default, the canvas to render is the root canvas
|
|
Diego Barrios Romero |
71669d |
// This can be changed through --canvas option
|
|
Diego Barrios Romero |
71669d |
job.canvas = job.root;
|
|
Diego Barrios Romero |
71669d |
|
|
Diego Barrios Romero |
71669d |
if(!job.canvas)
|
|
Diego Barrios Romero |
71669d |
{
|
|
Diego Barrios Romero |
0d46b7 |
throw SynfigToolException(SYNFIGTOOL_FILENOTFOUND,
|
|
|
103db6 |
etl::strprintf(_("Unable to load file '%s'."), job.filename.c_str()));
|
|
Diego Barrios Romero |
71669d |
}
|
|
Diego Barrios Romero |
71669d |
|
|
|
139eb0 |
job.root->set_time(0);
|
|
Diego Barrios Romero |
71669d |
}
|
|
Diego Barrios Romero |
71669d |
else
|
|
Diego Barrios Romero |
0d46b7 |
{
|
|
Diego Barrios Romero |
0d46b7 |
throw SynfigToolException(SYNFIGTOOL_MISSINGARGUMENT,
|
|
Diego Barrios Romero |
0d46b7 |
_("No input file provided."));
|
|
Diego Barrios Romero |
0d46b7 |
}
|
|
Diego Barrios Romero |
71669d |
|
|
|
891c49 |
if (!set_target.empty())
|
|
Diego Barrios Romero |
71669d |
{
|
|
|
891c49 |
job.target_name = set_target;
|
|
Diego Barrios Romero |
0d46b7 |
VERBOSE_OUT(1) << _("Target set to ") << job.target_name << std::endl;
|
|
Diego Barrios Romero |
71669d |
}
|
|
Diego Barrios Romero |
71669d |
|
|
Diego Barrios Romero |
71669d |
// Determine output
|
|
|
891c49 |
if (!set_output_file.empty())
|
|
Diego Barrios Romero |
71669d |
{
|
|
|
891c49 |
job.outfilename = set_output_file;
|
|
Diego Barrios Romero |
71669d |
}
|
|
Diego Barrios Romero |
0b9c51 |
|
|
|
891c49 |
if (sw_extract_alpha)
|
|
|
4010f4 |
{
|
|
|
4010f4 |
job.extract_alpha = true;
|
|
|
4010f4 |
}
|
|
Diego Barrios Romero |
71669d |
|
|
|
891c49 |
if (set_quality > 0)
|
|
|
891c49 |
job.quality = set_quality;
|
|
Diego Barrios Romero |
71669d |
else
|
|
Diego Barrios Romero |
71669d |
job.quality = DEFAULT_QUALITY;
|
|
Diego Barrios Romero |
71669d |
|
|
Diego Barrios Romero |
0d46b7 |
VERBOSE_OUT(1) << _("Quality set to ") << job.quality << std::endl;
|
|
Diego Barrios Romero |
71669d |
|
|
Diego Barrios Romero |
71669d |
// WARNING: canvas must be before append
|
|
Diego Barrios Romero |
71669d |
|
|
|
891c49 |
if (!set_canvas_id.empty())
|
|
Diego Barrios Romero |
71669d |
{
|
|
|
891c49 |
std::string canvasid = set_canvas_id;
|
|
Diego Barrios Romero |
71669d |
|
|
Diego Barrios Romero |
71669d |
try
|
|
Diego Barrios Romero |
71669d |
{
|
|
Diego Barrios Romero |
0d46b7 |
std::string warnings;
|
|
Diego Barrios Romero |
71669d |
job.canvas = job.root->find_canvas(canvasid, warnings);
|
|
Diego Barrios Romero |
71669d |
// TODO: This exceptions should not terminate the program if multi-job
|
|
Diego Barrios Romero |
71669d |
// processing is available.
|
|
Diego Barrios Romero |
71669d |
}
|
|
Diego Barrios Romero |
71669d |
catch(Exception::IDNotFound&)
|
|
Diego Barrios Romero |
71669d |
{
|
|
Diego Barrios Romero |
0d46b7 |
throw SynfigToolException(SYNFIGTOOL_INVALIDJOB,
|
|
|
3e2a84 |
etl::strprintf(_("Unable to find canvas with ID \"%s\" in %s.\n"
|
|
|
3e2a84 |
"Throwing out job..."),
|
|
|
103db6 |
canvasid.c_str(), job.filename.c_str()));
|
|
Diego Barrios Romero |
71669d |
}
|
|
Diego Barrios Romero |
71669d |
catch(Exception::BadLinkName&)
|
|
Diego Barrios Romero |
71669d |
{
|
|
Diego Barrios Romero |
0d46b7 |
throw SynfigToolException(SYNFIGTOOL_INVALIDJOB,
|
|
|
3e2a84 |
etl::strprintf(_("Invalid canvas name \"%s\" in %s.\n"
|
|
|
3e2a84 |
"Throwing out job..."),
|
|
|
103db6 |
canvasid.c_str(), job.filename.c_str())); // FIXME: is here must be canvasid nor canvasname?
|
|
Diego Barrios Romero |
71669d |
}
|
|
Diego Barrios Romero |
71669d |
|
|
Diego Barrios Romero |
71669d |
// Later we need to set the other parameters for the jobs
|
|
Diego Barrios Romero |
71669d |
}
|
|
Diego Barrios Romero |
71669d |
|
|
Diego Barrios Romero |
71669d |
// WARNING: append must be before list-canvases
|
|
Diego Barrios Romero |
71669d |
|
|
|
891c49 |
if (!misc_append_filename.empty())
|
|
Diego Barrios Romero |
71669d |
{
|
|
Diego Barrios Romero |
71669d |
// TODO: Enable multi-appending. Disabled in the previous CLI version
|
|
|
891c49 |
std::string composite_file = misc_append_filename;
|
|
Diego Barrios Romero |
71669d |
|
|
Diego Barrios Romero |
0d46b7 |
std::string errors, warnings;
|
|
|
bcf554 |
Canvas::Handle composite;
|
|
|
eca4bf |
if (FileSystem::Handle file_system = CanvasFileNaming::make_filesystem(composite_file))
|
|
|
bcf554 |
{
|
|
|
3d2479 |
FileSystem::Identifier identifier = file_system->get_identifier(CanvasFileNaming::project_file(composite_file));
|
|
|
eca4bf |
composite = open_canvas_as(identifier, composite_file, errors, warnings);
|
|
|
eca4bf |
}
|
|
|
eca4bf |
else
|
|
|
bcf554 |
{
|
|
|
eca4bf |
errors.append("Cannot open container " + composite_file + "\n");
|
|
|
bcf554 |
}
|
|
|
bcf554 |
|
|
Diego Barrios Romero |
71669d |
if(!composite)
|
|
Diego Barrios Romero |
71669d |
{
|
|
Carlos Lopez |
ac6eb5 |
VERBOSE_OUT(1) << _("Unable to append '") << composite_file.c_str()
|
|
Carlos Lopez |
ac6eb5 |
<< "'." << endl;
|
|
Diego Barrios Romero |
71669d |
}
|
|
Diego Barrios Romero |
71669d |
else
|
|
Diego Barrios Romero |
71669d |
{
|
|
Diego Barrios Romero |
71669d |
Canvas::reverse_iterator iter;
|
|
Diego Barrios Romero |
71669d |
for(iter=composite->rbegin(); iter!=composite->rend(); ++iter)
|
|
Diego Barrios Romero |
71669d |
{
|
|
Diego Barrios Romero |
71669d |
Layer::Handle layer(*iter);
|
|
|
7406a5 |
//if(layer->active())
|
|
Carlos Lopez |
4b1dad |
job.canvas->push_front(layer->clone(composite));
|
|
Diego Barrios Romero |
71669d |
}
|
|
Diego Barrios Romero |
71669d |
}
|
|
Diego Barrios Romero |
71669d |
|
|
Diego Barrios Romero |
0d46b7 |
VERBOSE_OUT(2) << _("Appended contents of ") << composite_file << endl;
|
|
Diego Barrios Romero |
71669d |
}
|
|
Diego Barrios Romero |
0b9c51 |
|
|
|
891c49 |
//if (_vm.count("list-canvases") || misc_canvases)
|
|
|
891c49 |
if (misc_canvases)
|
|
Diego Barrios Romero |
71669d |
{
|
|
Diego Barrios Romero |
71669d |
print_child_canvases(job.filename + "#", job.root);
|
|
Diego Barrios Romero |
0d46b7 |
std::cerr << std::endl;
|
|
Diego Barrios Romero |
71669d |
|
|
Diego Barrios Romero |
0d46b7 |
throw SynfigToolException(SYNFIGTOOL_OK);
|
|
Diego Barrios Romero |
71669d |
}
|
|
Diego Barrios Romero |
71669d |
|
|
|
891c49 |
if (!misc_canvas_info.empty())
|
|
Diego Barrios Romero |
71669d |
{
|
|
Diego Barrios Romero |
71669d |
extract_canvas_info(job);
|
|
Diego Barrios Romero |
71669d |
print_canvas_info(job);
|
|
Diego Barrios Romero |
71669d |
|
|
Diego Barrios Romero |
0d46b7 |
throw SynfigToolException(SYNFIGTOOL_OK);
|
|
Diego Barrios Romero |
71669d |
}
|
|
Diego Barrios Romero |
71669d |
|
|
Diego Barrios Romero |
71669d |
return job;
|
|
Diego Barrios Romero |
71669d |
}
|
|
Diego Barrios Romero |
71669d |
|
|
|
891c49 |
//void OptionsProcessor::print_target_video_codecs_help() const
|
|
|
891c49 |
void SynfigCommandLineParser::print_target_video_codecs_help() const
|
|
Diego Barrios Romero |
0b9c51 |
{
|
|
Diego Barrios Romero |
0b9c51 |
for (std::vector<videocodec>::const_iterator itr = _allowed_video_codecs.begin();</videocodec>
|
|
Diego Barrios Romero |
0b9c51 |
itr != _allowed_video_codecs.end(); ++itr)
|
|
Diego Barrios Romero |
0b9c51 |
{
|
|
Diego Barrios Romero |
0b9c51 |
std::cout << " " << itr->name << ": \t" << itr->description
|
|
Diego Barrios Romero |
0b9c51 |
<< std::endl;
|
|
Diego Barrios Romero |
0b9c51 |
}
|
|
Diego Barrios Romero |
0b9c51 |
}
|
|
Diego Barrios Romero |
0b9c51 |
|
|
Diego Barrios Romero |
06d6b9 |
#ifdef _DEBUG
|
|
Diego Barrios Romero |
06d6b9 |
|
|
Diego Barrios Romero |
06d6b9 |
// DEBUG auxiliar functions
|
|
Diego Barrios Romero |
06d6b9 |
void guid_test()
|
|
Diego Barrios Romero |
06d6b9 |
{
|
|
Diego Barrios Romero |
0b9c51 |
std::cout << "GUID Test" << std::endl;
|
|
Diego Barrios Romero |
06d6b9 |
for(int i = 20; i; i--)
|
|
Diego Barrios Romero |
0b9c51 |
std::cout << synfig::GUID().get_string() << ' '
|
|
Diego Barrios Romero |
0b9c51 |
<< synfig::GUID().get_string() << std::endl;
|
|
Diego Barrios Romero |
06d6b9 |
}
|
|
Diego Barrios Romero |
06d6b9 |
|
|
Diego Barrios Romero |
06d6b9 |
void signal_test_func()
|
|
Diego Barrios Romero |
06d6b9 |
{
|
|
Diego Barrios Romero |
0b9c51 |
std::cout << "**SIGNAL CALLED**" << std::endl;
|
|
Diego Barrios Romero |
06d6b9 |
}
|
|
Diego Barrios Romero |
06d6b9 |
|
|
Diego Barrios Romero |
06d6b9 |
void signal_test()
|
|
Diego Barrios Romero |
06d6b9 |
{
|
|
Diego Barrios Romero |
06d6b9 |
sigc::signal<void> sig;</void>
|
|
Diego Barrios Romero |
06d6b9 |
sigc::connection conn;
|
|
Diego Barrios Romero |
0b9c51 |
std::cout << "Signal Test" << std::endl;
|
|
Diego Barrios Romero |
06d6b9 |
conn = sig.connect(sigc::ptr_fun(signal_test_func));
|
|
Diego Barrios Romero |
0b9c51 |
std::cout << "Next line should exclaim signal called." << std::endl;
|
|
Diego Barrios Romero |
06d6b9 |
sig();
|
|
Diego Barrios Romero |
06d6b9 |
conn.disconnect();
|
|
Diego Barrios Romero |
0b9c51 |
std::cout << "Next line should NOT exclaim signal called." << std::endl;
|
|
Diego Barrios Romero |
06d6b9 |
sig();
|
|
Diego Barrios Romero |
0b9c51 |
std::cout << "done." << std::endl;
|
|
Diego Barrios Romero |
06d6b9 |
}
|
|
Diego Barrios Romero |
06d6b9 |
|
|
Diego Barrios Romero |
06d6b9 |
// DEBUG options ----------------------------------------------
|
|
|
30c9aa |
//void OptionsProcessor::process_debug_options() throw (SynfigToolException&)
|
|
|
30c9aa |
void SynfigCommandLineParser::process_debug_options() throw (SynfigToolException&)
|
|
Diego Barrios Romero |
06d6b9 |
{
|
|
|
891c49 |
if (debug_signal)
|
|
Diego Barrios Romero |
06d6b9 |
{
|
|
Diego Barrios Romero |
06d6b9 |
signal_test();
|
|
Diego Barrios Romero |
06d6b9 |
throw (SynfigToolException(SYNFIGTOOL_HELP));
|
|
Diego Barrios Romero |
06d6b9 |
}
|
|
Diego Barrios Romero |
06d6b9 |
|
|
|
891c49 |
if (debug_guid)
|
|
Diego Barrios Romero |
06d6b9 |
{
|
|
Diego Barrios Romero |
06d6b9 |
guid_test();
|
|
Diego Barrios Romero |
06d6b9 |
throw (SynfigToolException(SYNFIGTOOL_HELP));
|
|
Diego Barrios Romero |
06d6b9 |
}
|
|
Diego Barrios Romero |
06d6b9 |
}
|
|
Diego Barrios Romero |
06d6b9 |
|
|
Diego Barrios Romero |
06d6b9 |
#endif
|
|
Diego Barrios Romero |
06d6b9 |
|