Merge remote-tracking branch 'origin/master' into ys_new_features

This commit is contained in:
YuSanka 2019-05-22 13:51:49 +02:00
commit ccdd68f157
20 changed files with 9564 additions and 1428 deletions

33
doc/Dependencies.md Normal file
View File

@ -0,0 +1,33 @@
# Dependency report for PrusaSlicer
## Possible dynamic linking on Linux
* zlib: This should not be even mentioned in our cmake scripts but due to a bug in the system libraries of gtk it has to be linked to PrusaSlicer.
* wxWidgets: searches for wx-3.1 by default, but with cmake option `SLIC3R_WX_STABLE=ON` it will use wx-3.0 bundled with most distros.
* libcurl
* tbb
* boost
* eigen
* glew
* expat
* openssl
* nlopt
* gtest
## External libraries in source tree
* ad-mesh: Lots of customization, have to be bundled in the source tree.
* avrdude: Like ad-mesh, many customization, need to be in the source tree.
* clipper: An important library we have to have full control over it. We also have some slicer specific modifications.
* glu-libtess: This is an extract of the mesa/glu library not oficially available as a package.
* imgui: no packages for debian, author suggests using in the source tree
* miniz: No packages, author suggests using in the source tree
* qhull: libqhull-dev does not contain libqhullcpp => link errors. Until it is fixed, we will use the builtin version. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=925540
* semver: One module C library, author expects to use clib for installation. No packages.
* Shiny: no packages
* poly2tree: Obsolete, candidate for removal
* polypartition: Obsolete, candidate for removal
## Header only
* igl
* nanosvg
* agg

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -508,10 +508,12 @@ void ConfigBase::load_from_gcode_file(const std::string &file)
boost::nowide::ifstream ifs(file);
{
const char slic3r_gcode_header[] = "; generated by Slic3r ";
const char prusaslicer_gcode_header[] = "; generated by PrusaSlicer ";
std::string firstline;
std::getline(ifs, firstline);
if (strncmp(slic3r_gcode_header, firstline.c_str(), strlen(slic3r_gcode_header)) != 0)
throw std::runtime_error("Not a Slic3r generated g-code.");
if (strncmp(slic3r_gcode_header, firstline.c_str(), strlen(slic3r_gcode_header)) != 0 &&
strncmp(prusaslicer_gcode_header, firstline.c_str(), strlen(prusaslicer_gcode_header)) != 0)
throw std::runtime_error("Not a PrusaSlicer / Slic3r PE generated g-code.");
}
ifs.seekg(0, ifs.end);
auto file_length = ifs.tellg();

View File

@ -2,7 +2,7 @@
#include <string.h>
#include <map>
#include <string>
#include <expat/expat.h>
#include <expat.h>
#include <boost/nowide/cstdio.hpp>

View File

