mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-17 11:47:54 -06:00
Implemented naming of the SLA export file based on the output file name
template. Reworked naming of the plater exports to not use the output file name template, but to derive the file name from the first printable object's name. Fixed error handling: Reimpemented the Perl's "eval" blocks as try / catch blocks.
This commit is contained in:
parent
041fae8148
commit
d46d0dc365
25 changed files with 474 additions and 344 deletions
|
@ -402,6 +402,8 @@ const Transform3f& GLVolume::world_matrix() const
|
|||
|
||||
const BoundingBoxf3& GLVolume::transformed_bounding_box() const
|
||||
{
|
||||
assert(bounding_box.defined || bounding_box.min(0) >= bounding_box.max(0) || bounding_box.min(1) >= bounding_box.max(1) || bounding_box.min(2) >= bounding_box.max(2));
|
||||
|
||||
if (m_transformed_bounding_box_dirty)
|
||||
{
|
||||
#if ENABLE_MODELVOLUME_TRANSFORM
|
||||
|
|
|
@ -40,8 +40,9 @@ BackgroundSlicingProcess::~BackgroundSlicingProcess()
|
|||
boost::nowide::remove(m_temp_output_path.c_str());
|
||||
}
|
||||
|
||||
void BackgroundSlicingProcess::select_technology(PrinterTechnology tech)
|
||||
bool BackgroundSlicingProcess::select_technology(PrinterTechnology tech)
|
||||
{
|
||||
bool changed = false;
|
||||
if (m_print == nullptr || m_print->technology() != tech) {
|
||||
if (m_print != nullptr)
|
||||
this->reset();
|
||||
|
@ -49,8 +50,10 @@ void BackgroundSlicingProcess::select_technology(PrinterTechnology tech)
|
|||
case ptFFF: m_print = m_fff_print; break;
|
||||
case ptSLA: m_print = m_sla_print; break;
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
assert(m_print != nullptr);
|
||||
return changed;
|
||||
}
|
||||
|
||||
PrinterTechnology BackgroundSlicingProcess::current_printer_technology() const
|
||||
|
|
|
@ -55,7 +55,8 @@ public:
|
|||
void set_finished_event(int event_id) { m_event_finished_id = event_id; }
|
||||
|
||||
// Activate either m_fff_print or m_sla_print.
|
||||
void select_technology(PrinterTechnology tech);
|
||||
// Return true if changed.
|
||||
bool select_technology(PrinterTechnology tech);
|
||||
|
||||
// Get the currently active printer technology.
|
||||
PrinterTechnology current_printer_technology() const;
|
||||
|
|
|
@ -88,16 +88,18 @@ bool GUI_App::OnInit()
|
|||
|
||||
// just checking for existence of Slic3r::data_dir is not enough : it may be an empty directory
|
||||
// supplied as argument to --datadir; in that case we should still run the wizard
|
||||
// eval{
|
||||
preset_bundle->setup_directories();
|
||||
// };
|
||||
// if ($@) {
|
||||
// warn $@ . "\n";
|
||||
// fatal_error(undef, $@);
|
||||
// }
|
||||
try {
|
||||
preset_bundle->setup_directories();
|
||||
} catch (const std::exception &ex) {
|
||||
show_error(nullptr, ex.what());
|
||||
// Exit the application.
|
||||
return false;
|
||||
}
|
||||
|
||||
app_conf_exists = app_config->exists();
|
||||
// load settings
|
||||
if (app_conf_exists) app_config->load();
|
||||
if (app_conf_exists)
|
||||
app_config->load();
|
||||
app_config->set("version", SLIC3R_VERSION);
|
||||
app_config->save();
|
||||
|
||||
|
@ -109,9 +111,8 @@ bool GUI_App::OnInit()
|
|||
preset_bundle->set_default_suppressed(app_config->get("no_defaults") == "1");
|
||||
try {
|
||||
preset_bundle->load_presets(*app_config);
|
||||
} catch (const std::exception & /* ex */) {
|
||||
// warn $@ . "\n";
|
||||
// show_error(undef, $@);
|
||||
} catch (const std::exception &ex) {
|
||||
show_error(nullptr, ex.what());
|
||||
}
|
||||
|
||||
// Let the libslic3r know the callback, which will translate messages on demand.
|
||||
|
@ -168,14 +169,13 @@ bool GUI_App::OnInit()
|
|||
// are shown before or in the same event callback with the main frame creation.
|
||||
// Therefore we schedule them for later using CallAfter.
|
||||
CallAfter([this]() {
|
||||
// eval{
|
||||
if (!preset_updater->config_update())
|
||||
try {
|
||||
if (!preset_updater->config_update())
|
||||
mainframe->Close();
|
||||
} catch (const std::exception &ex) {
|
||||
show_error(nullptr, ex.what());
|
||||
mainframe->Close();
|
||||
// };
|
||||
// if ($@) {
|
||||
// show_error(undef, $@);
|
||||
// mainframe->Close();
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
CallAfter([this]() {
|
||||
|
@ -675,6 +675,7 @@ void GUI_App::delete_tab_from_list(Tab* tab)
|
|||
void GUI_App::load_current_presets()
|
||||
{
|
||||
PrinterTechnology printer_technology = preset_bundle->printers.get_edited_preset().printer_technology();
|
||||
this->plater()->set_printer_technology(printer_technology);
|
||||
for (Tab *tab : tabs_list)
|
||||
if (tab->supports_printer_technology(printer_technology)) {
|
||||
if (tab->name() == "printer")
|
||||
|
|
|
@ -681,10 +681,9 @@ void MainFrame::load_config_file(wxString file/* = wxEmptyString*/)
|
|||
}
|
||||
try {
|
||||
wxGetApp().preset_bundle->load_config_file(file.ToStdString());
|
||||
} catch (std::exception & /* ex */) {
|
||||
// Dont proceed further if the config file cannot be loaded.
|
||||
// if (Slic3r::GUI::catch_error(this))
|
||||
// return;
|
||||
} catch (const std::exception &ex) {
|
||||
show_error(this, ex.what());
|
||||
return;
|
||||
}
|
||||
wxGetApp().load_current_presets();
|
||||
wxGetApp().app_config->update_config_dir(get_dir_name(file));
|
||||
|
@ -696,9 +695,9 @@ void MainFrame::export_configbundle()
|
|||
if (!wxGetApp().check_unsaved_changes())
|
||||
return;
|
||||
// validate current configuration in case it's dirty
|
||||
auto valid = wxGetApp().preset_bundle->full_config().validate();
|
||||
if (!valid.empty()) {
|
||||
// Slic3r::GUI::catch_error(this);
|
||||
auto err = wxGetApp().preset_bundle->full_config().validate();
|
||||
if (! err.empty()) {
|
||||
show_error(this, err);
|
||||
return;
|
||||
}
|
||||
// Ask user for a file name.
|
||||
|
@ -715,8 +714,8 @@ void MainFrame::export_configbundle()
|
|||
wxGetApp().app_config->update_config_dir(get_dir_name(file));
|
||||
try {
|
||||
wxGetApp().preset_bundle->export_configbundle(file.ToStdString());
|
||||
} catch (std::exception & /* ex */) {
|
||||
// Slic3r::GUI::catch_error(this);
|
||||
} catch (const std::exception &ex) {
|
||||
show_error(this, ex.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -742,9 +741,10 @@ void MainFrame::load_configbundle(wxString file/* = wxEmptyString, const bool re
|
|||
|
||||
auto presets_imported = 0;
|
||||
try {
|
||||
presets_imported = wxGetApp().preset_bundle->load_configbundle(file.ToStdString());
|
||||
} catch (std::exception & /* ex */) {
|
||||
// Slic3r::GUI::catch_error(this) and return;
|
||||
presets_imported = wxGetApp().preset_bundle->load_configbundle(file.ToStdString());
|
||||
} catch (const std::exception &ex) {
|
||||
show_error(this, ex.what());
|
||||
return;
|
||||
}
|
||||
|
||||
// Load the currently selected preset into the GUI, update the preset selection box.
|
||||
|
|
|
@ -755,7 +755,7 @@ void Sidebar::show_sliced_info_sizer(const bool show)
|
|||
|
||||
p->sliced_info->Show(show);
|
||||
if (show) {
|
||||
const PrintStatistics& ps = p->plater->print().print_statistics();
|
||||
const PrintStatistics& ps = p->plater->fff_print().print_statistics();
|
||||
const bool is_wipe_tower = ps.total_wipe_tower_filament > 0;
|
||||
|
||||
wxString new_label = _(L("Used Filament (m)"));
|
||||
|
@ -801,7 +801,7 @@ void Sidebar::show_sliced_info_sizer(const bool show)
|
|||
}
|
||||
|
||||
// if there is a wipe tower, insert number of toolchanges info into the array:
|
||||
p->sliced_info->SetTextAndShow(siWTNumbetOfToolchanges, is_wipe_tower ? wxString::Format("%.d", p->plater->print().wipe_tower_data().number_of_toolchanges) : "N/A");
|
||||
p->sliced_info->SetTextAndShow(siWTNumbetOfToolchanges, is_wipe_tower ? wxString::Format("%.d", p->plater->fff_print().wipe_tower_data().number_of_toolchanges) : "N/A");
|
||||
}
|
||||
|
||||
Layout();
|
||||
|
@ -906,7 +906,7 @@ struct Plater::priv
|
|||
|
||||
// Data
|
||||
Slic3r::DynamicPrintConfig *config;
|
||||
Slic3r::Print print;
|
||||
Slic3r::Print fff_print;
|
||||
Slic3r::SLAPrint sla_print;
|
||||
Slic3r::Model model;
|
||||
PrinterTechnology printer_technology = ptFFF;
|
||||
|
@ -973,6 +973,8 @@ struct Plater::priv
|
|||
void sla_optimize_rotation();
|
||||
void split_object();
|
||||
void split_volume();
|
||||
bool background_processing_enabled() const { return this->get_config("background_processing") == "1"; }
|
||||
void update_print_volume_state();
|
||||
void schedule_background_process();
|
||||
// Update background processing thread from the current config and Model.
|
||||
enum UpdateBackgroundProcessReturnState {
|
||||
|
@ -1061,7 +1063,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
|||
#endif // ENABLE_NEW_MENU_LAYOUT
|
||||
{
|
||||
arranging.store(false);
|
||||
background_process.set_fff_print(&print);
|
||||
background_process.set_fff_print(&fff_print);
|
||||
background_process.set_sla_print(&sla_print);
|
||||
background_process.set_gcode_preview_data(&gcode_preview_data);
|
||||
background_process.set_slicing_completed_event(EVT_SLICING_COMPLETED);
|
||||
|
@ -1073,7 +1075,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
|||
auto statuscb = [this](const Slic3r::PrintBase::SlicingStatus &status) {
|
||||
wxQueueEvent(this->q, new Slic3r::SlicingStatusEvent(EVT_SLICING_UPDATE, 0, status));
|
||||
};
|
||||
print.set_status_callback(statuscb);
|
||||
fff_print.set_status_callback(statuscb);
|
||||
sla_print.set_status_callback(statuscb);
|
||||
this->q->Bind(EVT_SLICING_UPDATE, &priv::on_slicing_update, this);
|
||||
|
||||
|
@ -1323,8 +1325,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path> &input_
|
|||
if (obj->name.empty())
|
||||
obj->name = fs::path(obj->input_file).filename().string();
|
||||
}
|
||||
}
|
||||
catch (const std::runtime_error &e) {
|
||||
} catch (const std::exception &e) {
|
||||
GUI::show_error(q, e.what());
|
||||
continue;
|
||||
}
|
||||
|
@ -1480,13 +1481,15 @@ std::unique_ptr<CheckboxFileDialog> Plater::priv::get_export_file(GUI::FileType
|
|||
case FT_GCODE:
|
||||
wildcard = file_wildcards[file_type];
|
||||
break;
|
||||
// FT_GCODE
|
||||
default:
|
||||
wildcard = file_wildcards[FT_MODEL];
|
||||
break;
|
||||
}
|
||||
|
||||
fs::path output_file(print.output_filepath(std::string()));
|
||||
// Update printbility state of each of the ModelInstances.
|
||||
this->update_print_volume_state();
|
||||
// Find the file name of the first printable object.
|
||||
fs::path output_file = this->model.propose_export_file_name();
|
||||
|
||||
switch (file_type) {
|
||||
case FT_STL: output_file.replace_extension("stl"); break;
|
||||
|
@ -1495,8 +1498,6 @@ std::unique_ptr<CheckboxFileDialog> Plater::priv::get_export_file(GUI::FileType
|
|||
default: break;
|
||||
}
|
||||
|
||||
wxGetApp().preset_bundle->export_selections(print.placeholder_parser());
|
||||
|
||||
auto dlg = Slic3r::make_unique<CheckboxFileDialog>(q,
|
||||
((file_type == FT_AMF) || (file_type == FT_3MF)) ? _(L("Export print config")) : "",
|
||||
true,
|
||||
|
@ -1809,6 +1810,15 @@ void Plater::priv::schedule_background_process()
|
|||
this->background_process_timer.Start(500, wxTIMER_ONE_SHOT);
|
||||
}
|
||||
|
||||
void Plater::priv::update_print_volume_state()
|
||||
{
|
||||
BoundingBox bed_box_2D = get_extents(Polygon::new_scale(this->config->opt<ConfigOptionPoints>("bed_shape")->values));
|
||||
BoundingBoxf3 print_volume(unscale(bed_box_2D.min(0), bed_box_2D.min(1), 0.0), unscale(bed_box_2D.max(0), bed_box_2D.max(1), scale_(this->config->opt_float("max_print_height"))));
|
||||
// Allow the objects to protrude below the print bed, only the part of the object above the print bed will be sliced.
|
||||
print_volume.min(2) = -1e10;
|
||||
this->q->model().update_print_volume_state(print_volume);
|
||||
}
|
||||
|
||||
// Update background processing thread from the current config and Model.
|
||||
// Returns a bitmask of UpdateBackgroundProcessReturnState.
|
||||
unsigned int Plater::priv::update_background_process()
|
||||
|
@ -1819,16 +1829,10 @@ unsigned int Plater::priv::update_background_process()
|
|||
// If the async_apply_config() was not called by the timer, kill the timer, so the async_apply_config()
|
||||
// will not be called again in vain.
|
||||
this->background_process_timer.Stop();
|
||||
|
||||
DynamicPrintConfig config = wxGetApp().preset_bundle->full_config();
|
||||
BoundingBox bed_box_2D = get_extents(Polygon::new_scale(config.opt<ConfigOptionPoints>("bed_shape")->values));
|
||||
BoundingBoxf3 print_volume(unscale(bed_box_2D.min(0), bed_box_2D.min(1), 0.0), unscale(bed_box_2D.max(0), bed_box_2D.max(1), scale_(config.opt_float("max_print_height"))));
|
||||
// Allow the objects to protrude below the print bed, only the part of the object above the print bed will be sliced.
|
||||
print_volume.min(2) = -1e10;
|
||||
this->q->model().update_print_volume_state(print_volume);
|
||||
|
||||
// Update the "out of print bed" state of ModelInstances.
|
||||
this->update_print_volume_state();
|
||||
// Apply new config to the possibly running background task.
|
||||
Print::ApplyStatus invalidated = this->background_process.apply(this->q->model(), std::move(config));
|
||||
Print::ApplyStatus invalidated = this->background_process.apply(this->q->model(), wxGetApp().preset_bundle->full_config());
|
||||
|
||||
// Just redraw the 3D canvas without reloading the scene to consume the update of the layer height profile.
|
||||
if (this->canvas3D->is_layers_editing_enabled())
|
||||
|
@ -1880,7 +1884,7 @@ void Plater::priv::async_apply_config()
|
|||
unsigned int state = this->update_background_process();
|
||||
if (state & UPDATE_BACKGROUND_PROCESS_REFRESH_SCENE)
|
||||
this->canvas3D->reload_scene(false);
|
||||
if ((state & UPDATE_BACKGROUND_PROCESS_RESTART) != 0 && this->get_config("background_processing") == "1") {
|
||||
if ((state & UPDATE_BACKGROUND_PROCESS_RESTART) != 0 && this->background_processing_enabled()) {
|
||||
// The print is valid and it can be started.
|
||||
if (this->background_process.start())
|
||||
this->statusbar()->set_cancel_callback([this]() {
|
||||
|
@ -1918,7 +1922,7 @@ void Plater::priv::fix_through_netfabb(const int obj_idx)
|
|||
|
||||
const auto model_object = model.objects[obj_idx];
|
||||
Model model_fixed;// = new Model();
|
||||
fix_model_by_win10_sdk_gui(*model_object, print, model_fixed);
|
||||
fix_model_by_win10_sdk_gui(*model_object, this->fff_print, model_fixed);
|
||||
|
||||
auto new_obj_idxs = load_model_objects(model_fixed.objects);
|
||||
if (new_obj_idxs.empty())
|
||||
|
@ -2235,7 +2239,8 @@ bool Plater::priv::init_object_menu()
|
|||
item_sla_autorot = append_menu_item(&object_menu, wxID_ANY, _(L("Optimize orientation")), _(L("Optimize the rotation of the object for better print results.")),
|
||||
[this](wxCommandEvent&) { sla_optimize_rotation(); });
|
||||
|
||||
if(printer_technology == ptFFF) item_sla_autorot = object_menu.Remove(item_sla_autorot);
|
||||
if (printer_technology == ptFFF)
|
||||
item_sla_autorot = object_menu.Remove(item_sla_autorot);
|
||||
|
||||
// ui updates needs to be binded to the parent panel
|
||||
if (q != nullptr)
|
||||
|
@ -2318,9 +2323,12 @@ Plater::~Plater()
|
|||
p->canvas3D = nullptr;
|
||||
}
|
||||
|
||||
Sidebar& Plater::sidebar() { return *p->sidebar; }
|
||||
Model& Plater::model() { return p->model; }
|
||||
Print& Plater::print() { return p->print; }
|
||||
Sidebar& Plater::sidebar() { return *p->sidebar; }
|
||||
Model& Plater::model() { return p->model; }
|
||||
const Print& Plater::fff_print() const { return p->fff_print; }
|
||||
Print& Plater::fff_print() { return p->fff_print; }
|
||||
const SLAPrint& Plater::sla_print() const { return p->sla_print; }
|
||||
SLAPrint& Plater::sla_print() { return p->sla_print; }
|
||||
|
||||
#if ENABLE_NEW_MENU_LAYOUT
|
||||
void Plater::load_project()
|
||||
|
@ -2509,53 +2517,33 @@ void Plater::export_gcode(fs::path output_path)
|
|||
return;
|
||||
}
|
||||
|
||||
std::string err = wxGetApp().preset_bundle->full_config().validate();
|
||||
if (err.empty())
|
||||
err = p->background_process.validate();
|
||||
if (! err.empty()) {
|
||||
// The config is not valid
|
||||
GUI::show_error(this, _(err));
|
||||
// bitmask of UpdateBackgroundProcessReturnState
|
||||
unsigned int state = this->p->update_background_process();
|
||||
if (state & priv::UPDATE_BACKGROUND_PROCESS_REFRESH_SCENE)
|
||||
this->p->canvas3D->reload_scene(false);
|
||||
if ((state & priv::UPDATE_BACKGROUND_PROCESS_INVALID) != 0)
|
||||
return;
|
||||
}
|
||||
|
||||
std::string final_path;
|
||||
if(printer_technology() == ptFFF) { // TODO: custom button for SLA export
|
||||
// select output file
|
||||
if (output_path.empty()) {
|
||||
// XXX: take output path from CLI opts? Ancient Slic3r versions used to do that...
|
||||
|
||||
// Copy the names of active presets into the placeholder parser.
|
||||
wxGetApp().preset_bundle->export_selections(p->print.placeholder_parser());
|
||||
|
||||
// select output file
|
||||
if (output_path.empty()) {
|
||||
// XXX: take output path from CLI opts? Ancient Slic3r versions used to do that...
|
||||
|
||||
// If possible, remove accents from accented latin characters.
|
||||
// This function is useful for generating file names to be processed by legacy firmwares.
|
||||
auto default_output_file = fs::path(Slic3r::fold_utf8_to_ascii(
|
||||
p->print.output_filepath(output_path.string())
|
||||
// FIXME: ^ errors to handle?
|
||||
));
|
||||
auto start_dir = wxGetApp().app_config->get_last_output_dir(default_output_file.parent_path().string());
|
||||
|
||||
wxFileDialog dlg(this, _(L("Save G-code file as:")),
|
||||
start_dir,
|
||||
default_output_file.filename().string(),
|
||||
GUI::file_wildcards[FT_GCODE],
|
||||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT
|
||||
);
|
||||
|
||||
if (dlg.ShowModal() == wxID_OK) {
|
||||
fs::path path(dlg.GetPath());
|
||||
wxGetApp().app_config->update_last_output_dir(path.parent_path().string());
|
||||
output_path = path;
|
||||
}
|
||||
// If possible, remove accents from accented latin characters.
|
||||
// This function is useful for generating file names to be processed by legacy firmwares.
|
||||
fs::path default_output_file;
|
||||
try {
|
||||
default_output_file = this->p->background_process.current_print()->output_filepath(output_path.string());
|
||||
} catch (const std::exception &ex) {
|
||||
show_error(this, ex.what());
|
||||
return;
|
||||
}
|
||||
default_output_file = fs::path(Slic3r::fold_utf8_to_ascii(default_output_file.string()));
|
||||
auto start_dir = wxGetApp().app_config->get_last_output_dir(default_output_file.parent_path().string());
|
||||
|
||||
final_path = p->print.output_filepath(output_path.string());
|
||||
} else {
|
||||
wxFileDialog dlg(this, _(L("Save Zip file as:")),
|
||||
wxGetApp().app_config->get_last_output_dir(""),
|
||||
"out.zip",
|
||||
GUI::file_wildcards[FT_PNGZIP],
|
||||
wxFileDialog dlg(this, (printer_technology() == ptFFF) ? _(L("Save G-code file as:")) : _(L("Save Zip file as:")),
|
||||
start_dir,
|
||||
default_output_file.filename().string(),
|
||||
GUI::file_wildcards[(printer_technology() == ptFFF) ? FT_GCODE : FT_PNGZIP],
|
||||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT
|
||||
);
|
||||
|
||||
|
@ -2564,13 +2552,25 @@ void Plater::export_gcode(fs::path output_path)
|
|||
wxGetApp().app_config->update_last_output_dir(path.parent_path().string());
|
||||
output_path = path;
|
||||
}
|
||||
|
||||
final_path = output_path.string();
|
||||
} else {
|
||||
try {
|
||||
output_path = this->p->background_process.current_print()->output_filepath(output_path.string());
|
||||
} catch (const std::exception &ex) {
|
||||
show_error(this, ex.what());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (! output_path.empty()) {
|
||||
this->p->background_process.schedule_export(final_path);
|
||||
this->p->background_process.start();
|
||||
if (! output_path.empty())
|
||||
this->p->background_process.schedule_export(output_path.string());
|
||||
|
||||
if ((! output_path.empty() || this->p->background_processing_enabled()) && ! this->p->background_process.running()) {
|
||||
// The print is valid and it should be started.
|
||||
if (this->p->background_process.start())
|
||||
this->p->statusbar()->set_cancel_callback([this]() {
|
||||
this->p->statusbar()->set_status_text(L("Cancelling"));
|
||||
this->p->background_process.stop();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2660,11 +2660,8 @@ void Plater::reslice()
|
|||
unsigned int state = this->p->update_background_process();
|
||||
if (state & priv::UPDATE_BACKGROUND_PROCESS_REFRESH_SCENE)
|
||||
this->p->canvas3D->reload_scene(false);
|
||||
if ((state & priv::UPDATE_BACKGROUND_PROCESS_INVALID) == 0 && !this->p->background_process.running()) {
|
||||
if ((state & priv::UPDATE_BACKGROUND_PROCESS_INVALID) == 0 && ! this->p->background_process.running()) {
|
||||
// The print is valid and it can be started.
|
||||
// Copy the names of active presets into the placeholder parser.
|
||||
//FIXME how to generate a file name for the SLA printers?
|
||||
wxGetApp().preset_bundle->export_selections(this->print().placeholder_parser());
|
||||
if (this->p->background_process.start())
|
||||
this->p->statusbar()->set_cancel_callback([this]() {
|
||||
this->p->statusbar()->set_status_text(L("Cancelling"));
|
||||
|
@ -2709,12 +2706,8 @@ void Plater::on_config_change(const DynamicPrintConfig &config)
|
|||
bool update_scheduled = false;
|
||||
for (auto opt_key : p->config->diff(config)) {
|
||||
p->config->set_key_value(opt_key, config.option(opt_key)->clone());
|
||||
if (opt_key == "printer_technology") {
|
||||
p->printer_technology = config.opt_enum<PrinterTechnology>(opt_key);
|
||||
p->background_process.select_technology(this->printer_technology());
|
||||
//FIXME for SLA synchronize
|
||||
//p->background_process.apply(Model)!
|
||||
}
|
||||
if (opt_key == "printer_technology")
|
||||
this->set_printer_technology(config.opt_enum<PrinterTechnology>(opt_key));
|
||||
else if (opt_key == "bed_shape") {
|
||||
this->p->canvas3D->set_bed_shape(p->config->option<ConfigOptionPoints>(opt_key)->values);
|
||||
if (p->preview) p->preview->set_bed_shape(p->config->option<ConfigOptionPoints>(opt_key)->values);
|
||||
|
@ -2811,6 +2804,16 @@ PrinterTechnology Plater::printer_technology() const
|
|||
return p->printer_technology;
|
||||
}
|
||||
|
||||
void Plater::set_printer_technology(PrinterTechnology printer_technology)
|
||||
{
|
||||
p->printer_technology = printer_technology;
|
||||
if (p->background_process.select_technology(printer_technology)) {
|
||||
// Update the active presets.
|
||||
}
|
||||
//FIXME for SLA synchronize
|
||||
//p->background_process.apply(Model)!
|
||||
}
|
||||
|
||||
void Plater::changed_object(int obj_idx)
|
||||
{
|
||||
if (obj_idx < 0)
|
||||
|
@ -2827,20 +2830,21 @@ void Plater::changed_object(int obj_idx)
|
|||
model_object->center_around_origin();
|
||||
#endif // !ENABLE_MODELVOLUME_TRANSFORM
|
||||
model_object->ensure_on_bed();
|
||||
if (this->p->printer_technology == ptSLA) {
|
||||
// Update the SLAPrint from the current Model, so that the reload_scene()
|
||||
// pulls the correct data.
|
||||
this->p->update_background_process();
|
||||
}
|
||||
p->canvas3D->reload_scene(false);
|
||||
}
|
||||
|
||||
// update print
|
||||
this->p->schedule_background_process();
|
||||
if (list->is_parts_changed() || list->is_part_settings_changed()) {
|
||||
this->p->schedule_background_process();
|
||||
#if !ENABLE_MODIFIED_CAMERA_TARGET
|
||||
p->canvas3D->zoom_to_volumes();
|
||||
#endif // !ENABLE_MODIFIED_CAMERA_TARGET
|
||||
}
|
||||
else {
|
||||
this->p->schedule_background_process();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Plater::fix_through_netfabb(const int obj_idx) { p->fix_through_netfabb(obj_idx); }
|
||||
|
|
|
@ -111,7 +111,10 @@ public:
|
|||
|
||||
Sidebar& sidebar();
|
||||
Model& model();
|
||||
Print& print();
|
||||
const Print& fff_print() const;
|
||||
Print& fff_print();
|
||||
const SLAPrint& sla_print() const;
|
||||
SLAPrint& sla_print();
|
||||
|
||||
#if ENABLE_NEW_MENU_LAYOUT
|
||||
void load_project();
|
||||
|
@ -168,7 +171,9 @@ public:
|
|||
bool is_single_full_object_selection() const;
|
||||
GLCanvas3D* canvas3D();
|
||||
|
||||
PrinterTechnology printer_technology() const;
|
||||
PrinterTechnology printer_technology() const;
|
||||
void set_printer_technology(PrinterTechnology printer_technology);
|
||||
|
||||
private:
|
||||
struct priv;
|
||||
std::unique_ptr<priv> p;
|
||||
|
|
|
@ -363,39 +363,6 @@ const std::vector<std::string>& Preset::nozzle_options()
|
|||
return s_opts;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& Preset::sla_printer_options()
|
||||
{
|
||||
static std::vector<std::string> s_opts;
|
||||
if (s_opts.empty()) {
|
||||
s_opts = {
|
||||
"printer_technology",
|
||||
"bed_shape", "max_print_height",
|
||||
"display_width", "display_height", "display_pixels_x", "display_pixels_y",
|
||||
"printer_correction",
|
||||
"printer_notes",
|
||||
"inherits"
|
||||
};
|
||||
}
|
||||
return s_opts;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& Preset::sla_material_options()
|
||||
{
|
||||
static std::vector<std::string> s_opts;
|
||||
if (s_opts.empty()) {
|
||||
s_opts = {
|
||||
"layer_height", "initial_layer_height",
|
||||
"exposure_time", "initial_exposure_time",
|
||||
"material_correction_printing", "material_correction_curing",
|
||||
"material_notes",
|
||||
"default_sla_material_profile",
|
||||
"compatible_printers",
|
||||
"compatible_printers_condition", "inherits"
|
||||
};
|
||||
}
|
||||
return s_opts;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& Preset::sla_print_options()
|
||||
{
|
||||
static std::vector<std::string> s_opts;
|
||||
|
@ -418,6 +385,7 @@ const std::vector<std::string>& Preset::sla_print_options()
|
|||
"pad_wall_height",
|
||||
"pad_max_merge_distance",
|
||||
"pad_edge_radius",
|
||||
"output_filename_format",
|
||||
"default_sla_print_profile",
|
||||
"compatible_printers",
|
||||
"compatible_printers_condition",
|
||||
|
@ -427,6 +395,39 @@ const std::vector<std::string>& Preset::sla_print_options()
|
|||
return s_opts;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& Preset::sla_material_options()
|
||||
{
|
||||
static std::vector<std::string> s_opts;
|
||||
if (s_opts.empty()) {
|
||||
s_opts = {
|
||||
"initial_layer_height",
|
||||
"exposure_time", "initial_exposure_time",
|
||||
"material_correction_printing", "material_correction_curing",
|
||||
"material_notes",
|
||||
"default_sla_material_profile",
|
||||
"compatible_printers",
|
||||
"compatible_printers_condition", "inherits"
|
||||
};
|
||||
}
|
||||
return s_opts;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& Preset::sla_printer_options()
|
||||
{
|
||||
static std::vector<std::string> s_opts;
|
||||
if (s_opts.empty()) {
|
||||
s_opts = {
|
||||
"printer_technology",
|
||||
"bed_shape", "max_print_height",
|
||||
"display_width", "display_height", "display_pixels_x", "display_pixels_y",
|
||||
"printer_correction",
|
||||
"printer_notes",
|
||||
"inherits"
|
||||
};
|
||||
}
|
||||
return s_opts;
|
||||
}
|
||||
|
||||
PresetCollection::PresetCollection(Preset::Type type, const std::vector<std::string> &keys, const Slic3r::StaticPrintConfig &defaults, const std::string &default_name) :
|
||||
m_type(type),
|
||||
m_edited_preset(type, "", false),
|
||||
|
@ -539,8 +540,8 @@ static bool profile_print_params_same(const DynamicPrintConfig &cfg1, const Dyna
|
|||
// Following keys are used by the UI, not by the slicing core, therefore they are not important
|
||||
// when comparing profiles for equality. Ignore them.
|
||||
for (const char *key : { "compatible_printers", "compatible_printers_condition", "inherits",
|
||||
"print_settings_id", "filament_settings_id", "sla_material_settings_id", "printer_settings_id",
|
||||
"printer_model", "printer_variant", "default_print_profile", "default_filament_profile", "default_sla_material_profile" })
|
||||
"print_settings_id", "filament_settings_id", "sla_print_settings_id", "sla_material_settings_id", "printer_settings_id",
|
||||
"printer_model", "printer_variant", "default_print_profile", "default_filament_profile", "default_sla_print_profile", "default_sla_material_profile" })
|
||||
diff.erase(std::remove(diff.begin(), diff.end(), key), diff.end());
|
||||
// Preset with the same name as stored inside the config exists.
|
||||
return diff.empty();
|
||||
|
@ -562,7 +563,7 @@ Preset& PresetCollection::load_external_preset(
|
|||
bool select)
|
||||
{
|
||||
// Load the preset over a default preset, so that the missing fields are filled in from the default preset.
|
||||
DynamicPrintConfig cfg(this->default_preset().config);
|
||||
DynamicPrintConfig cfg(this->default_preset_for(config).config);
|
||||
cfg.apply_only(config, cfg.keys(), true);
|
||||
// Is there a preset already loaded with the name stored inside the config?
|
||||
std::deque<Preset>::iterator it = this->find_preset_internal(original_name);
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include <wx/wupdlock.h>
|
||||
|
||||
#include "libslic3r/libslic3r.h"
|
||||
#include "libslic3r/PlaceholderParser.hpp"
|
||||
#include "libslic3r/Utils.hpp"
|
||||
|
||||
// Store the print/filament/printer presets into a "presets" subdirectory of the Slic3rPE config dir.
|
||||
|
@ -95,8 +94,8 @@ PresetBundle::PresetBundle() :
|
|||
preset.config.option<ConfigOptionStrings>("default_filament_profile", true)->values = { "" };
|
||||
}
|
||||
else {
|
||||
preset.config.optptr("default_sla_material_profile", true);
|
||||
preset.config.optptr("default_sla_print_profile", true);
|
||||
preset.config.optptr("default_sla_material_profile", true);
|
||||
}
|
||||
// default_sla_material_profile
|
||||
preset.inherits();
|
||||
|
@ -391,24 +390,7 @@ void PresetBundle::export_selections(AppConfig &config)
|
|||
}
|
||||
config.set("presets", "sla_print", sla_prints.get_selected_preset_name());
|
||||
config.set("presets", "sla_material", sla_materials.get_selected_preset_name());
|
||||
config.set("presets", "printer", printers.get_selected_preset_name());
|
||||
}
|
||||
|
||||
void PresetBundle::export_selections(PlaceholderParser &pp)
|
||||
{
|
||||
assert(filament_presets.size() >= 1);
|
||||
assert(filament_presets.size() > 1 || filaments.get_selected_preset_name() == filament_presets.front());
|
||||
switch (printers.get_edited_preset().printer_technology()) {
|
||||
case ptFFF:
|
||||
pp.set("print_preset", prints.get_selected_preset().name);
|
||||
pp.set("filament_preset", filament_presets);
|
||||
break;
|
||||
case ptSLA:
|
||||
pp.set("sla_print_preset", sla_prints.get_selected_preset().name);
|
||||
pp.set("sla_material_preset", sla_materials.get_selected_preset().name);
|
||||
break;
|
||||
}
|
||||
pp.set("printer_preset", printers.get_selected_preset().name);
|
||||
config.set("presets", "printer", printers.get_selected_preset_name());
|
||||
}
|
||||
|
||||
bool PresetBundle::load_compatible_bitmaps()
|
||||
|
@ -676,7 +658,8 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
|
|||
size_t num_extruders = (printer_technology == ptFFF) ?
|
||||
std::min(config.option<ConfigOptionFloats>("nozzle_diameter" )->values.size(),
|
||||
config.option<ConfigOptionFloats>("filament_diameter")->values.size()) :
|
||||
0;
|
||||
// 1 SLA material
|
||||
1;
|
||||
// Make a copy of the "compatible_printers_condition_cummulative" and "inherits_cummulative" vectors, which
|
||||
// accumulate values over all presets (print, filaments, printers).
|
||||
// These values will be distributed into their particular presets when loading.
|
||||
|
@ -687,8 +670,16 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
|
|||
compatible_printers_condition_values.resize(num_extruders + 2, std::string());
|
||||
inherits_values.resize(num_extruders + 2, std::string());
|
||||
// The "default_filament_profile" will be later extracted into the printer profile.
|
||||
if (printer_technology == ptFFF)
|
||||
config.option<ConfigOptionStrings>("default_filament_profile", true)->values.resize(num_extruders, std::string());
|
||||
switch (printer_technology) {
|
||||
case ptFFF:
|
||||
config.option<ConfigOptionString>("default_print_profile", true);
|
||||
config.option<ConfigOptionStrings>("default_filament_profile", true)->values.resize(num_extruders, std::string());
|
||||
break;
|
||||
case ptSLA:
|
||||
config.option<ConfigOptionString>("default_sla_print_profile", true);
|
||||
config.option<ConfigOptionString>("default_sla_material_profile", true);
|
||||
break;
|
||||
}
|
||||
|
||||
// 1) Create a name from the file name.
|
||||
// Keep the suffix (.ini, .gcode, .amf, .3mf etc) to differentiate it from the normal profiles.
|
||||
|
@ -697,22 +688,24 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
|
|||
// 2) If the loading succeeded, split and load the config into print / filament / printer settings.
|
||||
// First load the print and printer presets.
|
||||
|
||||
// #ys_FIXME_SLA_PRINT
|
||||
for (size_t i_group = 0; i_group < 2; ++ i_group) {
|
||||
PresetCollection &presets = (i_group == 0) ? ((printer_technology == ptFFF) ? this->prints : this->sla_materials) : this->printers;
|
||||
// Split the "compatible_printers_condition" and "inherits" values one by one from a single vector to the print & printer profiles.
|
||||
size_t idx = (i_group == 0) ? 0 : num_extruders + 1;
|
||||
inherits = inherits_values[idx];
|
||||
compatible_printers_condition = compatible_printers_condition_values[idx];
|
||||
auto load_preset =
|
||||
[&config, &inherits, &inherits_values, &compatible_printers_condition, &compatible_printers_condition_values, is_external, &name, &name_or_path]
|
||||
(PresetCollection &presets, size_t idx, const std::string &key) {
|
||||
// Split the "compatible_printers_condition" and "inherits" values one by one from a single vector to the print & printer profiles.
|
||||
inherits = inherits_values[idx];
|
||||
compatible_printers_condition = compatible_printers_condition_values[idx];
|
||||
if (is_external)
|
||||
presets.load_external_preset(name_or_path, name,
|
||||
config.opt_string((i_group == 0) ? ((printer_technology == ptFFF) ? "print_settings_id" : "sla_material_settings_id") : "printer_settings_id", true),
|
||||
config);
|
||||
else
|
||||
presets.load_preset(presets.path_from_name(name), name, config).save();
|
||||
}
|
||||
presets.load_external_preset(name_or_path, name, config.opt_string(key, true), config);
|
||||
else
|
||||
presets.load_preset(presets.path_from_name(name), name, config).save();
|
||||
};
|
||||
|
||||
switch (Preset::printer_technology(config)) {
|
||||
case ptFFF:
|
||||
{
|
||||
load_preset(this->prints, 0, "print_settings_id");
|
||||
load_preset(this->printers, num_extruders + 1, "printer_settings_id");
|
||||
|
||||
if (Preset::printer_technology(config) == ptFFF) {
|
||||
// 3) Now load the filaments. If there are multiple filament presets, split them and load them.
|
||||
auto old_filament_profile_names = config.option<ConfigOptionStrings>("filament_settings_id", true);
|
||||
old_filament_profile_names->values.resize(num_extruders, std::string());
|
||||
|
@ -721,12 +714,15 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
|
|||
// Split the "compatible_printers_condition" and "inherits" from the cummulative vectors to separate filament presets.
|
||||
inherits = inherits_values[1];
|
||||
compatible_printers_condition = compatible_printers_condition_values[1];
|
||||
if (is_external)
|
||||
this->filaments.load_external_preset(name_or_path, name, old_filament_profile_names->values.front(), config);
|
||||
else
|
||||
this->filaments.load_preset(this->filaments.path_from_name(name), name, config).save();
|
||||
Preset *loaded = nullptr;
|
||||
if (is_external) {
|
||||
loaded = &this->filaments.load_external_preset(name_or_path, name, old_filament_profile_names->values.front(), config);
|
||||
} else {
|
||||
loaded = &this->filaments.load_preset(this->filaments.path_from_name(name), name, config);
|
||||
loaded->save();
|
||||
}
|
||||
this->filament_presets.clear();
|
||||
this->filament_presets.emplace_back(name);
|
||||
this->filament_presets.emplace_back(loaded->name);
|
||||
} else {
|
||||
// Split the filament presets, load each of them separately.
|
||||
std::vector<DynamicPrintConfig> configs(num_extruders, this->filaments.default_preset().config);
|
||||
|
@ -772,12 +768,18 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
|
|||
this->filament_presets.emplace_back(loaded->name);
|
||||
}
|
||||
}
|
||||
|
||||
// 4) Load the project config values (the per extruder wipe matrix etc).
|
||||
this->project_config.apply_only(config, s_project_options);
|
||||
break;
|
||||
}
|
||||
case ptSLA:
|
||||
load_preset(this->sla_prints, 0, "sla_print_settings_id");
|
||||
load_preset(this->sla_materials, 1, "sla_material_settings_id");
|
||||
load_preset(this->printers, 2, "printer_settings_id");
|
||||
break;
|
||||
}
|
||||
|
||||
this->update_compatible_with_printer(false);
|
||||
this->update_compatible_with_printer(false);
|
||||
}
|
||||
|
||||
// Load the active configuration of a config bundle from a boost property_tree. This is a private method called from load_config_file.
|
||||
|
@ -1229,7 +1231,9 @@ void PresetBundle::update_compatible_with_printer(bool select_other_if_incompati
|
|||
switch (printers.get_edited_preset().printer_technology()) {
|
||||
case ptFFF:
|
||||
{
|
||||
const std::string &prefered_print_profile = printer_preset.config.opt_string("default_print_profile");
|
||||
assert(printer_preset.config.has("default_print_profile"));
|
||||
assert(printer_preset.config.has("default_filament_profile"));
|
||||
const std::string &prefered_print_profile = printer_preset.config.opt_string("default_print_profile");
|
||||
const std::vector<std::string> &prefered_filament_profiles = printer_preset.config.option<ConfigOptionStrings>("default_filament_profile")->values;
|
||||
prefered_print_profile.empty() ?
|
||||
this->prints.update_compatible_with_printer(printer_preset, select_other_if_incompatible) :
|
||||
|
@ -1263,18 +1267,18 @@ void PresetBundle::update_compatible_with_printer(bool select_other_if_incompati
|
|||
}
|
||||
case ptSLA:
|
||||
{
|
||||
const std::string &prefered_sla_material_profile = printer_preset.config.opt_string("default_sla_material_profile");
|
||||
assert(printer_preset.config.has("default_sla_print_profile"));
|
||||
assert(printer_preset.config.has("default_sla_material_profile"));
|
||||
const std::string &prefered_sla_print_profile = printer_preset.config.opt_string("default_sla_print_profile");
|
||||
(prefered_sla_print_profile.empty()) ?
|
||||
this->sla_prints.update_compatible_with_printer(printer_preset, select_other_if_incompatible) :
|
||||
this->sla_prints.update_compatible_with_printer(printer_preset, select_other_if_incompatible,
|
||||
[&prefered_sla_print_profile](const std::string& profile_name){ return profile_name == prefered_sla_print_profile; });
|
||||
const std::string &prefered_sla_material_profile = printer_preset.config.opt_string("default_sla_material_profile");
|
||||
prefered_sla_material_profile.empty() ?
|
||||
this->sla_materials.update_compatible_with_printer(printer_preset, select_other_if_incompatible) :
|
||||
this->sla_materials.update_compatible_with_printer(printer_preset, select_other_if_incompatible,
|
||||
[&prefered_sla_material_profile](const std::string& profile_name){ return profile_name == prefered_sla_material_profile; });
|
||||
|
||||
const std::string &prefered_sla_print_profile = printer_preset.config.opt_string("default_sla_print_profile");
|
||||
prefered_sla_print_profile.empty() ?
|
||||
this->sla_prints.update_compatible_with_printer(printer_preset, select_other_if_incompatible) :
|
||||
this->sla_prints.update_compatible_with_printer(printer_preset, select_other_if_incompatible,
|
||||
[&prefered_sla_print_profile](const std::string& profile_name){ return profile_name == prefered_sla_print_profile; });
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,6 @@ namespace GUI {
|
|||
class BitmapCache;
|
||||
};
|
||||
|
||||
class PlaceholderParser;
|
||||
|
||||
// Bundle of Print + Filament + Printer presets.
|
||||
class PresetBundle
|
||||
{
|
||||
|
@ -35,8 +33,6 @@ public:
|
|||
|
||||
// Export selections (current print, current filaments, current printer) into config.ini
|
||||
void export_selections(AppConfig &config);
|
||||
// Export selections (current print, current filaments, current printer) into a placeholder parser.
|
||||
void export_selections(PlaceholderParser &pp);
|
||||
|
||||
PresetCollection prints;
|
||||
PresetCollection sla_prints;
|
||||
|
|
|
@ -3042,6 +3042,12 @@ void TabSLAPrint::build()
|
|||
optgroup->append_single_option_line("pad_max_merge_distance");
|
||||
optgroup->append_single_option_line("pad_edge_radius");
|
||||
|
||||
page = add_options_page(_(L("Output options")), "page_white_go.png");
|
||||
optgroup = page->new_optgroup(_(L("Output file")));
|
||||
Option option = optgroup->get_option("output_filename_format");
|
||||
option.opt.full_width = true;
|
||||
optgroup->append_single_option_line(option);
|
||||
|
||||
page = add_options_page(_(L("Dependencies")), "wrench.png");
|
||||
optgroup = page->new_optgroup(_(L("Profile dependencies")));
|
||||
Line line = optgroup->create_single_option_line("compatible_printers");//Line { _(L("Compatible printers")), "" };
|
||||
|
@ -3050,7 +3056,7 @@ void TabSLAPrint::build()
|
|||
};
|
||||
optgroup->append_line(line, &m_colored_Label);
|
||||
|
||||
Option option = optgroup->get_option("compatible_printers_condition");
|
||||
option = optgroup->get_option("compatible_printers_condition");
|
||||
option.opt.full_width = true;
|
||||
optgroup->append_single_option_line(option);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue