generated by zdoc.tcl on Thu Feb 14 16:15:14 MET 2002

tclContour.tcl



contour
Comments  
Arguments  
Used by  
Uses  
    variable setRestLength
    global setMetricParameters
    global resetMetricParameters
    global fuseContour
}


contour::activeContour2DboundaryCondition
Comments  
Arguments viewer
camera
contour
Used by  
Uses  
proc contour::activeContour2DboundaryCondition { viewer camera contour } {
    global boundaryType
    global extremityType
    if {![winfo exists .dialogBoundaryCondition2D]} {
    set bg #A0D0A0
    set bg2  #80C080
    set root .dialogBoundaryCondition2D
    toplevel .dialogBoundaryCondition2D -bg $bg
    wm title .dialogBoundaryCondition2D "ActiveContour2D Boundary Conditions"
    set mn [tk_optionMenu $root.type boundaryType Position Tangent "First Derivative" "Second Derivative" Curvature "Simplex Angle"]
    $root.type  configure -bg $bg2

    for {set i 0} {$i <= [$mn index last]} {incr i} {
        $mn entryconfigure $i -selectcolor black -command "contour::displayBoundaryConditions2D $contour \[$mn entrycget $i -label\] \$extremityType" -background $bg2
    }
    pack $root.type -padx 10 -pady 10 -expand true -fill x

    set mn2 [tk_optionMenu $root.extremity extremityType "First End" "Last End"]
    $root.extremity  configure -bg $bg2

    for {set i 0} {$i <= [$mn2 index last]} {incr i} {
        $mn2 entryconfigure $i -selectcolor black -command "contour::displayBoundaryConditions2D $contour \$boundaryType \[$mn2 entrycget $i -label\]" -background $bg2
    }
    pack $root.extremity -padx 10 -pady 10 -expand true -fill x
    
    frame $root.f -bg $bg
    pack $root.f -expand true -fill both
    frame $root.buttons -bg $bg
    button $root.buttons.apply -text Apply -command "contour::setBoundaryConditions2D $contour \$boundaryType \$extremityType" -bg $bg2
    button $root.buttons.applyDismiss -text "Apply & Dismiss" -command "contour::setBoundaryConditions2D $contour \$boundaryType \$extremityType;destroy $root" -bg $bg2
    button $root.buttons.destroy -text "Destroy" -command "destroy $root" -bg $bg2
    pack $root.buttons.apply $root.buttons.applyDismiss  $root.buttons.destroy -side left -expand true -fill both -padx 20 -pady 10
    pack $root.buttons -expand true -fill both
    
    set boundaryType "Position"
    contour::displayBoundaryConditions2D $contour "Position" "First End"
    }
}


contour::attachmentConstraint
Comments  
Arguments contour
px
py
vertex
stiffness
Used by contour::editForceConstraint2D
Uses  
proc contour::attachmentConstraint { contour px py  vertex stiffness} {
    set root .attachmentConstraint2D
    if {![winfo exists $root]} {
    set bg #A0D0A0
    set bg2  #80C080
    toplevel $root -bg $bg
    wm title $root "Attachment Constraint"
    
    frame $root.f -bg $bg

    frame $root.f.px -bd 2 -bg $bg
    entry $root.f.px.entry -relief sunken -width 10 -bg $bg
    $root.f.px.entry delete 0 10
    $root.f.px.entry insert 0 $px
    label $root.f.px.label -text "X Coordinate" -bg $bg
    pack $root.f.px.entry -side right -padx 20
    pack $root.f.px.label -side left -padx 20

    frame $root.f.py -bd 2 -bg $bg
    entry $root.f.py.entry -relief sunken -width 10 -bg $bg
    $root.f.py.entry delete 0 10
    $root.f.py.entry insert 0 $py
    label $root.f.py.label -text "Y Coordinate" -bg $bg
    pack $root.f.py.entry -side right -padx 20
    pack $root.f.py.label -side left -padx 20

    frame $root.f.stiff -bd 2 -bg $bg
    entry $root.f.stiff.entry -relief sunken -width 25 -bg $bg
    $root.f.stiff.entry delete 0 25
    $root.f.stiff.entry insert 0 $stiffness
    label $root.f.stiff.label -text "Stiffness" -bg $bg
    pack $root.f.stiff.entry -side right -padx 20
    pack $root.f.stiff.label -side left -padx 20

    frame $root.f.vertex -bd 2 -bg $bg
    label $root.f.vertex.entry -text $vertex -bg $bg
    label $root.f.vertex.label -text "Vertex" -bg $bg
    pack $root.f.vertex.entry -side right -padx 20
    pack $root.f.vertex.label -side left -padx 20

    pack  $root.f.px  $root.f.py $root.f.stiff $root.f.vertex -side top -fill x
    pack $root.f -expand true -fill both
    
    frame $root.buttons -bg $bg
    button $root.buttons.apply -text Apply -command "evaluate \"$contour -attachmentConstraint \[$root.f.vertex.entry get \] \[$root.f.px.entry get\] \[$root.f.py.entry get\] \[$root.f.stiff.entry get\]\"" -bg $bg
    button $root.buttons.applyDismiss -text "Apply & Dismiss" -command "evaluate \"$contour -attachmentConstraint \[$root.f.vertex.entry cget -text\] \[$root.f.px.entry get\] \[$root.f.py.entry get\] \[$root.f.stiff.entry get\]\";destroy $root" -bg $bg
    button $root.buttons.destroy -text "Destroy" -command "destroy $root" -bg $bg
    pack $root.buttons.apply $root.buttons.applyDismiss  $root.buttons.destroy -side left -expand true -fill both -padx 20 -pady 10
    pack $root.buttons -expand true -fill both
    }
}


contour::balloonConstraint
Comments  
Arguments contour
ratio
Used by contour::editForceConstraint2D
Uses  
proc contour::balloonConstraint { contour ratio} {
    set root .balloonConstraint2D
    if {![winfo exists $root]} {
    set bg #A0D0A0
    set bg2  #80C080
    toplevel $root -bg $bg
    wm title $root "Balloon Constraint"
    
    frame $root.f -bg $bg

    frame $root.f.ratio -bd 2 -bg $bg
    entry $root.f.ratio.entry -relief sunken -width 10 -bg $bg
    $root.f.ratio.entry delete 0 10
    $root.f.ratio.entry insert 0 $ratio
    label $root.f.ratio.label -text "Balloon Force Ratio" -bg $bg
    pack $root.f.ratio.entry -side right -padx 20
    pack $root.f.ratio.label -side left -padx 20


    pack  $root.f.ratio -side top -fill x
    pack $root.f -expand true -fill both
    
    frame $root.buttons -bg $bg
    button $root.buttons.apply -text Apply -command "evaluate \"$contour -balloonConstraint \[$root.f.ratio.entry get \]\"" -bg $bg
    button $root.buttons.applyDismiss -text "Apply & Dismiss" -command "evaluate \"$contour -balloonConstraint \[$root.f.ratio.entry get \]\";destroy $root" -bg $bg
    button $root.buttons.destroy -text "Destroy" -command "destroy $root" -bg $bg
    pack $root.buttons.apply $root.buttons.applyDismiss  $root.buttons.destroy -side left -expand true -fill both -padx 20 -pady 10
    pack $root.buttons -expand true -fill both
    }
}


contour::curvatureSpacingConstraint
Comments  
Arguments contour
frequency
extent
Used by contour::editPositionConstraint2D
Uses  
proc contour::curvatureSpacingConstraint { contour frequency extent} {
    set root .curvatureSpacingConstraint2D
    if {![winfo exists $root]} {
    set bg #A0D0A0
    set bg2  #80C080
    toplevel $root -bg $bg
    wm title $root "Curvature Spacing Constraint"
    
    frame $root.f -bg $bg

    frame $root.f.frequency -bd 2 -bg $bg
    entry $root.f.frequency.entry -relief sunken -width 10 -bg $bg
    $root.f.frequency.entry delete 0 10
    $root.f.frequency.entry insert 0 $frequency
    label $root.f.frequency.label -text "Curvature Spacing Constraint Frequency" -bg $bg
    pack $root.f.frequency.entry -side right -padx 20
    pack $root.f.frequency.label -side left -padx 20


    pack  $root.f.frequency -side top -fill x
    pack $root.f -expand true -fill both

    frame $root.f.extent -bd 2 -bg $bg
    scale $root.f.extent.scale -orient horizontal -label "Constraint Magnitude" -from 0 -to 1 -length 200 -resolution 0.01 -bg $bg
    $root.f.extent.scale  set $extent
    pack $root.f.extent.scale -side right -padx 20

    pack  $root.f.frequency  $root.f.extent -side top -fill x
    pack $root.f -expand true -fill both
    
    frame $root.buttons -bg $bg
    button $root.buttons.apply -text Apply -command "evaluate \"$contour -curvatureSpacingConstraint \[$root.f.frequency.entry get \] \[$root.f.extent.scale get \]\"" -bg $bg
    button $root.buttons.applyDismiss -text "Apply & Dismiss" -command "evaluate \"$contour -curvatureSpacingConstraint \[$root.f.frequency.entry get \] \[$root.f.extent.scale get \]\";destroy $root" -bg $bg
    button $root.buttons.destroy -text "Destroy" -command "destroy $root" -bg $bg
    pack $root.buttons.apply $root.buttons.applyDismiss  $root.buttons.destroy -side left -expand true -fill both -padx 20 -pady 10
    pack $root.buttons -expand true -fill both
    }
}


contour::displayBoundaryConditions2D
Comments  
Arguments contour
boundary
extremity
Used by  
Uses  
proc contour::displayBoundaryConditions2D { contour boundary extremity } {
    switch $boundary {
    "Position" { set boundaryName "position"; set scalar 0}
    "Tangent" { set boundaryName "tangent"; set scalar 0}
    "First Derivative" { set boundaryName "1rstDerivative"; set scalar 0}
    "Second Derivative" { set boundaryName "2ndDerivative"; set scalar 0}
    "Curvature" { set boundaryName "curvature"; set scalar 1}
    "Simplex Angle" { set boundaryName "simplexAngle"; set scalar 1}
    }

    switch $extremity {
    "First End" { set extremityName "first" }
    "Last End" { set extremityName "last" }
    }
    set vector [$contour -boundaryCondition $boundaryName $extremityName]
    if {$scalar == 0} {
    set root  .dialogBoundaryCondition2D
    set bg #A0D0A0
    set bg2  #80C080

    set list [winfo children $root.f]
    foreach w $list { destroy $w}

    foreach i {tx ty } {
        frame $root.f.$i -bd 2 -bg $bg
        entry $root.f.$i.entry -relief sunken -width 25 -bg $bg
        label $root.f.$i.label -bg $bg2
        pack  $root.f.$i.entry -side right -padx 20
        pack  $root.f.$i.label -side left -padx 20
    }
    $root.f.tx.label configure -text "X coordinate"
    $root.f.ty.label configure -text "Y coordinate"
    pack $root.f.tx $root.f.ty  -side top -fill x
    pack $root.f -expand true -fill both
    
    .dialogBoundaryCondition2D.f.tx.entry delete 0 20
    .dialogBoundaryCondition2D.f.tx.entry insert 0 [lindex $vector 0]
    .dialogBoundaryCondition2D.f.ty.entry delete 0 20
    .dialogBoundaryCondition2D.f.ty.entry insert 0 [lindex $vector 1]
    }
    if {$scalar == 1} {
    set root  .dialogBoundaryCondition2D
    set bg #A0D0A0
    set bg2  #80C080

    set list [winfo children $root.f]
    foreach w $list { destroy $w}

    frame $root.f.val -bd 2 -bg $bg
    entry $root.f.val.entry -relief sunken -width 25 -bg $bg
    label $root.f.val.label -bg $bg2 -text $boundary
    pack  $root.f.val.entry -side right -padx 20
    pack  $root.f.val.label -side left -padx 20
    pack $root.f.val   -side top -fill x
    pack $root.f -expand true -fill both
    .dialogBoundaryCondition2D.f.val.entry delete 0 20
    .dialogBoundaryCondition2D.f.val.entry insert 0 [lindex $vector 0]
    

    }
}


contour::displayInternalForce2D
Comments  
Arguments contour
item
force
Used by contour::displayInternalForce2D
Uses contour::displayInternalForce2D
proc contour::displayInternalForce2D { contour item force } {
    set root .dialogInternalForce2D
    set list [winfo children $root.f]
    set bg #A0D0A0
    set bg2  #80C080
    foreach w $list {destroy $w}

    switch $force {
    "Spring-Mass" {
        set  contour::setRestLength 1
        checkbutton $root.f.restLength -variable contour::setRestLength -text "Set Spring Rest Length" -relief flat -bg $bg
        pack $root.f.restLength -side left
        pack $root.f -expand true -fill both
    }
    "Angular Spring-Mass System" {
        contour::displayInternalForce2D $contour $item "Spring-Mass System"
    }
    "Simplex C2" {
        set  setMetricParameters 0
        checkbutton $root.f.setMetric -variable contour::setMetricParameters -text "Set Metric Parameters" -relief flat -bg $bg
        set resetMetricParameters 0
        checkbutton $root.f.resetMetric -variable contour::resetMetricParameters -text "Reset Metric Parameters" -relief flat -bg $bg
        pack $root.f.setMetric $root.f.resetMetric  -side left
        pack $root.f -expand true -fill both
    }
    }
}


contour::displayNormalLine
Comments  
Arguments contour
camera
Used by  
Uses  
proc contour::displayNormalLine {contour camera} {
    if [ string compare [ $contour -vertexParameter ] {none} ] {
    $contour -selectLine [$contour -vertexParameter line]
    foreach f [ [ $camera -scene ] -objects ] {
        if [ string match {rimg2D?} $f ] {
        switch [ $contour -sliceGeometry ] {
            "X" {scan [ $contour -vertexParameter position ] {%f %f} px  py; scan [ $contour -vertexParameter normal ] {%f %f } nx ny;  evaluate "$f -displayLine [ expr [ $contour -sliceNumber ] +.5 ] $py  $px 0.0 $ny $nx [ $contour -vertexParameter externalForceRange ]"}
            "Y" {scan [ $contour -vertexParameter position ] {%f %f} px  py; scan [ $contour -vertexParameter normal ] {%f %f } nx ny;  evaluate "$f -displayLine $px [ expr [ $contour -sliceNumber ] +.5] $py   $nx 0.0 $ny  [ $contour -vertexParameter externalForceRange ]"}
            "Z" {scan [ $contour -vertexParameter position ] {%f %f} px  py; scan [ $contour -vertexParameter normal ] {%f %f } nx ny;  evaluate "$f -displayLine $px $py [ expr [ $contour -sliceNumber ] +.5]  $nx $ny 0  [ $contour -vertexParameter externalForceRange ]"}
        }
        }
    }
    }
}


contour::distanceConstraint
Comments  
Arguments contour
frequency
minDistance
maxDistance
Used by contour::editPositionConstraint2D
Uses  
proc contour::distanceConstraint { contour frequency minDistance maxDistance} {
    set root .distanceConstraint2D
    if {![winfo exists $root]} {
    set bg #A0D0A0
    set bg2  #80C080
    toplevel $root -bg $bg
    wm title $root "Distance Constraint"
    
    frame $root.f -bg $bg

    frame $root.f.freq -bd 2 -bg $bg
    entry $root.f.freq.entry -relief sunken -width 10 -bg $bg
    $root.f.freq.entry delete 0 10
    $root.f.freq.entry insert 0 $frequency
    label $root.f.freq.label -text "Frequency" -bg $bg
    pack $root.f.freq.entry -side right -padx 20
    pack $root.f.freq.label -side left -padx 20

    frame $root.f.min -bd 2 -bg $bg
    entry $root.f.min.entry -relief sunken -width 25 -bg $bg
    $root.f.min.entry delete 0 25
    $root.f.min.entry insert 0 $minDistance
    label $root.f.min.label -text "Minimum Distance" -bg $bg
    pack $root.f.min.entry -side right -padx 20
    pack $root.f.min.label -side left -padx 20

    frame $root.f.max -bd 2 -bg $bg
    entry $root.f.max.entry -relief sunken -width 25 -bg $bg
    $root.f.max.entry delete 0 25
    $root.f.max.entry insert 0 $maxDistance
    label $root.f.max.label -text "Maximum Distance" -bg $bg
    pack $root.f.max.entry -side right -padx 20
    pack $root.f.max.label -side left -padx 20

    pack  $root.f.freq  $root.f.min $root.f.max -side top -fill x
    pack $root.f -expand true -fill both
    
    frame $root.buttons -bg $bg
    button $root.buttons.apply -text Apply -command "evaluate \"$contour -distanceConstraint \[$root.f.freq.entry get\] \[$root.f.min.entry get\] \[$root.f.max.entry get\]\"" -bg $bg
    button $root.buttons.applyDismiss -text "Apply & Dismiss" -command "evaluate \"$contour -distanceConstraint \[$root.f.freq.entry get\] \[$root.f.min.entry get\] \[$root.f.max.entry get\]\";destroy $root" -bg $bg
    button $root.buttons.destroy -text "Destroy" -command "destroy $root" -bg $bg
    pack $root.buttons.apply $root.buttons.applyDismiss  $root.buttons.destroy -side left -expand true -fill both -padx 20 -pady 10
    pack $root.buttons -expand true -fill both
    }
}


contour::editForceConstraint2D
Comments  
Arguments name
contour
index
Used by contour::forceConstraint2D
Uses contour::attachmentConstraint
contour::balloonConstraint
proc contour::editForceConstraint2D { name contour index } {
    set j  -1
    set label  [$contour -forceConstraint $index ]
    for { set i 0 } { $i <= $index } { incr i } {
    set label2 [$contour -forceConstraint $i ]
    if  {[string compare $label2 $label ]==0}  {
        incr j}
    }
    switch $name {
    "Attachment Constraint" { set result [ $contour -attachmentConstraint $j]; contour::attachmentConstraint $contour [lindex $result 1]  [lindex $result 2] [lindex $result 0] [lindex $result 3]  }
    "Balloon Force" {contour::balloonConstraint $contour  [ $contour -balloonConstraint ] }
    }
}


contour::editPositionConstraint2D
Comments  
Arguments name
contour
Used by contour::positionConstraint2D
Uses contour::spacingConstraint
contour::curvatureSpacingConstraint
contour::distanceConstraint
contour::topologyConstraint
contour::rectangleConstraint
proc contour::editPositionConstraint2D { name contour } {
    switch $name {
    "Distance Constraint" { set result [ $contour -distanceConstraint ]; contour::distanceConstraint $contour [lindex $result 0]  [lindex $result 1] [lindex $result 2]  }
    "Rectangle Constraint" { set result [ $contour -rectangleConstraint ]; contour::rectangleConstraint $contour [lindex $result 0]  [lindex $result 1] [lindex $result 2] [lindex $result 3] [lindex $result 4]  }
    "Spacing Constraint" { set result [ $contour -spacingConstraint ]; contour::spacingConstraint $contour [lindex $result 0]  [lindex $result 1] [lindex $result 2] [lindex $result 3]  }
    "Topology Constraint" { set result [ $contour -topologyConstraint ]; contour::topologyConstraint $contour [lindex $result 0]  [lindex $result 1] [lindex $result 2] [lindex $result 3]}
    "Curvature Spacing Constraint" { set result [ $contour -curvatureSpacingConstraint ]; contour::curvatureSpacingConstraint $contour [lindex $result 0]  [lindex $result 1] }
    }
}


contour::forceConstraint2D
Comments  
Arguments contour
Used by  
Uses contour::editForceConstraint2D
proc contour::forceConstraint2D { contour } {
    set root .forceConstraint2D
    if {![winfo exists $root]} {
    set bg #A0D0A0
    set bg2  #80C080
    toplevel $root -bg $bg
    wm title $root "ActiveContour2D Force Constraint"
    label $root.msg -justify center -text "List of Force Constraints" -bg $bg
    pack $root.msg  -side top
    
    frame $root.f -borderwidth .5c -bg $bg
    pack $root.f -side top -expand yes -fill y
    
    scrollbar $root.f.scroll -command "$root.f.list yview" -bg $bg
    listbox $root.f.list -yscroll "$root.f.scroll set" -setgrid 1 -height 12 -bg $bg
    pack $root.f.scroll -side right -fill y
    pack $root.f.list -side left -expand 1 -fill both


    set nbConstraints [$contour -forceConstraint]
    for { set i 0 } { $i < $nbConstraints } { incr i } {
        $root.f.list insert $i [$contour -forceConstraint $i ]
    }

    frame $root.process -bg $bg
    pack $root.process -side top -pady 2m
    menubutton $root.process.create -text "Create Constraint" -bg $bg -underline 0 -direction above -menu $root.process.create.m -relief raised
    menu $root.process.create.m -tearoff 0
    $root.process.create.m add command -label "Attachment Constraint" -command "if \[ string compare \[ $contour -vertexParameter \] {none} \] {destroy $root;contour::attachmentConstraint $contour \[ lindex \[$contour -vertexParameter position\] 0\]  \[ lindex \[$contour -vertexParameter position\] 1\] \[ $contour -vertexParameter rank \]  0.5  } "
    $root.process.create.m add command -label "Balloon Constraint" -command "if { !\[ string compare \[ $contour -balloonConstraint \] {none} \] } { destroy $root;contour::balloonConstraint $contour \[ expr \[ $contour -edgeLength mean\] *0.1 \] }"
    button $root.process.edit -text "Edit Constraint" -bg $bg -command " contour::editForceConstraint2D \[ $root.f.list get \[ lindex \[ $root.f.list curselection \] 0 \] \] $contour \[ lindex \[ $root.f.list curselection \] 0 \]; destroy $root"
    button $root.process.delete -text "Delete Constraint" -bg $bg -command "$contour -forceConstraint \[ lindex \[ $root.f.list curselection \] 0 \] delete;destroy $root"
    pack $root.process.create $root.process.edit $root.process.delete -side top -expand 1

    frame $root.button -bg $bg
    pack $root.button -side bottom -pady 2m
    button $root.button.dismiss -text Dismiss -command "destroy $root" -bg $bg
    pack  $root.button.dismiss -side left -expand 1
    }
}


contour::getImageSize
Comments  
Arguments contour
Used by  
Uses  
proc contour::getImageSize { contour } {
    if [string match sact2D? $contour] {
    foreach f [ [ $contour -scene ] -objects ] {
        if [ string match {rimg2D?} $f ] {
        set sizes [ [ $f -images intensity ] -size ]
        switch [ $contour -sliceGeometry ] {
            "Z" { return " 0.0 0.0 [ lindex $sizes 0] [ lindex $sizes 1] " }
            "Y" { return { 0.0 0.0 [ lindex $sizes 1] [ lindex $sizes 2] } }
            "X" { return { 0.0 0.0 [ lindex $sizes 0] [ lindex $sizes 2] } }
        }
        }
    }
    } else {
    return {0.0 0.0 1.0 1.0}
    }
}


contour::getNbInitialVertices
Comments  
Arguments init
color
Used by  
Uses  
proc contour::getNbInitialVertices { init color } {
    set root .nbInitialVertices
    if {![winfo exists $root]} {
    set bg #A0D0A0
    set bg2  #80C080
    toplevel $root -bg $bg
    wm title $root "Number of Vertices"
    
    frame $root.f -bg $bg

    frame $root.f.vertex -bd 2 -bg $bg
    entry $root.f.vertex.entry -relief sunken -width 10 -bg $bg
    $root.f.vertex.entry delete 0 10
    
    $root.f.vertex.entry insert 0 [ $init -nbVertices]
    label $root.f.vertex.label -text "Nb of Vertices" -bg $bg
    pack $root.f.vertex.entry -side right -padx 20
    pack $root.f.vertex.label -side left -padx 20

    pack  $root.f.vertex  -side top -fill x
    pack $root.f -expand true -fill both
    
    frame $root.buttons -bg $bg
    button $root.buttons.apply -text Apply -command "evaluate \"$init -nbVertices \[$root.f.vertex.entry get\]\";destroy $root " -bg $bg
    button $root.buttons.destroy -text "Destroy" -command "destroy $root" -bg $bg
    pack $root.buttons.apply $root.buttons.destroy -side left -expand true -fill both -padx 20 -pady 10
    pack $root.buttons -expand true -fill both
    }
}


contour::getSliceDistance
Comments  
Arguments contour
inr
Used by contour::installSliceContour3DMenu
Uses  
proc contour::getSliceDistance { contour inr } {
    scan [ $inr -voxel ] {%f %f %f} vx vy vz
    switch [ [$contour -sliceContour] -sliceGeometry ] {
    "X" { set val $vx}
    "Y" { set val $vy}
    "Z" { set val $vz}
    }
}


contour::installActiveContour2DEdgeMenu
Comments  
Arguments viewer
camera
contour
Used by contour::installActiveContour3DMenu
contour::installActiveContour2DMenu
simulation::installActiveTubeMenu
Uses modules::selectColor
proc contour::installActiveContour2DEdgeMenu { viewer camera contour } {
    set bg [$viewer cget -background]
    menubutton $viewer.context.edge -text "Edge" -menu $viewer.context.edge.m -anchor w -bg $bg
    set medge [menu $viewer.context.edge.m -bg $bg]
    $medge add command -label "Selected Edge Color..." -command "set col \[ modules::selectColor  \[ $contour -selectedEdgeColor\] \]; evaluate \"$contour -selectedEdgeColor \[lindex \$col 0\] \[lindex \$col 1\] \[lindex \$col 2\] \""
    $medge add cascade -label "Line Width" -menu   $medge.sub4
    set m4 [menu  $medge.sub4 -tearoff 0]
    $m4 add command -label "1" -command "evaluate \"$contour -selectedEdgeWidth 1\""
    $m4 add command -label "2" -command "evaluate \"$contour -selectedEdgeWidth 2\""
    $m4 add command -label "3" -command "evaluate \"$contour -selectedEdgeWidth 3\""
    $m4 add command -label "4" -command "evaluate \"$contour -selectedEdgeWidth 4\""
    $m4 add command -label "5" -command "evaluate \"$contour -selectedEdgeWidth 5\""
    $medge add command -label "Add Vertex" -command "evaluate \"$contour -addVertex\""
    $medge add command -label "Merge Edges" -command "evaluate \"$contour -mergeEdges\""
    $medge add command -label "Cut Edge" -command "evaluate \"$contour -cutEdge\""
    pack  $viewer.context.edge -side left
}


contour::installActiveContour2DLineMenu
Comments  
Arguments viewer
camera
contour
Used by simulation::installActiveTubeMenu
contour::installActiveContour3DMenu
contour::installActiveContour2DMenu
Uses contour::installContourLineMenu
proc contour::installActiveContour2DLineMenu { viewer camera contour } {
    contour::installContourLineMenu $viewer $camera $contour
    $viewer.context.line.m add command -label "Boundary Conditions Info..." -command "contour::activeContour2DboundaryCondition $viewer $camera $contour"
    pack  $viewer.context.line -side left
}


contour::installActiveContour2DMenu
Comments  
Arguments viewer
camera
contour
bg
Used by contour::installSliceActiveContour2DMenu
Uses contour::installActiveContour2DEdgeMenu
contour::installActiveContour2DVertexMenu
contour::installActiveContour2DLineMenu
proc contour::installActiveContour2DMenu { viewer camera contour bg } {
    global showRange
    global showClosest
    installContourFileMenu $viewer $camera $contour $bg
    installContourDisplayMenu $viewer $camera $contour $bg
    installContourInternalMenu $viewer $camera $contour $bg
    installContourExternalMenu $viewer $camera $contour $bg
    
    set mdisplay     $viewer.context.display.m
    $mdisplay add cascade -label "Show Force Range" -menu   $mdisplay.sub6
    menu  $mdisplay.sub6 -tearoff 0 -postcommand "scan \[$contour -showRangeDistance \] {%s} contour::showRange"
    $mdisplay.sub6 add radio -selectcolor "black" -label "Show Force Range" -variable contour::showRange -value "true" -command "evaluate \"$contour -showRangeDistance true\""
    $mdisplay.sub6 add radio -selectcolor "black" -label "Hide Force Range" -variable contour::showRange -value "false" -command "evaluate \"$contour -showRangeDistance false\""
    $mdisplay add cascade -label "Show Closest Point" -menu   $mdisplay.sub5
    menu  $mdisplay.sub5 -tearoff 0 -postcommand "scan \[$contour -showClosestPoint \] {%s} contour::showClosest"
    $mdisplay.sub5 add radio -selectcolor "black" -label "Show Closest Point" -variable contour::showClosest -value "true" -command "evaluate \"$contour -showClosestPoint true\""
    $mdisplay.sub5 add radio -selectcolor "black" -label "Hide Closest Point" -variable contour::showClosest -value "false" -command "evaluate \"$contour -showClosestPoint false\""
    
    
    if {[string compare [$contour -selectionMode] "edge"]== 0} {
    contour::installActiveContour2DEdgeMenu $viewer $camera $contour
    }    
    if {[string compare [$contour -selectionMode] "line"]== 0} {
    contour::installActiveContour2DLineMenu $viewer $camera $contour
    }        
    if {[string compare [$contour -selectionMode] "vertex"]== 0} {
    contour::installActiveContour2DVertexMenu $viewer $camera $contour
    }


    #Defines the menu call with the right button
    set popup [menu $viewer.popup -tearoff 0 -bg "white" -postcommand "scan \[$contour -selectionMode \] {%s} contour::selectionMode;scan \[$camera -motionMode \] {%s} contour::motionMode " ]
    $popup add command -label "Left Button" -state disabled -command {}
    $popup add radio -selectcolor "black" -label "Select Object" -variable contour::selectionMode -value "object" -command "evaluate \"$contour -selectionMode object  $camera\""
    $popup add radio -selectcolor "black" -label "Select Line" -variable contour::selectionMode -value "line" -command "evaluate \"$contour -selectionMode line  $camera\""
    $popup add radio -selectcolor "black" -label "Select Vertex" -variable contour::selectionMode -value "vertex" -command "evaluate \"$contour -selectionMode vertex  $camera\""
    $popup add radio -selectcolor "black" -label "Select Edge" -variable contour::selectionMode -value "edge" -command "evaluate \"$contour -selectionMode edge  $camera\""
    $popup add radio -selectcolor "black" -label "Grab Vertex" -variable contour::selectionMode -value "grab" -command "evaluate \"$contour -selectionMode grab  $camera\""
    $popup add radio -selectcolor "black" -label "Move Vertex" -variable contour::selectionMode -value "moveVertex" -command "evaluate \"$contour -selectionMode moveVertex  $camera\""
    $popup add radio -selectcolor "black" -label "Add Vertex" -variable contour::selectionMode -value "addVertex" -command "evaluate \"$contour -selectionMode addVertex  $camera\""
    $popup add radio -selectcolor "black" -label "Insert Vertex" -variable contour::selectionMode -value "insertVertex" -command "evaluate \"$contour -selectionMode insertVertex  $camera\""

    $popup add command -label "Middle Button" -state disabled -command {}
    $popup add radio -selectcolor "black" -label "Move Contour" -variable contour::motionMode -value "object" -command "evaluate \"$contour -motionMode $camera contour\""
    $popup add radio -selectcolor "black" -label "Move Line" -variable contour::motionMode -value "cameraObject" -command "evaluate \"$contour -motionMode $camera line\""
    $popup add radio -selectcolor "black" -label "Move Camera" -variable contour::motionMode -value "camera" -command "evaluate \"$contour -motionMode $camera camera\""
    $popup add separator
    
    bind [$camera -widget] <Button-3> "tk_popup $popup %X %Y"
}


contour::installActiveContour2DVertexMenu
Comments  
Arguments viewer
camera
contour
Used by contour::installActiveContour3DMenu
contour::installActiveContour2DMenu
simulation::installActiveTubeMenu
Uses contour::installContourVertexMenu
proc contour::installActiveContour2DVertexMenu { viewer camera contour } {
    global vertexMobility
    contour::installContourVertexMenu $viewer $camera $contour
    $viewer.context.vertex.m add command -label "Remove Vertex" -command "evaluate \"$contour -removeVertex\""
    
    $viewer.context.vertex.m add cascade -label "Free/Fix" -menu $viewer.context.vertex.m.sub1
    menu $viewer.context.vertex.m.sub1 -tearoff 0 -postcommand "scan \[$contour -vertexParameter mobility \] {%s} contour::vertexMobility"
    $viewer.context.vertex.m.sub1 add radio -selectcolor "black" -label "Fixed" -variable contour::vertexMobility -value "true" -command "evaluate \"$contour -vertexParameter mobility true\""
    $viewer.context.vertex.m.sub1 add radio -selectcolor "black" -label "Free" -variable contour::vertexMobility -value "false" -command "evaluate \"$contour -vertexParameter mobility false\""
    if { [ string match {sact2D*} $contour ] } {
    $viewer.context.vertex.m add command -label "View Normal Line Slice..." -command "contour::displayNormalLine $contour $camera"
    }
    pack  $viewer.context.vertex -side left
}


contour::installActiveContour3DMenu
Comments  
Arguments viewer
camera
contour
bg
Used by SM2::installContourSM2Menu
Uses contour::installActiveContour2DEdgeMenu
contour::installActiveContour2DVertexMenu
imagedata::editIntensityProfileDialog
contour::installActiveContour2DLineMenu
proc contour::installActiveContour3DMenu { viewer camera contour bg } {
    global showRange
    global showClosest
    installContourFileMenu $viewer $camera $contour $bg
    installContourDisplayMenu $viewer $camera $contour $bg
    installContourInternalMenu $viewer $camera $contour $bg
    installContourExternalMenu $viewer $camera $contour $bg
    
    set mdisplay     $viewer.context.display.m
    $mdisplay add cascade -label "Show Force Range" -menu   $mdisplay.sub6
    menu  $mdisplay.sub6 -tearoff 0 -postcommand "scan \[$contour -showRangeDistance \] {%s} contour::showRange"
    $mdisplay.sub6 add radio -selectcolor "black" -label "Show Force Range" -variable contour::showRange -value "true" -command "evaluate \"$contour -showRangeDistance true\""
    $mdisplay.sub6 add radio -selectcolor "black" -label "Hide Force Range" -variable contour::showRange -value "false" -command "evaluate \"$contour -showRangeDistance false\""
    $mdisplay add cascade -label "Show Closest Point" -menu   $mdisplay.sub5
    menu  $mdisplay.sub5 -tearoff 0 -postcommand "scan \[$contour -showClosestPoint \] {%s} contour::showClosest"
    $mdisplay.sub5 add radio -selectcolor "black" -label "Show Closest Point" -variable contour::showClosest -value "true" -command "evaluate \"$contour -showClosestPoint true\""
    $mdisplay.sub5 add radio -selectcolor "black" -label "Hide Closest Point" -variable contour::showClosest -value "false" -command "evaluate \"$contour -showClosestPoint false\""


    set mn $viewer.context.external.m
    $mn add command -label "Store Intensity Profiles..." -command "contour::storeIntensityProfileDialog $contour 3D"
    $mn add command -label "Edit Intensity Profiles..." -command "set rinfs \[ $contour -rangeInformationSet \]; if \[ string compare \$rinfs \"Intensity Profile\" \] { if \[string compare \[isModuleLoaded tclImageData \] no \] { imagedata::editIntensityProfileDialog \[ new ipinfos \$rinfs \]  } } "


    if {[string compare [evaluate "$contour -selectionMode"] "edge"]== 0} {
    contour::installActiveContour2DEdgeMenu $viewer $camera $contour
    }    
    if {[string compare [evaluate "$contour -selectionMode"] "line"]== 0} {
    contour::installActiveContour2DLineMenu $viewer $camera $contour
    }        
    if {[string compare [evaluate "$contour -selectionMode"] "vertex"]== 0} {
    contour::installActiveContour2DVertexMenu $viewer $camera $contour
    }



    #Defines the menu call with the right button
    set popup [menu $viewer.popup -tearoff 0 -bg "white" -postcommand "scan \[$contour -selectionMode \] {%s} contour::selectionMode;scan \[$camera -motionMode \] {%s} contour::motionMode " ]
    $popup add command -label "Left Button" -state disabled -command {}
    $popup add radio -selectcolor "black" -label "Select Object" -variable contour::selectionMode -value "object" -command "evaluate \"$contour -selectionMode object  $camera\""
    $popup add radio -selectcolor "black" -label "Select Line" -variable contour::selectionMode -value "line" -command "evaluate \"$contour -selectionMode line  $camera\""
    $popup add radio -selectcolor "black" -label "Select Vertex" -variable contour::selectionMode -value "vertex" -command "evaluate \"$contour -selectionMode vertex  $camera\""
    $popup add radio -selectcolor "black" -label "Select Edge" -variable contour::selectionMode -value "edge" -command "evaluate \"$contour -selectionMode edge  $camera\""
    $popup add radio -selectcolor "black" -label "Grab Vertex" -variable contour::selectionMode -value "grab" -command "evaluate \"$contour -selectionMode grab  $camera\""
    $popup add command -label "Middle Button" -state disabled -command {}
    $popup add radio -selectcolor "black" -label "Move Contour" -variable contour::motionMode -value "object" -command "evaluate \"$camera -motionMode object\""
    $popup add radio -selectcolor "black" -label "Move Camera" -variable contour::motionMode -value "camera" -command "evaluate \"$camera -motionMode camera\""
    $popup add separator
    
    bind [$camera -widget] <Button-3> "tk_popup $popup %X %Y"
}


contour::installContour2DInitMenu
Comments  
Arguments parent
camera
init
color
Used by  
Uses  
proc contour::installContour2DInitMenu { parent camera init color } {
    global primitive
    global actionMode
    menubutton $parent.context.object -text "Object" -menu $parent.context.object.mn -bg $color
    set menu [menu $parent.context.object.mn -bg $color]
    $menu add command -label {Nb Vertices...} -command "contour::getNbInitialVertices $init $color"
    $menu add separator
    $menu add command -label {Create Contour2D} -command "evaluate \"$init -createContour contour\""
    $menu add command -label {Create ActiveContour2D} -command "evaluate \"$init -createContour activeContour\""     
    $menu add command -label {Create SliceActiveContour2D} -command "evaluate \"$init -createContour sliceActiveContour\""
    $menu add separator
    $menu add command -label destroy -command "evaluate \"$init -destroy\""
    menubutton $parent.context.prim -text "Primitive" -menu $parent.context.prim.mn -bg $color
    set menu [menu $parent.context.prim.mn -bg $color -tearoff 0  -postcommand "scan \[$init -primitive \] {%s} contour::primitive"]
    $menu add radio -variable contour::primitive -value "circle" -selectcolor "black" -label Circle -command "evaluate \"$init -primitive circle\""
    $menu add radio -variable contour::primitive -value "ellipse" -selectcolor "black" -label Ellipse -command "evaluate \"$init -primitive ellipse\""
    $menu add radio -variable contour::primitive -value "rectangle" -selectcolor "black" -label Rectangle -command "evaluate \"$init -primitive rectangle\""
    $menu add radio -variable contour::primitive -value "closedPolygon" -selectcolor "black" -label {Closed Polygon} -command "evaluate \"$init -primitive closedPolygon\""
    $menu add radio -variable contour::primitive -value "openPolygon" -selectcolor "black" -label {Open Polygon} -command "evaluate \"$init -primitive openPolygon\""
    pack $parent.context.object $parent.context.prim -side left
    pack $parent.context

    evaluate "$init -actionMode create $camera"
    set popup [ menu $parent.popup -tearoff 0 -bg "white" -postcommand "scan \[$init -actionMode \] {%s} contour::actionMode" ]
    $popup add command -label "Left Button" -state disabled -command {}
    $popup add radio -label "Create" -variable contour::actionMode -value "create" -selectcolor "black" -command  "evaluate \"$init -actionMode create $camera\""
    $popup add radio -label "Move" -variable contour::actionMode -value "move" -selectcolor "black" -command  "evaluate \"$init -actionMode move $camera\""
    $popup add radio -label "Edit" -variable contour::actionMode -value "edit" -selectcolor "black" -command  "evaluate \"$init -actionMode edit $camera\""
    $popup add radio -label "Delete" -variable contour::actionMode -value "delete" -selectcolor "black" -command  "evaluate \"$init -actionMode delete $camera\""
    bind [$camera -widget] <Button-3> "tk_popup $popup %X %Y"

    #    bind [$camera -widget] <ButtonPress-1> "$init -buttonPressed $camera %x %y"
    bind [$camera -widget] <ButtonRelease-1> "bind [$camera -widget] <B1-Motion> \"\" "
}


contour::installContourDisplayMenu
Comments  
Arguments viewer
camera
contour
bg
Used by contour::installContourMenu
Uses modules::selectColor
proc contour::installContourDisplayMenu { viewer camera contour bg } {
    global showVertex

    menubutton $viewer.context.display -text "Display" -menu $viewer.context.display.m -anchor w -bg $bg
    set mdisplay [menu $viewer.context.display.m -bg $bg ]
    $mdisplay add command -label "Line Color..." -command "set col \[ modules::selectColor  \[ $contour -lineColor\] \]; evaluate \"$contour -lineColor \[lindex \$col 0\] \[lindex \$col 1\] \[lindex \$col 2\] \""
    $mdisplay add cascade -label "Line Size" -menu   $mdisplay.sub2
    set m2 [menu  $mdisplay.sub2 -tearoff 0]
    $m2 add command -label "1" -command "evaluate \"$contour -lineWidth 1\""
    $m2 add command -label "2" -command "evaluate \"$contour -lineWidth 2\""
    $m2 add command -label "3" -command "evaluate \"$contour -lineWidth 3\""
    $m2 add command -label "4" -command "evaluate \"$contour -lineWidth 4\""

    $mdisplay add cascade -label "Show Vertex" -menu   $mdisplay.sub3
    menu  $mdisplay.sub3 -tearoff 0 -postcommand "scan \[$contour -vertexMode \] {%s} a; switch \$a { show {set contour::showVertex show} hide {set contour::showVertex hide}}"
    $mdisplay.sub3 add radio -selectcolor "black" -label "Show Vertices" -variable contour::showVertex -value "show" -command "evaluate \"$contour -vertexMode show\""
    $mdisplay.sub3 add radio  -selectcolor "black" -label "Hide Vertices" -variable contour::showVertex -value "hide" -command "evaluate \"$contour -vertexMode hide\""

    $mdisplay add cascade -label "Vertex Size" -menu   $mdisplay.sub4
    set m4 [menu  $mdisplay.sub4 -tearoff 0]
    $m4 add command -label "1" -command "evaluate \"$contour -vertexSize 1\""
    $m4 add command -label "2" -command "evaluate \"$contour -vertexSize 2\""
    $m4 add command -label "3" -command "evaluate \"$contour -vertexSize 3\""
    $m4 add command -label "4" -command "evaluate \"$contour -vertexSize 4\""
    $m4 add command -label "5" -command "evaluate \"$contour -vertexSize 5\""
    
    $mdisplay add command -label "Vertex Color..." -command "set col \[ modules::selectColor  \[ $contour -vertexColor\] \]; evaluate \"$contour -vertexColor \[lindex \$col 0\] \[lindex \$col 1\] \[lindex \$col 2\] \""
    pack  $viewer.context.display -side left
}


