GCodeViewer -> Draw alphed extrusion paths into legend when set as not visible

This commit is contained in:
enricoturri1966 2020-04-25 12:24:56 +02:00
parent eadad6c1d1
commit 4ea96340d8
3 changed files with 20 additions and 9 deletions

View File

@ -33,8 +33,7 @@ static GCodeProcessor::EMoveType buffer_type(unsigned char id) {
return static_cast<GCodeProcessor::EMoveType>(static_cast<unsigned char>(GCodeProcessor::EMoveType::Retract) + id);
}
std::vector<std::array<float, 3>> decode_colors(const std::vector<std::string>& colors)
{
std::vector<std::array<float, 3>> decode_colors(const std::vector<std::string>& colors) {
static const float INV_255 = 1.0f / 255.0f;
std::vector<std::array<float, 3>> output(colors.size(), {0.0f, 0.0f, 0.0f} );
@ -67,6 +66,10 @@ void GCodeViewer::VBuffer::reset()
vertices_count = 0;
}
bool GCodeViewer::Path::is_path_visible(unsigned int flags, const Path& path) {
return Extrusions::is_role_visible(flags, path.role);
};
void GCodeViewer::IBuffer::reset()
{
// release gpu memory
@ -509,10 +512,6 @@ void GCodeViewer::render_toolpaths() const
BOOST_LOG_TRIVIAL(error) << "Unable to find uniform_color uniform";
};
auto is_path_visible = [](unsigned int flags, const Path& path) {
return Extrusions::is_role_visible(flags, path.role);
};
glsafe(::glCullFace(GL_BACK));
glsafe(::glLineWidth(3.0f));
@ -600,7 +599,7 @@ void GCodeViewer::render_toolpaths() const
case GCodeProcessor::EMoveType::Extrude:
{
for (const Path& path : buffer.paths) {
if (!is_path_visible(m_extrusions.role_visibility_flags, path))
if (!Path::is_path_visible(m_extrusions.role_visibility_flags, path))
continue;
set_color(current_program_id, extrusion_color(path));
@ -713,7 +712,13 @@ void GCodeViewer::render_overlay() const
case EViewType::FeatureType:
{
for (ExtrusionRole role : m_roles) {
bool visible = m_extrusions.is_role_visible(role);
if (!visible)
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.3333f);
add_item(Extrusion_Role_Colors[static_cast<unsigned int>(role)], I18N::translate_utf8(ExtrusionEntity::role_to_string(role)));
if (!visible)
ImGui::PopStyleVar();
}
break;
}

View File

@ -54,6 +54,8 @@ class GCodeViewer
feedrate == move.feedrate && fan_speed == move.fan_speed && volumetric_rate == move.volumetric_rate() &&
extruder_id == move.extruder_id && cp_color_id == move.cp_color_id;
}
static bool is_path_visible(unsigned int flags, const Path& path);
};
// buffer containing indices data and shader for a specific toolpath type
@ -130,6 +132,10 @@ class GCodeViewer
void reset_ranges() { ranges.reset(); }
bool is_role_visible(ExtrusionRole role) const {
return role < erCount && (role_visibility_flags & (1 << role)) != 0;
}
static bool is_role_visible(unsigned int flags, ExtrusionRole role) {
return role < erCount && (flags & (1 << role)) != 0;
}

View File

@ -332,7 +332,7 @@ bool Preview::init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view
#if ENABLE_GCODE_VIEWER
m_combochecklist_options = new wxComboCtrl();
m_combochecklist_options->Create(this, wxID_ANY, _(L("Options")), wxDefaultPosition, wxSize(15 * wxGetApp().em_unit(), -1), wxCB_READONLY);
m_combochecklist_options->Create(this, wxID_ANY, _(L("Others")), wxDefaultPosition, wxSize(15 * wxGetApp().em_unit(), -1), wxCB_READONLY);
std::string options_items = GUI::into_u8(
_(L("Travel")) + "|0|" +
_(L("Retractions")) + "|0|" +
@ -344,7 +344,7 @@ bool Preview::init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view
_(L("Shells")) + "|0|" +
_(L("Legend")) + "|1"
);
Slic3r::GUI::create_combochecklist(m_combochecklist_options, GUI::into_u8(_(L("Options"))), options_items);
Slic3r::GUI::create_combochecklist(m_combochecklist_options, GUI::into_u8(_(L("Others"))), options_items);
#else
m_checkbox_travel = new wxCheckBox(this, wxID_ANY, _(L("Travel")));
m_checkbox_retractions = new wxCheckBox(this, wxID_ANY, _(L("Retractions")));