mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-30 01:42:01 +08:00
New gcode visualization - Modify pre-gcode preview to use the new toolpaths renderer, WIP (brim/skirt/wipe tower)
This commit is contained in:
parent
0faaf6b683
commit
a2b9104567
@ -1134,7 +1134,7 @@ void GCodeViewer::init()
|
||||
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& print, const std::vector<std::string>&str_tool_colors)
|
||||
void GCodeViewer::load_as_gcode(const GCodeProcessorResult& gcode_result, const Print& print, const std::vector<std::string>& str_tool_colors)
|
||||
{
|
||||
m_new_viewer.set_top_layer_only_view_range(get_app_config()->get_bool("seq_top_layer_only"));
|
||||
|
||||
@ -1330,7 +1330,24 @@ void GCodeViewer::load(const GCodeProcessorResult & gcode_result, const Print &
|
||||
}
|
||||
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if !ENABLE_NEW_GCODE_VIEWER
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
void GCodeViewer::load_as_preview(libvgcode::GCodeInputData&& data, const std::vector<std::string>& str_tool_colors)
|
||||
{
|
||||
m_new_viewer.reset();
|
||||
|
||||
if (!str_tool_colors.empty()) {
|
||||
std::vector<ColorRGBA> tool_colors;
|
||||
decode_colors(str_tool_colors, tool_colors);
|
||||
std::vector<libvgcode::Color> colors;
|
||||
colors.reserve(tool_colors.size());
|
||||
for (const ColorRGBA& color : tool_colors) {
|
||||
colors.emplace_back(libvgcode::convert(color));
|
||||
}
|
||||
m_new_viewer.set_tool_colors(colors);
|
||||
}
|
||||
m_new_viewer.load(std::move(data));
|
||||
}
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
void GCodeViewer::refresh(const GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors)
|
||||
{
|
||||
@ -1409,7 +1426,7 @@ void GCodeViewer::refresh(const GCodeProcessorResult& gcode_result, const std::v
|
||||
log_memory_used("Refreshed G-code extrusion paths, ");
|
||||
}
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // !ENABLE_NEW_GCODE_VIEWER
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
void GCodeViewer::update_shells_color_by_extruder(const DynamicPrintConfig* config)
|
||||
@ -1594,7 +1611,8 @@ void GCodeViewer::update_sequential_view_current(unsigned int first, unsigned in
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
m_new_viewer.set_view_visible_range(static_cast<uint32_t>(first), static_cast<uint32_t>(last));
|
||||
wxGetApp().plater()->enable_preview_moves_slider(m_new_viewer.get_enabled_segments_count() > 0);
|
||||
const std::array<uint32_t, 2>& enabled_range = m_new_viewer.get_view_enabled_range();
|
||||
wxGetApp().plater()->enable_preview_moves_slider(enabled_range[1] > enabled_range[0]);
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
auto is_visible = [this](unsigned int id) {
|
||||
@ -1710,16 +1728,17 @@ void GCodeViewer::set_layers_z_range(const std::array<unsigned int, 2>& layers_z
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
m_new_viewer.set_layers_view_range(static_cast<uint32_t>(layers_z_range[0]), static_cast<uint32_t>(layers_z_range[1]));
|
||||
wxGetApp().plater()->update_preview_moves_slider();
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
bool keep_sequential_current_first = layers_z_range[0] >= m_layers_z_range[0];
|
||||
bool keep_sequential_current_last = layers_z_range[1] <= m_layers_z_range[1];
|
||||
m_layers_z_range = layers_z_range;
|
||||
refresh_render_paths(keep_sequential_current_first, keep_sequential_current_last);
|
||||
wxGetApp().plater()->update_preview_moves_slider();
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
wxGetApp().plater()->update_preview_moves_slider();
|
||||
}
|
||||
|
||||
void GCodeViewer::export_toolpaths_to_obj(const char* filename) const
|
||||
@ -3631,172 +3650,174 @@ void GCodeViewer::render_new_toolpaths()
|
||||
m_new_viewer.render(converted_view_matrix, converted_projetion_matrix);
|
||||
|
||||
#if ENABLE_NEW_GCODE_VIEWER_DEBUG
|
||||
ImGuiWrapper& imgui = *wxGetApp().imgui();
|
||||
const Size cnv_size = wxGetApp().plater()->get_current_canvas3D()->get_canvas_size();
|
||||
imgui.set_next_window_pos(static_cast<float>(cnv_size.get_width()), 0.0f, ImGuiCond_Always, 1.0f, 0.0f);
|
||||
imgui.begin(std::string("LibVGCode Viewer Debug"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize);
|
||||
if (is_legend_shown()) {
|
||||
ImGuiWrapper& imgui = *wxGetApp().imgui();
|
||||
const Size cnv_size = wxGetApp().plater()->get_current_canvas3D()->get_canvas_size();
|
||||
imgui.set_next_window_pos(static_cast<float>(cnv_size.get_width()), 0.0f, ImGuiCond_Always, 1.0f, 0.0f);
|
||||
imgui.begin(std::string("LibVGCode Viewer Debug"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize);
|
||||
|
||||
if (ImGui::BeginTable("Data", 2)) {
|
||||
if (ImGui::BeginTable("Data", 2)) {
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "# vertices");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
imgui.text(std::to_string(m_new_viewer.get_vertices_count()));
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "# enabled lines");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
const std::array<uint32_t, 2>& enabled_segments_range = m_new_viewer.get_enabled_segments_range();
|
||||
imgui.text(std::to_string(m_new_viewer.get_enabled_segments_count()) + " [" + std::to_string(enabled_segments_range[0]) +
|
||||
"-" + std::to_string(enabled_segments_range[1]) + "]");
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "# enabled options");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
const std::array<uint32_t, 2>& enabled_options_range = m_new_viewer.get_enabled_options_range();
|
||||
imgui.text(std::to_string(m_new_viewer.get_enabled_options_count()) + " [" + std::to_string(enabled_options_range[0]) +
|
||||
"-" + std::to_string(enabled_options_range[1]) + "]");
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "layers range");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
const std::array<uint32_t, 2>& layers_range = m_new_viewer.get_layers_view_range();
|
||||
imgui.text(std::to_string(layers_range[0]) + " - " + std::to_string(layers_range[1]));
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "view range (full)");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
const std::array<uint32_t, 2>& full_view_range = m_new_viewer.get_view_full_range();
|
||||
imgui.text(std::to_string(full_view_range[0]) + " - " + std::to_string(full_view_range[1]) + " | " +
|
||||
std::to_string(m_new_viewer.get_vertex_at(full_view_range[0]).gcode_id) + " - " +
|
||||
std::to_string(m_new_viewer.get_vertex_at(full_view_range[1]).gcode_id));
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "view range (enabled)");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
const std::array<uint32_t, 2>& enabled_view_range = m_new_viewer.get_view_enabled_range();
|
||||
imgui.text(std::to_string(enabled_view_range[0]) + " - " + std::to_string(enabled_view_range[1]) + " | " +
|
||||
std::to_string(m_new_viewer.get_vertex_at(enabled_view_range[0]).gcode_id) + " - " +
|
||||
std::to_string(m_new_viewer.get_vertex_at(enabled_view_range[1]).gcode_id));
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "view range (visible)");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
const std::array<uint32_t, 2>& visible_view_range = m_new_viewer.get_view_visible_range();
|
||||
imgui.text(std::to_string(visible_view_range[0]) + " - " + std::to_string(visible_view_range[1]) + " | " +
|
||||
std::to_string(m_new_viewer.get_vertex_at(visible_view_range[0]).gcode_id) + " - " +
|
||||
std::to_string(m_new_viewer.get_vertex_at(visible_view_range[1]).gcode_id));
|
||||
|
||||
auto add_range_property_row = [&imgui](const std::string& label, const std::array<float, 2>& range) {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, label);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "# vertices");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
char buf[128];
|
||||
sprintf(buf, "%.3f - %.3f", range[0], range[1]);
|
||||
imgui.text(buf);
|
||||
};
|
||||
imgui.text(std::to_string(m_new_viewer.get_vertices_count()));
|
||||
|
||||
add_range_property_row("height range", m_new_viewer.get_height_range().get_range());
|
||||
add_range_property_row("width range", m_new_viewer.get_width_range().get_range());
|
||||
add_range_property_row("speed range", m_new_viewer.get_speed_range().get_range());
|
||||
add_range_property_row("fan speed range", m_new_viewer.get_fan_speed_range().get_range());
|
||||
add_range_property_row("temperature range", m_new_viewer.get_temperature_range().get_range());
|
||||
add_range_property_row("volumetric rate range", m_new_viewer.get_volumetric_rate_range().get_range());
|
||||
add_range_property_row("layer time linear range", m_new_viewer.get_layer_time_range(libvgcode::EColorRangeType::Linear).get_range());
|
||||
add_range_property_row("layer time logarithmic range", m_new_viewer.get_layer_time_range(libvgcode::EColorRangeType::Logarithmic).get_range());
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "# enabled lines");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
const std::array<uint32_t, 2>& enabled_segments_range = m_new_viewer.get_enabled_segments_range();
|
||||
imgui.text(std::to_string(m_new_viewer.get_enabled_segments_count()) + " [" + std::to_string(enabled_segments_range[0]) +
|
||||
"-" + std::to_string(enabled_segments_range[1]) + "]");
|
||||
|
||||
ImGui::EndTable();
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "# enabled options");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
const std::array<uint32_t, 2>& enabled_options_range = m_new_viewer.get_enabled_options_range();
|
||||
imgui.text(std::to_string(m_new_viewer.get_enabled_options_count()) + " [" + std::to_string(enabled_options_range[0]) +
|
||||
"-" + std::to_string(enabled_options_range[1]) + "]");
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "layers range");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
const std::array<uint32_t, 2>& layers_range = m_new_viewer.get_layers_view_range();
|
||||
imgui.text(std::to_string(layers_range[0]) + " - " + std::to_string(layers_range[1]));
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "view range (full)");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
const std::array<uint32_t, 2>& full_view_range = m_new_viewer.get_view_full_range();
|
||||
imgui.text(std::to_string(full_view_range[0]) + " - " + std::to_string(full_view_range[1]) + " | " +
|
||||
std::to_string(m_new_viewer.get_vertex_at(full_view_range[0]).gcode_id) + " - " +
|
||||
std::to_string(m_new_viewer.get_vertex_at(full_view_range[1]).gcode_id));
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "view range (enabled)");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
const std::array<uint32_t, 2>& enabled_view_range = m_new_viewer.get_view_enabled_range();
|
||||
imgui.text(std::to_string(enabled_view_range[0]) + " - " + std::to_string(enabled_view_range[1]) + " | " +
|
||||
std::to_string(m_new_viewer.get_vertex_at(enabled_view_range[0]).gcode_id) + " - " +
|
||||
std::to_string(m_new_viewer.get_vertex_at(enabled_view_range[1]).gcode_id));
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "view range (visible)");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
const std::array<uint32_t, 2>& visible_view_range = m_new_viewer.get_view_visible_range();
|
||||
imgui.text(std::to_string(visible_view_range[0]) + " - " + std::to_string(visible_view_range[1]) + " | " +
|
||||
std::to_string(m_new_viewer.get_vertex_at(visible_view_range[0]).gcode_id) + " - " +
|
||||
std::to_string(m_new_viewer.get_vertex_at(visible_view_range[1]).gcode_id));
|
||||
|
||||
auto add_range_property_row = [&imgui](const std::string& label, const std::array<float, 2>& range) {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, label);
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
char buf[128];
|
||||
sprintf(buf, "%.3f - %.3f", range[0], range[1]);
|
||||
imgui.text(buf);
|
||||
};
|
||||
|
||||
add_range_property_row("height range", m_new_viewer.get_height_range().get_range());
|
||||
add_range_property_row("width range", m_new_viewer.get_width_range().get_range());
|
||||
add_range_property_row("speed range", m_new_viewer.get_speed_range().get_range());
|
||||
add_range_property_row("fan speed range", m_new_viewer.get_fan_speed_range().get_range());
|
||||
add_range_property_row("temperature range", m_new_viewer.get_temperature_range().get_range());
|
||||
add_range_property_row("volumetric rate range", m_new_viewer.get_volumetric_rate_range().get_range());
|
||||
add_range_property_row("layer time linear range", m_new_viewer.get_layer_time_range(libvgcode::EColorRangeType::Linear).get_range());
|
||||
add_range_property_row("layer time logarithmic range", m_new_viewer.get_layer_time_range(libvgcode::EColorRangeType::Logarithmic).get_range());
|
||||
|
||||
ImGui::EndTable();
|
||||
|
||||
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
|
||||
ImGui::Separator();
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::BeginTable("Cog", 2)) {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "Cog marker scale factor");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
imgui.text(std::to_string(get_cog_marker_scale_factor()));
|
||||
if (ImGui::BeginTable("Cog", 2)) {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "Cog marker scale factor");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
imgui.text(std::to_string(get_cog_marker_scale_factor()));
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::BeginTable("Tool", 2)) {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "Tool marker scale factor");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
imgui.text(std::to_string(m_new_viewer.get_tool_marker_scale_factor()));
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "Tool marker z offset");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
float tool_z_offset = m_new_viewer.get_tool_marker_offset_z();
|
||||
if (imgui.slider_float("##ToolZOffset", &tool_z_offset, 0.0f, 1.0f))
|
||||
m_new_viewer.set_tool_marker_offset_z(tool_z_offset);
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "Tool marker color");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
const libvgcode::Color& color = m_new_viewer.get_tool_marker_color();
|
||||
std::array<float, 3> c = { static_cast<float>(color[0]) / 255.0f, static_cast<float>(color[1]) / 255.0f, static_cast<float>(color[2]) / 255.0f };
|
||||
if (ImGui::ColorPicker3("##ToolColor", c.data())) {
|
||||
m_new_viewer.set_tool_marker_color({ static_cast<uint8_t>(c[0] * 255.0f),
|
||||
static_cast<uint8_t>(c[1] * 255.0f),
|
||||
static_cast<uint8_t>(c[2] * 255.0f) });
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::BeginTable("Tool", 2)) {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "Tool marker scale factor");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
imgui.text(std::to_string(m_new_viewer.get_tool_marker_scale_factor()));
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "Tool marker z offset");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
float tool_z_offset = m_new_viewer.get_tool_marker_offset_z();
|
||||
if (imgui.slider_float("##ToolZOffset", &tool_z_offset, 0.0f, 1.0f))
|
||||
m_new_viewer.set_tool_marker_offset_z(tool_z_offset);
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "Tool marker color");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
const libvgcode::Color& color = m_new_viewer.get_tool_marker_color();
|
||||
std::array<float, 3> c = { static_cast<float>(color[0]) / 255.0f, static_cast<float>(color[1]) / 255.0f, static_cast<float>(color[2]) / 255.0f };
|
||||
if (ImGui::ColorPicker3("##ToolColor", c.data())) {
|
||||
m_new_viewer.set_tool_marker_color({ static_cast<uint8_t>(c[0] * 255.0f),
|
||||
static_cast<uint8_t>(c[1] * 255.0f),
|
||||
static_cast<uint8_t>(c[2] * 255.0f) });
|
||||
}
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "Tool marker alpha");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
float tool_alpha = m_new_viewer.get_tool_marker_alpha();
|
||||
if (imgui.slider_float("##ToolAlpha", &tool_alpha, 0.25f, 0.75f))
|
||||
m_new_viewer.set_tool_marker_alpha(tool_alpha);
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
if (ImGui::BeginTable("Radii", 2)) {
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "Tool marker alpha");
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "Travels radius");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
float tool_alpha = m_new_viewer.get_tool_marker_alpha();
|
||||
if (imgui.slider_float("##ToolAlpha", &tool_alpha, 0.25f, 0.75f))
|
||||
m_new_viewer.set_tool_marker_alpha(tool_alpha);
|
||||
float travels_radius = m_new_viewer.get_travels_radius();
|
||||
ImGui::SetNextItemWidth(200.0f);
|
||||
if (imgui.slider_float("##TravelRadius", &travels_radius, 0.05f, 0.5f))
|
||||
m_new_viewer.set_travels_radius(travels_radius);
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "Wipes radius");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
float wipes_radius = m_new_viewer.get_wipes_radius();
|
||||
ImGui::SetNextItemWidth(200.0f);
|
||||
if (imgui.slider_float("##WipesRadius", &wipes_radius, 0.05f, 0.5f))
|
||||
m_new_viewer.set_wipes_radius(wipes_radius);
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
|
||||
|
||||
imgui.end();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
if (ImGui::BeginTable("Radii", 2)) {
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "Travels radius");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
float travels_radius = m_new_viewer.get_travels_radius();
|
||||
ImGui::SetNextItemWidth(200.0f);
|
||||
if (imgui.slider_float("##TravelRadius", &travels_radius, 0.05f, 0.5f))
|
||||
m_new_viewer.set_travels_radius(travels_radius);
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, "Wipes radius");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
float wipes_radius = m_new_viewer.get_wipes_radius();
|
||||
ImGui::SetNextItemWidth(200.0f);
|
||||
if (imgui.slider_float("##WipesRadius", &wipes_radius, 0.05f, 0.5f))
|
||||
m_new_viewer.set_wipes_radius(wipes_radius);
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
imgui.end();
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER_DEBUG
|
||||
}
|
||||
#else
|
||||
@ -4153,8 +4174,17 @@ void GCodeViewer::render_shells()
|
||||
|
||||
void GCodeViewer::render_legend(float& legend_height)
|
||||
{
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
if (!is_legend_shown())
|
||||
return;
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
if (!m_legend_enabled)
|
||||
return;
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
const Size cnv_size = wxGetApp().plater()->get_current_canvas3D()->get_canvas_size();
|
||||
|
||||
|
@ -922,13 +922,16 @@ private:
|
||||
float m_cog_marker_size{ 1.0f };
|
||||
bool m_tool_marker_fixed_screen_size{ false };
|
||||
float m_tool_marker_size{ 1.0f };
|
||||
bool m_legend_visible{ true };
|
||||
bool m_legend_enabled{ true };
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
EViewType m_view_type{ EViewType::FeatureType };
|
||||
bool m_legend_enabled{ true };
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
bool m_legend_enabled{ true };
|
||||
|
||||
struct LegendResizer
|
||||
{
|
||||
bool dirty{ true };
|
||||
@ -977,7 +980,8 @@ public:
|
||||
// extract rendering data from the given parameters
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
void load(const GCodeProcessorResult& gcode_result, const Print& print, const std::vector<std::string>& str_tool_colors);
|
||||
void load_as_gcode(const GCodeProcessorResult& gcode_result, const Print& print, const std::vector<std::string>& str_tool_colors);
|
||||
void load_as_preview(libvgcode::GCodeInputData&& data, const std::vector<std::string>& str_tool_colors);
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
void load(const GCodeProcessorResult& gcode_result, const Print& print);
|
||||
@ -1087,8 +1091,18 @@ public:
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
void set_layers_z_range(const std::array<unsigned int, 2>& layers_z_range);
|
||||
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
bool is_legend_shown() const { return m_legend_visible && m_legend_enabled; }
|
||||
void show_legend(bool show) { m_legend_visible = show; }
|
||||
void enable_legend(bool enable) { m_legend_enabled = enable; }
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
bool is_legend_enabled() const { return m_legend_enabled; }
|
||||
void enable_legend(bool enable) { m_legend_enabled = enable; }
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
void set_force_shells_visible(bool visible) { m_shells.force_visible = visible; }
|
||||
|
||||
|
@ -1763,10 +1763,16 @@ void GLCanvas3D::enable_layers_editing(bool enable)
|
||||
set_as_dirty();
|
||||
}
|
||||
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if !ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
void GLCanvas3D::enable_legend_texture(bool enable)
|
||||
{
|
||||
m_gcode_viewer.enable_legend(enable);
|
||||
}
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // !ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
void GLCanvas3D::enable_picking(bool enable)
|
||||
{
|
||||
@ -2695,7 +2701,8 @@ void GLCanvas3D::load_gcode_preview(const GCodeProcessorResult& gcode_result, co
|
||||
{
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
m_gcode_viewer.load(gcode_result, *this->fff_print(), str_tool_colors);
|
||||
m_gcode_viewer.enable_legend(true);
|
||||
m_gcode_viewer.load_as_gcode(gcode_result, *this->fff_print(), str_tool_colors);
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
m_gcode_viewer.load(gcode_result, *this->fff_print());
|
||||
@ -2758,11 +2765,29 @@ void GLCanvas3D::load_preview(const std::vector<std::string>& str_tool_colors, c
|
||||
this->reset_volumes();
|
||||
|
||||
const BuildVolume &build_volume = m_bed.build_volume();
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if !ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
_load_print_toolpaths(build_volume);
|
||||
_load_wipe_tower_toolpaths(build_volume, str_tool_colors);
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // !ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
for (const PrintObject* object : print->objects())
|
||||
_load_print_object_toolpaths(*object, build_volume, str_tool_colors, color_print_values);
|
||||
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
libvgcode::GCodeInputData data = libvgcode::convert(*print, str_tool_colors);
|
||||
|
||||
// send data to the viewer
|
||||
m_gcode_viewer.enable_legend(false);
|
||||
m_gcode_viewer.load_as_preview(std::move(data), str_tool_colors);
|
||||
|
||||
// TODO check build_volume <<<<<<<<<<<<<<
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
m_gcode_viewer.set_force_shells_visible(false);
|
||||
_set_warning_notification_if_needed(EWarning::ToolpathOutside);
|
||||
}
|
||||
@ -6733,6 +6758,9 @@ void GLCanvas3D::_stop_timer()
|
||||
m_timer.Stop();
|
||||
}
|
||||
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if !ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
void GLCanvas3D::_load_print_toolpaths(const BuildVolume &build_volume)
|
||||
{
|
||||
const Print *print = this->fff_print();
|
||||
@ -6798,6 +6826,9 @@ void GLCanvas3D::_load_print_toolpaths(const BuildVolume &build_volume)
|
||||
volume->is_outside = !contains(build_volume, volume->model);
|
||||
}
|
||||
}
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // !ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, const BuildVolume& build_volume, const std::vector<std::string>& str_tool_colors, const std::vector<CustomGCode::Item>& color_print_values)
|
||||
{
|
||||
@ -7113,6 +7144,9 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
|
||||
BOOST_LOG_TRIVIAL(debug) << "Loading print object toolpaths in parallel - end" << m_volumes.log_memory_info() << log_memory_info();
|
||||
}
|
||||
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if !ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
void GLCanvas3D::_load_wipe_tower_toolpaths(const BuildVolume& build_volume, const std::vector<std::string>& str_tool_colors)
|
||||
{
|
||||
const Print *print = this->fff_print();
|
||||
@ -7171,20 +7205,20 @@ void GLCanvas3D::_load_wipe_tower_toolpaths(const BuildVolume& build_volume, con
|
||||
tbb::spin_mutex new_volume_mutex;
|
||||
auto new_volume = [this, &new_volume_mutex](const ColorRGBA& color) {
|
||||
auto *volume = new GLVolume(color);
|
||||
volume->is_extrusion_path = true;
|
||||
// to prevent sending data to gpu (in the main thread) while
|
||||
// editing the model geometry
|
||||
volume->model.disable_render();
|
||||
tbb::spin_mutex::scoped_lock lock;
|
||||
lock.acquire(new_volume_mutex);
|
||||
m_volumes.volumes.emplace_back(volume);
|
||||
lock.release();
|
||||
return volume;
|
||||
volume->is_extrusion_path = true;
|
||||
// to prevent sending data to gpu (in the main thread) while
|
||||
// editing the model geometry
|
||||
volume->model.disable_render();
|
||||
tbb::spin_mutex::scoped_lock lock;
|
||||
lock.acquire(new_volume_mutex);
|
||||
m_volumes.volumes.emplace_back(volume);
|
||||
lock.release();
|
||||
return volume;
|
||||
};
|
||||
|
||||
const size_t volumes_cnt_initial = m_volumes.volumes.size();
|
||||
std::vector<GLVolumeCollection> volumes_per_thread(n_items);
|
||||
tbb::parallel_for(
|
||||
tbb::blocked_range<size_t>(0, n_items, grain_size),
|
||||
tbb::parallel_for(tbb::blocked_range<size_t>(0, n_items, grain_size),
|
||||
[&ctxt, &new_volume](const tbb::blocked_range<size_t>& range) {
|
||||
// Bounding box of this slab of a wipe tower.
|
||||
GLVolumePtrs vols;
|
||||
@ -7270,27 +7304,31 @@ void GLCanvas3D::_load_wipe_tower_toolpaths(const BuildVolume& build_volume, con
|
||||
if (!geometries[i].is_empty())
|
||||
vols[i]->model.init_from(std::move(geometries[i]));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
BOOST_LOG_TRIVIAL(debug) << "Loading wipe tower toolpaths in parallel - finalizing results" << m_volumes.log_memory_info() << log_memory_info();
|
||||
// Remove empty volumes from the newly added volumes.
|
||||
{
|
||||
for (auto ptr_it = m_volumes.volumes.begin() + volumes_cnt_initial; ptr_it != m_volumes.volumes.end(); ++ptr_it)
|
||||
for (auto ptr_it = m_volumes.volumes.begin() + volumes_cnt_initial; ptr_it != m_volumes.volumes.end(); ++ptr_it) {
|
||||
if ((*ptr_it)->empty()) {
|
||||
delete *ptr_it;
|
||||
delete* ptr_it;
|
||||
*ptr_it = nullptr;
|
||||
}
|
||||
}
|
||||
m_volumes.volumes.erase(std::remove(m_volumes.volumes.begin() + volumes_cnt_initial, m_volumes.volumes.end(), nullptr), m_volumes.volumes.end());
|
||||
}
|
||||
for (size_t i = volumes_cnt_initial; i < m_volumes.volumes.size(); ++i) {
|
||||
GLVolume* v = m_volumes.volumes[i];
|
||||
v->is_outside = !contains(build_volume, v->model);
|
||||
// We are done editinig the model, now it can be sent to gpu
|
||||
// We are done editing the model, now it can be sent to gpu
|
||||
v->model.enable_render();
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(debug) << "Loading wipe tower toolpaths in parallel - end" << m_volumes.log_memory_info() << log_memory_info();
|
||||
}
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // !ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
// While it looks like we can call
|
||||
// this->reload_scene(true, true)
|
||||
|
@ -800,7 +800,13 @@ public:
|
||||
bool is_reload_delayed() const;
|
||||
|
||||
void enable_layers_editing(bool enable);
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if !ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
void enable_legend_texture(bool enable);
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // !ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
void enable_picking(bool enable);
|
||||
void enable_moving(bool enable);
|
||||
void enable_gizmos(bool enable);
|
||||
@ -835,7 +841,6 @@ public:
|
||||
void delete_selected();
|
||||
void ensure_on_bed(unsigned int object_idx, bool allow_negative_z);
|
||||
|
||||
bool is_gcode_legend_enabled() const { return m_gcode_viewer.is_legend_enabled(); }
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
std::vector<double> get_gcode_layers_zs() const;
|
||||
@ -843,6 +848,8 @@ public:
|
||||
std::vector<float> get_gcode_layers_times(libvgcode::ETimeMode mode) const { return m_gcode_viewer.get_layers_times(mode); }
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
bool is_gcode_legend_enabled() const { return m_gcode_viewer.is_legend_enabled(); }
|
||||
|
||||
GCodeViewer::EViewType get_gcode_view_type() const { return m_gcode_viewer.get_view_type(); }
|
||||
const std::vector<double>& get_gcode_layers_zs() const;
|
||||
unsigned int get_gcode_options_visibility_flags() const { return m_gcode_viewer.get_options_visibility_flags(); }
|
||||
@ -851,7 +858,7 @@ public:
|
||||
void set_toolpath_role_visibility_flags(unsigned int flags);
|
||||
void set_toolpath_view_type(GCodeViewer::EViewType type);
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // !ENABLE_NEW_GCODE_VIEWER
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
std::vector<double> get_volumes_print_zs(bool active_only) const;
|
||||
void set_volumes_z_range(const std::array<double, 2>& range);
|
||||
@ -870,8 +877,8 @@ public:
|
||||
void load_gcode_preview(const GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors);
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
void set_gcode_view_preview_type(libvgcode::EViewType type) { return m_gcode_viewer.set_view_type(type); }
|
||||
libvgcode::EViewType get_gcode_view_preview_type() const { return m_gcode_viewer.get_view_type(); }
|
||||
void set_gcode_view_type(libvgcode::EViewType type) { return m_gcode_viewer.set_view_type(type); }
|
||||
libvgcode::EViewType get_gcode_view_type() const { return m_gcode_viewer.get_view_type(); }
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
void refresh_gcode_preview_render_paths(bool keep_sequential_current_first, bool keep_sequential_current_last);
|
||||
@ -978,8 +985,17 @@ public:
|
||||
bool are_labels_shown() const { return m_labels.is_shown(); }
|
||||
void show_labels(bool show) { m_labels.show(show); }
|
||||
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
bool is_legend_shown() const { return m_gcode_viewer.is_legend_shown(); }
|
||||
void show_legend(bool show) { m_gcode_viewer.show_legend(show); m_dirty = true; }
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
bool is_legend_shown() const { return m_gcode_viewer.is_legend_enabled(); }
|
||||
void show_legend(bool show) { m_gcode_viewer.enable_legend(show); m_dirty = true; }
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
bool is_using_slope() const { return m_slope.is_used(); }
|
||||
void use_slope(bool use) { m_slope.use(use); }
|
||||
@ -1117,16 +1133,28 @@ private:
|
||||
void _start_timer();
|
||||
void _stop_timer();
|
||||
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if !ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
// Create 3D thick extrusion lines for a skirt and brim.
|
||||
// Adds a new Slic3r::GUI::3DScene::Volume to volumes, updates collision with the build_volume.
|
||||
void _load_print_toolpaths(const BuildVolume &build_volume);
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // !ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
// Create 3D thick extrusion lines for object forming extrusions.
|
||||
// Adds a new Slic3r::GUI::3DScene::Volume to $self->volumes,
|
||||
// one for perimeters, one for infill and one for supports, updates collision with the build_volume.
|
||||
void _load_print_object_toolpaths(const PrintObject& print_object, const BuildVolume &build_volume,
|
||||
const std::vector<std::string>& str_tool_colors, const std::vector<CustomGCode::Item>& color_print_values);
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if !ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
// Create 3D thick extrusion lines for wipe tower extrusions, updates collision with the build_volume.
|
||||
void _load_wipe_tower_toolpaths(const BuildVolume &build_volume, const std::vector<std::string>& str_tool_colors);
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // !ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
// Load SLA objects and support structures for objects, for which the slaposSliceSupports step has been finished.
|
||||
void _load_sla_shells();
|
||||
|
@ -215,7 +215,15 @@ bool Preview::init(wxWindow* parent, Bed3D& bed, Model* model)
|
||||
m_canvas->set_config(m_config);
|
||||
m_canvas->set_model(model);
|
||||
m_canvas->set_process(m_process);
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
m_canvas->show_legend(true);
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
m_canvas->enable_legend_texture(true);
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
m_canvas->enable_dynamic_background(true);
|
||||
|
||||
m_layers_slider_sizer = create_layers_slider_sizer();
|
||||
@ -722,6 +730,9 @@ void Preview::update_moves_slider()
|
||||
{
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
if (m_gcode_result->moves.empty())
|
||||
return;
|
||||
|
||||
const std::array<uint32_t, 2>& range = m_canvas->get_gcode_view_enabled_range();
|
||||
uint32_t last_gcode_id = m_canvas->get_gcode_vertex_at(static_cast<size_t>(range[0])).gcode_id;
|
||||
|
||||
@ -853,7 +864,7 @@ void Preview::load_print_as_fff(bool keep_z_range)
|
||||
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
const libvgcode::EViewType gcode_view_type = m_canvas->get_gcode_view_preview_type();
|
||||
const libvgcode::EViewType gcode_view_type = m_canvas->get_gcode_view_type();
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
GCodeViewer::EViewType gcode_view_type = m_canvas->get_gcode_view_preview_type();
|
||||
@ -951,7 +962,7 @@ void Preview::load_print_as_fff(bool keep_z_range)
|
||||
if (choice != gcode_view_type) {
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
m_canvas->set_gcode_view_preview_type(choice);
|
||||
m_canvas->set_gcode_view_type(choice);
|
||||
#else
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
m_canvas->set_gcode_view_preview_type(choice);
|
||||
@ -968,7 +979,8 @@ void Preview::load_print_as_fff(bool keep_z_range)
|
||||
// all layers filtered out
|
||||
hide_layers_slider();
|
||||
m_canvas_widget->Refresh();
|
||||
} else
|
||||
}
|
||||
else
|
||||
update_layers_slider(zs, keep_z_range);
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
#include "libslic3r/Print.hpp"
|
||||
|
||||
namespace libvgcode {
|
||||
|
||||
@ -235,6 +236,299 @@ GCodeInputData convert(const Slic3r::GCodeProcessorResult& result, float travels
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void thick_lines_to_geometry(const Slic3r::Lines& lines, const std::vector<float>& widths, const std::vector<float>& heights,
|
||||
float top_z, size_t layer_id, size_t extruder_id, size_t color_id, EGCodeExtrusionRole extrusion_role, bool closed, GCodeInputData& data)
|
||||
{
|
||||
if (lines.empty())
|
||||
return;
|
||||
|
||||
// loop once more in case of closed loops
|
||||
const size_t lines_end = closed ? (lines.size() + 1) : lines.size();
|
||||
for (size_t ii = 0; ii < lines_end; ++ii) {
|
||||
const size_t i = (ii == lines.size()) ? 0 : ii;
|
||||
const Slic3r::Line& line = lines[i];
|
||||
// first segment of the polyline
|
||||
if (ii == 0) {
|
||||
// add a dummy vertex at the start, to separate the current line from the others
|
||||
const Slic3r::Vec2f a = unscale(line.a).cast<float>();
|
||||
libvgcode::PathVertex vertex = { convert(Slic3r::Vec3f(a.x(), a.y(), top_z)), heights[i], widths[i], 0.0f, 0.0f,
|
||||
0.0f, 0.0f, extrusion_role, EMoveType::Noop, 0, static_cast<uint32_t>(layer_id),
|
||||
static_cast<uint8_t>(extruder_id), static_cast<uint8_t>(color_id), { 0.0f, 0.0f } };
|
||||
data.vertices.emplace_back(vertex);
|
||||
// add the starting vertex of the segment
|
||||
vertex.type = EMoveType::Extrude;
|
||||
data.vertices.emplace_back(vertex);
|
||||
data.vertices.emplace_back(vertex);
|
||||
}
|
||||
// add the ending vertex of the segment
|
||||
const Slic3r::Vec2f b = unscale(line.b).cast<float>();
|
||||
const libvgcode::PathVertex vertex = { convert(Slic3r::Vec3f(b.x(), b.y(), top_z)), heights[i], widths[i], 0.0f, 0.0f,
|
||||
0.0f, 0.0f, extrusion_role, EMoveType::Extrude, 0, static_cast<uint32_t>(layer_id),
|
||||
static_cast<uint8_t>(extruder_id), static_cast<uint8_t>(color_id), { 0.0f, 0.0f } };
|
||||
data.vertices.emplace_back(vertex);
|
||||
}
|
||||
}
|
||||
|
||||
//static void thick_lines_to_verts(const Slic3r::Lines& lines, const std::vector<double>& widths, const std::vector<double>& heights, bool closed,
|
||||
// double top_z, GCodeInputData& data)
|
||||
//{
|
||||
// thick_lines_to_geometry(lines, widths, heights, closed, top_z, data);
|
||||
//}
|
||||
|
||||
|
||||
static void convert(const Slic3r::ExtrusionPath& extrusion_path, float print_z, size_t layer_id, size_t extruder_id, size_t color_id,
|
||||
EGCodeExtrusionRole extrusion_role, const Slic3r::Point& shift, GCodeInputData& data)
|
||||
{
|
||||
Slic3r::Polyline polyline = extrusion_path.polyline;
|
||||
polyline.remove_duplicate_points();
|
||||
polyline.translate(shift);
|
||||
const Slic3r::Lines lines = polyline.lines();
|
||||
std::vector<float> widths(lines.size(), extrusion_path.width());
|
||||
std::vector<float> heights(lines.size(), extrusion_path.height());
|
||||
thick_lines_to_geometry(lines, widths, heights, print_z, layer_id, extruder_id, color_id, extrusion_role, false, data);
|
||||
}
|
||||
|
||||
static void convert(const Slic3r::ExtrusionMultiPath& extrusion_multi_path, float print_z, size_t layer_id, size_t extruder_id,
|
||||
size_t color_id, EGCodeExtrusionRole extrusion_role, const Slic3r::Point& shift, GCodeInputData& data)
|
||||
{
|
||||
Slic3r::Lines lines;
|
||||
std::vector<float> widths;
|
||||
std::vector<float> heights;
|
||||
for (const Slic3r::ExtrusionPath& extrusion_path : extrusion_multi_path.paths) {
|
||||
Slic3r::Polyline polyline = extrusion_path.polyline;
|
||||
polyline.remove_duplicate_points();
|
||||
polyline.translate(shift);
|
||||
const Slic3r::Lines lines_this = polyline.lines();
|
||||
append(lines, lines_this);
|
||||
widths.insert(widths.end(), lines_this.size(), extrusion_path.width());
|
||||
heights.insert(heights.end(), lines_this.size(), extrusion_path.height());
|
||||
}
|
||||
thick_lines_to_geometry(lines, widths, heights, print_z, layer_id, extruder_id, color_id, extrusion_role, false, data);
|
||||
}
|
||||
|
||||
static void convert(const Slic3r::ExtrusionLoop& extrusion_loop, float print_z, size_t layer_id, size_t extruder_id, size_t color_id,
|
||||
EGCodeExtrusionRole extrusion_role, const Slic3r::Point& shift, GCodeInputData& data)
|
||||
{
|
||||
Slic3r::Lines lines;
|
||||
std::vector<float> widths;
|
||||
std::vector<float> heights;
|
||||
for (const Slic3r::ExtrusionPath& extrusion_path : extrusion_loop.paths) {
|
||||
Slic3r::Polyline polyline = extrusion_path.polyline;
|
||||
polyline.remove_duplicate_points();
|
||||
polyline.translate(shift);
|
||||
const Slic3r::Lines lines_this = polyline.lines();
|
||||
append(lines, lines_this);
|
||||
widths.insert(widths.end(), lines_this.size(), extrusion_path.width());
|
||||
heights.insert(heights.end(), lines_this.size(), extrusion_path.height());
|
||||
}
|
||||
thick_lines_to_geometry(lines, widths, heights, print_z, layer_id, extruder_id, color_id, extrusion_role, true, data);
|
||||
}
|
||||
|
||||
// forward declaration
|
||||
static void convert(const Slic3r::ExtrusionEntityCollection& extrusion_entity_collection, float print_z, size_t layer_id,
|
||||
EGCodeExtrusionRole extrusion_role, const Slic3r::Point& shift, GCodeInputData& data);
|
||||
|
||||
static void convert(const Slic3r::ExtrusionEntity& extrusion_entity, float print_z, size_t layer_id, size_t extruder_id, size_t color_id,
|
||||
EGCodeExtrusionRole extrusion_role, const Slic3r::Point& shift, GCodeInputData& data)
|
||||
{
|
||||
auto* extrusion_path = dynamic_cast<const Slic3r::ExtrusionPath*>(&extrusion_entity);
|
||||
if (extrusion_path != nullptr)
|
||||
convert(*extrusion_path, print_z, layer_id, extruder_id, color_id, extrusion_role, shift, data);
|
||||
else {
|
||||
auto* extrusion_loop = dynamic_cast<const Slic3r::ExtrusionLoop*>(&extrusion_entity);
|
||||
if (extrusion_loop != nullptr)
|
||||
convert(*extrusion_loop, print_z, layer_id, extruder_id, color_id, extrusion_role, shift, data);
|
||||
else {
|
||||
auto* extrusion_multi_path = dynamic_cast<const Slic3r::ExtrusionMultiPath*>(&extrusion_entity);
|
||||
if (extrusion_multi_path != nullptr)
|
||||
convert(*extrusion_multi_path, print_z, layer_id, extruder_id, color_id, extrusion_role, shift, data);
|
||||
else {
|
||||
auto* extrusion_entity_collection = dynamic_cast<const Slic3r::ExtrusionEntityCollection*>(&extrusion_entity);
|
||||
if (extrusion_entity_collection != nullptr)
|
||||
convert(*extrusion_entity_collection, print_z, layer_id, extruder_id, color_id, extrusion_role, shift, data);
|
||||
else
|
||||
throw Slic3r::RuntimeError("Found unexpected extrusion_entity type");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void convert(const Slic3r::ExtrusionEntityCollection& extrusion_entity_collection, float print_z, size_t layer_id,
|
||||
size_t extruder_id, size_t color_id, EGCodeExtrusionRole extrusion_role, const Slic3r::Point& shift, GCodeInputData& data)
|
||||
{
|
||||
for (const Slic3r::ExtrusionEntity* extrusion_entity : extrusion_entity_collection.entities) {
|
||||
if (extrusion_entity != nullptr)
|
||||
convert(*extrusion_entity, print_z, layer_id, extruder_id, color_id, extrusion_role, shift, data);
|
||||
}
|
||||
}
|
||||
|
||||
static void convert_brim_skirt(const Slic3r::Print& print, GCodeInputData& data)
|
||||
{
|
||||
// auto start_time = std::chrono::high_resolution_clock::now();
|
||||
|
||||
// number of skirt layers
|
||||
size_t total_layer_count = 0;
|
||||
for (const Slic3r::PrintObject* print_object : print.objects()) {
|
||||
total_layer_count = std::max(total_layer_count, print_object->total_layer_count());
|
||||
}
|
||||
size_t skirt_height = print.has_infinite_skirt() ? total_layer_count : std::min<size_t>(print.config().skirt_height.value, total_layer_count);
|
||||
if (skirt_height == 0 && print.has_brim())
|
||||
skirt_height = 1;
|
||||
|
||||
// Get first skirt_height layers.
|
||||
//FIXME This code is fishy. It may not work for multiple objects with different layering due to variable layer height feature.
|
||||
// This is not critical as this is just an initial preview.
|
||||
const Slic3r::PrintObject* highest_object = *std::max_element(print.objects().begin(), print.objects().end(),
|
||||
[](auto l, auto r) { return l->layers().size() < r->layers().size(); });
|
||||
std::vector<float> print_zs;
|
||||
print_zs.reserve(skirt_height * 2);
|
||||
for (size_t i = 0; i < std::min(skirt_height, highest_object->layers().size()); ++i) {
|
||||
print_zs.emplace_back(float(highest_object->layers()[i]->print_z));
|
||||
}
|
||||
// Only add skirt for the raft layers.
|
||||
for (size_t i = 0; i < std::min(skirt_height, std::min(highest_object->slicing_parameters().raft_layers(), highest_object->support_layers().size())); ++i) {
|
||||
print_zs.emplace_back(float(highest_object->support_layers()[i]->print_z));
|
||||
}
|
||||
Slic3r::sort_remove_duplicates(print_zs);
|
||||
skirt_height = std::min(skirt_height, print_zs.size());
|
||||
print_zs.erase(print_zs.begin() + skirt_height, print_zs.end());
|
||||
|
||||
for (size_t i = 0; i < skirt_height; ++i) {
|
||||
if (i == 0)
|
||||
convert(print.brim(), print_zs[i], i, 0, 0, EGCodeExtrusionRole::Skirt, Slic3r::Point(0, 0), data);
|
||||
convert(print.skirt(), print_zs[i], i, 0, 0, EGCodeExtrusionRole::Skirt, Slic3r::Point(0, 0), data);
|
||||
}
|
||||
|
||||
// auto end_time = std::chrono::high_resolution_clock::now();
|
||||
// std::cout << "convert_brim_skirt: " << std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time).count() << "ms\n";
|
||||
}
|
||||
|
||||
class WipeTowerHelper
|
||||
{
|
||||
public:
|
||||
WipeTowerHelper(const Slic3r::Print& print)
|
||||
: m_print(print)
|
||||
{
|
||||
const Slic3r::PrintConfig& config = m_print.config();
|
||||
const Slic3r::WipeTowerData& wipe_tower_data = m_print.wipe_tower_data();
|
||||
if (wipe_tower_data.priming && config.single_extruder_multi_material_priming) {
|
||||
for (size_t i = 0; i < wipe_tower_data.priming.get()->size(); ++i) {
|
||||
m_priming.emplace_back(wipe_tower_data.priming.get()->at(i));
|
||||
}
|
||||
}
|
||||
if (wipe_tower_data.final_purge)
|
||||
m_final.emplace_back(*wipe_tower_data.final_purge.get());
|
||||
|
||||
m_angle = config.wipe_tower_rotation_angle.value / 180.0f * PI;
|
||||
m_position = Slic3r::Vec2f(config.wipe_tower_x.value, config.wipe_tower_y.value);
|
||||
m_layers_count = wipe_tower_data.tool_changes.size() + (m_priming.empty() ? 0 : 1);
|
||||
}
|
||||
|
||||
const std::vector<Slic3r::WipeTower::ToolChangeResult>& tool_change(size_t idx) {
|
||||
const auto& tool_changes = m_print.wipe_tower_data().tool_changes;
|
||||
return m_priming.empty() ?
|
||||
((idx == tool_changes.size()) ? m_final : tool_changes[idx]) :
|
||||
((idx == 0) ? m_priming : (idx == tool_changes.size() + 1) ? m_final : tool_changes[idx - 1]);
|
||||
}
|
||||
|
||||
float get_angle() const { return m_angle; }
|
||||
const Slic3r::Vec2f& get_position() const { return m_position; }
|
||||
size_t get_layers_count() { return m_layers_count; }
|
||||
|
||||
private:
|
||||
const Slic3r::Print& m_print;
|
||||
std::vector<Slic3r::WipeTower::ToolChangeResult> m_priming;
|
||||
std::vector<Slic3r::WipeTower::ToolChangeResult> m_final;
|
||||
Slic3r::Vec2f m_position{ Slic3r::Vec2f::Zero() };
|
||||
float m_angle{ 0.0f };
|
||||
size_t m_layers_count{ 0 };
|
||||
};
|
||||
|
||||
static void convert_wipe_tower(const Slic3r::Print& print, const std::vector<std::string>& str_tool_colors, GCodeInputData& data)
|
||||
{
|
||||
// auto start_time = std::chrono::high_resolution_clock::now();
|
||||
|
||||
WipeTowerHelper wipe_tower(print);
|
||||
const float angle = wipe_tower.get_angle();
|
||||
const Slic3r::Vec2f& position = wipe_tower.get_position();
|
||||
|
||||
for (size_t item = 0; item < wipe_tower.get_layers_count(); ++item) {
|
||||
const std::vector<Slic3r::WipeTower::ToolChangeResult>& layer = wipe_tower.tool_change(item);
|
||||
for (const Slic3r::WipeTower::ToolChangeResult& extrusions : layer) {
|
||||
for (size_t i = 1; i < extrusions.extrusions.size(); /*no increment*/) {
|
||||
const Slic3r::WipeTower::Extrusion& e = extrusions.extrusions[i];
|
||||
if (e.width == 0.0f) {
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
size_t j = i + 1;
|
||||
if (str_tool_colors.empty())
|
||||
for (; j < extrusions.extrusions.size() && extrusions.extrusions[j].width > 0.0f; ++j);
|
||||
else
|
||||
for (; j < extrusions.extrusions.size() && extrusions.extrusions[j].tool == e.tool && extrusions.extrusions[j].width > 0.0f; ++j);
|
||||
|
||||
const size_t n_lines = j - i;
|
||||
Slic3r::Lines lines;
|
||||
std::vector<float> widths;
|
||||
std::vector<float> heights;
|
||||
lines.reserve(n_lines);
|
||||
widths.reserve(n_lines);
|
||||
heights.assign(n_lines, extrusions.layer_height);
|
||||
Slic3r::WipeTower::Extrusion e_prev = extrusions.extrusions[i - 1];
|
||||
|
||||
if (!extrusions.priming) { // wipe tower extrusions describe the wipe tower at the origin with no rotation
|
||||
e_prev.pos = Eigen::Rotation2Df(angle) * e_prev.pos;
|
||||
e_prev.pos += position;
|
||||
}
|
||||
|
||||
for (; i < j; ++i) {
|
||||
Slic3r::WipeTower::Extrusion ee = extrusions.extrusions[i];
|
||||
assert(ee.width > 0.0f);
|
||||
if (!extrusions.priming) {
|
||||
ee.pos = Eigen::Rotation2Df(angle) * ee.pos;
|
||||
ee.pos += position;
|
||||
}
|
||||
lines.emplace_back(Slic3r::Point::new_scale(e_prev.pos.x(), e_prev.pos.y()), Slic3r::Point::new_scale(ee.pos.x(), ee.pos.y()));
|
||||
widths.emplace_back(ee.width);
|
||||
e_prev = ee;
|
||||
}
|
||||
|
||||
thick_lines_to_geometry(lines, widths, heights, extrusions.print_z, item, static_cast<size_t>(e.tool), 0,
|
||||
EGCodeExtrusionRole::WipeTower, lines.front().a == lines.back().b, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// auto end_time = std::chrono::high_resolution_clock::now();
|
||||
// std::cout << "convert_wipe_tower: " << std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time).count() << "ms\n";
|
||||
}
|
||||
|
||||
static void convert_object(const Slic3r::PrintObject& object, GCodeInputData& data)
|
||||
{
|
||||
// auto start_time = std::chrono::high_resolution_clock::now();
|
||||
|
||||
// auto end_time = std::chrono::high_resolution_clock::now();
|
||||
// std::cout << "convert_object: " << std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time).count() << "ms\n";
|
||||
}
|
||||
|
||||
// mapping from Slic3r::Print to libvgcode::GCodeInputData
|
||||
GCodeInputData convert(const Slic3r::Print& print, const std::vector<std::string>& str_tool_colors)
|
||||
{
|
||||
GCodeInputData ret;
|
||||
|
||||
if (print.is_step_done(Slic3r::psSkirtBrim) && (print.has_skirt() || print.has_brim()))
|
||||
convert_brim_skirt(print, ret);
|
||||
|
||||
if (!print.wipe_tower_data().tool_changes.empty() && print.is_step_done(Slic3r::psWipeTower))
|
||||
convert_wipe_tower(print, str_tool_colors, ret);
|
||||
|
||||
for (const Slic3r::PrintObject* object : print.objects()) {
|
||||
convert_object(*object, ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace libvgcode
|
||||
|
||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
@ -16,6 +16,10 @@
|
||||
#include "include/GCodeInputData.hpp"
|
||||
#include "include/ColorRange.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
class Print;
|
||||
} // namespace Slic3r
|
||||
|
||||
namespace libvgcode {
|
||||
|
||||
// mapping from Slic3r::Vec3f to libvgcode::Vec3
|
||||
@ -55,6 +59,9 @@ extern Slic3r::PrintEstimatedStatistics::ETimeMode convert(const ETimeMode& mode
|
||||
extern GCodeInputData convert(const Slic3r::GCodeProcessorResult& result, float travels_radius = Default_Travels_Radius,
|
||||
float wipes_radius = Default_Wipes_Radius);
|
||||
|
||||
// mapping from Slic3r::Print to libvgcode::GCodeInputData
|
||||
extern GCodeInputData convert(const Slic3r::Print& print, const std::vector<std::string>& str_tool_colors);
|
||||
|
||||
} // namespace libvgcode
|
||||
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
|
@ -418,11 +418,16 @@ void ViewerImpl::reset()
|
||||
|
||||
void ViewerImpl::load(GCodeInputData&& gcode_data)
|
||||
{
|
||||
if (gcode_data.vertices.empty())
|
||||
return;
|
||||
|
||||
m_loading = true;
|
||||
|
||||
m_vertices = std::move(gcode_data.vertices);
|
||||
m_settings.spiral_vase_mode = gcode_data.spiral_vase_mode;
|
||||
|
||||
m_used_extruders_ids.reserve(m_vertices.size());
|
||||
|
||||
for (size_t i = 0; i < m_vertices.size(); ++i) {
|
||||
const PathVertex& v = m_vertices[i];
|
||||
m_layers.update(v, static_cast<uint32_t>(i));
|
||||
@ -434,6 +439,9 @@ void ViewerImpl::load(GCodeInputData&& gcode_data)
|
||||
else
|
||||
m_extrusion_roles.add(v.role, v.times);
|
||||
|
||||
if (v.type == EMoveType::Extrude)
|
||||
m_used_extruders_ids.emplace_back(v.extruder_id);
|
||||
|
||||
if (i > 0) {
|
||||
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
|
||||
// updates calculation for center of gravity
|
||||
@ -454,6 +462,7 @@ void ViewerImpl::load(GCodeInputData&& gcode_data)
|
||||
|
||||
std::sort(m_used_extruders_ids.begin(), m_used_extruders_ids.end());
|
||||
m_used_extruders_ids.erase(std::unique(m_used_extruders_ids.begin(), m_used_extruders_ids.end()), m_used_extruders_ids.end());
|
||||
m_used_extruders_ids.shrink_to_fit();
|
||||
|
||||
// reset segments visibility bitset
|
||||
m_valid_lines_bitset = BitSet<>(m_vertices.size());
|
||||
@ -535,9 +544,8 @@ void ViewerImpl::load(GCodeInputData&& gcode_data)
|
||||
glsafe(glBindTexture(GL_TEXTURE_BUFFER, old_bound_texture));
|
||||
}
|
||||
|
||||
if (!m_layers.empty())
|
||||
set_layers_view_range(0, static_cast<uint32_t>(m_layers.count() - 1));
|
||||
|
||||
update_view_full_range();
|
||||
m_view_range.set_visible(m_view_range.get_enabled());
|
||||
update_enabled_entities();
|
||||
update_colors();
|
||||
|
||||
@ -725,6 +733,7 @@ void ViewerImpl::set_layers_view_range(uint32_t min, uint32_t max)
|
||||
m_layers.set_view_range(min, max);
|
||||
// force immediate update of the full range
|
||||
update_view_full_range();
|
||||
m_view_range.set_visible(m_view_range.get_enabled());
|
||||
m_settings.update_enabled_entities = true;
|
||||
m_settings.update_colors = true;
|
||||
}
|
||||
@ -828,7 +837,7 @@ void ViewerImpl::toggle_extrusion_role_visibility(EGCodeExtrusionRole role)
|
||||
try {
|
||||
bool& value = m_settings.extrusion_roles_visibility.at(role);
|
||||
value = !value;
|
||||
m_settings.update_view_full_range = true;
|
||||
update_view_full_range();
|
||||
m_settings.update_enabled_entities = true;
|
||||
m_settings.update_colors = true;
|
||||
}
|
||||
@ -1123,6 +1132,10 @@ void ViewerImpl::update_view_full_range()
|
||||
++first_it;
|
||||
}
|
||||
|
||||
// If the first vertex is an extrusion, add an extra step to properly detect the first segment
|
||||
if (first_it != m_vertices.begin() && first_it->type == EMoveType::Extrude)
|
||||
--first_it;
|
||||
|
||||
if (first_it == m_vertices.end())
|
||||
m_view_range.set_full(Range());
|
||||
else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user