Preview legend: title of estimated print time section dependent on results
This commit is contained in:
parent
c732deeb91
commit
c9dffd0c89
1 changed files with 25 additions and 16 deletions
|
@ -3341,14 +3341,31 @@ void GCodeViewer::render_legend(float& legend_height) const
|
||||||
if (show_estimated_time) {
|
if (show_estimated_time) {
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
std::string time_title = _u8L("Estimated printing times");
|
std::string time_title = _u8L("Estimated printing times");
|
||||||
switch (m_time_estimate_mode)
|
auto can_show_mode_button = [this](PrintEstimatedStatistics::ETimeMode mode) {
|
||||||
{
|
bool show = false;
|
||||||
case PrintEstimatedStatistics::ETimeMode::Normal: { time_title += " [" + _u8L("Normal mode") + "]:"; break; }
|
if (m_print_statistics.modes.size() > 1 && m_print_statistics.modes[static_cast<size_t>(mode)].roles_times.size() > 0) {
|
||||||
case PrintEstimatedStatistics::ETimeMode::Stealth: { time_title += " [" + _u8L("Stealth mode") + "]:"; break; }
|
for (size_t i = 0; i < m_print_statistics.modes.size(); ++i) {
|
||||||
default: { assert(false); break; }
|
if (i != static_cast<size_t>(mode) &&
|
||||||
|
m_print_statistics.modes[i].time > 0.0f &&
|
||||||
|
short_time(get_time_dhms(m_print_statistics.modes[static_cast<size_t>(mode)].time)) != short_time(get_time_dhms(m_print_statistics.modes[i].time))) {
|
||||||
|
show = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return show;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (can_show_mode_button(m_time_estimate_mode)) {
|
||||||
|
switch (m_time_estimate_mode)
|
||||||
|
{
|
||||||
|
case PrintEstimatedStatistics::ETimeMode::Normal: { time_title += " [" + _u8L("Normal mode") + "]"; break; }
|
||||||
|
case PrintEstimatedStatistics::ETimeMode::Stealth: { time_title += " [" + _u8L("Stealth mode") + "]"; break; }
|
||||||
|
default: { assert(false); break; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
imgui.title(time_title);
|
imgui.title(time_title + ":");
|
||||||
|
|
||||||
std::string first_str = _u8L("First layer");
|
std::string first_str = _u8L("First layer");
|
||||||
std::string total_str = _u8L("Total");
|
std::string total_str = _u8L("Total");
|
||||||
|
@ -3369,16 +3386,8 @@ void GCodeViewer::render_legend(float& legend_height) const
|
||||||
ImGui::SameLine(max_len);
|
ImGui::SameLine(max_len);
|
||||||
imgui.text(short_time(get_time_dhms(time_mode.time)));
|
imgui.text(short_time(get_time_dhms(time_mode.time)));
|
||||||
|
|
||||||
auto show_mode_button = [this, &imgui](const wxString& label, PrintEstimatedStatistics::ETimeMode mode) {
|
auto show_mode_button = [this, &imgui, can_show_mode_button](const wxString& label, PrintEstimatedStatistics::ETimeMode mode) {
|
||||||
bool show = false;
|
if (can_show_mode_button(mode)) {
|
||||||
for (size_t i = 0; i < m_print_statistics.modes.size(); ++i) {
|
|
||||||
if (i != static_cast<size_t>(mode) &&
|
|
||||||
short_time(get_time_dhms(m_print_statistics.modes[static_cast<size_t>(mode)].time)) != short_time(get_time_dhms(m_print_statistics.modes[i].time))) {
|
|
||||||
show = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (show && m_print_statistics.modes[static_cast<size_t>(mode)].roles_times.size() > 0) {
|
|
||||||
if (imgui.button(label)) {
|
if (imgui.button(label)) {
|
||||||
*const_cast<PrintEstimatedStatistics::ETimeMode*>(&m_time_estimate_mode) = mode;
|
*const_cast<PrintEstimatedStatistics::ETimeMode*>(&m_time_estimate_mode) = mode;
|
||||||
wxGetApp().plater()->get_current_canvas3D()->set_as_dirty();
|
wxGetApp().plater()->get_current_canvas3D()->set_as_dirty();
|
||||||
|
|
Loading…
Reference in a new issue