NEW:add "obj preview thumnailData" function

jira: none

Change-Id: I688c2f05bf85fca376418115acddb5066ef980eb
(cherry picked from commit 16f2b2bcb5fd157f25aa7012dabd99a8d31aec07)
(cherry picked from commit 7cc21b5e9745a84d75ea13b66f5653520bb1cba3)
This commit is contained in:
zhou.xu
2024-11-05 14:52:12 +08:00
committed by Noisyfox
parent d4d86a5966
commit 926c22b797
13 changed files with 492 additions and 162 deletions

View File

@@ -3524,7 +3524,10 @@ 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,bool ban_light = false);
Camera::EType camera_type,
Camera::ViewAngleType camera_view_angle_type = Camera::ViewAngleType::Iso,
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);
@@ -5016,15 +5019,16 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
std::vector<Preset *> project_presets;
bool is_xxx;
Semver file_version;
//ObjImportColorFn obj_color_fun=nullptr;
auto obj_color_fun = [this, &path](std::vector<RGBA> &input_colors, bool is_single_color, std::vector<unsigned char> &filament_ids,
unsigned char &first_extruder_id) {
auto obj_color_fun = [this, &path](ObjDialogInOut &in_out) {
if (!boost::iends_with(path.string(), ".obj")) { return; }
const std::vector<std::string> extruder_colours = wxGetApp().plater()->get_extruder_colors_from_plater_config();
ObjColorDialog color_dlg(nullptr, input_colors, is_single_color, extruder_colours, filament_ids, first_extruder_id);
ObjColorDialog color_dlg(nullptr, in_out, extruder_colours);
color_dlg.CenterOnScreen();
if (color_dlg.ShowModal() != wxID_OK) {
filament_ids.clear();
in_out.filament_ids.clear();
}
};
if (boost::iends_with(path.string(), ".stp") ||
@@ -6894,11 +6898,13 @@ void Plater::priv::reload_from_disk()
// load one file at a time
for (size_t i = 0; i < input_paths.size(); ++i) {
const auto& path = input_paths[i].string();
auto obj_color_fun = [this, &path](std::vector<RGBA> &input_colors, bool is_single_color, std::vector<unsigned char> &filament_ids, unsigned char &first_extruder_id) {
auto obj_color_fun = [this, &path](ObjDialogInOut &in_out) {
if (!boost::iends_with(path, ".obj")) { return; }
const std::vector<std::string> extruder_colours = wxGetApp().plater()->get_extruder_colors_from_plater_config();
ObjColorDialog color_dlg(nullptr, input_colors, is_single_color, extruder_colours, filament_ids, first_extruder_id);
if (color_dlg.ShowModal() != wxID_OK) { filament_ids.clear(); }
ObjColorDialog color_dlg(nullptr, in_out, extruder_colours);
if (color_dlg.ShowModal() != wxID_OK) {
in_out.filament_ids.clear();
}
};
wxBusyCursor wait;
wxBusyInfo info(_L("Reload from:") + " " + from_u8(path), q->get_current_canvas3D()->get_wxglcanvas());
@@ -8633,9 +8639,16 @@ 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, bool ban_light)
void Plater::priv::generate_thumbnail(ThumbnailData & data,
unsigned int w,
unsigned int h,
const ThumbnailsParams &thumbnail_params,
Camera::EType camera_type,
Camera::ViewAngleType camera_view_angle_type,
bool for_picking,
bool ban_light)
{
view3D->get_canvas3d()->render_thumbnail(data, w, h, thumbnail_params, camera_type, use_top_view, for_picking, ban_light);
view3D->get_canvas3d()->render_thumbnail(data, w, h, thumbnail_params, camera_type, camera_view_angle_type, for_picking, ban_light);
}
//BBS: add plate id for thumbnail generate param
@@ -11565,11 +11578,23 @@ void Plater::update_all_plate_thumbnails(bool force_update)
}
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);
Camera::EType::Ortho, Camera::ViewAngleType::Iso, false, true);
}
}
}
void Plater::update_obj_preview_thumbnail(ModelObject *mo, int obj_idx, int vol_idx, std::vector<Slic3r::ColorRGBA> colors, int camera_view_angle_type)
{
PartPlate * plate = get_partplate_list().get_plate(0);
ThumbnailsParams thumbnail_params = {{}, false, true, true, true, 0, false};
GLVolumeCollection cur_volumes;
cur_volumes.load_object_volume(mo, obj_idx, vol_idx, 0, "volume", true, false, false, false);
ModelObjectPtrs model_objects;
model_objects.emplace_back(mo);
get_view3D_canvas3D()->render_thumbnail(plate->obj_preview_thumbnail_data, colors, plate->plate_thumbnail_width, plate->plate_thumbnail_height, thumbnail_params,
model_objects, cur_volumes, Camera::EType::Ortho, (Camera::ViewAngleType) camera_view_angle_type, false, true);
}
//invalid all plate's thumbnails
void Plater::invalid_all_plate_thumbnails()
{
@@ -13411,8 +13436,8 @@ int Plater::export_3mf(const boost::filesystem::path& output_path, SaveStrategy
} 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);
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, Camera::ViewAngleType::Iso, false, true);
}
no_light_thumbnails.push_back(no_light_thumbnail_data);
//ThumbnailData* calibration_data = &p->partplate_list.get_plate(i)->cali_thumbnail_data;
@@ -13429,8 +13454,8 @@ int Plater::export_3mf(const boost::filesystem::path& output_path, SaveStrategy
else {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": re-generate top_thumbnail for plate %1%") % i;
const ThumbnailsParams thumbnail_params = { {}, false, true, false, true, i };
p->generate_thumbnail(p->partplate_list.get_plate(i)->top_thumbnail_data, THUMBNAIL_SIZE_3MF.first, THUMBNAIL_SIZE_3MF.second,
thumbnail_params, Camera::EType::Ortho, true, false);
p->generate_thumbnail(p->partplate_list.get_plate(i)->top_thumbnail_data, THUMBNAIL_SIZE_3MF.first, THUMBNAIL_SIZE_3MF.second, thumbnail_params,
Camera::EType::Ortho, Camera::ViewAngleType::Top_Plate, false);
}
top_thumbnails.push_back(top_thumbnail);
@@ -13442,8 +13467,8 @@ int Plater::export_3mf(const boost::filesystem::path& output_path, SaveStrategy
else {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": re-generate pick_thumbnail for plate %1%") % i;
const ThumbnailsParams thumbnail_params = { {}, false, true, false, true, i };
p->generate_thumbnail(p->partplate_list.get_plate(i)->pick_thumbnail_data, THUMBNAIL_SIZE_3MF.first, THUMBNAIL_SIZE_3MF.second,
thumbnail_params, Camera::EType::Ortho, true, true);
p->generate_thumbnail(p->partplate_list.get_plate(i)->pick_thumbnail_data, THUMBNAIL_SIZE_3MF.first, THUMBNAIL_SIZE_3MF.second, thumbnail_params,
Camera::EType::Ortho, Camera::ViewAngleType::Top_Plate, true);
}
picking_thumbnails.push_back(picking_thumbnail);
}
@@ -16219,5 +16244,24 @@ SuppressBackgroundProcessingUpdate::~SuppressBackgroundProcessingUpdate()
{
wxGetApp().plater()->schedule_background_process(m_was_scheduled);
}
wxString get_view_type_string(Camera::ViewAngleType type) {
switch (type) {
case Slic3r::GUI::Camera::ViewAngleType::Iso: return _L("isometric");
case Slic3r::GUI::Camera::ViewAngleType::Top_Front: return _L("top_front");
case Slic3r::GUI::Camera::ViewAngleType::Left: return _L("left");
case Slic3r::GUI::Camera::ViewAngleType::Right: return _L("right");
case Slic3r::GUI::Camera::ViewAngleType::Top: return _L("top");
case Slic3r::GUI::Camera::ViewAngleType::Bottom: return _L("bottom");
case Slic3r::GUI::Camera::ViewAngleType::Front: return _L("front");
case Slic3r::GUI::Camera::ViewAngleType::Rear: return _L("rear");
default: return "";
}
}
wxArrayString get_all_camera_view_type() {
wxArrayString all_types;
for (size_t i = 0; i < (int)Camera::ViewAngleType::Count_ViewAngleType; i++) {
all_types.Add(get_view_type_string((Camera::ViewAngleType) i));
}
return all_types;
}
}} // namespace Slic3r::GUI