mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-13 22:05:56 +08:00
CLI: Start PS with entered print/printer/material profiles, when no other input info is provided
(FR from #13327 - Command line in shortcut to select printer configuration doesn't work) SPE-2465
This commit is contained in:
parent
a937e1f042
commit
4a2e9d887a
@ -751,6 +751,11 @@ int CLI::run(int argc, char **argv)
|
||||
params.load_configs = load_configs;
|
||||
params.extra_config = std::move(m_extra_config);
|
||||
params.input_files = std::move(m_input_files);
|
||||
if (has_config_from_profiles && params.input_files.empty()) {
|
||||
params.selected_presets = Slic3r::GUI::CLISelectedProfiles{ m_config.opt_string("print-profile"),
|
||||
m_config.opt_string("printer-profile") ,
|
||||
m_config.option<ConfigOptionStrings>("material-profile")->values };
|
||||
}
|
||||
params.start_as_gcodeviewer = start_as_gcodeviewer;
|
||||
params.start_downloader = start_downloader;
|
||||
params.download_url = download_url;
|
||||
|
@ -817,6 +817,26 @@ void GUI_App::post_init()
|
||||
}
|
||||
if (! this->init_params->extra_config.empty())
|
||||
this->mainframe->load_config(this->init_params->extra_config);
|
||||
|
||||
if (this->init_params->selected_presets.has_valid_data()) {
|
||||
if (Tab* printer_tab = get_tab(Preset::TYPE_PRINTER))
|
||||
printer_tab->select_preset(this->init_params->selected_presets.printer);
|
||||
|
||||
const bool is_fff = preset_bundle->printers.get_selected_preset().printer_technology() == ptFFF;
|
||||
if (Tab* print_tab = get_tab(is_fff ? Preset::TYPE_PRINT : Preset::TYPE_SLA_PRINT))
|
||||
print_tab->select_preset(this->init_params->selected_presets.print);
|
||||
|
||||
if (Tab* print_tab = get_tab(is_fff ? Preset::TYPE_FILAMENT : Preset::TYPE_SLA_MATERIAL)) {
|
||||
const auto& materials = this->init_params->selected_presets.materials;
|
||||
print_tab->select_preset(materials[0]);
|
||||
|
||||
if (is_fff && materials.size() > 1) {
|
||||
for (size_t idx = 1; idx < materials.size(); idx++)
|
||||
preset_bundle->set_filament_preset(idx, materials[idx]);
|
||||
sidebar().update_all_filament_comboboxes();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// show "Did you know" notification
|
||||
|
@ -17,6 +17,15 @@ struct OpenGLVersions
|
||||
static const std::vector<std::pair<int, int>> core;
|
||||
};
|
||||
|
||||
struct CLISelectedProfiles
|
||||
{
|
||||
std::string print;
|
||||
std::string printer;
|
||||
std::vector<std::string> materials;
|
||||
|
||||
bool has_valid_data() { return !print.empty() && !printer.empty() && !materials.empty(); }
|
||||
};
|
||||
|
||||
struct GUI_InitParams
|
||||
{
|
||||
int argc;
|
||||
@ -28,6 +37,7 @@ struct GUI_InitParams
|
||||
std::vector<std::string> load_configs;
|
||||
DynamicPrintConfig extra_config;
|
||||
std::vector<std::string> input_files;
|
||||
CLISelectedProfiles selected_presets;
|
||||
|
||||
bool start_as_gcodeviewer;
|
||||
bool start_downloader;
|
||||
|
@ -587,6 +587,12 @@ void Sidebar::remove_unused_filament_combos(const size_t current_extruder_count)
|
||||
}
|
||||
}
|
||||
|
||||
void Sidebar::update_all_filament_comboboxes()
|
||||
{
|
||||
for (PlaterPresetComboBox* cb : m_combos_filament)
|
||||
cb->update();
|
||||
}
|
||||
|
||||
void Sidebar::update_all_preset_comboboxes()
|
||||
{
|
||||
PresetBundle &preset_bundle = *wxGetApp().preset_bundle;
|
||||
@ -604,8 +610,7 @@ void Sidebar::update_all_preset_comboboxes()
|
||||
// Update the filament choosers to only contain the compatible presets, update the color preview,
|
||||
// update the dirty flags.
|
||||
if (print_tech == ptFFF) {
|
||||
for (PlaterPresetComboBox* cb : m_combos_filament)
|
||||
cb->update();
|
||||
update_all_filament_comboboxes();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,6 +135,7 @@ public:
|
||||
void update_objects_list_extruder_column(size_t extruders_count);
|
||||
void update_presets(Preset::Type preset_type);
|
||||
void update_printer_presets_combobox();
|
||||
void update_all_filament_comboboxes();
|
||||
|
||||
void msw_rescale();
|
||||
void sys_color_changed();
|
||||
|
Loading…
x
Reference in New Issue
Block a user