gave 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README ADDED
@@ -0,0 +1,52 @@
1
+ GAVE README
2
+ ============
3
+
4
+ GAVE is a gtk+ based grid data analyser and viewer writen on Ruby
5
+
6
+ Requirements
7
+ ------------
8
+
9
+ * ruby >= 1.6
10
+ * GTK+
11
+ * DCL-C+gtk
12
+ * Ruby-Gnome2
13
+ * Ruby-NetCDF >= 0.5.5
14
+ * Ruby-DCL
15
+ * GPhys >= 0.2.2
16
+
17
+ Install
18
+ -------
19
+
20
+ De-Compress archive and enter its top directory.
21
+ Then type:
22
+
23
+ $ ruby setup.rb config
24
+ ($ su)
25
+ # ruby setup.rb install
26
+
27
+ You can also install files into your favorite directory
28
+ by supplying setup.rb some options. Try "ruby setup.rb --help".
29
+ Online document for setup.rb is "http://www.loveruby.net/en/prog/setup.html".
30
+
31
+ Usage
32
+ -----
33
+
34
+ Please type:
35
+
36
+ $ gave [filename [-d|--draw]] [-s|--show_windows]
37
+
38
+ License
39
+ -------
40
+
41
+ GNU LGPL, Lesser General Public License version 2.
42
+
43
+
44
+ Bug Reports
45
+ -----------
46
+
47
+ Any kind of bug reports are welcom.
48
+ If you find bugs, please email me.
49
+
50
+
51
+ Seiya Nishizawa
52
+ seiya@kugi.kyoto-u.ac.jp
@@ -0,0 +1,1983 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ tmp = $LOAD_PATH.dup
4
+ $LOAD_PATH[0] = File.dirname($0)
5
+ tmp.length.times{|i| $LOAD_PATH[i+1] = tmp[i]}
6
+
7
+ $VERBOSE = nil
8
+
9
+
10
+ require "numru/gphys"
11
+ require "numru/gave/gave_config"
12
+ require "numru/gave/draw"
13
+
14
+ argv = ARGV
15
+
16
+ device = "dcl"
17
+ device = "vtk" if argv.delete("--with-vtk")
18
+ device = "dcl" if argv.delete("--with-dcl")
19
+
20
+ if device == "dcl"
21
+ require "numru/gave/draw_dcl"
22
+ elsif device == "vtk"
23
+ require "numru/gave/draw_vtk"
24
+ end
25
+
26
+
27
+
28
+ GAVE_VERSION = "1.2.1"
29
+ HP_URL_JA = "http://www.gfd-dennou.org/arch/ruby/products/gave/index-j.html"
30
+ HP_URL_EN = "http://www.gfd-dennou.org/arch/ruby/products/gave/index.html"
31
+
32
+ begin
33
+ require "gettext"
34
+ include GetText
35
+ gettext_path = DATA_PATH+"/locale"
36
+ bindtextdomain("gave",gettext_path,nil,charset="UTF-8")
37
+ rescue LoadError
38
+ def _(str) str end
39
+ class Locale
40
+ def get; "C"; end
41
+ end
42
+ end
43
+
44
+ module NumRu
45
+ class GPhys
46
+ alias :_initialize :initialize
47
+ def initialize(*arg)
48
+ _initialize(*arg)
49
+ @funcs = Array.new
50
+ end
51
+ alias_method( "_slice".intern, "[]".intern)
52
+ def [](*slicer)
53
+ obj = self._slice(*slicer)
54
+ obj.funcs = self.funcs
55
+ return obj
56
+ end
57
+ alias :_cut :cut
58
+ def cut(*args)
59
+ obj = self._cut(*args)
60
+ obj.funcs = self.funcs
61
+ return obj
62
+ end
63
+ alias :_cyclic_ext :cyclic_ext
64
+ def cyclic_ext(dim,modulo)
65
+ obj = self._cyclic_ext(dim,modulo)
66
+ obj.funcs = self.funcs
67
+ return obj
68
+ end
69
+ def funcs
70
+ @funcs.dup
71
+ end
72
+ attr_writer :funcs
73
+ end
74
+ end
75
+
76
+ include NumRu
77
+
78
+
79
+ if GAVE_GTK_VERSION == 1
80
+ require "gtk"
81
+ require "gdk_pixbuf"
82
+ module Gtk
83
+ class Widget
84
+ def set_size_request(*arg); set_usize(*arg); end
85
+ def set_resizable(tf); set_policy(tf,tf,tf); end
86
+ def set_resizable_and_shrink(tfr,tfs); set_policy(tfs,tfr,tfr); end
87
+ end
88
+ class Window
89
+ def active?
90
+ !visible?
91
+ end
92
+ def add_accel_group(accel)
93
+ accel.attach(self)
94
+ end
95
+ end
96
+ class Entry
97
+ def text; get_text; end
98
+ def text=(str); set_text(str.to_s); end
99
+ end
100
+ class ToggleButton
101
+ def add_xpm(xpm, window)
102
+ pix, mask = Gdk::Pixmap.create_from_xpm_d(window, nil, xpm)
103
+ pixmap = Gtk::Pixmap.new(pix, mask)
104
+ self.add(pixmap)
105
+ end
106
+ end
107
+ class Label
108
+ def selectable=(dummy) end
109
+ def justify=(arg) set_justify(arg) end
110
+ def wrap=(arg) set_line_wrap(arg) end
111
+ end
112
+ class Justification
113
+ CENTER = Gtk::JUSTIFY_CENTER
114
+ end
115
+ class ItemFactory
116
+ STOCK_ITEM = ITEM
117
+ alias _create_items create_items
118
+ def create_items(ary)
119
+ ary2 = ary.collect{|a| [ a[0], a[2], a[1], a[4], a[5] ] }
120
+ _create_items(ary2)
121
+ end
122
+ alias _create_item create_item
123
+ def create_item(*ary,&proc)
124
+ _create_item(ary[0],ary[2],ary[1],&Proc.new{|w| proc.call(ary[4],w)})
125
+ end
126
+ end
127
+ class Stock
128
+ OPEN = nil
129
+ SAVE = nil
130
+ QUIT = nil
131
+ end
132
+ class FileSelection
133
+ def set_select_multiple(dummy); self; end
134
+ def selections; [filename]; end
135
+ end
136
+ end
137
+ class List
138
+ def initialize
139
+ @clist = Gtk::CList.new([_("name"),_("value")])
140
+ @clist.set_usize(300,200)
141
+ @clist.set_column_width(0,100)
142
+ end
143
+ def set_item(name, value)
144
+ @clist.append([name, value])
145
+ end
146
+ def add_note(note, title)
147
+ sw = Gtk::ScrolledWindow.new(nil,nil)
148
+ sw.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
149
+ sw.add(@clist.show)
150
+ note.append_page_menu(sw.show, Gtk::Label.new(title), Gtk::Label.new(title))
151
+ end
152
+ end
153
+ TOPLEVEL = Gtk::WINDOW_TOPLEVEL
154
+
155
+ elsif GAVE_GTK_VERSION ==2
156
+ require "gtk2"
157
+ require "numru/gave/fileselection"
158
+ if defined?(DFileSelection)
159
+ class DRbObject
160
+ alias :_initialize :initialize
161
+ def initialize(*arg)
162
+ _initialize(*arg)
163
+ @funcs = Array.new
164
+ end
165
+ def funcs
166
+ @funcs.dup
167
+ end
168
+ attr_writer :funcs
169
+ end
170
+ end
171
+
172
+ module Gtk
173
+ class Widget
174
+ def set_resizable_and_shrink(tfr,tfs); set_resizable(tfr).set_allow_shrink(false); end
175
+ end
176
+ class ToggleButton
177
+ def add_xpm(xpm, dummy)
178
+ image = Gtk::Image.new(Gdk::Pixbuf.new(xpm))
179
+ self.add(image)
180
+ end
181
+ end
182
+ end
183
+ class List
184
+ def initialize
185
+ @model = Gtk::ListStore.new(String, String)
186
+ end
187
+ def set_item(name, value)
188
+ iter = @model.append
189
+ iter[0] = name
190
+ iter[1] = value
191
+ end
192
+ def add_note(note, title)
193
+ treeview = Gtk::TreeView.new(@model)
194
+ treeview.append_column(Gtk::TreeViewColumn.new("name", Gtk::CellRendererText.new, {:text => 0}))
195
+ treeview.append_column(Gtk::TreeViewColumn.new("value", Gtk::CellRendererText.new, {:text => 1}))
196
+ sw = Gtk::ScrolledWindow.new(nil,nil)
197
+ sw.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
198
+ sw.add(treeview.show)
199
+ note.append_page(sw.show, Gtk::Label.new(title))
200
+ end
201
+ end
202
+ TOPLEVEL = Gtk::Window::TOPLEVEL
203
+ Gtk.init
204
+ end
205
+
206
+
207
+ class Select_value
208
+ attr_reader :index, :box
209
+ def initialize(val)
210
+ height=20
211
+ @val = val
212
+ @max = val.length-1
213
+ @index = 0
214
+ entry = Gtk::Entry.new
215
+ entry.set_size_request(50,height)
216
+ entry.set_editable(false)
217
+ entry.set_text(val[0].to_s)
218
+ @adjustment = Gtk::Adjustment.new(0,0,@max+1,1,10,1)
219
+ @adjustment.signal_connect("value-changed"){|w|
220
+ @index=w.value.round
221
+ entry.set_text(val[@index].to_s)
222
+ }
223
+ @scale = Gtk::HScale::new(@adjustment)
224
+ @scale.set_size_request(150,height)
225
+ @scale.set_draw_value(false)
226
+ @box = Gtk::HBox.new(false,0)
227
+ @box.pack_start(entry, true, true, 0 )
228
+ @box.pack_start(@scale)
229
+ @box.set_sensitive(false)
230
+ end
231
+ def active; @box.set_sensitive(true); end
232
+ def not_active; @box.set_sensitive(false); end
233
+ def next
234
+ if @index < @max then
235
+ @adjustment.value = @index+1
236
+ else
237
+ @adjustment.value = 0
238
+ end
239
+ end
240
+ def val
241
+ @val
242
+ end
243
+ end
244
+
245
+ class Var_select < Gtk::Combo
246
+ def initialize
247
+ super
248
+ entry.set_editable(false)
249
+ not_active
250
+ end
251
+ def get; entry.text; end
252
+ def set(array); set_popdown_strings(array); end
253
+ def set_text(text); entry.text=text; end
254
+ def active; set_sensitive(true); end
255
+ def not_active
256
+ set_sensitive(false)
257
+ entry.set_text(_("cannot select"))
258
+ end
259
+ def signal; entry.signal_connect("changed"){yield}; end
260
+ # def signal; entry.signal_connect("activate"){yield}; end
261
+ end
262
+
263
+
264
+ # draw tyep constant
265
+ LINE = 0
266
+ CONTOUR = 1
267
+ MAP = 2
268
+ VECTOR = 3
269
+ SURFACE = 4
270
+
271
+ FUNC = 10
272
+ Funcs1 = ["mean","stddev","max","min"]
273
+ SFunc = {"mean"=>_("mean"),"stddev"=>_("stddev"),"max"=>_("max"),"min"=>_("min")}
274
+
275
+ class String
276
+ alias :_to_f :to_f
277
+ def to_f
278
+ if self==""
279
+ return false
280
+ else
281
+ return self._to_f
282
+ end
283
+ end
284
+ end
285
+
286
+ class GAVE
287
+
288
+ def min(x,y)
289
+ x<y ? x : y
290
+ end
291
+ def max(x,y)
292
+ x>y ? x : y
293
+ end
294
+
295
+ attr_accessor :autodraw
296
+ def initialize(device)
297
+ @autodraw = false
298
+
299
+ @vars = Hash.new
300
+ @dims = Hash.new
301
+
302
+ accel = Gtk::AccelGroup.new
303
+
304
+ # FileSelection
305
+ fs = Gtk::FileSelection.new("")
306
+ fs.ok_button.signal_connect("clicked"){|w|
307
+ fs.hide
308
+ @filecall.call(fs.selections)
309
+ }
310
+ fs.cancel_button.signal_connect("clicked"){fs.hide}
311
+
312
+ if defined?(DFileSelection)
313
+ dfs = DFileSelection.new("Open druby")
314
+ dfs.ok_button.signal_connect("clicked"){|w|
315
+ dfs.hide
316
+ file_open(dfs.selection)
317
+ }
318
+ end
319
+
320
+ # sub windows
321
+ @subwindows = Array.new
322
+ var_window = Gtk::Window.new(TOPLEVEL).set_title(_("Variable")).set_resizable(false)
323
+ @subwindows.push var_window
324
+ axis_window = Gtk::Window.new(TOPLEVEL).set_title(_("Axis")).set_resizable(false)
325
+ @subwindows.push axis_window
326
+ @dims_window = Gtk::Window.new(TOPLEVEL).set_title(_("Dimensions")).set_resizable(false) #set_policy(false,false,true)
327
+ @subwindows.push @dims_window
328
+ attr_window = Gtk::Window.new(TOPLEVEL).set_title(_("Attributes")).set_resizable_and_shrink(true,false) #set_policy(false,true,false)
329
+ @subwindows.push attr_window
330
+ movie_window = Gtk::Window.new(TOPLEVEL).set_title(_("Movie")).set_resizable(false)
331
+ @subwindows.push movie_window
332
+ map_window = Gtk::Window.new(TOPLEVEL).set_title(_("Map")).set_resizable(false)
333
+ @subwindows.push map_window
334
+ cont_window = Gtk::Window.new(TOPLEVEL).set_title(_("Parameter for Contour and Tone")).set_resizable(false)
335
+ @subwindows.push cont_window
336
+ vector_window = Gtk::Window.new(TOPLEVEL).set_title(_("Parameter for Vector")).set_resizable(false)
337
+ @subwindows.push vector_window
338
+ div_window = Gtk::Window.new(TOPLEVEL).set_title(_("Division")).set_resizable(false)
339
+ @subwindows.push div_window
340
+ if device == "vtk"
341
+ surface_window = Gtk::Window.new(TOPLEVEL).set_title(_("Isovalue Surface")).set_resizable(false)
342
+ @subwindows.push surface_window
343
+ end
344
+ p_w = Proc.new{|c,w| c.set_active(false); w.hide }
345
+ var_window.signal_connect("delete-event"){|w,e| p_w.call(@check_var,w) }
346
+ axis_window.signal_connect("delete-event"){|w,e| p_w.call(@check_axis,w) }
347
+ @dims_window.signal_connect("delete-event"){|w,e| p_w.call(@check_dims,w) }
348
+ attr_window.signal_connect("delete-event"){|w,e| p_w.call(@check_attr,w) }
349
+ movie_window.signal_connect("delete-event"){|w,e| p_w.call(@check_movie,w) }
350
+ map_window.signal_connect("delete-event"){|w,e| p_w.call(@check_map,w) }
351
+ cont_window.signal_connect("delete-event"){|w,e| p_w.call(@check_level,w) }
352
+ vector_window.signal_connect("delete-event"){|w,e| p_w.call(@check_vector,w) }
353
+ if @device == "vtk"
354
+ surface_window.signal_connect("delete-event"){|w,e| p_w.call(@check_surface,w) }
355
+ end
356
+ div_window.signal_connect("delete-event"){|w,e| p_w.call(@check_div,w) }
357
+
358
+ # Variable window
359
+ @title_entry = Gtk::Entry.new
360
+ @miss_entry = Gtk::Entry.new
361
+ table = Gtk::Table.new(2,2,false)
362
+ table.attach(Gtk::Label.new(_("title")),0,1,0,1)
363
+ table.attach(@title_entry,1,2,0,1)
364
+ # table.attach(Gtk::Label.new(_("missing value")),0,1,1,2)
365
+ # table.attach(@miss_entry,1,2,1,2)
366
+ var_window.add(table.show_all)
367
+
368
+ # Axis window
369
+ @logxbutton = Gtk::CheckButton.new(_("log scale"))
370
+ @x_title = Gtk::Entry.new
371
+ @x_unit = Gtk::Entry.new
372
+ @x_min = Gtk::Entry.new
373
+ @x_max = Gtk::Entry.new
374
+ table = Gtk::Table.new(2,5,false)
375
+ table.attach(@logxbutton,1,2,0,1)
376
+ table.attach(Gtk::Label.new(_("title")),0,1,1,2)
377
+ table.attach(@x_title,1,2,1,2)
378
+ table.attach(Gtk::Label.new(_("unit")),0,1,2,3)
379
+ table.attach(@x_unit,1,2,2,3)
380
+ table.attach(Gtk::Label.new(_("min")),0,1,3,4)
381
+ table.attach(@x_min,1,2,3,4)
382
+ table.attach(Gtk::Label.new(_("max")),0,1,4,5)
383
+ table.attach(@x_max,1,2,4,5)
384
+ @x_frame = Gtk::Frame.new(_("X-Axis"))
385
+ @x_frame.add(table)
386
+
387
+ @logybutton = Gtk::CheckButton.new(_("log scale"))
388
+ @y_title = Gtk::Entry.new
389
+ @y_unit = Gtk::Entry.new
390
+ @y_min = Gtk::Entry.new
391
+ @y_max = Gtk::Entry.new
392
+ table = Gtk::Table.new(2,5,false)
393
+ table.attach(@logybutton,1,2,0,1)
394
+ table.attach(Gtk::Label.new(_("title")),0,1,1,2)
395
+ table.attach(@y_title,1,2,1,2)
396
+ table.attach(Gtk::Label.new(_("unit")),0,1,2,3)
397
+ table.attach(@y_unit,1,2,2,3)
398
+ table.attach(Gtk::Label.new(_("min")),0,1,3,4)
399
+ table.attach(@y_min,1,2,3,4)
400
+ table.attach(Gtk::Label.new(_("max")),0,1,4,5)
401
+ table.attach(@y_max,1,2,4,5)
402
+ @y_frame = Gtk::Frame.new(_("Y-Axis"))
403
+ @y_frame.add(table)
404
+ axisbox = Gtk::VBox.new
405
+ axisbox.pack_start(@x_frame)
406
+ axisbox.pack_start(@y_frame)
407
+ axis_window.add(axisbox.show_all)
408
+
409
+ # Attributes window
410
+ @attr_note = Gtk::Notebook::new()
411
+ @attr_note.set_tab_pos(Gtk::POS_TOP)
412
+ @attr_note.set_size_request(300, 200)
413
+ @attr_note.set_scrollable(true)
414
+ @attr_note.set_enable_popup(true)
415
+ box = Gtk::VBox.new(false,0)
416
+ box.pack_start(@attr_note)
417
+ attr_window.add(box.show_all)
418
+
419
+ # Movie winsow
420
+ start_xpm = ["11 11 2 1", " c None", "+ c black",
421
+ "+ ",
422
+ "+++ ",
423
+ "+++++ ",
424
+ "+++++++ ",
425
+ "+++++++++ ",
426
+ "+++++++++++",
427
+ "+++++++++ ",
428
+ "+++++++ ",
429
+ "+++++ ",
430
+ "+++ ",
431
+ "+ "]
432
+ stop_xpm = ["11 11 2 1", " c None", "+ c black",
433
+ " ",
434
+ " +++++++++ ",
435
+ " +++++++++ ",
436
+ " +++++++++ ",
437
+ " +++++++++ ",
438
+ " +++++++++ ",
439
+ " +++++++++ ",
440
+ " +++++++++ ",
441
+ " +++++++++ ",
442
+ " +++++++++ ",
443
+ " "]
444
+ rec_xpm = ["11 11 2 1", " c None", "+ c red",
445
+ " +++ ",
446
+ " +++++++ ",
447
+ " +++++++++ ",
448
+ " +++++++++ ",
449
+ "+++++++++++",
450
+ "+++++++++++",
451
+ "+++++++++++",
452
+ " +++++++++ ",
453
+ " +++++++++ ",
454
+ " +++++++ ",
455
+ " +++ "]
456
+ @movie = false
457
+ @movie_step = 1.0
458
+ @rec = false
459
+ @fnum = "001"
460
+ movie_window.realize
461
+ start_button = Gtk::ToggleButton.new
462
+ start_button.add_xpm(start_xpm, movie_window.window)
463
+ stop_button = Gtk::ToggleButton.new
464
+ stop_button.add_xpm(stop_xpm, movie_window.window)
465
+ rec_button = Gtk::ToggleButton.new
466
+ rec_button.add_xpm(rec_xpm, movie_window.window)
467
+ start_button.signal_connect("clicked"){|w|
468
+ if w.active? then
469
+ @time = Time.now
470
+ @movie = Gtk.idle_add{
471
+ if Time.now - @time > @movie_step then
472
+ draw_next
473
+ if @rec then
474
+ @draw.save_image("dcl"+@fnum+".png")
475
+ @fnum.next!
476
+ end
477
+ @time = Time.now
478
+ end
479
+ true
480
+ }
481
+ else
482
+ Gtk.idle_remove(@movie)
483
+ end
484
+ }
485
+ stop_button.signal_connect("clicked"){
486
+ if start_button.active? then
487
+ start_button.set_active(false)
488
+ Gtk.idle_remove(@movie)
489
+ end
490
+ }
491
+ rec_button.signal_connect("clicked"){|w|
492
+ @rec = w.active?
493
+ }
494
+ @movie_combo = Gtk::Combo.new.set_size_request(50,30)
495
+ @movie_combo.entry.set_editable(false)
496
+ @movie_combo.entry.set_text("-")
497
+ box1 = Gtk::HBox.new(false,0)
498
+ box1.pack_start(@movie_combo)
499
+ box1.pack_start(start_button)
500
+ box1.pack_start(stop_button)
501
+ box1.pack_start(rec_button)
502
+ adjustment = Gtk::Adjustment.new(@movie_step,0.0,3,0.1,1,1)
503
+ adjustment.signal_connect("value-changed"){|w|
504
+ @movie_step=w.value
505
+ }
506
+ scale = Gtk::HScale.new(adjustment)
507
+ scale.set_size_request(150,30)
508
+ scale.set_update_policy(Gtk::UPDATE_DELAYED)
509
+ scale.set_draw_value(false)
510
+ box2 = Gtk::HBox.new(false,0)
511
+ box2.pack_start(Gtk::Label.new(_("fast")))
512
+ box2.pack_start(scale)
513
+ box2.pack_start(Gtk::Label.new(_("slow")))
514
+ @movie_box = Gtk::VBox.new(false,0)
515
+ @movie_box.pack_start(box1)
516
+ @movie_box.pack_start(box2)
517
+ movie_window.add(@movie_box.show_all)
518
+
519
+ # Map window
520
+ @map_type = [_("ORTHOGRAPHIC"),_("POLAR STEREO"),_("AZIMUTHAL"),_("AZIMUTHAL EQ. AREA")]
521
+ @map_combo = Gtk::Combo.new
522
+ @map_combo.entry.set_editable(false)
523
+ @map_combo.set_popdown_strings(@map_type)
524
+ @pole_lon = Gtk::Entry.new
525
+ @pole_lat = Gtk::Entry.new
526
+ @pole_rot = Gtk::Entry.new
527
+ table = Gtk::Table.new(2,3,false)
528
+ table.attach(Gtk::Label.new(_("longitude")),0,1,0,1)
529
+ table.attach(@pole_lon,1,2,0,1)
530
+ table.attach(Gtk::Label.new(_("latitude")),0,1,1,2)
531
+ table.attach(@pole_lat,1,2,1,2)
532
+ table.attach(Gtk::Label.new(_("rotation")),0,1,2,3)
533
+ table.attach(@pole_rot,1,2,2,3)
534
+ pole_frame = Gtk::Frame.new(_("Pole"))
535
+ pole_frame.add(table)
536
+ @map_check = Gtk::CheckButton.new(_("draw map")).set_active(true)
537
+ box = Gtk::VBox.new(false,0)
538
+ box.pack_start(@map_combo)
539
+ box.pack_start(pole_frame.show_all)
540
+ box.pack_start(@map_check)
541
+ map_window.add(box.show_all)
542
+
543
+ # Level window
544
+ @cont_min_entry = Gtk::Entry.new
545
+ @cont_interval_entry = Gtk::Entry.new
546
+ cont_manual_box = Gtk::HBox.new.set_sensitive(false)
547
+ cont_manual_box.pack_start(Gtk::Label.new(_("min")))
548
+ cont_manual_box.pack_start(@cont_min_entry)
549
+ cont_manual_box.pack_start(Gtk::Label.new(_("interval")))
550
+ cont_manual_box.pack_start(@cont_interval_entry)
551
+ cont_auto_radio = Gtk::RadioButton.new(_("auto"))
552
+ cont_manual_radio = Gtk::RadioButton.new(cont_auto_radio,_("manual"))
553
+ cont_auto_radio.signal_connect("toggled"){|w|
554
+ cont_manual_box.set_sensitive(false)
555
+ @cont_level = false
556
+ }
557
+ cont_manual_radio.signal_connect("toggled"){|w|
558
+ cont_manual_box.set_sensitive(true)
559
+ @cont_level = true
560
+ }
561
+ cont_int_box = Gtk::HBox.new
562
+ cont_int_box.pack_start(cont_auto_radio)
563
+ cont_int_box.pack_start(cont_manual_radio)
564
+ cont_int_box.pack_start(cont_manual_box)
565
+ @cont_draw_button = Gtk::CheckButton.new(_("draw")).set_active(true)
566
+ @cont_draw_button.signal_connect("toggled"){|w|
567
+ cont_int_box.set_sensitive(w.active?)
568
+ }
569
+ cont_table = Gtk::Table.new(2,3,false)
570
+ cont_table.attach(Gtk::Label.new(_("Contour")),0,2,0,1)
571
+ cont_table.attach(@cont_draw_button,1,2,1,2)
572
+ cont_table.attach(Gtk::Label.new(_("Contour")+" "+_("interval")),0,1,2,3)
573
+ cont_table.attach(cont_int_box,1,2,2,3)
574
+
575
+ @tone_min_entry = Gtk::Entry.new
576
+ @tone_interval_entry = Gtk::Entry.new
577
+ tone_manual_box = Gtk::HBox.new.set_sensitive(false)
578
+ tone_manual_box.pack_start(Gtk::Label.new(_("min")))
579
+ tone_manual_box.pack_start(@tone_min_entry)
580
+ tone_manual_box.pack_start(Gtk::Label.new(_("interval")))
581
+ tone_manual_box.pack_start(@tone_interval_entry)
582
+ tone_auto_radio = Gtk::RadioButton.new(_("auto"))
583
+ tone_manual_radio = Gtk::RadioButton.new(tone_auto_radio,_("manual"))
584
+ tone_auto_radio.signal_connect("toggled"){|w|
585
+ tone_manual_box.set_sensitive(false)
586
+ @tone_level = false
587
+ }
588
+ tone_manual_radio.signal_connect("toggled"){|w|
589
+ tone_manual_box.set_sensitive(true)
590
+ @tone_level = true
591
+ }
592
+ tone_int_box = Gtk::HBox.new
593
+ tone_int_box.pack_start(tone_auto_radio)
594
+ tone_int_box.pack_start(tone_manual_radio)
595
+ tone_int_box.pack_start(tone_manual_box)
596
+ tone_method_e_radio = Gtk::RadioButton.new(_("Use")+" uetone")
597
+ tone_method_f_radio = Gtk::RadioButton.new(tone_method_e_radio,_("Use")+" uetonf ("+_("cellular")+" "+_("algorithm")+")")
598
+ tone_method_c_radio = Gtk::RadioButton.new(tone_method_e_radio,_("Use")+" uetonc ("+_("cellular")+" "+_("tiling")+")")
599
+ @tone_method = "uetone"
600
+ tone_method_e_radio.signal_connect("toggled"){ @tone_method = "uetone" }
601
+ tone_method_f_radio.signal_connect("toggled"){ @tone_method = "uetonf" }
602
+ tone_method_c_radio.signal_connect("toggled"){ @tone_method = "uetonc" }
603
+ tone_method_e_radio.set_active(true)
604
+ tone_method_box = Gtk::HBox.new
605
+ tone_method_box.pack_start(tone_method_e_radio)
606
+ tone_method_box.pack_start(tone_method_f_radio)
607
+ tone_method_box.pack_start(tone_method_c_radio)
608
+ @tone_draw_button = Gtk::CheckButton.new(_("draw")).set_active(true)
609
+ @tone_draw_button.signal_connect("toggled"){|w|
610
+ tone_int_box.set_sensitive(w.active?)
611
+ tone_method_box.set_sensitive(w.active?)
612
+ }
613
+ tone_table = Gtk::Table.new(2,3,false)
614
+ tone_table.attach(Gtk::Label.new(_("Tone")),0,2,0,1)
615
+ tone_table.attach(@tone_draw_button,1,2,1,2)
616
+ tone_table.attach(Gtk::Label.new(_("Tone")+" "+_("interval")),0,1,2,3)
617
+ tone_table.attach(tone_int_box,1,2,2,3)
618
+ tone_table.attach(Gtk::Label.new(_("Method")),0,1,3,4)
619
+ tone_table.attach(tone_method_box,1,2,3,4)
620
+ level_box = Gtk::VBox.new
621
+ level_box.pack_start(cont_table)
622
+ level_box.pack_start(Gtk::HSeparator.new)
623
+ level_box.pack_start(tone_table)
624
+ cont_window.add(level_box.show_all)
625
+
626
+ # Vector Window
627
+ @vector_scale_x_entry = Gtk::Entry.new
628
+ @vector_scale_y_entry = Gtk::Entry.new
629
+ scale_entry_box = Gtk::HBox.new.set_sensitive(false)
630
+ scale_entry_box.pack_start(Gtk::Label.new("X"))
631
+ scale_entry_box.pack_start(@vector_scale_x_entry)
632
+ scale_entry_box.pack_start(Gtk::Label.new("Y"))
633
+ scale_entry_box.pack_start(@vector_scale_y_entry)
634
+ check = Gtk::CheckButton.new(_("manual"))
635
+ check.signal_connect("toggled"){|w|
636
+ scale_entry_box.set_sensitive(w.active?)
637
+ @vector_factor = w.active?
638
+ }
639
+ scale_box = Gtk::HBox.new
640
+ scale_box.pack_start(check)
641
+ scale_box.pack_start(scale_entry_box)
642
+
643
+ @vector_thinout_x_entry = Gtk::Entry.new
644
+ @vector_thinout_y_entry = Gtk::Entry.new
645
+ thinout_entry_box = Gtk::HBox.new.set_sensitive(false)
646
+ thinout_entry_box.pack_start(Gtk::Label.new("X"))
647
+ thinout_entry_box.pack_start(@vector_thinout_x_entry)
648
+ thinout_entry_box.pack_start(Gtk::Label.new("Y"))
649
+ thinout_entry_box.pack_start(@vector_thinout_y_entry)
650
+ check = Gtk::CheckButton.new(_("manual"))
651
+ check.signal_connect("toggled"){|w|
652
+ thinout_entry_box.set_sensitive(w.active?)
653
+ @vector_thinout = w.active?
654
+ }
655
+ thinout_box = Gtk::HBox.new
656
+ thinout_box.pack_start(check)
657
+ thinout_box.pack_start(thinout_entry_box)
658
+
659
+ vector_table = Gtk::Table.new(2,2,false)
660
+ vector_table.attach(Gtk::Label.new(_("Scale")),0,1,0,1)
661
+ vector_table.attach(scale_box,1,2,0,1)
662
+ vector_table.attach(Gtk::Label.new(_("Thin out")),0,1,1,2)
663
+ vector_table.attach(thinout_box,1,2,1,2)
664
+ vector_window.add(vector_table.show_all)
665
+
666
+ # Isovalue Surface Window
667
+ scale = Gtk::HScale.new(0,1,0.01)
668
+ scale.set_size_request(200,40)
669
+ scale.value = 0.5
670
+ @surface_adjust = scale.adjustment
671
+ surface_box = Gtk::HBox.new
672
+ surface_box.pack_start(Gtk::Label.new(_("value")))
673
+ surface_box.pack_start(scale)
674
+ if device=="vtk"
675
+ surface_window.add(surface_box.show_all)
676
+ end
677
+
678
+ # Division Window
679
+ @leng_div = Gtk::RadioButton.new(_("Lengthways"))
680
+ @side_div = Gtk::RadioButton.new(@leng_div, _("Sideways"))
681
+ @x_div = Gtk::Entry.new.set_text("1")
682
+ @y_div = Gtk::Entry.new.set_text("1")
683
+ val_table = Gtk::Table.new(2,3,false)
684
+ val_table.attach(@leng_div,0,1,0,1)
685
+ val_table.attach(@side_div,1,2,0,1)
686
+ val_table.attach(Gtk::Label.new("X"),0,1,1,2)
687
+ val_table.attach(@x_div,1,2,1,2)
688
+ val_table.attach(Gtk::Label.new("Y"),0,1,2,3)
689
+ val_table.attach(@y_div,1,2,2,3)
690
+ val_table.set_sensitive(false)
691
+ button = Gtk::CheckButton.new("divide")
692
+ button.signal_connect("toggled"){|w|
693
+ val_table.set_sensitive(w.active?)
694
+ }
695
+ div_box = Gtk::VBox.new
696
+ div_box.pack_start(button)
697
+ div_box.pack_start(val_table)
698
+ div_window.add(div_box.show_all)
699
+
700
+ # Variable Combo
701
+ @var_select = Var_select.new
702
+ @var2_select = Var_select.new
703
+ @axisx_select = Var_select.new
704
+ @axisy_select = Var_select.new
705
+ @axisz_select = Var_select.new
706
+ @var_select.signal{set_var}
707
+ @var2_select.signal{set_var2}
708
+ @axisx_select.signal{set_axisx}
709
+ @axisy_select.signal{set_axisy}
710
+ @axisz_select.signal{set_axisz}
711
+
712
+ # figure type item
713
+ select_type = Proc.new{|type|
714
+ type = type[0] if type.class == Array
715
+ @fig_type = type
716
+ case type
717
+ when LINE
718
+ @fig_dimension = 1
719
+ when CONTOUR, VECTOR, MAP
720
+ @fig_dimension = 2
721
+ when SURFACE
722
+ @fig_dimension = 3
723
+ end
724
+ set_type
725
+ }
726
+
727
+ items = [
728
+ ["/"+_("Line"), Gtk::ItemFactory::ITEM,nil,nil,select_type,LINE],
729
+ ["/"+_("Contour")+" & "+_("Tone"), Gtk::ItemFactory::ITEM,nil,nil,select_type,CONTOUR],
730
+ ["/"+_("Map"), Gtk::ItemFactory::ITEM,nil,nil,select_type,MAP],
731
+ ["/"+_("Vector"), Gtk::ItemFactory::ITEM,nil,nil,select_type,VECTOR]
732
+ ]
733
+ if device == "vtk"
734
+ items.push ["/"+_("Surface"), Gtk::ItemFactory::ITEM,nil,nil,select_type,SURFACE]
735
+ @enable_3d = true
736
+ end
737
+ type_itemfact = Gtk::ItemFactory.new(Gtk::ItemFactory::TYPE_OPTION_MENU, "<type>", accel)
738
+ type_itemfact.create_items(items)
739
+ @typeomenu = type_itemfact.get_widget("<type>")
740
+ @typeomenu.set_sensitive(false)
741
+ @typemenu = Array.new
742
+ @typemenu[LINE] = type_itemfact.get_item("/"+_("Line"))
743
+ @typemenu[CONTOUR] = type_itemfact.get_item("/"+_("Contour")+" & "+_("Tone"))
744
+ @typemenu[MAP] = type_itemfact.get_item("/"+_("Map"))
745
+ @typemenu[VECTOR] = type_itemfact.get_item("/"+_("Vector"))
746
+ if @enable_3d
747
+ @typemenu[SURFACE] = type_itemfact.get_item("/"+_("Surface"))
748
+ end
749
+
750
+
751
+ select_func = Proc.new{|func|
752
+ func = func[0] if func.class == Array
753
+ set_func(func)
754
+ }
755
+ items = [ ["/"+_("Functions"), Gtk::ItemFactory::BRANCH ] ]
756
+ Funcs1.each{|func|
757
+ items.push( ["/"+_("Functions")+"/"+SFunc[func], Gtk::ItemFactory::ITEM, nil, nil, select_func, func ] )
758
+ }
759
+ type_itemfact.create_items(items)
760
+
761
+ # Draw button
762
+ @crewindbutton = Gtk::CheckButton.new(_("new Window"))
763
+ @drawbutton = Gtk::Button.new(_("draw")).set_sensitive(false)
764
+ @drawbutton.signal_connect("clicked"){
765
+ if @fig_type==FUNC
766
+ exec_func
767
+ else
768
+ draw_x
769
+ end
770
+ }
771
+
772
+ # Select table
773
+ table = Gtk::Table.new(2,7,false)
774
+ i = 0
775
+ table.attach(Gtk::Label.new(_("Variable")),0,1,i,i+1)
776
+ table.attach(@var_select,1,2,i,i+1)
777
+ i += 1
778
+ table.attach(Gtk::Label.new(_("Variable")+"2"),0,1,i,i+1)
779
+ table.attach(@var2_select,1,2,i,i+1)
780
+ i += 1
781
+ table.attach(Gtk::Label.new(_("Action")),0,1,i,i+1)
782
+ table.attach(@typeomenu,1,2,i,i+1)
783
+ i += 1
784
+ table.attach(Gtk::Label.new("X-"+_("Axis")),0,1,i,i+1)
785
+ table.attach(@axisx_select,1,2,i,i+1)
786
+ i += 1
787
+ table.attach(Gtk::Label.new("Y-"+_("Axis")),0,1,i,i+1)
788
+ table.attach(@axisy_select,1,2,i,i+1)
789
+ if @enable_3d
790
+ i += 1
791
+ table.attach(Gtk::Label.new("Z-"+_("Axis")),0,1,i,i+1)
792
+ table.attach(@axisz_select,1,2,i,i+1)
793
+ end
794
+ i += 1
795
+ table.attach(@crewindbutton,0,1,i,i+1)
796
+ table.attach(@drawbutton,1,2,i,i+1)
797
+
798
+ # Main Menu
799
+ p_f_o = Proc.new{
800
+ fs.set_title(_("Open File"))
801
+ fs.complete("*.nc")
802
+ fs.hide_fileop_buttons
803
+ fs.set_select_multiple(true)
804
+ @filecall = Proc.new{|filenames| file_open(filenames)}
805
+ fs.show
806
+ }
807
+ p_f_o2 = Proc.new{ dfs.show } if defined?(DFileSelection)
808
+ p_f_si = Proc.new{
809
+ if !@draw.nil?
810
+ fs.set_title(_("Save Image"))
811
+ fs.complete("*.png")
812
+ fs.show_fileop_buttons
813
+ fs.set_select_multiple(false)
814
+ @filecall = Proc.new{|filenames|
815
+ filename = filenames[0]
816
+ if !FileTest.exist?(filename)
817
+ @draw.save_image(filename)
818
+ else
819
+ dialog = Gtk::Dialog.new
820
+ dialog.set_modal(true)
821
+ dialog.vbox.pack_start(Gtk::Label.new("Can "+filename+" overwrite ?"))
822
+ ok_button=Gtk::Button.new(_("OK"))
823
+ ok_button.signal_connect("clicked"){dialog.destroy; @draw.save_image(filename)}
824
+ cancel_button=Gtk::Button.new(_("Cancel"))
825
+ cancel_button.signal_connect("clicked"){dialog.destroy}
826
+ dialog.action_area.pack_start(ok_button)
827
+ dialog.action_area.pack_start(cancel_button)
828
+ dialog.show_all
829
+ end
830
+ }
831
+ fs.show
832
+ end
833
+ }
834
+ p_f_sc = Proc.new{
835
+ if !@draw.nil?
836
+ fs.set_title(_("Save Code"))
837
+ fs.complete("*.rb")
838
+ fs.show_fileop_buttons
839
+ fs.set_select_multiple(false)
840
+ @filecall = proc{|filenames|
841
+ filename = filenames[0]
842
+ if !FileTest.exist?(filename)
843
+ @draw.save_code(filename)
844
+ else
845
+ dialog = Gtk::Dialog.new
846
+ dialog.set_modal(true)
847
+ dialog.vbox.pack_start(Gtk::Label.new("Can "+filename+" overwrite ?"))
848
+ ok_button=Gtk::Button.new(_("OK"))
849
+ ok_button.signal_connect("clicked"){dialog.destroy; @draw.save_code(filename)}
850
+ cancel_button=Gtk::Button.new(_("Cancel"))
851
+ cancel_button.signal_connect("clicked"){dialog.destroy}
852
+ dialog.action_area.pack_start(ok_button)
853
+ dialog.action_area.pack_start(cancel_button)
854
+ dialog.show_all
855
+ end
856
+ }
857
+ fs.show
858
+ end
859
+ }
860
+ p_f_sn = Proc.new{
861
+ if !@draw.nil?
862
+ fs.set_title(_("Save NetCDF"))
863
+ fs.complete("*.nc")
864
+ fs.show_fileop_buttons
865
+ fs.set_select_multiple(false)
866
+ @filecall = proc{|filenames|
867
+ filename = filenames[0]
868
+ if !FileTest.exist?(filename)
869
+ file = NetCDF.create(filename)
870
+ gphys = @draw_data.gphys
871
+ gphys = gphys.copy if !(GPhys===gphys)
872
+ GPhys::IO.write(file,gphys)
873
+ file.close
874
+ else
875
+ dialog = Gtk::Dialog.new
876
+ dialog.set_modal(true)
877
+ dialog.vbox.pack_start(Gtk::Label.new("Can "+filename+" overwrite ?"))
878
+ ok_button=Gtk::Button.new(_("OK"))
879
+ ok_button.signal_connect("clicked"){
880
+ dialog.destroy
881
+ file = NetCDF.create(filename)
882
+ gphys = @draw_data.gphys
883
+ gphys = gphys.copy if !(GPhys===gphys)
884
+ GPhys::IO.write(file,gphys)
885
+ file.close
886
+ }
887
+ cancel_button=Gtk::Button.new(_("Cancel"))
888
+ cancel_button.signal_connect("clicked"){dialog.destroy}
889
+ dialog.action_area.pack_start(ok_button)
890
+ dialog.action_area.pack_start(cancel_button)
891
+ dialog.show_all
892
+ end
893
+ }
894
+ fs.show
895
+ end
896
+ }
897
+ p_f_q = Proc.new{finish}
898
+
899
+ p_t = Proc.new{|data|
900
+ if data.class==Array
901
+ window,w = data
902
+ else
903
+ window = data
904
+ w = window
905
+ end
906
+ if w.active? then window.show else window.hide end
907
+ }
908
+
909
+ p_h_h = Proc.new{
910
+ if Locale.get =~ /ja/
911
+ url = HP_URL_JA
912
+ else
913
+ url = HP_URL_EN
914
+ end
915
+ system("mozilla -remote 'openURL(#{url})'")
916
+ }
917
+ p_h_a = Proc.new{
918
+ dialog = Gtk::Dialog.new.set_title(_("About this program"))
919
+ dialog.vbox.pack_start(Gtk::Label.new("\nGAVE version #{GAVE_VERSION}\n"))
920
+ dialog.vbox.pack_start(Gtk::Label.new(_("This program is made by Seiya Nishizawa")))
921
+ dialog.vbox.pack_start(Gtk::Label.new("seiya@kugi.kyoto-u.ac.jp\n"))
922
+ ok_button=Gtk::Button.new(_("OK"))
923
+ ok_button.signal_connect("clicked"){dialog.destroy}
924
+ dialog.action_area.pack_start(ok_button)
925
+ dialog.show_all
926
+ }
927
+
928
+ fileitem = [["/"+_("File")+"(_F)", Gtk::ItemFactory::BRANCH]]
929
+ fileitem.push ["/"+_("File")+"(F)/"+_("Open")+"(_O)", Gtk::ItemFactory::STOCK_ITEM, "<control>O", Gtk::Stock::OPEN, p_f_o]
930
+ fileitem.push ["/"+_("File")+"(F)/"+"Open DRuby", Gtk::ItemFactory::STOCK_ITEM, nil, Gtk::Stock::OPEN, p_f_o2] if defined?(DFileSelection)
931
+ fileitem.push ["/"+_("File")+"(F)/"+_("Save Image")+"(_S)", Gtk::ItemFactory::STOCK_ITEM, "<control>S", Gtk::Stock::SAVE, p_f_si]
932
+ fileitem.push ["/"+_("File")+"(F)/"+_("Save Code")+"(_C)", Gtk::ItemFactory::STOCK_ITEM, "<control>C", Gtk::Stock::SAVE, p_f_sc]
933
+ fileitem.push ["/"+_("File")+"(F)/"+_("Save NetCDF")+"(_N)", Gtk::ItemFactory::STOCK_ITEM, "<control>N", Gtk::Stock::SAVE, p_f_sn]
934
+ fileitem.push ["/"+_("File")+"(F)/"+_("Quit")+"(_Q)", Gtk::ItemFactory::STOCK_ITEM, "<control>Q", Gtk::Stock::QUIT, p_f_q]
935
+
936
+ toolsitem = [["/"+_("Tools")+"(_T)", Gtk::ItemFactory::BRANCH]]
937
+ toolsitem.push ["/"+_("Tools")+"(T)/"+_("Variable")+"(_V)", Gtk::ItemFactory::CHECK_ITEM, nil, nil, p_t, var_window]
938
+ toolsitem.push ["/"+_("Tools")+"(T)/"+_("Axis")+"(_A)", Gtk::ItemFactory::CHECK_ITEM, nil, nil, p_t, axis_window]
939
+ toolsitem.push ["/"+_("Tools")+"(T)/"+_("Dimensions")+"(_D)", Gtk::ItemFactory::CHECK_ITEM, nil, nil, p_t, @dims_window]
940
+ toolsitem.push ["/"+_("Tools")+"(T)/"+_("Attributes")+"(_T)", Gtk::ItemFactory::CHECK_ITEM, nil, nil, p_t, attr_window]
941
+ toolsitem.push ["/"+_("Tools")+"(T)/"+_("Movie")+"(_O)", Gtk::ItemFactory::CHECK_ITEM, nil, nil, p_t, movie_window]
942
+ toolsitem.push ["/"+_("Tools")+"(T)/"+_("Map")+"(_M)", Gtk::ItemFactory::CHECK_ITEM, nil, nil, p_t, map_window]
943
+ toolsitem.push ["/"+_("Tools")+"(T)/"+_("Contour")+" & "+_("Tone")+"(_C)", Gtk::ItemFactory::CHECK_ITEM, nil, nil, p_t, cont_window]
944
+ toolsitem.push ["/"+_("Tools")+"(T)/"+_("Vector")+"(_E)", Gtk::ItemFactory::CHECK_ITEM, nil, nil, p_t, vector_window]
945
+ toolsitem.push ["/"+_("Tools")+"(T)/"+_("Surface")+"(_S)", Gtk::ItemFactory::CHECK_ITEM, nil, nil, p_t, surface_window]
946
+ # toolsitem.push ["/"+_("Tools")+"(T)/"+_("Division")+"(_I)", Gtk::ItemFactory::CHECK_ITEM, nil, nil, p_t, div_window]
947
+
948
+ windowitem = [["/"+_("Windows")+"(_W)", Gtk::ItemFactory::BRANCH]]
949
+
950
+ helpitem = [["/"+_("Help")+"(_H)", Gtk::ItemFactory::LAST_BRANCH]]
951
+ helpitem.push ["/"+_("Help")+"(H)/"+_("HomePage")+"(_H)", Gtk::ItemFactory::ITEM, nil, nil, p_h_h]
952
+ helpitem.push ["/"+_("Help")+"(H)/"+_("About")+"(_A)", Gtk::ItemFactory::ITEM, nil, nil, p_h_a]
953
+
954
+ items = fileitem + toolsitem + windowitem+helpitem
955
+ @main_itemfact = Gtk::ItemFactory.new(Gtk::ItemFactory::TYPE_MENU_BAR, "<main>", accel)
956
+ @main_itemfact.create_items(items)
957
+
958
+ @save_image = @main_itemfact.get_item("/"+_("File")+"(F)/"+_("Save Image")+"(S)").set_sensitive(false)
959
+ @save_code = @main_itemfact.get_item("/"+_("File")+"(F)/"+_("Save Code")+"(C)").set_sensitive(false)
960
+ @save_netcdf = @main_itemfact.get_item("/"+_("File")+"(F)/"+_("Save NetCDF")+"(N)").set_sensitive(false)
961
+
962
+ @check_var = @main_itemfact.get_item("/"+_("Tools")+"(T)/"+_("Variable")+"(V)")
963
+ @check_axis = @main_itemfact.get_item("/"+_("Tools")+"(T)/"+_("Axis")+"(A)")
964
+ @check_dims = @main_itemfact.get_item("/"+_("Tools")+"(T)/"+_("Dimensions")+"(D)")
965
+ @check_attr = @main_itemfact.get_item("/"+_("Tools")+"(T)/"+_("Attributes")+"(T)")
966
+ @check_movie = @main_itemfact.get_item("/"+_("Tools")+"(T)/"+_("Movie")+"(O)")
967
+ @check_map = @main_itemfact.get_item("/"+_("Tools")+"(T)/"+_("Map")+"(M)")
968
+ @check_level = @main_itemfact.get_item("/"+_("Tools")+"(T)/"+_("Contour")+" & "+_("Tone")+"(_C)")
969
+ @check_vector = @main_itemfact.get_item("/"+_("Tools")+"(T)/"+_("Vector")+"(E)")
970
+ if device == "vtk"
971
+ @check_surface = @main_itemfact.get_item("/"+_("Tools")+"(T)/"+_("Surface")+"(S)")
972
+ end
973
+ # @check_div = @main_itemfact.get_item("/"+_("Tools")+"(T)/"+_("Division")+"(L)")
974
+
975
+
976
+ # main window
977
+ totalbox = Gtk::VBox.new(false,0)
978
+ totalbox.pack_start(@main_itemfact.get_widget("<main>"),false,true,0)
979
+ totalbox.pack_start(table,false,true,0)
980
+ main_window = Gtk::Window.new(TOPLEVEL).set_resizable(false)
981
+ main_window.set_title("gave")
982
+ main_window.add(totalbox)
983
+ main_window.signal_connect("delete-event"){false}
984
+ main_window.signal_connect("destroy"){finish}
985
+ main_window.add_accel_group(accel)
986
+ main_window.show_all
987
+
988
+ end
989
+
990
+ def showwindows
991
+ @subwindows.each{|w| w.show}
992
+ end
993
+
994
+
995
+ def set_title(str); @title_entry.text=str; end
996
+ def get_title; @title_entry.text; end
997
+ # def set_missing(val); @miss_entry.text=val.to_s; end
998
+ # def get_missing; @miss_entry.text.to_f; end
999
+ def set_div(ary)
1000
+ ary[0]==0 ? @leng_div.active=true : @side_div.active=true
1001
+ @x_div.text = ary[1].to_s
1002
+ @y_div.text = ary[2].to_s
1003
+ end
1004
+ def get_div
1005
+ [@leng_div.active? ? 0 : 1, @x_div.text.to_i, @y_div.text.to_i]
1006
+ end
1007
+
1008
+ def set_axis_x_log(tf); @logxbutton.active=tf; end
1009
+ def get_axis_x_log; @logxbutton.active?; end
1010
+ def set_axis_x_title(str); @x_title.text=str; end
1011
+ def get_axis_x_title; @x_title.text; end
1012
+ def set_axis_x_unit(str); @x_unit.text=str; end
1013
+ def get_axis_x_unit; @x_unit.text; end
1014
+ def set_axis_x_min(val); @x_min.text=val.to_s; end
1015
+ def get_axis_x_min; @x_min.text.to_f ; end
1016
+ def set_axis_x_max(val); @x_max.text=val.to_s; end
1017
+ def get_axis_x_max; @x_max.text.to_f ; end
1018
+ def set_axis_y_log(tf); @logybutton.active=tf; end
1019
+ def get_axis_y_log; @logybutton.active?; end
1020
+ def set_axis_y_title(str); @y_title.text=str; end
1021
+ def get_axis_y_title; @y_title.text; end
1022
+ def set_axis_y_unit(str); @y_unit.text=str; end
1023
+ def get_axis_y_unit; @y_unit.text; end
1024
+ def set_axis_y_min(val); @y_min.text=val.to_s; end
1025
+ def get_axis_y_min; @y_min.text.to_f ; end
1026
+ def set_axis_y_max(val); @y_max.text=val.to_s; end
1027
+ def get_axis_y_max; @y_max.text.to_f ; end
1028
+
1029
+ # OpenFile
1030
+ def add_attr_list(varray,name=nil)
1031
+ attr_list = List.new
1032
+ varray.att_names.each{|n|
1033
+ val = varray.get_att(n)
1034
+ if val.class==NArray then
1035
+ val = val.to_a.join(",")
1036
+ end
1037
+ attr_list.set_item(n, val)
1038
+ }
1039
+ attr_list.add_note(@attr_note,name ? name : varray.name)
1040
+ end
1041
+ def open_var(gphys, filenames, filetype=nil)
1042
+ vn_o = gphys.name
1043
+ vn = vn_o
1044
+ unless gphys.rank==1 && gphys.axnames[0]==vn then
1045
+ if @vars.has_key?(vn)
1046
+ i=2
1047
+ while @vars.has_key?(vn = vn_o+"(#{i})")
1048
+ i+=1
1049
+ end
1050
+ end
1051
+ @vars[vn] = gphys
1052
+ filenames = [filenames] if !(Array===filenames)
1053
+ @vars[vn].funcs = [[filenames, filetype, vn_o]]
1054
+ gphys.axnames.each{|an|
1055
+ val = gphys.coord(an).val
1056
+ i = nil
1057
+ an_o = an
1058
+ while true
1059
+ an = i ? an_o+"(#{i})" : an
1060
+ if @dims.has_key?(an) then
1061
+ if @dims[an].val == val
1062
+ an = nil
1063
+ break
1064
+ end
1065
+ else
1066
+ break
1067
+ end
1068
+ i ? i+=1 : i=2
1069
+ end
1070
+ if an
1071
+ @dims[an] = Select_value.new(val)
1072
+ add_attr_list(gphys.coord(an_o),an)
1073
+ end
1074
+ }
1075
+ add_attr_list(gphys.data)
1076
+ end
1077
+ end
1078
+
1079
+ def file_open(filenames)
1080
+ if ! (filenames[0]=~/^druby:\/\//)
1081
+ filename = filenames.collect{|fn|
1082
+ fn.sub!(/^file:\/\//,"")
1083
+ if fn=~/^http:\/\//
1084
+ fn
1085
+ else
1086
+ File.expand_path(fn)
1087
+ end
1088
+ }
1089
+ begin
1090
+ if filename.length==1
1091
+ file = nil
1092
+ GPhys::IO.var_names_except_coordinates(filename[0]).each{|vn|
1093
+ gphys = GPhys::IO.open(file ? file : filename[0],vn)
1094
+ file = gphys.data.file if file.nil?
1095
+ open_var(gphys,filename[0])
1096
+ }
1097
+ # attr_list = List.new
1098
+ # file.each_att{|att|
1099
+ # val = att.get
1100
+ # if val.class==NArray then
1101
+ # val = att.get.to_a.join(",")
1102
+ # end
1103
+ # attr_list.set_item(att.name, val)
1104
+ # }
1105
+ # attr_list.add_note(@attr_note, _("global"))
1106
+ else
1107
+ begin
1108
+ GPhys::IO.var_names_except_coordinates(filename).each{|vn|
1109
+ gphys = GPhys::IO.open(fn,vn)
1110
+ open_var(gphys,fn)
1111
+ }
1112
+ rescue
1113
+ filename.each{|fn|
1114
+ GPhys::IO.var_names_except_coordinates(fn).each{|vn|
1115
+ gphys = GPhys::IO.open(fn,vn)
1116
+ open_var(gphys, fn)
1117
+ }
1118
+ # attr_list = List.new
1119
+ # f.each_att{|att|
1120
+ # val = att.get
1121
+ # if val.class==NArray then
1122
+ # val = att.get.to_a.join(",")
1123
+ # end
1124
+ # attr_list.set_item(att.name, val)
1125
+ # }
1126
+ # attr_list.add_note(@attr_note, _("global")+" (#{File.basename(fn)})")
1127
+ }
1128
+ end
1129
+ end
1130
+ rescue
1131
+ error_message = $!.to_s
1132
+ dialog = Gtk::Dialog.new.set_title(_("Error Message"))
1133
+ dialog.set_modal(true)
1134
+ dialog.vbox.pack_start(Gtk::Label.new(filename[0]))
1135
+ dialog.vbox.pack_start(Gtk::Label.new(error_message))
1136
+ dialog.vbox.pack_start(Gtk::Label.new("in opening File"))
1137
+ ok_button=Gtk::Button.new(_("OK"))
1138
+ ok_button.signal_connect("clicked"){dialog.destroy}
1139
+ dialog.action_area.pack_start(ok_button)
1140
+ dialog.show_all
1141
+ clear_all
1142
+ end
1143
+
1144
+ else
1145
+ ary = filenames[0].split("/")
1146
+ host = "druby://"+ary[2]
1147
+ path = ary[3..-1].join("/")
1148
+ raise "path is not given" if path==""
1149
+ tree = DRbObject.new(nil,host)
1150
+ gphys = tree.data(path)
1151
+ open_var(gphys, filenames, "druby")
1152
+ end
1153
+
1154
+ clear_dim
1155
+ @dimtable = Gtk::Table.new(2, @dims.length, false)
1156
+ i=0
1157
+ @dims.keys.sort.each{|dim|
1158
+ @dimtable.attach(Gtk::Label.new(dim).set_size_request(30,20), 0, 1, i, i+1 )
1159
+ @dimtable.attach(@dims[dim].box, 1, 2, i, i+1 )
1160
+ i += 1
1161
+ }
1162
+ @dims_window.add(@dimtable.show_all)
1163
+
1164
+ @var_select.set(@vars.keys.sort.reverse)
1165
+ @var_select.active
1166
+ set_var
1167
+
1168
+ end
1169
+
1170
+ def set_var
1171
+ vname = @var_select.get
1172
+ return if vname==_("cannot select") ||vname==""
1173
+ @vname = vname
1174
+ gphys = @vars[@vname]
1175
+ title = gphys.name
1176
+ title += "("+gphys.units.to_s+")" if gphys.units.to_s!=""
1177
+ set_title(title)
1178
+ ax = gphys.axnames
1179
+ type = @draw_data && @draw_data.type
1180
+ if ax.length == 1 then
1181
+ @typeomenu.set_history(LINE)
1182
+ @typemenu[LINE].activate
1183
+ @typeomenu.set_sensitive(false)
1184
+ axis = nil
1185
+ if type==LINE && ax.index(@x_name)
1186
+ axis = @x_name
1187
+ end
1188
+ clear_axisx
1189
+ @typeomenu.set_history(0)
1190
+ @typemenu[LINE].activate
1191
+ if axis
1192
+ @axisx_select.set_text(axis)
1193
+ set_axis_x_title( @draw_data.axis_x.title )
1194
+ set_axis_x_unit( @draw_data.axis_x.unit )
1195
+ set_axis_x_log( @draw_data.axis_x.log )
1196
+ set_axis_x_min( @draw_data.axis_x.min )
1197
+ set_axis_x_max( @draw_data.axis_x.max )
1198
+ end
1199
+ else
1200
+ if @enable_3d
1201
+ if ax.length == 2
1202
+ @typemenu[SURFACE].set_sensitive(false)
1203
+ else
1204
+ @typemenu[SURFACE].set_sensitive(true)
1205
+ end
1206
+ end
1207
+ axis = nil
1208
+ if type
1209
+ if @fig_dimension==2 && ax.index(@x_name) && ax.index(@y_name)
1210
+ axis = [@x_name,@y_name]
1211
+ elsif @fig_dimension==3 && ax.index(@x_name) && ax.index(@y_name) && ax.index(@z_name)
1212
+ axis = [@x_name,@y_name,@z_name]
1213
+ end
1214
+ end
1215
+ clear_axisx
1216
+ @axisx_select.set(ax)
1217
+ @axisx_select.set_text("")
1218
+ @typeomenu.set_sensitive(true)
1219
+ if axis
1220
+ @typeomenu.set_history(type)
1221
+ @typemenu[type].activate
1222
+ @axisx_select.set_text(axis[0])
1223
+ @axisy_select.set_text(axis[1])
1224
+ if @fig_dimension==3
1225
+ @axisz_select.set_text(axis[2])
1226
+ end
1227
+ set_axis_x_title( @draw_data.axis_x.title )
1228
+ set_axis_x_unit( @draw_data.axis_x.unit )
1229
+ set_axis_x_log( @draw_data.axis_x.log )
1230
+ set_axis_x_min( @draw_data.axis_x.min )
1231
+ set_axis_x_max( @draw_data.axis_x.max )
1232
+
1233
+ set_axis_y_title( @draw_data.axis_y.title )
1234
+ set_axis_y_unit( @draw_data.axis_y.unit )
1235
+ set_axis_y_log( @draw_data.axis_y.log )
1236
+ set_axis_y_min( @draw_data.axis_y.min )
1237
+ set_axis_y_max( @draw_data.axis_y.max )
1238
+ else
1239
+ @typeomenu.set_history(CONTOUR)
1240
+ @typemenu[CONTOUR].activate
1241
+ end
1242
+ end
1243
+ if @autodraw
1244
+ @autodraw=false
1245
+ @drawbutton.clicked
1246
+ end
1247
+ end
1248
+
1249
+ def set_var2
1250
+ vname = @var2_select.get
1251
+ if !(vname==_("cannot select") ||vname=="") then
1252
+ @vname2 = vname
1253
+ gphys1 = @vars[@vname2]
1254
+ gphys2 = @vars[@vname]
1255
+ title = gphys1.name+","+gphys2.name
1256
+ set_title(title)
1257
+ end
1258
+ end
1259
+
1260
+ def set_type
1261
+ @drawbutton.children[0].set_text(_("draw"))
1262
+ clear_axisx
1263
+ if @vname.nil? then return end
1264
+ x_name = @vars[@vname].axnames[0]
1265
+ if @fig_type == MAP
1266
+ @vars[@vname].axnames.each{|dim|
1267
+ if dim.downcase=~/^(lon|x)/ then
1268
+ x_name = dim
1269
+ break
1270
+ end
1271
+ }
1272
+ end
1273
+ if @fig_type == VECTOR
1274
+ vars2 = Array.new
1275
+ @vars.keys.sort.reverse.each{|name|
1276
+ v = @vars[name]
1277
+ next if name==@vname
1278
+ if v.shape == @vars[@vname].shape
1279
+ if v.rank.times{|i| break if v.coord(i).val!=@vars[@vname].coord(i).val }
1280
+ vars2.push name
1281
+ end
1282
+ end
1283
+ }
1284
+ if vars2.length>0
1285
+ @var2_select.set(vars2)
1286
+ @var2_select.active
1287
+ set_var2
1288
+ else
1289
+ @var2_select.not_active
1290
+ clear_axisx({"axisx_hide"=>true})
1291
+ return
1292
+ end
1293
+ else
1294
+ clear_var2("var2_hide")
1295
+ end
1296
+ @axisx_select.set_text(x_name)
1297
+ @axisx_select.active
1298
+ set_axisx
1299
+ end
1300
+
1301
+ def set_func(func)
1302
+ @fig_type = FUNC
1303
+ @fig_dimension = 1
1304
+ @func_type = func
1305
+ @drawbutton.children[0].set_text(SFunc[func])
1306
+ clear_axisx
1307
+ @axisx_select.set_text(@vars[@vname].axnames[0])
1308
+ @axisx_select.active
1309
+ set_axisx
1310
+ end
1311
+
1312
+ def set_axisx
1313
+ if @vname.nil? then return end
1314
+ clear_axisx
1315
+ name = @axisx_select.get
1316
+ if name==_("cannot select") || name=="" then
1317
+ clear_axisy
1318
+ return
1319
+ end
1320
+ @x_name = name
1321
+ set_axis_x_title(@x_name)
1322
+ x = @vars[@vname].coord(@x_name)
1323
+ x.att_names.each{|key|
1324
+ if key=~/unit/ then set_axis_x_unit(x.get_att(key)) end
1325
+ }
1326
+ @x_frame.set_sensitive(true)
1327
+ if @fig_type == FUNC then
1328
+ clear_axisy({"axisy_hide"=>true})
1329
+ func_ok
1330
+ return
1331
+ elsif @fig_dimension == 1
1332
+ clear_axisy({"axisy_hide"=>true})
1333
+ draw_ok
1334
+ return
1335
+ else
1336
+ clear_axisy
1337
+ ay = @vars[@vname].axnames
1338
+ ay.delete(@x_name)
1339
+ @axisy_select.set(ay)
1340
+ y_name = ay[0]
1341
+ if @fig_type == MAP then
1342
+ ay.each{|dim|
1343
+ if dim.downcase=~/^(lat|y)/ then
1344
+ y_name = dim
1345
+ flag = false
1346
+ break
1347
+ end
1348
+ }
1349
+ end
1350
+ @axisy_select.set_text(y_name)
1351
+ @axisy_select.active
1352
+ set_axisy
1353
+ return
1354
+ end
1355
+ end
1356
+ def set_axisy
1357
+ if @vname.nil? then return end
1358
+ clear_axisy
1359
+ name = @axisy_select.get
1360
+ if name!=_("cannot select") && name!="" then
1361
+ @y_name = name
1362
+ set_axis_y_title(@y_name)
1363
+ y = @vars[@vname].coord(@y_name)
1364
+ y.att_names.each{|key|
1365
+ if key=~/unit/ then set_axis_y_unit(y.get_att(key)) end
1366
+ }
1367
+ @y_frame.set_sensitive(true)
1368
+ if @fig_dimension == 2
1369
+ clear_axisz({"axisz_hide"=>true})
1370
+ draw_ok
1371
+ return
1372
+ else
1373
+ clear_axisz
1374
+ az = @vars[@vname].axnames
1375
+ az.delete(@x_name)
1376
+ az.delete(@y_name)
1377
+ @axisz_select.set(az)
1378
+ z_name = az[0]
1379
+ @axisz_select.set_text(z_name)
1380
+ @axisz_select.active
1381
+ set_axisz
1382
+ end
1383
+ end
1384
+ end
1385
+ def set_axisz
1386
+ if @vname.nil? then return end
1387
+ clear_axisz
1388
+ name = @axisz_select.get
1389
+ if name!=_("cannot select") && name!="" then
1390
+ @z_name = name
1391
+ z = @vars[@vname].coord(@z_name)
1392
+ draw_ok
1393
+ end
1394
+ end
1395
+
1396
+ def func_ok
1397
+ clear_draw
1398
+ @drawbutton.set_sensitive(true)
1399
+ end
1400
+ def draw_ok
1401
+ clear_draw
1402
+ dims = @vars[@vname].axnames
1403
+ dims.delete(@x_name)
1404
+ dims.delete(@y_name)
1405
+ dims.delete(@z_name)
1406
+ if dims.length!=0 then
1407
+ @movie_combo.set_popdown_strings(dims)
1408
+ @movie_box.set_sensitive(true)
1409
+ dims.each{|dn| @dims[dn].active }
1410
+ end
1411
+ @drawbutton.set_sensitive(true)
1412
+ end
1413
+
1414
+ def clear_all(option={})
1415
+ clear_var(option)
1416
+ end
1417
+ def clear_var(option={})
1418
+ hide = option.delete("var_hide")
1419
+ if hide
1420
+ option["var2_hide"]=true
1421
+ option["axisx_hide"]=true
1422
+ option["axisy_hide"]=true
1423
+ option["axisz_hide"]=true
1424
+ end
1425
+ clear_dim
1426
+ clear_var2(option)
1427
+ clear_axisx(option)
1428
+ if @vname.nil? then return end
1429
+ @var_select.not_active if hide
1430
+ @vname = nil
1431
+ end
1432
+ def clear_var2(option={})
1433
+ hide = option.delete("var2_hide")
1434
+ if @vname2.nil? then return end
1435
+ @var2_select.not_active if hide
1436
+ @vname2 = nil
1437
+ end
1438
+ def clear_dim(option={})
1439
+ if !@dimtable.nil?
1440
+ @dimtable.hide
1441
+ @dims_window.remove(@dimtable)
1442
+ @dimtable.each{|w| @dimtable.remove(w)}
1443
+ end
1444
+ end
1445
+ def clear_axisx(option={})
1446
+ hide = option.delete("axisx_hide")
1447
+ if hide
1448
+ option["axisy_hide"]=true
1449
+ option["axisz_hide"]=true
1450
+ end
1451
+ clear_axisy(option)
1452
+ @axisx_select.not_active if hide
1453
+ @x_name = nil
1454
+ @x_frame.set_sensitive(false)
1455
+ set_axis_x_log(false)
1456
+ set_axis_x_title("")
1457
+ set_axis_x_unit("")
1458
+ set_axis_x_min(nil)
1459
+ set_axis_x_max(nil)
1460
+ end
1461
+ def clear_axisy(option={})
1462
+ hide = option.delete("axisy_hide")
1463
+ if hide
1464
+ option["axisz_hide"]=true
1465
+ end
1466
+ clear_draw(option)
1467
+ @axisy_select.not_active if hide
1468
+ @y_name = nil
1469
+ set_axis_y_log(false)
1470
+ set_axis_y_title("")
1471
+ set_axis_y_unit("")
1472
+ set_axis_y_min(nil)
1473
+ set_axis_y_max(nil)
1474
+ end
1475
+ def clear_axisz(option={})
1476
+ hide = option.delete("axisz_hide")
1477
+ clear_draw(option)
1478
+ @axisz_select.not_active if hide
1479
+ @z_name = nil
1480
+ end
1481
+ def clear_draw(option={})
1482
+ @drawbutton.set_sensitive(false)
1483
+ @dims.each_value{|dim| dim.not_active}
1484
+ @movie_box.set_sensitive(false)
1485
+ @movie_combo.entry.set_text("-")
1486
+ set_div([false,1,1])
1487
+ end
1488
+
1489
+ def exec_func
1490
+ gphys = @vars[@vname]
1491
+ ofuncs = gphys.funcs
1492
+ min = get_axis_x_min
1493
+ max = get_axis_x_max
1494
+ min = gphys.coord(@x_name)[0].val[0] if !min
1495
+ max = gphys.coord(@x_name)[-1].val[0] if !max
1496
+ index = Array.new(gphys.rank)
1497
+ ix = gphys.axnames.index(@x_name)
1498
+ gphys.rank.times{|i|
1499
+ if i==ix then index[i] = min..max else index[i] = true end
1500
+ }
1501
+ func = [@func_type,ix,index]
1502
+ it = 0
1503
+ for var in @vars
1504
+ funcs = var[1].funcs
1505
+ if funcs.length==1 || funcs[0..-2]!=ofuncs || funcs[-1][0..1]!=func[0..1] then
1506
+ next
1507
+ elsif funcs[-1]==func
1508
+ it = false
1509
+ break
1510
+ elsif
1511
+ it += 1
1512
+ end
1513
+ end
1514
+ if it then
1515
+ if it>0 then add = "-#{it}" else add = "" end
1516
+ vn2 = "#{@vname} (#{@x_name} #{@func_type}#{add})"
1517
+ gphys = gphys.cut(*index)
1518
+ @vars[vn2] = gphys.send(@func_type,ix)
1519
+ @vars[vn2].funcs=(ofuncs.push([@func_type,ix,index]))
1520
+ @vars[vn2].name = vn2
1521
+ @var_select.not_active
1522
+ @var_select.set(@vars.keys.sort.reverse)
1523
+ @var_select.active
1524
+ end
1525
+ end
1526
+
1527
+ def make_draw_data
1528
+ draw_data = Draw_data.new
1529
+
1530
+ gphys = @vars[@vname]
1531
+ dims = gphys.axnames
1532
+ index = Array.new(dims.length)
1533
+ dims.each_with_index{|dim,i|
1534
+ if dim==@x_name||dim==@y_name||dim==@z_name then
1535
+ index[i] = 0..-1
1536
+ else
1537
+ index[i] = @dims[dim].index
1538
+ end
1539
+ }
1540
+ gphys = gphys[*index]
1541
+ if @fig_type==VECTOR
1542
+ gphys2 = @vars[@vname2]
1543
+ gphys2 = gphys2[*index]
1544
+ else
1545
+ gphys2 = nil
1546
+ end
1547
+
1548
+ draw_data.type = @fig_type
1549
+ dims = gphys.axnames
1550
+ if @fig_dimension == 2
1551
+ if dims.index(@x_name)>dims.index(@y_name) then
1552
+ draw_data.transpose = true
1553
+ else
1554
+ draw_data.transpose = false
1555
+ end
1556
+ end
1557
+ if @fig_type==MAP
1558
+ gphys = gphys.cyclic_ext(@x_name,360)
1559
+ end
1560
+
1561
+ draw_data.axis_x.title = get_axis_x_title
1562
+ unit = get_axis_x_unit
1563
+ if unit != ""
1564
+ draw_data.axis_x.unit = unit
1565
+ if unit != gphys.coord(0).units.to_s
1566
+ coord = gphys.coord(0)
1567
+ gphys.axis(0).set_pos( coord.units.convert2(coord,Units.new(unit)) )
1568
+ end
1569
+ end
1570
+ draw_data.axis_y.title = get_axis_y_title
1571
+ unit = get_axis_y_unit
1572
+ if unit != ""
1573
+ draw_data.axis_y.unit = unit
1574
+ if @fig_type==CONTOUR || @fig_type==VECTOR
1575
+ if unit != gphys.coord(1).units.to_s
1576
+ coord = gphys.coord(1)
1577
+ gphys.axis(1).set_pos( coord.units.convert2(coord,Units.new(unit)) )
1578
+ end
1579
+ end
1580
+ end
1581
+
1582
+ x = gphys.coord(@x_name).val
1583
+ min = get_axis_x_min
1584
+ max = get_axis_x_max
1585
+ unless min
1586
+ case gphys.axis(@x_name).draw_positive
1587
+ when true
1588
+ min = min(x[0],x[-1])
1589
+ when false
1590
+ min = max(x[0],x[-1])
1591
+ when nil
1592
+ min = x[0]
1593
+ end
1594
+ end
1595
+ unless max
1596
+ case gphys.axis(@x_name).draw_positive
1597
+ when true
1598
+ max = max(x[0],x[-1])
1599
+ when false
1600
+ max = min(x[0],x[-1])
1601
+ when nil
1602
+ max = x[-1]
1603
+ end
1604
+ end
1605
+ draw_data.axis_x.min = min
1606
+ draw_data.axis_x.max = max
1607
+
1608
+ min = get_axis_y_min
1609
+ max = get_axis_y_max
1610
+ if @fig_dimension == 1
1611
+ min = gphys.data.min if !min
1612
+ min = min.val if !(Numeric===min)
1613
+ max = gphys.data.max if !max
1614
+ max = max.val if !(Numeric===max)
1615
+ elsif @fig_type==MAP
1616
+ lat = @pole_lat.text.to_f
1617
+ y = gphys.coord(@y_name).val
1618
+ if (!min)&&(!max)
1619
+ min,max = [y[0],y[-1]]
1620
+ if min*max < 0
1621
+ if min.abs<max.abs
1622
+ min = 0
1623
+ lat = max>0 ? 90 : -90 unless lat
1624
+ else
1625
+ max = 0
1626
+ lat = min>0 ? 90 : -90 unless lat
1627
+ end
1628
+ else
1629
+ lat = max > 0 ? 90 : -90 unless lat
1630
+ end
1631
+ elsif (!min)&&max
1632
+ min = y[0]
1633
+ lat = max>0 ? 90 : -90 unless lat
1634
+ elsif min&&(!max)
1635
+ max = y[-1]
1636
+ lat = min>0 ? 90 : -90 unless lat
1637
+ else
1638
+ if !lat
1639
+ if max.abs>min.abs
1640
+ lat = max>0 ? 90 : -90
1641
+ else
1642
+ lat = min>0 ? 90 : -90
1643
+ end
1644
+ end
1645
+ end
1646
+ lon = @pole_lon.text.to_f
1647
+ rot = @pole_rot.text.to_f
1648
+ lon = 0 unless lon
1649
+ rot = 0 unless rot
1650
+ draw_data.map_pole = [lon,lat,rot]
1651
+ elsif
1652
+ y = gphys.coord(@y_name).val
1653
+ unless min
1654
+ case gphys.axis(@y_name).draw_positive
1655
+ when true
1656
+ min = min(y[0],y[-1])
1657
+ when false
1658
+ min = max(y[0],y[-1])
1659
+ when nil
1660
+ min = y[0]
1661
+ end
1662
+ end
1663
+ unless max
1664
+ case gphys.axis(@y_name).draw_positive
1665
+ when true
1666
+ max = max(y[0],y[-1])
1667
+ when false
1668
+ max = min(y[0],y[-1])
1669
+ when nil
1670
+ max = y[-1]
1671
+ end
1672
+ end
1673
+ end
1674
+ draw_data.axis_y.min = min
1675
+ draw_data.axis_y.max = max
1676
+
1677
+ if @fig_dimension==3
1678
+ min = nil
1679
+ max = nil
1680
+ z = gphys.coord(@z_name).val
1681
+ unless min
1682
+ case gphys.axis(@z_name).draw_positive
1683
+ when true
1684
+ min = min(z[0],z[-1])
1685
+ when false
1686
+ min = max(z[0],z[-1])
1687
+ when nil
1688
+ min = z[0]
1689
+ end
1690
+ end
1691
+ unless max
1692
+ case gphys.axis(@z_name).draw_positive
1693
+ when true
1694
+ max = max(z[0],z[-1])
1695
+ when false
1696
+ max = min(z[0],z[-1])
1697
+ when nil
1698
+ max = z[-1]
1699
+ end
1700
+ end
1701
+ draw_data.axis_z.min = min
1702
+ draw_data.axis_z.max = max
1703
+ end
1704
+
1705
+ log = get_axis_x_log
1706
+ if (min(draw_data.axis_x.min,draw_data.axis_x.max)<=0) && log then
1707
+ dialog = Gtk::Dialog.new.set_title(_("Error Message"))
1708
+ dialog.set_modal(true)
1709
+ dialog.vbox.pack_start(Gtk::Label.new(_("X-Axis")+" "+_("has negative value for log scale")))
1710
+ ok_button=Gtk::Button.new(_("OK"))
1711
+ ok_button.signal_connect("clicked"){dialog.destroy}
1712
+ dialog.action_area.pack_start(ok_button)
1713
+ dialog.show_all
1714
+ return
1715
+ end
1716
+ draw_data.axis_x.log = log
1717
+
1718
+ log = get_axis_y_log
1719
+ if (min(draw_data.axis_y.min,draw_data.axis_y.max)<=0) and log then
1720
+ dialog = Gtk::Dialog.new.set_title(_("Error Message"))
1721
+ dialog.set_modal(true)
1722
+ dialog.vbox.pack_start(Gtk::Label.new(_("Y-Axis")+" "+_("has negative value for log scale")))
1723
+ ok_button=Gtk::Button.new(_("OK"))
1724
+ ok_button.signal_connect("clicked"){dialog.destroy}
1725
+ dialog.action_area.pack_start(ok_button)
1726
+ dialog.show_all
1727
+ return
1728
+ end
1729
+ draw_data.axis_y.log = log
1730
+
1731
+ if @fig_dimension == 1
1732
+ x = draw_data.axis_x
1733
+ xmin = x.min
1734
+ xmax = x.max
1735
+ x = gphys.coord(0).val
1736
+ if (x[-1]-x[0])/(xmax-xmin) < 0
1737
+ xmin,xmax = [xmax,xmin]
1738
+ end
1739
+ gphys = gphys.cut(xmin..xmax)
1740
+ elsif @fig_dimension == 2
1741
+ x = draw_data.axis_x
1742
+ y = draw_data.axis_y
1743
+ if draw_data.transpose
1744
+ x,y = [y,x]
1745
+ end
1746
+ xmin = x.min
1747
+ xmax = x.max
1748
+ ymin = y.min
1749
+ ymax = y.max
1750
+ x = gphys.coord(0).val
1751
+ y = gphys.coord(1).val
1752
+ if (x[-1]-x[0])/(xmax-xmin) < 0
1753
+ xmin,xmax = [xmax,xmin]
1754
+ end
1755
+ if (y[-1]-y[0])/(ymax-ymin) < 0
1756
+ ymin,ymax = [ymax,ymin]
1757
+ end
1758
+ gphys = gphys.cut(xmin..xmax, ymin..ymax)
1759
+ if @fig_type==VECTOR
1760
+ gphys2 = gphys2.cut(xmin..xmax, ymin..ymax)
1761
+ end
1762
+ elsif @fig_dimension == 3
1763
+ x = draw_data.axis_x
1764
+ y = draw_data.axis_y
1765
+ z = draw_data.axis_z
1766
+ xmin = x.min
1767
+ xmax = x.max
1768
+ ymin = y.min
1769
+ ymax = y.max
1770
+ zmin = z.min
1771
+ zmax = z.max
1772
+ x = gphys.coord(0).val
1773
+ y = gphys.coord(1).val
1774
+ z = gphys.coord(2).val
1775
+ if (x[-1]-x[0])/(xmax-xmin) < 0
1776
+ xmin,xmax = [xmax,xmin]
1777
+ end
1778
+ if (y[-1]-y[0])/(ymax-ymin) < 0
1779
+ ymin,ymax = [ymax,ymin]
1780
+ end
1781
+ if (z[-1]-z[0])/(zmax-zmin) < 0
1782
+ zmin,zmax = [zmax,zmin]
1783
+ end
1784
+ gphys = gphys.cut(xmin..xmax, ymin..ymax, zmin..zmax)
1785
+ end
1786
+
1787
+
1788
+
1789
+
1790
+ # draw_data.missing_value = get_missing
1791
+ draw_data.title = get_title
1792
+ if @fig_type==CONTOUR || @fig_type==MAP
1793
+ if @cont_draw_button.active?
1794
+ draw_data.cont = true
1795
+ if @cont_level
1796
+ draw_data.cont_i = [@cont_min_entry.text.to_f,@cont_interval_entry.text.to_f]
1797
+ else
1798
+ draw_data.cont_i = nil
1799
+ end
1800
+ else
1801
+ draw_data.cont = nil
1802
+ end
1803
+ if @tone_draw_button.active?
1804
+ draw_data.tone = @tone_method
1805
+ if @tone_level
1806
+ draw_data.tone_i = [@tone_min_entry.text.to_f,@tone_interval_entry.text.to_f]
1807
+ else
1808
+ draw_data.tone_i = nil
1809
+ end
1810
+ else
1811
+ draw_data.tone = nil
1812
+ end
1813
+ end
1814
+
1815
+ if @fig_type==MAP then
1816
+ draw_data.map_type = @map_type.index(@map_combo.entry.text)+30
1817
+ draw_data.map_draw = @map_check.active?
1818
+ else
1819
+ draw_data.map_type = nil
1820
+ end
1821
+
1822
+ if @fig_type==VECTOR
1823
+ if @vector_thinout
1824
+ nx = @vector_thinout_x_entry.text.to_i
1825
+ ny = @vector_thinout_y_entry.text.to_i
1826
+ else
1827
+ nx = 0
1828
+ ny = 0
1829
+ end
1830
+ nx = 15 if nx<2
1831
+ ny = 15 if ny<2
1832
+ lenx = gphys.axis(0).length
1833
+ if lenx>nx
1834
+ stepx = (lenx/nx).floor
1835
+ nx = (lenx/stepx).floor
1836
+ ix = NArray.sint(nx).indgen(stepx/2,stepx)
1837
+ else
1838
+ nx = lenx
1839
+ ix = true
1840
+ end
1841
+ leny = gphys.axis(1).length
1842
+ if leny>ny
1843
+ stepy = (leny/ny).floor
1844
+ ny = (leny/stepy).floor
1845
+ iy = NArray.sint(ny).indgen(stepy/2,stepy)
1846
+ else
1847
+ ny = leny
1848
+ iy = true
1849
+ end
1850
+ ix,iy = [iy,ix] if draw_data.transpose
1851
+ @vector_thinout_x_entry.set_text(nx.to_s)
1852
+ @vector_thinout_y_entry.set_text(ny.to_s)
1853
+
1854
+ gphys = gphys[ix,iy]
1855
+ gphys2 = gphys2[ix,iy]
1856
+
1857
+ if @vector_factor
1858
+ draw_data.vector = [@vector_scale_x_entry.text.to_f,@vector_scale_y_entry.text.to_f]
1859
+ else
1860
+ draw_data.vector = nil
1861
+ end
1862
+ end
1863
+
1864
+ if @fig_type == SURFACE
1865
+ draw_data.surface = @surface_adjust.value
1866
+ end
1867
+
1868
+
1869
+ draw_data.gphys = gphys
1870
+ draw_data.gphys2 = gphys2
1871
+
1872
+ return draw_data
1873
+ end
1874
+
1875
+ def add_window
1876
+ if defined?(@nwindows)
1877
+ @nwindows += 1
1878
+ type = "/"+_("Windows")+"(W)/1"
1879
+ else
1880
+ @dwindows = Array.new
1881
+ @nwindows = 1
1882
+ type = Gtk::ItemFactory::RADIO_ITEM
1883
+ end
1884
+ draw = Draw.new(@nwindows)
1885
+ @dwindows.push draw
1886
+ windowitem = [["/"+_("Windows")+"(_W)", Gtk::ItemFactory::BRANCH]]
1887
+ path = "/"+_("Windows")+"(W)/#{@nwindows}"
1888
+ @main_itemfact.create_item(path, type, nil, nil, @nwindows){|n, wid|
1889
+ if wid.active?
1890
+ @draw = @dwindows[n-1]
1891
+ @draw.show
1892
+ end
1893
+ }
1894
+ @main_itemfact.get_item(path).active = true
1895
+ draw
1896
+ end
1897
+
1898
+ def draw_x
1899
+ @draw_data = make_draw_data
1900
+ @save_image.set_sensitive(true)
1901
+ @save_code.set_sensitive(true)
1902
+ @save_netcdf.set_sensitive(true)
1903
+ @draw = add_window if @draw.nil?|@crewindbutton.active?
1904
+ @draw.draw_x(@draw_data)
1905
+ end
1906
+
1907
+
1908
+ def draw_next
1909
+ dim = @movie_combo.entry.text
1910
+ return if dim=="-"
1911
+ @dims[dim].next
1912
+ draw_x
1913
+ end
1914
+
1915
+ # start
1916
+ def start
1917
+ Gtk.main
1918
+ end
1919
+
1920
+ # quit
1921
+ def file_close
1922
+ clear_var
1923
+ @vars.clear
1924
+ @dims.clear
1925
+ end
1926
+ def finish
1927
+ file_close
1928
+ Gtk.main_quit
1929
+ end
1930
+
1931
+ end
1932
+
1933
+
1934
+
1935
+ $main = GAVE.new(device)
1936
+
1937
+ $main.autodraw = argv.delete("--draw") || argv.delete("-d")
1938
+ $main.autodraw = argv.delete("-autodraw") || $main.autodraw # Obsolute
1939
+
1940
+ $main.showwindows if argv.delete("--show_windows") || argv.delete("-s")
1941
+
1942
+ badoptions = ""
1943
+ argv.each{|str|
1944
+ if str[0..0] == "-"
1945
+ badoptions += str+","
1946
+ end
1947
+ }
1948
+ raise "No such options: #{badoptions.chop!}" if badoptions != ""
1949
+
1950
+ begin
1951
+ $main.file_open(argv) if argv.length!=0
1952
+ argv=[]
1953
+
1954
+ $main.start
1955
+ rescue
1956
+ dialog = Gtk::Dialog.new.set_title(_("Error Message"))
1957
+ dialog.set_modal(true)
1958
+ p $!.exception.message
1959
+ str = "\n"+$!.message+"\n"
1960
+ str += $!.backtrace.join("\n")+"\n\n"
1961
+ label = Gtk::Label.new(str)
1962
+ label.selectable=true
1963
+ label.justify=Gtk::Justification::CENTER
1964
+ dialog.vbox.pack_start(label)
1965
+ str = _("If this error have come from bug of this program, please report to")
1966
+ str += "\n<seiya@kugi.kyoto-u.ac.jp>\n"
1967
+ label = Gtk::Label.new(str)
1968
+ label.selectable=true
1969
+ label.justify=Gtk::Justification::CENTER
1970
+ label.wrap=true
1971
+ dialog.vbox.pack_start(label)
1972
+ ok_button=Gtk::Button.new(_("OK"))
1973
+ ok_button.signal_connect("clicked"){dialog.destroy}
1974
+ dialog.action_area.pack_start(ok_button)
1975
+ dialog.signal_connect("destroy"){Gtk.main_quit}
1976
+ dialog.show_all
1977
+ Gtk.main
1978
+ # $main.clear_var
1979
+ # $main.clear_var({"var_hide"=>true})
1980
+ # $main.set_var
1981
+ argv = []
1982
+ retry
1983
+ end