mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-23 08:41:11 -06:00
Merge branch 'master' into wipe_tower_improvements
This commit is contained in:
commit
4583d62edd
126 changed files with 5240 additions and 607 deletions
|
@ -45,6 +45,10 @@ void AppConfig::set_defaults()
|
|||
// Version check is enabled by default in the config, but it is not implemented yet.
|
||||
if (get("version_check").empty())
|
||||
set("version_check", "1");
|
||||
// Use OpenGL 1.1 even if OpenGL 2.0 is available. This is mainly to support some buggy Intel HD Graphics drivers.
|
||||
// https://github.com/prusa3d/Slic3r/issues/233
|
||||
if (get("use_legacy_opengl").empty())
|
||||
set("use_legacy_opengl", "0");
|
||||
}
|
||||
|
||||
void AppConfig::load()
|
||||
|
|
|
@ -13,6 +13,14 @@
|
|||
#pragma comment(lib, "user32.lib")
|
||||
#endif
|
||||
|
||||
#include <wx/app.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/frame.h>
|
||||
#include <wx/menu.h>
|
||||
#include <wx/notebook.h>
|
||||
#include <wx/panel.h>
|
||||
#include <wx/sizer.h>
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
#if __APPLE__
|
||||
|
@ -134,4 +142,45 @@ void break_to_debugger()
|
|||
#endif /* _WIN32 */
|
||||
}
|
||||
|
||||
// Passing the wxWidgets GUI classes instantiated by the Perl part to C++.
|
||||
wxApp *g_wxApp = nullptr;
|
||||
wxFrame *g_wxMainFrame = nullptr;
|
||||
wxNotebook *g_wxTabPanel = nullptr;
|
||||
|
||||
void set_wxapp(wxApp *app)
|
||||
{
|
||||
g_wxApp = app;
|
||||
}
|
||||
|
||||
void set_main_frame(wxFrame *main_frame)
|
||||
{
|
||||
g_wxMainFrame = main_frame;
|
||||
}
|
||||
|
||||
void set_tab_panel(wxNotebook *tab_panel)
|
||||
{
|
||||
g_wxTabPanel = tab_panel;
|
||||
}
|
||||
|
||||
void add_debug_menu(wxMenuBar *menu)
|
||||
{
|
||||
#if 0
|
||||
auto debug_menu = new wxMenu();
|
||||
debug_menu->Append(wxWindow::NewControlId(1), "Some debug");
|
||||
menu->Append(debug_menu, _T("&Debug"));
|
||||
#endif
|
||||
}
|
||||
|
||||
void create_preset_tab(const char *name)
|
||||
{
|
||||
auto *panel = new wxPanel(g_wxTabPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL);
|
||||
// Vertical sizer to hold the choice menu and the rest of the page.
|
||||
auto *sizer = new wxBoxSizer(wxVERTICAL);
|
||||
sizer->SetSizeHints(panel);
|
||||
panel->SetSizer(sizer);
|
||||
auto *button = new wxButton(panel, wxID_ANY, "Hello World", wxDefaultPosition, wxDefaultSize, 0);
|
||||
sizer->Add(button, 0, 0, 0);
|
||||
g_wxTabPanel->AddPage(panel, name);
|
||||
}
|
||||
|
||||
} }
|
||||
|
|
|
@ -4,6 +4,11 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class wxApp;
|
||||
class wxFrame;
|
||||
class wxMenuBar;
|
||||
class wxNotebook;
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
void disable_screensaver();
|
||||
|
@ -12,6 +17,16 @@ std::vector<std::string> scan_serial_ports();
|
|||
bool debugged();
|
||||
void break_to_debugger();
|
||||
|
||||
// Passing the wxWidgets GUI classes instantiated by the Perl part to C++.
|
||||
void set_wxapp(wxApp *app);
|
||||
void set_main_frame(wxFrame *main_frame);
|
||||
void set_tab_panel(wxNotebook *tab_panel);
|
||||
|
||||
void add_debug_menu(wxMenuBar *menu);
|
||||
// Create a new preset tab (print, filament or printer),
|
||||
// add it at the end of the tab panel.
|
||||
void create_preset_tab(const char *name);
|
||||
|
||||
} }
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "../../libslic3r/libslic3r.h"
|
||||
#include "../../libslic3r/Utils.hpp"
|
||||
#include "../../libslic3r/PlaceholderParser.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
|
@ -79,7 +80,8 @@ void Preset::set_num_extruders(DynamicPrintConfig &config, unsigned int num_extr
|
|||
auto *opt = config.option(key, false);
|
||||
assert(opt != nullptr);
|
||||
assert(opt->is_vector());
|
||||
static_cast<ConfigOptionVectorBase*>(opt)->resize(num_extruders, defaults.option(key));
|
||||
if (opt != nullptr && opt->is_vector())
|
||||
static_cast<ConfigOptionVectorBase*>(opt)->resize(num_extruders, defaults.option(key));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,18 +142,37 @@ std::string Preset::label() const
|
|||
return this->name + (this->is_dirty ? g_suffix_modified : "");
|
||||
}
|
||||
|
||||
bool Preset::is_compatible_with_printer(const std::string &active_printer) const
|
||||
bool Preset::is_compatible_with_printer(const Preset &active_printer, const DynamicPrintConfig *extra_config) const
|
||||
{
|
||||
auto *compatible_printers = dynamic_cast<const ConfigOptionStrings*>(this->config.option("compatible_printers"));
|
||||
return this->is_default || active_printer.empty() ||
|
||||
compatible_printers == nullptr || compatible_printers->values.empty() ||
|
||||
std::find(compatible_printers->values.begin(), compatible_printers->values.end(), active_printer) !=
|
||||
auto *condition = dynamic_cast<const ConfigOptionString*>(this->config.option("compatible_printers_condition"));
|
||||
auto *compatible_printers = dynamic_cast<const ConfigOptionStrings*>(this->config.option("compatible_printers"));
|
||||
bool has_compatible_printers = compatible_printers != nullptr && ! compatible_printers->values.empty();
|
||||
if (! has_compatible_printers && condition != nullptr && ! condition->value.empty()) {
|
||||
try {
|
||||
return PlaceholderParser::evaluate_boolean_expression(condition->value, active_printer.config, extra_config);
|
||||
} catch (const std::runtime_error &err) {
|
||||
//FIXME in case of an error, return "compatible with everything".
|
||||
printf("Preset::is_compatible_with_printer - parsing error of compatible_printers_condition %s:\n%s\n", active_printer.name.c_str(), err.what());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return this->is_default || active_printer.name.empty() || ! has_compatible_printers ||
|
||||
std::find(compatible_printers->values.begin(), compatible_printers->values.end(), active_printer.name) !=
|
||||
compatible_printers->values.end();
|
||||
}
|
||||
|
||||
bool Preset::update_compatible_with_printer(const std::string &active_printer)
|
||||
bool Preset::is_compatible_with_printer(const Preset &active_printer) const
|
||||
{
|
||||
return this->is_compatible = is_compatible_with_printer(active_printer);
|
||||
DynamicPrintConfig config;
|
||||
config.set_key_value("printer_preset", new ConfigOptionString(active_printer.name));
|
||||
config.set_key_value("num_extruders", new ConfigOptionInt(
|
||||
(int)static_cast<const ConfigOptionFloats*>(active_printer.config.option("nozzle_diameter"))->values.size()));
|
||||
return this->is_compatible_with_printer(active_printer, &config);
|
||||
}
|
||||
|
||||
bool Preset::update_compatible_with_printer(const Preset &active_printer, const DynamicPrintConfig *extra_config)
|
||||
{
|
||||
return this->is_compatible = is_compatible_with_printer(active_printer, extra_config);
|
||||
}
|
||||
|
||||
const std::vector<std::string>& Preset::print_options()
|
||||
|
@ -179,7 +200,8 @@ const std::vector<std::string>& Preset::print_options()
|
|||
"top_infill_extrusion_width", "support_material_extrusion_width", "infill_overlap", "bridge_flow_ratio", "clip_multipart_objects",
|
||||
"elefant_foot_compensation", "xy_size_compensation", "threads", "resolution", "wipe_tower", "wipe_tower_x", "wipe_tower_y",
|
||||
"wipe_tower_width", "wipe_tower_per_color_wipe", "wipe_tower_rotation_angle",
|
||||
"compatible_printers"
|
||||
"compatible_printers", "compatible_printers_condition"
|
||||
|
||||
};
|
||||
return s_opts;
|
||||
}
|
||||
|
@ -192,7 +214,7 @@ const std::vector<std::string>& Preset::filament_options()
|
|||
"first_layer_bed_temperature", "fan_always_on", "cooling", "min_fan_speed", "max_fan_speed", "bridge_fan_speed",
|
||||
"disable_fan_first_layers", "fan_below_layer_time", "slowdown_below_layer_time", "min_print_speed", "start_filament_gcode",
|
||||
"end_filament_gcode",
|
||||
"compatible_printers"
|
||||
"compatible_printers", "compatible_printers_condition"
|
||||
};
|
||||
return s_opts;
|
||||
}
|
||||
|
@ -242,6 +264,21 @@ PresetCollection::~PresetCollection()
|
|||
m_bitmap_main_frame = nullptr;
|
||||
}
|
||||
|
||||
void PresetCollection::reset(bool delete_files)
|
||||
{
|
||||
if (m_presets.size() > 1) {
|
||||
if (delete_files) {
|
||||
// Erase the preset files.
|
||||
for (Preset &preset : m_presets)
|
||||
if (! preset.is_default && ! preset.is_external)
|
||||
boost::nowide::remove(preset.file.c_str());
|
||||
}
|
||||
// Don't use m_presets.resize() here as it requires a default constructor for Preset.
|
||||
m_presets.erase(m_presets.begin() + 1, m_presets.end());
|
||||
this->select_preset(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Load all presets found in dir_path.
|
||||
// Throws an exception on error.
|
||||
void PresetCollection::load_presets(const std::string &dir_path, const std::string &subdir)
|
||||
|
@ -283,10 +320,11 @@ Preset& PresetCollection::load_preset(const std::string &path, const std::string
|
|||
|
||||
Preset& PresetCollection::load_preset(const std::string &path, const std::string &name, DynamicPrintConfig &&config, bool select)
|
||||
{
|
||||
Preset key(m_type, name);
|
||||
auto it = std::lower_bound(m_presets.begin(), m_presets.end(), key);
|
||||
if (it == m_presets.end() || it->name != name)
|
||||
auto it = this->find_preset_internal(name);
|
||||
if (it == m_presets.end() || it->name != name) {
|
||||
// The preset was not found. Create a new preset.
|
||||
it = m_presets.emplace(it, Preset(m_type, name, false));
|
||||
}
|
||||
Preset &preset = *it;
|
||||
preset.file = path;
|
||||
preset.config = std::move(config);
|
||||
|
@ -301,9 +339,8 @@ void PresetCollection::save_current_preset(const std::string &new_name)
|
|||
{
|
||||
// 1) Find the preset with a new_name or create a new one,
|
||||
// initialize it with the edited config.
|
||||
Preset key(m_type, new_name, false);
|
||||
auto it = std::lower_bound(m_presets.begin(), m_presets.end(), key);
|
||||
if (it != m_presets.end() && it->name == key.name) {
|
||||
auto it = this->find_preset_internal(new_name);
|
||||
if (it != m_presets.end() && it->name == new_name) {
|
||||
// Preset with the same name found.
|
||||
Preset &preset = *it;
|
||||
if (preset.is_default)
|
||||
|
@ -314,11 +351,8 @@ void PresetCollection::save_current_preset(const std::string &new_name)
|
|||
} else {
|
||||
// Creating a new preset.
|
||||
Preset &preset = *m_presets.insert(it, m_edited_preset);
|
||||
std::string file_name = new_name;
|
||||
if (! boost::iends_with(file_name, ".ini"))
|
||||
file_name += ".ini";
|
||||
preset.name = new_name;
|
||||
preset.file = (boost::filesystem::path(m_dir_path) / file_name).make_preferred().string();
|
||||
preset.file = this->path_from_name(new_name);
|
||||
}
|
||||
// 2) Activate the saved preset.
|
||||
this->select_preset_by_name(new_name, true);
|
||||
|
@ -356,7 +390,7 @@ bool PresetCollection::load_bitmap_default(const std::string &file_name)
|
|||
Preset* PresetCollection::find_preset(const std::string &name, bool first_visible_if_not_found)
|
||||
{
|
||||
Preset key(m_type, name, false);
|
||||
auto it = std::lower_bound(m_presets.begin(), m_presets.end(), key);
|
||||
auto it = this->find_preset_internal(name);
|
||||
// Ensure that a temporary copy is returned if the preset found is currently selected.
|
||||
return (it != m_presets.end() && it->name == key.name) ? &this->preset(it - m_presets.begin()) :
|
||||
first_visible_if_not_found ? &this->first_visible() : nullptr;
|
||||
|
@ -394,31 +428,25 @@ void PresetCollection::set_default_suppressed(bool default_suppressed)
|
|||
}
|
||||
}
|
||||
|
||||
void PresetCollection::update_compatible_with_printer(const std::string &active_printer, bool select_other_if_incompatible)
|
||||
void PresetCollection::update_compatible_with_printer(const Preset &active_printer, bool select_other_if_incompatible)
|
||||
{
|
||||
size_t num_visible = 0;
|
||||
DynamicPrintConfig config;
|
||||
config.set_key_value("printer_preset", new ConfigOptionString(active_printer.name));
|
||||
config.set_key_value("num_extruders", new ConfigOptionInt(
|
||||
(int)static_cast<const ConfigOptionFloats*>(active_printer.config.option("nozzle_diameter"))->values.size()));
|
||||
for (size_t idx_preset = 1; idx_preset < m_presets.size(); ++ idx_preset) {
|
||||
bool selected = idx_preset == m_idx_selected;
|
||||
Preset &preset_selected = m_presets[idx_preset];
|
||||
Preset &preset_edited = selected ? m_edited_preset : preset_selected;
|
||||
if (preset_edited.update_compatible_with_printer(active_printer))
|
||||
// Mark compatible presets as visible.
|
||||
preset_selected.is_visible = true;
|
||||
else if (selected && select_other_if_incompatible) {
|
||||
preset_selected.is_visible = false;
|
||||
if (! preset_edited.update_compatible_with_printer(active_printer, &config) &&
|
||||
selected && select_other_if_incompatible)
|
||||
m_idx_selected = (size_t)-1;
|
||||
}
|
||||
if (selected)
|
||||
preset_selected.is_compatible = preset_edited.is_compatible;
|
||||
if (preset_selected.is_visible)
|
||||
++ num_visible;
|
||||
}
|
||||
if (m_idx_selected == (size_t)-1)
|
||||
// Find some other visible preset.
|
||||
this->select_preset(first_visible_idx());
|
||||
else if (num_visible == 0)
|
||||
// Show the "-- default --" preset.
|
||||
m_presets.front().is_visible = true;
|
||||
// Find some other compatible preset, or the "-- default --" preset.
|
||||
this->select_preset(first_compatible_idx());
|
||||
}
|
||||
|
||||
// Save the preset under a new name. If the name is different from the old one,
|
||||
|
@ -459,7 +487,7 @@ void PresetCollection::update_tab_ui(wxBitmapComboBox *ui, bool show_incompatibl
|
|||
ui->Clear();
|
||||
for (size_t i = this->m_presets.front().is_visible ? 0 : 1; i < this->m_presets.size(); ++ i) {
|
||||
const Preset &preset = this->m_presets[i];
|
||||
if (! show_incompatible && ! preset.is_compatible && i != m_idx_selected)
|
||||
if (! preset.is_visible || (! show_incompatible && ! preset.is_compatible && i != m_idx_selected))
|
||||
continue;
|
||||
const wxBitmap *bmp = preset.is_compatible ? m_bitmap_compatible : m_bitmap_incompatible;
|
||||
ui->Append(wxString::FromUTF8((preset.name + (preset.is_dirty ? g_suffix_modified : "")).c_str()),
|
||||
|
@ -486,13 +514,36 @@ bool PresetCollection::update_dirty_ui(wxBitmapComboBox *ui)
|
|||
std::string preset_name = Preset::remove_suffix_modified(old_label);
|
||||
const Preset *preset = this->find_preset(preset_name, false);
|
||||
assert(preset != nullptr);
|
||||
std::string new_label = preset->is_dirty ? preset->name + g_suffix_modified : preset->name;
|
||||
if (old_label != new_label)
|
||||
ui->SetString(ui_id, wxString::FromUTF8(new_label.c_str()));
|
||||
if (preset != nullptr) {
|
||||
std::string new_label = preset->is_dirty ? preset->name + g_suffix_modified : preset->name;
|
||||
if (old_label != new_label)
|
||||
ui->SetString(ui_id, wxString::FromUTF8(new_label.c_str()));
|
||||
}
|
||||
}
|
||||
#ifdef __APPLE__
|
||||
// wxWidgets on OSX do not upload the text of the combo box line automatically.
|
||||
// Force it to update by re-selecting.
|
||||
ui->SetSelection(ui->GetSelection());
|
||||
#endif /* __APPLE __ */
|
||||
return was_dirty != is_dirty;
|
||||
}
|
||||
|
||||
std::vector<std::string> PresetCollection::current_dirty_options() const
|
||||
{
|
||||
std::vector<std::string> changed = this->get_selected_preset().config.diff(this->get_edited_preset().config);
|
||||
// The "compatible_printers" option key is handled differently from the others:
|
||||
// It is not mandatory. If the key is missing, it means it is compatible with any printer.
|
||||
// If the key exists and it is empty, it means it is compatible with no printer.
|
||||
std::initializer_list<const char*> optional_keys { "compatible_printers", "compatible_printers_condition" };
|
||||
for (auto &opt_key : optional_keys) {
|
||||
if (this->get_selected_preset().config.has(opt_key) != this->get_edited_preset().config.has(opt_key))
|
||||
changed.emplace_back(opt_key);
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
// Select a new preset. This resets all the edits done to the currently selected preset.
|
||||
// If the preset with index idx does not exist, a first visible preset is selected.
|
||||
Preset& PresetCollection::select_preset(size_t idx)
|
||||
{
|
||||
for (Preset &preset : m_presets)
|
||||
|
@ -509,10 +560,9 @@ bool PresetCollection::select_preset_by_name(const std::string &name_w_suffix, b
|
|||
{
|
||||
std::string name = Preset::remove_suffix_modified(name_w_suffix);
|
||||
// 1) Try to find the preset by its name.
|
||||
Preset key(m_type, name, false);
|
||||
auto it = std::lower_bound(m_presets.begin(), m_presets.end(), key);
|
||||
auto it = this->find_preset_internal(name);
|
||||
size_t idx = 0;
|
||||
if (it != m_presets.end() && it->name == key.name)
|
||||
if (it != m_presets.end() && it->name == name)
|
||||
// Preset found by its name.
|
||||
idx = it - m_presets.begin();
|
||||
else {
|
||||
|
@ -544,4 +594,11 @@ std::string PresetCollection::name() const
|
|||
}
|
||||
}
|
||||
|
||||
// Generate a file path from a profile name. Add the ".ini" suffix if it is missing.
|
||||
std::string PresetCollection::path_from_name(const std::string &new_name) const
|
||||
{
|
||||
std::string file_name = boost::iends_with(new_name, ".ini") ? new_name : (new_name + ".ini");
|
||||
return (boost::filesystem::path(m_dir_path) / file_name).make_preferred().string();
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
|
|
|
@ -79,9 +79,11 @@ public:
|
|||
void set_dirty(bool dirty = true) { this->is_dirty = dirty; }
|
||||
void reset_dirty() { this->is_dirty = false; }
|
||||
|
||||
bool is_compatible_with_printer(const std::string &active_printer) const;
|
||||
bool is_compatible_with_printer(const Preset &active_printer, const DynamicPrintConfig *extra_config) const;
|
||||
bool is_compatible_with_printer(const Preset &active_printer) const;
|
||||
|
||||
// Mark this preset as compatible if it is compatible with active_printer.
|
||||
bool update_compatible_with_printer(const std::string &active_printer);
|
||||
bool update_compatible_with_printer(const Preset &active_printer, const DynamicPrintConfig *extra_config);
|
||||
|
||||
// Resize the extruder specific fields, initialize them with the content of the 1st extruder.
|
||||
void set_num_extruders(unsigned int n) { set_num_extruders(this->config, n); }
|
||||
|
@ -114,6 +116,8 @@ public:
|
|||
PresetCollection(Preset::Type type, const std::vector<std::string> &keys);
|
||||
~PresetCollection();
|
||||
|
||||
void reset(bool delete_files);
|
||||
|
||||
Preset::Type type() const { return m_type; }
|
||||
std::string name() const;
|
||||
const std::deque<Preset>& operator()() const { return m_presets; }
|
||||
|
@ -159,7 +163,7 @@ public:
|
|||
// Return a preset by an index. If the preset is active, a temporary copy is returned.
|
||||
Preset& preset(size_t idx) { return (int(idx) == m_idx_selected) ? m_edited_preset : m_presets[idx]; }
|
||||
const Preset& preset(size_t idx) const { return const_cast<PresetCollection*>(this)->preset(idx); }
|
||||
void discard_current_changes() { m_edited_preset = m_presets[m_idx_selected]; }
|
||||
void discard_current_changes() { m_presets[m_idx_selected].reset_dirty(); m_edited_preset = m_presets[m_idx_selected]; }
|
||||
|
||||
// Return a preset by its name. If the preset is active, a temporary copy is returned.
|
||||
// If a preset is not found by its name, null is returned.
|
||||
|
@ -180,14 +184,14 @@ public:
|
|||
size_t size() const { return this->m_presets.size(); }
|
||||
|
||||
// For Print / Filament presets, disable those, which are not compatible with the printer.
|
||||
void update_compatible_with_printer(const std::string &active_printer, bool select_other_if_incompatible);
|
||||
void update_compatible_with_printer(const Preset &active_printer, bool select_other_if_incompatible);
|
||||
|
||||
size_t num_visible() const { return std::count_if(m_presets.begin(), m_presets.end(), [](const Preset &preset){return preset.is_visible;}); }
|
||||
|
||||
// Compare the content of get_selected_preset() with get_edited_preset() configs, return true if they differ.
|
||||
bool current_is_dirty() { return ! this->current_dirty_options().empty(); }
|
||||
bool current_is_dirty() const { return ! this->current_dirty_options().empty(); }
|
||||
// Compare the content of get_selected_preset() with get_edited_preset() configs, return the list of keys where they differ.
|
||||
std::vector<std::string> current_dirty_options() { return this->get_selected_preset().config.diff(this->get_edited_preset().config); }
|
||||
std::vector<std::string> current_dirty_options() const;
|
||||
|
||||
// Update the choice UI from the list of presets.
|
||||
// If show_incompatible, all presets are shown, otherwise only the compatible presets are shown.
|
||||
|
@ -207,11 +211,26 @@ public:
|
|||
// With force, the changes are reverted if the new index is the same as the old index.
|
||||
bool select_preset_by_name(const std::string &name, bool force);
|
||||
|
||||
// Generate a file path from a profile name. Add the ".ini" suffix if it is missing.
|
||||
std::string path_from_name(const std::string &new_name) const;
|
||||
|
||||
private:
|
||||
PresetCollection();
|
||||
PresetCollection(const PresetCollection &other);
|
||||
PresetCollection& operator=(const PresetCollection &other);
|
||||
|
||||
// Find a preset in the sorted list of presets.
|
||||
// The "-- default -- " preset is always the first, so it needs
|
||||
// to be handled differently.
|
||||
std::deque<Preset>::iterator find_preset_internal(const std::string &name)
|
||||
{
|
||||
Preset key(m_type, name);
|
||||
auto it = std::lower_bound(m_presets.begin() + 1, m_presets.end(), key);
|
||||
return (it == m_presets.end() && m_presets.front().name == name) ? m_presets.begin() : it;
|
||||
}
|
||||
std::deque<Preset>::const_iterator find_preset_internal(const std::string &name) const
|
||||
{ return const_cast<PresetCollection*>(this)->find_preset_internal(name); }
|
||||
|
||||
// Type of this PresetCollection: TYPE_PRINT, TYPE_FILAMENT or TYPE_PRINTER.
|
||||
Preset::Type m_type;
|
||||
// List of presets, starting with the "- default -" preset.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//#undef NDEBUGc
|
||||
//#undef NDEBUG
|
||||
#include <cassert>
|
||||
|
||||
#include "PresetBundle.hpp"
|
||||
|
@ -25,6 +25,10 @@
|
|||
#include "../../libslic3r/PlaceholderParser.hpp"
|
||||
#include "../../libslic3r/Utils.hpp"
|
||||
|
||||
// Store the print/filament/printer presets into a "presets" subdirectory of the Slic3rPE config dir.
|
||||
// This breaks compatibility with the upstream Slic3r if the --datadir is used to switch between the two versions.
|
||||
// #define SLIC3R_PROFILE_USE_PRESETS_SUBDIR
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
PresetBundle::PresetBundle() :
|
||||
|
@ -34,7 +38,8 @@ PresetBundle::PresetBundle() :
|
|||
m_bitmapCompatible(new wxBitmap),
|
||||
m_bitmapIncompatible(new wxBitmap)
|
||||
{
|
||||
::wxInitAllImageHandlers();
|
||||
if (wxImage::FindHandler(wxBITMAP_TYPE_PNG) == nullptr)
|
||||
wxImage::AddHandler(new wxPNGHandler);
|
||||
|
||||
// Create the ID config keys, as they are not part of the Static print config classes.
|
||||
this->prints.preset(0).config.opt_string("print_settings_id", true);
|
||||
|
@ -42,7 +47,9 @@ PresetBundle::PresetBundle() :
|
|||
this->printers.preset(0).config.opt_string("print_settings_id", true);
|
||||
// Create the "compatible printers" keys, as they are not part of the Static print config classes.
|
||||
this->filaments.preset(0).config.optptr("compatible_printers", true);
|
||||
this->filaments.preset(0).config.optptr("compatible_printers_condition", true);
|
||||
this->prints.preset(0).config.optptr("compatible_printers", true);
|
||||
this->prints.preset(0).config.optptr("compatible_printers_condition", true);
|
||||
|
||||
this->prints .load_bitmap_default("cog.png");
|
||||
this->filaments.load_bitmap_default("spool.png");
|
||||
|
@ -62,23 +69,54 @@ PresetBundle::~PresetBundle()
|
|||
delete bitmap.second;
|
||||
}
|
||||
|
||||
void PresetBundle::reset(bool delete_files)
|
||||
{
|
||||
// Clear the existing presets, delete their respective files.
|
||||
this->prints .reset(delete_files);
|
||||
this->filaments.reset(delete_files);
|
||||
this->printers .reset(delete_files);
|
||||
this->filament_presets.clear();
|
||||
this->filament_presets.emplace_back(this->filaments.get_selected_preset().name);
|
||||
}
|
||||
|
||||
void PresetBundle::setup_directories()
|
||||
{
|
||||
boost::filesystem::path dir = boost::filesystem::canonical(Slic3r::data_dir());
|
||||
if (! boost::filesystem::is_directory(dir))
|
||||
throw std::runtime_error(std::string("datadir does not exist: ") + Slic3r::data_dir());
|
||||
std::initializer_list<const char*> names = { "print", "filament", "printer" };
|
||||
for (const char *name : names) {
|
||||
boost::filesystem::path subdir = (dir / name).make_preferred();
|
||||
boost::filesystem::path data_dir = boost::filesystem::path(Slic3r::data_dir());
|
||||
std::initializer_list<boost::filesystem::path> paths = {
|
||||
data_dir,
|
||||
#ifdef SLIC3R_PROFILE_USE_PRESETS_SUBDIR
|
||||
// Store the print/filament/printer presets into a "presets" directory.
|
||||
data_dir / "presets",
|
||||
data_dir / "presets" / "print",
|
||||
data_dir / "presets" / "filament",
|
||||
data_dir / "presets" / "printer"
|
||||
#else
|
||||
// Store the print/filament/printer presets at the same location as the upstream Slic3r.
|
||||
data_dir / "print",
|
||||
data_dir / "filament",
|
||||
data_dir / "printer"
|
||||
#endif
|
||||
};
|
||||
for (const boost::filesystem::path &path : paths) {
|
||||
boost::filesystem::path subdir = path;
|
||||
subdir.make_preferred();
|
||||
if (! boost::filesystem::is_directory(subdir) &&
|
||||
! boost::filesystem::create_directory(subdir))
|
||||
throw std::runtime_error(std::string("Slic3r was unable to create its data directory at ") + subdir.string());
|
||||
}
|
||||
}
|
||||
|
||||
void PresetBundle::load_presets(const std::string &dir_path)
|
||||
void PresetBundle::load_presets()
|
||||
{
|
||||
std::string errors_cummulative;
|
||||
const std::string dir_path = data_dir()
|
||||
#ifdef SLIC3R_PROFILE_USE_PRESETS_SUBDIR
|
||||
// Store the print/filament/printer presets into a "presets" directory.
|
||||
+ "/presets"
|
||||
#else
|
||||
// Store the print/filament/printer presets at the same location as the upstream Slic3r.
|
||||
#endif
|
||||
;
|
||||
try {
|
||||
this->prints.load_presets(dir_path, "print");
|
||||
} catch (const std::runtime_error &err) {
|
||||
|
@ -95,6 +133,7 @@ void PresetBundle::load_presets(const std::string &dir_path)
|
|||
errors_cummulative += err.what();
|
||||
}
|
||||
this->update_multi_material_filament_presets();
|
||||
this->update_compatible_with_printer(false);
|
||||
if (! errors_cummulative.empty())
|
||||
throw std::runtime_error(errors_cummulative);
|
||||
}
|
||||
|
@ -125,8 +164,10 @@ void PresetBundle::load_selections(const AppConfig &config)
|
|||
this->set_filament_preset(i, remove_ini_suffix(config.get("presets", name)));
|
||||
}
|
||||
// Update visibility of presets based on their compatibility with the active printer.
|
||||
// This will switch the print or filament presets to compatible if the active presets are incompatible.
|
||||
this->update_compatible_with_printer(false);
|
||||
// Always try to select a compatible print and filament preset to the current printer preset,
|
||||
// as the application may have been closed with an active "external" preset, which does not
|
||||
// exist.
|
||||
this->update_compatible_with_printer(true);
|
||||
}
|
||||
|
||||
// Export selections (current print, current filaments, current printer) into config.ini
|
||||
|
@ -216,6 +257,8 @@ DynamicPrintConfig PresetBundle::full_config() const
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
out.erase("compatible_printers");
|
||||
|
||||
static const char *keys[] = { "perimeter", "infill", "solid_infill", "support_material", "support_material_interface" };
|
||||
for (size_t i = 0; i < sizeof(keys) / sizeof(keys[0]); ++ i) {
|
||||
|
@ -239,7 +282,7 @@ void PresetBundle::load_config_file(const std::string &path)
|
|||
config.apply(FullPrintConfig::defaults());
|
||||
config.load_from_gcode(path);
|
||||
Preset::normalize(config);
|
||||
load_config_file_config(path, std::move(config));
|
||||
load_config_file_config(path, true, std::move(config));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -268,7 +311,7 @@ void PresetBundle::load_config_file(const std::string &path)
|
|||
config.apply(FullPrintConfig::defaults());
|
||||
config.load(tree);
|
||||
Preset::normalize(config);
|
||||
load_config_file_config(path, std::move(config));
|
||||
load_config_file_config(path, true, std::move(config));
|
||||
break;
|
||||
}
|
||||
case CONFIG_FILE_TYPE_CONFIG_BUNDLE:
|
||||
|
@ -278,17 +321,32 @@ void PresetBundle::load_config_file(const std::string &path)
|
|||
}
|
||||
|
||||
// Load a config file from a boost property_tree. This is a private method called from load_config_file.
|
||||
void PresetBundle::load_config_file_config(const std::string &path, const DynamicPrintConfig &config)
|
||||
void PresetBundle::load_config_file_config(const std::string &name_or_path, bool is_external, DynamicPrintConfig &&config)
|
||||
{
|
||||
// The "compatible_printers" field should not have been exported into a config.ini or a G-code anyway,
|
||||
// but some of the alpha versions of Slic3r did.
|
||||
{
|
||||
ConfigOption *opt_compatible = config.optptr("compatible_printers");
|
||||
if (opt_compatible != nullptr) {
|
||||
assert(opt_compatible->type() == coStrings);
|
||||
if (opt_compatible->type() == coStrings)
|
||||
static_cast<ConfigOptionStrings*>(opt_compatible)->values.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// 1) Create a name from the file name.
|
||||
// Keep the suffix (.ini, .gcode, .amf, .3mf etc) to differentiate it from the normal profiles.
|
||||
std::string name = boost::filesystem::path(path).filename().string();
|
||||
std::string name = is_external ? boost::filesystem::path(name_or_path).filename().string() : name_or_path;
|
||||
|
||||
// 2) If the loading succeeded, split and load the config into print / filament / printer settings.
|
||||
// First load the print and printer presets.
|
||||
for (size_t i_group = 0; i_group < 2; ++ i_group) {
|
||||
PresetCollection &presets = (i_group == 0) ? this->prints : this->printers;
|
||||
presets.load_preset(path, name, config).is_external = true;
|
||||
Preset &preset = presets.load_preset(is_external ? name_or_path : presets.path_from_name(name), name, config);
|
||||
if (is_external)
|
||||
preset.is_external = true;
|
||||
else
|
||||
preset.save();
|
||||
}
|
||||
|
||||
// 3) Now load the filaments. If there are multiple filament presets, split them and load them.
|
||||
|
@ -296,7 +354,12 @@ void PresetBundle::load_config_file_config(const std::string &path, const Dynami
|
|||
auto *filament_diameter = dynamic_cast<const ConfigOptionFloats*>(config.option("filament_diameter"));
|
||||
size_t num_extruders = std::min(nozzle_diameter->values.size(), filament_diameter->values.size());
|
||||
if (num_extruders <= 1) {
|
||||
this->filaments.load_preset(path, name, config).is_external = true;
|
||||
Preset &preset = this->filaments.load_preset(
|
||||
is_external ? name_or_path : this->filaments.path_from_name(name), name, config);
|
||||
if (is_external)
|
||||
preset.is_external = true;
|
||||
else
|
||||
preset.save();
|
||||
this->filament_presets.clear();
|
||||
this->filament_presets.emplace_back(name);
|
||||
} else {
|
||||
|
@ -310,7 +373,7 @@ void PresetBundle::load_config_file_config(const std::string &path, const Dynami
|
|||
if (other_opt->is_scalar()) {
|
||||
for (size_t i = 0; i < configs.size(); ++ i)
|
||||
configs[i].option(key, false)->set(other_opt);
|
||||
} else {
|
||||
} else if (key != "compatible_printers") {
|
||||
for (size_t i = 0; i < configs.size(); ++ i)
|
||||
static_cast<ConfigOptionVectorBase*>(configs[i].option(key, false))->set_at(other_opt, 0, i);
|
||||
}
|
||||
|
@ -323,11 +386,20 @@ void PresetBundle::load_config_file_config(const std::string &path, const Dynami
|
|||
suffix[0] = 0;
|
||||
else
|
||||
sprintf(suffix, " (%d)", i);
|
||||
std::string new_name = name + suffix;
|
||||
// Load all filament presets, but only select the first one in the preset dialog.
|
||||
this->filaments.load_preset(path, name + suffix, std::move(configs[i]), i == 0).is_external = true;
|
||||
this->filament_presets.emplace_back(name + suffix);
|
||||
Preset &preset = this->filaments.load_preset(
|
||||
is_external ? name_or_path : this->filaments.path_from_name(new_name),
|
||||
new_name, std::move(configs[i]), i == 0);
|
||||
if (is_external)
|
||||
preset.is_external = true;
|
||||
else
|
||||
preset.save();
|
||||
this->filament_presets.emplace_back(new_name);
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
|
@ -335,7 +407,8 @@ void PresetBundle::load_config_file_config_bundle(const std::string &path, const
|
|||
{
|
||||
// 1) Load the config bundle into a temp data.
|
||||
PresetBundle tmp_bundle;
|
||||
tmp_bundle.load_configbundle(path);
|
||||
// Load the config bundle, don't save the loaded presets to user profile directory.
|
||||
tmp_bundle.load_configbundle(path, 0);
|
||||
std::string bundle_name = std::string(" - ") + boost::filesystem::path(path).filename().string();
|
||||
|
||||
// 2) Extract active configs from the config bundle, copy them and activate them in this bundle.
|
||||
|
@ -368,6 +441,14 @@ void PresetBundle::load_config_file_config_bundle(const std::string &path, const
|
|||
}
|
||||
assert(! preset_name_dst.empty());
|
||||
// Save preset_src->config into collection_dst under preset_name_dst.
|
||||
// The "compatible_printers" field should not have been exported into a config.ini or a G-code anyway,
|
||||
// but some of the alpha versions of Slic3r did.
|
||||
ConfigOption *opt_compatible = preset_src->config.optptr("compatible_printers");
|
||||
if (opt_compatible != nullptr) {
|
||||
assert(opt_compatible->type() == coStrings);
|
||||
if (opt_compatible->type() == coStrings)
|
||||
static_cast<ConfigOptionStrings*>(opt_compatible)->values.clear();
|
||||
}
|
||||
collection_dst.load_preset(path, preset_name_dst, std::move(preset_src->config), activate).is_external = true;
|
||||
return preset_name_dst;
|
||||
};
|
||||
|
@ -377,12 +458,17 @@ void PresetBundle::load_config_file_config_bundle(const std::string &path, const
|
|||
this->update_multi_material_filament_presets();
|
||||
for (size_t i = 1; i < std::min(tmp_bundle.filament_presets.size(), this->filament_presets.size()); ++ i)
|
||||
this->filament_presets[i] = load_one(this->filaments, tmp_bundle.filaments, tmp_bundle.filament_presets[i], false);
|
||||
|
||||
this->update_compatible_with_printer(false);
|
||||
}
|
||||
|
||||
// Load a config bundle file, into presets and store the loaded presets into separate files
|
||||
// of the local configuration directory.
|
||||
size_t PresetBundle::load_configbundle(const std::string &path)
|
||||
size_t PresetBundle::load_configbundle(const std::string &path, unsigned int flags)
|
||||
{
|
||||
if (flags & LOAD_CFGBNDLE_RESET_USER_PROFILE)
|
||||
this->reset(flags & LOAD_CFGBNDLE_SAVE);
|
||||
|
||||
// 1) Read the complete config file into a boost::property_tree.
|
||||
namespace pt = boost::property_tree;
|
||||
pt::ptree tree;
|
||||
|
@ -444,8 +530,20 @@ size_t PresetBundle::load_configbundle(const std::string &path)
|
|||
for (auto &kvp : section.second)
|
||||
config.set_deserialize(kvp.first, kvp.second.data());
|
||||
Preset::normalize(config);
|
||||
// Decide a full path to this .ini file.
|
||||
auto file_name = boost::algorithm::iends_with(preset_name, ".ini") ? preset_name : preset_name + ".ini";
|
||||
auto file_path = (boost::filesystem::path(data_dir())
|
||||
#ifdef SLIC3R_PROFILE_USE_PRESETS_SUBDIR
|
||||
// Store the print/filament/printer presets into a "presets" directory.
|
||||
/ "presets"
|
||||
#else
|
||||
// Store the print/filament/printer presets at the same location as the upstream Slic3r.
|
||||
#endif
|
||||
/ presets->name() / file_name).make_preferred();
|
||||
// Load the preset into the list of presets, save it to disk.
|
||||
presets->load_preset(Slic3r::config_path(presets->name(), preset_name), preset_name, std::move(config), false).save();
|
||||
Preset &loaded = presets->load_preset(file_path.string(), preset_name, std::move(config), false);
|
||||
if (flags & LOAD_CFGBNDLE_SAVE)
|
||||
loaded.save();
|
||||
++ presets_loaded;
|
||||
}
|
||||
}
|
||||
|
@ -462,6 +560,8 @@ size_t PresetBundle::load_configbundle(const std::string &path)
|
|||
this->update_multi_material_filament_presets();
|
||||
for (size_t i = 0; i < std::min(this->filament_presets.size(), active_filaments.size()); ++ i)
|
||||
this->filament_presets[i] = filaments.find_preset(active_filaments[i], true)->name;
|
||||
|
||||
this->update_compatible_with_printer(false);
|
||||
return presets_loaded;
|
||||
}
|
||||
|
||||
|
@ -480,8 +580,8 @@ void PresetBundle::update_multi_material_filament_presets()
|
|||
|
||||
void PresetBundle::update_compatible_with_printer(bool select_other_if_incompatible)
|
||||
{
|
||||
this->prints.update_compatible_with_printer(this->printers.get_selected_preset().name, select_other_if_incompatible);
|
||||
this->filaments.update_compatible_with_printer(this->printers.get_selected_preset().name, select_other_if_incompatible);
|
||||
this->prints.update_compatible_with_printer(this->printers.get_edited_preset(), select_other_if_incompatible);
|
||||
this->filaments.update_compatible_with_printer(this->printers.get_edited_preset(), select_other_if_incompatible);
|
||||
if (select_other_if_incompatible) {
|
||||
// Verify validity of the current filament presets.
|
||||
for (std::string &filament_name : this->filament_presets) {
|
||||
|
@ -557,9 +657,9 @@ static inline int hex_digit_to_int(const char c)
|
|||
static inline bool parse_color(const std::string &scolor, unsigned char *rgb_out)
|
||||
{
|
||||
rgb_out[0] = rgb_out[1] = rgb_out[2] = 0;
|
||||
const char *c = scolor.data() + 1;
|
||||
if (scolor.size() != 7 || scolor.front() != '#')
|
||||
return false;
|
||||
const char *c = scolor.data() + 1;
|
||||
for (size_t i = 0; i < 3; ++ i) {
|
||||
int digit1 = hex_digit_to_int(*c ++);
|
||||
int digit2 = hex_digit_to_int(*c ++);
|
||||
|
|
|
@ -15,10 +15,14 @@ public:
|
|||
PresetBundle();
|
||||
~PresetBundle();
|
||||
|
||||
// Remove all the presets but the "-- default --".
|
||||
// Optionally remove all the files referenced by the presets from the user profile directory.
|
||||
void reset(bool delete_files);
|
||||
|
||||
void setup_directories();
|
||||
|
||||
// Load ini files of all types (print, filament, printer) from the provided directory path.
|
||||
void load_presets(const std::string &dir_path);
|
||||
// Load ini files of all types (print, filament, printer) from Slic3r::data_dir() / presets.
|
||||
void load_presets();
|
||||
|
||||
// Load selections (current print, current filaments, current printer) from config.ini
|
||||
// This is done just once on application start up.
|
||||
|
@ -40,6 +44,11 @@ public:
|
|||
|
||||
DynamicPrintConfig full_config() const;
|
||||
|
||||
// Load user configuration and store it into the user profiles.
|
||||
// This method is called by the configuration wizard.
|
||||
void load_config(const std::string &name, DynamicPrintConfig config)
|
||||
{ this->load_config_file_config(name, false, std::move(config)); }
|
||||
|
||||
// Load an external config file containing the print, filament and printer presets.
|
||||
// Instead of a config file, a G-code may be loaded containing the full set of parameters.
|
||||
// In the future the configuration will likely be read from an AMF file as well.
|
||||
|
@ -51,7 +60,14 @@ public:
|
|||
// Load settings into the provided settings instance.
|
||||
// Activate the presets stored in the config bundle.
|
||||
// Returns the number of presets loaded successfully.
|
||||
size_t load_configbundle(const std::string &path);
|
||||
enum {
|
||||
// Save the profiles, which have been loaded.
|
||||
LOAD_CFGBNDLE_SAVE = 1,
|
||||
// Delete all old config profiles before loading.
|
||||
LOAD_CFGBNDLE_RESET_USER_PROFILE = 2
|
||||
};
|
||||
// Load the config bundle, store it to the user profile directory by default.
|
||||
size_t load_configbundle(const std::string &path, unsigned int flags = LOAD_CFGBNDLE_SAVE);
|
||||
|
||||
// Export a config bundle file containing all the presets and the names of the active presets.
|
||||
void export_configbundle(const std::string &path); // , const DynamicPrintConfig &settings);
|
||||
|
@ -78,7 +94,10 @@ public:
|
|||
void update_compatible_with_printer(bool select_other_if_incompatible);
|
||||
|
||||
private:
|
||||
void load_config_file_config(const std::string &path, const DynamicPrintConfig &config);
|
||||
// Load print, filament & printer presets from a config. If it is an external config, then the name is extracted from the external path.
|
||||
// and the external config is just referenced, not stored into user profile directory.
|
||||
// If it is not an external config, then the config will be stored into the user profile directory.
|
||||
void load_config_file_config(const std::string &name_or_path, bool is_external, DynamicPrintConfig &&config);
|
||||
void load_config_file_config_bundle(const std::string &path, const boost::property_tree::ptree &tree);
|
||||
bool load_compatible_bitmaps();
|
||||
|
||||
|
|
|
@ -55,11 +55,6 @@ static const ConfigOptionFloatOrPercent& first_positive(const ConfigOptionFloatO
|
|||
return (v1 != nullptr && v1->value > 0) ? *v1 : ((v2.value > 0) ? v2 : v3);
|
||||
}
|
||||
|
||||
static double first_positive(double v1, double v2)
|
||||
{
|
||||
return (v1 > 0.) ? v1 : v2;
|
||||
}
|
||||
|
||||
std::string PresetHints::maximum_volumetric_flow_description(const PresetBundle &preset_bundle)
|
||||
{
|
||||
// Find out, to which nozzle index is the current filament profile assigned.
|
||||
|
@ -106,6 +101,7 @@ std::string PresetHints::maximum_volumetric_flow_description(const PresetBundle
|
|||
const auto &solid_infill_extrusion_width = *print_config.option<ConfigOptionFloatOrPercent>("solid_infill_extrusion_width");
|
||||
const auto &support_material_extrusion_width = *print_config.option<ConfigOptionFloatOrPercent>("support_material_extrusion_width");
|
||||
const auto &top_infill_extrusion_width = *print_config.option<ConfigOptionFloatOrPercent>("top_infill_extrusion_width");
|
||||
const auto &first_layer_speed = *print_config.option<ConfigOptionFloatOrPercent>("first_layer_speed");
|
||||
|
||||
// Index of an extruder assigned to a feature. If set to 0, an active extruder will be used for a multi-material print.
|
||||
// If different from idx_extruder, it will not be taken into account for this hint.
|
||||
|
@ -136,12 +132,18 @@ std::string PresetHints::maximum_volumetric_flow_description(const PresetBundle
|
|||
const float bfr = bridging ? bridge_flow_ratio : 0.f;
|
||||
double max_flow = 0.;
|
||||
std::string max_flow_extrusion_type;
|
||||
auto limit_by_first_layer_speed = [&first_layer_speed, first_layer](double speed_normal, double speed_max) {
|
||||
if (first_layer && first_layer_speed.value > 0)
|
||||
// Apply the first layer limit.
|
||||
speed_normal = first_layer_speed.get_abs_value(speed_normal);
|
||||
return (speed_normal > 0.) ? speed_normal : speed_max;
|
||||
};
|
||||
if (perimeter_extruder_active) {
|
||||
double external_perimeter_rate = Flow::new_from_config_width(frExternalPerimeter,
|
||||
first_positive(first_layer_extrusion_width_ptr, external_perimeter_extrusion_width, extrusion_width),
|
||||
nozzle_diameter, lh, bfr).mm3_per_mm() *
|
||||
(bridging ? bridge_speed :
|
||||
first_positive(std::max(external_perimeter_speed, small_perimeter_speed), max_print_speed));
|
||||
limit_by_first_layer_speed(std::max(external_perimeter_speed, small_perimeter_speed), max_print_speed));
|
||||
if (max_flow < external_perimeter_rate) {
|
||||
max_flow = external_perimeter_rate;
|
||||
max_flow_extrusion_type = "external perimeters";
|
||||
|
@ -150,7 +152,7 @@ std::string PresetHints::maximum_volumetric_flow_description(const PresetBundle
|
|||
first_positive(first_layer_extrusion_width_ptr, perimeter_extrusion_width, extrusion_width),
|
||||
nozzle_diameter, lh, bfr).mm3_per_mm() *
|
||||
(bridging ? bridge_speed :
|
||||
first_positive(std::max(perimeter_speed, small_perimeter_speed), max_print_speed));
|
||||
limit_by_first_layer_speed(std::max(perimeter_speed, small_perimeter_speed), max_print_speed));
|
||||
if (max_flow < perimeter_rate) {
|
||||
max_flow = perimeter_rate;
|
||||
max_flow_extrusion_type = "perimeters";
|
||||
|
@ -159,7 +161,7 @@ std::string PresetHints::maximum_volumetric_flow_description(const PresetBundle
|
|||
if (! bridging && infill_extruder_active) {
|
||||
double infill_rate = Flow::new_from_config_width(frInfill,
|
||||
first_positive(first_layer_extrusion_width_ptr, infill_extrusion_width, extrusion_width),
|
||||
nozzle_diameter, lh, bfr).mm3_per_mm() * first_positive(infill_speed, max_print_speed);
|
||||
nozzle_diameter, lh, bfr).mm3_per_mm() * limit_by_first_layer_speed(infill_speed, max_print_speed);
|
||||
if (max_flow < infill_rate) {
|
||||
max_flow = infill_rate;
|
||||
max_flow_extrusion_type = "infill";
|
||||
|
@ -169,7 +171,7 @@ std::string PresetHints::maximum_volumetric_flow_description(const PresetBundle
|
|||
double solid_infill_rate = Flow::new_from_config_width(frInfill,
|
||||
first_positive(first_layer_extrusion_width_ptr, solid_infill_extrusion_width, extrusion_width),
|
||||
nozzle_diameter, lh, 0).mm3_per_mm() *
|
||||
(bridging ? bridge_speed : first_positive(solid_infill_speed, max_print_speed));
|
||||
(bridging ? bridge_speed : limit_by_first_layer_speed(solid_infill_speed, max_print_speed));
|
||||
if (max_flow < solid_infill_rate) {
|
||||
max_flow = solid_infill_rate;
|
||||
max_flow_extrusion_type = "solid infill";
|
||||
|
@ -177,7 +179,7 @@ std::string PresetHints::maximum_volumetric_flow_description(const PresetBundle
|
|||
if (! bridging) {
|
||||
double top_solid_infill_rate = Flow::new_from_config_width(frInfill,
|
||||
first_positive(first_layer_extrusion_width_ptr, top_infill_extrusion_width, extrusion_width),
|
||||
nozzle_diameter, lh, bfr).mm3_per_mm() * first_positive(top_solid_infill_speed, max_print_speed);
|
||||
nozzle_diameter, lh, bfr).mm3_per_mm() * limit_by_first_layer_speed(top_solid_infill_speed, max_print_speed);
|
||||
if (max_flow < top_solid_infill_rate) {
|
||||
max_flow = top_solid_infill_rate;
|
||||
max_flow_extrusion_type = "top solid infill";
|
||||
|
@ -188,7 +190,7 @@ std::string PresetHints::maximum_volumetric_flow_description(const PresetBundle
|
|||
double support_material_rate = Flow::new_from_config_width(frSupportMaterial,
|
||||
first_positive(first_layer_extrusion_width_ptr, support_material_extrusion_width, extrusion_width),
|
||||
nozzle_diameter, lh, bfr).mm3_per_mm() *
|
||||
(bridging ? bridge_speed : first_positive(support_material_speed, max_print_speed));
|
||||
(bridging ? bridge_speed : limit_by_first_layer_speed(support_material_speed, max_print_speed));
|
||||
if (max_flow < support_material_rate) {
|
||||
max_flow = support_material_rate;
|
||||
max_flow_extrusion_type = "support";
|
||||
|
@ -198,23 +200,23 @@ std::string PresetHints::maximum_volumetric_flow_description(const PresetBundle
|
|||
double support_material_interface_rate = Flow::new_from_config_width(frSupportMaterialInterface,
|
||||
first_positive(first_layer_extrusion_width_ptr, support_material_extrusion_width, extrusion_width),
|
||||
nozzle_diameter, lh, bfr).mm3_per_mm() *
|
||||
(bridging ? bridge_speed : first_positive(support_material_interface_speed, max_print_speed));
|
||||
(bridging ? bridge_speed : limit_by_first_layer_speed(support_material_interface_speed, max_print_speed));
|
||||
if (max_flow < support_material_interface_rate) {
|
||||
max_flow = support_material_interface_rate;
|
||||
max_flow_extrusion_type = "support interface";
|
||||
}
|
||||
}
|
||||
|
||||
//FIXME handle gap_fill_speed
|
||||
if (! out.empty())
|
||||
out += "\n";
|
||||
out += (first_layer ? "First layer volumetric" : (bridging ? "Bridging volumetric" : "Volumetric"));
|
||||
out += " flow rate is maximized ";
|
||||
out += ((max_volumetric_speed > 0 && max_volumetric_speed < max_flow) ?
|
||||
bool limited_by_max_volumetric_speed = max_volumetric_speed > 0 && max_volumetric_speed < max_flow;
|
||||
out += (limited_by_max_volumetric_speed ?
|
||||
"by the print profile maximum" :
|
||||
("when printing " + max_flow_extrusion_type))
|
||||
("when printing " + max_flow_extrusion_type))
|
||||
+ " with a volumetric rate ";
|
||||
if (max_volumetric_speed > 0 && max_volumetric_speed < max_flow)
|
||||
if (limited_by_max_volumetric_speed)
|
||||
max_flow = max_volumetric_speed;
|
||||
char buf[2048];
|
||||
sprintf(buf, "%3.2f mm³/s", max_flow);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue