mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-22 04:35:17 +00:00
NEW: Add FilamentMapDialog
support drag drop to modify the filament map jira: none Change-Id: I0ed3180a0fa8e95e7c871bb039eb844faccd1344 (cherry picked from commit 67f67d76889668fdd80ae5e496b6cbca5f771a43)
This commit is contained in:
@@ -1185,7 +1185,8 @@ void ToolOrdering::reorder_extruders_for_minimum_flush_volume()
|
|||||||
std::vector<int>filament_maps(number_of_extruders, 0);
|
std::vector<int>filament_maps(number_of_extruders, 0);
|
||||||
if (nozzle_nums > 1) {
|
if (nozzle_nums > 1) {
|
||||||
filament_maps = m_print->get_filament_maps();
|
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;
|
const PrintConfig* print_config = m_print_config_ptr;
|
||||||
if (!print_config && m_print_object_ptr) {
|
if (!print_config && m_print_object_ptr) {
|
||||||
print_config = &(m_print_object_ptr->print()->config());
|
print_config = &(m_print_object_ptr->print()->config());
|
||||||
|
|||||||
@@ -2626,6 +2626,11 @@ std::vector<int> Print::get_filament_maps() const
|
|||||||
return m_config.filament_map.values;
|
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
|
size_t Print::get_extruder_id(unsigned int filament_id) const
|
||||||
{
|
{
|
||||||
std::vector<int> filament_map = get_filament_maps();
|
std::vector<int> filament_map = get_filament_maps();
|
||||||
|
|||||||
@@ -936,6 +936,7 @@ public:
|
|||||||
|
|
||||||
void update_filament_maps_to_config(std::vector<int> f_maps);
|
void update_filament_maps_to_config(std::vector<int> f_maps);
|
||||||
std::vector<int> get_filament_maps() const;
|
std::vector<int> get_filament_maps() const;
|
||||||
|
FilamentMapMode get_filament_map_mode() const;
|
||||||
// get the group label of filament
|
// get the group label of filament
|
||||||
size_t get_extruder_id(unsigned int filament_id) const;
|
size_t get_extruder_id(unsigned int filament_id) const;
|
||||||
|
|
||||||
|
|||||||
@@ -295,6 +295,10 @@ set(SLIC3R_GUI_SOURCES
|
|||||||
GUI/ConfigManipulation.hpp
|
GUI/ConfigManipulation.hpp
|
||||||
GUI/Field.cpp
|
GUI/Field.cpp
|
||||||
GUI/Field.hpp
|
GUI/Field.hpp
|
||||||
|
GUI/DragDropPanel.cpp
|
||||||
|
GUI/DragDropPanel.hpp
|
||||||
|
GUI/FilamentMapDialog.cpp
|
||||||
|
GUI/FilamentMapDialog.hpp
|
||||||
GUI/FileArchiveDialog.cpp
|
GUI/FileArchiveDialog.cpp
|
||||||
GUI/FileArchiveDialog.hpp
|
GUI/FileArchiveDialog.hpp
|
||||||
GUI/OptionsGroup.cpp
|
GUI/OptionsGroup.cpp
|
||||||
|
|||||||
233
src/slic3r/GUI/DragDropPanel.cpp
Normal file
233
src/slic3r/GUI/DragDropPanel.cpp
Normal 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
|
||||||
39
src/slic3r/GUI/DragDropPanel.hpp
Normal file
39
src/slic3r/GUI/DragDropPanel.hpp
Normal 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_ */
|
||||||
140
src/slic3r/GUI/FilamentMapDialog.cpp
Normal file
140
src/slic3r/GUI/FilamentMapDialog.cpp
Normal 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
|
||||||
40
src/slic3r/GUI/FilamentMapDialog.hpp
Normal file
40
src/slic3r/GUI/FilamentMapDialog.hpp
Normal 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_ */
|
||||||
@@ -4394,7 +4394,12 @@ void GCodeViewer::render_legend_color_arr_recommen(float window_padding)
|
|||||||
lineStart.x = ImGui::GetItemRectMin().x;
|
lineStart.x = ImGui::GetItemRectMin().x;
|
||||||
ImGui::GetWindowDrawList()->AddLine(lineStart, lineEnd, HyperColor);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1033,6 +1033,14 @@ void PartPlate::render_icons(bool bottom, bool only_name, int hover_id)
|
|||||||
render_icon_texture(m_lock_icon.model, m_partplate_list->m_lockopen_texture);
|
render_icon_texture(m_lock_icon.model, 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_plate_filament_map_icon.model, m_partplate_list->m_plate_set_filament_map_hovered_texture);
|
||||||
|
else
|
||||||
|
render_icon_texture(m_plate_filament_map_icon.model, m_partplate_list->m_plate_set_filament_map_texture);
|
||||||
|
}
|
||||||
|
|
||||||
if (hover_id == 6) {
|
if (hover_id == 6) {
|
||||||
render_icon_texture(m_plate_name_edit_icon.model, m_partplate_list->m_plate_name_edit_hovered_texture);
|
render_icon_texture(m_plate_name_edit_icon.model, m_partplate_list->m_plate_name_edit_hovered_texture);
|
||||||
show_tooltip(_u8L("Edit current plate name"));
|
show_tooltip(_u8L("Edit current plate name"));
|
||||||
@@ -1349,6 +1357,7 @@ void PartPlate::register_raycasters_for_picking(GLCanvas3D &canvas)
|
|||||||
canvas.remove_raycasters_for_picking(SceneRaycaster::EType::Bed, picking_id_component(6));
|
canvas.remove_raycasters_for_picking(SceneRaycaster::EType::Bed, picking_id_component(6));
|
||||||
register_model_for_picking(canvas, m_plate_name_edit_icon, picking_id_component(6));
|
register_model_for_picking(canvas, m_plate_name_edit_icon, picking_id_component(6));
|
||||||
register_model_for_picking(canvas, m_move_front_icon, picking_id_component(7));
|
register_model_for_picking(canvas, m_move_front_icon, picking_id_component(7));
|
||||||
|
register_model_for_picking(canvas, m_plate_filament_map_icon, picking_id_component(PLATE_FILAMENT_MAP_ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
int PartPlate::picking_id_component(int idx) const
|
int PartPlate::picking_id_component(int idx) const
|
||||||
@@ -2702,7 +2711,8 @@ bool PartPlate::set_shape(const Pointfs& shape, const Pointfs& exclude_areas, Ve
|
|||||||
calc_vertex_for_icons(2, m_arrange_icon);
|
calc_vertex_for_icons(2, m_arrange_icon);
|
||||||
calc_vertex_for_icons(3, m_lock_icon);
|
calc_vertex_for_icons(3, m_lock_icon);
|
||||||
calc_vertex_for_icons(4, m_plate_settings_icon);
|
calc_vertex_for_icons(4, m_plate_settings_icon);
|
||||||
calc_vertex_for_icons(5, m_move_front_icon);
|
calc_vertex_for_icons(5, m_plate_filament_map_icon);
|
||||||
|
calc_vertex_for_icons(6, m_move_front_icon);
|
||||||
// ORCA also change bed_icon_count number in calc_vertex_for_icons() after adding or removing icons for circular shaped beds that uses vertical alingment for icons
|
// ORCA also change bed_icon_count number in calc_vertex_for_icons() after adding or removing icons for circular shaped beds that uses vertical alingment for icons
|
||||||
|
|
||||||
//calc_vertex_for_number(0, (m_plate_index < 9), m_plate_idx_icon);
|
//calc_vertex_for_number(0, (m_plate_index < 9), m_plate_idx_icon);
|
||||||
@@ -3179,7 +3189,7 @@ FilamentMapMode PartPlate::get_filament_map_mode()
|
|||||||
return m_config.option<ConfigOptionEnum<FilamentMapMode>>("filament_map_mode", true)->value;
|
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;
|
m_config.option<ConfigOptionEnum<FilamentMapMode>>("filament_map_mode", true)->value = mode;
|
||||||
}
|
}
|
||||||
@@ -3450,6 +3460,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)
|
//if (m_bedtype_changed_texture.get_id() == 0)
|
||||||
{
|
{
|
||||||
file_name = path + (m_is_dark ? "plate_settings_changed_dark.svg" : "plate_settings_changed.svg");
|
file_name = path + (m_is_dark ? "plate_settings_changed_dark.svg" : "plate_settings_changed.svg");
|
||||||
@@ -3527,9 +3551,9 @@ void PartPlateList::release_icon_textures()
|
|||||||
m_lockopen_texture.reset();
|
m_lockopen_texture.reset();
|
||||||
m_lockopen_hovered_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_texture.reset();
|
|
||||||
m_plate_settings_hovered_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_texture.reset();
|
||||||
m_plate_name_edit_hovered_texture.reset();
|
m_plate_name_edit_hovered_texture.reset();
|
||||||
for (int i = 0;i < MAX_PLATE_COUNT; i++) {
|
for (int i = 0;i < MAX_PLATE_COUNT; i++) {
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ private:
|
|||||||
PickingModel m_orient_icon;
|
PickingModel m_orient_icon;
|
||||||
PickingModel m_lock_icon;
|
PickingModel m_lock_icon;
|
||||||
PickingModel m_plate_settings_icon;
|
PickingModel m_plate_settings_icon;
|
||||||
|
PickingModel m_plate_filament_map_icon;
|
||||||
PickingModel m_plate_name_edit_icon;
|
PickingModel m_plate_name_edit_icon;
|
||||||
PickingModel m_move_front_icon;
|
PickingModel m_move_front_icon;
|
||||||
GLModel m_plate_idx_icon;
|
GLModel m_plate_idx_icon;
|
||||||
@@ -198,7 +199,8 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static const unsigned int PLATE_NAME_HOVER_ID = 6;
|
static const unsigned int PLATE_NAME_HOVER_ID = 6;
|
||||||
static const unsigned int GRABBER_COUNT = 8;
|
static const unsigned int PLATE_FILAMENT_MAP_ID = 8;
|
||||||
|
static const unsigned int GRABBER_COUNT = 9;
|
||||||
|
|
||||||
static ColorRGBA SELECT_COLOR;
|
static ColorRGBA SELECT_COLOR;
|
||||||
static ColorRGBA UNSELECT_COLOR;
|
static ColorRGBA UNSELECT_COLOR;
|
||||||
@@ -482,7 +484,7 @@ public:
|
|||||||
void print() const;
|
void print() const;
|
||||||
|
|
||||||
FilamentMapMode get_filament_map_mode();
|
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();
|
std::vector<int> get_filament_maps();
|
||||||
void set_filament_maps(const std::vector<int>& f_maps);
|
void set_filament_maps(const std::vector<int>& f_maps);
|
||||||
@@ -574,6 +576,8 @@ class PartPlateList : public ObjectBase
|
|||||||
GLTexture m_plate_settings_changed_texture;
|
GLTexture m_plate_settings_changed_texture;
|
||||||
GLTexture m_plate_settings_hovered_texture;
|
GLTexture m_plate_settings_hovered_texture;
|
||||||
GLTexture m_plate_settings_changed_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_texture;
|
||||||
GLTexture m_plate_name_edit_hovered_texture;
|
GLTexture m_plate_name_edit_hovered_texture;
|
||||||
GLTexture m_idx_textures[MAX_PLATE_COUNT];
|
GLTexture m_idx_textures[MAX_PLATE_COUNT];
|
||||||
|
|||||||
@@ -153,6 +153,7 @@
|
|||||||
#include "CreatePresetsDialog.hpp"
|
#include "CreatePresetsDialog.hpp"
|
||||||
#include "FileArchiveDialog.hpp"
|
#include "FileArchiveDialog.hpp"
|
||||||
#include "StepMeshDialog.hpp"
|
#include "StepMeshDialog.hpp"
|
||||||
|
#include "FilamentMapDialog.hpp"
|
||||||
#include "CloneDialog.hpp"
|
#include "CloneDialog.hpp"
|
||||||
|
|
||||||
using boost::optional;
|
using boost::optional;
|
||||||
@@ -177,6 +178,7 @@ wxDEFINE_EVENT(EVT_IMPORT_MODEL_ID, wxCommandEvent);
|
|||||||
wxDEFINE_EVENT(EVT_DOWNLOAD_PROJECT, wxCommandEvent);
|
wxDEFINE_EVENT(EVT_DOWNLOAD_PROJECT, wxCommandEvent);
|
||||||
wxDEFINE_EVENT(EVT_PUBLISH, wxCommandEvent);
|
wxDEFINE_EVENT(EVT_PUBLISH, wxCommandEvent);
|
||||||
wxDEFINE_EVENT(EVT_OPEN_PLATESETTINGSDIALOG, wxCommandEvent);
|
wxDEFINE_EVENT(EVT_OPEN_PLATESETTINGSDIALOG, wxCommandEvent);
|
||||||
|
wxDEFINE_EVENT(EVT_OPEN_FILAMENT_MAP_SETTINGS_DIALOG, wxCommandEvent);
|
||||||
// BBS: backup & restore
|
// BBS: backup & restore
|
||||||
wxDEFINE_EVENT(EVT_RESTORE_PROJECT, wxCommandEvent);
|
wxDEFINE_EVENT(EVT_RESTORE_PROJECT, wxCommandEvent);
|
||||||
wxDEFINE_EVENT(EVT_PRINT_FINISHED, wxCommandEvent);
|
wxDEFINE_EVENT(EVT_PRINT_FINISHED, wxCommandEvent);
|
||||||
@@ -3362,6 +3364,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_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_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_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"); });
|
//q->Bind(EVT_GLVIEWTOOLBAR_ASSEMBLE, [q](SimpleEvent&) { q->select_view_3D("Assemble"); });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14433,6 +14436,18 @@ void Plater::open_platesettings_dialog(wxCommandEvent& evt) {
|
|||||||
curr_plate->set_plate_name(dlg.get_plate_name().ToUTF8().data());
|
curr_plate->set_plate_name(dlg.get_plate_name().ToUTF8().data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
//BBS: select Plate by hover_id
|
||||||
int Plater::select_plate_by_hover_id(int hover_id, bool right_click, bool isModidyPlateName)
|
int Plater::select_plate_by_hover_id(int hover_id, bool right_click, bool isModidyPlateName)
|
||||||
{
|
{
|
||||||
@@ -14589,6 +14604,18 @@ int Plater::select_plate_by_hover_id(int hover_id, bool right_click, bool isModi
|
|||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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 == 6) && (!right_click)) {
|
else if ((action == 6) && (!right_click)) {
|
||||||
// set the plate type
|
// set the plate type
|
||||||
ret = select_plate(plate_index);
|
ret = select_plate(plate_index);
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ enum class ActionButtonType : int;
|
|||||||
wxDECLARE_EVENT(EVT_SLICING_UPDATE, Slic3r::SlicingStatusEvent);
|
wxDECLARE_EVENT(EVT_SLICING_UPDATE, Slic3r::SlicingStatusEvent);
|
||||||
wxDECLARE_EVENT(EVT_PUBLISH, wxCommandEvent);
|
wxDECLARE_EVENT(EVT_PUBLISH, wxCommandEvent);
|
||||||
wxDECLARE_EVENT(EVT_OPEN_PLATESETTINGSDIALOG, 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_REPAIR_MODEL, wxCommandEvent);
|
||||||
wxDECLARE_EVENT(EVT_FILAMENT_COLOR_CHANGED, wxCommandEvent);
|
wxDECLARE_EVENT(EVT_FILAMENT_COLOR_CHANGED, wxCommandEvent);
|
||||||
wxDECLARE_EVENT(EVT_INSTALL_PLUGIN_NETWORKING, wxCommandEvent);
|
wxDECLARE_EVENT(EVT_INSTALL_PLUGIN_NETWORKING, wxCommandEvent);
|
||||||
@@ -456,6 +457,7 @@ public:
|
|||||||
void send_job_finished(wxCommandEvent& evt);
|
void send_job_finished(wxCommandEvent& evt);
|
||||||
void publish_job_finished(wxCommandEvent& evt);
|
void publish_job_finished(wxCommandEvent& evt);
|
||||||
void open_platesettings_dialog(wxCommandEvent& evt);
|
void open_platesettings_dialog(wxCommandEvent& evt);
|
||||||
|
void open_filament_map_setting_dialog(wxCommandEvent &evt);
|
||||||
void on_change_color_mode(SimpleEvent& evt);
|
void on_change_color_mode(SimpleEvent& evt);
|
||||||
void eject_drive();
|
void eject_drive();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user