From b8202e62f7417a86666e09f36e9a09d3b0f2549f Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Mon, 15 Mar 2021 14:52:57 +0100 Subject: [PATCH] Moved Platform.cpp/hpp to libslic3r --- src/PrusaSlicer.cpp | 3 +++ src/libslic3r/CMakeLists.txt | 2 ++ src/{slic3r/Utils => libslic3r}/Platform.cpp | 8 -------- src/{slic3r/Utils => libslic3r}/Platform.hpp | 9 +++------ src/slic3r/CMakeLists.txt | 2 -- src/slic3r/GUI/GUI_Init.cpp | 3 --- src/slic3r/GUI/OpenGLManager.cpp | 5 +++-- src/slic3r/GUI/Plater.cpp | 5 +++-- src/slic3r/GUI/RemovableDriveManager.cpp | 6 +++--- 9 files changed, 17 insertions(+), 26 deletions(-) rename src/{slic3r/Utils => libslic3r}/Platform.cpp (92%) rename src/{slic3r/Utils => libslic3r}/Platform.hpp (80%) diff --git a/src/PrusaSlicer.cpp b/src/PrusaSlicer.cpp index ed2d702728..10da1cb071 100644 --- a/src/PrusaSlicer.cpp +++ b/src/PrusaSlicer.cpp @@ -38,6 +38,7 @@ #include "libslic3r/GCode/PostProcessor.hpp" #include "libslic3r/Model.hpp" #include "libslic3r/ModelArrange.hpp" +#include "libslic3r/Platform.hpp" #include "libslic3r/Print.hpp" #include "libslic3r/SLAPrint.hpp" #include "libslic3r/TriangleMesh.hpp" @@ -68,6 +69,8 @@ int CLI::run(int argc, char **argv) { // Mark the main thread for the debugger and for runtime checks. set_current_thread_name("slic3r_main"); + // Detect the operating system flavor. + detect_platform(); #ifdef __WXGTK__ // On Linux, wxGTK has no support for Wayland, and the app crashes on diff --git a/src/libslic3r/CMakeLists.txt b/src/libslic3r/CMakeLists.txt index 6159b2c5c3..4a762f7e15 100644 --- a/src/libslic3r/CMakeLists.txt +++ b/src/libslic3r/CMakeLists.txt @@ -141,6 +141,8 @@ add_library(libslic3r STATIC PerimeterGenerator.hpp PlaceholderParser.cpp PlaceholderParser.hpp + Platform.cpp + Platform.hpp Point.cpp Point.hpp Polygon.cpp diff --git a/src/slic3r/Utils/Platform.cpp b/src/libslic3r/Platform.cpp similarity index 92% rename from src/slic3r/Utils/Platform.cpp rename to src/libslic3r/Platform.cpp index 3d101d6628..4c88051490 100644 --- a/src/slic3r/Utils/Platform.cpp +++ b/src/libslic3r/Platform.cpp @@ -1,15 +1,8 @@ #include "Platform.hpp" - -// For starting another PrusaSlicer instance on OSX. -// Fails to compile on Windows on the build server. - -#include - #include namespace Slic3r { -namespace GUI { static auto s_platform = Platform::Uninitialized; static auto s_platform_flavor = PlatformFlavor::Uninitialized; @@ -74,5 +67,4 @@ PlatformFlavor platform_flavor() return s_platform_flavor; } -} // namespace GUI } // namespace Slic3r diff --git a/src/slic3r/Utils/Platform.hpp b/src/libslic3r/Platform.hpp similarity index 80% rename from src/slic3r/Utils/Platform.hpp rename to src/libslic3r/Platform.hpp index c0ee3541df..735728e89a 100644 --- a/src/slic3r/Utils/Platform.hpp +++ b/src/libslic3r/Platform.hpp @@ -1,8 +1,7 @@ -#ifndef SLIC3R_GUI_Utils_Platform_HPP -#define SLIC3R_GUI_Utils_Platform_HPP +#ifndef SLIC3R_Platform_HPP +#define SLIC3R_Platform_HPP namespace Slic3r { -namespace GUI { enum class Platform { @@ -37,8 +36,6 @@ void detect_platform(); Platform platform(); PlatformFlavor platform_flavor(); - -} // namespace GUI } // namespace Slic3r -#endif // SLIC3R_GUI_Utils_Platform_HPP +#endif // SLIC3R_Platform_HPP diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index 6436de2ca8..4b3a1c6ca9 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -209,8 +209,6 @@ set(SLIC3R_GUI_SOURCES Utils/Bonjour.hpp Utils/PresetUpdater.cpp Utils/PresetUpdater.hpp - Utils/Platform.cpp - Utils/Platform.hpp Utils/Process.cpp Utils/Process.hpp Utils/Profile.hpp diff --git a/src/slic3r/GUI/GUI_Init.cpp b/src/slic3r/GUI/GUI_Init.cpp index 3c77f33358..839782741f 100644 --- a/src/slic3r/GUI/GUI_Init.cpp +++ b/src/slic3r/GUI/GUI_Init.cpp @@ -9,7 +9,6 @@ #include "slic3r/GUI/format.hpp" #include "slic3r/GUI/MainFrame.hpp" #include "slic3r/GUI/Plater.hpp" -#include "slic3r/Utils/Platform.hpp" // To show a message box if GUI initialization ends up with an exception thrown. #include @@ -37,8 +36,6 @@ int GUI_Run(GUI_InitParams ¶ms) signal(SIGCHLD, SIG_DFL); #endif // __APPLE__ - detect_platform(); - try { GUI::GUI_App* gui = new GUI::GUI_App(params.start_as_gcodeviewer ? GUI::GUI_App::EAppMode::GCodeViewer : GUI::GUI_App::EAppMode::Editor); if (gui->get_app_mode() != GUI::GUI_App::EAppMode::GCodeViewer) { diff --git a/src/slic3r/GUI/OpenGLManager.cpp b/src/slic3r/GUI/OpenGLManager.cpp index 8e87740360..c843da4600 100644 --- a/src/slic3r/GUI/OpenGLManager.cpp +++ b/src/slic3r/GUI/OpenGLManager.cpp @@ -4,7 +4,8 @@ #include "GUI.hpp" #include "I18N.hpp" #include "3DScene.hpp" -#include "slic3r/Utils/Platform.hpp" + +#include "libslic3r/Platform.hpp" #include @@ -324,7 +325,7 @@ void OpenGLManager::detect_multisample(int* attribList) enable_multisample && // Disable multi-sampling on ChromeOS, as the OpenGL virtualization swaps Red/Blue channels with multi-sampling enabled, // at least on some platforms. - (platform() != Platform::Linux || platform_flavor() != PlatformFlavor::LinuxOnChromium) && + platform_flavor() != PlatformFlavor::LinuxOnChromium && wxGLCanvas::IsDisplaySupported(attribList) ? EMultisampleState::Enabled : EMultisampleState::Disabled; // Alternative method: it was working on previous version of wxWidgets but not with the latest, at least on Windows diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 15e89168a3..273f39b1e2 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -76,7 +76,6 @@ #include "../Utils/FixModelByWin10.hpp" #include "../Utils/UndoRedo.hpp" #include "../Utils/PresetUpdater.hpp" -#include "../Utils/Platform.hpp" #include "../Utils/Process.hpp" #include "RemovableDriveManager.hpp" #include "InstanceCheck.hpp" @@ -89,7 +88,9 @@ #include // Needs to be last because reasons :-/ #include "WipeTowerDialog.hpp" + #include "libslic3r/CustomGCode.hpp" +#include "libslic3r/Platform.hpp" using boost::optional; namespace fs = boost::filesystem; @@ -3660,7 +3661,7 @@ void Plater::priv::on_process_completed(SlicingProcessCompletedEvent &evt) show_action_buttons(false); notification_manager->push_exporting_finished_notification(last_output_path, last_output_dir_path, // Don't offer the "Eject" button on ChromeOS, the Linux side has no control over it. - platform() != Platform::Linux || platform_flavor() != PlatformFlavor::LinuxOnChromium); + platform_flavor() != PlatformFlavor::LinuxOnChromium); wxGetApp().removable_drive_manager()->set_exporting_finished(true); }else if (exporting_status == ExportingStatus::EXPORTING_TO_LOCAL && !has_error) notification_manager->push_exporting_finished_notification(last_output_path, last_output_dir_path, false); diff --git a/src/slic3r/GUI/RemovableDriveManager.cpp b/src/slic3r/GUI/RemovableDriveManager.cpp index c200956e19..33e61ab90f 100644 --- a/src/slic3r/GUI/RemovableDriveManager.cpp +++ b/src/slic3r/GUI/RemovableDriveManager.cpp @@ -1,5 +1,5 @@ #include "RemovableDriveManager.hpp" -#include "slic3r/Utils/Platform.hpp" +#include "libslic3r/Platform.hpp" #include #include @@ -232,7 +232,7 @@ std::vector RemovableDriveManager::search_for_removable_drives() cons #else - if (platform() == Platform::Linux && platform_flavor() == PlatformFlavor::LinuxOnChromium) { + if (platform_flavor() == PlatformFlavor::LinuxOnChromium) { // ChromeOS specific: search /mnt/chromeos/removable/* folder search_for_drives_internal::search_path("/mnt/chromeos/removable/*", "/mnt/chromeos/removable", current_drives); } else { @@ -452,7 +452,7 @@ RemovableDriveManager::RemovableDrivesStatus RemovableDriveManager::status() tbb::mutex::scoped_lock lock(m_drives_mutex); out.has_eject = // Cannot control eject on Chromium. - (platform() != Platform::Linux || platform_flavor() != PlatformFlavor::LinuxOnChromium) && + platform_flavor() != PlatformFlavor::LinuxOnChromium && this->find_last_save_path_drive_data() != m_current_drives.end(); out.has_removable_drives = ! m_current_drives.empty(); }