mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-10 08:17:51 -06:00
Menu_bar and preset_tabs are in main window now
This commit is contained in:
parent
e86f149cbd
commit
8b582bbcd1
12 changed files with 489 additions and 219 deletions
|
@ -18,17 +18,20 @@
|
|||
|
||||
#include <fstream>
|
||||
#include <boost/geometry/strategies/spherical/compare_circular.hpp>
|
||||
#include "GUI_App.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI
|
||||
{
|
||||
namespace GUI {
|
||||
|
||||
static wxString dots("…", wxConvUTF8);
|
||||
|
||||
MainFrame::MainFrame(const bool no_plater, const bool loaded) :
|
||||
wxFrame(NULL, wxID_ANY, "FORK_NAME-VERSION", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE),
|
||||
m_no_plater(no_plater),
|
||||
m_loaded(loaded)
|
||||
{
|
||||
// Slic3r::GUI::set_main_frame(this);
|
||||
// m_appController = new Slic3r::AppController();
|
||||
m_appController = new Slic3r::AppController();
|
||||
|
||||
// #if _WIN32
|
||||
// // Load the icon either from the exe, or from the ico file.
|
||||
|
@ -36,73 +39,68 @@ wxFrame(NULL, wxID_ANY, "FORK_NAME-VERSION", wxDefaultPosition, wxDefaultSize, w
|
|||
// auto iconfile = Slic3r::var("Slic3r.ico");// unless - f iconfile;
|
||||
// SetIcon(wxIcon(iconfile, wxBITMAP_TYPE_ICO));
|
||||
// #else
|
||||
// SetIcon(wxIcon(Slic3r::var("Slic3r_128px.png"), wxBITMAP_TYPE_PNG));
|
||||
SetIcon(wxIcon("c:\\src\\Slic3r_TMP\\resources\\icons\\Slic3r_128px.png", wxBITMAP_TYPE_PNG));
|
||||
SetIcon(wxIcon(Slic3r::var("Slic3r_128px.png"), wxBITMAP_TYPE_PNG));
|
||||
// #ifdef // _WIN32
|
||||
|
||||
// initialize tabpanel and menubar
|
||||
// init_tabpanel();
|
||||
// init_menubar();
|
||||
init_tabpanel();
|
||||
init_menubar();
|
||||
|
||||
// set default tooltip timer in msec
|
||||
// SetAutoPop supposedly accepts long integers but some bug doesn't allow for larger values
|
||||
// (SetAutoPop is not available on GTK.)
|
||||
// wxToolTip::SetAutoPop(32767);
|
||||
wxToolTip::SetAutoPop(32767);
|
||||
|
||||
// initialize status bar
|
||||
// m_statusbar = new Slic3r::GUI::ProgressStatusBar(this);
|
||||
// m_statusbar->embed();
|
||||
// m_statusbar->set_status_text(L("Version ").Slic3r::VERSION.L(" - Remember to check for updates at http://github.com/prusa3d/slic3r/releases"));
|
||||
m_statusbar = new Slic3r::GUI::ProgressStatusBar(this);
|
||||
m_statusbar->embed(this);
|
||||
m_statusbar->set_status_text(_(L("Version ")) +
|
||||
"Slic3r_VERSION" + // Slic3r::VERSION +
|
||||
_(L(" - Remember to check for updates at http://github.com/prusa3d/slic3r/releases")));
|
||||
// Make the global status bar and its progress indicator available in C++
|
||||
// m_appController->set_global_progress_indicator(m_statusbar);
|
||||
m_appController->set_global_progress_indicator(m_statusbar);
|
||||
|
||||
// m_appController->set_model(m_plater->model);
|
||||
// m_appController->set_print(m_plater->print);
|
||||
//
|
||||
// m_plater->appController = m_appController;
|
||||
|
||||
// m_loaded = true;
|
||||
//
|
||||
// // initialize layout
|
||||
// auto sizer = new wxBoxSizer(wxVERTICAL);
|
||||
// if (m_tabpanel)
|
||||
// sizer->Add(m_tabpanel, 1, wxEXPAND);
|
||||
// sizer->SetSizeHints(this);
|
||||
// SetSizer(sizer);
|
||||
// Fit();
|
||||
// SetMinSize(wxSize(760, 490));
|
||||
// SetSize(GetMinSize());
|
||||
// // wxTheApp->restore_window_pos(this, "main_frame");
|
||||
// Show();
|
||||
// Layout();
|
||||
m_loaded = true;
|
||||
|
||||
// initialize layout
|
||||
auto sizer = new wxBoxSizer(wxVERTICAL);
|
||||
if (m_tabpanel)
|
||||
sizer->Add(m_tabpanel, 1, wxEXPAND);
|
||||
sizer->SetSizeHints(this);
|
||||
SetSizer(sizer);
|
||||
Fit();
|
||||
SetMinSize(wxSize(760, 490));
|
||||
SetSize(GetMinSize());
|
||||
wxGetApp().restore_window_pos(this, "main_frame");
|
||||
Show();
|
||||
Layout();
|
||||
|
||||
// declare events
|
||||
// Bind(wxEVT_CLOSE_WINDOW, [](wxEvent& event){
|
||||
// if (event.CanVeto() && !Slic3r::GUI::check_unsaved_changes) {
|
||||
// event.Veto();
|
||||
// return;
|
||||
// }
|
||||
// // save window size
|
||||
// wxTheApp->save_window_pos(this, "main_frame");
|
||||
// // Save the slic3r.ini.Usually the ini file is saved from "on idle" callback,
|
||||
// // but in rare cases it may not have been called yet.
|
||||
// wxTheApp->{app_config}->save();
|
||||
Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& event){
|
||||
if (event.CanVeto() && !wxGetApp().check_unsaved_changes()) {
|
||||
event.Veto();
|
||||
return;
|
||||
}
|
||||
// save window size
|
||||
wxGetApp().save_window_pos(this, "main_frame");
|
||||
// Save the slic3r.ini.Usually the ini file is saved from "on idle" callback,
|
||||
// but in rare cases it may not have been called yet.
|
||||
wxGetApp().app_config->save();
|
||||
// if (m_plater)
|
||||
// m_plater->print = undef;
|
||||
// _3DScene::remove_all_canvases();
|
||||
_3DScene::remove_all_canvases();
|
||||
// Slic3r::GUI::deregister_on_request_update_callback();
|
||||
// // propagate event
|
||||
// event.Skip();
|
||||
// });
|
||||
// propagate event
|
||||
event.Skip();
|
||||
});
|
||||
|
||||
// update_ui_from_settings();
|
||||
//
|
||||
// Slic3r::GUI::update_mode();
|
||||
wxMenu *menuHelp = new wxMenu;
|
||||
menuHelp->Append(wxID_ABOUT);
|
||||
wxMenuBar *menuBar = new wxMenuBar;
|
||||
menuBar->Append(menuHelp, "&Help");
|
||||
SetMenuBar(menuBar);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -110,18 +108,18 @@ wxFrame(NULL, wxID_ANY, "FORK_NAME-VERSION", wxDefaultPosition, wxDefaultSize, w
|
|||
void MainFrame::init_tabpanel()
|
||||
{
|
||||
m_tabpanel = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL);
|
||||
Slic3r::GUI::set_tab_panel(m_tabpanel);
|
||||
// Slic3r::GUI::set_tab_panel(m_tabpanel);
|
||||
|
||||
// m_tabpanel->Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, [m_tabpanel](wxEvent&){
|
||||
// auto panel = m_tabpanel->GetCurrentPage();
|
||||
// // panel->OnActivate(); if panel->can('OnActivate');
|
||||
//
|
||||
// std::vector<std::string> tab_names = { "print", "filament", "printer" };
|
||||
// for (auto& tab_name : tab_names) {
|
||||
// if (tab_name == panel->GetName())
|
||||
// Slic3r::GUI::get_preset_tab(tab_name.c_str())->OnActivate();
|
||||
// }
|
||||
// });
|
||||
m_tabpanel->Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, [this](wxEvent&){
|
||||
auto panel = m_tabpanel->GetCurrentPage();
|
||||
// panel->OnActivate(); if panel->can('OnActivate');
|
||||
|
||||
std::vector<std::string> tab_names = { "print", "filament", "printer" };
|
||||
for (auto& tab_name : tab_names) {
|
||||
if (tab_name == panel->GetName())
|
||||
m_options_tabs.at(tab_name)->OnActivate();
|
||||
}
|
||||
});
|
||||
|
||||
if (!m_no_plater) {
|
||||
// m_plater = new Slic3r::GUI::Plater(m_tabpanel,
|
||||
|
@ -221,10 +219,10 @@ void MainFrame::init_tabpanel()
|
|||
// });
|
||||
|
||||
|
||||
// Slic3r::GUI::create_preset_tabs(true, VALUE_CHANGE_EVENT, PRESETS_CHANGED_EVENT);
|
||||
create_preset_tabs();
|
||||
std::vector<std::string> tab_names = { "print", "filament", "sla_material", "printer" };
|
||||
// for (auto tab_name : tab_names)
|
||||
// m_options_tabs[tab_name] = Slic3r::GUI::get_preset_tab(tab_name.c_str()); //
|
||||
for (auto tab_name : tab_names)
|
||||
m_options_tabs[tab_name] = get_preset_tab(tab_name.c_str());
|
||||
|
||||
if (m_plater) {
|
||||
// m_plater->on_select_preset(sub{
|
||||
|
@ -232,7 +230,7 @@ void MainFrame::init_tabpanel()
|
|||
// $self->{options_tabs}{$group}->select_preset($name);
|
||||
// });
|
||||
// load initial config
|
||||
auto full_config = Slic3r::GUI::get_preset_bundle()->full_config();
|
||||
auto full_config = wxGetApp().preset_bundle->full_config();
|
||||
// m_plater->on_config_change(full_config);
|
||||
|
||||
// Show a correct number of filament fields.
|
||||
|
@ -246,51 +244,99 @@ void MainFrame::init_tabpanel()
|
|||
}
|
||||
}
|
||||
|
||||
Tab* MainFrame::get_preset_tab(const std::string& name)
|
||||
{
|
||||
Tab* tab = get_tab(name);
|
||||
if (tab) return tab;
|
||||
|
||||
for (size_t i = 0; i < m_tabpanel->GetPageCount(); ++i) {
|
||||
tab = dynamic_cast<Tab*>(m_tabpanel->GetPage(i));
|
||||
if (!tab)
|
||||
continue;
|
||||
if (tab->name() == name) {
|
||||
return tab;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void MainFrame::create_preset_tabs()
|
||||
{
|
||||
// update_label_colours_from_appconfig();
|
||||
add_created_tab(new TabPrint(m_tabpanel));
|
||||
add_created_tab(new TabFilament(m_tabpanel));
|
||||
add_created_tab(new TabSLAMaterial(m_tabpanel));
|
||||
add_created_tab(new TabPrinter(m_tabpanel));
|
||||
}
|
||||
|
||||
void MainFrame::add_created_tab(Tab* panel)
|
||||
{
|
||||
panel->create_preset_tab(wxGetApp().preset_bundle);
|
||||
|
||||
// Load the currently selected preset into the GUI, update the preset selection box.
|
||||
panel->load_current_preset();
|
||||
|
||||
const wxString& tab_name = panel->GetName();
|
||||
bool add_panel = true;
|
||||
|
||||
auto preset_tabs = get_preset_tabs();
|
||||
auto it = std::find_if(preset_tabs->begin(), preset_tabs->end(),
|
||||
[tab_name](PresetTab& tab){return tab.name == tab_name; });
|
||||
if (it != preset_tabs->end()) {
|
||||
it->panel = panel;
|
||||
add_panel = it->technology == wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology();
|
||||
}
|
||||
|
||||
if (add_panel)
|
||||
m_tabpanel->AddPage(panel, panel->title());
|
||||
}
|
||||
|
||||
void MainFrame::init_menubar()
|
||||
{
|
||||
// File menu
|
||||
auto fileMenu = new wxMenu();
|
||||
wxMenu* fileMenu = new wxMenu;
|
||||
{
|
||||
// wxTheApp->append_menu_item(fileMenu, L("Open STL/OBJ/AMF/3MF…\tCtrl+O"), L('Open a model'), [](wxCommandEvent&){
|
||||
wxGetApp().append_menu_item(fileMenu, wxID_ANY, _(L("Open STL/OBJ/AMF/3MF…\tCtrl+O")), _(L("Open a model")),
|
||||
"", [](wxCommandEvent&){
|
||||
// if (m_plater) m_plater->add();
|
||||
// }, undef, undef); //'brick_add.png');
|
||||
append_menu_item(fileMenu, wxID_ANY, _(L("&Load Config…\tCtrl+L")), _(L("Load exported configuration file")),
|
||||
}); //'brick_add.png');
|
||||
append_menu_item(fileMenu, wxID_ANY, _(L("&Load Config…\tCtrl+L")), _(L("Load exported configuration file")),
|
||||
[this](wxCommandEvent&){ load_config_file(); }, "plugin_add.png");
|
||||
append_menu_item(fileMenu, wxID_ANY, _(L("&Export Config…\tCtrl+E")), _(L("Export current configuration to file")),
|
||||
append_menu_item(fileMenu, wxID_ANY, _(L("&Export Config…\tCtrl+E")), _(L("Export current configuration to file")),
|
||||
[this](wxCommandEvent&){ export_config(); }, "plugin_go.png");
|
||||
append_menu_item(fileMenu, wxID_ANY, _(L("&Load Config Bundle…")), _(L("Load presets from a bundle")),
|
||||
append_menu_item(fileMenu, wxID_ANY, _(L("&Load Config Bundle…")), _(L("Load presets from a bundle")),
|
||||
[this](wxCommandEvent&){ load_configbundle(); }, "lorry_add.png");
|
||||
append_menu_item(fileMenu, wxID_ANY, _(L("&Export Config Bundle…")), _(L("Export all presets to file")),
|
||||
append_menu_item(fileMenu, wxID_ANY, _(L("&Export Config Bundle…")), _(L("Export all presets to file")),
|
||||
[this](wxCommandEvent&){ export_configbundle(); }, "lorry_go.png");
|
||||
fileMenu->AppendSeparator();
|
||||
wxMenuItem* repeat = nullptr;
|
||||
append_menu_item(fileMenu, wxID_ANY, _(L("Q&uick Slice…\tCtrl+U")), _(L("Slice a file into a G-code")),
|
||||
append_menu_item(fileMenu, wxID_ANY, _(L("Q&uick Slice…\tCtrl+U")), _(L("Slice a file into a G-code")),
|
||||
[this, repeat](wxCommandEvent&){
|
||||
wxTheApp->CallAfter([this, repeat](){
|
||||
quick_slice();
|
||||
repeat->Enable(is_last_input_file()/*defined $Slic3r::GUI::MainFrame::last_input_file*/);
|
||||
repeat->Enable(is_last_input_file());
|
||||
}); }, "cog_go.png");
|
||||
append_menu_item(fileMenu, wxID_ANY, _(L("Quick Slice and Save &As…\tCtrl+Alt+U")), _(L("Slice a file into a G-code, save as")),
|
||||
append_menu_item(fileMenu, wxID_ANY, _(L("Quick Slice and Save &As…\tCtrl+Alt+U")), _(L("Slice a file into a G-code, save as")),
|
||||
[this, repeat](wxCommandEvent&){
|
||||
wxTheApp->CallAfter([this, repeat](){
|
||||
quick_slice(/*save_as = > 1*/qsSaveAs);
|
||||
repeat->Enable(is_last_input_file()/*defined $Slic3r::GUI::MainFrame::last_input_file*/);
|
||||
quick_slice(qsSaveAs);
|
||||
repeat->Enable(is_last_input_file());
|
||||
}); }, "cog_go.png");
|
||||
repeat = append_menu_item(fileMenu, wxID_ANY, _(L("&Repeat Last Quick Slice\tCtrl+Shift+U")), _(L("Repeat last quick slice")),
|
||||
[this](wxCommandEvent&){
|
||||
wxTheApp->CallAfter([this](){
|
||||
quick_slice(/*reslice = > 1*/qsReslice);
|
||||
quick_slice(qsReslice);
|
||||
}); }, "cog_go.png");
|
||||
repeat->Enable(0);
|
||||
fileMenu->AppendSeparator();
|
||||
append_menu_item(fileMenu, wxID_ANY, _(L("Slice to SV&G…\tCtrl+G")), _(L("Slice file to a multi-layer SVG")),
|
||||
[this](wxCommandEvent&){ quick_slice(/*save_as = > 1, export_svg = > 1*/qsSaveAs | qsExportSVG); }, "shape_handles.png");
|
||||
append_menu_item(fileMenu, wxID_ANY, _(L("Slice to PNG…")), _(L("Slice file to a set of PNG files")),
|
||||
append_menu_item(fileMenu, wxID_ANY, _(L("Slice to SV&G…\tCtrl+G")), _(L("Slice file to a multi-layer SVG")),
|
||||
[this](wxCommandEvent&){ quick_slice(qsSaveAs | qsExportSVG); }, "shape_handles.png");
|
||||
append_menu_item(fileMenu, wxID_ANY, _(L("Slice to PNG…")), _(L("Slice file to a set of PNG files")),
|
||||
[this](wxCommandEvent&){ slice_to_png(); /*$self->quick_slice(save_as = > 0, export_png = > 1);*/ }, "shape_handles.png");
|
||||
m_menu_item_reslice_now = append_menu_item(fileMenu, wxID_ANY, _(L("(&Re)Slice Now\tCtrl+S")), _(L("Start new slicing process")),
|
||||
[this](wxCommandEvent&){ reslice_now(); }, "shape_handles.png");
|
||||
fileMenu->AppendSeparator();
|
||||
append_menu_item(fileMenu, wxID_ANY, _(L("Repair STL file…")), _(L("Automatically repair an STL file")),
|
||||
append_menu_item(fileMenu, wxID_ANY, _(L("Repair STL file…")), _(L("Automatically repair an STL file")),
|
||||
[this](wxCommandEvent&){ repair_stl(); }, "wrench.png");
|
||||
fileMenu->AppendSeparator();
|
||||
append_menu_item(fileMenu, wxID_EXIT, _(L("&Quit")), _(L("Quit Slic3r")),
|
||||
|
@ -372,7 +418,7 @@ void MainFrame::init_menubar()
|
|||
[this](wxCommandEvent&){ wxLaunchDefaultBrowser("http://manual.slic3r.org/"); });
|
||||
helpMenu->AppendSeparator();
|
||||
append_menu_item(helpMenu, wxID_ANY, _(L("System Info")), _(L("Show system information")),
|
||||
[this](wxCommandEvent&){ /*wxTheApp->system_info();*/ });
|
||||
[this](wxCommandEvent&){ wxGetApp().system_info(); });
|
||||
append_menu_item(helpMenu, wxID_ANY, _(L("Show &Configuration Folder")), _(L("Show user configuration folder (datadir)")),
|
||||
[this](wxCommandEvent&){ Slic3r::GUI::desktop_open_datadir_folder(); });
|
||||
append_menu_item(helpMenu, wxID_ANY, _(L("Report an Issue")), _(L("Report an issue on the Slic3r Prusa Edition")),
|
||||
|
@ -392,7 +438,7 @@ void MainFrame::init_menubar()
|
|||
menubar->Append(windowMenu, L("&Window"));
|
||||
if (m_viewMenu) menubar->Append(m_viewMenu, L("&View"));
|
||||
// Add additional menus from C++
|
||||
// Slic3r::GUI::add_menus(menubar, preferences_event, lang_ch_event);
|
||||
wxGetApp().add_config_menu(menubar);
|
||||
menubar->Append(helpMenu, L("&Help"));
|
||||
SetMenuBar(menubar);
|
||||
}
|
||||
|
@ -414,22 +460,19 @@ void MainFrame::slice_to_png(){
|
|||
}
|
||||
|
||||
// To perform the "Quck Slice", "Quick Slice and Save As", "Repeat last Quick Slice" and "Slice to SVG".
|
||||
void MainFrame::quick_slice(const /*QuickSlice*/int qs/* = qsUndef const bool reslice,
|
||||
const bool export_svg,
|
||||
const bool export_png,
|
||||
const bool save_as*/){
|
||||
void MainFrame::quick_slice(const int qs){
|
||||
// my $progress_dialog;
|
||||
wxString input_file;
|
||||
// eval
|
||||
// {
|
||||
// validate configuration
|
||||
auto config = get_preset_bundle()->full_config();
|
||||
auto config = wxGetApp().preset_bundle->full_config();
|
||||
config.validate();
|
||||
|
||||
// select input file
|
||||
if (/*!reslice*/(qs & qsReslice) == 0) {
|
||||
if (!(qs & qsReslice)) {
|
||||
auto dlg = new wxFileDialog(this, _(L("Choose a file to slice (STL/OBJ/AMF/3MF/PRUSA):")),
|
||||
get_app_config()->get_last_dir(), "",
|
||||
wxGetApp().app_config->get_last_dir(), "",
|
||||
MODEL_WILDCARD, wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
||||
if (dlg->ShowModal() != wxID_OK) {
|
||||
dlg->Destroy();
|
||||
|
@ -437,7 +480,7 @@ void MainFrame::quick_slice(const /*QuickSlice*/int qs/* = qsUndef const bool re
|
|||
}
|
||||
input_file = dlg->GetPath();
|
||||
dlg->Destroy();
|
||||
if (/*!export_svg*/(qs & qsExportSVG) == 0)
|
||||
if (!(qs & qsExportSVG))
|
||||
m_qs_last_input_file = input_file;
|
||||
}
|
||||
else {
|
||||
|
@ -456,7 +499,7 @@ void MainFrame::quick_slice(const /*QuickSlice*/int qs/* = qsUndef const bool re
|
|||
input_file = m_qs_last_input_file;
|
||||
}
|
||||
auto input_file_basename = get_base_name(input_file);
|
||||
get_app_config()->update_skein_dir(get_dir_name(input_file));
|
||||
wxGetApp().app_config->update_skein_dir(get_dir_name(input_file));
|
||||
|
||||
auto bed_shape = Slic3r::Polygon::new_scale(config.option<ConfigOptionPoints>("bed_shape")->values);
|
||||
// auto print_center = Slic3r::Pointf->new_unscale(bed_shape.bounding_box().center());
|
||||
|
@ -464,7 +507,7 @@ void MainFrame::quick_slice(const /*QuickSlice*/int qs/* = qsUndef const bool re
|
|||
// auto sprint = new Slic3r::Print::Simple(
|
||||
// print_center = > print_center,
|
||||
// status_cb = > [](int percent, const wxString& msg){
|
||||
// m_progress_dialog->Update(percent, msg+"…");
|
||||
// m_progress_dialog->Update(percent, msg+"…");
|
||||
// });
|
||||
|
||||
// keep model around
|
||||
|
@ -474,22 +517,22 @@ void MainFrame::quick_slice(const /*QuickSlice*/int qs/* = qsUndef const bool re
|
|||
// sprint->set_model(model);
|
||||
|
||||
// Copy the names of active presets into the placeholder parser.
|
||||
// get_preset_bundle()->export_selections(sprint->placeholder_parser);
|
||||
// wxGetApp().preset_bundle->export_selections(sprint->placeholder_parser);
|
||||
|
||||
// select output file
|
||||
wxString output_file;
|
||||
if (/*reslice*/(qs & qsReslice)/* != 0*/) {
|
||||
if (qs & qsReslice) {
|
||||
if (!m_qs_last_output_file.IsEmpty())
|
||||
output_file = m_qs_last_output_file;
|
||||
}
|
||||
else if (/*save_as*/(qs & qsSaveAs)/* != 0*/) {
|
||||
else if (qs & qsSaveAs) {
|
||||
// The following line may die if the output_filename_format template substitution fails.
|
||||
// output_file = sprint->output_filepath;
|
||||
// if (export_svg)
|
||||
// output_file = ~s / \.[gG][cC][oO][dD][eE]$ / .svg /;
|
||||
auto dlg = new wxFileDialog(this, _(L("Save ")) + (qs & qsExportSVG/*export_svg*/ ? _(L("SVG")) : _(L("G-code"))) + _(L(" file as:")),
|
||||
get_app_config()->get_last_output_dir(get_dir_name(output_file)), get_base_name(input_file),
|
||||
qs & qsExportSVG/*export_svg*/ ? FILE_WILDCARDS.at("svg") : FILE_WILDCARDS.at("gcode"),
|
||||
auto dlg = new wxFileDialog(this, _(L("Save ")) + (qs & qsExportSVG ? _(L("SVG")) : _(L("G-code"))) + _(L(" file as:")),
|
||||
wxGetApp().app_config->get_last_output_dir(get_dir_name(output_file)), get_base_name(input_file),
|
||||
qs & qsExportSVG ? FILE_WILDCARDS.at("svg") : FILE_WILDCARDS.at("gcode"),
|
||||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||
if (dlg->ShowModal() != wxID_OK) {
|
||||
dlg->Destroy();
|
||||
|
@ -497,15 +540,15 @@ void MainFrame::quick_slice(const /*QuickSlice*/int qs/* = qsUndef const bool re
|
|||
}
|
||||
output_file = dlg->GetPath();
|
||||
dlg->Destroy();
|
||||
if (/*!export_svg*/!(qs & qsExportSVG))
|
||||
if (!(qs & qsExportSVG))
|
||||
m_qs_last_output_file = output_file;
|
||||
get_app_config()->update_last_output_dir(get_dir_name(output_file));
|
||||
wxGetApp().app_config->update_last_output_dir(get_dir_name(output_file));
|
||||
}
|
||||
else if (/*export_png*/qs & qsExportPNG) {
|
||||
else if (qs & qsExportPNG) {
|
||||
// output_file = sprint->output_filepath;
|
||||
// output_file = ~s / \.[gG][cC][oO][dD][eE]$ / .zip / ;
|
||||
auto dlg = new wxFileDialog(this, _(L("Save zip file as:")),
|
||||
get_app_config()->get_last_output_dir(get_dir_name(output_file)),
|
||||
wxGetApp().app_config->get_last_output_dir(get_dir_name(output_file)),
|
||||
get_base_name(output_file), "*.zip", wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||
if (dlg->ShowModal() != wxID_OK) {
|
||||
dlg->Destroy();
|
||||
|
@ -516,7 +559,7 @@ void MainFrame::quick_slice(const /*QuickSlice*/int qs/* = qsUndef const bool re
|
|||
}
|
||||
|
||||
// show processbar dialog
|
||||
m_progress_dialog = new wxProgressDialog(_(L("Slicing…")), _(L("Processing ")) + input_file_basename + "…",
|
||||
m_progress_dialog = new wxProgressDialog(_(L("Slicing…")), _(L("Processing ")) + input_file_basename + "…",
|
||||
100, this, 4);
|
||||
m_progress_dialog->Pulse();
|
||||
{
|
||||
|
@ -556,7 +599,7 @@ void MainFrame::repair_stl()
|
|||
wxString input_file;
|
||||
{
|
||||
auto dlg = new wxFileDialog(this, _(L("Select the STL file to repair:")),
|
||||
get_app_config()->get_last_dir(), "",
|
||||
wxGetApp().app_config->get_last_dir(), "",
|
||||
FILE_WILDCARDS.at("stl"), wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
||||
if (dlg->ShowModal() != wxID_OK) {
|
||||
dlg->Destroy();
|
||||
|
@ -590,7 +633,7 @@ void MainFrame::repair_stl()
|
|||
void MainFrame::export_config()
|
||||
{
|
||||
// Generate a cummulative configuration for the selected print, filaments and printer.
|
||||
auto config = get_preset_bundle()->full_config();
|
||||
auto config = wxGetApp().preset_bundle->full_config();
|
||||
// Validate the cummulative configuration.
|
||||
auto valid = config.validate();
|
||||
if (!valid.empty()) {
|
||||
|
@ -599,13 +642,13 @@ void MainFrame::export_config()
|
|||
}
|
||||
// Ask user for the file name for the config file.
|
||||
auto dlg = new wxFileDialog(this, _(L("Save configuration as:")),
|
||||
!m_last_config.IsEmpty() ? get_dir_name(m_last_config) : get_app_config()->get_last_dir(),
|
||||
!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.at("ini"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||
wxString file = dlg->ShowModal() == wxID_OK ? dlg->GetPath() : wxEmptyString;
|
||||
dlg->Destroy();
|
||||
if (!file.IsEmpty()) {
|
||||
get_app_config()->update_config_dir(get_dir_name(file));
|
||||
wxGetApp().app_config->update_config_dir(get_dir_name(file));
|
||||
m_last_config = file;
|
||||
config.save(file.ToStdString());
|
||||
}
|
||||
|
@ -615,10 +658,10 @@ void MainFrame::export_config()
|
|||
void MainFrame::load_config_file(wxString file/* = wxEmptyString*/)
|
||||
{
|
||||
if (file.IsEmpty()) {
|
||||
if (!Slic3r::GUI::check_unsaved_changes())
|
||||
if (!wxGetApp().check_unsaved_changes())
|
||||
return;
|
||||
auto dlg = new wxFileDialog(this, _(L("Select configuration to load:")),
|
||||
!m_last_config.IsEmpty() ? get_dir_name(m_last_config) : get_app_config()->get_last_dir(),
|
||||
!m_last_config.IsEmpty() ? get_dir_name(m_last_config) : wxGetApp().app_config->get_last_dir(),
|
||||
"config.ini", "INI files (*.ini, *.gcode)|*.ini;*.INI;*.gcode;*.g", wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
||||
if (dlg->ShowModal() != wxID_OK)
|
||||
return;
|
||||
|
@ -626,39 +669,39 @@ void MainFrame::load_config_file(wxString file/* = wxEmptyString*/)
|
|||
dlg->Destroy();
|
||||
}
|
||||
// eval{
|
||||
get_preset_bundle()->load_config_file(file.ToStdString());
|
||||
wxGetApp().preset_bundle->load_config_file(file.ToStdString());
|
||||
// };
|
||||
// Dont proceed further if the config file cannot be loaded.
|
||||
// if (Slic3r::GUI::catch_error(this))
|
||||
// return;
|
||||
for (auto tab : m_options_tabs )
|
||||
tab.second->load_current_preset();
|
||||
get_app_config()->update_config_dir(get_dir_name(file));
|
||||
wxGetApp().app_config->update_config_dir(get_dir_name(file));
|
||||
m_last_config = file;
|
||||
}
|
||||
|
||||
void MainFrame::export_configbundle()
|
||||
{
|
||||
if (!Slic3r::GUI::check_unsaved_changes())
|
||||
if (!wxGetApp().check_unsaved_changes())
|
||||
return;
|
||||
// validate current configuration in case it's dirty
|
||||
auto valid = get_preset_bundle()->full_config().validate();
|
||||
auto valid = wxGetApp().preset_bundle->full_config().validate();
|
||||
if (!valid.empty()) {
|
||||
// Slic3r::GUI::catch_error(this);
|
||||
return;
|
||||
}
|
||||
// Ask user for a file name.
|
||||
auto dlg = new wxFileDialog(this, _(L("Save presets bundle as:")),
|
||||
!m_last_config.IsEmpty() ? get_dir_name(m_last_config) : get_app_config()->get_last_dir(),
|
||||
!m_last_config.IsEmpty() ? get_dir_name(m_last_config) : wxGetApp().app_config->get_last_dir(),
|
||||
"Slic3r_config_bundle.ini",
|
||||
FILE_WILDCARDS.at("ini"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||
wxString file = dlg->ShowModal() == wxID_OK ? dlg->GetPath() : wxEmptyString;
|
||||
dlg->Destroy();
|
||||
if (!file.IsEmpty()) {
|
||||
// Export the config bundle.
|
||||
get_app_config()->update_config_dir(get_dir_name(file));
|
||||
wxGetApp().app_config->update_config_dir(get_dir_name(file));
|
||||
// eval{
|
||||
get_preset_bundle()->export_configbundle(file.ToStdString());
|
||||
wxGetApp().preset_bundle->export_configbundle(file.ToStdString());
|
||||
// };
|
||||
// Slic3r::GUI::catch_error(this);
|
||||
}
|
||||
|
@ -668,11 +711,11 @@ void MainFrame::export_configbundle()
|
|||
// to auto - install a config bundle on a fresh user account,
|
||||
// but that behavior was not documented and likely buggy.
|
||||
void MainFrame::load_configbundle(wxString file/* = wxEmptyString, const bool reset_user_profile*/){
|
||||
if (!Slic3r::GUI::check_unsaved_changes())
|
||||
if (!wxGetApp().check_unsaved_changes())
|
||||
return;
|
||||
if (file.IsEmpty()) {
|
||||
auto dlg = new wxFileDialog(this, _(L("Select configuration to load:")),
|
||||
!m_last_config.IsEmpty() ? get_dir_name(m_last_config) : get_app_config()->get_last_dir(),
|
||||
!m_last_config.IsEmpty() ? get_dir_name(m_last_config) : wxGetApp().app_config->get_last_dir(),
|
||||
"config.ini", FILE_WILDCARDS.at("ini"), wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
||||
if (dlg->ShowModal() != wxID_OK)
|
||||
return;
|
||||
|
@ -680,11 +723,11 @@ void MainFrame::load_configbundle(wxString file/* = wxEmptyString, const bool re
|
|||
dlg->Destroy();
|
||||
}
|
||||
|
||||
get_app_config()->update_config_dir(get_dir_name(file));
|
||||
wxGetApp().app_config->update_config_dir(get_dir_name(file));
|
||||
|
||||
auto presets_imported = 0;
|
||||
// eval{
|
||||
presets_imported = get_preset_bundle()->load_configbundle(file.ToStdString());
|
||||
presets_imported = wxGetApp().preset_bundle->load_configbundle(file.ToStdString());
|
||||
// };
|
||||
// Slic3r::GUI::catch_error(this) and return;
|
||||
|
||||
|
@ -734,7 +777,7 @@ wxMenuItem* MainFrame::append_menu_item(wxMenu* menu,
|
|||
// Update the UI based on the current preferences.
|
||||
void MainFrame::update_ui_from_settings()
|
||||
{
|
||||
// m_menu_item_reslice_now->Enable(get_app_config()->get("background_processing"));
|
||||
m_menu_item_reslice_now->Enable(wxGetApp().app_config->get("background_processing") == "1");
|
||||
// if (m_plater) m_plater->update_ui_from_settings();
|
||||
std::vector<std::string> tab_names = { "print", "filament", "printer" };
|
||||
for (auto tab_name: tab_names)
|
||||
|
@ -754,4 +797,4 @@ std::string MainFrame::get_dir_name(const wxString full_name) const
|
|||
|
||||
|
||||
} // GUI
|
||||
} //Slic3r
|
||||
} // Slic3r
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue