Run image projection in background thread (with progress bar)

This commit is contained in:
sentientstardust
2026-05-25 11:45:49 +01:00
parent bf81236bc5
commit b9c73d7a41
5 changed files with 1301 additions and 232 deletions

View File

@@ -147,7 +147,7 @@ struct TextureMappingZone
static constexpr int DefaultTopVisiblePerimeterRecolorAboveLayers = 2;
static constexpr bool DefaultTopVisiblePerimeterRecolorPointSampling = true;
static constexpr bool DefaultTopSurfaceImagePrintingEnabled = false;
static constexpr int DefaultTopSurfaceImagePrintingMethod = int(TopSurfaceImageSameAngle45Width);
static constexpr int DefaultTopSurfaceImagePrintingMethod = int(TopSurfaceImageContoning);
static constexpr float MinTopSurfaceImageLineWidthMm = 0.32f;
static constexpr float MaxTopSurfaceImageLineWidthMm = 0.80f;
static constexpr float DefaultTopSurfaceImageMinLineWidthMm = 0.32f;
@@ -166,7 +166,7 @@ struct TextureMappingZone
static constexpr float MaxTopSurfaceContoningMinFeatureMm = 20.f;
static constexpr float DefaultTopSurfaceContoningMinFeatureMm = 0.f;
static constexpr bool DefaultTopSurfaceContoningColorLowerSurfaces = true;
static constexpr bool DefaultTopSurfaceContoningOnlyColorSurfaceInfill = false;
static constexpr bool DefaultTopSurfaceContoningOnlyColorSurfaceInfill = true;
static constexpr bool DefaultCompactOffsetMode = true;
static constexpr bool DefaultUseLegacyFixedColorMode = false;
static constexpr bool DefaultHighSpeedImageTextureSampling = true;

File diff suppressed because it is too large Load Diff

View File

@@ -171,7 +171,8 @@ protected:
bool m_detect_geometry_edge = true;
// Filament remap feature
std::vector<size_t> m_extruder_remap; // index → target extruder index
std::vector<unsigned int> m_remap_source_filament_ids;
std::vector<size_t> m_extruder_remap;
bool m_show_filament_remap_ui = false;
static const constexpr float CursorRadiusMin = 0.1f; // cannot be zero
@@ -237,6 +238,8 @@ private:
const std::array<float, 4> &clipping_plane) const override;
// Filament remapping methods
std::vector<unsigned int> selected_object_used_filament_ids() const;
void refresh_filament_remap_sources(bool reset_targets = false);
void remap_filament_assignments();
void render_filament_remap_ui(float window_width, float max_tooltip_width);
bool selected_object_has_imported_vertex_colors() const;
@@ -532,6 +535,8 @@ private:
float height = 0.f;
};
struct ProjectionInput;
bool load_projection_image();
void clear_projection_image();
void ensure_text_font_names();
@@ -560,10 +565,15 @@ private:
bool selected_object_has_vertex_color_data() const;
bool selected_object_has_rgb_data() const;
bool selected_object_has_raw_atlas_texture_data() const;
bool start_projection_job();
bool project_image_to_selected_object();
bool project_to_vertex_colors(ModelObject *object);
bool project_to_image_texture(ModelObject *object);
bool project_to_rgb_data(ModelObject *object);
void fill_projection_input(ProjectionInput &input, const ModelObject *object) const;
bool project_image_to_object(ModelObject *object, unsigned int texture_mapping_filament_id, const ProjectionInput &input, const std::function<void(int)> &progress_fn = {}, const std::function<void()> &check_cancel = {});
bool project_to_vertex_colors(ModelObject *object, const ProjectionInput &input, const std::function<void(int)> &progress_fn = {}, const std::function<void()> &check_cancel = {});
bool project_to_image_texture(ModelObject *object, const ProjectionInput &input, const std::function<void(int)> &progress_fn = {}, const std::function<void()> &check_cancel = {});
bool project_to_rgb_data(ModelObject *object, const ProjectionInput &input, const std::function<void(int)> &progress_fn = {}, const std::function<void()> &check_cancel = {});
void render_projection_progress();
void request_projection_job_cancel();
void refresh_projected_object(ModelObject *object);
void remember_projected_object(ModelObject *object);
void backup_projected_objects();
@@ -609,7 +619,11 @@ private:
bool m_projection_panel_expanded = true;
bool m_apply_transparency_as_background = false;
bool m_pass_through_model = false;
bool m_erase_region_painting = true;
bool m_convert_existing_colors_to_raw_offsets = true;
std::atomic_bool m_projection_job_active { false };
std::atomic_bool m_projection_job_cancel_requested { false };
std::atomic_int m_projection_job_progress { 0 };
std::vector<ObjectID> m_projected_object_ids;
};