@ -1180,7 +1180,6 @@ Transform3d assemble_transform(const Vec3d& translation, const Vec3d& rotation,
Vec3d extract_euler_angles(const Eigen::Matrix<double, 3, 3, Eigen::DontAlign>& rotation_matrix)
{
#if ENABLE_NEW_EULER_ANGLES
// reference: http://www.gregslabaugh.net/publications/euler.pdf
Vec3d angles1 = Vec3d::Zero();
Vec3d angles2 = Vec3d::Zero();
@ -1219,40 +1218,7 @@ Vec3d extract_euler_angles(const Eigen::Matrix<double, 3, 3, Eigen::DontAlign>&
double min_2 = angles2.cwiseAbs().minCoeff();
bool use_1 = (min_1 < min_2) || (is_approx(min_1, min_2) && (angles1.norm() <= angles2.norm()));
Vec3d angles = use_1 ? angles1 : angles2;
#else
auto y_only = [](const Eigen::Matrix<double, 3, 3, Eigen::DontAlign>& matrix) -> bool {
return (matrix(0, 1) == 0.0) && (matrix(1, 0) == 0.0) && (matrix(1, 1) == 1.0) && (matrix(1, 2) == 0.0) && (matrix(2, 1) == 0.0);
};
// see: https://www.learnopencv.com/rotation-matrix-to-euler-angles/
double cy_abs = ::sqrt(sqr(rotation_matrix(0, 0)) + sqr(rotation_matrix(1, 0)));
Vec3d angles = Vec3d::Zero();
if (cy_abs >= 1e-6)
{
angles(0) = ::atan2(rotation_matrix(2, 1), rotation_matrix(2, 2));
angles(1) = ::atan2(-rotation_matrix(2, 0), cy_abs);
angles(2) = ::atan2(rotation_matrix(1, 0), rotation_matrix(0, 0));
// this is an hack to try to avoid this function to return "strange" values due to gimbal lock
if (y_only(rotation_matrix) && (angles(0) == (double)PI) && (angles(2) == (double)PI))
{
angles(0) = 0.0;
angles(1) = ::atan2(rotation_matrix(2, 0), cy_abs) - (double)PI;
angles(2) = 0.0;
}
}
else
{
angles(0) = 0.0;
angles(1) = ::atan2(-rotation_matrix(2, 0), cy_abs);
angles(2) = (angles(1) >= 0.0) ? ::atan2(rotation_matrix(1, 2), rotation_matrix(1, 1)) : ::atan2(-rotation_matrix(1, 2), rotation_matrix(1, 1));
}
#endif // ENABLE_NEW_EULER_ANGLES
return angles;
return use_1 ? angles1 : angles2;
}
Vec3d extract_euler_angles(const Transform3d& transform)
@ -1288,18 +1254,8 @@ void Transformation::Flags::set(bool dont_translate, bool dont_rotate, bool dont
}
Transformation::Transformation()
#if !ENABLE_VOLUMES_CENTERING_FIXES
: m_offset(Vec3d::Zero())
, m_rotation(Vec3d::Zero())
, m_scaling_factor(Vec3d::Ones())
, m_mirror(Vec3d::Ones())
, m_matrix(Transform3d::Identity())
, m_dirty(false)
#endif // !ENABLE_VOLUMES_CENTERING_FIXES
{
#if ENABLE_VOLUMES_CENTERING_FIXES
reset();
#endif // ENABLE_VOLUMES_CENTERING_FIXES
}
Transformation::Transformation(const Transform3d& transform)
@ -1420,7 +1376,6 @@ void Transformation::set_from_transform(const Transform3d& transform)
// std::cout << "something went wrong in extracting data from matrix" << std::endl;
}
#if ENABLE_VOLUMES_CENTERING_FIXES
void Transformation::reset()
{
m_offset = Vec3d::Zero();
@ -1430,7 +1385,6 @@ void Transformation::reset()
m_matrix = Transform3d::Identity();
m_dirty = false;
}
#endif // ENABLE_VOLUMES_CENTERING_FIXES
const Transform3d& Transformation::get_matrix(bool dont_translate, bool dont_rotate, bool dont_scale, bool dont_mirror) const
{

View File

@ -253,9 +253,7 @@ public:
void set_from_transform(const Transform3d& transform);
#if ENABLE_VOLUMES_CENTERING_FIXES
void reset();
#endif // ENABLE_VOLUMES_CENTERING_FIXES
const Transform3d& get_matrix(bool dont_translate = false, bool dont_rotate = false, bool dont_scale = false, bool dont_mirror = false) const;

View File

@ -503,9 +503,7 @@ void Model::convert_multipart_object(unsigned int max_extruders)
{
new_v->name = o->name;
new_v->config.set_deserialize("extruder", get_auto_extruder_id_as_string(max_extruders));
#if ENABLE_VOLUMES_CENTERING_FIXES
new_v->translate(-o->origin_translation);
#endif // ENABLE_VOLUMES_CENTERING_FIXES
}
}
@ -681,9 +679,7 @@ ModelVolume* ModelObject::add_volume(const TriangleMesh &mesh)
{
ModelVolume* v = new ModelVolume(this, mesh);
this->volumes.push_back(v);
#if ENABLE_VOLUMES_CENTERING_FIXES
v->center_geometry();
#endif // ENABLE_VOLUMES_CENTERING_FIXES
this->invalidate_bounding_box();
return v;
}
@ -692,9 +688,7 @@ ModelVolume* ModelObject::add_volume(TriangleMesh &&mesh)
{
ModelVolume* v = new ModelVolume(this, std::move(mesh));
this->volumes.push_back(v);
#if ENABLE_VOLUMES_CENTERING_FIXES
v->center_geometry();
#endif // ENABLE_VOLUMES_CENTERING_FIXES
this->invalidate_bounding_box();
return v;
}
@ -703,9 +697,7 @@ ModelVolume* ModelObject::add_volume(const ModelVolume &other)
{
ModelVolume* v = new ModelVolume(this, other);
this->volumes.push_back(v);
#if ENABLE_VOLUMES_CENTERING_FIXES
v->center_geometry();
#endif // ENABLE_VOLUMES_CENTERING_FIXES
this->invalidate_bounding_box();
return v;
}
@ -714,9 +706,7 @@ ModelVolume* ModelObject::add_volume(const ModelVolume &other, TriangleMesh &&me
{
ModelVolume* v = new ModelVolume(this, other, std::move(mesh));
this->volumes.push_back(v);
#if ENABLE_VOLUMES_CENTERING_FIXES
v->center_geometry();
#endif // ENABLE_VOLUMES_CENTERING_FIXES
this->invalidate_bounding_box();
return v;
}
@ -727,7 +717,6 @@ void ModelObject::delete_volume(size_t idx)
delete *i;
this->volumes.erase(i);
#if ENABLE_VOLUMES_CENTERING_FIXES
if (this->volumes.size() == 1)
{
// only one volume left
@ -743,24 +732,6 @@ void ModelObject::delete_volume(size_t idx)
v->set_transformation(t);
v->set_new_unique_id();
}
#else
if (this->volumes.size() == 1)
{
// only one volume left
// center it and update the instances accordingly
// rationale: the volume may be shifted with respect to the object center and this may lead to wrong rotation and scaling
// when modifying the instance matrix of the derived GLVolume
ModelVolume* v = this->volumes.front();
v->center_geometry();
const Vec3d& vol_offset = v->get_offset();
for (ModelInstance* inst : this->instances)
{
inst->set_offset(inst->get_offset() + inst->get_matrix(true) * vol_offset);
}
v->set_offset(Vec3d::Zero());
v->set_new_unique_id();
}
#endif // ENABLE_VOLUMES_CENTERING_FIXES
this->invalidate_bounding_box();
}
@ -903,28 +874,15 @@ const BoundingBoxf3& ModelObject::raw_bounding_box() const
if (! m_raw_bounding_box_valid) {
m_raw_bounding_box_valid = true;
m_raw_bounding_box.reset();
#if ENABLE_GENERIC_SUBPARTS_PLACEMENT
if (this->instances.empty())
throw std::invalid_argument("Can't call raw_bounding_box() with no instances");
const Transform3d& inst_matrix = this->instances.front()->get_transformation().get_matrix(true);
#endif // ENABLE_GENERIC_SUBPARTS_PLACEMENT
for (const ModelVolume *v : this->volumes)
if (v->is_model_part()) {
#if !ENABLE_GENERIC_SUBPARTS_PLACEMENT
if (this->instances.empty())
throw std::invalid_argument("Can't call raw_bounding_box() with no instances");
#endif // !ENABLE_GENERIC_SUBPARTS_PLACEMENT
#if ENABLE_GENERIC_SUBPARTS_PLACEMENT
m_raw_bounding_box.merge(v->mesh.transformed_bounding_box(inst_matrix * v->get_matrix()));
#else
// unmaintaned
assert(false);
// vol_mesh.transform(v->get_matrix());
// m_raw_bounding_box_valid.merge(this->instances.front()->transform_mesh_bounding_box(vol_mesh, true));
#endif // ENABLE_GENERIC_SUBPARTS_PLACEMENT
}
{
if (v->is_model_part())
m_raw_bounding_box.merge(v->mesh.transformed_bounding_box(inst_matrix * v->get_matrix()));
}
}
return m_raw_bounding_box;
}
@ -933,22 +891,11 @@ const BoundingBoxf3& ModelObject::raw_bounding_box() const
BoundingBoxf3 ModelObject::instance_bounding_box(size_t instance_idx, bool dont_translate) const
{
BoundingBoxf3 bb;
#if ENABLE_GENERIC_SUBPARTS_PLACEMENT
const Transform3d& inst_matrix = this->instances[instance_idx]->get_transformation().get_matrix(dont_translate);
#endif // ENABLE_GENERIC_SUBPARTS_PLACEMENT
for (ModelVolume *v : this->volumes)
{
if (v->is_model_part())
{
#if ENABLE_GENERIC_SUBPARTS_PLACEMENT
bb.merge(v->mesh.transformed_bounding_box(inst_matrix * v->get_matrix()));
#else
// not maintained
assert(false);
//mesh.transform(v->get_matrix());
//bb.merge(this->instances[instance_idx]->transform_mesh_bounding_box(mesh, dont_translate));
#endif // ENABLE_GENERIC_SUBPARTS_PLACEMENT
}
}
return bb;
}
@ -1007,22 +954,11 @@ Polygon ModelObject::convex_hull_2d(const Transform3d &trafo_instance) const
return hull;
}
#if ENABLE_VOLUMES_CENTERING_FIXES
void ModelObject::center_around_origin(bool include_modifiers)
#else
void ModelObject::center_around_origin()
#endif // ENABLE_VOLUMES_CENTERING_FIXES
{
// calculate the displacements needed to
// center this object around the origin
#if ENABLE_VOLUMES_CENTERING_FIXES
BoundingBoxf3 bb = include_modifiers ? full_raw_mesh_bounding_box() : raw_mesh_bounding_box();
#else
BoundingBoxf3 bb;
for (ModelVolume *v : this->volumes)
if (v->is_model_part())
bb.merge(v->mesh.bounding_box());
#endif // ENABLE_VOLUMES_CENTERING_FIXES
// Shift is the vector from the center of the bounding box to the origin
Vec3d shift = -bb.center();
@ -1309,9 +1245,6 @@ void ModelObject::split(ModelObjectPtrs* new_objects)
for (const ModelInstance *model_instance : this->instances)
new_object->add_instance(*model_instance);
ModelVolume* new_vol = new_object->add_volume(*volume, std::move(*mesh));
#if !ENABLE_VOLUMES_CENTERING_FIXES
new_vol->center_geometry();
#endif // !ENABLE_VOLUMES_CENTERING_FIXES
for (ModelInstance* model_instance : new_object->instances)
{
@ -1605,7 +1538,6 @@ bool ModelVolume::is_splittable() const
void ModelVolume::center_geometry()
{
#if ENABLE_VOLUMES_CENTERING_FIXES
Vec3d shift = mesh.bounding_box().center();
if (!shift.isApprox(Vec3d::Zero()))
{
@ -1613,12 +1545,6 @@ void ModelVolume::center_geometry()
m_convex_hull.translate(-(float)shift(0), -(float)shift(1), -(float)shift(2));
translate(shift);
}
#else
Vec3d shift = -mesh.bounding_box().center();
mesh.translate((float)shift(0), (float)shift(1), (float)shift(2));
m_convex_hull.translate((float)shift(0), (float)shift(1), (float)shift(2));
translate(-shift);
#endif // ENABLE_VOLUMES_CENTERING_FIXES
}
void ModelVolume::calculate_convex_hull()

View File

@ -243,11 +243,8 @@ public:
// This method is used by the auto arrange function.
Polygon convex_hull_2d(const Transform3d &trafo_instance) const;
#if ENABLE_VOLUMES_CENTERING_FIXES
void center_around_origin(bool include_modifiers = true);
#else
void center_around_origin();
#endif // ENABLE_VOLUMES_CENTERING_FIXES
void ensure_on_bed();
void translate_instances(const Vec3d& vector);
void translate_instance(size_t instance_idx, const Vec3d& vector);

View File

@ -28,19 +28,6 @@
#define ENABLE_NONCUSTOM_DATA_VIEW_RENDERING (0 && ENABLE_1_42_0_ALPHA1)
//====================
// 1.42.0.alpha4 techs
//====================
#define ENABLE_1_42_0_ALPHA4 1
// Changed algorithm to extract euler angles from rotation matrix
#define ENABLE_NEW_EULER_ANGLES (1 && ENABLE_1_42_0_ALPHA4)
// Modified initial default placement of generic subparts
#define ENABLE_GENERIC_SUBPARTS_PLACEMENT (1 && ENABLE_1_42_0_ALPHA4)
// Bunch of fixes related to volumes centering
#define ENABLE_VOLUMES_CENTERING_FIXES (1 && ENABLE_1_42_0_ALPHA4)
//====================
// 1.42.0.alpha7 techs
//====================
@ -59,12 +46,4 @@
#define ENABLE_SVG_ICONS (1 && ENABLE_1_42_0_ALPHA8 && ENABLE_TEXTURES_FROM_SVG)
//====================
// 1.42.0.rc techs
//====================
#define ENABLE_1_42_0_RC 1
// Disables Edit->Deselect all item menu item
#define DISABLE_DESELECT_ALL_MENU_ITEM (1 && ENABLE_1_42_0_RC)
#endif // _technologies_h_

View File

@ -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>

View File

@ -728,7 +728,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);
@ -750,9 +750,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();
@ -831,10 +831,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")));
}

