mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Show both layer time and tick info when tick is highlighted (#2312)
* Show both layer time and tick info when tick is highlighted * Use previous layer's complete time as current layer's tick time
This commit is contained in:
		
							parent
							
								
									8e70081879
								
							
						
					
					
						commit
						d31ca04720
					
				
					 1 changed files with 20 additions and 15 deletions
				
			
		| 
						 | 
					@ -6,7 +6,6 @@
 | 
				
			||||||
#define IMGUI_DEFINE_MATH_OPERATORS
 | 
					#define IMGUI_DEFINE_MATH_OPERATORS
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#include <imgui/imgui_internal.h>
 | 
					#include <imgui/imgui_internal.h>
 | 
				
			||||||
#include <boost/algorithm/string/replace.hpp>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Slic3r {
 | 
					namespace Slic3r {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -102,19 +101,19 @@ static std::string short_and_splitted_time(const std::string &time)
 | 
				
			||||||
    // Format the dhm time.
 | 
					    // Format the dhm time.
 | 
				
			||||||
    char buffer[64];
 | 
					    char buffer[64];
 | 
				
			||||||
    if (days > 0)
 | 
					    if (days > 0)
 | 
				
			||||||
        ::sprintf(buffer, "%dd%dh\n%dm", days, hours, minutes);
 | 
					        ::sprintf(buffer, "%dd%dh%dm", days, hours, minutes);
 | 
				
			||||||
    else if (hours > 0) {
 | 
					    else if (hours > 0) {
 | 
				
			||||||
        if (hours < 10 && minutes < 10 && seconds < 10)
 | 
					        if (hours < 10 && minutes < 10 && seconds < 10)
 | 
				
			||||||
            ::sprintf(buffer, "%dh%dm%ds", hours, minutes, seconds);
 | 
					            ::sprintf(buffer, "%dh%dm%ds", hours, minutes, seconds);
 | 
				
			||||||
        else if (hours > 10 && minutes > 10 && seconds > 10)
 | 
					        else if (hours > 10 && minutes > 10 && seconds > 10)
 | 
				
			||||||
            ::sprintf(buffer, "%dh\n%dm\n%ds", hours, minutes, seconds);
 | 
					            ::sprintf(buffer, "%dh%dm%ds", hours, minutes, seconds);
 | 
				
			||||||
        else if ((minutes < 10 && seconds > 10) || (minutes > 10 && seconds < 10))
 | 
					        else if ((minutes < 10 && seconds > 10) || (minutes > 10 && seconds < 10))
 | 
				
			||||||
            ::sprintf(buffer, "%dh\n%dm%ds", hours, minutes, seconds);
 | 
					            ::sprintf(buffer, "%dh%dm%ds", hours, minutes, seconds);
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
            ::sprintf(buffer, "%dh%dm\n%ds", hours, minutes, seconds);
 | 
					            ::sprintf(buffer, "%dh%dm%ds", hours, minutes, seconds);
 | 
				
			||||||
    } else if (minutes > 0) {
 | 
					    } else if (minutes > 0) {
 | 
				
			||||||
        if (minutes > 10 && seconds > 10)
 | 
					        if (minutes > 10 && seconds > 10)
 | 
				
			||||||
            ::sprintf(buffer, "%dm\n%ds", minutes, seconds);
 | 
					            ::sprintf(buffer, "%dm%ds", minutes, seconds);
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
            ::sprintf(buffer, "%dm%ds", minutes, seconds);
 | 
					            ::sprintf(buffer, "%dm%ds", minutes, seconds);
 | 
				
			||||||
    } else
 | 
					    } else
 | 
				
			||||||
| 
						 | 
					@ -725,21 +724,32 @@ void IMSlider::show_tooltip(const std::string tooltip) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void IMSlider::show_tooltip(const TickCode& tick){
 | 
					void IMSlider::show_tooltip(const TickCode& tick){
 | 
				
			||||||
 | 
					    // Use previous layer's complete time as current layer's tick time,
 | 
				
			||||||
 | 
					    // since ticks are added at the beginning of current layer
 | 
				
			||||||
 | 
					    std::string time_str = "";
 | 
				
			||||||
 | 
					    // TODO: support first layer
 | 
				
			||||||
 | 
					    if (tick.tick > 0) {
 | 
				
			||||||
 | 
					        time_str = get_label(tick.tick - 1, ltEstimatedTime);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if (!time_str.empty()) {
 | 
				
			||||||
 | 
					        time_str += "\n";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    switch (tick.type)
 | 
					    switch (tick.type)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    case CustomGCode::ColorChange:
 | 
					    case CustomGCode::ColorChange:
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
    case CustomGCode::PausePrint:
 | 
					    case CustomGCode::PausePrint:
 | 
				
			||||||
        show_tooltip(_u8L("Pause:") + " \"" + gcode(PausePrint) + "\"");
 | 
					        show_tooltip(time_str + _u8L("Pause:") + " \"" + gcode(PausePrint) + "\"");
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
    case CustomGCode::ToolChange:
 | 
					    case CustomGCode::ToolChange:
 | 
				
			||||||
        show_tooltip(_u8L("Change Filament"));
 | 
					        show_tooltip(time_str + _u8L("Change Filament"));
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
    case CustomGCode::Template:
 | 
					    case CustomGCode::Template:
 | 
				
			||||||
        show_tooltip(_u8L("Custom Template:") + " \"" + gcode(Template) + "\"");
 | 
					        show_tooltip(time_str + _u8L("Custom Template:") + " \"" + gcode(Template) + "\"");
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
    case CustomGCode::Custom:
 | 
					    case CustomGCode::Custom:
 | 
				
			||||||
        show_tooltip(_u8L("Custom G-code:") + " \"" + tick.extra + "\"");
 | 
					        show_tooltip(time_str + _u8L("Custom G-code:") + " \"" + tick.extra + "\"");
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
    default:
 | 
					    default:
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
| 
						 | 
					@ -769,10 +779,6 @@ void IMSlider::draw_tick_on_mouse_position(const ImRect& slideable_region) {
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    int tick = get_tick_near_point(v_min, v_max, context.IO.MousePos, slideable_region);
 | 
					    int tick = get_tick_near_point(v_min, v_max, context.IO.MousePos, slideable_region);
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
//    if (tick == v_min || tick == v_max) {
 | 
					 | 
				
			||||||
//        return;
 | 
					 | 
				
			||||||
//    }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    //draw tick
 | 
					    //draw tick
 | 
				
			||||||
    ImVec2 tick_offset   = ImVec2(22.0f, 14.0f) * m_scale;
 | 
					    ImVec2 tick_offset   = ImVec2(22.0f, 14.0f) * m_scale;
 | 
				
			||||||
    float  tick_width    = 1.0f * m_scale;
 | 
					    float  tick_width    = 1.0f * m_scale;
 | 
				
			||||||
| 
						 | 
					@ -787,7 +793,6 @@ void IMSlider::draw_tick_on_mouse_position(const ImRect& slideable_region) {
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    // draw layer time
 | 
					    // draw layer time
 | 
				
			||||||
    std::string label = get_label(tick, ltEstimatedTime);
 | 
					    std::string label = get_label(tick, ltEstimatedTime);
 | 
				
			||||||
    boost::ireplace_all(label, "\n", "");
 | 
					 | 
				
			||||||
    show_tooltip(label);
 | 
					    show_tooltip(label);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue