Merge branch 'project_specific_config' into wipe_tower_improvements

This commit is contained in:
Lukas Matena 2018-03-15 14:05:45 +01:00
commit e864238609
10 changed files with 77 additions and 52 deletions

View File

@ -50,15 +50,16 @@ if(NOT DEFINED CMAKE_PREFIX_PATH)
endif() endif()
endif() endif()
add_subdirectory(xs)
if (MSVC) if (MSVC)
# By default the startup project in MSVC is the 'ALL_BUILD' cmake-created project, # By default the startup project in MSVC is the 'ALL_BUILD' cmake-created project,
# but we want 'slic3r' as the startup one because debugging run command is associated with it. # but we want 'slic3r' as the startup one because debugging run command is associated with it.
# (Unfortunatelly it cannot be associated with ALL_BUILD using CMake.) # (Unfortunatelly it cannot be associated with ALL_BUILD using CMake.)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT slic3r) # Note: For some reason this needs to be set in the top-level CMakeLists.txt
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT XS)
endif () endif ()
add_subdirectory(xs)
enable_testing () enable_testing ()
get_filename_component(PERL_BIN_PATH "${PERL_EXECUTABLE}" DIRECTORY) get_filename_component(PERL_BIN_PATH "${PERL_EXECUTABLE}" DIRECTORY)
add_test (NAME xs COMMAND "${PERL_EXECUTABLE}" ${PERL_BIN_PATH}/prove -I ${PROJECT_SOURCE_DIR}/local-lib/lib/perl5 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/xs) add_test (NAME xs COMMAND "${PERL_EXECUTABLE}" ${PERL_BIN_PATH}/prove -I ${PROJECT_SOURCE_DIR}/local-lib/lib/perl5 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/xs)

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<LocalDebuggerCommand>C:\wperl64d\bin\perl.exe</LocalDebuggerCommand>
<LocalDebuggerCommandArguments>slic3r.pl</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerWorkingDirectory>..\..</LocalDebuggerWorkingDirectory>
</PropertyGroup>
</Project>

View File

@ -8,4 +8,11 @@
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup /> <ItemDefinitionGroup />
<ItemGroup /> <ItemGroup />
<PropertyGroup>
<LocalDebuggerCommand>C:\wperl64d\bin\perl.exe</LocalDebuggerCommand>
<LocalDebuggerCommandArguments>slic3r.pl</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerWorkingDirectory>..\..</LocalDebuggerWorkingDirectory>
</PropertyGroup>
</Project> </Project>

View File

