~ubuntu-branches/ubuntu/raring/grace/raring

« back to all changes in this revision

Viewing changes to .pc/non-resizable-dialogs.diff/src/tickwin.c

  • Committer: Bazaar Package Importer
  • Author(s): Nicholas Breen
  • Date: 2010-06-06 14:36:06 UTC
  • mfrom: (4.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100606143606-g8rdx6m4wyg3xx8l
Tags: 1:5.1.22-7
* Replace defoma font management with new /usr/sbin/update-grace-fonts
  trigger.  Many thanks to Kenshi Muto for the implementation.
  (Closes: #542335, #583956, #583964)
  - README.Debian: Update description of font handling, eliminate all
    references to defoma.
  - control: Depends -= defoma, += fontconfig.
* grace.preinst, grace.postinst: Additionally remove code only needed for
  upgrades from truly antique (pre-oldstable) releases.
* patches/nonlinear_extended.diff: Add menu entry for Doniach-Sunjic peak
  fitting.  (Closes: #583966)
* Backed out subscript-superscript-scale.diff pending coordination with
  upstream, to avoid distro-specific incompatibilities.
* compat: Increment to debhelper v7.
* Convert to source format 3.0 (quilt).  Replace uuencoded icons with 
  their decoded PNG forms; clean out the associated decoding and patching
  logic from rules, and remove Build-Depends on sharutils and quilt.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Grace - GRaphing, Advanced Computation and Exploration of data
 
3
 * 
 
4
 * Home page: http://plasma-gate.weizmann.ac.il/Grace/
 
5
 * 
 
6
 * Copyright (c) 1991-1995 Paul J Turner, Portland, OR
 
7
 * Copyright (c) 1996-2003 Grace Development Team
 
8
 * 
 
9
 * Maintained by Evgeny Stambulchik
 
10
 * 
 
11
 * 
 
12
 *                           All Rights Reserved
 
13
 * 
 
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.
 
18
 * 
 
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.
 
23
 * 
 
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.
 
27
 */
 
28
 
 
29
/* 
 
30
 *
 
31
 * ticks / tick labels / axis labels
 
32
 *
 
33
 */
 
34
 
 
35
#include <config.h>
 
36
#include <cmath.h>
 
37
 
 
38
#include <stdio.h>
 
39
#include <stdlib.h>
 
40
 
 
41
#include <Xm/Xm.h>
 
42
#include <Xm/ScrolledW.h>
 
43
 
 
44
#include "globals.h"
 
45
#include "protos.h"
 
46
#include "utils.h"
 
47
#include "graphs.h"
 
48
#include "graphutils.h"
 
49
#include "motifinc.h"
 
50
 
 
51
#define cg get_cg()
 
52
 
 
53
static int curaxis;
 
54
 
 
55
static Widget axes_dialog = NULL;
 
56
 
 
57
static Widget axes_tab;
 
58
 
 
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 */
 
113
static Widget tmlen;
 
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;
 
119
 
 
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;
 
126
 
 
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);
 
132
 
 
133
void create_axes_dialog_cb(void *data)
 
134
{
 
135
    create_axes_dialog(-1);
 
136
}
 
137
 
 
138
/*
 
139
 * Create the ticks popup
 
140
 */
 
141
void create_axes_dialog(int axisno)
 
142
{
 
143
    set_wait_cursor();
 
144
    
 
145
    if (axisno >= 0 && axisno < MAXAXES) {
 
146
        curaxis = axisno;
 
147
    }
 
148
    
 
149
    if (axes_dialog == NULL) {
 
150
        int i;
 
151
        char buf[32];
 
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;
 
155
 
 
156
        axes_dialog = CreateDialogForm(app_shell, "Axes");
 
157
 
 
158
        rc_head = CreateVContainer(axes_dialog);
 
159
        AddDialogFormChild(axes_dialog, rc_head);
 
160
        
 
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);
 
174
        
 
175
        rc = CreateHContainer(rc_head);
 
176
        axis_world_start = CreateTextItem2(rc, 10, "Start:");
 
177
        axis_world_stop = CreateTextItem2(rc, 10, "Stop:");
 
178
 
 
179
        rc = CreateHContainer(rc_head);
 
180
 
 
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);
 
191
 
 
192
        axis_invert = CreateToggleButton(rc, "Invert axis");
 
193
        
 
194
 
 
195
        /* ------------ Tabs --------------*/
 
196
 
 
197
        
 
198
        axes_tab = CreateTab(axes_dialog); 
 
199
        AddDialogFormChild(axes_dialog, axes_tab);       
 
200
 
 
201
        axes_main = CreateTabPage(axes_tab, "Main");
 
202
 
 
203
        fr = CreateFrame(axes_main, "Axis label");
 
204
        
 
205
        axislabel = CreateCSText(fr, "Label string:");
 
206
        
 
207
        fr = CreateFrame(axes_main, "Tick properties");
 
208
        rc = CreateVContainer(fr);
 
209
 
 
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);
 
214
 
 
215
        rc2 = CreateHContainer(rc);
 
216
        tlform = CreateFormatChoice(rc2, "Format:");
 
217
        tlprec = CreatePrecisionChoice(rc2, "Precision:");
 
218
 
 
219
        fr = CreateFrame(axes_main, "Display options");
 
220
        rc = CreateHContainer(fr);
 
221
        
 
222
        rc2 = CreateVContainer(rc);
 
223
        tlonoff = CreateToggleButton(rc2, "Display tick labels");
 
224
        tonoff = CreateToggleButton(rc2, "Display tick marks");
 
225
        
 
226
        rc2 = CreateVContainer(rc);
 
227
        baronoff = CreateToggleButton(rc2, "Display axis bar");
 
228
 
 
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:");
 
234
 
 
235
        fr = CreateFrame(axes_main, "Tick label properties");
 
236
        rc = CreateHContainer(fr);
 
237
 
 
238
        tlfont = CreateFontChoice(rc, "Font:");
 
239
        tlcolor = CreateColorChoice(rc, "Color:");
 
240
 
 
241
 
 
242
        axes_label = CreateTabPage(axes_tab, "Axis label & bar");
 
243
 
 
244
        fr = CreateFrame(axes_label, "Label properties");
 
245
        rc = CreateVContainer(fr);
 
246
 
 
247
        rc2 = CreateHContainer(rc);
 
248
        axislabelfont = CreateFontChoice(rc2, "Font:");
 
249
        axislabelcolor = CreateColorChoice(rc2, "Color:");
 
250
        
 
251
        rc2 = CreateHContainer(rc);
 
252
        axislabelcharsize = CreateCharSizeChoice(rc2, "Char size");
 
253
        SetScaleWidth(axislabelcharsize, 160);
 
254
        
 
255
        axislabellayout = CreatePanelChoice(rc2, "Layout:",
 
256
                                            3,
 
257
                                            "Parallel to axis",
 
258
                                            "Perpendicular to axis",
 
259
                                            NULL);
 
260
 
 
261
        rc2 = CreateHContainer(rc);
 
262
        axislabelop = CreatePanelChoice(rc2, "Side:",
 
263
                                             4,
 
264
                                             "Normal",
 
265
                                             "Opposite",
 
266
                                             "Both",
 
267
                                             NULL);
 
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);
 
277
 
 
278
 
 
279
        fr = CreateFrame(axes_label, "Bar properties");
 
280
        rc = CreateVContainer(fr);
 
281
 
 
282
        rc2 = CreateHContainer(rc);
 
283
        barcolor = CreateColorChoice(rc2, "Color:");
 
284
        barlinew = CreateLineWidthChoice(rc2, "Width:");
 
285
        
 
286
        barlines = CreateLineStyleChoice(rc, "Line style:");
 
287
 
 
288
 
 
289
        axes_ticklabel = CreateTabPage(axes_tab, "Tick labels");
 
290
 
 
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);
 
297
 
 
298
        fr = CreateFrame(axes_ticklabel, "Placement");
 
299
        rc = CreateHContainer(fr);
 
300
 
 
301
        rc2 = CreateVContainer(rc);
 
302
        ticklop = CreatePanelChoice(rc2, "Side:",
 
303
                                    4,
 
304
                                    "Normal",
 
305
                                    "Opposite",
 
306
                                    "Both",
 
307
                                    NULL);
 
308
        tlstagger = CreatePanelChoice(rc2, "Stagger:",
 
309
                                      11,
 
310
                        "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
 
311
                                      NULL);
 
312
        
 
313
        
 
314
        rc2 = CreateVContainer(rc);
 
