def add_default_flags()

in scripts/ui/common.py [0:0]


def add_default_flags(parent):
    """Retrieves the default flags to the local flagfile on the specified tab from
    either the source or scripts binaries.

    Args:
        parent (App(QDialog)): Object corresponding to the parent UI element.
    """
    default_flags = {}

    tag = parent.tag
    if tag in ["bg", "depth"]:
        default_flags.update(
            {
                os.path.join(depth_est_src, "DerpCLI.cpp"): {
                    "max_depth_m",
                    "min_depth_m",
                    "resolution",
                    "var_high_thresh",
                    "var_noise_floor",
                }
            }
        )

    if tag == "depth":
        default_flags.update(
            {
                os.path.join(render_scripts, "setup.py"): {"do_temporal_filter"},
                os.path.join(depth_est_src, "TemporalBilateralFilter.cpp"): {
                    "time_radius"
                },
                os.path.join(render_src, "GenerateForegroundMasks.cpp"): {
                    "blur_radius",
                    "morph_closing_size",
                    "threshold",
                },
            }
        )
    elif tag == "export":
        default_flags.update(
            {
                os.path.join(render_src, "SimpleMeshRenderer.cpp"): {"width"},
                os.path.join(render_src, "ConvertToBinary.cpp"): {"output_formats"},
            }
        )

    flagfile_fn = os.path.join(parent.path_flags, parent.flagfile_basename)
    flags = get_flags_from_flagfile(flagfile_fn)
    for source in default_flags:
        if os.path.isfile(source):
            source_flags = get_flags(source)
        else:
            source_flags
        desired_flags = default_flags[source]
        for source_flag in source_flags:
            flag_name = source_flag["name"]

            # Only add the default flag if not already present in current flags
            if flag_name in desired_flags:
                if flag_name not in flags or flags[flag_name] == "":
                    flags[flag_name] = source_flag["default"]

    # Add run flags
    if tag == "bg":
        flags["run_generate_foreground_masks"] = False
        flags["run_precompute_resizes"] = True
        flags["run_depth_estimation"] = True
        flags["run_convert_to_binary"] = False
        flags["run_fusion"] = False
        flags["run_simple_mesh_renderer"] = False
        flags["use_foreground_masks"] = False
    elif tag == "depth":
        flags["run_depth_estimation"] = True
        flags["run_precompute_resizes"] = True
        flags["run_precompute_resizes_foreground"] = True
        flags["run_convert_to_binary"] = False
        flags["run_fusion"] = False
        flags["run_simple_mesh_renderer"] = False
    elif tag == "export":
        flags["run_generate_foreground_masks"] = False
        flags["run_precompute_resizes"] = False
        flags["run_precompute_resizes_foreground"] = False
        flags["run_depth_estimation"] = False

    # Overwrite flag file
    sorted_flags = collections.OrderedDict(sorted(flags.items()))
    dep_util.write_flagfile(flagfile_fn, sorted_flags)