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