Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
elif (metadata and metadata["type"] == 0) or (not metadata and v in DB.entities):
changed, new_entity = imgui.combo(
iden, DB.entities.index(v), DB.entities
)
if changed:
return (ent, att, DB.entities[new_entity])
elif (metadata and metadata["type"] == 2) or (not metadata and isinstance(v, int)):
changed, new_value = imgui.input_int(iden, v)
if changed:
return (ent, att, new_value)
elif (metadata and metadata["type"] == 3) or (not metadata and isinstance(v, float)):
changed, new_value = imgui.input_float(iden, v)
if changed:
return (ent, att, new_value)
elif (metadata and metadata["type"] == 1) or (not metadata and isinstance(v, str)):
changed, new_value = imgui.input_text(
iden,
v,
256,
imgui.INPUT_TEXT_ENTER_RETURNS_TRUE
)
if changed:
return (ent, att, new_value)
except Exception as e:
print("--------")
traceback.print_exc()
print("--------")
imgui.text_colored(str(v), 1, 0, 0, 1)
if imgui.is_item_hovered() and metadata:
imgui.begin_tooltip()
imgui.text_colored("Type: ", 0, 0, 1, 1)
imgui.same_line()
else:
zoom_msg = ""
msg = zoom_msg + image_type_msg
imgui.text(msg)
if im.can_show_big_viewport():
imgui.same_line()
if im.get_force_viewport_size():
show_zoom_button("reset viewport", perform_reset_viewport_size)
else:
show_zoom_button("fit viewport", perform_force_viewport_size)
imgui.new_line()
# Save button
# imgui.same_line()
imgui.push_item_width(60)
changed, im.filename = imgui.input_text(imgui_ext.make_unique_label(""), im.filename, 1000)
imgui.same_line()
if imgui.small_button(imgui_ext.make_unique_label("save")):
cv2.imwrite(im.filename, im.image)
# Show pixel color info
if mouse_location is not None:
color = zoomed_image[int(round(mouse_location.y)), int(round(mouse_location.x))]
mouse2 = np.array([[mouse_location.x], [mouse_location.y], [1.]])
pt_original = np.dot(numpy.linalg.inv(im.zoom_info.affine_transform), mouse2)
position_msg = "({0},{1})".format(int(round(pt_original[0, 0])), int(round(pt_original[1, 0])))
imgui.text(position_msg + " " + color_msg(color))
else:
imgui.text("")
return mouse_location_original_image
def draw_ok_cancel_popup(ide, message="Type a Thing:"):
if imgui.begin_popup(ide):
if not ide in popup_registry:
popup_registry[ide] = ""
imgui.text(message)
changed, popup_registry[ide] = imgui.input_text(
"##" + ide,
popup_registry[ide],
26,
imgui.INPUT_TEXT_ENTER_RETURNS_TRUE
)
if changed or imgui.button("OK"):
imgui.close_current_popup()
val = popup_registry[ide]
popup_registry[ide] = ""
imgui.end_popup()
return val
imgui.same_line()
if imgui.button("Cancel"):
imgui.close_current_popup()
popup_registry[ide] = ""
imgui.end_popup()
data_attr = data_attr.lower().replace(" ", "_").replace("-", "_")
changed, data_type = imgui.combo(
"Value Type##data-type", data_type, DB.type_name
)
if changed and (data_type == 2 or data_type == 3 or data_type == 0):
data_value = 0
elif changed and data_type == 1:
data_value = ""
if data_type == 0:
changed, data_value = imgui.combo(
"Value##data-value-entity",
data_value,
DB.entities
)
elif data_type == 1:
changed, data_value = imgui.input_text(
'Value##data-value-string',
data_value,
256,
imgui.INPUT_TEXT_ENTER_RETURNS_TRUE
)
elif data_type == 2:
changed, data_value = imgui.input_int(
'Value##data-value-int',
data_value
)
elif data_type == 3:
changed, data_value = imgui.input_float(
'Value##data-value-float',
data_value
)
if imgui.button("OK") or imgui.get_io().keys_down[SDL_SCANCODE_RETURN]:
def draw_imgui_query_box(DB, monospace_font):
global query_language, query_value, query_result, query_binds, data_entity, data_attr, data_type, data_value, query_error, new_query_result
imgui.begin("Query...", False)
imgui.push_item_width(100)
clicked, query_language = imgui.combo(
"##query-language", query_language, ["S-Expr", "NL"]
)
imgui.pop_item_width()
imgui.same_line()
if query_language == 0:
imgui.push_font(monospace_font)
changed, query_value = imgui.input_text(
'##query-box',
query_value,
256,
imgui.INPUT_TEXT_ENTER_RETURNS_TRUE
)
if query_language == 0:
imgui.pop_font()
if query_binds == {}:
imgui.text_colored("The results match, but no bindings were created", 0, 1, 0, 1)
elif query_binds:
draw_query(query_binds)
elif query_binds is None and query_result:
imgui.text_colored("Bindings empty but backtracker still present. Try clicking 'Next'", 0, 0, 1, 1)
else:
imgui.text("No results")
def draw_data_popup(DB, constant=False):
global data_entity, data_attr, data_type, data_value, query_error
if imgui.begin_popup("new-data"):
if not constant:
changed, data_entity = imgui.combo(
"Entity##data-entity", data_entity, DB.entities
)
changed, data_attr = imgui.input_text(
'Attribute##data-attr',
data_attr,
256,
)
data_attr = data_attr.lower().replace(" ", "_").replace("-", "_")
changed, data_type = imgui.combo(
"Value Type##data-type", data_type, DB.type_name
)
if changed and (data_type == 2 or data_type == 3 or data_type == 0):
data_value = 0
elif changed and data_type == 1:
data_value = ""
if data_type == 0:
changed, data_value = imgui.combo(
"Value##data-value-entity",
data_value,
def draw_imgui_eav_database(DB):
global table_error
if SHOW_VARS['EAV']:
_, opened = imgui.begin("EAV Database", True)
SHOW_VARS['EAV'] = SHOW_VARS['EAV'] and opened
changed, search_query["entity"] = imgui.input_text(
"Search Entity##search",
search_query["entity"],
256,
imgui.INPUT_TEXT_ENTER_RETURNS_TRUE
)
changed, search_query["attribute"] = imgui.input_text(
"Search Attribute##search-2",
search_query["attribute"],
26,
imgui.INPUT_TEXT_ENTER_RETURNS_TRUE
)
imgui.columns(3, "EavDBAttributes")
imgui.separator()
imgui.text("entity")