mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-07-31 20:31:59 +08:00
Don't refresh the 3D view unless really necessary
If you spot a missed refresh, please tell me how to reproduce.
This commit is contained in:
parent
7be5f47a0e
commit
ca995447fb
@ -1339,9 +1339,10 @@ void GLCanvas3D::reset_volumes(bool is_destroying)
|
|||||||
|
|
||||||
_set_current();
|
_set_current();
|
||||||
|
|
||||||
m_selection.clear(is_destroying);
|
m_selection.clear(is_destroying);
|
||||||
m_volumes.clear();
|
m_volumes.release_geometry();
|
||||||
m_dirty = true;
|
m_volumes.clear();
|
||||||
|
m_dirty = true;
|
||||||
|
|
||||||
if(!is_destroying)
|
if(!is_destroying)
|
||||||
_set_warning_texture(WarningTexture::ObjectOutside, false);
|
_set_warning_texture(WarningTexture::ObjectOutside, false);
|
||||||
@ -2326,23 +2327,23 @@ static void reserve_new_volume_finalize_old_volume(GLVolume& vol_new, GLVolume&
|
|||||||
vol_old.finalize_geometry(gl_initialized);
|
vol_old.finalize_geometry(gl_initialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::load_gcode_preview(const GCodeProcessor::Result& gcode_result)
|
void GLCanvas3D::load_gcode_preview(const GCodeProcessor::Result& gcode_result, const std::vector<std::string>& str_tool_colors)
|
||||||
{
|
{
|
||||||
m_gcode_viewer.load(gcode_result, *this->fff_print(), m_initialized);
|
if (m_dirty_gcode) {
|
||||||
|
m_dirty_gcode = false;
|
||||||
|
m_gcode_viewer.load(gcode_result, *this->fff_print(), m_initialized);
|
||||||
|
|
||||||
if (wxGetApp().is_editor()) {
|
if (wxGetApp().is_editor()) {
|
||||||
m_gcode_viewer.update_shells_color_by_extruder(m_config);
|
m_gcode_viewer.update_shells_color_by_extruder(m_config);
|
||||||
_show_warning_texture_if_needed(WarningTexture::ToolpathOutside);
|
_show_warning_texture_if_needed(WarningTexture::ToolpathOutside);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_gcode_viewer.refresh(gcode_result, str_tool_colors);
|
||||||
|
set_as_dirty();
|
||||||
|
request_extra_frame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::refresh_gcode_preview(const GCodeProcessor::Result& gcode_result, const std::vector<std::string>& str_tool_colors)
|
|
||||||
{
|
|
||||||
m_gcode_viewer.refresh(gcode_result, str_tool_colors);
|
|
||||||
set_as_dirty();
|
|
||||||
request_extra_frame();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if ENABLE_RENDER_PATH_REFRESH_AFTER_OPTIONS_CHANGE
|
#if ENABLE_RENDER_PATH_REFRESH_AFTER_OPTIONS_CHANGE
|
||||||
void GLCanvas3D::refresh_gcode_preview_render_paths()
|
void GLCanvas3D::refresh_gcode_preview_render_paths()
|
||||||
{
|
{
|
||||||
@ -2367,23 +2368,27 @@ void GLCanvas3D::load_sla_preview()
|
|||||||
|
|
||||||
void GLCanvas3D::load_preview(const std::vector<std::string>& str_tool_colors, const std::vector<CustomGCode::Item>& color_print_values)
|
void GLCanvas3D::load_preview(const std::vector<std::string>& str_tool_colors, const std::vector<CustomGCode::Item>& color_print_values)
|
||||||
{
|
{
|
||||||
const Print *print = this->fff_print();
|
const Print* print = this->fff_print();
|
||||||
if (print == nullptr)
|
if (print == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_set_current();
|
_set_current();
|
||||||
|
|
||||||
// Release OpenGL data before generating new data.
|
if (m_dirty_preview || m_volumes.empty()) {
|
||||||
this->reset_volumes();
|
m_dirty_preview = false;
|
||||||
|
// Release OpenGL data before generating new data.
|
||||||
|
this->reset_volumes();
|
||||||
|
//note: this isn't releasing all the memory in all os, can make it crash on linux for exemple.
|
||||||
|
|
||||||
_load_print_toolpaths();
|
_load_print_toolpaths();
|
||||||
_load_wipe_tower_toolpaths(str_tool_colors);
|
_load_wipe_tower_toolpaths(str_tool_colors);
|
||||||
for (const PrintObject* object : print->objects())
|
for (const PrintObject* object : print->objects())
|
||||||
_load_print_object_toolpaths(*object, str_tool_colors, color_print_values);
|
_load_print_object_toolpaths(*object, str_tool_colors, color_print_values);
|
||||||
|
|
||||||
_update_toolpath_volumes_outside_state();
|
_update_toolpath_volumes_outside_state();
|
||||||
_show_warning_texture_if_needed(WarningTexture::ToolpathOutside);
|
_show_warning_texture_if_needed(WarningTexture::ToolpathOutside);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GLCanvas3D::bind_event_handlers()
|
void GLCanvas3D::bind_event_handlers()
|
||||||
{
|
{
|
||||||
@ -4835,7 +4840,7 @@ bool GLCanvas3D::_init_collapse_toolbar()
|
|||||||
bool GLCanvas3D::_set_current()
|
bool GLCanvas3D::_set_current()
|
||||||
{
|
{
|
||||||
return m_context != nullptr && m_canvas->SetCurrent(*m_context);
|
return m_context != nullptr && m_canvas->SetCurrent(*m_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::_resize(unsigned int w, unsigned int h)
|
void GLCanvas3D::_resize(unsigned int w, unsigned int h)
|
||||||
{
|
{
|
||||||
|
@ -475,6 +475,8 @@ private:
|
|||||||
|
|
||||||
// Screen is only refreshed from the OnIdle handler if it is dirty.
|
// Screen is only refreshed from the OnIdle handler if it is dirty.
|
||||||
bool m_dirty;
|
bool m_dirty;
|
||||||
|
bool m_dirty_preview = true;
|
||||||
|
bool m_dirty_gcode = true;
|
||||||
bool m_initialized;
|
bool m_initialized;
|
||||||
bool m_apply_zoom_to_volumes_filter;
|
bool m_apply_zoom_to_volumes_filter;
|
||||||
mutable std::vector<int> m_hover_volume_idxs;
|
mutable std::vector<int> m_hover_volume_idxs;
|
||||||
@ -557,6 +559,9 @@ public:
|
|||||||
void post_event(wxEvent &&event);
|
void post_event(wxEvent &&event);
|
||||||
|
|
||||||
void set_as_dirty();
|
void set_as_dirty();
|
||||||
|
void set_preview_dirty() { m_dirty_preview = true; }
|
||||||
|
bool is_preview_dirty() { return m_dirty_preview; }
|
||||||
|
void set_gcode_viewer_dirty() { m_dirty_gcode = true; }
|
||||||
void set_items_show(bool show_objects, bool show_gcode);
|
void set_items_show(bool show_objects, bool show_gcode);
|
||||||
|
|
||||||
unsigned int get_volumes_count() const;
|
unsigned int get_volumes_count() const;
|
||||||
@ -666,8 +671,7 @@ public:
|
|||||||
|
|
||||||
void reload_scene(bool refresh_immediately, bool force_full_scene_refresh = false);
|
void reload_scene(bool refresh_immediately, bool force_full_scene_refresh = false);
|
||||||
|
|
||||||
void load_gcode_preview(const GCodeProcessor::Result& gcode_result);
|
void load_gcode_preview(const GCodeProcessor::Result& gcode_result, const std::vector<std::string>& str_tool_colors);
|
||||||
void refresh_gcode_preview(const GCodeProcessor::Result& gcode_result, const std::vector<std::string>& str_tool_colors);
|
|
||||||
#if ENABLE_RENDER_PATH_REFRESH_AFTER_OPTIONS_CHANGE
|
#if ENABLE_RENDER_PATH_REFRESH_AFTER_OPTIONS_CHANGE
|
||||||
void refresh_gcode_preview_render_paths();
|
void refresh_gcode_preview_render_paths();
|
||||||
#endif // ENABLE_RENDER_PATH_REFRESH_AFTER_OPTIONS_CHANGE
|
#endif // ENABLE_RENDER_PATH_REFRESH_AFTER_OPTIONS_CHANGE
|
||||||
|
@ -416,8 +416,9 @@ void Preview::reload_print(bool keep_volumes)
|
|||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
m_volumes_cleanup_required ||
|
m_volumes_cleanup_required ||
|
||||||
#endif /* __linux__ */
|
#endif /* __linux__ */
|
||||||
!keep_volumes)
|
(!keep_volumes && m_canvas->is_preview_dirty()))
|
||||||
{
|
{
|
||||||
|
m_canvas->set_preview_dirty();
|
||||||
m_canvas->reset_volumes();
|
m_canvas->reset_volumes();
|
||||||
m_loaded = false;
|
m_loaded = false;
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
@ -1020,8 +1021,9 @@ void Preview::load_print_as_fff(bool keep_z_range)
|
|||||||
m_canvas->set_selected_extruder(0);
|
m_canvas->set_selected_extruder(0);
|
||||||
if (current_force_state == ForceState::ForceGcode || (gcode_preview_data_valid && current_force_state != ForceState::ForceExtrusions)) {
|
if (current_force_state == ForceState::ForceGcode || (gcode_preview_data_valid && current_force_state != ForceState::ForceExtrusions)) {
|
||||||
// Load the real G-code preview.
|
// Load the real G-code preview.
|
||||||
m_canvas->load_gcode_preview(*m_gcode_result);
|
if (current_force_state == ForceState::NoForce)
|
||||||
m_canvas->refresh_gcode_preview(*m_gcode_result, colors);
|
m_canvas->set_items_show(false, true);
|
||||||
|
m_canvas->load_gcode_preview(*m_gcode_result, colors);
|
||||||
m_left_sizer->Show(m_bottom_toolbar_panel);
|
m_left_sizer->Show(m_bottom_toolbar_panel);
|
||||||
m_left_sizer->Layout();
|
m_left_sizer->Layout();
|
||||||
Refresh();
|
Refresh();
|
||||||
@ -1029,6 +1031,8 @@ void Preview::load_print_as_fff(bool keep_z_range)
|
|||||||
m_loaded = true;
|
m_loaded = true;
|
||||||
} else {
|
} else {
|
||||||
// Load the initial preview based on slices, not the final G-code.
|
// Load the initial preview based on slices, not the final G-code.
|
||||||
|
if (current_force_state == ForceState::NoForce)
|
||||||
|
m_canvas->set_items_show(true, false);
|
||||||
m_canvas->load_preview(colors, color_print_values);
|
m_canvas->load_preview(colors, color_print_values);
|
||||||
m_left_sizer->Hide(m_bottom_toolbar_panel);
|
m_left_sizer->Hide(m_bottom_toolbar_panel);
|
||||||
m_left_sizer->Layout();
|
m_left_sizer->Layout();
|
||||||
@ -1039,8 +1043,9 @@ void Preview::load_print_as_fff(bool keep_z_range)
|
|||||||
// all layers filtered out
|
// all layers filtered out
|
||||||
hide_layers_slider();
|
hide_layers_slider();
|
||||||
m_canvas_widget->Refresh();
|
m_canvas_widget->Refresh();
|
||||||
} else
|
} else {
|
||||||
update_layers_slider(zs, keep_z_range);
|
update_layers_slider(zs, keep_z_range);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_PREVIEW_TYPE_CHANGE
|
#if ENABLE_PREVIEW_TYPE_CHANGE
|
||||||
@ -1071,6 +1076,13 @@ void Preview::load_print_as_fff(bool keep_z_range)
|
|||||||
#endif // ENABLE_PREVIEW_TYPE_CHANGE
|
#endif // ENABLE_PREVIEW_TYPE_CHANGE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Preview::reset_gcode_toolpaths()
|
||||||
|
{
|
||||||
|
if (current_force_state == ForceState::NoForce)
|
||||||
|
m_canvas->set_items_show(true, false);
|
||||||
|
m_canvas->reset_gcode_toolpaths();
|
||||||
|
}
|
||||||
|
|
||||||
void Preview::load_print_as_sla()
|
void Preview::load_print_as_sla()
|
||||||
{
|
{
|
||||||
if (m_loaded || (m_process->current_printer_technology() != ptSLA))
|
if (m_loaded || (m_process->current_printer_technology() != ptSLA))
|
||||||
|
@ -203,6 +203,7 @@ Preview(wxWindow* parent, Model* model, DynamicPrintConfig* config, BackgroundSl
|
|||||||
|
|
||||||
bool can_display_gcode();
|
bool can_display_gcode();
|
||||||
bool can_display_volume();
|
bool can_display_volume();
|
||||||
|
void reset_gcode_toolpaths();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ForceState current_force_state = ForceState::NoForce;
|
ForceState current_force_state = ForceState::NoForce;
|
||||||
|
@ -3576,8 +3576,14 @@ void Plater::priv::set_current_panel(wxTitledPanel* panel)
|
|||||||
// FIXME: it may be better to have a single function making this check and let it be called wherever needed
|
// FIXME: it may be better to have a single function making this check and let it be called wherever needed
|
||||||
bool export_in_progress = this->background_process.is_export_scheduled();
|
bool export_in_progress = this->background_process.is_export_scheduled();
|
||||||
bool model_fits = view3D->check_volumes_outside_state() != ModelInstancePVS_Partly_Outside;
|
bool model_fits = view3D->check_volumes_outside_state() != ModelInstancePVS_Partly_Outside;
|
||||||
if (!model.objects.empty() && !export_in_progress && model_fits)
|
|
||||||
this->q->reslice();
|
if (!model.objects.empty() && !export_in_progress && model_fits) {
|
||||||
|
//check if already slicing
|
||||||
|
bool already_running = this->background_process.state() == BackgroundSlicingProcess::State::STATE_RUNNING ||
|
||||||
|
this->background_process.state() == BackgroundSlicingProcess::State::STATE_STARTED;
|
||||||
|
if(!already_running)
|
||||||
|
this->q->reslice();
|
||||||
|
}
|
||||||
// keeps current gcode preview, if any
|
// keeps current gcode preview, if any
|
||||||
preview->reload_print(true);
|
preview->reload_print(true);
|
||||||
}
|
}
|
||||||
@ -3722,6 +3728,7 @@ void Plater::priv::on_slicing_update(SlicingStatusEvent &evt)
|
|||||||
|
|
||||||
void Plater::priv::on_slicing_completed(wxCommandEvent & evt)
|
void Plater::priv::on_slicing_completed(wxCommandEvent & evt)
|
||||||
{
|
{
|
||||||
|
preview->get_canvas3d()->set_gcode_viewer_dirty();
|
||||||
// auto_switch_preview == 0 means "no force tab change"
|
// auto_switch_preview == 0 means "no force tab change"
|
||||||
// auto_switch_preview == 1 means "force tab change"
|
// auto_switch_preview == 1 means "force tab change"
|
||||||
// auto_switch_preview == 2 means "force tab change only if already on a plater one"
|
// auto_switch_preview == 2 means "force tab change only if already on a plater one"
|
||||||
@ -3753,6 +3760,8 @@ void Plater::priv::on_slicing_began()
|
|||||||
{
|
{
|
||||||
clear_warnings();
|
clear_warnings();
|
||||||
notification_manager->close_notification_of_type(NotificationType::SlicingComplete);
|
notification_manager->close_notification_of_type(NotificationType::SlicingComplete);
|
||||||
|
preview->get_canvas3d()->set_gcode_viewer_dirty();
|
||||||
|
preview->get_canvas3d()->set_preview_dirty();
|
||||||
}
|
}
|
||||||
void Plater::priv::add_warning(const Slic3r::PrintStateBase::Warning& warning, size_t oid)
|
void Plater::priv::add_warning(const Slic3r::PrintStateBase::Warning& warning, size_t oid)
|
||||||
{
|
{
|
||||||
@ -4390,7 +4399,7 @@ void Plater::priv::enable_preview_moves_slider(bool enable)
|
|||||||
|
|
||||||
void Plater::priv::reset_gcode_toolpaths()
|
void Plater::priv::reset_gcode_toolpaths()
|
||||||
{
|
{
|
||||||
preview->get_canvas3d()->reset_gcode_toolpaths();
|
preview->reset_gcode_toolpaths();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Plater::priv::can_set_instance_to_object() const
|
bool Plater::priv::can_set_instance_to_object() const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user