Merge branch 'master' of https://github.com/Prusa3d/PrusaSlicer
This commit is contained in:
commit
ae887d5833
9 changed files with 129 additions and 22 deletions
|
@ -961,7 +961,7 @@ void GCode::_do_export(Print &print, FILE *file)
|
||||||
// Write thumbnails using base64 encoding
|
// Write thumbnails using base64 encoding
|
||||||
if (thumbnail_data != nullptr)
|
if (thumbnail_data != nullptr)
|
||||||
{
|
{
|
||||||
const unsigned int max_row_length = 78;
|
const size_t max_row_length = 78;
|
||||||
|
|
||||||
for (const ThumbnailData& data : *thumbnail_data)
|
for (const ThumbnailData& data : *thumbnail_data)
|
||||||
{
|
{
|
||||||
|
@ -972,19 +972,21 @@ void GCode::_do_export(Print &print, FILE *file)
|
||||||
void* png_data = tdefl_write_image_to_png_file_in_memory_ex((const void*)data.pixels.data(), data.width, data.height, 4, &png_size, MZ_DEFAULT_LEVEL, 1);
|
void* png_data = tdefl_write_image_to_png_file_in_memory_ex((const void*)data.pixels.data(), data.width, data.height, 4, &png_size, MZ_DEFAULT_LEVEL, 1);
|
||||||
if (png_data != nullptr)
|
if (png_data != nullptr)
|
||||||
{
|
{
|
||||||
_write_format(file, "\n;\n; thumbnail begin %dx%d\n", data.width, data.height);
|
std::string encoded;
|
||||||
|
encoded.resize(boost::beast::detail::base64::encoded_size(png_size));
|
||||||
|
encoded.resize(boost::beast::detail::base64::encode((void*)&encoded[0], (const void*)png_data, png_size));
|
||||||
|
|
||||||
std::string encoded = boost::beast::detail::base64_encode((const std::uint8_t*)png_data, png_size);
|
_write_format(file, "\n;\n; thumbnail begin %dx%d %d\n", data.width, data.height, encoded.size());
|
||||||
|
|
||||||
unsigned int row_count = 0;
|
unsigned int row_count = 0;
|
||||||
while (encoded.length() > max_row_length)
|
while (encoded.size() > max_row_length)
|
||||||
{
|
{
|
||||||
_write_format(file, "; %s\n", encoded.substr(0, max_row_length).c_str());
|
_write_format(file, "; %s\n", encoded.substr(0, max_row_length).c_str());
|
||||||
encoded = encoded.substr(max_row_length);
|
encoded = encoded.substr(max_row_length);
|
||||||
++row_count;
|
++row_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (encoded.length() > 0)
|
if (encoded.size() > 0)
|
||||||
_write_format(file, "; %s\n", encoded.c_str());
|
_write_format(file, "; %s\n", encoded.c_str());
|
||||||
|
|
||||||
_write(file, "; thumbnail end\n;\n");
|
_write(file, "; thumbnail end\n;\n");
|
||||||
|
@ -997,9 +999,12 @@ void GCode::_do_export(Print &print, FILE *file)
|
||||||
size_t row_size = 4 * data.width;
|
size_t row_size = 4 * data.width;
|
||||||
for (int r = (int)data.height - 1; r >= 0; --r)
|
for (int r = (int)data.height - 1; r >= 0; --r)
|
||||||
{
|
{
|
||||||
std::string encoded = boost::beast::detail::base64_encode((const std::uint8_t*)(data.pixels.data() + r * row_size), row_size);
|
std::string encoded;
|
||||||
|
encoded.resize(boost::beast::detail::base64::encoded_size(row_size));
|
||||||
|
encoded.resize(boost::beast::detail::base64::encode((void*)&encoded[0], (const void*)(data.pixels.data() + r * row_size), row_size));
|
||||||
|
|
||||||
unsigned int row_count = 0;
|
unsigned int row_count = 0;
|
||||||
while (encoded.length() > max_row_length)
|
while (encoded.size() > max_row_length)
|
||||||
{
|
{
|
||||||
if (row_count == 0)
|
if (row_count == 0)
|
||||||
_write_format(file, "; %s\n", encoded.substr(0, max_row_length).c_str());
|
_write_format(file, "; %s\n", encoded.substr(0, max_row_length).c_str());
|
||||||
|
@ -1010,7 +1015,7 @@ void GCode::_do_export(Print &print, FILE *file)
|
||||||
++row_count;
|
++row_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (encoded.length() > 0)
|
if (encoded.size() > 0)
|
||||||
{
|
{
|
||||||
if (row_count == 0)
|
if (row_count == 0)
|
||||||
_write_format(file, "; %s\n", encoded.c_str());
|
_write_format(file, "; %s\n", encoded.c_str());
|
||||||
|
|
|
@ -2440,6 +2440,34 @@ void PrintConfigDef::init_sla_params()
|
||||||
def->min = 0;
|
def->min = 0;
|
||||||
def->set_default_value(new ConfigOptionFloat(0.3));
|
def->set_default_value(new ConfigOptionFloat(0.3));
|
||||||
|
|
||||||
|
def = this->add("bottle_volume", coFloat);
|
||||||
|
def->label = L("Bottle volume");
|
||||||
|
def->tooltip = L("Bottle volume");
|
||||||
|
def->sidetext = L("ml");
|
||||||
|
def->min = 50;
|
||||||
|
def->set_default_value(new ConfigOptionFloat(1000.0));
|
||||||
|
|
||||||
|
def = this->add("bottle_weight", coFloat);
|
||||||
|
def->label = L("Bottle weight");
|
||||||
|
def->tooltip = L("Bottle weight");
|
||||||
|
def->sidetext = L("kg");
|
||||||
|
def->min = 0;
|
||||||
|
def->set_default_value(new ConfigOptionFloat(1.0));
|
||||||
|
|
||||||
|
def = this->add("material_density", coFloat);
|
||||||
|
def->label = L("Density");
|
||||||
|
def->tooltip = L("Density");
|
||||||
|
def->sidetext = L("g/ml");
|
||||||
|
def->min = 0;
|
||||||
|
def->set_default_value(new ConfigOptionFloat(1.0));
|
||||||
|
|
||||||
|
def = this->add("bottle_cost", coFloat);
|
||||||
|
def->label = L("Cost");
|
||||||
|
def->tooltip = L("Cost");
|
||||||
|
def->sidetext = L("money/bottle");
|
||||||
|
def->min = 0;
|
||||||
|
def->set_default_value(new ConfigOptionFloat(0.0));
|
||||||
|
|
||||||
def = this->add("faded_layers", coInt);
|
def = this->add("faded_layers", coInt);
|
||||||
def->label = L("Faded layers");
|
def->label = L("Faded layers");
|
||||||
def->tooltip = L("Number of the layers needed for the exposure time fade from initial exposure time to the exposure time");
|
def->tooltip = L("Number of the layers needed for the exposure time fade from initial exposure time to the exposure time");
|
||||||
|
|
|
@ -1126,6 +1126,10 @@ class SLAMaterialConfig : public StaticPrintConfig
|
||||||
STATIC_PRINT_CONFIG_CACHE(SLAMaterialConfig)
|
STATIC_PRINT_CONFIG_CACHE(SLAMaterialConfig)
|
||||||
public:
|
public:
|
||||||
ConfigOptionFloat initial_layer_height;
|
ConfigOptionFloat initial_layer_height;
|
||||||
|
ConfigOptionFloat bottle_cost;
|
||||||
|
ConfigOptionFloat bottle_volume;
|
||||||
|
ConfigOptionFloat bottle_weight;
|
||||||
|
ConfigOptionFloat material_density;
|
||||||
ConfigOptionFloat exposure_time;
|
ConfigOptionFloat exposure_time;
|
||||||
ConfigOptionFloat initial_exposure_time;
|
ConfigOptionFloat initial_exposure_time;
|
||||||
ConfigOptionFloats material_correction;
|
ConfigOptionFloats material_correction;
|
||||||
|
@ -1133,6 +1137,10 @@ protected:
|
||||||
void initialize(StaticCacheBase &cache, const char *base_ptr)
|
void initialize(StaticCacheBase &cache, const char *base_ptr)
|
||||||
{
|
{
|
||||||
OPT_PTR(initial_layer_height);
|
OPT_PTR(initial_layer_height);
|
||||||
|
OPT_PTR(bottle_cost);
|
||||||
|
OPT_PTR(bottle_volume);
|
||||||
|
OPT_PTR(bottle_weight);
|
||||||
|
OPT_PTR(material_density);
|
||||||
OPT_PTR(exposure_time);
|
OPT_PTR(exposure_time);
|
||||||
OPT_PTR(initial_exposure_time);
|
OPT_PTR(initial_exposure_time);
|
||||||
OPT_PTR(material_correction);
|
OPT_PTR(material_correction);
|
||||||
|
|
|
@ -1607,7 +1607,11 @@ bool SLAPrint::invalidate_state_by_config_options(const std::vector<t_config_opt
|
||||||
"output_filename_format",
|
"output_filename_format",
|
||||||
"fast_tilt_time",
|
"fast_tilt_time",
|
||||||
"slow_tilt_time",
|
"slow_tilt_time",
|
||||||
"area_fill"
|
"area_fill",
|
||||||
|
"bottle_cost",
|
||||||
|
"bottle_volume",
|
||||||
|
"bottle_weight",
|
||||||
|
"material_density"
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<SLAPrintStep> steps;
|
std::vector<SLAPrintStep> steps;
|
||||||
|
|
|
@ -1131,8 +1131,11 @@ void GUI_App::gcode_thumbnails_debug()
|
||||||
boost::nowide::ofstream out_file(out_filename.c_str(), std::ios::binary);
|
boost::nowide::ofstream out_file(out_filename.c_str(), std::ios::binary);
|
||||||
if (out_file.good())
|
if (out_file.good())
|
||||||
{
|
{
|
||||||
std::string decoded = boost::beast::detail::base64_decode(row);
|
std::string decoded;
|
||||||
out_file.write(decoded.c_str(), decoded.length());
|
decoded.resize(boost::beast::detail::base64::decoded_size(row.size()));
|
||||||
|
decoded.resize(boost::beast::detail::base64::decode((void*)&decoded[0], row.data(), row.size()).first);
|
||||||
|
|
||||||
|
out_file.write(decoded.c_str(), decoded.size());
|
||||||
out_file.close();
|
out_file.close();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -1147,8 +1150,11 @@ void GUI_App::gcode_thumbnails_debug()
|
||||||
std::vector<unsigned char> thumbnail(4 * width * height, 0);
|
std::vector<unsigned char> thumbnail(4 * width * height, 0);
|
||||||
for (unsigned int r = 0; r < (unsigned int)rows.size(); ++r)
|
for (unsigned int r = 0; r < (unsigned int)rows.size(); ++r)
|
||||||
{
|
{
|
||||||
std::string decoded_row = boost::beast::detail::base64_decode(rows[r]);
|
std::string decoded_row;
|
||||||
if ((unsigned int)decoded_row.length() == width * 4)
|
decoded_row.resize(boost::beast::detail::base64::decoded_size(rows[r].size()));
|
||||||
|
decoded_row.resize(boost::beast::detail::base64::decode((void*)&decoded_row[0], rows[r].data(), rows[r].size()).first);
|
||||||
|
|
||||||
|
if ((unsigned int)decoded_row.size() == width * 4)
|
||||||
{
|
{
|
||||||
void* image_ptr = (void*)(thumbnail.data() + r * width * 4);
|
void* image_ptr = (void*)(thumbnail.data() + r * width * 4);
|
||||||
::memcpy(image_ptr, (const void*)decoded_row.c_str(), width * 4);
|
::memcpy(image_ptr, (const void*)decoded_row.c_str(), width * 4);
|
||||||
|
|
|
@ -231,7 +231,7 @@ SlicedInfo::SlicedInfo(wxWindow *parent) :
|
||||||
init_info_label(_(L("Used Filament (mm³)")));
|
init_info_label(_(L("Used Filament (mm³)")));
|
||||||
init_info_label(_(L("Used Filament (g)")));
|
init_info_label(_(L("Used Filament (g)")));
|
||||||
init_info_label(_(L("Used Material (unit)")));
|
init_info_label(_(L("Used Material (unit)")));
|
||||||
init_info_label(_(L("Cost")));
|
init_info_label(_(L("Cost (money)")));
|
||||||
init_info_label(_(L("Estimated printing time")));
|
init_info_label(_(L("Estimated printing time")));
|
||||||
init_info_label(_(L("Number of tool changes")));
|
init_info_label(_(L("Number of tool changes")));
|
||||||
|
|
||||||
|
@ -1129,12 +1129,10 @@ void Sidebar::show_info_sizer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sidebar::show_sliced_info_sizer(const bool show)
|
void Sidebar::update_sliced_info_sizer()
|
||||||
{
|
{
|
||||||
wxWindowUpdateLocker freeze_guard(this);
|
if (p->sliced_info->IsShown(size_t(0)))
|
||||||
|
{
|
||||||
p->sliced_info->Show(show);
|
|
||||||
if (show) {
|
|
||||||
if (p->plater->printer_technology() == ptSLA)
|
if (p->plater->printer_technology() == ptSLA)
|
||||||
{
|
{
|
||||||
const SLAPrintStatistics& ps = p->plater->sla_print().print_statistics();
|
const SLAPrintStatistics& ps = p->plater->sla_print().print_statistics();
|
||||||
|
@ -1150,7 +1148,18 @@ void Sidebar::show_sliced_info_sizer(const bool show)
|
||||||
wxString::Format("%.2f", (ps.objects_used_material + ps.support_used_material) / 1000);
|
wxString::Format("%.2f", (ps.objects_used_material + ps.support_used_material) / 1000);
|
||||||
p->sliced_info->SetTextAndShow(siMateril_unit, info_text, new_label);
|
p->sliced_info->SetTextAndShow(siMateril_unit, info_text, new_label);
|
||||||
|
|
||||||
p->sliced_info->SetTextAndShow(siCost, "N/A"/*wxString::Format("%.2f", ps.total_cost)*/);
|
wxString str_total_cost = "N/A";
|
||||||
|
|
||||||
|
DynamicPrintConfig* cfg = wxGetApp().get_tab(Preset::TYPE_SLA_MATERIAL)->get_config();
|
||||||
|
if (cfg->option("bottle_cost")->getFloat() > 0.0 &&
|
||||||
|
cfg->option("bottle_volume")->getFloat() > 0.0)
|
||||||
|
{
|
||||||
|
double material_cost = cfg->option("bottle_cost")->getFloat() /
|
||||||
|
cfg->option("bottle_volume")->getFloat();
|
||||||
|
str_total_cost = wxString::Format("%.2f", material_cost*(ps.objects_used_material + ps.support_used_material) / 1000);
|
||||||
|
}
|
||||||
|
p->sliced_info->SetTextAndShow(siCost, str_total_cost);
|
||||||
|
|
||||||
wxString t_est = std::isnan(ps.estimated_print_time) ? "N/A" : get_time_dhms(float(ps.estimated_print_time));
|
wxString t_est = std::isnan(ps.estimated_print_time) ? "N/A" : get_time_dhms(float(ps.estimated_print_time));
|
||||||
p->sliced_info->SetTextAndShow(siEstimatedTime, t_est, _(L("Estimated printing time")) + " :");
|
p->sliced_info->SetTextAndShow(siEstimatedTime, t_est, _(L("Estimated printing time")) + " :");
|
||||||
|
|
||||||
|
@ -1224,6 +1233,15 @@ void Sidebar::show_sliced_info_sizer(const bool show)
|
||||||
p->sliced_info->SetTextAndShow(siMateril_unit, "N/A");
|
p->sliced_info->SetTextAndShow(siMateril_unit, "N/A");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sidebar::show_sliced_info_sizer(const bool show)
|
||||||
|
{
|
||||||
|
wxWindowUpdateLocker freeze_guard(this);
|
||||||
|
|
||||||
|
p->sliced_info->Show(show);
|
||||||
|
if (show)
|
||||||
|
update_sliced_info_sizer();
|
||||||
|
|
||||||
Layout();
|
Layout();
|
||||||
p->scrolled->Refresh();
|
p->scrolled->Refresh();
|
||||||
|
|
|
@ -112,6 +112,7 @@ public:
|
||||||
void update_objects_list_extruder_column(size_t extruders_count);
|
void update_objects_list_extruder_column(size_t extruders_count);
|
||||||
void show_info_sizer();
|
void show_info_sizer();
|
||||||
void show_sliced_info_sizer(const bool show);
|
void show_sliced_info_sizer(const bool show);
|
||||||
|
void update_sliced_info_sizer();
|
||||||
void enable_buttons(bool enable);
|
void enable_buttons(bool enable);
|
||||||
void set_btn_label(const ActionButtonType btn_type, const wxString& label) const;
|
void set_btn_label(const ActionButtonType btn_type, const wxString& label) const;
|
||||||
bool show_reslice(bool show) const;
|
bool show_reslice(bool show) const;
|
||||||
|
|
|
@ -513,6 +513,10 @@ const std::vector<std::string>& Preset::sla_material_options()
|
||||||
s_opts = {
|
s_opts = {
|
||||||
"material_type",
|
"material_type",
|
||||||
"initial_layer_height",
|
"initial_layer_height",
|
||||||
|
"bottle_cost",
|
||||||
|
"bottle_volume",
|
||||||
|
"bottle_weight",
|
||||||
|
"material_density",
|
||||||
"exposure_time",
|
"exposure_time",
|
||||||
"initial_exposure_time",
|
"initial_exposure_time",
|
||||||
"material_correction",
|
"material_correction",
|
||||||
|
|
|
@ -3419,8 +3419,41 @@ void TabSLAMaterial::build()
|
||||||
|
|
||||||
auto page = add_options_page(_(L("Material")), "resin");
|
auto page = add_options_page(_(L("Material")), "resin");
|
||||||
|
|
||||||
auto optgroup = page->new_optgroup(_(L("Layers")));
|
auto optgroup = page->new_optgroup(_(L("Material")));
|
||||||
// optgroup->append_single_option_line("layer_height");
|
optgroup->append_single_option_line("bottle_cost");
|
||||||
|
optgroup->append_single_option_line("bottle_volume");
|
||||||
|
optgroup->append_single_option_line("bottle_weight");
|
||||||
|
optgroup->append_single_option_line("material_density");
|
||||||
|
|
||||||
|
optgroup->m_on_change = [this, optgroup](t_config_option_key opt_key, boost::any value)
|
||||||
|
{
|
||||||
|
DynamicPrintConfig new_conf = *m_config;
|
||||||
|
|
||||||
|
if (opt_key == "bottle_volume") {
|
||||||
|
double new_bottle_weight = boost::any_cast<double>(value)/(new_conf.option("material_density")->getFloat() * 1000);
|
||||||
|
new_conf.set_key_value("bottle_weight", new ConfigOptionFloat(new_bottle_weight));
|
||||||
|
}
|
||||||
|
if (opt_key == "bottle_weight") {
|
||||||
|
double new_bottle_volume = boost::any_cast<double>(value)*(new_conf.option("material_density")->getFloat() * 1000);
|
||||||
|
new_conf.set_key_value("bottle_volume", new ConfigOptionFloat(new_bottle_volume));
|
||||||
|
}
|
||||||
|
if (opt_key == "material_density") {
|
||||||
|
double new_bottle_volume = new_conf.option("bottle_weight")->getFloat() * boost::any_cast<double>(value) * 1000;
|
||||||
|
new_conf.set_key_value("bottle_volume", new ConfigOptionFloat(new_bottle_volume));
|
||||||
|
}
|
||||||
|
|
||||||
|
load_config(new_conf);
|
||||||
|
|
||||||
|
update_dirty();
|
||||||
|
on_value_change(opt_key, value);
|
||||||
|
|
||||||
|
if (opt_key == "bottle_volume" || opt_key == "bottle_cost") {
|
||||||
|
wxGetApp().sidebar().update_sliced_info_sizer();
|
||||||
|
wxGetApp().sidebar().Layout();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
optgroup = page->new_optgroup(_(L("Layers")));
|
||||||
optgroup->append_single_option_line("initial_layer_height");
|
optgroup->append_single_option_line("initial_layer_height");
|
||||||
|
|
||||||
optgroup = page->new_optgroup(_(L("Exposure")));
|
optgroup = page->new_optgroup(_(L("Exposure")));
|
||||||
|
|
Loading…
Reference in a new issue