mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-10 08:17:51 -06:00
GCode viewer using the proper layout when started as a standalone application
This commit is contained in:
parent
8579184d70
commit
ab556a398b
16 changed files with 341 additions and 115 deletions
|
@ -92,7 +92,6 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
|
|||
}
|
||||
#endif // ENABLE_GCODE_VIEWER_TASKBAR_ICON
|
||||
|
||||
// SetIcon(wxIcon(Slic3r::var("PrusaSlicer_128px.png"), wxBITMAP_TYPE_PNG));
|
||||
// Load the icon either from the exe, or from the ico file.
|
||||
#if _WIN32
|
||||
{
|
||||
|
@ -102,7 +101,24 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
|
|||
SetIcon(wxIcon(szExeFileName, wxBITMAP_TYPE_ICO));
|
||||
}
|
||||
#else
|
||||
SetIcon(wxIcon(Slic3r::var("PrusaSlicer_128px.png"), wxBITMAP_TYPE_PNG));
|
||||
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
switch (wxGetApp().get_mode())
|
||||
{
|
||||
default:
|
||||
case GUI_App::EMode::Editor:
|
||||
{
|
||||
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
SetIcon(wxIcon(Slic3r::var("PrusaSlicer_128px.png"), wxBITMAP_TYPE_PNG));
|
||||
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
break;
|
||||
}
|
||||
case GUI_App::EMode::GCodeViewer:
|
||||
{
|
||||
SetIcon(wxIcon(Slic3r::var("PrusaSlicer-gcodeviewer_128px.png"), wxBITMAP_TYPE_PNG));
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
#endif // _WIN32
|
||||
|
||||
// initialize status bar
|
||||
|
@ -116,8 +132,15 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
|
|||
// initialize tabpanel and menubar
|
||||
init_tabpanel();
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
init_editor_menubar();
|
||||
init_gcodeviewer_menubar();
|
||||
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
if (wxGetApp().is_gcode_viewer())
|
||||
init_menubar_as_gcodeviewer();
|
||||
else
|
||||
init_menubar_as_editor();
|
||||
#else
|
||||
init_menubar_as_editor();
|
||||
init_menubar_as_gcodeviewer();
|
||||
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
|
||||
#if _WIN32
|
||||
// This is needed on Windows to fake the CTRL+# of the window menu when using the numpad
|
||||
|
@ -148,7 +171,10 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
|
|||
sizer->Add(m_main_sizer, 1, wxEXPAND);
|
||||
SetSizer(sizer);
|
||||
// initialize layout from config
|
||||
update_layout();
|
||||
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
if (wxGetApp().is_editor())
|
||||
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
update_layout();
|
||||
sizer->SetSizeHints(this);
|
||||
Fit();
|
||||
|
||||
|
@ -300,10 +326,17 @@ void MainFrame::update_layout()
|
|||
};
|
||||
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
ESettingsLayout layout = wxGetApp().is_gcode_viewer() ? ESettingsLayout::GCodeViewer :
|
||||
(wxGetApp().app_config->get("old_settings_layout_mode") == "1" ? ESettingsLayout::Old :
|
||||
wxGetApp().app_config->get("new_settings_layout_mode") == "1" ? ESettingsLayout::New :
|
||||
wxGetApp().app_config->get("dlg_settings_layout_mode") == "1" ? ESettingsLayout::Dlg : ESettingsLayout::Old);
|
||||
#else
|
||||
ESettingsLayout layout = (m_mode == EMode::GCodeViewer) ? ESettingsLayout::GCodeViewer :
|
||||
(wxGetApp().app_config->get("old_settings_layout_mode") == "1" ? ESettingsLayout::Old :
|
||||
wxGetApp().app_config->get("new_settings_layout_mode") == "1" ? ESettingsLayout::New :
|
||||
wxGetApp().app_config->get("dlg_settings_layout_mode") == "1" ? ESettingsLayout::Dlg : ESettingsLayout::Old);
|
||||
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
#else
|
||||
ESettingsLayout layout = wxGetApp().app_config->get("old_settings_layout_mode") == "1" ? ESettingsLayout::Old :
|
||||
wxGetApp().app_config->get("new_settings_layout_mode") == "1" ? ESettingsLayout::New :
|
||||
|
@ -375,6 +408,12 @@ void MainFrame::update_layout()
|
|||
case ESettingsLayout::GCodeViewer:
|
||||
{
|
||||
m_main_sizer->Add(m_plater, 1, wxEXPAND);
|
||||
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
m_plater->set_bed_shape({ { 0.0, 0.0 }, { 200.0, 0.0 }, { 200.0, 200.0 }, { 0.0, 200.0 } }, "", "", true);
|
||||
m_plater->enable_view_toolbar(false);
|
||||
m_plater->get_collapse_toolbar().set_enabled(false);
|
||||
m_plater->collapse_sidebar(true);
|
||||
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
m_plater->Show();
|
||||
break;
|
||||
}
|
||||
|
@ -482,6 +521,7 @@ void MainFrame::shutdown()
|
|||
|
||||
if (m_plater != nullptr) {
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
// restore sidebar if it was hidden when switching to gcode viewer mode
|
||||
if (m_restore_from_gcode_viewer.collapsed_sidebar)
|
||||
m_plater->collapse_sidebar(false);
|
||||
|
@ -489,6 +529,7 @@ void MainFrame::shutdown()
|
|||
// restore sla printer if it was deselected when switching to gcode viewer mode
|
||||
if (m_restore_from_gcode_viewer.sla_technology)
|
||||
m_plater->set_printer_technology(ptSLA);
|
||||
#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
// Stop the background thread (Windows and Linux).
|
||||
// Disconnect from a 3DConnextion driver (OSX).
|
||||
|
@ -590,7 +631,10 @@ void MainFrame::init_tabpanel()
|
|||
// or when the preset's "modified" status changes.
|
||||
Bind(EVT_TAB_PRESETS_CHANGED, &MainFrame::on_presets_changed, this); // #ys_FIXME_to_delete
|
||||
|
||||
create_preset_tabs();
|
||||
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
if (wxGetApp().is_editor())
|
||||
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
create_preset_tabs();
|
||||
|
||||
if (m_plater) {
|
||||
// load initial config
|
||||
|
@ -891,7 +935,7 @@ static void add_common_view_menu_items(wxMenu* view_menu, MainFrame* mainFrame,
|
|||
"", nullptr, [can_change_view]() { return can_change_view(); }, mainFrame);
|
||||
}
|
||||
|
||||
void MainFrame::init_editor_menubar()
|
||||
void MainFrame::init_menubar_as_editor()
|
||||
#else
|
||||
void MainFrame::init_menubar()
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
@ -1055,6 +1099,7 @@ void MainFrame::init_menubar()
|
|||
[this](wxCommandEvent&) { repair_stl(); }, "wrench", nullptr,
|
||||
[this]() { return true; }, this);
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
fileMenu->AppendSeparator();
|
||||
append_menu_item(fileMenu, wxID_ANY, _L("&G-code preview"), _L("Switch to G-code preview mode"),
|
||||
[this](wxCommandEvent&) {
|
||||
|
@ -1063,6 +1108,7 @@ void MainFrame::init_menubar()
|
|||
wxString(SLIC3R_APP_NAME) + " - " + _L("Switch to G-code preview mode"), wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION | wxCENTRE).ShowModal() == wxID_YES)
|
||||
set_mode(EMode::GCodeViewer);
|
||||
}, "", nullptr);
|
||||
#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
fileMenu->AppendSeparator();
|
||||
append_menu_item(fileMenu, wxID_EXIT, _L("&Quit"), wxString::Format(_L("Quit %s"), SLIC3R_APP_NAME),
|
||||
|
@ -1286,6 +1332,17 @@ void MainFrame::init_menubar()
|
|||
// assign menubar to frame after appending items, otherwise special items
|
||||
// will not be handled correctly
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
m_menubar = new wxMenuBar();
|
||||
m_menubar->Append(fileMenu, _L("&File"));
|
||||
if (editMenu) m_menubar->Append(editMenu, _L("&Edit"));
|
||||
m_menubar->Append(windowMenu, _L("&Window"));
|
||||
if (viewMenu) m_menubar->Append(viewMenu, _L("&View"));
|
||||
// Add additional menus from C++
|
||||
wxGetApp().add_config_menu(m_menubar);
|
||||
m_menubar->Append(helpMenu, _L("&Help"));
|
||||
SetMenuBar(m_menubar);
|
||||
#else
|
||||
m_editor_menubar = new wxMenuBar();
|
||||
m_editor_menubar->Append(fileMenu, _L("&File"));
|
||||
if (editMenu) m_editor_menubar->Append(editMenu, _L("&Edit"));
|
||||
|
@ -1295,6 +1352,7 @@ void MainFrame::init_menubar()
|
|||
wxGetApp().add_config_menu(m_editor_menubar);
|
||||
m_editor_menubar->Append(helpMenu, _L("&Help"));
|
||||
SetMenuBar(m_editor_menubar);
|
||||
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
#else
|
||||
auto menubar = new wxMenuBar();
|
||||
menubar->Append(fileMenu, _(L("&File")));
|
||||
|
@ -1323,15 +1381,11 @@ void MainFrame::init_menubar()
|
|||
#endif
|
||||
|
||||
if (plater()->printer_technology() == ptSLA)
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
update_editor_menubar();
|
||||
#else
|
||||
update_menubar();
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
}
|
||||
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
void MainFrame::init_gcodeviewer_menubar()
|
||||
void MainFrame::init_menubar_as_gcodeviewer()
|
||||
{
|
||||
wxMenu* fileMenu = new wxMenu;
|
||||
{
|
||||
|
@ -1342,9 +1396,11 @@ void MainFrame::init_gcodeviewer_menubar()
|
|||
append_menu_item(fileMenu, wxID_ANY, _L("Export &toolpaths as OBJ") + dots, _L("Export toolpaths as OBJ"),
|
||||
[this](wxCommandEvent&) { if (m_plater != nullptr) m_plater->export_toolpaths_to_obj(); }, "export_plater", nullptr,
|
||||
[this]() {return can_export_toolpaths(); }, this);
|
||||
#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
fileMenu->AppendSeparator();
|
||||
append_menu_item(fileMenu, wxID_ANY, _L("Exit &G-code preview"), _L("Switch to editor mode"),
|
||||
[this](wxCommandEvent&) { set_mode(EMode::Editor); });
|
||||
#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
fileMenu->AppendSeparator();
|
||||
append_menu_item(fileMenu, wxID_EXIT, _L("&Quit"), wxString::Format(_L("Quit %s"), SLIC3R_APP_NAME),
|
||||
[this](wxCommandEvent&) { Close(false); });
|
||||
|
@ -1360,13 +1416,22 @@ void MainFrame::init_gcodeviewer_menubar()
|
|||
// helpmenu
|
||||
auto helpMenu = generate_help_menu();
|
||||
|
||||
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
m_menubar = new wxMenuBar();
|
||||
m_menubar->Append(fileMenu, _L("&File"));
|
||||
if (viewMenu != nullptr) m_menubar->Append(viewMenu, _L("&View"));
|
||||
m_menubar->Append(helpMenu, _L("&Help"));
|
||||
SetMenuBar(m_menubar);
|
||||
#else
|
||||
m_gcodeviewer_menubar = new wxMenuBar();
|
||||
m_gcodeviewer_menubar->Append(fileMenu, _L("&File"));
|
||||
if ((viewMenu != nullptr))
|
||||
if (viewMenu != nullptr)
|
||||
m_gcodeviewer_menubar->Append(viewMenu, _L("&View"));
|
||||
m_gcodeviewer_menubar->Append(helpMenu, _L("&Help"));
|
||||
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
}
|
||||
|
||||
#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
void MainFrame::set_mode(EMode mode)
|
||||
{
|
||||
if (m_mode == mode)
|
||||
|
@ -1432,7 +1497,7 @@ void MainFrame::set_mode(EMode mode)
|
|||
TCHAR szExeFileName[MAX_PATH];
|
||||
GetModuleFileName(nullptr, szExeFileName, MAX_PATH);
|
||||
SetIcon(wxIcon(szExeFileName, wxBITMAP_TYPE_ICO));
|
||||
}
|
||||
}
|
||||
#else
|
||||
SetIcon(wxIcon(Slic3r::var("PrusaSlicer_128px.png"), wxBITMAP_TYPE_PNG));
|
||||
#endif // _WIN32
|
||||
|
@ -1488,11 +1553,11 @@ void MainFrame::set_mode(EMode mode)
|
|||
|
||||
m_plater->Thaw();
|
||||
|
||||
SetIcon(wxIcon(Slic3r::var("PrusaSlicerGCodeViewer_128px.png"), wxBITMAP_TYPE_PNG));
|
||||
SetIcon(wxIcon(Slic3r::var("PrusaSlicer-gcodeviewer_128px.png"), wxBITMAP_TYPE_PNG));
|
||||
#if ENABLE_GCODE_VIEWER_TASKBAR_ICON
|
||||
if (m_taskbar_icon != nullptr) {
|
||||
m_taskbar_icon->RemoveIcon();
|
||||
m_taskbar_icon->SetIcon(wxIcon(Slic3r::var("PrusaSlicerGCodeViewer_128px.png"), wxBITMAP_TYPE_PNG), "PrusaSlicer-GCode viewer");
|
||||
m_taskbar_icon->SetIcon(wxIcon(Slic3r::var("PrusaSlicer-gcodeviewer_128px.png"), wxBITMAP_TYPE_PNG), "PrusaSlicer-GCode viewer");
|
||||
}
|
||||
#endif // ENABLE_GCODE_VIEWER_TASKBAR_ICON
|
||||
|
||||
|
@ -1500,20 +1565,22 @@ void MainFrame::set_mode(EMode mode)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
void MainFrame::update_editor_menubar()
|
||||
#else
|
||||
void MainFrame::update_menubar()
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
{
|
||||
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
if (wxGetApp().is_gcode_viewer())
|
||||
return;
|
||||
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
|
||||
const bool is_fff = plater()->printer_technology() == ptFFF;
|
||||
|
||||
m_changeable_menu_items[miExport] ->SetItemLabel((is_fff ? _(L("Export &G-code")) : _(L("E&xport")) ) + dots + "\tCtrl+G");
|
||||
m_changeable_menu_items[miSend] ->SetItemLabel((is_fff ? _(L("S&end G-code")) : _(L("S&end to print"))) + dots + "\tCtrl+Shift+G");
|
||||
m_changeable_menu_items[miExport] ->SetItemLabel((is_fff ? _L("Export &G-code") : _L("E&xport")) + dots + "\tCtrl+G");
|
||||
m_changeable_menu_items[miSend] ->SetItemLabel((is_fff ? _L("S&end G-code") : _L("S&end to print")) + dots + "\tCtrl+Shift+G");
|
||||
|
||||
m_changeable_menu_items[miMaterialTab] ->SetItemLabel((is_fff ? _(L("&Filament Settings Tab")) : _(L("Mate&rial Settings Tab"))) + "\tCtrl+3");
|
||||
m_changeable_menu_items[miMaterialTab] ->SetItemLabel((is_fff ? _L("&Filament Settings Tab") : _L("Mate&rial Settings Tab")) + "\tCtrl+3");
|
||||
m_changeable_menu_items[miMaterialTab] ->SetBitmap(create_scaled_bitmap(is_fff ? "spool" : "resin"));
|
||||
|
||||
m_changeable_menu_items[miPrinterTab] ->SetBitmap(create_scaled_bitmap(is_fff ? "printer" : "sla_printer"));
|
||||
|
@ -1996,6 +2063,11 @@ SettingsDialog::SettingsDialog(MainFrame* mainframe)
|
|||
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX | wxMAXIMIZE_BOX, "settings_dialog"),
|
||||
m_main_frame(mainframe)
|
||||
{
|
||||
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
if (wxGetApp().is_gcode_viewer())
|
||||
return;
|
||||
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
|
||||
#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT && defined(__WXMSW__)
|
||||
// ys_FIXME! temporary workaround for correct font scaling
|
||||
// Because of from wxWidgets 3.1.3 auto rescaling is implemented for the Fonts,
|
||||
|
@ -2006,8 +2078,6 @@ SettingsDialog::SettingsDialog(MainFrame* mainframe)
|
|||
#endif // ENABLE_WX_3_1_3_DPI_CHANGED_EVENT
|
||||
this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
|
||||
|
||||
// SetIcon(wxIcon(Slic3r::var("PrusaSlicer_128px.png"), wxBITMAP_TYPE_PNG));
|
||||
// Load the icon either from the exe, or from the ico file.
|
||||
#if _WIN32
|
||||
{
|
||||
|
@ -2070,6 +2140,11 @@ SettingsDialog::SettingsDialog(MainFrame* mainframe)
|
|||
|
||||
void SettingsDialog::on_dpi_changed(const wxRect& suggested_rect)
|
||||
{
|
||||
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
if (wxGetApp().is_gcode_viewer())
|
||||
return;
|
||||
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||
|
||||
const int& em = em_unit();
|
||||
const wxSize& size = wxSize(85 * em, 50 * em);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue