Merge remote-tracking branch 'remote/master' into SoftFever

This commit is contained in:
SoftFever 2022-09-03 00:17:59 +08:00
commit 4fd174175c
298 changed files with 13879 additions and 6228 deletions

View file

@ -68,8 +68,8 @@ set(SLIC3R_GUI_SOURCES
GUI/Widgets/SideTools.hpp
GUI/Widgets/WebView.cpp
GUI/Widgets/WebView.hpp
GUI/Widgets/wxStaticText2.cpp
GUI/Widgets/wxStaticText2.hpp
GUI/Widgets/ErrorMsgStaticText.cpp
GUI/Widgets/ErrorMsgStaticText.hpp
GUI/AboutDialog.cpp
GUI/AboutDialog.hpp
GUI/NetworkTestDialog.cpp
@ -129,6 +129,8 @@ set(SLIC3R_GUI_SOURCES
GUI/Gizmos/GLGizmoFaceDetector.hpp
GUI/Gizmos/GLGizmoSeam.cpp
GUI/Gizmos/GLGizmoSeam.hpp
GUI/Gizmos/GLGizmoText.cpp
GUI/Gizmos/GLGizmoText.hpp
GUI/GLSelectionRectangle.cpp
GUI/GLSelectionRectangle.hpp
GUI/Gizmos/GizmoObjectManipulation.cpp

View file

@ -434,6 +434,7 @@ GLVolume::GLVolume(float r, float g, float b, float a)
, zoom_to_volumes(true)
, shader_outside_printer_detection_enabled(false)
, is_outside(false)
, partly_inside(false)
, hover(HS_None)
, is_modifier(false)
, is_wipe_tower(false)
@ -679,7 +680,7 @@ void GLVolume::render(bool with_outline) const
bool color_volume = false;
ModelObjectPtrs& model_objects = GUI::wxGetApp().model().objects;
do {
if (object_idx() >= model_objects.size())
if ((!printable) || object_idx() >= model_objects.size())
break;
ModelObject* mo = model_objects[object_idx()];
@ -907,7 +908,7 @@ void GLVolume::simple_render(GLShaderProgram* shader, ModelObjectPtrs& model_obj
ModelObject* model_object = nullptr;
ModelVolume* model_volume = nullptr;
do {
if (object_idx() >= model_objects.size())
if ((!printable) || object_idx() >= model_objects.size())
break;
model_object = model_objects[object_idx()];
@ -1290,9 +1291,16 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
//shader->set_uniform("print_volume.xy_data", m_render_volume.data);
//shader->set_uniform("print_volume.z_data", m_render_volume.zs);
/*shader->set_uniform("print_volume.type", static_cast<int>(m_print_volume.type));
shader->set_uniform("print_volume.xy_data", m_print_volume.data);
shader->set_uniform("print_volume.z_data", m_print_volume.zs);*/
if (volume.first->partly_inside) {
//only partly inside volume need to be painted with boundary check
shader->set_uniform("print_volume.type", static_cast<int>(m_print_volume.type));
shader->set_uniform("print_volume.xy_data", m_print_volume.data);
shader->set_uniform("print_volume.z_data", m_print_volume.zs);
}
else {
//use -1 ad a invalid type
shader->set_uniform("print_volume.type", -1);
}
shader->set_uniform("volume_world_matrix", volume.first->world_matrix());
shader->set_uniform("slope.actived", m_slope.active && !volume.first->is_modifier && !volume.first->is_wipe_tower);
shader->set_uniform("slope.volume_world_normal_matrix", static_cast<Matrix3f>(volume.first->world_matrix().matrix().block(0, 0, 3, 3).inverse().transpose().cast<float>()));
@ -1378,6 +1386,7 @@ bool GLVolumeCollection::check_outside_state(const BuildVolume &build_volume, Mo
const std::vector<BoundingBoxf3>& exclude_areas = curr_plate->get_exclude_areas();
for (GLVolume* volume : this->volumes)
{
if (! volume->is_modifier && (volume->shader_outside_printer_detection_enabled || (! volume->is_wipe_tower && volume->composite_id.volume_id >= 0))) {
BuildVolume::ObjectState state;
const BoundingBoxf3& bb = volume_bbox(*volume);
@ -1405,6 +1414,7 @@ bool GLVolumeCollection::check_outside_state(const BuildVolume &build_volume, Mo
int64_t comp_id = ((int64_t)volume->composite_id.object_id << 32) | ((int64_t)volume->composite_id.instance_id);
volume->is_outside = state != BuildVolume::ObjectState::Inside;
//volume->partly_inside = (state == BuildVolume::ObjectState::Colliding);
if (volume->printable) {
if (overall_state == ModelInstancePVS_Inside && volume->is_outside) {
overall_state = ModelInstancePVS_Fully_Outside;
@ -1448,6 +1458,23 @@ bool GLVolumeCollection::check_outside_state(const BuildVolume &build_volume, Mo
BOOST_LOG_TRIVIAL(debug) << "instance includes " << volume->name << " is partially outside of bed";
}
}
}
for (GLVolume* volume : this->volumes)
{
if (! volume->is_modifier && (volume->shader_outside_printer_detection_enabled || (! volume->is_wipe_tower && volume->composite_id.volume_id >= 0)))
{
int64_t comp_id = ((int64_t)volume->composite_id.object_id << 32) | ((int64_t)volume->composite_id.instance_id);
if (model_state.find(comp_id) != model_state.end())
{
if (model_state[comp_id] == ModelInstancePVS_Partly_Outside) {
volume->partly_inside = true;
}
else
volume->partly_inside = false;
}
}
}
if (out_state != nullptr)
*out_state = overall_state;
@ -1459,8 +1486,10 @@ void GLVolumeCollection::reset_outside_state()
{
for (GLVolume* volume : this->volumes)
{
if (volume != nullptr)
if (volume != nullptr) {
volume->is_outside = false;
volume->partly_inside = false;
}
}
}

View file

@ -371,6 +371,7 @@ public:
bool shader_outside_printer_detection_enabled : 1;
// Wheter or not this volume is outside print volume.
bool is_outside : 1;
bool partly_inside : 1;
// Wheter or not this volume has been generated from a modifier
bool is_modifier : 1;
// Wheter or not this volume has been generated from the wipe tower

View file

@ -188,10 +188,6 @@ void AMSSetting::create()
m_sizer_main->Fit(this);
this->Centre(wxBOTH);
// set mode
update_insert_material_read_mode(true);
update_starting_read_mode(false);
}
void AMSSetting::update_insert_material_read_mode(bool selected)

View file

@ -393,7 +393,7 @@ void AmsMapingPopup::add_ams_mapping(std::vector<TrayData> tray_data)
sizer_mapping_item->Add(number, 0, wxALIGN_CENTER_HORIZONTAL, 0);
sizer_mapping_item->Add(m_filament_name, 0, wxALIGN_CENTER_HORIZONTAL, 0);
sizer_mapping_list->Add(sizer_mapping_item, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, FromDIP(5));
sizer_mapping_list->Add(sizer_mapping_item, 0, wxALL, FromDIP(5));
m_amsmapping_sizer_list.push_back(sizer_mapping_list);
}
m_sizer_list->Add(sizer_mapping_list, 0, wxALIGN_CENTER_HORIZONTAL, 0);
@ -514,4 +514,101 @@ void MappingItem::doRender(wxDC &dc)
}
}
AmsMapingTipPopup::AmsMapingTipPopup(wxWindow *parent)
:wxPopupTransientWindow(parent, wxBORDER_NONE)
{
SetBackgroundColour(*wxWHITE);
wxBoxSizer *m_sizer_main = new wxBoxSizer(wxVERTICAL);
m_sizer_main->Add(0, 0, 1, wxTOP, FromDIP(28));
wxBoxSizer *m_sizer_body = new wxBoxSizer(wxHORIZONTAL);
m_sizer_body->Add(0, 0, 0, wxEXPAND | wxLEFT, FromDIP(20));
m_panel_enable_ams = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(200, -1), wxTAB_TRAVERSAL);
m_panel_enable_ams->SetBackgroundColour(*wxWHITE);
wxBoxSizer *sizer_enable_ams = new wxBoxSizer(wxVERTICAL);
m_title_enable_ams = new wxStaticText(m_panel_enable_ams, wxID_ANY, _L("Enable AMS"), wxDefaultPosition, wxDefaultSize, 0);
m_title_enable_ams->SetBackgroundColour(*wxWHITE);
m_title_enable_ams->Wrap(-1);
sizer_enable_ams->Add(m_title_enable_ams, 0, 0, 0);
m_tip_enable_ams = new wxStaticText(m_panel_enable_ams, wxID_ANY, _L("Print with filaments in the AMS"), wxDefaultPosition, wxDefaultSize, 0);
m_tip_enable_ams->SetBackgroundColour(*wxWHITE);
m_tip_enable_ams->Wrap(-1);
sizer_enable_ams->Add(m_tip_enable_ams, 0, wxTOP, 8);
wxBoxSizer *sizer_enable_ams_img;
sizer_enable_ams_img = new wxBoxSizer(wxVERTICAL);
auto img_enable_ams = new wxStaticBitmap(m_panel_enable_ams, wxID_ANY, create_scaled_bitmap("monitor_upgrade_ams", this, 108), wxDefaultPosition,
wxSize(FromDIP(118), FromDIP(108)), 0);
sizer_enable_ams_img->Add(img_enable_ams, 0, wxALIGN_CENTER_HORIZONTAL, 0);
sizer_enable_ams->Add(sizer_enable_ams_img, 1, wxEXPAND | wxTOP, FromDIP(20));
m_panel_enable_ams->SetSizer(sizer_enable_ams);
m_panel_enable_ams->Layout();
m_sizer_body->Add(m_panel_enable_ams, 0, 0, 0);
m_split_lines = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(1, FromDIP(150)), wxTAB_TRAVERSAL);
m_split_lines->SetBackgroundColour(wxColour(238, 238, 238));
m_sizer_body->Add(m_split_lines, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, FromDIP(10));
m_panel_disable_ams = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(200, -1), wxTAB_TRAVERSAL);
m_panel_disable_ams->SetBackgroundColour(*wxWHITE);
wxBoxSizer *sizer_disable_ams;
sizer_disable_ams = new wxBoxSizer(wxVERTICAL);
m_title_disable_ams = new wxStaticText(m_panel_disable_ams, wxID_ANY, _L("Disable AMS"), wxDefaultPosition, wxDefaultSize, 0);
m_title_disable_ams->SetBackgroundColour(*wxWHITE);
m_title_disable_ams->Wrap(-1);
sizer_disable_ams->Add(m_title_disable_ams, 0, 0, 0);
m_tip_disable_ams = new wxStaticText(m_panel_disable_ams, wxID_ANY, _L("Print with the filament mounted on the back of chassis"), wxDefaultPosition, wxDefaultSize, 0);
m_tip_disable_ams->SetBackgroundColour(*wxWHITE);
m_tip_disable_ams->Wrap(-1);
sizer_disable_ams->Add(m_tip_disable_ams, 0, wxTOP, FromDIP(8));
wxBoxSizer *sizer_disable_ams_img;
sizer_disable_ams_img = new wxBoxSizer(wxVERTICAL);
auto img_disable_ams = new wxStaticBitmap(m_panel_disable_ams, wxID_ANY, create_scaled_bitmap("disable_ams_demo_icon", this, 95), wxDefaultPosition,
wxSize(FromDIP(95), FromDIP(109)), 0);
sizer_disable_ams_img->Add(img_disable_ams, 0, wxALIGN_CENTER_HORIZONTAL, 0);
sizer_disable_ams->Add(sizer_disable_ams_img, 1, wxEXPAND | wxTOP, FromDIP(20));
m_panel_disable_ams->SetSizer(sizer_disable_ams);
m_panel_disable_ams->Layout();
m_sizer_body->Add(m_panel_disable_ams, 0, 0, 0);
m_sizer_body->Add(0, 0, 0, wxEXPAND | wxRIGHT, FromDIP(20));
m_sizer_main->Add(m_sizer_body, 0, wxEXPAND, 0);
m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(28));
this->SetSizer(m_sizer_main);
this->Layout();
this->Fit();
Bind(wxEVT_PAINT, &AmsMapingTipPopup::paintEvent, this);
}
void AmsMapingTipPopup::paintEvent(wxPaintEvent &evt)
{
wxPaintDC dc(this);
dc.SetPen(wxColour(0xAC, 0xAC, 0xAC));
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.DrawRoundedRectangle(0, 0, GetSize().x, GetSize().y, 0);
}
void AmsMapingTipPopup::OnDismiss() {}
bool AmsMapingTipPopup::ProcessLeftDown(wxMouseEvent &event) {
return wxPopupTransientWindow::ProcessLeftDown(event); }
}} // namespace Slic3r::GUI

View file

@ -137,6 +137,27 @@ public:
void paintEvent(wxPaintEvent &evt);
};
class AmsMapingTipPopup : public wxPopupTransientWindow
{
public:
AmsMapingTipPopup(wxWindow *parent);
~AmsMapingTipPopup(){};
void paintEvent(wxPaintEvent &evt);
virtual void OnDismiss() wxOVERRIDE;
virtual bool ProcessLeftDown(wxMouseEvent &event) wxOVERRIDE;
public:
wxPanel * m_panel_enable_ams;
wxStaticText * m_title_enable_ams;
wxStaticText * m_tip_enable_ams;
wxPanel * m_split_lines;
wxPanel * m_panel_disable_ams;
wxStaticText * m_title_disable_ams;
wxStaticText * m_tip_disable_ams;
};
wxDECLARE_EVENT(EVT_SET_FINISH_MAPPING, wxCommandEvent);
}} // namespace Slic3r::GUI

View file

@ -17,6 +17,8 @@
#include <wx/filedlg.h>
#include <wx/wupdlock.h>
#include <wx/dataview.h>
#include <wx/tokenzr.h>
#include <wx/arrstr.h>
#include <wx/tglbtn.h>
#include "wxExtensions.hpp"
@ -44,18 +46,17 @@ const std::vector<std::string> license_list = {
AuFile::AuFile(wxWindow *parent, fs::path file_path, wxString file_name, AuxiliaryFolderType type, wxWindowID id, const wxPoint &pos, const wxSize &size, long style)
{
wxPanel::Create(parent, id, pos, wxSize(FromDIP(300), FromDIP(340)), style);
SetBackgroundColour(AUFILE_GREY300);
wxBoxSizer *sizer_body = new wxBoxSizer(wxVERTICAL);
SetSize(wxSize(FromDIP(300), FromDIP(340)));
SetMinSize(wxSize(FromDIP(300), FromDIP(340)));
SetMaxSize(wxSize(FromDIP(300), FromDIP(340)));
m_type = type;
m_file_path = file_path;
m_file_name = file_name;
wxSize panel_size = m_type == MODEL_PICTURE ? AUFILE_PICTURES_PANEL_SIZE : AUFILE_PANEL_SIZE;
wxPanel::Create(parent, id, pos, panel_size, style);
SetBackgroundColour(AUFILE_GREY300);
wxBoxSizer *sizer_body = new wxBoxSizer(wxVERTICAL);
SetSize(panel_size);
if (m_type == MODEL_PICTURE) {
if (m_file_path.empty()) { return; }
auto image = new wxImage(encode_path(m_file_path.string().c_str()));
@ -64,19 +65,19 @@ AuFile::AuFile(wxWindow *parent, fs::path file_path, wxString file_name, Auxilia
auto size = wxSize(0, 0);
float proportion = float(image->GetSize().x) / float(image->GetSize().y);
if (proportion >= 1) {
size.x = FromDIP(300);
size.y = FromDIP(300) / proportion;
size.x = AUFILE_PICTURES_SIZE.x;
size.y = AUFILE_PICTURES_SIZE.x / proportion;
} else {
size.y = FromDIP(300);
size.x = FromDIP(300) * proportion;
size.y = AUFILE_PICTURES_SIZE.y;
size.x = AUFILE_PICTURES_SIZE.y * proportion;
}
image->Rescale(size.x, size.y);
m_file_bitmap = wxBitmap(*image);
m_file_bitmap.bmp() = wxBitmap(*image);
} else {
m_bitmap_excel = create_scaled_bitmap("placeholder_excel", nullptr, 300);
m_bitmap_pdf = create_scaled_bitmap("placeholder_pdf", nullptr, 300);
m_bitmap_txt = create_scaled_bitmap("placeholder_txt", nullptr, 300);
m_bitmap_excel = ScalableBitmap(this, "placeholder_excel", 168);
m_bitmap_pdf = ScalableBitmap(this, "placeholder_pdf", 168);
m_bitmap_txt = ScalableBitmap(this, "placeholder_txt", 168);
if (m_type == OTHERS) {m_file_bitmap = m_bitmap_txt;}
if (m_type == BILL_OF_MATERIALS) {
@ -90,6 +91,7 @@ AuFile::AuFile(wxWindow *parent, fs::path file_path, wxString file_name, Auxilia
if (m_type == ASSEMBLY_GUIDE) {m_file_bitmap = m_bitmap_pdf;}
}
m_add_file = _L("Add File");
cover_text_left = _L("Set as cover");
cover_text_right = _L("Rename");
cover_text_cover = _L("Cover");
@ -98,15 +100,15 @@ AuFile::AuFile(wxWindow *parent, fs::path file_path, wxString file_name, Auxilia
m_file_edit_mask = ScalableBitmap(this, "auxiliary_edit_mask", 43);
m_file_delete = ScalableBitmap(this, "auxiliary_delete", 28);
auto m_text_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(FromDIP(300), FromDIP(40)), wxTAB_TRAVERSAL);
auto m_text_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(panel_size.x, AUFILE_TEXT_HEIGHT), wxTAB_TRAVERSAL);
m_text_panel->SetBackgroundColour(AUFILE_GREY300);
wxBoxSizer *m_text_sizer = new wxBoxSizer(wxVERTICAL);
m_text_name = new wxStaticText(m_text_panel, wxID_ANY, m_file_name, wxDefaultPosition, wxSize(FromDIP(300), FromDIP(20)), 0);
m_text_name->Wrap(FromDIP(290));
m_text_name = new wxStaticText(m_text_panel, wxID_ANY, m_file_name, wxDefaultPosition, wxSize(panel_size.x, -1), wxST_ELLIPSIZE_END);
m_text_name->Wrap(panel_size.x - FromDIP(10));
m_text_name->SetFont(::Label::Body_14);
m_input_name = new ::TextInput(m_text_panel, wxEmptyString, wxEmptyString, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(300), FromDIP(35)), wxTE_PROCESS_ENTER);
m_input_name = new ::TextInput(m_text_panel, wxEmptyString, wxEmptyString, wxEmptyString, wxDefaultPosition, wxSize(panel_size.x, FromDIP(35)), wxTE_PROCESS_ENTER);
m_input_name->GetTextCtrl()->SetFont(::Label::Body_13);
m_input_name->SetFont(::Label::Body_14);
m_input_name->Hide();
@ -117,7 +119,7 @@ AuFile::AuFile(wxWindow *parent, fs::path file_path, wxString file_name, Auxilia
m_text_panel->SetSizer(m_text_sizer);
m_text_panel->Layout();
sizer_body->Add(0, 0, 0, wxTOP, FromDIP(300));
sizer_body->Add(0, 0, 0, wxTOP, panel_size.y - AUFILE_TEXT_HEIGHT);
sizer_body->Add(m_text_panel, 0, wxALIGN_CENTER, 0);
SetSizer(sizer_body);
@ -149,12 +151,26 @@ void AuFile::exit_rename_mode()
void AuFile::OnPaint(wxPaintEvent &event)
{
//wxPaintDC dc(this);
//render(dc);
wxBufferedPaintDC dc(this);
PrepareDC(dc);
wxPaintDC dc(this);
#ifdef __WXMSW__
wxSize size = GetSize();
wxMemoryDC memdc;
wxBitmap bmp(size.x, size.y);
memdc.SelectObject(bmp);
memdc.Blit({ 0, 0 }, size, &dc, { 0, 0 });
{
wxGCDC dc2(memdc);
PaintBackground(dc2);
PaintForeground(dc2);
}
memdc.SelectObject(wxNullBitmap);
dc.DrawBitmap(bmp, 0, 0);
#else
PaintBackground(dc);
PaintForeground(dc);
#endif
}
void AuFile::PaintBackground(wxDC &dc)
@ -169,21 +185,66 @@ void AuFile::PaintBackground(wxDC &dc)
dc.DrawRectangle(windowRect);
wxSize size = wxSize(FromDIP(300), FromDIP(300));
dc.SetPen(AUFILE_GREY200);
dc.SetBrush(AUFILE_GREY200);
dc.DrawRectangle(0,0,size.x,size.y);
dc.DrawBitmap(m_file_bitmap, (size.x - m_file_bitmap.GetSize().x) / 2, (size.y - m_file_bitmap.GetSize().y) / 2);
wxSize size = m_type == MODEL_PICTURE ? AUFILE_PICTURES_SIZE : AUFILE_SIZE;
if (m_type == AddFileButton)
{
auto pen_width = FromDIP(2);
dc.SetPen(wxPen(AUFILE_GREY500, pen_width));
dc.SetBrush(AUFILE_GREY200);
dc.DrawRoundedRectangle(pen_width / 2, pen_width / 2, size.x - pen_width / 2, size.y - pen_width / 2, AUFILE_ROUNDING);
auto line_length = FromDIP(50);
dc.DrawLine(wxPoint((size.x - line_length) / 2, size.y / 2), wxPoint((size.x + line_length) / 2, size.y / 2));
dc.DrawLine(wxPoint(size.x / 2, (size.y - line_length) / 2), wxPoint(size.x / 2, (size.y + line_length) / 2));
dc.SetFont(Label::Body_16);
auto sizet = dc.GetTextExtent(m_add_file);
auto pos = wxPoint(0, 0);
pos.x = (size.x - sizet.x) / 2;
pos.y = (size.y - 40); // to modify
dc.SetTextForeground(AUFILE_GREY500);
dc.DrawText(m_add_file, pos);
}
else {
dc.SetPen(AUFILE_GREY200);
dc.SetBrush(AUFILE_GREY200);
dc.DrawRoundedRectangle(0, 0, size.x, size.y, AUFILE_ROUNDING);
dc.DrawBitmap(m_file_bitmap.bmp(), (size.x - m_file_bitmap.GetBmpWidth()) / 2, (size.y - m_file_bitmap.GetBmpHeight()) / 2);
}
}
void AuFile::OnEraseBackground(wxEraseEvent &evt) {}
void AuFile::PaintForeground(wxDC &dc)
{
wxSize size = wxSize(FromDIP(300), FromDIP(300));
wxSize size = m_type == MODEL_PICTURE ? AUFILE_PICTURES_SIZE : AUFILE_SIZE;
if (m_hover) {
dc.DrawBitmap(m_file_edit_mask.bmp(), 0, size.y - m_file_edit_mask.GetBmpSize().y);
if (m_type == AddFileButton) {
auto pen_width = FromDIP(2);
dc.SetPen(wxPen(AUFILE_BRAND, pen_width));
dc.SetBrush(AUFILE_BRAND_TRANSPARENT);
dc.DrawRoundedRectangle(pen_width / 2, pen_width / 2, size.x - pen_width / 2, size.y - pen_width / 2, AUFILE_ROUNDING);
auto line_length = FromDIP(50);
dc.DrawLine(wxPoint((size.x - line_length) / 2, size.y / 2), wxPoint((size.x + line_length) / 2, size.y / 2));
dc.DrawLine(wxPoint(size.x / 2, (size.y - line_length) / 2), wxPoint(size.x / 2, (size.y + line_length) / 2));
auto sizet = dc.GetTextExtent(m_add_file);
auto pos = wxPoint(0, 0);
pos.x = (size.x - sizet.x) / 2;
pos.y = (size.y - 40); // to modify
dc.SetTextForeground(AUFILE_BRAND);
dc.DrawText(m_add_file, pos);
return;
}
if (m_type == MODEL_PICTURE) {
dc.DrawBitmap(m_file_edit_mask.bmp(), 0, size.y - m_file_edit_mask.GetBmpSize().y);
}
dc.SetFont(Label::Body_14);
dc.SetTextForeground(*wxWHITE);
if (m_type == MODEL_PICTURE) {
@ -210,11 +271,11 @@ void AuFile::PaintForeground(wxDC &dc)
dc.DrawRectangle(pos.x, pos.y, 2, FromDIP(30));
} else {
// right text
auto sizet = dc.GetTextExtent(cover_text_right);
/* auto sizet = dc.GetTextExtent(cover_text_right);
auto pos = wxPoint(0, 0);
pos.x = (size.x - sizet.x) / 2;
pos.y = (size.y - (m_file_edit_mask.GetBmpSize().y + sizet.y) / 2);
dc.DrawText(cover_text_right, pos);
pos.x = (size.x - sizet.x) / 2;
pos.y = (size.y - (m_file_edit_mask.GetBmpSize().y + sizet.y) / 2);
dc.DrawText(cover_text_right, pos);*/
}
}
@ -246,7 +307,7 @@ void AuFile::on_mouse_leave(wxMouseEvent &evt)
void AuFile::on_input_enter(wxCommandEvent &evt)
{
auto new_file_name = into_u8(m_input_name->GetTextCtrl()->GetValue());
auto new_file_name = m_input_name->GetTextCtrl()->GetValue();
auto m_valid_type = Valid;
wxString info_line;
@ -271,7 +332,7 @@ void AuFile::on_input_enter(wxCommandEvent &evt)
auto new_fullname = new_file_name + m_file_path.extension().string();
auto new_fullname_path = dir.string() + "/" + new_fullname;
wxString new_fullname_path = dir.wstring() + "/" + new_fullname;
fs::path new_dir_path(new_fullname_path.c_str());
@ -314,7 +375,7 @@ void AuFile::on_input_enter(wxCommandEvent &evt)
// post event
auto event = wxCommandEvent(EVT_AUXILIARY_UPDATE_RENAME);
event.SetString(wxString::Format("%s|%s|%s", s_default_folders[m_type], m_file_path.string(), new_dir_path.string()));
event.SetString(wxString::Format("%s|%s|%s", s_default_folders[m_type], m_file_path.wstring(), new_dir_path.wstring()));
event.SetEventObject(m_parent);
wxPostEvent(m_parent, event);
@ -328,12 +389,19 @@ void AuFile::on_input_enter(wxCommandEvent &evt)
void AuFile::on_dclick(wxMouseEvent &evt)
{
wxLaunchDefaultApplication(m_file_path.wstring(), 0);
if (m_type == AddFileButton)
return;
else
wxLaunchDefaultApplication(m_file_path.wstring(), 0);
}
void AuFile::on_mouse_left_up(wxMouseEvent &evt)
{
wxSize size = wxSize(FromDIP(300), FromDIP(300));
if (m_type == AddFileButton) {
return;
}
wxSize size = m_type == MODEL_PICTURE ? AUFILE_PICTURES_SIZE : AUFILE_SIZE;
auto pos = evt.GetPosition();
// set cover
@ -343,28 +411,36 @@ void AuFile::on_mouse_left_up(wxMouseEvent &evt)
auto cover_right = mask_size.x / 2;
auto cover_bottom = size.y;
if (pos.x > cover_left && pos.x < cover_right && pos.y > cover_top && pos.y < cover_bottom) { on_set_cover(); }
if (pos.x > cover_left && pos.x < cover_right && pos.y > cover_top && pos.y < cover_bottom) {
if(m_type == MODEL_PICTURE)
on_set_cover();
/* else
on_set_rename();*/
return;
}
// rename
auto rename_left = mask_size.x / 2;
auto rename_top = size.y - mask_size.y;
auto rename_right = mask_size.x;
auto rename_bottom = size.y;
if (pos.x > rename_left && pos.x < rename_right && pos.y > rename_top && pos.y < rename_bottom) { on_set_rename(); }
if (pos.x > rename_left && pos.x < rename_right && pos.y > rename_top && pos.y < rename_bottom) { on_set_rename(); return; }
// close
auto close_left = size.x - m_file_delete.GetBmpSize().x - FromDIP(15);
auto close_top = FromDIP(15);
auto close_right = size.x - FromDIP(15);
auto close_bottom = m_file_delete.GetBmpSize().y + FromDIP(15);
if (pos.x > close_left && pos.x < close_right && pos.y > close_top && pos.y < close_bottom) { on_set_delete(); }
if (pos.x > close_left && pos.x < close_right && pos.y > close_top && pos.y < close_bottom) { on_set_delete(); return; }
exit_rename_mode();
}
void AuFile::on_set_cover()
{
if (wxGetApp().plater()->model().model_info == nullptr) { wxGetApp().plater()->model().model_info = std::make_shared<ModelInfo>(); }
wxGetApp().plater()->model().model_info->cover_file = m_file_name.ToStdString();
wxGetApp().plater()->model().model_info->cover_file = std::string(m_file_name.ToUTF8().data());
auto full_path = m_file_path.branch_path();
auto full_root_path = full_path.branch_path();
@ -378,14 +454,15 @@ void AuFile::on_set_cover()
}
bool result = true;
wxImage thumbnail_img;;
wxImage thumbnail_img;
result = generate_image(m_file_path.string(), thumbnail_img, _3MF_COVER_SIZE);
if (result) {
auto cover_img_path = dir_path.string() + "/thumbnail_3mf.png";
thumbnail_img.SaveFile(encode_path(cover_img_path.c_str()));
}
result = generate_image(m_file_path.string(), thumbnail_img, PRINTER_THUMBNAIL_SMALL_SIZE, GERNERATE_IMAGE_CROP_VERTICAL);
result = generate_image(m_file_path.string(), thumbnail_img, PRINTER_THUMBNAIL_SMALL_SIZE);
if (result) {
auto small_img_path = dir_path.string() + "/thumbnail_small.png";
thumbnail_img.SaveFile(encode_path(small_img_path.c_str()));
@ -429,7 +506,7 @@ void AuFile::on_set_delete()
if (is_fine) {
auto evt = wxCommandEvent(EVT_AUXILIARY_UPDATE_DELETE);
evt.SetString(wxString::Format("%s|%s", s_default_folders[m_type], m_file_path.string()));
evt.SetString(wxString::Format("%s|%s", s_default_folders[m_type], m_file_path.wstring()));
evt.SetEventObject(m_parent);
wxPostEvent(m_parent, evt);
}
@ -468,11 +545,11 @@ void AuFile::msw_rescale()
}
image->Rescale(size.x, size.y);
m_file_bitmap = wxBitmap(*image);
m_file_bitmap.bmp() = wxBitmap(*image);
} else {
m_bitmap_excel = create_scaled_bitmap("placeholder_excel", nullptr, 300);
m_bitmap_pdf = create_scaled_bitmap("placeholder_pdf", nullptr, 300);
m_bitmap_txt = create_scaled_bitmap("placeholder_txt", nullptr, 300);
m_bitmap_excel = ScalableBitmap(this, "placeholder_excel", 168);
m_bitmap_pdf = ScalableBitmap(this, "placeholder_pdf", 168);
m_bitmap_txt = ScalableBitmap(this, "placeholder_txt", 168);
if (m_type == OTHERS) { m_file_bitmap = m_bitmap_txt; }
if (m_type == BILL_OF_MATERIALS) { m_file_bitmap = m_bitmap_excel; }
@ -504,7 +581,8 @@ AuFolderPanel::AuFolderPanel(wxWindow *parent, AuxiliaryFolderType type, wxWindo
m_button_add->SetMinSize(wxSize(-1, FromDIP(24)));
m_button_add->SetCornerRadius(FromDIP(12));
m_button_add->SetFont(Label::Body_14);
// m_button_add->Bind(wxEVT_LEFT_UP, &AuxiliaryPanel::on_add, this);
m_big_button_add = new AuFile(m_scrolledWindow, fs::path(), "", AddFileButton, -1);
/*m_button_del = new Button(m_scrolledWindow, _L("Delete"), "auxiliary_delete_file", 12, 12);
m_button_del->SetBackgroundColor(btn_bg_white);
@ -515,12 +593,18 @@ AuFolderPanel::AuFolderPanel(wxWindow *parent, AuxiliaryFolderType type, wxWindo
// m_button_del->Bind(wxEVT_LEFT_UP, &AuxiliaryPanel::on_delete, this);
sizer_top->Add(0, 0, 0, wxLEFT, FromDIP(10));
sizer_top->Add(m_button_add, 0, wxALL, 0);
m_gsizer_content = new wxWrapSizer(wxHORIZONTAL, wxWRAPSIZER_DEFAULT_FLAGS);
if (m_type == MODEL_PICTURE) {
sizer_top->Add(m_button_add, 0, wxALL, 0);
m_big_button_add->Hide();
}
else {
m_gsizer_content->Add(m_big_button_add, 0, wxALL, FromDIP(8));
m_button_add->Hide();
}
// sizer_top->Add(m_button_del, 0, wxALL, 0);
m_gsizer_content = new wxGridSizer(0, 3, FromDIP(18), FromDIP(18));
sizer_body->Add(sizer_top, 0, wxEXPAND | wxTOP, FromDIP(35));
sizer_body->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(30));
sizer_body->AddSpacer(FromDIP(14));
sizer_body->Add(m_gsizer_content, 0, 0, 0);
m_scrolledWindow->SetSizer(sizer_body);
m_scrolledWindow->Layout();
@ -529,18 +613,25 @@ AuFolderPanel::AuFolderPanel(wxWindow *parent, AuxiliaryFolderType type, wxWindo
this->SetSizer(sizer_main);
this->Layout();
m_button_add->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(AuFolderPanel::on_add), NULL, this);
// m_button_del->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(AuFolderPanel::on_delete), NULL, this);
m_big_button_add->Bind(wxEVT_LEFT_DOWN, [this](auto& e)
{
auto evt = wxCommandEvent(EVT_AUXILIARY_IMPORT);
evt.SetString(s_default_folders[m_type]);
evt.SetEventObject(m_parent);
wxPostEvent(m_parent, evt);
});
m_button_add->Bind(wxEVT_BUTTON, &AuFolderPanel::on_add, this);
}
void AuFolderPanel::clear()
{
for (auto i = 0; i < m_aufiles_list.GetCount(); i++) {
AuFiles *aufile = m_aufiles_list[i];
if (aufile->file != NULL) { aufile->file->Destroy(); }
if (aufile->file) { aufile->file->Destroy(); }
}
m_aufiles_list.clear();
m_gsizer_content->Layout();
Layout();
Refresh();
}
void AuFolderPanel::update(std::vector<fs::path> paths)
@ -551,7 +642,7 @@ void AuFolderPanel::update(std::vector<fs::path> paths)
auto name = encode_path(temp_name.c_str());
auto aufile = new AuFile(m_scrolledWindow, paths[i], name, m_type, wxID_ANY);
m_gsizer_content->Add(aufile, 0, 0, 0);
m_gsizer_content->Add(aufile, 0, wxALL, FromDIP(8));
auto af = new AuFiles;
af->path = paths[i].string();
af->file = aufile;
@ -570,7 +661,7 @@ void AuFolderPanel::msw_rescale()
}
}
void AuFolderPanel::on_add(wxCommandEvent &event)
void AuFolderPanel::on_add(wxCommandEvent& event)
{
auto evt = wxCommandEvent(EVT_AUXILIARY_IMPORT);
evt.SetString(s_default_folders[m_type]);
@ -582,8 +673,6 @@ void AuFolderPanel::on_delete(wxCommandEvent &event) { clear(); }
AuFolderPanel::~AuFolderPanel()
{
m_button_add->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(AuFolderPanel::on_add), NULL, this);
// m_button_del->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(AuFolderPanel::on_delete), NULL, this);
}
void AuFolderPanel::update_cover()
@ -617,22 +706,29 @@ AuxiliaryPanel::AuxiliaryPanel(wxWindow *parent, wxWindowID id, const wxPoint &p
// delete event
Bind(EVT_AUXILIARY_UPDATE_DELETE, [this](wxCommandEvent &e) {
auto info_str = e.GetString();
auto parems = std::vector<std::string>{};
Split(info_str.ToStdString(), "|", parems);
wxArrayString parems;
wxStringTokenizer tokenizer(info_str, "|");
while (tokenizer.HasMoreTokens()) {
wxString token = tokenizer.GetNextToken();
parems.Add(token);
}
auto model = parems[0];
auto name = parems[1];
auto iter = m_paths_list.find(model);
auto iter = m_paths_list.find(model.ToStdString());
if (iter != m_paths_list.end()) {
auto list = iter->second;
for (auto i = 0; i < list.size(); i++) {
if (list[i] == name) {
if (list[i].wstring() == name) {
list.erase(std::begin(list) + i);
break;
}
}
m_paths_list[model] = list;
m_paths_list[model.ToStdString()] = list;
update_all_panel();
update_all_cover();
}
@ -642,24 +738,28 @@ AuxiliaryPanel::AuxiliaryPanel(wxWindow *parent, wxWindowID id, const wxPoint &p
Bind(EVT_AUXILIARY_UPDATE_RENAME, [this](wxCommandEvent &e) {
auto info_str = e.GetString();
auto parems = std::vector<std::string>{};
Split(info_str.ToStdString(), "|", parems);
wxArrayString parems;
wxStringTokenizer tokenizer(info_str, "|");
while (tokenizer.HasMoreTokens()) {
wxString token = tokenizer.GetNextToken();
parems.Add(token);
}
auto model = parems[0];
auto old_name = parems[1];
auto new_name = parems[2];
auto iter = m_paths_list.find(model);
auto iter = m_paths_list.find(model.ToStdString());
if (iter != m_paths_list.end()) {
auto list = iter->second;
for (auto i = 0; i < list.size(); i++) {
if (list[i] == old_name) {
list[i] = new_name;
if (list[i].wstring() == old_name) {
list[i] = fs::path(new_name.c_str());
break;
}
}
m_paths_list[model] = list;
m_paths_list[model.ToStdString()] = list;
}
});
}
@ -943,6 +1043,7 @@ void AuxiliaryPanel::update_all_panel()
{
std::map<std::string, std::vector<fs::path>>::iterator mit;
Freeze();
m_pictures_panel->clear();
m_bill_of_materials_panel->clear();
m_assembly_panel->clear();
@ -954,6 +1055,7 @@ void AuxiliaryPanel::update_all_panel()
if (mit->first == "Assembly Guide") { m_assembly_panel->update(mit->second); }
if (mit->first == "Others") { m_others_panel->update(mit->second); }
}
Thaw();
}
void AuxiliaryPanel::update_all_cover()
@ -977,7 +1079,7 @@ void AuxiliaryPanel::update_all_cover()
wxBoxSizer *m_sizer_body = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *m_sizer_designer = new wxBoxSizer(wxHORIZONTAL);
auto m_text_designer = new wxStaticText(this, wxID_ANY, _L("Designer"), wxDefaultPosition, wxSize(120, -1), 0);
auto m_text_designer = new wxStaticText(this, wxID_ANY, _L("Author"), wxDefaultPosition, wxSize(120, -1), 0);
m_text_designer->Wrap(-1);
m_sizer_designer->Add(m_text_designer, 0, wxALIGN_CENTER, 0);

View file

@ -48,8 +48,17 @@
#include "Widgets/SideTools.hpp"
#define AUFILE_GREY700 wxColour(107, 107, 107)
#define AUFILE_GREY500 wxColour(158, 158, 158)
#define AUFILE_GREY300 wxColour(238, 238, 238)
#define AUFILE_GREY200 wxColour(248, 248, 248)
#define AUFILE_BRAND wxColour(0, 174, 66)
#define AUFILE_BRAND_TRANSPARENT wxColour(215, 232, 222)
#define AUFILE_PICTURES_SIZE wxSize(FromDIP(300), FromDIP(300))
#define AUFILE_PICTURES_PANEL_SIZE wxSize(FromDIP(300), FromDIP(340))
#define AUFILE_SIZE wxSize(FromDIP(168), FromDIP(168))
#define AUFILE_PANEL_SIZE wxSize(FromDIP(168), FromDIP(208))
#define AUFILE_TEXT_HEIGHT FromDIP(40)
#define AUFILE_ROUNDING FromDIP(5)
enum AuxiliaryFolderType {
MODEL_PICTURE,
@ -58,6 +67,7 @@ enum AuxiliaryFolderType {
OTHERS,
THUMBNAILS,
DESIGNER,
AddFileButton,
};
const static std::array<wxString, 5> s_default_folders = {("Model Pictures"), ("Bill of Materials"), ("Assembly Guide"), ("Others"), (".thumbnails")};
@ -76,18 +86,19 @@ public:
wxStaticText* m_text_name {nullptr};
::TextInput* m_input_name {nullptr};
fs::path m_file_path;
wxString m_add_file;
wxString m_file_name;
wxString cover_text_left;
wxString cover_text_right;
wxString cover_text_cover;
wxBitmap m_file_bitmap;
ScalableBitmap m_file_bitmap;
ScalableBitmap m_file_cover;
ScalableBitmap m_file_edit_mask;
ScalableBitmap m_file_delete;
wxBitmap m_bitmap_excel;
wxBitmap m_bitmap_pdf;
wxBitmap m_bitmap_txt;
ScalableBitmap m_bitmap_excel;
ScalableBitmap m_bitmap_pdf;
ScalableBitmap m_bitmap_txt;
public:
AuFile(wxWindow *parent, fs::path file_path, wxString file_name, AuxiliaryFolderType type, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, long style = wxTAB_TRAVERSAL);
@ -144,12 +155,13 @@ public:
public:
AuxiliaryFolderType m_type;
wxScrolledWindow * m_scrolledWindow{nullptr};
wxGridSizer * m_gsizer_content{nullptr};
wxWrapSizer * m_gsizer_content{nullptr};
Button * m_button_add{nullptr};
Button * m_button_del{nullptr};
AuFile * m_big_button_add{ nullptr };
AuFilesHash m_aufiles_list;
void on_add(wxCommandEvent &event);
void on_add(wxCommandEvent& event);
void on_delete(wxCommandEvent &event);
};

View file

@ -93,7 +93,7 @@ void BBLStatusBarSend::set_progress(int val)
return;
//add the logic for arrange/orient jobs, which don't call stop_busy
if (!m_sizer->IsShown(m_prog)) {
if (!m_prog->IsShown()) {
m_sizer->Show(m_prog);
m_sizer->Show(m_cancelbutton);
}

View file

@ -15,7 +15,7 @@
namespace Slic3r {
namespace GUI {
BindMachineDilaog::BindMachineDilaog(Plater *plater /*= nullptr*/)
BindMachineDialog::BindMachineDialog(Plater *plater /*= nullptr*/)
: DPIDialog(static_cast<wxWindow *>(wxGetApp().mainframe), wxID_ANY, _L("Log in printer"), wxDefaultPosition, wxDefaultSize, wxCAPTION)
{
std::string icon_path = (boost::format("%1%/images/BambuStudioTitle.ico") % resources_dir()).str();
@ -92,12 +92,12 @@ namespace GUI {
m_avatar = new wxStaticBitmap(m_panel_right, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(FromDIP(60), FromDIP(60)), 0);
wxWebRequest request = wxWebSession::GetDefault().CreateRequest(this, wxGetApp().getAgent()->get_user_avatar());
if (!request.IsOk()) {
web_request = wxWebSession::GetDefault().CreateRequest(this, wxGetApp().getAgent()->get_user_avatar());
if (!web_request.IsOk()) {
// todo request fail
}
// Start the request
request.Start();
web_request.Start();
}
m_sizer_right_v->Add(m_avatar, 0, wxALIGN_CENTER, 0);
@ -172,23 +172,25 @@ namespace GUI {
Fit();
Centre(wxBOTH);
Bind(wxEVT_SHOW, &BindMachineDilaog::on_show, this);
Bind(wxEVT_SHOW, &BindMachineDialog::on_show, this);
m_button_bind->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(BindMachineDilaog::on_bind_printer), NULL, this);
m_button_cancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(BindMachineDilaog::on_cancel), NULL, this);
this->Connect(EVT_BIND_MACHINE_FAIL, wxCommandEventHandler(BindMachineDilaog::on_bind_fail), NULL, this);
this->Connect(EVT_BIND_MACHINE_SUCCESS, wxCommandEventHandler(BindMachineDilaog::on_bind_success), NULL, this);
this->Connect(EVT_BIND_UPDATE_MESSAGE, wxCommandEventHandler(BindMachineDilaog::on_update_message), NULL, this);
Bind(wxEVT_CLOSE_WINDOW, &BindMachineDialog::on_close, this);
m_button_bind->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(BindMachineDialog::on_bind_printer), NULL, this);
m_button_cancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(BindMachineDialog::on_cancel), NULL, this);
this->Connect(EVT_BIND_MACHINE_FAIL, wxCommandEventHandler(BindMachineDialog::on_bind_fail), NULL, this);
this->Connect(EVT_BIND_MACHINE_SUCCESS, wxCommandEventHandler(BindMachineDialog::on_bind_success), NULL, this);
this->Connect(EVT_BIND_UPDATE_MESSAGE, wxCommandEventHandler(BindMachineDialog::on_update_message), NULL, this);
m_simplebook->SetSelection(1);
}
BindMachineDilaog::~BindMachineDilaog()
BindMachineDialog::~BindMachineDialog()
{
m_button_bind->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(BindMachineDilaog::on_bind_printer), NULL, this);
m_button_cancel->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(BindMachineDilaog::on_cancel), NULL, this);
this->Disconnect(EVT_BIND_MACHINE_FAIL, wxCommandEventHandler(BindMachineDilaog::on_bind_fail), NULL, this);
this->Disconnect(EVT_BIND_MACHINE_SUCCESS, wxCommandEventHandler(BindMachineDilaog::on_bind_success), NULL, this);
this->Disconnect(EVT_BIND_UPDATE_MESSAGE, wxCommandEventHandler(BindMachineDilaog::on_update_message), NULL, this);
m_button_bind->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(BindMachineDialog::on_bind_printer), NULL, this);
m_button_cancel->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(BindMachineDialog::on_cancel), NULL, this);
this->Disconnect(EVT_BIND_MACHINE_FAIL, wxCommandEventHandler(BindMachineDialog::on_bind_fail), NULL, this);
this->Disconnect(EVT_BIND_MACHINE_SUCCESS, wxCommandEventHandler(BindMachineDialog::on_bind_success), NULL, this);
this->Disconnect(EVT_BIND_UPDATE_MESSAGE, wxCommandEventHandler(BindMachineDialog::on_update_message), NULL, this);
}
//static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
@ -205,30 +207,49 @@ namespace GUI {
//}
void BindMachineDilaog::on_cancel(wxCommandEvent &event)
void BindMachineDialog::on_cancel(wxCommandEvent &event)
{
EndModal(wxID_CANCEL);
on_destroy();
EndModal(wxID_CANCEL);
}
void BindMachineDilaog::on_bind_fail(wxCommandEvent &event)
void BindMachineDialog::on_destroy()
{
if (m_bind_job) {
m_bind_job->cancel();
m_bind_job->join();
}
if (web_request.IsOk()) {
web_request.Cancel();
}
}
void BindMachineDialog::on_close(wxCloseEvent &event)
{
on_destroy();
event.Skip();
}
void BindMachineDialog::on_bind_fail(wxCommandEvent &event)
{
//m_status_text->SetLabel(_L("Would you like to log in this printer with current account?"));
m_simplebook->SetSelection(1);
}
void BindMachineDilaog::on_update_message(wxCommandEvent &event)
void BindMachineDialog::on_update_message(wxCommandEvent &event)
{
m_status_text->SetLabelText(event.GetString());
}
void BindMachineDilaog::on_bind_success(wxCommandEvent &event)
void BindMachineDialog::on_bind_success(wxCommandEvent &event)
{
EndModal(wxID_OK);
MessageDialog msg_wingow(nullptr, _L("Log in successful."), "", wxAPPLY | wxOK);
if (msg_wingow.ShowModal() == wxOK) { return; }
}
void BindMachineDilaog::on_bind_printer(wxCommandEvent &event)
void BindMachineDialog::on_bind_printer(wxCommandEvent &event)
{
//check isset info
if (m_machine_info == nullptr || m_machine_info == NULL) return;
@ -242,13 +263,13 @@ namespace GUI {
m_bind_job->start();
}
void BindMachineDilaog::on_dpi_changed(const wxRect &suggested_rect)
void BindMachineDialog::on_dpi_changed(const wxRect &suggested_rect)
{
m_button_bind->SetMinSize(BIND_DIALOG_BUTTON_SIZE);
m_button_cancel->SetMinSize(BIND_DIALOG_BUTTON_SIZE);
}
void BindMachineDilaog::on_show(wxShowEvent &event)
void BindMachineDialog::on_show(wxShowEvent &event)
{
//m_printer_name->SetLabelText(m_machine_info->get_printer_type_string());
m_printer_name->SetLabelText(from_u8(m_machine_info->dev_name));
@ -256,7 +277,7 @@ void BindMachineDilaog::on_show(wxShowEvent &event)
}
UnBindMachineDilaog::UnBindMachineDilaog(Plater *plater /*= nullptr*/)
UnBindMachineDialog::UnBindMachineDialog(Plater *plater /*= nullptr*/)
: DPIDialog(static_cast<wxWindow *>(wxGetApp().mainframe), wxID_ANY, _L("Log out printer"), wxDefaultPosition, wxDefaultSize, wxCAPTION)
{
std::string icon_path = (boost::format("%1%/images/BambuStudioTitle.ico") % resources_dir()).str();
@ -402,24 +423,24 @@ UnBindMachineDilaog::UnBindMachineDilaog(Plater *plater /*= nullptr*/)
Fit();
Centre(wxBOTH);
Bind(wxEVT_SHOW, &UnBindMachineDilaog::on_show, this);
m_button_unbind->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(UnBindMachineDilaog::on_unbind_printer), NULL, this);
m_button_cancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(UnBindMachineDilaog::on_cancel), NULL, this);
Bind(wxEVT_SHOW, &UnBindMachineDialog::on_show, this);
m_button_unbind->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(UnBindMachineDialog::on_unbind_printer), NULL, this);
m_button_cancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(UnBindMachineDialog::on_cancel), NULL, this);
}
UnBindMachineDilaog::~UnBindMachineDilaog()
UnBindMachineDialog::~UnBindMachineDialog()
{
m_button_unbind->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(UnBindMachineDilaog::on_unbind_printer), NULL, this);
m_button_cancel->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(UnBindMachineDilaog::on_cancel), NULL, this);
m_button_unbind->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(UnBindMachineDialog::on_unbind_printer), NULL, this);
m_button_cancel->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(UnBindMachineDialog::on_cancel), NULL, this);
}
void UnBindMachineDilaog::on_cancel(wxCommandEvent &event)
void UnBindMachineDialog::on_cancel(wxCommandEvent &event)
{
EndModal(wxID_CANCEL);
}
void UnBindMachineDilaog::on_unbind_printer(wxCommandEvent &event)
void UnBindMachineDialog::on_unbind_printer(wxCommandEvent &event)
{
if (!wxGetApp().is_user_login()) {
m_status_text->SetLabelText(_L("Please log in first."));
@ -455,13 +476,13 @@ void UnBindMachineDilaog::on_unbind_printer(wxCommandEvent &event)
}
}
void UnBindMachineDilaog::on_dpi_changed(const wxRect &suggested_rect)
void UnBindMachineDialog::on_dpi_changed(const wxRect &suggested_rect)
{
m_button_unbind->SetMinSize(BIND_DIALOG_BUTTON_SIZE);
m_button_cancel->SetMinSize(BIND_DIALOG_BUTTON_SIZE);
}
void UnBindMachineDilaog::on_show(wxShowEvent &event)
void UnBindMachineDialog::on_show(wxShowEvent &event)
{
//m_printer_name->SetLabelText(m_machine_info->get_printer_type_string());
m_printer_name->SetLabelText(from_u8(m_machine_info->dev_name));

View file

@ -16,6 +16,7 @@
#include <wx/icon.h>
#include <wx/dialog.h>
#include <curl/curl.h>
#include <wx/webrequest.h>
#include "wxExtensions.hpp"
#include "Plater.hpp"
#include "Widgets/StepCtrl.hpp"
@ -42,7 +43,7 @@ struct MemoryStruct
size_t size;
};
class BindMachineDilaog : public DPIDialog
class BindMachineDialog : public DPIDialog
{
private:
wxStaticText * m_printer_name;
@ -54,14 +55,15 @@ private:
Button * m_button_cancel;
wxSimplebook *m_simplebook;
wxStaticBitmap *m_avatar;
wxWebRequest web_request;
MachineObject * m_machine_info{nullptr};
std::shared_ptr<BindJob> m_bind_job;
std::shared_ptr<BBLStatusBarBind> m_status_bar;
public:
BindMachineDilaog(Plater *plater = nullptr);
~BindMachineDilaog();
BindMachineDialog(Plater *plater = nullptr);
~BindMachineDialog();
void on_cancel(wxCommandEvent &event);
void on_bind_fail(wxCommandEvent &event);
void on_update_message(wxCommandEvent &event);
@ -70,9 +72,11 @@ public:
void on_dpi_changed(const wxRect &suggested_rect) override;
void update_machine_info(MachineObject *info) { m_machine_info = info; };
void on_show(wxShowEvent &event);
void on_close(wxCloseEvent& event);
void on_destroy();
};
class UnBindMachineDilaog : public DPIDialog
class UnBindMachineDialog : public DPIDialog
{
protected:
wxStaticText * m_printer_name;
@ -84,8 +88,8 @@ protected:
wxStaticBitmap *m_avatar;
public:
UnBindMachineDilaog(Plater *plater = nullptr);
~UnBindMachineDilaog();
UnBindMachineDialog(Plater *plater = nullptr);
~UnBindMachineDialog();
void on_cancel(wxCommandEvent &event);
void on_unbind_printer(wxCommandEvent &event);

View file

@ -93,6 +93,9 @@ void Camera::select_view(const std::string& direction)
look_at(m_target + m_distance * Vec3d::UnitY(), m_target, Vec3d::UnitZ());
else if (direction == "topfront")
look_at(m_target - 0.707 * m_distance * Vec3d::UnitY() + 0.707 * m_distance * Vec3d::UnitZ(), m_target, Vec3d::UnitY() + Vec3d::UnitZ());
else if (direction == "plate") {
look_at(m_target - 0.707 * m_distance * Vec3d::UnitY() + 0.707 * m_distance * Vec3d::UnitZ(), m_target, Vec3d::UnitY() + Vec3d::UnitZ());
}
}
double Camera::get_fov() const

View file

@ -11,7 +11,6 @@
#include "MsgDialog.hpp"
#include "Plater.hpp"
#include "GUI_App.hpp"
#include "nlohmann/json.hpp"
#include <thread>
#include <mutex>
#include <codecvt>
@ -21,7 +20,6 @@
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
using namespace nlohmann;
namespace pt = boost::property_tree;
@ -259,63 +257,34 @@ wxString HMSItem::get_hms_msg_level_str(HMSMessageLevel level)
return "";
}
PRINTER_TYPE MachineObject::parse_printer_type(std::string type_str)
std::string MachineObject::parse_printer_type(std::string type_str)
{
if (type_str.compare("3DPrinter-P1") == 0) {
return PRINTER_TYPE::PRINTER_3DPrinter_P1;
} else if (type_str.compare("3DPrinter-X1") == 0) {
return PRINTER_TYPE::PRINTER_3DPrinter_X1;
if (type_str.compare("3DPrinter-X1") == 0) {
return "BL-P002";
} else if (type_str.compare("3DPrinter-X1-Carbon") == 0) {
return PRINTER_TYPE::PRINTER_3DPrinter_X1_Carbon;
}
BOOST_LOG_TRIVIAL(trace) << "unknown printer type: " << type_str;
return PRINTER_TYPE::PRINTER_3DPrinter_UKNOWN;
}
PRINTER_TYPE MachineObject::parse_iot_printer_type(std::string type_str)
{
if (type_str.compare("BL-P003") == 0) {
return PRINTER_TYPE::PRINTER_3DPrinter_P1;
} else if (type_str.compare("BL-P002") == 0) {
return PRINTER_TYPE::PRINTER_3DPrinter_X1;
return "BL-P001";
} else if (type_str.compare("BL-P001") == 0) {
return PRINTER_TYPE::PRINTER_3DPrinter_X1_Carbon;
}
BOOST_LOG_TRIVIAL(trace) << "unknown printer type: " << type_str;
return PRINTER_TYPE::PRINTER_3DPrinter_UKNOWN;
}
PRINTER_TYPE MachineObject::parse_preset_printer_type(std::string type_str)
{
return parse_iot_printer_type(type_str);
}
std::string MachineObject::get_preset_printer_model_name(PRINTER_TYPE printer_type)
{
if (printer_type == PRINTER_TYPE::PRINTER_3DPrinter_P1) {
return "Bambu Lab P1";
} else if (printer_type == PRINTER_TYPE::PRINTER_3DPrinter_X1) {
return "Bambu Lab X1";
} else if (printer_type == PRINTER_TYPE::PRINTER_3DPrinter_X1_Carbon) {
return "Bambu Lab X1 Carbon";
return type_str;
} else if (type_str.compare("BL-P003") == 0) {
return type_str;
} else {
return "";
return DeviceManager::parse_printer_type(type_str);
}
return "";
}
std::string MachineObject::get_preset_printer_model_name(std::string printer_type)
{
return DeviceManager::get_printer_display_name(printer_type);
}
wxString MachineObject::get_printer_type_display_str()
{
if (printer_type == PRINTER_TYPE::PRINTER_3DPrinter_P1)
return "Bambu Lab P1";
else if (printer_type == PRINTER_TYPE::PRINTER_3DPrinter_X1)
return "Bambu Lab X1";
else if (printer_type == PRINTER_TYPE::PRINTER_3DPrinter_X1_Carbon)
return "Bambu Lab X1 Carbon";
return _L("Unknown");
std::string display_name = get_preset_printer_model_name(printer_type);
if (!display_name.empty())
return display_name;
else
return _L("Unknown");
}
void MachineObject::set_access_code(std::string code)
@ -335,17 +304,6 @@ bool MachineObject::is_lan_mode_printer()
return result;
}
std::string MachineObject::get_printer_type_string()
{
if (printer_type == PRINTER_TYPE::PRINTER_3DPrinter_P1)
return "3DPrinter-P1";
else if (printer_type == PRINTER_TYPE::PRINTER_3DPrinter_X1)
return "3DPrinter-X1";
else if (printer_type == PRINTER_TYPE::PRINTER_3DPrinter_X1_Carbon)
return "3DPrinter-X1-Carbon";
return "3DPrinter";
}
MachineObject::MachineObject(NetworkAgent* agent, std::string name, std::string id, std::string ip)
:dev_name(name),
dev_id(id),
@ -370,7 +328,11 @@ MachineObject::MachineObject(NetworkAgent* agent, std::string name, std::string
ams_exist_bits = 0;
tray_exist_bits = 0;
tray_is_bbl_bits = 0;
ams_rfid_status = 0;
is_ams_need_update = false;
ams_insert_flag = false;
ams_power_on_flag = false;
ams_support_use_ams = false;
/* signals */
wifi_signal = "";
@ -1454,22 +1416,39 @@ int MachineObject::command_axis_control(std::string axis, double unit, double va
int MachineObject::command_start_calibration()
{
// fixed gcode file
json j;
j["print"]["command"] = "gcode_file";
j["print"]["param"] = "/usr/etc/print/auto_cali_for_user.gcode";
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
return this->publish_json(j.dump());
if (printer_type == "BL-P001"
|| printer_type == "BL-P002") {
// fixed gcode file
json j;
j["print"]["command"] = "gcode_file";
j["print"]["param"] = "/usr/etc/print/auto_cali_for_user.gcode";
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
return this->publish_json(j.dump());
} else {
json j;
j["print"]["command"] = "calibration";
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
return this->publish_json(j.dump());
}
}
int MachineObject::command_unload_filament()
{
// fixed gcode file
json j;
j["print"]["command"] = "gcode_file";
j["print"]["param"] = "/usr/etc/print/filament_unload.gcode";
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
return this->publish_json(j.dump());
if (printer_type == "BL-P001"
|| printer_type == "BL-P002") {
// fixed gcode file
json j;
j["print"]["command"] = "gcode_file";
j["print"]["param"] = "/usr/etc/print/filament_unload.gcode";
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
return this->publish_json(j.dump());
}
else {
json j;
j["print"]["command"] = "unload_filament";
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
return this->publish_json(j.dump());
}
}
@ -1617,6 +1596,7 @@ void MachineObject::reset()
iot_print_status = "";
print_status = "";
last_mc_print_stage = -1;
m_new_ver_list_exist = false;
subtask_ = nullptr;
@ -1694,6 +1674,40 @@ bool MachineObject::is_info_ready()
return false;
}
bool MachineObject::is_function_supported(PrinterFunction func)
{
std::string func_name;
switch (func) {
case FUNC_MONITORING:
func_name = "FUNC_MONITORING";
break;
case FUNC_TIMELAPSE:
func_name = "FUNC_TIMELAPSE";
break;
case FUNC_RECORDING:
func_name = "FUNC_RECORDING";
break;
case FUNC_FIRSTLAYER_INSPECT:
func_name = "FUNC_FIRSTLAYER_INSPECT";
break;
case FUNC_SPAGHETTI:
func_name = "FUNC_SPAGHETTI";
break;
case FUNC_FLOW_CALIBRATION:
func_name = "FUNC_FLOW_CALIBRATION";
break;
case FUNC_AUTO_LEVELING:
func_name = "FUNC_AUTO_LEVELING";
break;
case FUNC_CHAMBER_TEMP:
func_name = "FUNC_CHAMBER_TEMP";
break;
default:
return true;
}
return DeviceManager::is_function_supported(printer_type, func_name);
}
int MachineObject::publish_json(std::string json_str, int qos)
{
if (is_lan_mode_printer()) {
@ -1824,6 +1838,30 @@ int MachineObject::parse_json(std::string payload)
#pragma endregion
#pragma region online
// parse online info
try {
if (jj.contains("online")) {
if (jj["online"].contains("ahb")) {
if (jj["online"]["ahb"].get<bool>()) {
online_ahb = true;
} else {
online_ahb = false;
}
}
if (jj["online"].contains("rfid")) {
if (jj["online"]["rfid"].get<bool>()) {
online_rfid = true;
} else {
online_rfid = false;
}
}
}
} catch (...) {
;
}
#pragma endregion
#pragma region print_task
if (jj.contains("printer_type")) {
printer_type = parse_printer_type(jj["printer_type"].get<std::string>());
@ -2069,6 +2107,31 @@ int MachineObject::parse_json(std::string payload)
}
}
}
// new ver list
if (jj["upgrade_state"].contains("new_ver_list")) {
m_new_ver_list_exist = true;
new_ver_list.clear();
for (auto ver_item = jj["upgrade_state"]["new_ver_list"].begin(); ver_item != jj["upgrade_state"]["new_ver_list"].end(); ver_item++) {
ModuleVersionInfo ver_info;
if (ver_item->contains("name"))
ver_info.name = (*ver_item)["name"].get<std::string>();
else
continue;
if (ver_item->contains("cur_ver"))
ver_info.sw_ver = (*ver_item)["cur_ver"].get<std::string>();
if (ver_item->contains("new_ver"))
ver_info.sw_new_ver = (*ver_item)["new_ver"].get<std::string>();
if (ver_info.name == "ota") {
ota_new_version_number = ver_info.sw_new_ver;
}
new_ver_list.insert(std::make_pair(ver_info.name, ver_info));
}
} else {
new_ver_list.clear();
}
}
}
catch (...) {
@ -2181,6 +2244,10 @@ int MachineObject::parse_json(std::string payload)
if (jj["ams"].contains("tray_read_done_bits")) {
tray_read_done_bits = stol(jj["ams"]["tray_read_done_bits"].get<std::string>(), nullptr, 16);
}
if (jj["ams"].contains("tray_reading_bits")) {
tray_reading_bits = stol(jj["ams"]["tray_reading_bits"].get<std::string>(), nullptr, 16);
ams_support_use_ams = true;
}
if (jj["ams"].contains("tray_is_bbl_bits")) {
tray_is_bbl_bits = stol(jj["ams"]["tray_is_bbl_bits"].get<std::string>(), nullptr, 16);
}
@ -2194,6 +2261,15 @@ int MachineObject::parse_json(std::string payload)
if (jj["ams"].contains("tray_tar")) {
m_tray_tar = jj["ams"]["tray_tar"].get<std::string>();
}
if (jj["ams"].contains("insert_flag")) {
ams_insert_flag = jj["ams"]["insert_flag"].get<bool>();
}
if (jj["ams"].contains("ams_rfid_status"))
ams_rfid_status = jj["ams"]["ams_rfid_status"].get<int>();
if (jj["ams"].contains("power_on_flag")) {
ams_power_on_flag = jj["ams"]["power_on_flag"].get<bool>();
}
if (ams_exist_bits != last_ams_exist_bits
|| last_tray_exist_bits != last_tray_exist_bits
@ -2931,11 +3007,15 @@ std::map<std::string, MachineObject*> DeviceManager::get_my_machine_list()
std::map<std::string, MachineObject*> result;
for (auto it = userMachineList.begin(); it != userMachineList.end(); it++) {
if (!it->second)
continue;
if (!it->second->is_lan_mode_printer())
result.insert(std::make_pair(it->first, it->second));
}
for (auto it = localMachineList.begin(); it != localMachineList.end(); it++) {
if (!it->second)
continue;
if (it->second->has_access_right() && it->second->is_avaliable() && it->second->is_lan_mode_printer()) {
// remove redundant in userMachineList
if (result.find(it->first) == result.end()) {
@ -3004,7 +3084,7 @@ void DeviceManager::parse_user_print_info(std::string body)
if (!elem["dev_online"].is_null())
obj->m_is_online = elem["dev_online"].get<bool>();
if (elem.contains("dev_model_name") && !elem["dev_model_name"].is_null())
obj->printer_type = MachineObject::parse_iot_printer_type(elem["dev_model_name"].get<std::string>());
obj->printer_type = elem["dev_model_name"].get<std::string>();
if (!elem["task_status"].is_null())
obj->iot_print_status = elem["task_status"].get<std::string>();
if (elem.contains("dev_product_name") && !elem["dev_product_name"].is_null())
@ -3083,4 +3163,67 @@ void DeviceManager::load_last_machine()
}
}
json DeviceManager::function_table = json::object();
std::string DeviceManager::parse_printer_type(std::string type_str)
{
if (DeviceManager::function_table.contains("printers")) {
for (auto printer : DeviceManager::function_table["printers"]) {
if (printer.contains("model_id") && printer["model_id"].get<std::string>() == type_str) {
if (printer.contains("printer_type")) {
return printer["printer_type"].get<std::string>();
}
}
}
}
return "";
}
std::string DeviceManager::get_printer_display_name(std::string type_str)
{
if (DeviceManager::function_table.contains("printers")) {
for (auto printer : DeviceManager::function_table["printers"]) {
if (printer.contains("model_id") && printer["model_id"].get<std::string>() == type_str) {
if (printer.contains("display_name")) {
return printer["display_name"].get<std::string>();
}
}
}
}
return "";
}
bool DeviceManager::is_function_supported(std::string type_str, std::string function_name)
{
if (DeviceManager::function_table.contains("printers")) {
for (auto printer : DeviceManager::function_table["printers"]) {
if (printer.contains("model_id") && printer["model_id"].get<std::string>() == type_str) {
if (printer.contains("func")) {
if (printer["func"].contains(function_name))
return printer["func"][function_name].get<bool>();
}
}
}
}
return true;
}
bool DeviceManager::load_functional_config(std::string config_file)
{
std::ifstream json_file(config_file.c_str());
try {
if (json_file.is_open()) {
json_file >> DeviceManager::function_table;
return true;
} else {
BOOST_LOG_TRIVIAL(error) << "load functional config failed, file = " << config_file;
}
}
catch(...) {
BOOST_LOG_TRIVIAL(error) << "load functional config failed, file = " << config_file;
return false;
}
return true;
}
} // namespace Slic3r

View file

@ -7,6 +7,7 @@
#include <memory>
#include <chrono>
#include <boost/thread.hpp>
#include "nlohmann/json.hpp"
#include "libslic3r/ProjectTask.hpp"
#include "slic3r/Utils/json_diff.hpp"
#include "slic3r/Utils/NetworkAgent.hpp"
@ -32,17 +33,10 @@ inline int correct_filament_temperature(int filament_temp)
wxString get_stage_string(int stage);
using namespace nlohmann;
namespace Slic3r {
enum PRINTER_TYPE {
PRINTER_3DPrinter_UKNOWN,
PRINTER_3DPrinter_NONE,
PRINTER_3DPrinter_X1_Carbon, // BL-P001
PRINTER_3DPrinter_X1, // BL-P002
PRINTER_3DPrinter_P1, // BL-P003
};
enum PRINTING_STAGE {
PRINTING_STAGE_PRINTING = 0,
PRINTING_STAGE_BED_LEVELING,
@ -62,6 +56,18 @@ enum PRINTING_STAGE {
PRINTING_STAGE_COUNT
};
enum PrinterFunction {
FUNC_MONITORING = 0,
FUNC_TIMELAPSE,
FUNC_RECORDING,
FUNC_FIRSTLAYER_INSPECT,
FUNC_SPAGHETTI,
FUNC_FLOW_CALIBRATION,
FUNC_AUTO_LEVELING,
FUNC_CHAMBER_TEMP,
FUNC_MAX
};
enum PrintingSpeedLevel {
SPEED_LEVEL_INVALID = 0,
@ -105,6 +111,16 @@ enum AmsStatusMain {
AMS_STATUS_MAIN_UNKNOWN = 0xFF,
};
enum AmsRfidStatus {
AMS_RFID_IDLE = 0,
AMS_RFID_READING = 1,
AMS_RFID_GCODE_TRANS = 2,
AMS_RFID_GCODE_RUNNING = 3,
AMS_RFID_ASSITANT = 4,
AMS_RFID_SWITCH_FILAMENT= 5,
AMS_RFID_HAS_FILAMENT = 6
};
class AmsTray {
public:
AmsTray(std::string tray_id) {
@ -296,14 +312,13 @@ public:
std::string sn;
std::string hw_ver;
std::string sw_ver;
std::string sw_new_ver;
};
/* static members and functions */
static inline int m_sequence_id = 20000;
static PRINTER_TYPE parse_printer_type(std::string type_str);
static PRINTER_TYPE parse_iot_printer_type(std::string type_str);
static PRINTER_TYPE parse_preset_printer_type(std::string type_str);
static std::string get_preset_printer_model_name(PRINTER_TYPE printer_type);
static std::string parse_printer_type(std::string type_str);
static std::string get_preset_printer_model_name(std::string printer_type);
static bool is_bbl_filament(std::string tag_uid);
typedef std::function<void()> UploadedFn;
@ -321,8 +336,8 @@ public:
bool has_access_right() { return !access_code.empty(); }
void set_access_code(std::string code);
bool is_lan_mode_printer();
PRINTER_TYPE printer_type = PRINTER_3DPrinter_UKNOWN;
std::string get_printer_type_string();
//PRINTER_TYPE printer_type = PRINTER_3DPrinter_UKNOWN;
std::string printer_type; /* model_id */
wxString get_printer_type_display_str();
std::string product_name; // set by iot service, get /user/print
@ -344,6 +359,11 @@ public:
long tray_exist_bits = 0;
long tray_is_bbl_bits = 0;
long tray_read_done_bits = 0;
long tray_reading_bits = 0;
int ams_rfid_status = 0;
bool ams_insert_flag { false };
bool ams_power_on_flag { false };
bool ams_support_use_ams { false };
AmsStatusMain ams_status_main;
int ams_status_sub;
int ams_version = 0;
@ -373,6 +393,9 @@ public:
bool is_mapping_exceed_filament(std::vector<FilamentInfo>& result, int &exceed_index);
void reset_mapping_result(std::vector<FilamentInfo>& result);
/*online*/
bool online_rfid;
bool online_ahb;
/* temperature */
float nozzle_temp;
@ -413,6 +436,8 @@ public:
std::string ota_new_version_number;
std::string ahb_new_version_number;
std::map<std::string, ModuleVersionInfo> module_vers;
std::map<std::string, ModuleVersionInfo> new_ver_list;
bool m_new_ver_list_exist = false;
int upgrade_err_code = 0;
std::vector<FirmwareInfo> firmware_list;
@ -568,6 +593,7 @@ public:
void set_online_state(bool on_off);
bool is_online() { return m_is_online; }
bool is_info_ready();
bool is_function_supported(PrinterFunction func);
/* Msg for display MsgFn */
@ -630,6 +656,13 @@ public:
// get alive machine
std::map<std::string, MachineObject*> get_local_machine_list();
void load_last_machine();
static json function_table;
static std::string parse_printer_type(std::string type_str);
static std::string get_printer_display_name(std::string type_str);
static bool is_function_supported(std::string type_str, std::string function_name);
static bool load_functional_config(std::string config_file);
};
} // namespace Slic3r

View file

@ -51,6 +51,8 @@ DownloadProgressDialog::DownloadProgressDialog(wxString title)
Layout();
Fit();
CentreOnParent();
Bind(wxEVT_CLOSE_WINDOW, &DownloadProgressDialog::on_close, this);
}
bool DownloadProgressDialog::Show(bool show)
@ -91,6 +93,15 @@ bool DownloadProgressDialog::Show(bool show)
return DPIDialog::Show(show);
}
void DownloadProgressDialog::on_close(wxCloseEvent& event)
{
if (m_upgrade_job) {
m_upgrade_job->cancel();
m_upgrade_job->join();
}
event.Skip();
}
DownloadProgressDialog::~DownloadProgressDialog() {}
void DownloadProgressDialog::on_dpi_changed(const wxRect &suggested_rect) {}

View file

@ -33,6 +33,7 @@ class DownloadProgressDialog : public DPIDialog
{
protected:
bool Show(bool show) override;
void on_close(wxCloseEvent& event);
public:
DownloadProgressDialog(wxString title);
@ -42,7 +43,7 @@ public:
void update_release_note(std::string release_note, std::string version);
std::shared_ptr<BBLStatusBarSend> m_status_bar;
std::shared_ptr<UpgradeNetworkJob> m_upgrade_job;
std::shared_ptr<UpgradeNetworkJob> m_upgrade_job { nullptr };
wxPanel * m_panel_download;

View file

@ -4385,7 +4385,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
{
case EViewType::FeatureType:
{
append_headers({_u8L("Line type"), _u8L("Time"), _u8L("Percent"), "", _u8L("Display")}, offsets);
append_headers({_u8L("Line Type"), _u8L("Time"), _u8L("Percent"), "", _u8L("Display")}, offsets);
break;
}
case EViewType::Height: { imgui.title(_u8L("Layer Height (mm)")); break; }
@ -4998,6 +4998,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
ImGui::SameLine();
imgui.title(time_title);
std::string filament_str = _u8L("Filament");
std::string cost_str = _u8L("Cost");
std::string prepare_str = _u8L("Prepare time");
std::string print_str = _u8L("Model printing time");
std::string total_str = _u8L("Total");
@ -5006,7 +5007,10 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
if (time_mode.layers_times.empty())
max_len += ImGui::CalcTextSize(total_str.c_str()).x;
else {
max_len += std::max(ImGui::CalcTextSize(print_str.c_str()).x ,std::max(std::max(ImGui::CalcTextSize(prepare_str.c_str()).x, ImGui::CalcTextSize(total_str.c_str()).x), ImGui::CalcTextSize(filament_str.c_str()).x));
max_len += std::max(ImGui::CalcTextSize(cost_str.c_str()).x,
std::max(ImGui::CalcTextSize(print_str.c_str()).x,
std::max(std::max(ImGui::CalcTextSize(prepare_str.c_str()).x, ImGui::CalcTextSize(total_str.c_str()).x),
ImGui::CalcTextSize(filament_str.c_str()).x)));
}
//BBS display filament cost
@ -5031,6 +5035,17 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
auto it = std::find_if(time_mode.roles_times.begin(), time_mode.roles_times.end(), [role](const std::pair<ExtrusionRole, float>& item) { return role == item.first; });
return (it != time_mode.roles_times.end()) ? it->second : 0.0f;
};
//BBS: display cost of filaments
ImGui::Dummy({window_padding, window_padding});
ImGui::SameLine();
imgui.text(cost_str + ":");
ImGui::SameLine(max_len);
//char buf[64];
::sprintf(buf, "%.2f", ps.total_cost);
imgui.text(buf);
//BBS: start gcode is prepeare time
if (role_time(erCustom) != 0.0f) {
ImGui::Dummy({ window_padding, window_padding });

View file

@ -595,6 +595,7 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, Bed3D &bed)
#endif
, m_in_render(false)
, m_main_toolbar(GLToolbar::Normal, "Main")
, m_separator_toolbar(GLToolbar::Normal, "Separator")
, m_assemble_view_toolbar(GLToolbar::Normal, "Assembly_View")
, m_return_toolbar()
, m_canvas_type(ECanvasType::CanvasView3D)
@ -1021,6 +1022,11 @@ void GLCanvas3D::enable_return_toolbar(bool enable)
m_return_toolbar.set_enabled(enable);
}
void GLCanvas3D::enable_separator_toolbar(bool enable)
{
m_separator_toolbar.set_enabled(enable);
}
void GLCanvas3D::enable_dynamic_background(bool enable)
{
m_dynamic_background_enabled = enable;
@ -2147,7 +2153,7 @@ void GLCanvas3D::bind_event_handlers()
m_canvas->Bind(wxEVT_PAINT, &GLCanvas3D::on_paint, this);
m_canvas->Bind(wxEVT_SET_FOCUS, &GLCanvas3D::on_set_focus, this);
m_event_handlers_bound = true;
m_canvas->Bind(wxEVT_GESTURE_PAN, &GLCanvas3D::on_gesture, this);
m_canvas->Bind(wxEVT_GESTURE_ZOOM, &GLCanvas3D::on_gesture, this);
m_canvas->Bind(wxEVT_GESTURE_ROTATE, &GLCanvas3D::on_gesture, this);
@ -2184,7 +2190,7 @@ void GLCanvas3D::unbind_event_handlers()
m_canvas->Unbind(wxEVT_PAINT, &GLCanvas3D::on_paint, this);
m_canvas->Unbind(wxEVT_SET_FOCUS, &GLCanvas3D::on_set_focus, this);
m_event_handlers_bound = false;
m_canvas->Unbind(wxEVT_GESTURE_PAN, &GLCanvas3D::on_gesture, this);
m_canvas->Unbind(wxEVT_GESTURE_ZOOM, &GLCanvas3D::on_gesture, this);
m_canvas->Unbind(wxEVT_GESTURE_ROTATE, &GLCanvas3D::on_gesture, this);
@ -2292,30 +2298,25 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
case WXK_CONTROL_M:
#endif /* __APPLE__ */
{
//#ifdef _WIN32
// if (wxGetApp().app_config->get("use_legacy_3DConnexion") == "1") {
//#endif //_WIN32
//#ifdef __APPLE__
// // On OSX use Cmd+Shift+M to "Show/Hide 3Dconnexion devices settings dialog"
// if ((evt.GetModifiers() & shiftMask) != 0) {
//#endif // __APPLE__
//
//#ifdef SUPPORT_3D_CONNEXION
// Mouse3DController& controller = wxGetApp().plater()->get_mouse3d_controller();
// controller.show_settings_dialog(!controller.is_settings_dialog_shown());
// m_dirty = true;
//#endif
//#ifdef __APPLE__
// }
// else
// // and Cmd+M to minimize application
// wxGetApp().mainframe->Iconize();
//#endif // __APPLE__
//#ifdef _WIN32
// }
//#endif //_WIN32
post_event(SimpleEvent(EVT_GLTOOLBAR_CLONE));
#ifdef _WIN32
if (wxGetApp().app_config->get("use_legacy_3DConnexion") == "true") {
#endif //_WIN32
#ifdef __APPLE__
// On OSX use Cmd+Shift+M to "Show/Hide 3Dconnexion devices settings dialog"
if ((evt.GetModifiers() & shiftMask) != 0) {
#endif // __APPLE__
Mouse3DController& controller = wxGetApp().plater()->get_mouse3d_controller();
controller.show_settings_dialog(!controller.is_settings_dialog_shown());
m_dirty = true;
#ifdef __APPLE__
}
else
// and Cmd+M to minimize application
wxGetApp().mainframe->Iconize();
#endif // __APPLE__
#ifdef _WIN32
}
#endif //_WIN32
break;
}
#ifdef __APPLE__
@ -2368,7 +2369,10 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
break;
// BBS
case '0': { select_view("topfront"); break; }
case '0': {
select_view("plate");
zoom_to_bed();
break; }
case '1': { select_view("top"); break; }
case '2': { select_view("bottom"); break; }
case '3': { select_view("front"); break; }
@ -2711,7 +2715,10 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
switch (keyCode) {
case '0':
case WXK_NUMPAD0: //0 on numpad
{ select_view("topfront"); break; }
{ select_view("plate");
zoom_to_bed();
break;
}
case '1':
case WXK_NUMPAD1: //1 on numpad
{ select_view("top"); break; }
@ -3332,8 +3339,8 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
else
rotate_target = volumes_bounding_box().center();
//BBS do not limit rotate in assemble view
//camera.rotate_local_with_target(Vec3d(rot.y(), rot.x(), 0.), rotate_target);
camera.rotate_on_sphere_with_target(rot.x(), rot.y(), true, rotate_target);
camera.rotate_local_with_target(Vec3d(rot.y(), rot.x(), 0.), rotate_target);
//camera.rotate_on_sphere_with_target(rot.x(), rot.y(), false, rotate_target);
}
else {
#ifdef SUPPORT_FEEE_CAMERA
@ -4994,6 +5001,9 @@ bool GLCanvas3D::_init_toolbars()
if (!_init_return_toolbar())
return false;
if (!_init_separator_toolbar())
return false;
#if 0
if (!_init_view_toolbar())
return false;
@ -5134,16 +5144,6 @@ bool GLCanvas3D::_init_main_toolbar()
if (!m_main_toolbar.add_item(item))
return false;
GLToolbarItem::Data sperate_item;
sperate_item.name = "seperatetag";
sperate_item.icon_filename = "seperator.svg";
sperate_item.sprite_id = ++item.sprite_id;
sperate_item.left.action_callback = [this]() { };
sperate_item.visibility_callback = []()->bool { return true; };
sperate_item.enabling_callback = []()->bool { return false; };
if (!m_main_toolbar.add_item(sperate_item))
return false;
return true;
}
@ -5207,16 +5207,6 @@ bool GLCanvas3D::_init_assemble_view_toolbar()
m_assemble_view_toolbar.set_separator_size(10);
m_assemble_view_toolbar.set_gap_size(4);
GLToolbarItem::Data sperate_item;
sperate_item.name = "start_seperator";
sperate_item.icon_filename = "seperator.svg";
sperate_item.sprite_id = 0;
sperate_item.left.action_callback = [this]() {};
sperate_item.visibility_callback = []()->bool { return true; };
sperate_item.enabling_callback = []()->bool { return false; };
if (!m_assemble_view_toolbar.add_item(sperate_item))
return false;
GLToolbarItem::Data item;
item.name = "assembly_view";
item.icon_filename = "toolbar_assemble.svg";
@ -5245,6 +5235,45 @@ bool GLCanvas3D::_init_return_toolbar()
return m_return_toolbar.init();
}
bool GLCanvas3D::_init_separator_toolbar()
{
if (!m_separator_toolbar.is_enabled())
return true;
BackgroundTexture::Metadata background_data;
background_data.filename = "toolbar_background.png";
background_data.left = 0;
background_data.top = 0;
background_data.right = 0;
background_data.bottom = 0;
if (!m_separator_toolbar.init(background_data))
{
// unable to init the toolbar texture, disable it
m_separator_toolbar.set_enabled(false);
return true;
}
m_separator_toolbar.set_layout_type(GLToolbar::Layout::Horizontal);
//BBS: assemble toolbar is at the top and right, we don't need the rounded-corner effect at the left side and the top side
m_separator_toolbar.set_horizontal_orientation(GLToolbar::Layout::HO_Left);
m_separator_toolbar.set_vertical_orientation(GLToolbar::Layout::VO_Top);
m_separator_toolbar.set_border(5.0f);
GLToolbarItem::Data sperate_item;
sperate_item.name = "start_seperator";
sperate_item.icon_filename = "seperator.svg";
sperate_item.sprite_id = 0;
sperate_item.left.action_callback = [this]() {};
sperate_item.visibility_callback = []()->bool { return true; };
sperate_item.enabling_callback = []()->bool { return false; };
if (!m_separator_toolbar.add_item(sperate_item))
return false;
return true;
}
// BBS
#if 0
@ -5647,13 +5676,13 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type, bool with
switch (build_volume.type()) {
case BuildVolume::Type::Rectangle: {
const BoundingBox3Base<Vec3d> bed_bb = build_volume.bounding_volume().inflated(BuildVolume::SceneEpsilon);
m_volumes.set_print_volume({ 0, // circle
m_volumes.set_print_volume({ 0, // Rectangle
{ float(bed_bb.min.x()), float(bed_bb.min.y()), float(bed_bb.max.x()), float(bed_bb.max.y()) },
{ 0.0f, float(build_volume.printable_height()) } });
break;
}
case BuildVolume::Type::Circle: {
m_volumes.set_print_volume({ 1, // rectangle
m_volumes.set_print_volume({ 1, // Circle
{ unscaled<float>(build_volume.circle().center.x()), unscaled<float>(build_volume.circle().center.y()), unscaled<float>(build_volume.circle().radius + BuildVolume::SceneEpsilon), 0.0f },
{ 0.0f, float(build_volume.printable_height() + BuildVolume::SceneEpsilon) } });
break;
@ -5844,6 +5873,7 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale()
//BBS: GUI refactor: GLToolbar
m_main_toolbar.set_scale(sc);
m_assemble_view_toolbar.set_scale(sc);
m_separator_toolbar.set_scale(sc);
collapse_toolbar.set_scale(sc);
size *= m_retina_helper->get_scale_factor();
@ -5853,15 +5883,16 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale()
//BBS: GUI refactor: GLToolbar
m_main_toolbar.set_icons_size(GLGizmosManager::Default_Icons_Size * scale);
m_assemble_view_toolbar.set_icons_size(size);
m_separator_toolbar.set_icons_size(size);
collapse_toolbar.set_icons_size(size);
#endif // ENABLE_RETINA_GL
//BBS: GUI refactor: GLToolbar
#if BBS_TOOLBAR_ON_TOP
float collapse_toolbar_width = collapse_toolbar.is_enabled() ? collapse_toolbar.get_width() : 0.0f;
float collapse_toolbar_width = collapse_toolbar.is_enabled() ? collapse_toolbar.get_width() : GLToolbar::Default_Icons_Size;
float top_tb_width = m_main_toolbar.get_width() + m_gizmos.get_scaled_total_width() + m_assemble_view_toolbar.get_width() + collapse_toolbar_width;
int items_cnt = m_main_toolbar.get_visible_items_cnt() + m_gizmos.get_selectable_icons_cnt() + m_assemble_view_toolbar.get_visible_items_cnt() + collapse_toolbar.get_visible_items_cnt();
float top_tb_width = m_main_toolbar.get_width() + m_gizmos.get_scaled_total_width() + m_assemble_view_toolbar.get_width() + m_separator_toolbar.get_width() + collapse_toolbar_width;
int items_cnt = m_main_toolbar.get_visible_items_cnt() + m_gizmos.get_selectable_icons_cnt() + m_assemble_view_toolbar.get_visible_items_cnt() + m_separator_toolbar.get_visible_items_cnt() + collapse_toolbar.get_visible_items_cnt();
float noitems_width = top_tb_width - size * items_cnt; // width of separators and borders in top toolbars
// calculate scale needed for items in all top toolbars
@ -5917,6 +5948,7 @@ void GLCanvas3D::_render_overlays()
//BBS: GUI refactor: GLToolbar
m_main_toolbar.set_scale(scale);
m_assemble_view_toolbar.set_scale(scale);
m_separator_toolbar.set_scale(scale);
wxGetApp().plater()->get_collapse_toolbar().set_scale(scale);
m_gizmos.set_overlay_scale(scale);
#else
@ -5929,10 +5961,13 @@ void GLCanvas3D::_render_overlays()
//BBS: GUI refactor: GLToolbar
m_main_toolbar.set_icons_size(gizmo_size);
m_assemble_view_toolbar.set_icons_size(gizmo_size);
m_separator_toolbar.set_icons_size(gizmo_size);
wxGetApp().plater()->get_collapse_toolbar().set_icons_size(size);
m_gizmos.set_overlay_icon_size(gizmo_size);
#endif // ENABLE_RETINA_GL
_render_separator_toolbar_right();
_render_separator_toolbar_left();
_render_main_toolbar();
//BBS: GUI refactor: GLToolbar
_render_imgui_select_plate_toolbar();
@ -6135,8 +6170,9 @@ void GLCanvas3D::_render_main_toolbar()
float collapse_toolbar_width = collapse_toolbar.is_enabled() ? collapse_toolbar.get_width() : 0.0f;
float gizmo_width = m_gizmos.get_scaled_total_width();
float assemble_width = m_assemble_view_toolbar.get_width();
float separator_width = m_separator_toolbar.get_width();
float top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
float left = std::max(-0.5f * cnv_size.get_width(), -0.5f * (m_main_toolbar.get_width() + gizmo_width + assemble_width - collapse_toolbar_width)) * inv_zoom;
float left = std::max(-0.5f * cnv_size.get_width(), -0.5f * (m_main_toolbar.get_width() + separator_width + gizmo_width + assemble_width - collapse_toolbar_width)) * inv_zoom;
#else
float gizmo_height = m_gizmos.get_scaled_total_height();
float space_height = GLGizmosManager::Default_Icons_Size * wxGetApp().toolbar_icon_scale();
@ -6327,8 +6363,9 @@ void GLCanvas3D::_render_assemble_view_toolbar() const
float collapse_toolbar_width = collapse_toolbar.is_enabled() ? collapse_toolbar.get_width() : 0.0f;
float gizmo_width = m_gizmos.get_scaled_total_width();
float assemble_width = m_assemble_view_toolbar.get_width();
float separator_width = m_separator_toolbar.get_width();
float top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
float main_toolbar_left = std::max(-0.5f * cnv_size.get_width(), -0.5f * (m_main_toolbar.get_width() + gizmo_width + assemble_width - collapse_toolbar_width)) * inv_zoom;
float main_toolbar_left = std::max(-0.5f * cnv_size.get_width(), -0.5f * (m_main_toolbar.get_width() + gizmo_width + assemble_width - separator_width - collapse_toolbar_width)) * inv_zoom;
float left = main_toolbar_left + (m_main_toolbar.get_width() + gizmo_width) * inv_zoom;
//float left = 0.5f * (m_main_toolbar.get_width() + gizmo_width - m_assemble_view_toolbar.get_width() + collapse_toolbar_width) * inv_zoom;
#else
@ -6397,6 +6434,48 @@ void GLCanvas3D::_render_return_toolbar() const
imgui.end();
}
void GLCanvas3D::_render_separator_toolbar_right() const
{
if (!m_separator_toolbar.is_enabled())
return;
Size cnv_size = get_canvas_size();
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
float collapse_toolbar_width = collapse_toolbar.is_enabled() ? collapse_toolbar.get_width() : 0.0f;
float gizmo_width = m_gizmos.get_scaled_total_width();
float assemble_width = m_assemble_view_toolbar.get_width();
float separator_width = m_separator_toolbar.get_width();
float top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
float main_toolbar_left = std::max(-0.5f * cnv_size.get_width(), -0.5f * (m_main_toolbar.get_width() + gizmo_width + assemble_width - collapse_toolbar_width)) * inv_zoom;
float left = main_toolbar_left + (m_main_toolbar.get_width() + gizmo_width) * inv_zoom;
m_separator_toolbar.set_position(top, left);
m_separator_toolbar.render(*this,GLToolbarItem::SeparatorLine);
}
void GLCanvas3D::_render_separator_toolbar_left() const
{
if (!m_separator_toolbar.is_enabled())
return;
Size cnv_size = get_canvas_size();
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
float collapse_toolbar_width = collapse_toolbar.is_enabled() ? collapse_toolbar.get_width() : 0.0f;
float gizmo_width = m_gizmos.get_scaled_total_width();
float assemble_width = m_assemble_view_toolbar.get_width();
float separator_width = m_separator_toolbar.get_width();
float top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
float main_toolbar_left = std::max(-0.5f * cnv_size.get_width(), -0.5f * (m_main_toolbar.get_width() + gizmo_width + assemble_width + separator_width - collapse_toolbar_width)) * inv_zoom;
float left = main_toolbar_left + (m_main_toolbar.get_width()) * inv_zoom;
m_separator_toolbar.set_position(top, left);
m_separator_toolbar.render(*this,GLToolbarItem::SeparatorLine);
}
void GLCanvas3D::_render_collapse_toolbar() const
{
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
@ -6554,10 +6633,10 @@ void GLCanvas3D::_render_paint_toolbar() const
float gray = 0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2];
if (gray < 80){
ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, 1.0f), item_text.c_str());
ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, 1.0f), item_text.c_str());
} else{
ImGui::TextColored(ImVec4(0.0f, 0.0f, 0.0f, 1.0f), item_text.c_str());
}
}
}
ImGui::AlignTextToFramePadding();
imgui.end();

View file

@ -399,6 +399,7 @@ private:
GLGizmosManager m_gizmos;
//BBS: GUI refactor: GLToolbar
mutable GLToolbar m_main_toolbar;
mutable GLToolbar m_separator_toolbar;
mutable IMToolbar m_sel_plate_toolbar;
mutable GLToolbar m_assemble_view_toolbar;
mutable IMReturnToolbar m_return_toolbar;
@ -667,6 +668,7 @@ public:
void enable_select_plate_toolbar(bool enable);
void enable_assemble_view_toolbar(bool enable);
void enable_return_toolbar(bool enable);
void enable_separator_toolbar(bool enable);
void enable_dynamic_background(bool enable);
void enable_labels(bool enable) { m_labels.enable(enable); }
void enable_slope(bool enable) { m_slope.enable(enable); }
@ -686,6 +688,8 @@ public:
float get_main_toolbar_width() { return m_main_toolbar.get_width();}
float get_assemble_view_toolbar_width() { return m_assemble_view_toolbar.get_width(); }
float get_assemble_view_toolbar_height() { return m_assemble_view_toolbar.get_height(); }
float get_separator_toolbar_width() { return m_separator_toolbar.get_width(); }
float get_separator_toolbar_height() { return m_separator_toolbar.get_height(); }
float get_collapse_toolbar_width();
float get_collapse_toolbar_height();
@ -923,6 +927,7 @@ private:
bool _update_imgui_select_plate_toolbar();
bool _init_assemble_view_toolbar();
bool _init_return_toolbar();
bool _init_separator_toolbar();
// BBS
//bool _init_view_toolbar();
bool _init_collapse_toolbar();
@ -967,6 +972,8 @@ private:
void _render_imgui_select_plate_toolbar() const;
void _render_assemble_view_toolbar() const;
void _render_return_toolbar() const;
void _render_separator_toolbar_right() const;
void _render_separator_toolbar_left() const;
void _render_collapse_toolbar() const;
// BBS
//void _render_view_toolbar() const;

View file

@ -538,7 +538,7 @@ bool GLToolbar::update_items_state()
return ret;
}
void GLToolbar::render(const GLCanvas3D& parent)
void GLToolbar::render(const GLCanvas3D& parent,GLToolbarItem::EType type)
{
if (!m_enabled || m_items.empty())
return;
@ -549,7 +549,7 @@ void GLToolbar::render(const GLCanvas3D& parent)
switch (m_layout.type)
{
default:
case Layout::Horizontal: { render_horizontal(parent); break; }
case Layout::Horizontal: { render_horizontal(parent,type); break; }
case Layout::Vertical: { render_vertical(parent); break; }
}
}
@ -1386,7 +1386,7 @@ void GLToolbar::render_arrow(const GLCanvas3D& parent, GLToolbarItem* highlighte
}
}
void GLToolbar::render_horizontal(const GLCanvas3D& parent)
void GLToolbar::render_horizontal(const GLCanvas3D& parent,GLToolbarItem::EType type)
{
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
float factor = inv_zoom * m_layout.scale;
@ -1404,6 +1404,8 @@ void GLToolbar::render_horizontal(const GLCanvas3D& parent)
float left = m_layout.left;
float top = m_layout.top;
float right = left + scaled_width;
if (type == GLToolbarItem::SeparatorLine)
right = left + scaled_width * 0.5;
float bottom = top - scaled_height;
render_background(left, top, right, bottom, scaled_border);

View file

@ -68,6 +68,7 @@ public:
//BBS: GUI refactor: GLToolbar
ActionWithText,
ActionWithTextImage,
SeparatorLine,
Num_Types
};
@ -400,7 +401,7 @@ public:
// returns true if any item changed its state
bool update_items_state();
void render(const GLCanvas3D& parent);
void render(const GLCanvas3D& parent,GLToolbarItem::EType type = GLToolbarItem::Action);
void render_arrow(const GLCanvas3D& parent, GLToolbarItem* highlighted_item);
bool on_mouse(wxMouseEvent& evt, GLCanvas3D& parent);
@ -429,7 +430,7 @@ private:
int contains_mouse_vertical(const Vec2d& mouse_pos, const GLCanvas3D& parent) const;
void render_background(float left, float top, float right, float bottom, float border) const;
void render_horizontal(const GLCanvas3D& parent);
void render_horizontal(const GLCanvas3D& parent,GLToolbarItem::EType type);
void render_vertical(const GLCanvas3D& parent);
bool generate_icons_texture();

View file

@ -1095,6 +1095,9 @@ void GUI_App::post_init()
hms_query->check_hms_info();
});
std::string functional_config_file = Slic3r::resources_dir() + "/config.json";
DeviceManager::load_functional_config(encode_path(functional_config_file.c_str()));
BOOST_LOG_TRIVIAL(info) << "finished post_init";
//BBS: remove the single instance currently
/*#ifdef _WIN32
@ -1481,6 +1484,19 @@ void GUI_App::restart_networking()
BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< boost::format(" exit, m_agent=%1%")%m_agent;
}
void GUI_App::remove_old_networking_plugins()
{
auto plugin_folder = boost::filesystem::path(wxStandardPaths::Get().GetUserDataDir().ToUTF8().data()) / "plugins";
if (boost::filesystem::exists(plugin_folder)) {
BOOST_LOG_TRIVIAL(info) << "[remove_old_networking_plugins] remove the directory "<<plugin_folder.string();
try {
fs::remove_all(plugin_folder);
} catch (...) {
BOOST_LOG_TRIVIAL(error) << "Failed removing the plugins directory " << plugin_folder.string();
}
}
}
int GUI_App::updating_bambu_networking()
{
DownloadProgressDialog dlg(_L("Downloading Bambu Network Plug-in"));
@ -1838,6 +1854,20 @@ bool GUI_App::on_init_inner()
CBaseException::set_log_folder(data_dir());
#endif
wxGetApp().Bind(wxEVT_QUERY_END_SESSION, [this](auto & e) {
if (mainframe) {
wxCloseEvent e2(wxEVT_CLOSE_WINDOW);
e2.SetCanVeto(true);
mainframe->GetEventHandler()->ProcessEvent(e2);
if (e2.GetVeto()) {
e.Veto();
return;
}
}
for (auto d : dialogStack)
d->EndModal(wxID_CANCEL);
});
std::map<std::string, std::string> extra_headers = get_extra_header();
Slic3r::Http::set_extra_headers(extra_headers);
@ -1896,10 +1926,20 @@ bool GUI_App::on_init_inner()
init_fonts();
if (m_last_config_version) {
if (*m_last_config_version < *Semver::parse(SLIC3R_VERSION))
check_older_app_config(*m_last_config_version, true);
} else {
check_older_app_config(Semver(), false);
int last_major = m_last_config_version->maj();
int last_minor = m_last_config_version->min();
int last_patch = m_last_config_version->patch()/100;
std::string studio_ver = SLIC3R_VERSION;
int cur_major = atoi(studio_ver.substr(0,2).c_str());
int cur_minor = atoi(studio_ver.substr(3,2).c_str());
int cur_patch = atoi(studio_ver.substr(6,2).c_str());
BOOST_LOG_TRIVIAL(info) << boost::format("last app version {%1%.%2%.%3%}, current version {%4%.%5%.%6%}")
%last_major%last_minor%last_patch%cur_major%cur_minor%cur_patch;
if ((last_major != cur_major)
||(last_minor != cur_minor)
||(last_patch != cur_patch)) {
remove_old_networking_plugins();
}
}
app_config->set("version", SLIC3R_VERSION);
@ -2538,21 +2578,21 @@ float GUI_App::toolbar_icon_scale(const bool is_limited/* = false*/) const
const float icon_sc = m_em_unit * 0.1f;
#endif // __APPLE__
return icon_sc;
//return icon_sc;
//const std::string& auto_val = app_config->get("toolkit_size");
const std::string& auto_val = app_config->get("toolkit_size");
//if (auto_val.empty())
// return icon_sc;
if (auto_val.empty())
return icon_sc;
//int int_val = 100;
//// correct value in respect to toolkit_size
//int_val = std::min(atoi(auto_val.c_str()), int_val);
int int_val = 100;
// correct value in respect to toolkit_size
int_val = std::min(atoi(auto_val.c_str()), int_val);
//if (is_limited && int_val < 50)
// int_val = 50;
if (is_limited && int_val < 50)
int_val = 50;
//return 0.01f * int_val * icon_sc;
return 0.01f * int_val * icon_sc;
}
void GUI_App::set_auto_toolbar_icon_scale(float scale) const
@ -2911,6 +2951,7 @@ void GUI_App::request_user_logout()
m_agent->set_user_selected_machine("");
/* delete old user settings */
m_device_manager->clean_user_info();
GUI::wxGetApp().sidebar().load_ams_list({});
GUI::wxGetApp().remove_user_presets();
GUI::wxGetApp().stop_sync_user_preset();
}
@ -2920,7 +2961,9 @@ int GUI_App::request_user_unbind(std::string dev_id)
{
int result = -1;
if (m_agent) {
return m_agent->unbind(dev_id);
result = m_agent->unbind(dev_id);
BOOST_LOG_TRIVIAL(info) << "request_user_unbind, dev_id = " << dev_id << ", result = " << result;
return result;
}
return result;
}
@ -3008,6 +3051,31 @@ std::string GUI_App::handle_web_request(std::string cmd)
}
}
}
else if (command_str.compare("homepage_delete_recentfile") == 0) {
if (root.get_child_optional("data") != boost::none) {
pt::ptree data_node = root.get_child("data");
boost::optional<std::string> path = data_node.get_optional<std::string>("path");
if (path.has_value()) {
this->request_remove_project(path.value());
}
}
}
else if (command_str.compare("homepage_delete_all_recentfile") == 0) {
this->request_remove_project("");
}
else if (command_str.compare("homepage_explore_recentfile") == 0) {
if (root.get_child_optional("data") != boost::none) {
pt::ptree data_node = root.get_child("data");
boost::optional<std::string> path = data_node.get_optional<std::string>("path");
if (path.has_value())
{
boost::filesystem::path NowFile(path.value());
std::string FolderPath = NowFile.parent_path().make_preferred().string();
desktop_open_any_folder(FolderPath);
}
}
}
else if (command_str.compare("homepage_open_hotspot") == 0) {
if (root.get_child_optional("data") != boost::none) {
pt::ptree data_node = root.get_child("data");
@ -3042,6 +3110,16 @@ std::string GUI_App::handle_web_request(std::string cmd)
wxPostEvent(mainframe, e);
}
}
else if (command_str.compare("userguide_wiki_open") == 0) {
if (root.get_child_optional("data") != boost::none) {
pt::ptree data_node = root.get_child("data");
boost::optional<std::string> path = data_node.get_optional<std::string>("url");
if (path.has_value()) {
wxLaunchDefaultBrowser(path.value());
}
}
}
}
}
catch (...) {
@ -3116,6 +3194,11 @@ void GUI_App::request_open_project(std::string project_id)
CallAfter([this, project_id] { mainframe->open_recent_project(-1, wxString::FromUTF8(project_id)); });
}
void GUI_App::request_remove_project(std::string project_id)
{
mainframe->remove_recent_project(-1, wxString::FromUTF8(project_id));
}
void GUI_App::handle_http_error(unsigned int status, std::string body)
{
// tips body size must less than 1024
@ -3335,6 +3418,10 @@ void GUI_App::remove_user_presets()
{
if (preset_bundle && m_agent) {
preset_bundle->remove_users_preset(*app_config);
std::string user_id = m_agent->get_user_id();
preset_bundle->remove_user_presets_directory(user_id);
//update ui
mainframe->update_side_preset_ui();
}

View file

@ -376,6 +376,7 @@ public:
void download_project(std::string project_id);
void request_project_download(std::string project_id);
void request_open_project(std::string project_id);
void request_remove_project(std::string project_id);
void handle_http_error(unsigned int status, std::string body);
void on_http_error(wxCommandEvent &evt);
@ -532,6 +533,7 @@ private:
bool on_init_network(bool try_backup = false);
void init_networking_callbacks();
void init_app_config();
void remove_old_networking_plugins();
//BBS set extra header for http request
std::map<std::string, std::string> get_extra_header();
void init_http_extra_header();

View file

@ -991,6 +991,7 @@ void MenuFactory::create_bbl_part_menu()
[]() { return plater()->can_split(true); }, m_parent);
menu->AppendSeparator();
append_menu_item_per_object_settings(menu);
append_menu_item_change_type(menu);
}
void MenuFactory::create_bbl_assemble_part_menu()
@ -1320,7 +1321,9 @@ void MenuFactory::append_menu_item_change_filament(wxMenu* menu)
for (int i = 1; i <= filaments_cnt; i++)
{
bool is_active_extruder = i == initial_extruder;
// BBS
//bool is_active_extruder = i == initial_extruder;
bool is_active_extruder = false;
int icon_idx = i == 0 ? 0 : i - 1;
const wxString& item_name = wxString::Format(_L("Filament %d"), i) +

View file

@ -1842,7 +1842,10 @@ void ObjectList::load_modifier(const wxArrayString& input_files, ModelObject& mo
new_volume->name = boost::filesystem::path(input_file).filename().string();
// set a default extruder value, since user can't add it manually
// BBS
new_volume->config.set_key_value("extruder", new ConfigOptionInt(1));
int extruder_id = 0;
if (model_object.config.has("extruder"))
extruder_id = model_object.config.opt_int("extruder");
new_volume->config.set_key_value("extruder", new ConfigOptionInt(extruder_id));
// update source data
new_volume->source.input_file = input_file;
new_volume->source.object_idx = obj_idx;
@ -1945,7 +1948,10 @@ void ObjectList::load_generic_subobject(const std::string& type_name, const Mode
new_volume->name = into_u8(name);
// set a default extruder value, since user can't add it manually
// BBS
new_volume->config.set_key_value("extruder", new ConfigOptionInt(1));
int extruder_id = 0;
if (model_object.config.has("extruder"))
extruder_id = model_object.config.opt_int("extruder");
new_volume->config.set_key_value("extruder", new ConfigOptionInt(extruder_id));
new_volume->source.is_from_builtin_objects = true;
select_item([this, obj_idx, new_volume]() {
@ -1962,28 +1968,7 @@ void ObjectList::load_generic_subobject(const std::string& type_name, const Mode
wxGetApp().plater()->canvas3D()->update_instance_printable_state_for_object((size_t)obj_idx);
// apply the instance transform to all volumes and reset instance transform except the offset
{
const Geometry::Transformation &instance_transformation = model_object.instances[0]->get_transformation();
Vec3d original_instance_center = instance_transformation.get_offset();
const Transform3d &transformation_matrix = instance_transformation.get_matrix();
for (ModelVolume *volume : model_object.volumes) {
const Transform3d &volume_matrix = volume->get_matrix();
Transform3d new_matrix = transformation_matrix * volume_matrix;
volume->set_transformation(new_matrix);
}
model_object.instances[0]->set_transformation(Geometry::Transformation());
model_object.ensure_on_bed();
// keep new instance center the same as the original center
model_object.translate(-original_instance_center);
model_object.origin_translation += original_instance_center;
model_object.translate_instances(model_object.origin_translation);
model_object.origin_translation = Vec3d::Zero();
// update the cache data in selection to keep the data of ModelVolume and GLVolume are consistent
wxGetApp().plater()->update();
}
apply_object_instance_transfrom_to_all_volumes(&model_object);
selection_changed();
@ -2069,6 +2054,52 @@ void ObjectList::load_mesh_object(const TriangleMesh &mesh, const wxString &name
#endif /* _DEBUG */
}
void ObjectList::load_mesh_part(const TriangleMesh& mesh, const wxString& name, bool center)
{
wxDataViewItem item = GetSelection();
// we can add volumes for Object or Instance
if (!item || !(m_objects_model->GetItemType(item) & (itObject | itInstance)))
return;
const int obj_idx = m_objects_model->GetObjectIdByItem(item);
if (obj_idx < 0) return;
// Get object item, if Instance is selected
if (m_objects_model->GetItemType(item) & itInstance)
item = m_objects_model->GetItemById(obj_idx);
take_snapshot("Load Mesh Part");
ModelObject* mo = (*m_objects)[obj_idx];
// apply the instance transform to all volumes and reset instance transform except the offset
apply_object_instance_transfrom_to_all_volumes(mo);
ModelVolume* mv = mo->add_volume(mesh);
Vec3d instance_bbox = mo->mesh().bounding_box().size();
Vec3d offset = mv->get_offset() + Vec3d(0, 0, instance_bbox[2] / 2);
mv->set_offset(offset);
mv->name = name.ToStdString();
std::vector<ModelVolume*> volumes;
volumes.push_back(mv);
wxDataViewItemArray items = reorder_volumes_and_get_selection(obj_idx, [volumes](const ModelVolume* volume) {
return std::find(volumes.begin(), volumes.end(), volume) != volumes.end(); });
wxGetApp().plater()->canvas3D()->update_instance_printable_state_for_object((size_t)obj_idx);
if (items.size() > 1) {
m_selection_mode = smVolume;
m_last_selected_item = wxDataViewItem(nullptr);
}
select_items(items);
selection_changed();
//BBS: notify partplate the modify
notify_instance_updated(obj_idx);
}
//BBS
void ObjectList::del_object(const int obj_idx, bool refresh_immediately)
{
@ -5006,5 +5037,28 @@ bool ObjectList::has_paint_on_segmentation()
return m_objects_model->HasInfoItem(InfoItemType::MmuSegmentation);
}
void ObjectList::apply_object_instance_transfrom_to_all_volumes(ModelObject *model_object) {
const Geometry::Transformation &instance_transformation = model_object->instances[0]->get_transformation();
Vec3d original_instance_center = instance_transformation.get_offset();
const Transform3d &transformation_matrix = instance_transformation.get_matrix();
for (ModelVolume *volume : model_object->volumes) {
const Transform3d &volume_matrix = volume->get_matrix();
Transform3d new_matrix = transformation_matrix * volume_matrix;
volume->set_transformation(new_matrix);
}
model_object->instances[0]->set_transformation(Geometry::Transformation());
model_object->ensure_on_bed();
// keep new instance center the same as the original center
model_object->translate(-original_instance_center);
model_object->origin_translation += original_instance_center;
model_object->translate_instances(model_object->origin_translation);
model_object->origin_translation = Vec3d::Zero();
// update the cache data in selection to keep the data of ModelVolume and GLVolume are consistent
wxGetApp().plater()->update();
}
} //namespace GUI
} //namespace Slic3r

View file

@ -281,6 +281,8 @@ public:
void load_generic_subobject(const std::string& type_name, const ModelVolumeType type);
void load_shape_object(const std::string &type_name);
void load_mesh_object(const TriangleMesh &mesh, const wxString &name, bool center = true);
// BBS
void load_mesh_part(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);
@ -450,6 +452,9 @@ private:
void OnEditingStarted(wxDataViewEvent &event);
void OnEditingDone(wxDataViewEvent &event);
// apply the instance transform to all volumes and reset instance transform except the offset
void apply_object_instance_transfrom_to_all_volumes(ModelObject *model_object);
std::vector<int> m_columns_width;
};

View file

@ -73,16 +73,26 @@ void GridCellIconRenderer::Draw(wxGrid& grid,
//not changed
return;
}
if (!table->m_icon_col_width) {
//if (!table->m_icon_col_width) {
table->m_icon_row_height = grid.GetRowSize(row);
table->m_icon_col_width = grid.GetColSize(col);
}
//}
wxBitmap& bitmap = table->get_undo_bitmap();
int bitmap_width = bitmap.GetWidth();
int bitmap_height = bitmap.GetHeight();
int offset_x = (table->m_icon_col_width - bitmap_width)/2;
int offset_y = (table->m_icon_row_height - bitmap_height)/2;
#ifdef __WXOSX_COCOA__
auto lock_pos = wxPoint(rect.x + offset_x, rect.y + offset_y);
auto left = (28 - 12) / 2;
auto top = (32 - 12) / 2;
lock_pos.x += left;
lock_pos.y += top;
dc.DrawBitmap(bitmap, lock_pos);
#else
dc.DrawBitmap(bitmap, wxPoint(rect.x + offset_x, rect.y + offset_y));
#endif
//dc.SetPen(*wxGREEN_PEN);
//dc.SetBrush(*wxTRANSPARENT_BRUSH);
@ -148,17 +158,15 @@ void GridCellFilamentsEditor::Create(wxWindow* parent,
if ( !m_allowOthers )
style |= wxCB_READONLY;
wxBitmapComboBox *bitmap_combo = new wxBitmapComboBox(parent, id, wxEmptyString,
wxDefaultPosition, wxDefaultSize,
m_choices,
style);
::ComboBox *bitmap_combo = new ComboBox(parent, id, wxEmptyString,
wxDefaultPosition, wxSize(((*m_icons)[0])->GetWidth() + 10, -1), 0, nullptr, CB_NO_DROP_ICON | CB_NO_TEXT | wxCB_READONLY);
if (m_icons) {
int array_count = m_choices.GetCount();
int icon_count = m_icons->size();
for (int i = 0; i < array_count; i++)
{
wxBitmap* bitmap = (i < icon_count) ? (*m_icons)[i] : (*m_icons)[0];
bitmap_combo->SetItemBitmap(i, *bitmap);
bitmap_combo->Append(m_choices[i], *bitmap);
}
}
m_control = bitmap_combo;
@ -214,7 +222,10 @@ void GridCellFilamentsEditor::BeginEdit(int row, int col, wxGrid* grid)
}
//m_value = grid->GetTable()->GetValue(row, col);
Reset(); // this updates combo box to correspond to m_value
//Reset(); // this updates combo box to correspond to m_value
int pos = Combo()->FindString(m_value);
if (pos == wxNOT_FOUND) pos = 0;
Combo()->SetSelection(pos);
Combo()->SetFocus();
@ -223,7 +234,7 @@ void GridCellFilamentsEditor::BeginEdit(int row, int col, wxGrid* grid)
// choice is made in it under OS X. The bug is almost certainly due to a
// problem in focus events generation logic but it's not obvious to fix and
// for now this at least allows to use wxGrid.
Combo()->Popup();
//Combo()->Popup();
#endif
if (evtHandler)
@ -254,7 +265,6 @@ bool GridCellFilamentsEditor::EndEdit(int WXUNUSED(row),
return true;
}
wxGridActivationResult GridCellFilamentsEditor::TryActivate(int row, int col, wxGrid* grid, const wxGridActivationSource& actSource)
{
ObjectGridTable *table = dynamic_cast<ObjectGridTable *>(grid->GetTable());
@ -305,55 +315,222 @@ void GridCellFilamentsEditor::DoActivate(int row, int col, wxGrid* grid)
}
}
// ----------------------------------------------------------------------------
// GridCellFilamentsRenderer
// ----------------------------------------------------------------------------
void GridCellFilamentsRenderer::Draw(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
const wxRect& rect,
int row, int col,
bool isSelected)
void GridCellFilamentsRenderer::Draw(wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, const wxRect &rect, int row, int col, bool isSelected)
{
ObjectGridTable *table = dynamic_cast<ObjectGridTable *>(grid.GetTable());
wxRect text_rect = rect;
ObjectGridTable *table = dynamic_cast<ObjectGridTable *>(grid.GetTable());
wxRect text_rect = rect;
if (table) {
ObjectGridTable::ObjectGridCol* grid_col = table->get_grid_col(col);
ObjectGridTable::ObjectGridRow* grid_row = table->get_grid_row(row - 1);
ConfigOptionInt& cur_option = dynamic_cast<ConfigOptionInt&>((*grid_row)[(ObjectGridTable::GridColType)col]);
ObjectGridTable::ObjectGridCol *grid_col = table->get_grid_col(col);
ObjectGridTable::ObjectGridRow *grid_row = table->get_grid_row(row - 1);
ConfigOptionInt & cur_option = dynamic_cast<ConfigOptionInt &>((*grid_row)[(ObjectGridTable::GridColType) col]);
wxBitmap* bitmap = table->get_color_bitmap((cur_option.value >= 1)?cur_option.value-1:cur_option.value);
int bitmap_width = bitmap->GetWidth();
int bitmap_height = bitmap->GetHeight();
int offset_x = grid_cell_border_width;
int offset_y = (rect.height > bitmap_height)?(rect.height - bitmap_height)/2 : grid_cell_border_height;
wxBitmap *bitmap = table->get_color_bitmap((cur_option.value >= 1) ? cur_option.value - 1 : cur_option.value);
int bitmap_width = bitmap->GetWidth();
int bitmap_height = bitmap->GetHeight();
int offset_x = grid_cell_border_width;
int offset_y = (rect.height > bitmap_height) ? (rect.height - bitmap_height) / 2 : grid_cell_border_height;
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(wxBrush(attr.GetBackgroundColour()));
dc.DrawRectangle(rect);
dc.DrawBitmap(*bitmap, wxPoint(rect.x + offset_x, rect.y + offset_y));
text_rect.x += bitmap_width + grid_cell_border_width *2;
text_rect.width -= (bitmap_width + grid_cell_border_width *2);
text_rect.x += bitmap_width + grid_cell_border_width * 2;
text_rect.width -= (bitmap_width + grid_cell_border_width * 2);
}
//wxGridCellChoiceRenderer::Draw(grid, attr, dc, rect, row, col, isSelected);
}
wxSize GridCellFilamentsRenderer::GetBestSize(wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, int WXUNUSED(row), int WXUNUSED(col))
{
wxSize size{48, -1};
return size;
}
GridCellFilamentsRenderer *GridCellFilamentsRenderer::Clone() const { return new GridCellFilamentsRenderer(); }
// ----------------------------------------------------------------------------
// GridCellFilamentsRenderer
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// GridCellChoiceEditor
// ----------------------------------------------------------------------------
GridCellChoiceEditor::GridCellChoiceEditor(const wxArrayString &choices)
: wxGridCellChoiceEditor(choices)
{}
GridCellChoiceEditor::GridCellChoiceEditor(size_t count, const wxString choices[])
: wxGridCellChoiceEditor(count, choices)
{}
wxGridCellEditor *GridCellChoiceEditor::Clone() const
{
GridCellChoiceEditor *editor = new GridCellChoiceEditor;
editor->m_allowOthers = m_allowOthers;
editor->m_choices = m_choices;
return editor;
}
void GridCellChoiceEditor::Create(wxWindow *parent, wxWindowID id, wxEvtHandler *evtHandler)
{
int style = wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB | wxBORDER_NONE;
if (!m_allowOthers) style |= wxCB_READONLY;
::ComboBox *bitmap_combo = new ComboBox(parent, id, wxEmptyString, wxDefaultPosition, wxSize(100, -1), 0, nullptr, wxCB_READONLY);
bitmap_combo->SetFont(::Label::Body_12);
int array_count = m_choices.GetCount();
for (int i = 0; i < array_count; i++) {
bitmap_combo->Append(m_choices[i]);
}
m_control = bitmap_combo;
wxGridCellEditor::Create(parent, id, evtHandler);
}
void GridCellChoiceEditor::SetSize(const wxRect &rect)
{
wxGridCellChoiceEditor::SetSize(rect);
}
void GridCellChoiceEditor::OnComboCloseUp(wxCommandEvent &evt) { wxGridCellChoiceEditor::OnComboCloseUp(evt); }
void GridCellChoiceEditor::BeginEdit(int row, int col, wxGrid *grid)
{
wxGridCellEditorEvtHandler *evtHandler = NULL;
if (m_control) {
// This event handler is needed to properly dismiss the editor when the popup is closed
m_control->Bind(wxEVT_COMBOBOX_CLOSEUP, &GridCellChoiceEditor::OnComboCloseUp, this);
evtHandler = wxDynamicCast(m_control->GetEventHandler(), wxGridCellEditorEvtHandler);
}
// Don't immediately end if we get a kill focus event within BeginEdit
if (evtHandler) evtHandler->SetInSetFocus(true);
m_value = grid->GetTable()->GetValue(row, col);
// Reset(); // this updates combo box to correspond to m_value
int pos = Combo()->FindString(m_value);
if (pos == wxNOT_FOUND) pos = 0;
Combo()->SetSelection(pos);
Combo()->SetFocus();
#ifdef __WXOSX_COCOA__
// This is a work around for the combobox being simply dismissed when a
// choice is made in it under OS X. The bug is almost certainly due to a
// problem in focus events generation logic but it's not obvious to fix and
// for now this at least allows to use wxGrid.
//Combo()->Popup();
#endif
if (evtHandler) {
// When dropping down the menu, a kill focus event
// happens after this point, so we can't reset the flag yet.
#if !defined(__WXGTK20__)
evtHandler->SetInSetFocus(false);
#endif
}
}
bool GridCellChoiceEditor::EndEdit(int WXUNUSED(row), int WXUNUSED(col), const wxGrid *WXUNUSED(grid), const wxString &WXUNUSED(oldval), wxString *newval)
{
const wxString value = Combo()->GetValue();
if (value == m_value) return false;
m_value = value;
if (newval) *newval = value;
return true;
}
wxGridActivationResult GridCellChoiceEditor::TryActivate(int row, int col, wxGrid *grid, const wxGridActivationSource &actSource)
{
ObjectGridTable * table = dynamic_cast<ObjectGridTable *>(grid->GetTable());
ObjectGridTable::ObjectGridCol *grid_col = table->get_grid_col(col);
ObjectGridTable::ObjectGridRow *grid_row = table->get_grid_row(row - 1);
if (actSource.GetOrigin() == wxGridActivationSource::Key) {
const wxKeyEvent &key_event = actSource.GetKeyEvent();
int keyCode = key_event.GetKeyCode();
wxString choice;
int digital_value = keyCode - '0';
if ((digital_value >= 1) && (digital_value <= 9))
m_cached_value = digital_value;
else
m_cached_value = -1;
if (m_cached_value != -1) {
if (m_cached_value <= grid_col->choice_count) {
choice = grid_col->choices[m_cached_value - 1];
return wxGridActivationResult::DoChange(choice);
} else {
return wxGridActivationResult::DoNothing();
}
} else
return wxGridActivationResult::DoNothing();
} else {
m_cached_value = -1;
return wxGridActivationResult::DoEdit();
}
}
void GridCellChoiceEditor::DoActivate(int row, int col, wxGrid *grid)
{
if (m_cached_value != -1) {
ObjectGridTable * table = dynamic_cast<ObjectGridTable *>(grid->GetTable());
ObjectGridTable::ObjectGridCol *grid_col = table->get_grid_col(col);
ObjectGridTable::ObjectGridRow *grid_row = table->get_grid_row(row - 1);
if (m_cached_value <= grid_col->choice_count) {
wxString choice = grid_col->choices[m_cached_value - 1];
table->SetValue(row, col, choice);
// Combo()->SetValue(choice);
}
m_cached_value = -1;
}
}
void GridCellComboBoxRenderer::Draw(wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, const wxRect &rect, int row, int col, bool isSelected)
{
ObjectGridTable *table = dynamic_cast<ObjectGridTable *>(grid.GetTable());
wxRect text_rect = rect;
if (table) {
ObjectGridTable::ObjectGridCol *grid_col = table->get_grid_col(col);
ObjectGridTable::ObjectGridRow *grid_row = table->get_grid_row(row - 1);
ConfigOptionInt & cur_option = dynamic_cast<ConfigOptionInt &>((*grid_row)[(ObjectGridTable::GridColType) col]);
wxBitmap *bitmap = table->get_color_bitmap((cur_option.value >= 1) ? cur_option.value - 1 : cur_option.value);
int bitmap_width = bitmap->GetWidth();
int bitmap_height = bitmap->GetHeight();
int offset_x = grid_cell_border_width;
int offset_y = (rect.height > bitmap_height) ? (rect.height - bitmap_height) / 2 : grid_cell_border_height;
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(wxBrush(attr.GetBackgroundColour()));
dc.DrawRectangle(rect);
dc.DrawBitmap(*bitmap, wxPoint(rect.x + offset_x, rect.y + offset_y));
text_rect.x += bitmap_width + grid_cell_border_width * 2;
text_rect.width -= (bitmap_width + grid_cell_border_width * 2);
}
wxGridCellChoiceRenderer::Draw(grid, attr, dc, text_rect, row, col, isSelected);
}
wxSize GridCellFilamentsRenderer::GetBestSize(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
int WXUNUSED(row),
int WXUNUSED(col))
wxSize GridCellComboBoxRenderer::GetBestSize(wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, int WXUNUSED(row), int WXUNUSED(col))
{
wxSize size{128, -1};
wxSize size{48, -1};
return size;
}
GridCellFilamentsRenderer *GridCellFilamentsRenderer::Clone() const
{
return new GridCellFilamentsRenderer();
}
GridCellComboBoxRenderer *GridCellComboBoxRenderer::Clone() const { return new GridCellComboBoxRenderer(); }
// ----------------------------------------------------------------------------
// wxGridCellSupportEditor
@ -466,7 +643,58 @@ void GridCellSupportRenderer::Draw(wxGrid& grid,
wxRendererNative::Get().DrawCheckBox( &grid, dc, text_rect, flags );
}*/
wxGridCellBoolRenderer::Draw(grid, attr, dc, rect, row, col, isSelected);
//wxGridCellBoolRenderer::Draw(grid, attr, dc, rect, row, col, isSelected);
ObjectGridTable * table = dynamic_cast<ObjectGridTable *>(grid.GetTable());
ObjectGridTable::ObjectGridCol *grid_col = table->get_grid_col(col);
ObjectGridTable::ObjectGridRow *grid_row = table->get_grid_row(row - 1);
ConfigOptionBool & cur_option = dynamic_cast<ConfigOptionBool &>((*grid_row)[(ObjectGridTable::GridColType) col]);
auto height = grid.GetRowSize(row);
auto width = grid.GetColSize(col);
wxGridCellRenderer::Draw(grid, attr, dc, rect, row, col, isSelected);
if (cur_option.value) {
auto check_on = create_scaled_bitmap("check_on", nullptr, 18);
dc.SetPen(*wxTRANSPARENT_PEN);
auto offsetx = 0;
auto offsety = 0;
#ifdef __WXOSX_MAC__
offsetx = (width - 18) / 2;
offsety = (height - 18) / 2;
#else
offsetx = (width - check_on.GetSize().x) / 2;
offsety = (height - check_on.GetSize().y) / 2;
#endif // __WXOSX_MAC__
dc.DrawBitmap(check_on, rect.x + offsetx, rect.y + offsety);
//dc.SetBrush(wxBrush(wxColour(0x00, 0xAE, 0x42)));
//dc.DrawBitmap(check_on, (width - check_on.GetSize().x) / 2, (height - check_on.GetSize().y) / 2);
} else {
auto check_off = create_scaled_bitmap("check_off_focused", nullptr, 18);
dc.SetPen(*wxTRANSPARENT_PEN);
auto offsetx = 0;
auto offsety = 0;
#ifdef __WXOSX_MAC__
offsetx = (width - 18) / 2;
offsety = (height - 18) / 2;
#else
offsetx = (width - check_off.GetSize().x) / 2;
offsety = (height - check_off.GetSize().y) / 2;
#endif // __WXOSX_MAC__
dc.DrawBitmap(check_off, rect.x + offsetx, rect.y + offsety);
//dc.SetBrush(wxBrush(wxColour(0x00, 0xAE, 0x42)));
//dc.DrawBitmap(check_off, (width - check_off.GetSize().x) / 2, (height - check_off.GetSize().y) / 2);
}
}
wxSize GridCellSupportRenderer::GetBestSize(wxGrid& grid,
@ -1497,6 +1725,7 @@ wxString ObjectGridTable::convert_filament_string(int index, wxString& filament_
else
result_str = filament_str;
result_str = "";
return result_str;
}
@ -1515,12 +1744,12 @@ void ObjectGridTable::init_cols(ObjectGrid *object_grid)
// printable for object
ObjectGridCol* col = new ObjectGridCol(coBool, "printable", ObjectGridTable::category_all, true, false, true, false, wxALIGN_CENTRE);
ObjectGridCol *col = new ObjectGridCol(coBool, "printable", ObjectGridTable::category_all, true, false, true, false, wxALIGN_CENTRE);
col->size = object_grid->GetTextExtent(L("Printable")).x;
m_col_data.push_back(col);
// reset icon for printable
col = new ObjectGridCol(coBool, "printable_reset", ObjectGridTable::category_all, true, true, false, false, wxALIGN_CENTRE);
col = new ObjectGridCol(coBool, "printable_reset", ObjectGridTable::category_all, true, true, false, false, wxALIGN_LEFT);
m_col_data.push_back(col);
//first column for plate_index
@ -1532,7 +1761,7 @@ void ObjectGridTable::init_cols(ObjectGrid *object_grid)
m_col_data.push_back(col);*/
//3th column: for object/volume name
col = new ObjectGridCol(coString, "name", ObjectGridTable::category_all, false, false, true, false, wxALIGN_CENTRE);
col = new ObjectGridCol(coString, "name", ObjectGridTable::category_all, false, false, true, false, wxALIGN_LEFT);
col->size = 200;
m_col_data.push_back(col);
@ -1549,21 +1778,21 @@ void ObjectGridTable::init_cols(ObjectGrid *object_grid)
m_col_data.push_back(col);
//object layer height
col = new ObjectGridCol(coFloat, "layer_height", L("Quality"), true, false, true, true, wxALIGN_CENTRE);
col->size = object_grid->GetTextExtent(L("Layer height")).x;
col = new ObjectGridCol(coFloat, "layer_height", L("Quality"), true, false, true, true, wxALIGN_CENTRE);
col->size = object_grid->GetTextExtent(L("Layer height")).x - 28;
m_col_data.push_back(col);
//reset icon for extruder_id
col = new ObjectGridCol(coFloat, "layer_height_reset", L("Quality"), true, true, false, false, wxALIGN_CENTRE);
col = new ObjectGridCol(coFloat, "layer_height_reset", L("Quality"), true, true, false, false, wxALIGN_LEFT);
m_col_data.push_back(col);
//object/volume perimeters
col = new ObjectGridCol(coInt, "wall_loops", L("Strength"), false, false, true, true, wxALIGN_CENTRE);
col = new ObjectGridCol(coInt, "wall_loops", L("Strength"), false, false, true, true, wxALIGN_CENTRE);
col->size = object_grid->GetTextExtent(L("Wall loops")).x;
m_col_data.push_back(col);
//reset icon for perimeters
col = new ObjectGridCol(coInt, "wall_loops_reset", L("Strength"), false, true, false, false, wxALIGN_CENTRE);
col = new ObjectGridCol(coInt, "wall_loops_reset", L("Strength"), false, true, false, false, wxALIGN_LEFT);
m_col_data.push_back(col);
//object/volume fill density
@ -1572,7 +1801,7 @@ void ObjectGridTable::init_cols(ObjectGrid *object_grid)
m_col_data.push_back(col);
//reset icon for fill density
col = new ObjectGridCol(coPercent, "fill_density_reset", L("Strength"), false, true, false, false, wxALIGN_CENTRE);
col = new ObjectGridCol(coPercent, "fill_density_reset", L("Strength"), false, true, false, false, wxALIGN_LEFT);
m_col_data.push_back(col);
//support material
@ -1585,23 +1814,23 @@ void ObjectGridTable::init_cols(ObjectGrid *object_grid)
m_col_data.push_back(col);
//Bed Adhesion
col = new ObjectGridCol(coEnum, "brim_type", L("Support"), true, false, true, true, wxALIGN_CENTRE);
col = new ObjectGridCol(coEnum, "brim_type", L("Support"), true, false, true, true, wxALIGN_LEFT);
col->size = object_grid->GetTextExtent(L("Auto Brim")).x + 8; //add 8 for border
col->choices = brim_choices;
col->choice_count = WXSIZEOF(brim_choices);
m_col_data.push_back(col);
//reset icon for Bed Adhesion
col = new ObjectGridCol(coEnum, "brim_type_reset", L("Support"), true, true, false, false, wxALIGN_CENTRE);
col = new ObjectGridCol(coEnum, "brim_type_reset", L("Support"), true, true, false, false, wxALIGN_LEFT);
m_col_data.push_back(col);
//object/volume speed
col = new ObjectGridCol(coFloat, "inner_wall_speed", L("Speed"), false, false, true, true, wxALIGN_CENTRE);
col = new ObjectGridCol(coFloat, "inner_wall_speed", L("Speed"), false, false, true, true, wxALIGN_LEFT);
col->size = object_grid->GetTextExtent(L("Inner wall speed")).x;
m_col_data.push_back(col);
//reset icon for speed
col = new ObjectGridCol(coFloat, "inner_wall_speed_reset", L("Speed"), false, true, false, false, wxALIGN_CENTRE);
col = new ObjectGridCol(coFloat, "inner_wall_speed_reset", L("Speed"), false, true, false, false, wxALIGN_LEFT);
m_col_data.push_back(col);
return;
@ -1922,17 +2151,20 @@ void ObjectGridTable::update_row_properties()
switch (grid_col->type)
{
case coString:
grid_table->SetCellEditor(row, col, new wxGridCellAutoWrapStringEditor());
grid_table->SetCellRenderer(row, col, new wxGridCellAutoWrapStringRenderer());
if (col == ObjectGridTable::col_plate_index)
grid_table->SetReadOnly(row, col);
grid_table->SetCellEditor(row, col, new GridCellTextEditor());
//grid_table->SetCellRenderer(row, col, new wxGridCellAutoWrapStringRenderer());
grid_table->SetCellFitMode(row, col, wxGridFitMode::Ellipsize());
break;
case coBool:
grid_table->SetCellEditor(row, col, new GridCellSupportEditor());
//grid_table->SetCellEditor(row, col, new wxGridCellBoolEditor());
//grid_table->SetCellRenderer(row, col, new GridCellSupportRenderer());
grid_table->SetCellRenderer(row, col, new wxGridCellBoolRenderer());
grid_table->SetCellRenderer(row, col, new GridCellSupportRenderer());
break;
case coInt:
grid_table->SetCellEditor(row, col, new wxGridCellNumberEditor());
grid_table->SetCellEditor(row, col, new GridCellTextEditor());
grid_table->SetCellRenderer(row, col, new wxGridCellNumberRenderer());
break;
case coEnum:
@ -1940,26 +2172,21 @@ void ObjectGridTable::update_row_properties()
GridCellFilamentsEditor *filament_editor = new GridCellFilamentsEditor(grid_col->choice_count, grid_col->choices, false, &m_panel->m_color_bitmaps);
grid_table->SetCellEditor(row, col, filament_editor);
grid_table->SetCellRenderer(row, col, new GridCellFilamentsRenderer());
}
else
grid_table->SetCellEditor(row, col, new wxGridCellChoiceEditor(grid_col->choice_count, grid_col->choices));
} else {
GridCellChoiceEditor *combo_editor = new GridCellChoiceEditor(grid_col->choice_count, grid_col->choices);
grid_table->SetCellEditor(row, col, combo_editor);
grid_table->SetCellRenderer(row, col, new wxGridCellChoiceRenderer());
//new wxGridCellChoiceEditor(grid_col->choice_count, grid_col->choices));
}
break;
case coFloat:
grid_table->SetCellEditor(row, col, new wxGridCellFloatEditor(6,2));
grid_table->SetCellRenderer(row, col, new wxGridCellFloatRenderer(6,2));
grid_table->SetCellEditor(row, col, new GridCellTextEditor());
grid_table->SetCellRenderer(row, col, new wxGridCellFloatRenderer(6,1));
break;
case coPercent:
{
/*wxGridCellFloatEditor *float_editor = new wxGridCellFloatEditor(6,2);
wxFloatingPointValidator<float> *float_validator = new wxFloatingPointValidator<float>(3, nullptr, wxNUM_VAL_ZERO_AS_BLANK);
float_validator->SetRange(0.f, 100.f);
float_editor->SetValidator(*float_validator);
if (rows < 3)
m_object_grid->SetCellEditor(row, col, float_editor);
else*/
grid_table->SetCellEditor(row, col, new wxGridCellFloatEditor(6,2));
grid_table->SetCellRenderer(row, col, new wxGridCellFloatRenderer(6,2));
grid_table->SetCellEditor(row, col, new GridCellTextEditor());
grid_table->SetCellRenderer(row, col, new wxGridCellFloatRenderer(6,1));
break;
}
default:
@ -2049,7 +2276,7 @@ void ObjectGridTable::sort_row_data(compare_row_func sort_func)
std::copy(new_grid_rows.begin(), new_grid_rows.end(), m_grid_data.begin());
new_grid_rows.clear();
update_row_properties();
//update_row_properties();
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" finished, this %1%, row_data size %2%") %this % m_grid_data.size();
}
@ -2165,7 +2392,7 @@ bool ObjectGridTable::OnCellLeftClick(int row, int col, ConfigOptionType &type)
if (row == 0) {
sort_by_col(col);
} else if (col >= col_name) {
} else if (col >= col_printable_reset) {
ObjectGridRow *grid_row = m_grid_data[row - 1];
ObjectGridCol* grid_col = m_col_data[col];
ObjectGridCol* grid_col_2 = m_col_data[col - 1];
@ -2401,11 +2628,10 @@ ObjectTablePanel::ObjectTablePanel( wxWindow* parent, wxWindowID id, const wxPoi
//m_object_grid_table->SetAttrProvider(new MyGridCellAttrProvider);
//m_object_grid->AssignTable(m_object_grid_table);
m_side_window = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxSize(FromDIP(460),FromDIP(480)), wxVSCROLL);
m_side_window = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxSize(FromDIP(440),FromDIP(480)), wxVSCROLL);
m_side_window->SetScrollRate( 0, 5 );
m_page_sizer = new wxBoxSizer(wxVERTICAL);
m_page_top_sizer = new wxBoxSizer(wxHORIZONTAL);
//m_page_top_sizer = new wxBoxSizer(wxHORIZONTAL);
m_side_window->SetBackgroundColour(wxColour(0xff, 0xff, 0xff));
m_side_window->SetSizer(m_page_sizer);
m_side_window->SetScrollbars(1, 20, 1, 2);
@ -2444,7 +2670,7 @@ ObjectTablePanel::ObjectTablePanel( wxWindow* parent, wxWindowID id, const wxPoi
m_side_window->SetFont(::Label::Body_12);
m_object_settings = new ObjectTableSettings(m_side_window, m_object_grid_table);
m_object_settings->Hide();
m_page_sizer->Add(m_page_top_sizer, 0, wxEXPAND | wxALIGN_CENTER_HORIZONTAL, 0);
//m_page_sizer->Add(m_page_top_sizer, 0, wxALIGN_CENTER_HORIZONTAL, 0);
m_page_sizer->Add(m_object_settings->get_sizer(), 1, wxEXPAND | wxALL, 2 );
auto m_line_left = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(1,-1), wxTAB_TRAVERSAL);
@ -2464,7 +2690,7 @@ ObjectTablePanel::ObjectTablePanel( wxWindow* parent, wxWindowID id, const wxPoi
int ObjectTablePanel::init_bitmap()
{
m_undo_bitmap = create_scaled_bitmap("lock_normal", nullptr, 24);
m_undo_bitmap = create_scaled_bitmap("lock_normal", nullptr, 18);
m_color_bitmaps = get_extruder_color_icons();
return 0;
@ -2535,33 +2761,39 @@ void ObjectTablePanel::load_data()
//construct tables
//m_object_grid->CreateGrid(rows, cols, wxGridSelectCells);
#if HAS_COL_HEADER
m_object_grid->SetColLabelValue(ObjectGridTable::col_printable, L("Printable"));
m_object_grid->SetColLabelAlignment(wxALIGN_LEFT, wxALIGN_CENTER);
m_object_grid->SetColLabelValue(ObjectGridTable::col_printable, _L("Printable"));
m_object_grid->SetColLabelValue(ObjectGridTable::col_printable_reset, "");
m_object_grid->SetColLabelValue(ObjectGridTable::col_plate_index, L("Plate"));
m_object_grid->SetColLabelValue(ObjectGridTable::col_plate_index, _L("Plate"));
/*m_object_grid->SetColLabelValue(ObjectGridTable::col_assemble_name, L("Module"));*/
m_object_grid->SetColLabelValue(ObjectGridTable::col_name, L("Name"));
m_object_grid->SetColLabelValue(ObjectGridTable::col_filaments, L("Filament"));
m_object_grid->SetColLabelValue(ObjectGridTable::col_name, _L("Name"));
m_object_grid->SetColLabelValue(ObjectGridTable::col_filaments, _L("Filament"));
m_object_grid->SetColLabelValue(ObjectGridTable::col_filaments_reset, "");
m_object_grid->SetColLabelValue(ObjectGridTable::col_layer_height, L("Layer height"));
m_object_grid->SetColLabelValue(ObjectGridTable::col_layer_height, _L("Layer height"));
m_object_grid->SetColLabelValue(ObjectGridTable::col_layer_height_reset, "");
m_object_grid->SetColLabelValue(ObjectGridTable::col_wall_loops, L("Wall loops"));
m_object_grid->SetColLabelValue(ObjectGridTable::col_wall_loops, _L("Wall loops"));
m_object_grid->SetColLabelValue(ObjectGridTable::col_wall_loops_reset, "");
m_object_grid->SetColLabelValue(ObjectGridTable::col_fill_density, L("Infill density(%)"));
m_object_grid->SetColLabelValue(ObjectGridTable::col_fill_density, _L("Infill density(%)"));
m_object_grid->SetColLabelValue(ObjectGridTable::col_fill_density_reset, "");
m_object_grid->SetColLabelValue(ObjectGridTable::col_enable_support, L("Support"));
m_object_grid->SetColLabelValue(ObjectGridTable::col_enable_support, _L("Support"));
m_object_grid->SetColLabelValue(ObjectGridTable::col_enable_support_reset, "");
m_object_grid->SetColLabelValue(ObjectGridTable::col_brim_type, L("Brim"));
m_object_grid->SetColLabelValue(ObjectGridTable::col_brim_type, _L("Brim"));
m_object_grid->SetColLabelValue(ObjectGridTable::col_brim_type_reset, "");
m_object_grid->SetColLabelValue(ObjectGridTable::col_speed_perimeter, L("Inner wall speed"));
m_object_grid->SetColLabelValue(ObjectGridTable::col_speed_perimeter, _L("Inner wall speed"));
m_object_grid->SetColLabelValue(ObjectGridTable::col_speed_perimeter_reset, "");
m_object_grid->SetLabelFont(Label::Head_13);
m_object_grid->SetLabelTextColour(wxColour(0x30,0x3a,0x3c));
m_object_grid->SetLabelBackgroundColour(wxColour(0xff,0xff,0xff));
m_object_grid->SetLabelBackgroundColour(wxColour(0xff, 0xff, 0xff));
#else
m_object_grid->HideColLabels();
#endif
m_object_grid->HideRowLabels();
m_object_grid->EnableGridLines (true);
m_object_grid->EnableGridLines (false);
m_object_grid->EnableDragColSize(false);
m_object_grid->EnableDragGridSize(false);
m_object_grid->EnableDragRowSize(false);
/*set the first row as label*/
//format
@ -2570,7 +2802,7 @@ void ObjectTablePanel::load_data()
//attr->SetBackgroundColour(wxColour(191, 191, 255));
attr->SetBackgroundColour(*wxWHITE);
attr->SetTextColour(*wxBLACK);
attr->SetAlignment(wxALIGN_CENTRE, wxALIGN_CENTRE);
attr->SetAlignment(wxALIGN_LEFT, wxALIGN_CENTRE);
attr->SetReadOnly(true);
m_object_grid->SetRowAttr (0, attr);
#if HAS_COL_HEADER
@ -2580,7 +2812,7 @@ void ObjectTablePanel::load_data()
m_object_grid->SetCellSize(0, ObjectGridTable::col_printable, 1, 2);
//m_object_grid->SetCellSize(0, ObjectGridTable::col_assemble_name, 1, 1);
m_object_grid->SetCellSize(0, ObjectGridTable::col_name, 1, 1);
m_object_grid->SetCellSize(0, ObjectGridTable::col_filaments, 1, 2);
m_object_grid->SetCellSize(0, ObjectGridTable::col_filaments, 1, 1);
m_object_grid->SetCellSize(0, ObjectGridTable::col_layer_height, 1, 2);
m_object_grid->SetCellSize(0, ObjectGridTable::col_wall_loops, 1, 2);
m_object_grid->SetCellSize(0, ObjectGridTable::col_fill_density, 1, 2);
@ -2588,14 +2820,8 @@ void ObjectTablePanel::load_data()
m_object_grid->SetCellSize(0, ObjectGridTable::col_brim_type, 1, 2);
m_object_grid->SetCellSize(0, ObjectGridTable::col_speed_perimeter, 1, 2);
//m_object_grid->SetSelectionForeground(wxColour(255, 0, 0));
//m_object_grid->SetSelectionBackground(wxColour(0, 255, 0));
//wxGridCellAutoWrapStringEditor* string_editor = new wxGridCellAutoWrapStringEditor();
//wxGridCellBoolEditor* bool_editor = new wxGridCellBoolEditor();
//wxGridCellFloatEditor* float_editor = new wxGridCellFloatEditor();
//wxGridCellNumberEditor* number_editor = new wxGridCellNumberEditor();
//wxGridCellChoiceEditor* choice_editor = new wxGridCellChoiceEditor();
//wxGridCellEnumEditor* enum_editor = new wxGridCellEnumEditor();
//m_object_grid->SetSelectionForeground(wxColour(0xDB,0xFD,0xE7));
//m_object_grid->SetSelectionBackground(*wxWHITE);
for (int col = 0; col < cols; col++)
{
@ -2627,45 +2853,39 @@ void ObjectTablePanel::load_data()
switch (grid_col->type)
{
case coString:
m_object_grid->SetCellEditor(row, col, new wxGridCellAutoWrapStringEditor());
m_object_grid->SetCellRenderer(row, col, new wxGridCellAutoWrapStringRenderer());
m_object_grid->SetCellEditor(row, col, new GridCellTextEditor());
//m_object_grid->SetCellRenderer(row, col, new wxGridCellAutoWrapStringRenderer());
m_object_grid->SetCellFitMode(row, col, wxGridFitMode::Ellipsize());
break;
case coBool:
m_object_grid->SetCellEditor(row, col, new GridCellSupportEditor());
//m_object_grid->SetCellEditor(row, col, new wxGridCellBoolEditor());
//m_object_grid->SetCellRenderer(row, col, new GridCellSupportRenderer());
m_object_grid->SetCellRenderer(row, col, new wxGridCellBoolRenderer());
m_object_grid->SetCellRenderer(row, col, new GridCellSupportRenderer());
break;
case coInt:
m_object_grid->SetCellEditor(row, col, new wxGridCellNumberEditor());
m_object_grid->SetCellEditor(row, col, new GridCellTextEditor());
m_object_grid->SetCellRenderer(row, col, new wxGridCellNumberRenderer());
break;
case coEnum:
if (col == ObjectGridTable::col_filaments) {
GridCellFilamentsEditor *filament_editor = new GridCellFilamentsEditor(grid_col->choice_count, grid_col->choices, false, &m_color_bitmaps);
m_object_grid->SetCellEditor(row, col, filament_editor);
//m_object_grid->SetCellEditor(row, col, new wxGridCellChoiceEditor(grid_col->choice_count, grid_col->choices));
m_object_grid->SetCellRenderer(row, col, new GridCellFilamentsRenderer());
} else {
GridCellChoiceEditor *combo_editor = new GridCellChoiceEditor(grid_col->choice_count, grid_col->choices);
m_object_grid->SetCellEditor(row, col, combo_editor);
m_object_grid->SetCellRenderer(row, col, new wxGridCellChoiceRenderer());
}
else
m_object_grid->SetCellEditor(row, col, new wxGridCellChoiceEditor(grid_col->choice_count, grid_col->choices));
break;
case coFloat:
m_object_grid->SetCellEditor(row, col, new wxGridCellFloatEditor(6,2));
m_object_grid->SetCellRenderer(row, col, new wxGridCellFloatRenderer(6,2));
m_object_grid->SetCellEditor(row, col, new GridCellTextEditor());
m_object_grid->SetCellRenderer(row, col, new wxGridCellFloatRenderer(6,1));
break;
case coPercent:
{
/*wxGridCellFloatEditor *float_editor = new wxGridCellFloatEditor(6,2);
wxFloatingPointValidator<float> *float_validator = new wxFloatingPointValidator<float>(3, nullptr, wxNUM_VAL_ZERO_AS_BLANK);
float_validator->SetRange(0.f, 100.f);
float_editor->SetValidator(*float_validator);
if (rows < 3)
m_object_grid->SetCellEditor(row, col, float_editor);
else*/
m_object_grid->SetCellEditor(row, col, new wxGridCellFloatEditor(6,2));
m_object_grid->SetCellRenderer(row, col, new wxGridCellFloatRenderer(6,2));
m_object_grid->SetCellEditor(row, col, new GridCellTextEditor());
m_object_grid->SetCellRenderer(row, col, new wxGridCellFloatRenderer(6,1));
break;
}
default:
@ -2681,34 +2901,98 @@ void ObjectTablePanel::load_data()
}
}
}
m_object_grid->Fit();
for (int i = 0; i < ObjectGridTable::col_max; i++)
{
ObjectGridTable::ObjectGridCol *grid_col = m_object_grid_table->get_grid_col(i);
if (grid_col->size > 0) {
int fit_size1 = m_object_grid->GetColSize(i);
m_object_grid->SetColSize(i, grid_col->size);
//if (grid_col->size < fit_size1) m_object_grid->SetColSize(i, grid_col->size);
}
}
m_object_grid->Fit();
for (int i = 0; i < ObjectGridTable::col_max; i++) {
switch (i) {
case ObjectGridTable::col_printable: {
m_object_grid->SetColSize(i, m_object_grid->GetColSize(i) - FromDIP(28));
break;
}
//else {
//adjust the left col
//int delta = grid_col->size - fit_size1;
//grid_col = m_object_grid_table->get_grid_col(i - 1);
//int fit_size2 = m_object_grid->GetColSize(i-1);
//grid_col->size = fit_size2 - delta;
//m_object_grid->SetColSize(i, grid_col->size);
//}
case ObjectGridTable::col_printable_reset:
m_object_grid->SetColSize(i, FromDIP(28));
break;
case ObjectGridTable::col_name:
m_object_grid->SetColSize(i, FromDIP(100));
break;
case ObjectGridTable::col_filaments:
m_object_grid->SetColSize(i, FromDIP(52));
break;
case ObjectGridTable::col_filaments_reset:
m_object_grid->SetColSize(i, FromDIP(28));
break;
case ObjectGridTable::col_layer_height: {
auto width = m_object_grid->GetColSize(i) - FromDIP(28);
if (width < m_object_grid->GetTextExtent(("000.00")).x) {
width = m_object_grid->GetTextExtent(("000.00")).x;
}
m_object_grid->SetColSize(i, width);
break;
}
case ObjectGridTable::col_layer_height_reset:
m_object_grid->SetColSize(i, FromDIP(28));
break;
case ObjectGridTable::col_wall_loops:
m_object_grid->SetColSize(i, m_object_grid->GetColSize(i) - FromDIP(28));
break;
case ObjectGridTable::col_wall_loops_reset:
m_object_grid->SetColSize(i, FromDIP(28));
break;
case ObjectGridTable::col_fill_density:
m_object_grid->SetColSize(i, m_object_grid->GetColSize(i) - FromDIP(28));
break;
case ObjectGridTable::col_fill_density_reset:
m_object_grid->SetColSize(i, FromDIP(28));
break;
case ObjectGridTable::col_enable_support:
m_object_grid->SetColSize(i, m_object_grid->GetColSize(i) - FromDIP(28));
break;
case ObjectGridTable::col_enable_support_reset:
m_object_grid->SetColSize(i, FromDIP(28));
break;
case ObjectGridTable::col_brim_type:
m_object_grid->SetColSize(i, FromDIP(56));
break;
case ObjectGridTable::col_brim_type_reset:
m_object_grid->SetColSize(i, FromDIP(28));
break;
case ObjectGridTable::col_speed_perimeter: {
auto width = m_object_grid->GetColSize(i) - FromDIP(28);
if (width < m_object_grid->GetTextExtent(("000.00")).x) { width = m_object_grid->GetTextExtent(("000.00")).x; }
m_object_grid->SetColSize(i, width);
break;
}
case ObjectGridTable::col_speed_perimeter_reset:
m_object_grid->SetColSize(i, FromDIP(28));
break;
}
}
//set col size after fit
/* ObjectGridTable::ObjectGridCol* grid_col = m_object_grid_table->get_grid_col(ObjectGridTable::col_brim_type);
grid_col->size = m_object_grid->GetTextExtent(grid_col->choices[0]).x + 30;
m_object_grid->SetColSize(ObjectGridTable::col_brim_type, grid_col->size);
grid_col = m_object_grid_table->get_grid_col(ObjectGridTable::col_filaments);
grid_col->size = 128;
m_object_grid->SetColSize(ObjectGridTable::col_filaments, grid_col->size);*/
m_object_grid->SetGridLineColour(*wxWHITE);
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(", finished, got %1% rows, %2% cols") %m_object_grid_table->GetNumberRows() %m_object_grid_table->GetNumberCols() ;
}
@ -2794,7 +3078,6 @@ void ObjectTablePanel::OnSelectCell( wxGridEvent& ev )
m_cur_row = row;
m_cur_col = col;
ev.Skip();
}
@ -2866,7 +3149,7 @@ void ObjectTablePanel::resetAllValuesInSideWindow(int row, bool is_object, Model
// ObjectTableDialog
// ----------------------------------------------------------------------------
ObjectTableDialog::ObjectTableDialog(wxWindow* parent, Plater* platerObj, Model *modelObj, wxSize maxSize)
: GUI::DPIDialog(parent, wxID_ANY, _L("Object/Part Setting"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX | wxRESIZE_BORDER)
: GUI::DPIDialog(parent, wxID_ANY, _L("Object/Part Setting"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
,
m_model(modelObj), m_plater(platerObj)
{
@ -2906,6 +3189,7 @@ ObjectTableDialog::ObjectTableDialog(wxWindow* parent, Plater* platerObj, Model
m_main_sizer->Add(m_line_top, 0, wxEXPAND, 0);
m_obj_panel = new ObjectTablePanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxEmptyString, m_plater, m_model);
m_obj_panel->SetBackgroundColour(wxColour(0x00,0xAE,0x42));
//m_top_sizer->Add(m_obj_panel, 1, wxALL | wxEXPAND, 5);
wxSize panel_size = m_obj_panel->get_init_size();
@ -2937,19 +3221,20 @@ ObjectTableDialog::ObjectTableDialog(wxWindow* parent, Plater* platerObj, Model
//this->Layout();
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", created, this %1%, m_obj_panel %2%") %this % m_obj_panel;
m_main_sizer->Add(m_obj_panel, 1, wxEXPAND|wxTOP,2);
m_main_sizer->Add(m_obj_panel, 1, wxEXPAND|wxLEFT,FromDIP(10));
SetSizer(m_main_sizer);
Layout();
Fit();
Layout();
}
ObjectTableDialog::~ObjectTableDialog()
{
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", this %1%, m_obj_panel %2%") %this % m_obj_panel;
#ifdef __WXOSX_MAC__
if (m_obj_panel) {
delete m_obj_panel;
m_obj_panel = nullptr;
}
#endif
}
void ObjectTableDialog::Popup(int obj_idx, int vol_idx, wxPoint position /*= wxDefaultPosition*/)
@ -2957,7 +3242,8 @@ void ObjectTableDialog::Popup(int obj_idx, int vol_idx, wxPoint position /*= wxD
m_obj_panel->sort_by_default();
m_obj_panel->SetSelection(obj_idx, vol_idx);
this->SetPosition(position);
//this->SetPosition(position);
Centre(wxBOTH);
this->ShowModal();
}
@ -2981,23 +3267,88 @@ void ObjectTableDialog::on_sys_color_changed()
void ObjectTableDialog::OnClose(wxCloseEvent &evt)
{
this->GetSize(&g_dialog_width, &g_dialog_height);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", g_dialog_width %1%, g_dialog_height %2%") %g_dialog_width % g_dialog_height;
#ifdef __WINDOWS__
if (m_obj_panel) {
delete m_obj_panel;
m_obj_panel = nullptr;
}
DestroyChildren();
Destroy();
#endif
#ifdef __WXOSX_MAC__
evt.Skip();
#endif
}
void ObjectTableDialog::OnSize(wxSizeEvent& event)
{
SetSize(wxSize(-1, FromDIP(480)));
SetMinSize(wxSize(-1, FromDIP(480)));
SetMaxSize(wxSize(-1, FromDIP(480)));
return;
wxSize new_size = event.GetSize();
if ((new_size.GetWidth() > g_dialog_max_width) || (new_size.GetHeight() > g_dialog_max_height)) {
int width = (new_size.GetWidth() > g_dialog_max_width)?new_size.GetWidth():g_dialog_max_width;
int height = (new_size.GetHeight() > g_dialog_max_height)?new_size.GetHeight():g_dialog_max_height;
this->SetMaxSize(wxSize(width, height));
}
event.Skip();
//SetSize(wxSize(-1, FromDIP(480)));
//SetMinSize(wxSize(-1, FromDIP(480)));
//SetMaxSize(wxSize(-1, FromDIP(480)));
//return;
//wxSize new_size = event.GetSize();
//if ((new_size.GetWidth() > g_dialog_max_width) || (new_size.GetHeight() > g_dialog_max_height)) {
// int width = (new_size.GetWidth() > g_dialog_max_width)?new_size.GetWidth():g_dialog_max_width;
// int height = (new_size.GetHeight() > g_dialog_max_height)?new_size.GetHeight():g_dialog_max_height;
// this->SetMaxSize(wxSize(width, height));
//}
//event.Skip();
}
// ----------------------------------------------------------------------------
// GridCellTextEditor
// ----------------------------------------------------------------------------
GridCellTextEditor::GridCellTextEditor() : wxGridCellTextEditor() {}
GridCellTextEditor::~GridCellTextEditor() {}
void GridCellTextEditor::Create(wxWindow *parent, wxWindowID id, wxEvtHandler *evtHandler)
{
::TextInput *text_input = new ::TextInput(parent, wxEmptyString, wxEmptyString, wxEmptyString, wxDefaultPosition, wxSize(-1, -1), wxTE_PROCESS_ENTER);
m_control = text_input;
wxGridCellEditor::Create(parent, id, evtHandler);
}
void GridCellTextEditor::StartingKey(wxKeyEvent &event) {}
void GridCellTextEditor::SetSize(const wxRect &rect) { wxGridCellTextEditor::SetSize(rect); }
void GridCellTextEditor::BeginEdit(int row, int col, wxGrid *grid)
{
ObjectGridTable * table = dynamic_cast<ObjectGridTable *>(grid->GetTable());
ObjectGridTable::ObjectGridCol *grid_col = table->get_grid_col(col);
ObjectGridTable::ObjectGridRow *grid_row = table->get_grid_row(row - 1);
auto val = table->GetValue(row, col);
Text()->GetTextCtrl()->SetValue(val);
Text()->SetFocus();
}
bool GridCellTextEditor::EndEdit(int row, int col, const wxGrid *grid, const wxString &WXUNUSED(oldval), wxString *newval)
{
ObjectGridTable * table = dynamic_cast<ObjectGridTable *>(grid->GetTable());
ObjectGridTable::ObjectGridCol *grid_col = table->get_grid_col(col);
ObjectGridTable::ObjectGridRow *grid_row = table->get_grid_row(row - 1);
wxCHECK_MSG(m_control, false, "wxGridCellTextEditor must be created first!");
const wxString value = Text()->GetTextCtrl()->GetValue();
if (value == m_value) return false;
m_value = value;
if (newval) *newval = m_value;
return true;
}
void GridCellTextEditor::ApplyEdit(int row, int col, wxGrid *grid)
{
grid->GetTable()->SetValue(row, col, m_value);
m_value.clear();
}
} // namespace GUI

View file

@ -23,6 +23,10 @@
#include "OptionsGroup.hpp"
#include "GUI_Factories.hpp"
#include "GUI_ObjectTableSettings.hpp"
#include "Widgets/TextInput.hpp"
class ComboBox;
class TextInput;
namespace Slic3r {
@ -50,11 +54,31 @@ public:
virtual GridCellIconRenderer *Clone() const wxOVERRIDE;
};
// the editor for string data allowing to choose from the list of strings
class GridCellTextEditor : public wxGridCellTextEditor
{
public:
GridCellTextEditor();
~GridCellTextEditor();
virtual void Create(wxWindow *parent, wxWindowID id, wxEvtHandler *evtHandler) wxOVERRIDE;
void StartingKey(wxKeyEvent &event) wxOVERRIDE;
virtual void SetSize(const wxRect &rect) wxOVERRIDE;
virtual void BeginEdit(int row, int col, wxGrid *grid) wxOVERRIDE;
virtual bool EndEdit(int row, int col, const wxGrid *grid, const wxString &oldval, wxString *newval) wxOVERRIDE;
virtual void ApplyEdit(int row, int col, wxGrid *grid) wxOVERRIDE;
protected:
::TextInput *Text() const { return (::TextInput *) m_control; }
wxDECLARE_NO_COPY_CLASS(GridCellTextEditor);
private:
wxString m_value;
};
class GridCellFilamentsEditor : public wxGridCellChoiceEditor
{
public:
// if !allowOthers, user can't type a string not in choices array
GridCellFilamentsEditor(size_t count = 0,
const wxString choices[] = NULL,
bool allowOthers = false,
@ -78,7 +102,7 @@ public:
virtual void DoActivate(int row, int col, wxGrid* grid) wxOVERRIDE;
protected:
wxBitmapComboBox *Combo() const { return (wxBitmapComboBox *)m_control; }
::ComboBox *Combo() const { return (::ComboBox *)m_control; }
void OnComboCloseUp(wxCommandEvent& evt);
std::vector<wxBitmap*>* m_icons;
@ -108,6 +132,44 @@ public:
virtual GridCellFilamentsRenderer *Clone() const wxOVERRIDE;
};
class GridCellChoiceEditor : public wxGridCellChoiceEditor
{
public:
GridCellChoiceEditor(size_t count = 0, const wxString choices[] = NULL);
GridCellChoiceEditor(const wxArrayString &choices);
virtual void Create(wxWindow *parent, wxWindowID id, wxEvtHandler *evtHandler) wxOVERRIDE;
virtual void SetSize(const wxRect &rect) wxOVERRIDE;
virtual wxGridCellEditor *Clone() const wxOVERRIDE;
virtual void BeginEdit(int row, int col, wxGrid *grid) wxOVERRIDE;
virtual bool EndEdit(int row, int col, const wxGrid *grid, const wxString &oldval, wxString *newval) wxOVERRIDE;
virtual wxGridActivationResult TryActivate(int row, int col, wxGrid *grid, const wxGridActivationSource &actSource) wxOVERRIDE;
virtual void DoActivate(int row, int col, wxGrid *grid) wxOVERRIDE;
protected:
::ComboBox *Combo() const { return (::ComboBox *) m_control; }
void OnComboCloseUp(wxCommandEvent &evt);
wxDECLARE_NO_COPY_CLASS(GridCellChoiceEditor);
private:
int m_cached_value{-1};
};
class GridCellComboBoxRenderer : public wxGridCellChoiceRenderer
{
public:
virtual void Draw(wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, const wxRect &rect, int row, int col, bool isSelected) wxOVERRIDE;
virtual wxSize GetBestSize(wxGrid &WXUNUSED(grid), wxGridCellAttr &attr, wxDC &dc, int WXUNUSED(row), int WXUNUSED(col)) wxOVERRIDE;
virtual GridCellComboBoxRenderer *Clone() const wxOVERRIDE;
};
class GridCellSupportEditor : public wxGridCellBoolEditor
{
public:
@ -115,7 +177,6 @@ public:
virtual void DoActivate(int row, int col, wxGrid* grid) wxOVERRIDE;
private:
// These functions modify or use m_value.
void SetValueFromGrid(int row, int col, wxGrid* grid);
void SetGridFromValue(int row, int col, wxGrid* grid) const;
@ -150,6 +211,7 @@ public:
virtual GridCellSupportRenderer *Clone() const wxOVERRIDE;
};
//ObjectGrid for the param setting table
class ObjectGrid : public wxGrid
{

View file

@ -22,6 +22,10 @@ namespace Slic3r
namespace GUI
{
wxDEFINE_EVENT(EVT_LOCK_DISABLE, wxCommandEvent);
wxDEFINE_EVENT(EVT_LOCK_ENABLE, wxCommandEvent);
OTG_Settings::OTG_Settings(wxWindow* parent, const bool staticbox) :
m_parent(parent)
{
@ -162,10 +166,23 @@ bool ObjectTableSettings::update_settings_list(bool is_object, bool is_multiple_
auto btn = new ScalableButton(parent, wxID_ANY, m_bmp_reset);
btn->SetToolTip(_(L("Reset parameter")));
#ifdef __WINDOWS__
btn->SetBackgroundColour(*wxWHITE);
#endif // DEBUG
btn->SetBitmapFocus(m_bmp_reset_focus.bmp());
btn->SetBitmapHover(m_bmp_reset_focus.bmp());
#ifdef __WINDOWS__
btn->SetBitmapDisabled(m_bmp_reset_disable.bmp());
#endif
#ifdef __WXOSX_MAC__
btn->Bind(EVT_LOCK_DISABLE, [this, btn](auto &e) { btn->SetBitmap(m_bmp_reset_disable.bmp()); });
btn->Bind(EVT_LOCK_ENABLE, [this, btn](auto &e) { btn->SetBitmap(m_bmp_reset_focus.bmp()); });
#endif
btn->Bind(wxEVT_BUTTON, [btn, opt_key, this, is_object, object, config, group_category](wxEvent &event) {
//wxGetApp().plater()->take_snapshot(from_u8((boost::format(_utf8(L("Reset Option %s"))) % opt_key).str()));
@ -185,6 +202,14 @@ bool ObjectTableSettings::update_settings_list(bool is_object, bool is_multiple_
m_current_config.apply(config->get(), true);
update_config_values(is_object, object, config, group_category);
this->m_parent->Thaw();
#ifdef __WXOSX_MAC__
if (!btn->IsEnabled()) {
btn->SetBitmap(m_bmp_reset_disable.bmp());
} else {
btn->SetBitmap(m_bmp_reset_focus.bmp());
}
#endif
});
(const_cast<Line&>(line)).extra_widget_win = btn;
return btn;
@ -211,7 +236,9 @@ bool ObjectTableSettings::update_settings_list(bool is_object, bool is_multiple_
ctrl->SetBitmap_(m_bmp_reset);
ctrl->SetBitmapFocus(m_bmp_reset_focus.bmp());
ctrl->SetBitmapHover(m_bmp_reset_focus.bmp());
#ifdef __WINDOWS__
ctrl->SetBitmapDisabled(m_bmp_reset_disable.bmp());
#endif
};
const bool is_extruders_cat = cat.first == "Extruders";
@ -308,10 +335,22 @@ int ObjectTableSettings::update_extra_column_visible_status(ConfigOptionsGroup*
if (line) {
if ((config->has(opt.name)) && reset_window&&reset_window->IsEnabled()) {
line->extra_widget_win->Enable();
#ifdef __WXOSX_MAC__
wxCommandEvent event(EVT_LOCK_ENABLE);
event.SetEventObject(line->extra_widget_win);
wxPostEvent(line->extra_widget_win, event);
#endif
count++;
}
else
} else {
line->extra_widget_win->Disable();
#ifdef __WXOSX_MAC__
wxCommandEvent event(EVT_LOCK_DISABLE);
event.SetEventObject(line->extra_widget_win);
wxPostEvent(line->extra_widget_win, event);
#endif
}
}
}
wxGridSizer* grid_sizer = option_group->get_grid_sizer();

View file

@ -76,7 +76,8 @@ public:
void resetAllValues(int row, bool is_object, ModelObject* object, ModelConfig* config, const std::string& category);
void msw_rescale();
};
wxDECLARE_EVENT(EVT_LOCK_DISABLE, wxCommandEvent);
wxDECLARE_EVENT(EVT_LOCK_ENABLE, wxCommandEvent);
}}
#endif // slic3r_GUI_ObjectTableSettings_hpp_

View file

@ -78,6 +78,7 @@ bool View3D::init(wxWindow* parent, Bed3D& bed, Model* model, DynamicPrintConfig
//BBS: GUI refactor: GLToolbar
m_canvas->enable_select_plate_toolbar(false);
m_canvas->enable_assemble_view_toolbar(true);
m_canvas->enable_separator_toolbar(true);
m_canvas->enable_labels(true);
m_canvas->enable_slope(true);
@ -446,40 +447,45 @@ void Preview::update_layers_slider_mode()
// multi-extruder printer profile , but whole model is printed by only one extruder
// false -> multi-extruder printer profile , and model is printed by several extruders
bool one_extruder_printed_model = true;
bool can_change_color = true;
// extruder used for whole model for multi-extruder printer profile
int only_extruder = -1;
// BBS
if (wxGetApp().filaments_cnt() > 1) {
const ModelObjectPtrs &objects = wxGetApp().plater()->model().objects;
//const ModelObjectPtrs& objects = wxGetApp().plater()->model().objects;
auto plate_extruders = wxGetApp().plater()->get_partplate_list().get_curr_plate()->get_extruders();
for (auto extruder : plate_extruders) {
if (extruder != plate_extruders[0])
can_change_color = false;
}
// check if whole model uses just only one extruder
if (!objects.empty()) {
const int extruder = objects[0]->config.has("extruder") ? objects[0]->config.option("extruder")->getInt() : 0;
if (!plate_extruders.empty()) {
//const int extruder = objects[0]->config.has("extruder") ? objects[0]->config.option("extruder")->getInt() : 0;
const int extruder = plate_extruders[0];
only_extruder = extruder;
// auto is_one_extruder_printed_model = [objects, extruder]() {
// for (ModelObject *object : objects) {
// if (object->config.has("extruder") && object->config.option("extruder")->getInt() != extruder) /*return false*/;
auto is_one_extruder_printed_model = [objects, extruder]() {
for (ModelObject *object : objects) {
if (object->config.has("extruder") && object->config.option("extruder")->getInt() != extruder) return false;
// for (ModelVolume *volume : object->volumes)
// if ((volume->config.has("extruder") && volume->config.option("extruder")->getInt() != extruder) || !volume->mmu_segmentation_facets.empty()) return false;
for (ModelVolume *volume : object->volumes)
if ((volume->config.has("extruder") && volume->config.option("extruder")->getInt() != extruder) || !volume->mmu_segmentation_facets.empty()) return false;
// for (const auto &range : object->layer_config_ranges)
// if (range.second.has("extruder") && range.second.option("extruder")->getInt() != extruder) return false;
// }
// return true;
// };
for (const auto &range : object->layer_config_ranges)
if (range.second.has("extruder") && range.second.option("extruder")->getInt() != extruder) return false;
}
return true;
};
if (is_one_extruder_printed_model())
only_extruder = extruder;
else
one_extruder_printed_model = false;
// if (is_one_extruder_printed_model())
// only_extruder = extruder;
// else
// one_extruder_printed_model = false;
}
}
IMSlider *m_layers_slider = m_canvas->get_gcode_viewer().get_layers_slider();
m_layers_slider->SetModeAndOnlyExtruder(one_extruder_printed_model, only_extruder);
m_layers_slider->SetModeAndOnlyExtruder(one_extruder_printed_model, only_extruder, can_change_color);
}
void Preview::update_layers_slider_from_canvas(wxKeyEvent &event)
@ -763,6 +769,7 @@ bool AssembleView::init(wxWindow* parent, Bed3D& bed, Model* model, DynamicPrint
//BBS: GUI refactor: GLToolbar
m_canvas->enable_assemble_view_toolbar(false);
m_canvas->enable_return_toolbar(true);
m_canvas->enable_separator_toolbar(false);
// BBS: set volume_selection_mode to Volume
m_canvas->get_selection().set_volume_selection_mode(Selection::Volume);

View file

@ -450,7 +450,7 @@ bool generate_image(const std::string &filename, wxImage &image, wxSize img_size
if (method == GERNERATE_IMAGE_RESIZE) {
float h_factor = img.GetHeight() / (float) image.GetHeight();
float w_factor = img.GetWidth() / (float) image.GetWidth();
float factor = std::max(h_factor, w_factor);
float factor = std::min(h_factor, w_factor);
int tar_height = (int) ((float) img.GetHeight() / factor);
int tar_width = (int) ((float) img.GetWidth() / factor);
img = img.Rescale(tar_width, tar_height);
@ -465,9 +465,11 @@ bool generate_image(const std::string &filename, wxImage &image, wxSize img_size
return false;
}
image.ConvertAlphaToMask(image.GetMaskRed(), image.GetMaskGreen(), image.GetMaskBlue());
//image.ConvertAlphaToMask(image.GetMaskRed(), image.GetMaskGreen(), image.GetMaskBlue());
return true;
}
std::deque<wxDialog*> dialogStack;
}
}

View file

@ -104,6 +104,8 @@ struct DpiChangedEvent : public wxEvent {
wxDECLARE_EVENT(EVT_DPI_CHANGED_SLICER, DpiChangedEvent);
#endif // !wxVERSION_EQUAL_OR_GREATER_THAN
extern std::deque<wxDialog*> dialogStack;
template<class P> class DPIAware : public P
{
public:
@ -189,6 +191,19 @@ public:
event.Skip();
on_sys_color_changed();
});
if (std::is_same<wxDialog, P>::value) {
this->Bind(wxEVT_CHAR_HOOK, [this](wxKeyEvent& e) {
if (e.GetKeyCode() == WXK_ESCAPE) {
//if (this->IsModal())
// this->EndModal(wxID_CANCEL);
//else
this->Close();
}
else
e.Skip();
});
}
}
virtual ~DPIAware() {}
@ -208,6 +223,14 @@ public:
on_sys_color_changed();
}
#endif
int ShowModal()
{
dialogStack.push_front(this);
int r = wxDialog::ShowModal();
dialogStack.pop_front();
return r;
}
protected:
virtual void on_dpi_changed(const wxRect &suggested_rect) = 0;

View file

@ -209,6 +209,7 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
GizmoImguiBegin(get_name(), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar);
// First calculate width of all the texts that are could possibly be shown. We will decide set the dialog width based on that:
const float space_size = m_imgui->get_style_scaling() * 8;
const float clipping_slider_left = m_imgui->calc_text_size(m_desc.at("clipping_of_view")).x + m_imgui->scaled(1.5f);
const float cursor_slider_left = m_imgui->calc_text_size(m_desc.at("cursor_size")).x + m_imgui->scaled(1.5f);
const float gap_fill_slider_left = m_imgui->calc_text_size(m_desc.at("gap_fill")).x + m_imgui->scaled(1.5f);
@ -220,7 +221,6 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
const float tips_width = m_imgui->calc_text_size(_L("Auto support threshold angle: ") + " 90 ").x + m_imgui->scaled(1.5f);
const float minimal_slider_width = m_imgui->scaled(4.f);
float slider_width_times = 1.5;
float caption_max = 0.f;
float total_text_max = 0.f;
@ -233,12 +233,10 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
const float sliders_left_width = std::max(std::max(cursor_slider_left, clipping_slider_left), std::max(highlight_slider_left, gap_fill_slider_left));
const float slider_icon_width = m_imgui->get_slider_icon_size().x;
float window_width = minimal_slider_width + sliders_left_width + slider_icon_width;
const float max_tooltip_width = ImGui::GetFontSize() * 20.0f;
window_width = std::max(window_width, total_text_max);
window_width = std::max(window_width, buttons_width);
window_width = std::max(window_width, tips_width);
const float sliders_width = m_imgui->scaled(7.0f);
const float drag_left_width = ImGui::GetStyle().WindowPadding.x + sliders_left_width + sliders_width - space_size;
float drag_pos_times = 0.7;
@ -252,15 +250,22 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
if (i != 0) ImGui::SameLine((empty_button_width + m_imgui->scaled(1.75f)) * i + m_imgui->scaled(1.3f));
if (m_current_tool == tool_icons[i]) {
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.81f, 0.81f, 0.81f, 1.0f)); // r, g, b, a
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.81f, 0.81f, 0.81f, 1.0f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.81f, 0.81f, 0.81f, 1.0f));
}
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0);
if (m_current_tool == tool_icons[i]) {
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.86f, 0.99f, 0.91f, 1.00f)); // r, g, b, a
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.86f, 0.99f, 0.91f, 1.00f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.86f, 0.99f, 0.91f, 1.00f));
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.00f, 0.68f, 0.26f, 1.00f));
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 1.0);
}
bool btn_clicked = ImGui::Button(into_u8(btn_name).c_str());
if (m_current_tool == tool_icons[i])
{
ImGui::PopStyleColor(4);
ImGui::PopStyleVar(2);
}
ImGui::PopStyleVar(1);
if (m_current_tool == tool_icons[i])ImGui::PopStyleColor(3);
if (btn_clicked && m_current_tool != tool_icons[i]) {
m_current_tool = tool_icons[i];
@ -287,9 +292,9 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
ImGui::AlignTextToFramePadding();
m_imgui->text(m_desc.at("cursor_size"));
ImGui::SameLine(sliders_left_width);
ImGui::PushItemWidth(window_width - sliders_left_width - slider_icon_width);
ImGui::PushItemWidth(sliders_width);
m_imgui->bbl_slider_float_style("##cursor_radius", &m_cursor_radius, CursorRadiusMin, CursorRadiusMax, "%.2f", 1.0f, true);
ImGui::SameLine(window_width - drag_pos_times * slider_icon_width);
ImGui::SameLine(drag_left_width);
ImGui::PushItemWidth(1.5 * slider_icon_width);
ImGui::BBLDragFloat("##cursor_radius_input", &m_cursor_radius, 0.05f, 0.0f, 0.0f, "%.2f");
} else if (m_current_tool == ImGui::SphereButtonIcon) {
@ -299,9 +304,9 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
ImGui::AlignTextToFramePadding();
m_imgui->text(m_desc.at("cursor_size"));
ImGui::SameLine(sliders_left_width);
ImGui::PushItemWidth(window_width - sliders_left_width - slider_icon_width);
ImGui::PushItemWidth(sliders_width);
m_imgui->bbl_slider_float_style("##cursor_radius", &m_cursor_radius, CursorRadiusMin, CursorRadiusMax, "%.2f", 1.0f, true);
ImGui::SameLine(window_width - drag_pos_times * slider_icon_width);
ImGui::SameLine(drag_left_width);
ImGui::PushItemWidth(1.5 * slider_icon_width);
ImGui::BBLDragFloat("##cursor_radius_input", &m_cursor_radius, 0.05f, 0.0f, 0.0f, "%.2f");
} else if (m_current_tool == ImGui::FillButtonIcon) {
@ -312,13 +317,13 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
m_imgui->text(m_desc.at("smart_fill_angle"));
std::string format_str = std::string("%.f") + I18N::translate_utf8("", "Face angle threshold, placed after the number with no whitespace in between.");
ImGui::SameLine(sliders_left_width);
ImGui::PushItemWidth(window_width - sliders_left_width - slider_icon_width);
ImGui::PushItemWidth(sliders_width);
if (m_imgui->bbl_slider_float_style("##smart_fill_angle", &m_smart_fill_angle, SmartFillAngleMin, SmartFillAngleMax, format_str.data(), 1.0f, true))
for (auto& triangle_selector : m_triangle_selectors) {
triangle_selector->seed_fill_unselect_all_triangles();
triangle_selector->request_update_render_data();
}
ImGui::SameLine(window_width - drag_pos_times * slider_icon_width);
ImGui::SameLine(drag_left_width);
ImGui::PushItemWidth(1.5 * slider_icon_width);
ImGui::BBLDragFloat("##smart_fill_angle_input", &m_smart_fill_angle, 0.05f, 0.0f, 0.0f, "%.2f");
} else if (m_current_tool == ImGui::GapFillIcon) {
@ -328,10 +333,10 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
ImGui::AlignTextToFramePadding();
m_imgui->text(m_desc["gap_area"] + ":");
ImGui::SameLine(sliders_left_width);
ImGui::PushItemWidth(window_width - sliders_left_width - slider_icon_width);
ImGui::PushItemWidth(sliders_width);
std::string format_str = std::string("%.2f") + I18N::translate_utf8("", "Triangle patch area threshold,""triangle patch will be merged to neighbor if its area is less than threshold");
m_imgui->bbl_slider_float_style("##gap_area", &TriangleSelectorPatch::gap_area, TriangleSelectorPatch::GapAreaMin, TriangleSelectorPatch::GapAreaMax, format_str.data(), 1.0f, true);
ImGui::SameLine(window_width - drag_pos_times * slider_icon_width);
ImGui::SameLine(drag_left_width);
ImGui::PushItemWidth(1.5 * slider_icon_width);
ImGui::BBLDragFloat("##gap_area_input", &TriangleSelectorPatch::gap_area, 0.05f, 0.0f, 0.0f, "%.2f");
}
@ -349,7 +354,7 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
ImGui::SetCursorPosY(slider_start_position_y);
std::string format_str = std::string("%.f");
ImGui::PushItemWidth(window_width - sliders_left_width - slider_icon_width);
ImGui::PushItemWidth(sliders_width);
wxString tooltip = _L("Highlight faces according to overhang angle.");
if (m_imgui->bbl_slider_float_style("##angle_threshold_deg", &m_highlight_by_angle_threshold_deg, 0.f, 90.f, format_str.data(), 1.0f, true, tooltip)) {
m_parent.set_slope_normal_angle(90.f - m_highlight_by_angle_threshold_deg);
@ -369,7 +374,7 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
}
ImGui::EndTooltip();
}
ImGui::SameLine(window_width - drag_pos_times * slider_icon_width);
ImGui::SameLine(drag_left_width);
ImGui::PushItemWidth(1.5 * slider_icon_width);
ImGui::BBLDragFloat("##angle_threshold_deg_input", &m_highlight_by_angle_threshold_deg, 0.05f, 0.0f, 0.0f, "%.2f");
@ -380,10 +385,10 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
auto clp_dist = float(m_c->object_clipper()->get_position());
ImGui::SameLine(sliders_left_width);
ImGui::PushItemWidth(window_width - sliders_left_width - slider_icon_width);
ImGui::PushItemWidth(sliders_width);
bool b_bbl_slider_float = m_imgui->bbl_slider_float_style("##clp_dist", &clp_dist, 0.f, 1.f, "%.2f", 1.0f, true);
ImGui::SameLine(window_width - drag_pos_times * slider_icon_width);
ImGui::SameLine(drag_left_width);
ImGui::PushItemWidth(1.5 * slider_icon_width);
bool b_drag_input = ImGui::BBLDragFloat("##clp_dist_input", &clp_dist, 0.05f, 0.0f, 0.0f, "%.2f");

View file

@ -328,16 +328,16 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
// BBS
ImGuiWrapper::push_toolbar_style(m_parent.get_scale());
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8.0f, 16.0f));
GizmoImguiBegin(get_name(), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar);
// First calculate width of all the texts that are could possibly be shown. We will decide set the dialog width based on that:
const float clipping_slider_left = m_imgui->calc_text_size(m_desc.at("clipping_of_view")).x + m_imgui->scaled(1.f);
const float cursor_slider_left = m_imgui->calc_text_size(m_desc.at("cursor_size")).x + m_imgui->scaled(1.f);
const float space_size = m_imgui->get_style_scaling() * 8;
const float clipping_slider_left = m_imgui->calc_text_size(m_desc.at("clipping_of_view")).x + m_imgui->scaled(1.5f);
const float cursor_slider_left = m_imgui->calc_text_size(m_desc.at("cursor_size")).x + m_imgui->scaled(1.5f);
const float smart_fill_slider_left = m_imgui->calc_text_size(m_desc.at("smart_fill_angle")).x + m_imgui->scaled(1.5f);
const float edge_detect_slider_left = m_imgui->calc_text_size(m_desc.at("edge_detection")).x + m_imgui->scaled(1.f);
const float gap_area_slider_left = m_imgui->calc_text_size(m_desc.at("gap_area")).x + m_imgui->scaled(1.5f);
const float height_range_slider_left = m_imgui->calc_text_size(m_desc.at("height_range")).x + m_imgui->scaled(1.5f);
const float gap_area_slider_left = m_imgui->calc_text_size(m_desc.at("gap_area")).x + m_imgui->scaled(1.5f) + space_size;
const float height_range_slider_left = m_imgui->calc_text_size(m_desc.at("height_range")).x + m_imgui->scaled(2.f);
const float remove_btn_width = m_imgui->calc_text_size(m_desc.at("remove_all")).x + m_imgui->scaled(1.f);
const float filter_btn_width = m_imgui->calc_text_size(m_desc.at("perform")).x + m_imgui->scaled(1.f);
@ -358,7 +358,7 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
const float height_max_width = std::max(clipping_slider_left,height_range_slider_left);
const float sliders_left_width = std::max(smart_fill_slider_left,
std::max(cursor_slider_left, std::max(edge_detect_slider_left, std::max(gap_area_slider_left, std::max(height_range_slider_left,
clipping_slider_left)))));
clipping_slider_left))))) + space_size;
const float slider_icon_width = m_imgui->get_slider_icon_size().x;
float window_width = minimal_slider_width + sliders_left_width + slider_icon_width;
const int max_filament_items_per_line = 8;
@ -369,8 +369,10 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
window_width = std::max(window_width, buttons_width);
window_width = std::max(window_width, max_filament_items_per_line * filament_item_width + +m_imgui->scaled(0.5f));
const float sliders_width = m_imgui->scaled(7.0f);
const float drag_left_width = ImGui::GetStyle().WindowPadding.x + sliders_width - space_size;
const float max_tooltip_width = ImGui::GetFontSize() * 20.0f;
float slider_width_times = 1.5;
ImDrawList * draw_list = ImGui::GetWindowDrawList();
ImVec2 pos = ImGui::GetCursorScreenPos();
static float color_button_high = 25.0;
@ -383,14 +385,15 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
float start_pos_x = ImGui::GetCursorPos().x;
const ImVec2 max_label_size = ImGui::CalcTextSize("99", NULL, true);
const float item_spacing = m_imgui->scaled(0.8f);
for (int extruder_idx = 0; extruder_idx < m_extruders_colors.size(); extruder_idx++) {
size_t n_extruder_colors = std::min((size_t)EnforcerBlockerType::ExtruderMax, m_extruders_colors.size());
for (int extruder_idx = 0; extruder_idx < n_extruder_colors; extruder_idx++) {
const std::array<float, 4> &extruder_color = m_extruders_colors[extruder_idx];
ImVec4 color_vec(extruder_color[0], extruder_color[1], extruder_color[2], extruder_color[3]);
std::string color_label = std::string("##extruder color ") + std::to_string(extruder_idx);
std::string item_text = std::to_string(extruder_idx + 1);
const ImVec2 label_size = ImGui::CalcTextSize(item_text.c_str(), NULL, true);
const ImVec2 button_size(max_label_size.x + m_imgui->scaled(0.5f), 0.f);
const ImVec2 button_size(max_label_size.x + m_imgui->scaled(0.5f),0.f);
float button_offset = start_pos_x;
if (extruder_idx % max_filament_items_per_line != 0) {
@ -402,13 +405,19 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
ImGuiColorEditFlags flags = ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_NoTooltip;
if (m_selected_extruder_idx != extruder_idx) flags |= ImGuiColorEditFlags_NoBorder;
#ifdef __APPLE__
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.4f, 0.4f, 0.4f, 1.0f));
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.00f, 0.68f, 0.26f, 1.00f));
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0);
bool color_picked = ImGui::ColorButton(color_label.c_str(), color_vec, flags, button_size);
ImGui::PopStyleVar(1);
ImGui::PopStyleVar(2);
ImGui::PopStyleColor(1);
#else
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.00f, 0.68f, 0.26f, 1.00f));
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 2.0);
bool color_picked = ImGui::ColorButton(color_label.c_str(), color_vec, flags, button_size);
ImGui::PopStyleVar(2);
ImGui::PopStyleColor(1);
#endif
color_button_high = ImGui::GetCursorPos().y - color_button - 2.0;
if (color_picked) { m_selected_extruder_idx = extruder_idx; }
@ -418,12 +427,14 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
// draw filament id
float gray = 0.299 * extruder_color[0] + 0.587 * extruder_color[1] + 0.114 * extruder_color[2];
ImGui::SameLine(button_offset + (button_size.x - label_size.x) / 2.f);
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, {10.0,15.0});
if (gray * 255.f < 80.f)
ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, 1.0f), item_text.c_str());
else
ImGui::TextColored(ImVec4(0.0f, 0.0f, 0.0f, 1.0f), item_text.c_str());
}
ImGui::PopStyleVar();
}
//ImGui::NewLine();
ImGui::Dummy(ImVec2(0.0f, ImGui::GetFontSize() * 0.1));
@ -432,20 +443,26 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
std::array<wchar_t, 6> tool_icons = { ImGui::CircleButtonIcon,ImGui::SphereButtonIcon, ImGui::TriangleButtonIcon, ImGui::HeightRangeIcon, ImGui::FillButtonIcon, ImGui::GapFillIcon };
std::array<wxString, 6> tool_tips = { _L("Circle"), _L("Sphere"), _L("Triangle"), _L("Height Range"), _L("Fill"), _L("Gap Fill") };
for (int i = 0; i < tool_icons.size(); i++) {
std::string str_label = std::string("##");
std::string str_label = std::string("");
std::wstring btn_name = tool_icons[i] + boost::nowide::widen(str_label);
if (i != 0) ImGui::SameLine((empty_button_width + m_imgui->scaled(1.75f)) * i + m_imgui->scaled(0.5f));
if (m_current_tool == tool_icons[i]) {
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.81f, 0.81f, 0.81f, 1.0f)); // r, g, b, a
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.81f, 0.81f, 0.81f, 1.0f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.81f, 0.81f, 0.81f, 1.0f));
}
if (i != 0) ImGui::SameLine((empty_button_width + m_imgui->scaled(1.75f)) * i + m_imgui->scaled(1.5f));
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0);
if (m_current_tool == tool_icons[i]) {
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.86f, 0.99f, 0.91f, 1.00f)); // r, g, b, a
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.86f, 0.99f, 0.91f, 1.00f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.86f, 0.99f, 0.91f, 1.00f));
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.00f, 0.68f, 0.26f, 1.00f));
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 1.0);
}
bool btn_clicked = ImGui::Button(into_u8(btn_name).c_str());
if (m_current_tool == tool_icons[i])
{
ImGui::PopStyleColor(4);
ImGui::PopStyleVar(2);
}
ImGui::PopStyleVar(1);
if (m_current_tool == tool_icons[i]) ImGui::PopStyleColor(3);
if (btn_clicked && m_current_tool != tool_icons[i]) {
m_current_tool = tool_icons[i];
@ -475,9 +492,9 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
ImGui::AlignTextToFramePadding();
m_imgui->text(m_desc.at("cursor_size"));
ImGui::SameLine(circle_max_width);
ImGui::PushItemWidth(window_width - circle_max_width - slider_width_times * slider_icon_width);
ImGui::PushItemWidth(sliders_width);
m_imgui->bbl_slider_float_style("##cursor_radius", &m_cursor_radius, CursorRadiusMin, CursorRadiusMax, "%.2f", 1.0f, true);
ImGui::SameLine(window_width - slider_icon_width);
ImGui::SameLine(drag_left_width + circle_max_width);
ImGui::PushItemWidth(1.5 * slider_icon_width);
ImGui::BBLDragFloat("##cursor_radius_input", &m_cursor_radius, 0.05f, 0.0f, 0.0f, "%.2f");
@ -488,9 +505,9 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
auto clp_dist = float(m_c->object_clipper()->get_position());
ImGui::SameLine(circle_max_width);
ImGui::PushItemWidth(window_width - circle_max_width - slider_width_times * slider_icon_width);
ImGui::PushItemWidth(sliders_width);
bool slider_clp_dist = m_imgui->bbl_slider_float_style("##clp_dist", &clp_dist, 0.f, 1.f, "%.2f", 1.0f, true);
ImGui::SameLine(window_width - slider_icon_width);
ImGui::SameLine(drag_left_width + circle_max_width);
ImGui::PushItemWidth(1.5 * slider_icon_width);
bool b_clp_dist_input = ImGui::BBLDragFloat("##clp_dist_input", &clp_dist, 0.05f, 0.0f, 0.0f, "%.2f");
@ -505,9 +522,9 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
auto clp_dist = float(m_c->object_clipper()->get_position());
ImGui::SameLine(clipping_slider_left);
ImGui::PushItemWidth(window_width - clipping_slider_left - slider_width_times * slider_icon_width);
ImGui::PushItemWidth(sliders_width);
bool slider_clp_dist = m_imgui->bbl_slider_float_style("##clp_dist", &clp_dist, 0.f, 1.f, "%.2f", 1.0f, true);
ImGui::SameLine(window_width - slider_icon_width);
ImGui::SameLine(drag_left_width + clipping_slider_left);
ImGui::PushItemWidth(1.5 * slider_icon_width);
bool b_clp_dist_input = ImGui::BBLDragFloat("##clp_dist_input", &clp_dist, 0.05f, 0.0f, 0.0f, "%.2f");
@ -524,13 +541,13 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
std::string format_str = std::string("%.f") + I18N::translate_utf8("°", "Face angle threshold,"
"placed after the number with no whitespace in between.");
ImGui::SameLine(sliders_left_width);
ImGui::PushItemWidth(window_width - sliders_left_width - slider_width_times * slider_icon_width);
ImGui::PushItemWidth(sliders_width);
if (m_imgui->bbl_slider_float_style("##smart_fill_angle", &m_smart_fill_angle, SmartFillAngleMin, SmartFillAngleMax, format_str.data(), 1.0f, true))
for (auto &triangle_selector : m_triangle_selectors) {
triangle_selector->seed_fill_unselect_all_triangles();
triangle_selector->request_update_render_data();
}
ImGui::SameLine(window_width - slider_icon_width);
ImGui::SameLine(drag_left_width + sliders_left_width);
ImGui::PushItemWidth(1.5 * slider_icon_width);
ImGui::BBLDragFloat("##smart_fill_angle_input", &m_smart_fill_angle, 0.05f, 0.0f, 0.0f, "%.2f");
} else {
@ -544,9 +561,9 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
auto clp_dist = float(m_c->object_clipper()->get_position());
ImGui::SameLine(sliders_left_width);
ImGui::PushItemWidth(window_width - sliders_left_width - slider_width_times * slider_icon_width);
ImGui::PushItemWidth(sliders_width);
bool slider_clp_dist = m_imgui->bbl_slider_float_style("##clp_dist", &clp_dist, 0.f, 1.f, "%.2f", 1.0f, true);
ImGui::SameLine(window_width - slider_icon_width);
ImGui::SameLine(drag_left_width + sliders_left_width);
ImGui::PushItemWidth(1.5 * slider_icon_width);
bool b_clp_dist_input = ImGui::BBLDragFloat("##clp_dist_input", &clp_dist, 0.05f, 0.0f, 0.0f, "%.2f");
@ -558,10 +575,10 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
ImGui::AlignTextToFramePadding();
m_imgui->text(m_desc["height_range"] + ":");
ImGui::SameLine(height_max_width);
ImGui::PushItemWidth(window_width - height_max_width - slider_width_times * slider_icon_width);
ImGui::PushItemWidth(sliders_width);
std::string format_str = std::string("%.2f") + I18N::translate_utf8("mm", "Heigh range," "Facet in [cursor z, cursor z + height] will be selected.");
m_imgui->bbl_slider_float_style("##cursor_height", &m_cursor_height, CursorHeightMin, CursorHeightMax, format_str.data(), 1.0f, true);
ImGui::SameLine(window_width - slider_icon_width);
ImGui::SameLine(drag_left_width + height_max_width);
ImGui::PushItemWidth(1.5 * slider_icon_width);
ImGui::BBLDragFloat("##cursor_height_input", &m_cursor_height, 0.05f, 0.0f, 0.0f, "%.2f");
@ -572,9 +589,9 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
auto clp_dist = float(m_c->object_clipper()->get_position());
ImGui::SameLine(height_max_width);
ImGui::PushItemWidth(window_width - height_max_width - slider_width_times * slider_icon_width);
ImGui::PushItemWidth(sliders_width);
bool slider_clp_dist = m_imgui->bbl_slider_float_style("##clp_dist", &clp_dist, 0.f, 1.f, "%.2f", 1.0f, true);
ImGui::SameLine(window_width - slider_icon_width);
ImGui::SameLine(drag_left_width + height_max_width);
ImGui::PushItemWidth(1.5 * slider_icon_width);
bool b_clp_dist_input = ImGui::BBLDragFloat("##clp_dist_input", &clp_dist, 0.05f, 0.0f, 0.0f, "%.2f");
@ -586,10 +603,10 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
ImGui::AlignTextToFramePadding();
m_imgui->text(m_desc["gap_area"] + ":");
ImGui::SameLine(gap_area_slider_left);
ImGui::PushItemWidth(window_width - gap_area_slider_left - slider_width_times * slider_icon_width);
ImGui::PushItemWidth(sliders_width);
std::string format_str = std::string("%.2f") + I18N::translate_utf8("", "Triangle patch area threshold,""triangle patch will be merged to neighbor if its area is less than threshold");
m_imgui->bbl_slider_float_style("##gap_area", &TriangleSelectorPatch::gap_area, TriangleSelectorPatch::GapAreaMin, TriangleSelectorPatch::GapAreaMax, format_str.data(), 1.0f, true);
ImGui::SameLine(window_width - slider_icon_width);
ImGui::SameLine(drag_left_width + gap_area_slider_left);
ImGui::PushItemWidth(1.5 * slider_icon_width);
ImGui::BBLDragFloat("##gap_area_input", &TriangleSelectorPatch::gap_area, 0.05f, 0.0f, 0.0f, "%.2f");
}
@ -638,7 +655,6 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
GizmoImguiEnd();
// BBS
ImGui::PopStyleVar(1);
ImGuiWrapper::pop_toolbar_style();
}
@ -689,7 +705,8 @@ void GLGizmoMmuSegmentation::init_model_triangle_selectors()
const TriangleMesh* mesh = &mv->mesh();
m_triangle_selectors.emplace_back(std::make_unique<TriangleSelectorPatch>(*mesh, ebt_colors, 0.2));
// Reset of TriangleSelector is done inside TriangleSelectorMmGUI's constructor, so we don't need it to perform it again in deserialize().
m_triangle_selectors.back()->deserialize(mv->mmu_segmentation_facets.get_data(), false);
EnforcerBlockerType max_ebt = (EnforcerBlockerType)std::min(m_extruders_colors.size(), (size_t)EnforcerBlockerType::ExtruderMax);
m_triangle_selectors.back()->deserialize(mv->mmu_segmentation_facets.get_data(), false, max_ebt);
m_triangle_selectors.back()->request_update_render_data();
m_volumes_extruder_idxs.push_back(mv->extruder_id());
}
@ -754,6 +771,7 @@ void GLGizmoMmuSegmentation::on_set_state()
if (get_state() == Off) {
ModelObject* mo = m_c->selection_info()->model_object();
if (mo) Slic3r::save_object_mesh(*mo);
m_parent.post_event(SimpleEvent(EVT_GLCANVAS_FORCE_UPDATE));
}
}

View file

@ -1091,7 +1091,7 @@ void TriangleSelectorPatch::render(ImGuiWrapper* imgui)
void TriangleSelectorPatch::update_triangles_per_type()
{
m_triangle_patches.resize((int)EnforcerBlockerType::ExtruderMax);
m_triangle_patches.resize((int)EnforcerBlockerType::ExtruderMax + 1);
for (int i = 0; i < m_triangle_patches.size(); i++) {
auto& patch = m_triangle_patches[i];
patch.type = (EnforcerBlockerType)i;

View file

@ -178,17 +178,11 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit)
GizmoImguiBegin(get_name(), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar);
// First calculate width of all the texts that are could possibly be shown. We will decide set the dialog width based on that:
const float space_size = m_imgui->get_style_scaling() * 8;
const float clipping_slider_left = std::max(m_imgui->calc_text_size(m_desc.at("clipping_of_view")).x,
m_imgui->calc_text_size(m_desc.at("reset_direction")).x)
+ m_imgui->scaled(1.5f);
const float cursor_size_slider_left = m_imgui->calc_text_size(m_desc.at("cursor_size")).x + m_imgui->scaled(1.f);
const float cursor_type_radio_left = m_imgui->calc_text_size(m_desc["cursor_type"]).x + m_imgui->scaled(1.f);
const float cursor_type_radio_sphere = m_imgui->calc_text_size(m_desc["sphere"]).x + m_imgui->scaled(2.5f);
const float cursor_type_radio_circle = m_imgui->calc_text_size(m_desc["circle"]).x + m_imgui->scaled(2.5f);
const float button_width = m_imgui->calc_text_size(m_desc.at("remove_all")).x + m_imgui->scaled(1.f);
const float minimal_slider_width = m_imgui->scaled(4.f);
const float empty_button_width = m_imgui->calc_button_size("").x;
float caption_max = 0.f;
@ -197,19 +191,12 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit)
caption_max = std::max(caption_max, m_imgui->calc_text_size(m_desc[t + "_caption"]).x);
total_text_max = std::max(total_text_max, m_imgui->calc_text_size(m_desc[t]).x);
}
total_text_max += caption_max + m_imgui->scaled(1.f);
caption_max += m_imgui->scaled(1.f);
float slider_width_times = 1.5;
const float sliders_left_width = std::max(cursor_size_slider_left, clipping_slider_left);
#if ENABLE_ENHANCED_IMGUI_SLIDER_FLOAT
const float slider_icon_width = m_imgui->get_slider_icon_size().x;
float window_width = minimal_slider_width + sliders_left_width + slider_icon_width;
#else
float window_width = minimal_slider_width + sliders_left_width;
#endif // ENABLE_ENHANCED_IMGUI_SLIDER_FLOAT
window_width = std::max(window_width, total_text_max);
window_width = std::max(window_width, button_width);
window_width = std::max(window_width, cursor_type_radio_left + cursor_type_radio_sphere + cursor_type_radio_circle);
const float sliders_width = m_imgui->scaled(7.0f);
const float drag_left_width = ImGui::GetStyle().WindowPadding.x + sliders_left_width + sliders_width - space_size;
const float max_tooltip_width = ImGui::GetFontSize() * 20.0f;
@ -222,17 +209,22 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit)
std::wstring btn_name = tool_icons[i] + boost::nowide::widen(str_label);
if (i != 0) ImGui::SameLine((empty_button_width + m_imgui->scaled(1.75f)) * i + m_imgui->scaled(1.3f));
if (m_current_tool == tool_icons[i]) {
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.81f, 0.81f, 0.81f, 1.0f)); // r, g, b, a
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.81f, 0.81f, 0.81f, 1.0f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.81f, 0.81f, 0.81f, 1.0f));
}
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0);
if (m_current_tool == tool_icons[i]) {
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.86f, 0.99f, 0.91f, 1.00f)); // r, g, b, a
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.86f, 0.99f, 0.91f, 1.00f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.86f, 0.99f, 0.91f, 1.00f));
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.00f, 0.68f, 0.26f, 1.00f));
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 1.0);
}
bool btn_clicked = ImGui::Button(into_u8(btn_name).c_str());
if (m_current_tool == tool_icons[i])
{
ImGui::PopStyleColor(4);
ImGui::PopStyleVar(2);
}
ImGui::PopStyleVar(1);
if (m_current_tool == tool_icons[i])ImGui::PopStyleColor(3);
if (btn_clicked && m_current_tool != tool_icons[i]) {
m_current_tool = tool_icons[i];
for (auto& triangle_selector : m_triangle_selectors) {
@ -263,9 +255,9 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit)
m_imgui->text(m_desc.at("cursor_size"));
ImGui::SameLine(sliders_left_width);
ImGui::PushItemWidth(window_width - sliders_left_width - slider_width_times * slider_icon_width);
ImGui::PushItemWidth(sliders_width);
m_imgui->bbl_slider_float_style("##cursor_radius", &m_cursor_radius, CursorRadiusMin, CursorRadiusMax, "%.2f", 1.0f, true);
ImGui::SameLine(window_width - slider_icon_width);
ImGui::SameLine(drag_left_width);
ImGui::PushItemWidth(1.5 * slider_icon_width);
ImGui::BBLDragFloat("##cursor_radius_input", &m_cursor_radius, 0.05f, 0.0f, 0.0f, "%.2f");
@ -275,10 +267,10 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit)
auto clp_dist = float(m_c->object_clipper()->get_position());
ImGui::SameLine(sliders_left_width);
ImGui::PushItemWidth(window_width - sliders_left_width - slider_width_times * slider_icon_width);
ImGui::PushItemWidth(sliders_width);
bool slider_clp_dist = m_imgui->bbl_slider_float_style("##clp_dist", &clp_dist, 0.f, 1.f, "%.2f", 1.0f, true);
ImGui::SameLine(window_width - slider_icon_width);
ImGui::SameLine(drag_left_width);
ImGui::PushItemWidth(1.5 * slider_icon_width);
bool b_clp_dist_input = ImGui::BBLDragFloat("##clp_dist_input", &clp_dist, 0.05f, 0.0f, 0.0f, "%.2f");
if (slider_clp_dist || b_clp_dist_input) { m_c->object_clipper()->set_position(clp_dist, true); }

View file

@ -0,0 +1,210 @@
// Include GLGizmoBase.hpp before I18N.hpp as it includes some libigl code, which overrides our localization "L" macro.
#include "GLGizmoText.hpp"
#include "slic3r/GUI/GLCanvas3D.hpp"
#include "slic3r/GUI/Gizmos/GLGizmosCommon.hpp"
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/ImGuiWrapper.hpp"
#include "slic3r/GUI/GUI_ObjectList.hpp"
#include "libslic3r/Geometry/ConvexHull.hpp"
#include "libslic3r/Model.hpp"
#include "libslic3r/Shape/TextShape.hpp"
#include <numeric>
#include <GL/glew.h>
#ifndef IMGUI_DEFINE_MATH_OPERATORS
#define IMGUI_DEFINE_MATH_OPERATORS
#endif
#include <imgui/imgui_internal.h>
namespace Slic3r {
namespace GUI {
static double g_normal_precise = 0.0015;
GLGizmoText::GLGizmoText(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
: GLGizmoBase(parent, icon_filename, sprite_id)
{
}
bool GLGizmoText::on_init()
{
m_avail_font_names = init_occt_fonts();
m_shortcut_key = WXK_CONTROL_T;
return true;
}
void GLGizmoText::on_set_state()
{
}
CommonGizmosDataID GLGizmoText::on_get_requirements() const
{
return CommonGizmosDataID::SelectionInfo;
}
std::string GLGizmoText::on_get_name() const
{
return _u8L("Text shape");
}
bool GLGizmoText::on_is_activable() const
{
// This is assumed in GLCanvas3D::do_rotate, do not change this
// without updating that function too.
return m_parent.get_selection().is_single_full_instance();
}
void GLGizmoText::on_render()
{
// TODO:
}
void GLGizmoText::on_render_for_picking()
{
// TODO:
}
void GLGizmoText::push_combo_style(const float scale)
{
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 1.0f * scale);
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f * scale);
ImGui::PushStyleColor(ImGuiCol_PopupBg, ImGuiWrapper::COL_WINDOW_BG);
ImGui::PushStyleColor(ImGuiCol_BorderActive, ImVec4(0.00f, 0.68f, 0.26f, 1.00f));
ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(0.00f, 0.68f, 0.26f, 0.0f));
ImGui::PushStyleColor(ImGuiCol_HeaderActive, ImVec4(0.00f, 0.68f, 0.26f, 1.0f));
ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(0.00f, 0.68f, 0.26f, 1.0f));
ImGui::PushStyleColor(ImGuiCol_ScrollbarBg, ImGuiWrapper::COL_WINDOW_BG);
ImGui::PushStyleColor(ImGuiCol_Button, { 1.00f, 1.00f, 1.00f, 0.0f });
}
void GLGizmoText::pop_combo_style()
{
ImGui::PopStyleVar(2);
ImGui::PopStyleColor(7);
}
// BBS
void GLGizmoText::on_render_input_window(float x, float y, float bottom_limit)
{
const float win_h = ImGui::GetWindowHeight();
y = std::min(y, bottom_limit - win_h);
GizmoImguiSetNextWIndowPos(x, y, ImGuiCond_Always, 0.0f, 0.0f);
static float last_y = 0.0f;
static float last_h = 0.0f;
const float currt_scale = m_parent.get_scale();
ImGuiWrapper::push_toolbar_style(currt_scale);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4.0,5.0) * currt_scale);
GizmoImguiBegin("Text", ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar);
float space_size = m_imgui->get_style_scaling() * 8;
float font_cap = m_imgui->calc_text_size(_L("Font")).x;
float size_cap = m_imgui->calc_text_size(_L("Size")).x;
float thickness_cap = m_imgui->calc_text_size(_L("Thickness")).x;
float input_cap = m_imgui->calc_text_size(_L("Input text")).x;
float caption_size = std::max(std::max(font_cap, size_cap), std::max(thickness_cap, input_cap)) + space_size + ImGui::GetStyle().WindowPadding.x;
float input_text_size = m_imgui->scaled(12.0f);
float button_size = ImGui::GetFrameHeight();
float input_size = input_text_size - button_size * 2 - ImGui::GetStyle().ItemSpacing.x * 4;
ImTextureID normal_B = m_parent.get_gizmos_manager().get_icon_texture_id(GLGizmosManager::MENU_ICON_NAME::IC_TEXT_B);
ImTextureID press_B_hover = m_parent.get_gizmos_manager().get_icon_texture_id(GLGizmosManager::MENU_ICON_NAME::IC_TEXT_B_HOVER);
ImTextureID press_B_press = m_parent.get_gizmos_manager().get_icon_texture_id(GLGizmosManager::MENU_ICON_NAME::IC_TEXT_B_PRESS);
ImTextureID normal_T = m_parent.get_gizmos_manager().get_icon_texture_id(GLGizmosManager::MENU_ICON_NAME::IC_TEXT_T);
ImTextureID press_T_hover = m_parent.get_gizmos_manager().get_icon_texture_id(GLGizmosManager::MENU_ICON_NAME::IC_TEXT_T_HOVER);
ImTextureID press_T_press = m_parent.get_gizmos_manager().get_icon_texture_id(GLGizmosManager::MENU_ICON_NAME::IC_TEXT_T_PRESS);
// adjust window position to avoid overlap the view toolbar
if (last_h != win_h || last_y != y) {
// ask canvas for another frame to render the window in the correct position
m_imgui->set_requires_extra_frame();
if (last_h != win_h)
last_h = win_h;
if (last_y != y)
last_y = y;
}
ImGui::AlignTextToFramePadding();
const char** cstr_font_names = (const char**)calloc(m_avail_font_names.size(), sizeof(const char*));
for (int i = 0; i < m_avail_font_names.size(); i++)
cstr_font_names[i] = m_avail_font_names[i].c_str();
m_imgui->text(_L("Font"));
ImGui::SameLine(caption_size);
ImGui::PushItemWidth(input_text_size + ImGui::GetFrameHeight() * 2);
push_combo_style(currt_scale);
if (ImGui::BBLBeginCombo("##Font", cstr_font_names[m_curr_font_idx], 0)) {
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(4.0f, 0.0f) * currt_scale);
for (int i = 0; i < m_avail_font_names.size(); i++) {
const bool is_selected = (m_curr_font_idx == i);
if (ImGui::BBLSelectable(cstr_font_names[i], is_selected)) {
m_curr_font_idx = i;
m_font_name = cstr_font_names[m_curr_font_idx];
}
if (is_selected) {
ImGui::SetItemDefaultFocus();
}
}
ImGui::PopStyleVar(2);
ImGui::EndCombo();
}
pop_combo_style();
ImGui::AlignTextToFramePadding();
m_imgui->text(_L("Size"));
ImGui::SameLine(caption_size);
ImGui::PushItemWidth(input_size);
ImGui::InputFloat("###font_size", &m_font_size, 0.0f, 0.0f, "%.2f");
if (m_font_size < 3.0f)m_font_size = 3.0f;
ImGui::SameLine();
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, {0.0,0.0});
ImGui::BBLImageButton(normal_B,press_B_hover,press_B_press,{button_size,button_size},m_bold);
ImGui::SameLine();
ImGui::BBLImageButton(normal_T,press_T_hover,press_T_press,{button_size,button_size},m_italic);
ImGui::PopStyleVar(2);
ImGui::AlignTextToFramePadding();
m_imgui->text(_L("Thickness"));
ImGui::SameLine(caption_size);
ImGui::PushItemWidth(input_text_size);
ImGui::InputFloat("###text_thickness", &m_thickness,0.0f, 0.0f, "%.2f");
if (m_thickness < 0.1f)m_thickness = 0.1f;
ImGui::AlignTextToFramePadding();
m_imgui->text(_L("Input text"));
ImGui::SameLine(caption_size);
ImGui::PushItemWidth(input_text_size);
ImGui::InputText("", m_text, sizeof(m_text));
ImGui::Separator();
m_imgui->disabled_begin(m_text[0] == '\0' || m_text[0] == ' ');
float offset = caption_size + input_text_size - m_imgui->calc_text_size(_L("Add")).x - space_size;
ImGui::Dummy({0.0, 0.0});
ImGui::SameLine(offset);
bool add_clicked = m_imgui->button(_L("Add"));
if (add_clicked) {
TriangleMesh mesh;
load_text_shape(m_text, m_font_name.c_str(), m_font_size, m_thickness, m_bold, m_italic, mesh);
ObjectList* obj_list = wxGetApp().obj_list();
obj_list->load_mesh_part(mesh, "text_shape");
}
m_imgui->disabled_end();
GizmoImguiEnd();
ImGui::PopStyleVar();
ImGuiWrapper::pop_toolbar_style();
}
} // namespace GUI
} // namespace Slic3r

View file

@ -0,0 +1,45 @@
#ifndef slic3r_GLGizmoText_hpp_
#define slic3r_GLGizmoText_hpp_
#include "GLGizmoBase.hpp"
#include "slic3r/GUI/3DScene.hpp"
namespace Slic3r {
enum class ModelVolumeType : int;
namespace GUI {
class GLGizmoText : public GLGizmoBase
{
private:
std::vector<std::string> m_avail_font_names;
char m_text[256] = { 0 };
std::string m_font_name;
float m_font_size = 16.f;
int m_curr_font_idx = 0;
bool m_bold = true;
bool m_italic = false;
float m_thickness = 2.f;
public:
GLGizmoText(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
protected:
virtual bool on_init() override;
virtual std::string on_get_name() const override;
virtual bool on_is_activable() const override;
virtual void on_render() override;
virtual void on_render_for_picking() override;
void push_combo_style(const float scale);
void pop_combo_style();
virtual void on_set_state() override;
virtual CommonGizmosDataID on_get_requirements() const override;
virtual void on_render_input_window(float x, float y, float bottom_limit);
};
} // namespace GUI
} // namespace Slic3r
#endif // slic3r_GLGizmoText_hpp_

View file

@ -22,6 +22,7 @@
#include "slic3r/GUI/Gizmos/GLGizmoSeam.hpp"
#include "slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp"
#include "slic3r/GUI/Gizmos/GLGizmoSimplify.hpp"
#include "slic3r/GUI/Gizmos/GLGizmoText.hpp"
#include "libslic3r/format.hpp"
#include "libslic3r/Model.hpp"
@ -146,6 +147,7 @@ bool GLGizmosManager::init()
m_gizmos.emplace_back(new GLGizmoAdvancedCut(m_parent, "toolbar_cut.svg", EType::Cut));
m_gizmos.emplace_back(new GLGizmoFdmSupports(m_parent, "toolbar_support.svg", EType::FdmSupports));
m_gizmos.emplace_back(new GLGizmoSeam(m_parent, "toolbar_seam.svg", EType::Seam));
m_gizmos.emplace_back(new GLGizmoText(m_parent, "toolbar_text.svg", EType::Text));
m_gizmos.emplace_back(new GLGizmoMmuSegmentation(m_parent, "mmu_segmentation.svg", EType::MmuSegmentation));
m_gizmos.emplace_back(new GLGizmoSimplify(m_parent, "reduce_triangles.svg", EType::Simplify));
//m_gizmos.emplace_back(new GLGizmoSlaSupports(m_parent, "sla_supports.svg", sprite_id++));
@ -194,6 +196,37 @@ bool GLGizmosManager::init_icon_textures()
else
return false;
if (IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/text_B.svg", 20, 20, texture_id))
icon_list.insert(std::make_pair((int)IC_TEXT_B, texture_id));
else
return false;
if (IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/text_B_hover.svg", 20, 20, texture_id))
icon_list.insert(std::make_pair((int)IC_TEXT_B_HOVER, texture_id));
else
return false;
if (IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/text_B_press.svg", 20, 20, texture_id))
icon_list.insert(std::make_pair((int)IC_TEXT_B_PRESS, texture_id));
else
return false;
if (IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/text_T.svg", 20, 20, texture_id))
icon_list.insert(std::make_pair((int)IC_TEXT_T, texture_id));
else
return false;
if (IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/text_T_hover.svg", 20, 20, texture_id))
icon_list.insert(std::make_pair((int)IC_TEXT_T_HOVER, texture_id));
else
return false;
if (IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/text_T_press.svg", 20, 20, texture_id))
icon_list.insert(std::make_pair((int)IC_TEXT_T_PRESS, texture_id));
else
return false;
return true;
}
@ -1379,7 +1412,8 @@ void GLGizmosManager::update_on_off_state(const Vec2d& mouse_pos)
size_t idx = get_gizmo_idx_from_mouse(mouse_pos);
if (idx != Undefined && m_gizmos[idx]->is_activable() && m_hover == idx) {
activate_gizmo(m_current == idx ? Undefined : (EType)idx);
wxGetApp().obj_list()->select_object_item((EType)idx <= Rotate);
// BBS
wxGetApp().obj_list()->select_object_item((EType)idx <= Scale);
}
}

View file

@ -72,6 +72,8 @@ public:
Cut,
FdmSupports,
Seam,
// BBS
Text,
MmuSegmentation,
Simplify,
SlaSupports,
@ -149,6 +151,12 @@ public:
IC_TOOLBAR_RESET_HOVER,
IC_TOOLBAR_TOOLTIP,
IC_TOOLBAR_TOOLTIP_HOVER,
IC_TEXT_B,
IC_TEXT_B_HOVER,
IC_TEXT_B_PRESS,
IC_TEXT_T,
IC_TEXT_T_HOVER,
IC_TEXT_T_PRESS,
IC_NAME_COUNT,
};

View file

@ -83,7 +83,11 @@ int HMSQuery::load_from_local(std::string &version_info)
return -1;
}
std::string filename = get_hms_file();
std::string dir_str = (boost::filesystem::path(data_dir()) / filename).make_preferred().string();
auto hms_folder = (boost::filesystem::path(data_dir()) / "hms");
if (!fs::exists(hms_folder))
fs::create_directory(hms_folder);
std::string dir_str = (hms_folder / filename).make_preferred().string();
std::ifstream json_file(encode_path(dir_str.c_str()));
try {
if (json_file.is_open()) {
@ -111,7 +115,10 @@ int HMSQuery::save_to_local()
return -1;
}
std::string filename = get_hms_file();
std::string dir_str = (boost::filesystem::path(data_dir()) / filename).make_preferred().string();
auto hms_folder = (boost::filesystem::path(data_dir()) / "hms");
if (!fs::exists(hms_folder))
fs::create_directory(hms_folder);
std::string dir_str = (hms_folder / 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;

View file

@ -83,9 +83,8 @@ HMSNotifyItem::HMSNotifyItem(wxWindow *parent, HMSItem& item)
}
});
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()));
});
if (!m_url.empty()) wxLaunchDefaultBrowser(m_url);
});
}
HMSNotifyItem ::~HMSNotifyItem() {
;

View file

@ -521,6 +521,11 @@ Info IMSlider::GetTicksValues() const
void IMSlider::SetTicksValues(const Info &custom_gcode_per_print_z)
{
if (!m_can_change_color) {
m_ticks.erase_all_ticks_with_code(ToolChange);
return;
}
if (m_values.empty()) {
m_ticks.mode = m_mode;
return;
@ -584,7 +589,7 @@ void IMSlider::SetDrawMode(bool is_sequential_print)
dmRegular;
}
void IMSlider::SetModeAndOnlyExtruder(const bool is_one_extruder_printed_model, const int only_extruder)
void IMSlider::SetModeAndOnlyExtruder(const bool is_one_extruder_printed_model, const int only_extruder, bool can_change_color)
{
m_mode = !is_one_extruder_printed_model ? MultiExtruder : only_extruder < 0 ? SingleExtruder : MultiAsSingle;
if (!m_ticks.mode || (m_ticks.empty() && m_ticks.mode != m_mode)) m_ticks.mode = m_mode;
@ -593,6 +598,8 @@ void IMSlider::SetModeAndOnlyExtruder(const bool is_one_extruder_printed_model,
UseDefaultColors(m_mode == SingleExtruder);
m_is_wipe_tower = m_mode != SingleExtruder;
m_can_change_color = can_change_color;
}
void IMSlider::SetExtruderColors( const std::vector<std::string>& extruder_colors)
@ -1252,7 +1259,10 @@ void IMSlider::render_menu()
//BBS render this menu item only when extruder_num > 1
if (extruder_num > 1) {
if (begin_menu(_u8L("Change Filament").c_str())) {
if (!m_can_change_color) {
begin_menu(_u8L("Change Filament").c_str(), false);
}
else if (begin_menu(_u8L("Change Filament").c_str())) {
for (int i = 0; i < extruder_num; i++) {
std::array<float, 4> rgba = decode_color_to_float_array(colors[i]);
ImU32 icon_clr = IM_COL32(rgba[0] * 255.0f, rgba[1] * 255.0f, rgba[2] * 255.0f, rgba[3] * 255.0f);

View file

@ -245,7 +245,7 @@ public:
void SetExtraStyle(long style) { m_extra_style = style; }
void SetManipulationMode(Mode mode) { m_mode = mode; }
Mode GetManipulationMode() const { return m_mode; }
void SetModeAndOnlyExtruder(const bool is_one_extruder_printed_model, const int only_extruder);
void SetModeAndOnlyExtruder(const bool is_one_extruder_printed_model, const int only_extruder, bool can_change_color);
void SetExtruderColors(const std::vector<std::string> &extruder_colors);
bool IsNewPrint();
@ -360,6 +360,7 @@ private:
std::vector<double> m_layers_times;
std::vector<double> m_layers_values;
std::vector<std::string> m_extruder_colors;
bool m_can_change_color;
std::string m_print_obj_idxs;
bool m_is_need_post_tick_changed_event { false };
Type m_tick_change_event_type;

View file

@ -543,7 +543,7 @@ bool ImGuiWrapper::bbl_slider_float_style(const std::string &label, float *v, fl
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f);
ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(238 / 255.0f, 238 / 255.0f, 238 / 255.0f, 0.00f));
ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(238 / 255.0f, 238 / 255.0f, 238 / 255.0f, 0.00f));
ImGui::PushStyleColor(ImGuiCol_SliderGrab, ImVec4(0.00f, 0.68f, 0.26f, 1.00f));
ImGui::PushStyleColor(ImGuiCol_SliderGrab, ImVec4(0.81f, 0.81f, 0.81f, 1.0f));
ImGui::PushStyleColor(ImGuiCol_SliderGrabActive, ImVec4(0.00f, 0.68f, 0.26f, 1.00f));
bool ret = bbl_slider_float(label, v, v_min,v_max, format, power, clamp,tooltip);
@ -1643,6 +1643,7 @@ void ImGuiWrapper::push_toolbar_style(const float scale)
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(20.0f, 10.0f) * scale);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 3.0f * scale);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 2.0f * scale);
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(10.0f, 10.0f) * scale);
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(50/255.0f, 58/255.0f, 61/255.0f, 1.00f)); // 1
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImGuiWrapper::COL_WINDOW_BG); // 2
@ -1665,7 +1666,7 @@ void ImGuiWrapper::pop_toolbar_style()
{
// size in push toolbar style
ImGui::PopStyleColor(15);
ImGui::PopStyleVar(5);
ImGui::PopStyleVar(6);
}
void ImGuiWrapper::push_menu_style(const float scale)

View file

@ -138,7 +138,7 @@ void Slic3r::GUI::ImageGrid::DoAction(size_t index, int action)
if (action == 0) {
m_file_sys->DeleteFiles(index);
} else {
if (index >= 0) {
if (index != -1) {
auto &file = m_file_sys->GetFile(index);
if (file.IsDownload() && file.progress >= -1) {
if (file.progress >= 100) {
@ -480,13 +480,13 @@ void ImageGrid::render(wxDC& dc)
if (file.IsDownload()) {
if (file.progress == -1) {
secondAction = _L("Cancel");
dc.DrawText(_L("Waiting"), pt + wxPoint{24, m_image_size.GetHeight() - 36});
dc.DrawText(_L("Waiting"), pt + wxPoint{24, m_image_size.GetHeight() - 64});
} else if (file.progress < 0) {
secondAction = _L("Retry");
dc.DrawText(_L("Failed"), pt + wxPoint{24, m_image_size.GetHeight() - 36});
dc.DrawText(_L("Failed"), pt + wxPoint{24, m_image_size.GetHeight() - 64});
} else if (file.progress >= 100) {
secondAction = _L("Open");
dc.DrawText(_L("Finished"), pt + wxPoint{24, m_image_size.GetHeight() - 36});
dc.DrawText(_L("Finished"), pt + wxPoint{24, m_image_size.GetHeight() - 64});
} else {
secondAction = _L("Cancel");
if (file.progress != m_background_progress) {
@ -567,7 +567,7 @@ void Slic3r::GUI::ImageGrid::renderButtons(wxDC &dc, wxStringList const &texts,
wxRect rect(rect2);
rect.SetWidth(rect.GetWidth() / texts.size());
int state = m_pressed ? StateColor::Pressed : StateColor::Hovered;
dc.SetFont(Label::Body_12);
dc.SetFont(Label::Body_14);
//mdc.SelectObject(m_button_background);
for (size_t i = 0; i < texts.size(); ++i) {
int states = hit == i ? state : 0;

View file

@ -152,6 +152,7 @@ void PrintJob::process()
params.task_record_timelapse= this->task_record_timelapse;
params.ams_mapping = this->task_ams_mapping;
params.connection_type = this->connection_type;
params.task_use_ams = this->task_use_ams;
// local print access
params.dev_ip = m_dev_ip;
@ -221,9 +222,19 @@ void PrintJob::process()
return was_canceled();
};
NetworkAgent* m_agent = wxGetApp().getAgent();
if (params.connection_type != "lan") {
if (params.dev_ip.empty())
params.comments = "no_ip";
else if (this->cloud_print_only)
params.comments = "low_version";
else if (!this->has_sdcard)
params.comments = "no_sdcard";
else if (params.password.empty())
params.comments = "no_password";
if (!this->cloud_print_only
&& !params.password.empty()
&& !params.dev_ip.empty()
@ -232,6 +243,13 @@ void PrintJob::process()
BOOST_LOG_TRIVIAL(info) << "print_job: try to start local print with record";
this->update_status(curr_percent, _L("Sending print job over LAN"));
result = m_agent->start_local_print_with_record(params, update_fn, cancel_fn);
if (result == BAMBU_NETWORK_ERR_FTP_LOGIN_DENIED) {
params.comments = "wrong_code";
} else if (result == BAMBU_NETWORK_ERR_FTP_UPLOAD_FAILED) {
params.comments = "upload_failed";
} else {
params.comments = (boost::format("failed(%1%)") % result).str();
}
if (result < 0) {
// try to send with cloud
BOOST_LOG_TRIVIAL(warning) << "print_job: try to send with cloud";

View file

@ -50,6 +50,7 @@ public:
std::string connection_type;
bool cloud_print_only { false };
bool has_sdcard { false };
bool task_use_ams { true };
void set_print_config(std::string bed_type, bool bed_leveling, bool flow_cali, bool vabration_cali, bool record_timelapse, bool layer_inspect)
{

View file

@ -181,6 +181,11 @@ void KBShortcutsDialog::fill_shortcuts()
{ ctrl + "X", L("Cut") },
{ ctrl + "C", L("Copy to clipboard") },
{ ctrl + "V", L("Paste from clipboard") },
// Configuration
{ ctrl + "P", L("Preferences") },
//3D control
{ ctrl + "M", L("Show/Hide 3Dconnexion devices settings dialog") },
//DEL
#ifdef __APPLE__
{"fn+⌫", L("Delete selected")},
#else
@ -215,7 +220,6 @@ void KBShortcutsDialog::fill_shortcuts()
{L("Arrow Left"), L("Move selection 10 mm in negative X direction")},
{L("Arrow Right"), L("Move selection 10 mm in positive X direction")},
{L("Shift+Any arrow"), L("Movement step set to 1 mm")},
{"Esc", L("Deselect all")},
{"1-9", L("keyboard 1-9: set filament for object/part")},
{ctrl + "0", L("Camera view - Default")},
@ -225,11 +229,11 @@ void KBShortcutsDialog::fill_shortcuts()
{ctrl + "4", L("Camera view - Behind")},
{ctrl + "5", L("Camera Angle - Left side")},
{ctrl + "6", L("Camera Angle - Right side")},
{ctrl + "A", L("Select all objects")},
{ctrl + "D", L("Delete all")},
{ctrl + "Z", L("Undo")},
{ctrl + "Y", L("Redo")},
{ctrl + "M", L("Clone selected")},
{ "M", L("Gizmo move") },
{ "S", L("Gizmo scale") },
{ "R", L("Gizmo rotate") },
@ -237,6 +241,7 @@ void KBShortcutsDialog::fill_shortcuts()
{ "F", L("Gizmo Place face on bed") },
{ "L", L("Gizmo SLA support points") },
{ "P", L("Gizmo FDM paint-on seam") },
};
m_full_shortcuts.push_back({ { _L("Plater"), "" }, plater_shortcuts });
@ -245,13 +250,11 @@ void KBShortcutsDialog::fill_shortcuts()
{"Shift+", L("Move: press to snap by 1mm") },
#ifdef __APPLE__
{L("⌘+Mouse wheel"), L("Support/Color Painting: adjust pen radius")},
{L("+Mouse wheel"), L("Support/Color Painting: adjust section position")},
{L("+Mouse wheel"), L("Support/Color Painting: adjust section position")},
#else
{L("Ctrl+Mouse wheel"), L("Support/Color Painting: adjust pen radius")},
{L("Alt+Mouse wheel"), L("Support/Color Painting: adjust section position")},
#endif
};
m_full_shortcuts.push_back({{_L("Gizmo"), ""}, gizmos_shortcuts});
@ -293,7 +296,6 @@ void KBShortcutsDialog::fill_shortcuts()
m_full_shortcuts.push_back({ { _L("Preview"), "" }, preview_shortcuts });
}
wxPanel* KBShortcutsDialog::create_page(wxWindow* parent, const ShortcutsItem& shortcuts, const wxFont& font, const wxFont& bold_font)
{
wxPanel* main_page = new wxPanel(parent);

View file

@ -1241,6 +1241,7 @@ wxBoxSizer* MainFrame::create_side_tools()
m_slice_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event)
{
//this->m_plater->select_view_3D("Preview");
m_plater->update();
if (m_slice_select == eSliceAll)
wxPostEvent(m_plater, SimpleEvent(EVT_GLTOOLBAR_SLICE_ALL));
else
@ -1692,7 +1693,10 @@ static wxMenu* generate_help_menu()
static void add_common_view_menu_items(wxMenu* view_menu, MainFrame* mainFrame, std::function<bool(void)> can_change_view)
{
// The camera control accelerators are captured by GLCanvas3D::on_char().
append_menu_item(view_menu, wxID_ANY, _L("Default View") + "\tCtrl+0", _L("Default View"), [mainFrame](wxCommandEvent&) { mainFrame->select_view("topfront"); },
append_menu_item(view_menu, wxID_ANY, _L("Default View") + "\tCtrl+0", _L("Default View"), [mainFrame](wxCommandEvent&) {
mainFrame->select_view("plate");
mainFrame->plater()->get_current_canvas3D()->zoom_to_bed();
},
"", nullptr, [can_change_view]() { return can_change_view(); }, mainFrame);
//view_menu->AppendSeparator();
//TRN To be shown in the main menu View->Top
@ -1782,18 +1786,24 @@ void MainFrame::init_menubar_as_editor()
fileMenu->AppendSeparator();
//BBS
// BBS
wxMenu *import_menu = new wxMenu();
#ifdef __WINDOWS__
append_menu_item(fileMenu, wxID_ANY, _L("Import 3MF/STL/STEP/OBJ/AMF") + dots + "\tCtrl+I", _L("Load a model"),
append_menu_item(import_menu, wxID_ANY, _L("Import 3MF/STL/STEP/OBJ/AMF") + dots + "\tCtrl+I", _L("Load a model"),
[this](wxCommandEvent&) { if (m_plater) {
m_plater->add_model();
} }, "menu_import", nullptr,
[this](){return can_add_models(); }, this);
#else
append_menu_item(fileMenu, wxID_ANY, _L("Import 3MF/STL/STEP/OBJ/AMF") + dots + "\tCtrl+I", _L("Load a model"),
append_menu_item(import_menu, wxID_ANY, _L("Import 3MF/STL/STEP/OBJ/AMF") + dots + "\tCtrl+I", _L("Load a model"),
[this](wxCommandEvent&) { if (m_plater) { m_plater->add_model(); } }, "", nullptr,
[this](){return can_add_models(); }, this);
#endif
append_menu_item(import_menu, wxID_ANY, _L("Import Configs") + dots /*+ "\tCtrl+I"*/, _L("Load configs"),
[this](wxCommandEvent&) { load_config_file(); }, "menu_import", nullptr,
[this](){return true; }, this);
append_submenu(fileMenu, import_menu, wxID_ANY, _L("Import"), "");
wxMenu* export_menu = new wxMenu();
@ -1801,6 +1811,9 @@ void MainFrame::init_menubar_as_editor()
append_menu_item(export_menu, wxID_ANY, _L("Export all objects as STL") + dots, _L("Export all objects as STL"),
[this](wxCommandEvent&) { if (m_plater) m_plater->export_stl(); }, "menu_export_stl", nullptr,
[this](){return can_export_model(); }, this);
append_menu_item(export_menu, wxID_ANY, _L("Export Generic 3MF") + dots/* + "\tCtrl+G"*/, _L("Export 3mf file without using some 3mf-extensions"),
[this](wxCommandEvent&) { if (m_plater) m_plater->export_core_3mf(); }, "menu_export_sliced_file", nullptr,
[this](){return can_export_model(); }, this);
// BBS export .gcode.3mf
append_menu_item(export_menu, wxID_ANY, _L("Export Sliced File") + dots/* + "\tCtrl+G"*/, _L("Export current Sliced file"),
[this](wxCommandEvent&) { if (m_plater) wxPostEvent(m_plater, SimpleEvent(EVT_GLTOOLBAR_EXPORT_SLICED_FILE)); }, "menu_export_sliced_file", nullptr,
@ -1808,6 +1821,11 @@ void MainFrame::init_menubar_as_editor()
append_menu_item(export_menu, wxID_ANY, _L("Export G-code") + dots/* + "\tCtrl+G"*/, _L("Export current plate as G-code"),
[this](wxCommandEvent&) { if (m_plater) m_plater->export_gcode(false); }, "menu_export_gcode", nullptr,
[this]() {return can_export_gcode(); }, this);
append_menu_item(
export_menu, wxID_ANY, _L("Export &Configs") + dots /* + "\tCtrl+E"*/, _L("Export current configuration to files"),
[this](wxCommandEvent &) { export_config(); },
"menu_export_config", nullptr,
[]() { return true; }, this);
append_submenu(fileMenu, export_menu, wxID_ANY, _L("Export"), "");
@ -1866,7 +1884,7 @@ void MainFrame::init_menubar_as_editor()
"menu_remove", nullptr, [this](){return can_delete_all(); }, this);
editMenu->AppendSeparator();
// BBS Clone Selected
append_menu_item(editMenu, wxID_ANY, _L("Clone selected") + "\tCtrl+M",
append_menu_item(editMenu, wxID_ANY, _L("Clone selected") /*+ "\tCtrl+M"*/,
_L("Clone copies of selections"),[this](wxCommandEvent&) {
m_plater->clone_selection();
},
@ -1981,7 +1999,7 @@ 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+,", "");
//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", "");
@ -2056,7 +2074,7 @@ void MainFrame::init_menubar_as_editor()
#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, "");
//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:
@ -2080,11 +2098,11 @@ void MainFrame::init_menubar_as_editor()
//});
//parent_menu->Insert(0, about_item);
append_menu_item(
parent_menu, wxID_ANY, _L("About") + "", _L(""),
parent_menu, wxID_ANY, _L(about_title), _L(""),
[this](wxCommandEvent &) { Slic3r::GUI::about();},
"", nullptr, []() { return true; }, this, 0);
append_menu_item(
parent_menu, wxID_ANY, _L("Preferences") + "\tCtrl+'", _L(""),
parent_menu, wxID_ANY, _L("Preferences") + "\tCtrl+,", _L(""),
[this](wxCommandEvent &) {
PreferencesDialog dlg(this);
dlg.ShowModal();
@ -2129,13 +2147,13 @@ void MainFrame::init_menubar_as_editor()
//m_topbar->AddDropDownMenuItem(config_item);
m_topbar->AddDropDownSubMenu(helpMenu, _L("Help"));
#else
m_menubar->Append(fileMenu, _L("&File"));
m_menubar->Append(fileMenu, wxString::Format("&%s", _L("File")));
if (editMenu)
m_menubar->Append(editMenu, _L("&Edit"));
m_menubar->Append(editMenu, wxString::Format("&%s", _L("Edit")));
if (viewMenu)
m_menubar->Append(viewMenu, _L("&View"));
m_menubar->Append(viewMenu, wxString::Format("&%s", _L("View")));
if (helpMenu)
m_menubar->Append(helpMenu, _L("&Help"));
m_menubar->Append(helpMenu, wxString::Format("&%s", _L("Help")));
SetMenuBar(m_menubar);
#endif
@ -2258,28 +2276,48 @@ void MainFrame::reslice_now()
m_plater->reslice();
}
struct ConfigsOverwriteConfirmDialog : MessageDialog
{
ConfigsOverwriteConfirmDialog(wxWindow *parent, wxString name, bool exported)
: MessageDialog(parent,
wxString::Format(exported ? _("A file exists with the same name: %s, do you wan't to override it.") :
_("A config exists with the same name: %s, do you wan't to override it."),
name),
_L(exported ? "Overwrite file" : "Overwrite config"),
wxYES_NO | wxNO_DEFAULT)
{
add_button(wxID_YESTOALL, false, _L("Yes to All"));
add_button(wxID_NOTOALL, false, _L("No to All"));
}
};
void MainFrame::export_config()
{
// Generate a cummulative configuration for the selected print, filaments and printer.
auto config = wxGetApp().preset_bundle->full_config();
// Validate the cummulative configuration.
auto valid = config.validate();
if (! valid.empty()) {
show_error(this, valid);
return;
}
// Ask user for the file name for the config file.
wxFileDialog dlg(this, _L("Save configuration as:"),
!m_last_config.IsEmpty() ? get_dir_name(m_last_config) : wxGetApp().app_config->get_last_dir(),
!m_last_config.IsEmpty() ? get_base_name(m_last_config) : "config.ini",
file_wildcards(FT_INI), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
wxString file;
wxDirDialog dlg(this, _L("Choose a directory"),
from_u8(!m_last_config.IsEmpty() ? get_dir_name(m_last_config) : wxGetApp().app_config->get_last_dir()), wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
wxString path;
if (dlg.ShowModal() == wxID_OK)
file = dlg.GetPath();
if (!file.IsEmpty()) {
wxGetApp().app_config->update_config_dir(get_dir_name(file));
m_last_config = file;
config.save(file.ToUTF8().data());
path = dlg.GetPath();
if (!path.IsEmpty()) {
// Export the config bundle.
wxGetApp().app_config->update_config_dir(into_u8(path));
try {
auto files = wxGetApp().preset_bundle->export_current_configs(into_u8(path), [this](std::string const & name) {
ConfigsOverwriteConfirmDialog dlg(this, from_u8(name), true);
int res = dlg.ShowModal();
int ids[]{wxID_NO, wxID_YES, wxID_NOTOALL, wxID_YESTOALL};
return std::find(ids, ids + 4, res) - ids;
}, false);
if (!files.empty())
m_last_config = from_u8(files.back());
MessageDialog dlg(this, wxString::Format(_L_PLURAL("There is %d config exported. (Only non-system configs)",
"There are %d configs exported. (Only non-system configs)", files.size()), files.size()),
_L("Export result"), wxOK);
dlg.ShowModal();
} catch (const std::exception &ex) {
show_error(this, ex.what());
}
}
}
@ -2289,16 +2327,34 @@ void MainFrame::load_config_file()
//BBS do not load config file
// if (!wxGetApp().check_and_save_current_preset_changes(_L("Loading profile file"), "", false))
// return;
// wxFileDialog dlg(this, _L("Select profile to load:"),
// !m_last_config.IsEmpty() ? get_dir_name(m_last_config) : wxGetApp().app_config->get_last_dir(),
// "config.json", "INI files (*.ini, *.gcode)|*.json;;*.gcode;*.g", wxFD_OPEN | wxFD_FILE_MUST_EXIST);
// wxString file;
// if (dlg.ShowModal() == wxID_OK)
// file = dlg.GetPath();
// if (! file.IsEmpty() && this->load_config_file(file.ToUTF8().data())) {
// wxGetApp().app_config->update_config_dir(get_dir_name(file));
// m_last_config = file;
// }
wxFileDialog dlg(this, _L("Select profile to load:"),
!m_last_config.IsEmpty() ? get_dir_name(m_last_config) : wxGetApp().app_config->get_last_dir(),
"config.json", "Config files (*.json)|*.json", wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST);
wxArrayString files;
if (dlg.ShowModal() != wxID_OK)
return;
dlg.GetPaths(files);
std::vector<std::string> cfiles;
for (auto file : files) {
cfiles.push_back(into_u8(file));
m_last_config = file;
}
bool update = false;
wxGetApp().preset_bundle->import_presets(cfiles, [this](std::string const & name) {
ConfigsOverwriteConfirmDialog dlg(this, from_u8(name), false);
int res = dlg.ShowModal();
int ids[]{wxID_NO, wxID_YES, wxID_NOTOALL, wxID_YESTOALL};
return std::find(ids, ids + 4, res) - ids;
},
ForwardCompatibilitySubstitutionRule::Enable);
if (!cfiles.empty()) {
wxGetApp().app_config->update_config_dir(get_dir_name(cfiles.back()));
wxGetApp().load_current_presets();
}
MessageDialog dlg2(this, wxString::Format(_L_PLURAL("There is %d config imported. (Only non-system and compatible configs)",
"There are %d configs imported. (Only non-system and compatible configs)", cfiles.size()), cfiles.size()),
_L("Import result"), wxOK);
dlg2.ShowModal();
}
// Load a config file containing a Print, Filament & Printer preset from command line.
@ -2656,6 +2712,28 @@ void MainFrame::open_recent_project(size_t file_id, wxString const & filename)
}
}
void MainFrame::remove_recent_project(size_t file_id, wxString const &filename)
{
if (file_id == size_t(-1)) {
if (filename.IsEmpty())
while (m_recent_projects.GetCount() > 0)
m_recent_projects.RemoveFileFromHistory(0);
else
file_id = m_recent_projects.FindFileInHistory(filename);
}
if (file_id != size_t(-1))
m_recent_projects.RemoveFileFromHistory(file_id);
std::vector<std::string> recent_projects;
size_t count = m_recent_projects.GetCount();
for (size_t i = 0; i < count; ++i)
{
recent_projects.push_back(into_u8(m_recent_projects.GetHistoryFile(i)));
}
wxGetApp().app_config->set_recent_projects(recent_projects);
wxGetApp().app_config->save();
m_webview->SendRecentList("");
}
void MainFrame::load_url(wxString url)
{
BOOST_LOG_TRIVIAL(trace) << "load_url:" << url;
@ -2760,7 +2838,7 @@ std::string MainFrame::get_base_name(const wxString &full_name, const char *exte
std::string MainFrame::get_dir_name(const wxString &full_name) const
{
return boost::filesystem::path(full_name.wx_str()).parent_path().string();
return boost::filesystem::path(into_u8(full_name)).parent_path().string();
}

View file

@ -299,6 +299,7 @@ public:
void add_to_recent_projects(const wxString& filename);
void get_recent_projects(boost::property_tree::wptree & tree);
void open_recent_project(size_t file_id, wxString const & filename);
void remove_recent_project(size_t file_id, wxString const &filename);
void technology_changed();

View file

@ -53,19 +53,23 @@ MediaFilePanel::MediaFilePanel(wxWindow * parent)
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);
m_button_timelapse->SetCanFocus(false);
m_button_video = new ::Button(m_type_panel, _L("Video"), "", wxBORDER_NONE);
m_button_video->SetCanFocus(false);
wxBoxSizer *type_sizer = new wxBoxSizer(wxHORIZONTAL);
type_sizer->Add(m_button_timelapse, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 24);
type_sizer->Add(m_button_video, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 24);
m_type_panel->SetSizer(type_sizer);
top_sizer->Add(m_type_panel, 0, wxALIGN_CENTER_VERTICAL);
//top_sizer->Add(m_type_panel, 0, wxALIGN_CENTER_VERTICAL);
// File management
m_manage_panel = new ::StaticBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
m_manage_panel->SetBackgroundColor(StateColor());
m_button_delete = new ::Button(m_manage_panel, _L("Delete"));
m_button_download = new ::Button(m_manage_panel, _L("Download"));
m_button_delete->SetCanFocus(false);
m_button_download = new ::Button(m_manage_panel, _L("Download"));
m_button_download->SetCanFocus(false);
m_button_management = new ::Button(m_manage_panel, _L("Management"));
wxBoxSizer *manage_sizer = new wxBoxSizer(wxHORIZONTAL);
@ -110,7 +114,10 @@ MediaFilePanel::MediaFilePanel(wxWindow * parent)
auto b = dynamic_cast<Button *>(e.GetEventObject());
if (b == m_button_video)
type = PrinterFileSystem::F_VIDEO;
if (m_last_type == type)
return;
m_image_grid->SetFileType(type);
m_last_type = type;
{
wxCommandEvent e(wxEVT_CHECKBOX);
e.SetEventObject(m_button_timelapse);
@ -146,9 +153,10 @@ MediaFilePanel::MediaFilePanel(wxWindow * parent)
m_button_delete->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [this](auto &e) { m_image_grid->DoActionOnSelection(0); });
auto onShowHide = [this](auto &e) {
e.Skip();
if (m_isBeingDeleted) return;
auto fs = m_image_grid ? m_image_grid->GetFileSystem() : nullptr;
if (fs) e.IsShown() && IsShown() ? fs->Start() : fs->Stop();
if (fs) IsShownOnScreen() ? fs->Start() : fs->Stop();
};
Bind(wxEVT_SHOW, onShowHide);
parent->GetParent()->Bind(wxEVT_SHOW, onShowHide);
@ -175,6 +183,7 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
m_image_grid->SetStatus(m_bmp_failed.bmp(), _L("No printers."));
} else {
boost::shared_ptr<PrinterFileSystem> fs(new PrinterFileSystem);
m_image_grid->SetFileType(m_last_type);
m_image_grid->SetFileSystem(fs);
fs->Bind(EVT_MODE_CHANGED, &MediaFilePanel::modeChanged, this);
fs->Bind(EVT_STATUS_CHANGED, [this, wfs = boost::weak_ptr(fs)](auto &e) {

View file

@ -68,6 +68,7 @@ private:
ImageGrid * m_image_grid = nullptr;
int m_last_mode = 0;
int m_last_type = 0;
};

View file

@ -17,6 +17,7 @@ MediaPlayCtrl::MediaPlayCtrl(wxWindow *parent, wxMediaCtrl2 *media_ctrl, const w
m_media_ctrl->Bind(wxEVT_MEDIA_STATECHANGED, &MediaPlayCtrl::onStateChanged, this);
m_button_play = new Button(this, "", "media_play", wxBORDER_NONE);
m_button_play->SetCanFocus(false);
m_label_status = new Label(this);
@ -35,6 +36,18 @@ MediaPlayCtrl::MediaPlayCtrl(wxWindow *parent, wxMediaCtrl2 *media_ctrl, const w
m_thread = boost::thread([this] {
media_proc();
});
#if BBL_RELEASE_TO_PUBLIC
m_next_retry = wxDateTime::Now();
#endif
auto onShowHide = [this](auto &e) {
e.Skip();
if (m_isBeingDeleted) return;
IsShownOnScreen() ? Play() : Stop();
};
parent->Bind(wxEVT_SHOW, onShowHide);
parent->GetParent()->GetParent()->Bind(wxEVT_SHOW, onShowHide);
}
MediaPlayCtrl::~MediaPlayCtrl()
@ -59,13 +72,20 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
m_failed_retry = 0;
if (m_last_state != MEDIASTATE_IDLE)
Stop();
//Play();
SetStatus("");
if (m_next_retry.IsValid())
Play();
else
SetStatus("");
}
void MediaPlayCtrl::Play()
{
if (!m_next_retry.IsValid())
return;
if (!IsShownOnScreen())
return;
if (m_machine.empty()) {
Stop();
SetStatus(_L("Initialize failed (No Device)!"));
return;
}
@ -113,19 +133,24 @@ void MediaPlayCtrl::Stop()
boost::unique_lock lock(m_mutex);
m_tasks.push_back("<stop>");
m_cond.notify_all();
m_last_state = MEDIASTATE_IDLE;
SetStatus(_L("Stopped."));
}
m_last_state = MEDIASTATE_IDLE;
SetStatus(_L("Stopped."));
++m_failed_retry;
//m_next_retry = wxDateTime::Now() + wxTimeSpan::Seconds(5 * m_failed_retry);
if (m_next_retry.IsValid())
m_next_retry = wxDateTime::Now() + wxTimeSpan::Seconds(5 * m_failed_retry);
}
void MediaPlayCtrl::TogglePlay()
{
if (m_last_state != MEDIASTATE_IDLE)
if (m_last_state != MEDIASTATE_IDLE) {
m_next_retry = wxDateTime();
Stop();
else
} else {
m_failed_retry = 0;
m_next_retry = wxDateTime::Now();
Play();
}
}
void MediaPlayCtrl::SetStatus(wxString const& msg2)
@ -193,7 +218,6 @@ void MediaPlayCtrl::onStateChanged(wxMediaEvent& event)
if (last_state == MEDIASTATE_IDLE && state == wxMEDIASTATE_STOPPED) {
return;
}
m_last_state = state;
if ((last_state == wxMEDIASTATE_PAUSED || last_state == wxMEDIASTATE_PLAYING) &&
state == wxMEDIASTATE_STOPPED) {
Stop();
@ -204,6 +228,7 @@ void MediaPlayCtrl::onStateChanged(wxMediaEvent& event)
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl::onStateChanged: size: " << size.x << "x" << size.y;
m_failed_code = m_media_ctrl->GetLastError();
if (size.GetWidth() > 1000) {
m_last_state = state;
SetStatus(_L("Playing..."));
m_failed_retry = 0;
boost::unique_lock lock(m_mutex);

View file

@ -198,19 +198,17 @@ MonitorPanel::~MonitorPanel()
});
//m_status_add_machine_panel = new AddMachinePanel(m_tabpanel);
m_status_info_panel = new StatusPanel(m_tabpanel);
m_media_file_panel = new MediaFilePanel(m_tabpanel);
m_status_info_panel = new StatusPanel(m_tabpanel);
m_tabpanel->AddPage(m_status_info_panel, _L("Status"), "", true);
#if !BBL_RELEASE_TO_PUBLIC
m_media_file_panel = new MediaFilePanel(m_tabpanel);
m_tabpanel->AddPage(m_media_file_panel, _L("Media"), "", false);
m_upgrade_panel = new UpgradePanel(m_tabpanel);
m_tabpanel->AddPage(m_upgrade_panel, _L("Update"), "", false);
m_hms_panel = new HMSPanel(m_tabpanel);
m_tabpanel->AddPage(m_hms_panel, _L("HMS"), "", false);
#endif
m_tabpanel->AddPage(m_hms_panel, _L("HMS"),"", false);
m_initialized = true;
show_status((int)MonitorStatus::MONITOR_NO_PRINTER);
@ -258,10 +256,8 @@ void MonitorPanel::msw_rescale()
//m_status_add_machine_panel->msw_rescale();
m_status_info_panel->msw_rescale();
m_media_file_panel->Rescale();
#if !BBL_RELEASE_TO_PUBLIC
m_upgrade_panel->msw_rescale();
m_hms_panel->msw_rescale();
#endif
m_connection_info->SetCornerRadius(0);
m_connection_info->SetSize(wxSize(FromDIP(220), FromDIP(25)));
@ -375,6 +371,15 @@ void MonitorPanel::update_all()
return;
obj = dev->get_selected_machine();
// check valid machine
if (obj && dev->get_my_machine(obj->dev_id) == nullptr) {
dev->set_selected_machine("");
if (m_agent)
m_agent->set_user_selected_machine("");
show_status((int)MONITOR_NO_PRINTER);
return;
}
//BBS check mqtt connections if user is login
if (wxGetApp().is_user_login()) {
// check mqtt connection and reconnect if disconnected
@ -394,16 +399,11 @@ void MonitorPanel::update_all()
}
m_status_info_panel->obj = obj;
#if !BBL_RELEASE_TO_PUBLIC
m_upgrade_panel->update(obj);
#endif
m_status_info_panel->m_media_play_ctrl->SetMachineObject(IsShown() ? obj : nullptr);
#if !BBL_RELEASE_TO_PUBLIC
m_status_info_panel->m_media_play_ctrl->SetMachineObject(obj);
m_media_file_panel->SetMachineObject(obj);
#endif
update_status(obj);
if (!obj) {
@ -433,14 +433,12 @@ void MonitorPanel::update_all()
m_status_info_panel->update(obj);
}
#if !BBL_RELEASE_TO_PUBLIC
if (m_hms_panel->IsShown()) {
m_hms_panel->update(obj);
}
if (m_upgrade_panel->IsShown()) {
m_upgrade_panel->update(obj);
}
#endif
}
bool MonitorPanel::Show(bool show)
@ -468,7 +466,6 @@ bool MonitorPanel::Show(bool show)
}
} else {
m_refresh_timer->Stop();
m_status_info_panel->m_media_play_ctrl->SetMachineObject(nullptr);
}
return wxPanel::Show(show);
}

View file

@ -448,9 +448,24 @@ void Mouse3DController::render_settings_dialog(GLCanvas3D& canvas) const
ImGuiWrapper& imgui = *wxGetApp().imgui();
imgui.set_next_window_pos(0.5f * (float)cnv_size.get_width(), 0.5f * (float)cnv_size.get_height(), ImGuiCond_Always, 0.5f, 0.5f);
float space_size = imgui.get_style_scaling() * 8;
float speed_size = imgui.calc_text_size(_L("Speed:")).x + imgui.scaled(1.5f);
float dead_size = imgui.calc_text_size(_L("Deadzone:")).x + imgui.scaled(1.5f);
float option_size = imgui.calc_text_size(_L("Options:")).x + imgui.scaled(1.5f);
float max_left_size = std::max(speed_size,std::max(dead_size,option_size)) + space_size;
float trans_size = imgui.calc_text_size(_L("Translate")).x + space_size;
float zoom_size = imgui.calc_text_size(_L("Zoom")).x + space_size;
float rota_size = imgui.calc_text_size(_L("Rotation")).x + space_size;
float trasn_zoom_size = imgui.calc_text_size(_L("Translation/Zoom")).x + space_size;
float max_slider_txt_size = std::max(std::max(trans_size,zoom_size),std::max(rota_size,trasn_zoom_size));
ImGuiWrapper::push_toolbar_style(wxGetApp().plater()->canvas3D()->get_scale());
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(20.0f, 20.0f));
static ImVec2 last_win_size(0.0f, 0.0f);
bool shown = true;
if (imgui.begin(_L("3Dconnexion settings"), &shown, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse)) {
if (imgui.begin(_L("3Dconnexion settings"), &shown, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse || ImGuiWindowFlags_NoTitleBar)) {
if (shown) {
ImVec2 win_size = ImGui::GetWindowSize();
if (last_win_size.x != win_size.x || last_win_size.y != win_size.y) {
@ -460,52 +475,109 @@ void Mouse3DController::render_settings_dialog(GLCanvas3D& canvas) const
canvas.request_extra_frame();
}
const ImVec4& color = ImGui::GetStyleColorVec4(ImGuiCol_Separator);
imgui.text_colored(color, _L("Device:"));
const ImVec4& color = ImVec4(0.56f, 0.56f, 0.56f, 1.00f);
/*imgui.text(_L("Device:"));
ImGui::SameLine();
imgui.text(m_device_str);
ImGui::Separator();
imgui.text_colored(color, _L("Speed:"));
imgui.text(m_device_str);*/
ImGui::AlignTextToFramePadding();
imgui.text_colored(color,_L("Speed:"));
ImGui::SameLine(max_left_size + max_slider_txt_size - trans_size);
imgui.text(_L("Translate"));
ImGui::SameLine(max_left_size + max_slider_txt_size);
ImGui::PushItemWidth(imgui.scaled(6.0f));
float translation_scale = float(params_copy.translation.scale) / float(Params::DefaultTranslationScale);
if (imgui.slider_float(_L("Translation"), &translation_scale, float(Params::MinTranslationScale), float(Params::MaxTranslationScale), "%.1f")) {
bool b_translation = imgui.bbl_slider_float_style("##Translate", &translation_scale, float(Params::MinTranslationScale), float(Params::MaxTranslationScale), "%.1f");
ImGui::SameLine();
ImGui::PushItemWidth(imgui.scaled(3.0f));
bool b_translation_dragfloat = ImGui::BBLDragFloat("##Translate_input", &translation_scale, float(Params::MinTranslationScale), float(Params::MaxTranslationScale),0.0, "%.1f");
if (b_translation || b_translation_dragfloat) {
params_copy.translation.scale = Params::DefaultTranslationScale * double(translation_scale);
params_changed = true;
}
ImGui::SameLine();
ImGui::Dummy({space_size, 0.0});
ImGui::Dummy({0.0, 0.0});
ImGui::SameLine(max_left_size + max_slider_txt_size - rota_size);
ImGui::AlignTextToFramePadding();
imgui.text(_L("Rotation"));
ImGui::SameLine(max_left_size + max_slider_txt_size);
ImGui::PushItemWidth(imgui.scaled(6.0f));
float rotation_scale = params_copy.rotation.scale / Params::DefaultRotationScale;
if (imgui.slider_float(_L("Rotation") + "##1", &rotation_scale, 0.1f, 10.0f, "%.1f")) {
bool b_rotation1 = imgui.bbl_slider_float_style("##Rotation1", &rotation_scale, 0.1f, 10.0f, "%.1f");
ImGui::SameLine();
ImGui::PushItemWidth(imgui.scaled(3.0f));
bool b_rotation1_dragfloat = ImGui::BBLDragFloat("##Rotation1_input", &rotation_scale, 0.1f, 10.0f, 0.0, "%.1f");
if (b_rotation1 || b_rotation1_dragfloat) {
params_copy.rotation.scale = Params::DefaultRotationScale * rotation_scale;
params_changed = true;
}
ImGui::SameLine();
ImGui::Dummy({space_size, 0.0});
ImGui::Dummy({0.0, 0.0});
ImGui::SameLine(max_left_size + max_slider_txt_size - zoom_size);
ImGui::AlignTextToFramePadding();
imgui.text(_L("Zoom"));
ImGui::SameLine(max_left_size + max_slider_txt_size);
ImGui::PushItemWidth(imgui.scaled(6.0f));
float zoom_scale = params_copy.zoom.scale / Params::DefaultZoomScale;
if (imgui.slider_float(_L("Zoom"), &zoom_scale, 0.1f, 10.0f, "%.1f")) {
bool b_zoom = imgui.bbl_slider_float_style("##Zoom", &zoom_scale, 0.1f, 10.0f, "%.1f");
ImGui::SameLine();
ImGui::PushItemWidth(imgui.scaled(3.0f));
bool b_zoom_dragfloat = ImGui::BBLDragFloat("##Zoom_input", &zoom_scale, 0.1f, 10.0f, 0.0, "%.1f");
if (b_zoom || b_zoom_dragfloat) {
params_copy.zoom.scale = Params::DefaultZoomScale * zoom_scale;
params_changed = true;
}
ImGui::Separator();
imgui.text_colored(color, _L("Deadzone:"));
ImGui::AlignTextToFramePadding();
imgui.text_colored(color,_L("Deadzone:"));
ImGui::SameLine(max_left_size + max_slider_txt_size - trasn_zoom_size);
imgui.text(_L("Translation/Zoom"));
ImGui::SameLine(max_left_size + max_slider_txt_size);
float translation_deadzone = (float)params_copy.translation.deadzone;
if (imgui.slider_float(_L("Translation") + "/" + _L("Zoom"), &translation_deadzone, 0.0f, (float)Params::MaxTranslationDeadzone, "%.2f")) {
params_copy.translation.deadzone = (double)translation_deadzone;
params_changed = true;
ImGui::PushItemWidth(imgui.scaled(6.0f));
float translation_deadzone = (float) params_copy.translation.deadzone;
bool b_tran_zoom = imgui.bbl_slider_float_style("##Translation/Zoom", &translation_deadzone, 0.0f, (float) Params::MaxTranslationDeadzone, "%.2f");
ImGui::SameLine();
ImGui::PushItemWidth(imgui.scaled(3.0f));
bool b_tran_zoom_dragfloat = ImGui::BBLDragFloat("##Translation/Zoom_input", &translation_deadzone, 0.0f, (float) Params::MaxTranslationDeadzone, 0.0, "%.1f");
if (b_tran_zoom || b_tran_zoom_dragfloat) {
params_copy.translation.deadzone = (double) translation_deadzone;
params_changed = true;
}
ImGui::SameLine();
ImGui::Dummy({space_size, 0.0});
ImGui::Dummy({0.0, 0.0});
ImGui::SameLine(max_left_size + max_slider_txt_size - rota_size);
ImGui::AlignTextToFramePadding();
imgui.text(_L("Rotation"));
ImGui::SameLine(max_left_size + max_slider_txt_size);
ImGui::PushItemWidth(imgui.scaled(6.0f));
float rotation_deadzone = params_copy.rotation.deadzone;
if (imgui.slider_float(_L("Rotation") + "##2", &rotation_deadzone, 0.0f, Params::MaxRotationDeadzone, "%.2f")) {
params_copy.rotation.deadzone = rotation_deadzone;
params_changed = true;
bool b_rotation2 = imgui.bbl_slider_float_style("##Rotation2", &rotation_deadzone, 0.0f, Params::MaxRotationDeadzone, "%.2f");
ImGui::SameLine();
ImGui::PushItemWidth(imgui.scaled(3.0f));
bool b_rotation2_dragfloat = ImGui::BBLDragFloat("##Rotation2_input", &rotation_deadzone, 0.0f, Params::MaxRotationDeadzone, 0.0, "%.1f");
if (b_rotation2 || b_rotation2_dragfloat) {
params_copy.rotation.deadzone = rotation_deadzone;
params_changed = true;
}
ImGui::SameLine();
ImGui::Dummy({space_size, 0.0});
ImGui::PopItemWidth();
ImGui::Separator();
imgui.text_colored(color, _L("Options:"));
ImGui::AlignTextToFramePadding();
imgui.text_colored(color,_L("Options:"));
ImGui::SameLine(max_left_size + max_slider_txt_size - imgui.get_slider_icon_size().x + + space_size);
bool swap_yz = params_copy.swap_yz;
if (imgui.checkbox(_L("Swap Y/Z axes"), swap_yz)) {
if (imgui.bbl_checkbox(_L("Swap Y/Z axes"), swap_yz)) {
params_copy.swap_yz = swap_yz;
params_changed = true;
}
@ -540,6 +612,9 @@ void Mouse3DController::render_settings_dialog(GLCanvas3D& canvas) const
#endif // ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
ImGui::Separator();
float window_width = ImGui::GetWindowWidth();
ImGui::Dummy({0.0, 0.0});
ImGui::SameLine((window_width - imgui.calc_text_size(_L("Close")).x)/2);
if (imgui.button(_L("Close"))) {
// the user clicked on the [Close] button
m_settings_dialog_closed_by_user = true;
@ -554,7 +629,8 @@ void Mouse3DController::render_settings_dialog(GLCanvas3D& canvas) const
}
imgui.end();
ImGui::PopStyleVar(1);
ImGuiWrapper::pop_toolbar_style();
if (params_changed) {
// Synchronize front end parameters to back end.
std::scoped_lock<std::mutex> lock(m_params_ui_mutex);

View file

@ -768,9 +768,9 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord h_pos, wxCoord v_pos)
break;
}
}
//is_url_string = !suppress_hyperlinks && !og_line.label_path.empty();
is_url_string = !suppress_hyperlinks && !og_line.label_path.empty();
// BBS
h_pos = draw_text(dc, wxPoint(h_pos, v_pos), label /* + ":" */, text_clr, ctrl->opt_group->label_width * ctrl->m_em_unit, true);
h_pos = draw_text(dc, wxPoint(h_pos, v_pos), label /* + ":" */, text_clr, ctrl->opt_group->label_width * ctrl->m_em_unit, is_url_string, true);
}
// If there's a widget, build it and set result to the correct position.
@ -844,12 +844,12 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord h_pos, wxCoord v_pos)
//if (!ctrl->opt_group->option_label_at_right) // BBS
//label += ":";
//if (is_url_string)
// is_url_string = false;
//else if(opt == option_set.front())
// is_url_string = !suppress_hyperlinks && !og_line.label_path.empty();
if (is_url_string)
is_url_string = false;
else if(opt == option_set.front())
is_url_string = !suppress_hyperlinks && !og_line.label_path.empty();
static wxColor c("#6B6B6B");
h_pos = draw_text(dc, wxPoint(h_pos, v_pos), label, field ? (field->blink() ? &blink_color : &c) : nullptr, ctrl->opt_group->sublabel_width * ctrl->m_em_unit);
h_pos = draw_text(dc, wxPoint(h_pos, v_pos), label, field ? (field->blink() ? &blink_color : &c) : nullptr, ctrl->opt_group->sublabel_width * ctrl->m_em_unit, is_url_string);
h_pos += 8;
}
@ -884,7 +884,7 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord h_pos, wxCoord v_pos)
}
}
wxCoord OG_CustomCtrl::CtrlLine::draw_text(wxDC& dc, wxPoint pos, const wxString& text, const wxColour* color, int width, bool is_main/* = false*/)
wxCoord OG_CustomCtrl::CtrlLine::draw_text(wxDC &dc, wxPoint pos, const wxString &text, const wxColour *color, int width, bool is_url/* = false*/, bool is_main/* = false*/)
{
wxString multiline_text;
auto size = Label::split_lines(dc, width, text, multiline_text);
@ -903,13 +903,16 @@ wxCoord OG_CustomCtrl::CtrlLine::draw_text(wxDC& dc, wxPoint pos, const wxStr
wxColour old_clr = dc.GetTextForeground();
wxFont old_font = dc.GetFont();
// if (is_focused && is_url)
// // temporary workaround for the OSX because of strange Bold font behavior on BigSerf
//#ifdef __APPLE__
// dc.SetFont(old_font.Underlined());
//#else
// dc.SetFont(old_font.Bold().Underlined());
//#endif
static wxColor clr_url("#00AE42");
if (is_focused && is_url) {
// temporary workaround for the OSX because of strange Bold font behavior on BigSerf
#ifdef __APPLE__
dc.SetFont(old_font.Underlined());
#else
dc.SetFont(old_font.Bold().Underlined());
#endif
color = &clr_url;
}
dc.SetTextForeground(color ? *color :
#ifdef _WIN32
wxGetApp().get_label_clr_default());
@ -983,7 +986,7 @@ bool OG_CustomCtrl::CtrlLine::launch_browser() const
if (!is_focused || og_line.label_path.empty())
return false;
return true;
return OptionsGroup::launch_browser(og_line.label_path);
}
} // GUI

View file

@ -61,7 +61,7 @@ class OG_CustomCtrl :public wxPanel
void render_separator(wxDC& dc, wxCoord v_pos);
void render(wxDC& dc, wxCoord h_pos, wxCoord v_pos);
wxCoord draw_text (wxDC& dc, wxPoint pos, const wxString& text, const wxColour* color, int width, bool is_url = false);
wxCoord draw_text (wxDC& dc, wxPoint pos, const wxString& text, const wxColour* color, int width, bool is_url = false, bool is_main = false);
wxPoint draw_blinking_bmp(wxDC& dc, wxPoint pos, bool is_blinking);
wxCoord draw_act_bmps(wxDC& dc, wxPoint pos, const wxBitmap& bmp_undo_to_sys, const wxBitmap& bmp_undo, bool is_blinking, size_t rect_id = 0);
bool launch_browser() const;

View file

@ -1378,7 +1378,7 @@ void ObjectDataViewModel::UpdateVolumesExtruderBitmap(wxDataViewItem obj_item, b
return;
ObjectDataViewModelNode* obj_node = static_cast<ObjectDataViewModelNode*>(obj_item.GetID());
for (auto child : obj_node->GetChildren())
if (child->GetVolumeType() == ModelVolumeType::MODEL_PART)
if (child->GetVolumeType() == ModelVolumeType::MODEL_PART || child->GetVolumeType() == ModelVolumeType::PARAMETER_MODIFIER)
child->UpdateExtruderAndColorIcon(use_obj_extruder ? obj_node->GetExtruder() : "");
}

View file

@ -1217,7 +1217,7 @@ void ExtruderOptionsGroup::on_change_OG(const t_config_option_key& opt_id, const
wxString OptionsGroup::get_url(const std::string& path_end)
{
//BBS
return "";
return wxString::Format(L"https://wiki.bambulab.com/%s/software/bambu-studio/%s", L"en", from_u8(path_end));
}
bool OptionsGroup::launch_browser(const std::string& path_end)

View file

@ -74,7 +74,7 @@ public:
};
private:
PartPlateList* m_partplate_list;
PartPlateList* m_partplate_list {nullptr };
Plater* m_plater; //Plater reference, not own it
Model* m_model; //Model reference, not own it
PrinterTechnology printer_technology;
@ -507,7 +507,7 @@ public:
m_height_limit_mode = mode;
}
int get_curr_plate_index() { return m_current_plate; }
int get_curr_plate_index() const { return m_current_plate; }
PartPlate* get_curr_plate() { return m_plate_list[m_current_plate]; }
PartPlate* get_selected_plate();

View file

@ -1,5 +1,4 @@
#include "Plater.hpp"
#include <cstddef>
#include <algorithm>
#include <numeric>
@ -41,6 +40,7 @@
#include "libslic3r/libslic3r.h"
#include "libslic3r/Format/STL.hpp"
#include "libslic3r/Format/STEP.hpp"
#include "libslic3r/Format/AMF.hpp"
//#include "libslic3r/Format/3mf.hpp"
#include "libslic3r/Format/bbs_3mf.hpp"
@ -296,7 +296,7 @@ struct Sidebar::priv
wxStaticLine* m_staticline2;
wxPanel* m_panel_project_title;
ScalableButton* m_filament_icon = nullptr;
ScalableButton * m_flushing_volume_btn = nullptr;
Button * m_flushing_volume_btn = nullptr;
// BBS printer config
StaticBox* m_panel_printer_title = nullptr;
@ -570,11 +570,34 @@ Sidebar::Sidebar(Plater *parent)
spliter_2->SetLineColour("#CECECE");
scrolled_sizer->Add(spliter_2, 0, wxEXPAND);
bSizer39->AddStretchSpacer(1);
// BBS
// add wiping dialog
p->m_flushing_volume_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "flush_volumes");
p->m_flushing_volume_btn->SetToolTip(_L("Flushing volumes"));
//wiping_dialog_button->SetFont(wxGetApp().normal_font());
p->m_flushing_volume_btn = new Button(p->m_panel_filament_title, _L("Flushing volumes"));
p->m_flushing_volume_btn->SetFont(Label::Body_10);
p->m_flushing_volume_btn->SetPaddingSize(wxSize(FromDIP(8),FromDIP(3)));
p->m_flushing_volume_btn->SetCornerRadius(FromDIP(8));
StateColor flush_bg_col(std::pair<wxColour, int>(wxColour(219, 253, 231), StateColor::Pressed),
std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Hovered),
std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Normal));
StateColor flush_fg_col(std::pair<wxColour, int>(wxColour(107, 107, 107), StateColor::Pressed),
std::pair<wxColour, int>(wxColour(107, 107, 107), StateColor::Hovered),
std::pair<wxColour, int>(wxColour(107, 107, 107), StateColor::Normal));
StateColor flush_bd_col(std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Pressed),
std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Hovered),
std::pair<wxColour, int>(wxColour(172, 172, 172), StateColor::Normal));
p->m_flushing_volume_btn->SetBackgroundColor(flush_bg_col);
p->m_flushing_volume_btn->SetBorderColor(flush_bd_col);
p->m_flushing_volume_btn->SetTextColor(flush_fg_col);
p->m_flushing_volume_btn->SetFocus();
p->m_flushing_volume_btn->SetId(wxID_RESET);
p->m_flushing_volume_btn->Rescale();
p->m_flushing_volume_btn->Bind(wxEVT_BUTTON, ([parent](wxCommandEvent &e)
{
@ -604,10 +627,9 @@ Sidebar::Sidebar(Plater *parent)
wxPostEvent(parent, SimpleEvent(EVT_SCHEDULE_BACKGROUND_PROCESS, parent));
}
}));
bSizer39->Add(p->m_flushing_volume_btn, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, em);
bSizer39->Add(p->m_flushing_volume_btn, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(5));
bSizer39->Hide(p->m_flushing_volume_btn);
bSizer39->AddStretchSpacer(1);
bSizer39->Add(FromDIP(10), 0, 0, 0, 0 );
ScalableButton* add_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "add_filament");
add_btn->Bind(wxEVT_BUTTON, [this, scrolled_sizer](wxCommandEvent& e){
@ -967,7 +989,7 @@ void Sidebar::msw_rescale()
p->m_bpButton_add_filament->msw_rescale();
p->m_bpButton_del_filament->msw_rescale();
p->m_bpButton_set_filament->msw_rescale();
p->m_flushing_volume_btn->msw_rescale();
p->m_flushing_volume_btn->Rescale();
//BBS
m_bed_type_list->Rescale();
m_bed_type_list->SetMinSize({-1, 3 * wxGetApp().em_unit()});
@ -1838,6 +1860,7 @@ struct Plater::priv
// returns the path to project file with the given extension (none if extension == wxEmptyString)
// extension should contain the leading dot, i.e.: ".3mf"
wxString get_project_filename(const wxString& extension = wxEmptyString) const;
wxString get_export_gcode_filename(const wxString& extension = wxEmptyString, bool only_filename = false) const;
void set_project_filename(const wxString& filename);
//BBS store bbs project name
@ -2593,7 +2616,39 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
int answer_convert_from_imperial_units = wxOK_DEFAULT;
int tolal_model_count = 0;
int progress_percent = 0;
int total_files = input_files.size();
const int stage_percent[IMPORT_STAGE_MAX+1] = {
5, // IMPORT_STAGE_RESTORE
10, // IMPORT_STAGE_OPEN
30, // IMPORT_STAGE_READ_FILES
50, // IMPORT_STAGE_EXTRACT
60, // IMPORT_STAGE_LOADING_OBJECTS
70, // IMPORT_STAGE_LOADING_PLATES
80, // IMPORT_STAGE_FINISH
85, // IMPORT_STAGE_ADD_INSTANCE
90, // IMPORT_STAGE_UPDATE_GCODE
92, // IMPORT_STAGE_CHECK_MODE_GCODE
95, // UPDATE_GCODE_RESULT
98, // IMPORT_LOAD_CONFIG
99, // IMPORT_LOAD_MODEL_OBJECTS
100
};
const int step_percent[LOAD_STEP_STAGE_NUM+1] = {
5, // LOAD_STEP_STAGE_READ_FILE
30, // LOAD_STEP_STAGE_GET_SOLID
60, // LOAD_STEP_STAGE_GET_MESH
100
};
const float INPUT_FILES_RATIO = 0.7;
const float INIT_MODEL_RATIO = 0.75;
const float CENTER_AROUND_ORIGIN_RATIO = 0.8;
const float LOAD_MODEL_RATIO = 0.9;
for (size_t i = 0; i < input_files.size(); ++i) {
int file_percent = 0;
#ifdef _WIN32
auto path = input_files[i];
// On Windows, we swap slashes to back slashes, see GH #6803 as read_from_file() does not understand slashes on Windows thus it assignes full path to names of loaded objects.
@ -2603,15 +2658,13 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
const auto &path = input_files[i];
#endif // _WIN32
const auto filename = path.filename();
int progress_percent = static_cast<int>(100.0f * static_cast<float>(i) / static_cast<float>(input_files.size()));
int progress_percent = static_cast<int>(100.0f * static_cast<float>(i) / static_cast<float>(input_files.size()));
const auto real_filename = (strategy & LoadStrategy::Restore) ? input_files[++i].filename() : filename;
const auto dlg_info = _L("Loading file") + ": " + from_path(real_filename);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": load file %1%") % filename;
dlg_cont = dlg.Update(progress_percent, dlg_info);
if (!dlg_cont) return empty_result;
dlg.Fit();
const bool type_3mf = std::regex_match(path.string(), pattern_3mf);
// const bool type_zip_amf = !type_3mf && std::regex_match(path.string(), pattern_zip_amf);
const bool type_any_amf = !type_3mf && std::regex_match(path.string(), pattern_any_amf);
@ -2642,19 +2695,22 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
// BBS: backup & restore
model = Slic3r::Model::read_from_archive(path.string(), &config_loaded, &config_substitutions, en_3mf_file_type, strategy, &plate_data, &project_presets,
&file_version,
[this, &dlg, real_filename, progress_percent](int import_stage, int current, int total, bool &cancel) {
[this, &dlg, real_filename, &progress_percent, &file_percent, stage_percent, INPUT_FILES_RATIO, total_files, i](int import_stage, int current, int total, bool &cancel) {
bool cont = true;
float percent_float = (100.0f * (float)i / (float)total_files) + INPUT_FILES_RATIO * ((float)stage_percent[import_stage] + (float)current * (float)(stage_percent[import_stage + 1] - stage_percent[import_stage]) /(float) total) / (float)total_files;
BOOST_LOG_TRIVIAL(trace) << "load_3mf_file: percent(float)=" << percent_float << ", stage = " << import_stage << ", curr = " << current << ", total = " << total;
progress_percent = (int)percent_float;
wxString msg = wxString::Format(_L("Loading file: %s"), from_path(real_filename));
cont = dlg.Update(progress_percent, msg);
cancel = !cont;
});
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__
<< boost::format(", plate_data.size %1%, project_preset.size %2%, is_bbs_3mf %3%, file_version %4% \n") % plate_data.size() %
project_presets.size() % (en_3mf_file_type == En3mfType::From_BBS) % file_version.to_string();
// add extruder for prusa model if the number of existing extruders is not enough
if (en_3mf_file_type == En3mfType::From_Prusa) {
// 1. add extruder for prusa model if the number of existing extruders is not enough
// 2. add extruder for BBS model if only import geometry
if (en_3mf_file_type == En3mfType::From_Prusa || (en_3mf_file_type == En3mfType::From_BBS && load_model && !load_config)) {
std::set<int> extruderIds;
for (ModelObject *o : model.objects) {
if (o->config.option("extruder")) extruderIds.insert(o->config.extruder());
@ -2725,11 +2781,36 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
context += append;
show_info(q, context, _L("Newer 3mf version"));
}
else {
//if the minor version is not matched
if (file_version.min() != app_version.min()) {
wxString text = wxString::Format(_L("The 3mf's version %s is newer than %s's version %s, Suggest to upgrade your software.\n"),
file_version.to_string(), std::string(SLIC3R_APP_FULL_NAME), app_version.to_string());
show_info(q, text, _L("Newer 3mf version"));
}
}
} else if (!load_config) {
// reset config except color
for (ModelObject *model_object : model.objects) {
bool has_extruder = model_object->config.has("extruder");
int extruder_id = -1;
// save the extruder information before reset
if (has_extruder) { extruder_id = model_object->config.extruder(); }
model_object->config.reset();
// restore the extruder after reset
if (has_extruder) { model_object->config.set("extruder", extruder_id); }
// Is there any modifier or advanced config data?
for (ModelVolume *model_volume : model_object->volumes) model_volume->config.reset();
for (ModelVolume *model_volume : model_object->volumes) {
has_extruder = model_volume->config.has("extruder");
if (has_extruder) { extruder_id = model_volume->config.extruder(); }
model_volume->config.reset();
if (has_extruder) { model_volume->config.set("extruder", extruder_id); }
}
}
}
@ -2883,11 +2964,25 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
Semver file_version;
model = Slic3r::Model::read_from_file(
path.string(), nullptr, nullptr, strategy, &plate_data, &project_presets, &is_xxx, &file_version, nullptr,
[&dlg, real_filename, progress_percent](int import_stage, int current, int total, bool &cancel) {
bool cont = true;
wxString msg = wxString::Format("Loading file: %s", from_path(real_filename));
cont = dlg.Update(progress_percent, msg);
cancel = !cont;
[this, &dlg, real_filename, &progress_percent, &file_percent, INPUT_FILES_RATIO, total_files, i](int current, int total, bool &cancel)
{
bool cont = true;
float percent_float = (100.0f * (float)i / (float)total_files) + INPUT_FILES_RATIO * 100.0f * ((float)current / (float)total) / (float)total_files;
BOOST_LOG_TRIVIAL(trace) << "load_stl_file: percent(float)=" << percent_float << ", curr = " << current << ", total = " << total;
progress_percent = (int)percent_float;
wxString msg = wxString::Format(_L("Loading file: %s"), from_path(real_filename));
cont = dlg.Update(progress_percent, msg);
cancel = !cont;
},
[this, &dlg, real_filename, &progress_percent, &file_percent, step_percent, INPUT_FILES_RATIO, total_files, i](int load_stage, int current, int total, bool &cancel)
{
bool cont = true;
float percent_float = (100.0f * (float)i / (float)total_files) + INPUT_FILES_RATIO * ((float)step_percent[load_stage] + (float)current * (float)(step_percent[load_stage + 1] - step_percent[load_stage]) / (float)total) / (float)total_files;
BOOST_LOG_TRIVIAL(trace) << "load_step_file: percent(float)=" << percent_float << ", stage = " << load_stage << ", curr = " << current << ", total = " << total;
progress_percent = (int)percent_float;
wxString msg = wxString::Format(_L("Loading file: %s"), from_path(real_filename));
cont = dlg.Update(progress_percent, msg);
cancel = !cont;
},
[](int isUtf8StepFile) {
if (!isUtf8StepFile)
@ -2929,6 +3024,10 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
continue;
}
progress_percent = 100.0f * (float)i / (float)total_files + INIT_MODEL_RATIO * 100.0f / (float)total_files;
dlg_cont = dlg.Update(progress_percent);
if (!dlg_cont) return empty_result;
if (load_model) {
// The model should now be initialized
auto convert_from_imperial_units = [](Model &model, bool only_small_volumes) { model.convert_from_imperial_units(only_small_volumes); };
@ -3005,6 +3104,10 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
// return obj_idxs;
//}
progress_percent = 100.0f * (float)i / (float)total_files + CENTER_AROUND_ORIGIN_RATIO * 100.0f / (float)total_files;
dlg_cont = dlg.Update(progress_percent);
if (!dlg_cont) return empty_result;
int model_idx = 0;
for (ModelObject *model_object : model.objects) {
if (!type_3mf && !type_any_amf) model_object->center_around_origin(false);
@ -3021,6 +3124,9 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
tolal_model_count += model_idx;
progress_percent = 100.0f * (float)i / (float)total_files + LOAD_MODEL_RATIO * 100.0f / (float)total_files;
dlg_cont = dlg.Update(progress_percent);
if (!dlg_cont) return empty_result;
if (one_by_one) {
// BBS: add load_old_project logic
@ -5625,8 +5731,30 @@ PlateBBoxData Plater::priv::generate_first_layer_bbox()
wxString Plater::priv::get_project_filename(const wxString& extension) const
{
auto full_filename = m_project_folder / std::string((m_project_name + extension).mb_str(wxConvUTF8));
return m_project_folder.empty() ? "" : from_path(full_filename);
if (m_project_name.empty())
return "";
else {
auto full_filename = m_project_folder / std::string((m_project_name + extension).mb_str(wxConvUTF8));
return m_project_folder.empty() ? "" : from_path(full_filename);
}
}
wxString Plater::priv::get_export_gcode_filename(const wxString& extension, bool only_filename) const
{
std::string plate_index_str = (boost::format("_plate_%1%") % std::to_string(partplate_list.get_curr_plate_index() + 1)).str();
if (!m_project_folder.empty()) {
if (!only_filename) {
auto full_filename = m_project_folder / std::string((m_project_name + plate_index_str + extension).mb_str(wxConvUTF8));
return from_path(full_filename);
} else {
return m_project_name + wxString(plate_index_str) + extension;
}
} else {
if (only_filename)
return m_project_name + wxString(plate_index_str) + extension;
else
return "";
}
}
wxString Plater::priv::get_project_name()
@ -6188,8 +6316,7 @@ void Plater::priv::undo()
// BBS: undo-redo until modify record
while (--it_current != snapshots.begin() && !snapshot_modifies_project(*it_current));
if (it_current == snapshots.begin()) return;
while (--it_current != snapshots.begin() && !snapshot_modifies_project(*it_current));
this->undo_redo_to(++it_current);
this->undo_redo_to(it_current);
}
void Plater::priv::redo()
@ -6198,8 +6325,10 @@ void Plater::priv::redo()
auto it_current = std::lower_bound(snapshots.begin(), snapshots.end(), UndoRedo::Snapshot(this->undo_redo_stack().active_snapshot_time()));
// BBS: undo-redo until modify record
while (it_current != snapshots.end() && !snapshot_modifies_project(*it_current++));
if (it_current != snapshots.end())
this->undo_redo_to(it_current);
if (it_current != snapshots.end()) {
while (it_current != snapshots.end() && !snapshot_modifies_project(*it_current++));
this->undo_redo_to(--it_current);
}
}
void Plater::priv::undo_redo_to(size_t time_to_load)
@ -6336,6 +6465,9 @@ void Plater::priv::undo_redo_to(std::vector<UndoRedo::Snapshot>::const_iterator
}
if (need_update) {
// update print to current plate (preview->m_process)
this->partplate_list.update_slice_context_to_current_plate(this->background_process);
this->preview->update_gcode_result(this->partplate_list.get_current_slice_result());
this->update();
}
}
@ -6996,12 +7128,13 @@ ProjectDropDialog::ProjectDropDialog(const std::string &filename)
m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, 10);
wxBoxSizer *m_sizer_bottom = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *m_sizer_left = new wxBoxSizer(wxHORIZONTAL);
// hide the "Don't show again" checkbox
//wxBoxSizer *m_sizer_left = new wxBoxSizer(wxHORIZONTAL);
auto dont_show_again = create_item_checkbox(_L("Don't show again"), this, _L("Don't show again"), "show_drop_project_dialog");
m_sizer_left->Add(dont_show_again, 0, wxALL, 5);
//auto dont_show_again = create_item_checkbox(_L("Don't show again"), this, _L("Don't show again"), "show_drop_project_dialog");
//m_sizer_left->Add(dont_show_again, 0, wxALL, 5);
m_sizer_bottom->Add(m_sizer_left, 0, wxEXPAND, 5);
//m_sizer_bottom->Add(m_sizer_left, 0, wxEXPAND, 5);
m_sizer_bottom->Add(0, 0, 1, wxEXPAND, 5);
@ -7926,16 +8059,28 @@ void Plater::export_gcode_3mf()
//calc default_output_file, get default output file from background process
fs::path default_output_file;
default_output_file = into_path(get_project_filename(".3mf"));
if (default_output_file.empty())
default_output_file = into_path(get_project_name() + ".3mf");
AppConfig& appconfig = *wxGetApp().app_config;
std::string start_dir;
default_output_file = into_path(get_export_gcode_filename(".3mf"));
if (default_output_file.empty()) {
try {
start_dir = appconfig.get_last_output_dir("", false);
wxString filename = get_export_gcode_filename(".3mf", true);
std::string full_filename = start_dir + "/" + filename.utf8_string();
default_output_file = boost::filesystem::path(full_filename);
} catch(...) {
;
}
}
//BBS replace gcode extension to .gcode.3mf
default_output_file = default_output_file.replace_extension(".gcode.3mf");
default_output_file = fs::path(Slic3r::fold_utf8_to_ascii(default_output_file.string()));
AppConfig &appconfig = *wxGetApp().app_config;
//Get a last save path
std::string start_dir = appconfig.get_last_output_dir(default_output_file.parent_path().string(), false);
start_dir = appconfig.get_last_output_dir(default_output_file.parent_path().string(), false);
fs::path output_path;
{
std::string ext = default_output_file.extension().string();
@ -7945,8 +8090,12 @@ void Plater::export_gcode_3mf()
GUI::file_wildcards(FT_3MF, ext),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT
);
if (dlg.ShowModal() == wxID_OK)
if (dlg.ShowModal() == wxID_OK) {
output_path = into_path(dlg.GetPath());
ext = output_path.extension().string();
if (ext != ".3mf")
output_path = output_path.string() + ".3mf";
}
}
if (!output_path.empty()) {
@ -7965,6 +8114,14 @@ void Plater::export_gcode_3mf()
}
}
void Plater::export_core_3mf()
{
wxString path = p->get_export_file(FT_3MF);
if (path.empty()) { return; }
const std::string path_u8 = into_u8(path);
export_3mf(path_u8, SaveStrategy::Silence);
}
void Plater::export_stl(bool extended, bool selection_only)
{
if (p->model.objects.empty()) { return; }
@ -8957,6 +9114,11 @@ wxString Plater::get_project_filename(const wxString& extension) const
return p->get_project_filename(extension);
}
wxString Plater::get_export_gcode_filename(const wxString & extension, bool only_filename) const
{
return p->get_export_gcode_filename(extension, only_filename);
}
void Plater::set_project_filename(const wxString& filename)
{
p->set_project_filename(filename);

View file

@ -297,6 +297,7 @@ public:
void export_gcode(bool prefer_removable);
void export_gcode_3mf();
void export_core_3mf();
void export_stl(bool extended = false, bool selection_only = false);
//BBS: remove amf
//void export_amf();
@ -371,6 +372,7 @@ public:
//void show_action_buttons(const bool is_ready_to_slice) const;
wxString get_project_filename(const wxString& extension = wxEmptyString) const;
wxString get_export_gcode_filename(const wxString& extension = wxEmptyString, bool only_filename = false) const;
void set_project_filename(const wxString& filename);
bool is_export_gcode_scheduled() const;

View file

@ -390,8 +390,10 @@ void PresetComboBox::add_ams_filaments(std::string selected, bool alias_name)
std::string setting_id = f.opt_string("filament_settings_id", 0u);
auto iter = std::find_if(filaments.begin(), filaments.end(),
[&setting_id](auto &f) { return f.is_compatible && f.is_system && f.filament_id == setting_id; });
if (iter == filaments.end())
if (iter == filaments.end()) {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": filament_id %1% not found or system or compatible") % setting_id;
continue;
}
const_cast<Preset&>(*iter).is_visible = true;
auto color = f.opt_string("filament_colour", 0u);
wxColour clr(color);

View file

@ -75,6 +75,26 @@ void PrintOptionsDialog::update_spaghetti()
void PrintOptionsDialog::update_options(MachineObject *obj_)
{
if (!obj_) return;
if (obj_->is_function_supported(PrinterFunction::FUNC_FIRSTLAYER_INSPECT)) {
text_first_layer->Show();
m_cb_first_layer->Show();
} else {
text_first_layer->Hide();
m_cb_first_layer->Hide();
}
if (obj_->is_function_supported(PrinterFunction::FUNC_SPAGHETTI)) {
text_spaghetti->Show();
m_cb_spaghetti->Show();
m_cb_spaghetti_print_halt->Show();
text_spaghetti_print_halt->Show();
}else {
text_spaghetti->Hide();
m_cb_spaghetti->Hide();
m_cb_spaghetti_print_halt->Hide();
text_spaghetti_print_halt->Hide();
}
this->Freeze();
m_cb_spaghetti->SetValue(obj_->xcam_spaghetti_detector);
m_cb_spaghetti_print_halt->SetValue(obj_->xcam_spaghetti_print_halt);
@ -88,7 +108,7 @@ wxBoxSizer* PrintOptionsDialog::create_settings_group(wxWindow* parent)
auto sizer = new wxBoxSizer(wxVERTICAL);
auto line_sizer = new wxBoxSizer(wxHORIZONTAL);
m_cb_spaghetti = new CheckBox(parent);
auto text_spaghetti = new wxStaticText(parent, wxID_ANY, _L("Spaghetti Detection"));
text_spaghetti = new wxStaticText(parent, wxID_ANY, _L("Spaghetti Detection"));
text_spaghetti->SetFont(Label::Body_14);
line_sizer->Add(FromDIP(5), 0, 0, 0);
line_sizer->Add(m_cb_spaghetti, 0, wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(5));
@ -112,7 +132,7 @@ wxBoxSizer* PrintOptionsDialog::create_settings_group(wxWindow* parent)
line_sizer = new wxBoxSizer(wxHORIZONTAL);
m_cb_first_layer = new CheckBox(parent);
auto text_first_layer = new wxStaticText(parent, wxID_ANY, _L("First Layer Inspection"));
text_first_layer = new wxStaticText(parent, wxID_ANY, _L("First Layer Inspection"));
text_first_layer->SetFont(Label::Body_14);
line_sizer->Add(FromDIP(5), 0, 0, 0);
line_sizer->Add(m_cb_first_layer, 0, wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(5));

View file

@ -24,6 +24,8 @@ protected:
CheckBox* m_cb_first_layer;
CheckBox* m_cb_spaghetti;
CheckBox* m_cb_spaghetti_print_halt;
wxStaticText* text_first_layer;
wxStaticText* text_spaghetti;
wxStaticText* text_spaghetti_print_halt;
wxBoxSizer* create_settings_group(wxWindow* parent);

View file

@ -290,6 +290,8 @@ void PrinterFileSystem::BuildGroups()
{
if (m_file_list.empty())
return;
m_group_year.clear();
m_group_month.clear();
wxDateTime t = wxDateTime((time_t) m_file_list.front().time);
m_group_year.push_back(0);
m_group_month.push_back(0);
@ -451,10 +453,11 @@ void PrinterFileSystem::UpdateFocusThumbnail()
wxString mimetype = resp.value("mimetype", "image/jpeg");
std::string thumbnail = resp["thumbnail"];
boost::uint32_t size = resp["size"];
wxMemoryInputStream mis(data, size);
wxImage image(mis, mimetype);
thumb.name = thumbnail;
thumb.thumbnail = image;
thumb.name = thumbnail;
if (size > 0) {
wxMemoryInputStream mis(data, size);
thumb.thumbnail = wxImage(mis, mimetype);
}
return 0;
},
[this](int result, Thumbnail const &thumb) {

View file

@ -114,7 +114,7 @@ SavePresetDialog::Item::Item(Preset::Type type, const std::string &suffix, wxBox
m_sizer_left->Add(0, 0, 0, wxLEFT, 10);
auto m_left_text = new wxStaticText(parent, wxID_ANY, L("User Preset"), wxDefaultPosition, wxDefaultSize, 0);
auto m_left_text = new wxStaticText(parent, wxID_ANY, _L("User Preset"), wxDefaultPosition, wxDefaultSize, 0);
m_left_text->Wrap(-1);
m_left_text->SetFont(::Label::Body_13);
m_left_text->SetForegroundColour(wxColour(107,107,107));
@ -133,7 +133,7 @@ SavePresetDialog::Item::Item(Preset::Type type, const std::string &suffix, wxBox
m_sizer_right->Add(0, 0, 0, wxLEFT, 10);
auto m_right_text = new wxStaticText(parent, wxID_ANY, L("Project Inside Preset"), wxDefaultPosition, wxDefaultSize, 0);
auto m_right_text = new wxStaticText(parent, wxID_ANY, _L("Project Inside Preset"), wxDefaultPosition, wxDefaultSize, 0);
m_right_text->SetForegroundColour(wxColour(107,107,107));
m_right_text->SetFont(::Label::Body_13);
m_right_text->Wrap(-1);

View file

@ -122,7 +122,7 @@ MachineObjectPanel::~MachineObjectPanel() {}
void MachineObjectPanel::show_bind_dialog()
{
if (wxGetApp().is_user_login()) {
BindMachineDilaog dlg;
BindMachineDialog dlg;
dlg.update_machine_info(m_info);
dlg.ShowModal();
}
@ -279,7 +279,9 @@ void MachineObjectPanel::on_mouse_left_up(wxMouseEvent &evt)
event.SetEventObject(this);
GetEventHandler()->ProcessEvent(event);
} else {
wxGetApp().mainframe->jump_to_monitor(m_info->dev_id);
if (m_info) {
wxGetApp().mainframe->jump_to_monitor(m_info->dev_id);
}
//wxGetApp().mainframe->SetFocus();
wxCommandEvent event(EVT_DISSMISS_MACHINE_LIST);
event.SetEventObject(this->GetParent());
@ -287,7 +289,7 @@ void MachineObjectPanel::on_mouse_left_up(wxMouseEvent &evt)
}
return;
}
if (m_info->is_lan_mode_printer()) {
if (m_info && m_info->is_lan_mode_printer()) {
if (m_info->has_access_right() && m_info->is_avaliable()) {
wxGetApp().mainframe->jump_to_monitor(m_info->dev_id);
} else {
@ -299,7 +301,7 @@ void MachineObjectPanel::on_mouse_left_up(wxMouseEvent &evt)
wxGetApp().mainframe->jump_to_monitor(m_info->dev_id);
}
} else {
if (m_info->is_lan_mode_printer()) {
if (m_info && m_info->is_lan_mode_printer()) {
wxCommandEvent event(EVT_CONNECT_LAN_PRINT);
event.SetEventObject(this);
wxPostEvent(this, event);
@ -339,6 +341,15 @@ SelectMachinePopup::SelectMachinePopup(wxWindow *parent)
m_scrolledWindow->Layout();
m_sizxer_scrolledWindow->Fit(m_scrolledWindow);
#if !BBL_RELEASE_TO_PUBLIC && defined(__WINDOWS__)
m_sizer_search_bar = new wxBoxSizer(wxVERTICAL);
m_search_bar = new wxSearchCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_search_bar->ShowSearchButton( true );
m_search_bar->ShowCancelButton( false );
m_sizer_search_bar->Add( m_search_bar, 1, wxALL| wxEXPAND, 1 );
m_sizer_main->Add(m_sizer_search_bar, 0, wxALL | wxEXPAND, FromDIP(2));
m_search_bar->Bind( wxEVT_COMMAND_TEXT_UPDATED, &SelectMachinePopup::update_machine_list, this );
#endif
auto own_title = create_title_panel(_L("My Device"));
m_sizer_my_devices = new wxBoxSizer(wxVERTICAL);
auto other_title = create_title_panel(_L("Other Device"));
@ -367,7 +378,7 @@ SelectMachinePopup::SelectMachinePopup(wxWindow *parent)
Bind(EVT_DISSMISS_MACHINE_LIST, &SelectMachinePopup::on_dissmiss_win, this);
}
SelectMachinePopup::~SelectMachinePopup() { delete m_refresh_timer; }
SelectMachinePopup::~SelectMachinePopup() { delete m_refresh_timer;}
void SelectMachinePopup::Popup(wxWindow *WXUNUSED(focus))
{
@ -427,7 +438,20 @@ bool SelectMachinePopup::ProcessLeftDown(wxMouseEvent &event) {
return wxPopupTransientWindow::ProcessLeftDown(event);
}
bool SelectMachinePopup::Show(bool show) { return wxPopupTransientWindow::Show(show); }
bool SelectMachinePopup::Show(bool show) {
if (show) {
for (int i = 0; i < m_user_list_machine_panel.size(); i++) {
m_user_list_machine_panel[i]->mPanel->update_machine_info(nullptr);
m_user_list_machine_panel[i]->mPanel->Hide();
}
for (int j = 0; 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();
}
}
return wxPopupTransientWindow::Show(show);
}
wxWindow *SelectMachinePopup::create_title_panel(wxString text)
{
@ -490,6 +514,11 @@ void SelectMachinePopup::update_other_devices()
if (i < m_other_list_machine_panel.size()) {
op = m_other_list_machine_panel[i]->mPanel;
op->Show();
#if !BBL_RELEASE_TO_PUBLIC && defined(__WINDOWS__)
if (!search_for_printer(mobj)) {
op->Hide();
}
#endif
} else {
op = new MachineObjectPanel(m_scrolledWindow, wxID_ANY);
MachinePanel* mpanel = new MachinePanel();
@ -520,17 +549,19 @@ void SelectMachinePopup::update_other_devices()
}
op->Bind(EVT_CONNECT_LAN_PRINT, [this, mobj](wxCommandEvent &e) {
if (mobj->is_lan_mode_printer()) {
ConnectPrinterDialog dlg(wxGetApp().mainframe, wxID_ANY, _L("Input access code"));
dlg.set_machine_object(mobj);
if (dlg.ShowModal() == wxID_OK) {
wxGetApp().mainframe->jump_to_monitor(mobj->dev_id);
if (mobj) {
if (mobj->is_lan_mode_printer()) {
ConnectPrinterDialog dlg(wxGetApp().mainframe, wxID_ANY, _L("Input access code"));
dlg.set_machine_object(mobj);
if (dlg.ShowModal() == wxID_OK) {
wxGetApp().mainframe->jump_to_monitor(mobj->dev_id);
}
}
}
});
op->Bind(EVT_BIND_MACHINE, [this, mobj](wxCommandEvent &e) {
BindMachineDilaog dlg;
BindMachineDialog dlg;
dlg.update_machine_info(mobj);
int dlg_result = wxID_CANCEL;
dlg_result = dlg.ShowModal();
@ -575,6 +606,11 @@ void SelectMachinePopup::update_user_devices()
if (i < m_user_list_machine_panel.size()) {
op = m_user_list_machine_panel[i]->mPanel;
op->Show();
#if !BBL_RELEASE_TO_PUBLIC && defined(__WINDOWS__)
if (!search_for_printer(mobj)) {
op->Hide();
}
#endif
} else {
op = new MachineObjectPanel(m_scrolledWindow, wxID_ANY);
MachinePanel* mpanel = new MachinePanel();
@ -604,7 +640,8 @@ void SelectMachinePopup::update_user_devices()
}
op->Bind(EVT_UNBIND_MACHINE, [this, dev, mobj](wxCommandEvent& e) {
dev->set_selected_machine("");
mobj->set_access_code("");
if (mobj)
mobj->set_access_code("");
MessageDialog msg_wingow(nullptr, _L("Log out successful."), "", wxAPPLY | wxOK);
if (msg_wingow.ShowModal() == wxOK) { return; }
});
@ -613,7 +650,7 @@ void SelectMachinePopup::update_user_devices()
op->show_printer_bind(true, PrinterBindState::ALLOW_UNBIND);
op->Bind(EVT_UNBIND_MACHINE, [this, mobj, dev](wxCommandEvent& e) {
// show_unbind_dialog
UnBindMachineDilaog dlg;
UnBindMachineDialog dlg;
dlg.update_machine_info(mobj);
if (dlg.ShowModal() == wxID_OK) {
dev->set_selected_machine("");
@ -639,11 +676,13 @@ void SelectMachinePopup::update_user_devices()
}
op->Bind(EVT_CONNECT_LAN_PRINT, [this, mobj](wxCommandEvent &e) {
if (mobj->is_lan_mode_printer()) {
ConnectPrinterDialog dlg(wxGetApp().mainframe, wxID_ANY, _L("Input access code"));
dlg.set_machine_object(mobj);
if (dlg.ShowModal() == wxID_OK) {
wxGetApp().mainframe->jump_to_monitor(mobj->dev_id);
if (mobj) {
if (mobj->is_lan_mode_printer()) {
ConnectPrinterDialog dlg(wxGetApp().mainframe, wxID_ANY, _L("Input access code"));
dlg.set_machine_object(mobj);
if (dlg.ShowModal() == wxID_OK) {
wxGetApp().mainframe->jump_to_monitor(mobj->dev_id);
}
}
}
});
@ -668,6 +707,23 @@ void SelectMachinePopup::update_user_devices()
this->Thaw();
}
bool SelectMachinePopup::search_for_printer(MachineObject* obj)
{
std::string search_text = std::string((m_search_bar->GetValue()).mb_str());
if (search_text.empty()) {
return true;
}
auto name = obj->dev_name;
auto ip = obj->dev_ip;
auto name_it = name.find(search_text);
auto ip_it = ip.find(search_text);
if ((name_it != std::string::npos)||(ip_it != std::string::npos)) {
return true;
}
return false;
}
void SelectMachinePopup::on_dissmiss_win(wxCommandEvent &event)
{
Dismiss();
@ -771,6 +827,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
: DPIDialog(static_cast<wxWindow *>(wxGetApp().mainframe), wxID_ANY, _L("Send print job to"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
, m_plater(plater), m_export_3mf_cancel(false)
, m_mapping_popup(AmsMapingPopup(this))
, m_mapping_tip_popup(AmsMapingTipPopup(this))
{
#ifdef __WINDOWS__
SetDoubleBuffered(true);
@ -797,7 +854,13 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL);
m_line_top->SetBackgroundColour(wxColour(166, 169, 170));
m_panel_image = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
m_scrollable_view = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
m_sizer_scrollable_view = new wxBoxSizer(wxVERTICAL);
m_scrollable_region = new wxPanel(m_scrollable_view, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
m_sizer_scrollable_region = new wxBoxSizer(wxVERTICAL);
m_panel_image = new wxPanel(m_scrollable_region, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
m_panel_image->SetBackgroundColour(m_colour_def_color);
sizer_thumbnail = new wxBoxSizer(wxVERTICAL);
@ -813,16 +876,16 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
wxBoxSizer *m_sizer_basic_weight = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *m_sizer_basic_time = new wxBoxSizer(wxHORIZONTAL);
auto timeimg = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("print-time", this, 18), wxDefaultPosition, wxSize(FromDIP(18), FromDIP(18)), 0);
auto timeimg = new wxStaticBitmap(m_scrollable_region, wxID_ANY, create_scaled_bitmap("print-time", this, 18), wxDefaultPosition, wxSize(FromDIP(18), FromDIP(18)), 0);
m_sizer_basic_weight->Add(timeimg, 1, wxEXPAND | wxALL, FromDIP(5));
m_stext_time = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
m_stext_time = new wxStaticText(m_scrollable_region, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
m_sizer_basic_weight->Add(m_stext_time, 0, wxALL, FromDIP(5));
m_sizer_basic->Add(m_sizer_basic_weight, 0, wxALIGN_CENTER, 0);
m_sizer_basic->Add(0, 0, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(30));
auto weightimg = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("print-weight", this, 18), wxDefaultPosition, wxSize(FromDIP(18), FromDIP(18)), 0);
auto weightimg = new wxStaticBitmap(m_scrollable_region, wxID_ANY, create_scaled_bitmap("print-weight", this, 18), wxDefaultPosition, wxSize(FromDIP(18), FromDIP(18)), 0);
m_sizer_basic_time->Add(weightimg, 1, wxEXPAND | wxALL, FromDIP(5));
m_stext_weight = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
m_stext_weight = new wxStaticText(m_scrollable_region, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
m_sizer_basic_time->Add(m_stext_weight, 0, wxALL, FromDIP(5));
m_sizer_basic->Add(m_sizer_basic_time, 0, wxALIGN_CENTER, 0);
@ -871,13 +934,15 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
m_sizer_select = new wxGridSizer(1, 2, 0, 0);
select_bed = create_item_checkbox(_L("Bed Leveling"), this, _L("Bed Leveling"), "bed_leveling");
select_flow = create_item_checkbox(_L("Flow Calibration"), this, _L("Flow Calibration"), "flow_cali");
select_bed->Show(true);
select_flow->Show(true);
select_use_ams = create_ams_checkbox(_L("Enable AMS"), this, _L("Enable AMS"));
m_sizer_select->Add(select_bed);
m_sizer_select->Add(select_flow);
m_sizer_select->Add(select_use_ams);
select_bed->Show(true);
select_flow->Show(true);
select_use_ams->Show(true);
// line schedule
m_line_schedule = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1));
@ -945,12 +1010,22 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
Bind(EVT_PRINT_JOB_CANCEL, &SelectMachineDialog::on_print_job_cancel, this);
Bind(EVT_SET_FINISH_MAPPING, &SelectMachineDialog::on_set_finish_mapping, this);
m_sizer_scrollable_region->Add(m_panel_image, 0, wxALIGN_CENTER_HORIZONTAL, 0);
m_sizer_scrollable_region->Add(0, 0, 0, wxTOP, FromDIP(10));
m_sizer_scrollable_region->Add(m_sizer_basic, 0, wxALIGN_CENTER_HORIZONTAL, 0);
m_sizer_scrollable_region->Add(m_sizer_material, 0, wxALIGN_CENTER_HORIZONTAL);
m_scrollable_region->SetSizer(m_sizer_scrollable_region);
m_scrollable_region->Layout();
m_scrollable_view->SetSizer(m_sizer_scrollable_view);
m_scrollable_view->Layout();
m_sizer_scrollable_view->Add(m_scrollable_region, 0, wxEXPAND, 0);
m_sizer_main->Add(m_line_top, 0, wxEXPAND, 0);
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(22));
m_sizer_main->Add(m_panel_image, 0, wxALIGN_CENTER_HORIZONTAL, 0);
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(10));
m_sizer_main->Add(m_sizer_basic, 0, wxALIGN_CENTER_HORIZONTAL, 0);
m_sizer_main->Add(m_sizer_material, 0, wxALIGN_CENTER_HORIZONTAL);
m_sizer_main->Add(m_scrollable_view, 0, wxALIGN_CENTER_HORIZONTAL, 0);
m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(8));
m_sizer_main->Add(m_statictext_ams_msg, 0, wxALIGN_CENTER_HORIZONTAL, 0);
m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(8));
@ -979,6 +1054,54 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
Centre(wxBOTH);
}
wxWindow *SelectMachineDialog::create_ams_checkbox(wxString title, wxWindow *parent, wxString tooltip)
{
auto checkbox = new wxWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
checkbox->SetBackgroundColour(m_colour_def_color);
wxBoxSizer *sizer_checkbox = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *sizer_check = new wxBoxSizer(wxVERTICAL);
ams_check = new ::CheckBox(checkbox);
sizer_check->Add(ams_check, 0, wxBOTTOM | wxEXPAND | wxTOP, FromDIP(5));
sizer_checkbox->Add(sizer_check, 0, wxEXPAND, FromDIP(5));
sizer_checkbox->Add(0, 0, 0, wxEXPAND | wxLEFT, FromDIP(11));
auto text = new wxStaticText(checkbox, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, 0);
text->SetFont(::Label::Body_13);
text->SetForegroundColour(wxColour(107, 107, 107));
text->Wrap(-1);
sizer_checkbox->Add(text, 0, wxALIGN_CENTER, FromDIP(5));
auto img_ams_tip = new wxStaticBitmap(checkbox, wxID_ANY, create_scaled_bitmap("enable_ams", this, 16), wxDefaultPosition, wxSize(FromDIP(16), FromDIP(16)), 0);
sizer_checkbox->Add(img_ams_tip, 0, wxALIGN_CENTER | wxLEFT, FromDIP(5));
img_ams_tip->Bind(wxEVT_ENTER_WINDOW, [this, img_ams_tip](auto &e) {
wxPoint pos = img_ams_tip->ClientToScreen(wxPoint(0, 0));
pos.y += img_ams_tip->GetRect().height;
m_mapping_tip_popup.Position(pos, wxSize(0, 0));
m_mapping_tip_popup.Popup();
});
img_ams_tip->Bind(wxEVT_LEAVE_WINDOW, [this, img_ams_tip](auto &e) {
m_mapping_tip_popup.Dismiss();
});
checkbox->SetSizer(sizer_checkbox);
checkbox->Layout();
sizer_checkbox->Fit(checkbox);
checkbox->SetToolTip(tooltip);
text->SetToolTip(tooltip);
text->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &) {
ams_check->SetValue(ams_check->GetValue() ? false : true);
});
return checkbox;
}
wxWindow *SelectMachineDialog::create_item_checkbox(wxString title, wxWindow *parent, wxString tooltip, std::string param)
{
auto checkbox = new wxWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
@ -1012,26 +1135,18 @@ wxWindow *SelectMachineDialog::create_item_checkbox(wxString title, wxWindow *pa
return checkbox;
}
void SelectMachineDialog::update_select_layout(PRINTER_TYPE type)
void SelectMachineDialog::update_select_layout(MachineObject *obj)
{
if (type == PRINTER_TYPE::PRINTER_3DPrinter_UKNOWN) {
select_bed->Show();
if (obj && obj->is_function_supported(PrinterFunction::FUNC_FLOW_CALIBRATION)) {
select_flow->Show();
} else if (type == PRINTER_TYPE::PRINTER_3DPrinter_X1) {
select_bed->Show();
select_flow->Show();
} else if (type == PRINTER_TYPE::PRINTER_3DPrinter_X1_Carbon) {
select_bed->Show();
select_flow->Show();
} else if (type == PRINTER_TYPE::PRINTER_3DPrinter_P1) {
select_bed->Show();
select_flow->Show(false);
} else if (type == PRINTER_TYPE::PRINTER_3DPrinter_NONE) {
select_bed->Hide();
select_flow->Hide();
} else {
select_flow->Hide();
}
if (obj && obj->is_function_supported(PrinterFunction::FUNC_AUTO_LEVELING)) {
select_bed->Show();
select_flow->Show();
} else {
select_bed->Hide();
}
Fit();
@ -1043,7 +1158,10 @@ void SelectMachineDialog::prepare_mode()
if (m_print_job) {
m_print_job->join();
}
wxEndBusyCursor();
if (wxIsBusy())
wxEndBusyCursor();
Enable_Send_Button(true);
m_status_bar->reset();
@ -1343,6 +1461,10 @@ void SelectMachineDialog::show_status(PrintDialogStatus status, std::vector<wxSt
update_print_status_msg(msg_text, true, true);
Enable_Send_Button(false);
Enable_Refresh_Button(true);
} else if (status == PrintDialogStatus::PrintStatusDisableAms) {
update_print_status_msg(wxEmptyString, false, false);
Enable_Send_Button(false);
Enable_Refresh_Button(true);
} else if (status == PrintDialogStatus::PrintStatusNeedUpgradingAms) {
wxString msg_text;
if (params.size() > 0)
@ -1552,6 +1674,12 @@ void SelectMachineDialog::on_ok(wxCommandEvent &event)
false,
true);
if (obj_->has_ams()) {
m_print_job->task_use_ams = ams_check->GetValue();
} else {
m_print_job->task_use_ams = false;
}
m_print_job->on_success([this]() { finish_mode(); });
wxCommandEvent evt(m_plater->get_print_finished_event());
@ -1722,7 +1850,7 @@ void SelectMachineDialog::update_user_printer()
}
else {
m_printer_last_select = "";
update_select_layout(PRINTER_TYPE::PRINTER_3DPrinter_NONE);
update_select_layout(nullptr);
m_comboBox_printer->SetTextLabel("");
}
@ -1767,7 +1895,7 @@ void SelectMachineDialog::on_selection_changed(wxCommandEvent &event)
if (obj) {
obj->command_get_version();
dev->set_selected_machine(m_printer_last_select);
update_select_layout(obj->printer_type);
update_select_layout(obj);
} else {
BOOST_LOG_TRIVIAL(error) << "on_selection_changed dev_id not found";
return;
@ -1778,6 +1906,15 @@ void SelectMachineDialog::on_selection_changed(wxCommandEvent &event)
update_show_status();
}
void SelectMachineDialog::update_ams_check(MachineObject* obj)
{
if (obj && obj->ams_support_use_ams) {
ams_check->Show();
} else {
ams_check->Hide();
}
}
void SelectMachineDialog::update_show_status()
{
// refreshing return
@ -1831,6 +1968,7 @@ void SelectMachineDialog::update_show_status()
}
reset_timeout();
update_ams_check(obj_);
// reading done
if (obj_->is_in_upgrading()) {
@ -1860,6 +1998,14 @@ void SelectMachineDialog::update_show_status()
return;
}
if (obj_->ams_support_use_ams) {
if (!ams_check->GetValue()) {
m_ams_mapping_result.clear();
show_status(PrintDialogStatus::PrintStatusDisableAms);
return;
}
}
// do ams mapping if no ams result
if (m_ams_mapping_result.empty()) {
do_ams_mapping(obj_);
@ -2005,6 +2151,7 @@ void SelectMachineDialog::set_default()
// checkbox default values
m_checkbox_list["bed_leveling"]->SetValue(true);
m_checkbox_list["flow_cali"]->SetValue(true);
ams_check->SetValue(true);
// thumbmail
//wxBitmap bitmap;
@ -2071,7 +2218,7 @@ void SelectMachineDialog::set_default()
auto colour_rgb = wxColour((int) rgb[0], (int) rgb[1], (int) rgb[2]);
if (extruder >= materials.size() || extruder < 0 || extruder >= display_materials.size())
continue;
MaterialItem *item = new MaterialItem(this, colour_rgb, _L(display_materials[extruder]));
MaterialItem *item = new MaterialItem(m_scrollable_region, colour_rgb, _L(display_materials[extruder]));
m_sizer_material->Add(item, 0, wxALL, FromDIP(4));
item->Bind(wxEVT_LEFT_UP, [this, item, materials, extruder](wxMouseEvent &e) {
@ -2131,14 +2278,43 @@ void SelectMachineDialog::set_default()
if (extruders.size() <= 4) {
m_sizer_material->SetCols(extruders.size());
Layout();
Fit();
} else {
m_sizer_material->SetCols(4);
Layout();
Fit();
}
m_scrollable_region->Layout();
m_scrollable_region->Fit();
//m_scrollable_view->Layout();
//m_scrollable_view->Fit();
m_scrollable_view->SetSize(m_scrollable_region->GetSize());
m_scrollable_view->SetMinSize(m_scrollable_region->GetSize());
m_scrollable_view->SetMaxSize(m_scrollable_region->GetSize());
Layout();
Fit();
wxSize screenSize = wxGetDisplaySize();
auto dialogSize = this->GetSize();
#ifdef __WINDOWS__
if (screenSize.y < dialogSize.y) {
m_need_adaptation_screen = true;
m_scrollable_view->SetScrollRate(0, 5);
m_scrollable_view->SetSize(wxSize(-1, FromDIP(220)));
m_scrollable_view->SetMinSize(wxSize(-1, FromDIP(220)));
m_scrollable_view->SetMaxSize(wxSize(-1, FromDIP(220)));
} else {
/* m_scrollable_view->SetSize(m_scrollable_region->GetSize());
m_scrollable_view->SetMinSize(m_scrollable_region->GetSize());
m_scrollable_view->SetMaxSize(m_scrollable_region->GetSize());*/
m_scrollable_view->SetScrollRate(0, 0);
}
#endif // __WXOSX_MAC__
reset_ams_material();
// basic info
@ -2173,10 +2349,9 @@ bool SelectMachineDialog::Show(bool show)
m_refresh_timer->Stop();
}
if (show) { CenterOnParent(); }
Layout();
Fit();
if (show) { CenterOnParent(); }
return DPIDialog::Show(show);
}
@ -2233,7 +2408,8 @@ EditDevNameDialog::~EditDevNameDialog() {}
void EditDevNameDialog::set_machine_obj(MachineObject *obj)
{
m_info = obj;
m_textCtr->GetTextCtrl()->SetValue(from_u8(m_info->dev_name));
if (m_info)
m_textCtr->GetTextCtrl()->SetValue(from_u8(m_info->dev_name));
}
void EditDevNameDialog::on_dpi_changed(const wxRect &suggested_rect)
@ -2291,7 +2467,8 @@ void EditDevNameDialog::on_edit_name(wxCommandEvent &e)
if (dev) {
auto utf8_str = new_dev_name.ToUTF8();
auto name = std::string(utf8_str.data(), utf8_str.length());
dev->modify_device_name(m_info->dev_id, name);
if (m_info)
dev->modify_device_name(m_info->dev_id, name);
}
DPIDialog::EndModal(wxID_CLOSE);
}

View file

@ -22,6 +22,7 @@
#include <wx/spinctrl.h>
#include <wx/artprov.h>
#include <wx/wrapsizer.h>
#include <wx/srchctrl.h>
#include "AmsMappingPopup.hpp"
#include "GUI_Utils.hpp"
@ -197,6 +198,8 @@ private:
wxBoxSizer * m_sizer_body{nullptr};
wxBoxSizer * m_sizer_my_devices{nullptr};
wxBoxSizer * m_sizer_other_devices{nullptr};
wxBoxSizer * m_sizer_search_bar{nullptr};
wxSearchCtrl* m_search_bar{nullptr};
wxScrolledWindow * m_scrolledWindow{nullptr};
wxWindow * m_panel_body{nullptr};
wxTimer * m_refresh_timer{nullptr};
@ -215,6 +218,7 @@ private:
void update_other_devices();
void update_user_devices();
bool search_for_printer(MachineObject* obj);
void on_dissmiss_win(wxCommandEvent &event);
wxWindow *create_title_panel(wxString text);
};
@ -235,6 +239,7 @@ enum PrintDialogStatus {
PrintStatusNeedUpgradingAms,
PrintStatusInSystemPrinting,
PrintStatusInPrinting,
PrintStatusDisableAms,
PrintStatusAmsMappingSuccess,
PrintStatusAmsMappingInvalid,
PrintStatusAmsMappingU0Invalid,
@ -306,8 +311,17 @@ protected:
wxBoxSizer * m_sizer_main;
wxBoxSizer * m_sizer_bottom;
bool m_need_adaptation_screen {false};
wxScrolledWindow * m_scrollable_view;
wxBoxSizer * m_sizer_scrollable_view;
wxPanel* m_scrollable_region;
wxBoxSizer* m_sizer_scrollable_region;
wxWindow *select_bed{nullptr};
wxWindow *select_flow{nullptr};
wxWindow *select_use_ams{nullptr};
CheckBox *ams_check{nullptr};
void stripWhiteSpace(std::string& str);
@ -318,10 +332,11 @@ protected:
public:
SelectMachineDialog(Plater *plater = nullptr);
wxWindow *create_ams_checkbox(wxString title, wxWindow *parent, wxString tooltip);
~SelectMachineDialog();
wxWindow *create_item_checkbox(wxString title, wxWindow *parent, wxString tooltip, std::string param);
void update_select_layout(PRINTER_TYPE type);
void update_select_layout(MachineObject *obj);
void prepare_mode();
void sending_mode();
void finish_mode();
@ -350,6 +365,7 @@ protected:
wxPanel * m_panel_status{nullptr};
wxButton * m_button_cancel{nullptr};
AmsMapingPopup m_mapping_popup{nullptr};
AmsMapingTipPopup m_mapping_tip_popup{nullptr};
std::string m_print_info;
int timeout_count = 0;
@ -358,6 +374,7 @@ protected:
void update_user_printer();
void reset_ams_material();
void update_show_status();
void update_ams_check(MachineObject* obj);
wxTimer *m_refresh_timer { nullptr };

View file

@ -2624,9 +2624,11 @@ void Selection::paste_objects_from_clipboard()
PartPlate* plate = wxGetApp().plater()->get_partplate_list().get_curr_plate();
bool in_current = plate->intersects(bbox);
auto start_point = in_current?src_object->instances.front()->get_offset():plate->get_build_volume().center();
auto start_offset = in_current?src_object->instances.front()->get_offset():plate->get_build_volume().center();
auto start_point = in_current?bbox.center():plate->get_build_volume().center();
auto point_offset = start_offset - start_point;
auto empty_cell = wxGetApp().plater()->canvas3D()->get_nearest_empty_cell({start_point(0), start_point(1)});
Vec3d displacement = { empty_cell.x(),empty_cell.y(),start_point(2) };
Vec3d displacement = { empty_cell.x() + point_offset.x(), empty_cell.y() + point_offset.y(), start_point(2) };
for (ModelInstance* inst : dst_object->instances)
inst->set_offset(displacement);

View file

@ -60,7 +60,7 @@ static wxColour TEXT_LIGHT_FONT_COL = wxColour(107, 107, 107);
#define NORMAL_SPACING FromDIP(5)
#define PAGE_SPACING FromDIP(10)
#define PAGE_MIN_WIDTH FromDIP(574)
#define PROGRESSBAR_HEIGHT FromDIP(14)
#define PROGRESSBAR_HEIGHT FromDIP(8)
#define SWITCH_BUTTON_SIZE (wxSize(FromDIP(40), -1))
#define TASK_THUMBNAIL_SIZE (wxSize(FromDIP(120), FromDIP(120)))
@ -170,12 +170,14 @@ void StatusBasePanel::init_bitmaps()
m_bitmap_fan_off = ScalableBitmap(this, "monitor_fan_off", 24);
m_bitmap_speed = ScalableBitmap(this, "monitor_speed", 24);
m_bitmap_speed_active = ScalableBitmap(this, "monitor_speed_active", 24);
m_bitmap_use_time = ScalableBitmap(this, "print_info_time", 16);
m_bitmap_use_weight = ScalableBitmap(this, "print_info_weight", 16);
m_thumbnail_placeholder = ScalableBitmap(this, "monitor_placeholder", 120);
m_thumbnail_sdcard = ScalableBitmap(this, "monitor_sdcard_thumbnail", 120);
//m_bitmap_camera = create_scaled_bitmap("monitor_camera", nullptr, 18);
m_bitmap_extruder = *cache.load_png("monitor_extruder", FromDIP(28), FromDIP(70), false, false);
m_bitmap_sdcard_state_on = create_scaled_bitmap("sdcard_state_on", nullptr, 16);
m_bitmap_sdcard_state_off = create_scaled_bitmap("sdcard_state_off", nullptr, 16);
m_bitmap_sdcard_state_on = create_scaled_bitmap("sdcard_state_on", nullptr, 20);
m_bitmap_sdcard_state_off = create_scaled_bitmap("sdcard_state_off", nullptr, 20);
}
wxBoxSizer *StatusBasePanel::create_monitoring_page()
@ -212,18 +214,18 @@ wxBoxSizer *StatusBasePanel::create_monitoring_page()
//m_bitmap_camera_img->SetMinSize(wxSize(FromDIP(32), FromDIP(18)));
//bSizer_monitoring_title->Add(m_bitmap_camera_img, 0, wxALIGN_CENTER_VERTICAL | wxALL, FromDIP(5));
m_bitmap_sdcard_off_img = new wxStaticBitmap(m_panel_monitoring_title, wxID_ANY, m_bitmap_sdcard_state_off, wxDefaultPosition, wxSize(FromDIP(32), FromDIP(16)), 0);
m_bitmap_sdcard_off_img->SetMinSize(wxSize(FromDIP(32), FromDIP(16)));
m_bitmap_sdcard_on_img = new wxStaticBitmap(m_panel_monitoring_title, wxID_ANY, m_bitmap_sdcard_state_on, wxDefaultPosition, wxSize(FromDIP(32), FromDIP(16)), 0);
m_bitmap_sdcard_on_img->SetMinSize(wxSize(FromDIP(32), FromDIP(16)));
m_bitmap_sdcard_off_img = new wxStaticBitmap(m_panel_monitoring_title, wxID_ANY, m_bitmap_sdcard_state_off, wxDefaultPosition, wxSize(FromDIP(38), FromDIP(24)), 0);
m_bitmap_sdcard_off_img->SetMinSize(wxSize(FromDIP(38), FromDIP(24)));
m_bitmap_sdcard_on_img = new wxStaticBitmap(m_panel_monitoring_title, wxID_ANY, m_bitmap_sdcard_state_on, wxDefaultPosition, wxSize(FromDIP(38), FromDIP(24)), 0);
m_bitmap_sdcard_on_img->SetMinSize(wxSize(FromDIP(38), FromDIP(24)));
m_bitmap_sdcard_on_img->Hide();
m_timelapse_button = new CameraItem(m_panel_monitoring_title, "timelapse_off_normal", "timelapse_on_normal", "timelapse_off_hover", "timelapse_on_hover");
m_timelapse_button->SetMinSize(wxSize(32, 24));
m_timelapse_button->SetMinSize(wxSize(FromDIP(38), FromDIP(24)));
m_timelapse_button->SetBackgroundColour(STATUS_TITLE_BG);
m_recording_button = new CameraItem(m_panel_monitoring_title, "recording_off_normal", "recording_on_normal", "recording_off_hover", "recording_on_hover");
m_recording_button->SetMinSize(wxSize(32, 24));
m_recording_button->SetMinSize(wxSize(FromDIP(38), FromDIP(24)));
m_recording_button->SetBackgroundColour(STATUS_TITLE_BG);
m_timelapse_button->SetToolTip(_L("Timelapse"));
@ -272,6 +274,8 @@ wxBoxSizer *StatusBasePanel::create_project_task_page(wxWindow *parent)
m_staticText_printing->SetForegroundColour(PAGE_TITLE_FONT_COL);
bSizer_printing_title->Add(m_staticText_printing, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, PAGE_TITLE_LEFT_MARGIN);
bSizer_printing_title->Add(0, 0, 1, wxEXPAND, 0);
m_panel_printing_title->SetSizer(bSizer_printing_title);
m_panel_printing_title->Layout();
bSizer_printing_title->Fit(m_panel_printing_title);
@ -292,93 +296,135 @@ wxBoxSizer *StatusBasePanel::create_project_task_page(wxWindow *parent)
wxBoxSizer *bSizer_task_name = new wxBoxSizer(wxVERTICAL);
bSizer_task_name->Add(0, 0, 1, wxEXPAND, FromDIP(5));
wxBoxSizer *bSizer_task_name_hor = new wxBoxSizer(wxHORIZONTAL);
wxPanel* task_name_panel = new wxPanel(parent);
m_staticText_subtask_value = new wxStaticText(parent, wxID_ANY, _L("N/A"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT | wxST_ELLIPSIZE_END);
m_staticText_subtask_value = new wxStaticText(task_name_panel, wxID_ANY, _L("N/A"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT | wxST_ELLIPSIZE_END);
m_staticText_subtask_value->Wrap(-1);
m_staticText_subtask_value->SetFont(wxFont(13, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxT("HarmonyOS Sans SC")));
#ifdef __WXOSX_MAC__
m_staticText_subtask_value->SetFont(::Label::Body_13);
#else
m_staticText_subtask_value->SetFont(wxFont(13, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxT("HarmonyOS Sans SC")));
#endif
m_staticText_subtask_value->SetForegroundColour(wxColour(44, 44, 46));
m_printing_stage_value = new wxStaticText(parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT | wxST_ELLIPSIZE_END);
m_printing_stage_value->Wrap(-1);
m_printing_stage_value->SetFont(wxFont(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxT("HarmonyOS Sans SC")));
m_printing_stage_value->SetForegroundColour(STAGE_TEXT_COL);
m_bitmap_static_use_time = new wxStaticBitmap(task_name_panel, wxID_ANY, m_bitmap_use_time.bmp(), wxDefaultPosition, wxSize(FromDIP(16), FromDIP(16)));
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, wxEXPAND, FromDIP(5));
m_staticText_consumption_of_time = new wxStaticText(task_name_panel, wxID_ANY, "0m", wxDefaultPosition, wxDefaultSize, 0);
m_staticText_consumption_of_time->SetFont(::Label::Body_12);
m_staticText_consumption_of_time->SetForegroundColour(wxColour(0x68, 0x68, 0x68));
m_staticText_consumption_of_time->Wrap(-1);
m_bitmap_static_use_weight = new wxStaticBitmap(task_name_panel, wxID_ANY, m_bitmap_use_weight.bmp(), wxDefaultPosition, wxSize(FromDIP(16), FromDIP(16)));
m_staticText_consumption_of_weight = new wxStaticText(task_name_panel, wxID_ANY, "0g", wxDefaultPosition, wxDefaultSize, 0);
m_staticText_consumption_of_weight->SetFont(::Label::Body_12);
m_staticText_consumption_of_weight->SetForegroundColour(wxColour(0x68, 0x68, 0x68));
m_staticText_consumption_of_weight->Wrap(-1);
bSizer_task_name_hor->Add(m_staticText_subtask_value, 1, wxALL | wxEXPAND, 0);
bSizer_task_name_hor->Add(0, 0, 1, wxEXPAND, 0);
bSizer_task_name_hor->Add(m_bitmap_static_use_time, 0, wxALIGN_CENTER_VERTICAL, 0);
bSizer_task_name_hor->Add(m_staticText_consumption_of_time, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, FromDIP(3));
bSizer_task_name_hor->Add(0, 0, 0, wxLEFT, FromDIP(20));
bSizer_task_name_hor->Add(m_bitmap_static_use_weight, 0, wxALIGN_CENTER_VERTICAL, 0);
bSizer_task_name_hor->Add(m_staticText_consumption_of_weight, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(3));
bSizer_task_name_hor->Add(0, 0, 0, wxRIGHT, FromDIP(10));
task_name_panel->SetSizer(bSizer_task_name_hor);
task_name_panel->Layout();
task_name_panel->Fit();
bSizer_task_name->Add(task_name_panel, 0, wxEXPAND, FromDIP(5));
/* wxFlexGridSizer *fgSizer_task = new wxFlexGridSizer(2, 2, 0, 0);
fgSizer_task->AddGrowableCol(0);
fgSizer_task->SetFlexibleDirection(wxVERTICAL);
fgSizer_task->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);*/
m_printing_stage_value = new wxStaticText(parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT | wxST_ELLIPSIZE_END);
m_printing_stage_value->Wrap(-1);
#ifdef __WXOSX_MAC__
m_printing_stage_value->SetFont(::Label::Body_11);
#else
m_printing_stage_value->SetFont(wxFont(11, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxT("HarmonyOS Sans SC")));
#endif
m_printing_stage_value->SetForegroundColour(STAGE_TEXT_COL);
auto m_panel_progress = new wxPanel(parent, wxID_ANY);
m_panel_progress->SetBackgroundColour(*wxWHITE);
auto m_sizer_progressbar = new wxBoxSizer(wxHORIZONTAL);
m_gauge_progress = new ProgressBar(m_panel_progress, wxID_ANY, 100, wxDefaultPosition, wxDefaultSize);
m_gauge_progress->SetValue(0);
m_gauge_progress->SetHeight(PROGRESSBAR_HEIGHT);
//m_gauge_progress->SetMinSize(wxSize(FromDIP(238), 16));
m_gauge_progress->SetMaxSize(wxSize(FromDIP(600), 16));
//fgSizer_task->Add(m_gauge_progress, 0, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 0);
m_gauge_progress->SetMaxSize(wxSize(FromDIP(600), -1));
m_panel_progress->SetSizer(m_sizer_progressbar);
m_panel_progress->Layout();
//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, 0);
//fgSizer_task->Add(m_panel_progress, 0, wxALIGN_CENTER_VERTICAL | wxEXPAND, 0);
m_panel_progress->SetSize(wxSize(-1, FromDIP(24)));
m_panel_progress->SetMaxSize(wxSize(-1, FromDIP(24)));
wxBoxSizer *bSizer_task_btn = new wxBoxSizer(wxHORIZONTAL);
bSizer_task_btn->Add(FromDIP(10), 0, 0);
m_button_report = new Button(m_panel_progress, _L("Report"));
StateColor report_bg(std::pair<wxColour, int>(wxColour(255, 255, 255), StateColor::Disabled), std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed),
std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Hovered), std::pair<wxColour, int>(wxColour(255, 255, 255), StateColor::Enabled),
std::pair<wxColour, int>(wxColour(255, 255, 255), StateColor::Normal));
m_button_report->SetBackgroundColor(report_bg);
m_button_report->SetMinSize(TASK_BUTTON_SIZE2);
StateColor report_bd(std::pair<wxColour, int>(wxColour(144, 144, 144), StateColor::Disabled), std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Enabled));
m_button_report->SetBorderColor(report_bd);
StateColor report_text(std::pair<wxColour, int>(wxColour(144, 144, 144), StateColor::Disabled), std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Enabled));
m_button_report->SetTextColor(report_text);
m_button_report->SetFont(Label::Body_10);
m_button_report->Hide();
m_sizer_progressbar->Add(m_button_report, 0, wxALL, FromDIP(5));
/* m_button_report = new Button(m_panel_progress, _L("Report"));
StateColor report_bg(std::pair<wxColour, int>(wxColour(255, 255, 255), StateColor::Disabled), std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed),
std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Hovered), std::pair<wxColour, int>(wxColour(255, 255, 255), StateColor::Enabled),
std::pair<wxColour, int>(wxColour(255, 255, 255), StateColor::Normal));
m_button_report->SetBackgroundColor(report_bg);
m_button_report->SetMinSize(TASK_BUTTON_SIZE2);
StateColor report_bd(std::pair<wxColour, int>(wxColour(144, 144, 144), StateColor::Disabled), std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Enabled));
m_button_report->SetBorderColor(report_bd);
StateColor report_text(std::pair<wxColour, int>(wxColour(144, 144, 144), StateColor::Disabled), std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Enabled));
m_button_report->SetTextColor(report_text);
m_button_report->SetFont(Label::Body_10);
m_button_report->Hide();
m_sizer_progressbar->Add(m_button_report, 0, wxALL, FromDIP(5));*/
m_button_pause_resume = new Button(m_panel_progress, _L("Pause"));
m_button_pause_resume = new ScalableButton(m_panel_progress, wxID_ANY, "print_control_pause", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER,true);
StateColor pause_resume_bg(std::pair<wxColour, int>(wxColour(255, 255, 255), 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>(wxColour(0, 174, 66), StateColor::Enabled),
std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Normal));
m_button_pause_resume->SetBackgroundColor(pause_resume_bg);
StateColor pause_resume_bd(std::pair<wxColour, int>(wxColour(144, 144, 144), StateColor::Disabled), std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Enabled));
m_button_pause_resume->SetBorderColor(pause_resume_bd);
StateColor pause_resume_text(std::pair<wxColour, int>(wxColour(144, 144, 144), StateColor::Disabled), std::pair<wxColour, int>(wxColour(255, 255, 255), StateColor::Enabled));
m_button_pause_resume->SetTextColor(pause_resume_text);
m_button_pause_resume->SetFont(Label::Body_10);
m_button_pause_resume->SetMinSize(TASK_BUTTON_SIZE2);
//bSizer_task_btn->Add(m_button_pause_resume, 0, wxALIGN_RIGHT | wxALL, FromDIP(5));
m_button_pause_resume->Bind(wxEVT_ENTER_WINDOW, [this](auto &e) {
if (m_button_pause_resume->GetToolTipText() == _L("Pause")) {
m_button_pause_resume->SetBitmap_("print_control_pause_hover");
}
if (m_button_pause_resume->GetToolTipText() == _L("Resume")) {
m_button_pause_resume->SetBitmap_("print_control_resume_hover");
}
});
m_button_pause_resume->Bind(wxEVT_LEAVE_WINDOW, [this](auto &e) {
auto buf = m_button_pause_resume->GetClientData();
if (m_button_pause_resume->GetToolTipText() == _L("Pause")) {
m_button_pause_resume->SetBitmap_("print_control_pause");
}
if (m_button_pause_resume->GetToolTipText() == _L("Resume")) {
m_button_pause_resume->SetBitmap_("print_control_resume");
}
});
m_button_abort = new ScalableButton(m_panel_progress, wxID_ANY, "print_control_stop", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true);
m_button_abort->SetToolTip(_L("Stop"));
m_button_abort->Bind(wxEVT_ENTER_WINDOW, [this](auto &e) {
m_button_abort->SetBitmap_("print_control_stop_hover");
});
m_button_abort->Bind(wxEVT_LEAVE_WINDOW, [this](auto &e) {
m_button_abort->SetBitmap_("print_control_stop"); }
);
m_sizer_progressbar->Add(m_gauge_progress, 1, wxALIGN_CENTER_VERTICAL, 0);
m_sizer_progressbar->Add(0, 0, 0, wxEXPAND|wxLEFT, FromDIP(18));
m_sizer_progressbar->Add(m_button_pause_resume, 0, wxALL, FromDIP(5));
m_button_abort = new Button(m_panel_progress, _L("Stop"));
StateColor abort_bg(std::pair<wxColour, int>(wxColour(255, 255, 255), StateColor::Disabled), std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed),
std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Hovered), std::pair<wxColour, int>(wxColour(255, 255, 255), StateColor::Enabled),
std::pair<wxColour, int>(wxColour(255, 255, 255), StateColor::Normal));
m_button_abort->SetBackgroundColor(abort_bg);
StateColor abort_bd(std::pair<wxColour, int>(wxColour(144, 144, 144), StateColor::Disabled), std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Enabled));
m_button_abort->SetBorderColor(abort_bd);
StateColor abort_text(std::pair<wxColour, int>(wxColour(144, 144, 144), StateColor::Disabled), std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Enabled));
m_button_abort->SetTextColor(abort_text);
m_button_abort->SetFont(Label::Body_10);
m_button_abort->SetMinSize(TASK_BUTTON_SIZE2);
//bSizer_task_btn->Add(m_button_abort, 0, wxALIGN_RIGHT | wxALL, FromDIP(5));
m_sizer_progressbar->Add(0, 0, 0, wxEXPAND|wxLEFT, FromDIP(18));
m_sizer_progressbar->Add(m_button_abort, 0, wxALL, FromDIP(5));
//fgSizer_task->Add(bSizer_task_btn, 0, wxEXPAND, 0);
@ -391,14 +437,35 @@ wxBoxSizer *StatusBasePanel::create_project_task_page(wxWindow *parent)
penel_text->SetBackgroundColour(*wxWHITE);
penel_bottons->SetBackgroundColour(*wxWHITE);
m_staticText_progress_percent = new wxStaticText(penel_text, wxID_ANY, _L("0%"), wxDefaultPosition, wxDefaultSize, 0);
m_staticText_progress_percent->Wrap(-1);
m_staticText_progress_percent->SetFont(::Label::Head_13);
wxBoxSizer *sizer_percent = new wxBoxSizer(wxVERTICAL);
sizer_percent->Add(0, 0, 1, wxEXPAND, 0);
wxBoxSizer *sizer_percent_icon = new wxBoxSizer(wxVERTICAL);
sizer_percent_icon->Add(0, 0, 1, wxEXPAND, 0);
m_staticText_progress_percent = new wxStaticText(penel_text, wxID_ANY, L("0"), wxDefaultPosition, wxDefaultSize, 0);
m_staticText_progress_percent->SetFont(::Label::Head_18);
m_staticText_progress_percent->SetMaxSize(wxSize(-1, FromDIP(20)));
m_staticText_progress_percent->SetForegroundColour(wxColour(0, 174, 66));
m_staticText_progress_percent_icon = new wxStaticText(penel_text, wxID_ANY, L("%"), wxDefaultPosition, wxDefaultSize, 0);
m_staticText_progress_percent_icon->SetFont(::Label::Body_11);
m_staticText_progress_percent_icon->SetMaxSize(wxSize(-1, FromDIP(13)));
m_staticText_progress_percent_icon->SetForegroundColour(wxColour(0, 174, 66));
sizer_percent->Add(m_staticText_progress_percent, 0, 0, 0);
#ifdef __WXOSX_MAC__
sizer_percent_icon->Add(m_staticText_progress_percent_icon, 0, wxBOTTOM, FromDIP(2));
#else
sizer_percent_icon->Add(m_staticText_progress_percent_icon, 0, 0, 0);
#endif
m_staticText_progress_left = new wxStaticText(penel_text, wxID_ANY, _L("N/A"), wxDefaultPosition, wxDefaultSize, 0);
m_staticText_progress_left = new wxStaticText(penel_text, wxID_ANY, L("N/A"), wxDefaultPosition, wxDefaultSize, 0);
m_staticText_progress_left->Wrap(-1);
m_staticText_progress_left->SetFont(wxFont(10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxT("HarmonyOS Sans SC")));
m_staticText_progress_left->SetFont(wxFont(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxT("HarmonyOS Sans SC")));
m_staticText_progress_left->SetForegroundColour(wxColour(146, 146, 146));
//fgSizer_task->Add(bSizer_buttons, 0, wxEXPAND, 0);
@ -410,7 +477,9 @@ wxBoxSizer *StatusBasePanel::create_project_task_page(wxWindow *parent)
panel_button_block->SetSize(wxSize(TASK_BUTTON_SIZE.x * 2 + FromDIP(5) * 2, -1));
panel_button_block->SetBackgroundColour(*wxWHITE);
bSizer_text->Add(m_staticText_progress_percent, 0, wxALIGN_CENTER | wxALL, 0);
//bSizer_text->Add(m_staticText_progress_percent, 0, wxALL, 0);
bSizer_text->Add(sizer_percent, 0, wxEXPAND, 0);
bSizer_text->Add(sizer_percent_icon, 0, wxEXPAND, 0);
bSizer_text->Add(0, 0, 1, wxEXPAND, 0);
bSizer_text->Add(m_staticText_progress_left, 0, wxALIGN_CENTER | wxALL, 0);
@ -424,8 +493,11 @@ wxBoxSizer *StatusBasePanel::create_project_task_page(wxWindow *parent)
penel_bottons->SetSizer(bSizer_buttons);
penel_bottons->Layout();
bSizer_subtask_info->Add(m_panel_progress, 0, wxEXPAND, FromDIP(5));
bSizer_subtask_info->Add(penel_bottons, 0, wxEXPAND, FromDIP(5));
bSizer_subtask_info->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(14));
bSizer_subtask_info->Add(bSizer_task_name, 0, wxEXPAND|wxRIGHT, FromDIP(18));
bSizer_subtask_info->Add(m_printing_stage_value, 0, wxEXPAND | wxTOP, FromDIP(5));
bSizer_subtask_info->Add(penel_bottons, 0, wxEXPAND | wxTOP, FromDIP(10));
bSizer_subtask_info->Add(m_panel_progress, 0, wxEXPAND|wxRIGHT, FromDIP(25));
m_printing_sizer->Add(bSizer_subtask_info, 1, wxALL | wxEXPAND, 0);
@ -445,19 +517,27 @@ wxBoxSizer *StatusBasePanel::create_project_task_page(wxWindow *parent)
wxBoxSizer *static_text_sizer = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *text_sizer = new wxBoxSizer(wxHORIZONTAL);
m_error_text = new wxStaticText2(m_panel_error_txt);
m_error_text->SetForegroundColour(PAGE_TITLE_FONT_COL);
m_error_text = new ErrorMsgStaticText(m_panel_error_txt);
m_error_text->SetForegroundColour(wxColour(255, 0, 0));
text_sizer->Add(m_error_text, 1, wxEXPAND|wxLEFT, FromDIP(17));
m_button_clean = new Button(m_panel_error_txt, _L("Clean"));
m_button_clean->SetBackgroundColor(abort_bg);
m_button_clean->SetBorderColor(abort_bd);
m_button_clean->SetTextColor(abort_text);
StateColor clean_bg(std::pair<wxColour, int>(wxColour(255, 255, 255), StateColor::Disabled), std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed),
std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Hovered), std::pair<wxColour, int>(wxColour(255, 255, 255), StateColor::Enabled),
std::pair<wxColour, int>(wxColour(255, 255, 255), StateColor::Normal));
StateColor clean_bd(std::pair<wxColour, int>(wxColour(144, 144, 144), StateColor::Disabled), std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Enabled));
StateColor clean_text(std::pair<wxColour, int>(wxColour(144, 144, 144), StateColor::Disabled), std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Enabled));
m_button_clean->SetBackgroundColor(clean_bg);
m_button_clean->SetBorderColor(clean_bd);
m_button_clean->SetTextColor(clean_text);
m_button_clean->SetFont(Label::Body_10);
m_button_clean->SetMinSize(TASK_BUTTON_SIZE2);
static_text_sizer->Add(text_sizer, 1, wxEXPAND|wxTOP, FromDIP(7));
static_text_sizer->Add(text_sizer, 1, wxEXPAND, 0);
static_text_sizer->Add( FromDIP(10), 0, 0, 0, 0 );
static_text_sizer->Add(m_button_clean, 0, wxALIGN_CENTRE_VERTICAL|wxRIGHT,FromDIP(5));
static_text_sizer->Add(m_button_clean, 0, wxALIGN_CENTRE_VERTICAL|wxRIGHT, FromDIP(5));
m_panel_error_txt->SetSizer(static_text_sizer);
m_panel_error_txt->Hide();
@ -882,7 +962,7 @@ wxBoxSizer *StatusBasePanel::create_ams_group(wxWindow *parent)
auto sizer = new wxBoxSizer(wxVERTICAL);
auto sizer_box = new wxBoxSizer(wxVERTICAL);
m_ams_control_box = new RoundedRectangle(parent, wxColour(0xEE, 0xEE, 0xEE), wxDefaultPosition, wxDefaultSize, 5, 1);
m_ams_control_box->SetMinSize(wxSize(FromDIP(530), FromDIP(310)));
m_ams_control_box->SetMinSize(wxSize(FromDIP(530), -1));
m_ams_control_box->SetBackgroundColour(*wxWHITE);
#if !BBL_RELEASE_TO_PUBLIC
m_ams_debug = new wxStaticText(m_ams_control_box, wxID_ANY, _L("Debug Info"), wxDefaultPosition, wxDefaultSize, 0);
@ -955,9 +1035,9 @@ StatusPanel::StatusPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, co
init_scaled_buttons();
m_buttons.push_back(m_button_report);
m_buttons.push_back(m_button_pause_resume);
m_buttons.push_back(m_button_abort);
//m_buttons.push_back(m_button_report);
//m_buttons.push_back(m_button_pause_resume);
//m_buttons.push_back(m_button_abort);
m_buttons.push_back(m_button_unload);
m_buttons.push_back(m_button_clean);
m_buttons.push_back(m_bpButton_z_10);
@ -975,7 +1055,10 @@ StatusPanel::StatusPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, co
/* set default enable state */
m_button_pause_resume->Enable(false);
m_button_pause_resume->SetBitmap_("print_control_resume_disable");
m_button_abort->Enable(false);
m_button_abort->SetBitmap_("print_control_stop_disable");
Bind(wxEVT_WEBREQUEST_STATE, &StatusPanel::on_webrequest_state, this);
@ -1056,12 +1139,12 @@ StatusPanel::~StatusPanel()
void StatusPanel::init_scaled_buttons()
{
m_button_report->SetMinSize(wxSize(FromDIP(48), FromDIP(24)));
m_button_report->SetCornerRadius(FromDIP(12));
m_button_pause_resume->SetMinSize(wxSize(FromDIP(48), FromDIP(24)));
m_button_pause_resume->SetCornerRadius(FromDIP(12));
m_button_abort->SetMinSize(wxSize(FromDIP(48), FromDIP(24)));
m_button_abort->SetCornerRadius(FromDIP(12));
// m_button_report->SetMinSize(wxSize(FromDIP(48), FromDIP(24)));
// m_button_report->SetCornerRadius(FromDIP(12));
//m_button_pause_resume->SetMinSize(wxSize(FromDIP(48), FromDIP(24)));
//m_button_pause_resume->SetCornerRadius(FromDIP(12));
//m_button_abort->SetMinSize(wxSize(FromDIP(48), FromDIP(24)));
//m_button_abort->SetCornerRadius(FromDIP(12));
m_button_clean->SetMinSize(wxSize(FromDIP(48), FromDIP(24)));
m_button_clean->SetCornerRadius(FromDIP(12));
m_button_unload->SetMinSize(wxSize(-1, FromDIP(24)));
@ -1230,14 +1313,41 @@ void StatusPanel::update(MachineObject *obj)
}
calibration_dlg->update_cali(obj);
if (print_options_dlg == nullptr) {
print_options_dlg = new PrintOptionsDialog(this);
print_options_dlg->update_machine_obj(obj);
if (obj->is_function_supported(PrinterFunction::FUNC_FIRSTLAYER_INSPECT)
|| obj->is_function_supported(PrinterFunction::FUNC_SPAGHETTI)) {
m_options_btn->Show();
if (print_options_dlg == nullptr) {
print_options_dlg = new PrintOptionsDialog(this);
print_options_dlg->update_machine_obj(obj);
} else {
print_options_dlg->update_machine_obj(obj);
}
print_options_dlg->update_options(obj);
} else {
print_options_dlg->update_machine_obj(obj);
m_options_btn->Hide();
}
print_options_dlg->update_options(obj);
if (obj->is_function_supported(PrinterFunction::FUNC_TIMELAPSE)) {
m_timelapse_button->Show();
} else {
m_timelapse_button->Hide();
}
if (obj->is_function_supported(PrinterFunction::FUNC_RECORDING)) {
m_recording_button->Show();
} else {
m_recording_button->Hide();
}
if (obj->is_function_supported(PrinterFunction::FUNC_CHAMBER_TEMP)) {
m_tempCtrl_frame->Enable();
} else {
m_tempCtrl_frame->SetLabel(TEMP_BLANK_STR);
m_tempCtrl_frame->GetTextCtrl()->SetLabel(TEMP_BLANK_STR);
m_tempCtrl_frame->Disable();
}
update_error_message();
}
@ -1422,7 +1532,13 @@ void StatusPanel::update_misc_ctrl(MachineObject *obj)
void StatusPanel::update_ams(MachineObject *obj)
{
// update obj in sub dlg
if (m_ams_setting_dlg) { m_ams_setting_dlg->obj = obj; }
if (m_ams_setting_dlg) {
m_ams_setting_dlg->obj = obj;
if (obj && m_ams_setting_dlg->IsShown()) {
m_ams_setting_dlg->update_insert_material_read_mode(obj->ams_insert_flag);
m_ams_setting_dlg->update_starting_read_mode(obj->ams_power_on_flag);
}
}
if (m_filament_setting_dlg) { m_filament_setting_dlg->obj = obj; }
if (!obj || !obj->is_connected()) {
@ -1430,6 +1546,7 @@ void StatusPanel::update_ams(MachineObject *obj)
last_ams_exist_bits = -1;
last_tray_is_bbl_bits = -1;
last_read_done_bits = -1;
last_reading_bits = -1;
last_ams_version = -1;
m_ams_control->EnterNoneAMSMode();
show_ams_group(false);
@ -1473,6 +1590,7 @@ void StatusPanel::update_ams(MachineObject *obj)
last_ams_exist_bits = obj->ams_exist_bits;
last_tray_is_bbl_bits = obj->tray_is_bbl_bits;
last_read_done_bits = obj->tray_read_done_bits;
last_reading_bits = obj->tray_reading_bits;
last_ams_version = obj->ams_version;
}
@ -1573,10 +1691,20 @@ void StatusPanel::update_ams(MachineObject *obj)
for (auto tray_it = ams_it->second->trayList.begin(); tray_it != ams_it->second->trayList.end(); tray_it++) {
std::string tray_id = tray_it->first;
int tray_id_int = atoi(tray_id.c_str());
if ((obj->tray_read_done_bits & (1 << (ams_id_int * 4 + tray_id_int))) == 0) {
m_ams_control->PlayRridLoading(ams_id, tray_id);
if (obj->ams_insert_flag < 0) {
// old protocol
if ((obj->tray_read_done_bits & (1 << (ams_id_int * 4 + tray_id_int))) == 0) {
m_ams_control->PlayRridLoading(ams_id, tray_id);
} else {
m_ams_control->StopRridLoading(ams_id, tray_id);
}
} else {
m_ams_control->StopRridLoading(ams_id, tray_id);
// new protocol
if ((obj->tray_reading_bits & (1 << (ams_id_int * 4 + tray_id_int))) != 0) {
m_ams_control->PlayRridLoading(ams_id, tray_id);
} else {
m_ams_control->StopRridLoading(ams_id, tray_id);
}
}
}
} catch (...) {}
@ -1639,6 +1767,42 @@ void StatusPanel::update_left_time(int mc_left_time)
m_staticText_progress_left->SetLabelText(left_time_text);
}
void StatusPanel::update_basic_print_data(bool def)
{
if (def) {
if (!obj) return;
if (!obj->slice_info) return;
wxString prediction = wxString::Format("%s", get_bbl_time_dhms(obj->slice_info->prediction));
wxString weight = wxString::Format("%.2fg", obj->slice_info->weight);
if (!m_staticText_consumption_of_time->IsShown()) {
m_bitmap_static_use_time->Show();
m_staticText_consumption_of_time->Show();
}
if (!m_staticText_consumption_of_weight->IsShown()) {
m_bitmap_static_use_weight->Show();
m_staticText_consumption_of_weight->Show();
}
m_staticText_consumption_of_time->SetLabelText(prediction);
m_staticText_consumption_of_weight->SetLabelText(weight);
} else {
if (m_staticText_consumption_of_time->IsShown()) {
m_bitmap_static_use_time->Hide();
m_staticText_consumption_of_time->Hide();
}
if (m_staticText_consumption_of_weight->IsShown()) {
m_bitmap_static_use_weight->Hide();
m_staticText_consumption_of_weight->Hide();
}
m_staticText_consumption_of_time->SetLabelText("0m");
m_staticText_consumption_of_weight->SetLabelText("0g");
}
}
void StatusPanel::update_subtask(MachineObject *obj)
{
if (!obj) return;
@ -1648,28 +1812,39 @@ void StatusPanel::update_subtask(MachineObject *obj)
} else if (obj->is_in_printing() || obj->print_status == "FINISH") {
if (obj->is_in_prepare()) {
m_button_abort->Enable(false);
m_button_abort->SetBitmap_("print_control_stop_disable");
m_button_pause_resume->Enable(false);
m_button_pause_resume->SetLabel(_L("Pause"));
m_button_pause_resume->SetBitmap_("print_control_pause_disable");
wxString prepare_text = wxString::Format(_L("Downloading..."));
if (obj->gcode_file_prepare_percent >= 0 && obj->gcode_file_prepare_percent <= 100)
prepare_text += wxString::Format("(%d%%)", obj->gcode_file_prepare_percent);
m_printing_stage_value->SetLabelText(prepare_text);
m_gauge_progress->SetValue(0);
m_staticText_progress_percent->SetLabelText(NA_STR);
m_staticText_progress_percent_icon->SetLabelText(wxEmptyString);
m_staticText_progress_left->SetLabel(NA_STR);
m_staticText_progress_left->SetLabelText(NA_STR);
wxString subtask_text = wxString::Format("%s", GUI::from_u8(obj->subtask_name));
m_staticText_subtask_value->SetLabelText(subtask_text);
update_basic_print_data(false);
} else {
if (obj->can_resume())
m_button_pause_resume->SetLabel(_L("Resume"));
else
m_button_pause_resume->SetLabel(_L("Pause"));
if (obj->can_resume()) {
m_button_pause_resume->SetBitmap_("print_control_resume");
if (m_button_pause_resume->GetToolTipText() != _L("Resume")) { m_button_pause_resume->SetToolTip(_L("Resume")); }
} else {
m_button_pause_resume->SetBitmap_("print_control_pause");
if (m_button_pause_resume->GetToolTipText() != _L("Pause")) { m_button_pause_resume->SetToolTip(_L("Pause")); }
}
if (obj->print_status == "FINISH") {
m_button_abort->Enable(false);
m_button_abort->SetBitmap_("print_control_stop_disable");
m_button_pause_resume->Enable(false);
m_button_pause_resume->SetBitmap_("print_control_resume_disable");
} else {
m_button_abort->Enable(true);
m_button_abort->SetBitmap_("print_control_stop");
m_button_pause_resume->Enable(true);
}
// update printing stage
@ -1677,18 +1852,22 @@ void StatusPanel::update_subtask(MachineObject *obj)
update_left_time(obj->mc_left_time);
if (obj->subtask_) {
m_gauge_progress->SetValue(obj->subtask_->task_progress);
m_staticText_progress_percent->SetLabelText(wxString::Format("%d%%", obj->subtask_->task_progress));
m_staticText_progress_percent->SetLabelText(wxString::Format("%d", obj->subtask_->task_progress));
m_staticText_progress_percent_icon->SetLabelText("%");
} else {
m_gauge_progress->SetValue(0);
m_staticText_progress_percent->SetLabelText(NA_STR);
m_staticText_progress_percent_icon->SetLabelText(wxEmptyString);
}
}
wxString subtask_text = wxString::Format("%s", GUI::from_u8(obj->subtask_name));
m_staticText_subtask_value->SetLabelText(subtask_text);
//update thumbnail
if (obj->is_sdcard_printing()) {
update_basic_print_data(false);
update_sdcard_subtask(obj);
} else {
update_basic_print_data(true);
update_cloud_subtask(obj);
}
} else {
@ -1744,13 +1923,18 @@ void StatusPanel::update_sdcard_subtask(MachineObject *obj)
void StatusPanel::reset_printing_values()
{
m_button_pause_resume->Enable(false);
m_button_pause_resume->SetLabel(_L("Pause"));
m_button_pause_resume->SetBitmap_("print_control_pause_disable");
m_button_abort->Enable(false);
m_button_abort->SetBitmap_("print_control_stop_disable");
m_gauge_progress->SetValue(0);
m_staticText_subtask_value->SetLabelText(NA_STR);
update_basic_print_data(false);
m_printing_stage_value->SetLabelText("");
m_staticText_progress_left->SetLabelText(NA_STR);
m_staticText_progress_percent->SetLabelText(NA_STR);
m_staticText_progress_percent_icon->SetLabelText(wxEmptyString);
m_bitmap_thumbnail->SetBitmap(m_thumbnail_placeholder.bmp());
m_start_loading_thumbnail = false;
m_load_sdcard_thumbnail = false;
@ -1881,8 +2065,8 @@ void StatusPanel::on_ams_setting_click(SimpleEvent &event)
{
if (!m_ams_setting_dlg) m_ams_setting_dlg = new AMSSetting((wxWindow *) this, wxID_ANY);
if (obj) {
m_ams_setting_dlg->update_insert_material_read_mode(true);
m_ams_setting_dlg->update_starting_read_mode(true);
m_ams_setting_dlg->update_insert_material_read_mode(obj->ams_insert_flag);
m_ams_setting_dlg->update_starting_read_mode(obj->ams_power_on_flag);
std::string ams_id = m_ams_control->GetCurentAms();
try {
int ams_id_int = atoi(ams_id.c_str());
@ -2243,6 +2427,11 @@ void StatusPanel::set_default()
m_show_ams_group = false;
reset_printing_values();
m_timelapse_button->Show();
m_recording_button->Show();
m_tempCtrl_frame->Show();
m_options_btn->Show();
reset_temp_misc_control();
m_ams_control->Hide();
m_ams_control_box->Hide();
@ -2312,10 +2501,10 @@ void StatusPanel::msw_rescale()
//m_bitmap_camera_img->SetBitmap(m_bitmap_camera);
//m_bitmap_camera_img->SetMinSize(wxSize(FromDIP(32), FromDIP(18)));
m_timelapse_button->SetMinSize(wxSize(32, 24));
m_recording_button->SetMinSize(wxSize(32, 24));
m_bitmap_sdcard_off_img->SetMinSize(wxSize(FromDIP(32), FromDIP(20)));
m_bitmap_sdcard_on_img->SetMinSize(wxSize(FromDIP(32), FromDIP(20)));
m_timelapse_button->SetMinSize(wxSize(38, 24));
m_recording_button->SetMinSize(wxSize(38, 24));
m_bitmap_sdcard_off_img->SetMinSize(wxSize(FromDIP(38), FromDIP(24)));
m_bitmap_sdcard_on_img->SetMinSize(wxSize(FromDIP(38), FromDIP(24)));
m_bpButton_xy->Rescale();
m_tempCtrl_nozzle->SetMinSize(TEMP_CTRL_MIN_SIZE);

View file

@ -28,7 +28,7 @@
#include "Widgets/ImageSwitchButton.hpp"
#include "Widgets/AMSControl.hpp"
#include "HMS.hpp"
#include "Widgets/wxStaticText2.hpp"
#include "Widgets/ErrorMsgStaticText.hpp"
class StepIndicator;
#define COMMAND_TIMEOUT_U0 15
@ -78,6 +78,8 @@ protected:
ScalableBitmap m_bitmap_lamp_off;
ScalableBitmap m_bitmap_fan_on;
ScalableBitmap m_bitmap_fan_off;
ScalableBitmap m_bitmap_use_time;
ScalableBitmap m_bitmap_use_weight;
wxBitmap m_bitmap_extruder;
CameraRecordingStatus m_state_recording{CameraRecordingStatus::RECORDING_NONE};
@ -97,6 +99,8 @@ protected:
wxPanel * m_panel_printing_title;
wxPanel * m_panel_control_title;
wxStaticText* m_staticText_consumption_of_time;
wxStaticText * m_staticText_consumption_of_weight;
wxStaticText * m_staticText_monitoring;
wxStaticText * m_staticText_timelapse;
SwitchButton * m_bmToggleBtn_timelapse;
@ -105,6 +109,8 @@ protected:
wxStaticBitmap *m_bitmap_recording_img;
wxStaticBitmap *m_bitmap_sdcard_on_img;
wxStaticBitmap *m_bitmap_sdcard_off_img;
wxStaticBitmap *m_bitmap_static_use_time;
wxStaticBitmap *m_bitmap_static_use_weight;
wxMediaCtrl2 * m_media_ctrl;
@ -116,10 +122,11 @@ protected:
wxStaticText * m_printing_stage_value;
ProgressBar* m_gauge_progress;
wxStaticText * m_staticText_progress_percent;
wxStaticText * m_staticText_progress_percent_icon;
wxStaticText * m_staticText_progress_left;
Button * m_button_report;
Button * m_button_pause_resume;
Button * m_button_abort;
ScalableButton *m_button_pause_resume;
ScalableButton *m_button_abort;
Button * m_button_clean;
wxStaticText * m_text_tasklist_caption;
@ -170,7 +177,7 @@ protected:
wxBoxSizer * m_tasklist_caption_sizer;
wxPanel* m_panel_error_txt;
wxPanel* m_staticline;
wxStaticText2 * m_error_text;
ErrorMsgStaticText * m_error_text;
wxStaticText* m_staticText_calibration_caption;
wxStaticText* m_staticText_calibration_caption_top;
wxStaticText* m_calibration_text;
@ -320,6 +327,7 @@ protected:
void update(MachineObject* obj);
void show_printing_status(bool ctrl_area = true, bool temp_area = true);
void update_left_time(int mc_left_time);
void update_basic_print_data(bool def = false);
void update_subtask(MachineObject *obj);
void update_cloud_subtask(MachineObject *obj);
void update_sdcard_subtask(MachineObject *obj);
@ -349,6 +357,7 @@ public:
long last_ams_exist_bits { -1 };
long last_tray_is_bbl_bits{ -1 };
long last_read_done_bits{ -1 };
long last_reading_bits { -1 };
long last_ams_version { -1 };
std::vector<int> last_stage_list_info;

View file

@ -1372,12 +1372,50 @@ 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" )
if (opt_key == "single_extruder_multi_material" || opt_key == "extruders_count" )
update_wiping_button_visibility();
if (opt_key == "enable_prime_tower") {
bool timelapse_enabled = m_config->option<ConfigOptionBool>("timelapse_no_toolhead")->value;
if (!boost::any_cast<bool>(value) && timelapse_enabled) {
MessageDialog dlg(wxGetApp().plater(), _L("Prime tower is required by timeplase. Are you sure you want to disable both of them?"),
_L("Warning"), wxICON_WARNING | wxYES | wxNO);
if (dlg.ShowModal() == wxID_YES) {
DynamicPrintConfig new_conf = *m_config;
new_conf.set_key_value("timelapse_no_toolhead", new ConfigOptionBool(false));
m_config_manipulation.apply(m_config, &new_conf);
wxGetApp().plater()->update();
}
else {
DynamicPrintConfig new_conf = *m_config;
new_conf.set_key_value("enable_prime_tower", new ConfigOptionBool(true));
m_config_manipulation.apply(m_config, &new_conf);
}
}
update_wiping_button_visibility();
}
// reload scene to update timelapse wipe tower
if (opt_key == "timelapse_no_toolhead")
wxGetApp().plater()->update();
if (opt_key == "timelapse_no_toolhead") {
bool wipe_tower_enabled = m_config->option<ConfigOptionBool>("enable_prime_tower")->value;
if (!wipe_tower_enabled && boost::any_cast<bool>(value)) {
MessageDialog dlg(wxGetApp().plater(), _L("Prime tower is required by timelapse. Do you want to enable both of them?"),
_L("Warning"), wxICON_WARNING | wxYES | wxNO);
if (dlg.ShowModal() == wxID_YES) {
DynamicPrintConfig new_conf = *m_config;
new_conf.set_key_value("enable_prime_tower", new ConfigOptionBool(true));
m_config_manipulation.apply(m_config, &new_conf);
wxGetApp().plater()->update();
}
else {
DynamicPrintConfig new_conf = *m_config;
new_conf.set_key_value("timelapse_no_toolhead", new ConfigOptionBool(false));
m_config_manipulation.apply(m_config, &new_conf);
}
} else {
wxGetApp().plater()->update();
}
}
// BBS
#if 0
@ -1711,7 +1749,7 @@ void TabPrint::build()
auto optgroup = page->new_optgroup(L("Layer height"));
optgroup->append_single_option_line("layer_height");
optgroup->append_single_option_line("initial_layer_print_height");
optgroup->append_single_option_line("adaptive_layer_height");
optgroup->append_single_option_line("adaptive_layer_height", "adaptive-layer-height");
optgroup = page->new_optgroup(L("Line width"));
optgroup->append_single_option_line("line_width");
@ -1724,7 +1762,7 @@ void TabPrint::build()
optgroup->append_single_option_line("support_line_width");
optgroup = page->new_optgroup(L("Seam"));
optgroup->append_single_option_line("seam_position");
optgroup->append_single_option_line("seam_position", "Seam");
optgroup = page->new_optgroup(L("Precision"));
optgroup->append_single_option_line("resolution");
@ -1782,8 +1820,9 @@ void TabPrint::build()
optgroup->append_single_option_line("sparse_infill_speed");
optgroup->append_single_option_line("internal_solid_infill_speed");
optgroup->append_single_option_line("top_surface_speed");
optgroup->append_single_option_line("enable_overhang_speed");
optgroup->append_single_option_line("enable_overhang_speed", "slow-down-for-overhang");
Line line = { L("Overhang speed"), L("This is the speed for various overhang degrees. Overhang degrees are expressed as a percentage of line width. 0 speed means no slowing down for the overhang degree range and wall speed is used") };
line.label_path = "slow-down-for-overhang";
line.append_option(optgroup->get_option("overhang_1_4_speed"));
line.append_option(optgroup->get_option("overhang_2_4_speed"));
line.append_option(optgroup->get_option("overhang_3_4_speed"));
@ -1809,41 +1848,41 @@ void TabPrint::build()
page = add_options_page(L("Support"), "support");
optgroup = page->new_optgroup(L("Support"));
optgroup->append_single_option_line("enable_support");
optgroup->append_single_option_line("support_type");
optgroup->append_single_option_line("support_threshold_angle");
optgroup->append_single_option_line("enable_support", "support");
optgroup->append_single_option_line("support_type", "support");
optgroup->append_single_option_line("support_threshold_angle", "support");
optgroup->append_single_option_line("support_on_build_plate_only");
//optgroup->append_single_option_line("enforce_support_layers");
optgroup = page->new_optgroup(L("Support filament"));
optgroup->append_single_option_line("support_filament");
optgroup->append_single_option_line("support_interface_filament");
optgroup->append_single_option_line("support_filament", "support");
optgroup->append_single_option_line("support_interface_filament", "support");
//optgroup = page->new_optgroup(L("Options for support material and raft"));
//optgroup->append_single_option_line("support_style");
//BBS
optgroup = page->new_optgroup(L("Advanced"));
optgroup->append_single_option_line("tree_support_branch_distance");
optgroup->append_single_option_line("tree_support_branch_diameter");
optgroup->append_single_option_line("tree_support_branch_angle");
optgroup->append_single_option_line("tree_support_branch_distance", "support");
optgroup->append_single_option_line("tree_support_branch_diameter", "support");
optgroup->append_single_option_line("tree_support_branch_angle", "support");
optgroup->append_single_option_line("tree_support_wall_count");
optgroup->append_single_option_line("tree_support_with_infill");
optgroup->append_single_option_line("support_top_z_distance");
optgroup->append_single_option_line("support_base_pattern");
optgroup->append_single_option_line("support_base_pattern_spacing");
optgroup->append_single_option_line("support_top_z_distance", "support");
optgroup->append_single_option_line("support_base_pattern", "support");
optgroup->append_single_option_line("support_base_pattern_spacing", "support");
//optgroup->append_single_option_line("support_angle");
optgroup->append_single_option_line("support_interface_top_layers");
optgroup->append_single_option_line("support_interface_bottom_layers");
optgroup->append_single_option_line("support_interface_pattern");
optgroup->append_single_option_line("support_interface_spacing");
optgroup->append_single_option_line("support_interface_top_layers", "support");
optgroup->append_single_option_line("support_interface_bottom_layers", "support");
optgroup->append_single_option_line("support_interface_pattern", "support");
optgroup->append_single_option_line("support_interface_spacing", "support");
optgroup->append_single_option_line("support_bottom_interface_spacing");
//optgroup->append_single_option_line("support_interface_loop_pattern");
optgroup->append_single_option_line("support_object_xy_distance");
optgroup->append_single_option_line("bridge_no_support");
optgroup->append_single_option_line("max_bridge_length");
optgroup->append_single_option_line("thick_bridges");
optgroup->append_single_option_line("support_object_xy_distance", "support");
optgroup->append_single_option_line("bridge_no_support", "support");
optgroup->append_single_option_line("max_bridge_length", "support");
optgroup->append_single_option_line("thick_bridges", "support");
//optgroup->append_single_option_line("independent_support_layer_height");
page = add_options_page(L("Others"), "advanced");
@ -1851,9 +1890,9 @@ void TabPrint::build()
optgroup->append_single_option_line("skirt_loops");
optgroup->append_single_option_line("skirt_distance");
//optgroup->append_single_option_line("draft_shield");
optgroup->append_single_option_line("brim_type");
optgroup->append_single_option_line("brim_width");
optgroup->append_single_option_line("brim_object_gap");
optgroup->append_single_option_line("brim_type", "auto-brim");
optgroup->append_single_option_line("brim_width", "auto-brim");
optgroup->append_single_option_line("brim_object_gap", "auto-brim");
optgroup->append_single_option_line("raft_layers");
//optgroup->append_single_option_line("raft_first_layer_density");
//optgroup->append_single_option_line("raft_first_layer_expansion");
@ -1865,14 +1904,14 @@ void TabPrint::build()
optgroup->append_single_option_line("prime_tower_brim_width");
optgroup = page->new_optgroup(L("Flush options"));
optgroup->append_single_option_line("flush_into_infill");
optgroup->append_single_option_line("flush_into_objects");
optgroup->append_single_option_line("flush_into_support");
optgroup->append_single_option_line("flush_into_infill", "reduce-wasting-during-filament-change");
optgroup->append_single_option_line("flush_into_objects", "reduce-wasting-during-filament-change");
optgroup->append_single_option_line("flush_into_support", "reduce-wasting-during-filament-change");
optgroup = page->new_optgroup(L("Special mode"));
optgroup->append_single_option_line("print_sequence");
optgroup->append_single_option_line("spiral_mode");
optgroup->append_single_option_line("timelapse_no_toolhead");
optgroup->append_single_option_line("spiral_mode", "spiral-vase");
optgroup->append_single_option_line("timelapse_no_toolhead", "Timelapse");
//BBS: todo remove clearance to machine
#if 0
//line = { L("Extruder radius"), "" };
@ -2039,7 +2078,7 @@ void TabPrintModel::build()
optgroup->append_single_option_line("layer_height");
optgroup->append_single_option_line("sparse_infill_density");
optgroup->append_single_option_line("wall_loops");
optgroup->append_single_option_line("enable_support");
optgroup->append_single_option_line("enable_support", "support");
m_pages.pop_back();
m_pages.insert(m_pages.begin(), page);
@ -2436,6 +2475,11 @@ void TabFilament::build()
line.append_option(optgroup->get_option("hot_plate_temp"));
optgroup->append_line(line);
line = {L("Textured PEI Plate"), L("Bed temperature when Textured PEI Plate is installed. Value 0 means the filament does not support to print on the Textured PEI Plate")};
line.append_option(optgroup->get_option("textured_plate_temp_initial_layer"));
line.append_option(optgroup->get_option("textured_plate_temp"));
optgroup->append_line(line);
optgroup->m_on_change = [this, optgroup](t_config_option_key opt_key, boost::any value)
{
DynamicPrintConfig& filament_config = wxGetApp().preset_bundle->filaments.get_edited_preset().config;
@ -2450,6 +2494,9 @@ void TabFilament::build()
else if (opt_key == "hot_plate_temp" || opt_key == "hot_plate_temp_initial_layer") {
m_config_manipulation.check_bed_temperature_difference(BedType::btPEI, &filament_config);
}
else if (opt_key == "textured_plate_temp" || opt_key == "textured_plate_temp_initial_layer") {
m_config_manipulation.check_bed_temperature_difference(BedType::btPTE, &filament_config);
}
else if (opt_key == "nozzle_temperature") {
m_config_manipulation.check_nozzle_temperature_range(&filament_config);
}
@ -2480,25 +2527,27 @@ void TabFilament::build()
//};
//optgroup->append_line(line);
optgroup = page->new_optgroup(L("Cooling for specific layer"));
optgroup->append_single_option_line("close_fan_the_first_x_layers");
optgroup->append_single_option_line("close_fan_the_first_x_layers", "auto-cooling");
//optgroup->append_single_option_line("full_fan_speed_layer");
optgroup = page->new_optgroup(L("Part cooling fan"));
line = { L("Min fan speed threshold"), L("Part cooling fan speed will start to run at min speed when the estimated layer time is no longer than the layer time in setting. When layer time is shorter than threshold, fan speed is interpolated between the minimum and maximum fan speed according to layer printing time") };
line.label_path = "auto-cooling";
line.append_option(optgroup->get_option("fan_min_speed"));
line.append_option(optgroup->get_option("fan_cooling_layer_time"));
optgroup->append_line(line);
line = { L("Max fan speed threshold"), L("Part cooling fan speed will be max when the estimated layer time is shorter than the setting value") };
line.label_path = "auto-cooling";
line.append_option(optgroup->get_option("fan_max_speed"));
line.append_option(optgroup->get_option("slow_down_layer_time"));
optgroup->append_line(line);
optgroup->append_single_option_line("reduce_fan_stop_start_freq");
optgroup->append_single_option_line("slow_down_for_layer_cooling");
optgroup->append_single_option_line("slow_down_for_layer_cooling", "auto-cooling");
optgroup->append_single_option_line("slow_down_min_speed");
optgroup->append_single_option_line("enable_overhang_bridge_fan");
optgroup->append_single_option_line("overhang_fan_threshold");
optgroup->append_single_option_line("overhang_fan_speed");
optgroup->append_single_option_line("enable_overhang_bridge_fan", "auto-cooling");
optgroup->append_single_option_line("overhang_fan_threshold", "auto-cooling");
optgroup->append_single_option_line("overhang_fan_speed", "auto-cooling");
optgroup = page->new_optgroup(L("Auxiliary part cooling fan"));
optgroup->append_single_option_line("additional_cooling_fan_speed");

View file

@ -1822,7 +1822,7 @@ DiffPresetDialog::DiffPresetDialog(MainFrame* mainframe)
});
}
m_show_all_presets = new wxCheckBox(this, wxID_ANY, "Show all presets (including incompatible)");
m_show_all_presets = new wxCheckBox(this, wxID_ANY, _L("Show all presets (including incompatible)"));
m_show_all_presets->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent&) {
bool show_all = m_show_all_presets->GetValue();
for (auto preset_combos : m_preset_combos) {
@ -1883,7 +1883,7 @@ void DiffPresetDialog::update_bundles_from_app()
void DiffPresetDialog::show(Preset::Type type /* = Preset::TYPE_INVALID*/)
{
this->SetTitle("Compare Presets");
this->SetTitle(_L("Compare presets"));
m_view_type = type;
update_bundles_from_app();

View file

@ -19,8 +19,6 @@ MachineInfoPanel::MachineInfoPanel(wxWindow* parent, wxWindowID id, const wxPoin
init_bitmaps();
wxBoxSizer *m_top_sizer = new wxBoxSizer(wxVERTICAL);
m_panel_caption = create_caption_panel(this);
@ -107,6 +105,13 @@ MachineInfoPanel::MachineInfoPanel(wxWindow* parent, wxWindowID id, const wxPoin
wxBoxSizer *m_ams_content_sizer = new wxBoxSizer(wxVERTICAL);
m_ams_content_sizer->Add(0, 40, 0, wxEXPAND, FromDIP(5));
m_ahb_panel = new AmsPanel(this, wxID_ANY);
m_ahb_panel->m_staticText_ams->SetLabel("AMS HUB");
m_ams_content_sizer->Add(m_ahb_panel, 0, wxEXPAND, 0);
m_ams_info_sizer = new wxGridSizer(0, 2, FromDIP(30), FromDIP(30));
@ -122,7 +127,6 @@ MachineInfoPanel::MachineInfoPanel(wxWindow* parent, wxWindowID id, const wxPoin
}
m_ams_content_sizer->Add(m_ams_info_sizer, 0, wxEXPAND, 0);
m_ams_sizer->Add(m_ams_content_sizer, 1, wxEXPAND, 0);
m_main_left_sizer->Add(m_ams_sizer, 0, wxEXPAND, 0);
@ -276,7 +280,7 @@ void MachineInfoPanel::update(MachineObject* obj)
m_caption_text->SetLabelText(caption_text);
show_status(MachineObject::UpgradingDisplayState::UpgradingUnavaliable);
} else {
show_status(obj->upgrade_display_state);
show_status(obj->upgrade_display_state, obj->upgrade_status);
if (obj->upgrade_display_state == (int) MachineObject::UpgradingDisplayState::UpgradingUnavaliable) {
if (obj->can_abort()) {
wxString caption_text = wxString::Format("%s(%s)", from_u8(obj->dev_name), _L("Printing"));
@ -332,32 +336,135 @@ void MachineInfoPanel::update_version_text(MachineObject* obj)
} else {
// update version text
auto it = obj->module_vers.find("ota");
if (obj->upgrade_new_version
&& !obj->ota_new_version_number.empty()) {
if (it != obj->module_vers.end()) {
wxString ver_text = wxString::Format("%s->%s", it->second.sw_ver, obj->ota_new_version_number);
m_staticText_ver_val->SetLabelText(ver_text);
// old protocol
if (obj->new_ver_list.empty() && !obj->m_new_ver_list_exist) {
if (obj->upgrade_new_version
&& !obj->ota_new_version_number.empty()) {
if (it != obj->module_vers.end()) {
wxString ver_text = wxString::Format("%s->%s", it->second.sw_ver, obj->ota_new_version_number);
m_staticText_ver_val->SetLabelText(ver_text);
}
else {
m_staticText_ver_val->SetLabelText("-");
}
m_ota_new_version_img->Show();
}
else {
m_staticText_ver_val->SetLabelText("-");
if (it != obj->module_vers.end()) {
wxString ver_text = wxString::Format("%s(%s)", it->second.sw_ver, _L("Latest version"));
m_staticText_ver_val->SetLabelText(ver_text);
}
else {
m_staticText_ver_val->SetLabelText("-");
}
m_ota_new_version_img->Hide();
}
m_ota_new_version_img->Show();
}
else {
if (it != obj->module_vers.end()) {
wxString ver_text = wxString::Format("%s(%s)", it->second.sw_ver, _L("Lastest version"));
} else {
auto ota_it = obj->new_ver_list.find("ota");
if (ota_it == obj->new_ver_list.end()) {
wxString ver_text = wxString::Format("%s(%s)", it->second.sw_ver, _L("Latest version"));
m_staticText_ver_val->SetLabelText(ver_text);
m_ota_new_version_img->Hide();
} else {
if (ota_it->second.sw_new_ver != ota_it->second.sw_ver) {
m_ota_new_version_img->Show();
wxString ver_text = wxString::Format("%s->%s", ota_it->second.sw_ver, ota_it->second.sw_new_ver);
m_staticText_ver_val->SetLabelText(ver_text);
} else {
m_ota_new_version_img->Hide();
wxString ver_text = wxString::Format("%s(%s)", it->second.sw_ver, _L("Latest version"));
m_staticText_ver_val->SetLabelText(ver_text);
}
}
else {
m_staticText_ver_val->SetLabelText("-");
}
m_ota_new_version_img->Hide();
}
}
}
void MachineInfoPanel::update_ams(MachineObject *obj)
{
bool has_hub_model = false;
//hub
if (!obj->online_ahb || obj->module_vers.find("ahb") == obj->module_vers.end())
m_ahb_panel->Hide();
else {
has_hub_model = true;
show_ams(true);
for (auto i = 0; i < m_amspanel_list.GetCount(); i++) {
AmsPanel *amspanel = m_amspanel_list[i];
amspanel->Hide();
}
m_ahb_panel->Show();
wxString hub_sn = "-";
if (!obj->module_vers.find("ahb")->second.sn.empty()) {
wxString sn_text = obj->module_vers.find("ahb")->second.sn;
hub_sn = sn_text.MakeUpper();
}
wxString hub_ver = "-";
if (!obj->module_vers.find("ahb")->second.sw_ver.empty()) {
wxString sn_text = obj->module_vers.find("ahb")->second.sw_ver;
hub_ver = sn_text.MakeUpper();
}
/* auto ver_item = obj->new_ver_list.find("ahb");
if (ver_item != obj->new_ver_list.end()) {
m_ahb_panel->m_ams_new_version_img->Show();
hub_ver = wxString::Format("%s->%s", hub_ver, ver_item->second.sw_new_ver);
} else {
m_ahb_panel->m_ams_new_version_img->Hide();
hub_ver = wxString::Format("%s(%s)", hub_ver, _L("Latest version"));
}*/
if (obj->new_ver_list.empty() && !obj->m_new_ver_list_exist) {
if (obj->upgrade_new_version && obj->ahb_new_version_number.compare(obj->module_vers.find("ahb")->second.sw_ver) != 0) {
m_ahb_panel->m_ams_new_version_img->Show();
if (obj->ahb_new_version_number.empty()) {
hub_ver = wxString::Format("%s", obj->module_vers.find("ahb")->second.sw_ver);
} else {
hub_ver = wxString::Format("%s->%s", obj->module_vers.find("ahb")->second.sw_ver, obj->ahb_new_version_number);
}
} else {
m_ahb_panel->m_ams_new_version_img->Hide();
if (obj->ahb_new_version_number.empty()) {
wxString ver_text = wxString::Format("%s", obj->module_vers.find("ahb")->second.sw_ver);
hub_ver = ver_text;
} else {
wxString ver_text = wxString::Format("%s(%s)", obj->module_vers.find("ahb")->second.sw_ver, _L("Latest version"));
hub_ver = ver_text;
}
}
} else {
auto ver_item = obj->new_ver_list.find("ahb");
if (ver_item == obj->new_ver_list.end()) {
m_ahb_panel->m_ams_new_version_img->Hide();
wxString ver_text = wxString::Format("%s(%s)", obj->module_vers.find("ahb")->second.sw_ver, _L("Latest version"));
hub_ver = ver_text;
} else {
if (ver_item->second.sw_new_ver != ver_item->second.sw_ver) {
m_ahb_panel->m_ams_new_version_img->Show();
wxString ver_text = wxString::Format("%s->%s", ver_item->second.sw_ver, ver_item->second.sw_new_ver);
hub_ver = ver_text;
} else {
m_ahb_panel->m_ams_new_version_img->Hide();
wxString ver_text = wxString::Format("%s(%s)", ver_item->second.sw_ver, _L("Latest version"));
hub_ver = ver_text;
}
}
}
m_ahb_panel->m_staticText_ams_sn_val->SetLabelText(hub_sn);
m_ahb_panel->m_staticText_ams_ver_val->SetLabelText(hub_ver);
}
//ams
if (obj->ams_exist_bits != 0) {
show_ams(true);
std::map<int, MachineObject::ModuleVersionInfo> ver_list = obj->get_ams_version();
@ -381,34 +488,69 @@ void MachineInfoPanel::update_ams(MachineObject *obj)
auto it = ver_list.find(atoi(iter->first.c_str()));
auto ams_id = std::stoi(iter->second->id);
if (it == ver_list.end()) {
// hide this ams
wxString ams_text = wxString::Format("AMS%s", std::to_string(ams_index + 1));
wxString ams_text = wxString::Format("AMS%s", std::to_string(ams_id + 1));
ams_name = ams_text;
ams_sn = "-";
ams_ver = "-";
} else {
// update ams img
wxString ams_text = wxString::Format("AMS%s", std::to_string(ams_index + 1));
wxString ams_text = wxString::Format("AMS%s", std::to_string(ams_id + 1));
ams_name = ams_text;
if (obj->upgrade_new_version
&& !obj->ams_new_version_number.empty()
&& obj->ams_new_version_number.compare(it->second.sw_ver) != 0) {
amspanel->m_ams_new_version_img->Show();
wxString ver_text = wxString::Format("%s->%s", it->second.sw_ver, obj->ams_new_version_number);
ams_ver = ver_text;
if (obj->new_ver_list.empty() && !obj->m_new_ver_list_exist) {
if (obj->upgrade_new_version
&& obj->ams_new_version_number.compare(it->second.sw_ver) != 0) {
amspanel->m_ams_new_version_img->Show();
if (obj->ams_new_version_number.empty()) {
ams_ver = wxString::Format("%s", it->second.sw_ver);
} else {
ams_ver = wxString::Format("%s->%s", it->second.sw_ver, obj->ams_new_version_number);
}
} else {
amspanel->m_ams_new_version_img->Hide();
if (obj->ams_new_version_number.empty()) {
wxString ver_text = wxString::Format("%s", it->second.sw_ver);
ams_ver = ver_text;
} else {
wxString ver_text = wxString::Format("%s(%s)", it->second.sw_ver, _L("Latest version"));
ams_ver = ver_text;
}
}
} else {
amspanel->m_ams_new_version_img->Hide();
wxString ver_text = wxString::Format("%s(%s)", it->second.sw_ver, _L("Lastest version"));
ams_ver = ver_text;
std::string ams_idx = (boost::format("ams/%1%") % ams_id).str();
auto ver_item = obj->new_ver_list.find(ams_idx);
if (ver_item == obj->new_ver_list.end()) {
amspanel->m_ams_new_version_img->Hide();
wxString ver_text = wxString::Format("%s(%s)", it->second.sw_ver, _L("Latest version"));
ams_ver = ver_text;
} else {
if (ver_item->second.sw_new_ver != ver_item->second.sw_ver) {
amspanel->m_ams_new_version_img->Show();
wxString ver_text = wxString::Format("%s->%s", ver_item->second.sw_ver, ver_item->second.sw_new_ver);
ams_ver = ver_text;
} else {
amspanel->m_ams_new_version_img->Hide();
wxString ver_text = wxString::Format("%s(%s)", ver_item->second.sw_ver, _L("Latest version"));
ams_ver = ver_text;
}
}
}
// update ams sn
if (it->second.sn.empty()) {
ams_sn = "-";
} else {
wxString sn_text = it->second.sn;
ams_sn = sn_text.MakeUpper();
}
}
}
amspanel->m_staticText_ams->SetLabelText(ams_name);
@ -418,18 +560,19 @@ void MachineInfoPanel::update_ams(MachineObject *obj)
ams_index++;
}
} else {
show_ams(false);
if (!has_hub_model) { show_ams(false); }
}
this->Layout();
}
void MachineInfoPanel::show_status(int status)
void MachineInfoPanel::show_status(int status, std::string upgrade_status_str)
{
if (last_status == status)
return;
last_status = status;
if (last_status == status && last_status_str == upgrade_status_str) return;
last_status = status;
last_status_str = upgrade_status_str;
BOOST_LOG_TRIVIAL(trace) << "MachineInfoPanel: show_status = " << status;
BOOST_LOG_TRIVIAL(trace) << "MachineInfoPanel: show_status = " << status << ", str = " << upgrade_status_str;
Freeze();
@ -459,15 +602,7 @@ void MachineInfoPanel::show_status(int status)
m_staticText_upgrading_percent->SetForegroundColour(TEXT_NORMAL_CLR);
m_staticText_upgrading_percent->Show();
} else if (status == (int) MachineObject::UpgradingDisplayState::UpgradingFinished) {
if (true) {
for (size_t i = 0; i < m_upgrading_sizer->GetItemCount(); i++) { m_upgrading_sizer->Show(true); }
m_button_upgrade_firmware->Hide();
m_staticText_upgrading_info->SetLabel(_L("Upgrading success"));
m_staticText_upgrading_info->Show();
m_staticText_upgrading_info->SetForegroundColour(TEXT_NORMAL_CLR);
m_staticText_upgrading_percent->SetForegroundColour(TEXT_NORMAL_CLR);
m_upgrade_retry_img->Hide();
} else {
if (upgrade_status_str == "UPGRADE_FAIL") {
m_staticText_upgrading_info->SetLabel(_L("Upgrading failed"));
m_staticText_upgrading_info->SetForegroundColour(TEXT_FAILED_CLR);
for (size_t i = 0; i < m_upgrading_sizer->GetItemCount(); i++) { m_upgrading_sizer->Show(true); }
@ -475,6 +610,14 @@ void MachineInfoPanel::show_status(int status)
m_staticText_upgrading_info->Show();
m_staticText_upgrading_percent->Hide();
m_upgrade_retry_img->Show();
} else {
for (size_t i = 0; i < m_upgrading_sizer->GetItemCount(); i++) { m_upgrading_sizer->Show(true); }
m_button_upgrade_firmware->Hide();
m_staticText_upgrading_info->SetLabel(_L("Upgrading success"));
m_staticText_upgrading_info->Show();
m_staticText_upgrading_info->SetForegroundColour(TEXT_NORMAL_CLR);
m_staticText_upgrading_percent->SetForegroundColour(TEXT_NORMAL_CLR);
m_upgrade_retry_img->Hide();
}
} else {
;

View file

@ -48,7 +48,7 @@ protected:
wxStaticText * m_staticText_ver_val;
wxStaticLine * m_staticline;
wxStaticBitmap *m_ams_img;
AmsPanel* m_ahb_panel;
wxGridSizer * m_ams_info_sizer;
@ -75,6 +75,7 @@ protected:
wxBitmap upgrade_green_icon;
wxBitmap upgrade_yellow_icon;
int last_status = -1;
std::string last_status_str = "";
void upgrade_firmware_internal();
void on_upgrade_firmware(wxCommandEvent &event);
@ -94,7 +95,7 @@ public:
void update(MachineObject *obj);
void update_version_text(MachineObject *obj);
void update_ams(MachineObject *obj);
void show_status(int status);
void show_status(int status, std::string upgrade_status_str = "");
void show_ams(bool show = false, bool force_update = false);
MachineObject *m_obj{nullptr};

View file

@ -77,7 +77,18 @@ GuideFrame::GuideFrame(GUI_App *pGUI, long style)
//int screenwidth = wxSystemSettings::GetMetric(wxSYS_SCREEN_X, NULL);
//int MaxY = (screenheight - pSize.y) > 0 ? (screenheight - pSize.y) / 2 : 0;
//MoveWindow(this->m_hWnd, (screenwidth - pSize.x) / 2, MaxY, pSize.x, pSize.y, TRUE);
#ifdef __WXMSW__
this->Bind(wxEVT_CHAR_HOOK, [this](wxKeyEvent& e) {
if ((m_page == BBL_FILAMENT_ONLY || m_page == BBL_MODELS_ONLY) && e.GetKeyCode() == WXK_ESCAPE) {
if (this->IsModal())
this->EndModal(wxID_CANCEL);
else
this->Close();
}
else
e.Skip();
});
#endif
// Connect the webview events
Bind(wxEVT_WEBVIEW_NAVIGATING, &GuideFrame::OnNavigationRequest, this, m_browser->GetId());
Bind(wxEVT_WEBVIEW_NAVIGATED, &GuideFrame::OnNavigationComplete, this, m_browser->GetId());
@ -121,6 +132,7 @@ void GuideFrame::load_url(wxString &url)
wxString GuideFrame::SetStartPage(GuidePage startpage, bool load)
{
m_page = startpage;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< boost::format(" enter, load=%1%, start_page=%2%")%load%int(startpage);
//wxLogMessage("GUIDE: webpage_1 %s", (boost::filesystem::path(resources_dir()) / "web\\guide\\1\\index.html").make_preferred().string().c_str() );
wxString TargetUrl = from_u8( (boost::filesystem::path(resources_dir()) / "web/guide/1/index.html").make_preferred().string() );
@ -274,7 +286,9 @@ void GuideFrame::OnScriptMessage(wxWebViewEvent &evt)
json j = json::parse(strInput);
wxString strCmd = j["command"];
if (strCmd == "close_page") {
this->EndModal(wxID_CANCEL);
}
if (strCmd == "user_clause") {
wxString strAction = j["data"]["action"];
@ -898,7 +912,7 @@ int GuideFrame::LoadProfile()
} else {
//cout << "is a file" << endl;
//cout << iter->path().string() << endl;
wxString strVendor = wxString(iter->path().string()).BeforeLast('.');
wxString strVendor = from_u8(iter->path().string()).BeforeLast('.');
strVendor = strVendor.AfterLast( '\\');
strVendor = strVendor.AfterLast('\/');

View file

@ -47,7 +47,7 @@ public:
BBL_FILAMENTS,
BBL_FILAMENT_ONLY,
BBL_MODELS_ONLY
};
}m_page;
//Web Function
void load_url(wxString &url);

View file

@ -1311,18 +1311,17 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
// normal mode
//Freeze();
wxBoxSizer *m_sizer_body = new wxBoxSizer(wxVERTICAL);
auto amswin = new wxWindow(this, wxID_ANY, wxDefaultPosition, wxSize(-1, AMS_CAN_ITEM_HEIGHT_SIZE));
amswin->SetBackgroundColour(*wxWHITE);
m_amswin = new wxWindow(this, wxID_ANY, wxDefaultPosition, wxSize(-1, AMS_CAN_ITEM_HEIGHT_SIZE));
m_amswin->SetBackgroundColour(*wxWHITE);
// top - ams tag
m_simplebook_amsitems = new wxSimplebook(amswin, wxID_ANY);
m_simplebook_amsitems = new wxSimplebook(m_amswin, wxID_ANY);
m_simplebook_amsitems->SetSize(wxSize(-1, AMS_CAN_ITEM_HEIGHT_SIZE));
m_simplebook_amsitems->SetMinSize(wxSize(-1, AMS_CAN_ITEM_HEIGHT_SIZE));
auto m_sizer_amsitems = new wxBoxSizer(wxHORIZONTAL);
m_simplebook_amsitems->SetSizer(m_sizer_amsitems);
m_simplebook_amsitems->Layout();
m_sizer_amsitems->Fit(m_simplebook_amsitems);
m_sizer_body->Add(m_simplebook_amsitems, 0, wxEXPAND, 0);
m_panel_top = new wxPanel(m_simplebook_amsitems, wxID_ANY, wxDefaultPosition, wxSize(-1, AMS_CAN_ITEM_HEIGHT_SIZE));
m_sizer_top = new wxBoxSizer(wxHORIZONTAL);
m_panel_top->SetSizer(m_sizer_top);
@ -1338,12 +1337,11 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
m_simplebook_amsitems->AddPage(m_panel_top, wxEmptyString, false);
m_simplebook_amsitems->AddPage(m_panel_top_empty, wxEmptyString, false);
m_sizer_body->Add(0, 0, 1, wxEXPAND | wxTOP, 18);
wxBoxSizer *m_sizer_bottom = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *m_sizer_left = new wxBoxSizer(wxVERTICAL);
m_panel_can = new StaticBox(amswin, wxID_ANY, wxDefaultPosition, AMS_CANS_SIZE, wxBORDER_NONE);
m_panel_can = new StaticBox(m_amswin, wxID_ANY, wxDefaultPosition, AMS_CANS_SIZE, wxBORDER_NONE);
m_panel_can->SetMinSize(AMS_CANS_SIZE);
m_panel_can->SetCornerRadius(FromDIP(10));
m_panel_can->SetBackgroundColor(AMS_CONTROL_DEF_BLOCK_BK_COLOUR);
@ -1389,7 +1387,7 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
wxBoxSizer *m_sizer_left_bottom = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *sizer_sextruder = new wxBoxSizer(wxVERTICAL);
auto extruder_pane = new wxPanel(amswin, wxID_ANY, wxDefaultPosition, AMS_EXTRUDER_SIZE);
auto extruder_pane = new wxPanel(m_amswin, wxID_ANY, wxDefaultPosition, AMS_EXTRUDER_SIZE);
extruder_pane->SetSizer(sizer_sextruder);
extruder_pane->Layout();
@ -1413,14 +1411,13 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
StateColor btn_bd_white(std::pair<wxColour, int>(AMS_CONTROL_WHITE_COLOUR, StateColor::Disabled), std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Enabled));
StateColor btn_text_green(std::pair<wxColour, int>(*wxBLACK, StateColor::Disabled), std::pair<wxColour, int>(AMS_CONTROL_WHITE_COLOUR, StateColor::Enabled));
m_sizer_left_bottom->AddStretchSpacer();
m_button_extruder_feed = new Button(amswin, _L("Load Filament"));
m_button_extruder_feed = new Button(m_amswin, _L("Load Filament"));
m_button_extruder_feed->SetBackgroundColor(btn_bg_green);
m_button_extruder_feed->SetBorderColor(btn_bd_green);
m_button_extruder_feed->SetTextColor(btn_text_green);
m_button_extruder_feed->SetFont(Label::Body_13);
m_button_extruder_back = new Button(amswin, _L("Unload Filament"));
m_button_extruder_back = new Button(m_amswin, _L("Unload Filament"));
m_button_extruder_back->SetBackgroundColor(btn_bg_white);
m_button_extruder_back->SetBorderColor(btn_bd_white);
m_button_extruder_back->SetFont(Label::Body_13);
@ -1434,7 +1431,7 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
m_sizer_bottom->Add(0, 0, 0, wxEXPAND | wxLEFT, FromDIP(43));
wxBoxSizer *m_sizer_right = new wxBoxSizer(wxVERTICAL);
m_simplebook_right = new wxSimplebook(amswin, wxID_ANY);
m_simplebook_right = new wxSimplebook(m_amswin, wxID_ANY);
m_simplebook_right->SetMinSize(AMS_STEP_SIZE);
m_simplebook_right->SetSize(AMS_STEP_SIZE);
m_simplebook_right->SetBackgroundColour(*wxWHITE);
@ -1447,7 +1444,7 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
m_tip_right_top->SetForegroundColour(AMS_CONTROL_BRAND_COLOUR);
m_tip_right_top->Wrap(AMS_STEP_SIZE.x);
m_sizer_right_tip->Add(m_tip_right_top, 0, 0, 0);
m_sizer_right_tip->Add(0, 0, 0, wxTOP, 10);
m_sizer_right_tip->Add(0, 0, 0, wxTOP, FromDIP(10));
m_tip_load_info = new wxStaticText(tip_right, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
m_tip_load_info->SetFont(::Label::Body_13);
m_tip_load_info->SetForegroundColour(AMS_CONTROL_GRAY700);
@ -1470,31 +1467,34 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
m_simplebook_right->AddPage(m_filament_unload_step, wxEmptyString, false);
wxBoxSizer *m_sizer_right_bottom = new wxBoxSizer(wxHORIZONTAL);
m_sizer_right_bottom->Add(0, 0, 1, wxEXPAND, 5);
m_button_ams_setting = new Button(amswin, _L("AMS Settings"));
m_sizer_right_bottom->Add(0, 0, 1, wxEXPAND, FromDIP(5));
m_button_ams_setting = new Button(m_amswin, _L("AMS Settings"));
m_button_ams_setting->SetBackgroundColor(btn_bg_white);
m_button_ams_setting->SetBorderColor(btn_bd_white);
m_button_ams_setting->SetFont(Label::Body_13);
m_button_ams_setting->Hide();
m_sizer_right_bottom->Add(m_button_ams_setting, 0, wxTOP, 20);
m_sizer_right->Add(m_sizer_right_bottom, 0, wxEXPAND, 5);
m_sizer_bottom->Add(m_sizer_right, 0, wxEXPAND, 5);
m_sizer_body->Add(m_sizer_bottom, 0, wxEXPAND | wxLEFT, 11);
//m_button_ams_setting->Hide();
m_sizer_right_bottom->Add(m_button_ams_setting, 0, wxTOP, FromDIP(20));
m_sizer_right->Add(m_sizer_right_bottom, 0, wxEXPAND, FromDIP(5));
m_sizer_bottom->Add(m_sizer_right, 0, wxEXPAND, FromDIP(5));
m_sizer_body->Add(m_simplebook_amsitems, 0, wxEXPAND, 0);
m_sizer_body->Add(0, 0, 1, wxEXPAND | wxTOP, FromDIP(18));
m_sizer_body->Add(m_sizer_bottom, 0, wxEXPAND | wxLEFT, FromDIP(11));
init_scaled_buttons();
amswin->SetSizer(m_sizer_body);
amswin->Layout();
amswin->Fit();
m_amswin->SetSizer(m_sizer_body);
m_amswin->Layout();
m_amswin->Fit();
//Thaw();
SetSize(amswin->GetSize());
SetMinSize(amswin->GetSize());
SetSize(m_amswin->GetSize());
SetMinSize(m_amswin->GetSize());
// calibration mode
m_simplebook_calibration = new wxSimplebook(this, wxID_ANY, wxDefaultPosition, amswin->GetSize(), wxTAB_TRAVERSAL);
m_simplebook_calibration = new wxSimplebook(this, wxID_ANY, wxDefaultPosition, m_amswin->GetSize(), wxTAB_TRAVERSAL);
auto m_in_calibration_panel = new wxWindow(m_simplebook_calibration, wxID_ANY, wxDefaultPosition, amswin->GetSize(), wxTAB_TRAVERSAL);
auto m_in_calibration_panel = new wxWindow(m_simplebook_calibration, wxID_ANY, wxDefaultPosition, m_amswin->GetSize(), wxTAB_TRAVERSAL);
m_in_calibration_panel->SetBackgroundColour(AMS_CONTROL_WHITE_COLOUR);
wxBoxSizer *sizer_calibration_h = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *sizer_calibration_v = new wxBoxSizer(wxVERTICAL);
@ -1506,15 +1506,15 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
m_text_calibration_tip->SetFont(::Label::Body_14);
m_text_calibration_tip->SetForegroundColour(AMS_CONTROL_GRAY700);
sizer_calibration_v->Add(thumbnail, 0, wxALIGN_CENTER, 0);
sizer_calibration_v->Add(0, 0, 0, wxTOP, 16);
sizer_calibration_v->Add(0, 0, 0, wxTOP, FromDIP(16));
sizer_calibration_v->Add(m_text_calibration_percent, 0, wxALIGN_CENTER, 0);
sizer_calibration_v->Add(0, 0, 0, wxTOP, 8);
sizer_calibration_v->Add(0, 0, 0, wxTOP, FromDIP(8));
sizer_calibration_v->Add(m_text_calibration_tip, 0, wxALIGN_CENTER, 0);
sizer_calibration_h->Add(sizer_calibration_v, 1, wxALIGN_CENTER, 0);
m_in_calibration_panel->SetSizer(sizer_calibration_h);
m_in_calibration_panel->Layout();
auto m_calibration_err_panel = new wxWindow(m_simplebook_calibration, wxID_ANY, wxDefaultPosition, amswin->GetSize(), wxTAB_TRAVERSAL);
auto m_calibration_err_panel = new wxWindow(m_simplebook_calibration, wxID_ANY, wxDefaultPosition, m_amswin->GetSize(), wxTAB_TRAVERSAL);
m_calibration_err_panel->SetBackgroundColour(AMS_CONTROL_WHITE_COLOUR);
wxBoxSizer *sizer_err_calibration_h = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *sizer_err_calibration_v = new wxBoxSizer(wxVERTICAL);
@ -1547,10 +1547,10 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
sizer_button->Add(m_button_calibration_cancel, 0, wxALL, 5);
sizer_err_calibration_v->Add(m_hyperlink, 0, wxALIGN_CENTER, 0);
sizer_err_calibration_v->Add(0, 0, 0, wxTOP, 6);
sizer_err_calibration_v->Add(0, 0, 0, wxTOP, FromDIP(6));
sizer_err_calibration_v->Add(m_tip_calibration_err, 0, wxALIGN_CENTER, 0);
sizer_err_calibration_v->Add(0, 0, 0, wxTOP, 8);
sizer_err_calibration_v->Add(sizer_button, 0, wxALIGN_CENTER | wxTOP, 18);
sizer_err_calibration_v->Add(0, 0, 0, wxTOP, FromDIP(8));
sizer_err_calibration_v->Add(sizer_button, 0, wxALIGN_CENTER | wxTOP, FromDIP(18));
sizer_err_calibration_h->Add(sizer_err_calibration_v, 1, wxALIGN_CENTER, 0);
m_calibration_err_panel->SetSizer(sizer_err_calibration_h);
m_calibration_err_panel->Layout();
@ -1558,7 +1558,7 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
m_simplebook_calibration->AddPage(m_in_calibration_panel, wxEmptyString, false);
m_simplebook_calibration->AddPage(m_calibration_err_panel, wxEmptyString, false);
AddPage(amswin, wxEmptyString, false);
AddPage(m_amswin, wxEmptyString, false);
AddPage(m_simplebook_calibration, wxEmptyString, false);
UpdateStepCtrl();
@ -1747,7 +1747,20 @@ void AMSControl::CreateAms()
void AMSControl::Reset()
{
m_current_ams = "";
auto caninfo0_0 = Caninfo{"def_can_0", L(""), *wxWHITE, AMSCanType::AMS_CAN_TYPE_NONE};
auto caninfo0_1 = Caninfo{"def_can_1", L(""), *wxWHITE, AMSCanType::AMS_CAN_TYPE_NONE};
auto caninfo0_2 = Caninfo{"def_can_2", L(""), *wxWHITE, AMSCanType::AMS_CAN_TYPE_NONE};
auto caninfo0_3 = Caninfo{"def_can_3", L(""), *wxWHITE, AMSCanType::AMS_CAN_TYPE_NONE};
AMSinfo ams1 = AMSinfo{"def_ams_0", std::vector<Caninfo>{caninfo0_0, caninfo0_1, caninfo0_2, caninfo0_3}};
AMSinfo ams2 = AMSinfo{"def_ams_1", std::vector<Caninfo>{caninfo0_0, caninfo0_1, caninfo0_2, caninfo0_3}};
AMSinfo ams3 = AMSinfo{"def_ams_2", std::vector<Caninfo>{caninfo0_0, caninfo0_1, caninfo0_2, caninfo0_3}};
AMSinfo ams4 = AMSinfo{"def_ams_3", std::vector<Caninfo>{caninfo0_0, caninfo0_1, caninfo0_2, caninfo0_3}};
std::vector<AMSinfo> ams_info{ams1, ams2, ams3, ams4};
std::vector<AMSinfo>::iterator it;
UpdateAms(ams_info, false);
m_current_ams = "";
m_current_senect = "";
}
@ -1760,6 +1773,21 @@ void AMSControl::UpdateAms(std::vector<AMSinfo> info, bool keep_selection)
// update item
m_ams_info = info;
if (info.size() > 1) {
m_simplebook_amsitems->Show();
m_amswin->Layout();
m_amswin->Fit();
SetSize(m_amswin->GetSize());
SetMinSize(m_amswin->GetSize());
} else {
m_simplebook_amsitems->Hide();
m_amswin->Layout();
m_amswin->Fit();
SetSize(m_amswin->GetSize());
SetMinSize(m_amswin->GetSize());
}
for (auto i = 0; i < m_ams_item_list.GetCount(); i++) {
AmsItems *item = m_ams_item_list[i];
if (i < info.size() && info.size() > 1) {

View file

@ -449,6 +449,7 @@ protected:
wxStaticText *m_text_calibration_percent = {nullptr};
wxWindow * m_none_ams_panel = {nullptr};
wxWindow * m_panel_top = {nullptr};
wxWindow * m_amswin = {nullptr};
StaticBox * m_panel_can = {nullptr};
wxBoxSizer *m_sizer_top = {nullptr};

View file

@ -122,6 +122,8 @@ bool Button::Enable(bool enable)
return result;
}
void Button::SetCanFocus(bool canFocus) { this->canFocus = canFocus; }
void Button::Rescale()
{
if (this->active_icon.bmp().IsOk())
@ -230,7 +232,8 @@ void Button::mouseDown(wxMouseEvent& event)
{
event.Skip();
pressedDown = true;
SetFocus();
if (canFocus)
SetFocus();
CaptureMouse();
}
@ -286,3 +289,5 @@ WXLRESULT Button::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
}
#endif
bool Button::AcceptsFocus() const { return canFocus; }

View file

@ -15,7 +15,8 @@ class Button : public StaticBox
StateColor text_color;
bool pressedDown = false;
bool m_selected = true;
bool m_selected = true;
bool canFocus = true;
static const int buttonWidth = 200;
static const int buttonHeight = 50;
@ -43,7 +44,9 @@ public:
void SetSelected(bool selected = true) { m_selected = selected; }
bool Enable(bool enable = true);
bool Enable(bool enable = true) override;
void SetCanFocus(bool canFocus) override;
void Rescale();
@ -52,6 +55,8 @@ protected:
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) override;
#endif
bool AcceptsFocus() const override;
private:
void paintEvent(wxPaintEvent& evt);

View file

@ -1,17 +1,17 @@
#include "wxStaticText2.hpp"
#include "ErrorMsgStaticText.hpp"
wxStaticText2::wxStaticText2() {}
ErrorMsgStaticText::ErrorMsgStaticText() {}
wxStaticText2::wxStaticText2(wxWindow * parent,
ErrorMsgStaticText::ErrorMsgStaticText(wxWindow * parent,
wxWindowID id,
const wxPoint & pos,
const wxSize & size)
{
Create(parent, id, pos, size);
Bind(wxEVT_PAINT, &wxStaticText2::paintEvent, this);
Bind(wxEVT_PAINT, &ErrorMsgStaticText::paintEvent, this);
}
void wxStaticText2::paintEvent(wxPaintEvent &evt)
void ErrorMsgStaticText::paintEvent(wxPaintEvent &evt)
{
auto size = GetSize();
wxPaintDC dc(this);

View file

@ -1,18 +1,18 @@
#ifndef _WX_STATTEXT2_H_
#define _WX_STATTEXT2_H_
#ifndef _WX_ERRORMSGSTATTEXT_H_
#define _WX_ERRORMSGSTATTEXT_H_
#include "wx/stattext.h"
class WXDLLIMPEXP_CORE wxStaticText2 : public wxPanel
class WXDLLIMPEXP_CORE ErrorMsgStaticText : public wxPanel
{
public:
wxString m_msg;
wxStaticText2();
wxStaticText2(wxWindow *parent,
ErrorMsgStaticText();
ErrorMsgStaticText(wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxSize(200,200));
const wxSize& size = wxSize(0,0));
void paintEvent(wxPaintEvent &evt);

View file

@ -34,6 +34,7 @@ wxFont Label::Body_15 = Label::sysFont(15, false);
wxFont Label::Body_14 = Label::sysFont(14, false);
wxFont Label::Body_13 = Label::sysFont(13, false);
wxFont Label::Body_12 = Label::sysFont(12, false);
wxFont Label::Body_11 = Label::sysFont(11, false);
wxFont Label::Body_10 = Label::sysFont(10, false);
wxFont Label::Body_9 = Label::sysFont(9, false);

View file

@ -27,6 +27,7 @@ public:
static wxFont Body_13;
static wxFont Body_12;
static wxFont Body_10;
static wxFont Body_11;
static wxFont Body_9;
static wxFont sysFont(int size, bool bold = false);

View file

@ -55,7 +55,7 @@ void TextInput::Create(wxWindow * parent,
style &= ~wxRIGHT;
state_handler.attach({&label_color, & text_color});
state_handler.update_binds();
text_ctrl = new wxTextCtrl(this, wxID_ANY, text, {4, 4}, wxDefaultSize, style | wxBORDER_NONE);
text_ctrl = new wxTextCtrl(this, wxID_ANY, text, {4, 4}, wxDefaultSize, style | wxBORDER_NONE | wxTE_PROCESS_ENTER);
text_ctrl->SetFont(Label::Body_14);
text_ctrl->SetInitialSize(text_ctrl->GetBestSize());
text_ctrl->SetBackgroundColour(background_color.colorForStates(state_handler.states()));

View file

@ -172,6 +172,16 @@ WipingDialog::WipingDialog(wxWindow* parent, const std::vector<float>& matrix, c
this->FindWindowById(wxID_RESET, this)->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { m_panel_wiping->calc_flushing_volumes(); });
}
this->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& e) { EndModal(wxCANCEL); });
this->Bind(wxEVT_CHAR_HOOK, [this](wxKeyEvent& e) {
if (e.GetKeyCode() == WXK_ESCAPE) {
if (this->IsModal())
this->EndModal(wxID_CANCEL);
else
this->Close();
}
else
e.Skip();
});
}
void WipingPanel::create_panels(wxWindow* parent, const int num) {

View file

@ -36,7 +36,7 @@ namespace BBL {
#define BAMBU_NETWORK_LIBRARY "bambu_networking"
#define BAMBU_NETWORK_AGENT_NAME "bambu_network_agent"
#define BAMBU_NETWORK_AGENT_VERSION "01.01.01.02"
#define BAMBU_NETWORK_AGENT_VERSION "01.02.00.01"
//iot preset type strings
@ -113,6 +113,7 @@ struct PrintParams {
std::string ftp_file_md5;
std::string ams_mapping;
std::string connection_type;
std::string comments;
/* access options */
std::string dev_ip;
@ -125,6 +126,7 @@ struct PrintParams {
bool task_vibration_cali; /* vibration calibration of task */
bool task_layer_inspect; /* first layer inspection of task */
bool task_record_timelapse; /* record timelapse of task */
bool task_use_ams;
};
}