From 6fc98f05efbe6b61bc8102ea37b9a3453a5d2333 Mon Sep 17 00:00:00 2001 From: test Date: Tue, 6 Oct 2020 14:23:17 +0200 Subject: [PATCH 1/3] OSX specific: Trying to detect opening of files through Finder at the application start to switch to G-code viewer --- src/slic3r/GUI/GUI_App.cpp | 19 +++++++++++++++++++ src/slic3r/GUI/GUI_App.hpp | 1 + 2 files changed, 20 insertions(+) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 5312a0fce..3e63ee3fc 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1626,6 +1626,25 @@ bool GUI_App::OnExceptionInMainLoop() } #ifdef __APPLE__ +void GUI_App::OSXStoreOpenFiles(const wxArrayString &fileNames) +{ + wxArrayString other_files; + std::vector gcode_files; + const std::regex pattern_gcode_drop(".*[.](gcode|g)", std::regex::icase); + for (const auto& filename : fileNames) { + boost::filesystem::path path(into_path(filename)); + if (std::regex_match(path.string(), pattern_gcode_drop)) + gcode_files.emplace_back(filename); + else + other_files.Add(filename); + } + if (! gcode_files.empty()) { + // Drag & Dropping a G-code onto PrusaSlicer. Switch PrusaSlicer to G-code viewer mode. + //FIXME Switch application to G-code viewer mode? + wxMessageBox("PrusaSlicer on early startup", wxString::Format("Switching to G-code viewer for %s", gcode_files.front()), wxICON_INFORMATION); + } + wxApp::OSXStoreOpenFiles(other_files); +} void GUI_App::MacNewFile() { m_mac_initialized = true; diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 53eef2518..836378d70 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -250,6 +250,7 @@ public: virtual bool OnExceptionInMainLoop() override; #ifdef __APPLE__ + void OSXStoreOpenFiles(const wxArrayString &files) override; // Called if there is no file to open. void MacNewFile(); // wxWidgets override to get an event on open files. From c4951c5efc8c930b7bb97f8d1c39a2ab4b663ebe Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 6 Oct 2020 12:27:58 +0200 Subject: [PATCH 2/3] Fix of a modifier transparency problem in painting gizmos --- src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp index f4e17d44c..88593776d 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp @@ -177,6 +177,7 @@ void GLGizmoPainterBase::render_cursor_circle() const glsafe(::glPopAttrib()); glsafe(::glPopMatrix()); + glsafe(::glEnable(GL_DEPTH_TEST)); } From eed45eddd6cb42a37ce722381904622eedcbe4df Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Tue, 6 Oct 2020 15:09:38 +0200 Subject: [PATCH 3/3] OSX specific: Switching to a G-code viewer if the Finder opens Slicer with a G-code file argument. --- src/slic3r/GUI/GUI_App.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 3e63ee3fc..3dd3b3519 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1626,6 +1626,9 @@ bool GUI_App::OnExceptionInMainLoop() } #ifdef __APPLE__ +// This callback is called from wxEntry()->wxApp::CallOnInit()->NSApplication run +// that is, before GUI_App::OnInit(), so we have a chance to switch GUI_App +// to a G-code viewer. void GUI_App::OSXStoreOpenFiles(const wxArrayString &fileNames) { wxArrayString other_files; @@ -1642,6 +1645,7 @@ void GUI_App::OSXStoreOpenFiles(const wxArrayString &fileNames) // Drag & Dropping a G-code onto PrusaSlicer. Switch PrusaSlicer to G-code viewer mode. //FIXME Switch application to G-code viewer mode? wxMessageBox("PrusaSlicer on early startup", wxString::Format("Switching to G-code viewer for %s", gcode_files.front()), wxICON_INFORMATION); + m_app_mode = EAppMode::GCodeViewer; } wxApp::OSXStoreOpenFiles(other_files); } @@ -1671,9 +1675,12 @@ void GUI_App::MacOpenFiles(const wxArrayString &fileNames) start_new_gcodeviewer(&filename); } else if (! gcode_files.empty()) { assert(! m_mac_initialized); + assert(m_app_mode == EAppMode::GCodeViewer); // Drag & Dropping a G-code onto PrusaSlicer. Switch PrusaSlicer to G-code viewer mode. //FIXME Switch application to G-code viewer mode? wxMessageBox("PrusaSlicer on startup", wxString::Format("Switching to G-code viewer for %s", gcode_files.front()), wxICON_INFORMATION); + // Load the G-code into the G-code viewer. + this->plater()->load_gcode(paths.front()); } m_mac_initialized = true; }