mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-25 07:34:03 -06:00
GCodeViewer -> Refactoring and code cleanup
This commit is contained in:
parent
6e2307f56d
commit
66964c44c1
8 changed files with 26 additions and 77 deletions
|
@ -254,11 +254,9 @@ bool GCodeViewer::init_shaders()
|
|||
switch (buffer_type(i))
|
||||
{
|
||||
case GCodeProcessor::EMoveType::Tool_change: { vertex_shader = "toolchanges.vs"; fragment_shader = "toolchanges.fs"; break; }
|
||||
#if ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
case GCodeProcessor::EMoveType::Color_change: { vertex_shader = "colorchanges.vs"; fragment_shader = "colorchanges.fs"; break; }
|
||||
case GCodeProcessor::EMoveType::Pause_Print: { vertex_shader = "pauses.vs"; fragment_shader = "pauses.fs"; break; }
|
||||
case GCodeProcessor::EMoveType::Custom_GCode: { vertex_shader = "customs.vs"; fragment_shader = "customs.fs"; break; }
|
||||
#endif // ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
case GCodeProcessor::EMoveType::Retract: { vertex_shader = "retractions.vs"; fragment_shader = "retractions.fs"; break; }
|
||||
case GCodeProcessor::EMoveType::Unretract: { vertex_shader = "unretractions.vs"; fragment_shader = "unretractions.fs"; break; }
|
||||
case GCodeProcessor::EMoveType::Extrude: { vertex_shader = "extrusions.vs"; fragment_shader = "extrusions.fs"; break; }
|
||||
|
@ -320,11 +318,9 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result)
|
|||
switch (curr.type)
|
||||
{
|
||||
case GCodeProcessor::EMoveType::Tool_change:
|
||||
#if ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
case GCodeProcessor::EMoveType::Color_change:
|
||||
case GCodeProcessor::EMoveType::Pause_Print:
|
||||
case GCodeProcessor::EMoveType::Custom_GCode:
|
||||
#endif // ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
case GCodeProcessor::EMoveType::Retract:
|
||||
case GCodeProcessor::EMoveType::Unretract:
|
||||
{
|
||||
|
@ -523,7 +519,6 @@ void GCodeViewer::render_toolpaths() const
|
|||
glsafe(::glDisable(GL_PROGRAM_POINT_SIZE));
|
||||
break;
|
||||
}
|
||||
#if ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
case GCodeProcessor::EMoveType::Color_change:
|
||||
{
|
||||
std::array<float, 3> color = { 1.0f, 0.0f, 0.0f };
|
||||
|
@ -551,7 +546,6 @@ void GCodeViewer::render_toolpaths() const
|
|||
glsafe(::glDisable(GL_PROGRAM_POINT_SIZE));
|
||||
break;
|
||||
}
|
||||
#endif // ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
case GCodeProcessor::EMoveType::Retract:
|
||||
{
|
||||
std::array<float, 3> color = { 1.0f, 0.0f, 1.0f };
|
||||
|
@ -746,9 +740,6 @@ void GCodeViewer::render_legend() const
|
|||
const int items_cnt = static_cast<int>(cp_values.size());
|
||||
if (items_cnt == 0) { // There is no one color change, but there are some pause print or custom Gcode
|
||||
add_item(m_tool_colors.front(), I18N::translate_utf8(L("Default print color")));
|
||||
#if !ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
add_item(m_tool_colors.back(), I18N::translate_utf8(L("Pause print or custom G-code")));
|
||||
#endif // !ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
}
|
||||
else {
|
||||
for (int i = items_cnt; i >= 0; --i) {
|
||||
|
|
|
@ -229,12 +229,12 @@ Preview::Preview(
|
|||
, m_checkbox_travel(nullptr)
|
||||
, m_checkbox_retractions(nullptr)
|
||||
, m_checkbox_unretractions(nullptr)
|
||||
#if ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
, m_checkbox_tool_changes(nullptr)
|
||||
, m_checkbox_color_changes(nullptr)
|
||||
, m_checkbox_pause_prints(nullptr)
|
||||
, m_checkbox_custom_gcodes(nullptr)
|
||||
#endif // ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
, m_checkbox_shells(nullptr)
|
||||
, m_checkbox_legend(nullptr)
|
||||
, m_config(config)
|
||||
|
@ -336,12 +336,12 @@ bool Preview::init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view
|
|||
m_checkbox_travel = new wxCheckBox(this, wxID_ANY, _(L("Travel")));
|
||||
m_checkbox_retractions = new wxCheckBox(this, wxID_ANY, _(L("Retractions")));
|
||||
m_checkbox_unretractions = new wxCheckBox(this, wxID_ANY, _(L("Unretractions")));
|
||||
#if ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
m_checkbox_tool_changes = new wxCheckBox(this, wxID_ANY, _(L("Tool changes")));
|
||||
m_checkbox_color_changes = new wxCheckBox(this, wxID_ANY, _(L("Color changes")));
|
||||
m_checkbox_pause_prints = new wxCheckBox(this, wxID_ANY, _(L("Pause prints")));
|
||||
m_checkbox_custom_gcodes = new wxCheckBox(this, wxID_ANY, _(L("Custom GCodes")));
|
||||
#endif // ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
m_checkbox_shells = new wxCheckBox(this, wxID_ANY, _(L("Shells")));
|
||||
m_checkbox_legend = new wxCheckBox(this, wxID_ANY, _(L("Legend")));
|
||||
m_checkbox_legend->SetValue(true);
|
||||
|
@ -363,7 +363,7 @@ bool Preview::init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view
|
|||
bottom_sizer->AddSpacer(10);
|
||||
bottom_sizer->Add(m_checkbox_unretractions, 0, wxEXPAND | wxALL, 5);
|
||||
bottom_sizer->AddSpacer(10);
|
||||
#if ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
bottom_sizer->Add(m_checkbox_tool_changes, 0, wxEXPAND | wxALL, 5);
|
||||
bottom_sizer->AddSpacer(10);
|
||||
bottom_sizer->Add(m_checkbox_color_changes, 0, wxEXPAND | wxALL, 5);
|
||||
|
@ -372,7 +372,7 @@ bool Preview::init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view
|
|||
bottom_sizer->AddSpacer(10);
|
||||
bottom_sizer->Add(m_checkbox_custom_gcodes, 0, wxEXPAND | wxALL, 5);
|
||||
bottom_sizer->AddSpacer(10);
|
||||
#endif // ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
bottom_sizer->Add(m_checkbox_shells, 0, wxEXPAND | wxALL, 5);
|
||||
bottom_sizer->AddSpacer(20);
|
||||
bottom_sizer->Add(m_checkbox_legend, 0, wxEXPAND | wxALL, 5);
|
||||
|
@ -555,12 +555,12 @@ void Preview::bind_event_handlers()
|
|||
m_checkbox_travel->Bind(wxEVT_CHECKBOX, &Preview::on_checkbox_travel, this);
|
||||
m_checkbox_retractions->Bind(wxEVT_CHECKBOX, &Preview::on_checkbox_retractions, this);
|
||||
m_checkbox_unretractions->Bind(wxEVT_CHECKBOX, &Preview::on_checkbox_unretractions, this);
|
||||
#if ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
m_checkbox_tool_changes->Bind(wxEVT_CHECKBOX, &Preview::on_checkbox_tool_changes, this);
|
||||
m_checkbox_color_changes->Bind(wxEVT_CHECKBOX, &Preview::on_checkbox_color_changes, this);
|
||||
m_checkbox_pause_prints->Bind(wxEVT_CHECKBOX, &Preview::on_checkbox_pause_prints, this);
|
||||
m_checkbox_custom_gcodes->Bind(wxEVT_CHECKBOX, &Preview::on_checkbox_custom_gcodes, this);
|
||||
#endif // ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
m_checkbox_shells->Bind(wxEVT_CHECKBOX, &Preview::on_checkbox_shells, this);
|
||||
m_checkbox_legend->Bind(wxEVT_CHECKBOX, &Preview::on_checkbox_legend, this);
|
||||
}
|
||||
|
@ -573,12 +573,12 @@ void Preview::unbind_event_handlers()
|
|||
m_checkbox_travel->Unbind(wxEVT_CHECKBOX, &Preview::on_checkbox_travel, this);
|
||||
m_checkbox_retractions->Unbind(wxEVT_CHECKBOX, &Preview::on_checkbox_retractions, this);
|
||||
m_checkbox_unretractions->Unbind(wxEVT_CHECKBOX, &Preview::on_checkbox_unretractions, this);
|
||||
#if ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
m_checkbox_tool_changes->Unbind(wxEVT_CHECKBOX, &Preview::on_checkbox_tool_changes, this);
|
||||
m_checkbox_color_changes->Unbind(wxEVT_CHECKBOX, &Preview::on_checkbox_color_changes, this);
|
||||
m_checkbox_pause_prints->Unbind(wxEVT_CHECKBOX, &Preview::on_checkbox_pause_prints, this);
|
||||
m_checkbox_custom_gcodes->Unbind(wxEVT_CHECKBOX, &Preview::on_checkbox_custom_gcodes, this);
|
||||
#endif // ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
m_checkbox_shells->Unbind(wxEVT_CHECKBOX, &Preview::on_checkbox_shells, this);
|
||||
m_checkbox_legend->Unbind(wxEVT_CHECKBOX, &Preview::on_checkbox_legend, this);
|
||||
}
|
||||
|
@ -591,12 +591,12 @@ void Preview::show_hide_ui_elements(const std::string& what)
|
|||
m_checkbox_travel->Enable(enable);
|
||||
m_checkbox_retractions->Enable(enable);
|
||||
m_checkbox_unretractions->Enable(enable);
|
||||
#if ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
m_checkbox_tool_changes->Enable(enable);
|
||||
m_checkbox_color_changes->Enable(enable);
|
||||
m_checkbox_pause_prints->Enable(enable);
|
||||
m_checkbox_custom_gcodes->Enable(enable);
|
||||
#endif // ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
m_checkbox_shells->Enable(enable);
|
||||
m_checkbox_legend->Enable(enable);
|
||||
|
||||
|
@ -610,12 +610,12 @@ void Preview::show_hide_ui_elements(const std::string& what)
|
|||
m_checkbox_travel->Show(visible);
|
||||
m_checkbox_retractions->Show(visible);
|
||||
m_checkbox_unretractions->Show(visible);
|
||||
#if ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
m_checkbox_tool_changes->Show(visible);
|
||||
m_checkbox_color_changes->Show(visible);
|
||||
m_checkbox_pause_prints->Show(visible);
|
||||
m_checkbox_custom_gcodes->Show(visible);
|
||||
#endif // ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
m_checkbox_shells->Show(visible);
|
||||
m_checkbox_legend->Show(visible);
|
||||
m_label_view_type->Show(visible);
|
||||
|
@ -709,7 +709,7 @@ void Preview::on_checkbox_unretractions(wxCommandEvent& evt)
|
|||
refresh_print();
|
||||
}
|
||||
|
||||
#if ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
void Preview::on_checkbox_tool_changes(wxCommandEvent& evt)
|
||||
{
|
||||
m_canvas->set_toolpath_move_type_visible(GCodeProcessor::EMoveType::Tool_change, m_checkbox_tool_changes->IsChecked());
|
||||
|
@ -733,7 +733,7 @@ void Preview::on_checkbox_custom_gcodes(wxCommandEvent& evt)
|
|||
m_canvas->set_toolpath_move_type_visible(GCodeProcessor::EMoveType::Custom_GCode, m_checkbox_custom_gcodes->IsChecked());
|
||||
refresh_print();
|
||||
}
|
||||
#endif // ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
||||
void Preview::on_checkbox_shells(wxCommandEvent& evt)
|
||||
{
|
||||
|
@ -1053,9 +1053,9 @@ void Preview::load_print_as_fff(bool keep_z_range)
|
|||
#endif // ENABLE_GCODE_VIEWER
|
||||
{
|
||||
colors = wxGetApp().plater()->get_colors_for_color_print();
|
||||
#if !ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
#if !ENABLE_GCODE_VIEWER
|
||||
colors.push_back("#808080"); // gray color for pause print or custom G-code
|
||||
#endif // !ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
#endif // !ENABLE_GCODE_VIEWER
|
||||
|
||||
if (!gcode_preview_data_valid)
|
||||
color_print_values = wxGetApp().plater()->model().custom_gcode_per_print_z.gcodes;
|
||||
|
|
|
@ -98,12 +98,12 @@ class Preview : public wxPanel
|
|||
wxCheckBox* m_checkbox_travel;
|
||||
wxCheckBox* m_checkbox_retractions;
|
||||
wxCheckBox* m_checkbox_unretractions;
|
||||
#if ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
wxCheckBox* m_checkbox_tool_changes;
|
||||
wxCheckBox* m_checkbox_color_changes;
|
||||
wxCheckBox* m_checkbox_pause_prints;
|
||||
wxCheckBox* m_checkbox_custom_gcodes;
|
||||
#endif // ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
wxCheckBox* m_checkbox_shells;
|
||||
wxCheckBox* m_checkbox_legend;
|
||||
|
||||
|
@ -195,12 +195,12 @@ private:
|
|||
void on_checkbox_travel(wxCommandEvent& evt);
|
||||
void on_checkbox_retractions(wxCommandEvent& evt);
|
||||
void on_checkbox_unretractions(wxCommandEvent& evt);
|
||||
#if ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
void on_checkbox_tool_changes(wxCommandEvent& evt);
|
||||
void on_checkbox_color_changes(wxCommandEvent& evt);
|
||||
void on_checkbox_pause_prints(wxCommandEvent& evt);
|
||||
void on_checkbox_custom_gcodes(wxCommandEvent& evt);
|
||||
#endif // ENABLE_GCODE_VIEWER_SEPARATE_PAUSE_PRINT
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
void on_checkbox_shells(wxCommandEvent& evt);
|
||||
void on_checkbox_legend(wxCommandEvent& evt);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue