1870 std::cout <<
"Project must be built before running visualize." << std::endl;
1874#ifdef ENABLE_HELIOS_VISUALIZER
1888 IMGUI_CHECKVERSION();
1889 ImGui::CreateContext();
1890 ImGuiIO &io = ImGui::GetIO();
1892 ImFont *arial = io.Fonts->AddFontFromFileTTF(
"plugins/visualizer/fonts/Arial.ttf", 16.0f);
1895 io.FontDefault = arial;
1896 io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
1905 glfwShowWindow(window);
1907 bool show_demo_window =
false;
1908 bool my_tool_active =
true;
1912 ImGui_ImplGlfw_InitForOpenGL(window,
true);
1913 ImGui_ImplOpenGL3_Init();
1916 ImVec2 current_position;
1917 ImVec2 last_position;
1918 bool currently_collapsed;
1919 bool previously_collapsed =
false;
1920 std::string current_tab =
"General";
1921 std::string previous_tab =
"General";
1927 bool switch_visualization =
false;
1929 std::string current_cam_position =
"0";
1930 while (glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS && glfwWindowShouldClose((GLFWwindow *) window) == 0) {
1932 ImGui_ImplOpenGL3_NewFrame();
1933 ImGui_ImplGlfw_NewFrame();
1953 ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize;
1954 ImGuiWindowFlags window_flags2 = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize;
1958 int windowSize_x = 0;
1959 int windowSize_y = 0;
1961 glfwGetWindowSize((GLFWwindow *) window, &windowSize_x, &windowSize_y);
1962 int2 windowSize(windowSize_x, windowSize_y);
1965 glm::vec4 origin_position;
1966 std::string current_label;
1967 if (ImGui::IsMouseDown(ImGuiMouseButton_Left) && !ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) {
1968 currently_dragging =
"";
1969 disable_dragging =
true;
1971 if (!ImGui::IsMouseDown(ImGuiMouseButton_Left)) {
1972 if (!currently_dragging.empty()) {
1986 ImVec2 mouse_pos = ImGui::GetMousePos();
1988 vec3 camera_pos = camera_lookat_pos[0];
1989 vec3 lookat_pos = camera_lookat_pos[1];
1990 float drag_distance = std::sqrt(std::pow(mouse_pos.x - dragging_start_position.
x, 2) + std::pow(mouse_pos.y - dragging_start_position.
y, 2));
1992 float depth = (camera_pos - lookat_pos).magnitude();
1993 vec3 view_dir = (camera_pos - lookat_pos).normalize();
1997 vec3 right_dir =
cross(world_up, view_dir);
2003 float base_offset = 0.001f;
2004 float offset = base_offset * depth;
2006 if (currently_dragging_type ==
"canopy") {
2007 canopy_dict[currently_dragging].origin += drag_distance * offset * (up_dir + right_dir);
2008 }
else if (currently_dragging_type ==
"rig") {
2009 camera_positions[rig_dict[currently_dragging]] += drag_distance * offset * (up_dir + right_dir);
2012 currently_dragging =
"";
2013 disable_dragging =
false;
2014 dragging_start_position =
int2(0, 0);
2016 int object_window_count = 0;
2017 for (
auto current_label: canopy_labels_set) {
2018 vec3 canopy_origin_ = canopy_dict[current_label].origin;
2019 origin_position = glm::vec4(canopy_origin_.
x, canopy_origin_.
y, canopy_origin_.
z, 1.0);
2020 origin_position = perspectiveTransformationMatrix * origin_position;
2023 ImVec2 next_window_pos = ImVec2(((origin_position.x / origin_position.w) * 0.5f + 0.5f) * windowSize.
x, (1.0f - ((origin_position.y / origin_position.w) * 0.5f + 0.5f)) * windowSize.
y);
2037 ImGui::SetNextWindowCollapsed(
true, ImGuiCond_Once);
2038 ImGui::SetNextWindowPos(next_window_pos);
2040 ImGui::Begin((current_label +
"###" + std::to_string(object_window_count)).c_str(),
nullptr,
2041 ImGui::IsWindowCollapsed() ? 0 : ImGuiWindowFlags_AlwaysAutoResize);
2042 if (ImGui::IsWindowCollapsed()) {
2043 ImGui::SetWindowSize(ImVec2(150, 10));
2045 canopyTab(current_label, object_window_count);
2047 object_window_count++;
2049 for (
auto current_label: rig_labels_set) {
2050 vec3 camera_position_ = camera_position_vec[rig_dict[current_label]][0];
2051 origin_position = glm::vec4(camera_position_.
x, camera_position_.
y, camera_position_.
z, 1.0);
2052 origin_position = perspectiveTransformationMatrix * origin_position;
2055 ImVec2 next_window_pos = ImVec2(((origin_position.x / origin_position.w) * 0.5f + 0.5f) * windowSize.
x, (1.0f - ((origin_position.y / origin_position.w) * 0.5f + 0.5f)) * windowSize.
y);
2069 ImGui::SetNextWindowCollapsed(
true, ImGuiCond_Once);
2070 ImGui::SetNextWindowPos(next_window_pos);
2072 ImGui::Begin((current_label +
"###" + std::to_string(object_window_count)).c_str(),
nullptr,
2073 ImGui::IsWindowCollapsed() ? 0 : ImGuiWindowFlags_AlwaysAutoResize);
2074 if (ImGui::IsWindowCollapsed()) {
2075 ImGui::SetWindowSize(ImVec2(150, 10));
2077 rigTab(current_label, object_window_count);
2079 object_window_count++;
2081 for (std::string obj_name: obj_names_set) {
2082 current_label = obj_name;
2083 vec3 obj_position_ = objects_dict[current_label].position;
2084 origin_position = glm::vec4(obj_position_.
x, obj_position_.
y, obj_position_.
z, 1.0);
2085 origin_position = perspectiveTransformationMatrix * origin_position;
2088 ImVec2 next_window_pos = ImVec2(((origin_position.x / origin_position.w) * 0.5f + 0.5f) * windowSize.
x, (1.0f - ((origin_position.y / origin_position.w) * 0.5f + 0.5f)) * windowSize.
y);
2102 ImGui::SetNextWindowCollapsed(
true, ImGuiCond_Once);
2103 ImGui::SetNextWindowPos(next_window_pos);
2105 ImGui::Begin((current_label +
"###" + std::to_string(object_window_count)).c_str(),
nullptr,
2106 ImGui::IsWindowCollapsed() ? 0 : ImGuiWindowFlags_AlwaysAutoResize);
2107 if (ImGui::IsWindowCollapsed()) {
2108 ImGui::SetWindowSize(ImVec2(150, 10));
2110 objectTab(current_label, object_window_count);
2112 object_window_count++;
2115 ImGui::SetNextWindowCollapsed(
false, ImGuiCond_Once);
2116 ImGui::Begin(
"Editor",
nullptr, window_flags2);
2119 current_position = ImGui::GetWindowPos();
2120 currently_collapsed = ImGui::IsWindowCollapsed();
2122 if (current_tab != previous_tab || current_position.x != last_position.x || current_position.y != last_position.y || currently_collapsed != previously_collapsed) {
2124 previous_tab = current_tab;
2126 if (ImGui::BeginMenuBar()) {
2127 if (ImGui::BeginMenu(
"File")) {
2128 if (ImGui::MenuItem(
"Open..",
"Ctrl+O")) {
2130 if (!file_name.empty()) {
2134 if (ImGui::MenuItem(
"Save XML",
"Ctrl+S")) {
2137 if (ImGui::MenuItem(
"Save As",
"Ctrl+S")) {
2139 if (!new_xml_file.empty()) {
2140 std::string file_extension = new_xml_file;
2141 size_t last_obj_file = file_extension.rfind(
'.');
2142 if (last_obj_file != std::string::npos) {
2143 file_extension = file_extension.substr(last_obj_file + 1);
2145 if (file_extension ==
"xml") {
2146 if (!std::filesystem::exists(new_xml_file)) {
2148 std::filesystem::copy(xml_input_file, new_xml_file, std::filesystem::copy_options::overwrite_existing);
2151 std::string xml_input_file_ = xml_input_file;
2152 pugi::xml_node helios_ = helios;
2153 xml_input_file = new_xml_file;
2154 if (!
open_xml_file(xml_input_file, xmldoc, xml_error_string)) {
2166 std::cout <<
"Not a valid file type. Project must be saved to a XML file." << std::endl;
2170 std::cout <<
"Not a valid file." << std::endl;
2173 if (ImGui::MenuItem(
"Close",
"Ctrl+W")) {
2174 my_tool_active =
false;
2178 if (ImGui::BeginMenu(
"Visualization")) {
2181 if (ImGui::MenuItem(
"! REFRESH LIST !")) {
2182 refreshVisualizationTypes();
2186 if (ImGui::MenuItem(
"RGB (Default)") && visualization_type !=
"RGB") {
2187 visualization_type =
"RGB";
2188 switch_visualization =
true;
2190 std::set<std::string> vis_types;
2191 std::set_union(visualization_types_primitive.begin(), visualization_types_primitive.end(), visualization_types_object.begin(), visualization_types_object.end(), std::inserter(vis_types, vis_types.begin()));
2192 for (
auto &type: vis_types) {
2193 if (ImGui::MenuItem(type.c_str()) && visualization_type != type) {
2194 visualization_type = type;
2195 switch_visualization =
true;
2198 if (switch_visualization) {
2199 if (visualization_type !=
"RGB") {
2200 if (visualization_types_primitive.find(visualization_type) != visualization_types_primitive.end()) {
2209 switch_visualization =
false;
2213 ImGui::EndMenuBar();
2215 if (ImGui::Button(
"Reload")) {
2217 const char *font_name =
"LCD";
2222#ifdef ENABLE_PLANT_ARCHITECTURE
2225#ifdef ENABLE_RADIATION_MODEL
2228#ifdef ENABLE_SOLARPOSITION
2231#ifdef ENABLE_ENERGYBALANCEMODEL
2234#ifdef ENABLE_BOUNDARYLAYERCONDUCTANCEMODEL
2237#ifdef ENABLE_RADIATION_MODEL
2244#ifdef ENABLE_PLANT_ARCHITECTURE
2250 std::string image_dir =
"./saved/";
2251 bool dir = std::filesystem::create_directories(image_dir);
2252 if (!dir && !std::filesystem::exists(image_dir)) {
2253 helios_runtime_error(
"Error: image output directory " + image_dir +
" could not be created. Exiting...");
2258#ifdef ENABLE_RADIATION_MODEL
2260 if (ImGui::Button(
"Record")) {
2261 if (band_group_names.empty()) {
2262 std::cout <<
"At least 1 band group (a group of 1 or 3 bands) must be defined to record images." << std::endl;
2265 const char *font_name =
"LCD";
2268 updatePrimitiveTypes();
2278 ImGui::OpenPopupOnItemClick(
"repeat_record", ImGuiPopupFlags_MouseButtonRight);
2284 ImGui::Text(
"Console:");
2286 if (ImGui::BeginTabBar(
"Settings#left_tabs_bar")) {
2287 if (ImGui::BeginTabItem(
"General")) {
2288 current_tab =
"General";
2290 ImGui::SetWindowFontScale(1.25f);
2291 ImGui::Text(
"Visualization:");
2292 ImGui::SetWindowFontScale(1.0f);
2294 bool enable_coords_ = enable_coordinate_axes;
2295 toggle_button(
"##coordinate_axes", &enable_coordinate_axes);
2296 if (enable_coords_ != enable_coordinate_axes) {
2297 if (enable_coordinate_axes) {
2306 if (enable_coordinate_axes) {
2307 ImGui::Text(
"Coordinate Axes Enabled");
2309 ImGui::Text(
"Coordinate Axes Disabled");
2312 bool enable_colorbar_ = enable_colorbar;
2314 if (enable_colorbar_ != enable_colorbar) {
2315 if (enable_colorbar) {
2324 if (enable_colorbar) {
2325 ImGui::Text(
"Colorbar Enabled");
2327 ImGui::Text(
"Colorbar Disabled");
2330 std::string prev_lighting_model = lighting_model;
2331 ImGui::SetNextItemWidth(120);
2332 dropDown(
"Lighting Model", lighting_model, lighting_models);
2333 if (prev_lighting_model != lighting_model) {
2334 if (lighting_model ==
"None")
2336 if (lighting_model ==
"Phong")
2338 if (lighting_model ==
"Phong Shadowed")
2341 ImGui::SetNextItemWidth(120);
2343 ImGui::InputFloat(
"Light Intensity Factor", &light_intensity);
2348 if (light_coord_type) {
2350 vec2 light_dir_sphere;
2353 ImGui::Text(
"Elevation:");
2355 ImGui::SetNextItemWidth(80);
2356 ImGui::InputFloat(
"##light_elevation", &light_dir_sphere.
x);
2358 ImGui::Text(
"Azimuth:");
2360 ImGui::SetNextItemWidth(80);
2361 ImGui::InputFloat(
"##light_azimuth", &light_dir_sphere.
y);
2363 ImGui::Text(
"Light Direction (Spherical)");
2364 if (light_dir_sphere.
x != light_dir_sphere_.
elevation || light_dir_sphere.
y != light_dir_sphere_.
azimuth) {
2370 light_dir[0] = light_direction.
x;
2371 light_dir[1] = light_direction.
y;
2372 light_dir[2] = light_direction.
z;
2373 ImGui::InputFloat3(
"Light Direction (Cartesian)", light_dir);
2374 light_direction.
x = light_dir[0];
2375 light_direction.
y = light_dir[1];
2376 light_direction.
z = light_dir[2];
2380 ImGui::SetWindowFontScale(1.25f);
2381 ImGui::Text(
"Location:");
2382 ImGui::SetWindowFontScale(1.0f);
2383 if (ImGui::Button(
"Update Location")) {
2387 ImGui::SetNextItemWidth(100);
2388 ImGui::InputFloat(
"Latitude", &latitude);
2390 randomizerParams(
"latitude");
2391 ImGui::OpenPopupOnItemClick(
"randomize_latitude", ImGuiPopupFlags_MouseButtonRight);
2394 ImGui::SetNextItemWidth(100);
2395 ImGui::InputFloat(
"Longitude", &longitude);
2397 randomizerParams(
"longitude");
2398 ImGui::OpenPopupOnItemClick(
"randomize_longitude", ImGuiPopupFlags_MouseButtonRight);
2400 ImGui::SetNextItemWidth(100);
2401 ImGui::InputInt(
"UTC Offset", &UTC_offset);
2403 randomizerParams(
"UTC_offset");
2404 ImGui::OpenPopupOnItemClick(
"randomize_UTC_offset", ImGuiPopupFlags_MouseButtonRight);
2406 ImGui::SetNextItemWidth(60);
2407 ImGui::RadioButton(
"CSV", is_weather_file_csv);
2408 if (ImGui::IsItemClicked())
2409 is_weather_file_csv =
true;
2411 ImGui::RadioButton(
"CIMIS", !is_weather_file_csv);
2412 if (ImGui::IsItemClicked())
2413 is_weather_file_csv =
false;
2414 std::string prev_weather_file;
2415 std::string *weather_file;
2416 if (is_weather_file_csv) {
2418 weather_file = &csv_weather_file;
2419 prev_weather_file = csv_weather_file;
2421 ImGui::Text(
"CIMIS");
2422 weather_file = &cimis_weather_file;
2423 prev_weather_file = cimis_weather_file;
2426 if (ImGui::Button(
"Weather File")) {
2428 if (!weather_file_.empty()) {
2429 *weather_file = weather_file_;
2431 if (is_weather_file_csv) {
2437 std::cout <<
"Failed to load weather file: " << *weather_file << std::endl;
2438 *weather_file = prev_weather_file;
2441 *weather_file = prev_weather_file;
2445 std::string shorten_weather_file = *weather_file;
2446 for (
char &c: shorten_weather_file) {
2451 size_t last_weather_file = shorten_weather_file.rfind(
'/');
2452 if (last_weather_file != std::string::npos) {
2453 shorten_weather_file = shorten_weather_file.substr(last_weather_file + 1);
2455 ImGui::Text(
"%s", shorten_weather_file.c_str());
2457 ImGui::SetWindowFontScale(1.25f);
2458 ImGui::Text(
"Ground:");
2459 ImGui::SetWindowFontScale(1.0f);
2460 if (ImGui::Button(
"Update Ground")) {
2462 updatePrimitiveTypes();
2468 if (ImGui::Button(
"Delete Ground")) {
2470 updatePrimitiveTypes();
2477 ImGui::RadioButton(
"Use Texture File", ground_flag == 1);
2478 if (ImGui::IsItemClicked())
2481 ImGui::RadioButton(
"Use Model File", ground_flag == 2);
2482 if (ImGui::IsItemClicked())
2484 if (ground_flag == 0) {
2486 ImGui::ColorEdit3(
"##ground_color_edit", ground_color);
2487 }
else if (ground_flag == 1) {
2489 ImGui::SetNextItemWidth(60);
2490 if (ImGui::Button(
"Ground Texture File")) {
2492 if (!ground_texture_file_.empty()) {
2493 ground_texture_file = ground_texture_file_;
2497 std::string shorten = ground_texture_file;
2498 for (
char &c: shorten) {
2503 size_t last = shorten.rfind(
'/');
2504 if (last != std::string::npos) {
2505 shorten = shorten.substr(last + 1);
2507 ImGui::Text(
"%s", shorten.c_str());
2508 }
else if (ground_flag == 2) {
2510 ImGui::SetNextItemWidth(60);
2511 if (ImGui::Button(
"Ground Model File")) {
2513 if (!ground_model_file_.empty()) {
2514 ground_model_file = ground_model_file_;
2518 ImGui::Text(
"%s",
shortenPath(ground_model_file).c_str());
2520 toggle_button(
"##use_ground_texture_color", &use_ground_texture);
2522 if (use_ground_texture) {
2524 ImGui::Text(
"Use Ground Texture Color");
2527 ImGui::ColorEdit3(
"##ground_color_edit", ground_color);
2529 ImGui::Text(
"Manually Set Ground Color");
2532 ImGui::SetNextItemWidth(60);
2533 ImGui::InputFloat(
"##domain_origin_x", &domain_origin.
x);
2535 randomizerParams(
"domain_origin_x");
2536 ImGui::OpenPopupOnItemClick(
"randomize_domain_origin_x", ImGuiPopupFlags_MouseButtonRight);
2538 ImGui::SetNextItemWidth(60);
2539 ImGui::InputFloat(
"##domain_origin_y", &domain_origin.
y);
2541 randomizerParams(
"domain_origin_y");
2542 ImGui::OpenPopupOnItemClick(
"randomize_domain_origin_y", ImGuiPopupFlags_MouseButtonRight);
2544 ImGui::SetNextItemWidth(60);
2545 ImGui::InputFloat(
"##domain_origin_z", &domain_origin.
z);
2547 randomizerParams(
"domain_origin_z");
2548 ImGui::OpenPopupOnItemClick(
"randomize_domain_origin_z", ImGuiPopupFlags_MouseButtonRight);
2550 ImGui::Text(
"Domain Origin");
2551 if (ground_flag == 1) {
2553 ImGui::SetNextItemWidth(100);
2554 ImGui::InputInt(
"##ground_resolution_x", &ground_resolution.
x);
2555 randomizePopup(
"ground_resolution_x",
createTaggedPtr(&ground_resolution.
x));
2556 randomizerParams(
"ground_resolution_x");
2557 ImGui::OpenPopupOnItemClick(
"randomize_ground_resolution_x", ImGuiPopupFlags_MouseButtonRight);
2559 ImGui::SetNextItemWidth(100);
2560 ImGui::InputInt(
"##ground_resolution_y", &ground_resolution.
y);
2561 randomizePopup(
"ground_resolution_y",
createTaggedPtr(&ground_resolution.
y));
2562 randomizerParams(
"ground_resolution_y");
2563 ImGui::OpenPopupOnItemClick(
"randomize_ground_resolution_y", ImGuiPopupFlags_MouseButtonRight);
2565 ImGui::Text(
"Ground Resolution");
2567 ImGui::SetNextItemWidth(50);
2568 ImGui::InputFloat(
"##domain_extent_x", &domain_extent.
x);
2570 randomizerParams(
"domain_extent_x");
2571 ImGui::OpenPopupOnItemClick(
"randomize_domain_extent_x", ImGuiPopupFlags_MouseButtonRight);
2573 ImGui::SetNextItemWidth(50);
2574 ImGui::InputFloat(
"##domain_extent_y", &domain_extent.
y);
2576 randomizerParams(
"domain_extent_y");
2577 ImGui::OpenPopupOnItemClick(
"randomize_domain_extent_y", ImGuiPopupFlags_MouseButtonRight);
2579 ImGui::Text(
"Domain Extent");
2581 ImGui::SetNextItemWidth(60);
2583 temp[0] = num_tiles.
x;
2584 temp[1] = num_tiles.
y;
2585 ImGui::InputInt2(
"Number of Tiles", temp);
2586 num_tiles.
x = temp[0];
2587 num_tiles.
y = temp[1];
2590 ImGui::EndTabItem();
2593 if (ImGui::BeginTabItem(
"Object")) {
2594 current_tab =
"Object";
2595 if (ImGui::Button(
"Load Object File")) {
2597 if (!new_obj_file.empty() && std::filesystem::exists(new_obj_file)) {
2598 if (std::filesystem::path(new_obj_file).extension() !=
".obj" && std::filesystem::path(new_obj_file).extension() !=
".ply") {
2599 std::cout <<
"Object file must have .obj or .ply extension." << std::endl;
2602 std::vector<uint> new_UUIDs;
2603 if (std::filesystem::path(new_obj_file).extension() ==
".obj") {
2605 }
else if (std::filesystem::path(new_obj_file).extension() ==
".ply") {
2609 std::filesystem::path mtl_path(new_obj_file);
2610 mtl_path.replace_extension(
"mtl");
2611 if (std::filesystem::exists(mtl_path)) {
2612 new_obj.use_texture_file =
true;
2614 new_obj.use_texture_file =
false;
2618 std::string default_object_label =
"object";
2619 std::string new_obj_label =
"object_0";
2621 while (objects_dict.find(new_obj_label) != objects_dict.end()) {
2623 new_obj_label = default_object_label +
"_" + std::to_string(count);
2625 obj_names_set.insert(new_obj_label);
2626 new_obj.index = obj_idx;
2628 new_obj.name = new_obj_label;
2629 new_obj.file = new_obj_file;
2630 new_obj.UUIDs = new_UUIDs;
2631 new_obj.position =
vec3(0, 0, 0);
2632 new_obj.prev_position =
vec3(0, 0, 0);
2633 new_obj.orientation =
vec3(0, 0, 0);
2634 new_obj.prev_orientation =
vec3(0, 0, 0);
2635 new_obj.scale =
vec3(1, 1, 1);
2636 new_obj.prev_scale =
vec3(1, 1, 1);
2638 new_obj.prev_color =
RGBcolor(0, 0, 1);
2639 new_obj.data_group =
"";
2640 new_obj.is_dirty =
false;
2641 current_obj = new_obj_label;
2642 objects_dict[new_obj_label] = new_obj;
2646 if (ImGui::BeginCombo(
"##obj_combo", current_obj.c_str())) {
2647 for (std::string obj_name: obj_names_set) {
2648 bool is_obj_selected = (current_obj == obj_name);
2649 if (ImGui::Selectable(obj_name.c_str(), is_obj_selected))
2650 current_obj = obj_name;
2651 if (is_obj_selected)
2652 ImGui::SetItemDefaultFocus();
2657 ImGui::Text(
"Select Object");
2658 if (!current_obj.empty()) {
2663 if (ImGui::Button(
"Delete Object")) {
2664 deleteObject(current_obj);
2666 if (objects_dict[current_obj].is_dirty) {
2668 ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 0, 0, 255));
2669 ImGui::Text(
"update required");
2670 ImGui::PopStyleColor();
2672 ImGui::SetNextItemWidth(100);
2673 std::string prev_obj_name = objects_dict[current_obj].name;
2674 ImGui::InputText(
"##obj_name", &objects_dict[current_obj].name);
2675 if (objects_dict[current_obj].name != prev_obj_name && !objects_dict[current_obj].name.empty() && obj_names_set.find(objects_dict[current_obj].name) == obj_names_set.end()) {
2676 object temp_obj = objects_dict[prev_obj_name];
2677 current_obj = objects_dict[current_obj].name;
2678 std::map<std::string, object>::iterator delete_obj_iter = objects_dict.find(prev_obj_name);
2679 if (delete_obj_iter != objects_dict.end()) {
2680 objects_dict.erase(delete_obj_iter);
2682 objects_dict[current_obj] = temp_obj;
2683 obj_names_set.erase(prev_obj_name);
2684 obj_names_set.insert(current_obj);
2686 objects_dict[current_obj].name = prev_obj_name;
2689 ImGui::Text(
"Object Name");
2690 if (!current_obj.empty()) {
2692 ImGui::SetNextItemWidth(100);
2693 std::string prev_obj_data_group = objects_dict[current_obj].data_group;
2694 ImGui::InputText(
"##obj_data_group", &objects_dict[current_obj].data_group);
2695 if (objects_dict[current_obj].data_group ==
"All" || objects_dict[current_obj].data_group.empty()) {
2696 objects_dict[current_obj].data_group = prev_obj_data_group;
2698 if (!objects_dict[current_obj].data_group.empty() && prev_obj_data_group != objects_dict[current_obj].data_group) {
2699 std::string new_data_group = objects_dict[current_obj].data_group;
2703 ImGui::Text(
"Data Group");
2704 bool use_obj_texture = objects_dict[current_obj].use_texture_file;
2706 if (use_obj_texture != objects_dict[current_obj].use_texture_file) {
2707 objects_dict[current_obj].use_texture_file = use_obj_texture;
2708 objects_dict[current_obj].is_dirty =
true;
2713 if (!use_obj_texture) {
2716 col[0] = objects_dict[current_obj].color.r;
2717 col[1] = objects_dict[current_obj].color.g;
2718 col[2] = objects_dict[current_obj].color.b;
2719 ImGui::ColorEdit3(
"##obj_color_edit", col);
2720 if (objects_dict[current_obj].color.r != col[0] || objects_dict[current_obj].color.g != col[1] || objects_dict[current_obj].color.b != col[2]) {
2724 ImGui::Text(
"Object Color");
2727 ImGui::Text(
"Use Color from Texture File");
2730 ImGui::SetNextItemWidth(60);
2731 ImGui::InputFloat(
"##obj_scale_x", &objects_dict[current_obj].scale.x);
2732 randomizePopup(
"obj_scale_x_" + std::to_string(objects_dict[current_obj].index),
createTaggedPtr(&objects_dict[current_obj].scale.x, &objects_dict[current_obj].is_dirty));
2733 randomizerParams(
"obj_scale_x_" + std::to_string(objects_dict[current_obj].index));
2734 ImGui::OpenPopupOnItemClick((
"randomize_obj_scale_x_" + std::to_string(objects_dict[current_obj].index)).c_str(), ImGuiPopupFlags_MouseButtonRight);
2736 ImGui::SetNextItemWidth(60);
2737 ImGui::InputFloat(
"##obj_scale_y", &objects_dict[current_obj].scale.y);
2738 randomizePopup(
"obj_scale_y_" + std::to_string(objects_dict[current_obj].index),
createTaggedPtr(&objects_dict[current_obj].scale.y, &objects_dict[current_obj].is_dirty));
2739 randomizerParams(
"obj_scale_y_" + std::to_string(objects_dict[current_obj].index));
2740 ImGui::OpenPopupOnItemClick((
"randomize_obj_scale_y_" + std::to_string(objects_dict[current_obj].index)).c_str(), ImGuiPopupFlags_MouseButtonRight);
2742 ImGui::SetNextItemWidth(60);
2743 ImGui::InputFloat(
"##obj_scale_z", &objects_dict[current_obj].scale.z);
2744 randomizePopup(
"obj_scale_z_" + std::to_string(objects_dict[current_obj].index),
createTaggedPtr(&objects_dict[current_obj].scale.z, &objects_dict[current_obj].is_dirty));
2745 randomizerParams(
"obj_scale_z_" + std::to_string(objects_dict[current_obj].index));
2746 ImGui::OpenPopupOnItemClick((
"randomize_obj_scale_z_" + std::to_string(objects_dict[current_obj].index)).c_str(), ImGuiPopupFlags_MouseButtonRight);
2748 ImGui::Text(
"Object Scale");
2750 ImGui::SetNextItemWidth(60);
2751 ImGui::InputFloat(
"##obj_position_x", &objects_dict[current_obj].position.x);
2752 randomizePopup(
"obj_position_x_" + std::to_string(objects_dict[current_obj].index),
createTaggedPtr(&objects_dict[current_obj].position.x, &objects_dict[current_obj].is_dirty));
2753 randomizerParams(
"obj_position_x_" + std::to_string(objects_dict[current_obj].index));
2754 ImGui::OpenPopupOnItemClick((
"randomize_obj_position_x_" + std::to_string(objects_dict[current_obj].index)).c_str(), ImGuiPopupFlags_MouseButtonRight);
2756 ImGui::SetNextItemWidth(60);
2757 ImGui::InputFloat(
"##obj_position_y", &objects_dict[current_obj].position.y);
2758 randomizePopup(
"obj_position_y_" + std::to_string(objects_dict[current_obj].index),
createTaggedPtr(&objects_dict[current_obj].position.y, &objects_dict[current_obj].is_dirty));
2759 randomizerParams(
"obj_position_y_" + std::to_string(objects_dict[current_obj].index));
2760 ImGui::OpenPopupOnItemClick((
"randomize_obj_position_y_" + std::to_string(objects_dict[current_obj].index)).c_str(), ImGuiPopupFlags_MouseButtonRight);
2762 ImGui::SetNextItemWidth(60);
2763 ImGui::InputFloat(
"##obj_position_z", &objects_dict[current_obj].position.z);
2764 randomizePopup(
"obj_position_z_" + std::to_string(objects_dict[current_obj].index),
createTaggedPtr(&objects_dict[current_obj].position.z, &objects_dict[current_obj].is_dirty));
2765 randomizerParams(
"obj_position_z_" + std::to_string(objects_dict[current_obj].index));
2766 ImGui::OpenPopupOnItemClick((
"randomize_obj_position_z_" + std::to_string(objects_dict[current_obj].index)).c_str(), ImGuiPopupFlags_MouseButtonRight);
2768 ImGui::Text(
"Object Position");
2770 ImGui::SetNextItemWidth(60);
2771 ImGui::InputFloat(
"##obj_orientation_x", &objects_dict[current_obj].orientation.x);
2772 randomizePopup(
"obj_orientation_x_" + std::to_string(objects_dict[current_obj].index),
createTaggedPtr(&objects_dict[current_obj].orientation.x, &objects_dict[current_obj].is_dirty));
2773 randomizerParams(
"obj_orientation_x_" + std::to_string(objects_dict[current_obj].index));
2774 ImGui::OpenPopupOnItemClick((
"randomize_obj_orientation_x_" + std::to_string(objects_dict[current_obj].index)).c_str(), ImGuiPopupFlags_MouseButtonRight);
2776 ImGui::SetNextItemWidth(60);
2777 ImGui::InputFloat(
"##obj_orientation_y", &objects_dict[current_obj].orientation.y);
2778 randomizePopup(
"obj_orientation_y_" + std::to_string(objects_dict[current_obj].index),
createTaggedPtr(&objects_dict[current_obj].orientation.y, &objects_dict[current_obj].is_dirty));
2779 randomizerParams(
"obj_orientation_y_" + std::to_string(objects_dict[current_obj].index));
2780 ImGui::OpenPopupOnItemClick((
"randomize_obj_orientation_y_" + std::to_string(objects_dict[current_obj].index)).c_str(), ImGuiPopupFlags_MouseButtonRight);
2782 ImGui::SetNextItemWidth(60);
2783 ImGui::InputFloat(
"##obj_orientation_z", &objects_dict[current_obj].orientation.z);
2784 randomizePopup(
"obj_orientation_z_" + std::to_string(objects_dict[current_obj].index),
createTaggedPtr(&objects_dict[current_obj].orientation.z, &objects_dict[current_obj].is_dirty));
2785 randomizerParams(
"obj_orientation_z_" + std::to_string(objects_dict[current_obj].index));
2786 ImGui::OpenPopupOnItemClick((
"randomize_obj_orientation_z_" + std::to_string(objects_dict[current_obj].index)).c_str(), ImGuiPopupFlags_MouseButtonRight);
2788 ImGui::Text(
"Object Orientation");
2789 if (objects_dict[current_obj].position != objects_dict[current_obj].prev_position || objects_dict[current_obj].orientation != objects_dict[current_obj].prev_orientation ||
2790 objects_dict[current_obj].scale != objects_dict[current_obj].prev_scale || objects_dict[current_obj].color != objects_dict[current_obj].prev_color) {
2791 objects_dict[current_obj].is_dirty =
true;
2793 if (objects_dict[current_obj].is_dirty && !ImGui::IsAnyItemActive() && !ImGui::IsAnyItemFocused()) {
2798 ImGui::EndTabItem();
2801#ifdef ENABLE_PLANT_ARCHITECTURE
2803 if (ImGui::BeginTabItem(
"Canopy")) {
2804 current_tab =
"Canopy";
2805 dropDown(
"##canopy_combo", current_canopy, canopy_labels_set);
2807 if (ImGui::Button(
"Add Canopy")) {
2810 if (!current_canopy.empty()) {
2811 if (ImGui::Button(
"Update Canopy")) {
2812 updateCanopy(current_canopy);
2814 canopy_dict[current_canopy].is_dirty =
false;
2817 if (ImGui::Button(
"Delete Canopy")) {
2818 deleteCanopy(current_canopy);
2819 updatePrimitiveTypes();
2824 if (canopy_dict[current_canopy].is_dirty) {
2826 ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 0, 0, 255));
2827 ImGui::Text(
"update required");
2828 ImGui::PopStyleColor();
2830 ImGui::SetNextItemWidth(100);
2831 std::string prev_canopy_name = canopy_dict[current_canopy].label;
2832 ImGui::InputText(
"##canopy_name", &canopy_dict[current_canopy].label);
2833 if (canopy_dict[current_canopy].label != prev_canopy_name && canopy_labels_set.find(canopy_dict[current_canopy].label) == canopy_labels_set.end() && !canopy_dict[current_canopy].label.empty()) {
2834 canopy temp = canopy_dict[current_canopy];
2835 current_canopy = canopy_dict[prev_canopy_name].label;
2836 std::map<std::string, canopy>::iterator current_canopy_iter = canopy_dict.find(prev_canopy_name);
2837 if (current_canopy_iter != canopy_dict.end()) {
2838 canopy_dict.erase(current_canopy_iter);
2840 canopy_dict[current_canopy] = temp;
2842 canopy_labels_set.erase(prev_canopy_name);
2843 canopy_labels_set.insert(current_canopy);
2845 canopy_dict[current_canopy].label = prev_canopy_name;
2848 ImGui::Text(
"Canopy Name");
2850 ImGui::SetNextItemWidth(250);
2852 std::string prev_lib = canopy_dict[current_canopy].library_name_verbose;
2853 dropDown(
"Plant Library###dropdown", canopy_dict[current_canopy].library_name_verbose, plant_types_verbose);
2854 if (canopy_dict[current_canopy].library_name_verbose != prev_lib)
2855 canopy_dict[current_canopy].is_dirty =
true;
2856 canopy_dict[current_canopy].library_name = plant_type_lookup[canopy_dict[current_canopy].library_name_verbose];
2858 ImGui::SetNextItemWidth(100);
2859 std::string prev_canopy_data_group = canopy_dict[current_canopy].data_group;
2860 ImGui::InputText(
"##canopy_data_group", &canopy_dict[current_canopy].data_group);
2861 if (canopy_dict[current_canopy].data_group ==
"All" || canopy_dict[current_canopy].data_group.empty()) {
2862 canopy_dict[current_canopy].data_group = prev_canopy_data_group;
2864 if (!canopy_dict[current_canopy].data_group.empty() && prev_canopy_data_group != canopy_dict[current_canopy].data_group) {
2865 std::string new_data_group = canopy_dict[current_canopy].data_group;
2866 std::vector<uint> canopy_primID_vec;
2867 for (
int i = 0; i < canopy_dict[current_canopy].IDs.size(); i++) {
2869 canopy_primID_vec.insert(canopy_primID_vec.end(), new_canopy_primIDs.begin(), new_canopy_primIDs.end());
2874 ImGui::Text(
"Data Group");
2876 vec3 prev_canopy_origin_ =
vec3(canopy_dict[current_canopy].origin);
2877 ImGui::SetNextItemWidth(60);
2878 ImGui::InputFloat(
"##canopy_origin_x", &canopy_dict[current_canopy].origin.x);
2879 randomizePopup(
"canopy_origin_x_" + std::to_string(canopy_dict[current_canopy].idx),
createTaggedPtr(&canopy_dict[current_canopy].origin.x));
2880 randomizerParams(
"canopy_origin_x_" + std::to_string(canopy_dict[current_canopy].idx));
2881 ImGui::OpenPopupOnItemClick((
"randomize_canopy_origin_x_" + std::to_string(canopy_dict[current_canopy].idx)).c_str(), ImGuiPopupFlags_MouseButtonRight);
2883 ImGui::SetNextItemWidth(60);
2884 ImGui::InputFloat(
"##canopy_origin_y", &canopy_dict[current_canopy].origin.y);
2885 randomizePopup(
"canopy_origin_y_" + std::to_string(canopy_dict[current_canopy].idx),
createTaggedPtr(&canopy_dict[current_canopy].origin.y));
2886 randomizerParams(
"canopy_origin_y_" + std::to_string(canopy_dict[current_canopy].idx));
2887 ImGui::OpenPopupOnItemClick((
"randomize_canopy_origin_y_" + std::to_string(canopy_dict[current_canopy].idx)).c_str(), ImGuiPopupFlags_MouseButtonRight);
2889 ImGui::SetNextItemWidth(60);
2890 ImGui::InputFloat(
"##canopy_origin_z", &canopy_dict[current_canopy].origin.z);
2891 randomizePopup(
"canopy_origin_z_" + std::to_string(canopy_dict[current_canopy].idx),
createTaggedPtr(&canopy_dict[current_canopy].origin.z));
2892 randomizerParams(
"canopy_origin_z_" + std::to_string(canopy_dict[current_canopy].idx));
2893 ImGui::OpenPopupOnItemClick((
"randomize_canopy_origin_z_" + std::to_string(canopy_dict[current_canopy].idx)).c_str(), ImGuiPopupFlags_MouseButtonRight);
2895 ImGui::Text(
"Canopy Origin");
2896 if (prev_canopy_origin_ != canopy_dict[current_canopy].origin) {
2897 canopy_dict[current_canopy].is_dirty =
true;
2900 int2 prev_plant_count_ =
int2(canopy_dict[current_canopy].plant_count);
2901 ImGui::SetNextItemWidth(100);
2902 ImGui::InputInt(
"##plant_count_x", &canopy_dict[current_canopy].plant_count.x);
2903 canopy_dict[current_canopy].plant_count.x = std::max(canopy_dict[current_canopy].plant_count.x, 1);
2904 randomizePopup(
"plant_count_x_" + std::to_string(canopy_dict[current_canopy].idx),
createTaggedPtr(&canopy_dict[current_canopy].plant_count.x));
2905 randomizerParams(
"plant_count_x_" + std::to_string(canopy_dict[current_canopy].idx));
2906 ImGui::OpenPopupOnItemClick((
"randomize_plant_count_x_" + std::to_string(canopy_dict[current_canopy].idx)).c_str(), ImGuiPopupFlags_MouseButtonRight);
2908 ImGui::SetNextItemWidth(100);
2909 ImGui::InputInt(
"##plant_count_y", &canopy_dict[current_canopy].plant_count.y);
2910 canopy_dict[current_canopy].plant_count.y = std::max(canopy_dict[current_canopy].plant_count.y, 1);
2911 randomizePopup(
"plant_count_y_" + std::to_string(canopy_dict[current_canopy].idx),
createTaggedPtr(&canopy_dict[current_canopy].plant_count.y));
2912 randomizerParams(
"plant_count_y_" + std::to_string(canopy_dict[current_canopy].idx));
2913 ImGui::OpenPopupOnItemClick((
"randomize_plant_count_y_" + std::to_string(canopy_dict[current_canopy].idx)).c_str(), ImGuiPopupFlags_MouseButtonRight);
2915 ImGui::Text(
"Plant Count");
2916 if (prev_plant_count_ != canopy_dict[current_canopy].plant_count) {
2917 canopy_dict[current_canopy].is_dirty =
true;
2920 vec2 prev_plant_spacing_ =
vec2(canopy_dict[current_canopy].plant_spacing);
2921 ImGui::SetNextItemWidth(50);
2922 ImGui::InputFloat(
"##plant_spacing_x", &canopy_dict[current_canopy].plant_spacing.x);
2923 randomizePopup(
"plant_spacing_x_" + std::to_string(canopy_dict[current_canopy].idx),
createTaggedPtr(&canopy_dict[current_canopy].plant_spacing.x));
2924 randomizerParams(
"plant_spacing_x_" + std::to_string(canopy_dict[current_canopy].idx));
2925 ImGui::OpenPopupOnItemClick((
"randomize_plant_spacing_x_" + std::to_string(canopy_dict[current_canopy].idx)).c_str(), ImGuiPopupFlags_MouseButtonRight);
2927 ImGui::SetNextItemWidth(50);
2928 ImGui::InputFloat(
"##plant_spacing_y", &canopy_dict[current_canopy].plant_spacing.y);
2929 randomizePopup(
"plant_spacing_y_" + std::to_string(canopy_dict[current_canopy].idx),
createTaggedPtr(&canopy_dict[current_canopy].plant_spacing.y));
2930 randomizerParams(
"plant_spacing_y_" + std::to_string(canopy_dict[current_canopy].idx));
2931 ImGui::OpenPopupOnItemClick((
"randomize_plant_spacing_y_" + std::to_string(canopy_dict[current_canopy].idx)).c_str(), ImGuiPopupFlags_MouseButtonRight);
2933 ImGui::Text(
"Plant Spacing");
2934 if (prev_plant_spacing_ != canopy_dict[current_canopy].plant_spacing) {
2935 canopy_dict[current_canopy].is_dirty =
true;
2938 float prev_age_ = canopy_dict[current_canopy].age;
2939 ImGui::SetNextItemWidth(80);
2940 ImGui::InputFloat(
"Plant Age", &canopy_dict[current_canopy].age);
2941 randomizePopup(
"plant_age_" + std::to_string(canopy_dict[current_canopy].idx),
createTaggedPtr(&canopy_dict[current_canopy].age));
2942 randomizerParams(
"plant_age_" + std::to_string(canopy_dict[current_canopy].idx));
2943 ImGui::OpenPopupOnItemClick((
"randomize_plant_age_" + std::to_string(canopy_dict[current_canopy].idx)).c_str(), ImGuiPopupFlags_MouseButtonRight);
2944 if (prev_age_ != canopy_dict[current_canopy].age) {
2945 canopy_dict[current_canopy].is_dirty =
true;
2948 float prev_ground_clipping_height_ = canopy_dict[current_canopy].ground_clipping_height;
2949 ImGui::SetNextItemWidth(80);
2950 ImGui::InputFloat(
"Ground Clipping Height", &canopy_dict[current_canopy].ground_clipping_height);
2951 randomizePopup(
"ground_clipping_height_" + std::to_string(canopy_dict[current_canopy].idx),
createTaggedPtr(&canopy_dict[current_canopy].ground_clipping_height));
2952 randomizerParams(
"ground_clipping_height_" + std::to_string(canopy_dict[current_canopy].idx));
2953 ImGui::OpenPopupOnItemClick((
"randomize_ground_clipping_height_" + std::to_string(canopy_dict[current_canopy].idx)).c_str(), ImGuiPopupFlags_MouseButtonRight);
2954 if (prev_ground_clipping_height_ != canopy_dict[current_canopy].ground_clipping_height) {
2955 canopy_dict[current_canopy].is_dirty =
true;
2957 if (ImGui::Button(
"Save Canopy to OBJ/PLY File")) {
2959 if (!new_obj_file.empty()) {
2960 std::string file_extension = new_obj_file;
2961 size_t last_obj_file = file_extension.rfind(
'.');
2962 if (last_obj_file != std::string::npos) {
2963 file_extension = file_extension.substr(last_obj_file + 1);
2965 if (file_extension ==
"obj" || file_extension ==
"ply") {
2966 if (!std::filesystem::exists(new_obj_file)) {
2968 std::ofstream outFile(new_obj_file);
2970 if (!save_plants_individually) {
2971 saveCanopy(new_obj_file, canopy_dict[current_canopy].IDs, canopy_dict[current_canopy].origin, file_extension);
2973 saveCanopy(new_obj_file, canopy_dict[current_canopy].IDs, canopy_dict[current_canopy].individual_plant_locations, file_extension);
2977 std::cout <<
"Not a valid file type. Object must be saved to .obj or .ply file." << std::endl;
2981 std::cout <<
"Not a valid file." << std::endl;
2985 ImGui::Checkbox(
"Save plants individually", &save_plants_individually);
2987 ImGui::EndTabItem();
2991#ifdef ENABLE_RADIATION_MODEL
2992 if (enable_radiation) {
2993 if (ImGui::BeginTabItem(
"Radiation")) {
2994 current_tab =
"Radiation";
2996 ImGui::SetNextItemWidth(60);
2997 if (ImGui::Button(
"Load XML Library File")) {
2999 if (!new_xml_library_file.empty() && std::filesystem::exists(new_xml_library_file)) {
3000 if (xml_library_files.find(new_xml_library_file) == xml_library_files.end()) {
3001 xml_library_files.insert(new_xml_library_file);
3002 std::vector<std::string> current_spectra_file =
get_xml_node_values(new_xml_library_file,
"label",
"globaldata_vec2");
3003 for (
int i = 0; i < current_spectra_file.size(); i++) {
3004 possible_spectra.insert(current_spectra_file[i]);
3011 ImGui::SetWindowFontScale(1.25f);
3012 ImGui::Text(
"Global Properties:");
3013 ImGui::SetWindowFontScale(1.0f);
3015 ImGui::Text(
"Enforce Periodic Boundary Condition:");
3017 bool prev_cond_x = enforce_periodic_boundary_x;
3018 ImGui::Checkbox(
"x###periodic_boundary_x", &enforce_periodic_boundary_x);
3020 bool prev_cond_y = enforce_periodic_boundary_y;
3021 ImGui::Checkbox(
"y###periodic_boundary_y", &enforce_periodic_boundary_y);
3022 if (prev_cond_x != enforce_periodic_boundary_x || prev_cond_y != enforce_periodic_boundary_y) {
3023 if (enforce_periodic_boundary_x && enforce_periodic_boundary_y)
3025 else if (enforce_periodic_boundary_x)
3027 else if (enforce_periodic_boundary_y)
3033 ImGui::SetNextItemWidth(60);
3034 float prev_value = diffuse_extinction_coeff;
3035 ImGui::InputFloat(
"Diffuse Extinction Coefficient", &diffuse_extinction_coeff);
3036 if (prev_value != diffuse_extinction_coeff) {
3039 randomizePopup(
"diffuse_extinction_coeff",
createTaggedPtr(&diffuse_extinction_coeff));
3040 randomizerParams(
"diffuse_extinction_coeff");
3041 ImGui::OpenPopupOnItemClick(
"randomize_diffuse_extinction_coeff", ImGuiPopupFlags_MouseButtonRight);
3043 ImGui::SetNextItemWidth(60);
3044 prev_value = air_turbidity;
3045 ImGui::InputFloat(
"Air Turbidity", &air_turbidity);
3046 if (prev_value != air_turbidity) {
3047 if (air_turbidity > 0) {
3049 }
else if (air_turbidity < 0) {
3052 if (air_turbidity > 0 && air_turbidity < 1) {
3059 randomizerParams(
"air_turbidity");
3060 ImGui::OpenPopupOnItemClick(
"randomize_air_turbidity", ImGuiPopupFlags_MouseButtonRight);
3062 ImGui::SetNextItemWidth(250);
3064 if (ImGui::BeginCombo(
"##combo_solar_direct_spectrum", solar_direct_spectrum.c_str())) {
3065 for (
auto &spectra: possible_spectra) {
3066 bool is_solar_direct_spectrum_selected = (solar_direct_spectrum == spectra);
3067 if (ImGui::Selectable(spectra.c_str(), is_solar_direct_spectrum_selected))
3068 solar_direct_spectrum = spectra;
3069 if (is_solar_direct_spectrum_selected)
3070 ImGui::SetItemDefaultFocus();
3075 ImGui::Text(
"Solar Direct Spectrum");
3077 ImGui::SetWindowFontScale(1.25f);
3078 ImGui::Text(
"Add Band:");
3079 ImGui::SetWindowFontScale(1.0f);
3083 if (enable_wavelength) {
3084 ImGui::Text(
"Wavelength Min:");
3086 ImGui::SetNextItemWidth(60);
3087 ImGui::InputFloat(
"##wavelength_min", &wavelength_min);
3089 ImGui::Text(
"Max:");
3091 ImGui::SetNextItemWidth(60);
3092 ImGui::InputFloat(
"##wavelength_max", &wavelength_max);
3094 ImGui::Text(
"No Specified Wavelength");
3097 ImGui::Text(
"Label:");
3099 ImGui::SetNextItemWidth(100);
3100 ImGui::InputText(
"##new_band_label", &new_band_label);
3102 ImGui::Text(
"Emission:");
3104 ImGui::Checkbox(
"##enable_emission", &enable_emission);
3106 if (ImGui::Button(
"Add Band")) {
3107 if (enable_wavelength) {
3108 addBand(new_band_label, wavelength_min, wavelength_max, enable_emission);
3110 addBand(new_band_label, enable_emission);
3111 bandlabels_set_wavelength.insert(new_band_label);
3115 ImGui::SetWindowFontScale(1.25f);
3116 ImGui::Text(
"Band Properties:");
3117 ImGui::SetWindowFontScale(1.0f);
3119 if (ImGui::BeginCombo(
"##combo_current_band", current_band.c_str())) {
3120 for (std::string band: bandlabels_set) {
3121 bool is_current_band_selected = (current_band == band);
3122 if (ImGui::Selectable(band.c_str(), is_current_band_selected))
3123 current_band = band;
3124 if (is_current_band_selected)
3125 ImGui::SetItemDefaultFocus();
3130 ImGui::Text(
"Select Band");
3132 int prev_direct_ray_count;
3133 ImGui::SetNextItemWidth(100);
3134 if (current_band ==
"All") {
3135 prev_direct_ray_count = direct_ray_count;
3136 ImGui::InputInt(
"Direct Ray Count", &direct_ray_count);
3137 randomizePopup(
"direct_ray_count",
createTaggedPtr(&direct_ray_count));
3138 randomizerParams(
"direct_ray_count");
3139 ImGui::OpenPopupOnItemClick(
"randomize_direct_ray_count", ImGuiPopupFlags_MouseButtonRight);
3140 if (direct_ray_count != prev_direct_ray_count) {
3141 for (std::string band: bandlabels) {
3143 direct_ray_count_dict[band] = direct_ray_count;
3147 prev_direct_ray_count = direct_ray_count_dict[current_band];
3148 ImGui::InputInt(
"Direct Ray Count", &direct_ray_count_dict[current_band]);
3149 randomizePopup(
"direct_ray_count_" + current_band,
createTaggedPtr(&direct_ray_count_dict[current_band]));
3150 randomizerParams(
"direct_ray_count_" + current_band);
3151 ImGui::OpenPopupOnItemClick((
"randomize_direct_ray_count_" + current_band).c_str(), ImGuiPopupFlags_MouseButtonRight);
3152 if (direct_ray_count_dict[current_band] != prev_direct_ray_count) {
3157 ImGui::SetNextItemWidth(100);
3158 int prev_diffuse_ray_count;
3159 if (current_band ==
"All") {
3160 prev_diffuse_ray_count = diffuse_ray_count;
3161 ImGui::InputInt(
"Diffuse Ray Count", &diffuse_ray_count);
3162 randomizePopup(
"diffuse_ray_count",
createTaggedPtr(&diffuse_ray_count));
3163 randomizerParams(
"diffuse_ray_count");
3164 ImGui::OpenPopupOnItemClick(
"randomize_diffuse_ray_count", ImGuiPopupFlags_MouseButtonRight);
3165 if (diffuse_ray_count != prev_diffuse_ray_count) {
3166 for (std::string band: bandlabels) {
3168 diffuse_ray_count_dict[band] = diffuse_ray_count;
3172 prev_diffuse_ray_count = diffuse_ray_count_dict[current_band];
3173 ImGui::InputInt(
"Diffuse Ray Count", &diffuse_ray_count_dict[current_band]);
3174 randomizePopup(
"diffuse_ray_count_" + current_band,
createTaggedPtr(&diffuse_ray_count_dict[current_band]));
3175 randomizerParams(
"diffuse_ray_count_" + current_band);
3176 ImGui::OpenPopupOnItemClick((
"randomize_diffuse_ray_count_" + current_band).c_str(), ImGuiPopupFlags_MouseButtonRight);
3177 if (diffuse_ray_count_dict[current_band] != prev_diffuse_ray_count) {
3182 ImGui::SetNextItemWidth(100);
3183 int prev_scattering_depth;
3184 if (current_band ==
"All") {
3185 prev_scattering_depth = scattering_depth;
3186 ImGui::InputInt(
"Scattering Depth", &scattering_depth);
3187 randomizePopup(
"scattering_depth",
createTaggedPtr(&scattering_depth));
3188 randomizerParams(
"scattering_depth");
3189 ImGui::OpenPopupOnItemClick(
"randomize_scattering_depth", ImGuiPopupFlags_MouseButtonRight);
3190 if (scattering_depth <= 0) {
3191 scattering_depth = prev_scattering_depth;
3193 if (prev_scattering_depth != scattering_depth) {
3194 for (std::string band: bandlabels) {
3196 scattering_depth_dict[band] = scattering_depth;
3200 prev_scattering_depth = scattering_depth_dict[current_band];
3201 ImGui::InputInt(
"Scattering Depth", &scattering_depth_dict[current_band]);
3202 randomizePopup(
"scattering_depth_" + current_band,
createTaggedPtr(&scattering_depth_dict[current_band]));
3203 randomizerParams(
"scattering_depth_" + current_band);
3204 ImGui::OpenPopupOnItemClick((
"randomize_scattering_depth_" + current_band).c_str(), ImGuiPopupFlags_MouseButtonRight);
3205 if (scattering_depth_dict[current_band] <= 0) {
3206 scattering_depth_dict[current_band] = prev_scattering_depth;
3208 if (prev_scattering_depth != scattering_depth_dict[current_band]) {
3213 ImGui::SetWindowFontScale(1.25f);
3214 ImGui::Text(
"Radiative Properties:");
3215 ImGui::SetWindowFontScale(1.0f);
3216 ImGui::SetNextItemWidth(100);
3218 if (ImGui::Button(
"Refresh###data_groups_refresh")) {
3219 updatePrimitiveTypes();
3223 ImGui::SetNextItemWidth(150);
3224 if (ImGui::BeginCombo(
"##data_group_primitive", current_data_group.c_str())) {
3225 for (std::string data_group: data_groups_set) {
3226 bool is_data_group_selected = (current_data_group == data_group);
3227 if (ImGui::Selectable(data_group.c_str(), is_data_group_selected))
3228 current_data_group = data_group;
3229 if (is_data_group_selected)
3230 ImGui::SetItemDefaultFocus();
3235 ImGui::SetNextItemWidth(100);
3236 ImGui::Text(
"Select Data Group");
3239 if (ImGui::Button(
"Refresh")) {
3240 updatePrimitiveTypes();
3244 ImGui::SetNextItemWidth(150);
3245 if (ImGui::BeginCombo(
"##combo_primitive", current_primitive.c_str())) {
3246 for (
int m = 0; m < primitive_names.size(); m++) {
3247 bool is_primitive_selected = (current_primitive == primitive_names[m]);
3248 if (ImGui::Selectable(primitive_names[m].c_str(), is_primitive_selected))
3249 current_primitive = primitive_names[m];
3250 if (is_primitive_selected)
3251 ImGui::SetItemDefaultFocus();
3256 ImGui::SetNextItemWidth(100);
3257 ImGui::Text(
"Select Primitive Type");
3258 if (current_data_group ==
"All") {
3260 ImGui::Text(
"Reflectivity:");
3261 std::string toggle_display_reflectivity =
"Manual Entry";
3262 bool reflectivity_continuous = primitive_continuous[current_primitive][0];
3263 toggle_button(
"##reflectivity_toggle", &reflectivity_continuous);
3264 if (reflectivity_continuous != primitive_continuous[current_primitive][0]) {
3265 if (current_primitive ==
"All") {
3266 for (
auto &prim_values: primitive_continuous) {
3267 primitive_continuous[prim_values.first][0] = reflectivity_continuous;
3270 primitive_continuous[current_primitive][0] = reflectivity_continuous;
3272 if (primitive_continuous[current_primitive][0]) {
3273 toggle_display_reflectivity =
"File Entry";
3276 ImGui::SetNextItemWidth(250);
3277 if (!primitive_continuous[current_primitive][0]) {
3278 ImGui::Text(
"Select band:");
3280 ImGui::SetNextItemWidth(60);
3281 if (ImGui::BeginCombo(
"##combo_band_reflectivity", current_band_reflectivity.c_str())) {
3282 for (
int n = 0; n < bandlabels.size(); n++) {
3283 bool is_band_selected = (current_band_reflectivity == bandlabels[n]);
3284 if (ImGui::Selectable(bandlabels[n].c_str(), is_band_selected))
3285 current_band_reflectivity = bandlabels[n];
3286 if (is_band_selected)
3287 ImGui::SetItemDefaultFocus();
3292 ImGui::Text(
"Enter value:");
3294 ImGui::SetNextItemWidth(80);
3295 if (current_primitive ==
"All") {
3296 float prev_reflectivity = reflectivity;
3297 ImGui::InputFloat(
"##reflectivity_all", &reflectivity);
3298 if (reflectivity != prev_reflectivity) {
3299 for (
auto &prim_values: primitive_values[current_band_reflectivity]) {
3300 primitive_values[current_band_reflectivity][prim_values.first][0] = reflectivity;
3304 ImGui::InputFloat(
"##reflectivity", &primitive_values[current_band_reflectivity][current_primitive][0]);
3307 std::string reflectivity_prev = primitive_spectra[current_primitive][0];
3308 if (ImGui::BeginCombo(
"##reflectivity_combo_all", reflectivity_prev.c_str())) {
3309 for (
auto &spectra: possible_spectra) {
3310 bool is_spectra_selected = (primitive_spectra[current_primitive][0] == spectra);
3311 if (ImGui::Selectable(spectra.c_str(), is_spectra_selected))
3312 primitive_spectra[current_primitive][0] = spectra;
3313 if (is_spectra_selected)
3314 ImGui::SetItemDefaultFocus();
3318 if (current_primitive ==
"All" && reflectivity_prev != primitive_spectra[current_primitive][0]) {
3319 for (
auto &prim_spectrum: primitive_spectra) {
3320 primitive_spectra[prim_spectrum.first][0] = primitive_spectra[current_primitive][0];
3325 ImGui::Text(
"%s", toggle_display_reflectivity.c_str());
3327 ImGui::Text(
"Transmissivity:");
3328 std::string toggle_display_transmissivity =
"Manual Entry";
3329 bool transmissivity_continuous = primitive_continuous[current_primitive][1];
3330 toggle_button(
"##transmissivity_toggle", &transmissivity_continuous);
3331 if (transmissivity_continuous != primitive_continuous[current_primitive][1]) {
3332 if (current_primitive ==
"All") {
3333 for (
auto &prim_values: primitive_continuous) {
3334 primitive_continuous[prim_values.first][1] = transmissivity_continuous;
3337 primitive_continuous[current_primitive][1] = transmissivity_continuous;
3339 if (primitive_continuous[current_primitive][1]) {
3340 toggle_display_transmissivity =
"File Entry";
3343 ImGui::SetNextItemWidth(250);
3344 if (!primitive_continuous[current_primitive][1]) {
3345 ImGui::Text(
"Select band:");
3347 ImGui::SetNextItemWidth(60);
3348 if (ImGui::BeginCombo(
"##combo_band_transmissivity", current_band_transmissivity.c_str())) {
3349 for (
int n = 0; n < bandlabels.size(); n++) {
3350 bool is_band_selected = (current_band_transmissivity == bandlabels[n]);
3351 if (ImGui::Selectable(bandlabels[n].c_str(), is_band_selected))
3352 current_band_transmissivity = bandlabels[n];
3353 if (is_band_selected)
3354 ImGui::SetItemDefaultFocus();
3359 ImGui::Text(
"Enter value:");
3361 ImGui::SetNextItemWidth(80);
3362 if (current_primitive ==
"All") {
3363 float prev_transmissivity = transmissivity;
3364 ImGui::InputFloat(
"##transmissivity_all", &transmissivity);
3365 if (transmissivity != prev_transmissivity) {
3366 for (
auto &prim_values: primitive_values[current_band_transmissivity]) {
3367 primitive_values[current_band_transmissivity][prim_values.first][1] = transmissivity;
3371 ImGui::InputFloat(
"##transmissivity", &primitive_values[current_band_transmissivity][current_primitive][1]);
3374 std::string transmissivity_prev = primitive_spectra[current_primitive][1];
3375 if (ImGui::BeginCombo(
"##transmissivity_combo", transmissivity_prev.c_str())) {
3376 for (
auto &spectra: possible_spectra) {
3377 bool is_spectra_selected = (primitive_spectra[current_primitive][1] == spectra);
3378 if (ImGui::Selectable(spectra.c_str(), is_spectra_selected))
3379 primitive_spectra[current_primitive][1] = spectra;
3380 if (is_spectra_selected)
3381 ImGui::SetItemDefaultFocus();
3385 if (current_primitive ==
"All" && transmissivity_prev != primitive_spectra[current_primitive][1]) {
3386 for (
auto &prim_spectrum: primitive_spectra) {
3387 primitive_spectra[prim_spectrum.first][1] = primitive_spectra[current_primitive][1];
3392 ImGui::Text(
"%s", toggle_display_transmissivity.c_str());
3394 ImGui::Text(
"Emissivity:");
3397 ImGui::Dummy(ImVec2(35.f, 0.f));
3399 ImGui::Text(
"Select band:");
3401 ImGui::SetNextItemWidth(60);
3402 if (ImGui::BeginCombo(
"##combo_band_emissivity", current_band_emissivity.c_str())) {
3403 for (std::string band: bandlabels_set_emissivity) {
3404 bool is_band_selected = (current_band_emissivity == band);
3405 if (ImGui::Selectable(band.c_str(), is_band_selected))
3406 current_band_emissivity = band;
3407 if (is_band_selected)
3408 ImGui::SetItemDefaultFocus();
3413 ImGui::Text(
"Enter value:");
3415 ImGui::SetNextItemWidth(80);
3416 if (current_primitive ==
"All") {
3417 float prev_emissivity = emissivity;
3418 ImGui::InputFloat(
"##emissivity_all", &emissivity);
3419 if (emissivity != prev_emissivity) {
3420 for (
auto &prim_values: primitive_values[current_band_emissivity]) {
3421 primitive_values[current_band_emissivity][prim_values.first][2] = emissivity;
3425 ImGui::InputFloat(
"##emissivity", &primitive_values[current_band_emissivity][current_primitive][2]);
3428 ImGui::Text(
"Manual Entry");
3431 ImGui::Text(
"Reflectivity:");
3432 std::string toggle_display_reflectivity =
"Manual Entry";
3433 bool reflectivity_continuous = primitive_continuous_dict[current_data_group][current_primitive][0];
3434 toggle_button(
"##reflectivity_toggle", &reflectivity_continuous);
3435 if (reflectivity_continuous != primitive_continuous_dict[current_data_group][current_primitive][0]) {
3436 if (current_primitive ==
"All") {
3437 for (
auto &prim_values: primitive_continuous_dict[current_data_group]) {
3438 primitive_continuous_dict[current_data_group][prim_values.first][0] = reflectivity_continuous;
3441 primitive_continuous_dict[current_data_group][current_primitive][0] = reflectivity_continuous;
3443 if (primitive_continuous_dict[current_data_group][current_primitive][0]) {
3444 toggle_display_reflectivity =
"File Entry";
3447 ImGui::SetNextItemWidth(250);
3448 if (!primitive_continuous_dict[current_data_group][current_primitive][0]) {
3449 ImGui::Text(
"Select band:");
3451 ImGui::SetNextItemWidth(60);
3452 if (ImGui::BeginCombo(
"##combo_band_reflectivity", current_band_reflectivity.c_str())) {
3453 for (
int n = 0; n < bandlabels.size(); n++) {
3454 bool is_band_selected = (current_band_reflectivity == bandlabels[n]);
3455 if (ImGui::Selectable(bandlabels[n].c_str(), is_band_selected))
3456 current_band_reflectivity = bandlabels[n];
3457 if (is_band_selected)
3458 ImGui::SetItemDefaultFocus();
3463 ImGui::Text(
"Enter value:");
3465 ImGui::SetNextItemWidth(80);
3466 if (current_primitive ==
"All") {
3467 float prev_reflectivity = reflectivity;
3468 ImGui::InputFloat(
"##reflectivity_all", &reflectivity);
3469 if (reflectivity != prev_reflectivity) {
3470 for (
auto &prim_values: primitive_values_dict[current_data_group][current_band_reflectivity]) {
3471 primitive_values_dict[current_data_group][current_band_reflectivity][prim_values.first][0] = reflectivity;
3475 ImGui::InputFloat(
"##reflectivity", &primitive_values_dict[current_data_group][current_band_reflectivity][current_primitive][0]);
3478 std::string reflectivity_prev = primitive_spectra_dict[current_data_group][current_primitive][0];
3479 if (ImGui::BeginCombo(
"##reflectivity_combo", reflectivity_prev.c_str())) {
3480 for (
auto &spectra: possible_spectra) {
3481 bool is_spectra_selected = (primitive_spectra_dict[current_data_group][current_primitive][0] == spectra);
3482 if (ImGui::Selectable(spectra.c_str(), is_spectra_selected))
3483 primitive_spectra_dict[current_data_group][current_primitive][0] = spectra;
3484 if (is_spectra_selected)
3485 ImGui::SetItemDefaultFocus();
3489 if (current_primitive ==
"All" && reflectivity_prev != primitive_spectra_dict[current_data_group][current_primitive][0]) {
3490 for (
auto &prim_spectrum: primitive_spectra_dict[current_data_group]) {
3491 primitive_spectra_dict[current_data_group][prim_spectrum.first][0] = primitive_spectra_dict[current_data_group][current_primitive][0];
3496 ImGui::TextUnformatted(
"%s", toggle_display_reflectivity.c_str());
3498 ImGui::Text(
"Transmissivity:");
3499 std::string toggle_display_transmissivity =
"Manual Entry";
3500 bool transmissivity_continuous = primitive_continuous_dict[current_data_group][current_primitive][1];
3501 toggle_button(
"##transmissivity_toggle", &transmissivity_continuous);
3502 if (transmissivity_continuous != primitive_continuous_dict[current_data_group][current_primitive][1]) {
3503 if (current_primitive ==
"All") {
3504 for (
auto &prim_values: primitive_continuous_dict[current_data_group]) {
3505 primitive_continuous_dict[current_data_group][prim_values.first][1] = transmissivity_continuous;
3508 primitive_continuous_dict[current_data_group][current_primitive][1] = transmissivity_continuous;
3510 if (primitive_continuous_dict[current_data_group][current_primitive][1]) {
3511 toggle_display_transmissivity =
"File Entry";
3514 ImGui::SetNextItemWidth(250);
3515 if (!primitive_continuous_dict[current_data_group][current_primitive][1]) {
3516 ImGui::Text(
"Select band:");
3518 ImGui::SetNextItemWidth(60);
3519 if (ImGui::BeginCombo(
"##combo_band_transmissivity", current_band_transmissivity.c_str())) {
3520 for (
int n = 0; n < bandlabels.size(); n++) {
3521 bool is_band_selected = (current_band_transmissivity == bandlabels[n]);
3522 if (ImGui::Selectable(bandlabels[n].c_str(), is_band_selected))
3523 current_band_transmissivity = bandlabels[n];
3524 if (is_band_selected)
3525 ImGui::SetItemDefaultFocus();
3530 ImGui::Text(
"Enter value:");
3532 ImGui::SetNextItemWidth(80);
3533 if (current_primitive ==
"All") {
3534 float prev_transmissivity = transmissivity;
3535 ImGui::InputFloat(
"##transmissivity_all", &transmissivity);
3536 if (transmissivity != prev_transmissivity) {
3537 for (
auto &prim_values: primitive_values_dict[current_data_group][current_band_transmissivity]) {
3538 primitive_values_dict[current_data_group][current_band_transmissivity][prim_values.first][1] = transmissivity;
3542 ImGui::InputFloat(
"##transmissivity", &primitive_values_dict[current_data_group][current_band_transmissivity][current_primitive][1]);
3545 std::string transmissivity_prev = primitive_spectra_dict[current_data_group][current_primitive][1];
3546 if (ImGui::BeginCombo(
"##transmissivity_combo", transmissivity_prev.c_str())) {
3547 for (
auto &spectra: possible_spectra) {
3548 bool is_spectra_selected = (primitive_spectra_dict[current_data_group][current_primitive][1] == spectra);
3549 if (ImGui::Selectable(spectra.c_str(), is_spectra_selected))
3550 primitive_spectra_dict[current_data_group][current_primitive][1] = spectra;
3551 if (is_spectra_selected)
3552 ImGui::SetItemDefaultFocus();
3556 if (current_primitive ==
"All" && transmissivity_prev != primitive_spectra_dict[current_data_group][current_primitive][1]) {
3557 for (
auto &prim_spectrum: primitive_spectra_dict[current_data_group]) {
3558 primitive_spectra_dict[current_data_group][prim_spectrum.first][1] = primitive_spectra_dict[current_data_group][current_primitive][1];
3563 ImGui::TextUnformatted(
"%s", toggle_display_transmissivity.c_str());
3565 ImGui::Text(
"Emissivity:");
3568 ImGui::Dummy(ImVec2(35.f, 0.f));
3570 ImGui::Text(
"Select band:");
3572 ImGui::SetNextItemWidth(60);
3573 if (ImGui::BeginCombo(
"##combo_band_emissivity", current_band_emissivity.c_str())) {
3574 for (std::string band: bandlabels_set_emissivity) {
3575 bool is_band_selected = (current_band_emissivity == band);
3576 if (ImGui::Selectable(band.c_str(), is_band_selected))
3577 current_band_emissivity = band;
3578 if (is_band_selected)
3579 ImGui::SetItemDefaultFocus();
3584 ImGui::Text(
"Enter value:");
3586 ImGui::SetNextItemWidth(80);
3587 if (current_primitive ==
"All") {
3588 float prev_emissivity = emissivity;
3589 ImGui::InputFloat(
"##emissivity_all", &emissivity);
3590 if (emissivity != prev_emissivity) {
3591 for (
auto &prim_values: primitive_values_dict[current_data_group][current_band_emissivity]) {
3592 primitive_values_dict[current_data_group][current_band_emissivity][prim_values.first][2] = emissivity;
3596 ImGui::InputFloat(
"##emissivity", &primitive_values_dict[current_data_group][current_band_emissivity][current_primitive][2]);
3599 ImGui::Text(
"Manual Entry");
3602 ImGui::EndTabItem();
3606 if (enable_radiation) {
3608 if (ImGui::BeginTabItem(
"Rig")) {
3609 current_tab =
"Rig";
3610 if (ImGui::BeginCombo(
"##rig_combo", current_rig.c_str())) {
3611 for (
auto rig_label: rig_labels_set) {
3612 bool is_rig_selected = (current_rig == rig_label);
3613 if (ImGui::Selectable(rig_label.c_str(), is_rig_selected))
3614 current_rig = rig_label;
3615 current_cam_position =
"0";
3616 if (is_rig_selected)
3617 ImGui::SetItemDefaultFocus();
3622 if (ImGui::Button(
"Add Rig")) {
3623 std::string default_rig_label =
"rig";
3624 std::string new_rig_label =
"rig_0";
3626 while (rig_dict.find(new_rig_label) != rig_dict.end()) {
3628 new_rig_label = default_rig_label +
"_" + std::to_string(count);
3630 rig_dict.insert({new_rig_label, scast<int>(rig_labels.size())});
3631 camera_positions.push_back(camera_position);
3632 camera_lookats.push_back(camera_lookat);
3633 camera_labels.push_back(camera_label);
3634 camera_position_vec.push_back(camera_position_vec[rig_dict[current_rig]]);
3635 camera_lookat_vec.push_back(camera_lookat_vec[rig_dict[current_rig]]);
3636 rig_labels.push_back(new_rig_label);
3637 rig_labels_set.insert(new_rig_label);
3638 rig_camera_labels.push_back(rig_camera_labels[rig_dict[current_rig]]);
3639 rig_light_labels.push_back(rig_light_labels[rig_dict[current_rig]]);
3640 keypoint_frames.push_back(keypoint_frames[rig_dict[current_rig]]);
3641 num_images_vec.push_back(num_images_vec[rig_dict[current_rig]]);
3642 rig_colors.push_back(rig_colors[rig_dict[current_rig]]);
3646 std::string parent =
"rig";
3647 pugi::xml_node rig_block = helios.child(parent.c_str());
3648 pugi::xml_node new_rig_node = helios.append_copy(rig_block);
3649 std::string name =
"label";
3650 pugi::xml_attribute node_label = new_rig_node.attribute(name.c_str());
3651 node_label.set_value(new_rig_label.c_str());
3652 current_rig = new_rig_label;
3654 if (!current_rig.empty()) {
3660 if (ImGui::Button(
"Delete Rig")) {
3664 ImGui::SetNextItemWidth(100);
3665 std::string prev_rig_name = rig_labels[rig_dict[current_rig]];
3666 ImGui::InputText(
"##rig_name", &rig_labels[rig_dict[current_rig]]);
3667 if (rig_labels[rig_dict[current_rig]] != prev_rig_name && rig_dict.find(rig_labels[rig_dict[current_rig]]) == rig_dict.end() && !rig_labels[rig_dict[current_rig]].empty()) {
3668 int temp = rig_dict[current_rig];
3669 current_rig = rig_labels[rig_dict[current_rig]];
3670 std::map<std::string, int>::iterator current_rig_iter = rig_dict.find(prev_rig_name);
3671 if (current_rig_iter != rig_dict.end()) {
3672 rig_dict.erase(current_rig_iter);
3674 rig_dict[current_rig] = temp;
3675 rig_labels_set.erase(prev_rig_name);
3676 rig_labels_set.insert(rig_labels[rig_dict[current_rig]]);
3678 rig_labels[rig_dict[current_rig]] = prev_rig_name;
3681 ImGui::Text(
"Rig Name");
3683 bool write_depth_ = write_depth[rig_dict[current_rig]];
3684 ImGui::Checkbox(
"Write Depth Images", &write_depth_);
3685 write_depth[rig_dict[current_rig]] = write_depth_;
3687 bool write_norm_depth_ = write_norm_depth[rig_dict[current_rig]];
3688 ImGui::Checkbox(
"Write Norm Depth Images", &write_norm_depth_);
3689 write_norm_depth[rig_dict[current_rig]] = write_norm_depth_;
3691 if (ImGui::BeginPopup(
"multi_select_popup")) {
3692 for (
auto &box_pair: bounding_boxes) {
3693 ImGui::Selectable(box_pair.first.c_str(), &box_pair.second, ImGuiSelectableFlags_DontClosePopups);
3697 if (ImGui::Button(
"Select Bounding Box Objects")) {
3698 ImGui::OpenPopup(
"multi_select_popup");
3702 ImGui::Text(
"Objects:");
3704 for (
auto &box_pair: bounding_boxes) {
3705 if (box_pair.second) {
3706 ImGui::SameLine(), ImGui::Text(
"%i. %s", idx, box_pair.first.c_str());
3712 col[0] = rig_colors[rig_dict[current_rig]].r;
3713 col[1] = rig_colors[rig_dict[current_rig]].g;
3714 col[2] = rig_colors[rig_dict[current_rig]].b;
3715 ImGui::ColorEdit3(
"##rig_color_edit", col);
3718 ImGui::Text(
"Rig Color");
3739 ImGui::Text(
"Cameras:");
3740 for (
int i = 0; i < camera_names.size(); i++) {
3741 std::string &camera_name = camera_names[i];
3743 ImGui::SetNextItemWidth(60);
3745 std::set curr_set = rig_camera_labels[rig_dict[current_rig]];
3749 bool isCameraSelected = curr_set.find(camera_name) != curr_set.end();
3751 if (ImGui::Checkbox(camera_name.c_str(), &isCameraSelected)) {
3752 if (isCameraSelected) {
3753 rig_camera_labels[rig_dict[current_rig]].insert(camera_name);
3755 rig_camera_labels[rig_dict[current_rig]].erase(camera_name);
3761 ImGui::Text(
"Lights:");
3762 for (
int i = 0; i < light_names.size(); i++) {
3763 std::string &light_name = light_names[i];
3765 ImGui::SetNextItemWidth(60);
3767 std::set curr_rig_light = rig_light_labels[rig_dict[current_rig]];
3768 bool isLightSelected = curr_rig_light.find(light_name) != curr_rig_light.end();
3770 if (ImGui::Checkbox(light_name.c_str(), &isLightSelected)) {
3771 if (isLightSelected) {
3772 rig_light_labels[rig_dict[current_rig]].insert(light_name);
3774 rig_light_labels[rig_dict[current_rig]].erase(light_name);
3780 std::stringstream cam_pos_value;
3781 cam_pos_value << current_cam_position.c_str();
3782 int current_cam_position_;
3783 cam_pos_value >> current_cam_position_;
3784 current_keypoint = std::to_string(keypoint_frames[rig_dict[current_rig]][current_cam_position_]);
3785 std::string modified_current_keypoint = std::to_string(keypoint_frames[rig_dict[current_rig]][current_cam_position_] + 1);
3786 if (ImGui::BeginCombo(
"##cam_combo", modified_current_keypoint.c_str())) {
3787 for (
int n = 1; n <= camera_position_vec[rig_dict[current_rig]].size(); n++) {
3788 std::string select_cam_position = std::to_string(n - 1);
3789 std::string selected_keypoint = std::to_string(keypoint_frames[rig_dict[current_rig]][n - 1]);
3790 bool is_pos_selected = (current_cam_position == select_cam_position);
3791 std::string modified_selected_keypoint = std::to_string(keypoint_frames[rig_dict[current_rig]][n - 1] + 1);
3792 if (ImGui::Selectable(modified_selected_keypoint.c_str(), is_pos_selected)) {
3793 current_cam_position = std::to_string(n - 1);
3795 if (is_pos_selected)
3796 ImGui::SetItemDefaultFocus();
3800 cam_pos_value << current_cam_position.c_str();
3801 cam_pos_value >> current_cam_position_;
3803 if (ImGui::Button(
"Add Keypoint")) {
3804 camera_position_vec[rig_dict[current_rig]].push_back(camera_position_vec[rig_dict[current_rig]][current_cam_position_]);
3805 camera_lookat_vec[rig_dict[current_rig]].push_back(camera_lookat_vec[rig_dict[current_rig]][current_cam_position_]);
3806 keypoint_frames[rig_dict[current_rig]].push_back(keypoint_frames[rig_dict[current_rig]].back() + 1);
3810 ImGui::SetNextItemWidth(80);
3811 int modified_keypoint_frame = keypoint_frames[rig_dict[current_rig]][current_cam_position_] + 1;
3812 ImGui::InputInt(
"Keypoint Frame", &modified_keypoint_frame);
3813 if (modified_keypoint_frame != keypoint_frames[rig_dict[current_rig]][current_cam_position_] + 1) {
3814 keypoint_frames[rig_dict[current_rig]][current_cam_position_] = modified_keypoint_frame - 1;
3817 vec3 prev_rig_position_ = camera_position_vec[rig_dict[current_rig]][current_cam_position_];
3818 ImGui::SetNextItemWidth(60);
3819 ImGui::InputFloat(
"##camera_position_x", &camera_position_vec[rig_dict[current_rig]][current_cam_position_].x);
3820 randomizePopup(
"camera_position_x_" + std::to_string(rig_dict[current_rig]) + std::to_string(current_cam_position_),
createTaggedPtr(&camera_position_vec[rig_dict[current_rig]][current_cam_position_].x));
3821 randomizerParams(
"camera_position_x_" + std::to_string(rig_dict[current_rig]) + std::to_string(current_cam_position_));
3822 ImGui::OpenPopupOnItemClick((
"randomize_camera_position_x_" + std::to_string(rig_dict[current_rig]) + std::to_string(current_cam_position_)).c_str(), ImGuiPopupFlags_MouseButtonRight);
3824 ImGui::SetNextItemWidth(60);
3825 ImGui::InputFloat(
"##camera_position_y", &camera_position_vec[rig_dict[current_rig]][current_cam_position_].y);
3826 randomizePopup(
"camera_position_y_" + std::to_string(rig_dict[current_rig]) + std::to_string(current_cam_position_),
createTaggedPtr(&camera_position_vec[rig_dict[current_rig]][current_cam_position_].y));
3827 randomizerParams(
"camera_position_y_" + std::to_string(rig_dict[current_rig]) + std::to_string(current_cam_position_));
3828 ImGui::OpenPopupOnItemClick((
"randomize_camera_position_y_" + std::to_string(rig_dict[current_rig]) + std::to_string(current_cam_position_)).c_str(), ImGuiPopupFlags_MouseButtonRight);
3830 ImGui::SetNextItemWidth(60);
3831 ImGui::InputFloat(
"##camera_position_z", &camera_position_vec[rig_dict[current_rig]][current_cam_position_].z);
3832 randomizePopup(
"camera_position_z_" + std::to_string(rig_dict[current_rig]) + std::to_string(current_cam_position_),
createTaggedPtr(&camera_position_vec[rig_dict[current_rig]][current_cam_position_].z));
3833 randomizerParams(
"camera_position_z_" + std::to_string(rig_dict[current_rig]) + std::to_string(current_cam_position_));
3834 ImGui::OpenPopupOnItemClick((
"randomize_camera_position_z_" + std::to_string(rig_dict[current_rig]) + std::to_string(current_cam_position_)).c_str(), ImGuiPopupFlags_MouseButtonRight);
3836 ImGui::Text(
"Rig Position");
3838 ImGui::Button(
"Add Noise###position");
3839 noisePopup(
"rig_position_noise_" + std::to_string(rig_dict[current_rig]), rig_lookat_noise[rig_dict[current_rig]]);
3840 ImGui::OpenPopupOnItemClick((
"rig_position_noise_" + std::to_string(rig_dict[current_rig])).c_str(), ImGuiPopupFlags_MouseButtonLeft);
3842 vec3 prev_rig_lookat_ = camera_lookat_vec[rig_dict[current_rig]][current_cam_position_];
3843 ImGui::SetNextItemWidth(60);
3844 ImGui::InputFloat(
"##camera_lookat_x", &camera_lookat_vec[rig_dict[current_rig]][current_cam_position_].x);
3845 randomizePopup(
"camera_lookat_x_" + std::to_string(rig_dict[current_rig]) + std::to_string(current_cam_position_),
createTaggedPtr(&camera_lookat_vec[rig_dict[current_rig]][current_cam_position_].x));
3846 randomizerParams(
"camera_lookat_x_" + std::to_string(rig_dict[current_rig]) + std::to_string(current_cam_position_));
3847 ImGui::OpenPopupOnItemClick((
"randomize_camera_lookat_x_" + std::to_string(rig_dict[current_rig]) + std::to_string(current_cam_position_)).c_str(), ImGuiPopupFlags_MouseButtonRight);
3849 ImGui::SetNextItemWidth(60);
3850 ImGui::InputFloat(
"##camera_lookat_y", &camera_lookat_vec[rig_dict[current_rig]][current_cam_position_].y);
3851 randomizePopup(
"camera_lookat_y_" + std::to_string(rig_dict[current_rig]) + std::to_string(current_cam_position_),
createTaggedPtr(&camera_lookat_vec[rig_dict[current_rig]][current_cam_position_].y));
3852 randomizerParams(
"camera_lookat_y_" + std::to_string(rig_dict[current_rig]) + std::to_string(current_cam_position_));
3853 ImGui::OpenPopupOnItemClick((
"randomize_camera_lookat_y_" + std::to_string(rig_dict[current_rig]) + std::to_string(current_cam_position_)).c_str(), ImGuiPopupFlags_MouseButtonRight);
3855 ImGui::SetNextItemWidth(60);
3856 ImGui::InputFloat(
"##camera_lookat_z", &camera_lookat_vec[rig_dict[current_rig]][current_cam_position_].z);
3857 randomizePopup(
"camera_lookat_z_" + std::to_string(rig_dict[current_rig]) + std::to_string(current_cam_position_),
createTaggedPtr(&camera_lookat_vec[rig_dict[current_rig]][current_cam_position_].z));
3858 randomizerParams(
"camera_lookat_z_" + std::to_string(rig_dict[current_rig]) + std::to_string(current_cam_position_));
3859 ImGui::OpenPopupOnItemClick((
"randomize_camera_lookat_z_" + std::to_string(rig_dict[current_rig]) + std::to_string(current_cam_position_)).c_str(), ImGuiPopupFlags_MouseButtonRight);
3861 ImGui::Text(
"Rig Lookat");
3863 ImGui::Button(
"Add Noise###lookat");
3864 noisePopup(
"rig_lookat_noise_" + std::to_string(rig_dict[current_rig]), rig_lookat_noise[rig_dict[current_rig]]);
3865 ImGui::OpenPopupOnItemClick((
"rig_lookat_noise_" + std::to_string(rig_dict[current_rig])).c_str(), ImGuiPopupFlags_MouseButtonLeft);
3867 ImGui::SetNextItemWidth(80);
3868 ImGui::InputInt(
"Total Number of Frames", &num_images_vec[rig_dict[current_rig]]);
3869 num_images_vec[rig_dict[current_rig]] = std::max(num_images_vec[rig_dict[current_rig]], *std::max_element(keypoint_frames[rig_dict[current_rig]].begin(), keypoint_frames[rig_dict[(std::string) current_rig]].end()) + 1);
3871 if (prev_rig_position_ != camera_position_vec[rig_dict[current_rig]][current_cam_position_] || prev_rig_lookat_ != camera_lookat_vec[rig_dict[current_rig]][current_cam_position_]) {
3875 ImGui::EndTabItem();
3878 if (ImGui::BeginTabItem(
"Camera")) {
3879 current_tab =
"Camera";
3881 ImGui::SetNextItemWidth(60);
3882 if (ImGui::Button(
"Load XML Library File")) {
3884 if (!new_xml_library_file.empty() && std::filesystem::exists(new_xml_library_file)) {
3885 if (camera_xml_library_files.find(new_xml_library_file) == camera_xml_library_files.end()) {
3886 camera_xml_library_files.insert(new_xml_library_file);
3887 std::vector<std::string> current_camera_file =
get_xml_node_values(new_xml_library_file,
"label",
"globaldata_vec2");
3888 possible_camera_calibrations.insert(possible_camera_calibrations.end(), current_camera_file.begin(), current_camera_file.end());
3895 ImGui::SetWindowFontScale(1.25f);
3896 ImGui::Text(
"Band Groups:");
3897 ImGui::SetWindowFontScale(1.0f);
3898 dropDown(
"##band_group_combo", current_band_group, band_group_names);
3900 if (ImGui::Button(
"Add Band Group")) {
3901 std::string default_band_group_label =
"band_group";
3902 std::string new_band_group_label =
"band_group_0";
3904 while (band_group_lookup.find(new_band_group_label) != band_group_lookup.end()) {
3906 new_band_group_label = default_band_group_label +
"_" + std::to_string(count);
3908 std::vector<std::string> new_band_group_vector;
3909 new_band_group_vector.push_back(
"red");
3910 new_band_group_vector.push_back(
"green");
3911 new_band_group_vector.push_back(
"blue");
3912 bandGroup new_band_group{new_band_group_vector,
false,
false};
3913 band_group_lookup[new_band_group_label] = new_band_group;
3914 band_group_names.insert(new_band_group_label);
3915 current_band_group = new_band_group_label;
3917 if (!current_band_group.empty()) {
3918 ImGui::SetNextItemWidth(100);
3919 std::string prev_group_name = current_band_group;
3920 ImGui::InputText(
"Group Name", ¤t_band_group);
3921 if (current_band_group.empty() || band_group_lookup.find(current_band_group) != band_group_lookup.end()) {
3922 current_band_group = prev_group_name;
3924 if (current_band_group != prev_group_name) {
3925 bandGroup temp = band_group_lookup[prev_group_name];
3926 std::map<std::string, bandGroup>::iterator current_band_group_iter = band_group_lookup.find(prev_group_name);
3927 if (current_band_group_iter != band_group_lookup.end()) {
3928 band_group_lookup.erase(current_band_group_iter);
3930 band_group_lookup[current_band_group] = temp;
3931 band_group_names.erase(prev_group_name);
3932 band_group_names.insert(current_band_group);
3935 if (ImGui::Button(
"Delete Group")) {
3936 band_group_names.erase(current_band_group);
3937 band_group_lookup.erase(current_band_group);
3938 current_band_group =
"";
3940 ImGui::Checkbox(
"Grayscale", &band_group_lookup[current_band_group].grayscale);
3942 ImGui::Checkbox(
"Norm", &band_group_lookup[current_band_group].norm);
3944 ImGui::SetNextItemWidth(100);
3945 dropDown(
"##band_1_combo", band_group_lookup[current_band_group].bands[0], bandlabels);
3946 if (!band_group_lookup[current_band_group].grayscale) {
3949 ImGui::SetNextItemWidth(100);
3950 dropDown(
"##band_2_combo", band_group_lookup[current_band_group].bands[1], bandlabels);
3953 ImGui::SetNextItemWidth(100);
3954 dropDown(
"##band_3_combo", band_group_lookup[current_band_group].bands[2], bandlabels);
3956 ImGui::Text(
"Select Bands");
3959 ImGui::Text(
"Select Band");
3962 ImGui::SetWindowFontScale(1.25f);
3963 ImGui::Text(
"Edit Camera:");
3964 ImGui::SetWindowFontScale(1.0f);
3965 if (ImGui::BeginCombo(
"##camera_combo", current_cam.c_str())) {
3966 for (
int n = 0; n < camera_names.size(); n++) {
3967 bool is_cam_selected = (current_cam == camera_names[n]);
3968 if (ImGui::Selectable(camera_names[n].c_str(), is_cam_selected))
3969 current_cam = camera_names[n];
3970 if (is_cam_selected)
3971 ImGui::SetItemDefaultFocus();
3976 if (ImGui::Button(
"Add New Camera")) {
3977 std::string default_cam_name =
"camera";
3978 std::string new_cam_name =
"camera_0";
3980 while (camera_dict.find(new_cam_name) != camera_dict.end()) {
3982 new_cam_name = default_cam_name +
"_" + std::to_string(count);
3984 camera_dict.insert({new_cam_name, scast<int>(camera_names.size())});
3985 camera_resolutions.push_back(camera_resolution);
3986 camera_calibrations.push_back(camera_calibrations[camera_dict[current_cam]]);
3987 focal_plane_distances.push_back(focal_plane_distance);
3988 lens_diameters.push_back(lens_diameter);
3989 FOV_aspect_ratios.push_back(FOV_aspect_ratio);
3990 HFOVs.push_back(HFOV);
3991 camera_names.push_back(new_cam_name);
3992 std::string parent =
"camera";
3993 pugi::xml_node camera_block = helios.child(parent.c_str());
3994 pugi::xml_node new_cam_node = helios.append_copy(camera_block);
3995 std::string name =
"label";
3996 pugi::xml_attribute node_label = new_cam_node.attribute(name.c_str());
3997 node_label.set_value(new_cam_name.c_str());
3998 current_cam = new_cam_name;
4000 ImGui::SetNextItemWidth(100);
4001 std::string prev_cam_name = camera_names[camera_dict[current_cam]];
4002 ImGui::InputText(
"##cam_name", &camera_names[camera_dict[current_cam]]);
4003 if (camera_names[camera_dict[current_cam]] != prev_cam_name) {
4004 int temp = camera_dict[current_cam];
4005 current_cam = camera_names[camera_dict[current_cam]];
4006 std::map<std::string, int>::iterator current_cam_iter = camera_dict.find(prev_cam_name);
4007 if (current_cam_iter != camera_dict.end()) {
4008 camera_dict.erase(current_cam_iter);
4010 camera_dict[current_cam] = temp;
4013 ImGui::Text(
"Camera Label");
4015 ImGui::SetNextItemWidth(100);
4016 dropDown(
"##camera_calibration_band", current_calibration_band, bandlabels);
4018 ImGui::Text(
"Band");
4019 ImGui::SetNextItemWidth(250);
4021 dropDown(
"##camera_band_group_combo", camera_calibrations[camera_dict[current_cam]][current_calibration_band], possible_camera_calibrations);
4023 ImGui::Text(
"Calibration");
4039 ImGui::SetNextItemWidth(90);
4040 ImGui::InputInt(
"##camera_resolution_x", &camera_resolutions[camera_dict[current_cam]].x);
4041 randomizePopup(
"camera_resolution_x_" + std::to_string(camera_dict[current_cam]),
createTaggedPtr(&camera_resolutions[camera_dict[current_cam]].x));
4042 randomizerParams(
"camera_resolution_x_" + std::to_string(camera_dict[current_cam]));
4043 ImGui::OpenPopupOnItemClick((
"randomize_camera_resolution_x_" + std::to_string(camera_dict[current_cam])).c_str(), ImGuiPopupFlags_MouseButtonRight);
4045 ImGui::SetNextItemWidth(90);
4046 ImGui::InputInt(
"##camera_resolution_y", &camera_resolutions[camera_dict[current_cam]].y);
4047 randomizePopup(
"camera_resolution_y_" + std::to_string(camera_dict[current_cam]),
createTaggedPtr(&camera_resolutions[camera_dict[current_cam]].y));
4048 randomizerParams(
"camera_resolution_y_" + std::to_string(camera_dict[current_cam]));
4049 ImGui::OpenPopupOnItemClick((
"randomize_camera_resolution_y_" + std::to_string(camera_dict[current_cam])).c_str(), ImGuiPopupFlags_MouseButtonRight);
4051 ImGui::Text(
"Camera Resolution");
4053 ImGui::SetNextItemWidth(50);
4054 ImGui::InputFloat(
"Focal Plane Distance", &focal_plane_distances[camera_dict[current_cam]]);
4055 randomizePopup(
"focal_plane_distance_" + std::to_string(camera_dict[current_cam]),
createTaggedPtr(&focal_plane_distances[camera_dict[current_cam]]));
4056 randomizerParams(
"focal_plane_distance_" + std::to_string(camera_dict[current_cam]));
4057 ImGui::OpenPopupOnItemClick((
"randomize_focal_plane_distance_" + std::to_string(camera_dict[current_cam])).c_str(), ImGuiPopupFlags_MouseButtonRight);
4059 ImGui::SetNextItemWidth(50);
4060 ImGui::InputFloat(
"Lens Diameter", &lens_diameters[camera_dict[current_cam]]);
4061 randomizePopup(
"lens_diameter_" + std::to_string(camera_dict[current_cam]),
createTaggedPtr(&lens_diameters[camera_dict[current_cam]]));
4062 randomizerParams(
"lens_diameter_" + std::to_string(camera_dict[current_cam]));
4063 ImGui::OpenPopupOnItemClick((
"randomize_lens_diameter_" + std::to_string(camera_dict[current_cam])).c_str(), ImGuiPopupFlags_MouseButtonRight);
4065 ImGui::SetNextItemWidth(50);
4066 ImGui::InputFloat(
"FOV Aspect Ratio", &FOV_aspect_ratios[camera_dict[current_cam]]);
4067 randomizePopup(
"FOV_aspect_ratio_" + std::to_string(camera_dict[current_cam]),
createTaggedPtr(&FOV_aspect_ratios[camera_dict[current_cam]]));
4068 randomizerParams(
"FOV_aspect_ratio_" + std::to_string(camera_dict[current_cam]));
4069 ImGui::OpenPopupOnItemClick((
"randomize_FOV_aspect_ratio_" + std::to_string(camera_dict[current_cam])).c_str(), ImGuiPopupFlags_MouseButtonRight);
4071 ImGui::SetNextItemWidth(50);
4072 ImGui::InputFloat(
"HFOV", &HFOVs[camera_dict[current_cam]]);
4073 randomizePopup(
"HFOV_" + std::to_string(camera_dict[current_cam]),
createTaggedPtr(&HFOVs[camera_dict[current_cam]]));
4074 randomizerParams(
"HFOV_" + std::to_string(camera_dict[current_cam]));
4075 ImGui::OpenPopupOnItemClick((
"HFOV_" + std::to_string(camera_dict[current_cam])).c_str(), ImGuiPopupFlags_MouseButtonRight);
4077 ImGui::EndTabItem();
4080 if (ImGui::BeginTabItem(
"Light")) {
4081 current_tab =
"Light";
4083 ImGui::SetNextItemWidth(60);
4084 if (ImGui::Button(
"Load XML Library File")) {
4086 if (!new_xml_library_file.empty() && std::filesystem::exists(new_xml_library_file)) {
4087 if (light_xml_library_files.find(new_xml_library_file) == light_xml_library_files.end()) {
4088 light_xml_library_files.insert(new_xml_library_file);
4089 std::vector<std::string> current_light_file =
get_xml_node_values(new_xml_library_file,
"label",
"globaldata_vec2");
4090 possible_light_spectra.insert(possible_light_spectra.end(), current_light_file.begin(), current_light_file.end());
4095 if (ImGui::BeginCombo(
"##light_combo", current_light.c_str())) {
4096 for (
int n = 0; n < light_names.size(); n++) {
4097 bool is_light_selected = (current_light == light_names[n]);
4098 if (ImGui::Selectable(light_names[n].c_str(), is_light_selected))
4099 current_light = light_names[n];
4100 if (is_light_selected)
4101 ImGui::SetItemDefaultFocus();
4106 if (ImGui::Button(
"Add Light")) {
4107 std::string default_light_name =
"light";
4108 std::string new_light_name =
"light_0";
4110 while (light_dict.find(new_light_name) != light_dict.end()) {
4112 new_light_name = default_light_name +
"_" + std::to_string(count);
4114 light_dict.insert({new_light_name, scast<int>(light_names.size())});
4115 light_spectra.push_back(light_spectra[light_dict[current_light]]);
4116 light_types.push_back(light_types[light_dict[current_light]]);
4117 light_direction_vec.push_back(light_direction_vec[light_dict[current_light]]);
4118 light_direction_sph_vec.push_back(light_direction_sph_vec[light_dict[current_light]]);
4119 light_rotation_vec.push_back(light_rotation_vec[light_dict[current_light]]);
4120 light_size_vec.push_back(light_size_vec[light_dict[current_light]]);
4121 light_radius_vec.push_back(light_radius_vec[light_dict[current_light]]);
4122 light_names.push_back(new_light_name);
4123 light_flux_vec.push_back(light_flux_vec[light_dict[current_light]]);
4124 std::string parent =
"light";
4125 pugi::xml_node light_block = helios.child(parent.c_str());
4126 pugi::xml_node new_light_node = helios.append_copy(light_block);
4127 std::string name =
"label";
4128 pugi::xml_attribute node_label = new_light_node.attribute(name.c_str());
4129 node_label.set_value(new_light_name.c_str());
4130 current_light = new_light_name;
4132 ImGui::SetNextItemWidth(100);
4133 std::string prev_light_name = light_names[light_dict[current_light]];
4134 ImGui::InputText(
"##light_name", &light_names[light_dict[current_light]]);
4135 if (light_names[light_dict[current_light]] != prev_light_name) {
4136 int temp = light_dict[current_light];
4137 current_light = light_names[light_dict[current_light]];
4138 std::map<std::string, int>::iterator current_light_iter = light_dict.find(prev_light_name);
4139 if (current_light_iter != light_dict.end()) {
4140 light_dict.erase(current_light_iter);
4142 light_dict[current_light] = temp;
4145 ImGui::Text(
"Light Label");
4147 std::string prev_light_spectra = light_spectra[light_dict[current_light]];
4148 if (ImGui::BeginCombo(
"##light_spectra_combo", light_spectra[light_dict[current_light]].c_str())) {
4149 for (
int n = 0; n < possible_light_spectra.size(); n++) {
4150 bool is_light_spectra_selected = (light_spectra[light_dict[current_light]] == possible_light_spectra[n]);
4151 if (ImGui::Selectable(possible_light_spectra[n].c_str(), is_light_spectra_selected))
4152 light_spectra[light_dict[current_light]] = possible_light_spectra[n];
4153 if (is_light_spectra_selected)
4154 ImGui::SetItemDefaultFocus();
4159 ImGui::Text(
"Light Spectrum");
4161 if (ImGui::BeginCombo(
"##light_type_combo", light_types[light_dict[current_light]].c_str())) {
4162 for (
int n = 0; n < all_light_types.size(); n++) {
4163 bool is_type_selected = (light_types[light_dict[current_light]] == all_light_types[n]);
4164 if (ImGui::Selectable(all_light_types[n].c_str(), is_type_selected)) {
4165 light_types[light_dict[current_light]] = all_light_types[n];
4167 if (is_type_selected)
4168 ImGui::SetItemDefaultFocus();
4173 ImGui::Text(
"Light Type");
4180 if (light_types[light_dict[(std::string) current_light]] ==
"collimated" || light_types[light_dict[(std::string) current_light]] ==
"sunsphere") {
4181 ImGui::SetNextItemWidth(90);
4182 ImGui::InputFloat(
"##light_direction_x", &light_direction_vec[light_dict[current_light]].x);
4183 randomizePopup(
"light_direction_x_" + std::to_string(light_dict[current_light]),
createTaggedPtr(&light_direction_vec[light_dict[current_light]].x));
4184 randomizerParams(
"light_direction_x_" + std::to_string(light_dict[current_light]));
4185 ImGui::OpenPopupOnItemClick((
"light_direction_x_" + std::to_string(light_dict[current_light])).c_str(), ImGuiPopupFlags_MouseButtonRight);
4187 ImGui::SetNextItemWidth(90);
4188 ImGui::InputFloat(
"##light_direction_y", &light_direction_vec[light_dict[current_light]].y);
4189 randomizePopup(
"light_direction_y_" + std::to_string(light_dict[current_light]),
createTaggedPtr(&light_direction_vec[light_dict[current_light]].y));
4190 randomizerParams(
"light_direction_y_" + std::to_string(light_dict[current_light]));
4191 ImGui::OpenPopupOnItemClick((
"light_direction_y_" + std::to_string(light_dict[current_light])).c_str(), ImGuiPopupFlags_MouseButtonRight);
4193 ImGui::SetNextItemWidth(90);
4194 ImGui::InputFloat(
"##light_direction_z", &light_direction_vec[light_dict[current_light]].z);
4195 randomizePopup(
"light_direction_z_" + std::to_string(light_dict[current_light]),
createTaggedPtr(&light_direction_vec[light_dict[current_light]].z));
4196 randomizerParams(
"light_direction_z_" + std::to_string(light_dict[current_light]));
4197 ImGui::OpenPopupOnItemClick((
"light_direction_z_" + std::to_string(light_dict[current_light])).c_str(), ImGuiPopupFlags_MouseButtonRight);
4199 ImGui::Text(
"Light Direction");
4202 ImGui::SetNextItemWidth(90);
4203 ImGui::InputFloat(
"##source_flux", &light_flux_vec[light_dict[current_light]]);
4204 randomizePopup(
"source_flux_" + std::to_string(light_dict[current_light]),
createTaggedPtr(&light_flux_vec[light_dict[current_light]]));
4205 randomizerParams(
"source_flux_" + std::to_string(light_dict[current_light]));
4206 ImGui::OpenPopupOnItemClick((
"source_flux_" + std::to_string(light_dict[current_light])).c_str(), ImGuiPopupFlags_MouseButtonRight);
4208 ImGui::Text(
"Source Flux");
4211 if (light_types[light_dict[current_light]] ==
"disk" || light_types[light_dict[current_light]] ==
"rectangle") {
4212 ImGui::SetNextItemWidth(90);
4213 ImGui::InputFloat(
"##light_rotation_x", &light_rotation_vec[light_dict[current_light]].x);
4214 randomizePopup(
"light_rotation_x_" + std::to_string(light_dict[current_light]),
createTaggedPtr(&light_rotation_vec[light_dict[current_light]].x));
4215 randomizerParams(
"light_rotation_x_" + std::to_string(light_dict[current_light]));
4216 ImGui::OpenPopupOnItemClick((
"light_rotation_x_" + std::to_string(light_dict[current_light])).c_str(), ImGuiPopupFlags_MouseButtonRight);
4218 ImGui::SetNextItemWidth(90);
4219 ImGui::InputFloat(
"##light_rotation_y", &light_rotation_vec[light_dict[current_light]].y);
4220 randomizePopup(
"light_rotation_y_" + std::to_string(light_dict[current_light]),
createTaggedPtr(&light_rotation_vec[light_dict[current_light]].y));
4221 randomizerParams(
"light_rotation_y_" + std::to_string(light_dict[current_light]));
4222 ImGui::OpenPopupOnItemClick((
"light_rotation_y_" + std::to_string(light_dict[current_light])).c_str(), ImGuiPopupFlags_MouseButtonRight);
4224 ImGui::SetNextItemWidth(90);
4225 ImGui::InputFloat(
"##light_rotation_z", &light_rotation_vec[light_dict[current_light]].z);
4226 randomizePopup(
"light_rotation_z_" + std::to_string(light_dict[current_light]),
createTaggedPtr(&light_rotation_vec[light_dict[current_light]].z));
4227 randomizerParams(
"light_rotation_z_" + std::to_string(light_dict[current_light]));
4228 ImGui::OpenPopupOnItemClick((
"light_rotation_z_" + std::to_string(light_dict[current_light])).c_str(), ImGuiPopupFlags_MouseButtonRight);
4230 ImGui::Text(
"Light Rotation");
4233 if (light_types[light_dict[current_light]] ==
"rectangle") {
4234 ImGui::SetNextItemWidth(90);
4235 ImGui::InputFloat(
"##light_size_x", &light_size_vec[light_dict[current_light]].x);
4236 randomizePopup(
"light_size_x_" + std::to_string(light_dict[current_light]),
createTaggedPtr(&light_size_vec[light_dict[current_light]].x));
4237 randomizerParams(
"light_size_x_" + std::to_string(light_dict[current_light]));
4238 ImGui::OpenPopupOnItemClick((
"light_size_x_" + std::to_string(light_dict[current_light])).c_str(), ImGuiPopupFlags_MouseButtonRight);
4240 ImGui::SetNextItemWidth(90);
4241 ImGui::InputFloat(
"##light_size_y", &light_size_vec[light_dict[current_light]].y);
4242 randomizePopup(
"light_size_y_" + std::to_string(light_dict[current_light]),
createTaggedPtr(&light_size_vec[light_dict[current_light]].y));
4243 randomizerParams(
"light_size_y_" + std::to_string(light_dict[current_light]));
4244 ImGui::OpenPopupOnItemClick((
"light_size_y_" + std::to_string(light_dict[current_light])).c_str(), ImGuiPopupFlags_MouseButtonRight);
4246 ImGui::Text(
"Light Size");
4249 if (light_types[light_dict[current_light]] ==
"disk" || light_types[light_dict[current_light]] ==
"sphere") {
4250 ImGui::SetNextItemWidth(90);
4251 ImGui::InputFloat(
"##light_radius", &light_radius_vec[light_dict[current_light]]);
4252 randomizePopup(
"light_radius_" + std::to_string(light_dict[current_light]),
createTaggedPtr(&light_radius_vec[light_dict[current_light]]));
4253 randomizerParams(
"light_radius_" + std::to_string(light_dict[current_light]));
4254 ImGui::OpenPopupOnItemClick((
"light_radius_" + std::to_string(light_dict[current_light])).c_str(), ImGuiPopupFlags_MouseButtonRight);
4256 ImGui::Text(
"Light Radius");
4259 ImGui::EndTabItem();
4268 last_position = current_position;
4269 previously_collapsed = currently_collapsed;
4272 if (is_dirty && !ImGui::IsMouseDragging(ImGuiMouseButton_Left) && !ImGui::IsMouseDown(ImGuiMouseButton_Left)) {
4287 ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
4288 glfwSwapBuffers(window);
4289 if (!io.WantCaptureMouse && !ImGui::IsAnyItemHovered()) {
4294 std::this_thread::sleep_for(std::chrono::milliseconds(100 / 6));
4297 ImGui_ImplOpenGL3_Shutdown();
4298 ImGui_ImplGlfw_Shutdown();
4299 ImGui::DestroyContext();
4302 std::cout <<
"Visualizer plugin is required for this function." << std::endl;