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

« back to all changes in this revision

Viewing changes to visualization/nviz/scripts/panel_arrow.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 north arrow 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
 
set Nv_(arw_font) {"helvetica" "17"}
31
 
 
32
 
##########################################################################
33
 
 
34
 
proc mkarrowPanel { BASE } {
35
 
    global Nv_
36
 
    global n_arrow_size n_arrow arw_text_size
37
 
    global arw_clr arw_text_clr
38
 
    global nviztxtfont
39
 
 
40
 
    # defaults (for some reason not recognizing globals)
41
 
        set n_arrow_size [expr int([Nget_longdim]/8.)]
42
 
        set arw_clr "#000000"
43
 
    set arw_text_clr "#DDDDDD"
44
 
    #This doesn't do anything currently
45
 
    set arw_text_size "not funct." 
46
 
 
47
 
    set panel [St_create {window name size priority} $BASE [G_msg "North arrow"] 2 5]
48
 
    frame $BASE -relief flat -borderwidth 0
49
 
    Nv_mkPanelname $BASE [G_msg "North Arrow Panel"]
50
 
 
51
 
    # This section contains widgets for placing the north arrow
52
 
    set rbase1 [frame $BASE.arrow]
53
 
    Label $rbase1.arrow_lbl -text [G_msg "Arrow: "] -fg black
54
 
    LabelEntry $rbase1.arrow_size -relief sunken -entrybg white \
55
 
        -textvariable n_arrow_size -width 8 -justify right\
56
 
        -label [G_msg "size (in map units) "] -fg black -labelfont $nviztxtfont
57
 
    pack $rbase1.arrow_lbl $rbase1.arrow_size -side left -expand no -fill none
58
 
    
59
 
    $rbase1.arrow_size bind <Key> {if {$Nauto_draw == 1} {Ndraw_all}} 
60
 
 
61
 
    Button $rbase1.color -text [G_msg "Color"] \
62
 
                -bg $arw_clr -width 8 -bd 1 \
63
 
                -command "change_arrow_color $rbase1.color arrow" \
64
 
                -fg "#ffffff"
65
 
    pack $rbase1.color -side right \
66
 
        -expand yes -fill none -anchor e
67
 
 
68
 
        pack $rbase1 -side top -expand yes -fill both -padx 3 -pady 4
69
 
 
70
 
    # This section contains widgets for north text
71
 
    set rbase2 [frame $BASE.txt]
72
 
    Label $rbase2.txt_lbl -text [G_msg "North text: "] -fg black
73
 
    Button $rbase2.font -text [G_msg "Font"] \
74
 
                -width 8 -command "select_arw_font $rbase2.font" -bd 1 \
75
 
                -helptext [G_msg "Select font family, size, and style"]
76
 
    pack $rbase2.txt_lbl $rbase2.font -side left -expand no -fill none
77
 
    
78
 
    Button $rbase2.color -text [G_msg "Color"] \
79
 
                -bg $arw_text_clr -width 8 -bd 1 \
80
 
                -command "change_arrow_color $rbase2.color text" \
81
 
                -fg "#ffffff"
82
 
    pack $rbase2.color -side right \
83
 
        -expand yes -fill none -anchor e
84
 
 
85
 
        pack $rbase2 -side top -expand yes -fill both -padx 3
86
 
 
87
 
    # close panel section
88
 
    set rbase3 [frame $BASE.button]
89
 
    Button $rbase3.place -text [G_msg "Place arrow"] -bd 1 \
90
 
         -command "bind_mouse $Nv_(TOP).canvas; $Nv_(TOP) configure -cursor plus"
91
 
    pack $rbase3.place -expand yes -side left -expand no -fill none
92
 
 
93
 
    button $rbase3.close -text [G_msg "Close"] -command "Nv_closePanel $BASE" \
94
 
                -anchor se -bd 1
95
 
        pack $rbase3.close -side right -fill none -expand no
96
 
        pack $rbase3 -side top -fill both -expand yes -padx 3 -pady 4
97
 
 
98
 
    return $panel
99
 
}
100
 
 
101
 
