Better const correctness

This commit is contained in:
Vojtech Bubnik 2022-10-19 15:50:17 +02:00
parent 24f671e924
commit acbc60f3e3
5 changed files with 8 additions and 8 deletions

View File

@ -564,7 +564,7 @@ ExtrusionEntityCollection make_brim(const Print &print, PrintTryCancel try_cance
} }
#endif // BRIM_DEBUG_TO_SVG #endif // BRIM_DEBUG_TO_SVG
const bool could_brim_intersects_skirt = std::any_of(print.objects().begin(), print.objects().end(), [&print](PrintObject *object) { const bool could_brim_intersects_skirt = std::any_of(print.objects().begin(), print.objects().end(), [&print](const PrintObject *object) {
const BrimType &bt = object->config().brim_type; const BrimType &bt = object->config().brim_type;
return (bt == btOuterOnly || bt == btOuterAndInner) && print.config().skirt_distance.value < object->config().brim_width; return (bt == btOuterOnly || bt == btOuterAndInner) && print.config().skirt_distance.value < object->config().brim_width;
}); });

View File

@ -3908,7 +3908,7 @@ static void generate_support_areas(Print &print, const BuildVolume &build_volume
void fff_tree_support_generate(PrintObject &print_object, std::function<void()> throw_on_cancel) void fff_tree_support_generate(PrintObject &print_object, std::function<void()> throw_on_cancel)
{ {
size_t idx = 0; size_t idx = 0;
for (PrintObject* po : print_object.print()->objects()) { for (const PrintObject *po : print_object.print()->objects()) {
if (po == &print_object) if (po == &print_object)
break; break;
++idx; ++idx;

View File

@ -2123,13 +2123,13 @@ void Control::show_cog_icon_context_menu()
GUI::wxGetApp().plater()->PopupMenu(&menu); GUI::wxGetApp().plater()->PopupMenu(&menu);
} }
bool check_color_change(PrintObject* object, size_t frst_layer_id, size_t layers_cnt, bool check_overhangs, std::function<bool(Layer*)> break_condition) bool check_color_change(const PrintObject* object, size_t frst_layer_id, size_t layers_cnt, bool check_overhangs, std::function<bool(const Layer*)> break_condition)
{ {
double prev_area = area(object->get_layer(frst_layer_id)->lslices); double prev_area = area(object->get_layer(frst_layer_id)->lslices);
bool detected = false; bool detected = false;
for (size_t i = frst_layer_id+1; i < layers_cnt; i++) { for (size_t i = frst_layer_id+1; i < layers_cnt; i++) {
Layer* layer = object->get_layer(i); const Layer* layer = object->get_layer(i);
double cur_area = area(layer->lslices); double cur_area = area(layer->lslices);
// check for overhangs // check for overhangs
@ -2169,7 +2169,7 @@ void Control::auto_color_change()
if (object->layer_count() < 2) if (object->layer_count() < 2)
continue; continue;
check_color_change(object, 1, object->layers().size(), false, [this, extruders_cnt](Layer* layer) check_color_change(object, 1, object->layers().size(), false, [this, extruders_cnt](const Layer* layer)
{ {
int tick = get_tick_from_value(layer->print_z); int tick = get_tick_from_value(layer->print_z);
if (tick >= 0 && !m_ticks.has_tick(tick)) { if (tick >= 0 && !m_ticks.has_tick(tick)) {

View File

@ -31,10 +31,10 @@ constexpr double epsilon() { return 0.0011; }
bool equivalent_areas(const double& bottom_area, const double& top_area); bool equivalent_areas(const double& bottom_area, const double& top_area);
// return true if color change was detected // return true if color change was detected
bool check_color_change(PrintObject* object, size_t frst_layer_id, size_t layers_cnt, bool check_overhangs, bool check_color_change(const PrintObject* object, size_t frst_layer_id, size_t layers_cnt, bool check_overhangs,
// what to do with detected color change // what to do with detected color change
// and return true when detection have to be desturbed // and return true when detection have to be desturbed
std::function<bool(Layer*)> break_condition); std::function<bool(const Layer*)> break_condition);
// custom message the slider sends to its parent to notify a tick-change: // custom message the slider sends to its parent to notify a tick-change:
wxDECLARE_EVENT(wxCUSTOMEVT_TICKSCHANGED, wxEvent); wxDECLARE_EVENT(wxCUSTOMEVT_TICKSCHANGED, wxEvent);

View File

@ -574,7 +574,7 @@ void Preview::update_layers_slider(const std::vector<double>& layers_z, bool kee
if (i < min_solid_height) if (i < min_solid_height)
continue; continue;
if (DoubleSlider::check_color_change(object, i, num_layers, true, [this, object](Layer*) { if (DoubleSlider::check_color_change(object, i, num_layers, true, [this, object](const Layer*) {
NotificationManager* notif_mngr = wxGetApp().plater()->get_notification_manager(); NotificationManager* notif_mngr = wxGetApp().plater()->get_notification_manager();
notif_mngr->push_notification( notif_mngr->push_notification(
NotificationType::SignDetected, NotificationManager::NotificationLevel::PrintInfoNotificationLevel, NotificationType::SignDetected, NotificationManager::NotificationLevel::PrintInfoNotificationLevel,