
#-------------------------------------------------------------------------------
# Module:     editConstants.tk
# Activation: Dynamically loaded on user request
# Scope:      Dialog for generating constant node and arc labels
#-------------------------------------------------------------------------------



proc SelectConstants {} {
    global WDConstant DefPadX ThisGraph ThisLabel ThisValue

    set title "Constant Labels"

    if {[RegisterFormOrWindow $title constant WDConstant SelectConstants \
            "Done"          {} \
            "Apply"         {
                if {$ThisValue!=""} {
                    $ThisGraph set $ThisLabel $ThisValue
                    PropagateModifications
                }
            } \
            ""              {} \
            ""              {} \
        ]
    } {
        return
    }


    if {![info exists ThisLabel] || \
            ($ThisLabel!="ucap" && $ThisLabel!="lcap" && \
             $ThisLabel!="length" && $ThisLabel!="demand")} {
        set ThisLabel "ucap"
        set ThisValue ""
    }

    frame $WDConstant.options
    label $WDConstant.options.label -text "Labels:" -anchor w
    radiobutton $WDConstant.options.ucap -text "Upper Bounds" \
        -variable ThisLabel -value "ucap" -anchor w
    radiobutton $WDConstant.options.lcap -text "Lower Bounds" \
        -variable ThisLabel -value "lcap" -anchor w
    radiobutton $WDConstant.options.length -text "Arc Lengths" \
        -variable ThisLabel -value "length" -anchor w
    radiobutton $WDConstant.options.demand -text "Node Demands" \
        -variable ThisLabel -value "demand" -anchor w
    pack $WDConstant.options.label $WDConstant.options.ucap \
        $WDConstant.options.lcap $WDConstant.options.length \
        $WDConstant.options.demand -side top -fill x
     
    frame $WDConstant.value
    label $WDConstant.value.label -text "New Constant Value:" -anchor w
    entry $WDConstant.value.value -textvariable ThisValue -bg white
    pack $WDConstant.value.label $WDConstant.value.value -side top -fill x

    pack $WDConstant.options $WDConstant.value -padx $DefPadX \
        -pady 5m -side top -anchor w


    DisplayForm $title
}

SelectConstants
