FIX:gcode viewer color arrangement recommendation
1.Limit of four filaments per row 2.Fix incorrect data 3.Add filament id display 4.Optimised layout Change-Id: I9ac3701c99597a5ed243dac0e3e371cf9aca4066
This commit is contained in:
parent
4086ec60c2
commit
3321277f86
|
@ -1012,16 +1012,6 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr
|
||||||
m_gcode_result = &gcode_result;
|
m_gcode_result = &gcode_result;
|
||||||
m_only_gcode_in_preview = only_gcode;
|
m_only_gcode_in_preview = only_gcode;
|
||||||
|
|
||||||
std::vector<int> filament_maps = print.get_filament_maps();
|
|
||||||
std::vector<std::string> color_opt = print.config().option<ConfigOptionStrings>("filament_colour")->values;
|
|
||||||
std::vector<std::string> type_opt = print.config().option<ConfigOptionStrings>("filament_type")->values;
|
|
||||||
for (int i = 0; i < filament_maps.size(); ++i) {
|
|
||||||
if (filament_maps[i] == 1) {
|
|
||||||
m_left_extruder_filament.emplace_back(type_opt[i], color_opt[i]);
|
|
||||||
} else {
|
|
||||||
m_right_extruder_filament.emplace_back(type_opt[i], color_opt[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_sequential_view.gcode_window.load_gcode(gcode_result.filename, gcode_result.lines_ends);
|
m_sequential_view.gcode_window.load_gcode(gcode_result.filename, gcode_result.lines_ends);
|
||||||
|
|
||||||
//BBS: add only gcode mode
|
//BBS: add only gcode mode
|
||||||
|
@ -1033,6 +1023,18 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr
|
||||||
|
|
||||||
load_toolpaths(gcode_result, build_volume, exclude_bounding_box);
|
load_toolpaths(gcode_result, build_volume, exclude_bounding_box);
|
||||||
|
|
||||||
|
// BBS: data for rendering color arrangement recommendation
|
||||||
|
m_nozzle_nums = print.config().option<ConfigOptionFloats>("nozzle_diameter")->values.size();
|
||||||
|
std::vector<int> filament_maps = print.get_filament_maps();
|
||||||
|
std::vector<std::string> color_opt = print.config().option<ConfigOptionStrings>("filament_colour")->values;
|
||||||
|
std::vector<std::string> type_opt = print.config().option<ConfigOptionStrings>("filament_type")->values;
|
||||||
|
for (auto extruder_id : m_extruder_ids) {
|
||||||
|
if (filament_maps[extruder_id] == 1) {
|
||||||
|
m_left_extruder_filament.push_back({type_opt[extruder_id], color_opt[extruder_id], extruder_id});
|
||||||
|
} else {
|
||||||
|
m_right_extruder_filament.push_back({type_opt[extruder_id], color_opt[extruder_id], extruder_id});
|
||||||
|
}
|
||||||
|
}
|
||||||
//BBS: add mutex for protection of gcode result
|
//BBS: add mutex for protection of gcode result
|
||||||
if (m_layers.empty()) {
|
if (m_layers.empty()) {
|
||||||
gcode_result.unlock();
|
gcode_result.unlock();
|
||||||
|
@ -1288,6 +1290,8 @@ void GCodeViewer::reset()
|
||||||
m_print_statistics.reset();
|
m_print_statistics.reset();
|
||||||
m_custom_gcode_per_print_z = std::vector<CustomGCode::Item>();
|
m_custom_gcode_per_print_z = std::vector<CustomGCode::Item>();
|
||||||
m_sequential_view.gcode_window.reset();
|
m_sequential_view.gcode_window.reset();
|
||||||
|
m_left_extruder_filament.clear();
|
||||||
|
m_right_extruder_filament.clear();
|
||||||
#if ENABLE_GCODE_VIEWER_STATISTICS
|
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
m_statistics.reset_all();
|
m_statistics.reset_all();
|
||||||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
|
@ -4617,8 +4621,10 @@ void GCodeViewer::render_legend_color_arr_recommen(float window_padding)
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
imgui.title(_u8L("Color Arrangement Recommendation"));
|
imgui.title(_u8L("Color Arrangement Recommendation"));
|
||||||
//BBS AMS containers
|
//BBS AMS containers
|
||||||
|
int AMS_filament_max_num = std::max(m_left_extruder_filament.size(), m_right_extruder_filament.size());
|
||||||
|
float AMS_container_height = (std::ceil(AMS_filament_max_num / 4.0f) * 80.0f + 70.0f ) * m_scale;
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(window_padding * 3, 0));
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(window_padding * 3, 0));
|
||||||
ImGui::BeginChild("#AMS", ImVec2(0, 230.0f), false, ImGuiWindowFlags_AlwaysUseWindowPadding);
|
ImGui::BeginChild("#AMS", ImVec2(0, AMS_container_height), false, ImGuiWindowFlags_AlwaysUseWindowPadding);
|
||||||
{
|
{
|
||||||
// BBS save time;
|
// BBS save time;
|
||||||
imgui.text(_u8L("Since you set 1 AMS"));
|
imgui.text(_u8L("Since you set 1 AMS"));
|
||||||
|
@ -4632,7 +4638,7 @@ void GCodeViewer::render_legend_color_arr_recommen(float window_padding)
|
||||||
float available_width = ImGui::GetContentRegionAvail().x;
|
float available_width = ImGui::GetContentRegionAvail().x;
|
||||||
float available_height = ImGui::GetContentRegionAvail().y;
|
float available_height = ImGui::GetContentRegionAvail().y;
|
||||||
float half_width = available_width * 0.5f;
|
float half_width = available_width * 0.5f;
|
||||||
float spacing = 12.0f * m_scale;
|
float spacing = 18.0f * m_scale;
|
||||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.00f, 0.00f, 0.00f, 0.3f));
|
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.00f, 0.00f, 0.00f, 0.3f));
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(window_padding * 2, window_padding));
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(window_padding * 2, window_padding));
|
||||||
ImDrawList *child_begin_draw_list = ImGui::GetWindowDrawList();
|
ImDrawList *child_begin_draw_list = ImGui::GetWindowDrawList();
|
||||||
|
@ -4644,8 +4650,9 @@ void GCodeViewer::render_legend_color_arr_recommen(float window_padding)
|
||||||
ImGui::Dummy({window_padding, window_padding});
|
ImGui::Dummy({window_padding, window_padding});
|
||||||
int index = 1;
|
int index = 1;
|
||||||
for (const auto &extruder_filament : m_left_extruder_filament) {
|
for (const auto &extruder_filament : m_left_extruder_filament) {
|
||||||
imgui.filament_group(extruder_filament.first, extruder_filament.second.c_str());
|
imgui.filament_group(extruder_filament.type, extruder_filament.hex_color.c_str(), extruder_filament.filament_id);
|
||||||
if (index % 4 != 0) { ImGui::SameLine(0, spacing); }
|
if (index % 4 != 0) { ImGui::SameLine(0, spacing); }
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
}
|
}
|
||||||
|
@ -4658,8 +4665,9 @@ void GCodeViewer::render_legend_color_arr_recommen(float window_padding)
|
||||||
ImGui::Dummy({window_padding, window_padding});
|
ImGui::Dummy({window_padding, window_padding});
|
||||||
int index = 1;
|
int index = 1;
|
||||||
for (const auto &extruder_filament : m_right_extruder_filament) {
|
for (const auto &extruder_filament : m_right_extruder_filament) {
|
||||||
imgui.filament_group(extruder_filament.first, extruder_filament.second.c_str());
|
imgui.filament_group(extruder_filament.type, extruder_filament.hex_color.c_str(), extruder_filament.filament_id);
|
||||||
if (index % 4 != 0) { ImGui::SameLine(0, spacing); }
|
if (index % 4 != 0) { ImGui::SameLine(0, spacing); }
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
}
|
}
|
||||||
|
@ -4996,10 +5004,12 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(m_nozzle_nums > 1)
|
||||||
render_legend_color_arr_recommen(window_padding);
|
render_legend_color_arr_recommen(window_padding);
|
||||||
|
|
||||||
//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::SameLine();
|
ImGui::SameLine();
|
||||||
imgui.bold_text(_u8L("Color Scheme"));
|
imgui.bold_text(_u8L("Color Scheme"));
|
||||||
push_combo_style();
|
push_combo_style();
|
||||||
|
|
|
@ -720,6 +720,13 @@ public:
|
||||||
std::vector<bool> m_tool_visibles;
|
std::vector<bool> m_tool_visibles;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ExtruderFilament
|
||||||
|
{
|
||||||
|
std::string type;
|
||||||
|
std::string hex_color;
|
||||||
|
unsigned char filament_id;
|
||||||
|
};
|
||||||
|
|
||||||
enum class EViewType : unsigned char
|
enum class EViewType : unsigned char
|
||||||
{
|
{
|
||||||
FeatureType = 0,
|
FeatureType = 0,
|
||||||
|
@ -752,9 +759,9 @@ private:
|
||||||
std::vector<size_t> m_ssid_to_moveid_map;
|
std::vector<size_t> m_ssid_to_moveid_map;
|
||||||
|
|
||||||
//BBS: extruder dispensing filament
|
//BBS: extruder dispensing filament
|
||||||
//std::pair<TYPE, CLOUR>
|
std::vector<ExtruderFilament> m_left_extruder_filament;
|
||||||
std::vector<std::pair<std::string, std::string>> m_left_extruder_filament;
|
std::vector<ExtruderFilament> m_right_extruder_filament;
|
||||||
std::vector<std::pair<std::string, std::string>> m_right_extruder_filament;
|
size_t m_nozzle_nums;
|
||||||
|
|
||||||
std::vector<TBuffer> m_buffers{ static_cast<size_t>(EMoveType::Extrude) };
|
std::vector<TBuffer> m_buffers{ static_cast<size_t>(EMoveType::Extrude) };
|
||||||
// bounding box of toolpaths
|
// bounding box of toolpaths
|
||||||
|
|
|
@ -2841,13 +2841,17 @@ void ImGuiWrapper::clipboard_set(void* /* user_data */, const char* text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiWrapper::filament_group(const std::string &filament_type, const char *hex_color)
|
void ImGuiWrapper::filament_group(const std::string &filament_type, const char *hex_color, unsigned char filament_id)
|
||||||
{
|
{
|
||||||
//ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
//ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
||||||
|
std::string id = std::to_string(static_cast<unsigned int> (filament_id + 1));
|
||||||
ImDrawList *draw_list = ImGui::GetWindowDrawList();
|
ImDrawList *draw_list = ImGui::GetWindowDrawList();
|
||||||
static ImTextureID transparent;
|
static ImTextureID transparent;
|
||||||
ImVec2 img_size = {30.0f, 45.0f};
|
ImVec2 img_size = {30.0f, 45.0f};
|
||||||
ImVec2 text_size = ImGui::CalcTextSize(filament_type.c_str());
|
ImVec2 text_size = ImGui::CalcTextSize(filament_type.c_str());
|
||||||
|
ImVec2 id_text_size = this->calc_text_size(id);
|
||||||
|
unsigned char rgb[3];
|
||||||
|
|
||||||
BitmapCache::load_from_svg_file_change_color(Slic3r::resources_dir() + "/images/filament_green.svg", img_size.x, img_size.y, transparent, hex_color);
|
BitmapCache::load_from_svg_file_change_color(Slic3r::resources_dir() + "/images/filament_green.svg", img_size.x, img_size.y, transparent, hex_color);
|
||||||
ImGui::BeginGroup();
|
ImGui::BeginGroup();
|
||||||
{
|
{
|
||||||
|
@ -2856,6 +2860,11 @@ void ImGuiWrapper::filament_group(const std::string &filament_type, const char *
|
||||||
// image border test
|
// image border test
|
||||||
// draw_list->AddRect(cursor_pos, {cursor_pos.x + img_size.x, cursor_pos.y + img_size.y}, IM_COL32(0, 0, 0, 255));
|
// draw_list->AddRect(cursor_pos, {cursor_pos.x + img_size.x, cursor_pos.y + img_size.y}, IM_COL32(0, 0, 0, 255));
|
||||||
ImVec2 current_cursor = ImGui::GetCursorPos();
|
ImVec2 current_cursor = ImGui::GetCursorPos();
|
||||||
|
ImGui::SetCursorPos({current_cursor.x + (img_size.x - id_text_size.x) * 0.5f + 2, current_cursor.y + (img_size.y - id_text_size.y) * 0.5f - 2});
|
||||||
|
Slic3r::GUI::BitmapCache::parse_color(hex_color, rgb);
|
||||||
|
float gray = 0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2];
|
||||||
|
ImVec4 text_color = gray < 80 ? ImVec4(1.0f, 1.0f, 1.0f, 1.0f) : ImVec4(0, 0, 0, 1.0f);
|
||||||
|
this->text_colored(text_color, id.c_str());
|
||||||
ImGui::SetCursorPos({current_cursor.x + (img_size.x - text_size.x) * 0.5f, current_cursor.y + 40});
|
ImGui::SetCursorPos({current_cursor.x + (img_size.x - text_size.x) * 0.5f, current_cursor.y + 40});
|
||||||
this->text(filament_type);
|
this->text(filament_type);
|
||||||
ImGui::EndGroup();
|
ImGui::EndGroup();
|
||||||
|
|
|
@ -153,7 +153,7 @@ public:
|
||||||
void text_wrapped(const wxString &label, float wrap_width);
|
void text_wrapped(const wxString &label, float wrap_width);
|
||||||
void tooltip(const char *label, float wrap_width);
|
void tooltip(const char *label, float wrap_width);
|
||||||
void tooltip(const wxString &label, float wrap_width);
|
void tooltip(const wxString &label, float wrap_width);
|
||||||
void filament_group(const std::string &filament_type, const char *hex_color);
|
void filament_group(const std::string &filament_type, const char *hex_color, unsigned char filament_id);
|
||||||
void sub_title(const std::string &label);
|
void sub_title(const std::string &label);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue