mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-08-14 08:06:06 +08:00
NEW:add no light thumbnail
Jira: none Change-Id: I3c0510dd4d7e444f1a6326b7a59a0ebd5e7aa410 (cherry picked from commit a3d8c36783716e24f39803a8c146a43b1014c092)
This commit is contained in:
parent
23b46e7d09
commit
47c442a61e
@ -1,5 +1,6 @@
|
||||
#version 110
|
||||
|
||||
uniform bool ban_light;
|
||||
uniform vec4 uniform_color;
|
||||
uniform float emission_factor;
|
||||
|
||||
@ -12,5 +13,9 @@ void main()
|
||||
{
|
||||
if (world_pos.z < 0.0)
|
||||
discard;
|
||||
gl_FragColor = vec4(vec3(intensity.y) + uniform_color.rgb * (intensity.x + emission_factor), uniform_color.a);
|
||||
if(ban_light){
|
||||
gl_FragColor = uniform_color;
|
||||
} else{
|
||||
gl_FragColor = vec4(vec3(intensity.y) + uniform_color.rgb * (intensity.x + emission_factor), uniform_color.a);
|
||||
}
|
||||
}
|
||||
|
@ -4796,7 +4796,7 @@ int CLI::run(int argc, char **argv)
|
||||
global_begin_time = (long long)Slic3r::Utils::get_current_time_utc();
|
||||
if (export_to_3mf) {
|
||||
//BBS: export as bbl 3mf
|
||||
std::vector<ThumbnailData *> thumbnails, top_thumbnails, pick_thumbnails;
|
||||
std::vector<ThumbnailData *> thumbnails, no_light_thumbnails, top_thumbnails, pick_thumbnails;
|
||||
std::vector<PlateBBoxData*> plate_bboxes;
|
||||
PlateDataPtrs plate_data_list;
|
||||
partplate_list.store_to_3mf_structure(plate_data_list);
|
||||
@ -5136,9 +5136,11 @@ int CLI::run(int argc, char **argv)
|
||||
else{
|
||||
ThumbnailData* top_thumbnail = &part_plate->top_thumbnail_data;
|
||||
ThumbnailData* picking_thumbnail = &part_plate->pick_thumbnail_data;
|
||||
ThumbnailData *no_light_thumbnail = &part_plate->no_light_thumbnail_data;
|
||||
if ((plate_to_slice != 0) && (plate_to_slice != (i + 1))) {
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("Line %1%: regenerate thumbnail, Skip plate %2%.")%__LINE__%(i+1);
|
||||
part_plate->top_thumbnail_data.reset();
|
||||
part_plate->no_light_thumbnail_data.reset();
|
||||
part_plate->pick_thumbnail_data.reset();
|
||||
plate_data->top_file.clear();
|
||||
plate_data->pick_file.clear();
|
||||
@ -5151,6 +5153,7 @@ int CLI::run(int argc, char **argv)
|
||||
if (skip_useless_pick && ((plate_object_count[i] <= 1) || (plate_object_count[i] > 64)))
|
||||
{
|
||||
//don't render pick and top
|
||||
part_plate->no_light_thumbnail_data.reset();
|
||||
part_plate->top_thumbnail_data.reset();
|
||||
part_plate->pick_thumbnail_data.reset();
|
||||
plate_data->top_file.clear();
|
||||
@ -5194,6 +5197,7 @@ int CLI::run(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (need_create_top_group) {
|
||||
no_light_thumbnails.push_back(&part_plate->no_light_thumbnail_data);
|
||||
top_thumbnails.push_back(&part_plate->top_thumbnail_data);
|
||||
pick_thumbnails.push_back(&part_plate->pick_thumbnail_data);
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("plate %1%: add thumbnail data for top and pick into group")%(i+1);
|
||||
@ -5246,6 +5250,7 @@ int CLI::run(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (need_create_top_group) {
|
||||
no_light_thumbnails.push_back(&part_plate->no_light_thumbnail_data);
|
||||
top_thumbnails.push_back(&part_plate->top_thumbnail_data);
|
||||
pick_thumbnails.push_back(&part_plate->pick_thumbnail_data);
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("plate %1%: add thumbnail data for top and pick into group")%(i+1);
|
||||
@ -5390,7 +5395,7 @@ int CLI::run(int argc, char **argv)
|
||||
model.mk_version = makerlab_version;
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("mk_name %1%, mk_version %2%")%makerlab_name %makerlab_version;
|
||||
}
|
||||
if (! this->export_project(&m_models[0], export_3mf_file, plate_data_list, project_presets, thumbnails, top_thumbnails, pick_thumbnails,
|
||||
if (!this->export_project(&m_models[0], export_3mf_file, plate_data_list, project_presets, thumbnails, no_light_thumbnails, top_thumbnails, pick_thumbnails,
|
||||
calibration_thumbnails, plate_bboxes, &m_print_config, minimum_save, plate_to_slice - 1))
|
||||
{
|
||||
release_PlateData_list(plate_data_list);
|
||||
@ -5400,6 +5405,8 @@ int CLI::run(int argc, char **argv)
|
||||
|
||||
for (unsigned int i = 0; i < thumbnails.size(); i++)
|
||||
thumbnails[i]->reset();
|
||||
for (unsigned int i = 0; i < no_light_thumbnails.size(); i++)
|
||||
no_light_thumbnails[i]->reset();
|
||||
for (unsigned int i = 0; i < top_thumbnails.size(); i++)
|
||||
top_thumbnails[i]->reset();
|
||||
for (unsigned int i = 0; i < pick_thumbnails.size(); i++)
|
||||
@ -5614,7 +5621,11 @@ bool CLI::export_models(IO::ExportFormat format)
|
||||
|
||||
//BBS: add export_project function
|
||||
bool CLI::export_project(Model *model, std::string& path, PlateDataPtrs &partplate_data,
|
||||
std::vector<Preset*>& project_presets, std::vector<ThumbnailData*>& thumbnails, std::vector<ThumbnailData*>& top_thumbnails, std::vector<ThumbnailData*>& pick_thumbnails,
|
||||
std::vector<Preset *> & project_presets,
|
||||
std::vector<ThumbnailData *> &thumbnails,
|
||||
std::vector<ThumbnailData *> &no_light_thumbnails,
|
||||
std::vector<ThumbnailData *> &top_thumbnails,
|
||||
std::vector<ThumbnailData *> &pick_thumbnails,
|
||||
std::vector<ThumbnailData*>& calibration_thumbnails, std::vector<PlateBBoxData*>& plate_bboxes, const DynamicPrintConfig* config, bool minimum_save, int plate_to_export)
|
||||
{
|
||||
//const std::string path = this->output_filepath(*model, IO::TMF);
|
||||
@ -5627,6 +5638,7 @@ bool CLI::export_project(Model *model, std::string& path, PlateDataPtrs &partpla
|
||||
store_params.project_presets = project_presets;
|
||||
store_params.config = (DynamicPrintConfig*)config;
|
||||
store_params.thumbnail_data = thumbnails;
|
||||
store_params.no_light_thumbnail_data = no_light_thumbnails;
|
||||
store_params.top_thumbnail_data = top_thumbnails;
|
||||
store_params.pick_thumbnail_data = pick_thumbnails;
|
||||
store_params.calibration_thumbnail_data = calibration_thumbnails;
|
||||
|
@ -89,7 +89,10 @@ private:
|
||||
bool export_models(IO::ExportFormat format);
|
||||
//BBS: add export_project function
|
||||
bool export_project(Model *model, std::string& path, PlateDataPtrs &partplate_data, std::vector<Preset*>& project_presets,
|
||||
std::vector<ThumbnailData*>& thumbnails, std::vector<ThumbnailData*>& top_thumbnails, std::vector<ThumbnailData*>& pick_thumbnails,
|
||||
std::vector<ThumbnailData *> &thumbnails,
|
||||
std::vector<ThumbnailData *> &no_light_thumbnails,
|
||||
std::vector<ThumbnailData *> &top_thumbnails,
|
||||
std::vector<ThumbnailData *> &pick_thumbnails,
|
||||
std::vector<ThumbnailData*>& calibration_thumbnails,
|
||||
std::vector<PlateBBoxData*>& plate_bboxes, const DynamicPrintConfig* config, bool minimum_save, int plate_to_export = -1);
|
||||
|
||||
|
@ -5271,6 +5271,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
||||
std::vector<Preset*>& project_presets,
|
||||
const DynamicPrintConfig* config,
|
||||
const std::vector<ThumbnailData*>& thumbnail_data,
|
||||
const std::vector<ThumbnailData *>& no_light_thumbnail_data,
|
||||
const std::vector<ThumbnailData*>& top_thumbnail_data,
|
||||
const std::vector<ThumbnailData*>& pick_thumbnail_data,
|
||||
Export3mfProgressFn proFn,
|
||||
@ -5357,7 +5358,8 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
||||
boost::filesystem::remove(filename + ".tmp", ec);
|
||||
|
||||
bool result = _save_model_to_file(filename + ".tmp", *store_params.model, store_params.plate_data_list, store_params.project_presets, store_params.config,
|
||||
store_params.thumbnail_data, store_params.top_thumbnail_data, store_params.pick_thumbnail_data, store_params.proFn,
|
||||
store_params.thumbnail_data, store_params.no_light_thumbnail_data, store_params.top_thumbnail_data, store_params.pick_thumbnail_data,
|
||||
store_params.proFn,
|
||||
store_params.calibration_thumbnail_data, store_params.id_bboxes, store_params.project, store_params.export_plate_idx);
|
||||
if (result) {
|
||||
boost::filesystem::rename(filename + ".tmp", filename, ec);
|
||||
@ -5433,6 +5435,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
||||
std::vector<Preset*>& project_presets,
|
||||
const DynamicPrintConfig* config,
|
||||
const std::vector<ThumbnailData*>& thumbnail_data,
|
||||
const std::vector<ThumbnailData*>& no_light_thumbnail_data,
|
||||
const std::vector<ThumbnailData*>& top_thumbnail_data,
|
||||
const std::vector<ThumbnailData*>& pick_thumbnail_data,
|
||||
Export3mfProgressFn proFn,
|
||||
@ -5505,6 +5508,11 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
||||
% thumbnail_data.size() %plate_data_list.size();
|
||||
return false;
|
||||
}
|
||||
if ((no_light_thumbnail_data.size() > 0) && (no_light_thumbnail_data.size() > plate_data_list.size())) {
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ":" << __LINE__ << boost::format(", no_light_thumbnail_data size %1% > plate count %2%") %
|
||||
no_light_thumbnail_data.size() % plate_data_list.size();
|
||||
return false;
|
||||
}
|
||||
if ((top_thumbnail_data.size() > 0)&&(top_thumbnail_data.size() > plate_data_list.size())) {
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ":" << __LINE__ << boost::format(", top_thumbnail_data size %1% > plate count %2%")
|
||||
% top_thumbnail_data.size() %plate_data_list.size();
|
||||
@ -5540,6 +5548,16 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int index = 0; index < no_light_thumbnail_data.size(); index++) {
|
||||
if (no_light_thumbnail_data[index]->is_valid()) {
|
||||
if (!_add_thumbnail_file_to_archive(archive, *no_light_thumbnail_data[index], "Metadata/plate_no_light", index)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format(",add no light thumbnail %1%'s data into 3mf") % (index + 1);
|
||||
thumbnail_status[index] = true;
|
||||
}
|
||||
}
|
||||
// Adds the file Metadata/top_i.png and Metadata/pick_i.png
|
||||
for (unsigned int index = 0; index < top_thumbnail_data.size(); index++)
|
||||
{
|
||||
|
@ -213,6 +213,7 @@ struct StoreParams
|
||||
std::vector<Preset*> project_presets;
|
||||
DynamicPrintConfig* config;
|
||||
std::vector<ThumbnailData*> thumbnail_data;
|
||||
std::vector<ThumbnailData*> no_light_thumbnail_data;
|
||||
std::vector<ThumbnailData*> top_thumbnail_data;
|
||||
std::vector<ThumbnailData*> pick_thumbnail_data;
|
||||
std::vector<ThumbnailData*> calibration_thumbnail_data;
|
||||
|
@ -911,7 +911,7 @@ void GLVolume::render(bool with_outline, const std::array<float, 4>& body_color)
|
||||
}
|
||||
|
||||
//BBS add render for simple case
|
||||
void GLVolume::simple_render(GLShaderProgram* shader, ModelObjectPtrs& model_objects, std::vector<std::array<float, 4>>& extruder_colors) const
|
||||
void GLVolume::simple_render(GLShaderProgram *shader, ModelObjectPtrs &model_objects, std::vector<std::array<float, 4>> &extruder_colors, bool ban_light) const
|
||||
{
|
||||
if (this->is_left_handed())
|
||||
glFrontFace(GL_CW);
|
||||
@ -959,6 +959,9 @@ void GLVolume::simple_render(GLShaderProgram* shader, ModelObjectPtrs& model_obj
|
||||
int extruder_id = model_volume->extruder_id();
|
||||
//to make black not too hard too see
|
||||
std::array<float, 4> new_color = adjust_color_for_rendering(extruder_colors[extruder_id - 1]);
|
||||
if (ban_light) {
|
||||
new_color[3] = (255 - (extruder_id - 1))/255.0f;
|
||||
}
|
||||
shader->set_uniform("uniform_color", new_color);
|
||||
}
|
||||
else {
|
||||
@ -966,12 +969,18 @@ void GLVolume::simple_render(GLShaderProgram* shader, ModelObjectPtrs& model_obj
|
||||
//shader->set_uniform("uniform_color", extruder_colors[idx - 1]);
|
||||
//to make black not too hard too see
|
||||
std::array<float, 4> new_color = adjust_color_for_rendering(extruder_colors[idx - 1]);
|
||||
if (ban_light) {
|
||||
new_color[3] = (255 - (idx - 1))/255.0f;
|
||||
}
|
||||
shader->set_uniform("uniform_color", new_color);
|
||||
}
|
||||
else {
|
||||
//shader->set_uniform("uniform_color", extruder_colors[0]);
|
||||
//to make black not too hard too see
|
||||
std::array<float, 4> new_color = adjust_color_for_rendering(extruder_colors[0]);
|
||||
if (ban_light) {
|
||||
new_color[3] = (255 - 0) / 255.0f;
|
||||
}
|
||||
shader->set_uniform("uniform_color", new_color);
|
||||
}
|
||||
}
|
||||
|
@ -528,7 +528,7 @@ public:
|
||||
const std::array<float, 4> &body_color = {1.0f, 1.0f, 1.0f, 1.0f} ) const;
|
||||
|
||||
//BBS: add simple render function for thumbnail
|
||||
void simple_render(GLShaderProgram* shader, ModelObjectPtrs& model_objects, std::vector<std::array<float, 4>>& extruder_colors) const;
|
||||
void simple_render(GLShaderProgram* shader, ModelObjectPtrs& model_objects, std::vector<std::array<float, 4>>& extruder_colors,bool ban_light =false) const;
|
||||
|
||||
void finalize_geometry(bool opengl_initialized) { this->indexed_vertex_array->finalize_geometry(opengl_initialized); }
|
||||
void release_geometry() { this->indexed_vertex_array->release_geometry(); }
|
||||
|
@ -2076,13 +2076,24 @@ void GLCanvas3D::render(bool only_init)
|
||||
m_render_stats.increment_fps_counter();
|
||||
}
|
||||
|
||||
void GLCanvas3D::render_thumbnail(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, const ThumbnailsParams& thumbnail_params, Camera::EType camera_type, bool use_top_view, bool for_picking)
|
||||
void GLCanvas3D::render_thumbnail(ThumbnailData & thumbnail_data,
|
||||
unsigned int w,
|
||||
unsigned int h,
|
||||
const ThumbnailsParams &thumbnail_params,
|
||||
Camera::EType camera_type,
|
||||
bool use_top_view,
|
||||
bool for_picking,
|
||||
bool ban_light)
|
||||
{
|
||||
render_thumbnail(thumbnail_data, w, h, thumbnail_params, m_volumes, camera_type, use_top_view, for_picking);
|
||||
render_thumbnail(thumbnail_data, w, h, thumbnail_params, m_volumes, camera_type, use_top_view, for_picking, ban_light);
|
||||
}
|
||||
|
||||
void GLCanvas3D::render_thumbnail(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, const ThumbnailsParams& thumbnail_params,
|
||||
const GLVolumeCollection& volumes, Camera::EType camera_type, bool use_top_view, bool for_picking)
|
||||
const GLVolumeCollection &volumes,
|
||||
Camera::EType camera_type,
|
||||
bool use_top_view,
|
||||
bool for_picking,
|
||||
bool ban_light)
|
||||
{
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("thumbnail");
|
||||
ModelObjectPtrs& model_objects = GUI::wxGetApp().model().objects;
|
||||
@ -2090,14 +2101,19 @@ void GLCanvas3D::render_thumbnail(ThumbnailData& thumbnail_data, unsigned int w,
|
||||
switch (OpenGLManager::get_framebuffers_type())
|
||||
{
|
||||
case OpenGLManager::EFramebufferType::Arb:
|
||||
{ render_thumbnail_framebuffer(thumbnail_data, w, h, thumbnail_params,
|
||||
wxGetApp().plater()->get_partplate_list(), model_objects, volumes, colors, shader, camera_type, use_top_view, for_picking); break; }
|
||||
{ render_thumbnail_framebuffer(thumbnail_data, w, h, thumbnail_params, wxGetApp().plater()->get_partplate_list(), model_objects, volumes, colors, shader, camera_type,
|
||||
use_top_view, for_picking, ban_light);
|
||||
break;
|
||||
}
|
||||
case OpenGLManager::EFramebufferType::Ext:
|
||||
{ render_thumbnail_framebuffer_ext(thumbnail_data, w, h, thumbnail_params,
|
||||
wxGetApp().plater()->get_partplate_list(), model_objects, volumes, colors, shader, camera_type, use_top_view, for_picking); break; }
|
||||
{ render_thumbnail_framebuffer_ext(thumbnail_data, w, h, thumbnail_params, wxGetApp().plater()->get_partplate_list(), model_objects, volumes, colors, shader, camera_type,
|
||||
use_top_view, for_picking, ban_light);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{ render_thumbnail_legacy(thumbnail_data, w, h, thumbnail_params,
|
||||
wxGetApp().plater()->get_partplate_list(), model_objects, volumes, colors, shader, camera_type); break; }
|
||||
{ render_thumbnail_legacy(thumbnail_data, w, h, thumbnail_params, wxGetApp().plater()->get_partplate_list(), model_objects, volumes, colors, shader, camera_type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5644,7 +5660,11 @@ static void debug_output_thumbnail(const ThumbnailData& thumbnail_data)
|
||||
|
||||
void GLCanvas3D::render_thumbnail_internal(ThumbnailData& thumbnail_data, const ThumbnailsParams& thumbnail_params,
|
||||
PartPlateList& partplate_list, ModelObjectPtrs& model_objects, const GLVolumeCollection& volumes, std::vector<std::array<float, 4>>& extruder_colors,
|
||||
GLShaderProgram* shader, Camera::EType camera_type, bool use_top_view, bool for_picking)
|
||||
GLShaderProgram * shader,
|
||||
Camera::EType camera_type,
|
||||
bool use_top_view,
|
||||
bool for_picking,
|
||||
bool ban_light)
|
||||
{
|
||||
//BBS modify visible calc function
|
||||
int plate_idx = thumbnail_params.plate_id;
|
||||
@ -5832,6 +5852,7 @@ void GLCanvas3D::render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
||||
else {
|
||||
shader->start_using();
|
||||
shader->set_uniform("emission_factor", 0.1f);
|
||||
shader->set_uniform("ban_light", ban_light);
|
||||
for (GLVolume* vol : visible_volumes) {
|
||||
//BBS set render color for thumbnails
|
||||
curr_color[0] = vol->color[0];
|
||||
@ -5840,6 +5861,9 @@ void GLCanvas3D::render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
||||
curr_color[3] = vol->color[3];
|
||||
|
||||
std::array<float, 4> new_color = adjust_color_for_rendering(curr_color);
|
||||
if (ban_light) {
|
||||
new_color[3] =(255 - vol->extruder_id)/255.0f;
|
||||
}
|
||||
shader->set_uniform("uniform_color", new_color);
|
||||
shader->set_uniform("volume_world_matrix", vol->world_matrix());
|
||||
//BBS set all volume to orange
|
||||
@ -5853,7 +5877,7 @@ void GLCanvas3D::render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
||||
// the volume may have been deactivated by an active gizmo
|
||||
bool is_active = vol->is_active;
|
||||
vol->is_active = true;
|
||||
vol->simple_render(shader, model_objects, extruder_colors);
|
||||
vol->simple_render(shader, model_objects, extruder_colors, ban_light);
|
||||
vol->is_active = is_active;
|
||||
}
|
||||
shader->stop_using();
|
||||
@ -5872,7 +5896,11 @@ void GLCanvas3D::render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
||||
|
||||
void GLCanvas3D::render_thumbnail_framebuffer(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, const ThumbnailsParams& thumbnail_params,
|
||||
PartPlateList& partplate_list, ModelObjectPtrs& model_objects, const GLVolumeCollection& volumes, std::vector<std::array<float, 4>>& extruder_colors,
|
||||
GLShaderProgram* shader, Camera::EType camera_type, bool use_top_view, bool for_picking)
|
||||
GLShaderProgram * shader,
|
||||
Camera::EType camera_type,
|
||||
bool use_top_view,
|
||||
bool for_picking,
|
||||
bool ban_light)
|
||||
{
|
||||
thumbnail_data.set(w, h);
|
||||
if (!thumbnail_data.is_valid())
|
||||
@ -5925,7 +5953,8 @@ void GLCanvas3D::render_thumbnail_framebuffer(ThumbnailData& thumbnail_data, uns
|
||||
glsafe(::glDrawBuffers(1, drawBufs));
|
||||
|
||||
if (::glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE) {
|
||||
render_thumbnail_internal(thumbnail_data, thumbnail_params, partplate_list, model_objects, volumes, extruder_colors, shader, camera_type, use_top_view, for_picking);
|
||||
render_thumbnail_internal(thumbnail_data, thumbnail_params, partplate_list, model_objects, volumes, extruder_colors, shader,
|
||||
camera_type, use_top_view, for_picking,ban_light);
|
||||
|
||||
if (multisample) {
|
||||
GLuint resolve_fbo;
|
||||
@ -5980,7 +6009,11 @@ void GLCanvas3D::render_thumbnail_framebuffer(ThumbnailData& thumbnail_data, uns
|
||||
|
||||
void GLCanvas3D::render_thumbnail_framebuffer_ext(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, const ThumbnailsParams& thumbnail_params,
|
||||
PartPlateList& partplate_list, ModelObjectPtrs& model_objects, const GLVolumeCollection& volumes, std::vector<std::array<float, 4>>& extruder_colors,
|
||||
GLShaderProgram* shader, Camera::EType camera_type, bool use_top_view, bool for_picking)
|
||||
GLShaderProgram * shader,
|
||||
Camera::EType camera_type,
|
||||
bool use_top_view,
|
||||
bool for_picking,
|
||||
bool ban_light)
|
||||
{
|
||||
thumbnail_data.set(w, h);
|
||||
if (!thumbnail_data.is_valid())
|
||||
@ -6032,7 +6065,8 @@ void GLCanvas3D::render_thumbnail_framebuffer_ext(ThumbnailData& thumbnail_data,
|
||||
glsafe(::glDrawBuffers(1, drawBufs));
|
||||
|
||||
if (::glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) == GL_FRAMEBUFFER_COMPLETE_EXT) {
|
||||
render_thumbnail_internal(thumbnail_data, thumbnail_params, partplate_list, model_objects, volumes, extruder_colors, shader, camera_type, use_top_view, for_picking);
|
||||
render_thumbnail_internal(thumbnail_data, thumbnail_params, partplate_list, model_objects, volumes, extruder_colors, shader, camera_type, use_top_view, for_picking,
|
||||
ban_light);
|
||||
|
||||
if (multisample) {
|
||||
GLuint resolve_fbo;
|
||||
|
@ -846,20 +846,39 @@ public:
|
||||
// printable_only == false -> render also non printable volumes as grayed
|
||||
// parts_only == false -> render also sla support and pad
|
||||
void render_thumbnail(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, const ThumbnailsParams& thumbnail_params,
|
||||
Camera::EType camera_type, bool use_top_view = false, bool for_picking = false);
|
||||
Camera::EType camera_type,
|
||||
bool use_top_view = false,
|
||||
bool for_picking = false,
|
||||
bool ban_light = false);
|
||||
void render_thumbnail(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, const ThumbnailsParams& thumbnail_params,
|
||||
const GLVolumeCollection& volumes, Camera::EType camera_type, bool use_top_view = false, bool for_picking = false);
|
||||
const GLVolumeCollection &volumes,
|
||||
Camera::EType camera_type,
|
||||
bool use_top_view = false,
|
||||
bool for_picking = false,
|
||||
bool ban_light = false);
|
||||
static void render_thumbnail_internal(ThumbnailData& thumbnail_data, const ThumbnailsParams& thumbnail_params, PartPlateList& partplate_list, ModelObjectPtrs& model_objects,
|
||||
const GLVolumeCollection& volumes, std::vector<std::array<float, 4>>& extruder_colors,
|
||||
GLShaderProgram* shader, Camera::EType camera_type, bool use_top_view = false, bool for_picking = false);
|
||||
GLShaderProgram * shader,
|
||||
Camera::EType camera_type,
|
||||
bool use_top_view = false,
|
||||
bool for_picking = false,
|
||||
bool ban_light = false);
|
||||
// render thumbnail using an off-screen framebuffer
|
||||
static void render_thumbnail_framebuffer(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, const ThumbnailsParams& thumbnail_params,
|
||||
PartPlateList& partplate_list, ModelObjectPtrs& model_objects, const GLVolumeCollection& volumes, std::vector<std::array<float, 4>>& extruder_colors,
|
||||
GLShaderProgram* shader, Camera::EType camera_type, bool use_top_view = false, bool for_picking = false);
|
||||
GLShaderProgram * shader,
|
||||
Camera::EType camera_type,
|
||||
bool use_top_view = false,
|
||||
bool for_picking = false,
|
||||
bool ban_light = false);
|
||||
// render thumbnail using an off-screen framebuffer when GLEW_EXT_framebuffer_object is supported
|
||||
static void render_thumbnail_framebuffer_ext(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, const ThumbnailsParams& thumbnail_params,
|
||||
PartPlateList& partplate_list, ModelObjectPtrs& model_objects, const GLVolumeCollection& volumes, std::vector<std::array<float, 4>>& extruder_colors,
|
||||
GLShaderProgram* shader, Camera::EType camera_type, bool use_top_view = false, bool for_picking = false);
|
||||
GLShaderProgram * shader,
|
||||
Camera::EType camera_type,
|
||||
bool use_top_view = false,
|
||||
bool for_picking = false,
|
||||
bool ban_light = false);
|
||||
|
||||
//BBS use gcoder viewer render calibration thumbnails
|
||||
void render_calibration_thumbnail(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, const ThumbnailsParams& thumbnail_params);
|
||||
|
@ -4196,6 +4196,7 @@ int PartPlateList::notify_instance_update(int obj_id, int instance_id, bool is_n
|
||||
PartPlate* plate = m_plate_list[obj_id - 1000];
|
||||
plate->update_slice_result_valid_state( false );
|
||||
plate->thumbnail_data.reset();
|
||||
plate->no_light_thumbnail_data.reset();
|
||||
plate->top_thumbnail_data.reset();
|
||||
plate->pick_thumbnail_data.reset();
|
||||
|
||||
@ -4226,12 +4227,14 @@ int PartPlateList::notify_instance_update(int obj_id, int instance_id, bool is_n
|
||||
plate->update_states();
|
||||
plate->update_slice_result_valid_state();
|
||||
plate->thumbnail_data.reset();
|
||||
plate->no_light_thumbnail_data.reset();
|
||||
plate->top_thumbnail_data.reset();
|
||||
plate->pick_thumbnail_data.reset();
|
||||
return 0;
|
||||
}
|
||||
plate->update_slice_result_valid_state();
|
||||
plate->thumbnail_data.reset();
|
||||
plate->no_light_thumbnail_data.reset();
|
||||
plate->top_thumbnail_data.reset();
|
||||
plate->pick_thumbnail_data.reset();
|
||||
}
|
||||
@ -4293,6 +4296,7 @@ int PartPlateList::notify_instance_update(int obj_id, int instance_id, bool is_n
|
||||
|
||||
plate->update_slice_result_valid_state();
|
||||
plate->thumbnail_data.reset();
|
||||
plate->no_light_thumbnail_data.reset();
|
||||
plate->top_thumbnail_data.reset();
|
||||
plate->pick_thumbnail_data.reset();
|
||||
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(": add it to new plate %1%") % i;
|
||||
@ -4330,6 +4334,7 @@ int PartPlateList::notify_instance_removed(int obj_id, int instance_id)
|
||||
plate->remove_instance(obj_id, instance_to_delete);
|
||||
plate->update_slice_result_valid_state();
|
||||
plate->thumbnail_data.reset();
|
||||
plate->no_light_thumbnail_data.reset();
|
||||
plate->top_thumbnail_data.reset();
|
||||
plate->pick_thumbnail_data.reset();
|
||||
}
|
||||
|
@ -256,6 +256,7 @@ public:
|
||||
//static const int plate_x_offset = 20; //mm
|
||||
//static const double plate_x_gap = 0.2;
|
||||
ThumbnailData thumbnail_data;
|
||||
ThumbnailData no_light_thumbnail_data;
|
||||
static const int plate_thumbnail_width = 512;
|
||||
static const int plate_thumbnail_height = 512;
|
||||
|
||||
|
@ -2635,7 +2635,7 @@ struct Plater::priv
|
||||
|
||||
//BBS: add plate_id for thumbnail
|
||||
void generate_thumbnail(ThumbnailData& data, unsigned int w, unsigned int h, const ThumbnailsParams& thumbnail_params,
|
||||
Camera::EType camera_type, bool use_top_view = false, bool for_picking = false);
|
||||
Camera::EType camera_type, bool use_top_view = false, bool for_picking = false,bool ban_light = false);
|
||||
ThumbnailsList generate_thumbnails(const ThumbnailsParams& params, Camera::EType camera_type);
|
||||
//BBS
|
||||
void generate_calibration_thumbnail(ThumbnailData& data, unsigned int w, unsigned int h, const ThumbnailsParams& thumbnail_params);
|
||||
@ -7347,10 +7347,9 @@ void Plater::priv::on_3dcanvas_mouse_dragging_finished(SimpleEvent&)
|
||||
}
|
||||
|
||||
//BBS: add plate id for thumbnail generate param
|
||||
void Plater::priv::generate_thumbnail(ThumbnailData& data, unsigned int w, unsigned int h, const ThumbnailsParams& thumbnail_params,
|
||||
Camera::EType camera_type, bool use_top_view, bool for_picking)
|
||||
void Plater::priv::generate_thumbnail(ThumbnailData& data, unsigned int w, unsigned int h, const ThumbnailsParams& thumbnail_params, Camera::EType camera_type, bool use_top_view, bool for_picking, bool ban_light)
|
||||
{
|
||||
view3D->get_canvas3d()->render_thumbnail(data, w, h, thumbnail_params, camera_type, use_top_view, for_picking);
|
||||
view3D->get_canvas3d()->render_thumbnail(data, w, h, thumbnail_params, camera_type, use_top_view, for_picking, ban_light);
|
||||
}
|
||||
|
||||
//BBS: add plate id for thumbnail generate param
|
||||
@ -9880,6 +9879,10 @@ void Plater::update_all_plate_thumbnails(bool force_update)
|
||||
if (force_update || !plate->thumbnail_data.is_valid()) {
|
||||
get_view3D_canvas3D()->render_thumbnail(plate->thumbnail_data, plate->plate_thumbnail_width, plate->plate_thumbnail_height, thumbnail_params, Camera::EType::Ortho);
|
||||
}
|
||||
if (force_update || !plate->no_light_thumbnail_data.is_valid()) {
|
||||
get_view3D_canvas3D()->render_thumbnail(plate->no_light_thumbnail_data, plate->plate_thumbnail_width, plate->plate_thumbnail_height, thumbnail_params,
|
||||
Camera::EType::Ortho,false,false,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -9892,6 +9895,7 @@ void Plater::invalid_all_plate_thumbnails()
|
||||
for (int i = 0; i < get_partplate_list().get_plate_count(); i++) {
|
||||
PartPlate* plate = get_partplate_list().get_plate(i);
|
||||
plate->thumbnail_data.reset();
|
||||
plate->no_light_thumbnail_data.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@ -11522,6 +11526,7 @@ int Plater::export_3mf(const boost::filesystem::path& output_path, SaveStrategy
|
||||
|
||||
//BBS: add plate logic for thumbnail generate
|
||||
std::vector<ThumbnailData*> thumbnails;
|
||||
std::vector<ThumbnailData*> no_light_thumbnails;
|
||||
std::vector<ThumbnailData*> calibration_thumbnails;
|
||||
std::vector<ThumbnailData*> top_thumbnails;
|
||||
std::vector<ThumbnailData*> picking_thumbnails;
|
||||
@ -11542,6 +11547,17 @@ int Plater::export_3mf(const boost::filesystem::path& output_path, SaveStrategy
|
||||
}
|
||||
thumbnails.push_back(thumbnail_data);
|
||||
|
||||
ThumbnailData *no_light_thumbnail_data = &p->partplate_list.get_plate(i)->no_light_thumbnail_data;
|
||||
if (p->partplate_list.get_plate(i)->no_light_thumbnail_data.is_valid() && using_exported_file()) {
|
||||
// no need to generate thumbnail
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": non need to re-generate thumbnail for gcode/exported mode of plate %1%") % i;
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": re-generate thumbnail for plate %1%") % i;
|
||||
const ThumbnailsParams thumbnail_params = {{}, false, true, true, true, i};
|
||||
p->generate_thumbnail(p->partplate_list.get_plate(i)->no_light_thumbnail_data, THUMBNAIL_SIZE_3MF.first, THUMBNAIL_SIZE_3MF.second,
|
||||
thumbnail_params, Camera::EType::Ortho,false,false,true);
|
||||
}
|
||||
no_light_thumbnails.push_back(no_light_thumbnail_data);
|
||||
//ThumbnailData* calibration_data = &p->partplate_list.get_plate(i)->cali_thumbnail_data;
|
||||
//calibration_thumbnails.push_back(calibration_data);
|
||||
PlateBBoxData* plate_bbox_data = &p->partplate_list.get_plate(i)->cali_bboxes_data;
|
||||
@ -11605,6 +11621,7 @@ int Plater::export_3mf(const boost::filesystem::path& output_path, SaveStrategy
|
||||
store_params.project_presets = project_presets;
|
||||
store_params.config = export_config ? &cfg : nullptr;
|
||||
store_params.thumbnail_data = thumbnails;
|
||||
store_params.no_light_thumbnail_data = no_light_thumbnails;
|
||||
store_params.top_thumbnail_data = top_thumbnails;
|
||||
store_params.pick_thumbnail_data = picking_thumbnails;
|
||||
store_params.calibration_thumbnail_data = calibration_thumbnails;
|
||||
@ -11698,6 +11715,10 @@ int Plater::export_3mf(const boost::filesystem::path& output_path, SaveStrategy
|
||||
//release the data here, as it will always be generated when export
|
||||
calibration_thumbnails[i]->reset();
|
||||
}
|
||||
for (unsigned int i = 0; i < no_light_thumbnails.size(); i++) {
|
||||
// release the data here, as it will always be generated when export
|
||||
no_light_thumbnails[i]->reset();
|
||||
}
|
||||
for (unsigned int i = 0; i < top_thumbnails.size(); i++)
|
||||
{
|
||||
//release the data here, as it will always be generated when export
|
||||
|
@ -1821,6 +1821,7 @@ void SelectMachineDialog::sync_ams_mapping_result(std::vector<FilamentInfo> &res
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
updata_thumbnail_data_after_connected_printer();
|
||||
}
|
||||
|
||||
void print_ams_mapping_result(std::vector<FilamentInfo>& result)
|
||||
@ -2950,6 +2951,11 @@ void SelectMachineDialog::on_set_finish_mapping(wxCommandEvent &evt)
|
||||
BOOST_LOG_TRIVIAL(info) << "The ams mapping selection result: data is " << selection_data;
|
||||
|
||||
if (selection_data_arr.size() == 6) {
|
||||
auto ams_colour = wxColour(wxAtoi(selection_data_arr[0]), wxAtoi(selection_data_arr[1]), wxAtoi(selection_data_arr[2]), wxAtoi(selection_data_arr[3]));
|
||||
int old_filament_id = (int) wxAtoi(selection_data_arr[5]);
|
||||
change_default_normal(old_filament_id, ams_colour);
|
||||
set_default_normal(m_preview_thumbnail_data);//do't reset ams
|
||||
|
||||
int ctype = 0;
|
||||
std::vector<wxColour> material_cols;
|
||||
std::vector<std::string> tray_cols;
|
||||
@ -3355,8 +3361,6 @@ void SelectMachineDialog::on_selection_changed(wxCommandEvent &event)
|
||||
|
||||
show_status(PrintDialogStatus::PrintStatusInit);
|
||||
|
||||
reset_ams_material();
|
||||
|
||||
update_show_status();
|
||||
}
|
||||
|
||||
@ -3931,20 +3935,211 @@ void SelectMachineDialog::set_default()
|
||||
m_checkbox_list["use_ams"]->SetValue(true);
|
||||
|
||||
if (m_print_type == PrintFromType::FROM_NORMAL) {
|
||||
set_default_normal();
|
||||
reset_and_sync_ams_list();
|
||||
set_default_normal(m_plater->get_partplate_list().get_curr_plate()->thumbnail_data);
|
||||
}
|
||||
else if (m_print_type == PrintFromType::FROM_SDCARD_VIEW) {
|
||||
set_default_from_sdcard();
|
||||
}
|
||||
|
||||
|
||||
Layout();
|
||||
Fit();
|
||||
}
|
||||
|
||||
void SelectMachineDialog::set_default_normal()
|
||||
void SelectMachineDialog::reset_and_sync_ams_list()
|
||||
{
|
||||
// for black list
|
||||
std::vector<std::string> materials;
|
||||
std::vector<std::string> brands;
|
||||
std::vector<std::string> display_materials;
|
||||
std::vector<std::string> m_filaments_id;
|
||||
auto preset_bundle = wxGetApp().preset_bundle;
|
||||
|
||||
for (auto filament_name : preset_bundle->filament_presets) {
|
||||
for (int f_index = 0; f_index < preset_bundle->filaments.size(); f_index++) {
|
||||
PresetCollection *filament_presets = &wxGetApp().preset_bundle->filaments;
|
||||
Preset * preset = &filament_presets->preset(f_index);
|
||||
|
||||
if (preset && filament_name.compare(preset->name) == 0) {
|
||||
std::string display_filament_type;
|
||||
std::string filament_type = preset->config.get_filament_type(display_filament_type);
|
||||
std::string m_filament_id = preset->filament_id;
|
||||
display_materials.push_back(display_filament_type);
|
||||
materials.push_back(filament_type);
|
||||
m_filaments_id.push_back(m_filament_id);
|
||||
|
||||
std::string m_vendor_name = "";
|
||||
auto vendor = dynamic_cast<ConfigOptionStrings *>(preset->config.option("filament_vendor"));
|
||||
if (vendor && (vendor->values.size() > 0)) {
|
||||
std::string vendor_name = vendor->values[0];
|
||||
m_vendor_name = vendor_name;
|
||||
}
|
||||
brands.push_back(m_vendor_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto extruders = wxGetApp().plater()->get_partplate_list().get_curr_plate()->get_used_extruders();
|
||||
BitmapCache bmcache;
|
||||
MaterialHash::iterator iter = m_materialList.begin();
|
||||
while (iter != m_materialList.end()) {
|
||||
int id = iter->first;
|
||||
Material *item = iter->second;
|
||||
item->item->Destroy();
|
||||
delete item;
|
||||
iter++;
|
||||
}
|
||||
|
||||
m_sizer_material->Clear();
|
||||
m_materialList.clear();
|
||||
m_filaments.clear();
|
||||
|
||||
for (auto i = 0; i < extruders.size(); i++) {
|
||||
auto extruder = extruders[i] - 1;
|
||||
auto colour = wxGetApp().preset_bundle->project_config.opt_string("filament_colour", (unsigned int) extruder);
|
||||
unsigned char rgb[4];
|
||||
bmcache.parse_color4(colour, rgb);
|
||||
|
||||
auto colour_rgb = wxColour((int) rgb[0], (int) rgb[1], (int) rgb[2], (int) rgb[3]);
|
||||
if (extruder >= materials.size() || extruder < 0 || extruder >= display_materials.size()) continue;
|
||||
|
||||
MaterialItem *item = new MaterialItem(m_scrollable_region, colour_rgb, _L(display_materials[extruder]));
|
||||
m_sizer_material->Add(item, 0, wxALL, FromDIP(4));
|
||||
|
||||
item->Bind(wxEVT_LEFT_UP, [this, item, materials, extruder](wxMouseEvent &e) {});
|
||||
item->Bind(wxEVT_LEFT_DOWN, [this, item, materials, extruder](wxMouseEvent &e) {
|
||||
MaterialHash::iterator iter = m_materialList.begin();
|
||||
while (iter != m_materialList.end()) {
|
||||
int id = iter->first;
|
||||
Material * item = iter->second;
|
||||
MaterialItem *m = item->item;
|
||||
m->on_normal();
|
||||
iter++;
|
||||
}
|
||||
|
||||
m_current_filament_id = extruder;
|
||||
item->on_selected();
|
||||
|
||||
auto mouse_pos = ClientToScreen(e.GetPosition());
|
||||
wxPoint rect = item->ClientToScreen(wxPoint(0, 0));
|
||||
|
||||
// update ams data
|
||||
DeviceManager *dev_manager = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev_manager) return;
|
||||
MachineObject *obj_ = dev_manager->get_selected_machine();
|
||||
|
||||
if (obj_ && obj_->is_support_ams_mapping()) {
|
||||
if (m_mapping_popup.IsShown()) return;
|
||||
wxPoint pos = item->ClientToScreen(wxPoint(0, 0));
|
||||
pos.y += item->GetRect().height;
|
||||
m_mapping_popup.Move(pos);
|
||||
|
||||
if (obj_ && obj_->has_ams() && m_checkbox_list["use_ams"]->GetValue() && obj_->dev_id == m_printer_last_select) {
|
||||
m_mapping_popup.set_parent_item(item);
|
||||
m_mapping_popup.set_current_filament_id(extruder);
|
||||
m_mapping_popup.set_tag_texture(materials[extruder]);
|
||||
m_mapping_popup.update_ams_data(obj_->amsList);
|
||||
m_mapping_popup.Popup();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Material *material_item = new Material();
|
||||
material_item->id = extruder;
|
||||
material_item->item = item;
|
||||
m_materialList[i] = material_item;
|
||||
|
||||
// build for ams mapping
|
||||
if (extruder < materials.size() && extruder >= 0) {
|
||||
FilamentInfo info;
|
||||
info.id = extruder;
|
||||
info.type = materials[extruder];
|
||||
info.brand = brands[extruder];
|
||||
info.filament_id = m_filaments_id[extruder];
|
||||
info.color = wxString::Format("#%02X%02X%02X%02X", colour_rgb.Red(), colour_rgb.Green(), colour_rgb.Blue(), colour_rgb.Alpha()).ToStdString();
|
||||
m_filaments.push_back(info);
|
||||
}
|
||||
}
|
||||
|
||||
if (extruders.size() <= 4) {
|
||||
m_sizer_material->SetCols(extruders.size());
|
||||
} else {
|
||||
m_sizer_material->SetCols(4);
|
||||
}
|
||||
|
||||
// reset_ams_material();//show "-"
|
||||
}
|
||||
|
||||
void SelectMachineDialog::clone_thumbnail_data() {
|
||||
ThumbnailData &data = m_plater->get_partplate_list().get_curr_plate()->thumbnail_data;
|
||||
m_preview_thumbnail_data.reset();
|
||||
m_preview_thumbnail_data.set(data.width, data.height);
|
||||
if (data.width > 0 && data.height > 0) {
|
||||
for (unsigned int r = 0; r < data.height; ++r) {
|
||||
unsigned int rr = (data.height - 1 - r) * data.width;
|
||||
for (unsigned int c = 0; c < data.width; ++c) {
|
||||
unsigned char *origin_px = (unsigned char *) data.pixels.data() + 4 * (rr + c);
|
||||
unsigned char *new_px = (unsigned char *) m_preview_thumbnail_data.pixels.data() + 4 * (rr + c);
|
||||
for (size_t i = 0; i < 4; i++) {
|
||||
new_px[i] = origin_px[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SelectMachineDialog::updata_thumbnail_data_after_connected_printer()
|
||||
{
|
||||
// change thumbnail_data
|
||||
clone_thumbnail_data();
|
||||
MaterialHash::iterator iter = m_materialList.begin();
|
||||
bool is_connect_printer = true;
|
||||
while (iter != m_materialList.end()) {
|
||||
int id = iter->first;
|
||||
Material * item = iter->second;
|
||||
MaterialItem *m = item->item;
|
||||
if (m->m_ams_name == "-") {
|
||||
is_connect_printer = false;
|
||||
break;
|
||||
}
|
||||
change_default_normal(id, m->m_ams_coloul);
|
||||
iter++;
|
||||
}
|
||||
if (is_connect_printer) {
|
||||
set_default_normal(m_preview_thumbnail_data);
|
||||
}
|
||||
}
|
||||
|
||||
void SelectMachineDialog::change_default_normal(int old_filament_id, wxColour temp_ams_color)
|
||||
{
|
||||
std::array<float, 4> _temp_ams_color = {temp_ams_color.Red() / 255.0f, temp_ams_color.Green() / 255.0f, temp_ams_color.Blue() / 255.0f, temp_ams_color.Alpha() / 255.0f};
|
||||
auto __temp_ams_color_ = adjust_color_for_rendering(_temp_ams_color);
|
||||
wxColour ams_color((int)(__temp_ams_color_[0] * 255.0f), (int) (__temp_ams_color_[1] * 255.0f),
|
||||
(int) (__temp_ams_color_[2] * 255.0f), (int)( __temp_ams_color_[3] * 255.0f));
|
||||
ThumbnailData& data =m_plater->get_partplate_list().get_curr_plate()->thumbnail_data;
|
||||
ThumbnailData& no_light_data = m_plater->get_partplate_list().get_curr_plate()->no_light_thumbnail_data;
|
||||
if (data.width > 0 && data.height > 0 && data.width == no_light_data.width && data.height == no_light_data.height) {
|
||||
for (unsigned int r = 0; r < data.height; ++r) {
|
||||
unsigned int rr = (data.height - 1 - r) * data.width;
|
||||
for (unsigned int c = 0; c < data.width; ++c) {
|
||||
unsigned char *no_light_px = (unsigned char *) no_light_data.pixels.data() + 4 * (rr + c);
|
||||
unsigned char *origin_px = (unsigned char *) data.pixels.data() + 4 * (rr + c);
|
||||
unsigned char *new_px = (unsigned char *) m_preview_thumbnail_data.pixels.data() + 4 * (rr + c);
|
||||
if (no_light_px[3] == (255 - old_filament_id)) {
|
||||
new_px[3] = origin_px[3]; // alpha
|
||||
for (size_t i = 0; i < 3; i++) {
|
||||
unsigned char cur_single_color = i == 0 ? ams_color.Red() : (i == 1 ? ams_color.Green() : ams_color.Blue());
|
||||
new_px[i] = std::clamp(cur_single_color + (origin_px[i] - no_light_px[i]),0,255);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SelectMachineDialog::set_default_normal(const ThumbnailData &data)
|
||||
{
|
||||
update_page_turn_state(false);
|
||||
ThumbnailData& data = m_plater->get_partplate_list().get_curr_plate()->thumbnail_data;
|
||||
if (data.is_valid()) {
|
||||
wxImage image(data.width, data.height);
|
||||
image.InitAlpha();
|
||||
@ -3960,136 +4155,6 @@ void SelectMachineDialog::set_default_normal()
|
||||
m_thumbnailPanel->set_thumbnail(image);
|
||||
}
|
||||
|
||||
//for black list
|
||||
std::vector<std::string> materials;
|
||||
std::vector<std::string> brands;
|
||||
std::vector<std::string> display_materials;
|
||||
std::vector<std::string> m_filaments_id;
|
||||
|
||||
|
||||
auto preset_bundle = wxGetApp().preset_bundle;
|
||||
|
||||
for (auto filament_name : preset_bundle->filament_presets) {
|
||||
for (int f_index = 0; f_index < preset_bundle->filaments.size(); f_index++) {
|
||||
PresetCollection* filament_presets = &wxGetApp().preset_bundle->filaments;
|
||||
Preset* preset = &filament_presets->preset(f_index);
|
||||
|
||||
if (preset && filament_name.compare(preset->name) == 0) {
|
||||
std::string display_filament_type;
|
||||
std::string filament_type = preset->config.get_filament_type(display_filament_type);
|
||||
std::string m_filament_id=preset->filament_id;
|
||||
display_materials.push_back(display_filament_type);
|
||||
materials.push_back(filament_type);
|
||||
m_filaments_id.push_back(m_filament_id);
|
||||
|
||||
std::string m_vendor_name = "";
|
||||
auto vendor = dynamic_cast<ConfigOptionStrings*> (preset->config.option("filament_vendor"));
|
||||
if (vendor && (vendor->values.size() > 0)) {
|
||||
std::string vendor_name = vendor->values[0];
|
||||
m_vendor_name = vendor_name;
|
||||
}
|
||||
brands.push_back(m_vendor_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//init MaterialItem
|
||||
auto extruders = wxGetApp().plater()->get_partplate_list().get_curr_plate()->get_used_extruders();
|
||||
BitmapCache bmcache;
|
||||
|
||||
MaterialHash::iterator iter = m_materialList.begin();
|
||||
while (iter != m_materialList.end()) {
|
||||
int id = iter->first;
|
||||
Material* item = iter->second;
|
||||
item->item->Destroy();
|
||||
delete item;
|
||||
iter++;
|
||||
}
|
||||
|
||||
m_sizer_material->Clear();
|
||||
m_materialList.clear();
|
||||
m_filaments.clear();
|
||||
|
||||
for (auto i = 0; i < extruders.size(); i++) {
|
||||
auto extruder = extruders[i] - 1;
|
||||
auto colour = wxGetApp().preset_bundle->project_config.opt_string("filament_colour", (unsigned int) extruder);
|
||||
unsigned char rgb[4];
|
||||
bmcache.parse_color4(colour, rgb);
|
||||
|
||||
auto colour_rgb = wxColour((int) rgb[0], (int) rgb[1], (int) rgb[2], (int) rgb[3]);
|
||||
if (extruder >= materials.size() || extruder < 0 || extruder >= display_materials.size())
|
||||
continue;
|
||||
|
||||
MaterialItem* item = new MaterialItem(m_scrollable_region, colour_rgb, _L(display_materials[extruder]));
|
||||
m_sizer_material->Add(item, 0, wxALL, FromDIP(4));
|
||||
|
||||
item->Bind(wxEVT_LEFT_UP, [this, item, materials, extruder](wxMouseEvent& e) {});
|
||||
item->Bind(wxEVT_LEFT_DOWN, [this, item, materials, extruder](wxMouseEvent& e) {
|
||||
MaterialHash::iterator iter = m_materialList.begin();
|
||||
while (iter != m_materialList.end()) {
|
||||
int id = iter->first;
|
||||
Material* item = iter->second;
|
||||
MaterialItem* m = item->item;
|
||||
m->on_normal();
|
||||
iter++;
|
||||
}
|
||||
|
||||
m_current_filament_id = extruder;
|
||||
item->on_selected();
|
||||
|
||||
|
||||
auto mouse_pos = ClientToScreen(e.GetPosition());
|
||||
wxPoint rect = item->ClientToScreen(wxPoint(0, 0));
|
||||
|
||||
// update ams data
|
||||
DeviceManager* dev_manager = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev_manager) return;
|
||||
MachineObject* obj_ = dev_manager->get_selected_machine();
|
||||
|
||||
if (obj_ && obj_->is_support_ams_mapping()) {
|
||||
if (m_mapping_popup.IsShown()) return;
|
||||
wxPoint pos = item->ClientToScreen(wxPoint(0, 0));
|
||||
pos.y += item->GetRect().height;
|
||||
m_mapping_popup.Move(pos);
|
||||
|
||||
if (obj_ &&
|
||||
obj_->has_ams() &&
|
||||
m_checkbox_list["use_ams"]->GetValue() &&
|
||||
obj_->dev_id == m_printer_last_select)
|
||||
{
|
||||
m_mapping_popup.set_parent_item(item);
|
||||
m_mapping_popup.set_current_filament_id(extruder);
|
||||
m_mapping_popup.set_tag_texture(materials[extruder]);
|
||||
m_mapping_popup.update_ams_data(obj_->amsList);
|
||||
m_mapping_popup.Popup();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Material* material_item = new Material();
|
||||
material_item->id = extruder;
|
||||
material_item->item = item;
|
||||
m_materialList[i] = material_item;
|
||||
|
||||
// build for ams mapping
|
||||
if (extruder < materials.size() && extruder >= 0) {
|
||||
FilamentInfo info;
|
||||
info.id = extruder;
|
||||
info.type = materials[extruder];
|
||||
info.brand = brands[extruder];
|
||||
info.filament_id=m_filaments_id[extruder];
|
||||
info.color = wxString::Format("#%02X%02X%02X%02X", colour_rgb.Red(), colour_rgb.Green(), colour_rgb.Blue(), colour_rgb.Alpha()).ToStdString();
|
||||
m_filaments.push_back(info);
|
||||
}
|
||||
}
|
||||
|
||||
if (extruders.size() <= 4) {
|
||||
m_sizer_material->SetCols(extruders.size());
|
||||
}
|
||||
else {
|
||||
m_sizer_material->SetCols(4);
|
||||
}
|
||||
|
||||
m_scrollable_region->Layout();
|
||||
m_scrollable_region->Fit();
|
||||
|
||||
@ -4118,10 +4183,6 @@ void SelectMachineDialog::set_default_normal()
|
||||
m_scrollable_view->SetScrollRate(0, 0);
|
||||
}
|
||||
#endif // __WXOSX_MAC__
|
||||
|
||||
|
||||
reset_ams_material();
|
||||
|
||||
// basic info
|
||||
auto aprint_stats = m_plater->get_partplate_list().get_current_fff_print().print_statistics();
|
||||
wxString time;
|
||||
|
@ -443,6 +443,7 @@ protected:
|
||||
wxStaticBitmap * img_use_ams_tip{nullptr};
|
||||
wxStaticBitmap * img_ams_backup{nullptr};
|
||||
ScalableBitmap * enable_ams{nullptr};
|
||||
ThumbnailData m_preview_thumbnail_data;//when ams map change
|
||||
|
||||
public:
|
||||
SelectMachineDialog(Plater *plater = nullptr);
|
||||
@ -481,7 +482,11 @@ public:
|
||||
void on_set_finish_mapping(wxCommandEvent& evt);
|
||||
void on_print_job_cancel(wxCommandEvent& evt);
|
||||
void set_default();
|
||||
void set_default_normal();
|
||||
void reset_and_sync_ams_list();
|
||||
void clone_thumbnail_data();
|
||||
void updata_thumbnail_data_after_connected_printer();
|
||||
void change_default_normal(int old_filament_id, wxColour temp_ams_color);
|
||||
void set_default_normal(const ThumbnailData&);
|
||||
void set_default_from_sdcard();
|
||||
void update_page_turn_state(bool show);
|
||||
void on_timer(wxTimerEvent& event);
|
||||
|
Loading…
x
Reference in New Issue
Block a user