#5080 - Reworked logic for automatic selection of current view type in preview
This commit is contained in:
parent
4870656877
commit
26982b16c7
4 changed files with 56 additions and 1 deletions
|
@ -88,7 +88,8 @@
|
|||
//===================
|
||||
#define ENABLE_2_3_0_BETA2 1
|
||||
|
||||
#define ENABLE_ARROW_KEYS_WITH_SLIDERS (1 && ENABLE_2_3_0_BETA2)
|
||||
#define ENABLE_ARROW_KEYS_WITH_SLIDERS (1 && ENABLE_2_3_0_BETA2)
|
||||
#define ENABLE_PREVIEW_TYPE_CHANGE (1 && ENABLE_2_3_0_BETA2)
|
||||
|
||||
|
||||
#endif // _prusaslicer_technologies_h_
|
||||
|
|
|
@ -172,7 +172,9 @@ 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))
|
||||
|
@ -318,6 +320,7 @@ 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) {
|
||||
|
@ -331,6 +334,7 @@ void Preview::set_number_extruders(unsigned int number_extruders)
|
|||
m_preferred_color_mode = (type == tool_idx) ? "tool_or_feature" : "feature";
|
||||
}
|
||||
}
|
||||
#endif // !ENABLE_PREVIEW_TYPE_CHANGE
|
||||
|
||||
void Preview::bed_shape_changed()
|
||||
{
|
||||
|
@ -465,10 +469,19 @@ 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();
|
||||
}
|
||||
|
@ -505,6 +518,7 @@ void Preview::on_combochecklist_options(wxCommandEvent& evt)
|
|||
m_canvas->set_as_dirty();
|
||||
}
|
||||
|
||||
#if !ENABLE_PREVIEW_TYPE_CHANGE
|
||||
void Preview::update_view_type(bool keep_volumes)
|
||||
{
|
||||
const DynamicPrintConfig& config = wxGetApp().preset_bundle->project_config;
|
||||
|
@ -526,6 +540,7 @@ void Preview::update_view_type(bool keep_volumes)
|
|||
|
||||
reload_print(keep_volumes);
|
||||
}
|
||||
#endif // !ENABLE_PREVIEW_TYPE_CHANGE
|
||||
|
||||
void Preview::update_bottom_toolbar()
|
||||
{
|
||||
|
@ -582,7 +597,12 @@ 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;
|
||||
|
@ -848,6 +868,7 @@ 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.
|
||||
|
@ -860,6 +881,7 @@ void Preview::load_print_as_fff(bool keep_z_range)
|
|||
// 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();
|
||||
|
@ -908,6 +930,24 @@ void Preview::load_print_as_fff(bool keep_z_range)
|
|||
} else
|
||||
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) {
|
||||
const wxString choice = !wxGetApp().plater()->model().custom_gcode_per_print_z.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));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_PREVIEW_TYPE_CHANGE
|
||||
}
|
||||
|
||||
void Preview::load_print_as_sla()
|
||||
|
|
|
@ -102,7 +102,11 @@ 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 };
|
||||
|
||||
|
@ -136,7 +140,9 @@ 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);
|
||||
|
@ -150,7 +156,9 @@ 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; }
|
||||
|
||||
|
|
|
@ -5529,8 +5529,12 @@ 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)
|
||||
|
@ -5769,7 +5773,9 @@ 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;
|
||||
|
|
Loading…
Reference in a new issue