Skip to content

Commit

Permalink
gcode preview not refreshed / range slider set to 0:0 by default #1532
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Mar 11, 2022
1 parent 398e80f commit c7d3dc3
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/libslic3r/GCode/GCodeProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1463,6 +1463,9 @@ void GCodeProcessor::finalize(bool post_process)
#if ENABLE_GCODE_VIEWER_STATISTICS
m_result.time = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - m_start_time).count();
#endif // ENABLE_GCODE_VIEWER_STATISTICS

//result is now updated
m_result.computed_timestamp = std::time(0);
}

float GCodeProcessor::get_time(PrintEstimatedStatistics::ETimeMode mode) const
Expand Down
5 changes: 5 additions & 0 deletions src/slic3r/GUI/BackgroundSlicingProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ void BackgroundSlicingProcess::process_fff()
}
this->set_step_done(bspsGCodeFinalize);
}
evt.SetInt((int)(m_fff_print->step_state_with_timestamp(PrintStep::psGCodeExport).timestamp));
wxQueueEvent(GUI::wxGetApp().mainframe->m_plater, evt.Clone());
}

static void write_thumbnail(Zipper& zipper, const ThumbnailData& data)
Expand All @@ -181,6 +183,9 @@ void BackgroundSlicingProcess::process_sla()
{
assert(m_print == m_sla_print);
m_print->process();
wxCommandEvent evt(m_event_slicing_completed_id);
evt.SetInt((int)(m_sla_print->step_state_with_timestamp(SLAPrintStep::slapsRasterize).timestamp));
wxQueueEvent(GUI::wxGetApp().mainframe->m_plater, evt.Clone());
if (this->set_step_started(bspsGCodeFinalize)) {
if (! m_export_path.empty()) {
wxQueueEvent(GUI::wxGetApp().mainframe->m_plater, new wxCommandEvent(m_event_export_began_id));
Expand Down
4 changes: 4 additions & 0 deletions src/slic3r/GUI/GCodeViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,10 @@ void GCodeViewer::init()
m_gl_data_initialized = true;
}

bool GCodeViewer::is_loaded(const GCodeProcessorResult& gcode_result) {
return (m_last_result_id == gcode_result.id);
}

void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& print, bool initialized)
{
// avoid processing if called with the same gcode_result
Expand Down
1 change: 1 addition & 0 deletions src/slic3r/GUI/GCodeViewer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ class GCodeViewer

// extract rendering data from the given parameters
void load(const GCodeProcessorResult& gcode_result, const Print& print, bool initialized);
bool is_loaded(const GCodeProcessorResult& gcode_result);
// recalculate ranges in dependence of what is visible and sets tool/print colors
void refresh(const GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors);
void refresh_render_paths();
Expand Down
3 changes: 2 additions & 1 deletion src/slic3r/GUI/GLCanvas3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2182,7 +2182,8 @@ bool GLCanvas3D::is_gcode_preview_dirty(const GCodeProcessorResult& gcode_result

void GLCanvas3D::load_gcode_preview(const GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors)
{
if (last_showned_gcode != gcode_result.computed_timestamp) {
if (last_showned_gcode != gcode_result.computed_timestamp
|| !m_gcode_viewer.is_loaded(gcode_result)) {
last_showned_gcode = gcode_result.computed_timestamp;
m_gcode_viewer.load(gcode_result, *this->fff_print(), m_initialized);

Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/GUI_Preview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ void Preview::update_layers_slider(const std::vector<double>& layers_z, bool kee
// Save the initial slider span.
double z_low = m_layers_slider->GetLowerValueD();
double z_high = m_layers_slider->GetHigherValueD();
bool was_empty = m_layers_slider->GetMaxValue() == 0;
bool was_empty = m_layers_slider->GetMaxValue() == 0 || z_high == 0;

bool force_sliders_full_range = was_empty;
if (!keep_z_range)
Expand Down

0 comments on commit c7d3dc3

Please sign in to comment.