315
        rc3 = CreateHContainer(rc2);
 
316
        tlstarttype = CreatePanelChoice(rc3, "Start at:",
 
317
                                        3,
 
318
                                        "Axis min", "Specified:",
 
319
                                        NULL);
 
320
        tlstart = CreateTextItem2(rc3, 8, "");
 
321
 
 
322
        rc3 = CreateHContainer(rc2);
 
323
        tlstoptype = CreatePanelChoice(rc3, "Stop at:",
 
324
                                       3,
 
325
                                       "Axis max", "Specified:",
 
326
                                       NULL);
 
327
        tlstop = CreateTextItem2(rc3, 8, "");
 
328
 
 
329
        fr = CreateFrame(axes_ticklabel, "Extra");
 
330
        rc = CreateVContainer(fr);
 
331
 
 
332
        rc2 = CreateHContainer(rc);
 
333
        tlskip = CreatePanelChoice(rc2, "Skip every:",
 
334
                                   11,
 
335
                        "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
 
336
                                   NULL);
 
337
 
 
338
        tlformula = CreateTextInput(rc2, "Axis transform:");
 
339
 
 
340
        rc2 = CreateHContainer(rc);
 
341
        tlprestr = CreateTextItem2(rc2, 13, "Prepend:");
 
342
        tlappstr = CreateTextItem2(rc2, 13, "Append:");
 
343
 
 
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);
 
353
 
 
354
 
 
355
        axes_tickmark = CreateTabPage(axes_tab, "Tick marks");
 
356
 
 
357
        fr = CreateFrame(axes_tickmark, "Placement");
 
358
        rc2 = CreateVContainer(fr);
 
359
        rc = CreateHContainer(rc2);
 
360
        tinout = CreatePanelChoice(rc, "Pointing:",
 
361
                                   4,
 
362
                                   "In", "Out", "Both",
 
363
                                   NULL);
 
364
        tickop = CreatePanelChoice(rc, "Draw on:",
 
365
                                   4,
 
366
                                   "Normal side",
 
367
                                   "Opposite side",
 
368
                                   "Both sides",
 
369
                                   NULL);
 
370
        rc = CreateHContainer(rc2);
 
371
        tround = CreateToggleButton(rc, "Place at rounded positions");
 
372
        autonum = CreatePanelChoice(rc, "Autotick divisions",
 
373
                                    12,
 
374
                                    "2",
 
375
                                    "3",
 
376
                                    "4",
 
377
                                    "5",
 
378
                                    "6",
 
379
                                    "7",
 
380
                                    "8",
 
381
                                    "9",
 
382
                                    "10",
 
383
                                    "11",
 
384
                                    "12",
 
385
                                    NULL);
 
386
        
 
387
        rc2 = CreateHContainer(axes_tickmark);
 
388
 
 
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:");
 
397
 
 
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:");
 
405
 
 
406
 
 
407
        axes_special = CreateTabPage(axes_tab, "Special");
 
408
 
 
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);
 
416
 
 
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:");
 
