1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
## -*- tcl -*-
# # ## ### ##### ######## ############# ######################
## (c) 2022 Andreas Kupries
# @@ Meta Begin
# Package map::box::display 0.1
# Meta author {Andreas Kupries}
# Meta location https://core.tcl.tk/tklib
# Meta platform tcl
# Meta summary Widget to display a single box definition
# Meta description Widget to display the information of a single box definition
# Meta subject {box display, tabular}
# Meta subject {tabular, box display}
# Meta require {Tcl 8.6-}
# Meta require {Tk 8.6-}
# Meta require debug
# Meta require debug::caller
# Meta require {map::slippy 0.8}
# Meta require scrollutil
# Meta require snit
# Meta require tablelist
# @@ Meta End
package provide map::box::display 0.1
# # ## ### ##### ######## ############# ######################
## API
#
## <class> OBJ
#
## <obj> set GEOBOX -> VOID Show this box, or nothing, if empty
#
# # ## ### ##### ######## ############# ######################
## Requirements
package require Tcl 8.6-
package require Tk 8.6-
# ;# Tcllib
package require debug ;# - Narrative Tracing
package require debug::caller ;#
package require map::slippy 0.8 ;# - Map utilities
package require snit ;# - OO system
# ;# Tklib
package require scrollutil ;# - Scroll framework
package require tablelist ;# - Tabular display
# # ## ### ##### ######## ############# ######################
## Ensemble setup.
namespace eval map { namespace export box ; namespace ensemble create }
namespace eval map::box { namespace export display ; namespace ensemble create }
debug level tklib/map/box/display
debug prefix tklib/map/box/display {<[pid]> [debug caller] | }
# # ## ### ##### ######## ############# ######################
snit::widget ::map::box::display {
# . . .. ... ..... ........ ............. .....................
## State
variable myspec {} ;# Table data derived from the box specification
# . . .. ... ..... ........ ............. .....................
## Lifecycle
constructor {} {
debug.tklib/map/box/display {}
scrollutil::scrollarea $win.sa
tablelist::tablelist $win.sa.table -width 60 -columntitles {What {} {}}
$win.sa setwidget $win.sa.table
pack $win.sa -in $win -fill both -expand 1
$win.sa.table configure -listvariable [myvar myspec]
return
}
destructor {
debug.tklib/map/box/display {}
return
}
# . . .. ... ..... ........ ............. .....................
## API
method set {geobox} {
debug.tklib/map/box/display {}
if {![llength $geobox]} {
set myspec {}
return
}
# Assemble table data
lassign [map slippy geo box corners $geobox] tl bl tr br
set center [map slippy geo box center $geobox]
set diameter [map slippy geo box diameter $geobox]
set length [map slippy geo box perimeter $geobox]
lappend data [list TopLeft {*}[map slippy geo limit $tr]]
lappend data [list BottomLeft {*}[map slippy geo limit $bl]]
lappend data [list TopRight {*}[map slippy geo limit $tr]]
lappend data [list BottomRight {*}[map slippy geo limit $br]]
lappend data [list Center {*}[map slippy geo limit $center]]
lappend data [list Diameter [map slippy pretty-distance $diameter] {}]
lappend data [list Perimeter [map slippy pretty-distance $length] {}]
# ... and commit
set myspec $data
return
}
# . . .. ... ..... ........ ............. .....................
}
# # ## ### ##### ######## ############# ######################
return
|