proc bind_mouse { W } {
102
 
        global Nv_
103
 
        bind $W <1> {
104
 
                place_narrow %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
 
# use Tk dialog to select fonts
116
 
proc select_arw_font {fbutton} {
117
 
        global Nv_
118
 
        
119
 
    set fon [SelectFont $fbutton.fontset -type dialog -sampletext [G_msg "The quick brown fox jumps over the lazy dog"] -title [G_msg "Select font"] -font Nv_(arw_font)]
120
 
        if { $fon != "" } {set Nv_(arw_font) $fon}
121
 
}
122
 
 
123
 
#############################################################
124
 
 
125
 
# Simple routine to change the color of Arrow.
126
 
# text color not yet user settable.
127
 
proc change_arrow_color { me type } {
128
 
        global Nv_
129
 
        global arw_clr arw_text_clr
130
 
        global Nauto_draw
131
 
        
132
 
        # set color button background to match arrow color
133
 
    set clr [lindex [$me configure -bg] 4]
134
 
    set clr [mkColorPopup .colorpop arw_clr $clr 1]
135
 
    if {$type == "arrow"} {
136
 
            set arw_clr $clr
137
 
        } elseif {$type == "text"} {
138
 
                set arw_text_clr $clr
139
 
        }
140
 
    $me configure -bg $clr
141
 
 
142
 
        # set color button text to black or white depending on
143
 
        # darkness of color
144
 
    set clrnum [split $clr {}]
145
 
    set rhex "0x[lindex $clrnum 1][lindex $clrnum 2]"
146
 
    set ghex "0x[lindex $clrnum 3][lindex $clrnum 4]"
147
 
    set bhex "0x[lindex $clrnum 5][lindex $clrnum 6]"
148
 
    set clrsum [expr $rhex + $ghex +$bhex]
149
 
   
150
 
    if {$clrsum < 400 } {
151
 
           $me configure -fg "white"
152
 
         } else {
153
 
           $me configure -fg "black"
154
 
         }
155
 
        if {$Nauto_draw == 1} {
156
 
                Ndraw_all
157
 
        } 
158
 
         
159
 
}
160
 
###########################
161
 
proc place_narrow {W x y} {
162
 
 
163
 
        global Nv_ n_arrow n_arrow_size
164
 
        global n_arrow_x n_arrow_y n_arrow_z
165
 
        global arw_clr arw_text_clr
166
 
        global Nauto_draw
167
 
        
168
 
        set y [expr $Nv_(height) - $y]
169
 
 
170
 
        #create font description        
171
 
        set weight "medium"
172
 
        set slant "r"
173
 
        set style ""
174
 
    set clr $arw_text_clr
175
 
        
176
 
        if {[lindex $Nv_(arw_font) 0] != ""} {set Nv_(arw_FontType) [lindex $Nv_(arw_font) 0]}
177
 
        if {[lindex $Nv_(arw_font) 1] != ""} {set Nv_(arw_FontSize) [lindex $Nv_(arw_font) 1]}  
178
 
        if {[lsearch $Nv_(arw_font) "bold"] != -1} {set weight "bold"}
179
 
        if {[lsearch $Nv_(arw_font) "italic"] != -1} {set slant "i"}
180
 
        if {[lsearch $Nv_(arw_font) "underline"] != -1} {set style "underline"}
181
 
        if {[lsearch $Nv_(arw_font) "overstrike"] != -1} {set style "overstrike"}
182
 
        
183
 
        set font "*-$Nv_(arw_FontType)-$weight-$slant-normal-$style-$Nv_(arw_FontSize)-*-*-*-*-*-*-*"
184
 
 
185
 
#       Nplace_label $Nv_(label_text) $font $Nv_(arw_FontSize) $arw_text_clr $sx $sy
186
 
 
187
 
#Draw North Arrow at selected point
188
 
    set curr [Nget_current surf]
189
 
    if {$curr} {
190
 
        set location [Nset_Narrow $x $y $curr $n_arrow_size]
191
 
        set n_arrow_x [lindex $location 0]
192
 
        set n_arrow_y [lindex $location 1]
193
 
        set n_arrow_z [lindex $location 2]
194
 
 
195
 
        Ndraw_Narrow $n_arrow_x $n_arrow_y $n_arrow_z $n_arrow_size \
196
 
                $arw_clr $arw_text_clr
197
 
        #set chuckbutton
198
 
        set n_arrow 1
199
 
    }
200
 
 
201
 
#remove canvas binding
202
 
    bind $W <1> {}
203
 
 
204
 
}