Tech ENABLE_PREVIEW_TYPE_CHANGE set as default

This commit is contained in:
enricoturri1966 2021-02-18 11:52:14 +01:00
parent 65f5ac4f8a
commit aec39aaba6
4 changed files with 1 additions and 94 deletions

View File

@ -85,8 +85,7 @@
//===================
#define ENABLE_2_3_0_BETA2 1
#define ENABLE_NEW_NOTIFICATIONS_FADE_OUT (1 && ENABLE_2_3_0_BETA2)
#define ENABLE_PREVIEW_TYPE_CHANGE (1 && ENABLE_2_3_0_BETA2)
#define ENABLE_NEW_NOTIFICATIONS_FADE_OUT (1 && ENABLE_2_3_0_BETA2)
//===================

View File

@ -169,9 +169,6 @@ Preview::Preview(
: m_config(config)
, m_process(process)
, m_gcode_result(gcode_result)
#if !ENABLE_PREVIEW_TYPE_CHANGE
, m_preferred_color_mode("feature")
#endif // !ENABLE_PREVIEW_TYPE_CHANGE
, m_schedule_background_process(schedule_background_process_func)
{
if (init(parent, model))
@ -315,22 +312,6 @@ void Preview::set_as_dirty()
m_canvas->set_as_dirty();
}
#if !ENABLE_PREVIEW_TYPE_CHANGE
void Preview::set_number_extruders(unsigned int number_extruders)
{
if (m_number_extruders != number_extruders) {
m_number_extruders = number_extruders;
int tool_idx = m_choice_view_type->FindString(_(L("Tool")));
int type = (number_extruders > 1) ? tool_idx /* color by a tool number */ : 0; // color by a feature type
m_choice_view_type->SetSelection(type);
if (0 <= type && (type < static_cast<int>(GCodeViewer::EViewType::Count)))
m_canvas->set_gcode_view_preview_type(static_cast<GCodeViewer::EViewType>(type));
m_preferred_color_mode = (type == tool_idx) ? "tool_or_feature" : "feature";
}
}
#endif // !ENABLE_PREVIEW_TYPE_CHANGE
void Preview::bed_shape_changed()
{
if (m_canvas != nullptr)
@ -468,20 +449,11 @@ void Preview::on_size(wxSizeEvent& evt)
void Preview::on_choice_view_type(wxCommandEvent& evt)
{
#if !ENABLE_PREVIEW_TYPE_CHANGE
m_preferred_color_mode = (m_choice_view_type->GetStringSelection() == L("Tool")) ? "tool" : "feature";
#endif // !ENABLE_PREVIEW_TYPE_CHANGE
int selection = m_choice_view_type->GetCurrentSelection();
#if ENABLE_PREVIEW_TYPE_CHANGE
if (0 <= selection && selection < static_cast<int>(GCodeViewer::EViewType::Count)) {
m_canvas->set_toolpath_view_type(static_cast<GCodeViewer::EViewType>(selection));
m_keep_current_preview_type = true;
}
#else
if (0 <= selection && selection < static_cast<int>(GCodeViewer::EViewType::Count))
m_canvas->set_toolpath_view_type(static_cast<GCodeViewer::EViewType>(selection));
#endif // ENABLE_PREVIEW_TYPE_CHANGE
refresh_print();
}
@ -522,30 +494,6 @@ void Preview::on_combochecklist_options(wxCommandEvent& evt)
#endif // ENABLE_RENDER_PATH_REFRESH_AFTER_OPTIONS_CHANGE
}
#if !ENABLE_PREVIEW_TYPE_CHANGE
void Preview::update_view_type(bool keep_volumes)
{
const DynamicPrintConfig& config = wxGetApp().preset_bundle->project_config;
const wxString& choice = !wxGetApp().plater()->model().custom_gcode_per_print_z.gcodes.empty() /*&&
(wxGetApp().extruders_edited_cnt()==1 || !slice_completed) */?
_L("Color Print") :
config.option<ConfigOptionFloats>("wiping_volumes_matrix")->values.size() > 1 ?
_L("Tool") :
_L("Feature type");
int type = m_choice_view_type->FindString(choice);
if (m_choice_view_type->GetSelection() != type) {
m_choice_view_type->SetSelection(type);
if (0 <= type && type < static_cast<int>(GCodeViewer::EViewType::Count))
m_canvas->set_gcode_view_preview_type(static_cast<GCodeViewer::EViewType>(type));
m_preferred_color_mode = "feature";
}
reload_print(keep_volumes);
}
#endif // !ENABLE_PREVIEW_TYPE_CHANGE
void Preview::update_bottom_toolbar()
{
combochecklist_set_flags(m_combochecklist_features, m_canvas->get_toolpath_role_visibility_flags());
@ -601,12 +549,8 @@ wxBoxSizer* Preview::create_layers_slider_sizer()
model.custom_gcode_per_print_z = m_layers_slider->GetTicksValues();
m_schedule_background_process();
#if ENABLE_PREVIEW_TYPE_CHANGE
m_keep_current_preview_type = false;
reload_print(false);
#else
update_view_type(false);
#endif // ENABLE_PREVIEW_TYPE_CHANGE
});
return sizer;
@ -876,21 +820,6 @@ void Preview::load_print_as_fff(bool keep_z_range)
return;
}
#if !ENABLE_PREVIEW_TYPE_CHANGE
if (m_preferred_color_mode == "tool_or_feature") {
// It is left to Slic3r to decide whether the print shall be colored by the tool or by the feature.
// Color by feature if it is a single extruder print.
unsigned int number_extruders = (unsigned int)print->extruders().size();
int tool_idx = m_choice_view_type->FindString(_L("Tool"));
int type = (number_extruders > 1) ? tool_idx /* color by a tool number */ : 0; // color by a feature type
m_choice_view_type->SetSelection(type);
if (0 <= type && type < static_cast<int>(GCodeViewer::EViewType::Count))
m_canvas->set_gcode_view_preview_type(static_cast<GCodeViewer::EViewType>(type));
// If the->SetSelection changed the following line, revert it to "decide yourself".
m_preferred_color_mode = "tool_or_feature";
}
#endif // !ENABLE_PREVIEW_TYPE_CHANGE
GCodeViewer::EViewType gcode_view_type = m_canvas->get_gcode_view_preview_type();
bool gcode_preview_data_valid = !m_gcode_result->moves.empty();
// Collect colors per extruder.
@ -939,7 +868,6 @@ void Preview::load_print_as_fff(bool keep_z_range)
update_layers_slider(zs, keep_z_range);
}
#if ENABLE_PREVIEW_TYPE_CHANGE
unsigned int number_extruders = (unsigned int)print->extruders().size();
if (!m_keep_current_preview_type) {
@ -955,7 +883,6 @@ void Preview::load_print_as_fff(bool keep_z_range)
}
}
}
#endif // ENABLE_PREVIEW_TYPE_CHANGE
}
void Preview::load_print_as_sla()

