b641da667c2692c3c44c903165251b5e40253d83
[alexxy/gromacs.git] / include / xvgr.h
1 /*
2  * 
3  *                This source code is part of
4  * 
5  *                 G   R   O   M   A   C   S
6  * 
7  *          GROningen MAchine for Chemical Simulations
8  * 
9  *                        VERSION 3.2.0
10  * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12  * Copyright (c) 2001-2004, The GROMACS development team,
13  * check out http://www.gromacs.org for more information.
14
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * as published by the Free Software Foundation; either version 2
18  * of the License, or (at your option) any later version.
19  * 
20  * If you want to redistribute modifications, please consider that
21  * scientific software is very special. Version control is crucial -
22  * bugs must be traceable. We will be happy to consider code for
23  * inclusion in the official distribution, but derived work must not
24  * be called official GROMACS. Details are found in the README & COPYING
25  * files - if they are missing, get the official version at www.gromacs.org.
26  * 
27  * To help us fund GROMACS development, we humbly ask that you cite
28  * the papers on the package - you can find them in the top README file.
29  * 
30  * For more info, check our website at http://www.gromacs.org
31  * 
32  * And Hey:
33  * Gromacs Runs On Most of All Computer Systems
34  */
35
36 #ifndef _xvgr_h
37 #define _xvgr_h
38
39 #include "visibility.h"
40 #include "sysstuff.h"
41 #include "typedefs.h"
42 #include "viewit.h"
43
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47
48 /***************************************************
49  *            XVGR   DEFINITIONS
50  ***************************************************/
51 enum {
52   elNone, elSolid, elDotted, elDashed, 
53   elLongDashed, elDotDashed, elNR
54 };
55 /* xvgr line-styles */
56
57 enum {  
58   ecWhite, ecFrank, ecBlack=ecFrank,
59   ecRed, ecGreen, ecBlue, ecYellow, ecBrown, ecGray, 
60   ecPurple, ecLightBlue, ecViolet, ecHolland, ecLila, ecDarkGray, 
61   ecAquamarine, ecOlive, ecNR
62 };
63 /* xvgr line-colors */
64
65 enum {
66   eppNone, eppColor, eppPattern, eppNR
67 };
68 /* xvgr pattern type */
69
70 enum {
71   evView, evWorld, evNR
72 };
73 /* view type */
74
75 /***************************************************
76  *            XVGR   ROUTINES
77  ***************************************************/
78
79 /* Strings such as titles, lables and legends can contain escape sequences
80  * for formatting. Currently supported are:
81  * \s : start subscript
82  * \S : start superscript
83  * \N : end sub/superscript
84  * \symbol : where symbol is the full name of a greek letter
85  *           (see the xvgrstr function in xvgr.c for the full list)
86  *           when starting with a capital, a capital symbol will be printed,
87  *           note that symbol does not need to be followed by a space
88  * \8 : (deprecated) start symbol font
89  * \4 : (deprecated) end symbol font
90  */
91
92 GMX_LIBGMX_EXPORT
93 gmx_bool output_env_get_print_xvgr_codes(const output_env_t oenv);
94 /* Returns if we should print xmgrace or xmgr codes */
95
96 enum {
97   exvggtNONE, exvggtXNY, exvggtXYDY, exvggtXYDYDY, exvggtNR
98 };
99
100 GMX_LIBGMX_EXPORT
101 void xvgr_header(FILE *fp,const char *title,const char *xaxis,
102                         const char *yaxis,int exvg_graph_type,
103                         const output_env_t oenv);
104 /* In most cases you want to use xvgropen_type, which does the same thing
105  * but takes a filename and opens it.
106  */
107
108 GMX_LIBGMX_EXPORT
109 FILE *xvgropen_type(const char *fn,const char *title,const char *xaxis,
110                            const char *yaxis,int exvg_graph_type,
111                            const output_env_t oenv);
112 /* Open a file, and write a title, and axis-labels in Xvgr format
113  * or write nothing when oenv specifies so.
114  * The xvgr graph type enum is defined above.
115  */
116
117 GMX_LIBGMX_EXPORT
118 FILE *xvgropen(const char *fn,const char *title,const char *xaxis,
119                       const char *yaxis,const output_env_t oenv);
120 /* Calls xvgropen_type with graph type xvggtXNY. */
121
122 /* Close xvgr file, and clean up internal file buffers correctly */
123 GMX_LIBGMX_EXPORT
124 void xvgrclose(FILE *fp);
125
126 GMX_LIBGMX_EXPORT
127 void xvgr_subtitle(FILE *out,const char *subtitle,
128                           const output_env_t oenv);
129 /* Set the subtitle in xvgr */
130
131 GMX_LIBGMX_EXPORT
132 void xvgr_view(FILE *out,real xmin,real ymin,real xmax,real ymax,        
133                       const output_env_t oenv);
134 /* Set the view in xvgr */
135
136 GMX_LIBGMX_EXPORT
137 void xvgr_world(FILE *out,real xmin,real ymin,real xmax,real ymax,
138                        const output_env_t oenv);
139 /* Set the world in xvgr */
140
141 GMX_LIBGMX_EXPORT
142 void xvgr_legend(FILE *out,int nsets,const char** setnames,
143                  const output_env_t oenv);
144 /* Make a legend box, and also modifies the view to make room for the legend */
145
146
147 GMX_LIBGMX_EXPORT
148 void xvgr_new_dataset(FILE *out, 
149                       int nr_first, int nsets, const char **setnames, 
150                       const output_env_t oenv);
151 /* End the previous data set(s) and start new one(s). 
152     nr_first = the global set number of the first new set (or 0 if no legend)
153     nsets = the number of sets (or 0 if no legends)
154     setnames = the set names (or NULL if no legends)
155 */
156
157 GMX_LIBGMX_EXPORT
158 void xvgr_line_props(FILE *out,int NrSet,int LineStyle,int LineColor,
159                             const output_env_t oenv);
160 /* Set xvgr line styles and colors */
161
162 void xvgr_box(FILE *out,
163                      int LocType,
164                      real xmin,real ymin,real xmax,real ymax,
165                      int LineStyle,int LineWidth,int LineColor,
166                      int BoxFill,int BoxColor,int BoxPattern,
167                      const output_env_t oenv);
168 /* Make a box */
169
170 GMX_LIBGMX_EXPORT
171 int read_xvg_legend(const char *fn,double ***y,int *ny,
172                            char **subtitle,char ***legend);
173 /* Read an xvg file for post processing. The number of rows is returned
174  * fn is the filename, y is a pointer to a 2D array (to be allocated by
175  * the routine) ny is the number of columns (including X if appropriate).
176  * If subtitle!=NULL, read the subtitle (when present),
177  * the subtitle string will be NULL when not present.
178  * If legend!=NULL, read the legends for the sets (when present),
179  * 0 is the first y legend, the legend string will be NULL when not present.
180  */
181
182 GMX_LIBGMX_EXPORT
183 int read_xvg(const char *fn,double ***y,int *ny);
184 /* As read_xvg_legend, but does not read legends. */
185  
186 GMX_LIBGMX_EXPORT
187 void write_xvg(const char *fn,const char *title,int nx,int ny,real **y,
188                       const char** leg, const output_env_t oenv);
189 /* Write a two D array (y) of dimensions nx rows times
190  * ny columns to a file. If leg != NULL it will be written too.
191  */
192
193
194 /* This function reads ascii (xvg) files and extracts the data sets to a 
195  * two dimensional array which is returned.
196  */
197 GMX_LIBGMX_EXPORT
198 real **read_xvg_time(const char *fn,
199                             gmx_bool bHaveT,
200                             gmx_bool bTB,real tb,
201                             gmx_bool bTE,real te,
202                             int nsets_in,int *nset,int *nval,
203                             real *dt,real **t);
204 #ifdef __cplusplus
205 }
206 #endif
207
208 #endif  /* _xvgr_h */