This commit is contained in:
SoftFever 2022-12-21 17:05:27 +08:00
parent dc1fcf7ed6
commit d9e9fb2206
13 changed files with 475 additions and 154 deletions

View file

@ -32,6 +32,9 @@ wxDEFINE_EVENT(EVT_GLTOOLBAR_PRINT_SELECT, SimpleEvent);
wxDEFINE_EVENT(EVT_GLTOOLBAR_SEND_TO_PRINTER, SimpleEvent);
wxDEFINE_EVENT(EVT_GLTOOLBAR_SEND_TO_PRINTER_ALL, SimpleEvent);
//SoftFever: goodie bag
wxDEFINE_EVENT(EVT_GLTOOLBAR_PA_CALIB, SimpleEvent);
wxDEFINE_EVENT(EVT_GLTOOLBAR_ADD, SimpleEvent);
wxDEFINE_EVENT(EVT_GLTOOLBAR_DELETE, SimpleEvent);
wxDEFINE_EVENT(EVT_GLTOOLBAR_DELETE_ALL, SimpleEvent);

View file

@ -32,6 +32,9 @@ wxDECLARE_EVENT(EVT_GLTOOLBAR_PRINT_SELECT, SimpleEvent);
wxDECLARE_EVENT(EVT_GLTOOLBAR_SEND_TO_PRINTER, SimpleEvent);
wxDECLARE_EVENT(EVT_GLTOOLBAR_SEND_TO_PRINTER_ALL, SimpleEvent);
//SoftFever: goodie bag event
wxDECLARE_EVENT(EVT_GLTOOLBAR_PA_CALIB, SimpleEvent);
wxDECLARE_EVENT(EVT_GLTOOLBAR_ADD, SimpleEvent);
wxDECLARE_EVENT(EVT_GLTOOLBAR_DELETE, SimpleEvent);
wxDECLARE_EVENT(EVT_GLTOOLBAR_DELETE_ALL, SimpleEvent);

View file

