mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-21 20:18:17 +08:00
GCodeViewer -> Selection of extrusions view type
This commit is contained in:
parent
75d1e8373d
commit
7b0e35e70d
@ -354,6 +354,35 @@ void GCodeViewer::load_shells(const Print& print, bool initialized)
|
||||
|
||||
void GCodeViewer::render_toolpaths() const
|
||||
{
|
||||
auto extrusion_color = [this](const Path& path) {
|
||||
std::array<float, 4> color;
|
||||
switch (m_view_type)
|
||||
{
|
||||
case EViewType::FeatureType:
|
||||
{
|
||||
unsigned int color_id = static_cast<unsigned int>(path.role);
|
||||
if (color_id >= erCount)
|
||||
color_id = 0;
|
||||
|
||||
color = m_extrusion_role_colors[color_id];
|
||||
break;
|
||||
}
|
||||
case EViewType::Height:
|
||||
case EViewType::Width:
|
||||
case EViewType::Feedrate:
|
||||
case EViewType::FanSpeed:
|
||||
case EViewType::VolumetricRate:
|
||||
case EViewType::Tool:
|
||||
case EViewType::ColorPrint:
|
||||
default:
|
||||
{
|
||||
color = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
break;
|
||||
}
|
||||
}
|
||||
return color;
|
||||
};
|
||||
|
||||
auto set_color = [](GLint current_program_id, const std::array<float, 4>& color) {
|
||||
if (current_program_id > 0) {
|
||||
GLint color_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "uniform_color") : -1;
|
||||
@ -427,12 +456,7 @@ void GCodeViewer::render_toolpaths() const
|
||||
{
|
||||
for (const Path& path : buffer.paths)
|
||||
{
|
||||
unsigned int color_id = static_cast<unsigned int>(path.role);
|
||||
if (color_id >= erCount)
|
||||
color_id = 0;
|
||||
|
||||
set_color(current_program_id, m_extrusion_role_colors[color_id]);
|
||||
|
||||
set_color(current_program_id, extrusion_color(path));
|
||||
glsafe(::glDrawElements(GL_LINE_STRIP, GLsizei(path.last - path.first + 1), GL_UNSIGNED_INT, (const void*)(path.first * sizeof(GLuint))));
|
||||
}
|
||||
break;
|
||||
|
@ -62,6 +62,21 @@ class GCodeViewer
|
||||
Shader shader;
|
||||
};
|
||||
|
||||
public:
|
||||
enum class EViewType : unsigned char
|
||||
{
|
||||
FeatureType,
|
||||
Height,
|
||||
Width,
|
||||
Feedrate,
|
||||
FanSpeed,
|
||||
VolumetricRate,
|
||||
Tool,
|
||||
ColorPrint,
|
||||
Count
|
||||
};
|
||||
|
||||
private:
|
||||
VBuffer m_vertices;
|
||||
std::vector<IBuffer> m_buffers{ static_cast<size_t>(GCodeProcessor::EMoveType::Extrude) };
|
||||
|
||||
@ -71,6 +86,8 @@ class GCodeViewer
|
||||
|
||||
std::array<std::array<float, 4>, erCount> m_extrusion_role_colors;
|
||||
|
||||
EViewType m_view_type{ EViewType::FeatureType };
|
||||
|
||||
public:
|
||||
GCodeViewer() = default;
|
||||
~GCodeViewer() { reset(); }
|
||||
@ -86,6 +103,14 @@ public:
|
||||
|
||||
const std::vector<double>& get_layers_zs() const { return m_layers_zs; };
|
||||
|
||||
EViewType get_view_type() const { return m_view_type; }
|
||||
void set_view_type(EViewType type) {
|
||||
if (type == EViewType::Count)
|
||||
type = EViewType::FeatureType;
|
||||
|
||||
m_view_type = type;
|
||||
}
|
||||
|
||||
bool is_toolpath_visible(GCodeProcessor::EMoveType type) const;
|
||||
void set_toolpath_visible(GCodeProcessor::EMoveType type, bool visible);
|
||||
|
||||
|
@ -2323,6 +2323,11 @@ void GLCanvas3D::set_toolpath_visible(GCodeProcessor::EMoveType type, bool visib
|
||||
m_gcode_viewer.set_toolpath_visible(type, visible);
|
||||
}
|
||||
|
||||
void GLCanvas3D::set_toolpath_view_type(GCodeViewer::EViewType type)
|
||||
{
|
||||
m_gcode_viewer.set_view_type(type);
|
||||
}
|
||||
|
||||
void GLCanvas3D::set_shells_visible(bool visible)
|
||||
{
|
||||
m_gcode_viewer.set_shells_visible(visible);
|
||||
|
@ -642,6 +642,7 @@ public:
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
const std::vector<double>& get_layers_zs() const;
|
||||
void set_toolpath_visible(GCodeProcessor::EMoveType type, bool visible);
|
||||
void set_toolpath_view_type(GCodeViewer::EViewType type);
|
||||
void set_shells_visible(bool visible);
|
||||
#else
|
||||
std::vector<double> get_current_print_zs(bool active_only) const;
|
||||
|
@ -602,10 +602,17 @@ void Preview::on_choice_view_type(wxCommandEvent& evt)
|
||||
{
|
||||
m_preferred_color_mode = (m_choice_view_type->GetStringSelection() == L("Tool")) ? "tool" : "feature";
|
||||
int selection = m_choice_view_type->GetCurrentSelection();
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
if (0 <= selection && selection < static_cast<int>(GCodeViewer::EViewType::Count))
|
||||
m_canvas->set_toolpath_view_type(static_cast<GCodeViewer::EViewType>(selection));
|
||||
|
||||
refresh_print();
|
||||
#else
|
||||
if ((0 <= selection) && (selection < (int)GCodePreviewData::Extrusion::Num_View_Types))
|
||||
m_gcode_preview_data->extrusion.view_type = (GCodePreviewData::Extrusion::EViewType)selection;
|
||||
|
||||
reload_print();
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
}
|
||||
|
||||
void Preview::on_combochecklist_features(wxCommandEvent& evt)
|
||||
|
Loading…
x
Reference in New Issue
Block a user