Follow-up last commit: Fixed warnings and added missed include

This commit is contained in:
YuSanka 2024-04-05 13:15:11 +02:00
parent e9361b4f61
commit ed51fc24c9
10 changed files with 23 additions and 54 deletions

View File

@ -328,7 +328,7 @@ void GCodeViewer::SequentialView::Marker::render_position_window(const libvgcode
}
if (properties_shown) {
auto append_table_row = [&imgui](const std::string& label, std::function<void(void)> value_callback) {
auto append_table_row = [](const std::string& label, std::function<void(void)> value_callback) {
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGuiPureWrap::text_colored(ImGuiPureWrap::COL_ORANGE_LIGHT, label);
@ -340,13 +340,13 @@ void GCodeViewer::SequentialView::Marker::render_position_window(const libvgcode
if (ImGui::BeginTable("Properties", 2)) {
char buff[1024];
append_table_row(_u8L("Type"), [&imgui, &vertex]() {
append_table_row(_u8L("Type"), [&vertex]() {
std::string text = _u8L(to_string(vertex.type));
if (vertex.is_extrusion())
text += " (" + _u8L(to_string(vertex.role)) + ")";
ImGuiPureWrap::text(text);
});
append_table_row(_u8L("Width") + " (" + _u8L("mm") + ")", [&imgui, &vertex, &buff]() {
append_table_row(_u8L("Width") + " (" + _u8L("mm") + ")", [&vertex, &buff]() {
std::string text;
if (vertex.is_extrusion()) {
sprintf(buff, "%.3f", vertex.width);
@ -356,7 +356,7 @@ void GCodeViewer::SequentialView::Marker::render_position_window(const libvgcode
text = _u8L("N/A");
ImGuiPureWrap::text(text);
});
append_table_row(_u8L("Height") + " (" + _u8L("mm") + ")", [&imgui, &vertex, &buff]() {
append_table_row(_u8L("Height") + " (" + _u8L("mm") + ")", [&vertex, &buff]() {
std::string text;
if (vertex.is_extrusion()) {
sprintf(buff, "%.3f", vertex.height);
@ -366,13 +366,13 @@ void GCodeViewer::SequentialView::Marker::render_position_window(const libvgcode
text = _u8L("N/A");
ImGuiPureWrap::text(text);
});
append_table_row(_u8L("Layer"), [&imgui, &vertex, &buff]() {
append_table_row(_u8L("Layer"), [&vertex, &buff]() {
sprintf(buff, "%d", vertex.layer_id + 1);
const std::string text = std::string(buff);
ImGuiPureWrap::text(text);
});
#if !ENABLE_ACTUAL_SPEED_DEBUG
append_table_row(_u8L("Speed") + " (" + _u8L("mm/s") + ")", [&imgui, &vertex, &buff]() {
append_table_row(_u8L("Speed") + " (" + _u8L("mm/s") + ")", [&vertex, &buff]() {
std::string text;
if (vertex.is_extrusion()) {
sprintf(buff, "%.1f", vertex.feedrate);
@ -382,7 +382,7 @@ void GCodeViewer::SequentialView::Marker::render_position_window(const libvgcode
text = _u8L("N/A");
ImGuiPureWrap::text(text);
});
append_table_row(_u8L("Actual speed") + " (" + _u8L("mm/s") + ")", [&imgui, &vertex, &buff]() {
append_table_row(_u8L("Actual speed") + " (" + _u8L("mm/s") + ")", [&vertex, &buff]() {
std::string text;
if (vertex.is_extrusion()) {
sprintf(buff, "%.1f", vertex.actual_feedrate);
@ -393,7 +393,7 @@ void GCodeViewer::SequentialView::Marker::render_position_window(const libvgcode
ImGuiPureWrap::text(text);
});
#endif // !ENABLE_ACTUAL_SPEED_DEBUG
append_table_row(_u8L("Fan speed") + " (" + _u8L("%") + ")", [&imgui, &vertex, &buff]() {
append_table_row(_u8L("Fan speed") + " (" + _u8L("%") + ")", [&vertex, &buff]() {
std::string text;
if (vertex.is_extrusion()) {
sprintf(buff, "%.0f", vertex.fan_speed);
@ -403,11 +403,11 @@ void GCodeViewer::SequentialView::Marker::render_position_window(const libvgcode
text = _u8L("N/A");
ImGuiPureWrap::text(text);
});
append_table_row(_u8L("Temperature") + " (" + _u8L("°C") + ")", [&imgui, &vertex, &buff]() {
append_table_row(_u8L("Temperature") + " (" + _u8L("°C") + ")", [&vertex, &buff]() {
sprintf(buff, "%.0f", vertex.temperature);
ImGuiPureWrap::text(std::string(buff));
});
append_table_row(_u8L("Time"), [viewer, &imgui, &vertex, &buff, vertex_id]() {
append_table_row(_u8L("Time"), [viewer, &vertex, &buff, vertex_id]() {
const float estimated_time = viewer->get_estimated_time_at(vertex_id);
sprintf(buff, "%s (%.3fs)", get_time_dhms(estimated_time).c_str(), vertex.times[static_cast<size_t>(viewer->get_time_mode())]);
const std::string text = std::string(buff);
@ -721,7 +721,7 @@ void GCodeViewer::SequentialView::GCodeWindow::render(float top, float bottom, s
ImGuiWrapper& imgui = *wxGetApp().imgui();
auto add_item_to_line = [&imgui](const std::string& txt, const ImVec4& color, float spacing, size_t& current_length) {
auto add_item_to_line = [](const std::string& txt, const ImVec4& color, float spacing, size_t& current_length) {
static const size_t LENGTH_THRESHOLD = 60;
if (txt.empty())
@ -2085,7 +2085,7 @@ void GCodeViewer::render_legend(float& legend_height)
}
};
auto append_headers = [&imgui](const std::array<std::string, 5>& texts, const std::array<float, 4>& offsets) {
auto append_headers = [](const std::array<std::string, 5>& texts, const std::array<float, 4>& offsets) {
size_t i = 0;
for (; i < offsets.size(); i++) {
ImGuiPureWrap::text(texts[i]);
@ -2537,7 +2537,7 @@ void GCodeViewer::render_legend(float& legend_height)
return items;
};
auto append_color_change = [&imgui](const ColorRGBA& color1, const ColorRGBA& color2, const std::array<float, 4>& offsets, const Times& times) {
auto append_color_change = [](const ColorRGBA& color1, const ColorRGBA& color2, const std::array<float, 4>& offsets, const Times& times) {
ImGuiPureWrap::text(_u8L("Color change"));
ImGui::SameLine();
@ -2556,7 +2556,7 @@ void GCodeViewer::render_legend(float& legend_height)
ImGuiPureWrap::text(short_time_ui(get_time_dhms(times.second - times.first)));
};
auto append_print = [&imgui, imperial_units](const ColorRGBA& color, const std::array<float, 4>& offsets, const Times& times, std::pair<double, double> used_filament) {
auto append_print = [imperial_units](const ColorRGBA& color, const std::array<float, 4>& offsets, const Times& times, std::pair<double, double> used_filament) {
ImGuiPureWrap::text(_u8L("Print"));
ImGui::SameLine();
@ -2644,7 +2644,7 @@ void GCodeViewer::render_legend(float& legend_height)
}
}
auto add_strings_row_to_table = [&imgui](const std::string& col_1, const ImVec4& col_1_color, const std::string& col_2, const ImVec4& col_2_color) {
auto add_strings_row_to_table = [](const std::string& col_1, const ImVec4& col_1_color, const std::string& col_2, const ImVec4& col_2_color) {
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGuiPureWrap::text_colored(col_1_color, col_1.c_str());
@ -2778,7 +2778,7 @@ void GCodeViewer::render_legend(float& legend_height)
}
// toolbar section
auto toggle_button = [this, &imgui, icon_size](Preview::OptionType type, const std::string& name,
auto toggle_button = [this, icon_size](Preview::OptionType type, const std::string& name,
std::function<void(ImGuiWindow& window, const ImVec2& pos, float size)> draw_callback) {
bool active = false;
#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS

View File

@ -1874,7 +1874,6 @@ void GLCanvas3D::render()
_render_overlays();
if (wxGetApp().plater()->is_render_statistic_dialog_visible()) {
ImGuiWrapper& imgui = *wxGetApp().imgui();
ImGuiPureWrap::begin(std::string("Render statistics"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
ImGuiPureWrap::text("FPS (SwapBuffers() calls per second):");
ImGui::SameLine();
@ -4562,8 +4561,6 @@ bool GLCanvas3D::_render_undo_redo_stack(const bool is_undo, float pos_x)
{
bool action_taken = false;
ImGuiWrapper* imgui = wxGetApp().imgui();
ImGuiPureWrap::set_next_window_pos(pos_x, m_undoredo_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
std::string title = is_undo ? _u8L("Undo History") : _u8L("Redo History");
ImGuiPureWrap::begin(title, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);

View File

@ -154,7 +154,7 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
window_width = std::max(window_width, tool_type_radio_left + tool_type_radio_brush + tool_type_radio_smart_fill);
window_width = std::max(window_width, 2.f * buttons_width + m_imgui->scaled(1.f));
auto draw_text_with_caption = [this, &caption_max](const std::string& caption, const std::string& text) {
auto draw_text_with_caption = [&caption_max](const std::string& caption, const std::string& text) {
ImGuiPureWrap::text_colored(ImGuiPureWrap::COL_ORANGE_LIGHT, caption);
ImGui::SameLine(caption_max);
ImGuiPureWrap::text(text);

View File

@ -1842,7 +1842,7 @@ void GLGizmoMeasure::on_render_input_window(float x, float y, float bottom_limit
if (ImGui::BeginTable("Commands", 2)) {
unsigned int row_count = 1;
add_row_to_table(
[this]() {
[]() {
ImGuiPureWrap::text_colored(ImGuiPureWrap::COL_ORANGE_LIGHT, _u8L("Left mouse button"));
},
[this]() {
@ -1978,7 +1978,7 @@ void GLGizmoMeasure::on_render_input_window(float x, float y, float bottom_limit
if (m_selected_features.first.feature.has_value() || m_selected_features.second.feature.has_value()) {
add_row_to_table(
[this]() {
[]() {
ImGuiPureWrap::text_colored(ImGuiPureWrap::COL_ORANGE_LIGHT, "Esc");
},
[this]() {

View File

@ -319,7 +319,7 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
window_width = std::max(window_width, tool_type_radio_brush + tool_type_radio_bucket_fill + tool_type_radio_smart_fill);
window_width = std::max(window_width, 2.f * buttons_width + m_imgui->scaled(1.f));
auto draw_text_with_caption = [this, &caption_max](const std::string &caption, const std::string& text) {
auto draw_text_with_caption = [&caption_max](const std::string &caption, const std::string& text) {
ImGuiPureWrap::text_colored(ImGuiPureWrap::COL_ORANGE_LIGHT, caption);
ImGui::SameLine(caption_max);
ImGuiPureWrap::text(text);

View File

@ -633,7 +633,6 @@ void GLGizmoRotate3D::on_unregister_raycasters_for_picking()
GLGizmoRotate3D::RotoptimzeWindow::RotoptimzeWindow(ImGuiWrapper * imgui,
State & state,
const Alignment &alignment)
: m_imgui{imgui}
{
ImGuiPureWrap::begin(_u8L("Optimize orientation"), ImGuiWindowFlags_NoMove |
ImGuiWindowFlags_AlwaysAutoResize |

View File

@ -177,8 +177,6 @@ private:
class RotoptimzeWindow
{
ImGuiWrapper *m_imgui = nullptr;
public:
struct State {
float accuracy = 1.f;

View File

@ -113,7 +113,7 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit)
window_width = std::max(window_width, button_width);
window_width = std::max(window_width, cursor_type_radio_left + cursor_type_radio_sphere + cursor_type_radio_circle);
auto draw_text_with_caption = [this, &caption_max](const std::string& caption, const std::string& text) {
auto draw_text_with_caption = [&caption_max](const std::string& caption, const std::string& text) {
ImGuiPureWrap::text_colored(ImGuiPureWrap::COL_ORANGE_LIGHT, caption);
ImGui::SameLine(caption_max);
ImGuiPureWrap::text(text);

View File

@ -8,6 +8,7 @@
#include <string>
#include <string_view>
#include <vector>
#include <optional>
#include <imgui/imgui.h>

View File

@ -470,32 +470,6 @@ bool ImGuiWrapper::slider_float(const wxString& label, float* v, float v_min, fl
return this->slider_float(label_utf8.c_str(), v, v_min, v_max, format, power, clamp, tooltip, show_edit_btn);
}
static bool image_button_ex(ImGuiID id, ImTextureID texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec2& padding, const ImVec4& bg_col, const ImVec4& tint_col, ImGuiButtonFlags flags)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = ImGui::GetCurrentWindow();
if (window->SkipItems)
return false;
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size + padding * 2);
ImGui::ItemSize(bb);
if (!ImGui::ItemAdd(bb, id))
return false;
bool hovered, held;
bool pressed = ImGui::ButtonBehavior(bb, id, &hovered, &held, flags);
// Render
const ImU32 col = ImGui::GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
ImGui::RenderNavHighlight(bb, id);
ImGui::RenderFrame(bb.Min, bb.Max, col, true, ImClamp((float)ImMin(padding.x, padding.y), 0.0f, g.Style.FrameRounding));
if (bg_col.w > 0.0f)
window->DrawList->AddRectFilled(bb.Min + padding, bb.Max - padding, ImGui::GetColorU32(bg_col));
window->DrawList->AddImage(texture_id, bb.Min + padding, bb.Max - padding, uv0, uv1, ImGui::GetColorU32(tint_col));
return pressed;
}
bool ImGuiWrapper::image_button(const wchar_t icon, const std::string& tooltip)
{
const ImGuiIO& io = ImGui::GetIO();
@ -821,7 +795,7 @@ void ImGuiWrapper::search_list(const ImVec2& size_, bool (*items_getter)(int, co
ImGui::ListBoxFooter();
auto check_box = [&edited, this](const std::string& label, bool& check) {
auto check_box = [&edited](const std::string& label, bool& check) {
ImGui::SameLine();
bool ch = check;
ImGuiPureWrap::checkbox(label, ch);