NEW: Add FilamentMapDialog

support drag drop to modify the filament map
jira: none

Change-Id: I0ed3180a0fa8e95e7c871bb039eb844faccd1344
This commit is contained in:
zhimin.zeng 2024-07-17 10:51:02 +08:00 committed by lane.wei
parent cffb4a8564
commit 67f67d7688
14 changed files with 530 additions and 10 deletions

View File

@ -1179,7 +1179,8 @@ void ToolOrdering::reorder_extruders_for_minimum_flush_volume()
std::vector<int>filament_maps(number_of_extruders, 0);
if (nozzle_nums > 1) {
filament_maps = m_print->get_filament_maps();
if (print_config->print_sequence != PrintSequence::ByObject || m_print->objects().size() == 1) {
if (m_print->get_filament_map_mode() == FilamentMapMode::fmmAuto
&& (print_config->print_sequence != PrintSequence::ByObject || m_print->objects().size() == 1)) {
const PrintConfig* print_config = m_print_config_ptr;
if (!print_config && m_print_object_ptr) {
print_config = &(m_print_object_ptr->print()->config());

View File

@ -2345,6 +2345,11 @@ std::vector<int> Print::get_filament_maps() const
return m_config.filament_map.values;
}
FilamentMapMode Print::get_filament_map_mode() const
{
return m_config.filament_map_mode;
}
size_t Print::get_extruder_id(unsigned int filament_id) const
{
std::vector<int> filament_map = get_filament_maps();

View File

@ -807,6 +807,7 @@ public:
void update_filament_maps_to_config(std::vector<int> f_maps);
std::vector<int> get_filament_maps() const;
FilamentMapMode get_filament_map_mode() const;
// get the group label of filament
size_t get_extruder_id(unsigned int filament_id) const;

View File

@ -277,6 +277,10 @@ set(SLIC3R_GUI_SOURCES
GUI/ConfigManipulation.hpp
GUI/Field.cpp
GUI/Field.hpp
GUI/DragDropPanel.cpp
GUI/DragDropPanel.hpp
GUI/FilamentMapDialog.cpp
GUI/FilamentMapDialog.hpp
GUI/OptionsGroup.cpp
GUI/OptionsGroup.hpp
GUI/OG_CustomCtrl.cpp

View File

@ -0,0 +1,233 @@
#include "DragDropPanel.hpp"
namespace Slic3r { namespace GUI {
// Custom data object used to store information that needs to be backed up during drag and drop
class ColorDataObject : public wxDataObjectSimple
{
public:
ColorDataObject(wxPanel *color_block = nullptr, wxPanel *parent = nullptr, const wxColour &color = *wxBLACK, int filament_id = 0)
: wxDataObjectSimple(wxDF_PRIVATE)
, m_parent(parent)
, m_source_block(color_block)
, m_color(color)
, m_filament_id(filament_id) {}
wxColour GetColor() const { return m_color; }
void SetColor(const wxColour &color) { m_color = color; }
int GetFilament() const { return m_filament_id; }
void SetFilament(int label) { m_filament_id = label; }
wxPanel *GetParent() const { return m_parent; }
void SetParent(wxPanel * parent) { m_parent = parent; }
wxPanel *GetSourceBlock() const { return m_source_block; }
void SetSourceBlock(wxPanel *source_block) { m_source_block = source_block; }
virtual size_t GetDataSize() const override { return sizeof(m_color) + sizeof(int) + sizeof(m_parent) + sizeof(m_source_block); }
virtual bool GetDataHere(void *buf) const override
{
char *ptr = static_cast<char *>(buf);
wxColour * colorBuf = static_cast<wxColour *>(buf);
*colorBuf = m_color;
std::memcpy(ptr + sizeof(m_color), &m_filament_id, sizeof(int));
wxPanel **panelBuf = reinterpret_cast<wxPanel **>(static_cast<char *>(buf) + sizeof(m_color) + sizeof(int));
*panelBuf = m_parent;
wxPanel **blockBuf = reinterpret_cast<wxPanel **>(static_cast<char *>(buf) + sizeof(m_color) + sizeof(int) + sizeof(m_parent));
*blockBuf = m_source_block;
return true;
}
virtual bool SetData(size_t len, const void *buf) override
{
if (len == GetDataSize()) {
const char *ptr = static_cast<const char *>(buf);
m_color = *static_cast<const wxColour *>(buf);
std::memcpy(&m_filament_id, ptr + sizeof(m_color), sizeof(int));
m_parent = *reinterpret_cast<wxPanel *const *>(static_cast<const char *>(buf) + sizeof(m_color) + sizeof(int));
m_source_block = *reinterpret_cast<wxPanel *const *>(static_cast<const char *>(buf) + sizeof(m_color) + sizeof(int) + sizeof(m_parent));
return true;
}
return false;
}
private:
int m_filament_id;
wxColour m_color;
wxPanel *m_parent;
wxPanel *m_source_block;
};
/////////////// ColorPanel start ////////////////////////
// The UI panel of drag item
class ColorPanel : public wxPanel
{
public:
ColorPanel(DragDropPanel *parent, const wxColour &color, int filament_id)
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(50, 50), wxBORDER_SIMPLE)
, m_parent(parent)
, m_color(color)
, m_filament_id(filament_id)
{
SetBackgroundColour(color);
Bind(wxEVT_LEFT_DOWN, &ColorPanel::OnLeftDown, this);
Bind(wxEVT_LEFT_UP, &ColorPanel::OnLeftUp, this);
Bind(wxEVT_PAINT, &ColorPanel::OnPaint, this);
}
wxColour GetColor() const { return GetBackgroundColour(); }
int GetFilamentId() const { return m_filament_id; }
private:
void OnLeftDown(wxMouseEvent &event);
void OnLeftUp(wxMouseEvent &event);
void OnPaint(wxPaintEvent &event);
DragDropPanel *m_parent;
wxColor m_color;
int m_filament_id;
};
void ColorPanel::OnLeftDown(wxMouseEvent &event)
{
m_parent->set_is_draging(true);
m_parent->DoDragDrop(this, GetColor(), GetFilamentId());
}
void ColorPanel::OnLeftUp(wxMouseEvent &event) { m_parent->set_is_draging(false); }
void ColorPanel::OnPaint(wxPaintEvent &event)
{
wxPaintDC dc(this);
wxSize size = GetSize();
wxString label = wxString::Format(wxT("%d"), m_filament_id);
dc.SetTextForeground(m_color.GetLuminance() < 0.51 ? *wxWHITE : *wxBLACK); // set text color
dc.DrawLabel(label, wxRect(0, 0, size.GetWidth(), size.GetHeight()), wxALIGN_CENTER);
}
/////////////// ColorPanel end ////////////////////////
// Save the source object information to m_data when dragging
class ColorDropSource : public wxDropSource
{
public:
ColorDropSource(wxPanel *parent, wxPanel *color_block, const wxColour &color, int filament_id) : wxDropSource()
{
m_data.SetColor(color);
m_data.SetFilament(filament_id);
m_data.SetParent(parent);
m_data.SetSourceBlock(color_block);
SetData(m_data); // Set drag source data
}
private:
ColorDataObject m_data;
};
/////////////// ColorDropTarget start ////////////////////////
// Get the data from the drag source when drop it
class ColorDropTarget : public wxDropTarget
{
public:
ColorDropTarget(DragDropPanel *panel) : wxDropTarget(/*new wxDataObjectComposite*/), m_panel(panel)
{
m_data = new ColorDataObject();
SetDataObject(m_data);
}
virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def) override;
virtual bool OnDrop(wxCoord x, wxCoord y) override {
return true;
}
private:
DragDropPanel * m_panel;
ColorDataObject* m_data;
};
wxDragResult ColorDropTarget::OnData(wxCoord x, wxCoord y, wxDragResult def)
{
if (!GetData())
return wxDragNone;
if (m_data->GetParent() == m_panel) {
return wxDragNone;
}
DragDropPanel * parent_panel = dynamic_cast<DragDropPanel *>(m_data->GetParent());
ColorPanel * color_block = dynamic_cast<ColorPanel *>(m_data->GetSourceBlock());
assert(parent_panel && color_block);
parent_panel->RemoveColorBlock(color_block);
ColorDataObject *dataObject = dynamic_cast<ColorDataObject *>(GetDataObject());
m_panel->AddColorBlock(m_data->GetColor(), m_data->GetFilament());
return wxDragCopy;
}
/////////////// ColorDropTarget end ////////////////////////
DragDropPanel::DragDropPanel(wxWindow *parent, const wxString &label)
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE)
{
SetBackgroundColour(*wxLIGHT_GREY);
m_sizer = new wxBoxSizer(wxVERTICAL);
wxStaticText *staticText = new wxStaticText(this, wxID_ANY, label);
m_sizer->Add(staticText, 0, wxALIGN_CENTER | wxALL, 5);
m_sizer->AddSpacer(20);
m_grid_item_sizer = new wxGridSizer(0, 3, 10, 10); // row = 0, col = 3, 10 10 is space
m_sizer->Add(m_grid_item_sizer);
// set droptarget
auto drop_target = new ColorDropTarget(this);
SetDropTarget(drop_target);
SetSizer(m_sizer);
Fit();
}
void DragDropPanel::AddColorBlock(const wxColour &color, int filament_id)
{
ColorPanel *panel = new ColorPanel(this, color, filament_id);
panel->SetMinSize(wxSize(50, 50));
m_grid_item_sizer->Add(panel, 0, wxALIGN_CENTER | wxALL, 5);
Layout();
}
void DragDropPanel::RemoveColorBlock(ColorPanel *panel)
{
m_sizer->Detach(panel);
panel->Destroy();
Layout();
}
void DragDropPanel::DoDragDrop(ColorPanel *panel, const wxColour &color, int filament_id)
{
ColorDropSource source(this, panel, color, filament_id);
source.DoDragDrop(wxDrag_CopyOnly);
}
std::vector<int> DragDropPanel::GetAllFilaments() const
{
std::vector<int> filaments;
for (size_t i = 0; i < m_grid_item_sizer->GetItemCount(); ++i) {
wxSizerItem *item = m_grid_item_sizer->GetItem(i);
if (item != nullptr) {
wxWindow * window = item->GetWindow();
ColorPanel *colorPanel = dynamic_cast<ColorPanel *>(window);
if (colorPanel != nullptr) {
filaments.push_back(colorPanel->GetFilamentId());
}
}
}
return filaments;
}
}} // namespace Slic3r::GUI

View File

@ -0,0 +1,39 @@
#ifndef slic3r_DragDropPanel_hpp_
#define slic3r_DragDropPanel_hpp_
#include "GUI.hpp"
#include "GUI_Utils.hpp"
#include <wx/simplebook.h>
#include <wx/dialog.h>
#include <wx/timer.h>
#include <vector>
namespace Slic3r { namespace GUI {
class ColorPanel;
class DragDropPanel : public wxPanel
{
public:
DragDropPanel(wxWindow *parent, const wxString &label);
void AddColorBlock(const wxColour &color, int filament_id);
void RemoveColorBlock(ColorPanel *panel);
void DoDragDrop(ColorPanel *panel, const wxColour &color, int filament_id);
std::vector<int> GetAllFilaments() const;
void set_is_draging(bool is_draging) { m_is_draging = is_draging; }
bool is_draging() const { return m_is_draging; }
private:
wxBoxSizer *m_sizer;
wxGridSizer *m_grid_item_sizer;
private:
bool m_is_draging = false;
};
}} // namespace Slic3r::GUI
#endif /* slic3r_DragDropPanel_hpp_ */

View File

@ -0,0 +1,140 @@
#include "FilamentMapDialog.hpp"
#include "DragDropPanel.hpp"
#include "Widgets/Button.hpp"
#include "I18N.hpp"
namespace Slic3r { namespace GUI {
wxColour hex_to_color(const std::string &hex)
{
if ((hex.length() != 7 && hex.length() != 9) || hex[0] != '#') {
throw std::invalid_argument("Invalid hex color format");
}
unsigned int r, g, b, a = 255;
std::stringstream ss;
// r
ss << std::hex << hex.substr(1, 2);
ss >> r;
ss.clear();
ss.str("");
// g
ss << std::hex << hex.substr(3, 2);
ss >> g;
ss.clear();
ss.str("");
// b
ss << std::hex << hex.substr(5, 2);
ss >> b;
// a
if (hex.length() == 9) {
ss.clear();
ss.str("");
ss << std::hex << hex.substr(7, 2);
ss >> a;
}
return wxColour(r, g, b, a);
}
FilamentMapDialog::FilamentMapDialog(wxWindow *parent, const DynamicPrintConfig *config, const std::vector<int> &filament_map, bool is_auto)
: wxDialog(parent, wxID_ANY, _L("Filament arrangement method of plate"), wxDefaultPosition, wxSize(2000, 1500))
, m_config(config)
, m_filament_map(filament_map)
{
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"));
if (is_auto)
m_auto_radio->SetValue(true);
else
m_manual_radio->SetValue(true);
mode_sizer->Add(m_auto_radio, 1, wxALL, 5);
mode_sizer->Add(m_manual_radio, 1, wxALL, 5);
main_sizer->Add(mode_sizer, 0, wxEXPAND | wxALL, 10);
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_left_panel = new DragDropPanel(this, wxT("Left nozzle:"));
m_right_panel = new DragDropPanel(this, wxT("Right nozzle:"));
std::vector<std::string> filament_color = config->option<ConfigOptionStrings>("filament_colour")->values;
for (size_t i = 0; i < filament_map.size(); ++i) {
if (filament_map[i] == 1) {
m_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);
}
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);
wxBoxSizer *button_sizer = new wxBoxSizer(wxHORIZONTAL);
Button * ok_btn = new Button(this, _L("OK"));
Button * cancel_btn = new Button(this, _L("Cancel"));
button_sizer->Add(ok_btn, 0, wxALL, 5);
button_sizer->Add(cancel_btn, 0, wxALL, 5);
main_sizer->Add(button_sizer, 0, wxALIGN_CENTER | wxALL, 10);
ok_btn->Bind(wxEVT_BUTTON, &FilamentMapDialog::on_ok, this);
cancel_btn->Bind(wxEVT_BUTTON, &FilamentMapDialog::on_cancle, this);
SetSizer(main_sizer);
Layout();
Fit();
CenterOnParent();
}
bool FilamentMapDialog::is_auto() const
{
if (m_auto_radio->GetValue()) {
return true;
}
return false;
}
void FilamentMapDialog::on_ok(wxCommandEvent &event)
{
std::vector<int> left_filaments = m_left_panel->GetAllFilaments();
std::vector<int> right_filaments = m_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()) {
m_filament_map[i] = 2;
}
}
EndModal(wxID_OK);
}
void FilamentMapDialog::on_cancle(wxCommandEvent &event)
{
EndModal(wxID_CANCEL);
}
}} // namespace Slic3r::GUI

