void CommandLineHandler::print_program_usage( const char* program_name, SuperLogger& logger) const { SaveLogFormatterConfig save_config(logger); logger.set_format(LogMessage::Info, "{message}"); LOG_INFO(logger, "usage: %s [project.appleseed]", program_name); LOG_INFO(logger, "options:"); parser().print_usage(logger); #ifdef _WIN32 const StringLogTarget& target = static_cast<const StringLogTarget&>(logger.get_log_target()); const QString str = QString::fromStdString(target.get_string()); QMessageBox msgbox; msgbox.setWindowTitle("appleseed.studio Program Usage"); msgbox.setIcon(QMessageBox::Information); msgbox.setText("<pre>" + str + "</pre>"); msgbox.setStandardButtons(QMessageBox::Ok); msgbox.setDefaultButton(QMessageBox::Ok); msgbox.exec(); #endif }
int main(int argc, const char* argv[]) { SuperLogger logger; Application::check_installation(logger); CommandLineHandler cl; cl.parse(argc, argv, logger); global_logger().add_target(&logger.get_log_target()); // Construct the schema filename. const filesystem::path schema_path = filesystem::path(Application::get_root_path()) / "schemas/project.xsd"; // Load the input project from disk. ProjectFileReader reader; auto_release_ptr<Project> project( reader.read( cl.m_filename.values()[0].c_str(), schema_path.file_string().c_str())); // Bail out if the project couldn't be loaded. if (project.get() == 0) return 1; // Write the project back to disk. return ProjectFileWriter::write(project.ref()) ? 0 : 1; }
int main(int argc, const char* argv[]) { // Initialize the logger that will be used throughout the program. SuperLogger logger; // Make sure appleseed is correctly installed. Application::check_installation(logger); // Parse the command line. CommandLineHandler cl; cl.parse(argc, argv, logger); // Load an apply settings from the settings file. Dictionary settings; Application::load_settings("appleseed.tools.xml", settings, logger); logger.configure_from_settings(settings); // Apply command line arguments. cl.apply(logger); // Configure the renderer's global logger. // Must be done after settings have been loaded and the command line // has been parsed, because these two operations may replace the log // target of the global logger. global_logger().initialize_from(logger); // Retrieve the command line arguments. const string& input_filepath = cl.m_filenames.values()[0]; const string& output_filepath = cl.m_filenames.values()[1]; const FluffParams params(cl); // Construct the schema file path. const bf::path schema_filepath = bf::path(Application::get_root_path()) / "schemas" / "project.xsd"; // Read the input project from disk. ProjectFileReader reader; auto_release_ptr<Project> project( reader.read( input_filepath.c_str(), schema_filepath.string().c_str())); // Bail out if the project couldn't be loaded. if (project.get() == 0) return 1; // Fluffify the project. make_fluffy(project.ref(), params); // Write the project back to disk. const bool success = ProjectFileWriter::write( project.ref(), output_filepath.c_str()); return success ? 0 : 1; }
void CommandLineHandler::print_program_usage( const char* executable_name, SuperLogger& logger) const { SaveLogFormatterConfig save_config(logger); logger.set_verbosity_level(LogMessage::Info); logger.set_format(LogMessage::Info, "{message}"); LOG_INFO(logger, "usage: %s [options] master.appleseed output.appleseed", executable_name); LOG_INFO(logger, "options:"); parser().print_usage(logger); }
int main(int argc, char* argv[]) { start_memory_tracking(); // Our message handler must be set before the construction of QApplication. g_previous_message_handler = qInstallMsgHandler(message_handler); QApplication application(argc, argv); QApplication::setOrganizationName("appleseedhq"); QApplication::setOrganizationDomain("appleseedhq.net"); QApplication::setApplicationName("appleseed.studio"); QApplication::setApplicationVersion(Appleseed::get_lib_version()); QApplication::setWindowIcon(QIcon(make_app_path("icons/appleseed.png"))); // The locale must be set after the construction of QApplication. QLocale::setDefault(QLocale::C); setlocale(LC_ALL, "C"); check_installation(); // Parse the command line. SuperLogger logger; #ifdef _WIN32 logger.set_log_target(create_string_log_target()); #endif CommandLineHandler cl; cl.parse(argc, const_cast<const char**>(argv), logger); configure_application(application); appleseed::studio::MainWindow window; if (!cl.m_filename.values().empty()) { const QString filename = QString::fromStdString(cl.m_filename.value()); if (cl.m_render.is_set()) { const QString configuration = QString::fromStdString(cl.m_render.value()); window.open_and_render_project(filename, configuration); } else { window.open_project(filename); } } window.show(); return application.exec(); }
int main(int argc, const char* argv[]) { SuperLogger logger; Application::check_installation(logger); CommandLineHandler cl; cl.parse(argc, argv, logger); // Initialize the renderer's logger. global_logger().add_target(&logger.get_log_target()); // Retrieve the input file path. const string& input_filepath = cl.m_filename.value(); // Construct the schema file path. const filesystem::path schema_filepath = filesystem::path(Application::get_root_path()) / "schemas" / "project.xsd"; // Read the input project from disk. // Note: it is crucial that we read mesh files as well, so that we can collect // material slots declared by objects. Material slots are required by the project // file updater, for instance when migrating projects from rev. 7 to rev. 8. ProjectFileReader reader; auto_release_ptr<Project> project( reader.read( input_filepath.c_str(), schema_filepath.string().c_str(), ProjectFileReader::OmitProjectFileUpdate)); // Bail out if the project couldn't be loaded. if (project.get() == 0) return 1; // Update the project file to the desired revision. ProjectFileUpdater updater; if (cl.m_to_revision.is_set()) updater.update(project.ref(), cl.m_to_revision.value()); else updater.update(project.ref()); // Write the project back to disk. const bool success = ProjectFileWriter::write( project.ref(), project->get_path(), ProjectFileWriter::OmitWritingGeometryFiles | ProjectFileWriter::OmitBringingAssets); return success ? 0 : 1; }
void CommandLineHandlerBase::print_system_information(SuperLogger& logger) { SaveLogFormatterConfig save_config(logger); logger.set_format(LogMessage::Info, "{message}"); System::print_information(logger); }
int main(int argc, const char* argv[]) { SuperLogger logger; Application::check_installation(logger); CommandLineHandler cl; cl.parse(argc, argv, logger); global_logger().add_target(&logger.get_log_target()); // Retrieve the input file path. const string& input_filepath = cl.m_filename.values()[0]; // Construct the schema file path. const string schema_filepath = (filesystem::path(Application::get_root_path()) / "schemas" / "project.xsd").string(); // Load the input project from disk. ProjectFileReader reader; auto_release_ptr<Project> project( reader.read( input_filepath.c_str(), schema_filepath.c_str(), ProjectFileReader::OmitReadingMeshFiles | ProjectFileReader::OmitProjectFileUpdate)); // Bail out if the project couldn't be loaded. if (project.get() == 0) return 1; // Update the project file to the desired revision. ProjectFileUpdater updater; if (cl.m_to_revision.is_set()) updater.update(project.ref(), cl.m_to_revision.values()[0]); else updater.update(project.ref()); // Write the project back to disk. const bool success = ProjectFileWriter::write( project.ref(), project->get_path(), ProjectFileWriter::OmitWritingMeshFiles | ProjectFileWriter::OmitCopyingAssets); return success ? 0 : 1; }
void CommandLineHandlerBase::parse(const int argc, const char* argv[], SuperLogger& logger) { impl->m_executable_name = bf::path(argv[0]).filename().string(); impl->m_parser.parse(argc, argv, impl->m_parse_results); if (impl->m_help.is_set()) { print_program_usage(impl->m_executable_name.c_str(), logger); exit(EXIT_SUCCESS); } if (impl->m_message_coloring.is_set()) logger.enable_message_coloring(); if (impl->m_message_verbosity.is_set()) logger.set_verbosity_level_from_string(impl->m_message_verbosity.value().c_str()); }
int main(int argc, const char* argv[]) { SuperLogger logger; Application::check_installation(logger); CommandLineHandler cl; cl.parse(argc, argv, logger); // Initialize the renderer's logger. global_logger().add_target(&logger.get_log_target()); // Retrieve the command line arguments. const string& input_filepath = cl.m_filenames.values()[0]; const string& output_filepath = cl.m_filenames.values()[1]; const FluffParams params(cl); // Construct the schema file path. const filesystem::path schema_filepath = filesystem::path(Application::get_root_path()) / "schemas" / "project.xsd"; // Read the input project from disk. ProjectFileReader reader; auto_release_ptr<Project> project( reader.read( input_filepath.c_str(), schema_filepath.string().c_str())); // Bail out if the project couldn't be loaded. if (project.get() == 0) return 1; // Fluffify the project. make_fluffy(project.ref(), params); // Write the project back to disk. const bool success = ProjectFileWriter::write( project.ref(), output_filepath.c_str()); return success ? 0 : 1; }
void CommandLineHandler::print_program_usage( const char* program_name, SuperLogger& logger) const { SaveLogFormatterConfig save_config(logger); logger.set_format(LogMessage::Info, "{message}"); LOG_INFO(logger, "usage: %s [options] input-file output-file", program_name); LOG_INFO(logger, "options:"); parser().print_usage(logger); }
int main(int argc, const char* argv[]) { start_memory_tracking(); SuperLogger logger; Application::check_installation(logger); g_cl.parse(argc, argv, logger); // Read the application's settings from disk. load_settings(logger); if (g_settings.get_optional<bool>("message_coloring", false)) logger.enable_message_coloring(); // Run unit tests. if (g_cl.m_run_unit_tests.is_set()) run_unit_tests(logger); // Run unit benchmarks. if (g_cl.m_run_unit_benchmarks.is_set()) run_unit_benchmarks(logger); // Dump entity definitions. if (g_cl.m_dump_entity_definitions.is_set()) dump_entity_definitions(logger); // Render the specified project. if (!g_cl.m_filenames.values().empty()) { const string project_filename = g_cl.m_filenames.values().front(); if (g_cl.m_benchmark_mode.is_set()) benchmark_render(project_filename, logger); else render(project_filename, logger); } return 0; }
int main(int argc, const char* argv[]) { SuperLogger logger; Application::check_installation(logger); g_cl.parse(argc, argv, logger); global_logger().add_target(&logger.get_log_target()); const string base_output_filename = filesystem::path(g_cl.m_filenames.values()[1]).stem().string(); auto_ptr<AnimationGenerator> generator; if (g_cl.m_animation_path.is_set()) generator.reset(new PathAnimationGenerator(base_output_filename, logger)); else generator.reset(new TurntableAnimationGenerator(base_output_filename, logger)); generator->generate(); return 0; }
int main(int argc, const char* argv[]) { // Initialize the logger that will be used throughout the program. SuperLogger logger; // Make sure appleseed is correctly installed. Application::check_installation(logger); // Parse the command line. CommandLineHandler cl; cl.parse(argc, argv, logger); // Load an apply settings from the settings file. Dictionary settings; Application::load_settings("appleseed.tools.xml", settings, logger); logger.configure_from_settings(settings); // Apply command line arguments. cl.apply(logger); dump_metadata(cl.m_format.value(), logger); return 0; }
void CommandLineHandler::print_program_usage( const char* program_name, SuperLogger& logger) const { LogTargetBase& log_target = logger.get_log_target(); const LogMessage::FormattingFlags old_flags = log_target.set_formatting_flags(LogMessage::Info, LogMessage::DisplayMessage); LOG_INFO(logger, "usage: %s [options] project.appleseed", program_name); LOG_INFO(logger, "options:"); parser().print_usage(logger); log_target.set_formatting_flags(LogMessage::Info, old_flags); }
void CommandLineHandlerBase::parse( const int argc, const char* argv[], SuperLogger& logger) { ParseResults results; impl->m_parser.parse(argc, argv, results); if (impl->m_message_coloring.is_set()) logger.enable_message_coloring(); if (impl->m_message_verbosity.is_set()) set_verbosity(logger, impl->m_message_verbosity.value()); if (impl->m_version.is_set()) print_version_information(logger); if (impl->m_system.is_set()) print_system_information(logger); if (impl->m_help.is_set()) { const string program_name = filesystem::path(argv[0]).filename().string(); print_program_usage(program_name.c_str(), logger); exit(0); } if (impl->m_display_options.is_set()) { LOG_INFO(logger, "recognized options:"); impl->m_parser.print_recognized_options(logger); } results.m_messages.print(logger); if (results.m_errors > 0 || results.m_warnings > 0) { LOG( logger, results.m_errors > 0 ? LogMessage::Fatal : LogMessage::Warning, FMT_SIZE_T " error%s, " FMT_SIZE_T " warning%s encountered while parsing the command line.", results.m_errors, results.m_errors > 1 ? "s" : "", results.m_warnings, results.m_warnings > 1 ? "s" : ""); } }
void CommandLineHandlerBase::print_version_information(SuperLogger& logger) const { SaveLogFormatterConfig save_config(logger); logger.set_format(LogMessage::Info, "{message}"); LOG_INFO( logger, "%s, using %s version %s, %s configuration\n" "compiled on %s at %s using %s version %s\n" "copyright (c) 2010-2013 Francois Beaune, Jupiter Jazz Limited.\n" "copyright (c) 2014 Francois Beaune, The appleseedhq Organization.\n" "this software is released under the MIT license (http://www.opensource.org/licenses/mit-license.php).\n" "visit http://appleseedhq.net/ for additional information and resources.", impl->m_application_name.c_str(), Appleseed::get_lib_name(), Appleseed::get_lib_version(), Appleseed::get_lib_configuration(), Appleseed::get_lib_compilation_date(), Appleseed::get_lib_compilation_time(), Compiler::get_compiler_name(), Compiler::get_compiler_version()); }
int main(int argc, char* argv[]) { // Enable memory tracking immediately as to catch as many leaks as possible. start_memory_tracking(); // Our message handler must be set before the construction of QApplication. g_previous_message_handler = qInstallMsgHandler(message_handler); QApplication application(argc, argv); QApplication::setOrganizationName("appleseedhq"); QApplication::setOrganizationDomain("appleseedhq.net"); QApplication::setApplicationName("appleseed.studio"); QApplication::setApplicationVersion(Appleseed::get_lib_version()); QApplication::setWindowIcon(QIcon(make_app_path("icons/appleseed.png"))); application.setAttribute(Qt::AA_DontUseNativeMenuBar, true); // The locale must be set after the construction of QApplication. QLocale::setDefault(QLocale::C); // QApplication sets C locale to the user's locale, we need to fix this. std::setlocale(LC_ALL, "C"); // QT changes locale when loading image from disk for the very first time. // The problem was tracked for both QImage and QPixmap. // Both classes in their `load()` function call `QImageReader.read()` // which results in change of the locale back to system settings. // This is a dirty fix which loads any image at the very beginning and // resets the locale right after, thus preventing the `QImageReader.read()` // to change it again (as it happens only on the very first `read`). // Issue reported and tracked on GitHub under reference #1435. QImageReader(make_app_path("icons/icon.png")).read(); // any image // Make sure this build can run on this host. check_compatibility(); // Make sure appleseed is correctly installed. check_installation(); // Parse the command line. SuperLogger logger; #ifdef _WIN32 // On Windows, we will display command line arguments in a message box // so we need to capture CommandLineHandler's output into a string. logger.set_log_target(create_string_log_target()); #endif CommandLineHandler cl; cl.parse(argc, const_cast<const char**>(argv), logger); // Configure the application to use our default stylesheet file. set_default_stylesheet(application); // Create the application's main window. appleseed::studio::MainWindow window; // Initialize the python interpreter and load plugins. PythonInterpreter::instance().set_main_window(&window); PythonInterpreter::instance().load_plugins(); // If a project file was specified on the command line, open it and optionally start rendering. if (!cl.m_filename.values().empty()) { const QString filename = QString::fromStdString(cl.m_filename.value()); if (cl.m_render.is_set()) { const QString configuration = QString::fromStdString(cl.m_render.value()); window.open_and_render_project(filename, configuration); } else { window.open_project_async(filename); } } window.show(); return application.exec(); }
int main(int argc, const char* argv[]) { // Initialize the logger that will be used throughout the program. SuperLogger logger; // Make sure appleseed is correctly installed. Application::check_installation(logger); // Parse the command line. CommandLineHandler cl; cl.parse(argc, argv, logger); // Load an apply settings from the settings file. Dictionary settings; Application::load_settings("appleseed.tools.xml", settings, logger); logger.configure_from_settings(settings); // Apply command line arguments. cl.apply(logger); // Configure the renderer's global logger. // Must be done after settings have been loaded and the command line // has been parsed, because these two operations may replace the log // target of the global logger. global_logger().initialize_from(logger); // Retrieve the input file path. const string& input_filepath = cl.m_filename.value(); // Construct the schema file path. const bf::path schema_filepath = bf::path(Application::get_root_path()) / "schemas" / "project.xsd"; // Read the input project from disk. // Note: it is crucial that we read mesh files as well, so that we can collect // material slots declared by objects. Material slots are required by the project // file updater, for instance when migrating projects from rev. 7 to rev. 8. ProjectFileReader reader; auto_release_ptr<Project> project( reader.read( input_filepath.c_str(), schema_filepath.string().c_str(), ProjectFileReader::OmitProjectFileUpdate)); // Bail out if the project couldn't be loaded. if (project.get() == 0) return 1; // Update the project file to the desired revision. ProjectFileUpdater updater; if (cl.m_to_revision.is_set()) updater.update(project.ref(), cl.m_to_revision.value()); else updater.update(project.ref()); // Write the project back to disk. const bool success = ProjectFileWriter::write( project.ref(), project->get_path(), ProjectFileWriter::OmitWritingGeometryFiles | ProjectFileWriter::OmitHandlingAssetFiles); return success ? 0 : 1; }