update member function calls to match changes in updated spacebox branch
This commit is contained in:
parent
17dee6174f
commit
7ff0d01c6f
2
lib/sb
2
lib/sb
|
@ -1 +1 @@
|
|||
Subproject commit 21e1e7e707004fee91425cb5aef099a19b3fb4ff
|
||||
Subproject commit dc2141c2c441d92b35979f3dac0d5d7e74e440d6
|
|
@ -39,7 +39,7 @@ Pudding::Pudding()
|
|||
camera_view.texture(sb::Texture());
|
||||
|
||||
/* set up pudding model */
|
||||
nlohmann::json pudding = get_configuration()["pudding"];
|
||||
nlohmann::json pudding = configuration()["pudding"];
|
||||
load_pudding_model(pudding["top-radius"], pudding["base-radius"], pudding["ring-vertex-count"], pudding["layer-count"],
|
||||
pudding["y-range"][0], pudding["y-range"][1], pudding["gradient-position"]);
|
||||
|
||||
|
@ -238,7 +238,7 @@ void Pudding::load_gl_context()
|
|||
/* Read every jpg in the folder at tile path into a GL texture and associate with the background object. */
|
||||
void Pudding::load_tiles()
|
||||
{
|
||||
for (fs::path path : sb::glob(get_configuration()["resource"]["tile-path"].get<fs::path>() / ".*.jpg"))
|
||||
for (fs::path path : sb::glob(configuration()["resource"]["tile-path"].get<fs::path>() / ".*.jpg"))
|
||||
{
|
||||
sb::Texture texture {path};
|
||||
texture.load();
|
||||
|
@ -249,12 +249,12 @@ void Pudding::load_tiles()
|
|||
/* Load every png in the button path as a Texture and add to a map. */
|
||||
void Pudding::load_pads()
|
||||
{
|
||||
for (fs::path path : sb::glob(get_configuration()["resource"]["button-path"].get<fs::path>() / ".*.png"))
|
||||
for (fs::path path : sb::glob(configuration()["resource"]["button-path"].get<fs::path>() / ".*.png"))
|
||||
{
|
||||
labels[path.stem()] = sb::Texture(path);
|
||||
labels[path.stem()].load();
|
||||
}
|
||||
nlohmann::json interface = get_configuration()["interface"];
|
||||
nlohmann::json interface = configuration()["interface"];
|
||||
camera_button.texture(labels["scan"]);
|
||||
camera_button.translation({interface["main-button-single-x"], interface["main-button-y"]});
|
||||
camera_button.scale(interface["main-button-scale"], window_box().aspect());
|
||||
|
@ -353,7 +353,7 @@ void Pudding::respond(SDL_Event& event)
|
|||
Box viewport_ndc = sb::Display::ndc;
|
||||
/* Drag viewport completely closed to the bottom of the screen */
|
||||
viewport_ndc.top(viewport_ndc.bottom(), true);
|
||||
nlohmann::json interface = get_configuration()["interface"];
|
||||
nlohmann::json interface = configuration()["interface"];
|
||||
/* Drag viewport back up the height of the pop-up window */
|
||||
viewport_ndc.drag_top(interface["pop-up-viewport-height"]);
|
||||
/* Get the viewport in pixel resolution to size the buttons to be square inside the viewport */
|
||||
|
@ -449,27 +449,27 @@ void Pudding::add_item(const std::string& upc)
|
|||
{
|
||||
Item item;
|
||||
item.upc(upc);
|
||||
if (get_configuration()["api"]["open-food-enabled"])
|
||||
if (configuration()["api"]["open-food-enabled"])
|
||||
{
|
||||
incorporate_open_api(item, OPEN_FOOD_API_URL);
|
||||
}
|
||||
if (get_configuration()["api"]["open-products-enabled"])
|
||||
if (configuration()["api"]["open-products-enabled"])
|
||||
{
|
||||
incorporate_open_api(item, OPEN_PRODUCTS_API_URL);
|
||||
}
|
||||
if (get_configuration()["api"]["nutronix-enabled"])
|
||||
if (configuration()["api"]["nutronix-enabled"])
|
||||
{
|
||||
incorporate_nutronix_api(item);
|
||||
}
|
||||
if (get_configuration()["api"]["edamam-enabled"])
|
||||
if (configuration()["api"]["edamam-enabled"])
|
||||
{
|
||||
incorporate_edamam_api(item);
|
||||
}
|
||||
if (get_configuration()["api"]["best-buy-enabled"])
|
||||
if (configuration()["api"]["best-buy-enabled"])
|
||||
{
|
||||
incorporate_best_buy_api(item);
|
||||
}
|
||||
if (get_configuration()["api"]["google-books-enabled"])
|
||||
if (configuration()["api"]["google-books-enabled"])
|
||||
{
|
||||
incorporate_google_books_api(item);
|
||||
}
|
||||
|
@ -481,7 +481,7 @@ void Pudding::add_item(const std::string& upc)
|
|||
/* Move the camera button away from center to make room for inventory button if this is the first item added. */
|
||||
if (items.size() == 1)
|
||||
{
|
||||
const nlohmann::json& interface = get_configuration()["interface"];
|
||||
const nlohmann::json& interface = configuration()["interface"];
|
||||
camera_button.translation({-1.0f * interface["main-button-double-x"].get<float>(), interface["main-button-y"]});
|
||||
}
|
||||
}
|
||||
|
@ -539,8 +539,8 @@ void Pudding::incorporate_nutronix_api(Item& item)
|
|||
/* Nutronix requires API keys in headers for validation */
|
||||
nlohmann::json json = json_from_url(
|
||||
NUTRONIX_API_URL + item.upc(), {
|
||||
"x-app-id: " + get_configuration()["api"]["nutronix-app-id"].get<std::string>(),
|
||||
"x-app-key: " + get_configuration()["api"]["nutronix-app-key"].get<std::string>()
|
||||
"x-app-id: " + configuration()["api"]["nutronix-app-id"].get<std::string>(),
|
||||
"x-app-key: " + configuration()["api"]["nutronix-app-key"].get<std::string>()
|
||||
});
|
||||
/* test that should determine if a Nutronix response is not empty */
|
||||
if (!(json.contains("message") && json["message"] == NUTRONIX_NOT_FOUND))
|
||||
|
@ -574,8 +574,8 @@ void Pudding::incorporate_edamam_api(Item& item)
|
|||
/* build API url by concatenating relevant values into query string */
|
||||
std::stringstream url;
|
||||
url << "https://api.edamam.com/api/food-database/v2/parser?upc=" << item.upc() << "&app_id=" <<
|
||||
get_configuration()["api"]["edamam-app-id"].get<std::string>() << "&app_key=" <<
|
||||
get_configuration()["api"]["edamam-app-key"].get<std::string>();
|
||||
configuration()["api"]["edamam-app-id"].get<std::string>() << "&app_key=" <<
|
||||
configuration()["api"]["edamam-app-key"].get<std::string>();
|
||||
nlohmann::json json = json_from_url(url.str());
|
||||
/* test that should determine if a Edamam response has food data */
|
||||
if (json.contains("hints") && json["hints"][0].contains("food"))
|
||||
|
@ -607,7 +607,7 @@ void Pudding::incorporate_best_buy_api(Item& item)
|
|||
/* build API url by concatenating relevant values into query string */
|
||||
std::stringstream url;
|
||||
url << "https://api.bestbuy.com/v1/products(upc=" << item.upc() << ")?format=json&apiKey=" <<
|
||||
get_configuration()["api"]["best-buy-api-key"].get<std::string>();
|
||||
configuration()["api"]["best-buy-api-key"].get<std::string>();
|
||||
nlohmann::json json = json_from_url(url.str());
|
||||
/* test that should determine if a Best Buy response has a result */
|
||||
if (json.contains("total") && json["total"].get<int>() > 0)
|
||||
|
@ -673,9 +673,9 @@ void Pudding::incorporate_google_books_api(Item& item)
|
|||
*/
|
||||
void Pudding::save_item_json(const nlohmann::json& json, const Item& item, const std::string& api_name) const
|
||||
{
|
||||
if (get_configuration()["scan"]["json-save"])
|
||||
if (configuration()["scan"]["json-save"])
|
||||
{
|
||||
fs::path path = get_configuration()["scan"]["json-save-directory"];
|
||||
fs::path path = configuration()["scan"]["json-save-directory"];
|
||||
if (!fs::exists(path))
|
||||
{
|
||||
fs::create_directories(path);
|
||||
|
@ -734,7 +734,7 @@ void Pudding::curl_get_bytes(const std::string& url, std::vector<std::uint8_t>&
|
|||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, Pudding::curl_write_response);
|
||||
std::vector<std::uint8_t> food_barcode_response;
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &storage);
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, get_configuration()["api"]["user-agent"].get<std::string>().c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, configuration()["api"]["user-agent"].get<std::string>().c_str());
|
||||
struct curl_slist* list = nullptr;
|
||||
if (headers.size() > 0)
|
||||
{
|
||||
|
@ -871,9 +871,9 @@ void Pudding::update()
|
|||
float time_seconds = SDL_GetTicks() / 1000.0f;
|
||||
|
||||
/* if the config is set to refresh automatically, there may be a new barcode available */
|
||||
if (current_config_barcode != get_configuration()["scan"]["barcode"])
|
||||
if (current_config_barcode != configuration()["scan"]["barcode"])
|
||||
{
|
||||
current_config_barcode = get_configuration()["scan"]["barcode"];
|
||||
current_config_barcode = configuration()["scan"]["barcode"];
|
||||
current_barcode = current_config_barcode;
|
||||
std::ostringstream message;
|
||||
message << "read new barcode from config " << current_barcode;
|
||||
|
@ -891,7 +891,7 @@ void Pudding::update()
|
|||
new_frame_available = false;
|
||||
/* Convert to grayscale for ZBar */
|
||||
cv::cvtColor(camera_frame, camera_frame, cv::COLOR_BGR2GRAY);
|
||||
if (get_configuration()["scan"]["enabled"])
|
||||
if (configuration()["scan"]["enabled"])
|
||||
{
|
||||
zbar::Image query_image(camera_frame.cols, camera_frame.rows, "Y800", static_cast<void*>(camera_frame.data),
|
||||
camera_frame.cols * camera_frame.rows);
|
||||
|
@ -919,7 +919,7 @@ void Pudding::update()
|
|||
/* shrink viewport if item texture or camera will be displayed */
|
||||
if (item_display_active() || capture.isOpened())
|
||||
{
|
||||
viewport.drag_bottom(0.5f * get_configuration()["interface"]["pop-up-viewport-height"].get<float>() * viewport.height());
|
||||
viewport.drag_bottom(0.5f * configuration()["interface"]["pop-up-viewport-height"].get<float>() * viewport.height());
|
||||
}
|
||||
|
||||
/* Save the main viewport dimensions */
|
||||
|
@ -949,7 +949,7 @@ void Pudding::update()
|
|||
/* draw pudding model using MVP shader */
|
||||
glUseProgram(mvp_program);
|
||||
/* calculate the transformation matrix for displaying pudding in viewport */
|
||||
model = glm::rotate(model, weight(get_configuration()["pudding"]["rotation-speed"].get<float>()), Y_UNIT_NORMAL_3D);
|
||||
model = glm::rotate(model, weight(configuration()["pudding"]["rotation-speed"].get<float>()), Y_UNIT_NORMAL_3D);
|
||||
projection = glm::perspective(
|
||||
glm::radians(40.0f * 1 / viewport.aspect()), viewport.aspect(), 0.1f, 100.0f);
|
||||
mvp = projection * VIEW_MATRIX * model;
|
||||
|
@ -980,9 +980,9 @@ void Pudding::update()
|
|||
sb::Log::gl_errors("after pudding sides, before pudding top/bottom");
|
||||
/* enable squircling and draw the top and bottom of pudding */
|
||||
glUniform1i(uniform["mvp"]["uv transformation"], UV_SQUIRCLE);
|
||||
glUniform1f(uniform["mvp"]["coordinate bound"], get_configuration()["pudding"]["top-radius"]);
|
||||
glUniform1f(uniform["mvp"]["coordinate bound"], configuration()["pudding"]["top-radius"]);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, pudding_triangle_vertex_count, pudding_fan_vertex_count);
|
||||
glUniform1f(uniform["mvp"]["coordinate bound"], get_configuration()["pudding"]["base-radius"]);
|
||||
glUniform1f(uniform["mvp"]["coordinate bound"], configuration()["pudding"]["base-radius"]);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, pudding_triangle_vertex_count + pudding_fan_vertex_count, pudding_fan_vertex_count);
|
||||
/* disable squircling for all other drawing */
|
||||
glUniform1i(uniform["mvp"]["uv transformation"], UV_NONE);
|
||||
|
@ -1049,7 +1049,7 @@ void Pudding::update()
|
|||
inventory_button.draw(uniform["flat"]["transformation"]);
|
||||
}
|
||||
}
|
||||
SDL_GL_SwapWindow(get_window());
|
||||
SDL_GL_SwapWindow(window());
|
||||
sb::Log::gl_errors("at end of update");
|
||||
/* add a new item if a new barcode was scanned or entered */
|
||||
if (current_barcode != previous_barcode)
|
||||
|
|
Loading…
Reference in New Issue