-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAvImageViewPanel.cc
More file actions
1791 lines (1604 loc) · 51.4 KB
/
AvImageViewPanel.cc
File metadata and controls
1791 lines (1604 loc) · 51.4 KB
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
//# Copyright (C) 1995-2002 Board of Trustees of the University of Illinois
//#
//# This software, both binary and source, is copyrighted by The
//# Board of Trustees of the University of Illinois. Ownership
//# remains with the University. You should have received a copy
//# of a licensing agreement with this software. See the file
//# "AIPSVIEW_COPYRIGHT", or contact the University at this address:
//#
//# The NCSA AipsView Visualization System
//# National Center for Supercomputing Applications
//# University of Illinois
//# 405 North Mathews Ave.
//# Urbana, IL 61801
//# aipsview@ncsa.uiuc.edu
//# --------------------------------------------------
//
// $Header: /home/cvs/aips++/code/trial/apps/aipsview/Attic/AvImageViewPanel.cc,v 19.0 2003/07/16 05:47:38 aips2adm Exp $
//
// $Log: AvImageViewPanel.cc,v $
// Revision 19.0 2003/07/16 05:47:38 aips2adm
// exhale: Base release 19.000.00
//
// Revision 18.0 2002/06/07 21:29:17 aips2adm
// exhale: Base release 18.000.00
//
// Revision 17.3 2002/01/22 21:58:23 hravlin
// Made infoMenuLen a uInt. Gave some widgets non-empty names.
//
// Revision 17.2 2002/01/09 18:18:44 hravlin
// Changed references to MAXVALUE to FLOATMAX which is defined in Av.h.
//
// Revision 17.1 2002/01/07 22:31:50 hravlin
// Removed check for __P.
//
// Revision 17.0 2001/11/12 19:42:46 aips2adm
// exhale: Base release 17.000.00
//
// Revision 16.0 2001/05/03 01:42:52 aips2adm
// exhale: Base release 16.000.00
//
// Revision 15.1 2000/12/21 20:20:36 hravlin
// Removed a call to vItem_.showSlice() that now causes an extra redraw.
//
// Revision 15.0 2000/10/26 17:11:47 aips2adm
// exhale: Base release 15.000.00
//
// Revision 14.1 2000/07/18 16:48:01 hravlin
// Changes to remove char * <- const char * compiler warnings.
//
// Revision 14.0 2000/03/23 16:08:44 aips2adm
// exhale: Base release 14.000.00
//
// Revision 13.2 1999/10/01 21:57:00 hravlin
// *** empty log message ***
//
// Revision 13.1 1999/08/25 19:48:06 hravlin
// Edits (mostly casts) to remove compiler warnings.
//
// Revision 13.0 1999/08/10 18:40:33 aips2adm
// exhale: Base release 13.000.00
//
// Revision 12.0 1999/07/15 00:23:37 aips2adm
// exhale: Base release 12.000.00
//
// Revision 11.0 1998/10/03 07:01:09 aips2adm
// exhale: Base release 11.000.00
//
// Revision 10.3 1998/08/26 19:45:14 hr
// setSlice() gets called recursively when animating. Removed the warning
// message.
//
// Revision 10.2 1998/08/19 21:20:54 hr
// In buildProfile(), made sure that profile setup window would have
// class name of AipsView.
//
// Revision 10.1 1998/08/04 19:36:52 hr
// AvImageViewPanel::displaySliceValue() wasn't telling XYZToWorld() that
// ijk_ was in SR values.
//
// Revision 10.0 1998/07/20 17:55:12 aips2adm
// exhale: Base release 10.000.00
//
// Revision 9.4 1998/06/18 14:40:47 hr
// Added a comment saying the egcs issues an ignorable warning in showRegion(...).
//
// Revision 9.3 1997/12/08 22:18:42 hr
// In updateReadouts(), the call to XYZToWorld wasn't saying values were SR.
//
// Revision 9.2 1997/10/29 19:57:17 hr
// Added support for profile locking.
//
// Revision 9.1 1997/09/19 21:35:38 hr
// In accessorCB(), the call to sliceStep_->setValue was passing SR, not DS values.
// If the starting plane wasn't 0, this could cause setSlice to be recursively
// called and, sometimes, apparently creating an oscillation in the display.
//
// Revision 9.0 1997/08/25 21:29:47 aips2adm
// exhale: Base release 09.000.00
//
// Revision 8.8 1997/08/12 21:39:41 hr
// In the constructor, changed check of Item_.nSlice to accessor()->depth() for deciding whether
// to create profile support.
//
// Revision 8.7 1997/08/01 21:40:24 hr
// DCC found some unused code.
//
// Revision 8.6 1997/08/01 21:12:52 hr
// Moved most of the profile code to AvProfile.cc.
//
// Revision 8.5 1997/06/23 19:58:13 hr
// In openProfileDevice(), allow user to flip axes.
//
// Revision 8.4 1997/06/16 21:46:06 hr
// Changes to print axes in scaled format (m/s -> km/s).
//
// Revision 8.3 1997/05/20 19:43:43 hr
// In constructor, needed a check for rank. In setRegion, test for rank
// was against >= 2.
//
// Revision 8.2 1997/04/23 20:52:13 hr
// Changed variables named 'end' to 'End' to make SunOs compiler happy.
//
// Revision 8.1 1997/04/15 20:00:25 hr
// Added support for displaying cursor world position in "raw" mode rather
// than formated. Increased the number of digits shown when displaying in
// formatted mode.
//
// Revision 8.0 1997/02/20 03:18:13 aips2adm
// exhale: Base release 08.000.00
//
// Revision 7.15 1997/02/17 20:05:37 hr
// setSlice() wasn't checking to make sure sliceStep_ wasn't NULL (
// that there was more than one slice).
//
// Revision 7.14 1997/02/11 21:31:01 hr
// In displayInfo() added a check to make sure profile gets created if
// user requests the profile be displayed from the current cursor position.
//
// Revision 7.13 1997/02/09 22:32:08 bglenden
// undef INVALID if defined. It can be defined mby MwmUtil.h, which can
// cause an aipsview enum to get trashed.
//
// Revision 7.12 1997/02/09 00:37:24 hr
// Removed an unused variable.
//
// Revision 7.11 1997/02/09 00:11:21 hr
// displayInfo() wasn't checking to see if sliceStep_ was NULL when
// handling oneIndexing.
// Added ability to change profile colors.
//
// Revision 7.10 1997/02/06 18:02:42 hr
// Changes to support 1 relative readouts.
//
// Revision 7.9 1997/02/05 18:08:36 hr
// __P problem.
// Removed most environment variables.
// Changes to use AvProfileOptions, overlayed profile prints and
// dumping profiles to a file.
//
// Revision 7.8 1997/02/03 21:15:54 hr
// Init was using a blank value label instead of "Value" if dataUnits()
// returned an empty string.
//
// Revision 7.7 1997/01/24 20:28:27 hr
// Added worldCursor().
// printProfile() calls PGCanvas::cpgend() rather than directly calling PGPLOT.
//
// Revision 7.6 1997/01/09 21:38:30 hr
// setSlice() had an effeciency check so it wouldn't try to reset the current
// slice. Unfortunately, this conflicts with the way AnimPanel works.
// (The image would change but no other information for included windows).
//
// Revision 7.5 1996/12/17 17:12:07 droberts
// Removed call to isnand().
//
// Revision 7.4 1996/12/12 08:32:17 droberts
// Final update from monet archive.
//
// Revision 1.16 1996/11/11 15:57:50 hr
// Changed setRegionTo() and setRegionFrom() to each make a single call
// to XYZToWorld() rather than one for each axis.
//
// Revision 1.15 1996/11/06 22:44:25 hr
// Had previously misspelled __SVR4 as __SVR.
//
// Revision 1.14 1996/11/06 17:00:47 hr
// Sun's 4.1.3 doesn't know about isnand().
// The compiler was complaining about "end" being redefined in a couple
// of places.
//
// Revision 1.13 1996/11/04 20:10:36 hr
// In printProfile(), changed to use AvString rather than char * in
// some calls to PGCanvas.
//
// Revision 1.12 1996/10/02 16:55:58 hr
// profileHandler calls imageWindow::setPositions to update any included
// windows.
//
// Revision 1.11 1996/10/02 14:55:16 hr
// Added work around for problem of displayInfo sometimes trying to display
// NaN for world position.
//
// Revision 1.10 1996/10/02 14:20:54 hr
// Initial pass at letting slice be set from profile window.
// Added initial length to AvWPosition declarations.
// Changed setSlice() to take an optional SR argument.
// Calls to accessor()->{set,get}Plane() now state slice is in DS coords.
//
// Revision 1.9 1996/10/01 16:55:45 hr
// In displayInfo(), needed to give wp an initial length.
//
// Revision 1.8 1996/09/27 16:50:47 hr
// ijk_ needed to be fully initialized.
// In printProfile(), one of the zero line y coordinates wasn't being set.
//
// Revision 1.7 1996/09/25 21:39:06 hr
// Stepper made editable again. String formatting changed in a few places.
// More work to clean up DS vs SR problems.
// displayInfo modified to not need event mask. Code to set region was moved
// elsewhere.
// getProfile was modified to work better with AvAccessor.
// Profile printing was turned on.
// The function setRegion() was added to handle region changes from ImageWindow.
//
// Revision 1.6 1996/09/20 20:19:35 pixton
// Prefixed all classes with Av
//
// Revision 1.5 1996/09/18 19:20:55 hr
// More integration with AvAccessor.
//
// Revision 1.4 1996/09/10 16:54:26 hr
// Initial changes for integration with AvAccessor & AvDataSet.
//
// Revision 1.3 1996/08/19 20:41:56 pixton
// remove g++ warnings, provided code snippets for
// future integration (search AVINTEGRATION).
//
// Revision 1.2 1996/08/14 18:57:06 hr
// Changes to remove g++ warnings (from bglenden).
//
// Revision 1.1 1996/07/11 21:31:21 pixton
// Automated Checkin
//
// Revision 1.36 1996/06/18 18:46:14 pixton
// Copyright Update
//
// Revision 1.35 1996/04/17 16:38:35 hr
// printProfile() now draws the zero line rather than let pgtbox do it.
//
// Revision 1.34 1996/04/16 20:47:20 hr
// Had a problem in the dataReadoutWindow creation.
//
// Revision 1.33 1996/04/16 20:28:43 hr
// Reordered some code, removed some unused code, added setAtWindow().
//
// Revision 1.32 1996/04/16 16:24:28 hr
// Some compilers can't handle initializations like:
// char * buffer[] = { "A","B","C" };
// Changing to "static char *..." works.
//
// Revision 1.31 1996/03/28 22:26:55 hr
// Changes to help prevent accessing non existent array entries when
// the rank is 2.
// Moved the "Printing to..." message so it is displayed after a successful
// open (printProfile()).
//
// Revision 1.30 1996/03/27 22:24:36 hr
// Wide spread changes needed to support user editing of start and end
// slice indexes.
//
// Revision 1.29 1996/03/25 18:44:30 hr
// Added ability to change line width and style and to draw as a histogram
// to drawProfile.
//
// Revision 1.28 1996/03/20 18:13:54 hr
// Replaced a strcat with strcpy in printProfile.
//
// Revision 1.27 1996/03/20 16:49:30 hr
// Moved call to displayInfo to later in constructor so profile wouldn't be
// generated until a mouse click.
// Added support to print the profile (getProfile(), printProfile()).
//
// Revision 1.26 1996/03/13 17:17:45 hr
// Added drawing of zero line to drawProfile().
//
// Revision 1.25 1996/02/09 18:22:47 hr
// Removed an erroneous static from an enum definition.
//
// Revision 1.24 1996/02/09 18:15:27 hr
// Moved menu support for Region & Profile to AvImageViewPanel and
// added check to see if Region &/or Profile should be turned on by default.
//
// Revision 1.23 1995/09/20 20:03:06 baker
// Release Beta 1.0
//
// Revision 1.23 1995/09/20 01:56:34 baker
// Release Beta 1.0
//
// Revision 1.22 1995/08/14 21:11:21 hr
// Profiles 'skip over' blanked data rather than drawing them.
// If the first point was blanked, value readout remained blank until a non
// blanked value was chosen.
//
// Revision 1.21 1995/07/28 21:03:05 hr
// Changed reference from MAXFLOAT to MAXVALUE (defined in Av.h).
//
// Revision 1.20 1995/07/26 19:41:29 hr
// Initialize dataValue_ to MAXFLOAT.
//
// Revision 1.19 1995/07/20 18:57:00 hr
// During last checkin, the file got truncated.
//
// Revision 1.18 1995/07/20 18:48:17 hr
// showRegion had accidently started deleting the AvImageViewItem it created.
//
// Revision 1.17 1995/07/20 17:19:13 hr
// Replaced use of HUGE_VAL with MAXVALUE and BLANKEDVALUE.
//
// Revision 1.16 1995/07/18 17:14:41 hr
// g++ doesn't like constructs like for(int i;;); for(i). Or buf[int &];
//
// Revision 1.15 1995/07/11 21:23:09 hr
// Call imageWindow::updateBox when "Value" or "Region" toggles change.
//
// Revision 1.14 1995/07/10 19:43:35 hr
// Added displayValue(). Changing Slice index now updates value readout.
//
// Revision 1.13 1995/06/27 16:29:15 hr
// Profile now displays blanked data using the previous value.
//
// Revision 1.12 1995/06/23 15:28:38 hr
// Changed display of blanked data to say "Blanked".
//
// Revision 1.11 1995/06/16 18:04:43 hr
// Hide region/profile if built inside parent.
// When "Show Region" or "Show Profile" is selected the first time,
// enable region/profile. Turn off when hiding, but remember for the
// next time its shown.
// displayInfo was always redrawing profile even when profiling was off.
//
// Revision 1.10 1995/06/09 19:33:01 hr
// Added show/hidePart so Region and Profile could be hidden.
//
// Revision 1.9 1995/05/18 20:58:35 hr
// The "Value" toggle in the info box is on by default
//
// Revision 1.8 1995/05/17 17:10:49 hr
// Profile: added a vertical line indicating current slice.
// min/max labels are constant width and created with g format.
// updateDisplayInfo was calling updateProfileInfo even when
// there was no profile.
//
// Revision 1.7 1995/05/12 21:20:09 hr
// Changes to data clip min/max are propagated to profile display.
//
// Revision 1.6 1995/05/02 20:31:25 pixton
// Added registration of region and location selection with the
// imageDataItem to separate the method of selection from the
// glish interpreter.
//
// Revision 1.5 1995/04/19 20:39:29 hr
// Added haveProfile_ flag so profiles aren't drawn until one exists.
//
// Revision 1.4 1995/04/19 17:18:49 hr
// setSlice checks for valid slice index.
//
// Revision 1.3 1995/04/19 14:28:22 hr
// Changes to move animation controls to inside imageView window.
// Added AvAnimPanel. Removed AvAnimCtlr.
//
// Revision 1.2 1995/04/10 21:02:55 hr
// Added support for syncronized animation.
//
// Revision 1.1 1995/03/16 19:45:22 pixton
// Initial revision
//
//
//---------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h> // getenv
#include <iostream.h>
//#include <math.h>
#include <Xm/ArrowB.h>
#include <Xm/DrawingA.h>
#include <Xm/Form.h>
#include <Xm/Label.h>
#include <Xm/Frame.h>
#include <Xm/PushB.h>
#include <Xm/RowColumn.h>
#include <Xm/Scale.h>
#include <Xm/Separator.h>
#include <Xm/TextF.h>
#include <Xm/ToggleB.h>
#include <Xm/MwmUtil.h> // The MWM_DECOR constants.
#if defined(INVALID)
// This define in MwmUtil.h can make AvImageControlPanel.h unhappy
#undef INVALID
#endif
#include "AvClipper.h"
#include "AvImageView.h"
#include "AvImageViewPanel.h"
#include "AvStepper.h"
#include "AvTable.h"
#include "AvUserComp.h"
#include "AvImageWindow.h" // for getImageWindow call.
#include "AvPosition.h"
#include "AvProfile.h"
#include "Av.h"
#ifdef PGPLOT
#include "AvProfileConfig.h"
// Menu string for opening profile setup window.
static const char *PROFILEMENU= "Profile";
#endif
#include "AvProfileOptions.h"
/* Get environment string for environment variable str.
*/
static char *getEnvStr(const char *str, char *def=NULL)
{
char *env;
env = getenv(str);
if((env == NULL) || (strlen(env) == 0))
return def;
else
return env;
}
static Boolean getEnvBoolean(const char *str, Boolean def=FALSE)
{
char *env;
env = getEnvStr(str);
if(env == NULL)
return def;
if((*env == 'T') || (*env == 't') || (*env == '1'))
return TRUE;
else
if((*env == 'F') || (*env == 'f') || (*env == '0'))
return FALSE;
return def;
}
const char * AvImageViewPanel::className () const
{
return ("AvImageViewPanel");
}
static AvMenuButtonInfo infoMenu[] = {
{ "Region", TOGGLE_BUTTON, 0},
{ "Profile", TOGGLE_BUTTON, 0},
{ "Included Profiles", TOGGLE_BUTTON, 0},
};
enum {REGIONINDEX, PROFILEINDEX, INCLUDEDPROFILEINDEX};
static const uInt infoMenuLen = (uInt)(sizeof(infoMenu)/sizeof(*infoMenu));
static const int ACCMASK = AvAccessor::DEFAULTMASK | AvDataSet::DEFAULTMASK
| AvAccessor::PLANE | AvAccessor::REGION;
AvImageViewPanel::AvImageViewPanel
(Widget parent, int buildInsideParent, AvImageViewItem & v)
: AvFormComp (parent, buildInsideParent),
vItem_ (v)
{
mode_ = 0;
gc_ = 0;
showRawPosition_ = FALSE;
sliceStep_ = NULL;
dataValue_ = -FLOATMAX; // Don't want it to be FLOATMAX.
int rank = v.accessor()->rank();
int i;
accessor()->addCallback(&AvImageViewPanel::accessorCB_,
ACCMASK, this, NULL);
// Fill in the table
// These values are mapped dataset (not subregion).
regionLeft_ = accessor()->getAxisStart(xAxis());
regionRight_ = regionLeft_ + accessor()->getAxisLength(xAxis()) -1;
regionBottom_ = accessor()->getAxisStart(yAxis());
regionTop_ = regionLeft_ + accessor()->getAxisLength(yAxis())-1;
// Current cursor position in subrange (SR) coordinates.
ijk_.resize(rank);
ijk_ = 0;
if(rank > 2)
ijk_(viewAxis()) = accessor()->getPlane();
// FEEDBACK ITEMS
int nFeedbackToggles = 3;
WidgetList feedbackToggles =
(WidgetList) XtMalloc (nFeedbackToggles * (int)sizeof (Widget));
int toggles = 0;
if(! buildInsideParent)
XtVaSetValues (parentWidget_,
XmNallowShellResize, TRUE,
XmNmwmDecorations,
MWM_DECOR_ALL |
MWM_DECOR_MENU |
MWM_DECOR_MINIMIZE |
MWM_DECOR_MAXIMIZE,
NULL);
XtVaSetValues (baseWidget_,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
NULL);
Widget parts = XtVaCreateManagedWidget
("partsRC", xmRowColumnWidgetClass, baseWidget_,
XmNorientation, XmVERTICAL,
XmNspacing, 3,
XmNmarginTop, 10,
XmNmarginWidth, 8,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_FORM,
// XmNbottomAttachment, XmATTACH_FORM,
NULL);
if (vItem_.nSlice (viewAxis()) > 1) {
Widget sliceInfo = XtVaCreateManagedWidget
("sliceInfo", xmFormWidgetClass, parts,
NULL);
buildSliceControls (sliceInfo);
XtVaCreateManagedWidget ("", xmSeparatorWidgetClass, parts, NULL);
}
Widget dataReadoutForm = XtVaCreateManagedWidget
("dataReadoutForm", xmFormWidgetClass, parts,
NULL);
feedbackToggles[toggles++] = buildDataReadout (dataReadoutForm);
XtVaCreateManagedWidget ("", xmSeparatorWidgetClass, parts, NULL);
Widget regionDefForm = XtVaCreateManagedWidget
("regionDefForm", xmFormWidgetClass, parts,
NULL);
regionForm_ = regionDefForm;
feedbackToggles[toggles++] = buildRegionDef (regionDefForm);
if(accessor()->depth() > 1) {
XtVaCreateManagedWidget ("", xmSeparatorWidgetClass, parts, NULL);
Widget profileForm = XtVaCreateManagedWidget
("", xmFormWidgetClass, parts,
NULL);
profileForm_ = profileForm;
feedbackToggles[toggles++] = buildProfile (profileForm);
}
else
{
profileForm_ = NULL;
profileToggle_ = NULL;
xProfile_ = NULL;
pgProfile_ = NULL;
#ifdef PGPLOT
pgProfile_ = NULL;
#endif
profileOptions_ = NULL;
profileSetup_ = NULL;
}
// Hide region/profile unless defaults have been set to show them.
if(builtInsideParent())
{ int hparts = HIDDENPARTS;
if(infoMenu[REGIONINDEX].buttonData != 0)
hparts &= ~REGION;
if(infoMenu[PROFILEINDEX].buttonData != 0)
hparts &= ~PROFILE;
hidePart(hparts);
}
// displayInfo(0, 0, 0);
ijk_(xAxis()) = -1; // X & Y will get set via displayInfo call below.
// This will force the change.
displayInfo(0, 0);
// add the callbacks to the toggles controlling feedback mode
for (i=0; i<toggles; i++)
XtAddCallback (feedbackToggles[i],
XmNvalueChangedCallback,
(XtCallbackProc) &AvImageViewPanel::switchModeCB,
(XtPointer) this);
}
// Turn on/off a toggle: VALUE, REGION or PROFILE. Except VALUE is never
// changed here.
void AvImageViewPanel::setPartToggle(const int mask, const Boolean on)
{
if(mask & VALUE)
{ XmToggleButtonSetState(valueToggle_, on, FALSE);
if(on)
mode_ |= UPDATE_VALUE;
else
mode_ &= ~UPDATE_VALUE;
}
if(mask & REGION)
{ XmToggleButtonSetState(regionToggle_, on, FALSE);
if(on)
mode_ |= UPDATE_REGION;
else
mode_ &= ~UPDATE_REGION;
}
if((mask & PROFILE) && (profileToggle_ != NULL))
{ XmToggleButtonSetState(profileToggle_, on, FALSE);
if(on)
mode_ |= UPDATE_PROFILE;
else
mode_ &= ~UPDATE_PROFILE;
}
}
void AvImageViewPanel::showPart_ (Widget w)
{
if( (w != NULL) && (!XtIsManaged(w)))
XtManageChild(w);
}
AvAccessor *AvImageViewPanel::accessor()const{return vItem_.accessor();}
void AvImageViewPanel::hidePart_ (Widget w)
{
if( (w != NULL) && (XtIsManaged(w)))
XtUnmanageChild(w);
}
void AvImageViewPanel::showPart (const int mask)
{
if(mask & REGION)
{ // Set the toggle to the state it had when last hidden.
setPartToggle(REGION, oRegionState_);
showPart_(regionForm_);
}
if(mask & PROFILE)
{ // Set the toggle to the state it had when last hidden.
setPartToggle(PROFILE, oProfileState_);
showPart_(profileForm_);
}
}
// Hide a part and turn it off remembering how it was set.
void AvImageViewPanel::hidePart (const int mask)
{
if(mask & REGION)
{ hidePart_(regionForm_);
oRegionState_ = doingRegion();
}
if(mask & PROFILE)
{ hidePart_(profileForm_);
oProfileState_ = doingProfile();
}
// Disable what we hide.
setPartToggle(mask, FALSE);
}
void AvImageViewPanel::showRegion (Widget, AvImageViewPanel * p, XtPointer)
{
// Create view of subregion. Since it is in its own window, it will delete
// itself.
if(p == NULL)
return;
// This causes a warning from the egcs compiler that should be ignored.
// (See above comment).
new AvImageViewItem (p->vItem_);
}
// Get around XmTextFieldSetString not taking a const char *.
static void SetXmTextFieldSetString (Widget w, const char *cs)
{ char *s = new char[strlen(cs) +1];
strcpy(s, cs);
XmTextFieldSetString(w, s);
delete [] s;
}
void AvImageViewPanel::buildSliceControls (Widget parent)
{
Widget labelWidget = XtVaCreateManagedWidget
("FontBoldItalic", xmLabelWidgetClass, parent,
XmNalignment, XmALIGNMENT_BEGINNING,
NULL);
setLabelString (labelWidget, accessor()->axisName(viewAxis()));
Widget sliceForm = XtVaCreateManagedWidget
("", xmFormWidgetClass, parent,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, labelWidget,
XmNleftOffset, 10,
XmNmarginHeight, 0,
XmNshadowThickness, 1,
XmNshadowType, XmSHADOW_IN,
NULL);
sliceWorld_ = XtVaCreateManagedWidget
("FontPlain", xmTextFieldWidgetClass, parent,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, sliceForm,
XmNleftOffset, 10,
XmNrightAttachment, XmATTACH_FORM,
XmNcolumns, 8,
XmNshadowThickness, 1,
XmNeditable, False,
NULL);
// Create the slice stepper.
int sliceIndex = accessor()->getPlane(); // Slice in SR coords.
// Index of current plane in world coordinates.
double zVal;
// It is possible for the value to depend on the X or Y value, but we
// have to choose something, so we choose 0,0.
accessor()->XYZToWorld(0, 0, sliceIndex, zAxis(), zVal);
SetXmTextFieldSetString (sliceWorld_,
accessor()->axisValueUnits(zAxis(), zVal).chars());
// Stepper showing start and end planes.
int zStart = accessor()->getAxisStart(zAxis());
int zEnd = zStart + accessor()->getAxisLength(zAxis()) - 1;
sliceStep_ = new AvStepper(sliceForm, TRUE, zStart, zEnd, TRUE);
sliceStep_->setDisplayOffset(AvImageView::oneIndexing());
sliceStep_->setValue (accessor()->getPlane(FALSE)); // In DS coords.
sliceStep_->addCallback
((AvConductorCB) &AvImageViewPanel::updateSliceCB,
AvConductor::ValueChanged,
(XtPointer) this, (XtPointer) NULL);
// In case user changes slice range.
sliceStep_->addCallback
((AvConductorCB) &AvImageViewPanel::rangeChangedCB,
AvStepper::RangeChanged,
(XtPointer) this, (XtPointer) NULL);
sliceStep_->show();
sliceIJK_ = sliceStep_->baseWidget();
XtVaSetValues (sliceIJK_,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
XmNshadowThickness, 1,
XmNshadowType, XmSHADOW_IN,
XmNmarginHeight, 0,
NULL);
}
Widget AvImageViewPanel::buildDataReadout (Widget parent)
{
// Create the "Value" toggle and start off in UPDATE_VALUE mode.
Widget dataReadoutLabel = XtVaCreateManagedWidget
("FontBoldItalic", xmToggleButtonWidgetClass, parent,
XmNuserData, UPDATE_VALUE,
XmNset, TRUE,
NULL);
// The label for the data "Value" indicator was "Value" now it's
// the data unit string. (eg. "jy/beam").
const char *value = accessor()->dataUnits();
if((value == NULL) || (strlen(value) == 0))
value = "Value";
setLabelString (dataReadoutLabel, value);
valueToggle_ = dataReadoutLabel;
mode_ |= UPDATE_VALUE;
dataReadoutValue = XtVaCreateManagedWidget
("FontPlain", xmTextFieldWidgetClass, parent,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, dataReadoutLabel,
XmNcolumns, 16,
XmNshadowThickness, 1,
XmNeditable, FALSE,
XmNcursorPositionVisible, FALSE,
NULL);
dataReadoutLocation = XtVaCreateManagedWidget
("FontPlain", xmTextFieldWidgetClass, parent,
XmNleftOffset, 8,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, dataReadoutValue,
XmNrightAttachment, XmATTACH_FORM,
XmNrightOffset, 8,
XmNcolumns, 10,
XmNshadowThickness, 1,
XmNeditable, FALSE,
XmNcursorPositionVisible, FALSE,
NULL);
Widget dataReadoutWorldLabelI = XtVaCreateManagedWidget
("FontPlain", xmLabelWidgetClass, parent,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, dataReadoutLocation,
XmNtopOffset, 8,
NULL);
setLabelString (dataReadoutWorldLabelI, accessor()->axisName(xAxis()));
dataReadoutWorldI = XtVaCreateManagedWidget
("FontPlain", xmTextFieldWidgetClass, parent,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, dataReadoutLocation,
XmNtopOffset, 4,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, dataReadoutWorldLabelI,
XmNrightAttachment, XmATTACH_POSITION,
XmNrightPosition, 49,
XmNcolumns, 10,
XmNshadowThickness, 1,
XmNeditable, FALSE,
XmNcursorPositionVisible, FALSE,
NULL);
Widget dataReadoutWorldLabelJ = XtVaCreateManagedWidget
("FontPlain", xmLabelWidgetClass, parent,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, dataReadoutLocation,
XmNtopOffset, 8,
XmNleftAttachment, XmATTACH_POSITION,
XmNleftPosition, 50,
NULL);
setLabelString (dataReadoutWorldLabelJ, accessor()->axisName(yAxis()));
dataReadoutWorldJ = XtVaCreateManagedWidget
("FontPlain", xmTextFieldWidgetClass, parent,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, dataReadoutLocation,
XmNtopOffset, 4,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, dataReadoutWorldLabelJ,
XmNrightAttachment, XmATTACH_FORM,
XmNcolumns, 15,
XmNshadowThickness, 1,
XmNeditable, FALSE,
XmNcursorPositionVisible, FALSE,
NULL);
dataReadoutWindowLocation = NULL;
// This will allow displaying the cursor X/Y location. Since it's only
// useful for debugging, you need to know the magic environment variable
// to turn it on.
#define SHOWWINDOWLOCATION
#ifdef SHOWWINDOWLOCATION
if(getEnvBoolean("AV_SHOW_XLOC"))
{
Widget dataReadoutWindowLabel = XtVaCreateManagedWidget
("FontPlain", xmLabelWidgetClass, parent,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, dataReadoutWorldLabelI,
XmNtopOffset, 4,
NULL);
setLabelString (dataReadoutWindowLabel, "Cursor x/y");
dataReadoutWindowLocation = XtVaCreateManagedWidget
("FontPlain", xmTextFieldWidgetClass, parent,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, dataReadoutWorldI,
XmNtopOffset, 6,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, dataReadoutWindowLabel,
XmNrightAttachment, XmATTACH_POSITION,
XmNrightPosition, 49,
XmNcolumns, 10,
XmNshadowThickness, 1,
XmNeditable, FALSE,
XmNcursorPositionVisible, FALSE,
NULL);
}
#endif
return (dataReadoutLabel);
}
Widget AvImageViewPanel::buildRegionDef (Widget parent)
{
// If panel will be built inside parent, enable. It will be
// turned off by the hidePart() call in constructor.
Widget regionDefLabel = XtVaCreateManagedWidget
("FontBoldItalic", xmToggleButtonWidgetClass, parent,
XmNuserData, UPDATE_REGION,
XmNset, builtInsideParent(),
NULL);
setLabelString (regionDefLabel, "Region");
regionToggle_ = regionDefLabel;
if(builtInsideParent())
mode_ |= UPDATE_REGION;
regionIJKCoords = XtVaCreateManagedWidget
("FontPlain", xmTextFieldWidgetClass, parent,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, regionDefLabel,
XmNleftOffset, 15,
XmNrightAttachment, XmATTACH_FORM,
XmNshadowThickness, 1,
XmNeditable, FALSE,
XmNcursorPositionVisible, FALSE,
NULL);
// make the table
regionTable = new AvTable (parent, TRUE, 2, 2);
// position the table's widget
Widget regionTableWidget = regionTable->baseWidget ();
XtVaSetValues (regionTableWidget,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, regionDefLabel,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
NULL);
// set the labels of the region table
static const char * defcLabels[] = {"Bottom Left", "Top Right"};
regionTable->setColumnLabels (defcLabels);
regionTable->setRowLabel(accessor()->axisName(xAxis()), 0);
regionTable->setRowLabel(accessor()->axisName(yAxis()), 1);
regionTable->setCellWidth (8);
setRegionFrom (regionLeft_, regionBottom_);
setRegionTo (regionRight_, regionTop_);
char str[128];
sprintf (str, "(%d, %d) to (%d, %d)",
regionLeft_, regionBottom_, regionRight_, regionTop_);
XmTextFieldSetString (regionIJKCoords, str);
regionTable->show();
// if this is a toplevel view, then we support region display
// in a separate window. Otherwise, we don't want this button.
if (!vItem_.subview()) {
Widget regionShowButton = XtVaCreateManagedWidget
("Display Region", xmPushButtonWidgetClass, parent,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, regionTable->baseWidget(),
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
XmNshadowThickness, 1,
NULL);
XtAddCallback (regionShowButton, XmNactivateCallback,
(XtCallbackProc) &AvImageViewPanel::showRegion,
(XtPointer) this);
}
return (regionDefLabel);
}
Widget AvImageViewPanel::buildProfile (Widget parent)
{
#ifdef PGPLOT
Widget profileRCW = XtVaCreateManagedWidget
("profileRCW", xmRowColumnWidgetClass, parent,
XmNorientation, XmHORIZONTAL,
// XmNspacing, 30,
XmNspacing, 0,
XmNmarginTop, 1,
XmNmarginWidth, 1,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
// XmNtopAttachment, XmATTACH_FORM,
// XmNbottomAttachment, XmATTACH_FORM,
NULL);
// If panel will be built inside parent, enable profiling. It will be
// turned off by the hidePart() call in constructor.
Widget profileLabel = XtVaCreateManagedWidget
("FontBoldItalic", xmToggleButtonWidgetClass, profileRCW,
XmNuserData, UPDATE_PROFILE,
XmNset, builtInsideParent(),
NULL);
setLabelString (profileLabel, "Profile");
profileToggle_ = profileLabel;
Widget lockProfileW = XtVaCreateManagedWidget
("FontBoldItalic", xmToggleButtonWidgetClass, profileRCW,
XmNuserData, LOCK_PROFILE,
// XmNset, builtInsideParent(),