Initial import of prusa-slicer.

This commit is contained in:
Jason Tibbitts 2019-06-07 15:10:23 -05:00
parent 3b762f3319
commit f9f2d405f2
10 changed files with 1035 additions and 0 deletions

View File

@ -0,0 +1,254 @@
From 07282eb24d027817b4279f59ebbf0d80bac5f950 Mon Sep 17 00:00:00 2001
From: Lukas Matena <lukasmatena@seznam.cz>
Date: Wed, 22 May 2019 16:43:14 +0200
Subject: [PATCH] Fixed unit tests when run with range checks on std::vector
There was a bug in unit tests that led to generating the wipe tower with non-normalized preset.
This caused out-of-bounds access into max_layer_height vector in fill_wipe_tower_partitions.
The problem surfaced in https://github.com/prusa3d/PrusaSlicer/issues/2288.
I quickly patched additional normalization of the preset to prevent this from happening.
Also, an assert in the same function turned out to trip on one of the tests.
This one was commented out for now and will (hopefully) be looked into later.
Function Print::apply_config was renamed to apply_config_perl_tests_only so everyone
sees its current purpose and does not mistake it for the more important Print::apply.
---
lib/Slic3r/Print/Simple.pm | 2 +-
lib/Slic3r/Test.pm | 8 ++++----
src/libslic3r/GCode/ToolOrdering.cpp | 5 ++++-
src/libslic3r/Print.cpp | 28 +++++++++++++++++++++++++---
src/libslic3r/Print.hpp | 2 +-
src/libslic3r/PrintBase.hpp | 2 +-
src/libslic3r/PrintObject.cpp | 2 +-
src/libslic3r/SLAPrint.cpp | 2 +-
t/combineinfill.t | 2 +-
t/print.t | 2 +-
t/skirt_brim.t | 2 +-
xs/xsp/Print.xsp | 4 ++--
12 files changed, 43 insertions(+), 18 deletions(-)
diff --git a/lib/Slic3r/Print/Simple.pm b/lib/Slic3r/Print/Simple.pm
index b5b749f12..2ab68f4d3 100644
--- a/lib/Slic3r/Print/Simple.pm
+++ b/lib/Slic3r/Print/Simple.pm
@@ -13,7 +13,7 @@ use Slic3r::Geometry qw(X Y);
has '_print' => (
is => 'ro',
default => sub { Slic3r::Print->new },
- handles => [qw(apply_config extruders output_filepath
+ handles => [qw(apply_config_perl_tests_only extruders output_filepath
total_used_filament total_extruded_volume
placeholder_parser process)],
);
diff --git a/lib/Slic3r/Test.pm b/lib/Slic3r/Test.pm
index b767ca593..d1b99e48c 100644
--- a/lib/Slic3r/Test.pm
+++ b/lib/Slic3r/Test.pm
@@ -176,7 +176,7 @@ sub init_print {
$config->set('gcode_comments', 1) if $ENV{SLIC3R_TESTS_GCODE};
my $print = Slic3r::Print->new;
- $print->apply_config($config);
+ $print->apply_config_perl_tests_only($config);
$models = [$models] if ref($models) ne 'ARRAY';
$models = [ map { ref($_) ? $_ : model($_, %params) } @$models ];
@@ -192,8 +192,8 @@ sub init_print {
$print->add_model_object($model_object);
}
}
- # Call apply_config one more time, so that the layer height profiles are updated over all PrintObjects.
- $print->apply_config($config);
+ # Call apply_config_perl_tests_only one more time, so that the layer height profiles are updated over all PrintObjects.
+ $print->apply_config_perl_tests_only($config);
$print->validate;
# We return a proxy object in order to keep $models alive as required by the Print API.
@@ -250,7 +250,7 @@ sub add_facet {
package Slic3r::Test::Print;
use Moo;
-has 'print' => (is => 'ro', required => 1, handles => [qw(process apply_config)]);
+has 'print' => (is => 'ro', required => 1, handles => [qw(process apply_config_perl_tests_only)]);
has 'models' => (is => 'ro', required => 1);
1;
diff --git a/src/libslic3r/GCode/ToolOrdering.cpp b/src/libslic3r/GCode/ToolOrdering.cpp
index e800cd53f..e25ad91fe 100644
--- a/src/libslic3r/GCode/ToolOrdering.cpp
+++ b/src/libslic3r/GCode/ToolOrdering.cpp
@@ -327,7 +327,10 @@ void ToolOrdering::fill_wipe_tower_partitions(const PrintConfig &config, coordf_
LayerTools &lt_prev = m_layer_tools[j - 1];
LayerTools &lt_next = m_layer_tools[j + 1];
assert(! lt_prev.extruders.empty() && ! lt_next.extruders.empty());
- assert(lt_prev.extruders.back() == lt_next.extruders.front());
+ // FIXME: Following assert tripped when running combine_infill.t. I decided to comment it out for now.
+ // If it is a bug, it's likely not critical, because this code is unchanged for a long time. It might
+ // still be worth looking into it more and decide if it is a bug or an obsolete assert.
+ //assert(lt_prev.extruders.back() == lt_next.extruders.front());
lt_extra.has_wipe_tower = true;
lt_extra.extruders.push_back(lt_next.extruders.front());
lt_extra.wipe_tower_partitions = lt_next.wipe_tower_partitions;
diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp
index 29bbb49fe..f9129f15a 100644
--- a/src/libslic3r/Print.cpp
+++ b/src/libslic3r/Print.cpp
@@ -51,7 +51,7 @@ void Print::reload_object(size_t /* idx */)
this->invalidate_all_steps();
/* TODO: this method should check whether the per-object config and per-material configs
have changed in such a way that regions need to be rearranged or we can just apply
- the diff and invalidate something. Same logic as apply_config()
+ the diff and invalidate something. Same logic as apply()
For now we just re-add all objects since we haven't implemented this incremental logic yet.
This should also check whether object volumes (parts) have changed. */
// collect all current model objects
@@ -83,7 +83,7 @@ PrintRegion* Print::add_region(const PrintRegionConfig &config)
return m_regions.back();
}
-// Called by Print::apply_config().
+// Called by Print::apply().
// This method only accepts PrintConfig option keys.
bool Print::invalidate_state_by_config_options(const std::vector<t_config_option_key> &opt_keys)
{
@@ -422,10 +422,32 @@ void Print::add_model_object(ModelObject* model_object, int idx)
}
}
-bool Print::apply_config(DynamicPrintConfig config)
+// This function is only called through the Perl-C++ binding from the unit tests, should be
+// removed when unit tests are rewritten to C++.
+bool Print::apply_config_perl_tests_only(DynamicPrintConfig config)
{
tbb::mutex::scoped_lock lock(this->state_mutex());
+
+ // Perl unit tests were failing in case the preset was not normalized (e.g. https://github.com/prusa3d/PrusaSlicer/issues/2288 was caused
+ // by too short max_layer_height vector. Calling the necessary function Preset::normalize(...) is not currently possible because there is no
+ // access to preset. This should be solved when the unit tests are rewritten to C++. For now we just copy-pasted code from Preset.cpp
+ // to make sure the unit tests pass (functions set_num_extruders and nozzle_options()).
+ auto *nozzle_diameter = dynamic_cast<const ConfigOptionFloats*>(config.option("nozzle_diameter", true));
+ assert(nozzle_diameter != nullptr);
+ const auto &defaults = FullPrintConfig::defaults();
+ for (const std::string &key : { "nozzle_diameter", "min_layer_height", "max_layer_height", "extruder_offset",
+ "retract_length", "retract_lift", "retract_lift_above", "retract_lift_below", "retract_speed", "deretract_speed",
+ "retract_before_wipe", "retract_restart_extra", "retract_before_travel", "wipe",
+ "retract_layer_change", "retract_length_toolchange", "retract_restart_extra_toolchange", "extruder_colour" })
+ {
+ auto *opt = config.option(key, true);
+ assert(opt != nullptr);
+ assert(opt->is_vector());
+ unsigned int num_extruders = (unsigned int)nozzle_diameter->values.size();
+ static_cast<ConfigOptionVectorBase*>(opt)->resize(num_extruders, defaults.option(key));
+ }
+
// we get a copy of the config object so we can modify it safely
config.normalize();
diff --git a/src/libslic3r/Print.hpp b/src/libslic3r/Print.hpp
index be2a9a3bd..53d6d692d 100644
--- a/src/libslic3r/Print.hpp
+++ b/src/libslic3r/Print.hpp
@@ -294,7 +294,7 @@ class Print : public PrintBaseWithState<PrintStep, psCount>
// The following three methods are used by the Perl tests only. Get rid of them!
void reload_object(size_t idx);
void add_model_object(ModelObject* model_object, int idx = -1);
- bool apply_config(DynamicPrintConfig config);
+ bool apply_config_perl_tests_only(DynamicPrintConfig config);
void process() override;
// Exports G-code into a file name based on the path_template, returns the file path of the generated G-code file.
diff --git a/src/libslic3r/PrintBase.hpp b/src/libslic3r/PrintBase.hpp
index a4ef67117..d4c39499c 100644
--- a/src/libslic3r/PrintBase.hpp
+++ b/src/libslic3r/PrintBase.hpp
@@ -84,7 +84,7 @@ class PrintState : public PrintStateBase
// Set the step as started. Block on mutex while the Print / PrintObject / PrintRegion objects are being
// modified by the UI thread.
- // This is necessary to block until the Print::apply_config() updates its state, which may
+ // This is necessary to block until the Print::apply() updates its state, which may
// influence the processing step being entered.
template<typename ThrowIfCanceled>
bool set_started(StepType step, tbb::mutex &mtx, ThrowIfCanceled throw_if_canceled) {
diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp
index bcc61e0bf..660a2d939 100644
--- a/src/libslic3r/PrintObject.cpp
+++ b/src/libslic3r/PrintObject.cpp
@@ -435,7 +435,7 @@ SupportLayerPtrs::const_iterator PrintObject::insert_support_layer(SupportLayerP
return m_support_layers.insert(pos, new SupportLayer(id, this, height, print_z, slice_z));
}
-// Called by Print::apply_config().
+// Called by Print::apply().
// This method only accepts PrintObjectConfig and PrintRegionConfig option keys.
bool PrintObject::invalidate_state_by_config_options(const std::vector<t_config_option_key> &opt_keys)
{
diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp
index 457be23ba..f0dfddda0 100644
--- a/src/libslic3r/SLAPrint.cpp
+++ b/src/libslic3r/SLAPrint.cpp
@@ -1552,7 +1552,7 @@ SLAPrintObject::SLAPrintObject(SLAPrint *print, ModelObject *model_object):
SLAPrintObject::~SLAPrintObject() {}
-// Called by SLAPrint::apply_config().
+// Called by SLAPrint::apply().
// This method only accepts SLAPrintObjectConfig option keys.
bool SLAPrintObject::invalidate_state_by_config_options(const std::vector<t_config_option_key> &opt_keys)
{
diff --git a/t/combineinfill.t b/t/combineinfill.t
index 563ecb9c1..8aa0ff5e3 100644
--- a/t/combineinfill.t
+++ b/t/combineinfill.t
@@ -89,7 +89,7 @@ plan tests => 8;
# we disable combination after infill has been generated
$config->set('infill_every_layers', 1);
- $print->apply_config($config);
+ $print->apply_config_perl_tests_only($config);
$print->process;
ok !(defined first { @{$_->get_region(0)->fill_surfaces} == 0 }
diff --git a/t/print.t b/t/print.t
index 6939d5f15..be2db3431 100644
--- a/t/print.t
+++ b/t/print.t
@@ -44,7 +44,7 @@ use Slic3r::Test;
is $print->print->regions->[0]->config->fill_density, 100, 'region config inherits model object config';
# user exports G-code, thus the default config is reapplied
- $print->print->apply_config($config);
+ $print->print->apply_config_perl_tests_only($config);
is $print->print->regions->[0]->config->fill_density, 100, 'apply_config() does not override per-object settings';
diff --git a/t/skirt_brim.t b/t/skirt_brim.t
index 225b0a92f..b05435784 100644
--- a/t/skirt_brim.t
+++ b/t/skirt_brim.t
@@ -106,7 +106,7 @@ use Slic3r::Test;
# we enable support material after skirt has been generated
$config->set('support_material', 1);
- $print->apply_config($config);
+ $print->apply_config_perl_tests_only($config);
my $skirt_length = 0;
my @extrusion_points = ();
diff --git a/xs/xsp/Print.xsp b/xs/xsp/Print.xsp
index f4c04577d..c35f967f8 100644
--- a/xs/xsp/Print.xsp
+++ b/xs/xsp/Print.xsp
@@ -142,8 +142,8 @@ _constant()
%};
void add_model_object(ModelObject* model_object, int idx = -1);
- bool apply_config(DynamicPrintConfig* config)
- %code%{ RETVAL = THIS->apply_config(*config); %};
+ bool apply_config_perl_tests_only(DynamicPrintConfig* config)
+ %code%{ RETVAL = THIS->apply_config_perl_tests_only(*config); %};
bool has_infinite_skirt();
std::vector<unsigned int> extruders() const;
int validate() %code%{

59
fix-gizmo-icon-size.patch Normal file
View File

@ -0,0 +1,59 @@
diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp
index 1280fa6d9..ff2295cd7 100644
--- a/src/slic3r/GUI/GLCanvas3D.cpp
+++ b/src/slic3r/GUI/GLCanvas3D.cpp
@@ -4098,8 +4098,8 @@ void GLCanvas3D::_render_gizmos_overlay() const
#if ENABLE_RETINA_GL
m_gizmos.set_overlay_scale(m_retina_helper->get_scale_factor());
#else
-// m_gizmos.set_overlay_scale(m_canvas->GetContentScaleFactor());
- m_gizmos.set_overlay_scale(wxGetApp().em_unit()*0.1f);//! #ys_FIXME_experiment
+ const float size = int(GLGizmosManager::Default_Icons_Size*wxGetApp().toolbar_icon_scale());
+ m_gizmos.set_overlay_icon_size(size);
#endif /* __WXMSW__ */
m_gizmos.render_overlay(*this, m_selection);
diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp
index 472abd6dc..6773dbd30 100644
--- a/src/slic3r/GUI/GUI_App.cpp
+++ b/src/slic3r/GUI/GUI_App.cpp
@@ -390,6 +390,27 @@ void GUI_App::set_label_clr_sys(const wxColour& clr) {
app_config->save();
}
+float GUI_App::toolbar_icon_scale(const bool is_limited/* = false*/) const
+{
+#ifdef __APPLE__
+ const float icon_sc = 1.0f; // for Retina display will be used its own scale
+#else
+ const float icon_sc = m_em_unit*0.1f;
+#endif // __APPLE__
+
+ const std::string& use_val = app_config->get("use_custom_toolbar_size");
+ const std::string& val = app_config->get("custom_toolbar_size");
+
+ if (val.empty() || use_val.empty() || use_val == "0")
+ return icon_sc;
+
+ int int_val = atoi(val.c_str());
+ if (is_limited && int_val < 50)
+ int_val = 50;
+
+ return 0.01f * int_val * icon_sc;
+}
+
void GUI_App::recreate_GUI()
{
// Weird things happen as the Paint messages are floating around the windows being destructed.
diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp
index 1c9a462c6..b70f0dc16 100644
--- a/src/slic3r/GUI/GUI_App.hpp
+++ b/src/slic3r/GUI/GUI_App.hpp
@@ -115,6 +115,7 @@ public:
const wxFont& normal_font() { return m_normal_font; }
size_t em_unit() const { return m_em_unit; }
void set_em_unit(const size_t em_unit) { m_em_unit = em_unit; }
+ float toolbar_icon_scale(const bool is_limited = false) const;
void recreate_GUI();
void system_info();

View File

@ -0,0 +1,21 @@
diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp
index 3880f1d79..907231b76 100644
--- a/src/slic3r/GUI/GUI_App.cpp
+++ b/src/slic3r/GUI/GUI_App.cpp
@@ -142,6 +142,16 @@ GUI_App::GUI_App()
bool GUI_App::OnInit()
{
+ wxSetAssertHandler([](const wxString &file,
+ int line,
+ const wxString &func,
+ const wxString &cond,
+ const wxString &msg)
+ {
+ BOOST_LOG_TRIVIAL(debug) << file << " line: " << line << ":\n" << func
+ << " " << cond << " " << msg;
+ });
+
try {
return on_init_inner();
} catch (...) {

105
mode-switching-fix.patch Normal file
View File

@ -0,0 +1,105 @@
diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp
index 472abd6dc..74a574fe3 100644
--- a/src/slic3r/GUI/GUI_App.cpp
+++ b/src/slic3r/GUI/GUI_App.cpp
@@ -707,7 +707,7 @@ void GUI_App::update_mode()
void GUI_App::add_config_menu(wxMenuBar *menu)
{
auto local_menu = new wxMenu();
- wxWindowID config_id_base = wxWindow::NewControlId((int)ConfigMenuCnt);
+ wxWindowID config_id_base = wxWindow::NewControlId(int(ConfigMenuCnt));
const auto config_wizard_name = _(ConfigWizard::name(true).wx_str());
const auto config_wizard_tooltip = wxString::Format(_(L("Run %s")), config_wizard_name);
@@ -729,9 +729,9 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeSimple, _(L("Simple")), _(L("Simple View Mode")));
mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeAdvanced, _(L("Advanced")), _(L("Advanced View Mode")));
mode_menu->AppendRadioItem(config_id_base + ConfigMenuModeExpert, _(L("Expert")), _(L("Expert View Mode")));
- Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Check(get_mode() == comSimple); }, config_id_base + ConfigMenuModeSimple);
- Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Check(get_mode() == comAdvanced); }, config_id_base + ConfigMenuModeAdvanced);
- Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Check(get_mode() == comExpert); }, config_id_base + ConfigMenuModeExpert);
+ Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { if(get_mode() == comSimple) evt.Check(true); }, config_id_base + ConfigMenuModeSimple);
+ Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { if(get_mode() == comAdvanced) evt.Check(true); }, config_id_base + ConfigMenuModeAdvanced);
+ Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { if(get_mode() == comExpert) evt.Check(true); }, config_id_base + ConfigMenuModeExpert);
local_menu->AppendSubMenu(mode_menu, _(L("Mode")), wxString::Format(_(L("%s View Mode")), SLIC3R_APP_NAME));
local_menu->AppendSeparator();
@@ -810,10 +810,14 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
break;
}
});
- mode_menu->Bind(wxEVT_MENU, [this, config_id_base](wxEvent& event) {
- int id_mode = event.GetId() - config_id_base;
- save_mode(id_mode - ConfigMenuModeSimple);
- });
+
+ using std::placeholders::_1;
+
+ auto modfn = [this](int mode, wxCommandEvent&) { if(get_mode() != mode) save_mode(mode); };
+ mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comSimple, _1), config_id_base + ConfigMenuModeSimple);
+ mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comAdvanced, _1), config_id_base + ConfigMenuModeAdvanced);
+ mode_menu->Bind(wxEVT_MENU, std::bind(modfn, comExpert, _1), config_id_base + ConfigMenuModeExpert);
+
menu->Append(local_menu, _(L("&Configuration")));
}
diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp
index 103a9ecf0..76ba853dc 100644
--- a/src/slic3r/GUI/wxExtensions.cpp
+++ b/src/slic3r/GUI/wxExtensions.cpp
@@ -2557,6 +2557,11 @@ ModeSizer::ModeSizer(wxWindow *parent, int hgap/* = 10*/) :
{_(L("Expert")), "mode_expert_sq.png"}
};
+ auto modebtnfn = [](wxCommandEvent &event, int mode_id) {
+ Slic3r::GUI::wxGetApp().save_mode(mode_id);
+ event.Skip();
+ };
+
m_mode_btns.reserve(3);
for (const auto& button : buttons) {
#ifdef __WXOSX__
@@ -2567,37 +2572,22 @@ ModeSizer::ModeSizer(wxWindow *parent, int hgap/* = 10*/) :
#else
m_mode_btns.push_back(new ModeButton(parent, wxID_ANY, button.second, button.first));;
#endif // __WXOSX__
+
+ m_mode_btns.back()->Bind(wxEVT_BUTTON, std::bind(modebtnfn, std::placeholders::_1, m_mode_btns.size() - 1));
+ Add(m_mode_btns.back());
}
-
- for (auto btn : m_mode_btns)
- {
- btn->Bind(wxEVT_BUTTON, [btn, this](wxCommandEvent &event) {
- event.Skip();
- int mode_id = 0;
- for (auto cur_btn : m_mode_btns) {
- if (cur_btn == btn)
- break;
- else
- mode_id++;
- }
- Slic3r::GUI::wxGetApp().save_mode(mode_id);
- });
-
- Add(btn);
- }
-
}
void ModeSizer::SetMode(const int mode)
{
- for (int m = 0; m < m_mode_btns.size(); m++)
- m_mode_btns[m]->SetState(m == mode);
+ for (size_t m = 0; m < m_mode_btns.size(); m++)
+ m_mode_btns[m]->SetState(int(m) == mode);
}
void ModeSizer::msw_rescale()
{
- for (int m = 0; m < m_mode_btns.size(); m++)
+ for (size_t m = 0; m < m_mode_btns.size(); m++)
m_mode_btns[m]->msw_rescale();
}