420
 
 
421
        sw = XtVaCreateManagedWidget("sw",
 
422
                                     xmScrolledWindowWidgetClass, axes_special,
 
423
                                     XmNheight, 240,
 
424
                                     XmNscrollingPolicy, XmAUTOMATIC,
 
425
                                     NULL);
 
426
        rc = CreateVContainer(sw);
 
427
 
 
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, "");
 
433
        }
 
434
 
 
435
 
 
436
        SelectTabPage(axes_tab, axes_main);
 
437
 
 
438
         
 
439
        rc = CreateVContainer(axes_dialog);
 
440
        axis_applyto = CreatePanelChoice(rc,
 
441
                                         "Apply to:",
 
442
                                         5,
 
443
                                         "Current axis",
 
444
                                         "All axes, current graph",
 
445
                                         "Current axis, all graphs",
 
446
                                         "All axes, all graphs",
 
447
                                         NULL);
 
448
 
 
449
        CreateAACDialog(axes_dialog, rc, axes_aac_cb, NULL);
 
450
        
 
451
        /* set reasonable scrolling */
 
452
        vbar = XtNameToWidget(sw, "VertScrollBar");
 
453
        if (vbar) {
 
454
            int maxval;
 
455
            XtVaGetValues(vbar, XmNmaximum, &maxval, NULL);
 
456
            XtVaSetValues(vbar, XmNincrement, (int) rint(maxval/MAX_TICKS), NULL);
 
457
        }
 
458
    }
 
459
    update_ticks(cg);
 
460
    
 
461
    RaiseWindow(GetParent(axes_dialog));
 
462
    unset_wait_cursor();
 
463
}
 
464
 
 
465
/*
 
466
 * Callback function for definition of tick marks and axis labels.
 
467
 */
 
468
static int axes_aac_cb(void *data)
 
469
{
 
470
    int i, j;
 
471
    int applyto;
 
472
    int axis_start, axis_stop, graph_start, graph_stop;
 
473
    int scale, invert;
 
474
    tickmarks *t;
 
475
    double axestart, axestop;
 
476
    char *cp;
 
477
    world w;
 
478
    
 
479
    applyto = GetChoice(axis_applyto);
 
480
    
 
481
    t = new_graph_tickmarks();
 
482
    if (!t) {
 
483
        return RETURN_FAILURE;
 
484
    }
 
485
 
 
486
    t->active = GetToggleButtonState(axis_active);
 
487
    
 
488
    t->zero = GetToggleButtonState(axis_zero);
 
489
 
 
490
    if (xv_evalexpr(tmajor, &t->tmajor) != RETURN_SUCCESS) {
 
491
        errmsg( "Specify major tick spacing" );
 
492
        free_graph_tickmarks(t);
 
493
        return RETURN_FAILURE;
 
494
    }
 
495
    t->nminor = (int) GetSpinChoice(nminor);
 
496
 
 
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));
 
501
 
 
502
    xv_evalexpr(offx, &t->offsx);
 
503
    xv_evalexpr(offy, &t->offsy);
 
504
 
 
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);
 
510
    }
 
511
    t->label.font = GetOptionChoice(axislabelfont);
 
512
    t->label.color = GetOptionChoice(axislabelcolor);
 
513
    t->label.charsize = GetCharSizeChoice(axislabelcharsize);
 
514
 
 
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);
 
519
 
 
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;
 
533
        }
 
534
    }
 
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;
 
541
        }
 
542
    }
 
543
    t->tl_format = GetOptionChoice(tlform);
 
544
 
 
545
    t->tl_formula = copy_string(NULL, GetTextString(tlformula));
 
546
 
 
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);
 
551
    }
 
552
    
 
553
    t->tl_angle = GetAngleChoice(tlangle);
 
554
    
 
555
    t->tl_charsize = GetCharSizeChoice(tlcharsize);
 
