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

tclInrimage.tcl



inrimage
Comments  
Arguments  
Used by  
Uses  
    global busy
    set busy 0
    
    set dispMode WITHOUT_VECTOR
    set longMaxMode MAX2
    set normMode LINEAR
    set arrow true
    set useVoxelSize true
    set useAxis false
    set activate false
    set mval inr1
    set inrslicemenu {jk}
    set theImage {jk}
    set mview multiview1
    
    set operator add
    set operand cst

    set con 4

    set cmd nocrop
    
    set oper binary
    set tcc {}
    set ncc all
    set output binary
    set df perona
    set dt 1.0
    set tmax 3.0
    set smooth false
    set sigma 1.0
    set quant 80.0
    set disk false
    
    set filter rec
    set rfilter deriche
    set dim 3D

    set fromimage 1

}


inrimage::OldaddObjectMenu
Comments  
Arguments name
mname
toff
color
Used by  
Uses simulation::addSimuTetraView
triangulation::addTrianView
tetrahedrisation::addTetraView
proc inrimage::OldaddObjectMenu { name mname {toff 0} {color "#E8E0D2"}} {
    set mn [menu $name -tearoff $toff -bg $color]
    if [string compare [isModuleLoaded tclSM2] no] {
    sm2::addSM2View $mn $mname 0 $color
    }
    if [string compare [isModuleLoaded tclTriangulation] no] {
    triangulation::addTrianView $mn $mname 0 $color
    }
    if [string compare [isModuleLoaded tclTetrahedrisation] no] {
    tetrahedrisation::addTetraView $mn $mname 0 $color
    }
    if [string compare [isModuleLoaded tclSimulation] no] {
    simulation::addSimuTetraView $mn $mname 0 $color
    }
}


inrimage::UpdateTable
Comments  
Arguments root
graph
p1
p2
how
Used by  
Uses  
proc inrimage::UpdateTable { root graph p1 p2 how } {
    table configure $root c0 -width [$graph extents leftmargin]
    table configure $root c2 -width [$graph extents rightmargin]
    table configure $root r1 -height [$graph extents topmargin]
    table configure $root r3 -height [$graph extents bottommargin]
}


inrimage::XYZFrame
Comments  
Arguments fname
title
color
X
Y
Z
valX
valY
valZ
Used by inrimage::melDialog
inrimage::cropDialog
Uses  
proc inrimage::XYZFrame { fname title color X Y Z {valX 0} {valY 0} {valZ 0}} {
    frame $fname -bg $color
    
    label $fname.l -text $title -relief raised -bg $color
    pack $fname.l -fill x
    scale $fname.x -from 0 -to $X -orient horiz -bg $color
    $fname.x set $valX
    bind $fname.x <Enter> "focus $fname.x"
    scale $fname.y -from 0 -to $Y -orient horiz -bg $color
    $fname.y set $valY
    bind $fname.y <Enter> "focus $fname.y"
    scale $fname.z -from 0 -to $Z -orient horiz -bg $color
    $fname.z set $valZ
    bind $fname.z <Enter> "focus $fname.z"

    pack $fname.l $fname.x $fname.y $fname.z  -fill x
}


inrimage::addObjectMenu
Comments  
Arguments name
mname
img
toff
color
Used by inrimage::mergeView
inrimage::singleViewImage
inrimage::viewInrimage
inrimage::mergeView4D
inrimage::view4D
Uses inrimage::isRoiInView
inrimage::isSliceableInView
proc inrimage::addObjectMenu { name mname img {toff 0} {color "#E8E0D2"}} {
    set mn [menu $name -tearoff $toff -bg $color]
    $name add cascade -label "Surface Slice" -menu $name.surf
    set scn   [ lindex [ split [ ${mname} -views] ] 0 ]
    menu $name.surf -tearoff $toff -bg $color -postcommand "set inrimage::scn \[ \[ lindex \[ split \[ ${mname} -views\] \] 0 \] -scene \]; $name.surf delete 0 last; foreach {i} \[surfaceSliceables\] { set inrimage::view(\$i) \[ inrimage::isSliceableInView  \$i \${inrimage::scn} \]; $name.surf add checkbutton -variable inrimage::view(\$i) -label \$i -command \" if  \$inrimage::view(\$i) \{evaluate {\[inrimage::getSliceableInView  \$i \${inrimage::scn} \] -destroy } \} else  \{evaluate {new surfview \$i -scene \${inrimage::scn} } \} \" }"
    $name add cascade -label "Surface ROI" -menu $name.roi
    menu $name.roi -tearoff $toff -bg $color -postcommand "set inrimage::scn \[ \[ lindex \[ split \[ ${mname} -views\] \] 0 \] -scene \]; $name.roi delete 0 last; foreach {i} \[surfaceSliceables\] { set inrimage::view(\$i) \[ inrimage::isRoiInView  \$i \${inrimage::scn} \]; $name.roi add checkbutton -variable inrimage::view(\$i) -label \$i -command \" if  \$inrimage::view(\$i) \{evaluate {\[inrimage::getRoiInView  \$i \${inrimage::scn} \] -destroy } \} else  \{evaluate {new roi $img \$i region  \${inrimage::scn} } \} \" }"
}


inrimage::anisoDiffDialog
Comments  
Arguments img
color
Used by  
Uses inrimage::choiceFrame
proc inrimage::anisoDiffDialog { img {color "#E8E0D2"}} {
    if ![winfo exists .anisoDiff] {
    toplevel .anisoDiff -bg $color
    wm title .anisoDiff "Anisotropic Diffusion"

    frame .anisoDiff.df -bg $color
    frame .anisoDiff.time -bg $color
    frame .anisoDiff.smooth -bg $color
    frame .anisoDiff.b -bg $color

    inrimage::choiceFrame .anisoDiff.df.choice "Diffusion function" inrimage::df $color {"Aubert" aubert} {"Perona and Malik (enhance)" perona}  
    scale .anisoDiff.df.quant -from 0 -to 100 -length 100 -resolution 1 -bg $color -variable inrimage::quant -orient horizontal -label "Quantile on gradient histogramm"

    
    scale .anisoDiff.time.step -from 0 -to 2 -length 300 -resolution 0.01 -bg $color -variable inrimage::dt -orient horizontal -label "Time Step"
    scale .anisoDiff.time.total -from 0 -to 10 -length 300 -resolution 0.1 -bg $color -variable inrimage::tmax -orient horizontal -label "Diffusion Time"
    inrimage::choiceFrame .anisoDiff.time.disk "Write on Disk temporary buffers ?" inrimage::disk $color {"Yes" true} {"No" false}
    
    inrimage::choiceFrame .anisoDiff.smooth.choice "Gaussian Smoothing to compute diffusivity ?" inrimage::smooth $color {"Yes" true} {"No" false}
    scale .anisoDiff.smooth.sigma -from 0 -to 5 -length 300 -resolution 0.1 -bg $color -variable inrimage::sigma -orient horizontal -label "Standard deviation of Gaussian Smoothing"

    
    button .anisoDiff.b.ok -text "OK" -command "set cmd \"$img -anisotropicDiffusion \$inrimage::dt\ \$inrimage::tmax\ \$inrimage::quant\ \$inrimage::smooth\ \$inrimage::sigma\ \$inrimage::df\ \$inrimage::disk\"; view \[evaluate \$cmd \]; destroy .anisoDiff" -bg $color
    button .anisoDiff.b.dismiss -text "Dismiss" -command "destroy .anisoDiff" -bg $color

    pack .anisoDiff.df.choice .anisoDiff.df.quant -padx 10 -pady 10 -fill x
    pack .anisoDiff.smooth.choice .anisoDiff.smooth.sigma -padx 10 -pady 10
    pack .anisoDiff.df -side left -fill x
    pack .anisoDiff.smooth -side right
    pack .anisoDiff.time.step  .anisoDiff.time.total .anisoDiff.time.disk -fill x -padx 10 -pady 10
    pack .anisoDiff.time
    pack .anisoDiff.b.ok .anisoDiff.b.dismiss -side left -expand true -fill x -padx 20 -pady 10
    pack .anisoDiff.b

    }
}


inrimage::arithmeticDialog
Comments apply an arithmetic operator on an inrimage
Arguments img
color
Used by  
Uses inrimage::choiceFrame
inrimage::inrOptionMenu
proc inrimage::arithmeticDialog { img {color "#E8E0D2"}} {
    if ![winfo exists .arith] {
    toplevel .arith -bg $color
    wm title .arith "Arithmetic operation"
    frame .arith.d -bg $color
    frame .arith.b -bg $color
    frame .arith.d.operand -bg $color

    inrimage::choiceFrame .arith.d.operator "arithmetic operator" inrimage::operator $color {" set value" set} {"+ (add)" add} {"- (substract)" sub} {"* (multiplicate)" mul} {"/ (divide)" div}
    set inrimage::operator add

    label .arith.d.operand.l -text "operand" -relief raised -bg $color
    radiobutton .arith.d.operand.cst -text "Constant" -variable inrimage::operand -value cst -bg $color -anchor w  -command ".arith.d.operand.menu configure -state disabled; .arith.d.operand.e configure -state normal"
    entry .arith.d.operand.e -fg black -bg white -relief sunken
    .arith.d.operand.e insert 0 "1.0"
    radiobutton .arith.d.operand.inr -text "Inrimage" -variable inrimage::operand -value inr -bg $color -anchor w  -command ".arith.d.operand.e configure -state disabled; .arith.d.operand.menu configure -state normal"
    inrimage::inrOptionMenu .arith.d.operand.menu "" $color
    .arith.d.operand.menu configure -state disabled
    set inrimage::operand cst

    button .arith.b.ok -text "OK" -command "if { !\[string compare \$inrimage::operand cst\] } { evaluate \"$img -arith \$inrimage::operator \[.arith.d.operand.e get\]\" } else { evaluate \"$img -arith \$inrimage::operator \$inrimage::mval\"}; destroy .arith" -bg $color
    button .arith.b.dismiss -text "Dismiss" -command "destroy .arith" -bg $color

    pack .arith.d.operand.l .arith.d.operand.cst .arith.d.operand.e .arith.d.operand.inr .arith.d.operand.menu -fill x

    pack .arith.d.operator .arith.d.operand -side left -expand true -fill both -padx 10 -pady 10
    pack .arith.b.ok .arith.b.dismiss -side left -expand true -fill x -padx 20 -pady 10
    pack .arith.d .arith.b
    }
}


inrimage::centerSliceCameraOnLandmark
Comments  
Arguments lset
vx
vy
vz
Used by  
Uses  
proc inrimage::centerSliceCameraOnLandmark { lset vx vy vz} {

    if [string compare [ $lset -selectedLandmark ] "none" ] {

    foreach {cam} [ [$lset -scene]  -camera]  {
        if {[string match slicecam* $cam]} {
        switch [$cam -geometry] {"X" {} "Y" {} "Z" {}}
        }
    }
    }
}


inrimage::chamferDialog
Comments  
Arguments img
color
Used by  
Uses inrimage::inrscale
proc inrimage::chamferDialog { img {color "#E8E0D2"}} {
    if ![winfo exists .chamfer] {
    toplevel .chamfer -bg $color
    wm title .chamfer "Chamfer Map"

    frame .chamfer.d -bg $color
    frame .chamfer.b -bg $color
    
    frame .chamfer.d.dim -bg $color
    frame .chamfer.d.size -bg $color
    frame .chamfer.d.th -bg $color

    label .chamfer.d.dim.l -text "Dimensions" -relief raised -bg $color
    radiobutton .chamfer.d.dim.dd -text "2D" -variable inrimage::dim -value "2D" -bg $color
    radiobutton .chamfer.d.dim.td -text "3D" -variable inrimage::dim -value "3D" -bg $color
    set inrimage::dim 3D
    pack .chamfer.d.dim.l .chamfer.d.dim.dd .chamfer.d.dim.td -fill x

    frame .chamfer.d.size.h -bg $color
    frame .chamfer.d.size.b -bg $color
    pack .chamfer.d.size.h .chamfer.d.size.b

    label .chamfer.d.size.h.l -text "          Chamfer Size          " -relief raised -bg $color
    pack .chamfer.d.size.h.l

    radiobutton .chamfer.d.size.b.t -text "3" -variable inrimage::size -value "3" -bg $color
    radiobutton .chamfer.d.size.b.c -text "5" -variable inrimage::size -value "5" -bg $color
    tk_optionMenu .chamfer.d.size.b.distancet inrimage::distt "MALANDAIN3x3x3"
    tk_optionMenu .chamfer.d.size.b.distancec inrimage::distc "CHAMFER5x5x5"
    
    set inrimage::size 3

    grid .chamfer.d.size.b.t .chamfer.d.size.b.distancet -row 2
    grid .chamfer.d.size.b.c .chamfer.d.size.b.distancec -row 3
    
    label .chamfer.d.th.l -bg $color -text " Threshold "
    inrimage::inrscale .chamfer.d.th.sc $img $color min

    pack .chamfer.d.th.l .chamfer.d.th.sc -fill x

    pack .chamfer.d.dim .chamfer.d.size .chamfer.d.th -side left -fill both -padx 10 -pady 10
    
    button .chamfer.b.ok -text "OK" -command "set cmd \"$img -chamfer \$inrimage::dim thres \[.chamfer.d.th.sc get\] size \$inrimage::size \"; if ![string compare \$inrimage::size 3] { set cmd \[concat \$cmd \$inrimage::distt \] } else { set cmd \[concat \$cmd \$inrimage::distc \] } ; view \[evaluate \$cmd \]; destroy .chamfer" -bg $color
    button .chamfer.b.dismiss -text "Dismiss" -command "destroy .chamfer" -bg $color
    pack .chamfer.b.ok .chamfer.b.dismiss -side left -expand true -fill x -padx 20 -pady 10

    pack .chamfer.d .chamfer.b

    }

}


inrimage::choiceFrame
Comments  
Arguments fname
title
varname
color
args
Used by inrimage::anisoDiffDialog
inrimage::recursiveFilterDialog
inrimage::inrimageDialog
inrimage::convoluteDialog
inrimage::arithmeticDialog
inrimage::morphomathematicDialog
inrimage::connexeDialog
Uses  
proc inrimage::choiceFrame { fname title varname color args } {
    frame $fname -bg $color
    
    label $fname.l -text $title -relief raised -bg $color
    pack $fname.l -fill x
    foreach { i } $args {
    set label [lindex $i 0]
    set val [lindex $i 1]
    radiobutton $fname.$val -text $label -variable $varname -value $val -bg $color -anchor w
    pack $fname.$val -fill x
    }
}


inrimage::colormapMenu
Comments  
Arguments menu
mname
color
option
Used by inrimage::multiviewmenu
inrimage::multiviewMergeMenu
inrimage::multiview4Dmenu
Uses inrimage::getCmapFromMultiview
proc inrimage::colormapMenu { menu mname color {option "-scalemode"}} {
    set mcmap [menu $menu -tearoff 0 -bg $color -postcommand "set inrimage::mcmap \[ inrimage::getCmapFromMultiview $mname $option\] " ]
    $mcmap add radiobutton -variable inrimage::mcmap -label "Affine"  -value "affine" -command "inrimage::setCmapFromMultiview $mname affine $option"
    $mcmap add radiobutton -variable inrimage::mcmap -label "Threshold"  -value "threshold" -command "inrimage::setCmapFromMultiview $mname threshold $option"
    $mcmap add radiobutton -variable inrimage::mcmap -label "PET Colors"  -value "pet" -command "inrimage::setCmapFromMultiview $mname pet $option"
    $mcmap add radiobutton -variable inrimage::mcmap -label "Red"  -value "red" -command "inrimage::setCmapFromMultiview $mname red $option"
    $mcmap add radiobutton -variable inrimage::mcmap -label "Green"  -value "green" -command "inrimage::setCmapFromMultiview $mname green $option"
    $mcmap add radiobutton -variable inrimage::mcmap -label "Blue"  -value "blue" -command "inrimage::setCmapFromMultiview $mname blue $option"
    $mcmap add radiobutton -variable inrimage::mcmap -label "User Defined"  -value "user" -command "inrimage::setCmapFromMultiview $mname user $option \[ new cm \[ tk_getOpenFile -filetypes { {\"ColorMap File\" {.cmap}} {\"Inrimage\" {.inr} } {\"All\" {*} } }  \] \]"
}


inrimage::connexeDialog
Comments  
Arguments img
color
Used by  
Uses inrimage::inrscale
inrimage::choiceFrame
proc inrimage::connexeDialog { img {color "#E8E0D2"}} {
    if ![winfo exists .connexe] {
    toplevel .connexe -bg $color
    wm title .connexe "Connexe components"

    frame .connexe.d -bg $color
    frame .connexe.b -bg $color

    inrimage::choiceFrame .connexe.d.con "connexity" inrimage::con $color {"4 (2D edge)" 4} {"8 (2D vertex)" 8} {"6 (3D face)" 6} {"18 (3D edge)" 18} {"26 (3D vertex)" 26}
    set inrimage::con 26

    frame .connexe.d.op -bg $color
    label  .connexe.d.op.l3 -text "Image thresholding" -relief raised -bg $color
    label .connexe.d.op.l1 -text "low threshold" -bg $color -anchor w
    inrimage::inrscale .connexe.d.op.s1 $img $color min
    label .connexe.d.op.l11 -text "high threshold" -bg $color -anchor w
    inrimage::inrscale .connexe.d.op.s11 $img $color max
    
    checkbutton .connexe.d.op.b3 -text "Hysteresis thresholding" -variable inrimage::oper -onvalue 1 -offvalue 0  -bg $color -anchor w  -command { if {$inrimage::oper == 1} {.connexe.d.op.s2 configure -state normal; } else {.connexe.d.op.s2 configure -state disabled; }}
    label .connexe.d.op.l2 -text "Keep only high threshold CC larger than:" -bg $color -anchor w
    scale .connexe.d.op.s2 -from 1 -to 10000 -length 200 -orient horiz -bg $color -state disabled
    .connexe.d.op.s2 configure -state disabled
    set inrimage::oper 0

    frame .connexe.d.cc -bg $color
    label  .connexe.d.cc.l1 -text "Connexe component" -relief raised -bg $color
    checkbutton .connexe.d.cc.b1 -text "Keep only CC larger than:" -variable inrimage::tcc -onvalue 1 -offvalue 0  -bg $color -anchor w -command { if { $inrimage::tcc == 1 } { .connexe.d.cc.s1 configure -state normal } else { .connexe.d.cc.s1 configure -state disabled } }
    set inrimage::tcc 0
    scale .connexe.d.cc.s1 -from 1 -to 10000 -length 200 -orient horiz -bg $color -state disabled
    bind .connexe.d.cc.s1 <Enter> {focus .connexe.d.cc.s1}
    radiobutton .connexe.d.cc.b2 -text "Any number of CC" -variable inrimage::ncc -value all -bg $color -anchor w  -command { .connexe.d.cc.s2 configure -state disabled }
    radiobutton .connexe.d.cc.b3 -text "Given number of CC" -variable inrimage::ncc -value given -bg $color -anchor w  -command { .connexe.d.cc.s2 configure -state normal }
    scale .connexe.d.cc.s2 -from 1 -to 200 -length 200 -orient horiz -bg $color -state disabled
    radiobutton .connexe.d.cc.b4 -text "Only maximal CC" -variable inrimage::ncc -value max -bg $color -anchor w  -command { .connexe.d.cc.s2 configure -state disabled }
    set inrimage::ncc all

    frame .connexe.d.out -bg $color
    label  .connexe.d.out.l1 -text "Output image" -relief raised -bg $color
    radiobutton .connexe.d.out.b1 -text "binary" -variable inrimage::output -value binary  -bg $color -anchor w
    radiobutton .connexe.d.out.b2 -text "one grey level per CC" -variable inrimage::output -value label  -bg $color -anchor w
    set inrimage::output binary

    label .connexe.d.out.l11 -text "background" -bg $color -anchor w
    inrimage::inrscale .connexe.d.out.s1 $img $color min
    label .connexe.d.out.l2 -text "foreground" -bg $color -anchor w
    inrimage::inrscale .connexe.d.out.s2 $img $color max

    #button .connexe.b.ok -text "OK" -command "set cmd \"$img -connexe con \$inrimage::con \"; set th \"lt \[.connexe.d.op.s1 get\] \"; if {\$inrimage::oper == 1} { set th \[ concat \$th \"ht \[.connexe.d.op.s11 get\] \"\]}; set cmd \[concat \$cmd \$th\]; if \$inrimage::tcc { set cmd \[concat \$cmd \"tcc \[.connexe.d.cc.s1 get\]\"\]};if !\[string compare \$inrimage::ncc max\] { set cmd \[concat \$cmd max\]} elseif !\[string compare \$inrimage::ncc given\] { set cmd \[concat \$cmd \"ncc \[.connexe.d.cc.s2 get\]\"\]};set cmd \[concat \$cmd \"output \$inrimage::output\"\]; if {\$inrimage::oper == 1} { set cmd \[ concat \$cmd \"hyster tcc_ht \[.connexe.d.op.s2 get\]\"\]}; puts \$cmd; evaluate \$cmd; destroy .connexe" -bg $color
    button .connexe.b.ok -text "OK" -command "set cmd \"$img -connexe con \$inrimage::con \"; set th \"lt \[.connexe.d.op.s1 get\] \"; set th \[ concat \$th \"ht \[.connexe.d.op.s11 get\] \"\]; set cmd \[concat \$cmd \$th\]; if \$inrimage::tcc { set cmd \[concat \$cmd \"tcc \[.connexe.d.cc.s1 get\]\"\]};if !\[string compare \$inrimage::ncc max\] { set cmd \[concat \$cmd max\]} elseif !\[string compare \$inrimage::ncc given\] { set cmd \[concat \$cmd \"ncc \[.connexe.d.cc.s2 get\]\"\]};set cmd \[concat \$cmd \"output \$inrimage::output\"\]; if {\$inrimage::oper == 1} { set cmd \[ concat \$cmd \"hyster tcc_ht \[.connexe.d.op.s2 get\]\"\]}; puts \$cmd; evaluate \$cmd; destroy .connexe" -bg $color
    button .connexe.b.dismiss -text "Dismiss" -command "destroy .connexe" -bg $color

    pack .connexe.d.op.l3 .connexe.d.op.l1 .connexe.d.op.s1 .connexe.d.op.b3 .connexe.d.op.l11 .connexe.d.op.s11 .connexe.d.op.l2 .connexe.d.op.s2 -fill x
    pack .connexe.d.cc.l1 .connexe.d.cc.b1 .connexe.d.cc.s1 .connexe.d.cc.b2 .connexe.d.cc.b3 .connexe.d.cc.s2 .connexe.d.cc.b4 -fill x
    pack .connexe.d.out.l1 .connexe.d.out.b1 .connexe.d.out.b2 .connexe.d.out.l11 .connexe.d.out.s1 .connexe.d.out.l2 .connexe.d.out.s2 -fill x
    pack .connexe.d.con .connexe.d.op .connexe.d.cc .connexe.d.out -side left -fill both -padx 10 -pady 10

    pack .connexe.b.ok .connexe.b.dismiss -side left -expand true -fill x -padx 20 -pady 10
    pack .connexe.d .connexe.b
    }
}


