ENH: add thumbnail for printer and bed type

2. modify ams color style
jira: none

Change-Id: Ibc4cc21c4bcbd2e3c35f81c574f24786f41b9e62
This commit is contained in:
zhimin.zeng 2024-12-23 15:28:41 +08:00 committed by lane.wei
parent 7ff9b96837
commit b391241a0b
4 changed files with 56 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@ -218,6 +218,26 @@ void Plater::show_illegal_characters_warning(wxWindow* parent)
show_error(parent, _L("Invalid name, the following characters are not allowed:") + " <>:/\\|?*\"" +_L("(Including its escape characters)"));
}
static std::map<BedType, std::string> bed_type_thumbnails = {
{BedType::btPC, "bed_cool"},
{BedType::btEP, "bed_engineering"},
{BedType::btPEI, "bed_pei"},
{BedType::btPTE, "bed_high_templ"},
{BedType::btSuperTack, "bed_cool_supertack"}
};
// print_model_id
static std::map<std::string, std::string> printer_thumbnails = {
{"N1", "printer_preview_N1"},
{"N2S", "printer_preview_N2S"},
{"C11", "printer_preview_C11"},
{"C12", "printer_preview_C12"},
{"C13", "printer_preview_C13"},
{"BL-P001", "printer_preview_BL-P001"},
{"BL-P002", "printer_preview_BL-P002"},
{"O1D", "printer_preview_O1D"},
};
enum SlicedInfoIdx
{
siFilament_m,
@ -944,6 +964,13 @@ void ExtruderGroup::update_ams()
if (ams_n4 * 4 + ams_n1 * 2 <= 8)
is_upward = false;
std::vector<wxColour> colors = {
wxColour(255, 110, 100),
wxColour(97, 27, 22),
wxColour(7, 134, 219),
wxColour(170, 111, 252)
};
bool display_front_ams = !is_upward;
size_t i = 0;
for (; i < ams_n4 && i < 4; ++i) {
@ -953,7 +980,11 @@ void ExtruderGroup::update_ams()
if (show_this_ams) {
AMSinfo ams_info;
ams_info.ams_type = AMSModel::GENERIC_AMS;
for (size_t i = 0; i < 4; ++i) ams_info.cans.emplace_back(Caninfo());
for (size_t i = 0; i < 4; ++i) {
Caninfo can_info;
can_info.material_colour = colors[i];
ams_info.cans.push_back(can_info);
}
ams[i]->Update(ams_info);
ams[i]->Refresh();
ams[i]->Open();
@ -969,7 +1000,9 @@ void ExtruderGroup::update_ams()
if (show_this_ams) {
AMSinfo ams_info;
ams_info.ams_type = AMSModel::N3S_AMS;
ams_info.cans.emplace_back(Caninfo());
Caninfo can_info;
can_info.material_colour = wxColour(255, 110, 100);
ams_info.cans.push_back(can_info);
ams[i]->Update(ams_info);
ams[i]->Refresh();
ams[i]->Open();
@ -1431,6 +1464,11 @@ Sidebar::Sidebar(Plater *parent)
}
}
p->combo_printer_bed->Bind(wxEVT_COMBOBOX, [this](auto &e) {
int selection = p->combo_printer_bed->GetSelection();
p->image_printer_bed->SetBitmap(create_scaled_bitmap(bed_type_thumbnails[BedType(selection + 1)], this, 48));
});
{
auto hovered = std::make_shared<wxWindow *>();
for (wxWindow *w : std::initializer_list<wxWindow *>{p->panel_printer_bed, wiki_bed, p->image_printer_bed, p->combo_printer_bed}) {
@ -1980,8 +2018,10 @@ void Sidebar::update_all_preset_comboboxes()
cb->update();
}
if (p->combo_printer)
if (p->combo_printer) {
p->combo_printer->update();
update_printer_thumbnail();
}
}
void Sidebar::update_presets(Preset::Type preset_type)
@ -2912,6 +2952,17 @@ void Sidebar::set_is_gcode_file(bool flag)
}
}
void Sidebar::update_printer_thumbnail()
{
auto& preset_bundle = wxGetApp().preset_bundle;
Preset & selected_preset = preset_bundle->printers.get_edited_preset();
std::string printer_type = selected_preset.get_current_printer_type(preset_bundle);
if (printer_thumbnails.find(printer_type) != printer_thumbnails.end())
p->image_printer->SetBitmap(create_scaled_bitmap(printer_thumbnails[printer_type], this, 48));
else
p->image_printer->SetBitmap(create_scaled_bitmap("printer_placeholder", this, 48));
}
void Sidebar::auto_calc_flushing_volumes(const int modify_id)
{
auto& preset_bundle = wxGetApp().preset_bundle;
@ -7454,6 +7505,7 @@ void Plater::priv::on_combobox_select(wxCommandEvent &evt)
PlaterPresetComboBox* preset_combo_box = dynamic_cast<PlaterPresetComboBox*>(evt.GetEventObject());
if (preset_combo_box) {
this->on_select_preset(evt);
sidebar->update_printer_thumbnail();
}
else {
this->on_select_bed_type(evt);

View File

@ -199,6 +199,7 @@ public:
void update_soft_first_start_state() { m_soft_first_start = false; }
void cancel_update_3d_state() { m_update_3d_state = false; }
bool get_update_3d_state() { return m_update_3d_state; }
void update_printer_thumbnail();
private:
struct priv;
std::unique_ptr<priv> p;