Improved extruder_selector for DoubleSlider
This commit is contained in:
parent
4b0fe7cba4
commit
76ec1bc7e3
9 changed files with 88 additions and 49 deletions
|
@ -1692,15 +1692,27 @@ void GCode::process_layer(
|
||||||
}
|
}
|
||||||
|
|
||||||
// we should add or not colorprint_change in respect to nozzle_diameter count instead of really used extruders count
|
// we should add or not colorprint_change in respect to nozzle_diameter count instead of really used extruders count
|
||||||
if (colorprint_change && print./*extruders()*/config().nozzle_diameter.size()==1)
|
// #ys_FIXME_COLOR
|
||||||
{
|
// if (colorprint_change && print./*extruders()*/config().nozzle_diameter.size()==1)
|
||||||
// add tag for analyzer
|
// {
|
||||||
gcode += "; " + GCodeAnalyzer::Color_Change_Tag + "\n";
|
// // add tag for analyzer
|
||||||
// add tag for time estimator
|
// gcode += "; " + GCodeAnalyzer::Color_Change_Tag + "\n";
|
||||||
gcode += "; " + GCodeTimeEstimator::Color_Change_Tag + "\n";
|
// // add tag for time estimator
|
||||||
// #ys_FIXME_COLOR
|
// gcode += "; " + GCodeTimeEstimator::Color_Change_Tag + "\n";
|
||||||
// gcode += "M600\n";
|
//
|
||||||
gcode += custom_code + "\n";
|
// gcode += "M600\n";
|
||||||
|
// }
|
||||||
|
if (colorprint_change) {
|
||||||
|
if (print.config().nozzle_diameter.size() == 1)
|
||||||
|
{
|
||||||
|
// add tag for analyzer
|
||||||
|
gcode += "; " + GCodeAnalyzer::Color_Change_Tag + "\n";
|
||||||
|
// add tag for time estimator
|
||||||
|
gcode += "; " + GCodeTimeEstimator::Color_Change_Tag + "\n";
|
||||||
|
if (custom_code == "tool_change")
|
||||||
|
custom_code = "M600";
|
||||||
|
gcode += custom_code + "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -586,14 +586,15 @@ std::string Model::propose_export_file_name_and_path(const std::string &new_exte
|
||||||
return boost::filesystem::path(this->propose_export_file_name_and_path()).replace_extension(new_extension).string();
|
return boost::filesystem::path(this->propose_export_file_name_and_path()).replace_extension(new_extension).string();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<double, DynamicPrintConfig>> Model:: get_custom_tool_changes(double default_layer_height) const
|
std::vector<std::pair<double, DynamicPrintConfig>> Model::get_custom_tool_changes(double default_layer_height, size_t num_extruders) const
|
||||||
{
|
{
|
||||||
std::vector<std::pair<double, DynamicPrintConfig>> custom_tool_changes;
|
std::vector<std::pair<double, DynamicPrintConfig>> custom_tool_changes;
|
||||||
if (!custom_gcode_per_height.empty()) {
|
if (!custom_gcode_per_height.empty()) {
|
||||||
for (const CustomGCode& custom_gcode : custom_gcode_per_height)
|
for (const CustomGCode& custom_gcode : custom_gcode_per_height)
|
||||||
if (custom_gcode.gcode == "tool_change") {
|
if (custom_gcode.gcode == "tool_change") {
|
||||||
DynamicPrintConfig config;
|
DynamicPrintConfig config;
|
||||||
config.set_key_value("extruder", new ConfigOptionInt(custom_gcode.extruder));
|
// If extruder count in PrinterSettings was changed, use default (0) extruder for extruders, more than num_extruders
|
||||||
|
config.set_key_value("extruder", new ConfigOptionInt(custom_gcode.extruder > num_extruders ? 0 : custom_gcode.extruder));
|
||||||
// For correct extruders(tools) changing, we should decrease custom_gcode.height value by one default layer height
|
// For correct extruders(tools) changing, we should decrease custom_gcode.height value by one default layer height
|
||||||
custom_tool_changes.push_back({ custom_gcode.height - default_layer_height, config });
|
custom_tool_changes.push_back({ custom_gcode.height - default_layer_height, config });
|
||||||
}
|
}
|
||||||
|
|
|
@ -837,7 +837,7 @@ public:
|
||||||
std::string propose_export_file_name_and_path(const std::string &new_extension) const;
|
std::string propose_export_file_name_and_path(const std::string &new_extension) const;
|
||||||
|
|
||||||
// from custom_gcode_per_height get just tool_change codes
|
// from custom_gcode_per_height get just tool_change codes
|
||||||
std::vector<std::pair<double, DynamicPrintConfig>> get_custom_tool_changes(double default_layer_height) const;
|
std::vector<std::pair<double, DynamicPrintConfig>> get_custom_tool_changes(double default_layer_height, size_t num_extruders) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit Model(int) : ObjectBase(-1) { assert(this->id().invalid()); };
|
explicit Model(int) : ObjectBase(-1) { assert(this->id().invalid()); };
|
||||||
|
|
|
@ -834,7 +834,8 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
|
||||||
for (PrintObject *print_object : m_objects)
|
for (PrintObject *print_object : m_objects)
|
||||||
print_object_status.emplace(PrintObjectStatus(print_object));
|
print_object_status.emplace(PrintObjectStatus(print_object));
|
||||||
|
|
||||||
std::vector<std::pair<double, DynamicPrintConfig>> custom_tool_changes = m_model.get_custom_tool_changes(m_default_object_config.layer_height);
|
std::vector<std::pair<double, DynamicPrintConfig>> custom_tool_changes =
|
||||||
|
m_model.get_custom_tool_changes(m_default_object_config.layer_height, num_extruders);
|
||||||
|
|
||||||
// 3) Synchronize ModelObjects & PrintObjects.
|
// 3) Synchronize ModelObjects & PrintObjects.
|
||||||
for (size_t idx_model_object = 0; idx_model_object < model.objects.size(); ++ idx_model_object) {
|
for (size_t idx_model_object = 0; idx_model_object < model.objects.size(); ++ idx_model_object) {
|
||||||
|
|
|
@ -500,9 +500,19 @@ void Preview::reset_sliders()
|
||||||
void Preview::update_sliders(const std::vector<double>& layers_z, bool keep_z_range)
|
void Preview::update_sliders(const std::vector<double>& layers_z, bool keep_z_range)
|
||||||
{
|
{
|
||||||
m_enabled = true;
|
m_enabled = true;
|
||||||
|
// update extruder selector
|
||||||
|
if (wxGetApp().extruders_edited_cnt() != m_extruder_selector->GetCount()-1)
|
||||||
|
{
|
||||||
|
int selection = m_extruder_selector->GetSelection();
|
||||||
|
update_extruder_selector();
|
||||||
|
if (selection >= m_extruder_selector->GetCount())
|
||||||
|
selection = 0;
|
||||||
|
m_extruder_selector->SetSelection(selection);
|
||||||
|
}
|
||||||
|
|
||||||
update_double_slider(layers_z, keep_z_range);
|
update_double_slider(layers_z, keep_z_range);
|
||||||
m_double_slider_sizer->Show((size_t)0);
|
m_double_slider_sizer->Show((size_t)0);
|
||||||
if (m_slider->GetManipulationState() != DoubleSlider::msMultiExtruder)
|
if (m_slider->GetManipulationState() == DoubleSlider::msSingleExtruder)
|
||||||
m_double_slider_sizer->GetItem(size_t(0))->GetSizer()->Hide((size_t)0);
|
m_double_slider_sizer->GetItem(size_t(0))->GetSizer()->Hide((size_t)0);
|
||||||
Layout();
|
Layout();
|
||||||
}
|
}
|
||||||
|
@ -560,7 +570,7 @@ void Preview::on_checkbox_legend(wxCommandEvent& evt)
|
||||||
m_canvas_widget->Refresh();
|
m_canvas_widget->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preview::update_view_type()
|
void Preview::update_view_type(bool slice_completed)
|
||||||
{
|
{
|
||||||
const DynamicPrintConfig& config = wxGetApp().preset_bundle->project_config;
|
const DynamicPrintConfig& config = wxGetApp().preset_bundle->project_config;
|
||||||
|
|
||||||
|
@ -574,8 +584,8 @@ void Preview::update_view_type()
|
||||||
_(L("Feature type"));
|
_(L("Feature type"));
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const wxString& choice = !wxGetApp().plater()->model().custom_gcode_per_height.empty()// &&
|
const wxString& choice = !wxGetApp().plater()->model().custom_gcode_per_height.empty() &&
|
||||||
/*wxGetApp().extruders_edited_cnt()==1*/ ?
|
(wxGetApp().extruders_edited_cnt()==1 || !slice_completed) ?
|
||||||
_(L("Color Print")) :
|
_(L("Color Print")) :
|
||||||
config.option<ConfigOptionFloats>("wiping_volumes_matrix")->values.size() > 1 ?
|
config.option<ConfigOptionFloats>("wiping_volumes_matrix")->values.size() > 1 ?
|
||||||
_(L("Tool")) :
|
_(L("Tool")) :
|
||||||
|
@ -590,25 +600,39 @@ void Preview::update_view_type()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Preview::update_extruder_selector()
|
||||||
|
{
|
||||||
|
m_extruder_selector->Clear();
|
||||||
|
|
||||||
|
m_extruder_selector->Append("Whole print");
|
||||||
|
const int extruder_cnt = wxGetApp().extruders_edited_cnt();
|
||||||
|
int i = 0;
|
||||||
|
while (i < extruder_cnt)
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
m_extruder_selector->Append(wxString::Format("Extruder %d", i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Preview::create_double_slider()
|
void Preview::create_double_slider()
|
||||||
{
|
{
|
||||||
m_slider = new DoubleSlider(this, wxID_ANY, 0, 0, 0, 100);
|
m_slider = new DoubleSlider(this, wxID_ANY, 0, 0, 0, 100);
|
||||||
// #ys_FIXME_COLOR
|
// #ys_FIXME_COLOR
|
||||||
// m_double_slider_sizer->Add(m_slider, 0, wxEXPAND, 0);
|
// m_double_slider_sizer->Add(m_slider, 0, wxEXPAND, 0);
|
||||||
|
|
||||||
auto extruder_selector = new wxComboBox(this, wxID_ANY);
|
m_extruder_selector = new wxComboBox(this, wxID_ANY);
|
||||||
extruder_selector->Append("Whole print");
|
update_extruder_selector();
|
||||||
int extruder_cnt = wxGetApp().extruders_edited_cnt();
|
m_extruder_selector->SetSelection(0);
|
||||||
int i = 0;
|
m_extruder_selector->Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& evt)
|
||||||
while (i < extruder_cnt)
|
|
||||||
{
|
{
|
||||||
i++;
|
m_slider->SetManipulationState(m_extruder_selector->GetSelection() == 0 ?
|
||||||
extruder_selector->Append(wxString::Format("Extruder %d", i));
|
DoubleSlider::msMultiExtruderWholePrint :
|
||||||
}
|
DoubleSlider::msMultiExtruder);
|
||||||
extruder_selector->SetSelection(0);
|
});
|
||||||
|
m_extruder_selector->Disable(); // temporary disabled to suppress extruder selection
|
||||||
|
|
||||||
auto sizer = new wxBoxSizer(wxVERTICAL);
|
auto sizer = new wxBoxSizer(wxVERTICAL);
|
||||||
sizer->Add(extruder_selector, 0, wxEXPAND, 0);
|
sizer->Add(m_extruder_selector, 0, wxEXPAND, 0);
|
||||||
sizer->Add(m_slider, 1, wxEXPAND, 0);
|
sizer->Add(m_slider, 1, wxEXPAND, 0);
|
||||||
|
|
||||||
m_double_slider_sizer->Add(sizer, 0, wxEXPAND, 0);
|
m_double_slider_sizer->Add(sizer, 0, wxEXPAND, 0);
|
||||||
|
@ -627,7 +651,7 @@ void Preview::create_double_slider()
|
||||||
model.custom_gcode_per_height = m_slider->GetTicksValues_();
|
model.custom_gcode_per_height = m_slider->GetTicksValues_();
|
||||||
m_schedule_background_process();
|
m_schedule_background_process();
|
||||||
|
|
||||||
update_view_type();
|
update_view_type(false);
|
||||||
|
|
||||||
reload_print();
|
reload_print();
|
||||||
});
|
});
|
||||||
|
@ -733,16 +757,14 @@ void Preview::update_double_slider(const std::vector<double>& layers_z, bool kee
|
||||||
// m_slider->EnableTickManipulation(color_print_enable);
|
// m_slider->EnableTickManipulation(color_print_enable);
|
||||||
|
|
||||||
m_slider->EnableTickManipulation(color_print_enable);
|
m_slider->EnableTickManipulation(color_print_enable);
|
||||||
m_slider->SetManipulationState(DoubleSlider::msSingleExtruder);
|
if (color_print_enable && wxGetApp().extruders_edited_cnt() > 1) {
|
||||||
if (color_print_enable) {
|
//bool is_detected_full_print = //wxGetApp().plater()->fff_print().extruders().size() == 1;
|
||||||
const DynamicPrintConfig& cfg = wxGetApp().preset_bundle->printers.get_edited_preset().config;
|
m_slider->SetManipulationState(m_extruder_selector->GetSelection()==0 ?
|
||||||
if (cfg.opt<ConfigOptionFloats>("nozzle_diameter")->values.size() > 1) {
|
DoubleSlider::msMultiExtruderWholePrint : DoubleSlider::msMultiExtruder);
|
||||||
// ys_TODO : fill is_detected_one_extruder_print value
|
|
||||||
bool is_detected_one_extruder_print = wxGetApp().plater()->fff_print().extruders().size() == 1;
|
|
||||||
m_slider->SetManipulationState(is_detected_one_extruder_print ?
|
|
||||||
DoubleSlider::msMultiExtruderSimple : DoubleSlider::msMultiExtruder);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
m_slider->SetManipulationState(DoubleSlider::msSingleExtruder);
|
||||||
|
|
||||||
}
|
}
|
||||||
// #ys_FIXME_COLOR
|
// #ys_FIXME_COLOR
|
||||||
void Preview::check_slider_values(std::vector<double>& ticks_from_config,
|
void Preview::check_slider_values(std::vector<double>& ticks_from_config,
|
||||||
|
|
|
@ -103,6 +103,7 @@ class Preview : public wxPanel
|
||||||
bool m_enabled;
|
bool m_enabled;
|
||||||
|
|
||||||
DoubleSlider* m_slider {nullptr};
|
DoubleSlider* m_slider {nullptr};
|
||||||
|
wxComboBox* m_extruder_selector {nullptr};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Preview(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model, DynamicPrintConfig* config,
|
Preview(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model, DynamicPrintConfig* config,
|
||||||
|
@ -129,7 +130,8 @@ public:
|
||||||
void move_double_slider(wxKeyEvent& evt);
|
void move_double_slider(wxKeyEvent& evt);
|
||||||
void edit_double_slider(wxKeyEvent& evt);
|
void edit_double_slider(wxKeyEvent& evt);
|
||||||
|
|
||||||
void update_view_type();
|
void update_view_type(bool slice_completed);
|
||||||
|
void update_extruder_selector();
|
||||||
|
|
||||||
bool is_loaded() const { return m_loaded; }
|
bool is_loaded() const { return m_loaded; }
|
||||||
|
|
||||||
|
|
|
@ -4702,7 +4702,7 @@ void Plater::reslice()
|
||||||
p->show_action_buttons(true);
|
p->show_action_buttons(true);
|
||||||
|
|
||||||
// update type of preview
|
// update type of preview
|
||||||
p->preview->update_view_type();
|
p->preview->update_view_type(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plater::reslice_SLA_supports(const ModelObject &object, bool postpone_error_messages)
|
void Plater::reslice_SLA_supports(const ModelObject &object, bool postpone_error_messages)
|
||||||
|
|
|
@ -3056,8 +3056,8 @@ wxString DoubleSlider::get_tooltip(bool is_revert_icon_focused)
|
||||||
tooltip = tick_code_it == m_ticks_.end() ? _(L("Add color change")) :
|
tooltip = tick_code_it == m_ticks_.end() ? _(L("Add color change")) :
|
||||||
tick_code_it->gcode == "M600" ? _(L("Delete color change")) :
|
tick_code_it->gcode == "M600" ? _(L("Delete color change")) :
|
||||||
tick_code_it->gcode == "M25" ? _(L("Delete pause")) :
|
tick_code_it->gcode == "M25" ? _(L("Delete pause")) :
|
||||||
tick_code_it->gcode == "tool_change" ?
|
tick_code_it->gcode == "tool_change" ? ( m_state == msSingleExtruder ? _(L("Delete color change")) :
|
||||||
from_u8((boost::format(_utf8(L("Delete extruder change to \"%1%\""))) % tick_code_it->extruder).str()) :
|
from_u8((boost::format(_utf8(L("Delete extruder change to \"%1%\""))) % tick_code_it->extruder).str()) ) :
|
||||||
from_u8((boost::format(_utf8(L("Delete \"%1%\" code"))) % tick_code_it->gcode).str());
|
from_u8((boost::format(_utf8(L("Delete \"%1%\" code"))) % tick_code_it->gcode).str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3329,7 +3329,7 @@ void DoubleSlider::OnRightUp(wxMouseEvent& event)
|
||||||
if (m_show_context_menu) {
|
if (m_show_context_menu) {
|
||||||
wxMenu menu;
|
wxMenu menu;
|
||||||
|
|
||||||
if (m_state == msMultiExtruderSimple)
|
if (m_state == msMultiExtruderWholePrint)
|
||||||
{
|
{
|
||||||
const wxString name = _(L("Change extruder"));
|
const wxString name = _(L("Change extruder"));
|
||||||
|
|
||||||
|
@ -3349,9 +3349,8 @@ void DoubleSlider::OnRightUp(wxMouseEvent& event)
|
||||||
menu.AppendSubMenu(change_extruder_menu, name, _(L("Use another extruder")));
|
menu.AppendSubMenu(change_extruder_menu, name, _(L("Use another extruder")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (m_state != msMultiExtruderSimple)
|
append_menu_item(&menu, wxID_ANY, _(L("Add color change")) + " (M600)", "",
|
||||||
append_menu_item(&menu, wxID_ANY, _(L("Add color change")) + " (M600)", "",
|
|
||||||
[this](wxCommandEvent&) { add_code("M600"); }, "colorchange_add_off.png", &menu);
|
[this](wxCommandEvent&) { add_code("M600"); }, "colorchange_add_off.png", &menu);
|
||||||
|
|
||||||
append_menu_item(&menu, wxID_ANY, _(L("Add pause SD print")) + " (M25)", "",
|
append_menu_item(&menu, wxID_ANY, _(L("Add pause SD print")) + " (M25)", "",
|
||||||
|
@ -3382,16 +3381,17 @@ void DoubleSlider::add_code(std::string code)
|
||||||
wxString msg_header = from_u8((boost::format(_utf8(L("Custom Gcode on current layer (%1% mm)."))) % m_values[tick]).str());
|
wxString msg_header = from_u8((boost::format(_utf8(L("Custom Gcode on current layer (%1% mm)."))) % m_values[tick]).str());
|
||||||
|
|
||||||
// get custom gcode
|
// get custom gcode
|
||||||
wxTextEntryDialog dlg(nullptr, msg_text, msg_header, wxEmptyString,
|
wxTextEntryDialog dlg(nullptr, msg_text, msg_header, m_custom_gcode,
|
||||||
wxTextEntryDialogStyle | wxTE_MULTILINE);
|
wxTextEntryDialogStyle | wxTE_MULTILINE);
|
||||||
if (dlg.ShowModal() != wxID_OK || dlg.GetValue().IsEmpty())
|
if (dlg.ShowModal() != wxID_OK || dlg.GetValue().IsEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
code = dlg.GetValue().c_str();
|
m_custom_gcode = dlg.GetValue();
|
||||||
|
code = m_custom_gcode.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
int extruder = 0;
|
int extruder = 0;
|
||||||
if (m_state == msMultiExtruderSimple)
|
if (m_state == msMultiExtruderWholePrint)
|
||||||
extruder = get_extruder_for_tick(m_selection == ssLower ? m_lower_value : m_higher_value);
|
extruder = get_extruder_for_tick(m_selection == ssLower ? m_lower_value : m_higher_value);
|
||||||
|
|
||||||
m_ticks_.insert(TICK_CODE(tick, code, extruder));
|
m_ticks_.insert(TICK_CODE(tick, code, extruder));
|
||||||
|
|
|
@ -809,7 +809,7 @@ public:
|
||||||
static enum ManipulationState {
|
static enum ManipulationState {
|
||||||
msSingleExtruder, // single extruder printer preset is selected
|
msSingleExtruder, // single extruder printer preset is selected
|
||||||
msMultiExtruder, // multiple extruder printer preset is selected
|
msMultiExtruder, // multiple extruder printer preset is selected
|
||||||
msMultiExtruderSimple // multiple extruder printer preset is selected, but one-extruder print is detected
|
msMultiExtruderWholePrint // multiple extruder printer preset is selected, and "Whole print" is selected
|
||||||
};
|
};
|
||||||
void SetManipulationState(ManipulationState state) {
|
void SetManipulationState(ManipulationState state) {
|
||||||
m_state = state;
|
m_state = state;
|
||||||
|
@ -903,6 +903,7 @@ private:
|
||||||
bool m_is_enabled_tick_manipulation = true;
|
bool m_is_enabled_tick_manipulation = true;
|
||||||
bool m_show_context_menu = false;
|
bool m_show_context_menu = false;
|
||||||
ManipulationState m_state = msSingleExtruder;
|
ManipulationState m_state = msSingleExtruder;
|
||||||
|
wxString m_custom_gcode = wxEmptyString;
|
||||||
|
|
||||||
wxRect m_rect_lower_thumb;
|
wxRect m_rect_lower_thumb;
|
||||||
wxRect m_rect_higher_thumb;
|
wxRect m_rect_higher_thumb;
|
||||||
|
|
Loading…
Add table
Reference in a new issue