556
 
 
557
    switch ((int) GetChoice(tinout)) {
 
558
    case 0:
 
559
        t->t_inout = TICKS_IN;
 
560
        break;
 
561
    case 1:
 
562
        t->t_inout = TICKS_OUT;
 
563
        break;
 
564
    case 2:
 
565
        t->t_inout = TICKS_BOTH;
 
566
        break;
 
567
    }
 
568
    
 
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);
 
575
    
 
576
    t->props.size = GetCharSizeChoice(tlen);
 
577
    t->mprops.size = GetCharSizeChoice(tmlen);
 
578
 
 
579
    t->t_autonum = GetChoice(autonum) + 2;
 
580
 
 
581
    t->t_round = GetToggleButtonState(tround);
 
582
    
 
583
    t->props.gridflag = GetToggleButtonState(tgrid);
 
584
    t->mprops.gridflag = GetToggleButtonState(tmgrid);
 
585
 
 
586
    t->t_drawbarcolor = GetOptionChoice(barcolor);
 
587
    t->t_drawbarlinew = GetSpinChoice(barlinew);
 
588
    t->t_drawbarlines = GetOptionChoice(barlines);
 
589
 
 
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]);
 
598
                if (cp[0] == '\0') {
 
599
                    t->tloc[i].type = TICK_TYPE_MINOR;
 
600
                } else {
 
601
                    t->tloc[i].type = TICK_TYPE_MAJOR;
 
602
                }
 
603
                if (t->t_spec == TICKS_SPEC_BOTH) {
 
604
                    t->tloc[i].label = copy_string(t->tloc[i].label, cp);
 
605
                } else {
 
606
                    t->tloc[i].label = copy_string(t->tloc[i].label, NULL);
 
607
                }
 
608
            } else {
 
609
                errmsg("Not enough tick locations specified");
 
610
                free_graph_tickmarks(t);
 
611
                return RETURN_FAILURE;
 
612
            }
 
613
        }
 
614
    }
 
615
    
 
616
    switch (applyto) {
 
617
    case 0:                     /* current axis */
 
618
        axis_start = curaxis;
 
619
        axis_stop  = curaxis;
 
620
        graph_start = cg;
 
621
        graph_stop  = cg;
 
622
        break;
 
623
    case 1:                     /* all axes, current graph */
 
624
        axis_start = 0;
 
625
        axis_stop  = MAXAXES - 1;
 
626
        graph_start = cg;
 
627
        graph_stop  = cg;
 
628
        break;
 
629
    case 2:                     /* current axis, all graphs */
 
630
        axis_start = curaxis;
 
631
        axis_stop  = curaxis;
 
632
        graph_start = 0;
 
633
        graph_stop  = number_of_graphs() - 1;
 
634
        break;
 
635
    case 3:                     /* all axes, all graphs */
 
636
        axis_start = 0;
 
637
        axis_stop  = MAXAXES - 1;
 
638
        graph_start = 0;
 
639
        graph_stop  = number_of_graphs() - 1;
 
640
        break;
 
641
    default:
 
642
        axis_start = curaxis;
 
643
        axis_stop  = curaxis;
 
644
        graph_start = cg;
 
645
        graph_stop  = cg;
 
646
        break;        
 
647
    }
 
648
        
 
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;
 
654
    }
 
655
                
 
656
    for (i = graph_start; i <= graph_stop; i++) {
 
657
        for (j = axis_start; j <= axis_stop; j++) {
 
658
        
 
659
            get_graph_world(i, &w);
 
660
            if (is_xaxis(j)) {
 
661
                w.xg1 = axestart;
 
662
                w.xg2 = axestop;
 
663
            } else {
 
664
                w.yg1 = axestart; 
 
665
                w.yg2 = axestop;
 
666
            }
 
667
            set_graph_world(i, w);
 
668
            
 
669
            scale = GetOptionChoice(axis_scale);
 
670
            if (is_xaxis(j)) {
 
671
                set_graph_xscale(i, scale);
 
672
            } else {
 
673
                set_graph_yscale(i, scale);
 
674
            }
 
675
 
 
676
            invert = GetToggleButtonState(axis_invert);
 
677
            if (is_xaxis(j)) {
 
678
                set_graph_xinvert(i, invert);
 
679
            } else {
 
680
                set_graph_yinvert(i, invert);
 
681
            }
 
682
            
 
683
            t->tl_op = GetChoice(ticklop);
 
684
 
 
685
            t->t_op = GetChoice(tickop);
 
686
 
 
687
            set_graph_tickmarks(i, j, t);
 
688
        }
 
689
    }
 
690
    
 
691
    free_graph_tickmarks(t);
 
692
    
 
693
    xdrawgraph();
 
694
 
 
695
    update_ticks(cg);
 
696
    
 
697
    return RETURN_SUCCESS;
 
698
}
 
699
 
 
700
/*
 
701
 * This CB services the axis "Scale" selector 
 
702
 */
 
703
static void axis_scale_cb(int value, void *data)
 
704
{
 
705
    int scale = value;
 
706
    double major_space, axestart, axestop;
 
707
    int auton;
 
708
    char buf[32];
 
709
    
 
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;
 
714
    
 
715
    switch (scale) {
 
716
    case SCALE_NORMAL:
 
717
        if (major_space <= 0.0) {
 
718
            sprintf(buf, "%g", (axestop - axestart)/auton);
 
719
            xv_setstr(tmajor, buf);
 
720
        }
 
721
        break;
 
722
    case SCALE_LOG:
 
723
        if (axestart <= 0.0 && axestop <= 0.0) {
 
724
            errmsg("Can't set logarithmic scale for negative coordinates");
 
725
            SetOptionChoice(axis_scale, SCALE_NORMAL);
 
726
            return;
 
727
        } else if (axestart <= 0.0) {
 
728
            axestart = axestop/1.0e3;
 
729
            sprintf(buf, "%g", axestart);
 
730
            xv_setstr(axis_world_start, buf);
 
731
        }
 
732
        xv_setstr(tmajor, "10");
 
733
        SetSpinChoice(nminor, 9);
 
734
        break;
 
735
     case SCALE_LOGIT:
 
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);
 
739
            return;
 
740
        } 
 
741
        if (axestart <= 0.0) {
 
742
            axestart = 0.1;
 
743
            sprintf(buf, "%g", axestart);
 
744
            xv_setstr(axis_world_start, buf);
 
745
        }
 
746
        if (axestop >= 1.0) {
 
747
            axestop = 0.95;
 
748
            sprintf(buf, "%g", axestop);
 
749
            xv_setstr(axis_world_stop, buf);
 
750
        }
 
751
        if (major_space >= 1.0) {
 
752
            xv_setstr(tmajor, "0.6");
 
753
        }
 
754
        break;  
 
755
    }
 
756
}
 
757
 
 
758
/*
 
759
 * Fill 'Axes' dialog with values
 
760
 */
 
761
 
 
762
void update_ticks(int gno)
 
763
{
 
764
    tickmarks *t;
 
765
    world w;
 
766
    char buf[128];
 
767
    int i;
 
768
 
 
769
    if (axes_dialog && XtIsManaged(axes_dialog)) {
 
770
        t = get_graph_tickmarks(gno, curaxis);
 
771
        if (!t) {
 
772
            return;
 
773
        }
 
774
 
 
775
        SetToggleButtonState(axis_active, is_axis_active(gno, curaxis));
 
776
        if (is_axis_active(gno, curaxis) == FALSE) {
 
777
            SetSensitive(axes_tab, False);
 
778
        } else {
 
779
            SetSensitive(axes_tab, True);
 
780
        }
 
781
 
 
782
        SetOptionChoice(editaxis, curaxis);
 
783
 
 
784
        SetToggleButtonState(axis_zero, is_zero_axis(gno, curaxis));
 
785
 
 
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));
 
