ENH: support nozzle info, support new popup style
jira: [STUDIO-11974] Change-Id: I8d80338d5b90bcca824ea46be2066f1bfb7aa10a
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 8.7 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 8.7 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 7.4 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 8.3 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 8.4 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 10 KiB |
@ -2760,17 +2760,14 @@ _compare_obj_names(MachineObject* obj1, MachineObject* obj2)
|
||||
*@note _collect_machine_list
|
||||
*@param dev_manager -- the device manager
|
||||
*@param sorted_machine_objs -- return the sorted machine objects
|
||||
*@param sorted_machine_names -- return the sorted machine shown names
|
||||
*@param best_one -- return the best one
|
||||
*/
|
||||
/*******************************************************************/
|
||||
static void
|
||||
_collect_sorted_machines(Slic3r::DeviceManager* dev_manager,
|
||||
std::vector<MachineObject*>& sorted_machine_objs,
|
||||
wxArrayString& sorted_machine_names)
|
||||
std::vector<MachineObject*>& sorted_machine_objs)
|
||||
{
|
||||
sorted_machine_objs.clear();
|
||||
sorted_machine_names.clear();
|
||||
if (!dev_manager)
|
||||
{
|
||||
return;
|
||||
@ -2822,15 +2819,11 @@ _collect_sorted_machines(Slic3r::DeviceManager* dev_manager,
|
||||
|
||||
/* Step 3: Get the sorted objects*/
|
||||
auto _collect_sorted_objs = [](const std::vector<MachineObject*>& obj_list,
|
||||
std::vector<MachineObject*>& sorted_machine_objs,
|
||||
wxArrayString& sorted_machine_names)
|
||||
std::vector<MachineObject*>& sorted_machine_objs)
|
||||
{
|
||||
for (auto obj : obj_list)
|
||||
{
|
||||
sorted_machine_objs.push_back(obj);
|
||||
const wxString& dev_name = wxString::FromUTF8(obj->dev_name);
|
||||
obj->is_lan_mode_printer() ? sorted_machine_names.push_back(dev_name + "(LAN)"):
|
||||
sorted_machine_names.push_back(dev_name);
|
||||
}
|
||||
};
|
||||
|
||||
@ -2838,11 +2831,11 @@ _collect_sorted_machines(Slic3r::DeviceManager* dev_manager,
|
||||
if (cur_selected_obj)
|
||||
{
|
||||
std::vector<MachineObject*> cur_selected_obj_list{ cur_selected_obj };
|
||||
_collect_sorted_objs(cur_selected_obj_list, sorted_machine_objs, sorted_machine_names);
|
||||
_collect_sorted_objs(cur_selected_obj_list, sorted_machine_objs);
|
||||
}
|
||||
_collect_sorted_objs(match_avaliable_list, sorted_machine_objs, sorted_machine_names);
|
||||
_collect_sorted_objs(match_inavaliable_list, sorted_machine_objs, sorted_machine_names);
|
||||
_collect_sorted_objs(other_list, sorted_machine_objs, sorted_machine_names);
|
||||
_collect_sorted_objs(match_avaliable_list, sorted_machine_objs);
|
||||
_collect_sorted_objs(match_inavaliable_list, sorted_machine_objs);
|
||||
_collect_sorted_objs(other_list, sorted_machine_objs);
|
||||
}
|
||||
|
||||
void SelectMachineDialog::update_user_printer()
|
||||
@ -2856,11 +2849,9 @@ void SelectMachineDialog::update_user_printer()
|
||||
m_print_info = "";
|
||||
}
|
||||
|
||||
wxArrayString sorted_machine_names;
|
||||
_collect_sorted_machines(dev, m_list, sorted_machine_names);
|
||||
|
||||
// update the machine list, and select a default machine
|
||||
m_printer_box->SetPrinterName(sorted_machine_names);
|
||||
_collect_sorted_machines(dev, m_list);
|
||||
m_printer_box->SetPrinters(m_list);
|
||||
if (!m_list.empty())
|
||||
{
|
||||
m_printer_last_select = m_list.front()->dev_id;
|
||||
@ -3053,15 +3044,6 @@ void SelectMachineDialog::on_selection_changed(wxCommandEvent &event)
|
||||
}
|
||||
|
||||
if (obj) {
|
||||
// update image
|
||||
auto printer_img_name = "printer_preview_" + obj->printer_type;
|
||||
try {
|
||||
m_printer_box->SetPrinterImage(create_scaled_bitmap(printer_img_name, this, 52));
|
||||
} catch (const std::exception &) {
|
||||
m_printer_box->SetPrinterImage(create_scaled_bitmap("printer_preview_BL-P001", this, 52));
|
||||
}
|
||||
|
||||
|
||||
obj->command_get_version();
|
||||
obj->command_request_push_all();
|
||||
if (!dev->get_selected_machine()) {
|
||||
@ -5019,6 +5001,67 @@ void PrinterInfoBox::UpdatePlate(const std::string& plate_name)
|
||||
}
|
||||
}
|
||||
|
||||
static wxString _get_tips(MachineObject* obj_)
|
||||
{
|
||||
wxString tips;
|
||||
tips = obj_->get_printer_type_display_str();
|
||||
|
||||
wxString ext_diameter;
|
||||
if (obj_->m_extder_data.total_extder_count == 1) {
|
||||
ext_diameter += wxString::FromDouble(obj_->m_extder_data.extders[0].current_nozzle_diameter);
|
||||
ext_diameter += "mm";
|
||||
} else if (obj_->m_extder_data.total_extder_count == 2) {
|
||||
ext_diameter += wxString::FromDouble(obj_->m_extder_data.extders[1].current_nozzle_diameter);//Left
|
||||
ext_diameter += "/";
|
||||
ext_diameter += wxString::FromDouble(obj_->m_extder_data.extders[0].current_nozzle_diameter);
|
||||
ext_diameter += "mm";
|
||||
} else {
|
||||
assert(0);
|
||||
}
|
||||
|
||||
if (!ext_diameter.empty()) {
|
||||
tips += " ";
|
||||
tips += ext_diameter;
|
||||
}
|
||||
|
||||
return tips;
|
||||
}
|
||||
|
||||
void PrinterInfoBox::SetPrinters(const std::vector<MachineObject*>& sorted_printers)
|
||||
{
|
||||
m_comboBox_printer->Clear();
|
||||
|
||||
std::vector<DropDown::Item> drop_items;
|
||||
for (MachineObject* obj : sorted_printers)
|
||||
{
|
||||
wxString shown_dev_name = wxString::FromUTF8(obj->dev_name);
|
||||
if (obj->is_lan_mode_printer()) {
|
||||
shown_dev_name += "(LAN)";
|
||||
}
|
||||
|
||||
DropDown::Item drop_item;
|
||||
drop_item.text = shown_dev_name;
|
||||
drop_item.text_static_tips = _get_tips(obj);
|
||||
|
||||
// update image
|
||||
try
|
||||
{
|
||||
drop_item.icon = create_scaled_bitmap("printer_preview_" + obj->printer_type, this, 32);
|
||||
drop_item.icon_textctrl = create_scaled_bitmap("printer_preview_" + obj->printer_type, this, 52);
|
||||
}
|
||||
catch (const std::exception&)
|
||||
{
|
||||
drop_item.icon = create_scaled_bitmap("printer_preview_BL-P001", this, 32);
|
||||
drop_item.icon_textctrl = create_scaled_bitmap("printer_preview_BL-P001", this, 52);
|
||||
}
|
||||
|
||||
drop_item.tip = obj->get_printer_type_display_str();
|
||||
drop_items.emplace_back(drop_item);
|
||||
}
|
||||
|
||||
m_comboBox_printer->SetItems(drop_items);
|
||||
}
|
||||
|
||||
void PrinterInfoBox::EnableEditing(bool enable)
|
||||
{
|
||||
m_comboBox_printer->Enable(enable);
|
||||
@ -5077,14 +5120,10 @@ void PrinterInfoBox::Create()
|
||||
printer_staticbox->SetMaxSize(wxSize(FromDIP(338), FromDIP(68)));
|
||||
printer_staticbox->SetBorderColor(wxColour(0xCECECE));
|
||||
|
||||
m_printer_image = new wxStaticBitmap(printer_staticbox, wxID_ANY, create_scaled_bitmap("printer_preview_BL-P001", this, 52));
|
||||
m_printer_image->SetMinSize(wxSize(FromDIP(52), FromDIP(52)));
|
||||
m_printer_image->SetMaxSize(wxSize(FromDIP(52), FromDIP(52)));
|
||||
|
||||
m_comboBox_printer = new ComboBox(printer_staticbox, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY);
|
||||
m_comboBox_printer->SetBorderWidth(0);
|
||||
m_comboBox_printer->SetMinSize(wxSize(FromDIP(225), FromDIP(60)));
|
||||
m_comboBox_printer->SetMaxSize(wxSize(FromDIP(225), FromDIP(60)));
|
||||
m_comboBox_printer->SetMinSize(wxSize(FromDIP(277), FromDIP(60)));
|
||||
m_comboBox_printer->SetMaxSize(wxSize(FromDIP(277), FromDIP(60)));
|
||||
m_comboBox_printer->SetBackgroundColor(*wxWHITE);
|
||||
m_comboBox_printer->Bind(wxEVT_COMBOBOX, &SelectMachineDialog::on_selection_changed, m_select_dialog);
|
||||
|
||||
@ -5096,7 +5135,6 @@ void PrinterInfoBox::Create()
|
||||
m_button_question->SetToolTip(_L("Click here if you can't connect to the printer"));
|
||||
|
||||
sizer_printer_staticbox->Add(0, 0, 0, wxLEFT, FromDIP(7));
|
||||
sizer_printer_staticbox->Add(m_printer_image, 0, wxALIGN_CENTER, 0);
|
||||
sizer_printer_staticbox->Add(m_comboBox_printer, 0, wxALIGN_CENTER, 0);
|
||||
sizer_printer_staticbox->Add(m_button_refresh, 0, wxALIGN_CENTER, 0);
|
||||
sizer_printer_staticbox->AddSpacer(FromDIP(10));
|
||||
|
@ -515,9 +515,7 @@ public:
|
||||
|
||||
ComboBox* GetPrinterComboBox() const { return m_comboBox_printer; }
|
||||
void SetPrinterName(const wxString& printer_name) { m_comboBox_printer->SetValue(printer_name); };
|
||||
void SetPrinterName(const wxArrayString& priner_names) { m_comboBox_printer->Set(priner_names); }
|
||||
|
||||
void SetPrinterImage(const wxBitmap& bitmap) { m_printer_image->SetBitmap(bitmap); }
|
||||
void SetPrinters(const std::vector<MachineObject*>& sorted_printers);
|
||||
|
||||
void EnableEditing(bool enable);
|
||||
void EnableRefreshButton(bool enable);
|
||||
@ -533,7 +531,6 @@ private:
|
||||
// owner
|
||||
SelectMachineDialog* m_select_dialog;
|
||||
|
||||
wxStaticBitmap* m_printer_image{ nullptr };
|
||||
Label* m_stext_printer_title{ nullptr };
|
||||
ComboBox* m_comboBox_printer{ nullptr };
|
||||
ScalableButton* m_button_refresh{ nullptr };
|
||||
|
@ -86,10 +86,17 @@ void ComboBox::SetSelection(int n)
|
||||
return;
|
||||
drop.SetSelection(n);
|
||||
SetLabel(drop.GetValue());
|
||||
if (drop.selection >= 0 && drop.iconSize.y > 0 && items[drop.selection].icon.IsOk())
|
||||
SetIcon(items[drop.selection].icon);
|
||||
if (drop.selection >= 0 && drop.iconSize.y > 0 && items[drop.selection].icon_textctrl.IsOk())
|
||||
SetIcon(items[drop.selection].icon_textctrl);
|
||||
else
|
||||
SetIcon("drop_down");
|
||||
|
||||
if (drop.selection >= 0) {
|
||||
SetStaticTips(items[drop.selection].text_static_tips, wxNullBitmap);
|
||||
} else {
|
||||
SetStaticTips(wxEmptyString, wxNullBitmap);
|
||||
}
|
||||
|
||||
}
|
||||
void ComboBox::SelectAndNotify(int n) {
|
||||
SetSelection(n);
|
||||
@ -111,10 +118,16 @@ void ComboBox::SetValue(const wxString &value)
|
||||
{
|
||||
drop.SetValue(value);
|
||||
SetLabel(value);
|
||||
if (drop.selection >= 0 && drop.iconSize.y > 0 && items[drop.selection].icon.IsOk())
|
||||
SetIcon(items[drop.selection].icon);
|
||||
if (drop.selection >= 0 && drop.iconSize.y > 0 && items[drop.selection].icon_textctrl.IsOk())
|
||||
SetIcon(items[drop.selection].icon_textctrl);
|
||||
else
|
||||
SetIcon("drop_down");
|
||||
|
||||
if (drop.selection >= 0) {
|
||||
SetStaticTips(items[drop.selection].text_static_tips, wxNullBitmap);
|
||||
} else {
|
||||
SetStaticTips(wxEmptyString, wxNullBitmap);
|
||||
}
|
||||
}
|
||||
|
||||
void ComboBox::SetLabel(const wxString &value)
|
||||
@ -189,13 +202,20 @@ int ComboBox::Append(const wxString &text,
|
||||
|
||||
int ComboBox::Append(const wxString &text, const wxBitmap &bitmap, const wxString &group, void *clientData)
|
||||
{
|
||||
Item item{text, bitmap, clientData, group};
|
||||
Item item{text, wxEmptyString, bitmap, bitmap, clientData, group};
|
||||
items.push_back(item);
|
||||
SetClientDataType(wxClientData_Void);
|
||||
drop.Invalidate();
|
||||
return items.size() - 1;
|
||||
}
|
||||
|
||||
int ComboBox::SetItems(const std::vector<DropDown::Item>& the_items)
|
||||
{
|
||||
items = the_items;
|
||||
drop.Invalidate();
|
||||
return items.size() - 1;
|
||||
}
|
||||
|
||||
void ComboBox::DoClear()
|
||||
{
|
||||
SetIcon("drop_down");
|
||||
@ -258,7 +278,7 @@ int ComboBox::DoInsertItems(const wxArrayStringsAdapter &items,
|
||||
{
|
||||
if (pos > this->items.size()) return -1;
|
||||
for (int i = 0; i < items.GetCount(); ++i) {
|
||||
Item item { items[i], wxNullBitmap, clientData ? clientData[i] : NULL };
|
||||
Item item { items[i], wxEmptyString, wxNullBitmap, wxNullBitmap, clientData ? clientData[i] : NULL };
|
||||
this->items.insert(this->items.begin() + pos, item);
|
||||
++pos;
|
||||
}
|
||||
|
@ -40,6 +40,8 @@ public:
|
||||
|
||||
int Append(const wxString &item, const wxBitmap &bitmap, const wxString &group, void *clientData = nullptr);
|
||||
|
||||
int SetItems(const std::vector<DropDown::Item>& the_items);
|
||||
|
||||
void set_replace_text(wxString text, wxString image_name);
|
||||
unsigned int GetCount() const override;
|
||||
|
||||
|
@ -19,7 +19,9 @@ public:
|
||||
struct Item
|
||||
{
|
||||
wxString text;
|
||||
wxString text_static_tips;// display static tips for TextInput.eg.PrinterInfoBox
|
||||
wxBitmap icon;
|
||||
wxBitmap icon_textctrl;// display icon for TextInput.eg.PrinterInfoBox
|
||||
void * data{nullptr};
|
||||
wxString group{};
|
||||
wxString alias{};
|
||||
|
@ -95,6 +95,14 @@ void TextInput::SetLabel(const wxString& label)
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void TextInput::SetStaticTips(const wxString& tips, const wxBitmap& bitmap)
|
||||
{
|
||||
static_tips = tips;
|
||||
static_tips_icon = bitmap;
|
||||
messureSize();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void TextInput::SetIcon(const wxBitmap &icon)
|
||||
{
|
||||
this->icon = ScalableBitmap();
|
||||
@ -228,7 +236,7 @@ void TextInput::render(wxDC& dc)
|
||||
pt.x = (size.x - (szIcon.x + 0 + labelSize.x)) / 2;
|
||||
}
|
||||
dc.DrawBitmap(icon.bmp(), pt);
|
||||
pt.x += szIcon.x + 0;
|
||||
pt.x += (szIcon.x + szIcon.x * 0.2);
|
||||
}
|
||||
if (icon_1.bmp().IsOk()) {
|
||||
wxSize szIcon = icon_1.GetBmpSize();
|
||||
@ -243,18 +251,51 @@ void TextInput::render(wxDC& dc)
|
||||
}
|
||||
auto text = wxWindow::GetLabel();
|
||||
if (!text.IsEmpty()) {
|
||||
if (static_tips.IsEmpty()) {
|
||||
wxSize textSize = text_ctrl->GetSize();
|
||||
if (align_right || align_center) {
|
||||
if (align_right || align_center)
|
||||
{
|
||||
if (pt.x + labelSize.x + 5 > size.x)
|
||||
text = wxControl::Ellipsize(text, dc, wxELLIPSIZE_END, size.x - pt.x - 5);
|
||||
pt.y = (size.y - labelSize.y) / 2;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
pt.x += textSize.x;
|
||||
pt.y = (size.y + textSize.y) / 2 - labelSize.y;
|
||||
}
|
||||
dc.SetTextForeground(label_color.colorForStates(states));
|
||||
dc.SetFont(GetFont());
|
||||
dc.DrawText(text, pt);
|
||||
} else {
|
||||
wxSize textSize = text_ctrl->GetSize();
|
||||
if (align_right || align_center) {
|
||||
if (pt.x + labelSize.x + 5 > size.x)
|
||||
text = wxControl::Ellipsize(text, dc, wxELLIPSIZE_END, size.x - pt.x - 5);
|
||||
pt.y = (size.y - labelSize.y - static_tips_size.y - 8) / 2;
|
||||
} else {
|
||||
pt.x += textSize.x;
|
||||
pt.y = (size.y - labelSize.y - static_tips_size.y - 8) / 2;
|
||||
}
|
||||
dc.SetTextForeground(label_color.colorForStates(states));
|
||||
dc.SetFont(GetFont());
|
||||
dc.DrawText(text, pt);
|
||||
|
||||
if (align_right || align_center) {
|
||||
if (pt.x + static_tips_size.x + 5 > size.x) {
|
||||
text = wxControl::Ellipsize(static_tips, dc, wxELLIPSIZE_END, size.x - pt.x - 5);
|
||||
}
|
||||
|
||||
pt.y += (labelSize.y + 8);
|
||||
} else {
|
||||
pt.x += static_tips_size.x;
|
||||
pt.y += (labelSize.y + 8);
|
||||
}
|
||||
|
||||
dc.SetTextForeground(wxColour(144, 144, 144));
|
||||
dc.SetFont(GetFont());
|
||||
dc.DrawText(static_tips, pt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -264,10 +305,19 @@ void TextInput::messureSize()
|
||||
wxClientDC dc(this);
|
||||
labelSize = dc.GetTextExtent(wxWindow::GetLabel());
|
||||
wxSize textSize = text_ctrl->GetSize();
|
||||
|
||||
if (!static_tips.empty()) {
|
||||
static_tips_size = dc.GetTextExtent(static_tips);
|
||||
textSize.x = std::max(labelSize.GetWidth(), static_tips_size.GetWidth());
|
||||
textSize.y += static_tips_size.y;
|
||||
textSize.y += 8;
|
||||
}
|
||||
|
||||
int h = textSize.y + 8;
|
||||
if (size.y < h) {
|
||||
size.y = h;
|
||||
}
|
||||
|
||||
wxSize minSize = size;
|
||||
minSize.x = GetMinWidth();
|
||||
SetMinSize(minSize);
|
||||
|
@ -14,6 +14,10 @@ class TextInput : public wxNavigationEnabled<StaticBox>
|
||||
StateColor text_color;
|
||||
wxTextCtrl * text_ctrl;
|
||||
|
||||
wxString static_tips;
|
||||
wxSize static_tips_size;
|
||||
wxBitmap static_tips_icon;
|
||||
|
||||
static const int TextInputWidth = 200;
|
||||
static const int TextInputHeight = 50;
|
||||
|
||||
@ -41,8 +45,9 @@ public:
|
||||
|
||||
void SetLabel(const wxString& label);
|
||||
|
||||
void SetIcon(const wxBitmap & icon);
|
||||
void SetStaticTips(const wxString& tips, const wxBitmap& bitmap);
|
||||
|
||||
void SetIcon(const wxBitmap & icon);
|
||||
void SetIcon(const wxString & icon);
|
||||
|
||||
void SetIcon_1(const wxString &icon);
|
||||
|