
proc ShowNDisplayOptions {} {
    global WDNodeDisplay InternalWindowing DialogFrame DefPadX DefPadY

    if {$InternalWindowing} {
        set WDNodeDisplay $DialogFrame.nodedisplay
        if {![winfo exists $WDNodeDisplay]} {
            frame $WDNodeDisplay
        }
        
        RegisterDialog "Node Display Options" $WDNodeDisplay ShowNDisplayOptions {}
    } else {
        set WDNodeDisplay .nodedisplay
        if {![winfo exists $WDNodeDisplay]} {
            toplevel $WDNodeDisplay
            wm title $WDNodeDisplay "Node Display Options"
            wm resizable $WDNodeDisplay 0 0
        }
    }

    global goblinNodeStyle goblinNodeLabels goblinNodeColours
    
    frame $WDNodeDisplay.buttons
    button $WDNodeDisplay.buttons.done -text "Done" -command { \
        if {$InternalWindowing} {
            DestroyActiveDialog
        } else {
            destroy $WDNodeDisplay
        }
        InitDisplay
    }

    pack $WDNodeDisplay.buttons.done -side left -fill x -padx 3m
    pack $WDNodeDisplay.buttons -padx 3m -pady 3m -side bottom

    frame $WDNodeDisplay.options
    pack $WDNodeDisplay.options -fill both -padx $DefPadX -pady $DefPadY

    frame $WDNodeDisplay.options.nodeLabels
    frame $WDNodeDisplay.options.nodeColours
    frame $WDNodeDisplay.options.nodeStyle
    pack $WDNodeDisplay.options.nodeLabels $WDNodeDisplay.options.nodeColours \
        $WDNodeDisplay.options.nodeStyle -side top -fill x -pady 5m


    label $WDNodeDisplay.options.nodeLabels.label -text "Node Labels:" -anchor w
    radiobutton $WDNodeDisplay.options.nodeLabels.noLabels -text "No Labels" \
        -variable goblinNodeLabels -value 0 -anchor w
    radiobutton $WDNodeDisplay.options.nodeLabels.indices -text "Node Indices" \
        -variable goblinNodeLabels -value 1 -anchor w
    radiobutton $WDNodeDisplay.options.nodeLabels.labels -text "Distance Labels" \
        -variable goblinNodeLabels -value 2 -anchor w
    radiobutton $WDNodeDisplay.options.nodeLabels.potentials -text "Potentials" \
        -variable goblinNodeLabels -value 3 -anchor w
    radiobutton $WDNodeDisplay.options.nodeLabels.colours -text "Colours" \
        -variable goblinNodeLabels -value 4 -anchor w
    radiobutton $WDNodeDisplay.options.nodeLabels.demands -text "Demands" \
        -variable goblinNodeLabels -value 5 -anchor w
    pack $WDNodeDisplay.options.nodeLabels.label \
        $WDNodeDisplay.options.nodeLabels.noLabels \
        $WDNodeDisplay.options.nodeLabels.indices \
        $WDNodeDisplay.options.nodeLabels.labels \
        $WDNodeDisplay.options.nodeLabels.potentials \
        $WDNodeDisplay.options.nodeLabels.colours \
        $WDNodeDisplay.options.nodeLabels.demands \
        -fill x

    label $WDNodeDisplay.options.nodeColours.label -text "Node Colours:" -anchor w
    radiobutton $WDNodeDisplay.options.nodeColours.uncoloured -text "Uncoloured" \
        -variable goblinNodeColours -value 0 -anchor w
    radiobutton $WDNodeDisplay.options.nodeColours.labels -text "Distance Labels" \
        -variable goblinNodeColours -value 1 -anchor w
    radiobutton $WDNodeDisplay.options.nodeColours.colours -text "Colours" \
        -variable goblinNodeColours -value 2 -anchor w
    radiobutton $WDNodeDisplay.options.nodeColours.demands -text "Demands" \
        -variable goblinNodeColours -value 3 -anchor w
    radiobutton $WDNodeDisplay.options.nodeColours.part -text "Partition" \
        -variable goblinNodeColours -value 4 -anchor w
    pack $WDNodeDisplay.options.nodeColours.label \
        $WDNodeDisplay.options.nodeColours.uncoloured \
        $WDNodeDisplay.options.nodeColours.colours \
        $WDNodeDisplay.options.nodeColours.demands \
        $WDNodeDisplay.options.nodeColours.labels \
        $WDNodeDisplay.options.nodeColours.part \
        -fill x

    label $WDNodeDisplay.options.nodeStyle.label -text "Node Style:" -anchor w
    radiobutton $WDNodeDisplay.options.nodeStyle.dots -text "Dots" \
        -variable goblinNodeStyle -value 0 -anchor w
    radiobutton $WDNodeDisplay.options.nodeStyle.circles -text "Circles" \
        -variable goblinNodeStyle -value 1 -anchor w
    radiobutton $WDNodeDisplay.options.nodeStyle.boxes -text "Boxes" \
        -variable goblinNodeStyle -value 2 -anchor w
    pack $WDNodeDisplay.options.nodeStyle.label \
        $WDNodeDisplay.options.nodeStyle.dots \
        $WDNodeDisplay.options.nodeStyle.circles \
        $WDNodeDisplay.options.nodeStyle.boxes \
        -fill x

    if {$InternalWindowing} {
        pack $WDNodeDisplay -anchor nw
        AlignActiveDialog
    }
}

global WDNodeDisplay
if {![info exists WDNodeDisplay] || ![winfo exists $WDNodeDisplay]} {ShowNDisplayOptions}