inrimage::convoluteDialog
Comments  
Arguments img
color
Used by  
Uses inrimage::choiceFrame
proc inrimage::convoluteDialog { img {color "#E8E0D2"}} {
    
    if ![winfo exists .convolution] {
    toplevel .convolution -bg $color
    wm title .convolution "Filter convolution"

    frame .convolution.d -bg $color
    frame .convolution.b -bg $color

    inrimage::choiceFrame .convolution.d.filter "Filter type" inrimage::filter $color {"gaussian (2D)" "gauss 2D"} {"gaussian (3D)" "gauss 3D"} {"X smoothing" smoothX} {"Y smoothing" smoothY} {"Z smoothing" smoothZ} {"X first derivative" derX} {"Y first derivative" derY} {"Z first derivative" derZ} {"X second derivative" der2X} {"Y second derivative" der2Y} {"Z second derivative" der2Z}
    set inrimage::filter "gauss 3D"

    frame .convolution.d.sigma -bg $color
    label .convolution.d.sigma.l1 -text "Filter half size" -relief raised -bg $color
    scale .convolution.d.sigma.s1 -from 1 -to 15 -orient horiz -bg $color
    bind .convolution.d.sigma.s1 <Enter> { focus .convolution.d.sigma.s1 }

    button .convolution.b.ok -text "OK" -command "evaluate \"$img -convolute filterSize \[.convolution.d.sigma.s1 get\] \$inrimage::filter\"; destroy .convolution" -bg $color
    button .convolution.b.dismiss -text "Dismiss" -command "destroy .convolution" -bg $color

    pack .convolution.d.sigma.l1 .convolution.d.sigma.s1 -fill x
    pack .convolution.d.filter .convolution.d.sigma -side left -fill both -padx 10 -pady 10
    pack .convolution.b.ok .convolution.b.dismiss -side left -expand true -fill x -padx 20 -pady 10
    pack .convolution.d .convolution.b
    }
}


inrimage::createROIList
Comments  
Arguments rlist
inr
scn
bg
Used by  
Uses  
proc inrimage::createROIList { rlist inr scn {bg "PeachPuff2"}} {
    set root .{$inr}ROIList
    if {![winfo exists $root]} {
    toplevel $root -bg $bg
    wm title $root "ROI Management"
    frame $root.f

    button $root.f.create -text "Create New ROI" -command "set r \[ evaluate \"$rlist -newROI\"\];modules::entryDialog .{\$r}Name $bg {Set the region name} \"\[\$r -realName\]\" \"evaluate \{ \$r -realName ... \} \"" -width 20 -height 5 -bg seashell3
    menubutton $root.f.select -text "Select ROI" -menu $root.f.select.m -anchor c -bg blue -width 20 -height 5
    menu  $root.f.select.m -bg $bg -postcommand "$root.f.select.m delete 0 last; foreach {i} \[ $rlist -rois \] { $root.f.select.m add command -label \" \[ \$i -realName \] (\$i)\" -command \" foreach {cam} \\\[$scn -camera\\\] \{ \\\$cam -select \$i \} \"}"
    menubutton $root.f.show -text "Show/Hide ROI" -menu $root.f.show.m -anchor c -bg green -width 20 -height 5
    menu  $root.f.show.m -bg $bg -postcommand "$root.f.show.m delete 0 last; foreach {i} \[ $rlist -rois \] { set inrimage::show(\$i) \[\$i -visibility \];$root.f.show.m add checkbutton -label \" \[ \$i -realName \] (\$i)\" -variable inrimage::show(\$i) -onvalue true -offvalue false -command \" \$i -visibility \\\$inrimage::show(\$i) \" }"
    button $root.f.write -text "Save all ROIs" -command "if  !\[ string compare  \[ $rlist -write name \] \"defaultName.rl\" \] {$rlist -write \[tk_getSaveFile -initialfile defaultName.rl -filetypes { { {ROI List} {.rl} } {{All} {*}} } -parent . -title {Select a ROI List} \] } else {$rlist -write}" -width 20 -height 5 -bg red
    button $root.f.quit -text "Quit" -command "$rlist -destroy;destroy $root" -width 20 -height 5 -bg brown

    pack $root.f.create -side top -expand true
    pack $root.f.select -side top -expand true
    pack $root.f.show -side top -expand true
    pack $root.f.write -side top -expand true
    pack $root.f.quit -side top -expand true
    pack $root.f
    }
    
}


inrimage::createToplevel
Comments  
Arguments parent
img
color
Used by inrimage::singleViewImage
inrimage::mergeView4D
inrimage::view4D
inrimage::viewInrimage
inrimage::mergeView
Uses  
proc inrimage::createToplevel { parent img color } {
    if { [lsearch [winfo visualsavailable .] "truecolor 24"] > 0 } {
    toplevel $parent -bg $color
    } else {
    if {![string compare [$img -type] "rgb"] || ![string compare [$img -type] "rgba"]} {
        toplevel $parent -visual "truecolor 24" -bg $color
    } else {
        if { [lsearch [winfo visualsavailable .] "grayscale 24"] > 0 } {
        toplevel $parent -visual "grayscale 24" -bg $color
        } elseif { [lsearch [winfo visualsavailable .] "grayscale 8"] > 0 } {
        toplevel $parent -visual "grayscale 8" -bg $color
        } else {
        toplevel $parent -visual "best" -bg $color
        }
    }
    }
}


inrimage::cropDialog
Comments  
Arguments img
color
Used by  
Uses inrimage::XYZFrame
proc inrimage::cropDialog { img {color "#E8E0D2"}} {
    if ![winfo exists .crop] {
    toplevel .crop -bg $color
    wm title .crop "Crop Image"

    frame .crop.d -bg $color
    frame .crop.b -bg $color

    scan [$img -size] "%u %u %u" xout yout zout
    set xout [ expr $xout -1 ]  
    set yout [ expr $yout -1 ]  
    set zout [ expr $zout -1 ]  
    inrimage::XYZFrame .crop.d.first "First corner voxel" $color 0 0 0
    inrimage::XYZFrame .crop.d.second "Second corner voxel" $color $xout $yout $zout  $xout $yout $zout

    button .crop.b.ok -text "OK" -command "evaluate \"$img -crop org  \[.crop.d.first.x get\]  \[.crop.d.first.y get\] \[.crop.d.first.z get\] end \[.crop.d.second.x get\] \[.crop.d.second.y get\]  \[.crop.d.second.z get\]; destroy .crop\"" -bg $color
    button .crop.b.dismiss -text "Dismiss" -command "destroy .crop" -bg $color

    pack .crop.d.first .crop.d.second -side left -fill both -pady 10 -padx 10

    pack .crop.b.ok .crop.b.dismiss -side left -expand true -fill x -padx 20 -pady 10
    pack .crop.d .crop.b
    }
}


inrimage::deleteLandmark
Comments  
Arguments lset
camera
x
y
Used by  
Uses  
proc inrimage::deleteLandmark {lset camera x y } {
    set widget [$camera -widget]
    $widget configure -closeenough 2.0
    $widget dtag selected
    $widget addtag selected closest $x $y

    set tagList [split [$widget gettags selected ] ]

    set template [ format "%sland*" $lset ]
    set name [ format "%sland" $lset ]
    foreach t $tagList {
    if {[string match  $template $t] } {
        scan  $t "$name%s" landm
        $lset -removeLandmark $landm
    }
    }
}


inrimage::evalDialog
Comments  
Arguments img
color
Used by  
Uses  
proc inrimage::evalDialog { img {color "#E8E0D2"}} {
    if ![winfo exists .evalinr] {
    set root .evalinr
    toplevel $root -bg $color
    wm title $root "Function Evaluation"

    frame $root.d -bg $color
    frame $root.h -bg $color
    frame $root.b -bg $color

    frame $root.d.eval -bg $color
    label $root.d.eval.l -bg $color -text "Enter Function:" -anchor w
    entry $root.d.eval.e -bg $color -fg black -relief sunken -width 70
    bind $root.d.eval.e <Return> "evaluate \"$img -eval \[ $root.d.eval.e get \] \""
    pack $root.d.eval.l $root.d.eval.e -fill x
    pack   $root.d.eval

    text $root.h.text -height 10 -wrap word -xscrollcommand "$root.h.xscroll set"  -yscrollcommand "$root.h.yscroll set"   -setgrid 1 -highlightthickness 0 -pady 2 -padx 3  
    scrollbar $root.h.xscroll -command "$root.h.text xview"  -highlightthickness 0 -orient horizontal
    scrollbar $root.h.yscroll -command "$root.h.text yview"  -highlightthickness 0 -orient vertical
    grid $root.h.text -in $root.h -padx 1 -pady 1 -row 0 -column 0 -rowspan 1 -columnspan 1 -sticky news  
    grid $root.h.yscroll -in $root.h -padx 1 -pady 1 -row 0 -column 1 -rowspan 1 -columnspan 1 -sticky news  
    grid $root.h.xscroll -in $root.h -padx 1 -pady 1 -row 1 -column 0 -rowspan 1 -columnspan 1 -sticky news  
    grid rowconfig    $root.h 0 -weight 1 -minsize 0
    grid columnconfig $root.h 0 -weight 1 -minsize 0    

    $root.h.text insert 1.0 "Evaluates expression in function string.\n Supports the following arithmetic operators in the following order:\n \t  ^(power),\n\t /(division) or *(multiplication) \n\t +(addition) or -(subtraction)\n Operators with the same priority are processed from left to right. All other operators have lowest priority  and therefore processed from left to right as well.\n Special operators: \n\t |<(minimum),\n\t |>(maximum)\n Logical Operators(returns 1=true,0=false):\n\t   <=(Smaller or equal),\n\t  >=(Larger or equal),\n\t  ==(equal),\n\t   >(larger),\n\t  <(smaller),\n\t  &&(and),\n\t  ||(or).\n  Standard functions (angles are in radians):\n\t abs(),\n\t exp(),\n\t ceil()(rounds upwards),\n\t floor()(rounds downwards),\n\t log(),\n\t sqrt(),\n\t sin(),\n\t cos(),\n\t tan(),\n\t asin(),\n\t acos(),\n\t atan(),\n\t sinh(),\n\t cosh(),\n\t tanh().\n      Global functions (returns a scalar and calculates value based on the expression given as input to the function)):\n\t mean,\n\t min(minimum value),\n\t max(maximum value),\n\t med(median),\n\t std(estimated standard deviation),\n\t var(estimated variance).\n    Variables: \n\t x,y,z (pixel positions),\n\t inrX(X can be any number of a valid image).\n\n\n Examples: \n\t inr3 -eval inr1|<inr2  (each pixel of inr3 contains the  maximum of the corresponding pixels in inr1 and inr2), \n\t inr3 -eval inr1 -eval (x-64)^2+(y-64)^2+(z-64)^2<200  (creates a sphere),\n\t inr3 -eval inr1-mean(inr1)(set mean to zero), \n\t inr3 -eval (inr1-min(inr1))/(max(inr1)-min(inr1))*100  (normalizes image between 0 and 100),\n\t inr3 -eval med(sqrt(inr1^2/inr2)/(x+y+z)^3)*inr2 (I don't know).\n"
    $root.h.text mark set insert 1.0    
    #        pack $root.h.text $root.h.xscroll $root.h.yscroll
    button $root.b.ok -text "Evaluate" -bg $color -command "evaluate \"$img -eval \[ $root.d.eval.e get \] \""
    button $root.b.dismiss -text "Dismiss" -command "destroy $root" -bg $color
    pack  $root.b.ok $root.b.dismiss -side left -expand true -fill x -padx 20 -pady 10
    pack $root.d $root.h $root.b
    }
}


inrimage::fillDialog
Comments  
Arguments img
color
Used by  
Uses inrimage::inrscale
proc inrimage::fillDialog { img {color "#E8E0D2"}} {
    
    if ![winfo exists .fill] {
    toplevel .fill -bg $color
    wm title .fill "Fill contours"
    
    frame .fill.d -bg $color
    frame .fill.b -bg $color

    label .fill.d.l1 -text "Contour options" -relief raised -bg $color
    radiobutton .fill.d.b1 -text "2D contours" -variable inrimage::dim -value "2D"  -bg $color -anchor w
    radiobutton .fill.d.b2 -text "3D contours" -variable inrimage::dim -value "3D"  -bg $color -anchor w
    set inrimage::dim "2D"

    label .fill.d.l2 -text "Background voxels value" -bg $color -anchor w
    inrimage::inrscale .fill.d.s1 $img $color min
    label .fill.d.l3 -text "Foreground voxels value" -bg $color -anchor w
    inrimage::inrscale .fill.d.s2 $img $color max

    button .fill.b.ok -text "OK" -command "evaluate \"$img -fill \$inrimage::dim bg \[.fill.d.s1 get\] fg \[.fill.d.s2 get\]\"; destroy .fill" -bg $color
    button .fill.b.dismiss -text "Dismiss" -command "destroy .fill" -bg $color

    pack .fill.d.l1 .fill.d.b1 .fill.d.b2 .fill.d.l2 .fill.d.s1 .fill.d.l3 .fill.d.s2 -fill x

    pack .fill.b.ok .fill.b.dismiss -side left -expand true -fill x -padx 20 -pady 10
    pack .fill.d .fill.b
    }
}


inrimage::getABackground
Comments  
Arguments image
mn
Used by  
Uses  
proc inrimage::getABackground { image mn } {
    set cam [ lindex [ $mn -views ] end ]
    set scn [ $cam -scene]
    set inrv "none"
    foreach { o } [ $scn -objects ] {
    if { [string match inrview* $o]} {set inrv $o}
    }
    if { [string compare $inrv "none"] } {
    set bg [ $o -background $cam ]
    return $bg
    } else {
    return "none"
    }
}


inrimage::getCmapFromMultiview
Comments  
Arguments multiview
option
Used by inrimage::colormapMenu
Uses  
proc inrimage::getCmapFromMultiview { multiview {option "-scalemode"}} {
    set  val "none"
    foreach {i} [ [ $multiview -scene] -objects] {
    if {[string match  inrview* $i]} {set val $i}
    if {[string match  inr4Dview* $i]} {set val $i}
    if {[string match  overinrview* $i]} {set val $i}
    if {[string match  overinr4Dview* $i]} {set val $i}
    }
    if { [string compare $val "none"] } {
    return  [ [$val -background [ lindex [$multiview -views] 0 ] ] $option]
    } else {
    return "none"
    }
}


inrimage::getInrFromCamera
Comments  
Arguments slicecam
Used by graphics2D::slicecammenu
inrimage::viewerXCropMenu
inrimage::viewerXIsolateMenu
inrimage::viewerXZeroMenu
Uses  
proc inrimage::getInrFromCamera { slicecam} {
    set  val "none"
    foreach {i} [ [ $slicecam -scene] -objects] {
    if {[string match  inrview* $i]} {set val $i}    
    if {[string match  inr4Dview* $i]} {set val $i}    
    if {[string match  overinrview* $i]} {set val $i}
    if {[string match  overinr4Dview* $i]} {set val $i}
    }
    if { [string compare $val "none"] } {
    return [$val -inrimage ]
    } else {
    return "none"
    }
}


inrimage::getInterpolationFromMultiview
Comments  
Arguments multiview
option
Used by inrimage::interpolationMenu
Uses  
proc inrimage::getInterpolationFromMultiview { multiview {option "-interpolation"}} {
    set  val "none"
    foreach {i} [ [ $multiview -scene] -objects] {
    if {[string match  inrview* $i]} {set val $i}
    if {[string match  inr4Dview* $i]} {set val $i}
    if {[string match  overinrview* $i]} {set val $i}
    if {[string match  overinr4Dview* $i]} {set val $i}
    }
    if { [string compare $val "none"] } {
    return  [ [$val -background [ lindex [$multiview -views] 0 ] ] $option]
    } else {
    return "none"
    }
}


inrimage::getRoiInView
Comments  
Arguments sliceable
scene
Used by  
Uses  
proc inrimage::getRoiInView  { sliceable scene} {
    set val "none"
    foreach {i} [which roi] {
    if ![string compare [ $i -scene] $scene] {
        if ![string compare [ $i -mesh ] $sliceable ] {
        set val $i
        }
    }
    }
    return $val
}


inrimage::getScene2DFromInr
Comments  
Arguments inr
Used by  
Uses  
proc inrimage::getScene2DFromInr { inr} {
    set  val "none"
    foreach {i} [ which inrview ] {
    set img [$i -inrimage]
    if {![string compare $inr   $img]} {set val [ $i -scene]}    
    }
    if { ![string compare $val "none"] } {
    foreach {i} [ which overinrview ] {
        set img [$i -inrimage]
        if {![string $inr   $img]} {set val [ $i -scene]}    
    }
    }
    if { ![string compare $val "none"] } {
    return [ new scn2D]
    } else {
    return $val
    }    
}


inrimage::getScene2DFromMultiview
Comments  
Arguments mname
Used by  
Uses  
proc inrimage::getScene2DFromMultiview { mname} {
    return [ [ lindex [$mname -views] 0 ] -scene ]
}


inrimage::getSliceableInView
Comments  
Arguments sliceable
scene
Used by  
Uses  
proc inrimage::getSliceableInView  { sliceable scene} {
    set val "none"
    foreach {i} [which surfview] {
    if ![string compare [ $i -scene] $scene] {
        if ![string compare [ $i -mesh ] $sliceable ] {
        set val $i
        }
    }
    }
    return $val
}


inrimage::glscalemenu
Comments  
Arguments sname
toff
color
Used by  
Uses  
proc inrimage::glscalemenu { sname {toff 0} {color "#E8E0D2"}} {
    set name [$sname -widget].m
    set mn [menu $name -tearoff $toff -bg $color -postcommand "set activate \[$sname -activate\]"]
    
    $mn add command -label $sname -state disabled -command {}
    $mn add command -label "set value..." -command "graphics2D::setScaleValue $sname $color"
    $mn add cascade -label "add" -menu $mn.add
    menu $mn.add -tearoff $toff -bg $color -postcommand "$mn.add delete 0 last; foreach { i } \[ which inrbgrnd \] {$mn.add add command -label \$i -command \"evaluate { $sname -add \$i } \" }"
    $mn add cascade -label "remove" -menu $mn.remove
    menu $mn.remove -tearoff $toff -bg $color -postcommand "$mn.remove delete 0 last; foreach { i } \[ $sname -objects \] {$mn.remove add command -label \$i -command \" evaluate { $sname -remove \$i} \" }"
    $mn add cascade -label "speed" -menu $mn.speed
    menu $mn.speed -tearoff $toff -bg $color
    $mn.speed add command -label "very slow" -command "evaluate \"$sname -maxSteps 1000\""
    $mn.speed add command -label "slow" -command "evaluate \"$sname -maxSteps 200\""
    $mn.speed add command -label "normal" -command "evaluate \"$sname -maxSteps 100\""
    $mn.speed add command -label "fast" -command "evaluate \"$sname -maxSteps 30\""
    $mn.speed add command -label "very fast" -command "evaluate \"$sname -maxSteps 10\""
    $mn add checkbutton -label "activate" -variable inrimage::activate  -onvalue "true" -offvalue "false" -command "$sname -activate \$inrimage::activate"
    $mn add separator
    $mn add command -label "destroy" -command "$sname -destroy"
    bind [$sname -widget] <Button-3> "tk_popup $name %X %Y"
}


inrimage::gradientDialog
Comments  
Arguments img
color
Used by  
Uses inrimage::inrscale
proc inrimage::gradientDialog { img {color "#E8E0D2"}} {

    if ![winfo exists .gradient] {
    toplevel .gradient -bg $color
    wm title .gradient "Gradient computation"

    frame .gradient.d -bg $color
    frame .gradient.b -bg $color

    frame .gradient.d.rec -bg $color
    radiobutton .gradient.d.rec.b1 -text "Recursive filters" -relief raised -variable inrimage::filter -value rec  -bg $color -anchor w -command { .gradient.d.rec.b2 configure -state normal; .gradient.d.rec.b3 configure -state normal; .gradient.d.rec.b4 configure -state normal; .gradient.d.rec.s1 configure -state normal; .gradient.d.sobel.s1 configure -state disabled }
    radiobutton .gradient.d.rec.b2 -text "Deriche step-edge" -variable inrimage::rfilter -value deriche  -bg $color -anchor w
    radiobutton .gradient.d.rec.b3 -text "Deriche gaussian" -variable inrimage::rfilter -value gaussian  -bg $color -anchor w
    radiobutton .gradient.d.rec.b4 -text "Marta" -variable inrimage::rfilter -value marta  -bg $color -anchor w
    set inrimage::rfilter deriche
    label .gradient.d.rec.l1 -text "Filter standard deviation" -bg $color -anchor w
    scale .gradient.d.rec.s1 -from 0.1 -to 20 -resolution 0.1 -orient horiz -bg $color
    .gradient.d.rec.s1 set 3
    bind .gradient.d.rec.s1 <Enter> { focus .gradient.d.rec.s1 }

    frame .gradient.d.sobel -bg $color
    radiobutton .gradient.d.sobel.b1 -text "Sobel filters" -relief raised -variable inrimage::filter -value sobel  -bg $color -anchor w -command { .gradient.d.rec.b2 configure -state disabled; .gradient.d.rec.b3 configure -state disabled; .gradient.d.rec.b4 configure -state disabled; .gradient.d.rec.s1 configure -state disabled; .gradient.d.sobel.s1 configure -state normal }
    label .gradient.d.sobel.l1 -text "Filter size" -bg $color -anchor w
    scale .gradient.d.sobel.s1 -from 3 -to 15 -orient horiz -bg $color -state disabled
    bind .gradient.d.sobel.s1 <Enter> { focus .gradient.d.sobel.s1 }

    set inrimage::filter rec

    frame .gradient.d.opt -bg $color
    label .gradient.d.opt.l1 -text "Options" -relief raised -bg $color
    radiobutton .gradient.d.opt.b1 -text "3D" -variable inrimage::dim -value "3D"  -bg $color -anchor w
    radiobutton .gradient.d.opt.b2 -text "2D" -variable inrimage::dim -value "2D"  -bg $color -anchor w
    set inrimage::dim 3D
    checkbutton .gradient.d.opt.b3 -text "Max gradient value along gradient direction" -variable max -onvalue max -offvalue ""  -bg $color -anchor w
    set max ""
    radiobutton .gradient.d.opt.b4 -text "Compute norm only" -variable inrimage::output -value ""  -bg $color -anchor w
    radiobutton .gradient.d.opt.b5 -text "Return gradient vectors" -variable inrimage::output -value "dir vectors"  -bg $color -anchor w
    radiobutton .gradient.d.opt.b6 -text "Sample gradient vectors" -variable inrimage::output -value "dir sample"  -bg $color -anchor w
    set inrimage::output ""
    checkbutton .gradient.d.opt.b7 -text "Low threshold" -variable lt -onvalue 1 -offvalue 0  -bg $color -anchor w -command { if $lt { .gradient.d.opt.s1 configure -state normal } else { .gradient.d.opt.s1 configure -state disabled } }
    inrimage::inrscale .gradient.d.opt.s1 $img $color min
    .gradient.d.opt.s1 configure -state disabled

    button .gradient.b.ok -text "OK" -command "set cmd \"$img -gradient \$inrimage::dim \$inrimage::output \$max \$inrimage::filter \"; if !\[string compare \$inrimage::filter rec\] { set cmd \[concat \$cmd \"\$inrimage::rfilter sigma \[.gradient.d.rec.s1 get\] \"\] } else { set cmd \[concat \$cmd \"sigma \[.gradient.d.sobel.s1 get\] \"\] }; if \$lt { set cmd \[concat \$cmd \"lt \[.gradient.d.opt.s1 get\]\"\]}; foreach i \[evaluate \$cmd\] { view \$i }; destroy .gradient" -bg $color
    button .gradient.b.dismiss -text "Dismiss" -command "destroy .gradient" -bg $color
    
    pack .gradient.d.rec.b1 .gradient.d.rec.b2 .gradient.d.rec.b3 .gradient.d.rec.b4 .gradient.d.rec.l1 .gradient.d.rec.s1 -fill x
    pack .gradient.d.sobel.b1 .gradient.d.sobel.l1 .gradient.d.sobel.s1 -fill x
    pack .gradient.d.opt.l1 .gradient.d.opt.b1 .gradient.d.opt.b2 -fill x
    pack .gradient.d.opt.b3 -fill x -pady 10
    pack .gradient.d.opt.b4 .gradient.d.opt.b5 .gradient.d.opt.b6 -fill x
    pack .gradient.d.opt.b7 -fill x -pady 10
    pack .gradient.d.opt.s1 -fill x
    pack .gradient.d.rec .gradient.d.sobel .gradient.d.opt -side left -fill both -padx 10 -pady 10

    pack .gradient.b.ok .gradient.b.dismiss -side left -expand true -fill x -padx 20 -pady 10
    pack .gradient.d .gradient.b
    }
}


inrimage::inr4Dlist
Comments  
Arguments name
cmd
toff
color
Used by inrimage::multiview4Dmenu
Uses  
proc inrimage::inr4Dlist { name cmd {toff 0} {color "#E8E0D2"}} {
    menu $name -tearoff $toff -bg $color -postcommand "$name delete 0 last; foreach { i } \[which inr4D\] { $name add command -label \$i -command \[modules::menusubstitute {$cmd} ... \$i\] }" -bg $color
}


inrimage::inr4Dmenu
Comments  
Arguments name
iname
toff
color
Used by inrimage::multiview4Dmenu
Uses  
proc inrimage::inr4Dmenu { name iname {toff 0} {color "#E8E0D2"} } {
    set mn [menu $name -tearoff $toff -bg $color]
    
    $mn add command -label $iname -state disabled -command {}
    $mn add command -label "anisotropic diffusion..." -command "inrimage::anisoDiffDialog $iname $color"
    $mn add separator
    $mn add command -label "Save" -command "$iname -save"
    $mn add command -label "Save As..." -command "$iname -save \[tk_getSaveFile -filetypes {{\"Inrimage 4D\" {.inr4D} } {All *}} -parent . -title {Save Inrimage4D as}\]"
}


inrimage::inrOptionMenu
Comments  
Arguments name
cmd
color
Used by inrimage::arithmeticDialog
inrimage::melDialog
Uses  
proc inrimage::inrOptionMenu { name {cmd ""} {color "#E8E0D2"}} {
    if ![string compare $cmd ""] {
    set cmdf 0
    } else {
    set cmdf 1
    }

    set mn [tk_optionMenu $name inrimage::mval {}]
    if $cmdf {
    foreach { i } [which inr] {
        $mn add radiobutton -variable inrimage::mval -label $i  -command [modules::menusubstitute $cmd ... $i]
    }
    } else {
    foreach { i } [which inr] {
        $mn add radiobutton -variable inrimage::mval -label $i
    }
    }
    $mn delete 0
    set inrimage::mval inr1
    if $cmdf { eval [modules::menusubstitute $cmd ... inr1] }
    $name configure -bg $color
}


inrimage::inrimageDialog
Comments  
Arguments color
Used by  
Uses inrimage::choiceFrame
proc inrimage::inrimageDialog {{color "#E8E0D2"}} {

    if ![winfo exists .newinr] {
    toplevel .newinr -bg $color
    wm title .newinr "Create new inrimage"

    frame .newinr.d -bg $color
    frame .newinr.b -bg $color

    inrimage::choiceFrame .newinr.d.type "Type" inrimage::type $color {"8 bits unsigned" 8bits} {"16 bits signed" s16bits} {"16 bits unsigned" 16bits} {"32 bits signed" s32bits} {"32 bits unsigned" 32bits} {"64 bits signed" s64bits} {"64 bits unsigned" 64bits} {"float" float} {"double" double} {"RGB" rgb} {"RGBA" rgba} {"float vector" floatVector} {"double vector" doubleVector}
    set inrimage::type 8bits
    .newinr.d.type.8bits configure -command { .newinr.d.size.s4 configure -state disabled }
    .newinr.d.type.16bits configure -command { .newinr.d.size.s4 configure -state disabled }
    .newinr.d.type.s16bits configure -command { .newinr.d.size.s4 configure -state disabled }
    .newinr.d.type.32bits configure -command { .newinr.d.size.s4 configure -state disabled }
    .newinr.d.type.s32bits configure -command { .newinr.d.size.s4 configure -state disabled }
    .newinr.d.type.64bits configure -command { .newinr.d.size.s4 configure -state disabled }
    .newinr.d.type.s64bits configure -command { .newinr.d.size.s4 configure -state disabled }
    .newinr.d.type.float configure -command { .newinr.d.size.s4 configure -state disabled }
    .newinr.d.type.double configure -command { .newinr.d.size.s4 configure -state disabled }
    .newinr.d.type.rgb configure -command { .newinr.d.size.s4 configure -state disabled }
    .newinr.d.type.rgba configure -command { .newinr.d.size.s4 configure -state disabled }
    .newinr.d.type.floatVector configure -command { .newinr.d.size.s4 configure -state normal }
    .newinr.d.type.doubleVector configure -command { .newinr.d.size.s4 configure -state normal }
    
    frame .newinr.d.size -bg $color
    label .newinr.d.size.l1 -text "Size" -relief raised -bg $color
    scale .newinr.d.size.s1 -label "X" -from 1 -to 1024 -length 256 -orient horiz -bg $color
    .newinr.d.size.s1 set 100
    bind .newinr.d.size.s1 <Enter> { focus .newinr.d.size.s1 }
    scale .newinr.d.size.s2 -label "Y" -from 1 -to 1024 -length 256 -orient horiz -bg $color
    .newinr.d.size.s2 set 100
    bind .newinr.d.size.s2 <Enter> { focus .newinr.d.size.s2 }
    scale .newinr.d.size.s3 -label "Z" -from 1 -to 1024 -length 256 -orient horiz -bg $color
    .newinr.d.size.s3 set 100
    bind .newinr.d.size.s3 <Enter> { focus .newinr.d.size.s3 }
    scale .newinr.d.size.s4 -label "Vectorial dimension" -from 2 -to 30 -orient horiz -bg $color
    .newinr.d.size.s4 set 3
    .newinr.d.size.s4 configure -state disabled
    bind .newinr.d.size.s4 <Enter> { focus .newinr.d.size.s4 }

    button .newinr.b.ok -text "OK" -command "if { !\[string compare \$inrimage::type floatVector\] || !\[string compare \$inrimage::type doubleVector\] } { set inrimage::dim \[.newinr.d.size.s4 get\]} else { set inrimage::dim \"\" } ;view \[evaluate \"new inr x \[.newinr.d.size.s1 get\] y  \[.newinr.d.size.s2 get\] z \[.newinr.d.size.s3 get\] type \$inrimage::type \$inrimage::dim\"\]; destroy .newinr" -bg $color
    button .newinr.b.dismiss -text "Dismiss" -command "destroy .newinr" -bg $color

    pack .newinr.d.size.l1 .newinr.d.size.s1 .newinr.d.size.s2 .newinr.d.size.s3 -fill x
    pack .newinr.d.size.s4 -pady 20 -fill x

    pack .newinr.d.type .newinr.d.size -side left -padx 10 -pady 10 -fill both

    pack .newinr.b.ok .newinr.b.dismiss -side left -expand true -fill x -padx 20 -pady 10
    pack .newinr.d .newinr.b
    }
}


inrimage::inrlist
Comments  
Arguments name
cmd
toff
color
Used by inrimage::multiviewmenu
inrimage::inrmenu
inrimage::slicecammenu
Uses  
proc inrimage::inrlist { name cmd {toff 0} {color "#E8E0D2"}} {
    menu $name -tearoff $toff -bg $color -postcommand "$name delete 0 last; foreach { i } \[which inr\] { $name add command -label \$i -command \[modules::menusubstitute {$cmd} ... \$i\] }" -bg $color
}


inrimage::inrmenu
Comments  
Arguments name
iname
mview
toff
color
Used by inrimage::multiviewMergeMenu
inrimage::inrslicecammenu
inrimage::multiviewmenu
Uses cisosurf::extractIsosurf
inrimage::inrlist
proc inrimage::inrmenu { name iname {mview 0} {toff 0} {color "#E8E0D2"}  } {
    set mn [menu $name -tearoff $toff -bg $color]
    
    $mn add command -label $iname -state disabled -command {}
    $mn add command -label "voxel size..." -command "inrimage::voxelSizeDialog $iname $color"
    $mn add command -label "copy" -command "view \[evaluate \"$iname -copy\"\]"
    $mn add cascade -label "convert" -menu $mn.convert
    menu $mn.convert -tearoff 0 -bg $color

    $mn.convert add cascade -label "convert (cast)" -menu $mn.cast
    menu $mn.cast -tearoff 0 -bg $color
    $mn.cast add command -label "8 bits" -command "evaluate \"$iname -type cast 8bits\""
    $mn.cast add command -label "16 bits signed" -command "evaluate \"$iname -type cast s16bits\""
    $mn.cast add command -label "16 bits unsigned" -command "evaluate \"$iname -type cast 16bits\""
    $mn.cast add command -label "32 bits signed" -command "evaluate \"$iname -type cast s32bits\""
    $mn.cast add command -label "32 bits unsigned" -command "evaluate \"$iname -type cast 32bits\""
    $mn.cast add command -label "64 bits signed" -command "evaluate \"$iname -type cast s64bits\""
    $mn.cast add command -label "64 bits unsigned" -command "evaluate \"$iname -type cast 64bits\""
    $mn.cast add command -label "float" -command "evaluate \"$iname -type cast float\""
    $mn.cast add command -label "double" -command "evaluate \"$iname -type cast double\""
    $mn.cast add command -label "RGB" -command "evaluate \"$iname -type cast rgb\""
    $mn.cast add command -label "RGBA" -command "evaluate \"$iname -type cast rgba\""
    $mn.cast add command -label "float vector" -command "evaluate \"$iname -type cast floatVector\""
    $mn.cast add command -label "double vector" -command "evaluate \"$iname -type cast doubleVector\""

    $mn.convert add cascade -label "convert (scale)" -menu $mn.scale
    menu $mn.scale -tearoff 0 -bg $color
    $mn.scale add command -label "8 bits" -command "evaluate \"$iname -type scale 8bits\""
    $mn.scale add command -label "16 bits signed" -command "evaluate \"$iname -type scale s16bits\""
    $mn.scale add command -label "16 bits unsigned" -command "evaluate \"$iname -type scale 16bits\""
    $mn.scale add command -label "32 bits signed" -command "evaluate \"$iname -type scale s32bits\""
    $mn.scale add command -label "32 bits unsigned" -command "evaluate \"$iname -type scale 32bits\""
    $mn.scale add command -label "64 bits signed" -command "evaluate \"$iname -type scale s64bits\""
    $mn.scale add command -label "64 bits unsigned" -command "evaluate \"$iname -type scale 64bits\""
    $mn.scale add command -label "float" -command "evaluate \"$iname -type scale float\""
    $mn.scale add command -label "double" -command "evaluate \"$iname -type scale double\""
    $mn.scale add command -label "RGB" -command "evaluate \"$iname -type scale rgb"
    $mn.scale add command -label "RGBA" -command "evaluate \"$iname -type scale rgba\""
    $mn.scale add command -label "float vector" -command "evaluate \"$iname -type scale floatVector\""
    $mn.scale add command -label "double vector" -command "evaluate \"$iname -type scale doubleVector\""
    $mn add separator
    $mn add command -label "insert image..." -command "inrimage::melDialog $iname $color"
    $mn add command -label "crop image..." -command "inrimage::cropDialog $iname $color"
    $mn add cascade -label "flip" -menu $mn.flip
    menu $mn.flip -tearoff 0 -bg $color
    $mn.flip add command -label "along X" -command "evaluate \"$iname -flip X\""
    $mn.flip add command -label "along Y" -command "evaluate \"$iname -flip Y\""
    $mn.flip add command -label "along Z" -command "evaluate \"$iname -flip Z\""



    #     $mn add separator
    #     $mn add cascade -label "interpolation" -menu $mn.interp
    #     menu $mn.interp -tearoff 0 -bg $color
    #     $mn.interp add command -label "nearest" -command "evaluate \"$iname -interpolation nearest\""
    #     $mn.interp add command -label "trilinear" -command "evaluate \"$iname -interpolation trilin\""

    #     $mn add cascade -label "extrapolation" -menu $mn.extrap
    #     menu $mn.extrap -tearoff 0 -bg $color
    #     $mn.extrap add command -label "nearest" -command "evaluate \"$iname -extrapolation nearest\""
    #     $mn.extrap add command -label "to zero" -command "evaluate \"$iname -extrapolation tozero\""

    $mn add separator
    $mn add command -label "arithmetic ..." -command "inrimage::arithmeticDialog $iname $color"

    $mn add separator
    $mn add command -label "morphomathematic..." -command "inrimage::morphomathematicDialog $iname $color"
    $mn add command -label "connexe..." -command "inrimage::connexeDialog $iname $color"
    $mn add command -label "fill..." -command "inrimage::fillDialog $iname $color"
    $mn add command -label "chamfer map ... " -command "inrimage::chamferDialog $iname $color"

    $mn add separator
    $mn add cascade -label "logical operations" -menu $mn.logical
    menu $mn.logical -tearoff 0 -bg $color

    $mn.logical add command -label "not" -command "evaluate \"$iname -logic not\""
    $mn.logical add cascade -label "logical or" -menu $mn.or
    inrimage::inrlist $mn.or "$iname -logic or ..." 0 $color
    $mn.logical add cascade -label "logical and" -menu $mn.and
    inrimage::inrlist $mn.and "$iname -logic and ..." 0 $color
    $mn.logical add cascade -label "logical xor" -menu $mn.xor
    inrimage::inrlist $mn.xor "$iname -logic xor ..." 0 $color

    $mn add separator

    $mn add command -label "DFT / DFT-1 3D" -command "evaluate \"$iname -dft 3D\""
    $mn add command -label "DFT / DFT-1 2D" -command "evaluate \"$iname -dft 2D\""

    $mn add separator
    $mn add command -label "histogram..." -command "set h \[ evaluate \"$iname -histogram\" \];evaluate \" \$h -plot\""
    $mn add command -label "threshold..." -command "inrimage::thresholdDialog $iname  $mview $color"
    $mn add command -label "apply windowing" -command "inrimage::windowImage $iname $mview"
    $mn add command -label "eval function..." -command "inrimage::evalDialog $iname $color"

    $mn add separator
    
    $mn add cascade -label "Filtering" -menu $mn.filter
    menu $mn.filter -tearoff 0 -bg $color
    
    $mn.filter add command -label "gradient..." -command "inrimage::gradientDialog $iname $color"
    $mn.filter add command -label "laplacian..." -command "inrimage::laplacianDialog $iname $color"
    $mn.filter add command -label "convolute..." -command "inrimage::convoluteDialog $iname $color"
    $mn.filter add command -label "recursive filter..." -command "inrimage::recursiveFilterDialog $iname $color"

    $mn.filter add command -label "noise..." -command "inrimage::noiseDialog $iname $color"
    $mn.filter add command -label "anisotropic diffusion..." -command "inrimage::anisoDiffDialog $iname $color"

    $mn add separator

    $mn add command -label "crest extraction..." -command "if {!\[string compare \[isModuleLoaded tclEpinrimage \] no \]} { evaluate \"yav::setDependance;yav::loadModule tclEpinrimage yav::moduleDependance\"; if [winfo exists .yavModule ] {yav::updateModuleDialog .yavModule } }; epinrimage::crestextraction $iname $color"

    $mn add command -label "isosurface extraction..." -command "if {!\[string compare \[isModuleLoaded tclCIsosurf \] no \]} { evaluate \"yav::setDependance; yav::loadModule tclCIsosurf yav::moduleDependance\"; if [winfo exists .yavModule ] {yav::updateModuleDialog .yavModule } }; cisosurf::extractIsosurf $iname $color"


}


inrimage::inrscale
Comments  
Arguments name
img
color
minormax
Used by inrimage::thresholdDialog
inrimage::fillDialog
inrimage::gradientDialog
inrimage::chamferDialog
inrimage::connexeDialog
inrimage::noiseDialog
imagedata::gradientDialog
imagedata::gradientGradientDialog
Uses  
proc inrimage::inrscale { name img color {minormax min}} {
    scan [$img -glbounds] "%s %s" min max
    if ![string compare [$img -floating] true] {
    set resol [expr $max / 1000.0 - $min / 1000.0]
    } else {
    set resol 1
    }
    scale $name -from $min -to $max -bg $color -orient horiz -resolution $resol -length 255
    bind $name <Enter> "focus $name"
    if ![string compare $minormax min] {
    $name set $min
    } else {
    $name set $max
    }
}


inrimage::inrslicecammenu
Comments  
Arguments mn
vname
color
Used by inrimage::slicecammenu
Uses inrimage::inrmenu
proc inrimage::inrslicecammenu { mn vname color} {
    if {![winfo exists $mn.inr]} {
    $mn add separator
    set inr [$vname -inrimage]
    if [string compare $inr "no inrimage"] {
        $mn add cascade -label $inr -menu $mn.inr
        inrimage::inrmenu $mn.inr [$vname -inrimage] 0 0 $color
        $mn add command -label "set gray level bounds" -command "\[$vname -inrimage\] -glbounds min \[\[$vname -minscale\] -get\] max \[\[$vname -maxscale\] -get\]"
    }
    }
}


inrimage::installInrviewMenu
Comments  
Arguments menu
camera
inrview
bg
Used by  
Uses  
proc inrimage::installInrviewMenu { menu camera inrview bg } {
    
    # Ce menu est a afficher uniquement pour les images vectorielles de type floatVector ou doubleVector
    if { ![string compare [ [$inrview -inrimage] -type] "floatVector"] || ![string compare [ [$inrview -inrimage] -type] "doubleVector"] } {
    menubutton $menu.context.mode -text "Display Mode" -menu $menu.context.mode.mn -bg $bg
    set mn [menu $menu.context.mode.mn -bg $bg -postcommand ""]
    $mn add radiobutton -label "hide Vectors" -variable inrimage::dispMode -value "WITHOUT_VECTOR" -command "evaluate \"$inrview -displayMode \$inrimage::dispMode\""
    $mn add radiobutton -label "show Vectors" -variable inrimage::dispMode -value "WITH_VECTOR" -command "inrimage::vectorDialog [$inrview -inrimage] $inrview $bg WITH_VECTOR"
    $mn add radiobutton -label "show Vectors only" -variable inrimage::dispMode -value "VECTOR_ONLY" -command "inrimage::vectorDialog [$inrview -inrimage] $inrview $bg VECTOR_ONLY"
    pack $menu.context.mode -side left
    }
}


inrimage::installLandmarkSetMenu
Comments  
Arguments viewer
camera
lset
bg
Used by  
Uses modules::selectColor
proc inrimage::installLandmarkSetMenu { viewer camera lset 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 "Save Landmark Set as..." -command "evaluate \" $lset -saveAs \[tk_getSaveFile -filetypes { {{Landmark Set} {.lset} } {\\\"All\\\" *} } -parent . -title {Select a Landmark Set} \] \" "
    $mfile add separator
    $mfile add command -label "Destroy" -command "evaluate \"$lset -destroy\""

    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 cascade -label "Display Mode" -menu   $mdisplay.sub3
    set m3 [menu  $mdisplay.sub3 -tearoff 0 -postcommand "set inrimage::lsetm \[ $lset -displayMode \] " ]
    $m3 add radiobutton -variable inrimage::lsetm -label "Hide" -value "hide" -command "evaluate \"$lset -displayMode hide \""
    $m3 add radiobutton -variable inrimage::lsetm -label "Use Crosses" -value "cross" -command "evaluate \"$lset -displayMode cross \""
    $m3 add radiobutton -variable inrimage::lsetm -label "Use Voxels" -value "voxel" -command "evaluate \"$lset -displayMode voxel\""
    $mdisplay add command -label "Cross Size..." -command "modules::scaleDialog .{$lset}CrossSize $bg {Choose Cross Size} 1 15 \[$lset -crossSize\] \"evaluate \{ $lset -crossSize ...\} \" "
    $mdisplay add command -label "Landmark Color..." -command "set col \[ modules::selectColor  \[ $lset -color\] \]; evaluate \"$lset -color \[lindex \$col 0\] \[lindex \$col 1\] \[lindex \$col 2\] \""
    $mdisplay add command -label "Selected Landmark Color..." -command "set col \[ modules::selectColor  \[ $lset -color\] \]; evaluate \"$lset -color \[lindex \$col 0\] \[lindex \$col 1\] \[lindex \$col 2\] \""

    menubutton $viewer.context.landmark -text "Landmarks" -menu $viewer.context.landmark.m -anchor w -bg $bg
    set mland [menu $viewer.context.landmark.m -bg $bg]
    $mland add cascade -label "Landmark Information" -menu   $mland.sub3
    set m3 [menu  $mland.sub3 -tearoff 0 -postcommand "$mland.sub3 delete 0 last;set selectedLandmark \[$lset -selectedLandmark\];foreach {i} \[ $lset -landmarks \] { scan \$i \"%s %s %s %s %s %s \"  vx vy vz tx ty tz; $mland.sub3 add radio -variable selectedLandmark -label \[ lindex \$i 6\]  -command \" tk_messageBox -type ok -message \\\"Voxel position : \$vx \$vy \$vz \n World position : \$tx \$ty \$tz \n Name : \[ lindex \$i 6 \] \\\" \"} " ]
    $mland add cascade -label "Remove Landmarks" -menu   $mland.sub4
    set m4 [menu  $mland.sub4 -tearoff 0 -postcommand "$mland.sub4 delete 0 last;foreach {i} \[ $lset -landmarks \] { $mland.sub4 add command -label \[ lindex \$i 6\]  -command \" $lset -removeLandmark \[ lindex \$i 6\] \"} " ]
    $mland add cascade -label "Select Landmarks" -menu   $mland.sub1
    set m1 [menu  $mland.sub1 -tearoff 0 -postcommand "$mland.sub1 delete 0 last;set selectedLandmark \[$lset -selectedLandmark\]; foreach {i} \[ $lset -landmarks \] {  scan \$i \"%s %s %s \"  vx vy vz; $mland.sub1 add radio -label \[ lindex \$i 6\] -variable selectedLandmark -command \" $lset -selectedLandmark \[ lindex \$i 6\];inrimage::centerSliceCameraOnLandmark $lset \$vx \$vy \$vz \"} " ]

    pack  $viewer.context.file -side left
    pack  $viewer.context.display -side left
    pack  $viewer.context.landmark -side left
    
}


inrimage::installLandmarkSetPopupMenu
Comments  
Arguments widget
camera
lset
bg
Used by  
Uses  
proc inrimage::installLandmarkSetPopupMenu { widget camera lset bg } {
    if {[winfo exists $widget]} {
    destroy $widget
    }
    set popup [ menu $widget -tearoff 0 -bg "white" -postcommand "scan \[$lset -selectionMode \] {%s} inrimage::lsetselMode" ]
    $popup add command -label "Left Button" -state disabled -command {}
    $popup add radio -label "Create Landmarks" -variable inrimage::lsetselMode -value "create" -command  "evaluate \"$lset -selectionMode create \""
    $popup add radio -label "Move Landmarks" -variable inrimage::lsetselMode -value "move" -command  "evaluate \"$lset -selectionMode move \""
    $popup add radio -label "Delete Landmarks" -variable inrimage::lsetselMode -value "delete" -command  "evaluate \"$lset -selectionMode delete \""

    bind [$camera -widget] <Button-3> "tk_popup $popup %X %Y"
}


inrimage::installROIEditMenu
Comments  
Arguments viewer
camera
roi
bg
Used by  
Uses inrimage::installROIMenu
proc inrimage::installROIEditMenu { viewer camera roi bg } {
    inrimage::installROIMenu $viewer $camera $roi $bg
}


inrimage::installROIEditPopupMenu
Comments  
Arguments widget
camera
roie
bg
Used by  
Uses  
proc inrimage::installROIEditPopupMenu { widget camera roie bg } {
    if {[winfo exists $widget]} {
    destroy $widget
    }
    set popup [ menu $widget -tearoff 0 -bg "white" -postcommand "scan \[$roie -selectionMode \] {%s} inrimage::roieselMode" ]
    $popup add command -label "Left Button" -state disabled -command {}
    $popup add radio -label "Use Brush" -variable inrimage::roieselMode -value "brush" -command  "evaluate \"$roie -selectionMode brush \""
    $popup add radio -label "Use Eraser" -variable inrimage::roieselMode -value "eraser" -command  "evaluate \"$roie -selectionMode eraser \""
    $popup add radio -label "Use Polygon" -variable inrimage::roieselMode -value "line" -command  "evaluate \"$roie -selectionMode line \""
    $popup add separator
    $popup add command -label "Set Brush Size..." -command "modules::scaleDialog .{$roie}BrushSize $bg {Choose Brush Size} 1 5 \[$roie -brushWidth\] \"evaluate \{ $roie -brushWidth ...\} \" "
    $popup add command -label "Set Eraser Size..." -command "modules::scaleDialog .{$roie}EraserSize $bg {Choose Eraser Size} 1 5 \[$roie -eraserWidth\] \"evaluate \{ $roie -eraserWidth ...\} \" "
    bind [$camera -widget] <Button-3> "tk_popup $popup %X %Y"
}


inrimage::installROIMenu
Comments  
Arguments viewer
camera
roi
bg
Used by inrimage::installROIEditMenu
Uses modules::selectColor
proc inrimage::installROIMenu { viewer camera roi 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 "Save ROI" -command "evaluate \"$roi -save \""
    $mfile add command -label "Save ROI as..." -command "evaluate \"$roi -save \[tk_getSaveFile -filetypes {{\"ROI\" {*.roi } } } -parent . -title {Select a ROI name} \] \""
    $mfile add separator
    $mfile add command -label "Save as binary Image" -command "set im \[evaluate \"$roi -binary \"\]; \$im -save \[inrimage::saveImage \"binary.inr.gz\"\]"
    $mfile add separator
    $mfile add command -label "Destroy" -command "evaluate \"$roi -destroy\""
    menubutton $viewer.context.display -text "Display" -menu $viewer.context.display.m -anchor w -bg $bg
    set mdisplay [menu $viewer.context.display.m -bg $bg -postcommand "set inrimage::showROI \[ $roi -visibility \]"]
    $mdisplay add command -label "ROI Color..." -command "set col \[ modules::selectColor  \[ $roi -color\] \]; evaluate \"$roi -color \[lindex \$col 0\] \[lindex \$col 1\] \[lindex \$col 2\] \""
    $mdisplay add cascade -label "Display Mode" -menu   $mdisplay.sub3
    set m3 [menu  $mdisplay.sub3 -tearoff 0 -postcommand "set inrimage::roim \[ $roi -greyLevel \] " ]
    $m3 add radiobutton -variable inrimage::roim -label "Use Grey Level" -value "true" -command "evaluate \"$roi -greyLevel true \""
    $m3 add radiobutton -variable inrimage::roim -label "Use Color" -value "false" -command "evaluate \"$roi -greyLevel false \""

    $mdisplay add checkbutton -label "Show ROI" -variable inrimage::showROI -onvalue "true" -offvalue "false" -command "evaluate \"$roi -visibility \$inrimage::showROI \""

    $mdisplay add cascade -label "ROI Opacity" -menu   $mdisplay.sub2
    set m2 [menu  $mdisplay.sub2 -tearoff 0]
    $m2 add command -label "100\%" -command "evaluate \"$roi -opacity full \""
    $m2 add command -label "75\%" -command "evaluate \"$roi -opacity opacity75 \""
    $m2 add command -label "50\%" -command "evaluate \"$roi -opacity opacity50 \""
    $m2 add command -label "25\%" -command "evaluate \"$roi -opacity opacity25 \""
    $m2 add command -label "12\%" -command "evaluate \"$roi -opacity opacity12 \""
    menubutton $viewer.context.stat -text "Algorithms" -menu $viewer.context.stat.m -anchor w -bg $bg
    set mstat [menu $viewer.context.stat.m -bg $bg]
    $mstat add command -label "ROI Histogram..." -command "set h \[evaluate \"$roi -histogram\" \]; evaluate \"\$h -plot\""
    $mstat add command -label "Dilate 3D" -command "evaluate \"$roi -morpho dilation iter 1 con 6\""
    $mstat add command -label "Erode 3D" -command "evaluate \"$roi -morpho erosion iter 1 con 6\""
    $mstat add command -label "2D Closure (size 1)" -command "evaluate \"$roi -morpho dilation iter 1 con 4\";evaluate \"$roi -morpho erosion iter 1 con 4\" "  
    $mstat add command -label "2D Closure (size 2)" -command "evaluate \"$roi -morpho dilation iter 2 con 4\";evaluate \"$roi -morpho erosion iter 2 con 4\" "
    $mstat add command -label "3D Closure (size 1)" -command "evaluate \"$roi -morpho dilation iter 1 con 26\";evaluate \"$roi -morpho erosion iter 1 con 26\" "  
    $mstat add command -label "3D Closure (size 2)" -command "evaluate \"$roi -morpho dilation iter 2 con 26\";evaluate \"$roi -morpho erosion iter 2 con 26\" "

    menubutton $viewer.context.name -text "ROI" -menu $viewer.context.name.m -anchor w -bg $bg
    set mname [menu $viewer.context.name.m -bg $bg]
    $mname add command -label "set Name..." -command "modules::entryDialog .{$roi}Name $bg {Set the region name} \"\[$roi -realName\]\" \"evaluate \{ $roi -realName ... \} \""
    pack  $viewer.context.file -side left
    pack  $viewer.context.display -side left
    pack  $viewer.context.stat -side left
    pack  $viewer.context.name -side left
}


inrimage::interpolationMenu
Comments  
Arguments menu
mname
color
option
Used by inrimage::multiviewmenu
Uses inrimage::getInterpolationFromMultiview
proc inrimage::interpolationMenu { menu mname color {option "-interpolation"}} {
    set mcmap [menu $menu -tearoff 0 -bg $color -postcommand "set inrimage::minterp \[ inrimage::getInterpolationFromMultiview $mname $option\] " ]
    $mcmap add radiobutton -variable inrimage::minterp -label "Nearest"  -value "nearest" -command "inrimage::setInterpolationFromMultiview $mname nearest $option"
    $mcmap add radiobutton -variable inrimage::minterp -label "Bilinear"  -value "bilinear" -command "inrimage::setInterpolationFromMultiview $mname bilinear $option"
}


inrimage::isRoiInView
Comments  
Arguments sliceable
scene
Used by inrimage::addObjectMenu
Uses  
proc inrimage::isRoiInView  { sliceable scene} {
    set val 0
    foreach {i} [which roi] {
    if ![string compare [ $i -scene] $scene] {
        if ![string compare [ $i -mesh ] $sliceable ] {
        set val 1
        }
    }
    }
    return $val
}


inrimage::isSliceableInView
Comments  
Arguments sliceable
scene
Used by inrimage::addObjectMenu
Uses  
proc inrimage::isSliceableInView  { sliceable scene} {
    set val 0
    foreach {i} [which surfview] {
    if ![string compare [ $i -scene] $scene] {
        if ![string compare [ $i -mesh ] $sliceable ] {
        set val 1
        }
    }
    }
    return $val
}


inrimage::laplacianDialog
Comments  
Arguments img
color
Used by  
Uses  
proc inrimage::laplacianDialog { img {color "#E8E0D2"}} {

    if ![winfo exists .laplacian] {
    toplevel .laplacian -bg $color
    wm title .laplacian "Laplacian computation"

    frame .laplacian.d -bg $color
    frame .laplacian.b -bg $color

    label .laplacian.d.l1 -text "Recursive filters" -relief raised -bg $color
    radiobutton .laplacian.d.b1 -text "Deriche step-edge" -variable inrimage::rfilter -value deriche  -bg $color -anchor w
    radiobutton .laplacian.d.b2 -text "Deriche gaussian" -variable inrimage::rfilter -value gaussian  -bg $color -anchor w
    radiobutton .laplacian.d.b3 -text "Marta" -variable inrimage::rfilter -value marta  -bg $color -anchor w
    set inrimage::rfilter deriche
    label .laplacian.d.l2 -text "Filter standard deviation" -bg $color -anchor w
    scale .laplacian.d.s1 -from 0.1 -to 20 -resolution 0.1 -orient horiz -bg $color
    .laplacian.d.s1 set 3
    bind .laplacian.d.s1 <Enter> { focus .laplacian.d.s1 }

    button .laplacian.b.ok -text "OK" -command "evaluate \"$img -laplacian \$inrimage::rfilter sigma \[.laplacian.d.s1 get\]\"; destroy .laplacian" -bg $color
    button .laplacian.b.dismiss -text "Dismiss" -command "destroy .laplacian" -bg $color

    pack .laplacian.d.l1 .laplacian.d.b1 .laplacian.d.b2 .laplacian.d.b3 .laplacian.d.l2 .laplacian.d.s1 -fill x

    pack .laplacian.b.ok .laplacian.b.dismiss -side left -expand true -fill x -padx 20 -pady 10
    pack .laplacian.d .laplacian.b -pady 10
    }
}


inrimage::loadImage
Comments  
Arguments  
Used by  
Uses  
proc inrimage::loadImage { } {
    return [tk_getOpenFile -filetypes {
    {"Inrimage, 3Ds" {.inr .inr.gz .hdr .dim} }
    {"Gif, 2Ds" {.gif .ppm .pgm .bmp} }
    {"Iris" {.rgb} }
    {"All" * }} -parent . -title {Select an image}]
}


inrimage::melBounds
Comments  
Arguments img
Used by  
Uses  
proc inrimage::melBounds { img } {
    scan [$img -size] "%u %u %u" x y z
    .mel.d.in.x configure -to $x
    .mel.d.in.y configure -to $y
    .mel.d.in.z configure -to $z
    .mel.d.size.x configure -to $x
    .mel.d.size.y configure -to $y
    .mel.d.size.z configure -to $z
}


inrimage::melDialog
Comments  
Arguments img
color
Used by  
Uses inrimage::XYZFrame
inrimage::inrOptionMenu
proc inrimage::melDialog { img {color "#E8E0D2"}} {
    if ![winfo exists .mel] {
    toplevel .mel -bg $color
    wm title .mel "Mel images"

    frame .mel.d -bg $color
    frame .mel.b -bg $color

    scan [$img -size] "%u %u %u" xout yout zout
    set xout [ expr $xout -1 ]  
    set yout [ expr $yout -1 ]  
    set zout [ expr $zout -1 ]  
    inrimage::XYZFrame .mel.d.out "Mel in $img at:" $color $xout $yout $zout
    inrimage::XYZFrame .mel.d.in "Mel from:" $color 10 10 10
    inrimage::XYZFrame .mel.d.size "Mel box size:" $color 10 10 10

    inrimage::inrOptionMenu .mel.d.in.menu "inrimage::melBounds ..." $color
    pack .mel.d.in.menu -fill x -pady 10

    button .mel.b.ok -text "OK" -command "evaluate \"$img -mel \$inrimage::mval ixo \[.mel.d.out.x get\] iyo \[.mel.d.out.y get\] izo \[.mel.d.out.z get\] ixi \[.mel.d.in.x get\] iyi \[.mel.d.in.y get\] izi \[.mel.d.in.z get\] idx \[.mel.d.size.x get\] idy \[.mel.d.size.y get\] idz \[.mel.d.size.z get\]; destroy .mel\"" -bg $color
    button .mel.b.dismiss -text "Dismiss" -command "destroy .mel" -bg $color

    pack .mel.d.out .mel.d.in .mel.d.size -side left -fill both -pady 10 -padx 10

    pack .mel.b.ok .mel.b.dismiss -side left -expand true -fill x -padx 20 -pady 10
    pack .mel.d .mel.b
    }
}


inrimage::mergeView
Comments  
Arguments inr1
inr2
color
subcolor
Used by  
Uses inrimage::addObjectMenu
inrimage::multiviewMergeMenu
inrimage::createToplevel
proc inrimage::mergeView { inr1 inr2 {color "#E8E0D2"} {subcolor "#D8D0C2"}} {
    set mulview [new multiview]
    set parent ".${mulview}"
    inrimage::createToplevel $parent $inr1 $color
    
    wm title $parent "$inr1 ([lindex  [split  [$inr1 -name] /] end]  ) with $inr2 ([lindex  [split  [$inr1 -name] /] end]  ) "
    #attach multiview to widget ~/irm.inr  
    $mulview -parentWidget $parent
    #creates frames and sliders

    frame $parent.voxel -bg $color
    frame $parent.f1 -bg $color
    frame $parent.f2 -bg $color
    frame $parent.f2.g -bg $color
    frame $parent.f2.b -bg $color
    frame $parent.f2.m -bg $color
    frame $parent.f2.d -bg $color

    scale $parent.f2.b.opacity -orient horizontal -font fixed -width 10 -bg $color -label "opacity between $inr1 and $inr2"
    label $parent.f2.g.l -text "min and max \ngrey level $inr1" -bg $color
    scale $parent.f2.g.glmin -orient vertical -font fixed -width 10 -bg $color
    scale $parent.f2.g.glmax -orient vertical -font fixed -width 10 -bg $color      
    scale $parent.f2.d.glmin2 -orient vertical -font fixed -width 10 -bg $color
    label $parent.f2.d.l -text "min and max \ngrey level $inr2" -bg $color
    scale $parent.f2.d.glmax2 -orient vertical -font fixed -width 10 -bg $color  
    pack $parent.voxel  -fill both
    pack $parent.f1   -fill both
    
    
    #creates frames for menu
    set submenu $parent.submenu
    frame $parent.submenu  -bg "#D8D0C2"
    frame $submenu.context -height 26 -bg $subcolor
    label $submenu.name -text "no selected object" -anchor e -bg $subcolor
    pack $submenu.context -side left  -fill both
    pack $submenu.name -side right
    pack $submenu  -fill both
    
    #create min and max glscale
    set opacityscale [new opascale  -in $parent.f2.b.opacity]
    set minglscale [new glscale -min -in $parent.f2.g.glmin]
    set maxglscale [new glscale -max -in $parent.f2.g.glmax]
    set minglscale2 [new glscale -min -in $parent.f2.d.glmin2]
    set maxglscale2 [new glscale -max -in $parent.f2.d.glmax2]
    
    label $parent.voxel.v -font fixed  -bg $color -text "Voxel Value "
    label $parent.voxel.l -font fixed  -bg $color
    pack $parent.voxel.v $parent.voxel.l  -side left
    #pack $parent.voxel.v   -side left

    pack $parent.f2.g.l $parent.f2.d.l -side top -fill both
    pack  $parent.f2.b -side bottom -fill both
    pack  $parent.f2.g $parent.f2.m $parent.f2.d -side left -fill both

    pack  $parent.f2   -expand true -fill both
    pack  $parent.f2.d.glmin2 $parent.f2.d.glmax2 $parent.f2.g.glmin  $parent.f2.g.glmax -fill both -side left

    pack $parent.f2.b.opacity -fill both
    frame $parent.f2.m.ne -bg $color
    frame $parent.f2.m.so -bg $color -borderwidth 1
    frame $parent.f2.m.se -bg $color -borderwidth 1
    
    grid $parent.f2.m.ne -column 2 -row 1
    grid $parent.f2.m.so -column 1 -row 2
    grid $parent.f2.m.se -column 2 -row 2
    
    set inrv [new overinrview $inr1 $inr2 -noGLScale]
    set scn [$inrv -scene]
    #create first camera
    set cam1 [new slicecam Z -scene $scn -in $parent.f2.m.se -motion  $parent.voxel.l -useSlice true -useMenu true -menu $parent.submenu]
    $mulview -add $cam1
    #get background
    set bg1 [$inrv -background $cam1]
    #attach grey-level and opacity scales
    $bg1 -greyLevel min $minglscale
    $bg1 -greyLevel max $maxglscale
    $bg1 -greyLevel min2 $minglscale2
    $bg1 -greyLevel max2 $maxglscale2
    $bg1 -opacity $opacityscale
    #get slice scale
    set slicescale [$cam1 -slicescale]
    #create second camera
    set cam2 [new slicecam Y -scene $scn -in $parent.f2.m.ne -motion  $parent.voxel.l -useSlice true -useMenu false]
    $mulview -add $cam2
    #get background
    set bg2 [$inrv -background $cam2]
    #attach grey-level and opacity scales
    $bg2 -greyLevel min $minglscale
    $bg2 -greyLevel max $maxglscale
    $bg2 -greyLevel min2 $minglscale2
    $bg2 -greyLevel max2 $maxglscale2
    $bg2 -opacity $opacityscale
    #create second camera
    set cam3 [new slicecam X -scene $scn -in $parent.f2.m.so -motion  $parent.voxel.l -useSlice true -useMenu false]
    $mulview -add $cam3
    #get background
    set bg3 [$inrv -background $cam3]
    #attach grey-level and opacity scales
    $bg3 -greyLevel min $minglscale
    $bg3 -greyLevel max $maxglscale
    $bg3 -greyLevel min2 $minglscale2
    $bg3 -greyLevel max2 $maxglscale2
    $bg3 -opacity $opacityscale
    #add menu
    menubutton $parent.f1.mv -text "Multi-view" -anchor w -menu $parent.f1.mv.m -bg $color
    inrimage::multiviewMergeMenu $parent.f1.mv.m  $mulview $inr1 1
    pack $parent.f1.mv -side left
    menubutton $parent.f1.o  -text "Objects" -menu $parent.f1.o.m -anchor w -bg $color
    menu $parent.f1.o.m -bg $color -postcommand "
        scan \[ $cam1 -select \] {%s} selectedObject;  
    #delete previous items
        $parent.f1.o.m  delete 0 last
    foreach {i} \[ \[$cam1 -scene\] -objects\] {
        $parent.f1.o.m  add radio -selectcolor \"black\" -variable selectedObject -label \$i -command \" $cam1 -select \$i \"
}


inrimage::mergeView4D
Comments  
Arguments inr1
inr2
color
subcolor
Used by  
Uses inrimage::multiviewMergeMenu
inrimage::createToplevel
inrimage::addObjectMenu
proc inrimage::mergeView4D { inr1 inr2 {color "#E8E0D2"} {subcolor "#D8D0C2"}} {
    set mulview [new multiview4D]
    set parent ".${mulview}"
    inrimage::createToplevel $parent $inr1 $color
    
    wm title $parent "Merging $inr1 with $inr2"
    #attach multiview to widget
    $mulview -parentWidget $parent
    #creates frames and sliders
    frame $parent.f1 -bg $color
    frame $parent.f2 -bg $color
    scale $parent.opacity -orient horizontal -font fixed -width 10 -bg $color -label "opacity between $inr1 and $inr2"
    scale $parent.time -orient horizontal -font fixed -width 10 -bg $color -label "Time"
    scale $parent.slicex -orient horizontal -font fixed -width 10 -bg $color -label "X"
    scale $parent.slicey -orient horizontal -font fixed -width 10 -bg $color -label "Y"
    scale $parent.slicez -orient horizontal -font fixed -width 10 -bg $color -label "Z"
    scale $parent.glmin -orient horizontal -font fixed -width 10 -bg $color -label "min grey level for $inr1"
    scale $parent.glmax -orient horizontal -font fixed -width 10 -bg $color  -label "max grey level for $inr1"
    scale $parent.glmin2 -orient horizontal -font fixed -width 10 -bg $color -label "min grey level for $inr2"
    scale $parent.glmax2 -orient horizontal -font fixed -width 10 -bg $color  -label "max grey level for $inr2"
    pack $parent.f1 $parent.f2 $parent.opacity $parent.time $parent.slicex $parent.slicey $parent.slicez $parent.glmin $parent.glmax $parent.glmin2 $parent.glmax2 -expand true -fill x
    
    #create min and max glscale
    set timescale [new slicescale  -in $parent.time]
    set opacityscale [new opascale  -in $parent.opacity]
    set xscale [new slicescale  -in $parent.slicex]
    set yscale [new slicescale  -in $parent.slicey]
    set zscale [new slicescale  -in $parent.slicez]
    set minglscale [new glscale -min -in $parent.glmin]
    set maxglscale [new glscale -max -in $parent.glmax]
    set minglscale2 [new glscale -min -in $parent.glmin2]
    set maxglscale2 [new glscale -max -in $parent.glmax2]
    
    label $parent.f1.l -font fixed -anchor e -bg $color
    pack $parent.f1.l -side right -expand true -fill x
    
    frame $parent.f2.zy -bg $color -borderwidth 1
    frame $parent.f2.xz -bg $color -borderwidth 1
    frame $parent.f2.xy -bg $color -borderwidth 1
    frame $parent.f2.xt -bg $color -borderwidth 1
    frame $parent.f2.yt -bg $color -borderwidth 1
    frame $parent.f2.zt -bg $color -borderwidth 1
    label $parent.f2.lzy -text "ZY" -bg $color
    label $parent.f2.lxz -text "XZ" -bg $color
    label $parent.f2.lxy -text "XY" -bg $color
    label $parent.f2.lxt -text "XT" -bg $color
    label $parent.f2.lyt -text "YT" -bg $color
    label $parent.f2.lzt -text "ZT" -bg $color
    
    
    grid $parent.f2.zy -column 1 -row 1
    grid $parent.f2.xz -column 2 -row 1
    grid $parent.f2.xy -column 3 -row 1
    grid $parent.f2.lzy -column 1 -row 2
    grid $parent.f2.lxz -column 2 -row 2
    grid $parent.f2.lxy -column 3 -row 2
    grid $parent.f2.xt -column 1 -row 3
    grid $parent.f2.yt -column 2 -row 3
    grid $parent.f2.zt -column 3 -row 3
    grid $parent.f2.lxt -column 1 -row 4
    grid $parent.f2.lyt -column 2 -row 4
    grid $parent.f2.lzt -column 3 -row 4
    
    set inrv [new overinr4Dview $inr1 $inr2 -noGLScale]
    set scn [$inrv -scene]
    
    #create first camera
    set cam1 [new timecam Z -scene $scn -in $parent.f2.xy -motion  $parent.f1.l -useSlice true  -useSlice2 true -slice $zscale -slice2 $timescale]
    $mulview -add $cam1
    #get background
    set bg1 [$inrv -background $cam1]
    #attach grey-level and opacity scales
    $bg1 -greyLevel min $minglscale
    $bg1 -greyLevel max $maxglscale
    $bg1 -greyLevel min2 $minglscale2
    $bg1 -greyLevel max2 $maxglscale2
    $bg1 -opacity $opacityscale
    # ???????
    #get slice scale
    #set slicescale [$cam1 -slicescale]
    # ???????
    #create second camera
    set cam2 [new timecam Y -scene $scn -in $parent.f2.xz -motion  $parent.f1.l -useSlice true  -useSlice2 true -slice $yscale -slice2 $timescale]
    $mulview -add $cam2
    #get background
    set bg2 [$inrv -background $cam2]
    #attach grey-level and opacity scales
    $bg2 -greyLevel min $minglscale
    $bg2 -greyLevel max $maxglscale
    $bg2 -greyLevel min2 $minglscale2
    $bg2 -greyLevel max2 $maxglscale2
    $bg2 -opacity $opacityscale
    #create third camera
    set cam3 [new timecam X -scene $scn -in $parent.f2.zy -motion  $parent.f1.l -useSlice true  -useSlice2 true -slice $xscale -slice2 $timescale]
    $mulview -add $cam3
    #get background
    set bg3 [$inrv -background $cam3]
    #attach grey-level and opacity scales
    $bg3 -greyLevel min $minglscale
    $bg3 -greyLevel max $maxglscale
    $bg3 -greyLevel min2 $minglscale2
    $bg3 -greyLevel max2 $maxglscale2
    $bg3 -opacity $opacityscale
    #create fourth camera
    set cam4 [new timecam XT -scene $scn -in $parent.f2.xt -motion  $parent.f1.l -useSlice true  -useSlice2 true -slice $yscale -slice2 $zscale]
    $mulview -add $cam4
    #get background
    set bg4 [$inrv -background $cam4]
    #attach grey-level and opacity scales
    $bg4 -greyLevel min $minglscale
    $bg4 -greyLevel max $maxglscale
    $bg4 -greyLevel min2 $minglscale2
    $bg4 -greyLevel max2 $maxglscale2
    $bg4 -opacity $opacityscale
    #create fifth camera
    set cam5 [new timecam YT -scene $scn -in $parent.f2.yt -motion  $parent.f1.l -useSlice true  -useSlice2 true -slice $xscale -slice2 $zscale]
    $mulview -add $cam5
    #get background
    set bg5 [$inrv -background $cam5]
    #attach grey-level and opacity scales
    $bg5 -greyLevel min $minglscale
    $bg5 -greyLevel max $maxglscale
    $bg5 -greyLevel min2 $minglscale2
    $bg5 -greyLevel max2 $maxglscale2
    $bg5 -opacity $opacityscale
    #create sixth camera
    set cam6 [new timecam ZT -scene $scn -in $parent.f2.zt -motion  $parent.f1.l -useSlice true  -useSlice2 true -slice $xscale -slice2 $yscale]
    $mulview -add $cam6
    #get background
    set bg6 [$inrv -background $cam6]
    #attach grey-level and opacity scales
    $bg6 -greyLevel min $minglscale
    $bg6 -greyLevel max $maxglscale
    $bg6 -greyLevel min2 $minglscale2
    $bg6 -greyLevel max2 $maxglscale2
    $bg6 -opacity $opacityscale
    #add menu
    menubutton $parent.f1.mv -text "Multi-view 4D" -anchor w -menu $parent.f1.mv.m -bg $color
    inrimage::multiviewMergeMenu $parent.f1.mv.m  $mulview $inr1 1
    pack $parent.f1.mv -side left
    menubutton $parent.f1.o  -text "Objects" -menu $parent.f1.o.m -anchor w -bg $color
    menu $parent.f1.o.m -bg $color -postcommand "
        scan \[ $cam1 -select \] {%s} selectedObject;  
    #delete previous items
        $parent.f1.o.m  delete 0 last
    foreach {i} \[ \[$cam1 -scene\] -objects\] {
        $parent.f1.o.m  add radio -selectcolor \"black\" -variable selectedObject -label \$i -command \" $cam1 -select \$i \"
}


inrimage::morphomathematicDialog
Comments apply an arithmetic operator on an inrimage
Arguments img
color
Used by  
Uses inrimage::choiceFrame
proc inrimage::morphomathematicDialog { img {color "#E8E0D2"}} {
    if ![winfo exists .morpho] {
    toplevel .morpho -bg $color
    wm title .morpho "Morphomathematic operation"
    frame .morpho.d -bg $color
    frame .morpho.b -bg $color
    frame .morpho.d.operand -bg $color
    frame .morpho.d.element -bg $color

    inrimage::choiceFrame .morpho.d.operand.operator "morphomathematic operator" inrimage::operator $color {erosion ero} {dilation dil} {openning open} {closure close} {tophat tophat} {invtophat invtophat} {morphogradient grad} {lowermorphogradient lowgrad} {uppermorphogradient uppgrad} { medianfiltering median }
    set inrimage::operator ero

    inrimage::choiceFrame .morpho.d.operand.con "connexity" inrimage::con $color {"4 (2D edge)" 4} {"8 (2D vertex)" 8} {"6 (3D face)" 6} {"10 (????)" 10} {"18 (3D edge)" 18} {"26 (3D vertex)" 26}
    set inrimage::con 26

    frame .morpho.d.operand.niter -bg $color
    label .morpho.d.operand.niter.l -text "number of iterations" -relief raise -bg $color
    scale .morpho.d.operand.niter.s -from 1 -to 20 -orient vertical -bg $color

    inrimage::choiceFrame .morpho.d.operand.mode "Mode" inrimage::mode $color {"Binary" binary} {"GreyLevel" greylevel}
    set inrimage::mode greylevel

    button .morpho.b.ok -text "OK" -command "evaluate \"$img -morpho \$inrimage::operator con \$inrimage::con  i \[.morpho.d.operand.niter.s get\] \"; destroy .morpho" -bg $color
    button .morpho.b.dismiss -text "Dismiss" -command "destroy .morpho" -bg $color

    pack .morpho.d.operand.niter.l .morpho.d.operand.niter.s -fill y

    pack .morpho.d.operand.operator .morpho.d.operand.con .morpho.d.operand.niter .morpho.d.operand.mode -side left -expand true -fill both -padx 10 -pady 10
    #pack .morpho.d.element.l .morpho.d.element.r .morpho.d.element.b .morpho.d.element.list .morpho.d.element.center .morpho.d.element.lab_center -side left -expand true -fill x -padx 20 -pady 10
    pack .morpho.b.ok .morpho.b.dismiss -side left -expand true -fill x -padx 20 -pady 10
    pack .morpho.d.operand .morpho.d.element -side top
    pack .morpho.d .morpho.b
    }
}


inrimage::moveLandmark
Comments  
Arguments lset
camera
x
y
Used by  
Uses  
proc inrimage::moveLandmark {lset camera x y } {
    set widget [$camera -widget]
    $widget configure -closeenough 2.0
    $widget dtag selected
    $widget addtag selected closest $x $y

    set tagList [split [$widget gettags selected ] ]

    set template [ format "%sland*" $lset ]
    set name [ format "%sland" $lset ]
    foreach t $tagList {
    if {[string match  $template $t] } {
        scan  $t "$name%s" landm
        $lset -movingLandmark $landm
    }
    }

}


inrimage::multiview4Dmenu
Comments  
Arguments name
mname
img
toff
color
Used by inrimage::view4D
Uses inrimage::inr4Dlist
inrimage::viewerXCropMenu
inrimage::inr4Dmenu
inrimage::colormapMenu
proc inrimage::multiview4Dmenu { name mname img {toff 0} {color "#E8E0D2"}} {
    set mn [menu $name -tearoff $toff -bg $color -postcommand "set inrimage::useVoxelSize \[${mname} -ignoreVoxelSize\]; set inrimage::useAxis \[${mname} -axis\]; set inrimage::activate \[${mname} -activate\]"]
    $mn add command -label $mname -state disabled -command {}
    $mn add checkbutton -label "Use voxel size" -variable inrimage::useVoxelSize  -onvalue "false" -offvalue "true" -command "evaluate \"${mname} -ignoreVoxelSize \$inrimage::useVoxelSize\""
    $mn add checkbutton -label "Display axis" -variable inrimage::useAxis  -onvalue "true" -offvalue "false" -command "evaluate \"$mname -axis \$inrimage::useAxis\""
    $mn add cascade -label "Zoom" -menu $mn.zoom
    menu $mn.zoom -tearoff 0 -bg $color
    $mn.zoom add command -label " 25 %" -command "evaluate \"$mname -scale * 0.25\""
    $mn.zoom add command -label " 50 %" -command "evaluate \"$mname -scale * 0.5\""
    $mn.zoom add command -label " 75 %" -command "evaluate \"$mname -scale * 0.75\""
    $mn.zoom add command -label "125 %" -command "evaluate \"$mname -scale * 1.25\""
    $mn.zoom add command -label "150 %" -command "evaluate \"$mname -scale * 1.5\""
    $mn.zoom add command -label "200 %" -command "evaluate \"$mname -scale * 2\""
    $mn.zoom add command -label "300 %" -command "evaluate \"$mname -scale * 3\""
    $mn.zoom add command -label "400 %" -command "evaluate \"$mname -scale * 4\""
    $mn add cascade -label "Image Commands" -menu $mn.image
    $mn add command -label "Set Voxel Size" -command "inrimage::voxel4DSizeDialog $img $color"
    inrimage::inr4Dmenu $mn.image $img
    
    $mn add cascade -label "ColorMap" -menu $mn.colormap
    inrimage::colormapMenu $mn.colormap $mname $color
    $mn add cascade -label "Compare" -menu $mn.comp
    inrimage::inr4Dlist $mn.comp "evaluate \"$mname -add \[... -slicecams \] \" " 0 $color
    $mn add command -label "Set visible region..." -command "set inrimage::mview $mname; evaluate \"new bbox4D \[ lindex \[ split \[ $mname -views\] \] 0 \] -color green -menu  inrimage::viewerXVisibleMenu\""
    $mn add command -label "Reset visible region" -command "evaluate \"$mname -visible all\""
    $mn add command -label "Crop image..." -command "set inrimage::mview $mname; evaluate \"new bbox4D \[ lindex \[ split \[ $mname -views\] \] 0 \] -color cyan -menu  inrimage::viewerXCropMenu \""
    $mn add separator
    $mn add command -label "Script Dialog" -command "if {!\[winfo exists .yav\]} {loadSource tclModules.tcl; loadSource yav++.tcl;yav::interface}"
    $mn add separator
    $mn add command -label "destroy" -command "evaluate \"$mname -destroy\""
}


inrimage::multiviewMergeMenu
Comments  
Arguments name
mname
img
img2
toff
color
Used by inrimage::mergeView4D
inrimage::mergeView
Uses inrimage::inrmenu
inrimage::colormapMenu
inrimage::viewerXIsolateMenu
inrimage::viewerXZeroMenu
inrimage::viewerXCropMenu
proc inrimage::multiviewMergeMenu { name mname img img2 {toff 0} {color "#E8E0D2"}} {
    set mn [menu $name -tearoff $toff -bg $color -postcommand "set inrimage::useVoxelSize \[${mname} -ignoreVoxelSize\]; set inrimage::useAxis \[${mname} -axis\]; set inrimage::activate \[${mname} -activate\]"]
    $mn add command -label $mname -state disabled -command {}
    $mn add checkbutton -label "Use voxel size" -variable inrimage::useVoxelSize  -onvalue "false" -offvalue "true" -command "evaluate \"${mname} -ignoreVoxelSize \$inrimage::useVoxelSize\""
    $mn add checkbutton -label "Display axis" -variable inrimage::useAxis  -onvalue "true" -offvalue "false" -command "evaluate \"$mname -axis \$inrimage::useAxis\""
    $mn add cascade -label "Zoom" -menu $mn.zoom
    menu $mn.zoom -tearoff 0 -bg $color
    $mn.zoom add command -label " 25 %" -command "evaluate \"$mname -scale * 0.25\""
    $mn.zoom add command -label " 50 %" -command "evaluate \"$mname -scale * 0.5\""
    $mn.zoom add command -label " 75 %" -command "evaluate \"$mname -scale * 0.75\""
    $mn.zoom add command -label "125 %" -command "evaluate \"$mname -scale * 1.25\""
    $mn.zoom add command -label "150 %" -command "evaluate \"$mname -scale * 1.5\""
    $mn.zoom add command -label "200 %" -command "evaluate \"$mname -scale * 2\""
    $mn.zoom add command -label "300 %" -command "evaluate \"$mname -scale * 3\""
    $mn.zoom add command -label "400 %" -command "evaluate \"$mname -scale * 4\""
    $mn add cascade -label "ColorMap image 1" -menu $mn.colormap
    inrimage::colormapMenu $mn.colormap $mname $color
    $mn add cascade -label "ColorMap image 2" -menu $mn.colormap2
    inrimage::colormapMenu $mn.colormap2 $mname $color -scalemode2
    if ![string compare [limitedVersion] "false" ] {
    $mn add separator
    $mn add cascade -label "Image Commands Image 1" -menu $mn.image
    inrimage::inrmenu $mn.image $img  $mname
    $mn add cascade -label "Image Commands Image 2" -menu $mn.image2
    inrimage::inrmenu $mn.image2 $img2  $mname
    }
    $mn add separator
    $mn add command -label "Load Image..." -command {set inr [inrimage::loadImage];if [string compare $inr ""] { set inr [ evaluate "new inr $inr" ]; evaluate "view $inr" } }
    $mn add command -label "New Image..." -command "inrimage::inrimageDialog $color"
    $mn add separator
    $mn add command -label "Set visible region..." -command "set inrimage::mview $mname; evaluate \"new bbox3D \[ lindex \[ split \[ $mname -views\] \] 0 \] -color green -menu  inrimage::viewerXVisibleMenu\""
    $mn add command -label "Reset visible region" -command "evaluate \"$mname -visible all\""
    $mn add command -label "Crop image..." -command "set inrimage::mview $mname; evaluate \"new bbox3D \[ lindex \[ split \[ $mname -views\] \] 0 \] -color cyan -menu  inrimage::viewerXCropMenu \""
    $mn add command -label "Isolate Region..." -command "set inrimage::mview $mname; evaluate \"new bbox3D \[ lindex \[ split \[ $mname -views\] \] 0 \] -color yellow -menu  inrimage::viewerXIsolateMenu \""
    $mn add command -label "Zero Region..." -command "set inrimage::mview $mname; evaluate \"new bbox3D \[ lindex \[ split \[ $mname -views\] \] 0 \] -color magenta -menu  inrimage::viewerXZeroMenu \""
    $mn add checkbutton -label "Activate" -variable inrimage::activate  -onvalue "true" -offvalue "false" -command "evaluate \"$mname -activate \$inrimage::activate\""
    $mn add separator
    $mn add command -label "Script Dialog" -command "if {!\[winfo exists .yav\]} {loadSource tclModules.tcl; loadSource yav++.tcl;yav::interface}"
    $mn add separator
    $mn add command -label "destroy" -command "evaluate \"$mname -destroy\""
}


inrimage::multiviewmenu
Comments  
Arguments name
mname
img
toff
color
Used by inrimage::singleViewImage
inrimage::viewInrimage
Uses inrimage::colormapMenu
inrimage::inrlist
inrimage::viewerXZeroMenu
inrimage::viewerXCropMenu
inrimage::viewerXIsolateMenu
inrimage::inrmenu
inrimage::interpolationMenu
proc inrimage::multiviewmenu { name mname img {toff 0} {color "#E8E0D2"}} {
    set mn [menu $name -tearoff $toff -bg $color -postcommand "set inrimage::useVoxelSize \[${mname} -ignoreVoxelSize\]; set inrimage::useAxis \[${mname} -axis\]; set inrimage::activate \[${mname} -activate\]"]
    $mn add command -label $mname -state disabled -command {}
    $mn add checkbutton -label "Use voxel size" -variable inrimage::useVoxelSize  -onvalue "false" -offvalue "true" -command "evaluate \"${mname} -ignoreVoxelSize \$inrimage::useVoxelSize\""
    $mn add checkbutton -label "Display axis" -variable inrimage::useAxis  -onvalue "true" -offvalue "false" -command "evaluate \"$mname -axis \$inrimage::useAxis\""
    $mn add cascade -label "Zoom" -menu $mn.zoom
    menu $mn.zoom -tearoff 0 -bg $color
    $mn.zoom add command -label " 25 %" -command "evaluate \"$mname -scale * 0.25\""
    $mn.zoom add command -label " 50 %" -command "evaluate \"$mname -scale * 0.5\""
    $mn.zoom add command -label " 75 %" -command "evaluate \"$mname -scale * 0.75\""
    $mn.zoom add command -label "125 %" -command "evaluate \"$mname -scale * 1.25\""
    $mn.zoom add command -label "150 %" -command "evaluate \"$mname -scale * 1.5\""
    $mn.zoom add command -label "200 %" -command "evaluate \"$mname -scale * 2\""
    $mn.zoom add command -label "300 %" -command "evaluate \"$mname -scale * 3\""
    $mn.zoom add command -label "400 %" -command "evaluate \"$mname -scale * 4\""

    
    $mn add cascade -label "Interpolation" -menu $mn.interpolation
    inrimage::interpolationMenu $mn.interpolation $mname $color
    $mn add cascade -label "ColorMap" -menu $mn.colormap
    inrimage::colormapMenu $mn.colormap $mname $color
    $mn add separator
    $mn add command -label "Voxel size..." -command "inrimage::voxelSizeDialog $img $color"
    $mn add command -label "Save Image" -command "evaluate \"$img -save\" "
    $mn add command -label "Save Image as..." -command "set name \[inrimage::saveImage\]; if \[string compare \$name {}\] { evaluate \"$img -save \$name\" }"
    
    if ![string compare [limitedVersion] "false" ] {
    $mn add separator
    $mn add cascade -label "Image Processing Commands" -menu $mn.image
    inrimage::inrmenu $mn.image $img $mname
    }
    
    $mn add separator
    $mn add cascade -label "File..." -menu $mn.file
    menu $mn.file -tearoff 0 -bg $color

    


    $mn.file add command -label "Load Image..." -command {set inr [inrimage::loadImage];if [string compare $inr ""] { set inr [ evaluate "new inr $inr" ]; evaluate "view $inr" } }
    $mn.file add command -label "New Image..." -command "inrimage::inrimageDialog $color"
    $mn.file add cascade -label "View Image" -menu $mn.vi
    menu $mn.vi -tearoff 0 -postcommand "$mn.vi delete 0 last; foreach {i } \[which inr\] { $mn.vi add command -label \"\$i ( \[lindex  \[ split \[ \$i -name \] / \] end \])\" -command \"evaluate \\\" view \$i \\\" \" }"

    $mn add separator


    $mn add cascade -label "Landmarks..." -menu $mn.land
    menu $mn.land -tearoff 0 -bg $color
    $mn.land add command -label "Create Landmarks" -command "new lset -scene [inrimage::getScene2DFromMultiview $mname]"
    $mn.land add command -label "Load Landmarks" -command "new lset -scene [inrimage::getScene2DFromMultiview $mname] \[tk_getOpenFile -filetypes { {{Landmark Set} {.lset} } {{All} *} } -parent . -title {Select a Landmark Set} \]"

    $mn add separator
    $mn add cascade -label "Compare" -menu $mn.comp
    inrimage::inrlist $mn.comp "evaluate \"$mname -add \[... -slicecams \] \" " 0 $color
    $mn add command -label "Set visible region..." -command "set inrimage::mview $mname; evaluate \"new bbox3D \[ lindex \[ split \[ $mname -views\] \] 0 \] -color green -menu  inrimage::viewerXVisibleMenu\""
    $mn add command -label "Reset visible region" -command "evaluate \"$mname -visible all\""
    $mn add command -label "Crop image..." -command "set inrimage::mview $mname; evaluate \"new bbox3D \[ lindex \[ split \[ $mname -views\] \] 0 \] -color cyan -menu  inrimage::viewerXCropMenu \""
    $mn add command -label "Isolate Region..." -command "set inrimage::mview $mname; evaluate \"new bbox3D \[ lindex \[ split \[ $mname -views\] \] 0 \] -color yellow -menu  inrimage::viewerXIsolateMenu \""
    $mn add command -label "Zero Region..." -command "set inrimage::mview $mname; evaluate \"new bbox3D \[ lindex \[ split \[ $mname -views\] \] 0 \] -color magenta -menu  inrimage::viewerXZeroMenu \""
    #    $mn add checkbutton -label "Activate" -variable inrimage::activate  -onvalue "true" -offvalue "false" -command "evaluate \"$mname -activate \$inrimage::activate\""
    $mn add separator
    $mn add command -label "Script Dialog" -command "if {!\[winfo exists .yav\]} {loadSource tclModules.tcl; loadSource yav++.tcl;yav::interface}"
    $mn add separator

    $mn add cascade -label "Delete ..." -menu $mn.delete
    menu $mn.delete -tearoff 0 -bg $color

    $mn.delete add command -label "Delete Image" -command "if !\[ string compare \[tk_messageBox -type okcancel -message {Really Delete Image ? }\] ok \] { evaluate \"$mname -destroy\"; evaluate \"$img -destroy\"}"
    #$mn add separator
    $mn.delete add command -label "Delete Viewer" -command "evaluate \"$mname -destroy\""
}


inrimage::noiseDialog
Comments  
Arguments img
color
Used by  
Uses inrimage::inrscale
proc inrimage::noiseDialog { img {color "#E8E0D2"}} {

    if ![winfo exists .noise] {
    toplevel .noise -bg $color
    wm title .noise "Generate gaussian noisy box"

    frame .noise.d -bg $color
    frame .noise.b -bg $color

    frame .noise.d.par -bg $color
    label .noise.d.par.l1 -text "Noise parameters" -relief raised -bg $color
    radiobutton .noise.d.par.b1 -text "Mean value from image" -variable inrimage::fromimage -value 1  -bg $color -anchor w -command { .noise.d.par.mean configure -state disabled }
    radiobutton .noise.d.par.b2 -text "Fixed mean value" -variable inrimage::fromimage -value 0  -bg $color -anchor w -command { .noise.d.par.mean configure -state normal }
    set inrimage::fromimage 1
    inrimage::inrscale .noise.d.par.mean $img $color
    .noise.d.par.mean set 100.0
    .noise.d.par.mean configure -state disabled
    label .noise.d.par.l3 -text "Noise standard deviation" -bg $color -anchor w
    scale .noise.d.par.dev -from 0 -to 100.0 -resolution 0.1 -orient horiz -bg $color
    bind .noise.d.par.dev <Enter> { focus .noise.d.par.dev }
    .noise.d.par.dev set 3.0

    frame .noise.d.box -bg $color
    label .noise.d.box.l1 -text "Noise region" -relief raised -bg $color
    scan [$img -size] "%u %u %u" x y z
    set x [expr $x - 1]
    set y [expr $y - 1]
    set z [expr $z - 1]
    label .noise.d.box.l2 -text "From:" -bg $color -anchor w
    scale .noise.d.box.fx -from 0 -to $x -orient horiz -bg $color
    bind .noise.d.box.fx <Enter> { focus .noise.d.box.fx }
    scale .noise.d.box.fy -from 0 -to $y -orient horiz -bg $color
    bind .noise.d.box.fy <Enter> { focus .noise.d.box.fy }
    scale .noise.d.box.fz -from 0 -to $z -orient horiz -bg $color
    bind .noise.d.box.fz <Enter> { focus .noise.d.box.fz }
    label .noise.d.box.l3 -text "To:" -bg $color -anchor w
    scale .noise.d.box.tx -from 0 -to $x -orient horiz -bg $color
    .noise.d.box.tx set $x
    bind .noise.d.box.tx <Enter> { focus .noise.d.box.tx }
    scale .noise.d.box.ty -from 0 -to $y -orient horiz -bg $color
    .noise.d.box.ty set $y
    bind .noise.d.box.ty <Enter> { focus .noise.d.box.ty }
    scale .noise.d.box.tz -from 0 -to $z -orient horiz -bg $color
    .noise.d.box.tz set $z
    bind .noise.d.box.tz <Enter> { focus .noise.d.box.tz }

    button .noise.b.ok -text "OK" -command "if \$inrimage::fromimage { set mean \"\" } else { set mean \"mean \[.noise.d.par.mean get\]\"}; evaluate \"$img -noise \$mean dev \[.noise.d.par.dev get\] org \[.noise.d.box.fx get\] \[.noise.d.box.fy get\] \[.noise.d.box.fz get\] end \[.noise.d.box.tx get\] \[.noise.d.box.ty get\] \[.noise.d.box.tz get\]\"; destroy .noise" -bg $color
    button .noise.b.dismiss -text "Dismiss" -command "destroy .noise" -bg $color

    pack .noise.d.box.l1 .noise.d.box.l2 .noise.d.box.fx .noise.d.box.fy .noise.d.box.fz .noise.d.box.l3 .noise.d.box.tx .noise.d.box.ty .noise.d.box.tz -fill x
    pack .noise.d.par.l1 .noise.d.par.b1 .noise.d.par.b2 .noise.d.par.mean .noise.d.par.l3 .noise.d.par.dev -fill x
    pack .noise.d.par .noise.d.box -side left -padx 10 -pady 10 -fill both

    pack .noise.b.ok .noise.b.dismiss -side left -expand true -fill x -padx 20 -pady 10
    pack .noise.d .noise.b
    }
}


inrimage::opacityscalemenu
Comments  
Arguments sname
toff
color
Used by  
Uses  
proc inrimage::opacityscalemenu { sname {toff 0} {color "#E8E0D2"}} {
    set name [$sname -widget].m
    set mn [menu $name -tearoff $toff -bg $color -postcommand "set activate \[$sname -activate\]"]

    $mn add command -label $sname -state disabled -command {}
    $mn add cascade -label "add" -menu $mn.add
    menu $mn.add -tearoff $toff -bg $color -postcommand "$mn.add delete 0 last; foreach { i } \[ which overinrbgrnd \] {$mn.add add command -label \$i -command \" evaluate {  $sname -add \$i } \" }"
    $mn add cascade -label "remove" -menu $mn.remove
    menu $mn.remove -tearoff $toff -bg $color -postcommand "$mn.remove delete 0 last; foreach { i } \[ $sname -objects \] {$mn.remove add command -label \$i -command \" evaluate { $sname -remove \$i } \"}"
    $mn add cascade -label "speed" -menu $mn.speed
    menu $mn.speed -tearoff $toff -bg $color
    $mn.speed add command -label "very slow" -command "evaluate \"$sname -maxSteps 500\""
    $mn.speed add command -label "slow" -command "evaluate \"$sname -maxSteps 100\""
    $mn.speed add command -label "normal" -command "evaluate \"$sname -maxSteps 20\""
    $mn.speed add command -label "fast" -command "evaluate \"$sname -maxSteps 10\""
    $mn.speed add command -label "very fast" -command "evaluate \"$sname -maxSteps 5\""
    $mn add checkbutton -label "activate" -variable inrimage::activate  -onvalue "true" -offvalue "false" -command "$sname -activate \$inrimage::activate"
    $mn add separator
    $mn add command -label "destroy" -command "$sname -destroy"
    bind [$sname -widget] <Button-3> "tk_popup $name %X %Y"
}


inrimage::recursiveFilterDialog
Comments  
Arguments img
color
Used by  
Uses inrimage::choiceFrame
proc inrimage::recursiveFilterDialog { img {color "#E8E0D2"}} {

    if ![winfo exists .recfilter] {
    toplevel .recfilter -bg $color
    wm title .recfilter "Recursive filtering"

    frame .recfilter.d -bg $color
    frame .recfilter.b -bg $color

    frame .recfilter.d.sigma -bg $color

    inrimage::choiceFrame .recfilter.d.rfilter "Recursive filter" inrimage::rfilter $color {"Deriche step-edge" deriche} {"Deriche gaussian" gaussian} {"Marta" marta}
    label .recfilter.d.rfilter.l2 -text "Filter standard deviation" -bg $color
    scale .recfilter.d.rfilter.s1 -from 0.1 -to 20.0 -resolution 0.1 -orient horiz -bg $color
    .recfilter.d.rfilter.s1 set 3.0
    bind .recfilter.d.rfilter.s1 <Enter> { focus .recfilter.d.rfilter.s1 }
    pack .recfilter.d.rfilter.l2 .recfilter.d.rfilter.s1 -fill x
    set inrimage::rfilter deriche

    inrimage::choiceFrame .recfilter.d.filter "Filter type" inrimage::filter $color {"gaussian (2D)" "gauss 2D"} {"gaussian (3D)" "gauss 3D"} {"X smoothing" smoothX} {"Y smoothing" smoothY} {"Z smoothing" smoothZ} {"X first derivative" derX} {"Y first derivative" derY} {"Z first derivative" derZ} {"X second derivative" der2X} {"Y second derivative" der2Y} {"Z second derivative" der2Z}
    set inrimage::filter "gauss 3D"

    button .recfilter.b.ok -text "OK" -command "evaluate \"$img -recfilter \$inrimage::rfilter \$inrimage::filter sigma \[.recfilter.d.rfilter.s1 get\]\"; destroy .recfilter" -bg $color
    button .recfilter.b.dismiss -text "Dismiss" -command "destroy .recfilter" -bg $color

    pack .recfilter.d.rfilter .recfilter.d.filter -side left -fill both -padx 10 -pady 10
    pack .recfilter.b.ok .recfilter.b.dismiss -side left -expand true -fill x -padx 20 -pady 10
    pack .recfilter.d .recfilter.b
    }
}


inrimage::resizeGrid
Comments  
Arguments mview
grid
newHeight
newWidth
Used by  
Uses  
proc inrimage::resizeGrid {  mview grid newHeight newWidth} {
    if  [ expr [ winfo ismapped $grid ] || [ winfo ismapped $grid.so.f.view ] ]  {
    if [ string match $graphics2D::busy 0] {
        set graphics2D::busy 1
        set h [ winfo height $grid ]
        set w [ winfo width $grid ]
        set currentWidth [ expr [ winfo width $grid.so.f.view ] + [ winfo width $grid.se.f.view ] ]
        set currentHeight [ expr [ winfo height $grid.ne.f.view ] + [ winfo height $grid.se.f.view ] ]
        set sliderHeight [ expr [ winfo height $grid.ne.f.s ] + [ winfo height $grid.se.f.s ] ]
        set rw [ expr [ expr $w + 0.0 ] / $currentWidth]
        set rh [ expr  [ expr [ expr $h - $sliderHeight] + 0.0 ] / $currentHeight]
        if [ expr $rw < $rh ] {
        set r  $rw
        } else {
        set r  $rh  
        }
        set cam1  [ lindex [ $mview -views ] 0 ]
        $cam1 -scale [  expr $r * [ $cam1 -scale ] ]
        set cam2  [ lindex [ $mview -views ] 1 ]
        $cam2 -scale [  expr $r * [ $cam2 -scale ] ]
        set cam3  [ lindex [ $mview -views ] 2 ]
        $cam3 -scale [  expr $r * [ $cam3 -scale ] ]
        set graphics2D::busy 0
    }
     }
}


inrimage::resizeMergeGrid
Comments  
Arguments mview
grid
newHeight
newWidth
Used by  
Uses  
proc inrimage::resizeMergeGrid {  mview grid newHeight newWidth} {
    if  [ expr [ winfo ismapped $grid ] && [ winfo ismapped $grid.m.so.f.view ]  ]  {
    if [ string match $graphics2D::busy 0] {
        set graphics2D::busy 1
        set h [ winfo height $grid ]
        set w [ winfo width $grid ]
        set currentWidth [ expr [ winfo width $grid.m.so.f.view ] + [ winfo width $grid.m.se.f.view ] + [ winfo width $grid.d ] + [ winfo width $grid.g ] ]
        set currentHeight [ expr [ winfo height $grid.m.ne.f.view ] + [ winfo height $grid.m.se.f.view ] ]
        set sliderHeight [ expr [ winfo height $grid.m.ne.f.s ] + [ winfo height $grid.m.se.f.s ] ]
        set rw [ expr [ expr $w + 0.0 ] / $currentWidth]
        set rh [ expr  [ expr [ expr $h - $sliderHeight] + 0.0 ] / $currentHeight]
        if [ expr $rw < $rh ] {
        set r  $rw
        } else {
        set r  $rh  
        }
        set cam1  [ lindex [ $mview -views ] 0 ]
        $cam1 -scale [  expr $r * [ $cam1 -scale ] ]
        set cam2  [ lindex [ $mview -views ] 1 ]
        $cam2 -scale [  expr $r * [ $cam2 -scale ] ]
        set cam3  [ lindex [ $mview -views ] 2 ]
        $cam3 -scale [  expr $r * [ $cam3 -scale ] ]
        set graphics2D::busy 0
    }
    }
}


inrimage::resizeSingleGrid
Comments  
Arguments mview
grid
newHeight
newWidth
Used by  
Uses  
proc inrimage::resizeSingleGrid {  mview grid newHeight newWidth } {
    if  [ winfo ismapped $grid ] {
    if [ string match $graphics2D::busy 0] {
        set graphics2D::busy 1
        set h [ winfo height $grid ]
        set w [ winfo width $grid ]
        set currentWidth [  winfo width $grid.se.f.view ]
        set currentHeight [  winfo height $grid.se.f.view ]
        set sliderHeight [ winfo height $grid.se.f.s ]
        set rw [ expr [ expr $w + 0.0 ] / $currentWidth]
        set rh [ expr  [ expr [ expr $h - $sliderHeight] + 0.0 ] / $currentHeight]
        if [ expr $rw < $rh ] {
        set r  $rw
        } else {
            set r  $rh  
        }
        set cam1  [ lindex [ $mview -views ] 0 ]
        $cam1 -scale [  expr $r * [ $cam1 -scale ] ]
        set graphics2D::busy 0
    }
    }
}


inrimage::saveImage
Comments  
Arguments name
Used by  
Uses  
proc inrimage::saveImage {{name ""}} {
    return [tk_getSaveFile -filetypes {
    {"Inrimage, 3Ds" {.inr .inr.gz .hdr .dim} }
    {"2Ds" {.ppm .pgm} }
    {"Iris" {.rgb} }
    {"All" * }} -parent . -initialfile $name -title {Enter an image name}]
}


inrimage::setCmapFromMultiview
Comments  
Arguments multiview
cmap
option
cmoption
Used by inrimage::thresholdDialog
Uses  
proc inrimage::setCmapFromMultiview { multiview cmap {option "-scalemode"} {cmoption "none"} } {
    set  val "none"
    foreach {i} [ [ $multiview -scene] -objects] {
    if {[string match  inrview* $i]} {set val $i}
    if {[string match  inr4Dview* $i]} {set val $i}
    if {[string match  overinrview* $i]} {set val $i}
    if {[string match  overinr4Dview* $i]} {set val $i}
    }
    if { [string compare $val "none"] } {
    foreach {i}  [$multiview -views]  {
        if { [ string compare cmoption "none" ] } {
        [ $val -background $i ] $option $cmap $cmoption
        } else {
        [ $val -background $i ] $option $cmap
        }
    }
    } else {
    return "none"
    }
}


inrimage::setInterpolationFromMultiview
Comments  
Arguments multiview
interp
option
Used by  
Uses  
proc inrimage::setInterpolationFromMultiview { multiview interp {option "-interpolation"}  } {
    set  val "none"
    foreach {i} [ [ $multiview -scene] -objects] {
    if {[string match  inrview* $i]} {set val $i}
    if {[string match  inr4Dview* $i]} {set val $i}
    if {[string match  overinrview* $i]} {set val $i}
    if {[string match  overinr4Dview* $i]} {set val $i}
    }
    if { [string compare $val "none"] } {
    foreach {i}  [$multiview -views]  {
        [ $val -background $i ] $option $interp
    }
    } else {
    return "none"
    }
}


inrimage::singleViewImage
Comments  
Arguments inr1
geom
scene
color
subcolor
Used by  
Uses inrimage::createToplevel
inrimage::multiviewmenu
inrimage::addObjectMenu
proc inrimage::singleViewImage { inr1 { geom Z} {scene "none"} {color "#E8E0D2"} {subcolor "#D8D0C2"}} {
    set mulview [new multiview]
    set parent ".${mulview}"
    inrimage::createToplevel $parent $inr1 $color
    
    wm title $parent "Viewing $inr1"
    #attach multiview to widget
    $mulview -parentWidget $parent
    #creates frames and sliders
    frame $parent.voxel -bg $color
    frame $parent.f1 -bg $color
    frame $parent.f2 -bg $color

    scale $parent.glmin -orient horizontal -font fixed -width 10 -bg $color -label "min grey level"
    scale $parent.glmax -orient horizontal -font fixed -width 10 -bg $color  -label "max grey level"

    pack $parent.voxel  -fill both
    pack $parent.f1   -fill both

    #creates frames for menu
    set submenu $parent.submenu
    frame $parent.submenu  -bg "#D8D0C2"
    frame $submenu.context -height 26 -bg $subcolor
    label $submenu.name -text "no selected object" -anchor e -bg $subcolor
    pack $submenu.context -side left  -fill both
    pack $submenu.name -side right
    pack $submenu   -fill both

    #create min and max glscale
    set minglscale [new glscale -min -in $parent.glmin]
    set maxglscale [new glscale -max -in $parent.glmax]
    
    label $parent.voxel.v -font fixed  -bg $color -text "Voxel Value "
    label $parent.voxel.l -font fixed  -bg $color
    pack $parent.voxel.v $parent.voxel.l  -side left

    pack  $parent.f2   -expand true -fill both
    pack   $parent.glmax $parent.glmin  -fill x -side bottom -before $parent.f2
    
    frame $parent.f2.se -bg $color
    
    grid $parent.f2.se -column 1 -row 1
        
    if ![string compare $scene "none" ] {
    set inrv [new inrview $inr1  -noGLScale]
    } else {
    set inrv 0
    foreach {i} [$scene -objects] {
        if {[string match inrview* $i ]} {
        set inrv $i
        }
    }
    if ![ string compare $inrv "0"] {
        set inrv [new inrview $inr1  $scene -noGLScale]
    }
    }
    set scn [$inrv -scene]
    #create first camera
    set cam1 [new slicecam $geom -scene $scn -in $parent.f2.se -motion  $parent.voxel.l -useSlice true -useMenu true -menu $parent.submenu]
    $mulview -add $cam1
    #get background
    set bg1 [$inrv -background $cam1]
    #attach grey-level and opacity scales
    $bg1 -greyLevel min $minglscale
    $bg1 -greyLevel max $maxglscale
    #get slice scale
    set slicescale [$cam1 -slicescale]

    #add menu
    menubutton $parent.f1.mv -text "Multi-view" -anchor w -menu $parent.f1.mv.m -bg $color
    inrimage::multiviewmenu $parent.f1.mv.m  $mulview $inr1 1
    pack $parent.f1.mv -side left
    menubutton $parent.f1.o  -text "Objects" -menu $parent.f1.o.m -anchor w -bg $color
    menu $parent.f1.o.m -bg $color -postcommand "
        scan \[ $cam1 -select \] {%s} selectedObject;  
    #delete previous items
        $parent.f1.o.m  delete 0 last
    foreach {i} \[ \[$cam1 -scene\] -objects\] {
        $parent.f1.o.m  add radio -selectcolor \"black\" -variable selectedObject -label \$i -command \" $cam1 -select \$i \"
}


inrimage::slicecamlist
Comments  
Arguments name
cmd
toff
color
Used by  
Uses  
proc inrimage::slicecamlist { name cmd {toff 0} {color "#E8E0D2"}} {
    menu $name -tearoff $toff -bg $color -postcommand "$name delete 0 last; foreach { i } \[scalables\] { $name add command -label \$i -command \[modules::menusubstitute {$cmd} ... \$i\]}" -bg $color
}


inrimage::slicecammenu
Comments  
Arguments name
vname
toff
color
Used by inrimage::viewerPopupMenu
Uses inrimage::inrslicecammenu
inrimage::inrlist
proc inrimage::slicecammenu { name vname {toff 0} {color "#E8E0D2"} } {
    puts $vname
    set inrimage::inrslicemenu [menu $name -tearoff $toff -bg $color -postcommand "set inrimage::useVoxelSize \[$vname -ignoreVoxelSize\]; set inrimage::activate \[$vname -activate\]; set inrimage::theImage \[$vname -inrimage\]; if {\[string compare $inrimage::theImage \"no inrimage\"\]} { inrimage::inrslicecammenu $name $vname $color}"]
    set mn $inrimage::inrslicemenu
    $mn add command -label $vname -state disabled -command {}
    $mn add checkbutton -label "Use voxel size" -variable inrimage::useVoxelSize  -onvalue "false" -offvalue "true" -command "evaluate \"$vname -ignoreVoxelSize \$inrimage::useVoxelSize\""
    $mn add cascade -label "Zoom" -menu $mn.zoom
    menu $mn.zoom -tearoff 0 -bg $color
    $mn.zoom add command -label " 25 %" -command "evaluate \"$vname -scale * 0.25\""
    $mn.zoom add command -label " 50 %" -command "evaluate \"$vname -scale * 0.5\""
    $mn.zoom add command -label " 75 %" -command "evaluate \"$vname -scale * 0.75\""
    $mn.zoom add command -label "125 %" -command "evaluate \"$vname -scale * 1.25\""
    $mn.zoom add command -label "150 %" -command "evaluate \"$vname -scale * 1.5\""
    $mn.zoom add command -label "200 %" -command "evaluate \"$vname -scale * 2\""
    $mn.zoom add command -label "300 %" -command "evaluate \"$vname -scale * 3\""
    $mn.zoom add command -label "400 %" -command "evaluate \"$vname -scale * 4\""
    $mn add cascade -label "Slice" -menu $mn.slice
    menu $mn.slice -tearoff 0 -bg $color
    $mn.slice add command -label "X" -command "evaluate \"$vname -geometry X\""
    $mn.slice add command -label "Y" -command "evaluate \"$vname -geometry Y\""
    $mn.slice add command -label "Z" -command "evaluate \"$vname -geometry Z\""
    $mn.slice add command -label "alpha" -command "evaluate \"$vname -geometry alpha\""
    $mn add cascade -label "View image" -menu $mn.image
    inrimage::inrlist $mn.image "evaluate \"$vname -inrimage ...\"" 0 $color
    $mn add command -label "reset visible region" -command "evaluate \"$vname -visible all\""
    $mn add command -label "set visible region..." -command "evaluate \"new bbox3D \[ inrimage::getInrviewFromCamera  $vname\] -color green -menu  inrimage::viewerXVisibleMenu\""
    $mn add checkbutton -label "activate" -variable inrimage::activate  -onvalue "true" -offvalue "false" -command "evaluate \"$vname -activate \$inrimage::activate\""
    $mn add separator
    $mn add command -label "destroy" -command "evaluate \"$vname -destroy\""
}


inrimage::thresholdDialog
Comments  
Arguments img
mview
color
Used by  
Uses inrimage::inrscale
modules::drawHistogramInFrame
inrimage::setCmapFromMultiview
proc inrimage::thresholdDialog { img mview {color "#E8E0D2"}} {
    if ![winfo exists .threshold] {
    #get grey scale from mview
    set cam [ lindex [ $mview -views ] end ]
    set scn [ $cam -scene]
    set inrv "none"
    foreach { o } [ $scn -objects ] {
        if { [string match inrview* $o]} {set inrv $o}
        if {[string match  inr4Dview* $o]} {set inrv $o}    
        if {[string match  overinrview* $o]} {set inrv $o}
        if {[string match  overinr4Dview* $o]} {set inrv $o}
    }
    if { [string compare $inrv "none"] } {
        set bg [ $o -background $cam ]
        inrimage::setCmapFromMultiview $mview threshold
        set minScale [ [ $bg -greyLevel min ]  -widget ]
        set maxScale [ [ $bg -greyLevel max ] -widget ]
        
        set createGL 0
    } else  {
        set createGL 1
    }
    #copy of the original image
    set orgImg $img
    toplevel .threshold -bg $color
    wm title .threshold "Thresholding"

    frame .threshold.h -bg $color
    frame .threshold.d -bg $color
    frame .threshold.b -bg $color

    set histo [ $img -histogram ]
    modules::drawHistogramInFrame .threshold.h $histo $color
    set maxSample [$histo -stat maxNbSamples]
    pack .threshold.h
    frame .threshold.d.th -bg $color
    if {$createGL} {
        label .threshold.d.th.l1 -bg $color -text "Low threshold value" -anchor w
        inrimage::inrscale .threshold.d.th.min $img $color min
        label .threshold.d.th.l2 -bg $color -text "High threshold value" -anchor w
        inrimage::inrscale .threshold.d.th.max $img $color max
        set minScale .threshold.d.th.min
        set maxScale .threshold.d.th.max
    }
    
    set minLine [.threshold.h.g marker create line -coords "0 0 0 $maxSample" -outline "#FF0000"]
    bind $minScale <Enter> "focus $minScale"
    bind $minScale <Motion> ".threshold.h.g marker configure $minLine -coords \"\[ $minScale get \] 0 \[ $minScale get \] $maxSample\""


    set maxLine [.threshold.h.g marker create line -coords "[ $maxScale get ] 0 [ $maxScale get ] $maxSample" -outline "#00FF00" ]
    bind $maxScale <Enter> "focus $maxScale"
    bind $maxScale <Motion> ".threshold.h.g marker configure $maxLine -coords \"\[ $maxScale get \] 0 \[ $maxScale get \] $maxSample\""

    frame .threshold.d.fbg -bg $color
    label .threshold.d.fbg.l1 -bg $color -text "Thresholded image background value" -anchor w
    inrimage::inrscale .threshold.d.fbg.bg $img $color min
    radiobutton .threshold.d.fbg.crop -text "Keep voxels in \[min; max\]" -variable inrimage::cmd -value crop -bg $color -anchor w  -command ".threshold.d.fbg.fg configure -state disabled"
    radiobutton .threshold.d.fbg.nocrop -text "Set voxels in \[min; max\] to foreground" -variable inrimage::cmd -value nocrop -bg $color -anchor w  -command ".threshold.d.fbg.fg configure -state normal"
    label .threshold.d.fbg.l2 -bg $color -text "thresholded image foreground value" -anchor w
    inrimage::inrscale .threshold.d.fbg.fg $img $color max
    set inrimage::cmd nocrop

    frame .threshold.d.out -bg $color
    label .threshold.d.out.l1 -bg $color -text "Output of thresholding" -anchor w
    radiobutton .threshold.d.out.new -text "Put in new image" -variable inrimage::thout -value copy -bg $color -anchor w
    radiobutton .threshold.d.out.repl -text "Replace image" -variable inrimage::thout -value repl -bg $color -anchor w
    radiobutton .threshold.d.out.roi -text "Create ROI" -variable inrimage::thout -value roi -bg $color -anchor w
    set inrimage::thout copy
    
    button .threshold.b.ok -text "OK" -command "if \[string compare \$inrimage::thout repl\] {set img \[ evaluate \"$img -copy\" \] }; if !\[string compare \$inrimage::cmd crop\] { evaluate \"\$img -cropHistogramm min \[$minScale get\] max \[$maxScale get\] bg \[.threshold.d.fbg.bg get\]\" } else { evaluate \"\$img -threshold min \[$minScale get\] max \[$maxScale get\] bg \[.threshold.d.fbg.bg get\] fg \[.threshold.d.fbg.fg get\]\" }; if !\[string compare \$inrimage::thout copy\] { evaluate \"view \$img\" }; if !\[string compare \$inrimage::thout roi\] {evaluate \" new roi $orgImg \$img  \[inrimage::getScene2DFromInr $orgImg\]; \$img -destroy \"}; destroy .threshold;$histo -destroy;if {!$createGL} { bind $minScale <Motion> \"\";bind $maxScale <Motion> \"\" };inrimage::setCmapFromMultiview $mview affine" -bg $color
    button .threshold.b.dismiss -text "Dismiss" -command "destroy .threshold;if {!$createGL} { bind $minScale <Motion> \"\";bind $maxScale <Motion> \"\" };    inrimage::setCmapFromMultiview $mview affine" -bg $color

    pack .threshold.d.out.l1 .threshold.d.out.new .threshold.d.out.repl .threshold.d.out.roi -fill x
    if {$createGL} {
        pack .threshold.d.th.l1 $minScale .threshold.d.th.l2 $maxScale -fill x
    }

    pack .threshold.d.fbg.l1 .threshold.d.fbg.bg .threshold.d.fbg.crop .threshold.d.fbg.nocrop .threshold.d.fbg.l2 .threshold.d.fbg.fg -fill x

    pack .threshold.d.th .threshold.d.fbg .threshold.d.out -side left -fill both -pady 10 -padx 10
    

    pack .threshold.b.ok .threshold.b.dismiss -side left -expand true -fill x -padx 20 -pady 10
    pack .threshold.d .threshold.b
    }
}


inrimage::uninstallInrviewMenu
Comments  
Arguments viewer
camera
line
Used by  
Uses  
proc inrimage::uninstallInrviewMenu {viewer camera line} {
    # remove frame children
    set list [winfo children $viewer.context]  
    foreach w $list { destroy $w}
    pack $viewer.context -fill x
}


inrimage::uninstallLandmarkSetMenu
Comments  
Arguments viewer
camera
line
Used by  
Uses  
proc inrimage::uninstallLandmarkSetMenu {viewer camera line} {
    # remove frame children
    set list [winfo children $viewer.context]
    foreach w $list { destroy $w}
    pack $viewer.context -fill x
#    bind [$camera -widget] <Button-3> ""

}


inrimage::uninstallROIEditMenu
Comments  
Arguments viewer
camera
line
Used by  
Uses  
proc inrimage::uninstallROIEditMenu { 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> ""
}


inrimage::uninstallROIMenu
Comments  
Arguments viewer
camera
line
Used by  
Uses  
proc inrimage::uninstallROIMenu { 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> ""
}


inrimage::vectorDialog
Comments }
Arguments inr
inrview
color
mode
Used by  
Uses  
proc inrimage::vectorDialog { inr inrview color mode} {
    puts "MODE= $mode"
    if ![winfo exists .vector] {
    toplevel .vector -bg $color
    wm title .vector "Display Mode of 3D Field"
    frame .vector.d  -bg $color
    frame .vector.b  -bg $color
    
    frame .vector.d.echan -bg $color
    frame .vector.d.taille -bg $color
    frame .vector.d.long -bg $color
    frame .vector.d.norm -bg $color
    frame .vector.d.scale -bg $color
    frame .vector.d.color -bg $color
    
    label .vector.d.echan.l -text "Sampling" -bg blue -fg white
    set dimx [lindex [$inr -size] 0]
    set dimy [lindex [$inr -size] 1]
    set dimz [lindex [$inr -size] 2]

    scale .vector.d.echan.x -orient horizontal -resolution 1 -from 1 -to $dimx -length 100 -font fixed -width 10 -bg $color -label "sous-ech en x"
    scale .vector.d.echan.y -orient horizontal -resolution 1 -from 1 -to $dimy -length 100 -font fixed -width 10 -bg $color -label "sous-ech en y"
    scale .vector.d.echan.z -orient horizontal -resolution 1 -from 1 -to $dimz -length 100 -font fixed -width 10 -bg $color -label "sous-ech en z"
    pack .vector.d.echan.l .vector.d.echan.x .vector.d.echan.y .vector.d.echan.z -side top

    label .vector.d.taille.l -text "Taille" -bg blue -fg white
    scale .vector.d.taille.s -orient vertical -resolution 1 -from 1 -to 10 -length 100 -font fixed -width 10 -bg $color -label "Taille des fleches"
    checkbutton .vector.d.taille.b -text "with arrow" -variable inrimage::arrow -onvalue true -offvalue false -bg $color -anchor w -command "evaluate \"$inrview -arrow \$inrimage::arrow\""

    pack .vector.d.taille.l .vector.d.taille.s .vector.d.taille.b -side top -pady 10  

    label .vector.d.long.l -text "Maximum longueur Mode" -bg blue -fg white
    radiobutton .vector.d.long.r1 -text "MAX2" -variable inrimage::longMaxMode -value "MAX2" -command "evaluate \"$inrview -longMaxMode MAX2\"" -bg $color
    radiobutton .vector.d.long.r2 -text "MAX" -variable inrimage::longMaxMode -value "MAX" -command "evaluate \"$inrview -longMaxMode MAX\"" -bg $color
    radiobutton .vector.d.long.r3 -text "MIN2" -variable inrimage::longMaxMode -value "MIN2" -command "evaluate \"$inrview -longMaxMode MIN2\"" -bg $color
    radiobutton .vector.d.long.r4 -text "MIN" -variable inrimage::longMaxMode -value "MIN" -command "evaluate \"$inrview -longMaxMode MIN\"" -bg $color
    pack .vector.d.long.l .vector.d.long.r1 .vector.d.long.r2 .vector.d.long.r3 .vector.d.long.r4 -side top -pady 5 -padx 10 -anchor w

    label .vector.d.norm.l -text "Norm Mode" -bg blue -fg white
    radiobutton .vector.d.norm.r1 -text "LINEAR" -variable inrimage::normMode -value "LINEAR" -command ".vector.d.norm.e configure -state disabled" -bg $color
    radiobutton .vector.d.norm.r2 -text "EXP" -variable inrimage::normMode -value "EXP" -command ".vector.d.norm.e configure -state normal" -bg $color
    entry .vector.d.norm.e -fg black -bg white -relief sunken -textvariable alpha -state disabled
    pack .vector.d.norm.l .vector.d.norm.r1 .vector.d.norm.r2 .vector.d.norm.e -side top -pady 5 -padx 10 -anchor w

    label .vector.d.scale.l -text "Vector Scale" -bg blue -fg white
    scale .vector.d.scale.s  -orient vertical -resolution 0.2 -from 0 -to 10 -length 100 -font fixed -width 10 -bg $color -label "Scale des fleches"
    .vector.d.scale.s set 1

    pack .vector.d.scale.l .vector.d.scale.s -side top -pady 5 -padx 10 -anchor w


    label .vector.d.color.l -text "Color Scale" -bg blue -fg white
    scale .vector.d.color.i -orient horizontal -resolution 0.1 -from [[$inrview -GLScale [lindex [$inr -slicecams] 0] -min] -get] -to [[$inrview -GLScale [lindex [$inr -slicecams] 0] -max] -get] -length 100 -font fixed -width 10 -bg $color -label "seuil du bleu"
    scale .vector.d.color.s -orient horizontal -resolution 1 -from [[$inrview -GLScale [lindex [$inr -slicecams] 0] -min] -get] -to [[$inrview -GLScale [lindex [$inr -slicecams] 0] -max] -get] -length 100 -font fixed -width 10 -bg $color -label "seuil du rouge"
    .vector.d.color.s set [[$inrview -GLScale [lindex [$inr -slicecams] 0] -max] -get]
    pack .vector.d.color.l .vector.d.color.i .vector.d.color.s -side top -pady 5 -padx 10 -anchor w

    pack .vector.d.echan .vector.d.taille .vector.d.long .vector.d.norm .vector.d.scale .vector.d.color -side left -pady 10 -padx 10 -expand true
    
    button .vector.b.app -text "Apply" -command "evaluate \"$inrview -colorScale \[.vector.d.color.i get\] \[.vector.d.color.s get\]\"; evaluate \"$inrview -vectorScale \[.vector.d.scale.s get\]\"; evaluate \"$inrview -normMode \$inrimage::normMode \$alpha\"; evaluate \"$inrview -displayMode $mode \[.vector.d.echan.x get\] \[.vector.d.echan.y get\] \[.vector.d.echan.z get\] \[.vector.d.taille.s get\] \"" -bg $color

    button .vector.b.ok -text "OK" -command "evaluate \"$inrview -colorScale \[.vector.d.color.i get\] \[.vector.d.color.s get\]\"; evaluate \"$inrview -vectorScale \[.vector.d.scale.s get\]\"; evaluate \"$inrview -normMode \$inrimage::normMode \$alpha\"; evaluate \"$inrview -displayMode $mode \[.vector.d.echan.x get\] \[.vector.d.echan.y get\] \[.vector.d.echan.z get\] \[.vector.d.taille.s get\] \"; destroy .vector" -bg $color
    button .vector.b.dismiss -text "Dismiss"  -command "destroy .vector" -bg $color

    pack .vector.b.ok .vector.b.app .vector.b.dismiss -side left -padx 10 -pady 10

    pack .vector.d .vector.b -side top
    }
}


inrimage::view4D
Comments  
Arguments inr1
color
subcolor
Used by  
Uses inrimage::createToplevel
inrimage::multiview4Dmenu
inrimage::addObjectMenu
proc inrimage::view4D { inr1 {color "#E8E0D2"} {subcolor "#D8D0C2"}} {
    set mulview [new multiview4D]
    set parent ".${mulview}"
    inrimage::createToplevel $parent $inr1 $color
    
    wm title $parent "Viewing 4D image  $inr1"
    #attach multiview to widget
    $mulview -parentWidget $parent
    #creates frames and sliders
    frame $parent.f1 -bg $color
    frame $parent.f2 -bg $color
    scale $parent.time -orient horizontal -font fixed -width 10 -bg $color -label "Time"
    scale $parent.slicex -orient horizontal -font fixed -width 10 -bg $color -label "X"
    scale $parent.slicey -orient horizontal -font fixed -width 10 -bg $color -label "Y"
    scale $parent.slicez -orient horizontal -font fixed -width 10 -bg $color -label "Z"
    scale $parent.glmin -orient horizontal -font fixed -width 10 -bg $color -label "min grey level"
    scale $parent.glmax -orient horizontal -font fixed -width 10 -bg $color  -label "max grey level"
    pack $parent.f1 $parent.f2 $parent.time $parent.slicex $parent.slicey $parent.slicez $parent.glmin $parent.glmax  -expand true -fill x

    #create min and max glscale
    set timescale [new slicescale  -in $parent.time]
    set xscale [new slicescale  -in $parent.slicex]
    set yscale [new slicescale  -in $parent.slicey]
    set zscale [new slicescale  -in $parent.slicez]
    set minglscale [new glscale -min -in $parent.glmin]
    set maxglscale [new glscale -max -in $parent.glmax]
    
    label $parent.f1.l -font fixed -anchor e -bg $color
    pack $parent.f1.l -side right -expand true -fill x
    
    frame $parent.f2.zy -bg $color -borderwidth 1
    frame $parent.f2.xz -bg $color -borderwidth 1
    frame $parent.f2.xy -bg $color -borderwidth 1
    frame $parent.f2.xt -bg $color -borderwidth 1
    frame $parent.f2.yt -bg $color -borderwidth 1
    frame $parent.f2.zt -bg $color -borderwidth 1
    label $parent.f2.lzy -text "ZY" -bg $color
    label $parent.f2.lxz -text "XZ" -bg $color
    label $parent.f2.lxy -text "XY" -bg $color
    label $parent.f2.lxt -text "XT" -bg $color
    label $parent.f2.lyt -text "YT" -bg $color
    label $parent.f2.lzt -text "ZT" -bg $color
    

    grid $parent.f2.zy -column 1 -row 1
    grid $parent.f2.xz -column 2 -row 1
    grid $parent.f2.xy -column 3 -row 1
    grid $parent.f2.lzy -column 1 -row 2
    grid $parent.f2.lxz -column 2 -row 2
    grid $parent.f2.lxy -column 3 -row 2
    grid $parent.f2.xt -column 1 -row 3
    grid $parent.f2.yt -column 2 -row 3
    grid $parent.f2.zt -column 3 -row 3
    grid $parent.f2.lxt -column 1 -row 4
    grid $parent.f2.lyt -column 2 -row 4
    grid $parent.f2.lzt -column 3 -row 4
    
    
    set inrv [new inr4Dview $inr1 -noGLScale]
    set scn [$inrv -scene]
    #create first camera
    set cam1 [new timecam Z -scene $scn -in $parent.f2.xy -motion  $parent.f1.l -useSlice true  -useSlice2 true -slice $zscale -slice2 $timescale]
    $mulview -add $cam1
    #get background
    set bg1 [$inrv -background $cam1]
    #attach grey-level and opacity scales
    $bg1 -greyLevel min $minglscale
    $bg1 -greyLevel max $maxglscale
    #create second camera
    set cam2 [new timecam Y -scene $scn -in $parent.f2.xz -motion  $parent.f1.l -useSlice true  -useSlice2 true -slice $yscale -slice2 $timescale]
    $mulview -add $cam2
    #get background
    set bg2 [$inrv -background $cam2]
    #attach grey-level and opacity scales
    $bg2 -greyLevel min $minglscale
    $bg2 -greyLevel max $maxglscale
    #create third camera
    set cam3 [new timecam X -scene $scn -in $parent.f2.zy -motion  $parent.f1.l -useSlice true  -useSlice2 true -slice $xscale -slice2 $timescale]
    $mulview -add $cam3
    #get background
    set bg3 [$inrv -background $cam3]
    #attach grey-level and opacity scales
    $bg3 -greyLevel min $minglscale
    $bg3 -greyLevel max $maxglscale
    #create fourth camera
    set cam4 [new timecam XT -scene $scn -in $parent.f2.xt -motion  $parent.f1.l -useSlice true  -useSlice2 true -slice $yscale -slice2 $zscale]
    $mulview -add $cam4
    #get background
    set bg4 [$inrv -background $cam4]
    #attach grey-level and opacity scales
    $bg4 -greyLevel min $minglscale
    $bg4 -greyLevel max $maxglscale
    #create fifth camera
    set cam5 [new timecam YT -scene $scn -in $parent.f2.yt -motion  $parent.f1.l -useSlice true  -useSlice2 true -slice $xscale -slice2 $zscale]
    $mulview -add $cam5
    #get background
    set bg5 [$inrv -background $cam5]
    #attach grey-level and opacity scales
    $bg5 -greyLevel min $minglscale
    $bg5 -greyLevel max $maxglscale
    #create sixth camera
    set cam6 [new timecam ZT -scene $scn -in $parent.f2.zt -motion  $parent.f1.l -useSlice true  -useSlice2 true -slice $xscale -slice2 $yscale]
    $mulview -add $cam6
    #get background
    set bg6 [$inrv -background $cam6]
    #attach grey-level and opacity scales
    $bg6 -greyLevel min $minglscale
    $bg6 -greyLevel max $maxglscale
    #add menu
    menubutton $parent.f1.mv -text "Multi-view" -anchor w -menu $parent.f1.mv.m -bg $color
    inrimage::multiview4Dmenu $parent.f1.mv.m  $mulview $inr1 1
    pack $parent.f1.mv -side left
    menubutton $parent.f1.ao -text "Add Objects" -anchor w -menu $parent.f1.ao.m -bg $color
    inrimage::addObjectMenu $parent.f1.ao.m $mulview $inr1 1
    pack $parent.f1.ao -side left  
}


inrimage::viewInrimage
Comments  
Arguments inr1
scene
color
subcolor
Used by  
Uses inrimage::multiviewmenu
inrimage::addObjectMenu
inrimage::createToplevel
proc inrimage::viewInrimage { inr1 {scene "none"} {color "#E8E0D2"} {subcolor "#D8D0C2"}} {
    set mulview [new multiview]
    set parent ".${mulview}"
    inrimage::createToplevel $parent $inr1 $color
    
    wm title $parent "$inr1 ([lindex  [split  [$inr1 -name] /] end]  )"
    #attach multiview to widget
    $mulview -parentWidget $parent
    #creates frames and sliders
    frame $parent.voxel -bg $color
    frame $parent.f1 -bg $color
    frame $parent.f2 -bg $color

    scale $parent.glmin -orient horizontal -font fixed -width 10 -bg $color -label "min grey level"  
    scale $parent.glmax -orient horizontal -font fixed -width 10 -bg $color  -label "max grey level"

    pack $parent.voxel  -fill both
    pack $parent.f1   -fill both

    #creates frames for menu
    set submenu $parent.submenu
    frame $parent.submenu  -bg "#D8D0C2"
    frame $submenu.context -height 26 -bg $subcolor
    label $submenu.name -text "no selected object" -anchor e -bg $subcolor
    pack $submenu.context -side left -expand true -fill both
    pack $submenu.name -side right
    pack $submenu  -fill both

    #create min and max glscale
    set minglscale [new glscale -min -in $parent.glmin]
    set maxglscale [new glscale -max -in $parent.glmax]
    
    label $parent.voxel.v -font fixed  -bg $color -text "Voxel Value "
    label $parent.voxel.l -font fixed  -bg $color
    pack $parent.voxel.v $parent.voxel.l  -side left

    pack  $parent.f2   -expand true -fill both
    pack  $parent.glmax $parent.glmin -fill x  -side bottom -before $parent.f2  
    
    frame $parent.f2.ne -bg $color
    frame $parent.f2.so -bg $color -borderwidth 1
    frame $parent.f2.se -bg $color -borderwidth 1
    
    grid $parent.f2.ne -column 2 -row 1
    grid $parent.f2.so -column 1 -row 2
    grid $parent.f2.se -column 2 -row 2      
    grid rowconfigure $parent.f2 1 -weight 1
    grid rowconfigure $parent.f2 2 -weight 1
    
    if ![string compare $scene "none" ] {
    set inrv [new inrview $inr1  -noGLScale]
    } else {
    set inrv 0
    foreach {i} [$scene -objects] {
        if {[string match inrview* $i ]} {
        set inrv $i
        }
    }
    if ![ string compare $inrv "0"] {
        set inrv [new inrview $inr1  $scene -noGLScale]
    }
    }
    set scn [$inrv -scene]
    #create first camera
    set cam1 [new slicecam Z -scene $scn -in $parent.f2.se -motion  $parent.voxel.l -useSlice true -useMenu true -menu $parent.submenu]
    $mulview -add $cam1
    #get background
    set bg1 [$inrv -background $cam1]
    #attach grey-level and opacity scales
    $bg1 -greyLevel min $minglscale
    $bg1 -greyLevel max $maxglscale
    #get slice scale
    set slicescale [$cam1 -slicescale]
    #create second camera
    set cam2 [new slicecam Y -scene $scn -in $parent.f2.ne -motion  $parent.voxel.l -useSlice true -useMenu false]
    $mulview -add $cam2
    #get background
    set bg2 [$inrv -background $cam2]
    #attach grey-level and opacity scales
    $bg2 -greyLevel min $minglscale
    $bg2 -greyLevel max $maxglscale
    #create second camera
    set cam3 [new slicecam X -scene $scn -in $parent.f2.so -motion  $parent.voxel.l -useSlice true -useMenu false]
    $mulview -add $cam3
    #get background
    set bg3 [$inrv -background $cam3]
    #attach grey-level and opacity scales
    $bg3 -greyLevel min $minglscale
    $bg3 -greyLevel max $maxglscale
    #add menu
    menubutton $parent.f1.mv -text "Multi-view" -anchor w -menu $parent.f1.mv.m -bg $color
    inrimage::multiviewmenu $parent.f1.mv.m  $mulview $inr1 1
    pack $parent.f1.mv -side left
    menubutton $parent.f1.o  -text "Objects" -menu $parent.f1.o.m -anchor w -bg $color
    menu $parent.f1.o.m -bg $color -postcommand "
        scan \[ $cam1 -select \] {%s} selectedObject;  
    #delete previous items
        $parent.f1.o.m  delete 0 last
    foreach {i} \[ \[$cam1 -scene\] -objects\] {
        $parent.f1.o.m  add radio -selectcolor \"black\" -variable selectedObject -label \$i -command \" $cam1 -select \$i \"
}


inrimage::viewerPopupMenu
Comments  
Arguments slicecam
color
Used by  
Uses inrimage::slicecammenu
proc inrimage::viewerPopupMenu { slicecam {color "#E8E0D2"}} {
    set mint [$slicecam -widget].m
    if {![winfo exists $mint]} {
    inrimage::slicecammenu $mint $slicecam 0 $color
    }
    bind [$slicecam -widget] <Button-3> "tk_popup $mint %X %Y"
}


inrimage::viewerXCropMenu
Comments  
Arguments slicecam
bbox
color
Used by inrimage::multiview4Dmenu
inrimage::multiviewmenu
inrimage::multiviewMergeMenu
Uses inrimage::getInrFromCamera
proc inrimage::viewerXCropMenu { slicecam bbox {color "#E8E0D2"} } {
    set mint [$slicecam -widget].crop

    if {![winfo exists $mint]} {
    
    set mn [menu $mint -tearoff 0 -bg $color]
    $mn add command -label $slicecam -state disabled -command {}
    $mn add command -label "crop" -command "evaluate \" \[ inrimage::getInrFromCamera $slicecam \] -crop org \[$bbox -boxSize -org\] end \[$bbox -boxSize -end\]\";$bbox -destroy"
    $mn add command -label "drop" -command "$bbox -destroy"
    }

    bind [$slicecam -widget] <Button-3> "tk_popup $mint %X %Y"
}


inrimage::viewerXIsolateMenu
Comments  
Arguments slicecam
bbox
color
Used by inrimage::multiviewmenu
inrimage::multiviewMergeMenu
Uses inrimage::getInrFromCamera
proc inrimage::viewerXIsolateMenu { slicecam bbox {color "#E8E0D2"} } {
    set mint [$slicecam -widget].crop

    if {![winfo exists $mint]} {
    set mn [menu $mint -tearoff 0 -bg $color]
    $mn add command -label $slicecam -state disabled -command {}
    $mn add command -label "isolate" -command "evaluate \" \[ inrimage::getInrFromCamera $slicecam \] -isolateRegion org \[$bbox -boxSize -org\] end \[$bbox -boxSize -end\]\";$bbox -destroy"
    $mn add command -label "drop" -command "$bbox -destroy"
    }

    bind [$slicecam -widget] <Button-3> "tk_popup $mint %X %Y"
}


inrimage::viewerXVisibleMenu
Comments  
Arguments slicecam
bbox
color
Used by  
Uses  
proc inrimage::viewerXVisibleMenu { slicecam bbox {color "#E8E0D2"} } {
    set mint [$slicecam -widget].visible

    if {![winfo exists $mint]} {
    set mn [menu $mint -tearoff 0 -bg $color]
    $mn add command -label $slicecam -state disabled -command {}
    $mn add command -label "set visible region" -command "evaluate \"$inrimage::mview -visible \[$bbox -boxSize -org\] \[$bbox -boxSize -end\] \"; $bbox -destroy"
    $mn add command -label "reset to all image" -command "$inrimage::mview -visible all"
    $mn add command -label "drop" -command "$bbox -destroy"
    }

    bind [$slicecam -widget] <Button-3> "tk_popup $mint %X %Y"
}


inrimage::viewerXZeroMenu
Comments  
Arguments slicecam
bbox
color
Used by inrimage::multiviewmenu
inrimage::multiviewMergeMenu
Uses inrimage::getInrFromCamera
proc inrimage::viewerXZeroMenu { slicecam bbox {color "#E8E0D2"} } {
    set mint [$slicecam -widget].crop

    if {![winfo exists $mint]} {
    set mn [menu $mint -tearoff 0 -bg $color]
    $mn add command -label $slicecam -state disabled -command {}
    $mn add command -label "zero" -command "evaluate \" \[ inrimage::getInrFromCamera $slicecam \] -zeroRegion org \[$bbox -boxSize -org\] end \[$bbox -boxSize -end\]\";$bbox -destroy"
    $mn add command -label "drop" -command "$bbox -destroy"
    }

    bind [$slicecam -widget] <Button-3> "tk_popup $mint %X %Y"
}


inrimage::voxel4DSizeDialog
Comments set inrimage voxel size
Arguments img
color
Used by  
Uses  
proc inrimage::voxel4DSizeDialog { img color } {
    if ![winfo exists .voxelSize] {
    toplevel .voxelSize -bg $color
    wm title .voxelSize "Enter new voxel size"
    set maxvs 5

    scan "[$img -voxel]" "%f %f %f %f" vx vy vz vt
    set gr $vx
    if { $vy > $gr } { set gr $vy }
    if { $vz > $gr } { set gr $vz }
    if { $gr > [expr $maxvs - 3.0] } { set maxvs [expr $gr + 5.0] }
    
    scale .voxelSize.vx -label "VX" -from 0.01 -to $maxvs -resolution 0.01 -length 300 -orient horizontal -bg $color
    bind .voxelSize.vx <Enter> { focus .voxelSize.vx }
    scale .voxelSize.vy -label "VY" -from 0.01 -to $maxvs -resolution 0.01 -length 300 -orient horizontal -bg $color
    bind .voxelSize.vy <Enter> { focus .voxelSize.vy }
    scale .voxelSize.vz -label "VZ" -from 0.01 -to $maxvs -resolution 0.01 -length 300 -orient horizontal -bg $color
    bind .voxelSize.vz <Enter> { focus .voxelSize.vz }
    scale .voxelSize.vt -label "VT" -from 0.5 -to 15 -resolution 0.01 -length 300 -orient horizontal -bg $color
    bind .voxelSize.vt <Enter> { focus .voxelSize.vt }
    .voxelSize.vx set $vx
    .voxelSize.vy set $vy
    .voxelSize.vz set $vz
    .voxelSize.vt set $vt
    
    frame .voxelSize.b -bg $color
    button .voxelSize.b.ok -text "OK" -command "evaluate \"$img -voxel \[.voxelSize.vx get\] \[.voxelSize.vy get\] \[.voxelSize.vz get\] \[.voxelSize.vt get\]\"; destroy .voxelSize" -bg $color
    button .voxelSize.b.dismiss -text "Dismiss" -command "destroy .voxelSize" -bg $color
    
    pack .voxelSize.vx .voxelSize.vy .voxelSize.vz .voxelSize.vt .voxelSize.b
    pack .voxelSize.b.ok .voxelSize.b.dismiss -side left -padx 20 -pady 10
    }
}


inrimage::voxelSizeDialog
Comments set inrimage voxel size
Arguments img
color
Used by  
Uses  
proc inrimage::voxelSizeDialog { img color } {
    if ![winfo exists .voxelSize] {
    toplevel .voxelSize -bg $color
    wm title .voxelSize "Enter new voxel size"
    set maxvs 5

    scan "[$img -voxel]" "%f %f %f" vx vy vz
    set gr $vx
    if { $vy > $gr } { set gr $vy }
    if { $vz > $gr } { set gr $vz }
    if { $gr > [expr $maxvs - 3.0] } { set maxvs [expr $gr + 5.0] }
    
    scale .voxelSize.vx -label "VX" -from 0.01 -to $maxvs -resolution 0.01 -length 300 -orient horizontal -bg $color
    bind .voxelSize.vx <Enter> { focus .voxelSize.vx }
    scale .voxelSize.vy -label "VY" -from 0.01 -to $maxvs -resolution 0.01 -length 300 -orient horizontal -bg $color
    bind .voxelSize.vy <Enter> { focus .voxelSize.vy }
    scale .voxelSize.vz -label "VZ" -from 0.01 -to $maxvs -resolution 0.01 -length 300 -orient horizontal -bg $color
    bind .voxelSize.vz <Enter> { focus .voxelSize.vz }
    .voxelSize.vx set $vx
    .voxelSize.vy set $vy
    .voxelSize.vz set $vz
    
    frame .voxelSize.b -bg $color
    button .voxelSize.b.ok -text "OK" -command "evaluate \"$img -voxel \[.voxelSize.vx get\] \[.voxelSize.vy get\] \[.voxelSize.vz get\]\"; destroy .voxelSize" -bg $color
    button .voxelSize.b.dismiss -text "Dismiss" -command "destroy .voxelSize" -bg $color
    
    pack .voxelSize.vx .voxelSize.vy .voxelSize.vz .voxelSize.b
    pack .voxelSize.b.ok .voxelSize.b.dismiss -side left -padx 20 -pady 10
    }
}


inrimage::windowImage
Comments  
Arguments image
mn
Used by  
Uses  
proc inrimage::windowImage { image mn } {
    set cam [ lindex [ $mn -views ] end ]
    set scn [ $cam -scene]
    set inrv "none"
    foreach { o } [ $scn -objects ] {
    if { [string match inrview* $o]} {set inrv $o}    
    if {[string match  inr4Dview* $o]} {set inrv $o}    
    if {[string match  overinrview* $o]} {set inrv $o}
    if {[string match  overinr4Dview* $o]} {set inrv $o}
    }
    if { [string compare $inrv "none"] } {
    set bg [ $o -background $cam ]
    set min [ [ $bg -greyLevel min ] -get ]
    set max [ [ $bg -greyLevel max ] -get ]
    
    return [evaluate " view \[evaluate \"$image -windowing min $min max $max\" \] " ]
    }
    else    return "none"
}