A part of code related to loads after App::OnInit() call is moved from PrusaSlicer.cpp to GUI_App.cpp
Splash Screen under OSX requires a call of wxYeild() for update. But wxYield() furthers a case, when CallAfter() in CLI::run() was called at the wrong time, before some of the GUI was created. So, there is workaround: Parameters needed for later loads are encapsulated to GUI_App::AFTER_INIT_LOADS structure and are used in GUI_App::AFTER_INIT_LOADS::on_loads which is called just ones after wxEVT_IDLE
This commit is contained in:
parent
1fb400a091
commit
48f775decb
3 changed files with 83 additions and 1 deletions
|
@ -577,6 +577,12 @@ int CLI::run(int argc, char **argv)
|
||||||
|
|
||||||
// gui->autosave = m_config.opt_string("autosave");
|
// gui->autosave = m_config.opt_string("autosave");
|
||||||
GUI::GUI_App::SetInstance(gui);
|
GUI::GUI_App::SetInstance(gui);
|
||||||
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
gui->m_after_init_loads.set_params(load_configs, m_extra_config, m_input_files, start_as_gcodeviewer);
|
||||||
|
#else
|
||||||
|
gui->m_after_init_loads.set_params(load_configs, m_extra_config, m_input_files);
|
||||||
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
|
/*
|
||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
gui->CallAfter([gui, this, &load_configs, start_as_gcodeviewer] {
|
gui->CallAfter([gui, this, &load_configs, start_as_gcodeviewer] {
|
||||||
#else
|
#else
|
||||||
|
@ -614,6 +620,7 @@ int CLI::run(int argc, char **argv)
|
||||||
}
|
}
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
int result = wxEntry(argc, argv);
|
int result = wxEntry(argc, argv);
|
||||||
return result;
|
return result;
|
||||||
#else /* SLIC3R_GUI */
|
#else /* SLIC3R_GUI */
|
||||||
|
|
|
@ -123,6 +123,10 @@ public:
|
||||||
|
|
||||||
memDC.SelectObject(wxNullBitmap);
|
memDC.SelectObject(wxNullBitmap);
|
||||||
set_bitmap(bitmap);
|
set_bitmap(bitmap);
|
||||||
|
#ifdef __WXOSX__
|
||||||
|
// without this code splash screen wouldn't be updated under OSX
|
||||||
|
wxYield();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -531,6 +535,41 @@ static void generic_exception_handle()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUI_App::AFTER_INIT_LOADS::on_loads(GUI_App* gui)
|
||||||
|
{
|
||||||
|
if (!gui->initialized())
|
||||||
|
return;
|
||||||
|
|
||||||
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
if (m_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 (!m_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(m_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
|
||||||
|
}
|
||||||
|
|
||||||
IMPLEMENT_APP(GUI_App)
|
IMPLEMENT_APP(GUI_App)
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
@ -696,7 +735,6 @@ bool GUI_App::on_init_inner()
|
||||||
// create splash screen with updated bmp
|
// create splash screen with updated bmp
|
||||||
scrn = new SplashScreen(bmp.IsOk() ? bmp : create_scaled_bitmap("prusa_slicer_logo", nullptr, 400),
|
scrn = new SplashScreen(bmp.IsOk() ? bmp : create_scaled_bitmap("prusa_slicer_logo", nullptr, 400),
|
||||||
wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_TIMEOUT, 4000, splashscreen_pos, is_decorated);
|
wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_TIMEOUT, 4000, splashscreen_pos, is_decorated);
|
||||||
wxYield();
|
|
||||||
scrn->SetText(_L("Loading configuration..."));
|
scrn->SetText(_L("Loading configuration..."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -785,6 +823,13 @@ bool GUI_App::on_init_inner()
|
||||||
|
|
||||||
this->obj_manipul()->update_if_dirty();
|
this->obj_manipul()->update_if_dirty();
|
||||||
|
|
||||||
|
static bool update_gui_after_init = true;
|
||||||
|
if (update_gui_after_init)
|
||||||
|
{
|
||||||
|
update_gui_after_init = false;
|
||||||
|
m_after_init_loads.on_loads(this);
|
||||||
|
}
|
||||||
|
|
||||||
// Preset updating & Configwizard are done after the above initializations,
|
// Preset updating & Configwizard are done after the above initializations,
|
||||||
// and after MainFrame is created & shown.
|
// and after MainFrame is created & shown.
|
||||||
// The extra CallAfter() is needed because of Mac, where this is the only way
|
// The extra CallAfter() is needed because of Mac, where this is the only way
|
||||||
|
|
|
@ -140,6 +140,35 @@ private:
|
||||||
std::string m_instance_hash_string;
|
std::string m_instance_hash_string;
|
||||||
size_t m_instance_hash_int;
|
size_t m_instance_hash_int;
|
||||||
|
|
||||||
|
// parameters needed for the after OnInit() loads
|
||||||
|
struct AFTER_INIT_LOADS
|
||||||
|
{
|
||||||
|
std::vector<std::string> m_load_configs;
|
||||||
|
DynamicPrintConfig m_extra_config;
|
||||||
|
std::vector<std::string> m_input_files;
|
||||||
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
bool m_start_as_gcodeviewer;
|
||||||
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
|
|
||||||
|
void set_params(
|
||||||
|
const std::vector<std::string>& load_configs,
|
||||||
|
const DynamicPrintConfig& extra_config,
|
||||||
|
const std::vector<std::string>& input_files,
|
||||||
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
bool start_as_gcodeviewer
|
||||||
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
|
) {
|
||||||
|
m_load_configs = load_configs;
|
||||||
|
m_extra_config = extra_config;
|
||||||
|
m_input_files = input_files;
|
||||||
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
m_start_as_gcodeviewer = start_as_gcodeviewer;
|
||||||
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_loads(GUI_App* gui);
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool OnInit() override;
|
bool OnInit() override;
|
||||||
bool initialized() const { return m_initialized; }
|
bool initialized() const { return m_initialized; }
|
||||||
|
@ -236,6 +265,7 @@ public:
|
||||||
PresetUpdater* preset_updater{ nullptr };
|
PresetUpdater* preset_updater{ nullptr };
|
||||||
MainFrame* mainframe{ nullptr };
|
MainFrame* mainframe{ nullptr };
|
||||||
Plater* plater_{ nullptr };
|
Plater* plater_{ nullptr };
|
||||||
|
AFTER_INIT_LOADS m_after_init_loads;
|
||||||
|
|
||||||
PresetUpdater* get_preset_updater() { return preset_updater; }
|
PresetUpdater* get_preset_updater() { return preset_updater; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue