mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	Estimated printing time per layer for SLAPrint
Split the time if it's needed
This commit is contained in:
		
							parent
							
								
									5f97b2512b
								
							
						
					
					
						commit
						5144feb319
					
				
					 5 changed files with 87 additions and 20 deletions
				
			
		|  | @ -350,6 +350,7 @@ struct SLAPrintStatistics | |||
|     size_t                          fast_layers_count; | ||||
|     double                          total_cost; | ||||
|     double                          total_weight; | ||||
|     std::vector<double>             layers_times; | ||||
| 
 | ||||
|     // Config with the filled in print statistics.
 | ||||
|     DynamicConfig           config() const; | ||||
|  | @ -366,6 +367,7 @@ struct SLAPrintStatistics | |||
|         fast_layers_count = 0; | ||||
|         total_cost = 0.; | ||||
|         total_weight = 0.; | ||||
|         layers_times.clear(); | ||||
|     } | ||||
| }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -671,6 +671,8 @@ void SLAPrint::Steps::merge_slices_and_eval_stats() { | |||
|     double models_volume(0.0); | ||||
|      | ||||
|     double estim_time(0.0); | ||||
|     std::vector<double> layers_times; | ||||
|     layers_times.reserve(printer_input.size()); | ||||
|      | ||||
|     size_t slow_layers = 0; | ||||
|     size_t fast_layers = 0; | ||||
|  | @ -688,7 +690,7 @@ void SLAPrint::Steps::merge_slices_and_eval_stats() { | |||
|              | ||||
|             // write vars
 | ||||
|             &mutex, &models_volume, &supports_volume, &estim_time, &slow_layers, | ||||
|             &fast_layers, &fade_layer_time](size_t sliced_layer_cnt) | ||||
|             &fast_layers, &fade_layer_time, &layers_times](size_t sliced_layer_cnt) | ||||
|     { | ||||
|         PrintLayer &layer = m_print->m_printer_input[sliced_layer_cnt]; | ||||
| 
 | ||||
|  | @ -775,20 +777,21 @@ void SLAPrint::Steps::merge_slices_and_eval_stats() { | |||
|             else | ||||
|                 slow_layers++; | ||||
|              | ||||
|              | ||||
|             // Calculation of the printing time
 | ||||
|              | ||||
| 
 | ||||
|             double layer_times = 0.0; | ||||
|             if (sliced_layer_cnt < 3) | ||||
|                 estim_time += init_exp_time; | ||||
|             else if (fade_layer_time > exp_time) | ||||
|             { | ||||
|                 layer_times += init_exp_time; | ||||
|             else if (fade_layer_time > exp_time) { | ||||
|                 fade_layer_time -= delta_fade_time; | ||||
|                 estim_time += fade_layer_time; | ||||
|                 layer_times += fade_layer_time; | ||||
|             } | ||||
|             else | ||||
|                 estim_time += exp_time; | ||||
|              | ||||
|             estim_time += tilt_time; | ||||
|                 layer_times += exp_time; | ||||
|             layer_times += tilt_time; | ||||
| 
 | ||||
|             layers_times.push_back(layer_times); | ||||
|             estim_time += layer_times; | ||||
|         } | ||||
|     }; | ||||
|      | ||||
|  | @ -804,8 +807,10 @@ void SLAPrint::Steps::merge_slices_and_eval_stats() { | |||
|     // A layers count o the highest object
 | ||||
|     if (printer_input.size() == 0) | ||||
|         print_statistics.estimated_print_time = std::nan(""); | ||||
|     else | ||||
|     else { | ||||
|         print_statistics.estimated_print_time = estim_time; | ||||
|         print_statistics.layers_times = layers_times; | ||||
|     } | ||||
|      | ||||
|     print_statistics.fast_layers_count = fast_layers; | ||||
|     print_statistics.slow_layers_count = slow_layers; | ||||
|  |  | |||
|  | @ -381,9 +381,20 @@ void Control::SetTicksValues(const Info& custom_gcode_per_print_z) | |||
| } | ||||
| 
 | ||||
| void Control::SetLayersTimes(const std::vector<float>& layers_times) | ||||
| {  | ||||
|     m_layers_times.clear(); | ||||
|     if (layers_times.empty()) | ||||
|         return; | ||||
|     m_layers_times.resize(layers_times.size(), 0.0); | ||||
|     m_layers_times[0] = layers_times[0]; | ||||
|     for (size_t i = 1; i < layers_times.size(); i++) | ||||
|         m_layers_times[i] = m_layers_times[i - 1] + layers_times[i]; | ||||
| } | ||||
| 
 | ||||
| void Control::SetLayersTimes(const std::vector<double>& layers_times) | ||||
| {  | ||||
|     m_layers_times = layers_times; | ||||
|     for (int i = 1; i < m_layers_times.size(); i++) | ||||
|     for (size_t i = 1; i < m_layers_times.size(); i++) | ||||
|         m_layers_times[i] += m_layers_times[i - 1]; | ||||
| } | ||||
| 
 | ||||
|  | @ -579,7 +590,7 @@ void Control::draw_tick_on_mouse_position(wxDC& dc) | |||
|     } | ||||
| 
 | ||||
|     tick = get_value_from_position(m_moving_pos); | ||||
|     if (tick >= m_max_value || tick <= m_min_value || tick == m_higher_value || tick == m_lower_value) | ||||
|     if (tick > m_max_value || tick < m_min_value || tick == m_higher_value || tick == m_lower_value) | ||||
|         return; | ||||
| 
 | ||||
|     wxCoord new_pos = get_position_from_value(tick); | ||||
|  | @ -597,6 +608,47 @@ void Control::draw_tick_on_mouse_position(wxDC& dc) | |||
|     } | ||||
| } | ||||
| 
 | ||||
| static std::string short_and_splitted_time(const std::string& time) | ||||
| { | ||||
|     // Parse the dhms time format.
 | ||||
|     int days = 0; | ||||
|     int hours = 0; | ||||
|     int minutes = 0; | ||||
|     int seconds = 0; | ||||
|     if (time.find('d') != std::string::npos) | ||||
|         ::sscanf(time.c_str(), "%dd %dh %dm %ds", &days, &hours, &minutes, &seconds); | ||||
|     else if (time.find('h') != std::string::npos) | ||||
|         ::sscanf(time.c_str(), "%dh %dm %ds", &hours, &minutes, &seconds); | ||||
|     else if (time.find('m') != std::string::npos) | ||||
|         ::sscanf(time.c_str(), "%dm %ds", &minutes, &seconds); | ||||
|     else if (time.find('s') != std::string::npos) | ||||
|         ::sscanf(time.c_str(), "%ds", &seconds); | ||||
| 
 | ||||
|     // Format the dhm time.
 | ||||
|     char buffer[64]; | ||||
|     if (days > 0) | ||||
|         ::sprintf(buffer, "%dd%dh\n%dm", days, hours, minutes); | ||||
|     else if (hours > 0) { | ||||
|         if (hours < 10 && minutes < 10 && seconds < 10) | ||||
|             ::sprintf(buffer, "%dh%dm%ds", hours, minutes, seconds); | ||||
|         else if (hours > 10 && minutes > 10 && seconds > 10) | ||||
|             ::sprintf(buffer, "%dh\n%dm\n%ds", hours, minutes, seconds); | ||||
|         else if (minutes < 10 && seconds > 10 || minutes > 10 && seconds < 10) | ||||
|             ::sprintf(buffer, "%dh\n%dm%ds", hours, minutes, seconds); | ||||
|         else | ||||
|             ::sprintf(buffer, "%dh%dm\n%ds", hours, minutes, seconds); | ||||
|     } | ||||
|     else if (minutes > 0) { | ||||
|         if (minutes > 10 && seconds > 10) | ||||
|             ::sprintf(buffer, "%dm\n%ds", minutes, seconds); | ||||
|         else | ||||
|             ::sprintf(buffer, "%dm%ds", minutes, seconds); | ||||
|     } | ||||
|     else | ||||
|         ::sprintf(buffer, "%ds", seconds); | ||||
|     return buffer; | ||||
| } | ||||
| 
 | ||||
| wxString Control::get_label(int tick, LabelType label_type/* = ltHeightWithLayer*/) const | ||||
| { | ||||
|     const int value = tick; | ||||
|  | @ -613,7 +665,7 @@ wxString Control::get_label(int tick, LabelType label_type/* = ltHeightWithLayer | |||
|         if (label_type == ltEstimatedTime) { | ||||
|             if (m_values.size() != m_layers_times.size()) | ||||
|                 return "time"; | ||||
|             return Slic3r::short_time(get_time_dhms(m_layers_times[value])); | ||||
|             return short_and_splitted_time(get_time_dhms(m_layers_times[value])); | ||||
|         } | ||||
|         wxString str = m_values.empty() ? | ||||
|             wxString::Format("%.*f", 2, m_label_koef * value) : | ||||
|  | @ -664,7 +716,10 @@ void Control::draw_tick_text(wxDC& dc, const wxPoint& pos, int tick, LabelType l | |||
|             text_pos = wxPoint(pos.x - text_width - 1 - m_thumb_size.x, pos.y - 0.5 * text_height + 1); | ||||
|     } | ||||
| 
 | ||||
|     dc.DrawText(label, text_pos); | ||||
|     if (label_type == ltEstimatedTime) | ||||
|         dc.DrawLabel(label, wxRect(text_pos, wxSize(text_width, text_height)), wxALIGN_RIGHT); | ||||
|     else | ||||
|         dc.DrawText(label, text_pos); | ||||
| } | ||||
| 
 | ||||
| void Control::draw_thumb_text(wxDC& dc, const wxPoint& pos, const SelectedSlider& selection) const | ||||
|  |  | |||
|  | @ -225,6 +225,7 @@ public: | |||
|     Info    GetTicksValues() const; | ||||
|     void    SetTicksValues(const Info &custom_gcode_per_print_z); | ||||
|     void    SetLayersTimes(const std::vector<float>& layers_times); | ||||
|     void    SetLayersTimes(const std::vector<double>& layers_times); | ||||
| 
 | ||||
|     void    SetDrawMode(bool is_sla_print, bool is_sequential_print); | ||||
| #if ENABLE_GCODE_VIEWER | ||||
|  | @ -402,7 +403,7 @@ private: | |||
| 
 | ||||
|     std::vector<double> m_values; | ||||
|     TickCodeInfo        m_ticks; | ||||
|     std::vector<float>  m_layers_times; | ||||
|     std::vector<double> m_layers_times; | ||||
| 
 | ||||
|     std::vector<std::string>    m_extruder_colors; | ||||
| 
 | ||||
|  |  | |||
|  | @ -657,7 +657,8 @@ void Preview::update_layers_slider(const std::vector<double>& layers_z, bool kee | |||
|     // Detect and set manipulation mode for double slider
 | ||||
|     update_layers_slider_mode(); | ||||
| 
 | ||||
|     CustomGCode::Info& ticks_info_from_model = wxGetApp().plater()->model().custom_gcode_per_print_z; | ||||
|     Plater* plater = wxGetApp().plater(); | ||||
|     CustomGCode::Info& ticks_info_from_model = plater->model().custom_gcode_per_print_z; | ||||
|     check_layers_slider_values(ticks_info_from_model.gcodes, layers_z); | ||||
| 
 | ||||
|     m_layers_slider->SetSliderValues(layers_z); | ||||
|  | @ -680,12 +681,15 @@ void Preview::update_layers_slider(const std::vector<double>& layers_z, bool kee | |||
|     } | ||||
|     m_layers_slider->SetSelectionSpan(idx_low, idx_high); | ||||
|     m_layers_slider->SetTicksValues(ticks_info_from_model); | ||||
|     m_layers_slider->SetLayersTimes(m_gcode_result->time_statistics.modes[0].layers_times); | ||||
| 
 | ||||
|     bool sla_print_technology = wxGetApp().plater()->printer_technology() == ptSLA; | ||||
|     bool sla_print_technology = plater->printer_technology() == ptSLA; | ||||
|     bool sequential_print = wxGetApp().preset_bundle->prints.get_edited_preset().config.opt_bool("complete_objects"); | ||||
|     m_layers_slider->SetDrawMode(sla_print_technology, sequential_print); | ||||
|     m_layers_slider->SetExtruderColors(wxGetApp().plater()->get_extruder_colors_from_plater_config()); | ||||
|     m_layers_slider->SetExtruderColors(plater->get_extruder_colors_from_plater_config()); | ||||
|     if (sla_print_technology) | ||||
|         m_layers_slider->SetLayersTimes(plater->sla_print().print_statistics().layers_times); | ||||
|     else | ||||
|         m_layers_slider->SetLayersTimes(m_gcode_result->time_statistics.modes[0].layers_times); | ||||
| 
 | ||||
|     m_layers_slider_sizer->Show((size_t)0); | ||||
|     Layout(); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 YuSanka
						YuSanka