gCode Legend & Viewer Improvements (#8198)

* commit

* update buttons and icons

* Update GCodeViewer.cpp

* Update GCodeViewer.cpp

* Update GCodeViewer.cpp

* replace invisible item icon

* reduce code changes & add svg icons for hidden / visible

* update

* Update GCodeViewer.cpp

* Update GCodeViewer.cpp

* Update GCodeViewer.cpp

* fix window width when scrollbar visible

* Update GCodeViewer.cpp

* Update GCodeViewer.cpp

* add corner rounding to all plate stats

* Update GCodeViewer.cpp

* update

---------

Co-authored-by: SoftFever <softfeverever@gmail.com>
This commit is contained in:
yw4z 2025-03-30 15:07:49 +03:00 committed by GitHub
parent 933b282c53
commit 9fe905c47d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 82 additions and 48 deletions

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><line x1="9.5" y1="1.5" x2="6.5" y2="14.5" style="fill:none;stroke:#fff;stroke-linecap:round;stroke-linejoin:round"/><polyline points="12.5 12.5 15.5 8 12.5 3.5" style="fill:none;stroke:#fff;stroke-linecap:round;stroke-linejoin:round"/><polyline points="3.5 3.5 0.5 8 3.5 12.5" style="fill:none;stroke:#fff;stroke-linecap:round;stroke-linejoin:round"/></svg>

After

Width:  |  Height:  |  Size: 441 B

View file

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path d="M2.5,11.5l6-3,6,3m0-5-6-3-6,3" style="fill:none;stroke:#fff;stroke-linecap:round;stroke-linejoin:round"/></svg> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><polyline points="1.5 6.5 8 2.5 14.5 6.5" style="fill:none;stroke:#fff;stroke-linecap:round;stroke-linejoin:round"/><polyline points="1.5 13.5 8 9.5 14.5 13.5" style="fill:none;stroke:#fff;stroke-linecap:round;stroke-linejoin:round"/></svg>

Before

Width:  |  Height:  |  Size: 203 B

After

Width:  |  Height:  |  Size: 323 B

Before After
Before After

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path d="M5.5,3.374A5.893,5.893,0,0,1,7.5,3a7.644,7.644,0,0,1,6.446,4.5,8.7,8.7,0,0,1-1.838,2.487l.717.717a9.687,9.687,0,0,0,2.221-3.2A8.654,8.654,0,0,0,7.5,2a7.069,7.069,0,0,0-2.765.614Z" style="fill:gray"/><path d="M7.5,4a3.464,3.464,0,0,0-1.165.214l4.451,4.451A3.464,3.464,0,0,0,11,7.5,3.5,3.5,0,0,0,7.5,4Z" style="fill:gray"/><path d="M9.505,11.626A5.893,5.893,0,0,1,7.5,12,7.644,7.644,0,0,1,1.054,7.5,8.7,8.7,0,0,1,2.892,5.013L2.175,4.3A9.687,9.687,0,0,0-.046,7.5,8.654,8.654,0,0,0,7.5,13a7.073,7.073,0,0,0,2.765-.614Z" style="fill:gray"/><path d="M7.5,11a3.464,3.464,0,0,0,1.165-.214L4.214,6.335A3.464,3.464,0,0,0,4,7.5,3.5,3.5,0,0,0,7.5,11Z" style="fill:gray"/><path d="M13.5,14a.5.5,0,0,1-.354-.146l-12-12a.5.5,0,0,1,.708-.708l12,12A.5.5,0,0,1,13.5,14Z" style="fill:gray"/></svg>

After

Width:  |  Height:  |  Size: 870 B

View file

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path d="M14.5,3.5l-6,3-6-3m0,5,6,3,6-3" style="fill:none;stroke:#fff;stroke-linecap:round;stroke-linejoin:round"/></svg> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><polyline points="1.5 2.5 8 6.5 14.5 2.5" style="fill:none;stroke:#fff;stroke-linecap:round;stroke-linejoin:round"/><polyline points="1.5 9.5 8 13.5 14.5 9.5" style="fill:none;stroke:#fff;stroke-linecap:round;stroke-linejoin:round"/></svg>

Before

Width:  |  Height:  |  Size: 204 B

After

Width:  |  Height:  |  Size: 322 B

Before After
Before After

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path d="M7.5,3a7.644,7.644,0,0,1,6.446,4.5A7.644,7.644,0,0,1,7.5,12,7.644,7.644,0,0,1,1.054,7.5,7.644,7.644,0,0,1,7.5,3m0-1A8.654,8.654,0,0,0-.046,7.5,8.654,8.654,0,0,0,7.5,13a8.654,8.654,0,0,0,7.546-5.5A8.654,8.654,0,0,0,7.5,2Z" style="fill:#009688"/><path d="M7.5,4A3.5,3.5,0,1,0,11,7.5,3.5,3.5,0,0,0,7.5,4Z" style="fill:#009688"/></svg>

After

Width:  |  Height:  |  Size: 423 B

View file

@ -173,6 +173,9 @@ namespace ImGui
const wchar_t SphereButtonIcon = 0x0816; const wchar_t SphereButtonIcon = 0x0816;
const wchar_t GapFillIcon = 0x0817; const wchar_t GapFillIcon = 0x0817;
const wchar_t ConfirmIcon = 0x0818; const wchar_t ConfirmIcon = 0x0818;
const wchar_t gCodeButtonIcon = 0x0819; // ORCA
const wchar_t VisibleIcon = 0x0820; // ORCA
const wchar_t HiddenIcon = 0x0821; // ORCA
const wchar_t MinimalizeDarkButton = 0x081C; const wchar_t MinimalizeDarkButton = 0x081C;
const wchar_t MinimalizeHoverDarkButton = 0x081D; const wchar_t MinimalizeHoverDarkButton = 0x081D;

View file

@ -596,9 +596,9 @@ void GCodeViewer::SequentialView::GCodeWindow::render(float top, float bottom, f
//BBS: GUI refactor: move to right //BBS: GUI refactor: move to right
//imgui.set_next_window_pos(0.0f, top, ImGuiCond_Always, 0.0f, 0.0f); //imgui.set_next_window_pos(0.0f, top, ImGuiCond_Always, 0.0f, 0.0f);
imgui.set_next_window_pos(right, top, ImGuiCond_Always, 1.0f, 0.0f); imgui.set_next_window_pos(right, top + 6 * m_scale, ImGuiCond_Always, 1.0f, 0.0f); // ORCA add a small gap between legend and code viewer
imgui.set_next_window_size(0.0f, wnd_height, ImGuiCond_Always); imgui.set_next_window_size(0.0f, wnd_height, ImGuiCond_Always);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 8.0f * m_scale); // ORCA add window rounding to modernize / match style
ImGui::SetNextWindowBgAlpha(0.8f); ImGui::SetNextWindowBgAlpha(0.8f);
imgui.begin(std::string("G-code"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove); imgui.begin(std::string("G-code"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove);
@ -879,6 +879,7 @@ void GCodeViewer::set_scale(float scale)
if (m_sequential_view.m_scale != scale) { if (m_sequential_view.m_scale != scale) {
m_sequential_view.m_scale = scale; m_sequential_view.m_scale = scale;
m_sequential_view.marker.m_scale = scale; m_sequential_view.marker.m_scale = scale;
m_sequential_view.gcode_window.m_scale = scale; // ORCA
} }
} }
@ -4053,7 +4054,7 @@ void GCodeViewer::render_all_plates_stats(const std::vector<const GCodeProcessor
} }
ImGuiWrapper& imgui = *wxGetApp().imgui(); ImGuiWrapper& imgui = *wxGetApp().imgui();
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 8.0f * m_scale); // ORCA add window rounding to modernize / match style
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0, 10.0 * m_scale)); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0, 10.0 * m_scale));
ImGui::PushStyleColor(ImGuiCol_Separator, ImVec4(1.0f, 1.0f, 1.0f, 0.6f)); ImGui::PushStyleColor(ImGuiCol_Separator, ImVec4(1.0f, 1.0f, 1.0f, 0.6f));
ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(0.00f, 0.68f, 0.26f, 1.0f)); ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(0.00f, 0.68f, 0.26f, 1.0f));
@ -4363,8 +4364,8 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
ImGuiWrapper& imgui = *wxGetApp().imgui(); ImGuiWrapper& imgui = *wxGetApp().imgui();
//BBS: GUI refactor: move to the right //BBS: GUI refactor: move to the right
imgui.set_next_window_pos(float(canvas_width - right_margin * m_scale), 0.0f, ImGuiCond_Always, 1.0f, 0.0f); imgui.set_next_window_pos(float(canvas_width - right_margin * m_scale), 4.0f * m_scale, ImGuiCond_Always, 1.0f, 0.0f); // ORCA add a small gap to top to create seperation with main toolbar
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 8.0f * m_scale); // ORCA add window rounding to modernize / match style
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0,0.0)); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0,0.0));
ImGui::PushStyleColor(ImGuiCol_Separator, ImVec4(1.0f,1.0f,1.0f,0.6f)); ImGui::PushStyleColor(ImGuiCol_Separator, ImVec4(1.0f,1.0f,1.0f,0.6f));
ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(0.00f, 0.59f, 0.53f, 1.0f)); ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(0.00f, 0.59f, 0.53f, 1.0f));
@ -4403,9 +4404,10 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
ImVec2 pos_rect = ImGui::GetCursorScreenPos(); ImVec2 pos_rect = ImGui::GetCursorScreenPos();
float window_padding = 4.0f * m_scale; float window_padding = 4.0f * m_scale;
draw_list->AddRectFilled(ImVec2(pos_rect.x,pos_rect.y - ImGui::GetStyle().WindowPadding.y), // ORCA dont use background on top bar to give modern look
ImVec2(pos_rect.x + ImGui::GetWindowWidth() + ImGui::GetFrameHeight(),pos_rect.y + ImGui::GetFrameHeight() + window_padding * 2.5), //draw_list->AddRectFilled(ImVec2(pos_rect.x,pos_rect.y - ImGui::GetStyle().WindowPadding.y),
ImGui::GetColorU32(ImVec4(0,0,0,0.3))); //ImVec2(pos_rect.x + ImGui::GetWindowWidth() + ImGui::GetFrameHeight(),pos_rect.y + ImGui::GetFrameHeight() + window_padding * 2.5),
//ImGui::GetColorU32(ImVec4(0,0,0,0.3)));
auto append_item = [icon_size, &imgui, imperial_units, &window_padding, &draw_list, this]( auto append_item = [icon_size, &imgui, imperial_units, &window_padding, &draw_list, this](
EItemType type, EItemType type,
@ -4464,12 +4466,14 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
if (b_menu_item) if (b_menu_item)
callback(); callback();
if (checkbox) { if (checkbox) {
ImGui::SameLine(ImGui::GetWindowWidth() - ImGui::CalcTextSize(_u8L("Display").c_str()).x / 2 - ImGui::GetFrameHeight() / 2 - 2 * window_padding); //ImGui::SameLine(ImGui::GetWindowWidth() - ImGui::CalcTextSize(_u8L("Display").c_str()).x / 2 - ImGui::GetFrameHeight() / 2 - 2 * window_padding);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0, 0.0)); //ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0, 0.0));
ImGui::PushStyleColor(ImGuiCol_CheckMark, ImVec4(0.00f, 0.59f, 0.53f, 1.00f)); //ImGui::PushStyleColor(ImGuiCol_CheckMark, ImVec4(0.00f, 0.59f, 0.53f, 1.00f));
ImGui::Checkbox(("##" + columns_offsets[0].first).c_str(), &visible); //ImGui::Checkbox(("##" + columns_offsets[0].first).c_str(), &visible);
ImGui::PopStyleColor(1); //ImGui::PopStyleVar(1);
ImGui::PopStyleVar(1); // ORCA replace checkboxes with eye icon
ImGui::SameLine(ImGui::GetWindowWidth() - (16.f + 0.f) * m_scale - window_padding * 2 - (ImGui::GetScrollMaxY() > 0.0f ? ImGui::GetStyle().ScrollbarSize : 0));
ImGui::Text(into_u8(visible ? ImGui::VisibleIcon : ImGui::HiddenIcon).c_str(), ImVec2(16 * m_scale, 16 * m_scale));
} }
} }
@ -4515,8 +4519,13 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
} }
}; };
auto append_headers = [&imgui, window_padding](const std::vector<std::pair<std::string, float>>& title_offsets) { auto append_headers = [&imgui, window_padding, this](const std::vector<std::pair<std::string, float>>& title_offsets) {
for (size_t i = 0; i < title_offsets.size(); i++) { for (size_t i = 0; i < title_offsets.size(); i++) {
if (title_offsets[i].first == _u8L("Display")) { // ORCA Hide Display header
ImGui::SameLine(title_offsets[i].second);
ImGui::Dummy({(16.f - 6.f) * m_scale, 1}); // 16(icon) - 6(half of spacing)
continue;
}
ImGui::SameLine(title_offsets[i].second); ImGui::SameLine(title_offsets[i].second);
imgui.bold_text(title_offsets[i].first); imgui.bold_text(title_offsets[i].first);
} }
@ -4534,14 +4543,16 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
return ret; return ret;
}; };
auto calculate_offsets = [&imgui, max_width, window_padding](const std::vector<std::pair<std::string, std::vector<::string>>>& title_columns, float extra_size = 0.0f) { auto calculate_offsets = [&imgui, max_width, window_padding, this](const std::vector<std::pair<std::string, std::vector<::string>>>& title_columns, float extra_size = 0.0f) {
const ImGuiStyle& style = ImGui::GetStyle(); const ImGuiStyle& style = ImGui::GetStyle();
std::vector<float> offsets; std::vector<float> offsets;
offsets.push_back(max_width(title_columns[0].second, title_columns[0].first, extra_size) + 3.0f * style.ItemSpacing.x); // ORCA increase spacing for more readable format. Using direct number requires much less code change in here. GetTextLineHeight for additional spacing for icon_size
offsets.push_back(max_width(title_columns[0].second, title_columns[0].first, extra_size) + 12.f * m_scale + ImGui::GetTextLineHeight());
for (size_t i = 1; i < title_columns.size() - 1; i++) for (size_t i = 1; i < title_columns.size() - 1; i++)
offsets.push_back(offsets.back() + max_width(title_columns[i].second, title_columns[i].first) + style.ItemSpacing.x); offsets.push_back(offsets.back() + max_width(title_columns[i].second, title_columns[i].first) + 12.f * m_scale); // ORCA increase spacing for more readable format. Using direct number requires much less code change in here
if (title_columns.back().first == _u8L("Display")) { if (title_columns.back().first == _u8L("Display")) {
const auto preferred_offset = ImGui::GetWindowWidth() - ImGui::CalcTextSize(_u8L("Display").c_str()).x - ImGui::GetFrameHeight() / 2 - 2 * window_padding - ImGui::GetStyle().ScrollbarSize; //const auto preferred_offset = ImGui::GetWindowWidth() - ImGui::CalcTextSize(_u8L("Display").c_str()).x - ImGui::GetFrameHeight() / 2 - 2 * window_padding - ImGui::GetStyle().ScrollbarSize;
const auto preferred_offset = ImGui::GetWindowWidth() - (16.f - 6.f) * m_scale - ImGui::GetFrameHeight() / 2 - 2 * window_padding - (ImGui::GetScrollMaxY() > 0.0f ? ImGui::GetStyle().ScrollbarSize : 0);
if (preferred_offset > offsets.back()) { if (preferred_offset > offsets.back()) {
offsets.back() = preferred_offset; offsets.back() = preferred_offset;
} }
@ -4553,7 +4564,6 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
for (size_t i = 1; i < title_columns.size(); i++) { for (size_t i = 1; i < title_columns.size(); i++) {
ret.push_back(std::max(offsets[i - 1], i * average_col_width)); ret.push_back(std::max(offsets[i - 1], i * average_col_width));
} }
return ret; return ret;
}; };
@ -4639,30 +4649,39 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
//BBS display Color Scheme //BBS display Color Scheme
ImGui::Dummy({ window_padding, window_padding }); ImGui::Dummy({ window_padding, window_padding });
ImGui::Dummy({ window_padding, window_padding }); ImGui::Dummy({ window_padding, window_padding });
ImGui::SameLine(); ImGui::SameLine(window_padding * 2); // ORCA Ignores item spacing to get perfect window margins since since this part uses dummies for window padding
std::wstring btn_name; std::wstring btn_name;
if (m_fold) if (m_fold)
btn_name = ImGui::UnfoldButtonIcon; btn_name = ImGui::UnfoldButtonIcon;
else else
btn_name = ImGui::FoldButtonIcon; btn_name = ImGui::FoldButtonIcon;
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.0f, 0.59f, 0.53f, 1.00f)); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(84 / 255.f, 84 / 255.f, 90 / 255.f, 1.f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.0f, 0.59f, 0.53f, 0.78f)); ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(84 / 255.f, 84 / 255.f, 90 / 255.f, 1.f));
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f)); float calc_padding = (ImGui::GetFrameHeight() - 16 * m_scale) / 2; // ORCA calculated padding for 16x16 icon
//ImGui::PushItemWidth( ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(calc_padding, calc_padding)); // ORCA Center icon with frame padding
float button_width = 34.0f; ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f * m_scale); // ORCA Match button style with combo box
if (ImGui::Button(into_u8(btn_name).c_str(), ImVec2(button_width, 0))) {
float button_width = 16 * m_scale + calc_padding * 2; // ORCA match buttons height with combo box
if (ImGui::Button(into_u8(btn_name).c_str(), ImVec2(button_width, button_width))) {
m_fold = !m_fold; m_fold = !m_fold;
} }
ImGui::PopStyleColor(3);
ImGui::PopStyleVar(1);
ImGui::SameLine(); ImGui::SameLine();
imgui.bold_text(_u8L("Color Scheme")); const wchar_t gCodeToggle = ImGui::gCodeButtonIcon;
if (ImGui::Button(into_u8(gCodeToggle).c_str(), ImVec2(button_width, button_width))) {
wxGetApp().toggle_show_gcode_window();
wxGetApp().plater()->get_current_canvas3D()->post_event(SimpleEvent(wxEVT_PAINT));
}
ImGui::PopStyleColor(3);
ImGui::PopStyleVar(2);
//imgui.bold_text(_u8L("Color Scheme"));
push_combo_style(); push_combo_style();
ImGui::SameLine(); ImGui::SameLine();
const char* view_type_value = view_type_items_str[m_view_type_sel].c_str(); const char* view_type_value = view_type_items_str[m_view_type_sel].c_str();
ImGuiComboFlags flags = 0; ImGuiComboFlags flags = ImGuiComboFlags_HeightLargest; // ORCA allow to fit all items to prevent scrolling on reaching last elements
if (ImGui::BBLBeginCombo("", view_type_value, flags)) { if (ImGui::BBLBeginCombo("", view_type_value, flags)) {
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 0.0f); ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 0.0f);
for (int i = 0; i < view_type_items_str.size(); i++) { for (int i = 0; i < view_type_items_str.size(); i++) {
@ -4685,11 +4704,15 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
ImGui::EndCombo(); ImGui::EndCombo();
} }
pop_combo_style(); pop_combo_style();
ImGui::SameLine(); ImGui::SameLine(0, window_padding); // ORCA Without (0,window_padding) it adds unnecessary item spacing after combo box
ImGui::Dummy({ window_padding, window_padding }); ImGui::Dummy({ window_padding, window_padding });
ImGui::Dummy({ window_padding, window_padding }); // ORCA Matches top-bottom window paddings
float window_width = ImGui::GetWindowWidth(); // ORCA Store window width
if (m_fold) { if (m_fold) {
legend_height = ImGui::GetStyle().WindowPadding.y + ImGui::GetFrameHeight() + window_padding * 2.5; legend_height = ImGui::GetFrameHeight() + window_padding * 4; // ORCA using 4 instead 2 gives correct toolbar margins while its folded
ImGui::SameLine(window_width); // ORCA use stored window width while folded. This prevents annoying position change on fold/expand button
ImGui::Dummy({ 0, 0 });
imgui.end(); imgui.end();
ImGui::PopStyleColor(6); ImGui::PopStyleColor(6);
ImGui::PopStyleVar(2); ImGui::PopStyleVar(2);
@ -4813,16 +4836,16 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
labels.push_back(_u8L(ExtrusionEntity::role_to_string(role))); labels.push_back(_u8L(ExtrusionEntity::role_to_string(role)));
auto [time, percent] = role_time_and_percent(role); auto [time, percent] = role_time_and_percent(role);
times.push_back((time > 0.0f) ? short_time(get_time_dhms(time)) : ""); times.push_back((time > 0.0f) ? short_time(get_time_dhms(time)) : "");
if (percent == 0) if (percent == 0) // ORCA remove % symbol from rows
::sprintf(buffer, "0%%"); ::sprintf(buffer, "0");
else else
percent > 0.001 ? ::sprintf(buffer, "%.1f%%", percent * 100) : ::sprintf(buffer, "<0.1%%"); percent > 0.001 ? ::sprintf(buffer, "%.1f", percent * 100) : ::sprintf(buffer, "<0.1");
percents.push_back(buffer); percents.push_back(buffer);
auto [model_used_filament_m, model_used_filament_g] = used_filament_per_role(role); auto [model_used_filament_m, model_used_filament_g] = used_filament_per_role(role);
::sprintf(buffer, imperial_units ? "%.2f in" : "%.2f m", model_used_filament_m); ::sprintf(buffer, imperial_units ? "%.2fin" : "%.2fm", model_used_filament_m); // ORCA dont use spacing between value and unit
used_filaments_length.push_back(buffer); used_filaments_length.push_back(buffer);
::sprintf(buffer, imperial_units ? "%.2f oz" : "%.2f g", model_used_filament_g); ::sprintf(buffer, imperial_units ? "%.2foz" : "%.2fg", model_used_filament_g); // ORCA dont use spacing between value and unit
used_filaments_weight.push_back(buffer); used_filaments_weight.push_back(buffer);
} }
} }
@ -4831,15 +4854,16 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
{ {
auto [time, percent] = move_time_and_percent(EMoveType::Travel); auto [time, percent] = move_time_and_percent(EMoveType::Travel);
travel_time = (time > 0.0f) ? short_time(get_time_dhms(time)) : ""; travel_time = (time > 0.0f) ? short_time(get_time_dhms(time)) : "";
if (percent == 0) if (percent == 0) // ORCA remove % symbol from rows
::sprintf(buffer, "0%%"); ::sprintf(buffer, "0");
else else
percent > 0.001 ? ::sprintf(buffer, "%.1f%%", percent * 100) : ::sprintf(buffer, "<0.1%%"); percent > 0.001 ? ::sprintf(buffer, "%.1f", percent * 100) : ::sprintf(buffer, "<0.1");
travel_percent = buffer; travel_percent = buffer;
} }
offsets = calculate_offsets({ {_u8L("Line Type"), labels}, {_u8L("Time"), times}, {_u8L("Percent"), percents}, {"", used_filaments_length}, {"", used_filaments_weight}, {_u8L("Display"), {""}}}, icon_size); // ORCA use % symbol for percentage and use "Usage" for "Used filaments"
append_headers({{_u8L("Line Type"), offsets[0]}, {_u8L("Time"), offsets[1]}, {_u8L("Percent"), offsets[2]}, {_u8L("Used filament"), offsets[3]}, {_u8L("Display"), offsets[5]}}); offsets = calculate_offsets({ {_u8L("Line Type"), labels}, {_u8L("Time"), times}, {_u8L("%"), percents}, {"", used_filaments_length}, {"", used_filaments_weight}, {_u8L("Display"), {""}}}, icon_size);
append_headers({{_u8L("Line Type"), offsets[0]}, {_u8L("Time"), offsets[1]}, {_u8L("%"), offsets[2]}, {_u8L("Usage"), offsets[3]}, {_u8L("Display"), offsets[5]}});
break; break;
} }
case EViewType::Height: { imgui.title(_u8L("Layer Height (mm)")); break; } case EViewType::Height: { imgui.title(_u8L("Layer Height (mm)")); break; }
@ -4870,7 +4894,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
} }
offsets = calculate_offsets({ { "Extruder NNN", {""}}}, icon_size); offsets = calculate_offsets({ { "Extruder NNN", {""}}}, icon_size);
append_headers({ {_u8L("Filament"), offsets[0]}, {_u8L("Used filament"), offsets[1]} }); append_headers({ {_u8L("Filament"), offsets[0]}, {_u8L("Usage"), offsets[1]} });
break; break;
} }
case EViewType::ColorPrint: case EViewType::ColorPrint:
@ -5699,8 +5723,8 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
void GCodeViewer::push_combo_style() void GCodeViewer::push_combo_style()
{ {
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f * m_scale); // ORCA scale rounding
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f * m_scale); // ORCA scale frame size
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8.0,8.0)); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8.0,8.0));
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.0f, 0.0f, 0.0f, 0.3f)); ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.0f, 0.0f, 0.0f, 0.3f));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.0f, 0.0f, 0.0f, 0.3f)); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.0f, 0.0f, 0.0f, 0.3f));

