mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-25 15:44:12 -06:00
ENABLE_THUMBNAIL_GENERATOR -> Allow for multiple thumbnails into gcode and sl1 files
This commit is contained in:
parent
de60b40347
commit
2d5c28d6d1
7 changed files with 70 additions and 31 deletions
|
@ -120,7 +120,7 @@ static void write_thumbnail(Zipper& zipper, const ThumbnailData& data)
|
|||
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)
|
||||
{
|
||||
zipper.add_entry("thumbnail/thumbnail.png", (const std::uint8_t*)png_data, png_size);
|
||||
zipper.add_entry("thumbnail/thumbnail" + std::to_string(data.width) + "x" + std::to_string(data.height) + ".png", (const std::uint8_t*)png_data, png_size);
|
||||
mz_free(png_data);
|
||||
}
|
||||
}
|
||||
|
@ -138,8 +138,14 @@ void BackgroundSlicingProcess::process_sla()
|
|||
m_sla_print->export_raster(zipper);
|
||||
|
||||
#if ENABLE_THUMBNAIL_GENERATOR
|
||||
if ((m_thumbnail_data != nullptr) && m_thumbnail_data->is_valid())
|
||||
write_thumbnail(zipper, *m_thumbnail_data);
|
||||
if (m_thumbnail_data != nullptr)
|
||||
{
|
||||
for (const ThumbnailData& data : *m_thumbnail_data)
|
||||
{
|
||||
if (data.is_valid())
|
||||
write_thumbnail(zipper, data);
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||
|
||||
zipper.finalize();
|
||||
|
@ -458,8 +464,14 @@ void BackgroundSlicingProcess::prepare_upload()
|
|||
Zipper zipper{source_path.string()};
|
||||
m_sla_print->export_raster(zipper, m_upload_job.upload_data.upload_path.string());
|
||||
#if ENABLE_THUMBNAIL_GENERATOR
|
||||
if ((m_thumbnail_data != nullptr) && m_thumbnail_data->is_valid())
|
||||
write_thumbnail(zipper, *m_thumbnail_data);
|
||||
if (m_thumbnail_data != nullptr)
|
||||
{
|
||||
for (const ThumbnailData& data : *m_thumbnail_data)
|
||||
{
|
||||
if (data.is_valid())
|
||||
write_thumbnail(zipper, data);
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||
zipper.finalize();
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
void set_sla_print(SLAPrint *print) { m_sla_print = print; }
|
||||
void set_gcode_preview_data(GCodePreviewData *gpd) { m_gcode_preview_data = gpd; }
|
||||
#if ENABLE_THUMBNAIL_GENERATOR
|
||||
void set_thumbnail_data(const ThumbnailData* data) { m_thumbnail_data = data; }
|
||||
void set_thumbnail_data(const std::vector<ThumbnailData>* data) { m_thumbnail_data = data; }
|
||||
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||
|
||||
// The following wxCommandEvent will be sent to the UI thread / Platter window, when the slicing is finished
|
||||
|
@ -159,8 +159,8 @@ private:
|
|||
// Data structure, to which the G-code export writes its annotations.
|
||||
GCodePreviewData *m_gcode_preview_data = nullptr;
|
||||
#if ENABLE_THUMBNAIL_GENERATOR
|
||||
// Data structure, used to write thumbnail into gcode.
|
||||
const ThumbnailData *m_thumbnail_data = nullptr;
|
||||
// Data structures, used to write thumbnails into gcode.
|
||||
const std::vector<ThumbnailData>* m_thumbnail_data = nullptr;
|
||||
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||
// Temporary G-code, there is one defined for the BackgroundSlicingProcess, differentiated from the other processes by a process ID.
|
||||
std::string m_temp_output_path;
|
||||
|
|
|
@ -86,8 +86,8 @@ using Slic3r::Preset;
|
|||
using Slic3r::PrintHostJob;
|
||||
|
||||
#if ENABLE_THUMBNAIL_GENERATOR
|
||||
static const std::pair<unsigned int, unsigned int> THUMBNAIL_SIZE_FFF = { 128, 128 };
|
||||
static const std::pair<unsigned int, unsigned int> THUMBNAIL_SIZE_SLA = { 256, 256 };
|
||||
static const std::vector < std::pair<unsigned int, unsigned int>> THUMBNAIL_SIZE_FFF = { { 240, 320 }, { 220, 165 }, { 16, 16 } };
|
||||
static const std::vector<std::pair<unsigned int, unsigned int>> THUMBNAIL_SIZE_SLA = { { 800, 480 } };
|
||||
static const std::pair<unsigned int, unsigned int> THUMBNAIL_SIZE_3MF = { 256, 256 };
|
||||
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||
|
||||
|
@ -1371,7 +1371,7 @@ struct Plater::priv
|
|||
PrinterTechnology printer_technology = ptFFF;
|
||||
Slic3r::GCodePreviewData gcode_preview_data;
|
||||
#if ENABLE_THUMBNAIL_GENERATOR
|
||||
Slic3r::ThumbnailData thumbnail_data;
|
||||
std::vector<Slic3r::ThumbnailData> thumbnail_data;
|
||||
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||
|
||||
// GUI elements
|
||||
|
@ -3050,12 +3050,26 @@ bool Plater::priv::restart_background_process(unsigned int state)
|
|||
{
|
||||
// update thumbnail data
|
||||
if (this->printer_technology == ptFFF)
|
||||
// for ptFFF we need to generate the thumbnail before the export of gcode starts
|
||||
generate_thumbnail(this->thumbnail_data, THUMBNAIL_SIZE_FFF.first, THUMBNAIL_SIZE_FFF.second, true, true);
|
||||
{
|
||||
// for ptFFF we need to generate the thumbnails before the export of gcode starts
|
||||
this->thumbnail_data.clear();
|
||||
for (const std::pair<unsigned int, unsigned int>& size : THUMBNAIL_SIZE_FFF)
|
||||
{
|
||||
this->thumbnail_data.push_back(ThumbnailData());
|
||||
generate_thumbnail(this->thumbnail_data.back(), size.first, size.second, true, true);
|
||||
}
|
||||
}
|
||||
else if (this->printer_technology == ptSLA)
|
||||
// for ptSLA generate thumbnail without supports and pad (not yet calculated)
|
||||
{
|
||||
// for ptSLA generate thumbnails without supports and pad (not yet calculated)
|
||||
// to render also supports and pad see on_slicing_update()
|
||||
generate_thumbnail(this->thumbnail_data, THUMBNAIL_SIZE_SLA.first, THUMBNAIL_SIZE_SLA.second, true, true);
|
||||
this->thumbnail_data.clear();
|
||||
for (const std::pair<unsigned int, unsigned int>& size : THUMBNAIL_SIZE_SLA)
|
||||
{
|
||||
this->thumbnail_data.push_back(ThumbnailData());
|
||||
generate_thumbnail(this->thumbnail_data.back(), size.first, size.second, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||
// The print is valid and it can be started.
|
||||
|
@ -3402,7 +3416,14 @@ void Plater::priv::on_slicing_update(SlicingStatusEvent &evt)
|
|||
// update thumbnail data
|
||||
// for ptSLA generate the thumbnail after supports and pad have been calculated to have them rendered
|
||||
if ((this->printer_technology == ptSLA) && (evt.status.percent == -3))
|
||||
generate_thumbnail(this->thumbnail_data, THUMBNAIL_SIZE_SLA.first, THUMBNAIL_SIZE_SLA.second, true, false);
|
||||
{
|
||||
this->thumbnail_data.clear();
|
||||
for (const std::pair<unsigned int, unsigned int>& size : THUMBNAIL_SIZE_SLA)
|
||||
{
|
||||
this->thumbnail_data.push_back(ThumbnailData());
|
||||
generate_thumbnail(this->thumbnail_data.back(), size.first, size.second, true, false);
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||
*/
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue