2
* Grace - GRaphing, Advanced Computation and Exploration of data
4
* Home page: http://plasma-gate.weizmann.ac.il/Grace/
6
* Copyright (c) 1991-1995 Paul J Turner, Portland, OR
7
* Copyright (c) 1996-2003 Grace Development Team
9
* Maintained by Evgeny Stambulchik
14
* This program is free software; you can redistribute it and/or modify
15
* it under the terms of the GNU General Public License as published by
16
* the Free Software Foundation; either version 2 of the License, or
17
* (at your option) any later version.
19
* This program is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
* GNU General Public License for more details.
24
* You should have received a copy of the GNU General Public License
25
* along with this program; if not, write to the Free Software
26
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31
* ticks / tick labels / axis labels
42
#include <Xm/ScrolledW.h>
48
#include "graphutils.h"
55
static Widget axes_dialog = NULL;
57
static Widget axes_tab;
59
static OptionStructure *editaxis; /* which axis to edit */
60
static Widget axis_active; /* active or not */
61
static Widget axis_zero; /* "zero" or "plain" */
62
static OptionStructure *axis_scale; /* axis scale */
63
static Widget axis_invert; /* invert axis */
64
static Widget *axis_applyto; /* override */
65
static Widget offx; /* x offset of axis in viewport coords */
66
static Widget offy; /* y offset of axis in viewport coords */
67
static Widget tonoff; /* toggle display of axis ticks */
68
static Widget tlonoff; /* toggle display of tick labels */
69
static TextStructure *axislabel; /* axis label */
70
static Widget *axislabellayout; /* axis label layout (perp or parallel) */
71
static OptionStructure *axislabelplace; /* axis label placement, auto or specified */
72
static Widget axislabelspec_rc;
73
static Widget axislabelspec_para; /* location of axis label if specified (viewport coords) */
74
static Widget axislabelspec_perp; /* location of axis label if specified (viewport coords) */
75
static OptionStructure *axislabelfont; /* axis label font */
76
static Widget axislabelcharsize;/* axis label charsize */
77
static OptionStructure *axislabelcolor; /* axis label color */
78
static Widget *axislabelop; /* tick labels normal|opposite|both sides */
79
static Widget tmajor; /* major tick spacing */
80
static SpinStructure *nminor; /* # of minor ticks */
81
static Widget *tickop; /* ticks normal|opposite|both sides */
82
static Widget *ticklop; /* tick labels normal|opposite|both sides */
83
static OptionStructure *tlform; /* format for labels */
84
static Widget *tlprec; /* precision for labels */
85
static OptionStructure *tlfont; /* tick label font */
86
static Widget tlcharsize; /* tick label charsize */
87
static OptionStructure *tlcolor; /* tick label color */
88
static Widget tlappstr; /* tick label append string */
89
static Widget tlprestr; /* tick label prepend string */
90
static Widget *tlskip; /* tick marks to skip */
91
static Widget *tlstarttype; /* use graph min or starting value */
92
static Widget tlstart; /* value to start tick labels */
93
static Widget *tlstoptype; /* use graph max or stop value */
94
static Widget tlstop; /* value to stop tick labels */
95
static OptionStructure *tlgaptype; /* tick label placement, auto or specified */
96
static Widget tlgap_rc;
97
static Widget tlgap_para; /* location of tick label if specified (viewport coords) */
98
static Widget tlgap_perp; /* location of tick label if specified (viewport coords) */
99
static Widget tlangle; /* angle */
100
static Widget *tlstagger; /* stagger */
101
static TextStructure *tlformula; /* transformation if tick labels */
102
static Widget *autonum; /* number of autotick divisions */
103
static Widget tround; /* place at rounded positions */
104
static Widget tgrid; /* major ticks grid */
105
static OptionStructure *tgridcol;
106
static SpinStructure *tgridlinew;
107
static OptionStructure *tgridlines;
108
static Widget tmgrid; /* minor ticks grid */
109
static OptionStructure *tmgridcol;
110
static SpinStructure *tmgridlinew;
111
static OptionStructure *tmgridlines;
112
static Widget tlen; /* tick length */
114
static Widget *tinout; /* ticks in out or both */
115
static Widget baronoff; /* axis bar */
116
static OptionStructure *barcolor;
117
static SpinStructure *barlinew;
118
static OptionStructure *barlines;
120
static OptionStructure *specticks; /* special ticks/labels */
121
static SpinStructure *nspec;
122
static Widget specloc[MAX_TICKS];
123
static Widget speclabel[MAX_TICKS];
124
static Widget axis_world_start;
125
static Widget axis_world_stop;
127
static void set_axis_proc(int value, void *data);
128
static void set_active_proc(int onoff, void *data);
129
static int axes_aac_cb(void *data);
130
static void axis_scale_cb(int value, void *data);
131
static void auto_spec_cb(int value, void *data);
133
void create_axes_dialog_cb(void *data)
135
create_axes_dialog(-1);
139
* Create the ticks popup
141
void create_axes_dialog(int axisno)
145
if (axisno >= 0 && axisno < MAXAXES) {
149
if (axes_dialog == NULL) {
152
OptionItem opitems[MAXAXES];
153
Widget rc_head, rc, rc2, rc3, fr, sw, axes_main, axes_label,
154
axes_ticklabel, axes_tickmark, axes_special, vbar;
156
axes_dialog = CreateDialogForm(app_shell, "Axes");
158
rc_head = CreateVContainer(axes_dialog);
159
AddDialogFormChild(axes_dialog, rc_head);
161
rc = CreateHContainer(rc_head);
162
opitems[0].value = X_AXIS;
163
opitems[0].label = "X axis";
164
opitems[1].value = Y_AXIS;
165
opitems[1].label = "Y axis";
166
opitems[2].value = ZX_AXIS;
167
opitems[2].label = "Alt X axis";
168
opitems[3].value = ZY_AXIS;
169
opitems[3].label = "Alt Y axis";
170
editaxis = CreateOptionChoice(rc, "Edit:", 0, MAXAXES, opitems);
171
AddOptionChoiceCB(editaxis, set_axis_proc, NULL);
172
axis_active = CreateToggleButton(rc, "Active");
173
AddToggleButtonCB(axis_active, set_active_proc, NULL);
175
rc = CreateHContainer(rc_head);
176
axis_world_start = CreateTextItem2(rc, 10, "Start:");
177
axis_world_stop = CreateTextItem2(rc, 10, "Stop:");
179
rc = CreateHContainer(rc_head);
181
opitems[0].value = SCALE_NORMAL;
182
opitems[0].label = "Linear";
183
opitems[1].value = SCALE_LOG;
184
opitems[1].label = "Logarithmic";
185
opitems[2].value = SCALE_REC;
186
opitems[2].label = "Reciprocal";
187
opitems[3].value = SCALE_LOGIT;
188
opitems[3].label = "Logit";
189
axis_scale = CreateOptionChoice(rc, "Scale:", 0, 4, opitems);
190
AddOptionChoiceCB(axis_scale, axis_scale_cb, NULL);
192
axis_invert = CreateToggleButton(rc, "Invert axis");
195
/* ------------ Tabs --------------*/
198
axes_tab = CreateTab(axes_dialog);
199
AddDialogFormChild(axes_dialog, axes_tab);
201
axes_main = CreateTabPage(axes_tab, "Main");
203
fr = CreateFrame(axes_main, "Axis label");
205
axislabel = CreateCSText(fr, "Label string:");
207
fr = CreateFrame(axes_main, "Tick properties");
208
rc = CreateVContainer(fr);
210
rc2 = CreateHContainer(rc);
211
tmajor = CreateTextItem2(rc2, 8, "Major spacing:");
212
nminor = CreateSpinChoice(rc2, "Minor ticks:",
213
2, SPIN_TYPE_INT, 0.0, (double) MAX_TICKS - 1, 1.0);
215
rc2 = CreateHContainer(rc);
216
tlform = CreateFormatChoice(rc2, "Format:");
217
tlprec = CreatePrecisionChoice(rc2, "Precision:");
219
fr = CreateFrame(axes_main, "Display options");
220
rc = CreateHContainer(fr);
222
rc2 = CreateVContainer(rc);
223
tlonoff = CreateToggleButton(rc2, "Display tick labels");
224
tonoff = CreateToggleButton(rc2, "Display tick marks");
226
rc2 = CreateVContainer(rc);
227
baronoff = CreateToggleButton(rc2, "Display axis bar");
229
fr = CreateFrame(axes_main, "Axis placement");
230
rc = CreateHContainer(fr);
231
axis_zero = CreateToggleButton(rc, "Zero axis");
232
offx = CreateTextItem2(rc, 6, "Offsets - Normal:");
233
offy = CreateTextItem2(rc, 6, "Opposite:");
235
fr = CreateFrame(axes_main, "Tick label properties");
236
rc = CreateHContainer(fr);
238
tlfont = CreateFontChoice(rc, "Font:");
239
tlcolor = CreateColorChoice(rc, "Color:");
242
axes_label = CreateTabPage(axes_tab, "Axis label & bar");
244
fr = CreateFrame(axes_label, "Label properties");
245
rc = CreateVContainer(fr);
247
rc2 = CreateHContainer(rc);
248
axislabelfont = CreateFontChoice(rc2, "Font:");
249
axislabelcolor = CreateColorChoice(rc2, "Color:");
251
rc2 = CreateHContainer(rc);
252
axislabelcharsize = CreateCharSizeChoice(rc2, "Char size");
253
SetScaleWidth(axislabelcharsize, 160);
255
axislabellayout = CreatePanelChoice(rc2, "Layout:",
258
"Perpendicular to axis",
261
rc2 = CreateHContainer(rc);
262
axislabelop = CreatePanelChoice(rc2, "Side:",
268
opitems[0].value = TYPE_AUTO;
269
opitems[0].label = "Auto";
270
opitems[1].value = TYPE_SPEC;
271
opitems[1].label = "Specified";
272
axislabelplace = CreateOptionChoice(rc2, "Location:", 0, 2, opitems);
273
axislabelspec_rc = CreateHContainer(rc);
274
axislabelspec_para = CreateTextItem2(axislabelspec_rc, 7, "Parallel offset:");
275
axislabelspec_perp = CreateTextItem2(axislabelspec_rc, 7, "Perpendicular offset:");
276
AddOptionChoiceCB(axislabelplace, auto_spec_cb, axislabelspec_rc);
279
fr = CreateFrame(axes_label, "Bar properties");
280
rc = CreateVContainer(fr);
282
rc2 = CreateHContainer(rc);
283
barcolor = CreateColorChoice(rc2, "Color:");
284
barlinew = CreateLineWidthChoice(rc2, "Width:");
286
barlines = CreateLineStyleChoice(rc, "Line style:");
289
axes_ticklabel = CreateTabPage(axes_tab, "Tick labels");
291
fr = CreateFrame(axes_ticklabel, "Labels");
292
rc2 = CreateHContainer(fr);
293
tlcharsize = CreateCharSizeChoice(rc2, "Char size");
294
SetScaleWidth(tlcharsize, 200);
295
tlangle = CreateAngleChoice(rc2, "Angle");
296
SetScaleWidth(tlangle, 180);
298
fr = CreateFrame(axes_ticklabel, "Placement");
299
rc = CreateHContainer(fr);
301
rc2 = CreateVContainer(rc);
302
ticklop = CreatePanelChoice(rc2, "Side:",
308
tlstagger = CreatePanelChoice(rc2, "Stagger:",
310
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
314
rc2 = CreateVContainer(rc);
315
rc3 = CreateHContainer(rc2);
316
tlstarttype = CreatePanelChoice(rc3, "Start at:",
318
"Axis min", "Specified:",
320
tlstart = CreateTextItem2(rc3, 8, "");
322
rc3 = CreateHContainer(rc2);
323
tlstoptype = CreatePanelChoice(rc3, "Stop at:",
325
"Axis max", "Specified:",
327
tlstop = CreateTextItem2(rc3, 8, "");
329
fr = CreateFrame(axes_ticklabel, "Extra");
330
rc = CreateVContainer(fr);
332
rc2 = CreateHContainer(rc);
333
tlskip = CreatePanelChoice(rc2, "Skip every:",
335
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
338
tlformula = CreateTextInput(rc2, "Axis transform:");
340
rc2 = CreateHContainer(rc);
341
tlprestr = CreateTextItem2(rc2, 13, "Prepend:");
342
tlappstr = CreateTextItem2(rc2, 13, "Append:");
344
opitems[0].value = TYPE_AUTO;
345
opitems[0].label = "Auto";
346
opitems[1].value = TYPE_SPEC;
347
opitems[1].label = "Specified";
348
tlgaptype = CreateOptionChoice(rc, "Location:", 0, 2, opitems);
349
tlgap_rc = CreateHContainer(rc);
350
tlgap_para = CreateTextItem2(tlgap_rc, 7, "Parallel offset:");
351
tlgap_perp = CreateTextItem2(tlgap_rc, 7, "Perpendicular offset:");
352
AddOptionChoiceCB(tlgaptype, auto_spec_cb, tlgap_rc);
355
axes_tickmark = CreateTabPage(axes_tab, "Tick marks");
357
fr = CreateFrame(axes_tickmark, "Placement");
358
rc2 = CreateVContainer(fr);
359
rc = CreateHContainer(rc2);
360
tinout = CreatePanelChoice(rc, "Pointing:",
364
tickop = CreatePanelChoice(rc, "Draw on:",
370
rc = CreateHContainer(rc2);
371
tround = CreateToggleButton(rc, "Place at rounded positions");
372
autonum = CreatePanelChoice(rc, "Autotick divisions",
387
rc2 = CreateHContainer(axes_tickmark);
389
/* major tick marks */
390
fr = CreateFrame(rc2, "Major ticks");
391
rc = CreateVContainer(fr);
392
tgrid = CreateToggleButton(rc, "Draw grid lines");
393
tlen = CreateCharSizeChoice(rc, "Tick length");
394
tgridcol = CreateColorChoice(rc, "Color:");
395
tgridlinew = CreateLineWidthChoice(rc, "Line width:");
396
tgridlines = CreateLineStyleChoice(rc, "Line style:");
398
fr = CreateFrame(rc2, "Minor ticks");
399
rc = CreateVContainer(fr);
400
tmgrid = CreateToggleButton(rc, "Draw grid lines");
401
tmlen = CreateCharSizeChoice(rc, "Tick length");
402
tmgridcol = CreateColorChoice(rc, "Color:");
403
tmgridlinew = CreateLineWidthChoice(rc, "Line width:");
404
tmgridlines = CreateLineStyleChoice(rc, "Line style:");
407
axes_special = CreateTabPage(axes_tab, "Special");
409
opitems[0].value = TICKS_SPEC_NONE;
410
opitems[0].label = "None";
411
opitems[1].value = TICKS_SPEC_MARKS;
412
opitems[1].label = "Tick marks";
413
opitems[2].value = TICKS_SPEC_BOTH;
414
opitems[2].label = "Tick marks and labels";
415
specticks = CreateOptionChoice(axes_special, "Special ticks:", 0, 3, opitems);
417
nspec = CreateSpinChoice(axes_special, "Number of user ticks to use:",
418
3, SPIN_TYPE_INT, 0.0, (double) MAX_TICKS, 1.0);
419
CreateLabel(axes_special, "Tick location - Label:");
421
sw = XtVaCreateManagedWidget("sw",
422
xmScrolledWindowWidgetClass, axes_special,
424
XmNscrollingPolicy, XmAUTOMATIC,
426
rc = CreateVContainer(sw);
428
for (i = 0; i < MAX_TICKS; i++) {
429
rc3 = CreateHContainer(rc);
430
sprintf(buf, "%2d", i);
431
specloc[i] = CreateTextItem4(rc3, 12, buf);
432
speclabel[i] = CreateTextItem4(rc3, 30, "");
436
SelectTabPage(axes_tab, axes_main);
439
rc = CreateVContainer(axes_dialog);
440
axis_applyto = CreatePanelChoice(rc,
444
"All axes, current graph",
445
"Current axis, all graphs",
446
"All axes, all graphs",
449
CreateAACDialog(axes_dialog, rc, axes_aac_cb, NULL);
451
/* set reasonable scrolling */
452
vbar = XtNameToWidget(sw, "VertScrollBar");
455
XtVaGetValues(vbar, XmNmaximum, &maxval, NULL);
456
XtVaSetValues(vbar, XmNincrement, (int) rint(maxval/MAX_TICKS), NULL);
461
RaiseWindow(GetParent(axes_dialog));
466
* Callback function for definition of tick marks and axis labels.
468
static int axes_aac_cb(void *data)
472
int axis_start, axis_stop, graph_start, graph_stop;
475
double axestart, axestop;
479
applyto = GetChoice(axis_applyto);
481
t = new_graph_tickmarks();
483
return RETURN_FAILURE;
486
t->active = GetToggleButtonState(axis_active);
488
t->zero = GetToggleButtonState(axis_zero);
490
if (xv_evalexpr(tmajor, &t->tmajor) != RETURN_SUCCESS) {
491
errmsg( "Specify major tick spacing" );
492
free_graph_tickmarks(t);
493
return RETURN_FAILURE;
495
t->nminor = (int) GetSpinChoice(nminor);
497
t->tl_flag = GetToggleButtonState(tlonoff);
498
t->t_flag = GetToggleButtonState(tonoff);
499
t->t_drawbar = GetToggleButtonState(baronoff);
500
set_plotstr_string(&t->label, GetTextString(axislabel));
502
xv_evalexpr(offx, &t->offsx);
503
xv_evalexpr(offy, &t->offsy);
505
t->label_layout = GetChoice(axislabellayout) ? LAYOUT_PERPENDICULAR : LAYOUT_PARALLEL;
506
t->label_place = GetOptionChoice(axislabelplace);
507
if (t->label_place == TYPE_SPEC) {
508
xv_evalexpr(axislabelspec_para, &t->label.x);
509
xv_evalexpr(axislabelspec_perp, &t->label.y);
511
t->label.font = GetOptionChoice(axislabelfont);
512
t->label.color = GetOptionChoice(axislabelcolor);
513
t->label.charsize = GetCharSizeChoice(axislabelcharsize);
515
/* somehow the value of axislabelop gets automagically correctly
516
applied to all selected axes without checking for the value of
517
applyto directly here (strange...) */
518
t->label_op = GetChoice(axislabelop);
520
t->tl_font = GetOptionChoice(tlfont);
521
t->tl_color = GetOptionChoice(tlcolor);
522
t->tl_skip = GetChoice(tlskip);
523
t->tl_prec = GetChoice(tlprec);
524
t->tl_staggered = (int) GetChoice(tlstagger);
525
strcpy(t->tl_appstr, xv_getstr(tlappstr));
526
strcpy(t->tl_prestr, xv_getstr(tlprestr));
527
t->tl_starttype = (int) GetChoice(tlstarttype) == 0 ? TYPE_AUTO : TYPE_SPEC;
528
if (t->tl_starttype == TYPE_SPEC) {
529
if(xv_evalexpr(tlstart, &t->tl_start) != RETURN_SUCCESS) {
530
errmsg( "Specify tick label start" );
531
free_graph_tickmarks(t);
532
return RETURN_FAILURE;
535
t->tl_stoptype = (int) GetChoice(tlstoptype) == 0 ? TYPE_AUTO : TYPE_SPEC;
536
if (t->tl_stoptype == TYPE_SPEC) {
537
if(xv_evalexpr(tlstop, &t->tl_stop) != RETURN_SUCCESS){
538
errmsg( "Specify tick label stop" );
539
free_graph_tickmarks(t);
540
return RETURN_FAILURE;
543
t->tl_format = GetOptionChoice(tlform);
545
t->tl_formula = copy_string(NULL, GetTextString(tlformula));
547
t->tl_gaptype = GetOptionChoice(tlgaptype);
548
if (t->tl_gaptype == TYPE_SPEC) {
549
xv_evalexpr(tlgap_para, &t->tl_gap.x);
550
xv_evalexpr(tlgap_perp, &t->tl_gap.y);
553
t->tl_angle = GetAngleChoice(tlangle);
555
t->tl_charsize = GetCharSizeChoice(tlcharsize);
557
switch ((int) GetChoice(tinout)) {
559
t->t_inout = TICKS_IN;
562
t->t_inout = TICKS_OUT;
565
t->t_inout = TICKS_BOTH;
569
t->props.color = GetOptionChoice(tgridcol);
570
t->props.linew = GetSpinChoice(tgridlinew);
571
t->props.lines = GetOptionChoice(tgridlines);
572
t->mprops.color = GetOptionChoice(tmgridcol);
573
t->mprops.linew = GetSpinChoice(tmgridlinew);
574
t->mprops.lines = GetOptionChoice(tmgridlines);
576
t->props.size = GetCharSizeChoice(tlen);
577
t->mprops.size = GetCharSizeChoice(tmlen);
579
t->t_autonum = GetChoice(autonum) + 2;
581
t->t_round = GetToggleButtonState(tround);
583
t->props.gridflag = GetToggleButtonState(tgrid);
584
t->mprops.gridflag = GetToggleButtonState(tmgrid);
586
t->t_drawbarcolor = GetOptionChoice(barcolor);
587
t->t_drawbarlinew = GetSpinChoice(barlinew);
588
t->t_drawbarlines = GetOptionChoice(barlines);
590
t->t_spec = GetOptionChoice(specticks);
591
/* only read special info if special ticks used */
592
if (t->t_spec != TICKS_SPEC_NONE) {
593
t->nticks = (int) GetSpinChoice(nspec);
594
/* ensure that enough tick positions have been specified */
595
for (i = 0; i < t->nticks; i++) {
596
if (xv_evalexpr(specloc[i], &t->tloc[i].wtpos) == RETURN_SUCCESS) {
597
cp = xv_getstr(speclabel[i]);
599
t->tloc[i].type = TICK_TYPE_MINOR;
601
t->tloc[i].type = TICK_TYPE_MAJOR;
603
if (t->t_spec == TICKS_SPEC_BOTH) {
604
t->tloc[i].label = copy_string(t->tloc[i].label, cp);
606
t->tloc[i].label = copy_string(t->tloc[i].label, NULL);
609
errmsg("Not enough tick locations specified");
610
free_graph_tickmarks(t);
611
return RETURN_FAILURE;
617
case 0: /* current axis */
618
axis_start = curaxis;
623
case 1: /* all axes, current graph */
625
axis_stop = MAXAXES - 1;
629
case 2: /* current axis, all graphs */
630
axis_start = curaxis;
633
graph_stop = number_of_graphs() - 1;
635
case 3: /* all axes, all graphs */
637
axis_stop = MAXAXES - 1;
639
graph_stop = number_of_graphs() - 1;
642
axis_start = curaxis;
649
if (xv_evalexpr(axis_world_start, &axestart) != RETURN_SUCCESS ||
650
xv_evalexpr(axis_world_stop, &axestop) != RETURN_SUCCESS) {
651
errmsg("Axis start/stop values undefined");
652
free_graph_tickmarks(t);
653
return RETURN_FAILURE;
656
for (i = graph_start; i <= graph_stop; i++) {
657
for (j = axis_start; j <= axis_stop; j++) {
659
get_graph_world(i, &w);
667
set_graph_world(i, w);
669
scale = GetOptionChoice(axis_scale);
671
set_graph_xscale(i, scale);
673
set_graph_yscale(i, scale);
676
invert = GetToggleButtonState(axis_invert);
678
set_graph_xinvert(i, invert);
680
set_graph_yinvert(i, invert);
683
t->tl_op = GetChoice(ticklop);
685
t->t_op = GetChoice(tickop);
687
set_graph_tickmarks(i, j, t);
691
free_graph_tickmarks(t);
697
return RETURN_SUCCESS;
701
* This CB services the axis "Scale" selector
703
static void axis_scale_cb(int value, void *data)
706
double major_space, axestart, axestop;
710
xv_evalexpr(tmajor, &major_space);
711
xv_evalexpr(axis_world_start, &axestart) ;
712
xv_evalexpr(axis_world_stop, &axestop);
713
auton = GetChoice(autonum) + 2;
717
if (major_space <= 0.0) {
718
sprintf(buf, "%g", (axestop - axestart)/auton);
719
xv_setstr(tmajor, buf);
723
if (axestart <= 0.0 && axestop <= 0.0) {
724
errmsg("Can't set logarithmic scale for negative coordinates");
725
SetOptionChoice(axis_scale, SCALE_NORMAL);
727
} else if (axestart <= 0.0) {
728
axestart = axestop/1.0e3;
729
sprintf(buf, "%g", axestart);
730
xv_setstr(axis_world_start, buf);
732
xv_setstr(tmajor, "10");
733
SetSpinChoice(nminor, 9);
736
if (axestart <= 0.0 && axestop <= 0.0) {
737
errmsg("Can't set logit scale for values outside 0 and 1");
738
SetOptionChoice(axis_scale, SCALE_NORMAL);
741
if (axestart <= 0.0) {
743
sprintf(buf, "%g", axestart);
744
xv_setstr(axis_world_start, buf);
746
if (axestop >= 1.0) {
748
sprintf(buf, "%g", axestop);
749
xv_setstr(axis_world_stop, buf);
751
if (major_space >= 1.0) {
752
xv_setstr(tmajor, "0.6");
759
* Fill 'Axes' dialog with values
762
void update_ticks(int gno)
769
if (axes_dialog && XtIsManaged(axes_dialog)) {
770
t = get_graph_tickmarks(gno, curaxis);
775
SetToggleButtonState(axis_active, is_axis_active(gno, curaxis));
776
if (is_axis_active(gno, curaxis) == FALSE) {
777
SetSensitive(axes_tab, False);
779
SetSensitive(axes_tab, True);
782
SetOptionChoice(editaxis, curaxis);
784
SetToggleButtonState(axis_zero, is_zero_axis(gno, curaxis));
786
get_graph_world(gno, &w);
787
if (is_xaxis(curaxis)) {
788
sprintf(buf, "%.9g", w.xg1);
789
xv_setstr(axis_world_start, buf);
790
sprintf(buf, "%.9g", w.xg2);
791
xv_setstr(axis_world_stop, buf);
792
SetOptionChoice(axis_scale, get_graph_xscale(gno));
793
SetToggleButtonState(axis_invert, is_graph_xinvert(gno));
795
sprintf(buf, "%.9g", w.yg1);
796
xv_setstr(axis_world_start, buf);
797
sprintf(buf, "%.9g", w.yg2);
798
xv_setstr(axis_world_stop, buf);
799
SetOptionChoice(axis_scale, get_graph_yscale(gno));
800
SetToggleButtonState(axis_invert, is_graph_yinvert(gno));
803
sprintf(buf, "%.4f", t->offsx);
804
xv_setstr(offx, buf);
805
sprintf(buf, "%.4f", t->offsy);
806
xv_setstr(offy, buf);
808
SetChoice(axislabellayout, t->label_layout == LAYOUT_PERPENDICULAR ? 1 : 0);
809
SetOptionChoice(axislabelplace, t->label_place);
810
sprintf(buf, "%.4f", t->label.x);
811
xv_setstr(axislabelspec_para, buf);
812
sprintf(buf, "%.4f", t->label.y);
813
xv_setstr(axislabelspec_perp, buf);
814
SetSensitive(axislabelspec_rc, t->label_place == TYPE_SPEC);
815
SetOptionChoice(axislabelfont, t->label.font);
816
SetOptionChoice(axislabelcolor, t->label.color);
817
SetCharSizeChoice(axislabelcharsize, t->label.charsize);
818
SetChoice(axislabelop, t->label_op);
820
SetToggleButtonState(tlonoff, t->tl_flag);
821
SetToggleButtonState(tonoff, t->t_flag);
822
SetToggleButtonState(baronoff, t->t_drawbar);
823
SetTextString(axislabel, t->label.s);
825
if (is_log_axis(gno, curaxis)) {
826
if (t->tmajor <= 1.0) {
829
sprintf(buf, "%g", t->tmajor);
830
} else if (is_logit_axis(gno, curaxis)) {
831
if (t->tmajor <= 0.0) {
834
else if (t->tmajor >= 0.5) {
837
sprintf(buf, "%g", t->tmajor);
838
} else if (t->tmajor > 0) {
839
sprintf(buf, "%g", t->tmajor);
841
strcpy(buf, "UNDEFINED");
843
xv_setstr(tmajor, buf);
845
SetSpinChoice(nminor, t->nminor);
847
SetOptionChoice(tlfont, t->tl_font);
848
SetOptionChoice(tlcolor, t->tl_color);
849
SetChoice(tlskip, t->tl_skip);
850
SetChoice(tlstagger, t->tl_staggered);
851
xv_setstr(tlappstr, t->tl_appstr);
852
xv_setstr(tlprestr, t->tl_prestr);
853
SetChoice(tlstarttype, t->tl_starttype == TYPE_SPEC);
854
if (t->tl_starttype == TYPE_SPEC) {
855
sprintf(buf, "%f", t->tl_start);
856
xv_setstr(tlstart, buf);
857
sprintf(buf, "%f", t->tl_stop);
858
xv_setstr(tlstop, buf);
860
SetChoice(tlstoptype, t->tl_stoptype == TYPE_SPEC);
861
if (t->tl_stoptype == TYPE_SPEC) {
862
sprintf(buf, "%f", t->tl_stop);
863
xv_setstr(tlstop, buf);
865
SetOptionChoice(tlform, t->tl_format);
866
SetChoice(ticklop, t->tl_op);
867
SetTextString(tlformula, t->tl_formula);
868
SetChoice(tlprec, t->tl_prec);
870
SetOptionChoice(tlgaptype, t->tl_gaptype);
871
sprintf(buf, "%.4f", t->tl_gap.x);
872
xv_setstr(tlgap_para, buf);
873
sprintf(buf, "%.4f", t->tl_gap.y);
874
xv_setstr(tlgap_perp, buf);
875
SetSensitive(tlgap_rc, t->tl_gaptype == TYPE_SPEC);
877
SetCharSizeChoice(tlcharsize, t->tl_charsize);
878
SetAngleChoice(tlangle, t->tl_angle);
880
switch (t->t_inout) {
882
SetChoice(tinout, 0);
885
SetChoice(tinout, 1);
888
SetChoice(tinout, 2);
892
SetChoice(tickop, t->t_op);
894
SetOptionChoice(tgridcol, t->props.color);
895
SetSpinChoice(tgridlinew, t->props.linew);
896
SetOptionChoice(tgridlines, t->props.lines);
897
SetOptionChoice(tmgridcol, t->mprops.color);
898
SetSpinChoice(tmgridlinew, t->mprops.linew);
899
SetOptionChoice(tmgridlines, t->mprops.lines);
900
SetCharSizeChoice(tlen, t->props.size);
901
SetCharSizeChoice(tmlen, t->mprops.size);
903
SetChoice(autonum, t->t_autonum - 2);
905
SetToggleButtonState(tround, t->t_round);
906
SetToggleButtonState(tgrid, t->props.gridflag);
907
SetToggleButtonState(tmgrid, t->mprops.gridflag);
909
SetOptionChoice(barcolor, t->t_drawbarcolor);
910
SetSpinChoice(barlinew, t->t_drawbarlinew);
911
SetOptionChoice(barlines, t->t_drawbarlines);
913
SetOptionChoice(specticks, t->t_spec);
914
SetSpinChoice(nspec, t->nticks);
915
for (i = 0; i < t->nticks; i++) {
916
sprintf(buf, "%.9g", t->tloc[i].wtpos);
917
xv_setstr(specloc[i], buf);
918
if (t->tloc[i].type == TICK_TYPE_MAJOR) {
919
xv_setstr(speclabel[i], t->tloc[i].label);
921
xv_setstr(speclabel[i], "");
929
static void set_active_proc(int onoff, void *data)
931
SetSensitive(axes_tab, onoff);
934
static void set_axis_proc(int value, void *data)
940
static void auto_spec_cb(int value, void *data)
942
Widget rc = (Widget) data;
943
SetSensitive(rc, value);