1 /*============================================================================
2 PGSBOX 7.7 - draw curvilinear coordinate axes for PGPLOT.
3 Copyright (C) 1997-2021, Mark Calabretta
4
5 This file is part of PGSBOX.
6
7 PGSBOX is free software: you can redistribute it and/or modify it under the
8 terms of the GNU Lesser General Public License as published by the Free
9 Software Foundation, either version 3 of the License, or (at your option)
10 any later version.
11
12 PGSBOX is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
15 more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with PGSBOX. If not, see http://www.gnu.org/licenses.
19
20 Author: Mark Calabretta, Australia Telescope National Facility, CSIRO.
21 http://www.atnf.csiro.au/people/Mark.Calabretta
22 $Id: cpgsbox.c,v 7.7 2021/07/12 06:36:49 mcalabre Exp $
23 *===========================================================================*/
24
25 #include <string.h>
26 #include "cpgsbox.h"
27
28 // Fortran name mangling.
29 #include <wcsconfig_f77.h>
30 #define pgsbok_ F77_FUNC(pgsbok, PGSBOK)
31 #define pglbok_ F77_FUNC(pglbok, PGLBOK)
32
33 void pgsbok_(const float blc[2], const float trc[2], char idents[3][80],
34 const char opt[2], const int *labctl, const int *labden,
35 const int ci[7], const int gcode[2], const double *tiklen,
36 const int *ng1, const double *grid1, const int *ng2,
37 const double *grid2, const int *doeq, nlfunc_t nlfunc,
38 const int *nlc, const int *nli, const int *nld, char *nlcprm,
39 int *nliprm, double *nldprm, const int *nc, int *ic,
40 double cache[][4], int *ierr);
41
42 void pglbok_(char idents[3][80], const char opt[2], const int *labctl,
43 const int *labden, const int ci[7], const int gcode[2],
44 const double *tiklen, const int *ng1, const double *grid1,
45 const int *ng2, const double *grid2, const int *doeq,
46 const int *nc, int *ic, double cache[][4], int *ierr);
47
cpgsbox(const float blc[2],const float trc[2],char (* idents)[80],const char opt[2],int labctl,int labden,const int ci[7],const int gcode[2],double tiklen,int ng1,const double * grid1,int ng2,const double * grid2,int doeq,nlfunc_t nlfunc,int nlc,int nli,int nld,char nlcprm[],int nliprm[],double nldprm[],int nc,int * ic,double cache[][4],int * ierr)48 void cpgsbox(
49 const float blc[2],
50 const float trc[2],
51 char (*idents)[80],
52 const char opt[2],
53 int labctl,
54 int labden,
55 const int ci[7],
56 const int gcode[2],
57 double tiklen,
58 int ng1,
59 const double *grid1,
60 int ng2,
61 const double *grid2,
62 int doeq,
63 nlfunc_t nlfunc,
64 int nlc,
65 int nli,
66 int nld,
67 char nlcprm[],
68 int nliprm[],
69 double nldprm[],
70 int nc,
71 int *ic,
72 double cache[][4],
73 int *ierr)
74
75 {
76 // Convert variable length strings to fixed-length char arrays.
77 char ids[3][80];
78 for (int j = 0; j < 3; j++) {
79 if (strlen(idents[j]) > 80) {
80 strncpy(ids[j], idents[j], 80);
81 } else {
82 strcpy(ids[j], idents[j]);
83 for (int k = strlen(idents[j]); k < 80; k++) {
84 ids[j][k] = ' ';
85 }
86 }
87 }
88
89 pgsbok_(blc, trc, ids, opt, &labctl, &labden, ci, gcode, &tiklen, &ng1,
90 grid1, &ng2, grid2, &doeq, nlfunc, &nlc, &nli, &nld, nlcprm, nliprm,
91 nldprm, &nc, ic, cache, ierr);
92 return;
93 }
94
95 //----------------------------------------------------------------------------
96
cpglbox(char (* idents)[80],const char opt[2],int labctl,int labden,const int ci[7],const int gcode[2],double tiklen,int ng1,const double * grid1,int ng2,const double * grid2,int doeq,int nc,int * ic,double cache[][4],int * ierr)97 void cpglbox(
98 char (*idents)[80],
99 const char opt[2],
100 int labctl,
101 int labden,
102 const int ci[7],
103 const int gcode[2],
104 double tiklen,
105 int ng1,
106 const double *grid1,
107 int ng2,
108 const double *grid2,
109 int doeq,
110 int nc,
111 int *ic,
112 double cache[][4],
113 int *ierr)
114
115 {
116 // Convert variable length strings to fixed-length char arrays.
117 char ids[3][80];
118 for (int j = 0; j < 3; j++) {
119 if (strlen(idents[j]) > 80) {
120 strncpy(ids[j], idents[j], 80);
121 } else {
122 strcpy(ids[j], idents[j]);
123 for (int k = strlen(idents[j]); k < 80; k++) {
124 ids[j][k] = ' ';
125 }
126 }
127 }
128
129 pglbok_(ids, opt, &labctl, &labden, ci, gcode, &tiklen, &ng1, grid1, &ng2,
130 grid2, &doeq, &nc, ic, cache, ierr);
131 return;
132 }
133