Skip to content

Commit

Permalink
#447 thumbnails : colors choices (filament, user-defined) & bed display
Browse files Browse the repository at this point in the history
also for sla with support display.
  • Loading branch information
supermerill committed Sep 6, 2020
1 parent 82d83eb commit 852923e
Show file tree
Hide file tree
Showing 15 changed files with 164 additions and 31 deletions.
1 change: 1 addition & 0 deletions resources/profiles/PrusaResearch.idx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
min_slic3r_version = 2.2.0-alpha3
1.1.6 superslicer: thumbnails.
1.1.5 slic3r++ adaptation: overlapping & top pattern.
1.1.4 changed flow ratio from float to %
1.1.3 slic3r++ version
Expand Down
12 changes: 9 additions & 3 deletions resources/profiles/PrusaResearch.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Print profiles for the Prusa Research printers.
# it's a modified version for superslicer, this one is not endorsed by prusaresearch.

[vendor]
# Vendor name will be shown by the Config Wizard.
Expand All @@ -8,7 +9,7 @@ technologies = FFF; SLA

# Configuration version of this file. Config file will only be installed, if the config_version differs.
# This means, the server may force the PrusaSlicer configuration to be downgraded.
config_version = 1.1.5
config_version = 1.1.6
# Where to get the updates from?
config_update_url =
changelog_url =
Expand Down Expand Up @@ -151,7 +152,6 @@ default_acceleration = 1000
dont_support_bridges = 1
first_layer_size_compensation = -0.2
ensure_vertical_shell_thickness = 1

external_perimeters_first = 0
external_perimeter_extrusion_width = 0.45
extra_perimeters = 0
Expand Down Expand Up @@ -3889,7 +3889,10 @@ serial_port =
serial_speed = 250000
single_extruder_multi_material = 0
start_gcode = M862.3 P \"[printer_model]\" ; printer model check\nM862.1 P[nozzle_diameter] ; nozzle diameter check\nM115 U3.2.3 ; tell printer latest fw version\nG90 ; use absolute coordinates\nM83 ; extruder relative mode\nM204 S[machine_max_acceleration_extruding] T[machine_max_acceleration_retracting] ; MK2 firmware only supports the old M204 format\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 W ; home all without mesh bed level\nG80 ; mesh bed leveling\nG1 Y-3.0 F1000.0 ; go outside print area\nG92 E0.0\nG1 X60.0 E9.0 F1000.0 ; intro line\nG1 X100.0 E12.5 F1000.0 ; intro line\nG92 E0.0
toolchange_gcode =
thumbnails_color = #eb8037
thumbnails_with_bed = 1
thumbnails_custom_color = 1
toolchange_gcode = 1
use_firmware_retraction = 0
use_relative_e_distances = 1
use_volumetric_e = 0
Expand Down Expand Up @@ -4489,6 +4492,9 @@ min_initial_exposure_time = 1
max_initial_exposure_time = 300
printer_correction = 1,1,1
printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_SL1\n
thumbnails_color = #eb8037
thumbnails_with_bed = 1
thumbnails_custom_color = 1

# The obsolete presets will be removed when upgrading from the legacy configuration structure (up to Slic3r 1.39.2) to 1.40.0 and newer.
[obsolete_presets]
Expand Down
14 changes: 10 additions & 4 deletions resources/ui_layout/printer_fff.ui
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@ group:Print Host upload
printhost
group:silent_mode_event:Firmware
setting:gcode_flavor
line:Gcode thumbnails
setting:id$0:label$Small:thumbnails
setting:id$1:label$Big:thumbnails
end_line
setting:silent_mode
setting:remaining_times
setting:fan_speedup_time
group:Thumbnails
line:Size for Gcode
setting:id$0:label$Small:thumbnails
setting:id$1:label$Big:thumbnails
end_line
line:Color override
setting:label$:sidetext_width$1:thumbnails_custom_color
setting:label$:label_width$1:thumbnails_color
end_line
setting:thumbnails_with_bed
group:Advanced
setting:use_relative_e_distances
setting:use_firmware_retraction
Expand Down
13 changes: 13 additions & 0 deletions resources/ui_layout/printer_sla.ui
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ group:Exposure
setting:max_exposure_time
setting:min_initial_exposure_time
setting:max_initial_exposure_time
group:Thumbnails
line:Size for Gcode
setting:id$0:label$Small:thumbnails
setting:id$1:label$Big:thumbnails
end_line
line:Color override
setting:label$:sidetext_width$1:thumbnails_custom_color
setting:label$:label_width$1:thumbnails_color
end_line
line:Options
setting:thumbnails_with_bed
setting:thumbnails_with_support
end_line
group:Print Host upload
build_printhost

