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

yav.tcl



yav
Comments put all yav variables in a namespace
Arguments  
Used by  
Uses  
namespace eval yav {
    proc loadModule {module array } {
    if [ string match [isModuleLoaded $module] "no"] {
        set list [lindex [array get $array $module] 1]
        if ![ string match $list {}] {
        foreach m  $list {
            yav::loadModule $m $array
        }
        }
        evaluate "module -load $module"
    }
    }
    proc updateModuleDialog { root } {
    $root.f.frame.base delete 0 end
    foreach module $yav::moduleList {
        if ![string compare [isModuleLoaded $module] "no"] {
        $root.f.frame.base insert end $module
        }
    }
    $root.f.frame2.base delete 0 end
    foreach module [module -list] {
        if [string compare $module "tclModules" ] {
        set b 1
        foreach otherModule [ module -list ] {
            set val [lsearch  [lindex [array get yav::moduleDependance $otherModule] 1] $module ]
            if [ expr $val != -1 ] { set b 0}
        }
        if [ expr $b ==1 ] {
            $root.f.frame2.base insert end $module
        }
        }
    }

    
    }
    proc updateYavMenu { menu } {
    if [string compare [isModuleLoaded tclInrimage] no] {
        if [winfo exists $menu.images] {
        destroy  $menu.images
        }
        menubutton $menu.images -text "Images" -menu $menu.images.m -anchor w -bg $yav::color
        set mcreate [menu $menu.images.m -bg $yav::color ]
        set i inr
        $mcreate add command -label  [ scn2D -realName $i] -command "set name \[tk_getOpenFile -filetypes {{$i {[scn2D -suffix $i]}} {All *}}\]; if \[string compare \$name {}\] {evaluate \"new $i \{\$name\}\"}"
        set i inr4D
        $mcreate add command -label  [ scn2D -realName $i] -command "set name \[tk_getOpenFile -filetypes {{$i {[scn2D -suffix $i]}} {All *}}\]; if \[string compare \$name {}\] {evaluate \"new $i \{\$name\}\"}"
        $mcreate add separator
        $mcreate add cascade -label "3D Slicer" -menu $mcreate.view
        menu $mcreate.view -tearoff 0 -bg $yav::color -postcommand "$mcreate.view delete 0 end; foreach {i} \[which inr\] {$mcreate.view add command -label \"\$i ( \[lindex  \[ split \[ \$i -name \] / \] end \])\" -command \" evaluate \\\"view \$i \\\" \" } "
        $mcreate add cascade -label "Single Slicer" -menu $mcreate.slice

        menu $mcreate.slice -tearoff 0 -bg $yav::color -postcommand "$mcreate.slice delete 0 end; foreach i \[which inr\] {$mcreate.slice add command -label \"\$i ( \[lindex  \[ split \[ \$i -name \] / \] end \])\"  -command { evaluate \"new slicecam -scene \\\[ \\\[new inrview \$i \\\]  -scene \\\]  \" }}"
        $mcreate add cascade -label "Fuse images" -menu $mcreate.fuse
        menu $mcreate.fuse -tearoff 0 -bg $yav::color -postcommand "$mcreate.fuse delete 0 end; foreach i \[which inr\] { foreach j \[ which inr \] { if \[expr \\\{\"\$i\"<\"\$j\"\\\}  \] { $mcreate.fuse add command -label \"\$i and \$j\" -command \" evaluate \\\"inrimage::mergeView \$i \$j \\\" \" } } }"
        $mcreate add cascade -label "Fuse 4D images" -menu $mcreate.fuse4D
        menu $mcreate.fuse4D -tearoff 0 -bg $yav::color -postcommand "$mcreate.fuse4D delete 0 end; foreach i \[which inr4D\] { foreach j \[ which inr4D \] { if \[expr \\\{\"\$i\"<\"\$j\"\\\}  \] { $mcreate.fuse4D add command -label \"\$i and \$j\" -command \" evaluate \\\"inrimage::mergeView4D \$i \$j \\\" \" } } }"
        $mcreate add separator

        $mcreate add cascade -label "View 4D Image" -menu $mcreate.view4D
        menu $mcreate.view4D -tearoff 0 -bg $yav::color -postcommand "$mcreate.view4D delete 0 end; foreach {i} \[which inr4D\] {$mcreate.view4D add command -label \$i -command \" evaluate \\\"inrimage::view4D \$i \\\" \" } "

        pack $menu.images -side left
    }

    if [string compare [isModuleLoaded tclGraphics2D] no] {
        if [winfo exists $menu.2D] {
        destroy  $menu.2D
        }
        menubutton $menu.2D -text "2D" -menu $menu.2D.m -anchor w -bg $yav::color
        set mcreate [menu $menu.2D.m -bg $yav::color ]
        $mcreate add command -label "2D Scene" -command { evaluate "new scn2D" }
        foreach i [scn2D -which none] {
        $mcreate add command -label [ scn2D -realName $i ]  -command "evaluate \"new $i\""  
        }
        foreach i [scn2D -which file] {  
        #do not add images in menu
        if  [ expr [string compare $i "inr"] && [string compare $i "inr4D"] ] {
            $mcreate add command -label  [ scn2D -realName $i] -command "set name \[tk_getOpenFile -filetypes {{$i {[scn2D -suffix $i]}} {All *}}\]; if \[string compare \$name {}\] {evaluate \"new $i \{\$name\}\"}"
        }
        }
        $mcreate add separator
        $mcreate add command -label "2D Scene Graph" -command "modules:::sceneGraph 2D "

        pack $menu.2D -side left
    }

    if [winfo exists $menu.3D] {
        destroy  $menu.3D
    }

    if [string compare [isModuleLoaded tclGraphics3D] no] {
        menubutton $menu.3D -text "3D" -menu $menu.3D.m -anchor w -bg $yav::color
        set mcreate [menu $menu.3D.m -bg $yav::color ]
        $mcreate add command -label "3D Scene" -command { evaluate "new scn3D" }
        foreach i [scn3D -which none] {
        $mcreate add command -label [scn3D -realName $i] -command "evaluate \"new $i\""
        }
        foreach i [scn3D -which file] {
        $mcreate add command -label  [scn3D -realName $i] -command "set name \[tk_getOpenFile -filetypes {{$i {[scn3D -suffix $i]}} {All *}}\]; if \[string compare \$name {}\] {evaluate \"new $i \{\$name\}\"}"
        }
        if [string compare [isModuleLoaded tclImageData] no] {  
        $mcreate add separator
        $mcreate add cascade -label "3D view" -menu $mcreate.img3D
        menu $mcreate.img3D -tearoff 0 -bg $yav::color -postcommand "$mcreate.img3D delete 0 end; foreach i \[which inr\] {$mcreate.img3D add command -label \$i -command \" evaluate \\\"new img3D \$i \\\" \" }"
        }
        $mcreate add separator
        $mcreate add command -label "3D Scene Graph" -command "modules:::sceneGraph 3D"
        pack $menu.3D -side left
    }
    if [winfo exists $menu.4D] {
        destroy  $menu.4D
    }

    if [string compare [isModuleLoaded tclCamera4D] no] {
        menubutton $menu.4D -text "4D" -menu $menu.4D.m -anchor w -bg $yav::color
        set mcreate [menu $menu.4D.m -bg $yav::color ]
        $mcreate add command -label "4D Scene" -command { evaluate "new scn4D" }
        foreach i [scn4D -which none] {
        $mcreate add command -label [scn4D -realName $i ] -command "evaluate \"new $i\""
        }
        foreach i [scn4D -which file] {
        $mcreate add command -label [scn4D -realName $i ] -command "set name \[tk_getOpenFile -filetypes {{$i {[scn4D -suffix $i]}} {All *}}\]; if \[string compare \$name {}\] {evaluate \"new $i \{\$name\}\"}"
        }

        $mcreate add separator
        $mcreate add cascade -label view -menu $mcreate.view
        menu $mcreate.view -tearoff 0 -bg $yav::color -postcommand "$mcreate.view delete 0 end; foreach i \[which inr4D\] {$mcreate.view add command -label \$i -command \"view \$i\"}"

        pack $menu.4D -side left
    }
    
    }
    proc setDependance {} {
    variable moduleDependance
    variable moduleList
    # define the list of modules
    set moduleList { tclGraphics2D tclGraphics3D tclInrimage tclImageData tclTriangulation tclSM2 tclTetrahedrisation tclForceFeedback tclSimulation tclContour tclIsosurface tclLevelSets tclEpinrimage tclCIsosurf tclBat }
    # define the array of dependence of each array
    array set moduleDependance {tclInrimage {tclGraphics2D}}
    array set moduleDependance {tclImageData {tclInrimage tclGraphics3D}}
    array set moduleDependance {tclTriangulation {tclContour} }
    array set moduleDependance {tclContour {tclGraphics2D tclGraphics3D tclInrimage}}
    array set moduleDependance {tclSM2 {tclContour tclImageData}}
    array set moduleDependance {tclCamera4D {tclGraphics3D tclGraphics2D}}
    array set moduleDependance {tclTetrahedrisation {tclGraphics3D tclGraphics2D}}
    array set moduleDependance {tclForceFeedback {tclGraphics3D}}
    array set moduleDependance {tclSimulation {tclTriangulation tclTetrahedrisation tclForceFeedback}}
    array set moduleDependance {tclIsosurface {tclInrimage tclContour}}
    array set moduleDependance {tclLevelSets {tclContour tclIsosurface}}
    array set moduleDependance {tclCIsosurf {tclInrimage tclTriangulation}}
    array set moduleDependance {tclEpinrimage {tclInrimage tclContour}}
    array set moduleDependance {tclBat {tclGraphics3D tclGraphics2D}}
    }
    proc moduleDialog {} {
    yav::setDependance
    # main window
    set root .yavModule
    if {![winfo exists $root]} {
        toplevel $root -bg $yav::color
        wm title $root "Module Manager"
        
        frame $root.f -relief groove -bd 2 -bg $yav::color  
        
        # frame where modules to be loaded are stored
        frame $root.f.frame -relief groove -bd 2 -bg $yav::color  
        button $root.f.frame.add  -text ">> Add Module >>" -command "if \[ string compare \[ $root.f.frame.base curselection\] {} \] { yav::loadModule \[ $root.f.frame.base get \[  $root.f.frame.base curselection\] \] yav::moduleDependance; yav::updateModuleDialog $root;yav::updateYavMenu .yav.menu}"
        listbox $root.f.frame.base -height 8 -bg white -yscrollcommand [list $root.f.frame.sy  set]
        scrollbar $root.f.frame.sy  -orient vertical -bg $yav::color -command [list $root.f.frame.base yview]
        pack $root.f.frame.add  
        pack $root.f.frame.base $root.f.frame.sy -fill both -expand true -side left
        pack $root.f.frame -fill both -expand true -side left
        
        # frame where modules to already loaded are stored
        frame $root.f.frame2 -relief groove -bd 2 -bg $yav::color  
        button $root.f.frame2.remove  -text "<< Remove Module <<" -command "if \[ string compare \[ $root.f.frame2.base curselection\] {} \] { evaluate \"module -delete \[ $root.f.frame2.base get \[  $root.f.frame2.base curselection\] \] \"; yav::updateModuleDialog $root}"
        
        listbox $root.f.frame2.base -height 8 -bg white -yscrollcommand [list $root.f.frame2.sy  set]
        scrollbar $root.f.frame2.sy  -orient vertical -bg $yav::color -command [list $root.f.frame2.base yview]
        pack $root.f.frame2.remove
        pack $root.f.frame2.base $root.f.frame2.sy -fill both -expand true -side left
        pack $root.f.frame2 -fill both -expand true -side left
        pack $root.f -fill both -expand true -side top
        
        #frame for dismiss button
        frame $root.f2 -relief groove -bd 2 -bg $yav::color  
        button $root.f2.dismiss  -text "Dismiss" -command "destroy $root"
        pack $root.f2.dismiss
        pack $root.f2 -fill both -expand true -side top
        yav::updateModuleDialog $root
    }

    }

    # yav global variables
    foreach i [split [shell -path] :] {
    if [file exists $i/yav.gif] {
        set yavimg [image create photo -file $i/yav.gif]
        break;
    }
    }
    if ![info exists yav::yavimg] {
    set yavimg [image create bitmap -data "#define tst_width 32
#define tst_height 32
static unsigned char tst_bits[] = {
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    0xf9, 0x19, 0xcf, 0x9f, 0xf3, 0x4c, 0xce, 0x9f, 0x67, 0x4e, 0x8e, 0x8f,
    0x0f, 0xe7, 0x9c, 0xcf, 0x9f, 0xe7, 0x1c, 0xc7, 0x9f, 0x03, 0x38, 0xe7,
    0x9f, 0x03, 0x38, 0xe2, 0x9f, 0xf3, 0x79, 0xf0, 0x9f, 0xf3, 0xf9, 0xf8,
    0x9f, 0xf3, 0xf9, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff,
    0x3f, 0xf8, 0x3f, 0xfc, 0x9f, 0xf1, 0x1f, 0xf8, 0x9f, 0xf3, 0x8f, 0xf1,
    0xff, 0xf3, 0xcf, 0xf3, 0xff, 0xf9, 0xcf, 0xf3, 0xff, 0xf8, 0xcf, 0xf3,
    0x7f, 0xfc, 0xcf, 0xf3, 0x3f, 0xfe, 0xcf, 0xf3, 0x1f, 0x7f, 0x8e, 0xf1,
    0x1f, 0x70, 0x1e, 0xf8, 0x1f, 0xf0, 0x3f, 0xfc, 0xff, 0xff, 0xff, 0xff,
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}"]
    }
    set color lightblue

    proc interface { } {
    global env

    if ![info exists env(CYBERWARE_DIR)] {
        set env(CYBERWARE_DIR) [pwd]
    }
    if ![info exists env(NRCC_DIR)] {
        set env(NRCC_DIR) [pwd]
    }
    if ![info exists env(OGIS_DIR)] {
        set env(OGIS_DIR) [pwd]
    }
    if ![info exists env(ISOSURFACE_DIR)] {
        set env(ISOSURFACE_DIR) [pwd]
    }
    if ![info exists env(INRIMAGE_DIR)] {
        set env(INRIMAGE_DIR) [pwd]
    }
    if ![info exists env(TRIAN_DIR)] {
        set env(TRIAN_DIR) [pwd]
    }
    if ![info exists env(STEREO_DIR)] {
        set env(STEREO_DIR) [pwd]
    }
    if ![info exists env(POLY_DIR)] {
        set env(POLY_DIR) [pwd]
    }

    # main window
    toplevel .yav -bg $yav::color
    wm title .yav "Yet Another Viewer"

    # menu
    frame .yav.menu -relief groove -bd 2 -bg $yav::color  

    menubutton .yav.menu.file -text "File" -menu .yav.menu.file.m -anchor w -bg $yav::color
    set mfile [menu .yav.menu.file.m -bg $yav::color ]
    $mfile add command -label "Script..." -command {set fscr [tk_getOpenFile -filetypes {{Script {.tcl}} {All *}} -parent . -title {Select an image}]; if  [string compare $fscr ""] {evaluate "script $fscr"}}
    $mfile add command -label "Script args..." -command {set fscr [tk_getOpenFile -filetypes {{Script {.tcl}} {All *}} -parent . -title {Select an image}]; if  [string compare $fscr ""] {modules::setPartialCommand "script $fscr "}}
    $mfile add separator
    $mfile add command -label "Dump commands..." -command { modules::dumpCommandsToFile }
    $mfile add command -label "Dump results..." -command { modules::dumpResultsToFile }
    $mfile add command -label "Flush commands" -command { modules::flushCommands }
    $mfile add command -label "Flush results" -command { modules::flushResults }
    $mfile add separator
    $mfile add command -label "Module Manager..." -command yav::moduleDialog
    $mfile add command -label "Version" -command yav::version
    $mfile add command -label "Exit" -command exit
    pack .yav.menu.file -side left  

        yav::updateYavMenu .yav.menu

    frame .yav.interf -bg $yav::color
    modules::interface .yav.interf $yav::color
    
    pack .yav.menu -fill x
    pack .yav.interf -fill both -expand true
    
    }

    proc version {} {
    if { ![winfo exists .ver] } {
        toplevel .ver -bg $yav::color
        wm title .ver "YAV++ revision"
        frame .ver.f -bg $yav::color
        message .ver.f.m -justify center -width 200 -bg blue -fg white -relief raised -text "\
    Yet Another Viewer\n\
    \n\
    version 1.4 (beta)\n"
        label .ver.f.p -image $yav::yavimg
        message .ver.l -justify left -width 1000 -bg white -relief raised -text "\
    \n\
    A script interpretor for volume images processing and deformable models.\n\
    (in fact an extensible C++ front-end for TCL/TK)\n\
    \n\
    authors:\n\
    Johan Montagnat (Johan.Montagnat@sophia.inria.fr)\n\
    Hervé Delingette (Herve.Delingette@sophia.inria.fr)\n\
    contributors:\n\
    Alexandre Guimond (Alexandre.Guimond@sophia.inria.fr)\n\
    Jean-Christophe Lombardo (Jean-Christophe.Lombardo@sophia.inria.fr)\n\
    Nicolas Scapel (Nicolas.Scapel@sophia.inria.fr)\n\n\
    INRIA Sophia-Antipolis, Epidaure project\n\
    2004 route des lucioles, BP93, 06902 Sophia-Antipolis, France\n\
    http://www.inria.fr/epidaure/Epidaure-eng.html\n\
    \n\
    Using TCL/TK 8.1\n\
    http://www.scriptics.com/software/8.1.html\n\
    \n\
    OpenGL TK widget inspired from Togl v1.4, a Tk OpenGL widget\n\
    Brian Paul and Ben Bederson\n\
    http://www.cs.umd.edu/~bederson/Togl.html\n\
    \n"

           button .ver.b -text "Dismiss" -command "destroy .ver" -bg $yav::color -fg black
          
           pack .ver.f.m .ver.f.p -padx 5 -pady 5 -side left
           pack .ver.f
           pack .ver.l -padx 5 -pady 5 -fill x -expand true
           pack .ver.b -padx 5 -pady 5
     }
}