FIX: enhance filament_map auto manual behavior
1. auto mode dragdrop is not allowed 2. not display filament_map when there is no result in auto mode jira:none Change-Id: I0800e0d832e27fe459a17bb1aa829b5e72d0ee8f
This commit is contained in:
parent
7df6f6c986
commit
9ee85bef34
|
@ -2342,6 +2342,7 @@ void Print::update_filament_maps_to_config(std::vector<int> f_maps)
|
|||
t_config_option_keys keys(filament_options_with_variant.begin(), filament_options_with_variant.end());
|
||||
m_config.apply_only(m_full_print_config, keys, true);
|
||||
}
|
||||
m_has_auto_filament_map_result = true;
|
||||
}
|
||||
|
||||
std::vector<int> Print::get_filament_maps() const
|
||||
|
|
|
@ -868,6 +868,10 @@ public:
|
|||
void set_calib_params(const Calib_Params ¶ms);
|
||||
const Calib_Params& calib_params() const { return m_calib_params; }
|
||||
Vec2d translate_to_print_space(const Vec2d& point) const;
|
||||
|
||||
bool has_auto_filament_map_result() const { return m_has_auto_filament_map_result; }
|
||||
void set_auto_filament_map_result(bool has_result) { m_has_auto_filament_map_result = has_result; }
|
||||
|
||||
// scaled point
|
||||
Vec2d translate_to_print_space(const Point& point) const;
|
||||
static FilamentTempType get_filament_temp_type(const std::string& filament_type);
|
||||
|
@ -940,6 +944,7 @@ private:
|
|||
//BBS
|
||||
ConflictResultOpt m_conflict_result;
|
||||
FakeWipeTower m_fake_wipe_tower;
|
||||
bool m_has_auto_filament_map_result{false};
|
||||
|
||||
// OrcaSlicer: calibration
|
||||
Calib_Params m_calib_params;
|
||||
|
|
|
@ -228,6 +228,7 @@ void BackgroundSlicingProcess::process_fff()
|
|||
if (m_current_plate->get_filament_map_mode() == FilamentMapMode::fmmAuto) {
|
||||
std::vector<int> f_maps = m_fff_print->get_filament_maps();
|
||||
m_current_plate->set_filament_maps(f_maps);
|
||||
m_current_plate->set_auto_filament_map_result(m_fff_print->has_auto_filament_map_result());
|
||||
}
|
||||
wxCommandEvent evt(m_event_slicing_completed_id);
|
||||
// Post the Slicing Finished message for the G-code viewer to update.
|
||||
|
|
|
@ -171,8 +171,9 @@ wxDragResult ColorDropTarget::OnData(wxCoord x, wxCoord y, wxDragResult def)
|
|||
/////////////// ColorDropTarget end ////////////////////////
|
||||
|
||||
|
||||
DragDropPanel::DragDropPanel(wxWindow *parent, const wxString &label)
|
||||
DragDropPanel::DragDropPanel(wxWindow *parent, const wxString &label, bool is_auto)
|
||||
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE)
|
||||
, m_is_auto(is_auto)
|
||||
{
|
||||
SetBackgroundColour(*wxLIGHT_GREY);
|
||||
|
||||
|
@ -209,6 +210,9 @@ void DragDropPanel::RemoveColorBlock(ColorPanel *panel)
|
|||
|
||||
void DragDropPanel::DoDragDrop(ColorPanel *panel, const wxColour &color, int filament_id)
|
||||
{
|
||||
if (m_is_auto)
|
||||
return;
|
||||
|
||||
ColorDropSource source(this, panel, color, filament_id);
|
||||
source.DoDragDrop(wxDrag_CopyOnly);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class ColorPanel;
|
|||
class DragDropPanel : public wxPanel
|
||||
{
|
||||
public:
|
||||
DragDropPanel(wxWindow *parent, const wxString &label);
|
||||
DragDropPanel(wxWindow *parent, const wxString &label, bool is_auto);
|
||||
|
||||
void AddColorBlock(const wxColour &color, int filament_id);
|
||||
void RemoveColorBlock(ColorPanel *panel);
|
||||
|
@ -30,6 +30,7 @@ public:
|
|||
private:
|
||||
wxBoxSizer *m_sizer;
|
||||
wxGridSizer *m_grid_item_sizer;
|
||||
bool m_is_auto;
|
||||
|
||||
private:
|
||||
bool m_is_draging = false;
|
||||
|
|
|
@ -45,16 +45,21 @@ FilamentMapDialog::FilamentMapDialog(wxWindow *parent,
|
|||
const DynamicPrintConfig *config,
|
||||
const std::vector<int> &filament_map,
|
||||
const std::vector<int> &extruders,
|
||||
bool is_auto)
|
||||
bool is_auto,
|
||||
bool has_auto_result
|
||||
)
|
||||
: wxDialog(parent, wxID_ANY, _L("Filament arrangement method of plate"), wxDefaultPosition, wxSize(2000, 1500))
|
||||
, m_config(config)
|
||||
, m_filament_map(filament_map)
|
||||
, m_has_auto_result(has_auto_result)
|
||||
{
|
||||
wxBoxSizer *main_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
wxStaticBoxSizer *mode_sizer = new wxStaticBoxSizer(wxHORIZONTAL, this, _L("Mode"));
|
||||
m_auto_radio = new wxRadioButton(this, wxID_ANY, _L("Auto"));
|
||||
m_manual_radio = new wxRadioButton(this, wxID_ANY, _L("Customize"));
|
||||
m_auto_radio->Bind(wxEVT_RADIOBUTTON, &FilamentMapDialog::on_auto_radio, this);
|
||||
m_manual_radio->Bind(wxEVT_RADIOBUTTON, &FilamentMapDialog::on_manual_radio, this);
|
||||
|
||||
if (is_auto)
|
||||
m_auto_radio->SetValue(true);
|
||||
|
@ -68,10 +73,10 @@ FilamentMapDialog::FilamentMapDialog(wxWindow *parent,
|
|||
wxStaticText *tip_text = new wxStaticText(this, wxID_ANY, _L("You could arrange your filament like this, this is the best solution we calculated"));
|
||||
main_sizer->Add(tip_text, 0, wxALIGN_CENTER | wxALL, 5);
|
||||
|
||||
wxBoxSizer *panel_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
m_extruder_panel_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
m_left_panel = new DragDropPanel(this, wxT("Left nozzle:"));
|
||||
m_right_panel = new DragDropPanel(this, wxT("Right nozzle:"));
|
||||
m_manual_left_panel = new DragDropPanel(this, wxT("Left nozzle:"), false);
|
||||
m_manual_right_panel = new DragDropPanel(this, wxT("Right nozzle:"), false);
|
||||
|
||||
std::vector<std::string> filament_color = config->option<ConfigOptionStrings>("filament_colour")->values;
|
||||
for (size_t i = 0; i < filament_map.size(); ++i) {
|
||||
|
@ -80,23 +85,60 @@ FilamentMapDialog::FilamentMapDialog(wxWindow *parent,
|
|||
continue;
|
||||
|
||||
if (filament_map[i] == 1) {
|
||||
m_left_panel->AddColorBlock(hex_to_color(filament_color[i]), i + 1);
|
||||
m_manual_left_panel->AddColorBlock(hex_to_color(filament_color[i]), i + 1);
|
||||
}
|
||||
else if (filament_map[i] == 2) {
|
||||
m_right_panel->AddColorBlock(hex_to_color(filament_color[i]), i + 1);
|
||||
m_manual_right_panel->AddColorBlock(hex_to_color(filament_color[i]), i + 1);
|
||||
}
|
||||
else {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
panel_sizer->Add(m_left_panel, 1, wxEXPAND | wxALL, 5);
|
||||
panel_sizer->Add(m_right_panel, 1, wxEXPAND | wxALL, 5);
|
||||
m_left_panel->Layout();
|
||||
m_left_panel->Fit();
|
||||
m_right_panel->Layout();
|
||||
m_right_panel->Fit();
|
||||
main_sizer->Add(panel_sizer, 1, wxEXPAND | wxALL, 10);
|
||||
m_extruder_panel_sizer->Add(m_manual_left_panel, 1, wxEXPAND | wxALL, 5);
|
||||
m_extruder_panel_sizer->Add(m_manual_right_panel, 1, wxEXPAND | wxALL, 5);
|
||||
m_manual_left_panel->Layout();
|
||||
m_manual_left_panel->Fit();
|
||||
m_manual_right_panel->Layout();
|
||||
m_manual_right_panel->Fit();
|
||||
|
||||
m_auto_left_panel = new DragDropPanel(this, wxT("Left nozzle:"), true);
|
||||
m_auto_right_panel = new DragDropPanel(this, wxT("Right nozzle:"), true);
|
||||
|
||||
for (size_t i = 0; i < filament_map.size(); ++i) {
|
||||
auto iter = std::find(extruders.begin(), extruders.end(), i + 1);
|
||||
if (iter == extruders.end()) continue;
|
||||
|
||||
if (filament_map[i] == 1) {
|
||||
m_auto_left_panel->AddColorBlock(hex_to_color(filament_color[i]), i + 1);
|
||||
} else if (filament_map[i] == 2) {
|
||||
m_auto_right_panel->AddColorBlock(hex_to_color(filament_color[i]), i + 1);
|
||||
} else {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
m_extruder_panel_sizer->Add(m_auto_left_panel, 1, wxEXPAND | wxALL, 5);
|
||||
m_extruder_panel_sizer->Add(m_auto_right_panel, 1, wxEXPAND | wxALL, 5);
|
||||
m_auto_left_panel->Layout();
|
||||
m_auto_left_panel->Fit();
|
||||
m_auto_right_panel->Layout();
|
||||
m_auto_right_panel->Fit();
|
||||
|
||||
main_sizer->Add(m_extruder_panel_sizer, 1, wxEXPAND | wxALL, 10);
|
||||
|
||||
if (is_auto) {
|
||||
m_manual_left_panel->Hide();
|
||||
m_manual_right_panel->Hide();
|
||||
if (!m_has_auto_result) {
|
||||
m_auto_left_panel->Hide();
|
||||
m_auto_right_panel->Hide();
|
||||
}
|
||||
}
|
||||
else {
|
||||
m_auto_left_panel->Hide();
|
||||
m_auto_right_panel->Hide();
|
||||
}
|
||||
|
||||
wxBoxSizer *button_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
Button * ok_btn = new Button(this, _L("OK"));
|
||||
|
@ -125,17 +167,18 @@ bool FilamentMapDialog::is_auto() const
|
|||
|
||||
void FilamentMapDialog::on_ok(wxCommandEvent &event)
|
||||
{
|
||||
std::vector<int> left_filaments = m_left_panel->GetAllFilaments();
|
||||
std::vector<int> right_filaments = m_right_panel->GetAllFilaments();
|
||||
if (!is_auto()) {
|
||||
std::vector<int> left_filaments = m_manual_left_panel->GetAllFilaments();
|
||||
std::vector<int> right_filaments = m_manual_right_panel->GetAllFilaments();
|
||||
|
||||
for (int i = 0; i < m_filament_map.size(); ++i) {
|
||||
if (std::find(left_filaments.begin(), left_filaments.end(), i + 1) != left_filaments.end()) {
|
||||
m_filament_map[i] = 1;
|
||||
}
|
||||
else if (std::find(right_filaments.begin(), right_filaments.end(), i + 1) != right_filaments.end()) {
|
||||
} else if (std::find(right_filaments.begin(), right_filaments.end(), i + 1) != right_filaments.end()) {
|
||||
m_filament_map[i] = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EndModal(wxID_OK);
|
||||
}
|
||||
|
@ -145,4 +188,40 @@ void FilamentMapDialog::on_cancle(wxCommandEvent &event)
|
|||
EndModal(wxID_CANCEL);
|
||||
}
|
||||
|
||||
void FilamentMapDialog::on_auto_radio(wxCommandEvent& event)
|
||||
{
|
||||
if (!m_has_auto_result) {
|
||||
m_manual_left_panel->Hide();
|
||||
m_manual_right_panel->Hide();
|
||||
|
||||
m_auto_left_panel->Hide();
|
||||
m_auto_right_panel->Hide();
|
||||
|
||||
Layout();
|
||||
Fit();
|
||||
}
|
||||
else {
|
||||
m_auto_left_panel->Show();
|
||||
m_auto_right_panel->Show();
|
||||
|
||||
m_manual_left_panel->Hide();
|
||||
m_manual_right_panel->Hide();
|
||||
|
||||
Layout();
|
||||
Fit();
|
||||
}
|
||||
}
|
||||
|
||||
void FilamentMapDialog::on_manual_radio(wxCommandEvent& event)
|
||||
{
|
||||
m_manual_left_panel->Show();
|
||||
m_manual_right_panel->Show();
|
||||
|
||||
m_auto_left_panel->Hide();
|
||||
m_auto_right_panel->Hide();
|
||||
|
||||
Layout();
|
||||
Fit();
|
||||
}
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
|
|
@ -19,24 +19,32 @@ public:
|
|||
const DynamicPrintConfig *config,
|
||||
const std::vector<int> &filament_map,
|
||||
const std::vector<int> &extruders,
|
||||
bool is_auto);
|
||||
bool is_auto,
|
||||
bool has_auto_result
|
||||
);
|
||||
|
||||
bool is_auto() const;
|
||||
const std::vector<int>& get_filament_maps() { return m_filament_map; }
|
||||
const std::vector<int>& get_filament_maps() const { return m_filament_map; }
|
||||
|
||||
private:
|
||||
void on_ok(wxCommandEvent &event);
|
||||
void on_cancle(wxCommandEvent &event);
|
||||
void on_auto_radio(wxCommandEvent &event);
|
||||
void on_manual_radio(wxCommandEvent &event);
|
||||
|
||||
private:
|
||||
wxRadioButton* m_auto_radio;
|
||||
wxRadioButton* m_manual_radio;
|
||||
DragDropPanel* m_left_panel;
|
||||
DragDropPanel* m_right_panel;
|
||||
wxBoxSizer * m_extruder_panel_sizer;
|
||||
DragDropPanel* m_manual_left_panel;
|
||||
DragDropPanel* m_manual_right_panel;
|
||||
DragDropPanel* m_auto_left_panel;
|
||||
DragDropPanel* m_auto_right_panel;
|
||||
|
||||
private:
|
||||
const DynamicPrintConfig* m_config;
|
||||
std::vector<int> m_filament_map;
|
||||
bool m_has_auto_result;
|
||||
};
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
|
|
@ -2911,6 +2911,16 @@ void PartPlate::set_filament_map_mode(const FilamentMapMode& mode)
|
|||
m_config.option<ConfigOptionEnum<FilamentMapMode>>("filament_map_mode", true)->value = mode;
|
||||
}
|
||||
|
||||
bool PartPlate::has_auto_filament_map_reslut()
|
||||
{
|
||||
return m_has_auto_filament_map_result;
|
||||
}
|
||||
|
||||
void PartPlate::set_auto_filament_map_result(bool has_result)
|
||||
{
|
||||
m_has_auto_filament_map_result = has_result;
|
||||
}
|
||||
|
||||
std::vector<int> PartPlate::get_filament_maps()
|
||||
{
|
||||
std::vector<int>& filament_maps = m_config.option<ConfigOptionInts>("filament_map", true)->values;
|
||||
|
|
|
@ -104,6 +104,7 @@ private:
|
|||
bool m_slice_result_valid;
|
||||
bool m_apply_invalid {false};
|
||||
float m_slice_percent;
|
||||
bool m_has_auto_filament_map_result{false};
|
||||
|
||||
Print *m_print; //Print reference, not own it, no need to serialize
|
||||
GCodeProcessorResult *m_gcode_result;
|
||||
|
@ -479,6 +480,9 @@ public:
|
|||
FilamentMapMode get_filament_map_mode();
|
||||
void set_filament_map_mode(const FilamentMapMode& mode);
|
||||
|
||||
bool has_auto_filament_map_reslut();
|
||||
void set_auto_filament_map_result(bool has_result);
|
||||
|
||||
std::vector<int> get_filament_maps();
|
||||
void set_filament_maps(const std::vector<int>& f_maps);
|
||||
|
||||
|
|
|
@ -14344,11 +14344,17 @@ void Plater::open_platesettings_dialog(wxCommandEvent& evt) {
|
|||
void Plater::open_filament_map_setting_dialog(wxCommandEvent &evt)
|
||||
{
|
||||
PartPlate* curr_plate = p->partplate_list.get_curr_plate();
|
||||
FilamentMapDialog filament_dlg(this, config(), curr_plate->get_filament_maps(), curr_plate->get_extruders(true), curr_plate->get_filament_map_mode() == FilamentMapMode::fmmAuto);
|
||||
FilamentMapDialog filament_dlg(this, config(), curr_plate->get_filament_maps(), curr_plate->get_extruders(true),
|
||||
curr_plate->get_filament_map_mode() == FilamentMapMode::fmmAuto, curr_plate->has_auto_filament_map_reslut());
|
||||
if (filament_dlg.ShowModal() == wxID_OK) {
|
||||
std::vector<int> new_filament_maps = filament_dlg.get_filament_maps();
|
||||
std::vector<int> old_filament_maps = curr_plate->get_filament_maps();
|
||||
FilamentMapMode new_map_mode = filament_dlg.is_auto() ? FilamentMapMode::fmmAuto : FilamentMapMode::fmmManual;
|
||||
|
||||
if (new_map_mode == FilamentMapMode::fmmManual) {
|
||||
curr_plate->set_auto_filament_map_result(false);
|
||||
}
|
||||
|
||||
FilamentMapMode old_map_mode = curr_plate->get_filament_map_mode();
|
||||
bool need_invalidate = false;
|
||||
if (new_map_mode != old_map_mode) {
|
||||
|
|
Loading…
Reference in New Issue