diff --git a/CMakeLists.txt b/CMakeLists.txt index 04e023c09..76c937cae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,7 @@ endif() option(SLIC3R_STATIC "Compile Slic3r with static libraries (Boost, TBB, glew)" ${SLIC3R_STATIC_INITIAL}) option(SLIC3R_GUI "Compile Slic3r with GUI components (OpenGL, wxWidgets)" 1) option(SLIC3R_FHS "Assume Slic3r is to be installed in a FHS directory structure" 0) +option(SLIC3R_WX_STABLE "Build against wxWidgets stable (3.0) as oppsed to dev (3.1) on Linux" 0) option(SLIC3R_PROFILE "Compile Slic3r with an invasive Shiny profiler" 0) option(SLIC3R_MSVC_COMPILE_PARALLEL "Compile on Visual Studio in parallel" 1) option(SLIC3R_MSVC_PDB "Generate PDB files on MSVC in Release mode" 1) diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index 1b23c5864..386320d81 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -33,6 +33,7 @@ endif () set(DESTDIR "${CMAKE_CURRENT_BINARY_DIR}/destdir" CACHE PATH "Destination directory") option(DEP_DEBUG "Build debug variants (only applicable on Windows)" ON) +option(DEP_WX_STABLE "Build against wxWidgets stable 3.0 as opposed to default 3.1 (Linux only)" OFF) message(STATUS "Slic3r deps DESTDIR: ${DESTDIR}") message(STATUS "Slic3r deps debug build: ${DEP_DEBUG}") diff --git a/deps/deps-linux.cmake b/deps/deps-linux.cmake index 3f504b400..bf39f59e7 100644 --- a/deps/deps-linux.cmake +++ b/deps/deps-linux.cmake @@ -88,16 +88,24 @@ ExternalProject_Add(dep_libcurl INSTALL_COMMAND make install "DESTDIR=${DESTDIR}" ) +if (DEP_WX_STABLE) + set(DEP_WX_URL "https://github.com/wxWidgets/wxWidgets/releases/download/v3.0.4/wxWidgets-3.0.4.tar.bz2") + set(DEP_WX_HASH "SHA256=96157f988d261b7368e5340afa1a0cad943768f35929c22841f62c25b17bf7f0") +else () + set(DEP_WX_URL "https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.1/wxWidgets-3.1.1.tar.bz2") + set(DEP_WX_HASH "SHA256=c925dfe17e8f8b09eb7ea9bfdcfcc13696a3e14e92750effd839f5e10726159e") +endif() + ExternalProject_Add(dep_wxwidgets EXCLUDE_FROM_ALL 1 - URL "https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.1/wxWidgets-3.1.1.tar.bz2" - URL_HASH SHA256=c925dfe17e8f8b09eb7ea9bfdcfcc13696a3e14e92750effd839f5e10726159e + URL "${DEP_WX_URL}" + URL_HASH "${DEP_WX_HASH}" BUILD_IN_SOURCE 1 PATCH_COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/wxwidgets-pngprefix.h" src/png/pngprefix.h CONFIGURE_COMMAND ./configure "--prefix=${DESTDIR}/usr/local" --disable-shared - --with-gtk=2 + --with-gtk=2 --with-opengl --enable-unicode --enable-graphics_ctx diff --git a/doc/How to build - Windows.md b/doc/How to build - Windows.md index 898c830d0..90fcfde7d 100644 --- a/doc/How to build - Windows.md +++ b/doc/How to build - Windows.md @@ -7,7 +7,7 @@ CMake installer can be downloaded from [the official website](https://cmake.org/ Building with newer versions of MSVS (2015, 2017) may work too as reported by some of our users. -_Note:_ Thanks to **@supermerill** for testing and inspiration on this guide. +_Note:_ Thanks to [**@supermerill**](https://github.com/supermerill) for testing and inspiration on this guide. ### Dependencies diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fa043cf9e..fd5a735d7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -59,7 +59,19 @@ if (SLIC3R_GUI) endif() endif() - find_package(wxWidgets REQUIRED COMPONENTS base core adv html gl) + if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + if (SLIC3R_WX_STABLE) + find_package(wxWidgets 3.0 REQUIRED COMPONENTS base core adv html gl) + else () + find_package(wxWidgets 3.1 QUIET COMPONENTS base core adv html gl) + if (NOT wxWidgets_FOUND) + message(FATAL_ERROR "\nCould not find wxWidgets 3.1.\nHint: On Linux you can set -DSLIC3R_WX_STABLE=1 to use wxWidgets 3.0") + endif () + endif () + else () + find_package(wxWidgets 3.1 REQUIRED COMPONENTS base core adv html gl) + endif () + include(${wxWidgets_USE_FILE}) endif() diff --git a/src/slic3r/GUI/GLTexture.cpp b/src/slic3r/GUI/GLTexture.cpp index 0ac7e983e..292ef472a 100644 --- a/src/slic3r/GUI/GLTexture.cpp +++ b/src/slic3r/GUI/GLTexture.cpp @@ -36,7 +36,7 @@ bool GLTexture::load_from_file(const std::string& filename, bool generate_mipmap // Load a PNG with an alpha channel. wxImage image; - if (!image.LoadFile(wxString::FromUTF8(filename), wxBITMAP_TYPE_PNG)) + if (!image.LoadFile(wxString::FromUTF8(filename.c_str()), wxBITMAP_TYPE_PNG)) { reset(); return false; diff --git a/src/slic3r/GUI/GUI.cpp b/src/slic3r/GUI/GUI.cpp index 6cdb2ab7e..bb5ab29e0 100644 --- a/src/slic3r/GUI/GUI.cpp +++ b/src/slic3r/GUI/GUI.cpp @@ -234,7 +234,7 @@ void show_error(wxWindow* parent, const wxString& message) void show_error_id(int id, const std::string& message) { auto *parent = id != 0 ? wxWindow::FindWindowById(id) : nullptr; - show_error(parent, wxString::FromUTF8(message.data())); + show_error(parent, from_u8(message)); } void show_info(wxWindow* parent, const wxString& message, const wxString& title) @@ -324,7 +324,7 @@ wxString from_path(const boost::filesystem::path &path) #ifdef _WIN32 return wxString(path.string()); #else - return wxString::FromUTF8(path.string()); + return from_u8(path.string()); #endif } @@ -405,7 +405,7 @@ void desktop_open_datadir_folder() const auto path = data_dir(); #ifdef _WIN32 - const auto widepath = wxString::FromUTF8(path.data()); + const wxString widepath = from_u8(path); const wchar_t *argv[] = { L"explorer", widepath.GetData(), nullptr }; ::wxExecute(const_cast(argv), wxEXEC_ASYNC, nullptr); #elif __APPLE__ diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index c1ef3e10d..1eaa6ccc2 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -67,7 +67,7 @@ wxString file_wildcards(FileType file_type, const std::string &custom_extension) out += std::string(";*") + custom_extension; } } - return wxString::FromUTF8(out.c_str()); + return from_u8(out); } static std::string libslic3r_translate_callback(const char *s) { return wxGetTranslation(wxString(s, wxConvUTF8)).utf8_str().data(); } @@ -464,7 +464,7 @@ bool GUI_App::select_language( wxArrayString & names, { m_wxLocale = new wxLocale; m_wxLocale->Init(identifiers[index]); - m_wxLocale->AddCatalogLookupPathPrefix(wxString::FromUTF8(localization_dir())); + m_wxLocale->AddCatalogLookupPathPrefix(from_u8(localization_dir())); m_wxLocale->AddCatalog(/*GetAppName()*/"Slic3rPE"); //FIXME This is a temporary workaround, the correct solution is to switch to "C" locale during file import / export only. wxSetlocale(LC_NUMERIC, "C"); @@ -492,7 +492,7 @@ bool GUI_App::load_language() { m_wxLocale = new wxLocale; m_wxLocale->Init(identifiers[i]); - m_wxLocale->AddCatalogLookupPathPrefix(wxString::FromUTF8(localization_dir())); + m_wxLocale->AddCatalogLookupPathPrefix(from_u8(localization_dir())); m_wxLocale->AddCatalog(/*GetAppName()*/"Slic3rPE"); //FIXME This is a temporary workaround, the correct solution is to switch to "C" locale during file import / export only. wxSetlocale(LC_NUMERIC, "C"); @@ -520,7 +520,7 @@ void GUI_App::get_installed_languages(wxArrayString & names, wxArrayLong & ident names.Clear(); identifiers.Clear(); - wxDir dir(wxString::FromUTF8(localization_dir())); + wxDir dir(from_u8(localization_dir())); wxString filename; const wxLanguageInfo * langinfo; wxString name = wxLocale::GetLanguageName(wxLANGUAGE_DEFAULT); diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp index 61aee6a67..e78917312 100644 --- a/src/slic3r/GUI/wxExtensions.cpp +++ b/src/slic3r/GUI/wxExtensions.cpp @@ -9,9 +9,12 @@ #include #include "BitmapCache.hpp" +#include "GUI.hpp" #include "GUI_App.hpp" #include "GUI_ObjectList.hpp" +using Slic3r::GUI::from_u8; + wxDEFINE_EVENT(wxCUSTOMEVT_TICKSCHANGED, wxEvent); wxDEFINE_EVENT(wxCUSTOMEVT_LAST_VOLUME_IS_DELETED, wxCommandEvent); @@ -37,7 +40,7 @@ wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const wxString& description, std::function cb, const std::string& icon, wxEvtHandler* event_handler) { - const wxBitmap& bmp = !icon.empty() ? wxBitmap(wxString::FromUTF8(Slic3r::var(icon)), wxBITMAP_TYPE_PNG) : wxNullBitmap; + const wxBitmap& bmp = !icon.empty() ? wxBitmap(from_u8(Slic3r::var(icon)), wxBITMAP_TYPE_PNG) : wxNullBitmap; return append_menu_item(menu, id, string, description, cb, bmp, event_handler); } @@ -48,7 +51,7 @@ wxMenuItem* append_submenu(wxMenu* menu, wxMenu* sub_menu, int id, const wxStrin wxMenuItem* item = new wxMenuItem(menu, id, string, description); if (!icon.empty()) - item->SetBitmap(wxBitmap(wxString::FromUTF8(Slic3r::var(icon)), wxBITMAP_TYPE_PNG)); + item->SetBitmap(wxBitmap(from_u8(Slic3r::var(icon)), wxBITMAP_TYPE_PNG)); item->SetSubMenu(sub_menu); menu->Append(item);