
#-------------------------------------------------------------------------------
# Module:     layoutArcs.tk
# Activation: Dynamically loaded on user request
# Scope:      Configuration of graph arc display
#-------------------------------------------------------------------------------



proc ShowADisplayOptions {} {
    global WDArcDisplay DefPadX

    set title "Arc Display Options"

    if {[RegisterFormOrWindow $title arcdisplay WDArcDisplay ShowADisplayOptions \
            "Done"          {
                goblin configure -arcFormatting $newArcFormatting
                PropagateModifications
            } \
            "Apply"         {
                goblin configure -arcFormatting $newArcFormatting
                PropagateModifications
            } \
            ""              {} \
            ""              {} \
        ]
    } {
        return
    }


    global goblinArrows goblinArcStyle goblinPredecessors goblinSubgraph \
        goblinArcLabels1 goblinArcLabels2 goblinArcLabels3 \
        goblinArcFormatting newArcFormatting
    set newArcFormatting $goblinArcFormatting

    frame $WDArcDisplay.options
    pack $WDArcDisplay.options -fill both -padx $DefPadX -pady 3m


    label $WDArcDisplay.options.formatStringLabel -text "Label Format: " \
        -anchor w
    grid $WDArcDisplay.options.formatStringLabel \
        -row 0 -column 0 -rowspan 1 -columnspan 1 -sticky news -padx 1m
    entry $WDArcDisplay.options.formatStringString \
        -textvariable newArcFormatting -bg white -width 20
    grid $WDArcDisplay.options.formatStringString \
        -row 0 -column 1 -rowspan 1 -columnspan 1 -sticky news -padx 1m


    frame $WDArcDisplay.options.separator -height 3m
    grid $WDArcDisplay.options.separator \
        -row 1 -column 0 -rowspan 1 -columnspan 2 -sticky news -padx 1m


    for {set i 1} {$i<=3} {incr i} {
        label $WDArcDisplay.options.arcLabelLabel$i -text "Arc Labels %$i: " \
            -anchor w
        grid $WDArcDisplay.options.arcLabelLabel$i -sticky news -padx 1m \
            -row [expr $i+1] -column 0 -rowspan 1 -columnspan 1

        menubutton $WDArcDisplay.options.arcLabelSelect$i \
            -menu $WDArcDisplay.options.arcLabelSelect$i.menu \
            -anchor w -bg white -relief ridge -width 15
        grid $WDArcDisplay.options.arcLabelSelect$i -sticky news -padx 1m \
            -row [expr $i+1] -column 1 -rowspan 1 -columnspan 1
    
        menu $WDArcDisplay.options.arcLabelSelect$i.menu -tearoff false
    }

    foreach {i text} { \
        0 "No Labels" \
        1 "Indices {0,1,2,..}" \
        7 "Indices {1,2,3,..}" \
        2 "Upper Capacity Bounds" \
        6 "Lower Capacity Bounds" \
        4 "Length Labels" \
        5 "Reduced Length Labels" \
        3 "Subgraph / Flow Labels" \
        8 "Edge Colours" \
    } {
        for {set j 1} {$j<=3} {incr j} {
            $WDArcDisplay.options.arcLabelSelect$j.menu add command \
                -label "#$i $text" \
                -command "set goblinArcLabels$j $i; $WDArcDisplay.options.arcLabelSelect$j configure -text \"$text\""
        }

        if {$goblinArcLabels1 == $i} {
            $WDArcDisplay.options.arcLabelSelect1 configure -text "$text"
        }
        if {$goblinArcLabels2 == $i} {
            $WDArcDisplay.options.arcLabelSelect2 configure -text "$text"
        }
        if {$goblinArcLabels3 == $i} {
            $WDArcDisplay.options.arcLabelSelect3 configure -text "$text"
        }
    }
    

    frame $WDArcDisplay.options.separator2 -height 3m
    grid $WDArcDisplay.options.separator2 \
        -row 5 -column 0 -rowspan 1 -columnspan 2 -sticky news -padx 1m

     
    label $WDArcDisplay.options.subgraphLabel -text "Arc Display: " \
        -anchor w
    grid $WDArcDisplay.options.subgraphLabel -sticky news -padx 1m \
        -row 6 -column 0 -rowspan 1 -columnspan 1

    menubutton $WDArcDisplay.options.subgraphSelect \
        -menu $WDArcDisplay.options.subgraphSelect.menu \
        -anchor w -bg white -relief ridge -width 15
    grid $WDArcDisplay.options.subgraphSelect -sticky news -padx 1m \
        -row 6 -column 1 -rowspan 1 -columnspan 1

    menu $WDArcDisplay.options.subgraphSelect.menu -tearoff false

    foreach {i text} { \
        0 "Hide All Arcs" \
        4 "Uniform" \
        1 "Supported Arcs Only" \
        2 "Fractional Arcs Dashed" \
        3 "Empty/Free/Full Arcs" \
        5 "Ordinal Styles" \
        6 "Fixed Arc Colours" \
        7 "Smooth Arc Colours" \
    } {
        $WDArcDisplay.options.subgraphSelect.menu add command \
            -label "$text" \
            -command "set goblinSubgraph $i; $WDArcDisplay.options.subgraphSelect configure -text \"$text\""

        if {$goblinSubgraph == $i} {
            $WDArcDisplay.options.subgraphSelect configure -text "$text"
        }
    }


    label $WDArcDisplay.options.arcStyleLabel -text "Arc Style: " \
        -anchor w
    grid $WDArcDisplay.options.arcStyleLabel -sticky news -padx 1m \
        -row 7 -column 0 -rowspan 1 -columnspan 1

    menubutton $WDArcDisplay.options.arcStyleSelect \
        -menu $WDArcDisplay.options.arcStyleSelect.menu \
        -anchor w -bg white -relief ridge -width 15
    grid $WDArcDisplay.options.arcStyleSelect -sticky news -padx 1m \
        -row 7 -column 1 -rowspan 1 -columnspan 1

    menu $WDArcDisplay.options.arcStyleSelect.menu -tearoff false

    foreach {i text} { \
        0 "Polygones" \
        1 "Splines" \
        2 "Rectilinear" \
    } {
        $WDArcDisplay.options.arcStyleSelect.menu add command \
            -label "$text" \
            -command "set goblinArcStyle $i; $WDArcDisplay.options.arcStyleSelect configure -text \"$text\""

        if {$goblinArcStyle == $i} {
            $WDArcDisplay.options.arcStyleSelect configure -text "$text"
        }
    }


    label $WDArcDisplay.options.arrowLabel -text "Arrows: " \
        -anchor w
    grid $WDArcDisplay.options.arrowLabel -sticky news -padx 1m \
        -row 8 -column 0 -rowspan 1 -columnspan 1

    menubutton $WDArcDisplay.options.arrowSelect \
        -menu $WDArcDisplay.options.arrowSelect.menu \
        -anchor w -bg white -relief ridge -width 15
    grid $WDArcDisplay.options.arrowSelect -sticky news -padx 1m \
        -row 8 -column 1 -rowspan 1 -columnspan 1

    menu $WDArcDisplay.options.arrowSelect.menu -tearoff false

    foreach {i text} { \
        0 "Leading" \
        1 "Centered" \
    } {
        $WDArcDisplay.options.arrowSelect.menu add command \
            -label "$text" \
            -command "set goblinArrows $i; $WDArcDisplay.options.arrowSelect configure -text \"$text\""

        if {$goblinArrows == $i} {
            $WDArcDisplay.options.arrowSelect configure -text "$text"
        }
    }


    grid rowconfig    $WDArcDisplay.options 0 -weight 1 -minsize 0
    grid columnconfig $WDArcDisplay.options 0 -weight 1 -minsize 0


    frame $WDArcDisplay.checkButtons
    pack $WDArcDisplay.checkButtons -fill both -padx $DefPadX -pady 5m

    checkbutton $WDArcDisplay.checkButtons.predecessors \
        -text "Show Predecessor Arcs" -variable goblinPredecessors -anchor c
    pack $WDArcDisplay.checkButtons.predecessors -fill x


    DisplayForm $title
    
    focus $WDArcDisplay.options.formatStringString
}

ShowADisplayOptions
