mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-06 21:44:08 -06:00
Merge branch 'master' into tm_pad_improve
This commit is contained in:
commit
a25072f0a3
24 changed files with 618 additions and 202 deletions
|
@ -33,6 +33,7 @@ if(PNG_FOUND AND NOT RASTERIZER_FORCE_BUILTIN_LIBPNG)
|
|||
else()
|
||||
set(ZLIB_LIBRARY "")
|
||||
message(WARNING "Using builtin libpng. This can cause crashes on some platforms.")
|
||||
set(SKIP_INSTALL_ALL 1) # Prevent png+zlib from creating install targets
|
||||
add_subdirectory(png/zlib)
|
||||
set(ZLIB_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/png/zlib ${CMAKE_CURRENT_BINARY_DIR}/png/zlib)
|
||||
include_directories(${ZLIB_INCLUDE_DIR})
|
||||
|
@ -188,3 +189,15 @@ else ()
|
|||
VERBATIM
|
||||
)
|
||||
endif()
|
||||
|
||||
# Slic3r binary install target
|
||||
if (WIN32)
|
||||
install(TARGETS slic3r RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}")
|
||||
if (MSVC)
|
||||
install(TARGETS slic3r_app_gui RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}")
|
||||
install(TARGETS slic3r_app_console RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}")
|
||||
install(TARGETS slic3r_app_noconsole RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}")
|
||||
endif ()
|
||||
else ()
|
||||
install(TARGETS slic3r RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
endif ()
|
||||
|
|
|
@ -218,7 +218,7 @@ public:
|
|||
|
||||
const T& get_at(size_t i) const { return const_cast<ConfigOptionVector<T>*>(this)->get_at(i); }
|
||||
|
||||
// Resize this vector by duplicating the last value.
|
||||
// Resize this vector by duplicating the /*last*/first value.
|
||||
// If the current vector is empty, the default value is used instead.
|
||||
void resize(size_t n, const ConfigOption *opt_default = nullptr) override
|
||||
{
|
||||
|
@ -238,7 +238,7 @@ public:
|
|||
this->values.resize(n, static_cast<const ConfigOptionVector<T>*>(opt_default)->values.front());
|
||||
} else {
|
||||
// Resize by duplicating the last value.
|
||||
this->values.resize(n, this->values.back());
|
||||
this->values.resize(n, this->values./*back*/front());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -204,7 +204,9 @@ std::string WipeTowerIntegration::append_tcr(GCode &gcodegen, const WipeTower::T
|
|||
if (! start_filament_gcode.empty()) {
|
||||
// Process the start_filament_gcode for the active filament only.
|
||||
gcodegen.placeholder_parser().set("current_extruder", new_extruder_id);
|
||||
gcode += gcodegen.placeholder_parser_process("start_filament_gcode", start_filament_gcode, new_extruder_id);
|
||||
DynamicConfig config;
|
||||
config.set_key_value("filament_extruder_id", new ConfigOptionInt(new_extruder_id));
|
||||
gcode += gcodegen.placeholder_parser_process("start_filament_gcode", start_filament_gcode, new_extruder_id, &config);
|
||||
check_add_eol(gcode);
|
||||
}
|
||||
// A phony move to the end position at the wipe tower.
|
||||
|
@ -787,11 +789,17 @@ void GCode::_do_export(Print &print, FILE *file)
|
|||
// Wipe tower will control the extruder switching, it will call the start_filament_gcode.
|
||||
} else {
|
||||
// Only initialize the initial extruder.
|
||||
_writeln(file, this->placeholder_parser_process("start_filament_gcode", print.config().start_filament_gcode.values[initial_extruder_id], initial_extruder_id));
|
||||
DynamicConfig config;
|
||||
config.set_key_value("filament_extruder_id", new ConfigOptionInt(int(initial_extruder_id)));
|
||||
_writeln(file, this->placeholder_parser_process("start_filament_gcode", print.config().start_filament_gcode.values[initial_extruder_id], initial_extruder_id, &config));
|
||||
}
|
||||
} else {
|
||||
for (const std::string &start_gcode : print.config().start_filament_gcode.values)
|
||||
_writeln(file, this->placeholder_parser_process("start_filament_gcode", start_gcode, (unsigned int)(&start_gcode - &print.config().start_filament_gcode.values.front())));
|
||||
DynamicConfig config;
|
||||
for (const std::string &start_gcode : print.config().start_filament_gcode.values) {
|
||||
int extruder_id = (unsigned int)(&start_gcode - &print.config().start_filament_gcode.values.front());
|
||||
config.set_key_value("filament_extruder_id", new ConfigOptionInt(extruder_id));
|
||||
_writeln(file, this->placeholder_parser_process("start_filament_gcode", start_gcode, extruder_id, &config));
|
||||
}
|
||||
}
|
||||
this->_print_first_layer_extruder_temperatures(file, print, start_gcode, initial_extruder_id, true);
|
||||
print.throw_if_canceled();
|
||||
|
@ -809,7 +817,7 @@ void GCode::_do_export(Print &print, FILE *file)
|
|||
for (const ExPolygon &expoly : layer->slices.expolygons)
|
||||
for (const Point © : object->copies()) {
|
||||
islands.emplace_back(expoly.contour);
|
||||
islands.back().translate(- copy);
|
||||
islands.back().translate(copy);
|
||||
}
|
||||
//FIXME Mege the islands in parallel.
|
||||
m_avoid_crossing_perimeters.init_external_mp(union_ex(islands));
|
||||
|
@ -990,10 +998,15 @@ void GCode::_do_export(Print &print, FILE *file)
|
|||
config.set_key_value("layer_z", new ConfigOptionFloat(m_writer.get_position()(2) - m_config.z_offset.value));
|
||||
if (print.config().single_extruder_multi_material) {
|
||||
// Process the end_filament_gcode for the active filament only.
|
||||
_writeln(file, this->placeholder_parser_process("end_filament_gcode", print.config().end_filament_gcode.get_at(m_writer.extruder()->id()), m_writer.extruder()->id(), &config));
|
||||
int extruder_id = m_writer.extruder()->id();
|
||||
config.set_key_value("filament_extruder_id", new ConfigOptionInt(extruder_id));
|
||||
_writeln(file, this->placeholder_parser_process("end_filament_gcode", print.config().end_filament_gcode.get_at(extruder_id), extruder_id, &config));
|
||||
} else {
|
||||
for (const std::string &end_gcode : print.config().end_filament_gcode.values)
|
||||
_writeln(file, this->placeholder_parser_process("end_filament_gcode", end_gcode, (unsigned int)(&end_gcode - &print.config().end_filament_gcode.values.front()), &config));
|
||||
for (const std::string &end_gcode : print.config().end_filament_gcode.values) {
|
||||
int extruder_id = (unsigned int)(&end_gcode - &print.config().end_filament_gcode.values.front());
|
||||
config.set_key_value("filament_extruder_id", new ConfigOptionInt(extruder_id));
|
||||
_writeln(file, this->placeholder_parser_process("end_filament_gcode", end_gcode, extruder_id, &config));
|
||||
}
|
||||
}
|
||||
_writeln(file, this->placeholder_parser_process("end_gcode", print.config().end_gcode, m_writer.extruder()->id(), &config));
|
||||
}
|
||||
|
|
|
@ -1194,7 +1194,7 @@ Vec3d extract_euler_angles(const Eigen::Matrix<double, 3, 3, Eigen::DontAlign>&
|
|||
}
|
||||
else
|
||||
{
|
||||
angles(1) = 0.0;
|
||||
angles(0) = 0.0;
|
||||
angles(1) = ::atan2(-rotation_matrix(2, 0), sy);
|
||||
angles(2) = (angles(1) >-0.0) ? ::atan2(rotation_matrix(1, 2), rotation_matrix(1, 1)) : ::atan2(-rotation_matrix(1, 2), rotation_matrix(1, 1));
|
||||
}
|
||||
|
|
2
src/platform/unix/fhs.hpp.in
Normal file
2
src/platform/unix/fhs.hpp.in
Normal file
|
@ -0,0 +1,2 @@
|
|||
#cmakedefine SLIC3R_FHS @SLIC3R_FHS@
|
||||
#define SLIC3R_FHS_RESOURCES "@SLIC3R_FHS_RESOURCES@"
|
|
@ -22,6 +22,8 @@
|
|||
#include <boost/nowide/cenv.hpp>
|
||||
#include <boost/nowide/iostream.hpp>
|
||||
|
||||
#include "unix/fhs.hpp" // Generated by CMake from ../platform/unix/fhs.hpp.in
|
||||
|
||||
#include "libslic3r/libslic3r.h"
|
||||
#include "libslic3r/Config.hpp"
|
||||
#include "libslic3r/Geometry.hpp"
|
||||
|
@ -77,6 +79,10 @@ int main(int argc, char **argv)
|
|||
// The resources are packed to 'resources'
|
||||
// Path from Slic3r binary to resources:
|
||||
boost::filesystem::path path_resources = path_to_binary.parent_path() / "resources";
|
||||
#elif defined SLIC3R_FHS
|
||||
// The application is packaged according to the Linux Filesystem Hierarchy Standard
|
||||
// Resources are set to the 'Architecture-independent (shared) data', typically /usr/share or /usr/local/share
|
||||
boost::filesystem::path path_resources = SLIC3R_FHS_RESOURCES;
|
||||
#else
|
||||
// The application is packed in the .tar.bz archive (or in AppImage) as 'bin/slic3r',
|
||||
// The resources are packed to 'resources'
|
||||
|
|
|
@ -66,12 +66,8 @@ void Field::PostInitialize()
|
|||
BUILD();
|
||||
}
|
||||
|
||||
void Field::on_kill_focus(wxEvent& event)
|
||||
void Field::on_kill_focus()
|
||||
{
|
||||
// Without this, there will be nasty focus bugs on Windows.
|
||||
// Also, docs for wxEvent::Skip() say "In general, it is recommended to skip all
|
||||
// non-command events to allow the default handling to take place."
|
||||
event.Skip();
|
||||
// call the registered function if it is available
|
||||
if (m_on_kill_focus!=nullptr)
|
||||
m_on_kill_focus(m_opt_id);
|
||||
|
@ -250,11 +246,23 @@ void TextCtrl::BUILD() {
|
|||
break;
|
||||
}
|
||||
|
||||
const long style = m_opt.multiline ? wxTE_MULTILINE : 0;
|
||||
const long style = m_opt.multiline ? wxTE_MULTILINE : wxTE_PROCESS_ENTER/*0*/;
|
||||
auto temp = new wxTextCtrl(m_parent, wxID_ANY, text_value, wxDefaultPosition, size, style);
|
||||
|
||||
temp->SetToolTip(get_tooltip_text(text_value));
|
||||
|
||||
if (style == wxTE_PROCESS_ENTER) {
|
||||
temp->Bind(wxEVT_TEXT_ENTER, ([this, temp](wxEvent& e)
|
||||
{
|
||||
#if !defined(__WXGTK__)
|
||||
e.Skip();
|
||||
temp->GetToolTip()->Enable(true);
|
||||
#endif // __WXGTK__
|
||||
propagate_value();
|
||||
bEnterPressed = true;
|
||||
}), temp->GetId());
|
||||
}
|
||||
|
||||
temp->Bind(wxEVT_SET_FOCUS, ([this](wxEvent& e) { on_set_focus(e); }), temp->GetId());
|
||||
|
||||
temp->Bind(wxEVT_LEFT_DOWN, ([temp](wxEvent& event)
|
||||
|
@ -272,14 +280,15 @@ void TextCtrl::BUILD() {
|
|||
|
||||
temp->Bind(wxEVT_KILL_FOCUS, ([this, temp](wxEvent& e)
|
||||
{
|
||||
#if !defined(__WXGTK__)
|
||||
e.Skip();
|
||||
#if !defined(__WXGTK__)
|
||||
temp->GetToolTip()->Enable(true);
|
||||
#endif // __WXGTK__
|
||||
if (is_defined_input_value<wxTextCtrl>(window, m_opt.type))
|
||||
on_change_field();
|
||||
else
|
||||
on_kill_focus(e);
|
||||
if (bEnterPressed) {
|
||||
bEnterPressed = false;
|
||||
return;
|
||||
}
|
||||
propagate_value();
|
||||
}), temp->GetId());
|
||||
/*
|
||||
temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent& evt)
|
||||
|
@ -311,6 +320,14 @@ void TextCtrl::BUILD() {
|
|||
window = dynamic_cast<wxWindow*>(temp);
|
||||
}
|
||||
|
||||
void TextCtrl::propagate_value()
|
||||
{
|
||||
if (is_defined_input_value<wxTextCtrl>(window, m_opt.type))
|
||||
on_change_field();
|
||||
else
|
||||
on_kill_focus();
|
||||
}
|
||||
|
||||
boost::any& TextCtrl::get_value()
|
||||
{
|
||||
wxString ret_str = static_cast<wxTextCtrl*>(window)->GetValue();
|
||||
|
@ -398,7 +415,7 @@ void SpinCtrl::BUILD() {
|
|||
const int max_val = m_opt.max < 2147483647 ? m_opt.max : 2147483647;
|
||||
|
||||
auto temp = new wxSpinCtrl(m_parent, wxID_ANY, text_value, wxDefaultPosition, size,
|
||||
0, min_val, max_val, default_value);
|
||||
0|wxTE_PROCESS_ENTER, min_val, max_val, default_value);
|
||||
|
||||
#ifndef __WXOSX__
|
||||
// #ys_FIXME_KILL_FOCUS
|
||||
|
@ -407,15 +424,23 @@ void SpinCtrl::BUILD() {
|
|||
// and on TEXT event under OSX
|
||||
temp->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e)
|
||||
{
|
||||
if (tmp_value < 0)
|
||||
on_kill_focus(e);
|
||||
else {
|
||||
e.Skip();
|
||||
on_change_field();
|
||||
e.Skip();
|
||||
if (bEnterPressed) {
|
||||
bEnterPressed = false;
|
||||
return;
|
||||
}
|
||||
|
||||
propagate_value();
|
||||
}), temp->GetId());
|
||||
|
||||
temp->Bind(wxEVT_SPINCTRL, ([this](wxCommandEvent e) { on_change_field(); }), temp->GetId());
|
||||
temp->Bind(wxEVT_SPINCTRL, ([this](wxCommandEvent e) { on_change_field(); }), temp->GetId());
|
||||
|
||||
temp->Bind(wxEVT_TEXT_ENTER, ([this](wxCommandEvent e)
|
||||
{
|
||||
e.Skip();
|
||||
propagate_value();
|
||||
bEnterPressed = true;
|
||||
}), temp->GetId());
|
||||
#endif
|
||||
|
||||
temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent e)
|
||||
|
@ -430,12 +455,7 @@ void SpinCtrl::BUILD() {
|
|||
tmp_value = std::stoi(value);
|
||||
else tmp_value = -9999;
|
||||
#ifdef __WXOSX__
|
||||
if (tmp_value < 0) {
|
||||
if (m_on_kill_focus != nullptr)
|
||||
m_on_kill_focus(m_opt_id);
|
||||
}
|
||||
else
|
||||
on_change_field();
|
||||
propagate_value();
|
||||
#endif
|
||||
}), temp->GetId());
|
||||
|
||||
|
@ -445,6 +465,14 @@ void SpinCtrl::BUILD() {
|
|||
window = dynamic_cast<wxWindow*>(temp);
|
||||
}
|
||||
|
||||
void SpinCtrl::propagate_value()
|
||||
{
|
||||
if (tmp_value < 0)
|
||||
on_kill_focus();
|
||||
else
|
||||
on_change_field();
|
||||
}
|
||||
|
||||
void Choice::BUILD() {
|
||||
auto size = wxSize(wxDefaultSize);
|
||||
if (m_opt.height >= 0) size.SetHeight(m_opt.height);
|
||||
|
@ -474,6 +502,7 @@ void Choice::BUILD() {
|
|||
if (temp->GetWindowStyle() != wxCB_READONLY) {
|
||||
temp->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) {
|
||||
e.Skip();
|
||||
if (m_opt.type == coStrings) return;
|
||||
double old_val = !m_value.empty() ? boost::any_cast<double>(m_value) : -99999;
|
||||
if (is_defined_input_value<wxComboBox>(window, m_opt.type)) {
|
||||
if (fabs(old_val - boost::any_cast<double>(get_value())) <= 0.0001)
|
||||
|
@ -482,7 +511,7 @@ void Choice::BUILD() {
|
|||
on_change_field();
|
||||
}
|
||||
else
|
||||
on_kill_focus(e);
|
||||
on_kill_focus();
|
||||
}), temp->GetId());
|
||||
}
|
||||
|
||||
|
@ -692,7 +721,7 @@ boost::any& Choice::get_value()
|
|||
}
|
||||
else if (m_opt.gui_type == "f_enum_open") {
|
||||
const int ret_enum = static_cast<wxComboBox*>(window)->GetSelection();
|
||||
if (ret_enum < 0 || m_opt.enum_values.empty())
|
||||
if (ret_enum < 0 || m_opt.enum_values.empty() || m_opt.type == coStrings)
|
||||
get_value_by_opt_type(ret_str);
|
||||
else
|
||||
m_value = atof(m_opt.enum_values[ret_enum].c_str());
|
||||
|
@ -754,8 +783,8 @@ void PointCtrl::BUILD()
|
|||
val = default_pt(1);
|
||||
wxString Y = val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 2, wxNumberFormatter::Style_None);
|
||||
|
||||
x_textctrl = new wxTextCtrl(m_parent, wxID_ANY, X, wxDefaultPosition, field_size);
|
||||
y_textctrl = new wxTextCtrl(m_parent, wxID_ANY, Y, wxDefaultPosition, field_size);
|
||||
x_textctrl = new wxTextCtrl(m_parent, wxID_ANY, X, wxDefaultPosition, field_size, wxEVT_TEXT_ENTER);
|
||||
y_textctrl = new wxTextCtrl(m_parent, wxID_ANY, Y, wxDefaultPosition, field_size, wxEVT_TEXT_ENTER);
|
||||
|
||||
temp->Add(new wxStaticText(m_parent, wxID_ANY, "x : "), 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
temp->Add(x_textctrl);
|
||||
|
@ -765,8 +794,11 @@ void PointCtrl::BUILD()
|
|||
// x_textctrl->Bind(wxEVT_TEXT, ([this](wxCommandEvent e) { on_change_field(); }), x_textctrl->GetId());
|
||||
// y_textctrl->Bind(wxEVT_TEXT, ([this](wxCommandEvent e) { on_change_field(); }), y_textctrl->GetId());
|
||||
|
||||
x_textctrl->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) { OnKillFocus(e, x_textctrl); }), x_textctrl->GetId());
|
||||
y_textctrl->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) { OnKillFocus(e, x_textctrl); }), y_textctrl->GetId());
|
||||
x_textctrl->Bind(wxEVT_TEXT_ENTER, ([this](wxCommandEvent e) { propagate_value(x_textctrl); }), x_textctrl->GetId());
|
||||
y_textctrl->Bind(wxEVT_TEXT_ENTER, ([this](wxCommandEvent e) { propagate_value(y_textctrl); }), y_textctrl->GetId());
|
||||
|
||||
x_textctrl->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) { e.Skip(); propagate_value(x_textctrl); }), x_textctrl->GetId());
|
||||
y_textctrl->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) { e.Skip(); propagate_value(y_textctrl); }), y_textctrl->GetId());
|
||||
|
||||
// // recast as a wxWindow to fit the calling convention
|
||||
sizer = dynamic_cast<wxSizer*>(temp);
|
||||
|
@ -775,14 +807,12 @@ void PointCtrl::BUILD()
|
|||
y_textctrl->SetToolTip(get_tooltip_text(X+", "+Y));
|
||||
}
|
||||
|
||||
void PointCtrl::OnKillFocus(wxEvent& e, wxTextCtrl* win)
|
||||
void PointCtrl::propagate_value(wxTextCtrl* win)
|
||||
{
|
||||
e.Skip();
|
||||
if (!win->GetValue().empty()) {
|
||||
if (!win->GetValue().empty())
|
||||
on_change_field();
|
||||
}
|
||||
else
|
||||
on_kill_focus(e);
|
||||
on_kill_focus();
|
||||
}
|
||||
|
||||
void PointCtrl::set_value(const Vec2d& value, bool change_event)
|
||||
|
|
|
@ -74,7 +74,7 @@ protected:
|
|||
/// Call the attached on_kill_focus method.
|
||||
//! It's important to use wxEvent instead of wxFocusEvent,
|
||||
//! in another case we can't unfocused control at all
|
||||
void on_kill_focus(wxEvent& event);
|
||||
void on_kill_focus();
|
||||
/// Call the attached on_change method.
|
||||
void on_set_focus(wxEvent& event);
|
||||
/// Call the attached on_change method.
|
||||
|
@ -226,6 +226,8 @@ protected:
|
|||
|
||||
// current value
|
||||
boost::any m_value;
|
||||
|
||||
bool bEnterPressed = false;
|
||||
|
||||
friend class OptionsGroup;
|
||||
};
|
||||
|
@ -252,6 +254,8 @@ public:
|
|||
~TextCtrl() {}
|
||||
|
||||
void BUILD();
|
||||
// Propagate value from field to the OptionGroupe and Config after kill_focus/ENTER
|
||||
void propagate_value();
|
||||
wxWindow* window {nullptr};
|
||||
|
||||
virtual void set_value(const std::string& value, bool change_event = false) {
|
||||
|
@ -310,6 +314,8 @@ public:
|
|||
|
||||
wxWindow* window{ nullptr };
|
||||
void BUILD() override;
|
||||
/// Propagate value from field to the OptionGroupe and Config after kill_focus/ENTER
|
||||
void propagate_value() ;
|
||||
|
||||
void set_value(const std::string& value, bool change_event = false) {
|
||||
m_disable_change_event = !change_event;
|
||||
|
@ -393,8 +399,8 @@ public:
|
|||
wxTextCtrl* y_textctrl{ nullptr };
|
||||
|
||||
void BUILD() override;
|
||||
|
||||
void OnKillFocus(wxEvent& e, wxTextCtrl* win);
|
||||
// Propagate value from field to the OptionGroupe and Config after kill_focus/ENTER
|
||||
void propagate_value(wxTextCtrl* win);
|
||||
void set_value(const Vec2d& value, bool change_event = false);
|
||||
void set_value(const boost::any& value, bool change_event = false);
|
||||
boost::any& get_value() override;
|
||||
|
|
|
@ -2513,7 +2513,9 @@ void GLCanvas3D::Selection::_render_sidebar_rotation_hints(const std::string& si
|
|||
|
||||
void GLCanvas3D::Selection::_render_sidebar_scale_hints(const std::string& sidebar_field) const
|
||||
{
|
||||
if (boost::ends_with(sidebar_field, "x") || requires_uniform_scale())
|
||||
bool uniform_scale = requires_uniform_scale() || wxGetApp().obj_manipul()->get_uniform_scaling();
|
||||
|
||||
if (boost::ends_with(sidebar_field, "x") || uniform_scale)
|
||||
{
|
||||
::glPushMatrix();
|
||||
::glRotated(-90.0, 0.0, 0.0, 1.0);
|
||||
|
@ -2521,14 +2523,14 @@ void GLCanvas3D::Selection::_render_sidebar_scale_hints(const std::string& sideb
|
|||
::glPopMatrix();
|
||||
}
|
||||
|
||||
if (boost::ends_with(sidebar_field, "y") || requires_uniform_scale())
|
||||
if (boost::ends_with(sidebar_field, "y") || uniform_scale)
|
||||
{
|
||||
::glPushMatrix();
|
||||
_render_sidebar_scale_hint(Y);
|
||||
::glPopMatrix();
|
||||
}
|
||||
|
||||
if (boost::ends_with(sidebar_field, "z") || requires_uniform_scale())
|
||||
if (boost::ends_with(sidebar_field, "z") || uniform_scale)
|
||||
{
|
||||
::glPushMatrix();
|
||||
::glRotated(90.0, 1.0, 0.0, 0.0);
|
||||
|
@ -2559,7 +2561,7 @@ void GLCanvas3D::Selection::_render_sidebar_rotation_hint(Axis axis) const
|
|||
|
||||
void GLCanvas3D::Selection::_render_sidebar_scale_hint(Axis axis) const
|
||||
{
|
||||
m_arrow.set_color((requires_uniform_scale() ? UNIFORM_SCALE_COLOR : AXES_COLOR[axis]), 3);
|
||||
m_arrow.set_color(((requires_uniform_scale() || wxGetApp().obj_manipul()->get_uniform_scaling()) ? UNIFORM_SCALE_COLOR : AXES_COLOR[axis]), 3);
|
||||
|
||||
::glTranslated(0.0, 5.0, 0.0);
|
||||
m_arrow.render();
|
||||
|
@ -3979,6 +3981,12 @@ BoundingBoxf3 GLCanvas3D::scene_bounding_box() const
|
|||
{
|
||||
BoundingBoxf3 bb = volumes_bounding_box();
|
||||
bb.merge(m_bed.get_bounding_box());
|
||||
if (m_config != nullptr)
|
||||
{
|
||||
double h = m_config->opt_float("max_print_height");
|
||||
bb.min(2) = std::min(bb.min(2), -h);
|
||||
bb.max(2) = std::max(bb.max(2), h);
|
||||
}
|
||||
return bb;
|
||||
}
|
||||
|
||||
|
@ -4939,8 +4947,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
|
||||
if (evt.Entering())
|
||||
{
|
||||
#if defined(__WXMSW__) || defined(__linux__)
|
||||
// On Windows and Linux needs focus in order to catch key events
|
||||
//#if defined(__WXMSW__) || defined(__linux__)
|
||||
// // On Windows and Linux needs focus in order to catch key events
|
||||
// Set focus in order to remove it from sidebar fields
|
||||
if (m_canvas != nullptr) {
|
||||
// Only set focus, if the top level window of this canvas is active.
|
||||
auto p = dynamic_cast<wxWindow*>(evt.GetEventObject());
|
||||
|
@ -4952,7 +4961,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
}
|
||||
|
||||
m_mouse.set_start_position_2D_as_invalid();
|
||||
#endif
|
||||
//#endif
|
||||
}
|
||||
else if (evt.Leaving())
|
||||
{
|
||||
|
|
|
@ -1523,7 +1523,7 @@ void GLGizmoFlatten::update_planes()
|
|||
const Transform3d& inst_matrix = m_model_object->instances.front()->get_matrix();
|
||||
|
||||
// Following constants are used for discarding too small polygons.
|
||||
const float minimal_area = 20.f; // in square mm (world coordinates)
|
||||
const float minimal_area = 5.f; // in square mm (world coordinates)
|
||||
const float minimal_side = 1.f; // mm
|
||||
|
||||
// Now we'll go through all the facets and append Points of facets sharing the same normal.
|
||||
|
|
|
@ -148,19 +148,21 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt
|
|||
config.set_key_value(opt_key, new ConfigOptionString(boost::any_cast<std::string>(value)));
|
||||
break;
|
||||
case coStrings:{
|
||||
if (opt_key == "compatible_prints" || opt_key == "compatible_printers" || opt_key == "post_process") {
|
||||
if (opt_key == "compatible_prints" || opt_key == "compatible_printers") {
|
||||
config.option<ConfigOptionStrings>(opt_key)->values =
|
||||
boost::any_cast<std::vector<std::string>>(value);
|
||||
}
|
||||
else if (config.def()->get(opt_key)->gui_flags.compare("serialized") == 0) {
|
||||
std::string str = boost::any_cast<std::string>(value);
|
||||
if (str.back() == ';') str.pop_back();
|
||||
// Split a string to multiple strings by a semi - colon.This is the old way of storing multi - string values.
|
||||
// Currently used for the post_process config value only.
|
||||
std::vector<std::string> values;
|
||||
boost::split(values, str, boost::is_any_of(";"));
|
||||
if (values.size() == 1 && values[0] == "")
|
||||
values.resize(0);//break;
|
||||
std::vector<std::string> values {};
|
||||
if (!str.empty()) {
|
||||
if (str.back() == ';') str.pop_back();
|
||||
// Split a string to multiple strings by a semi - colon.This is the old way of storing multi - string values.
|
||||
// Currently used for the post_process config value only.
|
||||
boost::split(values, str, boost::is_any_of(";"));
|
||||
if (values.size() == 1 && values[0] == "")
|
||||
values.resize(0);
|
||||
}
|
||||
config.option<ConfigOptionStrings>(opt_key)->values = values;
|
||||
}
|
||||
else{
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <wx/stdpaths.h>
|
||||
#include <wx/imagpng.h>
|
||||
|
@ -15,6 +14,7 @@
|
|||
#include <wx/filedlg.h>
|
||||
#include <wx/dir.h>
|
||||
#include <wx/wupdlock.h>
|
||||
#include <wx/filefn.h>
|
||||
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
|
@ -83,6 +83,11 @@ GUI_App::GUI_App()
|
|||
|
||||
bool GUI_App::OnInit()
|
||||
{
|
||||
// Verify resources path
|
||||
const wxString resources_dir = from_u8(Slic3r::resources_dir());
|
||||
wxCHECK_MSG(wxDirExists(resources_dir), false,
|
||||
wxString::Format("Resources path does not exist or is not a directory: %s", resources_dir));
|
||||
|
||||
#if ENABLE_IMGUI
|
||||
wxCHECK_MSG(m_imgui->init(), false, "Failed to initialize ImGui");
|
||||
#endif // ENABLE_IMGUI
|
||||
|
|
|
@ -635,7 +635,7 @@ void ObjectList::get_settings_choice(const wxString& category_name)
|
|||
// Add settings item for object
|
||||
const auto item = GetSelection();
|
||||
if (item) {
|
||||
const auto settings_item = m_objects_model->GetSettingsItem(item);
|
||||
const auto settings_item = m_objects_model->IsSettingsItem(item) ? item : m_objects_model->GetSettingsItem(item);
|
||||
select_item(settings_item ? settings_item :
|
||||
m_objects_model->AddSettingsChild(item));
|
||||
}
|
||||
|
@ -849,7 +849,7 @@ void ObjectList::load_part( ModelObject* model_object,
|
|||
new_volume->set_type(static_cast<ModelVolume::Type>(type));
|
||||
new_volume->name = boost::filesystem::path(input_file).filename().string();
|
||||
|
||||
part_names.Add(new_volume->name);
|
||||
part_names.Add(from_u8(new_volume->name));
|
||||
|
||||
// set a default extruder value, since user can't add it manually
|
||||
new_volume->config.set_key_value("extruder", new ConfigOptionInt(0));
|
||||
|
@ -903,7 +903,7 @@ void ObjectList::load_generic_subobject(const std::string& type_name, const int
|
|||
m_parts_changed = true;
|
||||
parts_changed(obj_idx);
|
||||
|
||||
select_item(m_objects_model->AddVolumeChild(GetSelection(), name, type));
|
||||
select_item(m_objects_model->AddVolumeChild(GetSelection(), from_u8(name), type));
|
||||
#ifndef __WXOSX__ //#ifdef __WXMSW__ // #ys_FIXME
|
||||
selection_changed();
|
||||
#endif //no __WXOSX__ //__WXMSW__
|
||||
|
@ -1031,7 +1031,7 @@ void ObjectList::split()
|
|||
parent = item;
|
||||
|
||||
for (auto id = 0; id < model_object->volumes.size(); id++) {
|
||||
const auto vol_item = m_objects_model->AddVolumeChild(parent, model_object->volumes[id]->name,
|
||||
const auto vol_item = m_objects_model->AddVolumeChild(parent, from_u8(model_object->volumes[id]->name),
|
||||
model_object->volumes[id]->is_modifier() ?
|
||||
ModelVolume::PARAMETER_MODIFIER : ModelVolume::MODEL_PART,
|
||||
model_object->volumes[id]->config.has("extruder") ?
|
||||
|
@ -1188,7 +1188,7 @@ void ObjectList::part_selection_changed()
|
|||
void ObjectList::add_object_to_list(size_t obj_idx)
|
||||
{
|
||||
auto model_object = (*m_objects)[obj_idx];
|
||||
wxString item_name = model_object->name;
|
||||
wxString item_name = from_u8(model_object->name);
|
||||
const auto item = m_objects_model->Add(item_name,
|
||||
!model_object->config.has("extruder") ? 0 :
|
||||
model_object->config.option<ConfigOptionInt>("extruder")->value);
|
||||
|
@ -1207,8 +1207,8 @@ void ObjectList::add_object_to_list(size_t obj_idx)
|
|||
if (model_object->volumes.size() > 1) {
|
||||
for (auto id = 0; id < model_object->volumes.size(); id++) {
|
||||
auto vol_item = m_objects_model->AddVolumeChild(item,
|
||||
model_object->volumes[id]->name,
|
||||
model_object->volumes[id]->type()/*ModelVolume::MODEL_PART*/,
|
||||
from_u8(model_object->volumes[id]->name),
|
||||
model_object->volumes[id]->type(),
|
||||
!model_object->volumes[id]->config.has("extruder") ? 0 :
|
||||
model_object->volumes[id]->config.option<ConfigOptionInt>("extruder")->value,
|
||||
false);
|
||||
|
|
|
@ -17,15 +17,9 @@ namespace GUI
|
|||
|
||||
ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
||||
OG_Settings(parent, true)
|
||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
, m_cache_position(Vec3d(DBL_MAX, DBL_MAX, DBL_MAX))
|
||||
, m_cache_rotation(Vec3d(DBL_MAX, DBL_MAX, DBL_MAX))
|
||||
, m_cache_scale(Vec3d(DBL_MAX, DBL_MAX, DBL_MAX))
|
||||
, m_cache_size(Vec3d(DBL_MAX, DBL_MAX, DBL_MAX))
|
||||
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
{
|
||||
m_og->set_name(_(L("Object Manipulation")));
|
||||
m_og->label_width = 100;
|
||||
m_og->label_width = 125;
|
||||
m_og->set_grid_vgap(5);
|
||||
|
||||
m_og->m_on_change = [this](const std::string& opt_key, const boost::any& value) {
|
||||
|
@ -80,25 +74,41 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
|||
int axis = opt_key.back() == 'x' ? 0 :
|
||||
opt_key.back() == 'y' ? 1 : 2;
|
||||
|
||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
value = m_cache.position(axis);
|
||||
#else
|
||||
value = m_cache_position(axis);
|
||||
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
}
|
||||
else if (param == "rotation") {
|
||||
int axis = opt_key.back() == 'x' ? 0 :
|
||||
opt_key.back() == 'y' ? 1 : 2;
|
||||
|
||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
value = m_cache.rotation(axis);
|
||||
#else
|
||||
value = m_cache_rotation(axis);
|
||||
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
}
|
||||
else if (param == "scale") {
|
||||
int axis = opt_key.back() == 'x' ? 0 :
|
||||
opt_key.back() == 'y' ? 1 : 2;
|
||||
|
||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
value = m_cache.scale(axis);
|
||||
#else
|
||||
value = m_cache_scale(axis);
|
||||
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
}
|
||||
else if (param == "size") {
|
||||
int axis = opt_key.back() == 'x' ? 0 :
|
||||
opt_key.back() == 'y' ? 1 : 2;
|
||||
|
||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
value = m_cache.size(axis);
|
||||
#else
|
||||
value = m_cache_size(axis);
|
||||
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
}
|
||||
|
||||
m_og->set_value(opt_key, double_to_string(value));
|
||||
|
@ -140,7 +150,7 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
|||
m_og->append_line(line);
|
||||
|
||||
|
||||
auto add_og_to_object_settings = [](const std::string& option_name, const std::string& sidetext)
|
||||
auto add_og_to_object_settings = [this](const std::string& option_name, const std::string& sidetext)
|
||||
{
|
||||
Line line = { _(option_name), "" };
|
||||
ConfigOptionDef def;
|
||||
|
@ -154,6 +164,26 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
|||
def.max = 360;
|
||||
}
|
||||
|
||||
// Add "uniform scaling" button in front of "Scale" option
|
||||
else if (option_name == "Scale") {
|
||||
line.near_label_widget = [this](wxWindow* parent) {
|
||||
auto btn = new PrusaLockButton(parent, wxID_ANY);
|
||||
btn->Bind(wxEVT_BUTTON, [btn, this](wxCommandEvent &event){
|
||||
event.Skip();
|
||||
wxTheApp->CallAfter([btn, this]() { set_uniform_scaling(btn->IsLocked()); });
|
||||
});
|
||||
return btn;
|
||||
};
|
||||
}
|
||||
|
||||
// Add empty bmp (Its size have to be equal to PrusaLockButton) in front of "Size" option to label alignment
|
||||
else if (option_name == "Size") {
|
||||
line.near_label_widget = [this](wxWindow* parent) {
|
||||
return new wxStaticBitmap(parent, wxID_ANY, wxNullBitmap, wxDefaultPosition,
|
||||
wxBitmap(from_u8(var("one_layer_lock_on.png")), wxBITMAP_TYPE_PNG).GetSize());
|
||||
};
|
||||
}
|
||||
|
||||
const std::string lower_name = boost::algorithm::to_lower_copy(option_name);
|
||||
|
||||
std::vector<std::string> axes{ "x", "y", "z" };
|
||||
|
@ -229,16 +259,38 @@ void ObjectManipulation::update_settings_value(const GLCanvas3D::Selection& sele
|
|||
m_new_rotation = volume->get_instance_rotation();
|
||||
m_new_scale = volume->get_instance_scaling_factor();
|
||||
int obj_idx = volume->object_idx();
|
||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
int instance_idx = volume->instance_idx();
|
||||
if ((0 <= obj_idx) && (obj_idx < (int)wxGetApp().model_objects()->size()))
|
||||
{
|
||||
bool changed_box = false;
|
||||
if (!m_cache.instance.matches_object(obj_idx))
|
||||
{
|
||||
m_cache.instance.set(obj_idx, instance_idx, (*wxGetApp().model_objects())[obj_idx]->raw_mesh().bounding_box().size());
|
||||
changed_box = true;
|
||||
}
|
||||
if (changed_box || !m_cache.instance.matches_instance(instance_idx) || !m_cache.scale.isApprox(100.0 * m_new_scale))
|
||||
m_new_size = volume->get_instance_transformation().get_matrix(true, true) * m_cache.instance.box_size;
|
||||
}
|
||||
else
|
||||
// this should never happen
|
||||
m_new_size = Vec3d::Zero();
|
||||
#else
|
||||
if ((0 <= obj_idx) && (obj_idx < (int)wxGetApp().model_objects()->size()))
|
||||
m_new_size = volume->get_instance_transformation().get_matrix(true, true) * (*wxGetApp().model_objects())[obj_idx]->raw_mesh().bounding_box().size();
|
||||
else
|
||||
// this should never happen
|
||||
m_new_size = Vec3d::Zero();
|
||||
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
|
||||
m_new_enabled = true;
|
||||
}
|
||||
else if (selection.is_single_full_object())
|
||||
{
|
||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
m_cache.instance.reset();
|
||||
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
|
||||
const BoundingBoxf3& box = selection.get_bounding_box();
|
||||
m_new_position = box.center();
|
||||
m_new_rotation = Vec3d::Zero();
|
||||
|
@ -250,6 +302,10 @@ void ObjectManipulation::update_settings_value(const GLCanvas3D::Selection& sele
|
|||
}
|
||||
else if (selection.is_single_modifier() || selection.is_single_volume())
|
||||
{
|
||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
m_cache.instance.reset();
|
||||
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
|
||||
// the selection contains a single volume
|
||||
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
|
||||
m_new_position = volume->get_volume_offset();
|
||||
|
@ -280,59 +336,71 @@ void ObjectManipulation::update_settings_value(const GLCanvas3D::Selection& sele
|
|||
void ObjectManipulation::update_if_dirty()
|
||||
{
|
||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
if (_(m_new_move_label_string) != m_move_Label->GetLabel())
|
||||
m_move_Label->SetLabel(_(m_new_move_label_string));
|
||||
if (m_cache.move_label_string != _(m_new_move_label_string))
|
||||
{
|
||||
m_cache.move_label_string = _(m_new_move_label_string);
|
||||
m_move_Label->SetLabel(m_cache.move_label_string);
|
||||
}
|
||||
|
||||
if (_(m_new_rotate_label_string) != m_rotate_Label->GetLabel())
|
||||
m_rotate_Label->SetLabel(_(m_new_rotate_label_string));
|
||||
if (m_cache.rotate_label_string != _(m_new_rotate_label_string))
|
||||
{
|
||||
m_cache.rotate_label_string = _(m_new_rotate_label_string);
|
||||
m_rotate_Label->SetLabel(m_cache.rotate_label_string);
|
||||
}
|
||||
|
||||
if (_(m_new_scale_label_string) != m_scale_Label->GetLabel())
|
||||
m_scale_Label->SetLabel(_(m_new_scale_label_string));
|
||||
if (m_cache.scale_label_string != _(m_new_scale_label_string))
|
||||
{
|
||||
m_cache.scale_label_string = _(m_new_scale_label_string);
|
||||
m_scale_Label->SetLabel(m_cache.scale_label_string);
|
||||
}
|
||||
|
||||
if (m_cache_position(0) != m_new_position(0))
|
||||
if (m_cache.position(0) != m_new_position(0))
|
||||
m_og->set_value("position_x", double_to_string(m_new_position(0), 2));
|
||||
|
||||
if (m_cache_position(1) != m_new_position(1))
|
||||
if (m_cache.position(1) != m_new_position(1))
|
||||
m_og->set_value("position_y", double_to_string(m_new_position(1), 2));
|
||||
|
||||
if (m_cache_position(2) != m_new_position(2))
|
||||
if (m_cache.position(2) != m_new_position(2))
|
||||
m_og->set_value("position_z", double_to_string(m_new_position(2), 2));
|
||||
|
||||
m_cache_position = m_new_position;
|
||||
m_cache.position = m_new_position;
|
||||
|
||||
auto scale = m_new_scale * 100.0;
|
||||
if (m_cache_scale(0) != scale(0))
|
||||
if (m_cache.scale(0) != scale(0))
|
||||
m_og->set_value("scale_x", double_to_string(scale(0), 2));
|
||||
|
||||
if (m_cache_scale(1) != scale(1))
|
||||
if (m_cache.scale(1) != scale(1))
|
||||
m_og->set_value("scale_y", double_to_string(scale(1), 2));
|
||||
|
||||
if (m_cache_scale(2) != scale(2))
|
||||
if (m_cache.scale(2) != scale(2))
|
||||
m_og->set_value("scale_z", double_to_string(scale(2), 2));
|
||||
|
||||
m_cache_scale = scale;
|
||||
m_cache.scale = scale;
|
||||
|
||||
if (m_cache_size(0) != m_new_size(0))
|
||||
if (m_cache.size(0) != m_new_size(0))
|
||||
m_og->set_value("size_x", double_to_string(m_new_size(0), 2));
|
||||
|
||||
if (m_cache_size(1) != m_new_size(1))
|
||||
if (m_cache.size(1) != m_new_size(1))
|
||||
m_og->set_value("size_y", double_to_string(m_new_size(1), 2));
|
||||
|
||||
if (m_cache_size(2) != m_new_size(2))
|
||||
if (m_cache.size(2) != m_new_size(2))
|
||||
m_og->set_value("size_z", double_to_string(m_new_size(2), 2));
|
||||
|
||||
m_cache_size = m_new_size;
|
||||
m_cache.size = m_new_size;
|
||||
|
||||
if (m_cache_rotation(0) != m_new_rotation(0))
|
||||
if (m_cache.rotation(0) != m_new_rotation(0))
|
||||
m_og->set_value("rotation_x", double_to_string(round_nearest(Geometry::rad2deg(m_new_rotation(0)), 0), 2));
|
||||
|
||||
if (m_cache_rotation(1) != m_new_rotation(1))
|
||||
if (m_cache.rotation(1) != m_new_rotation(1))
|
||||
m_og->set_value("rotation_y", double_to_string(round_nearest(Geometry::rad2deg(m_new_rotation(1)), 0), 2));
|
||||
|
||||
if (m_cache_rotation(2) != m_new_rotation(2))
|
||||
if (m_cache.rotation(2) != m_new_rotation(2))
|
||||
m_og->set_value("rotation_z", double_to_string(round_nearest(Geometry::rad2deg(m_new_rotation(2)), 0), 2));
|
||||
|
||||
m_cache_rotation = m_new_rotation;
|
||||
m_cache.rotation = m_new_rotation;
|
||||
|
||||
// if (wxGetApp().plater()->canvas3D()->get_selection().requires_uniform_scale())
|
||||
// m_uniform_scale = true;
|
||||
|
||||
if (m_new_enabled)
|
||||
m_og->enable();
|
||||
|
@ -378,11 +446,14 @@ void ObjectManipulation::update_if_dirty()
|
|||
|
||||
void ObjectManipulation::reset_settings_value()
|
||||
{
|
||||
m_new_position = Vec3d::Zero();
|
||||
m_new_rotation = Vec3d::Zero();
|
||||
m_new_position = Vec3d::Zero();
|
||||
m_new_rotation = Vec3d::Zero();
|
||||
m_new_scale = Vec3d::Ones();
|
||||
m_new_size = Vec3d::Zero();
|
||||
m_new_enabled = false;
|
||||
m_new_enabled = false;
|
||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
m_cache.instance.reset();
|
||||
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
#if !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
m_dirty = true;
|
||||
#endif // !ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
|
@ -393,10 +464,18 @@ void ObjectManipulation::change_position_value(const Vec3d& position)
|
|||
auto canvas = wxGetApp().plater()->canvas3D();
|
||||
GLCanvas3D::Selection& selection = canvas->get_selection();
|
||||
selection.start_dragging();
|
||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
selection.translate(position - m_cache.position, selection.requires_local_axes());
|
||||
#else
|
||||
selection.translate(position - m_cache_position, selection.requires_local_axes());
|
||||
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
canvas->do_move();
|
||||
|
||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
m_cache.position = position;
|
||||
#else
|
||||
m_cache_position = position;
|
||||
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
}
|
||||
|
||||
void ObjectManipulation::change_rotation_value(const Vec3d& rotation)
|
||||
|
@ -415,7 +494,7 @@ void ObjectManipulation::change_rotation_value(const Vec3d& rotation)
|
|||
canvas->do_rotate();
|
||||
|
||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
m_cache_rotation = rotation;
|
||||
m_cache.rotation = rotation;
|
||||
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
}
|
||||
|
||||
|
@ -423,9 +502,13 @@ void ObjectManipulation::change_scale_value(const Vec3d& scale)
|
|||
{
|
||||
Vec3d scaling_factor = scale;
|
||||
const GLCanvas3D::Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
||||
if (selection.requires_uniform_scale())
|
||||
if (m_uniform_scale || selection.requires_uniform_scale())
|
||||
{
|
||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
Vec3d abs_scale_diff = (scale - m_cache.scale).cwiseAbs();
|
||||
#else
|
||||
Vec3d abs_scale_diff = (scale - m_cache_scale).cwiseAbs();
|
||||
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
double max_diff = abs_scale_diff(X);
|
||||
Axis max_diff_axis = X;
|
||||
if (max_diff < abs_scale_diff(Y))
|
||||
|
@ -449,7 +532,10 @@ void ObjectManipulation::change_scale_value(const Vec3d& scale)
|
|||
canvas->do_scale();
|
||||
|
||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
m_cache_scale = scale;
|
||||
if (!m_cache.scale.isApprox(scale))
|
||||
m_cache.instance.instance_idx = -1;
|
||||
|
||||
m_cache.scale = scale;
|
||||
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
}
|
||||
|
||||
|
@ -457,7 +543,11 @@ void ObjectManipulation::change_size_value(const Vec3d& size)
|
|||
{
|
||||
const GLCanvas3D::Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
||||
|
||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
Vec3d ref_size = m_cache.size;
|
||||
#else
|
||||
Vec3d ref_size = m_cache_size;
|
||||
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
if (selection.is_single_full_instance())
|
||||
{
|
||||
const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
|
||||
|
@ -470,7 +560,7 @@ void ObjectManipulation::change_size_value(const Vec3d& size)
|
|||
|
||||
if (selection.requires_uniform_scale())
|
||||
{
|
||||
Vec3d abs_scale_diff = (scale - m_cache_scale).cwiseAbs();
|
||||
Vec3d abs_scale_diff = (scale - m_cache.scale).cwiseAbs();
|
||||
double max_diff = abs_scale_diff(X);
|
||||
Axis max_diff_axis = X;
|
||||
if (max_diff < abs_scale_diff(Y))
|
||||
|
@ -493,7 +583,7 @@ void ObjectManipulation::change_size_value(const Vec3d& size)
|
|||
canvas->get_selection().scale(scaling_factor, false);
|
||||
canvas->do_scale();
|
||||
|
||||
m_cache_size = size;
|
||||
m_cache.size = size;
|
||||
#else
|
||||
change_scale_value(100.0 * Vec3d(size(0) / ref_size(0), size(1) / ref_size(1), size(2) / ref_size(2)));
|
||||
#endif // ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
|
|
|
@ -15,10 +15,41 @@ namespace GUI {
|
|||
class ObjectManipulation : public OG_Settings
|
||||
{
|
||||
#if ENABLE_IMPROVED_SIDEBAR_OBJECTS_MANIPULATION
|
||||
Vec3d m_cache_position;
|
||||
Vec3d m_cache_rotation;
|
||||
Vec3d m_cache_scale;
|
||||
Vec3d m_cache_size;
|
||||
struct Cache
|
||||
{
|
||||
Vec3d position;
|
||||
Vec3d rotation;
|
||||
Vec3d scale;
|
||||
Vec3d size;
|
||||
|
||||
std::string move_label_string;
|
||||
std::string rotate_label_string;
|
||||
std::string scale_label_string;
|
||||
|
||||
struct Instance
|
||||
{
|
||||
int object_idx;
|
||||
int instance_idx;
|
||||
Vec3d box_size;
|
||||
|
||||
Instance() { reset(); }
|
||||
void reset() { this->object_idx = -1; this->instance_idx = -1; this->box_size = Vec3d::Zero(); }
|
||||
void set(int object_idx, int instance_idx, const Vec3d& box_size) { this->object_idx = object_idx; this->instance_idx = instance_idx; this->box_size = box_size; }
|
||||
bool matches(int object_idx, int instance_idx) const { return (this->object_idx == object_idx) && (this->instance_idx == instance_idx); }
|
||||
bool matches_object(int object_idx) const { return (this->object_idx == object_idx); }
|
||||
bool matches_instance(int instance_idx) const { return (this->instance_idx == instance_idx); }
|
||||
};
|
||||
|
||||
Instance instance;
|
||||
|
||||
Cache() : position(Vec3d(DBL_MAX, DBL_MAX, DBL_MAX)) , rotation(Vec3d(DBL_MAX, DBL_MAX, DBL_MAX))
|
||||
, scale(Vec3d(DBL_MAX, DBL_MAX, DBL_MAX)) , size(Vec3d(DBL_MAX, DBL_MAX, DBL_MAX))
|
||||
, move_label_string("") , rotate_label_string("") , scale_label_string("")
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
Cache m_cache;
|
||||
#else
|
||||
Vec3d m_cache_position{ 0., 0., 0. };
|
||||
Vec3d m_cache_rotation{ 0., 0., 0. };
|
||||
|
@ -43,6 +74,7 @@ class ObjectManipulation : public OG_Settings
|
|||
Vec3d m_new_scale;
|
||||
Vec3d m_new_size;
|
||||
bool m_new_enabled;
|
||||
bool m_uniform_scale {false};
|
||||
|
||||
public:
|
||||
ObjectManipulation(wxWindow* parent);
|
||||
|
@ -57,6 +89,9 @@ public:
|
|||
// Called from the App to update the UI if dirty.
|
||||
void update_if_dirty();
|
||||
|
||||
void set_uniform_scaling(const bool uniform_scale) { m_uniform_scale = uniform_scale;}
|
||||
bool get_uniform_scaling() const { return m_uniform_scale; }
|
||||
|
||||
private:
|
||||
void reset_settings_value();
|
||||
|
||||
|
|
|
@ -1053,7 +1053,7 @@ std::vector<std::string> PresetCollection::dirty_options(const Preset *edited, c
|
|||
std::vector<std::string> changed;
|
||||
if (edited != nullptr && reference != nullptr) {
|
||||
changed = deep_compare ?
|
||||
deep_diff(reference->config, edited->config) :
|
||||
deep_diff(edited->config, reference->config) :
|
||||
reference->config.diff(edited->config);
|
||||
// The "compatible_printers" option key is handled differently from the others:
|
||||
// It is not mandatory. If the key is missing, it means it is compatible with any printer.
|
||||
|
@ -1161,6 +1161,21 @@ std::string PresetCollection::name() const
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> PresetCollection::system_preset_names() const
|
||||
{
|
||||
size_t num = 0;
|
||||
for (const Preset &preset : m_presets)
|
||||
if (preset.is_system)
|
||||
++ num;
|
||||
std::vector<std::string> out;
|
||||
out.reserve(num);
|
||||
for (const Preset &preset : m_presets)
|
||||
if (preset.is_system)
|
||||
out.emplace_back(preset.name);
|
||||
std::sort(out.begin(), out.end());
|
||||
return out;
|
||||
}
|
||||
|
||||
// Generate a file path from a profile name. Add the ".ini" suffix if it is missing.
|
||||
std::string PresetCollection::path_from_name(const std::string &new_name) const
|
||||
{
|
||||
|
|
|
@ -365,6 +365,9 @@ public:
|
|||
std::vector<std::string> current_different_from_parent_options(const bool deep_compare = false) const
|
||||
{ return dirty_options(&this->get_edited_preset(), this->get_selected_preset_parent(), deep_compare); }
|
||||
|
||||
// Return a sorted list of system preset names.
|
||||
std::vector<std::string> system_preset_names() const;
|
||||
|
||||
// Update the choice UI from the list of presets.
|
||||
// If show_incompatible, all presets are shown, otherwise only the compatible presets are shown.
|
||||
// If an incompatible preset is selected, it is shown as well.
|
||||
|
|
|
@ -876,7 +876,8 @@ void PresetBundle::load_config_file_config_bundle(const std::string &path, const
|
|||
// The presets starting with '*' are considered non-terminal and they are
|
||||
// removed through the flattening process by this function.
|
||||
// This function will never fail, but it will produce error messages through boost::log.
|
||||
static void flatten_configbundle_hierarchy(boost::property_tree::ptree &tree, const std::string &group_name)
|
||||
// system_profiles will not be flattened, and they will be kept inside the "inherits" field
|
||||
static void flatten_configbundle_hierarchy(boost::property_tree::ptree &tree, const std::string &group_name, const std::vector<std::string> &system_profiles)
|
||||
{
|
||||
namespace pt = boost::property_tree;
|
||||
|
||||
|
@ -911,23 +912,38 @@ static void flatten_configbundle_hierarchy(boost::property_tree::ptree &tree, co
|
|||
for (const Prst &prst : presets) {
|
||||
// Parse the list of comma separated values, possibly enclosed in quotes.
|
||||
std::vector<std::string> inherits_names;
|
||||
std::vector<std::string> inherits_system;
|
||||
if (Slic3r::unescape_strings_cstyle(prst.node->get<std::string>("inherits", ""), inherits_names)) {
|
||||
// Resolve the inheritance by name.
|
||||
std::vector<Prst*> &inherits_nodes = const_cast<Prst&>(prst).inherits;
|
||||
for (const std::string &node_name : inherits_names) {
|
||||
auto it = presets.find(Prst(node_name, nullptr));
|
||||
if (it == presets.end())
|
||||
BOOST_LOG_TRIVIAL(error) << "flatten_configbundle_hierarchy: The preset " << prst.name << " inherits an unknown preset \"" << node_name << "\"";
|
||||
else {
|
||||
inherits_nodes.emplace_back(const_cast<Prst*>(&(*it)));
|
||||
inherits_nodes.back()->parent_of.emplace_back(const_cast<Prst*>(&prst));
|
||||
auto it_system = std::lower_bound(system_profiles.begin(), system_profiles.end(), node_name);
|
||||
if (it_system != system_profiles.end() && *it_system == node_name) {
|
||||
// Loading a user config budnle, this preset is derived from a system profile.
|
||||
inherits_system.emplace_back(node_name);
|
||||
} else {
|
||||
auto it = presets.find(Prst(node_name, nullptr));
|
||||
if (it == presets.end())
|
||||
BOOST_LOG_TRIVIAL(error) << "flatten_configbundle_hierarchy: The preset " << prst.name << " inherits an unknown preset \"" << node_name << "\"";
|
||||
else {
|
||||
inherits_nodes.emplace_back(const_cast<Prst*>(&(*it)));
|
||||
inherits_nodes.back()->parent_of.emplace_back(const_cast<Prst*>(&prst));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(error) << "flatten_configbundle_hierarchy: The preset " << prst.name << " has an invalid \"inherits\" field";
|
||||
}
|
||||
// Remove the "inherits" key, it has no meaning outside the config bundle.
|
||||
// Remove the "inherits" key, it has no meaning outside of the config bundle.
|
||||
const_cast<pt::ptree*>(prst.node)->erase("inherits");
|
||||
if (! inherits_system.empty()) {
|
||||
// Loaded a user config bundle, where a profile inherits a system profile.
|
||||
// User profile should be derived from a single system profile only.
|
||||
assert(inherits_system.size() == 1);
|
||||
if (inherits_system.size() > 1)
|
||||
BOOST_LOG_TRIVIAL(error) << "flatten_configbundle_hierarchy: The preset " << prst.name << " inherits from more than single system preset";
|
||||
prst.node->put("inherits", Slic3r::escape_string_cstyle(inherits_system.front()));
|
||||
}
|
||||
}
|
||||
|
||||
// 2) Create a linear ordering for the directed acyclic graph of preset inheritance.
|
||||
|
@ -983,13 +999,14 @@ static void flatten_configbundle_hierarchy(boost::property_tree::ptree &tree, co
|
|||
}
|
||||
}
|
||||
|
||||
static void flatten_configbundle_hierarchy(boost::property_tree::ptree &tree)
|
||||
// preset_bundle is set when loading user config bundles, which must not overwrite the system profiles.
|
||||
static void flatten_configbundle_hierarchy(boost::property_tree::ptree &tree, const PresetBundle *preset_bundle)
|
||||
{
|
||||
flatten_configbundle_hierarchy(tree, "print");
|
||||
flatten_configbundle_hierarchy(tree, "filament");
|
||||
flatten_configbundle_hierarchy(tree, "sla_print");
|
||||
flatten_configbundle_hierarchy(tree, "sla_material");
|
||||
flatten_configbundle_hierarchy(tree, "printer");
|
||||
flatten_configbundle_hierarchy(tree, "print", preset_bundle ? preset_bundle->prints.system_preset_names() : std::vector<std::string>());
|
||||
flatten_configbundle_hierarchy(tree, "filament", preset_bundle ? preset_bundle->filaments.system_preset_names() : std::vector<std::string>());
|
||||
flatten_configbundle_hierarchy(tree, "sla_print", preset_bundle ? preset_bundle->sla_prints.system_preset_names() : std::vector<std::string>());
|
||||
flatten_configbundle_hierarchy(tree, "sla_material", preset_bundle ? preset_bundle->sla_materials.system_preset_names() : std::vector<std::string>());
|
||||
flatten_configbundle_hierarchy(tree, "printer", preset_bundle ? preset_bundle->printers.system_preset_names() : std::vector<std::string>());
|
||||
}
|
||||
|
||||
// Load a config bundle file, into presets and store the loaded presets into separate files
|
||||
|
@ -1019,7 +1036,8 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla
|
|||
}
|
||||
|
||||
// 1.5) Flatten the config bundle by applying the inheritance rules. Internal profiles (with names starting with '*') are removed.
|
||||
flatten_configbundle_hierarchy(tree);
|
||||
// If loading a user config bundle, do not flatten with the system profiles, but keep the "inherits" flag intact.
|
||||
flatten_configbundle_hierarchy(tree, ((flags & LOAD_CFGBNDLE_SYSTEM) == 0) ? this : nullptr);
|
||||
|
||||
// 2) Parse the property_tree, extract the active preset names and the profiles, save them into local config files.
|
||||
// Parse the obsolete preset names, to be deleted when upgrading from the old configuration structure.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue