-
Notifications
You must be signed in to change notification settings - Fork 59
/
Gaia.tcl
3047 lines (2662 loc) · 109 KB
/
Gaia.tcl
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:
# Gaia.tcl
# Purpose:
# Defines a class for creating a GAIA window.
# Type of Module:
# [incr Tk] class
# Description:
# This is the class that creates the GAIA display tool.
# Invocation:
# Gaia name [configuration options]
# Notes:
# This will only run with the gaia_wish installed as part
# of the GAIA package with a Starlink extended Skycat.
# Authors:
# PWD: Peter Draper (STARLINK)
# ALLAN: Allan Brighton (ESO)
# MBT: Mark Taylor
# {enter_new_authors_here}
# Copyright:
# Copyright (C) 1998-2001 Central Laboratory of the Research Councils
# Copyright (C) 2006-2007 Particle Physics & Astronomy Research Council.
# Copyright (C) 2007-2014 Science and Technology Facilities Council.
# All Rights Reserved.
# Licence:
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street,Fifth Floor, Boston, MA
# 02110-1301, USA
# Inherits:
# Methods and configuration options of SkyCat (and Rtd).
# History:
# 24-SEP-1997 (PWD):
# Original version
# 10-MAR-1998 (PWD):
# Clone method now accepts a file name and additional options.
# 06-APR-1998 (PWD):
# Added demo toolbox.
# 07-APR-1998 (PWD):
# Moved temporary code to GaiaImageCtrl.
# 09-APR-1998 (PWD):
# Changed clone method to not use TopLevelWidget::start.
# This simplifies passing on new options and makes it
# possible to wait for the window to appear (start blocks
# with a tkwait which means that it is impossible to
# work out when the clone is running).
# 10-JUL-1998 (PWD):
# Added changes to support cloning of toolboxes.
# 10-SEP-1998 (PWD):
# Added SExtractor toolbox.
# 10-MAR-1999 (PWD):
# Attempt merge of Allan's GAIA plugin differences...
# 01-MAY-1999 (PWD):
# Added contouring toolbox.
# 28-MAY-1999 (PWD):
# Added optimal photometry toolbox.
# 28-JUN-1999 (PWD):
# Added ramp printing changes, hidden development code for now.
# 22-NOV-1999 (PWD):
# Added focus_follows_mouse option to stop funny effects
# with click-to-focus + autoraise under CDE.
# 06-DEC-1999 (PWD):
# Added Norman Gray's ESP toolbox. Commented out as not ready.
# 05-MAY-2000 (PWD):
# Changed so that CATLIB_CONFIG is used in preference to
# all other configuration files when set (otherwise need
# to delete ~/.skycat/skycat.cfg before can use another
# configuration file).
# 12-MAY-2000 (PWD):
# Added positions toolbox.
# 18-JUL-2000 (PWD):
# Added XY profiles toolbox.
# 22-MAR-2001 (PWD):
# Added Polarimetry toolbox.
# Revealed ramp printing option.
# 23-JUL-2001 (PWD):
# Added UKIRT quick look option.
# 21-JUL-2003 (PWD):
# Added support for the new tabbed interface.
# 13-OCT-2004 (PWD):
# Added cube display toolbox and associated changes.
# 05-MAY-2005 (PWD):
# Added RICE compression changes.
# 17-NOV-2005 (PWD):
# Update to Skycat version 2.7.4. No longer need to play with tkwait in
# noblock_clone.
# 19-JUL-2006 (MBT):
# Added plastic support.
# 23-JUL-2008 (PWD):
# Start adding VO support.
# 09-JUN-2009 (PWD):
# Add mask toolbox.
# 24-JUN-2009 (MBT):
# Replace PLASTIC support with SAMP support.
# {enter_changes_here}
#-
# Version.
# Make a local copy of about_skycat so we can divert bug reports.
set about_skycat ""
set about_gaia "
Starlink GAIA version $gaia_version
Copyright (C) 1997-2005 Central Laboratory of the Research Councils
Copyright (C) 2006-2007 Particle Physics and Astronomy Research Council
Copyright (C) 2007-2009 Science and Technology Facilities Council
Authors:
Peter W. Draper (p.w.draper@durham.ac.uk)
Norman Gray (norman@astro.gla.ac.uk)
David S. Berry (dsb@ast.man.ac.uk)
Mark Taylor (m.b.taylor@bristol.ac.uk)
GAIA is derived from SkyCat version $skycat_version
Copyright (C) 1996-2008 ESO - European Southern Observatory
Authors:
Allan Brighton (abrighto@eso.org)
Thomas Herlin (therlin@eso.org)
Miguel Albrecht (malbrech@eso.org)
Daniel Durand (durand@dao.nrc.ca)
Peter Biereichel (pbiereic@eso.org)
"
# Set the modification to about for the UKIRT quick look facility.
set about_ukirt_ql {
A modified GAIA for UKIRT quick look display
by Min Tan, Alan Bridger, Alan Pickup, Len Lawrance at UK ATC
based on:
}
# Where to send bugs.
set gaia_bugs {
Bug reports and suggestions to: starlink@jiscmail.ac.uk
}
set ukirt_ql_bugs {
Bug reports and suggestions to: ab@roe.ac.uk
}
set gaia_usage {
Usage: gaia ?NDF/fitsFile? ?-option value ...?
Options:
-always_merge <bool> - always merge primary & extension headers (MEFs).
-autofit <bool> - scale new image to fit window (keeps zoom).
-autoscale <bool> - scale image to fit window (disables zoom).
-cat <bool> - include ESO/Archive catalog extensions (default).
-catalog "<c1> <c2> .." - open windows for the given catalogs on startup.
-check_for_cubes <bool> - Check input files to see if they are cubes (default: 1) \\
-cupidcat catalog - open catalog as CUPID output (requires cube) \\
-colorramp_height <n> - height of colorramp window (default: 12).
-component <component> - NDF component to display (one of: data, variance)
-debug <bool> - debug flag: run bg processes in fg.
-deep_search <bool> - search NDF extensions for related NDFs
-default_cmap <cmap> - default colormap.
-default_itt <itt> - default intensity transfer table.
-extended_precision - show extra readout precision (default: 0).
-file <file> - image file to load.
-float_panel <bool> - put info panel in a popup window (default: 0).
-focus_follows_mouse <bool> - entry focus follows mouse (default: 0).
-force_degrees <bool> - force the display of degrees in main window (default: 0)
-geometry <wxh+x+y> - geometry of the main window (default: last session).
-hdu <n> - HDU to display (default: 1)
-ident <string> - identifying string that will be prefixed to the window title.
-interop_menu <bool> - reveal interop menu for SAMP interactions (default: 1).
-isize <n> - search box for centroiding (default: 9).
-linear_cartesian <bool> - assuming CAR projections are a linear mapping (default: 1).
-max_scale <n> - maximum scale for magnification menu (default: 20).
-maxshift <n.5> - maximum shift when centroiding (default: 5.5).
-min_scale <n> - minimum scale for magnification menu (default: -10).
-panel_layout <layout> - panel layout, one of: "saoimage", "reverse" or "default" .
-panel_orient <orient> - panel orientation, one of: "horizontal", "vertical"
-pick_zoom_factor <n> - scale factor used in pick object zoom window.
-pickobjectorient <v> - orientation for pick object win: "horizontal", "vertical"
-pixel_indices <bool> - show NDF pixel indices as X,Y readout values (default: 0).
-port <port> - listen for remote cmds on port (default: 0 = choose port).
-remote <bool> - use existing skycat process, if available, with Tk send.
-rtd <bool> - include ESO/VLT Real-Time Features.
-rtd_autocut <bool> - whether to apply the default autocut to realtime images.
-scrollbars <bool> - display scrollbars (not displayed by default).
-shm_data <bool> - put image data in sysV shared memory.
-shm_header <bool> - put image header in sysV shared memory.
-transient_spectralplot <bool> - spectral plot is a transient window. (default: 1)
-transient_tools <bool> - toolboxes are transient windows. (default: 0)
-ukirt_ql <bool> - show UKIRT Quick Look Facilities (default: 0).
-ukirt_xy <bool> - show XY profile UKIRT Quick Look Facilities (default: 0).
-use_zoom_view <bool> - use a "view" of the image for the zoom window (default).
-usexshm <bool> - use X shared mem, if available (default).
-verbose <bool> - print diagnostic messages.
-visual <visual_id> - X visual to use (pseudocolor, truecolor, visual id...)
-with_colorramp <bool> - display the color bar (default).
-with_pan_window <bool> - display the pan window (default).
-with_warp <bool> - add bindings to move mouse ptr with arrow keys (default: 1).
-with_zoom_window <bool> - display the zoom window (default).
-zoom_factor <n> - scale factor for zoom window (default: 4).
}
itk::usual Gaia {}
# Create a class for the application.
itcl::class gaia::Gaia {
inherit ::skycat::SkyCat
# Constructor: create a toplevel window.
constructor {args} {
# And start things going.
configure -center 0
# Remove any options we're overriding and evaluate all
# options.
itk_option remove rtd::Rtd::scrollbars
itk_option remove rtd::Rtd::panel_layout
itk_option remove rtd::Rtd::panel_orient
eval itk_initialize $args
# Set the default application icon.
global ::gaia_library
set default_icon [image create photo .gaia_logo -format gif \
-file $::gaia_library/gaia_small_logo.gif]
wm iconphoto . -default $default_icon
# Override about_skycat message.
global ::about_skycat ::about_gaia ::gaia_bugs
global ::about_ukirt_ql ::ukirt_ql_bugs
if { ! $itk_option(-ukirt_ql) } {
set about_skycat "$about_gaia $gaia_bugs"
} else {
set about_skycat "$about_ukirt_ql $about_gaia $ukirt_ql_bugs"
}
}
# Destructor:
destructor {
# If this is the final remaining instance of this class, do some
# application-wide clear up to clear any current registration with a
# SAMP hub.
if {"[itcl::find objects -class gaia::Gaia]" == "$this"} {
# Inform the SAMP hub that we are ceasing operations.
stop_samp_
}
# Delete temporary files used by SAMP components.
catch {
if { $samp_sender_ != {} } {
$samp_sender_ destructor
}
}
catch {
if { $samp_agent_ != {} } {
$samp_agent_ destructor
}
}
# Clear up the images list (this isn't done correctly in
# SkyCat, it uses $w_ instead of $image_).
global ::skycat_images
if {[info exists skycat_images]} {
set tmp {}
foreach w $skycat_images {
if {[winfo exists $w] && "$w" != "$image_"} {
lappend tmp $w
}
}
set skycat_images $tmp
}
# Kill the importer dialog, if used.
if { [info exists $w_.importer] && [winfo exists $w_.importer] } {
catch {delete object $w_.importer}
}
# The FITS browser needs to release any temporary files
# used for storing in-line compressed images.
catch {gaia::GaiaHduBrowser::release_temporary_files}
}
# Restore the position of the top level window from the previous
# session, or not depending on mode and whether an explicit value
# has been given on the command-line (0x0 resets to default size).
# Overridden from Skycat.
protected method load_toplevel_geometry {} {
if { $itk_option(-tabbedgaia) } {
return
}
if { [info exists ::geometry] } {
if { $::geometry != "0x0" } {
catch {wm geometry $w_ $::geometry}
}
} else {
if {[catch {set fd [::open $toplevel_geometry_]}]} {
return
}
catch {wm geometry $w_ [gets $fd]}
::close $fd
}
}
# Quit the application. Really....
# If being paranoid then ask for confirmation. Note I think this
# traps all ways of exiting that can be handled.
public method quit {} {
if { ! $itk_option(-quiet_exit) } {
if { ! [confirm_dialog \
"Are you sure you want to exit the application?" $w_]} {
return
}
}
# Permission supplied so continue with exit.
catch {
release_vtk_
}
delete object $w_
after idle exit
}
# Delete this object. Invoke the on_close_cmd if set.
public method delete_window {} {
delete object $w_
if { $itk_option(-on_close_cmd) != {} } {
catch {
eval $itk_option(-on_close_cmd)
}
}
}
# VTK requires that some objects are released before the associated
# windows are destroyed, so any method that deletes this object should
# call this method.
protected method release_vtk_ {} {
if { [::namespace exists "::gaia3d"] } {
gaia3d::Gaia3dVtk::release_all
}
}
# Called after the options have been evaluated. Add GAIA menu and
# extra items for other menus.
public method init {} {
# If not first window then show splash screen (better than no feedback).
if { $itk_option(-number) != 1 } {
make_init_window 1
}
# Do base class inits. Note stop creation of cat menu and opening
# of catalogues from the command-line so we can override use of
# SkySearch class.
set curval $itk_option(-cat)
set curcats $itk_option(-catalog)
set itk_option(-cat) 0
set itk_option(-catalog) {}
SkyCat::init
set itk_option(-cat) $curval
set itk_option(-catalog) $curcats
# Get the clone number for this window.
set clone_ $itk_option(-number)
# On openwindows iconwindows are displayed but do not
# redirect events, so add a fake deiconify binding.
if {$itk_option(-disp_image_icon)} {
bind $itk_component(icon) <Double-1> "wm deiconify $w_"
}
# Add the GAIA menubar.
feedback "GAIA toolboxes..."
if { $itk_option(-gaia) } {
add_gaia_menu
}
# Add the filters menu if required (not used at present).
feedback "filters..."
if { $itk_option(-filters) } {
make_filters_menu
}
# Add the catalogue menu.
if {$itk_option(-cat)} {
cat::AstroCat::add_catalog_menu \
$w_ [code $image_] ::gaia::GaiaSearch $itk_option(-debug)
}
# Open any local catalogues.
if { $itk_option(-catalog) != {} } {
# Make sure we use full path name for local catalogs
# and process option as a list
foreach f "$itk_option(-catalog)" {
if { [file exists $f] && "[string index $f 0]" != "/" } {
set $f [pwd]/$f
}
cat::AstroCat::open_catalog_window $f \
[code $image_] ::gaia::GaiaSearch $itk_option(-debug) $w_
}
}
# Add the SAMP menu.
if {$itk_option(-interop_menu)} {
add_interop_menu
}
# Add the SkyCat graphics features (really a plugin, but we're
# not using these yet).
add_graphics_features $w_
# And the other changes to menus that we require.
make_menu_changes
# Load user cmaps.
if { [::file exists $::env(HOME)/.skycat/colormaps] } {
set files [glob -nocomplain -directory $::env(HOME)/.skycat/colormaps "*.lasc"]
if { $files != {} } {
foreach file $files {
$image_ cmap file $file
}
}
}
# Center image first time.
after 0 [code $image_ center]
# Check if any post display tasks are required.
after 0 [code $this file_loaded_]
# If autoscaling, need to wait for realization the first time.
if { $itk_option(-autofill) } {
after 0 [code $this configure -autofill 1]
} elseif { $itk_option(-autoscale) } {
after 0 [code $this configure -autoscale 1]
} elseif { $itk_option(-autofit) } {
after 0 [code $this configure -autofit 1]
}
# Attempt to register as SAMP listener, adding callbacks to be
# informed when the status of the SAMP connection changes.
if {$itk_option(-interop_menu)} {
init_samp_
if { $samp_client_ != "" } {
$samp_client_ reg_change_command [code $this samp_reg_changed_]
samp_reg_changed_
set tracker [$samp_client_ cget -client_tracker]
$tracker client_change_command [code $this samp_client_changed_]
samp_client_changed_
}
}
# Start the internal debug logging, if required.
start_debuglog_
# Set the blank and background colours for the first time.
set_blankcolour
set_image_background
# Trap window closing and handle that.
wm protocol $w_ WM_DELETE_WINDOW [code $this close]
}
# Set/get X defaults - can be overridden in subclass and/or
# in user's .Xdefaults file.
protected method setXdefaults {} {
util::setXdefaults
SkyCat::setXdefaults
gaia::setXdefaults
}
# Start or stop the debug log. If the debuglog value is greater than 1
# then buffering is switched off so that the updates are immediate, useful
# when dealing with an aborting process that might miss output. If logging
# is already active new output is appended.
protected method start_debuglog_ {} {
if { $itk_option(-debuglog) } {
# If already started the log, we append new output.
if { $debug_started_ } {
set mode "a"
} else {
set mode "w"
}
set fid [::open "GaiaDebug.log" $mode]
if { $itk_option(-debuglog) > 1 } {
fconfigure $fid -buffering none
}
cmdtrace on notruncate $fid
set debug_started_ 1
} else {
if { $debug_started_ } {
cmdtrace off
}
}
}
# Display a window while the application is starting up, overriden
# to remove skycat logo and add plain option for showing
# minimalist stuff when creating a clone.
protected method make_init_window {{plain 0}} {
global ::about_skycat ::gaia_library
if { $itk_option(-tabbedgaia) } {
# If tabbedgaia then use a simple component not a window.
set w [frame $w_.init]
place $w -relx 0.5 -rely 0.5 -anchor s
} else {
set w [util::TopLevelWidget $w_.init -center 1 -cursor watch]
wm title $w "$appname_ loading..."
wm withdraw $w_
}
if { ! $plain } {
set gaia_logo [image create photo -file $gaia_library/gaia_logo.xpm]
pack \
[label $w.logo -image $gaia_logo -borderwidth 2 -relief groove] \
-side top -padx 1m -pady 1m
pack \
[message $w.msg -text $about_skycat \
-justify center \
-borderwidth 2 -relief groove] \
[ProgressBar $w.progress \
-from 0 -to 10 -value 0 \
-borderwidth 2 -relief groove] \
-side top -fill x -padx 1m -pady 2m -expand 1
} else {
pack \
[ProgressBar $w.progress \
-from 0 -to 10 -value 0 \
-borderwidth 2 -relief groove] \
-side top -fill x -padx 1m -pady 2m -expand 1
}
if { ! $itk_option(-tabbedgaia) } {
::tkwait visibility $w
}
}
# Add help for GAIA and SkyCat. Gets called a lot from base classes, so
# make sure done just once.
public method add_help_menu {} {
if { ! $help_menu_done_ } {
set help_menu_done_ 1
set m [add_help_button index "Help..." \
{Display the main help window and index}]
add_menuitem $m command "About ${appname_}..." \
{Display a window with information about this GAIA/SkyCat version}\
-command [code $itk_component(image) about]
add_menuitem $m command "About SkyCat..." \
{Display information about SkyCat in browser} \
-command [code $itk_component(image) send_to_browser \
$itk_option(-help_url)]
add_short_help $itk_component(menubar).help \
{Help menu: display information about this application}
}
}
# Create the rtd image widget with the extended RTD functionality
# needed by GAIA.
public method make_rtdimage {} {
set image_ $w_.image
itk_component add image {
GaiaImageCtrl $image_ \
-file $itk_option(-file) \
-file_change_cmd [code $this file_loaded_] \
-file_types $itk_option(-file_types) \
-usexshm $itk_option(-usexshm) \
-verbose $itk_option(-verbose) \
-shm_header $itk_option(-shm_header) \
-shm_data $itk_option(-shm_data) \
-min_colors $itk_option(-min_colors) \
-max_colors $itk_option(-max_colors) \
-drag_scroll $itk_option(-drag_scroll) \
-scrollbars $itk_option(-scrollbars) \
-subsample $itk_option(-subsample) \
-use_zoom_view $itk_option(-use_zoom_view) \
-zoom_view_propagate $itk_option(-zoom_view_propagate) \
-with_zoom_window $itk_option(-with_zoom_window) \
-dozoom $itk_option(-dozoom) \
-with_pan_window $itk_option(-with_pan_window) \
-zoom_factor $itk_option(-zoom_factor) \
-zoom_width $itk_option(-zoom_width) \
-zoom_height $itk_option(-zoom_height) \
-pan_width $itk_option(-pan_width) \
-pan_height $itk_option(-pan_height) \
-colorramp_height $itk_option(-colorramp_height) \
-default_cmap $itk_option(-default_cmap) \
-default_itt $itk_option(-default_itt) \
-with_colorramp $itk_option(-with_colorramp) \
-feedback [code $this feedback] \
-port $itk_option(-port) \
-shorthelpwin $this \
-debug $itk_option(-debug) \
-float_panel $itk_option(-float_panel) \
-newimagecmd [code $this cleared] \
-temporary $itk_option(-temporary) \
-ast_tag $ast_tag_ \
-grid_command [code $this redraw_specials_] \
-with_warp 1 \
-panel_layout $itk_option(-panel_layout) \
-panel_orient $itk_option(-panel_orient) \
-regioncommand [code $this select_region] \
-component $itk_option(-component) \
-min_scale $itk_option(-min_scale) \
-max_scale $itk_option(-max_scale) \
-pickobjectorient $itk_option(-pickobjectorient) \
-pick_zoom_factor $itk_option(-pick_zoom_factor) \
-hdu $itk_option(-hdu) \
-ukirt_ql $itk_option(-ukirt_ql) \
-ukirt_xy $itk_option(-ukirt_xy) \
-pixel_indices $itk_option(-pixel_indices) \
-appname $appname_ \
-extended_precision $itk_option(-extended_precision) \
-linear_cartesian $itk_option(-linear_cartesian) \
-force_degrees $itk_option(-force_degrees) \
-always_merge $itk_option(-always_merge) \
-show_hdu_chooser $itk_option(-show_hdu_chooser) \
-default_cut $itk_option(-default_cut) \
-ident $itk_option(-ident) \
-deep_search $itk_option(-deep_search)
}
# Keep a list of SkyCat/GAIA instances.
global ::skycat_images
lappend skycat_images $itk_component(image)
# Some modes require realtime events immediately (not just when
# the toolboxes are ready).
if { $itk_option(-ukirt_xy) || $itk_option(-rtd_autocut) } {
$image_ configure -real_time_command [code $this real_time_event_]
}
}
# Make changes to Skycat menus that we require.
public method make_menu_changes {} {
# Note bindings are not really needed, unless working with
# plugin (GAIA version of TopLevelWidget is fixed).
# File menu. Change to use local opening dialog (not the Ctrl version,
# that is inefficient for cubes, these go straight to the toolbox),
# also needs the bindings changing to work with the keyboard shortcuts
# and the "save region" removing.
set m [get_menu File]
$m entryconfigure "Open..." -command [code $this open_file]
bind $w_ <Control-o> [code $image_ open]
bind $w_ <Control-v> [code $this reopen]
bind $w_ <Control-s> [code $image_ save_as]
catch {$m delete "Save region as..."}
# Make reopen work locally so we can release cubes.
$m entryconfigure "Reopen" -command [code $this reopen]
# Insert cube entry.
set index [$m index "Reopen"]
insert_menuitem $m $index command "Open cube..." \
{Open a cube and display image sections from it} \
-command [code $this make_opencube_toolbox]
# Close also needs the command changing to delete the object.
$m entryconfigure "Close" \
-label "Close Window" \
-accelerator {Control-d} \
-command [code $this delete_window]
bind $w_ <Control-d> [code $this delete_window]
add_menu_short_help $m "Close Window" \
{Close this window, exit application if last}
add_menu_short_help $m "New Window" \
{Create a new main window}
# If this is the tabbedgaia instance, exit is controlled
# elsewhere.
if { $itk_option(-tabbedgaia) } {
$m delete {Exit}
}
# Add window for configuring the startup options. Put this just
# before the "Clear" item.
set index [$m index "Clear"]
insert_menuitem $m $index command "Startup options..." \
{Set startup-level configuration options} \
-command [code $this make_toolbox startup 0 1]
# Print becomes cascade menu with options for image and colourramp.
set index [$m index "Print..."]
catch {$m delete "Print..."}
insert_menuitem $m $index cascade "Print..." \
{Print image or colour ramp to postscript file or printer} \
-menu [menu $m.print]
add_menuitem $m.print command "Image..." \
{Print image and graphics to postscript file or printer} \
-command [code $image_ print] \
-accelerator {Control-p}
bind $w_ <Control-p> [code $image_ print]
add_menuitem $m.print command "Ramp..." \
{Print annotated postscript copy of colour ramp to file or printer} \
-command [code $this print_ramp_]
# Capture main window to a graphics format.
insert_menuitem $m $index command "Visible snapshot..." \
{Capture visible image to a graphic format: GIF, JPEG, PNG, TIFF} \
-command [code $image_ capture 0]
incr index
insert_menuitem $m $index command "Full snapshot..." \
{Capture image, including offscreen parts, to a graphic format:
GIF, JPEG, PNG, TIFF (can be slow for large images)} \
-command [code $image_ capture 1]
# Shortcuts for closing window.
bind $w_ <Control-n> [code $this clone]
bind $w_ <Control-q> [code $this quit]
# View menu. Add new items, rename "Cuts..." to Slice, add
# bindings for accelerators.
set m [get_menu View]
bind $w_ <Control-c> [code $image_ set_colors]
bind $w_ <Control-l> [code $image_ component info cut_level_dialog]
$m entryconfigure "Cuts..." -label "Slice..." -accelerator {Control-a}
bind $w_ <Control-a> [code $image_ spectrum 0]
$m entryconfigure "Pick Object..." -accelerator {Control-i}
bind $w_ <Control-i> [code $image_ pick_dialog]
bind $w_ <Control-f> [code $image_ view_fits_header]
# Add item to show any AST warnings about the header associated
# with the image.
set index [$m index "Fits header..."]
incr index
insert_menuitem $m $index command "Astrometry warnings..." \
{See any problems found with current astrometry headers} \
-command [code $image_ display_astwarn]
# Locate "Auto scale" item and change to activate our local
# method.
set index [$m index "Auto scale"]
$m entryconfigure $index -command [code $this autoscale_]
# Append experimental auto fill autoscale variant.
incr index
insert_menuitem $m $index checkbutton "Auto fill*" \
{Scale the image to fit the window in both dimensions (experimental)} \
-variable [scope itk_option(-autofill)] \
-onvalue 1 -offvalue 0 \
-command [code $this autofill_ 1]
# Auto fit to complement autoscale.
incr index
insert_menuitem $m $index checkbutton "Auto fit" \
{Scale the image to the max. visible size when loaded} \
-variable [scope itk_option(-autofit)] \
-onvalue 1 -offvalue 0 \
-command [code $this autofit_]
# HDUs are for NDFs too.
$m entryconfigure "Select FITS HDU..." \
-label "Select FITS HDU/NDF..."
add_menu_short_help $m "Select FITS HDU/NDF..." \
{Display the available FITS HDUs and NDFs}
# Change background and blank pixel colours.
set index [$m index "Magnification"]
incr index
insert_menuitem $m $index cascade "Blank pixel color" \
{Change the colour of blank pixels} \
-menu [menu $m.blank]
foreach colour $colours_ {
$m.blank add radiobutton \
-background $colour \
-variable [scope itk_option(-blank_color)] \
-value $colour \
-label { } \
-command [code $this set_blankcolour $colour]
}
insert_menuitem $m $index cascade "Image background" \
{Change the background colour of the main window} \
-menu [menu $m.back]
foreach colour $colours_ {
$m.back add radiobutton \
-background $colour \
-variable [scope itk_option(-image_background)] \
-value $colour \
-label { } \
-command [code $this set_image_background $colour]
}
# UKIRT quick look likes to attach to camera immediately.
if { $itk_option(-ukirt_ql) || $itk_option(-ukirt_xy) } {
attach_camera
}
# Toggle debug logging. Only show in developer mode.
if { $itk_option(-developer) } {
$m add separator
add_menuitem $m checkbutton "Debug logging" \
{Switch debug logging to GaiaDebug.log on and off} \
-variable [scope itk_option(-debuglog)] \
-onvalue 1 -offvalue 0 \
-command [code $this start_debuglog_]
}
}
# Add a menubutton with the GAIA options.
public method add_gaia_menu {} {
set toolmenu_ [add_menubutton Image-Analysis]
set m $toolmenu_
configure_menubutton Image-Analysis -underline 0
add_short_help $itk_component(menubar).image-analysis \
{Image analysis menu: do astronomy with image}
add_menuitem $m cascade "Aperture photometry" \
{Perform aperture photometry on image} \
-menu [menu $m.photom]
add_menuitem $m.photom command "Results in magnitudes..." \
{Display aperture photometry toolbox (results in magnitudes)} \
-command [code $this make_toolbox magphotom] \
-accelerator {Control-m}
bind $w_ <Control-m> [code $this make_toolbox magphotom]
add_menuitem $m.photom command "Results in data counts..." \
{Display aperture photometry toolbox (results in image data units)} \
-command [code $this make_toolbox countphotom] \
-accelerator {Control-g}
bind $w_ <Control-g> [code $this make_toolbox countphotom]
add_menuitem $m cascade "Optimal photometry" \
{Perform optimal photometry on image} \
-menu [menu $m.optphotom]
add_menuitem $m.optphotom command "Results in magnitudes..." \
{Display optimal photometry toolbox (results in magnitudes)} \
-command [code $this make_toolbox magoptphotom]
add_menuitem $m.optphotom command "Results in data counts..." \
{Display optimal photometry toolbox (results in image data units)} \
-command [code $this make_toolbox countoptphotom]
add_menuitem $m command "Image regions..." \
{Perform operations on regions of image} \
-command [code $this make_toolbox ard] \
-accelerator {Control-r}
bind $w_ <Control-r> [code $this make_toolbox ard]
add_menuitem $m command "STC-S regions..." \
{Drawn STC-S regions over image} \
-command [code $this make_toolbox stcs]
add_menuitem $m command "Patch image..." \
{Realistically replace parts of image} \
-command [code $this make_toolbox patch] \
-accelerator {Control-u}
bind $w_ <Control-u> [code $this make_toolbox patch]
add_menuitem $m command "Blink images..." \
{Blink compare all the displayed images} \
-command [code $this make_toolbox blink] \
-accelerator {Control-b}
bind $w_ <Control-b> [code $this make_toolbox blink]
add_menuitem $m command "Overlay axes grid..." \
{Draw axes over image } \
-command [code $this make_toolbox astgrid 0 1] \
-accelerator {Control-t}
bind $w_ <Control-t> [code $this make_toolbox astgrid 0 1]
add_menuitem $m cascade "Astrometry calibration" \
{Create and manipulate astrometry information} \
-menu [menu $m.astrom]
if { [info exists ::env(AUTOASTROM_DIR)] } {
add_menuitem $m.astrom cascade "Automatic position matching" \
{Create and manipulate astrometry information} \
-menu [menu $m.astrom.auto]
add_menuitem $m.astrom.auto command "Simple..." \
{Create a WCS for image using AUTOASTROM} \
-command [code $this make_toolbox simpleautoastrom]
add_menuitem $m.astrom.auto command "Advanced..." \
{Create a WCS for image using AUTOASTROM} \
-command [code $this make_toolbox advancedautoastrom]
}
add_menuitem $m.astrom command "Fit to star positions..." \
{Create a WCS for image using reference positions} \
-command [code $this make_toolbox astreference] \
-accelerator {Control-k}
bind $w_ <Control-k> [code $this make_toolbox astreference]
add_menuitem $m.astrom command "Tweak an existing calibration..." \
{Use linear transforms to refine the WCS associated with this image} \
-command [code $this make_toolbox astrefine] \
-accelerator {Control-z}
bind $w_ <Control-z> [code $this make_toolbox astrefine]
add_menuitem $m.astrom command "Copy from another image..." \
{Copy a WCS from another image} \
-command [code $this make_toolbox astcopy] \
-accelerator {Control-y}
bind $w_ <Control-y> [code $this make_toolbox astcopy]
add_menuitem $m.astrom command "Type in known calibration..." \
{Define a WCS for image using FITS-like description} \
-command [code $this make_toolbox astdefine] \
-accelerator {Control-w}
bind $w_ <Control-w> [code $this make_toolbox astdefine]
add_menuitem $m cascade "Change coordinates" \
{Change the secondary (alpha/delta) coordinate system} \
-menu [menu $m.coords]
add_menuitem $m.coords command "Built-in coordinates..." \
{Choose a coordinate system } \
-command [code $this make_toolbox astdomain]
add_menuitem $m.coords command "Show all coordinates..." \
{Display coordinates for all known systems} \
-command [code $this make_toolbox astdisplay]
add_menuitem $m.coords command "Celestial coordinates... " \
{Change the celestial coordinate system} \
-command [code $this make_toolbox astsystem]
add_menuitem $m command "Object detection... " \
{Automatically detect and parameterize objects} \
-command [code $this make_toolbox sextractor] \
-accelerator {Control-j}
bind $w_ <Control-j> [code $this make_toolbox sextractor]
add_menuitem $m command "Contouring... " \
{Contour this or another image over the displayed image...} \
-command [code $this make_toolbox contour] \
-accelerator {Control-h}
bind $w_ <Control-h> [code $this make_toolbox contour]
add_menuitem $m command "Surface photometry... " \
{Perform interactive galaxy surface photometry} \
-command [code $this make_toolbox esp] \
add_menuitem $m cascade "Positions..." \
{Select or import object positions} \
-menu [menu $m.positions]
add_menuitem $m.positions command "Select positions... " \
{Record or import object positions and measure properties} \
-command [code $this make_toolbox positions] \
add_menuitem $m.positions command "Import plain text file..." \
{Import a space or fixed width plain text file as a catalogue} \
-command [code $this import_catalogue_]
add_menuitem $m.positions command "Import CUPID catalogue..." \
{Import a CUPID catalogue selecting RA and Dec columns} \
-command [code $this import_cupid_cat_]
add_menuitem $m command "Mean X & Y profiles... " \
{Show X and Y averaged profiles of a rectangular region} \
-command [code $this make_toolbox xyprofile 0 1] \
-accelerator {Control-e}
bind $w_ <Control-e> [code $this make_xyprofile_toolbox xyprofile 0 0]
add_menuitem $m command "Histograms of XY region... " \
{Show histogram of a rectangular region} \
-command [code $this make_toolbox xyhistogram 0 1]
bind $w_ <Control-e> [code $this make_xyhistogram_toolbox xyhistogram 0 0]
add_menuitem $m command "Polarimetry toolbox... " \
{Display and manipulate POLPACK vector maps} \
-command [code $this make_toolbox polarimetry 0 1] \
add_menuitem $m command "Mask image..." \
{Display regions using an integer mask as a stencil} \