DoubleSlider modes(states) are extended and implemented mode detection from model
+ Some code refactoring
This commit is contained in:
parent
07c1c3d1dc
commit
fb65e3152f
5 changed files with 82 additions and 43 deletions
|
@ -692,7 +692,11 @@ void Preview::update_double_slider(const std::vector<double>& layers_z, bool kee
|
|||
bool color_print_enable = (wxGetApp().plater()->printer_technology() == ptFFF);
|
||||
|
||||
m_slider->EnableTickManipulation(color_print_enable);
|
||||
m_slider->SetManipulationState(wxGetApp().extruders_edited_cnt());
|
||||
|
||||
// Detect and set manipulation mode for double slider
|
||||
m_slider->SetManipulationState( wxGetApp().extruders_edited_cnt() == 1 ? DoubleSlider::msSingleExtruder :
|
||||
wxGetApp().plater()->is_one_extruder_printed_model() ? DoubleSlider::msMultiAsSingle :
|
||||
DoubleSlider::msMultiExtruder);
|
||||
}
|
||||
|
||||
void Preview::reset_double_slider()
|
||||
|
|
|
@ -5358,6 +5358,38 @@ bool Plater::is_export_gcode_scheduled() const
|
|||
return p->background_process.is_export_scheduled();
|
||||
}
|
||||
|
||||
bool Plater::is_one_extruder_printed_model()
|
||||
{
|
||||
if (wxGetApp().extruders_edited_cnt() == 1)
|
||||
return true;
|
||||
|
||||
// check if model use just one extruder
|
||||
const ModelObjectPtrs& objects = p->model.objects;
|
||||
if (!objects.empty())
|
||||
{
|
||||
const size_t extruder = objects[0]->config.has("extruder") ?
|
||||
objects[0]->config.option("extruder")->getInt() : 0;
|
||||
for (ModelObject* object : objects)
|
||||
{
|
||||
if (object->config.has("extruder") &&
|
||||
object->config.option("extruder")->getInt() != extruder)
|
||||
return false;
|
||||
|
||||
for (ModelVolume* volume : object->volumes)
|
||||
if (volume->config.has("extruder") &&
|
||||
volume->config.option("extruder")->getInt() != extruder)
|
||||
return false;
|
||||
|
||||
for (const auto& range : object->layer_config_ranges)
|
||||
if (range.second.has("extruder") &&
|
||||
range.second.option("extruder")->getInt() != extruder)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int Plater::get_selected_object_idx()
|
||||
{
|
||||
return p->get_selected_object_idx();
|
||||
|
|
|
@ -234,6 +234,7 @@ public:
|
|||
void set_project_filename(const wxString& filename);
|
||||
|
||||
bool is_export_gcode_scheduled() const;
|
||||
bool is_one_extruder_printed_model();
|
||||
|
||||
int get_selected_object_idx();
|
||||
bool is_single_full_object_selection() const;
|
||||
|
|
|
@ -2861,13 +2861,13 @@ void DoubleSlider::draw_colored_band(wxDC& dc)
|
|||
|
||||
const wxColour bg_clr = GetParent()->GetBackgroundColour();
|
||||
|
||||
wxColour clr = m_state == msSingleExtruder ? wxColour(colors[0]) : bg_clr;
|
||||
wxColour clr = m_ticks_.empty() ? bg_clr : wxColour(colors[0]);
|
||||
draw_band(dc, clr, main_band);
|
||||
|
||||
size_t i = 1;
|
||||
for (auto tick : m_ticks_)
|
||||
{
|
||||
if ( (m_state == msSingleExtruder && tick.gcode != Slic3r::ColorChangeCode) ||
|
||||
if ( (m_state != msMultiExtruder/*m_state == msSingleExtruder*/ && tick.gcode != Slic3r::ColorChangeCode) ||
|
||||
(m_state == msMultiExtruder && tick.gcode != Slic3r::ExtruderChangeCode) )
|
||||
continue;
|
||||
|
||||
|
@ -3182,31 +3182,50 @@ void DoubleSlider::OnLeftUp(wxMouseEvent& event)
|
|||
|
||||
if (m_show_context_menu)
|
||||
{
|
||||
if (m_state == msMultiExtruder)
|
||||
if (m_state == msSingleExtruder)
|
||||
add_code(Slic3r::ColorChangeCode);
|
||||
else
|
||||
{
|
||||
wxMenu menu;
|
||||
const int extruders_cnt = Slic3r::GUI::wxGetApp().extruders_edited_cnt();
|
||||
if (extruders_cnt > 1)
|
||||
{
|
||||
const int initial_extruder = get_extruder_for_tick(m_selection == ssLower ? m_lower_value : m_higher_value);
|
||||
{
|
||||
wxMenu menu;
|
||||
wxMenu* sub_menu = new wxMenu();
|
||||
wxString sub_menu_name = _(L("Change extruder"));
|
||||
std::string menu_icon_name = "change_extruder";
|
||||
|
||||
wxMenu* change_extruder_menu = new wxMenu();
|
||||
if (m_state == msMultiAsSingle)
|
||||
{
|
||||
int initial_extruder = get_extruder_for_tick(m_selection == ssLower ? m_lower_value : m_higher_value);
|
||||
if (initial_extruder == 0)
|
||||
initial_extruder = 1;
|
||||
|
||||
for (int i = 0; i <= extruders_cnt; i++) {
|
||||
const wxString item_name = i == 0 ? _(L("Default")) : wxString::Format(_(L("Extruder %d")), i);
|
||||
for (int i = /*0*/1; i <= extruders_cnt; i++) {
|
||||
const wxString item_name = i == 0 ? _(L("Default")) : wxString::Format(_(L("Extruder %d")), i);
|
||||
|
||||
append_menu_radio_item(change_extruder_menu, wxID_ANY, item_name, "",
|
||||
[this, i](wxCommandEvent&) { change_extruder(i); }, &menu)->Check(i == initial_extruder);
|
||||
append_menu_radio_item(sub_menu, wxID_ANY, item_name, "",
|
||||
[this, i](wxCommandEvent&) { change_extruder(i); }, &menu)->Check(i == initial_extruder);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 1; i <= extruders_cnt; i++) {
|
||||
const wxString item_name = wxString::Format(_(L("Extruder %d")), i);
|
||||
|
||||
append_menu_item(sub_menu, wxID_ANY, item_name, "",
|
||||
[this, i](wxCommandEvent&) { add_code(Slic3r::ColorChangeCode, i); }, "", &menu);
|
||||
}
|
||||
|
||||
sub_menu_name = from_u8((boost::format(_utf8(L("Add color change (%1%) for:"))) % Slic3r::ColorChangeCode).str());
|
||||
menu_icon_name = "colorchange_add_m";
|
||||
}
|
||||
|
||||
wxMenuItem* change_extruder_menu_item = menu.AppendSubMenu(change_extruder_menu, _(L("Change extruder")), _(L("Use another extruder")));
|
||||
change_extruder_menu_item->SetBitmap(create_scaled_bitmap(nullptr, "change_extruder"));
|
||||
}
|
||||
wxMenuItem* sub_menu_item = menu.AppendSubMenu(sub_menu, sub_menu_name, "");
|
||||
sub_menu_item->SetBitmap(create_scaled_bitmap(this, menu_icon_name));
|
||||
|
||||
Slic3r::GUI::wxGetApp().plater()->PopupMenu(&menu);
|
||||
Slic3r::GUI::wxGetApp().plater()->PopupMenu(&menu);
|
||||
}
|
||||
}
|
||||
else
|
||||
add_code(Slic3r::ColorChangeCode);
|
||||
|
||||
m_show_context_menu = false;
|
||||
}
|
||||
|
|
|
@ -823,7 +823,10 @@ public:
|
|||
|
||||
enum ManipulationState {
|
||||
msSingleExtruder, // single extruder printer preset is selected
|
||||
msMultiExtruder // multiple extruder printer preset is selected, and "Whole print" is selected
|
||||
msMultiAsSingle, // multiple extruder printer preset is selected, but
|
||||
// this mode works just for Single extruder print
|
||||
// (For all print from objects settings is used just one extruder)
|
||||
msMultiExtruder // multiple extruder printer preset is selected
|
||||
};
|
||||
void SetManipulationState(ManipulationState state) {
|
||||
m_state = state;
|
||||
|
@ -976,31 +979,11 @@ private:
|
|||
public:
|
||||
struct ExtrudersSequence
|
||||
{
|
||||
bool is_mm_intervals;
|
||||
double interval_by_mm;
|
||||
int interval_by_layers;
|
||||
std::vector<size_t> extruders;
|
||||
bool is_mm_intervals = true;
|
||||
double interval_by_mm = 3.0;
|
||||
int interval_by_layers = 10;
|
||||
std::vector<size_t> extruders = { 0 };
|
||||
|
||||
ExtrudersSequence() :
|
||||
is_mm_intervals(true),
|
||||
interval_by_mm(3.0),
|
||||
interval_by_layers(10),
|
||||
extruders({ 0 }) {}
|
||||
|
||||
ExtrudersSequence(const ExtrudersSequence& other) :
|
||||
is_mm_intervals(other.is_mm_intervals),
|
||||
interval_by_mm(other.interval_by_mm),
|
||||
interval_by_layers(other.interval_by_layers),
|
||||
extruders(other.extruders) {}
|
||||
|
||||
ExtrudersSequence& operator=(const ExtrudersSequence& other) {
|
||||
this->is_mm_intervals = other.is_mm_intervals;
|
||||
this->interval_by_mm = other.interval_by_mm;
|
||||
this->interval_by_layers= other.interval_by_layers;
|
||||
this->extruders = other.extruders;
|
||||
|
||||
return *this;
|
||||
}
|
||||
bool operator==(const ExtrudersSequence& other) const
|
||||
{
|
||||
return (other.is_mm_intervals == this->is_mm_intervals ) &&
|
||||
|
|
Loading…
Reference in a new issue