Hopefully final follow-up of 8ebb2e2
-> GCodeViewer: Ensure that the view is properly updated after automatic selection of view type when loading model using multiextruders prints
This commit is contained in:
parent
84c6199015
commit
90a23d73bc
3 changed files with 39 additions and 18 deletions
|
@ -671,6 +671,7 @@ public:
|
||||||
|
|
||||||
#if ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
#if ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
||||||
std::vector<CustomGCode::Item>& get_custom_gcode_per_print_z() { return m_custom_gcode_per_print_z; }
|
std::vector<CustomGCode::Item>& get_custom_gcode_per_print_z() { return m_custom_gcode_per_print_z; }
|
||||||
|
size_t get_extruders_count() { return m_extruders_count; }
|
||||||
#endif // ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
#endif // ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -636,6 +636,7 @@ public:
|
||||||
void set_toolpaths_z_range(const std::array<unsigned int, 2>& range);
|
void set_toolpaths_z_range(const std::array<unsigned int, 2>& range);
|
||||||
#if ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
#if ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
||||||
std::vector<CustomGCode::Item>& get_custom_gcode_per_print_z() { return m_gcode_viewer.get_custom_gcode_per_print_z(); }
|
std::vector<CustomGCode::Item>& get_custom_gcode_per_print_z() { return m_gcode_viewer.get_custom_gcode_per_print_z(); }
|
||||||
|
size_t get_gcode_extruders_count() { return m_gcode_viewer.get_extruders_count(); }
|
||||||
#endif // ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
#endif // ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
||||||
|
|
||||||
std::vector<int> load_object(const ModelObject& model_object, int obj_idx, std::vector<int> instance_idxs);
|
std::vector<int> load_object(const ModelObject& model_object, int obj_idx, std::vector<int> instance_idxs);
|
||||||
|
|
|
@ -935,9 +935,9 @@ void Preview::load_print_as_fff(bool keep_z_range)
|
||||||
color_print_values.clear();
|
color_print_values.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsShown()) {
|
std::vector<double> zs;
|
||||||
std::vector<double> zs;
|
|
||||||
|
|
||||||
|
if (IsShown()) {
|
||||||
m_canvas->set_selected_extruder(0);
|
m_canvas->set_selected_extruder(0);
|
||||||
if (gcode_preview_data_valid) {
|
if (gcode_preview_data_valid) {
|
||||||
// Load the real G-code preview.
|
// Load the real G-code preview.
|
||||||
|
@ -948,7 +948,12 @@ void Preview::load_print_as_fff(bool keep_z_range)
|
||||||
Refresh();
|
Refresh();
|
||||||
zs = m_canvas->get_gcode_layers_zs();
|
zs = m_canvas->get_gcode_layers_zs();
|
||||||
m_loaded = true;
|
m_loaded = true;
|
||||||
} else {
|
}
|
||||||
|
#if ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
||||||
|
else if (wxGetApp().is_editor()) {
|
||||||
|
#else
|
||||||
|
else {
|
||||||
|
#endif // ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
||||||
// Load the initial preview based on slices, not the final G-code.
|
// Load the initial preview based on slices, not the final G-code.
|
||||||
m_canvas->load_preview(colors, color_print_values);
|
m_canvas->load_preview(colors, color_print_values);
|
||||||
m_left_sizer->Hide(m_bottom_toolbar_panel);
|
m_left_sizer->Hide(m_bottom_toolbar_panel);
|
||||||
|
@ -956,6 +961,33 @@ void Preview::load_print_as_fff(bool keep_z_range)
|
||||||
Refresh();
|
Refresh();
|
||||||
zs = m_canvas->get_volumes_print_zs(true);
|
zs = m_canvas->get_volumes_print_zs(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
||||||
|
if (!zs.empty() && !m_keep_current_preview_type) {
|
||||||
|
unsigned int number_extruders = wxGetApp().is_editor() ?
|
||||||
|
(unsigned int)print->extruders().size() :
|
||||||
|
m_canvas->get_gcode_extruders_count();
|
||||||
|
std::vector<Item> gcodes = wxGetApp().is_editor() ?
|
||||||
|
wxGetApp().plater()->model().custom_gcode_per_print_z.gcodes :
|
||||||
|
m_canvas->get_custom_gcode_per_print_z();
|
||||||
|
const wxString choice = !gcodes.empty() ?
|
||||||
|
_L("Color Print") :
|
||||||
|
(number_extruders > 1) ? _L("Tool") : _L("Feature type");
|
||||||
|
|
||||||
|
int type = m_choice_view_type->FindString(choice);
|
||||||
|
if (m_choice_view_type->GetSelection() != type) {
|
||||||
|
if (0 <= type && type < static_cast<int>(GCodeViewer::EViewType::Count)) {
|
||||||
|
m_choice_view_type->SetSelection(type);
|
||||||
|
m_canvas->set_gcode_view_preview_type(static_cast<GCodeViewer::EViewType>(type));
|
||||||
|
if (wxGetApp().is_gcode_viewer()) {
|
||||||
|
m_keep_current_preview_type = true;
|
||||||
|
refresh_print();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
||||||
|
|
||||||
if (zs.empty()) {
|
if (zs.empty()) {
|
||||||
// all layers filtered out
|
// all layers filtered out
|
||||||
hide_layers_slider();
|
hide_layers_slider();
|
||||||
|
@ -964,35 +996,22 @@ void Preview::load_print_as_fff(bool keep_z_range)
|
||||||
update_layers_slider(zs, keep_z_range);
|
update_layers_slider(zs, keep_z_range);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
||||||
if (!m_keep_current_preview_type) {
|
if (!m_keep_current_preview_type) {
|
||||||
unsigned int number_extruders = (unsigned int)print->extruders().size();
|
unsigned int number_extruders = (unsigned int)print->extruders().size();
|
||||||
#if ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
|
||||||
std::vector<Item> gcodes = wxGetApp().is_editor() ?
|
|
||||||
wxGetApp().plater()->model().custom_gcode_per_print_z.gcodes :
|
|
||||||
m_canvas->get_custom_gcode_per_print_z();
|
|
||||||
const wxString choice = !gcodes.empty() ?
|
|
||||||
_L("Color Print") :
|
|
||||||
(number_extruders > 1) ? _L("Tool") : _L("Feature type");
|
|
||||||
#else
|
|
||||||
const wxString choice = !wxGetApp().plater()->model().custom_gcode_per_print_z.gcodes.empty() ?
|
const wxString choice = !wxGetApp().plater()->model().custom_gcode_per_print_z.gcodes.empty() ?
|
||||||
_L("Color Print") :
|
_L("Color Print") :
|
||||||
(number_extruders > 1) ? _L("Tool") : _L("Feature type");
|
(number_extruders > 1) ? _L("Tool") : _L("Feature type");
|
||||||
#endif // ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
|
||||||
|
|
||||||
int type = m_choice_view_type->FindString(choice);
|
int type = m_choice_view_type->FindString(choice);
|
||||||
if (m_choice_view_type->GetSelection() != type) {
|
if (m_choice_view_type->GetSelection() != type) {
|
||||||
if (0 <= type && type < static_cast<int>(GCodeViewer::EViewType::Count)) {
|
if (0 <= type && type < static_cast<int>(GCodeViewer::EViewType::Count)) {
|
||||||
m_choice_view_type->SetSelection(type);
|
m_choice_view_type->SetSelection(type);
|
||||||
m_canvas->set_gcode_view_preview_type(static_cast<GCodeViewer::EViewType>(type));
|
m_canvas->set_gcode_view_preview_type(static_cast<GCodeViewer::EViewType>(type));
|
||||||
#if ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
|
||||||
if (wxGetApp().is_gcode_viewer()) {
|
|
||||||
m_keep_current_preview_type = true;
|
|
||||||
refresh_print();
|
|
||||||
}
|
|
||||||
#endif // ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // !ENABLE_FIX_IMPORTING_COLOR_PRINT_VIEW_INTO_GCODEVIEWER
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preview::load_print_as_sla()
|
void Preview::load_print_as_sla()
|
||||||
|
|
Loading…
Reference in a new issue