~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to visualization/nviz/scripts/panel_scale.tcl

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
##########################################################################
2
 
3
 
# Panel to facilitate scale placement for finishing images produced
4
 
# by nviz.
5
 
#
6
 
##########################################################################
7
 
# 4/4/95
8
 
# M. Astley
9
 
# U.S. Army Construction Engineering Research Laboratory
10
 
#
11
 
# Major update of GUI Nov 2006, Michael Barton, Arizona State University
12
 
#
13
 
##########################################################################
14
 
# COPYRIGHT:    (C) 2006 by Michael Barton and the GRASS Development Team
15
 
#
16
 
#               This program is free software under the GNU General Public
17
 
#               License (>=v2). Read the file COPYING that comes with GRASS
18
 
#               for details.
19
 
#
20
 
##########################################################################
21
 
 
22
 
# Changes
23
 
#
24
 
 
25
 
# Panel specific globals
26
 
global Nv_
27
 
 
28
 
# default cursor
29
 
set Nv_(cursor) [$Nv_(TOP) cget -cursor]        
30
 
 
31
 
##########################################################################
32
 
 
33
 
proc mkscalePanel { BASE } {
34
 
    global Nv_
35
 
    global scalebar_size scalebar
36
 
    global bar_clr bar_text_clr
37
 
    global nviztxtfont
38
 
 
39
 
    # defaults
40
 
    set scalebar_size 1000
41
 
    set bar_clr "#000000"
42
 
    set bar_text_clr "#DDDDDD"
43
 
    set bar_text_size "non funct."
44
 
 
45
 
    set panel [St_create {window name size priority} $BASE [G_msg "Scale bar"] 2 5]
46
 
    frame $BASE -relief flat -borderwidth 0
47
 
    Nv_mkPanelname $BASE [G_msg "Scale Bar Panel"]
48
 
 
49
 
    # This section contains widgets for placing the scale bar
50
 
    set rbase1 [frame $BASE.scale]
51
 
    Label $rbase1.scalebar_lbl -text [G_msg "Scale bar: "] -fg black
52
 
    LabelEntry $rbase1.scalebar_size -relief sunken -entrybg white \
53
 
        -textvariable scalebar_size -width 8 \
54
 
        -label [G_msg "length (in map units) "] -fg black -font $nviztxtfont
55
 
    pack $rbase1.scalebar_lbl $rbase1.scalebar_size -side left -expand no -fill none
56
 
    
57
 
    $rbase1.scalebar_size bind <Key> {if {$Nauto_draw == 1} {Ndraw_all}} 
58
 
 
59
 
 
60
 
    Button $rbase1.color -text [G_msg "Color"] \
61
 
                -bg $bar_clr -width 8 -bd 1 \
62
 
                -command "change_scale_color $rbase1.color scale" \
63
 
                -fg "#ffffff"
64
 
    pack $rbase1.color -side right \
65
 
        -expand yes -fill none -anchor e
66
 
 
67
 
        pack $rbase1 -side top -expand yes -fill both -padx 3 -pady 4
68
 
 
69
 
    # This section contains widgets for scale text
70
 
    set rbase2 [frame $BASE.txt]
71
 
    Label $rbase2.txt_lbl -text [G_msg "Scale text: "] -fg black
72
 
    LabelEntry $rbase2.txt_size -relief sunken -entrybg grey \
73
 
        -textvariable bar_text_size -width 8 -justify right\
74
 
        -label [G_msg "size "] -fg black -labelfont $nviztxtfont
75
 
    pack $rbase2.txt_lbl $rbase2.txt_size -side left -expand no -fill none
76
 
    
77
 
    $rbase2.txt_size bind <Key> {if {$Nauto_draw == 1} {Ndraw_all}} 
78
 
 
79
 
    Button $rbase2.color -text [G_msg "Color"] \
80
 
                -bg $bar_text_clr -width 8 -bd 1 \
81
 
                -command "change_scale_color $rbase2.color text" \
82
 
                -fg "#ffffff"
83
 
    pack $rbase2.color -side right \
84
 
        -expand yes -fill none -anchor e
85
 
 
86
 
        pack $rbase2 -side top -expand yes -fill both -padx 3
87
 
 
88
 
    # close panel section
89
 
    set rbase3 [frame $BASE.button]
90
 
    Button $rbase3.place -text [G_msg "Place scale"] -bd 1 \
91
 
         -command "sb_bind_mouse $Nv_(TOP).canvas; $Nv_(TOP) configure -cursor plus"
92
 
    pack $rbase3.place -expand yes -side left -expand no -fill none
93
 
 
94
 
    button $rbase3.close -text [G_msg "Close"] -command "Nv_closePanel $BASE" \
95
 
                -anchor se -bd 1
96
 
        pack $rbase3.close -side right -fill none -expand no
97
 
        pack $rbase3 -side top -fill both -expand yes -padx 3 -pady 4
98
 
 
99
 
    return $panel
100
 
}
101
 
 
102
 
proc sb_bind_mouse { W } {
103
 
        bind $W <1> {
104
 
                place_scale %W %x %y 
105
 
                if {$Nauto_draw == 1} {
106
 
                        #Nset_cancel 0
107
 
                        Ndraw_all
108
 
                } 
109
 
                $Nv_(TOP) configure -cursor $Nv_(cursor)
110
 
        }
111
 
}
112
 
 
113
 
#############################################################
114
 
 
115
 
# Simple routine to change the colors
116
 
# text color not yet user settable.
117
 
proc change_scale_color { me type } {
118
 
        global Nv_
119
 
        global bar_clr bar_text_clr
120
 
        global Nauto_draw
121
 
        
122
 
        # set color button background to match scale/text color
123
 
    set clr [lindex [$me configure -bg] 4]
124
 
    set clr [mkColorPopup .colorpop bar_clr $clr 1]
125
 
    
126
 
    if {$type == "scale"} {
127
 
            set bar_clr $clr
128
 
        } elseif {$type == "text"} {
129
 
        set bar_text_clr $clr
130
 
    }
131
 
        
132
 
    $me configure -bg $clr
133
 
 
134
 
        # set color button text to black or white depending on
135
 
        # darkness of color
136
 
    set clrnum [split $clr {}]
137
 
    set rhex "0x[lindex $clrnum 1][lindex $clrnum 2]"
138
 
    set ghex "0x[lindex $clrnum 3][lindex $clrnum 4]"
139
 
    set bhex "0x[lindex $clrnum 5][lindex $clrnum 6]"
140
 
    set clrsum [expr $rhex + $ghex +$bhex]
141
 
   
142
 
    if {$clrsum < 400 } {
143
 
           $me configure -fg "white"
144
 
         } else {
145
 
           $me configure -fg "black"
146
 
         }
147
 
        if {$Nauto_draw == 1} {
148
 
                Ndraw_all
149
 
        }
150
 
 
151
 
}
152
 
###########################
153
 
proc place_scale {W x y} {
154
 
 
155
 
global Nv_ scalebar scalebar_size
156
 
global scalebar_x scalebar_y scalebar_z
157
 
global bar_clr bar_text_clr
158
 
global Nauto_draw
159
 
 
160
 
set y [expr $Nv_(height) - $y]
161
 
 
162
 
#Draw scale bar at selected point
163
 
    set curr [Nget_current surf]
164
 
    if {$curr} {
165
 
        set location [Nset_ScaleBar $x $y $curr $scalebar_size]
166
 
        set scalebar_x [lindex $location 0]
167
 
        set scalebar_y [lindex $location 1]
168
 
        set scalebar_z [lindex $location 2]
169
 
        
170
 
        Ndraw_ScaleBar $scalebar_x $scalebar_y $scalebar_z $scalebar_size \
171
 
                $bar_clr $bar_text_clr
172
 
        #set chuckbutton
173
 
        set scalebar 1
174
 
    }
175
 
 
176
 
#remove canvas binding
177
 
    bind $W <1> {}
178
 
 
179
 
}