Expand Down
2 changes: 1 addition & 1 deletion src/PrusaSlicer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ int CLI::run(int argc, char **argv)
// The outfile is processed by a PlaceholderParser.
outfile = fff_print.export_gcode(outfile, nullptr);
outfile_final = fff_print.print_statistics().finalize_output_path(outfile);
} else {
} else if (printer_technology == ptSLA) {
outfile = sla_print.output_filepath(outfile);
// We need to finalize the filename beforehand because the export function sets the filename inside the zip metadata
outfile_final = sla_print.print_statistics().finalize_output_path(outfile);
Expand Down
9 changes: 6 additions & 3 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ namespace DoExport {

#if ENABLE_THUMBNAIL_GENERATOR
template<typename WriteToOutput, typename ThrowIfCanceledCallback>
static void export_thumbnails_to_file(ThumbnailsGeneratorCallback &thumbnail_cb, const std::vector<Vec2d> &sizes, WriteToOutput output, ThrowIfCanceledCallback throw_if_canceled)
static void export_thumbnails_to_file(ThumbnailsGeneratorCallback &thumbnail_cb, const std::vector<Vec2d> &sizes, bool thumbnails_with_bed, WriteToOutput output, ThrowIfCanceledCallback throw_if_canceled)
{
// Write thumbnails using base64 encoding
if (thumbnail_cb != nullptr)
Expand All @@ -1021,7 +1021,7 @@ namespace DoExport {

const size_t max_row_length = 78;
ThumbnailsList thumbnails;
thumbnail_cb(thumbnails, good_sizes, true, true, true, true);
thumbnail_cb(thumbnails, good_sizes, true, true, thumbnails_with_bed, true);
for (const ThumbnailData& data : thumbnails)
{
if (data.is_valid())
Expand Down Expand Up @@ -1263,7 +1263,10 @@ void GCode::_do_export(Print &print, FILE *file)
_write_format(file, "; %s\n\n", Slic3r::header_slic3r_generated().c_str());

#if ENABLE_THUMBNAIL_GENERATOR
DoExport::export_thumbnails_to_file(thumbnail_cb, print.full_print_config().option<ConfigOptionPoints>("thumbnails")->values,
const ConfigOptionBool *thumbnails_with_bed = print.full_print_config().option<ConfigOptionBool>("thumbnails_with_bed");
DoExport::export_thumbnails_to_file(thumbnail_cb,
print.full_print_config().option<ConfigOptionPoints>("thumbnails")->values,
thumbnails_with_bed==nullptr? false:thumbnails_with_bed->value,
[this, file](const char* sz) { this->_write(file, sz); },
[&print]() { print.throw_if_canceled(); });
#endif // ENABLE_THUMBNAIL_GENERATOR
Expand Down
31 changes: 30 additions & 1 deletion src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,39 @@ void PrintConfigDef::init_common_params()
def->set_default_value(new ConfigOptionString(""));

def = this->add("thumbnails", coPoints);
def->label = L("Picture sizes to be stored into a .gcode and .sl1 files");
def->label = L("Thumbnails size");
def->tooltip = L("Picture sizes to be stored into a .gcode and .sl1 files");
def->mode = comExpert;
def->set_default_value(new ConfigOptionPoints{ Vec2d(0,0), Vec2d(0,0) });

def = this->add("thumbnails_color", coString);
def->label = L("Color");
def->full_label = L("Thumbnail color");
def->category = OptionCategory::filament;
def->tooltip = L("This is the color that will be enforce on objects in the thumbnails.");
def->gui_type = "color";
def->mode = comExpert;
def->set_default_value(new ConfigOptionString("#018aff"));

def = this->add("thumbnails_custom_color", coBool);
def->label = L("Enforce thumbnail color");
def->tooltip = L("Enforce a specific color on thumbnails."
" If not enforced, their color will be the one defined by the filament.");
def->mode = comExpert;
def->set_default_value(new ConfigOptionBool(false));

def = this->add("thumbnails_with_bed", coBool);
def->label = L("Bed on thumbnail");
def->tooltip = L("Show the bed texture on the thumbnail picture.");
def->mode = comExpert;
def->set_default_value(new ConfigOptionBool(true));

def = this->add("thumbnails_with_support", coBool);
def->label = L("Support on thumbnail");
def->tooltip = L("Show the suppots (and pads) on the thumbnail picture.");
def->mode = comExpert;
def->set_default_value(new ConfigOptionBool(false));

def = this->add("layer_height", coFloat);
def->label = L("Base Layer height");
def->category = OptionCategory::perimeter;
Expand Down
16 changes: 16 additions & 0 deletions src/libslic3r/PrintConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,9 @@ class PrintConfig : public MachineEnvelopeConfig, public GCodeConfig
ConfigOptionInts temperature;
ConfigOptionInt threads;
ConfigOptionPoints thumbnails;
ConfigOptionString thumbnails_color;
ConfigOptionBool thumbnails_custom_color;
ConfigOptionBool thumbnails_with_bed;
ConfigOptionPercent time_estimation_compensation;
ConfigOptionInts top_fan_speed;
ConfigOptionBools wipe;
Expand Down Expand Up @@ -1212,6 +1215,9 @@ class PrintConfig : public MachineEnvelopeConfig, public GCodeConfig
OPT_PTR(temperature);
OPT_PTR(threads);
OPT_PTR(thumbnails);
OPT_PTR(thumbnails_color);
OPT_PTR(thumbnails_custom_color);
OPT_PTR(thumbnails_with_bed);
OPT_PTR(time_estimation_compensation);
OPT_PTR(top_fan_speed);
OPT_PTR(wipe);
Expand Down Expand Up @@ -1526,6 +1532,11 @@ class SLAPrinterConfig : public StaticPrintConfig
ConfigOptionFloat max_exposure_time;
ConfigOptionFloat min_initial_exposure_time;
ConfigOptionFloat max_initial_exposure_time;
ConfigOptionPoints thumbnails;
ConfigOptionString thumbnails_color;
ConfigOptionBool thumbnails_custom_color;
ConfigOptionBool thumbnails_with_bed;
ConfigOptionBool thumbnails_with_support;
protected:
void initialize(StaticCacheBase &cache, const char *base_ptr)
{
Expand All @@ -1551,6 +1562,11 @@ class SLAPrinterConfig : public StaticPrintConfig
OPT_PTR(max_exposure_time);
OPT_PTR(min_initial_exposure_time);
OPT_PTR(max_initial_exposure_time);
OPT_PTR(thumbnails);
OPT_PTR(thumbnails_color);
OPT_PTR(thumbnails_custom_color);
OPT_PTR(thumbnails_with_bed);
OPT_PTR(thumbnails_with_support);
}
};

Expand Down
7 changes: 6 additions & 1 deletion src/libslic3r/SLAPrint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,12 @@ bool SLAPrint::invalidate_state_by_config_options(const std::vector<t_config_opt
"bottle_cost",
"bottle_volume",
"bottle_weight",
"material_density"
"material_density",
"thumbnails",
"thumbnails_color",
"thumbnails_custom_color",
"thumbnails_with_bed",
"thumbnails_with_support"
};

std::vector<SLAPrintStep> steps;
Expand Down
16 changes: 11 additions & 5 deletions src/slic3r/GUI/BackgroundSlicingProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,11 @@ void BackgroundSlicingProcess::process_sla()
for (const Vec2d &size : current_print()->full_print_config().option<ConfigOptionPoints>("thumbnails")->values)
if (size.x() > 0 && size.y() > 0)
good_sizes.push_back(size);
m_thumbnail_cb(thumbnails, good_sizes, true, true, true, true);
// m_thumbnail_cb(thumbnails, good_sizes, true, false, true, true); // renders also supports and pad
m_thumbnail_cb(thumbnails, good_sizes,
true, // printable_only
!m_sla_print->printer_config().thumbnails_with_support.value, // parts_only
m_sla_print->printer_config().thumbnails_with_bed.value, // show_bed
true); // transparent_background
for (const ThumbnailData& data : thumbnails)
{
if (data.is_valid())
Expand Down Expand Up @@ -488,7 +491,7 @@ void BackgroundSlicingProcess::prepare_upload()
}
run_post_process_scripts(source_path.string(), m_fff_print->config());
m_upload_job.upload_data.upload_path = m_fff_print->print_statistics().finalize_output_path(m_upload_job.upload_data.upload_path.string());
} else {
} else if (m_print == m_sla_print) {
m_upload_job.upload_data.upload_path = m_sla_print->print_statistics().finalize_output_path(m_upload_job.upload_data.upload_path.string());

Zipper zipper{source_path.string()};
Expand All @@ -501,8 +504,11 @@ void BackgroundSlicingProcess::prepare_upload()
for (const Vec2d &size : current_print()->full_print_config().option<ConfigOptionPoints>("thumbnails")->values)
if (size.x() > 0 && size.y() > 0)
good_sizes.push_back(size);
m_thumbnail_cb(thumbnails, good_sizes, true, true, true, true);
// m_thumbnail_cb(thumbnails, good_sizes, true, false, true, true); // renders also supports and pad
m_thumbnail_cb(thumbnails, good_sizes,
true, // printable_only
!m_sla_print->printer_config().thumbnails_with_support.value, // parts_only
m_sla_print->printer_config().thumbnails_with_bed.value, // show_bed
true); // transparent_background
for (const ThumbnailData& data : thumbnails)
{
if (data.is_valid())
Expand Down
23 changes: 15 additions & 8 deletions src/slic3r/GUI/Field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1161,14 +1161,21 @@ void Choice::msw_rescale(bool rescale_sidetext/* = false*/)

void ColourPicker::BUILD()
{
auto size = wxSize(def_width() * m_em_unit, wxDefaultCoord);
if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit);
if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit);
auto size = wxSize(def_width() * m_em_unit, wxDefaultCoord);
if (m_opt.height >= 0) size.SetHeight(m_opt.height * m_em_unit);
if (m_opt.width >= 0) size.SetWidth(m_opt.width * m_em_unit);

// Validate the color
wxString clr_str(m_opt.get_default_value<ConfigOptionStrings>()->get_at(m_opt_idx));
wxColour clr(clr_str);
if (clr_str.IsEmpty() || !clr.IsOk()) {
// Validate the color
wxColour clr = wxTransparentColour;
if (m_opt.type == coStrings)
clr = wxColour{wxString{ m_opt.get_default_value<ConfigOptionStrings>()->get_at(m_opt_idx) }};
if (m_opt.type == coString)
clr = wxColour{ wxString{ m_opt.get_default_value<ConfigOptionString>()->value } };
if (m_opt.type == coInts)
clr = wxColour{ (unsigned long)m_opt.get_default_value<ConfigOptionInts>()->get_at(m_opt_idx) };
if (m_opt.type == coInt)
clr = wxColour{ (unsigned long)m_opt.get_default_value<ConfigOptionInt>()->value };
if (!clr.IsOk()) {
clr = wxTransparentColour;
}

Expand All @@ -1181,7 +1188,7 @@ void ColourPicker::BUILD()

temp->Bind(wxEVT_COLOURPICKER_CHANGED, ([this](wxCommandEvent e) { on_change_field(); }), temp->GetId());

temp->SetToolTip(get_tooltip_text(clr_str));
temp->SetToolTip(get_tooltip_text(clr.GetAsString()));
}

void ColourPicker::set_undef_value(wxColourPickerCtrl* field)
Expand Down
23 changes: 20 additions & 3 deletions src/slic3r/GUI/GLCanvas3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4268,7 +4268,6 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, bool
return ret;
};

static const GLfloat orange[] = { 0.923f, 0.504f, 0.264f, 1.0f };
static const GLfloat gray[] = { 0.64f, 0.64f, 0.64f, 1.0f };

GLVolumePtrs visible_volumes;
Expand Down Expand Up @@ -4329,12 +4328,30 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, bool
if (print_box_detection_id != -1)
glsafe(::glUniform1i(print_box_detection_id, 0));

//parse custom color from config
float custom_color[] = { -1.0f, 0.0f, 0.0f, 1.0f };
if(Tab* tab = wxGetApp().get_tab(Preset::TYPE_PRINTER))
if(const DynamicPrintConfig* printer_config = tab->get_config())
if(const ConfigOptionBool *conf_ok = printer_config->option<ConfigOptionBool>("thumbnails_custom_color"))
if(conf_ok->value)
if (const ConfigOptionString* conf_color = printer_config->option<ConfigOptionString>("thumbnails_color"))
if(conf_color->value.length() > 6)
{
wxColour clr(conf_color->value);
custom_color[0] = clr.Red() / 255.f;
custom_color[1] = clr.Green() / 255.f;
custom_color[2] = clr.Blue() / 255.f;
}
for (const GLVolume* vol : visible_volumes)
{
if (color_id >= 0)
glsafe(::glUniform4fv(color_id, 1, (vol->printable && !vol->is_outside) ? orange : gray));
glsafe(::glUniform4fv(color_id, 1, (vol->printable && !vol->is_outside)
? (custom_color[0]<0 ? vol->color : custom_color)
: gray));
else
glsafe(::glColor4fv((vol->printable && !vol->is_outside) ? orange : gray));
glsafe(::glColor4fv((vol->printable && !vol->is_outside)
? (custom_color[0] < 0 ? vol->color : custom_color)
: gray));

vol->render();
}
Expand Down
14 changes: 13 additions & 1 deletion src/slic3r/GUI/Plater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5131,7 +5131,19 @@ void Plater::export_3mf(const boost::filesystem::path& output_path)
bool full_pathnames = wxGetApp().app_config->get("export_sources_full_pathnames") == "1";
#if ENABLE_THUMBNAIL_GENERATOR
ThumbnailData thumbnail_data;
p->generate_thumbnail(thumbnail_data, THUMBNAIL_SIZE_3MF.first, THUMBNAIL_SIZE_3MF.second, false, true, true, true);

const DynamicPrintConfig* printer_config = wxGetApp().get_tab(Preset::TYPE_PRINTER)->get_config();
bool show_bed_on_thumbnails = true;
if (const ConfigOptionBool* conf = printer_config->option<ConfigOptionBool>("thumbnails_with_bed"))
show_bed_on_thumbnails = conf->value;
bool show_support_on_thumbnails = false;
if (const ConfigOptionBool* conf = printer_config->option<ConfigOptionBool>("thumbnails_with_support"))
show_support_on_thumbnails = conf->value;
p->generate_thumbnail(thumbnail_data, THUMBNAIL_SIZE_3MF.first, THUMBNAIL_SIZE_3MF.second,
false, // printable_only
!show_support_on_thumbnails, // parts_only
show_bed_on_thumbnails, // show_bed
true); // transparent_background
if (Slic3r::store_3mf(path_u8.c_str(), &p->model, export_config ? &cfg : nullptr, full_pathnames, &thumbnail_data)) {
#else
if (Slic3r::store_3mf(path_u8.c_str(), &p->model, export_config ? &cfg : nullptr, full_pathnames)) {
Expand Down
10 changes: 9 additions & 1 deletion src/slic3r/GUI/Preset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,9 @@ const std::vector<std::string>& Preset::printer_options()
"machine_min_extruding_rate", "machine_min_travel_rate",
"machine_max_jerk_x", "machine_max_jerk_y", "machine_max_jerk_z", "machine_max_jerk_e",
"thumbnails",
"thumbnails_color",
"thumbnails_custom_color",
"thumbnails_with_bed",
"time_estimation_compensation",
"print_machine_envelope",
"fan_speedup_time",
Expand Down Expand Up @@ -742,7 +745,12 @@ const std::vector<std::string>& Preset::sla_printer_options()
"min_initial_exposure_time", "max_initial_exposure_time",
"print_host", "printhost_apikey", "printhost_cafile",
"printer_notes",
"inherits"
"inherits",
"thumbnails",
"thumbnails_color",
"thumbnails_custom_color",
"thumbnails_with_bed",
"thumbnails_with_support"
};
}
return s_opts;
Expand Down
Loading

0 comments on commit 852923e

Please sign in to comment.