Fixed many warnings in following files:

src/slic3r/Config/Snapshot.cpp
src/slic3r/GUI/Field.cpp
src/slic3r/GUI/GLToolbar.cpp
src/slic3r/GUI/GUI_ObjectList.cpp
src/slic3r/GUI/GUI_ObjectList.hpp
src/slic3r/GUI/Plater.cpp
src/slic3r/GUI/Plater.hpp
src/slic3r/GUI/PresetBundle.cpp
src/slic3r/GUI/Tab.cpp
src/slic3r/GUI/wxExtensions.cpp
This commit is contained in:
Lukas Matena 2019-09-06 17:46:55 +02:00
parent 4585618aea
commit 86b258f727
10 changed files with 57 additions and 59 deletions

View file

@ -202,9 +202,9 @@ void Snapshot::export_selections(AppConfig &config) const
config.clear_section("presets");
config.set("presets", "print", print);
config.set("presets", "filament", filaments.front());
for (int i = 1; i < filaments.size(); ++i) {
for (unsigned i = 1; i < filaments.size(); ++i) {
char name[64];
sprintf(name, "filament_%d", i);
sprintf(name, "filament_%u", i);
config.set("presets", name, filaments[i]);
}
config.set("presets", "printer", printer);
@ -373,9 +373,9 @@ const Snapshot& SnapshotDB::take_snapshot(const AppConfig &app_config, Snapshot:
snapshot.print = app_config.get("presets", "print");
snapshot.filaments.emplace_back(app_config.get("presets", "filament"));
snapshot.printer = app_config.get("presets", "printer");
for (unsigned int i = 1; i < 1000; ++ i) {
for (unsigned i = 1; i < 1000; ++ i) {
char name[64];
sprintf(name, "filament_%d", i);
sprintf(name, "filament_%u", i);
if (! app_config.has("presets", name))
break;
snapshot.filaments.emplace_back(app_config.get("presets", name));

View file

@ -854,7 +854,7 @@ void Choice::set_value(const boost::any& value, bool change_event)
text_value = wxString::Format(_T("%i"), int(boost::any_cast<int>(value)));
else
text_value = boost::any_cast<wxString>(value);
auto idx = 0;
size_t idx = 0;
for (auto el : m_opt.enum_values)
{
if (el == text_value)

View file

@ -861,11 +861,10 @@ int GLToolbar::contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3
float left = m_layout.left + scaled_border;
float top = m_layout.top - scaled_border;
int id = -1;
for (GLToolbarItem* item : m_items)
for (size_t id=0; id<m_items.size(); ++id)
{
++id;
GLToolbarItem* item = m_items[id];
if (!item->is_visible())
continue;
@ -936,11 +935,9 @@ int GLToolbar::contains_mouse_vertical(const Vec2d& mouse_pos, const GLCanvas3D&
float left = m_layout.left + scaled_border;
float top = m_layout.top - scaled_border;
int id = -1;
for (GLToolbarItem* item : m_items)
for (size_t id=0; id<m_items.size(); ++id)
{
++id;
GLToolbarItem* item = m_items[id];
if (!item->is_visible())
continue;

View file

@ -422,7 +422,7 @@ DynamicPrintConfig& ObjectList::get_item_config(const wxDataViewItem& item) cons
(*m_objects)[obj_idx]->config;
}
wxDataViewColumn* ObjectList::create_objects_list_extruder_column(int extruders_count)
wxDataViewColumn* ObjectList::create_objects_list_extruder_column(size_t extruders_count)
{
wxArrayString choices;
choices.Add(_(L("default")));
@ -435,9 +435,9 @@ wxDataViewColumn* ObjectList::create_objects_list_extruder_column(int extruders_
return column;
}
void ObjectList::update_extruder_values_for_items(const int max_extruder)
void ObjectList::update_extruder_values_for_items(const size_t max_extruder)
{
for (int i = 0; i < m_objects->size(); ++i)
for (size_t i = 0; i < m_objects->size(); ++i)
{
wxDataViewItem item = m_objects_model->GetItemById(i);
if (!item) continue;
@ -453,7 +453,7 @@ void ObjectList::update_extruder_values_for_items(const int max_extruder)
m_objects_model->SetValue(extruder, item, colExtruder);
if (object->volumes.size() > 1) {
for (auto id = 0; id < object->volumes.size(); id++) {
for (size_t id = 0; id < object->volumes.size(); id++) {
item = m_objects_model->GetItemByVolumeId(i, id);
if (!item) continue;
if (!object->volumes[id]->config.has("extruder") ||
@ -468,7 +468,7 @@ void ObjectList::update_extruder_values_for_items(const int max_extruder)
}
}
void ObjectList::update_objects_list_extruder_column(int extruders_count)
void ObjectList::update_objects_list_extruder_column(size_t extruders_count)
{
if (!this) return; // #ys_FIXME
if (printer_technology() == ptSLA)
@ -3262,7 +3262,7 @@ void ObjectList::change_part_type()
void ObjectList::last_volume_is_deleted(const int obj_idx)
{
if (obj_idx < 0 || obj_idx >= m_objects->size() || (*m_objects)[obj_idx]->volumes.size() != 1)
if (obj_idx < 0 || size_t(obj_idx) >= m_objects->size() || (*m_objects)[obj_idx]->volumes.size() != 1)
return;
auto volume = (*m_objects)[obj_idx]->volumes.front();

View file

@ -182,15 +182,15 @@ public:
void create_objects_ctrl();
void create_popup_menus();
wxDataViewColumn* create_objects_list_extruder_column(int extruders_count);
void update_objects_list_extruder_column(int extruders_count);
wxDataViewColumn* create_objects_list_extruder_column(size_t extruders_count);
void update_objects_list_extruder_column(size_t extruders_count);
// show/hide "Extruder" column for Objects List
void set_extruder_column_hidden(const bool hide) const;
// update extruder in current config
void update_extruder_in_config(const wxDataViewItem& item);
// update changed name in the object model
void update_name_in_model(const wxDataViewItem& item) const;
void update_extruder_values_for_items(const int max_extruder);
void update_extruder_values_for_items(const size_t max_extruder);
void init_icons();
void msw_rescale_icons();

View file

@ -883,7 +883,7 @@ void Sidebar::init_filament_combo(PresetComboBox **combo, const int extr_idx) {
sizer_filaments->Add(combo_and_btn_sizer, 1, wxEXPAND | wxBOTTOM, 1);
}
void Sidebar::remove_unused_filament_combos(const int current_extruder_count)
void Sidebar::remove_unused_filament_combos(const size_t current_extruder_count)
{
if (current_extruder_count >= p->combos_filament.size())
return;
@ -926,9 +926,9 @@ void Sidebar::update_presets(Preset::Type preset_type)
switch (preset_type) {
case Preset::TYPE_FILAMENT:
{
const int extruder_cnt = print_tech != ptFFF ? 1 :
const size_t extruder_cnt = print_tech != ptFFF ? 1 :
dynamic_cast<ConfigOptionFloats*>(preset_bundle.printers.get_edited_preset().config.option("nozzle_diameter"))->values.size();
const int filament_cnt = p->combos_filament.size() > extruder_cnt ? extruder_cnt : p->combos_filament.size();
const size_t filament_cnt = p->combos_filament.size() > extruder_cnt ? extruder_cnt : p->combos_filament.size();
if (filament_cnt == 1) {
// Single filament printer, synchronize the filament presets.
@ -1051,7 +1051,7 @@ wxButton* Sidebar::get_wiping_dialog_button()
return p->frequently_changed_parameters->get_wiping_dialog_button();
}
void Sidebar::update_objects_list_extruder_column(int extruders_count)
void Sidebar::update_objects_list_extruder_column(size_t extruders_count)
{
p->object_list->update_objects_list_extruder_column(extruders_count);
}
@ -4684,7 +4684,7 @@ void Plater::undo_redo_topmost_string_getter(const bool is_undo, std::string& ou
out_text = "";
}
void Plater::on_extruders_change(int num_extruders)
void Plater::on_extruders_change(size_t num_extruders)
{
auto& choices = sidebar().combos_filament();
@ -4693,7 +4693,7 @@ void Plater::on_extruders_change(int num_extruders)
wxWindowUpdateLocker noUpdates_scrolled_panel(&sidebar()/*.scrolled_panel()*/);
int i = choices.size();
size_t i = choices.size();
while ( i < num_extruders )
{
PresetComboBox* choice/*{ nullptr }*/;
@ -4880,7 +4880,7 @@ void Plater::changed_objects(const std::vector<size_t>& object_idxs)
if (object_idxs.empty())
return;
for (int obj_idx : object_idxs)
for (size_t obj_idx : object_idxs)
{
if (obj_idx < p->model.objects.size())
// recenter and re - align to Z = 0

View file

@ -89,7 +89,7 @@ public:
~Sidebar();
void init_filament_combo(PresetComboBox **combo, const int extr_idx);
void remove_unused_filament_combos(const int current_extruder_count);
void remove_unused_filament_combos(const size_t current_extruder_count);
void update_all_preset_comboboxes();
void update_presets(Slic3r::Preset::Type preset_type);
void update_mode_sizer() const;
@ -105,7 +105,7 @@ public:
ConfigOptionsGroup* og_freq_chng_params(const bool is_fff);
wxButton* get_wiping_dialog_button();
void update_objects_list_extruder_column(int extruders_count);
void update_objects_list_extruder_column(size_t extruders_count);
void show_info_sizer();
void show_sliced_info_sizer(const bool show);
void enable_buttons(bool enable);
@ -209,7 +209,7 @@ public:
void enter_gizmos_stack();
void leave_gizmos_stack();
void on_extruders_change(int extruders_count);
void on_extruders_change(size_t extruders_count);
void on_config_change(const DynamicPrintConfig &config);
// On activating the parent window.
void on_activate();

View file

@ -366,7 +366,7 @@ void PresetBundle::load_selections(const AppConfig &config, const std::string &p
this->filament_presets = { filaments.get_selected_preset_name() };
for (unsigned int i = 1; i < 1000; ++ i) {
char name[64];
sprintf(name, "filament_%d", i);
sprintf(name, "filament_%u", i);
if (! config.has("presets", name))
break;
this->filament_presets.emplace_back(remove_ini_suffix(config.get("presets", name)));
@ -388,11 +388,12 @@ void PresetBundle::export_selections(AppConfig &config)
config.clear_section("presets");
config.set("presets", "print", prints.get_selected_preset_name());
config.set("presets", "filament", filament_presets.front());
for (int i = 1; i < filament_presets.size(); ++i) {
for (unsigned i = 1; i < filament_presets.size(); ++i) {
char name[64];
sprintf(name, "filament_%d", i);
sprintf(name, "filament_%u", i);
config.set("presets", name, filament_presets[i]);
}
config.set("presets", "sla_print", sla_prints.get_selected_preset_name());
config.set("presets", "sla_material", sla_materials.get_selected_preset_name());
config.set("presets", "printer", printers.get_selected_preset_name());
@ -779,7 +780,7 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
Preset *loaded = nullptr;
if (is_external)
loaded = &this->filaments.load_external_preset(name_or_path, name,
(i < old_filament_profile_names->values.size()) ? old_filament_profile_names->values[i] : "",
(i < int(old_filament_profile_names->values.size())) ? old_filament_profile_names->values[i] : "",
std::move(cfg), i == 0);
else {
// Used by the config wizard when creating a custom setup.
@ -1262,7 +1263,7 @@ void PresetBundle::update_multi_material_filament_presets()
// Now verify if wiping_volumes_matrix has proper size (it is used to deduce number of extruders in wipe tower generator):
std::vector<double> old_matrix = this->project_config.option<ConfigOptionFloats>("wiping_volumes_matrix")->values;
size_t old_number_of_extruders = int(sqrt(old_matrix.size())+EPSILON);
size_t old_number_of_extruders = size_t(sqrt(old_matrix.size())+EPSILON);
if (num_extruders != old_number_of_extruders) {
// First verify if purging volumes presets for each extruder matches number of extruders
std::vector<double>& extruders = this->project_config.option<ConfigOptionFloats>("wiping_volumes_extruders")->values;

View file

@ -232,7 +232,7 @@ void Tab::create_preset_tab()
//! select_preset(m_presets_choice->GetStringSelection().ToUTF8().data());
//! we doing next:
int selected_item = m_presets_choice->GetSelection();
if (m_selected_preset_item == selected_item && !m_presets->current_is_dirty())
if (m_selected_preset_item == size_t(selected_item) && !m_presets->current_is_dirty())
return;
if (selected_item >= 0) {
std::string selected_string = m_presets_choice->GetString(selected_item).ToUTF8().data();
@ -489,7 +489,7 @@ template<class T>
void add_correct_opts_to_options_list(const std::string &opt_key, std::map<std::string, int>& map, Tab *tab, const int& value)
{
T *opt_cur = static_cast<T*>(tab->m_config->option(opt_key));
for (int i = 0; i < opt_cur->values.size(); i++)
for (size_t i = 0; i < opt_cur->values.size(); i++)
map.emplace(opt_key + "#" + std::to_string(i), value);
}
@ -1808,7 +1808,7 @@ void TabPrinter::build_fff()
optgroup->append_single_option_line("single_extruder_multi_material");
optgroup->m_on_change = [this, optgroup](t_config_option_key opt_key, boost::any value) {
size_t extruders_count = boost::any_cast<int>(optgroup->get_value("extruders_count"));
size_t extruders_count = boost::any_cast<size_t>(optgroup->get_value("extruders_count"));
wxTheApp->CallAfter([this, opt_key, value, extruders_count]() {
if (opt_key == "extruders_count" || opt_key == "single_extruder_multi_material") {
extruders_count_changed(extruders_count);
@ -2228,7 +2228,7 @@ void TabPrinter::build_unregular_pages()
// Add/delete Kinematics page according to is_marlin_flavor
size_t existed_page = 0;
for (int i = n_before_extruders; i < m_pages.size(); ++i) // first make sure it's not there already
for (size_t i = n_before_extruders; i < m_pages.size(); ++i) // first make sure it's not there already
if (m_pages[i]->title().find(_(L("Machine limits"))) != std::string::npos) {
if (!is_marlin_flavor || m_rebuild_kinematics_page)
m_pages.erase(m_pages.begin() + i);
@ -2253,7 +2253,7 @@ void TabPrinter::build_unregular_pages()
(m_has_single_extruder_MM_page && m_extruders_count == 1))
{
// if we have a single extruder MM setup, add a page with configuration options:
for (int i = 0; i < m_pages.size(); ++i) // first make sure it's not there already
for (size_t i = 0; i < m_pages.size(); ++i) // first make sure it's not there already
if (m_pages[i]->title().find(_(L("Single extruder MM setup"))) != std::string::npos) {
m_pages.erase(m_pages.begin() + i);
break;
@ -2399,8 +2399,8 @@ void TabPrinter::on_preset_loaded()
{
// update the extruders count field
auto *nozzle_diameter = dynamic_cast<const ConfigOptionFloats*>(m_config->option("nozzle_diameter"));
int extruders_count = nozzle_diameter->values.size();
set_value("extruders_count", extruders_count);
size_t extruders_count = nozzle_diameter->values.size();
set_value("extruders_count", int(extruders_count));
// update the GUI field according to the number of nozzle diameters supplied
extruders_count_changed(extruders_count);
}
@ -2538,7 +2538,7 @@ void TabPrinter::update_fff()
DynamicPrintConfig new_conf = *m_config;
if (dialog.ShowModal() == wxID_YES) {
auto wipe = static_cast<ConfigOptionBools*>(m_config->option("wipe")->clone());
for (int w = 0; w < wipe->values.size(); w++)
for (size_t w = 0; w < wipe->values.size(); w++)
wipe->values[w] = false;
new_conf.set_key_value("wipe", wipe);
}

View file

@ -940,7 +940,7 @@ wxDataViewItem ObjectDataViewModel::Delete(const wxDataViewItem &item)
// node can be deleted by the Delete, let's check its type while we safely can
bool is_instance_root = (node->m_type & itInstanceRoot);
for (int i = node->GetChildCount() - 1; i >= (is_instance_root ? 1 : 0); i--)
for (int i = int(node->GetChildCount() - 1); i >= (is_instance_root ? 1 : 0); i--)
Delete(wxDataViewItem(node->GetNthChild(i)));
return parent;
@ -1020,7 +1020,7 @@ wxDataViewItem ObjectDataViewModel::Delete(const wxDataViewItem &item)
{
int vol_cnt = 0;
int vol_idx = 0;
for (int i = 0; i < node_parent->GetChildCount(); ++i) {
for (size_t i = 0; i < node_parent->GetChildCount(); ++i) {
if (node_parent->GetNthChild(i)->GetType() == itVolume) {
vol_idx = i;
vol_cnt++;
@ -1059,7 +1059,7 @@ wxDataViewItem ObjectDataViewModel::Delete(const wxDataViewItem &item)
else
{
auto it = find(m_objects.begin(), m_objects.end(), node);
auto id = it - m_objects.begin();
size_t id = it - m_objects.begin();
if (it != m_objects.end())
{
// Delete all sub-items
@ -1230,7 +1230,7 @@ void ObjectDataViewModel::DeleteSettings(const wxDataViewItem& parent)
wxDataViewItem ObjectDataViewModel::GetItemById(int obj_idx)
{
if (obj_idx >= m_objects.size())
if (size_t(obj_idx) >= m_objects.size())
{
printf("Error! Out of objects range.\n");
return wxDataViewItem(0);
@ -1241,7 +1241,7 @@ wxDataViewItem ObjectDataViewModel::GetItemById(int obj_idx)
wxDataViewItem ObjectDataViewModel::GetItemByVolumeId(int obj_idx, int volume_idx)
{
if (obj_idx >= m_objects.size() || obj_idx < 0) {
if (size_t(obj_idx) >= m_objects.size()) {
printf("Error! Out of objects range.\n");
return wxDataViewItem(0);
}
@ -1265,7 +1265,7 @@ wxDataViewItem ObjectDataViewModel::GetItemByVolumeId(int obj_idx, int volume_id
wxDataViewItem ObjectDataViewModel::GetItemById(const int obj_idx, const int sub_obj_idx, const ItemType parent_type)
{
if (obj_idx >= m_objects.size() || obj_idx < 0) {
if (size_t(obj_idx) >= m_objects.size()) {
printf("Error! Out of objects range.\n");
return wxDataViewItem(0);
}
@ -1294,7 +1294,7 @@ wxDataViewItem ObjectDataViewModel::GetItemByLayerId(int obj_idx, int layer_idx)
wxDataViewItem ObjectDataViewModel::GetItemByLayerRange(const int obj_idx, const t_layer_height_range& layer_range)
{
if (obj_idx >= m_objects.size() || obj_idx < 0) {
if (size_t(obj_idx) >= m_objects.size()) {
printf("Error! Out of objects range.\n");
return wxDataViewItem(0);
}
@ -1411,13 +1411,13 @@ int ObjectDataViewModel::GetRowByItem(const wxDataViewItem& item) const
int row_num = 0;
for (int i = 0; i < m_objects.size(); i++)
for (size_t i = 0; i < m_objects.size(); i++)
{
row_num++;
if (item == wxDataViewItem(m_objects[i]))
return row_num;
for (int j = 0; j < m_objects[i]->GetChildCount(); j++)
for (size_t j = 0; j < m_objects[i]->GetChildCount(); j++)
{
row_num++;
ObjectDataViewModelNode* cur_node = m_objects[i]->GetNthChild(j);
@ -1429,7 +1429,7 @@ int ObjectDataViewModel::GetRowByItem(const wxDataViewItem& item) const
if (cur_node->m_type == itInstanceRoot)
{
row_num++;
for (int t = 0; t < cur_node->GetChildCount(); t++)
for (size_t t = 0; t < cur_node->GetChildCount(); t++)
{
row_num++;
if (item == wxDataViewItem(cur_node->GetNthChild(t)))
@ -1503,7 +1503,7 @@ bool ObjectDataViewModel::SetValue(const wxVariant &variant, const wxDataViewIte
bool ObjectDataViewModel::SetValue(const wxVariant &variant, const int item_idx, unsigned int col)
{
if (item_idx < 0 || item_idx >= m_objects.size())
if (size_t(item_idx) >= m_objects.size())
return false;
return m_objects[item_idx]->SetValue(variant, col);
@ -1662,7 +1662,7 @@ wxDataViewItem ObjectDataViewModel::GetItemByType(const wxDataViewItem &parent_i
if (node->GetChildCount() == 0)
return wxDataViewItem(0);
for (int i = 0; i < node->GetChildCount(); i++) {
for (size_t i = 0; i < node->GetChildCount(); i++) {
if (node->GetNthChild(i)->m_type == type)
return wxDataViewItem((void*)node->GetNthChild(i));
}
@ -2145,7 +2145,7 @@ void DoubleSlider::draw_scroll_line(wxDC& dc, const int lower_pos, const int hig
wxCoord segm_end_x = is_horizontal() ? higher_pos : width*0.5 - 1;
wxCoord segm_end_y = is_horizontal() ? height*0.5 - 1 : higher_pos-1;
for (int id = 0; id < m_line_pens.size(); id++)
for (size_t id = 0; id < m_line_pens.size(); id++)
{
dc.SetPen(*m_line_pens[id]);
dc.DrawLine(line_beg_x, line_beg_y, line_end_x, line_end_y);
@ -2494,7 +2494,7 @@ void DoubleSlider::draw_colored_band(wxDC& dc)
dc.SetBrush(clr);
dc.DrawRectangle(main_band);
int i = 1;
size_t i = 1;
for (auto tick : m_ticks)
{
if (i == colors_cnt)