@ -728,7 +728,7 @@ static const FileWildcards file_wildcards_by_type[FT_SIZE] = {
/* FT_OBJ */ { "OBJ files"sv, { ".obj"sv } },
/* FT_AMF */ { "AMF files"sv, { ".amf"sv, ".zip.amf"sv, ".xml"sv } },
/* FT_3MF */ { "3MF files"sv, { ".3mf"sv } },
/* FT_GCODE */ { "G-code files"sv, { ".gcode"sv } },
/* FT_GCODE */ { "G-code files"sv, { ".gcode"sv, ".3mf"sv } },
/* FT_MODEL */ {"Supported files"sv, {".3mf"sv, ".stl"sv, ".stp"sv, ".step"sv, ".svg"sv, ".amf"sv, ".obj"sv }},
/* FT_PROJECT */ { "Project files"sv, { ".3mf"sv} },
/* FT_GALLERY */ { "Known files"sv, { ".stl"sv, ".obj"sv } },
@ -3235,7 +3235,7 @@ void GUI_App::load_gcode(wxWindow* parent, wxString& input_file) const
{
input_file.Clear();
wxFileDialog dialog(parent ? parent : GetTopWindow(),
_L("Choose one file (gcode/.gco/.g/.ngc/ngc):"),
_L("Choose one file (gcode/3mf):"),
app_config->get_last_dir(), "",
file_wildcards(FT_GCODE), wxFD_OPEN | wxFD_FILE_MUST_EXIST);

View file

@ -831,6 +831,7 @@ void MainFrame::show_option(bool show)
m_print_btn->Hide();
m_slice_option_btn->Hide();
m_print_option_btn->Hide();
m_goodie_bag_btn->Hide();
Layout();
}
} else {
@ -839,6 +840,7 @@ void MainFrame::show_option(bool show)
m_print_btn->Show();
m_slice_option_btn->Show();
m_print_option_btn->Show();
m_goodie_bag_btn->Show();
Layout();
}
}
@ -1354,12 +1356,18 @@ wxBoxSizer* MainFrame::create_side_tools()
m_slice_select = eSlicePlate;
m_print_select = ePrintPlate;
m_goodie_bag_btn = new SideButton(this, _L("Goodiebag"), "");
m_slice_btn = new SideButton(this, _L("Slice"), "");
m_slice_option_btn = new SideButton(this, "", "sidebutton_dropdown", 0, FromDIP(14));
m_print_btn = new SideButton(this, _L("Print"), "");
m_print_option_btn = new SideButton(this, "", "sidebutton_dropdown", 0, FromDIP(14));
update_side_button_style();
m_goodie_bag_btn->Enable();
m_print_option_btn->Enable();
sizer->Add(m_goodie_bag_btn, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, FromDIP(1));
sizer->Add(FromDIP(15), 0, 0, 0, 0);
m_slice_option_btn->Enable();
m_print_option_btn->Enable();
sizer->Add(m_slice_option_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, FromDIP(1));
@ -1371,6 +1379,33 @@ wxBoxSizer* MainFrame::create_side_tools()
sizer->Layout();
m_goodie_bag_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event)
{
SidePopup* p = new SidePopup(this);
SideButton* calib_pa_btn = new SideButton(p, _L("Calibrate PA"), "");
calib_pa_btn->SetCornerRadius(0);
//SideButton* send_file_btn = new SideButton(p, _L("send file"), "");
//send_file_btn->SetCornerRadius(0);
calib_pa_btn->Bind(wxEVT_BUTTON, [this, p](wxCommandEvent&) {
//this->m_plater->select_view_3D("Preview");
m_plater->update();
wxPostEvent(m_plater, SimpleEvent(EVT_GLTOOLBAR_PA_CALIB));
this->m_tabpanel->SetSelection(tpPreview);
});
//send_file_btn->Bind(wxEVT_BUTTON, [this, p](wxCommandEvent&) {
// //this->m_plater->select_view_3D("Preview");
// wxPostEvent(m_plater, SimpleEvent(EVT_GLTOOLBAR_SEND_GCODE_FILE));
// });
p->append_button(calib_pa_btn);
//p->append_button(send_file_btn);
p->Popup(m_goodie_bag_btn);
}
);
m_slice_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event)
{
//this->m_plater->select_view_3D("Preview");
@ -1556,6 +1591,7 @@ wxBoxSizer* MainFrame::create_side_tools()
p->append_button(send_to_printer_btn);
p->append_button(send_to_printer_all_btn);
p->append_button(export_sliced_file_btn);
//p->append_button(export_gcode_btn);
p->append_button(export_all_sliced_file_btn);
}
@ -1703,6 +1739,14 @@ void MainFrame::update_side_button_style()
// BBS
int em = em_unit();
m_goodie_bag_btn->SetLayoutStyle(1);
m_goodie_bag_btn->SetTextLayout(SideButton::EHorizontalOrientation::HO_Center, FromDIP(15));
m_goodie_bag_btn->SetMinSize(wxSize(-1, FromDIP(24)));
m_goodie_bag_btn->SetCornerRadius(FromDIP(12));
m_goodie_bag_btn->SetExtraSize(wxSize(FromDIP(38), FromDIP(10)));
m_goodie_bag_btn->SetBottomColour(wxColour(0x3B4446));
m_slice_btn->SetLayoutStyle(1);
/*m_slice_btn->SetLayoutStyle(1);
m_slice_btn->SetTextLayout(SideButton::EHorizontalOrientation::HO_Center, FromDIP(15));
m_slice_btn->SetMinSize(wxSize(-1, FromDIP(24)));
@ -1786,6 +1830,7 @@ void MainFrame::on_dpi_changed(const wxRect& suggested_rect)
update_side_button_style();
m_goodie_bag_btn->Rescale();
m_slice_btn->Rescale();
m_print_btn->Rescale();
m_slice_option_btn->Rescale();

View file

@ -355,6 +355,7 @@ public:
// BBS
mutable int m_print_select{ ePrintAll };
mutable int m_slice_select{ eSliceAll };
SideButton* m_goodie_bag_btn{ nullptr };
SideButton* m_slice_btn{ nullptr };
SideButton* m_slice_option_btn{ nullptr };
SideButton* m_print_btn{ nullptr };

View file

@ -2032,6 +2032,7 @@ struct Plater::priv
//BBS: GUI refactor: GLToolbar
void on_action_open_project(SimpleEvent&);
void on_action_slice_plate(SimpleEvent&);
void on_action_calib_pa(SimpleEvent&);
void on_action_slice_all(SimpleEvent&);
void on_action_publish(wxCommandEvent &evt);
void on_action_print_plate(SimpleEvent&);
@ -2441,6 +2442,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
q->Bind(EVT_GLVIEWTOOLBAR_PREVIEW, [q](SimpleEvent&) { q->select_view_3D("Preview", false); });
q->Bind(EVT_GLTOOLBAR_SLICE_PLATE, &priv::on_action_slice_plate, this);
q->Bind(EVT_GLTOOLBAR_SLICE_ALL, &priv::on_action_slice_all, this);
q->Bind(EVT_GLTOOLBAR_SLICE_ALL, &priv::on_action_calib_pa, this);
q->Bind(EVT_GLTOOLBAR_PRINT_PLATE, &priv::on_action_print_plate, this);
q->Bind(EVT_GLTOOLBAR_SELECT_SLICED_PLATE, &priv::on_action_select_sliced_plate, this);
q->Bind(EVT_GLTOOLBAR_PRINT_ALL, &priv::on_action_print_all, this);
@ -5994,6 +5996,25 @@ void Plater::priv::on_action_slice_plate(SimpleEvent&)
}
}
//BBS: GUI refactor: slice plate
void Plater::priv::on_action_calib_pa(SimpleEvent&)
{
if (q != nullptr) {
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ":received calib pa event\n" ;
if(fff_print.model().objects.empty())
//add model
q->add_model(false,Slic3r::resources_dir()+"/calib/sf_placeholder.stl");
fff_print.is_calib_mode() = true;
//BBS update extruder params and speed table before slicing
Plater::setExtruderParams(Slic3r::Model::extruderParamsMap);
Plater::setPrintSpeedTable(Slic3r::Model::printSpeedMap);
m_slice_all = false;
q->reslice();
q->select_view_3D("Preview");
}
}
//BBS: GUI refactor: slice all
void Plater::priv::on_action_slice_all(SimpleEvent&)
{
@ -7800,16 +7821,22 @@ bool Plater::up_to_date(bool saved, bool backup)
!Slic3r::has_other_changes(backup));
}
void Plater::add_model(bool imperial_units/* = false*/)
void Plater::add_model(bool imperial_units/* = false*/, std::string fname/* = ""*/)
{
wxArrayString input_files;
wxGetApp().import_model(this, input_files);
if (input_files.empty())
return;
std::vector<fs::path> paths;
for (const auto &file : input_files)
paths.emplace_back(into_path(file));
if(fname.empty()){
wxArrayString input_files;
wxGetApp().import_model(this, input_files);
if (input_files.empty())
return;
for (const auto &file : input_files)
paths.emplace_back(into_path(file));
}
else{
paths.emplace_back(fname);
}
std::string snapshot_label;
assert(! paths.empty());

View file

@ -217,7 +217,7 @@ public:
bool open_3mf_file(const fs::path &file_path);
int get_3mf_file_count(std::vector<fs::path> paths);
void add_file();
void add_model(bool imperial_units = false);
void add_model(bool imperial_units = false, std::string fname = "");
void import_sl1_archive();
void extract_config_from_project();
void load_gcode();