View File

@ -1457,9 +1457,6 @@ void ObjectList::load_part( ModelObject* model_object,
delta = model_object->origin_translation - object->origin_translation;
}
for (auto volume : object->volumes) {
#if !ENABLE_VOLUMES_CENTERING_FIXES
volume->center_geometry();
#endif // !ENABLE_VOLUMES_CENTERING_FIXES
volume->translate(delta);
auto new_volume = model_object->add_volume(*volume);
new_volume->set_type(type);
@ -1582,14 +1579,6 @@ void ObjectList::load_generic_subobject(const std::string& type_name, const Mode
ModelVolume *new_volume = model_object.add_volume(std::move(mesh));
new_volume->set_type(type);
#if !ENABLE_GENERIC_SUBPARTS_PLACEMENT
new_volume->set_offset(Vec3d(0.0, 0.0, model_object.origin_translation(2) - mesh.stl.stats.min(2)));
#endif // !ENABLE_GENERIC_SUBPARTS_PLACEMENT
#if !ENABLE_VOLUMES_CENTERING_FIXES
new_volume->center_geometry();
#endif // !ENABLE_VOLUMES_CENTERING_FIXES
#if ENABLE_GENERIC_SUBPARTS_PLACEMENT
if (instance_idx != -1)
{
// First (any) GLVolume of the selected instance. They all share the same instance matrix.
@ -1605,7 +1594,6 @@ void ObjectList::load_generic_subobject(const std::string& type_name, const Mode
Vec3d(instance_bb.max(0), instance_bb.min(1), instance_bb.min(2)) + 0.5 * mesh_bb.size() - v->get_instance_offset();
new_volume->set_offset(v->get_instance_transformation().get_matrix(true).inverse() * offset);
}
#endif // ENABLE_GENERIC_SUBPARTS_PLACEMENT
new_volume->name = into_u8(name);
// set a default extruder value, since user can't add it manually

View File

@ -487,11 +487,9 @@ void MainFrame::init_menubar()
append_menu_item(editMenu, wxID_ANY, _(L("&Select all")) + sep + GUI::shortkey_ctrl_prefix() + sep_space + "A",
_(L("Selects all objects")), [this](wxCommandEvent&) { if (m_plater != nullptr) m_plater->select_all(); },
"", nullptr, [this](){return can_select(); }, this);
#if !DISABLE_DESELECT_ALL_MENU_ITEM
append_menu_item(editMenu, wxID_ANY, _(L("D&eselect all")) + sep + GUI::shortkey_ctrl_prefix() + sep + "Esc",
append_menu_item(editMenu, wxID_ANY, _(L("D&eselect all")) + sep + "Esc",
_(L("Deselects all objects")), [this](wxCommandEvent&) { if (m_plater != nullptr) m_plater->deselect_all(); },
"", nullptr, [this](){return can_deselect(); }, this);
#endif // !DISABLE_DESELECT_ALL_MENU_ITEM
editMenu->AppendSeparator();
append_menu_item(editMenu, wxID_ANY, _(L("&Delete selected")) + sep + hotkey_delete,
_(L("Deletes the current selection")),[this](wxCommandEvent&) { m_plater->remove_selected(); },

View File

@ -832,7 +832,7 @@ void Sidebar::update_presets(Preset::Type preset_type)
if (filament_cnt == 1) {
// Single filament printer, synchronize the filament presets.
const std::string &name = preset_bundle.filaments.get_selected_preset().name;
const std::string &name = preset_bundle.filaments.get_selected_preset_name();
preset_bundle.set_filament_preset(0, name);
}
@ -1251,9 +1251,7 @@ struct Plater::priv
static const std::regex pattern_3mf;
static const std::regex pattern_zip_amf;
static const std::regex pattern_any_amf;
#if ENABLE_VOLUMES_CENTERING_FIXES
static const std::regex pattern_prusa;
#endif // ENABLE_VOLUMES_CENTERING_FIXES
priv(Plater *q, MainFrame *main_frame);
@ -1387,9 +1385,7 @@ const std::regex Plater::priv::pattern_bundle(".*[.](amf|amf[.]xml|zip[.]amf|3mf
const std::regex Plater::priv::pattern_3mf(".*3mf", std::regex::icase);
const std::regex Plater::priv::pattern_zip_amf(".*[.]zip[.]amf", std::regex::icase);
const std::regex Plater::priv::pattern_any_amf(".*[.](amf|amf[.]xml|zip[.]amf)", std::regex::icase);
#if ENABLE_VOLUMES_CENTERING_FIXES
const std::regex Plater::priv::pattern_prusa(".*prusa", std::regex::icase);
#endif // ENABLE_VOLUMES_CENTERING_FIXES
Plater::priv::priv(Plater *q, MainFrame *main_frame)
: q(q)
@ -1644,9 +1640,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
const bool type_3mf = std::regex_match(path.string(), pattern_3mf);
const bool type_zip_amf = !type_3mf && std::regex_match(path.string(), pattern_zip_amf);
const bool type_any_amf = !type_3mf && std::regex_match(path.string(), pattern_any_amf);
#if ENABLE_VOLUMES_CENTERING_FIXES
const bool type_prusa = std::regex_match(path.string(), pattern_prusa);
#endif // ENABLE_VOLUMES_CENTERING_FIXES
Slic3r::Model model;
try {
@ -1691,9 +1685,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
{
// The model should now be initialized
#if ENABLE_VOLUMES_CENTERING_FIXES
if (!type_3mf && !type_any_amf && !type_prusa) {
#endif // ENABLE_VOLUMES_CENTERING_FIXES
if (model.looks_like_multipart_object()) {
wxMessageDialog dlg(q, _(L(
"This file contains several objects positioned at multiple heights. "
@ -1704,7 +1696,6 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
model.convert_multipart_object(nozzle_dmrs->values.size());
}
}
#if ENABLE_VOLUMES_CENTERING_FIXES
}
else if ((wxGetApp().get_mode() == comSimple) && (type_3mf || type_any_amf))
{
@ -1761,22 +1752,11 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
return obj_idxs;
}
}
#endif // ENABLE_VOLUMES_CENTERING_FIXES
#if !ENABLE_VOLUMES_CENTERING_FIXES
if (type_3mf || type_any_amf) {
#endif // !ENABLE_VOLUMES_CENTERING_FIXES
for (ModelObject* model_object : model.objects) {
#if ENABLE_VOLUMES_CENTERING_FIXES
model_object->center_around_origin(false);
#else
model_object->center_around_origin();
#endif // ENABLE_VOLUMES_CENTERING_FIXES
model_object->ensure_on_bed();
}
#if !ENABLE_VOLUMES_CENTERING_FIXES
}
#endif // !ENABLE_VOLUMES_CENTERING_FIXES
// check multi-part object adding for the SLA-printing
if (printer_technology == ptSLA)

View File

@ -526,9 +526,9 @@ DynamicPrintConfig PresetBundle::full_fff_config() const
opt->value = boost::algorithm::clamp<int>(opt->value, 0, int(num_extruders));
}
out.option<ConfigOptionString >("print_settings_id", true)->value = this->prints.get_selected_preset().name;
out.option<ConfigOptionString >("print_settings_id", true)->value = this->prints.get_selected_preset_name();
out.option<ConfigOptionStrings>("filament_settings_id", true)->values = this->filament_presets;
out.option<ConfigOptionString >("printer_settings_id", true)->value = this->printers.get_selected_preset().name;
out.option<ConfigOptionString >("printer_settings_id", true)->value = this->printers.get_selected_preset_name();
// Serialize the collected "compatible_printers_condition" and "inherits" fields.
// There will be 1 + num_exturders fields for "inherits" and 2 + num_extruders for "compatible_printers_condition" stored.
@ -577,9 +577,9 @@ DynamicPrintConfig PresetBundle::full_sla_config() const
out.erase("compatible_printers_condition");
out.erase("inherits");
out.option<ConfigOptionString >("sla_print_settings_id", true)->value = this->sla_prints.get_selected_preset().name;
out.option<ConfigOptionString >("sla_material_settings_id", true)->value = this->sla_materials.get_selected_preset().name;
out.option<ConfigOptionString >("printer_settings_id", true)->value = this->printers.get_selected_preset().name;
out.option<ConfigOptionString >("sla_print_settings_id", true)->value = this->sla_prints.get_selected_preset_name();
out.option<ConfigOptionString >("sla_material_settings_id", true)->value = this->sla_materials.get_selected_preset_name();
out.option<ConfigOptionString >("printer_settings_id", true)->value = this->printers.get_selected_preset_name();
// Serialize the collected "compatible_printers_condition" and "inherits" fields.
// There will be 1 + num_exturders fields for "inherits" and 2 + num_extruders for "compatible_printers_condition" stored.
@ -854,11 +854,11 @@ void PresetBundle::load_config_file_config_bundle(const std::string &path, const
collection_dst.load_preset(path, preset_name_dst, std::move(preset_src->config), activate).is_external = true;
return preset_name_dst;
};
load_one(this->prints, tmp_bundle.prints, tmp_bundle.prints .get_selected_preset().name, true);
load_one(this->sla_prints, tmp_bundle.sla_prints, tmp_bundle.sla_prints .get_selected_preset().name, true);
load_one(this->filaments, tmp_bundle.filaments, tmp_bundle.filaments .get_selected_preset().name, true);
load_one(this->sla_materials, tmp_bundle.sla_materials, tmp_bundle.sla_materials.get_selected_preset().name, true);
load_one(this->printers, tmp_bundle.printers, tmp_bundle.printers .get_selected_preset().name, true);
load_one(this->prints, tmp_bundle.prints, tmp_bundle.prints .get_selected_preset_name(), true);
load_one(this->sla_prints, tmp_bundle.sla_prints, tmp_bundle.sla_prints .get_selected_preset_name(), true);
load_one(this->filaments, tmp_bundle.filaments, tmp_bundle.filaments .get_selected_preset_name(), true);
load_one(this->sla_materials, tmp_bundle.sla_materials, tmp_bundle.sla_materials.get_selected_preset_name(), true);
load_one(this->printers, tmp_bundle.printers, tmp_bundle.printers .get_selected_preset_name(), true);
this->update_multi_material_filament_presets();
for (size_t i = 1; i < std::min(tmp_bundle.filament_presets.size(), this->filament_presets.size()); ++ i)
this->filament_presets[i] = load_one(this->filaments, tmp_bundle.filaments, tmp_bundle.filament_presets[i], false);
@ -1372,10 +1372,10 @@ void PresetBundle::export_configbundle(const std::string &path, bool export_syst
// Export the names of the active presets.
c << std::endl << "[presets]" << std::endl;
c << "print = " << this->prints.get_selected_preset().name << std::endl;
c << "sla_print = " << this->sla_prints.get_selected_preset().name << std::endl;
c << "sla_material = " << this->sla_materials.get_selected_preset().name << std::endl;
c << "printer = " << this->printers.get_selected_preset().name << std::endl;
c << "print = " << this->prints.get_selected_preset_name() << std::endl;
c << "sla_print = " << this->sla_prints.get_selected_preset_name() << std::endl;
c << "sla_material = " << this->sla_materials.get_selected_preset_name() << std::endl;
c << "printer = " << this->printers.get_selected_preset_name() << std::endl;
for (size_t i = 0; i < this->filament_presets.size(); ++ i) {
char suffix[64];
if (i > 0)

View File

@ -67,7 +67,7 @@ std::string PresetHints::maximum_volumetric_flow_description(const PresetBundle
int idx_extruder = 0;
int num_extruders = (int)preset_bundle.filament_presets.size();
for (; idx_extruder < num_extruders; ++ idx_extruder)
if (preset_bundle.filament_presets[idx_extruder] == preset_bundle.filaments.get_selected_preset().name)
if (preset_bundle.filament_presets[idx_extruder] == preset_bundle.filaments.get_selected_preset_name())
break;
if (idx_extruder == num_extruders)
// The current filament preset is not active for any extruder.

View File

@ -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();
}