mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-31 02:24:27 +08:00
Merge remote-tracking branch 'origin/et_gcode_viewer'
This commit is contained in:
commit
39fa079d56
BIN
resources/icons/PrusaSlicer-gcodeviewer_128px.png
Normal file
BIN
resources/icons/PrusaSlicer-gcodeviewer_128px.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 16 KiB |
BIN
resources/icons/splashscreen-gcodeviewer.jpg
Normal file
BIN
resources/icons/splashscreen-gcodeviewer.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 133 KiB |
@ -541,7 +541,11 @@ int CLI::run(int argc, char **argv)
|
|||||||
if (start_gui) {
|
if (start_gui) {
|
||||||
#ifdef SLIC3R_GUI
|
#ifdef SLIC3R_GUI
|
||||||
// #ifdef USE_WX
|
// #ifdef USE_WX
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
GUI::GUI_App* gui = new GUI::GUI_App(start_as_gcodeviewer ? GUI::GUI_App::EAppMode::GCodeViewer : GUI::GUI_App::EAppMode::Editor);
|
||||||
|
#else
|
||||||
GUI::GUI_App *gui = new GUI::GUI_App();
|
GUI::GUI_App *gui = new GUI::GUI_App();
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
|
||||||
bool gui_single_instance_setting = gui->app_config->get("single_instance") == "1";
|
bool gui_single_instance_setting = gui->app_config->get("single_instance") == "1";
|
||||||
if (Slic3r::instance_check(argc, argv, gui_single_instance_setting)) {
|
if (Slic3r::instance_check(argc, argv, gui_single_instance_setting)) {
|
||||||
|
@ -179,6 +179,11 @@ std::string AppConfig::load()
|
|||||||
|
|
||||||
void AppConfig::save()
|
void AppConfig::save()
|
||||||
{
|
{
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
if (!m_save_enabled)
|
||||||
|
return;
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
|
||||||
// The config is first written to a file with a PID suffix and then moved
|
// The config is first written to a file with a PID suffix and then moved
|
||||||
// to avoid race conditions with multiple instances of Slic3r
|
// to avoid race conditions with multiple instances of Slic3r
|
||||||
const auto path = config_path();
|
const auto path = config_path();
|
||||||
|
@ -18,6 +18,9 @@ public:
|
|||||||
AppConfig() :
|
AppConfig() :
|
||||||
m_dirty(false),
|
m_dirty(false),
|
||||||
m_orig_version(Semver::invalid()),
|
m_orig_version(Semver::invalid()),
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
m_save_enabled(true),
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
m_legacy_datadir(false)
|
m_legacy_datadir(false)
|
||||||
{
|
{
|
||||||
this->reset();
|
this->reset();
|
||||||
@ -157,6 +160,10 @@ public:
|
|||||||
bool get_mouse_device_swap_yz(const std::string& name, bool& swap) const
|
bool get_mouse_device_swap_yz(const std::string& name, bool& swap) const
|
||||||
{ return get_3dmouse_device_numeric_value(name, "swap_yz", swap); }
|
{ return get_3dmouse_device_numeric_value(name, "swap_yz", swap); }
|
||||||
|
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
void enable_save(bool enable) { m_save_enabled = enable; }
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
|
||||||
static const std::string SECTION_FILAMENTS;
|
static const std::string SECTION_FILAMENTS;
|
||||||
static const std::string SECTION_MATERIALS;
|
static const std::string SECTION_MATERIALS;
|
||||||
|
|
||||||
@ -183,6 +190,10 @@ private:
|
|||||||
bool m_dirty;
|
bool m_dirty;
|
||||||
// Original version found in the ini file before it was overwritten
|
// Original version found in the ini file before it was overwritten
|
||||||
Semver m_orig_version;
|
Semver m_orig_version;
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
// Whether or not calls to save() should take effect
|
||||||
|
bool m_save_enabled;
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
// Whether the existing version is before system profiles & configuration updating
|
// Whether the existing version is before system profiles & configuration updating
|
||||||
bool m_legacy_datadir;
|
bool m_legacy_datadir;
|
||||||
};
|
};
|
||||||
|
@ -59,5 +59,6 @@
|
|||||||
#define ENABLE_GCODE_VIEWER_STATISTICS (0 && ENABLE_GCODE_VIEWER)
|
#define ENABLE_GCODE_VIEWER_STATISTICS (0 && ENABLE_GCODE_VIEWER)
|
||||||
#define ENABLE_GCODE_VIEWER_DATA_CHECKING (0 && ENABLE_GCODE_VIEWER)
|
#define ENABLE_GCODE_VIEWER_DATA_CHECKING (0 && ENABLE_GCODE_VIEWER)
|
||||||
#define ENABLE_GCODE_VIEWER_TASKBAR_ICON (0 && ENABLE_GCODE_VIEWER)
|
#define ENABLE_GCODE_VIEWER_TASKBAR_ICON (0 && ENABLE_GCODE_VIEWER)
|
||||||
|
#define ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION (1 && ENABLE_GCODE_VIEWER)
|
||||||
|
|
||||||
#endif // _prusaslicer_technologies_h_
|
#endif // _prusaslicer_technologies_h_
|
||||||
|
@ -339,7 +339,11 @@ void GCodeViewer::load(const GCodeProcessor::Result& gcode_result, const Print&
|
|||||||
reset();
|
reset();
|
||||||
|
|
||||||
load_toolpaths(gcode_result);
|
load_toolpaths(gcode_result);
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
if (wxGetApp().is_editor())
|
||||||
|
#else
|
||||||
if (wxGetApp().mainframe->get_mode() != MainFrame::EMode::GCodeViewer)
|
if (wxGetApp().mainframe->get_mode() != MainFrame::EMode::GCodeViewer)
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
load_shells(print, initialized);
|
load_shells(print, initialized);
|
||||||
else {
|
else {
|
||||||
Pointfs bed_shape;
|
Pointfs bed_shape;
|
||||||
@ -875,7 +879,11 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result)
|
|||||||
|
|
||||||
for (size_t i = 0; i < m_vertices_count; ++i) {
|
for (size_t i = 0; i < m_vertices_count; ++i) {
|
||||||
const GCodeProcessor::MoveVertex& move = gcode_result.moves[i];
|
const GCodeProcessor::MoveVertex& move = gcode_result.moves[i];
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
if (wxGetApp().is_gcode_viewer())
|
||||||
|
#else
|
||||||
if (wxGetApp().mainframe->get_mode() == MainFrame::EMode::GCodeViewer)
|
if (wxGetApp().mainframe->get_mode() == MainFrame::EMode::GCodeViewer)
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
// for the gcode viewer we need all moves to correctly size the printbed
|
// for the gcode viewer we need all moves to correctly size the printbed
|
||||||
m_paths_bounding_box.merge(move.position.cast<double>());
|
m_paths_bounding_box.merge(move.position.cast<double>());
|
||||||
else {
|
else {
|
||||||
|
@ -2732,7 +2732,11 @@ static void load_gcode_retractions(const GCodePreviewData::Retraction& retractio
|
|||||||
void GLCanvas3D::load_gcode_preview(const GCodeProcessor::Result& gcode_result)
|
void GLCanvas3D::load_gcode_preview(const GCodeProcessor::Result& gcode_result)
|
||||||
{
|
{
|
||||||
m_gcode_viewer.load(gcode_result, *this->fff_print(), m_initialized);
|
m_gcode_viewer.load(gcode_result, *this->fff_print(), m_initialized);
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
if (wxGetApp().is_editor())
|
||||||
|
#else
|
||||||
if (wxGetApp().mainframe->get_mode() != MainFrame::EMode::GCodeViewer)
|
if (wxGetApp().mainframe->get_mode() != MainFrame::EMode::GCodeViewer)
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
_show_warning_texture_if_needed(WarningTexture::ToolpathOutside);
|
_show_warning_texture_if_needed(WarningTexture::ToolpathOutside);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4302,7 +4306,11 @@ void GLCanvas3D::update_ui_from_settings()
|
|||||||
#endif // ENABLE_RETINA_GL
|
#endif // ENABLE_RETINA_GL
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
if (wxGetApp().is_editor())
|
||||||
|
#else
|
||||||
if (wxGetApp().mainframe != nullptr && wxGetApp().mainframe->get_mode() != MainFrame::EMode::GCodeViewer)
|
if (wxGetApp().mainframe != nullptr && wxGetApp().mainframe->get_mode() != MainFrame::EMode::GCodeViewer)
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
wxGetApp().plater()->get_collapse_toolbar().set_enabled(wxGetApp().app_config->get("show_collapse_button") == "1");
|
wxGetApp().plater()->get_collapse_toolbar().set_enabled(wxGetApp().app_config->get("show_collapse_button") == "1");
|
||||||
#else
|
#else
|
||||||
bool enable_collapse = wxGetApp().app_config->get("show_collapse_button") == "1";
|
bool enable_collapse = wxGetApp().app_config->get("show_collapse_button") == "1";
|
||||||
@ -5405,7 +5413,11 @@ void GLCanvas3D::_render_background() const
|
|||||||
{
|
{
|
||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
bool use_error_color = false;
|
bool use_error_color = false;
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
if (wxGetApp().is_editor()) {
|
||||||
|
#else
|
||||||
if (wxGetApp().mainframe->get_mode() != MainFrame::EMode::GCodeViewer) {
|
if (wxGetApp().mainframe->get_mode() != MainFrame::EMode::GCodeViewer) {
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
use_error_color = m_dynamic_background_enabled;
|
use_error_color = m_dynamic_background_enabled;
|
||||||
if (!m_volumes.empty())
|
if (!m_volumes.empty())
|
||||||
use_error_color &= _is_any_volume_outside();
|
use_error_color &= _is_any_volume_outside();
|
||||||
@ -7134,7 +7146,11 @@ void GLCanvas3D::_show_warning_texture_if_needed(WarningTexture::Warning warning
|
|||||||
if (!m_volumes.empty())
|
if (!m_volumes.empty())
|
||||||
show = _is_any_volume_outside();
|
show = _is_any_volume_outside();
|
||||||
else {
|
else {
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
if (wxGetApp().is_editor()) {
|
||||||
|
#else
|
||||||
if (wxGetApp().mainframe->get_mode() != MainFrame::EMode::GCodeViewer) {
|
if (wxGetApp().mainframe->get_mode() != MainFrame::EMode::GCodeViewer) {
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
BoundingBoxf3 test_volume = (m_config != nullptr) ? print_volume(*m_config) : BoundingBoxf3();
|
BoundingBoxf3 test_volume = (m_config != nullptr) ? print_volume(*m_config) : BoundingBoxf3();
|
||||||
const BoundingBoxf3& paths_volume = m_gcode_viewer.get_paths_bounding_box();
|
const BoundingBoxf3& paths_volume = m_gcode_viewer.get_paths_bounding_box();
|
||||||
if (test_volume.radius() > 0.0 && paths_volume.radius() > 0.0)
|
if (test_volume.radius() > 0.0 && paths_volume.radius() > 0.0)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include "libslic3r/Technologies.hpp"
|
||||||
#include "GUI_App.hpp"
|
#include "GUI_App.hpp"
|
||||||
#include "GUI_ObjectList.hpp"
|
#include "GUI_ObjectList.hpp"
|
||||||
#include "GUI_ObjectManipulation.hpp"
|
#include "GUI_ObjectManipulation.hpp"
|
||||||
@ -434,8 +435,15 @@ static void generic_exception_handle()
|
|||||||
|
|
||||||
IMPLEMENT_APP(GUI_App)
|
IMPLEMENT_APP(GUI_App)
|
||||||
|
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
GUI_App::GUI_App(EAppMode mode)
|
||||||
|
#else
|
||||||
GUI_App::GUI_App()
|
GUI_App::GUI_App()
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
: wxApp()
|
: wxApp()
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
, m_app_mode(mode)
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
, m_em_unit(10)
|
, m_em_unit(10)
|
||||||
, m_imgui(new ImGuiWrapper())
|
, m_imgui(new ImGuiWrapper())
|
||||||
, m_wizard(nullptr)
|
, m_wizard(nullptr)
|
||||||
@ -491,6 +499,12 @@ void GUI_App::init_app_config()
|
|||||||
if (!app_config)
|
if (!app_config)
|
||||||
app_config = new AppConfig();
|
app_config = new AppConfig();
|
||||||
|
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
if (is_gcode_viewer())
|
||||||
|
// disable config save to avoid to mess it up for the editor
|
||||||
|
app_config->enable_save(false);
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
|
||||||
// load settings
|
// load settings
|
||||||
app_conf_exists = app_config->exists();
|
app_conf_exists = app_config->exists();
|
||||||
if (app_conf_exists) {
|
if (app_conf_exists) {
|
||||||
@ -527,18 +541,18 @@ bool GUI_App::on_init_inner()
|
|||||||
wxCHECK_MSG(wxDirExists(resources_dir), false,
|
wxCHECK_MSG(wxDirExists(resources_dir), false,
|
||||||
wxString::Format("Resources path does not exist or is not a directory: %s", resources_dir));
|
wxString::Format("Resources path does not exist or is not a directory: %s", resources_dir));
|
||||||
|
|
||||||
// Enable this to get the default Win32 COMCTRL32 behavior of static boxes.
|
// Enable this to get the default Win32 COMCTRL32 behavior of static boxes.
|
||||||
// wxSystemOptions::SetOption("msw.staticbox.optimized-paint", 0);
|
// wxSystemOptions::SetOption("msw.staticbox.optimized-paint", 0);
|
||||||
// Enable this to disable Windows Vista themes for all wxNotebooks. The themes seem to lead to terrible
|
// Enable this to disable Windows Vista themes for all wxNotebooks. The themes seem to lead to terrible
|
||||||
// performance when working on high resolution multi-display setups.
|
// performance when working on high resolution multi-display setups.
|
||||||
// wxSystemOptions::SetOption("msw.notebook.themed-background", 0);
|
// wxSystemOptions::SetOption("msw.notebook.themed-background", 0);
|
||||||
|
|
||||||
// Slic3r::debugf "wxWidgets version %s, Wx version %s\n", wxVERSION_STRING, wxVERSION;
|
// Slic3r::debugf "wxWidgets version %s, Wx version %s\n", wxVERSION_STRING, wxVERSION;
|
||||||
|
|
||||||
std::string msg = Http::tls_global_init();
|
std::string msg = Http::tls_global_init();
|
||||||
std::string ssl_cert_store = app_config->get("tls_accepted_cert_store_location");
|
std::string ssl_cert_store = app_config->get("tls_accepted_cert_store_location");
|
||||||
bool ssl_accept = app_config->get("tls_cert_store_accepted") == "yes" && ssl_cert_store == Http::tls_system_cert_store();
|
bool ssl_accept = app_config->get("tls_cert_store_accepted") == "yes" && ssl_cert_store == Http::tls_system_cert_store();
|
||||||
|
|
||||||
if (!msg.empty() && !ssl_accept) {
|
if (!msg.empty() && !ssl_accept) {
|
||||||
wxRichMessageDialog
|
wxRichMessageDialog
|
||||||
dlg(nullptr,
|
dlg(nullptr,
|
||||||
@ -548,11 +562,11 @@ bool GUI_App::on_init_inner()
|
|||||||
if (dlg.ShowModal() != wxID_YES) return false;
|
if (dlg.ShowModal() != wxID_YES) return false;
|
||||||
|
|
||||||
app_config->set("tls_cert_store_accepted",
|
app_config->set("tls_cert_store_accepted",
|
||||||
dlg.IsCheckBoxChecked() ? "yes" : "no");
|
dlg.IsCheckBoxChecked() ? "yes" : "no");
|
||||||
app_config->set("tls_accepted_cert_store_location",
|
app_config->set("tls_accepted_cert_store_location",
|
||||||
dlg.IsCheckBoxChecked() ? Http::tls_system_cert_store() : "");
|
dlg.IsCheckBoxChecked() ? Http::tls_system_cert_store() : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
app_config->set("version", SLIC3R_VERSION);
|
app_config->set("version", SLIC3R_VERSION);
|
||||||
app_config->save();
|
app_config->save();
|
||||||
/*
|
/*
|
||||||
@ -564,33 +578,43 @@ bool GUI_App::on_init_inner()
|
|||||||
wxInitAllImageHandlers();
|
wxInitAllImageHandlers();
|
||||||
|
|
||||||
wxBitmap bitmap = create_scaled_bitmap("prusa_slicer_logo", nullptr, 400);
|
wxBitmap bitmap = create_scaled_bitmap("prusa_slicer_logo", nullptr, 400);
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
wxBitmap bmp(is_editor() ? from_u8(var("splashscreen.jpg")) : from_u8(var("splashscreen-gcodeviewer.jpg")), wxBITMAP_TYPE_JPEG);
|
||||||
|
#else
|
||||||
wxBitmap bmp(from_u8(var("splashscreen.jpg")), wxBITMAP_TYPE_JPEG);
|
wxBitmap bmp(from_u8(var("splashscreen.jpg")), wxBITMAP_TYPE_JPEG);
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
|
||||||
DecorateSplashScreen(bmp);
|
DecorateSplashScreen(bmp);
|
||||||
|
|
||||||
SplashScreen* scrn = new SplashScreen(bmp.IsOk() ? bmp : bitmap, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_TIMEOUT, 4000, nullptr);
|
SplashScreen* scrn = new SplashScreen(bmp.IsOk() ? bmp : bitmap, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_TIMEOUT, 4000, nullptr);
|
||||||
scrn->SetText(_L("Loading configuration..."));
|
scrn->SetText(_L("Loading configuration..."));
|
||||||
|
|
||||||
preset_bundle = new PresetBundle();
|
preset_bundle = new PresetBundle();
|
||||||
|
|
||||||
// just checking for existence of Slic3r::data_dir is not enough : it may be an empty directory
|
// just checking for existence of Slic3r::data_dir is not enough : it may be an empty directory
|
||||||
// supplied as argument to --datadir; in that case we should still run the wizard
|
// supplied as argument to --datadir; in that case we should still run the wizard
|
||||||
preset_bundle->setup_directories();
|
preset_bundle->setup_directories();
|
||||||
|
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
if (is_editor()) {
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
associate_3mf_files();
|
associate_3mf_files();
|
||||||
#endif // __WXMSW__
|
#endif // __WXMSW__
|
||||||
|
|
||||||
preset_updater = new PresetUpdater();
|
preset_updater = new PresetUpdater();
|
||||||
Bind(EVT_SLIC3R_VERSION_ONLINE, [this](const wxCommandEvent &evt) {
|
Bind(EVT_SLIC3R_VERSION_ONLINE, [this](const wxCommandEvent& evt) {
|
||||||
app_config->set("version_online", into_u8(evt.GetString()));
|
app_config->set("version_online", into_u8(evt.GetString()));
|
||||||
app_config->save();
|
app_config->save();
|
||||||
if(this->plater_ != nullptr) {
|
if (this->plater_ != nullptr) {
|
||||||
if (*Semver::parse(SLIC3R_VERSION) < * Semver::parse(into_u8(evt.GetString()))) {
|
if (*Semver::parse(SLIC3R_VERSION) < *Semver::parse(into_u8(evt.GetString()))) {
|
||||||
this->plater_->get_notification_manager()->push_notification(NotificationType::NewAppAviable, *(this->plater_->get_current_canvas3D()));
|
this->plater_->get_notification_manager()->push_notification(NotificationType::NewAppAviable, *(this->plater_->get_current_canvas3D()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
}
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
|
||||||
// initialize label colors and fonts
|
// initialize label colors and fonts
|
||||||
init_label_colours();
|
init_label_colours();
|
||||||
@ -618,7 +642,10 @@ bool GUI_App::on_init_inner()
|
|||||||
Slic3r::I18N::set_translate_callback(libslic3r_translate_callback);
|
Slic3r::I18N::set_translate_callback(libslic3r_translate_callback);
|
||||||
|
|
||||||
// application frame
|
// application frame
|
||||||
scrn->SetText(_L("Creating settings tabs..."));
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
if (is_editor())
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
scrn->SetText(_L("Creating settings tabs..."));
|
||||||
|
|
||||||
mainframe = new MainFrame();
|
mainframe = new MainFrame();
|
||||||
// hide settings tabs after first Layout
|
// hide settings tabs after first Layout
|
||||||
@ -653,13 +680,20 @@ bool GUI_App::on_init_inner()
|
|||||||
static bool once = true;
|
static bool once = true;
|
||||||
if (once) {
|
if (once) {
|
||||||
once = false;
|
once = false;
|
||||||
check_updates(false);
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
if (preset_updater != nullptr) {
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
check_updates(false);
|
||||||
|
|
||||||
|
CallAfter([this] {
|
||||||
|
config_wizard_startup();
|
||||||
|
preset_updater->slic3r_update_notify();
|
||||||
|
preset_updater->sync(preset_bundle);
|
||||||
|
});
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
}
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
|
||||||
CallAfter([this] {
|
|
||||||
config_wizard_startup();
|
|
||||||
preset_updater->slic3r_update_notify();
|
|
||||||
preset_updater->sync(preset_bundle);
|
|
||||||
});
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
//sets window property to mainframe so other instances can indentify it
|
//sets window property to mainframe so other instances can indentify it
|
||||||
OtherInstanceMessageHandler::init_windows_properties(mainframe, m_instance_hash_int);
|
OtherInstanceMessageHandler::init_windows_properties(mainframe, m_instance_hash_int);
|
||||||
@ -667,8 +701,16 @@ bool GUI_App::on_init_inner()
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
load_current_presets();
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
if (is_gcode_viewer()) {
|
||||||
|
mainframe->update_layout();
|
||||||
|
if (plater_ != nullptr)
|
||||||
|
// ensure the selected technology is ptFFF
|
||||||
|
plater_->set_printer_technology(ptFFF);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
load_current_presets();
|
||||||
mainframe->Show(true);
|
mainframe->Show(true);
|
||||||
|
|
||||||
/* Temporary workaround for the correct behavior of the Scrolled sidebar panel:
|
/* Temporary workaround for the correct behavior of the Scrolled sidebar panel:
|
||||||
|
@ -94,8 +94,22 @@ static wxString dots("…", wxConvUTF8);
|
|||||||
|
|
||||||
class GUI_App : public wxApp
|
class GUI_App : public wxApp
|
||||||
{
|
{
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
public:
|
||||||
|
enum class EAppMode : unsigned char
|
||||||
|
{
|
||||||
|
Editor,
|
||||||
|
GCodeViewer
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
|
||||||
bool m_initialized { false };
|
bool m_initialized { false };
|
||||||
bool app_conf_exists{ false };
|
bool app_conf_exists{ false };
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
EAppMode m_app_mode{ EAppMode::Editor };
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
|
||||||
wxColour m_color_label_modified;
|
wxColour m_color_label_modified;
|
||||||
wxColour m_color_label_sys;
|
wxColour m_color_label_sys;
|
||||||
@ -125,13 +139,24 @@ class GUI_App : public wxApp
|
|||||||
std::unique_ptr <wxSingleInstanceChecker> m_single_instance_checker;
|
std::unique_ptr <wxSingleInstanceChecker> m_single_instance_checker;
|
||||||
std::string m_instance_hash_string;
|
std::string m_instance_hash_string;
|
||||||
size_t m_instance_hash_int;
|
size_t m_instance_hash_int;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool OnInit() override;
|
bool OnInit() override;
|
||||||
bool initialized() const { return m_initialized; }
|
bool initialized() const { return m_initialized; }
|
||||||
|
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
explicit GUI_App(EAppMode mode = EAppMode::Editor);
|
||||||
|
#else
|
||||||
GUI_App();
|
GUI_App();
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
~GUI_App() override;
|
~GUI_App() override;
|
||||||
|
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
EAppMode get_app_mode() const { return m_app_mode; }
|
||||||
|
bool is_editor() const { return m_app_mode == EAppMode::Editor; }
|
||||||
|
bool is_gcode_viewer() const { return m_app_mode == EAppMode::GCodeViewer; }
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
|
||||||
static std::string get_gl_info(bool format_as_html, bool extensions);
|
static std::string get_gl_info(bool format_as_html, bool extensions);
|
||||||
wxGLContext* init_glcontext(wxGLCanvas& canvas);
|
wxGLContext* init_glcontext(wxGLCanvas& canvas);
|
||||||
bool init_opengl();
|
bool init_opengl();
|
||||||
|
@ -1234,7 +1234,11 @@ void Preview::load_print_as_fff(bool keep_z_range)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
if (wxGetApp().is_editor() && !has_layers)
|
||||||
|
#else
|
||||||
if (wxGetApp().mainframe->get_mode() != MainFrame::EMode::GCodeViewer && !has_layers)
|
if (wxGetApp().mainframe->get_mode() != MainFrame::EMode::GCodeViewer && !has_layers)
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
#else
|
#else
|
||||||
if (! has_layers)
|
if (! has_layers)
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
|
@ -194,6 +194,9 @@ Preview(wxWindow* parent, Model* model, DynamicPrintConfig* config,
|
|||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
void update_bottom_toolbar();
|
void update_bottom_toolbar();
|
||||||
void update_moves_slider();
|
void update_moves_slider();
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
void hide_layers_slider();
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -203,7 +206,9 @@ private:
|
|||||||
void unbind_event_handlers();
|
void unbind_event_handlers();
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
void hide_layers_slider();
|
void hide_layers_slider();
|
||||||
|
#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
#else
|
#else
|
||||||
void show_hide_ui_elements(const std::string& what);
|
void show_hide_ui_elements(const std::string& what);
|
||||||
|
|
||||||
|
@ -95,9 +95,15 @@ void KBShortcutsDialog::fill_shortcuts()
|
|||||||
const std::string& alt = GUI::shortkey_alt_prefix();
|
const std::string& alt = GUI::shortkey_alt_prefix();
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
bool is_gcode_viewer = wxGetApp().mainframe->get_mode() == MainFrame::EMode::GCodeViewer;
|
bool is_gcode_viewer = wxGetApp().mainframe->get_mode() == MainFrame::EMode::GCodeViewer;
|
||||||
|
#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
if (wxGetApp().is_editor()) {
|
||||||
|
#else
|
||||||
if (!is_gcode_viewer) {
|
if (!is_gcode_viewer) {
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
Shortcuts commands_shortcuts = {
|
Shortcuts commands_shortcuts = {
|
||||||
// File
|
// File
|
||||||
|
@ -86,7 +86,6 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
|
|||||||
}
|
}
|
||||||
#endif // ENABLE_GCODE_VIEWER_TASKBAR_ICON
|
#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.
|
// Load the icon either from the exe, or from the ico file.
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
{
|
{
|
||||||
@ -96,7 +95,24 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
|
|||||||
SetIcon(wxIcon(szExeFileName, wxBITMAP_TYPE_ICO));
|
SetIcon(wxIcon(szExeFileName, wxBITMAP_TYPE_ICO));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
SetIcon(wxIcon(Slic3r::var("PrusaSlicer_128px.png"), wxBITMAP_TYPE_PNG));
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
switch (wxGetApp().get_app_mode())
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case GUI_App::EAppMode::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::EAppMode::GCodeViewer:
|
||||||
|
{
|
||||||
|
SetIcon(wxIcon(Slic3r::var("PrusaSlicer-gcodeviewer_128px.png"), wxBITMAP_TYPE_PNG));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
// initialize status bar
|
// initialize status bar
|
||||||
@ -110,8 +126,15 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
|
|||||||
// initialize tabpanel and menubar
|
// initialize tabpanel and menubar
|
||||||
init_tabpanel();
|
init_tabpanel();
|
||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
init_editor_menubar();
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
init_gcodeviewer_menubar();
|
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
|
#if _WIN32
|
||||||
// This is needed on Windows to fake the CTRL+# of the window menu when using the numpad
|
// This is needed on Windows to fake the CTRL+# of the window menu when using the numpad
|
||||||
@ -142,7 +165,10 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
|
|||||||
sizer->Add(m_main_sizer, 1, wxEXPAND);
|
sizer->Add(m_main_sizer, 1, wxEXPAND);
|
||||||
SetSizer(sizer);
|
SetSizer(sizer);
|
||||||
// initialize layout from config
|
// 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);
|
sizer->SetSizeHints(this);
|
||||||
Fit();
|
Fit();
|
||||||
|
|
||||||
@ -294,10 +320,17 @@ void MainFrame::update_layout()
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
#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 :
|
ESettingsLayout layout = (m_mode == EMode::GCodeViewer) ? ESettingsLayout::GCodeViewer :
|
||||||
(wxGetApp().app_config->get("old_settings_layout_mode") == "1" ? ESettingsLayout::Old :
|
(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("new_settings_layout_mode") == "1" ? ESettingsLayout::New :
|
||||||
wxGetApp().app_config->get("dlg_settings_layout_mode") == "1" ? ESettingsLayout::Dlg : ESettingsLayout::Old);
|
wxGetApp().app_config->get("dlg_settings_layout_mode") == "1" ? ESettingsLayout::Dlg : ESettingsLayout::Old);
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
#else
|
#else
|
||||||
ESettingsLayout layout = wxGetApp().app_config->get("old_settings_layout_mode") == "1" ? ESettingsLayout::Old :
|
ESettingsLayout layout = 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("new_settings_layout_mode") == "1" ? ESettingsLayout::New :
|
||||||
@ -369,6 +402,12 @@ void MainFrame::update_layout()
|
|||||||
case ESettingsLayout::GCodeViewer:
|
case ESettingsLayout::GCodeViewer:
|
||||||
{
|
{
|
||||||
m_main_sizer->Add(m_plater, 1, wxEXPAND);
|
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();
|
m_plater->Show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -476,6 +515,7 @@ void MainFrame::shutdown()
|
|||||||
|
|
||||||
if (m_plater != nullptr) {
|
if (m_plater != nullptr) {
|
||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
// restore sidebar if it was hidden when switching to gcode viewer mode
|
// restore sidebar if it was hidden when switching to gcode viewer mode
|
||||||
if (m_restore_from_gcode_viewer.collapsed_sidebar)
|
if (m_restore_from_gcode_viewer.collapsed_sidebar)
|
||||||
m_plater->collapse_sidebar(false);
|
m_plater->collapse_sidebar(false);
|
||||||
@ -483,6 +523,7 @@ void MainFrame::shutdown()
|
|||||||
// restore sla printer if it was deselected when switching to gcode viewer mode
|
// restore sla printer if it was deselected when switching to gcode viewer mode
|
||||||
if (m_restore_from_gcode_viewer.sla_technology)
|
if (m_restore_from_gcode_viewer.sla_technology)
|
||||||
m_plater->set_printer_technology(ptSLA);
|
m_plater->set_printer_technology(ptSLA);
|
||||||
|
#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
// Stop the background thread (Windows and Linux).
|
// Stop the background thread (Windows and Linux).
|
||||||
// Disconnect from a 3DConnextion driver (OSX).
|
// Disconnect from a 3DConnextion driver (OSX).
|
||||||
@ -584,7 +625,10 @@ void MainFrame::init_tabpanel()
|
|||||||
// or when the preset's "modified" status changes.
|
// or when the preset's "modified" status changes.
|
||||||
Bind(EVT_TAB_PRESETS_CHANGED, &MainFrame::on_presets_changed, this); // #ys_FIXME_to_delete
|
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) {
|
if (m_plater) {
|
||||||
// load initial config
|
// load initial config
|
||||||
@ -885,7 +929,7 @@ static void add_common_view_menu_items(wxMenu* view_menu, MainFrame* mainFrame,
|
|||||||
"", nullptr, [can_change_view]() { return can_change_view(); }, mainFrame);
|
"", nullptr, [can_change_view]() { return can_change_view(); }, mainFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::init_editor_menubar()
|
void MainFrame::init_menubar_as_editor()
|
||||||
#else
|
#else
|
||||||
void MainFrame::init_menubar()
|
void MainFrame::init_menubar()
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
@ -1050,6 +1094,7 @@ void MainFrame::init_menubar()
|
|||||||
[this]() { return true; }, this);
|
[this]() { return true; }, this);
|
||||||
fileMenu->AppendSeparator();
|
fileMenu->AppendSeparator();
|
||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
append_menu_item(fileMenu, wxID_ANY, _L("&G-code preview"), _L("Switch to G-code preview mode"),
|
append_menu_item(fileMenu, wxID_ANY, _L("&G-code preview"), _L("Switch to G-code preview mode"),
|
||||||
[this](wxCommandEvent&) {
|
[this](wxCommandEvent&) {
|
||||||
if (m_plater->model().objects.empty() ||
|
if (m_plater->model().objects.empty() ||
|
||||||
@ -1057,6 +1102,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)
|
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);
|
set_mode(EMode::GCodeViewer);
|
||||||
}, "", nullptr);
|
}, "", nullptr);
|
||||||
|
#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
append_menu_item(fileMenu, wxID_ANY, _L("&G-code preview") + dots, _L("Open G-code viewer"),
|
append_menu_item(fileMenu, wxID_ANY, _L("&G-code preview") + dots, _L("Open G-code viewer"),
|
||||||
[this](wxCommandEvent&) { start_new_gcodeviewer_open_file(this); }, "", nullptr);
|
[this](wxCommandEvent&) { start_new_gcodeviewer_open_file(this); }, "", nullptr);
|
||||||
@ -1273,6 +1319,17 @@ void MainFrame::init_menubar()
|
|||||||
// assign menubar to frame after appending items, otherwise special items
|
// assign menubar to frame after appending items, otherwise special items
|
||||||
// will not be handled correctly
|
// will not be handled correctly
|
||||||
#if ENABLE_GCODE_VIEWER
|
#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 = new wxMenuBar();
|
||||||
m_editor_menubar->Append(fileMenu, _L("&File"));
|
m_editor_menubar->Append(fileMenu, _L("&File"));
|
||||||
if (editMenu) m_editor_menubar->Append(editMenu, _L("&Edit"));
|
if (editMenu) m_editor_menubar->Append(editMenu, _L("&Edit"));
|
||||||
@ -1282,15 +1339,16 @@ void MainFrame::init_menubar()
|
|||||||
wxGetApp().add_config_menu(m_editor_menubar);
|
wxGetApp().add_config_menu(m_editor_menubar);
|
||||||
m_editor_menubar->Append(helpMenu, _L("&Help"));
|
m_editor_menubar->Append(helpMenu, _L("&Help"));
|
||||||
SetMenuBar(m_editor_menubar);
|
SetMenuBar(m_editor_menubar);
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
#else
|
#else
|
||||||
auto menubar = new wxMenuBar();
|
auto menubar = new wxMenuBar();
|
||||||
menubar->Append(fileMenu, _(L("&File")));
|
menubar->Append(fileMenu, _L("&File"));
|
||||||
if (editMenu) menubar->Append(editMenu, _(L("&Edit")));
|
if (editMenu) menubar->Append(editMenu, _L("&Edit"));
|
||||||
menubar->Append(windowMenu, _(L("&Window")));
|
menubar->Append(windowMenu, _L("&Window"));
|
||||||
if (viewMenu) menubar->Append(viewMenu, _(L("&View")));
|
if (viewMenu) menubar->Append(viewMenu, _L("&View"));
|
||||||
// Add additional menus from C++
|
// Add additional menus from C++
|
||||||
wxGetApp().add_config_menu(menubar);
|
wxGetApp().add_config_menu(menubar);
|
||||||
menubar->Append(helpMenu, _(L("&Help")));
|
menubar->Append(helpMenu, _L("&Help"));
|
||||||
SetMenuBar(menubar);
|
SetMenuBar(menubar);
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
|
|
||||||
@ -1298,7 +1356,11 @@ void MainFrame::init_menubar()
|
|||||||
// This fixes a bug on Mac OS where the quit command doesn't emit window close events
|
// This fixes a bug on Mac OS where the quit command doesn't emit window close events
|
||||||
// wx bug: https://trac.wxwidgets.org/ticket/18328
|
// wx bug: https://trac.wxwidgets.org/ticket/18328
|
||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
wxMenu* apple_menu = m_menubar->OSXGetAppleMenu();
|
||||||
|
#else
|
||||||
wxMenu* apple_menu = m_editor_menubar->OSXGetAppleMenu();
|
wxMenu* apple_menu = m_editor_menubar->OSXGetAppleMenu();
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
#else
|
#else
|
||||||
wxMenu *apple_menu = menubar->OSXGetAppleMenu();
|
wxMenu *apple_menu = menubar->OSXGetAppleMenu();
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
@ -1307,18 +1369,14 @@ void MainFrame::init_menubar()
|
|||||||
Close();
|
Close();
|
||||||
}, wxID_EXIT);
|
}, wxID_EXIT);
|
||||||
}
|
}
|
||||||
#endif
|
#endif // __APPLE__
|
||||||
|
|
||||||
if (plater()->printer_technology() == ptSLA)
|
if (plater()->printer_technology() == ptSLA)
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
update_editor_menubar();
|
|
||||||
#else
|
|
||||||
update_menubar();
|
update_menubar();
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
void MainFrame::init_gcodeviewer_menubar()
|
void MainFrame::init_menubar_as_gcodeviewer()
|
||||||
{
|
{
|
||||||
wxMenu* fileMenu = new wxMenu;
|
wxMenu* fileMenu = new wxMenu;
|
||||||
{
|
{
|
||||||
@ -1329,9 +1387,11 @@ void MainFrame::init_gcodeviewer_menubar()
|
|||||||
append_menu_item(fileMenu, wxID_ANY, _L("Export &toolpaths as OBJ") + dots, _L("Export toolpaths as OBJ"),
|
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](wxCommandEvent&) { if (m_plater != nullptr) m_plater->export_toolpaths_to_obj(); }, "export_plater", nullptr,
|
||||||
[this]() {return can_export_toolpaths(); }, this);
|
[this]() {return can_export_toolpaths(); }, this);
|
||||||
|
#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
fileMenu->AppendSeparator();
|
fileMenu->AppendSeparator();
|
||||||
append_menu_item(fileMenu, wxID_ANY, _L("Exit &G-code preview"), _L("Switch to editor mode"),
|
append_menu_item(fileMenu, wxID_ANY, _L("Exit &G-code preview"), _L("Switch to editor mode"),
|
||||||
[this](wxCommandEvent&) { set_mode(EMode::Editor); });
|
[this](wxCommandEvent&) { set_mode(EMode::Editor); });
|
||||||
|
#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
fileMenu->AppendSeparator();
|
fileMenu->AppendSeparator();
|
||||||
append_menu_item(fileMenu, wxID_EXIT, _L("&Quit"), wxString::Format(_L("Quit %s"), SLIC3R_APP_NAME),
|
append_menu_item(fileMenu, wxID_EXIT, _L("&Quit"), wxString::Format(_L("Quit %s"), SLIC3R_APP_NAME),
|
||||||
[this](wxCommandEvent&) { Close(false); });
|
[this](wxCommandEvent&) { Close(false); });
|
||||||
@ -1347,13 +1407,37 @@ void MainFrame::init_gcodeviewer_menubar()
|
|||||||
// helpmenu
|
// helpmenu
|
||||||
auto helpMenu = generate_help_menu();
|
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 = new wxMenuBar();
|
||||||
m_gcodeviewer_menubar->Append(fileMenu, _L("&File"));
|
m_gcodeviewer_menubar->Append(fileMenu, _L("&File"));
|
||||||
if ((viewMenu != nullptr))
|
if (viewMenu != nullptr)
|
||||||
m_gcodeviewer_menubar->Append(viewMenu, _L("&View"));
|
m_gcodeviewer_menubar->Append(viewMenu, _L("&View"));
|
||||||
m_gcodeviewer_menubar->Append(helpMenu, _L("&Help"));
|
m_gcodeviewer_menubar->Append(helpMenu, _L("&Help"));
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
// This fixes a bug on Mac OS where the quit command doesn't emit window close events
|
||||||
|
// wx bug: https://trac.wxwidgets.org/ticket/18328
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
wxMenu* apple_menu = m_menubar->OSXGetAppleMenu();
|
||||||
|
#else
|
||||||
|
wxMenu* apple_menu = m_gcodeviewer_menubar->OSXGetAppleMenu();
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
if (apple_menu != nullptr) {
|
||||||
|
apple_menu->Bind(wxEVT_MENU, [this](wxCommandEvent&) {
|
||||||
|
Close();
|
||||||
|
}, wxID_EXIT);
|
||||||
|
}
|
||||||
|
#endif // __APPLE__
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
void MainFrame::set_mode(EMode mode)
|
void MainFrame::set_mode(EMode mode)
|
||||||
{
|
{
|
||||||
if (m_mode == mode)
|
if (m_mode == mode)
|
||||||
@ -1419,7 +1503,7 @@ void MainFrame::set_mode(EMode mode)
|
|||||||
TCHAR szExeFileName[MAX_PATH];
|
TCHAR szExeFileName[MAX_PATH];
|
||||||
GetModuleFileName(nullptr, szExeFileName, MAX_PATH);
|
GetModuleFileName(nullptr, szExeFileName, MAX_PATH);
|
||||||
SetIcon(wxIcon(szExeFileName, wxBITMAP_TYPE_ICO));
|
SetIcon(wxIcon(szExeFileName, wxBITMAP_TYPE_ICO));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
SetIcon(wxIcon(Slic3r::var("PrusaSlicer_128px.png"), wxBITMAP_TYPE_PNG));
|
SetIcon(wxIcon(Slic3r::var("PrusaSlicer_128px.png"), wxBITMAP_TYPE_PNG));
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
@ -1475,11 +1559,11 @@ void MainFrame::set_mode(EMode mode)
|
|||||||
|
|
||||||
m_plater->Thaw();
|
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 ENABLE_GCODE_VIEWER_TASKBAR_ICON
|
||||||
if (m_taskbar_icon != nullptr) {
|
if (m_taskbar_icon != nullptr) {
|
||||||
m_taskbar_icon->RemoveIcon();
|
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
|
#endif // ENABLE_GCODE_VIEWER_TASKBAR_ICON
|
||||||
|
|
||||||
@ -1487,20 +1571,22 @@ void MainFrame::set_mode(EMode mode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
void MainFrame::update_editor_menubar()
|
|
||||||
#else
|
|
||||||
void MainFrame::update_menubar()
|
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;
|
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[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[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[miMaterialTab] ->SetBitmap(create_scaled_bitmap(is_fff ? "spool" : "resin"));
|
||||||
|
|
||||||
m_changeable_menu_items[miPrinterTab] ->SetBitmap(create_scaled_bitmap(is_fff ? "printer" : "sla_printer"));
|
m_changeable_menu_items[miPrinterTab] ->SetBitmap(create_scaled_bitmap(is_fff ? "printer" : "sla_printer"));
|
||||||
@ -1983,6 +2069,11 @@ SettingsDialog::SettingsDialog(MainFrame* mainframe)
|
|||||||
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX | wxMAXIMIZE_BOX, "settings_dialog"),
|
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX | wxMAXIMIZE_BOX, "settings_dialog"),
|
||||||
m_main_frame(mainframe)
|
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__)
|
#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT && defined(__WXMSW__)
|
||||||
// ys_FIXME! temporary workaround for correct font scaling
|
// ys_FIXME! temporary workaround for correct font scaling
|
||||||
// Because of from wxWidgets 3.1.3 auto rescaling is implemented for the Fonts,
|
// Because of from wxWidgets 3.1.3 auto rescaling is implemented for the Fonts,
|
||||||
@ -1993,8 +2084,6 @@ SettingsDialog::SettingsDialog(MainFrame* mainframe)
|
|||||||
#endif // ENABLE_WX_3_1_3_DPI_CHANGED_EVENT
|
#endif // ENABLE_WX_3_1_3_DPI_CHANGED_EVENT
|
||||||
this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
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.
|
// Load the icon either from the exe, or from the ico file.
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
{
|
{
|
||||||
@ -2057,6 +2146,11 @@ SettingsDialog::SettingsDialog(MainFrame* mainframe)
|
|||||||
|
|
||||||
void SettingsDialog::on_dpi_changed(const wxRect& suggested_rect)
|
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 int& em = em_unit();
|
||||||
const wxSize& size = wxSize(85 * em, 50 * em);
|
const wxSize& size = wxSize(85 * em, 50 * em);
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ class SettingsDialog : public DPIDialog
|
|||||||
MainFrame* m_main_frame { nullptr };
|
MainFrame* m_main_frame { nullptr };
|
||||||
public:
|
public:
|
||||||
SettingsDialog(MainFrame* mainframe);
|
SettingsDialog(MainFrame* mainframe);
|
||||||
~SettingsDialog() {}
|
~SettingsDialog() = default;
|
||||||
void set_tabpanel(wxNotebook* tabpanel) { m_tabpanel = tabpanel; }
|
void set_tabpanel(wxNotebook* tabpanel) { m_tabpanel = tabpanel; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -72,6 +72,9 @@ class MainFrame : public DPIFrame
|
|||||||
wxString m_qs_last_output_file = wxEmptyString;
|
wxString m_qs_last_output_file = wxEmptyString;
|
||||||
wxString m_last_config = wxEmptyString;
|
wxString m_last_config = wxEmptyString;
|
||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
wxMenuBar* m_menubar{ nullptr };
|
||||||
|
#else
|
||||||
wxMenuBar* m_editor_menubar{ nullptr };
|
wxMenuBar* m_editor_menubar{ nullptr };
|
||||||
wxMenuBar* m_gcodeviewer_menubar{ nullptr };
|
wxMenuBar* m_gcodeviewer_menubar{ nullptr };
|
||||||
|
|
||||||
@ -83,6 +86,7 @@ class MainFrame : public DPIFrame
|
|||||||
};
|
};
|
||||||
|
|
||||||
RestoreFromGCodeViewer m_restore_from_gcode_viewer;
|
RestoreFromGCodeViewer m_restore_from_gcode_viewer;
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@ -146,6 +150,7 @@ class MainFrame : public DPIFrame
|
|||||||
ESettingsLayout m_layout{ ESettingsLayout::Unknown };
|
ESettingsLayout m_layout{ ESettingsLayout::Unknown };
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
public:
|
public:
|
||||||
enum class EMode : unsigned char
|
enum class EMode : unsigned char
|
||||||
{
|
{
|
||||||
@ -155,6 +160,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
EMode m_mode{ EMode::Editor };
|
EMode m_mode{ EMode::Editor };
|
||||||
|
#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -182,16 +188,17 @@ public:
|
|||||||
void create_preset_tabs();
|
void create_preset_tabs();
|
||||||
void add_created_tab(Tab* panel);
|
void add_created_tab(Tab* panel);
|
||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
void init_editor_menubar();
|
void init_menubar_as_editor();
|
||||||
void update_editor_menubar();
|
void init_menubar_as_gcodeviewer();
|
||||||
void init_gcodeviewer_menubar();
|
|
||||||
|
|
||||||
|
#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
EMode get_mode() const { return m_mode; }
|
EMode get_mode() const { return m_mode; }
|
||||||
void set_mode(EMode mode);
|
void set_mode(EMode mode);
|
||||||
|
#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
#else
|
#else
|
||||||
void init_menubar();
|
void init_menubar();
|
||||||
void update_menubar();
|
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
|
void update_menubar();
|
||||||
|
|
||||||
void update_ui_from_settings();
|
void update_ui_from_settings();
|
||||||
bool is_loaded() const { return m_loaded; }
|
bool is_loaded() const { return m_loaded; }
|
||||||
|
@ -1369,41 +1369,52 @@ bool PlaterDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &fi
|
|||||||
this->MSWUpdateDragImageOnLeave();
|
this->MSWUpdateDragImageOnLeave();
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
|
|
||||||
// gcode section
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
for (const auto& filename : filenames) {
|
if (wxGetApp().is_gcode_viewer()) {
|
||||||
fs::path path(into_path(filename));
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
if (std::regex_match(path.string(), pattern_gcode_drop))
|
// gcode section
|
||||||
paths.push_back(std::move(path));
|
for (const auto& filename : filenames) {
|
||||||
}
|
fs::path path(into_path(filename));
|
||||||
|
if (std::regex_match(path.string(), pattern_gcode_drop))
|
||||||
if (paths.size() > 1) {
|
paths.push_back(std::move(path));
|
||||||
wxMessageDialog((wxWindow*)plater, _L("You can open only one .gcode file at a time."),
|
|
||||||
wxString(SLIC3R_APP_NAME) + " - " + _L("Drag and drop G-code file"), wxCLOSE | wxICON_WARNING | wxCENTRE).ShowModal();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (paths.size() == 1) {
|
|
||||||
if (wxGetApp().mainframe->get_mode() == MainFrame::EMode::GCodeViewer) {
|
|
||||||
plater->load_gcode(from_path(paths.front()));
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
if (wxMessageDialog((wxWindow*)plater, _L("Do you want to switch to G-code preview ?"),
|
|
||||||
wxString(SLIC3R_APP_NAME) + " - " + _L("Drag and drop G-code file"), wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT | wxCENTRE).ShowModal() == wxID_YES) {
|
|
||||||
|
|
||||||
if (plater->model().objects.empty() ||
|
if (paths.size() > 1) {
|
||||||
wxMessageDialog((wxWindow*)plater, _L("Switching to G-code preview mode will remove all objects, continue?"),
|
wxMessageDialog((wxWindow*)plater, _L("You can open only one .gcode file at a time."),
|
||||||
wxString(SLIC3R_APP_NAME) + " - " + _L("Switch to G-code preview mode"), wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT | wxCENTRE).ShowModal() == wxID_YES) {
|
wxString(SLIC3R_APP_NAME) + " - " + _L("Drag and drop G-code file"), wxCLOSE | wxICON_WARNING | wxCENTRE).ShowModal();
|
||||||
wxGetApp().mainframe->set_mode(MainFrame::EMode::GCodeViewer);
|
|
||||||
plater->load_gcode(from_path(paths.front()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else if (paths.size() == 1) {
|
||||||
|
#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
if (wxGetApp().mainframe->get_mode() == MainFrame::EMode::GCodeViewer) {
|
||||||
|
#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
plater->load_gcode(from_path(paths.front()));
|
||||||
|
return true;
|
||||||
|
#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (wxMessageDialog((wxWindow*)plater, _L("Do you want to switch to G-code preview ?"),
|
||||||
|
wxString(SLIC3R_APP_NAME) + " - " + _L("Drag and drop G-code file"), wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT | wxCENTRE).ShowModal() == wxID_YES) {
|
||||||
|
|
||||||
|
if (plater->model().objects.empty() ||
|
||||||
|
wxMessageDialog((wxWindow*)plater, _L("Switching to G-code preview mode will remove all objects, continue?"),
|
||||||
|
wxString(SLIC3R_APP_NAME) + " - " + _L("Switch to G-code preview mode"), wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT | wxCENTRE).ShowModal() == wxID_YES) {
|
||||||
|
wxGetApp().mainframe->set_mode(MainFrame::EMode::GCodeViewer);
|
||||||
|
plater->load_gcode(from_path(paths.front()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
}
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif //ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
|
|
||||||
// model section
|
// editor section
|
||||||
for (const auto &filename : filenames) {
|
for (const auto &filename : filenames) {
|
||||||
fs::path path(into_path(filename));
|
fs::path path(into_path(filename));
|
||||||
if (std::regex_match(path.string(), pattern_drop))
|
if (std::regex_match(path.string(), pattern_drop))
|
||||||
@ -1413,6 +1424,7 @@ bool PlaterDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &fi
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
#if !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
if (wxGetApp().mainframe->get_mode() == MainFrame::EMode::GCodeViewer) {
|
if (wxGetApp().mainframe->get_mode() == MainFrame::EMode::GCodeViewer) {
|
||||||
if (wxMessageDialog((wxWindow*)plater, _L("Do you want to exit G-code preview ?"),
|
if (wxMessageDialog((wxWindow*)plater, _L("Do you want to exit G-code preview ?"),
|
||||||
wxString(SLIC3R_APP_NAME) + " - " + _L("Drag and drop model file"), wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT | wxCENTRE).ShowModal() == wxID_YES)
|
wxString(SLIC3R_APP_NAME) + " - " + _L("Drag and drop model file"), wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT | wxCENTRE).ShowModal() == wxID_YES)
|
||||||
@ -1420,6 +1432,7 @@ bool PlaterDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &fi
|
|||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif // !ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
|
|
||||||
wxString snapshot_label;
|
wxString snapshot_label;
|
||||||
@ -1970,7 +1983,13 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
|||||||
q->SetDropTarget(new PlaterDropTarget(q)); // if my understanding is right, wxWindow takes the owenership
|
q->SetDropTarget(new PlaterDropTarget(q)); // if my understanding is right, wxWindow takes the owenership
|
||||||
q->Layout();
|
q->Layout();
|
||||||
|
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
set_current_panel(wxGetApp().is_editor() ? (wxPanel*)view3D : (wxPanel*)preview);
|
||||||
|
if (wxGetApp().is_gcode_viewer())
|
||||||
|
preview->hide_layers_slider();
|
||||||
|
#else
|
||||||
set_current_panel(view3D);
|
set_current_panel(view3D);
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
|
||||||
// updates camera type from .ini file
|
// updates camera type from .ini file
|
||||||
camera.set_type(get_config("use_perspective_camera"));
|
camera.set_type(get_config("use_perspective_camera"));
|
||||||
@ -1990,33 +2009,38 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
|||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
notification_manager = new NotificationManager(this->q);
|
notification_manager = new NotificationManager(this->q);
|
||||||
this->q->Bind(EVT_EJECT_DRIVE_NOTIFICAION_CLICKED, [this](EjectDriveNotificationClickedEvent&) { this->q->eject_drive(); });
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
this->q->Bind(EVT_EXPORT_GCODE_NOTIFICAION_CLICKED, [this](ExportGcodeNotificationClickedEvent&) { this->q->export_gcode(true); });
|
if (wxGetApp().is_editor()) {
|
||||||
this->q->Bind(EVT_PRESET_UPDATE_AVIABLE_CLICKED, [this](PresetUpdateAviableClickedEvent&) { wxGetApp().get_preset_updater()->on_update_notification_confirm(); });
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
this->q->Bind(EVT_EJECT_DRIVE_NOTIFICAION_CLICKED, [this](EjectDriveNotificationClickedEvent&) { this->q->eject_drive(); });
|
||||||
this->q->Bind(EVT_REMOVABLE_DRIVE_EJECTED, [this, q](RemovableDriveEjectEvent &evt) {
|
this->q->Bind(EVT_EXPORT_GCODE_NOTIFICAION_CLICKED, [this](ExportGcodeNotificationClickedEvent&) { this->q->export_gcode(true); });
|
||||||
if (evt.data.second) {
|
this->q->Bind(EVT_PRESET_UPDATE_AVIABLE_CLICKED, [this](PresetUpdateAviableClickedEvent&) { wxGetApp().get_preset_updater()->on_update_notification_confirm(); });
|
||||||
this->show_action_buttons(this->ready_to_slice);
|
this->q->Bind(EVT_REMOVABLE_DRIVE_EJECTED, [this, q](RemovableDriveEjectEvent &evt) {
|
||||||
notification_manager->push_notification(format(_L("Unmounting successful. The device %s(%s) can now be safely removed from the computer."),evt.data.first.name, evt.data.first.path),
|
if (evt.data.second) {
|
||||||
NotificationManager::NotificationLevel::RegularNotification, *q->get_current_canvas3D());
|
this->show_action_buttons(this->ready_to_slice);
|
||||||
} else {
|
notification_manager->push_notification(format(_L("Unmounting successful. The device %s(%s) can now be safely removed from the computer."),evt.data.first.name, evt.data.first.path),
|
||||||
notification_manager->push_notification(format(_L("Ejecting of device %s(%s) has failed."), evt.data.first.name, evt.data.first.path),
|
NotificationManager::NotificationLevel::RegularNotification, *q->get_current_canvas3D());
|
||||||
NotificationManager::NotificationLevel::ErrorNotification, *q->get_current_canvas3D());
|
} else {
|
||||||
}
|
notification_manager->push_notification(format(_L("Ejecting of device %s(%s) has failed."), evt.data.first.name, evt.data.first.path),
|
||||||
});
|
NotificationManager::NotificationLevel::ErrorNotification, *q->get_current_canvas3D());
|
||||||
this->q->Bind(EVT_REMOVABLE_DRIVES_CHANGED, [this, q](RemovableDrivesChangedEvent &) {
|
}
|
||||||
this->show_action_buttons(this->ready_to_slice);
|
});
|
||||||
if (!this->sidebar->get_eject_shown()) {
|
this->q->Bind(EVT_REMOVABLE_DRIVES_CHANGED, [this, q](RemovableDrivesChangedEvent &) {
|
||||||
notification_manager->close_notification_of_type(NotificationType::ExportToRemovableFinished);
|
this->show_action_buttons(this->ready_to_slice);
|
||||||
}
|
if (!this->sidebar->get_eject_shown()) {
|
||||||
});
|
notification_manager->close_notification_of_type(NotificationType::ExportToRemovableFinished);
|
||||||
// Start the background thread and register this window as a target for update events.
|
}
|
||||||
wxGetApp().removable_drive_manager()->init(this->q);
|
});
|
||||||
|
// Start the background thread and register this window as a target for update events.
|
||||||
|
wxGetApp().removable_drive_manager()->init(this->q);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Trigger enumeration of removable media on Win32 notification.
|
// Trigger enumeration of removable media on Win32 notification.
|
||||||
this->q->Bind(EVT_VOLUME_ATTACHED, [this](VolumeAttachedEvent &evt) { wxGetApp().removable_drive_manager()->volumes_changed(); });
|
this->q->Bind(EVT_VOLUME_ATTACHED, [this](VolumeAttachedEvent &evt) { wxGetApp().removable_drive_manager()->volumes_changed(); });
|
||||||
this->q->Bind(EVT_VOLUME_DETACHED, [this](VolumeDetachedEvent &evt) { wxGetApp().removable_drive_manager()->volumes_changed(); });
|
this->q->Bind(EVT_VOLUME_DETACHED, [this](VolumeDetachedEvent &evt) { wxGetApp().removable_drive_manager()->volumes_changed(); });
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
}
|
||||||
|
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
|
||||||
|
|
||||||
// Initialize the Undo / Redo stack with a first snapshot.
|
// Initialize the Undo / Redo stack with a first snapshot.
|
||||||
this->take_snapshot(_L("New Project"));
|
this->take_snapshot(_L("New Project"));
|
||||||
@ -5629,11 +5653,7 @@ void Plater::set_printer_technology(PrinterTechnology printer_technology)
|
|||||||
p->label_btn_send = printer_technology == ptFFF ? L("Send G-code") : L("Send to printer");
|
p->label_btn_send = printer_technology == ptFFF ? L("Send G-code") : L("Send to printer");
|
||||||
|
|
||||||
if (wxGetApp().mainframe != nullptr)
|
if (wxGetApp().mainframe != nullptr)
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
wxGetApp().mainframe->update_editor_menubar();
|
|
||||||
#else
|
|
||||||
wxGetApp().mainframe->update_menubar();
|
wxGetApp().mainframe->update_menubar();
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
p->update_main_toolbar_tooltips();
|
p->update_main_toolbar_tooltips();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user