1 /* @source ajgraph ************************************************************
2 **
3 ** AJAX GRAPH (ajax graphics) functions
4 **
5 ** These functions control all aspects of AJAX graphics.
6 **
7 ** @author Copyright (C) 1999 Ian Longden
8 ** @version $Revision: 1.135 $
9 ** @modified 1988-11-12 pmr First version
10 ** @modified 1999 ajb ANSI
11 ** @modified 2000-2011 Peter Rice
12 ** @modified $Date: 2012/10/25 13:18:26 $ by $Author: rice $
13 ** @@
14 **
15 ** This library is free software; you can redistribute it and/or
16 ** modify it under the terms of the GNU Lesser General Public
17 ** License as published by the Free Software Foundation; either
18 ** version 2.1 of the License, or (at your option) any later version.
19 **
20 ** This library is distributed in the hope that it will be useful,
21 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
22 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 ** Lesser General Public License for more details.
24 **
25 ** You should have received a copy of the GNU Lesser General Public
26 ** License along with this library; if not, write to the Free Software
27 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
28 ** MA 02110-1301, USA.
29 **
30 ******************************************************************************/
31
32
33 #include "ajlib.h"
34
35 #include "ajgraph.h"
36 #include "ajseq.h"
37 #include "ajmath.h"
38 #include "ajutil.h"
39
40 #include <math.h>
41 #include <limits.h>
42 #include <float.h>
43
44
45
46 #define GRAPHMAIN 1
47
48 #define AZ 28
49
50 #define GRAPH_DEBUG 1
51
52 #include "plplotP.h"
53
54
55 static void GraphArray(ajuint numofpoints,
56 float *x, float *y);
57 static void GraphArrayGaps(ajuint numofpoints,
58 float *x, float *y);
59 static void GraphArrayGapsI(ajuint numofpoints, ajint *x, ajint *y);
60 static void GraphCharScale(float size);
61 static void GraphCheckFlags(ajint flags);
62 static void GraphCheckPoints(ajint n, const PLFLT *x, const PLFLT *y);
63 static void GraphClose(void);
64 static void GraphColourBack(void);
65 static void GraphColourFore(void);
66 static void GraphDatafileNext(void);
67 static void GraphDataDraw(const AjPGraphdata graphdata);
68 static void GraphDataPrint(const AjPGraphdata graphdata);
69 static void GraphDefCharSize(float size);
70 static float GraphDistPts(float xx1, float yy1, float xx2, float yy2);
71 static void GraphDrawsetLines( ajuint numoflines,PLFLT *xx1, PLFLT *yy1);
72 static void GraphFill(ajuint numofpoints, float *x, float *y);
73 static void GraphFillPat(ajint pat);
74 static void GraphInit(AjPGraph thys);
75 static void GraphLabelTitle(const char *title, const char *subtitle);
76 static void GraphLineStyle(ajint style);
77 static void GraphNewPlplot(AjPGraph graph);
78 static void GraphDraw(const AjPGraph thys);
79 static void GraphPrint(const AjPGraph thys);
80 static void GraphOpenData(AjPGraph thys, const char *ext);
81 static void GraphOpenFile(AjPGraph thys, const char *ext);
82 static void GraphOpenSimple(AjPGraph thys, const char *ext);
83 #ifndef X_DISPLAY_MISSING
84 static void GraphOpenXwin(AjPGraph thys, const char *ext);
85 #endif
86 static void GraphPen(ajint pen, ajint red, ajint green, ajint blue);
87 static void GraphSetName(const AjPGraph thys,
88 const AjPStr txt, const char *ext);
89 static void GraphSetNumSubPage(ajuint numofsubpages);
90 static void GraphSetPen(ajint colour);
91 static void GraphSetWin(float xmin, float xmax, float ymin, float ymax);
92 static void GraphSetWin2(float xmin, float xmax, float ymin, float ymax);
93 static void GraphSubPage(ajint page);
94 static void GraphSymbols(float *xx1, float *yy1, ajuint numofdots,
95 ajint symbol);
96 static void GraphText(float xx1, float yy1, float xx2, float yy2,
97 float just, const char *text);
98 static void GraphWind(float xmin, float xmax, float ymin, float ymax);
99 static void GraphxyDisplayToBedgraph(AjPGraph thys, AjBool closeit,
100 const char *ext);
101 static void GraphxyDisplayToDas(AjPGraph thys, AjBool closeit,
102 const char *ext);
103 static void GraphxyDisplayToData(AjPGraph thys, AjBool closeit,
104 const char *ext);
105 static void GraphxyDisplayToFile(AjPGraph thys, AjBool closeit,
106 const char *ext);
107 static void GraphxyDisplayToWiggle(AjPGraph thys, AjBool closeit,
108 const char *ext);
109 static void GraphxyDisplayXwin(AjPGraph thys, AjBool closeit,
110 const char *ext);
111 static void GraphxyGeneral(AjPGraph thys, AjBool closeit);
112 static void GraphdataInit(AjPGraphdata graphdata);
113 static void GraphxyNewPlplot(AjPGraph thys);
114 static void GraphDrawarcText(PLFLT xcentre, PLFLT ycentre,
115 PLFLT Radius, PLFLT Angle, PLFLT pos,
116 const char *Text, PLFLT just);
117
118 enum AjEGraphObjectTypes { RECTANGLE, RECTANGLEFILL, TEXT, LINE};
119
120 static const char *graphColourName[] =
121 {
122 "BLACK", "RED", "YELLOW", "GREEN",
123 "AQUAMARINE", "PINK", "WHEAT",
124 "GREY", "BROWN", "BLUE", "BLUEVIOLET",
125 "CYAN", "TURQUOISE", "MAGENTA",
126 "SALMON", "WHITE"
127 };
128
129 struct graphSData
130 {
131 AjPFile File;
132 AjPStr FName;
133 AjPStr Ext;
134 ajint Num;
135 ajint Lines;
136 float xmin;
137 float ymin;
138 float xmax;
139 float ymax;
140 AjPList List;
141 } *graphData=NULL;
142
143
144
145
146 /* @filesection ajgraph *******************************************************
147 **
148 ** @nam1rule aj Function belongs to the AJAX library.
149 **
150 */
151
152
153
154
155 /* @datastatic GraphPType *****************************************************
156 **
157 ** Graph type definition structure
158 **
159 ** @alias GraphSType
160 ** @alias GraphOType
161 **
162 ** @attr Name [const char*] Name used by Ajax
163 ** @attr Device [const char*] Name used by plplot library
164 ** @attr Ext [const char*] File extension for output file if any
165 ** @attr Width [ajint] Default width within the driver, 0 if not a plot
166 ** @attr Height [ajint] Default height within the driver, 0 if not a plot
167 ** @attr Plplot [AjBool] true if using PlPlot data and library calls
168 ** @attr Alias [AjBool] ajTrue if this name is a user alias for another
169 ** entry with the same Device name.
170 ** @attr Screen [AjBool] true if plplot writes to the screen
171 ** @attr Onefile [AjBool] true if plplot can write multiple pages to one file
172 ** (for example, postscript output)
173 ** @attr Fixedsize [AjBool] true if plplot fixes the plot window size,
174 ** ignoring user settings
175 ** @attr Interactive [AjBool] true if plplot can interact with the device
176 ** @attr XYDisplay [void function] Function to display an XY graph
177 ** @attr GOpen [void function] Function to display a general graph
178 ** @attr Desc [const char*] Description
179 ** @@
180 ******************************************************************************/
181
182 typedef struct GraphSType
183 {
184 const char* Name;
185 const char* Device;
186 const char* Ext;
187 ajint Width;
188 ajint Height;
189 AjBool Plplot;
190 AjBool Alias;
191 AjBool Screen;
192 AjBool Onefile;
193 AjBool Fixedsize;
194 AjBool Interactive;
195 void (*XYDisplay) (AjPGraph thys, AjBool closeit, const char *ext);
196 void (*GOpen) (AjPGraph thys, const char *ext);
197 const char* Desc;
198 } GraphOType;
199 #define GraphPType GraphOType*
200
201
202
203
204 /* @funclist graphType ********************************************************
205 **
206 ** Graph functions to open and display a graph with the PLPLOT
207 ** device drivers
208 **
209 ******************************************************************************/
210
211 static GraphOType graphType[] =
212 {
213 /*Name Device Extension Width Height
214 PlPlot Alias Screen Onefile Fixedsize Interactive
215 DisplayFunction OpenFunction
216 Description*/
217 {"ps", "ps", ".ps", 720, 540,
218 AJTRUE, AJFALSE, AJFALSE, AJTRUE, AJFALSE, AJFALSE,
219 &GraphxyDisplayToFile, &GraphOpenFile,
220 "Postscript"},
221 {"postscript", "ps", ".ps", 720, 540,
222 AJTRUE, AJTRUE, AJFALSE, AJTRUE, AJFALSE, AJFALSE,
223 &GraphxyDisplayToFile, &GraphOpenFile,
224 "Postscript"},
225
226 #ifndef WIN32
227 {"hpgl", "lj_hpgl", ".hpgl", 11000,7200,
228 AJTRUE, AJFALSE, AJFALSE, AJTRUE, AJFALSE, AJFALSE,
229 &GraphxyDisplayToFile, &GraphOpenFile,
230 "HPGL general"},
231
232 {"hp7470", "hp7470", ".hpgl", 10300,7650,
233 AJTRUE, AJFALSE, AJFALSE, AJTRUE, AJFALSE, AJFALSE,
234 &GraphxyDisplayToFile, &GraphOpenFile,
235 "HPGL 7470 pen plotter"},
236
237 {"hp7580", "hp7580", ".hpgl", 9000, 5580,
238 AJTRUE, AJFALSE, AJFALSE, AJTRUE, AJFALSE, AJFALSE,
239 &GraphxyDisplayToFile, &GraphOpenFile,
240 "HPGL 7580 pen plotter"},
241 #endif
242
243 {"meta", "plmeta", ".meta", 0, 0,
244 AJTRUE, AJFALSE, AJFALSE, AJTRUE, AJFALSE, AJFALSE,
245 &GraphxyDisplayToFile, &GraphOpenFile,
246 "Metafile"},
247
248 {"cps", "psc", ".ps", 720, 540,
249 AJTRUE, AJFALSE, AJFALSE, AJTRUE, AJFALSE, AJFALSE,
250 &GraphxyDisplayToFile, &GraphOpenFile,
251 "Colour postscript"},
252
253 {"colourps", "psc", ".ps", 720, 540,
254 AJTRUE, AJTRUE, AJFALSE, AJTRUE, AJFALSE, AJFALSE,
255 &GraphxyDisplayToFile, &GraphOpenFile,
256 "Colour postscript"},
257
258 #ifndef WIN32
259 #ifndef X_DISPLAY_MISSING /* X11 is available */
260 {"x11", "xwin", "null", 1440, 900,
261 AJTRUE, AJFALSE, AJTRUE, AJTRUE, AJFALSE, AJTRUE,
262 &GraphxyDisplayXwin, &GraphOpenXwin,
263 "X11 in new window"},
264
265 {"xwindows", "xwin", "null", 1440, 900,
266 AJTRUE, AJTRUE, AJTRUE, AJTRUE, AJFALSE, AJTRUE,
267 &GraphxyDisplayXwin, &GraphOpenXwin,
268 "X11 in new window"},
269 #endif
270
271 {"tek", "tek4107t","null", 1024, 780,
272 AJTRUE, AJFALSE, AJTRUE, AJTRUE, AJFALSE, AJTRUE,
273 &GraphxyDisplayXwin, &GraphOpenSimple,
274 "Tektronix screen graphics"},
275
276 {"tek4107t", "tek4107t","null", 1024, 780,
277 AJTRUE, AJTRUE, AJTRUE, AJTRUE, AJFALSE, AJTRUE,
278 &GraphxyDisplayXwin, &GraphOpenSimple,
279 "Tektronix model 4107 screen graphics"},
280
281 {"tekt", "tekt", "null", 1024, 780,
282 AJTRUE, AJFALSE, AJTRUE, AJTRUE, AJFALSE, AJTRUE,
283 &GraphxyDisplayXwin, &GraphOpenSimple,
284 "Tektronix screen graphics"},
285
286 {"tektronics", "tekt", "null", 1024, 780,
287 AJTRUE, AJTRUE, AJTRUE, AJTRUE, AJFALSE, AJTRUE,
288 &GraphxyDisplayXwin, &GraphOpenSimple,
289 "Tektronix screen graphics"},
290
291 #endif
292
293 {"none", "null", "null", 0, 0,
294 AJTRUE, AJFALSE, AJFALSE, AJTRUE, AJFALSE, AJFALSE,
295 &GraphxyDisplayXwin, &GraphOpenSimple,
296 "No output"},
297
298 {"null", "null", "null", 0, 0,
299 AJTRUE, AJTRUE, AJFALSE, AJTRUE, AJFALSE, AJFALSE,
300 &GraphxyDisplayXwin, &GraphOpenSimple,
301 "No output"},
302
303 {"text", "null", "null", 0, 0,
304 AJTRUE, AJTRUE, AJFALSE, AJTRUE, AJFALSE, AJFALSE,
305 &GraphxyDisplayXwin, &GraphOpenSimple,
306 "Text file"},
307 /* data file output */
308
309 {"data", "data", ".dat", 960, 768,
310 AJTRUE, AJFALSE, AJFALSE, AJTRUE, AJTRUE, AJFALSE,
311 &GraphxyDisplayToData, &GraphOpenData,
312 "Data file for Staden package"},
313
314 {"das", "das", ".das", 0, 0,
315 AJTRUE, AJFALSE, AJFALSE, AJTRUE, AJFALSE, AJFALSE,
316 &GraphxyDisplayToDas, NULL,
317 "Data file for DAS server"},
318
319 {"wig", "wig", ".wig", 0, 0,
320 AJTRUE, AJFALSE, AJFALSE, AJTRUE, AJFALSE, AJFALSE,
321 GraphxyDisplayToWiggle, NULL,
322 "Wiggle data for genome browsers"},
323
324 {"bedgraph", "bedgraph", ".bedgraph", 0, 0,
325 AJTRUE, AJFALSE, AJFALSE, AJTRUE, AJFALSE, AJFALSE,
326 &GraphxyDisplayToBedgraph, NULL,
327 "BedGraph data for genome browsers"},
328
329 #ifndef WIN32
330 #ifndef X_DISPLAY_MISSING /* X11 is available */
331 {"xterm", "xterm", "null", 1024, 780,
332 AJTRUE, AJFALSE, AJTRUE, AJTRUE, AJFALSE, AJTRUE,
333 &GraphxyDisplayXwin, &GraphOpenXwin,
334 "Xterm screen graphics"},
335 #endif
336 #endif
337
338 #ifdef PLD_png /* if png/gd/zlib libraries available for png driver */
339 {"png", "png", ".png", 800, 600,
340 AJTRUE, AJFALSE, AJFALSE, AJFALSE, AJFALSE, AJFALSE,
341 &GraphxyDisplayToFile, &GraphOpenFile,
342 "PNG graphics files"},
343 #ifndef WIN32
344 {"gif", "gif", ".gif", 640, 480,
345 AJTRUE, AJFALSE, AJFALSE, AJFALSE, AJFALSE, AJFALSE,
346 &GraphxyDisplayToFile, &GraphOpenFile,
347 "GIF graphics files"},
348 #endif
349 #endif
350
351 #ifdef WIN32
352 {"win3", "win3", "null", 720, 540,
353 AJTRUE, AJFALSE, AJTRUE, AJTRUE, AJFALSE, AJTRUE,
354 &GraphxyDisplayXwin, &GraphOpenXwin,
355 "Windows screen graphics"},
356 #endif
357
358 #ifdef PLD_pdf /* if png/gd/zlib libraries available for png driver */
359 {"pdf", "pdf", ".pdf", 1683, 1190,
360 AJTRUE, AJFALSE, AJFALSE, AJTRUE, AJFALSE, AJFALSE,
361 &GraphxyDisplayToFile, &GraphOpenFile,
362 "PDF graphics files"},
363 #endif
364
365 {"svg", "svg", ".svg", 720, 540,
366 AJTRUE, AJFALSE, AJFALSE, AJTRUE, AJFALSE, AJFALSE,
367 &GraphxyDisplayToFile, &GraphOpenFile,
368 "SVG graphics files"},
369
370 {NULL, NULL, NULL, 0, 0,
371 AJFALSE, AJFALSE, AJFALSE, AJFALSE, AJFALSE, AJFALSE,
372 NULL, NULL,
373 NULL}
374 };
375
376
377 #ifndef NO_PLOT
378
379
380
381
382 static ajuint currentfgcolour = BLACK; /* Change with ajGraphicsSetFgcolour */
383 static AjBool currentbgwhite = AJTRUE; /* By default white background */
384 static PLFLT currentcharsize = 4.0; /* ajGraphicsSetCharSize to change */
385 static PLFLT currentcharscale = 1.0; /* ajGraphicsSetCharscale to change */
386
387 /* AJB: This variable is set quite a lot, but never used */
388 #if 0
389 static PLFLT currentcharht = 4.0; /* ajGraphicsSetCharscale to change */
390 #endif
391
392 static PLINT currentlinestyle = 1; /* ajGraphicsSetLinestyle to change*/
393 static PLINT currentfillpattern = 1; /* ajGraphicsSetFillpat to change*/
394
395 static AjPStr graphBasename = NULL;
396 static AjPStr graphExtension = NULL;
397
398 /******************************************************************************
399 plplot calls should only be made once from now on so all calls to plplot
400 should be made via ajGraph calls. So why bother? This is to make it easier
401 to change to another graph package as all the plplot calls should only be
402 listed once hence only a few routines should need to be changed?? Well in
403 theory anyway.
404 ******************************************************************************/
405
406 /******************************************************************************
407 PLPLOT CALLS *START*
408 ******************************************************************************/
409
410
411
412
413 /* @datasection [none] Graphics internals **************************************
414 **
415 ** Function is for controlling the graphics internals without using
416 ** an AjPGraph object
417 **
418 ** @nam2rule Graphics
419 */
420
421
422
423
424 /* @section modifiers **********************************************************
425 **
426 ** Controlling the internals
427 **
428 ** @fdata [none]
429 ** @fcategory modify
430 **
431 ** @nam3rule Close Close a plot
432 ** @nam4rule CloseWin Close a window based plot
433 ** @nam3rule Plenv Defines a PLPLOT environment
434 ** @nam3rule Reset Reset internal state
435 ** @nam3rule Set Set internal state
436 **
437 ** @nam4rule Bgcolour Background colour
438 ** @nam4rule Charscale Character scale factor
439 ** @nam4rule Charsize Character height
440 ** @nam4rule Defcharsize Character default height
441 ** @nam4rule Device Set plplot device name from graph object
442 ** @nam4rule Fgcolour Foreground plotting colour
443 ** @nam4rule Filename BaseName and extension
444 ** @nam4rule Fillpat Fill pattern
445 ** @nam4rule Labels Plot titles and axis labels
446 ** @nam4rule Linestyle Line style
447 ** @nam4rule Filename File name from graph object
448 ** @nam4rule Pagesize Page dimensions
449 ** @nam4rule Penwidth Pen width
450 ** @nam4rule Portrait Portrait orientation
451 ** @nam4rule Rlabel Right axis label
452 **
453 ** @nam5rule Black Set colour to black
454 ** @nam5rule White Set colour to white
455 **
456 ** @suffix C Character data
457 ** @suffix S String object data
458 **
459 ** @argrule Plenv xmin [float] X axis start
460 ** @argrule Plenv xmax [float] X axis end
461 ** @argrule Plenv ymin [float] Y axis start
462 ** @argrule Plenv ymax [float] Y axis end
463 ** @argrule Plenv flags [ajint] flag bit settings
464 ** @argrule SetFgcolour colour [ajint] Foreground plplot colour code
465 ** @argrule Charscale scale [float] Character relative scale factor
466 ** @argrule Charsize size [float] Character height in plot units
467 ** @argrule Defcharsize size [float] Default character height in plot units
468 ** @argrule Device graph [const AjPGraph] Graph object with device defined
469 ** @argrule Filename graph [const AjPGraph] Graph object with name defined
470 ** @argrule Fillpat patstyle [ajint] Pattern style plplot code
471 ** @argrule Linestyle linestyle [ajint] Line style plplot code
472 ** @argrule Pagesize plotwidth [ajuint] Page width (x-axis) in pixels or mm
473 ** @argrule Pagesize plotheight [ajuint] Page height (y-axis) in pixels or mm
474 ** @argrule Penwidth penwidth [float] Pen width in plot units
475 ** @argrule Portrait set [AjBool] True to set orientation, false for landscape
476 ** @argrule LabelsC x [const char*] X axis label
477 ** @argrule LabelsS strx [const AjPStr] X axis label
478 ** @argrule LabelsC y [const char*] Y axis label
479 ** @argrule LabelsS stry [const AjPStr] Y axis label
480 ** @argrule LabelsC title [const char*] Plot title
481 ** @argrule LabelsS strtitle [const AjPStr] Plot title
482 ** @argrule LabelsC subtitle [const char*] Plot subtitle
483 ** @argrule LabelsS strsubtitle [const AjPStr] Plot subtitle
484 ** @argrule RlabelC txt [const char*] C character string
485 ** @argrule RlabelS str [const AjPStr] String object
486 **
487 ** @valrule * [void]
488 ** @valrule *Charscale [float] previous character scale factor
489 ** @valrule *Charsize [float] previous character height in plot units
490 ** @valrule *Defcharsize [float] previous character height in plot units
491 ** @valrule *SetFgcolour [ajint] previous foreground colour code
492 ** @valrule *Fillpat [ajint] previous pattern fill plplot code
493 ** @valrule *Linestyle [ajint] previous line style plplot code
494 **
495 ******************************************************************************/
496
497
498
499
500 /* @func ajGraphicsClose ******************************************************
501 **
502 ** Close current Plot.
503 **
504 ** @return [void]
505 **
506 ** @release 6.2.0
507 ** @@
508 ******************************************************************************/
509
ajGraphicsClose(void)510 void ajGraphicsClose(void)
511 {
512 ajDebug("ajGraphicsClose\n");
513 GraphClose();
514
515 return;
516 }
517
518
519
520
521 /* @func ajGraphicsCloseWin ***************************************************
522 **
523 ** Close current window Plot
524 **
525 ** @return [void]
526 **
527 ** @release 6.2.0
528 ** @@
529 ******************************************************************************/
530
ajGraphicsCloseWin(void)531 void ajGraphicsCloseWin(void)
532 {
533 ajDebug("ajGraphicsCloseWin\n");
534 GraphClose();
535
536 return;
537 }
538
539
540
541
542 /* @func ajGraphicsPlenv ******************************************************
543 **
544 ** Defines a plot environment. i.e. tells plplot whether the graph is boxed,
545 ** whether it has tick marks, whether it has labels etc. These should already
546 ** be set in the flags.
547 **
548 ** @param [r] xmin [float] X axis start
549 ** @param [r] xmax [float] X axis end
550 ** @param [r] ymin [float] Y axis start
551 ** @param [r] ymax [float] Y axis end
552 ** @param [r] flags [ajint] flag bit settings
553 ** @return [void]
554 **
555 ** @release 6.2.0
556 ** @@
557 ******************************************************************************/
558
ajGraphicsPlenv(float xmin,float xmax,float ymin,float ymax,ajint flags)559 void ajGraphicsPlenv(float xmin, float xmax, float ymin, float ymax,
560 ajint flags)
561 {
562 char xopt[15] = " ";
563 char yopt[15] = " ";
564 ajuint i = 0;
565 ajuint j = 0;
566
567 /* ignore 'a' axis at zero value */
568 /* ignore 'd' label plot as date/time */
569 /* ignore 'f' fixed point labels */
570 /* ignore 'h' minor interval grid */
571 /* ignore 'l' logarithmic axis */
572
573 ajDebug("ajGraphicsPlenv(%.3f, %.3f, %.3f, %.3f, flags:%x)\n",
574 xmin, xmax, ymin, ymax, flags);
575 GraphSubPage(0);
576 GraphSetWin2(xmin,xmax,ymin,ymax);
577
578 if(flags & AJGRAPH_X_BOTTOM)
579 xopt[i++] = 'b';
580
581 if(flags & AJGRAPH_Y_LEFT)
582 yopt[j++] = 'b';
583
584 if(flags & AJGRAPH_X_TOP)
585 xopt[i++] = 'c';
586
587 if(flags & AJGRAPH_Y_RIGHT)
588 yopt[j++] = 'c';
589
590 if(flags & AJGRAPH_X_TICK)
591 {
592 xopt[i++] = 't'; /* do ticks */
593 xopt[i++] = 's'; /* do subticks */
594
595 if(flags & AJGRAPH_X_INVERT_TICK)
596 xopt[i++] = 'i';
597
598 if(flags & AJGRAPH_X_NUMLABEL_ABOVE)
599 xopt[i++] = 'm';
600 else
601 xopt[i++] = 'n'; /* write numeric labels */
602 }
603
604 if(flags & AJGRAPH_Y_TICK)
605 {
606 yopt[j++] = 't';
607 yopt[j++] = 's';
608
609 if(flags & AJGRAPH_Y_INVERT_TICK)
610 yopt[j++] = 'i';
611
612 if(flags & AJGRAPH_Y_NUMLABEL_LEFT)
613 yopt[j++] = 'm';
614 else
615 yopt[j++] = 'n';
616 }
617
618 if(flags & AJGRAPH_X_GRID)
619 xopt[i++] = 'g';
620
621 if(flags & AJGRAPH_Y_GRID)
622 yopt[j++] = 'g';
623
624 /* ignore minor interval grid option 'h' */
625
626 xopt[i] = '\0';
627 yopt[j] = '\0';
628
629 #if GRAPH_DEBUG
630 ajDebug("=g= plbox('%s', 0.0, 0, '%s', 0.0, 0) "
631 "[xopt, 0.0, 0, yopt, 0.0, 0]\n", xopt, yopt);
632 #endif
633 plbox(xopt, 0.0, 0, yopt, 0.0, 0);
634
635 return;
636 }
637
638
639
640
641 /* @func ajGraphicsResetBgcolour **********************************************
642 **
643 ** Reset the background colour to either black or white depending on the
644 ** current settings.
645 **
646 ** @return [void]
647 **
648 ** @release 6.2.0
649 ** @@
650 ******************************************************************************/
651
ajGraphicsResetBgcolour(void)652 void ajGraphicsResetBgcolour(void)
653 {
654 GraphColourBack();
655 return;
656 }
657
658
659
660
661 /* @func ajGraphicsResetFgcolour **********************************************
662 **
663 ** Reset the foreground plotting colour using current stored colour.
664 **
665 ** @return [void]
666 **
667 ** @release 6.2.0
668 ** @@
669 ******************************************************************************/
670
ajGraphicsResetFgcolour(void)671 void ajGraphicsResetFgcolour(void)
672 {
673 GraphColourFore();
674 return;
675 }
676
677
678
679
680 /* @func ajGraphicsSetBgcolourBlack *******************************************
681 **
682 ** Set the background colour to black
683 **
684 ** @return [void]
685 **
686 ** @release 6.2.0
687 ** @@
688 ******************************************************************************/
689
ajGraphicsSetBgcolourBlack(void)690 void ajGraphicsSetBgcolourBlack(void)
691 {
692 ajDebug("ajGraphicsSetBgcolourBlack currentbgwhite: %B\n", currentbgwhite);
693
694 if(currentbgwhite)
695 {
696 currentbgwhite = ajFalse;
697
698 GraphPen(0, 0, 0, 0);
699 GraphPen(MAXCOL, 255, 255, 255);
700
701 graphColourName[0] = "BLACK";
702 graphColourName[MAXCOL] = "WHITE";
703
704 ajDebug("ajGraphicsSetBgcolourBlack pen 0 '%s' pen %d '%s'\n",
705 graphColourName[0], MAXCOL, graphColourName[MAXCOL]);
706 }
707
708 return;
709 }
710
711
712
713
714 /* @func ajGraphicsSetBgcolourWhite *******************************************
715 **
716 ** Set the background colour to white (the default colour)
717 **
718 ** @return [void]
719 **
720 ** @release 6.2.0
721 ** @@
722 ******************************************************************************/
723
ajGraphicsSetBgcolourWhite(void)724 void ajGraphicsSetBgcolourWhite(void)
725 {
726 ajDebug("ajGraphicsSetBgcolourWhite currentbgwhite: %B\n", currentbgwhite);
727
728 if(!currentbgwhite)
729 {
730 currentbgwhite = ajTrue;
731
732 GraphPen(0, 255, 255, 255);
733 GraphPen(MAXCOL, 0, 0, 0);
734
735 graphColourName[0] = "WHITE";
736 graphColourName[MAXCOL] = "BLACK";
737
738 ajDebug("ajGraphicsSetBgcolourWhite pen 0 '%s' pen %d '%s'\n",
739 graphColourName[0], MAXCOL, graphColourName[MAXCOL]);
740 }
741
742 return;
743 }
744
745
746
747
748 /* @func ajGraphicsSetCharscale ***********************************************
749 **
750 ** Set the character scale factor
751 **
752 ** @param [r] scale [float] character scale.
753 ** @return [float] the previous character scale factor.
754 **
755 ** @release 6.2.0
756 ** @@
757 ******************************************************************************/
758
ajGraphicsSetCharscale(float scale)759 float ajGraphicsSetCharscale(float scale)
760 {
761 float oldscale;
762
763 oldscale = currentcharscale;
764
765 if(scale)
766 {
767 currentcharscale = scale;
768 GraphCharScale(currentcharscale);
769 }
770
771 return oldscale;
772 }
773
774
775
776
777 /* @func ajGraphicsSetCharsize ************************************************
778 **
779 ** Set the character size factor
780 **
781 ** @param [r] size [float] character size.
782 ** @return [float] the previous character size factor.
783 **
784 ** @release 6.2.0
785 ** @@
786 ******************************************************************************/
787
ajGraphicsSetCharsize(float size)788 float ajGraphicsSetCharsize(float size)
789 {
790 float oldsize;
791
792 oldsize = currentcharsize;
793
794 if(size)
795 {
796 currentcharsize = size;
797 #if 0
798 currentcharht = size;
799 #endif
800 currentcharscale = 1.0;
801 plschr(currentcharsize, currentcharscale);
802 }
803
804 return oldsize;
805 }
806
807
808
809
810 /* @func ajGraphicsSetDefcharsize *********************************************
811 **
812 ** Set the default character size in mm.
813 **
814 ** @param [r] size [float] character size in mm.
815 ** @return [float] the previous character size in mm.
816 **
817 ** @release 6.2.0
818 ** @@
819 ******************************************************************************/
820
ajGraphicsSetDefcharsize(float size)821 float ajGraphicsSetDefcharsize(float size)
822 {
823 float oldsize = 0.0;
824 float oldscale = 0.0;
825
826 ajGraphicsGetCharsize(&oldsize, &oldscale);
827 GraphDefCharSize((PLFLT)size);
828
829 return oldsize;
830 }
831
832
833
834
835 /* @func ajGraphicsSetDevice **************************************************
836 **
837 ** Set internal graph device to that selected for a graph object
838 **
839 ** @param [r] graph [const AjPGraph] Graph object with display type set
840 **
841 ** @return [void]
842 **
843 ** @release 6.2.0
844 ** @@
845 ******************************************************************************/
846
ajGraphicsSetDevice(const AjPGraph graph)847 void ajGraphicsSetDevice(const AjPGraph graph)
848 {
849 #if GRAPH_DEBUG
850 ajDebug("=g= plsdev ('%s') [graphType[%d].Device] ready: %B\n",
851 graphType[graph->displaytype].Device,
852 graph->displaytype, graph->ready);
853 #endif
854
855 if(!graph->ready)
856 plsdev(graphType[graph->displaytype].Device);
857
858 return;
859 }
860
861
862
863
864 /* @func ajGraphicsSetFgcolour ************************************************
865 **
866 ** Set the foreground plotting colour
867 **
868 ** @param [r] colour [ajint] colour to set drawing to.
869 ** @return [ajint] the previous colour.
870 **
871 ** @release 6.2.0
872 ** @@
873 ******************************************************************************/
874
ajGraphicsSetFgcolour(ajint colour)875 ajint ajGraphicsSetFgcolour(ajint colour)
876 {
877 ajint oldcolour;
878 ajint col;
879
880 col = colour;
881
882 /* in case of looping through colours */
883 /* start at the beginning once past end */
884 while(col > MAXCOL)
885 col -= (MAXCOL+1);
886
887 /*
888 if(col < 0)
889 ajDebug("ajGraphicsSetFgcolour give up and use "
890 "currentfgcolour %d '%s'\n",
891 currentfgcolour, graphColourName[currentfgcolour]);
892 */
893
894 if(col < 0)
895 return currentfgcolour;
896
897 oldcolour = currentfgcolour;
898 currentfgcolour = col;
899
900 if(currentbgwhite) /* swap black and white foreground */
901 {
902 if(col == 0)
903 col = MAXCOL;
904 else if(col == MAXCOL)
905 col = 0;
906 }
907
908 /*ajDebug("ajGraphicsSetFgcolour (%d '%s') currentbgwhite: %B, "
909 "oldcolour: %d '%s'\n",
910 colour, graphColourName[colour], currentbgwhite,
911 oldcolour, graphColourName[oldcolour]);*/
912
913 GraphColourFore();
914
915 return oldcolour;
916 }
917
918
919
920
921 /* @funcstatic GraphDefCharSize ***********************************************
922 **
923 ** Set the default char size in mm.
924 **
925 ** @param [r] size [float] Character size in mm. See PLPLOT.
926 ** @return [void]
927 **
928 ** @release 1.0.0
929 ** @@
930 ******************************************************************************/
931
GraphDefCharSize(float size)932 static void GraphDefCharSize(float size)
933 {
934 currentcharscale = 1.0;
935 currentcharsize = size;
936 #if 0
937 currentcharht = size;
938 #endif
939 plschr(currentcharsize, currentcharscale);
940
941 return;
942 }
943
944
945
946
947 /* @funcstatic GraphSetName ***************************************************
948 **
949 ** Set BaseName and extension.
950 **
951 ** @param [r] thys [const AjPGraph] Graph object.
952 ** @param [r] txt [const AjPStr] base name for files
953 ** @param [r] ext [const char*] extension for files
954 **
955 ** @return [void]
956 **
957 ** @release 1.0.0
958 ** @@
959 ******************************************************************************/
960
GraphSetName(const AjPGraph thys,const AjPStr txt,const char * ext)961 static void GraphSetName(const AjPGraph thys,
962 const AjPStr txt, const char *ext)
963 {
964 if(!thys->ready)
965 {
966 #if GRAPH_DEBUG
967 ajDebug("=g= plxsfnam ('%S', '%s')\n", txt, ext);
968 #endif
969
970 plxsfnam(ajStrGetPtr(txt), ext);
971 ajStrAssignS(&graphBasename, txt);
972 ajStrAssignC(&graphExtension, ext);
973 if(ajStrGetCharFirst(graphExtension) == '.')
974 ajStrCutStart(&graphExtension, 1);
975 }
976
977 return;
978 }
979
980
981
982
983 /* @func ajGraphicsSetFilename ************************************************
984 **
985 ** set BaseName and extension.
986 **
987 ** @param [r] graph [const AjPGraph] Graph object.
988 **
989 ** @return [void]
990 **
991 ** @release 6.2.0
992 ** @@
993 ******************************************************************************/
994
ajGraphicsSetFilename(const AjPGraph graph)995 void ajGraphicsSetFilename(const AjPGraph graph)
996 {
997 if(!ajCharMatchCaseC(graphType[graph->displaytype].Ext, "null"))
998 GraphSetName(graph, graph->outputfile,
999 graphType[graph->displaytype].Ext);
1000
1001 return;
1002 }
1003
1004
1005
1006
1007 /* @func ajGraphicsSetFillpat *************************************************
1008 **
1009 ** Set the Fill Pattern type.
1010 **
1011 ** @param [r] patstyle [ajint] line style to set drawing to.
1012 ** @return [ajint] the previous line style.
1013 **
1014 ** @release 6.2.0
1015 ** @@
1016 ******************************************************************************/
1017
ajGraphicsSetFillpat(ajint patstyle)1018 ajint ajGraphicsSetFillpat(ajint patstyle)
1019 {
1020 ajint oldstyle;
1021
1022 if(patstyle < 0 || patstyle > 8)
1023 patstyle = 1;
1024
1025 oldstyle = currentfillpattern;
1026 currentfillpattern = patstyle;
1027 GraphFillPat((PLINT)patstyle);
1028
1029 return oldstyle;
1030 }
1031
1032
1033
1034
1035 /* @func ajGraphicsSetLabelsC *************************************************
1036 **
1037 ** Label current Plot.
1038 **
1039 ** @param [r] x [const char*] text for x axis labelling.
1040 ** @param [r] y [const char*] text for y axis labelling.
1041 ** @param [r] title [const char*] text for title of plot.
1042 ** @param [r] subtitle [const char*] text for subtitle of plot.
1043 ** @return [void]
1044 **
1045 ** @release 6.2.0
1046 ** @@
1047 ******************************************************************************/
1048
ajGraphicsSetLabelsC(const char * x,const char * y,const char * title,const char * subtitle)1049 void ajGraphicsSetLabelsC(const char *x, const char *y,
1050 const char *title, const char *subtitle)
1051 {
1052 float fold;
1053
1054 #if GRAPH_DEBUG
1055 ajDebug("=g= plmtex('t', 2.5, 0.5, 0.5, '%s') [title]\n", title);
1056 #endif
1057
1058 plmtex("t", (PLFLT) 2.5, (PLFLT) 0.5, (PLFLT) 0.5, title);
1059
1060 #if GRAPH_DEBUG
1061 ajDebug("=g= plmtex('b', 3.2, 0.5, 0.5, '%s') [x-title]\n", x);
1062 #endif
1063
1064 plmtex("b", (PLFLT) 3.2, (PLFLT) 0.5, (PLFLT) 0.5, x);
1065
1066 #if GRAPH_DEBUG
1067 ajDebug("=g= plmtex('l', 5.0, 0.5, 0.5, '%s') [y-title]\n", y);
1068 #endif
1069
1070 plmtex("l", (PLFLT) 5.0, (PLFLT) 0.5, (PLFLT) 0.5, y);
1071
1072 fold = ajGraphicsSetCharscale(0.0);
1073 ajGraphicsSetCharscale(fold/(float)2.0);
1074
1075 #if GRAPH_DEBUG
1076 ajDebug("=g= plmtex('t', 1.5, 0.5, 0.5, '%s') [subtitle]\n", subtitle);
1077 #endif
1078
1079 plmtex("t", (PLFLT) 1.5, (PLFLT) 0.5, (PLFLT) 0.5, subtitle);
1080
1081 fold = ajGraphicsSetCharscale(fold);
1082
1083 /* pllab(x,y,title);*/
1084
1085 return;
1086 }
1087
1088
1089
1090
1091 /* @func ajGraphicsSetLabelsS *************************************************
1092 **
1093 ** Label current Plot.
1094 **
1095 ** @param [r] strx [const AjPStr] text for x axis labelling.
1096 ** @param [r] stry [const AjPStr] text for y axis labelling.
1097 ** @param [r] strtitle [const AjPStr] text for title of plot.
1098 ** @param [r] strsubtitle [const AjPStr] text for subtitle of plot.
1099 ** @return [void]
1100 **
1101 ** @release 6.2.0
1102 ** @@
1103 ******************************************************************************/
1104
ajGraphicsSetLabelsS(const AjPStr strx,const AjPStr stry,const AjPStr strtitle,const AjPStr strsubtitle)1105 void ajGraphicsSetLabelsS(const AjPStr strx, const AjPStr stry,
1106 const AjPStr strtitle, const AjPStr strsubtitle)
1107 {
1108 float fold;
1109
1110 #if GRAPH_DEBUG
1111 ajDebug("=g= plmtex('t', 2.5, 0.5, 0.5, '%S') [title]\n", strtitle);
1112 #endif
1113
1114 plmtex("t", (PLFLT) 2.5, (PLFLT) 0.5, (PLFLT) 0.5, MAJSTRGETPTR(strtitle));
1115
1116 #if GRAPH_DEBUG
1117 ajDebug("=g= plmtex('b', 3.2, 0.5, 0.5, '%S') [x-title]\n", strx);
1118 #endif
1119
1120 plmtex("b", (PLFLT) 3.2, (PLFLT) 0.5, (PLFLT) 0.5, MAJSTRGETPTR(strx));
1121
1122
1123 #if GRAPH_DEBUG
1124 ajDebug("=g= plmtex('l', 5.0, 0.5, 0.5, '%S') [y-title]\n", stry);
1125 #endif
1126
1127 plmtex("l", (PLFLT) 5.0, (PLFLT) 0.5, (PLFLT) 0.5, MAJSTRGETPTR(stry));
1128
1129 fold = ajGraphicsSetCharscale(0.0);
1130 ajGraphicsSetCharscale(fold/(float)2.0);
1131
1132 #if GRAPH_DEBUG
1133 ajDebug("=g= plmtex('t', 1.5, 0.5, 0.5, '%s') [subtitle]\n",
1134 MAJSTRGETPTR(strsubtitle));
1135 #endif
1136
1137 plmtex("t", (PLFLT) 1.5, (PLFLT) 0.5, (PLFLT) 0.5,
1138 MAJSTRGETPTR(strsubtitle));
1139
1140 fold = ajGraphicsSetCharscale(fold);
1141
1142 /* pllab(x,y,strtitle);*/
1143
1144 return;
1145 }
1146
1147
1148
1149
1150 /* @func ajGraphicsSetLinestyle ***********************************************
1151 **
1152 ** Set the line style.
1153 **
1154 ** @param [r] linestyle [ajint] line style to set drawing to.
1155 ** @return [ajint] the previous line style.
1156 **
1157 ** @release 6.2.0
1158 ** @@
1159 ******************************************************************************/
1160
ajGraphicsSetLinestyle(ajint linestyle)1161 ajint ajGraphicsSetLinestyle(ajint linestyle)
1162 {
1163 ajint oldstyle;
1164
1165 if(linestyle < 1 || linestyle > 8)
1166 linestyle = 1;
1167
1168 oldstyle = currentlinestyle;
1169 currentlinestyle = linestyle;
1170 GraphLineStyle((PLINT)linestyle);
1171
1172 return oldstyle;
1173 }
1174
1175
1176
1177
1178 /* @func ajGraphicsSetPagesize ************************************************
1179 **
1180 ** Set the width and height of the plot page.
1181 **
1182 ** Ignored by most plplot drivers, but will be used by PNG
1183 **
1184 ** @param [r] plotwidth [ajuint] Page width in pixels or mm
1185 ** @param [r] plotheight [ajuint] Page height in pixels or mm
1186 ** @return [void]
1187 **
1188 **
1189 ** @release 6.2.0
1190 ******************************************************************************/
1191
ajGraphicsSetPagesize(ajuint plotwidth,ajuint plotheight)1192 void ajGraphicsSetPagesize(ajuint plotwidth, ajuint plotheight)
1193 {
1194 plspage(0.0, 0.0, plotwidth, plotheight, 0, 0);
1195
1196 return;
1197 }
1198
1199
1200
1201
1202 /* @func ajGraphicsSetPenwidth ************************************************
1203 **
1204 ** Set the current pen width.
1205 **
1206 ** @param [r] penwidth [float] width for the pen.
1207 ** @return [void]
1208 **
1209 ** @release 6.2.0
1210 ** @@
1211 ******************************************************************************/
1212
ajGraphicsSetPenwidth(float penwidth)1213 void ajGraphicsSetPenwidth(float penwidth)
1214 {
1215 #if GRAPH_DEBUG
1216 ajDebug("=g= plwid(%.2f) [width]\n", penwidth);
1217 #endif
1218
1219 plwid((PLINT)penwidth);
1220
1221 return;
1222 }
1223
1224
1225
1226
1227 /* @func ajGraphicsSetPortrait ************************************************
1228 **
1229 ** Set graph orientation
1230 **
1231 ** @param [r] set [AjBool] portrait orientation if true, else landscape
1232 ** @return [void]
1233 **@@
1234 **
1235 ** @release 6.2.0
1236 ******************************************************************************/
1237
ajGraphicsSetPortrait(AjBool set)1238 void ajGraphicsSetPortrait(AjBool set)
1239 {
1240 #if GRAPH_DEBUG
1241 ajDebug("=g= plsori(%d) [ori]\n", set);
1242 #endif
1243
1244 if(set)
1245 plsori(1);
1246 else
1247 plsori(0);
1248
1249 return;
1250 }
1251
1252
1253
1254
1255 /* @func ajGraphicsSetRlabelC *************************************************
1256 **
1257 ** Label the right hand y axis.
1258 **
1259 ** @param [r] txt [const char*] text for label of right y axis.
1260 ** @return [void]
1261 **
1262 ** @release 6.2.0
1263 ** @@
1264 ******************************************************************************/
ajGraphicsSetRlabelC(const char * txt)1265 void ajGraphicsSetRlabelC(const char *txt)
1266 {
1267 #if GRAPH_DEBUG
1268 ajDebug("=g= plmtex('r', 2.0, 0.5, 0.5, '%s') [ajGraphicsDrawRlabelC]\n",
1269 txt);
1270 #endif
1271
1272 plmtex("r",2.0,0.5,0.5,txt);
1273
1274 return;
1275 }
1276
1277
1278
1279
1280 /* @func ajGraphicsSetRlabelS *************************************************
1281 **
1282 ** Label the right hand y axis.
1283 **
1284 ** @param [r] str [const AjPStr] text for label of right y axis.
1285 ** @return [void]
1286 **
1287 ** @release 6.2.0
1288 ** @@
1289 ******************************************************************************/
ajGraphicsSetRlabelS(const AjPStr str)1290 void ajGraphicsSetRlabelS(const AjPStr str)
1291 {
1292 #if GRAPH_DEBUG
1293 ajDebug("=g= plmtex('r', 2.0, 0.5, 0.5, '%S') [ajGraphicsDrawRlabelS]\n",
1294 str);
1295 #endif
1296
1297 plmtex("r",2.0,0.5,0.5,MAJSTRGETPTR(str));
1298
1299 return;
1300 }
1301
1302
1303
1304
1305 /* @funcstatic GraphColourFore ************************************************
1306 **
1307 ** Set the foreground plotting colour using current stored colour.
1308 ** @return [void]
1309 **
1310 ** @release 6.2.0
1311 ** @@
1312 ******************************************************************************/
1313
GraphColourFore(void)1314 static void GraphColourFore(void)
1315 {
1316 ajint colour;
1317
1318 colour = currentfgcolour;
1319
1320 if(currentbgwhite) /* OKAY!! when we swap backgrounds we also */
1321 {
1322 if(colour == 0) /* swap pens. User does not know this so switch */
1323 colour = MAXCOL; /* for them */
1324 else if(colour == MAXCOL)
1325 colour = 0;
1326 }
1327
1328 GraphSetPen(colour);
1329 /*ajDebug("GraphColourFore currentbgwhite: %B '%s' "
1330 "currentfgcolour: %d (%s) => %d (%s)\n",
1331 currentbgwhite, graphColourName[0],
1332 currentfgcolour, graphColourName[currentfgcolour],
1333 colour, graphColourName[colour]);*/
1334
1335 return;
1336 }
1337
1338
1339
1340
1341 /* @funcstatic GraphTextLength ************************************************
1342 **
1343 ** Compute the length of a string in millimetres.
1344 **
1345 ** @param [u] txt [const char*] text string
1346 ** @return [float] The length of the string in user coordinates
1347 **
1348 ** @release 1.0.0
1349 ** @@
1350 ******************************************************************************/
1351
GraphTextLength(const char * txt)1352 static float GraphTextLength(const char *txt)
1353 {
1354 return plstrl(txt);
1355 }
1356
1357
1358
1359
1360 /* @funcstatic GraphFillPat ***************************************************
1361 **
1362 ** Set the pattern to fill with.
1363 **
1364 ** @param [r] pat [ajint] Pattern code. See PLPLOT.
1365 **
1366 ** @return [void]
1367 **
1368 ** @release 1.0.0
1369 ** @@
1370 ******************************************************************************/
1371
GraphFillPat(ajint pat)1372 static void GraphFillPat(ajint pat)
1373 {
1374 #if GRAPH_DEBUG
1375 ajDebug("=g= plpsty(%d) [pattern style]\n", pat);
1376 #endif
1377
1378 plpsty((PLINT)pat);
1379
1380 return;
1381 }
1382
1383
1384
1385
1386 /* @funcstatic GraphLineStyle *************************************************
1387 **
1388 ** Set the Line style. i.e. dots dashes unbroken.
1389 **
1390 ** @param [r] style [ajint] Line style. See PLPLOT.
1391 **
1392 ** @return [void]
1393 **
1394 ** @release 1.0.0
1395 ** @@
1396 ******************************************************************************/
1397
GraphLineStyle(ajint style)1398 static void GraphLineStyle(ajint style)
1399 {
1400 #if GRAPH_DEBUG
1401 ajDebug("=g= pllsty(%d) [line style]\n", style);
1402 #endif
1403
1404 pllsty((PLINT)style);
1405
1406 return;
1407 }
1408
1409
1410
1411
1412 /* @funcstatic GraphCharScale *************************************************
1413 **
1414 ** Set the char size.
1415 **
1416 ** @param [r] scale [float] Character scale factor. See PLPLOT.
1417 **
1418 ** @return [void]
1419 **
1420 ** @release 4.1.0
1421 ** @@
1422 ******************************************************************************/
1423
GraphCharScale(float scale)1424 static void GraphCharScale(float scale)
1425 {
1426 #if GRAPH_DEBUG
1427 ajDebug("=g= plschr(0.0, %.2f) [0.0 charscale]\n", scale);
1428 #endif
1429
1430 plschr(0.0,(PLFLT)scale); /* use current size */
1431
1432 #if 0
1433 if(scale)
1434 currentcharht = currentcharsize*scale;
1435 #endif
1436
1437 return;
1438 }
1439
1440
1441
1442
1443 /* @funcstatic GraphLabelTitle ************************************************
1444 **
1445 ** Label current Plot with title and subtitle
1446 **
1447 ** @param [r] title [const char*] text for title of plot.
1448 ** @param [r] subtitle [const char*] text for subtitle of plot.
1449 ** @return [void]
1450 **
1451 ** @release 4.1.0
1452 ** @@
1453 ******************************************************************************/
1454
GraphLabelTitle(const char * title,const char * subtitle)1455 static void GraphLabelTitle(const char *title, const char *subtitle)
1456 {
1457 float fold;
1458 AjPStr tmpstr = NULL;
1459
1460 tmpstr = ajStrNewC(title);
1461 if(ajStrGetLen(tmpstr) > 55)
1462 {
1463 ajStrKeepRange(&tmpstr, 0, 55);
1464 ajStrAppendC(&tmpstr, "...");
1465 }
1466
1467 #if GRAPH_DEBUG
1468 ajDebug("=g= plmtex('t', 2.5, 0.5, 0.5, '%S') [title]\n", tmpstr);
1469 #endif
1470 plvsta(); /* set standard viewport for standard titles */
1471
1472 if(ajStrGetLen(tmpstr)) {
1473 fold = ajGraphicsSetCharscale(1.0);
1474 ajDebug("GraphLabelTitle title fold: %.3f size: %.3f scale %.3f\n",
1475 fold, currentcharsize, currentcharscale);
1476 plmtex("t", (PLFLT) 4.0, (PLFLT) 0.5, (PLFLT) 0.5,
1477 ajStrGetPtr(tmpstr));
1478 fold = ajGraphicsSetCharscale(fold);
1479 }
1480
1481 ajStrAssignC(&tmpstr, subtitle);
1482
1483 if(ajStrGetLen(tmpstr) > 95)
1484 {
1485 ajStrKeepRange(&tmpstr, 0, 95);
1486 ajStrAppendC(&tmpstr, "...");
1487 }
1488
1489 #if GRAPH_DEBUG
1490 ajDebug("=g= plmtex('t', 1.5, 0.5, 0.5, '%S') [subtitle]\n", tmpstr);
1491 #endif
1492
1493 if(ajStrGetLen(tmpstr))
1494 {
1495 fold = ajGraphicsSetCharscale(1.0);
1496 ajGraphicsSetCharscale(0.5);
1497 ajDebug("GraphLabelTitle subtitle fold: %.3f size: %.3f scale %.3f\n",
1498 fold, currentcharsize, currentcharscale);
1499 plmtex("t", (PLFLT) 5.0, (PLFLT) 0.5, (PLFLT) 0.5,
1500 ajStrGetPtr(tmpstr));
1501 fold = ajGraphicsSetCharscale(fold);
1502 }
1503
1504 if (graphData)
1505 {
1506 ajFmtPrintF(graphData->File,"##Maintitle %s\n",title);
1507 graphData->Lines++;
1508
1509 if(subtitle)
1510 {
1511 ajFmtPrintF(graphData->File,"##Subtitle %s\n",subtitle);
1512 graphData->Lines++;
1513 }
1514 }
1515
1516
1517 /* pllab(x,y,title);*/
1518
1519 ajStrDel(&tmpstr);
1520 return;
1521 }
1522
1523
1524
1525
1526 /* @funcstatic GraphSetPen ****************************************************
1527 **
1528 ** Set the pen to the colour specified.
1529 **
1530 ** @param [r] colour [ajint] Pen colour (see PLPLOT)
1531 **
1532 ** @return [void]
1533 **
1534 ** @release 1.0.0
1535 ** @@
1536 ******************************************************************************/
1537
GraphSetPen(ajint colour)1538 static void GraphSetPen(ajint colour)
1539 {
1540 #if GRAPH_DEBUG
1541 ajDebug("=g= plcol(%d '%s') [colour]\n", colour, graphColourName[colour]);
1542 #endif
1543
1544 plcol((PLINT)colour);
1545
1546 return;
1547 }
1548
1549
1550
1551
1552 /* @funcstatic GraphSetNumSubPage *********************************************
1553 **
1554 ** Sets the number of sub pages for a page.
1555 **
1556 ** @param [r] numofsubpages [ajuint] Number of subpages
1557 **
1558 ** @return [void]
1559 **
1560 ** @release 1.0.0
1561 ** @@
1562 ******************************************************************************/
1563
GraphSetNumSubPage(ajuint numofsubpages)1564 static void GraphSetNumSubPage(ajuint numofsubpages)
1565 {
1566 #if GRAPH_DEBUG
1567 ajDebug("=g= plssub (1, %d) [numofsubpages]\n", numofsubpages);
1568 #endif
1569
1570 plssub(1,numofsubpages);
1571
1572 return;
1573 }
1574
1575
1576
1577
1578 /* @section Base colours *******************************************************
1579 **
1580 ** Generating arrays of valid colour codes
1581 **
1582 ** @fdata [none]
1583 ** @fcategory new
1584 **
1585 ** @nam3rule Basecolour Base colour code array
1586 ** @nam4rule New Constructor
1587 ** @nam5rule Nuc Colours for nucleotide base codes
1588 ** @nam5rule Prot Colours for protein residue codes
1589 ** @argrule New codes [const AjPStr] Residue codes for each numbered position
1590 **
1591 ** @valrule * [ajint*] Array of colours (see PLPLOT)
1592 **
1593 ******************************************************************************/
1594
1595
1596
1597
1598 /* @func ajGraphicsBasecolourNewNuc *******************************************
1599 **
1600 ** Initialise a base colours array for a string of nucleotide
1601 ** sequence characters
1602 **
1603 ** @param [r] codes [const AjPStr] Residue codes for each numbered position
1604 ** @return [ajint*] Array of colours (see PLPLOT)
1605 **
1606 ** @release 6.2.0
1607 ** @@
1608 ******************************************************************************/
1609
ajGraphicsBasecolourNewNuc(const AjPStr codes)1610 ajint* ajGraphicsBasecolourNewNuc(const AjPStr codes)
1611 {
1612 ajint *ret;
1613 const char* alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
1614 ajint colours[] =
1615 {
1616 GREEN,YELLOW,BLUE,YELLOW,YELLOW,YELLOW,
1617 BLACK,YELLOW,YELLOW,YELLOW,YELLOW,YELLOW,
1618 YELLOW,YELLOW,YELLOW,YELLOW,YELLOW,YELLOW,
1619 YELLOW,RED,RED,YELLOW,YELLOW,YELLOW,
1620 YELLOW,YELLOW,YELLOW
1621 };
1622 const char* cp;
1623 const char* cq;
1624 ajint i;
1625 ajint j;
1626
1627 ret = (ajint *) AJALLOC0(sizeof(ajint)*AZ); /* BLACK is zero */
1628
1629 ajDebug("ajGraphGetBaseColourProt '%S'\n", codes);
1630
1631 cp = ajStrGetPtr(codes);
1632 i = 1;
1633
1634 while(*cp)
1635 {
1636 cq = strchr(alphabet, *cp);
1637
1638 if(cq)
1639 {
1640 j = cq - alphabet;
1641 ret[i] = colours[j];
1642 ajDebug("ColourProt %d: '%c' %d -> %d %s\n",
1643 i, *cp, j, colours[j], graphColourName[colours[j]]);
1644 }
1645
1646 i++;
1647 cp++;
1648 }
1649
1650 return ret;
1651 }
1652
1653
1654
1655
1656 /* @func ajGraphicsBasecolourNewProt ******************************************
1657 **
1658 ** Initialize a base colours array for a string of protein sequence characters
1659 ** according to the following colour scheme designed by Toby Gibson (EMBL
1660 ** Heidelberg) to show the chemical properties important in sequence
1661 ** and structure alignment and to be clear to those with common forms
1662 ** of colour blindness.
1663 **
1664 ** DE: Red (Acidic)
1665 ** HKR: Blue (Basic)
1666 ** NQ: Green (Amide)
1667 ** AILV: Black (Hydrophobic Small)
1668 ** FWY: Wheat (Hydrophobic Large)
1669 ** ST: Cyan (Hydroxyl group)
1670 ** CM: Yellow (Sulphur chemistry)
1671 ** G: Grey (helix breaker I)
1672 ** P: Violet (helix breaker II)
1673 **
1674 ** @param [r] codes [const AjPStr] Residue codes for each numbered position
1675 ** @return [ajint*] Array of colours (see PLPLOT)
1676 **
1677 ** @release 6.2.0
1678 ** @@
1679 ******************************************************************************/
1680
ajGraphicsBasecolourNewProt(const AjPStr codes)1681 ajint* ajGraphicsBasecolourNewProt(const AjPStr codes)
1682 {
1683 ajint *ret;
1684 const char* alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
1685 ajint colours[] =
1686 {
1687 BLACK,BLACK,YELLOW,RED,RED,WHEAT, /* A-F */
1688 GREY,BLUE,BLACK,BLACK,BLUE,BLACK, /* G-L */
1689 YELLOW,GREEN,BLACK,BLUEVIOLET,GREEN,BLUE, /* M-R */
1690 CYAN,CYAN,BLACK,BLACK,WHEAT,BLACK, /* S-X */
1691 WHEAT,BLACK,BLACK,BLACK}; /* Y-Z plus 2 more */
1692 const char* cp;
1693 const char* cq;
1694 ajint i;
1695 ajint j;
1696
1697 ret = (ajint *) AJALLOC0(sizeof(ajint)*AZ); /* BLACK is zero */
1698
1699 ajDebug("ajGraphGetBaseColourProt '%S'\n", codes);
1700
1701 cp = ajStrGetPtr(codes);
1702 i = 1;
1703
1704 while(*cp)
1705 {
1706 cq = strchr(alphabet, *cp);
1707
1708 if(cq)
1709 {
1710 j = cq - alphabet;
1711 ret[i] = colours[j];
1712 ajDebug("ColourProt %d: '%c' %d -> %d %s\n",
1713 i, *cp, j, colours[j], graphColourName[colours[j]]);
1714 }
1715
1716 i++;
1717 cp++;
1718 }
1719
1720 return ret;
1721 }
1722
1723
1724
1725
1726 /* @section Queries ***********************************************************
1727 **
1728 ** Querying and reporting internal values
1729 **
1730 ** @fdata [none]
1731 ** @fcategory use
1732 **
1733 ** @nam3rule Check Validate an external value
1734 ** @nam3rule Get Return an internal value
1735 **
1736 ** @nam4rule Charsize Character size in plot units
1737 ** @nam4rule CheckColour Find if the colour is on the list
1738 ** @nam4rule Fgcolour Undocumented
1739 ** @nam4rule Params Get parameters
1740 ** @nam5rule ParamsPage Get the output page parameters
1741 ** @suffix C Character data
1742 ** @suffix S String object data
1743 **
1744 **
1745 ** @argrule Charsize defheight [float*] default character height
1746 ** @argrule Charsize currentscale [float*] current (scaled) character height
1747 ** @argrule ParamsPage xp [float*] where to store the x pixels/inch
1748 ** @argrule ParamsPage yp [float*] where to store the y pixels/inch
1749 ** @argrule ParamsPage xleng [ajint*] where to store the x length
1750 ** @argrule ParamsPage yleng [ajint*] where to the y length
1751 ** @argrule ParamsPage xoff [ajint*] where to store the x offset
1752 ** @argrule ParamsPage yoff [ajint*] where to store the y offset
1753 ** @argrule C txt [const char*] colour name.
1754 ** @argrule S str [const AjPStr] colour name.
1755 **
1756 ** @valrule * [void]
1757 ** @valrule *Check [ajint] the colour number if found else -1.
1758 ** @valrule *Fgcolour [ajint] the foreground colour number
1759 **
1760 ******************************************************************************/
1761
1762
1763
1764
1765 /* @func ajGraphicsCheckColourC ***********************************************
1766 **
1767 ** Find if the colour is on the list
1768 **
1769 ** @param [r] txt [const char*] colour name.
1770 ** @return [ajint] the colour number if found else -1.
1771 **
1772 ** @release 6.2.0
1773 ** @@
1774 ******************************************************************************/
1775
ajGraphicsCheckColourC(const char * txt)1776 ajint ajGraphicsCheckColourC(const char* txt)
1777 {
1778 ajint i;
1779
1780 for(i=0;i<=MAXCOL;i++)
1781 if(ajCharMatchCaseC(txt,graphColourName[i]))
1782 return i;
1783
1784 return -1;
1785 }
1786
1787
1788
1789
1790 /* @func ajGraphicsCheckColourS ***********************************************
1791 **
1792 ** Find if the colour is on the list
1793 **
1794 ** @param [r] str [const AjPStr] colour name.
1795 ** @return [ajint] the colour number if found else -1.
1796 **
1797 ** @release 6.2.0
1798 ** @@
1799 ******************************************************************************/
1800
ajGraphicsCheckColourS(const AjPStr str)1801 ajint ajGraphicsCheckColourS(const AjPStr str)
1802 {
1803 ajint i;
1804
1805 for(i=0;i<=MAXCOL;i++)
1806 if(ajStrMatchCaseC(str,graphColourName[i]))
1807 return i;
1808
1809 return -1;
1810 }
1811
1812
1813
1814
1815 /* @func ajGraphicsGetCharsize ************************************************
1816 **
1817 ** Get the char size.
1818 **
1819 ** @param [u] defheight [float *] where to store the default character height
1820 ** @param [u] currentscale [float *] where to store the current (scaled)
1821 ** character height
1822 **
1823 ** @return [void]
1824 **
1825 ** @release 6.2.0
1826 ** @@
1827 ******************************************************************************/
1828
ajGraphicsGetCharsize(float * defheight,float * currentscale)1829 void ajGraphicsGetCharsize(float *defheight, float *currentscale)
1830 {
1831 if(graphData)
1832 {
1833 *defheight = currentcharsize;
1834 *currentscale = currentcharscale;
1835 }
1836 else
1837 {
1838 #if GRAPH_DEBUG
1839 ajDebug("=g= plgchr(&f &f) [defht:%f, scale:%f] plplot\n",
1840 *defheight, *currentscale);
1841 #endif
1842
1843 plgchr(defheight,currentscale);
1844 }
1845
1846 return;
1847 }
1848
1849
1850
1851
1852 /* @func ajGraphicsGetFgcolour ************************************************
1853 **
1854 ** Return current foreground colour
1855 **
1856 ** @return [ajint] colour.
1857 **
1858 ** @release 6.2.0
1859 ** @@
1860 ******************************************************************************/
1861
ajGraphicsGetFgcolour(void)1862 ajint ajGraphicsGetFgcolour(void)
1863 {
1864 return currentfgcolour;
1865 }
1866
1867
1868
1869
1870 /* @func ajGraphicsGetParamsPage **********************************************
1871 **
1872 ** Get the output page parameters for plplot internal use. These can be set by
1873 ** the user and used by some device drivers.
1874 **
1875 ** For graph data type, sets to zero as these are not applicable.
1876 **
1877 ** @param [u] xp [float *] where to store the x pixels/inch
1878 ** @param [u] yp [float *] where to store the y pixels/inch
1879 ** @param [u] xleng [ajint *] where to store the x length
1880 ** @param [u] yleng [ajint *] where to the y length
1881 ** @param [u] xoff [ajint *] where to store the x offset
1882 ** @param [u] yoff [ajint *] where to store the y offset
1883 **
1884 ** @return [void]
1885 **
1886 ** @release 6.2.0
1887 ** @@
1888 ******************************************************************************/
1889
ajGraphicsGetParamsPage(float * xp,float * yp,ajint * xleng,ajint * yleng,ajint * xoff,ajint * yoff)1890 void ajGraphicsGetParamsPage(float *xp,float *yp, ajint *xleng, ajint *yleng,
1891 ajint *xoff, ajint *yoff)
1892 {
1893 #if GRAPH_DEBUG
1894 ajDebug("=g= plgpage(&f &f) [&xp, &yp, &xleng, &yleng, &xoff, &yoff]\n");
1895 #endif
1896
1897 if(graphData)
1898 {
1899 *xp=0.0;
1900 *yp=0.0;
1901 *xleng=0;
1902 *yleng=0;
1903 *xoff=0;
1904 *yoff=0;
1905 }
1906 else
1907 {
1908 plgpage(xp,yp,xleng,yleng,xoff,yoff);
1909 ajDebug("returns xp:%.3f yp:%.3f xleng:%d yleng:%d xoff:%d yoff:%d\n",
1910 *xp, *yp, *xleng, *yleng, *xoff, *yoff);
1911 }
1912
1913 return;
1914 }
1915
1916
1917
1918
1919 /* @section Drawing ***********************************************************
1920 **
1921 ** Drawing lines and objects
1922 **
1923 ** @fdata [none]
1924 ** @fcategory use
1925 **
1926 ** @nam3rule Draw Draw at a point
1927 ** @nam3rule Drawarc Draw on an arc
1928 ** @nam3rule Drawbars Draw bar chart
1929 ** @nam3rule Drawpos Draw at a defined xy coordinate
1930 ** @nam3rule Drawset Draw at a set of defined xy coordinates
1931 **
1932 ** @nam4rule Arc Draw an arc
1933 ** @nam4rule Bars Error bars
1934 ** @nam4rule Box Box
1935 ** @nam4rule Circle Circle
1936 ** @nam4rule Dia Diamond
1937 ** @nam4rule Dots Dots
1938 ** @nam4rule Line Line
1939 ** @nam4rule Lines LInes
1940 ** @nam4rule Poly Polygon
1941 ** @nam4rule Rect Rectangle
1942 ** @nam4rule Rlabel Right axis label
1943 ** @nam4rule Symbols Symbols
1944 ** @nam4rule Text Text
1945 ** @nam4rule Tri Triangle
1946 ** @nam4rule Horiz Horizontal direction
1947 ** @nam4rule Vert Vertical direction
1948 ** @nam5rule Atend Placed with end at fixed point
1949 ** @nam5rule Atline Along a straight line
1950 ** @nam5rule Atmid Centred at a point
1951 ** @nam5rule Atstart Placed with start at fixed point
1952 ** @suffix Fill Fill in the plot area
1953 ** @suffix Justify Justify text according to a plplot justify value
1954 **
1955 ** @argrule Drawarc xcentre [PLFLT] Centre x coordinate
1956 ** @argrule Drawarc ycentre [PLFLT] Centre y coordinate
1957 ** @argrule Drawarc radius [PLFLT] Radius
1958 ** @argrule Drawarc startangle [PLFLT] Start angle
1959 ** @argrule Drawarc endangle [PLFLT] End angle
1960 ** @argrule DrawarcRect height [PLFLT] Height of the rectangle
1961 ** in user coordinates.
1962 **
1963 ** @argrule Drawbars num [ajuint] Number of dots
1964 ** @argrule DrawbarsHoriz y [CONST PLFLT*] y start positions
1965 ** @argrule DrawbarsHoriz xmin [CONST PLFLT*] x minimum values
1966 ** @argrule DrawbarsHoriz xmax [CONST PLFLT*] x maximum values
1967 ** @argrule DrawbarsVert x [CONST PLFLT*] x start positions
1968 ** @argrule DrawbarsVert ymin [CONST PLFLT*] y minimum values
1969 ** @argrule DrawbarsVert ymax [CONST PLFLT*] y maximum values
1970 **
1971 ** @argrule Drawpos x [PLFLT] x start position
1972 ** @argrule Drawpos y [PLFLT] y start position
1973 **
1974 ** @argrule Drawset num [ajuint] Number of dots
1975 ** @argrule Drawset xx [CONST PLFLT*] Centre x coordinates
1976 ** @argrule Drawset yy [CONST PLFLT*] Centre y coordinates
1977 **
1978 ** @argrule DrawposBox size [PLFLT] Size of sides starting at x,y
1979 ** @argrule DrawposCircle radius [float] radius of the circle.
1980 ** @argrule DrawposDia size [PLFLT] Size of sides starting at x,y
1981 ** @argrule DrawposLine x2 [PLFLT] x end position
1982 ** @argrule DrawposLine y2 [PLFLT] y end position
1983 ** @argrule DrawposRect x2 [PLFLT] x1 coordinate
1984 ** @argrule DrawposRect y2 [PLFLT] y1 coordinate
1985 ** @argrule DrawposTri x2 [PLFLT] x2 coordinate
1986 ** @argrule DrawposTri y2 [PLFLT] y2 coordinate
1987 ** @argrule DrawposTri x3 [PLFLT] x3 coordinate
1988 ** @argrule DrawposTri y3 [PLFLT] y3 coordinate
1989 ** @argrule DrawsetLines xx2 [CONST PLFLT*] Centre x2 coordinates
1990 ** @argrule DrawsetLines yy2 [CONST PLFLT*] Centre y2 coordinates
1991 ** @argrule DrawsetSymbols symbol [ajuint] Symbol code.
1992 ** @argrule TextAtline x2 [PLFLT] x2 coordinate
1993 ** @argrule TextAtline y2 [PLFLT] y2 coordinate
1994 ** @argrule Text txt [const char*] The text to be displayed.
1995 ** @argrule Justify just [PLFLT] justification of the string.
1996 **
1997 ** @valrule * [void]
1998 **
1999 ******************************************************************************/
2000
2001
2002
2003
2004 /* @func ajGraphicsDrawarcArc *************************************************
2005 **
2006 ** Draw a portion of a circle (an arc).
2007 **
2008 ** @param [r] xcentre [PLFLT] x coord for centre.
2009 ** @param [r] ycentre [PLFLT] y coord for centre.
2010 ** @param [r] radius [PLFLT] radius of the circle.
2011 ** @param [r] startangle [PLFLT] angle of the start of the arc.
2012 ** @param [r] endangle [PLFLT] angle of the end of the arc.
2013 ** @return [void]
2014 **
2015 ** @release 6.2.0
2016 ** @@
2017 **
2018 ** FIXME: Due to x and y not the same length this produces an oval!!
2019 ** This will have to do for now. But I am aware that the code
2020 ** is slow and not quite right.
2021 ******************************************************************************/
2022
ajGraphicsDrawarcArc(PLFLT xcentre,PLFLT ycentre,PLFLT radius,PLFLT startangle,PLFLT endangle)2023 void ajGraphicsDrawarcArc(PLFLT xcentre, PLFLT ycentre, PLFLT radius,
2024 PLFLT startangle, PLFLT endangle)
2025 {
2026 PLFLT angle;
2027 ajuint i;
2028 PLFLT x[361];
2029 PLFLT y[361];
2030 ajuint numofpoints;
2031 PLFLT stopangle = endangle;
2032
2033 if(endangle < startangle)
2034 stopangle += 360.0;
2035
2036 if((stopangle-startangle)>=360.0)
2037 stopangle = startangle + (float) 360.0;
2038
2039 x[0] = xcentre + ( radius*(float)cos(ajCvtDegToRad(startangle)) );
2040 y[0] = ycentre + ( radius*(float)sin(ajCvtDegToRad(startangle)) );
2041
2042 for(i=1, angle=startangle+1; angle<stopangle; angle++, i++)
2043 {
2044 x[i] = xcentre + ( radius*(float)cos(ajCvtDegToRad(angle)) );
2045 y[i] = ycentre + ( radius*(float)sin(ajCvtDegToRad(angle)) );
2046 }
2047
2048 x[i] = xcentre + ( radius*(float)cos(ajCvtDegToRad(stopangle)) );
2049 y[i] = ycentre + ( radius*(float)sin(ajCvtDegToRad(stopangle)) );
2050 numofpoints = i+1;
2051
2052 GraphDrawsetLines(numofpoints, x, y);
2053
2054 return;
2055 }
2056
2057
2058
2059
2060
2061 /* @func ajGraphicsDrawarcRect ************************************************
2062 **
2063 ** Draw a rectangle along a curve with the current pen colour/style.
2064 **
2065 ** @param [r] xcentre [PLFLT] x coord for centre.
2066 ** @param [r] ycentre [PLFLT] y coord for centre.
2067 ** @param [r] radius [PLFLT] radius of the circle.
2068 ** @param [r] startangle [PLFLT] angle of the start of the rectangle.
2069 ** @param [r] endangle [PLFLT] angle of the end of the rectangle.
2070 ** @param [r] height [PLFLT] Height of the rectangle in user coordinates.
2071 ** @return [void]
2072 **
2073 ** @release 6.2.0
2074 ** @@
2075 ******************************************************************************/
2076
ajGraphicsDrawarcRect(PLFLT xcentre,PLFLT ycentre,PLFLT radius,PLFLT startangle,PLFLT endangle,PLFLT height)2077 void ajGraphicsDrawarcRect(PLFLT xcentre, PLFLT ycentre, PLFLT radius,
2078 PLFLT startangle, PLFLT endangle,
2079 PLFLT height)
2080 {
2081 PLFLT *xyy1;
2082 PLFLT *xyy2;
2083 PLFLT r1Blocks;
2084 PLFLT r2Blocks;
2085
2086 r1Blocks = radius;
2087 r2Blocks = r1Blocks+height;
2088
2089 ajGraphicsDrawarcArc(xcentre, ycentre, r1Blocks, startangle, endangle);
2090 ajGraphicsDrawarcArc(xcentre, ycentre, r2Blocks, startangle, endangle);
2091
2092 xyy1 = ajGraphicsCalcCoord(xcentre, ycentre, r1Blocks, startangle);
2093 xyy2 = ajGraphicsCalcCoord(xcentre, ycentre, r2Blocks, startangle);
2094 ajGraphicsDrawposLine( xyy1[0], xyy1[1], xyy2[0], xyy2[1] );
2095 AJFREE(xyy1);
2096 AJFREE(xyy2);
2097 xyy1 = ajGraphicsCalcCoord(xcentre, ycentre, r1Blocks, endangle);
2098 xyy2 = ajGraphicsCalcCoord(xcentre, ycentre, r2Blocks, endangle);
2099 ajGraphicsDrawposLine( xyy1[0], xyy1[1], xyy2[0], xyy2[1] );
2100 AJFREE(xyy1);
2101 AJFREE(xyy2);
2102
2103 return;
2104 }
2105
2106
2107
2108
2109 /* @func ajGraphicsDrawarcRectFill ********************************************
2110 **
2111 ** Draw a rectangle along a curve and fill it with the current pen
2112 ** colour/style.
2113 **
2114 ** @param [r] xcentre [PLFLT] x coord for centre.
2115 ** @param [r] ycentre [PLFLT] y coord for centre.
2116 ** @param [r] radius [PLFLT] radius of the circle.
2117 ** @param [r] startangle [PLFLT] angle of the start of the rectangle.
2118 ** @param [r] endangle [PLFLT] angle of the end of the rectangle.
2119 ** @param [r] height [PLFLT] Height of the rectangle in user coordinates.
2120 ** @return [void]
2121 **
2122 ** @release 6.2.0
2123 ** @@
2124 ******************************************************************************/
2125
ajGraphicsDrawarcRectFill(PLFLT xcentre,PLFLT ycentre,PLFLT radius,PLFLT startangle,PLFLT endangle,PLFLT height)2126 void ajGraphicsDrawarcRectFill(PLFLT xcentre, PLFLT ycentre, PLFLT radius,
2127 PLFLT startangle, PLFLT endangle,
2128 PLFLT height)
2129 {
2130 PLFLT angle;
2131 ajuint i;
2132 PLFLT x[4];
2133 PLFLT y[4];
2134 ajuint numofpoints;
2135 PLFLT r1Blocks;
2136 PLFLT r2Blocks;
2137 PLFLT stopangle = endangle;
2138
2139 if(endangle < startangle)
2140 stopangle += 360.0;
2141
2142 if((stopangle-startangle)>=360.0)
2143 stopangle = startangle + (float) 360.0;
2144
2145 r1Blocks = radius;
2146 r2Blocks = r1Blocks+height;
2147
2148 x[0]=xcentre + ( r1Blocks*(float)cos(ajCvtDegToRad(startangle)) );
2149 y[0]=ycentre + ( r1Blocks*(float)sin(ajCvtDegToRad(startangle)) );
2150 x[1]=xcentre + ( r2Blocks*(float)cos(ajCvtDegToRad(startangle)) );
2151 y[1]=ycentre + ( r2Blocks*(float)sin(ajCvtDegToRad(startangle)) );
2152
2153 for(i=0, angle=startangle+1; angle<stopangle; angle++, i++)
2154 {
2155 x[2]=xcentre + ( r2Blocks*(float)cos(ajCvtDegToRad(angle)) );
2156 y[2]=ycentre + ( r2Blocks*(float)sin(ajCvtDegToRad(angle)) );
2157 x[3]=xcentre + ( r1Blocks*(float)cos(ajCvtDegToRad(angle)) );
2158 y[3]=ycentre + ( r1Blocks*(float)sin(ajCvtDegToRad(angle)) );
2159 numofpoints = 4;
2160 ajGraphicsDrawsetPolyFill(numofpoints, x, y);
2161 x[0] = x[3];
2162 y[0] = y[3];
2163 x[1] = x[2];
2164 y[1] = y[2];
2165 }
2166
2167 x[2]=xcentre + ( r2Blocks*(float)cos(ajCvtDegToRad(stopangle)) );
2168 y[2]=ycentre + ( r2Blocks*(float)sin(ajCvtDegToRad(stopangle)) );
2169 x[3]=xcentre + ( r1Blocks*(float)cos(ajCvtDegToRad(stopangle)) );
2170 y[3]=ycentre + ( r1Blocks*(float)sin(ajCvtDegToRad(stopangle)) );
2171 numofpoints = 4;
2172 ajGraphicsDrawsetPolyFill(numofpoints, x, y);
2173
2174 return;
2175 }
2176
2177
2178
2179
2180 /* @func ajGraphicsDrawarcTextJustify *****************************************
2181 **
2182 ** Draw text along a curve (i.e., an arc of a circle). The text is
2183 ** written character by character, forwards or backwards depending on
2184 ** the angle.
2185 **
2186 ** @param [r] xcentre [PLFLT] x coord for centre.
2187 ** @param [r] ycentre [PLFLT] y coord for centre.
2188 ** @param [r] radius [PLFLT] radius of the circle.
2189 ** @param [r] startangle [PLFLT] angle of the start of the arc (in deg).
2190 ** @param [r] endangle [PLFLT] angle of the end of the arc (in deg).
2191 ** @param [r] txt [const char*] The text to be displayed.
2192 ** @param [r] just [PLFLT] justification of the string.
2193 ** (0=left,1=right,0.5=middle etc)
2194 ** @return [void]
2195 **
2196 ** @release 6.2.0
2197 ** @@
2198 ******************************************************************************/
2199
ajGraphicsDrawarcTextJustify(PLFLT xcentre,PLFLT ycentre,PLFLT radius,PLFLT startangle,PLFLT endangle,const char * txt,PLFLT just)2200 void ajGraphicsDrawarcTextJustify(PLFLT xcentre, PLFLT ycentre, PLFLT radius,
2201 PLFLT startangle, PLFLT endangle,
2202 const char *txt, PLFLT just)
2203 {
2204 ajint numchar;
2205 PLFLT pos;
2206
2207 numchar = strlen(txt);
2208 pos = (endangle-startangle)/numchar;
2209
2210 if( ((startangle>180.0 && startangle<=360.0) &&
2211 (endangle>180.0 && endangle<=360.0)) ||
2212 ((startangle>540.0 && startangle<=720.0)
2213 && (endangle>540.0 && endangle<=720.0)) )
2214 GraphDrawarcText(xcentre, ycentre, radius, startangle,
2215 +1*pos, txt, just);
2216 else GraphDrawarcText(xcentre, ycentre, radius, endangle,
2217 -1*pos, txt, just);
2218
2219 return;
2220 }
2221
2222
2223
2224
2225 /* @func ajGraphicsDrawbarsHoriz **********************************************
2226 **
2227 ** Draw Horizontal Error Bars.
2228 **
2229 ** @param [r] num [ajuint] number of error bars to be drawn.
2230 ** @param [r] y [CONST PLFLT*] y positions to draw at.
2231 ** @param [r] xmin [CONST PLFLT*] x positions to start at.
2232 ** @param [r] xmax [CONST PLFLT*] x positions to end at.
2233 ** @return [void]
2234 **
2235 **
2236 ** @release 6.2.0
2237 ** @@
2238 ******************************************************************************/
ajGraphicsDrawbarsHoriz(ajuint num,PLFLT * y,PLFLT * xmin,PLFLT * xmax)2239 void ajGraphicsDrawbarsHoriz(ajuint num,
2240 PLFLT *y, PLFLT *xmin, PLFLT *xmax)
2241 {
2242 #if GRAPH_DEBUG
2243 if(num)
2244 ajDebug("=g= plerrx(%d %.2f..%.2f, %.2f, %.2f) "
2245 "[num,y..y,xmin,xmax]\n",
2246 num, y[0], y[num-1], xmin, xmax);
2247 else
2248 ajDebug("=g= plerrx(%d <>..<>, %.2f, %.2f) [num,y..y,xmin,xmax]\n",
2249 num, xmin, xmax);
2250 #endif
2251
2252 plerrx(num,y,xmin,xmax);
2253
2254 return;
2255 }
2256
2257
2258
2259
2260 /* @func ajGraphicsDrawbarsVert ***********************************************
2261 **
2262 ** Draw vertical Error Bars.
2263 **
2264 ** @param [r] num [ajuint] number of error bars to be drawn.
2265 ** @param [r] x [CONST PLFLT*] x positions to draw at.
2266 ** @param [r] ymin [CONST PLFLT*] y positions to start at.
2267 ** @param [r] ymax [CONST PLFLT*] y positions to end at.
2268 ** @return [void]
2269 **
2270 **
2271 ** @release 6.2.0
2272 ** @@
2273 ******************************************************************************/
2274
ajGraphicsDrawbarsVert(ajuint num,PLFLT * x,PLFLT * ymin,PLFLT * ymax)2275 void ajGraphicsDrawbarsVert(ajuint num,
2276 PLFLT *x, PLFLT *ymin, PLFLT *ymax)
2277 {
2278 #if GRAPH_DEBUG
2279 if(num)
2280 ajDebug("=g= plerry(%d %.2f..%.2f, %.2f, %.2f) "
2281 "[num,x..x,ymin,ymax]\n",
2282 num, x[0], x[num-1], ymin, ymax);
2283 else
2284 ajDebug("=g= plerry(%d <>..<>, %.2f, %.2f) [num,x..x,ymin,ymax]\n",
2285 num, ymin, ymax);
2286 #endif
2287
2288 plerry(num,x,ymin,ymax);
2289
2290 return;
2291 }
2292
2293
2294
2295
2296 /* @func ajGraphicsDrawposBox *************************************************
2297 **
2298 ** Draw a box to the plotter device at point xx0,yy0 size big.
2299 **
2300 ** @param [r] x [PLFLT] x position to draw the box.
2301 ** @param [r] y [PLFLT] y position to draw the box.
2302 ** @param [r] size [PLFLT] how big to draw the box.
2303 ** @return [void]
2304 **
2305 ** @release 6.2.0
2306 ** @@
2307 ******************************************************************************/
2308
ajGraphicsDrawposBox(PLFLT x,PLFLT y,PLFLT size)2309 void ajGraphicsDrawposBox(PLFLT x, PLFLT y,PLFLT size)
2310 {
2311 PLFLT xa[5];
2312 PLFLT ya[5];
2313
2314 if(graphData)
2315 {
2316 ajFmtPrintF(graphData->File,"Rectangle x1 %f y1 %f x2 %f"
2317 " y2 %f colour %d\n",
2318 x, y, x+size, y+size, currentfgcolour);
2319 graphData->Lines++;
2320 }
2321 else
2322 {
2323 xa[0] = x;
2324 ya[0] = y;
2325 xa[1] = x;
2326 ya[1] = y + size;
2327 xa[2] = x + size;
2328 ya[2] = y + size;
2329 xa[3] = x + size;
2330 ya[3] = y;
2331 xa[4] = x;
2332 ya[4] = y;
2333 GraphArray(5, xa, ya);
2334 }
2335
2336 return;
2337 }
2338
2339
2340
2341
2342 /* @func ajGraphicsDrawposBoxFill *********************************************
2343 **
2344 ** Draw a box to the plotter device at point xx0,yy0 size big and
2345 ** fill it in.
2346 **
2347 ** @param [r] x [PLFLT] x position to draw the box.
2348 ** @param [r] y [PLFLT] y position to draw the box.
2349 ** @param [r] size [PLFLT] how big to draw the box.
2350 ** @return [void]
2351 **
2352 ** @release 6.2.0
2353 ** @@
2354 ******************************************************************************/
2355
ajGraphicsDrawposBoxFill(PLFLT x,PLFLT y,PLFLT size)2356 void ajGraphicsDrawposBoxFill(PLFLT x, PLFLT y, PLFLT size)
2357 {
2358 PLFLT xa[4];
2359 PLFLT ya[4];
2360
2361 if(graphData)
2362 {
2363 ajFmtPrintF(graphData->File,"Shaded Rectangle x1 %f y1 %f x2 %f"
2364 " y2 %f colour %d\n",
2365 x, y, x+size, y+size, currentfgcolour);
2366 graphData->Lines++;
2367 }
2368 else
2369 {
2370 xa[0] = x;
2371 ya[0] = y;
2372 xa[1] = x;
2373 ya[1] = y + size;
2374 xa[2] = x + size;
2375 ya[2] = y + size;
2376 xa[3] = x + size;
2377 ya[3] = y;
2378 GraphFill(4, xa, ya);
2379 }
2380
2381 return;
2382 }
2383
2384
2385
2386
2387 /* @func ajGraphicsDrawposCircle **********************************************
2388 **
2389 ** Draw a circle.
2390 **
2391 ** @param [r] x [PLFLT] x coord for centre.
2392 ** @param [r] y [PLFLT] y coord for centre.
2393 ** @param [r] radius [float] radius of the circle.
2394 ** @return [void]
2395 **
2396 ** @release 6.2.0
2397 ** @@
2398 **
2399 ** FIXME: Due to x and y not the same length this produces an oval!!
2400 ** This will have to do for now. But I (il@sanger) am aware that the code
2401 ** is slow and not quite right.
2402 ******************************************************************************/
2403
ajGraphicsDrawposCircle(PLFLT x,PLFLT y,float radius)2404 void ajGraphicsDrawposCircle(PLFLT x, PLFLT y, float radius)
2405 {
2406 PLFLT xa[361];
2407 PLFLT ya[361];
2408
2409 ajint i;
2410
2411 /* graphData : uses GraphArray */
2412
2413 for(i=0;i<360;i++)
2414 {
2415 xa[i] = x + (radius * (float)cos(ajCvtDegToRad((float)i)));
2416 ya[i] = y + (radius * (float)sin(ajCvtDegToRad((float)i)));
2417 }
2418
2419 xa[360] = xa[0];
2420 ya[360] = ya[0];
2421
2422 GraphArray(361, xa,ya);
2423
2424 return;
2425 }
2426
2427
2428
2429
2430 /* @func ajGraphicsDrawposDia *************************************************
2431 **
2432 ** Draw a diamond to the plotter device at point xx0,yy0 size big.
2433 **
2434 ** @param [r] x [PLFLT] x position to draw the diamond.
2435 ** @param [r] y [PLFLT] y position to draw the diamond.
2436 ** @param [r] size [PLFLT] how big to draw the diamond.
2437 ** @return [void]
2438 **
2439 ** @release 6.2.0
2440 ** @@
2441 ******************************************************************************/
2442
ajGraphicsDrawposDia(PLFLT x,PLFLT y,PLFLT size)2443 void ajGraphicsDrawposDia(PLFLT x, PLFLT y, PLFLT size)
2444 {
2445 PLFLT xa[5];
2446 PLFLT ya[5];
2447 PLFLT incr;
2448
2449 incr = size*(float)0.5;
2450
2451 /* graphData : uses GraphArray */
2452
2453 xa[0] = x;
2454 ya[0] = y + incr;
2455 xa[1] = x + incr;
2456 ya[1] = y + size;
2457 xa[2] = x + size;
2458 ya[2] = y + incr;
2459 xa[3] = x + incr;
2460 ya[3] = y;
2461 xa[4] = x;
2462 ya[4] = y + incr;
2463 GraphArray(5, xa, ya);
2464
2465 return;
2466 }
2467
2468
2469
2470
2471 /* @func ajGraphicsDrawposDiaFill *********************************************
2472 **
2473 ** Draw a diamond to the plotter device at point xx0,yy0 size big and
2474 ** fill it in.
2475 **
2476 ** @param [r] x [PLFLT] x position to draw the diamond.
2477 ** @param [r] y [PLFLT] y position to draw the diamond.
2478 ** @param [r] size [PLFLT] how big to draw the diamond.
2479 ** @return [void]
2480 **
2481 ** @release 6.2.0
2482 ** @@
2483 ******************************************************************************/
2484
ajGraphicsDrawposDiaFill(PLFLT x,PLFLT y,PLFLT size)2485 void ajGraphicsDrawposDiaFill(PLFLT x, PLFLT y, PLFLT size)
2486 {
2487 PLFLT xa[4];
2488 PLFLT ya[4];
2489 PLFLT incr;
2490
2491 incr = size*(float)0.5;
2492
2493 xa[0] = x;
2494 ya[0] = y + incr;
2495 xa[1] = x + incr;
2496 ya[1] = y + size;
2497 xa[2] = x + size;
2498 ya[2] = y + incr;
2499 xa[3] = x + incr;
2500 ya[3] = y;
2501
2502 GraphFill(4, xa, ya);
2503
2504 return;
2505 }
2506
2507
2508
2509
2510 /* @func ajGraphicsDrawposLine ************************************************
2511 **
2512 ** Draw line between 2 points.
2513 **
2514 ** @param [r] x [PLFLT] x start position.
2515 ** @param [r] y [PLFLT] y start position.
2516 ** @param [r] x2 [PLFLT] x end position.
2517 ** @param [r] y2 [PLFLT] y end position.
2518 ** @return [void]
2519 **
2520 ** @release 6.2.0
2521 ** @@
2522 ******************************************************************************/
2523
ajGraphicsDrawposLine(PLFLT x,PLFLT y,PLFLT x2,PLFLT y2)2524 void ajGraphicsDrawposLine(PLFLT x, PLFLT y, PLFLT x2, PLFLT y2)
2525 {
2526 if(graphData)
2527 {
2528 ajFmtPrintF(graphData->File,
2529 "Line x1 %f y1 %f x2 %f y2 %f colour %d\n",
2530 x, y, x2, y2, currentfgcolour);
2531 graphData->Lines++;
2532 }
2533 else
2534 {
2535 #if GRAPH_DEBUG
2536 ajDebug("=g= pljoin(%.2f, %.2f, %.2f, %.2f) [xy xy]\n",
2537 x, y, x2, y2);
2538 #endif
2539
2540 pljoin(x,y,x2,y2);
2541 }
2542
2543 return;
2544 }
2545
2546
2547
2548
2549 /* @func ajGraphicsDrawposRect ************************************************
2550 **
2551 ** Draw a rectangle with the current pen colour/style.
2552 **
2553 ** @param [r] x [PLFLT] xx0 coord.
2554 ** @param [r] y [PLFLT] yy0 coord.
2555 ** @param [r] x2 [PLFLT] xx1 coord.
2556 ** @param [r] y2 [PLFLT] yy1 coord.
2557 ** @return [void]
2558 **
2559 **
2560 ** @release 6.2.0
2561 ** @@
2562 ******************************************************************************/
2563
ajGraphicsDrawposRect(PLFLT x,PLFLT y,PLFLT x2,PLFLT y2)2564 void ajGraphicsDrawposRect(PLFLT x, PLFLT y,PLFLT x2, PLFLT y2)
2565 {
2566 PLFLT xa[5];
2567 PLFLT ya[5];
2568
2569 if(graphData)
2570 {
2571 ajFmtPrintF(graphData->File,"Rectangle x1 %f y1 %f x2 %f"
2572 " y2 %f colour %d\n",
2573 x, y, x2, y2, currentfgcolour);
2574 graphData->Lines++;
2575 }
2576 else
2577 {
2578 xa[0] = x;
2579 ya[0] = y;
2580 xa[1] = x;
2581 ya[1] = y2;
2582 xa[2] = x2;
2583 ya[2] = y2;
2584 xa[3] = x2;
2585 ya[3] = y;
2586 xa[4] = x;
2587 ya[4] = y;
2588 GraphArray(5, xa, ya);
2589 }
2590
2591 return;
2592 }
2593
2594
2595
2596
2597 /* @func ajGraphicsDrawposRectFill ********************************************
2598 **
2599 ** Draw a rectangle and fill it with the current pen colour/style.
2600 **
2601 ** @param [r] x [PLFLT] xx0 coord.
2602 ** @param [r] y [PLFLT] yy0 coord.
2603 ** @param [r] x2 [PLFLT] xx1 coord.
2604 ** @param [r] y2 [PLFLT] yy1 coord.
2605 ** @return [void]
2606 **
2607 **
2608 ** @release 6.2.0
2609 ** @@
2610 ******************************************************************************/
2611
ajGraphicsDrawposRectFill(PLFLT x,PLFLT y,PLFLT x2,PLFLT y2)2612 void ajGraphicsDrawposRectFill(PLFLT x, PLFLT y, PLFLT x2, PLFLT y2)
2613 {
2614 PLFLT xa[4];
2615 PLFLT ya[4];
2616
2617 if(graphData)
2618 {
2619 ajFmtPrintF(graphData->File,"Shaded Rectangle x1 %f y1 %f x2 %f"
2620 " y2 %f colour %d\n",
2621 x, y, x2, y2, currentfgcolour);
2622 graphData->Lines++;
2623 }
2624 else
2625 {
2626 xa[0] = x;
2627 ya[0] = y;
2628 xa[1] = x;
2629 ya[1] = y2;
2630 xa[2] = x2;
2631 ya[2] = y2;
2632 xa[3] = x2;
2633 ya[3] = y;
2634 GraphFill(4, xa, ya);
2635 }
2636
2637 return;
2638 }
2639
2640
2641
2642
2643 /* @func ajGraphicsDrawposTextAtend *******************************************
2644 **
2645 ** Draw text ending at position (xx1,yy1)
2646 **
2647 ** @param [r] x [PLFLT] xx1 coord.
2648 ** @param [r] y [PLFLT] yy1 coord.
2649 ** @param [r] txt [const char*] The text to be displayed.
2650 ** @return [void]
2651 **
2652 **
2653 ** @release 6.2.0
2654 ** @@
2655 ******************************************************************************/
2656
ajGraphicsDrawposTextAtend(PLFLT x,PLFLT y,const char * txt)2657 void ajGraphicsDrawposTextAtend(PLFLT x, PLFLT y, const char *txt)
2658 {
2659 if(graphData)
2660 {
2661 ajFmtPrintF(graphData->File,
2662 "Text3 x1 %f y1 %f colour %d size %f %s\n",
2663 x,y,
2664 currentfgcolour, currentcharscale,txt);
2665 graphData->Lines++;
2666 }
2667 else
2668 GraphText(x,y,1.0,0.0,1.0, txt);
2669
2670 return;
2671 }
2672
2673
2674
2675
2676 /* @func ajGraphicsDrawposTextAtlineJustify ***********************************
2677 **
2678 ** Draw text along a line.
2679 **
2680 ** @param [r] x [PLFLT] x1 coord.
2681 ** @param [r] y [PLFLT] y1 coord.
2682 ** @param [r] x2 [PLFLT] x2 coord.
2683 ** @param [r] y2 [PLFLT] y2 coord.
2684 ** @param [r] txt [const char*] The text to be displayed.
2685 ** @param [r] just [PLFLT] justification of the string.
2686 ** (0=left,1=right,0.5=middle etc)
2687 ** @return [void]
2688 **
2689 **
2690 ** @release 6.2.0
2691 ** @@
2692 ******************************************************************************/
2693
ajGraphicsDrawposTextAtlineJustify(PLFLT x,PLFLT y,PLFLT x2,PLFLT y2,const char * txt,PLFLT just)2694 void ajGraphicsDrawposTextAtlineJustify(PLFLT x, PLFLT y, PLFLT x2, PLFLT y2,
2695 const char *txt, PLFLT just)
2696 {
2697 if(graphData)
2698 {
2699 ajFmtPrintF(graphData->File,
2700 "Textline x1 %f y1 %f x2 %f y2 %f colour %d size %f %s\n",
2701 x,y,x2, y2,
2702 currentfgcolour, currentcharscale,txt);
2703 graphData->Lines++;
2704 }
2705 else
2706 GraphText(x,y,x2-x,y2-y,just, txt);
2707
2708 return;
2709 }
2710
2711
2712
2713
2714 /* @func ajGraphicsDrawposTextAtmid *******************************************
2715 **
2716 ** Draw text with Mid point of text at (xx1,yy1).
2717 **
2718 ** For graph data type, writes directly.
2719 **
2720 ** @param [r] x [PLFLT] xx1 coord.
2721 ** @param [r] y [PLFLT] yy1 coord.
2722 ** @param [r] txt [const char*] The text to be displayed.
2723 ** @return [void]
2724 **
2725 **
2726 ** @release 6.2.0
2727 ** @@
2728 ******************************************************************************/
2729
ajGraphicsDrawposTextAtmid(PLFLT x,PLFLT y,const char * txt)2730 void ajGraphicsDrawposTextAtmid(PLFLT x, PLFLT y, const char *txt)
2731 {
2732 if(graphData)
2733 {
2734 ajFmtPrintF(graphData->File,
2735 "Text2 x1 %f y1 %f colour %d size %f %s\n",
2736 x, y,
2737 currentfgcolour, currentcharscale, txt);
2738 graphData->Lines++;
2739 }
2740 else
2741 GraphText(x,y,1.0,0.0,0.5, txt);
2742
2743 return;
2744 }
2745
2746
2747
2748
2749 /* @func ajGraphicsDrawposTextAtstart *****************************************
2750 **
2751 ** Draw text starting at position (xx1,yy1)
2752 **
2753 ** @param [r] x [PLFLT] xx1 coordinate
2754 ** @param [r] y [PLFLT] yy1 coordinate
2755 ** @param [r] txt [const char*] The text to be displayed.
2756 ** @return [void]
2757 **
2758 **
2759 ** @release 6.2.0
2760 ** @@
2761 ******************************************************************************/
2762
ajGraphicsDrawposTextAtstart(PLFLT x,PLFLT y,const char * txt)2763 void ajGraphicsDrawposTextAtstart(PLFLT x, PLFLT y, const char *txt)
2764 {
2765 if(graphData)
2766 {
2767 ajFmtPrintF(graphData->File,
2768 "Text1 x1 %f y1 %f colour %d size %f %s\n",
2769 x,y,
2770 currentfgcolour, currentcharscale,txt);
2771 graphData->Lines++;
2772 }
2773 else
2774 GraphText(x,y,1.0,0.0,0.0, txt);
2775
2776 return;
2777 }
2778
2779
2780
2781
2782 /* @func ajGraphicsDrawposTextJustify *****************************************
2783 **
2784 ** Draw text, positioning with respect to (xx1,yy1) by justified as
2785 ** defined by just.
2786 **
2787 ** @param [r] x [PLFLT] xx1 coord.
2788 ** @param [r] y [PLFLT] yy1 coord.
2789 ** @param [r] txt [const char*] The text to be displayed.
2790 ** @param [r] just [PLFLT] justification of the string.
2791 ** (0=left,1=right,0.5=middle etc)
2792 ** @return [void]
2793 **
2794 **
2795 ** @release 6.2.0
2796 ** @@
2797 ******************************************************************************/
2798
ajGraphicsDrawposTextJustify(PLFLT x,PLFLT y,const char * txt,PLFLT just)2799 void ajGraphicsDrawposTextJustify(PLFLT x, PLFLT y, const char *txt,
2800 PLFLT just)
2801 {
2802 if(graphData)
2803 {
2804 ajFmtPrintF(graphData->File,
2805 "Text1 x1 %f y1 %f colour %d size %f %s\n",
2806 x,y,currentfgcolour, currentcharscale,txt);
2807 graphData->Lines++;
2808 }
2809 else
2810 GraphText(x,y,1.0,0.0,just, txt);
2811
2812 return;
2813 }
2814
2815
2816
2817
2818 /* @func ajGraphicsDrawposTri *************************************************
2819 **
2820 ** Draw a Triangle.
2821 **
2822 ** @param [r] x [PLFLT] xx1 coord of point 1.
2823 ** @param [r] y [PLFLT] yy1 coord of point 1.
2824 ** @param [r] x2 [PLFLT] xx2 coord of point 2.
2825 ** @param [r] y2 [PLFLT] yy2 coord of point 2.
2826 ** @param [r] x3 [PLFLT] x3 coord of point 3.
2827 ** @param [r] y3 [PLFLT] y3 coord of point 3.
2828 ** @return [void]
2829 **
2830 ** @release 6.2.0
2831 ** @@
2832 ******************************************************************************/
2833
ajGraphicsDrawposTri(PLFLT x,PLFLT y,PLFLT x2,PLFLT y2,PLFLT x3,PLFLT y3)2834 void ajGraphicsDrawposTri(PLFLT x, PLFLT y, PLFLT x2, PLFLT y2,
2835 PLFLT x3, PLFLT y3)
2836 {
2837 PLFLT xa[4];
2838 PLFLT ya[4];
2839
2840 xa[0]=x; xa[1]=x2; xa[2]=x3; xa[3]=x;
2841 ya[0]=y; ya[1]=y2; ya[2]=y3; ya[3]=y;
2842
2843 ajGraphicsDrawsetPoly(4, xa, ya);
2844
2845 return;
2846 }
2847
2848
2849
2850
2851 /* @func ajGraphicsDrawposTriFill *********************************************
2852 **
2853 ** Draw a Triangle and fill it in.
2854 **
2855 ** @param [r] x [PLFLT] xx1 coord of point 1.
2856 ** @param [r] y [PLFLT] yy1 coord of point 1.
2857 ** @param [r] x2 [PLFLT] xx2 coord of point 2.
2858 ** @param [r] y2 [PLFLT] yy2 coord of point 2.
2859 ** @param [r] x3 [PLFLT] x3 coord of point 3.
2860 ** @param [r] y3 [PLFLT] y3 coord of point 3.
2861 ** @return [void]
2862 **
2863 ** @release 6.2.0
2864 ** @@
2865 ******************************************************************************/
2866
ajGraphicsDrawposTriFill(PLFLT x,PLFLT y,PLFLT x2,PLFLT y2,PLFLT x3,PLFLT y3)2867 void ajGraphicsDrawposTriFill(PLFLT x, PLFLT y, PLFLT x2, PLFLT y2,
2868 PLFLT x3, PLFLT y3)
2869 {
2870 PLFLT xa[3];
2871 PLFLT ya[3];
2872
2873 xa[0]=x; xa[1]=x2; xa[2]=x3;
2874 ya[0]=y; ya[1]=y2; ya[2]=y3;
2875
2876 ajGraphicsDrawsetPolyFill(3, xa, ya);
2877
2878 return;
2879 }
2880
2881
2882
2883
2884 /* @func ajGraphicsDrawsetDots ************************************************
2885 **
2886 ** Draw a set of dots.
2887 **
2888 ** @param [r] num [ajuint] The number of dots to be drawn.
2889 ** @param [r] xx [CONST PLFLT*] xx1 coord.
2890 ** @param [r] yy [CONST PLFLT*] yy1 coord.
2891 ** @return [void]
2892 **
2893 **
2894 ** @release 6.2.0
2895 ** @@
2896 ******************************************************************************/
2897
ajGraphicsDrawsetDots(ajuint num,PLFLT * xx,PLFLT * yy)2898 void ajGraphicsDrawsetDots(ajuint num, PLFLT *xx, PLFLT *yy)
2899 {
2900 GraphSymbols(xx, yy, num, 17);
2901
2902 /* see xx06c in examples for codes e.g. 17 is a dot*/
2903 return;
2904 }
2905
2906
2907
2908
2909 /* @funcstatic GraphDrawsetLines **********************************************
2910 **
2911 ** Draw a number of lines. The points are stored in two array.
2912 **
2913 ** @param [r] num [ajuint] number of joined points to plot.
2914 ** @param [r] xx [CONST PLFLT*] pointer to x coordinates.
2915 ** @param [r] yy [CONST PLFLT*] pointer to y coordinates.
2916 ** @return [void]
2917 **
2918 ** @release 6.2.0
2919 ** @@
2920 ******************************************************************************/
2921
GraphDrawsetLines(ajuint num,PLFLT * xx,PLFLT * yy)2922 static void GraphDrawsetLines(ajuint num, PLFLT *xx, PLFLT *yy)
2923 {
2924 ajuint i;
2925 PLFLT xx0;
2926 PLFLT yy0;
2927 PLFLT *xx1 = xx;
2928 PLFLT *yy1 = yy;
2929
2930 /* graphdata : calls ajGraphicsDrawposLine */
2931
2932 for(i=1; i<num; i++)
2933 {
2934 xx0 = *xx1++;
2935 yy0 = *yy1++;
2936 ajGraphicsDrawposLine(xx0,yy0,*xx1,*yy1);
2937 }
2938
2939 return;
2940 }
2941
2942
2943
2944
2945 /* @func ajGraphicsDrawsetLines ***********************************************
2946 **
2947 ** Draw a set of lines.
2948 **
2949 ** @param [r] num [ajuint] The number of lines to be drawn.
2950 ** @param [u] xx [CONST PLFLT*] x start coordinates
2951 ** @param [u] yy [CONST PLFLT*] y start coordinates
2952 ** @param [u] xx2 [CONST PLFLT*] x end coordinates
2953 ** @param [u] yy2 [CONST PLFLT*] y end coordinates
2954 ** @return [void]
2955 **
2956 **
2957 ** @release 6.2.0
2958 ** @@
2959 ******************************************************************************/
2960
ajGraphicsDrawsetLines(ajuint num,PLFLT * xx,PLFLT * yy,PLFLT * xx2,PLFLT * yy2)2961 void ajGraphicsDrawsetLines(ajuint num, PLFLT *xx, PLFLT *yy,
2962 PLFLT *xx2, PLFLT *yy2)
2963 {
2964 ajuint i = 0;
2965 PLFLT *xa = xx;
2966 PLFLT *ya = yy;
2967 PLFLT *xb = xx2;
2968 PLFLT *yb = yy2;
2969
2970 /* graphdata : calls ajGraphLine */
2971
2972 /*ajDebug("=g= ajGraphicsDrawsetLines(... %d) "
2973 "[xx1,xx2,yy1,yy2,numoflines]\n",
2974 num);*/
2975
2976 for(i=0; i<num; i++)
2977 ajGraphicsDrawposLine(*xa++,*ya++,*xb++,*yb++);
2978
2979 return;
2980 }
2981
2982
2983
2984
2985 /* @func ajGraphicsDrawsetPoly ************************************************
2986 **
2987 ** Draw a polygon.
2988 **
2989 ** @param [r] num [ajuint] number of points
2990 ** @param [r] xx [CONST PLFLT *] x coord of points
2991 ** @param [r] yy [CONST PLFLT *] y coord of points
2992 ** @return [void]
2993 **
2994 ** @release 6.2.0
2995 ** @@
2996 ******************************************************************************/
2997
ajGraphicsDrawsetPoly(ajuint num,PLFLT * xx,PLFLT * yy)2998 void ajGraphicsDrawsetPoly(ajuint num, PLFLT *xx, PLFLT *yy)
2999 {
3000 /* graphData : uses GraphArray */
3001
3002 GraphArray(num, xx, yy);
3003
3004 return;
3005 }
3006
3007
3008
3009
3010 /* @func ajGraphicsDrawsetPolyFill ********************************************
3011 **
3012 ** Draw a polygon and fill it in.
3013 **
3014 ** @param [r] num [ajuint] number of points
3015 ** @param [r] xx [CONST PLFLT *] x coord of points
3016 ** @param [r] yy [CONST PLFLT *] y coord of points
3017 ** @return [void]
3018 **
3019 ** @release 6.2.0
3020 ** @@
3021 ******************************************************************************/
3022
ajGraphicsDrawsetPolyFill(ajuint num,PLFLT * xx,PLFLT * yy)3023 void ajGraphicsDrawsetPolyFill(ajuint num, PLFLT *xx, PLFLT *yy)
3024 {
3025 GraphFill(num, xx, yy);
3026
3027 return;
3028 }
3029
3030
3031
3032
3033 /* @func ajGraphicsDrawsetSymbols *********************************************
3034 **
3035 ** Draw a set of dots.
3036 **
3037 ** @param [r] num [ajuint] Number of coordinates in xx1 and xx2.
3038 ** @param [r] xx [CONST PLFLT*] xx1 coord.
3039 ** @param [r] yy [CONST PLFLT*] yy1 coord.
3040 ** @param [r] symbol [ajuint] Symbol code.
3041 ** @return [void]
3042 **
3043 **
3044 ** @release 6.2.0
3045 ** @@
3046 ******************************************************************************/
3047
ajGraphicsDrawsetSymbols(ajuint num,PLFLT * xx,PLFLT * yy,ajuint symbol)3048 void ajGraphicsDrawsetSymbols(ajuint num, PLFLT *xx, PLFLT *yy,
3049 ajuint symbol)
3050 {
3051 GraphSymbols(xx, yy, num, symbol);
3052
3053 /* see xx06c in examples for codes e.g. 17 is a dot*/
3054 return;
3055 }
3056
3057
3058
3059
3060 /* @section Calculations ******************************************************
3061 **
3062 ** Calculations using plot internals
3063 **
3064 ** @fdata [none]
3065 ** @fcategory cast
3066 **
3067 ** @nam3rule Calc Calculation
3068 ** @nam4rule Charsize Computes the character size (in mm)
3069 ** @nam4rule Coord Compute the coordinates of a point on a circle
3070 ** knowing the angle
3071 ** @nam4rule Distance Compute the distance between 2 points in user coordinates
3072 ** @nam4rule Range Get the max and min of the data points you wish to display.
3073 ** @nam4rule Textheight Get text height (in mm)
3074 ** @nam4rule Textlength Get text length (in mm)
3075 ** @suffix C Character data
3076 ** @suffix S String object data
3077 **
3078 ** @argrule Charsize xx1 [PLFLT] xx1 coord.
3079 ** @argrule Charsize yy1 [PLFLT] yy1 coord.
3080 ** @argrule Charsize xx2 [PLFLT] xx2 coord.
3081 ** @argrule Charsize yy2 [PLFLT] yy2 coord.
3082 ** @argrule Charsize text [const char*] The text to be displayed.
3083 ** @argrule Charsize TextHeight [PLFLT] The height of the text (in user coord).
3084 ** @argrule Coord x [PLFLT] x coord for centre.
3085 ** @argrule Coord y [PLFLT] y coord for centre.
3086 ** @argrule Coord radius [PLFLT] Radius of the circle.
3087 ** @argrule Coord angle [PLFLT] angle at which the point is.
3088 ** @argrule Distance xx1 [PLFLT] x coord of point 1
3089 ** @argrule Distance yy1 [PLFLT] y coord of point 1
3090 ** @argrule Distance xx2 [PLFLT] x coord of point 2
3091 ** @argrule Distance yy2 [PLFLT] y coord of point 2
3092 ** @argrule Range array [const float*] array
3093 ** @argrule Range npoints [ajuint] Number of data points
3094 ** @argrule Range min [float*] min. value in array
3095 ** @argrule Range max [float*] max. value in array
3096 ** @argrule [r] C txt [const char*] Text
3097 ** @argrule [r] S str [const AjPStr] Text
3098 **
3099 ** @valrule * [void]
3100 ** @valrule *Charsize [PLFLT] The character size (in mm) that fits the specified
3101 ** height and length.
3102 ** @valrule *Coord [PLFLT*] The x and y coordinates of the point
3103 ** @valrule *Distance [PLFLT] Distance between 2 points in user coordinates
3104 ** @valrule *Textheight [PLFLT] Text height (in mm)
3105 ** @valrule *Textlength [PLFLT] Text length (in mm)
3106 **
3107 ******************************************************************************/
3108
3109
3110
3111
3112 /* @func ajGraphicsCalcCharsize ***********************************************
3113 **
3114 ** Computes the character size (in mm) needed to write a text string
3115 ** with specified height and length (in user coord). The length of the
3116 ** string is the distance between (xx1,yy1) and (xx2,yy2); its height is
3117 ** TextHeight. If the default size is too large, characters are
3118 ** shrunk. If it is too small, characters are enlarged.
3119 **
3120 ** @param [r] xx1 [PLFLT] xx1 coord.
3121 ** @param [r] yy1 [PLFLT] yy1 coord.
3122 ** @param [r] xx2 [PLFLT] xx2 coord.
3123 ** @param [r] yy2 [PLFLT] yy2 coord.
3124 ** @param [r] text [const char*] The text to be displayed.
3125 ** @param [r] TextHeight [PLFLT] The height of the text (in user coord).
3126 ** @return [PLFLT] The character size (in mm) that fits the specified
3127 ** height and length.
3128 **
3129 **
3130 ** @release 6.2.0
3131 ** @@
3132 ******************************************************************************/
3133
ajGraphicsCalcCharsize(PLFLT xx1,PLFLT yy1,PLFLT xx2,PLFLT yy2,const char * text,PLFLT TextHeight)3134 PLFLT ajGraphicsCalcCharsize(PLFLT xx1, PLFLT yy1, PLFLT xx2, PLFLT yy2,
3135 const char *text,
3136 PLFLT TextHeight)
3137 {
3138 PLFLT origStringHeight = 0.0;
3139 PLFLT origStringLength = 0.0;
3140 PLFLT distpts = 0.0;
3141 PLFLT origcharsize = 0.0;
3142 PLFLT origcharht = 0.0;
3143 PLFLT newcharsize = 0.0;
3144 PLFLT wx1 = 0.0;
3145 PLFLT wx2 = 0.0;
3146 PLFLT wy1 = 0.0;
3147 PLFLT wy2 = 0.0;
3148 PLINT win = 0;
3149
3150 plcalc_world(xx1, yy1, &wx1, &wy1, &win);
3151 plcalc_world(xx2, yy2, &wx2, &wy2, &win);
3152
3153 /* adjust character height */
3154
3155 ajGraphicsGetCharsize(&origcharsize,&origcharht);
3156
3157 origStringHeight = currentcharsize;
3158
3159 newcharsize = origcharsize * TextHeight/origStringHeight;
3160 ajGraphicsSetCharsize(newcharsize);
3161
3162 /* Now we have to check the text fits the available space */
3163
3164 /* adjust character width */
3165 distpts = ajGraphicsCalcDistance(xx1, yy1, xx2, yy2);
3166 origStringLength = ajGraphicsCalcTextlengthC(text);
3167
3168 if(origStringLength > distpts)
3169 newcharsize = newcharsize * distpts/origStringLength;
3170
3171 ajDebug("ajGraphicsCalcCharsize returns charsize %f\n", newcharsize);
3172 ajGraphicsSetCharsize(origcharsize);
3173
3174 return newcharsize;
3175 }
3176
3177
3178
3179
3180 /* @func ajGraphicsCalcCoord **************************************************
3181 **
3182 ** compute the coordinates of a point on a circle knowing the angle.
3183 **
3184 ** @param [r] x [PLFLT] x coord for centre.
3185 ** @param [r] y [PLFLT] y coord for centre.
3186 ** @param [r] radius [PLFLT] Radius of the circle.
3187 ** @param [r] angle [PLFLT] angle at which the point is.
3188 ** @return [PLFLT*] The x and y coordinates of the point.
3189 **
3190 ** @release 6.2.0
3191 ** @@
3192 ******************************************************************************/
3193
ajGraphicsCalcCoord(PLFLT x,PLFLT y,PLFLT radius,PLFLT angle)3194 PLFLT* ajGraphicsCalcCoord(PLFLT x, PLFLT y, PLFLT radius, PLFLT angle)
3195 {
3196 PLFLT *xy;
3197
3198 xy = (float *)AJALLOC( 2*sizeof(float) );
3199 xy[0] = x + ( radius*(float)cos(ajCvtDegToRad(angle)) );
3200 xy[1] = y + ( radius*(float)sin(ajCvtDegToRad(angle)) );
3201
3202 return xy;
3203 }
3204
3205
3206
3207
3208 /* @func ajGraphicsCalcDistance ***********************************************
3209 **
3210 ** Compute the distance between 2 points in user coordinates.
3211 **
3212 ** @param [r] xx1 [PLFLT] x coord of point 1
3213 ** @param [r] yy1 [PLFLT] y coord of point 1
3214 ** @param [r] xx2 [PLFLT] x coord of point 2
3215 ** @param [r] yy2 [PLFLT] y coord of point 2
3216 **
3217 ** @return [PLFLT] The distance between the 2 points in user coordinates.
3218 **
3219 ** @release 6.2.0
3220 ** @@
3221 ******************************************************************************/
3222
ajGraphicsCalcDistance(PLFLT xx1,PLFLT yy1,PLFLT xx2,PLFLT yy2)3223 PLFLT ajGraphicsCalcDistance(PLFLT xx1, PLFLT yy1, PLFLT xx2, PLFLT yy2)
3224 {
3225 return GraphDistPts(xx1, yy1, xx2, yy2);
3226 }
3227
3228
3229
3230
3231 /* @func ajGraphicsCalcRange **************************************************
3232 **
3233 ** Get the max and min of the data points you wish to display.
3234 **
3235 ** @param [r] array [const float*] array
3236 ** @param [r] npoints [ajuint] Number of data points
3237 ** @param [w] min [float*] min.
3238 ** @param [w] max [float*] max.
3239 ** @return [void]
3240 **
3241 ** @release 6.2.0
3242 ** @@
3243 ******************************************************************************/
3244
ajGraphicsCalcRange(const float * array,ajuint npoints,float * min,float * max)3245 void ajGraphicsCalcRange(const float *array,
3246 ajuint npoints, float *min, float *max)
3247 {
3248 ajuint i;
3249
3250 *min = FLT_MAX;
3251 *max = -FLT_MAX;
3252
3253 for(i=0;i<npoints;++i)
3254 {
3255 *min = (*min < array[i]) ? *min : array[i];
3256 *max = (*max > array[i]) ? *max : array[i];
3257 }
3258
3259 if(*min == *max)
3260 {
3261 *min *= (float) 0.9;
3262 *max *= (float) 1.1;
3263 }
3264
3265 return;
3266 }
3267
3268
3269
3270
3271 /* @func ajGraphicsCalcTextheight *********************************************
3272 **
3273 ** Compute the height of a character in millimetres.
3274 **
3275 ** @return [PLFLT] The height of the character in user coordinates.
3276 **
3277 ** @release 6.2.0
3278 ** @@
3279 ******************************************************************************/
3280
ajGraphicsCalcTextheight(void)3281 PLFLT ajGraphicsCalcTextheight(void)
3282 {
3283 return currentcharsize;
3284 }
3285
3286
3287
3288
3289 /* @func ajGraphicsCalcTextlengthC ********************************************
3290 **
3291 ** Compute the length of a string in millimetres.
3292 **
3293 ** @param [r] txt [const char*] Text
3294 **
3295 ** @return [PLFLT] The length of the string in user coordinates.
3296 **
3297 ** @release 6.2.0
3298 ** @@
3299 ******************************************************************************/
3300
ajGraphicsCalcTextlengthC(const char * txt)3301 PLFLT ajGraphicsCalcTextlengthC(const char *txt)
3302 {
3303 return GraphTextLength(txt);
3304 }
3305
3306
3307
3308
3309 /* @func ajGraphicsCalcTextlengthS ********************************************
3310 **
3311 ** Compute the length of a string in millimetres.
3312 **
3313 ** @param [r] str [const AjPStr] Text
3314 **
3315 ** @return [PLFLT] The length of the string in user coordinates.
3316 **
3317 ** @release 6.2.0
3318 ** @@
3319 ******************************************************************************/
3320
ajGraphicsCalcTextlengthS(const AjPStr str)3321 PLFLT ajGraphicsCalcTextlengthS(const AjPStr str)
3322 {
3323 return GraphTextLength(MAJSTRGETPTR(str));
3324 }
3325
3326
3327
3328
3329 /* @section unused ************************************************************
3330 **
3331 ** @fdata [none]
3332 **
3333 ** @nam3rule Unused Contains dummy calls to unused functions to keep
3334 ** compilers happy
3335 **
3336 ** @valrule * [void]
3337 ** @fcategory misc
3338 **
3339 ******************************************************************************/
3340
3341
3342
3343
3344 /* @func ajGraphicsUnused *****************************************************
3345 **
3346 ** Unused functions to avoid compiler warnings
3347 **
3348 ** @return [void]
3349 **
3350 ** @release 6.2.0
3351 ** @@
3352 ******************************************************************************/
3353
ajGraphicsUnused(void)3354 void ajGraphicsUnused(void)
3355 {
3356 float f = 0.0;
3357 ajint i = 0;
3358 AjPGraph thys = NULL;
3359 AjPGraphdata graphdata = NULL;
3360
3361 GraphPrint(thys);
3362 GraphDataPrint(graphdata);
3363 GraphCheckPoints(0, &f, &f);
3364 GraphCheckFlags(0);
3365 GraphArrayGapsI(0, &i, &i);
3366
3367 return;
3368 }
3369
3370
3371
3372
3373 /* @section exit **************************************************************
3374 **
3375 ** Functions called on exit
3376 **
3377 ** @fdata [none]
3378 **
3379 ** @nam3rule Exit Cleanup of internals when program exits
3380 **
3381 ** @valrule * [void]
3382 ** @fcategory misc
3383 **
3384 ******************************************************************************/
3385
3386
3387
3388
3389 /* @func ajGraphicsExit *******************************************************
3390 **
3391 ** Cleans up graphics internal memory
3392 **
3393 ** @return [void]
3394 **
3395 ** @release 6.2.0
3396 ** @@
3397 ******************************************************************************/
3398
ajGraphicsExit(void)3399 void ajGraphicsExit(void)
3400 {
3401 ajStrDel(&graphBasename);
3402 ajStrDel(&graphExtension);
3403
3404 return;
3405 }
3406
3407
3408
3409
3410 /* @datasection [AjPGraph] Graph object ****************************************
3411 **
3412 ** Function is for manipulating an AjPGraph general graph object
3413 **
3414 ** @nam2rule Graph
3415 **
3416 ******************************************************************************/
3417
3418
3419
3420
3421 /* @section Constructors ******************************************************
3422 **
3423 ** Construct a new graph object to be populated by other functions
3424 **
3425 ** @fdata [AjPGraph]
3426 ** @fcategory new
3427 **
3428 ** @nam3rule New
3429 **
3430 ** @valrule * [AjPGraph] New graph object
3431 **
3432 ******************************************************************************/
3433
3434
3435
3436
3437 /* @func ajGraphNew ***********************************************************
3438 **
3439 ** Create a structure to hold a general graph.
3440 **
3441 ** @return [AjPGraph] multiple graph structure.
3442 **
3443 ** @release 1.0.0
3444 ** @@
3445 ******************************************************************************/
3446
ajGraphNew(void)3447 AjPGraph ajGraphNew(void)
3448 {
3449 AjPGraph graph;
3450
3451 AJNEW0(graph);
3452 ajDebug("ajGraphNew - need to call ajGraphSet\n");
3453
3454 return graph;
3455 }
3456
3457
3458
3459
3460 /* @section Opening ***********************************************************
3461 **
3462 ** Opens a plot page
3463 **
3464 ** @fdata [AjPGraph]
3465 ** @fcategory modify
3466 **
3467 ** @nam3rule Init Initialise a graph object
3468 ** @nam4rule InitSeq Initialises using default values based on a sequence.
3469 ** @nam3rule Open Open a plot
3470 ** @nam3rule Newpage Start a new plot page
3471 ** @nam4rule OpenFlags Open a plot with PLPLOT flag bits
3472 ** @nam4rule OpenMm Open a window whose view is defined by x and y's
3473 ** size in millimetres**
3474 ** @nam4rule OpenPlotset Open a plot window with a set number of plots
3475 ** @nam4rule OpenWin Open a window whose view is defined by x and y's
3476 ** min and max.
3477 ** @argrule * thys [AjPGraph] Graph object
3478 ** @argrule Newpage resetdefaults [AjBool] reset page setting if true
3479 ** @argrule OpenWin xmin [float] minimum x value.(user coordinates)
3480 ** @argrule OpenWin xmax [float] maximum x value.
3481 ** @argrule OpenWin ymin [float] minimum y value.
3482 ** @argrule OpenWin ymax [float] maximum y value.
3483 ** @argrule OpenFlags xmin [PLFLT] minimum x value.(user coordinates)
3484 ** @argrule OpenFlags xmax [PLFLT] maximum x value.
3485 ** @argrule OpenFlags ymin [PLFLT] minimum y value.
3486 ** @argrule OpenFlags ymax [PLFLT] maximum y value.
3487 ** @argrule OpenFlags flags [ajint] flag bit settings
3488 ** @argrule OpenPlotset numofsets [ajuint] number of plots in set.
3489 ** @argrule Mm xmm [float*] x length in millimetres
3490 ** @argrule Mm ymm [float*] y length in millimetres
3491 ** @argrule ajGraphInitSeq seq [const AjPSeq] Sequence
3492 **
3493 ** @valrule * [void]
3494 **
3495 ******************************************************************************/
3496
3497
3498
3499
3500 /* @func ajGraphInitSeq *******************************************************
3501 **
3502 ** Initialises a graph using default values based on a sequence.
3503 **
3504 ** Existing titles and other data are unchanged
3505 **
3506 ** @param [u] thys [AjPGraph] Graph
3507 ** @param [r] seq [const AjPSeq] Sequence
3508 ** @return [void]
3509 **
3510 ** @release 1.0.0
3511 ** @@
3512 ******************************************************************************/
3513
ajGraphInitSeq(AjPGraph thys,const AjPSeq seq)3514 void ajGraphInitSeq(AjPGraph thys, const AjPSeq seq)
3515 {
3516 if(!ajStrGetLen(thys->title))
3517 ajFmtPrintS(&thys->title, "%S of %S",
3518 ajUtilGetProgram(), ajSeqGetNameS(seq));
3519
3520 ajGraphxySetXrangeII(thys, 1, ajSeqGetLen(seq));
3521
3522 return;
3523 }
3524
3525
3526
3527
3528 /* @func ajGraphNewpage *******************************************************
3529 **
3530 ** Clear Screen if (X) or new page if plotter/postscript. Also pass a boolean
3531 ** to state whether you want the current pen colour character sizes,
3532 ** plot title and subtitle, etc to be reset or stay the same for the next page.
3533 **
3534 ** @param [w] thys [AjPGraph] Graph object
3535 ** @param [r] resetdefaults [AjBool] reset page setting?
3536 ** @return [void]
3537 **
3538 ** @release 6.2.0
3539 ** @@
3540 ******************************************************************************/
3541
ajGraphNewpage(AjPGraph thys,AjBool resetdefaults)3542 void ajGraphNewpage(AjPGraph thys, AjBool resetdefaults)
3543 {
3544 ajint old;
3545 ajint cold;
3546 float fold;
3547
3548
3549 ajDebug("ajGraphNewPage reset:%B\n", resetdefaults);
3550
3551 if(graphData)
3552 {
3553 GraphDatafileNext();
3554 return;
3555 }
3556
3557 GraphSubPage(0);
3558
3559 if(resetdefaults)
3560 {
3561 ajGraphicsSetFgcolour(BLACK);
3562 ajGraphicsSetCharscale(1.0);
3563 ajGraphicsSetLinestyle(0);
3564 }
3565 else
3566 {
3567 /* pladv resets every thing so need */
3568 /* to get the old copies */
3569 cold = ajGraphicsSetFgcolour(BLACK);
3570 fold = ajGraphicsSetCharscale(0.0);
3571 old = ajGraphicsSetLinestyle(0);
3572 ajGraphTrace(thys);
3573
3574 GraphLabelTitle(((thys->flags & AJGRAPH_TITLE) ?
3575 ajStrGetPtr(thys->title) : " "),
3576 ((thys->flags & AJGRAPH_SUBTITLE) ?
3577 ajStrGetPtr(thys->subtitle) : " "));
3578
3579 if(thys->windowset)
3580 GraphSetWin(thys->xstart, thys->xend,
3581 thys->ystart, thys->yend);
3582 else
3583 GraphSetWin(0.0, 480.0,
3584 0.0, 640.0);
3585
3586 /* then set it again */
3587 ajGraphicsSetFgcolour(cold);
3588 ajGraphicsSetCharscale(fold);
3589 ajGraphicsSetLinestyle(old);
3590 }
3591
3592 return;
3593 }
3594
3595
3596
3597
3598 /* @func ajGraphOpenFlags *****************************************************
3599 **
3600 ** Open a window whose view is defined by the x's and y's min and max
3601 ** values.
3602 **
3603 ** @param [w] thys [AjPGraph] Graph object
3604 ** @param [r] xmin [PLFLT] minimum x value.(user coordinates)
3605 ** @param [r] xmax [PLFLT] maximum x value.
3606 ** @param [r] ymin [PLFLT] minimum y value.
3607 ** @param [r] ymax [PLFLT] maximum y value.
3608 ** @param [r] flags [ajint] flag bit settings
3609 **
3610 ** @return [void]
3611 **
3612 ** @release 6.2.0
3613 ** @@
3614 ******************************************************************************/
3615
ajGraphOpenFlags(AjPGraph thys,PLFLT xmin,PLFLT xmax,PLFLT ymin,PLFLT ymax,ajint flags)3616 void ajGraphOpenFlags(AjPGraph thys, PLFLT xmin, PLFLT xmax,
3617 PLFLT ymin, PLFLT ymax, ajint flags)
3618 {
3619 AjPTime ajtime;
3620
3621 ajGraphicsSetDevice(thys);
3622
3623 /* Calling funclist graphType() */
3624 if(thys)
3625 (*graphType[thys->displaytype].GOpen)(thys,
3626 graphType[thys->displaytype].Ext);
3627
3628 if( ajStrGetLen(thys->title) <=1)
3629 {
3630 ajtime = ajTimeNewToday();
3631 ajStrAppendC(&thys->title,
3632 ajFmtString("%S (%D)",ajUtilGetProgram(),ajtime));
3633 ajTimeDel(&ajtime);
3634 }
3635
3636 GraphSetName(thys, thys->outputfile,
3637 graphType[thys->displaytype].Ext);
3638 thys->xstart = xmin;
3639 thys->xend = xmax;
3640 thys->ystart = ymin;
3641 thys->yend = ymax;
3642
3643 GraphColourBack();
3644 GraphInit(thys);
3645 GraphColourFore();
3646 ajGraphicsPlenv(xmin, xmax , ymin, ymax , flags);
3647
3648 return;
3649 }
3650
3651
3652
3653
3654 /* @func ajGraphOpenMm ********************************************************
3655 **
3656 ** Open a window whose view is defined by x and y's size in millimetres
3657 ** to allow easy scaling of characters and strings whose sizes are always
3658 ** in millimetres.
3659 **
3660 ** @param [w] thys [AjPGraph] Graph object
3661 ** @param [w] xmm [float*] x length in millimetres
3662 ** @param [w] ymm [float*] y length in millimetres
3663 **
3664 ** @return [void]
3665 **
3666 ** @release 6.2.0
3667 ** @@
3668 ******************************************************************************/
3669
ajGraphOpenMm(AjPGraph thys,float * xmm,float * ymm)3670 void ajGraphOpenMm(AjPGraph thys, float * xmm, float * ymm)
3671 {
3672 PLFLT mmxmin;
3673 PLFLT mmxmax;
3674 PLFLT mmymin;
3675 PLFLT mmymax;
3676
3677 AjPTime ajtime;
3678
3679 ajGraphicsSetDevice(thys);
3680
3681 if (thys)
3682 {
3683 /* Calling funclist graphType() */
3684 (*graphType[thys->displaytype].GOpen)(thys,
3685 graphType[thys->displaytype].Ext);
3686
3687 if(!ajStrGetLen(thys->title))
3688 {
3689 ajFmtPrintAppS(&thys->title,"%S",
3690 ajUtilGetProgram());
3691 }
3692
3693 if(!ajStrGetLen(thys->subtitle))
3694 {
3695 ajtime = ajTimeNewTodayFmt("report");
3696 ajFmtPrintAppS(&thys->subtitle,"%D",
3697 ajtime);
3698 ajTimeDel(&ajtime);
3699 }
3700 }
3701 GraphColourBack();
3702 GraphInit(thys);
3703 GraphColourFore();
3704 GraphSubPage(0);
3705
3706 if(graphData)
3707 {
3708 *xmm= (float) 255.9;
3709 *ymm= (float) 191.9;
3710 }
3711 else
3712 {
3713 plgspa(&mmxmin, &mmxmax, &mmymin, &mmymax);
3714 *xmm = mmxmax - mmxmin;
3715 *ymm = mmymax - mmymin;
3716 }
3717
3718 GraphLabelTitle(((thys->flags & AJGRAPH_TITLE) ?
3719 ajStrGetPtr(thys->title) : ""),
3720 ((thys->flags & AJGRAPH_SUBTITLE) ?
3721 ajStrGetPtr(thys->subtitle) : ""));
3722 thys->xstart = 0.0;
3723 thys->xend = *xmm;
3724 thys->ystart = 0.0;
3725 thys->yend = *ymm;
3726 thys->windowset = ajTrue;
3727
3728 GraphSetWin(thys->xstart, thys->xend,
3729 thys->ystart, thys->yend);
3730
3731 return;
3732 }
3733
3734
3735
3736
3737 /* @func ajGraphOpenPlotset ***************************************************
3738 **
3739 ** Open a window with a set of plots
3740 **
3741 ** @param [w] thys [AjPGraph] Graph object.
3742 ** @param [r] numofsets [ajuint] number of plots in set.
3743 **
3744 ** @return [void]
3745 **
3746 ** @release 6.2.0
3747 ** @@
3748 ******************************************************************************/
3749
ajGraphOpenPlotset(AjPGraph thys,ajuint numofsets)3750 void ajGraphOpenPlotset(AjPGraph thys, ajuint numofsets)
3751 {
3752 ajGraphicsSetDevice(thys);
3753 GraphSetNumSubPage(numofsets);
3754 GraphColourBack();
3755 GraphInit(thys);
3756 GraphColourFore();
3757
3758 return;
3759 }
3760
3761
3762
3763
3764 /* @func ajGraphOpenWin *******************************************************
3765 **
3766 ** Open a window whose view is defined by x and y's min and max.
3767 **
3768 ** @param [w] thys [AjPGraph] Graph object
3769 ** @param [r] xmin [float] minimum x value.(user coordinates)
3770 ** @param [r] xmax [float] maximum x value.
3771 ** @param [r] ymin [float] minimum y value.
3772 ** @param [r] ymax [float] maximum y value.
3773 **
3774 ** @return [void]
3775 **
3776 ** @release 1.0.0
3777 ** @@
3778 ******************************************************************************/
3779
ajGraphOpenWin(AjPGraph thys,float xmin,float xmax,float ymin,float ymax)3780 void ajGraphOpenWin(AjPGraph thys, float xmin, float xmax,
3781 float ymin, float ymax)
3782 {
3783 AjPTime ajtime;
3784
3785 ajGraphicsSetDevice(thys);
3786
3787 if (thys)
3788 {
3789 /* Calling funclist graphType() */
3790 (*graphType[thys->displaytype].GOpen)(thys,
3791 graphType[thys->displaytype].Ext);
3792
3793 if(!ajStrGetLen(thys->title))
3794 {
3795 ajFmtPrintAppS(&thys->title,"%S",
3796 ajUtilGetProgram());
3797 }
3798
3799 if(!ajStrGetLen(thys->subtitle))
3800 {
3801 ajtime = ajTimeNewTodayFmt("report");
3802 ajFmtPrintAppS(&thys->subtitle,"%D",
3803 ajtime);
3804 ajTimeDel(&ajtime);
3805 }
3806 }
3807 GraphColourBack();
3808 GraphInit(thys);
3809 GraphColourFore();
3810 GraphSubPage(0);
3811
3812 GraphLabelTitle(((thys->flags & AJGRAPH_TITLE) ?
3813 ajStrGetPtr(thys->title) : ""),
3814 ((thys->flags & AJGRAPH_SUBTITLE) ?
3815 ajStrGetPtr(thys->subtitle) : ""));
3816 thys->xstart = xmin;
3817 thys->xend = xmax;
3818 thys->ystart = ymin;
3819 thys->yend = ymax;
3820 thys->windowset = ajTrue;
3821
3822 GraphSetWin(xmin, xmax, ymin, ymax);
3823
3824 return;
3825 }
3826
3827
3828
3829
3830 /* @section Modifiers *********************************************************
3831 **
3832 ** Modifying a general graph object
3833 **
3834 ** @fdata [AjPGraph]
3835 ** @fcategory modify
3836 **
3837 ** @nam3rule Append Add to end of an internal string
3838 ** @nam3rule Clear Clear and reset all internal values
3839 ** @nam3rule Set Set internal value(s)
3840 ** @nam3rule Show Set flag to show element of graph
3841 **
3842 ** @nam4rule Dataname Data source name
3843 ** @nam4rule Desc Plot description
3844 ** @nam4rule Devicetype Plplot device by name
3845 ** @nam4rule Flag Set or unset a plplot flag
3846 ** @nam4rule Multi Set graph to store multiple graphs
3847 ** @nam4rule Outdir Output directory
3848 ** @nam4rule Outfile Output filename
3849 ** @nam4rule Subtitle Graph subtitle
3850 ** @nam4rule Title Graph title
3851 ** @nam4rule Xlabel Title for the X axis
3852 ** @nam4rule Ylabel Title for the Y axis
3853 ** @suffix C C character string data
3854 ** @suffix S String object data
3855 **
3856 ** @argrule * thys [AjPGraph] Graph object
3857 ** @argrule Multi numsets [ajuint] Maximum number of graphs that can be stored
3858 ** @argrule Show set [AjBool] True to display, false to hide
3859 ** @argrule Devicetype devicetype [const AjPStr] AJAX device name
3860 ** @argrule Flag flag [ajint] Plplot flag (one bit set)
3861 ** @argrule Flag set [AjBool] Set the flag if true, unset it if false
3862 ** @argrule C txt [const char*] C character string
3863 ** @argrule S str [const AjPStr] String object
3864 **
3865 ** @valrule * [void]
3866 ** @valrule *Devicetype [AjBool] True on success
3867 *
3868 ******************************************************************************/
3869
3870
3871
3872
3873 /* @func ajGraphAppendTitleC **************************************************
3874 **
3875 ** Set an empty graph title from the description or program name and extra text
3876 ** 'of ...' supplied by the caller.
3877 **
3878 ** @param [u] thys [AjPGraph] Graph structure to store info in.
3879 ** @param [r] txt [const char*] Title.
3880 ** @return [void]
3881 **
3882 ** @release 6.2.0
3883 ** @@
3884 ******************************************************************************/
3885
ajGraphAppendTitleC(AjPGraph thys,const char * txt)3886 void ajGraphAppendTitleC(AjPGraph thys, const char* txt)
3887 {
3888 ajDebug("ajGraphAppendTitleC '%s'\n", txt);
3889
3890 if (!thys)
3891 return;
3892
3893 if(ajStrGetLen(thys->title))
3894 return;
3895
3896 if(ajStrGetLen(thys->desc))
3897 ajFmtPrintS(&thys->title, "%S of %s",
3898 thys->desc, txt);
3899 else
3900 ajFmtPrintS(&thys->title, "%S of %s",
3901 ajUtilGetProgram(), txt);
3902
3903 return;
3904 }
3905
3906
3907
3908
3909 /* @func ajGraphAppendTitleS **************************************************
3910 **
3911 ** Set an empty graph title from the description or program name and extra text
3912 ** 'of ...' supplied by the caller.
3913 **
3914 ** @param [u] thys [AjPGraph] Graph structure to store info in.
3915 ** @param [r] str [const AjPStr] Title.
3916 ** @return [void]
3917 **
3918 ** @release 6.2.0
3919 ** @@
3920 ******************************************************************************/
3921
ajGraphAppendTitleS(AjPGraph thys,const AjPStr str)3922 void ajGraphAppendTitleS(AjPGraph thys, const AjPStr str)
3923 {
3924 ajDebug("ajGraphAppendTitleS '%S'\n", str);
3925
3926 if (!thys)
3927 return;
3928
3929 if(ajStrGetLen(thys->title))
3930 return;
3931
3932 if(ajStrGetLen(thys->desc))
3933 ajFmtPrintS(&thys->title, "%S of %S",
3934 thys->desc, str);
3935 else
3936 ajFmtPrintS(&thys->title, "%S of %S",
3937 ajUtilGetProgram(), str);
3938
3939 return;
3940 }
3941
3942
3943
3944
3945 /* @func ajGraphClear *********************************************************
3946 **
3947 ** Delete all the drawable objects connected to the graph object.
3948 **
3949 ** @param [u] thys [AjPGraph] Graph object
3950 **
3951 ** @return [void]
3952 **
3953 ** @release 2.9.0
3954 ** @@
3955 ******************************************************************************/
3956
ajGraphClear(AjPGraph thys)3957 void ajGraphClear(AjPGraph thys)
3958 {
3959 AjPGraphobj Obj;
3960 AjPGraphobj anoth;
3961
3962 if(!thys->Mainobj)
3963 return;
3964 else
3965 {
3966 Obj = thys->Mainobj;
3967
3968 while(Obj)
3969 {
3970 anoth = Obj->next;
3971 ajStrDel(&Obj->text);
3972 AJFREE(Obj);
3973 Obj = anoth;
3974 }
3975 }
3976
3977 thys->Mainobj = NULL;
3978 thys->numofobjects = 0;
3979
3980 return;
3981 }
3982
3983
3984
3985
3986 /* @func ajGraphSetDatanameC **************************************************
3987 **
3988 ** Set the graph data source name.
3989 **
3990 ** @param [u] thys [AjPGraph] Graph structure to store info in.
3991 ** @param [r] txt [const char*] Data source name.
3992 **
3993 ** @return [void]
3994 **
3995 ** @release 6.5.0
3996 ** @@
3997 ******************************************************************************/
3998
ajGraphSetDatanameC(AjPGraph thys,const char * txt)3999 void ajGraphSetDatanameC(AjPGraph thys, const char* txt)
4000 {
4001 ajDebug("ajGraphSetDatanameC '%s'\n", txt);
4002
4003 ajStrAssignC(&thys->dataname,txt);
4004
4005 return;
4006 }
4007
4008
4009
4010
4011 /* @func ajGraphSetDatanameS **************************************************
4012 **
4013 ** Set the graph data source name.
4014 **
4015 ** @param [u] thys [AjPGraph] Graph structure to store info in.
4016 ** @param [r] str [const AjPStr] Data source name.
4017 **
4018 ** @return [void]
4019 **
4020 ** @release 6.5.0
4021 ** @@
4022 ******************************************************************************/
4023
ajGraphSetDatanameS(AjPGraph thys,const AjPStr str)4024 void ajGraphSetDatanameS(AjPGraph thys, const AjPStr str)
4025 {
4026 ajDebug("ajGraphSetDatanameS '%S'\n", str);
4027
4028 ajStrAssignS(&thys->dataname,str);
4029
4030 return;
4031 }
4032
4033
4034
4035
4036 /* @func ajGraphSetDescC ******************************************************
4037 **
4038 ** Set the graph description.
4039 **
4040 ** @param [u] thys [AjPGraph] Graph structure to store info in.
4041 ** @param [r] txt [const char*] Title.
4042 **
4043 ** @return [void]
4044 **
4045 ** @release 6.2.0
4046 ** @@
4047 ******************************************************************************/
4048
ajGraphSetDescC(AjPGraph thys,const char * txt)4049 void ajGraphSetDescC(AjPGraph thys, const char* txt)
4050 {
4051 ajDebug("ajGraphSetDescC '%s'\n", txt);
4052
4053 ajStrAssignC(&thys->desc,txt);
4054
4055 return;
4056 }
4057
4058
4059
4060
4061 /* @func ajGraphSetDescS ******************************************************
4062 **
4063 ** Set the graph description.
4064 **
4065 ** @param [u] thys [AjPGraph] Graph structure to store info in.
4066 ** @param [r] str [const AjPStr] Title.
4067 **
4068 ** @return [void]
4069 **
4070 ** @release 6.2.0
4071 ** @@
4072 ******************************************************************************/
4073
ajGraphSetDescS(AjPGraph thys,const AjPStr str)4074 void ajGraphSetDescS(AjPGraph thys, const AjPStr str)
4075 {
4076 ajDebug("ajGraphSetDescS '%S'\n", str);
4077
4078 ajStrAssignS(&thys->desc,str);
4079
4080 return;
4081 }
4082
4083
4084
4085
4086 /* @func ajGraphSetDevicetype *************************************************
4087 **
4088 ** Initialize options for a general graph object
4089 **
4090 ** @param [u] thys [AjPGraph] Graph object
4091 ** @param [r] devicetype [const AjPStr] Graph type
4092 ** @return [AjBool] ajTrue on success
4093 **
4094 ** @release 6.2.0
4095 ** @@
4096 ******************************************************************************/
4097
ajGraphSetDevicetype(AjPGraph thys,const AjPStr devicetype)4098 AjBool ajGraphSetDevicetype(AjPGraph thys, const AjPStr devicetype)
4099 {
4100 ajint i;
4101 ajint j=-1;
4102 ajint k;
4103 AjPStr aliases = NULL;
4104
4105 ajDebug("ajGraphSetDevicetype '%S'\n", devicetype);
4106
4107 for(i=0;graphType[i].Name;i++)
4108 {
4109 if(!graphType[i].GOpen)
4110 continue;
4111
4112 if(ajStrMatchCaseC(devicetype, graphType[i].Name))
4113 {
4114 j = i;
4115 break;
4116 }
4117
4118 if(ajCharPrefixCaseS(graphType[i].Name, devicetype))
4119 {
4120 if(j < 0)
4121 j = i;
4122 else
4123 {
4124 for(k=0;graphType[k].Name;k++)
4125 {
4126 if(ajCharPrefixCaseS(graphType[k].Name, devicetype))
4127 {
4128 if(ajStrGetLen(aliases))
4129 ajStrAppendC(&aliases, ", ");
4130 ajStrAppendC(&aliases, graphType[k].Name);
4131 }
4132 }
4133
4134 ajErr("Ambiguous graph device name '%S' (%S)",
4135 devicetype, aliases);
4136 ajStrDel(&aliases);
4137
4138 return ajFalse;
4139 }
4140 }
4141 }
4142
4143 if(j<0)
4144 return ajFalse;
4145
4146 GraphNewPlplot(thys);
4147
4148 thys->displaytype = j;
4149
4150 ajDebug("ajGraphSetDevicetype plplot type '%S' displaytype %d '%s'\n",
4151 devicetype, j, graphType[j].Name);
4152
4153 return ajTrue;
4154 }
4155
4156
4157
4158
4159 /* @func ajGraphSetFlag *******************************************************
4160 **
4161 ** Set the flags for the graph to add or subtract "flag" depending on set
4162 **
4163 ** @param [u] thys [AjPGraph] graph to have flags altered.
4164 ** @param [r] flag [ajint] flag to be set.
4165 ** @param [r] set [AjBool] whether to set the flag or remove it.
4166 ** @return [void]
4167 **
4168 ** @release 2.9.0
4169 ** @@
4170 ******************************************************************************/
4171
ajGraphSetFlag(AjPGraph thys,ajint flag,AjBool set)4172 void ajGraphSetFlag(AjPGraph thys, ajint flag, AjBool set)
4173 {
4174 if (!thys)
4175 return;
4176
4177 if(thys->flags & flag)
4178 {
4179 if(!set)
4180 thys->flags &= ~flag;
4181 }
4182 else
4183 {
4184 if(set)
4185 thys->flags |= flag;
4186 }
4187
4188 return;
4189 }
4190
4191
4192
4193
4194 /* @func ajGraphSetMulti ******************************************************
4195 **
4196 ** Create a structure to hold a number of graphs.
4197 **
4198 ** @param [w] thys [AjPGraph] Graph structure to store info in.
4199 ** @param [r] numsets [ajuint] maximum number of graphs that can be stored.
4200 ** @return [void]
4201 **
4202 ** @release 1.0.0
4203 ** @@
4204 ******************************************************************************/
4205
ajGraphSetMulti(AjPGraph thys,ajuint numsets)4206 void ajGraphSetMulti(AjPGraph thys, ajuint numsets)
4207 {
4208 if (!thys)
4209 return;
4210
4211 if (thys->graphs)
4212 AJFREE(thys->graphs);
4213
4214 AJCNEW0(thys->graphs,numsets);
4215
4216 ajDebug("ajGraphSetMulti numsets: %d\n", numsets);
4217
4218 thys->numofgraphs = 0;
4219 thys->numofgraphsmax = numsets;
4220 thys->minmaxcalc = 0;
4221 thys->flags = GRAPH_XY;
4222
4223 return;
4224 }
4225
4226
4227
4228
4229 /* @func ajGraphSetOutdirS ****************************************************
4230 **
4231 ** Set the directory of the output file. Only used later if the device
4232 ** plotter is capable of writing to a file (e.g. postscript or png)
4233 **
4234 ** @param [u] thys [AjPGraph] Graph structure to update file name
4235 ** @param [r] str [const AjPStr] Name of the file.
4236 ** @return [void]
4237 **
4238 ** @release 6.2.0
4239 ** @@
4240 ******************************************************************************/
4241
ajGraphSetOutdirS(AjPGraph thys,const AjPStr str)4242 void ajGraphSetOutdirS(AjPGraph thys, const AjPStr str)
4243 {
4244 if(!ajStrGetLen(str))
4245 return;
4246
4247 if (!thys)
4248 return;
4249
4250 if(ajStrGetCharLast(str) != '/')
4251 ajStrInsertC(&thys->outputfile, 0, "/");
4252 ajStrInsertS(&thys->outputfile, 0, str);
4253
4254 return;
4255 }
4256
4257
4258
4259
4260 /* @func ajGraphSetOutfileC ***************************************************
4261 **
4262 ** Set the name of the output file. Only used later if the device
4263 ** plotter is capable of postscript output. ps and cps.
4264 **
4265 ** @param [u] thys [AjPGraph] Graph structure to write file name to.
4266 ** @param [r] txt [const char*] Name of the file.
4267 ** @return [void]
4268 **
4269 ** @release 6.2.0
4270 ** @@
4271 ******************************************************************************/
4272
ajGraphSetOutfileC(AjPGraph thys,const char * txt)4273 void ajGraphSetOutfileC(AjPGraph thys, const char* txt)
4274 {
4275 if(!strlen(txt))
4276 return;
4277
4278 if (!thys)
4279 return;
4280
4281 ajStrAssignC(&thys->outputfile, txt);
4282
4283 return;
4284 }
4285
4286
4287
4288
4289 /* @func ajGraphSetOutfileS ***************************************************
4290 **
4291 ** Set the name of the output file. Only used later if the device
4292 ** plotter is capable of postscript output. ps and cps.
4293 **
4294 ** @param [u] thys [AjPGraph] Graph structure to write file name to.
4295 ** @param [r] str [const AjPStr] Name of the file.
4296 ** @return [void]
4297 **
4298 ** @release 6.2.0
4299 ** @@
4300 ******************************************************************************/
4301
ajGraphSetOutfileS(AjPGraph thys,const AjPStr str)4302 void ajGraphSetOutfileS(AjPGraph thys, const AjPStr str)
4303 {
4304 if(!ajStrGetLen(str))
4305 return;
4306
4307 if (!thys)
4308 return;
4309
4310 ajStrAssignS(&thys->outputfile, str);
4311
4312 return;
4313 }
4314
4315
4316
4317
4318 /* @func ajGraphSetSubtitleC **************************************************
4319 **
4320 ** Set the graph subtitle.
4321 **
4322 ** @param [u] thys [AjPGraph] Graph structure to store info in.
4323 ** @param [r] txt [const char*] Subtitle.
4324 ** @return [void]
4325 **
4326 ** @release 6.2.0
4327 ** @@
4328 ******************************************************************************/
4329
ajGraphSetSubtitleC(AjPGraph thys,const char * txt)4330 void ajGraphSetSubtitleC(AjPGraph thys, const char* txt)
4331 {
4332 ajStrAssignC(&thys->subtitle,txt);
4333
4334 return;
4335 }
4336
4337
4338
4339
4340 /* @func ajGraphSetSubtitleS **************************************************
4341 **
4342 ** Set the title for the Y axis.
4343 **
4344 ** @param [u] thys [AjPGraph] Graph structure to store info in.
4345 ** @param [r] str [const AjPStr] Subtitle
4346 ** @return [void]
4347 **
4348 ** @release 6.2.0
4349 ** @@
4350 ******************************************************************************/
4351
ajGraphSetSubtitleS(AjPGraph thys,const AjPStr str)4352 void ajGraphSetSubtitleS(AjPGraph thys, const AjPStr str)
4353 {
4354 ajStrAssignS(&thys->subtitle,str);
4355
4356 return;
4357 }
4358
4359
4360
4361
4362 /* @func ajGraphSetTitleC *****************************************************
4363 **
4364 ** Set the graph Title.
4365 **
4366 ** @param [u] thys [AjPGraph] Graph structure to store info in.
4367 ** @param [r] txt [const char*] title.
4368 ** @return [void]
4369 **
4370 ** @release 2.9.0
4371 ** @@
4372 ******************************************************************************/
4373
ajGraphSetTitleC(AjPGraph thys,const char * txt)4374 void ajGraphSetTitleC(AjPGraph thys, const char* txt)
4375 {
4376 ajDebug("ajGraphSetTitleC '%s'\n", txt);
4377
4378 ajStrAssignC(&thys->title,txt);
4379
4380 return;
4381 }
4382
4383
4384
4385
4386 /* @func ajGraphSetTitleS *****************************************************
4387 **
4388 ** Set the graph title.
4389 **
4390 ** @param [u] thys [AjPGraph] Graph structure to store info in.
4391 ** @param [r] str [const AjPStr] Title.
4392 ** @return [void]
4393 **
4394 ** @release 6.2.0
4395 ** @@
4396 ******************************************************************************/
4397
ajGraphSetTitleS(AjPGraph thys,const AjPStr str)4398 void ajGraphSetTitleS(AjPGraph thys, const AjPStr str)
4399 {
4400 ajDebug("ajGraphSetTitleS '%S'\n", str);
4401
4402 ajStrAssignS(&thys->title,str);
4403
4404 return;
4405 }
4406
4407
4408
4409
4410 /* @func ajGraphSetXlabelC ****************************************************
4411 **
4412 ** Set the title for the X axis for multiple plot on one graph.
4413 **
4414 ** @param [u] thys [AjPGraph] Graph structure to store info in.
4415 ** @param [r] txt [const char*] title for the x axis.
4416 ** @return [void]
4417 **
4418 ** @release 6.2.0
4419 ** @@
4420 ******************************************************************************/
4421
ajGraphSetXlabelC(AjPGraph thys,const char * txt)4422 void ajGraphSetXlabelC(AjPGraph thys, const char* txt)
4423 {
4424 ajStrAssignC(&thys->xaxis,txt);
4425
4426 return;
4427 }
4428
4429
4430
4431
4432 /* @func ajGraphSetXlabelS ****************************************************
4433 **
4434 ** Set the title for the X axis for multiple plots on one graph.
4435 **
4436 ** @param [u] thys [AjPGraph] Graph structure to store info in.
4437 ** @param [r] str [const AjPStr] title for the x axis.
4438 ** @return [void]
4439 **
4440 ** @release 6.2.0
4441 ** @@
4442 ******************************************************************************/
4443
ajGraphSetXlabelS(AjPGraph thys,const AjPStr str)4444 void ajGraphSetXlabelS(AjPGraph thys, const AjPStr str)
4445 {
4446 ajStrAssignS(&thys->xaxis,str);
4447
4448 return;
4449 }
4450
4451
4452
4453
4454 /* @func ajGraphSetYlabelC ****************************************************
4455 **
4456 ** Set the title for the Y axis for multiple plots on one graph.
4457 **
4458 ** @param [u] thys [AjPGraph] Graph structure to store info in.
4459 ** @param [r] txt [const char*] title for the y axis.
4460 ** @return [void]
4461 **
4462 ** @release 6.2.0
4463 ** @@
4464 ******************************************************************************/
4465
ajGraphSetYlabelC(AjPGraph thys,const char * txt)4466 void ajGraphSetYlabelC(AjPGraph thys, const char* txt)
4467 {
4468 ajStrAssignC(&thys->yaxis, txt);
4469
4470 return;
4471 }
4472
4473
4474
4475
4476 /* @func ajGraphSetYlabelS ****************************************************
4477 **
4478 ** Set the title for the Y axis for multiple plots on one graph.
4479 **
4480 ** @param [u] thys [AjPGraph] Graph structure to store info in.
4481 ** @param [r] str [const AjPStr] title for the y axis.
4482 ** @return [void]
4483 **
4484 ** @release 6.2.0
4485 ** @@
4486 ******************************************************************************/
4487
ajGraphSetYlabelS(AjPGraph thys,const AjPStr str)4488 void ajGraphSetYlabelS(AjPGraph thys, const AjPStr str)
4489 {
4490 ajStrAssignS(&thys->yaxis, str);
4491
4492 return;
4493 }
4494
4495
4496
4497
4498 /* @func ajGraphShowSubtitle **************************************************
4499 **
4500 ** Set whether the graph is to display the subtitle.
4501 **
4502 ** @param [u] thys [AjPGraph] graph to have flag altered
4503 ** @param [r] set [AjBool] whether to set or turn off.
4504 ** @return [void]
4505 **
4506 ** @release 6.2.0
4507 ** @@
4508 ******************************************************************************/
4509
ajGraphShowSubtitle(AjPGraph thys,AjBool set)4510 void ajGraphShowSubtitle(AjPGraph thys, AjBool set)
4511 {
4512 ajGraphSetFlag(thys, AJGRAPH_SUBTITLE, set);
4513
4514 return;
4515 }
4516
4517
4518
4519
4520 /* @func ajGraphShowTitle *****************************************************
4521 **
4522 ** Set whether the graph is to display the title.
4523 **
4524 ** @param [u] thys [AjPGraph] graph to have flag altered
4525 ** @param [r] set [AjBool] whether to set or turn off.
4526 ** @return [void]
4527 **
4528 ** @release 6.2.0
4529 ** @@
4530 ******************************************************************************/
4531
ajGraphShowTitle(AjPGraph thys,AjBool set)4532 void ajGraphShowTitle(AjPGraph thys, AjBool set)
4533 {
4534 ajGraphSetFlag(thys, AJGRAPH_TITLE, set);
4535
4536 return;
4537 }
4538
4539
4540
4541
4542 /* @section Queries ***********************************************************
4543 **
4544 ** Querying and reporting internal values
4545 **
4546 ** @fdata [AjPGraph]
4547 ** @fcategory use
4548 **
4549 ** @nam3rule Get Return an internal value
4550 ** @nam4rule Params Get parameters
4551 ** @nam5rule ParamsPage Get the output page parameters
4552 ** @nam4rule Subtitle Get subtitle
4553 ** @nam4rule Title Get title
4554 ** @nam4rule Xlabel Get x-axis label
4555 ** @nam4rule Ylabel Get y-axis label
4556 ** @nam3rule Is Test for presence of a property
4557 ** @nam4rule IsData Test for graph being a data file rather than a plot
4558 ** @suffix C Return a C character string
4559 ** @suffix S return a string object
4560 **
4561 ** @argrule * thys [const AjPGraph] Graph object
4562 ** @argrule ParamsPage xp [float*] where to store the x position
4563 ** @argrule ParamsPage yp [float*] where to store the y position
4564 ** @argrule ParamsPage xleng [ajint*] where to store the x length
4565 ** @argrule ParamsPage yleng [ajint*] where to the y length
4566 ** @argrule ParamsPage xoff [ajint*] where to store the x offset
4567 ** @argrule ParamsPage yoff [ajint*] where to store the y offset
4568 **
4569 ** @valrule * [void]
4570 ** @valrule *C [const char*] C character string
4571 ** @valrule *S [const AjPStr] String object
4572 ** @valrule *Is [AjBool] True if the property is found
4573 **
4574 ******************************************************************************/
4575
4576
4577
4578
4579 /* @func ajGraphGetParamsPage *************************************************
4580 **
4581 ** Get the output page parameters stored in a graph object
4582 **
4583 ** For graph data type, sets to zero as these are not applicable.
4584 **
4585 ** @param [r] thys [const AjPGraph] Graph object.
4586 ** @param [u] xp [float *] where to store the x position
4587 ** @param [u] yp [float *] where to store the y position
4588 ** @param [u] xleng [ajint *] where to store the x length
4589 ** @param [u] yleng [ajint *] where to the y length
4590 ** @param [u] xoff [ajint *] where to store the x offset
4591 ** @param [u] yoff [ajint *] where to store the y offset
4592 **
4593 ** @return [void]
4594 **
4595 ** @release 6.2.0
4596 ** @@
4597 ******************************************************************************/
4598
ajGraphGetParamsPage(const AjPGraph thys,float * xp,float * yp,ajint * xleng,ajint * yleng,ajint * xoff,ajint * yoff)4599 void ajGraphGetParamsPage(const AjPGraph thys,
4600 float *xp,float *yp, ajint *xleng, ajint *yleng,
4601 ajint *xoff, ajint *yoff)
4602 {
4603 #if GRAPH_DEBUG
4604 ajDebug("=g= plgpage(&f &f) [&xp, &yp, &xleng, &yleng, &xoff, &yoff]\n");
4605 #endif
4606
4607 if(graphData)
4608 {
4609 *xp=0.0;
4610 *yp=0.0;
4611 *xleng=graphType[thys->displaytype].Width;
4612 *yleng=graphType[thys->displaytype].Height;
4613 *xoff=0;
4614 *yoff=0;
4615 }
4616 else
4617 {
4618 plgpage(xp,yp,xleng,yleng,xoff,yoff);
4619 if(!*xleng)
4620 *xleng = graphType[thys->displaytype].Width;
4621 if(!*yleng)
4622 *yleng = graphType[thys->displaytype].Height;
4623 ajDebug("returns xp:%.3f yp:%.3f xleng:%d yleng:%d xoff:%d yoff:%d\n",
4624 *xp, *yp, *xleng, *yleng, *xoff, *yoff);
4625 }
4626
4627 return;
4628 }
4629
4630
4631
4632
4633 /* @func ajGraphGetSubtitleC **************************************************
4634 **
4635 ** Return plot subtitle
4636 **
4637 ** @param [r] thys [const AjPGraph] Graph object.
4638 ** @return [const char*] Subtitle
4639 **
4640 ** @release 6.2.0
4641 ** @@
4642 ******************************************************************************/
4643
ajGraphGetSubtitleC(const AjPGraph thys)4644 const char* ajGraphGetSubtitleC(const AjPGraph thys)
4645 {
4646 if (thys->subtitle)
4647 return ajStrGetPtr(thys->subtitle);
4648
4649 return "";
4650 }
4651
4652
4653
4654
4655 /* @func ajGraphGetSubtitleS **************************************************
4656 **
4657 ** Return plot subtitle
4658 **
4659 ** @param [r] thys [const AjPGraph] Graph object.
4660 ** @return [const AjPStr] Subtitle
4661 **
4662 ** @release 6.2.0
4663 ** @@
4664 ******************************************************************************/
4665
ajGraphGetSubtitleS(const AjPGraph thys)4666 const AjPStr ajGraphGetSubtitleS(const AjPGraph thys)
4667 {
4668 return thys->subtitle;
4669
4670 }
4671
4672
4673
4674
4675 /* @func ajGraphGetTitleC *****************************************************
4676 **
4677 ** Return plot title
4678 **
4679 ** @param [r] thys [const AjPGraph] Graph object.
4680 ** @return [const char*] Title
4681 **
4682 ** @release 2.9.0
4683 ** @@
4684 ******************************************************************************/
4685
ajGraphGetTitleC(const AjPGraph thys)4686 const char* ajGraphGetTitleC(const AjPGraph thys)
4687 {
4688 if(thys->title)
4689 return ajStrGetPtr(thys->title);
4690
4691 return "";
4692 }
4693
4694
4695
4696
4697 /* @func ajGraphGetTitleS *****************************************************
4698 **
4699 ** Return plot title
4700 **
4701 ** @param [r] thys [const AjPGraph] Graph object.
4702 ** @return [const AjPStr] Title
4703 **
4704 ** @release 6.2.0
4705 ** @@
4706 ******************************************************************************/
4707
ajGraphGetTitleS(const AjPGraph thys)4708 const AjPStr ajGraphGetTitleS(const AjPGraph thys)
4709 {
4710 return thys->title;
4711 }
4712
4713
4714
4715
4716 /* @func ajGraphGetXlabelC ****************************************************
4717 **
4718 ** Return plot x-axis label
4719 **
4720 ** @param [r] thys [const AjPGraph] Graph object.
4721 ** @return [const char*] Title of x-axis
4722 **
4723 ** @release 6.2.0
4724 ** @@
4725 ******************************************************************************/
4726
ajGraphGetXlabelC(const AjPGraph thys)4727 const char* ajGraphGetXlabelC(const AjPGraph thys)
4728 {
4729 if (thys->xaxis)
4730 return ajStrGetPtr(thys->xaxis);
4731
4732 return "";
4733 }
4734
4735
4736
4737
4738 /* @func ajGraphGetXlabelS ****************************************************
4739 **
4740 ** Return plot x-axis label
4741 **
4742 ** @param [r] thys [const AjPGraph] Graph object.
4743 ** @return [const AjPStr] Title of x-axis
4744 **
4745 ** @release 6.2.0
4746 ** @@
4747 ******************************************************************************/
4748
ajGraphGetXlabelS(const AjPGraph thys)4749 const AjPStr ajGraphGetXlabelS(const AjPGraph thys)
4750 {
4751 return thys->xaxis;
4752 }
4753
4754
4755
4756
4757 /* @func ajGraphGetYlabelC ****************************************************
4758 **
4759 ** Return plot y-axis label
4760 **
4761 ** @param [r] thys [const AjPGraph] Graph object.
4762 ** @return [const char*] Title of y-axis
4763 **
4764 ** @release 6.2.0
4765 ** @@
4766 ******************************************************************************/
4767
ajGraphGetYlabelC(const AjPGraph thys)4768 const char* ajGraphGetYlabelC(const AjPGraph thys)
4769 {
4770 if (thys->yaxis)
4771 return ajStrGetPtr(thys->yaxis);
4772
4773 return "";
4774 }
4775
4776
4777
4778
4779 /* @func ajGraphGetYlabelS ****************************************************
4780 **
4781 ** Return plot y-axis label
4782 **
4783 ** @param [r] thys [const AjPGraph] Graph object.
4784 ** @return [const AjPStr] Title of y-axis
4785 **
4786 ** @release 6.2.0
4787 ** @@
4788 ******************************************************************************/
4789
ajGraphGetYlabelS(const AjPGraph thys)4790 const AjPStr ajGraphGetYlabelS(const AjPGraph thys)
4791 {
4792 return thys->yaxis;
4793 }
4794
4795
4796
4797
4798
4799 /* @func ajGraphIsData ********************************************************
4800 **
4801 ** returns ajTrue if the graph is creating a data file
4802 **
4803 ** @param [r] thys [const AjPGraph] Graph object
4804 ** @return [AjBool] ajTrue if the graph is of type data
4805 **
4806 ** @release 2.9.0
4807 ** @@
4808 ******************************************************************************/
4809
ajGraphIsData(const AjPGraph thys)4810 AjBool ajGraphIsData(const AjPGraph thys)
4811 {
4812 return thys->isdata;
4813 }
4814
4815
4816
4817
4818 /* @section Plotting **********************************************************
4819 **
4820 ** Plotting drawable objects
4821 **
4822 ** @fdata [AjPGraph]
4823 ** @fcategory use
4824 **
4825 ** @nam3rule Add Add an object to a graph
4826 ** @nam4rule Line Line
4827 ** @nam4rule Rect Rectangle
4828 ** @nam4rule Text Text
4829 ** @nam5rule TextScale Scaled text
4830 ** @suffix C Character string input
4831 ** @suffix S String object data
4832 **
4833 ** @argrule * thys [AjPGraph] Graph object
4834 ** @argrule Add x [float] x start position
4835 ** @argrule Add y [float] y start position
4836 ** @argrule AddLine x2 [float] x end position
4837 ** @argrule AddLine y2 [float] y end position
4838 ** @argrule AddRect x2 [float] x end position
4839 ** @argrule AddRect y2 [float] y end position
4840 ** @argrule Add colour [ajint] Colour code (see PLPLOT)
4841 ** @argrule AddRect fill [ajint] Fill code (see PLPLOT)
4842 ** @argrule Scale scale [float] Character scale (0.0 to use the default)
4843 ** @argrule C txt [const char*] Text string
4844 ** @argrule S str [const AjPStr] Text string
4845 **
4846 ** @valrule * [void]
4847 **
4848 ******************************************************************************/
4849
4850
4851
4852
4853 /* @func ajGraphAddLine *******************************************************
4854 **
4855 ** Add a line to be drawn when the graph is plotted.
4856 **
4857 ** @param [u] thys [AjPGraph] Graph object
4858 ** @param [r] x [float] Start x position
4859 ** @param [r] y [float] Start y position
4860 ** @param [r] x2 [float] End x position
4861 ** @param [r] y2 [float] End y position
4862 ** @param [r] colour [ajint] Colour code (see PLPLOT)
4863 **
4864 ** @return [void]
4865 **
4866 ** @release 2.9.0
4867 ** @@
4868 ******************************************************************************/
4869
ajGraphAddLine(AjPGraph thys,float x,float y,float x2,float y2,ajint colour)4870 void ajGraphAddLine(AjPGraph thys, float x, float y,
4871 float x2, float y2, ajint colour)
4872 {
4873 AjPGraphobj Obj;
4874
4875 if(!thys->Mainobj)
4876 {
4877 AJNEW(thys->Mainobj);
4878 Obj = thys->Mainobj;
4879 }
4880 else
4881 {
4882 Obj = thys->Mainobj;
4883
4884 while(Obj->next)
4885 Obj = Obj->next;
4886
4887 AJNEW(Obj->next);
4888 Obj = Obj->next;
4889 }
4890
4891 ++thys->numofobjects;
4892
4893 Obj->type = LINE;
4894 Obj->text = 0;
4895 Obj->xx1 = x;
4896 Obj->xx2 = x2;
4897 Obj->yy1 = y;
4898 Obj->yy2 = y2;
4899 Obj->colour = colour;
4900 Obj->next = 0;
4901
4902 return;
4903 }
4904
4905
4906
4907
4908 /* @func ajGraphAddRect *******************************************************
4909 **
4910 ** Add a Rectangle to be drawn when the graph is plotted, fill states whether
4911 ** the rectangle should be filled in.
4912 **
4913 ** @param [u] thys [AjPGraph] Graph object
4914 ** @param [r] x [float] Start x coordinate
4915 ** @param [r] y [float] Start y coordinate
4916 ** @param [r] x2 [float] End x coordinate
4917 ** @param [r] y2 [float] End y coordinate
4918 ** @param [r] colour [ajint] Colour code (see PLPLOT)
4919 ** @param [r] fill [ajint] Fill code (see PLPLOT)
4920 **
4921 ** @return [void]
4922 **
4923 ** @release 2.9.0
4924 ** @@
4925 ******************************************************************************/
4926
ajGraphAddRect(AjPGraph thys,float x,float y,float x2,float y2,ajint colour,ajint fill)4927 void ajGraphAddRect(AjPGraph thys, float x, float y,
4928 float x2, float y2, ajint colour, ajint fill)
4929 {
4930 AjPGraphobj Obj;
4931
4932 if(!thys->Mainobj)
4933 {
4934 AJNEW(thys->Mainobj);
4935 Obj = thys->Mainobj;
4936 }
4937 else
4938 {
4939 Obj = thys->Mainobj;
4940
4941 while(Obj->next)
4942 Obj = Obj->next;
4943
4944 AJNEW(Obj->next);
4945 Obj = Obj->next;
4946 }
4947
4948 ++thys->numofobjects;
4949
4950
4951 if(fill)
4952 Obj->type = RECTANGLEFILL;
4953 else
4954 Obj->type = RECTANGLE;
4955
4956 Obj->text = 0;
4957 Obj->xx1 = x;
4958 Obj->xx2 = x2;
4959 Obj->yy1 = y;
4960 Obj->yy2 = y2;
4961 Obj->colour = colour;
4962 Obj->next = 0;
4963
4964 return;
4965 }
4966
4967
4968
4969
4970 /* @func ajGraphAddTextC ******************************************************
4971 **
4972 ** Add text to be drawn when the graph is plotted.
4973 **
4974 ** @param [u] thys [AjPGraph] Graph object
4975 ** @param [r] x [float] Start x position
4976 ** @param [r] y [float] Start y position
4977 ** @param [r] colour [ajint] Colour code (see PLPLOT)
4978 ** @param [r] txt [const char*] Text
4979 **
4980 ** @return [void]
4981 **
4982 ** @release 6.2.0
4983 ** @@
4984 ******************************************************************************/
4985
ajGraphAddTextC(AjPGraph thys,float x,float y,ajint colour,const char * txt)4986 void ajGraphAddTextC(AjPGraph thys, float x, float y,
4987 ajint colour, const char *txt)
4988 {
4989 AjPGraphobj Obj;
4990
4991 if(!thys->Mainobj)
4992 {
4993 AJNEW(thys->Mainobj);
4994 Obj = thys->Mainobj;
4995 }
4996 else
4997 {
4998 Obj = thys->Mainobj;
4999 while(Obj->next)
5000 Obj = Obj->next;
5001 AJNEW(Obj->next);
5002 Obj = Obj->next;
5003 }
5004
5005 ++thys->numofobjects;
5006
5007
5008 Obj->type = TEXT;
5009 Obj->text = ajStrNewC(txt);
5010 Obj->xx1 = x;
5011 Obj->xx2 = 0.0;
5012 Obj->yy1 = y;
5013 Obj->yy2 = 0.0;
5014 Obj->colour = colour;
5015 Obj->scale = 0.0;
5016 Obj->next = 0;
5017
5018 return;
5019 }
5020
5021
5022
5023
5024 /* @func ajGraphAddTextS ******************************************************
5025 **
5026 ** Add text to be drawn when the graph is plotted.
5027 **
5028 ** @param [u] thys [AjPGraph] Graph object
5029 ** @param [r] x [float] Start x position
5030 ** @param [r] y [float] Start y position
5031 ** @param [r] colour [ajint] Colour code (see PLPLOT)
5032 ** @param [r] str [const AjPStr] Text
5033 **
5034 ** @return [void]
5035 **
5036 ** @release 6.2.0
5037 ** @@
5038 ******************************************************************************/
5039
ajGraphAddTextS(AjPGraph thys,float x,float y,ajint colour,const AjPStr str)5040 void ajGraphAddTextS(AjPGraph thys, float x, float y,
5041 ajint colour, const AjPStr str)
5042 {
5043 AjPGraphobj Obj;
5044
5045 if(!thys->Mainobj)
5046 {
5047 AJNEW(thys->Mainobj);
5048 Obj = thys->Mainobj;
5049 }
5050 else
5051 {
5052 Obj = thys->Mainobj;
5053 while(Obj->next)
5054 Obj = Obj->next;
5055 AJNEW(Obj->next);
5056 Obj = Obj->next;
5057 }
5058
5059 ++thys->numofobjects;
5060
5061
5062 Obj->type = TEXT;
5063 Obj->text = ajStrNewS(str);
5064 Obj->xx1 = x;
5065 Obj->xx2 = 0.0;
5066 Obj->yy1 = y;
5067 Obj->yy2 = 0.0;
5068 Obj->colour = colour;
5069 Obj->scale = 0.0;
5070 Obj->next = 0;
5071
5072 return;
5073 }
5074
5075
5076
5077
5078 /* @func ajGraphAddTextScaleC *************************************************
5079 **
5080 ** Add text to be drawn when the graph is plotted.
5081 **
5082 ** @param [u] thys [AjPGraph] Graph object
5083 ** @param [r] x [float] Start x position
5084 ** @param [r] y [float] Start y position
5085 ** @param [r] colour [ajint] Colour code (see PLPLOT)
5086 ** @param [r] scale [float] Character scale (0.0 to use the default)
5087 ** @param [r] txt [const char*] Text
5088 **
5089 ** @return [void]
5090 **
5091 ** @release 6.2.0
5092 ** @@
5093 ******************************************************************************/
5094
ajGraphAddTextScaleC(AjPGraph thys,float x,float y,ajint colour,float scale,const char * txt)5095 void ajGraphAddTextScaleC(AjPGraph thys, float x, float y,
5096 ajint colour, float scale, const char *txt)
5097 {
5098 AjPGraphobj Obj;
5099
5100 if(!thys->Mainobj)
5101 {
5102 AJNEW(thys->Mainobj);
5103 Obj = thys->Mainobj;
5104 }
5105 else
5106 {
5107 Obj = thys->Mainobj;
5108
5109 while(Obj->next)
5110 Obj = Obj->next;
5111
5112 AJNEW(Obj->next);
5113 Obj = Obj->next;
5114 }
5115
5116 ++thys->numofobjects;
5117
5118
5119 Obj->type = TEXT;
5120 Obj->text = ajStrNewC(txt);
5121 Obj->xx1 = x;
5122 Obj->xx2 = 0.0;
5123 Obj->yy1 = y;
5124 Obj->yy2 = 0.0;
5125 Obj->colour = colour;
5126 Obj->scale = scale;
5127 Obj->next = 0;
5128
5129 return;
5130 }
5131
5132
5133
5134
5135 /* @func ajGraphAddTextScaleS *************************************************
5136 **
5137 ** Add text to be drawn when the graph is plotted.
5138 **
5139 ** @param [u] thys [AjPGraph] Graph object
5140 ** @param [r] x [float] Start x position
5141 ** @param [r] y [float] Start y position
5142 ** @param [r] colour [ajint] Colour code (see PLPLOT)
5143 ** @param [r] scale [float] Character scale (0.0 to use the default)
5144 ** @param [r] str [const AjPStr] Text
5145 **
5146 ** @return [void]
5147 **
5148 ** @release 6.2.0
5149 ** @@
5150 ******************************************************************************/
5151
ajGraphAddTextScaleS(AjPGraph thys,float x,float y,ajint colour,float scale,const AjPStr str)5152 void ajGraphAddTextScaleS(AjPGraph thys, float x, float y,
5153 ajint colour, float scale, const AjPStr str)
5154 {
5155 AjPGraphobj Obj;
5156
5157 if(!thys->Mainobj)
5158 {
5159 AJNEW(thys->Mainobj);
5160 Obj = thys->Mainobj;
5161 }
5162 else
5163 {
5164 Obj = thys->Mainobj;
5165
5166 while(Obj->next)
5167 Obj = Obj->next;
5168
5169 AJNEW(Obj->next);
5170 Obj = Obj->next;
5171 }
5172
5173 ++thys->numofobjects;
5174
5175
5176 Obj->type = TEXT;
5177 Obj->text = ajStrNewS(str);
5178 Obj->xx1 = x;
5179 Obj->xx2 = 0.0;
5180 Obj->yy1 = y;
5181 Obj->yy2 = 0.0;
5182 Obj->colour = colour;
5183 Obj->scale = scale;
5184 Obj->next = 0;
5185
5186 return;
5187 }
5188
5189
5190
5191
5192 /* @funcstatic GraphDraw ******************************************************
5193 **
5194 ** Display the drawable objects connected to this graph.
5195 **
5196 ** @param [r] thys [const AjPGraph] Graph object
5197 **
5198 ** @return [void]
5199 **
5200 ** @release 2.9.0
5201 ** @@
5202 ******************************************************************************/
5203
GraphDraw(const AjPGraph thys)5204 static void GraphDraw(const AjPGraph thys)
5205 {
5206 AjPGraphobj Obj;
5207 ajint temp;
5208 float cold = 1.0;
5209 ajuint nobj = 0;
5210
5211 /* graphdata : calls ajGraphLine etc. */
5212
5213 ajDebug("ajGraphDraw\n");
5214 if(!thys->Mainobj)
5215 return;
5216
5217 Obj = thys->Mainobj;
5218
5219 while(Obj)
5220 {
5221 if(Obj->type == RECTANGLE)
5222 {
5223 temp = ajGraphicsSetFgcolour(Obj->colour);
5224 ajGraphicsDrawposRect(Obj->xx1, Obj->yy1,Obj->xx2,
5225 Obj->yy2);
5226 ajGraphicsSetFgcolour(temp);
5227 }
5228 else if(Obj->type == RECTANGLEFILL)
5229 {
5230 temp = ajGraphicsSetFgcolour(Obj->colour);
5231 ajGraphicsDrawposRectFill(Obj->xx1, Obj->yy1,Obj->xx2,
5232 Obj->yy2);
5233 ajGraphicsSetFgcolour(temp);
5234 }
5235 else if(Obj->type == TEXT )
5236 {
5237 if(Obj->scale)
5238 cold = ajGraphicsSetCharscale(Obj->scale);
5239 temp = ajGraphicsSetFgcolour(Obj->colour);
5240 ajGraphicsDrawposTextAtstart(Obj->xx1, Obj->yy1,
5241 ajStrGetPtr(Obj->text));
5242 ajGraphicsSetFgcolour(temp);
5243 if(Obj->scale)
5244 ajGraphicsSetCharscale(cold);
5245 }
5246 else if(Obj->type == LINE)
5247 {
5248 temp = ajGraphicsSetFgcolour(Obj->colour);
5249 ajGraphicsDrawposLine(Obj->xx1, Obj->yy1,Obj->xx2,
5250 Obj->yy2);
5251 ajGraphicsSetFgcolour(temp);
5252 }
5253 else
5254 ajUserDumpC("UNDEFINED OBJECT TYPE USED");
5255
5256 Obj = Obj->next;
5257 ++nobj;
5258 }
5259
5260 ajDebug("drew %u objects in ajGraphDataDraw\n", nobj);
5261
5262 return;
5263 }
5264
5265
5266
5267
5268 /* @section Debugging **********************************************************
5269 **
5270 ** Tracing the internal values of a graph object
5271 **
5272 ** @fdata [AjPGraph]
5273 ** @fcategory use
5274 **
5275 ** @nam3rule Trace Trace internals
5276 **
5277 ** @argrule * thys [const AjPGraph] Graph object
5278 **
5279 ** @valrule * [void]
5280 **
5281 ******************************************************************************/
5282
5283
5284
5285
5286 /* @funcstatic GraphPrint *****************************************************
5287 **
5288 ** Print all the drawable objects in readable form.
5289 **
5290 ** @param [r] thys [const AjPGraph] Graph object
5291 **
5292 ** @return [void]
5293 **
5294 ** @release 2.9.0
5295 ** @@
5296 ******************************************************************************/
5297
GraphPrint(const AjPGraph thys)5298 static void GraphPrint(const AjPGraph thys)
5299 {
5300 AjPGraphobj Obj;
5301
5302 if(!thys->Mainobj)
5303 {
5304 ajUserDumpC("No Objects");
5305
5306 return;
5307 }
5308 else /* cycle through till NULL found */
5309 {
5310 Obj = thys->Mainobj;
5311
5312 while(Obj)
5313 {
5314 if(Obj->type == RECTANGLE )
5315 ajUser("type = RECTANGLE, %f %f %f %f col= %d",
5316 Obj->xx1, Obj->yy1,
5317 Obj->xx2,Obj->yy2,Obj->colour);
5318 else if(Obj->type == RECTANGLEFILL )
5319 ajUser("type = RECTANGLEFILL, %f %f %f %f col= %d",
5320 Obj->xx1, Obj->yy1,
5321 Obj->xx2,Obj->yy2,Obj->colour);
5322 else if(Obj->type == TEXT)
5323 ajUser("type = TEXT, %f %f col= %d %S",
5324 Obj->xx1, Obj->yy1,Obj->colour,
5325 Obj->text);
5326 else if(Obj->type == LINE )
5327 ajUser("type = LINE, %f %f %f %f col= %d",
5328 Obj->xx1, Obj->yy1,
5329 Obj->xx2,Obj->yy2,Obj->colour);
5330
5331 Obj = Obj->next;
5332 }
5333 }
5334
5335 return;
5336 }
5337
5338
5339
5340
5341 /* @func ajGraphTrace *********************************************************
5342 **
5343 ** Writes debug messages to trace the contents of a graph object.
5344 **
5345 ** @param [r] thys [const AjPGraph] Graph object
5346 ** @return [void]
5347 **
5348 ** @release 1.0.0
5349 ** @@
5350 ******************************************************************************/
5351
ajGraphTrace(const AjPGraph thys)5352 void ajGraphTrace(const AjPGraph thys)
5353 {
5354 AjPGraphdata graphdata;
5355 ajuint i;
5356
5357 ajDebug("Graph trace\n");
5358
5359 ajDebug("\n(a) True booleans\n");
5360
5361 ajDebug("minmaxcalc %B\n", thys->minmaxcalc);
5362
5363
5364 ajDebug("\n(b) Strings with values\n");
5365
5366 ajDebug("Desc '%S'\n", thys->desc);
5367 ajDebug("Title '%S'\n", thys->title);
5368 ajDebug("Subtitle '%S'\n", thys->subtitle);
5369 ajDebug("Xaxis '%S'\n", thys->xaxis);
5370 ajDebug("Yaxis '%S'\n", thys->yaxis);
5371 ajDebug("outputfile '%S'\n", thys->outputfile);
5372
5373 ajDebug("\n(c) Other values\n");
5374 ajDebug("flags %x\n", thys->flags);
5375 ajDebug("numofgraphs %d\n", thys->numofgraphs);
5376 ajDebug("numofgraphsmax %d\n", thys->numofgraphsmax);
5377 ajDebug("minX %7.3f maxX %7.3f\n",
5378 thys->minX,
5379 thys->maxX);
5380
5381 ajDebug("minX %7.3f maxX %7.3f\n",
5382 thys->minX,
5383 thys->maxX);
5384 ajDebug("minY %7.3f maxY %7.3f\n",
5385 thys->minY,
5386 thys->maxY);
5387 ajDebug("xstart %7.3f xend %7.3f\n",
5388 thys->xstart,
5389 thys->xend);
5390 ajDebug("ystart %7.3f yend %7.3f\n",
5391 thys->ystart,
5392 thys->yend);
5393 ajDebug("displaytype %d '%s'\n", thys->displaytype,
5394 graphType[thys->displaytype].Device);
5395
5396 for(i=0; i < thys->numofgraphs; i++)
5397 {
5398 ajDebug("GraphData[%u]\n", i);
5399 graphdata = (thys->graphs)[i];
5400 ajGraphdataTrace(graphdata);
5401 }
5402
5403 return;
5404 }
5405
5406
5407
5408
5409 /* @section Graph data management ********************************************
5410 **
5411 ** Functions to manage the graphdata objects associated with a graph object
5412 **
5413 ** @fdata [AjPGraph]
5414 ** @fcategory modify
5415 **
5416 ** @nam3rule Data
5417 ** @nam4rule Add Add a graph data object
5418 ** @nam4rule Replace Replace graph data object
5419 ** @suffix I Index number of data for multiple graphs
5420 **
5421 ** @argrule * thys [AjPGraph] multiple graph structure.
5422 ** @argrule * graphdata [AjPGraphdata] graph to be added.
5423 ** @argrule I num [ajuint] number within multiple graph.
5424 **
5425 ** @valrule * [AjBool]
5426 **
5427 ******************************************************************************/
5428
5429
5430
5431
5432 /* @func ajGraphDataAdd *******************************************************
5433 **
5434 ** Add another graph structure to the multiple graph structure.
5435 **
5436 ** The graphdata now belongs to the graph - do not delete it while
5437 ** the graph is using it.
5438 **
5439 ** @param [u] thys [AjPGraph] multiple graph structure.
5440 ** @param [u] graphdata [AjPGraphdata] graph to be added.
5441 ** @return [AjBool] True if graph added successfully
5442 **
5443 ** @release 2.9.0
5444 ** @@
5445 ******************************************************************************/
5446
ajGraphDataAdd(AjPGraph thys,AjPGraphdata graphdata)5447 AjBool ajGraphDataAdd(AjPGraph thys, AjPGraphdata graphdata)
5448 {
5449 if(thys->numofgraphs)
5450 {
5451 ajDebug("ajGraphDataAdd multi \n");
5452 }
5453
5454 if(thys->numofgraphs < thys->numofgraphsmax)
5455 {
5456 (thys->graphs)[thys->numofgraphs++] = graphdata;
5457 return ajTrue;
5458 }
5459
5460 ajErr("Too many multiple graphs - expected %d graphs",
5461 thys->numofgraphsmax);
5462
5463 return ajFalse;
5464 }
5465
5466
5467
5468
5469 /* @func ajGraphDataReplace ***************************************************
5470 **
5471 ** Replace graph structure into the multiple graph structure.
5472 **
5473 ** The graphdata now belongs to the graph - do not delete it while
5474 ** the graph is using it.
5475 **
5476 ** @param [u] thys [AjPGraph] multiple graph structure.
5477 ** @param [u] graphdata [AjPGraphdata] graph to be added.
5478 ** @return [AjBool] True if graph added successfully
5479 **
5480 ** @release 2.9.0
5481 ** @@
5482 ******************************************************************************/
5483
ajGraphDataReplace(AjPGraph thys,AjPGraphdata graphdata)5484 AjBool ajGraphDataReplace(AjPGraph thys, AjPGraphdata graphdata)
5485 {
5486 ajGraphdataDel(&(thys->graphs)[0]);
5487 (thys->graphs)[0] = graphdata;
5488 thys->numofgraphs=1;
5489
5490 thys->minmaxcalc = 0;
5491
5492 return ajTrue;
5493 }
5494
5495
5496
5497
5498 /* @func ajGraphDataReplaceI **************************************************
5499 **
5500 ** Replace one of the graph structures in the multiple graph structure.
5501 **
5502 ** The graphdata now belongs to the graph - do not delete it while
5503 ** the graph is using it.
5504 **
5505 ** @param [u] thys [AjPGraph] multiple graph structure.
5506 ** @param [u] graphdata [AjPGraphdata] graph to be added.
5507 ** @param [r] num [ajuint] number within multiple graph.
5508 ** @return [AjBool] True if graph added successfully
5509 **
5510 ** @release 4.1.0
5511 ** @@
5512 ******************************************************************************/
5513
ajGraphDataReplaceI(AjPGraph thys,AjPGraphdata graphdata,ajuint num)5514 AjBool ajGraphDataReplaceI(AjPGraph thys, AjPGraphdata graphdata, ajuint num)
5515 {
5516 if(thys->numofgraphs > num) {
5517 ajGraphdataDel(&(thys->graphs)[num]);
5518 (thys->graphs)[num] = graphdata;
5519 }
5520 else if(thys->numofgraphs < thys->numofgraphsmax)
5521 {
5522 (thys->graphs)[thys->numofgraphs++] = graphdata;
5523 }
5524 else
5525 {
5526 return ajFalse;
5527 }
5528
5529 thys->minmaxcalc = 0;
5530
5531 return ajTrue;
5532 }
5533
5534
5535
5536
5537 /* @datasection [AjPGraph] Graph object ****************************************
5538 **
5539 ** Function is for manipulating an AjPGraph object for an XY graph
5540 **
5541 ** @nam2rule Graphxy
5542 */
5543
5544
5545
5546
5547 /* @section Constructors ******************************************************
5548 **
5549 ** Construct a new graph object to be populated by other functions
5550 **
5551 ** @fdata [AjPGraph]
5552 ** @fcategory new
5553 **
5554 ** @nam3rule New
5555 ** @suffix I Number of graphs
5556 **
5557 ** @argrule I numsets [ajuint] maximum number of graphs that can be stored
5558 ** @valrule * [AjPGraph] New graph object
5559 **
5560 ******************************************************************************/
5561
5562
5563
5564
5565 /* @func ajGraphxyNewI ********************************************************
5566 **
5567 ** Create a structure to hold a number of graphs.
5568 **
5569 ** @param [r] numsets [ajuint] maximum number of graphs that can be stored.
5570 ** @return [AjPGraph] multiple graph structure.
5571 **
5572 ** @release 1.0.0
5573 ** @@
5574 ******************************************************************************/
5575
ajGraphxyNewI(ajuint numsets)5576 AjPGraph ajGraphxyNewI(ajuint numsets)
5577 {
5578 AjPGraph ret;
5579
5580 AJNEW0(ret);
5581 ret->numsets = numsets;
5582
5583 ajDebug("ajGraphxyNewI numsets: %d\n", numsets);
5584
5585 return ret;
5586 }
5587
5588
5589
5590
5591 /* @section Destructors *******************************************************
5592 **
5593 ** Destructors for AjGraph XY graph data
5594 **
5595 ** @fdata [AjPGraph]
5596 ** @fcategory delete
5597 **
5598 ** @nam3rule Del Destructor
5599 **
5600 ** @argrule Del pthis [AjPGraph*] Graph structure to store info in.
5601 **
5602 ** @valrule * [void]
5603 **
5604 ******************************************************************************/
5605
5606
5607
5608
5609 /* @func ajGraphxyDel *********************************************************
5610 **
5611 ** Destructor for a graph object
5612 **
5613 ** @param [w] pthis [AjPGraph*] Graph structure to store info in.
5614 ** @return [void]
5615 **
5616 ** @release 1.0.0
5617 ** @@
5618 ******************************************************************************/
5619
ajGraphxyDel(AjPGraph * pthis)5620 void ajGraphxyDel(AjPGraph* pthis)
5621 {
5622 AjPGraphdata graphdata;
5623 AjPGraph thys;
5624 ajuint i;
5625
5626 if(!pthis)
5627 return;
5628
5629 if(!*pthis)
5630 return;
5631
5632 thys = *pthis;
5633
5634 ajDebug("ajGraphxyDel numofgraphs:%d\n",
5635 thys->numofgraphs);
5636
5637 for(i = 0 ; i < thys->numofgraphs ; i++)
5638 {
5639 graphdata = (thys->graphs)[i];
5640
5641 if (graphdata)
5642 {
5643 ajDebug("ajGraphxyDel graphs[%d] xcalc:%B ycalc:%B x:%x y:%x\n",
5644 i, graphdata->xcalc, graphdata->ycalc,
5645 graphdata->x, graphdata->y);
5646
5647 if(!graphdata->xcalc)
5648 AJFREE(graphdata->x);
5649 if(!graphdata->ycalc)
5650 AJFREE(graphdata->y);
5651 ajGraphdataDel(&graphdata);
5652 }
5653 }
5654
5655 ajStrDel(&thys->desc);
5656 ajStrDel(&thys->title);
5657 ajStrDel(&thys->subtitle);
5658 ajStrDel(&thys->xaxis);
5659 ajStrDel(&thys->yaxis);
5660 ajStrDel(&thys->dataname);
5661 ajStrDel(&thys->outputfile);
5662
5663 ajGraphClear(thys);
5664
5665 AJFREE(thys->graphs);
5666
5667 AJFREE(thys);
5668
5669 *pthis = NULL;
5670
5671 return;
5672 }
5673
5674
5675
5676
5677 /* @section Display ***********************************************************
5678 **
5679 ** Functions to display or write the graph
5680 **
5681 ** @fdata [AjPGraph]
5682 ** @fcategory modify
5683 **
5684 ** @nam3rule Display Display the graph
5685 **
5686 ** @argrule Display thys [AjPGraph] Multiple graph pointer.
5687 ** @argrule Display closeit [AjBool] Whether to close graph at the end.
5688 **
5689 ** @valrule * [void]
5690 **
5691 ******************************************************************************/
5692
5693
5694
5695
5696 /* @func ajGraphxyDisplay *****************************************************
5697 **
5698 ** A general routine for drawing graphs.
5699 **
5700 ** @param [u] thys [AjPGraph] Multiple graph pointer.
5701 ** @param [r] closeit [AjBool] Whether to close graph at the end.
5702 ** @return [void]
5703 **
5704 ** @release 1.0.0
5705 ** @@
5706 ******************************************************************************/
5707
ajGraphxyDisplay(AjPGraph thys,AjBool closeit)5708 void ajGraphxyDisplay(AjPGraph thys, AjBool closeit)
5709 {
5710 /* Calling funclist graphType() */
5711 (graphType[thys->displaytype].XYDisplay)
5712 (thys, closeit, graphType[thys->displaytype].Ext);
5713
5714 return;
5715 }
5716
5717
5718
5719
5720 /* @section Modifiers *********************************************************
5721 **
5722 ** Set or modify internal values of an XY graph object
5723 **
5724 ** @fdata [AjPGraph]
5725 ** @fcategory modify
5726 **
5727 ** @nam3rule Set Set internals
5728 ** @nam3rule Setflag Set internal boolean flag
5729 ** @nam3rule Show Set whether to display an xy graph element
5730 ** @nam4rule Devicetype Plplot device type from a defined xy graph object
5731 ** @nam4rule Gaps Set whether graph will allow gaps
5732 ** @nam4rule Overlay Set whether graph will overlay multiple graphs
5733 ** @nam4rule Points Options for display of points on the graph
5734 ** @nam5rule PointsCircle Display of points as circles
5735 ** @nam5rule PointsJoin Display of points joined by lines
5736 ** @nam4rule Minmax Set min and max values
5737 ** @nam4rule Ranges Use min and max values from data
5738 ** @nam4rule Raxis Set the graph is to display a right hand Y axis.
5739 ** @nam4rule Uaxis Set the graph is to display an upper X axis.
5740 ** @nam4rule Unum Set the graph is to number an upper X axis.
5741 ** @nam4rule Ynum Set the graph is to number the Y axis.
5742 ** @nam4rule Xaxis Set the graph is to display an X axis.
5743 ** @nam4rule Yaxis Set the graph is to display a Y axis.
5744 ** @nam4rule Xlabel Set whether the graph is to label the x axis.
5745 ** @nam4rule Ylabel Set whether the graph is to label the y axis.
5746 ** @nam4rule Xtick Set whether the graph is to tick mark the x axis.
5747 ** @nam4rule Ytick Set whether the graph is to tick mark the y axis.
5748 ** @nam4rule Xend Set the end position for X in the graph.
5749 ** @nam4rule Yend Set the end position for Y in the graph.
5750 ** @nam4rule Xgrid Whether the graph is to grid the tick marks on the x axis
5751 ** @nam4rule Ygrid Whether the graph is to grid the tick marks on the y axis
5752 ** @nam4rule Xinvert whether the graph is to display the tick marks inside
5753 ** the plot on the x axis.
5754 ** @nam4rule Yinvert whether the graph is to display the tick marks inside
5755 ** the plot on the x axis.
5756 ** @nam4rule Xrange Set the X axis range
5757 ** @nam4rule Yrange Set the Y axis range
5758 ** @nam4rule Xstart Set the start position for X in the graph.
5759 ** @nam4rule Ystart Set the start position for Y in the graph.
5760 ** @suffix F floating point value
5761 ** @suffix I Integer value(s)
5762 **
5763 ** @argrule * thys [AjPGraph] Graph object
5764 ** @argrule Devicetype devicetype [const AjPStr] Device type
5765 ** @argrule Setflag set [AjBool] True to set the flag, false to clear
5766 ** @argrule Show set [AjBool] True to set the flag, false to clear
5767 ** @argrule Minmax xmin [float] X minimum value
5768 ** @argrule Minmax xmax [float] X maximum value
5769 ** @argrule Minmax ymin [float] Y minimum value
5770 ** @argrule Minmax ymax [float] Y maximum value
5771 ** @argrule F val [float] Graph position in user units
5772 ** @argrule I start [ajint] start position
5773 ** @argrule I end [ajint] end position
5774 **
5775 ** @valrule * [void]
5776 ** @valrule *Devicetype [AjBool] True on success
5777 **
5778 ******************************************************************************/
5779
5780
5781
5782
5783 /* @func ajGraphxySetDevicetype ***********************************************
5784 **
5785 ** Initialize options for a graphxy object
5786 **
5787 ** @param [u] thys [AjPGraph] Graph object
5788 ** @param [r] devicetype [const AjPStr] Device type
5789 ** @return [AjBool] ajTrue on success
5790 **
5791 ** @release 6.2.0
5792 ** @@
5793 ******************************************************************************/
5794
ajGraphxySetDevicetype(AjPGraph thys,const AjPStr devicetype)5795 AjBool ajGraphxySetDevicetype(AjPGraph thys, const AjPStr devicetype)
5796 {
5797 ajint i;
5798 ajint j=-1;
5799 ajint k;
5800 AjPStr aliases = NULL;
5801
5802 ajDebug("ajGraphxySetDevicetype '%S'\n", devicetype);
5803
5804 for(i=0;graphType[i].Name;i++)
5805 {
5806 if(!graphType[i].XYDisplay)
5807 continue;
5808
5809 if(ajStrMatchCaseC(devicetype, graphType[i].Name))
5810 {
5811 j = i;
5812 break;
5813 }
5814
5815 if(ajCharPrefixCaseS(graphType[i].Name, devicetype))
5816 {
5817 if(j < 0)
5818 j = i;
5819 else
5820 {
5821 for(k=0;graphType[k].Name;k++)
5822 {
5823 if(ajCharPrefixCaseS(graphType[k].Name, devicetype))
5824 {
5825 if(ajStrGetLen(aliases))
5826 ajStrAppendC(&aliases, ", ");
5827 ajStrAppendC(&aliases, graphType[k].Name);
5828 }
5829 }
5830
5831 ajErr("Ambiguous graph device name '%S' (%S)",
5832 devicetype, aliases);
5833 ajStrDel(&aliases);
5834
5835 return ajFalse;
5836 }
5837 }
5838 }
5839
5840 if(j<0)
5841 return ajFalse;
5842
5843 GraphxyNewPlplot(thys);
5844
5845 /* Calling funclist graphType() */
5846
5847 thys->displaytype = j;
5848
5849 ajDebug("ajGraphxySetDevicetype type '%S' displaytype %d '%s'\n",
5850 devicetype, j, graphType[j].Name);
5851
5852 return ajTrue;
5853
5854 }
5855
5856
5857
5858
5859 /* @func ajGraphxySetMinmax ***************************************************
5860 **
5861 ** Set the max and min of the data points for all graphs.
5862 **
5863 ** @param [u] thys [AjPGraph] multiple graph structure.
5864 ** @param [r] xmin [float] x min.
5865 ** @param [r] xmax [float] x max.
5866 ** @param [r] ymin [float] y min.
5867 ** @param [r] ymax [float] y max.
5868 ** @return [void]
5869 **
5870 ** @release 6.2.0
5871 ** @@
5872 ******************************************************************************/
5873
ajGraphxySetMinmax(AjPGraph thys,float xmin,float xmax,float ymin,float ymax)5874 void ajGraphxySetMinmax(AjPGraph thys,float xmin,float xmax,
5875 float ymin,float ymax)
5876 {
5877 AjPGraphdata graphdata;
5878 ajuint i;
5879
5880 if (!thys)
5881 return;
5882
5883 thys->minX = xmin;
5884 thys->minY = ymin;
5885 thys->maxX = xmax;
5886 thys->maxY = ymax;
5887
5888 for(i = 0 ; i < thys->numofgraphs ; i++)
5889 {
5890 graphdata = (thys->graphs)[i];
5891 graphdata->minX = xmin;
5892 graphdata->minY = ymin;
5893 graphdata->maxX = xmax;
5894 graphdata->maxY = ymax;
5895 }
5896
5897 return;
5898 }
5899
5900
5901
5902
5903 /* @func ajGraphxySetRanges ***************************************************
5904 **
5905 ** Calculate the max and min of the data points and store them.
5906 **
5907 ** See ajGraphxySetMaxmin for a function that defines explicit ranges
5908 **
5909 ** @param [u] thys [AjPGraph] multiple graph structure.
5910 ** @return [void]
5911 **
5912 ** @release 6.2.0
5913 ** @@
5914 ******************************************************************************/
5915
ajGraphxySetRanges(AjPGraph thys)5916 void ajGraphxySetRanges(AjPGraph thys)
5917 {
5918 AjPGraphdata graphdata = NULL;
5919 ajuint i;
5920 ajuint j;
5921
5922 for(i = 0 ; i < thys->numofgraphs ; i++)
5923 {
5924 graphdata = (thys->graphs)[i];
5925
5926 if(graphdata->truescale)
5927 {
5928 thys->minX = graphdata->tminX;
5929 thys->maxX = graphdata->tmaxX;
5930 thys->minY = graphdata->tminY;
5931 thys->maxY = graphdata->tmaxY;
5932
5933 graphdata->minX = graphdata->tminX;
5934 graphdata->maxX = graphdata->tmaxX;
5935 graphdata->minY = graphdata->tminY;
5936 graphdata->maxY = graphdata->tmaxY;
5937 }
5938 else
5939 {
5940 if(graphdata->minX == graphdata->maxX ||
5941 graphdata->minY == graphdata->maxY)
5942 {
5943 graphdata->minX = graphdata->minY = FLT_MAX;
5944 graphdata->maxX = graphdata->maxY = -FLT_MAX;
5945
5946 for( j = 0 ; j < graphdata->numofpoints; j++)
5947 {
5948 if(graphdata->maxX < (graphdata->x)[j])
5949 graphdata->maxX = (graphdata->x)[j];
5950 if(graphdata->maxY < (graphdata->y)[j])
5951 graphdata->maxY = (graphdata->y)[j];
5952 if(graphdata->minX > (graphdata->x)[j])
5953 graphdata->minX = (graphdata->x)[j];
5954 if(graphdata->minY > (graphdata->y)[j])
5955 graphdata->minY = (graphdata->y)[j];
5956 }
5957 if(graphdata->minX == graphdata->maxX)
5958 {
5959 if(graphdata->minX < 0.0)
5960 graphdata->minX *= (float) 1.1;
5961 else
5962 graphdata->minX /= (float) 1.1;
5963
5964 if(graphdata->maxX < 0.0)
5965 graphdata->maxX /= (float) 1.1;
5966 else
5967 graphdata->maxX *= (float) 1.1;
5968 }
5969
5970 if(graphdata->minY == graphdata->maxY)
5971 {
5972 if(graphdata->minY < 0.0)
5973 graphdata->minY *= (float) 1.1;
5974 else
5975 graphdata->minY /= (float) 1.1;
5976
5977 if(graphdata->maxY < 0.0)
5978 graphdata->maxY /= (float) 1.1;
5979 else
5980 graphdata->maxY *= (float) 1.1;
5981 }
5982 }
5983
5984 if (thys->minX > graphdata->minX)
5985 thys->minX = graphdata->minX;
5986
5987 if (thys->minY > graphdata->minY)
5988 thys->minY = graphdata->minY;
5989
5990 if (thys->maxX < graphdata->maxX)
5991 thys->maxX = graphdata->maxX;
5992
5993 if (thys->maxY < graphdata->maxY)
5994 thys->maxY = graphdata->maxY;
5995 }
5996 }
5997
5998
5999 if(!thys->minmaxcalc)
6000 {
6001 thys->xstart = thys->minX;
6002 thys->xend = thys->maxX;
6003 thys->ystart = thys->minY;
6004 thys->yend = thys->maxY;
6005
6006 thys->minmaxcalc = ajTrue;
6007 }
6008
6009 return;
6010 }
6011
6012
6013
6014
6015 /* @func ajGraphxySetXendF ****************************************************
6016 **
6017 ** Set the end position for X in the graph.
6018 **
6019 ** @param [u] thys [AjPGraph] Graph structure to store info in.
6020 ** @param [r] val [float] The end value for x graph coord
6021 ** @return [void]
6022 **
6023 ** @release 6.2.0
6024 ** @@
6025 ******************************************************************************/
6026
ajGraphxySetXendF(AjPGraph thys,float val)6027 void ajGraphxySetXendF(AjPGraph thys, float val)
6028 {
6029 if (thys)
6030 {
6031 thys->xend = val;
6032 }
6033
6034 return;
6035 }
6036
6037
6038
6039
6040 /* @func ajGraphxySetXrangeII *************************************************
6041 **
6042 ** Sets the X axis range with integers
6043 **
6044 ** @param [u] thys [AjPGraph] Graph
6045 ** @param [r] start [ajint] start position
6046 ** @param [r] end [ajint] end position
6047 ** @return [void]
6048 **
6049 ** @release 6.2.0
6050 ** @@
6051 ******************************************************************************/
6052
ajGraphxySetXrangeII(AjPGraph thys,ajint start,ajint end)6053 void ajGraphxySetXrangeII(AjPGraph thys, ajint start, ajint end)
6054 {
6055 if (thys)
6056 {
6057 thys->xstart = (float) start;
6058 thys->xend = (float) end;
6059 }
6060
6061 return;
6062 }
6063
6064
6065
6066
6067 /* @func ajGraphxySetXstartF **************************************************
6068 **
6069 ** Set the start position for X in the graph.
6070 **
6071 ** @param [u] thys [AjPGraph] Graph structure to store info in.
6072 ** @param [r] val [float] The start value for x graph coord.
6073 ** @return [void]
6074 **
6075 ** @release 6.2.0
6076 ** @@
6077 ******************************************************************************/
6078
ajGraphxySetXstartF(AjPGraph thys,float val)6079 void ajGraphxySetXstartF(AjPGraph thys, float val)
6080 {
6081 if (thys)
6082 {
6083 thys->xstart = val;
6084 }
6085
6086 return;
6087 }
6088
6089
6090
6091
6092 /* @func ajGraphxySetYendF ****************************************************
6093 **
6094 ** Set the end position for Y in the graph.
6095 **
6096 ** @param [u] thys [AjPGraph] Graph structure to store info in.
6097 ** @param [r] val [float] The start value for y graph coord.
6098 ** @return [void]
6099 **
6100 ** @release 6.2.0
6101 ** @@
6102 ******************************************************************************/
6103
ajGraphxySetYendF(AjPGraph thys,float val)6104 void ajGraphxySetYendF(AjPGraph thys, float val)
6105 {
6106 if (thys)
6107 {
6108 thys->yend = val;
6109 }
6110
6111 return;
6112 }
6113
6114
6115
6116
6117 /* @func ajGraphxySetYrangeII *************************************************
6118 **
6119 ** Sets the Y axis range with integers
6120 **
6121 ** @param [u] thys [AjPGraph] Graph
6122 ** @param [r] start [ajint] start position
6123 ** @param [r] end [ajint] end position
6124 ** @return [void]
6125 **
6126 ** @release 6.2.0
6127 ** @@
6128 ******************************************************************************/
6129
ajGraphxySetYrangeII(AjPGraph thys,ajint start,ajint end)6130 void ajGraphxySetYrangeII(AjPGraph thys, ajint start, ajint end)
6131 {
6132 if (thys)
6133 {
6134 thys->ystart = (float) start;
6135 thys->yend = (float) end;
6136 }
6137
6138 return;
6139 }
6140
6141
6142
6143
6144 /* @func ajGraphxySetYstartF **************************************************
6145 **
6146 ** Set the start position for Y in the graph.
6147 **
6148 ** @param [u] thys [AjPGraph] Graph structure to store info in.
6149 ** @param [r] val [float] The end value for y graph coord.
6150 ** @return [void]
6151 **
6152 ** @release 6.2.0
6153 ** @@
6154 ******************************************************************************/
6155
ajGraphxySetYstartF(AjPGraph thys,float val)6156 void ajGraphxySetYstartF(AjPGraph thys, float val)
6157 {
6158 if (thys)
6159 {
6160 thys->ystart = val;
6161 }
6162
6163 return;
6164 }
6165
6166
6167
6168
6169 /* @func ajGraphxySetflagGaps *************************************************
6170 **
6171 ** Set whether the graphs should enable gaps.
6172 **
6173 ** @param [u] thys [AjPGraph] Multiple graph object
6174 ** @param [r] set [AjBool] if true allow gaps else do not.
6175 ** @return [void]
6176 **
6177 ** @release 6.2.0
6178 ** @@
6179 ******************************************************************************/
6180
ajGraphxySetflagGaps(AjPGraph thys,AjBool set)6181 void ajGraphxySetflagGaps(AjPGraph thys, AjBool set)
6182 {
6183 if (!thys)
6184 return;
6185
6186 if(thys->flags & AJGRAPH_GAPS)
6187 {
6188 if(!set)
6189 thys->flags -= AJGRAPH_GAPS;
6190 }
6191 else
6192 {
6193 if(set)
6194 thys->flags += AJGRAPH_GAPS;
6195 }
6196
6197 return;
6198 }
6199
6200
6201
6202
6203 /* @func ajGraphxySetflagOverlay **********************************************
6204 **
6205 ** Set whether the graphs should lay on top of each other.
6206 **
6207 ** @param [u] thys [AjPGraph] Multiple graph object
6208 ** @param [r] set [AjBool] if true overlap else do not.
6209 ** @return [void]
6210 **
6211 ** @release 6.2.0
6212 ** @@
6213 ******************************************************************************/
6214
ajGraphxySetflagOverlay(AjPGraph thys,AjBool set)6215 void ajGraphxySetflagOverlay(AjPGraph thys, AjBool set)
6216 {
6217 if (!thys)
6218 return;
6219
6220 if(thys->flags & AJGRAPH_OVERLAP)
6221 {
6222 if(!set)
6223 thys->flags -= AJGRAPH_OVERLAP;
6224 }
6225 else
6226 {
6227 if(set)
6228 thys->flags += AJGRAPH_OVERLAP;
6229 }
6230
6231 return;
6232 }
6233
6234
6235
6236
6237 /* @func ajGraphxyShowPointsCircle ********************************************
6238 **
6239 ** Set the graph to draw circles at the points.
6240 **
6241 ** @param [u] thys [AjPGraph] graph to have flag altered
6242 ** @param [r] set [AjBool] whether to set or turn off.
6243 ** @return [void]
6244 **
6245 ** @release 6.2.0
6246 ** @@
6247 ******************************************************************************/
6248
ajGraphxyShowPointsCircle(AjPGraph thys,AjBool set)6249 void ajGraphxyShowPointsCircle(AjPGraph thys, AjBool set)
6250 {
6251 ajGraphSetFlag(thys, AJGRAPH_CIRCLEPOINTS, set);
6252
6253 return;
6254 }
6255
6256
6257
6258
6259 /* @func ajGraphxyShowPointsJoin **********************************************
6260 **
6261 ** Set the graph to draw lines between the points.
6262 **
6263 ** @param [u] thys [AjPGraph] graph to have flag altered
6264 ** @param [r] set [AjBool] whether to set or turn off.
6265 ** @return [void]
6266 **
6267 ** @release 6.2.0
6268 ** @@
6269 ******************************************************************************/
6270
ajGraphxyShowPointsJoin(AjPGraph thys,AjBool set)6271 void ajGraphxyShowPointsJoin(AjPGraph thys, AjBool set)
6272 {
6273 ajGraphSetFlag(thys, AJGRAPH_JOINPOINTS, set);
6274
6275 return;
6276 }
6277
6278
6279
6280
6281 /* @func ajGraphxyShowRaxis ***************************************************
6282 **
6283 ** Set the graph is to display a right hand Y axis.
6284 **
6285 ** @param [u] thys [AjPGraph] graph to have flag altered
6286 ** @param [r] set [AjBool] whether to set or turn off.
6287 ** @return [void]
6288 **
6289 ** @release 6.2.0
6290 ** @@
6291 ******************************************************************************/
6292
ajGraphxyShowRaxis(AjPGraph thys,AjBool set)6293 void ajGraphxyShowRaxis(AjPGraph thys, AjBool set)
6294 {
6295 ajGraphSetFlag(thys, AJGRAPH_Y_RIGHT, set);
6296
6297 return;
6298 }
6299
6300
6301
6302
6303 /* @func ajGraphxyShowUaxis ***************************************************
6304 **
6305 ** Set whether the graph is to display the left X axis at the top.
6306 **
6307 ** @param [u] thys [AjPGraph] graph to have flag altered
6308 ** @param [r] set [AjBool] whether to set or turn off.
6309 ** @return [void]
6310 **
6311 ** @release 6.2.0
6312 ** @@
6313 ******************************************************************************/
6314
ajGraphxyShowUaxis(AjPGraph thys,AjBool set)6315 void ajGraphxyShowUaxis(AjPGraph thys, AjBool set)
6316 {
6317 ajGraphSetFlag(thys, AJGRAPH_X_TOP, set);
6318
6319 return;
6320 }
6321
6322
6323
6324
6325 /* @func ajGraphxyShowUnum ****************************************************
6326 **
6327 ** Set whether the graph is to display the labels on the upper x axis.
6328 **
6329 ** @param [u] thys [AjPGraph] graph to have flag altered
6330 ** @param [r] set [AjBool] whether to set or turn off.
6331 ** @return [void]
6332 **
6333 ** @release 6.2.0
6334 ** @@
6335 ******************************************************************************/
6336
ajGraphxyShowUnum(AjPGraph thys,AjBool set)6337 void ajGraphxyShowUnum(AjPGraph thys, AjBool set)
6338 {
6339 ajGraphSetFlag(thys, AJGRAPH_X_NUMLABEL_ABOVE, set);
6340
6341 return;
6342 }
6343
6344
6345
6346
6347 /* @func ajGraphxyShowXaxis ***************************************************
6348 **
6349 ** Set whether the graph is to display a bottom x axis.
6350 **
6351 ** @param [u] thys [AjPGraph] graph to have flag altered
6352 ** @param [r] set [AjBool] whether to set or turn off.
6353 ** @return [void]
6354 **
6355 ** @release 6.2.0
6356 ** @@
6357 ******************************************************************************/
6358
ajGraphxyShowXaxis(AjPGraph thys,AjBool set)6359 void ajGraphxyShowXaxis(AjPGraph thys, AjBool set)
6360 {
6361 ajGraphSetFlag(thys, AJGRAPH_X_BOTTOM, set);
6362
6363 return;
6364 }
6365
6366
6367
6368
6369 /* @func ajGraphxyShowXgrid ***************************************************
6370 **
6371 ** Set whether the graph is to grid the tick marks on the x axis.
6372 **
6373 ** @param [u] thys [AjPGraph] graph to have flag altered
6374 ** @param [r] set [AjBool] whether to set or turn off.
6375 ** @return [void]
6376 **
6377 ** @release 6.2.0
6378 ** @@
6379 ******************************************************************************/
6380
ajGraphxyShowXgrid(AjPGraph thys,AjBool set)6381 void ajGraphxyShowXgrid(AjPGraph thys, AjBool set)
6382 {
6383 ajGraphSetFlag(thys, AJGRAPH_X_GRID, set);
6384
6385 return;
6386 }
6387
6388
6389
6390
6391 /* @func ajGraphxyShowXinvert *************************************************
6392 **
6393 ** Set whether the graph is to display the tick marks inside the plot on
6394 ** the x axis.
6395 **
6396 ** @param [u] thys [AjPGraph] graph to have flag altered
6397 ** @param [r] set [AjBool] whether to set or turn off.
6398 ** @return [void]
6399 **
6400 ** @release 6.2.0
6401 ** @@
6402 ******************************************************************************/
6403
ajGraphxyShowXinvert(AjPGraph thys,AjBool set)6404 void ajGraphxyShowXinvert(AjPGraph thys, AjBool set)
6405 {
6406 ajGraphSetFlag(thys, AJGRAPH_X_INVERT_TICK, set);
6407
6408 return;
6409 }
6410
6411
6412
6413
6414 /* @func ajGraphxyShowXlabel **************************************************
6415 **
6416 ** Set whether the graph is to label the x axis.
6417 **
6418 ** @param [u] thys [AjPGraph] graph to have flag altered
6419 ** @param [r] set [AjBool] whether to set or turn off.
6420 ** @return [void]
6421 **
6422 ** @release 6.2.0
6423 ** @@
6424 ******************************************************************************/
6425
ajGraphxyShowXlabel(AjPGraph thys,AjBool set)6426 void ajGraphxyShowXlabel(AjPGraph thys, AjBool set)
6427 {
6428 ajGraphSetFlag(thys, AJGRAPH_X_LABEL, set);
6429
6430 return;
6431 }
6432
6433
6434
6435
6436 /* @func ajGraphxyShowXtick ***************************************************
6437 **
6438 ** Set whether the graph is to display tick marks on the x axis.
6439 **
6440 ** @param [u] thys [AjPGraph] graph to have flag altered
6441 ** @param [r] set [AjBool] whether to set or turn off.
6442 ** @return [void]
6443 **
6444 ** @release 6.2.0
6445 ** @@
6446 ******************************************************************************/
6447
ajGraphxyShowXtick(AjPGraph thys,AjBool set)6448 void ajGraphxyShowXtick(AjPGraph thys, AjBool set)
6449 {
6450 ajGraphSetFlag(thys, AJGRAPH_X_TICK, set);
6451
6452 return;
6453 }
6454
6455
6456
6457
6458 /* @func ajGraphxyShowYaxis ***************************************************
6459 **
6460 ** Set whether the graph is to display the left Y axis.
6461 **
6462 ** @param [u] thys [AjPGraph] graph to have flag altered
6463 ** @param [r] set [AjBool] whether to set or turn off.
6464 ** @return [void]
6465 **
6466 ** @release 6.2.0
6467 ** @@
6468 ******************************************************************************/
6469
ajGraphxyShowYaxis(AjPGraph thys,AjBool set)6470 void ajGraphxyShowYaxis(AjPGraph thys, AjBool set)
6471 {
6472 ajGraphSetFlag(thys, AJGRAPH_Y_LEFT, set);
6473
6474 return;
6475 }
6476
6477
6478
6479
6480 /* @func ajGraphxyShowYgrid ***************************************************
6481 **
6482 ** Set whether the graph is to grid the tick marks on the x axis.
6483 **
6484 ** @param [u] thys [AjPGraph] graph to have flag altered
6485 ** @param [r] set [AjBool] whether to set or turn off.
6486 ** @return [void]
6487 **
6488 ** @release 6.2.0
6489 ** @@
6490 ******************************************************************************/
6491
ajGraphxyShowYgrid(AjPGraph thys,AjBool set)6492 void ajGraphxyShowYgrid(AjPGraph thys, AjBool set)
6493 {
6494 ajGraphSetFlag(thys, AJGRAPH_Y_GRID, set);
6495
6496 return;
6497 }
6498
6499
6500
6501
6502 /* @func ajGraphxyShowYinvert *************************************************
6503 **
6504 ** Set whether the graph is to display the tick marks inside the plot
6505 ** on the y axis.
6506 **
6507 ** @param [u] thys [AjPGraph] graph to have flag altered
6508 ** @param [r] set [AjBool] whether to set or turn off.
6509 ** @return [void]
6510 **
6511 ** @release 6.2.0
6512 ** @@
6513 ******************************************************************************/
6514
ajGraphxyShowYinvert(AjPGraph thys,AjBool set)6515 void ajGraphxyShowYinvert(AjPGraph thys, AjBool set)
6516 {
6517 ajGraphSetFlag(thys, AJGRAPH_Y_INVERT_TICK, set);
6518
6519 return;
6520 }
6521
6522
6523
6524
6525 /* @func ajGraphxyShowYlabel **************************************************
6526 **
6527 ** Set whether the graph is to label the y axis.
6528 **
6529 ** @param [u] thys [AjPGraph] graph to have flag altered
6530 ** @param [r] set [AjBool] whether to set or turn off.
6531 ** @return [void]
6532 **
6533 ** @release 6.2.0
6534 ** @@
6535 ******************************************************************************/
6536
ajGraphxyShowYlabel(AjPGraph thys,AjBool set)6537 void ajGraphxyShowYlabel(AjPGraph thys, AjBool set)
6538 {
6539 ajGraphSetFlag(thys, AJGRAPH_Y_LABEL, set);
6540
6541 return;
6542 }
6543
6544
6545
6546
6547 /* @func ajGraphxyShowYnum ****************************************************
6548 **
6549 ** Set whether the graph is to display the numbers on the left Y axis.
6550 **
6551 ** @param [u] thys [AjPGraph] graph to have flag altered
6552 ** @param [r] set [AjBool] whether to set or turn off.
6553 ** @return [void]
6554 **
6555 ** @release 6.2.0
6556 ** @@
6557 ******************************************************************************/
6558
ajGraphxyShowYnum(AjPGraph thys,AjBool set)6559 void ajGraphxyShowYnum(AjPGraph thys, AjBool set)
6560 {
6561 ajGraphSetFlag(thys, AJGRAPH_Y_NUMLABEL_LEFT, set);
6562
6563 return;
6564 }
6565
6566
6567
6568
6569 /* @func ajGraphxyShowYtick ***************************************************
6570 **
6571 ** Set the graph is to display tick marks on the y axis.
6572 **
6573 ** @param [u] thys [AjPGraph] graph to have flag altered
6574 ** @param [r] set [AjBool] whether to set or turn off.
6575 ** @return [void]
6576 **
6577 ** @release 6.2.0
6578 ** @@
6579 ******************************************************************************/
6580
ajGraphxyShowYtick(AjPGraph thys,AjBool set)6581 void ajGraphxyShowYtick(AjPGraph thys, AjBool set)
6582 {
6583 ajGraphSetFlag(thys, AJGRAPH_Y_TICK, set);
6584
6585 return;
6586 }
6587
6588
6589
6590
6591 /* @datasection [AjPGraphdata] Graph data object ******************************
6592 **
6593 ** Function is for manipulating an AjPGraphdata object
6594 **
6595 ** @nam2rule Graphdata
6596 */
6597
6598
6599
6600
6601 /* @section Constructors *******************************************************
6602 **
6603 ** Constructors for AjGraphdata plot data
6604 **
6605 ** @fdata [AjPGraphdata]
6606 ** @fcategory new
6607 **
6608 ** @nam3rule New Constructor
6609 ** @suffix I Number of points
6610 ** @argrule I numofpoints [ajuint] Number of points
6611 **
6612 ** @valrule * [AjPGraphdata] New graphdata object
6613 **
6614 ******************************************************************************/
6615
6616
6617
6618
6619 /* @func ajGraphdataNew *******************************************************
6620 **
6621 ** Creates a new empty graph
6622 **
6623 ** @return [AjPGraphdata] New empty graph
6624 **
6625 ** @release 6.2.0
6626 ** @@
6627 ******************************************************************************/
6628
ajGraphdataNew(void)6629 AjPGraphdata ajGraphdataNew(void)
6630 {
6631 static AjPGraphdata graphdata;
6632
6633 AJNEW0(graphdata);
6634 graphdata->numofpoints = 0;
6635
6636 return graphdata;
6637 }
6638
6639
6640
6641
6642 /* @func ajGraphdataNewI ******************************************************
6643 **
6644 ** Create and initialise the data structure for the graph with a defined
6645 ** number of data points.
6646 **
6647 ** @param [r] numofpoints [ajuint] Number of points
6648 ** @return [AjPGraphdata] Pointer to new graph structure.
6649 **
6650 ** @release 6.2.0
6651 ** @@
6652 ******************************************************************************/
6653
ajGraphdataNewI(ajuint numofpoints)6654 AjPGraphdata ajGraphdataNewI(ajuint numofpoints)
6655 {
6656 AjPGraphdata graphdata;
6657
6658 AJNEW0(graphdata);
6659
6660 GraphdataInit(graphdata);
6661
6662 graphdata->numofpoints = numofpoints;
6663
6664 graphdata->xcalc = ajFalse;
6665 AJCNEW0(graphdata->x, numofpoints);
6666
6667 graphdata->ycalc = ajFalse;
6668 AJCNEW0(graphdata->y, numofpoints);
6669
6670 return graphdata;
6671 }
6672
6673
6674
6675
6676 /* @section Destructors *******************************************************
6677 **
6678 ** Destructors for AjGraphdata plot data
6679 **
6680 ** @fdata [AjPGraphdata]
6681 ** @fcategory delete
6682 **
6683 ** @nam3rule Del Destructor
6684 **
6685 ** @argrule Del pthys [AjPGraphdata*] Graph data object
6686 ** @valrule * [void]
6687 **
6688 ******************************************************************************/
6689
6690
6691
6692
6693 /* @func ajGraphdataDel *******************************************************
6694 **
6695 ** Destructor for a graph data object
6696 **
6697 ** @param [d] pthys [AjPGraphdata*] Graph data object
6698 ** @return [void]
6699 **
6700 ** @release 6.2.0
6701 ** @@
6702 ******************************************************************************/
6703
ajGraphdataDel(AjPGraphdata * pthys)6704 void ajGraphdataDel(AjPGraphdata *pthys)
6705 {
6706 AjPGraphobj here = NULL;
6707 AjPGraphobj p = NULL;
6708 AjPGraphdata thys;
6709
6710 thys = *pthys;
6711
6712 if (!thys)
6713 return;
6714
6715 ajDebug("ajGraphdataDel objects:%d\n", thys->numofobjects);
6716
6717 here = p = thys->Dataobj;
6718
6719 while(p)
6720 {
6721 p = here->next;
6722 ajStrDel(&here->text);
6723 AJFREE(here);
6724 here = p;
6725 }
6726
6727 thys->Dataobj = NULL;
6728
6729 ajStrDel(&thys->title);
6730 ajStrDel(&thys->subtitle);
6731 ajStrDel(&thys->xaxis);
6732 ajStrDel(&thys->yaxis);
6733 ajStrDel(&thys->gtype);
6734 ajStrDel(&thys->dataname);
6735 AJFREE(thys->x);
6736 AJFREE(thys->y);
6737 thys->numofobjects = 0;
6738
6739 AJFREE(*pthys);
6740
6741 return;
6742 }
6743
6744
6745
6746
6747 /* @section Modifiers **********************************************************
6748 **
6749 ** Set or modify the internals of a graph data object
6750 **
6751 ** @fdata [AjPGraphdata]
6752 ** @fcategory modify
6753 **
6754 ** @nam3rule Set Set internal values
6755 ** @nam3rule Setflag Set internal boolean flag
6756 ** @nam3rule Show Set whether to display an xy graph element
6757 ** @nam4rule Colour Colour code (see PLPLOT)
6758 ** @nam4rule Dataname Data source name
6759 ** @nam4rule Linetype Set the line type for this graph.
6760 ** @nam4rule Minmax Set min and max values
6761 ** @nam4rule Subtitle Graph subtitle
6762 ** @nam4rule Title Graph title
6763 ** @nam4rule Truescale Set the scale max and min of the data points
6764 ** @nam4rule Type Graph data output type
6765 ** @nam4rule Xlabel Set the title for the X axis.
6766 ** @nam4rule Ylabel Set the title for the Y axis.
6767 ** @suffix C C character string data
6768 ** @suffix S String object data
6769 **
6770 ** @argrule * graphdata [AjPGraphdata] Graph data object
6771 ** @argrule Show set [AjBool] True to set the flag, false to clear
6772 ** @argrule Colour colour [ajint] Colour code (see PLPLOT)
6773 ** @argrule Linetype type [ajint] Set the line type.
6774 ** @argrule Minmax xmin [float] X minimum value
6775 ** @argrule Minmax xmax [float] X maximum value
6776 ** @argrule Minmax ymin [float] Y minimum value
6777 ** @argrule Minmax ymax [float] Y maximum value
6778 ** @argrule Truescale xmin [float] X minimum value
6779 ** @argrule Truescale xmax [float] X maximum value
6780 ** @argrule Truescale ymin [float] Y minimum value
6781 ** @argrule Truescale ymax [float] Y maximum value
6782 ** @argrule C txt [const char*] C character string
6783 ** @argrule S str [const AjPStr] String object
6784 **
6785 ** @valrule * [void]
6786 **
6787 ******************************************************************************/
6788
6789
6790
6791
6792 /* @func ajGraphdataSetColour *************************************************
6793 **
6794 ** Set the colour for the plot on one graph.
6795 **
6796 ** @param [u] graphdata [AjPGraphdata] Graph structure to store info in.
6797 ** @param [r] colour [ajint] colour for this plot.
6798 ** @return [void]
6799 **
6800 ** @release 6.2.0
6801 ** @@
6802 ******************************************************************************/
6803
ajGraphdataSetColour(AjPGraphdata graphdata,ajint colour)6804 void ajGraphdataSetColour(AjPGraphdata graphdata, ajint colour)
6805 {
6806 graphdata->colour = colour;
6807
6808 return;
6809 }
6810
6811
6812
6813
6814 /* @func ajGraphdataSetDatanameC **********************************************
6815 **
6816 ** Set the Subtitle.
6817 **
6818 ** @param [u] graphdata [AjPGraphdata] Graph structure to store info in.
6819 ** @param [r] txt [const char*] Data source name
6820 ** @return [void]
6821 **
6822 ** @release 6.5.0
6823 ** @@
6824 ******************************************************************************/
6825
ajGraphdataSetDatanameC(AjPGraphdata graphdata,const char * txt)6826 void ajGraphdataSetDatanameC(AjPGraphdata graphdata, const char *txt)
6827 {
6828 ajStrAssignEmptyC(&graphdata->dataname,txt);
6829
6830 return;
6831 }
6832
6833
6834
6835
6836 /* @func ajGraphdataSetDatanameS **********************************************
6837 **
6838 ** Set the Subtitle.
6839 **
6840 ** @param [u] graphdata [AjPGraphdata] Graph structure to store info in.
6841 ** @param [r] str [const AjPStr] Data source name
6842 ** @return [void]
6843 **
6844 ** @release 6.5.0
6845 ** @@
6846 ******************************************************************************/
6847
ajGraphdataSetDatanameS(AjPGraphdata graphdata,const AjPStr str)6848 void ajGraphdataSetDatanameS(AjPGraphdata graphdata, const AjPStr str)
6849 {
6850 ajStrAssignEmptyS(&graphdata->dataname,str);
6851
6852 return;
6853 }
6854
6855
6856
6857
6858 /* @func ajGraphdataSetLinetype ***********************************************
6859 **
6860 ** Set the line type for this graph.
6861 **
6862 ** @param [u] graphdata [AjPGraphdata] Graph structure to store info in.
6863 ** @param [r] type [ajint] Set the line type.
6864 ** @return [void]
6865 **
6866 ** @release 6.2.0
6867 ** @@
6868 ******************************************************************************/
6869
ajGraphdataSetLinetype(AjPGraphdata graphdata,ajint type)6870 void ajGraphdataSetLinetype(AjPGraphdata graphdata, ajint type)
6871 {
6872 graphdata->lineType = type;
6873
6874 return;
6875 }
6876
6877
6878
6879
6880 /* @func ajGraphdataSetMinmax *************************************************
6881 **
6882 ** Set the max and min of the data points you wish to display.
6883 **
6884 ** @param [u] graphdata [AjPGraphdata] multiple graph structure.
6885 ** @param [r] xmin [float] x min.
6886 ** @param [r] xmax [float] x max.
6887 ** @param [r] ymin [float] y min.
6888 ** @param [r] ymax [float] y max.
6889 ** @return [void]
6890 **
6891 ** @release 6.2.0
6892 ** @@
6893 ******************************************************************************/
6894
ajGraphdataSetMinmax(AjPGraphdata graphdata,float xmin,float xmax,float ymin,float ymax)6895 void ajGraphdataSetMinmax(AjPGraphdata graphdata, float xmin, float xmax,
6896 float ymin, float ymax)
6897 {
6898 graphdata->minX = xmin;
6899 graphdata->minY = ymin;
6900 graphdata->maxX = xmax;
6901 graphdata->maxY = ymax;
6902
6903 return;
6904 }
6905
6906
6907
6908
6909 /* @func ajGraphdataSetSubtitleC **********************************************
6910 **
6911 ** Set the subtitle.
6912 **
6913 ** @param [u] graphdata [AjPGraphdata] Graph structure to store info in.
6914 ** @param [r] txt [const char*] Sub Title
6915 ** @return [void]
6916 **
6917 ** @release 6.2.0
6918 ** @@
6919 ******************************************************************************/
6920
ajGraphdataSetSubtitleC(AjPGraphdata graphdata,const char * txt)6921 void ajGraphdataSetSubtitleC(AjPGraphdata graphdata, const char *txt)
6922 {
6923 ajStrAssignEmptyC(&graphdata->subtitle,txt);
6924
6925 return;
6926 }
6927
6928
6929
6930
6931 /* @func ajGraphdataSetSubtitleS **********************************************
6932 **
6933 ** Set the Subtitle.
6934 **
6935 ** @param [u] graphdata [AjPGraphdata] Graph structure to store info in.
6936 ** @param [r] str [const AjPStr] Sub Title
6937 ** @return [void]
6938 **
6939 ** @release 6.2.0
6940 ** @@
6941 ******************************************************************************/
6942
ajGraphdataSetSubtitleS(AjPGraphdata graphdata,const AjPStr str)6943 void ajGraphdataSetSubtitleS(AjPGraphdata graphdata, const AjPStr str)
6944 {
6945 ajStrAssignEmptyS(&graphdata->subtitle,str);
6946
6947 return;
6948 }
6949
6950
6951
6952
6953 /* @func ajGraphdataSetTitleC *************************************************
6954 **
6955 ** Set the title.
6956 **
6957 **
6958 ** @param [u] graphdata [AjPGraphdata] Graph structure to store info in.
6959 ** @param [r] txt [const char*] Title
6960 ** @return [void]
6961 **
6962 ** @release 6.2.0
6963 ** @@
6964 ******************************************************************************/
6965
ajGraphdataSetTitleC(AjPGraphdata graphdata,const char * txt)6966 void ajGraphdataSetTitleC(AjPGraphdata graphdata, const char *txt)
6967 {
6968 ajStrAssignEmptyC(&graphdata->title,txt);
6969
6970 return;
6971 }
6972
6973
6974
6975
6976 /* @func ajGraphdataSetTitleS *************************************************
6977 **
6978 ** Set the title.
6979 **
6980 **
6981 ** @param [u] graphdata [AjPGraphdata] Graph structure to store info in.
6982 ** @param [r] str [const AjPStr] Title
6983 ** @return [void]
6984 **
6985 ** @release 6.2.0
6986 ** @@
6987 ******************************************************************************/
6988
ajGraphdataSetTitleS(AjPGraphdata graphdata,const AjPStr str)6989 void ajGraphdataSetTitleS(AjPGraphdata graphdata, const AjPStr str)
6990 {
6991 ajStrAssignEmptyS(&graphdata->title,str);
6992
6993 return;
6994 }
6995
6996
6997
6998
6999 /* @func ajGraphdataSetTruescale **********************************************
7000 **
7001 ** Set the scale max and min of the data points you wish to display.
7002 **
7003 ** @param [u] graphdata [AjPGraphdata] multiple graph structure.
7004 ** @param [r] xmin [float] true x min.
7005 ** @param [r] xmax [float] true x max.
7006 ** @param [r] ymin [float] true y min.
7007 ** @param [r] ymax [float] true y max.
7008 ** @return [void]
7009 **
7010 ** @release 6.2.0
7011 ** @@
7012 ******************************************************************************/
7013
ajGraphdataSetTruescale(AjPGraphdata graphdata,float xmin,float xmax,float ymin,float ymax)7014 void ajGraphdataSetTruescale(AjPGraphdata graphdata, float xmin, float xmax,
7015 float ymin, float ymax)
7016 {
7017 graphdata->tminX = xmin;
7018 graphdata->tminY = ymin;
7019 graphdata->tmaxX = xmax;
7020 graphdata->tmaxY = ymax;
7021
7022 if(graphdata->tminX == graphdata->tmaxX)
7023 {
7024 if(!graphdata->tminX)
7025 {
7026 graphdata->tmaxX = 0.5;
7027 }
7028 else if (graphdata->tminX > 0)
7029 {
7030 graphdata->tmaxX *= 1.1F;
7031 graphdata->tminX /= 1.1F;
7032 }
7033 else
7034 {
7035 graphdata->tmaxX /= 1.1F;
7036 graphdata->tminX *= 1.1F;
7037 }
7038
7039 }
7040
7041 if(graphdata->tminY == graphdata->tmaxY)
7042 {
7043 if(!graphdata->tminY)
7044 {
7045 graphdata->tmaxY = 0.5;
7046 }
7047 else if (graphdata->tminY > 0)
7048 {
7049 graphdata->tmaxY *= 1.1F;
7050 graphdata->tminY /= 1.1F;
7051 }
7052 else
7053 {
7054 graphdata->tmaxY /= 1.1F;
7055 graphdata->tminY *= 1.1F;
7056 }
7057
7058 }
7059
7060 graphdata->truescale = ajTrue;
7061
7062 return;
7063 }
7064
7065
7066
7067
7068 /* @func ajGraphdataSetTypeC **************************************************
7069 **
7070 ** Set the type of the graph for data output.
7071 **
7072 ** @param [u] graphdata [AjPGraphdata] multiple graph structure.
7073 ** @param [r] txt [const char*] Type e.g. "2D Plot", "Histogram".
7074 ** @return [void]
7075 **
7076 ** @release 6.2.0
7077 ** @@
7078 ******************************************************************************/
7079
ajGraphdataSetTypeC(AjPGraphdata graphdata,const char * txt)7080 void ajGraphdataSetTypeC(AjPGraphdata graphdata,const char* txt)
7081 {
7082 ajStrAssignC(&graphdata->gtype,txt);
7083
7084 return;
7085 }
7086
7087
7088
7089
7090 /* @func ajGraphdataSetTypeS **************************************************
7091 **
7092 ** Set the type of the graph for data output.
7093 **
7094 ** @param [u] graphdata [AjPGraphdata] multiple graph structure.
7095 ** @param [r] str [const AjPStr] Type e.g. "2D Plot", "Histogram".
7096 ** @return [void]
7097 **
7098 ** @release 6.2.0
7099 ** @@
7100 ******************************************************************************/
7101
ajGraphdataSetTypeS(AjPGraphdata graphdata,const AjPStr str)7102 void ajGraphdataSetTypeS(AjPGraphdata graphdata,const AjPStr str)
7103 {
7104 ajStrAssignS(&graphdata->gtype,str);
7105
7106 return;
7107 }
7108
7109
7110
7111
7112 /* @func ajGraphdataSetXlabelC ************************************************
7113 **
7114 ** Set the title for the X axis.
7115 **
7116 ** @param [u] graphdata [AjPGraphdata] Graph structure to store info in.
7117 ** @param [r] txt[const char*] title for the X axis.
7118 ** @return [void]
7119 **
7120 ** @release 6.2.0
7121 ** @@
7122 ******************************************************************************/
7123
ajGraphdataSetXlabelC(AjPGraphdata graphdata,const char * txt)7124 void ajGraphdataSetXlabelC(AjPGraphdata graphdata, const char* txt)
7125 {
7126 ajStrAssignEmptyC(&graphdata->xaxis,txt);
7127
7128 return;
7129 }
7130
7131
7132
7133
7134 /* @func ajGraphdataSetXlabelS ************************************************
7135 **
7136 ** Set the title for the X axis.
7137 **
7138 ** @param [u] graphdata [AjPGraphdata] Graph structure to store info in.
7139 ** @param [r] str [const AjPStr] title for the X axis.
7140 ** @return [void]
7141 **
7142 ** @release 6.2.0
7143 ** @@
7144 ******************************************************************************/
7145
ajGraphdataSetXlabelS(AjPGraphdata graphdata,const AjPStr str)7146 void ajGraphdataSetXlabelS(AjPGraphdata graphdata, const AjPStr str)
7147 {
7148 ajStrAssignEmptyS(&graphdata->xaxis,str);
7149
7150 return;
7151 }
7152
7153
7154
7155
7156 /* @func ajGraphdataSetYlabelC ************************************************
7157 **
7158 ** Set the title for the Y axis.
7159 **
7160 ** @param [u] graphdata [AjPGraphdata] Graph structure to store info in.
7161 ** @param [r] txt [const char*] title for the Y axis.
7162 ** @return [void]
7163 **
7164 ** @release 6.2.0
7165 ** @@
7166 ******************************************************************************/
7167
ajGraphdataSetYlabelC(AjPGraphdata graphdata,const char * txt)7168 void ajGraphdataSetYlabelC(AjPGraphdata graphdata, const char* txt)
7169 {
7170 ajStrAssignEmptyC(&graphdata->yaxis,txt);
7171
7172 return;
7173 }
7174
7175
7176
7177
7178 /* @func ajGraphdataSetYlabelS ************************************************
7179 **
7180 ** Set the title for the Y axis.
7181 **
7182 ** @param [u] graphdata [AjPGraphdata] Graph structure to store info in.
7183 ** @param [r] str [const AjPStr] title for the Y axis.
7184 ** @return [void]
7185 **
7186 ** @release 6.2.0
7187 ** @@
7188 ******************************************************************************/
7189
ajGraphdataSetYlabelS(AjPGraphdata graphdata,const AjPStr str)7190 void ajGraphdataSetYlabelS(AjPGraphdata graphdata, const AjPStr str)
7191 {
7192 ajStrAssignEmptyS(&graphdata->yaxis, str);
7193
7194 return;
7195 }
7196
7197
7198
7199
7200 /* @funcstatic GraphInit ******************************************************
7201 **
7202 ** calls plinit.
7203 **
7204 ** @param [w] thys [AjPGraph] Graph object.
7205 ** @return [void]
7206 **
7207 ** @release 1.0.0
7208 ** @@
7209 ******************************************************************************/
7210
GraphInit(AjPGraph thys)7211 static void GraphInit(AjPGraph thys)
7212 {
7213 float fold;
7214
7215 if (thys)
7216 {
7217 if(!thys->ready)
7218 {
7219 #if GRAPH_DEBUG
7220 ajDebug("=g= plinit ()\n");
7221 #endif
7222
7223 plinit();
7224 }
7225
7226 thys->ready = ajTrue;
7227 }
7228
7229 fold = ajGraphicsSetCharscale(0.0);
7230 fold = ajGraphicsSetCharscale(fold);
7231
7232 return;
7233 }
7234
7235
7236
7237
7238 /* @funcstatic GraphSubPage ***************************************************
7239 **
7240 ** start new graph page.
7241 **
7242 ** @param [r] page [ajint] Page number
7243 **
7244 ** @return [void]
7245 **
7246 ** @release 1.0.0
7247 ** @@
7248 ******************************************************************************/
7249
GraphSubPage(ajint page)7250 static void GraphSubPage(ajint page)
7251 {
7252 #if GRAPH_DEBUG
7253 ajDebug("=g= pladv (%d) [page]\n", page);
7254 #endif
7255
7256 pladv(page);
7257
7258 return;
7259 }
7260
7261
7262
7263
7264 /* @funcstatic GraphWind ******************************************************
7265 **
7266 ** Calls plwind.
7267 **
7268 ** @param [r] xmin [float] Minimum x axis value
7269 ** @param [r] xmax [float] Maximum x axis value
7270 ** @param [r] ymin [float] Minimum y axis value
7271 ** @param [r] ymax [float] Maximum y axis value
7272 **
7273 ** @return [void]
7274 **
7275 ** @release 1.0.0
7276 ** @@
7277 ******************************************************************************/
7278
GraphWind(float xmin,float xmax,float ymin,float ymax)7279 static void GraphWind(float xmin, float xmax, float ymin, float ymax)
7280 {
7281 #if GRAPH_DEBUG
7282 ajDebug("=g= plwind (%.2f, %.2f, %.2f, %.2f) [xmin/max ymin/max]\n",
7283 xmin, xmax, ymin, ymax);
7284 #endif
7285
7286 plwind(xmin, xmax, ymin, ymax);
7287
7288 return;
7289 }
7290
7291
7292
7293
7294 /* @funcstatic GraphSetWin ****************************************************
7295 **
7296 ** Creates a window using the ranges.
7297 **
7298 ** @param [r] xmin [float] Minimum x axis value
7299 ** @param [r] xmax [float] Maximum x axis value
7300 ** @param [r] ymin [float] Minimum y axis value
7301 ** @param [r] ymax [float] Maximum y axis value
7302 **
7303 ** @return [void]
7304 **
7305 ** @release 1.0.0
7306 ** @@
7307 ******************************************************************************/
7308
GraphSetWin(float xmin,float xmax,float ymin,float ymax)7309 static void GraphSetWin(float xmin, float xmax, float ymin, float ymax)
7310 {
7311 ajDebug("GraphSetWin(%.3f, %.3f, %.3f, %.3f)\n",
7312 xmin, xmax, ymin, ymax);
7313
7314 if(graphData)
7315 {
7316 graphData->xmin = xmin;
7317 graphData->ymin = ymin;
7318 graphData->xmax = xmax;
7319 graphData->ymax = ymax;
7320
7321 if(graphData->Num == 1) /* else GraphDatafileNext does it */
7322 {
7323 ajFmtPrintF(graphData->File,
7324 "##Graphic\n##Screen x1 %f y1 %f x2 %f y2 %f\n",
7325 graphData->xmin, graphData->ymin,
7326 graphData->xmax, graphData->ymax);
7327 graphData->Lines++;
7328 graphData->Lines++;
7329 }
7330 }
7331 else
7332 {
7333 /*
7334 ** Use the whole screen. User may add boundaries by
7335 ** modifying xmin, xmax etc.
7336 */
7337 #if GRAPH_DEBUG
7338 ajDebug("=g= plvpor (0.0,1.0,0.0,1.0) [whole screen]\n");
7339 #endif
7340
7341 plvpor (0.0,1.0,0.0,1.0);
7342 GraphWind(xmin, xmax, ymin, ymax);
7343 }
7344
7345 return;
7346 }
7347
7348
7349
7350
7351 /* @funcstatic GraphSetWin2 ***************************************************
7352 **
7353 ** Creates a window using the ranges.
7354 **
7355 ** @param [r] xmin [float] Minimum x axis value
7356 ** @param [r] xmax [float] Maximum x axis value
7357 ** @param [r] ymin [float] Minimum y axis value
7358 ** @param [r] ymax [float] Maximum y axis value
7359 **
7360 ** @return [void]
7361 **
7362 ** @release 1.0.0
7363 ** @@
7364 ******************************************************************************/
7365
GraphSetWin2(float xmin,float xmax,float ymin,float ymax)7366 static void GraphSetWin2(float xmin, float xmax, float ymin, float ymax)
7367 {
7368 #if GRAPH_DEBUG
7369 ajDebug("=g= plvsta()\n");
7370 #endif
7371
7372 plvsta();
7373
7374 /* use the whole screen */
7375 GraphWind(xmin, xmax, ymin, ymax);
7376
7377 return;
7378 }
7379
7380
7381
7382
7383 /* @funcstatic GraphArray *****************************************************
7384 **
7385 ** Draw lines from the array of x and y values.
7386 **
7387 ** @param [r] numofpoints [ajuint] Number of data points
7388 ** @param [r] x [CONST float*] Array of x axis values
7389 ** @param [r] y [CONST float*] Array of y axis values
7390 **
7391 ** @return [void]
7392 **
7393 ** @release 1.0.0
7394 ** @@
7395 ******************************************************************************/
7396
GraphArray(ajuint numofpoints,float * x,float * y)7397 static void GraphArray(ajuint numofpoints, float *x, float *y)
7398 {
7399 ajuint i;
7400 float xlast;
7401 float ylast;
7402
7403 #if GRAPH_DEBUG
7404 if(numofpoints)
7405 ajDebug("=g= plline( %d, %.2f .. %.2f, %.2f .. %.2f) "
7406 "[num x..x y..y]\n",
7407 numofpoints, x[0], x[numofpoints-1], y[0], y[numofpoints-1] );
7408 else
7409 ajDebug("=g= plline( %d, <> .. <>, <> .. <>) [num x..x y..y]\n",
7410 numofpoints );
7411 #endif
7412
7413 if(graphData)
7414 {
7415 if(numofpoints < 2)
7416 return;
7417
7418 xlast = *x;
7419 ylast = *y;
7420
7421 for(i=1; i<numofpoints; i++)
7422 {
7423 ajGraphicsDrawposLine(xlast, ylast, x[i], y[i]);
7424 xlast = x[i];
7425 ylast = y[i];
7426 }
7427 }
7428 else
7429 plline(numofpoints, x,y);
7430
7431 return;
7432 }
7433
7434
7435
7436
7437 /* @funcstatic GraphArrayGaps *************************************************
7438 **
7439 ** Draw lines for an array of floats with gaps.
7440 ** Gaps are declared by having values of FLT_MIN.
7441 **
7442 ** @param [r] numofpoints [ajuint] Number of data points
7443 ** @param [r] x [CONST float*] Array of x axis values
7444 ** @param [r] y [CONST float*] Array of y axis values
7445 **
7446 ** @return [void]
7447 **
7448 ** @release 1.0.0
7449 ** @@
7450 ******************************************************************************/
7451
GraphArrayGaps(ajuint numofpoints,float * x,float * y)7452 static void GraphArrayGaps(ajuint numofpoints, float *x, float *y)
7453 {
7454 ajuint i;
7455 float *xx1,*xx2;
7456 float *yy1,*yy2;
7457
7458 xx1 = xx2 = x;
7459 yy1 = yy2 = y;
7460 xx2++;
7461 yy2++;
7462
7463 for(i=1;i<numofpoints;i++)
7464 {
7465 if(*xx2 != FLT_MIN && *xx1 != FLT_MIN &&
7466 *yy2 != FLT_MIN && *yy1 != FLT_MIN)
7467 {
7468 #if GRAPH_DEBUG
7469 ajDebug("=g= pljoin(%.2f, %.2f, %.2f, %.2f) [ xy xy]\n",
7470 *xx1, *yy1, *xx2, *yy2);
7471 #endif
7472
7473 pljoin(*xx1,*yy1,*xx2,*yy2);
7474 }
7475
7476 xx1++; yy1++;
7477 xx2++; yy2++;
7478 }
7479
7480 return;
7481 }
7482
7483
7484
7485
7486 /* @funcstatic GraphArrayGapsI ************************************************
7487 **
7488 ** Draw lines for an array of integers with gaps.
7489 ** Gaps are declared by having values of INT_MIN.
7490 **
7491 ** @param [r] numofpoints [ajuint] Number of data points
7492 ** @param [r] x [CONST ajint*] Array of x axis values
7493 ** @param [r] y [CONST ajint*] Array of y axis values
7494 **
7495 ** @return [void]
7496 **
7497 ** @release 1.0.0
7498 ** @@
7499 ******************************************************************************/
7500
GraphArrayGapsI(ajuint numofpoints,ajint * x,ajint * y)7501 static void GraphArrayGapsI(ajuint numofpoints, ajint *x, ajint *y)
7502 {
7503 ajuint i;
7504 ajint *xx1,*xx2;
7505 ajint *yy1,*yy2;
7506
7507 xx1 = xx2 = x;
7508 yy1 = yy2 = y;
7509 xx2++;
7510 yy2++;
7511
7512 for(i=0;i<numofpoints-1;i++)
7513 {
7514 if(*xx2 != INT_MIN && *xx1 != INT_MIN &&
7515 *yy2 != INT_MIN && *yy1 != INT_MIN)
7516 {
7517 #if GRAPH_DEBUG
7518 ajDebug("=g= pljoin(%.2f, %.2f, %.2f, %.2f) "
7519 "[ xy xy] [ajint xy xy]\n",
7520 (float)*xx1, (float)*xx2, (float)*yy1, (float)*yy2);
7521 #endif
7522
7523 pljoin((float)*xx1,(float)*yy1,(float)*xx2,(float)*yy2);
7524 }
7525
7526 xx1++; yy1++;
7527 xx2++; yy2++;
7528 }
7529
7530 return;
7531 }
7532
7533
7534
7535
7536 /* @funcstatic GraphFill ******************************************************
7537 **
7538 ** Polygon fill a set of points.
7539 **
7540 ** @param [r] numofpoints [ajuint] Number of data points
7541 ** @param [r] x [CONST float*] Array of x axis values
7542 ** @param [r] y [CONST float*] Array of y axis values
7543 **
7544 ** @return [void]
7545 **
7546 ** @release 1.0.0
7547 ** @@
7548 ******************************************************************************/
7549
GraphFill(ajuint numofpoints,float * x,float * y)7550 static void GraphFill(ajuint numofpoints, float *x, float *y)
7551 {
7552 #if GRAPH_DEBUG
7553 if(numofpoints)
7554 ajDebug("=g= plfill( %d, %.2f .. %.2f, %.2f .. %.2f) "
7555 "[num x..x y..y]\n",
7556 numofpoints, x[0], x[numofpoints-1], y[0], y[numofpoints-1] );
7557 else
7558 ajDebug("=g= plfill( %d, <> .. <>, <> .. <>) [num x..x y..y]\n",
7559 numofpoints );
7560 #endif
7561
7562 plfill(numofpoints, x, y);
7563
7564 return;
7565 }
7566
7567
7568
7569
7570 /* @funcstatic GraphPen *******************************************************
7571 **
7572 ** Change the actual colour of a pen.
7573 **
7574 ** @param [r] pen [ajint] Pen colour number
7575 ** @param [r] red [ajint] Red value (see PLPLOT)
7576 ** @param [r] green [ajint] Green value (see PLPLOT)
7577 ** @param [r] blue [ajint] Blue value (see PLPLOT)
7578 **
7579 ** @return [void]
7580 **
7581 ** @release 1.0.0
7582 ** @@
7583 ******************************************************************************/
7584
GraphPen(ajint pen,ajint red,ajint green,ajint blue)7585 static void GraphPen(ajint pen, ajint red, ajint green, ajint blue)
7586 {
7587 #if GRAPH_DEBUG
7588 ajDebug("=g= plscol0(%d, %d, %d, %d) [pen RGB]\n",
7589 pen, red, green, blue);
7590 #endif
7591
7592 plscol0(pen,red,green,blue);
7593
7594 return;
7595 }
7596
7597
7598
7599
7600 /* @funcstatic GraphClose *****************************************************
7601 **
7602 ** Close the graph with the plplot plend command.
7603 **
7604 ** @return [void]
7605 **
7606 ** @release 1.0.0
7607 ** @@
7608 ******************************************************************************/
7609
GraphClose(void)7610 static void GraphClose(void)
7611 {
7612 AjPList files = NULL;
7613 AjPStr tmpStr = NULL;
7614
7615 ajDebug("GraphClose\n");
7616
7617 if(graphData)
7618 files = graphData->List;
7619 else
7620 ajGraphicsGetOutfiles(&files);
7621
7622 while(ajListstrGetLength(files))
7623 {
7624 ajListstrPop(files, &tmpStr);
7625 ajDebug("GraphInfo file '%S'\n", tmpStr);
7626 ajFmtPrint("Created %S\n", tmpStr);
7627 ajStrDel(&tmpStr);
7628 }
7629
7630 if(graphData)
7631 {
7632 ajDebug("GraphClose deleting graphData '%F' '%S'.'%S'\n",
7633 graphData->File, graphData->FName, graphData->Ext);
7634 ajListstrFree(&graphData->List);
7635 ajFileClose(&graphData->File);
7636 ajStrDel(&graphData->FName);
7637 ajStrDel(&graphData->Ext);
7638 AJFREE(graphData);
7639
7640 #if GRAPH_DEBUG
7641 ajDebug("=g= plend()\n");
7642 #endif
7643
7644 plend();
7645 }
7646 else
7647 {
7648 ajListstrFree(&files);
7649
7650 #if GRAPH_DEBUG
7651 ajDebug("=g= plend()\n");
7652 #endif
7653
7654 plend();
7655 }
7656
7657 return;
7658 }
7659
7660
7661
7662
7663 /* @section Plotting **********************************************************
7664 **
7665 ** Plotting drawable objects
7666 **
7667 ** @fdata [AjPGraphdata]
7668 ** @fcategory use
7669 **
7670 ** @nam3rule Add Add an element to the plot data
7671 ** @nam3rule Addpos Add an element to the plot data at an (x,y) position
7672 ** @nam3rule Calc Calculate data points
7673 ** @nam4rule Line Add a line to be drawn when the graph is plotted.
7674 ** @nam4rule Rect Add a Rectangle to be drawn when the graph is plotted,
7675 ** @nam4rule Text Add Text to be drawn when the graph is plotted.
7676 ** @nam5rule TextScale Scaled text
7677 ** @nam4rule AddX Adds data points defined in two floating point arrays
7678 ** @nam5rule AddXY Adds (x,y) data points defined in two floating point arrays
7679 **
7680 ** @nam4rule CalcX data points defined by an x-axis start and increment
7681 ** @nam5rule CalcXY data points defined by an x-axis start and increment
7682 ** and a floating point array of y-axis values
7683 ** @suffix C Character data
7684 ** @suffix S String data
7685 **
7686 ** @argrule * graphdata [AjPGraphdata] Graph data object
7687 ** @argrule Addpos x [float] Start x position
7688 ** @argrule Addpos y [float] Start y position
7689 ** @argrule Line x2 [float] End x position
7690 ** @argrule Line y2 [float] End y position
7691 ** @argrule Rect x2 [float] End x position
7692 ** @argrule Rect y2 [float] End y position
7693 ** @argrule Addpos colour [ajint] Colour code (see PLPLOT)
7694 ** @argrule Rect fill [ajint] Fill code (see PLPLOT)
7695 ** @argrule Scale scale [float] Character scale (0.0 to use the default)
7696 ** @argrule C txt [const char*] Character text
7697 ** @argrule S str [const AjPStr] Character text
7698 ** @argrule AddXY xx [const float*] X coordinates
7699 ** @argrule AddXY yy [const float*] Y coordinates
7700 ** @argrule CalcXY numofpoints [ajuint] Number of points in array
7701 ** @argrule CalcXY start [float] Start position
7702 ** @argrule CalcXY incr [float] Increment
7703 ** @argrule CalcXY y [const float*] Y coordinates
7704 **
7705 ** @valrule * [void]
7706 **
7707 ******************************************************************************/
7708
7709
7710
7711
7712 /* @func ajGraphdataAddXY *****************************************************
7713 **
7714 ** Adds (x,y) data points defined in two floating point arrays
7715 **
7716 ** @param [u] graphdata [AjPGraphdata] Graph object
7717 ** @param [r] xx [const float*] X coordinates
7718 ** @param [r] yy [const float*] Y coordinates
7719 ** @return [void]
7720 **
7721 ** @release 6.2.0
7722 ** @@
7723 ******************************************************************************/
7724
ajGraphdataAddXY(AjPGraphdata graphdata,const float * xx,const float * yy)7725 void ajGraphdataAddXY(AjPGraphdata graphdata,
7726 const float *xx,const float *yy)
7727 {
7728 ajuint i;
7729
7730 for(i=0;i<graphdata->numofpoints; i++)
7731 {
7732 graphdata->x[i] = xx[i];
7733 graphdata->y[i] = yy[i];
7734 }
7735
7736 return;
7737 }
7738
7739
7740
7741
7742 /* @func ajGraphdataAddposLine ************************************************
7743 **
7744 ** Add a line to be drawn when the graph is plotted.
7745 **
7746 ** @param [u] graphdata [AjPGraphdata] Graph data object
7747 ** @param [r] x [float] Start x position
7748 ** @param [r] y [float] Start y position
7749 ** @param [r] x2 [float] End x position
7750 ** @param [r] y2 [float] End y position
7751 ** @param [r] colour [ajint] Colour code (see PLPLOT)
7752 **
7753 ** @return [void]
7754 **
7755 ** @release 6.2.0
7756 ** @@
7757 ******************************************************************************/
7758
ajGraphdataAddposLine(AjPGraphdata graphdata,float x,float y,float x2,float y2,ajint colour)7759 void ajGraphdataAddposLine(AjPGraphdata graphdata, float x, float y,
7760 float x2, float y2, ajint colour)
7761 {
7762 AjPGraphobj Obj;
7763
7764 if(!graphdata->Dataobj)
7765 {
7766 AJNEW((graphdata->Dataobj));
7767 Obj = graphdata->Dataobj;
7768 }
7769 else
7770 {
7771 Obj = graphdata->Dataobj;
7772
7773 while(Obj->next)
7774 Obj = Obj->next;
7775
7776 AJNEW(Obj->next);
7777 Obj = Obj->next;
7778 }
7779
7780 ++graphdata->numofobjects;
7781
7782 Obj->type = LINE;
7783 Obj->text = 0;
7784 Obj->xx1 = x;
7785 Obj->xx2 = x2;
7786 Obj->yy1 = y;
7787 Obj->yy2 = y2;
7788 Obj->colour = colour;
7789 Obj->next = 0;
7790
7791 return;
7792 }
7793
7794
7795
7796
7797 /* @func ajGraphdataAddposRect ************************************************
7798 **
7799 ** Add a Rectangle to be drawn when the graph is plotted, fill states whether
7800 ** the rectangle should be filled in.
7801 **
7802 ** @param [u] graphdata [AjPGraphdata] Graph data object
7803 ** @param [r] x [float] Start x position
7804 ** @param [r] y [float] Start y position
7805 ** @param [r] x2 [float] End x position
7806 ** @param [r] y2 [float] End y position
7807 ** @param [r] colour [ajint] Colour code (see PLPLOT)
7808 ** @param [r] fill [ajint] Fill code (see PLPLOT)
7809 **
7810 ** @return [void]
7811 **
7812 ** @release 6.2.0
7813 ** @@
7814 ******************************************************************************/
7815
ajGraphdataAddposRect(AjPGraphdata graphdata,float x,float y,float x2,float y2,ajint colour,ajint fill)7816 void ajGraphdataAddposRect(AjPGraphdata graphdata,
7817 float x, float y,
7818 float x2, float y2,
7819 ajint colour, ajint fill)
7820 {
7821 AjPGraphobj Obj;
7822
7823 if(!graphdata->Dataobj)
7824 {
7825 AJNEW((graphdata->Dataobj));
7826 Obj = graphdata->Dataobj;
7827 }
7828 else
7829 {
7830 Obj = graphdata->Dataobj;
7831
7832 while(Obj->next)
7833 Obj = Obj->next;
7834
7835 AJNEW(Obj->next);
7836 Obj = Obj->next;
7837 }
7838
7839 ++graphdata->numofobjects;
7840
7841
7842 if(fill)
7843 Obj->type = RECTANGLEFILL;
7844 else
7845 Obj->type = RECTANGLE;
7846
7847 Obj->text = 0;
7848 Obj->xx1 = x;
7849 Obj->xx2 = x2;
7850 Obj->yy1 = y;
7851 Obj->yy2 = y2;
7852 Obj->colour = colour;
7853 Obj->next = 0;
7854
7855 return;
7856 }
7857
7858
7859
7860
7861 /* @func ajGraphdataAddposTextC ***********************************************
7862 **
7863 ** Add Text to be drawn when the graph is plotted.
7864 **
7865 ** @param [u] graphdata [AjPGraphdata] Graph data object
7866 ** @param [r] x [float] Start x position
7867 ** @param [r] y [float] Start y position
7868 ** @param [r] colour [ajint] Colour code (see PLPLOT)
7869 ** @param [r] txt [const char*] Text to add
7870 1**
7871 ** @return [void]
7872 **
7873 ** @release 6.2.0
7874 ** @@
7875 ******************************************************************************/
7876
ajGraphdataAddposTextC(AjPGraphdata graphdata,float x,float y,ajint colour,const char * txt)7877 void ajGraphdataAddposTextC(AjPGraphdata graphdata, float x, float y,
7878 ajint colour, const char *txt)
7879 {
7880 AjPGraphobj Obj;
7881
7882 if(!graphdata->Dataobj)
7883 {
7884 AJNEW((graphdata->Dataobj));
7885 Obj = graphdata->Dataobj;
7886 }
7887 else /* cycle through till NULL found */
7888 {
7889 Obj = graphdata->Dataobj;
7890
7891 while(Obj->next)
7892 Obj = Obj->next;
7893
7894 AJNEW(Obj->next);
7895 Obj = Obj->next;
7896 }
7897
7898 ++graphdata->numofobjects;
7899
7900
7901 Obj->type = TEXT;
7902 Obj->text = 0;
7903 ajStrAssignEmptyC(&Obj->text,txt);
7904 Obj->xx1 = x;
7905 Obj->xx2 = 0.0;
7906 Obj->yy1 = y;
7907 Obj->yy2 = 0.0;
7908 Obj->colour = colour;
7909 Obj->scale = 0.0;
7910 Obj->next = 0;
7911
7912 return;
7913 }
7914
7915
7916
7917
7918 /* @func ajGraphdataAddposTextS ***********************************************
7919 **
7920 ** Add Text to be drawn when the graph is plotted.
7921 **
7922 ** @param [u] graphdata [AjPGraphdata] Graph data object
7923 ** @param [r] x [float] Start x position
7924 ** @param [r] y [float] Start y position
7925 ** @param [r] colour [ajint] Colour code (see PLPLOT)
7926 ** @param [r] str [const AjPStr] Text to add
7927 **
7928 ** @return [void]
7929 **
7930 ** @release 6.2.0
7931 ** @@
7932 ******************************************************************************/
7933
ajGraphdataAddposTextS(AjPGraphdata graphdata,float x,float y,ajint colour,const AjPStr str)7934 void ajGraphdataAddposTextS(AjPGraphdata graphdata, float x, float y,
7935 ajint colour, const AjPStr str)
7936 {
7937 AjPGraphobj Obj;
7938
7939 if(!graphdata->Dataobj)
7940 {
7941 AJNEW((graphdata->Dataobj));
7942 Obj = graphdata->Dataobj;
7943 }
7944 else /* cycle through till NULL found */
7945 {
7946 Obj = graphdata->Dataobj;
7947
7948 while(Obj->next)
7949 Obj = Obj->next;
7950
7951 AJNEW(Obj->next);
7952 Obj = Obj->next;
7953 }
7954
7955 ++graphdata->numofobjects;
7956
7957
7958 Obj->type = TEXT;
7959 Obj->text = 0;
7960 ajStrAssignEmptyS(&Obj->text,str);
7961 Obj->xx1 = x;
7962 Obj->xx2 = 0.0;
7963 Obj->yy1 = y;
7964 Obj->yy2 = 0.0;
7965 Obj->colour = colour;
7966 Obj->scale = 0.0;
7967 Obj->next = 0;
7968
7969 return;
7970 }
7971
7972
7973
7974
7975 /* @func ajGraphdataAddposTextScaleC ******************************************
7976 **
7977 ** Add Text to be drawn when the graph is plotted.
7978 **
7979 ** @param [u] graphdata [AjPGraphdata] Graph data object
7980 ** @param [r] x [float] Start x position
7981 ** @param [r] y [float] Start y position
7982 ** @param [r] colour [ajint] Colour code (see PLPLOT)
7983 ** @param [r] scale [float] Character scale (0.0 to use the default)
7984 ** @param [r] txt [const char*] Text to add
7985 **
7986 ** @return [void]
7987 **
7988 ** @release 6.2.0
7989 ** @@
7990 ******************************************************************************/
7991
ajGraphdataAddposTextScaleC(AjPGraphdata graphdata,float x,float y,ajint colour,float scale,const char * txt)7992 void ajGraphdataAddposTextScaleC(AjPGraphdata graphdata,
7993 float x, float y,
7994 ajint colour, float scale, const char *txt)
7995 {
7996 AjPGraphobj Obj;
7997
7998 if(!graphdata->Dataobj)
7999 {
8000 AJNEW((graphdata->Dataobj));
8001 Obj = graphdata->Dataobj;
8002 }
8003 else /* cycle through till NULL found */
8004 {
8005 Obj = graphdata->Dataobj;
8006
8007 while(Obj->next)
8008 Obj = Obj->next;
8009
8010 AJNEW(Obj->next);
8011 Obj = Obj->next;
8012 }
8013
8014 ++graphdata->numofobjects;
8015
8016
8017 Obj->type = TEXT;
8018 Obj->text = 0;
8019 ajStrAssignEmptyC(&Obj->text,txt);
8020 Obj->xx1 = x;
8021 Obj->xx2 = 0.0;
8022 Obj->yy1 = y;
8023 Obj->yy2 = 0.0;
8024 Obj->colour = colour;
8025 Obj->scale = scale;
8026 Obj->next = 0;
8027
8028 return;
8029 }
8030
8031
8032
8033
8034 /* @func ajGraphdataAddposTextScaleS ******************************************
8035 **
8036 ** Add Text to be drawn when the graph is plotted.
8037 **
8038 ** @param [u] graphdata [AjPGraphdata] Graph data object
8039 ** @param [r] x [float] Start x position
8040 ** @param [r] y [float] Start y position
8041 ** @param [r] colour [ajint] Colour code (see PLPLOT)
8042 ** @param [r] scale [float] Character scale (0.0 to use the default)
8043 ** @param [r] str [const AjPStr] Text to add
8044 **
8045 ** @return [void]
8046 **
8047 ** @release 6.2.0
8048 ** @@
8049 ******************************************************************************/
8050
ajGraphdataAddposTextScaleS(AjPGraphdata graphdata,float x,float y,ajint colour,float scale,const AjPStr str)8051 void ajGraphdataAddposTextScaleS(AjPGraphdata graphdata,
8052 float x, float y,
8053 ajint colour, float scale, const AjPStr str)
8054 {
8055 AjPGraphobj Obj;
8056
8057 if(!graphdata->Dataobj)
8058 {
8059 AJNEW((graphdata->Dataobj));
8060 Obj = graphdata->Dataobj;
8061 }
8062 else /* cycle through till NULL found */
8063 {
8064 Obj = graphdata->Dataobj;
8065
8066 while(Obj->next)
8067 Obj = Obj->next;
8068
8069 AJNEW(Obj->next);
8070 Obj = Obj->next;
8071 }
8072
8073 ++graphdata->numofobjects;
8074
8075
8076 Obj->type = TEXT;
8077 Obj->text = 0;
8078 ajStrAssignEmptyS(&Obj->text,str);
8079 Obj->xx1 = x;
8080 Obj->xx2 = 0.0;
8081 Obj->yy1 = y;
8082 Obj->yy2 = 0.0;
8083 Obj->colour = colour;
8084 Obj->scale = scale;
8085 Obj->next = 0;
8086
8087 return;
8088 }
8089
8090
8091
8092
8093 /* @func ajGraphdataCalcXY ****************************************************
8094 **
8095 ** Adds (x,y) data points defined by an x-axis start and increment
8096 ** and a floating point array of y-axis values.
8097 **
8098 ** @param [u] graphdata [AjPGraphdata] Graph object
8099 ** @param [r] numofpoints [ajuint] Number of points in array
8100 ** @param [r] start [float] Start position
8101 ** @param [r] incr [float] Increment
8102 ** @param [r] y [const float*] Y coordinates
8103 ** @return [void]
8104 **
8105 ** @release 6.2.0
8106 ** @@
8107 ******************************************************************************/
8108
ajGraphdataCalcXY(AjPGraphdata graphdata,ajuint numofpoints,float start,float incr,const float * y)8109 void ajGraphdataCalcXY(AjPGraphdata graphdata, ajuint numofpoints,
8110 float start, float incr, const float* y)
8111 {
8112 ajuint i;
8113 PLFLT x = 0.0;
8114
8115 if(!graphdata->xcalc)
8116 AJFREE(graphdata->x);
8117
8118 if(!graphdata->ycalc)
8119 AJFREE(graphdata->y);
8120
8121 graphdata->xcalc = ajFalse; /* i.e. OK to delete at the end as it */
8122 graphdata->ycalc = ajFalse; /* is our own copy */
8123
8124 AJCNEW(graphdata->x, numofpoints);
8125 AJCNEW(graphdata->y, numofpoints);
8126
8127 for(i=0;i<numofpoints; i++)
8128 {
8129 graphdata->x[i] = (start+x);
8130 graphdata->y[i] = y[i];
8131 x += incr;
8132 }
8133
8134 graphdata->numofpoints = numofpoints;
8135
8136 return;
8137 }
8138
8139
8140
8141
8142 /* @funcstatic GraphdataInit **************************************************
8143 **
8144 ** Initialise the contents of a graph object
8145 **
8146 ** @param [w] graphdata [AjPGraphdata] Graph structure to store info in.
8147 ** @return [void]
8148 **
8149 ** @release 6.2.0
8150 ** @@
8151 ******************************************************************************/
8152
GraphdataInit(AjPGraphdata graphdata)8153 static void GraphdataInit(AjPGraphdata graphdata)
8154 {
8155 ajDebug("GraphdataInit title: %x subtitle: %x xaxis: %x yaxis: %x\n",
8156 graphdata->title, graphdata->subtitle,
8157 graphdata->xaxis, graphdata->yaxis);
8158
8159 graphdata->x = NULL;
8160 graphdata->y = NULL;
8161 graphdata->xcalc = ajTrue;
8162 graphdata->ycalc = ajTrue;
8163 ajStrAssignEmptyC(&graphdata->title,"");
8164 ajStrAssignEmptyC(&graphdata->subtitle,"");
8165 ajStrAssignEmptyC(&graphdata->xaxis,"");
8166 ajStrAssignEmptyC(&graphdata->yaxis,"");
8167 ajStrAssignEmptyC(&graphdata->gtype,"");
8168 graphdata->minX = graphdata->maxX = 0;
8169 graphdata->minY = graphdata->maxY = 0;
8170 graphdata->lineType = 1;
8171 graphdata->colour = BLACK;
8172 graphdata->Dataobj = 0;
8173
8174 return;
8175 }
8176
8177
8178
8179
8180 /* @section Debugging **********************************************************
8181 **
8182 ** Tracing the internal values of a graph data object
8183 **
8184 ** @fdata [AjPGraphdata]
8185 ** @fcategory use
8186 **
8187 ** @nam3rule Trace
8188 **
8189 ** @argrule * thys [const AjPGraphdata] Graphdata object
8190 **
8191 ** @valrule * [void]
8192 **
8193 ******************************************************************************/
8194
8195
8196
8197
8198 /* @func ajGraphdataTrace *****************************************************
8199 **
8200 ** Writes debug messages to trace the contents of a graphdata object.
8201 **
8202 ** @param [r] thys [const AjPGraphdata] Graphdata object
8203 ** @return [void]
8204 **
8205 ** @release 6.2.0
8206 ** @@
8207 ******************************************************************************/
8208
ajGraphdataTrace(const AjPGraphdata thys)8209 void ajGraphdataTrace(const AjPGraphdata thys)
8210 {
8211 ajint i = 0;
8212 AjPGraphobj obj;
8213
8214 ajDebug("GraphData trace\n");
8215 ajDebug("\n(a) True booleans\n");
8216
8217 if(thys->xcalc)
8218 ajDebug("xcalc %B\n", thys->xcalc);
8219
8220 if(thys->ycalc)
8221 ajDebug("ycalc %B\n", thys->ycalc);
8222
8223 ajDebug("\n(b) Strings with values\n");
8224
8225 ajDebug("Title '%S'\n", thys->title);
8226 ajDebug("Subtitle '%S'\n", thys->subtitle);
8227 ajDebug("Xaxis '%S'\n", thys->xaxis);
8228 ajDebug("Yaxis '%S'\n", thys->yaxis);
8229 ajDebug("gtype '%S'\n", thys->gtype);
8230
8231 ajDebug("\n(c) Other values\n");
8232 ajDebug("numofpoints %d\n", thys->numofpoints);
8233 ajDebug("numofobjects %d\n", thys->numofobjects);
8234 ajDebug("minX %7.3f maxX %7.3f\n", thys->minX, thys->maxX);
8235 ajDebug("minY %7.3f maxY %7.3f\n", thys->minY, thys->maxY);
8236 ajDebug("tminX %7.3f tmaxX %7.3f\n", thys->tminX, thys->tmaxX);
8237 ajDebug("tminY %7.3f tmaxY %7.3f\n", thys->tminY, thys->tmaxY);
8238 ajDebug("colour %d\n", thys->colour);
8239 ajDebug("lineType %d\n", thys->lineType);
8240
8241 ajDebug("obj list: %x\n", thys->Dataobj);
8242
8243 if(thys->Dataobj)
8244 {
8245 obj=thys->Dataobj;
8246
8247 while(obj->next)
8248 {
8249 i++;
8250 obj = obj->next;
8251 }
8252 }
8253
8254 ajDebug("obj list length: %d/%d\n",
8255 i, thys->numofobjects);
8256
8257 return;
8258 }
8259
8260
8261
8262
8263 /******************************************************************************
8264 PLPLOT CALLS *END*
8265 ******************************************************************************/
8266
8267
8268
8269
8270 /* @datasection [none] Reporting internals ************************************
8271 **
8272 ** Reporting internal values for general graphs
8273 **
8274 ** @nam2rule Graphics
8275 **
8276 ******************************************************************************/
8277
8278
8279
8280
8281 /* @section Reporting internals ***********************************************
8282 **
8283 ** @fdata [none]
8284 ** @fcategory output
8285 **
8286 ** @nam3rule Dump Dump to standard error
8287 ** @nam3rule Get Get internal information
8288 ** @nam3rule List Save as a list object
8289 ** @nam3rule Print to an output file
8290 ** @nam4rule PrintType Print available device types
8291 ** @nam4rule Devices List of valid device names using AJAX names
8292 ** @nam4rule GetOutfiles Get output file names
8293 **
8294 ** @argrule Outfiles files [AjPList*] List of graph files
8295 ** @argrule ListDevices list [AjPList] List to write device names to.
8296 ** @argrule Print outf [AjPFile] Output file
8297 ** @argrule Type full [AjBool] Full report (usually ajFalse)
8298 **
8299 ** @valrule * [void]
8300 ** @valrule *Outfiles [ajuint]
8301 **
8302 ******************************************************************************/
8303
8304
8305
8306
8307 /* @func ajGraphicsDumpDevices ************************************************
8308 **
8309 ** Dump device options for a graph object
8310 **
8311 ** @return [void]
8312 **
8313 ** @release 6.2.0
8314 ** @@
8315 ******************************************************************************/
8316
ajGraphicsDumpDevices(void)8317 void ajGraphicsDumpDevices(void)
8318 {
8319 ajint i;
8320 ajint j;
8321 AjPStr aliases = NULL;
8322
8323 ajUserDumpC("Devices allowed (with alternative names) are:-");
8324
8325 for(i=0;graphType[i].Name;i++)
8326 {
8327 if(!graphType[i].GOpen)
8328 continue;
8329
8330 if(!graphType[i].Alias)
8331 {
8332 ajStrAssignClear(&aliases);
8333
8334 for(j=0;graphType[j].Name;j++)
8335 {
8336 if(graphType[j].Alias &&
8337 ajCharMatchC(graphType[i].Device, graphType[j].Device))
8338 {
8339 if(ajStrGetLen(aliases))
8340 ajStrAppendC(&aliases, ", ");
8341 ajStrAppendC(&aliases, graphType[j].Name);
8342 }
8343 }
8344
8345 if(ajStrGetLen(aliases))
8346 ajUser("%s (%S)",graphType[i].Name, aliases);
8347 else
8348 ajUserDumpC(graphType[i].Name);
8349 }
8350 }
8351
8352 ajStrDel(&aliases);
8353
8354 return;
8355 }
8356
8357
8358
8359
8360 /* @func ajGraphicsGetOutfiles ************************************************
8361 **
8362 ** Information on files created for graph output
8363 **
8364 ** @param [w] files [AjPList*] List of graph files
8365 ** @return [ajuint] Number of files (will match length of list)
8366 **
8367 ** @release 6.2.0
8368 ** @@
8369 ******************************************************************************/
8370
ajGraphicsGetOutfiles(AjPList * files)8371 ajuint ajGraphicsGetOutfiles(AjPList* files)
8372 {
8373 ajint i= -1;
8374 ajint j;
8375 AjPStr tmpStr = NULL;
8376
8377 PLINT family = 0;
8378 PLINT filenum = 0;
8379 PLINT bmax = 0;
8380 char filename[1024];
8381
8382 plgfam(&family, &filenum, &bmax);
8383
8384 if(filenum)
8385 i = filenum;
8386 else
8387 i = -1;
8388
8389 ajDebug("ajGraphicsGetOutfiles i:%d\n", i);
8390
8391 *files = ajListstrNew();
8392
8393 ajDebug("ajGraphicsGetOutfiles new list\n");
8394
8395 if(!i)
8396 return 0;
8397
8398 if(i < 0) /* single filename - or none */
8399 {
8400 plgfnam(filename);
8401 if(!*filename)
8402 return 0;
8403 ajStrAssignC(&tmpStr, filename);
8404 ajListstrPushAppend(*files, tmpStr);
8405 tmpStr=NULL;
8406 return 1;
8407 }
8408
8409 for(j=1; j<=i; j++) /* family: tmp has format, i is no. of files */
8410 {
8411 ajDebug("ajGraphicsGetOutfiles printing file %d\n", j);
8412 ajFmtPrintS(&tmpStr, "%S.%d.%S", graphBasename, j, graphExtension);
8413 ajDebug("ajGraphicsGetOutfiles storing file '%S'\n", tmpStr);
8414 ajListstrPushAppend(*files, tmpStr);
8415 tmpStr=NULL;
8416 }
8417
8418 return i;
8419 }
8420
8421
8422
8423
8424 /* @func ajGraphicsListDevices ************************************************
8425 **
8426 ** Store device names for a graph object in a list
8427 **
8428 ** @param [w] list [AjPList] List to write device names to.
8429 ** @return [void]
8430 **
8431 ** @release 6.2.0
8432 ** @@
8433 ******************************************************************************/
8434
ajGraphicsListDevices(AjPList list)8435 void ajGraphicsListDevices (AjPList list)
8436 {
8437 ajint i;
8438 AjPStr devicename;
8439
8440 for(i=0;graphType[i].Name;i++)
8441 {
8442 if(!graphType[i].GOpen)
8443 continue;
8444
8445 if(!graphType[i].Alias)
8446 {
8447 devicename = ajStrNewC(graphType[i].Name);
8448 ajListstrPushAppend(list, devicename);
8449 }
8450 }
8451
8452 return;
8453 }
8454
8455
8456
8457
8458 /* @func ajGraphicsPrintType **************************************************
8459 **
8460 ** Print graph types
8461 **
8462 ** @param [u] outf [AjPFile] Output file
8463 ** @param [r] full [AjBool] Full report (usually ajFalse)
8464 ** @return [void]
8465 **
8466 ** @release 6.2.0
8467 ** @@
8468 ******************************************************************************/
ajGraphicsPrintType(AjPFile outf,AjBool full)8469 void ajGraphicsPrintType(AjPFile outf, AjBool full)
8470 {
8471 GraphPType gt;
8472 ajint i;
8473
8474 ajFmtPrintF(outf, "\n");
8475 ajFmtPrintF(outf, "# Graphics devices\n");
8476 ajFmtPrintF(outf, "# Name Name\n");
8477 ajFmtPrintF(outf, "# Alias Alias name\n");
8478 ajFmtPrintF(outf, "# Device Device name\n");
8479 ajFmtPrintF(outf, "# Extension Filename extension (null if no file "
8480 "created)\n");
8481 ajFmtPrintF(outf, "# Description\n");
8482 ajFmtPrintF(outf, "# Name Alias Device Extension Description\n");
8483 ajFmtPrintF(outf, "GraphType {\n");
8484
8485 for(i=0; graphType[i].Name; i++)
8486 {
8487 gt = &graphType[i];
8488
8489 if(full || !gt->Alias)
8490 {
8491 ajFmtPrintF(outf, " %-10s", gt->Name);
8492 ajFmtPrintF(outf, " %5B", gt->Alias);
8493 ajFmtPrintF(outf, " %-10s", gt->Device);
8494 ajFmtPrintF(outf, " %-10s", gt->Ext);
8495 ajFmtPrintF(outf, " \"%s\"", gt->Desc);
8496 ajFmtPrintF(outf, "\n");
8497 }
8498 }
8499
8500 ajFmtPrintF(outf, "}\n");
8501
8502 return;
8503 }
8504
8505
8506
8507
8508 /* @datasection [none] Reporting internals ************************************
8509 **
8510 ** Reporting internal values for sequence-based XY graphs
8511 **
8512 ** @nam2rule Graphicsxy
8513 **
8514 ******************************************************************************/
8515
8516
8517
8518
8519 /* @section Reporting internals ***********************************************
8520 **
8521 ** @fdata [none]
8522 ** @fcategory output
8523 **
8524 ** @nam3rule Dump Dump to standard error
8525 ** @nam3rule List Save as a list object
8526 ** @nam4rule Devices List of valid device names using AJAX names
8527 **
8528 ** @argrule ListDevices list [AjPList] List to write device names to.
8529 **
8530 ** @valrule * [void]
8531 **
8532 ******************************************************************************/
8533
8534
8535
8536
8537 /* @func ajGraphicsxyDumpDevices **********************************************
8538 **
8539 ** Dump device options for a graph object
8540 **
8541 ** @return [void]
8542 **
8543 ** @release 6.2.0
8544 ** @@
8545 ******************************************************************************/
8546
ajGraphicsxyDumpDevices(void)8547 void ajGraphicsxyDumpDevices(void)
8548 {
8549 ajint i;
8550 ajint j;
8551 AjPStr aliases = NULL;
8552
8553 ajUserDumpC("Devices allowed (with alternative names) are:-");
8554
8555 for(i=0;graphType[i].Name;i++)
8556 {
8557 if(!graphType[i].XYDisplay)
8558 continue;
8559
8560 if(!graphType[i].Alias)
8561 {
8562 ajStrAssignClear(&aliases);
8563
8564 for(j=0;graphType[j].Name;j++)
8565 {
8566 if(graphType[j].Alias &&
8567 ajCharMatchC(graphType[i].Device, graphType[j].Device))
8568 {
8569 if(ajStrGetLen(aliases))
8570 ajStrAppendC(&aliases, ", ");
8571 ajStrAppendC(&aliases, graphType[j].Name);
8572 }
8573 }
8574
8575 if(ajStrGetLen(aliases))
8576 ajUser("%s (%S)",graphType[i].Name, aliases);
8577 else
8578 ajUserDumpC(graphType[i].Name);
8579 }
8580 }
8581
8582 ajStrDel(&aliases);
8583
8584 return;
8585 }
8586
8587
8588
8589
8590 /* @func ajGraphicsxyListDevices **********************************************
8591 **
8592 ** Store device names for a graph object in a list
8593 **
8594 ** @param [w] list [AjPList] List to write device names to.
8595 ** @return [void]
8596 **
8597 ** @release 6.2.0
8598 ** @@
8599 ******************************************************************************/
8600
ajGraphicsxyListDevices(AjPList list)8601 void ajGraphicsxyListDevices (AjPList list)
8602 {
8603 ajint i;
8604 AjPStr devicename;
8605
8606 for(i=0;graphType[i].Name;i++)
8607 {
8608 if(!graphType[i].XYDisplay)
8609 continue;
8610
8611 if(!graphType[i].Alias)
8612 {
8613 devicename = ajStrNewC(graphType[i].Name);
8614 ajListstrPushAppend(list, devicename);
8615 }
8616 }
8617
8618 return;
8619 }
8620
8621
8622
8623
8624 /* @funcstatic GraphCheckFlags ************************************************
8625 **
8626 ** Prints the flags defined by bits in the input integer value.
8627 **
8628 ** @param [r] flags [ajint] flag bits
8629 ** @return [void]
8630 **
8631 ** @release 1.0.0
8632 ** @@
8633 ******************************************************************************/
8634
GraphCheckFlags(ajint flags)8635 static void GraphCheckFlags(ajint flags)
8636 {
8637 ajFmtPrint("flag = %d\n",flags);
8638 if(flags & AJGRAPH_X_BOTTOM)
8639 ajFmtPrint("AJGRAPH_X_BOTTOM \n");
8640
8641 if(flags & AJGRAPH_Y_LEFT)
8642 ajFmtPrint("AJGRAPH_Y_LEFT \n");
8643
8644 if(flags & AJGRAPH_X_TOP)
8645 ajFmtPrint("AJGRAPH_X_TOP \n");
8646
8647 if(flags & AJGRAPH_Y_RIGHT)
8648 ajFmtPrint(" AJGRAPH_Y_RIGHT\n");
8649
8650 if(flags & AJGRAPH_X_TICK)
8651 ajFmtPrint("AJGRAPH_X_TICK \n");
8652
8653 if(flags & AJGRAPH_Y_TICK)
8654 ajFmtPrint("AJGRAPH_Y_TICK \n");
8655
8656 if(flags & AJGRAPH_X_LABEL)
8657 ajFmtPrint("AJGRAPH_X_LABEL \n");
8658
8659 if(flags & AJGRAPH_Y_LABEL)
8660 ajFmtPrint("AJGRAPH_Y_LABEL \n");
8661
8662 if(flags & AJGRAPH_TITLE)
8663 ajFmtPrint("AJGRAPH_TITLE \n");
8664
8665 if(flags & AJGRAPH_JOINPOINTS)
8666 ajFmtPrint("AJGRAPH_JOINPOINTS \n");
8667
8668 if(flags & AJGRAPH_OVERLAP)
8669 ajFmtPrint("AJGRAPH_OVERLAP \n");
8670
8671 if(flags & AJGRAPH_Y_NUMLABEL_LEFT)
8672 ajFmtPrint("AJGRAPH_Y_NUMLABEL_LEFT");
8673
8674 if(flags & AJGRAPH_Y_INVERT_TICK)
8675 ajFmtPrint("AJGRAPH_Y_INVERT_TICK");
8676
8677 if(flags & AJGRAPH_Y_GRID)
8678 ajFmtPrint("AJGRAPH_Y_GRID");
8679
8680 if(flags & AJGRAPH_X_NUMLABEL_ABOVE)
8681 ajFmtPrint("AJGRAPH_X_NUMLABEL_ABOVE");
8682
8683 if(flags & AJGRAPH_X_INVERT_TICK)
8684 ajFmtPrint("AJGRAPH_X_INVERT_TICK");
8685
8686 if(flags & AJGRAPH_X_GRID)
8687 ajFmtPrint("AJGRAPH_X_GRID");
8688
8689 return;
8690 }
8691
8692
8693
8694
8695 /* @funcstatic GraphCheckPoints ***********************************************
8696 **
8697 ** Prints a list of data points from two floating point arrays.
8698 **
8699 ** @param [r] n [ajint] Number of points to print
8700 ** @param [r] x [const PLFLT*] X coordinates
8701 ** @param [r] y [const PLFLT*] Y coordinates
8702 ** @return [void]
8703 **
8704 ** @release 1.0.0
8705 ** @@
8706 ******************************************************************************/
8707
GraphCheckPoints(ajint n,const PLFLT * x,const PLFLT * y)8708 static void GraphCheckPoints(ajint n, const PLFLT *x, const PLFLT *y)
8709 {
8710 ajint i;
8711
8712 for(i=0;i<n;i++)
8713 ajFmtPrint("%d %f %f\n",i,x[i],y[i]);
8714
8715 return;
8716 }
8717
8718
8719
8720
8721 /* @funcstatic GraphOpenFile **************************************************
8722 **
8723 ** A general routine for setting BaseName and extension in plplot.
8724 **
8725 ** @param [u] thys [AjPGraph] Multiple graph pointer.
8726 ** @param [r] ext [const char*] file extension
8727 ** @return [void]
8728 **
8729 ** @release 1.0.0
8730 ** @@
8731 ******************************************************************************/
8732
GraphOpenFile(AjPGraph thys,const char * ext)8733 static void GraphOpenFile(AjPGraph thys, const char *ext)
8734 {
8735 ajDebug("GraphOpenFile '%S'\n", thys->outputfile);
8736
8737 GraphSetName(thys, thys->outputfile,ext);
8738
8739 return;
8740 }
8741
8742
8743
8744
8745 /* @funcstatic GraphOpenData **************************************************
8746 **
8747 ** A general routine for setting BaseName and extension in plplot
8748 ** for -graph data output.
8749 **
8750 ** @param [u] thys [AjPGraph] Multiple graph pointer.
8751 ** @param [r] ext [const char*] file extension
8752 ** @return [void]
8753 **
8754 ** @release 2.8.0
8755 ** @@
8756 ******************************************************************************/
8757
GraphOpenData(AjPGraph thys,const char * ext)8758 static void GraphOpenData(AjPGraph thys, const char *ext)
8759 {
8760 ajDebug("GraphOpenData '%S' '%s\n", thys->outputfile, ext);
8761
8762 if(!graphData)
8763 {
8764 AJNEW0(graphData);
8765 graphData->List = ajListstrNew();
8766 }
8767
8768 GraphSetName(thys, thys->outputfile,ext);
8769 thys->isdata = ajTrue;
8770
8771 ajStrAssignS(&graphData->FName, thys->outputfile);
8772 ajStrAssignC(&graphData->Ext, ext);
8773
8774 GraphDatafileNext();
8775
8776 return;
8777 }
8778
8779
8780
8781
8782 /* @funcstatic GraphOpenSimple ************************************************
8783 **
8784 ** A general routine for drawing graphs. Does nothing.
8785 **
8786 ** This is called when initialised. Graph files are opened when
8787 ** each graph is written.
8788 **
8789 ** @param [u] thys [AjPGraph] Multiple graph pointer.
8790 ** @param [r] ext [const char*] file extension
8791 ** @return [void]
8792 **
8793 ** @release 4.0.0
8794 ** @@
8795 ******************************************************************************/
8796
GraphOpenSimple(AjPGraph thys,const char * ext)8797 static void GraphOpenSimple(AjPGraph thys, const char *ext )
8798 {
8799 (void) thys; /* make it used */
8800 (void) ext; /* make it used */
8801
8802 return;
8803 }
8804
8805
8806
8807
8808 #ifndef X_DISPLAY_MISSING
8809 /* @funcstatic GraphOpenXwin **************************************************
8810 **
8811 ** A general routine for drawing graphs to an xwin. Only creates the window.
8812 **
8813 ** @param [u] thys [AjPGraph] Multiple graph pointer.
8814 ** @param [r] ext [const char*] file extension
8815 ** @return [void]
8816 **
8817 ** @release 1.0.0
8818 ** @@
8819 ******************************************************************************/
8820
GraphOpenXwin(AjPGraph thys,const char * ext)8821 static void GraphOpenXwin(AjPGraph thys, const char *ext )
8822 {
8823 char* plargv[2] = {NULL,NULL};
8824 ajint plargc = 2;
8825 char argname[] = "-plwindow";
8826
8827 (void) thys; /* make it used */
8828 (void) ext; /* make it used */
8829
8830 plargv[0] = argname;
8831 plargv[1] = MAJSTRGETPTR(ajUtilGetProgram());
8832
8833 #if GRAPH_DEBUG
8834 ajDebug("=g= plparseopts('%s', '%s') ajUtilGetProgram\n",
8835 plargv[0], plargv[1]);
8836 #endif
8837
8838 plparseopts(&plargc, plargv,
8839 PL_PARSE_NOPROGRAM | PL_PARSE_QUIET |
8840 PL_PARSE_NODELETE | PL_PARSE_SKIP);
8841
8842 /*
8843 GraphLabelTitle(((thys->flags & AJGRAPH_TITLE) ?
8844 ajStrGetPtr(thys->title) : " "),
8845 ((thys->lags & AJGRAPH_SUBTITLE) ?
8846 ajStrGetPtr(thys->subtitle) : " "));
8847
8848 */
8849
8850 return;
8851 }
8852 #endif
8853
8854
8855
8856
8857 /* @funcstatic GraphxyDisplayToFile *******************************************
8858 **
8859 ** A general routine for drawing graphs to a file.
8860 **
8861 ** @param [u] thys [AjPGraph] Multiple graph pointer.
8862 ** @param [r] closeit [AjBool] Close file if true
8863 ** @param [r] ext [const char*] file extension
8864 ** @return [void]
8865 **
8866 ** @release 1.0.0
8867 ** @@
8868 ******************************************************************************/
8869
GraphxyDisplayToFile(AjPGraph thys,AjBool closeit,const char * ext)8870 static void GraphxyDisplayToFile(AjPGraph thys, AjBool closeit,
8871 const char *ext)
8872 {
8873 ajDebug("GraphxyDisplayToFile '%S'\n", thys->outputfile);
8874
8875 GraphSetName(thys, thys->outputfile,ext);
8876 ajGraphxySetRanges(thys);
8877 GraphxyGeneral(thys, closeit);
8878
8879 return;
8880 }
8881
8882
8883
8884
8885 /* @funcstatic GraphxyDisplayToDas ********************************************
8886 **
8887 ** A general routine for drawing graphs to DAS output file as points.
8888 **
8889 ** @param [u] thys [AjPGraph] Multiple graph pointer.
8890 ** @param [r] closeit [AjBool] Close file if true
8891 ** @param [r] ext [const char*] file extension
8892 ** @return [void]
8893 **
8894 ** @release 6.1.0
8895 ** @@
8896 ******************************************************************************/
8897
GraphxyDisplayToDas(AjPGraph thys,AjBool closeit,const char * ext)8898 static void GraphxyDisplayToDas(AjPGraph thys, AjBool closeit,
8899 const char *ext)
8900 {
8901 AjPFile outf = NULL;
8902 AjPGraphdata graphdata = NULL;
8903 AjPStr temp;
8904 AjPTime ajtime;
8905 ajuint i,j;
8906 float minxa = FLT_MAX;
8907 float minya = FLT_MAX;
8908 float maxxa = -FLT_MAX;
8909 float maxya = -FLT_MAX;
8910 ajint nfeat = 0;
8911 ajint istart;
8912 ajint iend;
8913
8914 /*
8915 ** Things to do:
8916 **
8917 ** Test this output
8918 ** Check how it handles multiple sequences
8919 ** Try to catch the sequence information
8920 **
8921 ** Do we want end=start or end=start+1
8922 **
8923 */
8924
8925 ajDebug("GraphxyDisplayToDas '%S' '%s' %d graphs\n",
8926 thys->outputfile, ext, thys->numofgraphs);
8927
8928 if(!graphData)
8929 {
8930 AJNEW0(graphData);
8931 graphData->List = ajListstrNew();
8932 }
8933
8934 /* Calculate maxima and minima */
8935 for(i=0;i<thys->numofgraphs;i++)
8936 {
8937 graphdata = (thys->graphs)[i];
8938 minxa = (minxa<graphdata->minX) ? minxa : graphdata->minX;
8939 minya = (minya<graphdata->minY) ? minya : graphdata->minY;
8940 maxxa = (maxxa>graphdata->maxX) ? maxxa : graphdata->maxX;
8941 maxya = (maxya>graphdata->maxY) ? maxya : graphdata->maxY;
8942 }
8943
8944 temp = ajFmtStr("%S%s",thys->outputfile,ext);
8945 outf = ajFileNewOutNameS(temp);
8946
8947 ajFmtPrintF(outf,"<DASGFF>\n");
8948 ajFmtPrintF(outf," <GFF version=\"1.0\" href=\"url\">\n");
8949 ajFmtPrintF(outf,"<!DOCTYPE DASGFF SYSTEM "
8950 "\"http://www.biodas.org/dtd/dasgff.dtd\">\n");
8951 ajFmtPrintF(outf,"<DASGFF>\n");
8952 ajFmtPrintF(outf," <GFF version=\"1.0\" href=\"url\">\n");
8953
8954 ajFmtPrintF(outf,"<!-- Title %S -->\n", thys->title);
8955 ajFmtPrintF(outf,"<!-- Graphs %d -->\n",thys->numofgraphs);
8956 ajFmtPrintF(outf,"<!-- Number %d -->\n",i+1);
8957 ajFmtPrintF(outf,"<!-- Points %d -->\n",graphdata->numofpoints);
8958
8959 for(i=0;i<thys->numofgraphs;i++)
8960 {
8961 graphdata = (thys->graphs)[i];
8962
8963 ajListstrPushAppend(graphData->List, temp);
8964 if(!outf)
8965 {
8966 ajErr("Could not open graph file %S\n",temp);
8967 return;
8968 }
8969 else
8970 ajDebug("Writing graph %d data to %S\n",i+1,temp);
8971
8972 if( ajStrGetLen(thys->title) <=1)
8973 {
8974 ajFmtPrintAppS(&thys->title,"%S",
8975 ajUtilGetProgram());
8976 }
8977 if( ajStrGetLen(thys->subtitle) <=1)
8978 {
8979 ajtime = ajTimeNewTodayFmt("report");
8980 ajFmtPrintAppS(&thys->subtitle,"%D",
8981 ajtime);
8982 ajTimeDel(&ajtime);
8983 }
8984
8985 istart = (ajint) graphdata->minX;
8986 if(istart < 1)
8987 istart = 1;
8988 iend = (ajint) graphdata->maxX;
8989 if(iend < istart)
8990 iend = istart;
8991 ajFmtPrintF(outf," <SEGMENT id=\"%s\" start=\"%d\" stop=\"%d\"\n",
8992 "graphid",
8993 istart,
8994 iend);
8995 ajFmtPrintF(outf,
8996 " version=\"%s\">\n",
8997 "0.0");
8998
8999
9000 /* Dump out the data points */
9001 for(j=0;j<graphdata->numofpoints;j++)
9002 {
9003 nfeat++;
9004 ajFmtPrintF(outf," <FEATURE id=\"%s.%d\">\n",
9005 "featid", nfeat);
9006 ajFmtPrintF(outf," <START>%d</START>\n",
9007 (ajint) graphdata->x[j]);
9008 ajFmtPrintF(outf," <END>%d</END>\n",
9009 (ajint) graphdata->x[j]);
9010 ajFmtPrintF(outf," <SCORE>%f</SCORE>\n",
9011 graphdata->y[j]);
9012 ajFmtPrintF(outf," </FEATURE>\n");
9013 }
9014
9015
9016 ajFmtPrintF(outf," <SEGMENT>\n");
9017 }
9018
9019 ajFmtPrintF(outf,
9020 " </GFF>\n");
9021 ajFmtPrintF(outf,
9022 "</DASGFF>\n");
9023
9024 ajFileClose(&outf);
9025 if(closeit)
9026 GraphClose();
9027
9028 return;
9029 }
9030
9031
9032
9033
9034 /* @funcstatic GraphxyDisplayToWiggle *****************************************
9035 **
9036 ** A general routine for drawing graphs to wiggle output file as points.
9037 **
9038 ** @param [u] thys [AjPGraph] Multiple graph pointer.
9039 ** @param [r] closeit [AjBool] Close file if true
9040 ** @param [r] ext [const char*] file extension
9041 ** @return [void]
9042 **
9043 ** @release 6.5.0
9044 ** @@
9045 ******************************************************************************/
9046
GraphxyDisplayToWiggle(AjPGraph thys,AjBool closeit,const char * ext)9047 static void GraphxyDisplayToWiggle(AjPGraph thys, AjBool closeit,
9048 const char *ext)
9049 {
9050 AjPFile outf = NULL;
9051 AjPGraphdata graphdata = NULL;
9052 AjPStr temp;
9053 AjPTime ajtime;
9054 ajuint i,j;
9055 float minxa = FLT_MAX;
9056 float minya = FLT_MAX;
9057 float maxxa = -FLT_MAX;
9058 float maxya = -FLT_MAX;
9059 ajint istart;
9060 ajint iend;
9061
9062 ajDebug("GraphxyDisplayToWiggle '%S' '%s' %d graphs\n",
9063 thys->outputfile, ext, thys->numofgraphs);
9064
9065 if(!graphData)
9066 {
9067 AJNEW0(graphData);
9068 graphData->List = ajListstrNew();
9069 }
9070
9071 /* Calculate maxima and minima */
9072 for(i=0;i<thys->numofgraphs;i++)
9073 {
9074 graphdata = (thys->graphs)[i];
9075 minxa = (minxa<graphdata->minX) ? minxa : graphdata->minX;
9076 minya = (minya<graphdata->minY) ? minya : graphdata->minY;
9077 maxxa = (maxxa>graphdata->maxX) ? maxxa : graphdata->maxX;
9078 maxya = (maxya>graphdata->maxY) ? maxya : graphdata->maxY;
9079 }
9080
9081 temp = ajFmtStr("%S%s",thys->outputfile,ext);
9082 outf = ajFileNewOutNameS(temp);
9083
9084 for(i=0;i<thys->numofgraphs;i++)
9085 {
9086 graphdata = (thys->graphs)[i];
9087
9088 /* open a file for dumping the data points */
9089 ajListstrPushAppend(graphData->List, temp);
9090 if(!outf)
9091 {
9092 ajErr("Could not open graph file %S\n",temp);
9093 return;
9094 }
9095 else
9096 ajDebug("Writing graph %d data to %S\n",i+1,temp);
9097
9098 if( ajStrGetLen(thys->title) <=1)
9099 {
9100 ajFmtPrintAppS(&thys->title,"%S",
9101 ajUtilGetProgram());
9102 }
9103 if( ajStrGetLen(thys->subtitle) <=1)
9104 {
9105 ajtime = ajTimeNewTodayFmt("report");
9106 ajFmtPrintAppS(&thys->subtitle,"%D",
9107 ajtime);
9108 ajTimeDel(&ajtime);
9109 }
9110
9111 istart = (ajint) graphdata->minX;
9112 if(istart < 1)
9113 istart = 1;
9114 iend = (ajint) graphdata->maxX;
9115 if(iend < istart)
9116 iend = istart;
9117
9118 /* Dump out the data points graphdata->x[j] graphdata->y[j] */
9119 for(j=0;j<graphdata->numofpoints;j++)
9120 {
9121 }
9122
9123 }
9124
9125 ajFileClose(&outf);
9126
9127 if(closeit)
9128 GraphClose();
9129
9130 return;
9131 }
9132
9133
9134
9135
9136 /* @funcstatic GraphxyDisplayToBedgraph ***************************************
9137 **
9138 ** A general routine for drawing graphs to bedgraph output file as points.
9139 **
9140 ** @param [u] thys [AjPGraph] Multiple graph pointer.
9141 ** @param [r] closeit [AjBool] Close file if true
9142 ** @param [r] ext [const char*] file extension
9143 ** @return [void]
9144 **
9145 ** @release 6.5.0
9146 ** @@
9147 ******************************************************************************/
9148
GraphxyDisplayToBedgraph(AjPGraph thys,AjBool closeit,const char * ext)9149 static void GraphxyDisplayToBedgraph(AjPGraph thys, AjBool closeit,
9150 const char *ext)
9151 {
9152 AjPFile outf = NULL;
9153 AjPGraphdata graphdata = NULL;
9154 AjPStr temp;
9155 AjPTime ajtime;
9156 ajuint i,j;
9157 float minxa = FLT_MAX;
9158 float minya = FLT_MAX;
9159 float maxxa = -FLT_MAX;
9160 float maxya = -FLT_MAX;
9161 ajint istart;
9162 ajint iend;
9163 ajint ipos;
9164
9165 ajDebug("GraphxyDisplayToBedgraph '%S' '%s' %d graphs\n",
9166 thys->outputfile, ext, thys->numofgraphs);
9167
9168 if(!graphData)
9169 {
9170 AJNEW0(graphData);
9171 graphData->List = ajListstrNew();
9172 }
9173
9174 /* Calculate maxima and minima */
9175 for(i=0;i<thys->numofgraphs;i++)
9176 {
9177 graphdata = (thys->graphs)[i];
9178 minxa = (minxa<graphdata->minX) ? minxa : graphdata->minX;
9179 minya = (minya<graphdata->minY) ? minya : graphdata->minY;
9180 maxxa = (maxxa>graphdata->maxX) ? maxxa : graphdata->maxX;
9181 maxya = (maxya>graphdata->maxY) ? maxya : graphdata->maxY;
9182 }
9183
9184 temp = ajFmtStr("%S%s",thys->outputfile,ext);
9185 outf = ajFileNewOutNameS(temp);
9186
9187 ajFmtPrintF(outf, "track type=bedGraph graphType=points\n");
9188 /* can also document:
9189 name trackLabel # default is "User Track"
9190 description centerlabel # default is "User Supplied Track"
9191 visibility full|dense|hide # default is hide (also values 2|1|0)
9192 color RRR,GGG,BBB # default is 255,255,255
9193 altColor RRR,GGG,BBB # default is 128,128,128
9194 priority N # default is 100
9195 autoScale on|off # default is on
9196 alwaysZero on|off # default is off
9197 gridDefault on|off # default is off
9198 maxHeightPixels max:default:min # default is 128:128:11
9199 graphType bar|points # default is bar
9200 viewLimits lower:upper # default is range found in data
9201 yLineMark real-value # default is 0.0
9202 yLineOnOff on|off # default is off
9203 windowingFunction maximum|mean|minimum # default is maximum
9204 smoothingWindow off|[2-16] # default is off
9205 */
9206
9207 for(i=0;i<thys->numofgraphs;i++)
9208 {
9209 graphdata = (thys->graphs)[i];
9210
9211 /* open a file for dumping the data points */
9212 ajListstrPushAppend(graphData->List, temp);
9213 if(!outf)
9214 {
9215 ajErr("Could not open graph file %S\n",temp);
9216 return;
9217 }
9218 else
9219 ajDebug("Writing graph %d data to %S\n",i+1,temp);
9220
9221 if( ajStrGetLen(thys->title) <=1)
9222 {
9223 ajFmtPrintAppS(&thys->title,"%S",
9224 ajUtilGetProgram());
9225 }
9226 if( ajStrGetLen(thys->subtitle) <=1)
9227 {
9228 ajtime = ajTimeNewTodayFmt("report");
9229 ajFmtPrintAppS(&thys->subtitle,"%D",
9230 ajtime);
9231 ajTimeDel(&ajtime);
9232 }
9233
9234 istart = (ajint) graphdata->minX;
9235 if(istart < 1)
9236 istart = 1;
9237 iend = (ajint) graphdata->maxX;
9238 if(iend < istart)
9239 iend = istart;
9240
9241 /* Dump out the data points graphdata->x[j] graphdata->y[j] */
9242 for(j=0;j<graphdata->numofpoints;j++)
9243 {
9244 ipos = ((int) graphdata->x[j]) - 1;
9245 if(ajStrGetLen(graphdata->dataname))
9246 ajFmtPrintF(outf, "%S %d %d %f\n",
9247 graphdata->dataname, ipos, ipos,
9248 graphdata->y[j]);
9249 else if(ajStrGetLen(thys->dataname))
9250 ajFmtPrintF(outf, "%S %d %d %f\n",
9251 thys->dataname, ipos, ipos,
9252 graphdata->y[j]);
9253 else
9254 ajFmtPrintF(outf, "%s %d %d %f\n",
9255 "unknown", ipos, ipos,
9256 graphdata->y[j]);
9257 }
9258
9259 }
9260
9261 ajFileClose(&outf);
9262
9263 if(closeit)
9264 GraphClose();
9265
9266 return;
9267 }
9268
9269
9270
9271
9272 /* @funcstatic GraphxyDisplayToData *******************************************
9273 **
9274 ** A general routine for drawing graphs to file as points.
9275 **
9276 ** @param [u] thys [AjPGraph] Multiple graph pointer.
9277 ** @param [r] closeit [AjBool] Close file if true
9278 ** @param [r] ext [const char*] file extension
9279 ** @return [void]
9280 **
9281 ** @release 1.0.0
9282 ** @@
9283 ******************************************************************************/
9284
GraphxyDisplayToData(AjPGraph thys,AjBool closeit,const char * ext)9285 static void GraphxyDisplayToData(AjPGraph thys, AjBool closeit,
9286 const char *ext)
9287 {
9288 AjPFile outf = NULL;
9289 AjPGraphdata graphdata = NULL;
9290 AjPGraphobj ptr = NULL;
9291 AjPStr temp;
9292 AjPTime ajtime;
9293 ajuint i,j;
9294 float minxa = FLT_MAX;
9295 float minya = FLT_MAX;
9296 float maxxa = -FLT_MAX;
9297 float maxya = -FLT_MAX;
9298 ajint type = 0;
9299
9300 ajDebug("GraphxyDisplayToData '%S' '%s' %d graphs\n",
9301 thys->outputfile, ext, thys->numofgraphs);
9302
9303 if(!graphData)
9304 {
9305 AJNEW0(graphData);
9306 graphData->List = ajListstrNew();
9307 }
9308
9309 /* Calculate maxima and minima */
9310 for(i=0;i<thys->numofgraphs;i++)
9311 {
9312 graphdata = (thys->graphs)[i];
9313 minxa = (minxa<graphdata->minX) ? minxa : graphdata->minX;
9314 minya = (minya<graphdata->minY) ? minya : graphdata->minY;
9315 maxxa = (maxxa>graphdata->maxX) ? maxxa : graphdata->maxX;
9316 maxya = (maxya>graphdata->maxY) ? maxya : graphdata->maxY;
9317 }
9318
9319 for(i=0;i<thys->numofgraphs;i++)
9320 {
9321 graphdata = (thys->graphs)[i];
9322
9323 /* open a file for dumping the data points */
9324 temp = ajFmtStr("%S%d%s",thys->outputfile,i+1,ext);
9325 outf = ajFileNewOutNameS(temp);
9326 ajListstrPushAppend(graphData->List, temp);
9327
9328 if(!outf)
9329 {
9330 ajErr("Could not open graph file %S\n",temp);
9331
9332 return;
9333 }
9334 else
9335 ajDebug("Writing graph %d data to %S\n",i+1,temp);
9336
9337 if( ajStrGetLen(thys->title) <=1)
9338 {
9339 ajFmtPrintAppS(&thys->title,"%S",
9340 ajUtilGetProgram());
9341 }
9342
9343 if( ajStrGetLen(thys->subtitle) <=1)
9344 {
9345 ajtime = ajTimeNewTodayFmt("report");
9346 ajFmtPrintAppS(&thys->subtitle,"%D",
9347 ajtime);
9348 ajTimeDel(&ajtime);
9349 }
9350
9351 ajFmtPrintF(outf,"##%S\n",graphdata->gtype);
9352 ajFmtPrintF(outf,"##Title %S\n",thys->title);
9353 ajFmtPrintF(outf,"##Graphs %d\n",thys->numofgraphs);
9354 ajFmtPrintF(outf,"##Number %d\n",i+1);
9355 ajFmtPrintF(outf,"##Points %d\n",graphdata->numofpoints);
9356
9357
9358 ajFmtPrintF(outf,"##XminA %f XmaxA %f YminA %f YmaxA %f\n",
9359 minxa,maxxa,minya,maxya);
9360 ajFmtPrintF(outf,"##Xmin %f Xmax %f Ymin %f Ymax %f\n",
9361 graphdata->tminX,graphdata->tmaxX,
9362 graphdata->tminY,graphdata->tmaxY);
9363 ajFmtPrintF(outf,"##ScaleXmin %f ScaleXmax %f ScaleYmin %f "
9364 "ScaleYmax %f\n",
9365 graphdata->minX,graphdata->maxX,
9366 graphdata->minY,graphdata->maxY);
9367
9368 ajFmtPrintF(outf,"##Maintitle %S\n",graphdata->title);
9369
9370 if(thys->numofgraphs == 1)
9371 {
9372 ajFmtPrintF(outf,"##Xtitle %S\n",thys->xaxis);
9373 ajFmtPrintF(outf,"##Ytitle %S\n",thys->yaxis);
9374 }
9375 else
9376 {
9377 if(graphdata->subtitle)
9378 ajFmtPrintF(outf,"##Subtitle %S\n",graphdata->subtitle);
9379 ajFmtPrintF(outf,"##Xtitle %S\n",graphdata->xaxis);
9380 ajFmtPrintF(outf,"##Ytitle %S\n",graphdata->yaxis);
9381 }
9382
9383 /* Dump out the data points */
9384 for(j=0;j<graphdata->numofpoints;j++)
9385 ajFmtPrintF(outf,"%f\t%f\n",graphdata->x[j],graphdata->y[j]);
9386
9387
9388 /* Now for the Data graph objects */
9389 ajFmtPrintF(outf,"##DataObjects\n##Number %d\n",
9390 graphdata->numofobjects);
9391
9392 if(graphdata->numofobjects)
9393 {
9394 ptr = graphdata->Dataobj;
9395
9396 for(j=0;j<graphdata->numofobjects;++j)
9397 {
9398 type = ptr->type;
9399
9400 if(type==LINE || type==RECTANGLE || type==RECTANGLEFILL)
9401 {
9402 if(type==LINE)
9403 ajFmtPrintF(outf,"Line ");
9404 else if(type==RECTANGLE)
9405 ajFmtPrintF(outf,"Rectangle ");
9406 else
9407 ajFmtPrintF(outf,"Filled Rectangle ");
9408 ajFmtPrintF(outf,"x1 %f y1 %f x2 %f y2 %f colour %d\n",
9409 ptr->xx1,ptr->yy1,
9410 ptr->xx2,ptr->yy2,ptr->colour);
9411 }
9412 else if(type==TEXT)
9413 {
9414 ajFmtPrintF(outf,"Textline ");
9415 ajFmtPrintF(outf,"x1 %f y1 %f x2 %f y2 %f colour %d "
9416 "size 1.0 %S\n",
9417 ptr->xx1,ptr->yy1,ptr->xx2,
9418 ptr->yy2,ptr->colour,
9419 ptr->text);
9420 }
9421
9422 ptr = ptr->next;
9423 }
9424 }
9425
9426
9427 /* Now for the Graph graph objects */
9428 ajFmtPrintF(outf,"##GraphObjects\n##Number %d\n",
9429 thys->numofobjects);
9430
9431 if(thys->numofobjects)
9432 {
9433 ptr = thys->Mainobj;
9434
9435 for(j=0;j<thys->numofobjects;++j)
9436 {
9437 type = ptr->type;
9438
9439 if(type==LINE || type==RECTANGLE || type==RECTANGLEFILL)
9440 {
9441 if(type==LINE)
9442 ajFmtPrintF(outf,"Line ");
9443 else if(type==RECTANGLE)
9444 ajFmtPrintF(outf,"Rectangle ");
9445 else
9446 ajFmtPrintF(outf,"Filled Rectangle ");
9447
9448 ajFmtPrintF(outf,"x1 %f y1 %f x2 %f y2 %f colour %d\n",
9449 ptr->xx1,ptr->yy1,
9450 ptr->xx2,ptr->yy2,ptr->colour);
9451 }
9452 else if(type==TEXT)
9453 {
9454 ajFmtPrintF(outf,"Textline ");
9455 ajFmtPrintF(outf,"x1 %f y1 %f x2 %f y2 %f colour %d "
9456 "size 1.0 %S\n",
9457 ptr->xx1,ptr->yy1,
9458 ptr->xx2,ptr->yy2,ptr->colour,
9459 ptr->text);
9460 }
9461
9462 ptr = ptr->next;
9463 }
9464 }
9465
9466
9467 ajFileClose(&outf);
9468 }
9469
9470 if(closeit)
9471 GraphClose();
9472
9473 return;
9474 }
9475
9476
9477
9478
9479 /* @funcstatic GraphxyDisplayXwin *********************************************
9480 **
9481 ** A general routine for drawing graphs to an xwin.
9482 **
9483 ** @param [u] thys [AjPGraph] Multiple graph pointer.
9484 ** @param [r] closeit [AjBool] Close file if true
9485 ** @param [r] ext [const char*] file extension
9486 ** @return [void]
9487 **
9488 ** @release 1.0.0
9489 ** @@
9490 ******************************************************************************/
9491
GraphxyDisplayXwin(AjPGraph thys,AjBool closeit,const char * ext)9492 static void GraphxyDisplayXwin(AjPGraph thys, AjBool closeit, const char *ext )
9493 {
9494 (void) ext; /* make it used */
9495
9496 ajGraphxySetRanges(thys);
9497 GraphxyGeneral(thys, closeit);
9498
9499 return;
9500 }
9501
9502
9503
9504
9505 /* @funcstatic GraphNewPlplot *************************************************
9506 **
9507 ** Populate a plplot structure to hold a general graph.
9508 **
9509 ** @param [w] graph [AjPGraph] multiple graph structure.
9510 ** @return [void]
9511 **
9512 ** @release 2.9.0
9513 ** @@
9514 ******************************************************************************/
9515
GraphNewPlplot(AjPGraph graph)9516 static void GraphNewPlplot(AjPGraph graph)
9517 {
9518 AJCNEW0(graph->graphs,1);
9519
9520 ajDebug("GraphNewPlplot\n");
9521
9522 graph->numofgraphs = 0;
9523 graph->numofgraphsmax = 1;
9524 graph->flags = GRAPH_XY;
9525 graph->minmaxcalc = 0;
9526 ajFmtPrintS(&graph->outputfile,"%S", ajUtilGetProgram());
9527
9528 return;
9529 }
9530
9531
9532
9533
9534 /* @funcstatic GraphxyNewPlplot ***********************************************
9535 **
9536 ** Create a structure to hold a number of graphs.
9537 **
9538 ** @param [w] thys [AjPGraph] Empty graph object
9539 ** @return [void]
9540 **
9541 ** @release 2.9.0
9542 ** @@
9543 ******************************************************************************/
9544
GraphxyNewPlplot(AjPGraph thys)9545 static void GraphxyNewPlplot(AjPGraph thys)
9546 {
9547 AJCNEW0(thys->graphs,thys->numsets);
9548
9549 ajDebug("GraphxyNewPlplot numsets: %d\n", thys->numsets);
9550
9551 thys->numofgraphs = 0;
9552 thys->numofgraphsmax = thys->numsets;
9553 thys->minX = thys->minY = FLT_MAX;
9554 thys->maxX = thys->maxY = -FLT_MAX;
9555 thys->flags = GRAPH_XY;
9556 thys->minmaxcalc = 0;
9557 thys->xstart = thys->xend = 0;
9558 thys->ystart = thys->yend = 0;
9559 thys->Mainobj = NULL;
9560 ajFmtPrintS(&thys->outputfile,"%S", ajUtilGetProgram());
9561
9562 return;
9563 }
9564
9565
9566
9567
9568 /* @funcstatic GraphxyGeneral *************************************************
9569 **
9570 ** A general routine for drawing graphs.
9571 **
9572 ** @param [u] thys [AjPGraph] Multiple graph pointer.
9573 ** @param [r] closeit [AjBool] Close at end if true.
9574 ** @return [void]
9575 **
9576 ** @release 1.0.0
9577 ** @@
9578 ******************************************************************************/
9579
GraphxyGeneral(AjPGraph thys,AjBool closeit)9580 static void GraphxyGeneral(AjPGraph thys, AjBool closeit)
9581 {
9582 AjPGraphdata graphdata;
9583 ajuint i;
9584 ajint old;
9585 ajint old2;
9586 AjPTime ajtime;
9587
9588 ajGraphicsSetDevice(thys);
9589
9590 ajDebug("GraphxyGeneral flags %x\n", thys->flags);
9591 ajDebug("... title '%S'\n", thys->title);
9592
9593 if(thys->flags & AJGRAPH_OVERLAP)
9594 {
9595 ajDebug("... AJGRAPH_OVERLAP\n");
9596 GraphColourBack();
9597 GraphInit(thys);
9598 GraphColourFore();
9599 /* GraphSubPage(0); Done in ajGraphicsplenv*/
9600
9601 if(thys->numofgraphs)
9602 {
9603 graphdata = (thys->graphs)[0];
9604 thys->xstart = graphdata->minX;
9605 thys->xend = graphdata->maxX;
9606 thys->ystart = graphdata->minY;
9607 thys->yend = graphdata->maxY;
9608 }
9609
9610 ajGraphicsPlenv(thys->xstart, thys->xend,
9611 thys->ystart, thys->yend,
9612 thys->flags);
9613
9614 if((thys->flags & AJGRAPH_TITLE) &&
9615 ajStrGetLen(thys->title) <=1)
9616 {
9617 ajtime = ajTimeNewToday();
9618 ajStrAppendC(&thys->title,
9619 ajFmtString("%S (%D)",
9620 ajUtilGetProgram(),
9621 ajtime));
9622 ajTimeDel(&ajtime);
9623 }
9624
9625 ajGraphicsSetLabelsS(((thys->flags & AJGRAPH_X_LABEL) ?
9626 thys->xaxis : NULL),
9627 ((thys->flags & AJGRAPH_Y_LABEL) ?
9628 thys->yaxis : NULL),
9629 ((thys->flags & AJGRAPH_TITLE) ?
9630 thys->title : NULL),
9631 (thys->flags & AJGRAPH_SUBTITLE) ?
9632 thys->subtitle : NULL);
9633
9634 for(i=0;i<thys->numofgraphs;i++)
9635 {
9636 graphdata = (thys->graphs)[i];
9637
9638 /* Draw the line through the data */
9639 old = ajGraphicsSetFgcolour(graphdata->colour);
9640
9641 if(thys->flags & AJGRAPH_CIRCLEPOINTS)
9642 ajGraphicsDrawsetSymbols(graphdata->numofpoints,
9643 (graphdata->x), (graphdata->y), 9);
9644
9645 old2 = ajGraphicsSetLinestyle(graphdata->lineType);
9646
9647 if(thys->flags & AJGRAPH_JOINPOINTS)
9648 {
9649 if(thys->flags & AJGRAPH_GAPS)
9650 GraphArrayGaps(graphdata->numofpoints,
9651 (graphdata->x),
9652 (graphdata->y));
9653 else
9654 GraphArray(graphdata->numofpoints,
9655 (graphdata->x), (graphdata->y));
9656 }
9657
9658 ajGraphicsSetLinestyle(old2);
9659 ajGraphicsSetFgcolour(old);
9660 }
9661
9662 GraphDraw(thys);
9663 }
9664 else
9665 {
9666 ajDebug("... else not AJGRAPH_OVERLAP\n");
9667 GraphColourBack();
9668 GraphInit(thys);
9669 GraphColourFore();
9670 GraphSubPage(0);
9671 GraphSetNumSubPage(thys->numofgraphs);
9672
9673 /* first do the main plot title */
9674 if((thys->flags & AJGRAPH_TITLE) &&
9675 ajStrGetLen(thys->title) <=1)
9676 {
9677 ajtime = ajTimeNewToday();
9678 ajStrAppendC(&thys->title,
9679 ajFmtString("%S (%D)",
9680 ajUtilGetProgram(),
9681 ajtime));
9682 ajTimeDel(&ajtime);
9683 }
9684
9685 for(i=0;i<thys->numofgraphs;i++)
9686 {
9687 graphdata = (thys->graphs)[i];
9688 ajGraphicsPlenv(graphdata->minX, graphdata->maxX,
9689 graphdata->minY, graphdata->maxY,
9690 thys->flags);
9691
9692 if(!ajStrGetLen(graphdata->title) &&
9693 (thys->flags & AJGRAPH_TITLE))
9694 ajStrAssignS(&graphdata->title, thys->title);
9695
9696 if(!ajStrGetLen(graphdata->subtitle) &&
9697 (thys->flags & AJGRAPH_SUBTITLE))
9698 ajStrAssignS(&graphdata->subtitle, thys->subtitle);
9699
9700 ajGraphicsSetLabelsS(((thys->flags & AJGRAPH_X_LABEL) ?
9701 graphdata->xaxis : NULL),
9702 ((thys->flags & AJGRAPH_Y_LABEL) ?
9703 graphdata->yaxis : NULL),
9704 ((thys->flags & AJGRAPH_TITLE) ?
9705 graphdata->title : NULL),
9706 (thys->flags & AJGRAPH_SUBTITLE) ?
9707 graphdata->subtitle : NULL);
9708 old = ajGraphicsSetFgcolour(graphdata->colour);
9709
9710 if(thys->flags & AJGRAPH_CIRCLEPOINTS)
9711 ajGraphicsDrawsetSymbols(graphdata->numofpoints,
9712 (graphdata->x), (graphdata->y), 9);
9713
9714 /* Draw the line through the data */
9715 /* old = ajGraphicsSetFgcolour(i+2);*/
9716 old2 = ajGraphicsSetLinestyle(graphdata->lineType);
9717
9718 if(thys->flags & AJGRAPH_JOINPOINTS)
9719 {
9720 if(thys->flags & AJGRAPH_GAPS)
9721 GraphArrayGaps(graphdata->numofpoints,
9722 (graphdata->x), (graphdata->y));
9723 else
9724 GraphArray(graphdata->numofpoints,
9725 (graphdata->x), (graphdata->y));
9726 }
9727
9728 ajGraphicsSetLinestyle(old2);
9729 ajGraphicsSetFgcolour(old);
9730 GraphDataDraw(graphdata);
9731 }
9732 }
9733
9734 if(closeit)
9735 GraphClose();
9736
9737 return;
9738 }
9739
9740
9741
9742
9743 /* @funcstatic GraphDataPrint *************************************************
9744 **
9745 ** Print all the drawable objects in readable form.
9746 **
9747 ** @param [r] graphdata [const AjPGraphdata] Graph data object
9748 **
9749 ** @return [void]
9750 **
9751 ** @release 2.9.0
9752 ** @@
9753 ******************************************************************************/
9754
GraphDataPrint(const AjPGraphdata graphdata)9755 static void GraphDataPrint(const AjPGraphdata graphdata)
9756 {
9757 AjPGraphobj Obj;
9758
9759 if(!graphdata->Dataobj)
9760 {
9761 ajUserDumpC("No Objects");
9762
9763 return;
9764 }
9765 else
9766 {
9767 Obj = graphdata->Dataobj;
9768
9769 while(Obj)
9770 {
9771 if(Obj->type == RECTANGLE )
9772 ajUser("type = RECTANGLE, %f %f %f %f col= %d",
9773 Obj->xx1,Obj->yy1,
9774 Obj->xx2,Obj->yy2,Obj->colour);
9775 else if(Obj->type == RECTANGLEFILL )
9776 ajUser("type = RECTANGLEFILL, %f %f %f %f col= %d",
9777 Obj->xx1, Obj->yy1,
9778 Obj->xx2,Obj->yy2,Obj->colour);
9779 else if(Obj->type == TEXT)
9780 ajUser("type = TEXT, %f %f col= %d %S",Obj->xx1,
9781 Obj->yy1,Obj->colour,
9782 Obj->text);
9783 else if(Obj->type == LINE )
9784 ajUser("type = LINE, %f %f %f %f col= %d",Obj->xx1,
9785 Obj->yy1,
9786 Obj->xx2,Obj->yy2,Obj->colour);
9787
9788 Obj = Obj->next;
9789 }
9790 }
9791
9792 return;
9793 }
9794
9795
9796
9797
9798 /* @funcstatic GraphDataDraw **************************************************
9799 **
9800 ** Display the drawable objects connected to this graph.
9801 **
9802 ** @param [r] graphdata [const AjPGraphdata] Graph data object
9803 **
9804 ** @return [void]
9805 **
9806 ** @release 2.9.0
9807 ** @@
9808 ******************************************************************************/
9809
GraphDataDraw(const AjPGraphdata graphdata)9810 static void GraphDataDraw(const AjPGraphdata graphdata)
9811 {
9812 AjPGraphobj Obj;
9813 ajint temp;
9814 ajuint nobj = 0;
9815
9816 /* graphdata : calls ajGraphLine */
9817
9818 if(!graphdata->Dataobj)
9819 return;
9820
9821 ajDebug("ajGraphDataDraw\n");
9822
9823 Obj = graphdata->Dataobj;
9824 while(Obj)
9825 {
9826 if(Obj->type == RECTANGLE)
9827 {
9828 temp = ajGraphicsSetFgcolour(Obj->colour);
9829 ajGraphicsDrawposRect(Obj->xx1, Obj->yy1,
9830 Obj->xx2,Obj->yy2);
9831 ajGraphicsSetFgcolour(temp);
9832 }
9833 else if(Obj->type == RECTANGLEFILL)
9834 {
9835 temp = ajGraphicsSetFgcolour(Obj->colour);
9836 ajGraphicsDrawposRectFill(Obj->xx1, Obj->yy1,
9837 Obj->xx2,Obj->yy2);
9838 ajGraphicsSetFgcolour(temp);
9839 }
9840 else if(Obj->type == TEXT )
9841 {
9842 temp = ajGraphicsSetFgcolour(Obj->colour);
9843 ajGraphicsDrawposTextAtstart(Obj->xx1, Obj->yy1,
9844 ajStrGetPtr(Obj->text));
9845 ajGraphicsSetFgcolour(temp);
9846 }
9847 else if(Obj->type == LINE)
9848 {
9849 temp = ajGraphicsSetFgcolour(Obj->colour);
9850 ajGraphicsDrawposLine(Obj->xx1, Obj->yy1,
9851 Obj->xx2,Obj->yy2);
9852 ajGraphicsSetFgcolour(temp);
9853 }
9854 else
9855 ajUserDumpC("UNDEFINED OBJECT TYPE USED");
9856
9857 Obj = Obj->next;
9858 ++nobj;
9859 }
9860
9861 ajDebug("drew %u objects in ajGraphDataDraw\n", nobj);
9862
9863 return;
9864 }
9865
9866
9867
9868
9869 /* @funcstatic GraphDistPts ***************************************************
9870 **
9871 ** Compute the distance between 2 points in user coordinates.
9872 **
9873 ** @param [r] xx1 [float] x coord of point 1
9874 ** @param [r] yy1 [float] y coord of point 1
9875 ** @param [r] xx2 [float] x coord of point 2
9876 ** @param [r] yy2 [float] y coord of point 2
9877 **
9878 ** @return [float] The distance between the 2 points in user coordinates
9879 **
9880 ** @release 1.0.0
9881 ** @@
9882 ******************************************************************************/
9883
GraphDistPts(float xx1,float yy1,float xx2,float yy2)9884 static float GraphDistPts(float xx1, float yy1, float xx2, float yy2)
9885 {
9886 PLFLT diag;
9887
9888 diag = (PLFLT) sqrt( (xx2-xx1) * (xx2-xx1) + (yy2-yy1) * (yy2-yy1) );
9889
9890 return diag;
9891 }
9892
9893
9894
9895
9896 /* @funcstatic GraphDrawarcText ***********************************************
9897 **
9898 ** Draw text along a curve (i.e., an arc of a circle).
9899 ** The text is written character by character.
9900 **
9901 ** @param [r] xcentre [PLFLT] x coord for centre.
9902 ** @param [r] ycentre [PLFLT] y coord for centre.
9903 ** @param [r] Radius [PLFLT] Radius of the circle.
9904 ** @param [r] Angle [PLFLT] angle at which a particular character
9905 ** will be written (in deg).
9906 ** @param [r] pos [PLFLT] index for incrementing the angle for the
9907 ** next character in the text.
9908 ** @param [r] txt [const char*] The text to be displayed.
9909 ** @param [r] just [PLFLT] justification of the string.
9910 ** (0=left,1=right,0.5=middle etc)
9911 ** @return [void]
9912 **
9913 ** @release 6.2.0
9914 ** @@
9915 ******************************************************************************/
9916
GraphDrawarcText(PLFLT xcentre,PLFLT ycentre,PLFLT Radius,PLFLT Angle,PLFLT pos,const char * txt,PLFLT just)9917 static void GraphDrawarcText(PLFLT xcentre, PLFLT ycentre,
9918 PLFLT Radius, PLFLT Angle, PLFLT pos,
9919 const char *txt, PLFLT just)
9920 {
9921 ajuint i;
9922 ajuint numchar;
9923 PLFLT *xy1;
9924 PLFLT *xy2;
9925 char textchar[2];
9926
9927 numchar = strlen(txt);
9928
9929 textchar[1] = '\0';
9930 for(i=0; i<numchar; i++)
9931 {
9932 xy1 = ajGraphicsCalcCoord(xcentre, ycentre, Radius, Angle+pos*(PLFLT)i+
9933 (PLFLT)0.5*pos);
9934 xy2 = ajGraphicsCalcCoord(xcentre, ycentre, Radius, Angle+pos*(PLFLT)i+
9935 (PLFLT)1.5*pos);
9936 textchar[0] = txt[i];
9937 ajGraphicsDrawposTextAtlineJustify(xy1[0], xy1[1],
9938 xy2[0], xy2[1],
9939 textchar, just);
9940 AJFREE(xy1);
9941 AJFREE(xy2);
9942 }
9943
9944 return;
9945 }
9946
9947
9948
9949
9950 /* @funcstatic GraphSymbols ***************************************************
9951 **
9952 ** Draw a symbol from the font list.
9953 **
9954 ** @param [r] xx1 [CONST float*] Array of x axis values
9955 ** @param [r] yy1 [CONST float*] Array of y axis values
9956 ** @param [r] numofdots [ajuint] Number of data points
9957 ** @param [r] symbol [ajint] Symbol number (see PLPLOT)
9958 **
9959 ** @return [void]
9960 **
9961 ** @release 1.0.0
9962 ** @@
9963 ******************************************************************************/
9964
GraphSymbols(float * xx1,float * yy1,ajuint numofdots,ajint symbol)9965 static void GraphSymbols(float *xx1, float *yy1, ajuint numofdots,
9966 ajint symbol)
9967 {
9968 #if GRAPH_DEBUG
9969 ajDebug("=g= plpoin(%d, %.2f .. %.2f, %.2f .. %.2f, %d) "
9970 "[size, x..x y..y sym ]\n",
9971 numofdots,xx1[0], xx1[numofdots-1], yy1[0], yy1[numofdots-1],
9972 symbol);
9973 #endif
9974
9975 plpoin(numofdots,xx1,yy1, symbol);
9976
9977 return;
9978 }
9979
9980
9981
9982
9983 /* @funcstatic GraphText ******************************************************
9984 **
9985 ** Display text.
9986 **
9987 ** @param [r] xx1 [float] Start of text box on x axis
9988 ** @param [r] yy1 [float] Start of text box on y axis
9989 ** @param [r] xx2 [float] End of text box on x axis
9990 ** @param [r] yy2 [float] End of text box on y axis
9991 ** @param [r] just [float] Justification (see PLPLOT)
9992 ** @param [r] txt [const char*] Text
9993 **
9994 ** @return [void]
9995 **
9996 ** @release 1.0.0
9997 ** @@
9998 ******************************************************************************/
9999
GraphText(float xx1,float yy1,float xx2,float yy2,float just,const char * txt)10000 static void GraphText(float xx1, float yy1, float xx2, float yy2,
10001 float just,const char *txt)
10002 {
10003 #if GRAPH_DEBUG
10004 ajDebug("=g= plptex(%.2f, %.2f, %.2f, %.2f, %.2f, '%s') "
10005 "[xy xy just text]\n",
10006 xx1, yy1, xx2, yy2, just, txt);
10007 #endif
10008
10009 plptex(xx1,yy1,xx2,yy2,just, txt);
10010
10011 return;
10012 }
10013
10014
10015
10016
10017 /* @funcstatic GraphDatafileNext **********************************************
10018 **
10019 ** Opens the first or next graphData file
10020 **
10021 ** return [void]
10022 **
10023 ** @release 2.8.0
10024 ** @@
10025 ******************************************************************************/
10026
GraphDatafileNext(void)10027 static void GraphDatafileNext(void)
10028 {
10029 AjPStr tempstr;
10030
10031 ajDebug("GraphDatafileNext lines %d (%.3f, %.3f, %.3f, %.3f)\n",
10032 graphData->Lines,
10033 graphData->xmin, graphData->xmax,
10034 graphData->ymin, graphData->ymax);
10035
10036 if(graphData)
10037 {
10038 tempstr = NULL;
10039 ajFileClose(&graphData->File);
10040 graphData->Lines = 0;
10041 tempstr = ajFmtStr("%S%d%S",
10042 graphData->FName,++graphData->Num,graphData->Ext);
10043 graphData->File = ajFileNewOutNameS(tempstr);
10044
10045 if(!graphData->File)
10046 {
10047 ajErr("Could not open graph file %S\n",tempstr);
10048 return;
10049 }
10050
10051 ajDebug("Writing graph %d data to %S\n",graphData->Num,tempstr);
10052
10053 if(graphData->Num > 1) /* ajGraphOpenWin will do the first */
10054 {
10055 ajFmtPrintF(graphData->File,
10056 "##Graphic\n##Screen x1 %f y1 %f x2 %f y2 %f\n",
10057 graphData->xmin, graphData->ymin,
10058 graphData->xmax, graphData->ymax);
10059 graphData->Lines++;
10060 graphData->Lines++;
10061 }
10062
10063 ajListstrPushAppend(graphData->List, tempstr);
10064 }
10065
10066 return;
10067 }
10068
10069
10070
10071
10072 /* @funcstatic GraphColourBack ************************************************
10073 **
10074 ** Set the background colour to either black or white depending on the
10075 ** current settings.
10076 **
10077 ** @return [void]
10078 **
10079 ** @release 6.2.0
10080 ** @@
10081 ******************************************************************************/
10082
GraphColourBack(void)10083 static void GraphColourBack(void)
10084 {
10085 /*ajDebug("GraphColourBack currentbgwhite: %B\n", currentbgwhite);*/
10086
10087 if(currentbgwhite)
10088 {
10089 GraphPen(0, 255, 255, 255);
10090 GraphPen(MAXCOL, 0, 0, 0);
10091
10092 graphColourName[0] = "WHITE";
10093 graphColourName[MAXCOL] = "BLACK";
10094
10095 /*ajDebug("GraphColourBack pens 0 '%s' and pen %d '%s'\n",
10096 graphColourName[0], MAXCOL, graphColourName[MAXCOL]);*/
10097 }
10098
10099 return;
10100 }
10101
10102
10103
10104
10105 #ifdef AJ_COMPILE_DEPRECATED_BOOK
10106 #endif
10107
10108
10109
10110
10111 #ifdef AJ_COMPILE_DEPRECATED
10112 /* @obsolete ajGraphClose
10113 ** @rename ajGraphicsClose
10114 */
ajGraphClose(void)10115 __deprecated void ajGraphClose(void)
10116 {
10117 GraphClose();
10118
10119 return;
10120 }
10121
10122
10123
10124
10125 /* @obsolete ajGraphCloseWin
10126 ** @rename ajGraphicsClose
10127 */
ajGraphCloseWin(void)10128 __deprecated void ajGraphCloseWin(void)
10129 {
10130 GraphClose();
10131
10132 return;
10133 }
10134
10135
10136
10137
10138 /* @obsolete ajGraphPlenv
10139 ** @rename ajGraphicsPlenv
10140 */
ajGraphPlenv(float xmin,float xmax,float ymin,float ymax,ajint flags)10141 __deprecated void ajGraphPlenv(float xmin, float xmax, float ymin, float ymax,
10142 ajint flags)
10143 {
10144 ajGraphicsPlenv(xmin, xmax, ymin, ymax, flags);
10145 return;
10146 }
10147
10148
10149
10150
10151 /* @obsolete ajGraphColourBack
10152 ** @rename ajGraphicsResetBgcolour
10153 */
10154
ajGraphColourBack(void)10155 __deprecated void ajGraphColourBack(void)
10156 {
10157 GraphColourBack();
10158 return;
10159 }
10160
10161
10162
10163
10164 /* @obsolete ajGraphColourFore
10165 ** @rename ajGraphicsResetFgcolour
10166 */
10167
ajGraphColourFore(void)10168 __deprecated void ajGraphColourFore(void)
10169 {
10170 GraphColourFore();
10171 return;
10172 }
10173
10174
10175
10176
10177 /* @obsolete ajGraphSetBackBlack
10178 ** @rename ajGraphicsSetBgcolourBlack
10179 */
10180
ajGraphSetBackBlack(void)10181 __deprecated void ajGraphSetBackBlack(void)
10182 {
10183 ajGraphicsSetBgcolourBlack();
10184 return;
10185 }
10186
10187
10188
10189
10190 /* @obsolete ajGraphSetBackWhite
10191 ** @rename ajGraphicsSetBgcolourkWhite
10192 */
10193
ajGraphSetBackWhite(void)10194 __deprecated void ajGraphSetBackWhite(void)
10195 {
10196 ajGraphicsSetBgcolourWhite();
10197 return;
10198 }
10199
10200
10201
10202
10203 /* @obsolete ajGraphSetCharScale
10204 ** @rename ajGraphicsSetCharscale
10205 */
10206
ajGraphSetCharScale(float scale)10207 __deprecated float ajGraphSetCharScale(float scale)
10208 {
10209 return ajGraphicsSetCharscale(scale);
10210 }
10211
10212
10213
10214
10215 /* @obsolete ajGraphSetCharSize
10216 ** @rename ajGraphicsSetCharsize
10217 */
10218
ajGraphSetCharSize(float size)10219 __deprecated float ajGraphSetCharSize(float size)
10220 {
10221 return ajGraphicsSetCharsize(size);
10222 }
10223
10224
10225
10226
10227 /* @obsolete ajGraphSetDefCharSize
10228 ** @rename ajGraphicsSetDefcharsize
10229 */
10230
ajGraphSetDefCharSize(float size)10231 __deprecated float ajGraphSetDefCharSize(float size)
10232 {
10233 return ajGraphicsSetDefcharsize(size);
10234 }
10235
10236
10237
10238
10239 /* @obsolete ajGraphSetDevice
10240 @rename ajGraphicsSetDevice
10241 */
10242
ajGraphSetDevice(const AjPGraph thys)10243 __deprecated void ajGraphSetDevice(const AjPGraph thys)
10244 {
10245 ajGraphicsSetDevice(thys);
10246
10247 return;
10248 }
10249
10250
10251
10252
10253 /* @obsolete ajGraphSetFore
10254 ** @rename ajGraphicsSetFgcolour
10255 */
10256
ajGraphSetFore(ajint colour)10257 __deprecated ajint ajGraphSetFore(ajint colour)
10258 {
10259
10260 return ajGraphicsSetFgcolour(colour);
10261 }
10262
10263
10264
10265
10266 /* @obsolete ajGraphSetName
10267 ** @rename ajGraphicsSetFilename
10268 */
ajGraphSetName(const AjPGraph thys)10269 __deprecated void ajGraphSetName(const AjPGraph thys)
10270 {
10271 ajGraphicsSetFilename(thys);
10272 return;
10273 }
10274
10275
10276
10277
10278 /* @obsolete ajGraphSetFillPat
10279 ** @rename ajGraphicsSetFillpat
10280 */
ajGraphSetFillPat(ajint style)10281 __deprecated ajint ajGraphSetFillPat(ajint style)
10282 {
10283 return ajGraphicsSetFillpat(style);
10284 }
10285
10286
10287
10288
10289 /* @obsolete ajGraphLabel
10290 ** @rename ajGraphicsSetLabelsC
10291 */
10292
ajGraphLabel(const char * x,const char * y,const char * title,const char * subtitle)10293 __deprecated void ajGraphLabel(const char *x, const char *y,
10294 const char *title, const char *subtitle)
10295 {
10296 ajGraphicsSetLabelsC(x, y, title, subtitle);
10297 return;
10298 }
10299
10300
10301
10302
10303 /* @obsolete ajGraphSetLineStyle
10304 ** @rename ajGraphicsSetLinestyle
10305 */
ajGraphSetLineStyle(ajint style)10306 __deprecated ajint ajGraphSetLineStyle(ajint style)
10307 {
10308 return ajGraphicsSetLinestyle(style);
10309 }
10310
10311
10312
10313
10314 /* @obsolete ajGraphSetPage
10315 ** @rename ajGraphicsSetPagesize
10316 */
ajGraphSetPage(ajuint width,ajuint height)10317 __deprecated void ajGraphSetPage(ajuint width, ajuint height)
10318 {
10319 ajGraphicsSetPagesize(width, height);
10320 return;
10321 }
10322
10323
10324
10325
10326 /* @obsolete ajGraphSetPenWidth
10327 ** @rename ajGraphicsSetPenwidth
10328 */
ajGraphSetPenWidth(float penwidth)10329 __deprecated void ajGraphSetPenWidth(float penwidth)
10330 {
10331 ajGraphicsSetPenwidth(penwidth);
10332 return;
10333 }
10334
10335
10336
10337
10338 /* @obsolete ajGraphSetOri
10339 ** @rename ajGraphicsSetPortrait
10340 */
10341
ajGraphSetOri(ajint ori)10342 __deprecated void ajGraphSetOri(ajint ori)
10343 {
10344 ajGraphicsSetPortrait(ori);
10345 return;
10346 }
10347
10348
10349
10350
10351 /* @obsolete ajGraphLabelYRight
10352 ** @rename ajGraphicsSetRlabelC
10353 */
10354
ajGraphLabelYRight(const char * text)10355 __deprecated void ajGraphLabelYRight(const char *text)
10356 {
10357 ajGraphicsSetRlabelC(text);
10358 return;
10359 }
10360
10361
10362
10363
10364 /* @obsolete ajGraphGetBaseColourNuc
10365 ** @rename ajGraphicsBasecolourNewNuc
10366 */
10367
ajGraphGetBaseColourNuc(const AjPStr codes)10368 __deprecated ajint* ajGraphGetBaseColourNuc(const AjPStr codes)
10369 {
10370 return ajGraphicsBasecolourNewNuc(codes);
10371 }
10372
10373
10374
10375
10376 /* @obsolete ajGraphGetBaseColourProt
10377 ** @rename ajGraphicsBasecolourNewProt
10378 */
10379
ajGraphGetBaseColourProt(const AjPStr codes)10380 __deprecated ajint* ajGraphGetBaseColourProt(const AjPStr codes)
10381 {
10382 return ajGraphicsBasecolourNewProt(codes);
10383 }
10384
10385
10386
10387
10388 /* @obsolete ajGraphGetBaseColour
10389 ** @remove Use ajGraphicsBasecolourNewNuc or ajGraphicsBasecolourNewProt
10390 */
10391
ajGraphGetBaseColour(void)10392 __deprecated ajint* ajGraphGetBaseColour(void)
10393 {
10394 ajint *ret;
10395
10396 ret = (ajint *) AJALLOC0(sizeof(ajint)*AZ);
10397
10398 ret[0] = BLACK; /* A */
10399 ret[1] = BLACK; /* B */
10400 ret[2] = YELLOW; /* C */
10401 ret[3] = RED; /* D */
10402 ret[4] = RED; /* E */
10403 ret[5] = WHEAT; /* F */
10404 ret[6] = GREY; /* G */
10405 ret[7] = BLUE; /* H */
10406 ret[8] = BLACK; /* I */
10407 ret[9] = BLACK; /* J */
10408 ret[10] = BLUE; /* K */
10409 ret[11] = BLACK; /* L */
10410 ret[12] = YELLOW; /* M */
10411 ret[13] = GREEN; /* N */
10412 ret[14] = BLACK; /* O */
10413 ret[15] = BLUEVIOLET; /* P */
10414 ret[16] = GREEN; /* Q */
10415 ret[17] = BLUE; /* R */
10416 ret[18] = CYAN; /* S */
10417 ret[19] = CYAN; /* T */
10418 ret[20] = BLACK; /* U */
10419 ret[21] = BLACK; /* V */
10420 ret[22] = WHEAT; /* W */
10421 ret[23] = BLACK; /* X */
10422 ret[24] = WHEAT; /* Y */
10423 ret[25] = BLACK; /* Z */
10424 ret[26] = BLACK; /* ? */
10425 ret[27] = BLACK; /* ?*/
10426
10427 return ret;
10428 }
10429
10430
10431
10432
10433 /* @obsolete ajGraphCheckColour
10434 ** @rename ajGraphicsCheckColourS
10435 */
10436
ajGraphCheckColour(const AjPStr colour)10437 __deprecated ajint ajGraphCheckColour(const AjPStr colour)
10438 {
10439 return ajGraphicsCheckColourS(colour);
10440 }
10441
10442
10443
10444
10445 /* @obsolete ajGraphGetColour
10446 ** @rename ajGraphicsGetFgcolour
10447 */
10448
ajGraphGetColour(void)10449 __deprecated ajint ajGraphGetColour(void)
10450 {
10451 return ajGraphicsGetFgcolour();
10452 }
10453
10454
10455
10456
10457 /* @obsolete ajGraphGetOut
10458 ** @rename ajGraphicsGetParamsPage
10459 */
10460
ajGraphGetOut(float * xp,float * yp,ajint * xleng,ajint * yleng,ajint * xoff,ajint * yoff)10461 __deprecated void ajGraphGetOut(float *xp,float *yp, ajint *xleng, ajint *yleng,
10462 ajint *xoff, ajint *yoff)
10463
10464 {
10465
10466 ajGraphicsGetParamsPage(xp, yp, xleng, yleng, xoff, yoff);
10467 return;
10468 }
10469
10470
10471
10472
10473 /* @obsolete ajGraphGetCharSize
10474 ** @rename ajGraphicsGetCharsize
10475 */
10476
ajGraphGetCharSize(float * defheight,float * currentheight)10477 __deprecated void ajGraphGetCharSize(float *defheight, float *currentheight)
10478 {
10479 ajGraphicsGetCharsize(defheight, currentheight);
10480 return;
10481 }
10482
10483
10484
10485
10486 /* @obsolete ajGraphPartCircle
10487 ** @rename ajGraphicsDrawarcArc
10488 */
10489
ajGraphPartCircle(PLFLT xcentre,PLFLT ycentre,PLFLT Radius,PLFLT StartAngle,PLFLT EndAngle)10490 __deprecated void ajGraphPartCircle(PLFLT xcentre, PLFLT ycentre, PLFLT Radius,
10491 PLFLT StartAngle, PLFLT EndAngle)
10492 {
10493
10494 ajGraphicsDrawarcArc(xcentre, ycentre, Radius, StartAngle, EndAngle);
10495 return;
10496 }
10497
10498
10499
10500
10501 /* @obsolete ajGraphRectangleOnCurve
10502 ** @replace ajGraphicsDrawarcRect (1,2,3,4,5,6/1,2,3,5,6,4)
10503 */
10504
ajGraphRectangleOnCurve(PLFLT xcentre,PLFLT ycentre,PLFLT Radius,PLFLT BoxHeight,PLFLT StartAngle,PLFLT EndAngle)10505 __deprecated void ajGraphRectangleOnCurve(PLFLT xcentre, PLFLT ycentre,
10506 PLFLT Radius, PLFLT BoxHeight,
10507 PLFLT StartAngle, PLFLT EndAngle)
10508 {
10509
10510 ajGraphicsDrawarcRect(xcentre, ycentre, Radius,
10511 StartAngle, EndAngle, BoxHeight);
10512 return;
10513 }
10514
10515
10516
10517
10518 /* @obsolete ajGraphFillRectangleOnCurve
10519 ** @replace ajGraphicsDrawarcRectFill (1,2,3,4,5,6/1,2,3,5,6,4)
10520 */
10521
ajGraphFillRectangleOnCurve(PLFLT xcentre,PLFLT ycentre,PLFLT Radius,PLFLT BoxHeight,PLFLT StartAngle,PLFLT EndAngle)10522 __deprecated void ajGraphFillRectangleOnCurve(PLFLT xcentre, PLFLT ycentre,
10523 PLFLT Radius,
10524 PLFLT BoxHeight, PLFLT StartAngle,
10525 PLFLT EndAngle)
10526 {
10527
10528 ajGraphicsDrawarcRectFill(xcentre, ycentre, Radius,
10529 StartAngle, EndAngle, BoxHeight);
10530 return;
10531 }
10532
10533
10534
10535
10536 /* @obsolete ajGraphDrawTextOnCurve
10537 ** @rename ajGraphicsDrawarcTextJustify
10538 */
10539
ajGraphDrawTextOnCurve(PLFLT xcentre,PLFLT ycentre,PLFLT Radius,PLFLT StartAngle,PLFLT EndAngle,const char * Text,PLFLT just)10540 __deprecated void ajGraphDrawTextOnCurve(PLFLT xcentre, PLFLT ycentre,
10541 PLFLT Radius, PLFLT StartAngle,
10542 PLFLT EndAngle,
10543 const char *Text, PLFLT just)
10544
10545 {
10546 ajGraphicsDrawarcTextJustify(xcentre, ycentre, Radius,
10547 StartAngle, EndAngle, Text, just);
10548 return;
10549 }
10550
10551
10552
10553
10554 /* @obsolete ajGraphHoriBars
10555 ** @rename ajGraphicsDrawbarsHoriz
10556 */
10557
ajGraphHoriBars(ajuint numofpoints,PLFLT * y,PLFLT * xmin,PLFLT * xmax)10558 __deprecated void ajGraphHoriBars(ajuint numofpoints,
10559 PLFLT *y, PLFLT *xmin, PLFLT *xmax)
10560 {
10561 ajGraphicsDrawbarsHoriz(numofpoints,y, xmin, xmax);
10562 return;
10563 }
10564
10565
10566
10567
10568 /* @obsolete ajGraphVertBars
10569 ** @rename ajGraphicsDrawbarsVert
10570 */
10571
ajGraphVertBars(ajuint numofpoints,PLFLT * x,PLFLT * ymin,PLFLT * ymax)10572 __deprecated void ajGraphVertBars(ajuint numofpoints,
10573 PLFLT *x, PLFLT *ymin, PLFLT *ymax)
10574 {
10575 ajGraphicsDrawbarsVert(numofpoints, x, ymin, ymax);
10576 return;
10577 }
10578
10579
10580
10581
10582 /* @obsolete ajGraphBox
10583 ** @rename ajGraphicsDrawposBox
10584 */
10585
ajGraphBox(PLFLT xx0,PLFLT yy0,PLFLT size)10586 __deprecated void ajGraphBox(PLFLT xx0, PLFLT yy0,PLFLT size)
10587 {
10588 ajGraphicsDrawposBox(xx0, yy0, size);
10589 return;
10590 }
10591
10592
10593
10594
10595 /* @obsolete ajGraphBoxFill
10596 ** @rename ajGraphicsDrawposBoxFill
10597 */
10598
ajGraphBoxFill(PLFLT xx0,PLFLT yy0,PLFLT size)10599 __deprecated void ajGraphBoxFill(PLFLT xx0, PLFLT yy0, PLFLT size)
10600 {
10601 ajGraphicsDrawposBoxFill(xx0, yy0, size);
10602 return;
10603 }
10604
10605
10606
10607
10608 /* @obsolete ajGraphCircle
10609 ** @rename ajGraphicsDrawposCircle
10610 */
10611
ajGraphCircle(PLFLT xcentre,PLFLT ycentre,float radius)10612 __deprecated void ajGraphCircle(PLFLT xcentre, PLFLT ycentre, float radius)
10613 {
10614 ajGraphicsDrawposCircle(xcentre, ycentre, radius);
10615 return;
10616 }
10617
10618
10619
10620
10621 /* @obsolete ajGraphDia
10622 ** @rename ajGraphicsDrawposDia
10623 */
10624
ajGraphDia(PLFLT xx0,PLFLT yy0,PLFLT size)10625 __deprecated void ajGraphDia(PLFLT xx0, PLFLT yy0, PLFLT size)
10626 {
10627 ajGraphicsDrawposDia(xx0, yy0, size);
10628 return;
10629 }
10630
10631
10632
10633
10634 /* @obsolete ajGraphDiaFill
10635 ** @rename ajGraphicsDrawposDiaFill
10636 */
10637
ajGraphDiaFill(PLFLT xx0,PLFLT yy0,PLFLT size)10638 __deprecated void ajGraphDiaFill(PLFLT xx0, PLFLT yy0, PLFLT size)
10639 {
10640 ajGraphicsDrawposDiaFill(xx0, yy0, size);
10641 return;
10642 }
10643
10644
10645
10646
10647 /* @obsolete ajGraphLine
10648 ** @rename ajGraphicsDrawposLine
10649 */
10650
ajGraphLine(PLFLT xx1,PLFLT yy1,PLFLT xx2,PLFLT yy2)10651 __deprecated void ajGraphLine(PLFLT xx1, PLFLT yy1, PLFLT xx2, PLFLT yy2)
10652 {
10653 ajGraphicsDrawposLine(xx1, yy1, xx2, yy2);
10654 return;
10655 }
10656
10657
10658
10659
10660 /* @obsolete ajGraphRect
10661 ** @rename ajGraphicsDrawposRect
10662 */
10663
ajGraphRect(PLFLT xx0,PLFLT yy0,PLFLT xx1,PLFLT yy1)10664 __deprecated void ajGraphRect(PLFLT xx0, PLFLT yy0,PLFLT xx1, PLFLT yy1)
10665 {
10666 ajGraphicsDrawposRect(xx0, yy0, xx1, yy1);
10667 return;
10668 }
10669
10670
10671
10672
10673 /* @obsolete ajGraphRectFill
10674 ** @rename ajGraphicsDrawposRectFill
10675 */
10676
ajGraphRectFill(PLFLT xx0,PLFLT yy0,PLFLT xx1,PLFLT yy1)10677 __deprecated void ajGraphRectFill(PLFLT xx0, PLFLT yy0, PLFLT xx1, PLFLT yy1)
10678 {
10679 ajGraphicsDrawposRectFill(xx0, yy0, xx1, yy1);
10680 return;
10681 }
10682
10683
10684
10685
10686
10687 /* @obsolete ajGraphTextEnd
10688 ** @rename ajGraphicsDrawposTextAtend
10689 */
10690
ajGraphTextEnd(PLFLT x,PLFLT y,const char * text)10691 __deprecated void ajGraphTextEnd(PLFLT x, PLFLT y, const char *text)
10692 {
10693 ajGraphicsDrawposTextAtend(x,y,text);
10694 return;
10695 }
10696
10697
10698
10699
10700 /* @obsolete ajGraphTextLine
10701 ** @rename ajGraphicsDrawposTextAtlineJustify
10702 */
10703
ajGraphTextLine(PLFLT xx1,PLFLT yy1,PLFLT xx2,PLFLT yy2,const char * text,PLFLT just)10704 __deprecated void ajGraphTextLine(PLFLT xx1, PLFLT yy1, PLFLT xx2, PLFLT yy2,
10705 const char *text, PLFLT just)
10706 {
10707 ajGraphicsDrawposTextAtlineJustify(xx1, yy1, xx2, yy2, text, just);
10708 return;
10709 }
10710
10711
10712
10713
10714 /* @obsolete ajGraphTextMid
10715 ** @rename ajGraphicsDrawposTextAtmid
10716 */
10717
ajGraphTextMid(PLFLT xx1,PLFLT yy1,const char * text)10718 __deprecated void ajGraphTextMid(PLFLT xx1, PLFLT yy1, const char *text)
10719 {
10720 ajGraphicsDrawposTextAtmid(xx1,yy1,text);
10721 return;
10722 }
10723
10724
10725
10726
10727 /* @obsolete ajGraphTextStart
10728 ** @rename ajGraphicsDrawposTextAtstart
10729 */
10730
ajGraphTextStart(PLFLT xx1,PLFLT yy1,const char * text)10731 __deprecated void ajGraphTextStart(PLFLT xx1, PLFLT yy1, const char *text)
10732 {
10733 ajGraphicsDrawposTextAtstart(xx1,yy1,text);
10734 return;
10735 }
10736
10737
10738
10739
10740 /* @obsolete ajGraphText
10741 ** @rename ajGraphicsDrawposTextJustify
10742 */
10743
ajGraphText(PLFLT xx1,PLFLT yy1,const char * text,PLFLT just)10744 __deprecated void ajGraphText(PLFLT xx1, PLFLT yy1,
10745 const char *text, PLFLT just)
10746 {
10747 ajGraphicsDrawposTextJustify(xx1,yy1,text,just);
10748 return;
10749 }
10750
10751
10752
10753
10754 /* @obsolete ajGraphTri
10755 ** @rename ajGraphicsDrawposTri
10756 */
10757
ajGraphTri(PLFLT xx1,PLFLT yy1,PLFLT xx2,PLFLT yy2,PLFLT x3,PLFLT y3)10758 __deprecated void ajGraphTri(PLFLT xx1, PLFLT yy1, PLFLT xx2, PLFLT yy2,
10759 PLFLT x3, PLFLT y3)
10760 {
10761 ajGraphicsDrawposTri(xx1,yy1,xx2,yy2,x3,y3);
10762 return;
10763 }
10764
10765
10766
10767
10768 /* @obsolete ajGraphTriFill
10769 ** @rename ajGraphicsDrawposTriFill
10770 */
10771
ajGraphTriFill(PLFLT xx1,PLFLT yy1,PLFLT xx2,PLFLT yy2,PLFLT x3,PLFLT y3)10772 __deprecated void ajGraphTriFill(PLFLT xx1, PLFLT yy1, PLFLT xx2, PLFLT yy2,
10773 PLFLT x3, PLFLT y3)
10774 {
10775 ajGraphicsDrawposTriFill(xx1,yy1,xx2,yy2,x3,y3);
10776 return;
10777 }
10778
10779
10780
10781
10782 /* @obsolete ajGraphDots
10783 ** @replace ajGraphicsDrawsetDots (1,2,3/3,1,2)
10784 */
10785
ajGraphDots(PLFLT * xx1,PLFLT * yy1,ajuint numofdots)10786 __deprecated void ajGraphDots(PLFLT *xx1, PLFLT *yy1, ajuint numofdots)
10787 {
10788 ajGraphicsDrawsetDots(numofdots,xx1,yy1);
10789 return;
10790 }
10791
10792
10793
10794
10795 /* @obsolete ajGraphLines
10796 ** @replace ajGraphicsDrawsetLines (1,2,3,4,5/5,1,2,3,4)
10797 */
10798
ajGraphLines(PLFLT * xx1,PLFLT * yy1,PLFLT * xx2,PLFLT * yy2,ajuint numoflines)10799 __deprecated void ajGraphLines(PLFLT *xx1, PLFLT *yy1, PLFLT *xx2, PLFLT *yy2,
10800 ajuint numoflines)
10801
10802 {
10803 ajGraphicsDrawsetLines(numoflines, xx1, yy1, xx2, yy2);
10804 return;
10805 }
10806
10807
10808
10809
10810 /* @obsolete ajGraphPoly
10811 ** @rename ajGraphicsDrawsetPoly
10812 */
10813
ajGraphPoly(ajuint n,PLFLT * x,PLFLT * y)10814 __deprecated void ajGraphPoly(ajuint n, PLFLT *x, PLFLT *y)
10815 {
10816 ajGraphicsDrawsetPoly(n, x, y);
10817 return;
10818 }
10819
10820
10821
10822
10823 /* @obsolete ajGraphPolyFill
10824 ** @rename ajGraphicsDrawsetPolyFill
10825 */
10826
ajGraphPolyFill(ajuint n,PLFLT * x,PLFLT * y)10827 __deprecated void ajGraphPolyFill(ajuint n, PLFLT *x, PLFLT *y)
10828 {
10829 ajGraphicsDrawsetPolyFill(n, x, y);
10830 return;
10831 }
10832
10833
10834
10835
10836 /* @obsolete ajGraphSymbols
10837 ** @rename ajGraphicsDrawsetSymbols
10838 */
10839
ajGraphSymbols(ajuint numofdots,PLFLT * xx1,PLFLT * yy1,ajuint symbol)10840 __deprecated void ajGraphSymbols( ajuint numofdots, PLFLT *xx1,PLFLT *yy1,
10841 ajuint symbol)
10842 {
10843 ajGraphicsDrawsetSymbols(numofdots,xx1,yy1,symbol);
10844 return;
10845 }
10846
10847
10848
10849
10850 /* @obsolete ajGraphFitTextAtline
10851 ** @rename ajGraphicsCalcCharsize
10852 */
ajGraphFitTextAtline(PLFLT xx1,PLFLT yy1,PLFLT xx2,PLFLT yy2,const char * text,PLFLT TextHeight)10853 __deprecated PLFLT ajGraphFitTextAtline(PLFLT xx1, PLFLT yy1,
10854 PLFLT xx2, PLFLT yy2,
10855 const char *text,
10856 PLFLT TextHeight)
10857 {
10858 return ajGraphicsCalcCharsize(xx1,yy1,xx2,yy2,text,TextHeight);
10859 }
10860
10861
10862
10863
10864 /* @obsolete ajComputeCoord
10865 ** @rename ajGraphicsCalcCoord
10866 */
ajComputeCoord(PLFLT xcentre,PLFLT ycentre,PLFLT Radius,PLFLT Angle)10867 __deprecated PLFLT* ajComputeCoord(PLFLT xcentre, PLFLT ycentre,
10868 PLFLT Radius, PLFLT Angle)
10869 {
10870 return ajGraphicsCalcCoord(xcentre, ycentre, Radius, Angle);
10871 }
10872
10873
10874
10875
10876 /* @obsolete ajGraphDistPts
10877 ** @rename ajGraphicsCalcDistance
10878 */
ajGraphDistPts(PLFLT xx1,PLFLT yy1,PLFLT xx2,PLFLT yy2)10879 __deprecated PLFLT ajGraphDistPts(PLFLT xx1, PLFLT yy1, PLFLT xx2, PLFLT yy2)
10880 {
10881 return GraphDistPts(xx1, yy1, xx2, yy2);
10882 }
10883
10884
10885
10886
10887 /* @obsolete ajGraphArrayMaxMin
10888 ** @rename ajGraphicsCalcRange
10889 */
ajGraphArrayMaxMin(const float * array,ajint npoints,float * min,float * max)10890 __deprecated void ajGraphArrayMaxMin(const float *array,
10891 ajint npoints, float *min, float *max)
10892 {
10893 ajGraphicsCalcRange(array, npoints, min, max);
10894 return;
10895 }
10896
10897
10898
10899
10900 /* @obsolete ajGraphTextHeight
10901 ** @rename ajGraphicsCalcTextheight
10902 */
ajGraphTextHeight(PLFLT xx1,PLFLT yy1,PLFLT xx2,PLFLT yy2)10903 __deprecated PLFLT ajGraphTextHeight(PLFLT xx1, PLFLT yy1,
10904 PLFLT xx2, PLFLT yy2)
10905 {
10906 (void) xx1;
10907 (void) yy1;
10908 (void) xx2;
10909 (void) yy2;
10910 return currentcharsize;
10911 }
10912
10913
10914
10915
10916 /* @obsolete ajGraphTextLength
10917 ** @rename ajGraphicsCalcTextlengthC
10918 */
ajGraphTextLength(PLFLT xx1,PLFLT yy1,PLFLT xx2,PLFLT yy2,const char * text)10919 __deprecated PLFLT ajGraphTextLength(PLFLT xx1, PLFLT yy1, PLFLT xx2, PLFLT yy2,
10920 const char *text)
10921 {
10922 (void) xx1;
10923 (void) yy1;
10924 (void) xx2;
10925 (void) yy2;
10926 return GraphTextLength(text);
10927 }
10928
10929
10930
10931
10932 /* @obsolete ajGraphNewPage
10933 ** @rename ajGraphNewpage
10934 */
ajGraphNewPage(AjPGraph thys,AjBool resetdefaults)10935 __deprecated void ajGraphNewPage(AjPGraph thys, AjBool resetdefaults)
10936 {
10937 ajGraphNewpage(thys, resetdefaults);
10938 return;
10939 }
10940
10941
10942
10943
10944 /* @obsolete ajGraphOpen
10945 ** @rename ajGraphOpenFlags
10946 */
ajGraphOpen(AjPGraph thys,PLFLT xmin,PLFLT xmax,PLFLT ymin,PLFLT ymax,ajint flags)10947 __deprecated void ajGraphOpen(AjPGraph thys, PLFLT xmin, PLFLT xmax,
10948 PLFLT ymin, PLFLT ymax, ajint flags)
10949 {
10950 ajGraphOpenFlags(thys, xmin, xmax, ymin, ymax, flags);
10951 return;
10952 }
10953
10954
10955
10956
10957 /* @obsolete ajGraphOpenPlot
10958 ** @rename ajGraphOpenPlotset
10959 */
ajGraphOpenPlot(AjPGraph thys,ajuint numofsets)10960 __deprecated void ajGraphOpenPlot(AjPGraph thys, ajuint numofsets)
10961 {
10962 ajGraphOpenPlotset(thys, numofsets);
10963 return;
10964 }
10965
10966
10967
10968
10969 /* @obsolete ajGraphSetTitlePlus
10970 ** @rename ajGraphAppendTitle
10971 */
ajGraphSetTitlePlus(AjPGraph thys,const AjPStr title)10972 __deprecated void ajGraphSetTitlePlus(AjPGraph thys, const AjPStr title)
10973 {
10974 ajGraphAppendTitleS(thys, title);
10975 return;
10976 }
10977
10978
10979
10980
10981 /* @obsolete ajGraphSetDesc
10982 ** @rename ajGraphSetDescS
10983 */
10984
ajGraphSetDesc(AjPGraph thys,const AjPStr title)10985 __deprecated void ajGraphSetDesc(AjPGraph thys, const AjPStr title)
10986 {
10987 ajGraphSetDescS(thys, title);
10988
10989 return;
10990 }
10991
10992
10993
10994
10995 /* @obsolete ajGraphSet
10996 ** @rename ajGraphSetDevicetype
10997 */
ajGraphSet(AjPGraph thys,const AjPStr type)10998 __deprecated AjBool ajGraphSet(AjPGraph thys, const AjPStr type)
10999 {
11000 return ajGraphSetDevicetype(thys, type);
11001 }
11002
11003
11004
11005
11006 /* @obsolete ajGraphSetDir
11007 ** @rename ajGraphSetOutdirS
11008 */
11009
ajGraphSetDir(AjPGraph thys,const AjPStr txt)11010 __deprecated void ajGraphSetDir(AjPGraph thys, const AjPStr txt)
11011 {
11012 ajGraphSetOutdirS(thys, txt);
11013 return;
11014 }
11015
11016
11017
11018
11019 /* @obsolete ajGraphSetOutC
11020 ** @rename ajGraphSetOutfileC
11021 */
ajGraphSetOutC(AjPGraph thys,const char * txt)11022 __deprecated void ajGraphSetOutC(AjPGraph thys, const char* txt)
11023 {
11024 ajGraphSetOutfileC(thys, txt);
11025 return;
11026 }
11027
11028
11029
11030
11031 /* @obsolete ajGraphSetOut
11032 ** @rename ajGraphSetOutfileS
11033 */
ajGraphSetOut(AjPGraph thys,const AjPStr txt)11034 __deprecated void ajGraphSetOut(AjPGraph thys, const AjPStr txt)
11035 {
11036
11037 ajGraphSetOutfileS(thys, txt);
11038 return;
11039 }
11040
11041
11042
11043
11044 /* @obsolete ajGraphSetSubTitleC
11045 ** @rename ajGraphSetSubtitleC
11046 */
11047
ajGraphSetSubTitleC(AjPGraph thys,const char * title)11048 __deprecated void ajGraphSetSubTitleC(AjPGraph thys, const char* title)
11049 {
11050 ajGraphSetSubtitleC(thys, title);
11051 return;
11052 }
11053
11054
11055
11056
11057 /* @obsolete ajGraphSetSubTitle
11058 ** @rename ajGraphSetSubtitleS
11059 */
11060
ajGraphSetSubTitle(AjPGraph thys,const AjPStr title)11061 __deprecated void ajGraphSetSubTitle(AjPGraph thys, const AjPStr title)
11062 {
11063 ajGraphSetSubtitleS(thys, title);
11064 return;
11065 }
11066
11067
11068
11069
11070 /* @obsolete ajGraphSetTitle
11071 ** @rename ajGraphSetTitleS
11072 */
11073
ajGraphSetTitle(AjPGraph thys,const AjPStr title)11074 __deprecated void ajGraphSetTitle(AjPGraph thys, const AjPStr title)
11075 {
11076 ajGraphSetTitleS(thys, title);
11077 return;
11078 }
11079
11080
11081
11082
11083 /* @obsolete ajGraphSetXTitleC
11084 ** @rename ajGraphSetXlabelC
11085 */
11086
ajGraphSetXTitleC(AjPGraph thys,const char * title)11087 __deprecated void ajGraphSetXTitleC(AjPGraph thys, const char* title)
11088 {
11089 ajGraphSetXlabelC(thys, title);
11090 return;
11091 }
11092
11093
11094
11095
11096 /* @obsolete ajGraphSetXTitle
11097 ** @rename ajGraphSetXlabelS
11098 */
11099
ajGraphSetXTitle(AjPGraph thys,const AjPStr title)11100 __deprecated void ajGraphSetXTitle(AjPGraph thys, const AjPStr title)
11101 {
11102 ajGraphSetXlabelS(thys, title);
11103 return;
11104 }
11105
11106
11107
11108
11109 /* @obsolete ajGraphSetYTitleC
11110 ** @rename ajGraphSetYlabelC
11111 */
11112
ajGraphSetYTitleC(AjPGraph thys,const char * title)11113 __deprecated void ajGraphSetYTitleC(AjPGraph thys, const char* title)
11114 {
11115 ajGraphSetYlabelC(thys, title);
11116 return;
11117 }
11118
11119
11120
11121
11122 /* @obsolete ajGraphSetYTitle
11123 ** @rename ajGraphSetYlabelS
11124 */
11125
ajGraphSetYTitle(AjPGraph thys,const AjPStr title)11126 __deprecated void ajGraphSetYTitle(AjPGraph thys, const AjPStr title)
11127 {
11128 ajGraphSetYlabelS(thys, title);
11129 return;
11130 }
11131
11132
11133
11134
11135 /* @obsolete ajGraphSetSubTitleDo
11136 ** @rename ajGraphShowSubtitle
11137 */
11138
ajGraphSetSubTitleDo(AjPGraph thys,AjBool set)11139 __deprecated void ajGraphSetSubTitleDo(AjPGraph thys, AjBool set)
11140 {
11141 ajGraphShowSubtitle(thys, set);
11142 return;
11143 }
11144
11145
11146
11147
11148 /* @obsolete ajGraphSetTitleDo
11149 ** @rename ajGraphShowTitle
11150 */
11151
ajGraphSetTitleDo(AjPGraph thys,AjBool set)11152 __deprecated void ajGraphSetTitleDo(AjPGraph thys, AjBool set)
11153 {
11154 ajGraphSetFlag(thys, AJGRAPH_TITLE, set);
11155
11156 return;
11157 }
11158
11159
11160
11161
11162 /* @obsolete ajGraphGetSubTitleC
11163 ** @rename ajGraphGetSubtitleC
11164 */
ajGraphGetSubTitleC(const AjPGraph thys)11165 __deprecated const char* ajGraphGetSubTitleC(const AjPGraph thys)
11166 {
11167 return ajGraphGetSubtitleC(thys);
11168 }
11169
11170
11171
11172
11173 /* @obsolete ajGraphGetSubTitle
11174 ** @rename ajGraphGetSubtitleS
11175 */
ajGraphGetSubTitle(const AjPGraph thys)11176 __deprecated const AjPStr ajGraphGetSubTitle(const AjPGraph thys)
11177 {
11178 return ajGraphGetSubtitleS(thys);
11179 }
11180
11181
11182
11183
11184 /* @obsolete ajGraphGetTitle
11185 ** @rename ajGraphGetTitleS
11186 */
ajGraphGetTitle(const AjPGraph thys)11187 __deprecated const AjPStr ajGraphGetTitle(const AjPGraph thys)
11188 {
11189 return thys->title;
11190 }
11191
11192
11193
11194
11195 /* @obsolete ajGraphGetXTitleC
11196 ** @rename ajGraphGetXlabelC
11197 */
ajGraphGetXTitleC(const AjPGraph thys)11198 __deprecated const char* ajGraphGetXTitleC(const AjPGraph thys)
11199 {
11200 return ajGraphGetXlabelC(thys);
11201 }
11202
11203
11204
11205
11206 /* @obsolete ajGraphGetXTitle
11207 ** @rename ajGraphGetXlabelS
11208 */
ajGraphGetXTitle(const AjPGraph thys)11209 __deprecated const AjPStr ajGraphGetXTitle(const AjPGraph thys)
11210 {
11211 return thys->xaxis;
11212 }
11213
11214
11215
11216
11217 /* @obsolete ajGraphGetYTitleC
11218 ** @rename ajGraphGetYlabelC
11219 */
ajGraphGetYTitleC(const AjPGraph thys)11220 __deprecated const char* ajGraphGetYTitleC(const AjPGraph thys)
11221 {
11222 return ajGraphGetYlabelC(thys);
11223 }
11224
11225
11226
11227
11228 /* @obsolete ajGraphGetYTitle
11229 ** @rename ajGraphGetYlabelS
11230 */
ajGraphGetYTitle(const AjPGraph thys)11231 __deprecated const AjPStr ajGraphGetYTitle(const AjPGraph thys)
11232 {
11233 return thys->yaxis;
11234 }
11235
11236
11237
11238
11239 /* @obsolete ajGraphAddText
11240 ** @rename ajGraphAddTextC
11241 */
ajGraphAddText(AjPGraph thys,float x,float y,ajint colour,const char * txt)11242 __deprecated void ajGraphAddText(AjPGraph thys, float x, float y,
11243 ajint colour, const char *txt)
11244 {
11245 ajGraphAddTextC(thys, x, y, colour, txt);
11246 return;
11247 }
11248
11249
11250
11251
11252 /* @obsolete ajGraphAddTextScale
11253 ** @rename ajGraphAddTextScaleC
11254 */
ajGraphAddTextScale(AjPGraph thys,float xx1,float yy1,ajint colour,float scale,const char * txt)11255 __deprecated void ajGraphAddTextScale(AjPGraph thys, float xx1, float yy1,
11256 ajint colour, float scale,
11257 const char *txt)
11258 {
11259
11260 ajGraphAddTextScaleC(thys, xx1, yy1, colour, scale, txt);
11261 return;
11262 }
11263
11264
11265
11266
11267 /* @obsolete ajGraphxySet
11268 ** @rename ajGraphxySetDevicetype
11269 */
ajGraphxySet(AjPGraph thys,const AjPStr type)11270 __deprecated AjBool ajGraphxySet(AjPGraph thys, const AjPStr type)
11271 {
11272 return ajGraphxySetDevicetype(thys, type);
11273 }
11274
11275
11276
11277
11278 /* @obsolete ajGraphxySetMaxMin
11279 ** @rename ajGraphxySetMinmax
11280 */
ajGraphxySetMaxMin(AjPGraph thys,float xmin,float xmax,float ymin,float ymax)11281 __deprecated void ajGraphxySetMaxMin(AjPGraph thys,float xmin,float xmax,
11282 float ymin,float ymax)
11283 {
11284 ajGraphxySetMinmax(thys, xmin, xmax, ymin, ymax);
11285 return;
11286 }
11287
11288
11289
11290
11291 /* @obsolete ajGraphxyCheckMaxMin
11292 ** @rename ajGraphxySetRanges
11293 */
ajGraphxyCheckMaxMin(AjPGraph thys)11294 __deprecated void ajGraphxyCheckMaxMin(AjPGraph thys)
11295 {
11296 ajGraphxySetRanges(thys);
11297 return;
11298 }
11299
11300
11301
11302
11303 /* @obsolete ajGraphxySetXEnd
11304 ** @rename ajGraphxySetXendF
11305 */
11306
ajGraphxySetXEnd(AjPGraph thys,float val)11307 __deprecated void ajGraphxySetXEnd(AjPGraph thys, float val)
11308 {
11309 ajGraphxySetXendF(thys, val);
11310 return;
11311 }
11312
11313
11314
11315
11316 /* @obsolete ajGraphxySetXRangeII
11317 ** @rename ajGraphxySetXrangeII
11318 */
11319
ajGraphxySetXRangeII(AjPGraph thys,ajint start,ajint end)11320 __deprecated void ajGraphxySetXRangeII(AjPGraph thys, ajint start, ajint end)
11321 {
11322 ajGraphxySetXrangeII(thys, start, end);
11323
11324 return;
11325 }
11326
11327
11328
11329
11330 /* @obsolete ajGraphxySetXStart
11331 ** @rename ajGraphxySetXstartF
11332 */
11333
ajGraphxySetXStart(AjPGraph thys,float val)11334 __deprecated void ajGraphxySetXStart(AjPGraph thys, float val)
11335 {
11336 ajGraphxySetXstartF(thys, val);
11337 return;
11338 }
11339
11340
11341
11342
11343 /* @obsolete ajGraphxySetYEnd
11344 ** @rename ajGraphxySetYendF
11345 */
11346
ajGraphxySetYEnd(AjPGraph thys,float val)11347 __deprecated void ajGraphxySetYEnd(AjPGraph thys, float val)
11348 {
11349 ajGraphxySetYendF(thys, val);
11350 return;
11351 }
11352
11353
11354
11355
11356 /* @obsolete ajGraphxySetYRangeII
11357 ** @rename ajGraphxySetYrangeII
11358 */
11359
ajGraphxySetYRangeII(AjPGraph thys,ajint start,ajint end)11360 __deprecated void ajGraphxySetYRangeII(AjPGraph thys, ajint start, ajint end)
11361
11362 {
11363 ajGraphxySetYrangeII(thys, start, end);
11364 return;
11365 }
11366
11367
11368
11369
11370 /* @obsolete ajGraphxySetYStart
11371 ** @rename ajGraphxySetYstartF
11372 */
11373
ajGraphxySetYStart(AjPGraph thys,float val)11374 __deprecated void ajGraphxySetYStart(AjPGraph thys, float val)
11375 {
11376 ajGraphxySetYstartF(thys, val);
11377 return;
11378 }
11379
11380
11381
11382
11383 /* @obsolete ajGraphxySetGaps
11384 ** @rename ajGraphxySetflagGaps
11385 */
ajGraphxySetGaps(AjPGraph thys,AjBool set)11386 __deprecated void ajGraphxySetGaps(AjPGraph thys, AjBool set)
11387 {
11388 ajGraphxySetflagGaps(thys, set);
11389 return;
11390 }
11391
11392
11393
11394
11395 /* @obsolete ajGraphxySetOverLap
11396 ** @rename ajGraphxySetflagOverlay
11397 */
ajGraphxySetOverLap(AjPGraph thys,AjBool overlap)11398 __deprecated void ajGraphxySetOverLap(AjPGraph thys, AjBool overlap)
11399 {
11400 ajGraphxySetflagOverlay(thys, overlap);
11401 return;
11402 }
11403
11404
11405
11406
11407 /* @obsolete ajGraphxySetCirclePoints
11408 ** @rename ajGraphxyShowPointsCircle
11409 */
ajGraphxySetCirclePoints(AjPGraph thys,AjBool set)11410 __deprecated void ajGraphxySetCirclePoints(AjPGraph thys, AjBool set)
11411 {
11412 ajGraphxyShowPointsCircle(thys, set);
11413 return;
11414 }
11415
11416
11417
11418
11419 /* @obsolete ajGraphxySetJoinPoints
11420 ** @rename ajGraphxyShowPointsJoin
11421 */
ajGraphxySetJoinPoints(AjPGraph thys,AjBool set)11422 __deprecated void ajGraphxySetJoinPoints(AjPGraph thys, AjBool set)
11423 {
11424 ajGraphSetFlag(thys, AJGRAPH_JOINPOINTS, set);
11425
11426 return;
11427 }
11428
11429
11430
11431
11432 /* @obsolete ajGraphxySetYRight
11433 ** @rename ajGraphxyShowRaxis
11434 */
11435
ajGraphxySetYRight(AjPGraph thys,AjBool set)11436 __deprecated void ajGraphxySetYRight(AjPGraph thys, AjBool set)
11437 {
11438 ajGraphxyShowRaxis(thys, set);
11439 return;
11440 }
11441
11442
11443
11444
11445 /* @obsolete ajGraphxySetXTop
11446 ** @rename ajGraphxyShowUaxis
11447 */
11448
ajGraphxySetXTop(AjPGraph thys,AjBool set)11449 __deprecated void ajGraphxySetXTop(AjPGraph thys, AjBool set)
11450 {
11451 ajGraphxyShowUaxis(thys,set);
11452 return;
11453 }
11454
11455
11456
11457
11458 /* @obsolete ajGraphxySetXLabelTop
11459 ** @rename ajGraphxyShowUnum
11460 */
11461
ajGraphxySetXLabelTop(AjPGraph thys,AjBool set)11462 __deprecated void ajGraphxySetXLabelTop(AjPGraph thys, AjBool set)
11463 {
11464 ajGraphxyShowUnum(thys, set);
11465 return;
11466 }
11467
11468
11469
11470
11471 /* @obsolete ajGraphxySetXBottom
11472 ** @rename ajGraphxyShowXaxis
11473 */
11474
ajGraphxySetXBottom(AjPGraph thys,AjBool set)11475 __deprecated void ajGraphxySetXBottom(AjPGraph thys, AjBool set)
11476 {
11477 ajGraphxyShowXaxis(thys,set);
11478 return;
11479 }
11480
11481
11482
11483
11484 /* @obsolete ajGraphxySetXGrid
11485 ** @rename ajGraphxyShowXgrid
11486 */
11487
ajGraphxySetXGrid(AjPGraph thys,AjBool set)11488 __deprecated void ajGraphxySetXGrid(AjPGraph thys, AjBool set)
11489 {
11490 ajGraphxyShowXgrid(thys, set);
11491 return;
11492 }
11493
11494
11495
11496
11497 /* @obsolete ajGraphxySetXInvTicks
11498 ** @rename ajGraphxyShowXinvert
11499 */
11500
ajGraphxySetXInvTicks(AjPGraph thys,AjBool set)11501 __deprecated void ajGraphxySetXInvTicks(AjPGraph thys, AjBool set)
11502 {
11503 ajGraphxyShowXinvert(thys, set);
11504 return;
11505 }
11506
11507
11508
11509
11510 /* @obsolete ajGraphxySetXLabel
11511 ** @rename ajGraphxyShowXlabel
11512 */
11513
ajGraphxySetXLabel(AjPGraph thys,AjBool set)11514 __deprecated void ajGraphxySetXLabel(AjPGraph thys, AjBool set)
11515 {
11516 ajGraphxyShowXlabel(thys, set);
11517 return;
11518 }
11519
11520
11521
11522
11523 /* @obsolete ajGraphxySetXTick
11524 ** @rename ajGraphxyShowXtick
11525 */
11526
ajGraphxySetXTick(AjPGraph thys,AjBool set)11527 __deprecated void ajGraphxySetXTick(AjPGraph thys, AjBool set)
11528 {
11529 ajGraphxyShowXtick(thys, set);
11530 return;
11531 }
11532
11533
11534
11535
11536 /* @obsolete ajGraphxySetYLeft
11537 ** @rename ajGraphxyShowYaxis
11538 */
ajGraphxySetYLeft(AjPGraph thys,AjBool set)11539 __deprecated void ajGraphxySetYLeft(AjPGraph thys, AjBool set)
11540 {
11541 ajGraphxyShowYaxis(thys, set);
11542 return;
11543 }
11544
11545
11546
11547
11548 /* @obsolete ajGraphxySetYGrid
11549 ** @rename ajGraphxyShowYgrid
11550 */
11551
ajGraphxySetYGrid(AjPGraph thys,AjBool set)11552 __deprecated void ajGraphxySetYGrid(AjPGraph thys, AjBool set)
11553 {
11554 ajGraphxyShowYgrid(thys, set);
11555 return;
11556 }
11557
11558
11559
11560
11561 /* @obsolete ajGraphxySetYInvTicks
11562 ** @rename ajGraphxyShowYinvert
11563 */
11564
ajGraphxySetYInvTicks(AjPGraph thys,AjBool set)11565 __deprecated void ajGraphxySetYInvTicks(AjPGraph thys, AjBool set)
11566 {
11567 ajGraphxyShowYinvert(thys,set);
11568 return;
11569 }
11570
11571
11572
11573
11574 /* @obsolete ajGraphxySetYLabel
11575 ** @rename ajGraphxyShowYlabel
11576 */
11577
ajGraphxySetYLabel(AjPGraph thys,AjBool set)11578 __deprecated void ajGraphxySetYLabel(AjPGraph thys, AjBool set)
11579 {
11580 ajGraphxyShowYlabel(thys, set);
11581 return;
11582 }
11583
11584
11585
11586
11587 /* @obsolete ajGraphxySetYLabelLeft
11588 ** @rename ajGraphxyShowYnum
11589 */
11590
ajGraphxySetYLabelLeft(AjPGraph thys,AjBool set)11591 __deprecated void ajGraphxySetYLabelLeft(AjPGraph thys, AjBool set)
11592 {
11593 ajGraphxyShowYnum(thys, set);
11594 return;
11595 }
11596
11597
11598
11599
11600 /* @obsolete ajGraphxySetYTick
11601 ** @rename ajGrapxyhShowYtick
11602 */
11603
ajGraphxySetYTick(AjPGraph thys,AjBool set)11604 __deprecated void ajGraphxySetYTick(AjPGraph thys, AjBool set)
11605 {
11606
11607 ajGraphxyShowYtick(thys, set);
11608 return;
11609 }
11610
11611
11612
11613
11614 /* @obsolete ajGraphdataSetLineType
11615 ** @rename ajGraphdataSetLinetype
11616 */
ajGraphdataSetLineType(AjPGraphdata graphdata,ajint type)11617 __deprecated void ajGraphdataSetLineType(AjPGraphdata graphdata, ajint type)
11618 {
11619 ajGraphdataSetLinetype(graphdata, type);
11620 return;
11621 }
11622
11623
11624
11625
11626 /* @obsolete ajGraphdataSetMaxMin
11627 ** @rename ajGraphdataSetMinmax
11628 */
ajGraphdataSetMaxMin(AjPGraphdata graphdata,float xmin,float xmax,float ymin,float ymax)11629 __deprecated void ajGraphdataSetMaxMin(AjPGraphdata graphdata,
11630 float xmin, float xmax,
11631 float ymin, float ymax)
11632 {
11633 ajGraphdataSetMinmax(graphdata, xmin, xmax, ymin, ymax);
11634 return;
11635 }
11636
11637
11638
11639
11640 /* @obsolete ajGraphdataSetSubTitleC
11641 ** @rename ajGraphdataSetSubtitleC
11642 */
ajGraphdataSetSubTitleC(AjPGraphdata graphdata,const char * title)11643 __deprecated void ajGraphdataSetSubTitleC(AjPGraphdata graphdata,
11644 const char *title)
11645 {
11646 ajStrAssignEmptyC(&graphdata->subtitle,title);
11647
11648 return;
11649 }
11650
11651
11652
11653
11654 /* @obsolete ajGraphdataSetSubTitle
11655 ** @rename ajGraphdataSetSubtitleS
11656 */
ajGraphdataSetSubTitle(AjPGraphdata graphdata,const AjPStr title)11657 __deprecated void ajGraphdataSetSubTitle(AjPGraphdata graphdata,
11658 const AjPStr title)
11659 {
11660 ajGraphdataSetSubtitleS(graphdata, title);
11661 return;
11662 }
11663
11664
11665
11666
11667 /* @obsolete ajGraphdataSetTitle
11668 ** @rename ajGraphdataSetTitleS
11669 */
ajGraphdataSetTitle(AjPGraphdata graphdata,const AjPStr title)11670 __deprecated void ajGraphdataSetTitle(AjPGraphdata graphdata,
11671 const AjPStr title)
11672 {
11673 ajGraphdataSetTitleS(graphdata, title);
11674 return;
11675 }
11676
11677
11678
11679
11680 /* @obsolete ajGraphdataSetMaxima
11681 ** @rename ajGraphdataSetTruescale
11682 */
ajGraphdataSetMaxima(AjPGraphdata graphdata,float xmin,float xmax,float ymin,float ymax)11683 __deprecated void ajGraphdataSetMaxima(AjPGraphdata graphdata,
11684 float xmin, float xmax,
11685 float ymin, float ymax)
11686 {
11687 ajGraphdataSetTruescale(graphdata, xmin, xmax, ymin, ymax);
11688 return;
11689 }
11690
11691
11692
11693
11694 /* @obsolete ajGraphdataSetXTitleC
11695 ** @rename ajGraphdataSetXlabelC
11696 */
ajGraphdataSetXTitleC(AjPGraphdata graphdata,const char * title)11697 __deprecated void ajGraphdataSetXTitleC(AjPGraphdata graphdata,
11698 const char* title)
11699 {
11700 ajGraphdataSetXlabelC(graphdata, title);
11701 return;
11702 }
11703
11704
11705
11706
11707 /* @obsolete ajGraphdataSetXTitle
11708 ** @rename ajGraphdataSetXlabelS
11709 */
ajGraphdataSetXTitle(AjPGraphdata graphdata,const AjPStr title)11710 __deprecated void ajGraphdataSetXTitle(AjPGraphdata graphdata,
11711 const AjPStr title)
11712 {
11713 ajStrAssignEmptyS(&graphdata->xaxis,title);
11714
11715 return;
11716 }
11717
11718
11719
11720
11721 /* @obsolete ajGraphdataSetYTitleC
11722 ** @rename ajGraphdataSetYlabelC
11723 */
ajGraphdataSetYTitleC(AjPGraphdata graphdata,const char * title)11724 __deprecated void ajGraphdataSetYTitleC(AjPGraphdata graphdata,
11725 const char* title)
11726 {
11727 ajGraphdataSetYlabelC(graphdata, title);
11728 return;
11729 }
11730
11731
11732
11733
11734 /* @obsolete ajGraphdataSetYTitle
11735 ** @rename ajGraphdataSetYlabelS
11736 */
ajGraphdataSetYTitle(AjPGraphdata graphdata,const AjPStr title)11737 __deprecated void ajGraphdataSetYTitle(AjPGraphdata graphdata,
11738 const AjPStr title)
11739 {
11740 ajStrAssignEmptyS(&graphdata->yaxis,title);
11741
11742 return;
11743 }
11744
11745
11746
11747
11748 /* @obsolete ajGraphdataSetXY
11749 ** @rename ajGraphdataAddXY
11750 */
ajGraphdataSetXY(AjPGraphdata graphdata,const float * x,const float * y)11751 __deprecated void ajGraphdataSetXY(AjPGraphdata graphdata,
11752 const float *x,const float *y)
11753 {
11754 ajGraphdataAddXY(graphdata, x, y);
11755 return;
11756 }
11757
11758
11759
11760
11761 /* @obsolete ajGraphdataAddLine
11762 ** @rename ajGraphdataAddposLine
11763 */
ajGraphdataAddLine(AjPGraphdata graphdata,float x,float y,float x2,float y2,ajint colour)11764 __deprecated void ajGraphdataAddLine(AjPGraphdata graphdata, float x, float y,
11765 float x2, float y2, ajint colour)
11766 {
11767 ajGraphdataAddposLine(graphdata, x, y, x2, y2, colour);
11768 return;
11769 }
11770
11771
11772
11773
11774 /* @obsolete ajGraphdataAddRect
11775 ** @rename ajGraphdataAddposRect
11776 */
ajGraphdataAddRect(AjPGraphdata graphdata,float x,float y,float x2,float y2,ajint colour,ajint fill)11777 __deprecated void ajGraphdataAddRect(AjPGraphdata graphdata,
11778 float x, float y,
11779 float x2, float y2,
11780 ajint colour, ajint fill)
11781 {
11782 ajGraphdataAddposRect(graphdata, x, y, x2, y2, colour, fill);
11783 return;
11784 }
11785
11786
11787
11788
11789 /* @obsolete ajGraphdataAddText
11790 ** @rename ajGraphdataAddposTextC
11791 */
11792
ajGraphdataAddText(AjPGraphdata graphdata,float x,float y,ajint colour,const char * txt)11793 __deprecated void ajGraphdataAddText(AjPGraphdata graphdata, float x, float y,
11794 ajint colour, const char *txt)
11795 {
11796 ajGraphdataAddposTextC(graphdata, x, y, colour, txt);
11797 return;
11798 }
11799
11800
11801
11802
11803 /* @obsolete ajGraphdataAddTextScale
11804 ** @rename ajGraphdataAddposTextScaleC
11805 */
ajGraphdataAddTextScale(AjPGraphdata graphdata,float xx1,float yy1,ajint colour,float scale,const char * txt)11806 __deprecated void ajGraphdataAddTextScale(AjPGraphdata graphdata,
11807 float xx1, float yy1,
11808 ajint colour, float scale, const char *txt)
11809 {
11810 ajGraphdataAddposTextScaleC(graphdata, xx1, yy1, colour, scale, txt);
11811 return;
11812 }
11813
11814
11815
11816
11817 /* @obsolete ajGraphInfo
11818 ** @rename ajGraphicsGetOutfiles
11819 */
11820
ajGraphInfo(AjPList * files)11821 __deprecated ajint ajGraphInfo(AjPList* files)
11822 {
11823 return ajGraphicsGetOutfiles(files);
11824 }
11825
11826
11827
11828
11829 /* @obsolete ajGraphListDevices
11830 ** @rename ajGraphicsListDevices
11831 */
ajGraphListDevices(AjPList list)11832 __deprecated void ajGraphListDevices (AjPList list)
11833 {
11834 ajGraphicsListDevices(list);
11835 return;
11836 }
11837
11838
11839
11840
11841 /* @obsolete ajGraphPrintType
11842 ** @rename ajGraphicsPrintType
11843 */
ajGraphPrintType(AjPFile outf,AjBool full)11844 __deprecated void ajGraphPrintType(AjPFile outf, AjBool full)
11845 {
11846 ajGraphicsPrintType(outf, full);
11847 return;
11848 }
11849
11850
11851
11852
11853 /* @obsolete ajGraphxyDumpDevices
11854 ** @rename ajGraphicsxyDumpDevices
11855 */
ajGraphxyDumpDevices(void)11856 __deprecated void ajGraphxyDumpDevices(void)
11857 {
11858 ajGraphicsxyDumpDevices();
11859 return;
11860 }
11861
11862
11863
11864
11865 /* @obsolete ajGraphxyListDevices
11866 ** @rename ajGraphicsxyListDevices
11867 */
ajGraphxyListDevices(AjPList list)11868 __deprecated void ajGraphxyListDevices (AjPList list)
11869 {
11870 ajGraphicsxyListDevices(list);
11871 return;
11872 }
11873 #endif
11874
11875
11876 #endif /* !NO_PLOT */
11877