mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-20 15:21:21 -06:00
Merge remote-tracking branch 'remote/master' into SoftFever
# Conflicts: # src/libslic3r/PerimeterGenerator.cpp
This commit is contained in:
commit
769bc14a8a
219 changed files with 11441 additions and 1527 deletions
|
@ -83,6 +83,21 @@ std::vector<std::array<float, 4>> get_extruders_colors()
|
|||
return colors_out;
|
||||
}
|
||||
|
||||
std::array<float, 4> adjust_color_for_rendering(const std::array<float, 4>& colors)
|
||||
{
|
||||
if ((colors[0] < 0.1) && (colors[1] < 0.1) && (colors[2] < 0.1))
|
||||
{
|
||||
std::array<float, 4> new_color;
|
||||
new_color[0] = 0.1;
|
||||
new_color[1] = 0.1;
|
||||
new_color[2] = 0.1;
|
||||
new_color[3] = colors[3];
|
||||
return new_color;
|
||||
}
|
||||
|
||||
return colors;
|
||||
}
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
#if ENABLE_SMOOTH_NORMALS
|
||||
|
@ -488,8 +503,11 @@ void GLVolume::set_render_color()
|
|||
else if (is_outside && shader_outside_printer_detection_enabled)
|
||||
set_render_color(OUTSIDE_COLOR);
|
||||
#endif
|
||||
else
|
||||
set_render_color(color);
|
||||
else {
|
||||
//to make black not too hard too see
|
||||
std::array<float, 4> new_color = adjust_color_for_rendering(color);
|
||||
set_render_color(new_color);
|
||||
}
|
||||
}
|
||||
|
||||
if (force_transparent)
|
||||
|
@ -708,13 +726,24 @@ void GLVolume::render(bool with_outline) const
|
|||
ModelObject* mo = model_objects[object_idx()];
|
||||
ModelVolume* mv = mo->volumes[volume_idx()];
|
||||
int extruder_id = mv->extruder_id();
|
||||
shader->set_uniform("uniform_color", colors[extruder_id - 1]);
|
||||
//shader->set_uniform("uniform_color", colors[extruder_id - 1]);
|
||||
//to make black not too hard too see
|
||||
std::array<float, 4> new_color = adjust_color_for_rendering(colors[extruder_id - 1]);
|
||||
shader->set_uniform("uniform_color", new_color);
|
||||
}
|
||||
else {
|
||||
if (idx <= colors.size())
|
||||
shader->set_uniform("uniform_color", colors[idx - 1]);
|
||||
else
|
||||
shader->set_uniform("uniform_color", colors[0]);
|
||||
if (idx <= colors.size()) {
|
||||
//shader->set_uniform("uniform_color", colors[idx - 1]);
|
||||
//to make black not too hard too see
|
||||
std::array<float, 4> new_color = adjust_color_for_rendering(colors[idx - 1]);
|
||||
shader->set_uniform("uniform_color", new_color);
|
||||
}
|
||||
else {
|
||||
//shader->set_uniform("uniform_color", colors[0]);
|
||||
//to make black not too hard too see
|
||||
std::array<float, 4> new_color = adjust_color_for_rendering(colors[0]);
|
||||
shader->set_uniform("uniform_color", new_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
iva.render(this->tverts_range, this->qverts_range);
|
||||
|
@ -913,13 +942,23 @@ void GLVolume::simple_render(GLShaderProgram* shader, ModelObjectPtrs& model_obj
|
|||
if (shader) {
|
||||
if (idx == 0) {
|
||||
int extruder_id = model_volume->extruder_id();
|
||||
shader->set_uniform("uniform_color", extruder_colors[extruder_id - 1]);
|
||||
//to make black not too hard too see
|
||||
std::array<float, 4> new_color = adjust_color_for_rendering(extruder_colors[extruder_id - 1]);
|
||||
shader->set_uniform("uniform_color", new_color);
|
||||
}
|
||||
else {
|
||||
if (idx <= extruder_colors.size())
|
||||
shader->set_uniform("uniform_color", extruder_colors[idx - 1]);
|
||||
else
|
||||
shader->set_uniform("uniform_color", extruder_colors[0]);
|
||||
if (idx <= extruder_colors.size()) {
|
||||
//shader->set_uniform("uniform_color", extruder_colors[idx - 1]);
|
||||
//to make black not too hard too see
|
||||
std::array<float, 4> new_color = adjust_color_for_rendering(extruder_colors[idx - 1]);
|
||||
shader->set_uniform("uniform_color", new_color);
|
||||
}
|
||||
else {
|
||||
//shader->set_uniform("uniform_color", extruder_colors[0]);
|
||||
//to make black not too hard too see
|
||||
std::array<float, 4> new_color = adjust_color_for_rendering(extruder_colors[0]);
|
||||
shader->set_uniform("uniform_color", new_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
iva.render(this->tverts_range, this->qverts_range);
|
||||
|
@ -978,8 +1017,10 @@ void GLWipeTowerVolume::render(bool with_outline) const
|
|||
|
||||
GLShaderProgram* shader = GUI::wxGetApp().get_current_shader();
|
||||
for (int i = 0; i < m_colors.size(); i++) {
|
||||
if (shader)
|
||||
shader->set_uniform("uniform_color", m_colors[i]);
|
||||
if (shader) {
|
||||
std::array<float, 4> new_color = adjust_color_for_rendering(m_colors[i]);
|
||||
shader->set_uniform("uniform_color", new_color);
|
||||
}
|
||||
this->iva_per_colors[i].render();
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#define glcheck()
|
||||
#endif // HAS_GLSAFE
|
||||
extern std::vector<std::array<float, 4>> get_extruders_colors();
|
||||
extern std::array<float, 4> adjust_color_for_rendering(const std::array<float, 4>& colors);
|
||||
|
||||
|
||||
namespace Slic3r {
|
||||
class SLAPrintObject;
|
||||
|
@ -373,7 +375,6 @@ public:
|
|||
bool is_modifier : 1;
|
||||
// Wheter or not this volume has been generated from the wipe tower
|
||||
bool is_wipe_tower : 1;
|
||||
bool is_timelapse_wipe_tower : 1;
|
||||
// Wheter or not this volume has been generated from an extrusion path
|
||||
bool is_extrusion_path : 1;
|
||||
// Wheter or not to always render this volume using its own alpha
|
||||
|
|
|
@ -502,7 +502,7 @@ AuFolderPanel::AuFolderPanel(wxWindow *parent, AuxiliaryFolderType type, wxWindo
|
|||
m_button_add->SetBackgroundColor(btn_bg_white);
|
||||
m_button_add->SetBorderColor(btn_bd_white);
|
||||
m_button_add->SetMinSize(wxSize(-1, FromDIP(24)));
|
||||
m_button_add->SetCornerRadius(12);
|
||||
m_button_add->SetCornerRadius(FromDIP(12));
|
||||
m_button_add->SetFont(Label::Body_14);
|
||||
// m_button_add->Bind(wxEVT_LEFT_UP, &AuxiliaryPanel::on_add, this);
|
||||
|
||||
|
|
|
@ -51,8 +51,8 @@ BBLStatusBar::BBLStatusBar(wxWindow *parent, int id)
|
|||
m_sizer->Add(m_object_info_sizer, 1, wxEXPAND | wxALL | wxALIGN_LEFT, 5);
|
||||
m_sizer->Add(m_slice_info_sizer, 1, wxEXPAND | wxALL | wxALIGN_LEFT, 5);
|
||||
m_sizer->Add(m_status_text, 1, wxEXPAND | wxALL | wxALIGN_LEFT, 5);
|
||||
m_sizer->Add(m_prog, 0, wxEXPAND | wxLEFT | wxALL | wxALIGN_RIGHT, 5);
|
||||
m_sizer->Add(m_cancelbutton, 0, wxEXPAND | wxALL | wxALIGN_RIGHT, 5);
|
||||
m_sizer->Add(m_prog, 0, wxEXPAND | wxLEFT | wxALL, 5);
|
||||
m_sizer->Add(m_cancelbutton, 0, wxEXPAND | wxALL, 5);
|
||||
m_sizer->SetSizeHints(m_self);
|
||||
m_self->SetSizer(m_sizer);
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ BBLStatusBarSend::BBLStatusBarSend(wxWindow *parent, int id)
|
|||
m_cancelbutton->SetMinSize(wxSize(m_self->FromDIP(64), m_self->FromDIP(24)));
|
||||
m_cancelbutton->SetTextColor(wxColour(107, 107, 107));
|
||||
m_cancelbutton->SetBackgroundColor(wxColour(255, 255, 255));
|
||||
m_cancelbutton->SetCornerRadius(12);
|
||||
m_cancelbutton->SetCornerRadius(m_self->FromDIP(12));
|
||||
m_cancelbutton->Bind(wxEVT_BUTTON,
|
||||
[this](wxCommandEvent &evt) {
|
||||
m_was_cancelled = true;
|
||||
|
|
|
@ -245,7 +245,7 @@ void BBLTopbar::Init(wxFrame* parent)
|
|||
this->AddStretchSpacer(1);
|
||||
|
||||
m_title_item = this->AddLabel(ID_TITLE, "", FromDIP(TOPBAR_TITLE_WIDTH));
|
||||
m_title_item->SetAlignment(wxCENTER);
|
||||
m_title_item->SetAlignment(wxALIGN_CENTRE);
|
||||
|
||||
this->AddSpacer(FromDIP(10));
|
||||
this->AddStretchSpacer(1);
|
||||
|
@ -407,7 +407,7 @@ void BBLTopbar::SetTitle(wxString title)
|
|||
title = wxControl::Ellipsize(title, dc, wxELLIPSIZE_END, FromDIP(TOPBAR_TITLE_WIDTH));
|
||||
|
||||
m_title_item->SetLabel(title);
|
||||
m_title_item->SetAlignment(wxALIGN_CENTRE_HORIZONTAL);
|
||||
m_title_item->SetAlignment(wxALIGN_CENTRE);
|
||||
this->Refresh();
|
||||
}
|
||||
|
||||
|
@ -493,7 +493,7 @@ void BBLTopbar::OnFullScreen(wxAuiToolBarEvent& event)
|
|||
m_frame->Restore();
|
||||
}
|
||||
else {
|
||||
wxDisplay display(wxDisplay::GetFromWindow(this));
|
||||
wxDisplay display(this);
|
||||
auto size = display.GetClientArea().GetSize();
|
||||
m_frame->SetMaxSize(size + wxSize{16, 16});
|
||||
m_normalRect = m_frame->GetRect();
|
||||
|
@ -524,7 +524,7 @@ void BBLTopbar::OnMouseLeftDClock(wxMouseEvent& mouse)
|
|||
m_frame->Restore();
|
||||
}
|
||||
else {
|
||||
wxDisplay display(wxDisplay::GetFromWindow(this));
|
||||
wxDisplay display(this);
|
||||
auto size = display.GetClientArea().GetSize();
|
||||
m_frame->SetMaxSize(size + wxSize{16, 16});
|
||||
m_normalRect = m_frame->GetRect();
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace GUI {
|
|||
|
||||
m_panel_left = new StaticBox(this, wxID_ANY, wxDefaultPosition, wxSize(FromDIP(201), FromDIP(212)), wxBORDER_NONE);
|
||||
m_panel_left->SetMinSize(wxSize(FromDIP(201), FromDIP(212)));
|
||||
m_panel_left->SetCornerRadius(8);
|
||||
m_panel_left->SetCornerRadius(FromDIP(8));
|
||||
m_panel_left->SetBackgroundColor(BIND_DIALOG_GREY200);
|
||||
wxBoxSizer *m_sizere_left_h = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxBoxSizer *m_sizere_left_v= new wxBoxSizer(wxVERTICAL);
|
||||
|
@ -55,7 +55,7 @@ namespace GUI {
|
|||
|
||||
m_panel_right = new StaticBox(this, wxID_ANY, wxDefaultPosition, wxSize(FromDIP(201), FromDIP(212)), wxBORDER_NONE);
|
||||
m_panel_right->SetMinSize(wxSize(FromDIP(201), FromDIP(212)));
|
||||
m_panel_right->SetCornerRadius(8);
|
||||
m_panel_right->SetCornerRadius(FromDIP(8));
|
||||
m_panel_right->SetBackgroundColor(BIND_DIALOG_GREY200);
|
||||
|
||||
m_user_name = new wxStaticText(m_panel_right, wxID_ANY, wxEmptyString);
|
||||
|
@ -136,7 +136,7 @@ namespace GUI {
|
|||
m_button_bind->SetTextColor(*wxWHITE);
|
||||
m_button_bind->SetSize(BIND_DIALOG_BUTTON_SIZE);
|
||||
m_button_bind->SetMinSize(BIND_DIALOG_BUTTON_SIZE);
|
||||
m_button_bind->SetCornerRadius(10);
|
||||
m_button_bind->SetCornerRadius(FromDIP(12));
|
||||
|
||||
|
||||
StateColor btn_bg_white(std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Hovered),
|
||||
|
@ -148,7 +148,7 @@ namespace GUI {
|
|||
m_button_cancel->SetSize(BIND_DIALOG_BUTTON_SIZE);
|
||||
m_button_cancel->SetMinSize(BIND_DIALOG_BUTTON_SIZE);
|
||||
m_button_cancel->SetTextColor(BIND_DIALOG_GREY900);
|
||||
m_button_cancel->SetCornerRadius(10);
|
||||
m_button_cancel->SetCornerRadius(FromDIP(12));
|
||||
|
||||
m_sizer_button->Add(m_button_bind, 0, wxALIGN_CENTER, 0);
|
||||
m_sizer_button->Add(0, 0, 0, wxLEFT, FromDIP(13));
|
||||
|
@ -273,7 +273,7 @@ UnBindMachineDilaog::UnBindMachineDilaog(Plater *plater /*= nullptr*/)
|
|||
|
||||
auto m_panel_left = new StaticBox(this, wxID_ANY, wxDefaultPosition, wxSize(FromDIP(201), FromDIP(212)), wxBORDER_NONE);
|
||||
m_panel_left->SetMinSize(wxSize(FromDIP(201), FromDIP(212)));
|
||||
m_panel_left->SetCornerRadius(8);
|
||||
m_panel_left->SetCornerRadius(FromDIP(8));
|
||||
m_panel_left->SetBackgroundColor(BIND_DIALOG_GREY200);
|
||||
wxBoxSizer *m_sizere_left_h = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxBoxSizer *m_sizere_left_v= new wxBoxSizer(wxVERTICAL);
|
||||
|
@ -297,7 +297,7 @@ UnBindMachineDilaog::UnBindMachineDilaog(Plater *plater /*= nullptr*/)
|
|||
|
||||
auto m_panel_right = new StaticBox(this, wxID_ANY, wxDefaultPosition, wxSize(FromDIP(201), FromDIP(212)), wxBORDER_NONE);
|
||||
m_panel_right->SetMinSize(wxSize(FromDIP(201), FromDIP(212)));
|
||||
m_panel_right->SetCornerRadius(8);
|
||||
m_panel_right->SetCornerRadius(FromDIP(8));
|
||||
m_panel_right->SetBackgroundColor(BIND_DIALOG_GREY200);
|
||||
m_user_name = new wxStaticText(m_panel_right, wxID_ANY, wxEmptyString);
|
||||
m_user_name->SetBackgroundColour(BIND_DIALOG_GREY200);
|
||||
|
@ -374,7 +374,7 @@ UnBindMachineDilaog::UnBindMachineDilaog(Plater *plater /*= nullptr*/)
|
|||
m_button_unbind->SetTextColor(*wxWHITE);
|
||||
m_button_unbind->SetSize(BIND_DIALOG_BUTTON_SIZE);
|
||||
m_button_unbind->SetMinSize(BIND_DIALOG_BUTTON_SIZE);
|
||||
m_button_unbind->SetCornerRadius(10);
|
||||
m_button_unbind->SetCornerRadius(FromDIP(12));
|
||||
|
||||
|
||||
StateColor btn_bg_white(std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Hovered),
|
||||
|
@ -386,7 +386,7 @@ UnBindMachineDilaog::UnBindMachineDilaog(Plater *plater /*= nullptr*/)
|
|||
m_button_cancel->SetSize(BIND_DIALOG_BUTTON_SIZE);
|
||||
m_button_cancel->SetMinSize(BIND_DIALOG_BUTTON_SIZE);
|
||||
m_button_cancel->SetTextColor(BIND_DIALOG_GREY900);
|
||||
m_button_cancel->SetCornerRadius(10);
|
||||
m_button_cancel->SetCornerRadius(FromDIP(12));
|
||||
|
||||
m_sizer_button->Add(m_button_unbind, 0, wxALIGN_CENTER, 0);
|
||||
m_sizer_button->Add(0, 0, 0, wxLEFT, FromDIP(13));
|
||||
|
|
|
@ -113,7 +113,7 @@ CalibrationDialog::CalibrationDialog(Plater *plater)
|
|||
|
||||
calibration_panel->SetSizer(calibration_sizer);
|
||||
calibration_panel->Layout();
|
||||
calibration_sizer->Add(m_calibration_flow, 0, wxALIGN_CENTER_HORIZONTAL | wxEXPAND, 0);
|
||||
calibration_sizer->Add(m_calibration_flow, 0, wxEXPAND, 0);
|
||||
|
||||
StateColor btn_bg_green(std::pair<wxColour, int>(AMS_CONTROL_DISABLE_COLOUR, StateColor::Disabled), std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed),
|
||||
std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered), std::pair<wxColour, int>(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal));
|
||||
|
@ -138,7 +138,7 @@ CalibrationDialog::CalibrationDialog(Plater *plater)
|
|||
cali_right_panel->SetSizer(cali_right_sizer_h);
|
||||
cali_right_panel->Layout();
|
||||
|
||||
sizer_body->Add(cali_right_panel, 0, wxALIGN_CENTER_HORIZONTAL | wxEXPAND, 0);
|
||||
sizer_body->Add(cali_right_panel, 0, wxEXPAND, 0);
|
||||
|
||||
body_panel->SetSizer(sizer_body);
|
||||
body_panel->Layout();
|
||||
|
|
|
@ -209,6 +209,18 @@ bool HMSItem::parse_hms_info(unsigned attr, unsigned code)
|
|||
return result;
|
||||
}
|
||||
|
||||
std::string HMSItem::get_long_error_code()
|
||||
{
|
||||
char buf[64];
|
||||
::sprintf(buf, "%02X%02X%02X00000%1X%04X",
|
||||
this->module_id,
|
||||
this->module_num,
|
||||
this->part_id,
|
||||
(int)this->msg_level,
|
||||
this->msg_code);
|
||||
return std::string(buf);
|
||||
}
|
||||
|
||||
wxString HMSItem::get_module_name(ModuleID module_id)
|
||||
{
|
||||
switch (module_id)
|
||||
|
|
|
@ -240,6 +240,8 @@ public:
|
|||
HMSMessageLevel msg_level = HMS_UNKNOWN;
|
||||
int msg_code = 0;
|
||||
bool parse_hms_info(unsigned attr, unsigned code);
|
||||
std::string get_long_error_code();
|
||||
|
||||
static wxString get_module_name(ModuleID module_id);
|
||||
static wxString get_hms_msg_level_str(HMSMessageLevel level);
|
||||
};
|
||||
|
|
|
@ -44,7 +44,7 @@ DownloadProgressDialog::DownloadProgressDialog(wxString title)
|
|||
m_panel_download->SetSize(wxSize(FromDIP(340), -1));
|
||||
m_panel_download->SetMinSize(wxSize(FromDIP(340), -1));
|
||||
m_panel_download->SetMaxSize(wxSize(FromDIP(340), -1));
|
||||
m_sizer_main->Add(m_panel_download, 0, wxALIGN_CENTER_VERTICAL|wxALL, FromDIP(20));
|
||||
m_sizer_main->Add(m_panel_download, 0, wxALL, FromDIP(20));
|
||||
m_sizer_main->Add(0, 0, 1, wxBOTTOM, 10);
|
||||
|
||||
SetSizer(m_sizer_main);
|
||||
|
|
|
@ -171,7 +171,10 @@ wxSize BitmapTextRenderer::GetSize() const
|
|||
}
|
||||
else
|
||||
#endif // SUPPORTS_MARKUP && wxHAS_GENERIC_DATAVIEWCTRL
|
||||
{
|
||||
size = GetTextExtent(m_value.GetText());
|
||||
size.x = size.x * 9 / 8;
|
||||
}
|
||||
|
||||
if (m_value.GetBitmap().IsOk())
|
||||
size.x += m_value.GetBitmap().GetWidth() + 4;
|
||||
|
|
|
@ -3000,7 +3000,8 @@ void GCodeViewer::load_shells(const Print& print, bool initialized, bool force_p
|
|||
|
||||
const double max_z = print.objects()[0]->model_object()->get_model()->bounding_box().max(2);
|
||||
const PrintConfig& config = print.config();
|
||||
if (extruders_count > 1 && config.enable_prime_tower && (config.print_sequence == PrintSequence::ByLayer)) {
|
||||
if (print.enable_timelapse_print()
|
||||
|| (extruders_count > 1 && config.enable_prime_tower && (config.print_sequence == PrintSequence::ByLayer))) {
|
||||
const float depth = print.wipe_tower_data(extruders_count).depth;
|
||||
const float brim_width = print.wipe_tower_data(extruders_count).brim_width;
|
||||
|
||||
|
@ -3063,8 +3064,10 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
|
|||
case EViewType::ColorPrint: {
|
||||
if (path.cp_color_id >= static_cast<unsigned char>(m_tools.m_tool_colors.size()))
|
||||
color = { 0.5f, 0.5f, 0.5f, 1.0f };
|
||||
else
|
||||
else {
|
||||
color = m_tools.m_tool_colors[path.cp_color_id];
|
||||
color = adjust_color_for_rendering(color);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EViewType::FilamentId: {
|
||||
|
@ -3946,6 +3949,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
//BBS: GUI refactor: move to the right
|
||||
imgui.set_next_window_pos(float(canvas_width - right_margin * m_scale), 0.0f, ImGuiCond_Always, 1.0f, 0.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0,0.0));
|
||||
ImGui::PushStyleColor(ImGuiCol_Separator, ImVec4(1.0f,1.0f,1.0f,0.6f));
|
||||
ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(0.00f, 0.68f, 0.26f, 1.0f));
|
||||
ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(0.00f, 0.68f, 0.26f, 1.0f));
|
||||
|
@ -3979,8 +3983,15 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
const float percent_bar_size = 0;
|
||||
|
||||
bool imperial_units = wxGetApp().app_config->get("use_inches") == "1";
|
||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||
ImVec2 pos_rect = ImGui::GetCursorScreenPos();
|
||||
float window_padding = 4.0f * m_scale;
|
||||
|
||||
auto append_item = [icon_size, percent_bar_size, &imgui, imperial_units](EItemType type, const Color &color, const std::string &label,
|
||||
draw_list->AddRectFilled(ImVec2(pos_rect.x,pos_rect.y - ImGui::GetStyle().WindowPadding.y),
|
||||
ImVec2(pos_rect.x + ImGui::GetWindowWidth() + ImGui::GetFrameHeight(),pos_rect.y + ImGui::GetFrameHeight() + window_padding * 2.5),
|
||||
ImGui::GetColorU32(ImVec4(0,0,0,0.3)));
|
||||
|
||||
auto append_item = [icon_size, percent_bar_size, &imgui, imperial_units,&window_padding,&draw_list,this](EItemType type, const Color &color, const std::string &label,
|
||||
bool visible = true, const std::string& time = "", float percent = 0.0f, float max_percent = 0.0f, const std::array<float, 4>& offsets = { 0.0f, 0.0f, 0.0f, 0.0f },
|
||||
double used_filament_m = 0.0, double used_filament_g = 0.0,
|
||||
std::function<void()> callback = nullptr) {
|
||||
|
@ -3989,13 +4000,13 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.3333f);
|
||||
*/
|
||||
|
||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||
ImVec2 pos = ImGui::GetCursorScreenPos();
|
||||
float dummy_size = icon_size;
|
||||
ImVec2 pos = ImVec2(ImGui::GetCursorScreenPos().x + window_padding * 3, ImGui::GetCursorScreenPos().y);
|
||||
float dummy_size = icon_size * m_scale;
|
||||
|
||||
switch (type) {
|
||||
default:
|
||||
case EItemType::Rect: {
|
||||
draw_list->AddRectFilled({ pos.x + 1.0f, pos.y + 5.0f }, { pos.x + icon_size - 1.0f, pos.y + icon_size + 3.0f },
|
||||
draw_list->AddRectFilled({ pos.x + 1.0f * m_scale, pos.y + 3.0f * m_scale }, { pos.x + icon_size - 1.0f * m_scale, pos.y + icon_size + 1.0f * m_scale },
|
||||
ImGui::GetColorU32({ color[0], color[1], color[2], 1.0f }));
|
||||
break;
|
||||
}
|
||||
|
@ -4019,10 +4030,18 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
}
|
||||
|
||||
// draw text
|
||||
ImGui::Dummy({ dummy_size, dummy_size });
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(20.0, 6.0 * m_scale));
|
||||
ImGui::Dummy({ dummy_size, 0.0 });
|
||||
ImGui::SameLine();
|
||||
if (callback != nullptr) {
|
||||
if (ImGui::MenuItem(label.c_str()))
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f * m_scale);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(20.0 * m_scale,0.0));
|
||||
ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(1.00f, 0.68f, 0.26f, 0.0f));
|
||||
ImGui::PushStyleColor(ImGuiCol_BorderActive, ImVec4(0.00f, 0.68f, 0.26f, 1.00f));
|
||||
bool b_menu_item = ImGui::BBLMenuItem(label.c_str());
|
||||
ImGui::PopStyleVar(2);
|
||||
ImGui::PopStyleColor(2);
|
||||
if (b_menu_item)
|
||||
callback();
|
||||
else {
|
||||
// show tooltip
|
||||
|
@ -4111,6 +4130,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
imgui.text(buf);
|
||||
}*/
|
||||
}
|
||||
ImGui::PopStyleVar(1);
|
||||
|
||||
/* BBS GUI refactor */
|
||||
/*if (!visible)
|
||||
|
@ -4143,10 +4163,10 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
auto append_headers = [&imgui](const std::array<std::string, 5>& texts, const std::array<float, 4>& offsets) {
|
||||
size_t i = 0;
|
||||
for (; i < offsets.size(); i++) {
|
||||
imgui.text(texts[i]);
|
||||
imgui.bold_text(texts[i]);
|
||||
ImGui::SameLine(offsets[i]);
|
||||
}
|
||||
imgui.text(texts[i]);
|
||||
imgui.bold_text(texts[i]);
|
||||
ImGui::Separator();
|
||||
};
|
||||
|
||||
|
@ -4230,6 +4250,9 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
};
|
||||
|
||||
//BBS display Color Scheme
|
||||
ImGui::Dummy({ window_padding, window_padding });
|
||||
ImGui::Dummy({ window_padding, window_padding });
|
||||
ImGui::SameLine();
|
||||
std::wstring btn_name;
|
||||
if (m_fold)
|
||||
btn_name = ImGui::UnfoldButtonIcon + boost::nowide::widen(std::string(""));
|
||||
|
@ -4247,10 +4270,9 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
ImGui::PopStyleColor(3);
|
||||
ImGui::PopStyleVar(1);
|
||||
ImGui::SameLine();
|
||||
ImGui::Text(_u8L("Color Scheme").c_str());
|
||||
imgui.bold_text(_u8L("Color Scheme"));
|
||||
push_combo_style();
|
||||
float combo_width = ImGui::GetContentRegionAvailWidth() - ImGui::CalcTextSize(_u8L("Color Scheme").c_str()).x - button_width - ImGui::GetStyle().FramePadding.x * 4;
|
||||
ImGui::PushItemWidth(combo_width);
|
||||
|
||||
ImGui::SameLine();
|
||||
const char* view_type_value = view_type_items_str[m_view_type_sel].c_str();
|
||||
ImGuiComboFlags flags = 0;
|
||||
|
@ -4276,11 +4298,13 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
ImGui::EndCombo();
|
||||
}
|
||||
pop_combo_style();
|
||||
ImGui::SameLine();
|
||||
ImGui::Dummy({ window_padding, window_padding });
|
||||
|
||||
if (m_fold) {
|
||||
imgui.end();
|
||||
ImGui::PopStyleColor(6);
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopStyleVar(2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4355,6 +4379,8 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
}
|
||||
|
||||
// extrusion paths section -> title
|
||||
ImGui::Dummy({ window_padding, window_padding });
|
||||
ImGui::SameLine();
|
||||
switch (m_view_type)
|
||||
{
|
||||
case EViewType::FeatureType:
|
||||
|
@ -4467,6 +4493,8 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
case EViewType::Feedrate: {
|
||||
append_range(m_extrusions.ranges.feedrate, 0);
|
||||
ImGui::Spacing();
|
||||
ImGui::Dummy({ window_padding, window_padding });
|
||||
ImGui::SameLine();
|
||||
append_headers({_u8L("Options"), "", "", "", _u8L("Display")}, offsets);
|
||||
const bool travel_visible = m_buffers[buffer_id(EMoveType::Travel)].visible;
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 3.0f));
|
||||
|
@ -4596,6 +4624,8 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
max_len += std::max(ImGui::CalcTextSize(filament_change_str.c_str()).x, ImGui::CalcTextSize(flushed_filament_str.c_str()).x);
|
||||
//BBS: display total flushed filament
|
||||
{
|
||||
ImGui::Dummy({window_padding, window_padding});
|
||||
ImGui::SameLine();
|
||||
imgui.text(flushed_filament_str + ":");
|
||||
ImGui::SameLine(max_len);
|
||||
char buf[64];
|
||||
|
@ -4607,6 +4637,8 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
}
|
||||
//BBS display filament change times
|
||||
{
|
||||
ImGui::Dummy({window_padding, window_padding});
|
||||
ImGui::SameLine();
|
||||
imgui.text(filament_change_str + ":");
|
||||
ImGui::SameLine(max_len);
|
||||
char temp_buf[64];
|
||||
|
@ -4962,6 +4994,8 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
}
|
||||
}
|
||||
ImGui::Dummy(ImVec2(0.0f, ImGui::GetFontSize() * 0.1));
|
||||
ImGui::Dummy({ window_padding, window_padding });
|
||||
ImGui::SameLine();
|
||||
imgui.title(time_title);
|
||||
std::string filament_str = _u8L("Filament");
|
||||
std::string prepare_str = _u8L("Prepare time");
|
||||
|
@ -4976,6 +5010,8 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
}
|
||||
|
||||
//BBS display filament cost
|
||||
ImGui::Dummy({ window_padding, window_padding });
|
||||
ImGui::SameLine();
|
||||
imgui.text(filament_str + ":");
|
||||
ImGui::SameLine(max_len);
|
||||
|
||||
|
@ -4997,13 +5033,19 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
};
|
||||
//BBS: start gcode is prepeare time
|
||||
if (role_time(erCustom) != 0.0f) {
|
||||
ImGui::Dummy({ window_padding, window_padding });
|
||||
ImGui::SameLine();
|
||||
imgui.text(prepare_str + ":");
|
||||
ImGui::SameLine(max_len);
|
||||
imgui.text(short_time(get_time_dhms(role_time(erCustom))));
|
||||
}
|
||||
ImGui::Dummy({ window_padding, window_padding });
|
||||
ImGui::SameLine();
|
||||
imgui.text(print_str + ":");
|
||||
ImGui::SameLine(max_len);
|
||||
imgui.text(short_time(get_time_dhms(time_mode.time - role_time(erCustom))));
|
||||
ImGui::Dummy({ window_padding, window_padding });
|
||||
ImGui::SameLine();
|
||||
imgui.text(total_str + ":");
|
||||
ImGui::SameLine(max_len);
|
||||
imgui.text(short_time(get_time_dhms(time_mode.time)));
|
||||
|
@ -5035,16 +5077,17 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
|||
}
|
||||
}
|
||||
legend_height = ImGui::GetCurrentWindow()->Size.y;
|
||||
|
||||
ImGui::Dummy({ window_padding, window_padding});
|
||||
imgui.end();
|
||||
ImGui::PopStyleColor(6);
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopStyleVar(2);
|
||||
}
|
||||
|
||||
void GCodeViewer::push_combo_style()
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8.0,8.0));
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.0f, 0.0f, 0.0f, 0.3f));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.0f, 0.0f, 0.0f, 0.3f));
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.0f, 0.0f, 0.0f, 0.3f));
|
||||
|
@ -5056,7 +5099,7 @@ void GCodeViewer::push_combo_style()
|
|||
}
|
||||
void GCodeViewer::pop_combo_style()
|
||||
{
|
||||
ImGui::PopStyleVar(2);
|
||||
ImGui::PopStyleVar(3);
|
||||
ImGui::PopStyleColor(8);
|
||||
}
|
||||
|
||||
|
|
|
@ -75,8 +75,7 @@ static constexpr const float TRACKBALLSIZE = 0.8f;
|
|||
static const float SLIDER_DEFAULT_RIGHT_MARGIN = 10.0f;
|
||||
static const float SLIDER_DEFAULT_BOTTOM_MARGIN = 10.0f;
|
||||
static const float SLIDER_RIGHT_MARGIN = 105.0f;
|
||||
static const float SLIDER_BOTTOM_MARGIN = 65.0f;
|
||||
|
||||
static const float SLIDER_BOTTOM_MARGIN = 90.0f;
|
||||
|
||||
float GLCanvas3D::DEFAULT_BG_LIGHT_COLOR[3] = { 0.906f, 0.906f, 0.906f };
|
||||
float GLCanvas3D::ERROR_BG_LIGHT_COLOR[3] = { 0.753f, 0.192f, 0.039f };
|
||||
|
@ -1926,7 +1925,11 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
|||
bool wt = dynamic_cast<const ConfigOptionBool*>(m_config->option("enable_prime_tower"))->value;
|
||||
auto co = dynamic_cast<const ConfigOptionEnum<PrintSequence>*>(m_config->option<ConfigOptionEnum<PrintSequence>>("print_sequence"));
|
||||
|
||||
if (filaments_count > 1 && wt && co != nullptr && co->value != PrintSequence::ByObject) {
|
||||
const DynamicPrintConfig &dconfig = wxGetApp().preset_bundle->prints.get_edited_preset().config;
|
||||
const ConfigOption * option = dconfig.option("timelapse_no_toolhead");
|
||||
bool timelapse_enabled = option ? option->getBool() : false;
|
||||
|
||||
if (timelapse_enabled || (filaments_count > 1 && wt && co != nullptr && co->value != PrintSequence::ByObject)) {
|
||||
for (int plate_id = 0; plate_id < n_plates; plate_id++) {
|
||||
DynamicPrintConfig& proj_cfg = wxGetApp().preset_bundle->project_config;
|
||||
float x = dynamic_cast<const ConfigOptionFloats*>(proj_cfg.option("wipe_tower_x"))->get_at(plate_id);
|
||||
|
@ -3828,32 +3831,6 @@ void GLCanvas3D::do_scale(const std::string& snapshot_type)
|
|||
}
|
||||
}
|
||||
|
||||
#if 1
|
||||
// BBS: update Timelapse Wipe Tower according to max height
|
||||
for (unsigned int obj_idx = 0; obj_idx < (unsigned int) m_model->objects.size(); ++obj_idx) {
|
||||
ModelObject *model_object = m_model->objects[obj_idx];
|
||||
if (model_object->is_timelapse_wipe_tower) {
|
||||
for (GLVolume *volume : m_volumes.volumes) {
|
||||
if (volume->composite_id.object_id == obj_idx) {
|
||||
int instance_idx = volume->instance_idx();
|
||||
auto curr_plate = wxGetApp().plater()->get_partplate_list().get_curr_plate();
|
||||
double max_height = curr_plate->estimate_timelapse_wipe_tower_height();
|
||||
float z_factor = max_height / model_object->raw_mesh_bounding_box().size()[2];
|
||||
volume->set_instance_scaling_factor(Vec3d(1.0, 1.0, z_factor));
|
||||
model_object->instances[instance_idx]->set_scaling_factor(Vec3d(1.0, 1.0, z_factor));
|
||||
volume->is_timelapse_wipe_tower = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ensure_on_bed(obj_idx, false);
|
||||
model_object->invalidate_bounding_box();
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//BBS: notify instance updates to part plater list
|
||||
m_selection.notify_instance_update(-1, -1);
|
||||
|
||||
|
@ -5869,6 +5846,9 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale()
|
|||
m_assemble_view_toolbar.set_scale(sc);
|
||||
collapse_toolbar.set_scale(sc);
|
||||
size *= m_retina_helper->get_scale_factor();
|
||||
|
||||
auto *m_notification = wxGetApp().plater()->get_notification_manager();
|
||||
m_notification->set_scale(sc);
|
||||
#else
|
||||
//BBS: GUI refactor: GLToolbar
|
||||
m_main_toolbar.set_icons_size(GLGizmosManager::Default_Icons_Size * scale);
|
||||
|
|
|
@ -805,8 +805,8 @@ void GLToolbar::do_action(GLToolbarItem::EActionType type, int item_id, GLCanvas
|
|||
|
||||
if ((m_type == Normal) && (item->get_state() != GLToolbarItem::Disabled))
|
||||
{
|
||||
// the item may get disabled during the action, if not, set it back to hover state
|
||||
item->set_state(GLToolbarItem::Hover);
|
||||
// the item may get disabled during the action, if not, set it back to normal state
|
||||
item->set_state(GLToolbarItem::Normal);
|
||||
parent.render();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1089,6 +1089,12 @@ void GUI_App::post_init()
|
|||
mainframe->refresh_plugin_tips();
|
||||
});
|
||||
|
||||
// update hms info
|
||||
CallAfter([this] {
|
||||
if (hms_query)
|
||||
hms_query->check_hms_info();
|
||||
});
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "finished post_init";
|
||||
//BBS: remove the single instance currently
|
||||
/*#ifdef _WIN32
|
||||
|
@ -1111,6 +1117,7 @@ GUI_App::GUI_App()
|
|||
, m_app_mode(EAppMode::Editor)
|
||||
, m_em_unit(10)
|
||||
, m_imgui(new ImGuiWrapper())
|
||||
, hms_query(new HMSQuery())
|
||||
//, m_removable_drive_manager(std::make_unique<RemovableDriveManager>())
|
||||
//, m_other_instance_message_handler(std::make_unique<OtherInstanceMessageHandler>())
|
||||
{
|
||||
|
@ -2203,6 +2210,7 @@ __retry:
|
|||
auto bambu_source = Slic3r::NetworkAgent::get_bambu_source_entry();
|
||||
if (!bambu_source) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": can not get bambu source module!";
|
||||
m_networking_compatible = false;
|
||||
if (app_config->get("installed_networking") == "1") {
|
||||
m_networking_need_update = true;
|
||||
}
|
||||
|
@ -2610,6 +2618,10 @@ void GUI_App::recreate_GUI(const wxString& msg_name)
|
|||
obj_list()->set_min_height();
|
||||
update_mode();
|
||||
|
||||
//check hms info for different language
|
||||
if (hms_query)
|
||||
hms_query->check_hms_info();
|
||||
|
||||
//BBS: trigger restore project logic here, and skip confirm
|
||||
plater_->trigger_restore_project(1);
|
||||
|
||||
|
@ -3019,10 +3031,12 @@ std::string GUI_App::handle_web_request(std::string cmd)
|
|||
wxKeyEvent e(wxEVT_CHAR_HOOK);
|
||||
#ifdef __APPLE__
|
||||
e.SetControlDown(cmdKey);
|
||||
e.SetRawControlDown(ctrlKey);
|
||||
#else
|
||||
e.SetControlDown(ctrlKey);
|
||||
#endif
|
||||
e.SetShiftDown(shiftKey);
|
||||
keyCode = keyCode == 188 ? ',' : keyCode;
|
||||
e.m_keyCode = keyCode;
|
||||
e.SetEventObject(mainframe);
|
||||
wxPostEvent(mainframe, e);
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "slic3r/GUI/DeviceManager.hpp"
|
||||
#include "slic3r/Utils/NetworkAgent.hpp"
|
||||
#include "slic3r/GUI/WebViewDialog.hpp"
|
||||
#include "slic3r/GUI/HMS.hpp"
|
||||
#include "slic3r/GUI/Jobs/UpgradeNetworkJob.hpp"
|
||||
#include "../Utils/PrintHost.hpp"
|
||||
|
||||
|
@ -62,6 +63,7 @@ class ParamsPanel;
|
|||
class NotificationManager;
|
||||
struct GUI_InitParams;
|
||||
class ParamsDialog;
|
||||
class HMSQuery;
|
||||
|
||||
|
||||
enum FileType
|
||||
|
@ -264,6 +266,7 @@ private:
|
|||
std::shared_ptr<UpgradeNetworkJob> m_upgrade_network_job;
|
||||
|
||||
VersionInfo version_info;
|
||||
HMSQuery *hms_query { nullptr };
|
||||
|
||||
boost::thread m_sync_update_thread;
|
||||
bool enable_sync = false;
|
||||
|
@ -280,6 +283,7 @@ public:
|
|||
void show_message_box(std::string msg) { wxMessageBox(msg); }
|
||||
EAppMode get_app_mode() const { return m_app_mode; }
|
||||
Slic3r::DeviceManager* getDeviceManager() { return m_device_manager; }
|
||||
HMSQuery* get_hms_query() { return hms_query; }
|
||||
NetworkAgent* getAgent() { return m_agent; }
|
||||
bool is_editor() const { return m_app_mode == EAppMode::Editor; }
|
||||
bool is_gcode_viewer() const { return m_app_mode == EAppMode::GCodeViewer; }
|
||||
|
|
|
@ -459,15 +459,6 @@ wxMenu* MenuFactory::append_submenu_add_generic(wxMenu* menu, ModelVolumeType ty
|
|||
[type, item](wxCommandEvent&) { obj_list()->load_generic_subobject(item, type); }, "", menu);
|
||||
}
|
||||
|
||||
// BBS: only add timelapse tower item for plate
|
||||
if (type == ModelVolumeType::INVALID) {
|
||||
auto item = L("Timelapse Wipe Tower");
|
||||
type = ModelVolumeType::TIMELAPSE_WIPE_TOWER;
|
||||
append_menu_item(sub_menu, wxID_ANY, _(item), "",
|
||||
[type, item](wxCommandEvent &) { obj_list()->load_generic_subobject(item, type); }, "", menu,
|
||||
[]() { return plater()->can_add_timelapse_wt(); }, m_parent);
|
||||
}
|
||||
|
||||
return sub_menu;
|
||||
}
|
||||
|
||||
|
@ -1392,8 +1383,8 @@ void MenuFactory::append_menu_item_locked(wxMenu* menu)
|
|||
m_parent->Bind(wxEVT_UPDATE_UI, [](wxUpdateUIEvent& evt) {
|
||||
PartPlate* plate = plater()->get_partplate_list().get_selected_plate();
|
||||
assert(plate);
|
||||
bool check = plate->is_locked();
|
||||
evt.Check(check);
|
||||
//bool check = plate->is_locked();
|
||||
//evt.Check(check);
|
||||
plater()->set_current_canvas_as_dirty();
|
||||
}, item->GetId());
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <wx/progdlg.h>
|
||||
#include <wx/listbook.h>
|
||||
#include <wx/numformatter.h>
|
||||
#include <wx/headerctrl.h>
|
||||
|
||||
#include "slic3r/Utils/FixModelByWin10.hpp"
|
||||
#include "libslic3r/Format/bbs_3mf.hpp"
|
||||
|
@ -75,7 +76,11 @@ ObjectList::ObjectList(wxWindow* parent) :
|
|||
wxDataViewCtrl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxDV_MULTIPLE)
|
||||
{
|
||||
wxGetApp().UpdateDVCDarkUI(this, true);
|
||||
|
||||
SetFont(Label::sysFont(13));
|
||||
#ifdef __WXMSW__
|
||||
GenericGetHeader()->SetFont(Label::sysFont(13));
|
||||
#endif
|
||||
|
||||
// create control
|
||||
create_objects_ctrl();
|
||||
|
||||
|
@ -1864,7 +1869,7 @@ static TriangleMesh create_mesh(const std::string& type_name, const BoundingBoxf
|
|||
const double side = wxGetApp().plater()->canvas3D()->get_size_proportional_to_max_bed_size(0.1);
|
||||
|
||||
indexed_triangle_set mesh;
|
||||
if (type_name == "Cube" || type_name == "Timelapse Wipe Tower")
|
||||
if (type_name == "Cube")
|
||||
// Sitting on the print bed, left front front corner at (0, 0).
|
||||
mesh = its_make_cube(side, side, side);
|
||||
else if (type_name == "Cylinder")
|
||||
|
@ -1892,10 +1897,6 @@ void ObjectList::load_generic_subobject(const std::string& type_name, const Mode
|
|||
load_shape_object(type_name);
|
||||
return;
|
||||
}
|
||||
else if (type == ModelVolumeType::TIMELAPSE_WIPE_TOWER) {
|
||||
load_shape_object(type_name, true);
|
||||
return;
|
||||
}
|
||||
|
||||
const int obj_idx = get_selected_obj_idx();
|
||||
if (obj_idx < 0)
|
||||
|
@ -1999,7 +2000,7 @@ void ObjectList::load_generic_subobject(const std::string& type_name, const Mode
|
|||
}
|
||||
}
|
||||
|
||||
void ObjectList::load_shape_object(const std::string &type_name, bool is_timelapse_wt)
|
||||
void ObjectList::load_shape_object(const std::string &type_name)
|
||||
{
|
||||
const Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
||||
//assert(selection.get_object_idx() == -1); // Add nothing is something is selected on 3DScene
|
||||
|
@ -2016,11 +2017,11 @@ void ObjectList::load_shape_object(const std::string &type_name, bool is_timelap
|
|||
BoundingBoxf3 bb;
|
||||
TriangleMesh mesh = create_mesh(type_name, bb);
|
||||
// BBS: remove "Shape" prefix
|
||||
load_mesh_object(mesh, _(type_name), true, is_timelapse_wt);
|
||||
load_mesh_object(mesh, _(type_name));
|
||||
wxGetApp().mainframe->update_title();
|
||||
}
|
||||
|
||||
void ObjectList::load_mesh_object(const TriangleMesh &mesh, const wxString &name, bool center, bool is_timelapse_wt)
|
||||
void ObjectList::load_mesh_object(const TriangleMesh &mesh, const wxString &name, bool center)
|
||||
{
|
||||
// Add mesh to model as a new object
|
||||
Model& model = wxGetApp().plater()->model();
|
||||
|
@ -2044,27 +2045,11 @@ void ObjectList::load_mesh_object(const TriangleMesh &mesh, const wxString &name
|
|||
new_object->invalidate_bounding_box();
|
||||
new_object->translate(-bb.center());
|
||||
|
||||
if (is_timelapse_wt) {
|
||||
new_object->is_timelapse_wipe_tower = true;
|
||||
auto curr_plate = wxGetApp().plater()->get_partplate_list().get_curr_plate();
|
||||
int highest_extruder = 0;
|
||||
double max_height = curr_plate->estimate_timelapse_wipe_tower_height(&highest_extruder);
|
||||
new_object->scale(1, 1, max_height / new_object->bounding_box().size()[2]);
|
||||
// BBS: find an empty cell to put the copied object
|
||||
auto start_point = wxGetApp().plater()->build_volume().bounding_volume2d().center();
|
||||
auto empty_cell = wxGetApp().plater()->canvas3D()->get_nearest_empty_cell({start_point(0), start_point(1)});
|
||||
|
||||
// move to garbage bin of curr plate
|
||||
auto offset = curr_plate->get_origin() + Vec3d(80.0, 230.0, -new_object->origin_translation.z());
|
||||
new_object->instances[0]->set_offset(offset);
|
||||
|
||||
new_object->config.set_key_value("sparse_infill_density", new ConfigOptionPercent(0));
|
||||
new_object->config.set_key_value("top_shell_layers", new ConfigOptionInt(0));
|
||||
new_object->config.set("extruder", highest_extruder);
|
||||
} else {
|
||||
// BBS: find an empty cell to put the copied object
|
||||
auto start_point = wxGetApp().plater()->build_volume().bounding_volume2d().center();
|
||||
auto empty_cell = wxGetApp().plater()->canvas3D()->get_nearest_empty_cell({start_point(0), start_point(1)});
|
||||
|
||||
new_object->instances[0]->set_offset(center ? to_3d(Vec2d(empty_cell(0), empty_cell(1)), -new_object->origin_translation.z()) : bb.center());
|
||||
}
|
||||
new_object->instances[0]->set_offset(center ? to_3d(Vec2d(empty_cell(0), empty_cell(1)), -new_object->origin_translation.z()) : bb.center());
|
||||
|
||||
new_object->ensure_on_bed();
|
||||
|
||||
|
@ -2760,11 +2745,6 @@ bool ObjectList::can_merge_to_multipart_object() const
|
|||
for (wxDataViewItem item : sels) {
|
||||
if (!(m_objects_model->GetItemType(item) & (itObject | itInstance)))
|
||||
return false;
|
||||
|
||||
// BBS: do not support to merge timelapse wipe tower with other objects
|
||||
ObjectDataViewModelNode* node = static_cast<ObjectDataViewModelNode*>(item.GetID());
|
||||
if (node != nullptr && node->IsTimelapseWipeTower())
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -279,8 +279,8 @@ public:
|
|||
//void load_part(ModelObject& model_object, std::vector<ModelVolume*>& added_volumes, ModelVolumeType type, bool from_galery = false);
|
||||
void load_modifier(const wxArrayString& input_files, ModelObject& model_object, std::vector<ModelVolume*>& added_volumes, ModelVolumeType type, bool from_galery = false);
|
||||
void load_generic_subobject(const std::string& type_name, const ModelVolumeType type);
|
||||
void load_shape_object(const std::string &type_name, bool is_timelapse_wt = false);
|
||||
void load_mesh_object(const TriangleMesh &mesh, const wxString &name, bool center = true, bool is_timelapse_wt = false);
|
||||
void load_shape_object(const std::string &type_name);
|
||||
void load_mesh_object(const TriangleMesh &mesh, const wxString &name, bool center = true);
|
||||
void del_object(const int obj_idx, bool refresh_immediately = true);
|
||||
void del_subobject_item(wxDataViewItem& item);
|
||||
void del_settings_from_config(const wxDataViewItem& parent_item);
|
||||
|
|
|
@ -2911,7 +2911,7 @@ ObjectTableDialog::ObjectTableDialog(wxWindow* parent, Plater* platerObj, Model
|
|||
wxSize panel_size = m_obj_panel->get_init_size();
|
||||
g_max_size_from_parent = maxSize;
|
||||
if ((maxSize.GetWidth() == -1) || (maxSize.GetHeight() == -1)) {
|
||||
wxDisplay display(wxDisplay::GetFromWindow(this));
|
||||
wxDisplay display(this);
|
||||
//auto drect = display.GetGeometry();
|
||||
wxRect client_area = display.GetClientArea ();
|
||||
g_max_size_from_parent.SetWidth(client_area.GetWidth());
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "slic3r/GUI/Plater.hpp"
|
||||
#include "slic3r/GUI/GUI_ObjectList.hpp"
|
||||
#include "slic3r/GUI/format.hpp"
|
||||
#include "slic3r/GUI/GUI.hpp"
|
||||
#include "slic3r/Utils/UndoRedo.hpp"
|
||||
|
||||
|
||||
|
@ -181,12 +182,6 @@ void GLGizmoFdmSupports::on_set_state()
|
|||
}
|
||||
}
|
||||
|
||||
static std::string into_u8(const wxString& str)
|
||||
{
|
||||
auto buffer_utf8 = str.utf8_str();
|
||||
return std::string(buffer_utf8.data());
|
||||
}
|
||||
|
||||
void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_limit)
|
||||
{
|
||||
init_print_instance();
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "slic3r/GUI/format.hpp"
|
||||
#include "slic3r/GUI/GUI_ObjectList.hpp"
|
||||
#include "slic3r/GUI/NotificationManager.hpp"
|
||||
#include "slic3r/GUI/GUI.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "slic3r/Utils/UndoRedo.hpp"
|
||||
|
@ -291,12 +292,6 @@ static void render_extruders_combo(const std::string &labe
|
|||
selection_idx = selection_out;
|
||||
}
|
||||
|
||||
static std::string into_u8(const wxString& str)
|
||||
{
|
||||
auto buffer_utf8 = str.utf8_str();
|
||||
return std::string(buffer_utf8.data());
|
||||
}
|
||||
|
||||
void GLGizmoMmuSegmentation::show_tooltip_information(float caption_max, float x, float y)
|
||||
{
|
||||
ImTextureID normal_id = m_parent.get_gizmos_manager().get_icon_texture_id(GLGizmosManager::MENU_ICON_NAME::IC_TOOLBAR_TOOLTIP);
|
||||
|
|
|
@ -1064,7 +1064,10 @@ void TriangleSelectorPatch::render(ImGuiWrapper* imgui)
|
|||
size_t color_idx = (size_t)patch.type;
|
||||
color = m_ebt_colors[color_idx];
|
||||
}
|
||||
shader->set_uniform("uniform_color", color);
|
||||
//to make black not too hard too see
|
||||
std::array<float, 4> new_color = adjust_color_for_rendering(color);
|
||||
shader->set_uniform("uniform_color", new_color);
|
||||
//shader->set_uniform("uniform_color", color);
|
||||
this->render(buffer_idx);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "slic3r/GUI/ImGuiWrapper.hpp"
|
||||
#include "slic3r/GUI/Plater.hpp"
|
||||
#include "slic3r/GUI/GUI_ObjectList.hpp"
|
||||
#include "slic3r/GUI/GUI.hpp"
|
||||
#include "slic3r/Utils/UndoRedo.hpp"
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
@ -155,12 +156,6 @@ void GLGizmoSeam::tool_changed(wchar_t old_tool, wchar_t new_tool)
|
|||
}
|
||||
}
|
||||
|
||||
static std::string into_u8(const wxString& str)
|
||||
{
|
||||
auto buffer_utf8 = str.utf8_str();
|
||||
return std::string(buffer_utf8.data());
|
||||
}
|
||||
|
||||
void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit)
|
||||
{
|
||||
if (! m_c->selection_info()->model_object())
|
||||
|
|
281
src/slic3r/GUI/HMS.cpp
Normal file
281
src/slic3r/GUI/HMS.cpp
Normal file
|
@ -0,0 +1,281 @@
|
|||
#include "HMS.hpp"
|
||||
|
||||
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
int get_hms_info_version(std::string& version)
|
||||
{
|
||||
AppConfig* config = wxGetApp().app_config;
|
||||
if (!config)
|
||||
return -1;
|
||||
std::string hms_host = config->get_hms_host();
|
||||
if(hms_host.empty()) {
|
||||
BOOST_LOG_TRIVIAL(error) << "hms_host is empty";
|
||||
return -1;
|
||||
}
|
||||
int result = -1;
|
||||
version = "";
|
||||
std::string url = (boost::format("https://%1%/GetVersion.php") % hms_host).str();
|
||||
Slic3r::Http http = Slic3r::Http::get(url);
|
||||
http.timeout_max(10)
|
||||
.on_complete([&result, &version](std::string body, unsigned status){
|
||||
try {
|
||||
json j = json::parse(body);
|
||||
if (j.contains("ver")) {
|
||||
version = std::to_string(j["ver"].get<long long>());
|
||||
}
|
||||
} catch (...) {
|
||||
;
|
||||
}
|
||||
})
|
||||
.on_error([&result](std::string body, std::string error, unsigned status) {
|
||||
BOOST_LOG_TRIVIAL(error) << "get_hms_info_version: body = " << body << ", status = " << status << ", error = " << error;
|
||||
result = -1;
|
||||
})
|
||||
.perform_sync();
|
||||
return result;
|
||||
}
|
||||
|
||||
int HMSQuery::download_hms_info()
|
||||
{
|
||||
AppConfig* config = wxGetApp().app_config;
|
||||
if (!config) return -1;
|
||||
|
||||
std::string hms_host = wxGetApp().app_config->get_hms_host();
|
||||
std::string lang_code = wxGetApp().app_config->get_language_code();
|
||||
std::string url = (boost::format("https://%1%/query.php?lang=%2%") % hms_host % lang_code).str();
|
||||
|
||||
Slic3r::Http http = Slic3r::Http::get(url);
|
||||
|
||||
http.on_complete([this](std::string body, unsigned status) {
|
||||
try {
|
||||
json j = json::parse(body);
|
||||
if (j.contains("result")) {
|
||||
if (j["result"] == 0 && j.contains("data")) {
|
||||
this->m_hms_json = j["data"];
|
||||
if (j.contains("ver"))
|
||||
m_hms_json["version"] = std::to_string(j["ver"].get<long long>());
|
||||
} else {
|
||||
this->m_hms_json.clear();
|
||||
BOOST_LOG_TRIVIAL(info) << "HMSQuery: update hms info error = " << j["result"].get<int>();
|
||||
}
|
||||
}
|
||||
} catch (...) {
|
||||
;
|
||||
}
|
||||
})
|
||||
.timeout_max(20)
|
||||
.on_error([](std::string body, std::string error, unsigned status) {
|
||||
BOOST_LOG_TRIVIAL(error) << "HMSQuery: update hms info error = " << error << ", body = " << body << ", status = " << status;
|
||||
}).perform_sync();
|
||||
|
||||
save_to_local();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int HMSQuery::load_from_local(std::string &version_info)
|
||||
{
|
||||
if (data_dir().empty()) {
|
||||
version_info = "";
|
||||
BOOST_LOG_TRIVIAL(error) << "HMS: load_from_local, data_dir() is empty";
|
||||
return -1;
|
||||
}
|
||||
std::string filename = get_hms_file();
|
||||
std::string dir_str = (boost::filesystem::path(data_dir()) / filename).make_preferred().string();
|
||||
std::ifstream json_file(encode_path(dir_str.c_str()));
|
||||
try {
|
||||
if (json_file.is_open()) {
|
||||
json_file >> m_hms_json;
|
||||
if (m_hms_json.contains("version")) {
|
||||
version_info = m_hms_json["version"].get<std::string>();
|
||||
return 0;
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(warning) << "HMS: load_from_local, no version info";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} catch(...) {
|
||||
version_info = "";
|
||||
return -1;
|
||||
}
|
||||
version_info = "";
|
||||
return 0;
|
||||
}
|
||||
|
||||
int HMSQuery::save_to_local()
|
||||
{
|
||||
if (data_dir().empty()) {
|
||||
BOOST_LOG_TRIVIAL(error) << "HMS: save_to_local, data_dir() is empty";
|
||||
return -1;
|
||||
}
|
||||
std::string filename = get_hms_file();
|
||||
std::string dir_str = (boost::filesystem::path(data_dir()) / filename).make_preferred().string();
|
||||
std::ofstream json_file(encode_path(dir_str.c_str()));
|
||||
if (json_file.is_open()) {
|
||||
json_file << std::setw(4) << m_hms_json << std::endl;
|
||||
json_file.close();
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::string HMSQuery::get_hms_file()
|
||||
{
|
||||
AppConfig* config = wxGetApp().app_config;
|
||||
if (!config)
|
||||
return HMS_INFO_FILE;
|
||||
std::string lang_code = wxGetApp().app_config->get_language_code();
|
||||
return (boost::format("hms_%1%.json") % lang_code).str();
|
||||
}
|
||||
|
||||
wxString HMSQuery::query_hms_msg(std::string long_error_code)
|
||||
{
|
||||
if (long_error_code.empty())
|
||||
return wxEmptyString;
|
||||
AppConfig* config = wxGetApp().app_config;
|
||||
if (!config) return wxEmptyString;
|
||||
|
||||
std::string hms_host = wxGetApp().app_config->get_hms_host();
|
||||
std::string lang_code = wxGetApp().app_config->get_language_code();
|
||||
|
||||
if (m_hms_json.contains("device_hms")) {
|
||||
if (m_hms_json["device_hms"].contains(lang_code)) {
|
||||
for (auto item = m_hms_json["device_hms"][lang_code].begin(); item != m_hms_json["device_hms"][lang_code].end(); item++) {
|
||||
if (item->contains("ecode") && (*item)["ecode"].get<std::string>() == long_error_code) {
|
||||
if (item->contains("intro")) {
|
||||
return wxString::FromUTF8((*item)["intro"].get<std::string>());
|
||||
}
|
||||
}
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << "hms: query_hms_msg, not found error_code = " << long_error_code;
|
||||
}
|
||||
} else {
|
||||
return wxEmptyString;
|
||||
}
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
wxString HMSQuery::query_error_msg(std::string error_code)
|
||||
{
|
||||
AppConfig* config = wxGetApp().app_config;
|
||||
if (!config) return wxEmptyString;
|
||||
|
||||
std::string hms_host = wxGetApp().app_config->get_hms_host();
|
||||
std::string lang_code = wxGetApp().app_config->get_language_code();
|
||||
|
||||
if (m_hms_json.contains("device_error")) {
|
||||
if (m_hms_json["device_error"].contains(lang_code)) {
|
||||
for (auto item = m_hms_json["device_error"][lang_code].begin(); item != m_hms_json["device_error"][lang_code].end(); item++) {
|
||||
if (item->contains("ecode") && (*item)["ecode"].get<std::string>() == error_code) {
|
||||
if (item->contains("intro")) {
|
||||
return wxString::FromUTF8((*item)["intro"].get<std::string>());
|
||||
}
|
||||
}
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << "hms: query_error_msg, not found error_code = " << error_code;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return wxEmptyString;
|
||||
}
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
wxString HMSQuery::query_print_error_msg(int print_error)
|
||||
{
|
||||
char buf[32];
|
||||
::sprintf(buf, "%08X", print_error);
|
||||
return query_error_msg(std::string(buf));
|
||||
}
|
||||
|
||||
int HMSQuery::check_hms_info()
|
||||
{
|
||||
int result = 0;
|
||||
bool download_new_hms_info = true;
|
||||
|
||||
// load local hms json file
|
||||
std::string version = "";
|
||||
if (load_from_local(version) == 0) {
|
||||
BOOST_LOG_TRIVIAL(info) << "HMS: check_hms_info current version = " << version;
|
||||
std::string new_version;
|
||||
get_hms_info_version(new_version);
|
||||
BOOST_LOG_TRIVIAL(info) << "HMS: check_hms_info latest version = " << new_version;
|
||||
if (!version.empty() && version == new_version) {
|
||||
download_new_hms_info = false;
|
||||
}
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << "HMS: check_hms_info need download new hms info = " << download_new_hms_info;
|
||||
// download if version is update
|
||||
if (download_new_hms_info) {
|
||||
result = download_hms_info();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string get_hms_wiki_url(std::string error_code)
|
||||
{
|
||||
AppConfig* config = wxGetApp().app_config;
|
||||
if (!config) return "";
|
||||
|
||||
std::string hms_host = wxGetApp().app_config->get_hms_host();
|
||||
std::string lang_code = wxGetApp().app_config->get_language_code();
|
||||
std::string url = (boost::format("https://%1%/index.php?e=%2%&s=device_hms&lang=%3%")
|
||||
% hms_host
|
||||
% error_code
|
||||
% lang_code).str();
|
||||
return url;
|
||||
}
|
||||
|
||||
std::string get_error_message(int error_code)
|
||||
{
|
||||
char buf[64];
|
||||
std::string result_str = "";
|
||||
std::sprintf(buf,"%08X",error_code);
|
||||
std::string hms_host = wxGetApp().app_config->get_hms_host();
|
||||
std::string get_lang = wxGetApp().app_config->get_language_code();
|
||||
|
||||
std::string url = (boost::format("https://%1%/query.php?lang=%2%&e=%3%")
|
||||
%hms_host
|
||||
%get_lang
|
||||
%buf).str();
|
||||
|
||||
Slic3r::Http http = Slic3r::Http::get(url);
|
||||
http.header("accept", "application/json")
|
||||
.timeout_max(10)
|
||||
.on_complete([get_lang, &result_str](std::string body, unsigned status) {
|
||||
try {
|
||||
json j = json::parse(body);
|
||||
if (j.contains("result")) {
|
||||
if (j["result"].get<int>() == 0) {
|
||||
if (j.contains("data")) {
|
||||
json jj = j["data"];
|
||||
if (jj.contains("device_error")) {
|
||||
if (jj["device_error"].contains(get_lang)) {
|
||||
if (jj["device_error"][get_lang].size() > 0) {
|
||||
if (!jj["device_error"][get_lang][0]["intro"].empty() || !jj["device_error"][get_lang][0]["ecode"].empty()) {
|
||||
std::string error_info = jj["device_error"][get_lang][0]["intro"].get<std::string>();
|
||||
std::string error_code = jj["device_error"][get_lang][0]["ecode"].get<std::string>();
|
||||
error_code.insert(4, " ");
|
||||
result_str = from_u8(error_info).ToStdString() + "[" + error_code + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (...) {
|
||||
;
|
||||
}
|
||||
})
|
||||
.on_error([](std::string body, std::string error, unsigned status) {
|
||||
BOOST_LOG_TRIVIAL(trace) << boost::format("[BBL ErrorMessage]: status=%1%, error=%2%, body=%3%") % status % error % body;
|
||||
}).perform_sync();
|
||||
|
||||
return result_str;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
45
src/slic3r/GUI/HMS.hpp
Normal file
45
src/slic3r/GUI/HMS.hpp
Normal file
|
@ -0,0 +1,45 @@
|
|||
#ifndef slic3r_HMS_hpp_
|
||||
#define slic3r_HMS_hpp_
|
||||
|
||||
#include "GUI_App.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "Widgets/Label.hpp"
|
||||
#include "Widgets/Button.hpp"
|
||||
#include "Widgets/StepCtrl.hpp"
|
||||
#include "BitmapCache.hpp"
|
||||
#include "slic3r/Utils/Http.hpp"
|
||||
#include "libslic3r/Thread.hpp"
|
||||
#include "nlohmann/json.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
#define HMS_INFO_FILE "hms.json"
|
||||
|
||||
class HMSQuery {
|
||||
protected:
|
||||
json m_hms_json;
|
||||
int download_hms_info();
|
||||
int load_from_local(std::string& version_info);
|
||||
int save_to_local();
|
||||
std::string get_hms_file();
|
||||
public:
|
||||
HMSQuery() {}
|
||||
int check_hms_info();
|
||||
wxString query_hms_msg(std::string long_error_code);
|
||||
wxString query_error_msg(std::string error_code);
|
||||
wxString query_print_error_msg(int print_error);
|
||||
};
|
||||
|
||||
int get_hms_info_version(std::string &version);
|
||||
|
||||
std::string get_hms_wiki_url(std::string code);
|
||||
|
||||
std::string get_error_message(int error_code);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -1,11 +1,124 @@
|
|||
#include "HMS.hpp"
|
||||
#include "HMSPanel.hpp"
|
||||
#include <slic3r/GUI/Widgets/Label.hpp>
|
||||
#include <slic3r/GUI/I18N.hpp>
|
||||
#include "GUI.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
#define HMS_NOTIFY_ITEM_TEXT_SIZE wxSize(FromDIP(730), -1)
|
||||
#define HMS_NOTIFY_ITEM_SIZE wxSize(-1, FromDIP(80))
|
||||
|
||||
HMSNotifyItem::HMSNotifyItem(wxWindow *parent, HMSItem& item)
|
||||
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
|
||||
, m_hms_item(item)
|
||||
, m_url(get_hms_wiki_url(item.get_long_error_code()))
|
||||
{
|
||||
init_bitmaps();
|
||||
|
||||
this->SetBackgroundColour(*wxWHITE);
|
||||
|
||||
auto main_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
m_panel_hms = new wxPanel(this, wxID_ANY, wxDefaultPosition, HMS_NOTIFY_ITEM_SIZE, wxTAB_TRAVERSAL);
|
||||
auto m_panel_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
auto m_panel_sizer_inner = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
m_bitmap_notify = new wxStaticBitmap(m_panel_hms, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0);
|
||||
m_bitmap_notify->SetBitmap(get_notify_bitmap());
|
||||
|
||||
m_hms_content = new wxStaticText(m_panel_hms, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
|
||||
m_hms_content->SetSize(HMS_NOTIFY_ITEM_TEXT_SIZE);
|
||||
m_hms_content->SetMinSize(HMS_NOTIFY_ITEM_TEXT_SIZE);
|
||||
m_hms_content->SetLabelText(_L(wxGetApp().get_hms_query()->query_hms_msg(m_hms_item.get_long_error_code())));
|
||||
m_hms_content->Wrap(HMS_NOTIFY_ITEM_TEXT_SIZE.GetX());
|
||||
|
||||
m_bitmap_arrow = new wxStaticBitmap(m_panel_hms, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0);
|
||||
if (!m_url.empty())
|
||||
m_bitmap_arrow->SetBitmap(m_img_arrow);
|
||||
|
||||
m_panel_sizer_inner->Add(m_bitmap_notify, 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
m_panel_sizer_inner->AddSpacer(FromDIP(8));
|
||||
m_panel_sizer_inner->Add(m_hms_content, 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
m_panel_sizer_inner->AddStretchSpacer();
|
||||
m_panel_sizer_inner->Add(m_bitmap_arrow, 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
|
||||
m_panel_sizer->Add(m_panel_sizer_inner, 1, wxEXPAND | wxALL, FromDIP(20));
|
||||
|
||||
m_staticline = new wxPanel(m_panel_hms, wxID_DELETE, wxDefaultPosition, wxSize(-1, FromDIP(1)));
|
||||
m_staticline->SetBackgroundColour(wxColour(238, 238, 238));
|
||||
|
||||
m_panel_sizer->Add(m_staticline, 0, wxLEFT | wxRIGHT | wxEXPAND, FromDIP(20));
|
||||
|
||||
m_panel_hms->SetSizer(m_panel_sizer);
|
||||
m_panel_hms->Layout();
|
||||
m_panel_sizer->Fit(m_panel_hms);
|
||||
|
||||
main_sizer->Add(m_panel_hms, 0, wxEXPAND, 0);
|
||||
|
||||
this->SetSizer(main_sizer);
|
||||
this->Layout();
|
||||
|
||||
m_hms_content->Bind(wxEVT_ENTER_WINDOW, [this](wxMouseEvent &e) {
|
||||
e.Skip();
|
||||
if (!m_url.empty()) {
|
||||
auto font = m_hms_content->GetFont();
|
||||
font.SetUnderlined(true);
|
||||
m_hms_content->SetFont(font);
|
||||
Layout();
|
||||
SetCursor(wxCURSOR_HAND);
|
||||
}
|
||||
});
|
||||
m_hms_content->Bind(wxEVT_LEAVE_WINDOW, [this](wxMouseEvent &e) {
|
||||
e.Skip();
|
||||
if (!m_url.empty()) {
|
||||
auto font = m_hms_content->GetFont();
|
||||
font.SetUnderlined(false);
|
||||
m_hms_content->SetFont(font);
|
||||
Layout();
|
||||
SetCursor(wxCURSOR_ARROW);
|
||||
}
|
||||
});
|
||||
m_hms_content->Bind(wxEVT_LEFT_UP, [this](wxMouseEvent &e) {
|
||||
if(!m_url.empty())
|
||||
wxLaunchDefaultBrowser(get_hms_wiki_url(m_hms_item.get_long_error_code()));
|
||||
});
|
||||
}
|
||||
HMSNotifyItem ::~HMSNotifyItem() {
|
||||
;
|
||||
}
|
||||
|
||||
void HMSNotifyItem::init_bitmaps() {
|
||||
m_img_notify_lv1 = create_scaled_bitmap("hms_notify_lv1", nullptr, 18);
|
||||
m_img_notify_lv2 = create_scaled_bitmap("hms_notify_lv2", nullptr, 18);
|
||||
m_img_notify_lv3 = create_scaled_bitmap("hms_notify_lv3", nullptr, 18);
|
||||
m_img_arrow = create_scaled_bitmap("hms_arrow", nullptr, 14);
|
||||
}
|
||||
|
||||
wxBitmap & HMSNotifyItem::get_notify_bitmap()
|
||||
{
|
||||
switch (m_hms_item.msg_level) {
|
||||
case (HMS_FATAL):
|
||||
return m_img_notify_lv1;
|
||||
break;
|
||||
case (HMS_SERIOUS):
|
||||
return m_img_notify_lv2;
|
||||
break;
|
||||
case (HMS_COMMON):
|
||||
return m_img_notify_lv3;
|
||||
break;
|
||||
case (HMS_INFO):
|
||||
//return m_img_notify_lv4;
|
||||
break;
|
||||
case (HMS_UNKNOWN):
|
||||
case (HMS_MSG_LEVEL_MAX):
|
||||
default: break;
|
||||
}
|
||||
return wxNullBitmap;
|
||||
}
|
||||
|
||||
HMSPanel::HMSPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style)
|
||||
:wxPanel(parent, id, pos, size, style)
|
||||
|
@ -19,39 +132,46 @@ HMSPanel::HMSPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wx
|
|||
|
||||
m_top_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
m_hms_content = new wxTextCtrl(m_scrolledWindow, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxTE_AUTO_URL | wxTE_MULTILINE);
|
||||
|
||||
m_top_sizer->Add(m_hms_content, 1, wxALL | wxEXPAND, 0);
|
||||
m_top_sizer->AddSpacer(FromDIP(30));
|
||||
|
||||
m_scrolledWindow->SetSizerAndFit(m_top_sizer);
|
||||
|
||||
m_main_sizer->Add(m_scrolledWindow, 1, wxALIGN_CENTER_HORIZONTAL | wxEXPAND, 0);
|
||||
m_main_sizer->Add(m_scrolledWindow, 1, wxEXPAND, 0);
|
||||
|
||||
this->SetSizerAndFit(m_main_sizer);
|
||||
|
||||
|
||||
Layout();
|
||||
}
|
||||
|
||||
HMSPanel::~HMSPanel() {
|
||||
;
|
||||
}
|
||||
|
||||
void HMSPanel::append_hms_panel(HMSItem& item) {
|
||||
m_notify_item = new HMSNotifyItem(m_scrolledWindow, item);
|
||||
m_top_sizer->Add(m_notify_item, 0, wxALIGN_CENTER_HORIZONTAL);
|
||||
}
|
||||
|
||||
void HMSPanel::delete_hms_panels() {
|
||||
m_scrolledWindow->DestroyChildren();
|
||||
}
|
||||
|
||||
void HMSPanel::update(MachineObject *obj)
|
||||
{
|
||||
if (obj) {
|
||||
this->Freeze();
|
||||
delete_hms_panels();
|
||||
wxString hms_text;
|
||||
for (auto item : obj->hms_list) {
|
||||
hms_text += wxString::Format("Module_ID = %s, module_num = %d,part_id = %d, msg level = %s msg code: 0x%x\n",
|
||||
HMSItem::get_module_name(item.module_id),
|
||||
item.module_num,
|
||||
item.part_id,
|
||||
HMSItem::get_hms_msg_level_str(item.msg_level),
|
||||
(unsigned)item.msg_code);
|
||||
if (wxGetApp().get_hms_query()) {
|
||||
append_hms_panel(item);
|
||||
}
|
||||
}
|
||||
m_hms_content->SetLabelText(hms_text);
|
||||
Layout();
|
||||
this->Thaw();
|
||||
} else {
|
||||
m_hms_content->SetLabelText("");
|
||||
delete_hms_panels();
|
||||
Layout();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,5 +180,4 @@ bool HMSPanel::Show(bool show)
|
|||
return wxPanel::Show(show);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}}
|
|
@ -6,17 +6,47 @@
|
|||
#include <slic3r/GUI/Widgets/Button.hpp>
|
||||
#include <slic3r/GUI/DeviceManager.hpp>
|
||||
#include <slic3r/GUI/Widgets/ScrolledWindow.hpp>
|
||||
#include <wx/html/htmlwin.h>
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
class HMSNotifyItem : public wxPanel
|
||||
{
|
||||
HMSItem & m_hms_item;
|
||||
std::string m_url;
|
||||
|
||||
wxPanel * m_panel_hms;
|
||||
wxStaticBitmap *m_bitmap_notify;
|
||||
wxStaticBitmap *m_bitmap_arrow;
|
||||
wxStaticText * m_hms_content;
|
||||
wxHtmlWindow * m_html;
|
||||
wxPanel * m_staticline;
|
||||
|
||||
wxBitmap m_img_notify_lv1;
|
||||
wxBitmap m_img_notify_lv2;
|
||||
wxBitmap m_img_notify_lv3;
|
||||
wxBitmap m_img_arrow;
|
||||
|
||||
void init_bitmaps();
|
||||
wxBitmap & get_notify_bitmap();
|
||||
|
||||
public:
|
||||
HMSNotifyItem(wxWindow *parent, HMSItem& item);
|
||||
~HMSNotifyItem();
|
||||
|
||||
void msw_rescale() {}
|
||||
};
|
||||
|
||||
class HMSPanel : public wxPanel
|
||||
{
|
||||
protected:
|
||||
wxScrolledWindow* m_scrolledWindow;
|
||||
wxBoxSizer* m_top_sizer;
|
||||
wxTextCtrl* m_hms_content;
|
||||
wxScrolledWindow *m_scrolledWindow;
|
||||
wxBoxSizer * m_top_sizer;
|
||||
HMSNotifyItem * m_notify_item;
|
||||
|
||||
void append_hms_panel(HMSItem &item);
|
||||
void delete_hms_panels();
|
||||
|
||||
public:
|
||||
HMSPanel(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, long style = wxTAB_TRAVERSAL);
|
||||
|
|
|
@ -1526,9 +1526,26 @@ void ImGuiWrapper::search_list(const ImVec2& size_, bool (*items_getter)(int, co
|
|||
// check_box(_L("Search in English"), view_params.english);
|
||||
}
|
||||
|
||||
void ImGuiWrapper::bold_text(const std::string& str)
|
||||
{
|
||||
if (bold_font){
|
||||
ImGui::PushFont(bold_font);
|
||||
text(str);
|
||||
ImGui::PopFont();
|
||||
} else {
|
||||
text(str);
|
||||
}
|
||||
}
|
||||
|
||||
void ImGuiWrapper::title(const std::string& str)
|
||||
{
|
||||
text(str);
|
||||
if (bold_font){
|
||||
ImGui::PushFont(bold_font);
|
||||
text(str);
|
||||
ImGui::PopFont();
|
||||
} else {
|
||||
text(str);
|
||||
}
|
||||
ImGui::Separator();
|
||||
}
|
||||
|
||||
|
@ -1690,6 +1707,7 @@ void ImGuiWrapper::init_font(bool compress)
|
|||
//FIXME replace with io.Fonts->AddFontFromMemoryTTF(buf_decompressed_data, (int)buf_decompressed_size, m_font_size, nullptr, ranges.Data);
|
||||
//https://github.com/ocornut/imgui/issues/220
|
||||
ImFont* font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/" + "HarmonyOS_Sans_SC_Regular.ttf").c_str(), m_font_size, nullptr, ranges.Data);
|
||||
|
||||
if (font == nullptr) {
|
||||
font = io.Fonts->AddFontDefault();
|
||||
if (font == nullptr) {
|
||||
|
@ -1697,6 +1715,15 @@ void ImGuiWrapper::init_font(bool compress)
|
|||
}
|
||||
}
|
||||
|
||||
ImFontConfig cfg = ImFontConfig();
|
||||
cfg.OversampleH = 1;
|
||||
bold_font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/" + "HarmonyOS_Sans_SC_Bold.ttf").c_str(), m_font_size, &cfg);
|
||||
|
||||
if (bold_font == nullptr) {
|
||||
bold_font = io.Fonts->AddFontDefault();
|
||||
if (bold_font == nullptr) { throw Slic3r::RuntimeError("ImGui: Could not load deafult font"); }
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
ImFontConfig config;
|
||||
config.MergeMode = true;
|
||||
|
|
|
@ -147,7 +147,12 @@ public:
|
|||
bool combo(const wxString& label, const std::vector<std::string>& options, int& selection); // Use -1 to not mark any option as selected
|
||||
bool undo_redo_list(const ImVec2& size, const bool is_undo, bool (*items_getter)(const bool, int, const char**), int& hovered, int& selected, int& mouse_wheel);
|
||||
void search_list(const ImVec2& size, bool (*items_getter)(int, const char** label, const char** tooltip), char* search_str,
|
||||
Search::OptionViewParameters& view_params, int& selected, bool& edited, int& mouse_wheel, bool is_localized);
|
||||
Search::OptionViewParameters &view_params,
|
||||
int & selected,
|
||||
bool & edited,
|
||||
int & mouse_wheel,
|
||||
bool is_localized);
|
||||
void bold_text(const std::string &str);
|
||||
void title(const std::string& str);
|
||||
|
||||
void disabled_begin(bool disabled);
|
||||
|
@ -204,6 +209,7 @@ private:
|
|||
static void clipboard_set(void* user_data, const char* text);
|
||||
|
||||
LastSliderStatus m_last_slider_status;
|
||||
ImFont* bold_font = nullptr;
|
||||
};
|
||||
|
||||
class IMTexture
|
||||
|
|
|
@ -35,6 +35,7 @@ void UpgradeNetworkJob::on_success(std::function<void()> success)
|
|||
|
||||
void UpgradeNetworkJob::update_status(int st, const wxString &msg)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(info) << "UpgradeNetworkJob: percent = " << st << "msg = " << msg;
|
||||
GUI::Job::update_status(st, msg);
|
||||
wxCommandEvent event(EVT_UPGRADE_UPDATE_MESSAGE);
|
||||
event.SetString(msg);
|
||||
|
@ -59,6 +60,8 @@ void UpgradeNetworkJob::process()
|
|||
auto path_str = tmp_path.string() + wxString::Format(".%d%s", get_current_pid(), ".tmp").ToStdString();
|
||||
tmp_path = fs::path(path_str);
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "UpgradeNetworkJob: save netowrk_plugin to " << tmp_path.string();
|
||||
|
||||
auto cancel_fn = [this]() {
|
||||
return was_canceled();
|
||||
};
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include "GUI_ObjectList.hpp"
|
||||
#include "NotificationManager.hpp"
|
||||
#include "MarkdownTip.hpp"
|
||||
#include "NetworkTestDialog.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <dbt.h>
|
||||
|
@ -344,7 +345,7 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
|
|||
// BBS: fix taskbar overlay on windows
|
||||
#ifdef WIN32
|
||||
auto setMaxSize = [this]() {
|
||||
wxDisplay display(wxDisplay::GetFromWindow(this));
|
||||
wxDisplay display(this);
|
||||
auto size = display.GetClientArea().GetSize();
|
||||
// 8 pixels shadow
|
||||
SetMaxSize(size + wxSize{16, 16});
|
||||
|
@ -355,7 +356,7 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
|
|||
});
|
||||
setMaxSize();
|
||||
this->Bind(wxEVT_MAXIMIZE, [this](auto &e) {
|
||||
wxDisplay display(wxDisplay::GetFromWindow(this));
|
||||
wxDisplay display(this);
|
||||
auto pos = display.GetClientArea().GetPosition();
|
||||
Move(pos - wxPoint{8, 8});
|
||||
e.Skip();
|
||||
|
@ -480,18 +481,36 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
|
|||
Slic3r::run_backup_ui_tasks();
|
||||
});
|
||||
; }
|
||||
|
||||
this->Bind(wxEVT_CHAR_HOOK, [this](wxKeyEvent &evt) {
|
||||
#ifdef __APPLE__
|
||||
if (evt.CmdDown() && evt.GetKeyCode() == 'H') { this->Iconize(); return;}
|
||||
if (evt.CmdDown() && (evt.GetKeyCode() == 'H')) {
|
||||
//call parent_menu hide behavior
|
||||
return;}
|
||||
if (evt.CmdDown() && (evt.GetKeyCode() == 'M')) {
|
||||
this->Iconize();
|
||||
return;
|
||||
}
|
||||
if (evt.CmdDown() && evt.GetKeyCode() == 'Q') { wxPostEvent(this, wxCloseEvent(wxEVT_CLOSE_WINDOW)); return;}
|
||||
if (evt.CmdDown() && evt.RawControlDown() && evt.GetKeyCode() == 'F') {
|
||||
EnableFullScreenView(true);
|
||||
if (IsFullScreen()) {
|
||||
ShowFullScreen(false);
|
||||
} else {
|
||||
ShowFullScreen(true);
|
||||
}
|
||||
return;}
|
||||
#endif
|
||||
if (evt.CmdDown() && evt.GetKeyCode() == 'N') { m_plater->new_project(); return;}
|
||||
if (evt.CmdDown() && evt.GetKeyCode() == 'O') { m_plater->load_project(); return;}
|
||||
if (evt.CmdDown() && evt.ShiftDown() && evt.GetKeyCode() == 'S') { if (m_plater) m_plater->save_project(true); return;}
|
||||
else if (evt.CmdDown() && evt.GetKeyCode() == 'S') { if (m_plater) m_plater->save_project(); return;}
|
||||
|
||||
if (evt.CmdDown() && evt.GetKeyCode() == 'P') {
|
||||
#ifdef __APPLE__
|
||||
if (evt.CmdDown() && evt.GetKeyCode() == ',')
|
||||
#else
|
||||
if (evt.CmdDown() && evt.GetKeyCode() == 'P')
|
||||
#endif
|
||||
{
|
||||
PreferencesDialog dlg(this);
|
||||
dlg.ShowModal();
|
||||
#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
||||
|
@ -502,6 +521,7 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
|
|||
plater()->refresh_print();
|
||||
return;
|
||||
}
|
||||
|
||||
if (evt.CmdDown() && evt.GetKeyCode() == 'I') {
|
||||
if (!can_add_models()) return;
|
||||
if (m_plater) { m_plater->add_model(); }
|
||||
|
@ -1167,24 +1187,28 @@ bool MainFrame::can_change_view() const
|
|||
}
|
||||
}
|
||||
|
||||
bool MainFrame::can_clone() const {
|
||||
return can_select() && !m_plater->is_selection_empty();
|
||||
}
|
||||
|
||||
bool MainFrame::can_select() const
|
||||
{
|
||||
return (m_plater != nullptr) && !m_plater->model().objects.empty();
|
||||
return (m_plater != nullptr) && (m_tabpanel->GetSelection() == TabPosition::tp3DEditor) && !m_plater->model().objects.empty();
|
||||
}
|
||||
|
||||
bool MainFrame::can_deselect() const
|
||||
{
|
||||
return (m_plater != nullptr) && !m_plater->is_selection_empty();
|
||||
return (m_plater != nullptr) && (m_tabpanel->GetSelection() == TabPosition::tp3DEditor) && !m_plater->is_selection_empty();
|
||||
}
|
||||
|
||||
bool MainFrame::can_delete() const
|
||||
{
|
||||
return (m_plater != nullptr) && !m_plater->is_selection_empty();
|
||||
return (m_plater != nullptr) && (m_tabpanel->GetSelection() == TabPosition::tp3DEditor) && !m_plater->is_selection_empty();
|
||||
}
|
||||
|
||||
bool MainFrame::can_delete_all() const
|
||||
{
|
||||
return (m_plater != nullptr) && !m_plater->model().objects.empty();
|
||||
return (m_plater != nullptr) && (m_tabpanel->GetSelection() == TabPosition::tp3DEditor) && !m_plater->model().objects.empty();
|
||||
}
|
||||
|
||||
bool MainFrame::can_reslice() const
|
||||
|
@ -1656,6 +1680,12 @@ static wxMenu* generate_help_menu()
|
|||
append_menu_item(helpMenu, wxID_ANY, about_title, about_title,
|
||||
[](wxCommandEvent&) { Slic3r::GUI::about(); });
|
||||
#endif
|
||||
|
||||
append_menu_item(helpMenu, wxID_ANY, _L("Open Network Test"), _L("Open Network Test"), [](wxCommandEvent&) {
|
||||
NetworkTestDialog dlg(wxGetApp().mainframe);
|
||||
dlg.ShowModal();
|
||||
});
|
||||
|
||||
return helpMenu;
|
||||
}
|
||||
|
||||
|
@ -1840,7 +1870,7 @@ void MainFrame::init_menubar_as_editor()
|
|||
_L("Clone copies of selections"),[this](wxCommandEvent&) {
|
||||
m_plater->clone_selection();
|
||||
},
|
||||
"menu_remove", nullptr, [this](){return can_select(); }, this);
|
||||
"menu_remove", nullptr, [this](){return can_clone(); }, this);
|
||||
editMenu->AppendSeparator();
|
||||
#else
|
||||
// BBS undo
|
||||
|
@ -1878,7 +1908,7 @@ void MainFrame::init_menubar_as_editor()
|
|||
_L("Clone copies of selections"),[this](wxCommandEvent&) {
|
||||
m_plater->clone_selection();
|
||||
},
|
||||
"", nullptr, [this](){return can_select(); }, this);
|
||||
"", nullptr, [this](){return can_clone(); }, this);
|
||||
editMenu->AppendSeparator();
|
||||
#endif
|
||||
|
||||
|
@ -1951,117 +1981,122 @@ void MainFrame::init_menubar_as_editor()
|
|||
#ifdef __APPLE__
|
||||
wxWindowID bambu_studio_id_base = wxWindow::NewControlId(int(2));
|
||||
wxMenu* parent_menu = m_menubar->OSXGetAppleMenu();
|
||||
auto preference_item = new wxMenuItem(parent_menu, BambuStudioMenuPreferences + bambu_studio_id_base, _L("Preferences") + "\tCtrl+P", "");
|
||||
auto preference_item = new wxMenuItem(parent_menu, BambuStudioMenuPreferences + bambu_studio_id_base, _L("Preferences") + "\tCtrl+,", "");
|
||||
#else
|
||||
wxMenu* parent_menu = m_topbar->GetTopMenu();
|
||||
auto preference_item = new wxMenuItem(parent_menu, ConfigMenuPreferences + config_id_base, _L("Preferences") + "\tCtrl+P", "");
|
||||
|
||||
#endif
|
||||
|
||||
//auto printer_item = new wxMenuItem(parent_menu, ConfigMenuPrinter + config_id_base, _L("Printer"), "");
|
||||
//auto language_item = new wxMenuItem(parent_menu, ConfigMenuLanguage + config_id_base, _L("Switch Language"), "");
|
||||
parent_menu->Bind(wxEVT_MENU, [this, config_id_base](wxEvent& event) {
|
||||
switch (event.GetId() - config_id_base) {
|
||||
//case ConfigMenuLanguage:
|
||||
//{
|
||||
// /* Before change application language, let's check unsaved changes on 3D-Scene
|
||||
// * and draw user's attention to the application restarting after a language change
|
||||
// */
|
||||
// {
|
||||
// // the dialog needs to be destroyed before the call to switch_language()
|
||||
// // or sometimes the application crashes into wxDialogBase() destructor
|
||||
// // so we put it into an inner scope
|
||||
// wxString title = _L("Language selection");
|
||||
// wxMessageDialog dialog(nullptr,
|
||||
// _L("Switching the language requires application restart.\n") + "\n\n" +
|
||||
// _L("Do you want to continue?"),
|
||||
// title,
|
||||
// wxICON_QUESTION | wxOK | wxCANCEL);
|
||||
// if (dialog.ShowModal() == wxID_CANCEL)
|
||||
// return;
|
||||
// }
|
||||
|
||||
// wxGetApp().switch_language();
|
||||
// break;
|
||||
//}
|
||||
//case ConfigMenuWizard:
|
||||
//{
|
||||
// wxGetApp().run_wizard(ConfigWizard::RR_USER);
|
||||
// break;
|
||||
//}
|
||||
case ConfigMenuPrinter:
|
||||
{
|
||||
wxGetApp().params_dialog()->Popup();
|
||||
wxGetApp().get_tab(Preset::TYPE_PRINTER)->restore_last_select_item();
|
||||
break;
|
||||
}
|
||||
case ConfigMenuPreferences:
|
||||
{
|
||||
wxGetApp().CallAfter([this] {
|
||||
PreferencesDialog dlg(this);
|
||||
dlg.ShowModal();
|
||||
#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
||||
if (dlg.seq_top_layer_only_changed() || dlg.seq_seq_top_gcode_indices_changed())
|
||||
#else
|
||||
if (dlg.seq_top_layer_only_changed())
|
||||
#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
||||
plater()->refresh_print();
|
||||
#if ENABLE_CUSTOMIZABLE_FILES_ASSOCIATION_ON_WIN
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
if (wxGetApp().app_config()->get("associate_3mf") == "true")
|
||||
wxGetApp().associate_3mf_files();
|
||||
if (wxGetApp().app_config()->get("associate_stl") == "true")
|
||||
wxGetApp().associate_stl_files();
|
||||
/*if (wxGetApp().app_config()->get("associate_step") == "true")
|
||||
wxGetApp().associate_step_files();*/
|
||||
#endif // _WIN32
|
||||
#endif
|
||||
});
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
// parent_menu->Bind(wxEVT_MENU, [this, config_id_base](wxEvent& event) {
|
||||
// switch (event.GetId() - config_id_base) {
|
||||
// //case ConfigMenuLanguage:
|
||||
// //{
|
||||
// // /* Before change application language, let's check unsaved changes on 3D-Scene
|
||||
// // * and draw user's attention to the application restarting after a language change
|
||||
// // */
|
||||
// // {
|
||||
// // // the dialog needs to be destroyed before the call to switch_language()
|
||||
// // // or sometimes the application crashes into wxDialogBase() destructor
|
||||
// // // so we put it into an inner scope
|
||||
// // wxString title = _L("Language selection");
|
||||
// // wxMessageDialog dialog(nullptr,
|
||||
// // _L("Switching the language requires application restart.\n") + "\n\n" +
|
||||
// // _L("Do you want to continue?"),
|
||||
// // title,
|
||||
// // wxICON_QUESTION | wxOK | wxCANCEL);
|
||||
// // if (dialog.ShowModal() == wxID_CANCEL)
|
||||
// // return;
|
||||
// // }
|
||||
//
|
||||
// // wxGetApp().switch_language();
|
||||
// // break;
|
||||
// //}
|
||||
// //case ConfigMenuWizard:
|
||||
// //{
|
||||
// // wxGetApp().run_wizard(ConfigWizard::RR_USER);
|
||||
// // break;
|
||||
// //}
|
||||
// case ConfigMenuPrinter:
|
||||
// {
|
||||
// wxGetApp().params_dialog()->Popup();
|
||||
// wxGetApp().get_tab(Preset::TYPE_PRINTER)->restore_last_select_item();
|
||||
// break;
|
||||
// }
|
||||
// case ConfigMenuPreferences:
|
||||
// {
|
||||
// wxGetApp().CallAfter([this] {
|
||||
// PreferencesDialog dlg(this);
|
||||
// dlg.ShowModal();
|
||||
//#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
||||
// if (dlg.seq_top_layer_only_changed() || dlg.seq_seq_top_gcode_indices_changed())
|
||||
//#else
|
||||
// if (dlg.seq_top_layer_only_changed())
|
||||
//#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
||||
// plater()->refresh_print();
|
||||
//#if ENABLE_CUSTOMIZABLE_FILES_ASSOCIATION_ON_WIN
|
||||
//#ifdef _WIN32
|
||||
// /*
|
||||
// if (wxGetApp().app_config()->get("associate_3mf") == "true")
|
||||
// wxGetApp().associate_3mf_files();
|
||||
// if (wxGetApp().app_config()->get("associate_stl") == "true")
|
||||
// wxGetApp().associate_stl_files();
|
||||
// /*if (wxGetApp().app_config()->get("associate_step") == "true")
|
||||
// wxGetApp().associate_step_files();*/
|
||||
//#endif // _WIN32
|
||||
//#endif
|
||||
// });
|
||||
// break;
|
||||
// }
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// });
|
||||
|
||||
#ifdef __APPLE__
|
||||
wxString about_title = wxString::Format(_L("&About %s"), SLIC3R_APP_FULL_NAME);
|
||||
auto about_item = new wxMenuItem(parent_menu, BambuStudioMenuAbout + bambu_studio_id_base, about_title, "");
|
||||
parent_menu->Bind(wxEVT_MENU, [this, bambu_studio_id_base](wxEvent& event) {
|
||||
switch (event.GetId() - bambu_studio_id_base) {
|
||||
case BambuStudioMenuAbout:
|
||||
Slic3r::GUI::about();
|
||||
break;
|
||||
case BambuStudioMenuPreferences:
|
||||
wxGetApp().CallAfter([this] {
|
||||
PreferencesDialog dlg(this);
|
||||
dlg.ShowModal();
|
||||
#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
||||
if (dlg.seq_top_layer_only_changed() || dlg.seq_seq_top_gcode_indices_changed())
|
||||
#else
|
||||
if (dlg.seq_top_layer_only_changed())
|
||||
#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
||||
plater()->refresh_print();
|
||||
#if ENABLE_CUSTOMIZABLE_FILES_ASSOCIATION_ON_WIN
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
if (wxGetApp().app_config()->get("associate_3mf") == "true")
|
||||
wxGetApp().associate_3mf_files();
|
||||
if (wxGetApp().app_config()->get("associate_stl") == "true")
|
||||
wxGetApp().associate_stl_files();
|
||||
/*if (wxGetApp().app_config()->get("associate_step") == "true")
|
||||
wxGetApp().associate_step_files();*/
|
||||
#endif // _WIN32
|
||||
#endif
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
});
|
||||
parent_menu->Insert(0, about_item);
|
||||
parent_menu->Insert(1, preference_item);
|
||||
//parent_menu->Bind(wxEVT_MENU, [this, bambu_studio_id_base](wxEvent& event) {
|
||||
// switch (event.GetId() - bambu_studio_id_base) {
|
||||
// case BambuStudioMenuAbout:
|
||||
// Slic3r::GUI::about();
|
||||
// break;
|
||||
// case BambuStudioMenuPreferences:
|
||||
// wxGetApp().CallAfter([this] {
|
||||
// PreferencesDialog dlg(this);
|
||||
// dlg.ShowModal();
|
||||
//#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
||||
// if (dlg.seq_top_layer_only_changed() || dlg.seq_seq_top_gcode_indices_changed())
|
||||
//#else
|
||||
// if (dlg.seq_top_layer_only_changed())
|
||||
//#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
||||
// plater()->refresh_print();
|
||||
// });
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
//});
|
||||
//parent_menu->Insert(0, about_item);
|
||||
append_menu_item(
|
||||
parent_menu, wxID_ANY, _L("About") + "", _L(""),
|
||||
[this](wxCommandEvent &) { Slic3r::GUI::about();},
|
||||
"", nullptr, []() { return true; }, this, 0);
|
||||
append_menu_item(
|
||||
parent_menu, wxID_ANY, _L("Preferences") + "\tCtrl+'", _L(""),
|
||||
[this](wxCommandEvent &) {
|
||||
PreferencesDialog dlg(this);
|
||||
dlg.ShowModal();
|
||||
#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
||||
if (dlg.seq_top_layer_only_changed() || dlg.seq_seq_top_gcode_indices_changed())
|
||||
#else
|
||||
if (dlg.seq_top_layer_only_changed())
|
||||
#endif
|
||||
plater()->refresh_print();
|
||||
},
|
||||
"", nullptr, []() { return true; }, this, 1);
|
||||
//parent_menu->Insert(1, preference_item);
|
||||
#endif
|
||||
// Help menu
|
||||
auto helpMenu = generate_help_menu();
|
||||
|
@ -2074,7 +2109,21 @@ void MainFrame::init_menubar_as_editor()
|
|||
if (viewMenu)
|
||||
m_topbar->AddDropDownSubMenu(viewMenu, _L("View"));
|
||||
//BBS add Preference
|
||||
m_topbar->AddDropDownMenuItem(preference_item);
|
||||
|
||||
append_menu_item(
|
||||
m_topbar->GetTopMenu(), wxID_ANY, _L("Preferences") + "\tCtrl+P", _L(""),
|
||||
[this](wxCommandEvent &) {
|
||||
PreferencesDialog dlg(this);
|
||||
dlg.ShowModal();
|
||||
#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
||||
if (dlg.seq_top_layer_only_changed() || dlg.seq_seq_top_gcode_indices_changed())
|
||||
#else
|
||||
if (dlg.seq_top_layer_only_changed())
|
||||
#endif
|
||||
plater()->refresh_print();
|
||||
},
|
||||
"", nullptr, []() { return true; }, this);
|
||||
//m_topbar->AddDropDownMenuItem(preference_item);
|
||||
//m_topbar->AddDropDownMenuItem(printer_item);
|
||||
//m_topbar->AddDropDownMenuItem(language_item);
|
||||
//m_topbar->AddDropDownMenuItem(config_item);
|
||||
|
|
|
@ -118,6 +118,7 @@ class MainFrame : public DPIFrame
|
|||
bool can_change_view() const;
|
||||
bool can_select() const;
|
||||
bool can_deselect() const;
|
||||
bool can_clone() const;
|
||||
bool can_delete() const;
|
||||
bool can_delete_all() const;
|
||||
bool can_reslice() const;
|
||||
|
|
|
@ -83,6 +83,8 @@ MarkdownTip::MarkdownTip()
|
|||
_timer->Bind(wxEVT_TIMER, &MarkdownTip::OnTimer, this);
|
||||
}
|
||||
|
||||
MarkdownTip::~MarkdownTip() { delete _timer; }
|
||||
|
||||
void MarkdownTip::LoadStyle()
|
||||
{
|
||||
_language = GUI::into_u8(GUI::wxGetApp().current_language_code());
|
||||
|
@ -139,7 +141,7 @@ bool MarkdownTip::ShowTip(wxPoint pos, std::string const &tip, std::string const
|
|||
this->Hide();
|
||||
}
|
||||
if (_tipView->GetParent() == this) {
|
||||
wxSize size = wxDisplay(wxDisplay::GetFromWindow(this)).GetClientArea().GetSize();
|
||||
wxSize size = wxDisplay(this).GetClientArea().GetSize();
|
||||
_requestPos = pos;
|
||||
if (pos.y + this->GetSize().y > size.y)
|
||||
pos.y = size.y - this->GetSize().y;
|
||||
|
@ -252,7 +254,7 @@ void MarkdownTip::OnTitleChanged(wxWebViewEvent& event)
|
|||
return;
|
||||
_lastHeight = height;
|
||||
height *= 1.25; height += 50;
|
||||
wxSize size = wxDisplay(wxDisplay::GetFromWindow(this)).GetClientArea().GetSize();
|
||||
wxSize size = wxDisplay(this).GetClientArea().GetSize();
|
||||
if (height > size.y)
|
||||
height = size.y;
|
||||
wxPoint pos = _requestPos;
|
||||
|
|
|
@ -28,6 +28,8 @@ private:
|
|||
|
||||
MarkdownTip();
|
||||
|
||||
~MarkdownTip();
|
||||
|
||||
void LoadStyle();
|
||||
|
||||
bool ShowTip(wxPoint pos, std::string const &tip, std::string const & tooltip);
|
||||
|
@ -48,13 +50,13 @@ private:
|
|||
void OnTimer(wxTimerEvent& event);
|
||||
|
||||
private:
|
||||
wxWebView* _tipView = NULL;
|
||||
wxWebView * _tipView = nullptr;
|
||||
std::string _lastTip;
|
||||
std::string _pendingScript = " ";
|
||||
std::string _language;
|
||||
wxPoint _requestPos;
|
||||
double _lastHeight = 0;
|
||||
wxTimer* _timer;
|
||||
wxTimer* _timer = nullptr;
|
||||
bool _hide = false;
|
||||
bool _data_dir = false;
|
||||
};
|
||||
|
|
|
@ -45,12 +45,12 @@ MediaFilePanel::MediaFilePanel(wxWindow * parent)
|
|||
time_sizer->Add(m_button_month, 0, wxALIGN_CENTER_VERTICAL);
|
||||
time_sizer->Add(m_button_all, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 24);
|
||||
m_time_panel->SetSizer(time_sizer);
|
||||
top_sizer->Add(m_time_panel, 1, wxALIGN_CENTER_VERTICAL | wxEXPAND);
|
||||
top_sizer->Add(m_time_panel, 1, wxEXPAND);
|
||||
|
||||
// File type
|
||||
m_type_panel = new ::StaticBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
|
||||
m_type_panel->SetBackgroundColor(*wxWHITE);
|
||||
m_type_panel->SetCornerRadius(5);
|
||||
m_type_panel->SetCornerRadius(FromDIP(5));
|
||||
m_type_panel->SetMinSize({-1, 48 * em_unit(this) / 10});
|
||||
m_button_timelapse = new ::Button(m_type_panel, _L("Timelapse"), "", wxBORDER_NONE);
|
||||
m_button_video = new ::Button(m_type_panel, _L("Video"), "", wxBORDER_NONE);
|
||||
|
@ -74,7 +74,7 @@ MediaFilePanel::MediaFilePanel(wxWindow * parent)
|
|||
manage_sizer->Add(m_button_download, 0, wxALIGN_CENTER_VERTICAL)->Show(false);
|
||||
manage_sizer->Add(m_button_management, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 24);
|
||||
m_manage_panel->SetSizer(manage_sizer);
|
||||
top_sizer->Add(m_manage_panel, 1, wxALIGN_CENTER_VERTICAL | wxEXPAND);
|
||||
top_sizer->Add(m_manage_panel, 1, wxEXPAND);
|
||||
|
||||
sizer->Add(top_sizer, 0, wxEXPAND);
|
||||
|
||||
|
@ -154,6 +154,11 @@ MediaFilePanel::MediaFilePanel(wxWindow * parent)
|
|||
parent->GetParent()->Bind(wxEVT_SHOW, onShowHide);
|
||||
}
|
||||
|
||||
MediaFilePanel::~MediaFilePanel()
|
||||
{
|
||||
SetMachineObject(nullptr);
|
||||
}
|
||||
|
||||
void MediaFilePanel::SetMachineObject(MachineObject* obj)
|
||||
{
|
||||
std::string machine = obj ? obj->dev_id : "";
|
||||
|
@ -269,4 +274,4 @@ MediaFileFrame::MediaFileFrame(wxWindow* parent)
|
|||
|
||||
void MediaFileFrame::on_dpi_changed(const wxRect& suggested_rect) { m_panel->Rescale(); Refresh(); }
|
||||
|
||||
}}
|
||||
}}
|
||||
|
|
|
@ -31,6 +31,8 @@ class MediaFilePanel : public wxPanel
|
|||
{
|
||||
public:
|
||||
MediaFilePanel(wxWindow * parent);
|
||||
|
||||
~MediaFilePanel();
|
||||
|
||||
void SetMachineObject(MachineObject * obj);
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ MediaPlayCtrl::MediaPlayCtrl(wxWindow *parent, wxMediaCtrl2 *media_ctrl, const w
|
|||
|
||||
m_button_play = new Button(this, "", "media_play", wxBORDER_NONE);
|
||||
|
||||
m_label_status = new Label(Label::Body_14, this);
|
||||
m_label_status = new Label(this);
|
||||
|
||||
m_button_play->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [this](auto & e) { TogglePlay(); });
|
||||
|
||||
|
@ -27,7 +27,7 @@ MediaPlayCtrl::MediaPlayCtrl(wxWindow *parent, wxMediaCtrl2 *media_ctrl, const w
|
|||
Bind(wxEVT_RIGHT_UP, [this](auto & e) { wxClipboard & c = *wxTheClipboard; if (c.Open()) { c.SetData(new wxTextDataObject(m_url)); c.Close(); } });
|
||||
|
||||
wxBoxSizer * sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(m_button_play, 0, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 0);
|
||||
sizer->Add(m_button_play, 0, wxEXPAND | wxALL, 0);
|
||||
sizer->AddStretchSpacer(1);
|
||||
sizer->Add(m_label_status, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, FromDIP(25));
|
||||
SetSizer(sizer);
|
||||
|
|
|
@ -52,8 +52,8 @@ AddMachinePanel::AddMachinePanel(wxWindow* parent, wxWindowID id, const wxPoint&
|
|||
horiz_sizer->Add(0, 0, 538, 0, 0);
|
||||
|
||||
wxBoxSizer* btn_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
m_button_add_machine = new Button(this, "", "monitor_add_machine", FromDIP(23));
|
||||
m_button_add_machine->SetCornerRadius(10);
|
||||
m_button_add_machine = new Button(this, "", "monitor_add_machine", FromDIP(24));
|
||||
m_button_add_machine->SetCornerRadius(FromDIP(12));
|
||||
StateColor button_bg(
|
||||
std::pair<wxColour, int>(0xCECECE, StateColor::Pressed),
|
||||
std::pair<wxColour, int>(0xCECECE, StateColor::Hovered),
|
||||
|
@ -129,7 +129,7 @@ MonitorPanel::~MonitorPanel()
|
|||
|
||||
if (m_refresh_timer)
|
||||
m_refresh_timer->Stop();
|
||||
|
||||
delete m_refresh_timer;
|
||||
}
|
||||
|
||||
void MonitorPanel::init_bitmap()
|
||||
|
|
|
@ -105,7 +105,7 @@ private:
|
|||
wxBitmap m_arrow_img;
|
||||
|
||||
int last_wifi_signal = -1;
|
||||
wxTimer* m_refresh_timer;
|
||||
wxTimer* m_refresh_timer = nullptr;
|
||||
int last_status;
|
||||
bool m_initialized { false };
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ Button* MsgDialog::add_button(wxWindowID btn_id, bool set_focus /*= false*/, con
|
|||
btn->SetMinSize(MSG_DIALOG_LONGER_BUTTON_SIZE);
|
||||
}
|
||||
|
||||
btn->SetCornerRadius(12);
|
||||
btn->SetCornerRadius(FromDIP(12));
|
||||
StateColor btn_bg_green(
|
||||
std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed),
|
||||
std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
|
||||
|
|
821
src/slic3r/GUI/NetworkTestDialog.cpp
Normal file
821
src/slic3r/GUI/NetworkTestDialog.cpp
Normal file
|
@ -0,0 +1,821 @@
|
|||
#include "NetworkTestDialog.hpp"
|
||||
#include "I18N.hpp"
|
||||
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "slic3r/Utils/Http.hpp"
|
||||
#include "libslic3r/AppConfig.hpp"
|
||||
#include <boost/asio/ip/address.hpp>
|
||||
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
wxDECLARE_EVENT(EVT_UPDATE_RESULT, wxCommandEvent);
|
||||
|
||||
wxDEFINE_EVENT(EVT_UPDATE_RESULT, wxCommandEvent);
|
||||
|
||||
static wxString NA_STR = _L("N/A");
|
||||
|
||||
NetworkTestDialog::NetworkTestDialog(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style)
|
||||
: DPIDialog(parent,wxID_ANY,from_u8((boost::format(_utf8(L("Network Test")))).str()),wxDefaultPosition,
|
||||
wxSize(1000, 700),
|
||||
/*wxCAPTION*/wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER)
|
||||
{
|
||||
this->SetSizeHints(wxDefaultSize, wxDefaultSize);
|
||||
|
||||
wxBoxSizer* main_sizer;
|
||||
main_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
wxBoxSizer* top_sizer = create_top_sizer(this);
|
||||
main_sizer->Add(top_sizer, 0, wxEXPAND, 5);
|
||||
|
||||
wxBoxSizer* info_sizer = create_info_sizer(this);
|
||||
main_sizer->Add(info_sizer, 0, wxEXPAND, 5);
|
||||
|
||||
wxBoxSizer* content_sizer = create_content_sizer(this);
|
||||
main_sizer->Add(content_sizer, 0, wxEXPAND, 5);
|
||||
|
||||
wxBoxSizer* result_sizer = create_result_sizer(this);
|
||||
main_sizer->Add(result_sizer, 1, wxEXPAND, 5);
|
||||
|
||||
set_default();
|
||||
|
||||
init_bind();
|
||||
|
||||
this->SetSizer(main_sizer);
|
||||
this->Layout();
|
||||
|
||||
this->Centre(wxBOTH);
|
||||
}
|
||||
|
||||
wxBoxSizer* NetworkTestDialog::create_top_sizer(wxWindow* parent)
|
||||
{
|
||||
auto sizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
auto line_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
btn_start = new wxButton(this, wxID_ANY, _L("Start Test Multi-Thread"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
line_sizer->Add(btn_start, 0, wxALL, 5);
|
||||
|
||||
btn_start_sequence = new wxButton(this, wxID_ANY, _L("Start Test Single-Thread"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
line_sizer->Add(btn_start_sequence, 0, wxALL, 5);
|
||||
|
||||
btn_download_log = new wxButton(this, wxID_ANY, _L("Export Log"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
line_sizer->Add(btn_download_log, 0, wxALL, 5);
|
||||
btn_download_log->Hide();
|
||||
|
||||
btn_start->Bind(wxEVT_BUTTON, [this](wxCommandEvent &evt) {
|
||||
start_all_job();
|
||||
});
|
||||
btn_start_sequence->Bind(wxEVT_BUTTON, [this](wxCommandEvent &evt) {
|
||||
start_all_job_sequence();
|
||||
});
|
||||
sizer->Add(line_sizer, 0, wxEXPAND, 5);
|
||||
return sizer;
|
||||
}
|
||||
|
||||
wxBoxSizer* NetworkTestDialog::create_info_sizer(wxWindow* parent)
|
||||
{
|
||||
auto sizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
text_basic_info = new wxStaticText(this, wxID_ANY, _L("Basic Info"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
text_basic_info->Wrap(-1);
|
||||
sizer->Add(text_basic_info, 0, wxALL, 5);
|
||||
|
||||
wxBoxSizer* version_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
text_version_title = new wxStaticText(this, wxID_ANY, _L("Studio Version:"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
text_version_title->Wrap(-1);
|
||||
version_sizer->Add(text_version_title, 0, wxALL, 5);
|
||||
|
||||
wxString text_version = get_studio_version();
|
||||
text_version_val = new wxStaticText(this, wxID_ANY, text_version, wxDefaultPosition, wxDefaultSize, 0);
|
||||
text_version_val->Wrap(-1);
|
||||
version_sizer->Add(text_version_val, 0, wxALL, 5);
|
||||
sizer->Add(version_sizer, 1, wxEXPAND, 5);
|
||||
|
||||
wxBoxSizer* sys_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
txt_sys_info_title = new wxStaticText(this, wxID_ANY, _L("System Version:"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
txt_sys_info_title->Wrap(-1);
|
||||
sys_sizer->Add(txt_sys_info_title, 0, wxALL, 5);
|
||||
|
||||
txt_sys_info_value = new wxStaticText(this, wxID_ANY, get_os_info(), wxDefaultPosition, wxDefaultSize, 0);
|
||||
txt_sys_info_value->Wrap(-1);
|
||||
sys_sizer->Add(txt_sys_info_value, 0, wxALL, 5);
|
||||
|
||||
sizer->Add(sys_sizer, 1, wxEXPAND, 5);
|
||||
|
||||
wxBoxSizer* line_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
txt_dns_info_title = new wxStaticText(this, wxID_ANY, _L("DNS Server:"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
txt_dns_info_title->Wrap(-1);
|
||||
txt_dns_info_title->Hide();
|
||||
line_sizer->Add(txt_dns_info_title, 0, wxALL, 5);
|
||||
|
||||
txt_dns_info_value = new wxStaticText(this, wxID_ANY, get_dns_info(), wxDefaultPosition, wxDefaultSize, 0);
|
||||
txt_dns_info_value->Hide();
|
||||
line_sizer->Add(txt_dns_info_value, 0, wxALL, 5);
|
||||
sizer->Add(line_sizer, 1, wxEXPAND, 5);
|
||||
|
||||
return sizer;
|
||||
}
|
||||
|
||||
wxBoxSizer* NetworkTestDialog::create_content_sizer(wxWindow* parent)
|
||||
{
|
||||
auto sizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
wxFlexGridSizer* grid_sizer;
|
||||
grid_sizer = new wxFlexGridSizer(0, 3, 0, 0);
|
||||
grid_sizer->SetFlexibleDirection(wxBOTH);
|
||||
grid_sizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
|
||||
|
||||
btn_link = new wxButton(this, wxID_ANY, _L("Test BambuLab"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
grid_sizer->Add(btn_link, 0, wxEXPAND | wxALL, 5);
|
||||
|
||||
text_link_title = new wxStaticText(this, wxID_ANY, _L("Test BambuLab:"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
text_link_title->Wrap(-1);
|
||||
grid_sizer->Add(text_link_title, 0, wxALIGN_RIGHT | wxALL, 5);
|
||||
|
||||
text_link_val = new wxStaticText(this, wxID_ANY, _L("N/A"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
text_link_val->Wrap(-1);
|
||||
grid_sizer->Add(text_link_val, 0, wxALL, 5);
|
||||
|
||||
btn_bing = new wxButton(this, wxID_ANY, _L("Test Bing.com"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
grid_sizer->Add(btn_bing, 0, wxEXPAND | wxALL, 5);
|
||||
|
||||
text_bing_title = new wxStaticText(this, wxID_ANY, _L("Test bing.com:"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
text_bing_title->Wrap(-1);
|
||||
grid_sizer->Add(text_bing_title, 0, wxALIGN_RIGHT | wxALL, 5);
|
||||
|
||||
text_bing_val = new wxStaticText(this, wxID_ANY, _L("N/A"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
text_bing_val->Wrap(-1);
|
||||
grid_sizer->Add(text_bing_val, 0, wxALL, 5);
|
||||
|
||||
btn_iot = new wxButton(this, wxID_ANY, _L("Test HTTP"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
grid_sizer->Add(btn_iot, 0, wxEXPAND | wxALL, 5);
|
||||
|
||||
text_iot_title = new wxStaticText(this, wxID_ANY, _L("Test HTTP Service:"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
text_iot_title->Wrap(-1);
|
||||
grid_sizer->Add(text_iot_title, 0, wxALIGN_RIGHT | wxALL, 5);
|
||||
|
||||
text_iot_value = new wxStaticText(this, wxID_ANY, _L("N/A"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
text_iot_value->Wrap(-1);
|
||||
grid_sizer->Add(text_iot_value, 0, wxALL, 5);
|
||||
|
||||
btn_oss = new wxButton(this, wxID_ANY, _L("Test storage"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
grid_sizer->Add(btn_oss, 0, wxEXPAND | wxALL, 5);
|
||||
|
||||
text_oss_title = new wxStaticText(this, wxID_ANY, _L("Test Storage Upload:"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
text_oss_title->Wrap(-1);
|
||||
grid_sizer->Add(text_oss_title, 0, wxALIGN_RIGHT | wxALL, 5);
|
||||
|
||||
text_oss_value = new wxStaticText(this, wxID_ANY, _L("N/A"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
text_oss_value->Wrap(-1);
|
||||
grid_sizer->Add(text_oss_value, 0, wxALL, 5);
|
||||
|
||||
btn_oss_upgrade = new wxButton(this, wxID_ANY, _L("Test storage upgrade"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
grid_sizer->Add(btn_oss_upgrade, 0, wxEXPAND | wxALL, 5);
|
||||
|
||||
text_oss_upgrade_title = new wxStaticText(this, wxID_ANY, _L("Test Storage Upgrade:"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
text_oss_upgrade_title->Wrap(-1);
|
||||
grid_sizer->Add(text_oss_upgrade_title, 0, wxALIGN_RIGHT | wxALL, 5);
|
||||
|
||||
text_oss_upgrade_value = new wxStaticText(this, wxID_ANY, _L("N/A"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
text_oss_upgrade_value->Wrap(-1);
|
||||
grid_sizer->Add(text_oss_upgrade_value, 0, wxALL, 5);
|
||||
|
||||
btn_oss_download = new wxButton(this, wxID_ANY, _L("Test storage download"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
grid_sizer->Add(btn_oss_download, 0, wxEXPAND | wxALL, 5);
|
||||
|
||||
text_oss_download_title = new wxStaticText(this, wxID_ANY, _L("Test Storage Download:"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
text_oss_download_title->Wrap(-1);
|
||||
grid_sizer->Add(text_oss_download_title, 0, wxALIGN_RIGHT | wxALL, 5);
|
||||
|
||||
text_oss_download_value = new wxStaticText(this, wxID_ANY, _L("N/A"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
text_oss_download_value->Wrap(-1);
|
||||
grid_sizer->Add(text_oss_download_value, 0, wxALL, 5);
|
||||
|
||||
btn_oss_upload = new wxButton(this, wxID_ANY, _L("Test Storage Upload"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
grid_sizer->Add(btn_oss_upload, 0, wxEXPAND | wxALL, 5);
|
||||
|
||||
text_oss_upload_title = new wxStaticText(this, wxID_ANY, _L("Test Storage Upload:"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
text_oss_upload_title->Wrap(-1);
|
||||
grid_sizer->Add(text_oss_upload_title, 0, wxALIGN_RIGHT | wxALL, 5);
|
||||
|
||||
text_oss_upload_value = new wxStaticText(this, wxID_ANY, _L("N/A"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
text_oss_upload_value->Wrap(-1);
|
||||
grid_sizer->Add(text_oss_upload_value, 0, wxALL, 5);
|
||||
|
||||
btn_oss_upload->Hide();
|
||||
text_oss_upload_title->Hide();
|
||||
text_oss_upload_value->Hide();
|
||||
|
||||
sizer->Add(grid_sizer, 1, wxEXPAND, 5);
|
||||
|
||||
btn_link->Bind(wxEVT_BUTTON, [this](wxCommandEvent& evt) {
|
||||
start_test_bambulab_thread();
|
||||
});
|
||||
|
||||
btn_bing->Bind(wxEVT_BUTTON, [this](wxCommandEvent& evt) {
|
||||
start_test_bing_thread();
|
||||
});
|
||||
|
||||
btn_iot->Bind(wxEVT_BUTTON, [this](wxCommandEvent& evt) {
|
||||
start_test_iot_thread();
|
||||
});
|
||||
|
||||
btn_oss->Bind(wxEVT_BUTTON, [this](wxCommandEvent& evt) {
|
||||
start_test_oss_thread();
|
||||
});
|
||||
|
||||
btn_oss_upgrade->Bind(wxEVT_BUTTON, [this](wxCommandEvent& evt) {
|
||||
start_test_oss_upgrade_thread();
|
||||
});
|
||||
|
||||
btn_oss_download->Bind(wxEVT_BUTTON, [this](wxCommandEvent& evt) {
|
||||
start_test_oss_download_thread();
|
||||
});
|
||||
|
||||
return sizer;
|
||||
}
|
||||
wxBoxSizer* NetworkTestDialog::create_result_sizer(wxWindow* parent)
|
||||
{
|
||||
auto sizer = new wxBoxSizer(wxVERTICAL);
|
||||
text_result = new wxStaticText(this, wxID_ANY, _L("Log Info"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
text_result->Wrap(-1);
|
||||
sizer->Add(text_result, 0, wxALL, 5);
|
||||
|
||||
txt_log = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
|
||||
sizer->Add(txt_log, 1, wxALL | wxEXPAND, 5);
|
||||
return sizer;
|
||||
}
|
||||
|
||||
NetworkTestDialog::~NetworkTestDialog()
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
void NetworkTestDialog::init_bind()
|
||||
{
|
||||
Bind(EVT_UPDATE_RESULT, [this](wxCommandEvent& evt) {
|
||||
if (evt.GetInt() == TEST_BAMBULAB_JOB) {
|
||||
text_link_val->SetLabelText(evt.GetString());
|
||||
} else if (evt.GetInt() == TEST_BING_JOB) {
|
||||
text_bing_val->SetLabelText(evt.GetString());
|
||||
} else if (evt.GetInt() == TEST_IOT_JOB) {
|
||||
text_iot_value->SetLabelText(evt.GetString());
|
||||
} else if (evt.GetInt() == TEST_OSS_JOB) {
|
||||
text_oss_value->SetLabelText(evt.GetString());
|
||||
} else if (evt.GetInt() == TEST_OSS_UPGRADE_JOB) {
|
||||
text_oss_upgrade_value->SetLabelText(evt.GetString());
|
||||
} else if (evt.GetInt() == TEST_OSS_DOWNLOAD_JOB) {
|
||||
text_oss_download_value->SetLabelText(evt.GetString());
|
||||
} else if (evt.GetInt() == TEST_OSS_UPLOAD_JOB) {
|
||||
text_oss_upload_value->SetLabelText(evt.GetString());
|
||||
}
|
||||
|
||||
std::time_t t = std::time(0);
|
||||
std::tm* now_time = std::localtime(&t);
|
||||
std::stringstream buf;
|
||||
buf << std::put_time(now_time, "%a %b %d %H:%M:%S");
|
||||
wxString info = wxString::Format("%s:", buf.str()) + evt.GetString() + "\n";
|
||||
try {
|
||||
txt_log->AppendText(info);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Unkown Exception in print_log, exception=" << e.what();
|
||||
return;
|
||||
}
|
||||
catch (...) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Unkown Exception in print_log";
|
||||
return;
|
||||
}
|
||||
return;
|
||||
});
|
||||
|
||||
Bind(wxEVT_CLOSE_WINDOW, &NetworkTestDialog::on_close, this);
|
||||
}
|
||||
|
||||
wxString NetworkTestDialog::get_os_info()
|
||||
{
|
||||
int major = 0, minor = 0, micro = 0;
|
||||
wxGetOsVersion(&major, &minor, µ);
|
||||
std::string os_version = (boost::format("%1%.%2%.%3%") % major % minor % micro).str();
|
||||
wxString text_sys_version = wxGetOsDescription() + wxString::Format("%d.%d.%d", major, minor, micro);
|
||||
return text_sys_version;
|
||||
}
|
||||
|
||||
|
||||
wxString NetworkTestDialog::get_dns_info()
|
||||
{
|
||||
return NA_STR;
|
||||
}
|
||||
|
||||
void NetworkTestDialog::start_all_job()
|
||||
{
|
||||
start_test_bing_thread();
|
||||
start_test_bambulab_thread();
|
||||
start_test_iot_thread();
|
||||
start_test_oss_thread();
|
||||
start_test_oss_upgrade_thread();
|
||||
start_test_oss_download_thread();
|
||||
start_test_ping_thread();
|
||||
}
|
||||
|
||||
void NetworkTestDialog::start_all_job_sequence()
|
||||
{
|
||||
m_sequence_job = new boost::thread([this] {
|
||||
update_status(-1, "start_test_sequence");
|
||||
start_test_bing();
|
||||
if (m_closing) return;
|
||||
start_test_bambulab();
|
||||
if (m_closing) return;
|
||||
start_test_oss();
|
||||
if (m_closing) return;
|
||||
start_test_oss_upgrade();
|
||||
if (m_closing) return;
|
||||
start_test_oss_download();
|
||||
update_status(-1, "end_test_sequence");
|
||||
});
|
||||
}
|
||||
|
||||
void NetworkTestDialog::start_test_bing()
|
||||
{
|
||||
m_in_testing[TEST_BING_JOB] = true;
|
||||
update_status(TEST_BING_JOB, "test bing start...");
|
||||
|
||||
std::string url = "http://www.bing.com/";
|
||||
Slic3r::Http http = Slic3r::Http::get(url);
|
||||
|
||||
int result = -1;
|
||||
http.timeout_max(10)
|
||||
.on_complete([this, &result](std::string body, unsigned status) {
|
||||
try {
|
||||
if (status == 200) {
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
;
|
||||
}
|
||||
})
|
||||
.on_ip_resolve([this](std::string ip) {
|
||||
wxString ip_report = wxString::Format("test bing ip resolved = %s", ip);
|
||||
update_status(TEST_BING_JOB, ip_report);
|
||||
})
|
||||
.on_error([this](std::string body, std::string error, unsigned int status) {
|
||||
wxString info = wxString::Format("status=%u, body=%s, error=%s", status, body, error);
|
||||
this->update_status(TEST_BING_JOB, "test bing failed");
|
||||
this->update_status(-1, info);
|
||||
}).perform_sync();
|
||||
if (result == 0) {
|
||||
update_status(TEST_BING_JOB, "test bing ok");
|
||||
}
|
||||
m_in_testing[TEST_BING_JOB] = false;
|
||||
}
|
||||
|
||||
void NetworkTestDialog::start_test_bambulab()
|
||||
{
|
||||
m_in_testing[TEST_BAMBULAB_JOB] = true;
|
||||
update_status(TEST_BAMBULAB_JOB, "test bambulab start...");
|
||||
|
||||
std::string platform = "windows";
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
platform = "windows";
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
platform = "macos";
|
||||
#endif
|
||||
#ifdef __LINUX__
|
||||
platform = "linux";
|
||||
#endif
|
||||
std::string query_params = (boost::format("?name=slicer&version=%1%&guide_version=%2%")
|
||||
% VersionInfo::convert_full_version(SLIC3R_VERSION)
|
||||
% VersionInfo::convert_full_version("0.0.0.1")
|
||||
).str();
|
||||
|
||||
AppConfig* app_config = wxGetApp().app_config;
|
||||
std::string url = wxGetApp().get_http_url(app_config->get_country_code()) + query_params;
|
||||
Slic3r::Http http = Slic3r::Http::get(url);
|
||||
int result = -1;
|
||||
http.header("accept", "application/json")
|
||||
.timeout_max(10)
|
||||
.on_complete([this, &result](std::string body, unsigned status) {
|
||||
try {
|
||||
if (status == 200) {
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
;
|
||||
}
|
||||
})
|
||||
.on_ip_resolve([this](std::string ip) {
|
||||
wxString ip_report = wxString::Format("test bambulab ip resolved = %s", ip);
|
||||
update_status(TEST_BAMBULAB_JOB, ip_report);
|
||||
})
|
||||
.on_error([this](std::string body, std::string error, unsigned int status) {
|
||||
wxString info = wxString::Format("status=%u, body=%s, error=%s", status, body, error);
|
||||
this->update_status(TEST_BAMBULAB_JOB, "test bambulab failed");
|
||||
this->update_status(-1, info);
|
||||
}).perform_sync();
|
||||
if (result == 0) {
|
||||
update_status(TEST_BAMBULAB_JOB, "test bambulab ok");
|
||||
}
|
||||
m_in_testing[TEST_BAMBULAB_JOB] = false;
|
||||
}
|
||||
|
||||
void NetworkTestDialog::start_test_iot()
|
||||
{
|
||||
m_in_testing[TEST_IOT_JOB] = true;
|
||||
update_status(TEST_IOT_JOB, "test http start...");
|
||||
NetworkAgent* agent = wxGetApp().getAgent();
|
||||
if (agent) {
|
||||
unsigned int http_code;
|
||||
std::string http_body;
|
||||
if (!agent->is_user_login()) {
|
||||
update_status(TEST_IOT_JOB, "please login first");
|
||||
} else {
|
||||
int result = agent->get_user_print_info(&http_code, &http_body);
|
||||
if (result == 0) {
|
||||
update_status(TEST_IOT_JOB, "test http ok");
|
||||
} else {
|
||||
update_status(TEST_IOT_JOB, "test http failed");
|
||||
wxString info = wxString::Format("test http failed, status = %u, error = %s", http_code, http_body);
|
||||
update_status(-1, info);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
update_status(TEST_IOT_JOB, "please install network module first");
|
||||
}
|
||||
m_in_testing[TEST_IOT_JOB] = false;
|
||||
}
|
||||
|
||||
void NetworkTestDialog::start_test_oss()
|
||||
{
|
||||
m_in_testing[TEST_OSS_JOB] = true;
|
||||
update_status(TEST_OSS_JOB, "test storage start...");
|
||||
|
||||
std::string url = "http://upload-file.bambulab.com";
|
||||
|
||||
AppConfig* config = wxGetApp().app_config;
|
||||
if (config) {
|
||||
if (config->get_country_code() == "CN")
|
||||
url = "http://upload-file.bambulab.cn";
|
||||
}
|
||||
|
||||
Slic3r::Http http = Slic3r::Http::get(url);
|
||||
|
||||
int result = -1;
|
||||
http.timeout_max(15)
|
||||
.on_complete([this, &result](std::string body, unsigned status) {
|
||||
try {
|
||||
if (status == 200) {
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
;
|
||||
}
|
||||
})
|
||||
.on_ip_resolve([this](std::string ip) {
|
||||
wxString ip_report = wxString::Format("test oss ip resolved = %s", ip);
|
||||
update_status(TEST_OSS_JOB, ip_report);
|
||||
})
|
||||
.on_error([this, &result](std::string body, std::string error, unsigned int status) {
|
||||
if (status == 403) {
|
||||
result = 0;
|
||||
} else {
|
||||
wxString info = wxString::Format("status=%u, body=%s, error=%s", status, body, error);
|
||||
this->update_status(TEST_OSS_JOB, "test storage failed");
|
||||
this->update_status(-1, info);
|
||||
}
|
||||
}).perform_sync();
|
||||
if (result == 0) {
|
||||
update_status(TEST_OSS_JOB, "test storage ok");
|
||||
}
|
||||
m_in_testing[TEST_OSS_JOB] = false;
|
||||
}
|
||||
|
||||
void NetworkTestDialog::start_test_oss_upgrade()
|
||||
{
|
||||
m_in_testing[TEST_OSS_UPGRADE_JOB] = true;
|
||||
update_status(TEST_OSS_UPGRADE_JOB, "test storage upgrade start...");
|
||||
|
||||
std::string url = "http://upgrade-file.bambulab.com";
|
||||
|
||||
AppConfig* config = wxGetApp().app_config;
|
||||
if (config) {
|
||||
if (config->get_country_code() == "CN")
|
||||
url = "http://upgrade-file.bambulab.cn";
|
||||
}
|
||||
|
||||
Slic3r::Http http = Slic3r::Http::get(url);
|
||||
|
||||
int result = -1;
|
||||
http.timeout_max(15)
|
||||
.on_complete([this, &result](std::string body, unsigned status) {
|
||||
try {
|
||||
if (status == 200) {
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
;
|
||||
}
|
||||
})
|
||||
.on_ip_resolve([this](std::string ip) {
|
||||
wxString ip_report = wxString::Format("test storage upgrade ip resolved = %s", ip);
|
||||
update_status(TEST_OSS_UPGRADE_JOB, ip_report);
|
||||
})
|
||||
.on_error([this, &result](std::string body, std::string error, unsigned int status) {
|
||||
if (status == 403) {
|
||||
result = 0;
|
||||
}
|
||||
else {
|
||||
wxString info = wxString::Format("status=%u, body=%s, error=%s", status, body, error);
|
||||
this->update_status(TEST_OSS_UPGRADE_JOB, "test storage upgrade failed");
|
||||
this->update_status(-1, info);
|
||||
}
|
||||
}).perform_sync();
|
||||
|
||||
if (result == 0) {
|
||||
update_status(TEST_OSS_UPGRADE_JOB, "test storage upgrade ok");
|
||||
}
|
||||
m_in_testing[TEST_OSS_UPGRADE_JOB] = false;
|
||||
}
|
||||
|
||||
void NetworkTestDialog::start_test_oss_download()
|
||||
{
|
||||
int result = 0;
|
||||
// get country_code
|
||||
AppConfig* app_config = wxGetApp().app_config;
|
||||
if (!app_config) {
|
||||
update_status(TEST_OSS_DOWNLOAD_JOB, "app config is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
m_in_testing[TEST_OSS_DOWNLOAD_JOB] = true;
|
||||
update_status(TEST_OSS_DOWNLOAD_JOB, "test storage download start...");
|
||||
m_download_cancel = false;
|
||||
// get temp path
|
||||
fs::path target_file_path = (fs::temp_directory_path() / "test_storage_download.zip");
|
||||
fs::path tmp_path = target_file_path;
|
||||
tmp_path += (boost::format(".%1%%2%") % get_current_pid() % ".tmp").str();
|
||||
|
||||
// get_url
|
||||
std::string url = wxGetApp().get_plugin_url(app_config->get_country_code());
|
||||
std::string download_url;
|
||||
Slic3r::Http http_url = Slic3r::Http::get(url);
|
||||
update_status(-1, "[test_oss_download]: url=" + url);
|
||||
|
||||
http_url.on_complete(
|
||||
[&download_url](std::string body, unsigned status) {
|
||||
try {
|
||||
json j = json::parse(body);
|
||||
std::string message = j["message"].get<std::string>();
|
||||
|
||||
if (message == "success") {
|
||||
json resource = j.at("resources");
|
||||
if (resource.is_array()) {
|
||||
for (auto iter = resource.begin(); iter != resource.end(); iter++) {
|
||||
Semver version;
|
||||
std::string url;
|
||||
std::string type;
|
||||
std::string vendor;
|
||||
std::string description;
|
||||
for (auto sub_iter = iter.value().begin(); sub_iter != iter.value().end(); sub_iter++) {
|
||||
if (boost::iequals(sub_iter.key(), "type")) {
|
||||
type = sub_iter.value();
|
||||
BOOST_LOG_TRIVIAL(info) << "[test_storage_download]: get version of settings's type, " << sub_iter.value();
|
||||
}
|
||||
else if (boost::iequals(sub_iter.key(), "version")) {
|
||||
version = *(Semver::parse(sub_iter.value()));
|
||||
}
|
||||
else if (boost::iequals(sub_iter.key(), "description")) {
|
||||
description = sub_iter.value();
|
||||
}
|
||||
else if (boost::iequals(sub_iter.key(), "url")) {
|
||||
url = sub_iter.value();
|
||||
}
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << "[test_storage_download]: get type " << type << ", version " << version.to_string() << ", url " << url;
|
||||
download_url = url;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
BOOST_LOG_TRIVIAL(info) << "[test_storage_download]: get version of plugin failed, body=" << body;
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
BOOST_LOG_TRIVIAL(error) << "[test_storage_download]: catch unknown exception";
|
||||
;
|
||||
}
|
||||
}).on_error(
|
||||
[&result, this](std::string body, std::string error, unsigned int status) {
|
||||
BOOST_LOG_TRIVIAL(error) << "[test_storage_download] on_error: " << error << ", body = " << body;
|
||||
wxString info = wxString::Format("status=%u, body=%s, error=%s", status, body, error);
|
||||
this->update_status(TEST_OSS_DOWNLOAD_JOB, "test storage download failed");
|
||||
this->update_status(-1, info);
|
||||
result = -1;
|
||||
}).perform_sync();
|
||||
|
||||
if (result < 0) {
|
||||
this->update_status(TEST_OSS_DOWNLOAD_JOB, "test storage download failed");
|
||||
m_in_testing[TEST_OSS_DOWNLOAD_JOB] = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (download_url.empty()) {
|
||||
BOOST_LOG_TRIVIAL(info) << "[test_oss_download]: no availaible plugin found for this app version: " << SLIC3R_VERSION;
|
||||
this->update_status(TEST_OSS_DOWNLOAD_JOB, "test storage download failed");
|
||||
m_in_testing[TEST_OSS_DOWNLOAD_JOB] = false;
|
||||
return;
|
||||
}
|
||||
if (m_download_cancel) {
|
||||
this->update_status(TEST_OSS_DOWNLOAD_JOB, "test storage download canceled");
|
||||
m_in_testing[TEST_OSS_DOWNLOAD_JOB] = false;
|
||||
return;
|
||||
}
|
||||
|
||||
bool cancel = false;
|
||||
BOOST_LOG_TRIVIAL(info) << "[test_storage_download] get_url = " << download_url;
|
||||
|
||||
// download
|
||||
Slic3r::Http http = Slic3r::Http::get(download_url);
|
||||
int reported_percent = 0;
|
||||
http.on_progress(
|
||||
[this, &result, &reported_percent](Slic3r::Http::Progress progress, bool& cancel) {
|
||||
int percent = 0;
|
||||
if (progress.dltotal != 0) {
|
||||
percent = progress.dlnow * 100 / progress.dltotal;
|
||||
}
|
||||
if (percent - reported_percent >= 10) {
|
||||
reported_percent = percent;
|
||||
std::string download_progress_info = (boost::format("downloading %1%%%") % percent).str();
|
||||
this->update_status(TEST_OSS_DOWNLOAD_JOB, download_progress_info);
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "[test_storage_download] progress: " << reported_percent;
|
||||
cancel = m_download_cancel;
|
||||
|
||||
if (cancel)
|
||||
result = -1;
|
||||
})
|
||||
.on_complete([this, tmp_path, target_file_path](std::string body, unsigned status) {
|
||||
BOOST_LOG_TRIVIAL(info) << "[test_storage_download] completed";
|
||||
bool cancel = false;
|
||||
fs::fstream file(tmp_path, std::ios::out | std::ios::binary | std::ios::trunc);
|
||||
file.write(body.c_str(), body.size());
|
||||
file.close();
|
||||
fs::rename(tmp_path, target_file_path);
|
||||
this->update_status(TEST_OSS_DOWNLOAD_JOB, "test storage download ok");
|
||||
})
|
||||
.on_error([this, &result](std::string body, std::string error, unsigned int status) {
|
||||
BOOST_LOG_TRIVIAL(error) << "[test_oss_download] downloading... on_error: " << error << ", body = " << body;
|
||||
wxString info = wxString::Format("status=%u, body=%s, error=%s", status, body, error);
|
||||
this->update_status(TEST_OSS_DOWNLOAD_JOB, "test storage download failed");
|
||||
this->update_status(-1, info);
|
||||
result = -1;
|
||||
});
|
||||
http.perform_sync();
|
||||
if (result < 0) {
|
||||
this->update_status(TEST_OSS_DOWNLOAD_JOB, "test storage download failed");
|
||||
} else {
|
||||
this->update_status(TEST_OSS_DOWNLOAD_JOB, "test storage download ok");
|
||||
}
|
||||
m_in_testing[TEST_OSS_DOWNLOAD_JOB] = false;
|
||||
return;
|
||||
}
|
||||
|
||||
void NetworkTestDialog::start_test_oss_upload()
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
void NetworkTestDialog::start_test_ping_thread()
|
||||
{
|
||||
test_job[TEST_PING_JOB] = new boost::thread([this] {
|
||||
m_in_testing[TEST_PING_JOB] = true;
|
||||
|
||||
m_in_testing[TEST_PING_JOB] = false;
|
||||
});
|
||||
}
|
||||
|
||||
void NetworkTestDialog::start_test_bing_thread()
|
||||
{
|
||||
test_job[TEST_BING_JOB] = new boost::thread([this] {
|
||||
start_test_bing();
|
||||
});
|
||||
}
|
||||
|
||||
void NetworkTestDialog::start_test_bambulab_thread()
|
||||
{
|
||||
if (m_in_testing[TEST_BAMBULAB_JOB]) return;
|
||||
test_job[TEST_BAMBULAB_JOB] = new boost::thread([this] {
|
||||
start_test_bambulab();
|
||||
});
|
||||
}
|
||||
|
||||
void NetworkTestDialog::start_test_iot_thread()
|
||||
{
|
||||
if (m_in_testing[TEST_IOT_JOB]) return;
|
||||
test_job[TEST_IOT_JOB] = new boost::thread([this] {
|
||||
start_test_iot();
|
||||
});
|
||||
}
|
||||
|
||||
void NetworkTestDialog::start_test_oss_thread()
|
||||
{
|
||||
test_job[TEST_OSS_JOB] = new boost::thread([this] {
|
||||
start_test_oss();
|
||||
});
|
||||
}
|
||||
|
||||
void NetworkTestDialog::start_test_oss_upgrade_thread()
|
||||
{
|
||||
test_job[TEST_OSS_UPGRADE_JOB] = new boost::thread([this] {
|
||||
start_test_oss_upgrade();
|
||||
});
|
||||
}
|
||||
|
||||
void NetworkTestDialog::start_test_oss_download_thread()
|
||||
{
|
||||
test_job[TEST_OSS_DOWNLOAD_JOB] = new boost::thread([this] {
|
||||
start_test_oss_download();
|
||||
});
|
||||
}
|
||||
|
||||
void NetworkTestDialog::start_test_oss_upload_thread()
|
||||
{
|
||||
test_job[TEST_OSS_UPLOAD_JOB] = new boost::thread([this] {
|
||||
start_test_oss_upload();
|
||||
});
|
||||
}
|
||||
|
||||
void NetworkTestDialog::on_close(wxCloseEvent& event)
|
||||
{
|
||||
m_download_cancel = true;
|
||||
m_closing = true;
|
||||
for (int i = 0; i < TEST_JOB_MAX; i++) {
|
||||
if (test_job[i]) {
|
||||
test_job[i]->join();
|
||||
test_job[i] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
wxString NetworkTestDialog::get_studio_version()
|
||||
{
|
||||
return wxString(SLIC3R_VERSION);
|
||||
}
|
||||
|
||||
void NetworkTestDialog::set_default()
|
||||
{
|
||||
for (int i = 0; i < TEST_JOB_MAX; i++) {
|
||||
test_job[i] = nullptr;
|
||||
m_in_testing[i] = false;
|
||||
}
|
||||
|
||||
m_sequence_job = nullptr;
|
||||
|
||||
text_version_val->SetLabelText(get_studio_version());
|
||||
txt_sys_info_value->SetLabelText(get_os_info());
|
||||
txt_dns_info_value->SetLabelText(get_dns_info());
|
||||
text_link_val->SetLabelText(NA_STR);
|
||||
text_bing_val->SetLabelText(NA_STR);
|
||||
text_iot_value->SetLabelText(NA_STR);
|
||||
text_oss_value->SetLabelText(NA_STR);
|
||||
text_oss_upgrade_value->SetLabelText(NA_STR);
|
||||
text_oss_download_value->SetLabelText(NA_STR);
|
||||
text_oss_upload_value->SetLabelText(NA_STR);
|
||||
//text_ping_value->SetLabelText(NA_STR);
|
||||
m_download_cancel = false;
|
||||
m_closing = false;
|
||||
}
|
||||
|
||||
|
||||
void NetworkTestDialog::on_dpi_changed(const wxRect &suggested_rect)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
void NetworkTestDialog::update_status(int job_id, wxString info)
|
||||
{
|
||||
auto evt = new wxCommandEvent(EVT_UPDATE_RESULT, this->GetId());
|
||||
evt->SetString(info);
|
||||
evt->SetInt(job_id);
|
||||
wxQueueEvent(this, evt);
|
||||
}
|
||||
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
||||
|
138
src/slic3r/GUI/NetworkTestDialog.hpp
Normal file
138
src/slic3r/GUI/NetworkTestDialog.hpp
Normal file
|
@ -0,0 +1,138 @@
|
|||
#ifndef slic3r_GUI_NetworkTestDialog_hpp_
|
||||
#define slic3r_GUI_NetworkTestDialog_hpp_
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
#include "GUI_Utils.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/bitmap.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/icon.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/font.h>
|
||||
#include <wx/colour.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/grid.h>
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/srchctrl.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <iomanip>
|
||||
#include <sys/timeb.h>
|
||||
#include <time.h>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
enum TestJob {
|
||||
TEST_BING_JOB = 0,
|
||||
TEST_BAMBULAB_JOB = 1,
|
||||
TEST_IOT_JOB = 2,
|
||||
TEST_OSS_JOB = 3,
|
||||
TEST_OSS_UPGRADE_JOB = 4,
|
||||
TEST_OSS_DOWNLOAD_JOB = 5,
|
||||
TEST_OSS_UPLOAD_JOB = 6,
|
||||
TEST_PING_JOB = 7,
|
||||
TEST_JOB_MAX = 8
|
||||
};
|
||||
|
||||
class NetworkTestDialog : public DPIDialog
|
||||
{
|
||||
protected:
|
||||
wxButton* btn_start;
|
||||
wxButton* btn_start_sequence;
|
||||
wxButton* btn_download_log;
|
||||
wxStaticText* text_basic_info;
|
||||
wxStaticText* text_version_title;
|
||||
wxStaticText* text_version_val;
|
||||
wxStaticText* txt_sys_info_title;
|
||||
wxStaticText* txt_sys_info_value;
|
||||
wxStaticText* txt_dns_info_title;
|
||||
wxStaticText* txt_dns_info_value;
|
||||
wxButton* btn_link;
|
||||
wxStaticText* text_link_title;
|
||||
wxStaticText* text_link_val;
|
||||
wxButton* btn_bing;
|
||||
wxStaticText* text_bing_title;
|
||||
wxStaticText* text_bing_val;
|
||||
wxButton* btn_iot;
|
||||
wxStaticText* text_iot_title;
|
||||
wxStaticText* text_iot_value;
|
||||
wxButton* btn_oss;
|
||||
wxStaticText* text_oss_title;
|
||||
wxStaticText* text_oss_value;
|
||||
wxButton* btn_oss_upgrade;
|
||||
wxStaticText* text_oss_upgrade_title;
|
||||
wxStaticText* text_oss_upgrade_value;
|
||||
wxButton* btn_oss_download;
|
||||
wxStaticText* text_oss_download_title;
|
||||
wxStaticText* text_oss_download_value;
|
||||
wxButton* btn_oss_upload;
|
||||
wxStaticText* text_oss_upload_title;
|
||||
wxStaticText* text_oss_upload_value;
|
||||
wxStaticText* text_ping_title;
|
||||
wxStaticText* text_ping_value;
|
||||
wxStaticText* text_result;
|
||||
wxTextCtrl* txt_log;
|
||||
|
||||
wxBoxSizer* create_top_sizer(wxWindow* parent);
|
||||
wxBoxSizer* create_info_sizer(wxWindow* parent);
|
||||
wxBoxSizer* create_content_sizer(wxWindow* parent);
|
||||
wxBoxSizer* create_result_sizer(wxWindow* parent);
|
||||
|
||||
boost::thread* test_job[TEST_JOB_MAX];
|
||||
boost::thread* m_sequence_job { nullptr };
|
||||
bool m_in_testing[TEST_JOB_MAX];
|
||||
bool m_download_cancel = false;
|
||||
bool m_closing = false;
|
||||
|
||||
void init_bind();
|
||||
|
||||
public:
|
||||
NetworkTestDialog(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(605, 375), long style = wxDEFAULT_DIALOG_STYLE);
|
||||
|
||||
~NetworkTestDialog();
|
||||
|
||||
void on_dpi_changed(const wxRect& suggested_rect);
|
||||
|
||||
void set_default();
|
||||
wxString get_studio_version();
|
||||
wxString get_os_info();
|
||||
wxString get_dns_info();
|
||||
|
||||
void start_all_job();
|
||||
void start_all_job_sequence();
|
||||
void start_test_bing_thread();
|
||||
void start_test_bambulab_thread();
|
||||
void start_test_iot_thread();
|
||||
void start_test_oss_thread();
|
||||
void start_test_oss_upgrade_thread();
|
||||
void start_test_oss_download_thread();
|
||||
void start_test_oss_upload_thread();
|
||||
void start_test_ping_thread();
|
||||
|
||||
void start_test_bing();
|
||||
void start_test_bambulab();
|
||||
void start_test_iot();
|
||||
void start_test_oss();
|
||||
void start_test_oss_upgrade();
|
||||
void start_test_oss_download();
|
||||
void start_test_oss_upload();
|
||||
|
||||
void on_close(wxCloseEvent& event);
|
||||
|
||||
void update_status(int job_id, wxString info);
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif
|
|
@ -20,6 +20,11 @@
|
|||
|
||||
#include "GUI_App.hpp"
|
||||
|
||||
#ifndef IMGUI_DEFINE_MATH_OPERATORS
|
||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
#endif
|
||||
#include <imgui/imgui_internal.h>
|
||||
|
||||
static constexpr float GAP_WIDTH = 10.0f;
|
||||
static constexpr float SPACE_RIGHT_PANEL = 10.0f;
|
||||
static constexpr float FADING_OUT_DURATION = 2.0f;
|
||||
|
@ -580,8 +585,17 @@ void NotificationManager::PopNotification::render_close_button(ImGuiWrapper& img
|
|||
void NotificationManager::PopNotification::bbl_render_left_sign(ImGuiWrapper &imgui, const float win_size_x, const float win_size_y, const float win_pos_x, const float win_pos_y)
|
||||
{
|
||||
ImDrawList *draw_list = ImGui::GetWindowDrawList();
|
||||
draw_list->AddRectFilled(ImVec2(win_pos_x - win_size_x, win_pos_y), ImVec2(win_pos_x - win_size_x + m_WindowRadius * 2, win_pos_y + win_size_y),ImGui::GetColorU32(ImVec4(m_CurrentColor.x, m_CurrentColor.y, m_CurrentColor.z,m_current_fade_opacity)), m_WindowRadius);
|
||||
draw_list->AddRectFilled(ImVec2(win_pos_x - win_size_x-m_WindowRadius, win_pos_y), ImVec2(win_pos_x - win_size_x + 10, win_pos_y + win_size_y),ImGui::GetColorU32(ImVec4(m_CurrentColor.x, m_CurrentColor.y, m_CurrentColor.z, m_current_fade_opacity)), 0);
|
||||
|
||||
ImVec2 round_rect_pos = ImVec2(win_pos_x - win_size_x, win_pos_y);
|
||||
ImVec2 round_rect_size = ImVec2(m_WindowRadius * 2, win_size_y);
|
||||
|
||||
ImVec2 rect_pos = round_rect_pos + ImVec2(m_WindowRadius, 0);
|
||||
ImVec2 rect_size = ImVec2(m_WindowRadius + 2 * wxGetApp().plater()->get_current_canvas3D()->get_scale(), win_size_y);
|
||||
|
||||
ImU32 clr = ImGui::GetColorU32(ImVec4(m_CurrentColor.x, m_CurrentColor.y, m_CurrentColor.z, m_current_fade_opacity));
|
||||
|
||||
draw_list->AddRectFilled(round_rect_pos, round_rect_pos + round_rect_size, clr, m_WindowRadius);
|
||||
draw_list->AddRectFilled(rect_pos, rect_pos + rect_size, clr, 0);
|
||||
}
|
||||
|
||||
void NotificationManager::PopNotification::render_left_sign(ImGuiWrapper& imgui)
|
||||
|
|
|
@ -333,18 +333,6 @@ void ObjectDataViewModelNode::SetPlateIdx(const int& idx)
|
|||
m_plate_idx = idx;
|
||||
}
|
||||
|
||||
// BBS
|
||||
bool ObjectDataViewModelNode::IsTimelapseWipeTower() const
|
||||
{
|
||||
if (m_model_object == nullptr)
|
||||
return false;
|
||||
|
||||
if (!(m_type & itObject) && !(m_type & itInstance))
|
||||
return false;
|
||||
|
||||
return m_model_object->is_timelapse_wipe_tower;
|
||||
}
|
||||
|
||||
void ObjectDataViewModelNode::UpdateExtruderAndColorIcon(wxString extruder /*= ""*/)
|
||||
{
|
||||
if (m_type == itVolume && m_volume_type != ModelVolumeType::MODEL_PART && m_volume_type != ModelVolumeType::PARAMETER_MODIFIER)
|
||||
|
|
|
@ -227,7 +227,6 @@ public:
|
|||
bool HasSupportPainting() const { return m_support_enable; }
|
||||
bool IsActionEnabled() const { return m_action_enable; }
|
||||
void UpdateExtruderAndColorIcon(wxString extruder = "");
|
||||
bool IsTimelapseWipeTower() const;
|
||||
|
||||
// use this function only for childrens
|
||||
void AssignAllVal(ObjectDataViewModelNode& from_node)
|
||||
|
|
|
@ -67,7 +67,7 @@ TipsDialog::TipsDialog(wxWindow *parent, const wxString &title)
|
|||
m_confirm->SetTextColor(wxColour(255, 255, 255));
|
||||
m_confirm->SetSize(TIPS_DIALOG_BUTTON_SIZE);
|
||||
m_confirm->SetMinSize(TIPS_DIALOG_BUTTON_SIZE);
|
||||
m_confirm->SetCornerRadius(12);
|
||||
m_confirm->SetCornerRadius(FromDIP(12));
|
||||
m_confirm->Bind(wxEVT_LEFT_DOWN, &TipsDialog::on_ok, this);
|
||||
m_sizer_right->Add(m_confirm, 0, wxALL, FromDIP(5));
|
||||
|
||||
|
@ -210,8 +210,7 @@ ParamsPanel::ParamsPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, c
|
|||
|
||||
m_process_icon = new ScalableButton(m_top_panel, wxID_ANY, "process");
|
||||
|
||||
m_title_label = new Label(Label::Body_14, _L("Process"), m_top_panel);
|
||||
m_title_label->Wrap( -1 );
|
||||
m_title_label = new Label(m_top_panel, _L("Process"));
|
||||
|
||||
//int width, height;
|
||||
// BBS: new layout
|
||||
|
@ -222,8 +221,7 @@ ParamsPanel::ParamsPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, c
|
|||
m_tips_arrow = new wxStaticBitmap(m_top_panel, wxID_ANY, m_tips_arrow_icon);
|
||||
m_tips_arrow->Hide();
|
||||
|
||||
m_title_view = new Label(Label::Body_14, _L("Advance"), m_top_panel);
|
||||
m_title_view->Wrap( -1 );
|
||||
m_title_view = new Label(m_top_panel, _L("Advance"));
|
||||
m_mode_view = new SwitchButton(m_top_panel, wxID_ABOUT);
|
||||
|
||||
// BBS: new layout
|
||||
|
|
|
@ -1103,8 +1103,12 @@ Vec3d PartPlate::estimate_wipe_tower_size(const double w, const double wipe_volu
|
|||
}
|
||||
wipe_tower_size(2) = max_height;
|
||||
|
||||
const DynamicPrintConfig &dconfig = wxGetApp().preset_bundle->prints.get_edited_preset().config;
|
||||
const ConfigOption* option = dconfig.option("timelapse_no_toolhead");
|
||||
bool timelapse_enabled = option ? option->getBool() : false;
|
||||
|
||||
double depth = wipe_volume * (plate_extruders.size() - 1) / (layer_height * w);
|
||||
if (depth > EPSILON) {
|
||||
if (timelapse_enabled || depth > EPSILON) {
|
||||
float min_wipe_tower_depth = 0.f;
|
||||
auto iter = WipeTower::min_depth_per_height.begin();
|
||||
while (iter != WipeTower::min_depth_per_height.end()) {
|
||||
|
@ -1142,26 +1146,6 @@ Vec3d PartPlate::estimate_wipe_tower_size(const double w, const double wipe_volu
|
|||
return wipe_tower_size;
|
||||
}
|
||||
|
||||
double PartPlate::estimate_timelapse_wipe_tower_height(int *highest_extruder_id) const
|
||||
{
|
||||
double max_height = 0;
|
||||
int highest_extruder = 0;
|
||||
|
||||
// auto m_model = wxGetApp().plater()->get_obj
|
||||
for (int obj_idx = 0; obj_idx < m_model->objects.size(); obj_idx++) {
|
||||
if (!contain_instance_totally(obj_idx, 0)) continue;
|
||||
if (m_model->objects[obj_idx]->is_timelapse_wipe_tower) continue;
|
||||
|
||||
BoundingBoxf3 bbox = m_model->objects[obj_idx]->bounding_box();
|
||||
if (bbox.size().z() > max_height) {
|
||||
max_height = bbox.size().z();
|
||||
highest_extruder = m_model->objects[obj_idx]->config.opt_int("extruder");
|
||||
}
|
||||
}
|
||||
if (highest_extruder_id) *highest_extruder_id = highest_extruder;
|
||||
return max_height;
|
||||
}
|
||||
|
||||
bool PartPlate::operator<(PartPlate& plate) const
|
||||
{
|
||||
int index = plate.get_index();
|
||||
|
@ -1636,33 +1620,6 @@ void PartPlate::move_instances_to(PartPlate& left_plate, PartPlate& right_plate,
|
|||
return;
|
||||
}
|
||||
|
||||
//can add timelapse object
|
||||
bool PartPlate::can_add_timelapse_object()
|
||||
{
|
||||
bool result = true;
|
||||
|
||||
if (obj_to_instance_set.size() == 0)
|
||||
return false;
|
||||
|
||||
for (std::set<std::pair<int, int>>::iterator it = obj_to_instance_set.begin(); it != obj_to_instance_set.end(); ++it)
|
||||
{
|
||||
int obj_id = it->first;
|
||||
|
||||
if (obj_id >= m_model->objects.size())
|
||||
continue;
|
||||
|
||||
ModelObject* object = m_model->objects[obj_id];
|
||||
|
||||
if (object->is_timelapse_wipe_tower)
|
||||
{
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void PartPlate::generate_logo_polygon(ExPolygon &logo_polygon)
|
||||
{
|
||||
if (m_shape.size() == 4)
|
||||
|
|
|
@ -238,7 +238,6 @@ public:
|
|||
|
||||
Vec3d get_origin() { return m_origin; }
|
||||
Vec3d estimate_wipe_tower_size(const double w, const double wipe_volume) const;
|
||||
double estimate_timelapse_wipe_tower_height(int* highest_extruder_id=NULL) const;
|
||||
std::vector<int> get_extruders() const;
|
||||
|
||||
/* instance related operations*/
|
||||
|
@ -278,9 +277,6 @@ public:
|
|||
//move instances to left or right PartPlate
|
||||
void move_instances_to(PartPlate& left_plate, PartPlate& right_plate, BoundingBoxf3* bounding_box = nullptr);
|
||||
|
||||
//can add timelapse object
|
||||
bool can_add_timelapse_object();
|
||||
|
||||
/*rendering related functions*/
|
||||
const Pointfs& get_shape() const { return m_shape; }
|
||||
bool set_shape(const Pointfs& shape, const Pointfs& exclude_areas, Vec2d position, float height_to_lid, float height_to_rod);
|
||||
|
|
|
@ -451,10 +451,7 @@ Sidebar::Sidebar(Plater *parent)
|
|||
p->m_panel_printer_title->SetBackgroundColor2(0xF1F1F1);
|
||||
|
||||
p->m_printer_icon = new ScalableButton(p->m_panel_printer_title, wxID_ANY, "printer");
|
||||
p->m_text_printer_settings = new wxStaticText(p->m_panel_printer_title, wxID_ANY, _L("Printer"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
p->m_text_printer_settings->Wrap(-1);
|
||||
p->m_text_printer_settings->SetFont(Label::Body_14);
|
||||
p->m_text_printer_settings->SetBackgroundColour(0xF1F1F1);
|
||||
p->m_text_printer_settings = new Label(p->m_panel_printer_title, _L("Printer"));
|
||||
|
||||
p->m_printer_setting = new ScalableButton(p->m_panel_printer_title, wxID_ANY, "settings");
|
||||
p->m_printer_setting->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) {
|
||||
|
@ -539,7 +536,7 @@ Sidebar::Sidebar(Plater *parent)
|
|||
|
||||
m_bed_type_list->Select(0);
|
||||
bed_type_sizer->Add(bed_type_title, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, FromDIP(10));
|
||||
bed_type_sizer->Add(m_bed_type_list, 1, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL | wxEXPAND, FromDIP(10));
|
||||
bed_type_sizer->Add(m_bed_type_list, 1, wxLEFT | wxRIGHT | wxEXPAND, FromDIP(10));
|
||||
vsizer_printer->Add(bed_type_sizer, 0, wxEXPAND | wxTOP, FromDIP(5));
|
||||
|
||||
p->m_panel_printer_content->SetSizer(vsizer_printer);
|
||||
|
@ -557,10 +554,7 @@ Sidebar::Sidebar(Plater *parent)
|
|||
wxBoxSizer* bSizer39;
|
||||
bSizer39 = new wxBoxSizer( wxHORIZONTAL );
|
||||
p->m_filament_icon = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "filament");
|
||||
p->m_staticText_filament_settings = new wxStaticText( p->m_panel_filament_title, wxID_ANY, _L("Filament"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
p->m_staticText_filament_settings->Wrap( -1 );
|
||||
p->m_staticText_filament_settings->SetFont(Label::Body_14);
|
||||
p->m_staticText_filament_settings->SetBackgroundColour(0xF1F1F1);
|
||||
p->m_staticText_filament_settings = new Label(p->m_panel_filament_title, _L("Filament"));
|
||||
bSizer39->Add(p->m_filament_icon, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, FromDIP(10));
|
||||
bSizer39->Add( p->m_staticText_filament_settings, 0, wxALIGN_CENTER );
|
||||
bSizer39->Add(FromDIP(10), 0, 0, 0, 0);
|
||||
|
@ -806,7 +800,7 @@ void Sidebar::init_filament_combo(PlaterPresetComboBox **combo, const int filame
|
|||
auto side = filament_idx % 2;
|
||||
auto /***/sizer_filaments = this->p->sizer_filaments->GetItem(side)->GetSizer();
|
||||
if (side == 1 && filament_idx > 1) sizer_filaments->Remove(filament_idx / 2);
|
||||
sizer_filaments->Add(combo_and_btn_sizer, 1, wxALIGN_CENTER | wxEXPAND);
|
||||
sizer_filaments->Add(combo_and_btn_sizer, 1, wxEXPAND);
|
||||
if (side == 0) {
|
||||
sizer_filaments = this->p->sizer_filaments->GetItem(1)->GetSizer();
|
||||
sizer_filaments->AddStretchSpacer(1);
|
||||
|
@ -1808,7 +1802,6 @@ struct Plater::priv
|
|||
// Sets m_bed.m_polygon to limit the object placement.
|
||||
//BBS: add bed exclude area
|
||||
void set_bed_shape(const Pointfs& shape, const Pointfs& exclude_areas, const double printable_height, const std::string& custom_texture, const std::string& custom_model, bool force_as_custom = false);
|
||||
bool can_add_timelapse_wt() const;
|
||||
|
||||
bool can_delete() const;
|
||||
bool can_delete_all() const;
|
||||
|
@ -3720,8 +3713,10 @@ void Plater::priv::process_validation_warning(StringObjectException const &warni
|
|||
auto action_fn = (mo || !warning.opt_key.empty()) ? [id = mo ? mo->id() : 0, opt = warning.opt_key](wxEvtHandler *) {
|
||||
auto & objects = wxGetApp().model().objects;
|
||||
auto iter = id.id ? std::find_if(objects.begin(), objects.end(), [id](auto o) { return o->id() == id; }) : objects.end();
|
||||
if (iter != objects.end())
|
||||
if (iter != objects.end()) {
|
||||
wxGetApp().mainframe->select_tab(MainFrame::tp3DEditor);
|
||||
wxGetApp().obj_list()->select_items({{*iter, nullptr}});
|
||||
}
|
||||
if (!opt.empty()) {
|
||||
if (iter != objects.end())
|
||||
wxGetApp().params_panel()->switch_to_object();
|
||||
|
@ -4802,7 +4797,7 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
|
|||
|
||||
if (preset_type == Preset::TYPE_FILAMENT) {
|
||||
wxGetApp().preset_bundle->set_filament_preset(idx, preset_name);
|
||||
//wxGetApp().get_tab(preset_type)->select_preset(preset_name);
|
||||
wxGetApp().plater()->update_project_dirty_from_presets();
|
||||
}
|
||||
|
||||
bool select_preset = !combo->selection_is_changed_according_to_physical_printers();
|
||||
|
@ -5991,16 +5986,6 @@ void Plater::priv::set_bed_shape(const Pointfs& shape, const Pointfs& exclude_ar
|
|||
}
|
||||
}
|
||||
|
||||
bool Plater::priv::can_add_timelapse_wt() const {
|
||||
const DynamicPrintConfig &dconfig = wxGetApp().preset_bundle->prints.get_edited_preset().config;
|
||||
const ConfigOption* option = dconfig.option("timelapse_no_toolhead");
|
||||
bool timelapse_enabled = option?option->getBool():false;
|
||||
|
||||
PartPlate* curr_plate = q->get_partplate_list().get_curr_plate();
|
||||
|
||||
return timelapse_enabled && curr_plate->can_add_timelapse_object();
|
||||
}
|
||||
|
||||
bool Plater::priv::can_delete() const
|
||||
{
|
||||
return !get_selection().is_empty() && !get_selection().is_wipe_tower();
|
||||
|
@ -7031,7 +7016,7 @@ ProjectDropDialog::ProjectDropDialog(const std::string &filename)
|
|||
m_confirm->SetTextColor(wxColour(255, 255, 255));
|
||||
m_confirm->SetSize(PROJECT_DROP_DIALOG_BUTTON_SIZE);
|
||||
m_confirm->SetMinSize(PROJECT_DROP_DIALOG_BUTTON_SIZE);
|
||||
m_confirm->SetCornerRadius(12);
|
||||
m_confirm->SetCornerRadius(FromDIP(12));
|
||||
m_confirm->Bind(wxEVT_LEFT_DOWN, &ProjectDropDialog::on_select_ok, this);
|
||||
m_sizer_right->Add(m_confirm, 0, wxALL, 5);
|
||||
|
||||
|
@ -7039,7 +7024,7 @@ ProjectDropDialog::ProjectDropDialog(const std::string &filename)
|
|||
m_cancel->SetTextColor(wxColour(107, 107, 107));
|
||||
m_cancel->SetSize(PROJECT_DROP_DIALOG_BUTTON_SIZE);
|
||||
m_cancel->SetMinSize(PROJECT_DROP_DIALOG_BUTTON_SIZE);
|
||||
m_cancel->SetCornerRadius(12);
|
||||
m_cancel->SetCornerRadius(FromDIP(12));
|
||||
m_cancel->Bind(wxEVT_LEFT_DOWN, &ProjectDropDialog::on_select_cancel, this);
|
||||
m_sizer_right->Add(m_cancel, 0, wxALL, 5);
|
||||
|
||||
|
@ -7272,7 +7257,7 @@ bool Plater::load_files(const wxArrayString& filenames)
|
|||
}
|
||||
}
|
||||
|
||||
Plater::TakeSnapshot snapshot(this, snapshot_label);
|
||||
//Plater::TakeSnapshot snapshot(this, snapshot_label);
|
||||
//load_files(normal_paths, LoadStrategy::LoadModel);
|
||||
|
||||
// BBS: check file types
|
||||
|
@ -7305,10 +7290,11 @@ bool Plater::load_files(const wxArrayString& filenames)
|
|||
open_3mf_file(normal_paths[0]);
|
||||
break;
|
||||
|
||||
case LoadFilesType::SingleOther:
|
||||
case LoadFilesType::SingleOther: {
|
||||
Plater::TakeSnapshot snapshot(this, snapshot_label);
|
||||
if (load_files(normal_paths, LoadStrategy::LoadModel, false).empty()) { res = false; }
|
||||
break;
|
||||
|
||||
}
|
||||
case LoadFilesType::Multiple3MF:
|
||||
first_file = std::vector<fs::path>{normal_paths[0]};
|
||||
for (auto i = 0; i < normal_paths.size(); i++) {
|
||||
|
@ -7319,9 +7305,11 @@ bool Plater::load_files(const wxArrayString& filenames)
|
|||
if (load_files(other_file, LoadStrategy::LoadModel).empty()) { res = false; }
|
||||
break;
|
||||
|
||||
case LoadFilesType::MultipleOther:
|
||||
if (load_files(normal_paths, LoadStrategy::LoadModel, true).empty()) { res = false; }
|
||||
case LoadFilesType::MultipleOther: {
|
||||
Plater::TakeSnapshot snapshot(this, snapshot_label);
|
||||
if (load_files(normal_paths, LoadStrategy::LoadModel, true).empty()) { res = false; }
|
||||
break;
|
||||
}
|
||||
|
||||
case LoadFilesType::Multiple3MFOther:
|
||||
for (const auto &path : normal_paths) {
|
||||
|
@ -7374,15 +7362,8 @@ bool Plater::open_3mf_file(const fs::path &file_path)
|
|||
|
||||
if (load_type == LoadType::Unknown) return false;
|
||||
|
||||
struct AllowSnapshots {
|
||||
AllowSnapshots(Plater *plater) : m_plater(plater) { m_plater->allow_snapshots(); }
|
||||
~AllowSnapshots() { m_plater->suppress_snapshots(); }
|
||||
Plater *m_plater;
|
||||
};
|
||||
switch (load_type) {
|
||||
case LoadType::OpenProject: {
|
||||
// remove snapshot taken by load_files and add_file
|
||||
AllowSnapshots as(this);
|
||||
if (wxGetApp().can_load_project())
|
||||
load_project(from_path(file_path));
|
||||
break;
|
||||
|
@ -7433,8 +7414,6 @@ void Plater::add_file()
|
|||
snapshot_label += encode_path(paths[i].filename().string().c_str());
|
||||
}
|
||||
|
||||
Plater::TakeSnapshot snapshot(this, snapshot_label);
|
||||
|
||||
// BBS: check file types
|
||||
auto loadfiles_type = LoadFilesType::NoFile;
|
||||
auto amf_files_count = get_3mf_file_count(paths);
|
||||
|
@ -7455,10 +7434,11 @@ void Plater::add_file()
|
|||
open_3mf_file(paths[0]);
|
||||
break;
|
||||
|
||||
case LoadFilesType::SingleOther:
|
||||
case LoadFilesType::SingleOther: {
|
||||
Plater::TakeSnapshot snapshot(this, snapshot_label);
|
||||
if (!load_files(paths, LoadStrategy::LoadModel, false).empty()) { wxGetApp().mainframe->update_title(); }
|
||||
break;
|
||||
|
||||
}
|
||||
case LoadFilesType::Multiple3MF:
|
||||
first_file = std::vector<fs::path>{paths[0]};
|
||||
for (auto i = 0; i < paths.size(); i++) {
|
||||
|
@ -7469,12 +7449,13 @@ void Plater::add_file()
|
|||
if (!load_files(other_file, LoadStrategy::LoadModel).empty()) { wxGetApp().mainframe->update_title(); }
|
||||
break;
|
||||
|
||||
case LoadFilesType::MultipleOther:
|
||||
case LoadFilesType::MultipleOther: {
|
||||
Plater::TakeSnapshot snapshot(this, snapshot_label);
|
||||
if (!load_files(paths, LoadStrategy::LoadModel, true).empty()) {
|
||||
wxGetApp().mainframe->update_title();
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
case LoadFilesType::Multiple3MFOther:
|
||||
for (const auto &path : paths) {
|
||||
if (wxString(encode_path(path.filename().string().c_str())).EndsWith("3mf")) {
|
||||
|
@ -9947,7 +9928,6 @@ void Plater::show_status_message(std::string s)
|
|||
BOOST_LOG_TRIVIAL(trace) << "show_status_message:" << s;
|
||||
}
|
||||
|
||||
bool Plater::can_add_timelapse_wt() const { return p->can_add_timelapse_wt(); } // BBS
|
||||
bool Plater::can_delete() const { return p->can_delete(); }
|
||||
bool Plater::can_delete_all() const { return p->can_delete_all(); }
|
||||
bool Plater::can_add_model() const { return !is_background_process_slicing(); }
|
||||
|
@ -9963,6 +9943,8 @@ bool Plater::can_split_to_volumes() const { return p->can_split_to_volumes(); }
|
|||
bool Plater::can_arrange() const { return p->can_arrange(); }
|
||||
bool Plater::can_paste_from_clipboard() const
|
||||
{
|
||||
if (!IsShown() || !p->is_view3D_shown()) return false;
|
||||
|
||||
const Selection& selection = p->view3D->get_canvas3d()->get_selection();
|
||||
const Selection::Clipboard& clipboard = selection.get_clipboard();
|
||||
|
||||
|
@ -9992,6 +9974,9 @@ bool Plater::can_cut_to_clipboard() const
|
|||
|
||||
bool Plater::can_copy_to_clipboard() const
|
||||
{
|
||||
if (!IsShown() || !p->is_view3D_shown())
|
||||
return false;
|
||||
|
||||
if (is_selection_empty())
|
||||
return false;
|
||||
|
||||
|
@ -10002,8 +9987,8 @@ bool Plater::can_copy_to_clipboard() const
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Plater::can_undo() const { return p->undo_redo_stack().has_undo_snapshot(); }
|
||||
bool Plater::can_redo() const { return p->undo_redo_stack().has_redo_snapshot(); }
|
||||
bool Plater::can_undo() const { return IsShown() && p->is_view3D_shown() && p->undo_redo_stack().has_undo_snapshot(); }
|
||||
bool Plater::can_redo() const { return IsShown() && p->is_view3D_shown() && p->undo_redo_stack().has_redo_snapshot(); }
|
||||
bool Plater::can_reload_from_disk() const { return p->can_reload_from_disk(); }
|
||||
//BBS
|
||||
bool Plater::can_fillcolor() const { return p->can_fillcolor(); }
|
||||
|
|
|
@ -418,7 +418,6 @@ public:
|
|||
|
||||
//BBS:
|
||||
void fill_color(int extruder_id);
|
||||
bool can_add_timelapse_wt() const;
|
||||
|
||||
bool can_delete() const;
|
||||
bool can_delete_all() const;
|
||||
|
|
|
@ -284,7 +284,6 @@ wxBoxSizer *PreferencesDialog::create_item_loglevel_combobox(wxString title, wxW
|
|||
|
||||
std::vector<wxString>::iterator iter;
|
||||
for (iter = vlist.begin(); iter != vlist.end(); iter++) { combobox->Append(*iter); }
|
||||
m_sizer_combox->Add(combobox, 0, wxALIGN_CENTER, 0);
|
||||
|
||||
auto severity_level = app_config->get("severity_level");
|
||||
if (!severity_level.empty()) { combobox->SetValue(severity_level); }
|
||||
|
|
|
@ -30,7 +30,11 @@ void ProjectDirtyStateManager::update_from_presets()
|
|||
if (!app.plater()->get_project_filename().IsEmpty()) {
|
||||
for (const auto &[type, name] : app.get_selected_presets()) {
|
||||
if (type == Preset::Type::TYPE_FILAMENT) {
|
||||
m_presets_dirty |= m_initial_filament_presets != wxGetApp().preset_bundle->filament_presets;
|
||||
m_presets_dirty |= m_initial_filament_presets_names != wxGetApp().preset_bundle->filament_presets;
|
||||
if (ConfigOption *color_option = wxGetApp().preset_bundle->project_config.option("filament_colour")) {
|
||||
auto colors = static_cast<ConfigOptionStrings *>(color_option->clone());
|
||||
m_presets_dirty |= m_initial_filament_presets_colors != colors->values;
|
||||
}
|
||||
} else {
|
||||
m_presets_dirty |= !m_initial_presets[type].empty() && m_initial_presets[type] != name;
|
||||
}
|
||||
|
@ -57,7 +61,11 @@ void ProjectDirtyStateManager::reset_initial_presets()
|
|||
GUI_App &app = wxGetApp();
|
||||
for (const auto &[type, name] : app.get_selected_presets()) {
|
||||
if (type == Preset::Type::TYPE_FILAMENT) {
|
||||
m_initial_filament_presets = wxGetApp().preset_bundle->filament_presets;
|
||||
m_initial_filament_presets_names = wxGetApp().preset_bundle->filament_presets;
|
||||
if (ConfigOption *color_option = wxGetApp().preset_bundle->project_config.option("filament_colour")) {
|
||||
auto colors = static_cast<ConfigOptionStrings *>(color_option->clone());
|
||||
m_initial_filament_presets_colors = colors->values;
|
||||
}
|
||||
} else {
|
||||
m_initial_presets[type] = name;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,8 @@ private:
|
|||
DynamicPrintConfig m_initial_project_config;
|
||||
|
||||
// filament preset independent of the m_initial_presets
|
||||
std::vector<std::string> m_initial_filament_presets;
|
||||
std::vector<std::string> m_initial_filament_presets_names; // all filament preset type name
|
||||
std::vector<std::string> m_initial_filament_presets_colors; // all filament preset color
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
|
|
|
@ -79,9 +79,9 @@ void ReleaseNoteDialog::on_dpi_changed(const wxRect &suggested_rect)
|
|||
{
|
||||
}
|
||||
|
||||
void ReleaseNoteDialog::update_release_note(std::string release_note, std::string version)
|
||||
void ReleaseNoteDialog::update_release_note(wxString release_note, std::string version)
|
||||
{
|
||||
m_text_up_info->SetLabel(wxString::Format("version %s update information :", version));
|
||||
m_text_up_info->SetLabel(wxString::Format(_L("version %s update information :"), version));
|
||||
wxBoxSizer * sizer_text_release_note = new wxBoxSizer(wxVERTICAL);
|
||||
auto m_staticText_release_note = new wxStaticText(m_scrollwindw_release_note, wxID_ANY, release_note, wxDefaultPosition, wxDefaultSize, 0);
|
||||
m_staticText_release_note->Wrap(FromDIP(530));
|
||||
|
@ -147,6 +147,7 @@ UpdateVersionDialog::UpdateVersionDialog(wxWindow *parent)
|
|||
m_butto_ok->SetFont(Label::Body_12);
|
||||
m_butto_ok->SetSize(wxSize(FromDIP(58), FromDIP(24)));
|
||||
m_butto_ok->SetMinSize(wxSize(FromDIP(58), FromDIP(24)));
|
||||
m_butto_ok->SetCornerRadius(FromDIP(12));
|
||||
|
||||
m_butto_ok->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) {
|
||||
EndModal(wxID_YES);
|
||||
|
@ -158,6 +159,7 @@ UpdateVersionDialog::UpdateVersionDialog(wxWindow *parent)
|
|||
m_button_cancel->SetFont(Label::Body_12);
|
||||
m_button_cancel->SetSize(wxSize(FromDIP(58), FromDIP(24)));
|
||||
m_button_cancel->SetMinSize(wxSize(FromDIP(58), FromDIP(24)));
|
||||
m_button_cancel->SetCornerRadius(FromDIP(12));
|
||||
|
||||
m_button_cancel->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) {
|
||||
EndModal(wxID_NO);
|
||||
|
@ -188,7 +190,7 @@ void UpdateVersionDialog::on_dpi_changed(const wxRect &suggested_rect) {
|
|||
|
||||
void UpdateVersionDialog::update_version_info(wxString release_note, wxString version)
|
||||
{
|
||||
m_text_up_info->SetLabel(wxString::Format("Click to download new version in default browser: %s", version));
|
||||
m_text_up_info->SetLabel(wxString::Format(_L("Click to download new version in default browser: %s"), version));
|
||||
wxBoxSizer *sizer_text_release_note = new wxBoxSizer(wxVERTICAL);
|
||||
auto m_staticText_release_note = new wxStaticText(m_scrollwindw_release_note, wxID_ANY, release_note, wxDefaultPosition, wxDefaultSize, 0);
|
||||
m_staticText_release_note->Wrap(FromDIP(530));
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
~ReleaseNoteDialog();
|
||||
|
||||
void on_dpi_changed(const wxRect &suggested_rect) override;
|
||||
void update_release_note(std::string release_note, std::string version);
|
||||
void update_release_note(wxString release_note, std::string version);
|
||||
|
||||
wxStaticText * m_text_up_info{nullptr};
|
||||
wxScrolledWindow *m_scrollwindw_release_note {nullptr};
|
||||
|
|
|
@ -339,7 +339,7 @@ void SavePresetDialog::build(std::vector<Preset::Type> types, std::string suffix
|
|||
m_confirm->SetBorderColor(wxColour(0, 174, 66));
|
||||
m_confirm->SetTextColor(wxColour(255, 255, 255));
|
||||
m_confirm->SetMinSize(SAVE_PRESET_DIALOG_BUTTON_SIZE);
|
||||
m_confirm->SetCornerRadius(12);
|
||||
m_confirm->SetCornerRadius(FromDIP(12));
|
||||
m_confirm->Bind(wxEVT_BUTTON, &SavePresetDialog::accept, this);
|
||||
btns->Add(m_confirm, 0, wxEXPAND, 0);
|
||||
|
||||
|
@ -350,7 +350,7 @@ void SavePresetDialog::build(std::vector<Preset::Type> types, std::string suffix
|
|||
m_cancel = new Button(this, _L("Cancel"));
|
||||
m_cancel->SetMinSize(SAVE_PRESET_DIALOG_BUTTON_SIZE);
|
||||
m_cancel->SetTextColor(wxColour(107, 107, 107));
|
||||
m_cancel->SetCornerRadius(12);
|
||||
m_cancel->SetCornerRadius(FromDIP(12));
|
||||
m_cancel->Bind(wxEVT_BUTTON, &SavePresetDialog::on_select_cancel, this);
|
||||
btns->Add(m_cancel, 0, wxEXPAND, 0);
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ void MachineObjectPanel::doRender(wxDC &dc)
|
|||
dc.SetFont(Label::Body_13);
|
||||
dc.SetBackgroundMode(wxTRANSPARENT);
|
||||
dc.SetTextForeground(SELECT_MACHINE_GREY900);
|
||||
wxString dev_name;
|
||||
wxString dev_name = "";
|
||||
if (m_info) {
|
||||
dev_name = from_u8(m_info->dev_name);
|
||||
}
|
||||
|
@ -367,6 +367,8 @@ SelectMachinePopup::SelectMachinePopup(wxWindow *parent)
|
|||
Bind(EVT_DISSMISS_MACHINE_LIST, &SelectMachinePopup::on_dissmiss_win, this);
|
||||
}
|
||||
|
||||
SelectMachinePopup::~SelectMachinePopup() { delete m_refresh_timer; }
|
||||
|
||||
void SelectMachinePopup::Popup(wxWindow *WXUNUSED(focus))
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(trace) << "get_print_info: start";
|
||||
|
@ -537,6 +539,7 @@ void SelectMachinePopup::update_other_devices()
|
|||
}
|
||||
|
||||
for (int j = i; j < m_other_list_machine_panel.size(); j++) {
|
||||
m_other_list_machine_panel[j]->mPanel->update_machine_info(nullptr);
|
||||
m_other_list_machine_panel[j]->mPanel->Hide();
|
||||
}
|
||||
m_sizer_other_devices->Layout();
|
||||
|
@ -653,6 +656,7 @@ void SelectMachinePopup::update_user_devices()
|
|||
}
|
||||
|
||||
for (int j = i; j < m_user_list_machine_panel.size(); j++) {
|
||||
m_user_list_machine_panel[j]->mPanel->update_machine_info(nullptr);
|
||||
m_user_list_machine_panel[j]->mPanel->Hide();
|
||||
}
|
||||
//m_sizer_my_devices->Layout();
|
||||
|
@ -897,7 +901,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
|
|||
m_button_ensure->SetTextColor(*wxWHITE);
|
||||
m_button_ensure->SetSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
|
||||
m_button_ensure->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
|
||||
m_button_ensure->SetCornerRadius(FromDIP(10));
|
||||
m_button_ensure->SetCornerRadius(FromDIP(12));
|
||||
|
||||
m_button_ensure->Bind(wxEVT_BUTTON, &SelectMachineDialog::on_ok, this);
|
||||
m_sizer_pcont->Add(m_button_ensure, 0, wxEXPAND | wxBOTTOM, FromDIP(10));
|
||||
|
@ -1954,9 +1958,9 @@ void SelectMachineDialog::Enable_Send_Button(bool en)
|
|||
void SelectMachineDialog::on_dpi_changed(const wxRect &suggested_rect)
|
||||
{
|
||||
m_button_refresh->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
|
||||
m_button_refresh->SetCornerRadius(FromDIP(10));
|
||||
m_button_refresh->SetCornerRadius(FromDIP(12));
|
||||
m_button_ensure->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
|
||||
m_button_ensure->SetCornerRadius(FromDIP(10));
|
||||
m_button_ensure->SetCornerRadius(FromDIP(12));
|
||||
m_status_bar->msw_rescale();
|
||||
Fit();
|
||||
Refresh();
|
||||
|
@ -2178,7 +2182,7 @@ bool SelectMachineDialog::Show(bool show)
|
|||
|
||||
SelectMachineDialog::~SelectMachineDialog()
|
||||
{
|
||||
;
|
||||
delete m_refresh_timer;
|
||||
}
|
||||
|
||||
EditDevNameDialog::EditDevNameDialog(Plater *plater /*= nullptr*/)
|
||||
|
@ -2212,7 +2216,7 @@ EditDevNameDialog::EditDevNameDialog(Plater *plater /*= nullptr*/)
|
|||
m_button_confirm->SetTextColor(wxColour(255, 255, 255));
|
||||
m_button_confirm->SetSize(wxSize(FromDIP(72), FromDIP(24)));
|
||||
m_button_confirm->SetMinSize(wxSize(FromDIP(72), FromDIP(24)));
|
||||
m_button_confirm->SetCornerRadius(12);
|
||||
m_button_confirm->SetCornerRadius(FromDIP(12));
|
||||
m_button_confirm->Bind(wxEVT_BUTTON, &EditDevNameDialog::on_edit_name, this);
|
||||
|
||||
m_sizer_main->Add(m_button_confirm, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, FromDIP(10));
|
||||
|
|
|
@ -181,7 +181,7 @@ class SelectMachinePopup : public wxPopupTransientWindow
|
|||
{
|
||||
public:
|
||||
SelectMachinePopup(wxWindow *parent);
|
||||
~SelectMachinePopup() {}
|
||||
~SelectMachinePopup();
|
||||
|
||||
// wxPopupTransientWindow virtual methods are all overridden to log them
|
||||
virtual void Popup(wxWindow *focus = NULL) wxOVERRIDE;
|
||||
|
@ -359,7 +359,7 @@ protected:
|
|||
void reset_ams_material();
|
||||
void update_show_status();
|
||||
|
||||
wxTimer *m_refresh_timer;
|
||||
wxTimer *m_refresh_timer { nullptr };
|
||||
|
||||
std::shared_ptr<PrintJob> m_print_job;
|
||||
|
||||
|
|
|
@ -249,8 +249,8 @@ wxBoxSizer *StatusBasePanel::create_monitoring_page()
|
|||
|
||||
m_media_play_ctrl = new MediaPlayCtrl(this, m_media_ctrl, wxDefaultPosition, wxSize(-1, FromDIP(40)));
|
||||
|
||||
sizer->Add(m_media_ctrl, 1, wxEXPAND | wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
|
||||
sizer->Add(m_media_play_ctrl, 0, wxEXPAND | wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
|
||||
sizer->Add(m_media_ctrl, 1, wxEXPAND | wxALL, 0);
|
||||
sizer->Add(m_media_play_ctrl, 0, wxEXPAND | wxALL, 0);
|
||||
// media_ctrl_panel->SetSizer(bSizer_monitoring);
|
||||
// media_ctrl_panel->Layout();
|
||||
//
|
||||
|
@ -306,7 +306,7 @@ wxBoxSizer *StatusBasePanel::create_project_task_page(wxWindow *parent)
|
|||
|
||||
bSizer_task_name->Add(m_staticText_subtask_value, 1, wxALL | wxEXPAND, 0);
|
||||
bSizer_task_name->Add(m_printing_stage_value, 1, wxALL | wxEXPAND, 0);
|
||||
bSizer_subtask_info->Add(bSizer_task_name, 1, wxALIGN_CENTER_VERTICAL | wxEXPAND, FromDIP(5));
|
||||
bSizer_subtask_info->Add(bSizer_task_name, 1, wxEXPAND, FromDIP(5));
|
||||
|
||||
/* wxFlexGridSizer *fgSizer_task = new wxFlexGridSizer(2, 2, 0, 0);
|
||||
fgSizer_task->AddGrowableCol(0);
|
||||
|
@ -330,7 +330,7 @@ wxBoxSizer *StatusBasePanel::create_project_task_page(wxWindow *parent)
|
|||
//m_panel_progress->SetMinSize(wxSize(FromDIP(574), -1));
|
||||
//m_panel_progress->SetMaxSize(wxSize(FromDIP(600), -1));
|
||||
|
||||
m_sizer_progressbar->Add(m_gauge_progress, 1, wxALIGN_CENTER_VERTICAL | wxEXPAND, 0);
|
||||
m_sizer_progressbar->Add(m_gauge_progress, 1, wxALIGN_CENTER_VERTICAL, 0);
|
||||
//fgSizer_task->Add(m_panel_progress, 0, wxALIGN_CENTER_VERTICAL | wxEXPAND, 0);
|
||||
|
||||
wxBoxSizer *bSizer_task_btn = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
@ -564,10 +564,11 @@ wxBoxSizer *StatusBasePanel::create_temp_control(wxWindow *parent)
|
|||
|
||||
wxWindowID nozzle_id = wxWindow::NewControlId();
|
||||
m_tempCtrl_nozzle = new TempInput(parent, nozzle_id, TEMP_BLANK_STR, TEMP_BLANK_STR, wxString("monitor_nozzle_temp"), wxString("monitor_nozzle_temp_active"),
|
||||
wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER | wxBORDER_NONE);
|
||||
wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER);
|
||||
m_tempCtrl_nozzle->SetMinSize(TEMP_CTRL_MIN_SIZE);
|
||||
m_tempCtrl_nozzle->SetMinTemp(nozzle_temp_range[0]);
|
||||
m_tempCtrl_nozzle->SetMaxTemp(nozzle_temp_range[1]);
|
||||
m_tempCtrl_nozzle->SetBorderWidth(FromDIP(2));
|
||||
m_tempCtrl_nozzle->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal)));
|
||||
m_tempCtrl_nozzle->SetBorderColor(StateColor(std::make_pair(*wxWHITE, (int) StateColor::Disabled), std::make_pair(BUTTON_HOVER_COL, (int) StateColor::Focused),
|
||||
std::make_pair(BUTTON_HOVER_COL, (int) StateColor::Hovered), std::make_pair(*wxWHITE, (int) StateColor::Normal)));
|
||||
|
@ -581,10 +582,11 @@ wxBoxSizer *StatusBasePanel::create_temp_control(wxWindow *parent)
|
|||
|
||||
wxWindowID bed_id = wxWindow::NewControlId();
|
||||
m_tempCtrl_bed = new TempInput(parent, bed_id, TEMP_BLANK_STR, TEMP_BLANK_STR, wxString("monitor_bed_temp"), wxString("monitor_bed_temp_active"), wxDefaultPosition,
|
||||
wxDefaultSize, wxALIGN_CENTER | wxBORDER_NONE);
|
||||
wxDefaultSize, wxALIGN_CENTER);
|
||||
m_tempCtrl_bed->SetMinTemp(bed_temp_range[0]);
|
||||
m_tempCtrl_bed->SetMaxTemp(bed_temp_range[1]);
|
||||
m_tempCtrl_bed->SetMinSize(TEMP_CTRL_MIN_SIZE);
|
||||
m_tempCtrl_bed->SetBorderWidth(FromDIP(2));
|
||||
m_tempCtrl_bed->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal)));
|
||||
m_tempCtrl_bed->SetBorderColor(StateColor(std::make_pair(*wxWHITE, (int) StateColor::Disabled), std::make_pair(BUTTON_HOVER_COL, (int) StateColor::Focused),
|
||||
std::make_pair(BUTTON_HOVER_COL, (int) StateColor::Hovered), std::make_pair(*wxWHITE, (int) StateColor::Normal)));
|
||||
|
@ -596,9 +598,10 @@ wxBoxSizer *StatusBasePanel::create_temp_control(wxWindow *parent)
|
|||
|
||||
wxWindowID frame_id = wxWindow::NewControlId();
|
||||
m_tempCtrl_frame = new TempInput(parent, frame_id, TEMP_BLANK_STR, TEMP_BLANK_STR, wxString("monitor_frame_temp"), wxString("monitor_frame_temp"), wxDefaultPosition,
|
||||
wxDefaultSize, wxALIGN_CENTER | wxBORDER_NONE);
|
||||
wxDefaultSize, wxALIGN_CENTER);
|
||||
m_tempCtrl_frame->SetReadOnly(true);
|
||||
m_tempCtrl_frame->SetMinSize(TEMP_CTRL_MIN_SIZE);
|
||||
m_tempCtrl_frame->SetBorderWidth(FromDIP(2));
|
||||
m_tempCtrl_frame->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal)));
|
||||
m_tempCtrl_frame->SetBorderColor(StateColor(std::make_pair(*wxWHITE, (int) StateColor::Disabled), std::make_pair(BUTTON_HOVER_COL, (int) StateColor::Focused),
|
||||
std::make_pair(BUTTON_HOVER_COL, (int) StateColor::Hovered), std::make_pair(*wxWHITE, (int) StateColor::Normal)));
|
||||
|
@ -609,7 +612,7 @@ wxBoxSizer *StatusBasePanel::create_temp_control(wxWindow *parent)
|
|||
|
||||
wxBoxSizer *m_misc_ctrl_sizer = create_misc_control(parent);
|
||||
|
||||
sizer->Add(m_misc_ctrl_sizer, 0, wxEXPAND | wxALIGN_CENTER_VERTICAL, 0);
|
||||
sizer->Add(m_misc_ctrl_sizer, 0, wxEXPAND, 0);
|
||||
return sizer;
|
||||
}
|
||||
|
||||
|
@ -620,10 +623,11 @@ wxBoxSizer *StatusBasePanel::create_misc_control(wxWindow *parent)
|
|||
wxBoxSizer *line_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
/* create speed control */
|
||||
m_switch_speed = new ImageSwitchButton(parent, m_bitmap_speed_active, m_bitmap_speed, wxBORDER_NONE);
|
||||
m_switch_speed = new ImageSwitchButton(parent, m_bitmap_speed_active, m_bitmap_speed);
|
||||
m_switch_speed->SetLabels(_L("100%"), _L("100%"));
|
||||
m_switch_speed->SetMinSize(MISC_BUTTON_SIZE);
|
||||
m_switch_speed->SetPadding(FromDIP(3));
|
||||
m_switch_speed->SetBorderWidth(FromDIP(2));
|
||||
m_switch_speed->SetFont(Label::Head_13);
|
||||
m_switch_speed->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal)));
|
||||
m_switch_speed->SetValue(false);
|
||||
|
@ -635,10 +639,11 @@ wxBoxSizer *StatusBasePanel::create_misc_control(wxWindow *parent)
|
|||
line_sizer->Add(line, 0, wxEXPAND | wxTOP | wxBOTTOM, 4);
|
||||
|
||||
/* create lamp control */
|
||||
m_switch_lamp = new ImageSwitchButton(parent, m_bitmap_lamp_on, m_bitmap_lamp_off, wxBORDER_NONE);
|
||||
m_switch_lamp = new ImageSwitchButton(parent, m_bitmap_lamp_on, m_bitmap_lamp_off);
|
||||
m_switch_lamp->SetLabels(_L("Lamp"), _L("Lamp"));
|
||||
m_switch_lamp->SetMinSize(MISC_BUTTON_SIZE);
|
||||
m_switch_lamp->SetPadding(FromDIP(3));
|
||||
m_switch_lamp->SetBorderWidth(FromDIP(2));
|
||||
m_switch_lamp->SetFont(Label::Head_13);
|
||||
m_switch_lamp->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal)));
|
||||
line_sizer->Add(m_switch_lamp, 1, wxALIGN_CENTER | wxALL, 0);
|
||||
|
@ -649,11 +654,12 @@ wxBoxSizer *StatusBasePanel::create_misc_control(wxWindow *parent)
|
|||
sizer->Add(line, 0, wxEXPAND | wxLEFT | wxRIGHT, 12);
|
||||
|
||||
line_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
m_switch_nozzle_fan = new ImageSwitchButton(parent, m_bitmap_fan_on, m_bitmap_fan_off, wxBORDER_NONE);
|
||||
m_switch_nozzle_fan = new ImageSwitchButton(parent, m_bitmap_fan_on, m_bitmap_fan_off);
|
||||
m_switch_nozzle_fan->SetMinSize(MISC_BUTTON_SIZE);
|
||||
m_switch_nozzle_fan->SetValue(false);
|
||||
m_switch_nozzle_fan->SetLabels(_L("Part Cooling"), _L("Part Cooling"));
|
||||
m_switch_nozzle_fan->SetPadding(FromDIP(3));
|
||||
m_switch_nozzle_fan->SetBorderWidth(FromDIP(2));
|
||||
m_switch_nozzle_fan->SetFont(SWITCH_FONT);
|
||||
m_switch_nozzle_fan->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_FAN_TEXT_COL, (int) StateColor::Normal)));
|
||||
|
||||
|
@ -662,10 +668,11 @@ wxBoxSizer *StatusBasePanel::create_misc_control(wxWindow *parent)
|
|||
line->SetLineColour(STATIC_BOX_LINE_COL);
|
||||
line_sizer->Add(line, 0, wxEXPAND | wxTOP | wxBOTTOM, 4);
|
||||
|
||||
m_switch_printing_fan = new ImageSwitchButton(parent, m_bitmap_fan_on, m_bitmap_fan_off, wxBORDER_NONE);
|
||||
m_switch_printing_fan = new ImageSwitchButton(parent, m_bitmap_fan_on, m_bitmap_fan_off);
|
||||
m_switch_printing_fan->SetValue(false);
|
||||
m_switch_printing_fan->SetMinSize(MISC_BUTTON_SIZE);
|
||||
m_switch_printing_fan->SetPadding(FromDIP(3));
|
||||
m_switch_printing_fan->SetBorderWidth(FromDIP(2));
|
||||
m_switch_printing_fan->SetFont(SWITCH_FONT);
|
||||
m_switch_printing_fan->SetLabels(_L("Aux Cooling"), _L("Aux Cooling"));
|
||||
m_switch_printing_fan->SetTextColor(
|
||||
|
@ -751,7 +758,7 @@ wxBoxSizer *StatusBasePanel::create_bed_control(wxWindow *parent)
|
|||
m_bpButton_z_10->SetMinSize(Z_BUTTON_SIZE);
|
||||
m_bpButton_z_10->SetCornerRadius(0);
|
||||
|
||||
bSizer_z_ctrl->Add(m_bpButton_z_10, 0, wxEXPAND | wxALL | wxALIGN_CENTER_HORIZONTAL, 0);
|
||||
bSizer_z_ctrl->Add(m_bpButton_z_10, 0, wxEXPAND | wxALL, 0);
|
||||
|
||||
m_bpButton_z_1 = new Button(panel, wxString(" 1"), "monitor_bed_up", 0, FromDIP(15));
|
||||
m_bpButton_z_1->SetFont(::Label::Body_13);
|
||||
|
@ -761,7 +768,7 @@ wxBoxSizer *StatusBasePanel::create_bed_control(wxWindow *parent)
|
|||
m_bpButton_z_1->SetMinSize(Z_BUTTON_SIZE);
|
||||
m_bpButton_z_1->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal)));
|
||||
|
||||
bSizer_z_ctrl->Add(m_bpButton_z_1, 0, wxEXPAND | wxALL | wxALIGN_CENTER_HORIZONTAL, 0);
|
||||
bSizer_z_ctrl->Add(m_bpButton_z_1, 0, wxEXPAND | wxALL, 0);
|
||||
|
||||
bSizer_z_ctrl->Add(0, FromDIP(6), 0, wxEXPAND, 0);
|
||||
|
||||
|
@ -773,7 +780,7 @@ wxBoxSizer *StatusBasePanel::create_bed_control(wxWindow *parent)
|
|||
m_bpButton_z_down_1->SetMinSize(Z_BUTTON_SIZE);
|
||||
m_bpButton_z_down_1->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal)));
|
||||
|
||||
bSizer_z_ctrl->Add(m_bpButton_z_down_1, 0, wxEXPAND | wxALL | wxALIGN_CENTER_HORIZONTAL, 0);
|
||||
bSizer_z_ctrl->Add(m_bpButton_z_down_1, 0, wxEXPAND | wxALL, 0);
|
||||
|
||||
m_bpButton_z_down_10 = new Button(panel, wxString("10"), "monitor_bed_down", 0, FromDIP(15));
|
||||
m_bpButton_z_down_10->SetFont(::Label::Body_13);
|
||||
|
@ -783,7 +790,7 @@ wxBoxSizer *StatusBasePanel::create_bed_control(wxWindow *parent)
|
|||
m_bpButton_z_down_10->SetMinSize(Z_BUTTON_SIZE);
|
||||
m_bpButton_z_down_10->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal)));
|
||||
|
||||
bSizer_z_ctrl->Add(m_bpButton_z_down_10, 0, wxEXPAND | wxALL | wxALIGN_CENTER_HORIZONTAL, 0);
|
||||
bSizer_z_ctrl->Add(m_bpButton_z_down_10, 0, wxEXPAND | wxALL, 0);
|
||||
|
||||
bSizer_z_ctrl->Add(0, FromDIP(16), 0, wxEXPAND, 0);
|
||||
|
||||
|
@ -850,7 +857,7 @@ wxBoxSizer *StatusBasePanel::create_extruder_control(wxWindow *parent)
|
|||
m_button_unload->SetTextColor(abort_text);
|
||||
m_button_unload->SetFont(Label::Body_10);
|
||||
m_button_unload->SetMinSize(wxSize(-1, FromDIP(24)));
|
||||
m_button_unload->SetCornerRadius(FromDIP(10));
|
||||
m_button_unload->SetCornerRadius(FromDIP(12));
|
||||
bSizer_e_ctrl->Add(0, 0, 1, wxEXPAND, 0);
|
||||
bSizer_e_ctrl->Add(m_button_unload, 0, wxALIGN_CENTER_HORIZONTAL| wxTOP|wxBOTTOM, FromDIP(5));
|
||||
|
||||
|
@ -1012,7 +1019,6 @@ StatusPanel::StatusPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, co
|
|||
Bind(EVT_AMS_REFRESH_RFID, &StatusPanel::on_ams_refresh_rfid, this);
|
||||
Bind(EVT_AMS_ON_SELECTED, &StatusPanel::on_ams_selected, this);
|
||||
Bind(EVT_AMS_ON_FILAMENT_EDIT, &StatusPanel::on_filament_edit, this);
|
||||
Bind(EVT_UPDATE_ERROR_MESSAGE, &StatusPanel::on_update_error_message, this);
|
||||
|
||||
m_switch_speed->Connect(wxEVT_LEFT_DOWN, wxCommandEventHandler(StatusPanel::on_switch_speed), NULL, this);
|
||||
m_calibration_btn->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_start_calibration), NULL, this);
|
||||
|
@ -1059,7 +1065,7 @@ void StatusPanel::init_scaled_buttons()
|
|||
m_button_clean->SetMinSize(wxSize(FromDIP(48), FromDIP(24)));
|
||||
m_button_clean->SetCornerRadius(FromDIP(12));
|
||||
m_button_unload->SetMinSize(wxSize(-1, FromDIP(24)));
|
||||
m_button_unload->SetCornerRadius(FromDIP(10));
|
||||
m_button_unload->SetCornerRadius(FromDIP(12));
|
||||
m_bpButton_z_10->SetMinSize(Z_BUTTON_SIZE);
|
||||
m_bpButton_z_10->SetCornerRadius(0);
|
||||
m_bpButton_z_1->SetMinSize(Z_BUTTON_SIZE);
|
||||
|
@ -1239,9 +1245,9 @@ void StatusPanel::update(MachineObject *obj)
|
|||
m_machine_ctrl_panel->Thaw();
|
||||
}
|
||||
|
||||
void StatusPanel::on_update_error_message(wxCommandEvent &event)
|
||||
void StatusPanel::show_error_message(wxString msg)
|
||||
{
|
||||
m_error_text->SetLabel(event.GetString());
|
||||
m_error_text->SetLabel(msg);
|
||||
m_staticline->Show();
|
||||
m_panel_error_txt->Show();
|
||||
}
|
||||
|
@ -1257,13 +1263,18 @@ void StatusPanel::update_error_message()
|
|||
}
|
||||
|
||||
if (before_error_code != obj->print_error) {
|
||||
get_error_message_thread = new boost::thread(Slic3r::create_thread([&] {
|
||||
std::string message = show_error_message(obj->print_error);
|
||||
wxCommandEvent event(EVT_UPDATE_ERROR_MESSAGE);
|
||||
event.SetString(wxString(message));
|
||||
event.SetEventObject(this);
|
||||
wxPostEvent(this, event);
|
||||
}));
|
||||
if (wxGetApp().get_hms_query()) {
|
||||
char buf[32];
|
||||
::sprintf(buf, "%08X", obj->print_error);
|
||||
std::string print_error_str = std::string(buf);
|
||||
if (print_error_str.size() > 4) {
|
||||
print_error_str.insert(4, " ");
|
||||
}
|
||||
wxString error_msg = wxString::Format("%s[%s]",
|
||||
wxGetApp().get_hms_query()->query_print_error_msg(obj->print_error),
|
||||
print_error_str);
|
||||
show_error_message(error_msg);
|
||||
}
|
||||
before_error_code = obj->print_error;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "Widgets/ProgressBar.hpp"
|
||||
#include "Widgets/ImageSwitchButton.hpp"
|
||||
#include "Widgets/AMSControl.hpp"
|
||||
#include "UpdateErrorMessage.hpp"
|
||||
#include "HMS.hpp"
|
||||
#include "Widgets/wxStaticText2.hpp"
|
||||
class StepIndicator;
|
||||
|
||||
|
@ -268,7 +268,7 @@ protected:
|
|||
void on_subtask_pause_resume(wxCommandEvent &event);
|
||||
void on_subtask_abort(wxCommandEvent &event);
|
||||
void on_subtask_clean(wxCommandEvent &event);
|
||||
void on_update_error_message(wxCommandEvent &event);
|
||||
void show_error_message(wxString msg);
|
||||
void error_info_reset();
|
||||
|
||||
/* axis control */
|
||||
|
@ -352,7 +352,6 @@ public:
|
|||
long last_ams_version { -1 };
|
||||
|
||||
std::vector<int> last_stage_list_info;
|
||||
boost::thread * get_error_message_thread{nullptr};
|
||||
|
||||
bool is_stage_list_info_changed(MachineObject* obj);
|
||||
|
||||
|
|
|
@ -267,7 +267,7 @@ void Tab::create_preset_tab()
|
|||
m_search_input->SetFont(wxGetApp().bold_font());
|
||||
|
||||
search_sizer->Add(new wxWindow(m_search_item, wxID_ANY, wxDefaultPosition, wxSize(0, 0)), 0, wxEXPAND | wxLEFT, 16);
|
||||
search_sizer->Add(m_search_input, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, wxGetApp().em_unit() / 2);
|
||||
search_sizer->Add(m_search_input, 1, wxEXPAND | wxALL, wxGetApp().em_unit() / 2);
|
||||
search_sizer->Add(new wxWindow(m_search_input, wxID_ANY, wxDefaultPosition, wxSize(0, 0)), 0, wxEXPAND | wxLEFT, 16);
|
||||
|
||||
|
||||
|
@ -335,7 +335,7 @@ void Tab::create_preset_tab()
|
|||
// BBS: model config
|
||||
if (m_presets_choice) {
|
||||
m_presets_choice->Reparent(m_top_panel);
|
||||
m_top_sizer->Add(m_presets_choice, 1, wxLEFT | wxRIGHT | wxEXPAND | wxALIGN_CENTER_VERTICAL, 10);
|
||||
m_top_sizer->Add(m_presets_choice, 1, wxLEFT | wxRIGHT | wxEXPAND, 10);
|
||||
} else {
|
||||
m_top_sizer->AddSpacer(10);
|
||||
m_top_sizer->AddStretchSpacer(1);
|
||||
|
@ -353,7 +353,7 @@ void Tab::create_preset_tab()
|
|||
m_top_sizer->Add( m_search_item, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT , 8 );
|
||||
|
||||
if (dynamic_cast<TabPrint*>(this) == nullptr) {
|
||||
m_static_title = new Label(Label::Body_12, _L("Advance"), m_top_panel);
|
||||
m_static_title = new Label(m_top_panel, Label::Body_12, _L("Advance"));
|
||||
m_static_title->Wrap( -1 );
|
||||
// BBS: open this tab by select first
|
||||
m_static_title->Bind(wxEVT_LEFT_UP, [this](auto& e) {
|
||||
|
@ -1375,11 +1375,9 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
|
|||
if (opt_key == "enable_prime_tower" || opt_key == "single_extruder_multi_material" || opt_key == "extruders_count" )
|
||||
update_wiping_button_visibility();
|
||||
|
||||
//popup message dialog when first selected
|
||||
if (opt_key == "timelapse_no_toolhead" && boost::any_cast<bool>(value))
|
||||
show_timelapse_warning_dialog();
|
||||
|
||||
|
||||
// reload scene to update timelapse wipe tower
|
||||
if (opt_key == "timelapse_no_toolhead")
|
||||
wxGetApp().plater()->update();
|
||||
|
||||
// BBS
|
||||
#if 0
|
||||
|
|
|
@ -953,7 +953,7 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection *dependent_
|
|||
}
|
||||
|
||||
(*btn)->SetMinSize(UNSAVE_CHANGE_DIALOG_BUTTON_SIZE);
|
||||
(*btn)->SetCornerRadius(12);
|
||||
(*btn)->SetCornerRadius(FromDIP(12));
|
||||
|
||||
(*btn)->Bind(wxEVT_BUTTON, [this, close_act, dependent_presets](wxEvent &) {
|
||||
bool save_names_and_types = close_act == Action::Save || (close_act == Action::Transfer && ActionButtons::KEEP & m_buttons);
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
#include "UpdateErrorMessage.hpp"
|
||||
|
||||
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
wxDEFINE_EVENT(EVT_UPDATE_ERROR_MESSAGE, wxCommandEvent);
|
||||
|
||||
std::string show_error_message(int error_code)
|
||||
{
|
||||
char buf[64];
|
||||
std::string result_str = "";
|
||||
std::sprintf(buf,"%08X",error_code);
|
||||
std::string hms_host = wxGetApp().app_config->get_hms_host();
|
||||
std::string get_lang = wxGetApp().app_config->get_langauge_code();
|
||||
|
||||
std::string url = (boost::format("https://%1%/query.php?lang=%2%&e=%3%")
|
||||
%hms_host
|
||||
%get_lang
|
||||
%buf).str();
|
||||
|
||||
Slic3r::Http http = Slic3r::Http::get(url);
|
||||
http.header("accept", "application/json")
|
||||
.timeout_max(10)
|
||||
.on_complete([get_lang, &result_str](std::string body, unsigned status) {
|
||||
try {
|
||||
json j = json::parse(body);
|
||||
if (j.contains("result")) {
|
||||
if (j["result"].get<int>() == 0) {
|
||||
if (j.contains("data")) {
|
||||
json jj = j["data"];
|
||||
if (jj.contains("device_error")) {
|
||||
if (jj["device_error"].contains(get_lang)) {
|
||||
if (jj["device_error"][get_lang].size() > 0) {
|
||||
if (!jj["device_error"][get_lang][0]["intro"].empty() || !jj["device_error"][get_lang][0]["ecode"].empty()) {
|
||||
std::string error_info = jj["device_error"][get_lang][0]["intro"].get<std::string>();
|
||||
std::string error_code = jj["device_error"][get_lang][0]["ecode"].get<std::string>();
|
||||
error_code.insert(4, " ");
|
||||
result_str = from_u8(error_info).ToStdString() + "[" + error_code + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (...) {
|
||||
;
|
||||
}
|
||||
})
|
||||
.on_error([](std::string body, std::string error, unsigned status) {
|
||||
BOOST_LOG_TRIVIAL(trace) << boost::format("[BBL ErrorMessage]: status=%1%, error=%2%, body=%3%") % status % error % body;
|
||||
}).perform_sync();
|
||||
|
||||
return result_str;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
#ifndef slic3r_UpdateErrorMessage_hpp_
|
||||
#define slic3r_UpdateErrorMessage_hpp_
|
||||
|
||||
#include "GUI_App.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "Widgets/Label.hpp"
|
||||
#include "Widgets/Button.hpp"
|
||||
#include "Widgets/StepCtrl.hpp"
|
||||
#include "BitmapCache.hpp"
|
||||
#include "slic3r/Utils/Http.hpp"
|
||||
#include "libslic3r/Thread.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
|
||||
std::string show_error_message(int error_code);
|
||||
|
||||
|
||||
wxDECLARE_EVENT(EVT_UPDATE_ERROR_MESSAGE, wxCommandEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -76,7 +76,7 @@ MachineInfoPanel::MachineInfoPanel(wxWindow* parent, wxWindowID id, const wxPoin
|
|||
m_staticText_ver = new wxStaticText(this, wxID_ANY, _L("Version:"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
m_staticText_ver->Wrap(-1);
|
||||
m_staticText_ver->SetFont(Label::Head_14);
|
||||
m_ota_ver_sizer->Add(m_staticText_ver, 0, wxALIGN_RIGHT | wxALL, FromDIP(5));
|
||||
m_ota_ver_sizer->Add(m_staticText_ver, 0, wxALL, FromDIP(5));
|
||||
|
||||
m_ota_info_sizer->Add(m_ota_ver_sizer, 0, wxEXPAND, 0);
|
||||
|
||||
|
@ -519,18 +519,18 @@ void MachineInfoPanel::on_show_release_note(wxMouseEvent &event)
|
|||
if (!dev) return;
|
||||
|
||||
|
||||
std::string next_version_release_note = "";
|
||||
std::string now_version_release_note = "";
|
||||
wxString next_version_release_note;
|
||||
wxString now_version_release_note;
|
||||
std::string version_number = "";
|
||||
|
||||
for (auto iter : m_obj->firmware_list) {
|
||||
if (iter.version == m_obj->ota_new_version_number) {
|
||||
version_number = m_obj->ota_new_version_number;
|
||||
next_version_release_note = iter.description;
|
||||
next_version_release_note = wxString::FromUTF8(iter.description);
|
||||
}
|
||||
if (iter.version == m_obj->get_ota_version()) {
|
||||
version_number = m_obj->get_ota_version();
|
||||
now_version_release_note = iter.description;
|
||||
now_version_release_note = wxString::FromUTF8(iter.description);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -563,7 +563,7 @@ UpgradePanel::UpgradePanel(wxWindow *parent, wxWindowID id, const wxPoint &pos,
|
|||
|
||||
m_scrolledWindow->SetSizerAndFit(m_machine_list_sizer);
|
||||
|
||||
m_main_sizer->Add(m_scrolledWindow, 1, wxALIGN_CENTER_HORIZONTAL | wxEXPAND, 0);
|
||||
m_main_sizer->Add(m_scrolledWindow, 1, wxEXPAND, 0);
|
||||
|
||||
this->SetSizerAndFit(m_main_sizer);
|
||||
|
||||
|
@ -679,7 +679,7 @@ bool UpgradePanel::Show(bool show)
|
|||
auto m_staticText_ams_ver = new wxStaticText(this, wxID_ANY, _L("Version:"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
m_staticText_ams_ver->Wrap(-1);
|
||||
m_staticText_ams_ver->SetFont(Label::Head_14);
|
||||
m_ams_ver_sizer->Add(m_staticText_ams_ver, 0, wxALIGN_RIGHT | wxALL, FromDIP(5));
|
||||
m_ams_ver_sizer->Add(m_staticText_ams_ver, 0, wxALL, FromDIP(5));
|
||||
|
||||
m_staticText_ams_ver_val = new wxStaticText(this, wxID_ANY, "-", wxDefaultPosition, wxDefaultSize, 0);
|
||||
m_staticText_ams_ver_val->Wrap(-1);
|
||||
|
|
|
@ -854,7 +854,7 @@ int GuideFrame::LoadProfile()
|
|||
//BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", will load config from %1%.") % bbl_bundle_path;
|
||||
m_ProfileJson = json::parse("{}");
|
||||
m_ProfileJson["model"] = json::array();
|
||||
m_ProfileJson["machine"] = json::array();
|
||||
m_ProfileJson["machine"] = json::object();
|
||||
m_ProfileJson["filament"] = json::object();
|
||||
m_ProfileJson["process"] = json::array();
|
||||
|
||||
|
@ -999,27 +999,205 @@ void StringReplace(string &strBase, string strSrc, string strDes)
|
|||
}
|
||||
|
||||
|
||||
//int GuideFrame::LoadProfileFamily(std::string strVendor, std::string strFilePath)
|
||||
//{
|
||||
// //wxString strFolder = strFilePath.BeforeLast(boost::filesystem::path::preferred_separator);
|
||||
// boost::filesystem::path file_path(strFilePath);
|
||||
// boost::filesystem::path vendor_dir = boost::filesystem::absolute(file_path.parent_path()/ strVendor).make_preferred();
|
||||
// BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", vendor path %1%.")% vendor_dir.string();
|
||||
// try {
|
||||
//
|
||||
// //wxLogMessage("GUIDE: json_path1 %s", w2s(strFilePath));
|
||||
//
|
||||
// std::string contents;
|
||||
// LoadFile(strFilePath, contents);
|
||||
// //wxLogMessage("GUIDE: json_path1 content: %s", contents);
|
||||
// json jLocal=json::parse(contents);
|
||||
// //wxLogMessage("GUIDE: json_path1 Loaded");
|
||||
//
|
||||
// // BBS:models
|
||||
// json pmodels = jLocal["machine_model_list"];
|
||||
// int nsize = pmodels.size();
|
||||
//
|
||||
// BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", got %1% machine models")%nsize;
|
||||
//
|
||||
// for (int n = 0; n < nsize; n++) {
|
||||
// json OneModel = pmodels.at(n);
|
||||
//
|
||||
// OneModel["model"] = OneModel["name"];
|
||||
// OneModel.erase("name");
|
||||
//
|
||||
// std::string s1 = OneModel["model"];
|
||||
// std::string s2 = OneModel["sub_path"];
|
||||
//
|
||||
// boost::filesystem::path sub_path = boost::filesystem::absolute(vendor_dir / s2).make_preferred();
|
||||
// std::string sub_file = sub_path.string();
|
||||
//
|
||||
// //wxLogMessage("GUIDE: json_path2 %s", w2s(ModelFilePath));
|
||||
// LoadFile(sub_file, contents);
|
||||
// //wxLogMessage("GUIDE: json_path2 content: %s", contents);
|
||||
// json pm=json::parse(contents);
|
||||
// //wxLogMessage("GUIDE: json_path2 loaded");
|
||||
//
|
||||
// OneModel["vendor"] = strVendor;
|
||||
// std::string NozzleOpt = pm["nozzle_diameter"];
|
||||
// StringReplace(NozzleOpt, " ", "");
|
||||
// OneModel["nozzle_diameter"] = NozzleOpt;
|
||||
// OneModel["materials"] = pm["default_materials"];
|
||||
//
|
||||
// //wxString strCoverPath = wxString::Format("%s\\%s\\%s_cover.png", strFolder, strVendor, std::string(s1.mb_str()));
|
||||
// std::string cover_file = s1+"_cover.png";
|
||||
// boost::filesystem::path cover_path = boost::filesystem::absolute(vendor_dir / cover_file).make_preferred();
|
||||
// OneModel["cover"] = cover_path.string();
|
||||
//
|
||||
// OneModel["nozzle_selected"] = "";
|
||||
//
|
||||
// m_ProfileJson["model"].push_back(OneModel);
|
||||
// }
|
||||
//
|
||||
// // BBS:Machine
|
||||
// json pmachine = jLocal["machine_list"];
|
||||
// nsize = pmachine.size();
|
||||
// BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", got %1% machines")%nsize;
|
||||
// for (int n = 0; n < nsize; n++) {
|
||||
// json OneMachine = pmachine.at(n);
|
||||
//
|
||||
// std::string s1 = OneMachine["name"];
|
||||
// std::string s2 = OneMachine["sub_path"];
|
||||
//
|
||||
// //wxString ModelFilePath = wxString::Format("%s\\%s\\%s", strFolder, strVendor, s2);
|
||||
// boost::filesystem::path sub_path = boost::filesystem::absolute(vendor_dir / s2).make_preferred();
|
||||
// std::string sub_file = sub_path.string();
|
||||
// LoadFile(sub_file, contents);
|
||||
// json pm = json::parse(contents);
|
||||
//
|
||||
// std::string strInstant = pm["instantiation"];
|
||||
// if (strInstant.compare("true") == 0) {
|
||||
// OneMachine["model"] = pm["printer_model"];
|
||||
//
|
||||
// m_ProfileJson["machine"].push_back(OneMachine);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // BBS:Filament
|
||||
// json pFilament = jLocal["filament_list"];
|
||||
// nsize = pFilament.size();
|
||||
//
|
||||
// int nFalse = 0;
|
||||
// int nModel = 0;
|
||||
// int nFinish = 0;
|
||||
// BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", got %1% filaments")%nsize;
|
||||
// for (int n = 0; n < nsize; n++) {
|
||||
// json OneFF = pFilament.at(n);
|
||||
//
|
||||
// std::string s1 = OneFF["name"];
|
||||
// std::string s2 = OneFF["sub_path"];
|
||||
//
|
||||
// if (!m_ProfileJson["filament"].contains(s1))
|
||||
// {
|
||||
// //wxString ModelFilePath = wxString::Format("%s\\%s\\%s", strFolder, strVendor, s2);
|
||||
// boost::filesystem::path sub_path = boost::filesystem::absolute(vendor_dir / s2).make_preferred();
|
||||
// std::string sub_file = sub_path.string();
|
||||
// LoadFile(sub_file, contents);
|
||||
// json pm = json::parse(contents);
|
||||
//
|
||||
// std::string strInstant = pm["instantiation"];
|
||||
// if (strInstant == "true") {
|
||||
// std::string sV;
|
||||
// std::string sT;
|
||||
//
|
||||
// int nRet = GetFilamentInfo(sub_file, sV, sT);
|
||||
// if (nRet != 0) continue;
|
||||
//
|
||||
// OneFF["vendor"] = sV;
|
||||
// OneFF["type"] = sT;
|
||||
//
|
||||
// OneFF["models"] = "";
|
||||
// OneFF["selected"] = 0;
|
||||
// }
|
||||
// else
|
||||
// continue;
|
||||
//
|
||||
// } else {
|
||||
// OneFF = m_ProfileJson["filament"][s1];
|
||||
// }
|
||||
//
|
||||
// std::string vModel = "";
|
||||
// int nm = m_ProfileJson["model"].size();
|
||||
// int bFind = 0;
|
||||
// for (int m = 0; m < nm; m++) {
|
||||
// std::string strFF = m_ProfileJson["model"][m]["materials"];
|
||||
// strFF = (boost::format(";%1%;")%strFF).str();
|
||||
// std::string strTT = (boost::format(";%1%;")%s1).str();
|
||||
// if (strFF.find(strTT) != std::string::npos) {
|
||||
// std::string sModel = m_ProfileJson["model"][m]["model"];
|
||||
//
|
||||
// vModel = (boost::format("%1%[%2%]")%vModel %sModel).str();
|
||||
// bFind = 1;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// OneFF["models"] = vModel;
|
||||
//
|
||||
// m_ProfileJson["filament"][s1] = OneFF;
|
||||
// }
|
||||
//
|
||||
// //process
|
||||
// json pProcess = jLocal["process_list"];
|
||||
// nsize = pProcess.size();
|
||||
// BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", got %1% processes")%nsize;
|
||||
// for (int n = 0; n < nsize; n++) {
|
||||
// json OneProcess = pProcess.at(n);
|
||||
//
|
||||
// std::string s2 = OneProcess["sub_path"];
|
||||
// //wxString ModelFilePath = wxString::Format("%s\\%s\\%s", strFolder, strVendor, s2);
|
||||
// boost::filesystem::path sub_path = boost::filesystem::absolute(vendor_dir / s2).make_preferred();
|
||||
// std::string sub_file = sub_path.string();
|
||||
// LoadFile(sub_file, contents);
|
||||
// json pm = json::parse(contents);
|
||||
//
|
||||
// std::string bInstall = pm["instantiation"];
|
||||
// if (bInstall == "true")
|
||||
// {
|
||||
// m_ProfileJson["process"].push_back(OneProcess);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// catch(nlohmann::detail::parse_error &err) {
|
||||
// BOOST_LOG_TRIVIAL(error) << __FUNCTION__<< ": parse "<<strFilePath <<" got a nlohmann::detail::parse_error, reason = " << err.what();
|
||||
// return -1;
|
||||
// }
|
||||
// catch (std::exception &e) {
|
||||
// // wxMessageBox(e.what(), "", MB_OK);
|
||||
// //wxLogMessage("GUIDE: LoadFamily Error: %s", e.what());
|
||||
// BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": parse " << strFilePath << " got exception: " << e.what();
|
||||
// return -1;
|
||||
// }
|
||||
//
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
int GuideFrame::LoadProfileFamily(std::string strVendor, std::string strFilePath)
|
||||
{
|
||||
//wxString strFolder = strFilePath.BeforeLast(boost::filesystem::path::preferred_separator);
|
||||
// wxString strFolder = strFilePath.BeforeLast(boost::filesystem::path::preferred_separator);
|
||||
boost::filesystem::path file_path(strFilePath);
|
||||
boost::filesystem::path vendor_dir = boost::filesystem::absolute(file_path.parent_path()/ strVendor).make_preferred();
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", vendor path %1%.")% vendor_dir.string();
|
||||
boost::filesystem::path vendor_dir = boost::filesystem::absolute(file_path.parent_path() / strVendor).make_preferred();
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", vendor path %1%.") % vendor_dir.string();
|
||||
try {
|
||||
|
||||
//wxLogMessage("GUIDE: json_path1 %s", w2s(strFilePath));
|
||||
// wxLogMessage("GUIDE: json_path1 %s", w2s(strFilePath));
|
||||
|
||||
std::string contents;
|
||||
LoadFile(strFilePath, contents);
|
||||
//wxLogMessage("GUIDE: json_path1 content: %s", contents);
|
||||
json jLocal=json::parse(contents);
|
||||
//wxLogMessage("GUIDE: json_path1 Loaded");
|
||||
// wxLogMessage("GUIDE: json_path1 content: %s", contents);
|
||||
json jLocal = json::parse(contents);
|
||||
// wxLogMessage("GUIDE: json_path1 Loaded");
|
||||
|
||||
// BBS:models
|
||||
json pmodels = jLocal["machine_model_list"];
|
||||
int nsize = pmodels.size();
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", got %1% machine models")%nsize;
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", got %1% machine models") % nsize;
|
||||
|
||||
for (int n = 0; n < nsize; n++) {
|
||||
json OneModel = pmodels.at(n);
|
||||
|
@ -1031,24 +1209,24 @@ int GuideFrame::LoadProfileFamily(std::string strVendor, std::string strFilePath
|
|||
std::string s2 = OneModel["sub_path"];
|
||||
|
||||
boost::filesystem::path sub_path = boost::filesystem::absolute(vendor_dir / s2).make_preferred();
|
||||
std::string sub_file = sub_path.string();
|
||||
std::string sub_file = sub_path.string();
|
||||
|
||||
//wxLogMessage("GUIDE: json_path2 %s", w2s(ModelFilePath));
|
||||
// wxLogMessage("GUIDE: json_path2 %s", w2s(ModelFilePath));
|
||||
LoadFile(sub_file, contents);
|
||||
//wxLogMessage("GUIDE: json_path2 content: %s", contents);
|
||||
json pm=json::parse(contents);
|
||||
//wxLogMessage("GUIDE: json_path2 loaded");
|
||||
// wxLogMessage("GUIDE: json_path2 content: %s", contents);
|
||||
json pm = json::parse(contents);
|
||||
// wxLogMessage("GUIDE: json_path2 loaded");
|
||||
|
||||
OneModel["vendor"] = strVendor;
|
||||
OneModel["vendor"] = strVendor;
|
||||
std::string NozzleOpt = pm["nozzle_diameter"];
|
||||
StringReplace(NozzleOpt, " ", "");
|
||||
OneModel["nozzle_diameter"] = NozzleOpt;
|
||||
OneModel["materials"] = pm["default_materials"];
|
||||
|
||||
//wxString strCoverPath = wxString::Format("%s\\%s\\%s_cover.png", strFolder, strVendor, std::string(s1.mb_str()));
|
||||
std::string cover_file = s1+"_cover.png";
|
||||
// wxString strCoverPath = wxString::Format("%s\\%s\\%s_cover.png", strFolder, strVendor, std::string(s1.mb_str()));
|
||||
std::string cover_file = s1 + "_cover.png";
|
||||
boost::filesystem::path cover_path = boost::filesystem::absolute(vendor_dir / cover_file).make_preferred();
|
||||
OneModel["cover"] = cover_path.string();
|
||||
OneModel["cover"] = cover_path.string();
|
||||
|
||||
OneModel["nozzle_selected"] = "";
|
||||
|
||||
|
@ -1058,24 +1236,25 @@ int GuideFrame::LoadProfileFamily(std::string strVendor, std::string strFilePath
|
|||
// BBS:Machine
|
||||
json pmachine = jLocal["machine_list"];
|
||||
nsize = pmachine.size();
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", got %1% machines")%nsize;
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", got %1% machines") % nsize;
|
||||
for (int n = 0; n < nsize; n++) {
|
||||
json OneMachine = pmachine.at(n);
|
||||
|
||||
std::string s1 = OneMachine["name"];
|
||||
std::string s2 = OneMachine["sub_path"];
|
||||
|
||||
//wxString ModelFilePath = wxString::Format("%s\\%s\\%s", strFolder, strVendor, s2);
|
||||
// wxString ModelFilePath = wxString::Format("%s\\%s\\%s", strFolder, strVendor, s2);
|
||||
boost::filesystem::path sub_path = boost::filesystem::absolute(vendor_dir / s2).make_preferred();
|
||||
std::string sub_file = sub_path.string();
|
||||
std::string sub_file = sub_path.string();
|
||||
LoadFile(sub_file, contents);
|
||||
json pm = json::parse(contents);
|
||||
|
||||
std::string strInstant = pm["instantiation"];
|
||||
if (strInstant.compare("true") == 0) {
|
||||
OneMachine["model"] = pm["printer_model"];
|
||||
OneMachine["nozzle"] = pm["nozzle_diameter"][0];
|
||||
|
||||
m_ProfileJson["machine"].push_back(OneMachine);
|
||||
m_ProfileJson["machine"][s1]=OneMachine;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1083,21 +1262,20 @@ int GuideFrame::LoadProfileFamily(std::string strVendor, std::string strFilePath
|
|||
json pFilament = jLocal["filament_list"];
|
||||
nsize = pFilament.size();
|
||||
|
||||
int nFalse = 0;
|
||||
int nModel = 0;
|
||||
int nFalse = 0;
|
||||
int nModel = 0;
|
||||
int nFinish = 0;
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", got %1% filaments")%nsize;
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", got %1% filaments") % nsize;
|
||||
for (int n = 0; n < nsize; n++) {
|
||||
json OneFF = pFilament.at(n);
|
||||
|
||||
std::string s1 = OneFF["name"];
|
||||
std::string s2 = OneFF["sub_path"];
|
||||
|
||||
if (!m_ProfileJson["filament"].contains(s1))
|
||||
{
|
||||
//wxString ModelFilePath = wxString::Format("%s\\%s\\%s", strFolder, strVendor, s2);
|
||||
if (!m_ProfileJson["filament"].contains(s1)) {
|
||||
// wxString ModelFilePath = wxString::Format("%s\\%s\\%s", strFolder, strVendor, s2);
|
||||
boost::filesystem::path sub_path = boost::filesystem::absolute(vendor_dir / s2).make_preferred();
|
||||
std::string sub_file = sub_path.string();
|
||||
std::string sub_file = sub_path.string();
|
||||
LoadFile(sub_file, contents);
|
||||
json pm = json::parse(contents);
|
||||
|
||||
|
@ -1110,67 +1288,60 @@ int GuideFrame::LoadProfileFamily(std::string strVendor, std::string strFilePath
|
|||
if (nRet != 0) continue;
|
||||
|
||||
OneFF["vendor"] = sV;
|
||||
OneFF["type"] = sT;
|
||||
OneFF["type"] = sT;
|
||||
|
||||
OneFF["models"] = "";
|
||||
OneFF["models"] = "";
|
||||
|
||||
json pPrinters = pm["compatible_printers"];
|
||||
int nPrinter = pPrinters.size();
|
||||
std::string ModelList = "";
|
||||
for (int i = 0; i < nPrinter; i++)
|
||||
{
|
||||
std::string sP = pPrinters.at(i);
|
||||
if (m_ProfileJson["machine"].contains(sP))
|
||||
{
|
||||
std::string mModel = m_ProfileJson["machine"][sP]["model"];
|
||||
std::string mNozzle = m_ProfileJson["machine"][sP]["nozzle"];
|
||||
std::string NewModel = mModel + "++" + mNozzle;
|
||||
|
||||
ModelList = (boost::format("%1%[%2%]") % ModelList % NewModel).str();
|
||||
}
|
||||
}
|
||||
|
||||
OneFF["models"] = ModelList;
|
||||
OneFF["selected"] = 0;
|
||||
}
|
||||
else
|
||||
|
||||
m_ProfileJson["filament"][s1] = OneFF;
|
||||
} else
|
||||
continue;
|
||||
|
||||
} else {
|
||||
OneFF = m_ProfileJson["filament"][s1];
|
||||
}
|
||||
|
||||
std::string vModel = "";
|
||||
int nm = m_ProfileJson["model"].size();
|
||||
int bFind = 0;
|
||||
for (int m = 0; m < nm; m++) {
|
||||
std::string strFF = m_ProfileJson["model"][m]["materials"];
|
||||
strFF = (boost::format(";%1%;")%strFF).str();
|
||||
std::string strTT = (boost::format(";%1%;")%s1).str();
|
||||
if (strFF.find(strTT) != std::string::npos) {
|
||||
std::string sModel = m_ProfileJson["model"][m]["model"];
|
||||
|
||||
vModel = (boost::format("%1%[%2%]")%vModel %sModel).str();
|
||||
bFind = 1;
|
||||
}
|
||||
}
|
||||
|
||||
OneFF["models"] = vModel;
|
||||
|
||||
m_ProfileJson["filament"][s1] = OneFF;
|
||||
}
|
||||
|
||||
//process
|
||||
// process
|
||||
json pProcess = jLocal["process_list"];
|
||||
nsize = pProcess.size();
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", got %1% processes")%nsize;
|
||||
nsize = pProcess.size();
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", got %1% processes") % nsize;
|
||||
for (int n = 0; n < nsize; n++) {
|
||||
json OneProcess = pProcess.at(n);
|
||||
|
||||
std::string s2 = OneProcess["sub_path"];
|
||||
//wxString ModelFilePath = wxString::Format("%s\\%s\\%s", strFolder, strVendor, s2);
|
||||
std::string s2 = OneProcess["sub_path"];
|
||||
// wxString ModelFilePath = wxString::Format("%s\\%s\\%s", strFolder, strVendor, s2);
|
||||
boost::filesystem::path sub_path = boost::filesystem::absolute(vendor_dir / s2).make_preferred();
|
||||
std::string sub_file = sub_path.string();
|
||||
std::string sub_file = sub_path.string();
|
||||
LoadFile(sub_file, contents);
|
||||
json pm = json::parse(contents);
|
||||
|
||||
std::string bInstall = pm["instantiation"];
|
||||
if (bInstall == "true")
|
||||
{
|
||||
m_ProfileJson["process"].push_back(OneProcess);
|
||||
}
|
||||
if (bInstall == "true") { m_ProfileJson["process"].push_back(OneProcess); }
|
||||
}
|
||||
|
||||
}
|
||||
catch(nlohmann::detail::parse_error &err) {
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__<< ": parse "<<strFilePath <<" got a nlohmann::detail::parse_error, reason = " << err.what();
|
||||
} catch (nlohmann::detail::parse_error &err) {
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": parse " << strFilePath << " got a nlohmann::detail::parse_error, reason = " << err.what();
|
||||
return -1;
|
||||
}
|
||||
catch (std::exception &e) {
|
||||
} catch (std::exception &e) {
|
||||
// wxMessageBox(e.what(), "", MB_OK);
|
||||
//wxLogMessage("GUIDE: LoadFamily Error: %s", e.what());
|
||||
// wxLogMessage("GUIDE: LoadFamily Error: %s", e.what());
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": parse " << strFilePath << " got exception: " << e.what();
|
||||
return -1;
|
||||
}
|
||||
|
@ -1178,6 +1349,7 @@ int GuideFrame::LoadProfileFamily(std::string strVendor, std::string strFilePath
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void GuideFrame::StrReplace(std::string &strBase, std::string strSrc, std::string strDes)
|
||||
{
|
||||
int pos = 0;
|
||||
|
|
|
@ -65,7 +65,7 @@ ZUserLogin::ZUserLogin() : wxDialog((wxWindow *) (wxGetApp().mainframe), wxID_AN
|
|||
TargetUrl = host_url + "/" + strlang + "/sign-in";
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "login url = " << TargetUrl.ToStdString();
|
||||
BOOST_LOG_TRIVIAL(info) << "login url = " << TargetUrl.ToStdString();
|
||||
|
||||
m_bbl_user_agent = wxString::Format("BBL-Slicer/v%s", SLIC3R_VERSION);
|
||||
|
||||
|
|
|
@ -398,8 +398,11 @@ void WebViewPanel::OnClose(wxCloseEvent& evt)
|
|||
this->Hide();
|
||||
}
|
||||
|
||||
void WebViewPanel::OnFreshLoginStatus(wxTimerEvent &event) {
|
||||
Slic3r::GUI::wxGetApp().get_login_info();
|
||||
void WebViewPanel::OnFreshLoginStatus(wxTimerEvent &event)
|
||||
{
|
||||
auto mainframe = Slic3r::GUI::wxGetApp().mainframe;
|
||||
if (mainframe && mainframe->m_webview == this)
|
||||
Slic3r::GUI::wxGetApp().get_login_info();
|
||||
}
|
||||
|
||||
void WebViewPanel::SendRecentList(wxString const &sequence_id)
|
||||
|
|
|
@ -1345,7 +1345,7 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
|
|||
|
||||
m_panel_can = new StaticBox(amswin, wxID_ANY, wxDefaultPosition, AMS_CANS_SIZE, wxBORDER_NONE);
|
||||
m_panel_can->SetMinSize(AMS_CANS_SIZE);
|
||||
m_panel_can->SetCornerRadius(10);
|
||||
m_panel_can->SetCornerRadius(FromDIP(10));
|
||||
m_panel_can->SetBackgroundColor(AMS_CONTROL_DEF_BLOCK_BK_COLOUR);
|
||||
|
||||
m_sizer_cans = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
@ -1532,7 +1532,7 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
|
|||
m_button_calibration_again->SetBorderColor(AMS_CONTROL_BRAND_COLOUR);
|
||||
m_button_calibration_again->SetTextColor(AMS_CONTROL_WHITE_COLOUR);
|
||||
m_button_calibration_again->SetMinSize(AMS_CONTRO_CALIBRATION_BUTTON_SIZE);
|
||||
m_button_calibration_again->SetCornerRadius(12);
|
||||
m_button_calibration_again->SetCornerRadius(FromDIP(12));
|
||||
m_button_calibration_again->Bind(wxEVT_LEFT_DOWN, &AMSControl::on_clibration_again_click, this);
|
||||
|
||||
sizer_button->Add(m_button_calibration_again, 0, wxALL, 5);
|
||||
|
@ -1542,7 +1542,7 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
|
|||
m_button_calibration_cancel->SetBorderColor(AMS_CONTROL_GRAY700);
|
||||
m_button_calibration_cancel->SetTextColor(AMS_CONTROL_GRAY800);
|
||||
m_button_calibration_cancel->SetMinSize(AMS_CONTRO_CALIBRATION_BUTTON_SIZE);
|
||||
m_button_calibration_cancel->SetCornerRadius(12);
|
||||
m_button_calibration_cancel->SetCornerRadius(FromDIP(12));
|
||||
m_button_calibration_cancel->Bind(wxEVT_LEFT_DOWN, &AMSControl::on_clibration_cancel_click, this);
|
||||
sizer_button->Add(m_button_calibration_cancel, 0, wxALL, 5);
|
||||
|
||||
|
@ -1575,9 +1575,9 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
|
|||
void AMSControl::init_scaled_buttons()
|
||||
{
|
||||
m_button_extruder_feed->SetMinSize(wxSize(-1, FromDIP(24)));
|
||||
m_button_extruder_feed->SetCornerRadius(FromDIP(11));
|
||||
m_button_extruder_feed->SetCornerRadius(FromDIP(12));
|
||||
m_button_extruder_back->SetMinSize(wxSize(-1, FromDIP(24)));
|
||||
m_button_extruder_back->SetCornerRadius(FromDIP(11));
|
||||
m_button_extruder_back->SetCornerRadius(FromDIP(12));
|
||||
m_button_ams_setting->SetMinSize(wxSize(-1, FromDIP(33)));
|
||||
m_button_ams_setting->SetCornerRadius(FromDIP(12));
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <wx/dcgraph.h>
|
||||
|
||||
static const wxColour bd = wxColour(0x00AE42);
|
||||
static const wxColour bd = wxColour(0, 174, 66);
|
||||
static const wxColour BUTTON_BG_COL = wxColour(238, 238, 238);
|
||||
static const wxColour BUTTON_IN_BG_COL = wxColour(206, 206, 206);
|
||||
static const wxColour blank_bg = wxColour(0xFFFFFF);
|
||||
|
@ -21,7 +21,7 @@ END_EVENT_TABLE()
|
|||
#define OUTER_SIZE FromDIP(105)
|
||||
#define INNER_SIZE FromDIP(58)
|
||||
#define HOME_SIZE FromDIP(23)
|
||||
#define BLANK_SIZE FromDIP(23)
|
||||
#define BLANK_SIZE FromDIP(24)
|
||||
#define GAP_SIZE FromDIP(4)
|
||||
|
||||
AxisCtrlButton::AxisCtrlButton(wxWindow *parent, ScalableBitmap &icon, long stlye)
|
||||
|
|
|
@ -253,7 +253,12 @@ void Button::keyDownUp(wxKeyEvent &event)
|
|||
GetEventHandler()->ProcessEvent(evt);
|
||||
return;
|
||||
}
|
||||
event.Skip();
|
||||
if (event.GetEventType() == wxEVT_KEY_DOWN &&
|
||||
(event.GetKeyCode() == WXK_TAB || event.GetKeyCode() == WXK_LEFT || event.GetKeyCode() == WXK_RIGHT
|
||||
|| event.GetKeyCode() == WXK_UP || event.GetKeyCode() == WXK_DOWN))
|
||||
HandleAsNavigationKey(event);
|
||||
else
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void Button::sendButtonEvent()
|
||||
|
@ -271,17 +276,10 @@ WXLRESULT Button::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
|||
if (nMsg == WM_KEYDOWN) {
|
||||
wxKeyEvent event(CreateKeyEvent(wxEVT_KEY_DOWN, wParam, lParam));
|
||||
switch (wParam) {
|
||||
case WXK_RETURN: {
|
||||
case WXK_RETURN: { // WXK_RETURN key is handled by default button
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
return 0;
|
||||
}
|
||||
case WXK_TAB:
|
||||
case WXK_LEFT:
|
||||
case WXK_RIGHT:
|
||||
case WXK_UP:
|
||||
case WXK_DOWN:
|
||||
if (HandleAsNavigationKey(event))
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return wxWindow::MSWWindowProc(nMsg, wParam, lParam);
|
||||
|
|
|
@ -43,9 +43,16 @@ void CheckBox::SetHalfChecked(bool value)
|
|||
|
||||
void CheckBox::Rescale()
|
||||
{
|
||||
m_on.msw_rescale();
|
||||
m_off.msw_rescale();
|
||||
SetSize(m_on.GetBmpSize());
|
||||
m_on.msw_rescale();
|
||||
m_half.msw_rescale();
|
||||
m_off.msw_rescale();
|
||||
m_on_disabled.msw_rescale();
|
||||
m_half_disabled.msw_rescale();
|
||||
m_off_disabled.msw_rescale();
|
||||
m_on_focused.msw_rescale();
|
||||
m_half_focused.msw_rescale();
|
||||
m_off_focused.msw_rescale();
|
||||
SetSize(m_on.GetBmpSize());
|
||||
update();
|
||||
}
|
||||
|
||||
|
|
|
@ -206,7 +206,7 @@ void ComboBox::DoSetItemClientData(unsigned int n, void *data)
|
|||
|
||||
void ComboBox::mouseDown(wxMouseEvent &event)
|
||||
{
|
||||
//SetFocus();
|
||||
SetFocus();
|
||||
if (drop_down) {
|
||||
drop.Hide();
|
||||
} else if (drop.HasDismissLongTime()) {
|
||||
|
@ -230,7 +230,8 @@ void ComboBox::mouseWheelMoved(wxMouseEvent &event)
|
|||
}
|
||||
}
|
||||
|
||||
void ComboBox::keyDown(wxKeyEvent& event) {
|
||||
void ComboBox::keyDown(wxKeyEvent& event)
|
||||
{
|
||||
switch (event.GetKeyCode()) {
|
||||
case WXK_RETURN:
|
||||
case WXK_SPACE:
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
#include "TextInput.hpp"
|
||||
#include "DropDown.hpp"
|
||||
|
||||
#define CB_NO_DROP_ICON 0x1000000
|
||||
#define CB_NO_TEXT 0x2000000
|
||||
#define CB_NO_DROP_ICON DD_NO_CHECK_ICON
|
||||
#define CB_NO_TEXT DD_NO_TEXT
|
||||
|
||||
class ComboBox : public wxWindowWithItems<TextInput, wxItemContainer>
|
||||
{
|
||||
|
|
|
@ -354,7 +354,7 @@ void DropDown::autoPosition()
|
|||
}
|
||||
if (GetPosition().y > pos.y) {
|
||||
// may exceed
|
||||
auto drect = wxDisplay(wxDisplay::GetFromWindow(GetParent())).GetGeometry();
|
||||
auto drect = wxDisplay(GetParent()).GetGeometry();
|
||||
if (GetPosition().y + size.y + 10 > drect.GetBottom()) {
|
||||
if (use_content_width && texts.size() <= 15) size.x += 6;
|
||||
size.y = drect.GetBottom() - GetPosition().y - 10;
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
#include "../wxExtensions.hpp"
|
||||
#include "StateHandler.hpp"
|
||||
|
||||
#define DD_NO_CHECK_ICON 0x1000000
|
||||
#define DD_NO_TEXT 0x2000000
|
||||
#define DD_STYLE_MASK 0x3000000
|
||||
#define DD_NO_CHECK_ICON 0x0001
|
||||
#define DD_NO_TEXT 0x0002
|
||||
#define DD_STYLE_MASK 0x0003
|
||||
|
||||
wxDECLARE_EVENT(EVT_DISMISS, wxCommandEvent);
|
||||
|
||||
|
|
|
@ -20,20 +20,18 @@ static const wxColour DEFAULT_PRESS_COL = wxColour(238, 238, 238);
|
|||
|
||||
ImageSwitchButton::ImageSwitchButton(wxWindow *parent, ScalableBitmap &img_on, ScalableBitmap &img_off, long style)
|
||||
: text_color(std::make_pair(0x6B6B6B, (int) StateColor::Disabled), std::make_pair(*wxBLACK, (int) StateColor::Normal))
|
||||
, state_handler(this)
|
||||
{
|
||||
radius = 0;
|
||||
m_padding = 0;
|
||||
m_on = img_on;
|
||||
m_off = img_off;
|
||||
bg_color = StateColor(std::make_pair(DEFAULT_PRESS_COL, (int) StateColor::Pressed),
|
||||
std::make_pair(*wxWHITE, (int) StateColor::Normal));
|
||||
border_color = StateColor(std::make_pair(DEFAULT_HOVER_COL, (int) StateColor::Hovered));
|
||||
background_color = StateColor(std::make_pair(*wxWHITE, (int) StateColor::Disabled), std::make_pair(DEFAULT_PRESS_COL, (int) StateColor::Pressed),
|
||||
std::make_pair(*wxWHITE, (int) StateColor::Normal));
|
||||
border_color = StateColor(std::make_pair(*wxWHITE, (int) StateColor::Disabled), std::make_pair(DEFAULT_HOVER_COL, (int) StateColor::Focused),
|
||||
std::make_pair(DEFAULT_HOVER_COL, (int) StateColor::Hovered), std::make_pair(*wxWHITE, (int) StateColor::Normal));
|
||||
|
||||
StaticBox::Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, style);
|
||||
|
||||
state_handler.attach({&bg_color});
|
||||
state_handler.attach({&border_color});
|
||||
state_handler.update_binds();
|
||||
messureSize();
|
||||
Refresh();
|
||||
}
|
||||
|
@ -64,19 +62,6 @@ void ImageSwitchButton::SetTextColor(StateColor const &color)
|
|||
Refresh();
|
||||
}
|
||||
|
||||
void ImageSwitchButton::SetBorderColor(StateColor const &color)
|
||||
{
|
||||
border_color = color;
|
||||
messureSize();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void ImageSwitchButton::SetBgColor(StateColor const &color) {
|
||||
bg_color = color;
|
||||
messureSize();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void ImageSwitchButton::SetValue(bool value)
|
||||
{
|
||||
m_on_off = value;
|
||||
|
@ -110,16 +95,6 @@ void ImageSwitchButton::render(wxDC& dc)
|
|||
int states = state_handler.states();
|
||||
wxSize size = GetSize();
|
||||
|
||||
if (pressedDown) {
|
||||
dc.SetBrush(bg_color.colorForStates(StateColor::Pressed));
|
||||
dc.DrawRectangle(wxRect(0, 0, size.x, size.y));
|
||||
}
|
||||
|
||||
if (hover) {
|
||||
dc.SetPen(border_color.colorForStates(StateColor::Hovered));
|
||||
dc.DrawRectangle(wxRect(0, 0, size.x, size.y));
|
||||
}
|
||||
|
||||
wxSize szIcon;
|
||||
wxSize szContent = textSize;
|
||||
ScalableBitmap &icon = GetValue() ? m_on : m_off;
|
||||
|
|
|
@ -17,8 +17,6 @@ public:
|
|||
void SetLabels(wxString const & lbl_on, wxString const & lbl_off);
|
||||
void SetImages(ScalableBitmap &img_on, ScalableBitmap &img_off);
|
||||
void SetTextColor(StateColor const &color);
|
||||
void SetBorderColor(StateColor const &color);
|
||||
void SetBgColor(StateColor const &color);
|
||||
void SetValue(bool value);
|
||||
void SetPadding(int padding);
|
||||
|
||||
|
@ -50,9 +48,6 @@ private:
|
|||
|
||||
wxString labels[2];
|
||||
StateColor text_color;
|
||||
StateColor bg_color;
|
||||
StateColor border_color;
|
||||
StateHandler state_handler;
|
||||
};
|
||||
|
||||
#endif // !slic3r_GUI_SwitchButton_hpp_
|
||||
|
|
|
@ -63,12 +63,11 @@ wxSize Label::split_lines(wxDC &dc, int width, const wxString &text, wxString &m
|
|||
return dc.GetMultiLineTextExtent(multiline_text);
|
||||
}
|
||||
|
||||
Label::Label(wxString const &text, wxWindow *parent) : Label(Body_16, text, parent) {}
|
||||
Label::Label(wxWindow *parent, wxString const &text) : Label(parent, Body_14, text) {}
|
||||
|
||||
Label::Label(wxFont const &font, wxWindow *parent) : Label(font, "", parent) {}
|
||||
|
||||
Label::Label(wxFont const &font, wxString const &text, wxWindow *parent) : wxStaticText(parent, wxID_ANY, text, wxDefaultPosition, wxDefaultSize, 0)
|
||||
Label::Label(wxWindow *parent, wxFont const &font, wxString const &text)
|
||||
: wxStaticText(parent, wxID_ANY, text, wxDefaultPosition, wxDefaultSize, 0)
|
||||
{
|
||||
SetBackgroundColour(StaticBox::GetParentBackgroundColor(parent));
|
||||
SetFont(font);
|
||||
SetBackgroundColour(StaticBox::GetParentBackgroundColor(parent));
|
||||
}
|
||||
|
|
|
@ -6,11 +6,9 @@
|
|||
class Label : public wxStaticText
|
||||
{
|
||||
public:
|
||||
Label(wxString const& text, wxWindow* parent = NULL);
|
||||
Label(wxWindow *parent, wxString const &text = {});
|
||||
|
||||
Label(wxFont const& font, wxWindow* parent = NULL);
|
||||
|
||||
Label(wxFont const& font, wxString const& text, wxWindow* parent = NULL);
|
||||
Label(wxWindow *parent, wxFont const &font, wxString const &text = {});
|
||||
|
||||
public:
|
||||
static wxFont Head_24;
|
||||
|
|
|
@ -221,6 +221,7 @@ bool ProgressDialog::Create(const wxString &title, const wxString &message, int
|
|||
m_button_cancel = new Button(this, _L("Cancel"));
|
||||
m_button_cancel->SetTextColor(PROGRESSDIALOG_GREY_700);
|
||||
m_button_cancel->SetMinSize(PROGRESSDIALOG_CANCEL_BUTTON_SIZE);
|
||||
m_button_cancel->SetCornerRadius(PROGRESSDIALOG_CANCEL_BUTTON_SIZE.y / 2);
|
||||
m_button_cancel->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &event) {
|
||||
if (m_state == Finished) {
|
||||
event.Skip();
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace Slic3r { namespace GUI {
|
|||
this->Bind(wxEVT_LEFT_UP, &SideTools::on_mouse_left_up, this);
|
||||
}
|
||||
|
||||
SideTools::~SideTools() {}
|
||||
SideTools::~SideTools() { delete m_intetval_timer; }
|
||||
|
||||
void SideTools::set_none_printer_mode()
|
||||
{
|
||||
|
|
|
@ -61,18 +61,7 @@ void SpinInput::Create(wxWindow *parent,
|
|||
text_ctrl->SetBackgroundColour(background_color.colorForStates(state_handler.states()));
|
||||
text_ctrl->SetForegroundColour(text_color.colorForStates(state_handler.states()));
|
||||
text_ctrl->SetInitialSize(text_ctrl->GetBestSize());
|
||||
text_ctrl->Bind(wxEVT_SET_FOCUS, [this](auto &e) {
|
||||
e.SetId(GetId());
|
||||
ProcessEventLocally(e);
|
||||
});
|
||||
text_ctrl->Bind(wxEVT_ENTER_WINDOW, [this](auto &e) {
|
||||
e.SetId(GetId());
|
||||
ProcessEventLocally(e);
|
||||
});
|
||||
text_ctrl->Bind(wxEVT_LEAVE_WINDOW, [this](auto &e) {
|
||||
e.SetId(GetId());
|
||||
ProcessEventLocally(e);
|
||||
});
|
||||
state_handler.attach_child(text_ctrl);
|
||||
text_ctrl->Bind(wxEVT_KILL_FOCUS, &SpinInput::onTextLostFocus, this);
|
||||
text_ctrl->Bind(wxEVT_TEXT_ENTER, &SpinInput::onTextEnter, this);
|
||||
text_ctrl->Bind(wxEVT_KEY_DOWN, &SpinInput::keyPressed, this);
|
||||
|
@ -281,6 +270,7 @@ void SpinInput::onTextLostFocus(wxEvent &event)
|
|||
// pass to outer
|
||||
event.SetId(GetId());
|
||||
ProcessEventLocally(event);
|
||||
e.Skip();
|
||||
}
|
||||
|
||||
void SpinInput::onTextEnter(wxCommandEvent &event)
|
||||
|
|
|
@ -5,24 +5,44 @@ wxDEFINE_EVENT(EVT_ENABLE_CHANGED, wxCommandEvent);
|
|||
StateHandler::StateHandler(wxWindow * owner)
|
||||
: owner_(owner)
|
||||
{
|
||||
owner_->PushEventHandler(this);
|
||||
if (owner->IsEnabled())
|
||||
states_ |= Enabled;
|
||||
if (owner->HasFocus())
|
||||
states_ |= Focused;
|
||||
}
|
||||
|
||||
StateHandler::~StateHandler() { owner_->RemoveEventHandler(this); }
|
||||
|
||||
void StateHandler::attach(StateColor const &color)
|
||||
{
|
||||
colors_.push_back(&color);
|
||||
}
|
||||
|
||||
void StateHandler::attach(std::vector<StateColor const *> const & colors)
|
||||
{
|
||||
colors_.insert(colors_.end(), colors.begin(), colors.end());
|
||||
}
|
||||
|
||||
void StateHandler::attach_child(wxWindow *child)
|
||||
{
|
||||
auto ch = new StateHandler(this, child);
|
||||
children_.emplace_back(ch);
|
||||
ch->update_binds();
|
||||
states2_ |= ch->states();
|
||||
}
|
||||
|
||||
void StateHandler::remove_child(wxWindow *child)
|
||||
{
|
||||
children_.erase(std::remove_if(children_.begin(), children_.end(),
|
||||
[child](auto &c) { return c->owner_ == child; }), children_.end());
|
||||
states2_ = 0;
|
||||
for (auto & c : children_) states2_ |= c->states();
|
||||
}
|
||||
|
||||
void StateHandler::update_binds()
|
||||
{
|
||||
int bind_states = 0;
|
||||
int bind_states = parent_ ? (parent_->bind_states_ & ~Enabled) : 0;
|
||||
for (auto c : colors_) {
|
||||
bind_states |= c->states();
|
||||
}
|
||||
|
@ -35,45 +55,68 @@ void StateHandler::update_binds()
|
|||
int s = states[i];
|
||||
if (diff & s) {
|
||||
if (bind_states & s) {
|
||||
owner_->Bind(events[i], &StateHandler::changed, this);
|
||||
Bind(events[i], &StateHandler::changed, this);
|
||||
if (events2[i])
|
||||
owner_->Bind(events2[i], &StateHandler::changed, this);
|
||||
Bind(events2[i], &StateHandler::changed, this);
|
||||
} else {
|
||||
owner_->Unbind(events[i], &StateHandler::changed, this);
|
||||
Unbind(events[i], &StateHandler::changed, this);
|
||||
if (events2[i])
|
||||
owner_->Unbind(events2[i], &StateHandler::changed, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
bind_states_ = bind_states;
|
||||
owner_->Refresh();
|
||||
for (auto &c : children_) c->update_binds();
|
||||
}
|
||||
|
||||
void StateHandler::changed(wxEvent & event)
|
||||
StateHandler::StateHandler(StateHandler *parent, wxWindow *owner)
|
||||
: StateHandler(owner)
|
||||
{
|
||||
states_ &= ~Enabled;
|
||||
parent_ = parent;
|
||||
}
|
||||
|
||||
void StateHandler::changed(wxEvent &event)
|
||||
{
|
||||
event.Skip();
|
||||
wxEventType events[] = {EVT_ENABLE_CHANGED, wxEVT_CHECKBOX, wxEVT_SET_FOCUS, wxEVT_ENTER_WINDOW, wxEVT_LEFT_DOWN};
|
||||
wxEventType events2[] = {{0}, {0}, wxEVT_KILL_FOCUS, wxEVT_LEAVE_WINDOW, wxEVT_LEFT_UP};
|
||||
int old = states2_ | states_;
|
||||
int old = states_;
|
||||
// some events are from another window (ex: text_ctrl of TextInput), save state in states2_ to avoid conflicts
|
||||
int & states = event.GetEventObject() == owner_ ? states_ : states2_;
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
if (events2[i]) {
|
||||
if (event.GetEventType() == events[i]) {
|
||||
states |= 1 << i;
|
||||
states_ |= 1 << i;
|
||||
break;
|
||||
} else if (event.GetEventType() == events2[i]) {
|
||||
states &= ~(1 << i);
|
||||
states_ &= ~(1 << i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (event.GetEventType() == events[i]) {
|
||||
states ^= (1 << i);
|
||||
states_ ^= (1 << i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (old != (states2_ | states_))
|
||||
owner_->Refresh();
|
||||
if (old != states_ && (old | states2_) != (states_ | states2_)) {
|
||||
if (parent_)
|
||||
parent_->changed(states_ | states2_);
|
||||
else
|
||||
owner_->Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void StateHandler::changed(int)
|
||||
{
|
||||
int old = states2_;
|
||||
states2_ = 0;
|
||||
for (auto &c : children_) states2_ |= c->states();
|
||||
if (old != states2_ && (old | states_) != (states_ | states2_)) {
|
||||
if (parent_)
|
||||
parent_->changed(states_ | states2_);
|
||||
else
|
||||
owner_->Refresh();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,24 +26,36 @@ public:
|
|||
public:
|
||||
StateHandler(wxWindow * owner);
|
||||
|
||||
~StateHandler();
|
||||
|
||||
public:
|
||||
void attach(StateColor const & color);
|
||||
|
||||
void attach(std::vector<StateColor const *> const & colors);
|
||||
|
||||
void attach_child(wxWindow *child);
|
||||
|
||||
void remove_child(wxWindow *child);
|
||||
|
||||
void update_binds();
|
||||
|
||||
int states() const { return states_ | states2_; }
|
||||
|
||||
private:
|
||||
void changed(wxEvent & event);
|
||||
StateHandler(StateHandler * parent, wxWindow *owner);
|
||||
|
||||
void changed(wxEvent &event);
|
||||
|
||||
void changed(int state2);
|
||||
|
||||
private:
|
||||
wxWindow * owner_;
|
||||
std::vector<StateColor const *> colors_;
|
||||
int bind_states_ = 0;
|
||||
int states_ = 0;
|
||||
int states2_ = 0;
|
||||
int states2_ = 0; // from children
|
||||
std::vector<std::unique_ptr<StateHandler>> children_;
|
||||
StateHandler * parent_ = nullptr;
|
||||
};
|
||||
|
||||
#endif // !slic3r_GUI_StateHandler_hpp_
|
||||
|
|
|
@ -5,7 +5,8 @@ wxDEFINE_EVENT( wxEVT_TAB_SEL_CHANGED, wxCommandEvent );
|
|||
|
||||
BEGIN_EVENT_TABLE(TabCtrl, StaticBox)
|
||||
|
||||
// catch paint events
|
||||
EVT_KEY_DOWN(TabCtrl::keyDown)
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
/*
|
||||
|
@ -201,6 +202,16 @@ void TabCtrl::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
|||
relayout();
|
||||
}
|
||||
|
||||
#ifdef __WIN32__
|
||||
|
||||
WXLRESULT TabCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
||||
{
|
||||
if (nMsg == WM_GETDLGCODE) { return DLGC_WANTARROWS; }
|
||||
return wxWindow::MSWWindowProc(nMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void TabCtrl::relayout()
|
||||
{
|
||||
int offset = 10;
|
||||
|
@ -243,11 +254,28 @@ void TabCtrl::relayout()
|
|||
|
||||
void TabCtrl::buttonClicked(wxCommandEvent &event)
|
||||
{
|
||||
auto btn = event.GetEventObject();
|
||||
SetFocus();
|
||||
auto btn = event.GetEventObject();
|
||||
auto iter = std::find(btns.begin(), btns.end(), btn);
|
||||
SelectItem(iter == btns.end() ? -1 : iter - btns.begin());
|
||||
}
|
||||
|
||||
void TabCtrl::keyDown(wxKeyEvent &event)
|
||||
{
|
||||
switch (event.GetKeyCode()) {
|
||||
case WXK_UP:
|
||||
case WXK_DOWN:
|
||||
case WXK_LEFT:
|
||||
case WXK_RIGHT:
|
||||
if ((event.GetKeyCode() == WXK_UP || event.GetKeyCode() == WXK_LEFT) && GetSelection() > 0) {
|
||||
SelectItem(GetSelection() - 1);
|
||||
} else if ((event.GetKeyCode() == WXK_DOWN || event.GetKeyCode() == WXK_RIGHT) && GetSelection() + 1 < btns.size()) {
|
||||
SelectItem(GetSelection() + 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void TabCtrl::doRender(wxDC& dc)
|
||||
{
|
||||
wxSize size = GetSize();
|
||||
|
@ -256,9 +284,9 @@ void TabCtrl::doRender(wxDC& dc)
|
|||
|
||||
auto x1 = btns[sel]->GetPosition().x;
|
||||
auto x2 = x1 + btns[sel]->GetSize().x;
|
||||
const int BS = border_width / 2;
|
||||
const int BS2 = (1 + border_width) / 2;
|
||||
#if 0
|
||||
const int BS = border_width / 2;
|
||||
x1 -= TAB_BUTTON_SPACE; x2 += TAB_BUTTON_SPACE;
|
||||
dc.SetPen(wxPen(border_color.colorForStates(states), border_width));
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
|
@ -275,7 +303,7 @@ void TabCtrl::doRender(wxDC& dc)
|
|||
dc.SetPen(wxPen(border_color.colorForStates(states), border_width));
|
||||
dc.DrawLine(0, size.y - BS2, size.x, size.y - BS2);
|
||||
wxColor c(0x42AE00);
|
||||
dc.SetPen(wxPen(c, 0));
|
||||
dc.SetPen(wxPen(c, 1));
|
||||
dc.SetBrush(c);
|
||||
dc.DrawRoundedRectangle(x1 - radius, size.y - BS2 - border_width * 3, x2 + radius * 2 - x1, border_width * 3, radius);
|
||||
#endif
|
||||
|
|
|
@ -65,9 +65,14 @@ public:
|
|||
private:
|
||||
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
|
||||
|
||||
#ifdef __WIN32__
|
||||
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) override;
|
||||
#endif
|
||||
|
||||
void relayout();
|
||||
|
||||
void buttonClicked(wxCommandEvent & event);
|
||||
void keyDown(wxKeyEvent &event);
|
||||
|
||||
void doRender(wxDC & dc) override;
|
||||
|
||||
|
|
|
@ -19,18 +19,14 @@ END_EVENT_TABLE()
|
|||
|
||||
|
||||
TempInput::TempInput()
|
||||
: state_handler(this)
|
||||
, border_color(std::make_pair(*wxWHITE, (int) StateColor::Disabled),
|
||||
std::make_pair(0x00AE42, (int) StateColor::Focused),
|
||||
std::make_pair(0x00AE42, (int) StateColor::Hovered),
|
||||
std::make_pair(*wxWHITE, (int) StateColor::Normal))
|
||||
, label_color(std::make_pair(wxColour(0xAC,0xAC,0xAC), (int) StateColor::Disabled),std::make_pair(0x323A3D, (int) StateColor::Normal))
|
||||
: label_color(std::make_pair(wxColour(0xAC,0xAC,0xAC), (int) StateColor::Disabled),std::make_pair(0x323A3D, (int) StateColor::Normal))
|
||||
, text_color(std::make_pair(wxColour(0xAC,0xAC,0xAC), (int) StateColor::Disabled), std::make_pair(0x6B6B6B, (int) StateColor::Normal))
|
||||
, background_color(std::make_pair(*wxWHITE, (int) StateColor::Disabled),
|
||||
std::make_pair(*wxWHITE, (int) StateColor::Normal))
|
||||
{
|
||||
hover = false;
|
||||
radius = 0;
|
||||
border_color = StateColor(std::make_pair(*wxWHITE, (int) StateColor::Disabled), std::make_pair(0x00AE42, (int) StateColor::Focused), std::make_pair(0x00AE42, (int) StateColor::Hovered),
|
||||
std::make_pair(*wxWHITE, (int) StateColor::Normal));
|
||||
background_color = StateColor(std::make_pair(*wxWHITE, (int) StateColor::Disabled), std::make_pair(*wxWHITE, (int) StateColor::Normal));
|
||||
SetFont(Label::Body_12);
|
||||
}
|
||||
|
||||
|
@ -44,41 +40,34 @@ TempInput::TempInput(wxWindow *parent, int type, wxString text, wxString label,
|
|||
|
||||
void TempInput::Create(wxWindow *parent, wxString text, wxString label, wxString normal_icon, wxString actice_icon, const wxPoint &pos, const wxSize &size, long style)
|
||||
{
|
||||
wxWindow::Create(parent, wxID_ANY, pos, size, style);
|
||||
StaticBox::Create(parent, wxID_ANY, pos, size, style);
|
||||
wxWindow::SetLabel(label);
|
||||
style &= ~wxALIGN_CENTER_HORIZONTAL;
|
||||
state_handler.attach({&border_color, &text_color, &background_color});
|
||||
state_handler.attach({&label_color, &text_color});
|
||||
state_handler.update_binds();
|
||||
|
||||
text_ctrl = new wxTextCtrl(this, wxID_ANY, text, {5, 5}, wxDefaultSize, wxTE_PROCESS_ENTER | wxBORDER_NONE, wxTextValidator(wxFILTER_NUMERIC), wxTextCtrlNameStr);
|
||||
text_ctrl->SetMaxLength(3);
|
||||
|
||||
state_handler.attach_child(text_ctrl);
|
||||
text_ctrl->Bind(wxEVT_SET_FOCUS, [this](auto &e) {
|
||||
e.SetId(GetId());
|
||||
ProcessEventLocally(e);
|
||||
|
||||
//enter input mode
|
||||
e.Skip();
|
||||
if (m_read_only) return;
|
||||
// enter input mode
|
||||
auto temp = text_ctrl->GetValue();
|
||||
if (temp.length() > 0 && temp[0] == (0x5f)) {
|
||||
text_ctrl->SetValue(wxEmptyString);
|
||||
}
|
||||
|
||||
if (wdialog != nullptr) { wdialog->Dismiss(); }
|
||||
});
|
||||
text_ctrl->Bind(wxEVT_ENTER_WINDOW, [this](auto &e) {
|
||||
if (m_read_only) {SetCursor(wxCURSOR_ARROW);}
|
||||
e.SetId(GetId());
|
||||
ProcessEventLocally(e);
|
||||
});
|
||||
text_ctrl->Bind(wxEVT_LEAVE_WINDOW, [this](auto &e) {
|
||||
e.SetId(GetId());
|
||||
ProcessEventLocally(e);
|
||||
if (m_read_only) { SetCursor(wxCURSOR_ARROW); }
|
||||
});
|
||||
text_ctrl->Bind(wxEVT_KILL_FOCUS, [this](auto &e) {
|
||||
OnEdit();
|
||||
e.SetId(GetId());
|
||||
ProcessEventLocally(e);
|
||||
|
||||
e.Skip();
|
||||
OnEdit();
|
||||
auto temp = text_ctrl->GetValue();
|
||||
if (temp.ToStdString().empty()) {
|
||||
text_ctrl->SetValue(wxString("_"));
|
||||
|
@ -102,9 +91,6 @@ void TempInput::Create(wxWindow *parent, wxString text, wxString label, wxString
|
|||
});
|
||||
text_ctrl->Bind(wxEVT_TEXT_ENTER, [this](wxCommandEvent &e) {
|
||||
OnEdit();
|
||||
e.SetId(GetId());
|
||||
ProcessEventLocally(e);
|
||||
|
||||
auto temp = text_ctrl->GetValue();
|
||||
if (temp.ToStdString().empty()) return;
|
||||
if (!AllisNum(temp.ToStdString())) return;
|
||||
|
@ -271,12 +257,6 @@ void TempInput::SetMaxTemp(int temp) { max_temp = temp; }
|
|||
|
||||
void TempInput::SetMinTemp(int temp) { min_temp = temp; }
|
||||
|
||||
void TempInput::SetCornerRadius(double radius)
|
||||
{
|
||||
this->radius = radius;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void TempInput::SetLabel(const wxString &label)
|
||||
{
|
||||
wxWindow::SetLabel(label);
|
||||
|
@ -284,12 +264,6 @@ void TempInput::SetLabel(const wxString &label)
|
|||
Refresh();
|
||||
}
|
||||
|
||||
void TempInput::SetBorderColor(StateColor const &color)
|
||||
{
|
||||
border_color = color;
|
||||
state_handler.update_binds();
|
||||
}
|
||||
|
||||
void TempInput::SetTextColor(StateColor const &color)
|
||||
{
|
||||
text_color = color;
|
||||
|
@ -302,12 +276,6 @@ void TempInput::SetLabelColor(StateColor const &color)
|
|||
state_handler.update_binds();
|
||||
}
|
||||
|
||||
void TempInput::SetBackgroundColor(StateColor const &color)
|
||||
{
|
||||
background_color = color;
|
||||
state_handler.update_binds();
|
||||
}
|
||||
|
||||
void TempInput::Rescale()
|
||||
{
|
||||
if (this->normal_icon.bmp().IsOk()) this->normal_icon.msw_rescale();
|
||||
|
@ -393,18 +361,18 @@ void TempInput::paintEvent(wxPaintEvent &evt)
|
|||
*/
|
||||
void TempInput::render(wxDC &dc)
|
||||
{
|
||||
StaticBox::render(dc);
|
||||
int states = state_handler.states();
|
||||
wxSize size = GetSize();
|
||||
bool align_right = GetWindowStyle() & wxRIGHT;
|
||||
|
||||
if (warning_mode) {
|
||||
dc.SetPen(wxPen(wxColour(255, 111, 0)));
|
||||
border_color = wxColour(255, 111, 0);
|
||||
} else {
|
||||
dc.SetPen(wxPen(border_color.colorForStates(states)));
|
||||
border_color = StateColor(std::make_pair(*wxWHITE, (int) StateColor::Disabled), std::make_pair(0x00AE42, (int) StateColor::Focused),
|
||||
std::make_pair(0x00AE42, (int) StateColor::Hovered), std::make_pair(*wxWHITE, (int) StateColor::Normal));
|
||||
}
|
||||
|
||||
dc.SetBrush(wxBrush(background_color.colorForStates(states)));
|
||||
dc.DrawRoundedRectangle(0, 0, size.x, size.y, radius);
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
// start draw
|
||||
wxPoint pt = {padding_left, 0};
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
#ifndef slic3r_GUI_TempInput_hpp_
|
||||
#define slic3r_GUI_TempInput_hpp_
|
||||
|
||||
#include <wx/textctrl.h>
|
||||
#include "../wxExtensions.hpp"
|
||||
#include "StateHandler.hpp"
|
||||
#include <wx/textctrl.h>
|
||||
#include "StaticBox.hpp"
|
||||
|
||||
wxDECLARE_EVENT(wxCUSTOMEVT_SET_TEMP_FINISH, wxCommandEvent);
|
||||
|
||||
class TempInput : public wxWindow
|
||||
class TempInput : public wxNavigationEnabled<StaticBox>
|
||||
{
|
||||
bool hover;
|
||||
double radius;
|
||||
|
||||
bool m_read_only{false};
|
||||
wxSize labelSize;
|
||||
|
@ -18,11 +17,8 @@ class TempInput : public wxWindow
|
|||
ScalableBitmap actice_icon;
|
||||
ScalableBitmap degree_icon;
|
||||
|
||||
StateHandler state_handler;
|
||||
StateColor label_color;
|
||||
StateColor text_color;
|
||||
StateColor border_color;
|
||||
StateColor background_color;
|
||||
|
||||
wxTextCtrl * text_ctrl;
|
||||
wxStaticText *warning_text;
|
||||
|
@ -93,18 +89,12 @@ public:
|
|||
wxString GetTagTemp() { return text_ctrl->GetValue(); }
|
||||
wxString GetCurrTemp() { return GetLabel(); }
|
||||
|
||||
void SetCornerRadius(double radius);
|
||||
|
||||
void SetLabel(const wxString &label);
|
||||
|
||||
void SetBorderColor(StateColor const &color);
|
||||
|
||||
void SetTextColor(StateColor const &color);
|
||||
|
||||
void SetLabelColor(StateColor const &color);
|
||||
|
||||
void SetBackgroundColor(StateColor const &color);
|
||||
|
||||
virtual void Rescale();
|
||||
|
||||
virtual bool Enable(bool enable = true) override;
|
||||
|
|
|
@ -60,22 +60,12 @@ void TextInput::Create(wxWindow * parent,
|
|||
text_ctrl->SetInitialSize(text_ctrl->GetBestSize());
|
||||
text_ctrl->SetBackgroundColour(background_color.colorForStates(state_handler.states()));
|
||||
text_ctrl->SetForegroundColour(text_color.colorForStates(state_handler.states()));
|
||||
text_ctrl->Bind(wxEVT_SET_FOCUS, [this](auto &e) {
|
||||
e.SetId(GetId());
|
||||
ProcessEventLocally(e);
|
||||
});
|
||||
text_ctrl->Bind(wxEVT_ENTER_WINDOW, [this](auto &e) {
|
||||
e.SetId(GetId());
|
||||
ProcessEventLocally(e);
|
||||
});
|
||||
text_ctrl->Bind(wxEVT_LEAVE_WINDOW, [this](auto &e) {
|
||||
e.SetId(GetId());
|
||||
ProcessEventLocally(e);
|
||||
});
|
||||
state_handler.attach_child(text_ctrl);
|
||||
text_ctrl->Bind(wxEVT_KILL_FOCUS, [this](auto &e) {
|
||||
OnEdit();
|
||||
e.SetId(GetId());
|
||||
ProcessEventLocally(e);
|
||||
e.Skip();
|
||||
});
|
||||
text_ctrl->Bind(wxEVT_TEXT_ENTER, [this](auto &e) {
|
||||
OnEdit();
|
||||
|
|
|
@ -97,7 +97,7 @@ wxBoxSizer* WipingDialog::create_btn_sizer(long flags)
|
|||
if (flags & wxRESET) {
|
||||
Button* calc_btn = new Button(this, _L("Auto-Calc"));
|
||||
calc_btn->SetMinSize(wxSize(FromDIP(75), FromDIP(24)));
|
||||
calc_btn->SetCornerRadius(12);
|
||||
calc_btn->SetCornerRadius(FromDIP(12));
|
||||
calc_btn->SetBackgroundColor(ok_btn_bg);
|
||||
calc_btn->SetBorderColor(ok_btn_bd);
|
||||
calc_btn->SetTextColor(ok_btn_text);
|
||||
|
@ -109,7 +109,7 @@ wxBoxSizer* WipingDialog::create_btn_sizer(long flags)
|
|||
if (flags & wxOK) {
|
||||
Button* ok_btn = new Button(this, _L("OK"));
|
||||
ok_btn->SetMinSize(BTN_SIZE);
|
||||
ok_btn->SetCornerRadius(12);
|
||||
ok_btn->SetCornerRadius(FromDIP(12));
|
||||
ok_btn->SetBackgroundColor(ok_btn_bg);
|
||||
ok_btn->SetBorderColor(ok_btn_bd);
|
||||
ok_btn->SetTextColor(ok_btn_text);
|
||||
|
@ -120,7 +120,7 @@ wxBoxSizer* WipingDialog::create_btn_sizer(long flags)
|
|||
if (flags & wxCANCEL) {
|
||||
Button* cancel_btn = new Button(this, _L("Cancel"));
|
||||
cancel_btn->SetMinSize(BTN_SIZE);
|
||||
cancel_btn->SetCornerRadius(12);
|
||||
cancel_btn->SetCornerRadius(FromDIP(12));
|
||||
cancel_btn->SetBackgroundColor(cancel_btn_bg);
|
||||
cancel_btn->SetBorderColor(cancel_btn_bd_);
|
||||
cancel_btn->SetTextColor(cancel_btn_text);
|
||||
|
@ -318,7 +318,7 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
|
|||
param_sizer->Add(m_flush_multiplier_ebox);
|
||||
param_sizer->AddStretchSpacer(1);
|
||||
|
||||
m_sizer_advanced->Add(param_sizer, 0, wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM, 10);
|
||||
m_sizer_advanced->Add(param_sizer, 0, wxTOP | wxBOTTOM, 10);
|
||||
}
|
||||
|
||||
m_page_advanced->Hide();
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
#include "wxMediaCtrl2.h"
|
||||
#include "I18N.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#ifdef __WIN32__
|
||||
#include <versionhelpers.h>
|
||||
#include <wx/msw/registry.h>
|
||||
#endif
|
||||
|
||||
wxMediaCtrl2::wxMediaCtrl2(wxWindow *parent)
|
||||
{
|
||||
|
@ -24,11 +29,15 @@ void wxMediaCtrl2::Load(wxURI url)
|
|||
{
|
||||
#ifdef __WIN32__
|
||||
if (m_imp == nullptr) {
|
||||
auto res = wxMessageBox(_L("Windows Media Player is required for this task! Shall I take you to the guide page of 'Get Windows Media Player'?"), _L("Error"), wxOK | wxCANCEL);
|
||||
if (res == wxOK) {
|
||||
wxString url = "https://support.microsoft.com/en-au/windows/get-windows-media-player-81718e0d-cfce-25b1-aee3-94596b658287";
|
||||
wxExecute("cmd /c start " + url, wxEXEC_HIDE_CONSOLE);
|
||||
}
|
||||
Slic3r::GUI::wxGetApp().CallAfter([] {
|
||||
auto res = wxMessageBox(_L("Windows Media Player is required for this task! Do you want to enable 'Windows Media Player' for your operation system?"), _L("Error"), wxOK | wxCANCEL);
|
||||
if (res == wxOK) {
|
||||
wxString url = IsWindows10OrGreater()
|
||||
? "ms-settings:optionalfeatures?activationSource=SMC-Article-14209"
|
||||
: "https://support.microsoft.com/en-au/windows/get-windows-media-player-81718e0d-cfce-25b1-aee3-94596b658287";
|
||||
wxExecute("cmd /c start " + url, wxEXEC_HIDE_CONSOLE);
|
||||
}
|
||||
});
|
||||
m_error = 2;
|
||||
wxMediaEvent event(wxEVT_MEDIA_STATECHANGED);
|
||||
event.SetId(GetId());
|
||||
|
@ -36,6 +45,23 @@ void wxMediaCtrl2::Load(wxURI url)
|
|||
wxPostEvent(this, event);
|
||||
return;
|
||||
}
|
||||
{
|
||||
wxRegKey key(wxRegKey::HKCR, "CLSID\\{233E64FB-2041-4A6C-AFAB-FF9BCF83E7AA}\\InProcServer32");
|
||||
wxString path = key.QueryDefaultValue();
|
||||
wxRegKey key2(wxRegKey::HKCR, "bambu");
|
||||
wxString clsid;
|
||||
key2.QueryRawValue("Source Filter", clsid);
|
||||
if (!wxFile::Exists(path) || clsid != L"{233E64FB-2041-4A6C-AFAB-FF9BCF83E7AA}") {
|
||||
wxMessageBox(_L("Missing BambuSource component registered for media playing! Please re-install BambuStutio or seek after-sales help."), _L("Error"),
|
||||
wxOK);
|
||||
m_error = 3;
|
||||
wxMediaEvent event(wxEVT_MEDIA_STATECHANGED);
|
||||
event.SetId(GetId());
|
||||
event.SetEventObject(this);
|
||||
wxPostEvent(this, event);
|
||||
return;
|
||||
}
|
||||
}
|
||||
url = wxURI(url.BuildURI().append("&hwnd=").append(
|
||||
boost::lexical_cast<std::string>(GetHandle())));
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue