SPE-1761: Show part shells in pre-gcode preview

This commit is contained in:
enricoturri1966 2023-06-07 15:06:54 +02:00
parent 391bf14559
commit b809996d30
7 changed files with 30 additions and 9 deletions

View File

@ -747,9 +747,7 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr
m_filament_diameters = gcode_result.filament_diameters;
m_filament_densities = gcode_result.filament_densities;
if (wxGetApp().is_editor())
load_shells(print);
else {
if (!wxGetApp().is_editor()) {
Pointfs bed_shape;
std::string texture;
std::string model;
@ -903,7 +901,6 @@ void GCodeViewer::reset()
m_filament_diameters = std::vector<float>();
m_filament_densities = std::vector<float>();
m_extrusions.reset_ranges();
m_shells.volumes.clear();
m_layers.reset();
m_layers_z_range = { 0, 0 };
m_roles = std::vector<GCodeExtrusionRole>();
@ -927,12 +924,13 @@ void GCodeViewer::render()
m_statistics.total_instances_gpu_size = 0;
#endif // ENABLE_GCODE_VIEWER_STATISTICS
glsafe(::glEnable(GL_DEPTH_TEST));
render_shells();
if (m_roles.empty())
return;
glsafe(::glEnable(GL_DEPTH_TEST));
render_toolpaths();
render_shells();
float legend_height = 0.0f;
if (!m_layers.empty()) {
render_legend(legend_height);
@ -2226,6 +2224,8 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result)
void GCodeViewer::load_shells(const Print& print)
{
m_shells.volumes.clear();
if (print.objects().empty())
// no shells, return
return;

View File

@ -838,6 +838,9 @@ public:
bool is_legend_enabled() const { return m_legend_enabled; }
void enable_legend(bool enable) { m_legend_enabled = enable; }
bool are_shells_visible() const { return m_shells.visible; }
void set_shells_visible(bool visible) { m_shells.visible = visible; }
void export_toolpaths_to_obj(const char* filename) const;
void toggle_gcode_window_visibility() { m_sequential_view.gcode_window.toggle_visibility(); }
@ -849,9 +852,10 @@ public:
const ConflictResultOpt& get_conflict_result() const { return m_conflict_result; }
void load_shells(const Print& print);
private:
void load_toolpaths(const GCodeProcessorResult& gcode_result);
void load_shells(const Print& print);
void render_toolpaths();
void render_shells();
void render_legend(float& legend_height);

View File

@ -1913,7 +1913,7 @@ void GLCanvas3D::render()
_render_bed_axes();
if (is_looking_downward)
_render_bed(camera.get_view_matrix(), camera.get_projection_matrix(), false);
if (!m_main_toolbar.is_enabled())
if (!m_main_toolbar.is_enabled() && current_printer_technology() != ptSLA)
_render_gcode();
_render_objects(GLVolumeCollection::ERenderType::Transparent);
@ -2637,12 +2637,19 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
m_dirty = true;
}
void GLCanvas3D::load_gcode_shells()
{
m_gcode_viewer_shells_visible = m_gcode_viewer.are_shells_visible();
m_gcode_viewer.load_shells(*this->fff_print());
m_gcode_viewer.update_shells_color_by_extruder(m_config);
m_gcode_viewer.set_shells_visible(true);
}
void GLCanvas3D::load_gcode_preview(const GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors)
{
m_gcode_viewer.load(gcode_result, *this->fff_print());
if (wxGetApp().is_editor()) {
m_gcode_viewer.update_shells_color_by_extruder(m_config);
_set_warning_notification_if_needed(EWarning::ToolpathOutside);
_set_warning_notification_if_needed(EWarning::GCodeConflict);
}
@ -2690,6 +2697,7 @@ void GLCanvas3D::load_preview(const std::vector<std::string>& str_tool_colors, c
for (const PrintObject* object : print->objects())
_load_print_object_toolpaths(*object, build_volume, str_tool_colors, color_print_values);
m_gcode_viewer.set_shells_visible(m_gcode_viewer_shells_visible);
_set_warning_notification_if_needed(EWarning::ToolpathOutside);
}

View File

@ -509,6 +509,7 @@ private:
TriangleMesh m_wipe_tower_mesh;
#endif // ENABLE_OPENGL_ES
GCodeViewer m_gcode_viewer;
bool m_gcode_viewer_shells_visible{ true };
RenderTimer m_render_timer;
@ -829,6 +830,7 @@ public:
void reload_scene(bool refresh_immediately, bool force_full_scene_refresh = false);
void load_gcode_shells();
void load_gcode_preview(const GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors);
void refresh_gcode_preview_render_paths(bool keep_sequential_current_first, bool keep_sequential_current_last);
void set_gcode_view_preview_type(GCodeViewer::EViewType type) { return m_gcode_viewer.set_view_type(type); }

View File

@ -279,6 +279,11 @@ void Preview::set_drop_target(wxDropTarget* target)
SetDropTarget(target);
}
void Preview::load_gcode_shells()
{
m_canvas->load_gcode_shells();
}
void Preview::load_print(bool keep_z_range)
{
PrinterTechnology tech = m_process->current_printer_technology();

View File

@ -132,6 +132,7 @@ public:
void select_view(const std::string& direction);
void set_drop_target(wxDropTarget* target);
void load_gcode_shells();
void load_print(bool keep_z_range = false);
void reload_print(bool keep_volumes = false);
void refresh_print();

View File

@ -3991,6 +3991,7 @@ void Plater::priv::set_current_panel(wxPanel* panel)
bool model_fits = view3D->get_canvas3d()->check_volumes_outside_state() != ModelInstancePVS_Partly_Outside;
if (!model.objects.empty() && !export_in_progress && model_fits) {
preview->get_canvas3d()->init_gcode_viewer();
preview->load_gcode_shells();
q->reslice();
}
// keeps current gcode preview, if any