View File

@ -102,11 +102,7 @@ class Preview : public wxPanel
std::function<void()> m_schedule_background_process;
unsigned int m_number_extruders { 1 };
#if ENABLE_PREVIEW_TYPE_CHANGE
bool m_keep_current_preview_type{ false };
#else
std::string m_preferred_color_mode;
#endif // ENABLE_PREVIEW_TYPE_CHANGE
bool m_loaded { false };
@ -138,9 +134,6 @@ public:
void set_as_dirty();
#if !ENABLE_PREVIEW_TYPE_CHANGE
void set_number_extruders(unsigned int number_extruders);
#endif // !ENABLE_PREVIEW_TYPE_CHANGE
void bed_shape_changed();
void select_view(const std::string& direction);
void set_drop_target(wxDropTarget* target);
@ -155,10 +148,6 @@ public:
void move_layers_slider(wxKeyEvent& evt);
void edit_layers_slider(wxKeyEvent& evt);
#if !ENABLE_PREVIEW_TYPE_CHANGE
void update_view_type(bool keep_volumes);
#endif // !ENABLE_PREVIEW_TYPE_CHANGE
bool is_loaded() const { return m_loaded; }
void update_bottom_toolbar();

View File

@ -5432,12 +5432,7 @@ void Plater::reslice()
if (clean_gcode_toolpaths)
reset_gcode_toolpaths();
#if ENABLE_PREVIEW_TYPE_CHANGE
p->preview->reload_print(!clean_gcode_toolpaths);
#else
// update type of preview
p->preview->update_view_type(!clean_gcode_toolpaths);
#endif // ENABLE_PREVIEW_TYPE_CHANGE
}
void Plater::reslice_SLA_supports(const ModelObject &object, bool postpone_error_messages)
@ -5681,9 +5676,6 @@ void Plater::on_config_change(const DynamicPrintConfig &config)
}
else if(opt_key == "extruder_colour") {
update_scheduled = true;
#if !ENABLE_PREVIEW_TYPE_CHANGE
p->preview->set_number_extruders(p->config->option<ConfigOptionStrings>(opt_key)->values.size());
#endif // !ENABLE_PREVIEW_TYPE_CHANGE
p->sidebar->obj_list()->update_extruder_colors();
} else if(opt_key == "max_print_height") {
update_scheduled = true;