mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 01:37:53 -06:00
GUI initialization extracted from PrusaSlicer.cpp to GUI_Init.cpp/hpp.
Implemented try/catch blocks for Slic3r exceptions and std::exceptions with GUI error reporting. This is extremely important to report corruption of PrusaSlicer.ini.
This commit is contained in:
parent
0f9faeda98
commit
027ab4fb02
8 changed files with 163 additions and 131 deletions
|
@ -45,18 +45,12 @@
|
|||
#include "libslic3r/Format/OBJ.hpp"
|
||||
#include "libslic3r/Format/SL1.hpp"
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "libslic3r/AppConfig.hpp"
|
||||
#include "libslic3r/Thread.hpp"
|
||||
|
||||
#include "PrusaSlicer.hpp"
|
||||
|
||||
#ifdef SLIC3R_GUI
|
||||
#include "slic3r/GUI/GUI.hpp"
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#include "slic3r/GUI/3DScene.hpp"
|
||||
#include "slic3r/GUI/InstanceCheck.hpp"
|
||||
#include "slic3r/GUI/MainFrame.hpp"
|
||||
#include "slic3r/GUI/Plater.hpp"
|
||||
#include "slic3r/GUI/GUI_Init.hpp"
|
||||
#endif /* SLIC3R_GUI */
|
||||
|
||||
using namespace Slic3r;
|
||||
|
@ -578,75 +572,20 @@ int CLI::run(int argc, char **argv)
|
|||
|
||||
if (start_gui) {
|
||||
#ifdef SLIC3R_GUI
|
||||
// #ifdef USE_WX
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
GUI::GUI_App* gui = new GUI::GUI_App(start_as_gcodeviewer ? GUI::GUI_App::EAppMode::GCodeViewer : GUI::GUI_App::EAppMode::Editor);
|
||||
if (gui->get_app_mode() != GUI::GUI_App::EAppMode::GCodeViewer) {
|
||||
// G-code viewer is currently not performing instance check, a new G-code viewer is started every time.
|
||||
bool gui_single_instance_setting = gui->app_config->get("single_instance") == "1";
|
||||
if (Slic3r::instance_check(argc, argv, gui_single_instance_setting)) {
|
||||
//TODO: do we have delete gui and other stuff?
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#else
|
||||
GUI::GUI_App *gui = new GUI::GUI_App();
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
||||
// gui->autosave = m_config.opt_string("autosave");
|
||||
GUI::GUI_App::SetInstance(gui);
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
gui->after_init_loads.set_params(load_configs, m_extra_config, m_input_files, start_as_gcodeviewer);
|
||||
#else
|
||||
gui->after_init_loads.set_params(load_configs, m_extra_config, m_input_files);
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
/*
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
gui->CallAfter([gui, this, &load_configs, start_as_gcodeviewer] {
|
||||
#else
|
||||
gui->CallAfter([gui, this, &load_configs] {
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
if (!gui->initialized()) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
if (start_as_gcodeviewer) {
|
||||
if (!m_input_files.empty())
|
||||
gui->plater()->load_gcode(wxString::FromUTF8(m_input_files[0].c_str()));
|
||||
} else {
|
||||
#endif // ENABLE_GCODE_VIEWER_AS
|
||||
#if 0
|
||||
// Load the cummulative config over the currently active profiles.
|
||||
//FIXME if multiple configs are loaded, only the last one will have an effect.
|
||||
// We need to decide what to do about loading of separate presets (just print preset, just filament preset etc).
|
||||
// As of now only the full configs are supported here.
|
||||
if (!m_print_config.empty())
|
||||
gui->mainframe->load_config(m_print_config);
|
||||
#endif
|
||||
if (!load_configs.empty())
|
||||
// Load the last config to give it a name at the UI. The name of the preset may be later
|
||||
// changed by loading an AMF or 3MF.
|
||||
//FIXME this is not strictly correct, as one may pass a print/filament/printer profile here instead of a full config.
|
||||
gui->mainframe->load_config_file(load_configs.back());
|
||||
// If loading a 3MF file, the config is loaded from the last one.
|
||||
if (!m_input_files.empty())
|
||||
gui->plater()->load_files(m_input_files, true, true);
|
||||
if (!m_extra_config.empty())
|
||||
gui->mainframe->load_config(m_extra_config);
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
}
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
});
|
||||
*/
|
||||
int result = wxEntry(argc, argv);
|
||||
return result;
|
||||
#else /* SLIC3R_GUI */
|
||||
Slic3r::GUI::GUI_InitParams params;
|
||||
params.argc = argc;
|
||||
params.argv = argv;
|
||||
params.load_configs = load_configs;
|
||||
params.extra_config = std::move(m_extra_config);
|
||||
params.input_files = std::move(m_input_files);
|
||||
params.start_as_gcodeviewer = start_as_gcodeviewer;
|
||||
return Slic3r::GUI::GUI_Run(params);
|
||||
#else // SLIC3R_GUI
|
||||
// No GUI support. Just print out a help.
|
||||
this->print_help(false);
|
||||
// If started without a parameter, consider it to be OK, otherwise report an error code (no action etc).
|
||||
return (argc == 0) ? 0 : 1;
|
||||
#endif /* SLIC3R_GUI */
|
||||
#endif // SLIC3R_GUI
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue