mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-22 16:21:24 -06:00
Merge branch 'master' of https://github.com/prusa3d/Slic3r into et_canvas_gui_refactoring
This commit is contained in:
commit
6ab0a526b3
14 changed files with 234 additions and 137 deletions
|
@ -10,8 +10,10 @@
|
|||
#include <wx/listctrl.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/timer.h>
|
||||
#include <wx/wupdlock.h>
|
||||
|
||||
#include "slic3r/GUI/GUI.hpp"
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#include "slic3r/GUI/I18N.hpp"
|
||||
#include "slic3r/Utils/Bonjour.hpp"
|
||||
|
||||
|
@ -49,31 +51,36 @@ struct LifetimeGuard
|
|||
LifetimeGuard(BonjourDialog *dialog) : dialog(dialog) {}
|
||||
};
|
||||
|
||||
|
||||
BonjourDialog::BonjourDialog(wxWindow *parent) :
|
||||
wxDialog(parent, wxID_ANY, _(L("Network lookup"))),
|
||||
list(new wxListView(this, wxID_ANY, wxDefaultPosition, wxSize(800, 300))),
|
||||
replies(new ReplySet),
|
||||
label(new wxStaticText(this, wxID_ANY, "")),
|
||||
timer(new wxTimer()),
|
||||
timer_state(0)
|
||||
BonjourDialog::BonjourDialog(wxWindow *parent, Slic3r::PrinterTechnology tech)
|
||||
: wxDialog(parent, wxID_ANY, _(L("Network lookup")), wxDefaultPosition, wxDefaultSize, wxRESIZE_BORDER)
|
||||
, list(new wxListView(this, wxID_ANY))
|
||||
, replies(new ReplySet)
|
||||
, label(new wxStaticText(this, wxID_ANY, ""))
|
||||
, timer(new wxTimer())
|
||||
, timer_state(0)
|
||||
, tech(tech)
|
||||
{
|
||||
const int em = GUI::wxGetApp().em_unit();
|
||||
list->SetMinSize(wxSize(80 * em, 30 * em));
|
||||
|
||||
wxBoxSizer *vsizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
vsizer->Add(label, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 10);
|
||||
vsizer->Add(label, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, em);
|
||||
|
||||
list->SetSingleStyle(wxLC_SINGLE_SEL);
|
||||
list->SetSingleStyle(wxLC_SORT_DESCENDING);
|
||||
list->AppendColumn(_(L("Address")), wxLIST_FORMAT_LEFT, 50);
|
||||
list->AppendColumn(_(L("Hostname")), wxLIST_FORMAT_LEFT, 100);
|
||||
list->AppendColumn(_(L("Service name")), wxLIST_FORMAT_LEFT, 200);
|
||||
list->AppendColumn(_(L("OctoPrint version")), wxLIST_FORMAT_LEFT, 50);
|
||||
list->AppendColumn(_(L("Address")), wxLIST_FORMAT_LEFT, 5 * em);
|
||||
list->AppendColumn(_(L("Hostname")), wxLIST_FORMAT_LEFT, 10 * em);
|
||||
list->AppendColumn(_(L("Service name")), wxLIST_FORMAT_LEFT, 20 * em);
|
||||
if (tech == ptFFF) {
|
||||
list->AppendColumn(_(L("OctoPrint version")), wxLIST_FORMAT_LEFT, 5 * em);
|
||||
}
|
||||
|
||||
vsizer->Add(list, 1, wxEXPAND | wxALL, 10);
|
||||
vsizer->Add(list, 1, wxEXPAND | wxALL, em);
|
||||
|
||||
wxBoxSizer *button_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
button_sizer->Add(new wxButton(this, wxID_OK, "OK"), 0, wxALL, 10);
|
||||
button_sizer->Add(new wxButton(this, wxID_CANCEL, "Cancel"), 0, wxALL, 10);
|
||||
button_sizer->Add(new wxButton(this, wxID_OK, "OK"), 0, wxALL, em);
|
||||
button_sizer->Add(new wxButton(this, wxID_CANCEL, "Cancel"), 0, wxALL, em);
|
||||
// ^ Note: The Ok/Cancel labels are translated by wxWidgets
|
||||
|
||||
vsizer->Add(button_sizer, 0, wxALIGN_CENTER);
|
||||
|
@ -110,7 +117,11 @@ bool BonjourDialog::show_and_lookup()
|
|||
// so that both threads can access it safely.
|
||||
auto dguard = std::make_shared<LifetimeGuard>(this);
|
||||
|
||||
// Note: More can be done here when we support discovery of hosts other than Octoprint and SL1
|
||||
Bonjour::TxtKeys txt_keys { "version", "model" };
|
||||
|
||||
bonjour = std::move(Bonjour("octoprint")
|
||||
.set_txt_keys(std::move(txt_keys))
|
||||
.set_retries(3)
|
||||
.set_timeout(4)
|
||||
.on_reply([dguard](BonjourReply &&reply) {
|
||||
|
@ -157,9 +168,20 @@ void BonjourDialog::on_reply(BonjourReplyEvent &e)
|
|||
return;
|
||||
}
|
||||
|
||||
// Filter replies based on selected technology
|
||||
const auto model = e.reply.txt_data.find("model");
|
||||
const bool sl1 = model != e.reply.txt_data.end() && model->second == "SL1";
|
||||
if (tech == ptFFF && sl1 || tech == ptSLA && !sl1) {
|
||||
return;
|
||||
}
|
||||
|
||||
replies->insert(std::move(e.reply));
|
||||
|
||||
auto selected = get_selected();
|
||||
|
||||
wxWindowUpdateLocker freeze_guard(this);
|
||||
(void)freeze_guard;
|
||||
|
||||
list->DeleteAllItems();
|
||||
|
||||
// The whole list is recreated so that we benefit from it already being sorted in the set.
|
||||
|
@ -168,12 +190,20 @@ void BonjourDialog::on_reply(BonjourReplyEvent &e)
|
|||
auto item = list->InsertItem(0, reply.full_address);
|
||||
list->SetItem(item, 1, reply.hostname);
|
||||
list->SetItem(item, 2, reply.service_name);
|
||||
list->SetItem(item, 3, reply.version);
|
||||
|
||||
if (tech == ptFFF) {
|
||||
const auto it = reply.txt_data.find("version");
|
||||
if (it != reply.txt_data.end()) {
|
||||
list->SetItem(item, 3, GUI::from_u8(it->second));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
this->list->SetColumnWidth(i, wxLIST_AUTOSIZE);
|
||||
if (this->list->GetColumnWidth(i) < 100) { this->list->SetColumnWidth(i, 100); }
|
||||
const int em = GUI::wxGetApp().em_unit();
|
||||
|
||||
for (int i = 0; i < list->GetColumnCount(); i++) {
|
||||
list->SetColumnWidth(i, wxLIST_AUTOSIZE);
|
||||
if (list->GetColumnWidth(i) < 10 * em) { list->SetColumnWidth(i, 10 * em); }
|
||||
}
|
||||
|
||||
if (!selected.IsEmpty()) {
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
#include <wx/dialog.h>
|
||||
|
||||
#include "libslic3r/PrintConfig.hpp"
|
||||
|
||||
class wxListView;
|
||||
class wxStaticText;
|
||||
class wxTimer;
|
||||
|
@ -21,7 +23,7 @@ class ReplySet;
|
|||
class BonjourDialog: public wxDialog
|
||||
{
|
||||
public:
|
||||
BonjourDialog(wxWindow *parent);
|
||||
BonjourDialog(wxWindow *parent, Slic3r::PrinterTechnology);
|
||||
BonjourDialog(BonjourDialog &&) = delete;
|
||||
BonjourDialog(const BonjourDialog &) = delete;
|
||||
BonjourDialog &operator=(BonjourDialog &&) = delete;
|
||||
|
@ -37,6 +39,7 @@ private:
|
|||
std::shared_ptr<Bonjour> bonjour;
|
||||
std::unique_ptr<wxTimer> timer;
|
||||
unsigned timer_state;
|
||||
Slic3r::PrinterTechnology tech;
|
||||
|
||||
void on_reply(BonjourReplyEvent &);
|
||||
void on_timer(wxTimerEvent &);
|
||||
|
|
|
@ -3045,6 +3045,7 @@ void GLCanvas3D::Gizmos::do_render_overlay(const GLCanvas3D& canvas, const GLCan
|
|||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||
|
||||
float height = get_total_overlay_height();
|
||||
float width = get_total_overlay_width();
|
||||
#if ENABLE_SVG_ICONS
|
||||
float scaled_border = m_overlay_border * m_overlay_scale * inv_zoom;
|
||||
#else
|
||||
|
@ -3056,7 +3057,7 @@ void GLCanvas3D::Gizmos::do_render_overlay(const GLCanvas3D& canvas, const GLCan
|
|||
|
||||
float left = top_x;
|
||||
float top = top_y;
|
||||
float right = left + get_total_overlay_width() * inv_zoom;
|
||||
float right = left + width * inv_zoom;
|
||||
float bottom = top - height * inv_zoom;
|
||||
|
||||
// renders background
|
||||
|
@ -3164,24 +3165,24 @@ void GLCanvas3D::Gizmos::do_render_overlay(const GLCanvas3D& canvas, const GLCan
|
|||
#if ENABLE_SVG_ICONS
|
||||
float u_icon_size = m_overlay_icons_size * m_overlay_scale * inv_tex_width;
|
||||
float v_icon_size = m_overlay_icons_size * m_overlay_scale * inv_tex_height;
|
||||
float top = sprite_id * v_icon_size;
|
||||
float left = state * u_icon_size;
|
||||
float bottom = top + v_icon_size;
|
||||
float right = left + u_icon_size;
|
||||
float v_top = sprite_id * v_icon_size;
|
||||
float u_left = state * u_icon_size;
|
||||
float v_bottom = v_top + v_icon_size;
|
||||
float u_right = u_left + u_icon_size;
|
||||
#else
|
||||
float uv_icon_size = (float)m_icons_texture.metadata.icon_size * inv_texture_size;
|
||||
float top = sprite_id * uv_icon_size;
|
||||
float left = state * uv_icon_size;
|
||||
float bottom = top + uv_icon_size;
|
||||
float right = left + uv_icon_size;
|
||||
float v_top = sprite_id * uv_icon_size;
|
||||
float u_left = state * uv_icon_size;
|
||||
float v_bottom = v_top + uv_icon_size;
|
||||
float u_right = u_left + uv_icon_size;
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
|
||||
GLTexture::render_sub_texture(icons_texture_id, top_x, top_x + scaled_icons_size, top_y - scaled_icons_size, top_y, { { left, bottom }, { right, bottom }, { right, top }, { left, top } });
|
||||
GLTexture::render_sub_texture(icons_texture_id, top_x, top_x + scaled_icons_size, top_y - scaled_icons_size, top_y, { { u_left, v_bottom }, { u_right, v_bottom }, { u_right, v_top }, { u_left, v_top } });
|
||||
#if ENABLE_IMGUI
|
||||
if (it->second->get_state() == GLGizmoBase::On) {
|
||||
float toolbar_top = (float)cnv_h - canvas.m_view_toolbar.get_height();
|
||||
#if ENABLE_SVG_ICONS
|
||||
it->second->render_input_window(2.0f * m_overlay_border + m_overlay_icons_size, 0.5f * cnv_h - top_y * zoom, toolbar_top, selection);
|
||||
it->second->render_input_window(width, 0.5f * cnv_h - top_y * zoom, toolbar_top, selection);
|
||||
#else
|
||||
it->second->render_input_window(2.0f * m_overlay_border + icon_size * zoom, 0.5f * cnv_h - top_y * zoom, toolbar_top, selection);
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
|
|
|
@ -44,12 +44,12 @@ static PrinterTechnology printer_technology()
|
|||
}
|
||||
|
||||
// Config from current edited printer preset
|
||||
DynamicPrintConfig& printer_config()
|
||||
static DynamicPrintConfig& printer_config()
|
||||
{
|
||||
return wxGetApp().preset_bundle->printers.get_edited_preset().config;
|
||||
}
|
||||
|
||||
int extruders_count()
|
||||
static int extruders_count()
|
||||
{
|
||||
return printer_technology() == ptSLA ? 1 :
|
||||
printer_config().option<ConfigOptionFloats>("nozzle_diameter")->values.size();
|
||||
|
|
|
@ -752,10 +752,11 @@ void Preview::load_print_as_fff()
|
|||
|
||||
if (IsShown())
|
||||
{
|
||||
if (gcode_preview_data_valid)
|
||||
if (gcode_preview_data_valid) {
|
||||
// Load the real G-code preview.
|
||||
m_canvas->load_gcode_preview(*m_gcode_preview_data, colors);
|
||||
else
|
||||
m_loaded = true;
|
||||
} else
|
||||
// Load the initial preview based on slices, not the final G-code.
|
||||
m_canvas->load_preview(colors, color_print_values);
|
||||
show_hide_ui_elements(gcode_preview_data_valid ? "full" : "simple");
|
||||
|
@ -767,7 +768,6 @@ void Preview::load_print_as_fff()
|
|||
m_canvas_widget->Refresh();
|
||||
} else
|
||||
update_sliders(zs);
|
||||
m_loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,12 +24,11 @@ namespace GUI {
|
|||
|
||||
|
||||
MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &headline, wxWindowID button_id) :
|
||||
// MsgDialog(parent, title, headline, wxBitmap(from_u8(Slic3r::var("Slic3r_192px.png")), wxBITMAP_TYPE_PNG), button_id)
|
||||
MsgDialog(parent, title, headline, create_scaled_bitmap("Slic3r_192px.png"), button_id)
|
||||
{}
|
||||
|
||||
MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &headline, wxBitmap bitmap, wxWindowID button_id) :
|
||||
wxDialog(parent, wxID_ANY, title),
|
||||
wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxRESIZE_BORDER),
|
||||
boldfont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)),
|
||||
content_sizer(new wxBoxSizer(wxVERTICAL)),
|
||||
btn_sizer(new wxBoxSizer(wxHORIZONTAL))
|
||||
|
@ -70,7 +69,6 @@ MsgDialog::~MsgDialog() {}
|
|||
|
||||
ErrorDialog::ErrorDialog(wxWindow *parent, const wxString &msg)
|
||||
: MsgDialog(parent, _(L("Slic3r error")), _(L("Slic3r has encountered an error")),
|
||||
// wxBitmap(from_u8(Slic3r::var("Slic3r_192px_grayscale.png")), wxBITMAP_TYPE_PNG),
|
||||
create_scaled_bitmap("Slic3r_192px_grayscale.png"),
|
||||
wxID_NONE)
|
||||
, msg(msg)
|
||||
|
|
|
@ -2495,8 +2495,10 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
|
|||
|
||||
void Plater::priv::on_slicing_update(SlicingStatusEvent &evt)
|
||||
{
|
||||
this->statusbar()->set_progress(evt.status.percent);
|
||||
this->statusbar()->set_status_text(_(L(evt.status.text)) + wxString::FromUTF8("…"));
|
||||
if (evt.status.percent >= -1) {
|
||||
this->statusbar()->set_progress(evt.status.percent);
|
||||
this->statusbar()->set_status_text(_(L(evt.status.text)) + wxString::FromUTF8("…"));
|
||||
}
|
||||
if (evt.status.flags & PrintBase::SlicingStatus::RELOAD_SCENE) {
|
||||
switch (this->printer_technology) {
|
||||
case ptFFF:
|
||||
|
@ -2514,6 +2516,10 @@ void Plater::priv::on_slicing_update(SlicingStatusEvent &evt)
|
|||
// Update SLA gizmo (reload_scene calls update_gizmos_data)
|
||||
q->canvas3D()->reload_scene(true);
|
||||
}
|
||||
if (evt.status.flags & PrintBase::SlicingStatus::RELOAD_SLA_PREVIEW) {
|
||||
// Update the SLA preview
|
||||
this->preview->reload_print();
|
||||
}
|
||||
}
|
||||
|
||||
void Plater::priv::on_slicing_completed(wxCommandEvent &)
|
||||
|
|
|
@ -74,7 +74,7 @@ void Tab::set_type()
|
|||
void Tab::create_preset_tab()
|
||||
{
|
||||
#ifdef __WINDOWS__
|
||||
SetDoubleBuffered(true);
|
||||
// SetDoubleBuffered(true);
|
||||
#endif //__WINDOWS__
|
||||
|
||||
m_preset_bundle = wxGetApp().preset_bundle;
|
||||
|
@ -1612,25 +1612,21 @@ bool Tab::current_preset_is_dirty()
|
|||
|
||||
void TabPrinter::build_printhost(ConfigOptionsGroup *optgroup)
|
||||
{
|
||||
const bool sla = m_presets->get_selected_preset().printer_technology() == ptSLA;
|
||||
const PrinterTechnology tech = m_presets->get_selected_preset().printer_technology();
|
||||
|
||||
// Only offer the host type selection for FFF, for SLA it's always the SL1 printer (at the moment)
|
||||
if (! sla) {
|
||||
if (tech == ptFFF) {
|
||||
optgroup->append_single_option_line("host_type");
|
||||
}
|
||||
|
||||
auto printhost_browse = [this, optgroup] (wxWindow* parent) {
|
||||
|
||||
// TODO: SLA Bonjour
|
||||
|
||||
auto printhost_browse = [=](wxWindow* parent) {
|
||||
auto btn = m_printhost_browse_btn = new wxButton(parent, wxID_ANY, _(L(" Browse "))+dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
|
||||
// btn->SetBitmap(wxBitmap(from_u8(Slic3r::var("zoom.png")), wxBITMAP_TYPE_PNG));
|
||||
btn->SetBitmap(create_scaled_bitmap("zoom.png"));
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(btn);
|
||||
|
||||
btn->Bind(wxEVT_BUTTON, [this, parent, optgroup](wxCommandEvent &e) {
|
||||
BonjourDialog dialog(parent);
|
||||
btn->Bind(wxEVT_BUTTON, [=](wxCommandEvent &e) {
|
||||
BonjourDialog dialog(parent, tech);
|
||||
if (dialog.show_and_lookup()) {
|
||||
optgroup->set_value("print_host", std::move(dialog.get_selected()), true);
|
||||
optgroup->get_field("print_host")->field_changed();
|
||||
|
@ -1643,7 +1639,6 @@ void TabPrinter::build_printhost(ConfigOptionsGroup *optgroup)
|
|||
auto print_host_test = [this](wxWindow* parent) {
|
||||
auto btn = m_print_host_test_btn = new wxButton(parent, wxID_ANY, _(L("Test")),
|
||||
wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
// btn->SetBitmap(wxBitmap(from_u8(Slic3r::var("wrench.png")), wxBITMAP_TYPE_PNG));
|
||||
btn->SetBitmap(create_scaled_bitmap("wrench.png"));
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(btn);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue