Fixing conflicts part 4:

See previous commit. This one applies changes from master_250
to the files mentioned
This commit is contained in:
Lukas Matena 2022-06-29 16:12:52 +02:00
parent d662bf2a18
commit 6c0db58628
10 changed files with 88 additions and 54 deletions

View File

@ -450,11 +450,7 @@ endif()
if (APPLE)
# This flag prevents the need for minimum SDK version 10.14
<<<<<<< HEAD
# currently, PS targets v10.10
=======
# currently, PS targets v10.12
>>>>>>> master_250
target_compile_options(libslic3r PUBLIC "-fno-aligned-allocation")
endif ()

View File

@ -679,13 +679,30 @@ void GCodeProcessor::UsedFilaments::reset()
role_cache = 0.0;
filaments_per_role.clear();
extruder_retracted_volume.clear();
}
void GCodeProcessor::UsedFilaments::increase_caches(double extruded_volume)
void GCodeProcessor::UsedFilaments::increase_caches(double extruded_volume, unsigned char extruder_id, double parking_volume, double extra_loading_volume)
{
color_change_cache += extruded_volume;
tool_change_cache += extruded_volume;
role_cache += extruded_volume;
if (extruder_id >= extruder_retracted_volume.size())
extruder_retracted_volume.resize(extruder_id + 1, parking_volume);
if (recent_toolchange) {
extruded_volume -= extra_loading_volume;
recent_toolchange = false;
}
extruder_retracted_volume[extruder_id] -= extruded_volume;
if (extruder_retracted_volume[extruder_id] < 0.) {
extruded_volume = - extruder_retracted_volume[extruder_id];
extruder_retracted_volume[extruder_id] = 0.;
color_change_cache += extruded_volume;
tool_change_cache += extruded_volume;
role_cache += extruded_volume;
}
}
void GCodeProcessor::UsedFilaments::process_color_change_cache()
@ -696,19 +713,16 @@ void GCodeProcessor::UsedFilaments::process_color_change_cache()
}
}
void GCodeProcessor::UsedFilaments::process_extruder_cache(GCodeProcessor* processor)
{
size_t active_extruder_id = processor->m_extruder_id;
void GCodeProcessor::UsedFilaments::process_extruder_cache(unsigned char extruder_id)
{
if (tool_change_cache != 0.0) {
if (volumes_per_extruder.find(active_extruder_id) != volumes_per_extruder.end())
volumes_per_extruder[active_extruder_id] += tool_change_cache;
else
volumes_per_extruder[active_extruder_id] = tool_change_cache;
tool_change_cache = 0.0;
}
volumes_per_extruder[extruder_id] += tool_change_cache;
tool_change_cache = 0.0;
}
recent_toolchange = true;
}
void GCodeProcessor::UsedFilaments::process_role_cache(GCodeProcessor* processor)
void GCodeProcessor::UsedFilaments::process_role_cache(const GCodeProcessor* processor)
{
if (role_cache != 0.0) {
std::pair<double, double> filament = { 0.0f, 0.0f };
@ -728,10 +742,10 @@ void GCodeProcessor::UsedFilaments::process_role_cache(GCodeProcessor* processor
}
}
void GCodeProcessor::UsedFilaments::process_caches(GCodeProcessor* processor)
void GCodeProcessor::UsedFilaments::process_caches(const GCodeProcessor* processor)
{
process_color_change_cache();
process_extruder_cache(processor);
process_extruder_cache(processor->m_extruder_id);
process_role_cache(processor);
}
@ -901,7 +915,14 @@ void GCodeProcessor::apply_config(const PrintConfig& config)
m_time_processor.filament_unload_times[i] = static_cast<float>(config.filament_unload_time.values[i]);
}
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) {
// With MM setups like Prusa MMU2, the filaments may be expected to be parked at the beginning.
// Remember the parking position so the initial load is not included in filament estimate.
if (config.single_extruder_multi_material && extruders_count > 1 && config.wipe_tower) {
m_parking_position = float(config.parking_pos_retraction.value);
m_extra_loading_move = float(config.extra_loading_move);
}
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) {
float max_acceleration = get_option_value(m_time_processor.machine_limits.machine_max_acceleration_extruding, i);
m_time_processor.machines[i].max_acceleration = max_acceleration;
m_time_processor.machines[i].acceleration = (max_acceleration > 0.0f) ? max_acceleration : DEFAULT_ACCELERATION;
@ -1242,6 +1263,8 @@ void GCodeProcessor::reset()
m_extruder_temps[i] = 0.0f;
}
m_parking_position = 0.f;
m_extra_loading_move = 0.f;
m_extruded_last_z = 0.0f;
m_first_layer_height = 0.0f;
m_g1_line_id = 0;
@ -2550,27 +2573,26 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line)
if (line.has_f())
m_feedrate = m_feed_multiply.current * line.f() * MMMIN_TO_MMSEC;
// calculates movement deltas
float max_abs_delta = 0.0f;
AxisCoords delta_pos;
for (unsigned char a = X; a <= E; ++a) {
delta_pos[a] = m_end_position[a] - m_start_position[a];
max_abs_delta = std::max<float>(max_abs_delta, std::abs(delta_pos[a]));
}
// calculates movement deltas
AxisCoords delta_pos;
for (unsigned char a = X; a <= E; ++a)
delta_pos[a] = m_end_position[a] - m_start_position[a];
if (std::all_of(delta_pos.begin(), delta_pos.end(), [](double d) { return d == 0.; }))
return;
const float volume_extruded_filament = area_filament_cross_section * delta_pos[E];
// no displacement, return
if (max_abs_delta == 0.0f)
return;
if (volume_extruded_filament != 0.)
m_used_filaments.increase_caches(volume_extruded_filament,
this->m_extruder_id, area_filament_cross_section * this->m_parking_position,
area_filament_cross_section * this->m_extra_loading_move);
const EMoveType type = move_type(delta_pos);
if (type == EMoveType::Extrude) {
const float delta_xyz = std::sqrt(sqr(delta_pos[X]) + sqr(delta_pos[Y]) + sqr(delta_pos[Z]));
const float volume_extruded_filament = area_filament_cross_section * delta_pos[E];
const float area_toolpath_cross_section = volume_extruded_filament / delta_xyz;
// save extruded volume to the cache
m_used_filaments.increase_caches(volume_extruded_filament);
// volume extruded filament / tool displacement = area toolpath cross section
m_mm3_per_mm = area_toolpath_cross_section;
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
@ -4090,7 +4112,7 @@ void GCodeProcessor::process_filaments(CustomGCode::Type code)
m_used_filaments.process_color_change_cache();
if (code == CustomGCode::ToolChange)
m_used_filaments.process_extruder_cache(this);
m_used_filaments.process_extruder_cache(this->m_extruder_id);
}
void GCodeProcessor::simulate_st_synchronize(float additional_time)

View File

@ -380,18 +380,19 @@ namespace Slic3r {
std::map<size_t, double> volumes_per_extruder;
double role_cache;
std::map<ExtrusionRole, std::pair<double, double>> filaments_per_role;
std::map<ExtrusionRole, std::pair<double, double>> filaments_per_role; // ExtrusionRole -> (m, g)
void reset();
void increase_caches(double extruded_volume);
void increase_caches(double extruded_volume, unsigned char extruder_id, double parking_volume, double extra_loading_volume);
void process_color_change_cache();
void process_extruder_cache(GCodeProcessor* processor);
void process_role_cache(GCodeProcessor* processor);
void process_caches(GCodeProcessor* processor);
friend class GCodeProcessor;
void process_extruder_cache(unsigned char extruder_id);
void process_role_cache(const GCodeProcessor* processor);
void process_caches(const GCodeProcessor* processor);
private:
std::vector<double> extruder_retracted_volume;
bool recent_toolchange = false;
};
public:
@ -562,6 +563,8 @@ namespace Slic3r {
unsigned char m_extruder_id;
ExtruderColors m_extruder_colors;
ExtruderTemps m_extruder_temps;
float m_parking_position;
float m_extra_loading_move;
float m_extruded_last_z;
float m_first_layer_height; // mm
unsigned int m_g1_line_id;

View File

@ -175,6 +175,7 @@ public:
Point rotated(double angle) const { Point res(*this); res.rotate(angle); return res; }
Point rotated(double cos_a, double sin_a) const { Point res(*this); res.rotate(cos_a, sin_a); return res; }
Point rotated(double angle, const Point &center) const { Point res(*this); res.rotate(angle, center); return res; }
Point rotate_90_degree_ccw() const { return Point(-this->y(), this->x()); }
int nearest_point_index(const Points &points) const;
int nearest_point_index(const PointConstPtrs &points) const;
int nearest_point_index(const PointPtrs &points) const;
@ -259,6 +260,15 @@ inline bool has_duplicate_successive_points_closed(const std::vector<Point> &pts
return has_duplicate_successive_points(pts) || (pts.size() >= 2 && pts.front() == pts.back());
}
inline bool shorter_then(const Point& p0, const coord_t len)
{
if (p0.x() > len || p0.x() < -len)
return false;
if (p0.y() > len || p0.y() < -len)
return false;
return p0.cast<int64_t>().squaredNorm() <= Slic3r::sqr(int64_t(len));
}
namespace int128 {
// Exact orientation predicate,
// returns +1: CCW, 0: collinear, -1: CW.

View File

@ -1,4 +1,3 @@
<<<<<<< HEAD
// FIXME: extract absolute units -> em
#include "ConfigWizard_private.hpp"
@ -1485,7 +1484,7 @@ PageDiameters::PageDiameters(ConfigWizard *parent)
auto *unit_filam = new wxStaticText(this, wxID_ANY, _L("mm"));
sizer_filam->AddGrowableCol(0, 1);
sizer_filam->Add(text_filam, 0, wxALIGN_CENTRE_VERTICAL);
sizer_filam->Add(diam_filam);
sizer_filam->Add(diam_filam, 0, wxALIGN_CENTRE_VERTICAL);
sizer_filam->Add(unit_filam, 0, wxALIGN_CENTRE_VERTICAL);
append(sizer_filam);
}

View File

@ -1840,6 +1840,10 @@ void GLCanvas3D::select_all()
{
m_selection.add_all();
m_dirty = true;
wxGetApp().obj_manipul()->set_dirty();
m_gizmos.reset_all_states();
m_gizmos.update_data();
post_event(SimpleEvent(EVT_GLCANVAS_OBJECT_SELECT));
}
void GLCanvas3D::deselect_all()

View File

@ -269,9 +269,9 @@ private:
credits = title + " " +
_L("is based on Slic3r by Alessandro Ranellucci and the RepRap community.") + "\n" +
_L("Developed by Prusa Research.")+ "\n\n" +
title + " " + _L("is licensed under the") + " " + _L("GNU Affero General Public License, version 3") + "\n\n" +
title + " " + _L("is licensed under the") + " " + _L("GNU Affero General Public License, version 3") + ".\n\n" +
_L("Contributions by Vojtech Bubnik, Enrico Turri, Oleksandra Iushchenko, Tamas Meszaros, Lukas Matena, Vojtech Kral, David Kocik and numerous others.") + "\n\n" +
_L("Artwork model by M Boyer");
_L("Artwork model by Leslie Ing");
title_font = version_font = credits_font = init_font;
}

View File

@ -944,7 +944,7 @@ void GLGizmoHollow::select_point(int i)
m_selected.assign(m_selected.size(), i == AllPoints);
m_selection_empty = (i == NoPoints);
if (i == AllPoints) {
if (i == AllPoints && ! drain_holes.empty()) {
m_new_hole_radius = drain_holes[0].radius;
m_new_hole_height = drain_holes[0].height;
}

View File

@ -1070,7 +1070,7 @@ void GLGizmoSlaSupports::select_point(int i)
point_and_selection.selected = ( i == AllPoints );
m_selection_empty = (i == NoPoints);
if (i == AllPoints)
if (i == AllPoints && ! m_editing_cache.empty())
m_new_point_head_diameter = m_editing_cache[0].support_point.head_front_radius * 2.f;
}
else {

View File

@ -326,9 +326,8 @@ public:
// fix_result containes a message if fixing failed
bool fix_model_by_win10_sdk_gui(ModelObject &model_object, int volume_idx, wxProgressDialog& progress_dialog, const wxString& msg_header, std::string& fix_result)
{
std::mutex mutex;
std::condition_variable condition;
std::unique_lock<std::mutex> lock(mutex);
std::mutex mtx;
std::condition_variable condition;
struct Progress {
std::string message;
int percent = 0;
@ -347,8 +346,8 @@ bool fix_model_by_win10_sdk_gui(ModelObject &model_object, int volume_idx, wxPro
// (It seems like wxWidgets initialize the COM contex as single threaded and we need a multi-threaded context).
bool success = false;
size_t ivolume = 0;
auto on_progress = [&mutex, &condition, &ivolume, &volumes, &progress](const char *msg, unsigned prcnt) {
std::lock_guard<std::mutex> lk(mutex);
auto on_progress = [&mtx, &condition, &ivolume, &volumes, &progress](const char *msg, unsigned prcnt) {
std::unique_lock<std::mutex> lock(mtx);
progress.message = msg;
progress.percent = (int)floor((float(prcnt) + float(ivolume) * 100.f) / float(volumes.size()));
progress.updated = true;
@ -424,6 +423,7 @@ bool fix_model_by_win10_sdk_gui(ModelObject &model_object, int volume_idx, wxPro
}
});
while (! finished) {
std::unique_lock<std::mutex> lock(mtx);
condition.wait_for(lock, std::chrono::milliseconds(250), [&progress]{ return progress.updated; });
// decrease progress.percent value to avoid closing of the progress dialog
if (!progress_dialog.Update(progress.percent-1, msg_header + _(progress.message)))