
# ----------------------------------------------------------------------
# THESE ARE BOGUS

proc show_visible_if_family {im} {
    global fam_visible
    
    if [interp exists batch_interp] {
	batch_interp eval $im configure -visible $fam_visible([batch_interp eval $im get -family])
    } else {
	$im configure -visible $fam_visible([$im get -family])
    }
}

proc object_geovisible_of_image {im {on_off ""}} {
    if {$on_off == ""} {
	if [interp exists batch_interp] {
	    return [batch_interp eval $im get -visible]
	} else {
	    return [$im get -visible]
	}
    }

    if [interp exists batch_interp] {
	 batch_interp eval $im configure -visible $on_off
    } else {
    	$im configure -visible $on_off
    }
}

proc object_type_of_image {im} {
    global projlib
    if [interp exists batch_interp] {
	return [ic_geo_get_object_type [batch_interp eval $im get -type] [batch_interp eval $im get -name]]
    } else {
	return [$projlib get_object_type [$im get -type] [$im get -number]]
    }
}

proc object_geotype_of_image {im} {
    global projlib
    if [interp exists batch_interp] {
	return [batch_interp eval $im get -type]
    } else {
	return [$im get -type]
    }
}

proc object_name_of_image {im} {
    if [interp exists batch_interp] {
	return [batch_interp eval $im get -name]
    } else {
	return [$im get -name]
    }
}

proc get_object_by_name {types n} {
    global projlib
    
    foreach type $types {
	if {([string first * $n] >= 0) || ([string first ? $n] >= 0) || ([string first \[ $n] >= 0)} {
	    # Have to search for all of them ...
	    set ret [batch_interp eval geo_match_name $type $n]
	} elseif [interp exists batch_interp] {
	    set ret [batch_interp eval \$projlib get_object_by_name $type \"$n\"]
	} else {
	    set ret [$projlib get_object_by_name $type $n]
	}
	if {$ret != ""} { return $ret }
    }
    return ""
}

proc get_dormant_object_by_name {types n} {
    global projlib
    
    set ret ""
    foreach type $types {
	if {([string first * $n] >= 0) || ([string first ? $n] >= 0) || ([string first \[ $n] >= 0)} {
	    # Have to search for all dormant of them ...
	    set ret [batch_interp eval geo_dormant_match_name $type $n]
	} elseif [interp exists batch_interp] {
	    set obj [batch_interp eval \$projlib get_object_by_name $type \"$n\"]
	    if [object_get_geo_dormant $obj] {
	      set ret $obj
	    }
	} else {
	    set obj [$projlib get_object_by_name $type $n]
	    if [object_get_geo_dormant $obj] {
	      set ret $obj
	    }	    
	}
	if {$ret != ""} { return $ret }
    }
    return ""
}

proc object_incident_of_image {im} {
    global projlib
    if [interp exists batch_interp] {
        return [batch_interp eval $im incident]
    } else {
        return [$im incident]
    }
}

proc object_boundary_of_image {im {outer 0} {even_if_dormant 0} {embedded 0}} {
    global projlib
    if ($even_if_dormant) {
        set dormant "even_if_dormant"
    } else {
        set dormant ""
    }
    if ($embedded) {
        set embedded "embedded"
    } else {
        set embedded ""
    }
    if $outer {
        if [interp exists batch_interp] {
            return [batch_interp eval $im outer_boundary]
        } else {
            return [$im outer_boundary]
        }
    } else {
        if [interp exists batch_interp] {
            return [batch_interp eval $im boundary $dormant $embedded]
        } else {
            return [$im boundary $dormant $embedded]
        }
    }
}

proc object_get_image {type name} {
    global projlib
    if [interp exists batch_interp] {
	return [batch_interp eval \$projlib get_object_by_name $type $name]
    } else {
	return [$projlib get_object_by_name $type $name]
    }
}

proc object_show_geo_selected {im on} {
    ic_show_geo_selected [batch_interp eval $im get -type] \
	[batch_interp eval $im get -name] $on
}

proc object_get_geo_dormant {im} {
    return [ic_geo_get_dormant_entity [object_geotype_of_image $im] [object_name_of_image $im]]
}


# -------------------------

# These let the batch interp see what is going on.

proc get_fam_visible {v}  { 
	global fam_visible
	if [ info exists fam_visible($v) ] { 
		return $fam_visible($v)
	} else {
		return 1
	}
}

proc get_geom_visible {v} { 
	global geom_visible
	if [ info exists geom_visible($v) ] {
		return $geom_visible($v)
	} else {
		return 1
	}
}

proc get_str_option {v}   { 
	global str_option  
	if [ info exists str_option($v) ] {
		return $str_option($v) 
	} else {
		return 1
	}
}

proc get_quad_option {v}   { 
	global quad  
	if [ info exists quad($v) ] {
		return $quad($v) 
	} else {
		return 0
	}
}

proc get_etm_undo_option {{unset 0}}   { 
	global etm_undo  
	if [ info exists etm_undo ] {
		if $unset {
		    unset etm_undo
		}
		return 1
	} else {
		return 0
	}
}

