b6f7f633dd34a8bb07bab33ef1e3039e833ae669
[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 "sysstuff.h"
40 #include "typedefs.h"
41 #include "viewit.h"
42
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46
47 /***************************************************
48  *            XVGR   DEFINITIONS
49  ***************************************************/
50 enum {
51   elNone, elSolid, elDotted, elDashed, 
52   elLongDashed, elDotDashed, elNR
53 };
54 /* xvgr line-styles */
55
56 enum {  
57   ecWhite, ecFrank, ecBlack=ecFrank,
58   ecRed, ecGreen, ecBlue, ecYellow, ecBrown, ecGray, 
59   ecPurple, ecLightBlue, ecViolet, ecHolland, ecLila, ecDarkGray, 
60   ecAquamarine, ecOlive, ecNR
61 };
62 /* xvgr line-colors */
63
64 enum {
65   eppNone, eppColor, eppPattern, eppNR
66 };
67 /* xvgr pattern type */
68
69 enum {
70   evView, evWorld, evNR
71 };
72 /* view type */
73
74 /***************************************************
75  *            XVGR   ROUTINES
76  ***************************************************/
77
78 /* Strings such as titles, lables and legends can contain escape sequences
79  * for formatting. Currently supported are:
80  * \s : start subscript
81  * \S : start superscript
82  * \N : end sub/superscript
83  * \symbol : where symbol is the full name of a greek letter
84  *           (see the xvgrstr function in xvgr.c for the full list)
85  *           when starting with a capital, a capital symbol will be printed,
86  *           note that symbol does not need to be followed by a space
87  * \8 : (deprecated) start symbol font
88  * \4 : (deprecated) end symbol font
89  */
90
91 bool output_env_get_print_xvgr_codes(const output_env_t oenv);
92 /* Returns if we should print xmgrace or xmgr codes */
93
94 enum {
95   exvggtNONE, exvggtXNY, exvggtXYDY, exvggtXYDYDY, exvggtNR
96 };
97
98 void xvgr_header(FILE *fp,const char *title,const char *xaxis,
99                         const char *yaxis,int exvg_graph_type,
100                         const output_env_t oenv);
101 /* In most cases you want to use xvgropen_type, which does the same thing
102  * but takes a filename and opens it.
103  */
104
105 FILE *xvgropen_type(const char *fn,const char *title,const char *xaxis,
106                            const char *yaxis,int exvg_graph_type,
107                            const output_env_t oenv);
108 /* Open a file, and write a title, and axis-labels in Xvgr format
109  * or write nothing when oenv specifies so.
110  * The xvgr graph type enum is defined above.
111  */
112
113 FILE *xvgropen(const char *fn,const char *title,const char *xaxis,
114                       const char *yaxis,const output_env_t oenv);
115 /* Calls xvgropen_type with graph type xvggtXNY. */
116
117 /* Close xvgr file, and clean up internal file buffers correctly */
118 void xvgrclose(FILE *fp);
119
120 void xvgr_subtitle(FILE *out,const char *subtitle,
121                           const output_env_t oenv);
122 /* Set the subtitle in xvgr */
123
124 void xvgr_view(FILE *out,real xmin,real ymin,real xmax,real ymax,        
125                       const output_env_t oenv);
126 /* Set the view in xvgr */
127
128 void xvgr_world(FILE *out,real xmin,real ymin,real xmax,real ymax,
129                        const output_env_t oenv);
130 /* Set the world in xvgr */
131
132 void xvgr_legend(FILE *out,int nsets,const char** setnames,
133                         const output_env_t oenv);
134 /* Make a legend box, and also modifies the view to make room for the legend */
135
136
137 void xvgr_new_dataset(FILE *out, const output_env_t oenv);
138 /* End the previous data set(s) and start new one(s). */
139
140 void xvgr_line_props(FILE *out,int NrSet,int LineStyle,int LineColor,
141                             const output_env_t oenv);
142 /* Set xvgr line styles and colors */
143
144 void xvgr_box(FILE *out,
145                      int LocType,
146                      real xmin,real ymin,real xmax,real ymax,
147                      int LineStyle,int LineWidth,int LineColor,
148                      int BoxFill,int BoxColor,int BoxPattern,
149                      const output_env_t oenv);
150 /* Make a box */
151
152 int read_xvg_legend(const char *fn,double ***y,int *ny,
153                            char **subtitle,char ***legend);
154 /* Read an xvg file for post processing. The number of rows is returned
155  * fn is the filename, y is a pointer to a 2D array (to be allocated by
156  * the routine) ny is the number of columns (including X if appropriate).
157  * If subtitle!=NULL, read the subtitle (when present),
158  * the subtitle string will be NULL when not present.
159  * If legend!=NULL, read the legends for the sets (when present),
160  * 0 is the first y legend, the legend string will be NULL when not present.
161  */
162
163 int read_xvg(const char *fn,double ***y,int *ny);
164 /* As read_xvg_legend, but does not read legends. */
165  
166 void write_xvg(const char *fn,const char *title,int nx,int ny,real **y,
167                       const char** leg, const output_env_t oenv);
168 /* Write a two D array (y) of dimensions nx rows times
169  * ny columns to a file. If leg != NULL it will be written too.
170  */
171
172
173 /* This function reads ascii (xvg) files and extracts the data sets to a 
174  * two dimensional array which is returned.
175  */
176 real **read_xvg_time(const char *fn,
177                             bool bHaveT,
178                             bool bTB,real tb,
179                             bool bTE,real te,
180                             int nsets_in,int *nset,int *nval,
181                             real *dt,real **t);
182 #ifdef __cplusplus
183 }
184 #endif
185
186 #endif  /* _xvgr_h */