-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatv.pro
10332 lines (8001 loc) · 315 KB
/
atv.pro
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;+
;
; NAME:
; ATV
;
; PURPOSE:
; Interactive display of 2-D images.
;
; CATEGORY:
; Image display.
;
; CALLING SEQUENCE:
; atv [,array_name OR fits_file] [,min = min_value] [,max=max_value]
; [,/linear] [,/log] [,/histeq] [,/asinh] [,/block]
; [,/align] [,/stretch] [,header = header]
;
; REQUIRED INPUTS:
; None. If atv is run with no inputs, the window widgets
; are realized and images can subsequently be passed to atv
; from the command line or from the pull-down file menu.
;
; OPTIONAL INPUTS:
; array_name: a 2-D array or 3-D data cube to display
; OR
; fits_file: a fits file name, enclosed in single quotes
;
; KEYWORDS:
; min: minimum data value to be mapped to the color table
; max: maximum data value to be mapped to the color table
; linear: use linear stretch
; log: use log stretch
; histeq: use histogram equalization
; asinh: use asinh stretch
; block: block IDL command line until ATV terminates
; align: align image with previously displayed image
; stretch: keep same min and max as previous image
; header: FITS image header (string array) for use with data array
;
; OUTPUTS:
; None.
;
; COMMON BLOCKS:
; atv_state: contains variables describing the display state
; atv_images: contains the internal copies of the display image
; atv_color: contains colormap vectors
; atv_pdata: contains plot and text annotation information
; atv_spectrum: contains information about extracted spectrum
;
; RESTRICTIONS:
; Requires IDL version 6.0 or greater.
; Requires Craig Markwardt's cmps_form.pro routine.
; Requires the GSFC IDL astronomy user's library routines.
; Some features may not work under all operating systems.
;
; EXAMPLE:
; To start atv running, just enter the command 'atv' at the idl
; prompt, either with or without an array name or fits file name
; as an input. Only one atv window will be created at a time,
; so if one already exists and another image is passed to atv
; from the idl command line, the new image will be displayed in
; the pre-existing atv window.
;
; MODIFICATION HISTORY:
; Written/maintained by Aaron J. Barth, with contributions by
; numerous others. First released 17 December 1998.
;
; This version is 2.3, last modified 18 October 2010.
;
; For the most current version, revision history, instructions,
; list of known bugs, and further information, go to:
; http://www.physics.uci.edu/~barth/atv
;-
;----------------------------------------------------------------------
; atv startup and initialization routines
;----------------------------------------------------------------------
pro atv_initcommon
; Routine to initialize the atv common blocks. Use common blocks so
; that other IDL programs can access the atv internal data easily.
common atv_state, state
common atv_color, r_vector, g_vector, b_vector, user_r, user_g, user_b
common atv_pdata, nplot, maxplot, plot_ptr
common atv_images, $
main_image, $
main_image_cube, $
display_image, $
scaled_image, $
blink_image1, $
blink_image2, $
blink_image3, $
unblink_image, $
pan_image
state = { $
version: '2.3', $ ; version # of this release
head_ptr: ptr_new(), $ ; pointer to image header
astr_ptr: ptr_new(), $ ; pointer to astrometry info structure
firstimage: 1, $ ; is this the first image?
block: 0, $ ; are we in blocking mode?
wcstype: 'none', $ ; coord info type (none/angle/lambda)
equinox: 'J2000', $ ; equinox of coord system
display_coord_sys: 'RA--', $ ; coord system displayed
display_equinox: 'J2000', $ ; equinox of displayed coords
display_base60: 1B, $ ; Display RA,dec in base 60?
cunit: '', $ ; wavelength units
imagename: '', $ ; image file name
title_extras: '', $ ; extras for image title
bitdepth: 8, $ ; 8 or 24 bit color mode?
screen_xsize: 1000, $ ; horizontal size of screen
screen_ysize: 1000, $ ; vertical size of screen
base_id: 0L, $ ; id of top-level base
base_min_size: [512L, 300L], $ ; min size for top-level base
draw_base_id: 0L, $ ; id of base holding draw window
draw_window_id: 0L, $ ; window id of draw window
draw_widget_id: 0L, $ ; widget id of draw widget
mousemode: "color", $ ; color, blink, zoom, or imexam
mode_droplist_id: 0L, $ ; id of mode droplist widget
track_window_id: 0L, $ ; widget id of tracking window
pan_widget_id: 0L, $ ; widget id of pan window
pan_window_id: 0L, $ ; window id of pan window
active_window_id: 0L, $ ; user's active window outside atv
active_window_pmulti: lonarr(5), $ ; user's active window p.multi
info_base_id: 0L, $ ; id of base holding info bars
location_bar_id: 0L, $ ; id of (x,y,value) label
wcs_bar_id: 0L, $ ; id of WCS label widget
min_text_id: 0L, $ ; id of min= widget
max_text_id: 0L, $ ; id of max= widget
menu_ids: lonarr(35), $ ; list of top menu items
colorbar_base_id: 0L, $ ; id of colorbar base widget
colorbar_widget_id: 0L, $ ; widget id of colorbar draw widget
colorbar_window_id: 0L, $ ; window id of colorbar
colorbar_height: 6L, $ ; height of colorbar in pixels
ncolors: 0B, $ ; image colors (!d.table_size - 9)
box_color: 2, $ ; color for pan box and zoom x
brightness: 0.5, $ ; initial brightness setting
contrast: 0.5, $ ; initial contrast setting
image_min: 0.0, $ ; min(main_image)
image_max: 0.0, $ ; max(main_image)
min_value: 0.0, $ ; min data value mapped to colors
max_value: 0.0, $ ; max data value mapped to colors
skymode: 0.0, $ ; sky mode value
skysig: 0.0, $ ; sky sigma value
draw_window_size: [512L, 512L], $ ; size of main draw window
track_window_size: 121L, $ ; size of tracking window
pan_window_size: 121L, $ ; size of pan window
pan_scale: 0.0, $ ; magnification of pan image
image_size: [0L,0L], $ ; size of main_image
invert_colormap: 0L, $ ; 0=normal, 1=inverted
coord: [0L, 0L], $ ; cursor position in image coords
scaling: 3, $ ; 0=lin,1=log,2=histeq,3=asinh
asinh_beta: 0.1, $ ; asinh nonlinearity parameter
offset: [0L, 0L], $ ; offset to viewport coords
base_pad: [0L, 0L], $ ; padding around draw base
zoom_level: 0L, $ ; integer zoom level, 0=normal
zoom_factor: 1.0, $ ; magnification factor = 2^zoom_level
centerpix: [0L, 0L], $ ; pixel at center of viewport
cstretch: 0B, $ ; flag = 1 while stretching colors
pan_offset: [0L, 0L], $ ; image offset in pan window
cube: 0, $ ; is main image a 3d cube?
osiriscube: 0, $ ; is cube an osiris-style (l,y,x) cube?
slice: 0, $ ; which slice of cube to display
slicebase_id: 0, $ ; widget id of slice base
slicer_id: 0, $ ; widget id of slice slider
sliceselect_id: 0, $ ; widget id of slice selector
slicecombine_id: 0, $ ; widget id of slice combine box
slicecombine: 1, $ ; # slices to combine
slicecombine_method: 1, $ ; 0 for average, 1 for median
nslices: 0, $ ; number of slices
frame: 1L, $ ; put frame around ps output?
framethick: 6, $ ; thickness of frame
plot_coord: [0L, 0L], $ ; cursor position for a plot
vector_coord1: [0L, 0L], $ ; 1st cursor position in vector plot
vector_coord2: [0L, 0L], $ ; 2nd cursor position in vector plot
vector_pixmap_id: 0L, $ ; id for vector pixmap
vectorpress: 0L, $ ; are we plotting a vector?
vectorstart: [0L,0L], $ ; device x,y of vector start
plot_type:'', $ ; plot type for plot window
lineplot_widget_id: 0L, $ ; id of lineplot widget
lineplot_window_id: 0L, $ ; id of lineplot window
lineplot_base_id: 0L, $ ; id of lineplot top-level base
lineplot_size: [600L, 500L], $ ; size of lineplot window
lineplot_min_size: [100L, 0L], $ ; min size of lineplot window
lineplot_pad: [0L, 0L], $ ; padding around lineplot window
lineplot_xmin_id: 0L, $ ; id of xmin for lineplot windows
lineplot_xmax_id: 0L, $ ; id of xmax for lineplot windows
lineplot_ymin_id: 0L, $ ; id of ymin for lineplot windows
lineplot_ymax_id: 0L, $ ; id of ymax for lineplot windows
lineplot_charsize_id: 0L, $ ; id of charsize for lineplots
lineplot_xmin: 0.0, $ ; xmin for lineplot windows
lineplot_xmax: 0.0, $ ; xmax for lineplot windows
lineplot_ymin: 0.0, $ ; ymin for lineplot windows
lineplot_ymax: 0.0, $ ; ymax for lineplot windows
lineplot_xmin_orig: 0.0, $ ; original xmin saved from histplot
lineplot_xmax_orig: 0.0, $ ; original xmax saved from histplot
holdrange_base_id: 0L, $ ; base id for 'Hold Range' button
holdrange_button_id: 0L, $ ; button id for 'Hold Range' button
holdrange_value: 0, $ ; 0=HoldRange Off, 1=HoldRange On
histbutton_base_id: 0L, $ ; id of histogram button base
histplot_binsize_id: 0L, $ ; id of binsize for histogram plot
x1_pix_id: 0L, $ ; id of x1 pixel for histogram plot
x2_pix_id: 0L, $ ; id of x2 pixel for histogram plot
y1_pix_id: 0L, $ ; id of y1 pixel for histogram plot
y2_pix_id: 0L, $ ; id of y2 pixel for histogram plot
plotcharsize: 1.0, $ ; charsize for plot window
binsize: 0.0, $ ; binsize for histogram plots
regionform_id: 0L, $ ; id of region form widget
reg_ids_ptr: ptr_new(), $ ; ids for region form widget
cursorpos: lonarr(2), $ ; cursor x,y for photometry & stats
centerpos: fltarr(2), $ ; centered x,y for photometry
cursorpos_id: 0L, $ ; id of cursorpos widget
centerpos_id: 0L, $ ; id of centerpos widget
centerbox_id: 0L, $ ; id of centeringboxsize widget
radius_id: 0L, $ ; id of radius widget
innersky_id: 0L, $ ; id of inner sky widget
outersky_id: 0L, $ ; id of outer sky widget
magunits: 0, $ ; 0=counts, 1=magnitudes
skytype: 0, $ ; 0=idlphot,1=median,2=no sky subtract
exptime: 1.0, $ ; exposure time for photometry
photzpt: 25.0, $ ; magnitude zeropoint
photprint: 0, $ ; print phot results to file?
photprint_id: 0L, $ ; id of phot print button
photfile: 0L, $ ; file unit of phot file
photfilename: 'atvphot.dat', $ ; filename of phot file
skyresult_id: 0L, $ ; id of sky widget
photresult_id: 0L, $ ; id of photometry result widget
photerror_id: 0L, $, ; id of photometry error widget
fwhm_id: 0L, $ ; id of fwhm widget
radplot_widget_id: 0L, $ ; id of radial profile widget
radplot_window_id: 0L, $ ; id of radial profile window
photzoom_window_id: 0L, $ ; id of photometry zoom window
photzoom_size: 190L, $ ; size in pixels of photzoom window
showradplot_id: 0L, $ ; id of button to show/hide radplot
photwarning_id: 0L, $ ; id of photometry warning widget
photwarning: ' ', $ ; photometry warning text
photerrors: 0, $ ; calculate photometric errors?
ccdgain: 1.0, $ ; CCD gain
ccdrn: 0.0, $ ; read noise
centerboxsize: 9L, $ ; centering box size
aprad: 5.0, $ ; aperture photometry radius
innersky: 10.0, $ ; inner sky radius
outersky: 20.0, $ ; outer sky radius
headinfo_base_id: 0L, $ ; headinfo base widget id
pixtable_base_id: 0L, $ ; pixel table base widget id
pixtable_tbl_id: 0L, $ ; pixel table widget_table id
stats_base_id: 0L, $ ; base widget for image stats
statboxsize: 11L, $ ; box size for computing statistics
statbox_id: 0L, $ ; widget id for stat box size
stat_npix_id: 0L, $ ; widget id for # pixels in stats box
statxcenter_id: 0L, $ ; widget id for stat box x center
statycenter_id: 0L, $ ; widget id for stat box y center
statbox_min_id: 0L, $ ; widget id for stat min box
statbox_max_id: 0L, $ ; widget id for stat max box
statbox_mean_id: 0L, $ ; widget id for stat mean box
statbox_median_id: 0L, $ ; widget id for stat median box
statbox_stdev_id: 0L, $ ; widget id for stat stdev box
statzoom_size: 300, $ ; size of statzoom window
statzoom_widget_id: 0L, $ ; widget id for stat zoom window
statzoom_window_id: 0L, $ ; window id for stat zoom window
showstatzoom_id: 0L, $ ; widget id for show/hide button
pan_pixmap: 0L, $ ; window id of pan pixmap
current_dir: '', $ ; current readfits directory
graphicsdevice: '', $ ; screen device
ispsformon: 0, $ ; is cmps_form running?
newrefresh: 0, $ ; refresh since last blink?
blinks: 0B, $ ; remembers which images are blinked
x_tracestep: 21L, $ ; extraction tracing step
x_tracestep_id: 0, $ ; widget id for tracestep
x_traceheight: 7L, $ ; extraction tracing height
x_traceheight_id: 0, $ ; widget id for trace height
x_xregion: [0L, 0L], $ ; extraction x region
x_xstart_id: 0, $ ; widget id for extraction x start
x_xend_id: 0, $ ; widget id for extraction x end
x_traceorder: 3, $ ; extraction trace fit order
x_traceorder_id: 0, $ ; widget id for extraction trace order
x_xlower: -5, $ ; extraction lower bound
x_xlower_id: 0, $ ; widget id for extraction lower
x_xupper: 5, $ ; extraction upper bound
x_xupper_id: 0, $ ; widget id for extraction upper
x_backsub: 1, $ ; background subtraction on?
x_back1: -25, $ ; extraction lower background 1
x_back2: -15, $ ; extraction lower background 2
x_back3: 15, $ ; extraction upper background 1
x_back4: 25, $ ; extraction upper background 2
x_back1_id: 0, $ ; widget id for lower background 1
x_back2_id: 0, $ ; widget id for lower background 2
x_back3_id: 0, $ ; widget id for upper background 1
x_back4_id: 0, $ ; widget id for upper background 2
x_fixed: 0, $ ; hold extraction parameters fixed?
activator: 0, $ ; is "activator" mode on?
delimiter: '/', $ ; filesystem level delimiter
default_align: 1, $ ; align next image by default?
default_autoscale: 1, $ ; autoscale images by default?
default_stretch: 0 $ ; use previous minmax for new image?
}
nplot = 0
maxplot = 5000
plot_ptr = ptrarr(maxplot+1) ; The 0th element isn't used.
blink_image1 = 0
blink_image2 = 0
blink_image3 = 0
end
;---------------------------------------------------------------------
pro atv_startup
; This routine initializes the atv internal variables, and creates and
; realizes the window widgets. It is only called by the atv main
; program level, when there is no previously existing atv window.
common atv_state
common atv_color
; save the user color table and pmulti first
tvlct, user_r, user_g, user_b, /get
; Read in a color table to initialize !d.table_size
; As a bare minimum, we need the 8 basic colors used by ATV_ICOLOR(),
; plus 2 more for a color map.
;loadct, 0, /silent
if (!d.table_size LT 12) then begin
message, 'Too few colors available for color table'
tvlct, user_r, user_g, user_b
atv_shutdown
endif
; Initialize the common blocks
atv_initcommon
state.active_window_pmulti = !p.multi
!p.multi = 0
osfamily = strupcase(!version.os_family)
case osfamily of
'UNIX': state.delimiter = '/'
'WINDOWS': state.delimiter = '\'
else:
endcase
state.ncolors = !d.table_size - 9
; If compiling atv to make a sav file for the atv virtual machine,
; always do it for 24-bit color with retain & decomposed set.
; Uncomment this block to compile atv for idl vm. For some reason,
; idl vm gets !d.n_colors=256 even on a 24-bit display, so we need
; this to work around it to force 24-bit mode.
;device, true_color=24
;device, decomposed=0
;device, retain=2
;state.bitdepth=24
; For normal idl operation, use the following. Comment this block out
; if compiling atv for idl vm.
if (!d.n_colors LE 256) then begin
state.bitdepth = 8
endif else begin
state.bitdepth = 24
device, decomposed=0
endelse
state.graphicsdevice = !d.name
state.screen_xsize = (get_screen_size())[0]
state.screen_ysize = (get_screen_size())[1]
; Get the current window id and color table
atv_getwindow
; Define the widgets. For the widgets that need to be modified later
; on, save their widget ids in state variables
base = widget_base(title = 'atv', $
/column, /base_align_right, $
app_mbar = top_menu, $
uvalue = 'atv_base', $
/tlb_size_events)
state.base_id = base
tmp_struct = {cw_pdmenu_s, flags:0, name:''}
top_menu_desc = [ $
{cw_pdmenu_s, 1, 'File'}, $ ; file menu
{cw_pdmenu_s, 0, 'ReadFits'}, $
{cw_pdmenu_s, 0, 'WriteFits'}, $
{cw_pdmenu_s, 0, 'WritePS'}, $
{cw_pdmenu_s, 1, 'WriteImage'}, $
{cw_pdmenu_s, 0, 'PNG'}, $
{cw_pdmenu_s, 0, 'JPEG'}, $
{cw_pdmenu_s, 2, 'TIFF'}, $
{cw_pdmenu_s, 0, '--------------'}, $
{cw_pdmenu_s, 1, 'GetImage'}, $
{cw_pdmenu_s, 2, ' DSS'}, $
; {cw_pdmenu_s, 2, ' FIRST'}, $
{cw_pdmenu_s, 0, '--------------'}, $
{cw_pdmenu_s, 2, 'Quit'}, $
{cw_pdmenu_s, 1, 'ColorMap'}, $ ; color menu
{cw_pdmenu_s, 0, 'Grayscale'}, $
{cw_pdmenu_s, 0, 'Blue-White'}, $
{cw_pdmenu_s, 0, 'Red-Orange'}, $
{cw_pdmenu_s, 0, 'Green-White'}, $
{cw_pdmenu_s, 0, 'Rainbow'}, $
{cw_pdmenu_s, 0, 'BGRY'}, $
{cw_pdmenu_s, 0, 'Stern Special'}, $
{cw_pdmenu_s, 0, 'ATV Special'}, $
{cw_pdmenu_s, 0, 'Velocity1'}, $
{cw_pdmenu_s, 2, 'Velocity2'}, $
{cw_pdmenu_s, 1, 'Scaling'}, $ ; scaling menu
{cw_pdmenu_s, 0, 'Asinh'}, $
{cw_pdmenu_s, 0, 'Log'}, $
{cw_pdmenu_s, 0, 'Linear'}, $
{cw_pdmenu_s, 0, 'HistEq'}, $
{cw_pdmenu_s, 0, '--------------'}, $
{cw_pdmenu_s, 2, 'Asinh Settings'}, $
{cw_pdmenu_s, 1, 'Labels'}, $ ; labels menu
{cw_pdmenu_s, 0, 'TextLabel'}, $
{cw_pdmenu_s, 0, 'Arrow'}, $
{cw_pdmenu_s, 0, 'Contour'}, $
{cw_pdmenu_s, 0, 'Compass'}, $
{cw_pdmenu_s, 0, 'ScaleBar'}, $
{cw_pdmenu_s, 0, 'Region'}, $
{cw_pdmenu_s, 0, '--------------'}, $
{cw_pdmenu_s, 0, 'EraseLast'}, $
{cw_pdmenu_s, 0, 'EraseAll'}, $
{cw_pdmenu_s, 0, '--------------'}, $
{cw_pdmenu_s, 0, 'LoadRegions'}, $
{cw_pdmenu_s, 2, 'SaveRegions'}, $
{cw_pdmenu_s, 1, 'Blink'}, $
{cw_pdmenu_s, 0, 'SetBlink1'}, $
{cw_pdmenu_s, 0, 'SetBlink2'}, $
{cw_pdmenu_s, 0, 'SetBlink3'}, $
{cw_pdmenu_s, 0, '--------------'}, $
{cw_pdmenu_s, 2, 'MakeRGB'}, $
{cw_pdmenu_s, 1, 'Rotate/Zoom'}, $
{cw_pdmenu_s, 0, 'Rotate'}, $
{cw_pdmenu_s, 0, '90 deg'}, $
{cw_pdmenu_s, 0, '180 deg'}, $
{cw_pdmenu_s, 0, '270 deg'}, $
{cw_pdmenu_s, 0, '--------------'}, $
{cw_pdmenu_s, 0, 'Invert X'}, $
{cw_pdmenu_s, 0, 'Invert Y'}, $
{cw_pdmenu_s, 0, 'Invert XY'}, $
{cw_pdmenu_s, 0, '--------------'}, $
{cw_pdmenu_s, 0, '1/16x'}, $
{cw_pdmenu_s, 0, '1/8x'}, $
{cw_pdmenu_s, 0, '1/4x'}, $
{cw_pdmenu_s, 0, '1/2x'}, $
{cw_pdmenu_s, 0, '1x'}, $
{cw_pdmenu_s, 0, '2x'}, $
{cw_pdmenu_s, 0, '4x'}, $
{cw_pdmenu_s, 0, '8x'}, $
{cw_pdmenu_s, 2, '16x'}, $
{cw_pdmenu_s, 1, 'ImageInfo'}, $ ;info menu
{cw_pdmenu_s, 0, 'ImageHeader'}, $
{cw_pdmenu_s, 0, 'Photometry'}, $
{cw_pdmenu_s, 0, 'Statistics'}, $
{cw_pdmenu_s, 0, 'PixelTable'}, $
{cw_pdmenu_s, 0, '--------------'}, $
{cw_pdmenu_s, 0, 'RA,dec (J2000)'}, $
{cw_pdmenu_s, 0, 'RA,dec (B1950)'}, $
{cw_pdmenu_s, 0, '--------------'}, $
{cw_pdmenu_s, 0, 'RA,dec (J2000) deg'}, $
{cw_pdmenu_s, 0, 'Galactic'}, $
{cw_pdmenu_s, 0, 'Ecliptic (J2000)'}, $
{cw_pdmenu_s, 2, 'Native'}, $
{cw_pdmenu_s, 1, 'Help'}, $ ; help menu
{cw_pdmenu_s, 2, 'ATV Help'} $
]
top_menu = cw_pdmenu(top_menu, top_menu_desc, $
ids = state.menu_ids, $
/mbar, $
/help, $
/return_name, $
uvalue = 'top_menu')
track_base = widget_base(base, /row)
state.info_base_id = widget_base(track_base, /column, /base_align_right)
buttonbar_base = widget_base(base, column=2)
state.draw_base_id = widget_base(base, $
/column, /base_align_left, $
uvalue = 'draw_base', $
frame = 2)
state.colorbar_base_id = widget_base(base, $
uvalue = 'cqolorbar_base', $
/column, /base_align_left, $
frame = 2)
state.min_text_id = cw_field(state.info_base_id, $
uvalue = 'min_text', $
/floating, $
title = 'Min=', $
value = state.min_value, $
/return_events, $
xsize = 12)
state.max_text_id = cw_field(state.info_base_id, $
uvalue = 'max_text', $
/floating, $
title = 'Max=', $
value = state.max_value, $
/return_events, $
xsize = 12)
tmp_string = string(1000, 1000, 1.0e-10, $
format = '("(",i5,",",i5,") ",g12.5)' )
state.location_bar_id = widget_label (state.info_base_id, $
value = tmp_string, $
uvalue = 'location_bar', frame = 1)
tmp_string = string(12, 12, 12.001, -60, 60, 60.01, ' J2000', $
format = '(i2,":",i2,":",f6.3," ",i3,":",i2,":",f5.2," ",a6)' )
state.wcs_bar_id = widget_label (state.info_base_id, $
value = tmp_string, $
uvalue = 'wcs_bar', frame = 1)
state.pan_widget_id = widget_draw(track_base, $
xsize = state.pan_window_size, $
ysize = state.pan_window_size, $
frame = 2, uvalue = 'pan_window', $
/button_events, /motion_events)
track_window = widget_draw(track_base, $
xsize=state.track_window_size, $
ysize=state.track_window_size, $
frame=2, uvalue='track_window')
modebase = widget_base(buttonbar_base, /row, /base_align_center)
modelist = ['Color', 'Zoom', 'Blink', 'ImExam', 'Vector']
mode_droplist_id = widget_droplist(modebase, $
frame = 1, $
title = 'MouseMode:', $
uvalue = 'mode', $
value = modelist)
state.mode_droplist_id = mode_droplist_id
button_base = widget_base(buttonbar_base, row=2)
invert_button = widget_button(button_base, $
value = 'Invert', $
uvalue = 'invert')
restretch_button = widget_button(button_base, $
value = 'Restretch', $
uvalue = 'restretch_button')
autoscale_button = widget_button(button_base, $
uvalue = 'autoscale_button', $
value = 'AutoScale')
fullrange_button = widget_button(button_base, $
uvalue = 'full_range', $
value = 'FullRange')
dummy_spacing_widget = widget_label(button_base,value='')
zoomin_button = widget_button(button_base, $
value = 'ZoomIn', $
uvalue = 'zoom_in')
zoomout_button = widget_button(button_base, $
value = 'ZoomOut', $
uvalue = 'zoom_out')
zoomone_button = widget_button(button_base, $
value = 'Zoom1', $
uvalue = 'zoom_one')
fullview_button = widget_button(button_base, $
value = 'FullView', $
uvalue = 'fullview')
center_button = widget_button(button_base, $
value = 'Center', $
uvalue = 'center')
;done_button = widget_button(button_base, $
; value = 'Done', $
; uvalue = 'done')
; Set widget y size for small screens
state.draw_window_size[1] = state.draw_window_size[1] < $
(state.screen_ysize - 300)
state.draw_widget_id = widget_draw(state.draw_base_id, $
uvalue = 'draw_window', $
/motion_events, /button_events, $
keyboard_events=2, $
scr_xsize = state.draw_window_size[0], $
scr_ysize = state.draw_window_size[1])
state.colorbar_widget_id = widget_draw(state.colorbar_base_id, $
uvalue = 'colorbar', $
scr_xsize = state.draw_window_size[0], $
scr_ysize = state.colorbar_height)
; Create the widgets on screen
widget_control, base, /realize
widget_control, state.pan_widget_id, draw_motion_events = 0
; get the window ids for the draw widgets
widget_control, track_window, get_value = tmp_value
state.track_window_id = tmp_value
widget_control, state.draw_widget_id, get_value = tmp_value
state.draw_window_id = tmp_value
widget_control, state.pan_widget_id, get_value = tmp_value
state.pan_window_id = tmp_value
widget_control, state.colorbar_widget_id, get_value = tmp_value
state.colorbar_window_id = tmp_value
; set the event handlers
widget_control, top_menu, event_pro = 'atv_topmenu_event'
widget_control, state.draw_widget_id, event_pro = 'atv_draw_event'
widget_control, state.pan_widget_id, event_pro = 'atv_pan_event'
; Find window padding sizes needed for resizing routines.
; Add extra padding for menu bar, since this isn't included in
; the geometry returned by widget_info.
; Also add extra padding for margin (frame) in draw base.
basegeom = widget_info(state.base_id, /geometry)
drawbasegeom = widget_info(state.draw_base_id, /geometry)
; Initialize the vectors that hold the current color table.
; See the routine atv_stretchct to see why we do it this way.
r_vector = bytarr(state.ncolors)
g_vector = bytarr(state.ncolors)
b_vector = bytarr(state.ncolors)
atv_getct, 0
state.invert_colormap = 0
; Create a pixmap window to hold the pan image
window, /free, xsize=state.pan_window_size, ysize=state.pan_window_size, $
/pixmap
state.pan_pixmap = !d.window
atv_resetwindow
atv_colorbar
widget_control, state.base_id, tlb_get_size=tmp_event
state.base_pad = tmp_event - state.draw_window_size
end
;--------------------------------------------------------------------
pro atv_colorbar
; Routine to tv the colorbar at the bottom of the atv window
common atv_state
atv_setwindow, state.colorbar_window_id
xsize = (widget_info(state.colorbar_widget_id, /geometry)).xsize
b = congrid( findgen(state.ncolors), xsize) + 8
c = replicate(1, state.colorbar_height)
a = b # c
tv, a
atv_resetwindow
end
;-------------------------------------------------------------------
pro atvclear
; displays a small blank image, useful for clearing memory if atv is
; displaying a huge image.
atv, fltarr(10,10)
end
;--------------------------------------------------------------------
; main atv event loops
;--------------------------------------------------------------------
pro atv_topmenu_event, event
; Event handler for top menu
common atv_state
common atv_images
widget_control, event.id, get_uvalue = event_name
if (!d.name NE state.graphicsdevice and event_name NE 'Quit') then return
if (state.bitdepth EQ 24) then true = 1 else true = 0
; Need to get active window here in case mouse goes to menu from top
; of atv window without entering the main base
atv_getwindow
case event_name of
; File menu options:
'ReadFits': begin
atv_readfits, newimage=newimage
if (newimage EQ 1) then begin
atv_getstats, align=state.default_align
if (state.default_align EQ 0) then begin
state.zoom_level = 0
state.zoom_factor = 1.0
endif
if (state.default_stretch EQ 0 AND $
state.default_autoscale EQ 1) then atv_autoscale
if (state.firstimage EQ 1) then atv_autoscale
atv_set_minmax
atv_displayall
atv_settitle
state.firstimage = 0
endif
end
'WriteFits': atv_writefits
'WritePS' : atv_writeps
'PNG': atv_writeimage, 'png'
'JPEG': atv_writeimage, 'jpg'
'TIFF': atv_writeimage, 'tiff'
'GetImage':
' DSS': atv_getdss
' FIRST': atv_getfirst
'LoadRegions': atv_loadregion
'SaveRegions': atv_saveregion
'Quit': if (state.activator EQ 0) then atv_shutdown $
else state.activator = 0
; ColorMap menu options:
'Grayscale': atv_getct, 0
'Blue-White': atv_getct, 1
'Red-Orange': atv_getct, 3
'BGRY': atv_getct, 4
'Rainbow': atv_getct, 13
'Stern Special': atv_getct, 15
'Green-White': atv_getct, 8
'ATV Special': atv_makect, event_name
'Velocity1': atv_makect, event_name
'Velocity2': atv_makect, event_name
; Scaling options:
'Linear': begin
state.scaling = 0
atv_displayall
end
'Log': begin
state.scaling = 1
atv_displayall
end
'HistEq': begin
state.scaling = 2
atv_displayall
end
'Asinh': begin
state.scaling = 3
atv_displayall
end
'Asinh Settings': begin
atv_setasinh
end
; Label options:
'TextLabel': atv_textlabel
'Arrow': atv_setarrow
'Contour': atv_oplotcontour
'Compass': atv_setcompass
'ScaleBar': atv_setscalebar
'Region': atv_setregion
'EraseLast': atverase, 1
'EraseAll': atverase
; Blink options:
'SetBlink1': begin
atv_setwindow, state.draw_window_id
blink_image1 = tvrd(true = true)
end
'SetBlink2': begin
atv_setwindow, state.draw_window_id
blink_image2 = tvrd(true = true)
end
'SetBlink3': begin
atv_setwindow, state.draw_window_id
blink_image3 = tvrd(true = true)
end
'MakeRGB' : atv_makergb
; Zoom/Rotate options
'1/16x': atv_zoom, 'onesixteenth'
'1/8x': atv_zoom, 'oneeighth'
'1/4x': atv_zoom, 'onefourth'
'1/2x': atv_zoom, 'onehalf'
'1x': atv_zoom, 'one'
'2x': atv_zoom, 'two'
'4x': atv_zoom, 'four'
'8x': atv_zoom, 'eight'
'16x': atv_zoom, 'sixteen'
'Invert X': atv_invert, 'x'
'Invert Y': atv_invert, 'y'
'Invert XY': atv_invert, 'xy'
'Rotate': atv_rotate, '0', /get_angle
'0 deg': atv_rotate, '0'
'90 deg': atv_rotate, '90'
'180 deg': atv_rotate, '180'
'270 deg': atv_rotate, '270'
; Info options:
'Photometry': atv_apphot
'ImageHeader': atv_headinfo
'Statistics': atv_showstats
'PixelTable': atv_pixtable
; Coordinate system options:
'--------------':
'RA,dec (J2000)': BEGIN
state.display_coord_sys = 'RA--'
state.display_equinox = 'J2000'
state.display_base60 = 1B
atv_gettrack ; refresh coordinate window
END
'RA,dec (B1950)': BEGIN
state.display_coord_sys = 'RA--'
state.display_equinox = 'B1950'
state.display_base60 = 1B
atv_gettrack ; refresh coordinate window
END
'RA,dec (J2000) deg': BEGIN
state.display_coord_sys = 'RA--'
state.display_equinox = 'J2000'
state.display_base60 = 0B
atv_gettrack ; refresh coordinate window
END
'Galactic': BEGIN
state.display_coord_sys = 'GLON'
atv_gettrack ; refresh coordinate window
END
'Ecliptic (J2000)': BEGIN
state.display_coord_sys = 'ELON'
state.display_equinox = 'J2000'
atv_gettrack ; refresh coordinate window
END
'Native': BEGIN
IF (state.wcstype EQ 'angle') THEN BEGIN
state.display_coord_sys = strmid((*state.astr_ptr).ctype[0], 0, 4)
state.display_equinox = state.equinox
atv_gettrack ; refresh coordinate window
ENDIF
END
; Help options:
'ATV Help': atv_help
else: print, 'Unknown event in file menu!'
endcase
; Need to test whether atv is still alive, since the quit option
; might have been selected.
if (xregistered('atv', /noshow)) then atv_resetwindow
end
;--------------------------------------------------------------------
pro atv_draw_event, event
; top-level event handler for draw widget events
common atv_state
if (!d.name NE state.graphicsdevice) then return
if (event.type EQ 0 or event.type EQ 1 or event.type EQ 2) then begin
case state.mousemode of
'color': atv_draw_color_event, event
'zoom': atv_draw_zoom_event, event
'blink': atv_draw_blink_event, event
'imexam': atv_draw_phot_event, event
'vector': atv_draw_vector_event, event
endcase
endif
if (event.type EQ 5 or event.type EQ 6) then $
atv_draw_keyboard_event, event
if (xregistered('atv', /noshow)) then $
widget_control, state.draw_widget_id, /sensitive, /input_focus
end
;--------------------------------------------------------------------
pro atv_draw_color_event, event
; Event handler for color mode
common atv_state
common atv_images
;if (!d.name NE state.graphicsdevice) then return
case event.type of
0: begin ; button press
if (event.press EQ 1) then begin
state.cstretch = 1
atv_stretchct, event.x, event.y, /getcursor
atv_resetwindow
atv_colorbar
endif else begin
atv_zoom, 'none', /recenter
endelse
end
1: begin
state.cstretch = 0 ; button release
if (state.bitdepth EQ 24) then atv_refresh
atv_draw_motion_event, event
end
2: begin ; motion event
if (state.cstretch EQ 1) then begin
atv_stretchct, event.x, event.y, /getcursor
atv_resetwindow
if (state.bitdepth EQ 24) then atv_refresh, /fast
endif else begin
atv_draw_motion_event, event
endelse
end
endcase
widget_control, state.draw_widget_id, /sensitive, /input_focus
end
;--------------------------------------------------------------------
pro atv_draw_keyboard_event, event
common atv_state
common atv_images
common atv_color
; Only want to look for key presses, not key releases.
if (event.release EQ 1) then return
if (event.type EQ 5) then begin
eventchar = string(event.ch)
if (!d.name NE state.graphicsdevice and eventchar NE 'q') then return
if (state.bitdepth EQ 24) then true = 1 else true = 0
case eventchar of
'1': atv_move_cursor, eventchar
'2': atv_move_cursor, eventchar
'3': atv_move_cursor, eventchar
'4': atv_move_cursor, eventchar
'6': atv_move_cursor, eventchar
'7': atv_move_cursor, eventchar
'8': atv_move_cursor, eventchar
'9': atv_move_cursor, eventchar
'r': atv_rowplot, /newcoord
'c': atv_colplot, /newcoord
's': atv_surfplot, /newcoord
't': atv_contourplot, /newcoord
'h': atv_histplot, /newcoord
'p': atv_apphot
'i': atv_showstats
'm': atv_changemode
'w': print, state.coord
'x': atvextract, /newcoord
'e': atverase