View file

@ -660,6 +660,7 @@ public:
std::vector<Line> m_lines; std::vector<Line> m_lines;
public: public:
float m_scale = 1.0f;
GCodeWindow() = default; GCodeWindow() = default;
~GCodeWindow() { stop_mapping_file(); } ~GCodeWindow() { stop_mapping_file(); }
void load_gcode(const std::string& filename, const std::vector<size_t> &lines_ends); void load_gcode(const std::string& filename, const std::vector<size_t> &lines_ends);

View file

@ -71,6 +71,9 @@ static const std::map<const wchar_t, std::string> font_icons = {
{ImGui::GapFillIcon , "gap_fill" }, {ImGui::GapFillIcon , "gap_fill" },
{ImGui::FoldButtonIcon , "im_fold" }, {ImGui::FoldButtonIcon , "im_fold" },
{ImGui::UnfoldButtonIcon , "im_unfold" }, {ImGui::UnfoldButtonIcon , "im_unfold" },
{ImGui::gCodeButtonIcon , "im_code" }, //ORCA
{ImGui::VisibleIcon , "im_visible" }, //ORCA
{ImGui::HiddenIcon , "im_hidden" }, //ORCA
{ImGui::SphereButtonIcon , "toolbar_modifier_sphere" }, {ImGui::SphereButtonIcon , "toolbar_modifier_sphere" },
// dark mode icon // dark mode icon
{ImGui::MinimalizeDarkButton , "notification_minimalize_dark" }, {ImGui::MinimalizeDarkButton , "notification_minimalize_dark" },