-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAvAxisConfig.cc
1886 lines (1647 loc) · 51.2 KB
/
AvAxisConfig.cc
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
//# --------------------------------------------------
//
//
// $Header: /home/cvs/aips++/code/trial/apps/aipsview/Attic/AvAxisConfig.cc,v 19.0 2003/07/16 05:47:59 aips2adm Exp $
//
// $Log: AvAxisConfig.cc,v $
// Revision 19.0 2003/07/16 05:47:59 aips2adm
// exhale: Base release 19.000.00
//
// Revision 18.0 2002/06/07 21:29:34 aips2adm
// exhale: Base release 18.000.00
//
// Revision 17.3 2002/01/30 22:30:30 hravlin
// Initialized a boolean var to make gcc happy.
//
// Revision 17.2 2002/01/22 21:36:27 hravlin
// Moved PtrToInt() to Av.h.
//
// Revision 17.1 2002/01/07 22:26:19 hravlin
// Removed check for __P.
//
// Revision 17.0 2001/11/12 19:43:02 aips2adm
// exhale: Base release 17.000.00
//
// Revision 16.0 2001/05/03 01:43:09 aips2adm
// exhale: Base release 16.000.00
//
// Revision 15.0 2000/10/26 17:12:35 aips2adm
// exhale: Base release 15.000.00
//
// Revision 14.1 2000/07/18 18:18:06 hravlin
// Changes to remove char * <- const char * compiler warnings.
//
// Revision 14.0 2000/03/23 16:09:05 aips2adm
// exhale: Base release 14.000.00
//
// Revision 13.3 2000/02/29 22:18:53 hravlin
// Under some circumstances, destroy() would delete markers_ twice.
//
// Revision 13.2 1999/09/24 21:01:40 hravlin
// Mostly cleanup + wasn't updating a variable in a callback.
//
// Revision 13.1 1999/08/25 20:01:12 hravlin
// Fixed problem with casting from XtPointer to enum.
// Edits (mostly casts) to remove compiler warnings.
//
// Revision 13.0 1999/08/10 18:40:55 aips2adm
// exhale: Base release 13.000.00
//
// Revision 12.0 1999/07/15 00:24:17 aips2adm
// exhale: Base release 12.000.00
//
// Revision 11.0 1998/10/03 07:02:05 aips2adm
// exhale: Base release 11.000.00
//
// Revision 10.0 1998/07/20 17:56:19 aips2adm
// exhale: Base release 10.000.00
//
// Revision 9.8 1998/05/01 21:23:15 hr
// Use Aipsview's colormap when creating widgets.
//
// Revision 9.7 1998/02/26 22:18:57 hr
// Changed some name strings and reoordered panels.
//
// Revision 9.6 1998/02/25 17:29:51 hr
// Changed label string for label color to "Text Color".
//
// Revision 9.5 1998/02/20 20:39:42 hr
// Changed user controls for positioning labels.
//
// Revision 9.4 1997/11/17 17:33:28 hr
// In axisOptions(), exchanged positions of "Set Offset.." and "Place Origin"
// buttons.
//
// Revision 9.3 1997/11/17 17:11:57 hr
// Removed some unused variables.
//
// Revision 9.2 1997/11/17 16:54:58 hr
// Added support for axis offsets and captions.
//
// Revision 9.1 1997/09/23 20:29:20 hr
// Changed the upper range of character sliders to 5.0 from 10.0.
//
// Revision 9.0 1997/08/25 21:31:29 aips2adm
// exhale: Base release 09.000.00
//
// Revision 8.9 1997/08/13 20:33:25 hr
// Added readouts to character scale and line width.
//
// Revision 8.8 1997/06/25 16:49:01 hr
// Made the default panel Global instead of XAxis.
//
// Revision 8.7 1997/05/07 21:32:29 hr
// Replaced Gadgets with Widgets.
//
// Revision 8.6 1997/04/28 17:14:30 hr
// Desensitize Marker toggle button when there are no markers.
// Motif 2.x seems to turn on/off radio buttons in a different order from
// 1.x so needed to modify panel management for 2.x.
//
// Revision 8.5 1997/04/25 16:02:30 hr
// Changed layout for curvilinear axis. Added "Use Global Color Selector" button.
//
// Revision 8.4 1997/04/24 20:41:11 hr
// Reformatted axis layout for grid labels.
//
// Revision 8.3 1997/04/23 19:47:55 hr
// Changed grid color toggle label to "Grid Color".
//
// Revision 8.2 1997/04/23 17:46:14 hr
// Cleaned up some DCC compiler warnings.
//
// Revision 8.1 1997/04/23 17:12:19 hr
// Changes to support options for drawing curvilinear axes.
//
// Revision 8.0 1997/02/20 03:19:21 aips2adm
// exhale: Base release 08.000.00
//
// Revision 7.7 1997/02/10 21:00:46 hr
// Marker type selector switched from slider to toggles.
//
// Revision 7.6 1997/02/10 16:04:23 hr
// Removed an assignment to an unused widget.
//
// Revision 7.5 1997/02/09 00:30:48 hr
// Removed an unused variable.
//
// Revision 7.4 1997/02/09 00:04:30 hr
// Changed from using internal to external part building routines.
//
//
//---------------------------------------------------------------------------
/* Av AxisConfig.cc
Build setup window to change axis parameters.
*/
#include <iostream.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <sys/types.h> // For stat call.
#include <sys/stat.h>
#include <errno.h>
#include <Xm/Xm.h>
#include <Xm/PushB.h>
#include <Xm/TextF.h>
#include <Xm/RowColumn.h>
#include <Xm/Label.h>
#include <Xm/Separator.h>
#include <Xm/ToggleB.h>
#include <Xm/Form.h>
#include <Xm/FileSB.h>
#include "AvAxisConfig.h"
#include "AvImageWindow.h"
#include "AvImageViewPanel.h"
#include "AvImageViewItem.h"
#include "AvGUIParts.h"
#include "AvWidgetMisc.h"
#include "Av.h"
/// Table to convert between strings and values.
// The different panels that can be displayed (one at a time).
// The ordering must follow the enum in the include file.
static IntMap Panels[] = {
{ AvAxisConfig::Global, "Global"},
{ AvAxisConfig::XYAxes, "Axes"},
{ AvAxisConfig::XAxis, "X Axis & V. Grid"},
{ AvAxisConfig::YAxis, "Y Axis & H. Grid"},
{ AvAxisConfig::XLabel, "X Label"},
{ AvAxisConfig::YLabel, "Y Label"},
{ AvAxisConfig::Title, "Title"},
{ AvAxisConfig::Markers, "Markers"},
{ AvAxisConfig::Captions, "Captions"},
{ 0, NULL}
};
// Label strings for the set marker position toggle.
static const char *TRACKMARKER = "Place Marker";
static const char *TRACKORIGIN = "Place Origin";
static const char *TRACKING = "Track Mouse ";
static const char *OFFSETTRACKING = "Origin Tracks Mouse";
// This is used to help text fields and buttons of a radioTextNotifier
// communicate with each other.
class tfHandler {
public:
tfHandler();
Widget button; // Button to turn on text field.
Widget field; // The text field.
const AvRadioTextNotifier *tfn;
static void handleTFCB(Widget, XtPointer, XtPointer);
// Called when button is pressed.
static void handleBtnCB(Widget, XtPointer, XtPointer);
void showString(const char *);
};
/////////////////////////////////
// When we want to be called.
static const int MOUSECHANGE =
AvConductor::MouseDown | AvConductor::MouseMove | AvConductor::MouseUp;
AvAxisConfig::MarkerData::MarkerData()
{
panel = NULL;
win = NULL;
marker = NULL;
}
AvAxisConfig::MarkerData::~MarkerData()
{
unlink();
}
// Connect to the image window's mouse tracker.
void AvAxisConfig::MarkerData::link()
{
if(win != NULL)
win->getTracker()->addCallback( &AvAxisConfig::markerTrackCB,
MOUSECHANGE, NULL,
(XtPointer )this);
}
// Disconnect from the image window's mouse tracker.
void AvAxisConfig::MarkerData::unlink()
{
if(win != NULL)
win->getTracker()->removeCallback(&AvAxisConfig::markerTrackCB,
MOUSECHANGE, NULL,
(XtPointer )this);
}
////////////////////////////////////////////////////////////////
AvAxisConfig::AvAxisConfig(const char *name, Widget ref, AvAxisOptions *ao,
AvImageViewItem *ivi)
{
name_ = "Setup for ";
name_ += name;
name_ += ":";
name_ += ao->config()->moduleName();
ref_ = ref;
dialog = NULL;
ivi_ = ivi; // Ivi is is being initialized, so be careful.
// The different panels that the 'Panels' buttons bring up.
for(int i=0; i < NUMPANELS; i++)
{ linPanels_[i] = NULL;
crvPanels_[i] = NULL;
}
panels_ = linPanels_;
offsetW_ = NULL;
trackOriginW_ = NULL;
captions_ = NULL;
panelNotifier_.init("Panels", NULL, NULL, Panels, 0, Global);
up_ = FALSE;
callback_ = NULL;
cbdata_ = NULL;
info_ = ao;
if(info_ != NULL)
{ info_->ref();
}
toggling_ = FALSE;
markers_ = NULL;
}
AvAxisConfig::~AvAxisConfig()
{
unlink();
popdown();
destroy(TRUE); // Get rid of any windows.
info_->unref();
// ??? Delete marker/captions??
}
// Build an option box for title, X or Y axes or captions.
Widget AvAxisConfig::labelOptions(const char *name, Widget parentW,
const AvAxisOptions::axisLabel *options)
{
// Frame around everything.
Widget radioFrame = labeledFrame(parentW, name, CENTER);
// Vertically stack contents
Widget optionsRC = XtVaCreateManagedWidget(name,
xmRowColumnWidgetClass,
radioFrame,
XmNpacking, XmPACK_TIGHT,
XmNorientation, XmVERTICAL,
NULL);
XtVaCreateManagedWidget("",
xmSeparatorWidgetClass,
optionsRC,
NULL);
////////////////////////////////////////////////////////////////
// Toggles describing how to display axis.
////////////////////////////////////////////////////////////////
// Axis text
Widget textBox = buildIntMapRadioBox(optionsRC, "label", "Label:",
&options->text_);
Widget tfW = XtVaCreateManagedWidget("axisTF",
xmTextFieldWidgetClass,
optionsRC,
XmNvalue, options->text_.getString(),
NULL);
XtAddCallback(tfW, XmNactivateCallback, &AvAxisConfig::handleTFCB,
(XtPointer) &options->text_);
// When the text field is activated, the "TextField" button needs to
// be on. When the "Default" or "TextField" buttons are pressed, the
// appropriate string should be displayed. tfHandler links them.
tfHandler *tfh = new tfHandler();
tfh->field = tfW;
tfh->tfn = &options->text_;
// Pick up the widget for the "TextField" button.
{ const AvRadioTextNotifier *rn = &options->text_;
Widget uw, dw;
int uv = rn->userValue();
int ui = rn->valueToIndex(uv);
int dv = rn->defaultValue();
int di = rn->valueToIndex(dv);
uw = childNameToWidget(textBox, rn->getName(ui));
tfh->button = uw;
XtAddCallback(uw, XmNvalueChangedCallback,
&tfHandler::handleBtnCB,
(XtPointer) tfh);
dw = childNameToWidget(textBox, rn->getName(di));
XtAddCallback(dw, XmNvalueChangedCallback,
&tfHandler::handleBtnCB,
(XtPointer) tfh);
XtAddCallback(tfW, XmNactivateCallback, &tfHandler::handleTFCB,
(XtPointer) tfh);
}
showEscapeCodes(optionsRC);
////////////////////////////////////////////////////////////////
// Axis character scale
buildDoubleSliderBox(optionsRC, "Character Scale:",
.1, 5.0, options->charScale_.getValue(), 1,
TRUE,
&options->charScale_);
////////////////////////////////////////////////////////////////
/// Label color.
////////////////////////////////////////////////////////////////
Widget colorFrame = labeledFrame(optionsRC,
"Text Color");
Widget colorRC = XtVaCreateManagedWidget("colorRC",
xmRowColumnWidgetClass,
colorFrame,
XmNpacking, XmPACK_TIGHT,
XmNorientation, XmVERTICAL,
NULL);
Widget colorBtnRC = XtVaCreateManagedWidget("colorBtnRC",
xmRowColumnWidgetClass,
colorRC,
XmNpacking, XmPACK_TIGHT,
XmNorientation, XmHORIZONTAL,
NULL);
// Should grid color track global or use the selector?
buildToggleButton(colorBtnRC, "Use Global Color Selector",
&options->useGlobalColor_);
buildToggleButton(colorBtnRC, "Opaque Background",
&options->opaqueBackground_);
buildColorSelector(colorRC, "color", NULL,
&options->color_);
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
// Text position
Widget placementFrame = labeledFrame(optionsRC,
"Text Placement:", LEFT);
Widget placementRC = XtVaCreateManagedWidget("placementRC",
xmRowColumnWidgetClass,
placementFrame,
XmNorientation, XmVERTICAL,
// XmNpacking, XmPACK_TIGHT,
// XmNpacking, XmPACK_COLUMN,
NULL);
buildDoubleSliderBox(placementRC, "X",
-2.0, 2.0, options->x_.getValue(), 2,
TRUE,
&options->x_);
buildDoubleSliderBox(placementRC, "Y",
-2.0, 2.0, options->y_.getValue(),2,
TRUE,
&options->y_);
// Since the angle slider is wider than normal, move the label
// above it.
Widget w = buildDoubleSliderBox(placementRC, "Angle:",
-180.0, 180.0, options->angle_.getValue(),0,
TRUE,
&options->angle_);
{ Widget slider = childNameToWidget(w, "slider");
if(slider != NULL)
{ Dimension width;
XtVaGetValues(slider,
XmNscaleWidth, &width,
NULL);
XtVaSetValues(slider,
XmNscaleWidth, 370,
NULL);
}
XtVaSetValues(w,
XmNorientation, XmVERTICAL,
XmNpacking, XmPACK_TIGHT,
NULL);
}
return radioFrame;
}
// Builds the tick mark controls.
void AvAxisConfig::tickMarks(const char *name, Widget parent,
const AvAxisOptions::axis *options,
const Boolean linearAxis)
{
Widget boxRC = XtVaCreateManagedWidget(name,
xmRowColumnWidgetClass,
parent,
XmNpacking, XmPACK_TIGHT,
XmNorientation, XmVERTICAL,
NULL);
/////////////////////////////////////////////////////////////////
// Major tick marks
XtVaCreateManagedWidget("Major tick intervals",
xmLabelWidgetClass,
boxRC,
NULL);
Widget majorRC = XtVaCreateManagedWidget(name,
xmRowColumnWidgetClass,
boxRC,
XmNpacking, XmPACK_TIGHT,
XmNorientation, XmHORIZONTAL,
NULL);
buildIntMapRadioBox(majorRC, "majorTicks", NULL,
linearAxis ? &options->linMajor_ :
&options->crvMajor_);
// int maxticks = (linearAxis) ? 12 : 24;
int maxticks = 24;
const AvIntegerNotifier *major = (linearAxis)
? &options->linMajorIntervals_
: &options->crvMajorIntervals_;
buildIntegerSliderBox(majorRC, NULL,
1, maxticks, major->getValue(),
FALSE, major);
/////////////////////////////////////////////////////////////////
// Minor tick marks
if(linearAxis)
{ XtVaCreateManagedWidget("Minor tick intervals",
xmLabelWidgetClass,
boxRC,
NULL);
Widget minorRC = XtVaCreateManagedWidget(name,
xmRowColumnWidgetClass,
boxRC,
XmNpacking, XmPACK_TIGHT,
XmNorientation, XmHORIZONTAL,
NULL);
buildIntMapRadioBox(minorRC, "minorTicks", NULL,
&options->minor_);
buildIntegerSliderBox(minorRC, NULL,
0, 10,
options->linMinorIntervals_.getValue(),
FALSE, &options->linMinorIntervals_);
}
}
// Builds the "Grid and TickMarks panel.
Widget AvAxisConfig::linAxisOptions(const char *name, Widget parentW,
const AvAxisOptions::axis *options)
{
Widget radioFrame = labeledFrame(parentW, name, CENTER);
// Vertically stack contents
Widget optionsRC = XtVaCreateManagedWidget(name,
xmRowColumnWidgetClass,
radioFrame,
XmNpacking, XmPACK_TIGHT,
XmNorientation, XmVERTICAL,
NULL);
/// Grid and Tickmarks.
Widget axisFrame = labeledFrame(optionsRC, "Grid & TickMarks");
Widget axisRC = XtVaCreateManagedWidget(name,
xmRowColumnWidgetClass,
axisFrame,
XmNpacking, XmPACK_TIGHT,
XmNorientation, XmVERTICAL,
NULL);
Widget axisOptionsRC = XtVaCreateManagedWidget(name,
xmRowColumnWidgetClass,
axisRC,
XmNpacking, XmPACK_COLUMN,
XmNorientation, XmHORIZONTAL,
XmNnumColumns, 3,
NULL);
buildIntMapRadioBox(axisOptionsRC, "drawzeroline",
"Draw Zero Line", &options->drawZeroLine_);
tickMarks("tickmarks", axisRC, options, TRUE);
Widget labellingFrame = labeledFrame(optionsRC, "Labels");
Widget labellingRC = XtVaCreateManagedWidget(name,
xmRowColumnWidgetClass,
labellingFrame,
XmNpacking, XmPACK_TIGHT,
XmNorientation, XmVERTICAL,
NULL);
// This is only relevant for Y axis labels.
if(options->typeMask() == AvAxisOptions::YAXIS)
buildToggleButton(labellingRC, "Vertical",
&options->vertical_);
buildIntMapRadioBox(labellingRC, "labelingBox", "Format:",
&options->decimal_);
buildIntMapRadioBox(labellingRC, "position", "Placement",
&options->position_);
return radioFrame;
}
Widget formatFrame=NULL;
// Builds the Panel for selecting options common to both axes.
Widget AvAxisConfig::axesOptions(const char *name, Widget parentW)
{
Widget axesFrame = labeledFrame(parentW, name, CENTER);
XtVaSetValues( axesFrame,
XmNbottomAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
NULL);
// Vertically stack contents
Widget axesRC = XtVaCreateManagedWidget("axesRC",
xmRowColumnWidgetClass,
axesFrame,
XmNpacking, XmPACK_TIGHT,
XmNorientation, XmVERTICAL,
XmNcolumns, 1,
NULL);
/// Frame and Grid toggles.
// Horizontally stack buttons.
Widget axisTogglesRC = XtVaCreateManagedWidget("axisTogglesRC",
xmRowColumnWidgetClass,
axesRC,
XmNpacking, XmPACK_TIGHT,
XmNorientation, XmHORIZONTAL,
NULL);
buildToggleButton(axisTogglesRC, "Draw Frame", &info_->gDrawFrame_);
buildToggleButton(axisTogglesRC, "Draw Grid", &info_->gDrawGrid_);
// Currently, the only time we can't use curvilinear mode is when
// displaying the wedge.
if(mayUseCurvilinear())
{ // What type of axis to use.
Widget w = buildIntMapRadioBox(axesRC, "axisBox", "Axis Type:",
&info_->gAxisType_, (XtPointer) this,
&AvAxisConfig::handleAxisTypeCB);
Widget rc= childNameToWidget(w, "axisBox");
XtVaSetValues(rc,
XmNnumColumns, 2,
NULL);
formatFrame = labeledFrame(axesRC, "Offset Format");
offsetW_ = formatFrame;
// Vertically stack contents
Widget offsetRC = XtVaCreateManagedWidget("offsetRC",
xmRowColumnWidgetClass,
formatFrame,
XmNpacking, XmPACK_TIGHT,
XmNorientation, XmVERTICAL,
XmNcolumns, 1,
NULL);
buildIntMapRadioBox(offsetRC, "axisFormatBox",
"Linear Offset Formats:",
&info_->gLinearAxisFormat_,
(XtPointer) this);
Widget miscRC = XtVaCreateManagedWidget("miscRC",
xmRowColumnWidgetClass,
offsetRC,
XmNpacking, XmPACK_TIGHT,
XmNorientation, XmHORIZONTAL,
// XmNcolumns, 1,
NULL);
Widget resetW = XtVaCreateManagedWidget("Set Offset to Center",
xmPushButtonWidgetClass,
miscRC,
NULL);
XtAddCallback( resetW, XmNactivateCallback,
&AvAxisConfig::resetOffsetCB,
(XtPointer) this);
// The "track" toggle. When set, the callback will link
// the positioning CB to the tracker.
w = XtVaCreateManagedWidget(TRACKORIGIN,
xmToggleButtonWidgetClass,
miscRC,
XmNset, False,
XmNborderWidth, 1,
XmNshadowThickness, 1,
NULL);
trackOriginW_ = w;
XtAddCallback( w, XmNvalueChangedCallback,
&AvAxisConfig::handleOffsetCB,
(XtPointer) this);
// Turn off offset formats if LINEAROFFSET isn't the default.
if(info_->gAxisType_.getValue() != AvAxisOptions::LINEAROFFSET)
XtSetSensitive(offsetW_, FALSE);
else
{ makeAxisLabels(OFFSET);
info_->gAxisType_.notify(); // Force a redraw.
}
buildToggleButton(offsetRC, "Offset Only Angular Positions",
&info_->gAngularOnly_,
(XtPointer) this,
&AvAxisConfig::angularCB,
GUICB_AFTER); // Put default cb after ours.
}
return axesFrame;
}
// Builds the axis panel for curvilinear axes.
Widget AvAxisConfig::crvAxisOptions(const char *name, Widget parentW,
const AvAxisOptions::axis *options)
{
Widget radioFrame = labeledFrame(parentW, name, CENTER);
// Vertically stack contents
Widget optionsRC = XtVaCreateManagedWidget(name,
xmRowColumnWidgetClass,
radioFrame,
XmNpacking, XmPACK_TIGHT,
XmNorientation, XmVERTICAL,
NULL);
/// Grid and Tickmarks.
Widget axisFrame = labeledFrame(optionsRC, "Grid");
Widget axisRC = XtVaCreateManagedWidget(name,
xmRowColumnWidgetClass,
axisFrame,
XmNpacking, XmPACK_TIGHT,
XmNorientation, XmVERTICAL,
NULL);
tickMarks("tickmarks", axisRC, options, FALSE);
Widget colorFrame = labeledFrame(optionsRC,
"Grid/Tick Color");
Widget colorRC = XtVaCreateManagedWidget("colorRC",
xmRowColumnWidgetClass,
colorFrame,
XmNpacking, XmPACK_TIGHT,
XmNorientation, XmVERTICAL,
NULL);
// Should grid color track global or use the selector?
buildToggleButton(colorRC, "Use Global Color Selector",
&options->useGlobalColor_);
// name and label need to be spelled differently.
buildColorSelector(colorRC, "color", NULL,
&options->color_);
////////////////////////////////////////////////////////////////
/// Grid/Tick mark labels.
Widget gridTickFrame = labeledFrame(optionsRC,
"Numerical Coordinates");
Widget gridTickRC = XtVaCreateManagedWidget(name,
xmRowColumnWidgetClass,
gridTickFrame,
XmNpacking, XmPACK_TIGHT,
XmNorientation, XmVERTICAL,
NULL);
buildToggleButton(gridTickRC, "Label Color Tracks Grid/Tick Color",
&options->labelTracksGrid_);
buildIntMapRadioBox(gridTickRC, "format", "Format",
&options->format_);
// The extra RC box helps get the label aligned.
Widget axisPlacementRC = XtVaCreateManagedWidget(name,
xmRowColumnWidgetClass,
gridTickRC,
XmNpacking, XmPACK_COLUMN,
XmNorientation, XmVERTICAL,
XmNpacking, XmPACK_TIGHT,
NULL);
XtVaCreateManagedWidget("Placement",
xmLabelWidgetClass,
axisPlacementRC,
// XmNalignment, XmALIGNMENT_CENTER,
// XmNalignment, XmALIGNMENT_BEGINNING,
NULL);
Widget labellingRC = XtVaCreateManagedWidget(name,
xmRowColumnWidgetClass,
axisPlacementRC,
XmNpacking, XmPACK_TIGHT,
XmNorientation, XmHORIZONTAL,
NULL);
buildToggleButton(labellingRC, "Top",
&options->top_);
buildToggleButton(labellingRC, "Bottom",
&options->bottom_);
buildToggleButton(labellingRC, "Left",
&options->left_);
buildToggleButton(labellingRC, "Right",
&options->right_);
return radioFrame;
}
// Build a marker panel for marker 'index'. Since placement is dependent
// on being able to track the mouse, if there is no ImageViewPanel, tracking
// isn't supported.
Widget AvAxisConfig::buildMarkerPanel(const char *, Widget parent,
const AvAxisOptions *info,
const int index)
{char buf[64];
const AvAxisOptions::marker *marker = info->getMarkerOptions(index);
sprintf(buf, "Marker_%02d", marker->markerIndex_);
Widget markerFrame = labeledFrame(parent, buf);
XtVaSetValues(markerFrame,
XmNbottomAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
NULL);
Widget markerRC = XtVaCreateWidget("markerRC",
xmRowColumnWidgetClass,
markerFrame,
XmNorientation, XmVERTICAL,
XmNpacking, XmPACK_TIGHT,
// XmNpacking, XmPACK_COLUMN,
// XmNpacking, XmPACK_NONE,
XmNnumColumns, 1,
NULL);
Widget showPlaceRC = XtVaCreateManagedWidget("showPlaceRC",
xmRowColumnWidgetClass,
markerRC,
XmNorientation, XmHORIZONTAL,
XmNpacking, XmPACK_TIGHT,
// XmNpacking, XmPACK_COLUMN,
// XmNpacking, XmPACK_NONE,
XmNnumColumns, 1,
NULL);
buildToggleButton(showPlaceRC, "Show Marker", &marker->show_);
// The "track" toggle. When set, the callback will link
// the positioning CB to the tracker.
// (This button doesn't lend itself to the buildToggleButton rtn).
if(ivi_ != NULL)
{ Widget w = XtVaCreateManagedWidget(TRACKMARKER,
xmToggleButtonWidgetClass,
showPlaceRC,
XmNset, False,
XmNborderWidth, 1,
XmNshadowThickness, 1,
NULL);
XtAddCallback( w, XmNvalueChangedCallback,
&AvAxisConfig::handleMarkerCB,
(XtPointer) &markers_[index]);
AvAccessor *a = ivi_->accessor();
// Max cursor value for computing fractional position.
markers_[index].xMax_ = (double)a->width() -1.0;
markers_[index].yMax_ = (double)a->height() -1.0;
}
else
{
markers_[index].yMax_ = 1.0;
markers_[index].xMax_ = 1.0;
}
buildDoubleSliderBox(markerRC, "Scale",
.1, 10.0, marker->scale_.getValue(), 1,
TRUE, &marker->scale_);
// Build a radio box for the marker type toggles.
buildMarkerSelector(markerRC, "Type", "Marker Type:",
&marker->type_);
markers_[index].panel = markerFrame;
if(ivi_ != NULL)
markers_[index].win = ivi_->getImageWindow();
else
markers_[index].win = NULL;
markers_[index].marker = marker;
// name and label need to be spelled differently.
buildColorSelector(markerRC, "color", "Color", &marker->color_);
XtManageChild(markerRC);
return markerFrame;
}
////////////////////////////////////////////////////////////////
// Global Options Panel
////////////////////////////////////////////////////////////////
Widget AvAxisConfig::buildGlobalsPanel(const char *name, Widget parent)
{
Widget globalFrame = labeledFrame(parent, name, CENTER);
XtVaSetValues( globalFrame,
XmNbottomAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
NULL);
// Vertically stack contents
Widget globalRC = XtVaCreateManagedWidget("globalRC",
xmRowColumnWidgetClass,
globalFrame,
XmNpacking, XmPACK_TIGHT,
XmNorientation, XmVERTICAL,
XmNcolumns, 1,
NULL);
////////////////////////////////////////////////////////////////
/// Generic
Widget gFrame = labeledFrame(globalRC, "Generic", LEFT);
// Vertically stack contents
Widget genericRC = XtVaCreateManagedWidget("genericRC",
xmRowColumnWidgetClass,
gFrame,
XmNpacking, XmPACK_TIGHT,
XmNorientation, XmVERTICAL,
NULL);
// Axis Font
buildIntMapRadioBox(genericRC, "fontBox", "Font:", &info_->gFont_);
// Line Width
buildIntegerSliderBox(genericRC, "Line Width",
1, 20, info_->gLineWidth_.getValue(),
TRUE, &info_->gLineWidth_);
// Global char scale.
////////////////////////////////////////////////////////////////
// Axis character scale
buildDoubleSliderBox(genericRC, "Character Scale:",
.1, 5.0, info_->gCharScale_.getValue(), 1,
TRUE,
&info_->gCharScale_);
/// Global color selector. And frame/grid color.
buildColorSelector(genericRC,
"axisColors", "Global Color Selector/Frame & Grid Color",
&info_->gAxisColor_);
////////////////////////////////////////////////////////////////
//// Label specific global parameters.
Widget labelFrame = labeledFrame(globalRC, "Label Specific", LEFT);
Widget labelRC = XtVaCreateManagedWidget("labelRC",
xmRowColumnWidgetClass,
labelFrame,
XmNorientation, XmVERTICAL,
NULL);
/// A couple of toggles. OK, only 1 for now.
// Horizontally stack buttons.
Widget labelTogglesRC = XtVaCreateManagedWidget("labelTogglesRC",
xmRowColumnWidgetClass,
labelRC,
XmNpacking, XmPACK_TIGHT,
XmNorientation, XmHORIZONTAL,
NULL);
buildToggleButton(labelTogglesRC, "Show Labels", &info_->gDrawLabels_);
return globalFrame;
}
// Attach each panel to the 4 sides of the frame.
static void attachPanels(Widget *panels, const int numpanels)
{
for(int i=0; i< numpanels; i++)
{ if(panels[i] == NULL)
continue;
else
XtVaSetValues(panels[i],
XmNbottomAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
NULL);
}
}
// Builds all marker panels.
Widget AvAxisConfig::buildMarkerPanels(const char *name, Widget parent)
{ Widget markersRC = NULL, markerPanel=NULL;
int numMarkers = info_->numMarkers();
if(numMarkers > 0)
{
markerPanel = labeledFrame(parent, name, CENTER);
markersRC = XtVaCreateWidget("markersTogglesRC",
xmRowColumnWidgetClass,
markerPanel,
XmNorientation, XmVERTICAL,
NULL);
XtVaCreateManagedWidget("",
xmSeparatorWidgetClass,
markersRC,
NULL);
// Choose which marker panel to display.
if(numMarkers > 1)
buildSliderBox(markersRC, "Marker #",
0, numMarkers-1, 0, 0, FALSE,
this, &AvAxisConfig::handleChooseMarkerCB);
// Form widget to hold the different editing panels.
Widget markerForm = XtVaCreateManagedWidget("MarkerForm",
xmFormWidgetClass,
markersRC,
NULL);
// Array to hold references to the sub panels.
markers_ = new MarkerData[numMarkers];
// Turn off all but one of the subpanels.
for(int mn=0; mn< numMarkers; mn++)
{ // Also fills in markers_[mn].
buildMarkerPanel("marker", markerForm, info_, mn);
XtUnmanageChild(markers_[mn].panel);
}
XtManageChild(markers_[0].panel);
if(markersRC != NULL)
XtManageChild(markersRC);