contour::installContourExternalMenu
Comments  
Arguments viewer
camera
contour
bg
Used by  
Uses imagedata::editRangeInformation
imagedata::createRangeInformation
proc contour::installContourExternalMenu { viewer camera contour bg} {
    menubutton $viewer.context.external -text "External Constraints" -menu $viewer.context.external.m -anchor w -bg $bg
    set mn [menu $viewer.context.external.m -bg $bg -tearoff 0 ]
    $mn add command -label "Edit Range Information" -command " if [string compare [isModuleLoaded tclImageData] no] { imagedata::editRangeInformation \[$contour -rangeInformation\]}"
    $mn add cascade -label "Set New Range Information" -menu $mn.new
    set mn2 [menu $mn.new -bg $bg -tearoff 0 ]
    if [string compare [isModuleLoaded tclImageData] no] { imagedata::createRangeInformation $mn.new $contour $bg }
    pack $viewer.context.external -side left
}


contour::installContourFileMenu
Comments  
Arguments viewer
camera
contour
bg
Used by simulation::installActiveTubeMenu
contour::installContourMenu
Uses  
proc contour::installContourFileMenu { viewer camera contour bg} {
    menubutton $viewer.context.file -text "File" -menu $viewer.context.file.m -anchor w -bg $bg
    set mfile [menu $viewer.context.file.m -bg $bg]
    $mfile add command -label "Load Contour..."  -command  "evaluate \"[$camera -scene] -load \[tk_getOpenFile -filetypes {{\"Contour\" {* } } } -parent . -title {Select a Lines3D}\] \""
    $mfile add command -label "Save Contour" -command "evaluate \"$contour -save \""
    $mfile add command -label "Save Contour as..." -command "contour::saveOption $contour {{\"Contour\" {* } } } {Select a Contour name}"
    $mfile add command -label "Save Contour as Maple File..." -command "evaluate \"$contour -saveAsMaple \[ tk_getSaveFile -filetypes \{{\"Maple File\" {*.txt } }\} -title \{Select Maple File\}\]\""
    $mfile add separator
    $mfile add cascade -label "Create Line" -menu $mfile.line
    menu $mfile.line -tearoff 0 -bg $bg
    if [ string match $contour sact2D*] {
    $mfile.line add command -label "Opened Line" -command "evaluate \"$contour -createLine open\"; $contour -selectionMode addVertex"
    $mfile.line add command -label "Closed Line" -command "evaluate \"$contour -createLine closed\"; $contour -selectionMode addVertex"
    }    else    {
    $mfile.line add command -label "Opened Line" -command "evaluate \"$contour -createLine open \[$camera -slice\] \"; $contour -selectionMode addVertex $camera"
    $mfile.line add command -label "Closed Line" -command "evaluate \"$contour -createLine closed \[$camera -slice\] \"; $contour -selectionMode addVertex $camera"        
    }
    $mfile add cascade -label "Add Contour" -menu $mfile.contours
    menu $mfile.contours -tearoff 0 -bg $bg -postcommand "
        $mfile.contours  delete 0 last
    foreach {i} \[ which \[$contour -kind\] \] {
        if \[ string compare \$i $contour\] { $mfile.contours  add command -label \$i -command \"evaluate {$contour -addContour \$i} \"  }
}


contour::installContourInternalMenu
Comments  
Arguments viewer
camera
contour
bg
Used by simulation::installActiveTubeMenu
Uses  
proc contour::installContourInternalMenu { viewer camera contour bg} {
    variable timeScheme
    menubutton $viewer.context.internal -text "Internal Constraints" -menu $viewer.context.internal.m -anchor w -bg $bg
    set minternal [menu $viewer.context.internal.m -bg $bg]
    $minternal add command -label "Internal Parameters..." -command "contour::internalParameters $contour "
    $minternal add command -label "Internal Force Type..." -command "contour::internalForce2D $contour "
    $minternal add cascade -label "Time Integration Scheme" -menu   $minternal.sub1
    set m1 [menu  $minternal.sub1 -tearoff 0 -postcommand "scan \[$contour -timeScheme \] {%s} contour::timeScheme"]
    $m1 add radio -label "Explicit" -command "evaluate \"$contour -timeScheme explicit\"" -selectcolor "black" -variable contour::timeScheme -value "explicit"
    $m1 add radio -label "Semi-Implicit" -command "evaluate \"$contour -timeScheme semiImplicit\""  -selectcolor "black" -variable contour::timeScheme -value "semiImplicit"
    $minternal add command -label "Force Constraint..." -command "contour::forceConstraint2D $contour "
    $minternal add command -label "Position Constraint..." -command "contour::positionConstraint2D $contour "
    pack  $viewer.context.internal -side left
}


contour::installContourLineMenu
Comments  
Arguments viewer
camera
line
Used by contour::installActiveContour2DLineMenu
Uses modules::selectColor
proc contour::installContourLineMenu { viewer camera line } {
    set bg [$viewer cget -background]
    menubutton $viewer.context.line -text "Line" -menu $viewer.context.line.m -anchor w -bg $bg    
    set mline [menu $viewer.context.line.m -bg $bg]
    $mline add command -label "Selected Line Color..." -command "set col \[ modules::selectColor  \[ $line -selectedLineColor\] \]; evaluate \"$line -selectedLineColor \[lindex \$col 0\] \[lindex \$col 1\] \[lindex \$col 2\]\" "
    $mline add command -label "Remove Line" -command "evaluate \"$line -removeLine\" "
    $mline add command -label "Close Line" -command "evaluate \"$line -closeLine\""
    $mline add command -label "Display Spacing/Curvature Graph" -command "evaluate \"$line -displaySpacingCurvature\""
    $mline add command -label "Display Curvature Profile Graph" -command "evaluate \"$line -displayCurvatureProfile\""
    if ![string match $line sact2D*] {
    #    $viewer.context.file.m add command -label "Propagate Next Slice" -command
    #    $viewer.context.file.m add command -label "Propagate Previous Slice" -command "evaluate \"$contour -duplicate [expr \[ $contour -sliceNumber \] - 1 ]\""
    $mline add command -label "Change Slice Number..." -command "contour::sliceContourNumber $line $camera"
    $mline add command -label "Propagate Next  Slice" -command "evaluate \"$line -duplicateLine \[expr \[ $line -sliceNumber \] + 1 \]\""
    $mline add command -label "Propagate Previous  Slice" -command "evaluate \"$line -duplicateLine \[expr \[ $line -sliceNumber \] - 1 \]\""
    }
    pack  $viewer.context.line -side left
}


contour::installContourMenu
Comments  
Arguments viewer
camera
contour
bg
Used by  
Uses contour::installContourDisplayMenu
contour::installContourFileMenu
proc contour::installContourMenu { viewer camera contour bg } {
    contour::installContourFileMenu $viewer $camera $contour $bg
    contour::installContourDisplayMenu $viewer $camera $contour $bg
    #Defines the menu call with the right button
    set popup [menu $viewer.popup -tearoff 0 -bg "white" -postcommand "scan \[$contour -selectionMode \] {%s} contour::selectionMode;scan \[$camera -motionMode \] {%s} contour::motionMode " ]
    $popup add command -label "Left Button" -state disabled -command {}
    $popup add radio -selectcolor "black" -label "Select Object" -variable contour::selectionMode -value "object" -command "evaluate \"$contour -selectionMode object  $camera\""
    $popup add radio -selectcolor "black" -label "Select Line" -variable contour::selectionMode -value "line" -command "evaluate \"$contour -selectionMode line  $camera\""
    $popup add radio -selectcolor "black" -label "Select Vertex" -variable contour::selectionMode -value "vertex" -command "evaluate \"$contour -selectionMode vertex  $camera\""
    $popup add radio -selectcolor "black" -label "Move Vertex" -variable contour::selectionMode -value "moveVertex" -command "evaluate \"$contour -selectionMode moveVertex  $camera\""
    $popup add radio -selectcolor "black" -label "Add Vertex" -variable contour::selectionMode -value "addVertex" -command "evaluate \"$contour -selectionMode addVertex  $camera\""
    $popup add radio -selectcolor "black" -label "Insert Vertex" -variable contour::selectionMode -value "insertVertex" -command "evaluate \"$contour -selectionMode insertVertex  $camera\""
    $popup add command -label "Middle Button" -state disabled -command {}
    $popup add radio -selectcolor "black" -label "Move Contour" -variable contour::motionMode -value "object" -command "evaluate \"$contour -motionMode $camera contour\""
    $popup add radio -selectcolor "black" -label "Move Line" -variable contour::motionMode -value "cameraObject" -command "evaluate \"$contour -motionMode $camera line\""
    $popup add radio -selectcolor "black" -label "Move Camera" -variable contour::motionMode -value "camera" -command "evaluate \"$contour -motionMode $camera camera\""
    $popup add separator
    
    bind [$camera -widget]  <Button-3> "tk_popup $popup %X %Y"
}


contour::installContourVertexMenu
Comments  
Arguments viewer
camera
line
Used by contour::installActiveContour2DVertexMenu
Uses imagedata::createRangeInformation
imagedata::editRangeInformation
modules::selectColor
proc contour::installContourVertexMenu { viewer camera line } {
    set bg [$viewer cget -background]
    menubutton $viewer.context.vertex -text "Vertex" -menu $viewer.context.vertex.m -anchor w -bg $bg
    set mvertex [menu $viewer.context.vertex.m -bg $bg]
    $mvertex add command -label "Selected Vertex Color..." -command "set col \[ modules::selectColor  \[ $line -selectedVertexColor\] \]; evaluate \"$line -selectedVertexColor \[lindex \$col 0\] \[lindex \$col 1\] \[lindex \$col 2\] \""

    $mvertex add command -label "Vertex Info..." -command "set val {};foreach f \[ $line -vertexParameter \] {set val \"\$val \$f : \[ $line -vertexParameter \$f \] \n\"};  tk_messageBox -message \$val "
    $mvertex add command -label "Edit Range Information" -command " if [string compare [isModuleLoaded tclImageData] no] { imagedata::editRangeInformation \[$line -vertexParameter -rangeInformation\]}"
    $mvertex add cascade -label "Set New Range Information" -menu $mvertex.new
    set mn2 [menu $mvertex.new -bg $bg -tearoff 0 ]
    if [string compare [isModuleLoaded tclImageData] no] { imagedata::createRangeInformation $mvertex.new "$line -vertexParameter" $bg }
    pack  $viewer.context.vertex -side left
}


contour::installSliceActiveContour2DMenu
Comments  
Arguments viewer
camera
contour
bg
Used by  
Uses contour::installActiveContour2DMenu
imagedata::editIntensityProfileDialog
proc contour::installSliceActiveContour2DMenu { viewer camera contour bg } {
    contour::installActiveContour2DMenu $viewer $camera $contour $bg
    $viewer.context.file.m add separator
    $viewer.context.file.m add command -label "Create 3D Interface" -command "evaluate \" new cam3D\";evaluate \" new sct3D $contour\" "
    $viewer.context.file.m add command -label "Slice Geometry.." -command "contour::sliceContourGeometry $contour $camera"

    set mn $viewer.context.external.m
    $mn add command -label "Store Intensity Profiles..." -command "contour::storeIntensityProfileDialog $contour 2D"
    $mn add command -label "Edit Intensity Profiles..." -command "set rinfs \[ $contour -rangeInformationSet \]; if \[ string compare \$rinfs \"Intensity Profile\" \] { if \[string compare \[isModuleLoaded tclImageData \] no \] { imagedata::editIntensityProfileDialog \[ new ipinfos \$rinfs \]  } } "

}


contour::installSliceContour3DMenu
Comments  
Arguments viewer
camera
contour
bg
Used by  
Uses contour::getSliceDistance
proc contour::installSliceContour3DMenu { viewer camera contour bg } {
    menubutton $viewer.context.file -text "File" -menu $viewer.context.file.m -anchor w -bg $bg
    set mfile [menu $viewer.context.file.m -bg $bg]
    $mfile add cascade -label "Slice Distance" -menu $mfile.inr
    menu $mfile.inr -bg $bg -tearoff 0 -postcommand "
        $mfile.inr delete 0 last
        foreach {i} \[ which inr \] {
           $mfile.inr add command -label \$i -command \"evaluate {$contour -sliceDistance \[ contour::getSliceDistance $contour \$i \] } \"
         }"
    $mfile add separator
    $mfile add command -label "Destroy" -command "evaluate \"$contour -destroy \""
    pack  $viewer.context.file -side left
    #Defines the menu call with the right button
    set popup [menu $viewer.popup -tearoff 0 -bg "white" -postcommand "scan \[$contour -selectionMode \] {%s} contour::selectionMode;scan \[$camera -motionMode \] {%s} contour::motionMode " ]
    $popup add command -label "Left Button" -state disabled -command {}
    $popup add radio -selectcolor "black" -label "Select Object" -variable contour::selectionMode -value "object" -command "evaluate \"$contour -selectionMode object  $camera\""
    $popup add radio -selectcolor "black" -label "Select Line" -variable contour::selectionMode -value "line" -command "evaluate \"$contour -selectionMode line  $camera\""
    $popup add radio -selectcolor "black" -label "Select Vertex" -variable contour::selectionMode -value "vertex" -command "evaluate \"$contour -selectionMode vertex  $camera\""
    
    bind [$camera -widget]  <Button-3> "tk_popup $popup %X %Y"
}


contour::internalForce2D
Comments  
Arguments contour
Used by  
Uses  
proc contour::internalForce2D { contour } {
    global forceType
    #    global extremityType
    if {![winfo exists .dialogInternalForce2D]} {
    set bg #A0D0A0
    set bg2  #80C080
    set root .dialogInternalForce2D
    toplevel $root -bg $bg
    wm title $root "ActiveContour Internal Force"


    set mn [tk_optionMenu $root.item deformableItem Contour]
    $root.item  configure -bg $bg2

    for {set i 0} {$i <= [$mn index last]} {incr i} {
        $mn entryconfigure $i -selectcolor black -command "contour::displayInternalForce2D $contour \[$mn entrycget $i -label\] \$forceType" -background $bg2
    }
    pack $root.item -padx 10 -pady 10 -expand true -fill x

    set mn2 [ eval {tk_optionMenu $root.type forceType} [$contour -listAvailableInternalForces]]


    $root.type  configure -bg $bg2

    for {set i 0} {$i <= [$mn2 index last]} {incr i} {
        $mn2 entryconfigure $i -selectcolor black -command "contour::displayInternalForce2D $contour \$deformableItem \[$mn2 entrycget $i -label\]" -background $bg2
    }
    pack $root.type -padx 10 -pady 10 -expand true -fill x

    
    frame $root.f -bg $bg
    pack $root.f -expand true -fill both

    frame $root.buttons -bg $bg
    button $root.buttons.apply -text Apply -command "contour::setInternalForce2D $contour \$deformableItem \$forceType" -bg $bg2
    button $root.buttons.applyDismiss -text "Apply & Dismiss" -command "contour::setInternalForce2D $contour \$deformableItem \$forceType;destroy $root" -bg $bg2
    button $root.buttons.destroy -text "Destroy" -command "destroy $root" -bg $bg2
    pack $root.buttons.apply $root.buttons.applyDismiss  $root.buttons.destroy -side left -expand true -fill both -padx 20 -pady 10
    pack $root.buttons -expand true -fill both

    set forceType [$contour -internalForce]
    contour::displayInternalForce2D $contour "Contour" $forceType
    }
}


contour::internalParameters
Comments  
Arguments line
Used by  
Uses  
proc contour::internalParameters {line } {
    global ipvalue
    
    if {![winfo exists .dialogInternal]} {
    set bg #A0D0A0
    toplevel .dialogInternal -bg $bg
    wm title .dialogInternal "Contour internal parameters"
    
    scale .dialogInternal.alpha -orient horizontal -label Alpha -from 0 -to 1 -length 200 -resolution 0.01 -bg $bg
    
    scale .dialogInternal.beta -orient horizontal -label Beta -from 0 -to 1 -length 200 -resolution 0.01 -bg $bg

    scale .dialogInternal.locality -orient horizontal -label Locality -from 0 -to 1 -length 200 -resolution 0.01 -bg $bg

    scale .dialogInternal.damping -orient horizontal -label Damping -from 0 -to 1 -resolution 0.01 -length 200 -bg $bg

    scale .dialogInternal.rigidity -orient horizontal -label Rigidity -from 0 -to [$line -contourParameter maximumRigidity] -length 200 -bg $bg
    
    button .dialogInternal.ok -text "Dismiss" -command "destroy .dialogInternal" -bg $bg
    
    set optionMenu [tk_optionMenu .dialogInternal.menu contour::ipvalue Contour "Selected Vertex" ]
    .dialogInternal.menu configure -bg $bg
    for {set i 0} {$i <= [$optionMenu index last]} {incr i} {
        $optionMenu entryconfigure $i -selectcolor black -command "contour::setInternalParameters $line \"[$optionMenu entrycget $i -label]\"" -background $bg
    }

    pack .dialogInternal.menu -padx 10 -pady 10
    pack .dialogInternal.alpha .dialogInternal.beta .dialogInternal.locality .dialogInternal.damping .dialogInternal.rigidity -padx 10 -pady 5
    pack .dialogInternal.ok -padx 10 -pady 20

    contour::setInternalParameters $line Contour
    }
}


contour::moveSliceCameras
Comments  
Arguments contour
slice
Used by  
Uses  
proc contour::moveSliceCameras { contour slice } {
    set scene [ $contour -scene ]
    foreach sc [which slicecam] {
    if ![string compare $scene [ $sc -scene ] ] {
        if ![ string compare [ $sc -geometry ] [$contour -sliceGeometry] ] {
        $sc -slice $slice
        }
    }
    }
}


contour::positionConstraint2D
Comments  
Arguments contour
Used by  
Uses contour::editPositionConstraint2D
proc contour::positionConstraint2D { contour } {
    set root .positionConstraint2D
    if {![winfo exists $root]} {
    set bg #A0D0A0
    set bg2  #80C080
    toplevel $root -bg $bg
    wm title $root "ActiveContour2D Position Constraint"
    label $root.msg -justify center -text "List of Position Constraints" -bg $bg
    pack $root.msg  -side top
    
    frame $root.f -borderwidth .5c -bg $bg
    pack $root.f -side top -expand yes -fill y
    
    scrollbar $root.f.scroll -command "$root.f.list yview" -bg $bg
    listbox $root.f.list -yscroll "$root.f.scroll set" -setgrid 1 -height 12 -bg $bg
    pack $root.f.scroll -side right -fill y
    pack $root.f.list -side left -expand 1 -fill both

    set nbConstraints [$contour -positionConstraint]
    for { set i 0 } { $i < $nbConstraints } { incr i } {
        $root.f.list insert $i [$contour -positionConstraint $i ]
    }

    frame $root.process -bg $bg
    pack $root.process -side top -pady 2m
    menubutton $root.process.create -text "Create Constraint" -bg $bg -underline 0 -direction above -menu $root.process.create.m -relief raised
    menu $root.process.create.m -tearoff 0
    $root.process.create.m add command -label "Distance Constraint" -command "destroy $root;contour::distanceConstraint $contour 5 \[ $contour -edgeLength min\] \[ $contour -edgeLength min\]  "
    $root.process.create.m add command -label "Rectangle Constraint" -command "destroy $root;contour::rectangleConstraint $contour 5  [contour::getImageSize $contour] "
    $root.process.create.m add command -label "Spacing Constraint" -command "destroy $root;contour::spacingConstraint $contour 5 0.75 1.5 "
    $root.process.create.m add command -label "Topology Constraint" -command "destroy $root;contour::topologyConstraint $contour 5 \[ expr \[ $contour -edgeLength min\]  *1.5 \] 8 true"
    $root.process.create.m add command -label "Curvature Spacing Constraint" -command "if { !\[ string compare \[ $contour -curvatureSpacingConstraint \] {none} \] } { destroy $root;contour::curvatureSpacingConstraint $contour 8 0.5  }"
    button $root.process.edit -text "Edit Constraint" -bg $bg -command " contour::editPositionConstraint2D \[ $root.f.list get \[ lindex \[ $root.f.list curselection \] 0 \] \] $contour; destroy $root"
    button $root.process.delete -text "Delete Constraint" -bg $bg -command "$contour -positionConstraint \[ lindex \[ $root.f.list curselection \] 0 \] delete;destroy $root"
    pack $root.process.create $root.process.edit $root.process.delete -side top -expand 1

    frame $root.button -bg $bg
    pack $root.button -side bottom -pady 2m
    button $root.button.dismiss -text Dismiss -command "destroy $root" -bg $bg
    pack  $root.button.dismiss -side left -expand 1
    }
}


contour::rectangleConstraint
Comments  
Arguments contour
frequency
p1x
p1y
p2x
p2y
Used by contour::editPositionConstraint2D
Uses  
proc contour::rectangleConstraint { contour frequency p1x p1y p2x p2y} {
    set root .distanceConstraint2D
    if {![winfo exists $root]} {
    set bg #A0D0A0
    set bg2  #80C080
    toplevel $root -bg $bg
    wm title $root "Rectangle Constraint"
    
    frame $root.f -bg $bg

    frame $root.f.freq -bd 2 -bg $bg
    entry $root.f.freq.entry -relief sunken -width 10 -bg $bg
    $root.f.freq.entry delete 0 10
    $root.f.freq.entry insert 0 $frequency
    label $root.f.freq.label -text "Frequency" -bg $bg
    pack $root.f.freq.entry -side right -padx 20
    pack $root.f.freq.label -side left -padx 20

    frame $root.f.p1 -bd 2 -bg $bg
    entry $root.f.p1.x -relief sunken -width 10 -bg $bg
    $root.f.p1.x delete 0 10
    $root.f.p1.x insert 0 $p1x
    entry $root.f.p1.y -relief sunken -width 10 -bg $bg
    $root.f.p1.y delete 0 10
    $root.f.p1.y insert 0 $p1y
    label $root.f.p1.label -text "Corner 1" -bg $bg
    pack $root.f.p1.x  $root.f.p1.y -side right -padx 20
    pack $root.f.p1.label -side left -padx 20

    frame $root.f.p2 -bd 2 -bg $bg
    entry $root.f.p2.x -relief sunken -width 10 -bg $bg
    $root.f.p2.x delete 0 10
    $root.f.p2.x insert 0 $p2x
    entry $root.f.p2.y -relief sunken -width 10 -bg $bg
    $root.f.p2.y delete 0 10
    $root.f.p2.y insert 0 $p2y
    label $root.f.p2.label -text "Corner 2" -bg $bg
    pack $root.f.p2.x  $root.f.p2.y -side right -padx 20
    pack $root.f.p2.label -side left -padx 20

    pack  $root.f.freq  $root.f.p1 $root.f.p2 -side top -fill x
    pack $root.f -expand true -fill both
    
    frame $root.buttons -bg $bg
    button $root.buttons.apply -text Apply -command "evaluate \"$contour -rectangleConstraint \[$root.f.freq.entry get\] \[$root.f.p1.x get\]  \[$root.f.p1.y get\]  \[$root.f.p2.x get\]  \[$root.f.p2.y get\]\"" -bg $bg
    button $root.buttons.applyDismiss -text "Apply & Dismiss" -command "evaluate \"$contour -rectangleConstraint \[$root.f.freq.entry get\] \[$root.f.p1.x get\]  \[$root.f.p1.y get\]  \[$root.f.p2.x get\]  \[$root.f.p2.y get\]\";destroy $root" -bg $bg
    button $root.buttons.destroy -text "Destroy" -command "destroy $root" -bg $bg
    pack $root.buttons.apply $root.buttons.applyDismiss  $root.buttons.destroy -side left -expand true -fill both -padx 20 -pady 10
    pack $root.buttons -expand true -fill both
    }
}


contour::saveOption
Comments  
Arguments object
fileType
windowTitle
Used by  
Uses  
proc contour::saveOption { object fileType windowTitle} {
    set root .contourSave
    if {![winfo exists $root]} {
    set bg "#A0D0A0"
    set bg2  "#80C080"
    toplevel $root -bg $bg
    wm title $root "Contour Save"
    frame $root.f -bg $bg

    foreach f [$object -saveOption] {
        set name $root.f.[string tolower $f]
        set $f.save [$object -saveOption $f]
        checkbutton $name  -text $f -variable $f.save -relief flat -bg $bg -onvalue {true} -offvalue {false}
        if {[$object -saveOption $f]}  {
        $name select
        } else {
        $name deselect
        }
        pack $name -side top -expand true -fill both
    }
    pack $root.f -side top
    frame $root.buttons -bg $bg
    button $root.buttons.save -text "Save" -command "destroy $root;  foreach f \[$object -saveOption\] {evaluate \"$object -saveOption \$f \[subst $\\{\$f.save\\} \]\"}; evaluate \"$object -save \[ tk_getSaveFile -filetypes \{$fileType\} -title \{$windowTitle\}\]\"" -bg $bg
    button $root.buttons.destroy -text "Dismiss" -command "evaluate \"destroy $root\"" -bg $bg
    pack $root.buttons.save  $root.buttons.destroy -side left -expand true -fill both -padx 20 -pady 10
    pack $root.buttons -expand true -fill both
    }
}


contour::setBoundaryConditions2D
Comments  
Arguments contour
boundary
extremity
Used by  
Uses  
proc contour::setBoundaryConditions2D { contour boundary extremity } {
    switch $boundary {
    "Position" { set boundaryName "position"; set scalar 0  }
    "Tangent" { set boundaryName "tangent"; set scalar 0  }
    "First Derivative" { set boundaryName "1rstDerivative"; set scalar 0  }
    "Second Derivative" { set boundaryName "2ndDerivative"; set scalar 0 }
    "Curvature" { set boundaryName "curvature"; set scalar 1}
    "Simplex Angle" { set boundaryName "simplexAngle"; set scalar 1}
    }

    switch $extremity {
    "First End" { set extremityName "first" }
    "Last End" { set extremityName "last" }
    }
    if {$scalar == 0} {
    evaluate "$contour -boundaryCondition $boundaryName $extremityName [.dialogBoundaryCondition2D.f.tx.entry get] [.dialogBoundaryCondition2D.f.ty.entry get]"
    }
    if {$scalar == 1} {
    evaluate "$contour -boundaryCondition $boundaryName $extremityName [.dialogBoundaryCondition2D.f.val.entry get] "
    }
}


contour::setInternalForce2D
Comments  
Arguments contour
item
force
Used by  
Uses  
proc contour::setInternalForce2D { contour item force } {
    switch $item {
    "Contour" { set itemName "internalForce" }
    }
    switch $force {
    "Spring-Mass" { if { $contour::setRestLength == 1 } {
        $contour -setRestLength }
    }
    "Simplex C2" {
        if { $contour::setMetricParameters == 1 } {
        $contour -metricParameters set }
        if { $contour::resetMetricParameters == 1 } {
        $contour -metricParameters reset }
    }
    }
    evaluate " $contour -$itemName \"$force\" "
}


contour::setInternalParameters
Comments  
Arguments line
label
Used by  
Uses  
proc contour::setInternalParameters {line label} {
    
    if {[winfo exists .dialogInternal]} {
    switch $label {
        "Contour" { set option "-contourParameter" }
        "Selected Vertex" { set option "-vertexParameter" }
    }
    
    .dialogInternal.alpha set [$line $option alpha]
    .dialogInternal.beta set [$line $option beta]
    .dialogInternal.locality set [$line $option locality]
    .dialogInternal.damping set [$line $option damping]
    .dialogInternal.rigidity set [$line $option rigidity]
    #        
    bind .dialogInternal.alpha <ButtonRelease-1> "evaluate \"$line $option alpha  \[.dialogInternal.alpha get\]\" "
    bind .dialogInternal.beta <ButtonRelease-1> "evaluate \"$line $option beta  \[.dialogInternal.beta get\]\" "
    bind .dialogInternal.locality <ButtonRelease-1> "evaluate \"$line $option locality  \[.dialogInternal.locality get\] \" "
    bind .dialogInternal.damping <ButtonRelease-1> "evaluate \"$line $option damping  \[.dialogInternal.damping get\] \""
    bind .dialogInternal.rigidity <ButtonRelease-1> "evaluate \"$line $option rigidity  \[.dialogInternal.rigidity get\] \" "
    }
}


contour::setPrimitive
Comments  
Arguments camera
init
x
y
Used by  
Uses  
proc contour::setPrimitive { camera init x y } {
    global result
    [$camera -widget] dtag selected
    [$camera -widget] addtag selected closest $x $y

    set tagList [split [[$camera -widget] gettags selected ] ]

    foreach t $tagList {
    if {[string match  "primitive$init*" $t] } {
        set name [ format "primitive%sn" $init ]
        scan $t "$name%d" result
        evaluate "$init -selectedPrimitive $result"
        evaluate "$init -buttonPressed $camera $x $y"
    }
    }
}


contour::sliceContourGeometry
Comments  
Arguments contour
camera
Used by  
Uses  
proc contour::sliceContourGeometry { contour camera} {
    global sliceGeom
    set root .sliceContourGeometry
    if {![winfo exists $root]} {
    set bg "#A0D0A0"
    set bg2  "#80C080"
    toplevel $root -bg $bg
    wm title $root "Slice Geometry"
    
    frame $root.f -bg $bg
    
    frame $root.f.sliceGeometry -bd 2 -bg $bg
    set mn [tk_optionMenu $root.f.sliceGeometry.type sliceGeom "X" "Y" "Z" "alpha"]
    $root.f.sliceGeometry.type configure -bg $bg2
    pack $root.f.sliceGeometry.type
    set sliceGeom [$contour -sliceGeometry]
    
    pack  $root.f.sliceGeometry -side top -fill x
    pack $root.f -expand true -fill both

    frame $root.buttons -bg $bg
    button $root.buttons.applyDismiss -text "Apply & Dismiss" -command "evaluate \"$contour -sliceGeometry \$sliceGeom\";$camera -redraw;destroy $root" -bg $bg
    button $root.buttons.destroy -text "Destroy" -command "destroy $root" -bg $bg
    pack $root.buttons.applyDismiss  $root.buttons.destroy -side left -expand true -fill both -padx 20 -pady 10
    pack $root.buttons -expand true -fill both
    }
}


contour::sliceContourNumber
Comments  
Arguments contour
camera
Used by  
Uses  
proc contour::sliceContourNumber { contour camera} {
    set root .sliceContourNumber
    if {![winfo exists $root]} {
    set bg "#A0D0A0"
    set bg2  "#80C080"
    toplevel $root -bg $bg
    wm title $root "Slice Number"
    
    frame $root.f -bg $bg
    
    frame $root.f.sliceNb -bd 2 -bg $bg
    entry $root.f.sliceNb.entry -relief sunken -width 10 -bg $bg
    $root.f.sliceNb.entry delete 0 10
    $root.f.sliceNb.entry insert 0 [$contour -sliceNumber]
    label $root.f.sliceNb.label -text "Slice Number" -bg $bg
    pack $root.f.sliceNb.entry -side right -padx 20
    pack $root.f.sliceNb.label -side left -padx 20

    pack  $root.f.sliceNb  -side top -fill x
    pack $root.f -expand true -fill both

    frame $root.buttons -bg $bg
    button $root.buttons.applyDismiss -text "Apply & Dismiss" -command "evaluate \"$contour -sliceNumber \[$root.f.sliceNb.entry get\]\"; $camera -redraw;destroy $root" -bg $bg
    button $root.buttons.destroy -text "Destroy" -command "destroy $root" -bg $bg
    pack $root.buttons.applyDismiss  $root.buttons.destroy -side left -expand true -fill both -padx 20 -pady 10
    pack $root.buttons -expand true -fill both
    }

}


contour::spacingConstraint
Comments  
Arguments contour
frequency
ar
minDistance
maxDistance
Used by contour::editPositionConstraint2D
Uses  
proc contour::spacingConstraint { contour frequency ar minDistance maxDistance} {
    set root .distanceConstraint2D
    if {![winfo exists $root]} {
    variable ar
    set bg #A0D0A0
    set bg2  #80C080
    toplevel $root -bg $bg
    wm title $root "Spacing Constraint"
    
    frame $root.f -bg $bg

    frame $root.f.freq -bd 2 -bg $bg
    entry $root.f.freq.entry -relief sunken -width 10 -bg $bg
    $root.f.freq.entry delete 0 10
    $root.f.freq.entry insert 0 $frequency
    label $root.f.freq.label -text "Frequency" -bg $bg
    pack $root.f.freq.entry -side right -padx 20
    pack $root.f.freq.label -side left -padx 20

    set contour::ar $ar
    frame $root.f.ar -bd 2 -bg $bg
    radiobutton $root.f.ar.absolute -text "absolute length" -selectcolor black -value length -bg $bg -relief raised -variable contour::ar
    radiobutton $root.f.ar.relative -text "relative length" -selectcolor black -value ratio -bg $bg -relief raised -variable contour::ar
    pack $root.f.ar.absolute $root.f.ar.relative -side left

    frame $root.f.min -bd 2 -bg $bg
    entry $root.f.min.entry -relief sunken -width 25 -bg $bg
    $root.f.min.entry delete 0 25
    $root.f.min.entry insert 0 $minDistance
    label $root.f.min.label -text "Minimum Spacing" -bg $bg
    pack $root.f.min.entry -side right -padx 20
    pack $root.f.min.label -side left -padx 20

    frame $root.f.max -bd 2 -bg $bg
    entry $root.f.max.entry -relief sunken -width 25 -bg $bg
    $root.f.max.entry delete 0 25
    $root.f.max.entry insert 0 $maxDistance
    label $root.f.max.label -text "Maximum Spacing" -bg $bg
    pack $root.f.max.entry -side right -padx 20
    pack $root.f.max.label -side left -padx 20

    pack  $root.f.freq $root.f.ar $root.f.min $root.f.max -side top -fill x
    pack $root.f -expand true -fill both
    
    frame $root.buttons -bg $bg
    button $root.buttons.apply -text Apply -command "evaluate \"$contour -spacingConstraint \[$root.f.freq.entry get\] \[$root.f.min.entry get\] \[$root.f.max.entry get\]\"" -bg $bg
    button $root.buttons.applyDismiss -text "Apply & Dismiss" -command "evaluate \"$contour -spacingConstraint \[$root.f.freq.entry get\] \[$root.f.min.entry get\] \[$root.f.max.entry get\]\";destroy $root" -bg $bg
    button $root.buttons.destroy -text "Destroy" -command "destroy $root" -bg $bg
    pack $root.buttons.apply $root.buttons.applyDismiss  $root.buttons.destroy -side left -expand true -fill both -padx 20 -pady 10
    pack $root.buttons -expand true -fill both
    }
}


contour::storeIntensityProfile2D
Comments  
Arguments object
range
Used by  
Uses  
proc contour::storeIntensityProfile2D { object range } {
    if [string compare [isModuleLoaded tclImageData] no ] {
    if [ string compare [which rimg2D] "" ] {
        set i 0
        set inr [ [lindex [which rimg2D] 0] -images intensity ]
        for {set i 0} {$i < [$object -getNbVertices] } { incr i} {
        $object -selectVertex $i
        $object -selectLine [ $object -vertexParameter line]
        set vertex v$i
        set p  [ $object -vertexParameter position]
        set d  [ $object -vertexParameter normal]
        scan [ $inr -voxel ] {%f %f %f} vx vy vz
        switch [$object -sliceGeometry] {
            "X" {scan [ $object -vertexParameter position ] {%f %f} pz  py; scan [ $object -vertexParameter normal ] {%f %f } nz ny; set px [ expr [ $object -sliceNumber] * $vx ];set nx 0}
            "Y" {scan [ $object -vertexParameter position ] {%f %f} px  pz; scan [ $object -vertexParameter normal ] {%f %f } nx nz; set py [ expr [ $object -sliceNumber] * $vy ];set ny 0}
            "Z" {scan [ $object -vertexParameter position ] {%f %f} px  py; scan [ $object -vertexParameter normal ] {%f %f } nx ny; set pz [ expr [ $object -sliceNumber] * $vz ];set nz 0}
        }
        set line [new il $inr $px $py $pz $nx $ny $nz  $range ]
        set profile [ new ipinfo $line 50 0 10.0 differences ]
        $line -destroy
        $object -vertexParameter rangeInformation [$profile -cast]
        }
    }
    }
}


contour::storeIntensityProfile3D
Comments  
Arguments object
range
Used by  
Uses  
proc contour::storeIntensityProfile3D { object range } {
    if [string compare [isModuleLoaded tclImageData] no ] {
    if [ string compare [which rimg3D] "" ] {
        set i 0
        set inr [ [lindex [which rimg3D] 0] -images intensity ]
        for {set i 0} {$i < [$object -getNbVertices] } { incr i} {
        $object -selectVertex $i
        set vertex v$i
        scan  [ $object -vertexParameter position] {%f %f %f} px py pz
        scan  [ $object -vertexParameter normal] {%f %f %f} nx ny nz
        set line [new il $inr $px $py $pz $nx $ny $nz  $range ]
        set profile [ new ipinfo $line 50 0 10.0 differences ]
        $line -destroy
        $object -vertexParameter rangeInformation [$profile -cast]
        }
    }
    }
}


contour::storeIntensityProfileDialog
Comments  
Arguments object
name
Used by  
Uses  
proc contour::storeIntensityProfileDialog { object name } {
    set root .storeIntensityProfileContour
    variable rangeIP
    if {![winfo exists $root]} {
    set bg #A0D0A0
    toplevel $root -bg $bg
    wm title $root "2D Contour Intensity Profile Storage"
    frame $root.f -bg $bg
    pack $root.f -expand true -fill both

    frame $root.f.sc -bg $bg
    set contour::rangeIP 10
    scale $root.f.sc.range -label "Range of Intensity Profile" -orient horizontal -variable contour::rangeIP -from 1 -to 30 -resolution 1 -bg $bg -length 200
    pack  $root.f.sc.range  -side left
    pack $root.f.sc -expand true -fill both
    
    frame $root.f.buttons -bg $bg
    button $root.f.buttons.store -text "Store Intensity Profiles" -command "destroy $root;contour::storeIntensityProfile$name $object $contour::rangeIP" -bg $bg
    button $root.f.buttons.dismiss -text Dismiss -command "destroy $root" -bg $bg
    pack $root.f.buttons.store  $root.f.buttons.dismiss -side left
    pack $root.f.buttons -expand true -fill both
    }
}


contour::topologyConstraint
Comments  
Arguments contour
frequency
gridSize
minNbVertices
fuse
Used by contour::editPositionConstraint2D
Uses  
proc contour::topologyConstraint { contour frequency gridSize minNbVertices fuse} {
    set root .topologyConstraint2D
    if {![winfo exists $root]} {
    set bg #A0D0A0
    set bg2  #80C080
    toplevel $root -bg $bg
    wm title $root "Topology Constraint"
    
    frame $root.f -bg $bg

    frame $root.f.freq -bd 2 -bg $bg
    entry $root.f.freq.entry -relief sunken -width 10 -bg $bg
    $root.f.freq.entry delete 0 10
    $root.f.freq.entry insert 0 $frequency
    label $root.f.freq.label -text "Frequency" -bg $bg
    pack $root.f.freq.entry -side right -padx 20
    pack $root.f.freq.label -side left -padx 20

    frame $root.f.size -bd 2 -bg $bg
    entry $root.f.size.entry -relief sunken -width 25 -bg $bg
    $root.f.size.entry delete 0 25
    $root.f.size.entry insert 0 $gridSize
    label $root.f.size.label -text "Grid Size" -bg $bg
    pack $root.f.size.entry -side right -padx 20
    pack $root.f.size.label -side left -padx 20

    frame $root.f.min -bd 2 -bg $bg
    entry $root.f.min.entry -relief sunken -width 10 -bg $bg
    $root.f.min.entry delete 0 10
    $root.f.min.entry insert 0 $minNbVertices
    label $root.f.min.label -text "Minimum Number Vertices" -bg $bg
    pack $root.f.min.entry -side right -padx 20
    pack $root.f.min.label -side left -padx 20

    frame $root.f.fuse -bd 2 -bg $bg
    set fuseContour $fuse
    checkbutton $root.f.fuse.check -variable contour::fuseContour -text "fuse Different Contours" -onvalue {true} -offvalue {false} -relief flat -bg $bg
    if { [ string compare $fuse {false}] } {
        $root.f.fuse.check select } else {
        $root.f.fuse.check deselect }
    pack $root.f.fuse.check -side right -padx 20

    pack  $root.f.freq  $root.f.size  $root.f.min  $root.f.fuse -side top -fill x
    pack $root.f -expand true -fill both
    
    frame $root.buttons -bg $bg
    button $root.buttons.apply -text Apply -command "evaluate \"$contour -topologyConstraint \[$root.f.freq.entry get\] \[$root.f.size.entry get\] \[$root.f.min.entry get\] \$contour::fuseContour \"" -bg $bg
    button $root.buttons.applyDismiss -text "Apply & Dismiss" -command "evaluate \"$contour -topologyConstraint \[$root.f.freq.entry get\] \[$root.f.size.entry get\] \[$root.f.min.entry get\] \$contour::fuseContour\";destroy $root" -bg $bg
    button $root.buttons.destroy -text "Destroy" -command "destroy $root" -bg $bg
    pack $root.buttons.apply $root.buttons.applyDismiss  $root.buttons.destroy -side left -expand true -fill both -padx 20 -pady 10
    pack $root.buttons -expand true -fill both
    }
}


contour::uninstallContour2DInitMenu
Comments  
Arguments parent
camera
init
Used by  
Uses  
proc contour::uninstallContour2DInitMenu { parent camera init } {
    bind [$camera -widget] <Button-3> ""
    bind [$camera -widget] <ButtonPress-1> "$camera -button1Pressed %x %y"
    bind [$camera -widget] <ButtonRelease-1> "$camera -button1Released %x %y"
    bind [$camera -widget] <B1-Motion> ""
    destroy  $parent.context.object
    destroy  $parent.context.prim
    destroy  $parent.popup
}


contour::uninstallContourEdgeMenu
Comments  
Arguments viewer
camera
Used by  
Uses  
proc contour::uninstallContourEdgeMenu { viewer camera } {
    destroy $viewer.context.edge
}


contour::uninstallContourLineMenu
Comments  
Arguments viewer
camera
Used by  
Uses  
proc contour::uninstallContourLineMenu { viewer camera } {
    destroy  $viewer.context.line
}


contour::uninstallContourMenu
Comments  
Arguments viewer
camera
line
Used by SM2::uninstallContourSM2Menu
Uses  
proc contour::uninstallContourMenu { viewer camera line} {
    # remove frame children
    set list [winfo children $viewer.context]
    foreach w $list { destroy $w}
    pack $viewer.context -fill x
    #remove popup
    destroy  $viewer.popup
    #reset selection mode
    $camera -motionMode camera
    #unbind popup
    bind [$camera -widget] <Button-3> ""
}


contour::uninstallContourVertexMenu
Comments  
Arguments viewer
camera
Used by  
Uses  
proc contour::uninstallContourVertexMenu { viewer camera } {
    destroy  $viewer.context.vertex
}