@ -50,7 +50,6 @@ and use these commands to build the Slic3r from the command line:
cd build cd build
cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release
nmake nmake
ctest --verbose # TODO: ???
cd .. cd ..
perl slic3r.pl perl slic3r.pl
@ -60,27 +59,34 @@ You may also build Slic3r PE with other build tools:
### Building with Visual Studio ### Building with Visual Studio
To build, lanuch and/or debug Slic3r PE with Visual Studio (64 bits), replace the `cmake` command with: To build and debug Slic3r PE with Visual Studio (64 bits), replace the `cmake` command with:
cmake .. -G "Visual Studio 12 Win64" -DCMAKE_CONFIGURATION_TYPES=Release;RelWithDebInfo || exit /b cmake .. -G "Visual Studio 12 Win64" -DCMAKE_CONFIGURATION_TYPES=RelWithDebInfo
For the 32-bit variant, use: For the 32-bit variant, use:
cmake .. -G "Visual Studio 12" -DCMAKE_CONFIGURATION_TYPES=Release;RelWithDebInfo || exit /b cmake .. -G "Visual Studio 12" -DCMAKE_CONFIGURATION_TYPES=RelWithDebInfo
After `cmake` has finished, go to the `Slic3r\build` directory and open the `Slic3r.sln` solution file. After `cmake` has finished, go to the build directory and open the `Slic3r.sln` solution file.
This should open Visual Studio and load all the Slic3r solution containing all the projects. This should open Visual Studio and load the Slic3r solution containing all the projects.
Make sure you use Visual Studio 2013 to open the solution. Make sure you use Visual Studio 2013 to open the solution.
You can then use the usual Visual Studio controls to build Slic3r. You can then use the usual Visual Studio controls to build Slic3r (Hit `F5` to build and run with debugger).
If you want to run or debug Slic3r from within Visual Studio, make sure the `slic3r` project is activated. If you want to run or debug Slic3r from within Visual Studio, make sure the `XS` project is activated.
There are multiple projects in the Slic3r solution, but only the `slic3r` project is configured with the right It should be set as the Startup project by CMake by default, but you might want to check anyway.
commands to run Slic3r. There are multiple projects in the Slic3r solution, but only the `XS` project is configured with the right
commands to run and debug Slic3r.
The above cmake commands generate Visual Studio project files with the `RelWithDebInfo` configuration only.
If you also want to use the `Release` configuration, you can generate Visual Studio projects with:
-DCMAKE_CONFIGURATION_TYPES=Release;RelWithDebInfo
(The `Debug` configuration is not supported as of now.)
### Building with ninja ### Building with ninja
To use [Ninja](TODO), replace the `cmake` and `nmake` commands with: To use [Ninja](https://ninja-build.org/), replace the `cmake` and `nmake` commands with:
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release
ninja ninja

View File

@ -82,11 +82,11 @@ $(OPENSSL).tar.gz:
libcurl: libopenssl $(CURL).tar.gz libcurl: libopenssl $(CURL).tar.gz
tar -zxvf $(CURL).tar.gz tar -zxvf $(CURL).tar.gz
# XXX: disable shared? # Note: It seems setting custom openssl path doesn't work when pkg-config and system openssl devel libs are installed
# Setting PKG_CONFIG_PATH should make libcurl find our previously built openssl cd $(CURL) && ./configure \
cd $(CURL) && PKG_CONFIG_PATH=$(DESTDIR)/usr/local/lib/pkgconfig ./configure \
--enable-static \ --enable-static \
--enable-shared \ --enable-shared \
--with-ssl=$(DESTDIR)/usr/local \
--with-pic \ --with-pic \
--enable-ipv6 \ --enable-ipv6 \
--enable-versioned-symbols \ --enable-versioned-symbols \

View File

@ -1,18 +1,18 @@
c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.cpp xs/src/slic3r/GUI/BedShapeDialog.cpp
c:\src\Slic3r\xs\src\slic3r\GUI\BedShapeDialog.hpp xs/src/slic3r/GUI/BedShapeDialog.hpp
c:\src\Slic3r\xs\src\slic3r\GUI\GUI.cpp xs/src/slic3r/GUI/GUI.cpp
c:\src\Slic3r\xs\src\slic3r\GUI\Tab.cpp xs/src/slic3r/GUI/Tab.cpp
c:\src\Slic3r\xs\src\slic3r\GUI\Tab.hpp xs/src/slic3r/GUI/Tab.hpp
c:\src\Slic3r\xs\src\slic3r\GUI\Field.cpp xs/src/slic3r/GUI/Field.cpp
c:\src\Slic3r\xs\src\slic3r\GUI\OptionsGroup.cpp xs/src/slic3r/GUI/OptionsGroup.cpp
c:\src\Slic3r\xs\src\slic3r\GUI\2DBed.cpp xs/src/slic3r/GUI/2DBed.cpp
c:\src\Slic3r\xs\src\slic3r\GUI\PresetHints.cpp xs/src/slic3r/GUI/PresetHints.cpp
c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.hpp xs/src/slic3r/GUI/Preferences.hpp
c:\src\Slic3r\xs\src\slic3r\GUI\Preferences.cpp xs/src/slic3r/GUI/Preferences.cpp
C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp xs/src/libslic3r/PrintConfig.cpp
c:\src\Slic3r\xs\src\libslic3r\GCode\PreviewData.cpp xs/src/libslic3r/GCode/PreviewData.cpp
c:\src\Slic3r\lib\Slic3r\GUI.pm lib/Slic3r/GUI.pm
c:\src\Slic3r\lib\Slic3r\GUI\MainFrame.pm lib/Slic3r/GUI/MainFrame.pm
c:\src\Slic3r\lib\Slic3r\GUI\Plater.pm lib/Slic3r/GUI/Plater.pm
c:\src\Slic3r\lib\Slic3r\GUI\Plater\2D.pm lib/Slic3r/GUI/Plater/2D.pm
c:\src\Slic3r\lib\Slic3r\GUI\Plater\3DPreview.pm lib/Slic3r/GUI/Plater/3DPreview.pm

View File

@ -630,15 +630,19 @@ elseif (NOT MSVC)
endif () endif ()
if (MSVC) if (MSVC)
# Here we associate some additional properties with the MSVC projects to enable compilation and debugging out of the box. # Here we associate some additional properties with the MSVC project to enable compilation and debugging out of the box.
# It seems a props file needs to be copied to the same dir as the proj file, otherwise MSVC doesn't load it up. set_target_properties(XS PROPERTIES VS_USER_PROPS "${PROJECT_SOURCE_DIR}/cmake/msvc/xs.wperl64d.props")
# For copying, the configure_file() function seems to work much better than the file() function.
configure_file("${PROJECT_SOURCE_DIR}/cmake/msvc/xs.wperl64d.props" ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
set_target_properties(XS PROPERTIES VS_USER_PROPS "xs.wperl64d.props")
configure_file("${PROJECT_SOURCE_DIR}/cmake/msvc/slic3r.wperl64d.props" ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
set_target_properties(slic3r PROPERTIES VS_USER_PROPS "slic3r.wperl64d.props")
endif() endif()
# l10n
set(L10N_DIR "${PROJECT_SOURCE_DIR}/resources/localization")
add_custom_target(pot
COMMAND xgettext --keyword=L --from-code=UTF-8 --debug
-f "${L10N_DIR}/list.txt"
-o "${L10N_DIR}/Slic3rPE.pot"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Generate pot file from strings in the source tree"
)
# Installation # Installation
install(TARGETS XS DESTINATION ${PERL_VENDORARCH}/auto/Slic3r/XS) install(TARGETS XS DESTINATION ${PERL_VENDORARCH}/auto/Slic3r/XS)

View File

@ -32,6 +32,9 @@
namespace Slic3r { namespace Slic3r {
static std::vector<std::string> s_project_options {
};
PresetBundle::PresetBundle() : PresetBundle::PresetBundle() :
prints(Preset::TYPE_PRINT, Preset::print_options()), prints(Preset::TYPE_PRINT, Preset::print_options()),
filaments(Preset::TYPE_FILAMENT, Preset::filament_options()), filaments(Preset::TYPE_FILAMENT, Preset::filament_options()),
@ -56,6 +59,8 @@ PresetBundle::PresetBundle() :
this->filaments.load_bitmap_default("spool.png"); this->filaments.load_bitmap_default("spool.png");
this->printers .load_bitmap_default("printer_empty.png"); this->printers .load_bitmap_default("printer_empty.png");
this->load_compatible_bitmaps(); this->load_compatible_bitmaps();
this->project_config.apply_only(FullPrintConfig::defaults(), s_project_options);
} }
PresetBundle::~PresetBundle() PresetBundle::~PresetBundle()
@ -223,6 +228,7 @@ DynamicPrintConfig PresetBundle::full_config() const
out.apply(FullPrintConfig()); out.apply(FullPrintConfig());
out.apply(this->prints.get_edited_preset().config); out.apply(this->prints.get_edited_preset().config);
out.apply(this->printers.get_edited_preset().config); out.apply(this->printers.get_edited_preset().config);
out.apply(this->project_config);
auto *nozzle_diameter = dynamic_cast<const ConfigOptionFloats*>(out.option("nozzle_diameter")); auto *nozzle_diameter = dynamic_cast<const ConfigOptionFloats*>(out.option("nozzle_diameter"));
size_t num_extruders = nozzle_diameter->values.size(); size_t num_extruders = nozzle_diameter->values.size();
@ -412,6 +418,9 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
} }
} }
// 4) Load the project config values (the per extruder wipe matrix etc).
this->project_config.apply_only(config, s_project_options);
this->update_compatible_with_printer(false); this->update_compatible_with_printer(false);
} }

View File

@ -39,6 +39,11 @@ public:
// extruders.size() should be the same as printers.get_edited_preset().config.nozzle_diameter.size() // extruders.size() should be the same as printers.get_edited_preset().config.nozzle_diameter.size()
std::vector<std::string> filament_presets; std::vector<std::string> filament_presets;
// The project configuration values are kept separated from the print/filament/printer preset,
// they are being serialized / deserialized from / to the .amf, .3mf, .config, .gcode,
// and they are being used by slicing core.
DynamicPrintConfig project_config;
bool has_defauls_only() const bool has_defauls_only() const
{ return prints.size() <= 1 && filaments.size() <= 1 && printers.size() <= 1; } { return prints.size() <= 1 && filaments.size() <= 1 && printers.size() <= 1; }

View File

@ -161,6 +161,8 @@ PresetCollection::arrayref()
Ref<PresetCollection> print() %code%{ RETVAL = &THIS->prints; %}; Ref<PresetCollection> print() %code%{ RETVAL = &THIS->prints; %};
Ref<PresetCollection> filament() %code%{ RETVAL = &THIS->filaments; %}; Ref<PresetCollection> filament() %code%{ RETVAL = &THIS->filaments; %};
Ref<PresetCollection> printer() %code%{ RETVAL = &THIS->printers; %}; Ref<PresetCollection> printer() %code%{ RETVAL = &THIS->printers; %};
Ref<DynamicPrintConfig> project_config() %code%{ RETVAL = &THIS->project_config; %};
bool has_defauls_only(); bool has_defauls_only();
std::vector<std::string> filament_presets() %code%{ RETVAL = THIS->filament_presets; %}; std::vector<std::string> filament_presets() %code%{ RETVAL = THIS->filament_presets; %};