View File

@ -0,0 +1,40 @@
#ifndef slic3r_FilamentMapDialog_hpp_
#define slic3r_FilamentMapDialog_hpp_
#include "GUI.hpp"
#include <wx/simplebook.h>
#include <wx/dialog.h>
#include <wx/timer.h>
#include <vector>
namespace Slic3r {
class DynamicPrintConfig;
namespace GUI {
class DragDropPanel;
class FilamentMapDialog : public wxDialog
{
public:
FilamentMapDialog(wxWindow *parent, const DynamicPrintConfig *config, const std::vector<int> &filament_map, bool is_auto);
bool is_auto() const;
const std::vector<int>& get_filament_maps() { return m_filament_map; }
private:
void on_ok(wxCommandEvent &event);
void on_cancle(wxCommandEvent &event);
private:
wxRadioButton* m_auto_radio;
wxRadioButton* m_manual_radio;
DragDropPanel* m_left_panel;
DragDropPanel* m_right_panel;
private:
const DynamicPrintConfig* m_config;
std::vector<int> m_filament_map;
};
}} // namespace Slic3r::GUI
#endif /* slic3r_FilamentMapDialog_hpp_ */

View File

@ -4611,7 +4611,12 @@ void GCodeViewer::render_legend_color_arr_recommen(float window_padding)
lineStart.x = ImGui::GetItemRectMin().x;
ImGui::GetWindowDrawList()->AddLine(lineStart, lineEnd, HyperColor);
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left));
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
Plater *plater = wxGetApp().plater();
wxCommandEvent evt(EVT_OPEN_FILAMENT_MAP_SETTINGS_DIALOG);
evt.SetEventObject(plater);
wxPostEvent(plater, evt);
}
}
};

