mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 14:46:05 +08:00
Merge branch 'master' of https://github.com/Prusa-Development/PrusaSlicerPrivate into et_transformations
This commit is contained in:
commit
d94bb65563
@ -72,6 +72,8 @@ int CLI::run(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
// Mark the main thread for the debugger and for runtime checks.
|
// Mark the main thread for the debugger and for runtime checks.
|
||||||
set_current_thread_name("slic3r_main");
|
set_current_thread_name("slic3r_main");
|
||||||
|
// Save the thread ID of the main thread.
|
||||||
|
save_main_thread_id();
|
||||||
|
|
||||||
#ifdef __WXGTK__
|
#ifdef __WXGTK__
|
||||||
// On Linux, wxGTK has no support for Wayland, and the app crashes on
|
// On Linux, wxGTK has no support for Wayland, and the app crashes on
|
||||||
|
@ -417,12 +417,8 @@ std::string AppConfig::load()
|
|||||||
|
|
||||||
void AppConfig::save()
|
void AppConfig::save()
|
||||||
{
|
{
|
||||||
{
|
if (! is_main_thread_active())
|
||||||
// Returns "undefined" if the thread naming functionality is not supported by the operating system.
|
throw CriticalException("Calling AppConfig::save() from a worker thread!");
|
||||||
std::optional<std::string> current_thread_name = get_current_thread_name();
|
|
||||||
if (current_thread_name && *current_thread_name != "slic3r_main")
|
|
||||||
throw CriticalException("Calling AppConfig::save() from a worker thread!");
|
|
||||||
}
|
|
||||||
|
|
||||||
// The config is first written to a file with a PID suffix and then moved
|
// The config is first written to a file with a PID suffix and then moved
|
||||||
// to avoid race conditions with multiple instances of Slic3r
|
// to avoid race conditions with multiple instances of Slic3r
|
||||||
|
@ -2946,10 +2946,10 @@ std::string GCode::_extrude(const ExtrusionPath &path, const std::string_view de
|
|||||||
prev = p;
|
prev = p;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::string comment;
|
std::string marked_comment;
|
||||||
if (m_config.gcode_comments) {
|
if (m_config.gcode_comments) {
|
||||||
comment = description;
|
marked_comment = description;
|
||||||
comment += description_bridge;
|
marked_comment += description_bridge;
|
||||||
}
|
}
|
||||||
double last_set_speed = new_points[0].speed * 60.0;
|
double last_set_speed = new_points[0].speed * 60.0;
|
||||||
gcode += m_writer.set_speed(last_set_speed, "", comment);
|
gcode += m_writer.set_speed(last_set_speed, "", comment);
|
||||||
@ -2958,7 +2958,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, const std::string_view de
|
|||||||
const ProcessedPoint& processed_point = new_points[i];
|
const ProcessedPoint& processed_point = new_points[i];
|
||||||
Vec2d p = this->point_to_gcode_quantized(processed_point.p);
|
Vec2d p = this->point_to_gcode_quantized(processed_point.p);
|
||||||
const double line_length = (p - prev).norm();
|
const double line_length = (p - prev).norm();
|
||||||
gcode += m_writer.extrude_to_xy(p, e_per_mm * line_length, comment);
|
gcode += m_writer.extrude_to_xy(p, e_per_mm * line_length, marked_comment);
|
||||||
prev = p;
|
prev = p;
|
||||||
double new_speed = processed_point.speed * 60.0;
|
double new_speed = processed_point.speed * 60.0;
|
||||||
if (last_set_speed != new_speed) {
|
if (last_set_speed != new_speed) {
|
||||||
|
@ -264,10 +264,11 @@ public:
|
|||||||
float original_speed)
|
float original_speed)
|
||||||
{
|
{
|
||||||
size_t speed_sections_count = std::min(overlaps.values.size(), speeds.values.size());
|
size_t speed_sections_count = std::min(overlaps.values.size(), speeds.values.size());
|
||||||
|
float speed_base = ext_perimeter_speed > 0 ? ext_perimeter_speed : original_speed;
|
||||||
std::vector<std::pair<float, float>> speed_sections;
|
std::vector<std::pair<float, float>> speed_sections;
|
||||||
for (size_t i = 0; i < speed_sections_count; i++) {
|
for (size_t i = 0; i < speed_sections_count; i++) {
|
||||||
float distance = path.width * (1.0 - (overlaps.get_at(i) / 100.0));
|
float distance = path.width * (1.0 - (overlaps.get_at(i) / 100.0));
|
||||||
float speed = speeds.get_at(i).percent ? (ext_perimeter_speed * speeds.get_at(i).value / 100.0) : speeds.get_at(i).value;
|
float speed = speeds.get_at(i).percent ? (speed_base * speeds.get_at(i).value / 100.0) : speeds.get_at(i).value;
|
||||||
speed_sections.push_back({distance, speed});
|
speed_sections.push_back({distance, speed});
|
||||||
}
|
}
|
||||||
std::sort(speed_sections.begin(), speed_sections.end(),
|
std::sort(speed_sections.begin(), speed_sections.end(),
|
||||||
|
@ -191,6 +191,26 @@ std::optional<std::string> get_current_thread_name()
|
|||||||
|
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
|
// To be called at the start of the application to save the current thread ID as the main (UI) thread ID.
|
||||||
|
static boost::thread::id g_main_thread_id;
|
||||||
|
|
||||||
|
void save_main_thread_id()
|
||||||
|
{
|
||||||
|
g_main_thread_id = boost::this_thread::get_id();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve the cached main (UI) thread ID.
|
||||||
|
boost::thread::id get_main_thread_id()
|
||||||
|
{
|
||||||
|
return g_main_thread_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checks whether the main (UI) thread is active.
|
||||||
|
bool is_main_thread_active()
|
||||||
|
{
|
||||||
|
return get_main_thread_id() == boost::this_thread::get_id();
|
||||||
|
}
|
||||||
|
|
||||||
// Spawn (n - 1) worker threads on Intel TBB thread pool and name them by an index and a system thread ID.
|
// Spawn (n - 1) worker threads on Intel TBB thread pool and name them by an index and a system thread ID.
|
||||||
// Also it sets locale of the worker threads to "C" for the G-code generator to produce "." as a decimal separator.
|
// Also it sets locale of the worker threads to "C" for the G-code generator to produce "." as a decimal separator.
|
||||||
void name_tbb_thread_pool_threads_set_locale()
|
void name_tbb_thread_pool_threads_set_locale()
|
||||||
|
@ -29,6 +29,13 @@ inline bool set_thread_name(boost::thread &thread, const std::string &thread_nam
|
|||||||
bool set_current_thread_name(const char *thread_name);
|
bool set_current_thread_name(const char *thread_name);
|
||||||
inline bool set_current_thread_name(const std::string &thread_name) { return set_current_thread_name(thread_name.c_str()); }
|
inline bool set_current_thread_name(const std::string &thread_name) { return set_current_thread_name(thread_name.c_str()); }
|
||||||
|
|
||||||
|
// To be called at the start of the application to save the current thread ID as the main (UI) thread ID.
|
||||||
|
void save_main_thread_id();
|
||||||
|
// Retrieve the cached main (UI) thread ID.
|
||||||
|
boost::thread::id get_main_thread_id();
|
||||||
|
// Checks whether the main (UI) thread is active.
|
||||||
|
bool is_main_thread_active();
|
||||||
|
|
||||||
// OSX specific: Set Quality of Service to "user initiated", so that the threads will be scheduled to high performance
|
// OSX specific: Set Quality of Service to "user initiated", so that the threads will be scheduled to high performance
|
||||||
// cores if available.
|
// cores if available.
|
||||||
void set_current_thread_qos();
|
void set_current_thread_qos();
|
||||||
|
@ -385,8 +385,10 @@ void GLVolume::render()
|
|||||||
GLShaderProgram* shader = GUI::wxGetApp().get_current_shader();
|
GLShaderProgram* shader = GUI::wxGetApp().get_current_shader();
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const bool is_left_handed = this->is_left_handed();
|
||||||
|
|
||||||
if (this->is_left_handed())
|
if (is_left_handed)
|
||||||
glsafe(::glFrontFace(GL_CW));
|
glsafe(::glFrontFace(GL_CW));
|
||||||
glsafe(::glCullFace(GL_BACK));
|
glsafe(::glCullFace(GL_BACK));
|
||||||
|
|
||||||
@ -395,7 +397,7 @@ void GLVolume::render()
|
|||||||
else
|
else
|
||||||
model.render(this->tverts_range);
|
model.render(this->tverts_range);
|
||||||
|
|
||||||
if (this->is_left_handed())
|
if (is_left_handed)
|
||||||
glsafe(::glFrontFace(GL_CCW));
|
glsafe(::glFrontFace(GL_CCW));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -793,6 +795,7 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
|
|||||||
glsafe(::glDisable(GL_CULL_FACE));
|
glsafe(::glDisable(GL_CULL_FACE));
|
||||||
|
|
||||||
for (GLVolumeWithIdAndZ& volume : to_render) {
|
for (GLVolumeWithIdAndZ& volume : to_render) {
|
||||||
|
const Transform3d& world_matrix = volume.first->world_matrix();
|
||||||
volume.first->set_render_color(true);
|
volume.first->set_render_color(true);
|
||||||
|
|
||||||
// render sinking contours of non-hovered volumes
|
// render sinking contours of non-hovered volumes
|
||||||
@ -814,9 +817,9 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
|
|||||||
shader->set_uniform("print_volume.type", static_cast<int>(m_print_volume.type));
|
shader->set_uniform("print_volume.type", static_cast<int>(m_print_volume.type));
|
||||||
shader->set_uniform("print_volume.xy_data", m_print_volume.data);
|
shader->set_uniform("print_volume.xy_data", m_print_volume.data);
|
||||||
shader->set_uniform("print_volume.z_data", m_print_volume.zs);
|
shader->set_uniform("print_volume.z_data", m_print_volume.zs);
|
||||||
shader->set_uniform("volume_world_matrix", volume.first->world_matrix());
|
shader->set_uniform("volume_world_matrix", world_matrix);
|
||||||
shader->set_uniform("slope.actived", m_slope.active && !volume.first->is_modifier && !volume.first->is_wipe_tower);
|
shader->set_uniform("slope.actived", m_slope.active && !volume.first->is_modifier && !volume.first->is_wipe_tower);
|
||||||
shader->set_uniform("slope.volume_world_normal_matrix", static_cast<Matrix3f>(volume.first->world_matrix().matrix().block(0, 0, 3, 3).inverse().transpose().cast<float>()));
|
shader->set_uniform("slope.volume_world_normal_matrix", static_cast<Matrix3f>(world_matrix.matrix().block(0, 0, 3, 3).inverse().transpose().cast<float>()));
|
||||||
shader->set_uniform("slope.normal_z", m_slope.normal_z);
|
shader->set_uniform("slope.normal_z", m_slope.normal_z);
|
||||||
|
|
||||||
#if ENABLE_ENVIRONMENT_MAP
|
#if ENABLE_ENVIRONMENT_MAP
|
||||||
@ -829,7 +832,7 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
|
|||||||
glcheck();
|
glcheck();
|
||||||
|
|
||||||
volume.first->model.set_color(volume.first->render_color);
|
volume.first->model.set_color(volume.first->render_color);
|
||||||
const Transform3d model_matrix = volume.first->world_matrix();
|
const Transform3d model_matrix = world_matrix;
|
||||||
shader->set_uniform("view_model_matrix", view_matrix * model_matrix);
|
shader->set_uniform("view_model_matrix", view_matrix * model_matrix);
|
||||||
shader->set_uniform("projection_matrix", projection_matrix);
|
shader->set_uniform("projection_matrix", projection_matrix);
|
||||||
const Matrix3d view_normal_matrix = view_matrix.matrix().block(0, 0, 3, 3) * model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose();
|
const Matrix3d view_normal_matrix = view_matrix.matrix().block(0, 0, 3, 3) * model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose();
|
||||||
|
@ -818,8 +818,11 @@ static float get_cursor_height()
|
|||||||
void GLCanvas3D::Tooltip::set_text(const std::string& text)
|
void GLCanvas3D::Tooltip::set_text(const std::string& text)
|
||||||
{
|
{
|
||||||
// If the mouse is inside an ImGUI dialog, then the tooltip is suppressed.
|
// If the mouse is inside an ImGUI dialog, then the tooltip is suppressed.
|
||||||
m_text = m_in_imgui ? std::string() : text;
|
const std::string& new_text = m_in_imgui ? std::string() : text;
|
||||||
m_cursor_height = get_cursor_height();
|
if (m_text != new_text) { // To avoid calling the expensive call to get_cursor_height.
|
||||||
|
m_text = new_text;
|
||||||
|
m_cursor_height = get_cursor_height();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::Tooltip::render(const Vec2d& mouse_position, GLCanvas3D& canvas)
|
void GLCanvas3D::Tooltip::render(const Vec2d& mouse_position, GLCanvas3D& canvas)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user