Skip to content

Commit

Permalink
Merge branch 'master' into rafting_extras_2
Browse files Browse the repository at this point in the history
  • Loading branch information
nemart69 committed Feb 9, 2021
2 parents 08131f0 + 8fbafbe commit 02b71f7
Show file tree
Hide file tree
Showing 209 changed files with 30,080 additions and 15,155 deletions.
19 changes: 19 additions & 0 deletions CMakeLists.txt
Expand Up @@ -35,15 +35,27 @@ option(SLIC3R_ASAN "Enable ASan on Clang and GCC" 0)

set(SLIC3R_GTK "2" CACHE STRING "GTK version to use with wxWidgets on Linux")

set(IS_CROSS_COMPILE FALSE)

if (APPLE)
set(CMAKE_FIND_FRAMEWORK LAST)
set(CMAKE_FIND_APPBUNDLE LAST)
list(FIND CMAKE_OSX_ARCHITECTURES ${CMAKE_SYSTEM_PROCESSOR} _arch_idx)
if (CMAKE_OSX_ARCHITECTURES AND _arch_idx LESS 0)
set(IS_CROSS_COMPILE TRUE)
endif ()
endif ()

# Proposal for C++ unit tests and sandboxes
option(SLIC3R_BUILD_SANDBOXES "Build development sandboxes" OFF)
option(SLIC3R_BUILD_TESTS "Build unit tests" ON)

if (IS_CROSS_COMPILE)
message("Detected cross compilation setup. Tests and encoding checks will be forcedly disabled!")
set(SLIC3R_PERL_XS OFF CACHE BOOL "" FORCE)
set(SLIC3R_BUILD_TESTS OFF CACHE BOOL "" FORCE)
endif ()

# Print out the SLIC3R_* cache options
get_cmake_property(_cache_vars CACHE_VARIABLES)
list (SORT _cache_vars)
Expand Down Expand Up @@ -190,6 +202,13 @@ if (NOT MSVC AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMP
add_compile_options(-Wno-ignored-attributes) # Tamas: Eigen include dirs are marked as SYSTEM
endif()

# Clang reports legacy OpenGL calls as deprecated. Turn off the warning for now
# to reduce the clutter, we know about this one. It should be reenabled after
# we finally get rid of the deprecated code.
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
add_compile_options(-Wno-deprecated-declarations)
endif()

#GCC generates loads of -Wunknown-pragmas when compiling igl. The fix is not easy due to a bug in gcc, see
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66943 or
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431
Expand Down
4 changes: 3 additions & 1 deletion cmake/modules/OpenVDBUtils.cmake
Expand Up @@ -157,7 +157,9 @@ function(OPENVDB_ABI_VERSION_FROM_PRINT OPENVDB_PRINT)
endif()

set(_OpenVDB_ABI)
string(REGEX REPLACE ".*abi([0-9]*).*" "\\1" _OpenVDB_ABI ${_VDB_PRINT_VERSION_STRING})
if (_VDB_PRINT_VERSION_STRING)
string(REGEX REPLACE ".*abi([0-9]*).*" "\\1" _OpenVDB_ABI ${_VDB_PRINT_VERSION_STRING})
endif ()
if(${_OpenVDB_ABI} STREQUAL ${_VDB_PRINT_VERSION_STRING})
set(_OpenVDB_ABI "")
endif()
Expand Down
89 changes: 89 additions & 0 deletions cmake/modules/bin2h.cmake
@@ -0,0 +1,89 @@
# Source: https://gist.github.com/sivachandran/3a0de157dccef822a230#file-bin2h-cmake
# Added modifications to suit prusaslicer
include(CMakeParseArguments)

# Function to wrap a given string into multiple lines at the given column position.
# Parameters:
# VARIABLE - The name of the CMake variable holding the string.
# AT_COLUMN - The column position at which string will be wrapped.
function(WRAP_STRING)
set(oneValueArgs VARIABLE AT_COLUMN)
cmake_parse_arguments(WRAP_STRING "${options}" "${oneValueArgs}" "" ${ARGN})

string(LENGTH ${${WRAP_STRING_VARIABLE}} stringLength)
math(EXPR offset "0")

while(stringLength GREATER 0)

if(stringLength GREATER ${WRAP_STRING_AT_COLUMN})
math(EXPR length "${WRAP_STRING_AT_COLUMN}")
else()
math(EXPR length "${stringLength}")
endif()

string(SUBSTRING ${${WRAP_STRING_VARIABLE}} ${offset} ${length} line)
set(lines "${lines}\n${line}")

math(EXPR stringLength "${stringLength} - ${length}")
math(EXPR offset "${offset} + ${length}")
endwhile()

set(${WRAP_STRING_VARIABLE} "${lines}" PARENT_SCOPE)
endfunction()

# Function to embed contents of a file as byte array in C/C++ header file(.h). The header file
# will contain a byte array and integer variable holding the size of the array.
# Parameters
# SOURCE_FILE - The path of source file whose contents will be embedded in the header file.
# VARIABLE_NAME - The name of the variable for the byte array. The string "_SIZE" will be append
# to this name and will be used a variable name for size variable.
# HEADER_FILE - The path of header file.
# APPEND - If specified appends to the header file instead of overwriting it
# NULL_TERMINATE - If specified a null byte(zero) will be append to the byte array. This will be
# useful if the source file is a text file and we want to use the file contents
# as string. But the size variable holds size of the byte array without this
# null byte.
# Usage:
# bin2h(SOURCE_FILE "Logo.png" HEADER_FILE "Logo.h" VARIABLE_NAME "LOGO_PNG")
function(BIN2H)
set(options APPEND NULL_TERMINATE ADD_WARNING_TEXT)
set(oneValueArgs SOURCE_FILE VARIABLE_NAME HEADER_FILE)
cmake_parse_arguments(BIN2H "${options}" "${oneValueArgs}" "" ${ARGN})

# reads source file contents as hex string
file(READ ${BIN2H_SOURCE_FILE} hexString HEX)
string(LENGTH ${hexString} hexStringLength)

# appends null byte if asked
if(BIN2H_NULL_TERMINATE)
set(hexString "${hexString}00")
endif()

# wraps the hex string into multiple lines at column 32(i.e. 16 bytes per line)
wrap_string(VARIABLE hexString AT_COLUMN 32)
math(EXPR arraySize "${hexStringLength} / 2")

# adds '0x' prefix and comma suffix before and after every byte respectively
string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1, " arrayValues ${hexString})
# removes trailing comma
string(REGEX REPLACE ", $" "" arrayValues ${arrayValues})

# converts the variable name into proper C identifier
string(MAKE_C_IDENTIFIER "${BIN2H_VARIABLE_NAME}" BIN2H_VARIABLE_NAME)
# string(TOUPPER "${BIN2H_VARIABLE_NAME}" BIN2H_VARIABLE_NAME)

# declares byte array and the length variables
set(arrayDefinition "const unsigned char ${BIN2H_VARIABLE_NAME}[] = { ${arrayValues} };")
set(arraySizeDefinition "const size_t ${BIN2H_VARIABLE_NAME}_SIZE = ${arraySize};")
set(warnTxt "")
if (BIN2H_ADD_WARNING_TEXT)
set(warnTxt "/* WARN: This file is auto-generated from ${BIN2H_SOURCE_FILE} */\n")
endif ()

set(declarations "${warnTxt}${arrayDefinition}\n\n${arraySizeDefinition}\n\n")
if(BIN2H_APPEND)
file(APPEND ${BIN2H_HEADER_FILE} "${declarations}")
else()
file(WRITE ${BIN2H_HEADER_FILE} "${declarations}")
endif()
endfunction()
7 changes: 4 additions & 3 deletions deps/deps-linux.cmake
Expand Up @@ -13,11 +13,11 @@ include("deps-unix-common.cmake")

ExternalProject_Add(dep_boost
EXCLUDE_FROM_ALL 1
URL "https://dl.bintray.com/boostorg/release/1.70.0/source/boost_1_70_0.tar.gz"
URL_HASH SHA256=882b48708d211a5f48e60b0124cf5863c1534cd544ecd0664bb534a4b5d506e9
URL "https://dl.bintray.com/boostorg/release/1.75.0/source/boost_1_75_0.tar.gz"
URL_HASH SHA256=aeb26f80e80945e82ee93e5939baebdca47b9dee80a07d3144be1e1a6a66dd6a
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND ./bootstrap.sh
--with-libraries=system,iostreams,filesystem,thread,log,locale,regex
--with-libraries=system,iostreams,filesystem,thread,log,locale,regex,date_time
"--prefix=${DESTDIR}/usr/local"
BUILD_COMMAND ./b2
-j ${NPROC}
Expand All @@ -26,6 +26,7 @@ ExternalProject_Add(dep_boost
variant=release
threading=multi
boost.locale.icu=off
--disable-icu
cflags=-fPIC
cxxflags=-fPIC
install
Expand Down
7 changes: 4 additions & 3 deletions deps/deps-macos.cmake
Expand Up @@ -18,12 +18,12 @@ include("deps-unix-common.cmake")

ExternalProject_Add(dep_boost
EXCLUDE_FROM_ALL 1
URL "https://dl.bintray.com/boostorg/release/1.70.0/source/boost_1_70_0.tar.gz"
URL_HASH SHA256=882b48708d211a5f48e60b0124cf5863c1534cd544ecd0664bb534a4b5d506e9
URL "https://dl.bintray.com/boostorg/release/1.75.0/source/boost_1_75_0.tar.gz"
URL_HASH SHA256=aeb26f80e80945e82ee93e5939baebdca47b9dee80a07d3144be1e1a6a66dd6a
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND ./bootstrap.sh
--with-toolset=clang
--with-libraries=system,iostreams,filesystem,thread,log,locale,regex
--with-libraries=system,iostreams,filesystem,thread,log,locale,regex,date_time
"--prefix=${DESTDIR}/usr/local"
BUILD_COMMAND ./b2
-j ${NPROC}
Expand All @@ -33,6 +33,7 @@ ExternalProject_Add(dep_boost
variant=release
threading=multi
boost.locale.icu=off
--disable-icu
"cflags=-fPIC -mmacosx-version-min=${DEP_OSX_TARGET}"
"cxxflags=-fPIC -mmacosx-version-min=${DEP_OSX_TARGET}"
"mflags=-fPIC -mmacosx-version-min=${DEP_OSX_TARGET}"
Expand Down
5 changes: 3 additions & 2 deletions deps/deps-mingw.cmake
Expand Up @@ -9,8 +9,8 @@ include("deps-unix-common.cmake")

ExternalProject_Add(dep_boost
EXCLUDE_FROM_ALL 1
URL "https://dl.bintray.com/boostorg/release/1.70.0/source/boost_1_70_0.tar.gz"
URL_HASH SHA256=882b48708d211a5f48e60b0124cf5863c1534cd544ecd0664bb534a4b5d506e9
URL "https://dl.bintray.com/boostorg/release/1.75.0/source/boost_1_75_0.tar.gz"
URL_HASH SHA256=aeb26f80e80945e82ee93e5939baebdca47b9dee80a07d3144be1e1a6a66dd6a
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND bootstrap.bat
BUILD_COMMAND b2.exe
Expand All @@ -21,6 +21,7 @@ ExternalProject_Add(dep_boost
--with-log
--with-locale
--with-regex
--with-date_time
"--prefix=${DESTDIR}/usr/local"
"address-model=${DEPS_BITS}"
"toolset=${DEP_BOOST_TOOLSET}"
Expand Down
6 changes: 4 additions & 2 deletions deps/deps-windows.cmake
Expand Up @@ -55,8 +55,8 @@ endmacro()

ExternalProject_Add(dep_boost
EXCLUDE_FROM_ALL 1
URL "https://dl.bintray.com/boostorg/release/1.70.0/source/boost_1_70_0.tar.gz"
URL_HASH SHA256=882b48708d211a5f48e60b0124cf5863c1534cd544ecd0664bb534a4b5d506e9
URL "https://dl.bintray.com/boostorg/release/1.75.0/source/boost_1_75_0.tar.gz"
URL_HASH SHA256=aeb26f80e80945e82ee93e5939baebdca47b9dee80a07d3144be1e1a6a66dd6a
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND bootstrap.bat
BUILD_COMMAND b2.exe
Expand All @@ -68,13 +68,15 @@ ExternalProject_Add(dep_boost
--with-log
--with-locale
--with-regex
--with-date_time
"--prefix=${DESTDIR}/usr/local"
"address-model=${DEPS_BITS}"
"toolset=${DEP_BOOST_TOOLSET}"
link=static
variant=release
threading=multi
boost.locale.icu=off
--disable-icu
"${DEP_BOOST_DEBUG}" release install
INSTALL_COMMAND "" # b2 does that already
)
Expand Down
2 changes: 1 addition & 1 deletion deps/wxWidgets/wxWidgets.cmake
@@ -1,4 +1,4 @@
if (APPLE AND ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
if (APPLE)
# The new OSX 11 (Big Sur) is not compatible with wxWidgets 3.1.3.
# Let's use patched wxWidgets 3.1.4, even though it is not quite tested.
set(_wx_git_tag v3.1.4-patched)
Expand Down
94 changes: 58 additions & 36 deletions doc/How to build - Windows.md
@@ -1,5 +1,61 @@
# Step by Step Visual Studio 2019 Instructions

# This how-to is out of date
### Install the tools

Install Visual Studio Community 2019 from [visualstudio.microsoft.com/vs/](https://visualstudio.microsoft.com/vs/). Older versions are not supported as PrusaSlicer requires support for C++17.
Select all workload options for C++

Install git for Windows from [gitforwindows.org](https://gitforwindows.org/)
Download and run the exe accepting all defaults

### Download sources

Clone the respository. To place it in C:\src\PrusaSlicer, run:
```
c:> mkdir src
c:> cd src
c:\src> git clone https://github.com/prusa3d/PrusaSlicer.git
```

### Compile the dependencies.
Dependencies are updated seldomly, thus they are compiled out of the PrusaSlicer source tree.
Go to the Windows Start Menu and Click on "Visual Studio 2019" folder, then select the ->"x64 Native Tools Command Prompt" to open a command window and run the following:
```
cd c:\src\PrusaSlicer\deps
mkdir build
cd build
cmake .. -G "Visual Studio 16 2019" -DDESTDIR="c:\src\PrusaSlicer-deps"
msbuild /m ALL_BUILD.vcxproj // This took 13.5 minutes on my machine: core I7-7700K @ 4.2Ghz with 32GB main memory and 20min on a average laptop
```

### Generate Visual Studio project file for PrusaSlicer, referencing the precompiled dependencies.
Go to the Windows Start Menu and Click on "Visual Studio 2019" folder, then select the ->"x64 Native Tools Command Prompt" to open a command window and run the following:
```
cd c:\src\PrusaSlicer\
mkdir build
cd build
cmake .. -G "Visual Studio 16 2019" -DCMAKE_PREFIX_PATH="c:\src\PrusaSlicer-deps\usr\local"
```

### Compile PrusaSlicer.

Double-click c:\src\PrusaSlicer\build\PrusaSlicer.sln to open in Visual Studio 2019.
OR
Open Visual Studio for C++ development (VS asks this the first time you start it).

Select PrusaSlicer_app_gui as your startup project (right-click->Set as Startup Project).

Run Build->Rebuild Solution once to populate all required dependency modules. This is NOT done automatically when you build/run. If you run both Debug and Release variants, you will need to do this once for each.

Debug->Start Debugging or press F5

PrusaSlicer should start. You're up and running!

note: Thanks to @douggorgen for the original guide, as an answer for a issue


# The below information is out of date, but still useful for reference purposes

We have switched to MS Visual Studio 2019.

Expand Down Expand Up @@ -119,38 +175,4 @@ option to CMake, this will only produce a _Release_ build.
Refer to the CMake scripts inside the `deps` directory to see which dependencies are built in what versions and how this is done.

\*) Specifically, the problem arises when building boost. Boost build tool appends all build options into paths of
intermediate files, which are not handled correctly by either `b2.exe` or possibly `ninja` (?).


# Noob guide (step by step)

- Install Visual Studio Community 2019 from [visualstudio.microsoft.com/vs/](https://visualstudio.microsoft.com/vs/)
- Select all workload options for C++
- Install git for Windows from [gitforwindows.org](https://gitforwindows.org/)
- download and run the exe accepting all defaults
- Download `PrusaSlicer-master.zip` from github
- This example will use the directory c:\PrusaSlicer and unzipped to `c:\PrusaSlicer\PrusaSlicer-master\` so this will be the prefix for all the steps. Substitute your as required prefix.
- Go to the Windows Start Menu and Click on "Visual Studio 2019" folder, then select the ->"x64 Native Tools Command Prompt" to open a command window

cd c:\PrusaSlicer\PrusaSlicer-master\deps
mkdir build
cd build
cmake .. -G "Visual Studio 16 2019" -DDESTDIR="c:\PrusaSlicer\PrusaSlicer-master"
msbuild /m ALL_BUILD.vcxproj // This took 13.5 minutes on the following machine: core I7-7700K @ 4.2Ghz with 32GB main memory and 20min on an average laptop
cd c:\PrusaSlicer\PrusaSlicer-master\
mkdir build
cd build
cmake .. -G "Visual Studio 16 2019" -DCMAKE_PREFIX_PATH="c:\PrusaSlicer\PrusaSlicer-master\usr\local"

- Open Visual Studio for c++ development (VS asks this the first time you start it)

`Open->Project/Solution` or `File->Open->Project/Solution` (depending on which dialog comes up first)

- Click on `c:\PrusaSlicer\PrusaSlicer-master\build\PrusaSlicer.sln`

`Debug->Start Debugging` or `Debug->Start Without debugging`

- PrusaSlicer should start.
- You're up and running!

Note: Thanks to @douggorgen for the original guide, as an answer for a issue
intermediate files, which are not handled correctly by either `b2.exe` or possibly `ninja` (?).
35 changes: 31 additions & 4 deletions doc/Localization_guide.md
Expand Up @@ -16,7 +16,7 @@ Full manual for GNUgettext can be seen here: http://www.gnu.org/software/gettext
https://github.com/prusa3d/PrusaSlicer/tree/master/resources/localization
2. Open this file in PoEdit as "Edit a translation"
3. Apply your corrections to the translation
4. Push changed PrusaSlicer.po and PrusaSlicer.mo (will create automatically after saving of PrusaSlicer.po in PoEdit) back to to the enter folder.
4. Push changed PrusaSlicer.po and PrusaSlicer.mo (will create automatically after saving of PrusaSlicer.po in PoEdit) into the original folder.

### Scenario 2. How do I add a new language support
1. Get file PrusaSlicer.pot here :
Expand Down Expand Up @@ -71,6 +71,33 @@ https://github.com/prusa3d/PrusaSlicer/tree/master/resources/localization/list.t
```
Notice, in this Catalog it will be totally same strings for initial text and translated.

When you have Catalog to translation open POT or PO file in PoEdit and start to translation,
it's very important to keep attention to every gaps and punctuation. Especially with
formatted strings. (using %d, %s, etc.)
When you have Catalog to translation open POT or PO file in PoEdit and start translating.


## General guidelines for PrusaSlicer translators


- We recommend using *PoEdit* application for translation (as described above). It will help you eliminate most punctuation errors and will show you strings with "random" translations (if the fuzzy parameter was used).

- To check how the translated text looks on the UI elements, test it :) If you use *PoEdit*, all you need to do is save the file. At this point, a MO file will be created. Rename it PrusaSlicer.mo, and you can run PrusaSlicer (see above).

- If you see an encoding error (garbage characters instead of Unicode) somewhere in PrusaSlicer, report it. It is likely not a problem of your translation, but a bug in the software.

- See on which UI elements the translated phrase will be used. Especially if it's a button, it is very important to decide on the translation and not write alternative translations in parentheses, as this will significantly increase the width of the button, which is sometimes highly undesirable:

![Long text on button](images/long_text_on_button.png)

- If you decide to use autocorrect or any batch processing tool, the output requires very careful proofreading. It is very easy to make it do changes that break things big time.

- **Any formatting parts of the phrases must remain unchanged.** For example, you should not change `%1%` to `%1 %`, you should not change `%%` to `%` (for percent sign) and similar. This will lead to application crashes.

- Please pay attention to spaces, line breaks (\n) and punctuation marks. **Don't add extra line breaks.** This is especially important for parameter names.

- Description of the parameters should not contain units of measurement. For example, "Enable fan if layer print time is less than ~~n seconds~~"

- For units of measurement, use the international system of units. Use "s" instead of "sec".

- If the phrase doesn't have a dot at the end, don't add it. And if it does, then don't forget to :)

- It is useful to stick to the same terminology in the application (especially with basic terms such as "filament" and similar). Stay consistent. Otherwise it will confuse users.

Binary file added doc/images/long_text_on_button.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 02b71f7

Please sign in to comment.