View File

@ -709,6 +709,14 @@ void PartPlate::render_icons(bool bottom, bool only_body, int hover_id)
render_icon_texture(m_partplate_list->m_lock_icon, m_partplate_list->m_lockopen_texture);
}
int extruder_count = wxGetApp().preset_bundle->get_printer_extruder_count();
if (extruder_count == 2) {
if (hover_id == PLATE_FILAMENT_MAP_ID)
render_icon_texture(m_partplate_list->m_plate_filament_map_icon, m_partplate_list->m_plate_set_filament_map_hovered_texture);
else
render_icon_texture(m_partplate_list->m_plate_filament_map_icon, m_partplate_list->m_plate_set_filament_map_texture);
}
if (hover_id == PLATE_NAME_ID)
render_icon_texture(m_plate_name_edit_icon, m_partplate_list->m_plate_name_edit_hovered_texture);
else
@ -2834,7 +2842,7 @@ FilamentMapMode PartPlate::get_filament_map_mode()
return m_config.option<ConfigOptionEnum<FilamentMapMode>>("filament_map_mode", true)->value;
}
void PartPlate::set_filament_map_mode(FilamentMapMode& mode)
void PartPlate::set_filament_map_mode(const FilamentMapMode& mode)
{
m_config.option<ConfigOptionEnum<FilamentMapMode>>("filament_map_mode", true)->value = mode;
}
@ -3338,6 +3346,20 @@ void PartPlateList::generate_icon_textures()
}
}
{
file_name = path + (m_is_dark ? "plate_set_filament_map_dark.svg" : "plate_set_filament_map.svg");
if (!m_plate_set_filament_map_texture.load_from_svg_file(file_name, true, false, false, icon_size)) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name;
}
}
{
file_name = path + (m_is_dark ? "plate_set_filament_map_hover_dark.svg" : "plate_set_filament_map_hover.svg");
if (!m_plate_set_filament_map_hovered_texture.load_from_svg_file(file_name, true, false, false, icon_size)) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name;
}
}
//if (m_bedtype_changed_texture.get_id() == 0)
{
file_name = path + (m_is_dark ? "plate_settings_changed_dark.svg" : "plate_settings_changed.svg");
@ -3433,9 +3455,9 @@ void PartPlateList::release_icon_textures()
m_lockopen_texture.reset();
m_lockopen_hovered_texture.reset();
m_plate_settings_texture.reset();
m_plate_settings_texture.reset();
m_plate_settings_texture.reset();
m_plate_settings_hovered_texture.reset();
m_plate_set_filament_map_texture.reset();
m_plate_set_filament_map_hovered_texture.reset();
m_plate_name_edit_texture.reset();
m_plate_name_edit_hovered_texture.reset();
for (int i = 0;i < MAX_PLATE_COUNT; i++) {

View File

@ -183,8 +183,8 @@ private:
public:
static const unsigned int PLATE_BASE_ID = 255 * 255 * 253;
//static const unsigned int PLATE_FILAMENT_MAP_ID = 6;//todo
static const unsigned int GRABBER_COUNT = 7;
static const unsigned int PLATE_FILAMENT_MAP_ID = 6;
static const unsigned int GRABBER_COUNT = 8;
static const unsigned int PLATE_NAME_ID = GRABBER_COUNT-1;
static std::array<float, 4> SELECT_COLOR;
@ -477,7 +477,7 @@ public:
std::map<std::string, std::string> get_diff_plate_setting();
FilamentMapMode get_filament_map_mode();
void set_filament_map_mode(FilamentMapMode& mode);
void set_filament_map_mode(const FilamentMapMode& mode);
std::vector<int> get_filament_maps();
void set_filament_maps(const std::vector<int>& f_maps);
@ -568,6 +568,8 @@ class PartPlateList : public ObjectBase
GLTexture m_plate_settings_changed_texture;
GLTexture m_plate_settings_hovered_texture;
GLTexture m_plate_settings_changed_hovered_texture;
GLTexture m_plate_set_filament_map_texture;
GLTexture m_plate_set_filament_map_hovered_texture;
GLTexture m_plate_name_edit_texture;
GLTexture m_plate_name_edit_hovered_texture;
GLTexture m_idx_textures[MAX_PLATE_COUNT];

View File

@ -142,6 +142,7 @@
#include "DailyTips.hpp"
#include "CreatePresetsDialog.hpp"
#include "StepMeshDialog.hpp"
#include "FilamentMapDialog.hpp"
using boost::optional;
namespace fs = boost::filesystem;
@ -165,6 +166,7 @@ wxDEFINE_EVENT(EVT_IMPORT_MODEL_ID, wxCommandEvent);
wxDEFINE_EVENT(EVT_DOWNLOAD_PROJECT, wxCommandEvent);
wxDEFINE_EVENT(EVT_PUBLISH, wxCommandEvent);
wxDEFINE_EVENT(EVT_OPEN_PLATESETTINGSDIALOG, wxCommandEvent);
wxDEFINE_EVENT(EVT_OPEN_FILAMENT_MAP_SETTINGS_DIALOG, wxCommandEvent);
// BBS: backup & restore
wxDEFINE_EVENT(EVT_RESTORE_PROJECT, wxCommandEvent);
wxDEFINE_EVENT(EVT_PRINT_FINISHED, wxCommandEvent);
@ -3344,6 +3346,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
q->Bind(EVT_SEND_FINISHED, [q](wxCommandEvent& evt) { q->send_job_finished(evt); });
q->Bind(EVT_PUBLISH_FINISHED, [q](wxCommandEvent& evt) { q->publish_job_finished(evt);});
q->Bind(EVT_OPEN_PLATESETTINGSDIALOG, [q](wxCommandEvent& evt) { q->open_platesettings_dialog(evt);});
q->Bind(EVT_OPEN_FILAMENT_MAP_SETTINGS_DIALOG, [q](wxCommandEvent &evt) { q->open_filament_map_setting_dialog(evt); });
//q->Bind(EVT_GLVIEWTOOLBAR_ASSEMBLE, [q](SimpleEvent&) { q->select_view_3D("Assemble"); });
}
@ -14321,6 +14324,18 @@ void Plater::open_platesettings_dialog(wxCommandEvent& evt) {
dlg.ShowModal();
}
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_filament_map_mode() == FilamentMapMode::fmmAuto);
if (filament_dlg.ShowModal() == wxID_OK) {
curr_plate->set_filament_maps(filament_dlg.get_filament_maps());
curr_plate->set_filament_map_mode(filament_dlg.is_auto() ? FilamentMapMode::fmmAuto : FilamentMapMode::fmmManual);
}
return;
}
//BBS: select Plate by hover_id
int Plater::select_plate_by_hover_id(int hover_id, bool right_click, bool isModidyPlateName)
{
@ -14484,7 +14499,19 @@ int Plater::select_plate_by_hover_id(int hover_id, bool right_click, bool isModi
ret = -1;
}
}
else if ((action == 6) && (!right_click)) {
else if ((action == PartPlate::PLATE_FILAMENT_MAP_ID) && (!right_click)) {
ret = select_plate(plate_index);
if (!ret) {
wxCommandEvent evt(EVT_OPEN_FILAMENT_MAP_SETTINGS_DIALOG);
evt.SetInt(plate_index);
evt.SetEventObject(this);
wxPostEvent(this, evt);
} else {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "can not select plate %1%" << plate_index;
ret = -1;
}
}
else if ((action == PartPlate::PLATE_NAME_ID) && (!right_click)) {
// set the plate type
ret = select_plate(plate_index);
if (!ret) {

View File

@ -90,6 +90,7 @@ enum class ActionButtonType : int;
wxDECLARE_EVENT(EVT_SLICING_UPDATE, Slic3r::SlicingStatusEvent);
wxDECLARE_EVENT(EVT_PUBLISH, wxCommandEvent);
wxDECLARE_EVENT(EVT_OPEN_PLATESETTINGSDIALOG, wxCommandEvent);
wxDECLARE_EVENT(EVT_OPEN_FILAMENT_MAP_SETTINGS_DIALOG, wxCommandEvent);
wxDECLARE_EVENT(EVT_REPAIR_MODEL, wxCommandEvent);
wxDECLARE_EVENT(EVT_FILAMENT_COLOR_CHANGED, wxCommandEvent);
wxDECLARE_EVENT(EVT_INSTALL_PLUGIN_NETWORKING, wxCommandEvent);
@ -407,6 +408,7 @@ public:
void send_job_finished(wxCommandEvent& evt);
void publish_job_finished(wxCommandEvent& evt);
void open_platesettings_dialog(wxCommandEvent& evt);
void open_filament_map_setting_dialog(wxCommandEvent &evt);
void on_change_color_mode(SimpleEvent& evt);
void eject_drive();

View File

@ -5824,7 +5824,6 @@ void Tab::update_extruder_variants(int extruder_id, bool reload)
m_extruder_switch->SetLabels(wxString::Format(_L("Left: %s"), left), wxString::Format(_L("Right: %s"), right));
m_extruder_switch->SetValue(extruder_id == 1);
m_extruder_switch->Enable(true);
assert(m_extruder_switch->IsEnabled());
} else {
m_extruder_switch->Enable(false);
}