View File

@@ -2341,8 +2341,8 @@ public:
wxALIGN_CENTER_VERTICAL | wxRIGHT,
gap);
wxArrayString top_surface_method_choices;
top_surface_method_choices.Add(_L("45 degree width modulation"));
top_surface_method_choices.Add(_L("Same-layer 45 partition"));
top_surface_method_choices.Add(_L("45 degree width modulation - not recommended"));
top_surface_method_choices.Add(_L("Same-layer 45 partition - not recommended"));
top_surface_method_choices.Add(_L("Contoning"));
m_top_surface_image_method_choice =
new wxChoice(top_surface_page, wxID_ANY, wxDefaultPosition, wxDefaultSize, top_surface_method_choices);
@@ -2800,6 +2800,8 @@ public:
}
bool top_surface_image_fixed_coloring_filaments() const
{
if (top_surface_image_printing_method() == int(TextureMappingZone::TopSurfaceImageContoning))
return true;
return m_top_surface_image_fixed_coloring_filaments_checkbox == nullptr ||
m_top_surface_image_fixed_coloring_filaments_checkbox->GetValue();
}
@@ -2834,8 +2836,9 @@ public:
}
bool top_surface_contoning_only_color_surface_infill() const
{
return m_top_surface_contoning_only_color_surface_infill_checkbox != nullptr &&
m_top_surface_contoning_only_color_surface_infill_checkbox->GetValue();
return m_top_surface_contoning_only_color_surface_infill_checkbox != nullptr ?
m_top_surface_contoning_only_color_surface_infill_checkbox->GetValue() :
TextureMappingZone::DefaultTopSurfaceContoningOnlyColorSurfaceInfill;
}
bool minimum_visibility_offset_enabled() const
{
@@ -3222,10 +3225,10 @@ private:
m_top_surface_image_min_line_width_spin->Enable(enabled);
if (m_top_surface_image_max_line_width_spin != nullptr)
m_top_surface_image_max_line_width_spin->Enable(enabled);
const bool contoning =
enabled &&
const bool contoning_selected =
m_top_surface_image_method_choice != nullptr &&
m_top_surface_image_method_choice->GetSelection() == int(TextureMappingZone::TopSurfaceImageContoning);
const bool contoning = enabled && contoning_selected;
if (contoning && m_modulation_mode_choice != nullptr) {
m_modulation_mode_choice->SetSelection(int(TextureMappingZone::ModulationPerimeterPathV2));
m_modulation_mode_manually_changed = true;
@@ -3255,8 +3258,10 @@ private:
m_top_surface_contoning_only_color_surface_infill_checkbox->Show(contoning);
m_top_surface_contoning_only_color_surface_infill_checkbox->Enable(contoning);
}
if (m_top_surface_image_fixed_coloring_filaments_checkbox != nullptr)
m_top_surface_image_fixed_coloring_filaments_checkbox->Enable(enabled);
if (m_top_surface_image_fixed_coloring_filaments_checkbox != nullptr) {
m_top_surface_image_fixed_coloring_filaments_checkbox->Show(!contoning_selected);
m_top_surface_image_fixed_coloring_filaments_checkbox->Enable(enabled && !contoning_selected);
}
layout_current_options_page();
if (!fit_dialog)
return;

View File

@@ -1 +1 @@
1.0.18
1.0.22