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

tclGraphics2D.tcl



graphics2D
Comments  
Arguments  
Used by  
Uses  
    set activate false
    global busy
    set busy 0

}


graphics2D::addCamera2DMenu
Comments  
Arguments menu
name
color
subcolor
Used by graphics2D::viewer2DMenu
Uses modules::selectColor
proc graphics2D::addCamera2DMenu { menu name color subcolor } {
    # File menu
    menubutton $menu.file -text "File" -menu $menu.file.m -anchor w -bg $color
    
    set mfile [menu $menu.file.m -bg $color]
    $mfile add command -label "Load File" -command  "\[$name -scene\] -load \[tk_getOpenFile -filetypes {{\"All\" {* } } } -parent . -title {Select a File}\] "
    $mfile add cascade -label "Create Object From File" -menu $mfile.load
    set mnew [menu $mfile.load -tearoff 0 -bg $color]
    foreach i [scn2D -which file] "$mnew 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\"}}"
    $mfile add cascade -label "Create Object" -menu $mfile.new
    set mnew [menu $mfile.new -tearoff 0 -bg $color]
    foreach i [scn2D -which none] "$mnew add command -label \[scn2D -realName \$i \] -command {evaluate \"new $i\"}"
    foreach i [scn2D -which camera] "$mnew add command -label \[scn2D -realName \$i \] -command {evaluate \"new $i -camera $name\"}"
    $mfile add command -label "Iteration Parameters..." -command "graphics2D::iterationParameters  \[$name -scene\] $color $subcolor"
    $mfile add command -label "Record..." -command "graphics2D::startRecording $name $color $subcolor"
    $mfile add separator
    $mfile add command -label "Script Dialog" -command "if {!\[winfo exists .yav\]} {loadSource tclModules.tcl; loadSource yav++.tcl;yav::interface}"
    $mfile add separator
    $mfile add command -label "Spawn new viewer" -command "new cam2D -scene [$name -scene]"
    $mfile add command -label "Destroy viewer" -command "$name -destroy"
    
    
    # Display menu
    menubutton $menu.display -text "Display" -menu $menu.display.m -anchor w -bg $color
    set mdisplay [menu $menu.display.m -bg $color -postcommand " scan \[$name -showBoundingBox\] {%s} a; switch \$a { true {set showBBox true} false {set showBBox false}}" ]
    $mdisplay add command -label "Focus on Scene" -command "$name -focus"
    $mdisplay add command -label "Change Background Color..." -command "set col \[ modules::selectColor  \[ $name -bgcolor\] \]; $name -bgcolor \[lindex \$col 0\] \[lindex \$col 1\] \[lindex \$col 2\] "
    $mdisplay add command -label "Save in a Postcript File..." -command "[$name -widget] postscript -file \[tk_getSaveFile -filetypes {{\"Postscript File\" {*.ps}} {\"Encapsulated Postscript File\" {*.eps}} {\"All\" {*} }  } -parent . -title {Select a Postcript File}\]"
    #Bounding Box          
    $mdisplay add separator
    $mdisplay add radio -selectcolor "black" -label "Show Bounding Box" -variable showBBox -value "true" -command "$name -showBoundingBox true"
    $mdisplay add radio -selectcolor "black" -label "Hide Bounding Box" -variable showBBox -value "false" -command "$name -showBoundingBox false"
    $mdisplay add command -label "Bounding Box Color..." -command "set col \[  modules::selectColor  \[ $name -boundingBoxColor\] \]; $name -boundingBoxColor \[lindex \$col 0\] \[lindex \$col 1\] \[lindex \$col 2\] "
    $mdisplay add cascade -label "Bounding Box Width" -menu $mdisplay.sub2
    set m2 [menu  $mdisplay.sub2 -tearoff 0 -bg $color]
    $m2 add command -label "1" -command "$name -boundingBoxWidth 1"
    $m2 add command -label "2" -command "$name -boundingBoxWidth 2"
    $m2 add command -label "3" -command "$name -boundingBoxWidth 3"
    
    # Objects menu
    menubutton $menu.objects -text "Objects" -menu $menu.objects.m -anchor w -bg $color
    menu $menu.objects.m -bg $color -postcommand "
        scan \[ $name -select \] {%s} selectedObject;  
    #delete previous items
        $menu.objects.m  delete 0 last
    foreach {i} \[ \[$name -scene\] -objects\] {
        $menu.objects.m  add radio -selectcolor \"black\" -variable selectedObject -label \$i -command \" $name -select \$i \"
}


graphics2D::installSelectedObjectMenu
Comments  
Arguments frame
camera
object
Used by  
Uses  
proc graphics2D::installSelectedObjectMenu { frame camera object } {
    set bg "light blue"
    menubutton $frame.default -text "Default $object menu" -menu $frame.default.m -anchor w -bg $bg
    set mfile [menu $frame.default.m -bg $bg]
    $mfile add command -label "Default entry"

    pack $frame.default -side left
}


graphics2D::installSurfaceViewMenu
Comments  
Arguments viewer
camera
surf
bg
Used by  
Uses modules::selectColor
proc graphics2D::installSurfaceViewMenu { viewer camera surf 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 "Destroy" -command "evaluate \"$surf -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 command -label "Trace Color..." -command "set col \[ modules::selectColor  \[ $surf -color\] \]; evaluate \"$surf -color \[lindex \$col 0\] \[lindex \$col 1\] \[lindex \$col 2\] \""
    pack  $viewer.context.file -side left
    pack  $viewer.context.display -side left
}


graphics2D::iterationParameters
Comments  
Arguments scene
bg
scolor
Used by  
Uses  
proc graphics2D::iterationParameters { scene {bg "#E8E0D2"} scolor } {
    global sliceGeom
    set root .iterationParameters
    if {![winfo exists $root]} {
    toplevel $root -bg $bg
    wm title $root "Iteration Parameters"
    
    frame $root.f -bg $bg
    
    frame $root.f.step -bd 2 -bg $bg
    entry $root.f.step.entry -relief sunken -width 10 -bg $bg
    $root.f.step.entry delete 0 10
    $root.f.step.entry insert 0 [$scene -iteration step]
    label $root.f.step.label -text "Number of calls per Step" -bg $bg
    pack $root.f.step.entry -side right -padx 20
    pack $root.f.step.label -side left -padx 20

    frame $root.f.call -bd 2 -bg $bg
    entry $root.f.call.entry -relief sunken -width 10 -bg $bg
    $root.f.call.entry delete 0 10
    $root.f.call.entry insert 0 [$scene -iteration call]
    label $root.f.call.label -text "Number of Iterations per Call" -bg $bg
    pack $root.f.call.entry -side right -padx 20
    pack $root.f.call.label -side left -padx 20

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

    frame $root.buttons -bg $scolor
    button $root.buttons.applyDismiss -text "Apply & Dismiss" -command "evaluate \"$scene -iteration step \[$root.f.step.entry get\]\";evaluate \"$scene -iteration call \[$root.f.call.entry get\]\";destroy $root" -bg $scolor
    button $root.buttons.destroy -text "Dismiss" -command "destroy $root" -bg $bg
    pack $root.buttons.applyDismiss  $root.buttons.destroy -side left -expand true -fill both -padx 20 -pady 10
    pack $root.buttons -expand true -fill both
    }
}


graphics2D::menusubstitute
Comments  
Arguments str
tag
elt
Used by  
Uses  
proc graphics2D::menusubstitute { str tag elt } {
    set index [string first $tag $str]
    if { $index == -1 } {
    return "eval {$str $elt}"
    } else {
    return "eval {[string range $str 0 [expr $index - 1]]$elt[string range $str [expr $index + [string length $tag]] end]}"
    }
}


graphics2D::resizeSliceViewer2D
Comments  
Arguments cam
frame
newHeight
newWidth
Used by  
Uses  
proc graphics2D::resizeSliceViewer2D {cam frame newHeight newWidth} {
    if  [ winfo ismapped $frame ] {
    if [ string match $graphics2D::busy 0] {
        set graphics2D::busy 1
        puts {inside}
        set h [ winfo height $frame ]
        set w [ winfo width $frame ]
        set currentWidth [ winfo width $frame.view ]
        set currentHeight [ winfo height $frame.view ]
        set sliceHeight [ expr [  expr [  expr [ winfo height $frame.l ] + [ winfo height $frame.s ] ] + [ winfo height $frame.min ] ] +[ winfo height $frame.max ] ]

        set rw [ expr [ expr $w + 0.0 ] / $currentWidth]
        set rh [ expr [ expr [ expr $h  - $sliceHeight] - 25.0 ] / $currentHeight]
        if [ expr $rw < $rh ] {
        set r  $rw
        } else {
        set r  $rh  
        }
        puts $h
        puts $sliceHeight
        puts $currentHeight
        puts $rw
        puts $rh
        $cam -scale [  expr $r * [ $cam -scale ] ]
        update
        set graphics2D::busy 0
    }
    #        evaluate "$cam -resize  [ expr  $newWidth - 2 ] [ expr $newHeight -2] "
    }
}


graphics2D::resizeViewer2D
Comments  
Arguments cam
frame
newHeight
newWidth
Used by  
Uses  
proc graphics2D::resizeViewer2D {cam frame newHeight newWidth} {
    if  [ winfo ismapped $frame ] {
    if [ string match $graphics2D::busy 0] {
        set graphics2D::busy 1
        set h [ winfo height $frame ]
        set w [ winfo width $frame ]
        set currentWidth [ winfo width $frame.view ]
        set currentHeight [ winfo height $frame.view ]
        set rw [ expr [ expr $w + 0.0 ] / $currentWidth]
        set rh [ expr [ expr $h + 0.0 ] / $currentHeight]
        if [ expr $rw < $rh ] {
        set r  $rw
        } else {
        set r  $rh  
        }
        $cam -scale [  expr $r * [ $cam -scale ] ]
        $cam -resize  [ expr  $newWidth - 2 ] [ expr $newHeight -2]
        update
        set graphics2D::busy 0
    }
    }
}


graphics2D::scalePopupMenu
Comments  
Arguments scale
color
Used by  
Uses graphics2D::scalemenu
proc graphics2D::scalePopupMenu { scale {color "#E8E0D2"}} {
    set mint [$scale -widget].m
    graphics2D::scalemenu $mint $scale 0 $color
    bind [$scale -widget] <Button-3> "tk_popup $mint %X %Y"
}


graphics2D::scalemenu
Comments  
Arguments name
sname
toff
color
Used by graphics2D::scalePopupMenu
Uses  
proc graphics2D::scalemenu { name sname {toff 0} {color "#E8E0D2"} } {
    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 slicecam \] {$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 very slow" -command "evaluate \"$sname -maxSteps 10000\""
    $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 graphics2D::activate -selectcolor black -onvalue "true" -offvalue "false" -command "$sname -activate \$graphics2D::activate"
    $mn add separator
    $mn add command -label "destroy" -command "$sname -destroy"
}


graphics2D::setScaleValue
Comments  
Arguments scale
color
Used by  
Uses  
proc graphics2D::setScaleValue  { scale color  } {
    set root .scaleValue
    if ![winfo exists $root] {
    toplevel $root  -bg $color
    frame $root.f -bg $color
    label $root.f.l -text "Set Scale Value" -bg $color
    entry $root.f.e -width 30 -bg white
    $root.f.e insert 0  [ $scale -get]
    bind $root.f.e <Return> "evaluate \"$scale -set \[$root.f.e get \];$scale -command  \[$root.f.e get \]\" "
    pack $root.f.l $root.f.e -side left
    frame $root.buttons -bg $color
    button $root.buttons.apply -text Set -command "evaluate \"$scale -set \[$root.f.e get \];$scale -command  \[$root.f.e get \] \";destroy $root" -bg $color
    button $root.buttons.destroy -text "Destroy" -command "destroy $root" -bg $color
    pack $root.buttons.apply $root.buttons.destroy -side left -expand true -fill both -padx 20 -pady 10
    pack $root.f $root.buttons -expand true -fill both
    }
}


graphics2D::slicecamlist
Comments  
Arguments name
cmd
toff
color
Used by  
Uses  
proc graphics2D::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 \[graphics2D::menusubstitute {$cmd} ... \$i\]}" -bg $color
}


graphics2D::slicecammenu
Comments  
Arguments name
vname
toff
color
Used by graphics2D::topSliceViewer2D
graphics2D::viewerPopupMenu
Uses inrimage::getInrFromCamera
proc graphics2D::slicecammenu { name vname {toff 0} {color "#E8E0D2"} } {
    set mn  [menu $name -tearoff $toff -bg $color ]
    $mn add command -label $vname -state disabled -command {}
    $mn add cascade -label "View Image" -menu $mn.image
    menu $mn.image -tearoff $toff -bg $color -postcommand " $mn.image delete 0 last;if \[ string compare \[ isModuleLoaded tclInrimage \] no \] { if !\[ string compare \[ inrimage::getInrFromCamera $vname \] \"none\" \] { foreach { i} \[ which inr\] { $mn.image add command -label \$i -command \" new inrview \$i \[ $vname -scene \] \"  } } }" -bg $color
    $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 command -label "record camera..." -command "graphics2D::startRecording $vname"
    $mn add command -label "reset visible region" -command "evaluate \"$vname -visible all\""
    $mn add command -label "set visible region..." -command "evaluate \"new bbox3D $vname \""
    #    $mn add checkbutton -label "activate" -variable inrimage::activate -selectcolor black -onvalue "true" -offvalue "false" -command "evaluate \"$vname -activate \$inrimage::activate\""
    $mn add command -label "save view to eps" -command "set name \[inrimage::saveImage\]; if \[string compare \$name {}\] { evaluate \"$vname -saveToeps \$name\" };"
    $mn add separator
    $mn add command -label "destroy" -command "evaluate \"$vname -destroy\""
}


graphics2D::startRecording
Comments  
Arguments cam
color
scolor
Used by  
Uses  
proc graphics2D::startRecording { cam  {color "#E8E0D2"} {scolor "#D8D0C2"} } {
    variable simu scene

    if ![winfo exists .recording] {
    toplevel .recording -bg $color
    frame .recording.f1 -bg $color
    frame .recording.f4 -bg $color
    frame .recording.f5 -bg $color
    frame .recording.f3 -bg $color
    frame .recording.f2 -bg $color

    label .recording.f1.l -text "base file name:" -bg $color
    entry .recording.f1.e -width 30 -bg white
    .recording.f1.e insert 0 dump
    pack .recording.f1.l .recording.f1.e -side left -pady 5


    label .recording.f4.l -text "Mpeg Encoding Command:" -bg $color
    entry .recording.f4.e -width 30 -bg white
    .recording.f4.e insert 0 mpeg_encode
    pack .recording.f4.l .recording.f4.e -side left -pady 5

    label .recording.f5.l -text "Mpeg Playing Command:" -bg $color
    entry .recording.f5.e -width 30 -bg white
    .recording.f5.e insert 0 xanim
    pack .recording.f5.l .recording.f5.e -side left -pady 5

    radiobutton .recording.f3.simu -variable graphics2D::simu -value scene -selectcolor black -text "At simulation rate" -bg $color -anchor w
    radiobutton .recording.f3.cam -variable graphics2D::simu -value camera -selectcolor black -text "At frame rate" -bg $color -anchor w
    pack .recording.f3.simu .recording.f3.cam -fill x -expand true

    button .recording.f2.start -text start -bg $scolor -command "
        if \[string compare \[.recording.f1.e get\] {}\] {
            .recording.f1.e configure -state disabled
            .recording.f3.simu configure -state disabled
            .recording.f3.cam configure -state disabled
            .recording.f2.start configure -state disabled
            .recording.f2.stop configure -state normal
            if \[string compare \$graphics2D::simu scene\] {
            .recording.f2.pause configure -state normal
            evaluate \"$cam -record frame \[.recording.f1.e get\]\"
            } else {
            .recording.f2.pause configure -state disabled
            evaluate \"$cam -record simulation \[.recording.f1.e get\]\"
            }
        }"
    button .recording.f2.pause -text pause -bg $scolor -state disabled -command "
        if \[string compare \[.recording.f2.pause cget -text\] pause\] {
            .recording.f2.pause configure -text pause
            evaluate \"$cam -record pause\"
        } else {
            .recording.f2.pause configure -text restart
            evaluate \"$cam -record pause\"
        }"
    button .recording.f2.stop -state disabled -text stop -bg $scolor -command "
        evaluate \"$cam -record stop\"
        .recording.f1.e configure -state normal
        .recording.f3.simu configure -state normal
        .recording.f3.cam configure -state normal
        .recording.f2.mpeg configure -state normal
        .recording.f2.start configure -state normal
        .recording.f2.pause configure -state disabled
        .recording.f2.stop configure -state disabled"
    button .recording.f2.mpeg -text mpeg -bg $scolor -state disabled -command "
                 evaluate \"modules::mpeg \[.recording.f1.e get\].xwd  \[.recording.f4.e get\]  \[.recording.f5.e get\]\""
    button .recording.f2.dismiss -text dismiss -bg $scolor -command {destroy .recording}
    pack .recording.f2.start .recording.f2.pause .recording.f2.stop  .recording.f2.mpeg  .recording.f2.dismiss -side left -padx 5 -pady 5

    pack .recording.f1 .recording.f4  .recording.f5  .recording.f3 .recording.f2 -fill x -pady 5
    }
}


graphics2D::startViewer2D
Comments  
Arguments parent
cam
Used by  
Uses  
proc graphics2D::startViewer2D { parent cam } {
    if [ winfo exists $parent.start] {
    $parent.start configure -text "Stop Computation" -command "evaluate \"[$cam -scene] -computation false\""
    }
}


graphics2D::stopViewer2D
Comments  
Arguments parent
cam
Used by graphics2D::viewer2DButtons
Uses  
proc graphics2D::stopViewer2D { parent cam } {
    if [ winfo exists $parent.start] {
    $parent.start configure -text "Start Computation" -command "evaluate \"[$cam -scene] -computation true\""
    }
}


graphics2D::topSliceViewer2D
Comments  
Arguments name
menu
width
height
color
subcolor
Used by  
Uses graphics2D::slicecammenu
proc graphics2D::topSliceViewer2D { name menu width height {color "#E8E0D2"} {subcolor "#D8D0C2"}} {
    set root  .$name
    toplevel $root -bg $color
    wm title $root "Slice Camera 2D ($name)"
    set parent $root

    if $menu {
    frame $root.menu -bg $color
    frame $root.submenu -bg $subcolor
    viewer2DMenu $root.menu $root.submenu $name $color $subcolor
    pack $root.menu -fill x
    pack $root.submenu -fill x
    }
    frame $root.f -bg $color
    pack $root.f -fill both -expand true
    viewer2D $name $root.f $menu 1 $width $height

    if $menu {

    frame $root.buttons -bg  $color
    viewer2DButtons $name $root.buttons $subcolor
    pack $root.buttons  -fill x -before $root.f.view -side bottom
    set parent $root.menu
    menubutton $parent.slice -text "Slice" -menu $parent.slice.m -anchor w -bg $color
    graphics2D::slicecammenu $parent.slice.m $name
    pack $parent.slice -side left
    }
    bind $root.f <Configure>  "graphics2D::resizeSliceViewer2D $name %W %h %w"
}


graphics2D::topViewer2D
Comments  
Arguments name
menu
width
height
color
subcolor
Used by  
Uses  
proc graphics2D::topViewer2D { name menu width height {color "#E8E0D2"} {subcolor "#D8D0C2"}} {
    set root  .$name
    toplevel $root -bg $color
    wm title $root "Camera 2D ($name)"

    if $menu {
    frame $root.menu -bg $color
    frame $root.submenu -bg $subcolor
    viewer2DMenu $root.menu $root.submenu $name $color $subcolor
    pack $root.menu -fill x
    pack $root.submenu -fill x
    }
    frame $root.f -bg $color
    pack $root.f -fill both -expand true
    viewer2D $name $root.f $menu 1 $width $height
    
    if $menu {
    frame $root.buttons -bg  $color
    viewer2DButtons $name $root.buttons $subcolor
    pack $root.buttons  -fill x  -before $root.f.view -side bottom
    }
    bind $root.f <Configure>  "graphics2D::resizeViewer2D $name %W %h %w"
    $name -resize [ $name -width ]  [ $name -height ]
}


graphics2D::uninstallSelectedObjectMenu
Comments  
Arguments frame
camera
object
Used by  
Uses  
proc graphics2D::uninstallSelectedObjectMenu { frame camera object } {
    destroy $frame.default
}


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


graphics2D::viewer2D
Comments  
Arguments name
parent
menu
expand
width
height
Used by  
Uses  
proc graphics2D::viewer2D { name parent menu expand width height } {
    canvas $parent.view -width $width -height $height -bg black    -highlightthickness 0

    #bind $parent.view <Configure> "$name -resize %w %h"
    bind $parent.view <ButtonPress-1> "$name -button1Pressed %x %y"
    bind $parent.view <ButtonRelease-1> "$name -button1Released %x %y"
    bind $parent.view <Control-ButtonPress-1> "$name -ctrlButton1Pressed %x %y"
    bind $parent.view <Control-ButtonRelease-1> "$name -button1Released %x %y"
    bind $parent.view <Shift-ButtonPress-1> "$name -shiftButton1Pressed %x %y"
    bind $parent.view <Shift-ButtonRelease-1> "$name -button1Released %x %y"

    bind $parent.view <ButtonPress-2> "$name -button2Pressed %x %y"
    bind $parent.view <ButtonRelease-2> "$name -button2Released %x %y"
    
    bind $parent.view <Control-ButtonPress-2> "$name -ctrlButton2Pressed %x %y"
    bind $parent.view <Control-ButtonRelease-2> "$name -button2Released %x %y"
    bind $parent.view <Shift-ButtonPress-2> "$name -shiftButton2Pressed %x %y"
    bind $parent.view <Shift-ButtonRelease-2> "$name -button2Released %x %y"
    if $menu {
    
    if $expand {
        pack $parent.view -expand true
    } else {
        pack $parent.view
    }
    } else {
    pack $parent.view -expand true
    }
}


graphics2D::viewer2DButtons
Comments  
Arguments name
parent
color
Used by  
Uses graphics2D::stopViewer2D
proc graphics2D::viewer2DButtons { name parent color } {
    button $parent.start -text "Start Computation" -bg "lightBlue" -anchor w -justify center -command "[$name -scene] -computation true" -bg $color
    button $parent.iter -text "Step" -bg "lightBlue" -anchor w -justify center -command "if { !\[string compare \[ \[$name -scene \] -computation \] true \] } {evaluate \"[$name -scene] -computation false\"; graphics2D::stopViewer2D $parent $name}; evaluate \"[$name -scene] -iteration\"" -bg $color
    pack $parent.start $parent.iter -side left -expand true
}


graphics2D::viewer2DMenu
Comments  
Arguments menu
submenu
name
color
subcolor
Used by  
Uses graphics2D::addCamera2DMenu
proc graphics2D::viewer2DMenu { menu submenu name color subcolor } {
    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 x
    pack $submenu.name -side right
    graphics2D::addCamera2DMenu $menu $name $color $subcolor
}


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


graphics2D::viewerVisibleMenu
Comments  
Arguments slicecam
bbox
color
Used by  
Uses  
proc graphics2D::viewerVisibleMenu { 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 \"$slicecam -visible \[$bbox -boxSize -org\] \[$bbox -boxSize -end\] \"; $bbox -destroy"
    $mn add command -label "reset to all image" -command "$slicecam -visible all"
    $mn add command -label "drop" -command "$bbox -destroy"
    }
    
    bind [$slicecam -widget] <Button-3> "tk_popup $mint %X %Y"
}