13
patch-expat-includes Normal file
View File

@ -0,0 +1,13 @@
diff --git a/src/libslic3r/Format/AMF.cpp b/src/libslic3r/Format/AMF.cpp
index ff1da37..a3f92e4 100644
--- a/src/libslic3r/Format/AMF.cpp
+++ b/src/libslic3r/Format/AMF.cpp
@@ -2,7 +2,7 @@
#include <string.h>
#include <map>
#include <string>
-#include <expat/expat.h>
+#include <expat.h>
#include <boost/nowide/cstdio.hpp>

65
patch-miniz-includes Normal file
View File

@ -0,0 +1,65 @@
diff --git a/src/libslic3r/Format/3mf.cpp b/src/libslic3r/Format/3mf.cpp
index 5a16a6e..2023259 100644
--- a/src/libslic3r/Format/3mf.cpp
+++ b/src/libslic3r/Format/3mf.cpp
@@ -16,7 +16,7 @@
#include <expat.h>
#include <Eigen/Dense>
-#include <miniz/miniz_zip.h>
+#include <miniz.h>
// VERSION NUMBERS
// 0 : .3mf, files saved by older slic3r or other applications. No version definition in them.
diff --git a/src/libslic3r/Format/AMF.cpp b/src/libslic3r/Format/AMF.cpp
index a3f92e4..f85c6d6 100644
--- a/src/libslic3r/Format/AMF.cpp
+++ b/src/libslic3r/Format/AMF.cpp
@@ -16,7 +16,7 @@
#include <boost/filesystem/operations.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/nowide/fstream.hpp>
-#include <miniz/miniz_zip.h>
+#include <miniz.h>
#if 0
// Enable debugging and assert in this file.
diff --git a/src/libslic3r/Format/PRUS.cpp b/src/libslic3r/Format/PRUS.cpp
index 80aae75..04cedc0 100644
--- a/src/libslic3r/Format/PRUS.cpp
+++ b/src/libslic3r/Format/PRUS.cpp
@@ -4,7 +4,7 @@
#include <boost/algorithm/string.hpp>
#include <boost/nowide/convert.hpp>
-#include <miniz/miniz_zip.h>
+#include <miniz.h>
#include <Eigen/Geometry>
diff --git a/src/libslic3r/Rasterizer/Rasterizer.cpp b/src/libslic3r/Rasterizer/Rasterizer.cpp
index 6384a24..e121355 100644
--- a/src/libslic3r/Rasterizer/Rasterizer.cpp
+++ b/src/libslic3r/Rasterizer/Rasterizer.cpp
@@ -15,7 +15,7 @@
#include <agg/agg_path_storage.h>
// Experimental minz image write:
-#include <miniz/miniz_tdef.h>
+#include <miniz.h>
namespace Slic3r {
diff --git a/src/libslic3r/Zipper.cpp b/src/libslic3r/Zipper.cpp
index 4466f1b..16f4f5b 100644
--- a/src/libslic3r/Zipper.cpp
+++ b/src/libslic3r/Zipper.cpp
@@ -3,7 +3,7 @@
#include <iostream>
#include "Zipper.hpp"
-#include "miniz/miniz_zip.h"
+#include <miniz.h>
#include <boost/log/trivial.hpp>
#include "I18N.hpp"

17
patch-qhull-includes Normal file
View File

@ -0,0 +1,17 @@
diff --git a/src/libslic3r/TriangleMesh.cpp b/src/libslic3r/TriangleMesh.cpp
index 20c9a9c..4d35cab 100644
--- a/src/libslic3r/TriangleMesh.cpp
+++ b/src/libslic3r/TriangleMesh.cpp
@@ -2,9 +2,9 @@
#include "ClipperUtils.hpp"
#include "Geometry.hpp"
#include "Tesselate.hpp"
-#include "qhull/src/libqhullcpp/Qhull.h"
-#include "qhull/src/libqhullcpp/QhullFacetList.h"
-#include "qhull/src/libqhullcpp/QhullVertexSet.h"
+#include <libqhullcpp/Qhull.h>
+#include <libqhullcpp/QhullFacetList.h>
+#include <libqhullcpp/QhullVertexSet.h>
#include <cmath>
#include <deque>
#include <queue>

16
prusa-slicer.appdata.xml Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<application>
<id type="desktop">prusa-slicer.desktop</id>
<metadata_license>0BSD</metadata_license>
<project_licence>AGPLv3</project_licence>
<summary>3D printing slicer optimized for Prusa printers</summary>
<description>
<p>PrusaSlicer takes 3D models (STL, OBJ, AMF) and converts them into G-code instructions for FFF printers or PNG layers for mSLA 3D printers. It's compatible with any modern printer based on the RepRap toolchain, including all those based on the Marlin, Prusa, Sprinter and Repetier firmware. It also works with Mach3, LinuxCNC and Machinekit controllers.</p>
<p>PrusaSlicer is based on Slic3r by Alessandro Ranelucci and the RepRap community.</p>
</description>
<screenshots>
<screenshot type="default" width="1152" height="940">https://www.prusa3d.com/wp-content/uploads/2018/07/image.jpg</screenshot>
</screenshots>
<url type="homepage">https://github.com/prusa3d/PrusaSlicer/</url>
<updatecontact>bubnikv@gmail.com</updatecontact>
</application>

12
prusa-slicer.desktop Normal file
View File

@ -0,0 +1,12 @@
[Desktop Entry]
Name=PrusaSlicer
GenericName=3D Printing Software
Icon=prusa-slicer
Exec=prusa-slicer %F
Terminal=false
Type=Application
MimeType=model/stl;model/x-wavefront-obj;model/3mf;model/x-geomview-off;application/x-amf;
Categories=Graphics;3DGraphics;Engineering;
Keywords=3D;Printing;Slicer;slice;3D;printer;convert;gcode;stl;obj;amf;SLA
StartupNotify=false
StartupWMClass=prusa-slicer

473
prusa-slicer.spec Normal file
View File

@ -0,0 +1,473 @@
# Currently all of the test suite requires the old Perl infrastructure to run.
%bcond_without perltests
Name: prusa-slicer
Version: 2.0.0
Release: 2%{?dist}
Summary: 3D printing slicer optimized for Prusa printers
# The main PrusaSlicer code and resources are AGPLv3, with small parts as
# Boost. but it includes some bundled libraries under varying licenses which
# are statically linked into the main executable. The full list would be:
# "AGPLv3 and CC-BY and GPLv2+ and (Copyright only or BSD) and Boost and
# MPLv2.0 and MIT and Unlicense and zlib and Qhull" (with Unlicense removed in
# F31) but the AGPLv3 dominates in the final executable.
# Technically the appdata.xml file is 0BSD but it seems quite pointless to list
# that here.
License: AGPLv3
URL: https://github.com/prusa3d/PrusaSlicer/
Source0: https://github.com/prusa3d/PrusaSlicer/archive/version_2.0.0.tar.gz
Source1: %name.desktop
Source2: %name.appdata.xml
# Fix an improper include of expat.h
# https://github.com/prusa3d/PrusaSlicer/pull/2315
Patch0: patch-expat-includes
# Fix improper qhull include locations
# https://github.com/prusa3d/PrusaSlicer/pull/2319
Patch1: patch-qhull-includes
# Fix a number of failing unit tests
# https://github.com/prusa3d/PrusaSlicer/issues/2288
Patch10: https://github.com/prusa3d/PrusaSlicer/commit/07282eb24d027817b4279f59ebbf0d80bac5f950.patch
# These patches are pulled from upstream's Debian packaging, and were cherry picked from post-release commits.
# I (JT) have not personally seen the bugs these fix but upstream asked that they be included.
Patch20: https://raw.githubusercontent.com/prusa3d/PrusaSlicer/debian/debian/patches/fix-gizmo-icon-size.patch
Patch21: https://raw.githubusercontent.com/prusa3d/PrusaSlicer/debian/debian/patches/handle-wx-assert-with-boost.patch
Patch22: https://raw.githubusercontent.com/prusa3d/PrusaSlicer/debian/debian/patches/mode-switching-fix.patch
# Currently a single test fails on these two architctures. See
# https://github.com/prusa3d/PrusaSlicer/issues/2461
# The test could be disabled but without a way to know if it will break
# something, it's safer to see what upstream has to say about it first.
ExcludeArch: s390x aarch64
BuildRequires: boost-devel
BuildRequires: cmake
BuildRequires: curl-devel
BuildRequires: desktop-file-utils
BuildRequires: eigen3-devel
BuildRequires: expat-devel
BuildRequires: gcc-c++
BuildRequires: gettext
BuildRequires: git-core
BuildRequires: glew-devel
BuildRequires: gtest-devel
BuildRequires: ImageMagick
BuildRequires: miniz-devel
BuildRequires: NLopt-devel
BuildRequires: tbb-devel
BuildRequires: wxBase3-devel
BuildRequires: wxGTK3-devel
# Upstream says this is obsolete, but still needed to compile
BuildRequires: poly2tri-devel
# Things we wish we could unbundle
#BuildRequires: admesh-devel >= 0.98.1
#BuildRequires: polyclipping-devel >= 6.2.0
#BuildRequires: boost-nowide-devel
#BuildRequires: qhull-devel
%if %{with perltests}
# All of the old Perl dependencies needed to run the test suite
BuildRequires: perl-devel
BuildRequires: perl-generators
BuildRequires: perl(Class::XSAccessor)
BuildRequires: perl(Devel::CheckLib)
BuildRequires: perl(Encode::Locale)
BuildRequires: perl(ExtUtils::Embed)
BuildRequires: perl(ExtUtils::MakeMaker)
BuildRequires: perl(ExtUtils::ParseXS)
BuildRequires: perl(ExtUtils::Typemaps::Default)
BuildRequires: perl(ExtUtils::Typemaps)
BuildRequires: perl(File::Basename)
BuildRequires: perl(File::Spec)
BuildRequires: perl(Getopt::Long)
BuildRequires: perl(Growl::GNTP)
BuildRequires: perl(IO::Scalar)
BuildRequires: perl(List::Util)
BuildRequires: perl(local::lib)
BuildRequires: perl(Math::PlanePath)
BuildRequires: perl(Module::Build::WithXSpp)
BuildRequires: perl(Moo)
BuildRequires: perl(parent)
BuildRequires: perl(POSIX)
BuildRequires: perl(Scalar::Util)
BuildRequires: perl(Storable)
BuildRequires: perl(SVG)
BuildRequires: perl(Test::Harness)
BuildRequires: perl(Test::More)
BuildRequires: perl(Thread::Semaphore)
BuildRequires: perl(threads)
BuildRequires: perl(Time::HiRes)
BuildRequires: perl(Unicode::Normalize)
BuildRequires: perl(Wx)
BuildRequires: perl(XML::SAX)
BuildRequires: perl(XML::SAX::ExpatXS)
%endif
Requires: hicolor-icon-theme
# === Bundled libraries ===
# Many are described here:
# https://github.com/prusa3d/PrusaSlicer/blob/master/doc/Dependencies.md
# Note that the developers have performed the worst sort of bundling: they are
# often using random portions of other projects, without keeping documentation
# or license files, and adding their own build system. It can be very
# difficult to tell what versions have been bundled or even where they came
# from.
# Upstream has custom patches, reluctant to send to upstream
# License: GPLv2+
# Upstream: http://github.com/admesh/admesh/
Provides: bundled(admesh-libs) = 0.98.1
# This is a header-only library, not packaged in Fedora
# License: Copyright only or BSD
# Upstream: http://antigrain.com
Provides: bundled(agg) = 2.4
# Patched to fix a bug in some Prusa hardware
# License: GPLv2+
# Upstream: http://www.nongnu.org/avrdude
Provides: bundled(avrdude) = 6.3
# This could be unbundled, but the Fedora package is broken....
# This is a version from 2017, seemingly the last commit available.
# Fedora bug: https://bugzilla.redhat.com/show_bug.cgi?id=1712550
# License: Boost
# Upstream: https://github.com/artyom-beilis/nowide
Provides: bundled(boost-nowide)
# License: MPLv2.0
# Upstream: https://github.com/libigl/libigl
Provides: bundled(igl)
# Not packaged in Fedora, but could be.
# License: MIT
# Upstream: https://github.com/ocornut/imgui
Provides: bundled(imgui) = 1.66
# Some old code extracted from mesa libGLU that was last changed upstream in
# 2010 and last substantially changed before things were imported to git.
# The files are in src/glu-libtess.
# License: MIT
Provides: bundled(mesa-libGLU)
%if %{?fedora <= 30}
# For <= F30, the system miniz is too old to be used. The bundled library is a
# fork from somewhere around 2.0.6, with various C++ source files added.
# License: MIT and Unlicense
Provides: bundled(miniz) = 2.0.6
%endif
# A header-only library, developed by one of the authors of PrusaSlicer. Not
# packaged in Fedora, but could be (for little benefit).
# None of the source files carry licensing information, but a file LICENSE.txt
# exists and contains the AGPL text.
# License: AGPLv3
# Upstream: https://github.com/tamasmeszaros/libnest2d
Provides: bundled(libnest2d) = 0.3.2
# A tiny header-only library, not packaged in Fedora (but could be, though
# there is little point). The filees appear to include commits up to and
# including one made on 2018-12-14 (c1f6e20) but nothing after.
# License: zlib
# Upstream: https://github.com/memononen/nanosvg
Provides: bundled(nanosvg)
# Two files from an old version of the Clipper/polyclipping library are used,
# but have been modified to add dependencies on other pieces of PrusaSlicer and
# to other bundled libraries. The library is packaged in Fedora but that
# version is not usable. (The bundled files are in src/clipper.)
# License: Boost
# Upstream: https://sourceforge.net/projects/polyclipping
Provides: bundled(polyclipping) = 6.2.9
# A tiny library, not packaged in Fedora (but could be). Supposedly this is a
# candidate for removal but is still required for compilation.
# License: MIT
# Upstream: https://github.com/ivanfratric/polypartition
Provides: bundled(polypartition)
# It looks like we could unbundle this, but the Fedora package is old and
# doesn't appear to be suitable. There is one change from upstream: in
# lib
# this, the compilation will fail as the slicer code expects floats while qhull
# uses doubles.
# License: Qhull
# Upstream: http://www.qhull.org
Provides: bundled(qhull) = 2016.01
# Is intended to be embedded (or installed into a source tree using clib).
# Could technically be packaged in Fedora but isn't currently.
# License: MIT
# Upstream: https://github.com/h2non/semver.c
Provides: bundled(semver) = 1.0.0
# Not packaged in Fedora; this is different from the existing "shiny" package.
# Upstream seems dead or idle as well. To top it all off, the files have been
# reorganized from the upstream version. Could technically be packaged, but
# PrusaSlicer would probably need patches to use it.
# License: MIT
# Upstream: https://sourceforge.net/projects/shinyprofiler/
Provides: bundled(shinyprofiler) = 2.6~rc1
# In case someone tries to install the upstream name
Provides: PrusaSlicer = %version-%release
# Because the old profiles are not compatible, don't replace slic3r-prusa3d
# until F31. Both packages can be installed and used in parallel
%if %{?fedora} >= 31
Obsoletes: slic3r-prusa3d < 1.41.3-2
Provides: slic3r-prusa3d = %version-%release
%endif
%description
PrusaSlicer takes 3D models (STL, OBJ, AMF) and converts them into G-code
instructions for FFF printers or PNG layers for mSLA 3D printers. It's
compatible with any modern printer based on the RepRap toolchain, including all
those based on the Marlin, Prusa, Sprinter and Repetier firmware. It also works
with Mach3, LinuxCNC and Machinekit controllers.
PrusaSlicer is based on Slic3r by Alessandro Ranelucci and the RepRap
community.
%prep
%autosetup -S git -n PrusaSlicer-version_2.0.0
commit () { git commit -q -a -m "$1" --author "%{__scm_author}"; }
# Fix the "UNKNOWN" in the displayed version string
sed -i 's/UNKNOWN/Fedora/' version.inc
commit "Fix version string"
# F29 has the nlopt library under a different name
%if %{?fedora} < 30
sed -ri 's/^(.*_NLopt_LIB_NAMES "nlopt)(".*)$/\1_cxx\2/' src/libnest2d/cmake_modules/FindNLopt.cmake
commit "Fix name of nlopt library"
%endif
# Copy out specific license files so we can reference them later.
license () { mv src/$1/$2 $2-$1; git add $2-$1; echo %%license $2-$1 >> license-files; }
license agg copying
license avrdude COPYING
license imgui LICENSE.txt
license libnest2d LICENSE.txt
license qhull COPYING.txt
commit "Move license files"
# Delete a stray font file
rm -rf resources/fonts
commit "Remove stray font file"
# Unbundle libraries
unbundle () {
rm -rf src/$1
sed -i "/add_subdirectory($1)/d" src/CMakeLists.txt
commit "Unbundle $1"
}
unbundle eigen
unbundle expat
unbundle glew
# This code doesn't seem to be used, so remove it to (potentially) simplify the
# licensing issue.
unbundle igl/copyleft
# Upstream says this is obsolete, but it's still needed for compilation.
# The Fedora version appears to work fine for that purpose so we'll use it.
unbundle poly2tri
# The miniz in F30 is too old to unbundle.
# The sed could be a patch, but conditionally applying patches is problematic
# and this will be fixed upstream in the next release.
%if %{?fedora} >= 31
unbundle miniz
sed -i 's/^#include.*miniz.*/#include <miniz.h>/' \
src/libslic3r/Format/{3mf.cpp,AMF.cpp,PRUS.cpp} \
src/libslic3r/Rasterizer/Rasterizer.cpp \
src/libslic3r/Zipper.cpp
commit "Fix miniz includes"
%endif
%build
mkdir Build
pushd Build
# -DSLIC3R_PCH=0 - Disable precompiled headers, which break cmake for some reason
# -DSLIC3R_FHS=1 - Enable FHS layout instead of installing things into the resources directory
# -DSLIC3R_WX_STABLE=1 - Allow use of wxGTK version 3.0 instead of 3.1.
%cmake .. -DSLIC3R_PCH=0 -DSLIC3R_FHS=1 -DSLIC3R_WX_STABLE=1 -DSLIC3R_GTK=3 \
-DSLIC3R_BUILD_TESTS=1 -DCMAKE_BUILD_TYPE=Release \
%if %{with perltests}
-DSLIC3R_PERL_XS=1
%endif
%make_build
popd
# Extract multiple sizes of PNG from the included .ico file. The order of
# extracted files can change, so a bit of magic is required to get stable
# filenames.
mkdir hicolor
pushd hicolor
convert -set filename:dim '%%wx%%h' ../resources/icons/PrusaSlicer.ico %name-%%[filename:dim].png
for res in 16 32 48 64 128 256; do
mkdir -p ${res}x${res}/apps
cp %name-${res}x${res}.png ${res}x${res}/apps/%name.png
done
rm %name-*.png
popd
# To avoid "iCCP: Not recognized known sRGB profile that has been edited"
pushd resources/icons
find . -type f -name "*.png" -exec convert {} -strip {} \;
popd
%install
pushd Build
%make_install
popd
mkdir -p %buildroot%_datadir/icons/hicolor/
cp -r hicolor/* %buildroot%_datadir/icons/hicolor/
mkdir -p %buildroot%_datadir/appdata
install -m 644 %SOURCE2 %buildroot%_datadir/appdata/%name.appdata.xml
desktop-file-install --dir=%buildroot%_datadir/applications %SOURCE1
# For now, delete the Perl module that gets installed. It only exists because
# we want the test suite to run. It could be placed into a subpackage, but
# nothing needs it currently and it would conflict with the other slic3r
# package.
rm -rf %buildroot/%perl_vendorarch
rm -rf %buildroot/%perl_vendorlib
# Upstream installs the translation source files when they probably shouldn't
ls -lR %buildroot%_datadir/PrusaSlicer/localization
rm %buildroot%_datadir/PrusaSlicer/localization/{PrusaSlicer.pot,list.txt}
find %buildroot%_datadir/PrusaSlicer/localization/ -name \*.po -delete
# Handle locale files. The find_lang macro doesn't work because it doesn't
# understand the directory structure. This copies part of the funtionality of
# find-lang.sh by:
# * Getting a listing of all files
# * removing the buildroot prefix
# * inserting the proper 'lang' tag
# * removing everything that doesn't have a lang tag
# * A list of lang-specific directories is also added
# The resulting file is included in the files list, where we must be careful to
# exclude that directory.
find %buildroot%_datadir/PrusaSlicer/localization -type f -o -type l | sed '
s:'"%buildroot"'::
s:\(.*/PrusaSlicer/localization/\)\([^/_]\+\)\(.*\.mo$\):%%lang(\2) \1\2\3:
s:^\([^%].*\)::
s:%lang(C) ::
/^$/d
' > lang-files
find %buildroot%_datadir/PrusaSlicer/localization -type d | sed '
s:'"%buildroot"'::
s:\(.*\):%dir \1:
' >> lang-files
%check
# Some tests are Perl but there is a framework for other tests even though
# currently the only thing that uses them is one of the bundled libraries.
# There's no reason not to run as much as we can.
pushd Build
make test ARGS=-V
%files -f license-files -f lang-files
%license LICENSE
%doc README.md
%_bindir/%name
%_datadir/icons/hicolor/*/apps/%name.png
%_datadir/applications/%name.desktop
%_datadir/appdata/%name.appdata.xml
%dir %_datadir/PrusaSlicer
%_datadir/PrusaSlicer/{icons,models,profiles,shaders}/
%changelog
* Wed Jun 05 2019 Jason L Tibbitts III <tibbs@math.uh.edu> - 2.0.0-2
- Update with review feedback.
* Mon May 20 2019 Jason L Tibbitts III <tibbs@math.uh.edu> - 2.0.0-1
- Update to 2.0.0 final release.
* Fri Feb 15 2019 Jason L Tibbitts III <tibbs@math.uh.edu> - 1.41.3-1
- Update to 1.41.3.
* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.41.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Wed Jan 30 2019 Jonathan Wakely <jwakely@redhat.com> - 1.41.0-3
- Rebuilt and patched for Boost 1.69
* Sun Dec 23 2018 Miro Hrončok <mhroncok@redhat.com> - 1.41.0-2
- Set GDK_BACKEND=x11 to prevent crashes on Wayland (#1661324)
* Mon Oct 1 2018 Tom Callaway <spot@fedoraproject.org> - 1.41.0-1
- update to 1.41.0
* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.33.8-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Sat Jun 30 2018 Jitka Plesnikova <jplesnik@redhat.com> - 1.33.8-11
- Perl 5.28 rebuild
* Tue Jun 05 2018 Jitka Plesnikova <jplesnik@redhat.com> - 1.33.8-10
- Add missing BR perl(ExtUtils::CBuilder)
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.33.8-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
* Thu Jan 18 2018 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 1.33.8-8
- Remove obsolete scriptlets
- Rebuilt for new boost
* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.33.8-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.33.8-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
* Wed Jul 19 2017 Jonathan Wakely <jwakely@redhat.com> - 1.33.8-5
- Rebuilt for s390x binutils bug
* Tue Jul 18 2017 Jonathan Wakely <jwakely@redhat.com> - 1.33.8-4
- Rebuilt for Boost 1.64
* Thu Jun 08 2017 Jitka Plesnikova <jplesnik@redhat.com> - 1.33.8-3
- Perl 5.26 re-rebuild of bootstrapped packages
* Mon May 15 2017 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.33.8-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_27_Mass_Rebuild
* Wed Feb 22 2017 Miro Hrončok <mhroncok@redhat.com> - 1.33.8-1
- Update to 1.33.8
- Mention it's a fork in the description and appdata file
- Require hicolor-icon-theme
- Exclude big endian arches
* Sat Dec 17 2016 Miro Hrončok <mhroncok@redhat.com> - 1.31.6-1
- Update to 1.31.6
- Bundle admesh
- Recommend Thread::Queue for faster slicing
- Unbundle glew
* Fri Nov 11 2016 Miro Hrončok <mhroncok@redhat.com> - 1.31.4-1
- New package adapted from the slic3r package