794
        } else {
 
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));
 
801
        }
 
802
 
 
803
        sprintf(buf, "%.4f", t->offsx);
 
804
        xv_setstr(offx, buf);
 
805
        sprintf(buf, "%.4f", t->offsy);
 
806
        xv_setstr(offy, buf);
 
807
 
 
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);
 
819
 
 
820
        SetToggleButtonState(tlonoff, t->tl_flag);
 
821
        SetToggleButtonState(tonoff, t->t_flag);
 
822
        SetToggleButtonState(baronoff, t->t_drawbar);
 
823
        SetTextString(axislabel, t->label.s);
 
824
 
 
825
        if (is_log_axis(gno, curaxis)) {
 
826
            if (t->tmajor <= 1.0) {
 
827
                t->tmajor = 10.0;
 
828
            }
 
829
            sprintf(buf, "%g", t->tmajor);          
 
830
        } else if (is_logit_axis(gno, curaxis)) {
 
831
            if (t->tmajor <= 0.0) {
 
832
                t->tmajor = 0.1;
 
833
            }
 
834
            else if (t->tmajor >= 0.5) {
 
835
                t->tmajor = 0.4;
 
836
            }
 
837
            sprintf(buf, "%g", t->tmajor);
 
838
        } else if (t->tmajor > 0) {
 
839
            sprintf(buf, "%g", t->tmajor);
 
840
        } else {
 
841
            strcpy(buf, "UNDEFINED");
 
842
        }
 
843
        xv_setstr(tmajor, buf);
 
844
 
 
845
        SetSpinChoice(nminor, t->nminor);
 
846
 
 
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);
 
859
        }
 
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);
 
864
        }
 
865
        SetOptionChoice(tlform, t->tl_format);
 
866
        SetChoice(ticklop, t->tl_op);
 
867
        SetTextString(tlformula, t->tl_formula);
 
868
        SetChoice(tlprec, t->tl_prec);
 
869
 
 
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);
 
876
 
 
877
        SetCharSizeChoice(tlcharsize, t->tl_charsize);
 
878
        SetAngleChoice(tlangle, t->tl_angle);
 
879
 
 
880
        switch (t->t_inout) {
 
881
        case TICKS_IN:
 
882
            SetChoice(tinout, 0);
 
883
            break;
 
884
        case TICKS_OUT:
 
885
            SetChoice(tinout, 1);
 
886
            break;
 
887
        case TICKS_BOTH:
 
888
            SetChoice(tinout, 2);
 
889
            break;
 
890
        }
 
891
        
 
892
        SetChoice(tickop, t->t_op);
 
893
        
 
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);
 
902
 
 
903
        SetChoice(autonum, t->t_autonum - 2);
 
904
 
 
905
        SetToggleButtonState(tround, t->t_round);
 
906
        SetToggleButtonState(tgrid, t->props.gridflag);
 
907
        SetToggleButtonState(tmgrid, t->mprops.gridflag);
 
908
 
 
909
        SetOptionChoice(barcolor, t->t_drawbarcolor);
 
910
        SetSpinChoice(barlinew, t->t_drawbarlinew);
 
911
        SetOptionChoice(barlines, t->t_drawbarlines);
 
912
 
 
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);
 
920
            } else {
 
921
                xv_setstr(speclabel[i], "");
 
922
            }
 
923
        }
 
924
    }
 
925
}
 
926
 
 
927
 
 
928
 
 
929
static void set_active_proc(int onoff, void *data)
 
930
{
 
931
    SetSensitive(axes_tab, onoff);
 
932
}
 
933
 
 
934
static void set_axis_proc(int value, void *data)
 
935
{
 
936
    curaxis = value;
 
937
    update_ticks(cg);
 
938
}
 
939
 
 
940
static void auto_spec_cb(int value, void *data)
 
941
{
 
942
    Widget rc = (Widget) data;
 
943
    SetSensitive(rc, value);
 
944
}