Skip to content

Commit

Permalink
Merge pull request IntelRealSense#6622 from ev-mp/win_warnings
Browse files Browse the repository at this point in the history
Eliminate multiple MSVC warnings
  • Loading branch information
ev-mp authored Jun 23, 2020
2 parents d5ac8bb + 7e85829 commit ee3f2ab
Show file tree
Hide file tree
Showing 27 changed files with 132 additions and 123 deletions.
12 changes: 6 additions & 6 deletions common/fw-update-helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ namespace rs2

auto flash = upd.create_flash_backup([&](const float progress)
{
_progress = ((ceil(progress * 5) / 5) * (30 - next_progress)) + next_progress;
_progress = int((ceil(progress * 5) / 5) * (30 - next_progress)) + next_progress;
});

auto temp = get_folder_path(special_folder::app_data);
Expand All @@ -221,7 +221,7 @@ namespace rs2
if (!check_for([this, serial, &dfu]() {
auto devs = _ctx.query_devices();

for (int j = 0; j < devs.size(); j++)
for (uint32_t j = 0; j < devs.size(); j++)
{
try
{
Expand Down Expand Up @@ -267,7 +267,7 @@ namespace rs2

dfu.update(_fw, [&](const float progress)
{
_progress = (ceil(progress * 10) / 10 * (90 - next_progress)) + next_progress;
_progress = int((ceil(progress * 10) / 10 * (90 - next_progress)) + next_progress);
});

log("Firmware Download completed, await DFU transition event");
Expand All @@ -279,15 +279,15 @@ namespace rs2
auto upd = _dev.as<updatable>();
upd.update_unsigned(_fw, [&](const float progress)
{
_progress = (ceil(progress * 10) / 10 * (90 - next_progress)) + next_progress;
_progress = int((ceil(progress * 10) / 10 * (90 - next_progress)) + next_progress);
});
log("Firmware Update completed, waiting for device to reconnect");
}

if (!check_for([this, serial, &dfu]() {
auto devs = _ctx.query_devices();

for (int j = 0; j < devs.size(); j++)
for (uint32_t j = 0; j < devs.size(); j++)
{
try
{
Expand Down Expand Up @@ -341,7 +341,7 @@ namespace rs2

ImGui::SetCursorScreenPos({ float(x + 9), float(y + height - 67) });

ImGui::PushStyleColor(ImGuiCol_Text, alpha(light_grey, 1. - t));
ImGui::PushStyleColor(ImGuiCol_Text, alpha(light_grey, 1.f - t));

if (update_state == RS2_FWU_STATE_INITIAL_PROMPT)
ImGui::Text("Firmware updates offer critical bug fixes and\nunlock new camera capabilities.");
Expand Down
22 changes: 11 additions & 11 deletions common/measurement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ void measurement::add_point(interest_point p)
state.polygons.clear();
}

int last = state.points.size();
if (current_hovered_point == -1 ||
int last = int(state.points.size());
if (current_hovered_point == -1 ||
current_hovered_point >= state.points.size())
{
state.points.push_back(p);
Expand Down Expand Up @@ -122,7 +122,7 @@ void measurement::add_point(interest_point p)
log_function(to_string() << "Measured distance of " << length_to_string(dist.length()));
}

last_hovered_point = state.points.size() - 1;
last_hovered_point = int(state.points.size() - 1);

commit_state();
}
Expand Down Expand Up @@ -186,18 +186,18 @@ void draw_sphere(const float3& pos, float r, int lats, int longs)
{
for(int i = 0; i <= lats; i++)
{
float lat0 = M_PI * (-0.5 + (float) (i - 1) / lats);
float lat0 = float(M_PI) * (-0.5f + (float) (i - 1) / lats);
float z0 = sin(lat0);
float zr0 = cos(lat0);

float lat1 = M_PI * (-0.5 + (float) i / lats);
float lat1 = float(M_PI) * (-0.5f + (float) i / lats);
float z1 = sin(lat1);
float zr1 = cos(lat1);

glBegin(GL_QUAD_STRIP);
for(int j = 0; j <= longs; j++)
{
float lng = 2 * M_PI * (float) (j - 1) / longs;
float lng = 2.f * float(M_PI) * (float) (j - 1) / longs;
float x = cos(lng);
float y = sin(lng);

Expand Down Expand Up @@ -305,7 +305,7 @@ void measurement::draw_ruler(ux_window& win, float3 from, float3 to, float heigh
// calculate center of the ruler line
float3 ctr = from + (to - from) / 2;
float distance = (to - from).length();
draw_label(win, ctr, distance, height);
draw_label(win, ctr, distance, int(height));
}
}

Expand Down Expand Up @@ -352,7 +352,7 @@ void measurement::update_input(ux_window& win, const rs2::rect& viewer_rect)
if (rect_copy.contains(win.get_mouse().cursor))
{
input_ctrl.click = true;
input_ctrl.click_time = glfwGetTime();
input_ctrl.click_time = float(glfwGetTime());
}
}
}
Expand Down Expand Up @@ -478,8 +478,8 @@ void measurement::draw(ux_window& win)
const int segments = 50;
for (int i = 0; i < segments; i++)
{
auto t1 = 2 * M_PI * ((float)i / segments);
auto t2 = 2 * M_PI * ((float)(i+1) / segments);
auto t1 = 2.f * float(M_PI) * ((float)i / segments);
auto t2 = 2.f * float(M_PI) * ((float)(i+1) / segments);
float4 xy1 { cosf(t1) * size, sinf(t1) * size, 0.f, 1.f };
xy1 = basis * xy1;
xy1 = float4 { _picked.x + xy1.x, _picked.y + xy1.y, _picked.z + xy1.z, 1.f };
Expand Down Expand Up @@ -556,7 +556,7 @@ void measurement::draw(ux_window& win)

auto area = calculate_area(points);

draw_label(win, mid, area, win.framebuf_height(), true);
draw_label(win, mid, area, int(win.framebuf_height()), true);
}

for (int i = 0; i < state.edges.size(); i++)
Expand Down
4 changes: 2 additions & 2 deletions common/measurement.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ namespace rs2
double selection_started = 0.0;
float2 down_pos { 0.f, 0.f };
int mouse_wheel = 0;
double click_time = 0.0;
float click_period() { return clamp((glfwGetTime() - click_time) * 10, 0.f, 1.f); }
float click_time = 0.f;
float click_period() { return clamp(float(glfwGetTime() - click_time) * 10, 0.f, 1.f); }
};
mouse_control input_ctrl;
int id = 0;
Expand Down
8 changes: 5 additions & 3 deletions common/metadata-helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ namespace rs2
&cbSecurityDescriptor, // security descriptor
&ftLastWriteTime); // last write time

for (int i = 0; i < cSubKeys; i++)
for (auto i = 0ul; i < cSubKeys; i++)
{
TCHAR achKey[MAX_KEY_LENGTH];
DWORD cbName = MAX_KEY_LENGTH;
Expand All @@ -133,7 +133,8 @@ namespace rs2
{
std::wstring suffix = achKey;
device_id rdid;
if (parse_device_id(std::string(suffix.begin(), suffix.end()), &rdid))
auto a = std::string(suffix.begin(), suffix.end());
if (parse_device_id(a, &rdid))
{
for (auto&& did : kvp.second)
{
Expand Down Expand Up @@ -223,6 +224,7 @@ namespace rs2
CloseHandle(sei.hProcess);
if (exitCode)
throw std::runtime_error("Failed to set metadata registry keys!");
return true;
}
}
else
Expand Down Expand Up @@ -287,7 +289,7 @@ namespace rs2

rs2::context ctx;
auto list = ctx.query_devices();
for (int i = 0; i < list.size(); i++)
for (uint32_t i = 0; i < list.size(); i++)
{
try
{
Expand Down
4 changes: 2 additions & 2 deletions common/model-views.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ namespace rs2
{
s->set_option( RS2_OPTION_SENSOR_MODE, resolution_from_width_height( res_values[ui.selected_res_id].first, res_values[ui.selected_res_id].second ) );
}
catch( not_implemented_error const & e )
catch( not_implemented_error const &)
{
// Just ignore for now: need to figure out a way to write to playback sensors...
}
Expand Down Expand Up @@ -1256,7 +1256,7 @@ namespace rs2
auto height = res_values[ui.selected_res_id].second;
auto res = resolution_from_width_height(width, height);
if (res >= RS2_SENSOR_MODE_VGA && res < RS2_SENSOR_MODE_COUNT)
s->set_option(RS2_OPTION_SENSOR_MODE, res);
s->set_option(RS2_OPTION_SENSOR_MODE, float(res));
}
}
ImGui::PopStyleColor();
Expand Down
24 changes: 12 additions & 12 deletions common/notifications.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ namespace rs2
auto a = curr_progress_value / 100.f;
ImGui::GetWindowDrawList()->AddRectFilled({ float(pos.x + 3 - i), float(pos.y + 3 - i) },
{ float(pos.x + filled_w + i), float(pos.y + 17 + i) },
ImColor(alpha(light_blue, sqrt(a) * 0.02f)), i);
ImColor(alpha(light_blue, sqrt(a) * 0.02f)), float(i));
}

ImGui::GetWindowDrawList()->AddRectFilled({ float(pos.x + 3), float(pos.y + 3) },
Expand Down Expand Up @@ -170,9 +170,9 @@ namespace rs2
{
ImVec4 c;

ImGui::PushStyleColor(ImGuiCol_Button, saturate(c, 1.3));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, saturate(c, 0.9));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, saturate(c, 1.5));
ImGui::PushStyleColor(ImGuiCol_Button, saturate(c, 1.3f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, saturate(c, 0.9f));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, saturate(c, 1.5f));
ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, white);
c = alpha(white, 1 - t);
ImGui::PushStyleColor(ImGuiCol_Text, c);
Expand All @@ -198,7 +198,7 @@ namespace rs2
void notification_model::draw_text(const char* msg, int x, int y, int h)
{
std::string text_name = to_string() << "##notification_text_" << index;
ImGui::PushTextWrapPos(x + width - 100);
ImGui::PushTextWrapPos(x + width - 100.f);
ImGui::PushStyleColor(ImGuiCol_FrameBg, transparent);
ImGui::PushStyleColor(ImGuiCol_ScrollbarBg, transparent);
ImGui::PushStyleColor(ImGuiCol_ScrollbarGrab, transparent);
Expand Down Expand Up @@ -232,7 +232,7 @@ namespace rs2
{
auto title = get_title();
auto lines = static_cast<int>(std::count(title.begin(), title.end(), '\n') + 1);
return (lines + 1) * ImGui::GetTextLineHeight() + 5;
return int((lines + 1) * ImGui::GetTextLineHeight() + 5);
}

void process_notification_model::draw_pre_effect(int x, int y)
Expand Down Expand Up @@ -333,8 +333,8 @@ namespace rs2
{
if (last_x > 100000)
{
last_x = x + 500;
last_y = y;
last_x = x + 500.f;
last_y = float(y);
}
last_moved = system_clock::now();
animating = true;
Expand All @@ -345,12 +345,12 @@ namespace rs2

if (s < 1.f)
{
x = s * x + (1 - s) * last_x;
y = s * y + (1 - s) * last_y;
x = int(s * x + (1 - s) * last_x);
y = int(s * y + (1 - s) * last_y);
}
else
{
last_x = x; last_y = y;
last_x = float(x); last_y = float(y);
animating = false;
if (dismissed && !expanded) to_close = true;
}
Expand Down Expand Up @@ -843,7 +843,7 @@ namespace rs2

ImGui::SetCursorScreenPos({ float(x + 10), float(y + 35) });

ImGui::PushStyleColor(ImGuiCol_Text, alpha(light_grey, 1. - t));
ImGui::PushStyleColor(ImGuiCol_Text, alpha(light_grey, 1.f - t));

std::string s = to_string() << "Saving 3D view to " <<
get_file_name(get_manager().get_filename());
Expand Down
26 changes: 13 additions & 13 deletions common/on-chip-calib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,9 @@ namespace rs2

auto calib_dev = _dev.as<auto_calibrated_device>();
if (tare)
_new_calib = calib_dev.run_tare_calibration(ground_truth, json, [&](const float progress) {_progress = progress;}, 5000);
_new_calib = calib_dev.run_tare_calibration(ground_truth, json, [&](const float progress) {_progress = int(progress);}, 5000);
else
_new_calib = calib_dev.run_on_chip_calibration(json, &_health, [&](const float progress) {_progress = progress;}, 5000);
_new_calib = calib_dev.run_on_chip_calibration(json, &_health, [&](const float progress) {_progress = int(progress);}, 5000);
}

void on_chip_calib_manager::process_flow(std::function<void()> cleanup,
Expand Down Expand Up @@ -393,7 +393,7 @@ namespace rs2

_viewer.is_3d_view = _in_3d_view;

_viewer.ground_truth_r = ground_truth;
_viewer.ground_truth_r = uint32_t(ground_truth);
config_file::instance().set(configurations::viewer::ground_truth_r, ground_truth);

_viewer.synchronization_enable = _synchronized;
Expand Down Expand Up @@ -516,7 +516,7 @@ namespace rs2
else
ImGui::SetCursorScreenPos({ float(x + 9), float(y + 27) });

ImGui::PushStyleColor(ImGuiCol_Text, alpha(light_grey, 1. - t));
ImGui::PushStyleColor(ImGuiCol_Text, alpha(light_grey, 1.f - t));

if (update_state == RS2_CALIB_STATE_INITIAL_PROMPT)
{
Expand Down Expand Up @@ -570,7 +570,7 @@ namespace rs2
ImGui::SetCursorScreenPos({ float(x + 135), float(y + 30) });

std::string id = to_string() << "##avg_step_count_" << index;
ImGui::PushItemWidth(width - 145);
ImGui::PushItemWidth(width - 145.f);
ImGui::SliderInt(id.c_str(), &get_manager().average_step_count, 1, 30);
ImGui::PopItemWidth();

Expand All @@ -586,7 +586,7 @@ namespace rs2

id = to_string() << "##step_count_" << index;

ImGui::PushItemWidth(width - 145);
ImGui::PushItemWidth(width - 145.f);
ImGui::SliderInt(id.c_str(), &get_manager().step_count, 1, 30);
ImGui::PopItemWidth();

Expand All @@ -607,14 +607,14 @@ namespace rs2
std::vector<const char*> vals_cstr;
for (auto&& s : vals) vals_cstr.push_back(s.c_str());

ImGui::PushItemWidth(width - 145);
ImGui::Combo(id.c_str(), &get_manager().accuracy, vals_cstr.data(), vals.size());
ImGui::PushItemWidth(width - 145.f);
ImGui::Combo(id.c_str(), &get_manager().accuracy, vals_cstr.data(), int(vals.size()));

ImGui::SetCursorScreenPos({ float(x + 135), float(y + 35 + ImGui::GetTextLineHeightWithSpacing()) });

ImGui::PopItemWidth();

draw_intrinsic_extrinsic(x, y + 3 * ImGui::GetTextLineHeightWithSpacing() - 10);
draw_intrinsic_extrinsic(x, y + 3 * int(ImGui::GetTextLineHeightWithSpacing()) - 10);

ImGui::SetCursorScreenPos({ float(x + 9), float(y + 52 + 4 * ImGui::GetTextLineHeightWithSpacing()) });
id = to_string() << "Apply High-Accuracy Preset##apply_preset_" << index;
Expand Down Expand Up @@ -651,7 +651,7 @@ namespace rs2
char buff[MAX_SIZE];
memcpy(buff, gt.c_str(), gt.size() + 1);

ImGui::PushItemWidth(width - 145);
ImGui::PushItemWidth(width - 145.f);
if (ImGui::InputText(id.c_str(), buff, std::max((int)gt.size() + 1, 10)))
{
std::stringstream ss;
Expand Down Expand Up @@ -704,9 +704,9 @@ namespace rs2
std::vector<const char*> vals_cstr;
for (auto&& s : vals) vals_cstr.push_back(s.c_str());

ImGui::PushItemWidth(width - 145);
ImGui::PushItemWidth(width - 145.f);

ImGui::Combo(id.c_str(), &get_manager().speed, vals_cstr.data(), vals.size());
ImGui::Combo(id.c_str(), &get_manager().speed, vals_cstr.data(), int(vals.size()));
ImGui::PopItemWidth();

draw_intrinsic_extrinsic(x, y);
Expand Down
2 changes: 1 addition & 1 deletion common/on-chip-calib.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace rs2

void update_last_used();

uint32_t ground_truth = 2500;
float ground_truth = 2500;
int average_step_count = 20;
int step_count = 20;
int accuracy = 2;
Expand Down
6 changes: 3 additions & 3 deletions common/rendering.h
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,7 @@ namespace rs2
inline float single_wave(float x)
{
auto c = clamp(x, 0.f, 1.f);
return 0.5f * (sinf(2.f * M_PI * c - M_PI_2) + 1.f);
return 0.5f * (sinf(2.f * float(M_PI) * c - float(M_PI_2)) + 1.f);
}

// convert 3d points into 2d viewport coordinates
Expand Down Expand Up @@ -1774,8 +1774,8 @@ namespace rs2
p2d.z = clamp(p2d.z, -1.0, 1.0);

// viewport coordinates
float x_vp = round((p2d.x + 1.0) / 2.0 * vp[2]) + vp[0];
float y_vp = round((p2d.y + 1.0) / 2.0 * vp[3]) + vp[1];
float x_vp = round((p2d.x + 1.f) / 2.f * vp[2]) + vp[0];
float y_vp = round((p2d.y + 1.f) / 2.f * vp[3]) + vp[1];

float2 p_w;
p_w.x = x_vp;
Expand Down
Loading

0 comments on commit ee3f2ab

Please sign in to comment.